ai 3.3.29 → 3.3.30
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.d.mts +13 -1
- package/dist/index.d.ts +13 -1
- package/dist/index.js +10 -5
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +10 -5
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/dist/index.d.mts
CHANGED
@@ -1519,10 +1519,22 @@ interface StreamTextResult<TOOLS extends Record<string, CoreTool>> {
|
|
1519
1519
|
|
1520
1520
|
@returns A data stream.
|
1521
1521
|
|
1522
|
-
@deprecated Use `
|
1522
|
+
@deprecated Use `toDataStream` instead.
|
1523
1523
|
*/
|
1524
1524
|
toAIStream(callbacks?: AIStreamCallbacksAndOptions): ReadableStream<Uint8Array>;
|
1525
1525
|
/**
|
1526
|
+
Converts the result to a data stream.
|
1527
|
+
|
1528
|
+
@param data an optional StreamData object that will be merged into the stream.
|
1529
|
+
@param getErrorMessage an optional function that converts an error to an error message.
|
1530
|
+
|
1531
|
+
@return A data stream.
|
1532
|
+
*/
|
1533
|
+
toDataStream(options?: {
|
1534
|
+
data?: StreamData;
|
1535
|
+
getErrorMessage?: (error: unknown) => string;
|
1536
|
+
}): ReadableStream<Uint8Array>;
|
1537
|
+
/**
|
1526
1538
|
Writes stream data output to a Node.js response-like object.
|
1527
1539
|
It sets a `Content-Type` header to `text/plain; charset=utf-8` and
|
1528
1540
|
writes each stream data part as a separate chunk.
|
package/dist/index.d.ts
CHANGED
@@ -1519,10 +1519,22 @@ interface StreamTextResult<TOOLS extends Record<string, CoreTool>> {
|
|
1519
1519
|
|
1520
1520
|
@returns A data stream.
|
1521
1521
|
|
1522
|
-
@deprecated Use `
|
1522
|
+
@deprecated Use `toDataStream` instead.
|
1523
1523
|
*/
|
1524
1524
|
toAIStream(callbacks?: AIStreamCallbacksAndOptions): ReadableStream<Uint8Array>;
|
1525
1525
|
/**
|
1526
|
+
Converts the result to a data stream.
|
1527
|
+
|
1528
|
+
@param data an optional StreamData object that will be merged into the stream.
|
1529
|
+
@param getErrorMessage an optional function that converts an error to an error message.
|
1530
|
+
|
1531
|
+
@return A data stream.
|
1532
|
+
*/
|
1533
|
+
toDataStream(options?: {
|
1534
|
+
data?: StreamData;
|
1535
|
+
getErrorMessage?: (error: unknown) => string;
|
1536
|
+
}): ReadableStream<Uint8Array>;
|
1537
|
+
/**
|
1526
1538
|
Writes stream data output to a Node.js response-like object.
|
1527
1539
|
It sets a `Content-Type` header to `text/plain; charset=utf-8` and
|
1528
1540
|
writes each stream data part as a separate chunk.
|
package/dist/index.js
CHANGED
@@ -4056,9 +4056,9 @@ var DefaultStreamTextResult = class {
|
|
4056
4056
|
});
|
4057
4057
|
}
|
4058
4058
|
toAIStream(callbacks = {}) {
|
4059
|
-
return this.
|
4059
|
+
return this.toDataStreamInternal({ callbacks });
|
4060
4060
|
}
|
4061
|
-
|
4061
|
+
toDataStreamInternal({
|
4062
4062
|
callbacks = {},
|
4063
4063
|
getErrorMessage: getErrorMessage4 = () => ""
|
4064
4064
|
// mask error messages for safety by default
|
@@ -4182,7 +4182,7 @@ var DefaultStreamTextResult = class {
|
|
4182
4182
|
contentType: "text/plain; charset=utf-8",
|
4183
4183
|
dataStreamVersion: "v1"
|
4184
4184
|
}),
|
4185
|
-
stream:
|
4185
|
+
stream: this.toDataStream({ data, getErrorMessage: getErrorMessage4 })
|
4186
4186
|
});
|
4187
4187
|
}
|
4188
4188
|
pipeTextStreamToResponse(response, init) {
|
@@ -4199,6 +4199,12 @@ var DefaultStreamTextResult = class {
|
|
4199
4199
|
toAIStreamResponse(options) {
|
4200
4200
|
return this.toDataStreamResponse(options);
|
4201
4201
|
}
|
4202
|
+
toDataStream(options) {
|
4203
|
+
const stream = this.toDataStreamInternal({
|
4204
|
+
getErrorMessage: options == null ? void 0 : options.getErrorMessage
|
4205
|
+
});
|
4206
|
+
return (options == null ? void 0 : options.data) ? mergeStreams(options == null ? void 0 : options.data.stream, stream) : stream;
|
4207
|
+
}
|
4202
4208
|
toDataStreamResponse(options) {
|
4203
4209
|
var _a11;
|
4204
4210
|
const init = options == null ? void 0 : "init" in options ? options.init : {
|
@@ -4208,8 +4214,7 @@ var DefaultStreamTextResult = class {
|
|
4208
4214
|
};
|
4209
4215
|
const data = options == null ? void 0 : "data" in options ? options.data : void 0;
|
4210
4216
|
const getErrorMessage4 = options == null ? void 0 : "getErrorMessage" in options ? options.getErrorMessage : void 0;
|
4211
|
-
|
4212
|
-
return new Response(stream, {
|
4217
|
+
return new Response(this.toDataStream({ data, getErrorMessage: getErrorMessage4 }), {
|
4213
4218
|
status: (_a11 = init == null ? void 0 : init.status) != null ? _a11 : 200,
|
4214
4219
|
statusText: init == null ? void 0 : init.statusText,
|
4215
4220
|
headers: prepareResponseHeaders(init, {
|