fumapress 0.1.21 → 0.1.23

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.
Files changed (71) hide show
  1. package/dist/lib/cli/index.mjs +1 -1
  2. package/dist/waku/public/assets/Icon-DLjCXBap.js +1 -0
  3. package/dist/waku/public/assets/{Icon-D30p-2dq.js → Icon-uimJ5tpe.js} +1 -1
  4. package/dist/waku/public/assets/_root-BWpoCRFY.css +1 -0
  5. package/dist/waku/public/assets/{_root-BWh8XBln.js → _root-DcSLRIv8.js} +2 -2
  6. package/dist/waku/public/assets/{algolia-B1uhfuD6.js → algolia-akct_lCZ.js} +1 -1
  7. package/dist/waku/public/assets/{chevron-right-DmP6Xa1g.js → chevron-right-DJ6X4mXo.js} +1 -1
  8. package/dist/waku/public/assets/{client-BSFjekJY.js → client-DU5zOesq.js} +1 -1
  9. package/dist/waku/public/assets/{collapsible-B2rvGry7.js → collapsible-Bqzit3JO.js} +1 -1
  10. package/dist/waku/public/assets/{core-C4jOG9I2.js → core-BfOvCGca.js} +1 -1
  11. package/dist/waku/public/assets/{i18n-V4QzeUbV.js → i18n-BU0Gqrrh.js} +1 -1
  12. package/dist/waku/public/assets/{index-xXa72sZS.js → index-C3-lsDRv.js} +1 -1
  13. package/dist/waku/public/assets/{index-NB9D4S1v.js → index-CCR9ecA8.js} +1 -1
  14. package/dist/waku/public/assets/{index-DW9Fo86a.js → index-CWwHJATE.js} +1 -1
  15. package/dist/waku/public/assets/{index-BQZmdbam.js → index-CY9LswMc.js} +1 -1
  16. package/dist/waku/public/assets/{index-CYJW3hzB.js → index-Cae1bXCh.js} +1 -1
  17. package/dist/waku/public/assets/{index-Bojr-xLv.js → index-CkzHlXhF.js} +1 -1
  18. package/dist/waku/public/assets/{index-B-5ouVG_.js → index-DOC-_zsC.js} +1 -1
  19. package/dist/waku/public/assets/{index-B65N5043.js → index-DOsFxkYv.js} +1 -1
  20. package/dist/waku/public/assets/{index-DHENdpwd.js → index-DhgWLnXf.js} +1 -1
  21. package/dist/waku/public/assets/index-E12FLc8f.js +1 -0
  22. package/dist/waku/public/assets/{index-OFfnl8sH.js → index-Po1UZSgL.js} +3 -3
  23. package/dist/waku/public/assets/{index-2HLUYgxN.js → index-T_b7wuyJ.js} +5 -5
  24. package/dist/waku/public/assets/{index-CBSxJfFU.js → index-yiM3u0f9.js} +1 -1
  25. package/dist/waku/public/assets/{index-Bonlu0LX.js → index-zSjxh5o9.js} +1 -1
  26. package/dist/waku/public/assets/{link-item-BlYkot48.js → link-item-CAVxr8-m.js} +1 -1
  27. package/dist/waku/public/assets/{merge-refs-BIez66Kl.js → merge-refs-B7SuKGTI.js} +1 -1
  28. package/dist/waku/public/assets/{orama-cloud-CazpSeQ0.js → orama-cloud-D6HIyrrx.js} +1 -1
  29. package/dist/waku/public/assets/{orama-cloud-legacy-CINWERV2.js → orama-cloud-legacy-AQ__GML5.js} +1 -1
  30. package/dist/waku/public/assets/{orama-static-DwfVMMmc.js → orama-static-CyMYfAPj.js} +1 -1
  31. package/dist/waku/public/assets/{page-actions--VStSULV.js → page-actions-CcyvVvdr.js} +1 -1
  32. package/dist/waku/public/assets/{proxy-CWSxKwWP.js → proxy-DdABrE5r.js} +1 -1
  33. package/dist/waku/public/assets/{search-D1WUBd3N.js → search-AdRfsIll.js} +1 -1
  34. package/dist/waku/public/assets/{search-default-B2jTK1EC.js → search-default-B4NAC8AJ.js} +3 -3
  35. package/dist/waku/public/assets/{use-copy-button-BO3GBlwZ.js → use-copy-button-auHqSfgW.js} +1 -1
  36. package/dist/waku/public/assets/{x-CB1cQ-bo.js → x-Blg1xIpd.js} +1 -1
  37. package/dist/waku/server/__vite_rsc_assets_manifest.js +151 -151
  38. package/dist/waku/server/assets/{_...slugs_-8lFegkVB.js → _...slugs_-DF1SYPMg.js} +32 -30
  39. package/dist/waku/server/assets/_root-BWpoCRFY.css +1 -0
  40. package/dist/waku/server/assets/{_root-B7AMftRI.js → _root-BiaZL9xf.js} +1 -1
  41. package/dist/waku/server/assets/{ai-C1Bf8DXZ.js → ai-vEEzbqB8.js} +2 -2
  42. package/dist/waku/server/assets/{chat-CN1qUeN-.js → chat-DOZ_Cx8A.js} +202 -12
  43. package/dist/waku/server/assets/{image.webp-PNGidV2r.js → image.webp-BW_97iH9.js} +1 -1
  44. package/dist/waku/server/assets/{img-C2Ne7ke5.js → img-B-t2xy2h.js} +1 -1
  45. package/dist/waku/server/assets/{index-CtEJq0xW.js → index--w0er2WH.js} +5 -5
  46. package/dist/waku/server/assets/{index-AIo6cWfN.js → index-BK2ZBQW1.js} +132 -54
  47. package/dist/waku/server/assets/{index-dpJ5KyUl.js → index-BXqq5kje.js} +1 -1
  48. package/dist/waku/server/assets/{index-D6orYQqE.js → index-CoHTzFHF.js} +1 -1
  49. package/dist/waku/server/assets/{index-QgPg52ej.js → index-D32Kgl7D.js} +1 -1
  50. package/dist/waku/server/assets/{index-BtnFj3IN.js → index-DShTeblm.js} +1 -1
  51. package/dist/waku/server/assets/{index-DFPuXyRR.js → index-DWNJLNyX.js} +1 -1
  52. package/dist/waku/server/assets/{index-6LQQnOj9.js → index-eAdvdAYz.js} +1 -1
  53. package/dist/waku/server/assets/{search-BuYfcIgW.js → search-BHsWHDmx.js} +2 -2
  54. package/dist/waku/server/assets/{server-entry-inner-DrYrCg3c.js → server-entry-inner-CYeTE9pH.js} +230 -189
  55. package/dist/waku/server/assets/{token-BJQ71htz.js → token-Dc4bIZyb.js} +3 -3
  56. package/dist/waku/server/assets/{token-util-BdUbceAe.js → token-util-BDWFgKKT.js} +16 -16
  57. package/dist/waku/server/assets/{token-util-WrcienE5.js → token-util-yHc1UlLV.js} +2 -2
  58. package/dist/waku/server/build.js +1 -1
  59. package/dist/waku/server/index.js +1 -1
  60. package/dist/waku/server/ssr/__vite_rsc_assets_manifest.js +151 -151
  61. package/dist/waku/server/ssr/assets/{Icon-BkWS2wcn.js → Icon-CjkqongL.js} +2 -2
  62. package/dist/waku/server/ssr/assets/{core-CLB7CUo5.js → core-Ru16gShL.js} +3 -3
  63. package/dist/waku/server/ssr/assets/{index-CKMvBRnq.js → index-BFvm1zbH.js} +4 -4
  64. package/dist/waku/server/ssr/assets/{index-BggSP1CG.js → index-CTD5LS21.js} +3 -3
  65. package/dist/waku/server/ssr/assets/{index-F8Xj3Sj4.js → index-DR2zqaC5.js} +1 -1
  66. package/dist/waku/server/ssr/index.js +12 -13
  67. package/package.json +15 -15
  68. package/dist/waku/public/assets/Icon-C79MpmBL.js +0 -1
  69. package/dist/waku/public/assets/_root-CzUOgPm2.css +0 -1
  70. package/dist/waku/public/assets/index-B7lX48CB.js +0 -1
  71. package/dist/waku/server/assets/_root-CzUOgPm2.css +0 -1
