ai 6.0.0-beta.149 → 6.0.0-beta.151
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 +12 -0
- package/dist/index.d.mts +90 -9
- package/dist/index.d.ts +90 -9
- package/dist/index.js +54 -33
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +52 -33
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.js +1 -1
- package/dist/internal/index.mjs +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -866,7 +866,7 @@ import {
|
|
|
866
866
|
} from "@ai-sdk/provider-utils";
|
|
867
867
|
|
|
868
868
|
// src/version.ts
|
|
869
|
-
var VERSION = true ? "6.0.0-beta.
|
|
869
|
+
var VERSION = true ? "6.0.0-beta.151" : "0.0.0-test";
|
|
870
870
|
|
|
871
871
|
// src/util/download/download.ts
|
|
872
872
|
var download = async ({ url }) => {
|
|
@@ -2788,13 +2788,17 @@ var text = () => ({
|
|
|
2788
2788
|
}
|
|
2789
2789
|
});
|
|
2790
2790
|
var object = ({
|
|
2791
|
-
schema: inputSchema
|
|
2791
|
+
schema: inputSchema,
|
|
2792
|
+
name: name15,
|
|
2793
|
+
description
|
|
2792
2794
|
}) => {
|
|
2793
2795
|
const schema = asSchema2(inputSchema);
|
|
2794
2796
|
return {
|
|
2795
2797
|
responseFormat: resolve(schema.jsonSchema).then((jsonSchema2) => ({
|
|
2796
2798
|
type: "json",
|
|
2797
|
-
schema: jsonSchema2
|
|
2799
|
+
schema: jsonSchema2,
|
|
2800
|
+
...name15 != null && { name: name15 },
|
|
2801
|
+
...description != null && { description }
|
|
2798
2802
|
})),
|
|
2799
2803
|
async parseCompleteOutput({ text: text2 }, context) {
|
|
2800
2804
|
const parseResult = await safeParseJSON2({ text: text2 });
|
|
@@ -2843,7 +2847,9 @@ var object = ({
|
|
|
2843
2847
|
};
|
|
2844
2848
|
};
|
|
2845
2849
|
var array = ({
|
|
2846
|
-
element: inputElementSchema
|
|
2850
|
+
element: inputElementSchema,
|
|
2851
|
+
name: name15,
|
|
2852
|
+
description
|
|
2847
2853
|
}) => {
|
|
2848
2854
|
const elementSchema = asSchema2(inputElementSchema);
|
|
2849
2855
|
return {
|
|
@@ -2860,7 +2866,9 @@ var array = ({
|
|
|
2860
2866
|
},
|
|
2861
2867
|
required: ["elements"],
|
|
2862
2868
|
additionalProperties: false
|
|
2863
|
-
}
|
|
2869
|
+
},
|
|
2870
|
+
...name15 != null && { name: name15 },
|
|
2871
|
+
...description != null && { description }
|
|
2864
2872
|
};
|
|
2865
2873
|
}),
|
|
2866
2874
|
async parseCompleteOutput({ text: text2 }, context) {
|
|
@@ -2938,7 +2946,9 @@ var array = ({
|
|
|
2938
2946
|
};
|
|
2939
2947
|
};
|
|
2940
2948
|
var choice = ({
|
|
2941
|
-
options: choiceOptions
|
|
2949
|
+
options: choiceOptions,
|
|
2950
|
+
name: name15,
|
|
2951
|
+
description
|
|
2942
2952
|
}) => {
|
|
2943
2953
|
return {
|
|
2944
2954
|
// JSON schema that describes an enumeration:
|
|
@@ -2952,7 +2962,9 @@ var choice = ({
|
|
|
2952
2962
|
},
|
|
2953
2963
|
required: ["result"],
|
|
2954
2964
|
additionalProperties: false
|
|
2955
|
-
}
|
|
2965
|
+
},
|
|
2966
|
+
...name15 != null && { name: name15 },
|
|
2967
|
+
...description != null && { description }
|
|
2956
2968
|
}),
|
|
2957
2969
|
async parseCompleteOutput({ text: text2 }, context) {
|
|
2958
2970
|
const parseResult = await safeParseJSON2({ text: text2 });
|
|
@@ -3008,10 +3020,15 @@ var choice = ({
|
|
|
3008
3020
|
}
|
|
3009
3021
|
};
|
|
3010
3022
|
};
|
|
3011
|
-
var json = (
|
|
3023
|
+
var json = ({
|
|
3024
|
+
name: name15,
|
|
3025
|
+
description
|
|
3026
|
+
} = {}) => {
|
|
3012
3027
|
return {
|
|
3013
3028
|
responseFormat: Promise.resolve({
|
|
3014
|
-
type: "json"
|
|
3029
|
+
type: "json",
|
|
3030
|
+
...name15 != null && { name: name15 },
|
|
3031
|
+
...description != null && { description }
|
|
3015
3032
|
}),
|
|
3016
3033
|
async parseCompleteOutput({ text: text2 }, context) {
|
|
3017
3034
|
const parseResult = await safeParseJSON2({ text: text2 });
|
|
@@ -4336,21 +4353,23 @@ function isFileUIPart(part) {
|
|
|
4336
4353
|
function isReasoningUIPart(part) {
|
|
4337
4354
|
return part.type === "reasoning";
|
|
4338
4355
|
}
|
|
4339
|
-
function
|
|
4356
|
+
function isStaticToolUIPart(part) {
|
|
4340
4357
|
return part.type.startsWith("tool-");
|
|
4341
4358
|
}
|
|
4342
4359
|
function isDynamicToolUIPart(part) {
|
|
4343
4360
|
return part.type === "dynamic-tool";
|
|
4344
4361
|
}
|
|
4345
|
-
function
|
|
4346
|
-
return
|
|
4362
|
+
function isToolUIPart(part) {
|
|
4363
|
+
return isStaticToolUIPart(part) || isDynamicToolUIPart(part);
|
|
4347
4364
|
}
|
|
4348
|
-
|
|
4365
|
+
var isToolOrDynamicToolUIPart = isToolUIPart;
|
|
4366
|
+
function getStaticToolName(part) {
|
|
4349
4367
|
return part.type.split("-").slice(1).join("-");
|
|
4350
4368
|
}
|
|
4351
|
-
function
|
|
4352
|
-
return isDynamicToolUIPart(part) ? part.toolName :
|
|
4369
|
+
function getToolName(part) {
|
|
4370
|
+
return isDynamicToolUIPart(part) ? part.toolName : getStaticToolName(part);
|
|
4353
4371
|
}
|
|
4372
|
+
var getToolOrDynamicToolName = getToolName;
|
|
4354
4373
|
|
|
4355
4374
|
// src/ui/process-ui-message-stream.ts
|
|
4356
4375
|
function createStreamingUIMessageState({
|
|
@@ -4384,9 +4403,7 @@ function processUIMessageStream({
|
|
|
4384
4403
|
await runUpdateMessageJob(async ({ state, write }) => {
|
|
4385
4404
|
var _a15, _b, _c, _d;
|
|
4386
4405
|
function getToolInvocation(toolCallId) {
|
|
4387
|
-
const toolInvocations = state.message.parts.filter(
|
|
4388
|
-
isToolOrDynamicToolUIPart
|
|
4389
|
-
);
|
|
4406
|
+
const toolInvocations = state.message.parts.filter(isToolUIPart);
|
|
4390
4407
|
const toolInvocation = toolInvocations.find(
|
|
4391
4408
|
(invocation) => invocation.toolCallId === toolCallId
|
|
4392
4409
|
);
|
|
@@ -4400,7 +4417,7 @@ function processUIMessageStream({
|
|
|
4400
4417
|
function updateToolPart(options) {
|
|
4401
4418
|
var _a16;
|
|
4402
4419
|
const part = state.message.parts.find(
|
|
4403
|
-
(part2) =>
|
|
4420
|
+
(part2) => isStaticToolUIPart(part2) && part2.toolCallId === options.toolCallId
|
|
4404
4421
|
);
|
|
4405
4422
|
const anyOptions = options;
|
|
4406
4423
|
const anyPart = part;
|
|
@@ -4572,7 +4589,7 @@ function processUIMessageStream({
|
|
|
4572
4589
|
break;
|
|
4573
4590
|
}
|
|
4574
4591
|
case "tool-input-start": {
|
|
4575
|
-
const toolInvocations = state.message.parts.filter(
|
|
4592
|
+
const toolInvocations = state.message.parts.filter(isStaticToolUIPart);
|
|
4576
4593
|
state.partialToolCalls[chunk.toolCallId] = {
|
|
4577
4594
|
text: "",
|
|
4578
4595
|
toolName: chunk.toolName,
|
|
@@ -4713,7 +4730,7 @@ function processUIMessageStream({
|
|
|
4713
4730
|
} else {
|
|
4714
4731
|
updateToolPart({
|
|
4715
4732
|
toolCallId: chunk.toolCallId,
|
|
4716
|
-
toolName:
|
|
4733
|
+
toolName: getStaticToolName(toolInvocation),
|
|
4717
4734
|
state: "output-available",
|
|
4718
4735
|
input: toolInvocation.input,
|
|
4719
4736
|
output: chunk.output,
|
|
@@ -4740,7 +4757,7 @@ function processUIMessageStream({
|
|
|
4740
4757
|
} else {
|
|
4741
4758
|
updateToolPart({
|
|
4742
4759
|
toolCallId: chunk.toolCallId,
|
|
4743
|
-
toolName:
|
|
4760
|
+
toolName: getStaticToolName(toolInvocation),
|
|
4744
4761
|
state: "output-error",
|
|
4745
4762
|
input: toolInvocation.input,
|
|
4746
4763
|
rawInput: toolInvocation.rawInput,
|
|
@@ -6958,7 +6975,7 @@ function convertToModelMessages(messages, options) {
|
|
|
6958
6975
|
messages = messages.map((message) => ({
|
|
6959
6976
|
...message,
|
|
6960
6977
|
parts: message.parts.filter(
|
|
6961
|
-
(part) => !
|
|
6978
|
+
(part) => !isToolUIPart(part) || part.state !== "input-streaming" && part.state !== "input-available"
|
|
6962
6979
|
)
|
|
6963
6980
|
}));
|
|
6964
6981
|
}
|
|
@@ -7040,8 +7057,8 @@ function convertToModelMessages(messages, options) {
|
|
|
7040
7057
|
text: part.text,
|
|
7041
7058
|
providerOptions: part.providerMetadata
|
|
7042
7059
|
});
|
|
7043
|
-
} else if (
|
|
7044
|
-
const toolName =
|
|
7060
|
+
} else if (isToolUIPart(part)) {
|
|
7061
|
+
const toolName = getToolName(part);
|
|
7045
7062
|
if (part.state !== "input-streaming") {
|
|
7046
7063
|
content.push({
|
|
7047
7064
|
type: "tool-call",
|
|
@@ -7090,7 +7107,7 @@ function convertToModelMessages(messages, options) {
|
|
|
7090
7107
|
content
|
|
7091
7108
|
});
|
|
7092
7109
|
const toolParts = block.filter(
|
|
7093
|
-
(part) =>
|
|
7110
|
+
(part) => isToolUIPart(part) && part.providerExecuted !== true
|
|
7094
7111
|
);
|
|
7095
7112
|
if (toolParts.length > 0) {
|
|
7096
7113
|
modelMessages.push({
|
|
@@ -7112,7 +7129,7 @@ function convertToModelMessages(messages, options) {
|
|
|
7112
7129
|
outputs.push({
|
|
7113
7130
|
type: "tool-result",
|
|
7114
7131
|
toolCallId: toolPart.toolCallId,
|
|
7115
|
-
toolName:
|
|
7132
|
+
toolName: getToolName(toolPart),
|
|
7116
7133
|
output: {
|
|
7117
7134
|
type: "error-text",
|
|
7118
7135
|
value: (_b2 = toolPart.approval.reason) != null ? _b2 : "Tool execution denied."
|
|
@@ -7123,7 +7140,7 @@ function convertToModelMessages(messages, options) {
|
|
|
7123
7140
|
}
|
|
7124
7141
|
case "output-error":
|
|
7125
7142
|
case "output-available": {
|
|
7126
|
-
const toolName =
|
|
7143
|
+
const toolName = getToolName(toolPart);
|
|
7127
7144
|
outputs.push({
|
|
7128
7145
|
type: "tool-result",
|
|
7129
7146
|
toolCallId: toolPart.toolCallId,
|
|
@@ -7148,7 +7165,7 @@ function convertToModelMessages(messages, options) {
|
|
|
7148
7165
|
var processBlock = processBlock2;
|
|
7149
7166
|
let block = [];
|
|
7150
7167
|
for (const part of message.parts) {
|
|
7151
|
-
if (isTextUIPart(part) || isReasoningUIPart(part) || isFileUIPart(part) ||
|
|
7168
|
+
if (isTextUIPart(part) || isReasoningUIPart(part) || isFileUIPart(part) || isToolUIPart(part) || isDataUIPart(part)) {
|
|
7152
7169
|
block.push(part);
|
|
7153
7170
|
} else if (part.type === "step-start") {
|
|
7154
7171
|
processBlock2();
|
|
@@ -11119,7 +11136,7 @@ var AbstractChat = class {
|
|
|
11119
11136
|
var _a15, _b;
|
|
11120
11137
|
const messages = this.state.messages;
|
|
11121
11138
|
const lastMessage = messages[messages.length - 1];
|
|
11122
|
-
const updatePart = (part) =>
|
|
11139
|
+
const updatePart = (part) => isToolUIPart(part) && part.state === "approval-requested" && part.approval.id === id ? {
|
|
11123
11140
|
...part,
|
|
11124
11141
|
state: "approval-responded",
|
|
11125
11142
|
approval: { id, approved, reason }
|
|
@@ -11148,7 +11165,7 @@ var AbstractChat = class {
|
|
|
11148
11165
|
var _a15, _b;
|
|
11149
11166
|
const messages = this.state.messages;
|
|
11150
11167
|
const lastMessage = messages[messages.length - 1];
|
|
11151
|
-
const updatePart = (part) =>
|
|
11168
|
+
const updatePart = (part) => isToolUIPart(part) && part.toolCallId === toolCallId ? { ...part, state, output, errorText } : part;
|
|
11152
11169
|
this.state.replaceMessage(messages.length - 1, {
|
|
11153
11170
|
...lastMessage,
|
|
11154
11171
|
parts: lastMessage.parts.map(updatePart)
|
|
@@ -11363,7 +11380,7 @@ function lastAssistantMessageIsCompleteWithApprovalResponses({
|
|
|
11363
11380
|
const lastStepStartIndex = message.parts.reduce((lastIndex, part, index) => {
|
|
11364
11381
|
return part.type === "step-start" ? index : lastIndex;
|
|
11365
11382
|
}, -1);
|
|
11366
|
-
const lastStepToolInvocations = message.parts.slice(lastStepStartIndex + 1).filter(
|
|
11383
|
+
const lastStepToolInvocations = message.parts.slice(lastStepStartIndex + 1).filter(isToolUIPart).filter((part) => !part.providerExecuted);
|
|
11367
11384
|
return (
|
|
11368
11385
|
// has at least one tool approval response
|
|
11369
11386
|
lastStepToolInvocations.filter((part) => part.state === "approval-responded").length > 0 && // all tool approvals must have a response
|
|
@@ -11387,7 +11404,7 @@ function lastAssistantMessageIsCompleteWithToolCalls({
|
|
|
11387
11404
|
const lastStepStartIndex = message.parts.reduce((lastIndex, part, index) => {
|
|
11388
11405
|
return part.type === "step-start" ? index : lastIndex;
|
|
11389
11406
|
}, -1);
|
|
11390
|
-
const lastStepToolInvocations = message.parts.slice(lastStepStartIndex + 1).filter(
|
|
11407
|
+
const lastStepToolInvocations = message.parts.slice(lastStepStartIndex + 1).filter(isToolUIPart).filter((part) => !part.providerExecuted);
|
|
11391
11408
|
return lastStepToolInvocations.length > 0 && lastStepToolInvocations.every(
|
|
11392
11409
|
(part) => part.state === "output-available" || part.state === "output-error"
|
|
11393
11410
|
);
|
|
@@ -11499,6 +11516,7 @@ export {
|
|
|
11499
11516
|
generateId,
|
|
11500
11517
|
generateObject,
|
|
11501
11518
|
generateText,
|
|
11519
|
+
getStaticToolName,
|
|
11502
11520
|
getTextFromDataUrl,
|
|
11503
11521
|
getToolName,
|
|
11504
11522
|
getToolOrDynamicToolName,
|
|
@@ -11507,6 +11525,7 @@ export {
|
|
|
11507
11525
|
isDeepEqualData,
|
|
11508
11526
|
isFileUIPart,
|
|
11509
11527
|
isReasoningUIPart,
|
|
11528
|
+
isStaticToolUIPart,
|
|
11510
11529
|
isTextUIPart,
|
|
11511
11530
|
isToolOrDynamicToolUIPart,
|
|
11512
11531
|
isToolUIPart,
|