ai 3.4.23 → 3.4.25
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 +14 -0
- package/dist/index.js +19 -16
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +19 -16
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
@@ -1,5 +1,19 @@
|
|
1
1
|
# ai
|
2
2
|
|
3
|
+
## 3.4.25
|
4
|
+
|
5
|
+
### Patch Changes
|
6
|
+
|
7
|
+
- 6e0fa1c: fix (ai/core): wait for tool results to arrive before sending finish event
|
8
|
+
|
9
|
+
## 3.4.24
|
10
|
+
|
11
|
+
### Patch Changes
|
12
|
+
|
13
|
+
- d92fd9f: feat (ui/svelte): support Svelte 5 peer dependency
|
14
|
+
- Updated dependencies [d92fd9f]
|
15
|
+
- @ai-sdk/svelte@0.0.56
|
16
|
+
|
3
17
|
## 3.4.23
|
4
18
|
|
5
19
|
### Patch Changes
|
package/dist/index.js
CHANGED
@@ -3655,8 +3655,6 @@ function runToolsTransformation({
|
|
3655
3655
|
telemetry,
|
3656
3656
|
abortSignal
|
3657
3657
|
}) {
|
3658
|
-
let canClose = false;
|
3659
|
-
const outstandingToolCalls = /* @__PURE__ */ new Set();
|
3660
3658
|
let toolResultsStreamController = null;
|
3661
3659
|
const toolResultsStream = new ReadableStream({
|
3662
3660
|
start(controller) {
|
@@ -3664,6 +3662,17 @@ function runToolsTransformation({
|
|
3664
3662
|
}
|
3665
3663
|
});
|
3666
3664
|
const activeToolCalls = {};
|
3665
|
+
const outstandingToolResults = /* @__PURE__ */ new Set();
|
3666
|
+
let canClose = false;
|
3667
|
+
let finishChunk = void 0;
|
3668
|
+
function attemptClose() {
|
3669
|
+
if (canClose && outstandingToolResults.size === 0) {
|
3670
|
+
if (finishChunk != null) {
|
3671
|
+
toolResultsStreamController.enqueue(finishChunk);
|
3672
|
+
}
|
3673
|
+
toolResultsStreamController.close();
|
3674
|
+
}
|
3675
|
+
}
|
3667
3676
|
const forwardStream = new TransformStream({
|
3668
3677
|
transform(chunk, controller) {
|
3669
3678
|
const chunkType = chunk.type;
|
@@ -3721,7 +3730,7 @@ function runToolsTransformation({
|
|
3721
3730
|
controller.enqueue(toolCall);
|
3722
3731
|
if (tool2.execute != null) {
|
3723
3732
|
const toolExecutionId = (0, import_ui_utils5.generateId)();
|
3724
|
-
|
3733
|
+
outstandingToolResults.add(toolExecutionId);
|
3725
3734
|
recordSpan({
|
3726
3735
|
name: "ai.toolCall",
|
3727
3736
|
attributes: selectTelemetryAttributes({
|
@@ -3746,10 +3755,8 @@ function runToolsTransformation({
|
|
3746
3755
|
type: "tool-result",
|
3747
3756
|
result
|
3748
3757
|
});
|
3749
|
-
|
3750
|
-
|
3751
|
-
toolResultsStreamController.close();
|
3752
|
-
}
|
3758
|
+
outstandingToolResults.delete(toolExecutionId);
|
3759
|
+
attemptClose();
|
3753
3760
|
try {
|
3754
3761
|
span.setAttributes(
|
3755
3762
|
selectTelemetryAttributes({
|
@@ -3769,10 +3776,8 @@ function runToolsTransformation({
|
|
3769
3776
|
type: "error",
|
3770
3777
|
error
|
3771
3778
|
});
|
3772
|
-
|
3773
|
-
|
3774
|
-
toolResultsStreamController.close();
|
3775
|
-
}
|
3779
|
+
outstandingToolResults.delete(toolExecutionId);
|
3780
|
+
attemptClose();
|
3776
3781
|
}
|
3777
3782
|
)
|
3778
3783
|
});
|
@@ -3786,13 +3791,13 @@ function runToolsTransformation({
|
|
3786
3791
|
break;
|
3787
3792
|
}
|
3788
3793
|
case "finish": {
|
3789
|
-
|
3794
|
+
finishChunk = {
|
3790
3795
|
type: "finish",
|
3791
3796
|
finishReason: chunk.finishReason,
|
3792
3797
|
logprobs: chunk.logprobs,
|
3793
3798
|
usage: calculateLanguageModelUsage(chunk.usage),
|
3794
3799
|
experimental_providerMetadata: chunk.providerMetadata
|
3795
|
-
}
|
3800
|
+
};
|
3796
3801
|
break;
|
3797
3802
|
}
|
3798
3803
|
default: {
|
@@ -3803,9 +3808,7 @@ function runToolsTransformation({
|
|
3803
3808
|
},
|
3804
3809
|
flush() {
|
3805
3810
|
canClose = true;
|
3806
|
-
|
3807
|
-
toolResultsStreamController.close();
|
3808
|
-
}
|
3811
|
+
attemptClose();
|
3809
3812
|
}
|
3810
3813
|
});
|
3811
3814
|
return new ReadableStream({
|