@openclaw/ai 2026.9.3 → 2026.9.5

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 (101) hide show
  1. package/README.md +1 -1
  2. package/dist/{anthropic-CZy5U0NY.mjs → anthropic-COtDvgtt.mjs} +16 -16
  3. package/dist/{anthropic-payload-policy-wuRCb6MH.d.mts → anthropic-payload-policy-5Erq1Nzy.d.mts} +3 -3
  4. package/dist/{anthropic-stream-reducer-B_yo_7pf.mjs → anthropic-stream-reducer-BvdYYWL8.mjs} +56 -47
  5. package/dist/{api-registry-CB1-1oQ2.d.mts → api-registry-Ba2Cv-ut.d.mts} +2 -2
  6. package/dist/{assistant-output-iqnlJCV2.mjs → assistant-output-BsEkB-vU.mjs} +1 -1
  7. package/dist/{azure-openai-responses-Crpa40QR.mjs → azure-openai-responses-YrgnD583.mjs} +6 -9
  8. package/dist/{base64-D-su8YVo.mjs → base64-BQOzsvUH.mjs} +4 -4
  9. package/dist/credential-redaction-BKv49aiv.d.mts +24 -0
  10. package/dist/{diagnostics-dV98PqIy.mjs → diagnostics-Dm4bisWG.mjs} +89 -2
  11. package/dist/diagnostics.d.mts +4 -23
  12. package/dist/diagnostics.mjs +3 -3
  13. package/dist/{event-stream-C1Z2piyk.d.mts → event-stream-CCoa-qSI.d.mts} +1 -1
  14. package/dist/event-stream-DmSCpi1T.d.mts +1 -0
  15. package/dist/event-stream.d.mts +2 -2
  16. package/dist/expect-lbe3Hgrh.mjs +8 -0
  17. package/dist/{google-BDPriaVe.mjs → google-BuhpRO9r.mjs} +7 -10
  18. package/dist/{google-messages-CVn9eFpF.mjs → google-messages-CyWnYlh0.mjs} +3 -4
  19. package/dist/{google-shared-BedY23XS.mjs → google-shared-BT5ZeNer.mjs} +13 -13
  20. package/dist/{google-vertex-DMz8XQCn.mjs → google-vertex-C7EplRvt.mjs} +5 -8
  21. package/dist/{host-CWuF-sS3.mjs → host-B4MeUNBc.mjs} +145 -12
  22. package/dist/{host-DK3wmS3e.d.mts → host-FZ1RA_qD.d.mts} +7 -3
  23. package/dist/{host-policy-CAopLRKA.mjs → host-policy-DUnXSx0I.mjs} +1 -1
  24. package/dist/{index-CQ6LTHw8.d.mts → index-DaF2QbwS.d.mts} +5 -10
  25. package/dist/index.d.mts +7 -8
  26. package/dist/index.mjs +5 -5
  27. package/dist/internal/anthropic.d.mts +6 -7
  28. package/dist/internal/anthropic.mjs +4 -4
  29. package/dist/internal/openai-completions-compat.d.mts +2 -0
  30. package/dist/internal/openai-completions-compat.mjs +2 -0
  31. package/dist/internal/openai-responses-payload-policy.d.mts +3 -3
  32. package/dist/internal/openai-responses-payload-policy.mjs +3 -2
  33. package/dist/internal/openai.d.mts +10 -53
  34. package/dist/internal/openai.mjs +11 -10
  35. package/dist/internal/runtime.d.mts +43 -10
  36. package/dist/internal/runtime.mjs +5 -11
  37. package/dist/internal/shared.d.mts +35 -5
  38. package/dist/internal/shared.mjs +4 -4
  39. package/dist/internal/tool-schema.d.mts +3 -3
  40. package/dist/internal/tool-schema.mjs +2 -2
  41. package/dist/{mistral--m-Jm6VZ.mjs → mistral-moA-mbwl.mjs} +9 -16
  42. package/dist/{openai-chatgpt-responses-nDZccFW-.mjs → openai-chatgpt-responses-DWID3EFO.mjs} +76 -33
  43. package/dist/{openai-completions-KuoZyx0d.mjs → openai-completions-DJ1Vm-CD.mjs} +12 -13
  44. package/dist/{openai-prompt-cache-BI0rkM-5.mjs → openai-completions-compat-CkwdxTZx.mjs} +5 -50
  45. package/dist/{openai-completions-compat-CXn3T1we.d.mts → openai-completions-compat-JE7gqxb9.d.mts} +4 -4
  46. package/dist/{openai-completions-stream-BQk3SkLD.mjs → openai-completions-stream-Bu98b0Hv.mjs} +128 -99
  47. package/dist/openai-prompt-cache-1wfaIszn.mjs +46 -0
  48. package/dist/{openai-prompt-cache-rrutvqxq.d.mts → openai-prompt-cache-CJ_xEevu.d.mts} +2 -2
  49. package/dist/{openai-provider-client-ha_WxTyj.mjs → openai-provider-client-DPo0Hmak.mjs} +2 -2
  50. package/dist/{openai-reasoning-effort-BK7FbcLT.mjs → openai-reasoning-effort-NlFZmfEu.mjs} +87 -19
  51. package/dist/{openai-responses-D99dOzKI.mjs → openai-responses-BejZzQCP.mjs} +9 -13
  52. package/dist/{openai-responses-compaction-window-D5jbzCi3.mjs → openai-responses-compaction-window-D6P5oZP5.mjs} +21 -140
  53. package/dist/openai-responses-contracts-DWrfMODE.mjs +81 -0
  54. package/dist/{openai-responses-contracts-B55afwRo.d.mts → openai-responses-contracts-Dflvrfa8.d.mts} +10 -39
  55. package/dist/{openai-responses-payload-policy-rLRPsSmB.d.mts → openai-responses-payload-policy-C7GsA1y0.d.mts} +5 -3
  56. package/dist/openai-responses-prompt-observer-internal-C15_-OwV.mjs +195 -0
  57. package/dist/{openai-responses-shared-ZyQEzS5i.mjs → openai-responses-shared-CwsziD_m.mjs} +390 -183
  58. package/dist/openai-responses-terminal-usage-Dl3J6zrf.d.mts +47 -0
  59. package/dist/{openai-tool-schema-CzjyYXun.mjs → openai-tool-schema-BO8rwyAD.mjs} +92 -68
  60. package/dist/{openai-transport-params-DNasp2fU.mjs → openai-transport-params-DQeuAvBl.mjs} +162 -51
  61. package/dist/positive-integer-DtjCkbue.mjs +8 -0
  62. package/dist/{provider-error-C6TbKiey.mjs → provider-error-DDqw9Qda.mjs} +140 -36
  63. package/dist/{provider-options-BXr9Ec83.d.mts → provider-options-DprLsWh9.d.mts} +9 -6
  64. package/dist/{provider-replay-context-BuSUaAk5.mjs → provider-replay-context-CnUSOwhr.mjs} +1 -1
  65. package/dist/{provider-transcript-transform-pPmUIwKt.mjs → provider-transcript-transform-BsRAhuWJ.mjs} +1 -1
  66. package/dist/provider-transport-turn-state-CkGToCD2.mjs +42 -0
  67. package/dist/{provider-types-CAV0Og3m.d.mts → provider-types-CAKRC7N5.d.mts} +3 -3
  68. package/dist/provider-types.d.mts +6 -7
  69. package/dist/providers.d.mts +2 -2
  70. package/dist/providers.mjs +10 -10
  71. package/dist/{reasoning-tag-text-partitioner-BQBi4B9d.mjs → reasoning-tag-text-partitioner-Dy9IO8Dc.mjs} +15 -14
  72. package/dist/{session-affinity-CCH7eYdB.mjs → session-affinity-Bcunsn4I.mjs} +5 -2
  73. package/dist/{simple-options-tcKOqnpF.mjs → simple-options-C6cFWj_f.mjs} +26 -5
  74. package/dist/{src-B2Q_6G8V.mjs → src-DeKjbE8I.mjs} +3 -6
  75. package/dist/{stream-first-event-timeout-2hfrquuz.mjs → stream-first-event-timeout-C9ZadkJW.mjs} +1 -1
  76. package/dist/{string-normalization-CmLIasuf.mjs → string-normalization-J9ZiLfGO.mjs} +13 -1
  77. package/dist/tool-schema-json-projection-CD9c_fK8.mjs +134 -0
  78. package/dist/{transport-stream-shared-DOxpGJ-H.d.mts → transport-stream-shared-BbUkFaHi.d.mts} +20 -36
  79. package/dist/{transport-stream-shared-Cu3ZPhNW.mjs → transport-stream-shared-D-6FQSHm.mjs} +223 -11
  80. package/dist/{transport-utils-CCooe-cr.mjs → transport-utils-1cyq5Y7x.mjs} +4 -7
  81. package/dist/transports.d.mts +51 -165
  82. package/dist/transports.mjs +172 -507
  83. package/dist/{types-Dy1q0CSu.d.mts → types-4_uVs5WH.d.mts} +49 -3
  84. package/dist/types-DkJfb4W3.d.mts +1 -0
  85. package/dist/types-LFWwv0cF.mjs +8 -0
  86. package/dist/types.d.mts +6 -7
  87. package/dist/types.mjs +4 -4
  88. package/dist/{validation-CaFUZN9B.d.mts → validation-Ctzu2DhF.d.mts} +1 -1
  89. package/dist/{validation-BDzVDnTs.mjs → validation-Dw7cb6BV.mjs} +1 -0
  90. package/dist/validation.d.mts +1 -1
  91. package/dist/validation.mjs +1 -1
  92. package/package.json +10 -5
  93. package/dist/diagnostics-DnPnOui6.d.mts +0 -29
  94. package/dist/event-stream-I_GlBsuZ.d.mts +0 -1
  95. package/dist/hash-CHgqbJmD.mjs +0 -16
  96. package/dist/json-parse-Dw_hnxsA.mjs +0 -146
  97. package/dist/openai-responses-prompt-observer-internal-tApyTLVu.mjs +0 -32
  98. package/dist/sanitize-unicode-Bb-v9meu.mjs +0 -83
  99. package/dist/tool-schema-json-projection-ClptDdAO.mjs +0 -82
  100. package/dist/types-BADKjDBI.d.mts +0 -1
  101. package/dist/types-BDdaOVi2.mjs +0 -6
