ai 5.0.0-beta.27 → 5.0.0-beta.29
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 +20 -0
- package/dist/bin/ai.min.js +25 -25
- package/dist/index.d.mts +66 -6
- package/dist/index.d.ts +66 -6
- package/dist/index.js +249 -126
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +234 -108
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.js +3 -1
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +3 -1
- package/dist/internal/index.mjs.map +1 -1
- package/dist/mcp-stdio/index.js.map +1 -1
- package/dist/mcp-stdio/index.mjs.map +1 -1
- package/package.json +3 -3
package/dist/index.mjs
CHANGED
@@ -8,8 +8,10 @@ var __export = (target, all) => {
|
|
8
8
|
import {
|
9
9
|
asSchema as asSchema5,
|
10
10
|
createIdGenerator as createIdGenerator5,
|
11
|
+
dynamicTool as dynamicTool2,
|
11
12
|
generateId as generateId2,
|
12
|
-
jsonSchema as jsonSchema2
|
13
|
+
jsonSchema as jsonSchema2,
|
14
|
+
tool as tool2
|
13
15
|
} from "@ai-sdk/provider-utils";
|
14
16
|
|
15
17
|
// src/generate-text/generate-text.ts
|
@@ -874,12 +876,14 @@ function prepareToolsAndToolChoice({
|
|
874
876
|
const toolType = tool3.type;
|
875
877
|
switch (toolType) {
|
876
878
|
case void 0:
|
879
|
+
case "dynamic":
|
877
880
|
case "function":
|
878
881
|
return {
|
879
882
|
type: "function",
|
880
883
|
name: name16,
|
881
884
|
description: tool3.description,
|
882
|
-
inputSchema: asSchema(tool3.inputSchema).jsonSchema
|
885
|
+
inputSchema: asSchema(tool3.inputSchema).jsonSchema,
|
886
|
+
providerOptions: tool3.providerOptions
|
883
887
|
};
|
884
888
|
case "provider-defined":
|
885
889
|
return {
|
@@ -1702,7 +1706,15 @@ async function doParseToolCall({
|
|
1702
1706
|
cause: parseResult.error
|
1703
1707
|
});
|
1704
1708
|
}
|
1705
|
-
return {
|
1709
|
+
return tool3.type === "dynamic" ? {
|
1710
|
+
type: "tool-call",
|
1711
|
+
toolCallId: toolCall.toolCallId,
|
1712
|
+
toolName: toolCall.toolName,
|
1713
|
+
input: parseResult.value,
|
1714
|
+
providerExecuted: toolCall.providerExecuted,
|
1715
|
+
providerMetadata: toolCall.providerMetadata,
|
1716
|
+
dynamic: true
|
1717
|
+
} : {
|
1706
1718
|
type: "tool-call",
|
1707
1719
|
toolCallId: toolCall.toolCallId,
|
1708
1720
|
toolName,
|
@@ -2245,7 +2257,8 @@ async function executeTools({
|
|
2245
2257
|
toolCallId,
|
2246
2258
|
toolName,
|
2247
2259
|
input,
|
2248
|
-
output: result
|
2260
|
+
output: result,
|
2261
|
+
dynamic: tool3.type === "dynamic"
|
2249
2262
|
};
|
2250
2263
|
} catch (error) {
|
2251
2264
|
recordErrorOnSpan(span, error);
|
@@ -2254,7 +2267,8 @@ async function executeTools({
|
|
2254
2267
|
toolCallId,
|
2255
2268
|
toolName,
|
2256
2269
|
input,
|
2257
|
-
error
|
2270
|
+
error,
|
2271
|
+
dynamic: tool3.type === "dynamic"
|
2258
2272
|
};
|
2259
2273
|
}
|
2260
2274
|
}
|
@@ -2386,7 +2400,8 @@ function asContent({
|
|
2386
2400
|
toolName: part.toolName,
|
2387
2401
|
input: toolCall.input,
|
2388
2402
|
error: part.result,
|
2389
|
-
providerExecuted: true
|
2403
|
+
providerExecuted: true,
|
2404
|
+
dynamic: toolCall.dynamic
|
2390
2405
|
};
|
2391
2406
|
}
|
2392
2407
|
return {
|
@@ -2395,7 +2410,8 @@ function asContent({
|
|
2395
2410
|
toolName: part.toolName,
|
2396
2411
|
input: toolCall.input,
|
2397
2412
|
output: part.result,
|
2398
|
-
providerExecuted: true
|
2413
|
+
providerExecuted: true,
|
2414
|
+
dynamic: toolCall.dynamic
|
2399
2415
|
};
|
2400
2416
|
}
|
2401
2417
|
}
|
@@ -2579,7 +2595,8 @@ var uiMessageChunkSchema = z7.union([
|
|
2579
2595
|
type: z7.literal("tool-input-start"),
|
2580
2596
|
toolCallId: z7.string(),
|
2581
2597
|
toolName: z7.string(),
|
2582
|
-
providerExecuted: z7.boolean().optional()
|
2598
|
+
providerExecuted: z7.boolean().optional(),
|
2599
|
+
dynamic: z7.boolean().optional()
|
2583
2600
|
}),
|
2584
2601
|
z7.strictObject({
|
2585
2602
|
type: z7.literal("tool-input-delta"),
|
@@ -2592,19 +2609,22 @@ var uiMessageChunkSchema = z7.union([
|
|
2592
2609
|
toolName: z7.string(),
|
2593
2610
|
input: z7.unknown(),
|
2594
2611
|
providerExecuted: z7.boolean().optional(),
|
2595
|
-
providerMetadata: providerMetadataSchema.optional()
|
2612
|
+
providerMetadata: providerMetadataSchema.optional(),
|
2613
|
+
dynamic: z7.boolean().optional()
|
2596
2614
|
}),
|
2597
2615
|
z7.strictObject({
|
2598
2616
|
type: z7.literal("tool-output-available"),
|
2599
2617
|
toolCallId: z7.string(),
|
2600
2618
|
output: z7.unknown(),
|
2601
|
-
providerExecuted: z7.boolean().optional()
|
2619
|
+
providerExecuted: z7.boolean().optional(),
|
2620
|
+
dynamic: z7.boolean().optional()
|
2602
2621
|
}),
|
2603
2622
|
z7.strictObject({
|
2604
2623
|
type: z7.literal("tool-output-error"),
|
2605
2624
|
toolCallId: z7.string(),
|
2606
2625
|
errorText: z7.string(),
|
2607
|
-
providerExecuted: z7.boolean().optional()
|
2626
|
+
providerExecuted: z7.boolean().optional(),
|
2627
|
+
dynamic: z7.boolean().optional()
|
2608
2628
|
}),
|
2609
2629
|
z7.strictObject({
|
2610
2630
|
type: z7.literal("reasoning"),
|
@@ -3093,7 +3113,33 @@ function processUIMessageStream({
|
|
3093
3113
|
async transform(chunk, controller) {
|
3094
3114
|
await runUpdateMessageJob(async ({ state, write }) => {
|
3095
3115
|
var _a16, _b, _c, _d;
|
3096
|
-
function
|
3116
|
+
function getToolInvocation(toolCallId) {
|
3117
|
+
const toolInvocations = state.message.parts.filter(isToolUIPart);
|
3118
|
+
const toolInvocation = toolInvocations.find(
|
3119
|
+
(invocation) => invocation.toolCallId === toolCallId
|
3120
|
+
);
|
3121
|
+
if (toolInvocation == null) {
|
3122
|
+
throw new Error(
|
3123
|
+
"tool-output-error must be preceded by a tool-input-available"
|
3124
|
+
);
|
3125
|
+
}
|
3126
|
+
return toolInvocation;
|
3127
|
+
}
|
3128
|
+
function getDynamicToolInvocation(toolCallId) {
|
3129
|
+
const toolInvocations = state.message.parts.filter(
|
3130
|
+
(part) => part.type === "dynamic-tool"
|
3131
|
+
);
|
3132
|
+
const toolInvocation = toolInvocations.find(
|
3133
|
+
(invocation) => invocation.toolCallId === toolCallId
|
3134
|
+
);
|
3135
|
+
if (toolInvocation == null) {
|
3136
|
+
throw new Error(
|
3137
|
+
"tool-output-error must be preceded by a tool-input-available"
|
3138
|
+
);
|
3139
|
+
}
|
3140
|
+
return toolInvocation;
|
3141
|
+
}
|
3142
|
+
function updateToolPart(options) {
|
3097
3143
|
var _a17;
|
3098
3144
|
const part = state.message.parts.find(
|
3099
3145
|
(part2) => isToolUIPart(part2) && part2.toolCallId === options.toolCallId
|
@@ -3122,6 +3168,34 @@ function processUIMessageStream({
|
|
3122
3168
|
});
|
3123
3169
|
}
|
3124
3170
|
}
|
3171
|
+
function updateDynamicToolPart(options) {
|
3172
|
+
const part = state.message.parts.find(
|
3173
|
+
(part2) => part2.type === "dynamic-tool" && part2.toolCallId === options.toolCallId
|
3174
|
+
);
|
3175
|
+
const anyOptions = options;
|
3176
|
+
const anyPart = part;
|
3177
|
+
if (part != null) {
|
3178
|
+
part.state = options.state;
|
3179
|
+
anyPart.toolName = options.toolName;
|
3180
|
+
anyPart.input = anyOptions.input;
|
3181
|
+
anyPart.output = anyOptions.output;
|
3182
|
+
anyPart.errorText = anyOptions.errorText;
|
3183
|
+
if (anyOptions.providerMetadata != null && part.state === "input-available") {
|
3184
|
+
part.callProviderMetadata = anyOptions.providerMetadata;
|
3185
|
+
}
|
3186
|
+
} else {
|
3187
|
+
state.message.parts.push({
|
3188
|
+
type: "dynamic-tool",
|
3189
|
+
toolName: options.toolName,
|
3190
|
+
toolCallId: options.toolCallId,
|
3191
|
+
state: options.state,
|
3192
|
+
input: anyOptions.input,
|
3193
|
+
output: anyOptions.output,
|
3194
|
+
errorText: anyOptions.errorText,
|
3195
|
+
...anyOptions.providerMetadata != null ? { callProviderMetadata: anyOptions.providerMetadata } : {}
|
3196
|
+
});
|
3197
|
+
}
|
3198
|
+
}
|
3125
3199
|
async function updateMessageMetadata(metadata) {
|
3126
3200
|
if (metadata != null) {
|
3127
3201
|
const mergedMetadata = state.message.metadata != null ? mergeObjects(state.message.metadata, metadata) : metadata;
|
@@ -3226,15 +3300,25 @@ function processUIMessageStream({
|
|
3226
3300
|
state.partialToolCalls[chunk.toolCallId] = {
|
3227
3301
|
text: "",
|
3228
3302
|
toolName: chunk.toolName,
|
3229
|
-
index: toolInvocations.length
|
3303
|
+
index: toolInvocations.length,
|
3304
|
+
dynamic: chunk.dynamic
|
3230
3305
|
};
|
3231
|
-
|
3232
|
-
|
3233
|
-
|
3234
|
-
|
3235
|
-
|
3236
|
-
|
3237
|
-
|
3306
|
+
if (chunk.dynamic) {
|
3307
|
+
updateDynamicToolPart({
|
3308
|
+
toolCallId: chunk.toolCallId,
|
3309
|
+
toolName: chunk.toolName,
|
3310
|
+
state: "input-streaming",
|
3311
|
+
input: void 0
|
3312
|
+
});
|
3313
|
+
} else {
|
3314
|
+
updateToolPart({
|
3315
|
+
toolCallId: chunk.toolCallId,
|
3316
|
+
toolName: chunk.toolName,
|
3317
|
+
state: "input-streaming",
|
3318
|
+
input: void 0,
|
3319
|
+
providerExecuted: chunk.providerExecuted
|
3320
|
+
});
|
3321
|
+
}
|
3238
3322
|
write();
|
3239
3323
|
break;
|
3240
3324
|
}
|
@@ -3244,26 +3328,45 @@ function processUIMessageStream({
|
|
3244
3328
|
const { value: partialArgs } = await parsePartialJson(
|
3245
3329
|
partialToolCall.text
|
3246
3330
|
);
|
3247
|
-
|
3248
|
-
|
3249
|
-
|
3250
|
-
|
3251
|
-
|
3252
|
-
|
3331
|
+
if (partialToolCall.dynamic) {
|
3332
|
+
updateDynamicToolPart({
|
3333
|
+
toolCallId: chunk.toolCallId,
|
3334
|
+
toolName: partialToolCall.toolName,
|
3335
|
+
state: "input-streaming",
|
3336
|
+
input: partialArgs
|
3337
|
+
});
|
3338
|
+
} else {
|
3339
|
+
updateToolPart({
|
3340
|
+
toolCallId: chunk.toolCallId,
|
3341
|
+
toolName: partialToolCall.toolName,
|
3342
|
+
state: "input-streaming",
|
3343
|
+
input: partialArgs
|
3344
|
+
});
|
3345
|
+
}
|
3253
3346
|
write();
|
3254
3347
|
break;
|
3255
3348
|
}
|
3256
3349
|
case "tool-input-available": {
|
3257
|
-
|
3258
|
-
|
3259
|
-
|
3260
|
-
|
3261
|
-
|
3262
|
-
|
3263
|
-
|
3264
|
-
|
3350
|
+
if (chunk.dynamic) {
|
3351
|
+
updateDynamicToolPart({
|
3352
|
+
toolCallId: chunk.toolCallId,
|
3353
|
+
toolName: chunk.toolName,
|
3354
|
+
state: "input-available",
|
3355
|
+
input: chunk.input,
|
3356
|
+
providerMetadata: chunk.providerMetadata
|
3357
|
+
});
|
3358
|
+
} else {
|
3359
|
+
updateToolPart({
|
3360
|
+
toolCallId: chunk.toolCallId,
|
3361
|
+
toolName: chunk.toolName,
|
3362
|
+
state: "input-available",
|
3363
|
+
input: chunk.input,
|
3364
|
+
providerExecuted: chunk.providerExecuted,
|
3365
|
+
providerMetadata: chunk.providerMetadata
|
3366
|
+
});
|
3367
|
+
}
|
3265
3368
|
write();
|
3266
|
-
if (onToolCall && !chunk.providerExecuted) {
|
3369
|
+
if (onToolCall && !chunk.providerExecuted && !chunk.dynamic) {
|
3267
3370
|
await onToolCall({
|
3268
3371
|
toolCall: chunk
|
3269
3372
|
});
|
@@ -3271,56 +3374,53 @@ function processUIMessageStream({
|
|
3271
3374
|
break;
|
3272
3375
|
}
|
3273
3376
|
case "tool-output-available": {
|
3274
|
-
|
3275
|
-
|
3276
|
-
|
3277
|
-
}
|
3278
|
-
const toolInvocationIndex = toolInvocations.findIndex(
|
3279
|
-
(invocation) => invocation.toolCallId === chunk.toolCallId
|
3280
|
-
);
|
3281
|
-
if (toolInvocationIndex === -1) {
|
3282
|
-
throw new Error(
|
3283
|
-
"tool_result must be preceded by a tool_call with the same toolCallId"
|
3377
|
+
if (chunk.dynamic) {
|
3378
|
+
const toolInvocation = getDynamicToolInvocation(
|
3379
|
+
chunk.toolCallId
|
3284
3380
|
);
|
3381
|
+
updateDynamicToolPart({
|
3382
|
+
toolCallId: chunk.toolCallId,
|
3383
|
+
toolName: toolInvocation.toolName,
|
3384
|
+
state: "output-available",
|
3385
|
+
input: toolInvocation.input,
|
3386
|
+
output: chunk.output
|
3387
|
+
});
|
3388
|
+
} else {
|
3389
|
+
const toolInvocation = getToolInvocation(chunk.toolCallId);
|
3390
|
+
updateToolPart({
|
3391
|
+
toolCallId: chunk.toolCallId,
|
3392
|
+
toolName: getToolName(toolInvocation),
|
3393
|
+
state: "output-available",
|
3394
|
+
input: toolInvocation.input,
|
3395
|
+
output: chunk.output,
|
3396
|
+
providerExecuted: chunk.providerExecuted
|
3397
|
+
});
|
3285
3398
|
}
|
3286
|
-
const toolName = getToolName(
|
3287
|
-
toolInvocations[toolInvocationIndex]
|
3288
|
-
);
|
3289
|
-
updateToolInvocationPart({
|
3290
|
-
toolCallId: chunk.toolCallId,
|
3291
|
-
toolName,
|
3292
|
-
state: "output-available",
|
3293
|
-
input: toolInvocations[toolInvocationIndex].input,
|
3294
|
-
output: chunk.output,
|
3295
|
-
providerExecuted: chunk.providerExecuted
|
3296
|
-
});
|
3297
3399
|
write();
|
3298
3400
|
break;
|
3299
3401
|
}
|
3300
3402
|
case "tool-output-error": {
|
3301
|
-
|
3302
|
-
|
3303
|
-
|
3304
|
-
}
|
3305
|
-
const toolInvocationIndex = toolInvocations.findIndex(
|
3306
|
-
(invocation) => invocation.toolCallId === chunk.toolCallId
|
3307
|
-
);
|
3308
|
-
if (toolInvocationIndex === -1) {
|
3309
|
-
throw new Error(
|
3310
|
-
"tool_result must be preceded by a tool_call with the same toolCallId"
|
3403
|
+
if (chunk.dynamic) {
|
3404
|
+
const toolInvocation = getDynamicToolInvocation(
|
3405
|
+
chunk.toolCallId
|
3311
3406
|
);
|
3407
|
+
updateDynamicToolPart({
|
3408
|
+
toolCallId: chunk.toolCallId,
|
3409
|
+
toolName: toolInvocation.toolName,
|
3410
|
+
state: "output-error",
|
3411
|
+
input: toolInvocation.input,
|
3412
|
+
errorText: chunk.errorText
|
3413
|
+
});
|
3414
|
+
} else {
|
3415
|
+
const toolInvocation = getToolInvocation(chunk.toolCallId);
|
3416
|
+
updateToolPart({
|
3417
|
+
toolCallId: chunk.toolCallId,
|
3418
|
+
toolName: getToolName(toolInvocation),
|
3419
|
+
state: "output-error",
|
3420
|
+
input: toolInvocation.input,
|
3421
|
+
errorText: chunk.errorText
|
3422
|
+
});
|
3312
3423
|
}
|
3313
|
-
const toolName = getToolName(
|
3314
|
-
toolInvocations[toolInvocationIndex]
|
3315
|
-
);
|
3316
|
-
updateToolInvocationPart({
|
3317
|
-
toolCallId: chunk.toolCallId,
|
3318
|
-
toolName,
|
3319
|
-
state: "output-error",
|
3320
|
-
input: toolInvocations[toolInvocationIndex].input,
|
3321
|
-
errorText: chunk.errorText,
|
3322
|
-
providerExecuted: chunk.providerExecuted
|
3323
|
-
});
|
3324
3424
|
write();
|
3325
3425
|
break;
|
3326
3426
|
}
|
@@ -4571,7 +4671,10 @@ var DefaultStreamTextResult = class {
|
|
4571
4671
|
abortSignal
|
4572
4672
|
});
|
4573
4673
|
}
|
4574
|
-
controller.enqueue(
|
4674
|
+
controller.enqueue({
|
4675
|
+
...chunk,
|
4676
|
+
dynamic: (tool3 == null ? void 0 : tool3.type) === "dynamic"
|
4677
|
+
});
|
4575
4678
|
break;
|
4576
4679
|
}
|
4577
4680
|
case "tool-input-end": {
|
@@ -4951,7 +5054,8 @@ var DefaultStreamTextResult = class {
|
|
4951
5054
|
type: "tool-input-start",
|
4952
5055
|
toolCallId: part.id,
|
4953
5056
|
toolName: part.toolName,
|
4954
|
-
providerExecuted: part.providerExecuted
|
5057
|
+
...part.providerExecuted != null ? { providerExecuted: part.providerExecuted } : {},
|
5058
|
+
...part.dynamic != null ? { dynamic: part.dynamic } : {}
|
4955
5059
|
});
|
4956
5060
|
break;
|
4957
5061
|
}
|
@@ -4969,8 +5073,9 @@ var DefaultStreamTextResult = class {
|
|
4969
5073
|
toolCallId: part.toolCallId,
|
4970
5074
|
toolName: part.toolName,
|
4971
5075
|
input: part.input,
|
4972
|
-
providerExecuted: part.providerExecuted,
|
4973
|
-
providerMetadata: part.providerMetadata
|
5076
|
+
...part.providerExecuted != null ? { providerExecuted: part.providerExecuted } : {},
|
5077
|
+
...part.providerMetadata != null ? { providerMetadata: part.providerMetadata } : {},
|
5078
|
+
...part.dynamic != null ? { dynamic: part.dynamic } : {}
|
4974
5079
|
});
|
4975
5080
|
break;
|
4976
5081
|
}
|
@@ -4979,7 +5084,8 @@ var DefaultStreamTextResult = class {
|
|
4979
5084
|
type: "tool-output-available",
|
4980
5085
|
toolCallId: part.toolCallId,
|
4981
5086
|
output: part.output,
|
4982
|
-
providerExecuted: part.providerExecuted
|
5087
|
+
...part.providerExecuted != null ? { providerExecuted: part.providerExecuted } : {},
|
5088
|
+
...part.dynamic != null ? { dynamic: part.dynamic } : {}
|
4983
5089
|
});
|
4984
5090
|
break;
|
4985
5091
|
}
|
@@ -4988,7 +5094,8 @@ var DefaultStreamTextResult = class {
|
|
4988
5094
|
type: "tool-output-error",
|
4989
5095
|
toolCallId: part.toolCallId,
|
4990
5096
|
errorText: onError(part.error),
|
4991
|
-
providerExecuted: part.providerExecuted
|
5097
|
+
...part.providerExecuted != null ? { providerExecuted: part.providerExecuted } : {},
|
5098
|
+
...part.dynamic != null ? { dynamic: part.dynamic } : {}
|
4992
5099
|
});
|
4993
5100
|
break;
|
4994
5101
|
}
|
@@ -7686,8 +7793,11 @@ var DefaultProviderRegistry = class {
|
|
7686
7793
|
};
|
7687
7794
|
|
7688
7795
|
// src/tool/mcp/mcp-client.ts
|
7689
|
-
import {
|
7690
|
-
|
7796
|
+
import {
|
7797
|
+
dynamicTool,
|
7798
|
+
jsonSchema,
|
7799
|
+
tool
|
7800
|
+
} from "@ai-sdk/provider-utils";
|
7691
7801
|
|
7692
7802
|
// src/tool/mcp/mcp-sse-transport.ts
|
7693
7803
|
import { EventSourceParserStream } from "@ai-sdk/provider-utils";
|
@@ -7697,9 +7807,10 @@ import { z as z9 } from "zod/v4";
|
|
7697
7807
|
|
7698
7808
|
// src/tool/mcp/types.ts
|
7699
7809
|
import { z as z8 } from "zod/v4";
|
7700
|
-
var LATEST_PROTOCOL_VERSION = "2025-
|
7810
|
+
var LATEST_PROTOCOL_VERSION = "2025-06-18";
|
7701
7811
|
var SUPPORTED_PROTOCOL_VERSIONS = [
|
7702
7812
|
LATEST_PROTOCOL_VERSION,
|
7813
|
+
"2025-03-26",
|
7703
7814
|
"2024-11-05"
|
7704
7815
|
];
|
7705
7816
|
var ClientOrServerImplementationSchema = z8.object({
|
@@ -8186,22 +8297,23 @@ var MCPClient = class {
|
|
8186
8297
|
continue;
|
8187
8298
|
}
|
8188
8299
|
const self = this;
|
8189
|
-
const
|
8300
|
+
const execute = async (args, options) => {
|
8301
|
+
var _a17;
|
8302
|
+
(_a17 = options == null ? void 0 : options.abortSignal) == null ? void 0 : _a17.throwIfAborted();
|
8303
|
+
return self.callTool({ name: name16, args, options });
|
8304
|
+
};
|
8305
|
+
const toolWithExecute = schemas === "automatic" ? dynamicTool({
|
8190
8306
|
description,
|
8191
|
-
inputSchema:
|
8307
|
+
inputSchema: jsonSchema({
|
8192
8308
|
...inputSchema,
|
8193
8309
|
properties: (_a16 = inputSchema.properties) != null ? _a16 : {},
|
8194
8310
|
additionalProperties: false
|
8195
|
-
})
|
8196
|
-
execute
|
8197
|
-
|
8198
|
-
|
8199
|
-
|
8200
|
-
|
8201
|
-
args,
|
8202
|
-
options
|
8203
|
-
});
|
8204
|
-
}
|
8311
|
+
}),
|
8312
|
+
execute
|
8313
|
+
}) : tool({
|
8314
|
+
description,
|
8315
|
+
inputSchema: schemas[name16].inputSchema,
|
8316
|
+
execute
|
8205
8317
|
});
|
8206
8318
|
tools[name16] = toolWithExecute;
|
8207
8319
|
}
|
@@ -8247,11 +8359,6 @@ var MCPClient = class {
|
|
8247
8359
|
}
|
8248
8360
|
};
|
8249
8361
|
|
8250
|
-
// src/tool/index.ts
|
8251
|
-
import {
|
8252
|
-
tool as tool2
|
8253
|
-
} from "@ai-sdk/provider-utils";
|
8254
|
-
|
8255
8362
|
// src/error/no-transcript-generated-error.ts
|
8256
8363
|
import { AISDKError as AISDKError21 } from "@ai-sdk/provider";
|
8257
8364
|
var NoTranscriptGeneratedError = class extends AISDKError21 {
|
@@ -8752,8 +8859,8 @@ var AbstractChat = class {
|
|
8752
8859
|
} : part
|
8753
8860
|
);
|
8754
8861
|
}
|
8755
|
-
if (this.status !== "streaming" && this.status !== "submitted" && ((_a16 = this.sendAutomaticallyWhen) == null ? void 0 : _a16.call(this, { messages }))) {
|
8756
|
-
|
8862
|
+
if (this.status !== "streaming" && this.status !== "submitted" && ((_a16 = this.sendAutomaticallyWhen) == null ? void 0 : _a16.call(this, { messages: this.state.messages }))) {
|
8863
|
+
this.makeRequest({
|
8757
8864
|
trigger: "submit-message",
|
8758
8865
|
messageId: (_b = this.lastMessage) == null ? void 0 : _b.id
|
8759
8866
|
});
|
@@ -8993,6 +9100,22 @@ function convertToModelMessages(messages, options) {
|
|
8993
9100
|
text: part.text,
|
8994
9101
|
providerOptions: part.providerMetadata
|
8995
9102
|
});
|
9103
|
+
} else if (part.type === "dynamic-tool") {
|
9104
|
+
const toolName = part.toolName;
|
9105
|
+
if (part.state === "input-streaming") {
|
9106
|
+
throw new MessageConversionError({
|
9107
|
+
originalMessage: message,
|
9108
|
+
message: `incomplete tool input is not supported: ${part.toolCallId}`
|
9109
|
+
});
|
9110
|
+
} else {
|
9111
|
+
content.push({
|
9112
|
+
type: "tool-call",
|
9113
|
+
toolCallId: part.toolCallId,
|
9114
|
+
toolName,
|
9115
|
+
input: part.input,
|
9116
|
+
...part.callProviderMetadata != null ? { providerOptions: part.callProviderMetadata } : {}
|
9117
|
+
});
|
9118
|
+
}
|
8996
9119
|
} else if (isToolUIPart(part)) {
|
8997
9120
|
const toolName = getToolName(part);
|
8998
9121
|
if (part.state === "input-streaming") {
|
@@ -9031,7 +9154,9 @@ function convertToModelMessages(messages, options) {
|
|
9031
9154
|
role: "assistant",
|
9032
9155
|
content
|
9033
9156
|
});
|
9034
|
-
const toolParts = block.filter(
|
9157
|
+
const toolParts = block.filter(
|
9158
|
+
(part) => isToolUIPart(part) && part.providerExecuted !== true || part.type === "dynamic-tool"
|
9159
|
+
);
|
9035
9160
|
if (toolParts.length > 0) {
|
9036
9161
|
modelMessages.push({
|
9037
9162
|
role: "tool",
|
@@ -9040,7 +9165,7 @@ function convertToModelMessages(messages, options) {
|
|
9040
9165
|
switch (toolPart.state) {
|
9041
9166
|
case "output-error":
|
9042
9167
|
case "output-available": {
|
9043
|
-
const toolName = getToolName(toolPart);
|
9168
|
+
const toolName = toolPart.type === "dynamic-tool" ? toolPart.toolName : getToolName(toolPart);
|
9044
9169
|
return {
|
9045
9170
|
type: "tool-result",
|
9046
9171
|
toolCallId: toolPart.toolCallId,
|
@@ -9067,7 +9192,7 @@ function convertToModelMessages(messages, options) {
|
|
9067
9192
|
var processBlock = processBlock2;
|
9068
9193
|
let block = [];
|
9069
9194
|
for (const part of message.parts) {
|
9070
|
-
if (part.type === "text" || part.type === "reasoning" || part.type === "file" || isToolUIPart(part)) {
|
9195
|
+
if (part.type === "text" || part.type === "reasoning" || part.type === "file" || part.type === "dynamic-tool" || isToolUIPart(part)) {
|
9071
9196
|
block.push(part);
|
9072
9197
|
} else if (part.type === "step-start") {
|
9073
9198
|
processBlock2();
|
@@ -9337,6 +9462,7 @@ export {
|
|
9337
9462
|
createUIMessageStreamResponse,
|
9338
9463
|
customProvider,
|
9339
9464
|
defaultSettingsMiddleware,
|
9465
|
+
dynamicTool2 as dynamicTool,
|
9340
9466
|
embed,
|
9341
9467
|
embedMany,
|
9342
9468
|
createMCPClient as experimental_createMCPClient,
|