@mcp-abap-adt/llm-agent 1.0.0 → 2.0.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/README.md +89 -477
- package/dist/agent.d.ts.map +1 -1
- package/dist/agent.js +2 -1
- package/dist/agent.js.map +1 -1
- package/dist/agents/anthropic-agent.d.ts +4 -3
- package/dist/agents/anthropic-agent.d.ts.map +1 -1
- package/dist/agents/anthropic-agent.js +18 -9
- package/dist/agents/anthropic-agent.js.map +1 -1
- package/dist/agents/base.d.ts +38 -4
- package/dist/agents/base.d.ts.map +1 -1
- package/dist/agents/base.js +130 -1
- package/dist/agents/base.js.map +1 -1
- package/dist/agents/deepseek-agent.d.ts +7 -3
- package/dist/agents/deepseek-agent.d.ts.map +1 -1
- package/dist/agents/deepseek-agent.js +34 -13
- package/dist/agents/deepseek-agent.js.map +1 -1
- package/dist/agents/openai-agent.d.ts +7 -3
- package/dist/agents/openai-agent.d.ts.map +1 -1
- package/dist/agents/openai-agent.js +52 -16
- package/dist/agents/openai-agent.js.map +1 -1
- package/dist/agents/prompt-based-agent.d.ts +4 -3
- package/dist/agents/prompt-based-agent.d.ts.map +1 -1
- package/dist/agents/prompt-based-agent.js +11 -4
- package/dist/agents/prompt-based-agent.js.map +1 -1
- package/dist/agents/sap-core-ai-agent.d.ts +0 -1
- package/dist/agents/sap-core-ai-agent.d.ts.map +1 -1
- package/dist/agents/sap-core-ai-agent.js +0 -3
- package/dist/agents/sap-core-ai-agent.js.map +1 -1
- package/dist/cli.js +10 -7
- package/dist/cli.js.map +1 -1
- package/dist/llm-providers/anthropic.d.ts +1 -0
- package/dist/llm-providers/anthropic.d.ts.map +1 -1
- package/dist/llm-providers/anthropic.js +13 -1
- package/dist/llm-providers/anthropic.js.map +1 -1
- package/dist/llm-providers/base.d.ts +5 -4
- package/dist/llm-providers/base.d.ts.map +1 -1
- package/dist/llm-providers/base.js.map +1 -1
- package/dist/llm-providers/deepseek.d.ts +4 -2
- package/dist/llm-providers/deepseek.d.ts.map +1 -1
- package/dist/llm-providers/deepseek.js +93 -7
- package/dist/llm-providers/deepseek.js.map +1 -1
- package/dist/llm-providers/openai.d.ts +3 -2
- package/dist/llm-providers/openai.d.ts.map +1 -1
- package/dist/llm-providers/openai.js +87 -7
- package/dist/llm-providers/openai.js.map +1 -1
- package/dist/llm-providers/sap-core-ai.d.ts +9 -5
- package/dist/llm-providers/sap-core-ai.d.ts.map +1 -1
- package/dist/llm-providers/sap-core-ai.js +18 -7
- package/dist/llm-providers/sap-core-ai.js.map +1 -1
- package/dist/mcp/client.d.ts +15 -6
- package/dist/mcp/client.d.ts.map +1 -1
- package/dist/mcp/client.js +64 -38
- package/dist/mcp/client.js.map +1 -1
- package/dist/smart-agent/adapters/llm-adapter.d.ts +4 -8
- package/dist/smart-agent/adapters/llm-adapter.d.ts.map +1 -1
- package/dist/smart-agent/adapters/llm-adapter.js +131 -16
- package/dist/smart-agent/adapters/llm-adapter.js.map +1 -1
- package/dist/smart-agent/adapters/mcp-client-adapter.d.ts.map +1 -1
- package/dist/smart-agent/adapters/mcp-client-adapter.js +4 -1
- package/dist/smart-agent/adapters/mcp-client-adapter.js.map +1 -1
- package/dist/smart-agent/agent.d.ts +30 -20
- package/dist/smart-agent/agent.d.ts.map +1 -1
- package/dist/smart-agent/agent.js +461 -356
- package/dist/smart-agent/agent.js.map +1 -1
- package/dist/smart-agent/builder.d.ts +18 -5
- package/dist/smart-agent/builder.d.ts.map +1 -1
- package/dist/smart-agent/builder.js +76 -24
- package/dist/smart-agent/builder.js.map +1 -1
- package/dist/smart-agent/classifier/llm-classifier.d.ts +1 -1
- package/dist/smart-agent/classifier/llm-classifier.d.ts.map +1 -1
- package/dist/smart-agent/classifier/llm-classifier.js +33 -41
- package/dist/smart-agent/classifier/llm-classifier.js.map +1 -1
- package/dist/smart-agent/cli.d.ts +3 -2
- package/dist/smart-agent/cli.d.ts.map +1 -1
- package/dist/smart-agent/cli.js +15 -9
- package/dist/smart-agent/cli.js.map +1 -1
- package/dist/smart-agent/config.d.ts +4 -15
- package/dist/smart-agent/config.d.ts.map +1 -1
- package/dist/smart-agent/config.js +109 -84
- package/dist/smart-agent/config.js.map +1 -1
- package/dist/smart-agent/context/context-assembler.d.ts +14 -2
- package/dist/smart-agent/context/context-assembler.d.ts.map +1 -1
- package/dist/smart-agent/context/context-assembler.js +35 -49
- package/dist/smart-agent/context/context-assembler.js.map +1 -1
- package/dist/smart-agent/interfaces/assembler.d.ts +2 -2
- package/dist/smart-agent/interfaces/assembler.d.ts.map +1 -1
- package/dist/smart-agent/interfaces/index.d.ts +1 -1
- package/dist/smart-agent/interfaces/index.d.ts.map +1 -1
- package/dist/smart-agent/interfaces/index.js.map +1 -1
- package/dist/smart-agent/interfaces/llm.d.ts +2 -1
- package/dist/smart-agent/interfaces/llm.d.ts.map +1 -1
- package/dist/smart-agent/interfaces/rag.d.ts +4 -0
- package/dist/smart-agent/interfaces/rag.d.ts.map +1 -1
- package/dist/smart-agent/interfaces/types.d.ts +38 -1
- package/dist/smart-agent/interfaces/types.d.ts.map +1 -1
- package/dist/smart-agent/interfaces/types.js.map +1 -1
- package/dist/smart-agent/llm/token-counting-llm.d.ts +2 -1
- package/dist/smart-agent/llm/token-counting-llm.d.ts.map +1 -1
- package/dist/smart-agent/llm/token-counting-llm.js +9 -0
- package/dist/smart-agent/llm/token-counting-llm.js.map +1 -1
- package/dist/smart-agent/logger/session-logger.d.ts +10 -0
- package/dist/smart-agent/logger/session-logger.d.ts.map +1 -0
- package/dist/smart-agent/logger/session-logger.js +40 -0
- package/dist/smart-agent/logger/session-logger.js.map +1 -0
- package/dist/smart-agent/pipeline.d.ts +12 -19
- package/dist/smart-agent/pipeline.d.ts.map +1 -1
- package/dist/smart-agent/pipeline.js +52 -25
- package/dist/smart-agent/pipeline.js.map +1 -1
- package/dist/smart-agent/policy/index.d.ts +1 -0
- package/dist/smart-agent/policy/index.d.ts.map +1 -1
- package/dist/smart-agent/policy/index.js +1 -0
- package/dist/smart-agent/policy/index.js.map +1 -1
- package/dist/smart-agent/policy/tool-availability-registry.d.ts +21 -0
- package/dist/smart-agent/policy/tool-availability-registry.d.ts.map +1 -0
- package/dist/smart-agent/policy/tool-availability-registry.js +77 -0
- package/dist/smart-agent/policy/tool-availability-registry.js.map +1 -0
- package/dist/smart-agent/rag/in-memory-rag.d.ts +1 -0
- package/dist/smart-agent/rag/in-memory-rag.d.ts.map +1 -1
- package/dist/smart-agent/rag/in-memory-rag.js +3 -0
- package/dist/smart-agent/rag/in-memory-rag.js.map +1 -1
- package/dist/smart-agent/rag/index.d.ts +2 -2
- package/dist/smart-agent/rag/index.d.ts.map +1 -1
- package/dist/smart-agent/rag/index.js +1 -1
- package/dist/smart-agent/rag/index.js.map +1 -1
- package/dist/smart-agent/rag/ollama-rag.d.ts +14 -16
- package/dist/smart-agent/rag/ollama-rag.d.ts.map +1 -1
- package/dist/smart-agent/rag/ollama-rag.js +37 -97
- package/dist/smart-agent/rag/ollama-rag.js.map +1 -1
- package/dist/smart-agent/rag/openai-embedder.d.ts +18 -0
- package/dist/smart-agent/rag/openai-embedder.d.ts.map +1 -0
- package/dist/smart-agent/rag/openai-embedder.js +48 -0
- package/dist/smart-agent/rag/openai-embedder.js.map +1 -0
- package/dist/smart-agent/rag/vector-rag.d.ts +31 -0
- package/dist/smart-agent/rag/vector-rag.d.ts.map +1 -0
- package/dist/smart-agent/rag/vector-rag.js +144 -0
- package/dist/smart-agent/rag/vector-rag.js.map +1 -0
- package/dist/smart-agent/server.d.ts.map +1 -1
- package/dist/smart-agent/server.js +107 -9
- package/dist/smart-agent/server.js.map +1 -1
- package/dist/smart-agent/smart-server.d.ts +14 -59
- package/dist/smart-agent/smart-server.d.ts.map +1 -1
- package/dist/smart-agent/smart-server.js +273 -84
- package/dist/smart-agent/smart-server.js.map +1 -1
- package/dist/smart-agent/testing/index.d.ts.map +1 -1
- package/dist/smart-agent/testing/index.js +33 -1
- package/dist/smart-agent/testing/index.js.map +1 -1
- package/dist/smart-agent/utils/external-tools-normalizer.d.ts +14 -0
- package/dist/smart-agent/utils/external-tools-normalizer.d.ts.map +1 -0
- package/dist/smart-agent/utils/external-tools-normalizer.js +135 -0
- package/dist/smart-agent/utils/external-tools-normalizer.js.map +1 -0
- package/dist/smart-agent/utils/tool-call-deltas.d.ts +4 -0
- package/dist/smart-agent/utils/tool-call-deltas.d.ts.map +1 -0
- package/dist/smart-agent/utils/tool-call-deltas.js +25 -0
- package/dist/smart-agent/utils/tool-call-deltas.js.map +1 -0
- package/dist/types.d.ts +17 -3
- package/dist/types.d.ts.map +1 -1
- package/dist/utils/errors.d.ts +4 -0
- package/dist/utils/errors.d.ts.map +1 -0
- package/dist/utils/errors.js +31 -0
- package/dist/utils/errors.js.map +1 -0
- package/package.json +11 -9
- package/dist/smoke-adapters.d.ts +0 -17
- package/dist/smoke-adapters.d.ts.map +0 -1
- package/dist/smoke-adapters.js +0 -178
- package/dist/smoke-adapters.js.map +0 -1
package/README.md
CHANGED
|
@@ -1,28 +1,26 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Smart Agent & Server
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
A high-performance, RAG-orchestrated LLM agent and OpenAI-compatible server with deep MCP integration.
|
|
4
4
|
|
|
5
5
|
## Overview
|
|
6
6
|
|
|
7
|
-
This
|
|
7
|
+
This project provides a robust orchestration layer that transforms standard LLMs into specialized autonomous agents. It handles multi-turn tool loops, long-term memory via RAG, and serves everything through a standard OpenAI-compatible API.
|
|
8
8
|
|
|
9
|
-
**
|
|
10
|
-
-
|
|
11
|
-
-
|
|
12
|
-
-
|
|
9
|
+
**Key Components:**
|
|
10
|
+
- **SmartAgent:** The core orchestrator that manages intent classification, RAG retrieval, and tool execution loops.
|
|
11
|
+
- **SmartServer:** A production-ready HTTP server that makes the agent accessible to any OpenAI-compatible client (Cline, Goose, etc.).
|
|
12
|
+
- **Hybrid RAG:** A multi-vector search engine combining semantic embeddings with BM25 lexical scoring.
|
|
13
13
|
|
|
14
14
|
## Features
|
|
15
15
|
|
|
16
|
-
- ✅
|
|
17
|
-
- ✅
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
- ✅
|
|
23
|
-
- ✅
|
|
24
|
-
- ✅ Raw LLM response passthrough for consumers
|
|
25
|
-
- 🔄 Streaming support (planned)
|
|
16
|
+
- ✅ **Real Incremental Streaming:** True per-token streaming for both text and tool-call deltas.
|
|
17
|
+
- ✅ **OpenAI SSE Compliance:** Fully compatible with official OpenAI SDKs and IDE plugins.
|
|
18
|
+
- ✅ **Hybrid RAG Search:** Combines Vector similarity (semantic) with BM25 (lexical) for pinpoint accuracy in technical domains like SAP/ABAP.
|
|
19
|
+
- ✅ **Multi-Intent Classification:** Automatically routes requests to `chat` (fast-path), `action` (tool-loop), or long-term memory (`fact`/`state`).
|
|
20
|
+
- ✅ **Reasoning Mode:** Optional transparent thought process (`<reasoning>` blocks) to explain agent strategy.
|
|
21
|
+
- ✅ **Resilience:** Built-in exponential backoff retries for LLM/Embeddings and auto-reconnect for MCP servers.
|
|
22
|
+
- ✅ **Helper LLM Support:** Offload summarization and translation tasks to cheaper/faster models.
|
|
23
|
+
- ✅ **Startup Health Checks:** Immediate diagnostics for all dependencies (Ollama, MCP, LLM).
|
|
26
24
|
|
|
27
25
|
## Installation
|
|
28
26
|
|
|
@@ -30,486 +28,100 @@ This agent acts as a thin orchestration layer between LLM providers and MCP (Mod
|
|
|
30
28
|
npm install @mcp-abap-adt/llm-agent
|
|
31
29
|
```
|
|
32
30
|
|
|
33
|
-
##
|
|
34
|
-
|
|
35
|
-
The agent can be used in two ways:
|
|
36
|
-
|
|
37
|
-
1. **Embedded in application** - Import and use directly in your CAP service or application (same process)
|
|
38
|
-
2. **Standalone service** - Run as a separate service/process
|
|
39
|
-
|
|
40
|
-
Both modes connect to MCP servers via transport protocols (HTTP/SSE/stdio), not directly to MCP server instances.
|
|
41
|
-
|
|
42
|
-
### Embedded Usage (Same Process)
|
|
43
|
-
|
|
44
|
-
When using the agent embedded in your application (e.g., in `cloud-llm-hub` CAP service), you import it as a module:
|
|
45
|
-
|
|
46
|
-
```typescript
|
|
47
|
-
// srv/agent-service.ts
|
|
48
|
-
import { SapCoreAIAgent, SapCoreAIProvider, MCPClientWrapper } from '@mcp-abap-adt/llm-agent';
|
|
49
|
-
import { executeHttpRequest } from '@sap-cloud-sdk/http-client';
|
|
50
|
-
|
|
51
|
-
export default class AgentService extends cds.Service {
|
|
52
|
-
private agent: SapCoreAIAgent;
|
|
53
|
-
|
|
54
|
-
async init() {
|
|
55
|
-
// Create SAP AI Core provider (all LLM providers through SAP AI Core)
|
|
56
|
-
const llmProvider = new SapCoreAIProvider({
|
|
57
|
-
destinationName: 'SAP_AI_CORE_DEST', // SAP destination for AI Core
|
|
58
|
-
model: 'gpt-4o-mini', // Model name determines which provider SAP AI Core uses
|
|
59
|
-
httpClient: async (config) => {
|
|
60
|
-
return await executeHttpRequest(
|
|
61
|
-
{ destinationName: config.destinationName },
|
|
62
|
-
{
|
|
63
|
-
method: config.method as any,
|
|
64
|
-
url: config.url,
|
|
65
|
-
headers: config.headers,
|
|
66
|
-
data: config.data,
|
|
67
|
-
}
|
|
68
|
-
);
|
|
69
|
-
},
|
|
70
|
-
});
|
|
71
|
-
|
|
72
|
-
// Create MCP client
|
|
73
|
-
const mcpClient = new MCPClientWrapper({
|
|
74
|
-
url: 'http://localhost:4004/mcp/stream/http', // MCP proxy endpoint
|
|
75
|
-
headers: {
|
|
76
|
-
'Authorization': 'Basic YWxpY2U6',
|
|
77
|
-
'X-SAP-Destination': 'SAP_DEV_DEST',
|
|
78
|
-
},
|
|
79
|
-
});
|
|
80
|
-
|
|
81
|
-
// Create agent
|
|
82
|
-
this.agent = new SapCoreAIAgent({
|
|
83
|
-
llmProvider,
|
|
84
|
-
mcpClient,
|
|
85
|
-
});
|
|
86
|
-
|
|
87
|
-
await this.agent.connect();
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
async chat(message: string) {
|
|
91
|
-
return await this.agent.process(message);
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
```
|
|
95
|
-
|
|
96
|
-
**Architecture Note:**
|
|
97
|
-
- The agent is imported as a module (like `@fr0ster/mcp-abap-adt`)
|
|
98
|
-
- Even when embedded in the same process, the agent connects to the MCP proxy via HTTP transport
|
|
99
|
-
- The MCP proxy embeds the `mcp-abap-adt` server instance
|
|
100
|
-
- This keeps the architecture clean: agent → MCP proxy (via HTTP) → embedded MCP server
|
|
101
|
-
|
|
102
|
-
See [Embedded Usage Guide](../../docs/LLM_AGENT_EMBEDDED_USAGE.md) for complete examples including per-request agent instances and caching strategies.
|
|
103
|
-
|
|
104
|
-
### Standalone Usage (Separate Process)
|
|
105
|
-
|
|
106
|
-
### Basic Example (Stdio Transport)
|
|
107
|
-
|
|
108
|
-
```typescript
|
|
109
|
-
import { SapCoreAIAgent, SapCoreAIProvider, MCPClientWrapper } from '@mcp-abap-adt/llm-agent';
|
|
110
|
-
import { executeHttpRequest } from '@sap-cloud-sdk/http-client';
|
|
111
|
-
|
|
112
|
-
// Create SAP AI Core provider
|
|
113
|
-
const llmProvider = new SapCoreAIProvider({
|
|
114
|
-
destinationName: 'SAP_AI_CORE_DEST',
|
|
115
|
-
model: 'gpt-4o-mini', // Routes to OpenAI through SAP AI Core
|
|
116
|
-
httpClient: async (config) => {
|
|
117
|
-
return await executeHttpRequest(
|
|
118
|
-
{ destinationName: config.destinationName },
|
|
119
|
-
{
|
|
120
|
-
method: config.method as any,
|
|
121
|
-
url: config.url,
|
|
122
|
-
headers: config.headers,
|
|
123
|
-
data: config.data,
|
|
124
|
-
}
|
|
125
|
-
);
|
|
126
|
-
},
|
|
127
|
-
});
|
|
128
|
-
|
|
129
|
-
const mcpClient = new MCPClientWrapper({
|
|
130
|
-
transport: 'stdio',
|
|
131
|
-
command: 'node',
|
|
132
|
-
args: ['path/to/mcp-server.js'],
|
|
133
|
-
});
|
|
134
|
-
|
|
135
|
-
const agent = new SapCoreAIAgent({
|
|
136
|
-
llmProvider,
|
|
137
|
-
mcpClient,
|
|
138
|
-
});
|
|
139
|
-
|
|
140
|
-
await agent.connect();
|
|
141
|
-
const response = await agent.process('What tools are available?');
|
|
142
|
-
console.log(response.message);
|
|
143
|
-
```
|
|
144
|
-
|
|
145
|
-
### HTTP Transport (Auto-Detection)
|
|
146
|
-
|
|
147
|
-
```typescript
|
|
148
|
-
import { Agent, OpenAIProvider, MCPClientWrapper } from '@mcp-abap-adt/llm-agent';
|
|
149
|
-
|
|
150
|
-
const llmProvider = new OpenAIProvider({
|
|
151
|
-
apiKey: process.env.OPENAI_API_KEY!,
|
|
152
|
-
model: 'gpt-4o-mini',
|
|
153
|
-
});
|
|
154
|
-
|
|
155
|
-
// Auto-detects 'stream-http' from URL
|
|
156
|
-
const mcpClient = new MCPClientWrapper({
|
|
157
|
-
url: 'http://localhost:4004/mcp/stream/http',
|
|
158
|
-
headers: {
|
|
159
|
-
'Authorization': 'Basic YWxpY2U6',
|
|
160
|
-
'Content-Type': 'application/x-ndjson',
|
|
161
|
-
},
|
|
162
|
-
});
|
|
163
|
-
|
|
164
|
-
const agent = new Agent({
|
|
165
|
-
llmProvider,
|
|
166
|
-
mcpClient,
|
|
167
|
-
});
|
|
168
|
-
|
|
169
|
-
await mcpClient.connect();
|
|
170
|
-
const sessionId = mcpClient.getSessionId(); // Get session ID for subsequent requests
|
|
171
|
-
|
|
172
|
-
const response = await agent.process('What tools are available?');
|
|
173
|
-
// The response is returned as-is; tool execution is handled by the consumer.
|
|
174
|
-
console.log(response.message);
|
|
175
|
-
```
|
|
176
|
-
|
|
177
|
-
### Explicit Transport Selection
|
|
178
|
-
|
|
179
|
-
```typescript
|
|
180
|
-
// SSE transport
|
|
181
|
-
const sseClient = new MCPClientWrapper({
|
|
182
|
-
transport: 'sse',
|
|
183
|
-
url: 'http://localhost:4004/mcp/stream/sse',
|
|
184
|
-
headers: {
|
|
185
|
-
'Authorization': 'Basic YWxpY2U6',
|
|
186
|
-
},
|
|
187
|
-
});
|
|
188
|
-
|
|
189
|
-
// Streamable HTTP transport
|
|
190
|
-
const httpClient = new MCPClientWrapper({
|
|
191
|
-
transport: 'stream-http',
|
|
192
|
-
url: 'http://localhost:4004/mcp/stream/http',
|
|
193
|
-
headers: {
|
|
194
|
-
'Authorization': 'Basic YWxpY2U6',
|
|
195
|
-
},
|
|
196
|
-
});
|
|
197
|
-
```
|
|
31
|
+
## Quick Start
|
|
198
32
|
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
### Embedded Usage in CAP Service
|
|
202
|
-
|
|
203
|
-
The agent can be imported and used directly in CAP services, similar to how `mcp-abap-adt` is used:
|
|
204
|
-
|
|
205
|
-
```typescript
|
|
206
|
-
// srv/agent-service.ts
|
|
207
|
-
import { Agent, OpenAIProvider } from '@mcp-abap-adt/llm-agent';
|
|
208
|
-
|
|
209
|
-
export default class AgentService extends cds.Service {
|
|
210
|
-
private agent: Agent;
|
|
211
|
-
|
|
212
|
-
async init() {
|
|
213
|
-
this.agent = new Agent({
|
|
214
|
-
llmProvider: new OpenAIProvider({
|
|
215
|
-
apiKey: process.env.OPENAI_API_KEY!,
|
|
216
|
-
}),
|
|
217
|
-
mcpConfig: {
|
|
218
|
-
url: 'http://localhost:4004/mcp/stream/http',
|
|
219
|
-
headers: {
|
|
220
|
-
'Authorization': 'Basic YWxpY2U6',
|
|
221
|
-
'X-SAP-Destination': 'SAP_DEV_DEST',
|
|
222
|
-
},
|
|
223
|
-
},
|
|
224
|
-
});
|
|
225
|
-
|
|
226
|
-
await this.agent.connect();
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
async chat(message: string) {
|
|
230
|
-
return await this.agent.process(message);
|
|
231
|
-
}
|
|
232
|
-
}
|
|
233
|
-
```
|
|
234
|
-
|
|
235
|
-
See [docs/LLM_AGENT_EMBEDDED_USAGE.md](../../docs/LLM_AGENT_EMBEDDED_USAGE.md) for complete embedded usage guide.
|
|
236
|
-
|
|
237
|
-
## Development
|
|
238
|
-
|
|
239
|
-
**Cross-Platform Development:** This project is configured for consistent behavior across Windows, Linux, and macOS. See the parent project's [Cross-Platform Development Guide](../../docs/CROSS_PLATFORM_GUIDE.md) for setup instructions and troubleshooting.
|
|
240
|
-
|
|
241
|
-
**Verify your setup:** Run `npm run verify:setup` from the root project to check cross-platform configuration.
|
|
242
|
-
|
|
243
|
-
```bash
|
|
244
|
-
# Install dependencies
|
|
245
|
-
npm install
|
|
246
|
-
|
|
247
|
-
# Setup environment (copy template and fill in your values)
|
|
248
|
-
cp .env.template .env
|
|
249
|
-
# Edit .env with your API keys and settings
|
|
250
|
-
|
|
251
|
-
# Build
|
|
252
|
-
npm run build
|
|
253
|
-
|
|
254
|
-
# Development mode (with tsx for hot reload)
|
|
255
|
-
# Will automatically load .env file if it exists
|
|
256
|
-
npm run dev
|
|
257
|
-
|
|
258
|
-
# Run test launcher (after build)
|
|
259
|
-
npm start
|
|
260
|
-
|
|
261
|
-
# Or with custom message
|
|
262
|
-
npm start "List all available ABAP programs"
|
|
263
|
-
```
|
|
264
|
-
|
|
265
|
-
### Environment Configuration
|
|
266
|
-
|
|
267
|
-
The agent supports configuration via `.env` file for easier setup:
|
|
268
|
-
|
|
269
|
-
1. Copy the template:
|
|
33
|
+
1. **Initialize Configuration:**
|
|
34
|
+
Run the agent once to generate the default `smart-server.yaml` template:
|
|
270
35
|
```bash
|
|
271
|
-
|
|
36
|
+
npx llm-agent-beta
|
|
272
37
|
```
|
|
273
38
|
|
|
274
|
-
2.
|
|
275
|
-
|
|
276
|
-
# Direct provider configuration (used by current CLI launcher)
|
|
277
|
-
LLM_PROVIDER=openai # openai | anthropic | deepseek
|
|
278
|
-
OPENAI_API_KEY=sk-proj-your-key
|
|
279
|
-
OPENAI_MODEL=gpt-4o-mini
|
|
280
|
-
|
|
281
|
-
# MCP Configuration (optional, for MCP integration)
|
|
282
|
-
MCP_ENDPOINT=http://localhost:4004/mcp/stream/http
|
|
283
|
-
MCP_DISABLED=false
|
|
284
|
-
```
|
|
285
|
-
|
|
286
|
-
**Optional (library-level SAP AI Core provider):**
|
|
287
|
-
SAP_CORE_AI_URL=https://api.ai.core.sap
|
|
288
|
-
SAP_CORE_AI_DESTINATION=SAP_AI_CORE_DEST
|
|
39
|
+
2. **Configure:**
|
|
40
|
+
Edit `smart-server.yaml` and `.env` with your API keys and MCP endpoints.
|
|
289
41
|
|
|
290
|
-
3.
|
|
42
|
+
3. **Launch Server:**
|
|
291
43
|
```bash
|
|
292
|
-
npm run dev
|
|
44
|
+
npm run dev -- --config smart-server.yaml
|
|
293
45
|
```
|
|
294
46
|
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
### Test Launcher
|
|
298
|
-
|
|
299
|
-
The agent includes a simple CLI test launcher for quick testing.
|
|
300
|
-
|
|
301
|
-
**Note:** The current CLI launcher uses direct providers (`openai`, `anthropic`, `deepseek`). `ollama` is listed in comments but not implemented.
|
|
302
|
-
|
|
303
|
-
#### Test LLM Only (Without MCP)
|
|
304
|
-
|
|
305
|
-
Test just the LLM provider without MCP integration:
|
|
306
|
-
|
|
307
|
-
**OpenAI:**
|
|
308
|
-
```bash
|
|
309
|
-
# Basic usage - set API key and run
|
|
310
|
-
export OPENAI_API_KEY="sk-proj-your-actual-key-here"
|
|
311
|
-
npm run dev:llm
|
|
312
|
-
|
|
313
|
-
# Or inline
|
|
314
|
-
OPENAI_API_KEY="sk-proj-your-key" npm run dev:llm
|
|
315
|
-
|
|
316
|
-
# With custom message
|
|
317
|
-
export OPENAI_API_KEY="sk-proj-your-key"
|
|
318
|
-
npm run dev:llm "Hello! Can you introduce yourself?"
|
|
319
|
-
|
|
320
|
-
# With specific model
|
|
321
|
-
export OPENAI_API_KEY="sk-proj-your-key"
|
|
322
|
-
export OPENAI_MODEL="gpt-4o" # or gpt-4-turbo, gpt-4o-mini, etc.
|
|
323
|
-
npm run dev:llm
|
|
324
|
-
|
|
325
|
-
# With organization ID (for team accounts)
|
|
326
|
-
export OPENAI_API_KEY="sk-proj-your-key"
|
|
327
|
-
export OPENAI_ORG="org-your-org-id"
|
|
328
|
-
npm run dev:llm
|
|
329
|
-
|
|
330
|
-
# With project ID (for project-specific billing)
|
|
331
|
-
export OPENAI_API_KEY="sk-proj-your-key"
|
|
332
|
-
export OPENAI_PROJECT="proj-your-project-id" # or OPENAI_PRJ
|
|
333
|
-
npm run dev:llm
|
|
334
|
-
|
|
335
|
-
# Full configuration
|
|
336
|
-
export OPENAI_API_KEY="sk-proj-your-key"
|
|
337
|
-
export OPENAI_MODEL="gpt-4o"
|
|
338
|
-
export OPENAI_ORG="org-your-org-id"
|
|
339
|
-
export OPENAI_PROJECT="proj-your-project-id"
|
|
340
|
-
npm run dev:llm
|
|
341
|
-
```
|
|
342
|
-
|
|
343
|
-
**Anthropic (Claude):**
|
|
344
|
-
```bash
|
|
345
|
-
# Set provider and API key
|
|
346
|
-
export LLM_PROVIDER=anthropic
|
|
347
|
-
export ANTHROPIC_API_KEY="sk-ant-your-actual-key-here"
|
|
348
|
-
npm run dev:llm
|
|
349
|
-
|
|
350
|
-
# With custom message
|
|
351
|
-
export LLM_PROVIDER=anthropic
|
|
352
|
-
export ANTHROPIC_API_KEY="sk-ant-your-key"
|
|
353
|
-
npm run dev:llm "What can you do?"
|
|
354
|
-
|
|
355
|
-
# With specific model
|
|
356
|
-
export LLM_PROVIDER=anthropic
|
|
357
|
-
export ANTHROPIC_API_KEY="sk-ant-your-key"
|
|
358
|
-
export ANTHROPIC_MODEL="claude-3-5-sonnet-20241022" # or claude-3-opus, etc.
|
|
359
|
-
npm run dev:llm
|
|
360
|
-
```
|
|
361
|
-
|
|
362
|
-
**DeepSeek:**
|
|
363
|
-
```bash
|
|
364
|
-
# Set provider and API key
|
|
365
|
-
export LLM_PROVIDER=deepseek
|
|
366
|
-
export DEEPSEEK_API_KEY="sk-your-actual-key-here"
|
|
367
|
-
npm run dev:llm
|
|
368
|
-
|
|
369
|
-
# With custom message
|
|
370
|
-
export LLM_PROVIDER=deepseek
|
|
371
|
-
export DEEPSEEK_API_KEY="sk-your-key"
|
|
372
|
-
npm run dev:llm "Explain what you can do"
|
|
373
|
-
```
|
|
374
|
-
|
|
375
|
-
**Alternative methods:**
|
|
376
|
-
```bash
|
|
377
|
-
# Method 1: Using dedicated script (recommended)
|
|
378
|
-
export OPENAI_API_KEY="sk-proj-..."
|
|
379
|
-
npm run dev:llm
|
|
380
|
-
|
|
381
|
-
# Method 2: Using flag
|
|
382
|
-
export OPENAI_API_KEY="sk-proj-..."
|
|
383
|
-
npm run dev -- --llm-only
|
|
384
|
-
|
|
385
|
-
# Method 3: Using environment variable
|
|
386
|
-
export OPENAI_API_KEY="sk-proj-..."
|
|
387
|
-
export MCP_DISABLED=true
|
|
388
|
-
npm run dev
|
|
389
|
-
```
|
|
390
|
-
|
|
391
|
-
#### Basic Usage with OpenAI (With MCP)
|
|
392
|
-
|
|
393
|
-
```bash
|
|
394
|
-
# Method 1: Export environment variable
|
|
395
|
-
export OPENAI_API_KEY="sk-proj-..."
|
|
396
|
-
export MCP_ENDPOINT="http://localhost:4004/mcp/stream/http"
|
|
397
|
-
npm run dev
|
|
398
|
-
|
|
399
|
-
# Method 2: Inline (one-time use)
|
|
400
|
-
OPENAI_API_KEY="sk-proj-..." npm run dev
|
|
401
|
-
|
|
402
|
-
# Method 3: With custom message
|
|
403
|
-
export OPENAI_API_KEY="sk-proj-..."
|
|
404
|
-
npm run dev "What ABAP programs are available?"
|
|
47
|
+
## Usage
|
|
405
48
|
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
49
|
+
### Connecting IDE Clients
|
|
50
|
+
|
|
51
|
+
Point your favorite AI client to your local SmartServer:
|
|
52
|
+
- **Base URL:** `http://localhost:4004/v1`
|
|
53
|
+
- **Model ID:** `smart-agent`
|
|
54
|
+
- **API Key:** (any string, e.g., `sk-none`)
|
|
55
|
+
|
|
56
|
+
### Intent Types
|
|
57
|
+
|
|
58
|
+
SmartAgent automatically classifies your input into:
|
|
59
|
+
- **Fact:** Technical rules or constraints (e.g., "ABAP Cloud forbids direct table access"). Stored in long-term facts RAG.
|
|
60
|
+
- **State:** Project context or temporary observations (e.g., "Kristina approves decisions", "Sky is blue"). Stored in state RAG.
|
|
61
|
+
- **Chat:** Trivial questions or math (e.g., "2+2"). Processed via fast-path without project context.
|
|
62
|
+
- **Action:** (Default) Engineering tasks requiring tools and deep analysis.
|
|
63
|
+
|
|
64
|
+
## Advanced Configuration (YAML)
|
|
65
|
+
|
|
66
|
+
```yaml
|
|
67
|
+
port: 4004
|
|
68
|
+
host: 0.0.0.0
|
|
69
|
+
|
|
70
|
+
# Hybrid RAG Settings
|
|
71
|
+
rag:
|
|
72
|
+
type: ollama
|
|
73
|
+
url: http://localhost:11434
|
|
74
|
+
vectorWeight: 0.7
|
|
75
|
+
keywordWeight: 0.3
|
|
76
|
+
|
|
77
|
+
# Multi-model Pipeline
|
|
78
|
+
pipeline:
|
|
79
|
+
llm:
|
|
80
|
+
main:
|
|
81
|
+
provider: deepseek
|
|
82
|
+
apiKey: ${DEEPSEEK_API_KEY}
|
|
83
|
+
model: deepseek-chat
|
|
84
|
+
classifier:
|
|
85
|
+
provider: deepseek
|
|
86
|
+
apiKey: ${DEEPSEEK_API_KEY}
|
|
87
|
+
model: deepseek-chat
|
|
88
|
+
temperature: 0.1
|
|
89
|
+
helper:
|
|
90
|
+
provider: deepseek
|
|
91
|
+
apiKey: ${DEEPSEEK_API_KEY}
|
|
92
|
+
model: deepseek-chat # Used for fast summarization/translation
|
|
93
|
+
temperature: 0.1
|
|
94
|
+
|
|
95
|
+
# Feature Toggles
|
|
96
|
+
agent:
|
|
97
|
+
showReasoning: true # Enable debug thought blocks
|
|
98
|
+
maxIterations: 10
|
|
99
|
+
historyAutoSummarizeLimit: 15
|
|
411
100
|
```
|
|
412
101
|
|
|
413
|
-
|
|
102
|
+
## Development
|
|
414
103
|
|
|
415
104
|
```bash
|
|
416
|
-
#
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
# Set required environment variables
|
|
420
|
-
export OPENAI_API_KEY="sk-proj-your-actual-key-here"
|
|
421
|
-
export MCP_ENDPOINT="http://localhost:4004/mcp/stream/http"
|
|
422
|
-
export SAP_DESTINATION="SAP_DEV_DEST" # Optional, for SAP integration
|
|
423
|
-
|
|
424
|
-
# Optional: Set model
|
|
425
|
-
export OPENAI_MODEL="gpt-4o-mini" # or gpt-4o, gpt-4-turbo, etc.
|
|
426
|
-
|
|
427
|
-
# Run test launcher
|
|
428
|
-
npm run dev
|
|
429
|
-
|
|
430
|
-
# Or with custom message
|
|
431
|
-
npm run dev "List all available tools and describe what they do"
|
|
432
|
-
```
|
|
105
|
+
# Build project
|
|
106
|
+
npm run build
|
|
433
107
|
|
|
434
|
-
|
|
108
|
+
# Run tests
|
|
109
|
+
npm run test:all
|
|
435
110
|
|
|
436
|
-
|
|
437
|
-
```bash
|
|
438
|
-
export LLM_PROVIDER=anthropic
|
|
439
|
-
export ANTHROPIC_API_KEY="sk-ant-your-key-here"
|
|
440
|
-
export ANTHROPIC_MODEL="claude-3-5-sonnet-20241022" # Optional
|
|
111
|
+
# Development with hot-reload
|
|
441
112
|
npm run dev
|
|
442
|
-
```
|
|
443
113
|
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
export LLM_PROVIDER=deepseek
|
|
447
|
-
export DEEPSEEK_API_KEY="sk-your-key-here"
|
|
448
|
-
export DEEPSEEK_MODEL="deepseek-chat" # Optional
|
|
449
|
-
npm run dev
|
|
450
|
-
```
|
|
114
|
+
# Smart server production entrypoint
|
|
115
|
+
npm run start
|
|
451
116
|
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
LLM Provider: openai
|
|
459
|
-
MCP Endpoint: http://localhost:4004/mcp/stream/http
|
|
460
|
-
Test Message: What tools are available?
|
|
461
|
-
|
|
462
|
-
✅ Created OpenAI provider
|
|
463
|
-
✅ Created MCP client
|
|
464
|
-
|
|
465
|
-
✅ Created agent instance
|
|
466
|
-
Agent type: OpenAIAgent
|
|
467
|
-
|
|
468
|
-
🔌 Connecting to MCP server...
|
|
469
|
-
✅ Connected to MCP server
|
|
470
|
-
|
|
471
|
-
📦 Available tools: 31
|
|
472
|
-
- GetProgram: Retrieve ABAP program source code...
|
|
473
|
-
- GetClass: Retrieve ABAP class source code...
|
|
474
|
-
- GetFunction: Retrieve ABAP function module...
|
|
475
|
-
... and 28 more
|
|
476
|
-
|
|
477
|
-
💬 Processing message: "What tools are available?"
|
|
478
|
-
|
|
479
|
-
📤 Response:
|
|
480
|
-
────────────────────────────────────────────────────────────
|
|
481
|
-
I can see you have 31 tools available for working with ABAP systems...
|
|
482
|
-
|
|
483
|
-
⏱️ Duration: 2341ms
|
|
484
|
-
|
|
485
|
-
📜 Conversation history: 4 messages
|
|
486
|
-
|
|
487
|
-
✅ Test completed successfully!
|
|
117
|
+
# Legacy compatibility aliases
|
|
118
|
+
npm run start:smart
|
|
119
|
+
npm run dev:llm
|
|
120
|
+
npm run start:llm
|
|
121
|
+
npm run test
|
|
122
|
+
npm run test:llm
|
|
488
123
|
```
|
|
489
124
|
|
|
490
|
-
The test launcher will:
|
|
491
|
-
- Connect to MCP server
|
|
492
|
-
- List available tools
|
|
493
|
-
- Process a test message
|
|
494
|
-
- Show response
|
|
495
|
-
- Display conversation history
|
|
496
|
-
|
|
497
|
-
## Tool Execution Responsibility
|
|
498
|
-
|
|
499
|
-
The agent does not execute tools. It only:
|
|
500
|
-
- Fetches MCP tool catalogs
|
|
501
|
-
- Passes tool definitions to the LLM
|
|
502
|
-
- Returns the raw LLM response to the consumer
|
|
503
|
-
|
|
504
|
-
If your application needs tool execution, parse the model output in the consumer layer and call MCP tools there.
|
|
505
|
-
|
|
506
|
-
## Architecture
|
|
507
|
-
|
|
508
|
-
- `src/agents/` - Agent implementations (BaseAgent, SapCoreAIAgent, etc.)
|
|
509
|
-
- `src/llm-providers/` - LLM provider implementations (OpenAI, Anthropic, DeepSeek, SapCoreAI)
|
|
510
|
-
- `src/mcp/` - MCP client wrapper
|
|
511
|
-
- `src/types.ts` - TypeScript type definitions
|
|
512
|
-
|
|
513
125
|
## License
|
|
514
126
|
|
|
515
127
|
MIT
|
package/dist/agent.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent.d.ts","sourceRoot":"","sources":["../src/agent.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,KAAK,eAAe,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACzE,OAAO,KAAK,EAAE,aAAa,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAEzD,MAAM,WAAW,WAAW;IAC1B,WAAW,EAAE,WAAW,CAAC;IACzB;;;OAGG;IACH,SAAS,CAAC,EAAE,gBAAgB,CAAC;IAC7B;;;OAGG;IACH,SAAS,CAAC,EAAE,eAAe,CAAC;IAC5B,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,qBAAa,KAAK;IAChB,OAAO,CAAC,WAAW,CAAc;IACjC,OAAO,CAAC,SAAS,CAAmB;IACpC,OAAO,CAAC,mBAAmB,CAAiB;gBAEhC,MAAM,EAAE,WAAW;IAe/B;;OAEG;IACG,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAI9B;;OAEG;IACG,OAAO,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"agent.d.ts","sourceRoot":"","sources":["../src/agent.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,KAAK,eAAe,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACzE,OAAO,KAAK,EAAE,aAAa,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAEzD,MAAM,WAAW,WAAW;IAC1B,WAAW,EAAE,WAAW,CAAC;IACzB;;;OAGG;IACH,SAAS,CAAC,EAAE,gBAAgB,CAAC;IAC7B;;;OAGG;IACH,SAAS,CAAC,EAAE,eAAe,CAAC;IAC5B,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,qBAAa,KAAK;IAChB,OAAO,CAAC,WAAW,CAAc;IACjC,OAAO,CAAC,SAAS,CAAmB;IACpC,OAAO,CAAC,mBAAmB,CAAiB;gBAEhC,MAAM,EAAE,WAAW;IAe/B;;OAEG;IACG,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAI9B;;OAEG;IACG,OAAO,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC;IA2C1D;;OAEG;IACH,OAAO,CAAC,kBAAkB;IAgB1B;;OAEG;IACH,YAAY,IAAI,IAAI;IAIpB;;OAEG;IACH,UAAU,IAAI,OAAO,EAAE;CAGxB"}
|
package/dist/agent.js
CHANGED
|
@@ -59,9 +59,10 @@ export class Agent {
|
|
|
59
59
|
};
|
|
60
60
|
}
|
|
61
61
|
catch (error) {
|
|
62
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
62
63
|
return {
|
|
63
64
|
message: '',
|
|
64
|
-
error:
|
|
65
|
+
error: errorMessage || 'Agent processing failed',
|
|
65
66
|
};
|
|
66
67
|
}
|
|
67
68
|
}
|
package/dist/agent.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent.js","sourceRoot":"","sources":["../src/agent.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAwB,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAkBzE,MAAM,OAAO,KAAK;IACR,WAAW,CAAc;IACzB,SAAS,CAAmB;IAC5B,mBAAmB,GAAc,EAAE,CAAC;IAE5C,YAAY,MAAmB;QA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QACR,OAAO,CAAC,GAAG,IAAI,CAAC,mBAAmB,CAAC,CAAC;IACvC,CAAC;CACF"}
|
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
* tool use blocks in the response content.
|
|
6
6
|
*/
|
|
7
7
|
import type { AnthropicProvider } from '../llm-providers/anthropic.js';
|
|
8
|
-
import type { Message } from '../types.js';
|
|
9
|
-
import { BaseAgent, type BaseAgentConfig } from './base.js';
|
|
8
|
+
import type { AgentStreamChunk, Message } from '../types.js';
|
|
9
|
+
import { type AgentCallOptions, BaseAgent, type BaseAgentConfig } from './base.js';
|
|
10
10
|
export interface AnthropicAgentConfig extends BaseAgentConfig {
|
|
11
11
|
llmProvider: AnthropicProvider;
|
|
12
12
|
}
|
|
@@ -16,7 +16,7 @@ export declare class AnthropicAgent extends BaseAgent {
|
|
|
16
16
|
/**
|
|
17
17
|
* Call Anthropic with tools using tools API
|
|
18
18
|
*/
|
|
19
|
-
protected callLLMWithTools(messages: Message[], tools:
|
|
19
|
+
protected callLLMWithTools(messages: Message[], tools: unknown[]): Promise<{
|
|
20
20
|
content: string;
|
|
21
21
|
raw?: unknown;
|
|
22
22
|
}>;
|
|
@@ -28,5 +28,6 @@ export declare class AnthropicAgent extends BaseAgent {
|
|
|
28
28
|
* Format messages for Anthropic API
|
|
29
29
|
*/
|
|
30
30
|
private formatMessagesForAnthropic;
|
|
31
|
+
protected streamLLMWithTools(_messages: Message[], _tools: unknown[], _options?: AgentCallOptions): AsyncGenerator<AgentStreamChunk, void, unknown>;
|
|
31
32
|
}
|
|
32
33
|
//# sourceMappingURL=anthropic-agent.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"anthropic-agent.d.ts","sourceRoot":"","sources":["../../src/agents/anthropic-agent.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"anthropic-agent.d.ts","sourceRoot":"","sources":["../../src/agents/anthropic-agent.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AACvE,OAAO,KAAK,EAAE,gBAAgB,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAC7D,OAAO,EACL,KAAK,gBAAgB,EACrB,SAAS,EACT,KAAK,eAAe,EACrB,MAAM,WAAW,CAAC;AAEnB,MAAM,WAAW,oBAAqB,SAAQ,eAAe;IAC3D,WAAW,EAAE,iBAAiB,CAAC;CAChC;AAED,qBAAa,cAAe,SAAQ,SAAS;IAC3C,OAAO,CAAC,WAAW,CAAoB;gBAE3B,MAAM,EAAE,oBAAoB;IAKxC;;OAEG;cACa,gBAAgB,CAC9B,QAAQ,EAAE,OAAO,EAAE,EACnB,KAAK,EAAE,OAAO,EAAE,GACf,OAAO,CAAC;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,GAAG,CAAC,EAAE,OAAO,CAAA;KAAE,CAAC;IAgE9C;;OAEG;IACH,OAAO,CAAC,4BAA4B;IAoBpC;;OAEG;IACH,OAAO,CAAC,0BAA0B;cAWjB,kBAAkB,CACjC,SAAS,EAAE,OAAO,EAAE,EACpB,MAAM,EAAE,OAAO,EAAE,EACjB,QAAQ,CAAC,EAAE,gBAAgB,GAC1B,cAAc,CAAC,gBAAgB,EAAE,IAAI,EAAE,OAAO,CAAC;CAMnD"}
|