@@ -1,28 +1,27 @@
1
1
  import { r as appendAssistantThinking } from "./event-stream-D8PARQfL.mjs";
2
- import { t as sanitizeSurrogates } from "./sanitize-unicode-Bb-v9meu.mjs";
3
- import { a as describeToolResultMediaPlaceholder, c as extractToolResultText, d as isImageWithMediaPayload } from "./host-CWuF-sS3.mjs";
4
2
  import { o as isRecord } from "./record-coerce-DwRYMj3t.mjs";
3
+ import { n as isOpenAIGpt55Model, r as isOpenAIGpt56Model, t as isOpenAIGpt54MiniModel } from "./openai-reasoning-effort-NlFZmfEu.mjs";
4
+ import { r as uniqueStrings } from "./string-normalization-J9ZiLfGO.mjs";
5
+ import { _ as isImageWithMediaPayload, d as describeToolResultMediaPlaceholder, m as extractToolResultText, v as sanitizeSurrogates } from "./host-B4MeUNBc.mjs";
5
6
  import { t as truncateUtf16Safe } from "./utf16-slice-CvGodqok.mjs";
6
- import { d as shouldOmitOllamaCompatResponseFormat, i as detectOpenAICompletionsCompat, r as resolveOpenAIPromptCacheParams, u as resolveOpenAICompletionsResponseFormat } from "./openai-prompt-cache-BI0rkM-5.mjs";
7
- import { r as emitModelTransportDebug } from "./diagnostics-dV98PqIy.mjs";
8
- import { t as createReasoningTagTextPartitioner } from "./reasoning-tag-text-partitioner-BQBi4B9d.mjs";
9
- import { i as asNonNegativeFiniteNumber } from "./base64-D-su8YVo.mjs";
10
- import { l as supportsModelTools, r as estimateStringChars } from "./transport-utils-CCooe-cr.mjs";
11
- import { n as uniqueStrings } from "./string-normalization-CmLIasuf.mjs";
12
- import { i as resolveProviderEndpoint, r as resolveOpenAIStrictToolSetting } from "./host-policy-CAopLRKA.mjs";
7
+ import { r as resolveOpenAIPromptCacheParams } from "./openai-prompt-cache-1wfaIszn.mjs";
8
+ import { r as emitModelTransportDebug } from "./diagnostics-Dm4bisWG.mjs";
9
+ import { i as asNonNegativeFiniteNumber } from "./base64-BQOzsvUH.mjs";
10
+ import { c as supportsModelTools, r as estimateStringChars } from "./transport-utils-1cyq5Y7x.mjs";
11
+ import { c as shouldOmitOllamaCompatResponseFormat, n as isNativeOpenAIEndpoint, s as resolveOpenAICompletionsResponseFormat, t as detectOpenAICompletionsCompat } from "./openai-completions-compat-CkwdxTZx.mjs";
12
+ import { i as resolveProviderEndpoint, r as resolveOpenAIStrictToolSetting } from "./host-policy-DUnXSx0I.mjs";
13
13
  import { t as resolveCacheRetention } from "./cache-retention-0x979a5V.mjs";
