ai 6.0.263 → 6.0.264
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 +6 -0
- package/dist/index.js +56 -14
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +56 -14
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.js +1 -1
- package/dist/internal/index.mjs +1 -1
- package/package.json +1 -1
- package/src/generate-text/stream-text.ts +65 -7
package/dist/index.mjs
CHANGED
|
@@ -1193,7 +1193,7 @@ import {
|
|
|
1193
1193
|
} from "@ai-sdk/provider-utils";
|
|
1194
1194
|
|
|
1195
1195
|
// src/version.ts
|
|
1196
|
-
var VERSION = true ? "6.0.
|
|
1196
|
+
var VERSION = true ? "6.0.264" : "0.0.0-test";
|
|
1197
1197
|
|
|
1198
1198
|
// src/util/download/download.ts
|
|
1199
1199
|
var download = async ({
|
|
@@ -7209,6 +7209,25 @@ var DefaultStreamTextResult = class {
|
|
|
7209
7209
|
const recordedSteps = [];
|
|
7210
7210
|
let recordedNoOutputError;
|
|
7211
7211
|
let currentStepToolSet = tools;
|
|
7212
|
+
const createPartIdReserver = () => {
|
|
7213
|
+
const usedIds = /* @__PURE__ */ new Set();
|
|
7214
|
+
return (id) => {
|
|
7215
|
+
if (!usedIds.has(id)) {
|
|
7216
|
+
usedIds.add(id);
|
|
7217
|
+
return id;
|
|
7218
|
+
}
|
|
7219
|
+
const generatedId = generateId2();
|
|
7220
|
+
let uniqueId = generatedId;
|
|
7221
|
+
let suffix = 0;
|
|
7222
|
+
while (usedIds.has(uniqueId)) {
|
|
7223
|
+
uniqueId = `${generatedId}-${++suffix}`;
|
|
7224
|
+
}
|
|
7225
|
+
usedIds.add(uniqueId);
|
|
7226
|
+
return uniqueId;
|
|
7227
|
+
};
|
|
7228
|
+
};
|
|
7229
|
+
const reserveTextPartId = createPartIdReserver();
|
|
7230
|
+
const reserveReasoningPartId = createPartIdReserver();
|
|
7212
7231
|
const pendingDeferredToolCalls = /* @__PURE__ */ new Map();
|
|
7213
7232
|
let rootSpan;
|
|
7214
7233
|
let activeTextContent = createIdMap();
|
|
@@ -7922,11 +7941,13 @@ var DefaultStreamTextResult = class {
|
|
|
7922
7941
|
modelId: modelInfo.modelId
|
|
7923
7942
|
};
|
|
7924
7943
|
let activeText = "";
|
|
7944
|
+
const textPartIds = /* @__PURE__ */ new Map();
|
|
7945
|
+
const reasoningPartIds = /* @__PURE__ */ new Map();
|
|
7925
7946
|
self.addStream(
|
|
7926
7947
|
streamWithToolResults.pipeThrough(
|
|
7927
7948
|
new TransformStream({
|
|
7928
7949
|
async transform(chunk, controller) {
|
|
7929
|
-
var _a23, _b2, _c2, _d2, _e2;
|
|
7950
|
+
var _a23, _b2, _c2, _d2, _e2, _f2, _g2, _h2, _i2;
|
|
7930
7951
|
resetChunkTimeout();
|
|
7931
7952
|
if (chunk.type === "stream-start") {
|
|
7932
7953
|
warnings = chunk.warnings;
|
|
@@ -7952,17 +7973,29 @@ var DefaultStreamTextResult = class {
|
|
|
7952
7973
|
hasReceivedOutputChunk = true;
|
|
7953
7974
|
}
|
|
7954
7975
|
switch (chunkType) {
|
|
7955
|
-
case "tool-approval-request":
|
|
7956
|
-
case "text-start":
|
|
7957
|
-
case "text-end": {
|
|
7976
|
+
case "tool-approval-request": {
|
|
7958
7977
|
controller.enqueue(chunk);
|
|
7959
7978
|
break;
|
|
7960
7979
|
}
|
|
7980
|
+
case "text-start": {
|
|
7981
|
+
const id = reserveTextPartId(chunk.id);
|
|
7982
|
+
textPartIds.set(chunk.id, id);
|
|
7983
|
+
controller.enqueue({ ...chunk, id });
|
|
7984
|
+
break;
|
|
7985
|
+
}
|
|
7986
|
+
case "text-end": {
|
|
7987
|
+
controller.enqueue({
|
|
7988
|
+
...chunk,
|
|
7989
|
+
id: (_a23 = textPartIds.get(chunk.id)) != null ? _a23 : chunk.id
|
|
7990
|
+
});
|
|
7991
|
+
textPartIds.delete(chunk.id);
|
|
7992
|
+
break;
|
|
7993
|
+
}
|
|
7961
7994
|
case "text-delta": {
|
|
7962
7995
|
if (chunk.delta.length > 0 || chunk.providerMetadata != null) {
|
|
7963
7996
|
controller.enqueue({
|
|
7964
7997
|
type: "text-delta",
|
|
7965
|
-
id: chunk.id,
|
|
7998
|
+
id: (_b2 = textPartIds.get(chunk.id)) != null ? _b2 : chunk.id,
|
|
7966
7999
|
text: chunk.delta,
|
|
7967
8000
|
providerMetadata: chunk.providerMetadata
|
|
7968
8001
|
});
|
|
@@ -7970,15 +8003,24 @@ var DefaultStreamTextResult = class {
|
|
|
7970
8003
|
activeText += chunk.delta;
|
|
7971
8004
|
break;
|
|
7972
8005
|
}
|
|
7973
|
-
case "reasoning-start":
|
|
8006
|
+
case "reasoning-start": {
|
|
8007
|
+
const id = reserveReasoningPartId(chunk.id);
|
|
8008
|
+
reasoningPartIds.set(chunk.id, id);
|
|
8009
|
+
controller.enqueue({ ...chunk, id });
|
|
8010
|
+
break;
|
|
8011
|
+
}
|
|
7974
8012
|
case "reasoning-end": {
|
|
7975
|
-
controller.enqueue(
|
|
8013
|
+
controller.enqueue({
|
|
8014
|
+
...chunk,
|
|
8015
|
+
id: (_c2 = reasoningPartIds.get(chunk.id)) != null ? _c2 : chunk.id
|
|
8016
|
+
});
|
|
8017
|
+
reasoningPartIds.delete(chunk.id);
|
|
7976
8018
|
break;
|
|
7977
8019
|
}
|
|
7978
8020
|
case "reasoning-delta": {
|
|
7979
8021
|
controller.enqueue({
|
|
7980
8022
|
type: "reasoning-delta",
|
|
7981
|
-
id: chunk.id,
|
|
8023
|
+
id: (_d2 = reasoningPartIds.get(chunk.id)) != null ? _d2 : chunk.id,
|
|
7982
8024
|
text: chunk.delta,
|
|
7983
8025
|
providerMetadata: chunk.providerMetadata
|
|
7984
8026
|
});
|
|
@@ -8003,9 +8045,9 @@ var DefaultStreamTextResult = class {
|
|
|
8003
8045
|
}
|
|
8004
8046
|
case "response-metadata": {
|
|
8005
8047
|
stepResponse = {
|
|
8006
|
-
id: (
|
|
8007
|
-
timestamp: (
|
|
8008
|
-
modelId: (
|
|
8048
|
+
id: (_e2 = chunk.id) != null ? _e2 : stepResponse.id,
|
|
8049
|
+
timestamp: (_f2 = chunk.timestamp) != null ? _f2 : stepResponse.timestamp,
|
|
8050
|
+
modelId: (_g2 = chunk.modelId) != null ? _g2 : stepResponse.modelId
|
|
8009
8051
|
};
|
|
8010
8052
|
break;
|
|
8011
8053
|
}
|
|
@@ -8019,7 +8061,7 @@ var DefaultStreamTextResult = class {
|
|
|
8019
8061
|
doStreamSpan.addEvent("ai.stream.finish");
|
|
8020
8062
|
doStreamSpan.setAttributes({
|
|
8021
8063
|
"ai.response.msToFinish": msToFinish,
|
|
8022
|
-
"ai.response.avgOutputTokensPerSecond": 1e3 * ((
|
|
8064
|
+
"ai.response.avgOutputTokensPerSecond": 1e3 * ((_h2 = stepUsage.outputTokens) != null ? _h2 : 0) / msToFinish
|
|
8023
8065
|
});
|
|
8024
8066
|
break;
|
|
8025
8067
|
}
|
|
@@ -8044,7 +8086,7 @@ var DefaultStreamTextResult = class {
|
|
|
8044
8086
|
}
|
|
8045
8087
|
controller.enqueue({
|
|
8046
8088
|
...chunk,
|
|
8047
|
-
dynamic: (
|
|
8089
|
+
dynamic: (_i2 = chunk.dynamic) != null ? _i2 : (tool2 == null ? void 0 : tool2.type) === "dynamic",
|
|
8048
8090
|
title: tool2 == null ? void 0 : tool2.title
|
|
8049
8091
|
});
|
|
8050
8092
|
break;
|