ai 4.0.31 → 4.0.33
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 +12 -0
- package/dist/index.d.mts +7 -1
- package/dist/index.d.ts +7 -1
- package/dist/index.js +28 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +28 -2
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
@@ -2714,12 +2714,27 @@ function createStitchableStream() {
|
|
2714
2714
|
innerStreamReaders.push(innerStream.getReader());
|
2715
2715
|
waitForNewStream.resolve();
|
2716
2716
|
},
|
2717
|
+
/**
|
2718
|
+
* Gracefully close the outer stream. This will let the inner streams
|
2719
|
+
* finish processing and then close the outer stream.
|
2720
|
+
*/
|
2717
2721
|
close: () => {
|
2718
2722
|
isClosed = true;
|
2719
2723
|
waitForNewStream.resolve();
|
2720
2724
|
if (innerStreamReaders.length === 0) {
|
2721
2725
|
controller == null ? void 0 : controller.close();
|
2722
2726
|
}
|
2727
|
+
},
|
2728
|
+
/**
|
2729
|
+
* Immediately close the outer stream. This will cancel all inner streams
|
2730
|
+
* and close the outer stream.
|
2731
|
+
*/
|
2732
|
+
terminate: () => {
|
2733
|
+
isClosed = true;
|
2734
|
+
waitForNewStream.resolve();
|
2735
|
+
innerStreamReaders.forEach((reader) => reader.cancel());
|
2736
|
+
innerStreamReaders = [];
|
2737
|
+
controller == null ? void 0 : controller.close();
|
2723
2738
|
}
|
2724
2739
|
};
|
2725
2740
|
}
|
@@ -3317,6 +3332,7 @@ var ToolExecutionError = class extends AISDKError9 {
|
|
3317
3332
|
constructor({
|
3318
3333
|
toolArgs,
|
3319
3334
|
toolName,
|
3335
|
+
toolCallId,
|
3320
3336
|
cause,
|
3321
3337
|
message = `Error executing tool ${toolName}: ${getErrorMessage2(cause)}`
|
3322
3338
|
}) {
|
@@ -3324,6 +3340,7 @@ var ToolExecutionError = class extends AISDKError9 {
|
|
3324
3340
|
this[_a9] = true;
|
3325
3341
|
this.toolArgs = toolArgs;
|
3326
3342
|
this.toolName = toolName;
|
3343
|
+
this.toolCallId = toolCallId;
|
3327
3344
|
}
|
3328
3345
|
static isInstance(error) {
|
3329
3346
|
return AISDKError9.hasMarker(error, marker9);
|
@@ -3946,6 +3963,7 @@ async function executeTools({
|
|
3946
3963
|
return result2;
|
3947
3964
|
} catch (error) {
|
3948
3965
|
throw new ToolExecutionError({
|
3966
|
+
toolCallId,
|
3949
3967
|
toolName,
|
3950
3968
|
toolArgs: args,
|
3951
3969
|
cause: error
|
@@ -4304,6 +4322,7 @@ function runToolsTransformation({
|
|
4304
4322
|
toolResultsStreamController.enqueue({
|
4305
4323
|
type: "error",
|
4306
4324
|
error: new ToolExecutionError({
|
4325
|
+
toolCallId: toolCall.toolCallId,
|
4307
4326
|
toolName: toolCall.toolName,
|
4308
4327
|
toolArgs: toolCall.args,
|
4309
4328
|
cause: error
|
@@ -4415,7 +4434,7 @@ function streamText({
|
|
4415
4434
|
tools,
|
4416
4435
|
toolChoice,
|
4417
4436
|
toolCallStreaming,
|
4418
|
-
transform
|
4437
|
+
transform,
|
4419
4438
|
activeTools,
|
4420
4439
|
repairToolCall,
|
4421
4440
|
maxSteps,
|
@@ -4689,7 +4708,14 @@ var DefaultStreamTextResult = class {
|
|
4689
4708
|
this.closeStream = stitchableStream.close;
|
4690
4709
|
let stream = stitchableStream.stream;
|
4691
4710
|
if (transform) {
|
4692
|
-
stream = stream.pipeThrough(
|
4711
|
+
stream = stream.pipeThrough(
|
4712
|
+
transform({
|
4713
|
+
tools,
|
4714
|
+
stopStream() {
|
4715
|
+
stitchableStream.terminate();
|
4716
|
+
}
|
4717
|
+
})
|
4718
|
+
);
|
4693
4719
|
}
|
4694
4720
|
this.baseStream = stream.pipeThrough(createOutputTransformStream(output)).pipeThrough(eventProcessor);
|
4695
4721
|
const { maxRetries, retry } = prepareRetries({
|