JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 10
  • Score
    100M100P100Q47690F
  • License MIT

A versatile JavaScript library for designing and managing intelligent agents capable of interacting with AI-driven chat models, leveraging OpenAI's GPT for dynamic conversations and task automation.

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:

Quick Start

Install Core Library

npm install agents-js

Install Playground

npm install -g agents-playground

Or use directly:

npx agents-playground ./my-agents.js

Features

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.js

License

MIT © Vikrant Guleria