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/CHANGELOG.md
CHANGED
package/dist/index.js
CHANGED
|
@@ -1304,7 +1304,7 @@ function detectMediaType({
|
|
|
1304
1304
|
var import_provider_utils3 = require("@ai-sdk/provider-utils");
|
|
1305
1305
|
|
|
1306
1306
|
// src/version.ts
|
|
1307
|
-
var VERSION = true ? "6.0.
|
|
1307
|
+
var VERSION = true ? "6.0.264" : "0.0.0-test";
|
|
1308
1308
|
|
|
1309
1309
|
// src/util/download/download.ts
|
|
1310
1310
|
var download = async ({
|
|
@@ -7281,6 +7281,25 @@ var DefaultStreamTextResult = class {
|
|
|
7281
7281
|
const recordedSteps = [];
|
|
7282
7282
|
let recordedNoOutputError;
|
|
7283
7283
|
let currentStepToolSet = tools;
|
|
7284
|
+
const createPartIdReserver = () => {
|
|
7285
|
+
const usedIds = /* @__PURE__ */ new Set();
|
|
7286
|
+
return (id) => {
|
|
7287
|
+
if (!usedIds.has(id)) {
|
|
7288
|
+
usedIds.add(id);
|
|
7289
|
+
return id;
|
|
7290
|
+
}
|
|
7291
|
+
const generatedId = generateId2();
|
|
7292
|
+
let uniqueId = generatedId;
|
|
7293
|
+
let suffix = 0;
|
|
7294
|
+
while (usedIds.has(uniqueId)) {
|
|
7295
|
+
uniqueId = `${generatedId}-${++suffix}`;
|
|
7296
|
+
}
|
|
7297
|
+
usedIds.add(uniqueId);
|
|
7298
|
+
return uniqueId;
|
|
7299
|
+
};
|
|
7300
|
+
};
|
|
7301
|
+
const reserveTextPartId = createPartIdReserver();
|
|
7302
|
+
const reserveReasoningPartId = createPartIdReserver();
|
|
7284
7303
|
const pendingDeferredToolCalls = /* @__PURE__ */ new Map();
|
|
7285
7304
|
let rootSpan;
|
|
7286
7305
|
let activeTextContent = createIdMap();
|
|
@@ -7994,11 +8013,13 @@ var DefaultStreamTextResult = class {
|
|
|
7994
8013
|
modelId: modelInfo.modelId
|
|
7995
8014
|
};
|
|
7996
8015
|
let activeText = "";
|
|
8016
|
+
const textPartIds = /* @__PURE__ */ new Map();
|
|
8017
|
+
const reasoningPartIds = /* @__PURE__ */ new Map();
|
|
7997
8018
|
self.addStream(
|
|
7998
8019
|
streamWithToolResults.pipeThrough(
|
|
7999
8020
|
new TransformStream({
|
|
8000
8021
|
async transform(chunk, controller) {
|
|
8001
|
-
var _a23, _b2, _c2, _d2, _e2;
|
|
8022
|
+
var _a23, _b2, _c2, _d2, _e2, _f2, _g2, _h2, _i2;
|
|
8002
8023
|
resetChunkTimeout();
|
|
8003
8024
|
if (chunk.type === "stream-start") {
|
|
8004
8025
|
warnings = chunk.warnings;
|
|
@@ -8024,17 +8045,29 @@ var DefaultStreamTextResult = class {
|
|
|
8024
8045
|
hasReceivedOutputChunk = true;
|
|
8025
8046
|
}
|
|
8026
8047
|
switch (chunkType) {
|
|
8027
|
-
case "tool-approval-request":
|
|
8028
|
-
case "text-start":
|
|
8029
|
-
case "text-end": {
|
|
8048
|
+
case "tool-approval-request": {
|
|
8030
8049
|
controller.enqueue(chunk);
|
|
8031
8050
|
break;
|
|
8032
8051
|
}
|
|
8052
|
+
case "text-start": {
|
|
8053
|
+
const id = reserveTextPartId(chunk.id);
|
|
8054
|
+
textPartIds.set(chunk.id, id);
|
|
8055
|
+
controller.enqueue({ ...chunk, id });
|
|
8056
|
+
break;
|
|
8057
|
+
}
|
|
8058
|
+
case "text-end": {
|
|
8059
|
+
controller.enqueue({
|
|
8060
|
+
...chunk,
|
|
8061
|
+
id: (_a23 = textPartIds.get(chunk.id)) != null ? _a23 : chunk.id
|
|
8062
|
+
});
|
|
8063
|
+
textPartIds.delete(chunk.id);
|
|
8064
|
+
break;
|
|
8065
|
+
}
|
|
8033
8066
|
case "text-delta": {
|
|
8034
8067
|
if (chunk.delta.length > 0 || chunk.providerMetadata != null) {
|
|
8035
8068
|
controller.enqueue({
|
|
8036
8069
|
type: "text-delta",
|
|
8037
|
-
id: chunk.id,
|
|
8070
|
+
id: (_b2 = textPartIds.get(chunk.id)) != null ? _b2 : chunk.id,
|
|
8038
8071
|
text: chunk.delta,
|
|
8039
8072
|
providerMetadata: chunk.providerMetadata
|
|
8040
8073
|
});
|
|
@@ -8042,15 +8075,24 @@ var DefaultStreamTextResult = class {
|
|
|
8042
8075
|
activeText += chunk.delta;
|
|
8043
8076
|
break;
|
|
8044
8077
|
}
|
|
8045
|
-
case "reasoning-start":
|
|
8078
|
+
case "reasoning-start": {
|
|
8079
|
+
const id = reserveReasoningPartId(chunk.id);
|
|
8080
|
+
reasoningPartIds.set(chunk.id, id);
|
|
8081
|
+
controller.enqueue({ ...chunk, id });
|
|
8082
|
+
break;
|
|
8083
|
+
}
|
|
8046
8084
|
case "reasoning-end": {
|
|
8047
|
-
controller.enqueue(
|
|
8085
|
+
controller.enqueue({
|
|
8086
|
+
...chunk,
|
|
8087
|
+
id: (_c2 = reasoningPartIds.get(chunk.id)) != null ? _c2 : chunk.id
|
|
8088
|
+
});
|
|
8089
|
+
reasoningPartIds.delete(chunk.id);
|
|
8048
8090
|
break;
|
|
8049
8091
|
}
|
|
8050
8092
|
case "reasoning-delta": {
|
|
8051
8093
|
controller.enqueue({
|
|
8052
8094
|
type: "reasoning-delta",
|
|
8053
|
-
id: chunk.id,
|
|
8095
|
+
id: (_d2 = reasoningPartIds.get(chunk.id)) != null ? _d2 : chunk.id,
|
|
8054
8096
|
text: chunk.delta,
|
|
8055
8097
|
providerMetadata: chunk.providerMetadata
|
|
8056
8098
|
});
|
|
@@ -8075,9 +8117,9 @@ var DefaultStreamTextResult = class {
|
|
|
8075
8117
|
}
|
|
8076
8118
|
case "response-metadata": {
|
|
8077
8119
|
stepResponse = {
|
|
8078
|
-
id: (
|
|
8079
|
-
timestamp: (
|
|
8080
|
-
modelId: (
|
|
8120
|
+
id: (_e2 = chunk.id) != null ? _e2 : stepResponse.id,
|
|
8121
|
+
timestamp: (_f2 = chunk.timestamp) != null ? _f2 : stepResponse.timestamp,
|
|
8122
|
+
modelId: (_g2 = chunk.modelId) != null ? _g2 : stepResponse.modelId
|
|
8081
8123
|
};
|
|
8082
8124
|
break;
|
|
8083
8125
|
}
|
|
@@ -8091,7 +8133,7 @@ var DefaultStreamTextResult = class {
|
|
|
8091
8133
|
doStreamSpan.addEvent("ai.stream.finish");
|
|
8092
8134
|
doStreamSpan.setAttributes({
|
|
8093
8135
|
"ai.response.msToFinish": msToFinish,
|
|
8094
|
-
"ai.response.avgOutputTokensPerSecond": 1e3 * ((
|
|
8136
|
+
"ai.response.avgOutputTokensPerSecond": 1e3 * ((_h2 = stepUsage.outputTokens) != null ? _h2 : 0) / msToFinish
|
|
8095
8137
|
});
|
|
8096
8138
|
break;
|
|
8097
8139
|
}
|
|
@@ -8116,7 +8158,7 @@ var DefaultStreamTextResult = class {
|
|
|
8116
8158
|
}
|
|
8117
8159
|
controller.enqueue({
|
|
8118
8160
|
...chunk,
|
|
8119
|
-
dynamic: (
|
|
8161
|
+
dynamic: (_i2 = chunk.dynamic) != null ? _i2 : (tool2 == null ? void 0 : tool2.type) === "dynamic",
|
|
8120
8162
|
title: tool2 == null ? void 0 : tool2.title
|
|
8121
8163
|
});
|
|
8122
8164
|
break;
|