190proof 1.0.114 → 1.0.115

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/README.md CHANGED
@@ -280,6 +280,7 @@ Optional per-request knobs live on `payload` (`GenericPayload`):
280
280
  - `payload.streamTimeoutMs`: `number` - OpenRouter-only: total wall-clock budget per streaming attempt (default: 600000).
281
281
  - `payload.streamDeadlineAt`: `number` - OpenRouter-only: absolute deadline (epoch ms) for the whole call **including retries** — the caller's turn budget. Each attempt gets `min(streamTimeoutMs, deadline - now)`, and once under 10s remain the call fails fast instead of starting a generation that cannot be delivered. Use it whenever the caller has its own timeout: a per-attempt budget alone is re-granted on every retry and can outlive that timeout.
282
282
  - `payload.thinkingConfig`: `Record<string, unknown>` - Google-only: forwarded verbatim as `generationConfig.thinkingConfig` on the Gemini request — e.g. `{ thinkingBudget: 0 }` to disable thinking, `{ thinkingLevel: "HIGH" }` on models that take a level. Ignored by all other adapters; shapes are model-specific and validated by Google, not the SDK.
283
+ - `payload.reasoningEffort`: `string` - OpenAI-only: forwarded as `reasoning_effort` on the request. Valid values are model-dependent (`none`/`minimal`/`low`/`medium`/`high`/`xhigh`/`max`). Reasoning-by-default models (the gpt-5.6 family) reject function tools on `/chat/completions` with a 400 unless this is explicitly `"none"` — their implicit default is `medium`. Ignored by all other adapters.
283
284
 
284
285
  When a streaming attempt is cut at its **total deadline** and prose has already arrived, the partial answer is returned with `truncated: true` on the response rather than discarded — those tokens were generated and billed, so throwing them away costs money and gives the user nothing. Surface such a reply as incomplete. Salvage never applies to tool-call turns (half-streamed arguments are unparseable JSON), to stalls (the provider died mid-thought), or to caller aborts. When nothing is salvageable, the discard is logged with an approximate token count — aborted attempts never receive OpenRouter's `usage` chunk, so that log line is the only record of the wasted spend.
285
286
 
