@openclaw/ai 2026.9.4 → 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 (97) hide show
  1. package/README.md +1 -1
  2. package/dist/{anthropic-C4Qu4H0Z.mjs → anthropic-COtDvgtt.mjs} +10 -11
  3. package/dist/{anthropic-payload-policy-BZ8umAbk.d.mts → anthropic-payload-policy-5Erq1Nzy.d.mts} +3 -3
  4. package/dist/{anthropic-stream-reducer-CILWF7JD.mjs → anthropic-stream-reducer-BvdYYWL8.mjs} +47 -43
  5. package/dist/{api-registry-ByUwIR0e.d.mts → api-registry-Ba2Cv-ut.d.mts} +2 -2
  6. package/dist/{assistant-output-tLt4H-iQ.mjs → assistant-output-BsEkB-vU.mjs} +1 -1
  7. package/dist/{azure-openai-responses-BAlqlKKc.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-QuErwCIl.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-Bt5Y4Pav.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-DPBAOaOW.mjs → google-BuhpRO9r.mjs} +6 -9
  18. package/dist/{google-messages-6JkpHrhJ.mjs → google-messages-CyWnYlh0.mjs} +3 -3
  19. package/dist/{google-shared-BvBeW9aq.mjs → google-shared-BT5ZeNer.mjs} +13 -13
  20. package/dist/{google-vertex-k-TMCAYD.mjs → google-vertex-C7EplRvt.mjs} +5 -8
  21. package/dist/{host-B8YfDGd4.mjs → host-B4MeUNBc.mjs} +25 -27
  22. package/dist/{host-4atIX-2V.d.mts → host-FZ1RA_qD.d.mts} +5 -3
  23. package/dist/{host-policy-Zcg_cNz8.mjs → host-policy-DUnXSx0I.mjs} +1 -1
  24. package/dist/{index-DdD3qerf.d.mts → index-DaF2QbwS.d.mts} +4 -9
  25. package/dist/index.d.mts +6 -7
  26. package/dist/index.mjs +3 -4
  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 +2 -2
  32. package/dist/internal/openai-responses-payload-policy.mjs +2 -2
  33. package/dist/internal/openai.d.mts +10 -53
  34. package/dist/internal/openai.mjs +11 -9
  35. package/dist/internal/runtime.d.mts +6 -8
  36. package/dist/internal/runtime.mjs +5 -9
  37. package/dist/internal/shared.d.mts +6 -5
  38. package/dist/internal/shared.mjs +4 -3
  39. package/dist/internal/tool-schema.d.mts +3 -3
  40. package/dist/internal/tool-schema.mjs +2 -2
  41. package/dist/{mistral-CxUZ1jUb.mjs → mistral-moA-mbwl.mjs} +9 -13
  42. package/dist/{openai-chatgpt-responses-CgO6kZfo.mjs → openai-chatgpt-responses-DWID3EFO.mjs} +73 -29
  43. package/dist/{openai-completions-yJuk7eis.mjs → openai-completions-DJ1Vm-CD.mjs} +11 -12
  44. package/dist/{openai-prompt-cache-Bds-n_9Q.mjs → openai-completions-compat-CkwdxTZx.mjs} +5 -50
  45. package/dist/{openai-completions-compat-eHgh5UPE.d.mts → openai-completions-compat-JE7gqxb9.d.mts} +4 -4
  46. package/dist/{openai-completions-stream-Da2vvl-S.mjs → openai-completions-stream-Bu98b0Hv.mjs} +94 -96
  47. package/dist/openai-prompt-cache-1wfaIszn.mjs +46 -0
  48. package/dist/{openai-prompt-cache-B4eYo2-I.d.mts → openai-prompt-cache-CJ_xEevu.d.mts} +2 -2
  49. package/dist/{openai-provider-client-S2gCrM2Z.mjs → openai-provider-client-DPo0Hmak.mjs} +2 -2
  50. package/dist/openai-reasoning-effort-NlFZmfEu.mjs +235 -0
  51. package/dist/{openai-responses-DaYwH05E.mjs → openai-responses-BejZzQCP.mjs} +8 -12
  52. package/dist/{openai-responses-compaction-window-CIhBAkkq.mjs → openai-responses-compaction-window-D6P5oZP5.mjs} +20 -62
  53. package/dist/openai-responses-contracts-DWrfMODE.mjs +81 -0
  54. package/dist/{openai-responses-contracts-BjBAqAg_.d.mts → openai-responses-contracts-Dflvrfa8.d.mts} +9 -5
  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-B8RdBPCv.mjs → openai-responses-shared-CwsziD_m.mjs} +385 -178
  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-9aPuV5YY.mjs → openai-transport-params-DQeuAvBl.mjs} +157 -47
  61. package/dist/{positive-integer-41zhOdcV.mjs → positive-integer-DtjCkbue.mjs} +1 -1
  62. package/dist/{provider-error-BA-v_tKd.mjs → provider-error-DDqw9Qda.mjs} +100 -38
  63. package/dist/{provider-options-Ceqv1OKk.d.mts → provider-options-DprLsWh9.d.mts} +9 -6
  64. package/dist/{provider-replay-context-CJ_YvcEW.mjs → provider-replay-context-CnUSOwhr.mjs} +1 -1
  65. package/dist/{provider-transcript-transform-V5YzU9zh.mjs → provider-transcript-transform-BsRAhuWJ.mjs} +1 -1
  66. package/dist/{provider-transport-turn-state-D5EXOFL2.mjs → provider-transport-turn-state-CkGToCD2.mjs} +1 -1
  67. package/dist/{provider-types-CVjKjsuq.d.mts → provider-types-CAKRC7N5.d.mts} +3 -3
  68. package/dist/provider-types.d.mts +5 -6
  69. package/dist/providers.d.mts +2 -2
  70. package/dist/providers.mjs +10 -10
  71. package/dist/{reasoning-tag-text-partitioner-BcR5pztD.mjs → reasoning-tag-text-partitioner-Dy9IO8Dc.mjs} +15 -7
  72. package/dist/{simple-options-BQbb4yQL.mjs → simple-options-C6cFWj_f.mjs} +5 -3
  73. package/dist/{usage-cost-BNWbbXav.mjs → src-DeKjbE8I.mjs} +3 -5
  74. package/dist/{stream-first-event-timeout-2hfrquuz.mjs → stream-first-event-timeout-C9ZadkJW.mjs} +1 -1
  75. package/dist/{string-normalization-CmLIasuf.mjs → string-normalization-J9ZiLfGO.mjs} +13 -1
  76. package/dist/tool-schema-json-projection-CD9c_fK8.mjs +134 -0
  77. package/dist/{transport-stream-shared-DNvmoWnv.d.mts → transport-stream-shared-BbUkFaHi.d.mts} +4 -4
  78. package/dist/{transport-stream-shared-zHll9BxO.mjs → transport-stream-shared-D-6FQSHm.mjs} +14 -14
  79. package/dist/{transport-utils-zrYjICLZ.mjs → transport-utils-1cyq5Y7x.mjs} +3 -3
  80. package/dist/transports.d.mts +26 -12
  81. package/dist/transports.mjs +130 -449
  82. package/dist/{types-Ntv5z2g2.d.mts → types-4_uVs5WH.d.mts} +47 -3
  83. package/dist/types-DkJfb4W3.d.mts +1 -0
  84. package/dist/types.d.mts +5 -6
  85. package/dist/types.mjs +2 -3
  86. package/dist/{validation-B0t_G2H6.d.mts → validation-Ctzu2DhF.d.mts} +1 -1
  87. package/dist/{validation-BDzVDnTs.mjs → validation-Dw7cb6BV.mjs} +1 -0
  88. package/dist/validation.d.mts +1 -1
  89. package/dist/validation.mjs +1 -1
  90. package/package.json +10 -5
  91. package/dist/diagnostics-DnPnOui6.d.mts +0 -29
  92. package/dist/event-stream-C3WGFsum.d.mts +0 -1
  93. package/dist/openai-responses-contracts-DDOHA62Y.mjs +0 -245
  94. package/dist/openai-responses-prompt-observer-internal-f8J7wpsk.mjs +0 -32
  95. package/dist/src-DDmEryvj.mjs +0 -2
  96. package/dist/tool-schema-json-projection-ClptDdAO.mjs +0 -82
  97. package/dist/types-DlfwzH3T.d.mts +0 -1
