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.mjs
CHANGED
|
@@ -12,7 +12,6 @@ import {
|
|
|
12
12
|
dynamicTool as dynamicTool2,
|
|
13
13
|
generateId as generateId2,
|
|
14
14
|
jsonSchema as jsonSchema2,
|
|
15
|
-
parseJsonEventStream as parseJsonEventStream3,
|
|
16
15
|
tool as tool2,
|
|
17
16
|
zodSchema
|
|
18
17
|
} from "@ai-sdk/provider-utils";
|
|
@@ -679,7 +678,7 @@ import {
|
|
|
679
678
|
} from "@ai-sdk/provider-utils";
|
|
680
679
|
|
|
681
680
|
// src/version.ts
|
|
682
|
-
var VERSION = true ? "5.0.
|
|
681
|
+
var VERSION = true ? "5.1.0-beta.1" : "0.0.0-test";
|
|
683
682
|
|
|
684
683
|
// src/util/download/download.ts
|
|
685
684
|
var download = async ({ url }) => {
|
|
@@ -972,12 +971,12 @@ async function downloadAssets(messages, download2, supportedUrls) {
|
|
|
972
971
|
}));
|
|
973
972
|
const downloadedFiles = await download2(plannedDownloads);
|
|
974
973
|
return Object.fromEntries(
|
|
975
|
-
downloadedFiles.
|
|
976
|
-
(
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
)
|
|
974
|
+
downloadedFiles.filter(
|
|
975
|
+
(downloadedFile) => (downloadedFile == null ? void 0 : downloadedFile.data) != null
|
|
976
|
+
).map(({ data, mediaType }, index) => [
|
|
977
|
+
plannedDownloads[index].url.toString(),
|
|
978
|
+
{ data, mediaType }
|
|
979
|
+
])
|
|
981
980
|
);
|
|
982
981
|
}
|
|
983
982
|
function convertPartToLanguageModelPart(part, downloadedAssets) {
|
|
@@ -2923,6 +2922,11 @@ var uiMessageChunkSchema = z7.union([
|
|
|
2923
2922
|
providerExecuted: z7.boolean().optional(),
|
|
2924
2923
|
dynamic: z7.boolean().optional()
|
|
2925
2924
|
}),
|
|
2925
|
+
z7.strictObject({
|
|
2926
|
+
type: z7.literal("reasoning"),
|
|
2927
|
+
text: z7.string(),
|
|
2928
|
+
providerMetadata: providerMetadataSchema.optional()
|
|
2929
|
+
}),
|
|
2926
2930
|
z7.strictObject({
|
|
2927
2931
|
type: z7.literal("reasoning-start"),
|
|
2928
2932
|
id: z7.string(),
|
|
@@ -2939,6 +2943,9 @@ var uiMessageChunkSchema = z7.union([
|
|
|
2939
2943
|
id: z7.string(),
|
|
2940
2944
|
providerMetadata: providerMetadataSchema.optional()
|
|
2941
2945
|
}),
|
|
2946
|
+
z7.strictObject({
|
|
2947
|
+
type: z7.literal("reasoning-part-finish")
|
|
2948
|
+
}),
|
|
2942
2949
|
z7.strictObject({
|
|
2943
2950
|
type: z7.literal("source-url"),
|
|
2944
2951
|
sourceId: z7.string(),
|
|
@@ -2961,10 +2968,7 @@ var uiMessageChunkSchema = z7.union([
|
|
|
2961
2968
|
providerMetadata: providerMetadataSchema.optional()
|
|
2962
2969
|
}),
|
|
2963
2970
|
z7.strictObject({
|
|
2964
|
-
type: z7.
|
|
2965
|
-
(value) => typeof value === "string" && value.startsWith("data-"),
|
|
2966
|
-
{ message: 'Type must start with "data-"' }
|
|
2967
|
-
),
|
|
2971
|
+
type: z7.string().startsWith("data-"),
|
|
2968
2972
|
id: z7.string().optional(),
|
|
2969
2973
|
data: z7.unknown(),
|
|
2970
2974
|
transient: z7.boolean().optional()
|
|
@@ -4593,7 +4597,7 @@ var DefaultStreamTextResult = class {
|
|
|
4593
4597
|
let activeReasoningContent = {};
|
|
4594
4598
|
const eventProcessor = new TransformStream({
|
|
4595
4599
|
async transform(chunk, controller) {
|
|
4596
|
-
var _a17, _b, _c
|
|
4600
|
+
var _a17, _b, _c;
|
|
4597
4601
|
controller.enqueue(chunk);
|
|
4598
4602
|
const { part } = chunk;
|
|
4599
4603
|
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") {
|
|
@@ -4626,18 +4630,6 @@ var DefaultStreamTextResult = class {
|
|
|
4626
4630
|
activeText.providerMetadata = (_a17 = part.providerMetadata) != null ? _a17 : activeText.providerMetadata;
|
|
4627
4631
|
}
|
|
4628
4632
|
if (part.type === "text-end") {
|
|
4629
|
-
const activeText = activeTextContent[part.id];
|
|
4630
|
-
if (activeText == null) {
|
|
4631
|
-
controller.enqueue({
|
|
4632
|
-
part: {
|
|
4633
|
-
type: "error",
|
|
4634
|
-
error: `text part ${part.id} not found`
|
|
4635
|
-
},
|
|
4636
|
-
partialOutput: void 0
|
|
4637
|
-
});
|
|
4638
|
-
return;
|
|
4639
|
-
}
|
|
4640
|
-
activeText.providerMetadata = (_b = part.providerMetadata) != null ? _b : activeText.providerMetadata;
|
|
4641
4633
|
delete activeTextContent[part.id];
|
|
4642
4634
|
}
|
|
4643
4635
|
if (part.type === "reasoning-start") {
|
|
@@ -4661,7 +4653,7 @@ var DefaultStreamTextResult = class {
|
|
|
4661
4653
|
return;
|
|
4662
4654
|
}
|
|
4663
4655
|
activeReasoning.text += part.text;
|
|
4664
|
-
activeReasoning.providerMetadata = (
|
|
4656
|
+
activeReasoning.providerMetadata = (_b = part.providerMetadata) != null ? _b : activeReasoning.providerMetadata;
|
|
4665
4657
|
}
|
|
4666
4658
|
if (part.type === "reasoning-end") {
|
|
4667
4659
|
const activeReasoning = activeReasoningContent[part.id];
|
|
@@ -4675,7 +4667,7 @@ var DefaultStreamTextResult = class {
|
|
|
4675
4667
|
});
|
|
4676
4668
|
return;
|
|
4677
4669
|
}
|
|
4678
|
-
activeReasoning.providerMetadata = (
|
|
4670
|
+
activeReasoning.providerMetadata = (_c = part.providerMetadata) != null ? _c : activeReasoning.providerMetadata;
|
|
4679
4671
|
delete activeReasoningContent[part.id];
|
|
4680
4672
|
}
|
|
4681
4673
|
if (part.type === "file") {
|
|
@@ -9709,11 +9701,9 @@ var AbstractChat = class {
|
|
|
9709
9701
|
}
|
|
9710
9702
|
};
|
|
9711
9703
|
this.addToolResult = async ({
|
|
9712
|
-
state = "output-available",
|
|
9713
9704
|
tool: tool3,
|
|
9714
9705
|
toolCallId,
|
|
9715
|
-
output
|
|
9716
|
-
errorText
|
|
9706
|
+
output
|
|
9717
9707
|
}) => this.jobExecutor.run(async () => {
|
|
9718
9708
|
var _a17, _b;
|
|
9719
9709
|
const messages = this.state.messages;
|
|
@@ -9721,16 +9711,16 @@ var AbstractChat = class {
|
|
|
9721
9711
|
this.state.replaceMessage(messages.length - 1, {
|
|
9722
9712
|
...lastMessage,
|
|
9723
9713
|
parts: lastMessage.parts.map(
|
|
9724
|
-
(part) => isToolOrDynamicToolUIPart(part) && part.toolCallId === toolCallId ? { ...part, state
|
|
9714
|
+
(part) => isToolOrDynamicToolUIPart(part) && part.toolCallId === toolCallId ? { ...part, state: "output-available", output } : part
|
|
9725
9715
|
)
|
|
9726
9716
|
});
|
|
9727
9717
|
if (this.activeResponse) {
|
|
9728
9718
|
this.activeResponse.state.message.parts = this.activeResponse.state.message.parts.map(
|
|
9729
9719
|
(part) => isToolOrDynamicToolUIPart(part) && part.toolCallId === toolCallId ? {
|
|
9730
9720
|
...part,
|
|
9731
|
-
state,
|
|
9721
|
+
state: "output-available",
|
|
9732
9722
|
output,
|
|
9733
|
-
errorText
|
|
9723
|
+
errorText: void 0
|
|
9734
9724
|
} : part
|
|
9735
9725
|
);
|
|
9736
9726
|
}
|
|
@@ -9939,9 +9929,7 @@ function lastAssistantMessageIsCompleteWithToolCalls({
|
|
|
9939
9929
|
return part.type === "step-start" ? index : lastIndex;
|
|
9940
9930
|
}, -1);
|
|
9941
9931
|
const lastStepToolInvocations = message.parts.slice(lastStepStartIndex + 1).filter(isToolOrDynamicToolUIPart);
|
|
9942
|
-
return lastStepToolInvocations.length > 0 && lastStepToolInvocations.every(
|
|
9943
|
-
(part) => part.state === "output-available" || part.state === "output-error"
|
|
9944
|
-
);
|
|
9932
|
+
return lastStepToolInvocations.length > 0 && lastStepToolInvocations.every((part) => part.state === "output-available");
|
|
9945
9933
|
}
|
|
9946
9934
|
|
|
9947
9935
|
// src/ui/transform-text-to-ui-message-stream.ts
|
|
@@ -10463,7 +10451,6 @@ export {
|
|
|
10463
10451
|
jsonSchema2 as jsonSchema,
|
|
10464
10452
|
lastAssistantMessageIsCompleteWithToolCalls,
|
|
10465
10453
|
modelMessageSchema,
|
|
10466
|
-
parseJsonEventStream3 as parseJsonEventStream,
|
|
10467
10454
|
parsePartialJson,
|
|
10468
10455
|
pipeTextStreamToResponse,
|
|
10469
10456
|
pipeUIMessageStreamToResponse,
|
|
@@ -10478,7 +10465,6 @@ export {
|
|
|
10478
10465
|
systemModelMessageSchema,
|
|
10479
10466
|
tool2 as tool,
|
|
10480
10467
|
toolModelMessageSchema,
|
|
10481
|
-
uiMessageChunkSchema,
|
|
10482
10468
|
userModelMessageSchema,
|
|
10483
10469
|
validateUIMessages,
|
|
10484
10470
|
wrapLanguageModel,
|