@omnixhq/ucp-client 0.2.0 → 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.
Files changed (62) hide show
  1. package/README.md +35 -2
  2. package/dist/adapters/anthropic.cjs +9 -5
  3. package/dist/adapters/anthropic.cjs.map +1 -1
  4. package/dist/adapters/anthropic.d.cts +3 -3
  5. package/dist/adapters/anthropic.d.cts.map +1 -1
  6. package/dist/adapters/anthropic.d.ts +3 -3
  7. package/dist/adapters/anthropic.d.ts.map +1 -1
  8. package/dist/adapters/anthropic.js +10 -5
  9. package/dist/adapters/anthropic.js.map +1 -1
  10. package/dist/adapters/langchain.cjs +4 -2
  11. package/dist/adapters/langchain.cjs.map +1 -1
  12. package/dist/adapters/langchain.d.cts +2 -2
  13. package/dist/adapters/langchain.d.cts.map +1 -1
  14. package/dist/adapters/langchain.d.ts +2 -2
  15. package/dist/adapters/langchain.d.ts.map +1 -1
  16. package/dist/adapters/langchain.js +5 -2
  17. package/dist/adapters/langchain.js.map +1 -1
  18. package/dist/adapters/mcp.cjs +9 -5
  19. package/dist/adapters/mcp.cjs.map +1 -1
  20. package/dist/adapters/mcp.d.cts +3 -3
  21. package/dist/adapters/mcp.d.cts.map +1 -1
  22. package/dist/adapters/mcp.d.ts +3 -3
  23. package/dist/adapters/mcp.d.ts.map +1 -1
  24. package/dist/adapters/mcp.js +10 -5
  25. package/dist/adapters/mcp.js.map +1 -1
  26. package/dist/adapters/openai.cjs +9 -5
  27. package/dist/adapters/openai.cjs.map +1 -1
  28. package/dist/adapters/openai.d.cts +3 -3
  29. package/dist/adapters/openai.d.cts.map +1 -1
  30. package/dist/adapters/openai.d.ts +3 -3
  31. package/dist/adapters/openai.d.ts.map +1 -1
  32. package/dist/adapters/openai.js +10 -5
  33. package/dist/adapters/openai.js.map +1 -1
  34. package/dist/adapters/vercel-ai.cjs +4 -2
  35. package/dist/adapters/vercel-ai.cjs.map +1 -1
  36. package/dist/adapters/vercel-ai.d.cts +2 -2
  37. package/dist/adapters/vercel-ai.d.cts.map +1 -1
  38. package/dist/adapters/vercel-ai.d.ts +2 -2
  39. package/dist/adapters/vercel-ai.d.ts.map +1 -1
  40. package/dist/adapters/vercel-ai.js +5 -2
  41. package/dist/adapters/vercel-ai.js.map +1 -1
  42. package/dist/catch-errors-BZP237w4.cjs +31 -0
  43. package/dist/catch-errors-BZP237w4.cjs.map +1 -0
  44. package/dist/{agent-tools-o2PEyGqh.d.cts → catch-errors-CbIHeFvF.d.cts} +13 -2
  45. package/dist/catch-errors-CbIHeFvF.d.cts.map +1 -0
  46. package/dist/catch-errors-Cpn2vHir.js +25 -0
  47. package/dist/catch-errors-Cpn2vHir.js.map +1 -0
  48. package/dist/{agent-tools-DBOuuSEd.d.ts → catch-errors-H8gObrht.d.ts} +13 -2
  49. package/dist/catch-errors-H8gObrht.d.ts.map +1 -0
  50. package/dist/errors-C1XqxNmZ.cjs +77 -0
  51. package/dist/errors-C1XqxNmZ.cjs.map +1 -0
  52. package/dist/errors-DX7yw6Gl.js +52 -0
  53. package/dist/errors-DX7yw6Gl.js.map +1 -0
  54. package/dist/index.cjs +137 -63
  55. package/dist/index.cjs.map +1 -1
  56. package/dist/index.d.cts +2 -2
  57. package/dist/index.d.ts +2 -2
  58. package/dist/index.js +124 -50
  59. package/dist/index.js.map +1 -1
  60. package/package.json +27 -4
  61. package/dist/agent-tools-DBOuuSEd.d.ts.map +0 -1
  62. package/dist/agent-tools-o2PEyGqh.d.cts.map +0 -1
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 { UCPError, UCPEscalationError } from '@omnixhq/ucp-client';
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:
@@ -236,7 +268,8 @@ server.setRequestHandler(CallToolRequestSchema, async (req) => ({
236
268
  ```bash
237
269
  npm install
238
270
  npm run build # tsdown (dual ESM + CJS)
239
- npm test # vitest (116 unit tests)
271
+ npm test # vitest (unit tests)
272
+ npm run test:types # type-level tests (vitest --typecheck.only)
240
273
  npm run typecheck # tsc --noEmit
241
274
  npm run lint # eslint
242
275
  npm run check:exports # attw
@@ -1,7 +1,9 @@
1
1
  "use strict";
2
+ require('../errors-C1XqxNmZ.cjs');
3
+ const require_catch_errors = require('../catch-errors-BZP237w4.cjs');
2
4
 
3
5
  //#region src/adapters/anthropic.ts
4
- function toAnthropicTools(agentTools) {
6
+ function toAnthropicTools(agentTools, _options) {
5
7
  return agentTools.map((tool) => ({
6
8
  name: tool.name,
7
9
  description: tool.description,
@@ -11,10 +13,12 @@ function toAnthropicTools(agentTools) {
11
13
  }
12
14
  }));
13
15
  }
14
- async function executeAnthropicToolCall(agentTools, toolName, toolInput) {
15
- const tool = agentTools.find((t) => t.name === toolName);
16
- if (!tool) throw new Error(`Tool not found: ${toolName}`);
17
- return tool.execute(toolInput);
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);
18
22
  }
19
23
 
20
24
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"anthropic.cjs","names":["agentTools: readonly AgentTool[]","toolName: string","toolInput: Record<string, unknown>"],"sources":["../../src/adapters/anthropic.ts"],"sourcesContent":["import type { AgentTool, JsonSchema } from '../agent-tools.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(agentTools: readonly AgentTool[]): 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): Promise<unknown> {\n const tool = agentTools.find((t) => t.name === toolName);\n if (!tool) {\n throw new Error(`Tool not found: ${toolName}`);\n }\n return tool.execute(toolInput);\n}\n"],"mappings":";;;AAiBA,SAAgB,iBAAiBA,YAA4D;AAC3F,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,yBACpBA,YACAC,UACAC,WACkB;CAClB,MAAM,OAAO,WAAW,KAAK,CAAC,MAAM,EAAE,SAAS,SAAS;AACxD,MAAK,KACH,OAAM,IAAI,OAAO,kBAAkB,SAAS;AAE9C,QAAO,KAAK,QAAQ,UAAU;AAC/B"}
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"}
@@ -1,4 +1,4 @@
1
- import { AgentTool, JsonSchema } from "../agent-tools-o2PEyGqh.cjs";
1
+ import { AdapterOptions, AgentTool, JsonSchema } from "../catch-errors-CbIHeFvF.cjs";
2
2
 
3
3
  //#region src/adapters/anthropic.d.ts
4
4
  interface AnthropicInputSchema {
@@ -12,8 +12,8 @@ interface AnthropicTool {
12
12
  readonly description: string;
13
13
  readonly input_schema: AnthropicInputSchema & JsonSchema;
14
14
  }
15
- declare function toAnthropicTools(agentTools: readonly AgentTool[]): readonly AnthropicTool[];
16
- declare function executeAnthropicToolCall(agentTools: readonly AgentTool[], toolName: string, toolInput: Record<string, unknown>): Promise<unknown>;
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
17
 
18
18
  //#endregion
19
19
  //# sourceMappingURL=anthropic.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"anthropic.d.cts","names":[],"sources":["../../src/adapters/anthropic.ts"],"sourcesContent":null,"mappings":";;;UAIiB,oBAAA;EAAA,SAAA,IAAA,EAAA,QAAoB;EAAA,SAAA,UAAA,CAAA,EAEb,QAFa,CAEJ,MAFI,CAAA,MAAA,EAEW,UAFX,CAAA,CAAA;EAAA,SAEW,QAAA,CAAA,EAAA,SAAA,MAAA,EAAA;EAAU,SAAzB,WAAA,CAAA,EAAA,MAAA;;AAAD,UAKf,aAAA,CALe;EAKf,SAAA,IAAA,EAAA,MAAa;EAAA,SAAA,WAAA,EAAA,MAAA;EAAA,SAGL,YAAA,EAAA,oBAAA,GAAuB,UAAvB;;AAAiC,iBAG1C,gBAAA,CAH0C,UAAA,EAAA,SAGJ,SAHI,EAAA,CAAA,EAAA,SAGmB,aAHnB,EAAA;AAG1C,iBAQM,wBAAA,CARU,UAAA,EAAA,SAST,SATS,EAAA,EAAA,QAAA,EAAA,MAAA,EAAA,SAAA,EAWnB,MAXmB,CAAA,MAAA,EAAA,OAAA,CAAA,CAAA,EAY7B,OAZ6B,CAAA,OAAA,CAAA"}
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"}
@@ -1,4 +1,4 @@
1
- import { AgentTool, JsonSchema } from "../agent-tools-DBOuuSEd.js";
1
+ import { AdapterOptions, AgentTool, JsonSchema } from "../catch-errors-H8gObrht.js";
2
2
 
3
3
  //#region src/adapters/anthropic.d.ts
4
4
  interface AnthropicInputSchema {
@@ -12,8 +12,8 @@ interface AnthropicTool {
12
12
  readonly description: string;
13
13
  readonly input_schema: AnthropicInputSchema & JsonSchema;
14
14
  }
15
- declare function toAnthropicTools(agentTools: readonly AgentTool[]): readonly AnthropicTool[];
16
- declare function executeAnthropicToolCall(agentTools: readonly AgentTool[], toolName: string, toolInput: Record<string, unknown>): Promise<unknown>;
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
17
 
18
18
  //#endregion
19
19
  //# sourceMappingURL=anthropic.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"anthropic.d.ts","names":[],"sources":["../../src/adapters/anthropic.ts"],"sourcesContent":null,"mappings":";;;UAIiB,oBAAA;EAAA,SAAA,IAAA,EAAA,QAAoB;EAAA,SAAA,UAAA,CAAA,EAEb,QAFa,CAEJ,MAFI,CAAA,MAAA,EAEW,UAFX,CAAA,CAAA;EAAA,SAEW,QAAA,CAAA,EAAA,SAAA,MAAA,EAAA;EAAU,SAAzB,WAAA,CAAA,EAAA,MAAA;;AAAD,UAKf,aAAA,CALe;EAKf,SAAA,IAAA,EAAA,MAAa;EAAA,SAAA,WAAA,EAAA,MAAA;EAAA,SAGL,YAAA,EAAA,oBAAA,GAAuB,UAAvB;;AAAiC,iBAG1C,gBAAA,CAH0C,UAAA,EAAA,SAGJ,SAHI,EAAA,CAAA,EAAA,SAGmB,aAHnB,EAAA;AAG1C,iBAQM,wBAAA,CARU,UAAA,EAAA,SAST,SATS,EAAA,EAAA,QAAA,EAAA,MAAA,EAAA,SAAA,EAWnB,MAXmB,CAAA,MAAA,EAAA,OAAA,CAAA,CAAA,EAY7B,OAZ6B,CAAA,OAAA,CAAA"}
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"}
@@ -1,5 +1,8 @@
1
+ import "../errors-DX7yw6Gl.js";
2
+ import { safeExecute } from "../catch-errors-Cpn2vHir.js";
3
+
1
4
  //#region src/adapters/anthropic.ts
2
- function toAnthropicTools(agentTools) {
5
+ function toAnthropicTools(agentTools, _options) {
3
6
  return agentTools.map((tool) => ({
4
7
  name: tool.name,
5
8
  description: tool.description,
@@ -9,10 +12,12 @@ function toAnthropicTools(agentTools) {
9
12
  }
10
13
  }));
11
14
  }
12
- async function executeAnthropicToolCall(agentTools, toolName, toolInput) {
13
- const tool = agentTools.find((t) => t.name === toolName);
14
- if (!tool) throw new Error(`Tool not found: ${toolName}`);
15
- return tool.execute(toolInput);
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);
16
21
  }
17
22
 
18
23
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"anthropic.js","names":["agentTools: readonly AgentTool[]","toolName: string","toolInput: Record<string, unknown>"],"sources":["../../src/adapters/anthropic.ts"],"sourcesContent":["import type { AgentTool, JsonSchema } from '../agent-tools.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(agentTools: readonly AgentTool[]): 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): Promise<unknown> {\n const tool = agentTools.find((t) => t.name === toolName);\n if (!tool) {\n throw new Error(`Tool not found: ${toolName}`);\n }\n return tool.execute(toolInput);\n}\n"],"mappings":";AAiBA,SAAgB,iBAAiBA,YAA4D;AAC3F,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,yBACpBA,YACAC,UACAC,WACkB;CAClB,MAAM,OAAO,WAAW,KAAK,CAAC,MAAM,EAAE,SAAS,SAAS;AACxD,MAAK,KACH,OAAM,IAAI,OAAO,kBAAkB,SAAS;AAE9C,QAAO,KAAK,QAAQ,UAAU;AAC/B"}
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"}
@@ -1,13 +1,15 @@
1
1
  "use strict";
2
+ require('../errors-C1XqxNmZ.cjs');
3
+ const require_catch_errors = require('../catch-errors-BZP237w4.cjs');
2
4
 
3
5
  //#region src/adapters/langchain.ts
4
- function toLangChainTools(agentTools) {
6
+ function toLangChainTools(agentTools, options) {
5
7
  return agentTools.map((tool) => ({
6
8
  name: tool.name,
7
9
  description: tool.description,
8
10
  schema: tool.parameters,
9
11
  call: async (input) => {
10
- const result = await tool.execute(input);
12
+ const result = await require_catch_errors.safeExecute(() => tool.execute(input), options?.catchErrors ?? false);
11
13
  return JSON.stringify(result);
12
14
  }
13
15
  }));
@@ -1 +1 @@
1
- {"version":3,"file":"langchain.cjs","names":["agentTools: readonly AgentTool[]","input: Record<string, unknown>"],"sources":["../../src/adapters/langchain.ts"],"sourcesContent":["import type { AgentTool, JsonSchema } from '../agent-tools.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(agentTools: readonly AgentTool[]): 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 tool.execute(input);\n return JSON.stringify(result);\n },\n }));\n}\n"],"mappings":";;;AAWA,SAAgB,iBAAiBA,YAA4D;AAC3F,QAAO,WAAW,IAAI,CAAC,UAAU;EAC/B,MAAM,KAAK;EACX,aAAa,KAAK;EAClB,QAAQ,KAAK;EACb,MAAM,OAAOC,UAAoD;GAC/D,MAAM,SAAS,MAAM,KAAK,QAAQ,MAAM;AACxC,UAAO,KAAK,UAAU,OAAO;EAC9B;CACF,GAAE;AACJ"}
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"}
@@ -1,4 +1,4 @@
1
- import { AgentTool, JsonSchema } from "../agent-tools-o2PEyGqh.cjs";
1
+ import { AdapterOptions, AgentTool, JsonSchema } from "../catch-errors-CbIHeFvF.cjs";
2
2
 
3
3
  //#region src/adapters/langchain.d.ts
4
4
  interface LangChainTool {
@@ -7,7 +7,7 @@ interface LangChainTool {
7
7
  readonly schema: JsonSchema;
8
8
  readonly call: (input: Record<string, unknown>) => Promise<string>;
9
9
  }
10
- declare function toLangChainTools(agentTools: readonly AgentTool[]): readonly LangChainTool[];
10
+ declare function toLangChainTools(agentTools: readonly AgentTool[], options?: AdapterOptions): readonly LangChainTool[];
11
11
 
12
12
  //#endregion
13
13
  //# sourceMappingURL=langchain.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"langchain.d.cts","names":[],"sources":["../../src/adapters/langchain.ts"],"sourcesContent":null,"mappings":";;;UAIiB,aAAA;EAAA,SAAA,IAAA,EAAA,MAAa;EAAA,SAAA,WAAA,EAAA,MAAA;EAAA,SAGX,MAAA,EAAA,UAAA;EAAU,SACJ,IAAA,EAAA,CAAA,KAAA,EAAA,MAAA,CAAA,MAAA,EAAA,OAAA,CAAA,EAAA,GAA4B,OAA5B,CAAA,MAAA,CAAA;;AAAmC,iBAG5C,gBAAA,CAH4C,UAAA,EAAA,SAGN,SAHM,EAAA,CAAA,EAAA,SAGiB,aAHjB,EAAA;;;AAG5D"}
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"}
@@ -1,4 +1,4 @@
1
- import { AgentTool, JsonSchema } from "../agent-tools-DBOuuSEd.js";
1
+ import { AdapterOptions, AgentTool, JsonSchema } from "../catch-errors-H8gObrht.js";
2
2
 
3
3
  //#region src/adapters/langchain.d.ts
4
4
  interface LangChainTool {
@@ -7,7 +7,7 @@ interface LangChainTool {
7
7
  readonly schema: JsonSchema;
8
8
  readonly call: (input: Record<string, unknown>) => Promise<string>;
9
9
  }
10
- declare function toLangChainTools(agentTools: readonly AgentTool[]): readonly LangChainTool[];
10
+ declare function toLangChainTools(agentTools: readonly AgentTool[], options?: AdapterOptions): readonly LangChainTool[];
11
11
 
12
12
  //#endregion
13
13
  //# sourceMappingURL=langchain.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"langchain.d.ts","names":[],"sources":["../../src/adapters/langchain.ts"],"sourcesContent":null,"mappings":";;;UAIiB,aAAA;EAAA,SAAA,IAAA,EAAA,MAAa;EAAA,SAAA,WAAA,EAAA,MAAA;EAAA,SAGX,MAAA,EAAA,UAAA;EAAU,SACJ,IAAA,EAAA,CAAA,KAAA,EAAA,MAAA,CAAA,MAAA,EAAA,OAAA,CAAA,EAAA,GAA4B,OAA5B,CAAA,MAAA,CAAA;;AAAmC,iBAG5C,gBAAA,CAH4C,UAAA,EAAA,SAGN,SAHM,EAAA,CAAA,EAAA,SAGiB,aAHjB,EAAA;;;AAG5D"}
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"}
@@ -1,11 +1,14 @@
1
+ import "../errors-DX7yw6Gl.js";
2
+ import { safeExecute } from "../catch-errors-Cpn2vHir.js";
3
+
1
4
  //#region src/adapters/langchain.ts
2
- function toLangChainTools(agentTools) {
5
+ function toLangChainTools(agentTools, options) {
3
6
  return agentTools.map((tool) => ({
4
7
  name: tool.name,
5
8
  description: tool.description,
6
9
  schema: tool.parameters,
7
10
  call: async (input) => {
8
- const result = await tool.execute(input);
11
+ const result = await safeExecute(() => tool.execute(input), options?.catchErrors ?? false);
9
12
  return JSON.stringify(result);
10
13
  }
11
14
  }));
@@ -1 +1 @@
1
- {"version":3,"file":"langchain.js","names":["agentTools: readonly AgentTool[]","input: Record<string, unknown>"],"sources":["../../src/adapters/langchain.ts"],"sourcesContent":["import type { AgentTool, JsonSchema } from '../agent-tools.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(agentTools: readonly AgentTool[]): 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 tool.execute(input);\n return JSON.stringify(result);\n },\n }));\n}\n"],"mappings":";AAWA,SAAgB,iBAAiBA,YAA4D;AAC3F,QAAO,WAAW,IAAI,CAAC,UAAU;EAC/B,MAAM,KAAK;EACX,aAAa,KAAK;EAClB,QAAQ,KAAK;EACb,MAAM,OAAOC,UAAoD;GAC/D,MAAM,SAAS,MAAM,KAAK,QAAQ,MAAM;AACxC,UAAO,KAAK,UAAU,OAAO;EAC9B;CACF,GAAE;AACJ"}
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"}
@@ -1,7 +1,9 @@
1
1
  "use strict";
2
+ require('../errors-C1XqxNmZ.cjs');
3
+ const require_catch_errors = require('../catch-errors-BZP237w4.cjs');
2
4
 
3
5
  //#region src/adapters/mcp.ts
4
- function toMCPTools(agentTools) {
6
+ function toMCPTools(agentTools, _options) {
5
7
  return agentTools.map((tool) => ({
6
8
  name: tool.name,
7
9
  description: tool.description,
@@ -11,10 +13,12 @@ function toMCPTools(agentTools) {
11
13
  }
12
14
  }));
13
15
  }
14
- async function executeMCPToolCall(agentTools, toolName, toolInput) {
15
- const tool = agentTools.find((t) => t.name === toolName);
16
- if (!tool) throw new Error(`Tool not found: ${toolName}`);
17
- return tool.execute(toolInput);
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);
18
22
  }
19
23
 
20
24
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"mcp.cjs","names":["agentTools: readonly AgentTool[]","toolName: string","toolInput: Record<string, unknown>"],"sources":["../../src/adapters/mcp.ts"],"sourcesContent":["import type { AgentTool, JsonSchema } from '../agent-tools.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(agentTools: readonly AgentTool[]): 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): Promise<unknown> {\n const tool = agentTools.find((t) => t.name === toolName);\n if (!tool) {\n throw new Error(`Tool not found: ${toolName}`);\n }\n return tool.execute(toolInput);\n}\n"],"mappings":";;;AAiBA,SAAgB,WAAWA,YAAsD;AAC/E,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,mBACpBA,YACAC,UACAC,WACkB;CAClB,MAAM,OAAO,WAAW,KAAK,CAAC,MAAM,EAAE,SAAS,SAAS;AACxD,MAAK,KACH,OAAM,IAAI,OAAO,kBAAkB,SAAS;AAE9C,QAAO,KAAK,QAAQ,UAAU;AAC/B"}
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"}
@@ -1,4 +1,4 @@
1
- import { AgentTool, JsonSchema } from "../agent-tools-o2PEyGqh.cjs";
1
+ import { AdapterOptions, AgentTool, JsonSchema } from "../catch-errors-CbIHeFvF.cjs";
2
2
 
3
3
  //#region src/adapters/mcp.d.ts
4
4
  interface MCPInputSchema {
@@ -12,8 +12,8 @@ interface MCPTool {
12
12
  readonly description: string;
13
13
  readonly inputSchema: MCPInputSchema & JsonSchema;
14
14
  }
15
- declare function toMCPTools(agentTools: readonly AgentTool[]): readonly MCPTool[];
16
- declare function executeMCPToolCall(agentTools: readonly AgentTool[], toolName: string, toolInput: Record<string, unknown>): Promise<unknown>;
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
17
 
18
18
  //#endregion
19
19
  //# sourceMappingURL=mcp.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"mcp.d.cts","names":[],"sources":["../../src/adapters/mcp.ts"],"sourcesContent":null,"mappings":";;;UAIiB,cAAA;EAAA,SAAA,IAAA,EAAA,QAAc;EAAA,SAAA,UAAA,CAAA,EAEP,QAFO,CAEE,MAFF,CAAA,MAAA,EAEiB,UAFjB,CAAA,CAAA;EAAA,SAEiB,QAAA,CAAA,EAAA,SAAA,MAAA,EAAA;EAAU,SAAzB,WAAA,CAAA,EAAA,MAAA;;AAAD,UAKf,OAAA,CALe;EAKf,SAAA,IAAO,EAAA,MAAA;EAAA,SAAA,WAAA,EAAA,MAAA;EAAA,SAGA,WAAA,EAAA,cAAA,GAAiB,UAAjB;;AAA2B,iBAGnC,UAAA,CAHmC,UAAA,EAAA,SAGH,SAHG,EAAA,CAAA,EAAA,SAGoB,OAHpB,EAAA;AAGnC,iBAQM,kBAAA,CARI,UAAA,EAAA,SASH,SATG,EAAA,EAAA,QAAA,EAAA,MAAA,EAAA,SAAA,EAWb,MAXa,CAAA,MAAA,EAAA,OAAA,CAAA,CAAA,EAYvB,OAZuB,CAAA,OAAA,CAAA"}
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"}
@@ -1,4 +1,4 @@
1
- import { AgentTool, JsonSchema } from "../agent-tools-DBOuuSEd.js";
1
+ import { AdapterOptions, AgentTool, JsonSchema } from "../catch-errors-H8gObrht.js";
2
2
 
3
3
  //#region src/adapters/mcp.d.ts
4
4
  interface MCPInputSchema {
@@ -12,8 +12,8 @@ interface MCPTool {
12
12
  readonly description: string;
13
13
  readonly inputSchema: MCPInputSchema & JsonSchema;
14
14
  }
15
- declare function toMCPTools(agentTools: readonly AgentTool[]): readonly MCPTool[];
16
- declare function executeMCPToolCall(agentTools: readonly AgentTool[], toolName: string, toolInput: Record<string, unknown>): Promise<unknown>;
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
17
 
18
18
  //#endregion
19
19
  //# sourceMappingURL=mcp.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"mcp.d.ts","names":[],"sources":["../../src/adapters/mcp.ts"],"sourcesContent":null,"mappings":";;;UAIiB,cAAA;EAAA,SAAA,IAAA,EAAA,QAAc;EAAA,SAAA,UAAA,CAAA,EAEP,QAFO,CAEE,MAFF,CAAA,MAAA,EAEiB,UAFjB,CAAA,CAAA;EAAA,SAEiB,QAAA,CAAA,EAAA,SAAA,MAAA,EAAA;EAAU,SAAzB,WAAA,CAAA,EAAA,MAAA;;AAAD,UAKf,OAAA,CALe;EAKf,SAAA,IAAO,EAAA,MAAA;EAAA,SAAA,WAAA,EAAA,MAAA;EAAA,SAGA,WAAA,EAAA,cAAA,GAAiB,UAAjB;;AAA2B,iBAGnC,UAAA,CAHmC,UAAA,EAAA,SAGH,SAHG,EAAA,CAAA,EAAA,SAGoB,OAHpB,EAAA;AAGnC,iBAQM,kBAAA,CARI,UAAA,EAAA,SASH,SATG,EAAA,EAAA,QAAA,EAAA,MAAA,EAAA,SAAA,EAWb,MAXa,CAAA,MAAA,EAAA,OAAA,CAAA,CAAA,EAYvB,OAZuB,CAAA,OAAA,CAAA"}
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"}
@@ -1,5 +1,8 @@
1
+ import "../errors-DX7yw6Gl.js";
2
+ import { safeExecute } from "../catch-errors-Cpn2vHir.js";
3
+
1
4
  //#region src/adapters/mcp.ts
2
- function toMCPTools(agentTools) {
5
+ function toMCPTools(agentTools, _options) {
3
6
  return agentTools.map((tool) => ({
4
7
  name: tool.name,
5
8
  description: tool.description,
@@ -9,10 +12,12 @@ function toMCPTools(agentTools) {
9
12
  }
10
13
  }));
11
14
  }
12
- async function executeMCPToolCall(agentTools, toolName, toolInput) {
13
- const tool = agentTools.find((t) => t.name === toolName);
14
- if (!tool) throw new Error(`Tool not found: ${toolName}`);
15
- return tool.execute(toolInput);
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);
16
21
  }
17
22
 
18
23
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"mcp.js","names":["agentTools: readonly AgentTool[]","toolName: string","toolInput: Record<string, unknown>"],"sources":["../../src/adapters/mcp.ts"],"sourcesContent":["import type { AgentTool, JsonSchema } from '../agent-tools.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(agentTools: readonly AgentTool[]): 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): Promise<unknown> {\n const tool = agentTools.find((t) => t.name === toolName);\n if (!tool) {\n throw new Error(`Tool not found: ${toolName}`);\n }\n return tool.execute(toolInput);\n}\n"],"mappings":";AAiBA,SAAgB,WAAWA,YAAsD;AAC/E,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,mBACpBA,YACAC,UACAC,WACkB;CAClB,MAAM,OAAO,WAAW,KAAK,CAAC,MAAM,EAAE,SAAS,SAAS;AACxD,MAAK,KACH,OAAM,IAAI,OAAO,kBAAkB,SAAS;AAE9C,QAAO,KAAK,QAAQ,UAAU;AAC/B"}
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"}
@@ -1,7 +1,9 @@
1
1
  "use strict";
2
+ require('../errors-C1XqxNmZ.cjs');
3
+ const require_catch_errors = require('../catch-errors-BZP237w4.cjs');
2
4
 
3
5
  //#region src/adapters/openai.ts
4
- function toOpenAITools(agentTools) {
6
+ function toOpenAITools(agentTools, _options) {
5
7
  return agentTools.map((tool) => ({
6
8
  type: "function",
7
9
  function: {
@@ -11,10 +13,12 @@ function toOpenAITools(agentTools) {
11
13
  }
12
14
  }));
13
15
  }
14
- async function executeOpenAIToolCall(agentTools, toolName, toolInput) {
15
- const tool = agentTools.find((t) => t.name === toolName);
16
- if (!tool) throw new Error(`Tool not found: ${toolName}`);
17
- return tool.execute(toolInput);
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);
18
22
  }
19
23
 
20
24
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"openai.cjs","names":["agentTools: readonly AgentTool[]","toolName: string","toolInput: Record<string, unknown>"],"sources":["../../src/adapters/openai.ts"],"sourcesContent":["import type { AgentTool, JsonSchema } from '../agent-tools.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(agentTools: readonly AgentTool[]): 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): Promise<unknown> {\n const tool = agentTools.find((t) => t.name === toolName);\n if (!tool) {\n throw new Error(`Tool not found: ${toolName}`);\n }\n return tool.execute(toolInput);\n}\n"],"mappings":";;;AAeA,SAAgB,cAAcA,YAAyD;AACrF,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,sBACpBA,YACAC,UACAC,WACkB;CAClB,MAAM,OAAO,WAAW,KAAK,CAAC,MAAM,EAAE,SAAS,SAAS;AACxD,MAAK,KACH,OAAM,IAAI,OAAO,kBAAkB,SAAS;AAE9C,QAAO,KAAK,QAAQ,UAAU;AAC/B"}
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"}
@@ -1,4 +1,4 @@
1
- import { AgentTool, JsonSchema } from "../agent-tools-o2PEyGqh.cjs";
1
+ import { AdapterOptions, AgentTool, JsonSchema } from "../catch-errors-CbIHeFvF.cjs";
2
2
 
3
3
  //#region src/adapters/openai.d.ts
4
4
  interface OpenAIFunction {
@@ -10,8 +10,8 @@ interface OpenAITool {
10
10
  readonly type: 'function';
11
11
  readonly function: OpenAIFunction;
12
12
  }
13
- declare function toOpenAITools(agentTools: readonly AgentTool[]): readonly OpenAITool[];
14
- declare function executeOpenAIToolCall(agentTools: readonly AgentTool[], toolName: string, toolInput: Record<string, unknown>): Promise<unknown>;
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
15
 
16
16
  //#endregion
17
17
  //# sourceMappingURL=openai.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"openai.d.cts","names":[],"sources":["../../src/adapters/openai.ts"],"sourcesContent":null,"mappings":";;;UAIiB,cAAA;EAAA,SAAA,IAAA,EAAA,MAAc;EAMd,SAAA,WAAU,EAAA,MAEN;EAGL,SAAA,UAAa,EARN,UAQM;;AAAsB,UALlC,UAAA,CAKkC;EAAS,SAAc,IAAA,EAAA,UAAA;EAAU,SAAA,QAAA,EAH/D,cAG+D;AAWpF;AAA2C,iBAX3B,aAAA,CAW2B,UAAA,EAAA,SAXQ,SAWR,EAAA,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,CAAA,EAGpB,OAHoB,CAAA,OAAA,CAAA"}
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"}
@@ -1,4 +1,4 @@
1
- import { AgentTool, JsonSchema } from "../agent-tools-DBOuuSEd.js";
1
+ import { AdapterOptions, AgentTool, JsonSchema } from "../catch-errors-H8gObrht.js";
2
2
 
3
3
  //#region src/adapters/openai.d.ts
4
4
  interface OpenAIFunction {
@@ -10,8 +10,8 @@ interface OpenAITool {
10
10
  readonly type: 'function';
11
11
  readonly function: OpenAIFunction;
12
12
  }
13
- declare function toOpenAITools(agentTools: readonly AgentTool[]): readonly OpenAITool[];
14
- declare function executeOpenAIToolCall(agentTools: readonly AgentTool[], toolName: string, toolInput: Record<string, unknown>): Promise<unknown>;
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
15
 
16
16
  //#endregion
17
17
  //# sourceMappingURL=openai.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"openai.d.ts","names":[],"sources":["../../src/adapters/openai.ts"],"sourcesContent":null,"mappings":";;;UAIiB,cAAA;EAAA,SAAA,IAAA,EAAA,MAAc;EAMd,SAAA,WAAU,EAAA,MAEN;EAGL,SAAA,UAAa,EARN,UAQM;;AAAsB,UALlC,UAAA,CAKkC;EAAS,SAAc,IAAA,EAAA,UAAA;EAAU,SAAA,QAAA,EAH/D,cAG+D;AAWpF;AAA2C,iBAX3B,aAAA,CAW2B,UAAA,EAAA,SAXQ,SAWR,EAAA,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,CAAA,EAGpB,OAHoB,CAAA,OAAA,CAAA"}
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"}
@@ -1,5 +1,8 @@
1
+ import "../errors-DX7yw6Gl.js";
2
+ import { safeExecute } from "../catch-errors-Cpn2vHir.js";
3
+
1
4
  //#region src/adapters/openai.ts
2
- function toOpenAITools(agentTools) {
5
+ function toOpenAITools(agentTools, _options) {
3
6
  return agentTools.map((tool) => ({
4
7
  type: "function",
5
8
  function: {
@@ -9,10 +12,12 @@ function toOpenAITools(agentTools) {
9
12
  }
10
13
  }));
11
14
  }
12
- async function executeOpenAIToolCall(agentTools, toolName, toolInput) {
13
- const tool = agentTools.find((t) => t.name === toolName);
14
- if (!tool) throw new Error(`Tool not found: ${toolName}`);
15
- return tool.execute(toolInput);
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);
16
21
  }
17
22
 
18
23
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"openai.js","names":["agentTools: readonly AgentTool[]","toolName: string","toolInput: Record<string, unknown>"],"sources":["../../src/adapters/openai.ts"],"sourcesContent":["import type { AgentTool, JsonSchema } from '../agent-tools.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(agentTools: readonly AgentTool[]): 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): Promise<unknown> {\n const tool = agentTools.find((t) => t.name === toolName);\n if (!tool) {\n throw new Error(`Tool not found: ${toolName}`);\n }\n return tool.execute(toolInput);\n}\n"],"mappings":";AAeA,SAAgB,cAAcA,YAAyD;AACrF,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,sBACpBA,YACAC,UACAC,WACkB;CAClB,MAAM,OAAO,WAAW,KAAK,CAAC,MAAM,EAAE,SAAS,SAAS;AACxD,MAAK,KACH,OAAM,IAAI,OAAO,kBAAkB,SAAS;AAE9C,QAAO,KAAK,QAAQ,UAAU;AAC/B"}
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"}
@@ -1,12 +1,14 @@
1
1
  "use strict";
2
+ require('../errors-C1XqxNmZ.cjs');
3
+ const require_catch_errors = require('../catch-errors-BZP237w4.cjs');
2
4
 
3
5
  //#region src/adapters/vercel-ai.ts
4
- function toVercelAITools(agentTools) {
6
+ function toVercelAITools(agentTools, options) {
5
7
  return Object.fromEntries(agentTools.map((tool) => [tool.name, {
6
8
  description: tool.description,
7
9
  parameters: tool.parameters,
8
10
  execute: async (args) => {
9
- const result = await tool.execute(args);
11
+ const result = await require_catch_errors.safeExecute(() => tool.execute(args), options?.catchErrors ?? false);
10
12
  return JSON.stringify(result);
11
13
  }
12
14
  }]));
@@ -1 +1 @@
1
- {"version":3,"file":"vercel-ai.cjs","names":["agentTools: readonly AgentTool[]","args: Record<string, unknown>"],"sources":["../../src/adapters/vercel-ai.ts"],"sourcesContent":["import type { AgentTool, JsonSchema } from '../agent-tools.js';\n\nexport type { AgentTool, JsonSchema };\n\nexport interface VercelAIToolDefinition {\n readonly description: string;\n readonly parameters: JsonSchema;\n readonly execute: (args: Record<string, unknown>) => Promise<string>;\n}\n\nexport type VercelAIToolMap = Record<string, VercelAIToolDefinition>;\n\nexport function toVercelAITools(agentTools: readonly AgentTool[]): VercelAIToolMap {\n return Object.fromEntries(\n agentTools.map((tool) => [\n tool.name,\n {\n description: tool.description,\n parameters: tool.parameters,\n execute: async (args: Record<string, unknown>): Promise<string> => {\n const result = await tool.execute(args);\n return JSON.stringify(result);\n },\n },\n ]),\n );\n}\n"],"mappings":";;;AAYA,SAAgB,gBAAgBA,YAAmD;AACjF,QAAO,OAAO,YACZ,WAAW,IAAI,CAAC,SAAS,CACvB,KAAK,MACL;EACE,aAAa,KAAK;EAClB,YAAY,KAAK;EACjB,SAAS,OAAOC,SAAmD;GACjE,MAAM,SAAS,MAAM,KAAK,QAAQ,KAAK;AACvC,UAAO,KAAK,UAAU,OAAO;EAC9B;CACF,CACF,EAAC,CACH;AACF"}
1
+ {"version":3,"file":"vercel-ai.cjs","names":["agentTools: readonly AgentTool[]","options?: AdapterOptions","args: Record<string, unknown>"],"sources":["../../src/adapters/vercel-ai.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 VercelAIToolDefinition {\n readonly description: string;\n readonly parameters: JsonSchema;\n readonly execute: (args: Record<string, unknown>) => Promise<string>;\n}\n\nexport type VercelAIToolMap = Record<string, VercelAIToolDefinition>;\n\nexport function toVercelAITools(\n agentTools: readonly AgentTool[],\n options?: AdapterOptions,\n): VercelAIToolMap {\n return Object.fromEntries(\n agentTools.map((tool) => [\n tool.name,\n {\n description: tool.description,\n parameters: tool.parameters,\n execute: async (args: Record<string, unknown>): Promise<string> => {\n const result = await safeExecute(() => tool.execute(args), options?.catchErrors ?? false);\n return JSON.stringify(result);\n },\n },\n ]),\n );\n}\n"],"mappings":";;;;;AAaA,SAAgB,gBACdA,YACAC,SACiB;AACjB,QAAO,OAAO,YACZ,WAAW,IAAI,CAAC,SAAS,CACvB,KAAK,MACL;EACE,aAAa,KAAK;EAClB,YAAY,KAAK;EACjB,SAAS,OAAOC,SAAmD;GACjE,MAAM,SAAS,MAAM,iCAAY,MAAM,KAAK,QAAQ,KAAK,EAAE,SAAS,eAAe,MAAM;AACzF,UAAO,KAAK,UAAU,OAAO;EAC9B;CACF,CACF,EAAC,CACH;AACF"}