ai 5.0.212 → 5.0.213
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 +11 -0
- package/dist/index.js +45 -9
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +45 -9
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.js +1 -1
- package/dist/internal/index.mjs +1 -1
- package/package.json +3 -3
package/dist/index.mjs
CHANGED
|
@@ -689,7 +689,7 @@ import {
|
|
|
689
689
|
} from "@ai-sdk/provider-utils";
|
|
690
690
|
|
|
691
691
|
// src/version.ts
|
|
692
|
-
var VERSION = true ? "5.0.
|
|
692
|
+
var VERSION = true ? "5.0.213" : "0.0.0-test";
|
|
693
693
|
|
|
694
694
|
// src/util/download/download.ts
|
|
695
695
|
var download = async ({
|
|
@@ -4245,11 +4245,35 @@ function runToolsTransformation({
|
|
|
4245
4245
|
experimental_context
|
|
4246
4246
|
}) {
|
|
4247
4247
|
let toolResultsStreamController = null;
|
|
4248
|
+
let toolResultsStreamClosed = false;
|
|
4248
4249
|
const toolResultsStream = new ReadableStream({
|
|
4249
4250
|
start(controller) {
|
|
4250
4251
|
toolResultsStreamController = controller;
|
|
4252
|
+
},
|
|
4253
|
+
cancel() {
|
|
4254
|
+
toolResultsStreamClosed = true;
|
|
4251
4255
|
}
|
|
4252
4256
|
});
|
|
4257
|
+
function enqueueToolResult(chunk) {
|
|
4258
|
+
if (toolResultsStreamClosed) {
|
|
4259
|
+
return;
|
|
4260
|
+
}
|
|
4261
|
+
try {
|
|
4262
|
+
toolResultsStreamController.enqueue(chunk);
|
|
4263
|
+
} catch (e) {
|
|
4264
|
+
toolResultsStreamClosed = true;
|
|
4265
|
+
}
|
|
4266
|
+
}
|
|
4267
|
+
function closeToolResultsStream() {
|
|
4268
|
+
if (toolResultsStreamClosed) {
|
|
4269
|
+
return;
|
|
4270
|
+
}
|
|
4271
|
+
toolResultsStreamClosed = true;
|
|
4272
|
+
try {
|
|
4273
|
+
toolResultsStreamController.close();
|
|
4274
|
+
} catch (e) {
|
|
4275
|
+
}
|
|
4276
|
+
}
|
|
4253
4277
|
const outstandingToolResults = /* @__PURE__ */ new Set();
|
|
4254
4278
|
const toolInputs = /* @__PURE__ */ new Map();
|
|
4255
4279
|
let canClose = false;
|
|
@@ -4257,9 +4281,9 @@ function runToolsTransformation({
|
|
|
4257
4281
|
function attemptClose() {
|
|
4258
4282
|
if (canClose && outstandingToolResults.size === 0) {
|
|
4259
4283
|
if (finishChunk != null) {
|
|
4260
|
-
|
|
4284
|
+
enqueueToolResult(finishChunk);
|
|
4261
4285
|
}
|
|
4262
|
-
|
|
4286
|
+
closeToolResultsStream();
|
|
4263
4287
|
}
|
|
4264
4288
|
}
|
|
4265
4289
|
const forwardStream = new TransformStream({
|
|
@@ -4313,7 +4337,7 @@ function runToolsTransformation({
|
|
|
4313
4337
|
});
|
|
4314
4338
|
controller.enqueue(toolCall);
|
|
4315
4339
|
if (toolCall.invalid) {
|
|
4316
|
-
|
|
4340
|
+
enqueueToolResult({
|
|
4317
4341
|
type: "tool-error",
|
|
4318
4342
|
toolCallId: toolCall.toolCallId,
|
|
4319
4343
|
toolName: toolCall.toolName,
|
|
@@ -4368,7 +4392,7 @@ function runToolsTransformation({
|
|
|
4368
4392
|
}
|
|
4369
4393
|
});
|
|
4370
4394
|
for await (const part of stream) {
|
|
4371
|
-
|
|
4395
|
+
enqueueToolResult({
|
|
4372
4396
|
...toolCall,
|
|
4373
4397
|
type: "tool-result",
|
|
4374
4398
|
output: part.output,
|
|
@@ -4382,7 +4406,7 @@ function runToolsTransformation({
|
|
|
4382
4406
|
}
|
|
4383
4407
|
} catch (error) {
|
|
4384
4408
|
recordErrorOnSpan(span, error);
|
|
4385
|
-
|
|
4409
|
+
enqueueToolResult({
|
|
4386
4410
|
...toolCall,
|
|
4387
4411
|
type: "tool-error",
|
|
4388
4412
|
error
|
|
@@ -4410,14 +4434,14 @@ function runToolsTransformation({
|
|
|
4410
4434
|
});
|
|
4411
4435
|
}
|
|
4412
4436
|
} catch (error) {
|
|
4413
|
-
|
|
4437
|
+
enqueueToolResult({ type: "error", error });
|
|
4414
4438
|
}
|
|
4415
4439
|
break;
|
|
4416
4440
|
}
|
|
4417
4441
|
case "tool-result": {
|
|
4418
4442
|
const toolName = chunk.toolName;
|
|
4419
4443
|
if (chunk.isError) {
|
|
4420
|
-
|
|
4444
|
+
enqueueToolResult({
|
|
4421
4445
|
type: "tool-error",
|
|
4422
4446
|
toolCallId: chunk.toolCallId,
|
|
4423
4447
|
toolName,
|
|
@@ -9790,7 +9814,19 @@ var uiMessagesSchema = lazyValidator2(
|
|
|
9790
9814
|
})
|
|
9791
9815
|
})
|
|
9792
9816
|
])
|
|
9793
|
-
)
|
|
9817
|
+
)
|
|
9818
|
+
}).superRefine((message, context) => {
|
|
9819
|
+
if (message.role !== "assistant" && message.parts.length === 0) {
|
|
9820
|
+
context.addIssue({
|
|
9821
|
+
origin: "array",
|
|
9822
|
+
code: "too_small",
|
|
9823
|
+
minimum: 1,
|
|
9824
|
+
inclusive: true,
|
|
9825
|
+
input: message.parts,
|
|
9826
|
+
path: ["parts"],
|
|
9827
|
+
message: "Message must contain at least one part"
|
|
9828
|
+
});
|
|
9829
|
+
}
|
|
9794
9830
|
})
|
|
9795
9831
|
).nonempty("Messages array must not be empty")
|
|
9796
9832
|
)
|