Arcaelas Agent Documentation¶
Welcome to @arcaelas/agent - a production-ready TypeScript library for building sophisticated AI agents with multi-provider support, reactive contexts, and intelligent tool orchestration.
What is Arcaelas Agent?¶
@arcaelas/agent enables you to create AI agents that scale from simple chatbots to complex organizational workflows through:
- π Multi-Provider Support - Automatic failover between OpenAI, Anthropic, Groq, Ollama, and custom APIs
- ποΈ Reactive Architecture - Hierarchical context inheritance with automatic state management
- π οΈ Tool Ecosystem - Built-in HTTP tools and seamless custom function integration
- π Full TypeScript - Complete type safety with discriminated unions and generics
Quick Start¶
Installation¶
Your First Agent¶
import { Agent, Rule } from '@arcaelas/agent';
import OpenAI from 'openai';
const openai = new OpenAI({
apiKey: process.env.OPENAI_API_KEY
});
const assistant = new Agent({
rules: [new Rule("Helpful assistant for daily tasks.")],
providers: [
async (ctx) => {
return await openai.chat.completions.create({
model: "gpt-4",
messages: ctx.messages.map(m => ({
role: m.role,
content: m.content
}))
});
}
]
});
const [messages, success] = await assistant.call("What's the weather like today?");
Continue with the full tutorial β
Core Architecture¶
Agent¶
Central orchestrator combining identity, behavior, tools, and AI providers.
const agent = new Agent({
rules: [
new Rule("Customer support specialist."),
professional_rule,
],
tools: [search_tool, database_tool],
providers: [openai_provider]
});
Context¶
Hierarchical state management with automatic inheritance.
const parent_context = new Context({
metadata: new Metadata().set("company", "Acme Corp"),
rules: [new Rule("Maintain professional tone")]
});
const child_context = new Context({
context: parent_context, // Inherits from parent
metadata: new Metadata().set("department", "Sales")
});
Tools¶
Extensible functions for external integrations.
const weather_tool = new Tool("get_weather", {
description: "Get current weather for any city",
parameters: {
city: "City name",
units: "Temperature units (celsius/fahrenheit)"
},
func: async (agent, { city, units }) => {
return `Weather in ${city}: Sunny, 24Β°C`;
}
});
Documentation¶
π Guides¶
- Getting Started - Complete tutorial
- Core Concepts - Architecture overview
- Providers - Multi-provider setup
- Best Practices - Production patterns
π§ API Reference¶
- Agent - Main orchestrator
- Context - State management
- Metadata - Key-value store
- Tool - Custom functions
- Rule - Behavioral guidelines
- Message - Conversation messages
- Providers - Provider functions
- Built-in Tools - TimeTool, RemoteTool, AgentTool, AskTool, ChoiceTool, SleepTool
π‘ Examples¶
- Basic Agent - Simple chatbot
- Multi-Provider - Resilient setup
- Custom Tools - Creating tools
- Context Inheritance - Enterprise patterns
- Advanced Patterns - Complex scenarios
π Advanced¶
- Architecture - Internal design
- Performance - Optimization
- Troubleshooting - Common issues
- Migration Guide - Version upgrades
Requirements¶
- Node.js β₯ 16.0.0
- TypeScript β₯ 4.5.0 (optional)
Links¶
Ready to build intelligent AI agents? Start with the Getting Started Guide β