Package Exports
- agents-js
- agents-js/tools
Readme
agents-js
A powerful JavaScript library for building and orchestrating AI agents with OpenAI's GPT models.
📦 Packages
This monorepo contains two packages:
- agents-js - Core library for building AI agents
- agents-playground - Interactive web UI for testing agents
Quick Start
Install Core Library
npm install agents-jsInstall Playground
npm install -g agents-playgroundOr use directly:
npx agents-playground ./my-agents.jsFeatures
agents-js
- 🤖 Multi-Agent Orchestration - Coordinate multiple specialized agents
- 🔄 Automatic Agent Transfers - Seamless handoffs between agents
- 🛠️ Pre-built Tools - Web search, calculations, time, and more
- 📊 Token Tracking - Monitor costs and usage
- 🔐 Session Management - Persistent conversations
- ⚡ Streaming Support - Real-time responses
- 🎯 Lifecycle Hooks - beforeModel, afterModel, beforeTool, afterTool
- ✅ Tool Confirmation - Human-in-the-loop for sensitive operations
- 📝 TypeScript Support - Full type definitions
agents-playground
- 🎨 Premium UI - Clean, modern interface
- 💬 Markdown Support - Rich text formatting
- 🔄 Agent Transfer Tracking - See which agents handle your requests
- 📊 Real-time Analytics - Token usage and cost tracking
- 🔧 Environment Management - Configure API keys on-the-fly
- 📱 Responsive Design - Works on desktop and mobile
Documentation
See individual package READMEs for detailed documentation:
Example
const { Agent, AgentController } = require("agents-js");
const { serperSearch, calculate } = require("agents-js/tools");
const OpenAI = require("openai");
const client = new OpenAI({
apiKey: process.env.OPENAI_API_KEY,
});
const controller = new AgentController(client);
const agent = new Agent({
name: "Assistant",
model: "gpt-4o-mini",
instructions:
"You are a helpful assistant with web search and calculation capabilities.",
functions: [serperSearch, calculate],
});
const response = await controller.run(agent, [
{ role: "user", content: "What's the weather in Tokyo?" },
]);
console.log(response.messages[response.messages.length - 1].content);
// Export for playground
module.exports = { agent };Development
# Install dependencies for all packages
npm run install:all
# Test with playground
cd packages/agents-playground
npm start ../path/to/your/agents.jsLicense
MIT © Vikrant Guleria