@vibe-agent-toolkit/runtime-claude-agent-sdk 0.1.2-rc.3
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 +321 -0
- package/dist/adapters/common-helpers.d.ts +161 -0
- package/dist/adapters/common-helpers.d.ts.map +1 -0
- package/dist/adapters/common-helpers.js +219 -0
- package/dist/adapters/common-helpers.js.map +1 -0
- package/dist/adapters/conversational-assistant.d.ts +109 -0
- package/dist/adapters/conversational-assistant.d.ts.map +1 -0
- package/dist/adapters/conversational-assistant.js +150 -0
- package/dist/adapters/conversational-assistant.js.map +1 -0
- package/dist/adapters/llm-analyzer.d.ts +99 -0
- package/dist/adapters/llm-analyzer.d.ts.map +1 -0
- package/dist/adapters/llm-analyzer.js +125 -0
- package/dist/adapters/llm-analyzer.js.map +1 -0
- package/dist/adapters/pure-function.d.ts +83 -0
- package/dist/adapters/pure-function.d.ts.map +1 -0
- package/dist/adapters/pure-function.js +120 -0
- package/dist/adapters/pure-function.js.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +11 -0
- package/dist/index.js.map +1 -0
- package/dist/session/index.d.ts +12 -0
- package/dist/session/index.d.ts.map +1 -0
- package/dist/session/index.js +13 -0
- package/dist/session/index.js.map +1 -0
- package/dist/types.d.ts +64 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/package.json +53 -0
package/README.md
ADDED
|
@@ -0,0 +1,321 @@
|
|
|
1
|
+
# @vibe-agent-toolkit/runtime-claude-agent-sdk
|
|
2
|
+
|
|
3
|
+
Runtime adapter for deploying VAT agents as Claude Agent SDK MCP tools.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- Converts VAT agents to Claude Agent SDK MCP tools
|
|
8
|
+
- Supports Pure Function, LLM Analyzer, and Conversational Assistant archetypes
|
|
9
|
+
- Maintains conversation history for multi-turn interactions
|
|
10
|
+
- Validates inputs and outputs using Zod schemas
|
|
11
|
+
- Single-agent or batch conversion patterns
|
|
12
|
+
|
|
13
|
+
## Installation
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
npm install @vibe-agent-toolkit/runtime-claude-agent-sdk
|
|
17
|
+
# or
|
|
18
|
+
bun add @vibe-agent-toolkit/runtime-claude-agent-sdk
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Supported Archetypes
|
|
22
|
+
|
|
23
|
+
### 1. Pure Function Tools
|
|
24
|
+
|
|
25
|
+
Stateless, deterministic agents with no external dependencies.
|
|
26
|
+
|
|
27
|
+
```typescript
|
|
28
|
+
import { query } from '@anthropic-ai/claude-agent-sdk';
|
|
29
|
+
import { haikuValidatorAgent } from '@vibe-agent-toolkit/vat-example-cat-agents';
|
|
30
|
+
import { convertPureFunctionToTool } from '@vibe-agent-toolkit/runtime-claude-agent-sdk';
|
|
31
|
+
|
|
32
|
+
const { server, metadata } = convertPureFunctionToTool(
|
|
33
|
+
haikuValidatorAgent,
|
|
34
|
+
HaikuSchema,
|
|
35
|
+
HaikuValidationResultSchema
|
|
36
|
+
);
|
|
37
|
+
|
|
38
|
+
// Use with Claude Agent SDK
|
|
39
|
+
for await (const message of query({
|
|
40
|
+
prompt: "Validate this haiku: 'Cat sits on warm mat / Purring in the sunshine / Dreams of tuna fish'",
|
|
41
|
+
options: {
|
|
42
|
+
mcpServers: { 'haiku-tools': server },
|
|
43
|
+
allowedTools: [metadata.toolName]
|
|
44
|
+
}
|
|
45
|
+
})) {
|
|
46
|
+
if (message.type === 'result') {
|
|
47
|
+
console.log(message.result);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
### 2. LLM Analyzer Tools
|
|
53
|
+
|
|
54
|
+
Single LLM call agents for classification and extraction.
|
|
55
|
+
|
|
56
|
+
```typescript
|
|
57
|
+
import { query } from '@anthropic-ai/claude-agent-sdk';
|
|
58
|
+
import { nameGeneratorAgent } from '@vibe-agent-toolkit/vat-example-cat-agents';
|
|
59
|
+
import { convertLLMAnalyzerToTool } from '@vibe-agent-toolkit/runtime-claude-agent-sdk';
|
|
60
|
+
|
|
61
|
+
const { server, metadata } = convertLLMAnalyzerToTool(
|
|
62
|
+
nameGeneratorAgent,
|
|
63
|
+
NameGeneratorInputSchema,
|
|
64
|
+
NameSuggestionSchema,
|
|
65
|
+
{
|
|
66
|
+
apiKey: process.env.ANTHROPIC_API_KEY,
|
|
67
|
+
model: 'claude-3-5-haiku-20241022',
|
|
68
|
+
temperature: 0.9
|
|
69
|
+
}
|
|
70
|
+
);
|
|
71
|
+
|
|
72
|
+
// Use with Claude Agent SDK
|
|
73
|
+
for await (const message of query({
|
|
74
|
+
prompt: "Generate a distinguished cat name for an orange cat",
|
|
75
|
+
options: {
|
|
76
|
+
mcpServers: { 'name-tools': server },
|
|
77
|
+
allowedTools: [metadata.toolName]
|
|
78
|
+
}
|
|
79
|
+
})) {
|
|
80
|
+
if (message.type === 'result') {
|
|
81
|
+
console.log(message.result);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
### 3. Conversational Assistant Tools
|
|
87
|
+
|
|
88
|
+
Multi-turn conversation agents with session state and history.
|
|
89
|
+
|
|
90
|
+
```typescript
|
|
91
|
+
import { query } from '@anthropic-ai/claude-agent-sdk';
|
|
92
|
+
import { breedAdvisorAgent } from '@vibe-agent-toolkit/vat-example-cat-agents';
|
|
93
|
+
import { convertConversationalAssistantToTool } from '@vibe-agent-toolkit/runtime-claude-agent-sdk';
|
|
94
|
+
|
|
95
|
+
const { server, metadata } = convertConversationalAssistantToTool(
|
|
96
|
+
breedAdvisorAgent,
|
|
97
|
+
BreedAdvisorInputSchema,
|
|
98
|
+
BreedAdvisorOutputSchema,
|
|
99
|
+
{
|
|
100
|
+
apiKey: process.env.ANTHROPIC_API_KEY,
|
|
101
|
+
model: 'claude-3-5-haiku-20241022',
|
|
102
|
+
temperature: 0.7
|
|
103
|
+
}
|
|
104
|
+
);
|
|
105
|
+
|
|
106
|
+
// Multi-turn conversation
|
|
107
|
+
const turns = [
|
|
108
|
+
"Hi! I'm looking for a cat breed. I live in a small apartment.",
|
|
109
|
+
"I love classical music! Chopin and Debussy are my favorites.",
|
|
110
|
+
"I don't mind grooming. What breeds would you recommend?"
|
|
111
|
+
];
|
|
112
|
+
|
|
113
|
+
for (const turn of turns) {
|
|
114
|
+
for await (const message of query({
|
|
115
|
+
prompt: turn,
|
|
116
|
+
options: {
|
|
117
|
+
mcpServers: { 'breed-advisor': server },
|
|
118
|
+
allowedTools: [metadata.toolName]
|
|
119
|
+
}
|
|
120
|
+
})) {
|
|
121
|
+
if (message.type === 'result') {
|
|
122
|
+
console.log(message.result);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
## Batch Conversion
|
|
129
|
+
|
|
130
|
+
Convert multiple agents to a single MCP server:
|
|
131
|
+
|
|
132
|
+
```typescript
|
|
133
|
+
import { convertLLMAnalyzersToTools } from '@vibe-agent-toolkit/runtime-claude-agent-sdk';
|
|
134
|
+
|
|
135
|
+
const { server, metadata } = convertLLMAnalyzersToTools({
|
|
136
|
+
generateName: {
|
|
137
|
+
agent: nameGeneratorAgent,
|
|
138
|
+
inputSchema: NameGeneratorInputSchema,
|
|
139
|
+
outputSchema: NameSuggestionSchema,
|
|
140
|
+
},
|
|
141
|
+
generateHaiku: {
|
|
142
|
+
agent: haikuGeneratorAgent,
|
|
143
|
+
inputSchema: HaikuGeneratorInputSchema,
|
|
144
|
+
outputSchema: HaikuSchema,
|
|
145
|
+
},
|
|
146
|
+
}, {
|
|
147
|
+
apiKey: process.env.ANTHROPIC_API_KEY,
|
|
148
|
+
model: 'claude-3-5-haiku-20241022',
|
|
149
|
+
temperature: 0.8,
|
|
150
|
+
});
|
|
151
|
+
|
|
152
|
+
// Use all tools together
|
|
153
|
+
for await (const message of query({
|
|
154
|
+
prompt: "Generate a cat name and haiku",
|
|
155
|
+
options: {
|
|
156
|
+
mcpServers: { 'cat-llm-tools': server },
|
|
157
|
+
allowedTools: [
|
|
158
|
+
'mcp__cat-llm-tools__generateName',
|
|
159
|
+
'mcp__cat-llm-tools__generateHaiku'
|
|
160
|
+
]
|
|
161
|
+
}
|
|
162
|
+
})) {
|
|
163
|
+
console.log(message);
|
|
164
|
+
}
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
## API Reference
|
|
168
|
+
|
|
169
|
+
### Single Agent Conversion
|
|
170
|
+
|
|
171
|
+
#### `convertPureFunctionToTool(agent, inputSchema, outputSchema, serverName?)`
|
|
172
|
+
|
|
173
|
+
Converts a VAT Pure Function agent to Claude Agent SDK MCP tool.
|
|
174
|
+
|
|
175
|
+
**Parameters:**
|
|
176
|
+
- `agent` - The VAT pure function agent
|
|
177
|
+
- `inputSchema` - Zod schema for input validation
|
|
178
|
+
- `outputSchema` - Zod schema for output validation
|
|
179
|
+
- `serverName` - Optional server name (defaults to agent name)
|
|
180
|
+
|
|
181
|
+
**Returns:** `AgentConversionResult<TInput, TOutput>`
|
|
182
|
+
|
|
183
|
+
#### `convertLLMAnalyzerToTool(agent, inputSchema, outputSchema, llmConfig, serverName?)`
|
|
184
|
+
|
|
185
|
+
Converts a VAT LLM Analyzer agent to Claude Agent SDK MCP tool.
|
|
186
|
+
|
|
187
|
+
**Parameters:**
|
|
188
|
+
- `agent` - The VAT LLM analyzer agent
|
|
189
|
+
- `inputSchema` - Zod schema for input validation
|
|
190
|
+
- `outputSchema` - Zod schema for output validation
|
|
191
|
+
- `llmConfig` - LLM configuration (`{ apiKey?, model?, temperature?, maxTokens? }`)
|
|
192
|
+
- `serverName` - Optional server name (defaults to agent name)
|
|
193
|
+
|
|
194
|
+
**Returns:** `AgentConversionResult<TInput, TOutput>`
|
|
195
|
+
|
|
196
|
+
#### `convertConversationalAssistantToTool(agent, inputSchema, outputSchema, llmConfig, serverName?)`
|
|
197
|
+
|
|
198
|
+
Converts a VAT Conversational Assistant agent to Claude Agent SDK MCP tool.
|
|
199
|
+
|
|
200
|
+
**Parameters:**
|
|
201
|
+
- `agent` - The VAT conversational assistant agent
|
|
202
|
+
- `inputSchema` - Zod schema for input validation
|
|
203
|
+
- `outputSchema` - Zod schema for output validation
|
|
204
|
+
- `llmConfig` - LLM configuration (`{ apiKey?, model?, temperature?, maxTokens? }`)
|
|
205
|
+
- `serverName` - Optional server name (defaults to agent name)
|
|
206
|
+
|
|
207
|
+
**Returns:** `AgentConversionResult<TInput, TOutput>`
|
|
208
|
+
|
|
209
|
+
### Batch Conversion
|
|
210
|
+
|
|
211
|
+
#### `convertPureFunctionsToTools(configs, serverName?)`
|
|
212
|
+
|
|
213
|
+
Batch converts multiple Pure Function agents.
|
|
214
|
+
|
|
215
|
+
**Parameters:**
|
|
216
|
+
- `configs` - Map of tool names to agent configurations
|
|
217
|
+
- `serverName` - Server name (defaults to 'vat-agents')
|
|
218
|
+
|
|
219
|
+
**Returns:** `BatchConversionResult`
|
|
220
|
+
|
|
221
|
+
#### `convertLLMAnalyzersToTools(configs, llmConfig, serverName?)`
|
|
222
|
+
|
|
223
|
+
Batch converts multiple LLM Analyzer agents.
|
|
224
|
+
|
|
225
|
+
**Parameters:**
|
|
226
|
+
- `configs` - Map of tool names to agent configurations
|
|
227
|
+
- `llmConfig` - Shared LLM configuration
|
|
228
|
+
- `serverName` - Server name (defaults to 'vat-llm-agents')
|
|
229
|
+
|
|
230
|
+
**Returns:** `BatchConversionResult`
|
|
231
|
+
|
|
232
|
+
#### `convertConversationalAssistantsToTools(configs, llmConfig, serverName?)`
|
|
233
|
+
|
|
234
|
+
Batch converts multiple Conversational Assistant agents.
|
|
235
|
+
|
|
236
|
+
**Parameters:**
|
|
237
|
+
- `configs` - Map of tool names to agent configurations
|
|
238
|
+
- `llmConfig` - Shared LLM configuration
|
|
239
|
+
- `serverName` - Server name (defaults to 'vat-conversational-agents')
|
|
240
|
+
|
|
241
|
+
**Returns:** `BatchConversionResult`
|
|
242
|
+
|
|
243
|
+
## Types
|
|
244
|
+
|
|
245
|
+
### `AgentConversionResult<TInput, TOutput>`
|
|
246
|
+
|
|
247
|
+
```typescript
|
|
248
|
+
interface AgentConversionResult<TInput, TOutput> {
|
|
249
|
+
server: ClaudeAgentMcpServer;
|
|
250
|
+
metadata: {
|
|
251
|
+
name: string;
|
|
252
|
+
description: string;
|
|
253
|
+
version: string;
|
|
254
|
+
archetype: string;
|
|
255
|
+
serverName: string;
|
|
256
|
+
toolName: string;
|
|
257
|
+
};
|
|
258
|
+
inputSchema: z.ZodType<TInput>;
|
|
259
|
+
outputSchema: z.ZodType<TOutput>;
|
|
260
|
+
}
|
|
261
|
+
```
|
|
262
|
+
|
|
263
|
+
### `BatchConversionResult`
|
|
264
|
+
|
|
265
|
+
```typescript
|
|
266
|
+
interface BatchConversionResult {
|
|
267
|
+
server: ClaudeAgentMcpServer;
|
|
268
|
+
metadata: {
|
|
269
|
+
serverName: string;
|
|
270
|
+
tools: Record<string, {
|
|
271
|
+
name: string;
|
|
272
|
+
description: string;
|
|
273
|
+
version: string;
|
|
274
|
+
archetype: string;
|
|
275
|
+
toolName: string;
|
|
276
|
+
}>;
|
|
277
|
+
};
|
|
278
|
+
}
|
|
279
|
+
```
|
|
280
|
+
|
|
281
|
+
### `ClaudeAgentLLMConfig`
|
|
282
|
+
|
|
283
|
+
```typescript
|
|
284
|
+
interface ClaudeAgentLLMConfig {
|
|
285
|
+
apiKey?: string; // Defaults to ANTHROPIC_API_KEY env var
|
|
286
|
+
model?: string; // Defaults to 'claude-3-5-haiku-20241022'
|
|
287
|
+
temperature?: number; // Defaults to 0.7
|
|
288
|
+
maxTokens?: number; // Defaults to 4096
|
|
289
|
+
}
|
|
290
|
+
```
|
|
291
|
+
|
|
292
|
+
## Examples
|
|
293
|
+
|
|
294
|
+
This adapter implements the `RuntimeAdapter` interface and can be tested with the runtime-agnostic demo:
|
|
295
|
+
|
|
296
|
+
```bash
|
|
297
|
+
# See vat-example-cat-agents/examples/runtime-adapter-demo.ts
|
|
298
|
+
# The common demo works with ALL runtime adapters via the RuntimeAdapter interface
|
|
299
|
+
```
|
|
300
|
+
|
|
301
|
+
For usage patterns, see the code examples in this README above.
|
|
302
|
+
|
|
303
|
+
## Architecture
|
|
304
|
+
|
|
305
|
+
This adapter:
|
|
306
|
+
|
|
307
|
+
1. **Wraps VAT agents** as Claude Agent SDK MCP tools
|
|
308
|
+
2. **Validates inputs/outputs** using Zod schemas
|
|
309
|
+
3. **Manages conversation history** for conversational agents
|
|
310
|
+
4. **Provides LLM context** for agents that need it
|
|
311
|
+
5. **Returns structured results** in Claude Agent SDK format
|
|
312
|
+
|
|
313
|
+
## License
|
|
314
|
+
|
|
315
|
+
MIT
|
|
316
|
+
|
|
317
|
+
## Related Packages
|
|
318
|
+
|
|
319
|
+
- [@vibe-agent-toolkit/agent-runtime](../agent-runtime) - Core agent definitions
|
|
320
|
+
- [@vibe-agent-toolkit/vat-example-cat-agents](../vat-example-cat-agents) - Example agents
|
|
321
|
+
- [@vibe-agent-toolkit/runtime-claude-skills](../runtime-claude-skills) - Claude Skills adapter
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
import { createSdkMcpServer, tool } from '@anthropic-ai/claude-agent-sdk';
|
|
2
|
+
import Anthropic from '@anthropic-ai/sdk';
|
|
3
|
+
import type { Agent, Message, PureFunctionAgent } from '@vibe-agent-toolkit/agent-runtime';
|
|
4
|
+
import type { z } from 'zod';
|
|
5
|
+
import type { ClaudeAgentLLMConfig, ClaudeAgentMcpServer } from '../types.js';
|
|
6
|
+
/**
|
|
7
|
+
* Creates metadata object for a single agent conversion
|
|
8
|
+
*/
|
|
9
|
+
export declare function createSingleToolMetadata(manifest: {
|
|
10
|
+
name: string;
|
|
11
|
+
description: string;
|
|
12
|
+
version: string;
|
|
13
|
+
}, archetype: string, mcpServerName: string): {
|
|
14
|
+
name: string;
|
|
15
|
+
description: string;
|
|
16
|
+
version: string;
|
|
17
|
+
archetype: string;
|
|
18
|
+
serverName: string;
|
|
19
|
+
toolName: string;
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* Creates metadata object for batch conversion
|
|
23
|
+
*/
|
|
24
|
+
export declare function createBatchToolMetadata(key: string, manifest: {
|
|
25
|
+
name: string;
|
|
26
|
+
description: string;
|
|
27
|
+
version: string;
|
|
28
|
+
}, archetype: string, serverName: string): {
|
|
29
|
+
name: string;
|
|
30
|
+
description: string;
|
|
31
|
+
version: string;
|
|
32
|
+
archetype: string;
|
|
33
|
+
toolName: string;
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* Creates an MCP server with a single tool
|
|
37
|
+
*/
|
|
38
|
+
export declare function createMcpServerWithTool<TInput, TOutput>(manifest: {
|
|
39
|
+
name: string;
|
|
40
|
+
description: string;
|
|
41
|
+
version: string;
|
|
42
|
+
}, mcpServerName: string, inputSchema: z.ZodType<TInput>, outputSchema: z.ZodType<TOutput>, handler: (input: TInput) => Promise<TOutput>): ClaudeAgentMcpServer;
|
|
43
|
+
/**
|
|
44
|
+
* Creates tool handler for batch conversion
|
|
45
|
+
*/
|
|
46
|
+
export declare function createToolHandler<TInput, TOutput>(agent: Agent<TInput, TOutput> | PureFunctionAgent<TInput, TOutput>, inputSchema: z.ZodType<TInput>, outputSchema: z.ZodType<TOutput>, getContext?: (input: TInput) => unknown): (args: unknown, _extra: unknown) => Promise<{
|
|
47
|
+
content: Array<{
|
|
48
|
+
type: 'text';
|
|
49
|
+
text: string;
|
|
50
|
+
}>;
|
|
51
|
+
}>;
|
|
52
|
+
/**
|
|
53
|
+
* Type for batch conversion metadata
|
|
54
|
+
*/
|
|
55
|
+
export type BatchToolMetadata = Record<string, {
|
|
56
|
+
name: string;
|
|
57
|
+
description: string;
|
|
58
|
+
version: string;
|
|
59
|
+
archetype: string;
|
|
60
|
+
toolName: string;
|
|
61
|
+
}>;
|
|
62
|
+
/**
|
|
63
|
+
* Generic helper to convert a single agent to MCP tool
|
|
64
|
+
* Reduces duplication between conversational and analyzer adapters
|
|
65
|
+
*/
|
|
66
|
+
export declare function convertAgentToTool<TInput, TOutput>(agent: Agent<TInput, TOutput>, inputSchema: z.ZodType<TInput>, outputSchema: z.ZodType<TOutput>, serverName: string | undefined, archetype: string, handler: (input: TInput) => Promise<TOutput>): {
|
|
67
|
+
server: ReturnType<typeof createSdkMcpServer>;
|
|
68
|
+
metadata: {
|
|
69
|
+
name: string;
|
|
70
|
+
description: string;
|
|
71
|
+
version: string;
|
|
72
|
+
archetype: string;
|
|
73
|
+
serverName: string;
|
|
74
|
+
toolName: string;
|
|
75
|
+
};
|
|
76
|
+
inputSchema: z.ZodType<TInput>;
|
|
77
|
+
outputSchema: z.ZodType<TOutput>;
|
|
78
|
+
};
|
|
79
|
+
/**
|
|
80
|
+
* Factory to create single agent converter functions
|
|
81
|
+
* Eliminates duplication between LLM analyzer and conversational assistant converters
|
|
82
|
+
*
|
|
83
|
+
* @param archetype - Agent archetype name
|
|
84
|
+
* @param createContext - Function to create LLM context from config
|
|
85
|
+
* @param createHandler - Function to create handler from agent and context
|
|
86
|
+
* @returns Converter function with same signature as manual implementations
|
|
87
|
+
*/
|
|
88
|
+
export declare function createSingleConverterFunction<TInput, TOutput, TCallLLM = unknown>(archetype: string, createContext: (config: ClaudeAgentLLMConfig) => {
|
|
89
|
+
callLLM: TCallLLM;
|
|
90
|
+
model: string;
|
|
91
|
+
temperature: number;
|
|
92
|
+
}, createHandler: (agent: Agent<TInput, TOutput>, callLLM: TCallLLM, model: string, temperature: number) => (input: TInput) => Promise<TOutput>): (agent: Agent<TInput, TOutput>, inputSchema: z.ZodType<TInput>, outputSchema: z.ZodType<TOutput>, llmConfig: ClaudeAgentLLMConfig, serverName?: string) => {
|
|
93
|
+
server: ReturnType<typeof createSdkMcpServer>;
|
|
94
|
+
metadata: {
|
|
95
|
+
name: string;
|
|
96
|
+
description: string;
|
|
97
|
+
version: string;
|
|
98
|
+
archetype: string;
|
|
99
|
+
serverName: string;
|
|
100
|
+
toolName: string;
|
|
101
|
+
};
|
|
102
|
+
inputSchema: z.ZodType<TInput>;
|
|
103
|
+
outputSchema: z.ZodType<TOutput>;
|
|
104
|
+
};
|
|
105
|
+
/**
|
|
106
|
+
* Helper to create tools array from agent configs
|
|
107
|
+
* Reduces duplication in batch conversion functions
|
|
108
|
+
*/
|
|
109
|
+
export declare function createToolsFromConfigs<TInput, TOutput>(configs: Record<string, {
|
|
110
|
+
agent: Agent<TInput, TOutput> | PureFunctionAgent<TInput, TOutput>;
|
|
111
|
+
inputSchema: z.ZodType<TInput>;
|
|
112
|
+
outputSchema: z.ZodType<TOutput>;
|
|
113
|
+
}>, archetype: string, serverName: string, contextFactory: (key: string) => unknown): {
|
|
114
|
+
tools: ReturnType<typeof tool>[];
|
|
115
|
+
toolsMetadata: BatchToolMetadata;
|
|
116
|
+
};
|
|
117
|
+
/**
|
|
118
|
+
* Helper to extract text from Anthropic API response
|
|
119
|
+
*
|
|
120
|
+
* @param response - Anthropic API response
|
|
121
|
+
* @returns Extracted text content
|
|
122
|
+
*/
|
|
123
|
+
export declare function extractTextFromResponse(response: Anthropic.Messages.Message): string;
|
|
124
|
+
/**
|
|
125
|
+
* Format messages for Anthropic API
|
|
126
|
+
*
|
|
127
|
+
* Extracts system prompt and filters/maps remaining messages to Anthropic format
|
|
128
|
+
*
|
|
129
|
+
* @param messages - Array of messages to format
|
|
130
|
+
* @returns Object with systemPrompt (if any) and conversationMessages in Anthropic format
|
|
131
|
+
*/
|
|
132
|
+
export declare function formatMessagesForAnthropic(messages: Message[]): {
|
|
133
|
+
systemPrompt?: string;
|
|
134
|
+
conversationMessages: Array<{
|
|
135
|
+
role: 'user' | 'assistant';
|
|
136
|
+
content: string;
|
|
137
|
+
}>;
|
|
138
|
+
};
|
|
139
|
+
/**
|
|
140
|
+
* Creates an Anthropic client and callLLM function for LLM Analyzer agents
|
|
141
|
+
*
|
|
142
|
+
* @param llmConfig - LLM configuration
|
|
143
|
+
* @returns Object containing callLLM function, model, and temperature
|
|
144
|
+
*/
|
|
145
|
+
export declare function createAnthropicLLMContext(llmConfig: ClaudeAgentLLMConfig): {
|
|
146
|
+
callLLM: (prompt: string) => Promise<string>;
|
|
147
|
+
model: string;
|
|
148
|
+
temperature: number;
|
|
149
|
+
};
|
|
150
|
+
/**
|
|
151
|
+
* Creates an Anthropic client and callLLM function for Conversational Assistant agents
|
|
152
|
+
*
|
|
153
|
+
* @param llmConfig - LLM configuration
|
|
154
|
+
* @returns Object containing callLLM function, model, and temperature
|
|
155
|
+
*/
|
|
156
|
+
export declare function createAnthropicConversationalContext(llmConfig: ClaudeAgentLLMConfig): {
|
|
157
|
+
callLLM: (messages: Message[], modelOverride?: string, tempOverride?: number) => Promise<string>;
|
|
158
|
+
model: string;
|
|
159
|
+
temperature: number;
|
|
160
|
+
};
|
|
161
|
+
//# sourceMappingURL=common-helpers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"common-helpers.d.ts","sourceRoot":"","sources":["../../src/adapters/common-helpers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,IAAI,EAAE,MAAM,gCAAgC,CAAC;AAC1E,OAAO,SAAS,MAAM,mBAAmB,CAAC;AAC1C,OAAO,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AAC3F,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAE7B,OAAO,KAAK,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAI9E;;GAEG;AACH,wBAAgB,wBAAwB,CACtC,QAAQ,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,EAChE,SAAS,EAAE,MAAM,EACjB,aAAa,EAAE,MAAM,GACpB;IACD,IAA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