Skip to content

maxdignan/Agent-Starter-Kit

Repository files navigation

Agent Starter Kit

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.

Agent Starter Kit

Features

  • 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

Installation

  1. Clone the repository:
git clone https://github.com/yourusername/agent-starter-kit.git
cd agent-starter-kit
  1. Install dependencies using npm:
npm install
  1. Set up your environment variables:
cp .env.example .env
# Edit .env and add your Anthropic API key

Quick Start

  1. 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>
  1. 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 };
  1. 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

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_schema object defining the expected inputs
  • A description string 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>

Core Components

AgentRuntime

The foundation of the framework is the AgentRuntime class, which implements the basic agent formula:

agent = while loop + llm + tools

Core Methods

  1. Constructor

    • Initializes with default Anthropic model
    • No system prompt by default
    • No tools by default
  2. Core Methods

    • run(prompt: string) -> Promise<string>: Main execution method

Examples

Check out the examples/ directory for more usage examples. Also, check out index.js file for a more complete example.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

MIT

About

A fun(ny), declarative, composable way to make agents

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published