@lov3kaizen/agentsea-core 0.3.1 → 0.5.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/dist/index.d.mts +184 -35
- package/dist/index.d.ts +184 -35
- package/dist/index.js +376 -88
- package/dist/index.mjs +371 -83
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -83,8 +83,17 @@ __export(index_exports, {
|
|
|
83
83
|
VoiceType: () => VoiceType,
|
|
84
84
|
Workflow: () => Workflow,
|
|
85
85
|
WorkflowFactory: () => WorkflowFactory,
|
|
86
|
+
calculatorClient: () => calculatorClient,
|
|
87
|
+
calculatorDef: () => calculatorDef,
|
|
88
|
+
calculatorServer: () => calculatorServer,
|
|
86
89
|
calculatorTool: () => calculatorTool,
|
|
90
|
+
clientTool: () => clientTool,
|
|
87
91
|
createACPTools: () => createACPTools,
|
|
92
|
+
createAnthropicProvider: () => createAnthropicProvider,
|
|
93
|
+
createGeminiProvider: () => createGeminiProvider,
|
|
94
|
+
createOllamaProvider: () => createOllamaProvider,
|
|
95
|
+
createOpenAIProvider: () => createOpenAIProvider,
|
|
96
|
+
createProvider: () => createProvider,
|
|
88
97
|
defaultLogger: () => defaultLogger,
|
|
89
98
|
figmaGetCommentsTool: () => figmaGetCommentsTool,
|
|
90
99
|
figmaGetFileTool: () => figmaGetFileTool,
|
|
@@ -97,14 +106,19 @@ __export(index_exports, {
|
|
|
97
106
|
globalMetrics: () => globalMetrics,
|
|
98
107
|
globalTracer: () => globalTracer,
|
|
99
108
|
httpRequestTool: () => httpRequestTool,
|
|
109
|
+
hybridTool: () => hybridTool,
|
|
100
110
|
mcpToolToAgenticTool: () => mcpToolToAgenticTool,
|
|
101
111
|
n8nExecuteWorkflowTool: () => n8nExecuteWorkflowTool,
|
|
102
112
|
n8nGetExecutionTool: () => n8nGetExecutionTool,
|
|
103
113
|
n8nGetWorkflowTool: () => n8nGetWorkflowTool,
|
|
104
114
|
n8nListWorkflowsTool: () => n8nListWorkflowsTool,
|
|
105
115
|
n8nTriggerWebhookTool: () => n8nTriggerWebhookTool,
|
|
116
|
+
serverTool: () => serverTool,
|
|
106
117
|
stringTransformTool: () => stringTransformTool,
|
|
107
|
-
textSummaryTool: () => textSummaryTool
|
|
118
|
+
textSummaryTool: () => textSummaryTool,
|
|
119
|
+
toLegacyTool: () => toLegacyTool,
|
|
120
|
+
toLegacyTools: () => toLegacyTools,
|
|
121
|
+
toolDefinition: () => toolDefinition
|
|
108
122
|
});
|
|
109
123
|
|
|
110
124
|
// src/types/index.ts
|
|
@@ -366,6 +380,7 @@ var Agent = class {
|
|
|
366
380
|
// Will be set by execute()
|
|
367
381
|
iterations: this.iterationCount
|
|
368
382
|
},
|
|
383
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
369
384
|
finishReason: llmResponse.stopReason
|
|
370
385
|
};
|
|
371
386
|
if (this.config.outputFormat && this.config.outputFormat !== "text") {
|
|
@@ -762,7 +777,7 @@ var httpRequestTool = {
|
|
|
762
777
|
url: z2.string().url().describe("The URL to make the request to"),
|
|
763
778
|
method: z2.enum(["GET", "POST", "PUT", "DELETE", "PATCH"]).default("GET").describe("HTTP method"),
|
|
764
779
|
headers: z2.record(z2.string()).optional().describe("HTTP headers"),
|
|
765
|
-
body: z2.
|
|
780
|
+
body: z2.unknown().optional().describe("Request body (for POST, PUT, PATCH)"),
|
|
766
781
|
timeout: z2.number().optional().default(1e4).describe("Request timeout in milliseconds")
|
|
767
782
|
}),
|
|
768
783
|
execute: async (params) => {
|
|
@@ -1220,7 +1235,7 @@ var n8nExecuteWorkflowTool = {
|
|
|
1220
1235
|
description: "Execute an n8n workflow by ID or name. Optionally pass input data to the workflow.",
|
|
1221
1236
|
parameters: z6.object({
|
|
1222
1237
|
workflowId: z6.string().describe("The ID of the workflow to execute"),
|
|
1223
|
-
data: z6.
|
|
1238
|
+
data: z6.unknown().optional().describe("Input data to pass to the workflow execution"),
|
|
1224
1239
|
waitForCompletion: z6.boolean().default(true).describe("Wait for workflow execution to complete before returning"),
|
|
1225
1240
|
apiKey: z6.string().optional().describe("n8n API key (or use N8N_API_KEY env var)"),
|
|
1226
1241
|
baseUrl: z6.string().optional().describe("n8n base URL (or use N8N_BASE_URL env var)")
|
|
@@ -1337,7 +1352,7 @@ var n8nTriggerWebhookTool = {
|
|
|
1337
1352
|
parameters: z6.object({
|
|
1338
1353
|
webhookPath: z6.string().describe('The webhook path (e.g., "webhook/my-workflow")'),
|
|
1339
1354
|
method: z6.enum(["GET", "POST", "PUT", "DELETE", "PATCH"]).default("POST").describe("HTTP method for the webhook"),
|
|
1340
|
-
data: z6.
|
|
1355
|
+
data: z6.unknown().optional().describe("Data to send to the webhook"),
|
|
1341
1356
|
headers: z6.record(z6.string()).optional().describe("Additional headers to include"),
|
|
1342
1357
|
baseUrl: z6.string().optional().describe("n8n base URL (or use N8N_BASE_URL env var)")
|
|
1343
1358
|
}),
|
|
@@ -1428,6 +1443,162 @@ async function pollExecutionStatus(executionId, apiKey, baseUrl, maxAttempts = 3
|
|
|
1428
1443
|
);
|
|
1429
1444
|
}
|
|
1430
1445
|
|
|
1446
|
+
// src/tools/built-in/calculator.isomorphic.ts
|
|
1447
|
+
import { z as z8 } from "zod";
|
|
1448
|
+
|
|
1449
|
+
// src/tools/tool-definition.ts
|
|
1450
|
+
import { z as z7 } from "zod";
|
|
1451
|
+
function toolDefinition(options) {
|
|
1452
|
+
const {
|
|
1453
|
+
name,
|
|
1454
|
+
description,
|
|
1455
|
+
inputSchema,
|
|
1456
|
+
outputSchema = z7.unknown(),
|
|
1457
|
+
needsApproval = false,
|
|
1458
|
+
retryConfig
|
|
1459
|
+
} = options;
|
|
1460
|
+
const createServerTool = (execute) => {
|
|
1461
|
+
const wrappedExecute = async (input, context) => {
|
|
1462
|
+
const validatedInput = inputSchema.parse(input);
|
|
1463
|
+
const result = await execute(validatedInput, context);
|
|
1464
|
+
if (outputSchema) {
|
|
1465
|
+
return outputSchema.parse(result);
|
|
1466
|
+
}
|
|
1467
|
+
return result;
|
|
1468
|
+
};
|
|
1469
|
+
return {
|
|
1470
|
+
name,
|
|
1471
|
+
description,
|
|
1472
|
+
inputSchema,
|
|
1473
|
+
outputSchema,
|
|
1474
|
+
needsApproval,
|
|
1475
|
+
retryConfig,
|
|
1476
|
+
environment: "server",
|
|
1477
|
+
execute: wrappedExecute,
|
|
1478
|
+
toTool() {
|
|
1479
|
+
return {
|
|
1480
|
+
name,
|
|
1481
|
+
description,
|
|
1482
|
+
parameters: inputSchema,
|
|
1483
|
+
execute: wrappedExecute,
|
|
1484
|
+
retryConfig
|
|
1485
|
+
};
|
|
1486
|
+
}
|
|
1487
|
+
};
|
|
1488
|
+
};
|
|
1489
|
+
const createClientTool = (execute) => {
|
|
1490
|
+
const wrappedExecute = async (input, context) => {
|
|
1491
|
+
const validatedInput = inputSchema.parse(input);
|
|
1492
|
+
const result = await execute(validatedInput, context);
|
|
1493
|
+
if (outputSchema) {
|
|
1494
|
+
return outputSchema.parse(result);
|
|
1495
|
+
}
|
|
1496
|
+
return result;
|
|
1497
|
+
};
|
|
1498
|
+
return {
|
|
1499
|
+
name,
|
|
1500
|
+
description,
|
|
1501
|
+
inputSchema,
|
|
1502
|
+
outputSchema,
|
|
1503
|
+
needsApproval,
|
|
1504
|
+
retryConfig,
|
|
1505
|
+
environment: "client",
|
|
1506
|
+
execute: wrappedExecute,
|
|
1507
|
+
toTool() {
|
|
1508
|
+
return {
|
|
1509
|
+
name,
|
|
1510
|
+
description,
|
|
1511
|
+
parameters: inputSchema,
|
|
1512
|
+
execute: wrappedExecute,
|
|
1513
|
+
retryConfig
|
|
1514
|
+
};
|
|
1515
|
+
}
|
|
1516
|
+
};
|
|
1517
|
+
};
|
|
1518
|
+
return {
|
|
1519
|
+
name,
|
|
1520
|
+
description,
|
|
1521
|
+
inputSchema,
|
|
1522
|
+
outputSchema,
|
|
1523
|
+
needsApproval,
|
|
1524
|
+
retryConfig,
|
|
1525
|
+
server: createServerTool,
|
|
1526
|
+
client: createClientTool,
|
|
1527
|
+
toTool(execute) {
|
|
1528
|
+
return createServerTool(execute).toTool();
|
|
1529
|
+
}
|
|
1530
|
+
};
|
|
1531
|
+
}
|
|
1532
|
+
function hybridTool(options) {
|
|
1533
|
+
const def = toolDefinition(options);
|
|
1534
|
+
const serverTool2 = def.server(options.server);
|
|
1535
|
+
const clientTool2 = def.client(options.client);
|
|
1536
|
+
return {
|
|
1537
|
+
name: def.name,
|
|
1538
|
+
description: def.description,
|
|
1539
|
+
inputSchema: def.inputSchema,
|
|
1540
|
+
outputSchema: def.outputSchema,
|
|
1541
|
+
needsApproval: def.needsApproval,
|
|
1542
|
+
retryConfig: def.retryConfig,
|
|
1543
|
+
server: serverTool2,
|
|
1544
|
+
client: clientTool2,
|
|
1545
|
+
toTool() {
|
|
1546
|
+
return serverTool2.toTool();
|
|
1547
|
+
}
|
|
1548
|
+
};
|
|
1549
|
+
}
|
|
1550
|
+
function serverTool(options) {
|
|
1551
|
+
return toolDefinition(options).server(options.execute);
|
|
1552
|
+
}
|
|
1553
|
+
function clientTool(options) {
|
|
1554
|
+
return toolDefinition(options).client(options.execute);
|
|
1555
|
+
}
|
|
1556
|
+
function toLegacyTool(tool) {
|
|
1557
|
+
return tool.toTool();
|
|
1558
|
+
}
|
|
1559
|
+
function toLegacyTools(tools) {
|
|
1560
|
+
return tools.map(toLegacyTool);
|
|
1561
|
+
}
|
|
1562
|
+
|
|
1563
|
+
// src/tools/built-in/calculator.isomorphic.ts
|
|
1564
|
+
var calculatorInputSchema = z8.object({
|
|
1565
|
+
operation: z8.enum(["add", "subtract", "multiply", "divide"]).describe("The arithmetic operation to perform"),
|
|
1566
|
+
a: z8.number().describe("First number"),
|
|
1567
|
+
b: z8.number().describe("Second number")
|
|
1568
|
+
});
|
|
1569
|
+
var calculatorOutputSchema = z8.object({
|
|
1570
|
+
result: z8.number().describe("The result of the calculation")
|
|
1571
|
+
});
|
|
1572
|
+
var calculatorDef = toolDefinition({
|
|
1573
|
+
name: "calculator",
|
|
1574
|
+
description: "Perform basic arithmetic operations (add, subtract, multiply, divide)",
|
|
1575
|
+
inputSchema: calculatorInputSchema,
|
|
1576
|
+
outputSchema: calculatorOutputSchema
|
|
1577
|
+
});
|
|
1578
|
+
function calculate(operation, a, b) {
|
|
1579
|
+
switch (operation) {
|
|
1580
|
+
case "add":
|
|
1581
|
+
return { result: a + b };
|
|
1582
|
+
case "subtract":
|
|
1583
|
+
return { result: a - b };
|
|
1584
|
+
case "multiply":
|
|
1585
|
+
return { result: a * b };
|
|
1586
|
+
case "divide":
|
|
1587
|
+
if (b === 0) {
|
|
1588
|
+
throw new Error("Cannot divide by zero");
|
|
1589
|
+
}
|
|
1590
|
+
return { result: a / b };
|
|
1591
|
+
default:
|
|
1592
|
+
throw new Error(`Unknown operation: ${operation}`);
|
|
1593
|
+
}
|
|
1594
|
+
}
|
|
1595
|
+
var calculatorServer = calculatorDef.server(({ operation, a, b }) => {
|
|
1596
|
+
return Promise.resolve(calculate(operation, a, b));
|
|
1597
|
+
});
|
|
1598
|
+
var calculatorClient = calculatorDef.client(({ operation, a, b }) => {
|
|
1599
|
+
return calculate(operation, a, b);
|
|
1600
|
+
});
|
|
1601
|
+
|
|
1431
1602
|
// src/providers/anthropic.ts
|
|
1432
1603
|
import Anthropic from "@anthropic-ai/sdk";
|
|
1433
1604
|
import { zodToJsonSchema } from "zod-to-json-schema";
|
|
@@ -1454,6 +1625,7 @@ var AnthropicProvider = class {
|
|
|
1454
1625
|
temperature: config.temperature,
|
|
1455
1626
|
system: config.systemPrompt,
|
|
1456
1627
|
messages: anthropicMessages,
|
|
1628
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1457
1629
|
tools,
|
|
1458
1630
|
top_p: config.topP,
|
|
1459
1631
|
stop_sequences: config.stopSequences
|
|
@@ -1485,6 +1657,7 @@ var AnthropicProvider = class {
|
|
|
1485
1657
|
temperature: config.temperature,
|
|
1486
1658
|
system: config.systemPrompt,
|
|
1487
1659
|
messages: anthropicMessages,
|
|
1660
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1488
1661
|
tools,
|
|
1489
1662
|
top_p: config.topP,
|
|
1490
1663
|
stop_sequences: config.stopSequences
|
|
@@ -1548,6 +1721,7 @@ var AnthropicProvider = class {
|
|
|
1548
1721
|
type: "tool_result",
|
|
1549
1722
|
tool_use_id: message.toolCallId || "",
|
|
1550
1723
|
content: message.content
|
|
1724
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1551
1725
|
});
|
|
1552
1726
|
}
|
|
1553
1727
|
}
|
|
@@ -1807,8 +1981,9 @@ var GeminiProvider = class {
|
|
|
1807
1981
|
*/
|
|
1808
1982
|
parseToolCalls(response) {
|
|
1809
1983
|
const toolCalls = [];
|
|
1810
|
-
|
|
1811
|
-
|
|
1984
|
+
const rawResponse = response.rawResponse;
|
|
1985
|
+
if (rawResponse?.functionCalls) {
|
|
1986
|
+
for (const call of rawResponse.functionCalls()) {
|
|
1812
1987
|
toolCalls.push({
|
|
1813
1988
|
id: `call-${Date.now()}-${Math.random()}`,
|
|
1814
1989
|
tool: call.name,
|
|
@@ -1998,7 +2173,7 @@ var OllamaProvider = class {
|
|
|
1998
2173
|
parseToolCalls(response) {
|
|
1999
2174
|
const rawResponse = response.rawResponse;
|
|
2000
2175
|
const toolCalls = [];
|
|
2001
|
-
if (rawResponse
|
|
2176
|
+
if (rawResponse?.message?.tool_calls) {
|
|
2002
2177
|
for (const toolCall of rawResponse.message.tool_calls) {
|
|
2003
2178
|
toolCalls.push({
|
|
2004
2179
|
id: toolCall.id || Math.random().toString(36),
|
|
@@ -2012,6 +2187,7 @@ var OllamaProvider = class {
|
|
|
2012
2187
|
/**
|
|
2013
2188
|
* Convert generic messages to Ollama format
|
|
2014
2189
|
*/
|
|
2190
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2015
2191
|
convertMessages(messages, systemPrompt) {
|
|
2016
2192
|
const converted = [];
|
|
2017
2193
|
if (systemPrompt) {
|
|
@@ -2046,6 +2222,7 @@ var OllamaProvider = class {
|
|
|
2046
2222
|
/**
|
|
2047
2223
|
* Make a request to Ollama API
|
|
2048
2224
|
*/
|
|
2225
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2049
2226
|
async makeRequest(endpoint, payload) {
|
|
2050
2227
|
const controller = new AbortController();
|
|
2051
2228
|
const timeoutId = setTimeout(() => controller.abort(), this.timeout);
|
|
@@ -2335,6 +2512,91 @@ var VLLMProvider = class extends OpenAICompatibleProvider {
|
|
|
2335
2512
|
}
|
|
2336
2513
|
};
|
|
2337
2514
|
|
|
2515
|
+
// src/providers/type-safe-provider.ts
|
|
2516
|
+
function createProvider(config) {
|
|
2517
|
+
let provider;
|
|
2518
|
+
switch (config.provider) {
|
|
2519
|
+
case "anthropic":
|
|
2520
|
+
provider = new AnthropicProvider();
|
|
2521
|
+
break;
|
|
2522
|
+
case "openai":
|
|
2523
|
+
provider = new OpenAIProvider();
|
|
2524
|
+
break;
|
|
2525
|
+
case "gemini":
|
|
2526
|
+
provider = new GeminiProvider();
|
|
2527
|
+
break;
|
|
2528
|
+
case "ollama":
|
|
2529
|
+
provider = new OllamaProvider();
|
|
2530
|
+
break;
|
|
2531
|
+
default: {
|
|
2532
|
+
const exhaustiveCheck = config;
|
|
2533
|
+
throw new Error(`Unknown provider: ${exhaustiveCheck.provider}`);
|
|
2534
|
+
}
|
|
2535
|
+
}
|
|
2536
|
+
return {
|
|
2537
|
+
config,
|
|
2538
|
+
provider,
|
|
2539
|
+
getModelInfo() {
|
|
2540
|
+
return (0, types_exports.getModelInfo)(config.model);
|
|
2541
|
+
},
|
|
2542
|
+
supportsCapability(capability) {
|
|
2543
|
+
return (0, types_exports.modelSupportsCapability)(config.model, capability);
|
|
2544
|
+
}
|
|
2545
|
+
};
|
|
2546
|
+
}
|
|
2547
|
+
function createAnthropicProvider(config, options) {
|
|
2548
|
+
const provider = new AnthropicProvider(options?.apiKey);
|
|
2549
|
+
return {
|
|
2550
|
+
config,
|
|
2551
|
+
provider,
|
|
2552
|
+
getModelInfo() {
|
|
2553
|
+
return (0, types_exports.getModelInfo)(config.model);
|
|
2554
|
+
},
|
|
2555
|
+
supportsCapability(capability) {
|
|
2556
|
+
return (0, types_exports.modelSupportsCapability)(config.model, capability);
|
|
2557
|
+
}
|
|
2558
|
+
};
|
|
2559
|
+
}
|
|
2560
|
+
function createOpenAIProvider(config, options) {
|
|
2561
|
+
const provider = new OpenAIProvider(options?.apiKey);
|
|
2562
|
+
return {
|
|
2563
|
+
config,
|
|
2564
|
+
provider,
|
|
2565
|
+
getModelInfo() {
|
|
2566
|
+
return (0, types_exports.getModelInfo)(config.model);
|
|
2567
|
+
},
|
|
2568
|
+
supportsCapability(capability) {
|
|
2569
|
+
return (0, types_exports.modelSupportsCapability)(config.model, capability);
|
|
2570
|
+
}
|
|
2571
|
+
};
|
|
2572
|
+
}
|
|
2573
|
+
function createGeminiProvider(config, options) {
|
|
2574
|
+
const provider = new GeminiProvider(options?.apiKey);
|
|
2575
|
+
return {
|
|
2576
|
+
config,
|
|
2577
|
+
provider,
|
|
2578
|
+
getModelInfo() {
|
|
2579
|
+
return (0, types_exports.getModelInfo)(config.model);
|
|
2580
|
+
},
|
|
2581
|
+
supportsCapability(capability) {
|
|
2582
|
+
return (0, types_exports.modelSupportsCapability)(config.model, capability);
|
|
2583
|
+
}
|
|
2584
|
+
};
|
|
2585
|
+
}
|
|
2586
|
+
function createOllamaProvider(config, options) {
|
|
2587
|
+
const provider = new OllamaProvider(options);
|
|
2588
|
+
return {
|
|
2589
|
+
config,
|
|
2590
|
+
provider,
|
|
2591
|
+
getModelInfo() {
|
|
2592
|
+
return (0, types_exports.getModelInfo)(config.model);
|
|
2593
|
+
},
|
|
2594
|
+
supportsCapability(capability) {
|
|
2595
|
+
return (0, types_exports.modelSupportsCapability)(config.model, capability);
|
|
2596
|
+
}
|
|
2597
|
+
};
|
|
2598
|
+
}
|
|
2599
|
+
|
|
2338
2600
|
// src/memory/buffer-memory.ts
|
|
2339
2601
|
var BufferMemory = class {
|
|
2340
2602
|
constructor(maxMessages) {
|
|
@@ -3826,7 +4088,7 @@ var MCPClient = class extends EventEmitter2 {
|
|
|
3826
4088
|
};
|
|
3827
4089
|
|
|
3828
4090
|
// src/mcp/tool-adapter.ts
|
|
3829
|
-
import { z as
|
|
4091
|
+
import { z as z9 } from "zod";
|
|
3830
4092
|
function mcpToolToAgenticTool(mcpTool, client) {
|
|
3831
4093
|
const zodSchema = jsonSchemaToZod(mcpTool.inputSchema);
|
|
3832
4094
|
return {
|
|
@@ -3834,7 +4096,10 @@ function mcpToolToAgenticTool(mcpTool, client) {
|
|
|
3834
4096
|
description: mcpTool.description,
|
|
3835
4097
|
parameters: zodSchema,
|
|
3836
4098
|
execute: async (params, _context) => {
|
|
3837
|
-
const response = await client.callTool(
|
|
4099
|
+
const response = await client.callTool(
|
|
4100
|
+
mcpTool.name,
|
|
4101
|
+
params
|
|
4102
|
+
);
|
|
3838
4103
|
if (response.isError) {
|
|
3839
4104
|
throw new Error(
|
|
3840
4105
|
`MCP tool error: ${response.content[0]?.text || "Unknown error"}`
|
|
@@ -3858,26 +4123,30 @@ function jsonSchemaToZod(schema) {
|
|
|
3858
4123
|
let zodType;
|
|
3859
4124
|
switch (propSchema.type) {
|
|
3860
4125
|
case "string":
|
|
3861
|
-
zodType =
|
|
3862
|
-
if (propSchema.description) {
|
|
4126
|
+
zodType = z9.string();
|
|
4127
|
+
if (typeof propSchema.description === "string") {
|
|
3863
4128
|
zodType = zodType.describe(propSchema.description);
|
|
3864
4129
|
}
|
|
3865
4130
|
break;
|
|
3866
4131
|
case "number":
|
|
3867
|
-
zodType =
|
|
3868
|
-
if (propSchema.description) {
|
|
4132
|
+
zodType = z9.number();
|
|
4133
|
+
if (typeof propSchema.description === "string") {
|
|
3869
4134
|
zodType = zodType.describe(propSchema.description);
|
|
3870
4135
|
}
|
|
3871
4136
|
break;
|
|
3872
4137
|
case "boolean":
|
|
3873
|
-
zodType =
|
|
3874
|
-
if (propSchema.description) {
|
|
4138
|
+
zodType = z9.boolean();
|
|
4139
|
+
if (typeof propSchema.description === "string") {
|
|
3875
4140
|
zodType = zodType.describe(propSchema.description);
|
|
3876
4141
|
}
|
|
3877
4142
|
break;
|
|
3878
4143
|
case "array":
|
|
3879
|
-
zodType =
|
|
3880
|
-
|
|
4144
|
+
zodType = z9.array(
|
|
4145
|
+
jsonSchemaToZod(
|
|
4146
|
+
propSchema.items || {}
|
|
4147
|
+
)
|
|
4148
|
+
);
|
|
4149
|
+
if (typeof propSchema.description === "string") {
|
|
3881
4150
|
zodType = zodType.describe(propSchema.description);
|
|
3882
4151
|
}
|
|
3883
4152
|
break;
|
|
@@ -3885,16 +4154,17 @@ function jsonSchemaToZod(schema) {
|
|
|
3885
4154
|
zodType = jsonSchemaToZod(propSchema);
|
|
3886
4155
|
break;
|
|
3887
4156
|
default:
|
|
3888
|
-
zodType =
|
|
4157
|
+
zodType = z9.any();
|
|
3889
4158
|
}
|
|
3890
|
-
|
|
4159
|
+
const required = schema.required;
|
|
4160
|
+
if (!required?.includes(key)) {
|
|
3891
4161
|
zodType = zodType.optional();
|
|
3892
4162
|
}
|
|
3893
4163
|
shape[key] = zodType;
|
|
3894
4164
|
}
|
|
3895
|
-
return
|
|
4165
|
+
return z9.object(shape);
|
|
3896
4166
|
}
|
|
3897
|
-
return
|
|
4167
|
+
return z9.any();
|
|
3898
4168
|
}
|
|
3899
4169
|
|
|
3900
4170
|
// src/mcp/registry.ts
|
|
@@ -4291,7 +4561,7 @@ var ACPClient = class {
|
|
|
4291
4561
|
};
|
|
4292
4562
|
|
|
4293
4563
|
// src/acp/tools.ts
|
|
4294
|
-
import { z as
|
|
4564
|
+
import { z as z10 } from "zod";
|
|
4295
4565
|
function createACPTools(client) {
|
|
4296
4566
|
return [
|
|
4297
4567
|
createSearchProductsTool(client),
|
|
@@ -4314,15 +4584,15 @@ function createSearchProductsTool(client) {
|
|
|
4314
4584
|
return {
|
|
4315
4585
|
name: "acp_search_products",
|
|
4316
4586
|
description: "Search for products in the commerce catalog. Supports filtering by query text, category, price range, and sorting.",
|
|
4317
|
-
parameters:
|
|
4318
|
-
query:
|
|
4319
|
-
category:
|
|
4320
|
-
minPrice:
|
|
4321
|
-
maxPrice:
|
|
4322
|
-
limit:
|
|
4323
|
-
offset:
|
|
4324
|
-
sortBy:
|
|
4325
|
-
sortOrder:
|
|
4587
|
+
parameters: z10.object({
|
|
4588
|
+
query: z10.string().optional().describe("Search query text"),
|
|
4589
|
+
category: z10.string().optional().describe("Product category filter"),
|
|
4590
|
+
minPrice: z10.number().optional().describe("Minimum price filter"),
|
|
4591
|
+
maxPrice: z10.number().optional().describe("Maximum price filter"),
|
|
4592
|
+
limit: z10.number().optional().default(10).describe("Maximum number of results"),
|
|
4593
|
+
offset: z10.number().optional().default(0).describe("Pagination offset"),
|
|
4594
|
+
sortBy: z10.enum(["price", "name", "popularity", "newest"]).optional().describe("Sort field"),
|
|
4595
|
+
sortOrder: z10.enum(["asc", "desc"]).optional().default("asc").describe("Sort order")
|
|
4326
4596
|
}),
|
|
4327
4597
|
execute: async (params) => {
|
|
4328
4598
|
const response = await client.searchProducts(params);
|
|
@@ -4341,8 +4611,8 @@ function createGetProductTool(client) {
|
|
|
4341
4611
|
return {
|
|
4342
4612
|
name: "acp_get_product",
|
|
4343
4613
|
description: "Get detailed information about a specific product by its ID.",
|
|
4344
|
-
parameters:
|
|
4345
|
-
productId:
|
|
4614
|
+
parameters: z10.object({
|
|
4615
|
+
productId: z10.string().describe("Product ID")
|
|
4346
4616
|
}),
|
|
4347
4617
|
execute: async (params) => {
|
|
4348
4618
|
const response = await client.getProduct(params.productId);
|
|
@@ -4357,7 +4627,7 @@ function createCreateCartTool(client) {
|
|
|
4357
4627
|
return {
|
|
4358
4628
|
name: "acp_create_cart",
|
|
4359
4629
|
description: "Create a new shopping cart for the customer. Returns the cart ID for subsequent operations.",
|
|
4360
|
-
parameters:
|
|
4630
|
+
parameters: z10.object({}),
|
|
4361
4631
|
execute: async () => {
|
|
4362
4632
|
const response = await client.createCart();
|
|
4363
4633
|
if (response.error) {
|
|
@@ -4371,14 +4641,14 @@ function createAddToCartTool(client) {
|
|
|
4371
4641
|
return {
|
|
4372
4642
|
name: "acp_add_to_cart",
|
|
4373
4643
|
description: "Add a product to the shopping cart with specified quantity.",
|
|
4374
|
-
parameters:
|
|
4375
|
-
cartId:
|
|
4376
|
-
productId:
|
|
4377
|
-
variantId:
|
|
4378
|
-
quantity:
|
|
4379
|
-
price:
|
|
4380
|
-
amount:
|
|
4381
|
-
currency:
|
|
4644
|
+
parameters: z10.object({
|
|
4645
|
+
cartId: z10.string().describe("Cart ID"),
|
|
4646
|
+
productId: z10.string().describe("Product ID to add"),
|
|
4647
|
+
variantId: z10.string().optional().describe("Product variant ID"),
|
|
4648
|
+
quantity: z10.number().min(1).describe("Quantity to add"),
|
|
4649
|
+
price: z10.object({
|
|
4650
|
+
amount: z10.number().describe("Price amount"),
|
|
4651
|
+
currency: z10.string().describe("Currency code (e.g., USD, EUR)")
|
|
4382
4652
|
}).describe("Product price")
|
|
4383
4653
|
}),
|
|
4384
4654
|
execute: async (params) => {
|
|
@@ -4401,10 +4671,10 @@ function createUpdateCartItemTool(client) {
|
|
|
4401
4671
|
return {
|
|
4402
4672
|
name: "acp_update_cart_item",
|
|
4403
4673
|
description: "Update the quantity of an item in the shopping cart.",
|
|
4404
|
-
parameters:
|
|
4405
|
-
cartId:
|
|
4406
|
-
productId:
|
|
4407
|
-
quantity:
|
|
4674
|
+
parameters: z10.object({
|
|
4675
|
+
cartId: z10.string().describe("Cart ID"),
|
|
4676
|
+
productId: z10.string().describe("Product ID to update"),
|
|
4677
|
+
quantity: z10.number().min(0).describe("New quantity (0 to remove)")
|
|
4408
4678
|
}),
|
|
4409
4679
|
execute: async (params) => {
|
|
4410
4680
|
const response = await client.updateCartItem(
|
|
@@ -4425,9 +4695,9 @@ function createRemoveFromCartTool(client) {
|
|
|
4425
4695
|
return {
|
|
4426
4696
|
name: "acp_remove_from_cart",
|
|
4427
4697
|
description: "Remove a product from the shopping cart.",
|
|
4428
|
-
parameters:
|
|
4429
|
-
cartId:
|
|
4430
|
-
productId:
|
|
4698
|
+
parameters: z10.object({
|
|
4699
|
+
cartId: z10.string().describe("Cart ID"),
|
|
4700
|
+
productId: z10.string().describe("Product ID to remove")
|
|
4431
4701
|
}),
|
|
4432
4702
|
execute: async (params) => {
|
|
4433
4703
|
const response = await client.removeFromCart(
|
|
@@ -4447,8 +4717,8 @@ function createGetCartTool(client) {
|
|
|
4447
4717
|
return {
|
|
4448
4718
|
name: "acp_get_cart",
|
|
4449
4719
|
description: "Get the current state of a shopping cart including all items and total amount.",
|
|
4450
|
-
parameters:
|
|
4451
|
-
cartId:
|
|
4720
|
+
parameters: z10.object({
|
|
4721
|
+
cartId: z10.string().describe("Cart ID")
|
|
4452
4722
|
}),
|
|
4453
4723
|
execute: async (params) => {
|
|
4454
4724
|
const response = await client.getCart(params.cartId);
|
|
@@ -4463,12 +4733,12 @@ function createCheckoutTool(client) {
|
|
|
4463
4733
|
return {
|
|
4464
4734
|
name: "acp_create_checkout",
|
|
4465
4735
|
description: "Create a checkout session from a shopping cart to begin the purchase process.",
|
|
4466
|
-
parameters:
|
|
4467
|
-
cartId:
|
|
4468
|
-
customer:
|
|
4469
|
-
email:
|
|
4470
|
-
name:
|
|
4471
|
-
phone:
|
|
4736
|
+
parameters: z10.object({
|
|
4737
|
+
cartId: z10.string().describe("Cart ID"),
|
|
4738
|
+
customer: z10.object({
|
|
4739
|
+
email: z10.string().email().describe("Customer email"),
|
|
4740
|
+
name: z10.string().optional().describe("Customer name"),
|
|
4741
|
+
phone: z10.string().optional().describe("Customer phone number")
|
|
4472
4742
|
}).optional().describe("Customer information")
|
|
4473
4743
|
}),
|
|
4474
4744
|
execute: async (params) => {
|
|
@@ -4489,15 +4759,15 @@ function createUpdateShippingAddressTool(client) {
|
|
|
4489
4759
|
return {
|
|
4490
4760
|
name: "acp_update_shipping_address",
|
|
4491
4761
|
description: "Update the shipping address for a checkout session.",
|
|
4492
|
-
parameters:
|
|
4493
|
-
sessionId:
|
|
4494
|
-
address:
|
|
4495
|
-
line1:
|
|
4496
|
-
line2:
|
|
4497
|
-
city:
|
|
4498
|
-
state:
|
|
4499
|
-
postalCode:
|
|
4500
|
-
country:
|
|
4762
|
+
parameters: z10.object({
|
|
4763
|
+
sessionId: z10.string().describe("Checkout session ID"),
|
|
4764
|
+
address: z10.object({
|
|
4765
|
+
line1: z10.string().describe("Address line 1"),
|
|
4766
|
+
line2: z10.string().optional().describe("Address line 2"),
|
|
4767
|
+
city: z10.string().describe("City"),
|
|
4768
|
+
state: z10.string().optional().describe("State/Province"),
|
|
4769
|
+
postalCode: z10.string().describe("Postal/ZIP code"),
|
|
4770
|
+
country: z10.string().describe("Country code (e.g., US, GB)")
|
|
4501
4771
|
}).describe("Shipping address")
|
|
4502
4772
|
}),
|
|
4503
4773
|
execute: async (params) => {
|
|
@@ -4518,12 +4788,12 @@ function createUpdatePaymentMethodTool(client) {
|
|
|
4518
4788
|
return {
|
|
4519
4789
|
name: "acp_update_payment_method",
|
|
4520
4790
|
description: "Update the payment method for a checkout session.",
|
|
4521
|
-
parameters:
|
|
4522
|
-
sessionId:
|
|
4523
|
-
paymentMethod:
|
|
4524
|
-
type:
|
|
4525
|
-
token:
|
|
4526
|
-
delegatedProvider:
|
|
4791
|
+
parameters: z10.object({
|
|
4792
|
+
sessionId: z10.string().describe("Checkout session ID"),
|
|
4793
|
+
paymentMethod: z10.object({
|
|
4794
|
+
type: z10.enum(["card", "delegated", "wallet", "bank_transfer"]).describe("Payment method type"),
|
|
4795
|
+
token: z10.string().optional().describe("Payment token"),
|
|
4796
|
+
delegatedProvider: z10.string().optional().describe("Delegated payment provider (e.g., stripe, paypal)")
|
|
4527
4797
|
}).describe("Payment method details")
|
|
4528
4798
|
}),
|
|
4529
4799
|
execute: async (params) => {
|
|
@@ -4544,8 +4814,8 @@ function createCompleteCheckoutTool(client) {
|
|
|
4544
4814
|
return {
|
|
4545
4815
|
name: "acp_complete_checkout",
|
|
4546
4816
|
description: "Complete the checkout process and create an order. This finalizes the purchase.",
|
|
4547
|
-
parameters:
|
|
4548
|
-
sessionId:
|
|
4817
|
+
parameters: z10.object({
|
|
4818
|
+
sessionId: z10.string().describe("Checkout session ID")
|
|
4549
4819
|
}),
|
|
4550
4820
|
execute: async (params) => {
|
|
4551
4821
|
const response = await client.completeCheckout(params.sessionId);
|
|
@@ -4562,8 +4832,8 @@ function createGetOrderTool(client) {
|
|
|
4562
4832
|
return {
|
|
4563
4833
|
name: "acp_get_order",
|
|
4564
4834
|
description: "Get detailed information about an order by its ID.",
|
|
4565
|
-
parameters:
|
|
4566
|
-
orderId:
|
|
4835
|
+
parameters: z10.object({
|
|
4836
|
+
orderId: z10.string().describe("Order ID")
|
|
4567
4837
|
}),
|
|
4568
4838
|
execute: async (params) => {
|
|
4569
4839
|
const response = await client.getOrder(params.orderId);
|
|
@@ -4578,8 +4848,8 @@ function createCancelOrderTool(client) {
|
|
|
4578
4848
|
return {
|
|
4579
4849
|
name: "acp_cancel_order",
|
|
4580
4850
|
description: "Cancel an order. Only orders that have not been shipped can be cancelled.",
|
|
4581
|
-
parameters:
|
|
4582
|
-
orderId:
|
|
4851
|
+
parameters: z10.object({
|
|
4852
|
+
orderId: z10.string().describe("Order ID")
|
|
4583
4853
|
}),
|
|
4584
4854
|
execute: async (params) => {
|
|
4585
4855
|
const response = await client.cancelOrder(params.orderId);
|
|
@@ -4594,8 +4864,8 @@ function createGetOrderTrackingTool(client) {
|
|
|
4594
4864
|
return {
|
|
4595
4865
|
name: "acp_get_order_tracking",
|
|
4596
4866
|
description: "Get shipping tracking information for an order.",
|
|
4597
|
-
parameters:
|
|
4598
|
-
orderId:
|
|
4867
|
+
parameters: z10.object({
|
|
4868
|
+
orderId: z10.string().describe("Order ID")
|
|
4599
4869
|
}),
|
|
4600
4870
|
execute: async (params) => {
|
|
4601
4871
|
const response = await client.getOrderTracking(params.orderId);
|
|
@@ -5170,12 +5440,14 @@ var OpenAIWhisperProvider = class {
|
|
|
5170
5440
|
text: verboseResponse.text,
|
|
5171
5441
|
language: verboseResponse.language,
|
|
5172
5442
|
duration: verboseResponse.duration,
|
|
5443
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
5173
5444
|
segments: verboseResponse.segments?.map((seg) => ({
|
|
5174
5445
|
id: seg.id,
|
|
5175
5446
|
start: seg.start,
|
|
5176
5447
|
end: seg.end,
|
|
5177
5448
|
text: seg.text
|
|
5178
5449
|
})),
|
|
5450
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
5179
5451
|
words: verboseResponse.words?.map((word) => ({
|
|
5180
5452
|
word: word.word,
|
|
5181
5453
|
start: word.start,
|
|
@@ -5449,6 +5721,7 @@ var OpenAITTSProvider = class {
|
|
|
5449
5721
|
try {
|
|
5450
5722
|
const response = await this.client.audio.speech.create({
|
|
5451
5723
|
model: config?.model || "tts-1",
|
|
5724
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
5452
5725
|
voice: config?.voice || "alloy",
|
|
5453
5726
|
input: text,
|
|
5454
5727
|
speed: config?.speed || 1,
|
|
@@ -5473,6 +5746,7 @@ var OpenAITTSProvider = class {
|
|
|
5473
5746
|
try {
|
|
5474
5747
|
const response = await this.client.audio.speech.create({
|
|
5475
5748
|
model: config?.model || "tts-1",
|
|
5749
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
5476
5750
|
voice: config?.voice || "alloy",
|
|
5477
5751
|
input: text,
|
|
5478
5752
|
speed: config?.speed || 1,
|
|
@@ -5916,13 +6190,13 @@ var TenantManager = class {
|
|
|
5916
6190
|
/**
|
|
5917
6191
|
* Get tenant by ID
|
|
5918
6192
|
*/
|
|
5919
|
-
|
|
6193
|
+
getTenant(tenantId) {
|
|
5920
6194
|
return this.storage.getTenant(tenantId);
|
|
5921
6195
|
}
|
|
5922
6196
|
/**
|
|
5923
6197
|
* Get tenant by slug
|
|
5924
6198
|
*/
|
|
5925
|
-
|
|
6199
|
+
getTenantBySlug(slug) {
|
|
5926
6200
|
return this.storage.getTenantBySlug(slug);
|
|
5927
6201
|
}
|
|
5928
6202
|
/**
|
|
@@ -6269,8 +6543,17 @@ export {
|
|
|
6269
6543
|
VoiceType,
|
|
6270
6544
|
Workflow,
|
|
6271
6545
|
WorkflowFactory,
|
|
6546
|
+
calculatorClient,
|
|
6547
|
+
calculatorDef,
|
|
6548
|
+
calculatorServer,
|
|
6272
6549
|
calculatorTool,
|
|
6550
|
+
clientTool,
|
|
6273
6551
|
createACPTools,
|
|
6552
|
+
createAnthropicProvider,
|
|
6553
|
+
createGeminiProvider,
|
|
6554
|
+
createOllamaProvider,
|
|
6555
|
+
createOpenAIProvider,
|
|
6556
|
+
createProvider,
|
|
6274
6557
|
defaultLogger,
|
|
6275
6558
|
figmaGetCommentsTool,
|
|
6276
6559
|
figmaGetFileTool,
|
|
@@ -6283,12 +6566,17 @@ export {
|
|
|
6283
6566
|
globalMetrics,
|
|
6284
6567
|
globalTracer,
|
|
6285
6568
|
httpRequestTool,
|
|
6569
|
+
hybridTool,
|
|
6286
6570
|
mcpToolToAgenticTool,
|
|
6287
6571
|
n8nExecuteWorkflowTool,
|
|
6288
6572
|
n8nGetExecutionTool,
|
|
6289
6573
|
n8nGetWorkflowTool,
|
|
6290
6574
|
n8nListWorkflowsTool,
|
|
6291
6575
|
n8nTriggerWebhookTool,
|
|
6576
|
+
serverTool,
|
|
6292
6577
|
stringTransformTool,
|
|
6293
|
-
textSummaryTool
|
|
6578
|
+
textSummaryTool,
|
|
6579
|
+
toLegacyTool,
|
|
6580
|
+
toLegacyTools,
|
|
6581
|
+
toolDefinition
|
|
6294
6582
|
};
|