@@ -1,26 +1,27 @@
1
1
  import { r as appendAssistantThinking } from "./event-stream-D8PARQfL.mjs";
2
- import { _ as isImageWithMediaPayload, d as describeToolResultMediaPlaceholder, m as extractToolResultText, v as sanitizeSurrogates } from "./host-B8YfDGd4.mjs";
3
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";
4
6
  import { t as truncateUtf16Safe } from "./utf16-slice-CvGodqok.mjs";
5
- import { d as shouldOmitOllamaCompatResponseFormat, i as detectOpenAICompletionsCompat, r as resolveOpenAIPromptCacheParams, u as resolveOpenAICompletionsResponseFormat } from "./openai-prompt-cache-Bds-n_9Q.mjs";
6
- import { r as emitModelTransportDebug } from "./diagnostics-QuErwCIl.mjs";
7
- import { i as asNonNegativeFiniteNumber } from "./base64-D-su8YVo.mjs";
8
- import { c as supportsModelTools, r as estimateStringChars } from "./transport-utils-zrYjICLZ.mjs";
9
- import { n as uniqueStrings } from "./string-normalization-CmLIasuf.mjs";
10
- import { i as resolveProviderEndpoint, r as resolveOpenAIStrictToolSetting } from "./host-policy-Zcg_cNz8.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";
11
13
  import { t as resolveCacheRetention } from "./cache-retention-0x979a5V.mjs";