14
- import { d as stripSystemPromptCacheBoundary, m as sortPromptCacheToolsByName, u as splitSystemPromptCacheBoundary } from "./simple-options-tcKOqnpF.mjs";
15
- import { C as readOpenAICompletionsContentDeltas, D as throwIfModelStreamAborted, E as resolvePromptCacheKey, S as parseOpenAICompletionsUsage, b as log, d as resolveOpenAIReasoningEffortMap, f as projectOpenAITools, g as createModelStreamCooperativeScheduler, h as GEMINI_THOUGHT_SIGNATURE_VALIDATOR_SKIP, p as reconcileOpenAICompletionsToolChoice, s as getCompat, u as resolveOpenAIStrictToolFlagWithDiagnostics, w as readOpenAICompletionsReasoningBatch, x as measureUtf8AppendBytes, y as isOpenAICompletionsThinkingEnabled } from "./openai-transport-params-DNasp2fU.mjs";
16
- import { s as finalizeTerminalToolCallArguments } from "./transport-stream-shared-Cu3ZPhNW.mjs";
14
+ import { f as splitSystemPromptCacheBoundary, h as stripSystemPromptRelocatableBoundary, m as stripSystemPromptCacheBoundary, p as splitSystemPromptRelocatableBoundary, v as sortPromptCacheToolsByName } from "./simple-options-C6cFWj_f.mjs";
15
+ import { A as resolvePromptCacheKey, C as isOpenAICompletionsThinkingEnabled, D as readOpenAICompletionsContentDeltas, E as parseOpenAICompletionsUsage, O as readOpenAICompletionsReasoningBatch, T as measureUtf8AppendBytes, d as prepareOpenAITools, f as projectOpenAITools, g as resolveOpenAISimpleReasoningEffort, h as resolveOpenAIRequestReasoning, j as throwIfModelStreamAborted, p as reconcileOpenAICompletionsToolChoice, s as getCompat, u as resolveOpenAIStrictToolFlagWithDiagnostics, v as GEMINI_THOUGHT_SIGNATURE_VALIDATOR_SKIP, w as log, y as createModelStreamCooperativeScheduler } from "./openai-transport-params-DQeuAvBl.mjs";
16
+ import { E as parseStreamingJson, c as finalizeTerminalToolCallArguments, w as createToolArgumentPreviewSchedule } from "./transport-stream-shared-D-6FQSHm.mjs";
17
17
  import { a as tagUnresolvedTextAsCommentary, i as tagPendingCommentaryText, n as rememberPendingCommentaryTags, r as tagInterruptedTextPhases, t as clearPendingCommentaryText } from "./assistant-text-phase-C20rxWwP.mjs";
18
- import { r as parseStreamingJson, t as createToolArgumentPreviewSchedule } from "./json-parse-Dw_hnxsA.mjs";
19
18
  import { t as notifyLlmRequestActivity } from "./llm-request-activity-BjtkplhG.mjs";
20
- import { a as withFirstStreamEventTimeout } from "./stream-first-event-timeout-2hfrquuz.mjs";
21
- import { t as transformProviderMessages } from "./provider-transcript-transform-pPmUIwKt.mjs";
22
- import { n as isOpenAIGpt55Model, o as resolveOpenAIReasoningEffortForModel, r as isOpenAIGpt56Model, t as isOpenAIGpt54MiniModel } from "./openai-reasoning-effort-BK7FbcLT.mjs";
23
- import { r as normalizeOpenAIStrictToolParameters } from "./openai-tool-schema-CzjyYXun.mjs";
19
+ import { a as withFirstStreamEventTimeout } from "./stream-first-event-timeout-C9ZadkJW.mjs";
20
+ import { t as transformProviderMessages } from "./provider-transcript-transform-BsRAhuWJ.mjs";
21
+ import { f as withPreparedToolSchemaNormalization, r as normalizeOpenAIStrictToolParameters } from "./openai-tool-schema-BO8rwyAD.mjs";
24
22
  import { isGoogleGemini3FlashModel, isGoogleGemini3ProModel } from "./internal/google-model-family.mjs";
25
23
  import { t as mapOpenAIStopReason } from "./openai-stop-reason-Drnn_6Qj.mjs";
24
+ import { t as createReasoningTagTextPartitioner } from "./reasoning-tag-text-partitioner-Dy9IO8Dc.mjs";
26
25
  import { randomUUID } from "node:crypto";
27
26
  //#region packages/ai/src/transports/deepseek-dsml-grammar.ts
