ai 6.0.232 → 6.0.234
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 +21 -0
- package/dist/index.d.mts +7 -5
- package/dist/index.d.ts +7 -5
- package/dist/index.js +132 -77
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +132 -77
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.js +26 -14
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +26 -14
- package/dist/internal/index.mjs.map +1 -1
- package/docs/07-reference/01-ai-sdk-core/02-stream-text.mdx +2 -2
- package/docs/07-reference/02-ai-sdk-ui/42-pipe-ui-message-stream-to-response.mdx +6 -1
- package/package.json +4 -4
- package/src/agent/pipe-agent-ui-stream-to-response.ts +1 -1
- package/src/generate-object/stream-object-result.ts +4 -1
- package/src/generate-object/stream-object.ts +1 -1
- package/src/generate-text/stream-text-result.ts +5 -2
- package/src/generate-text/stream-text.ts +2 -2
- package/src/text-stream/pipe-text-stream-to-response.ts +3 -2
- package/src/ui/process-ui-message-stream.ts +109 -61
- package/src/ui-message-stream/pipe-ui-message-stream-to-response.ts +3 -2
- package/src/util/detect-media-type.ts +57 -27
- package/src/util/write-to-server-response.ts +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,26 @@
|
|
|
1
1
|
# ai
|
|
2
2
|
|
|
3
|
+
## 6.0.234
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 1efdef8: fix(ai): bound media-type sniffing decode for ID3-prefixed input
|
|
8
|
+
|
|
9
|
+
Media-type detection stripped ID3 tags before the ~18-byte prefix cap, decoding the entire base64 attachment (plus a full-size copy) whenever the data began with `ID3`/`SUQz`. This turned the intended O(1) sniff into an O(N) decode of the whole attachment. Detection now decodes at most a bounded prefix and skips the ID3 tag within that bound, keeping cost O(1) in input size on all paths (image, audio, and combined).
|
|
10
|
+
|
|
11
|
+
- 49414cf: Return response piping promises so callers can catch stream read and write errors.
|
|
12
|
+
- Updated dependencies [e7d064f]
|
|
13
|
+
- @ai-sdk/gateway@3.0.156
|
|
14
|
+
|
|
15
|
+
## 6.0.233
|
|
16
|
+
|
|
17
|
+
### Patch Changes
|
|
18
|
+
|
|
19
|
+
- fe410e7: fix: detect MP4 audio from its ftyp box during transcription
|
|
20
|
+
- af7188c: fix(ai): preserve tool parts when tool call IDs repeat across steps
|
|
21
|
+
- Updated dependencies [a09f944]
|
|
22
|
+
- @ai-sdk/gateway@3.0.155
|
|
23
|
+
|
|
3
24
|
## 6.0.232
|
|
4
25
|
|
|
5
26
|
### Patch Changes
|
package/dist/index.d.mts
CHANGED
|
@@ -2395,7 +2395,7 @@ interface StreamTextResult<TOOLS extends ToolSet, OUTPUT extends Output> {
|
|
|
2395
2395
|
/**
|
|
2396
2396
|
* Writes UI message stream output to a Node.js response-like object.
|
|
2397
2397
|
*/
|
|
2398
|
-
pipeUIMessageStreamToResponse<UI_MESSAGE extends UIMessage>(response: ServerResponse, options?: UIMessageStreamResponseInit & UIMessageStreamOptions<UI_MESSAGE>): void
|
|
2398
|
+
pipeUIMessageStreamToResponse<UI_MESSAGE extends UIMessage>(response: ServerResponse, options?: UIMessageStreamResponseInit & UIMessageStreamOptions<UI_MESSAGE>): Promise<void>;
|
|
2399
2399
|
/**
|
|
2400
2400
|
* Writes text delta output to a Node.js response-like object.
|
|
2401
2401
|
* It sets a `Content-Type` header to `text/plain; charset=utf-8` and
|
|
@@ -2404,7 +2404,7 @@ interface StreamTextResult<TOOLS extends ToolSet, OUTPUT extends Output> {
|
|
|
2404
2404
|
* @param response A Node.js response-like object (ServerResponse).
|
|
2405
2405
|
* @param init Optional headers, status code, and status text.
|
|
2406
2406
|
*/
|
|
2407
|
-
pipeTextStreamToResponse(response: ServerResponse, init?: ResponseInit): void
|
|
2407
|
+
pipeTextStreamToResponse(response: ServerResponse, init?: ResponseInit): Promise<void>;
|
|
2408
2408
|
/**
|
|
2409
2409
|
* Converts the result to a streamed response object with a stream data part stream.
|
|
2410
2410
|
*
|
|
@@ -4245,11 +4245,12 @@ declare class JsonToSseTransformStream extends TransformStream<unknown, string>
|
|
|
4245
4245
|
* @param options.headers - Additional HTTP headers to include in the response.
|
|
4246
4246
|
* @param options.stream - The UI message chunk stream to send.
|
|
4247
4247
|
* @param options.consumeSseStream - Optional callback to consume a copy of the SSE stream independently.
|
|
4248
|
+
* @returns A promise that resolves when the stream has been written.
|
|
4248
4249
|
*/
|
|
4249
4250
|
declare function pipeUIMessageStreamToResponse({ response, status, statusText, headers, stream, consumeSseStream, }: {
|
|
4250
4251
|
response: ServerResponse;
|
|
4251
4252
|
stream: ReadableStream<UIMessageChunk>;
|
|
4252
|
-
} & UIMessageStreamResponseInit): void
|
|
4253
|
+
} & UIMessageStreamResponseInit): Promise<void>;
|
|
4253
4254
|
|
|
4254
4255
|
/**
|
|
4255
4256
|
* Transforms a stream of `UIMessageChunk`s into an `AsyncIterableStream` of `UIMessage`s.
|
|
@@ -5398,7 +5399,7 @@ interface StreamObjectResult<PARTIAL, RESULT, ELEMENT_STREAM> {
|
|
|
5398
5399
|
* @param response A Node.js response-like object (ServerResponse).
|
|
5399
5400
|
* @param init Optional headers, status code, and status text.
|
|
5400
5401
|
*/
|
|
5401
|
-
pipeTextStreamToResponse(response: ServerResponse$1, init?: ResponseInit): void
|
|
5402
|
+
pipeTextStreamToResponse(response: ServerResponse$1, init?: ResponseInit): Promise<void>;
|
|
5402
5403
|
/**
|
|
5403
5404
|
* Creates a simple text stream response.
|
|
5404
5405
|
* The response has a `Content-Type` header set to `text/plain; charset=utf-8`.
|
|
@@ -6283,11 +6284,12 @@ declare function createTextStreamResponse({ status, statusText, headers, textStr
|
|
|
6283
6284
|
* @param options.statusText - Optional HTTP status text.
|
|
6284
6285
|
* @param options.headers - Optional response headers.
|
|
6285
6286
|
* @param options.textStream - The text stream to pipe.
|
|
6287
|
+
* @returns A promise that resolves when the stream has been written.
|
|
6286
6288
|
*/
|
|
6287
6289
|
declare function pipeTextStreamToResponse({ response, status, statusText, headers, textStream, }: {
|
|
6288
6290
|
response: ServerResponse;
|
|
6289
6291
|
textStream: ReadableStream<string>;
|
|
6290
|
-
} & ResponseInit): void
|
|
6292
|
+
} & ResponseInit): Promise<void>;
|
|
6291
6293
|
|
|
6292
6294
|
/**
|
|
6293
6295
|
* The result of a `transcribe` call.
|
package/dist/index.d.ts
CHANGED
|
@@ -2395,7 +2395,7 @@ interface StreamTextResult<TOOLS extends ToolSet, OUTPUT extends Output> {
|
|
|
2395
2395
|
/**
|
|
2396
2396
|
* Writes UI message stream output to a Node.js response-like object.
|
|
2397
2397
|
*/
|
|
2398
|
-
pipeUIMessageStreamToResponse<UI_MESSAGE extends UIMessage>(response: ServerResponse, options?: UIMessageStreamResponseInit & UIMessageStreamOptions<UI_MESSAGE>): void
|
|
2398
|
+
pipeUIMessageStreamToResponse<UI_MESSAGE extends UIMessage>(response: ServerResponse, options?: UIMessageStreamResponseInit & UIMessageStreamOptions<UI_MESSAGE>): Promise<void>;
|
|
2399
2399
|
/**
|
|
2400
2400
|
* Writes text delta output to a Node.js response-like object.
|
|
2401
2401
|
* It sets a `Content-Type` header to `text/plain; charset=utf-8` and
|
|
@@ -2404,7 +2404,7 @@ interface StreamTextResult<TOOLS extends ToolSet, OUTPUT extends Output> {
|
|
|
2404
2404
|
* @param response A Node.js response-like object (ServerResponse).
|
|
2405
2405
|
* @param init Optional headers, status code, and status text.
|
|
2406
2406
|
*/
|
|
2407
|
-
pipeTextStreamToResponse(response: ServerResponse, init?: ResponseInit): void
|
|
2407
|
+
pipeTextStreamToResponse(response: ServerResponse, init?: ResponseInit): Promise<void>;
|
|
2408
2408
|
/**
|
|
2409
2409
|
* Converts the result to a streamed response object with a stream data part stream.
|
|
2410
2410
|
*
|
|
@@ -4245,11 +4245,12 @@ declare class JsonToSseTransformStream extends TransformStream<unknown, string>
|
|
|
4245
4245
|
* @param options.headers - Additional HTTP headers to include in the response.
|
|
4246
4246
|
* @param options.stream - The UI message chunk stream to send.
|
|
4247
4247
|
* @param options.consumeSseStream - Optional callback to consume a copy of the SSE stream independently.
|
|
4248
|
+
* @returns A promise that resolves when the stream has been written.
|
|
4248
4249
|
*/
|
|
4249
4250
|
declare function pipeUIMessageStreamToResponse({ response, status, statusText, headers, stream, consumeSseStream, }: {
|
|
4250
4251
|
response: ServerResponse;
|
|
4251
4252
|
stream: ReadableStream<UIMessageChunk>;
|
|
4252
|
-
} & UIMessageStreamResponseInit): void
|
|
4253
|
+
} & UIMessageStreamResponseInit): Promise<void>;
|
|
4253
4254
|
|
|
4254
4255
|
/**
|
|
4255
4256
|
* Transforms a stream of `UIMessageChunk`s into an `AsyncIterableStream` of `UIMessage`s.
|
|
@@ -5398,7 +5399,7 @@ interface StreamObjectResult<PARTIAL, RESULT, ELEMENT_STREAM> {
|
|
|
5398
5399
|
* @param response A Node.js response-like object (ServerResponse).
|
|
5399
5400
|
* @param init Optional headers, status code, and status text.
|
|
5400
5401
|
*/
|
|
5401
|
-
pipeTextStreamToResponse(response: ServerResponse$1, init?: ResponseInit): void
|
|
5402
|
+
pipeTextStreamToResponse(response: ServerResponse$1, init?: ResponseInit): Promise<void>;
|
|
5402
5403
|
/**
|
|
5403
5404
|
* Creates a simple text stream response.
|
|
5404
5405
|
* The response has a `Content-Type` header set to `text/plain; charset=utf-8`.
|
|
@@ -6283,11 +6284,12 @@ declare function createTextStreamResponse({ status, statusText, headers, textStr
|
|
|
6283
6284
|
* @param options.statusText - Optional HTTP status text.
|
|
6284
6285
|
* @param options.headers - Optional response headers.
|
|
6285
6286
|
* @param options.textStream - The text stream to pipe.
|
|
6287
|
+
* @returns A promise that resolves when the stream has been written.
|
|
6286
6288
|
*/
|
|
6287
6289
|
declare function pipeTextStreamToResponse({ response, status, statusText, headers, textStream, }: {
|
|
6288
6290
|
response: ServerResponse;
|
|
6289
6291
|
textStream: ReadableStream<string>;
|
|
6290
|
-
} & ResponseInit): void
|
|
6292
|
+
} & ResponseInit): Promise<void>;
|
|
6291
6293
|
|
|
6292
6294
|
/**
|
|
6293
6295
|
* The result of a `transcribe` call.
|
package/dist/index.js
CHANGED
|
@@ -1200,7 +1200,17 @@ var audioMediaTypeSignatures = [
|
|
|
1200
1200
|
},
|
|
1201
1201
|
{
|
|
1202
1202
|
mediaType: "audio/mp4",
|
|
1203
|
-
bytesPrefix: [
|
|
1203
|
+
bytesPrefix: [
|
|
1204
|
+
0,
|
|
1205
|
+
0,
|
|
1206
|
+
0,
|
|
1207
|
+
null,
|
|
1208
|
+
102,
|
|
1209
|
+
116,
|
|
1210
|
+
121,
|
|
1211
|
+
112
|
|
1212
|
+
// ftyp
|
|
1213
|
+
]
|
|
1204
1214
|
},
|
|
1205
1215
|
{
|
|
1206
1216
|
mediaType: "audio/webm",
|
|
@@ -1249,25 +1259,37 @@ var videoMediaTypeSignatures = [
|
|
|
1249
1259
|
// RIFF (AVI)
|
|
1250
1260
|
}
|
|
1251
1261
|
];
|
|
1252
|
-
var
|
|
1253
|
-
|
|
1262
|
+
var DEFAULT_SNIFF_BYTES = 18;
|
|
1263
|
+
var MAX_SIGNATURE_BYTES = 12;
|
|
1264
|
+
var MAX_ID3_TAG_BYTES = 128 * 1024;
|
|
1265
|
+
var ID3_SCAN_BYTES = MAX_ID3_TAG_BYTES + MAX_SIGNATURE_BYTES;
|
|
1266
|
+
function decodePrefix(data, maxBytes) {
|
|
1267
|
+
if (typeof data !== "string") {
|
|
1268
|
+
return data.length > maxBytes ? data.subarray(0, maxBytes) : data;
|
|
1269
|
+
}
|
|
1270
|
+
const maxChars = Math.ceil(maxBytes / 3) * 4;
|
|
1271
|
+
const bytes = (0, import_provider_utils2.convertBase64ToUint8Array)(
|
|
1272
|
+
data.substring(0, Math.min(data.length, maxChars))
|
|
1273
|
+
);
|
|
1274
|
+
return bytes.length > maxBytes ? bytes.subarray(0, maxBytes) : bytes;
|
|
1275
|
+
}
|
|
1276
|
+
function hasID3(bytes) {
|
|
1277
|
+
return bytes.length > 10 && bytes[0] === 73 && // 'I'
|
|
1278
|
+
bytes[1] === 68 && // 'D'
|
|
1279
|
+
bytes[2] === 51;
|
|
1280
|
+
}
|
|
1281
|
+
var stripID3 = (bytes) => {
|
|
1254
1282
|
const id3Size = (bytes[6] & 127) << 21 | (bytes[7] & 127) << 14 | (bytes[8] & 127) << 7 | bytes[9] & 127;
|
|
1255
|
-
return bytes.
|
|
1283
|
+
return bytes.subarray(id3Size + 10);
|
|
1256
1284
|
};
|
|
1257
|
-
function stripID3TagsIfPresent(data) {
|
|
1258
|
-
const hasId3 = typeof data === "string" && data.startsWith("SUQz") || typeof data !== "string" && data.length > 10 && data[0] === 73 && // 'I'
|
|
1259
|
-
data[1] === 68 && // 'D'
|
|
1260
|
-
data[2] === 51;
|
|
1261
|
-
return hasId3 ? stripID3(data) : data;
|
|
1262
|
-
}
|
|
1263
1285
|
function detectMediaType({
|
|
1264
1286
|
data,
|
|
1265
1287
|
signatures
|
|
1266
1288
|
}) {
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1289
|
+
let bytes = decodePrefix(data, DEFAULT_SNIFF_BYTES);
|
|
1290
|
+
if (hasID3(bytes)) {
|
|
1291
|
+
bytes = stripID3(decodePrefix(data, ID3_SCAN_BYTES));
|
|
1292
|
+
}
|
|
1271
1293
|
for (const signature of signatures) {
|
|
1272
1294
|
if (bytes.length >= signature.bytesPrefix.length && signature.bytesPrefix.every(
|
|
1273
1295
|
(byte, index) => byte === null || bytes[index] === byte
|
|
@@ -1282,7 +1304,7 @@ function detectMediaType({
|
|
|
1282
1304
|
var import_provider_utils3 = require("@ai-sdk/provider-utils");
|
|
1283
1305
|
|
|
1284
1306
|
// src/version.ts
|
|
1285
|
-
var VERSION = true ? "6.0.
|
|
1307
|
+
var VERSION = true ? "6.0.234" : "0.0.0-test";
|
|
1286
1308
|
|
|
1287
1309
|
// src/util/download/download.ts
|
|
1288
1310
|
var download = async ({
|
|
@@ -5452,7 +5474,7 @@ function writeToServerResponse({
|
|
|
5452
5474
|
response.end();
|
|
5453
5475
|
}
|
|
5454
5476
|
};
|
|
5455
|
-
read();
|
|
5477
|
+
return read();
|
|
5456
5478
|
}
|
|
5457
5479
|
|
|
5458
5480
|
// src/text-stream/pipe-text-stream-to-response.ts
|
|
@@ -5463,7 +5485,7 @@ function pipeTextStreamToResponse({
|
|
|
5463
5485
|
headers,
|
|
5464
5486
|
textStream
|
|
5465
5487
|
}) {
|
|
5466
|
-
writeToServerResponse({
|
|
5488
|
+
return writeToServerResponse({
|
|
5467
5489
|
response,
|
|
5468
5490
|
status,
|
|
5469
5491
|
statusText,
|
|
@@ -5786,11 +5808,32 @@ function processUIMessageStream({
|
|
|
5786
5808
|
async transform(chunk, controller) {
|
|
5787
5809
|
await runUpdateMessageJob(async ({ state, write }) => {
|
|
5788
5810
|
var _a22, _b, _c, _d;
|
|
5811
|
+
function getCurrentStepParts() {
|
|
5812
|
+
const parts = state.message.parts;
|
|
5813
|
+
let currentStepStartIndex = parts.length - 1;
|
|
5814
|
+
while (currentStepStartIndex >= 0 && parts[currentStepStartIndex].type !== "step-start") {
|
|
5815
|
+
currentStepStartIndex--;
|
|
5816
|
+
}
|
|
5817
|
+
return parts.slice(currentStepStartIndex + 1);
|
|
5818
|
+
}
|
|
5819
|
+
function getCurrentStepToolInvocations() {
|
|
5820
|
+
return getCurrentStepParts().filter(isToolUIPart);
|
|
5821
|
+
}
|
|
5789
5822
|
function getToolInvocation(toolCallId) {
|
|
5790
|
-
const toolInvocations =
|
|
5791
|
-
|
|
5823
|
+
const toolInvocations = getCurrentStepToolInvocations();
|
|
5824
|
+
let toolInvocation = toolInvocations.find(
|
|
5792
5825
|
(invocation) => invocation.toolCallId === toolCallId
|
|
5793
5826
|
);
|
|
5827
|
+
if (toolInvocation == null) {
|
|
5828
|
+
const parts = state.message.parts;
|
|
5829
|
+
for (let i = parts.length - 1; i >= 0; i--) {
|
|
5830
|
+
const part = parts[i];
|
|
5831
|
+
if (isToolUIPart(part) && part.toolCallId === toolCallId) {
|
|
5832
|
+
toolInvocation = part;
|
|
5833
|
+
break;
|
|
5834
|
+
}
|
|
5835
|
+
}
|
|
5836
|
+
}
|
|
5794
5837
|
if (toolInvocation == null) {
|
|
5795
5838
|
throw new UIMessageStreamError({
|
|
5796
5839
|
chunkType: "tool-invocation",
|
|
@@ -5800,9 +5843,9 @@ function processUIMessageStream({
|
|
|
5800
5843
|
}
|
|
5801
5844
|
return toolInvocation;
|
|
5802
5845
|
}
|
|
5803
|
-
function updateToolPart(options) {
|
|
5846
|
+
function updateToolPart(options, existingPart) {
|
|
5804
5847
|
var _a23;
|
|
5805
|
-
const part =
|
|
5848
|
+
const part = existingPart != null ? existingPart : getCurrentStepParts().find(
|
|
5806
5849
|
(part2) => isStaticToolUIPart(part2) && part2.toolCallId === options.toolCallId
|
|
5807
5850
|
);
|
|
5808
5851
|
const anyOptions = options;
|
|
@@ -5848,9 +5891,9 @@ function processUIMessageStream({
|
|
|
5848
5891
|
});
|
|
5849
5892
|
}
|
|
5850
5893
|
}
|
|
5851
|
-
function updateDynamicToolPart(options) {
|
|
5894
|
+
function updateDynamicToolPart(options, existingPart) {
|
|
5852
5895
|
var _a23, _b2;
|
|
5853
|
-
const part =
|
|
5896
|
+
const part = existingPart != null ? existingPart : getCurrentStepParts().find(
|
|
5854
5897
|
(part2) => part2.type === "dynamic-tool" && part2.toolCallId === options.toolCallId
|
|
5855
5898
|
);
|
|
5856
5899
|
const anyOptions = options;
|
|
@@ -6030,7 +6073,7 @@ function processUIMessageStream({
|
|
|
6030
6073
|
break;
|
|
6031
6074
|
}
|
|
6032
6075
|
case "tool-input-start": {
|
|
6033
|
-
const toolInvocations =
|
|
6076
|
+
const toolInvocations = getCurrentStepParts().filter(isStaticToolUIPart);
|
|
6034
6077
|
state.partialToolCalls[chunk.toolCallId] = {
|
|
6035
6078
|
text: "",
|
|
6036
6079
|
toolName: chunk.toolName,
|
|
@@ -6133,7 +6176,7 @@ function processUIMessageStream({
|
|
|
6133
6176
|
break;
|
|
6134
6177
|
}
|
|
6135
6178
|
case "tool-input-error": {
|
|
6136
|
-
const existingPart =
|
|
6179
|
+
const existingPart = getCurrentStepParts().filter(isToolUIPart).find((p) => p.toolCallId === chunk.toolCallId);
|
|
6137
6180
|
const isDynamic = existingPart != null ? existingPart.type === "dynamic-tool" : !!chunk.dynamic;
|
|
6138
6181
|
if (isDynamic) {
|
|
6139
6182
|
updateDynamicToolPart({
|
|
@@ -6181,31 +6224,37 @@ function processUIMessageStream({
|
|
|
6181
6224
|
case "tool-output-available": {
|
|
6182
6225
|
const toolInvocation = getToolInvocation(chunk.toolCallId);
|
|
6183
6226
|
if (toolInvocation.type === "dynamic-tool") {
|
|
6184
|
-
updateDynamicToolPart(
|
|
6185
|
-
|
|
6186
|
-
|
|
6187
|
-
|
|
6188
|
-
|
|
6189
|
-
|
|
6190
|
-
|
|
6191
|
-
|
|
6192
|
-
|
|
6193
|
-
|
|
6194
|
-
|
|
6195
|
-
|
|
6227
|
+
updateDynamicToolPart(
|
|
6228
|
+
{
|
|
6229
|
+
toolCallId: chunk.toolCallId,
|
|
6230
|
+
toolName: toolInvocation.toolName,
|
|
6231
|
+
state: "output-available",
|
|
6232
|
+
input: toolInvocation.input,
|
|
6233
|
+
output: chunk.output,
|
|
6234
|
+
preliminary: chunk.preliminary,
|
|
6235
|
+
providerExecuted: chunk.providerExecuted,
|
|
6236
|
+
providerMetadata: chunk.providerMetadata,
|
|
6237
|
+
title: toolInvocation.title,
|
|
6238
|
+
toolMetadata: toolInvocation.toolMetadata
|
|
6239
|
+
},
|
|
6240
|
+
toolInvocation
|
|
6241
|
+
);
|
|
6196
6242
|
} else {
|
|
6197
|
-
updateToolPart(
|
|
6198
|
-
|
|
6199
|
-
|
|
6200
|
-
|
|
6201
|
-
|
|
6202
|
-
|
|
6203
|
-
|
|
6204
|
-
|
|
6205
|
-
|
|
6206
|
-
|
|
6207
|
-
|
|
6208
|
-
|
|
6243
|
+
updateToolPart(
|
|
6244
|
+
{
|
|
6245
|
+
toolCallId: chunk.toolCallId,
|
|
6246
|
+
toolName: getStaticToolName(toolInvocation),
|
|
6247
|
+
state: "output-available",
|
|
6248
|
+
input: toolInvocation.input,
|
|
6249
|
+
output: chunk.output,
|
|
6250
|
+
providerExecuted: chunk.providerExecuted,
|
|
6251
|
+
preliminary: chunk.preliminary,
|
|
6252
|
+
providerMetadata: chunk.providerMetadata,
|
|
6253
|
+
title: toolInvocation.title,
|
|
6254
|
+
toolMetadata: toolInvocation.toolMetadata
|
|
6255
|
+
},
|
|
6256
|
+
toolInvocation
|
|
6257
|
+
);
|
|
6209
6258
|
}
|
|
6210
6259
|
write();
|
|
6211
6260
|
break;
|
|
@@ -6213,30 +6262,36 @@ function processUIMessageStream({
|
|
|
6213
6262
|
case "tool-output-error": {
|
|
6214
6263
|
const toolInvocation = getToolInvocation(chunk.toolCallId);
|
|
6215
6264
|
if (toolInvocation.type === "dynamic-tool") {
|
|
6216
|
-
updateDynamicToolPart(
|
|
6217
|
-
|
|
6218
|
-
|
|
6219
|
-
|
|
6220
|
-
|
|
6221
|
-
|
|
6222
|
-
|
|
6223
|
-
|
|
6224
|
-
|
|
6225
|
-
|
|
6226
|
-
|
|
6265
|
+
updateDynamicToolPart(
|
|
6266
|
+
{
|
|
6267
|
+
toolCallId: chunk.toolCallId,
|
|
6268
|
+
toolName: toolInvocation.toolName,
|
|
6269
|
+
state: "output-error",
|
|
6270
|
+
input: toolInvocation.input,
|
|
6271
|
+
errorText: chunk.errorText,
|
|
6272
|
+
providerExecuted: chunk.providerExecuted,
|
|
6273
|
+
providerMetadata: chunk.providerMetadata,
|
|
6274
|
+
title: toolInvocation.title,
|
|
6275
|
+
toolMetadata: toolInvocation.toolMetadata
|
|
6276
|
+
},
|
|
6277
|
+
toolInvocation
|
|
6278
|
+
);
|
|
6227
6279
|
} else {
|
|
6228
|
-
updateToolPart(
|
|
6229
|
-
|
|
6230
|
-
|
|
6231
|
-
|
|
6232
|
-
|
|
6233
|
-
|
|
6234
|
-
|
|
6235
|
-
|
|
6236
|
-
|
|
6237
|
-
|
|
6238
|
-
|
|
6239
|
-
|
|
6280
|
+
updateToolPart(
|
|
6281
|
+
{
|
|
6282
|
+
toolCallId: chunk.toolCallId,
|
|
6283
|
+
toolName: getStaticToolName(toolInvocation),
|
|
6284
|
+
state: "output-error",
|
|
6285
|
+
input: toolInvocation.input,
|
|
6286
|
+
rawInput: toolInvocation.rawInput,
|
|
6287
|
+
errorText: chunk.errorText,
|
|
6288
|
+
providerExecuted: chunk.providerExecuted,
|
|
6289
|
+
providerMetadata: chunk.providerMetadata,
|
|
6290
|
+
title: toolInvocation.title,
|
|
6291
|
+
toolMetadata: toolInvocation.toolMetadata
|
|
6292
|
+
},
|
|
6293
|
+
toolInvocation
|
|
6294
|
+
);
|
|
6240
6295
|
}
|
|
6241
6296
|
write();
|
|
6242
6297
|
break;
|
|
@@ -6441,7 +6496,7 @@ function pipeUIMessageStreamToResponse({
|
|
|
6441
6496
|
sseStream = stream1;
|
|
6442
6497
|
consumeSseStream({ stream: stream2 });
|
|
6443
6498
|
}
|
|
6444
|
-
writeToServerResponse({
|
|
6499
|
+
return writeToServerResponse({
|
|
6445
6500
|
response,
|
|
6446
6501
|
status,
|
|
6447
6502
|
statusText,
|
|
@@ -8678,7 +8733,7 @@ var DefaultStreamTextResult = class {
|
|
|
8678
8733
|
onError,
|
|
8679
8734
|
...init
|
|
8680
8735
|
} = {}) {
|
|
8681
|
-
pipeUIMessageStreamToResponse({
|
|
8736
|
+
return pipeUIMessageStreamToResponse({
|
|
8682
8737
|
response,
|
|
8683
8738
|
stream: this.toUIMessageStream({
|
|
8684
8739
|
originalMessages,
|
|
@@ -8695,7 +8750,7 @@ var DefaultStreamTextResult = class {
|
|
|
8695
8750
|
});
|
|
8696
8751
|
}
|
|
8697
8752
|
pipeTextStreamToResponse(response, init) {
|
|
8698
|
-
pipeTextStreamToResponse({
|
|
8753
|
+
return pipeTextStreamToResponse({
|
|
8699
8754
|
response,
|
|
8700
8755
|
textStream: this.textStream,
|
|
8701
8756
|
...init
|
|
@@ -9722,7 +9777,7 @@ async function pipeAgentUIStreamToResponse({
|
|
|
9722
9777
|
consumeSseStream,
|
|
9723
9778
|
...options
|
|
9724
9779
|
}) {
|
|
9725
|
-
pipeUIMessageStreamToResponse({
|
|
9780
|
+
return pipeUIMessageStreamToResponse({
|
|
9726
9781
|
response,
|
|
9727
9782
|
headers,
|
|
9728
9783
|
status,
|
|
@@ -11669,7 +11724,7 @@ var DefaultStreamObjectResult = class {
|
|
|
11669
11724
|
return createAsyncIterableStream(this.baseStream);
|
|
11670
11725
|
}
|
|
11671
11726
|
pipeTextStreamToResponse(response, init) {
|
|
11672
|
-
pipeTextStreamToResponse({
|
|
11727
|
+
return pipeTextStreamToResponse({
|
|
11673
11728
|
response,
|
|
11674
11729
|
textStream: this.textStream,
|
|
11675
11730
|
...init
|