12
- import { f as splitSystemPromptCacheBoundary, h as stripSystemPromptRelocatableBoundary, m as stripSystemPromptCacheBoundary, p as splitSystemPromptRelocatableBoundary, v as sortPromptCacheToolsByName } from "./simple-options-BQbb4yQL.mjs";
13
- 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-9aPuV5YY.mjs";
14
- import { E as parseStreamingJson, c as finalizeTerminalToolCallArguments, w as createToolArgumentPreviewSchedule } from "./transport-stream-shared-zHll9BxO.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";
15
17
  import { a as tagUnresolvedTextAsCommentary, i as tagPendingCommentaryText, n as rememberPendingCommentaryTags, r as tagInterruptedTextPhases, t as clearPendingCommentaryText } from "./assistant-text-phase-C20rxWwP.mjs";
16
18
  import { t as notifyLlmRequestActivity } from "./llm-request-activity-BjtkplhG.mjs";
17
- import { a as withFirstStreamEventTimeout } from "./stream-first-event-timeout-2hfrquuz.mjs";
18
- import { t as transformProviderMessages } from "./provider-transcript-transform-V5YzU9zh.mjs";
19
- import { _ as isOpenAIGpt56Model, b as resolveOpenAIReasoningEffortForModel, g as isOpenAIGpt55Model, h as isOpenAIGpt54MiniModel } from "./openai-responses-contracts-DDOHA62Y.mjs";
20
- 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";
21
22
  import { isGoogleGemini3FlashModel, isGoogleGemini3ProModel } from "./internal/google-model-family.mjs";
22
23
  import { t as mapOpenAIStopReason } from "./openai-stop-reason-Drnn_6Qj.mjs";
23
- import { t as createReasoningTagTextPartitioner } from "./reasoning-tag-text-partitioner-BcR5pztD.mjs";
24
+ import { t as createReasoningTagTextPartitioner } from "./reasoning-tag-text-partitioner-Dy9IO8Dc.mjs";
24
25
  import { randomUUID } from "node:crypto";
25
26
  //#region packages/ai/src/transports/deepseek-dsml-grammar.ts