28
27
  const DEEPSEEK_DSML_MARKERS = [
@@ -458,9 +457,18 @@ function convertMessages(model, context, compat, options = {}) {
458
457
  return id;
459
458
  };
460
459
  const transformedMessages = transformProviderMessages(context.messages, model, (id) => normalizeToolCallId(id));
460
+ let relocatableSplit;
461
+ let systemParamIndex;
461
462
  if (context.systemPrompt) {
462
463
  const role = model.reasoning && compat.supportsDeveloperRole ? "developer" : "system";
463
- const systemPrompt = options.preserveSystemPromptCacheBoundary ? context.systemPrompt : stripSystemPromptCacheBoundary(context.systemPrompt);
464
+ let systemPrompt;
465
+ if (options.preserveSystemPromptCacheBoundary) systemPrompt = stripSystemPromptRelocatableBoundary(context.systemPrompt);
466
+ else {
467
+ const split = splitSystemPromptRelocatableBoundary(context.systemPrompt);
468
+ if (split && split.relocatable.length > 0) relocatableSplit = split;
469
+ systemPrompt = stripSystemPromptCacheBoundary(context.systemPrompt);
470
+ }
471
+ systemParamIndex = params.length;
464
472
  params.push({
465
473
  role,
466
474
  content: sanitizeSurrogates(systemPrompt)
@@ -605,16 +613,37 @@ function convertMessages(model, context, compat, options = {}) {
605
613
  }
606
614
  lastRole = msg.role;
607
615
  }
616
+ if (relocatableSplit !== void 0 && systemParamIndex !== void 0) relocateNonBehavioralRegion({
617
+ params,
618
+ systemParamIndex,
619
+ split: relocatableSplit,
620
+ cacheOptOutIndexes: options.cacheOptOutIndexes
621
+ });
608
622
  return params;
609
623
  }
624
+ /** Commit relocation only after finding an emitted carrier. */
625
+ function relocateNonBehavioralRegion(args) {
626
+ const text = sanitizeSurrogates(stripSystemPromptCacheBoundary(args.split.relocatable));
627
+ for (let index = args.systemParamIndex + 1; index < args.params.length; index++) {
628
+ const param = args.params[index];
629
+ if (!param || param.role !== "user") continue;
630
+ if (typeof param.content === "string") param.content = `${param.content}\n\n${text}`;
631
+ else if (Array.isArray(param.content)) param.content = [...param.content, {
632
+ type: "text",
633
+ text
634
+ }];
635
+ else continue;
636
+ const systemParam = args.params[args.systemParamIndex];
637
+ if (systemParam) systemParam.content = sanitizeSurrogates(stripSystemPromptCacheBoundary(args.split.remainingPrompt));
638
+ args.cacheOptOutIndexes?.add(index);
639
+ return;
640
+ }
641
+ }
610
642
  //#endregion
611
643
  //#region packages/ai/src/transports/openai-completions-direct-policy.ts
612
- function applyDirectCompletionsReasoningAndRouting(params, model, options, compat) {
613
- const reasoningEffortMap = resolveOpenAIReasoningEffortMap(model);
614
- const thinkingLevelMap = model.thinkingLevelMap;
615
- const offReasoningEffort = reasoningEffortMap.off ?? model.thinkingLevelMap?.off;
616
- const reasoningEffort = options?.reasoningEffort === void 0 ? offReasoningEffort ?? void 0 : reasoningEffortMap[options.reasoningEffort] ?? thinkingLevelMap?.[options.reasoningEffort] ?? options.reasoningEffort;
617
- const reasoningEnabled = reasoningEffort !== void 0 && reasoningEffort !== "none";
644
+ function applyDirectCompletionsReasoningAndRouting(params, model, reasoning, compat) {
645
+ const nativeEffort = compat.thinkingFormat === "openrouter" ? void 0 : reasoning.effort;
646
+ const reasoningEnabled = reasoning.thinkingEnabled ?? false;
618
647
  if (compat.thinkingFormat === "zai" && model.reasoning) params.thinking = reasoningEnabled ? {
619
648
  type: "enabled",
620
649
  clear_thinking: false
@@ -626,17 +655,11 @@ function applyDirectCompletionsReasoningAndRouting(params, model, options, compa
626
655
  };
627
656
  else if (compat.thinkingFormat === "deepseek" && model.reasoning) {
628
657
  params.thinking = { type: reasoningEnabled ? "enabled" : "disabled" };
629
- if (reasoningEnabled && compat.supportsReasoningEffort) params.reasoning_effort = reasoningEffort;
630
- } else if (compat.thinkingFormat === "openrouter" && model.reasoning) {
631
- if (reasoningEnabled) params.reasoning = { effort: reasoningEffort };
632
- else if (offReasoningEffort !== null) params.reasoning = { effort: offReasoningEffort ?? "none" };
658
+ if (reasoningEnabled && compat.supportsReasoningEffort && nativeEffort !== void 0) params.reasoning_effort = nativeEffort;
633
659
  } else if (compat.thinkingFormat === "together" && model.reasoning) {
634
660
  params.reasoning = { enabled: reasoningEnabled };
635
- if (reasoningEnabled && compat.supportsReasoningEffort) params.reasoning_effort = reasoningEffort;
636
- } else if (reasoningEnabled && model.reasoning && compat.supportsReasoningEffort) params.reasoning_effort = reasoningEffort;
637
- else if (model.reasoning && compat.supportsReasoningEffort) {
638
- if (typeof offReasoningEffort === "string") params.reasoning_effort = offReasoningEffort;
639
- }
661
+ if (reasoningEnabled && compat.supportsReasoningEffort && nativeEffort !== void 0) params.reasoning_effort = nativeEffort;
662
+ } else if (model.reasoning && compat.supportsReasoningEffort && nativeEffort !== void 0) params.reasoning_effort = nativeEffort;
640
663
  if (compat.openRouterRouting) params.provider = compat.openRouterRouting;
641
664
  if (model.baseUrl.includes("ai-gateway.vercel.sh") && model.compat?.vercelGatewayRouting) {
642
665
  const routing = model.compat.vercelGatewayRouting;
@@ -807,7 +830,7 @@ function applyCompletionsReplay(outgoingMessages, context, model, compat) {
807
830
  //#endregion
808
831
  //#region packages/ai/src/transports/openai-completions-params.ts
809
832
  function isKnownOpenAICompletionsEndpoint(model) {
810
- if (!model.baseUrl.trim()) return true;
833
+ if (!model.baseUrl.trim() || isNativeOpenAIEndpoint(model)) return true;
811
834
  const endpointClass = resolveProviderEndpoint(model).endpointClass;
812
835
  if (endpointClass === "openai-public" || endpointClass === "azure-openai") return true;
813
836
  try {
@@ -816,9 +839,6 @@ function isKnownOpenAICompletionsEndpoint(model) {
816
839
  return false;
817
840
  }
818
841
  }
819
- function resolveOpenAICompletionsReasoningEffort(options) {
820
- return options?.reasoningEffort ?? options?.reasoning ?? "high";
821
- }
822
842
  function resolveOpenAICompletionsMaxTokens(model, options) {
823
843
  if (options?.maxTokens) return {
824
844
  maxTokens: options.maxTokens,
@@ -839,6 +859,7 @@ function resolveOpenAICompletionsModelMaxTokens(model) {
839
859
  }
840
860
  const OPENAI_COMPLETIONS_INPUT_TOKEN_SAFETY_MARGIN = 1.25;
841
861
  const OPENAI_COMPLETIONS_IMAGE_CHAR_ESTIMATE = 8e3;
862
+ const MIN_USEFUL_OUTPUT_TOKENS = 16;
842
863
  function estimateOpenAICompletionsInputTokens(payload) {
843
864
  let adjustedChars = 0;
844
865
  adjustedChars += estimateOpenAICompletionsMessagesChars(payload.messages);
@@ -899,9 +920,6 @@ function resolveOpenAICompletionsEffectiveContextTokens(model) {
899
920
  if (typeof contextTokens === "number" && Number.isFinite(contextTokens) && contextTokens > 0) return contextTokens;
900
921
  return typeof model.contextWindow === "number" && Number.isFinite(model.contextWindow) && model.contextWindow > 0 ? model.contextWindow : void 0;
901
922
  }
902
- function isQwenOpenAICompletionsThinkingFormat(format) {
903
- return format === "qwen" || format === "qwen-chat-template";
904
- }
905
923
  function setQwenChatTemplateThinking(params, enabled) {
906
924
  const existing = params.chat_template_kwargs;
907
925
  params.chat_template_kwargs = existing && typeof existing === "object" && !Array.isArray(existing) ? {
@@ -909,41 +927,51 @@ function setQwenChatTemplateThinking(params, enabled) {
909
927
  enable_thinking: enabled
910
928
  } : { enable_thinking: enabled };
911
929
  }
912
- function applyQwenOpenAICompletionsThinkingParams(params) {
913
- if (!params.modelReasoning || !isQwenOpenAICompletionsThinkingFormat(params.compatThinkingFormat)) return false;
914
- const enabled = isOpenAICompletionsThinkingEnabled(params.requestedEffort);
915
- if (params.compatThinkingFormat === "qwen-chat-template") setQwenChatTemplateThinking(params.payload, enabled);
916
- else params.payload.enable_thinking = enabled;
917
- return true;
918
- }
919
- function applyTogetherOpenAICompletionsThinkingParams(params) {
920
- if (!params.modelReasoning || params.compatThinkingFormat !== "together") return;
921
- params.payload.reasoning = { enabled: isOpenAICompletionsThinkingEnabled(params.requestedEffort) };
930
+ /** Return whether the binary control replaces scalar reasoning effort. */
931
+ function applyBinaryCompletionsThinkingParams(params) {
932
+ if (!params.modelReasoning) return false;
933
+ const enabled = params.thinkingEnabled;
934
+ switch (params.compatThinkingFormat) {
935
+ case "qwen-chat-template":
936
+ setQwenChatTemplateThinking(params.payload, enabled);
937
+ return true;
938
+ case "qwen":
939
+ params.payload.enable_thinking = enabled;
940
+ return true;
941
+ case "together":
942
+ params.payload.reasoning = { enabled };
943
+ return !enabled;
944
+ default: return false;
945
+ }
922
946
  }
923
947
  function convertTools(tools, compat, model, mode) {
924
- const projection = projectOpenAITools(tools);
925
- const strict = mode === "direct" ? compat.supportsStrictMode ? false : void 0 : resolveOpenAIStrictToolFlagWithDiagnostics(projection, resolveOpenAIStrictToolSetting(model, {
926
- transport: "stream",
927
- supportsStrictMode: compat?.supportsStrictMode
928
- }), {
929
- transport: "completions",
930
- model
931
- });
932
- return {
933
- projection,
934
- tools: sortPromptCacheToolsByName(projection.tools).map((tool) => {
935
- const functionTool = {
936
- name: tool.name,
937
- description: tool.description,
938
- parameters: mode === "direct" ? tool.parameters : normalizeOpenAIStrictToolParameters(tool.parameters, strict === true, model.compat)
939
- };
940
- if (strict !== void 0) functionTool.strict = strict;
941
- return {
942
- type: "function",
943
- function: functionTool
944
- };
945
- })
948
+ const prepared = mode === "managed" ? prepareOpenAITools(tools) : void 0;
949
+ const projection = prepared?.projection ?? projectOpenAITools(tools);
950
+ const convert = () => {
951
+ const strict = mode === "direct" ? compat.supportsStrictMode ? false : void 0 : resolveOpenAIStrictToolFlagWithDiagnostics(projection, resolveOpenAIStrictToolSetting(model, {
952
+ transport: "stream",
953
+ supportsStrictMode: compat?.supportsStrictMode
954
+ }), {
955
+ transport: "completions",
956
+ model
957
+ });
958
+ return {
959
+ projection,
960
+ tools: sortPromptCacheToolsByName(projection.tools).map((tool) => {
961
+ const functionTool = {
962
+ name: tool.name,
963
+ description: tool.description,
964
+ parameters: mode === "direct" ? tool.parameters : normalizeOpenAIStrictToolParameters(tool.parameters, strict === true, model.compat)
965
+ };
966
+ if (strict !== void 0) functionTool.strict = strict;
967
+ return {
968
+ type: "function",
969
+ function: functionTool
970
+ };
971
+ })
972
+ };
946
973
  };
974
+ return prepared ? withPreparedToolSchemaNormalization(prepared.schemas, convert) : convert();
947
975
  }
948
976
  function buildOpenAICompletionsParams(model, context, options) {
949
977
  return buildOpenAICompletionsRequest(model, context, options, { mode: "managed" });
@@ -1040,6 +1068,7 @@ function buildOpenAICompletionsRequest(model, context, options, policy) {
1040
1068
  if (clampedMaxTokens > remainingBudget) {
1041
1069
  clampedMaxTokens = remainingBudget;
1042
1070
  emitModelTransportDebug(log, `[completions] clamp_max_tokens provider=${model.provider} api=${model.api} model=${model.id} requested=${effectiveMaxTokens} output=${clampedMaxTokens} effectiveContext=${effectiveContextTokens} estimatedInput=${estimatedInputTokens}`);
1071
+ if (remainingBudget < MIN_USEFUL_OUTPUT_TOKENS) log.warn(`[completions] insufficient_output_budget provider=${model.provider} api=${model.api} model=${model.id} output=${clampedMaxTokens} effectiveContext=${effectiveContextTokens} estimatedInput=${estimatedInputTokens}`);
1043
1072
  }
1044
1073
  }
1045
1074
  if (policy.mode === "direct" ? options?.maxTokens : clampedMaxTokens) {
@@ -1047,34 +1076,34 @@ function buildOpenAICompletionsRequest(model, context, options, policy) {
1047
1076
  else params.max_completion_tokens = clampedMaxTokens;
1048
1077
  }
1049
1078
  }
1050
- if (policy.mode === "direct") {
1051
- applyDirectCompletionsReasoningAndRouting(params, model, options, compat);
1052
- return params;
1079
+ const isOpenRouter = compat.thinkingFormat === "openrouter";
1080
+ const usesBinaryOpenRouterThinking = isOpenRouter && (model.compat?.supportsReasoningEffort === false || model.compat?.supportedReasoningEfforts?.length === 0);
1081
+ const simpleReasoning = options?.reasoning;
1082
+ const requestedEffort = policy.mode === "direct" ? options?.reasoningEffort : options?.reasoningEffort ?? (simpleReasoning === "none" ? "none" : resolveOpenAISimpleReasoningEffort({
1083
+ ...model,
1084
+ compat: model.compat ?? void 0
1085
+ }, simpleReasoning)) ?? (usesBinaryOpenRouterThinking ? void 0 : "high");
1086
+ const reasoning = resolveOpenAIRequestReasoning(model, requestedEffort);
1087
+ const { effort, thinkingEnabled } = reasoning;
1088
+ if (isOpenRouter && model.reasoning) {
1089
+ if (usesBinaryOpenRouterThinking && thinkingEnabled !== void 0) params.reasoning = { enabled: thinkingEnabled };
1090
+ else if (effort !== void 0) params.reasoning = { effort };
1091
+ }
1092
+ if (policy.mode === "direct") applyDirectCompletionsReasoningAndRouting(params, model, reasoning, compat);
1093
+ else {
1094
+ const suppressScalarEffort = applyBinaryCompletionsThinkingParams({
1095
+ compatThinkingFormat: compat.thinkingFormat,
1096
+ modelReasoning: model.reasoning,
1097
+ payload: params,
1098
+ thinkingEnabled: thinkingEnabled ?? false
1099
+ });
1100
+ if (!isOpenRouter && effort && model.reasoning && compat.supportsReasoningEffort && !suppressScalarEffort) params.reasoning_effort = effort;
1101
+ if (compat.cacheControlFormat === "anthropic") applyCompletionsAnthropicCacheControl(params, cacheControl ?? null, cacheOptOutIndexes, markTools, !managedCompat?.requiresStringContent);
1102
+ }
1103
+ if (params.tools?.length && isKnownOpenAICompletionsEndpoint(model)) {
1104
+ if (isOpenAIGpt56Model(model)) params.reasoning_effort = "none";
1105
+ else if (isOpenAIGpt54MiniModel(model) || isOpenAIGpt55Model(model)) delete params.reasoning_effort;
1053
1106
  }
1054
- const completionsReasoningEffort = resolveOpenAICompletionsReasoningEffort(options);
1055
- const resolvedCompletionsReasoningEffort = completionsReasoningEffort ? resolveOpenAIReasoningEffortForModel({
1056
- model,
1057
- effort: completionsReasoningEffort,
1058
- fallbackMap: managedCompat?.reasoningEffortMap
1059
- }) : void 0;
1060
- const omitChatCompletionsToolReasoningEffort = Array.isArray(params.tools) && params.tools.length > 0 && (isOpenAIGpt54MiniModel(model) || isOpenAIGpt55Model(model) && isKnownOpenAICompletionsEndpoint(model));
1061
- const disableChatCompletionsToolReasoning = Array.isArray(params.tools) && params.tools.length > 0 && isOpenAIGpt56Model(model) && isKnownOpenAICompletionsEndpoint(model);
1062
- const handledQwenThinkingFormat = applyQwenOpenAICompletionsThinkingParams({
1063
- compatThinkingFormat: compat.thinkingFormat,
1064
- modelReasoning: model.reasoning,
1065
- payload: params,
1066
- requestedEffort: completionsReasoningEffort
1067
- });
1068
- applyTogetherOpenAICompletionsThinkingParams({
1069
- compatThinkingFormat: compat.thinkingFormat,
1070
- modelReasoning: model.reasoning,
1071
- payload: params,
1072
- requestedEffort: completionsReasoningEffort
1073
- });
1074
- if (disableChatCompletionsToolReasoning) params.reasoning_effort = "none";
1075
- else if (compat.thinkingFormat === "openrouter" && model.reasoning && resolvedCompletionsReasoningEffort) params.reasoning = { effort: resolvedCompletionsReasoningEffort };
1076
- else if (resolvedCompletionsReasoningEffort && model.reasoning && compat.supportsReasoningEffort && !handledQwenThinkingFormat && !omitChatCompletionsToolReasoningEffort) params.reasoning_effort = resolvedCompletionsReasoningEffort;
1077
- if (compat.cacheControlFormat === "anthropic") applyCompletionsAnthropicCacheControl(params, cacheControl ?? null, cacheOptOutIndexes, markTools, !managedCompat?.requiresStringContent);
1078
1107
  return params;
1079
1108
  }
1080
1109
  //#endregion
@@ -0,0 +1,46 @@
1
+ import { n as isNativeOpenAIEndpoint } from "./openai-completions-compat-CkwdxTZx.mjs";
2
+ //#region packages/normalization-core/src/code-points.ts
3
+ /** Truncates to a nonnegative code-point budget; grapheme clusters may be split. */
4
+ function truncateCodePoints(text, maxCodePoints) {
5
+ const limit = Math.max(0, Math.trunc(maxCodePoints) || 0);
6
+ if (text.length <= limit) return text;
7
+ const prefix = [];
8
+ for (const codePoint of text) {
9
+ if (prefix.length >= limit) break;
10
+ prefix.push(codePoint);
11
+ }
12
+ return prefix.join("");
13
+ }
14
+ //#endregion
15
+ //#region packages/ai/src/providers/openai-prompt-cache.ts
16
+ const EXTENDED_RETENTION_MODELS = /* @__PURE__ */ new Set([
17
+ "gpt-5.5",
18
+ "gpt-5.5-pro",
19
+ "gpt-5.4",
20
+ "gpt-5.2",
21
+ "gpt-5.1-codex-max",
22
+ "gpt-5.1",
23
+ "gpt-5.1-codex",
24
+ "gpt-5.1-codex-mini",
25
+ "gpt-5.1-chat-latest",
26
+ "gpt-5",
27
+ "gpt-5-codex",
28
+ "gpt-4.1"
29
+ ]);
30
+ /** Selects documented lifetime fields shared by Responses and Chat Completions. */
31
+ function resolveOpenAIPromptCacheParams(model, cacheRetention, compat) {
32
+ if (cacheRetention !== "long" || !compat.supportsPromptCacheKey || !compat.supportsLongCacheRetention) return {};
33
+ const version = /^gpt-(\d+)(?:\.(\d+))?(?:-|$)/.exec(model.id);
34
+ if (version && (Number(version[1]) > 5 || Number(version[1]) === 5 && Number(version[2]) >= 6)) return { prompt_cache_options: { ttl: "30m" } };
35
+ const modelId = model.id.replace(/-\d{4}-\d{2}-\d{2}$/, "");
36
+ return !isNativeOpenAIEndpoint(model) || EXTENDED_RETENTION_MODELS.has(modelId) ? { prompt_cache_retention: "24h" } : {};
37
+ }
38
+ /** Maximum prompt cache key length accepted by OpenAI-compatible request metadata. */
39
+ const OPENAI_PROMPT_CACHE_KEY_MAX_LENGTH = 64;
40
+ /** Truncates a prompt cache key by Unicode code point count. */
41
+ function clampOpenAIPromptCacheKey(key) {
42
+ if (key === void 0) return;
43
+ return truncateCodePoints(key, 64);
44
+ }
45
+ //#endregion
46
+ export { clampOpenAIPromptCacheKey as n, resolveOpenAIPromptCacheParams as r, OPENAI_PROMPT_CACHE_KEY_MAX_LENGTH as t };
@@ -1,5 +1,5 @@
1
- import { D as Model, j as OpenAICompletionsCompat, l as CacheRetention } from "./types-Dy1q0CSu.mjs";
2
- import "./types-BADKjDBI.mjs";
1
+ import { M as OpenAICompletionsCompat, O as Model, l as CacheRetention } from "./types-4_uVs5WH.mjs";
2
+ import "./types-DkJfb4W3.mjs";
3
3
  //#region packages/ai/src/providers/openai-prompt-cache.d.ts
4
4
  /** Selects documented lifetime fields shared by Responses and Chat Completions. */
5
5
  declare function resolveOpenAIPromptCacheParams(model: Pick<Model, "id" | "provider" | "baseUrl">, cacheRetention: CacheRetention, compat: Required<Pick<OpenAICompletionsCompat, "supportsPromptCacheKey" | "supportsLongCacheRetention">>): {
@@ -1,5 +1,5 @@
1
- import { n as getAiTransportHost } from "./host-CWuF-sS3.mjs";
2
- import { T as resolveOpenAIClientBaseUrl } from "./openai-transport-params-DNasp2fU.mjs";
1
+ import { n as getAiTransportHost } from "./host-B4MeUNBc.mjs";
2
+ import { k as resolveOpenAIClientBaseUrl } from "./openai-transport-params-DQeuAvBl.mjs";
3
3
  import { i as resolveCloudflareBaseUrl, r as isCloudflareProvider } from "./github-copilot-headers-B37TB3rB.mjs";
4
4
  import OpenAI from "openai";
5
5
  //#region packages/ai/src/providers/openai-provider-client.ts
@@ -1,11 +1,80 @@
1
1
  import { n as normalizeLowercaseStringOrEmpty } from "./string-coerce-fsri9iCu.mjs";
2
- import { n as uniqueStrings, t as normalizeStringEntries } from "./string-normalization-CmLIasuf.mjs";
2
+ import { i as asOptionalRecord } from "./record-coerce-DwRYMj3t.mjs";
3
+ import { n as normalizeUniqueTrimmedStringList } from "./string-normalization-J9ZiLfGO.mjs";
4
+ //#region packages/llm-core/src/model-data.ts
5
+ const MODEL_DATA_APIS = [
6
+ "openai-completions",
7
+ "openai-responses",
8
+ "openai-chatgpt-responses",
9
+ "anthropic-messages",
10
+ "google-generative-ai",
11
+ "google-vertex",
12
+ "github-copilot",
13
+ "bedrock-converse-stream",
14
+ "ollama",
15
+ "pi-messages",
16
+ "azure-openai-responses"
17
+ ];
18
+ const MODEL_DATA_THINKING_FORMATS = [
19
+ "openai",
20
+ "openrouter",
21
+ "deepseek",
22
+ "together",
23
+ "qwen",
24
+ "qwen-chat-template",
25
+ "zai"
26
+ ];
27
+ const MODEL_DATA_THINKING_LEVELS = [
28
+ "off",
29
+ "minimal",
30
+ "low",
31
+ "medium",
32
+ "high",
33
+ "xhigh",
34
+ "max"
35
+ ];
36
+ [...MODEL_DATA_APIS];
37
+ [...MODEL_DATA_THINKING_FORMATS];
38
+ /** Model-level thinking settings carried by provider catalog metadata. */
39
+ const MODEL_CATALOG_THINKING_LEVELS = [...MODEL_DATA_THINKING_LEVELS];
40
+ const OPENAI_THINKING_APIS = /* @__PURE__ */ new Set([
41
+ "openai-completions",
42
+ "openai-responses",
43
+ "openai-chatgpt-responses",
44
+ "azure-openai-responses"
45
+ ]);
46
+ /** Managed API aliases retain the source adapter's reasoning contract. */
47
+ function resolveOpenAIThinkingApi(api) {
48
+ if (typeof api !== "string") return;
49
+ const sourceApi = api.replace(/^openclaw-(.+)-transport$/u, "$1");
50
+ return OPENAI_THINKING_APIS.has(sourceApi) ? sourceApi : void 0;
51
+ }
52
+ /** Map keys describe logical choices; provider-native values retain their spelling. */
53
+ function listMappedModelThinkingLevels(model) {
54
+ const compat = asOptionalRecord(model.compat);
55
+ const efforts = compat?.supportedReasoningEfforts;
56
+ const api = resolveOpenAIThinkingApi(model.api);
57
+ const format = compat?.thinkingFormat;
58
+ if (!api || api === "openai-completions" && (format === "qwen" || format === "qwen-chat-template" || format === "zai") || compat?.supportsReasoningEffort === false || Array.isArray(efforts) && efforts.length === 0) return [];
59
+ const mapping = asOptionalRecord(compat?.reasoningEffortMap);
60
+ const mapped = new Set(Object.entries(mapping ?? {}).flatMap(([level, effort]) => typeof effort === "string" && effort.trim() ? [level.trim().toLowerCase()] : []));
61
+ return MODEL_CATALOG_THINKING_LEVELS.filter((level) => mapped.has(level));
62
+ }
63
+ //#endregion
3
64
  //#region packages/ai/src/providers/openai-reasoning-effort.ts
4
65
  /**
5
66
  * OpenAI-compatible reasoning-effort normalization. Different GPT families
6
67
  * expose different accepted effort enums, so callers map requested values here
7
68
  * before constructing provider payloads.
8
69
  */
70
+ const ENABLED_REASONING_EFFORTS = [
71
+ "minimal",
72
+ "low",
73
+ "medium",
74
+ "high",
75
+ "xhigh",
76
+ "max"
77
+ ];
9
78
  const GPT_5_REASONING_EFFORTS = [
10
79
  "minimal",
11
80
  "low",
@@ -66,12 +135,7 @@ const GENERIC_REASONING_EFFORTS = [
66
135
  ];
67
136
  const CANONICAL_REASONING_EFFORTS = /* @__PURE__ */ new Set([
68
137
  "none",
69
- "minimal",
70
- "low",
71
- "medium",
72
- "high",
73
- "xhigh",
74
- "max",
138
+ ...ENABLED_REASONING_EFFORTS,
75
139
  "off"
76
140
  ]);
77
141
  function normalizeModelId(id) {
@@ -105,8 +169,7 @@ function readCompatReasoningEfforts(compat) {
105
169
  if (compat.supportsReasoningEffort === false) return [];
106
170
  const raw = compat.supportedReasoningEfforts;
107
171
  if (!Array.isArray(raw)) return;
108
- const supported = uniqueStrings(normalizeStringEntries(raw.filter((value) => typeof value === "string")));
109
- return supported.length > 0 ? supported : void 0;
172
+ return normalizeUniqueTrimmedStringList(raw);
110
173
  }
111
174
  function isDisabledReasoningEffort(effort) {
112
175
  return effort === "none" || effort === "off";
@@ -120,8 +183,10 @@ function resolveOpenAIModelReasoningEfforts(model) {
120
183
  const compatEfforts = readCompatReasoningEfforts(model.compat);
121
184
  if (compatEfforts) return compatEfforts;
122
185
  const id = normalizeModelId(typeof model.id === "string" ? model.id : void 0);
123
- if (id === "gpt-6-astra" && model.api !== "azure-openai-responses") return GPT_6_ASTRA_REASONING_EFFORTS;
124
- if (/^gpt-5\.6(?:-|$)/u.test(id)) return GPT_56_REASONING_EFFORTS;
186
+ const api = resolveOpenAIThinkingApi(model.api);
187
+ const supportsMax = api !== "openai-completions";
188
+ if (id === "gpt-6-astra" && api !== "azure-openai-responses") return supportsMax ? GPT_6_ASTRA_REASONING_EFFORTS : GPT_CODEX_REASONING_EFFORTS;
189
+ if (/^gpt-5\.6(?:-|$)/u.test(id)) return supportsMax ? GPT_56_REASONING_EFFORTS : GPT_52_REASONING_EFFORTS;
125
190
  if (id === "gpt-5.1-codex-mini") return GPT_51_CODEX_MINI_REASONING_EFFORTS;
126
191
  if (id === "gpt-5.1-codex-max") return GPT_51_CODEX_MAX_REASONING_EFFORTS;
127
192
  if (/^gpt-5(?:\.\d+)?-codex(?:-|$)/u.test(id)) return GPT_CODEX_REASONING_EFFORTS;
@@ -142,26 +207,29 @@ function supportsOpenAITemperature(model) {
142
207
  if (typeof declared === "boolean") return declared;
143
208
  }
144
209
  const id = normalizeModelId(typeof model.id === "string" ? model.id : void 0);
145
- return (id !== "gpt-6-astra" || model.api === "azure-openai-responses") && !/^gpt-5\.6(?:-|$)/u.test(id);
210
+ return (id !== "gpt-6-astra" || resolveOpenAIThinkingApi(model.api) === "azure-openai-responses") && !/^gpt-5\.6(?:-|$)/u.test(id);
146
211
  }
147
212
  /** Return whether a model accepts a requested reasoning effort. */
148
213
  function supportsOpenAIReasoningEffort(model, effort) {
149
214
  return resolveOpenAISupportedReasoningEfforts(model).includes(normalizeOpenAIReasoningEffort(effort));
150
215
  }
216
+ /** Read provider mappings without folding provider-native labels. */
217
+ function resolveOpenAIReasoningEffortMapping(effort, mapping) {
218
+ const requested = normalizeOpenAIReasoningEffort(effort);
219
+ return mapping?.[requested] ?? (mapping && CANONICAL_REASONING_EFFORTS.has(requested) ? Object.entries(mapping).find(([key]) => normalizeOpenAIReasoningEffort(key) === requested)?.[1] : void 0);
220
+ }
151
221
  /** Resolve a requested reasoning effort to the closest value supported by the model. */
152
222
  function resolveOpenAIReasoningEffortForModel(params) {
153
223
  const requested = normalizeOpenAIReasoningEffort(params.effort);
154
- const mapped = params.fallbackMap?.[requested] ?? (params.fallbackMap && CANONICAL_REASONING_EFFORTS.has(requested) ? Object.entries(params.fallbackMap).find(([effort]) => normalizeOpenAIReasoningEffort(effort) === requested)?.[1] : void 0);
224
+ const mapped = resolveOpenAIReasoningEffortMapping(requested, params.fallbackMap);
155
225
  const normalized = mapped === void 0 ? requested : mapped.trim();
156
226
  const supported = resolveOpenAISupportedReasoningEfforts(params.model);
157
227
  if (supported.includes(normalized)) return normalized;
158
228
  if (requested === "off" && supported.includes("none")) return "none";
159
229
  if (isDisabledReasoningEffort(requested) || isDisabledReasoningEffort(normalized)) return;
160
- if (requested === "minimal" && supported.includes("low")) return "low";
161
- if ((requested === "minimal" || requested === "low") && supported.includes("medium")) return "medium";
162
- if (requested === "xhigh" && supported.includes("high")) return "high";
163
- if (requested === "max" && supported.includes("xhigh")) return "xhigh";
164
- return supported.find((effort) => !isDisabledReasoningEffort(normalizeOpenAIReasoningEffort(effort)));
230
+ const requestedRank = ENABLED_REASONING_EFFORTS.findIndex((effort) => effort === normalized);
231
+ const ranked = ENABLED_REASONING_EFFORTS.filter((effort) => supported.includes(effort));
232
+ return (requestedRank < 0 ? void 0 : ranked.findLast((effort) => ENABLED_REASONING_EFFORTS.indexOf(effort) <= requestedRank) ?? ranked[0]) ?? supported.find((effort) => !isDisabledReasoningEffort(normalizeOpenAIReasoningEffort(effort)));
165
233
  }
166
234
  //#endregion
167
- export { resolveOpenAIModelReasoningEfforts as a, supportsOpenAIReasoningEffort as c, normalizeOpenAIReasoningEffort as i, supportsOpenAITemperature as l, isOpenAIGpt55Model as n, resolveOpenAIReasoningEffortForModel as o, isOpenAIGpt56Model as r, resolveOpenAISupportedReasoningEfforts as s, isOpenAIGpt54MiniModel as t };
235
+ export { resolveOpenAIModelReasoningEfforts as a, resolveOpenAISupportedReasoningEfforts as c, MODEL_CATALOG_THINKING_LEVELS as d, listMappedModelThinkingLevels as f, normalizeOpenAIReasoningEffort as i, supportsOpenAIReasoningEffort as l, isOpenAIGpt55Model as n, resolveOpenAIReasoningEffortForModel as o, resolveOpenAIThinkingApi as p, isOpenAIGpt56Model as r, resolveOpenAIReasoningEffortMapping as s, isOpenAIGpt54MiniModel as t, supportsOpenAITemperature as u };
@@ -1,14 +1,15 @@
1
1
  import { t as __exportAll } from "./rolldown-runtime-BhDjJH2R.mjs";
2
2
  import { t as AssistantMessageEventStream } from "./event-stream-D8PARQfL.mjs";
3
- import { n as clampOpenAIPromptCacheKey, r as resolveOpenAIPromptCacheParams, s as resolveOpenAICompletionsCompat } from "./openai-prompt-cache-BI0rkM-5.mjs";
3
+ import { n as clampOpenAIPromptCacheKey, r as resolveOpenAIPromptCacheParams } from "./openai-prompt-cache-1wfaIszn.mjs";
4
+ import { i as resolveOpenAICompletionsCompat } from "./openai-completions-compat-CkwdxTZx.mjs";
4
5
  import { t as resolveCacheRetention } from "./cache-retention-0x979a5V.mjs";
5
- import { n as buildBaseOptions } from "./simple-options-tcKOqnpF.mjs";
6
+ import { n as buildBaseOptions } from "./simple-options-C6cFWj_f.mjs";
7
+ import { g as resolveOpenAISimpleReasoningEffort } from "./openai-transport-params-DQeuAvBl.mjs";
6
8
  import { n as getEnvApiKey } from "./env-api-keys-bktO00EJ.mjs";
7
- import { t as resolveOpencodeSessionHeaders } from "./session-affinity-CCH7eYdB.mjs";
8
- import { l as supportsOpenAITemperature } from "./openai-reasoning-effort-BK7FbcLT.mjs";
9
- import { a as resolveResponsesReasoningEffort, i as createResponsesAssistantOutput, n as applyResponsesServiceTierPricing, r as convertResponsesMessages, s as runResponsesStreamLifecycle, t as applyCommonResponsesParams } from "./openai-responses-shared-ZyQEzS5i.mjs";
9
+ import { n as resolveProviderSimpleCompletionHeaders } from "./provider-transport-turn-state-CkGToCD2.mjs";
10
+ import { a as runResponsesStreamLifecycle, i as createResponsesAssistantOutput, n as applyResponsesServiceTierPricing, r as convertResponsesMessages, t as applyCommonResponsesParams } from "./openai-responses-shared-CwsziD_m.mjs";
10
11
  import { n as hasCopilotVisionInput, t as buildCopilotDynamicHeaders } from "./github-copilot-headers-B37TB3rB.mjs";
11
- import { t as createOpenAIProviderClient } from "./openai-provider-client-ha_WxTyj.mjs";
12
+ import { t as createOpenAIProviderClient } from "./openai-provider-client-DPo0Hmak.mjs";
12
13
  //#region packages/ai/src/providers/openai-responses.ts
13
14
  var openai_responses_exports = /* @__PURE__ */ __exportAll({
14
15
  streamOpenAIResponses: () => streamOpenAIResponses,
@@ -21,9 +22,6 @@ function getCompat(model) {
21
22
  sendSessionIdHeader: model.compat?.sendSessionIdHeader ?? true
22
23
  };
23
24
  }
24
- /**
25
- * Generate function for OpenAI Responses API
26
- */
27
25
  const streamOpenAIResponses = (model, context, options) => {
28
26
  const stream = new AssistantMessageEventStream();
29
27
  const output = createResponsesAssistantOutput(model);
@@ -35,7 +33,7 @@ const streamOpenAIResponses = (model, context, options) => {
35
33
  createClient: () => {
36
34
  const apiKey = options?.apiKey || getEnvApiKey(model.provider) || "";
37
35
  const cacheSessionId = resolveCacheRetention(options?.cacheRetention) === "none" ? void 0 : options?.sessionId;
38
- return createClient(model, context, apiKey, resolveOpencodeSessionHeaders(model, options), cacheSessionId);
36
+ return createClient(model, context, apiKey, resolveProviderSimpleCompletionHeaders(model, options), cacheSessionId);
39
37
  },
40
38
  buildParams: (_requestModel, replayMode) => buildParams(model, context, options, replayMode),
41
39
  processStreamOptions: {
@@ -53,7 +51,7 @@ const streamSimpleOpenAIResponses = (model, context, options) => {
53
51
  return streamOpenAIResponses(model, context, {
54
52
  ...base,
55
53
  authProfileId: replayOptions?.authProfileId,
56
- reasoningEffort: resolveResponsesReasoningEffort(model, options?.reasoning),
54
+ reasoningEffort: resolveOpenAISimpleReasoningEffort(model, options?.reasoning),
57
55
  replayResponsesItemIds: replayOptions?.replayResponsesItemIds
58
56
  });
59
57
  };
@@ -92,8 +90,6 @@ function buildParams(model, context, options, replayMode = "checkpoint") {
92
90
  ...resolveOpenAIPromptCacheParams(model, cacheRetention, compat),
93
91
  store: false
94
92
  };
95
- if (options?.maxTokens) params.max_output_tokens = options?.maxTokens;
96
- if (options?.temperature !== void 0 && supportsOpenAITemperature(model)) params.temperature = options?.temperature;
97
93
  if (options?.serviceTier !== void 0) params.service_tier = options.serviceTier;
98
94
  applyCommonResponsesParams(params, model, context, options, { setDefaultReasoningOff: model.provider !== "github-copilot" });
99
95
  return params;