ai 6.0.0-beta.150 → 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 +6 -0
- package/dist/index.d.mts +36 -5
- package/dist/index.d.ts +36 -5
- package/dist/index.js +29 -25
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +27 -25
- 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 }) => {
|
|
@@ -4353,21 +4353,23 @@ function isFileUIPart(part) {
|
|
|
4353
4353
|
function isReasoningUIPart(part) {
|
|
4354
4354
|
return part.type === "reasoning";
|
|
4355
4355
|
}
|
|
4356
|
-
function
|
|
4356
|
+
function isStaticToolUIPart(part) {
|
|
4357
4357
|
return part.type.startsWith("tool-");
|
|
4358
4358
|
}
|
|
4359
4359
|
function isDynamicToolUIPart(part) {
|
|
4360
4360
|
return part.type === "dynamic-tool";
|
|
4361
4361
|
}
|
|
4362
|
-
function
|
|
4363
|
-
return
|
|
4362
|
+
function isToolUIPart(part) {
|
|
4363
|
+
return isStaticToolUIPart(part) || isDynamicToolUIPart(part);
|
|
4364
4364
|
}
|
|
4365
|
-
|
|
4365
|
+
var isToolOrDynamicToolUIPart = isToolUIPart;
|
|
4366
|
+
function getStaticToolName(part) {
|
|
4366
4367
|
return part.type.split("-").slice(1).join("-");
|
|
4367
4368
|
}
|
|
4368
|
-
function
|
|
4369
|
-
return isDynamicToolUIPart(part) ? part.toolName :
|
|
4369
|
+
function getToolName(part) {
|
|
4370
|
+
return isDynamicToolUIPart(part) ? part.toolName : getStaticToolName(part);
|
|
4370
4371
|
}
|
|
4372
|
+
var getToolOrDynamicToolName = getToolName;
|
|
4371
4373
|
|
|
4372
4374
|
// src/ui/process-ui-message-stream.ts
|
|
4373
4375
|
function createStreamingUIMessageState({
|
|
@@ -4401,9 +4403,7 @@ function processUIMessageStream({
|
|
|
4401
4403
|
await runUpdateMessageJob(async ({ state, write }) => {
|
|
4402
4404
|
var _a15, _b, _c, _d;
|
|
4403
4405
|
function getToolInvocation(toolCallId) {
|
|
4404
|
-
const toolInvocations = state.message.parts.filter(
|
|
4405
|
-
isToolOrDynamicToolUIPart
|
|
4406
|
-
);
|
|
4406
|
+
const toolInvocations = state.message.parts.filter(isToolUIPart);
|
|
4407
4407
|
const toolInvocation = toolInvocations.find(
|
|
4408
4408
|
(invocation) => invocation.toolCallId === toolCallId
|
|
4409
4409
|
);
|
|
@@ -4417,7 +4417,7 @@ function processUIMessageStream({
|
|
|
4417
4417
|
function updateToolPart(options) {
|
|
4418
4418
|
var _a16;
|
|
4419
4419
|
const part = state.message.parts.find(
|
|
4420
|
-
(part2) =>
|
|
4420
|
+
(part2) => isStaticToolUIPart(part2) && part2.toolCallId === options.toolCallId
|
|
4421
4421
|
);
|
|
4422
4422
|
const anyOptions = options;
|
|
4423
4423
|
const anyPart = part;
|
|
@@ -4589,7 +4589,7 @@ function processUIMessageStream({
|
|
|
4589
4589
|
break;
|
|
4590
4590
|
}
|
|
4591
4591
|
case "tool-input-start": {
|
|
4592
|
-
const toolInvocations = state.message.parts.filter(
|
|
4592
|
+
const toolInvocations = state.message.parts.filter(isStaticToolUIPart);
|
|
4593
4593
|
state.partialToolCalls[chunk.toolCallId] = {
|
|
4594
4594
|
text: "",
|
|
4595
4595
|
toolName: chunk.toolName,
|
|
@@ -4730,7 +4730,7 @@ function processUIMessageStream({
|
|
|
4730
4730
|
} else {
|
|
4731
4731
|
updateToolPart({
|
|
4732
4732
|
toolCallId: chunk.toolCallId,
|
|
4733
|
-
toolName:
|
|
4733
|
+
toolName: getStaticToolName(toolInvocation),
|
|
4734
4734
|
state: "output-available",
|
|
4735
4735
|
input: toolInvocation.input,
|
|
4736
4736
|
output: chunk.output,
|
|
@@ -4757,7 +4757,7 @@ function processUIMessageStream({
|
|
|
4757
4757
|
} else {
|
|
4758
4758
|
updateToolPart({
|
|
4759
4759
|
toolCallId: chunk.toolCallId,
|
|
4760
|
-
toolName:
|
|
4760
|
+
toolName: getStaticToolName(toolInvocation),
|
|
4761
4761
|
state: "output-error",
|
|
4762
4762
|
input: toolInvocation.input,
|
|
4763
4763
|
rawInput: toolInvocation.rawInput,
|
|
@@ -6975,7 +6975,7 @@ function convertToModelMessages(messages, options) {
|
|
|
6975
6975
|
messages = messages.map((message) => ({
|
|
6976
6976
|
...message,
|
|
6977
6977
|
parts: message.parts.filter(
|
|
6978
|
-
(part) => !
|
|
6978
|
+
(part) => !isToolUIPart(part) || part.state !== "input-streaming" && part.state !== "input-available"
|
|
6979
6979
|
)
|
|
6980
6980
|
}));
|
|
6981
6981
|
}
|
|
@@ -7057,8 +7057,8 @@ function convertToModelMessages(messages, options) {
|
|
|
7057
7057
|
text: part.text,
|
|
7058
7058
|
providerOptions: part.providerMetadata
|
|
7059
7059
|
});
|
|
7060
|
-
} else if (
|
|
7061
|
-
const toolName =
|
|
7060
|
+
} else if (isToolUIPart(part)) {
|
|
7061
|
+
const toolName = getToolName(part);
|
|
7062
7062
|
if (part.state !== "input-streaming") {
|
|
7063
7063
|
content.push({
|
|
7064
7064
|
type: "tool-call",
|
|
@@ -7107,7 +7107,7 @@ function convertToModelMessages(messages, options) {
|
|
|
7107
7107
|
content
|
|
7108
7108
|
});
|
|
7109
7109
|
const toolParts = block.filter(
|
|
7110
|
-
(part) =>
|
|
7110
|
+
(part) => isToolUIPart(part) && part.providerExecuted !== true
|
|
7111
7111
|
);
|
|
7112
7112
|
if (toolParts.length > 0) {
|
|
7113
7113
|
modelMessages.push({
|
|
@@ -7129,7 +7129,7 @@ function convertToModelMessages(messages, options) {
|
|
|
7129
7129
|
outputs.push({
|
|
7130
7130
|
type: "tool-result",
|
|
7131
7131
|
toolCallId: toolPart.toolCallId,
|
|
7132
|
-
toolName:
|
|
7132
|
+
toolName: getToolName(toolPart),
|
|
7133
7133
|
output: {
|
|
7134
7134
|
type: "error-text",
|
|
7135
7135
|
value: (_b2 = toolPart.approval.reason) != null ? _b2 : "Tool execution denied."
|
|
@@ -7140,7 +7140,7 @@ function convertToModelMessages(messages, options) {
|
|
|
7140
7140
|
}
|
|
7141
7141
|
case "output-error":
|
|
7142
7142
|
case "output-available": {
|
|
7143
|
-
const toolName =
|
|
7143
|
+
const toolName = getToolName(toolPart);
|
|
7144
7144
|
outputs.push({
|
|
7145
7145
|
type: "tool-result",
|
|
7146
7146
|
toolCallId: toolPart.toolCallId,
|
|
@@ -7165,7 +7165,7 @@ function convertToModelMessages(messages, options) {
|
|
|
7165
7165
|
var processBlock = processBlock2;
|
|
7166
7166
|
let block = [];
|
|
7167
7167
|
for (const part of message.parts) {
|
|
7168
|
-
if (isTextUIPart(part) || isReasoningUIPart(part) || isFileUIPart(part) ||
|
|
7168
|
+
if (isTextUIPart(part) || isReasoningUIPart(part) || isFileUIPart(part) || isToolUIPart(part) || isDataUIPart(part)) {
|
|
7169
7169
|
block.push(part);
|
|
7170
7170
|
} else if (part.type === "step-start") {
|
|
7171
7171
|
processBlock2();
|
|
@@ -11136,7 +11136,7 @@ var AbstractChat = class {
|
|
|
11136
11136
|
var _a15, _b;
|
|
11137
11137
|
const messages = this.state.messages;
|
|
11138
11138
|
const lastMessage = messages[messages.length - 1];
|
|
11139
|
-
const updatePart = (part) =>
|
|
11139
|
+
const updatePart = (part) => isToolUIPart(part) && part.state === "approval-requested" && part.approval.id === id ? {
|
|
11140
11140
|
...part,
|
|
11141
11141
|
state: "approval-responded",
|
|
11142
11142
|
approval: { id, approved, reason }
|
|
@@ -11165,7 +11165,7 @@ var AbstractChat = class {
|
|
|
11165
11165
|
var _a15, _b;
|
|
11166
11166
|
const messages = this.state.messages;
|
|
11167
11167
|
const lastMessage = messages[messages.length - 1];
|
|
11168
|
-
const updatePart = (part) =>
|
|
11168
|
+
const updatePart = (part) => isToolUIPart(part) && part.toolCallId === toolCallId ? { ...part, state, output, errorText } : part;
|
|
11169
11169
|
this.state.replaceMessage(messages.length - 1, {
|
|
11170
11170
|
...lastMessage,
|
|
11171
11171
|
parts: lastMessage.parts.map(updatePart)
|
|
@@ -11380,7 +11380,7 @@ function lastAssistantMessageIsCompleteWithApprovalResponses({
|
|
|
11380
11380
|
const lastStepStartIndex = message.parts.reduce((lastIndex, part, index) => {
|
|
11381
11381
|
return part.type === "step-start" ? index : lastIndex;
|
|
11382
11382
|
}, -1);
|
|
11383
|
-
const lastStepToolInvocations = message.parts.slice(lastStepStartIndex + 1).filter(
|
|
11383
|
+
const lastStepToolInvocations = message.parts.slice(lastStepStartIndex + 1).filter(isToolUIPart).filter((part) => !part.providerExecuted);
|
|
11384
11384
|
return (
|
|
11385
11385
|
// has at least one tool approval response
|
|
11386
11386
|
lastStepToolInvocations.filter((part) => part.state === "approval-responded").length > 0 && // all tool approvals must have a response
|
|
@@ -11404,7 +11404,7 @@ function lastAssistantMessageIsCompleteWithToolCalls({
|
|
|
11404
11404
|
const lastStepStartIndex = message.parts.reduce((lastIndex, part, index) => {
|
|
11405
11405
|
return part.type === "step-start" ? index : lastIndex;
|
|
11406
11406
|
}, -1);
|
|
11407
|
-
const lastStepToolInvocations = message.parts.slice(lastStepStartIndex + 1).filter(
|
|
11407
|
+
const lastStepToolInvocations = message.parts.slice(lastStepStartIndex + 1).filter(isToolUIPart).filter((part) => !part.providerExecuted);
|
|
11408
11408
|
return lastStepToolInvocations.length > 0 && lastStepToolInvocations.every(
|
|
11409
11409
|
(part) => part.state === "output-available" || part.state === "output-error"
|
|
11410
11410
|
);
|
|
@@ -11516,6 +11516,7 @@ export {
|
|
|
11516
11516
|
generateId,
|
|
11517
11517
|
generateObject,
|
|
11518
11518
|
generateText,
|
|
11519
|
+
getStaticToolName,
|
|
11519
11520
|
getTextFromDataUrl,
|
|
11520
11521
|
getToolName,
|
|
11521
11522
|
getToolOrDynamicToolName,
|
|
@@ -11524,6 +11525,7 @@ export {
|
|
|
11524
11525
|
isDeepEqualData,
|
|
11525
11526
|
isFileUIPart,
|
|
11526
11527
|
isReasoningUIPart,
|
|
11528
|
+
isStaticToolUIPart,
|
|
11527
11529
|
isTextUIPart,
|
|
11528
11530
|
isToolOrDynamicToolUIPart,
|
|
11529
11531
|
isToolUIPart,
|