package/dist/index.d.mts CHANGED
@@ -295,6 +295,14 @@ interface GenericPayload {
295
295
  * adapters. Forwarded as the request body's `provider` field.
296
296
  */
297
297
  provider?: OpenRouterProviderPreferences;
298
+ /**
299
+ * OpenAI-only: forwarded as `reasoning_effort` on the request. Valid values
300
+ * are model-dependent (`none`/`minimal`/`low`/`medium`/`high`/`xhigh`/`max`).
301
+ * Reasoning-by-default models (gpt-5.6 family) 400 on /chat/completions when
302
+ * function tools are present unless this is explicitly `"none"` — their
303
+ * implicit default is `medium`. Ignored by all other adapters.
304
+ */
305
+ reasoningEffort?: string;
298
306
  /**
299
307
  * Per-request HTTP timeout in ms for the underlying provider call (applied
300
308
  * per attempt, not across retries). Honored by all adapters (Anthropic,
package/dist/index.d.ts CHANGED
@@ -295,6 +295,14 @@ interface GenericPayload {
295
295
  * adapters. Forwarded as the request body's `provider` field.
296
296
  */
297
297
  provider?: OpenRouterProviderPreferences;
298
+ /**
299
+ * OpenAI-only: forwarded as `reasoning_effort` on the request. Valid values
300
+ * are model-dependent (`none`/`minimal`/`low`/`medium`/`high`/`xhigh`/`max`).
301
+ * Reasoning-by-default models (gpt-5.6 family) 400 on /chat/completions when
302
+ * function tools are present unless this is explicitly `"none"` — their
303
+ * implicit default is `medium`. Ignored by all other adapters.
304
+ */
305
+ reasoningEffort?: string;
298
306
  /**
299
307
  * Per-request HTTP timeout in ms for the underlying provider call (applied
300
308
  * per attempt, not across retries). Honored by all adapters (Anthropic,
package/dist/index.js CHANGED
@@ -28,8 +28,8 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
28
28
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
29
 
30
30
  // index.ts
31
- var index_exports = {};
32
- __export(index_exports, {
31
+ var proof_exports = {};
32
+ __export(proof_exports, {
33
33
  ClaudeModel: () => ClaudeModel,
34
34
  GPTModel: () => GPTModel,
35
35
  GeminiModel: () => GeminiModel,
@@ -41,7 +41,7 @@ __export(index_exports, {
41
41
  callWithRetries: () => callWithRetries,
42
42
  parseModelString: () => parseModelString
43
43
  });
44
- module.exports = __toCommonJS(index_exports);
44
+ module.exports = __toCommonJS(proof_exports);
45
45
 
46
46
  // interfaces.ts
47
47
  var ClaudeModel = /* @__PURE__ */ ((ClaudeModel2) => {
@@ -172,7 +172,8 @@ async function withRetries(identifier, apiName, fn, options = {}) {
172
172
  return await fn();
173
173
  } catch (error3) {
174
174
  lastError = error3;
175
- if ((_a = options.signal) == null ? void 0 : _a.aborted) throw error3;
175
+ if ((_a = options.signal) == null ? void 0 : _a.aborted)
176
+ throw error3;
176
177
  if (onError) {
177
178
  onError(error3, attempt);
178
179
  } else {
@@ -196,7 +197,8 @@ function parseStreamedResponse(identifier, paragraph, toolCallAccumulators, allo
196
197
  const functionCalls = [];
197
198
  for (let i = 0; i < toolCallAccumulators.length; i++) {
198
199
  const acc = toolCallAccumulators[i];
199
- if (!acc.name || !acc.arguments) continue;
200
+ if (!acc.name || !acc.arguments)
201
+ continue;
200
202
  if (allowedFunctionNames && !allowedFunctionNames.has(acc.name)) {
201
203
  throw new Error(
202
204
  `Stream error: received function call with unknown name: ${acc.name}`
@@ -335,7 +337,8 @@ function buildOpenAIRequestConfig(identifier, model, config) {
335
337
  };
336
338
  }
337
339
  function filterOpenAICompatReasoningDetails(details) {
338
- if (!Array.isArray(details)) return details || void 0;
340
+ if (!Array.isArray(details))
341
+ return details || void 0;
339
342
  const blocks = details.filter(
340
343
  (block) => typeof (block == null ? void 0 : block.type) === "string" && block.type.startsWith("reasoning.")
341
344
  );
@@ -346,6 +349,7 @@ async function prepareOpenAIPayload(identifier, payload) {
346
349
  const preparedPayload = {
347
350
  model: payload.model,
348
351
  messages: [],
352
+ reasoning_effort: payload.reasoningEffort,
349
353
  tools: (_a = payload.functions) == null ? void 0 : _a.map((fn) => ({
350
354
  type: "function",
351
355
  function: fn
@@ -406,11 +410,13 @@ async function prepareOpenAIPayload(identifier, payload) {
406
410
  };
407
411
  });
408
412
  }
409
- if (message.reasoning) outMessage.reasoning = message.reasoning;
413
+ if (message.reasoning)
414
+ outMessage.reasoning = message.reasoning;
410
415
  const reasoningDetails = filterOpenAICompatReasoningDetails(
411
416
  message.reasoningDetails
412
417
  );
413
- if (reasoningDetails) outMessage.reasoning_details = reasoningDetails;
418
+ if (reasoningDetails)
419
+ outMessage.reasoning_details = reasoningDetails;
414
420
  preparedPayload.messages.push(outMessage);
415
421
  }
416
422
  return preparedPayload;
@@ -472,7 +478,8 @@ async function callOpenAIStream(id, openAiPayload, openAiConfig, chunkTimeoutMs,
472
478
  }
473
479
  const jsonStrings = chunk.split(/^data: /gm);
474
480
  for (const jsonString of jsonStrings) {
475
- if (!jsonString) continue;
481
+ if (!jsonString)
482
+ continue;
476
483
  if (jsonString.includes("[DONE]")) {
477
484
  clearTimeout(overallTimeout);
478
485
  return parseStreamedResponse(
@@ -510,7 +517,8 @@ async function callOpenAIStream(id, openAiPayload, openAiConfig, chunkTimeoutMs,
510
517
  while (toolCallAccumulators.length <= idx) {
511
518
  toolCallAccumulators.push({ name: "", arguments: "" });
512
519
  }
513
- if (toolCall.id) toolCallAccumulators[idx].id = toolCall.id;
520
+ if (toolCall.id)
521
+ toolCallAccumulators[idx].id = toolCall.id;
514
522
  if ((_e = toolCall.function) == null ? void 0 : _e.name)
515
523
  toolCallAccumulators[idx].name += toolCall.function.name;
516
524
  if ((_f = toolCall.function) == null ? void 0 : _f.arguments)
@@ -518,9 +526,11 @@ async function callOpenAIStream(id, openAiPayload, openAiConfig, chunkTimeoutMs,
518
526
  }
519
527
  }
520
528
  const text = (_h = (_g = json.choices[0]) == null ? void 0 : _g.delta) == null ? void 0 : _h.content;
521
- if (text) paragraph += text;
529
+ if (text)
530
+ paragraph += text;
522
531
  const reasoningDelta = (_j = (_i = json.choices[0]) == null ? void 0 : _i.delta) == null ? void 0 : _j.reasoning;
523
- if (reasoningDelta) reasoning += reasoningDelta;
532
+ if (reasoningDelta)
533
+ reasoning += reasoningDelta;
524
534
  }
525
535
  }
526
536
  }
@@ -665,7 +675,8 @@ function jigAnthropicMessages(messages) {
665
675
  ];
666
676
  }
667
677
  jiggedMessages = jiggedMessages.reduce((acc, message) => {
668
- if (acc.length === 0) return [message];
678
+ if (acc.length === 0)
679
+ return [message];
669
680
  const lastMessage = acc[acc.length - 1];
670
681
  if (lastMessage.role === message.role) {
671
682
  const lastContent = Array.isArray(lastMessage.content) ? lastMessage.content : [{ type: "text", text: lastMessage.content }];
@@ -919,7 +930,8 @@ function jigGoogleMessages(messages) {
919
930
  ];
920
931
  }
921
932
  jiggedMessages = jiggedMessages.reduce((acc, message) => {
922
- if (acc.length === 0) return [message];
933
+ if (acc.length === 0)
934
+ return [message];
923
935
  const lastMessage = acc[acc.length - 1];
924
936
  if (lastMessage.role === message.role) {
925
937
  lastMessage.parts = [...lastMessage.parts, ...message.parts];
@@ -958,7 +970,8 @@ async function prepareGoogleAIPayload(_identifier, payload) {
958
970
  const toolNameById = /* @__PURE__ */ new Map();
959
971
  for (const m of payload.messages) {
960
972
  for (const fc of m.functionCalls || []) {
961
- if (fc.id) toolNameById.set(fc.id, fc.name);
973
+ if (fc.id)
974
+ toolNameById.set(fc.id, fc.name);
962
975
  }
963
976
  }
964
977
  for (const message of payload.messages) {
@@ -1038,7 +1051,8 @@ async function callGoogleAI(id, payload, requestTimeoutMs = 12e4, signal) {
1038
1051
  ...payload.thinkingConfig ? { thinkingConfig: payload.thinkingConfig } : {}
1039
1052
  }
1040
1053
  };
1041
- if (payload.tools) requestBody.tools = [payload.tools];
1054
+ if (payload.tools)
1055
+ requestBody.tools = [payload.tools];
1042
1056
  if (payload.tools && payload.toolConfig) {
1043
1057
  requestBody.toolConfig = payload.toolConfig;
1044
1058
  }
@@ -1096,7 +1110,8 @@ async function callGoogleAI(id, payload, requestTimeoutMs = 12e4, signal) {
1096
1110
  });
1097
1111
  continue;
1098
1112
  }
1099
- if (part.text) text += part.text;
1113
+ if (part.text)
1114
+ text += part.text;
1100
1115
  if ((_m = part.inlineData) == null ? void 0 : _m.data) {
1101
1116
  files.push({ mimeType: "image/png", data: part.inlineData.data });
1102
1117
  }
@@ -1174,15 +1189,21 @@ async function callGoogleAIWithRetries(id, payload, retries = 5, requestTimeoutM
1174
1189
  finishReason: error2.finishReason,
1175
1190
  modelVersion: error2.modelVersion
1176
1191
  };
1177
- if (error2.safetyRatings) errorDetails.safetyRatings = error2.safetyRatings;
1178
- if (error2.usageMetadata) errorDetails.usageMetadata = error2.usageMetadata;
1192
+ if (error2.safetyRatings)
1193
+ errorDetails.safetyRatings = error2.safetyRatings;
1194
+ if (error2.usageMetadata)
1195
+ errorDetails.usageMetadata = error2.usageMetadata;
1179
1196
  if (error2.promptFeedback)
1180
1197
  errorDetails.promptFeedback = error2.promptFeedback;
1181
- if (error2.status) errorDetails.httpStatus = error2.status;
1182
- if (error2.code) errorDetails.errorCode = error2.code;
1183
- if (error2.details) errorDetails.errorDetails = error2.details;
1198
+ if (error2.status)
1199
+ errorDetails.httpStatus = error2.status;
1200
+ if (error2.code)
1201
+ errorDetails.errorCode = error2.code;
1202
+ if (error2.details)
1203
+ errorDetails.errorDetails = error2.details;
1184
1204
  const fileUris = payload.messages.flatMap((m) => m.parts).filter((p) => "fileData" in p).map((p) => p.fileData.fileUri);
1185
- if (fileUris.length) errorDetails.fileUris = fileUris;
1205
+ if (fileUris.length)
1206
+ errorDetails.fileUris = fileUris;
1186
1207
  logger_default.error(
1187
1208
  id,
1188
1209
  `Retry #${attempt} error: ${error2.message}`,
@@ -1266,13 +1287,16 @@ function prepareOpenAICompatMessages(messages) {
1266
1287
  }
1267
1288
  };
1268
1289
  });
1269
- if (!content) outMessage.content = null;
1290
+ if (!content)
1291
+ outMessage.content = null;
1270
1292
  }
1271
- if (message.reasoning) outMessage.reasoning = message.reasoning;
1293
+ if (message.reasoning)
1294
+ outMessage.reasoning = message.reasoning;
1272
1295
  const reasoningDetails = filterOpenAICompatReasoningDetails(
1273
1296
  message.reasoningDetails
1274
1297
  );
1275
- if (reasoningDetails) outMessage.reasoning_details = reasoningDetails;
1298
+ if (reasoningDetails)
1299
+ outMessage.reasoning_details = reasoningDetails;
1276
1300
  out.push(outMessage);
1277
1301
  }
1278
1302
  return out;
@@ -1415,7 +1439,8 @@ function parseDsmlToolCalls(content) {
1415
1439
  let last = -1;
1416
1440
  let tag;
1417
1441
  while ((tag = DSML_ANY_TAG_RE.exec(content)) !== null) {
1418
- if (first === -1) first = tag.index;
1442
+ if (first === -1)
1443
+ first = tag.index;
1419
1444
  last = tag.index + tag[0].length;
1420
1445
  }
1421
1446
  const remaining = first === -1 ? content : (content.slice(0, first) + content.slice(last)).trim();
@@ -1431,7 +1456,8 @@ function finalizeOpenRouterMessage(id, raw) {
1431
1456
  const functionCalls = [];
1432
1457
  for (let i = 0; i < raw.toolCalls.length; i++) {
1433
1458
  const tc = raw.toolCalls[i];
1434
- if (!tc.name) continue;
1459
+ if (!tc.name)
1460
+ continue;
1435
1461
  functionCalls.push({
1436
1462
  id: (_a = tc.id) != null ? _a : `call_${i}`,
1437
1463
  name: tc.name,
@@ -1484,7 +1510,8 @@ async function callOpenRouterStream(id, payload, streamTimeoutMs = OPENROUTER_ST
1484
1510
  controller.abort();
1485
1511
  };
1486
1512
  const unref = (t) => {
1487
- if (typeof t === "object" && "unref" in t) t.unref();
1513
+ if (typeof t === "object" && "unref" in t)
1514
+ t.unref();
1488
1515
  return t;
1489
1516
  };
1490
1517
  const totalTimer = unref(
@@ -1552,88 +1579,98 @@ async function callOpenRouterStream(id, payload, streamTimeoutMs = OPENROUTER_ST
1552
1579
  const reader = response.body.getReader();
1553
1580
  const decoder = new TextDecoder();
1554
1581
  let lineBuffer = "";
1555
- outer: while (true) {
1556
- const { done, value } = await reader.read();
1557
- if (done) break;
1558
- lineBuffer += decoder.decode(value, { stream: true });
1559
- let newlineIdx;
1560
- while ((newlineIdx = lineBuffer.indexOf("\n")) !== -1) {
1561
- let line = lineBuffer.slice(0, newlineIdx);
1562
- lineBuffer = lineBuffer.slice(newlineIdx + 1);
1563
- if (line.endsWith("\r")) line = line.slice(0, -1);
1564
- if (!line) continue;
1565
- if (line.startsWith(":")) continue;
1566
- if (!line.startsWith("data:")) continue;
1567
- const dataStr = line.slice(5).trimStart();
1568
- if (dataStr === "[DONE]") {
1569
- sawDone = true;
1570
- break outer;
1571
- }
1572
- let json;
1573
- try {
1574
- json = JSON.parse(dataStr);
1575
- } catch (e) {
1576
- logger_default.error(
1577
- id,
1578
- "OpenRouter stream: unparseable data line:",
1579
- dataStr.slice(0, 200)
1580
- );
1581
- continue;
1582
- }
1583
- dataChunks++;
1584
- if (json.error) {
1585
- logger_default.error(id, "OpenRouter stream error event:", json.error);
1586
- const error2 = new Error(
1587
- `OpenRouter error: ${json.error.message}`
1588
- );
1589
- error2.data = json.error;
1590
- throw error2;
1591
- }
1592
- if (json.provider) provider = json.provider;
1593
- let useful = false;
1594
- if (json.usage) {
1595
- usage = json.usage;
1596
- useful = true;
1597
- }
1598
- const choice = (_c = json.choices) == null ? void 0 : _c[0];
1599
- if (choice) {
1600
- const delta = (_d = choice.delta) != null ? _d : {};
1601
- if (delta.content) {
1602
- paragraph += delta.content;
1603
- useful = true;
1582
+ outer:
1583
+ while (true) {
1584
+ const { done, value } = await reader.read();
1585
+ if (done)
1586
+ break;
1587
+ lineBuffer += decoder.decode(value, { stream: true });
1588
+ let newlineIdx;
1589
+ while ((newlineIdx = lineBuffer.indexOf("\n")) !== -1) {
1590
+ let line = lineBuffer.slice(0, newlineIdx);
1591
+ lineBuffer = lineBuffer.slice(newlineIdx + 1);
1592
+ if (line.endsWith("\r"))
1593
+ line = line.slice(0, -1);
1594
+ if (!line)
1595
+ continue;
1596
+ if (line.startsWith(":"))
1597
+ continue;
1598
+ if (!line.startsWith("data:"))
1599
+ continue;
1600
+ const dataStr = line.slice(5).trimStart();
1601
+ if (dataStr === "[DONE]") {
1602
+ sawDone = true;
1603
+ break outer;
1604
1604
  }
1605
- if (delta.reasoning) {
1606
- reasoning += delta.reasoning;
1607
- useful = true;
1605
+ let json;
1606
+ try {
1607
+ json = JSON.parse(dataStr);
1608
+ } catch (e) {
1609
+ logger_default.error(
1610
+ id,
1611
+ "OpenRouter stream: unparseable data line:",
1612
+ dataStr.slice(0, 200)
1613
+ );
1614
+ continue;
1608
1615
  }
1609
- if (Array.isArray(delta.reasoning_details) && delta.reasoning_details.length) {
1610
- reasoningDetails.push(...delta.reasoning_details);
1616
+ dataChunks++;
1617
+ if (json.error) {
1618
+ logger_default.error(id, "OpenRouter stream error event:", json.error);
1619
+ const error2 = new Error(
1620
+ `OpenRouter error: ${json.error.message}`
1621
+ );
1622
+ error2.data = json.error;
1623
+ throw error2;
1624
+ }
1625
+ if (json.provider)
1626
+ provider = json.provider;
1627
+ let useful = false;
1628
+ if (json.usage) {
1629
+ usage = json.usage;
1611
1630
  useful = true;
1612
1631
  }
1613
- if (Array.isArray(delta.tool_calls)) {
1614
- for (const toolCall of delta.tool_calls) {
1615
- const idx = (_e = toolCall.index) != null ? _e : 0;
1616
- while (toolCalls.length <= idx) {
1617
- toolCalls.push({ name: "", argumentsJson: "" });
1632
+ const choice = (_c = json.choices) == null ? void 0 : _c[0];
1633
+ if (choice) {
1634
+ const delta = (_d = choice.delta) != null ? _d : {};
1635
+ if (delta.content) {
1636
+ paragraph += delta.content;
1637
+ useful = true;
1638
+ }
1639
+ if (delta.reasoning) {
1640
+ reasoning += delta.reasoning;
1641
+ useful = true;
1642
+ }
1643
+ if (Array.isArray(delta.reasoning_details) && delta.reasoning_details.length) {
1644
+ reasoningDetails.push(...delta.reasoning_details);
1645
+ useful = true;
1646
+ }
1647
+ if (Array.isArray(delta.tool_calls)) {
1648
+ for (const toolCall of delta.tool_calls) {
1649
+ const idx = (_e = toolCall.index) != null ? _e : 0;
1650
+ while (toolCalls.length <= idx) {
1651
+ toolCalls.push({ name: "", argumentsJson: "" });
1652
+ }
1653
+ if (toolCall.id)
1654
+ toolCalls[idx].id = toolCall.id;
1655
+ if ((_f = toolCall.function) == null ? void 0 : _f.name)
1656
+ toolCalls[idx].name += toolCall.function.name;
1657
+ if ((_g = toolCall.function) == null ? void 0 : _g.arguments)
1658
+ toolCalls[idx].argumentsJson += toolCall.function.arguments;
1659
+ useful = true;
1618
1660
  }
1619
- if (toolCall.id) toolCalls[idx].id = toolCall.id;
1620
- if ((_f = toolCall.function) == null ? void 0 : _f.name)
1621
- toolCalls[idx].name += toolCall.function.name;
1622
- if ((_g = toolCall.function) == null ? void 0 : _g.arguments)
1623
- toolCalls[idx].argumentsJson += toolCall.function.arguments;
1661
+ }
1662
+ if (choice.finish_reason) {
1663
+ finishReason = choice.finish_reason;
1624
1664
  useful = true;
1625
1665
  }
1626
1666
  }
1627
- if (choice.finish_reason) {
1628
- finishReason = choice.finish_reason;
1629
- useful = true;
1630
- }
1667
+ if (useful)
1668
+ armStallTimer();
1631
1669
  }
1632
- if (useful) armStallTimer();
1633
1670
  }
1634
- }
1635
- if (sawDone) reader.cancel().catch(() => {
1636
- });
1671
+ if (sawDone)
1672
+ reader.cancel().catch(() => {
1673
+ });
1637
1674
  if (!sawDone && !finishReason) {
1638
1675
  logger_default.error(
1639
1676
  id,
@@ -1740,12 +1777,15 @@ var MODERATION_RE = /moderat|inappropriate content|content polic|content managem
1740
1777
  function moderationEvictionSlug(error2, payload) {
1741
1778
  var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
1742
1779
  const body = (_c = error2 == null ? void 0 : error2.data) != null ? _c : (_b = (_a = error2 == null ? void 0 : error2.response) == null ? void 0 : _a.data) == null ? void 0 : _b.error;
1743
- if (!body) return null;
1780
+ if (!body)
1781
+ return null;
1744
1782
  const message = String((_d = body.message) != null ? _d : "");
1745
1783
  const isModeration = body.code === 403 || Array.isArray((_e = body.metadata) == null ? void 0 : _e.reasons) || MODERATION_RE.test(message);
1746
- if (!isModeration) return null;
1784
+ if (!isModeration)
1785
+ return null;
1747
1786
  const display = (_h = (_f = body.metadata) == null ? void 0 : _f.provider_name) != null ? _h : (_g = /Upstream error from ([^:]+):/.exec(message)) == null ? void 0 : _g[1];
1748
- if (!display) return null;
1787
+ if (!display)
1788
+ return null;
1749
1789
  const key = normalizeProviderKey(display);
1750
1790
  const fromOrder = (_j = (_i = payload.provider) == null ? void 0 : _i.order) == null ? void 0 : _j.find(
1751
1791
  (entry) => normalizeProviderKey(entry) === key
@@ -1755,9 +1795,11 @@ function moderationEvictionSlug(error2, payload) {
1755
1795
  var MIN_STREAM_ATTEMPT_MS = 1e4;
1756
1796
  var estimateTokens = (text) => Math.round(text.length / 4);
1757
1797
  function streamAttemptBudgetMs(options) {
1758
- if (options.streamDeadlineAt === void 0) return options.streamTimeoutMs;
1798
+ if (options.streamDeadlineAt === void 0)
1799
+ return options.streamTimeoutMs;
1759
1800
  const remaining = options.streamDeadlineAt - Date.now();
1760
- if (remaining < MIN_STREAM_ATTEMPT_MS) return null;
1801
+ if (remaining < MIN_STREAM_ATTEMPT_MS)
1802
+ return null;
1761
1803
  return Math.min(options.streamTimeoutMs, remaining);
1762
1804
  }
1763
1805
  async function callOpenRouterWithRetries(id, payload, retries = 5, options, signal) {
@@ -1913,7 +1955,8 @@ async function callWithRetries(id, aiPayload, aiConfig, retries = 5, chunkTimeou
1913
1955
  (_e = result.provider) != null ? _e : result.provider = provider;
1914
1956
  return result;
1915
1957
  } catch (error2) {
1916
- if ((_f = aiPayload.signal) == null ? void 0 : _f.aborted) throw error2;
1958
+ if ((_f = aiPayload.signal) == null ? void 0 : _f.aborted)
1959
+ throw error2;
1917
1960
  if (aiPayload.fallbackModel) {
1918
1961
  logger_default.error(
1919
1962
  id,