|
1 | | -# RiLiGar - Agents SDK for JavaScript |
| 1 | +# @riligar/agents-sdk |
2 | 2 |
|
3 | | - |
4 | | - |
5 | | - |
6 | | - |
| 3 | +RiLiGar Agents SDK - JavaScript framework for building intelligent AI agents with LLM support via OpenRouter, custom tools, and MCP integration. |
7 | 4 |
|
| 5 | +## 🚀 Installation |
8 | 6 |
|
9 | | -## About |
| 7 | +```bash |
| 8 | +npm install @riligar/agents-sdk |
| 9 | +``` |
10 | 10 |
|
11 | | -The RiLiGar Agents SDK is a robust JavaScript library designed to streamline the development of AI-powered applications through seamless integration with various Large Language Model (LLM) providers such as OpenAI, Google, and Anthropic, as well as Meta's Llama and ModelContext. Built with flexibility and extensibility in mind, it implements the Message Control Protocol (MCP) for reliable agent communication and management. |
| 11 | +## ⚡ Quick Example |
12 | 12 |
|
13 | | -### Key Features |
| 13 | +```javascript |
| 14 | +import { Agent, Logger, model, tool } from '@riligar/agents-sdk'; |
14 | 15 |
|
15 | | -- **Multi-Provider Support**: Built-in integrations with major LLM providers |
16 | | -- **Agent Management System**: Sophisticated agent lifecycle and interaction handling |
17 | | -- **Voice Integration**: Native support for voice-based interactions |
18 | | -- **Advanced Tracing**: Comprehensive system for monitoring and debugging agent behaviors |
19 | | -- **MCP Protocol**: Implementation of Message Control Protocol |
| 16 | +// 1. Configure your API Key |
| 17 | +const OPENROUTER_API_KEY = process.env.OPENROUTER_API_KEY; |
20 | 18 |
|
21 | | -## Resources |
| 19 | +// 2. Create logger and model |
| 20 | +const logger = new Logger({ level: 'info' }); |
| 21 | +const llm = model.create({ |
| 22 | + apiKey: OPENROUTER_API_KEY, |
| 23 | + logger: logger, |
| 24 | +}); |
22 | 25 |
|
23 | | -- [OpenAI](https://platform.openai.com) |
24 | | - - [Library](https://github.com/openai/openai-node) |
25 | | -- [Anthropic](https://console.anthropic.com/) |
26 | | - - [SDK](https://github.com/anthropics/anthropic-sdk-typescript) |
27 | | -- [Google](https://ai.google.dev/gemini-api/) |
28 | | - - [SDK](https://www.npmjs.com/package/@google/genai) |
29 | | -- [Meta](https://www.llama.com/) |
30 | | -- [Model Context Protocol](https://modelcontextprotocol.io) |
31 | | - - [Documentation](https://modelcontextprotocol.info/docs/) |
32 | | - - [TypeScript SDK](https://github.com/modelcontextprotocol/typescript-sdk) |
33 | | - - [Inspector](https://github.com/modelcontextprotocol/inspector) |
| 26 | +// 3. Define tools (optional) |
| 27 | +const tools = await tool.build( |
| 28 | + [ |
| 29 | + { |
| 30 | + type: 'local', |
| 31 | + id: 'greeting', |
| 32 | + description: 'Returns a personalized greeting', |
| 33 | + parameters: { |
| 34 | + type: 'object', |
| 35 | + properties: { |
| 36 | + name: { type: 'string', description: 'Person name' }, |
| 37 | + }, |
| 38 | + required: ['name'], |
| 39 | + }, |
| 40 | + executeFn: async ({ name }) => { |
| 41 | + return { message: `Hello, ${name}! 👋` }; |
| 42 | + }, |
| 43 | + }, |
| 44 | + ], |
| 45 | + { logger } |
| 46 | +); |
| 47 | + |
| 48 | +// 4. Create your agent |
| 49 | +const agent = new Agent({ |
| 50 | + name: 'Assistant', |
| 51 | + instructions: 'You are a friendly assistant who can greet people.', |
| 52 | + model: llm, |
| 53 | + tools: tools, |
| 54 | + logger: logger, |
| 55 | +}); |
34 | 56 |
|
| 57 | +// 5. Execute tasks |
| 58 | +const result = agent.run('Greet John'); |
| 59 | +const text = await result.text; |
| 60 | +console.log(text); // Agent response |
| 61 | +``` |
35 | 62 |
|
36 | | -## Installation |
| 63 | +## 🎯 Key Features |
37 | 64 |
|
38 | | -```bash |
39 | | -npm install @riligar/agents-sdk |
| 65 | +| Feature | Description | Example | |
| 66 | +| ----------------- | ------------------------------------------- | --------------------------------------------- | |
| 67 | +| **🤖 Agents** | Intelligent agents with custom instructions | `new Agent({ name, instructions, model })` | |
| 68 | +| **🔧 Tools** | Local tools and MCP integration | `tool.build([{ type: 'local', executeFn }])` | |
| 69 | +| **📝 Logging** | Contextual and configurable logging system | `new Logger({ level: 'info' })` | |
| 70 | +| **🛡️ Guardrails** | Input and output validation | `guardrails: { input: [...], output: [...] }` | |
| 71 | +| **🔄 Handoffs** | Transfer between agents | `{ type: 'agent', agent: otherAgent }` | |
| 72 | +| **📡 Streaming** | Real-time responses | `result.textStream` | |
| 73 | + |
| 74 | +## 🌐 Supported Models |
| 75 | + |
| 76 | +Via **OpenRouter** (configure `OPENROUTER_API_KEY`): |
| 77 | + |
| 78 | +- OpenAI (GPT-4, GPT-3.5) |
| 79 | +- Anthropic (Claude) |
| 80 | +- Google (Gemini) |
| 81 | +- Meta (Llama) |
| 82 | +- Perplexity, Cohere, etc. |
| 83 | + |
| 84 | +```javascript |
| 85 | +const llm = model.create({ |
| 86 | + modelName: 'openai/gpt-4', // or 'anthropic/claude-3', 'google/gemini-pro' |
| 87 | + apiKey: process.env.OPENROUTER_API_KEY, |
| 88 | + temperature: 0.7, |
| 89 | +}); |
40 | 90 | ``` |
41 | 91 |
|
42 | | -### MCP Protocol |
| 92 | +## 📚 Practical Examples |
| 93 | + |
| 94 | +| Example | File | Description | |
| 95 | +| -------------- | ----------------------- | ----------------------- | |
| 96 | +| **Basic** | `examples/hello.js` | Simple agent with tools | |
| 97 | +| **Guardrails** | `examples/guardrail.js` | Input/output validation | |
| 98 | +| **Handoffs** | `examples/handoffs.js` | Transfer between agents | |
| 99 | +| **MCP** | `examples/mcp/` | MCP server integration | |
43 | 100 |
|
44 | | -The RiLiGar Agents SDK implements the Message Control Protocol (MCP) for reliable agent communication and management. MCP is a secure and efficient protocol that ensures secure and reliable communication between agents and their environment. |
| 101 | +Run any example: |
45 | 102 |
|
46 | 103 | ```bash |
47 | | -npx -y @modelcontextprotocol/inspector npm start |
| 104 | +export OPENROUTER_API_KEY="your-key-here" |
| 105 | +node examples/hello.js |
48 | 106 | ``` |
49 | 107 |
|
50 | | -## Usage |
| 108 | +## 🔗 MCP Integration |
51 | 109 |
|
52 | | -```js |
53 | | -const agent = new Agent({ |
54 | | - name: "Assistant", |
55 | | - instructions: "You are a helpful assistant. Respond to the user's questions in a friendly and concise manner." |
56 | | -}); |
| 110 | +Connect automatically to MCP servers: |
57 | 111 |
|
58 | | -// console.log("Running agent Assistant (turn 1)"); |
59 | | -const result = await Runner.run(agent, "Hello, world! What can you do for me?"); |
60 | | -console.log("\nUser: Hello, world! What can you do for me?"); |
61 | | -console.log(`Assistant: ${result.finalOutput}`); |
| 112 | +```javascript |
| 113 | +const tools = await tool.build( |
| 114 | + [ |
| 115 | + { |
| 116 | + type: 'remote', |
| 117 | + serverUrl: 'http://localhost:3000', // MCP Server |
| 118 | + }, |
| 119 | + ], |
| 120 | + { logger } |
| 121 | +); |
62 | 122 | ``` |
63 | 123 |
|
64 | | -## License |
| 124 | +## 📄 License |
65 | 125 |
|
66 | | -This project is licensed under the [Apache-2.0](./LICENSE) license. |
| 126 | +Apache-2.0 |
0 commit comments