ai 3.1.20 → 3.1.21

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/dist/index.mjs CHANGED
@@ -1372,6 +1372,16 @@ function toResponseMessages({
1372
1372
  }
1373
1373
  var experimental_generateText = generateText;
1374
1374
 
1375
+ // core/util/prepare-response-headers.ts
1376
+ function prepareResponseHeaders(init, { contentType }) {
1377
+ var _a;
1378
+ const headers = new Headers((_a = init == null ? void 0 : init.headers) != null ? _a : {});
1379
+ if (!headers.has("Content-Type")) {
1380
+ headers.set("Content-Type", contentType);
1381
+ }
1382
+ return headers;
1383
+ }
1384
+
1375
1385
  // core/generate-text/run-tools-transformation.ts
1376
1386
  import { NoSuchToolError as NoSuchToolError2 } from "@ai-sdk/provider";
1377
1387
 
@@ -1844,10 +1854,9 @@ var StreamTextResult = class {
1844
1854
  var _a;
1845
1855
  return new Response(this.textStream.pipeThrough(new TextEncoderStream()), {
1846
1856
  status: (_a = init == null ? void 0 : init.status) != null ? _a : 200,
1847
- headers: {
1848
- "Content-Type": "text/plain; charset=utf-8",
1849
- ...init == null ? void 0 : init.headers
1850
- }
1857
+ headers: prepareResponseHeaders(init, {
1858
+ contentType: "text/plain; charset=utf-8"
1859
+ })
1851
1860
  });
1852
1861
  }
1853
1862
  };
@@ -3477,10 +3486,9 @@ var StreamingTextResponse = class extends Response {
3477
3486
  super(processedStream, {
3478
3487
  ...init,
3479
3488
  status: 200,
3480
- headers: {
3481
- "Content-Type": "text/plain; charset=utf-8",
3482
- ...init == null ? void 0 : init.headers
3483
- }
3489
+ headers: prepareResponseHeaders(init, {
3490
+ contentType: "text/plain; charset=utf-8"
3491
+ })
3484
3492
  });
3485
3493
  }
3486
3494
  };