ai 5.0.51 → 5.0.53
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 +15 -0
- package/dist/index.d.mts +11 -8
- package/dist/index.d.ts +11 -8
- package/dist/index.js +20 -21
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +20 -21
- 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 +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
# ai
|
|
2
2
|
|
|
3
|
+
## 5.0.53
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- d335191: Extend addToolResult to support error results
|
|
8
|
+
|
|
9
|
+
## 5.0.52
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- c56822d: fix(ai): update `uiMessageChunkSchema` to satisfy the `UIMessageChunk` type
|
|
14
|
+
- 930399b: fix(ai): download files when intermediate file cannot be downloaded
|
|
15
|
+
- Updated dependencies [7ca78f1]
|
|
16
|
+
- @ai-sdk/gateway@1.0.29
|
|
17
|
+
|
|
3
18
|
## 5.0.51
|
|
4
19
|
|
|
5
20
|
### Patch Changes
|
package/dist/index.d.mts
CHANGED
|
@@ -1650,10 +1650,6 @@ declare const uiMessageChunkSchema: z.ZodUnion<readonly [z.ZodObject<{
|
|
|
1650
1650
|
errorText: z.ZodString;
|
|
1651
1651
|
providerExecuted: z.ZodOptional<z.ZodBoolean>;
|
|
1652
1652
|
dynamic: z.ZodOptional<z.ZodBoolean>;
|
|
1653
|
-
}, z.core.$strict>, z.ZodObject<{
|
|
1654
|
-
type: z.ZodLiteral<"reasoning">;
|
|
1655
|
-
text: z.ZodString;
|
|
1656
|
-
providerMetadata: z.ZodOptional<z.ZodType<_ai_sdk_provider.SharedV2ProviderMetadata, unknown, z.core.$ZodTypeInternals<_ai_sdk_provider.SharedV2ProviderMetadata, unknown>>>;
|
|
1657
1653
|
}, z.core.$strict>, z.ZodObject<{
|
|
1658
1654
|
type: z.ZodLiteral<"reasoning-start">;
|
|
1659
1655
|
id: z.ZodString;
|
|
@@ -1667,8 +1663,6 @@ declare const uiMessageChunkSchema: z.ZodUnion<readonly [z.ZodObject<{
|
|
|
1667
1663
|
type: z.ZodLiteral<"reasoning-end">;
|
|
1668
1664
|
id: z.ZodString;
|
|
1669
1665
|
providerMetadata: z.ZodOptional<z.ZodType<_ai_sdk_provider.SharedV2ProviderMetadata, unknown, z.core.$ZodTypeInternals<_ai_sdk_provider.SharedV2ProviderMetadata, unknown>>>;
|
|
1670
|
-
}, z.core.$strict>, z.ZodObject<{
|
|
1671
|
-
type: z.ZodLiteral<"reasoning-part-finish">;
|
|
1672
1666
|
}, z.core.$strict>, z.ZodObject<{
|
|
1673
1667
|
type: z.ZodLiteral<"source-url">;
|
|
1674
1668
|
sourceId: z.ZodString;
|
|
@@ -1688,7 +1682,7 @@ declare const uiMessageChunkSchema: z.ZodUnion<readonly [z.ZodObject<{
|
|
|
1688
1682
|
mediaType: z.ZodString;
|
|
1689
1683
|
providerMetadata: z.ZodOptional<z.ZodType<_ai_sdk_provider.SharedV2ProviderMetadata, unknown, z.core.$ZodTypeInternals<_ai_sdk_provider.SharedV2ProviderMetadata, unknown>>>;
|
|
1690
1684
|
}, z.core.$strict>, z.ZodObject<{
|
|
1691
|
-
type: z.
|
|
1685
|
+
type: z.ZodCustom<`data-${string}`, `data-${string}`>;
|
|
1692
1686
|
id: z.ZodOptional<z.ZodString>;
|
|
1693
1687
|
data: z.ZodUnknown;
|
|
1694
1688
|
transient: z.ZodOptional<z.ZodBoolean>;
|
|
@@ -1803,6 +1797,7 @@ type UIMessageChunk<METADATA = unknown, DATA_TYPES extends UIDataTypes = UIDataT
|
|
|
1803
1797
|
type: 'file';
|
|
1804
1798
|
url: string;
|
|
1805
1799
|
mediaType: string;
|
|
1800
|
+
providerMetadata?: ProviderMetadata;
|
|
1806
1801
|
} | DataUIMessageChunk<DATA_TYPES> | {
|
|
1807
1802
|
type: 'start-step';
|
|
1808
1803
|
} | {
|
|
@@ -4332,10 +4327,18 @@ declare abstract class AbstractChat<UI_MESSAGE extends UIMessage> {
|
|
|
4332
4327
|
* Clear the error state and set the status to ready if the chat is in an error state.
|
|
4333
4328
|
*/
|
|
4334
4329
|
clearError: () => void;
|
|
4335
|
-
addToolResult: <TOOL extends keyof InferUIMessageTools<UI_MESSAGE>>({ tool, toolCallId, output, }: {
|
|
4330
|
+
addToolResult: <TOOL extends keyof InferUIMessageTools<UI_MESSAGE>>({ state, tool, toolCallId, output, errorText, }: {
|
|
4331
|
+
state?: "output-available";
|
|
4336
4332
|
tool: TOOL;
|
|
4337
4333
|
toolCallId: string;
|
|
4338
4334
|
output: InferUIMessageTools<UI_MESSAGE>[TOOL]["output"];
|
|
4335
|
+
errorText?: never;
|
|
4336
|
+
} | {
|
|
4337
|
+
state: "output-error";
|
|
4338
|
+
tool: TOOL;
|
|
4339
|
+
toolCallId: string;
|
|
4340
|
+
output?: never;
|
|
4341
|
+
errorText: string;
|
|
4339
4342
|
}) => Promise<void>;
|
|
4340
4343
|
/**
|
|
4341
4344
|
* Abort the current request immediately, keep the generated tokens if any.
|
package/dist/index.d.ts
CHANGED
|
@@ -1650,10 +1650,6 @@ declare const uiMessageChunkSchema: z.ZodUnion<readonly [z.ZodObject<{
|
|
|
1650
1650
|
errorText: z.ZodString;
|
|
1651
1651
|
providerExecuted: z.ZodOptional<z.ZodBoolean>;
|
|
1652
1652
|
dynamic: z.ZodOptional<z.ZodBoolean>;
|
|
1653
|
-
}, z.core.$strict>, z.ZodObject<{
|
|
1654
|
-
type: z.ZodLiteral<"reasoning">;
|
|
1655
|
-
text: z.ZodString;
|
|
1656
|
-
providerMetadata: z.ZodOptional<z.ZodType<_ai_sdk_provider.SharedV2ProviderMetadata, unknown, z.core.$ZodTypeInternals<_ai_sdk_provider.SharedV2ProviderMetadata, unknown>>>;
|
|
1657
1653
|
}, z.core.$strict>, z.ZodObject<{
|
|
1658
1654
|
type: z.ZodLiteral<"reasoning-start">;
|
|
1659
1655
|
id: z.ZodString;
|
|
@@ -1667,8 +1663,6 @@ declare const uiMessageChunkSchema: z.ZodUnion<readonly [z.ZodObject<{
|
|
|
1667
1663
|
type: z.ZodLiteral<"reasoning-end">;
|
|
1668
1664
|
id: z.ZodString;
|
|
1669
1665
|
providerMetadata: z.ZodOptional<z.ZodType<_ai_sdk_provider.SharedV2ProviderMetadata, unknown, z.core.$ZodTypeInternals<_ai_sdk_provider.SharedV2ProviderMetadata, unknown>>>;
|
|
1670
|
-
}, z.core.$strict>, z.ZodObject<{
|
|
1671
|
-
type: z.ZodLiteral<"reasoning-part-finish">;
|
|
1672
1666
|
}, z.core.$strict>, z.ZodObject<{
|
|
1673
1667
|
type: z.ZodLiteral<"source-url">;
|
|
1674
1668
|
sourceId: z.ZodString;
|
|
@@ -1688,7 +1682,7 @@ declare const uiMessageChunkSchema: z.ZodUnion<readonly [z.ZodObject<{
|
|
|
1688
1682
|
mediaType: z.ZodString;
|
|
1689
1683
|
providerMetadata: z.ZodOptional<z.ZodType<_ai_sdk_provider.SharedV2ProviderMetadata, unknown, z.core.$ZodTypeInternals<_ai_sdk_provider.SharedV2ProviderMetadata, unknown>>>;
|
|
1690
1684
|
}, z.core.$strict>, z.ZodObject<{
|
|
1691
|
-
type: z.
|
|
1685
|
+
type: z.ZodCustom<`data-${string}`, `data-${string}`>;
|
|
1692
1686
|
id: z.ZodOptional<z.ZodString>;
|
|
1693
1687
|
data: z.ZodUnknown;
|
|
1694
1688
|
transient: z.ZodOptional<z.ZodBoolean>;
|
|
@@ -1803,6 +1797,7 @@ type UIMessageChunk<METADATA = unknown, DATA_TYPES extends UIDataTypes = UIDataT
|
|
|
1803
1797
|
type: 'file';
|
|
1804
1798
|
url: string;
|
|
1805
1799
|
mediaType: string;
|
|
1800
|
+
providerMetadata?: ProviderMetadata;
|
|
1806
1801
|
} | DataUIMessageChunk<DATA_TYPES> | {
|
|
1807
1802
|
type: 'start-step';
|
|
1808
1803
|
} | {
|
|
@@ -4332,10 +4327,18 @@ declare abstract class AbstractChat<UI_MESSAGE extends UIMessage> {
|
|
|
4332
4327
|
* Clear the error state and set the status to ready if the chat is in an error state.
|
|
4333
4328
|
*/
|
|
4334
4329
|
clearError: () => void;
|
|
4335
|
-
addToolResult: <TOOL extends keyof InferUIMessageTools<UI_MESSAGE>>({ tool, toolCallId, output, }: {
|
|
4330
|
+
addToolResult: <TOOL extends keyof InferUIMessageTools<UI_MESSAGE>>({ state, tool, toolCallId, output, errorText, }: {
|
|
4331
|
+
state?: "output-available";
|
|
4336
4332
|
tool: TOOL;
|
|
4337
4333
|
toolCallId: string;
|
|
4338
4334
|
output: InferUIMessageTools<UI_MESSAGE>[TOOL]["output"];
|
|
4335
|
+
errorText?: never;
|
|
4336
|
+
} | {
|
|
4337
|
+
state: "output-error";
|
|
4338
|
+
tool: TOOL;
|
|
4339
|
+
toolCallId: string;
|
|
4340
|
+
output?: never;
|
|
4341
|
+
errorText: string;
|
|
4339
4342
|
}) => Promise<void>;
|
|
4340
4343
|
/**
|
|
4341
4344
|
* Abort the current request immediately, keep the generated tokens if any.
|
package/dist/index.js
CHANGED
|
@@ -768,7 +768,7 @@ function detectMediaType({
|
|
|
768
768
|
var import_provider_utils2 = require("@ai-sdk/provider-utils");
|
|
769
769
|
|
|
770
770
|
// src/version.ts
|
|
771
|
-
var VERSION = true ? "5.0.
|
|
771
|
+
var VERSION = true ? "5.0.53" : "0.0.0-test";
|
|
772
772
|
|
|
773
773
|
// src/util/download/download.ts
|
|
774
774
|
var download = async ({ url }) => {
|
|
@@ -1058,12 +1058,12 @@ async function downloadAssets(messages, download2, supportedUrls) {
|
|
|
1058
1058
|
}));
|
|
1059
1059
|
const downloadedFiles = await download2(plannedDownloads);
|
|
1060
1060
|
return Object.fromEntries(
|
|
1061
|
-
downloadedFiles.
|
|
1062
|
-
(
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1061
|
+
downloadedFiles.map(
|
|
1062
|
+
(file, index) => file == null ? null : [
|
|
1063
|
+
plannedDownloads[index].url.toString(),
|
|
1064
|
+
{ data: file.data, mediaType: file.mediaType }
|
|
1065
|
+
]
|
|
1066
|
+
).filter((file) => file != null)
|
|
1067
1067
|
);
|
|
1068
1068
|
}
|
|
1069
1069
|
function convertPartToLanguageModelPart(part, downloadedAssets) {
|
|
@@ -2990,11 +2990,6 @@ var uiMessageChunkSchema = import_v47.z.union([
|
|
|
2990
2990
|
providerExecuted: import_v47.z.boolean().optional(),
|
|
2991
2991
|
dynamic: import_v47.z.boolean().optional()
|
|
2992
2992
|
}),
|
|
2993
|
-
import_v47.z.strictObject({
|
|
2994
|
-
type: import_v47.z.literal("reasoning"),
|
|
2995
|
-
text: import_v47.z.string(),
|
|
2996
|
-
providerMetadata: providerMetadataSchema.optional()
|
|
2997
|
-
}),
|
|
2998
2993
|
import_v47.z.strictObject({
|
|
2999
2994
|
type: import_v47.z.literal("reasoning-start"),
|
|
3000
2995
|
id: import_v47.z.string(),
|
|
@@ -3011,9 +3006,6 @@ var uiMessageChunkSchema = import_v47.z.union([
|
|
|
3011
3006
|
id: import_v47.z.string(),
|
|
3012
3007
|
providerMetadata: providerMetadataSchema.optional()
|
|
3013
3008
|
}),
|
|
3014
|
-
import_v47.z.strictObject({
|
|
3015
|
-
type: import_v47.z.literal("reasoning-part-finish")
|
|
3016
|
-
}),
|
|
3017
3009
|
import_v47.z.strictObject({
|
|
3018
3010
|
type: import_v47.z.literal("source-url"),
|
|
3019
3011
|
sourceId: import_v47.z.string(),
|
|
@@ -3036,7 +3028,10 @@ var uiMessageChunkSchema = import_v47.z.union([
|
|
|
3036
3028
|
providerMetadata: providerMetadataSchema.optional()
|
|
3037
3029
|
}),
|
|
3038
3030
|
import_v47.z.strictObject({
|
|
3039
|
-
type: import_v47.z.
|
|
3031
|
+
type: import_v47.z.custom(
|
|
3032
|
+
(value) => typeof value === "string" && value.startsWith("data-"),
|
|
3033
|
+
{ message: 'Type must start with "data-"' }
|
|
3034
|
+
),
|
|
3040
3035
|
id: import_v47.z.string().optional(),
|
|
3041
3036
|
data: import_v47.z.unknown(),
|
|
3042
3037
|
transient: import_v47.z.boolean().optional()
|
|
@@ -9726,9 +9721,11 @@ var AbstractChat = class {
|
|
|
9726
9721
|
}
|
|
9727
9722
|
};
|
|
9728
9723
|
this.addToolResult = async ({
|
|
9724
|
+
state = "output-available",
|
|
9729
9725
|
tool: tool3,
|
|
9730
9726
|
toolCallId,
|
|
9731
|
-
output
|
|
9727
|
+
output,
|
|
9728
|
+
errorText
|
|
9732
9729
|
}) => this.jobExecutor.run(async () => {
|
|
9733
9730
|
var _a17, _b;
|
|
9734
9731
|
const messages = this.state.messages;
|
|
@@ -9736,16 +9733,16 @@ var AbstractChat = class {
|
|
|
9736
9733
|
this.state.replaceMessage(messages.length - 1, {
|
|
9737
9734
|
...lastMessage,
|
|
9738
9735
|
parts: lastMessage.parts.map(
|
|
9739
|
-
(part) => isToolOrDynamicToolUIPart(part) && part.toolCallId === toolCallId ? { ...part, state
|
|
9736
|
+
(part) => isToolOrDynamicToolUIPart(part) && part.toolCallId === toolCallId ? { ...part, state, output, errorText } : part
|
|
9740
9737
|
)
|
|
9741
9738
|
});
|
|
9742
9739
|
if (this.activeResponse) {
|
|
9743
9740
|
this.activeResponse.state.message.parts = this.activeResponse.state.message.parts.map(
|
|
9744
9741
|
(part) => isToolOrDynamicToolUIPart(part) && part.toolCallId === toolCallId ? {
|
|
9745
9742
|
...part,
|
|
9746
|
-
state
|
|
9743
|
+
state,
|
|
9747
9744
|
output,
|
|
9748
|
-
errorText
|
|
9745
|
+
errorText
|
|
9749
9746
|
} : part
|
|
9750
9747
|
);
|
|
9751
9748
|
}
|
|
@@ -9954,7 +9951,9 @@ function lastAssistantMessageIsCompleteWithToolCalls({
|
|
|
9954
9951
|
return part.type === "step-start" ? index : lastIndex;
|
|
9955
9952
|
}, -1);
|
|
9956
9953
|
const lastStepToolInvocations = message.parts.slice(lastStepStartIndex + 1).filter(isToolOrDynamicToolUIPart);
|
|
9957
|
-
return lastStepToolInvocations.length > 0 && lastStepToolInvocations.every(
|
|
9954
|
+
return lastStepToolInvocations.length > 0 && lastStepToolInvocations.every(
|
|
9955
|
+
(part) => part.state === "output-available" || part.state === "output-error"
|
|
9956
|
+
);
|
|
9958
9957
|
}
|
|
9959
9958
|
|
|
9960
9959
|
// src/ui/transform-text-to-ui-message-stream.ts
|