agente-toolkit 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +211 -0
- package/dist/cjs/agents/calculator/CalculatorAgent.d.ts +10 -0
- package/dist/cjs/agents/calculator/CalculatorAgent.d.ts.map +1 -0
- package/dist/cjs/agents/index.d.ts +4 -0
- package/dist/cjs/agents/index.d.ts.map +1 -0
- package/dist/cjs/agents/manager/ManagerAgent.d.ts +34 -0
- package/dist/cjs/agents/manager/ManagerAgent.d.ts.map +1 -0
- package/dist/cjs/agents/weather/WeatherAgent.d.ts +10 -0
- package/dist/cjs/agents/weather/WeatherAgent.d.ts.map +1 -0
- package/dist/cjs/core/agent/Agent.d.ts +25 -0
- package/dist/cjs/core/agent/Agent.d.ts.map +1 -0
- package/dist/cjs/core/agent/Agent.js +95 -0
- package/dist/cjs/core/agent/Agent.js.map +1 -0
- package/dist/cjs/core/agent/AgentRegistry.d.ts +28 -0
- package/dist/cjs/core/agent/AgentRegistry.d.ts.map +1 -0
- package/dist/cjs/core/agent/AgentRegistry.js +74 -0
- package/dist/cjs/core/agent/AgentRegistry.js.map +1 -0
- package/dist/cjs/core/agent/index.d.ts +5 -0
- package/dist/cjs/core/agent/index.d.ts.map +1 -0
- package/dist/cjs/core/agent/types/AgentMetadata.d.ts +54 -0
- package/dist/cjs/core/agent/types/AgentMetadata.d.ts.map +1 -0
- package/dist/cjs/core/agent/types/RunOptions.d.ts +7 -0
- package/dist/cjs/core/agent/types/RunOptions.d.ts.map +1 -0
- package/dist/cjs/core/execution/ExecutionEngine.d.ts +44 -0
- package/dist/cjs/core/execution/ExecutionEngine.d.ts.map +1 -0
- package/dist/cjs/core/execution/ExecutionEngine.js +110 -0
- package/dist/cjs/core/execution/ExecutionEngine.js.map +1 -0
- package/dist/cjs/core/execution/PlanValidator.d.ts +20 -0
- package/dist/cjs/core/execution/PlanValidator.d.ts.map +1 -0
- package/dist/cjs/core/execution/PlanValidator.js +85 -0
- package/dist/cjs/core/execution/PlanValidator.js.map +1 -0
- package/dist/cjs/core/execution/Planner.d.ts +25 -0
- package/dist/cjs/core/execution/Planner.d.ts.map +1 -0
- package/dist/cjs/core/execution/Planner.js +200 -0
- package/dist/cjs/core/execution/Planner.js.map +1 -0
- package/dist/cjs/core/execution/ReferenceResolver.d.ts +43 -0
- package/dist/cjs/core/execution/ReferenceResolver.d.ts.map +1 -0
- package/dist/cjs/core/execution/ReferenceResolver.js +174 -0
- package/dist/cjs/core/execution/ReferenceResolver.js.map +1 -0
- package/dist/cjs/core/execution/ResponseProcessor.d.ts +12 -0
- package/dist/cjs/core/execution/ResponseProcessor.d.ts.map +1 -0
- package/dist/cjs/core/execution/ResponseProcessor.js +40 -0
- package/dist/cjs/core/execution/ResponseProcessor.js.map +1 -0
- package/dist/cjs/core/execution/index.d.ts +8 -0
- package/dist/cjs/core/execution/index.d.ts.map +1 -0
- package/dist/cjs/core/execution/types/ExecutionPlan.d.ts +6 -0
- package/dist/cjs/core/execution/types/ExecutionPlan.d.ts.map +1 -0
- package/dist/cjs/core/execution/types/PlanStep.d.ts +9 -0
- package/dist/cjs/core/execution/types/PlanStep.d.ts.map +1 -0
- package/dist/cjs/core/execution/types/ValidationResult.d.ts +5 -0
- package/dist/cjs/core/execution/types/ValidationResult.d.ts.map +1 -0
- package/dist/cjs/core/memory/index.d.ts +3 -0
- package/dist/cjs/core/memory/index.d.ts.map +1 -0
- package/dist/cjs/core/memory/memory.d.ts +34 -0
- package/dist/cjs/core/memory/memory.d.ts.map +1 -0
- package/dist/cjs/core/memory/memory.js +112 -0
- package/dist/cjs/core/memory/memory.js.map +1 -0
- package/dist/cjs/core/tools/AgentTool.d.ts +9 -0
- package/dist/cjs/core/tools/AgentTool.d.ts.map +1 -0
- package/dist/cjs/core/tools/index.d.ts +3 -0
- package/dist/cjs/core/tools/index.d.ts.map +1 -0
- package/dist/cjs/core/tools/types/Tool.d.ts +13 -0
- package/dist/cjs/core/tools/types/Tool.d.ts.map +1 -0
- package/dist/cjs/index.d.ts +12 -0
- package/dist/cjs/index.d.ts.map +1 -0
- package/dist/cjs/index.js +31 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/infrastructure/adapters/base/base.d.ts +55 -0
- package/dist/cjs/infrastructure/adapters/base/base.d.ts.map +1 -0
- package/dist/cjs/infrastructure/adapters/base/base.js +10 -0
- package/dist/cjs/infrastructure/adapters/base/base.js.map +1 -0
- package/dist/cjs/infrastructure/adapters/claude/claudeAdapter.d.ts +37 -0
- package/dist/cjs/infrastructure/adapters/claude/claudeAdapter.d.ts.map +1 -0
- package/dist/cjs/infrastructure/adapters/claude/claudeAdapter.js +166 -0
- package/dist/cjs/infrastructure/adapters/claude/claudeAdapter.js.map +1 -0
- package/dist/cjs/infrastructure/adapters/index.d.ts +6 -0
- package/dist/cjs/infrastructure/adapters/index.d.ts.map +1 -0
- package/dist/cjs/infrastructure/adapters/ollama/ollamaAdapter.d.ts +29 -0
- package/dist/cjs/infrastructure/adapters/ollama/ollamaAdapter.d.ts.map +1 -0
- package/dist/cjs/infrastructure/adapters/ollama/ollamaAdapter.js +155 -0
- package/dist/cjs/infrastructure/adapters/ollama/ollamaAdapter.js.map +1 -0
- package/dist/cjs/infrastructure/adapters/openai/openaiAdapter.d.ts +29 -0
- package/dist/cjs/infrastructure/adapters/openai/openaiAdapter.d.ts.map +1 -0
- package/dist/cjs/infrastructure/adapters/openai/openaiAdapter.js +148 -0
- package/dist/cjs/infrastructure/adapters/openai/openaiAdapter.js.map +1 -0
- package/dist/cjs/infrastructure/adapters/utils/schemaUtils.d.ts +25 -0
- package/dist/cjs/infrastructure/adapters/utils/schemaUtils.d.ts.map +1 -0
- package/dist/cjs/infrastructure/adapters/utils/schemaUtils.js +59 -0
- package/dist/cjs/infrastructure/adapters/utils/schemaUtils.js.map +1 -0
- package/dist/cjs/infrastructure/logging/implementations/defaultLoggers.d.ts +34 -0
- package/dist/cjs/infrastructure/logging/implementations/defaultLoggers.d.ts.map +1 -0
- package/dist/cjs/infrastructure/logging/implementations/defaultLoggers.js +64 -0
- package/dist/cjs/infrastructure/logging/implementations/defaultLoggers.js.map +1 -0
- package/dist/cjs/infrastructure/logging/implementations/logger.d.ts +34 -0
- package/dist/cjs/infrastructure/logging/implementations/logger.d.ts.map +1 -0
- package/dist/cjs/infrastructure/logging/implementations/logger.js +126 -0
- package/dist/cjs/infrastructure/logging/implementations/logger.js.map +1 -0
- package/dist/cjs/infrastructure/logging/index.d.ts +4 -0
- package/dist/cjs/infrastructure/logging/index.d.ts.map +1 -0
- package/dist/cjs/infrastructure/logging/interfaces/AgentLogger.d.ts +29 -0
- package/dist/cjs/infrastructure/logging/interfaces/AgentLogger.d.ts.map +1 -0
- package/dist/cjs/infrastructure/logging/utils/loggerUtils.d.ts +24 -0
- package/dist/cjs/infrastructure/logging/utils/loggerUtils.d.ts.map +1 -0
- package/dist/cjs/infrastructure/logging/utils/loggerUtils.js +82 -0
- package/dist/cjs/infrastructure/logging/utils/loggerUtils.js.map +1 -0
- package/dist/cjs/infrastructure/monitoring/decorators/fallbackMonitoring.d.ts +9 -0
- package/dist/cjs/infrastructure/monitoring/decorators/fallbackMonitoring.d.ts.map +1 -0
- package/dist/cjs/infrastructure/monitoring/decorators/fallbackMonitoring.js +96 -0
- package/dist/cjs/infrastructure/monitoring/decorators/fallbackMonitoring.js.map +1 -0
- package/dist/cjs/infrastructure/monitoring/decorators/monitoring.d.ts +5 -0
- package/dist/cjs/infrastructure/monitoring/decorators/monitoring.d.ts.map +1 -0
- package/dist/cjs/infrastructure/monitoring/decorators/monitoring.js +90 -0
- package/dist/cjs/infrastructure/monitoring/decorators/monitoring.js.map +1 -0
- package/dist/cjs/infrastructure/monitoring/index.d.ts +4 -0
- package/dist/cjs/infrastructure/monitoring/index.d.ts.map +1 -0
- package/dist/cjs/infrastructure/monitoring/utils/executionClassification.d.ts +14 -0
- package/dist/cjs/infrastructure/monitoring/utils/executionClassification.d.ts.map +1 -0
- package/dist/cjs/infrastructure/monitoring/utils/executionClassification.js +76 -0
- package/dist/cjs/infrastructure/monitoring/utils/executionClassification.js.map +1 -0
- package/dist/cjs/node_modules/tslib/tslib.es6.js +38 -0
- package/dist/cjs/node_modules/tslib/tslib.es6.js.map +1 -0
- package/dist/cjs/shared/utils/jsonParser.d.ts +17 -0
- package/dist/cjs/shared/utils/jsonParser.d.ts.map +1 -0
- package/dist/cjs/shared/utils/jsonParser.js +47 -0
- package/dist/cjs/shared/utils/jsonParser.js.map +1 -0
- package/dist/esm/core/agent/Agent.js +93 -0
- package/dist/esm/core/agent/Agent.js.map +1 -0
- package/dist/esm/core/agent/AgentRegistry.js +67 -0
- package/dist/esm/core/agent/AgentRegistry.js.map +1 -0
- package/dist/esm/core/execution/ExecutionEngine.js +108 -0
- package/dist/esm/core/execution/ExecutionEngine.js.map +1 -0
- package/dist/esm/core/execution/PlanValidator.js +83 -0
- package/dist/esm/core/execution/PlanValidator.js.map +1 -0
- package/dist/esm/core/execution/Planner.js +198 -0
- package/dist/esm/core/execution/Planner.js.map +1 -0
- package/dist/esm/core/execution/ReferenceResolver.js +172 -0
- package/dist/esm/core/execution/ReferenceResolver.js.map +1 -0
- package/dist/esm/core/execution/ResponseProcessor.js +38 -0
- package/dist/esm/core/execution/ResponseProcessor.js.map +1 -0
- package/dist/esm/core/memory/memory.js +110 -0
- package/dist/esm/core/memory/memory.js.map +1 -0
- package/dist/esm/index.js +11 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/infrastructure/adapters/base/base.js +8 -0
- package/dist/esm/infrastructure/adapters/base/base.js.map +1 -0
- package/dist/esm/infrastructure/adapters/claude/claudeAdapter.js +164 -0
- package/dist/esm/infrastructure/adapters/claude/claudeAdapter.js.map +1 -0
- package/dist/esm/infrastructure/adapters/ollama/ollamaAdapter.js +153 -0
- package/dist/esm/infrastructure/adapters/ollama/ollamaAdapter.js.map +1 -0
- package/dist/esm/infrastructure/adapters/openai/openaiAdapter.js +146 -0
- package/dist/esm/infrastructure/adapters/openai/openaiAdapter.js.map +1 -0
- package/dist/esm/infrastructure/adapters/utils/schemaUtils.js +57 -0
- package/dist/esm/infrastructure/adapters/utils/schemaUtils.js.map +1 -0
- package/dist/esm/infrastructure/logging/implementations/defaultLoggers.js +60 -0
- package/dist/esm/infrastructure/logging/implementations/defaultLoggers.js.map +1 -0
- package/dist/esm/infrastructure/logging/implementations/logger.js +123 -0
- package/dist/esm/infrastructure/logging/implementations/logger.js.map +1 -0
- package/dist/esm/infrastructure/logging/utils/loggerUtils.js +80 -0
- package/dist/esm/infrastructure/logging/utils/loggerUtils.js.map +1 -0
- package/dist/esm/infrastructure/monitoring/decorators/fallbackMonitoring.js +93 -0
- package/dist/esm/infrastructure/monitoring/decorators/fallbackMonitoring.js.map +1 -0
- package/dist/esm/infrastructure/monitoring/decorators/monitoring.js +88 -0
- package/dist/esm/infrastructure/monitoring/decorators/monitoring.js.map +1 -0
- package/dist/esm/infrastructure/monitoring/utils/executionClassification.js +72 -0
- package/dist/esm/infrastructure/monitoring/utils/executionClassification.js.map +1 -0
- package/dist/esm/node_modules/tslib/tslib.es6.js +35 -0
- package/dist/esm/node_modules/tslib/tslib.es6.js.map +1 -0
- package/dist/esm/shared/utils/jsonParser.js +45 -0
- package/dist/esm/shared/utils/jsonParser.js.map +1 -0
- package/dist/types/index.d.ts +380 -0
- package/package.json +91 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Carlos Angarita
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
# agente-toolkit
|
|
2
|
+
|
|
3
|
+
A modern TypeScript library for building AI agents with **native tool calling** and intelligent orchestration patterns. Features both single-agent execution and intelligent manager agents that automatically discover and route to specialized agents.
|
|
4
|
+
|
|
5
|
+
## 🚀 Key Features
|
|
6
|
+
|
|
7
|
+
### **Native Tool Calling Support**
|
|
8
|
+
|
|
9
|
+
- **Claude Native Integration**: Leverages Anthropic's built-in tool calling for optimal performance
|
|
10
|
+
- **Automatic Fallback**: Gracefully falls back to traditional planning when native tools aren't available
|
|
11
|
+
- **Adapter-Driven**: Clean abstraction that works with multiple LLM providers
|
|
12
|
+
|
|
13
|
+
### **Intelligent Agent Architecture**
|
|
14
|
+
|
|
15
|
+
- **Single-agent execution** with memory, tools, and conversational responses
|
|
16
|
+
- **Intelligent Manager pattern** via enhanced `ManagerAgent` with dynamic agent discovery
|
|
17
|
+
- **Smart routing** using agent keywords, capabilities, and examples for better delegation
|
|
18
|
+
- **Clean Architecture**: Separated concerns with ExecutionEngine, ResponseProcessor, and Planner
|
|
19
|
+
|
|
20
|
+
### **Advanced Capabilities**
|
|
21
|
+
|
|
22
|
+
- **Conversational Responses**: Automatic post-processing converts raw tool results into natural language
|
|
23
|
+
- **Memory Management**: Context-aware memory with relevance scoring
|
|
24
|
+
- **Safety Guardrails**: Max steps, max duration, stop-on-first-error
|
|
25
|
+
- **Comprehensive Logging**: Detailed execution tracking with step-level timings
|
|
26
|
+
|
|
27
|
+
## 🏗️ Architecture Overview
|
|
28
|
+
|
|
29
|
+
```
|
|
30
|
+
Agent (Coordinator)
|
|
31
|
+
├── ExecutionEngine (Execution Orchestration)
|
|
32
|
+
│ ├── Native tool calling (when supported)
|
|
33
|
+
│ ├── Fallback to planned execution
|
|
34
|
+
│ └── ResponseProcessor (Conversational formatting)
|
|
35
|
+
└── Planner (Traditional step-by-step execution)
|
|
36
|
+
├── Plan creation and validation
|
|
37
|
+
└── Tool coordination and execution
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## 🎯 Enhanced ManagerAgent
|
|
41
|
+
|
|
42
|
+
The `ManagerAgent` intelligently manages any registered agents with automatic discovery:
|
|
43
|
+
|
|
44
|
+
- **Dynamic Discovery**: Automatically finds and creates tools for all registered agents
|
|
45
|
+
- **Keyword-based Routing**: Uses agent keywords to match user requests to appropriate agents
|
|
46
|
+
- **Capability Awareness**: Leverages task types, examples, and limitations for smart delegation
|
|
47
|
+
- **Native Tool Integration**: Benefits from both native tool calling and conversational responses
|
|
48
|
+
|
|
49
|
+
### Quick Example
|
|
50
|
+
|
|
51
|
+
```typescript
|
|
52
|
+
import {
|
|
53
|
+
ManagerAgent,
|
|
54
|
+
CalculatorAgent,
|
|
55
|
+
WeatherAgent,
|
|
56
|
+
registerAgent,
|
|
57
|
+
ClaudeAdapter,
|
|
58
|
+
} from 'agente-toolkit';
|
|
59
|
+
|
|
60
|
+
// Register agents with their metadata
|
|
61
|
+
registerAgent('calculator', new CalculatorAgent(), CalculatorAgent.metadata);
|
|
62
|
+
registerAgent('weather', new WeatherAgent(), WeatherAgent.metadata);
|
|
63
|
+
|
|
64
|
+
// Create adapter with native tool support
|
|
65
|
+
const adapter = new ClaudeAdapter(process.env.ANTHROPIC_API_KEY);
|
|
66
|
+
|
|
67
|
+
// Create intelligent manager that routes based on keywords and capabilities
|
|
68
|
+
const manager = new ManagerAgent(adapter);
|
|
69
|
+
// Now handles: "Calculate 15+27" → Calculator, "Weather in NYC" → Weather
|
|
70
|
+
// All with conversational responses!
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
## 📦 Install
|
|
74
|
+
|
|
75
|
+
Clone and install dependencies:
|
|
76
|
+
|
|
77
|
+
```bash
|
|
78
|
+
git clone <repository-url>
|
|
79
|
+
cd agente-toolkit
|
|
80
|
+
npm install
|
|
81
|
+
npm run build
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
## Programmatic Usage
|
|
85
|
+
|
|
86
|
+
### Basic Agent with Native Tool Support
|
|
87
|
+
|
|
88
|
+
```typescript
|
|
89
|
+
import { Agent, ClaudeAdapter } from 'agente-toolkit';
|
|
90
|
+
|
|
91
|
+
// Create agent with native tool calling support
|
|
92
|
+
const agent = new Agent();
|
|
93
|
+
agent.setPrompt('You are a helpful assistant.');
|
|
94
|
+
// agent.addTool(...) - Add your custom tools
|
|
95
|
+
|
|
96
|
+
// Claude adapter automatically uses native tools when available
|
|
97
|
+
const adapter = new ClaudeAdapter(process.env.ANTHROPIC_API_KEY);
|
|
98
|
+
|
|
99
|
+
// Get conversational responses regardless of execution method
|
|
100
|
+
const result = await agent.run('Hello!', adapter, {
|
|
101
|
+
maxSteps: 8,
|
|
102
|
+
stopOnFirstToolError: true,
|
|
103
|
+
});
|
|
104
|
+
console.log(result); // Natural, conversational response
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
### Intelligent Manager Agent with Native Tools
|
|
108
|
+
|
|
109
|
+
```typescript
|
|
110
|
+
import {
|
|
111
|
+
ManagerAgent,
|
|
112
|
+
CalculatorAgent,
|
|
113
|
+
WeatherAgent,
|
|
114
|
+
registerAgent,
|
|
115
|
+
ClaudeAdapter,
|
|
116
|
+
} from 'agente-toolkit';
|
|
117
|
+
|
|
118
|
+
// Register agents with rich metadata
|
|
119
|
+
const calc = new CalculatorAgent();
|
|
120
|
+
const weather = new WeatherAgent();
|
|
121
|
+
|
|
122
|
+
registerAgent('calculator', calc, CalculatorAgent.metadata);
|
|
123
|
+
registerAgent('weather', weather, WeatherAgent.metadata);
|
|
124
|
+
|
|
125
|
+
// Create adapter with native tool calling support
|
|
126
|
+
const adapter = new ClaudeAdapter(process.env.ANTHROPIC_API_KEY);
|
|
127
|
+
|
|
128
|
+
// Create manager that intelligently routes and provides conversational responses
|
|
129
|
+
const manager = new ManagerAgent(adapter);
|
|
130
|
+
|
|
131
|
+
// The manager intelligently routes with natural responses:
|
|
132
|
+
// "Calculate 15 + 27" → Calculator agent → "The result is 42"
|
|
133
|
+
// "Weather in Tokyo" → Weather agent → "Current weather in Tokyo is 22°C with clear skies"
|
|
134
|
+
// "What's 50 divided by 2?" → Calculator agent → "50 divided by 2 equals 25"
|
|
135
|
+
|
|
136
|
+
const result = await manager.run('What is 25 * 4?', adapter);
|
|
137
|
+
// Returns: "25 multiplied by 4 equals 100"
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
### Architecture Benefits
|
|
141
|
+
|
|
142
|
+
```typescript
|
|
143
|
+
// Native tool calling (when supported)
|
|
144
|
+
const result1 = await agent.run('Weather in Paris', claudeAdapter);
|
|
145
|
+
// → Uses Claude's native tools → Conversational response
|
|
146
|
+
|
|
147
|
+
// Automatic fallback (when native tools fail or unavailable)
|
|
148
|
+
const result2 = await agent.run('Weather in Paris', basicAdapter);
|
|
149
|
+
// → Uses traditional planner → Converts to conversational response
|
|
150
|
+
|
|
151
|
+
// Both paths provide natural, user-friendly responses!
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
### Custom Agent with Modern Architecture
|
|
155
|
+
|
|
156
|
+
```typescript
|
|
157
|
+
import { Agent, AgentRegistration, ClaudeAdapter } from 'agente-toolkit';
|
|
158
|
+
|
|
159
|
+
class CustomAgent extends Agent {
|
|
160
|
+
static readonly metadata: AgentRegistration = {
|
|
161
|
+
metadata: {
|
|
162
|
+
id: 'custom',
|
|
163
|
+
name: 'Custom Agent',
|
|
164
|
+
description: 'Handles custom tasks with native tool support',
|
|
165
|
+
categories: ['utility', 'custom'],
|
|
166
|
+
keywords: ['custom', 'utility', 'helper', 'process'],
|
|
167
|
+
priority: 3,
|
|
168
|
+
},
|
|
169
|
+
capabilities: {
|
|
170
|
+
taskTypes: ['data processing', 'utility functions'],
|
|
171
|
+
examples: ['Process this data', 'Help with utility task'],
|
|
172
|
+
limitations: ['Cannot handle real-time data'],
|
|
173
|
+
},
|
|
174
|
+
};
|
|
175
|
+
|
|
176
|
+
constructor() {
|
|
177
|
+
super();
|
|
178
|
+
this.setPrompt('I am a helpful custom utility agent.');
|
|
179
|
+
// Add custom tools that benefit from native calling...
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
// Register and use with ManagerAgent (gets native tool benefits automatically)
|
|
184
|
+
registerAgent('custom', new CustomAgent(), CustomAgent.metadata);
|
|
185
|
+
const manager = new ManagerAgent(new ClaudeAdapter(process.env.ANTHROPIC_API_KEY));
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
## 🔧 Technical Highlights
|
|
189
|
+
|
|
190
|
+
### Execution Flow
|
|
191
|
+
|
|
192
|
+
1. **Agent receives request** → Memory retrieval → Context building
|
|
193
|
+
2. **ExecutionEngine decides** → Native tools (if supported) OR Traditional planner
|
|
194
|
+
3. **Native path**: Direct tool calling → Immediate conversational response
|
|
195
|
+
4. **Planned path**: Step-by-step execution → ResponseProcessor → Conversational response
|
|
196
|
+
5. **Result**: Always natural, user-friendly responses regardless of execution method
|
|
197
|
+
|
|
198
|
+
### Adapter Support
|
|
199
|
+
|
|
200
|
+
- **ClaudeAdapter**: Full native tool calling support with automatic fallback
|
|
201
|
+
- **Future adapters**: Can implement native tools or rely on traditional planning
|
|
202
|
+
- **Graceful degradation**: System works with any adapter capability level
|
|
203
|
+
|
|
204
|
+
## 📝 Notes
|
|
205
|
+
|
|
206
|
+
- **Native tool calling** provides faster, more natural interactions when available
|
|
207
|
+
- **Automatic fallback** ensures reliability across different model capabilities
|
|
208
|
+
- **Conversational responses** are generated for all execution paths
|
|
209
|
+
- **ManagerAgent** automatically benefits from native tools for all registered agents
|
|
210
|
+
- **Weather functions** call public APIs; ensure network access when using them
|
|
211
|
+
- **Verbose logging** (`--verbose`) shows detailed execution flow including native vs planned paths
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Agent } from '../../core/agent/Agent';
|
|
2
|
+
import { MemoryManager } from '../../core/memory/memory';
|
|
3
|
+
import { AgentRegistration } from '../../core/agent/types/AgentMetadata';
|
|
4
|
+
export declare class CalculatorAgent extends Agent {
|
|
5
|
+
static readonly metadata: AgentRegistration;
|
|
6
|
+
constructor(memoryManager?: MemoryManager);
|
|
7
|
+
getMetadata(): AgentRegistration;
|
|
8
|
+
private setupCalculatorTools;
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=CalculatorAgent.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CalculatorAgent.d.ts","sourceRoot":"","sources":["../../../../src/agents/calculator/CalculatorAgent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,wBAAwB,CAAC;AAC/C,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAEzD,OAAO,EAAE,iBAAiB,EAAE,MAAM,sCAAsC,CAAC;AAEzE,qBAAa,eAAgB,SAAQ,KAAK;IACxC,MAAM,CAAC,QAAQ,CAAC,QAAQ,EAAE,iBAAiB,CAgCzC;gBAEU,aAAa,CAAC,EAAE,aAAa;IAQzC,WAAW,IAAI,iBAAiB;IAIhC,OAAO,CAAC,oBAAoB;CA4C7B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/agents/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAC/D,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { Agent } from '../../core/agent/Agent';
|
|
2
|
+
import { MemoryManager } from '../../core/memory/memory';
|
|
3
|
+
import { ModelAdapter } from '../../infrastructure/adapters/base/base';
|
|
4
|
+
import { AgentRegistration } from '../../core/agent/types/AgentMetadata';
|
|
5
|
+
export interface ManagerAgentOptions {
|
|
6
|
+
/**
|
|
7
|
+
* Optional filter to only include agents from specific categories
|
|
8
|
+
*/
|
|
9
|
+
allowedCategories?: string[];
|
|
10
|
+
/**
|
|
11
|
+
* Maximum number of agents to register as tools (default: 10)
|
|
12
|
+
*/
|
|
13
|
+
maxAgents?: number;
|
|
14
|
+
/**
|
|
15
|
+
* Custom prompt override
|
|
16
|
+
*/
|
|
17
|
+
customPrompt?: string;
|
|
18
|
+
/**
|
|
19
|
+
* Whether to include detailed capability information in prompts
|
|
20
|
+
*/
|
|
21
|
+
includeDetailedCapabilities?: boolean;
|
|
22
|
+
}
|
|
23
|
+
export declare class ManagerAgent extends Agent {
|
|
24
|
+
constructor(adapter: ModelAdapter, memoryManager?: MemoryManager, options?: ManagerAgentOptions);
|
|
25
|
+
/**
|
|
26
|
+
* Static method to create a ManagerAgent with specific agents pre-registered
|
|
27
|
+
*/
|
|
28
|
+
static withAgents(adapter: ModelAdapter, agents: Array<{
|
|
29
|
+
name: string;
|
|
30
|
+
agent: Agent;
|
|
31
|
+
registration?: AgentRegistration;
|
|
32
|
+
}>, memoryManager?: MemoryManager, options?: ManagerAgentOptions): ManagerAgent;
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=ManagerAgent.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ManagerAgent.d.ts","sourceRoot":"","sources":["../../../../src/agents/manager/ManagerAgent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,wBAAwB,CAAC;AAC/C,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAEzD,OAAO,EAAE,YAAY,EAAE,MAAM,yCAAyC,CAAC;AAMvE,OAAO,EAAE,iBAAiB,EAAE,MAAM,sCAAsC,CAAC;AAEzE,MAAM,WAAW,mBAAmB;IAClC;;OAEG;IACH,iBAAiB,CAAC,EAAE,MAAM,EAAE,CAAC;IAE7B;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB;;OAEG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB;;OAEG;IACH,2BAA2B,CAAC,EAAE,OAAO,CAAC;CACvC;AAED,qBAAa,YAAa,SAAQ,KAAK;gBAEnC,OAAO,EAAE,YAAY,EACrB,aAAa,CAAC,EAAE,aAAa,EAC7B,OAAO,GAAE,mBAAwB;IA4HnC;;OAEG;IACH,MAAM,CAAC,UAAU,CACf,OAAO,EAAE,YAAY,EACrB,MAAM,EAAE,KAAK,CAAC;QACZ,IAAI,EAAE,MAAM,CAAC;QACb,KAAK,EAAE,KAAK,CAAC;QACb,YAAY,CAAC,EAAE,iBAAiB,CAAC;KAClC,CAAC,EACF,aAAa,CAAC,EAAE,aAAa,EAC7B,OAAO,GAAE,mBAAwB,GAChC,YAAY;CAUhB"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Agent } from '../../core/agent/Agent';
|
|
2
|
+
import { MemoryManager } from '../../core/memory/memory';
|
|
3
|
+
import { AgentRegistration } from '../../core/agent/types/AgentMetadata';
|
|
4
|
+
export declare class WeatherAgent extends Agent {
|
|
5
|
+
static readonly metadata: AgentRegistration;
|
|
6
|
+
constructor(memoryManager?: MemoryManager);
|
|
7
|
+
getMetadata(): AgentRegistration;
|
|
8
|
+
private setupWeatherTools;
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=WeatherAgent.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"WeatherAgent.d.ts","sourceRoot":"","sources":["../../../../src/agents/weather/WeatherAgent.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,wBAAwB,CAAC;AAE/C,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAEzD,OAAO,EAAE,iBAAiB,EAAE,MAAM,sCAAsC,CAAC;AAEzE,qBAAa,YAAa,SAAQ,KAAK;IACrC,MAAM,CAAC,QAAQ,CAAC,QAAQ,EAAE,iBAAiB,CAiCzC;gBAEU,aAAa,CAAC,EAAE,aAAa;IAQzC,WAAW,IAAI,iBAAiB;IAIhC,OAAO,CAAC,iBAAiB;CA+F1B"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { ModelAdapter } from '../../infrastructure/adapters/base/base';
|
|
2
|
+
import { MemoryManager, Memory } from '../memory/memory';
|
|
3
|
+
import { AgentLogger } from '../../infrastructure/logging/interfaces/AgentLogger';
|
|
4
|
+
import { Tool, Serializable } from '../tools/types/Tool';
|
|
5
|
+
import { RunOptions } from './types/RunOptions';
|
|
6
|
+
import { TSchema } from '@sinclair/typebox';
|
|
7
|
+
export declare class Agent {
|
|
8
|
+
private memoryManager;
|
|
9
|
+
private tools;
|
|
10
|
+
private prompt;
|
|
11
|
+
private executionEngine;
|
|
12
|
+
private logger;
|
|
13
|
+
private loggerUtils;
|
|
14
|
+
constructor(memoryManager?: MemoryManager, logger?: AgentLogger);
|
|
15
|
+
addTool<TParams extends TSchema, TResult extends Serializable = string>(tool: Tool<TParams, TResult>): void;
|
|
16
|
+
remember(message: string, type?: Memory['type'], importance?: number): void;
|
|
17
|
+
getMemory(): Memory[];
|
|
18
|
+
getMemoryCount(): number;
|
|
19
|
+
getRelevantMemories(context: string, maxCount?: number): Memory[];
|
|
20
|
+
setPrompt(prompt: string): void;
|
|
21
|
+
getPrompt(): string;
|
|
22
|
+
run(message: string, model: ModelAdapter, options?: RunOptions): Promise<string>;
|
|
23
|
+
private _executeDecisionCycle;
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=Agent.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Agent.d.ts","sourceRoot":"","sources":["../../../../src/core/agent/Agent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,yCAAyC,CAAC;AACvE,OAAO,EAAE,aAAa,EAA8B,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAErF,OAAO,EAAE,WAAW,EAAE,MAAM,qDAAqD,CAAC;AAGlF,OAAO,EAAE,IAAI,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAE5C,qBAAa,KAAK;IAChB,OAAO,CAAC,aAAa,CAAgB;IACrC,OAAO,CAAC,KAAK,CAAwB;IACrC,OAAO,CAAC,MAAM,CAAc;IAC5B,OAAO,CAAC,eAAe,CAAkB;IACzC,OAAO,CAAC,MAAM,CAAc;IAC5B,OAAO,CAAC,WAAW,CAAc;gBAErB,aAAa,CAAC,EAAE,aAAa,EAAE,MAAM,CAAC,EAAE,WAAW;IAO/D,OAAO,CAAC,OAAO,SAAS,OAAO,EAAE,OAAO,SAAS,YAAY,GAAG,MAAM,EACpE,IAAI,EAAE,IAAI,CAAC,OAAO,EAAE,OAAO,CAAC;IAK9B,QAAQ,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,GAAE,MAAM,CAAC,MAAM,CAAkB,EAAE,UAAU,SAAM,GAAG,IAAI;IASxF,SAAS,IAAI,MAAM,EAAE;IAIrB,cAAc,IAAI,MAAM;IAIxB,mBAAmB,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE;IAIjE,SAAS,CAAC,MAAM,EAAE,MAAM;IAIxB,SAAS,IAAI,MAAM;IAIb,GAAG,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,YAAY,EAAE,OAAO,GAAE,UAAe,GAAG,OAAO,CAAC,MAAM,CAAC;YAY5E,qBAAqB;CAkDpC"}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var memory = require('../memory/memory.js');
|
|
4
|
+
var ExecutionEngine = require('../execution/ExecutionEngine.js');
|
|
5
|
+
var defaultLoggers = require('../../infrastructure/logging/implementations/defaultLoggers.js');
|
|
6
|
+
var loggerUtils = require('../../infrastructure/logging/utils/loggerUtils.js');
|
|
7
|
+
|
|
8
|
+
class Agent {
|
|
9
|
+
constructor(memoryManager, logger) {
|
|
10
|
+
this.tools = [];
|
|
11
|
+
this.prompt = '';
|
|
12
|
+
this.memoryManager = memoryManager || new memory.SlidingWindowMemoryManager();
|
|
13
|
+
this.logger = logger || defaultLoggers.createDefaultLogger();
|
|
14
|
+
this.executionEngine = new ExecutionEngine.ExecutionEngine(this.logger);
|
|
15
|
+
this.loggerUtils = new loggerUtils.LoggerUtils(this.logger);
|
|
16
|
+
}
|
|
17
|
+
addTool(tool) {
|
|
18
|
+
this.tools.push(tool);
|
|
19
|
+
}
|
|
20
|
+
remember(message, type = 'conversation', importance = 0.5) {
|
|
21
|
+
this.memoryManager.addMemory({
|
|
22
|
+
type,
|
|
23
|
+
content: message,
|
|
24
|
+
importance,
|
|
25
|
+
});
|
|
26
|
+
this.loggerUtils.logMemoryOperation('add', { type, importance, contentLength: message.length });
|
|
27
|
+
}
|
|
28
|
+
getMemory() {
|
|
29
|
+
return this.memoryManager.getAllMemories();
|
|
30
|
+
}
|
|
31
|
+
getMemoryCount() {
|
|
32
|
+
return this.memoryManager.getMemoryCount();
|
|
33
|
+
}
|
|
34
|
+
getRelevantMemories(context, maxCount) {
|
|
35
|
+
return this.memoryManager.getRelevantMemories(context, maxCount);
|
|
36
|
+
}
|
|
37
|
+
setPrompt(prompt) {
|
|
38
|
+
this.prompt = prompt;
|
|
39
|
+
}
|
|
40
|
+
getPrompt() {
|
|
41
|
+
return this.prompt;
|
|
42
|
+
}
|
|
43
|
+
async run(message, model, options = {}) {
|
|
44
|
+
this.loggerUtils.logRunStart({
|
|
45
|
+
message: message.substring(0, 50) + '...',
|
|
46
|
+
options,
|
|
47
|
+
});
|
|
48
|
+
this.remember(message, 'conversation', 0.8);
|
|
49
|
+
const response = await this._executeDecisionCycle(message, model, options);
|
|
50
|
+
this.remember(`Agent response: ${response}`, 'conversation', 0.6);
|
|
51
|
+
this.loggerUtils.logRunEnd();
|
|
52
|
+
return response;
|
|
53
|
+
}
|
|
54
|
+
async _executeDecisionCycle(message, model, options) {
|
|
55
|
+
try {
|
|
56
|
+
const relevantMemories = this.memoryManager.getRelevantMemories(message, 5);
|
|
57
|
+
const memoryContext = relevantMemories.length > 0
|
|
58
|
+
? relevantMemories.map(m => `[${m.type}] ${m.content}`).join('\n')
|
|
59
|
+
: 'No relevant context available.';
|
|
60
|
+
this.logger.debug('Retrieved relevant memories', {
|
|
61
|
+
count: relevantMemories.length,
|
|
62
|
+
contextLength: memoryContext.length,
|
|
63
|
+
});
|
|
64
|
+
// Create execution context
|
|
65
|
+
const executionContext = {
|
|
66
|
+
message,
|
|
67
|
+
tools: this.tools,
|
|
68
|
+
memoryContext,
|
|
69
|
+
systemPrompt: this.prompt,
|
|
70
|
+
model,
|
|
71
|
+
options,
|
|
72
|
+
};
|
|
73
|
+
// Delegate to execution engine
|
|
74
|
+
const result = await this.executionEngine.execute(executionContext);
|
|
75
|
+
// Log the overall execution result
|
|
76
|
+
this.logger.debug('Agent execution completed', {
|
|
77
|
+
executionType: model.supportsNativeTools ? 'native' : 'planned',
|
|
78
|
+
resultLength: result.length,
|
|
79
|
+
});
|
|
80
|
+
// Remember the overall result
|
|
81
|
+
this.remember(`Agent processed request. Result: ${result}`, 'tool_result', 0.6);
|
|
82
|
+
return result;
|
|
83
|
+
}
|
|
84
|
+
catch (error) {
|
|
85
|
+
const errorMessage = `Execution failed: ${error instanceof Error ? error.message : String(error)}`;
|
|
86
|
+
this.logger.error('Agent execution failed', {
|
|
87
|
+
error: error instanceof Error ? error.message : String(error),
|
|
88
|
+
});
|
|
89
|
+
return errorMessage;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
exports.Agent = Agent;
|
|
95
|
+
//# sourceMappingURL=Agent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Agent.js","sources":["../../../../../src/core/agent/Agent.ts"],"sourcesContent":[null],"names":["SlidingWindowMemoryManager","createDefaultLogger","ExecutionEngine","LoggerUtils"],"mappings":";;;;;;;MAUa,KAAK,CAAA;IAQhB,WAAA,CAAY,aAA6B,EAAE,MAAoB,EAAA;QANvD,IAAA,CAAA,KAAK,GAAqB,EAAE;QAC5B,IAAA,CAAA,MAAM,GAAW,EAAE;QAMzB,IAAI,CAAC,aAAa,GAAG,aAAa,IAAI,IAAIA,iCAA0B,EAAE;AACtE,QAAA,IAAI,CAAC,MAAM,GAAG,MAAM,IAAIC,kCAAmB,EAAE;QAC7C,IAAI,CAAC,eAAe,GAAG,IAAIC,+BAAe,CAAC,IAAI,CAAC,MAAM,CAAC;QACvD,IAAI,CAAC,WAAW,GAAG,IAAIC,uBAAW,CAAC,IAAI,CAAC,MAAM,CAAC;IACjD;AAEA,IAAA,OAAO,CACL,IAA4B,EAAA;AAE5B,QAAA,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC;IACvB;IAEA,QAAQ,CAAC,OAAe,EAAE,IAAA,GAAuB,cAAc,EAAE,UAAU,GAAG,GAAG,EAAA;AAC/E,QAAA,IAAI,CAAC,aAAa,CAAC,SAAS,CAAC;YAC3B,IAAI;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AM,CAAC,KAAK,CACvD,EAAE;AACF,YAAA,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,wBAAwB,EAAE;AAC1C,gBAAA,KAAK,EAAE,KAAK,YAAY,KAAK,GAAG,KAAK,CAAC,OAAO,GAAG,MAAM,CAAC,KAAK,CAAC;AAC9D,aAAA,CAAC;AACF,YAAA,OAAO,YAAY;AACpB,QAAA;IACH;AACD;;;;"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Agent } from './Agent';
|
|
2
|
+
import { AgentRegistration } from './types/AgentMetadata';
|
|
3
|
+
interface RegisteredAgent {
|
|
4
|
+
agent: Agent;
|
|
5
|
+
registration: AgentRegistration;
|
|
6
|
+
}
|
|
7
|
+
export declare function registerAgent(name: string, agent: Agent, registration?: AgentRegistration): void;
|
|
8
|
+
export declare function getAgent(name: string): Agent | undefined;
|
|
9
|
+
export declare function getAgentRegistration(name: string): AgentRegistration | undefined;
|
|
10
|
+
export declare function getAllAgents(): Map<string, RegisteredAgent>;
|
|
11
|
+
export declare function findAgentsByCategory(category: string): Array<{
|
|
12
|
+
name: string;
|
|
13
|
+
agent: Agent;
|
|
14
|
+
registration: AgentRegistration;
|
|
15
|
+
}>;
|
|
16
|
+
export declare function findAgentsByKeywords(keywords: string[]): Array<{
|
|
17
|
+
name: string;
|
|
18
|
+
agent: Agent;
|
|
19
|
+
registration: AgentRegistration;
|
|
20
|
+
}>;
|
|
21
|
+
export declare function getAvailableAgents(): Array<{
|
|
22
|
+
name: string;
|
|
23
|
+
agent: Agent;
|
|
24
|
+
registration: AgentRegistration;
|
|
25
|
+
}>;
|
|
26
|
+
export declare function clearRegistry(): void;
|
|
27
|
+
export {};
|
|
28
|
+
//# sourceMappingURL=AgentRegistry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AgentRegistry.d.ts","sourceRoot":"","sources":["../../../../src/core/agent/AgentRegistry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAE1D,UAAU,eAAe;IACvB,KAAK,EAAE,KAAK,CAAC;IACb,YAAY,EAAE,iBAAiB,CAAC;CACjC;AAID,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,YAAY,CAAC,EAAE,iBAAiB,QAqBzF;AAED,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,KAAK,GAAG,SAAS,CAExD;AAED,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,MAAM,GAAG,iBAAiB,GAAG,SAAS,CAEhF;AAED,wBAAgB,YAAY,IAAI,GAAG,CAAC,MAAM,EAAE,eAAe,CAAC,CAE3D;AAED,wBAAgB,oBAAoB,CAClC,QAAQ,EAAE,MAAM,GACf,KAAK,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,KAAK,CAAC;IAAC,YAAY,EAAE,iBAAiB,CAAA;CAAE,CAAC,CAgBxE;AAED,wBAAgB,oBAAoB,CAClC,QAAQ,EAAE,MAAM,EAAE,GACjB,KAAK,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,KAAK,CAAC;IAAC,YAAY,EAAE,iBAAiB,CAAA;CAAE,CAAC,CAwBxE;AAED,wBAAgB,kBAAkB,IAAI,KAAK,CAAC;IAC1C,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,KAAK,CAAC;IACb,YAAY,EAAE,iBAAiB,CAAC;CACjC,CAAC,CAYD;AAED,wBAAgB,aAAa,SAE5B"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const registry = new Map();
|
|
4
|
+
function registerAgent(name, agent, registration) {
|
|
5
|
+
const defaultRegistration = {
|
|
6
|
+
metadata: {
|
|
7
|
+
id: name,
|
|
8
|
+
name: name,
|
|
9
|
+
description: `Agent: ${name}`,
|
|
10
|
+
categories: ['general'],
|
|
11
|
+
keywords: [name],
|
|
12
|
+
priority: 1,
|
|
13
|
+
enabled: true,
|
|
14
|
+
},
|
|
15
|
+
capabilities: {
|
|
16
|
+
taskTypes: ['general'],
|
|
17
|
+
examples: [],
|
|
18
|
+
},
|
|
19
|
+
};
|
|
20
|
+
registry.set(name, {
|
|
21
|
+
agent,
|
|
22
|
+
registration: registration || defaultRegistration,
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
function getAgent(name) {
|
|
26
|
+
var _a;
|
|
27
|
+
return (_a = registry.get(name)) === null || _a === void 0 ? void 0 : _a.agent;
|
|
28
|
+
}
|
|
29
|
+
function findAgentsByCategory(category) {
|
|
30
|
+
const results = [];
|
|
31
|
+
for (const [name, registered] of registry.entries()) {
|
|
32
|
+
if (registered.registration.metadata.categories.includes(category) &&
|
|
33
|
+
registered.registration.metadata.enabled !== false) {
|
|
34
|
+
results.push({ name, agent: registered.agent, registration: registered.registration });
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
// Sort by priority (higher priority first)
|
|
38
|
+
return results.sort((a, b) => (b.registration.metadata.priority || 0) - (a.registration.metadata.priority || 0));
|
|
39
|
+
}
|
|
40
|
+
function findAgentsByKeywords(keywords) {
|
|
41
|
+
const results = [];
|
|
42
|
+
for (const [name, registered] of registry.entries()) {
|
|
43
|
+
if (registered.registration.metadata.enabled === false)
|
|
44
|
+
continue;
|
|
45
|
+
const agentKeywords = registered.registration.metadata.keywords.map(k => k.toLowerCase());
|
|
46
|
+
const hasMatchingKeyword = keywords.some(keyword => agentKeywords.some(agentKeyword => agentKeyword.includes(keyword.toLowerCase()) ||
|
|
47
|
+
keyword.toLowerCase().includes(agentKeyword)));
|
|
48
|
+
if (hasMatchingKeyword) {
|
|
49
|
+
results.push({ name, agent: registered.agent, registration: registered.registration });
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
// Sort by priority (higher priority first)
|
|
53
|
+
return results.sort((a, b) => (b.registration.metadata.priority || 0) - (a.registration.metadata.priority || 0));
|
|
54
|
+
}
|
|
55
|
+
function getAvailableAgents() {
|
|
56
|
+
const results = [];
|
|
57
|
+
for (const [name, registered] of registry.entries()) {
|
|
58
|
+
if (registered.registration.metadata.enabled !== false) {
|
|
59
|
+
results.push({ name, agent: registered.agent, registration: registered.registration });
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
return results.sort((a, b) => (b.registration.metadata.priority || 0) - (a.registration.metadata.priority || 0));
|
|
63
|
+
}
|
|
64
|
+
function clearRegistry() {
|
|
65
|
+
registry.clear();
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
exports.clearRegistry = clearRegistry;
|
|
69
|
+
exports.findAgentsByCategory = findAgentsByCategory;
|
|
70
|
+
exports.findAgentsByKeywords = findAgentsByKeywords;
|
|
71
|
+
exports.getAgent = getAgent;
|
|
72
|
+
exports.getAvailableAgents = getAvailableAgents;
|
|
73
|
+
exports.registerAgent = registerAgent;
|
|
74
|
+
//# sourceMappingURL=AgentRegistry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AgentRegistry.js","sources":["../../../../../src/core/agent/AgentRegistry.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAQA,MAAM,QAAQ,GAAG,IAAI,GAAG,EAA2B;SAEnC,aAAa,CAAC,IAAY,EAAE,KAAY,EAAE,YAAgC,EAAA;AACxF,IAAA,MAAM,mBAAmB,GAAsB;AAC7C,QAAA,QAAQ,EAAE;AACR,YAAA,EAAE,EAAE,IAAI;AACR,YAAA,IAAI,EAAE,IAAI;YACV,WAAW,EAAE,CAAA,OAAA,EAAU,IAAI,CAAA,CAAE;YAC7B,UAAU,EAAE,CAAC,SAAS,CAAC;YACvB,QAAQ,EAAE,CAAC,IAAI,CAAC;AAChB,YAAA,QAAQ,EAAE,CAAC;AACX,YAAA,OAAO,EAAE,IAAI;AACd,SAAA;AACD,QAAA,YAAY,E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AAC,IAAI,CACjB,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,YAAY,CAAC,QAAQ,CAAC,QAAQ,IAAI,CAAC,KAAK,CAAC,CAAC,YAAY,CAAC,QAAQ,CAAC,QAAQ,IAAI,CAAC,CAAC,CAC5F;AACH;SAEgB,aAAa,GAAA;IAC3B,QAAQ,CAAC,KAAK,EAAE;AAClB;;;;;;;;;"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { Agent } from './Agent';
|
|
2
|
+
export { registerAgent, getAgent, getAvailableAgents, findAgentsByCategory, findAgentsByKeywords, clearRegistry, } from './AgentRegistry';
|
|
3
|
+
export type { AgentMetadata, AgentCapability, AgentRegistration } from './types/AgentMetadata';
|
|
4
|
+
export type { RunOptions } from './types/RunOptions';
|
|
5
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/core/agent/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,EACL,aAAa,EACb,QAAQ,EACR,kBAAkB,EAClB,oBAAoB,EACpB,oBAAoB,EACpB,aAAa,GACd,MAAM,iBAAiB,CAAC;AAGzB,YAAY,EAAE,aAAa,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC/F,YAAY,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
export interface AgentMetadata {
|
|
2
|
+
/**
|
|
3
|
+
* Unique identifier for the agent
|
|
4
|
+
*/
|
|
5
|
+
id: string;
|
|
6
|
+
/**
|
|
7
|
+
* Human-readable name for the agent
|
|
8
|
+
*/
|
|
9
|
+
name: string;
|
|
10
|
+
/**
|
|
11
|
+
* Description of what the agent does
|
|
12
|
+
*/
|
|
13
|
+
description: string;
|
|
14
|
+
/**
|
|
15
|
+
* Categories that this agent belongs to (e.g., "math", "weather", "search")
|
|
16
|
+
*/
|
|
17
|
+
categories: string[];
|
|
18
|
+
/**
|
|
19
|
+
* Keywords that can help identify when this agent should be used
|
|
20
|
+
*/
|
|
21
|
+
keywords: string[];
|
|
22
|
+
/**
|
|
23
|
+
* Priority level for this agent when multiple agents match a request
|
|
24
|
+
* Higher numbers = higher priority
|
|
25
|
+
*/
|
|
26
|
+
priority?: number;
|
|
27
|
+
/**
|
|
28
|
+
* Whether this agent is currently available for use
|
|
29
|
+
*/
|
|
30
|
+
enabled?: boolean;
|
|
31
|
+
/**
|
|
32
|
+
* Additional metadata that specific implementations might need
|
|
33
|
+
*/
|
|
34
|
+
custom?: Record<string, any>;
|
|
35
|
+
}
|
|
36
|
+
export interface AgentCapability {
|
|
37
|
+
/**
|
|
38
|
+
* What types of tasks this agent can handle
|
|
39
|
+
*/
|
|
40
|
+
taskTypes: string[];
|
|
41
|
+
/**
|
|
42
|
+
* Examples of questions/requests this agent can handle
|
|
43
|
+
*/
|
|
44
|
+
examples: string[];
|
|
45
|
+
/**
|
|
46
|
+
* Limitations or things this agent cannot do
|
|
47
|
+
*/
|
|
48
|
+
limitations?: string[];
|
|
49
|
+
}
|
|
50
|
+
export interface AgentRegistration {
|
|
51
|
+
metadata: AgentMetadata;
|
|
52
|
+
capabilities: AgentCapability;
|
|
53
|
+
}
|
|
54
|
+
//# sourceMappingURL=AgentMetadata.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AgentMetadata.d.ts","sourceRoot":"","sources":["../../../../../src/core/agent/types/AgentMetadata.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,aAAa;IAC5B;;OAEG;IACH,EAAE,EAAE,MAAM,CAAC;IAEX;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IAEb;;OAEG;IACH,WAAW,EAAE,MAAM,CAAC;IAEpB;;OAEG;IACH,UAAU,EAAE,MAAM,EAAE,CAAC;IAErB;;OAEG;IACH,QAAQ,EAAE,MAAM,EAAE,CAAC;IAEnB;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB;;OAEG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAElB;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CAC9B;AAED,MAAM,WAAW,eAAe;IAC9B;;OAEG;IACH,SAAS,EAAE,MAAM,EAAE,CAAC;IAEpB;;OAEG;IACH,QAAQ,EAAE,MAAM,EAAE,CAAC;IAEnB;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;CACxB;AAED,MAAM,WAAW,iBAAiB;IAChC,QAAQ,EAAE,aAAa,CAAC;IACxB,YAAY,EAAE,eAAe,CAAC;CAC/B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RunOptions.d.ts","sourceRoot":"","sources":["../../../../../src/core/agent/types/RunOptions.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,mBAAmB,CAAC,EAAE,MAAM,CAAC;CAC9B"}
|