ai 5.0.56 → 5.1.0-beta.1
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 -69
- package/dist/index.d.mts +34 -134
- package/dist/index.d.ts +34 -134
- package/dist/index.js +24 -39
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +24 -38
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.js +7 -7
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +7 -7
- package/dist/internal/index.mjs.map +1 -1
- package/package.json +7 -7
package/dist/index.js
CHANGED
|
@@ -103,7 +103,6 @@ __export(src_exports, {
|
|
|
103
103
|
jsonSchema: () => import_provider_utils35.jsonSchema,
|
|
104
104
|
lastAssistantMessageIsCompleteWithToolCalls: () => lastAssistantMessageIsCompleteWithToolCalls,
|
|
105
105
|
modelMessageSchema: () => modelMessageSchema,
|
|
106
|
-
parseJsonEventStream: () => import_provider_utils35.parseJsonEventStream,
|
|
107
106
|
parsePartialJson: () => parsePartialJson,
|
|
108
107
|
pipeTextStreamToResponse: () => pipeTextStreamToResponse,
|
|
109
108
|
pipeUIMessageStreamToResponse: () => pipeUIMessageStreamToResponse,
|
|
@@ -118,7 +117,6 @@ __export(src_exports, {
|
|
|
118
117
|
systemModelMessageSchema: () => systemModelMessageSchema,
|
|
119
118
|
tool: () => import_provider_utils35.tool,
|
|
120
119
|
toolModelMessageSchema: () => toolModelMessageSchema,
|
|
121
|
-
uiMessageChunkSchema: () => uiMessageChunkSchema,
|
|
122
120
|
userModelMessageSchema: () => userModelMessageSchema,
|
|
123
121
|
validateUIMessages: () => validateUIMessages,
|
|
124
122
|
wrapLanguageModel: () => wrapLanguageModel,
|
|
@@ -768,7 +766,7 @@ function detectMediaType({
|
|
|
768
766
|
var import_provider_utils2 = require("@ai-sdk/provider-utils");
|
|
769
767
|
|
|
770
768
|
// src/version.ts
|
|
771
|
-
var VERSION = true ? "5.0.
|
|
769
|
+
var VERSION = true ? "5.1.0-beta.1" : "0.0.0-test";
|
|
772
770
|
|
|
773
771
|
// src/util/download/download.ts
|
|
774
772
|
var download = async ({ url }) => {
|
|
@@ -1058,12 +1056,12 @@ async function downloadAssets(messages, download2, supportedUrls) {
|
|
|
1058
1056
|
}));
|
|
1059
1057
|
const downloadedFiles = await download2(plannedDownloads);
|
|
1060
1058
|
return Object.fromEntries(
|
|
1061
|
-
downloadedFiles.
|
|
1062
|
-
(
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
)
|
|
1059
|
+
downloadedFiles.filter(
|
|
1060
|
+
(downloadedFile) => (downloadedFile == null ? void 0 : downloadedFile.data) != null
|
|
1061
|
+
).map(({ data, mediaType }, index) => [
|
|
1062
|
+
plannedDownloads[index].url.toString(),
|
|
1063
|
+
{ data, mediaType }
|
|
1064
|
+
])
|
|
1067
1065
|
);
|
|
1068
1066
|
}
|
|
1069
1067
|
function convertPartToLanguageModelPart(part, downloadedAssets) {
|
|
@@ -2990,6 +2988,11 @@ var uiMessageChunkSchema = import_v47.z.union([
|
|
|
2990
2988
|
providerExecuted: import_v47.z.boolean().optional(),
|
|
2991
2989
|
dynamic: import_v47.z.boolean().optional()
|
|
2992
2990
|
}),
|
|
2991
|
+
import_v47.z.strictObject({
|
|
2992
|
+
type: import_v47.z.literal("reasoning"),
|
|
2993
|
+
text: import_v47.z.string(),
|
|
2994
|
+
providerMetadata: providerMetadataSchema.optional()
|
|
2995
|
+
}),
|
|
2993
2996
|
import_v47.z.strictObject({
|
|
2994
2997
|
type: import_v47.z.literal("reasoning-start"),
|
|
2995
2998
|
id: import_v47.z.string(),
|
|
@@ -3006,6 +3009,9 @@ var uiMessageChunkSchema = import_v47.z.union([
|
|
|
3006
3009
|
id: import_v47.z.string(),
|
|
3007
3010
|
providerMetadata: providerMetadataSchema.optional()
|
|
3008
3011
|
}),
|
|
3012
|
+
import_v47.z.strictObject({
|
|
3013
|
+
type: import_v47.z.literal("reasoning-part-finish")
|
|
3014
|
+
}),
|
|
3009
3015
|
import_v47.z.strictObject({
|
|
3010
3016
|
type: import_v47.z.literal("source-url"),
|
|
3011
3017
|
sourceId: import_v47.z.string(),
|
|
@@ -3028,10 +3034,7 @@ var uiMessageChunkSchema = import_v47.z.union([
|
|
|
3028
3034
|
providerMetadata: providerMetadataSchema.optional()
|
|
3029
3035
|
}),
|
|
3030
3036
|
import_v47.z.strictObject({
|
|
3031
|
-
type: import_v47.z.
|
|
3032
|
-
(value) => typeof value === "string" && value.startsWith("data-"),
|
|
3033
|
-
{ message: 'Type must start with "data-"' }
|
|
3034
|
-
),
|
|
3037
|
+
type: import_v47.z.string().startsWith("data-"),
|
|
3035
3038
|
id: import_v47.z.string().optional(),
|
|
3036
3039
|
data: import_v47.z.unknown(),
|
|
3037
3040
|
transient: import_v47.z.boolean().optional()
|
|
@@ -4656,7 +4659,7 @@ var DefaultStreamTextResult = class {
|
|
|
4656
4659
|
let activeReasoningContent = {};
|
|
4657
4660
|
const eventProcessor = new TransformStream({
|
|
4658
4661
|
async transform(chunk, controller) {
|
|
4659
|
-
var _a17, _b, _c
|
|
4662
|
+
var _a17, _b, _c;
|
|
4660
4663
|
controller.enqueue(chunk);
|
|
4661
4664
|
const { part } = chunk;
|
|
4662
4665
|
if (part.type === "text-delta" || part.type === "reasoning-delta" || part.type === "source" || part.type === "tool-call" || part.type === "tool-result" || part.type === "tool-input-start" || part.type === "tool-input-delta" || part.type === "raw") {
|
|
@@ -4689,18 +4692,6 @@ var DefaultStreamTextResult = class {
|
|
|
4689
4692
|
activeText.providerMetadata = (_a17 = part.providerMetadata) != null ? _a17 : activeText.providerMetadata;
|
|
4690
4693
|
}
|
|
4691
4694
|
if (part.type === "text-end") {
|
|
4692
|
-
const activeText = activeTextContent[part.id];
|
|
4693
|
-
if (activeText == null) {
|
|
4694
|
-
controller.enqueue({
|
|
4695
|
-
part: {
|
|
4696
|
-
type: "error",
|
|
4697
|
-
error: `text part ${part.id} not found`
|
|
4698
|
-
},
|
|
4699
|
-
partialOutput: void 0
|
|
4700
|
-
});
|
|
4701
|
-
return;
|
|
4702
|
-
}
|
|
4703
|
-
activeText.providerMetadata = (_b = part.providerMetadata) != null ? _b : activeText.providerMetadata;
|
|
4704
4695
|
delete activeTextContent[part.id];
|
|
4705
4696
|
}
|
|
4706
4697
|
if (part.type === "reasoning-start") {
|
|
@@ -4724,7 +4715,7 @@ var DefaultStreamTextResult = class {
|
|
|
4724
4715
|
return;
|
|
4725
4716
|
}
|
|
4726
4717
|
activeReasoning.text += part.text;
|
|
4727
|
-
activeReasoning.providerMetadata = (
|
|
4718
|
+
activeReasoning.providerMetadata = (_b = part.providerMetadata) != null ? _b : activeReasoning.providerMetadata;
|
|
4728
4719
|
}
|
|
4729
4720
|
if (part.type === "reasoning-end") {
|
|
4730
4721
|
const activeReasoning = activeReasoningContent[part.id];
|
|
@@ -4738,7 +4729,7 @@ var DefaultStreamTextResult = class {
|
|
|
4738
4729
|
});
|
|
4739
4730
|
return;
|
|
4740
4731
|
}
|
|
4741
|
-
activeReasoning.providerMetadata = (
|
|
4732
|
+
activeReasoning.providerMetadata = (_c = part.providerMetadata) != null ? _c : activeReasoning.providerMetadata;
|
|
4742
4733
|
delete activeReasoningContent[part.id];
|
|
4743
4734
|
}
|
|
4744
4735
|
if (part.type === "file") {
|
|
@@ -9733,11 +9724,9 @@ var AbstractChat = class {
|
|
|
9733
9724
|
}
|
|
9734
9725
|
};
|
|
9735
9726
|
this.addToolResult = async ({
|
|
9736
|
-
state = "output-available",
|
|
9737
9727
|
tool: tool3,
|
|
9738
9728
|
toolCallId,
|
|
9739
|
-
output
|
|
9740
|
-
errorText
|
|
9729
|
+
output
|
|
9741
9730
|
}) => this.jobExecutor.run(async () => {
|
|
9742
9731
|
var _a17, _b;
|
|
9743
9732
|
const messages = this.state.messages;
|
|
@@ -9745,16 +9734,16 @@ var AbstractChat = class {
|
|
|
9745
9734
|
this.state.replaceMessage(messages.length - 1, {
|
|
9746
9735
|
...lastMessage,
|
|
9747
9736
|
parts: lastMessage.parts.map(
|
|
9748
|
-
(part) => isToolOrDynamicToolUIPart(part) && part.toolCallId === toolCallId ? { ...part, state
|
|
9737
|
+
(part) => isToolOrDynamicToolUIPart(part) && part.toolCallId === toolCallId ? { ...part, state: "output-available", output } : part
|
|
9749
9738
|
)
|
|
9750
9739
|
});
|
|
9751
9740
|
if (this.activeResponse) {
|
|
9752
9741
|
this.activeResponse.state.message.parts = this.activeResponse.state.message.parts.map(
|
|
9753
9742
|
(part) => isToolOrDynamicToolUIPart(part) && part.toolCallId === toolCallId ? {
|
|
9754
9743
|
...part,
|
|
9755
|
-
state,
|
|
9744
|
+
state: "output-available",
|
|
9756
9745
|
output,
|
|
9757
|
-
errorText
|
|
9746
|
+
errorText: void 0
|
|
9758
9747
|
} : part
|
|
9759
9748
|
);
|
|
9760
9749
|
}
|
|
@@ -9963,9 +9952,7 @@ function lastAssistantMessageIsCompleteWithToolCalls({
|
|
|
9963
9952
|
return part.type === "step-start" ? index : lastIndex;
|
|
9964
9953
|
}, -1);
|
|
9965
9954
|
const lastStepToolInvocations = message.parts.slice(lastStepStartIndex + 1).filter(isToolOrDynamicToolUIPart);
|
|
9966
|
-
return lastStepToolInvocations.length > 0 && lastStepToolInvocations.every(
|
|
9967
|
-
(part) => part.state === "output-available" || part.state === "output-error"
|
|
9968
|
-
);
|
|
9955
|
+
return lastStepToolInvocations.length > 0 && lastStepToolInvocations.every((part) => part.state === "output-available");
|
|
9969
9956
|
}
|
|
9970
9957
|
|
|
9971
9958
|
// src/ui/transform-text-to-ui-message-stream.ts
|
|
@@ -10483,7 +10470,6 @@ function readUIMessageStream({
|
|
|
10483
10470
|
jsonSchema,
|
|
10484
10471
|
lastAssistantMessageIsCompleteWithToolCalls,
|
|
10485
10472
|
modelMessageSchema,
|
|
10486
|
-
parseJsonEventStream,
|
|
10487
10473
|
parsePartialJson,
|
|
10488
10474
|
pipeTextStreamToResponse,
|
|
10489
10475
|
pipeUIMessageStreamToResponse,
|
|
@@ -10498,7 +10484,6 @@ function readUIMessageStream({
|
|
|
10498
10484
|
systemModelMessageSchema,
|
|
10499
10485
|
tool,
|
|
10500
10486
|
toolModelMessageSchema,
|
|
10501
|
-
uiMessageChunkSchema,
|
|
10502
10487
|
userModelMessageSchema,
|
|
10503
10488
|
validateUIMessages,
|
|
10504
10489
|
wrapLanguageModel,
|