ai 5.0.271 → 5.0.273
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 +24 -0
- package/dist/index.d.mts +9 -1
- package/dist/index.d.ts +9 -1
- package/dist/index.js +56 -19
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +55 -19
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.js +1 -1
- package/dist/internal/index.mjs +1 -1
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -727,7 +727,7 @@ import {
|
|
|
727
727
|
} from "@ai-sdk/provider-utils";
|
|
728
728
|
|
|
729
729
|
// src/version.ts
|
|
730
|
-
var VERSION = true ? "5.0.
|
|
730
|
+
var VERSION = true ? "5.0.273" : "0.0.0-test";
|
|
731
731
|
|
|
732
732
|
// src/util/download/download.ts
|
|
733
733
|
var download = async ({
|
|
@@ -6322,6 +6322,20 @@ var DefaultStreamTextResult = class {
|
|
|
6322
6322
|
}
|
|
6323
6323
|
};
|
|
6324
6324
|
|
|
6325
|
+
// src/util/get-own.ts
|
|
6326
|
+
function getOwn(obj, key) {
|
|
6327
|
+
return obj != null && Object.hasOwn(obj, key) ? obj[key] : void 0;
|
|
6328
|
+
}
|
|
6329
|
+
|
|
6330
|
+
// src/ui/unavailable-tool.ts
|
|
6331
|
+
function markToolPartAsUnavailable(part) {
|
|
6332
|
+
part.dynamic = false;
|
|
6333
|
+
return part;
|
|
6334
|
+
}
|
|
6335
|
+
function isToolPartFromUnavailableTool(part) {
|
|
6336
|
+
return part.type === "dynamic-tool" && part.dynamic === false;
|
|
6337
|
+
}
|
|
6338
|
+
|
|
6325
6339
|
// src/ui/convert-to-model-messages.ts
|
|
6326
6340
|
function convertToModelMessages(messages, options) {
|
|
6327
6341
|
const modelMessages = [];
|
|
@@ -6333,6 +6347,25 @@ function convertToModelMessages(messages, options) {
|
|
|
6333
6347
|
)
|
|
6334
6348
|
}));
|
|
6335
6349
|
}
|
|
6350
|
+
function createModelOutput({
|
|
6351
|
+
toolPart,
|
|
6352
|
+
toolName,
|
|
6353
|
+
output,
|
|
6354
|
+
errorMode
|
|
6355
|
+
}) {
|
|
6356
|
+
const tool2 = getOwn(options == null ? void 0 : options.tools, toolName);
|
|
6357
|
+
if (errorMode === "none" && tool2 == null && isToolPartFromUnavailableTool(toolPart)) {
|
|
6358
|
+
return {
|
|
6359
|
+
type: "text",
|
|
6360
|
+
value: "Tool output omitted because the tool is no longer available."
|
|
6361
|
+
};
|
|
6362
|
+
}
|
|
6363
|
+
return createToolModelOutput({
|
|
6364
|
+
output,
|
|
6365
|
+
tool: tool2,
|
|
6366
|
+
errorMode
|
|
6367
|
+
});
|
|
6368
|
+
}
|
|
6336
6369
|
for (const message of messages) {
|
|
6337
6370
|
switch (message.role) {
|
|
6338
6371
|
case "system": {
|
|
@@ -6386,7 +6419,7 @@ function convertToModelMessages(messages, options) {
|
|
|
6386
6419
|
case "assistant": {
|
|
6387
6420
|
if (message.parts != null) {
|
|
6388
6421
|
let processBlock2 = function() {
|
|
6389
|
-
var _a16, _b
|
|
6422
|
+
var _a16, _b;
|
|
6390
6423
|
if (block.length === 0) {
|
|
6391
6424
|
return;
|
|
6392
6425
|
}
|
|
@@ -6438,9 +6471,10 @@ function convertToModelMessages(messages, options) {
|
|
|
6438
6471
|
type: "tool-result",
|
|
6439
6472
|
toolCallId: part.toolCallId,
|
|
6440
6473
|
toolName,
|
|
6441
|
-
output:
|
|
6474
|
+
output: createModelOutput({
|
|
6475
|
+
toolPart: part,
|
|
6476
|
+
toolName,
|
|
6442
6477
|
output: part.state === "output-error" ? part.errorText : part.output,
|
|
6443
|
-
tool: (_b = options == null ? void 0 : options.tools) == null ? void 0 : _b[toolName],
|
|
6444
6478
|
errorMode: part.state === "output-error" ? "json" : "none"
|
|
6445
6479
|
}),
|
|
6446
6480
|
...part.callProviderMetadata != null ? { providerOptions: part.callProviderMetadata } : {}
|
|
@@ -6448,7 +6482,7 @@ function convertToModelMessages(messages, options) {
|
|
|
6448
6482
|
}
|
|
6449
6483
|
}
|
|
6450
6484
|
} else if (isDataUIPart(part)) {
|
|
6451
|
-
const dataPart = (
|
|
6485
|
+
const dataPart = (_b = options == null ? void 0 : options.convertDataPart) == null ? void 0 : _b.call(
|
|
6452
6486
|
options,
|
|
6453
6487
|
part
|
|
6454
6488
|
);
|
|
@@ -6471,7 +6505,6 @@ function convertToModelMessages(messages, options) {
|
|
|
6471
6505
|
modelMessages.push({
|
|
6472
6506
|
role: "tool",
|
|
6473
6507
|
content: toolParts.map((toolPart) => {
|
|
6474
|
-
var _a17;
|
|
6475
6508
|
switch (toolPart.state) {
|
|
6476
6509
|
case "output-error":
|
|
6477
6510
|
case "output-available": {
|
|
@@ -6480,9 +6513,10 @@ function convertToModelMessages(messages, options) {
|
|
|
6480
6513
|
type: "tool-result",
|
|
6481
6514
|
toolCallId: toolPart.toolCallId,
|
|
6482
6515
|
toolName,
|
|
6483
|
-
output:
|
|
6516
|
+
output: createModelOutput({
|
|
6517
|
+
toolPart,
|
|
6518
|
+
toolName,
|
|
6484
6519
|
output: toolPart.state === "output-error" ? toolPart.errorText : toolPart.output,
|
|
6485
|
-
tool: (_a17 = options == null ? void 0 : options.tools) == null ? void 0 : _a17[toolName],
|
|
6486
6520
|
errorMode: toolPart.state === "output-error" ? "text" : "none"
|
|
6487
6521
|
}),
|
|
6488
6522
|
...toolPart.callProviderMetadata != null ? { providerOptions: toolPart.callProviderMetadata } : {}
|
|
@@ -6677,11 +6711,6 @@ var DefaultEmbedResult = class {
|
|
|
6677
6711
|
}
|
|
6678
6712
|
};
|
|
6679
6713
|
|
|
6680
|
-
// src/util/get-own.ts
|
|
6681
|
-
function getOwn(obj, key) {
|
|
6682
|
-
return obj != null && Object.hasOwn(obj, key) ? obj[key] : void 0;
|
|
6683
|
-
}
|
|
6684
|
-
|
|
6685
6714
|
// src/util/set-own.ts
|
|
6686
6715
|
function setOwn(object2, key, value) {
|
|
6687
6716
|
Object.defineProperty(object2, key, {
|
|
@@ -9753,7 +9782,9 @@ import {
|
|
|
9753
9782
|
} from "@ai-sdk/provider-utils";
|
|
9754
9783
|
function appendPathToUrl(url, path) {
|
|
9755
9784
|
const queryOrFragmentStart = url.search(/[?#]/);
|
|
9756
|
-
|
|
9785
|
+
const urlPath = queryOrFragmentStart === -1 ? url : url.slice(0, queryOrFragmentStart);
|
|
9786
|
+
const suffix = queryOrFragmentStart === -1 ? "" : url.slice(queryOrFragmentStart);
|
|
9787
|
+
return `${urlPath.endsWith("/") && path.startsWith("/") ? urlPath.slice(0, -1) : urlPath}${path}${suffix}`;
|
|
9757
9788
|
}
|
|
9758
9789
|
var HttpChatTransport = class {
|
|
9759
9790
|
constructor({
|
|
@@ -10393,20 +10424,20 @@ function asDynamicToolPart(toolPart) {
|
|
|
10393
10424
|
...toolPart.callProviderMetadata === void 0 ? {} : { callProviderMetadata: toolPart.callProviderMetadata }
|
|
10394
10425
|
};
|
|
10395
10426
|
if (toolPart.state === "output-available") {
|
|
10396
|
-
return {
|
|
10427
|
+
return markToolPartAsUnavailable({
|
|
10397
10428
|
...common,
|
|
10398
10429
|
state: "output-available",
|
|
10399
10430
|
input: toolPart.input,
|
|
10400
10431
|
output: toolPart.output,
|
|
10401
10432
|
...toolPart.preliminary === void 0 ? {} : { preliminary: toolPart.preliminary }
|
|
10402
|
-
};
|
|
10433
|
+
});
|
|
10403
10434
|
}
|
|
10404
|
-
return {
|
|
10435
|
+
return markToolPartAsUnavailable({
|
|
10405
10436
|
...common,
|
|
10406
10437
|
state: "output-error",
|
|
10407
10438
|
input: toolPart.input,
|
|
10408
10439
|
errorText: toolPart.errorText
|
|
10409
|
-
};
|
|
10440
|
+
});
|
|
10410
10441
|
}
|
|
10411
10442
|
var uiMessagesSchema = lazyValidator2(
|
|
10412
10443
|
() => zodSchema2(
|
|
@@ -10462,6 +10493,7 @@ var uiMessagesSchema = lazyValidator2(
|
|
|
10462
10493
|
}),
|
|
10463
10494
|
z8.object({
|
|
10464
10495
|
type: z8.literal("dynamic-tool"),
|
|
10496
|
+
dynamic: z8.literal(false).optional(),
|
|
10465
10497
|
toolName: z8.string(),
|
|
10466
10498
|
toolCallId: z8.string(),
|
|
10467
10499
|
state: z8.literal("input-streaming"),
|
|
@@ -10473,6 +10505,7 @@ var uiMessagesSchema = lazyValidator2(
|
|
|
10473
10505
|
}),
|
|
10474
10506
|
z8.object({
|
|
10475
10507
|
type: z8.literal("dynamic-tool"),
|
|
10508
|
+
dynamic: z8.literal(false).optional(),
|
|
10476
10509
|
toolName: z8.string(),
|
|
10477
10510
|
toolCallId: z8.string(),
|
|
10478
10511
|
state: z8.literal("input-available"),
|
|
@@ -10484,6 +10517,7 @@ var uiMessagesSchema = lazyValidator2(
|
|
|
10484
10517
|
}),
|
|
10485
10518
|
z8.object({
|
|
10486
10519
|
type: z8.literal("dynamic-tool"),
|
|
10520
|
+
dynamic: z8.literal(false).optional(),
|
|
10487
10521
|
toolName: z8.string(),
|
|
10488
10522
|
toolCallId: z8.string(),
|
|
10489
10523
|
state: z8.literal("output-available"),
|
|
@@ -10496,6 +10530,7 @@ var uiMessagesSchema = lazyValidator2(
|
|
|
10496
10530
|
}),
|
|
10497
10531
|
z8.object({
|
|
10498
10532
|
type: z8.literal("dynamic-tool"),
|
|
10533
|
+
dynamic: z8.literal(false).optional(),
|
|
10499
10534
|
toolName: z8.string(),
|
|
10500
10535
|
toolCallId: z8.string(),
|
|
10501
10536
|
state: z8.literal("output-error"),
|
|
@@ -10695,7 +10730,7 @@ async function safeValidateUIMessages({
|
|
|
10695
10730
|
}
|
|
10696
10731
|
const toolPart = part;
|
|
10697
10732
|
const toolName = toolPart.type.slice(5);
|
|
10698
|
-
const tool2 = tools
|
|
10733
|
+
const tool2 = getOwn(tools, toolName);
|
|
10699
10734
|
if (!tool2 && (toolPart.state === "output-available" || toolPart.state === "output-error")) {
|
|
10700
10735
|
message.parts[partIdx] = asDynamicToolPart(toolPart);
|
|
10701
10736
|
continue;
|
|
@@ -11038,6 +11073,7 @@ export {
|
|
|
11038
11073
|
hasToolCall,
|
|
11039
11074
|
isDataUIPart,
|
|
11040
11075
|
isDeepEqualData,
|
|
11076
|
+
isDynamicToolUIPart,
|
|
11041
11077
|
isFileUIPart,
|
|
11042
11078
|
isReasoningUIPart,
|
|
11043
11079
|
isTextUIPart,
|