ai 5.0.55 → 5.1.0-beta.0
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 +7 -67
- package/dist/index.d.mts +34 -156
- package/dist/index.d.ts +34 -156
- package/dist/index.js +79 -120
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +79 -118
- 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 +5 -5
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.0" : "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()
|
|
@@ -9697,11 +9701,9 @@ var AbstractChat = class {
|
|
|
9697
9701
|
}
|
|
9698
9702
|
};
|
|
9699
9703
|
this.addToolResult = async ({
|
|
9700
|
-
state = "output-available",
|
|
9701
9704
|
tool: tool3,
|
|
9702
9705
|
toolCallId,
|
|
9703
|
-
output
|
|
9704
|
-
errorText
|
|
9706
|
+
output
|
|
9705
9707
|
}) => this.jobExecutor.run(async () => {
|
|
9706
9708
|
var _a17, _b;
|
|
9707
9709
|
const messages = this.state.messages;
|
|
@@ -9709,16 +9711,16 @@ var AbstractChat = class {
|
|
|
9709
9711
|
this.state.replaceMessage(messages.length - 1, {
|
|
9710
9712
|
...lastMessage,
|
|
9711
9713
|
parts: lastMessage.parts.map(
|
|
9712
|
-
(part) => isToolOrDynamicToolUIPart(part) && part.toolCallId === toolCallId ? { ...part, state
|
|
9714
|
+
(part) => isToolOrDynamicToolUIPart(part) && part.toolCallId === toolCallId ? { ...part, state: "output-available", output } : part
|
|
9713
9715
|
)
|
|
9714
9716
|
});
|
|
9715
9717
|
if (this.activeResponse) {
|
|
9716
9718
|
this.activeResponse.state.message.parts = this.activeResponse.state.message.parts.map(
|
|
9717
9719
|
(part) => isToolOrDynamicToolUIPart(part) && part.toolCallId === toolCallId ? {
|
|
9718
9720
|
...part,
|
|
9719
|
-
state,
|
|
9721
|
+
state: "output-available",
|
|
9720
9722
|
output,
|
|
9721
|
-
errorText
|
|
9723
|
+
errorText: void 0
|
|
9722
9724
|
} : part
|
|
9723
9725
|
);
|
|
9724
9726
|
}
|
|
@@ -9927,9 +9929,7 @@ function lastAssistantMessageIsCompleteWithToolCalls({
|
|
|
9927
9929
|
return part.type === "step-start" ? index : lastIndex;
|
|
9928
9930
|
}, -1);
|
|
9929
9931
|
const lastStepToolInvocations = message.parts.slice(lastStepStartIndex + 1).filter(isToolOrDynamicToolUIPart);
|
|
9930
|
-
return lastStepToolInvocations.length > 0 && lastStepToolInvocations.every(
|
|
9931
|
-
(part) => part.state === "output-available" || part.state === "output-error"
|
|
9932
|
-
);
|
|
9932
|
+
return lastStepToolInvocations.length > 0 && lastStepToolInvocations.every((part) => part.state === "output-available");
|
|
9933
9933
|
}
|
|
9934
9934
|
|
|
9935
9935
|
// src/ui/transform-text-to-ui-message-stream.ts
|
|
@@ -10117,118 +10117,82 @@ var uiMessageSchema = z10.object({
|
|
|
10117
10117
|
])
|
|
10118
10118
|
)
|
|
10119
10119
|
});
|
|
10120
|
-
async function
|
|
10120
|
+
async function validateUIMessages({
|
|
10121
10121
|
messages,
|
|
10122
10122
|
metadataSchema,
|
|
10123
10123
|
dataSchemas,
|
|
10124
10124
|
tools
|
|
10125
10125
|
}) {
|
|
10126
|
-
|
|
10127
|
-
|
|
10128
|
-
|
|
10129
|
-
success: false,
|
|
10130
|
-
error: new InvalidArgumentError({
|
|
10131
|
-
parameter: "messages",
|
|
10132
|
-
value: messages,
|
|
10133
|
-
message: "messages parameter must be provided"
|
|
10134
|
-
})
|
|
10135
|
-
};
|
|
10136
|
-
}
|
|
10137
|
-
const validatedMessages = await validateTypes2({
|
|
10126
|
+
if (messages == null) {
|
|
10127
|
+
throw new InvalidArgumentError({
|
|
10128
|
+
parameter: "messages",
|
|
10138
10129
|
value: messages,
|
|
10139
|
-
|
|
10130
|
+
message: "messages parameter must be provided"
|
|
10140
10131
|
});
|
|
10141
|
-
|
|
10142
|
-
|
|
10132
|
+
}
|
|
10133
|
+
const validatedMessages = await validateTypes2({
|
|
10134
|
+
value: messages,
|
|
10135
|
+
schema: z10.array(uiMessageSchema)
|
|
10136
|
+
});
|
|
10137
|
+
if (metadataSchema) {
|
|
10138
|
+
for (const message of validatedMessages) {
|
|
10139
|
+
await validateTypes2({
|
|
10140
|
+
value: message.metadata,
|
|
10141
|
+
schema: metadataSchema
|
|
10142
|
+
});
|
|
10143
|
+
}
|
|
10144
|
+
}
|
|
10145
|
+
if (dataSchemas) {
|
|
10146
|
+
for (const message of validatedMessages) {
|
|
10147
|
+
const dataParts = message.parts.filter(
|
|
10148
|
+
(part) => part.type.startsWith("data-")
|
|
10149
|
+
);
|
|
10150
|
+
for (const dataPart of dataParts) {
|
|
10151
|
+
const dataName = dataPart.type.slice(5);
|
|
10152
|
+
const dataSchema = dataSchemas[dataName];
|
|
10153
|
+
if (!dataSchema) {
|
|
10154
|
+
throw new TypeValidationError4({
|
|
10155
|
+
value: dataPart.data,
|
|
10156
|
+
cause: `No data schema found for data part ${dataName}`
|
|
10157
|
+
});
|
|
10158
|
+
}
|
|
10143
10159
|
await validateTypes2({
|
|
10144
|
-
value:
|
|
10145
|
-
schema:
|
|
10160
|
+
value: dataPart.data,
|
|
10161
|
+
schema: dataSchema
|
|
10146
10162
|
});
|
|
10147
10163
|
}
|
|
10148
10164
|
}
|
|
10149
|
-
|
|
10150
|
-
|
|
10151
|
-
|
|
10152
|
-
|
|
10153
|
-
)
|
|
10154
|
-
|
|
10155
|
-
|
|
10156
|
-
|
|
10157
|
-
|
|
10158
|
-
|
|
10159
|
-
|
|
10160
|
-
|
|
10161
|
-
|
|
10162
|
-
|
|
10163
|
-
|
|
10164
|
-
|
|
10165
|
-
}
|
|
10165
|
+
}
|
|
10166
|
+
if (tools) {
|
|
10167
|
+
for (const message of validatedMessages) {
|
|
10168
|
+
const toolParts = message.parts.filter(
|
|
10169
|
+
(part) => part.type.startsWith("tool-")
|
|
10170
|
+
);
|
|
10171
|
+
for (const toolPart of toolParts) {
|
|
10172
|
+
const toolName = toolPart.type.slice(5);
|
|
10173
|
+
const tool3 = tools[toolName];
|
|
10174
|
+
if (!tool3) {
|
|
10175
|
+
throw new TypeValidationError4({
|
|
10176
|
+
value: toolPart.input,
|
|
10177
|
+
cause: `No tool schema found for tool part ${toolName}`
|
|
10178
|
+
});
|
|
10179
|
+
}
|
|
10180
|
+
if (toolPart.state === "input-available" || toolPart.state === "output-available" || toolPart.state === "output-error") {
|
|
10166
10181
|
await validateTypes2({
|
|
10167
|
-
value:
|
|
10168
|
-
schema:
|
|
10182
|
+
value: toolPart.input,
|
|
10183
|
+
schema: tool3.inputSchema
|
|
10169
10184
|
});
|
|
10170
10185
|
}
|
|
10171
|
-
|
|
10172
|
-
|
|
10173
|
-
|
|
10174
|
-
|
|
10175
|
-
|
|
10176
|
-
(part) => part.type.startsWith("tool-")
|
|
10177
|
-
);
|
|
10178
|
-
for (const toolPart of toolParts) {
|
|
10179
|
-
const toolName = toolPart.type.slice(5);
|
|
10180
|
-
const tool3 = tools[toolName];
|
|
10181
|
-
if (!tool3) {
|
|
10182
|
-
return {
|
|
10183
|
-
success: false,
|
|
10184
|
-
error: new TypeValidationError4({
|
|
10185
|
-
value: toolPart.input,
|
|
10186
|
-
cause: `No tool schema found for tool part ${toolName}`
|
|
10187
|
-
})
|
|
10188
|
-
};
|
|
10189
|
-
}
|
|
10190
|
-
if (toolPart.state === "input-available" || toolPart.state === "output-available" || toolPart.state === "output-error") {
|
|
10191
|
-
await validateTypes2({
|
|
10192
|
-
value: toolPart.input,
|
|
10193
|
-
schema: tool3.inputSchema
|
|
10194
|
-
});
|
|
10195
|
-
}
|
|
10196
|
-
if (toolPart.state === "output-available" && tool3.outputSchema) {
|
|
10197
|
-
await validateTypes2({
|
|
10198
|
-
value: toolPart.output,
|
|
10199
|
-
schema: tool3.outputSchema
|
|
10200
|
-
});
|
|
10201
|
-
}
|
|
10186
|
+
if (toolPart.state === "output-available" && tool3.outputSchema) {
|
|
10187
|
+
await validateTypes2({
|
|
10188
|
+
value: toolPart.output,
|
|
10189
|
+
schema: tool3.outputSchema
|
|
10190
|
+
});
|
|
10202
10191
|
}
|
|
10203
10192
|
}
|
|
10204
10193
|
}
|
|
10205
|
-
return {
|
|
10206
|
-
success: true,
|
|
10207
|
-
data: validatedMessages
|
|
10208
|
-
};
|
|
10209
|
-
} catch (error) {
|
|
10210
|
-
const err = error;
|
|
10211
|
-
return {
|
|
10212
|
-
success: false,
|
|
10213
|
-
error: err
|
|
10214
|
-
};
|
|
10215
10194
|
}
|
|
10216
|
-
|
|
10217
|
-
async function validateUIMessages({
|
|
10218
|
-
messages,
|
|
10219
|
-
metadataSchema,
|
|
10220
|
-
dataSchemas,
|
|
10221
|
-
tools
|
|
10222
|
-
}) {
|
|
10223
|
-
const response = await safeValidateUIMessages({
|
|
10224
|
-
messages,
|
|
10225
|
-
metadataSchema,
|
|
10226
|
-
dataSchemas,
|
|
10227
|
-
tools
|
|
10228
|
-
});
|
|
10229
|
-
if (!response.success)
|
|
10230
|
-
throw response.error;
|
|
10231
|
-
return response.data;
|
|
10195
|
+
return validatedMessages;
|
|
10232
10196
|
}
|
|
10233
10197
|
|
|
10234
10198
|
// src/ui-message-stream/create-ui-message-stream.ts
|
|
@@ -10451,12 +10415,10 @@ export {
|
|
|
10451
10415
|
jsonSchema2 as jsonSchema,
|
|
10452
10416
|
lastAssistantMessageIsCompleteWithToolCalls,
|
|
10453
10417
|
modelMessageSchema,
|
|
10454
|
-
parseJsonEventStream3 as parseJsonEventStream,
|
|
10455
10418
|
parsePartialJson,
|
|
10456
10419
|
pipeTextStreamToResponse,
|
|
10457
10420
|
pipeUIMessageStreamToResponse,
|
|
10458
10421
|
readUIMessageStream,
|
|
10459
|
-
safeValidateUIMessages,
|
|
10460
10422
|
simulateReadableStream,
|
|
10461
10423
|
simulateStreamingMiddleware,
|
|
10462
10424
|
smoothStream,
|
|
@@ -10466,7 +10428,6 @@ export {
|
|
|
10466
10428
|
systemModelMessageSchema,
|
|
10467
10429
|
tool2 as tool,
|
|
10468
10430
|
toolModelMessageSchema,
|
|
10469
|
-
uiMessageChunkSchema,
|
|
10470
10431
|
userModelMessageSchema,
|
|
10471
10432
|
validateUIMessages,
|
|
10472
10433
|
wrapLanguageModel,
|