26
27
  const DEEPSEEK_DSML_MARKERS = [
@@ -640,12 +641,9 @@ function relocateNonBehavioralRegion(args) {
640
641
  }
641
642
  //#endregion
642
643
  //#region packages/ai/src/transports/openai-completions-direct-policy.ts
643
- function applyDirectCompletionsReasoningAndRouting(params, model, options, compat) {
644
- const reasoningEffortMap = resolveOpenAIReasoningEffortMap(model);
645
- const thinkingLevelMap = model.thinkingLevelMap;
646
- const offReasoningEffort = reasoningEffortMap.off ?? model.thinkingLevelMap?.off;
647
- const reasoningEffort = options?.reasoningEffort === void 0 ? offReasoningEffort ?? void 0 : reasoningEffortMap[options.reasoningEffort] ?? thinkingLevelMap?.[options.reasoningEffort] ?? options.reasoningEffort;
648
- 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;
649
647
  if (compat.thinkingFormat === "zai" && model.reasoning) params.thinking = reasoningEnabled ? {
650
648
  type: "enabled",
651
649
  clear_thinking: false
@@ -657,17 +655,11 @@ function applyDirectCompletionsReasoningAndRouting(params, model, options, compa
657
655
  };
658
656
  else if (compat.thinkingFormat === "deepseek" && model.reasoning) {
659
657
  params.thinking = { type: reasoningEnabled ? "enabled" : "disabled" };
660
- if (reasoningEnabled && compat.supportsReasoningEffort) params.reasoning_effort = reasoningEffort;
661
- } else if (compat.thinkingFormat === "openrouter" && model.reasoning) {
662
- if (reasoningEnabled) params.reasoning = { effort: reasoningEffort };
663
- else if (offReasoningEffort !== null) params.reasoning = { effort: offReasoningEffort ?? "none" };
658
+ if (reasoningEnabled && compat.supportsReasoningEffort && nativeEffort !== void 0) params.reasoning_effort = nativeEffort;
664
659
  } else if (compat.thinkingFormat === "together" && model.reasoning) {
665
660
  params.reasoning = { enabled: reasoningEnabled };
666
- if (reasoningEnabled && compat.supportsReasoningEffort) params.reasoning_effort = reasoningEffort;
667
- } else if (reasoningEnabled && model.reasoning && compat.supportsReasoningEffort) params.reasoning_effort = reasoningEffort;
668
- else if (model.reasoning && compat.supportsReasoningEffort) {
669
- if (typeof offReasoningEffort === "string") params.reasoning_effort = offReasoningEffort;
670
- }
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;
671
663
  if (compat.openRouterRouting) params.provider = compat.openRouterRouting;
672
664
  if (model.baseUrl.includes("ai-gateway.vercel.sh") && model.compat?.vercelGatewayRouting) {
673
665
  const routing = model.compat.vercelGatewayRouting;
@@ -838,7 +830,7 @@ function applyCompletionsReplay(outgoingMessages, context, model, compat) {
838
830
  //#endregion
839
831
  //#region packages/ai/src/transports/openai-completions-params.ts
840
832
  function isKnownOpenAICompletionsEndpoint(model) {
841
- if (!model.baseUrl.trim()) return true;
833
+ if (!model.baseUrl.trim() || isNativeOpenAIEndpoint(model)) return true;
842
834
  const endpointClass = resolveProviderEndpoint(model).endpointClass;
843
835
  if (endpointClass === "openai-public" || endpointClass === "azure-openai") return true;
844
836
  try {
@@ -847,9 +839,6 @@ function isKnownOpenAICompletionsEndpoint(model) {
847
839
  return false;
848
840
  }
849
841
  }
850
- function resolveOpenAICompletionsReasoningEffort(options) {
851
- return options?.reasoningEffort ?? options?.reasoning ?? "high";
852
- }
853
842
  function resolveOpenAICompletionsMaxTokens(model, options) {
854
843
  if (options?.maxTokens) return {
855
844
  maxTokens: options.maxTokens,
@@ -870,6 +859,7 @@ function resolveOpenAICompletionsModelMaxTokens(model) {
870
859
  }
871
860
  const OPENAI_COMPLETIONS_INPUT_TOKEN_SAFETY_MARGIN = 1.25;
872
861
  const OPENAI_COMPLETIONS_IMAGE_CHAR_ESTIMATE = 8e3;
862
+ const MIN_USEFUL_OUTPUT_TOKENS = 16;
873
863
  function estimateOpenAICompletionsInputTokens(payload) {
874
864
  let adjustedChars = 0;
875
865
  adjustedChars += estimateOpenAICompletionsMessagesChars(payload.messages);
@@ -930,9 +920,6 @@ function resolveOpenAICompletionsEffectiveContextTokens(model) {
930
920
  if (typeof contextTokens === "number" && Number.isFinite(contextTokens) && contextTokens > 0) return contextTokens;
931
921
  return typeof model.contextWindow === "number" && Number.isFinite(model.contextWindow) && model.contextWindow > 0 ? model.contextWindow : void 0;
932
922
  }
933
- function isQwenOpenAICompletionsThinkingFormat(format) {
934
- return format === "qwen" || format === "qwen-chat-template";
935
- }
936
923
  function setQwenChatTemplateThinking(params, enabled) {
937
924
  const existing = params.chat_template_kwargs;
938
925
  params.chat_template_kwargs = existing && typeof existing === "object" && !Array.isArray(existing) ? {
@@ -940,41 +927,51 @@ function setQwenChatTemplateThinking(params, enabled) {
940
927
  enable_thinking: enabled
941
928
  } : { enable_thinking: enabled };
942
929
  }
943
- function applyQwenOpenAICompletionsThinkingParams(params) {
944
- if (!params.modelReasoning || !isQwenOpenAICompletionsThinkingFormat(params.compatThinkingFormat)) return false;
945
- const enabled = isOpenAICompletionsThinkingEnabled(params.requestedEffort);
946
- if (params.compatThinkingFormat === "qwen-chat-template") setQwenChatTemplateThinking(params.payload, enabled);
947
- else params.payload.enable_thinking = enabled;
948
- return true;
949
- }
950
- function applyTogetherOpenAICompletionsThinkingParams(params) {
951
- if (!params.modelReasoning || params.compatThinkingFormat !== "together") return;
952
- 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
+ }
953
946
  }
954
947
  function convertTools(tools, compat, model, mode) {
955
- const projection = projectOpenAITools(tools);
956
- const strict = mode === "direct" ? compat.supportsStrictMode ? false : void 0 : resolveOpenAIStrictToolFlagWithDiagnostics(projection, resolveOpenAIStrictToolSetting(model, {
957
- transport: "stream",
958
- supportsStrictMode: compat?.supportsStrictMode
959
- }), {
960
- transport: "completions",
961
- model
962
- });
963
- return {
964
- projection,
965
- tools: sortPromptCacheToolsByName(projection.tools).map((tool) => {
966
- const functionTool = {
967
- name: tool.name,
968
- description: tool.description,
969
- parameters: mode === "direct" ? tool.parameters : normalizeOpenAIStrictToolParameters(tool.parameters, strict === true, model.compat)
970
- };
971
- if (strict !== void 0) functionTool.strict = strict;
972
- return {
973
- type: "function",
974
- function: functionTool
975
- };
976
- })
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
+ };
977
973
  };
974
+ return prepared ? withPreparedToolSchemaNormalization(prepared.schemas, convert) : convert();
978
975
  }
979
976
  function buildOpenAICompletionsParams(model, context, options) {
980
977
  return buildOpenAICompletionsRequest(model, context, options, { mode: "managed" });
@@ -1071,6 +1068,7 @@ function buildOpenAICompletionsRequest(model, context, options, policy) {
1071
1068
  if (clampedMaxTokens > remainingBudget) {
1072
1069
  clampedMaxTokens = remainingBudget;
1073
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}`);
1074
1072
  }
1075
1073
  }
1076
1074
  if (policy.mode === "direct" ? options?.maxTokens : clampedMaxTokens) {
@@ -1078,34 +1076,34 @@ function buildOpenAICompletionsRequest(model, context, options, policy) {
1078
1076
  else params.max_completion_tokens = clampedMaxTokens;
1079
1077
  }
1080
1078
  }
1081
- if (policy.mode === "direct") {
1082
- applyDirectCompletionsReasoningAndRouting(params, model, options, compat);
1083
- 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;
1084
1106
  }
1085
- const completionsReasoningEffort = resolveOpenAICompletionsReasoningEffort(options);
1086
- const resolvedCompletionsReasoningEffort = completionsReasoningEffort ? resolveOpenAIReasoningEffortForModel({
1087
- model,
1088
- effort: completionsReasoningEffort,
1089
- fallbackMap: managedCompat?.reasoningEffortMap
1090
- }) : void 0;
1091
- const omitChatCompletionsToolReasoningEffort = Array.isArray(params.tools) && params.tools.length > 0 && (isOpenAIGpt54MiniModel(model) || isOpenAIGpt55Model(model) && isKnownOpenAICompletionsEndpoint(model));
1092
- const disableChatCompletionsToolReasoning = Array.isArray(params.tools) && params.tools.length > 0 && isOpenAIGpt56Model(model) && isKnownOpenAICompletionsEndpoint(model);
1093
- const handledQwenThinkingFormat = applyQwenOpenAICompletionsThinkingParams({
1094
- compatThinkingFormat: compat.thinkingFormat,
1095
- modelReasoning: model.reasoning,
1096
- payload: params,
1097
- requestedEffort: completionsReasoningEffort
1098
- });
1099
- applyTogetherOpenAICompletionsThinkingParams({
1100
- compatThinkingFormat: compat.thinkingFormat,
1101
- modelReasoning: model.reasoning,
1102
- payload: params,
1103
- requestedEffort: completionsReasoningEffort
1104
- });
1105
- if (disableChatCompletionsToolReasoning) params.reasoning_effort = "none";
1106
- else if (compat.thinkingFormat === "openrouter" && model.reasoning && resolvedCompletionsReasoningEffort) params.reasoning = { effort: resolvedCompletionsReasoningEffort };
1107
- else if (resolvedCompletionsReasoningEffort && model.reasoning && compat.supportsReasoningEffort && !handledQwenThinkingFormat && !omitChatCompletionsToolReasoningEffort) params.reasoning_effort = resolvedCompletionsReasoningEffort;
1108
- if (compat.cacheControlFormat === "anthropic") applyCompletionsAnthropicCacheControl(params, cacheControl ?? null, cacheOptOutIndexes, markTools, !managedCompat?.requiresStringContent);
1109
1107
  return params;
1110
1108
  }
1111
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 { M as OpenAICompletionsCompat, O as Model, l as CacheRetention } from "./types-Ntv5z2g2.mjs";
2
- import "./types-DlfwzH3T.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-B8YfDGd4.mjs";
2
- import { T as resolveOpenAIClientBaseUrl } from "./openai-transport-params-9aPuV5YY.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
@@ -0,0 +1,235 @@
1
+ import { n as normalizeLowercaseStringOrEmpty } from "./string-coerce-fsri9iCu.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
64
+ //#region packages/ai/src/providers/openai-reasoning-effort.ts
65
+ /**
66
+ * OpenAI-compatible reasoning-effort normalization. Different GPT families
67
+ * expose different accepted effort enums, so callers map requested values here
68
+ * before constructing provider payloads.
69
+ */
70
+ const ENABLED_REASONING_EFFORTS = [
71
+ "minimal",
72
+ "low",
73
+ "medium",
74
+ "high",
75
+ "xhigh",
76
+ "max"
77
+ ];
78
+ const GPT_5_REASONING_EFFORTS = [
79
+ "minimal",
80
+ "low",
81
+ "medium",
82
+ "high"
83
+ ];
84
+ const GPT_51_REASONING_EFFORTS = [
85
+ "none",
86
+ "low",
87
+ "medium",
88
+ "high"
89
+ ];
90
+ const GPT_52_REASONING_EFFORTS = [
91
+ "none",
92
+ "low",
93
+ "medium",
94
+ "high",
95
+ "xhigh"
96
+ ];
97
+ const GPT_56_REASONING_EFFORTS = [
98
+ "none",
99
+ "low",
100
+ "medium",
101
+ "high",
102
+ "xhigh",
103
+ "max"
104
+ ];
105
+ const GPT_6_ASTRA_REASONING_EFFORTS = [
106
+ "low",
107
+ "medium",
108
+ "high",
109
+ "xhigh",
110
+ "max"
111
+ ];
112
+ const GPT_CODEX_REASONING_EFFORTS = [
113
+ "low",
114
+ "medium",
115
+ "high",
116
+ "xhigh"
117
+ ];
118
+ const GPT_PRO_REASONING_EFFORTS = [
119
+ "medium",
120
+ "high",
121
+ "xhigh"
122
+ ];
123
+ const GPT_5_PRO_REASONING_EFFORTS = ["high"];
124
+ const GPT_51_CODEX_MAX_REASONING_EFFORTS = [
125
+ "none",
126
+ "medium",
127
+ "high",
128
+ "xhigh"
129
+ ];
130
+ const GPT_51_CODEX_MINI_REASONING_EFFORTS = ["medium"];
131
+ const GENERIC_REASONING_EFFORTS = [
132
+ "low",
133
+ "medium",
134
+ "high"
135
+ ];
136
+ const CANONICAL_REASONING_EFFORTS = /* @__PURE__ */ new Set([
137
+ "none",
138
+ ...ENABLED_REASONING_EFFORTS,
139
+ "off"
140
+ ]);
141
+ function normalizeModelId(id) {
142
+ return normalizeLowercaseStringOrEmpty(id ?? "").replace(/-\d{4}-\d{2}-\d{2}$/u, "");
143
+ }
144
+ /** Return whether a model is the GPT-5.4 mini family. */
145
+ function isOpenAIGpt54MiniModel(model) {
146
+ const id = normalizeModelId(typeof model.id === "string" ? model.id : void 0);
147
+ return /^gpt-5\.4-mini(?:-|$)/u.test(id);
148
+ }
149
+ /** Return whether a model is the GPT-5.5 family. */
150
+ function isOpenAIGpt55Model(model) {
151
+ const id = normalizeModelId(typeof model.id === "string" ? model.id : void 0);
152
+ const name = normalizeModelId(typeof model.name === "string" ? model.name : void 0);
153
+ return /^gpt-5\.5(?:-|$)/u.test(id) || /^gpt-5\.5(?:\s|\(|-|$)/u.test(name);
154
+ }
155
+ /** Return whether a model is the GPT-5.6 family. */
156
+ function isOpenAIGpt56Model(model) {
157
+ const id = normalizeModelId(typeof model.id === "string" ? model.id : void 0);
158
+ const name = normalizeModelId(typeof model.name === "string" ? model.name : void 0);
159
+ return /^gpt-5\.6(?:-|$)/u.test(id) || /^gpt-5\.6(?:\s|\(|-|$)/u.test(name);
160
+ }
161
+ /** Normalize user-facing reasoning effort names to API effort names. */
162
+ function normalizeOpenAIReasoningEffort(effort) {
163
+ const trimmed = effort.trim();
164
+ const folded = trimmed.toLowerCase();
165
+ return CANONICAL_REASONING_EFFORTS.has(folded) ? folded : trimmed;
166
+ }
167
+ function readCompatReasoningEfforts(compat) {
168
+ if (!compat || typeof compat !== "object") return;
169
+ if (compat.supportsReasoningEffort === false) return [];
170
+ const raw = compat.supportedReasoningEfforts;
171
+ if (!Array.isArray(raw)) return;
172
+ return normalizeUniqueTrimmedStringList(raw);
173
+ }
174
+ function isDisabledReasoningEffort(effort) {
175
+ return effort === "none" || effort === "off";
176
+ }
177
+ /** Resolve the reasoning efforts accepted by a specific OpenAI-compatible model. */
178
+ function resolveOpenAISupportedReasoningEfforts(model) {
179
+ return resolveOpenAIModelReasoningEfforts(model) ?? GENERIC_REASONING_EFFORTS;
180
+ }
181
+ /** Read a declared or known model contract, leaving unknown compatible models unspecified. */
182
+ function resolveOpenAIModelReasoningEfforts(model) {
183
+ const compatEfforts = readCompatReasoningEfforts(model.compat);
184
+ if (compatEfforts) return compatEfforts;
185
+ const id = normalizeModelId(typeof model.id === "string" ? model.id : void 0);
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;
190
+ if (id === "gpt-5.1-codex-mini") return GPT_51_CODEX_MINI_REASONING_EFFORTS;
191
+ if (id === "gpt-5.1-codex-max") return GPT_51_CODEX_MAX_REASONING_EFFORTS;
192
+ if (/^gpt-5(?:\.\d+)?-codex(?:-|$)/u.test(id)) return GPT_CODEX_REASONING_EFFORTS;
193
+ if (id === "gpt-5-pro") return GPT_5_PRO_REASONING_EFFORTS;
194
+ if (/^gpt-5\.[2-9](?:\.\d+)?-pro(?:-|$)/u.test(id)) return GPT_PRO_REASONING_EFFORTS;
195
+ if (/^gpt-5\.[2-9](?:\.\d+)?(?:-|$)/u.test(id)) return GPT_52_REASONING_EFFORTS;
196
+ if (/^gpt-5\.1(?:-|$)/u.test(id)) return GPT_51_REASONING_EFFORTS;
197
+ if (/^gpt-5(?:-|$)/u.test(id)) return GPT_5_REASONING_EFFORTS;
198
+ }
199
+ /**
200
+ * Return whether a model accepts temperature. GPT-5.6 and GPT-6 Astra
201
+ * reject it with a 400; catalog compat can override per model.
202
+ */
203
+ function supportsOpenAITemperature(model) {
204
+ const compat = model.compat;
205
+ if (compat && typeof compat === "object") {
206
+ const declared = compat.supportsTemperature;
207
+ if (typeof declared === "boolean") return declared;
208
+ }
209
+ const id = normalizeModelId(typeof model.id === "string" ? model.id : void 0);
210
+ return (id !== "gpt-6-astra" || resolveOpenAIThinkingApi(model.api) === "azure-openai-responses") && !/^gpt-5\.6(?:-|$)/u.test(id);
211
+ }
212
+ /** Return whether a model accepts a requested reasoning effort. */
213
+ function supportsOpenAIReasoningEffort(model, effort) {
214
+ return resolveOpenAISupportedReasoningEfforts(model).includes(normalizeOpenAIReasoningEffort(effort));
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
+ }
221
+ /** Resolve a requested reasoning effort to the closest value supported by the model. */
222
+ function resolveOpenAIReasoningEffortForModel(params) {
223
+ const requested = normalizeOpenAIReasoningEffort(params.effort);
224
+ const mapped = resolveOpenAIReasoningEffortMapping(requested, params.fallbackMap);
225
+ const normalized = mapped === void 0 ? requested : mapped.trim();
226
+ const supported = resolveOpenAISupportedReasoningEfforts(params.model);
227
+ if (supported.includes(normalized)) return normalized;
228
+ if (requested === "off" && supported.includes("none")) return "none";
229
+ if (isDisabledReasoningEffort(requested) || isDisabledReasoningEffort(normalized)) return;
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)));
233
+ }
234
+ //#endregion
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-Bds-n_9Q.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-BQbb4yQL.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 { C as supportsOpenAITemperature } from "./openai-responses-contracts-DDOHA62Y.mjs";
8
- import { n as resolveProviderSimpleCompletionHeaders } from "./provider-transport-turn-state-D5EXOFL2.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-B8RdBPCv.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-S2gCrM2Z.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);
@@ -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;