A JavaScript-based framework for building AI agents, inspired by React's design principles. The framework provides a declarative, component-based approach to building agents while maintaining simplicity and extensibility.
- Declarative programming style
- Component-based architecture
- Easy onboarding and setup
- Composable components
- Simple component interfaces
- Props-based data flow
- Hook-based extensibility
- Functional programming approach
- Explicit state management
- Abstracted LLM context window management
- XML/JSX-based agent definitions
- Clone the repository:
git clone https://github.com/yourusername/agent-starter-kit.git
cd agent-starter-kit- Install dependencies using npm:
npm install- Set up your environment variables:
cp .env.example .env
# Edit .env and add your Anthropic API key- Create an agent definition in XML format (e.g.,
test.xml):
<TestAgent systemPrompt="You are a helpful assistant that can answer questions and help with tasks.">
<TimeTool />
<WeatherTool />
</TestAgent>- Create your tools (e.g., in
tools/weather.js):
const weather = async (attributes, inputs) => {
const weather = 'sunny, 70 degrees, and 5 mph winds';
return weather;
};
weather.input_schema = {
type: 'object',
properties: {
location: { type: 'string', description: 'The location to get the weather in' }
}
};
weather.description = 'Get the weather in a given location';
module.exports = { weather };- Run your agent:
const agentParser = require('./agentParser');
// Parse and create the agent
const agent = agentParser.parseAgentFileByName('test');
const response = await agent.run("What's the weather and time in San Francisco?");
console.log(response);Tools are the building blocks of your agent's capabilities. Each tool is a JavaScript module that exports:
- An async function that implements the tool's functionality
- An
input_schemaobject defining the expected inputs - A
descriptionstring explaining the tool's purpose
Example tool structure:
const myTool = async (attributes, inputs) => {
// Tool implementation
return result;
};
myTool.input_schema = {
type: 'object',
properties: {
// Define your input parameters here
}
};
myTool.description = 'Description of what the tool does';
module.exports = { myTool };To use a tool in your agent, simply include it in your XML definition:
<MyAgent>
<MyTool />
</MyAgent>The foundation of the framework is the AgentRuntime class, which implements the basic agent formula:
agent = while loop + llm + tools
-
Constructor
- Initializes with default Anthropic model
- No system prompt by default
- No tools by default
-
Core Methods
run(prompt: string) -> Promise<string>: Main execution method
Check out the examples/ directory for more usage examples. Also, check out index.js file for a more complete example.
Contributions are welcome! Please feel free to submit a Pull Request.
MIT