@@ -1,4 +1,4 @@
1
- import { o as object, q as number, k as any, m as array, v as string, i as safeParseAsync, t as toJSONSchema, _ as _enum, p as literal, w as union, u as unknown, l as record } from "./server-entry-inner-DrYrCg3c.js";
1
+ import { o as object, q as number, k as any, m as array, v as string, i as safeParseAsync, t as toJSONSchema, _ as _enum, p as literal, w as union, u as unknown, l as record } from "./server-entry-inner-CYeTE9pH.js";
2
2
  import { Z as ZodFirstPartyTypeKind } from "./types-6YcaudHU.js";
3
3
  import "node:async_hooks";
4
4
  import "node:path";
@@ -2328,6 +2328,29 @@ function mapOpenRouterFinishReason(finishReason) {
2328
2328
  function createFinishReason(unified, raw) {
2329
2329
  return { unified, raw };
2330
2330
  }
2331
+ function withStreamErrorHandling(source, onError) {
2332
+ const reader = source.getReader();
2333
+ return new ReadableStream({
2334
+ async pull(controller) {
2335
+ try {
2336
+ const { done, value } = await reader.read();
2337
+ if (done) {
2338
+ controller.close();
2339
+ } else {
2340
+ controller.enqueue(value);
2341
+ }
2342
+ } catch (err) {
2343
+ onError(err);
2344
+ reader.cancel().catch(() => {
2345
+ });
2346
+ controller.close();
2347
+ }
2348
+ },
2349
+ cancel(reason) {
2350
+ reader.cancel(reason);
2351
+ }
2352
+ });
2353
+ }
2331
2354
  var _seenKeys;
2332
2355
  var ReasoningDetailsDuplicateTracker = class {
2333
2356
  constructor() {
@@ -2551,7 +2574,7 @@ function convertToOpenRouterChatMessages(prompt) {
2551
2574
  }
2552
2575
  const contentParts = content.map(
2553
2576
  (part, index) => {
2554
- var _a17, _b17, _c2, _d2, _e2, _f2;
2577
+ var _a17, _b17, _c2, _d2, _e2, _f2, _g2;
2555
2578
  const isLastTextPart = part.type === "text" && index === lastTextPartIndex;
2556
2579
  const partCacheControl = getCacheControl(part.providerOptions);
2557
2580
  const cacheControl = part.type === "text" ? partCacheControl != null ? partCacheControl : isLastTextPart ? messageCacheControl : void 0 : partCacheControl;
@@ -2574,14 +2597,26 @@ function convertToOpenRouterChatMessages(prompt) {
2574
2597
  }
2575
2598
  }, cacheControl && { cache_control: cacheControl });
2576
2599
  }
2577
- if ((_b17 = part.mediaType) == null ? void 0 : _b17.startsWith("audio/")) {
2600
+ if ((_b17 = part.mediaType) == null ? void 0 : _b17.startsWith("video/")) {
2601
+ const url = getFileUrl({
2602
+ part,
2603
+ defaultMediaType: "video/mp4"
2604
+ });
2605
+ return __spreadValues({
2606
+ type: "video_url",
2607
+ video_url: {
2608
+ url
2609
+ }
2610
+ }, cacheControl && { cache_control: cacheControl });
2611
+ }
2612
+ if ((_c2 = part.mediaType) == null ? void 0 : _c2.startsWith("audio/")) {
2578
2613
  return __spreadValues({
2579
2614
  type: "input_audio",
2580
2615
  input_audio: getInputAudioData(part)
2581
2616
  }, cacheControl && { cache_control: cacheControl });
2582
2617
  }
2583
2618
  const fileName = String(
2584
- (_f2 = (_e2 = (_d2 = (_c2 = part.providerOptions) == null ? void 0 : _c2.openrouter) == null ? void 0 : _d2.filename) != null ? _e2 : part.filename) != null ? _f2 : ""
2619
+ (_g2 = (_f2 = (_e2 = (_d2 = part.providerOptions) == null ? void 0 : _d2.openrouter) == null ? void 0 : _e2.filename) != null ? _f2 : part.filename) != null ? _g2 : ""
2585
2620
  );
2586
2621
  const fileData = getFileUrl({
2587
2622
  part,
@@ -2667,9 +2702,12 @@ function convertToOpenRouterChatMessages(prompt) {
2667
2702
  return !!detail.signature;
2668
2703
  });
2669
2704
  if (validDetails.length < candidateReasoningDetails.length) {
2670
- console.warn(
2671
- "[openrouter] Some reasoning_details entries were removed because they were missing signatures. See https://github.com/OpenRouterTeam/ai-sdk-provider/issues/423 for more details."
2672
- );
2705
+ const logger = globalThis.AI_SDK_LOG_WARNINGS;
2706
+ if (logger !== false && typeof logger !== "function") {
2707
+ console.warn(
2708
+ "[openrouter] Some reasoning_details entries were removed because they were missing signatures. See https://github.com/OpenRouterTeam/ai-sdk-provider/issues/423 for more details."
2709
+ );
2710
+ }
2673
2711
  }
2674
2712
  const uniqueDetails = [];
2675
2713
  for (const detail of validDetails) {
@@ -2701,6 +2739,7 @@ function convertToOpenRouterChatMessages(prompt) {
2701
2739
  role: "tool",
2702
2740
  tool_call_id: toolResponse.toolCallId,
2703
2741
  content: content2,
2742
+ name: toolResponse.toolName,
2704
2743
  cache_control: (_h = getCacheControl(providerOptions)) != null ? _h : getCacheControl(toolResponse.providerOptions)
2705
2744
  });
2706
2745
  }
@@ -2727,7 +2766,7 @@ function getToolResultContent(input) {
2727
2766
  }
2728
2767
  function mapToolResultContentParts(parts) {
2729
2768
  return parts.map((part) => {
2730
- var _a16, _b16, _c;
2769
+ var _a16, _b16, _c, _d;
2731
2770
  switch (part.type) {
2732
2771
  case "text":
2733
2772
  return { type: "text", text: part.text };
@@ -2759,7 +2798,13 @@ function mapToolResultContentParts(parts) {
2759
2798
  image_url: { url: dataUrl }
2760
2799
  };
2761
2800
  }
2762
- if ((_b16 = part.mediaType) == null ? void 0 : _b16.startsWith("audio/")) {
2801
+ if ((_b16 = part.mediaType) == null ? void 0 : _b16.startsWith("video/")) {
2802
+ return {
2803
+ type: "video_url",
2804
+ video_url: { url: dataUrl }
2805
+ };
2806
+ }
2807
+ if ((_c = part.mediaType) == null ? void 0 : _c.startsWith("audio/")) {
2763
2808
  const rawFormat = part.mediaType.replace("audio/", "");
2764
2809
  const format = MIME_TO_FORMAT[rawFormat];
2765
2810
  if (format !== void 0) {
@@ -2775,7 +2820,7 @@ function mapToolResultContentParts(parts) {
2775
2820
  return {
2776
2821
  type: "file",
2777
2822
  file: {
2778
- filename: (_c = part.filename) != null ? _c : "",
2823
+ filename: (_d = part.filename) != null ? _d : "",
2779
2824
  file_data: dataUrl
2780
2825
  }
2781
2826
  };
@@ -3259,20 +3304,6 @@ var OpenRouterChatLanguageModel = class {
3259
3304
  }
3260
3305
  break;
3261
3306
  }
3262
- case "reasoning.encrypted": {
3263
- if (detail.data) {
3264
- return {
3265
- type: "reasoning",
3266
- text: "[REDACTED]",
3267
- providerMetadata: {
3268
- openrouter: {
3269
- reasoning_details: [detail]
3270
- }
3271
- }
3272
- };
3273
- }
3274
- break;
3275
- }
3276
3307
  }
3277
3308
  return null;
3278
3309
  }).filter((p) => p !== null) : choice.message.reasoning ? [
@@ -3343,7 +3374,8 @@ var OpenRouterChatLanguageModel = class {
3343
3374
  (d) => d.type === "reasoning.encrypted" && d.data
3344
3375
  );
3345
3376
  const shouldOverrideFinishReason = hasToolCalls && hasEncryptedReasoning && choice.finish_reason === "stop";
3346
- const effectiveFinishReason = shouldOverrideFinishReason ? createFinishReason("tool-calls", (_j = choice.finish_reason) != null ? _j : void 0) : mapOpenRouterFinishReason(choice.finish_reason);
3377
+ const mappedFinishReason = shouldOverrideFinishReason ? createFinishReason("tool-calls", (_j = choice.finish_reason) != null ? _j : void 0) : mapOpenRouterFinishReason(choice.finish_reason);
3378
+ const effectiveFinishReason = hasToolCalls && mappedFinishReason.unified === "other" ? createFinishReason("tool-calls", mappedFinishReason.raw) : mappedFinishReason;
3347
3379
  return {
3348
3380
  content,
3349
3381
  finishReason: effectiveFinishReason,
@@ -3377,7 +3409,8 @@ var OpenRouterChatLanguageModel = class {
3377
3409
  response: {
3378
3410
  id: response.id,
3379
3411
  modelId: response.model,
3380
- headers: responseHeaders
3412
+ headers: responseHeaders,
3413
+ body: response
3381
3414
  }
3382
3415
  };
3383
3416
  }
@@ -3407,6 +3440,10 @@ var OpenRouterChatLanguageModel = class {
3407
3440
  abortSignal: options.abortSignal,
3408
3441
  fetch: this.config.fetch
3409
3442
  });
3443
+ let streamError;
3444
+ const safeResponse = withStreamErrorHandling(response, (err) => {
3445
+ streamError = err;
3446
+ });
3410
3447
  const toolCalls = [];
3411
3448
  let finishReason = createFinishReason("other");
3412
3449
  const usage = {
@@ -3435,7 +3472,7 @@ var OpenRouterChatLanguageModel = class {
3435
3472
  let openrouterResponseId;
3436
3473
  let provider;
3437
3474
  return {
3438
- stream: response.pipeThrough(
3475
+ stream: safeResponse.pipeThrough(
3439
3476
  new TransformStream({
3440
3477
  transform(chunk, controller) {
3441
3478
  var _a17, _b17, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u;
@@ -3509,7 +3546,7 @@ var OpenRouterChatLanguageModel = class {
3509
3546
  const delta = choice.delta;
3510
3547
  const emitReasoningChunk = (chunkText, providerMetadata) => {
3511
3548
  if (!reasoningStarted) {
3512
- reasoningId = openrouterResponseId || generateId();
3549
+ reasoningId = generateId();
3513
3550
  controller.enqueue({
3514
3551
  providerMetadata,
3515
3552
  type: "reasoning-start",
@@ -3539,32 +3576,31 @@ var OpenRouterChatLanguageModel = class {
3539
3576
  accumulatedReasoningDetails.push(detail);
3540
3577
  }
3541
3578
  }
3542
- const reasoningMetadata = {
3543
- openrouter: {
3544
- reasoning_details: accumulatedReasoningDetails.map((d) => __spreadValues({}, d))
3545
- }
3546
- };
3547
- for (const detail of delta.reasoning_details) {
3548
- switch (detail.type) {
3549
- case "reasoning.text": {
3550
- emitReasoningChunk(detail.text || "", reasoningMetadata);
3551
- break;
3579
+ if (!textStarted) {
3580
+ const reasoningMetadata = {
3581
+ openrouter: {
3582
+ reasoning_details: accumulatedReasoningDetails.map((d) => __spreadValues({}, d))
3552
3583
  }
3553
- case "reasoning.encrypted": {
3554
- if (detail.data) {
3555
- emitReasoningChunk("[REDACTED]", reasoningMetadata);
3584
+ };
3585
+ for (const detail of delta.reasoning_details) {
3586
+ switch (detail.type) {
3587
+ case "reasoning.text": {
3588
+ emitReasoningChunk(detail.text || "", reasoningMetadata);
3589
+ break;
3556
3590
  }
3557
- break;
3558
- }
3559
- case "reasoning.summary": {
3560
- if (detail.summary) {
3561
- emitReasoningChunk(detail.summary, reasoningMetadata);
3591
+ case "reasoning.encrypted": {
3592
+ break;
3593
+ }
3594
+ case "reasoning.summary": {
3595
+ if (detail.summary) {
3596
+ emitReasoningChunk(detail.summary, reasoningMetadata);
3597
+ }
3598
+ break;
3562
3599
  }
3563
- break;
3564
3600
  }
3565
3601
  }
3566
3602
  }
3567
- } else if (delta.reasoning) {
3603
+ } else if (delta.reasoning && !textStarted) {
3568
3604
  emitReasoningChunk(delta.reasoning);
3569
3605
  }
3570
3606
  if (delta.content) {
@@ -3714,6 +3750,13 @@ var OpenRouterChatLanguageModel = class {
3714
3750
  id: toolCall.id,
3715
3751
  toolName: toolCall.function.name
3716
3752
  });
3753
+ if (toolCall.function.arguments) {
3754
+ controller.enqueue({
3755
+ type: "tool-input-delta",
3756
+ id: toolCall.id,
3757
+ delta: toolCall.function.arguments
3758
+ });
3759
+ }
3717
3760
  }
3718
3761
  if (((_o = toolCallDelta.function) == null ? void 0 : _o.arguments) != null) {
3719
3762
  toolCall.function.arguments += (_q = (_p = toolCallDelta.function) == null ? void 0 : _p.arguments) != null ? _q : "";
@@ -3724,6 +3767,10 @@ var OpenRouterChatLanguageModel = class {
3724
3767
  delta: (_r = toolCallDelta.function.arguments) != null ? _r : ""
3725
3768
  });
3726
3769
  if (((_s = toolCall.function) == null ? void 0 : _s.name) != null && ((_t = toolCall.function) == null ? void 0 : _t.arguments) != null && isParsableJson(toolCall.function.arguments)) {
3770
+ controller.enqueue({
3771
+ type: "tool-input-end",
3772
+ id: toolCall.id
3773
+ });
3727
3774
  controller.enqueue({
3728
3775
  type: "tool-call",
3729
3776
  toolCallId: (_u = toolCall.id) != null ? _u : generateId(),
@@ -3753,21 +3800,44 @@ var OpenRouterChatLanguageModel = class {
3753
3800
  flush(controller) {
3754
3801
  var _a17;
3755
3802
  const hasToolCalls = toolCalls.length > 0;
3803
+ if (streamError != null) {
3804
+ finishReason = createFinishReason("error");
3805
+ controller.enqueue({ type: "error", error: streamError });
3806
+ }
3756
3807
  const hasEncryptedReasoning = accumulatedReasoningDetails.some(
3757
3808
  (d) => d.type === "reasoning.encrypted" && d.data
3758
3809
  );
3759
3810
  if (hasToolCalls && hasEncryptedReasoning && finishReason.unified === "stop") {
3760
3811
  finishReason = createFinishReason("tool-calls", finishReason.raw);
3761
3812
  }
3813
+ if (hasToolCalls && finishReason.unified === "other") {
3814
+ finishReason = createFinishReason("tool-calls", finishReason.raw);
3815
+ }
3762
3816
  if (finishReason.unified === "tool-calls") {
3763
3817
  for (const toolCall of toolCalls) {
3764
3818
  if (toolCall && !toolCall.sent) {
3819
+ const input = isParsableJson(toolCall.function.arguments) ? toolCall.function.arguments : "{}";
3820
+ if (!toolCall.inputStarted) {
3821
+ controller.enqueue({
3822
+ type: "tool-input-start",
3823
+ id: toolCall.id,
3824
+ toolName: toolCall.function.name
3825
+ });
3826
+ controller.enqueue({
3827
+ type: "tool-input-delta",
3828
+ id: toolCall.id,
3829
+ delta: input
3830
+ });
3831
+ }
3832
+ controller.enqueue({
3833
+ type: "tool-input-end",
3834
+ id: toolCall.id
3835
+ });
3765
3836
  controller.enqueue({
3766
3837
  type: "tool-call",
3767
3838
  toolCallId: (_a17 = toolCall.id) != null ? _a17 : generateId(),
3768
3839
  toolName: toolCall.function.name,
3769
- // Coerce invalid arguments to an empty JSON object
3770
- input: isParsableJson(toolCall.function.arguments) ? toolCall.function.arguments : "{}",
3840
+ input,
3771
3841
  providerMetadata: !reasoningDetailsAttachedToToolCall ? {
3772
3842
  openrouter: {
3773
3843
  reasoning_details: accumulatedReasoningDetails
@@ -4134,6 +4204,10 @@ var OpenRouterCompletionLanguageModel = class {
4134
4204
  abortSignal: options.abortSignal,
4135
4205
  fetch: this.config.fetch
4136
4206
  });
4207
+ let streamError;
4208
+ const safeResponse = withStreamErrorHandling(response, (err) => {
4209
+ streamError = err;
4210
+ });
4137
4211
  let finishReason = createFinishReason("other");
4138
4212
  const usage = {
4139
4213
  inputTokens: {
@@ -4153,7 +4227,7 @@ var OpenRouterCompletionLanguageModel = class {
4153
4227
  let provider;
4154
4228
  let rawUsage;
4155
4229
  return {
4156
- stream: response.pipeThrough(
4230
+ stream: safeResponse.pipeThrough(
4157
4231
  new TransformStream({
4158
4232
  transform(chunk, controller) {
4159
4233
  var _a16, _b16, _c, _d, _e;
@@ -4217,6 +4291,10 @@ var OpenRouterCompletionLanguageModel = class {
4217
4291
  }
4218
4292
  },
4219
4293
  flush(controller) {
4294
+ if (streamError != null) {
4295
+ finishReason = createFinishReason("error");
4296
+ controller.enqueue({ type: "error", error: streamError });
4297
+ }
4220
4298
  usage.raw = rawUsage;
4221
4299
  const openrouterMetadata = {
4222
4300
  usage: openrouterUsage
@@ -4504,19 +4582,19 @@ function withUserAgentSuffix2(headers, ...userAgentSuffixParts) {
4504
4582
  "user-agent": userAgent
4505
4583
  });
4506
4584
  }
4507
- var VERSION2 = "2.3.3";
4585
+ var VERSION2 = "2.5.0";
4508
4586
  function createOpenRouter(options = {}) {
4509
4587
  var _a16, _b16, _c;
4510
4588
  const baseURL = (_b16 = withoutTrailingSlash((_a16 = options.baseURL) != null ? _a16 : options.baseUrl)) != null ? _b16 : "https://openrouter.ai/api/v1";
4511
4589
  const compatibility = (_c = options.compatibility) != null ? _c : "compatible";
4512
4590
  const getHeaders = () => withUserAgentSuffix2(
4513
- __spreadValues(__spreadValues({
4591
+ __spreadValues(__spreadValues(__spreadValues(__spreadValues({
4514
4592
  Authorization: `Bearer ${loadApiKey({
4515
4593
  apiKey: options.apiKey,
4516
4594
  environmentVariableName: "OPENROUTER_API_KEY",
4517
4595
  description: "OpenRouter"
4518
4596
  })}`
4519
- }, options.headers), options.api_keys && Object.keys(options.api_keys).length > 0 && {
4597
+ }, options.appName && { "X-OpenRouter-Title": options.appName }), options.appUrl && { "HTTP-Referer": options.appUrl }), options.headers), options.api_keys && Object.keys(options.api_keys).length > 0 && {
4520
4598
  "X-Provider-API-Keys": JSON.stringify(options.api_keys)
4521
4599
  }),
4522
4600
  `ai-sdk/openrouter/${VERSION2}`
@@ -1,4 +1,4 @@
1
- import { r as registerClientReference } from "./server-entry-inner-DrYrCg3c.js";
1
+ import { r as registerClientReference } from "./server-entry-inner-CYeTE9pH.js";
2
2
  import "node:async_hooks";
3
3
  import "node:path";
4
4
  import "http";
@@ -1,4 +1,4 @@
1
- import { r as registerClientReference } from "./server-entry-inner-DrYrCg3c.js";
1
+ import { r as registerClientReference } from "./server-entry-inner-CYeTE9pH.js";
2
2
  import "node:async_hooks";
3
3
  import "node:path";
4
4
  import "http";
@@ -1,4 +1,4 @@
1
- import { r as registerClientReference } from "./server-entry-inner-DrYrCg3c.js";
1
+ import { r as registerClientReference } from "./server-entry-inner-CYeTE9pH.js";
2
2
  import "node:async_hooks";
3
3
  import "node:path";
4
4
  import "http";
@@ -1,4 +1,4 @@
1
- import { O as commonjsGlobal, P as commonjsRequire, f as getDefaultExportFromCjs } from "./server-entry-inner-DrYrCg3c.js";
1
+ import { O as commonjsGlobal, P as commonjsRequire, f as getDefaultExportFromCjs } from "./server-entry-inner-CYeTE9pH.js";
2
2
  import "node:async_hooks";
3
3
  import "node:path";
4
4
  import "http";
@@ -1,4 +1,4 @@
1
- import { a as jsxRuntime_reactServerExports, r as registerClientReference, N as react_reactServerExports } from "./server-entry-inner-DrYrCg3c.js";
1
+ import { a as jsxRuntime_reactServerExports, r as registerClientReference, N as react_reactServerExports } from "./server-entry-inner-CYeTE9pH.js";
2
2
  import "node:async_hooks";
3
3
  import "node:path";
4
4
  import "http";
@@ -1,4 +1,4 @@
1
- import { f as getDefaultExportFromCjs } from "./server-entry-inner-DrYrCg3c.js";
1
+ import { f as getDefaultExportFromCjs } from "./server-entry-inner-CYeTE9pH.js";
2
2
  import minproc from "node:process";
3
3
  import path$1 from "node:path";
4
4
  import { fileURLToPath } from "node:url";
@@ -1,5 +1,5 @@
1
- import { E as basename, F as extname, G as findPath, g as getConfigRuntime, e as getSource, D as revalidable } from "./server-entry-inner-DrYrCg3c.js";
2
- import { i as ccount, j as toMarkdown, r as remark, e as remarkGfm, g as remarkHeading, v as visit, k as toMdxExport } from "./index-6LQQnOj9.js";
1
+ import { E as basename, F as extname, G as findPath, g as getConfigRuntime, e as getSource, D as revalidable } from "./server-entry-inner-CYeTE9pH.js";
2
+ import { i as ccount, j as toMarkdown, r as remark, e as remarkGfm, g as remarkHeading, v as visit, k as toMdxExport } from "./index-eAdvdAYz.js";
3
3
  import { S as Search } from "./flexsearch.bundle.module.min-CgP_HR0V.js";
4
4
  import { s as stringifyEntitiesLight } from "./index-DxT83GRu.js";
5
5
  import "node:async_hooks";