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.js
CHANGED
@@ -33,7 +33,7 @@ __export(src_exports, {
|
|
33
33
|
InvalidPromptError: () => import_provider16.InvalidPromptError,
|
34
34
|
InvalidResponseDataError: () => import_provider16.InvalidResponseDataError,
|
35
35
|
InvalidStreamPartError: () => InvalidStreamPartError,
|
36
|
-
|
36
|
+
InvalidToolInputError: () => InvalidToolInputError,
|
37
37
|
JSONParseError: () => import_provider16.JSONParseError,
|
38
38
|
JsonToSseTransformStream: () => JsonToSseTransformStream,
|
39
39
|
LoadAPIKeyError: () => import_provider16.LoadAPIKeyError,
|
@@ -160,24 +160,22 @@ var InvalidStreamPartError = class extends import_provider2.AISDKError {
|
|
160
160
|
};
|
161
161
|
_a2 = symbol2;
|
162
162
|
|
163
|
-
// src/error/invalid-tool-
|
163
|
+
// src/error/invalid-tool-input-error.ts
|
164
164
|
var import_provider3 = require("@ai-sdk/provider");
|
165
|
-
var name3 = "
|
165
|
+
var name3 = "AI_InvalidToolInputError";
|
166
166
|
var marker3 = `vercel.ai.error.${name3}`;
|
167
167
|
var symbol3 = Symbol.for(marker3);
|
168
168
|
var _a3;
|
169
|
-
var
|
169
|
+
var InvalidToolInputError = class extends import_provider3.AISDKError {
|
170
170
|
constructor({
|
171
|
-
|
171
|
+
toolInput,
|
172
172
|
toolName,
|
173
173
|
cause,
|
174
|
-
message = `Invalid
|
175
|
-
cause
|
176
|
-
)}`
|
174
|
+
message = `Invalid input for tool ${toolName}: ${(0, import_provider3.getErrorMessage)(cause)}`
|
177
175
|
}) {
|
178
176
|
super({ name: name3, message, cause });
|
179
177
|
this[_a3] = true;
|
180
|
-
this.
|
178
|
+
this.toolInput = toolInput;
|
181
179
|
this.toolName = toolName;
|
182
180
|
}
|
183
181
|
static isInstance(error) {
|
@@ -328,7 +326,7 @@ var symbol10 = Symbol.for(marker10);
|
|
328
326
|
var _a10;
|
329
327
|
var ToolExecutionError = class extends import_provider10.AISDKError {
|
330
328
|
constructor({
|
331
|
-
|
329
|
+
toolInput,
|
332
330
|
toolName,
|
333
331
|
toolCallId,
|
334
332
|
cause,
|
@@ -336,7 +334,7 @@ var ToolExecutionError = class extends import_provider10.AISDKError {
|
|
336
334
|
}) {
|
337
335
|
super({ name: name10, message, cause });
|
338
336
|
this[_a10] = true;
|
339
|
-
this.
|
337
|
+
this.toolInput = toolInput;
|
340
338
|
this.toolName = toolName;
|
341
339
|
this.toolCallId = toolCallId;
|
342
340
|
}
|
@@ -550,25 +548,25 @@ var uiMessageStreamPartSchema = import_zod.z.union([
|
|
550
548
|
errorText: import_zod.z.string()
|
551
549
|
}),
|
552
550
|
import_zod.z.strictObject({
|
553
|
-
type: import_zod.z.literal("tool-
|
551
|
+
type: import_zod.z.literal("tool-input-start"),
|
554
552
|
toolCallId: import_zod.z.string(),
|
555
553
|
toolName: import_zod.z.string()
|
556
554
|
}),
|
557
555
|
import_zod.z.strictObject({
|
558
|
-
type: import_zod.z.literal("tool-
|
556
|
+
type: import_zod.z.literal("tool-input-delta"),
|
559
557
|
toolCallId: import_zod.z.string(),
|
560
|
-
|
558
|
+
inputTextDelta: import_zod.z.string()
|
561
559
|
}),
|
562
560
|
import_zod.z.strictObject({
|
563
|
-
type: import_zod.z.literal("tool-
|
561
|
+
type: import_zod.z.literal("tool-input-available"),
|
564
562
|
toolCallId: import_zod.z.string(),
|
565
563
|
toolName: import_zod.z.string(),
|
566
|
-
|
564
|
+
input: import_zod.z.unknown()
|
567
565
|
}),
|
568
566
|
import_zod.z.strictObject({
|
569
|
-
type: import_zod.z.literal("tool-
|
567
|
+
type: import_zod.z.literal("tool-output-available"),
|
570
568
|
toolCallId: import_zod.z.string(),
|
571
|
-
|
569
|
+
output: import_zod.z.unknown(),
|
572
570
|
providerMetadata: import_zod.z.any().optional()
|
573
571
|
}),
|
574
572
|
import_zod.z.strictObject({
|
@@ -1355,15 +1353,15 @@ function processUIMessageStream({
|
|
1355
1353
|
);
|
1356
1354
|
if (part2 != null) {
|
1357
1355
|
part2.state = options.state;
|
1358
|
-
part2.
|
1359
|
-
part2.
|
1356
|
+
part2.input = options.input;
|
1357
|
+
part2.output = options.output;
|
1360
1358
|
} else {
|
1361
1359
|
state.message.parts.push({
|
1362
1360
|
type: `tool-${options.toolName}`,
|
1363
1361
|
toolCallId: options.toolCallId,
|
1364
1362
|
state: options.state,
|
1365
|
-
|
1366
|
-
|
1363
|
+
input: options.input,
|
1364
|
+
output: options.output
|
1367
1365
|
});
|
1368
1366
|
}
|
1369
1367
|
}
|
@@ -1446,7 +1444,7 @@ function processUIMessageStream({
|
|
1446
1444
|
write();
|
1447
1445
|
break;
|
1448
1446
|
}
|
1449
|
-
case "tool-
|
1447
|
+
case "tool-input-start": {
|
1450
1448
|
const toolInvocations = state.message.parts.filter(isToolUIPart);
|
1451
1449
|
state.partialToolCalls[part.toolCallId] = {
|
1452
1450
|
text: "",
|
@@ -1456,33 +1454,33 @@ function processUIMessageStream({
|
|
1456
1454
|
updateToolInvocationPart({
|
1457
1455
|
toolCallId: part.toolCallId,
|
1458
1456
|
toolName: part.toolName,
|
1459
|
-
state: "
|
1460
|
-
|
1457
|
+
state: "input-streaming",
|
1458
|
+
input: void 0
|
1461
1459
|
});
|
1462
1460
|
write();
|
1463
1461
|
break;
|
1464
1462
|
}
|
1465
|
-
case "tool-
|
1463
|
+
case "tool-input-delta": {
|
1466
1464
|
const partialToolCall = state.partialToolCalls[part.toolCallId];
|
1467
|
-
partialToolCall.text += part.
|
1465
|
+
partialToolCall.text += part.inputTextDelta;
|
1468
1466
|
const { value: partialArgs } = await parsePartialJson(
|
1469
1467
|
partialToolCall.text
|
1470
1468
|
);
|
1471
1469
|
updateToolInvocationPart({
|
1472
1470
|
toolCallId: part.toolCallId,
|
1473
1471
|
toolName: partialToolCall.toolName,
|
1474
|
-
state: "
|
1475
|
-
|
1472
|
+
state: "input-streaming",
|
1473
|
+
input: partialArgs
|
1476
1474
|
});
|
1477
1475
|
write();
|
1478
1476
|
break;
|
1479
1477
|
}
|
1480
|
-
case "tool-
|
1478
|
+
case "tool-input-available": {
|
1481
1479
|
updateToolInvocationPart({
|
1482
1480
|
toolCallId: part.toolCallId,
|
1483
1481
|
toolName: part.toolName,
|
1484
|
-
state: "
|
1485
|
-
|
1482
|
+
state: "input-available",
|
1483
|
+
input: part.input
|
1486
1484
|
});
|
1487
1485
|
write();
|
1488
1486
|
if (onToolCall) {
|
@@ -1493,16 +1491,16 @@ function processUIMessageStream({
|
|
1493
1491
|
updateToolInvocationPart({
|
1494
1492
|
toolCallId: part.toolCallId,
|
1495
1493
|
toolName: part.toolName,
|
1496
|
-
state: "
|
1497
|
-
|
1498
|
-
result
|
1494
|
+
state: "output-available",
|
1495
|
+
input: part.input,
|
1496
|
+
output: result
|
1499
1497
|
});
|
1500
1498
|
write();
|
1501
1499
|
}
|
1502
1500
|
}
|
1503
1501
|
break;
|
1504
1502
|
}
|
1505
|
-
case "tool-
|
1503
|
+
case "tool-output-available": {
|
1506
1504
|
const toolInvocations = state.message.parts.filter(isToolUIPart);
|
1507
1505
|
if (toolInvocations == null) {
|
1508
1506
|
throw new Error("tool_result must be preceded by a tool_call");
|
@@ -1521,9 +1519,9 @@ function processUIMessageStream({
|
|
1521
1519
|
updateToolInvocationPart({
|
1522
1520
|
toolCallId: part.toolCallId,
|
1523
1521
|
toolName,
|
1524
|
-
state: "
|
1525
|
-
|
1526
|
-
|
1522
|
+
state: "output-available",
|
1523
|
+
input: toolInvocations[toolInvocationIndex].input,
|
1524
|
+
output: part.output
|
1527
1525
|
});
|
1528
1526
|
write();
|
1529
1527
|
break;
|
@@ -1619,7 +1617,7 @@ function isAssistantMessageWithCompletedToolCalls(message) {
|
|
1619
1617
|
return part.type === "step-start" ? index : lastIndex;
|
1620
1618
|
}, -1);
|
1621
1619
|
const lastStepToolInvocations = message.parts.slice(lastStepStartIndex + 1).filter(isToolUIPart);
|
1622
|
-
return lastStepToolInvocations.length > 0 && lastStepToolInvocations.every((part) => part.state === "
|
1620
|
+
return lastStepToolInvocations.length > 0 && lastStepToolInvocations.every((part) => part.state === "output-available");
|
1623
1621
|
}
|
1624
1622
|
|
1625
1623
|
// src/ui/chat.ts
|
@@ -1693,13 +1691,13 @@ var AbstractChat = class {
|
|
1693
1691
|
};
|
1694
1692
|
this.addToolResult = async ({
|
1695
1693
|
toolCallId,
|
1696
|
-
|
1694
|
+
output
|
1697
1695
|
}) => {
|
1698
1696
|
this.jobExecutor.run(async () => {
|
1699
|
-
|
1697
|
+
updateToolOutput({
|
1700
1698
|
messages: this.state.messages,
|
1701
1699
|
toolCallId,
|
1702
|
-
|
1700
|
+
output
|
1703
1701
|
});
|
1704
1702
|
this.messages = this.state.messages;
|
1705
1703
|
if (this.status === "submitted" || this.status === "streaming") {
|
@@ -1859,10 +1857,10 @@ var AbstractChat = class {
|
|
1859
1857
|
}
|
1860
1858
|
}
|
1861
1859
|
};
|
1862
|
-
function
|
1860
|
+
function updateToolOutput({
|
1863
1861
|
messages,
|
1864
1862
|
toolCallId,
|
1865
|
-
|
1863
|
+
output
|
1866
1864
|
}) {
|
1867
1865
|
const lastMessage = messages[messages.length - 1];
|
1868
1866
|
const toolPart = lastMessage.parts.find(
|
@@ -1871,8 +1869,8 @@ function updateToolResult({
|
|
1871
1869
|
if (toolPart == null) {
|
1872
1870
|
return;
|
1873
1871
|
}
|
1874
|
-
toolPart.state = "
|
1875
|
-
toolPart.
|
1872
|
+
toolPart.state = "output-available";
|
1873
|
+
toolPart.output = output;
|
1876
1874
|
}
|
1877
1875
|
|
1878
1876
|
// src/ui/convert-to-model-messages.ts
|
@@ -1929,17 +1927,17 @@ function convertToModelMessages(messages, options) {
|
|
1929
1927
|
});
|
1930
1928
|
} else if (isToolUIPart(part)) {
|
1931
1929
|
const toolName = getToolName(part);
|
1932
|
-
if (part.state === "
|
1930
|
+
if (part.state === "input-streaming") {
|
1933
1931
|
throw new MessageConversionError({
|
1934
1932
|
originalMessage: message,
|
1935
|
-
message: `
|
1933
|
+
message: `incomplete tool input is not supported: ${part.toolCallId}`
|
1936
1934
|
});
|
1937
1935
|
} else {
|
1938
1936
|
content.push({
|
1939
1937
|
type: "tool-call",
|
1940
1938
|
toolCallId: part.toolCallId,
|
1941
1939
|
toolName,
|
1942
|
-
|
1940
|
+
input: part.input
|
1943
1941
|
});
|
1944
1942
|
}
|
1945
1943
|
} else {
|
@@ -1956,26 +1954,26 @@ function convertToModelMessages(messages, options) {
|
|
1956
1954
|
modelMessages.push({
|
1957
1955
|
role: "tool",
|
1958
1956
|
content: toolParts.map((toolPart) => {
|
1959
|
-
if (toolPart.state !== "
|
1957
|
+
if (toolPart.state !== "output-available") {
|
1960
1958
|
throw new MessageConversionError({
|
1961
1959
|
originalMessage: message,
|
1962
1960
|
message: "ToolInvocation must have a result: " + JSON.stringify(toolPart)
|
1963
1961
|
});
|
1964
1962
|
}
|
1965
1963
|
const toolName = getToolName(toolPart);
|
1966
|
-
const { toolCallId,
|
1964
|
+
const { toolCallId, output } = toolPart;
|
1967
1965
|
const tool2 = tools[toolName];
|
1968
1966
|
return (tool2 == null ? void 0 : tool2.experimental_toToolResultContent) != null ? {
|
1969
1967
|
type: "tool-result",
|
1970
1968
|
toolCallId,
|
1971
1969
|
toolName,
|
1972
|
-
|
1973
|
-
experimental_content: tool2.experimental_toToolResultContent(
|
1970
|
+
output: tool2.experimental_toToolResultContent(output),
|
1971
|
+
experimental_content: tool2.experimental_toToolResultContent(output)
|
1974
1972
|
} : {
|
1975
1973
|
type: "tool-result",
|
1976
1974
|
toolCallId,
|
1977
1975
|
toolName,
|
1978
|
-
|
1976
|
+
output
|
1979
1977
|
};
|
1980
1978
|
})
|
1981
1979
|
});
|
@@ -3509,7 +3507,7 @@ function convertToLanguageModelMessage(message, downloadedAssets) {
|
|
3509
3507
|
type: "tool-call",
|
3510
3508
|
toolCallId: part.toolCallId,
|
3511
3509
|
toolName: part.toolName,
|
3512
|
-
|
3510
|
+
input: part.input,
|
3513
3511
|
providerOptions
|
3514
3512
|
};
|
3515
3513
|
}
|
@@ -3525,7 +3523,7 @@ function convertToLanguageModelMessage(message, downloadedAssets) {
|
|
3525
3523
|
type: "tool-result",
|
3526
3524
|
toolCallId: part.toolCallId,
|
3527
3525
|
toolName: part.toolName,
|
3528
|
-
|
3526
|
+
output: part.output,
|
3529
3527
|
content: part.experimental_content,
|
3530
3528
|
isError: part.isError,
|
3531
3529
|
providerOptions: part.providerOptions
|
@@ -3812,14 +3810,14 @@ var toolCallPartSchema = import_zod6.z.object({
|
|
3812
3810
|
type: import_zod6.z.literal("tool-call"),
|
3813
3811
|
toolCallId: import_zod6.z.string(),
|
3814
3812
|
toolName: import_zod6.z.string(),
|
3815
|
-
|
3813
|
+
input: import_zod6.z.unknown(),
|
3816
3814
|
providerOptions: providerMetadataSchema.optional()
|
3817
3815
|
});
|
3818
3816
|
var toolResultPartSchema = import_zod6.z.object({
|
3819
3817
|
type: import_zod6.z.literal("tool-result"),
|
3820
3818
|
toolCallId: import_zod6.z.string(),
|
3821
3819
|
toolName: import_zod6.z.string(),
|
3822
|
-
|
3820
|
+
output: import_zod6.z.unknown(),
|
3823
3821
|
content: toolResultContentSchema.optional(),
|
3824
3822
|
isError: import_zod6.z.boolean().optional(),
|
3825
3823
|
providerOptions: providerMetadataSchema.optional()
|
@@ -5412,11 +5410,18 @@ function prepareToolsAndToolChoice({
|
|
5412
5410
|
type: "function",
|
5413
5411
|
name: name17,
|
5414
5412
|
description: tool2.description,
|
5415
|
-
|
5413
|
+
inputSchema: (0, import_provider_utils17.asSchema)(tool2.inputSchema).jsonSchema
|
5414
|
+
};
|
5415
|
+
case "provider-defined-client":
|
5416
|
+
return {
|
5417
|
+
type: "provider-defined-client",
|
5418
|
+
name: name17,
|
5419
|
+
id: tool2.id,
|
5420
|
+
args: tool2.args
|
5416
5421
|
};
|
5417
|
-
case "provider-defined":
|
5422
|
+
case "provider-defined-server":
|
5418
5423
|
return {
|
5419
|
-
type: "provider-defined",
|
5424
|
+
type: "provider-defined-server",
|
5420
5425
|
name: name17,
|
5421
5426
|
id: tool2.id,
|
5422
5427
|
args: tool2.args
|
@@ -5496,7 +5501,7 @@ async function parseToolCall({
|
|
5496
5501
|
try {
|
5497
5502
|
return await doParseToolCall({ toolCall, tools });
|
5498
5503
|
} catch (error) {
|
5499
|
-
if (repairToolCall == null || !(NoSuchToolError.isInstance(error) ||
|
5504
|
+
if (repairToolCall == null || !(NoSuchToolError.isInstance(error) || InvalidToolInputError.isInstance(error))) {
|
5500
5505
|
throw error;
|
5501
5506
|
}
|
5502
5507
|
let repairedToolCall = null;
|
@@ -5504,9 +5509,9 @@ async function parseToolCall({
|
|
5504
5509
|
repairedToolCall = await repairToolCall({
|
5505
5510
|
toolCall,
|
5506
5511
|
tools,
|
5507
|
-
|
5508
|
-
const {
|
5509
|
-
return (0, import_provider_utils18.asSchema)(
|
5512
|
+
inputSchema: ({ toolName }) => {
|
5513
|
+
const { inputSchema } = tools[toolName];
|
5514
|
+
return (0, import_provider_utils18.asSchema)(inputSchema).jsonSchema;
|
5510
5515
|
},
|
5511
5516
|
system,
|
5512
5517
|
messages,
|
@@ -5536,12 +5541,12 @@ async function doParseToolCall({
|
|
5536
5541
|
availableTools: Object.keys(tools)
|
5537
5542
|
});
|
5538
5543
|
}
|
5539
|
-
const schema = (0, import_provider_utils18.asSchema)(tool2.
|
5540
|
-
const parseResult = toolCall.
|
5544
|
+
const schema = (0, import_provider_utils18.asSchema)(tool2.inputSchema);
|
5545
|
+
const parseResult = toolCall.input.trim() === "" ? await (0, import_provider_utils18.safeValidateTypes)({ value: {}, schema }) : await (0, import_provider_utils18.safeParseJSON)({ text: toolCall.input, schema });
|
5541
5546
|
if (parseResult.success === false) {
|
5542
|
-
throw new
|
5547
|
+
throw new InvalidToolInputError({
|
5543
5548
|
toolName,
|
5544
|
-
|
5549
|
+
toolInput: toolCall.input,
|
5545
5550
|
cause: parseResult.error
|
5546
5551
|
});
|
5547
5552
|
}
|
@@ -5549,7 +5554,7 @@ async function doParseToolCall({
|
|
5549
5554
|
type: "tool-call",
|
5550
5555
|
toolCallId: toolCall.toolCallId,
|
5551
5556
|
toolName,
|
5552
|
-
|
5557
|
+
input: parseResult.value
|
5553
5558
|
};
|
5554
5559
|
}
|
5555
5560
|
|
@@ -5652,15 +5657,15 @@ function toResponseMessages({
|
|
5652
5657
|
type: "tool-result",
|
5653
5658
|
toolCallId: toolResult.toolCallId,
|
5654
5659
|
toolName: toolResult.toolName,
|
5655
|
-
|
5660
|
+
output: tool2.experimental_toToolResultContent(toolResult.output),
|
5656
5661
|
experimental_content: tool2.experimental_toToolResultContent(
|
5657
|
-
toolResult.
|
5662
|
+
toolResult.output
|
5658
5663
|
)
|
5659
5664
|
} : {
|
5660
5665
|
type: "tool-result",
|
5661
5666
|
toolCallId: toolResult.toolCallId,
|
5662
5667
|
toolName: toolResult.toolName,
|
5663
|
-
|
5668
|
+
output: toolResult.output
|
5664
5669
|
};
|
5665
5670
|
});
|
5666
5671
|
if (toolResultContent.length > 0) {
|
@@ -5966,11 +5971,11 @@ async function executeTools({
|
|
5966
5971
|
abortSignal
|
5967
5972
|
}) {
|
5968
5973
|
const toolResults = await Promise.all(
|
5969
|
-
toolCalls.map(async ({ toolCallId, toolName,
|
5974
|
+
toolCalls.map(async ({ toolCallId, toolName, input }) => {
|
5970
5975
|
const tool2 = tools[toolName];
|
5971
|
-
if ((tool2 == null ? void 0 : tool2.
|
5972
|
-
await tool2.
|
5973
|
-
|
5976
|
+
if ((tool2 == null ? void 0 : tool2.onInputAvailable) != null) {
|
5977
|
+
await tool2.onInputAvailable({
|
5978
|
+
input,
|
5974
5979
|
toolCallId,
|
5975
5980
|
messages,
|
5976
5981
|
abortSignal
|
@@ -5990,15 +5995,15 @@ async function executeTools({
|
|
5990
5995
|
}),
|
5991
5996
|
"ai.toolCall.name": toolName,
|
5992
5997
|
"ai.toolCall.id": toolCallId,
|
5993
|
-
"ai.toolCall.
|
5994
|
-
output: () => JSON.stringify(
|
5998
|
+
"ai.toolCall.input": {
|
5999
|
+
output: () => JSON.stringify(input)
|
5995
6000
|
}
|
5996
6001
|
}
|
5997
6002
|
}),
|
5998
6003
|
tracer,
|
5999
6004
|
fn: async (span) => {
|
6000
6005
|
try {
|
6001
|
-
const result2 = await tool2.execute(
|
6006
|
+
const result2 = await tool2.execute(input, {
|
6002
6007
|
toolCallId,
|
6003
6008
|
messages,
|
6004
6009
|
abortSignal
|
@@ -6021,7 +6026,7 @@ async function executeTools({
|
|
6021
6026
|
throw new ToolExecutionError({
|
6022
6027
|
toolCallId,
|
6023
6028
|
toolName,
|
6024
|
-
|
6029
|
+
toolInput: input,
|
6025
6030
|
cause: error
|
6026
6031
|
});
|
6027
6032
|
}
|
@@ -6031,8 +6036,8 @@ async function executeTools({
|
|
6031
6036
|
type: "tool-result",
|
6032
6037
|
toolCallId,
|
6033
6038
|
toolName,
|
6034
|
-
|
6035
|
-
result
|
6039
|
+
input,
|
6040
|
+
output: result
|
6036
6041
|
};
|
6037
6042
|
})
|
6038
6043
|
);
|
@@ -6122,7 +6127,7 @@ function asToolCalls(content) {
|
|
6122
6127
|
toolCallType: toolCall.toolCallType,
|
6123
6128
|
toolCallId: toolCall.toolCallId,
|
6124
6129
|
toolName: toolCall.toolName,
|
6125
|
-
|
6130
|
+
input: toolCall.input
|
6126
6131
|
}));
|
6127
6132
|
}
|
6128
6133
|
|
@@ -6346,7 +6351,7 @@ function runToolsTransformation({
|
|
6346
6351
|
type: "tool-call-delta",
|
6347
6352
|
toolCallId: chunk.toolCallId,
|
6348
6353
|
toolName: chunk.toolName,
|
6349
|
-
|
6354
|
+
inputTextDelta: chunk.inputTextDelta
|
6350
6355
|
});
|
6351
6356
|
break;
|
6352
6357
|
}
|
@@ -6361,9 +6366,9 @@ function runToolsTransformation({
|
|
6361
6366
|
});
|
6362
6367
|
controller.enqueue(toolCall);
|
6363
6368
|
const tool2 = tools[toolCall.toolName];
|
6364
|
-
if (tool2.
|
6365
|
-
await tool2.
|
6366
|
-
|
6369
|
+
if (tool2.onInputAvailable != null) {
|
6370
|
+
await tool2.onInputAvailable({
|
6371
|
+
input: toolCall.input,
|
6367
6372
|
toolCallId: toolCall.toolCallId,
|
6368
6373
|
messages,
|
6369
6374
|
abortSignal
|
@@ -6383,22 +6388,22 @@ function runToolsTransformation({
|
|
6383
6388
|
}),
|
6384
6389
|
"ai.toolCall.name": toolCall.toolName,
|
6385
6390
|
"ai.toolCall.id": toolCall.toolCallId,
|
6386
|
-
"ai.toolCall.
|
6387
|
-
output: () => JSON.stringify(toolCall.
|
6391
|
+
"ai.toolCall.input": {
|
6392
|
+
output: () => JSON.stringify(toolCall.input)
|
6388
6393
|
}
|
6389
6394
|
}
|
6390
6395
|
}),
|
6391
6396
|
tracer,
|
6392
|
-
fn: async (span) => tool2.execute(toolCall.
|
6397
|
+
fn: async (span) => tool2.execute(toolCall.input, {
|
6393
6398
|
toolCallId: toolCall.toolCallId,
|
6394
6399
|
messages,
|
6395
6400
|
abortSignal
|
6396
6401
|
}).then(
|
6397
|
-
(
|
6402
|
+
(output) => {
|
6398
6403
|
toolResultsStreamController.enqueue({
|
6399
6404
|
...toolCall,
|
6400
6405
|
type: "tool-result",
|
6401
|
-
|
6406
|
+
output
|
6402
6407
|
});
|
6403
6408
|
outstandingToolResults.delete(toolExecutionId);
|
6404
6409
|
attemptClose();
|
@@ -6407,8 +6412,8 @@ function runToolsTransformation({
|
|
6407
6412
|
selectTelemetryAttributes({
|
6408
6413
|
telemetry,
|
6409
6414
|
attributes: {
|
6410
|
-
"ai.toolCall.
|
6411
|
-
output: () => JSON.stringify(
|
6415
|
+
"ai.toolCall.output": {
|
6416
|
+
output: () => JSON.stringify(output)
|
6412
6417
|
}
|
6413
6418
|
}
|
6414
6419
|
})
|
@@ -6422,7 +6427,7 @@ function runToolsTransformation({
|
|
6422
6427
|
error: new ToolExecutionError({
|
6423
6428
|
toolCallId: toolCall.toolCallId,
|
6424
6429
|
toolName: toolCall.toolName,
|
6425
|
-
|
6430
|
+
toolInput: toolCall.input,
|
6426
6431
|
cause: error
|
6427
6432
|
})
|
6428
6433
|
});
|
@@ -7074,8 +7079,8 @@ var DefaultStreamTextResult = class {
|
|
7074
7079
|
}
|
7075
7080
|
case "tool-call-streaming-start": {
|
7076
7081
|
const tool2 = tools == null ? void 0 : tools[chunk.toolName];
|
7077
|
-
if ((tool2 == null ? void 0 : tool2.
|
7078
|
-
await tool2.
|
7082
|
+
if ((tool2 == null ? void 0 : tool2.onInputStart) != null) {
|
7083
|
+
await tool2.onInputStart({
|
7079
7084
|
toolCallId: chunk.toolCallId,
|
7080
7085
|
messages: stepInputMessages,
|
7081
7086
|
abortSignal
|
@@ -7086,9 +7091,9 @@ var DefaultStreamTextResult = class {
|
|
7086
7091
|
}
|
7087
7092
|
case "tool-call-delta": {
|
7088
7093
|
const tool2 = tools == null ? void 0 : tools[chunk.toolName];
|
7089
|
-
if ((tool2 == null ? void 0 : tool2.
|
7090
|
-
await tool2.
|
7091
|
-
|
7094
|
+
if ((tool2 == null ? void 0 : tool2.onInputDelta) != null) {
|
7095
|
+
await tool2.onInputDelta({
|
7096
|
+
inputTextDelta: chunk.inputTextDelta,
|
7092
7097
|
toolCallId: chunk.toolCallId,
|
7093
7098
|
messages: stepInputMessages,
|
7094
7099
|
abortSignal
|
@@ -7403,7 +7408,7 @@ var DefaultStreamTextResult = class {
|
|
7403
7408
|
}
|
7404
7409
|
case "tool-call-streaming-start": {
|
7405
7410
|
controller.enqueue({
|
7406
|
-
type: "tool-
|
7411
|
+
type: "tool-input-start",
|
7407
7412
|
toolCallId: part.toolCallId,
|
7408
7413
|
toolName: part.toolName
|
7409
7414
|
});
|
@@ -7411,26 +7416,26 @@ var DefaultStreamTextResult = class {
|
|
7411
7416
|
}
|
7412
7417
|
case "tool-call-delta": {
|
7413
7418
|
controller.enqueue({
|
7414
|
-
type: "tool-
|
7419
|
+
type: "tool-input-delta",
|
7415
7420
|
toolCallId: part.toolCallId,
|
7416
|
-
|
7421
|
+
inputTextDelta: part.inputTextDelta
|
7417
7422
|
});
|
7418
7423
|
break;
|
7419
7424
|
}
|
7420
7425
|
case "tool-call": {
|
7421
7426
|
controller.enqueue({
|
7422
|
-
type: "tool-
|
7427
|
+
type: "tool-input-available",
|
7423
7428
|
toolCallId: part.toolCallId,
|
7424
7429
|
toolName: part.toolName,
|
7425
|
-
|
7430
|
+
input: part.input
|
7426
7431
|
});
|
7427
7432
|
break;
|
7428
7433
|
}
|
7429
7434
|
case "tool-result": {
|
7430
7435
|
controller.enqueue({
|
7431
|
-
type: "tool-
|
7436
|
+
type: "tool-output-available",
|
7432
7437
|
toolCallId: part.toolCallId,
|
7433
|
-
|
7438
|
+
output: part.output
|
7434
7439
|
});
|
7435
7440
|
break;
|
7436
7441
|
}
|
@@ -8437,15 +8442,14 @@ var MCPClient = class {
|
|
8437
8442
|
if (schemas !== "automatic" && !(name17 in schemas)) {
|
8438
8443
|
continue;
|
8439
8444
|
}
|
8440
|
-
const parameters = schemas === "automatic" ? (0, import_provider_utils25.jsonSchema)({
|
8441
|
-
...inputSchema,
|
8442
|
-
properties: (_a17 = inputSchema.properties) != null ? _a17 : {},
|
8443
|
-
additionalProperties: false
|
8444
|
-
}) : schemas[name17].parameters;
|
8445
8445
|
const self = this;
|
8446
8446
|
const toolWithExecute = tool({
|
8447
8447
|
description,
|
8448
|
-
|
8448
|
+
inputSchema: schemas === "automatic" ? (0, import_provider_utils25.jsonSchema)({
|
8449
|
+
...inputSchema,
|
8450
|
+
properties: (_a17 = inputSchema.properties) != null ? _a17 : {},
|
8451
|
+
additionalProperties: false
|
8452
|
+
}) : schemas[name17].inputSchema,
|
8449
8453
|
execute: async (args, options) => {
|
8450
8454
|
var _a18;
|
8451
8455
|
(_a18 = options == null ? void 0 : options.abortSignal) == null ? void 0 : _a18.throwIfAborted();
|
@@ -8578,7 +8582,7 @@ var DefaultTranscriptionResult = class {
|
|
8578
8582
|
InvalidPromptError,
|
8579
8583
|
InvalidResponseDataError,
|
8580
8584
|
InvalidStreamPartError,
|
8581
|
-
|
8585
|
+
InvalidToolInputError,
|
8582
8586
|
JSONParseError,
|
8583
8587
|
JsonToSseTransformStream,
|
8584
8588
|
LoadAPIKeyError,
|