ai 6.0.0-beta.48 → 6.0.0-beta.49
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 +9 -0
- package/dist/index.d.mts +46 -1
- package/dist/index.d.ts +46 -1
- package/dist/index.js +85 -37
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +86 -40
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.d.mts +1 -1
- package/dist/internal/index.d.ts +1 -1
- package/dist/internal/index.js +5 -1
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +5 -1
- package/dist/internal/index.mjs.map +1 -1
- package/package.json +3 -3
package/dist/index.mjs
CHANGED
|
@@ -774,7 +774,7 @@ import {
|
|
|
774
774
|
} from "@ai-sdk/provider-utils";
|
|
775
775
|
|
|
776
776
|
// src/version.ts
|
|
777
|
-
var VERSION = true ? "6.0.0-beta.
|
|
777
|
+
var VERSION = true ? "6.0.0-beta.49" : "0.0.0-test";
|
|
778
778
|
|
|
779
779
|
// src/util/download/download.ts
|
|
780
780
|
var download = async ({ url }) => {
|
|
@@ -1397,6 +1397,10 @@ var outputSchema = z4.discriminatedUnion("type", [
|
|
|
1397
1397
|
type: z4.literal("json"),
|
|
1398
1398
|
value: jsonValueSchema
|
|
1399
1399
|
}),
|
|
1400
|
+
z4.object({
|
|
1401
|
+
type: z4.literal("execution-denied"),
|
|
1402
|
+
reason: z4.string().optional()
|
|
1403
|
+
}),
|
|
1400
1404
|
z4.object({
|
|
1401
1405
|
type: z4.literal("error-text"),
|
|
1402
1406
|
value: z4.string()
|
|
@@ -3195,9 +3199,7 @@ function getResponseUIMessageId({
|
|
|
3195
3199
|
}
|
|
3196
3200
|
|
|
3197
3201
|
// src/ui/process-ui-message-stream.ts
|
|
3198
|
-
import {
|
|
3199
|
-
validateTypes
|
|
3200
|
-
} from "@ai-sdk/provider-utils";
|
|
3202
|
+
import { validateTypes } from "@ai-sdk/provider-utils";
|
|
3201
3203
|
|
|
3202
3204
|
// src/ui-message-stream/ui-message-chunks.ts
|
|
3203
3205
|
import { z as z7 } from "zod/v4";
|
|
@@ -3774,27 +3776,15 @@ function processUIMessageStream({
|
|
|
3774
3776
|
await runUpdateMessageJob(async ({ state, write }) => {
|
|
3775
3777
|
var _a17, _b, _c, _d;
|
|
3776
3778
|
function getToolInvocation(toolCallId) {
|
|
3777
|
-
const toolInvocations = state.message.parts.filter(isToolUIPart);
|
|
3778
|
-
const toolInvocation = toolInvocations.find(
|
|
3779
|
-
(invocation) => invocation.toolCallId === toolCallId
|
|
3780
|
-
);
|
|
3781
|
-
if (toolInvocation == null) {
|
|
3782
|
-
throw new Error(
|
|
3783
|
-
"tool-output-error must be preceded by a tool-input-available"
|
|
3784
|
-
);
|
|
3785
|
-
}
|
|
3786
|
-
return toolInvocation;
|
|
3787
|
-
}
|
|
3788
|
-
function getDynamicToolInvocation(toolCallId) {
|
|
3789
3779
|
const toolInvocations = state.message.parts.filter(
|
|
3790
|
-
|
|
3780
|
+
isToolOrDynamicToolUIPart
|
|
3791
3781
|
);
|
|
3792
3782
|
const toolInvocation = toolInvocations.find(
|
|
3793
3783
|
(invocation) => invocation.toolCallId === toolCallId
|
|
3794
3784
|
);
|
|
3795
3785
|
if (toolInvocation == null) {
|
|
3796
3786
|
throw new Error(
|
|
3797
|
-
|
|
3787
|
+
`no tool invocation found for tool call ${toolCallId}`
|
|
3798
3788
|
);
|
|
3799
3789
|
}
|
|
3800
3790
|
return toolInvocation;
|
|
@@ -4069,9 +4059,7 @@ function processUIMessageStream({
|
|
|
4069
4059
|
case "tool-approval-request": {
|
|
4070
4060
|
const toolInvocation = getToolInvocation(chunk.toolCallId);
|
|
4071
4061
|
toolInvocation.state = "approval-requested";
|
|
4072
|
-
toolInvocation.approval = {
|
|
4073
|
-
id: chunk.approvalId
|
|
4074
|
-
};
|
|
4062
|
+
toolInvocation.approval = { id: chunk.approvalId };
|
|
4075
4063
|
write();
|
|
4076
4064
|
break;
|
|
4077
4065
|
}
|
|
@@ -4082,10 +4070,8 @@ function processUIMessageStream({
|
|
|
4082
4070
|
break;
|
|
4083
4071
|
}
|
|
4084
4072
|
case "tool-output-available": {
|
|
4085
|
-
|
|
4086
|
-
|
|
4087
|
-
chunk.toolCallId
|
|
4088
|
-
);
|
|
4073
|
+
const toolInvocation = getToolInvocation(chunk.toolCallId);
|
|
4074
|
+
if (toolInvocation.type === "dynamic-tool") {
|
|
4089
4075
|
updateDynamicToolPart({
|
|
4090
4076
|
toolCallId: chunk.toolCallId,
|
|
4091
4077
|
toolName: toolInvocation.toolName,
|
|
@@ -4095,7 +4081,6 @@ function processUIMessageStream({
|
|
|
4095
4081
|
preliminary: chunk.preliminary
|
|
4096
4082
|
});
|
|
4097
4083
|
} else {
|
|
4098
|
-
const toolInvocation = getToolInvocation(chunk.toolCallId);
|
|
4099
4084
|
updateToolPart({
|
|
4100
4085
|
toolCallId: chunk.toolCallId,
|
|
4101
4086
|
toolName: getToolName(toolInvocation),
|
|
@@ -4110,10 +4095,8 @@ function processUIMessageStream({
|
|
|
4110
4095
|
break;
|
|
4111
4096
|
}
|
|
4112
4097
|
case "tool-output-error": {
|
|
4113
|
-
|
|
4114
|
-
|
|
4115
|
-
chunk.toolCallId
|
|
4116
|
-
);
|
|
4098
|
+
const toolInvocation = getToolInvocation(chunk.toolCallId);
|
|
4099
|
+
if (toolInvocation.type === "dynamic-tool") {
|
|
4117
4100
|
updateDynamicToolPart({
|
|
4118
4101
|
toolCallId: chunk.toolCallId,
|
|
4119
4102
|
toolName: toolInvocation.toolName,
|
|
@@ -4122,7 +4105,6 @@ function processUIMessageStream({
|
|
|
4122
4105
|
errorText: chunk.errorText
|
|
4123
4106
|
});
|
|
4124
4107
|
} else {
|
|
4125
|
-
const toolInvocation = getToolInvocation(chunk.toolCallId);
|
|
4126
4108
|
updateToolPart({
|
|
4127
4109
|
toolCallId: chunk.toolCallId,
|
|
4128
4110
|
toolName: getToolName(toolInvocation),
|
|
@@ -6245,6 +6227,13 @@ function convertToModelMessages(messages, options) {
|
|
|
6245
6227
|
...part.callProviderMetadata != null ? { providerOptions: part.callProviderMetadata } : {}
|
|
6246
6228
|
});
|
|
6247
6229
|
}
|
|
6230
|
+
if (part.approval != null) {
|
|
6231
|
+
content.push({
|
|
6232
|
+
type: "tool-approval-request",
|
|
6233
|
+
approvalId: part.approval.id,
|
|
6234
|
+
toolCallId: part.toolCallId
|
|
6235
|
+
});
|
|
6236
|
+
}
|
|
6248
6237
|
} else if (isToolUIPart(part)) {
|
|
6249
6238
|
const toolName = getToolName(part);
|
|
6250
6239
|
if (part.state !== "input-streaming") {
|
|
@@ -6295,7 +6284,7 @@ function convertToModelMessages(messages, options) {
|
|
|
6295
6284
|
(toolPart) => {
|
|
6296
6285
|
var _a18, _b2, _c;
|
|
6297
6286
|
const outputs = [];
|
|
6298
|
-
if (
|
|
6287
|
+
if (((_a18 = toolPart.approval) == null ? void 0 : _a18.approved) != null) {
|
|
6299
6288
|
outputs.push({
|
|
6300
6289
|
type: "tool-approval-response",
|
|
6301
6290
|
approvalId: toolPart.approval.id,
|
|
@@ -6308,7 +6297,7 @@ function convertToModelMessages(messages, options) {
|
|
|
6308
6297
|
outputs.push({
|
|
6309
6298
|
type: "tool-result",
|
|
6310
6299
|
toolCallId: toolPart.toolCallId,
|
|
6311
|
-
toolName:
|
|
6300
|
+
toolName: getToolOrDynamicToolName(toolPart),
|
|
6312
6301
|
output: {
|
|
6313
6302
|
type: "error-text",
|
|
6314
6303
|
value: (_b2 = toolPart.approval.reason) != null ? _b2 : "Tool execution denied."
|
|
@@ -6318,7 +6307,7 @@ function convertToModelMessages(messages, options) {
|
|
|
6318
6307
|
}
|
|
6319
6308
|
case "output-error":
|
|
6320
6309
|
case "output-available": {
|
|
6321
|
-
const toolName =
|
|
6310
|
+
const toolName = getToolOrDynamicToolName(toolPart);
|
|
6322
6311
|
outputs.push({
|
|
6323
6312
|
type: "tool-result",
|
|
6324
6313
|
toolCallId: toolPart.toolCallId,
|
|
@@ -6342,7 +6331,7 @@ function convertToModelMessages(messages, options) {
|
|
|
6342
6331
|
var processBlock = processBlock2;
|
|
6343
6332
|
let block = [];
|
|
6344
6333
|
for (const part of message.parts) {
|
|
6345
|
-
if (part.type === "text" || part.type === "reasoning" || part.type === "file" ||
|
|
6334
|
+
if (part.type === "text" || part.type === "reasoning" || part.type === "file" || isToolOrDynamicToolUIPart(part)) {
|
|
6346
6335
|
block.push(part);
|
|
6347
6336
|
} else if (part.type === "step-start") {
|
|
6348
6337
|
processBlock2();
|
|
@@ -10254,7 +10243,7 @@ var AbstractChat = class {
|
|
|
10254
10243
|
var _a17, _b;
|
|
10255
10244
|
const messages = this.state.messages;
|
|
10256
10245
|
const lastMessage = messages[messages.length - 1];
|
|
10257
|
-
const updatePart = (part) =>
|
|
10246
|
+
const updatePart = (part) => isToolOrDynamicToolUIPart(part) && part.state === "approval-requested" && part.approval.id === id ? {
|
|
10258
10247
|
...part,
|
|
10259
10248
|
state: "approval-responded",
|
|
10260
10249
|
approval: { id, approved, reason }
|
|
@@ -10626,7 +10615,8 @@ var uiMessagesSchema = lazySchema2(
|
|
|
10626
10615
|
state: z10.literal("input-streaming"),
|
|
10627
10616
|
input: z10.unknown().optional(),
|
|
10628
10617
|
output: z10.never().optional(),
|
|
10629
|
-
errorText: z10.never().optional()
|
|
10618
|
+
errorText: z10.never().optional(),
|
|
10619
|
+
approval: z10.never().optional()
|
|
10630
10620
|
}),
|
|
10631
10621
|
z10.object({
|
|
10632
10622
|
type: z10.literal("dynamic-tool"),
|
|
@@ -10636,7 +10626,38 @@ var uiMessagesSchema = lazySchema2(
|
|
|
10636
10626
|
input: z10.unknown(),
|
|
10637
10627
|
output: z10.never().optional(),
|
|
10638
10628
|
errorText: z10.never().optional(),
|
|
10639
|
-
callProviderMetadata: providerMetadataSchema.optional()
|
|
10629
|
+
callProviderMetadata: providerMetadataSchema.optional(),
|
|
10630
|
+
approval: z10.never().optional()
|
|
10631
|
+
}),
|
|
10632
|
+
z10.object({
|
|
10633
|
+
type: z10.literal("dynamic-tool"),
|
|
10634
|
+
toolName: z10.string(),
|
|
10635
|
+
toolCallId: z10.string(),
|
|
10636
|
+
state: z10.literal("approval-requested"),
|
|
10637
|
+
input: z10.unknown(),
|
|
10638
|
+
output: z10.never().optional(),
|
|
10639
|
+
errorText: z10.never().optional(),
|
|
10640
|
+
callProviderMetadata: providerMetadataSchema.optional(),
|
|
10641
|
+
approval: z10.object({
|
|
10642
|
+
id: z10.string(),
|
|
10643
|
+
approved: z10.never().optional(),
|
|
10644
|
+
reason: z10.never().optional()
|
|
10645
|
+
})
|
|
10646
|
+
}),
|
|
10647
|
+
z10.object({
|
|
10648
|
+
type: z10.literal("dynamic-tool"),
|
|
10649
|
+
toolName: z10.string(),
|
|
10650
|
+
toolCallId: z10.string(),
|
|
10651
|
+
state: z10.literal("approval-responded"),
|
|
10652
|
+
input: z10.unknown(),
|
|
10653
|
+
output: z10.never().optional(),
|
|
10654
|
+
errorText: z10.never().optional(),
|
|
10655
|
+
callProviderMetadata: providerMetadataSchema.optional(),
|
|
10656
|
+
approval: z10.object({
|
|
10657
|
+
id: z10.string(),
|
|
10658
|
+
approved: z10.boolean(),
|
|
10659
|
+
reason: z10.string().optional()
|
|
10660
|
+
})
|
|
10640
10661
|
}),
|
|
10641
10662
|
z10.object({
|
|
10642
10663
|
type: z10.literal("dynamic-tool"),
|
|
@@ -10647,7 +10668,12 @@ var uiMessagesSchema = lazySchema2(
|
|
|
10647
10668
|
output: z10.unknown(),
|
|
10648
10669
|
errorText: z10.never().optional(),
|
|
10649
10670
|
callProviderMetadata: providerMetadataSchema.optional(),
|
|
10650
|
-
preliminary: z10.boolean().optional()
|
|
10671
|
+
preliminary: z10.boolean().optional(),
|
|
10672
|
+
approval: z10.object({
|
|
10673
|
+
id: z10.string(),
|
|
10674
|
+
approved: z10.literal(true),
|
|
10675
|
+
reason: z10.string().optional()
|
|
10676
|
+
}).optional()
|
|
10651
10677
|
}),
|
|
10652
10678
|
z10.object({
|
|
10653
10679
|
type: z10.literal("dynamic-tool"),
|
|
@@ -10657,7 +10683,27 @@ var uiMessagesSchema = lazySchema2(
|
|
|
10657
10683
|
input: z10.unknown(),
|
|
10658
10684
|
output: z10.never().optional(),
|
|
10659
10685
|
errorText: z10.string(),
|
|
10660
|
-
callProviderMetadata: providerMetadataSchema.optional()
|
|
10686
|
+
callProviderMetadata: providerMetadataSchema.optional(),
|
|
10687
|
+
approval: z10.object({
|
|
10688
|
+
id: z10.string(),
|
|
10689
|
+
approved: z10.literal(true),
|
|
10690
|
+
reason: z10.string().optional()
|
|
10691
|
+
}).optional()
|
|
10692
|
+
}),
|
|
10693
|
+
z10.object({
|
|
10694
|
+
type: z10.literal("dynamic-tool"),
|
|
10695
|
+
toolName: z10.string(),
|
|
10696
|
+
toolCallId: z10.string(),
|
|
10697
|
+
state: z10.literal("output-denied"),
|
|
10698
|
+
input: z10.unknown(),
|
|
10699
|
+
output: z10.never().optional(),
|
|
10700
|
+
errorText: z10.never().optional(),
|
|
10701
|
+
callProviderMetadata: providerMetadataSchema.optional(),
|
|
10702
|
+
approval: z10.object({
|
|
10703
|
+
id: z10.string(),
|
|
10704
|
+
approved: z10.literal(false),
|
|
10705
|
+
reason: z10.string().optional()
|
|
10706
|
+
})
|
|
10661
10707
|
}),
|
|
10662
10708
|
z10.object({
|
|
10663
10709
|
type: z10.string().startsWith("tool-"),
|