ai 5.0.0-beta.28 → 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 +10 -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 +245 -123
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +230 -105
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.js +1 -0
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +1 -0
- 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,6 +876,7 @@ 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",
|
@@ -1703,7 +1706,15 @@ async function doParseToolCall({
|
|
1703
1706
|
cause: parseResult.error
|
1704
1707
|
});
|
1705
1708
|
}
|
1706
|
-
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
|
+
} : {
|
1707
1718
|
type: "tool-call",
|
1708
1719
|
toolCallId: toolCall.toolCallId,
|
1709
1720
|
toolName,
|
@@ -2246,7 +2257,8 @@ async function executeTools({
|
|
2246
2257
|
toolCallId,
|
2247
2258
|
toolName,
|
2248
2259
|
input,
|
2249
|
-
output: result
|
2260
|
+
output: result,
|
2261
|
+
dynamic: tool3.type === "dynamic"
|
2250
2262
|
};
|
2251
2263
|
} catch (error) {
|
2252
2264
|
recordErrorOnSpan(span, error);
|
@@ -2255,7 +2267,8 @@ async function executeTools({
|
|
2255
2267
|
toolCallId,
|
2256
2268
|
toolName,
|
2257
2269
|
input,
|
2258
|
-
error
|
2270
|
+
error,
|
2271
|
+
dynamic: tool3.type === "dynamic"
|
2259
2272
|
};
|
2260
2273
|
}
|
2261
2274
|
}
|
@@ -2387,7 +2400,8 @@ function asContent({
|
|
2387
2400
|
toolName: part.toolName,
|
2388
2401
|
input: toolCall.input,
|
2389
2402
|
error: part.result,
|
2390
|
-
providerExecuted: true
|
2403
|
+
providerExecuted: true,
|
2404
|
+
dynamic: toolCall.dynamic
|
2391
2405
|
};
|
2392
2406
|
}
|
2393
2407
|
return {
|
@@ -2396,7 +2410,8 @@ function asContent({
|
|
2396
2410
|
toolName: part.toolName,
|
2397
2411
|
input: toolCall.input,
|
2398
2412
|
output: part.result,
|
2399
|
-
providerExecuted: true
|
2413
|
+
providerExecuted: true,
|
2414
|
+
dynamic: toolCall.dynamic
|
2400
2415
|
};
|
2401
2416
|
}
|
2402
2417
|
}
|
@@ -2580,7 +2595,8 @@ var uiMessageChunkSchema = z7.union([
|
|
2580
2595
|
type: z7.literal("tool-input-start"),
|
2581
2596
|
toolCallId: z7.string(),
|
2582
2597
|
toolName: z7.string(),
|
2583
|
-
providerExecuted: z7.boolean().optional()
|
2598
|
+
providerExecuted: z7.boolean().optional(),
|
2599
|
+
dynamic: z7.boolean().optional()
|
2584
2600
|
}),
|
2585
2601
|
z7.strictObject({
|
2586
2602
|
type: z7.literal("tool-input-delta"),
|
@@ -2593,19 +2609,22 @@ var uiMessageChunkSchema = z7.union([
|
|
2593
2609
|
toolName: z7.string(),
|
2594
2610
|
input: z7.unknown(),
|
2595
2611
|
providerExecuted: z7.boolean().optional(),
|
2596
|
-
providerMetadata: providerMetadataSchema.optional()
|
2612
|
+
providerMetadata: providerMetadataSchema.optional(),
|
2613
|
+
dynamic: z7.boolean().optional()
|
2597
2614
|
}),
|
2598
2615
|
z7.strictObject({
|
2599
2616
|
type: z7.literal("tool-output-available"),
|
2600
2617
|
toolCallId: z7.string(),
|
2601
2618
|
output: z7.unknown(),
|
2602
|
-
providerExecuted: z7.boolean().optional()
|
2619
|
+
providerExecuted: z7.boolean().optional(),
|
2620
|
+
dynamic: z7.boolean().optional()
|
2603
2621
|
}),
|
2604
2622
|
z7.strictObject({
|
2605
2623
|
type: z7.literal("tool-output-error"),
|
2606
2624
|
toolCallId: z7.string(),
|
2607
2625
|
errorText: z7.string(),
|
2608
|
-
providerExecuted: z7.boolean().optional()
|
2626
|
+
providerExecuted: z7.boolean().optional(),
|
2627
|
+
dynamic: z7.boolean().optional()
|
2609
2628
|
}),
|
2610
2629
|
z7.strictObject({
|
2611
2630
|
type: z7.literal("reasoning"),
|
@@ -3094,7 +3113,33 @@ function processUIMessageStream({
|
|
3094
3113
|
async transform(chunk, controller) {
|
3095
3114
|
await runUpdateMessageJob(async ({ state, write }) => {
|
3096
3115
|
var _a16, _b, _c, _d;
|
3097
|
-
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) {
|
3098
3143
|
var _a17;
|
3099
3144
|
const part = state.message.parts.find(
|
3100
3145
|
(part2) => isToolUIPart(part2) && part2.toolCallId === options.toolCallId
|
@@ -3123,6 +3168,34 @@ function processUIMessageStream({
|
|
3123
3168
|
});
|
3124
3169
|
}
|
3125
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
|
+
}
|
3126
3199
|
async function updateMessageMetadata(metadata) {
|
3127
3200
|
if (metadata != null) {
|
3128
3201
|
const mergedMetadata = state.message.metadata != null ? mergeObjects(state.message.metadata, metadata) : metadata;
|
@@ -3227,15 +3300,25 @@ function processUIMessageStream({
|
|
3227
3300
|
state.partialToolCalls[chunk.toolCallId] = {
|
3228
3301
|
text: "",
|
3229
3302
|
toolName: chunk.toolName,
|
3230
|
-
index: toolInvocations.length
|
3303
|
+
index: toolInvocations.length,
|
3304
|
+
dynamic: chunk.dynamic
|
3231
3305
|
};
|
3232
|
-
|
3233
|
-
|
3234
|
-
|
3235
|
-
|
3236
|
-
|
3237
|
-
|
3238
|
-
|
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
|
+
}
|
3239
3322
|
write();
|
3240
3323
|
break;
|
3241
3324
|
}
|
@@ -3245,26 +3328,45 @@ function processUIMessageStream({
|
|
3245
3328
|
const { value: partialArgs } = await parsePartialJson(
|
3246
3329
|
partialToolCall.text
|
3247
3330
|
);
|
3248
|
-
|
3249
|
-
|
3250
|
-
|
3251
|
-
|
3252
|
-
|
3253
|
-
|
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
|
+
}
|
3254
3346
|
write();
|
3255
3347
|
break;
|
3256
3348
|
}
|
3257
3349
|
case "tool-input-available": {
|
3258
|
-
|
3259
|
-
|
3260
|
-
|
3261
|
-
|
3262
|
-
|
3263
|
-
|
3264
|
-
|
3265
|
-
|
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
|
+
}
|
3266
3368
|
write();
|
3267
|
-
if (onToolCall && !chunk.providerExecuted) {
|
3369
|
+
if (onToolCall && !chunk.providerExecuted && !chunk.dynamic) {
|
3268
3370
|
await onToolCall({
|
3269
3371
|
toolCall: chunk
|
3270
3372
|
});
|
@@ -3272,56 +3374,53 @@ function processUIMessageStream({
|
|
3272
3374
|
break;
|
3273
3375
|
}
|
3274
3376
|
case "tool-output-available": {
|
3275
|
-
|
3276
|
-
|
3277
|
-
|
3278
|
-
}
|
3279
|
-
const toolInvocationIndex = toolInvocations.findIndex(
|
3280
|
-
(invocation) => invocation.toolCallId === chunk.toolCallId
|
3281
|
-
);
|
3282
|
-
if (toolInvocationIndex === -1) {
|
3283
|
-
throw new Error(
|
3284
|
-
"tool_result must be preceded by a tool_call with the same toolCallId"
|
3377
|
+
if (chunk.dynamic) {
|
3378
|
+
const toolInvocation = getDynamicToolInvocation(
|
3379
|
+
chunk.toolCallId
|
3285
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
|
+
});
|
3286
3398
|
}
|
3287
|
-
const toolName = getToolName(
|
3288
|
-
toolInvocations[toolInvocationIndex]
|
3289
|
-
);
|
3290
|
-
updateToolInvocationPart({
|
3291
|
-
toolCallId: chunk.toolCallId,
|
3292
|
-
toolName,
|
3293
|
-
state: "output-available",
|
3294
|
-
input: toolInvocations[toolInvocationIndex].input,
|
3295
|
-
output: chunk.output,
|
3296
|
-
providerExecuted: chunk.providerExecuted
|
3297
|
-
});
|
3298
3399
|
write();
|
3299
3400
|
break;
|
3300
3401
|
}
|
3301
3402
|
case "tool-output-error": {
|
3302
|
-
|
3303
|
-
|
3304
|
-
|
3305
|
-
}
|
3306
|
-
const toolInvocationIndex = toolInvocations.findIndex(
|
3307
|
-
(invocation) => invocation.toolCallId === chunk.toolCallId
|
3308
|
-
);
|
3309
|
-
if (toolInvocationIndex === -1) {
|
3310
|
-
throw new Error(
|
3311
|
-
"tool_result must be preceded by a tool_call with the same toolCallId"
|
3403
|
+
if (chunk.dynamic) {
|
3404
|
+
const toolInvocation = getDynamicToolInvocation(
|
3405
|
+
chunk.toolCallId
|
3312
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
|
+
});
|
3313
3423
|
}
|
3314
|
-
const toolName = getToolName(
|
3315
|
-
toolInvocations[toolInvocationIndex]
|
3316
|
-
);
|
3317
|
-
updateToolInvocationPart({
|
3318
|
-
toolCallId: chunk.toolCallId,
|
3319
|
-
toolName,
|
3320
|
-
state: "output-error",
|
3321
|
-
input: toolInvocations[toolInvocationIndex].input,
|
3322
|
-
errorText: chunk.errorText,
|
3323
|
-
providerExecuted: chunk.providerExecuted
|
3324
|
-
});
|
3325
3424
|
write();
|
3326
3425
|
break;
|
3327
3426
|
}
|
@@ -4572,7 +4671,10 @@ var DefaultStreamTextResult = class {
|
|
4572
4671
|
abortSignal
|
4573
4672
|
});
|
4574
4673
|
}
|
4575
|
-
controller.enqueue(
|
4674
|
+
controller.enqueue({
|
4675
|
+
...chunk,
|
4676
|
+
dynamic: (tool3 == null ? void 0 : tool3.type) === "dynamic"
|
4677
|
+
});
|
4576
4678
|
break;
|
4577
4679
|
}
|
4578
4680
|
case "tool-input-end": {
|
@@ -4952,7 +5054,8 @@ var DefaultStreamTextResult = class {
|
|
4952
5054
|
type: "tool-input-start",
|
4953
5055
|
toolCallId: part.id,
|
4954
5056
|
toolName: part.toolName,
|
4955
|
-
providerExecuted: part.providerExecuted
|
5057
|
+
...part.providerExecuted != null ? { providerExecuted: part.providerExecuted } : {},
|
5058
|
+
...part.dynamic != null ? { dynamic: part.dynamic } : {}
|
4956
5059
|
});
|
4957
5060
|
break;
|
4958
5061
|
}
|
@@ -4970,8 +5073,9 @@ var DefaultStreamTextResult = class {
|
|
4970
5073
|
toolCallId: part.toolCallId,
|
4971
5074
|
toolName: part.toolName,
|
4972
5075
|
input: part.input,
|
4973
|
-
providerExecuted: part.providerExecuted,
|
4974
|
-
providerMetadata: part.providerMetadata
|
5076
|
+
...part.providerExecuted != null ? { providerExecuted: part.providerExecuted } : {},
|
5077
|
+
...part.providerMetadata != null ? { providerMetadata: part.providerMetadata } : {},
|
5078
|
+
...part.dynamic != null ? { dynamic: part.dynamic } : {}
|
4975
5079
|
});
|
4976
5080
|
break;
|
4977
5081
|
}
|
@@ -4980,7 +5084,8 @@ var DefaultStreamTextResult = class {
|
|
4980
5084
|
type: "tool-output-available",
|
4981
5085
|
toolCallId: part.toolCallId,
|
4982
5086
|
output: part.output,
|
4983
|
-
providerExecuted: part.providerExecuted
|
5087
|
+
...part.providerExecuted != null ? { providerExecuted: part.providerExecuted } : {},
|
5088
|
+
...part.dynamic != null ? { dynamic: part.dynamic } : {}
|
4984
5089
|
});
|
4985
5090
|
break;
|
4986
5091
|
}
|
@@ -4989,7 +5094,8 @@ var DefaultStreamTextResult = class {
|
|
4989
5094
|
type: "tool-output-error",
|
4990
5095
|
toolCallId: part.toolCallId,
|
4991
5096
|
errorText: onError(part.error),
|
4992
|
-
providerExecuted: part.providerExecuted
|
5097
|
+
...part.providerExecuted != null ? { providerExecuted: part.providerExecuted } : {},
|
5098
|
+
...part.dynamic != null ? { dynamic: part.dynamic } : {}
|
4993
5099
|
});
|
4994
5100
|
break;
|
4995
5101
|
}
|
@@ -7687,8 +7793,11 @@ var DefaultProviderRegistry = class {
|
|
7687
7793
|
};
|
7688
7794
|
|
7689
7795
|
// src/tool/mcp/mcp-client.ts
|
7690
|
-
import {
|
7691
|
-
|
7796
|
+
import {
|
7797
|
+
dynamicTool,
|
7798
|
+
jsonSchema,
|
7799
|
+
tool
|
7800
|
+
} from "@ai-sdk/provider-utils";
|
7692
7801
|
|
7693
7802
|
// src/tool/mcp/mcp-sse-transport.ts
|
7694
7803
|
import { EventSourceParserStream } from "@ai-sdk/provider-utils";
|
@@ -7698,9 +7807,10 @@ import { z as z9 } from "zod/v4";
|
|
7698
7807
|
|
7699
7808
|
// src/tool/mcp/types.ts
|
7700
7809
|
import { z as z8 } from "zod/v4";
|
7701
|
-
var LATEST_PROTOCOL_VERSION = "2025-
|
7810
|
+
var LATEST_PROTOCOL_VERSION = "2025-06-18";
|
7702
7811
|
var SUPPORTED_PROTOCOL_VERSIONS = [
|
7703
7812
|
LATEST_PROTOCOL_VERSION,
|
7813
|
+
"2025-03-26",
|
7704
7814
|
"2024-11-05"
|
7705
7815
|
];
|
7706
7816
|
var ClientOrServerImplementationSchema = z8.object({
|
@@ -8187,22 +8297,23 @@ var MCPClient = class {
|
|
8187
8297
|
continue;
|
8188
8298
|
}
|
8189
8299
|
const self = this;
|
8190
|
-
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({
|
8191
8306
|
description,
|
8192
|
-
inputSchema:
|
8307
|
+
inputSchema: jsonSchema({
|
8193
8308
|
...inputSchema,
|
8194
8309
|
properties: (_a16 = inputSchema.properties) != null ? _a16 : {},
|
8195
8310
|
additionalProperties: false
|
8196
|
-
})
|
8197
|
-
execute
|
8198
|
-
|
8199
|
-
|
8200
|
-
|
8201
|
-
|
8202
|
-
args,
|
8203
|
-
options
|
8204
|
-
});
|
8205
|
-
}
|
8311
|
+
}),
|
8312
|
+
execute
|
8313
|
+
}) : tool({
|
8314
|
+
description,
|
8315
|
+
inputSchema: schemas[name16].inputSchema,
|
8316
|
+
execute
|
8206
8317
|
});
|
8207
8318
|
tools[name16] = toolWithExecute;
|
8208
8319
|
}
|
@@ -8248,11 +8359,6 @@ var MCPClient = class {
|
|
8248
8359
|
}
|
8249
8360
|
};
|
8250
8361
|
|
8251
|
-
// src/tool/index.ts
|
8252
|
-
import {
|
8253
|
-
tool as tool2
|
8254
|
-
} from "@ai-sdk/provider-utils";
|
8255
|
-
|
8256
8362
|
// src/error/no-transcript-generated-error.ts
|
8257
8363
|
import { AISDKError as AISDKError21 } from "@ai-sdk/provider";
|
8258
8364
|
var NoTranscriptGeneratedError = class extends AISDKError21 {
|
@@ -8994,6 +9100,22 @@ function convertToModelMessages(messages, options) {
|
|
8994
9100
|
text: part.text,
|
8995
9101
|
providerOptions: part.providerMetadata
|
8996
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
|
+
}
|
8997
9119
|
} else if (isToolUIPart(part)) {
|
8998
9120
|
const toolName = getToolName(part);
|
8999
9121
|
if (part.state === "input-streaming") {
|
@@ -9032,7 +9154,9 @@ function convertToModelMessages(messages, options) {
|
|
9032
9154
|
role: "assistant",
|
9033
9155
|
content
|
9034
9156
|
});
|
9035
|
-
const toolParts = block.filter(
|
9157
|
+
const toolParts = block.filter(
|
9158
|
+
(part) => isToolUIPart(part) && part.providerExecuted !== true || part.type === "dynamic-tool"
|
9159
|
+
);
|
9036
9160
|
if (toolParts.length > 0) {
|
9037
9161
|
modelMessages.push({
|
9038
9162
|
role: "tool",
|
@@ -9041,7 +9165,7 @@ function convertToModelMessages(messages, options) {
|
|
9041
9165
|
switch (toolPart.state) {
|
9042
9166
|
case "output-error":
|
9043
9167
|
case "output-available": {
|
9044
|
-
const toolName = getToolName(toolPart);
|
9168
|
+
const toolName = toolPart.type === "dynamic-tool" ? toolPart.toolName : getToolName(toolPart);
|
9045
9169
|
return {
|
9046
9170
|
type: "tool-result",
|
9047
9171
|
toolCallId: toolPart.toolCallId,
|
@@ -9068,7 +9192,7 @@ function convertToModelMessages(messages, options) {
|
|
9068
9192
|
var processBlock = processBlock2;
|
9069
9193
|
let block = [];
|
9070
9194
|
for (const part of message.parts) {
|
9071
|
-
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)) {
|
9072
9196
|
block.push(part);
|
9073
9197
|
} else if (part.type === "step-start") {
|
9074
9198
|
processBlock2();
|
@@ -9338,6 +9462,7 @@ export {
|
|
9338
9462
|
createUIMessageStreamResponse,
|
9339
9463
|
customProvider,
|
9340
9464
|
defaultSettingsMiddleware,
|
9465
|
+
dynamicTool2 as dynamicTool,
|
9341
9466
|
embed,
|
9342
9467
|
embedMany,
|
9343
9468
|
createMCPClient as experimental_createMCPClient,
|