ai 4.0.0-canary.5 → 4.0.0-canary.6
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 +10 -0
- package/dist/index.d.mts +14 -8
- package/dist/index.d.ts +14 -8
- package/dist/index.js +44 -48
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +44 -48
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -7
package/dist/index.mjs
CHANGED
@@ -1499,19 +1499,18 @@ function calculateLanguageModelUsage(usage) {
|
|
1499
1499
|
}
|
1500
1500
|
|
1501
1501
|
// core/util/prepare-response-headers.ts
|
1502
|
-
function prepareResponseHeaders(
|
1502
|
+
function prepareResponseHeaders(headers, {
|
1503
1503
|
contentType,
|
1504
1504
|
dataStreamVersion
|
1505
1505
|
}) {
|
1506
|
-
|
1507
|
-
|
1508
|
-
|
1509
|
-
headers.set("Content-Type", contentType);
|
1506
|
+
const responseHeaders = new Headers(headers != null ? headers : {});
|
1507
|
+
if (!responseHeaders.has("Content-Type")) {
|
1508
|
+
responseHeaders.set("Content-Type", contentType);
|
1510
1509
|
}
|
1511
1510
|
if (dataStreamVersion !== void 0) {
|
1512
|
-
|
1511
|
+
responseHeaders.set("X-Vercel-AI-Data-Stream", dataStreamVersion);
|
1513
1512
|
}
|
1514
|
-
return
|
1513
|
+
return responseHeaders;
|
1515
1514
|
}
|
1516
1515
|
|
1517
1516
|
// core/generate-object/inject-json-instruction.ts
|
@@ -2277,7 +2276,7 @@ var DefaultGenerateObjectResult = class {
|
|
2277
2276
|
var _a11;
|
2278
2277
|
return new Response(JSON.stringify(this.object), {
|
2279
2278
|
status: (_a11 = init == null ? void 0 : init.status) != null ? _a11 : 200,
|
2280
|
-
headers: prepareResponseHeaders(init, {
|
2279
|
+
headers: prepareResponseHeaders(init == null ? void 0 : init.headers, {
|
2281
2280
|
contentType: "application/json; charset=utf-8"
|
2282
2281
|
})
|
2283
2282
|
});
|
@@ -2351,23 +2350,23 @@ function now() {
|
|
2351
2350
|
}
|
2352
2351
|
|
2353
2352
|
// core/util/prepare-outgoing-http-headers.ts
|
2354
|
-
function prepareOutgoingHttpHeaders(
|
2353
|
+
function prepareOutgoingHttpHeaders(headers, {
|
2355
2354
|
contentType,
|
2356
2355
|
dataStreamVersion
|
2357
2356
|
}) {
|
2358
|
-
const
|
2359
|
-
if (
|
2360
|
-
for (const [key, value] of Object.entries(
|
2361
|
-
|
2357
|
+
const outgoingHeaders = {};
|
2358
|
+
if (headers != null) {
|
2359
|
+
for (const [key, value] of Object.entries(headers)) {
|
2360
|
+
outgoingHeaders[key] = value;
|
2362
2361
|
}
|
2363
2362
|
}
|
2364
|
-
if (
|
2365
|
-
|
2363
|
+
if (outgoingHeaders["Content-Type"] == null) {
|
2364
|
+
outgoingHeaders["Content-Type"] = contentType;
|
2366
2365
|
}
|
2367
2366
|
if (dataStreamVersion !== void 0) {
|
2368
|
-
|
2367
|
+
outgoingHeaders["X-Vercel-AI-Data-Stream"] = dataStreamVersion;
|
2369
2368
|
}
|
2370
|
-
return
|
2369
|
+
return outgoingHeaders;
|
2371
2370
|
}
|
2372
2371
|
|
2373
2372
|
// core/util/write-to-server-response.ts
|
@@ -2882,7 +2881,7 @@ var DefaultStreamObjectResult = class {
|
|
2882
2881
|
response,
|
2883
2882
|
status: init == null ? void 0 : init.status,
|
2884
2883
|
statusText: init == null ? void 0 : init.statusText,
|
2885
|
-
headers: prepareOutgoingHttpHeaders(init, {
|
2884
|
+
headers: prepareOutgoingHttpHeaders(init == null ? void 0 : init.headers, {
|
2886
2885
|
contentType: "text/plain; charset=utf-8"
|
2887
2886
|
}),
|
2888
2887
|
stream: this.textStream.pipeThrough(new TextEncoderStream())
|
@@ -2892,7 +2891,7 @@ var DefaultStreamObjectResult = class {
|
|
2892
2891
|
var _a11;
|
2893
2892
|
return new Response(this.textStream.pipeThrough(new TextEncoderStream()), {
|
2894
2893
|
status: (_a11 = init == null ? void 0 : init.status) != null ? _a11 : 200,
|
2895
|
-
headers: prepareResponseHeaders(init, {
|
2894
|
+
headers: prepareResponseHeaders(init == null ? void 0 : init.headers, {
|
2896
2895
|
contentType: "text/plain; charset=utf-8"
|
2897
2896
|
})
|
2898
2897
|
});
|
@@ -4559,20 +4558,19 @@ var DefaultStreamTextResult = class {
|
|
4559
4558
|
});
|
4560
4559
|
return this.fullStream.pipeThrough(callbackTransformer).pipeThrough(streamPartsTransformer).pipeThrough(new TextEncoderStream());
|
4561
4560
|
}
|
4562
|
-
pipeDataStreamToResponse(response,
|
4563
|
-
|
4564
|
-
|
4565
|
-
|
4566
|
-
|
4567
|
-
|
4568
|
-
|
4569
|
-
|
4570
|
-
const sendUsage = options == null ? void 0 : "sendUsage" in options ? options.sendUsage : void 0;
|
4561
|
+
pipeDataStreamToResponse(response, {
|
4562
|
+
status,
|
4563
|
+
statusText,
|
4564
|
+
headers,
|
4565
|
+
data,
|
4566
|
+
getErrorMessage: getErrorMessage3,
|
4567
|
+
sendUsage
|
4568
|
+
} = {}) {
|
4571
4569
|
writeToServerResponse({
|
4572
4570
|
response,
|
4573
|
-
status
|
4574
|
-
statusText
|
4575
|
-
headers: prepareOutgoingHttpHeaders(
|
4571
|
+
status,
|
4572
|
+
statusText,
|
4573
|
+
headers: prepareOutgoingHttpHeaders(headers, {
|
4576
4574
|
contentType: "text/plain; charset=utf-8",
|
4577
4575
|
dataStreamVersion: "v1"
|
4578
4576
|
}),
|
@@ -4584,7 +4582,7 @@ var DefaultStreamTextResult = class {
|
|
4584
4582
|
response,
|
4585
4583
|
status: init == null ? void 0 : init.status,
|
4586
4584
|
statusText: init == null ? void 0 : init.statusText,
|
4587
|
-
headers: prepareOutgoingHttpHeaders(init, {
|
4585
|
+
headers: prepareOutgoingHttpHeaders(init == null ? void 0 : init.headers, {
|
4588
4586
|
contentType: "text/plain; charset=utf-8"
|
4589
4587
|
}),
|
4590
4588
|
stream: this.textStream.pipeThrough(new TextEncoderStream())
|
@@ -4597,22 +4595,20 @@ var DefaultStreamTextResult = class {
|
|
4597
4595
|
});
|
4598
4596
|
return (options == null ? void 0 : options.data) ? mergeStreams(options == null ? void 0 : options.data.stream, stream) : stream;
|
4599
4597
|
}
|
4600
|
-
toDataStreamResponse(
|
4601
|
-
|
4602
|
-
|
4603
|
-
|
4604
|
-
|
4605
|
-
|
4606
|
-
|
4607
|
-
|
4608
|
-
const getErrorMessage3 = options == null ? void 0 : "getErrorMessage" in options ? options.getErrorMessage : void 0;
|
4609
|
-
const sendUsage = options == null ? void 0 : "sendUsage" in options ? options.sendUsage : void 0;
|
4598
|
+
toDataStreamResponse({
|
4599
|
+
headers,
|
4600
|
+
status,
|
4601
|
+
statusText,
|
4602
|
+
data,
|
4603
|
+
getErrorMessage: getErrorMessage3,
|
4604
|
+
sendUsage
|
4605
|
+
} = {}) {
|
4610
4606
|
return new Response(
|
4611
4607
|
this.toDataStream({ data, getErrorMessage: getErrorMessage3, sendUsage }),
|
4612
4608
|
{
|
4613
|
-
status
|
4614
|
-
statusText
|
4615
|
-
headers: prepareResponseHeaders(
|
4609
|
+
status,
|
4610
|
+
statusText,
|
4611
|
+
headers: prepareResponseHeaders(headers, {
|
4616
4612
|
contentType: "text/plain; charset=utf-8",
|
4617
4613
|
dataStreamVersion: "v1"
|
4618
4614
|
})
|
@@ -4623,7 +4619,7 @@ var DefaultStreamTextResult = class {
|
|
4623
4619
|
var _a11;
|
4624
4620
|
return new Response(this.textStream.pipeThrough(new TextEncoderStream()), {
|
4625
4621
|
status: (_a11 = init == null ? void 0 : init.status) != null ? _a11 : 200,
|
4626
|
-
headers: prepareResponseHeaders(init, {
|
4622
|
+
headers: prepareResponseHeaders(init == null ? void 0 : init.headers, {
|
4627
4623
|
contentType: "text/plain; charset=utf-8"
|
4628
4624
|
})
|
4629
4625
|
});
|
@@ -5063,7 +5059,7 @@ function toDataStreamResponse(stream, options) {
|
|
5063
5059
|
return new Response(responseStream, {
|
5064
5060
|
status: (_a11 = init == null ? void 0 : init.status) != null ? _a11 : 200,
|
5065
5061
|
statusText: init == null ? void 0 : init.statusText,
|
5066
|
-
headers: prepareResponseHeaders(init, {
|
5062
|
+
headers: prepareResponseHeaders(init == null ? void 0 : init.headers, {
|
5067
5063
|
contentType: "text/plain; charset=utf-8",
|
5068
5064
|
dataStreamVersion: "v1"
|
5069
5065
|
})
|
@@ -5107,7 +5103,7 @@ function toDataStreamResponse2(stream, options = {}) {
|
|
5107
5103
|
return new Response(responseStream, {
|
5108
5104
|
status: (_a11 = init == null ? void 0 : init.status) != null ? _a11 : 200,
|
5109
5105
|
statusText: init == null ? void 0 : init.statusText,
|
5110
|
-
headers: prepareResponseHeaders(init, {
|
5106
|
+
headers: prepareResponseHeaders(init == null ? void 0 : init.headers, {
|
5111
5107
|
contentType: "text/plain; charset=utf-8",
|
5112
5108
|
dataStreamVersion: "v1"
|
5113
5109
|
})
|