ai 5.0.0-alpha.13 → 5.0.0-alpha.14
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/CHANGELOG.md +15 -0
- package/dist/index.d.mts +81 -68
- package/dist/index.d.ts +81 -68
- package/dist/index.js +120 -116
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +119 -115
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.d.mts +33 -20
- package/dist/internal/index.d.ts +33 -20
- package/dist/internal/index.js +14 -7
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +14 -7
- package/dist/internal/index.mjs.map +1 -1
- package/dist/mcp-stdio/index.d.mts +3 -3
- package/dist/mcp-stdio/index.d.ts +3 -3
- package/dist/mcp-stdio/index.js.map +1 -1
- package/dist/mcp-stdio/index.mjs.map +1 -1
- package/package.json +4 -4
package/dist/index.mjs
CHANGED
@@ -74,24 +74,22 @@ var InvalidStreamPartError = class extends AISDKError2 {
|
|
74
74
|
};
|
75
75
|
_a2 = symbol2;
|
76
76
|
|
77
|
-
// src/error/invalid-tool-
|
77
|
+
// src/error/invalid-tool-input-error.ts
|
78
78
|
import { AISDKError as AISDKError3, getErrorMessage } from "@ai-sdk/provider";
|
79
|
-
var name3 = "
|
79
|
+
var name3 = "AI_InvalidToolInputError";
|
80
80
|
var marker3 = `vercel.ai.error.${name3}`;
|
81
81
|
var symbol3 = Symbol.for(marker3);
|
82
82
|
var _a3;
|
83
|
-
var
|
83
|
+
var InvalidToolInputError = class extends AISDKError3 {
|
84
84
|
constructor({
|
85
|
-
|
85
|
+
toolInput,
|
86
86
|
toolName,
|
87
87
|
cause,
|
88
|
-
message = `Invalid
|
89
|
-
cause
|
90
|
-
)}`
|
88
|
+
message = `Invalid input for tool ${toolName}: ${getErrorMessage(cause)}`
|
91
89
|
}) {
|
92
90
|
super({ name: name3, message, cause });
|
93
91
|
this[_a3] = true;
|
94
|
-
this.
|
92
|
+
this.toolInput = toolInput;
|
95
93
|
this.toolName = toolName;
|
96
94
|
}
|
97
95
|
static isInstance(error) {
|
@@ -242,7 +240,7 @@ var symbol10 = Symbol.for(marker10);
|
|
242
240
|
var _a10;
|
243
241
|
var ToolExecutionError = class extends AISDKError10 {
|
244
242
|
constructor({
|
245
|
-
|
243
|
+
toolInput,
|
246
244
|
toolName,
|
247
245
|
toolCallId,
|
248
246
|
cause,
|
@@ -250,7 +248,7 @@ var ToolExecutionError = class extends AISDKError10 {
|
|
250
248
|
}) {
|
251
249
|
super({ name: name10, message, cause });
|
252
250
|
this[_a10] = true;
|
253
|
-
this.
|
251
|
+
this.toolInput = toolInput;
|
254
252
|
this.toolName = toolName;
|
255
253
|
this.toolCallId = toolCallId;
|
256
254
|
}
|
@@ -464,25 +462,25 @@ var uiMessageStreamPartSchema = z.union([
|
|
464
462
|
errorText: z.string()
|
465
463
|
}),
|
466
464
|
z.strictObject({
|
467
|
-
type: z.literal("tool-
|
465
|
+
type: z.literal("tool-input-start"),
|
468
466
|
toolCallId: z.string(),
|
469
467
|
toolName: z.string()
|
470
468
|
}),
|
471
469
|
z.strictObject({
|
472
|
-
type: z.literal("tool-
|
470
|
+
type: z.literal("tool-input-delta"),
|
473
471
|
toolCallId: z.string(),
|
474
|
-
|
472
|
+
inputTextDelta: z.string()
|
475
473
|
}),
|
476
474
|
z.strictObject({
|
477
|
-
type: z.literal("tool-
|
475
|
+
type: z.literal("tool-input-available"),
|
478
476
|
toolCallId: z.string(),
|
479
477
|
toolName: z.string(),
|
480
|
-
|
478
|
+
input: z.unknown()
|
481
479
|
}),
|
482
480
|
z.strictObject({
|
483
|
-
type: z.literal("tool-
|
481
|
+
type: z.literal("tool-output-available"),
|
484
482
|
toolCallId: z.string(),
|
485
|
-
|
483
|
+
output: z.unknown(),
|
486
484
|
providerMetadata: z.any().optional()
|
487
485
|
}),
|
488
486
|
z.strictObject({
|
@@ -1275,15 +1273,15 @@ function processUIMessageStream({
|
|
1275
1273
|
);
|
1276
1274
|
if (part2 != null) {
|
1277
1275
|
part2.state = options.state;
|
1278
|
-
part2.
|
1279
|
-
part2.
|
1276
|
+
part2.input = options.input;
|
1277
|
+
part2.output = options.output;
|
1280
1278
|
} else {
|
1281
1279
|
state.message.parts.push({
|
1282
1280
|
type: `tool-${options.toolName}`,
|
1283
1281
|
toolCallId: options.toolCallId,
|
1284
1282
|
state: options.state,
|
1285
|
-
|
1286
|
-
|
1283
|
+
input: options.input,
|
1284
|
+
output: options.output
|
1287
1285
|
});
|
1288
1286
|
}
|
1289
1287
|
}
|
@@ -1366,7 +1364,7 @@ function processUIMessageStream({
|
|
1366
1364
|
write();
|
1367
1365
|
break;
|
1368
1366
|
}
|
1369
|
-
case "tool-
|
1367
|
+
case "tool-input-start": {
|
1370
1368
|
const toolInvocations = state.message.parts.filter(isToolUIPart);
|
1371
1369
|
state.partialToolCalls[part.toolCallId] = {
|
1372
1370
|
text: "",
|
@@ -1376,33 +1374,33 @@ function processUIMessageStream({
|
|
1376
1374
|
updateToolInvocationPart({
|
1377
1375
|
toolCallId: part.toolCallId,
|
1378
1376
|
toolName: part.toolName,
|
1379
|
-
state: "
|
1380
|
-
|
1377
|
+
state: "input-streaming",
|
1378
|
+
input: void 0
|
1381
1379
|
});
|
1382
1380
|
write();
|
1383
1381
|
break;
|
1384
1382
|
}
|
1385
|
-
case "tool-
|
1383
|
+
case "tool-input-delta": {
|
1386
1384
|
const partialToolCall = state.partialToolCalls[part.toolCallId];
|
1387
|
-
partialToolCall.text += part.
|
1385
|
+
partialToolCall.text += part.inputTextDelta;
|
1388
1386
|
const { value: partialArgs } = await parsePartialJson(
|
1389
1387
|
partialToolCall.text
|
1390
1388
|
);
|
1391
1389
|
updateToolInvocationPart({
|
1392
1390
|
toolCallId: part.toolCallId,
|
1393
1391
|
toolName: partialToolCall.toolName,
|
1394
|
-
state: "
|
1395
|
-
|
1392
|
+
state: "input-streaming",
|
1393
|
+
input: partialArgs
|
1396
1394
|
});
|
1397
1395
|
write();
|
1398
1396
|
break;
|
1399
1397
|
}
|
1400
|
-
case "tool-
|
1398
|
+
case "tool-input-available": {
|
1401
1399
|
updateToolInvocationPart({
|
1402
1400
|
toolCallId: part.toolCallId,
|
1403
1401
|
toolName: part.toolName,
|
1404
|
-
state: "
|
1405
|
-
|
1402
|
+
state: "input-available",
|
1403
|
+
input: part.input
|
1406
1404
|
});
|
1407
1405
|
write();
|
1408
1406
|
if (onToolCall) {
|
@@ -1413,16 +1411,16 @@ function processUIMessageStream({
|
|
1413
1411
|
updateToolInvocationPart({
|
1414
1412
|
toolCallId: part.toolCallId,
|
1415
1413
|
toolName: part.toolName,
|
1416
|
-
state: "
|
1417
|
-
|
1418
|
-
result
|
1414
|
+
state: "output-available",
|
1415
|
+
input: part.input,
|
1416
|
+
output: result
|
1419
1417
|
});
|
1420
1418
|
write();
|
1421
1419
|
}
|
1422
1420
|
}
|
1423
1421
|
break;
|
1424
1422
|
}
|
1425
|
-
case "tool-
|
1423
|
+
case "tool-output-available": {
|
1426
1424
|
const toolInvocations = state.message.parts.filter(isToolUIPart);
|
1427
1425
|
if (toolInvocations == null) {
|
1428
1426
|
throw new Error("tool_result must be preceded by a tool_call");
|
@@ -1441,9 +1439,9 @@ function processUIMessageStream({
|
|
1441
1439
|
updateToolInvocationPart({
|
1442
1440
|
toolCallId: part.toolCallId,
|
1443
1441
|
toolName,
|
1444
|
-
state: "
|
1445
|
-
|
1446
|
-
|
1442
|
+
state: "output-available",
|
1443
|
+
input: toolInvocations[toolInvocationIndex].input,
|
1444
|
+
output: part.output
|
1447
1445
|
});
|
1448
1446
|
write();
|
1449
1447
|
break;
|
@@ -1539,7 +1537,7 @@ function isAssistantMessageWithCompletedToolCalls(message) {
|
|
1539
1537
|
return part.type === "step-start" ? index : lastIndex;
|
1540
1538
|
}, -1);
|
1541
1539
|
const lastStepToolInvocations = message.parts.slice(lastStepStartIndex + 1).filter(isToolUIPart);
|
1542
|
-
return lastStepToolInvocations.length > 0 && lastStepToolInvocations.every((part) => part.state === "
|
1540
|
+
return lastStepToolInvocations.length > 0 && lastStepToolInvocations.every((part) => part.state === "output-available");
|
1543
1541
|
}
|
1544
1542
|
|
1545
1543
|
// src/ui/chat.ts
|
@@ -1613,13 +1611,13 @@ var AbstractChat = class {
|
|
1613
1611
|
};
|
1614
1612
|
this.addToolResult = async ({
|
1615
1613
|
toolCallId,
|
1616
|
-
|
1614
|
+
output
|
1617
1615
|
}) => {
|
1618
1616
|
this.jobExecutor.run(async () => {
|
1619
|
-
|
1617
|
+
updateToolOutput({
|
1620
1618
|
messages: this.state.messages,
|
1621
1619
|
toolCallId,
|
1622
|
-
|
1620
|
+
output
|
1623
1621
|
});
|
1624
1622
|
this.messages = this.state.messages;
|
1625
1623
|
if (this.status === "submitted" || this.status === "streaming") {
|
@@ -1779,10 +1777,10 @@ var AbstractChat = class {
|
|
1779
1777
|
}
|
1780
1778
|
}
|
1781
1779
|
};
|
1782
|
-
function
|
1780
|
+
function updateToolOutput({
|
1783
1781
|
messages,
|
1784
1782
|
toolCallId,
|
1785
|
-
|
1783
|
+
output
|
1786
1784
|
}) {
|
1787
1785
|
const lastMessage = messages[messages.length - 1];
|
1788
1786
|
const toolPart = lastMessage.parts.find(
|
@@ -1791,8 +1789,8 @@ function updateToolResult({
|
|
1791
1789
|
if (toolPart == null) {
|
1792
1790
|
return;
|
1793
1791
|
}
|
1794
|
-
toolPart.state = "
|
1795
|
-
toolPart.
|
1792
|
+
toolPart.state = "output-available";
|
1793
|
+
toolPart.output = output;
|
1796
1794
|
}
|
1797
1795
|
|
1798
1796
|
// src/ui/convert-to-model-messages.ts
|
@@ -1849,17 +1847,17 @@ function convertToModelMessages(messages, options) {
|
|
1849
1847
|
});
|
1850
1848
|
} else if (isToolUIPart(part)) {
|
1851
1849
|
const toolName = getToolName(part);
|
1852
|
-
if (part.state === "
|
1850
|
+
if (part.state === "input-streaming") {
|
1853
1851
|
throw new MessageConversionError({
|
1854
1852
|
originalMessage: message,
|
1855
|
-
message: `
|
1853
|
+
message: `incomplete tool input is not supported: ${part.toolCallId}`
|
1856
1854
|
});
|
1857
1855
|
} else {
|
1858
1856
|
content.push({
|
1859
1857
|
type: "tool-call",
|
1860
1858
|
toolCallId: part.toolCallId,
|
1861
1859
|
toolName,
|
1862
|
-
|
1860
|
+
input: part.input
|
1863
1861
|
});
|
1864
1862
|
}
|
1865
1863
|
} else {
|
@@ -1876,26 +1874,26 @@ function convertToModelMessages(messages, options) {
|
|
1876
1874
|
modelMessages.push({
|
1877
1875
|
role: "tool",
|
1878
1876
|
content: toolParts.map((toolPart) => {
|
1879
|
-
if (toolPart.state !== "
|
1877
|
+
if (toolPart.state !== "output-available") {
|
1880
1878
|
throw new MessageConversionError({
|
1881
1879
|
originalMessage: message,
|
1882
1880
|
message: "ToolInvocation must have a result: " + JSON.stringify(toolPart)
|
1883
1881
|
});
|
1884
1882
|
}
|
1885
1883
|
const toolName = getToolName(toolPart);
|
1886
|
-
const { toolCallId,
|
1884
|
+
const { toolCallId, output } = toolPart;
|
1887
1885
|
const tool2 = tools[toolName];
|
1888
1886
|
return (tool2 == null ? void 0 : tool2.experimental_toToolResultContent) != null ? {
|
1889
1887
|
type: "tool-result",
|
1890
1888
|
toolCallId,
|
1891
1889
|
toolName,
|
1892
|
-
|
1893
|
-
experimental_content: tool2.experimental_toToolResultContent(
|
1890
|
+
output: tool2.experimental_toToolResultContent(output),
|
1891
|
+
experimental_content: tool2.experimental_toToolResultContent(output)
|
1894
1892
|
} : {
|
1895
1893
|
type: "tool-result",
|
1896
1894
|
toolCallId,
|
1897
1895
|
toolName,
|
1898
|
-
|
1896
|
+
output
|
1899
1897
|
};
|
1900
1898
|
})
|
1901
1899
|
});
|
@@ -3443,7 +3441,7 @@ function convertToLanguageModelMessage(message, downloadedAssets) {
|
|
3443
3441
|
type: "tool-call",
|
3444
3442
|
toolCallId: part.toolCallId,
|
3445
3443
|
toolName: part.toolName,
|
3446
|
-
|
3444
|
+
input: part.input,
|
3447
3445
|
providerOptions
|
3448
3446
|
};
|
3449
3447
|
}
|
@@ -3459,7 +3457,7 @@ function convertToLanguageModelMessage(message, downloadedAssets) {
|
|
3459
3457
|
type: "tool-result",
|
3460
3458
|
toolCallId: part.toolCallId,
|
3461
3459
|
toolName: part.toolName,
|
3462
|
-
|
3460
|
+
output: part.output,
|
3463
3461
|
content: part.experimental_content,
|
3464
3462
|
isError: part.isError,
|
3465
3463
|
providerOptions: part.providerOptions
|
@@ -3746,14 +3744,14 @@ var toolCallPartSchema = z6.object({
|
|
3746
3744
|
type: z6.literal("tool-call"),
|
3747
3745
|
toolCallId: z6.string(),
|
3748
3746
|
toolName: z6.string(),
|
3749
|
-
|
3747
|
+
input: z6.unknown(),
|
3750
3748
|
providerOptions: providerMetadataSchema.optional()
|
3751
3749
|
});
|
3752
3750
|
var toolResultPartSchema = z6.object({
|
3753
3751
|
type: z6.literal("tool-result"),
|
3754
3752
|
toolCallId: z6.string(),
|
3755
3753
|
toolName: z6.string(),
|
3756
|
-
|
3754
|
+
output: z6.unknown(),
|
3757
3755
|
content: toolResultContentSchema.optional(),
|
3758
3756
|
isError: z6.boolean().optional(),
|
3759
3757
|
providerOptions: providerMetadataSchema.optional()
|
@@ -5359,11 +5357,18 @@ function prepareToolsAndToolChoice({
|
|
5359
5357
|
type: "function",
|
5360
5358
|
name: name17,
|
5361
5359
|
description: tool2.description,
|
5362
|
-
|
5360
|
+
inputSchema: asSchema2(tool2.inputSchema).jsonSchema
|
5361
|
+
};
|
5362
|
+
case "provider-defined-client":
|
5363
|
+
return {
|
5364
|
+
type: "provider-defined-client",
|
5365
|
+
name: name17,
|
5366
|
+
id: tool2.id,
|
5367
|
+
args: tool2.args
|
5363
5368
|
};
|
5364
|
-
case "provider-defined":
|
5369
|
+
case "provider-defined-server":
|
5365
5370
|
return {
|
5366
|
-
type: "provider-defined",
|
5371
|
+
type: "provider-defined-server",
|
5367
5372
|
name: name17,
|
5368
5373
|
id: tool2.id,
|
5369
5374
|
args: tool2.args
|
@@ -5447,7 +5452,7 @@ async function parseToolCall({
|
|
5447
5452
|
try {
|
5448
5453
|
return await doParseToolCall({ toolCall, tools });
|
5449
5454
|
} catch (error) {
|
5450
|
-
if (repairToolCall == null || !(NoSuchToolError.isInstance(error) ||
|
5455
|
+
if (repairToolCall == null || !(NoSuchToolError.isInstance(error) || InvalidToolInputError.isInstance(error))) {
|
5451
5456
|
throw error;
|
5452
5457
|
}
|
5453
5458
|
let repairedToolCall = null;
|
@@ -5455,9 +5460,9 @@ async function parseToolCall({
|
|
5455
5460
|
repairedToolCall = await repairToolCall({
|
5456
5461
|
toolCall,
|
5457
5462
|
tools,
|
5458
|
-
|
5459
|
-
const {
|
5460
|
-
return asSchema3(
|
5463
|
+
inputSchema: ({ toolName }) => {
|
5464
|
+
const { inputSchema } = tools[toolName];
|
5465
|
+
return asSchema3(inputSchema).jsonSchema;
|
5461
5466
|
},
|
5462
5467
|
system,
|
5463
5468
|
messages,
|
@@ -5487,12 +5492,12 @@ async function doParseToolCall({
|
|
5487
5492
|
availableTools: Object.keys(tools)
|
5488
5493
|
});
|
5489
5494
|
}
|
5490
|
-
const schema = asSchema3(tool2.
|
5491
|
-
const parseResult = toolCall.
|
5495
|
+
const schema = asSchema3(tool2.inputSchema);
|
5496
|
+
const parseResult = toolCall.input.trim() === "" ? await safeValidateTypes3({ value: {}, schema }) : await safeParseJSON3({ text: toolCall.input, schema });
|
5492
5497
|
if (parseResult.success === false) {
|
5493
|
-
throw new
|
5498
|
+
throw new InvalidToolInputError({
|
5494
5499
|
toolName,
|
5495
|
-
|
5500
|
+
toolInput: toolCall.input,
|
5496
5501
|
cause: parseResult.error
|
5497
5502
|
});
|
5498
5503
|
}
|
@@ -5500,7 +5505,7 @@ async function doParseToolCall({
|
|
5500
5505
|
type: "tool-call",
|
5501
5506
|
toolCallId: toolCall.toolCallId,
|
5502
5507
|
toolName,
|
5503
|
-
|
5508
|
+
input: parseResult.value
|
5504
5509
|
};
|
5505
5510
|
}
|
5506
5511
|
|
@@ -5603,15 +5608,15 @@ function toResponseMessages({
|
|
5603
5608
|
type: "tool-result",
|
5604
5609
|
toolCallId: toolResult.toolCallId,
|
5605
5610
|
toolName: toolResult.toolName,
|
5606
|
-
|
5611
|
+
output: tool2.experimental_toToolResultContent(toolResult.output),
|
5607
5612
|
experimental_content: tool2.experimental_toToolResultContent(
|
5608
|
-
toolResult.
|
5613
|
+
toolResult.output
|
5609
5614
|
)
|
5610
5615
|
} : {
|
5611
5616
|
type: "tool-result",
|
5612
5617
|
toolCallId: toolResult.toolCallId,
|
5613
5618
|
toolName: toolResult.toolName,
|
5614
|
-
|
5619
|
+
output: toolResult.output
|
5615
5620
|
};
|
5616
5621
|
});
|
5617
5622
|
if (toolResultContent.length > 0) {
|
@@ -5917,11 +5922,11 @@ async function executeTools({
|
|
5917
5922
|
abortSignal
|
5918
5923
|
}) {
|
5919
5924
|
const toolResults = await Promise.all(
|
5920
|
-
toolCalls.map(async ({ toolCallId, toolName,
|
5925
|
+
toolCalls.map(async ({ toolCallId, toolName, input }) => {
|
5921
5926
|
const tool2 = tools[toolName];
|
5922
|
-
if ((tool2 == null ? void 0 : tool2.
|
5923
|
-
await tool2.
|
5924
|
-
|
5927
|
+
if ((tool2 == null ? void 0 : tool2.onInputAvailable) != null) {
|
5928
|
+
await tool2.onInputAvailable({
|
5929
|
+
input,
|
5925
5930
|
toolCallId,
|
5926
5931
|
messages,
|
5927
5932
|
abortSignal
|
@@ -5941,15 +5946,15 @@ async function executeTools({
|
|
5941
5946
|
}),
|
5942
5947
|
"ai.toolCall.name": toolName,
|
5943
5948
|
"ai.toolCall.id": toolCallId,
|
5944
|
-
"ai.toolCall.
|
5945
|
-
output: () => JSON.stringify(
|
5949
|
+
"ai.toolCall.input": {
|
5950
|
+
output: () => JSON.stringify(input)
|
5946
5951
|
}
|
5947
5952
|
}
|
5948
5953
|
}),
|
5949
5954
|
tracer,
|
5950
5955
|
fn: async (span) => {
|
5951
5956
|
try {
|
5952
|
-
const result2 = await tool2.execute(
|
5957
|
+
const result2 = await tool2.execute(input, {
|
5953
5958
|
toolCallId,
|
5954
5959
|
messages,
|
5955
5960
|
abortSignal
|
@@ -5972,7 +5977,7 @@ async function executeTools({
|
|
5972
5977
|
throw new ToolExecutionError({
|
5973
5978
|
toolCallId,
|
5974
5979
|
toolName,
|
5975
|
-
|
5980
|
+
toolInput: input,
|
5976
5981
|
cause: error
|
5977
5982
|
});
|
5978
5983
|
}
|
@@ -5982,8 +5987,8 @@ async function executeTools({
|
|
5982
5987
|
type: "tool-result",
|
5983
5988
|
toolCallId,
|
5984
5989
|
toolName,
|
5985
|
-
|
5986
|
-
result
|
5990
|
+
input,
|
5991
|
+
output: result
|
5987
5992
|
};
|
5988
5993
|
})
|
5989
5994
|
);
|
@@ -6073,7 +6078,7 @@ function asToolCalls(content) {
|
|
6073
6078
|
toolCallType: toolCall.toolCallType,
|
6074
6079
|
toolCallId: toolCall.toolCallId,
|
6075
6080
|
toolName: toolCall.toolName,
|
6076
|
-
|
6081
|
+
input: toolCall.input
|
6077
6082
|
}));
|
6078
6083
|
}
|
6079
6084
|
|
@@ -6301,7 +6306,7 @@ function runToolsTransformation({
|
|
6301
6306
|
type: "tool-call-delta",
|
6302
6307
|
toolCallId: chunk.toolCallId,
|
6303
6308
|
toolName: chunk.toolName,
|
6304
|
-
|
6309
|
+
inputTextDelta: chunk.inputTextDelta
|
6305
6310
|
});
|
6306
6311
|
break;
|
6307
6312
|
}
|
@@ -6316,9 +6321,9 @@ function runToolsTransformation({
|
|
6316
6321
|
});
|
6317
6322
|
controller.enqueue(toolCall);
|
6318
6323
|
const tool2 = tools[toolCall.toolName];
|
6319
|
-
if (tool2.
|
6320
|
-
await tool2.
|
6321
|
-
|
6324
|
+
if (tool2.onInputAvailable != null) {
|
6325
|
+
await tool2.onInputAvailable({
|
6326
|
+
input: toolCall.input,
|
6322
6327
|
toolCallId: toolCall.toolCallId,
|
6323
6328
|
messages,
|
6324
6329
|
abortSignal
|
@@ -6338,22 +6343,22 @@ function runToolsTransformation({
|
|
6338
6343
|
}),
|
6339
6344
|
"ai.toolCall.name": toolCall.toolName,
|
6340
6345
|
"ai.toolCall.id": toolCall.toolCallId,
|
6341
|
-
"ai.toolCall.
|
6342
|
-
output: () => JSON.stringify(toolCall.
|
6346
|
+
"ai.toolCall.input": {
|
6347
|
+
output: () => JSON.stringify(toolCall.input)
|
6343
6348
|
}
|
6344
6349
|
}
|
6345
6350
|
}),
|
6346
6351
|
tracer,
|
6347
|
-
fn: async (span) => tool2.execute(toolCall.
|
6352
|
+
fn: async (span) => tool2.execute(toolCall.input, {
|
6348
6353
|
toolCallId: toolCall.toolCallId,
|
6349
6354
|
messages,
|
6350
6355
|
abortSignal
|
6351
6356
|
}).then(
|
6352
|
-
(
|
6357
|
+
(output) => {
|
6353
6358
|
toolResultsStreamController.enqueue({
|
6354
6359
|
...toolCall,
|
6355
6360
|
type: "tool-result",
|
6356
|
-
|
6361
|
+
output
|
6357
6362
|
});
|
6358
6363
|
outstandingToolResults.delete(toolExecutionId);
|
6359
6364
|
attemptClose();
|
@@ -6362,8 +6367,8 @@ function runToolsTransformation({
|
|
6362
6367
|
selectTelemetryAttributes({
|
6363
6368
|
telemetry,
|
6364
6369
|
attributes: {
|
6365
|
-
"ai.toolCall.
|
6366
|
-
output: () => JSON.stringify(
|
6370
|
+
"ai.toolCall.output": {
|
6371
|
+
output: () => JSON.stringify(output)
|
6367
6372
|
}
|
6368
6373
|
}
|
6369
6374
|
})
|
@@ -6377,7 +6382,7 @@ function runToolsTransformation({
|
|
6377
6382
|
error: new ToolExecutionError({
|
6378
6383
|
toolCallId: toolCall.toolCallId,
|
6379
6384
|
toolName: toolCall.toolName,
|
6380
|
-
|
6385
|
+
toolInput: toolCall.input,
|
6381
6386
|
cause: error
|
6382
6387
|
})
|
6383
6388
|
});
|
@@ -7029,8 +7034,8 @@ var DefaultStreamTextResult = class {
|
|
7029
7034
|
}
|
7030
7035
|
case "tool-call-streaming-start": {
|
7031
7036
|
const tool2 = tools == null ? void 0 : tools[chunk.toolName];
|
7032
|
-
if ((tool2 == null ? void 0 : tool2.
|
7033
|
-
await tool2.
|
7037
|
+
if ((tool2 == null ? void 0 : tool2.onInputStart) != null) {
|
7038
|
+
await tool2.onInputStart({
|
7034
7039
|
toolCallId: chunk.toolCallId,
|
7035
7040
|
messages: stepInputMessages,
|
7036
7041
|
abortSignal
|
@@ -7041,9 +7046,9 @@ var DefaultStreamTextResult = class {
|
|
7041
7046
|
}
|
7042
7047
|
case "tool-call-delta": {
|
7043
7048
|
const tool2 = tools == null ? void 0 : tools[chunk.toolName];
|
7044
|
-
if ((tool2 == null ? void 0 : tool2.
|
7045
|
-
await tool2.
|
7046
|
-
|
7049
|
+
if ((tool2 == null ? void 0 : tool2.onInputDelta) != null) {
|
7050
|
+
await tool2.onInputDelta({
|
7051
|
+
inputTextDelta: chunk.inputTextDelta,
|
7047
7052
|
toolCallId: chunk.toolCallId,
|
7048
7053
|
messages: stepInputMessages,
|
7049
7054
|
abortSignal
|
@@ -7358,7 +7363,7 @@ var DefaultStreamTextResult = class {
|
|
7358
7363
|
}
|
7359
7364
|
case "tool-call-streaming-start": {
|
7360
7365
|
controller.enqueue({
|
7361
|
-
type: "tool-
|
7366
|
+
type: "tool-input-start",
|
7362
7367
|
toolCallId: part.toolCallId,
|
7363
7368
|
toolName: part.toolName
|
7364
7369
|
});
|
@@ -7366,26 +7371,26 @@ var DefaultStreamTextResult = class {
|
|
7366
7371
|
}
|
7367
7372
|
case "tool-call-delta": {
|
7368
7373
|
controller.enqueue({
|
7369
|
-
type: "tool-
|
7374
|
+
type: "tool-input-delta",
|
7370
7375
|
toolCallId: part.toolCallId,
|
7371
|
-
|
7376
|
+
inputTextDelta: part.inputTextDelta
|
7372
7377
|
});
|
7373
7378
|
break;
|
7374
7379
|
}
|
7375
7380
|
case "tool-call": {
|
7376
7381
|
controller.enqueue({
|
7377
|
-
type: "tool-
|
7382
|
+
type: "tool-input-available",
|
7378
7383
|
toolCallId: part.toolCallId,
|
7379
7384
|
toolName: part.toolName,
|
7380
|
-
|
7385
|
+
input: part.input
|
7381
7386
|
});
|
7382
7387
|
break;
|
7383
7388
|
}
|
7384
7389
|
case "tool-result": {
|
7385
7390
|
controller.enqueue({
|
7386
|
-
type: "tool-
|
7391
|
+
type: "tool-output-available",
|
7387
7392
|
toolCallId: part.toolCallId,
|
7388
|
-
|
7393
|
+
output: part.output
|
7389
7394
|
});
|
7390
7395
|
break;
|
7391
7396
|
}
|
@@ -8396,15 +8401,14 @@ var MCPClient = class {
|
|
8396
8401
|
if (schemas !== "automatic" && !(name17 in schemas)) {
|
8397
8402
|
continue;
|
8398
8403
|
}
|
8399
|
-
const parameters = schemas === "automatic" ? jsonSchema({
|
8400
|
-
...inputSchema,
|
8401
|
-
properties: (_a17 = inputSchema.properties) != null ? _a17 : {},
|
8402
|
-
additionalProperties: false
|
8403
|
-
}) : schemas[name17].parameters;
|
8404
8404
|
const self = this;
|
8405
8405
|
const toolWithExecute = tool({
|
8406
8406
|
description,
|
8407
|
-
|
8407
|
+
inputSchema: schemas === "automatic" ? jsonSchema({
|
8408
|
+
...inputSchema,
|
8409
|
+
properties: (_a17 = inputSchema.properties) != null ? _a17 : {},
|
8410
|
+
additionalProperties: false
|
8411
|
+
}) : schemas[name17].inputSchema,
|
8408
8412
|
execute: async (args, options) => {
|
8409
8413
|
var _a18;
|
8410
8414
|
(_a18 = options == null ? void 0 : options.abortSignal) == null ? void 0 : _a18.throwIfAborted();
|
@@ -8536,7 +8540,7 @@ export {
|
|
8536
8540
|
InvalidPromptError,
|
8537
8541
|
InvalidResponseDataError,
|
8538
8542
|
InvalidStreamPartError,
|
8539
|
-
|
8543
|
+
InvalidToolInputError,
|
8540
8544
|
JSONParseError,
|
8541
8545
|
JsonToSseTransformStream,
|
8542
8546
|
LoadAPIKeyError,
|