@omnixhq/ucp-client 0.1.3 → 0.3.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 +108 -18
- package/dist/adapters/anthropic.cjs +27 -0
- package/dist/adapters/anthropic.cjs.map +1 -0
- package/dist/adapters/anthropic.d.cts +22 -0
- package/dist/adapters/anthropic.d.cts.map +1 -0
- package/dist/adapters/anthropic.d.ts +22 -0
- package/dist/adapters/anthropic.d.ts.map +1 -0
- package/dist/adapters/anthropic.js +25 -0
- package/dist/adapters/anthropic.js.map +1 -0
- package/dist/adapters/langchain.cjs +20 -0
- package/dist/adapters/langchain.cjs.map +1 -0
- package/dist/adapters/langchain.d.cts +16 -0
- package/dist/adapters/langchain.d.cts.map +1 -0
- package/dist/adapters/langchain.d.ts +16 -0
- package/dist/adapters/langchain.d.ts.map +1 -0
- package/dist/adapters/langchain.js +19 -0
- package/dist/adapters/langchain.js.map +1 -0
- package/dist/adapters/mcp.cjs +27 -0
- package/dist/adapters/mcp.cjs.map +1 -0
- package/dist/adapters/mcp.d.cts +22 -0
- package/dist/adapters/mcp.d.cts.map +1 -0
- package/dist/adapters/mcp.d.ts +22 -0
- package/dist/adapters/mcp.d.ts.map +1 -0
- package/dist/adapters/mcp.js +25 -0
- package/dist/adapters/mcp.js.map +1 -0
- package/dist/adapters/openai.cjs +27 -0
- package/dist/adapters/openai.cjs.map +1 -0
- package/dist/adapters/openai.d.cts +20 -0
- package/dist/adapters/openai.d.cts.map +1 -0
- package/dist/adapters/openai.d.ts +20 -0
- package/dist/adapters/openai.d.ts.map +1 -0
- package/dist/adapters/openai.js +25 -0
- package/dist/adapters/openai.js.map +1 -0
- package/dist/adapters/vercel-ai.cjs +19 -0
- package/dist/adapters/vercel-ai.cjs.map +1 -0
- package/dist/adapters/vercel-ai.d.cts +16 -0
- package/dist/adapters/vercel-ai.d.cts.map +1 -0
- package/dist/adapters/vercel-ai.d.ts +16 -0
- package/dist/adapters/vercel-ai.d.ts.map +1 -0
- package/dist/adapters/vercel-ai.js +18 -0
- package/dist/adapters/vercel-ai.js.map +1 -0
- package/dist/catch-errors-BZP237w4.cjs +31 -0
- package/dist/catch-errors-BZP237w4.cjs.map +1 -0
- package/dist/catch-errors-CbIHeFvF.d.cts +494 -0
- package/dist/catch-errors-CbIHeFvF.d.cts.map +1 -0
- package/dist/catch-errors-Cpn2vHir.js +25 -0
- package/dist/catch-errors-Cpn2vHir.js.map +1 -0
- package/dist/catch-errors-H8gObrht.d.ts +494 -0
- package/dist/catch-errors-H8gObrht.d.ts.map +1 -0
- package/dist/errors-C1XqxNmZ.cjs +77 -0
- package/dist/errors-C1XqxNmZ.cjs.map +1 -0
- package/dist/errors-DX7yw6Gl.js +52 -0
- package/dist/errors-DX7yw6Gl.js.map +1 -0
- package/dist/index.cjs +137 -63
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +6 -483
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.ts +6 -483
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +124 -50
- package/dist/index.js.map +1 -1
- package/package.json +77 -4
package/README.md
CHANGED
|
@@ -84,7 +84,12 @@ Each tool returned by `getAgentTools()` has: `name`, `description`, `parameters`
|
|
|
84
84
|
## Error handling
|
|
85
85
|
|
|
86
86
|
```typescript
|
|
87
|
-
import {
|
|
87
|
+
import {
|
|
88
|
+
UCPError,
|
|
89
|
+
UCPEscalationError,
|
|
90
|
+
UCPIdempotencyConflictError,
|
|
91
|
+
UCPOAuthError,
|
|
92
|
+
} from '@omnixhq/ucp-client';
|
|
88
93
|
|
|
89
94
|
try {
|
|
90
95
|
await client.checkout.complete(sessionId, payload);
|
|
@@ -92,6 +97,12 @@ try {
|
|
|
92
97
|
if (err instanceof UCPEscalationError) {
|
|
93
98
|
// Redirect buyer to err.continue_url for merchant-hosted checkout
|
|
94
99
|
}
|
|
100
|
+
if (err instanceof UCPIdempotencyConflictError) {
|
|
101
|
+
// HTTP 409 — idempotency key reused with a different request body
|
|
102
|
+
}
|
|
103
|
+
if (err instanceof UCPOAuthError) {
|
|
104
|
+
// OAuth token exchange / refresh / revocation failed — err.statusCode
|
|
105
|
+
}
|
|
95
106
|
if (err instanceof UCPError) {
|
|
96
107
|
// err.code — e.g., 'PRODUCT_NOT_FOUND'
|
|
97
108
|
// err.messages[] — all messages from the server
|
|
@@ -101,6 +112,27 @@ try {
|
|
|
101
112
|
}
|
|
102
113
|
```
|
|
103
114
|
|
|
115
|
+
### catchErrors option
|
|
116
|
+
|
|
117
|
+
Pass `{ catchErrors: true }` to any adapter to return errors as structured objects instead of
|
|
118
|
+
throwing. The agent observes the failure and can decide what to do next — no try/catch needed in
|
|
119
|
+
every tool call.
|
|
120
|
+
|
|
121
|
+
```typescript
|
|
122
|
+
import { executeAnthropicToolCall } from '@omnixhq/ucp-client/anthropic';
|
|
123
|
+
import type { ToolErrorResult } from '@omnixhq/ucp-client';
|
|
124
|
+
|
|
125
|
+
const result = await executeAnthropicToolCall(agentTools, toolName, input, { catchErrors: true });
|
|
126
|
+
|
|
127
|
+
if (result && typeof result === 'object' && 'error' in result) {
|
|
128
|
+
const err = result as ToolErrorResult;
|
|
129
|
+
// { error: 'OUT_OF_STOCK: Item unavailable' }
|
|
130
|
+
// { requires_escalation: true, continue_url: 'https://...' }
|
|
131
|
+
}
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
All five adapters (`openai`, `anthropic`, `mcp`, `vercel-ai`, `langchain`) support `catchErrors`.
|
|
135
|
+
|
|
104
136
|
## Capabilities
|
|
105
137
|
|
|
106
138
|
The tools you get depend on what the server declares:
|
|
@@ -138,40 +170,97 @@ console.log(Object.keys(client.paymentHandlers));
|
|
|
138
170
|
// e.g., ['com.google.pay', 'dev.shopify.shop_pay']
|
|
139
171
|
```
|
|
140
172
|
|
|
141
|
-
##
|
|
173
|
+
## Framework adapters
|
|
142
174
|
|
|
143
|
-
|
|
175
|
+
Ready-made adapters convert `getAgentTools()` output to each framework's native format — no manual mapping.
|
|
176
|
+
|
|
177
|
+
| Framework | Import | Example |
|
|
178
|
+
| ----------------- | -------------------------------- | ---------------------------------------------------------------------- |
|
|
179
|
+
| **Anthropic SDK** | `@omnixhq/ucp-client` (built-in) | [examples/anthropic-agent-loop.ts](./examples/anthropic-agent-loop.ts) |
|
|
180
|
+
| **OpenAI SDK** | `@omnixhq/ucp-client/openai` | [examples/openai-agent-loop.ts](./examples/openai-agent-loop.ts) |
|
|
181
|
+
| **Vercel AI SDK** | `@omnixhq/ucp-client/vercel-ai` | [examples/vercel-ai-nextjs.ts](./examples/vercel-ai-nextjs.ts) |
|
|
182
|
+
| **LangChain** | `@omnixhq/ucp-client/langchain` | [examples/langchain-agent.ts](./examples/langchain-agent.ts) |
|
|
183
|
+
| **MCP server** | `@omnixhq/ucp-client/mcp` | [examples/mcp-server.ts](./examples/mcp-server.ts) |
|
|
144
184
|
|
|
145
185
|
**OpenAI:**
|
|
146
186
|
|
|
147
187
|
```typescript
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
188
|
+
import { toOpenAITools, executeOpenAIToolCall } from '@omnixhq/ucp-client/openai';
|
|
189
|
+
|
|
190
|
+
const tools = toOpenAITools(client.getAgentTools());
|
|
191
|
+
|
|
192
|
+
// In your agent loop:
|
|
193
|
+
const response = await openai.chat.completions.create({ model: 'gpt-4o', tools, messages });
|
|
194
|
+
|
|
195
|
+
for (const call of response.choices[0].message.tool_calls ?? []) {
|
|
196
|
+
const result = await executeOpenAIToolCall(
|
|
197
|
+
agentTools,
|
|
198
|
+
call.function.name,
|
|
199
|
+
JSON.parse(call.function.arguments),
|
|
200
|
+
);
|
|
201
|
+
}
|
|
152
202
|
```
|
|
153
203
|
|
|
154
204
|
**Vercel AI SDK:**
|
|
155
205
|
|
|
156
206
|
```typescript
|
|
157
|
-
import {
|
|
207
|
+
import { toVercelAITools } from '@omnixhq/ucp-client/vercel-ai';
|
|
208
|
+
import { jsonSchema, streamText } from 'ai';
|
|
158
209
|
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
210
|
+
const rawTools = toVercelAITools(client.getAgentTools());
|
|
211
|
+
|
|
212
|
+
// Wrap parameters with jsonSchema() for strict Vercel AI SDK typing:
|
|
213
|
+
const tools = Object.fromEntries(
|
|
214
|
+
Object.entries(rawTools).map(([name, t]) => [
|
|
215
|
+
name,
|
|
216
|
+
{ ...t, parameters: jsonSchema(t.parameters) },
|
|
163
217
|
]),
|
|
164
218
|
);
|
|
219
|
+
|
|
220
|
+
const result = await streamText({ model, tools, messages });
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
**LangChain:**
|
|
224
|
+
|
|
225
|
+
```typescript
|
|
226
|
+
import { toLangChainTools } from '@omnixhq/ucp-client/langchain';
|
|
227
|
+
import { DynamicStructuredTool } from '@langchain/core/tools';
|
|
228
|
+
import { z } from 'zod';
|
|
229
|
+
|
|
230
|
+
const rawTools = toLangChainTools(client.getAgentTools());
|
|
231
|
+
|
|
232
|
+
const tools = rawTools.map(
|
|
233
|
+
(t) =>
|
|
234
|
+
new DynamicStructuredTool({
|
|
235
|
+
name: t.name,
|
|
236
|
+
description: t.description,
|
|
237
|
+
schema: z.object({}),
|
|
238
|
+
func: t.call,
|
|
239
|
+
}),
|
|
240
|
+
);
|
|
165
241
|
```
|
|
166
242
|
|
|
167
243
|
**MCP server:**
|
|
168
244
|
|
|
169
245
|
```typescript
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
246
|
+
import { toMCPTools, executeMCPToolCall } from '@omnixhq/ucp-client/mcp';
|
|
247
|
+
|
|
248
|
+
const agentTools = client.getAgentTools();
|
|
249
|
+
|
|
250
|
+
server.setRequestHandler(ListToolsRequestSchema, async () => ({
|
|
251
|
+
tools: toMCPTools(agentTools),
|
|
252
|
+
}));
|
|
253
|
+
|
|
254
|
+
server.setRequestHandler(CallToolRequestSchema, async (req) => ({
|
|
255
|
+
content: [
|
|
256
|
+
{
|
|
257
|
+
type: 'text',
|
|
258
|
+
text: JSON.stringify(
|
|
259
|
+
await executeMCPToolCall(agentTools, req.params.name, req.params.arguments ?? {}),
|
|
260
|
+
),
|
|
261
|
+
},
|
|
262
|
+
],
|
|
263
|
+
}));
|
|
175
264
|
```
|
|
176
265
|
|
|
177
266
|
## Development
|
|
@@ -179,7 +268,8 @@ for (const t of tools) {
|
|
|
179
268
|
```bash
|
|
180
269
|
npm install
|
|
181
270
|
npm run build # tsdown (dual ESM + CJS)
|
|
182
|
-
npm test # vitest (
|
|
271
|
+
npm test # vitest (unit tests)
|
|
272
|
+
npm run test:types # type-level tests (vitest --typecheck.only)
|
|
183
273
|
npm run typecheck # tsc --noEmit
|
|
184
274
|
npm run lint # eslint
|
|
185
275
|
npm run check:exports # attw
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
require('../errors-C1XqxNmZ.cjs');
|
|
3
|
+
const require_catch_errors = require('../catch-errors-BZP237w4.cjs');
|
|
4
|
+
|
|
5
|
+
//#region src/adapters/anthropic.ts
|
|
6
|
+
function toAnthropicTools(agentTools, _options) {
|
|
7
|
+
return agentTools.map((tool) => ({
|
|
8
|
+
name: tool.name,
|
|
9
|
+
description: tool.description,
|
|
10
|
+
input_schema: {
|
|
11
|
+
...tool.parameters,
|
|
12
|
+
type: "object"
|
|
13
|
+
}
|
|
14
|
+
}));
|
|
15
|
+
}
|
|
16
|
+
async function executeAnthropicToolCall(agentTools, toolName, toolInput, options) {
|
|
17
|
+
return require_catch_errors.safeExecute(() => {
|
|
18
|
+
const tool = agentTools.find((t) => t.name === toolName);
|
|
19
|
+
if (!tool) throw new Error(`Tool not found: ${toolName}`);
|
|
20
|
+
return tool.execute(toolInput);
|
|
21
|
+
}, options?.catchErrors ?? false);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
//#endregion
|
|
25
|
+
exports.executeAnthropicToolCall = executeAnthropicToolCall
|
|
26
|
+
exports.toAnthropicTools = toAnthropicTools
|
|
27
|
+
//# sourceMappingURL=anthropic.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"anthropic.cjs","names":["agentTools: readonly AgentTool[]","_options?: AdapterOptions","toolName: string","toolInput: Record<string, unknown>","options?: AdapterOptions"],"sources":["../../src/adapters/anthropic.ts"],"sourcesContent":["import type { AgentTool, JsonSchema } from '../agent-tools.js';\nimport { type AdapterOptions, safeExecute } from './catch-errors.js';\n\nexport type { AgentTool, JsonSchema };\n\nexport interface AnthropicInputSchema {\n readonly type: 'object';\n readonly properties?: Readonly<Record<string, JsonSchema>>;\n readonly required?: readonly string[];\n readonly description?: string;\n}\n\nexport interface AnthropicTool {\n readonly name: string;\n readonly description: string;\n readonly input_schema: AnthropicInputSchema & JsonSchema;\n}\n\nexport function toAnthropicTools(\n agentTools: readonly AgentTool[],\n // accepted for API symmetry with executeAnthropicToolCall; catchErrors only applies at call time\n _options?: AdapterOptions,\n): readonly AnthropicTool[] {\n return agentTools.map((tool) => ({\n name: tool.name,\n description: tool.description,\n input_schema: { ...tool.parameters, type: 'object' as const },\n }));\n}\n\nexport async function executeAnthropicToolCall(\n agentTools: readonly AgentTool[],\n toolName: string,\n toolInput: Record<string, unknown>,\n options?: AdapterOptions,\n): Promise<unknown> {\n return safeExecute(() => {\n const tool = agentTools.find((t) => t.name === toolName);\n if (!tool) throw new Error(`Tool not found: ${toolName}`);\n return tool.execute(toolInput);\n }, options?.catchErrors ?? false);\n}\n"],"mappings":";;;;;AAkBA,SAAgB,iBACdA,YAEAC,UAC0B;AAC1B,QAAO,WAAW,IAAI,CAAC,UAAU;EAC/B,MAAM,KAAK;EACX,aAAa,KAAK;EAClB,cAAc;GAAE,GAAG,KAAK;GAAY,MAAM;EAAmB;CAC9D,GAAE;AACJ;AAED,eAAsB,yBACpBD,YACAE,UACAC,WACAC,SACkB;AAClB,QAAO,iCAAY,MAAM;EACvB,MAAM,OAAO,WAAW,KAAK,CAAC,MAAM,EAAE,SAAS,SAAS;AACxD,OAAK,KAAM,OAAM,IAAI,OAAO,kBAAkB,SAAS;AACvD,SAAO,KAAK,QAAQ,UAAU;CAC/B,GAAE,SAAS,eAAe,MAAM;AAClC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { AdapterOptions, AgentTool, JsonSchema } from "../catch-errors-CbIHeFvF.cjs";
|
|
2
|
+
|
|
3
|
+
//#region src/adapters/anthropic.d.ts
|
|
4
|
+
interface AnthropicInputSchema {
|
|
5
|
+
readonly type: 'object';
|
|
6
|
+
readonly properties?: Readonly<Record<string, JsonSchema>>;
|
|
7
|
+
readonly required?: readonly string[];
|
|
8
|
+
readonly description?: string;
|
|
9
|
+
}
|
|
10
|
+
interface AnthropicTool {
|
|
11
|
+
readonly name: string;
|
|
12
|
+
readonly description: string;
|
|
13
|
+
readonly input_schema: AnthropicInputSchema & JsonSchema;
|
|
14
|
+
}
|
|
15
|
+
declare function toAnthropicTools(agentTools: readonly AgentTool[], _options?: AdapterOptions): readonly AnthropicTool[];
|
|
16
|
+
declare function executeAnthropicToolCall(agentTools: readonly AgentTool[], toolName: string, toolInput: Record<string, unknown>, options?: AdapterOptions): Promise<unknown>;
|
|
17
|
+
|
|
18
|
+
//#endregion
|
|
19
|
+
//# sourceMappingURL=anthropic.d.ts.map
|
|
20
|
+
|
|
21
|
+
export { AgentTool, AnthropicInputSchema, AnthropicTool, JsonSchema, executeAnthropicToolCall, toAnthropicTools };
|
|
22
|
+
//# sourceMappingURL=anthropic.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"anthropic.d.cts","names":[],"sources":["../../src/adapters/anthropic.ts"],"sourcesContent":null,"mappings":";;;AAKiB,UAAA,oBAAA,CAAoB;EAAA,SAAA,IAAA,EAAA,QAAA;EAAA,SAEW,UAAA,CAAA,EAAxB,QAAwB,CAAf,MAAe,CAAA,MAAA,EAAA,UAAA,CAAA,CAAA;EAAU,SAAzB,QAAA,CAAA,EAAA,SAAA,MAAA,EAAA;EAAM,SAAf,WAAA,CAAA,EAAA,MAAA;AAAQ;AAKf,UAAA,aAAA,CAAa;EAAA,SAAA,IAAA,EAAA,MAAA;EAAA,SAGL,WAAA,EAAA,MAAA;EAAoB,SAAG,YAAA,EAAvB,oBAAuB,GAAA,UAAA;AAAU;AAG1C,iBAAA,gBAAA,CAAgB,UAAA,EAAA,SACT,SADS,EAAA,EAAA,QAAA,CAAA,EAGnB,cAHmB,CAAA,EAAA,SAIpB,aAJoB,EAAA;AAAA,iBAYV,wBAAA,CAZU,UAAA,EAAA,SAaT,SAbS,EAAA,EAAA,QAAA,EAAA,MAAA,EAAA,SAAA,EAenB,MAfmB,CAAA,MAAA,EAAA,OAAA,CAAA,EAAA,OAAA,CAAA,EAgBpB,cAhBoB,CAAA,EAiB7B,OAjB6B,CAAA,OAAA,CAAA"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { AdapterOptions, AgentTool, JsonSchema } from "../catch-errors-H8gObrht.js";
|
|
2
|
+
|
|
3
|
+
//#region src/adapters/anthropic.d.ts
|
|
4
|
+
interface AnthropicInputSchema {
|
|
5
|
+
readonly type: 'object';
|
|
6
|
+
readonly properties?: Readonly<Record<string, JsonSchema>>;
|
|
7
|
+
readonly required?: readonly string[];
|
|
8
|
+
readonly description?: string;
|
|
9
|
+
}
|
|
10
|
+
interface AnthropicTool {
|
|
11
|
+
readonly name: string;
|
|
12
|
+
readonly description: string;
|
|
13
|
+
readonly input_schema: AnthropicInputSchema & JsonSchema;
|
|
14
|
+
}
|
|
15
|
+
declare function toAnthropicTools(agentTools: readonly AgentTool[], _options?: AdapterOptions): readonly AnthropicTool[];
|
|
16
|
+
declare function executeAnthropicToolCall(agentTools: readonly AgentTool[], toolName: string, toolInput: Record<string, unknown>, options?: AdapterOptions): Promise<unknown>;
|
|
17
|
+
|
|
18
|
+
//#endregion
|
|
19
|
+
//# sourceMappingURL=anthropic.d.ts.map
|
|
20
|
+
|
|
21
|
+
export { AgentTool, AnthropicInputSchema, AnthropicTool, JsonSchema, executeAnthropicToolCall, toAnthropicTools };
|
|
22
|
+
//# sourceMappingURL=anthropic.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"anthropic.d.ts","names":[],"sources":["../../src/adapters/anthropic.ts"],"sourcesContent":null,"mappings":";;;AAKiB,UAAA,oBAAA,CAAoB;EAAA,SAAA,IAAA,EAAA,QAAA;EAAA,SAEW,UAAA,CAAA,EAAxB,QAAwB,CAAf,MAAe,CAAA,MAAA,EAAA,UAAA,CAAA,CAAA;EAAU,SAAzB,QAAA,CAAA,EAAA,SAAA,MAAA,EAAA;EAAM,SAAf,WAAA,CAAA,EAAA,MAAA;AAAQ;AAKf,UAAA,aAAA,CAAa;EAAA,SAAA,IAAA,EAAA,MAAA;EAAA,SAGL,WAAA,EAAA,MAAA;EAAoB,SAAG,YAAA,EAAvB,oBAAuB,GAAA,UAAA;AAAU;AAG1C,iBAAA,gBAAA,CAAgB,UAAA,EAAA,SACT,SADS,EAAA,EAAA,QAAA,CAAA,EAGnB,cAHmB,CAAA,EAAA,SAIpB,aAJoB,EAAA;AAAA,iBAYV,wBAAA,CAZU,UAAA,EAAA,SAaT,SAbS,EAAA,EAAA,QAAA,EAAA,MAAA,EAAA,SAAA,EAenB,MAfmB,CAAA,MAAA,EAAA,OAAA,CAAA,EAAA,OAAA,CAAA,EAgBpB,cAhBoB,CAAA,EAiB7B,OAjB6B,CAAA,OAAA,CAAA"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import "../errors-DX7yw6Gl.js";
|
|
2
|
+
import { safeExecute } from "../catch-errors-Cpn2vHir.js";
|
|
3
|
+
|
|
4
|
+
//#region src/adapters/anthropic.ts
|
|
5
|
+
function toAnthropicTools(agentTools, _options) {
|
|
6
|
+
return agentTools.map((tool) => ({
|
|
7
|
+
name: tool.name,
|
|
8
|
+
description: tool.description,
|
|
9
|
+
input_schema: {
|
|
10
|
+
...tool.parameters,
|
|
11
|
+
type: "object"
|
|
12
|
+
}
|
|
13
|
+
}));
|
|
14
|
+
}
|
|
15
|
+
async function executeAnthropicToolCall(agentTools, toolName, toolInput, options) {
|
|
16
|
+
return safeExecute(() => {
|
|
17
|
+
const tool = agentTools.find((t) => t.name === toolName);
|
|
18
|
+
if (!tool) throw new Error(`Tool not found: ${toolName}`);
|
|
19
|
+
return tool.execute(toolInput);
|
|
20
|
+
}, options?.catchErrors ?? false);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
//#endregion
|
|
24
|
+
export { executeAnthropicToolCall, toAnthropicTools };
|
|
25
|
+
//# sourceMappingURL=anthropic.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"anthropic.js","names":["agentTools: readonly AgentTool[]","_options?: AdapterOptions","toolName: string","toolInput: Record<string, unknown>","options?: AdapterOptions"],"sources":["../../src/adapters/anthropic.ts"],"sourcesContent":["import type { AgentTool, JsonSchema } from '../agent-tools.js';\nimport { type AdapterOptions, safeExecute } from './catch-errors.js';\n\nexport type { AgentTool, JsonSchema };\n\nexport interface AnthropicInputSchema {\n readonly type: 'object';\n readonly properties?: Readonly<Record<string, JsonSchema>>;\n readonly required?: readonly string[];\n readonly description?: string;\n}\n\nexport interface AnthropicTool {\n readonly name: string;\n readonly description: string;\n readonly input_schema: AnthropicInputSchema & JsonSchema;\n}\n\nexport function toAnthropicTools(\n agentTools: readonly AgentTool[],\n // accepted for API symmetry with executeAnthropicToolCall; catchErrors only applies at call time\n _options?: AdapterOptions,\n): readonly AnthropicTool[] {\n return agentTools.map((tool) => ({\n name: tool.name,\n description: tool.description,\n input_schema: { ...tool.parameters, type: 'object' as const },\n }));\n}\n\nexport async function executeAnthropicToolCall(\n agentTools: readonly AgentTool[],\n toolName: string,\n toolInput: Record<string, unknown>,\n options?: AdapterOptions,\n): Promise<unknown> {\n return safeExecute(() => {\n const tool = agentTools.find((t) => t.name === toolName);\n if (!tool) throw new Error(`Tool not found: ${toolName}`);\n return tool.execute(toolInput);\n }, options?.catchErrors ?? false);\n}\n"],"mappings":";;;;AAkBA,SAAgB,iBACdA,YAEAC,UAC0B;AAC1B,QAAO,WAAW,IAAI,CAAC,UAAU;EAC/B,MAAM,KAAK;EACX,aAAa,KAAK;EAClB,cAAc;GAAE,GAAG,KAAK;GAAY,MAAM;EAAmB;CAC9D,GAAE;AACJ;AAED,eAAsB,yBACpBD,YACAE,UACAC,WACAC,SACkB;AAClB,QAAO,YAAY,MAAM;EACvB,MAAM,OAAO,WAAW,KAAK,CAAC,MAAM,EAAE,SAAS,SAAS;AACxD,OAAK,KAAM,OAAM,IAAI,OAAO,kBAAkB,SAAS;AACvD,SAAO,KAAK,QAAQ,UAAU;CAC/B,GAAE,SAAS,eAAe,MAAM;AAClC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
require('../errors-C1XqxNmZ.cjs');
|
|
3
|
+
const require_catch_errors = require('../catch-errors-BZP237w4.cjs');
|
|
4
|
+
|
|
5
|
+
//#region src/adapters/langchain.ts
|
|
6
|
+
function toLangChainTools(agentTools, options) {
|
|
7
|
+
return agentTools.map((tool) => ({
|
|
8
|
+
name: tool.name,
|
|
9
|
+
description: tool.description,
|
|
10
|
+
schema: tool.parameters,
|
|
11
|
+
call: async (input) => {
|
|
12
|
+
const result = await require_catch_errors.safeExecute(() => tool.execute(input), options?.catchErrors ?? false);
|
|
13
|
+
return JSON.stringify(result);
|
|
14
|
+
}
|
|
15
|
+
}));
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
//#endregion
|
|
19
|
+
exports.toLangChainTools = toLangChainTools
|
|
20
|
+
//# sourceMappingURL=langchain.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"langchain.cjs","names":["agentTools: readonly AgentTool[]","options?: AdapterOptions","input: Record<string, unknown>"],"sources":["../../src/adapters/langchain.ts"],"sourcesContent":["import type { AgentTool, JsonSchema } from '../agent-tools.js';\nimport { type AdapterOptions, safeExecute } from './catch-errors.js';\n\nexport type { AgentTool, JsonSchema };\n\nexport interface LangChainTool {\n readonly name: string;\n readonly description: string;\n readonly schema: JsonSchema;\n readonly call: (input: Record<string, unknown>) => Promise<string>;\n}\n\nexport function toLangChainTools(\n agentTools: readonly AgentTool[],\n options?: AdapterOptions,\n): readonly LangChainTool[] {\n return agentTools.map((tool) => ({\n name: tool.name,\n description: tool.description,\n schema: tool.parameters,\n call: async (input: Record<string, unknown>): Promise<string> => {\n const result = await safeExecute(() => tool.execute(input), options?.catchErrors ?? false);\n return JSON.stringify(result);\n },\n }));\n}\n"],"mappings":";;;;;AAYA,SAAgB,iBACdA,YACAC,SAC0B;AAC1B,QAAO,WAAW,IAAI,CAAC,UAAU;EAC/B,MAAM,KAAK;EACX,aAAa,KAAK;EAClB,QAAQ,KAAK;EACb,MAAM,OAAOC,UAAoD;GAC/D,MAAM,SAAS,MAAM,iCAAY,MAAM,KAAK,QAAQ,MAAM,EAAE,SAAS,eAAe,MAAM;AAC1F,UAAO,KAAK,UAAU,OAAO;EAC9B;CACF,GAAE;AACJ"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { AdapterOptions, AgentTool, JsonSchema } from "../catch-errors-CbIHeFvF.cjs";
|
|
2
|
+
|
|
3
|
+
//#region src/adapters/langchain.d.ts
|
|
4
|
+
interface LangChainTool {
|
|
5
|
+
readonly name: string;
|
|
6
|
+
readonly description: string;
|
|
7
|
+
readonly schema: JsonSchema;
|
|
8
|
+
readonly call: (input: Record<string, unknown>) => Promise<string>;
|
|
9
|
+
}
|
|
10
|
+
declare function toLangChainTools(agentTools: readonly AgentTool[], options?: AdapterOptions): readonly LangChainTool[];
|
|
11
|
+
|
|
12
|
+
//#endregion
|
|
13
|
+
//# sourceMappingURL=langchain.d.ts.map
|
|
14
|
+
|
|
15
|
+
export { AgentTool, JsonSchema, LangChainTool, toLangChainTools };
|
|
16
|
+
//# sourceMappingURL=langchain.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"langchain.d.cts","names":[],"sources":["../../src/adapters/langchain.ts"],"sourcesContent":null,"mappings":";;;AAKiB,UAAA,aAAA,CAAa;EAAA,SAAA,IAAA,EAAA,MAAA;EAAA,SAGX,WAAA,EAAA,MAAA;EAAU,SACJ,MAAA,EADN,UACM;EAAM,SAAsB,IAAA,EAAA,CAAA,KAAA,EAA5B,MAA4B,CAAA,MAAA,EAAA,OAAA,CAAA,EAAA,GAAA,OAAA,CAAA,MAAA,CAAA;AAAO;AAG5C,iBAAA,gBAAA,CAAgB,UAAA,EAAA,SACT,SADS,EAAA,EAAA,OAAA,CAAA,EAEpB,cAFoB,CAAA,EAAA,SAGpB,aAHoB,EAAA"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { AdapterOptions, AgentTool, JsonSchema } from "../catch-errors-H8gObrht.js";
|
|
2
|
+
|
|
3
|
+
//#region src/adapters/langchain.d.ts
|
|
4
|
+
interface LangChainTool {
|
|
5
|
+
readonly name: string;
|
|
6
|
+
readonly description: string;
|
|
7
|
+
readonly schema: JsonSchema;
|
|
8
|
+
readonly call: (input: Record<string, unknown>) => Promise<string>;
|
|
9
|
+
}
|
|
10
|
+
declare function toLangChainTools(agentTools: readonly AgentTool[], options?: AdapterOptions): readonly LangChainTool[];
|
|
11
|
+
|
|
12
|
+
//#endregion
|
|
13
|
+
//# sourceMappingURL=langchain.d.ts.map
|
|
14
|
+
|
|
15
|
+
export { AgentTool, JsonSchema, LangChainTool, toLangChainTools };
|
|
16
|
+
//# sourceMappingURL=langchain.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"langchain.d.ts","names":[],"sources":["../../src/adapters/langchain.ts"],"sourcesContent":null,"mappings":";;;AAKiB,UAAA,aAAA,CAAa;EAAA,SAAA,IAAA,EAAA,MAAA;EAAA,SAGX,WAAA,EAAA,MAAA;EAAU,SACJ,MAAA,EADN,UACM;EAAM,SAAsB,IAAA,EAAA,CAAA,KAAA,EAA5B,MAA4B,CAAA,MAAA,EAAA,OAAA,CAAA,EAAA,GAAA,OAAA,CAAA,MAAA,CAAA;AAAO;AAG5C,iBAAA,gBAAA,CAAgB,UAAA,EAAA,SACT,SADS,EAAA,EAAA,OAAA,CAAA,EAEpB,cAFoB,CAAA,EAAA,SAGpB,aAHoB,EAAA"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import "../errors-DX7yw6Gl.js";
|
|
2
|
+
import { safeExecute } from "../catch-errors-Cpn2vHir.js";
|
|
3
|
+
|
|
4
|
+
//#region src/adapters/langchain.ts
|
|
5
|
+
function toLangChainTools(agentTools, options) {
|
|
6
|
+
return agentTools.map((tool) => ({
|
|
7
|
+
name: tool.name,
|
|
8
|
+
description: tool.description,
|
|
9
|
+
schema: tool.parameters,
|
|
10
|
+
call: async (input) => {
|
|
11
|
+
const result = await safeExecute(() => tool.execute(input), options?.catchErrors ?? false);
|
|
12
|
+
return JSON.stringify(result);
|
|
13
|
+
}
|
|
14
|
+
}));
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
//#endregion
|
|
18
|
+
export { toLangChainTools };
|
|
19
|
+
//# sourceMappingURL=langchain.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"langchain.js","names":["agentTools: readonly AgentTool[]","options?: AdapterOptions","input: Record<string, unknown>"],"sources":["../../src/adapters/langchain.ts"],"sourcesContent":["import type { AgentTool, JsonSchema } from '../agent-tools.js';\nimport { type AdapterOptions, safeExecute } from './catch-errors.js';\n\nexport type { AgentTool, JsonSchema };\n\nexport interface LangChainTool {\n readonly name: string;\n readonly description: string;\n readonly schema: JsonSchema;\n readonly call: (input: Record<string, unknown>) => Promise<string>;\n}\n\nexport function toLangChainTools(\n agentTools: readonly AgentTool[],\n options?: AdapterOptions,\n): readonly LangChainTool[] {\n return agentTools.map((tool) => ({\n name: tool.name,\n description: tool.description,\n schema: tool.parameters,\n call: async (input: Record<string, unknown>): Promise<string> => {\n const result = await safeExecute(() => tool.execute(input), options?.catchErrors ?? false);\n return JSON.stringify(result);\n },\n }));\n}\n"],"mappings":";;;;AAYA,SAAgB,iBACdA,YACAC,SAC0B;AAC1B,QAAO,WAAW,IAAI,CAAC,UAAU;EAC/B,MAAM,KAAK;EACX,aAAa,KAAK;EAClB,QAAQ,KAAK;EACb,MAAM,OAAOC,UAAoD;GAC/D,MAAM,SAAS,MAAM,YAAY,MAAM,KAAK,QAAQ,MAAM,EAAE,SAAS,eAAe,MAAM;AAC1F,UAAO,KAAK,UAAU,OAAO;EAC9B;CACF,GAAE;AACJ"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
require('../errors-C1XqxNmZ.cjs');
|
|
3
|
+
const require_catch_errors = require('../catch-errors-BZP237w4.cjs');
|
|
4
|
+
|
|
5
|
+
//#region src/adapters/mcp.ts
|
|
6
|
+
function toMCPTools(agentTools, _options) {
|
|
7
|
+
return agentTools.map((tool) => ({
|
|
8
|
+
name: tool.name,
|
|
9
|
+
description: tool.description,
|
|
10
|
+
inputSchema: {
|
|
11
|
+
...tool.parameters,
|
|
12
|
+
type: "object"
|
|
13
|
+
}
|
|
14
|
+
}));
|
|
15
|
+
}
|
|
16
|
+
async function executeMCPToolCall(agentTools, toolName, toolInput, options) {
|
|
17
|
+
return require_catch_errors.safeExecute(() => {
|
|
18
|
+
const tool = agentTools.find((t) => t.name === toolName);
|
|
19
|
+
if (!tool) throw new Error(`Tool not found: ${toolName}`);
|
|
20
|
+
return tool.execute(toolInput);
|
|
21
|
+
}, options?.catchErrors ?? false);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
//#endregion
|
|
25
|
+
exports.executeMCPToolCall = executeMCPToolCall
|
|
26
|
+
exports.toMCPTools = toMCPTools
|
|
27
|
+
//# sourceMappingURL=mcp.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcp.cjs","names":["agentTools: readonly AgentTool[]","_options?: AdapterOptions","toolName: string","toolInput: Record<string, unknown>","options?: AdapterOptions"],"sources":["../../src/adapters/mcp.ts"],"sourcesContent":["import type { AgentTool, JsonSchema } from '../agent-tools.js';\nimport { type AdapterOptions, safeExecute } from './catch-errors.js';\n\nexport type { AgentTool, JsonSchema };\n\nexport interface MCPInputSchema {\n readonly type: 'object';\n readonly properties?: Readonly<Record<string, JsonSchema>>;\n readonly required?: readonly string[];\n readonly description?: string;\n}\n\nexport interface MCPTool {\n readonly name: string;\n readonly description: string;\n readonly inputSchema: MCPInputSchema & JsonSchema;\n}\n\nexport function toMCPTools(\n agentTools: readonly AgentTool[],\n // accepted for API symmetry with executeMCPToolCall; catchErrors only applies at call time\n _options?: AdapterOptions,\n): readonly MCPTool[] {\n return agentTools.map((tool) => ({\n name: tool.name,\n description: tool.description,\n inputSchema: { ...tool.parameters, type: 'object' as const },\n }));\n}\n\nexport async function executeMCPToolCall(\n agentTools: readonly AgentTool[],\n toolName: string,\n toolInput: Record<string, unknown>,\n options?: AdapterOptions,\n): Promise<unknown> {\n return safeExecute(() => {\n const tool = agentTools.find((t) => t.name === toolName);\n if (!tool) throw new Error(`Tool not found: ${toolName}`);\n return tool.execute(toolInput);\n }, options?.catchErrors ?? false);\n}\n"],"mappings":";;;;;AAkBA,SAAgB,WACdA,YAEAC,UACoB;AACpB,QAAO,WAAW,IAAI,CAAC,UAAU;EAC/B,MAAM,KAAK;EACX,aAAa,KAAK;EAClB,aAAa;GAAE,GAAG,KAAK;GAAY,MAAM;EAAmB;CAC7D,GAAE;AACJ;AAED,eAAsB,mBACpBD,YACAE,UACAC,WACAC,SACkB;AAClB,QAAO,iCAAY,MAAM;EACvB,MAAM,OAAO,WAAW,KAAK,CAAC,MAAM,EAAE,SAAS,SAAS;AACxD,OAAK,KAAM,OAAM,IAAI,OAAO,kBAAkB,SAAS;AACvD,SAAO,KAAK,QAAQ,UAAU;CAC/B,GAAE,SAAS,eAAe,MAAM;AAClC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { AdapterOptions, AgentTool, JsonSchema } from "../catch-errors-CbIHeFvF.cjs";
|
|
2
|
+
|
|
3
|
+
//#region src/adapters/mcp.d.ts
|
|
4
|
+
interface MCPInputSchema {
|
|
5
|
+
readonly type: 'object';
|
|
6
|
+
readonly properties?: Readonly<Record<string, JsonSchema>>;
|
|
7
|
+
readonly required?: readonly string[];
|
|
8
|
+
readonly description?: string;
|
|
9
|
+
}
|
|
10
|
+
interface MCPTool {
|
|
11
|
+
readonly name: string;
|
|
12
|
+
readonly description: string;
|
|
13
|
+
readonly inputSchema: MCPInputSchema & JsonSchema;
|
|
14
|
+
}
|
|
15
|
+
declare function toMCPTools(agentTools: readonly AgentTool[], _options?: AdapterOptions): readonly MCPTool[];
|
|
16
|
+
declare function executeMCPToolCall(agentTools: readonly AgentTool[], toolName: string, toolInput: Record<string, unknown>, options?: AdapterOptions): Promise<unknown>;
|
|
17
|
+
|
|
18
|
+
//#endregion
|
|
19
|
+
//# sourceMappingURL=mcp.d.ts.map
|
|
20
|
+
|
|
21
|
+
export { AgentTool, JsonSchema, MCPInputSchema, MCPTool, executeMCPToolCall, toMCPTools };
|
|
22
|
+
//# sourceMappingURL=mcp.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcp.d.cts","names":[],"sources":["../../src/adapters/mcp.ts"],"sourcesContent":null,"mappings":";;;AAKiB,UAAA,cAAA,CAAc;EAAA,SAAA,IAAA,EAAA,QAAA;EAAA,SAEiB,UAAA,CAAA,EAAxB,QAAwB,CAAf,MAAe,CAAA,MAAA,EAAA,UAAA,CAAA,CAAA;EAAU,SAAzB,QAAA,CAAA,EAAA,SAAA,MAAA,EAAA;EAAM,SAAf,WAAA,CAAA,EAAA,MAAA;AAAQ;AAKf,UAAA,OAAA,CAAO;EAAA,SAAA,IAAA,EAAA,MAAA;EAAA,SAGA,WAAA,EAAA,MAAA;EAAc,SAAG,WAAA,EAAjB,cAAiB,GAAA,UAAA;AAAU;AAGnC,iBAAA,UAAA,CAAU,UAAA,EAAA,SACH,SADG,EAAA,EAAA,QAAA,CAAA,EAGb,cAHa,CAAA,EAAA,SAId,OAJc,EAAA;AAAA,iBAYJ,kBAAA,CAZI,UAAA,EAAA,SAaH,SAbG,EAAA,EAAA,QAAA,EAAA,MAAA,EAAA,SAAA,EAeb,MAfa,CAAA,MAAA,EAAA,OAAA,CAAA,EAAA,OAAA,CAAA,EAgBd,cAhBc,CAAA,EAiBvB,OAjBuB,CAAA,OAAA,CAAA"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { AdapterOptions, AgentTool, JsonSchema } from "../catch-errors-H8gObrht.js";
|
|
2
|
+
|
|
3
|
+
//#region src/adapters/mcp.d.ts
|
|
4
|
+
interface MCPInputSchema {
|
|
5
|
+
readonly type: 'object';
|
|
6
|
+
readonly properties?: Readonly<Record<string, JsonSchema>>;
|
|
7
|
+
readonly required?: readonly string[];
|
|
8
|
+
readonly description?: string;
|
|
9
|
+
}
|
|
10
|
+
interface MCPTool {
|
|
11
|
+
readonly name: string;
|
|
12
|
+
readonly description: string;
|
|
13
|
+
readonly inputSchema: MCPInputSchema & JsonSchema;
|
|
14
|
+
}
|
|
15
|
+
declare function toMCPTools(agentTools: readonly AgentTool[], _options?: AdapterOptions): readonly MCPTool[];
|
|
16
|
+
declare function executeMCPToolCall(agentTools: readonly AgentTool[], toolName: string, toolInput: Record<string, unknown>, options?: AdapterOptions): Promise<unknown>;
|
|
17
|
+
|
|
18
|
+
//#endregion
|
|
19
|
+
//# sourceMappingURL=mcp.d.ts.map
|
|
20
|
+
|
|
21
|
+
export { AgentTool, JsonSchema, MCPInputSchema, MCPTool, executeMCPToolCall, toMCPTools };
|
|
22
|
+
//# sourceMappingURL=mcp.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcp.d.ts","names":[],"sources":["../../src/adapters/mcp.ts"],"sourcesContent":null,"mappings":";;;AAKiB,UAAA,cAAA,CAAc;EAAA,SAAA,IAAA,EAAA,QAAA;EAAA,SAEiB,UAAA,CAAA,EAAxB,QAAwB,CAAf,MAAe,CAAA,MAAA,EAAA,UAAA,CAAA,CAAA;EAAU,SAAzB,QAAA,CAAA,EAAA,SAAA,MAAA,EAAA;EAAM,SAAf,WAAA,CAAA,EAAA,MAAA;AAAQ;AAKf,UAAA,OAAA,CAAO;EAAA,SAAA,IAAA,EAAA,MAAA;EAAA,SAGA,WAAA,EAAA,MAAA;EAAc,SAAG,WAAA,EAAjB,cAAiB,GAAA,UAAA;AAAU;AAGnC,iBAAA,UAAA,CAAU,UAAA,EAAA,SACH,SADG,EAAA,EAAA,QAAA,CAAA,EAGb,cAHa,CAAA,EAAA,SAId,OAJc,EAAA;AAAA,iBAYJ,kBAAA,CAZI,UAAA,EAAA,SAaH,SAbG,EAAA,EAAA,QAAA,EAAA,MAAA,EAAA,SAAA,EAeb,MAfa,CAAA,MAAA,EAAA,OAAA,CAAA,EAAA,OAAA,CAAA,EAgBd,cAhBc,CAAA,EAiBvB,OAjBuB,CAAA,OAAA,CAAA"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import "../errors-DX7yw6Gl.js";
|
|
2
|
+
import { safeExecute } from "../catch-errors-Cpn2vHir.js";
|
|
3
|
+
|
|
4
|
+
//#region src/adapters/mcp.ts
|
|
5
|
+
function toMCPTools(agentTools, _options) {
|
|
6
|
+
return agentTools.map((tool) => ({
|
|
7
|
+
name: tool.name,
|
|
8
|
+
description: tool.description,
|
|
9
|
+
inputSchema: {
|
|
10
|
+
...tool.parameters,
|
|
11
|
+
type: "object"
|
|
12
|
+
}
|
|
13
|
+
}));
|
|
14
|
+
}
|
|
15
|
+
async function executeMCPToolCall(agentTools, toolName, toolInput, options) {
|
|
16
|
+
return safeExecute(() => {
|
|
17
|
+
const tool = agentTools.find((t) => t.name === toolName);
|
|
18
|
+
if (!tool) throw new Error(`Tool not found: ${toolName}`);
|
|
19
|
+
return tool.execute(toolInput);
|
|
20
|
+
}, options?.catchErrors ?? false);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
//#endregion
|
|
24
|
+
export { executeMCPToolCall, toMCPTools };
|
|
25
|
+
//# sourceMappingURL=mcp.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcp.js","names":["agentTools: readonly AgentTool[]","_options?: AdapterOptions","toolName: string","toolInput: Record<string, unknown>","options?: AdapterOptions"],"sources":["../../src/adapters/mcp.ts"],"sourcesContent":["import type { AgentTool, JsonSchema } from '../agent-tools.js';\nimport { type AdapterOptions, safeExecute } from './catch-errors.js';\n\nexport type { AgentTool, JsonSchema };\n\nexport interface MCPInputSchema {\n readonly type: 'object';\n readonly properties?: Readonly<Record<string, JsonSchema>>;\n readonly required?: readonly string[];\n readonly description?: string;\n}\n\nexport interface MCPTool {\n readonly name: string;\n readonly description: string;\n readonly inputSchema: MCPInputSchema & JsonSchema;\n}\n\nexport function toMCPTools(\n agentTools: readonly AgentTool[],\n // accepted for API symmetry with executeMCPToolCall; catchErrors only applies at call time\n _options?: AdapterOptions,\n): readonly MCPTool[] {\n return agentTools.map((tool) => ({\n name: tool.name,\n description: tool.description,\n inputSchema: { ...tool.parameters, type: 'object' as const },\n }));\n}\n\nexport async function executeMCPToolCall(\n agentTools: readonly AgentTool[],\n toolName: string,\n toolInput: Record<string, unknown>,\n options?: AdapterOptions,\n): Promise<unknown> {\n return safeExecute(() => {\n const tool = agentTools.find((t) => t.name === toolName);\n if (!tool) throw new Error(`Tool not found: ${toolName}`);\n return tool.execute(toolInput);\n }, options?.catchErrors ?? false);\n}\n"],"mappings":";;;;AAkBA,SAAgB,WACdA,YAEAC,UACoB;AACpB,QAAO,WAAW,IAAI,CAAC,UAAU;EAC/B,MAAM,KAAK;EACX,aAAa,KAAK;EAClB,aAAa;GAAE,GAAG,KAAK;GAAY,MAAM;EAAmB;CAC7D,GAAE;AACJ;AAED,eAAsB,mBACpBD,YACAE,UACAC,WACAC,SACkB;AAClB,QAAO,YAAY,MAAM;EACvB,MAAM,OAAO,WAAW,KAAK,CAAC,MAAM,EAAE,SAAS,SAAS;AACxD,OAAK,KAAM,OAAM,IAAI,OAAO,kBAAkB,SAAS;AACvD,SAAO,KAAK,QAAQ,UAAU;CAC/B,GAAE,SAAS,eAAe,MAAM;AAClC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
require('../errors-C1XqxNmZ.cjs');
|
|
3
|
+
const require_catch_errors = require('../catch-errors-BZP237w4.cjs');
|
|
4
|
+
|
|
5
|
+
//#region src/adapters/openai.ts
|
|
6
|
+
function toOpenAITools(agentTools, _options) {
|
|
7
|
+
return agentTools.map((tool) => ({
|
|
8
|
+
type: "function",
|
|
9
|
+
function: {
|
|
10
|
+
name: tool.name,
|
|
11
|
+
description: tool.description,
|
|
12
|
+
parameters: tool.parameters
|
|
13
|
+
}
|
|
14
|
+
}));
|
|
15
|
+
}
|
|
16
|
+
async function executeOpenAIToolCall(agentTools, toolName, toolInput, options) {
|
|
17
|
+
return require_catch_errors.safeExecute(() => {
|
|
18
|
+
const tool = agentTools.find((t) => t.name === toolName);
|
|
19
|
+
if (!tool) throw new Error(`Tool not found: ${toolName}`);
|
|
20
|
+
return tool.execute(toolInput);
|
|
21
|
+
}, options?.catchErrors ?? false);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
//#endregion
|
|
25
|
+
exports.executeOpenAIToolCall = executeOpenAIToolCall
|
|
26
|
+
exports.toOpenAITools = toOpenAITools
|
|
27
|
+
//# sourceMappingURL=openai.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"openai.cjs","names":["agentTools: readonly AgentTool[]","_options?: AdapterOptions","toolName: string","toolInput: Record<string, unknown>","options?: AdapterOptions"],"sources":["../../src/adapters/openai.ts"],"sourcesContent":["import type { AgentTool, JsonSchema } from '../agent-tools.js';\nimport { type AdapterOptions, safeExecute } from './catch-errors.js';\n\nexport type { AgentTool, JsonSchema };\n\nexport interface OpenAIFunction {\n readonly name: string;\n readonly description: string;\n readonly parameters: JsonSchema;\n}\n\nexport interface OpenAITool {\n readonly type: 'function';\n readonly function: OpenAIFunction;\n}\n\nexport function toOpenAITools(\n agentTools: readonly AgentTool[],\n // accepted for API symmetry with executeOpenAIToolCall; catchErrors only applies at call time\n _options?: AdapterOptions,\n): readonly OpenAITool[] {\n return agentTools.map((tool) => ({\n type: 'function' as const,\n function: {\n name: tool.name,\n description: tool.description,\n parameters: tool.parameters,\n },\n }));\n}\n\nexport async function executeOpenAIToolCall(\n agentTools: readonly AgentTool[],\n toolName: string,\n toolInput: Record<string, unknown>,\n options?: AdapterOptions,\n): Promise<unknown> {\n return safeExecute(() => {\n const tool = agentTools.find((t) => t.name === toolName);\n if (!tool) throw new Error(`Tool not found: ${toolName}`);\n return tool.execute(toolInput);\n }, options?.catchErrors ?? false);\n}\n"],"mappings":";;;;;AAgBA,SAAgB,cACdA,YAEAC,UACuB;AACvB,QAAO,WAAW,IAAI,CAAC,UAAU;EAC/B,MAAM;EACN,UAAU;GACR,MAAM,KAAK;GACX,aAAa,KAAK;GAClB,YAAY,KAAK;EAClB;CACF,GAAE;AACJ;AAED,eAAsB,sBACpBD,YACAE,UACAC,WACAC,SACkB;AAClB,QAAO,iCAAY,MAAM;EACvB,MAAM,OAAO,WAAW,KAAK,CAAC,MAAM,EAAE,SAAS,SAAS;AACxD,OAAK,KAAM,OAAM,IAAI,OAAO,kBAAkB,SAAS;AACvD,SAAO,KAAK,QAAQ,UAAU;CAC/B,GAAE,SAAS,eAAe,MAAM;AAClC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { AdapterOptions, AgentTool, JsonSchema } from "../catch-errors-CbIHeFvF.cjs";
|
|
2
|
+
|
|
3
|
+
//#region src/adapters/openai.d.ts
|
|
4
|
+
interface OpenAIFunction {
|
|
5
|
+
readonly name: string;
|
|
6
|
+
readonly description: string;
|
|
7
|
+
readonly parameters: JsonSchema;
|
|
8
|
+
}
|
|
9
|
+
interface OpenAITool {
|
|
10
|
+
readonly type: 'function';
|
|
11
|
+
readonly function: OpenAIFunction;
|
|
12
|
+
}
|
|
13
|
+
declare function toOpenAITools(agentTools: readonly AgentTool[], _options?: AdapterOptions): readonly OpenAITool[];
|
|
14
|
+
declare function executeOpenAIToolCall(agentTools: readonly AgentTool[], toolName: string, toolInput: Record<string, unknown>, options?: AdapterOptions): Promise<unknown>;
|
|
15
|
+
|
|
16
|
+
//#endregion
|
|
17
|
+
//# sourceMappingURL=openai.d.ts.map
|
|
18
|
+
|
|
19
|
+
export { AgentTool, JsonSchema, OpenAIFunction, OpenAITool, executeOpenAIToolCall, toOpenAITools };
|
|
20
|
+
//# sourceMappingURL=openai.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"openai.d.cts","names":[],"sources":["../../src/adapters/openai.ts"],"sourcesContent":null,"mappings":";;;AAKiB,UAAA,cAAA,CAGM;EAGN,SAAA,IAAU,EAAA,MAAA;EAKX,SAAA,WAAa,EAAA,MAAA;EAAA,SAAA,UAAA,EARN,UAQM;;AAGhB,UARI,UAAA,CAQJ;EAAc,SACf,IAAA,EAAA,UAAA;EAAU,SAAA,QAAA,EAPD,cAOC;AAWtB;AAA2C,iBAf3B,aAAA,CAe2B,UAAA,EAAA,SAdpB,SAcoB,EAAA,EAAA,QAAA,CAAA,EAZ9B,cAY8B,CAAA,EAAA,SAX/B,UAW+B,EAAA;AACpB,iBADD,qBAAA,CACC,UAAA,EAAA,SAAA,SAAA,EAAA,EAAA,QAAA,EAAA,MAAA,EAAA,SAAA,EAEV,MAFU,CAAA,MAAA,EAAA,OAAA,CAAA,EAAA,OAAA,CAAA,EAGX,cAHW,CAAA,EAIpB,OAJoB,CAAA,OAAA,CAAA"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { AdapterOptions, AgentTool, JsonSchema } from "../catch-errors-H8gObrht.js";
|
|
2
|
+
|
|
3
|
+
//#region src/adapters/openai.d.ts
|
|
4
|
+
interface OpenAIFunction {
|
|
5
|
+
readonly name: string;
|
|
6
|
+
readonly description: string;
|
|
7
|
+
readonly parameters: JsonSchema;
|
|
8
|
+
}
|
|
9
|
+
interface OpenAITool {
|
|
10
|
+
readonly type: 'function';
|
|
11
|
+
readonly function: OpenAIFunction;
|
|
12
|
+
}
|
|
13
|
+
declare function toOpenAITools(agentTools: readonly AgentTool[], _options?: AdapterOptions): readonly OpenAITool[];
|
|
14
|
+
declare function executeOpenAIToolCall(agentTools: readonly AgentTool[], toolName: string, toolInput: Record<string, unknown>, options?: AdapterOptions): Promise<unknown>;
|
|
15
|
+
|
|
16
|
+
//#endregion
|
|
17
|
+
//# sourceMappingURL=openai.d.ts.map
|
|
18
|
+
|
|
19
|
+
export { AgentTool, JsonSchema, OpenAIFunction, OpenAITool, executeOpenAIToolCall, toOpenAITools };
|
|
20
|
+
//# sourceMappingURL=openai.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"openai.d.ts","names":[],"sources":["../../src/adapters/openai.ts"],"sourcesContent":null,"mappings":";;;AAKiB,UAAA,cAAA,CAGM;EAGN,SAAA,IAAU,EAAA,MAAA;EAKX,SAAA,WAAa,EAAA,MAAA;EAAA,SAAA,UAAA,EARN,UAQM;;AAGhB,UARI,UAAA,CAQJ;EAAc,SACf,IAAA,EAAA,UAAA;EAAU,SAAA,QAAA,EAPD,cAOC;AAWtB;AAA2C,iBAf3B,aAAA,CAe2B,UAAA,EAAA,SAdpB,SAcoB,EAAA,EAAA,QAAA,CAAA,EAZ9B,cAY8B,CAAA,EAAA,SAX/B,UAW+B,EAAA;AACpB,iBADD,qBAAA,CACC,UAAA,EAAA,SAAA,SAAA,EAAA,EAAA,QAAA,EAAA,MAAA,EAAA,SAAA,EAEV,MAFU,CAAA,MAAA,EAAA,OAAA,CAAA,EAAA,OAAA,CAAA,EAGX,cAHW,CAAA,EAIpB,OAJoB,CAAA,OAAA,CAAA"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import "../errors-DX7yw6Gl.js";
|
|
2
|
+
import { safeExecute } from "../catch-errors-Cpn2vHir.js";
|
|
3
|
+
|
|
4
|
+
//#region src/adapters/openai.ts
|
|
5
|
+
function toOpenAITools(agentTools, _options) {
|
|
6
|
+
return agentTools.map((tool) => ({
|
|
7
|
+
type: "function",
|
|
8
|
+
function: {
|
|
9
|
+
name: tool.name,
|
|
10
|
+
description: tool.description,
|
|
11
|
+
parameters: tool.parameters
|
|
12
|
+
}
|
|
13
|
+
}));
|
|
14
|
+
}
|
|
15
|
+
async function executeOpenAIToolCall(agentTools, toolName, toolInput, options) {
|
|
16
|
+
return safeExecute(() => {
|
|
17
|
+
const tool = agentTools.find((t) => t.name === toolName);
|
|
18
|
+
if (!tool) throw new Error(`Tool not found: ${toolName}`);
|
|
19
|
+
return tool.execute(toolInput);
|
|
20
|
+
}, options?.catchErrors ?? false);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
//#endregion
|
|
24
|
+
export { executeOpenAIToolCall, toOpenAITools };
|
|
25
|
+
//# sourceMappingURL=openai.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"openai.js","names":["agentTools: readonly AgentTool[]","_options?: AdapterOptions","toolName: string","toolInput: Record<string, unknown>","options?: AdapterOptions"],"sources":["../../src/adapters/openai.ts"],"sourcesContent":["import type { AgentTool, JsonSchema } from '../agent-tools.js';\nimport { type AdapterOptions, safeExecute } from './catch-errors.js';\n\nexport type { AgentTool, JsonSchema };\n\nexport interface OpenAIFunction {\n readonly name: string;\n readonly description: string;\n readonly parameters: JsonSchema;\n}\n\nexport interface OpenAITool {\n readonly type: 'function';\n readonly function: OpenAIFunction;\n}\n\nexport function toOpenAITools(\n agentTools: readonly AgentTool[],\n // accepted for API symmetry with executeOpenAIToolCall; catchErrors only applies at call time\n _options?: AdapterOptions,\n): readonly OpenAITool[] {\n return agentTools.map((tool) => ({\n type: 'function' as const,\n function: {\n name: tool.name,\n description: tool.description,\n parameters: tool.parameters,\n },\n }));\n}\n\nexport async function executeOpenAIToolCall(\n agentTools: readonly AgentTool[],\n toolName: string,\n toolInput: Record<string, unknown>,\n options?: AdapterOptions,\n): Promise<unknown> {\n return safeExecute(() => {\n const tool = agentTools.find((t) => t.name === toolName);\n if (!tool) throw new Error(`Tool not found: ${toolName}`);\n return tool.execute(toolInput);\n }, options?.catchErrors ?? false);\n}\n"],"mappings":";;;;AAgBA,SAAgB,cACdA,YAEAC,UACuB;AACvB,QAAO,WAAW,IAAI,CAAC,UAAU;EAC/B,MAAM;EACN,UAAU;GACR,MAAM,KAAK;GACX,aAAa,KAAK;GAClB,YAAY,KAAK;EAClB;CACF,GAAE;AACJ;AAED,eAAsB,sBACpBD,YACAE,UACAC,WACAC,SACkB;AAClB,QAAO,YAAY,MAAM;EACvB,MAAM,OAAO,WAAW,KAAK,CAAC,MAAM,EAAE,SAAS,SAAS;AACxD,OAAK,KAAM,OAAM,IAAI,OAAO,kBAAkB,SAAS;AACvD,SAAO,KAAK,QAAQ,UAAU;CAC/B,GAAE,SAAS,eAAe,MAAM;AAClC"}
|