@openclaw/ai 2026.9.2 → 2026.9.4

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 (115) hide show
  1. package/README.md +3 -2
  2. package/dist/anthropic-C4Qu4H0Z.mjs +377 -0
  3. package/dist/{anthropic-payload-policy-d46X2pR0.d.mts → anthropic-payload-policy-BZ8umAbk.d.mts} +16 -6
  4. package/dist/{anthropic-compaction-replay-DB2FGLQc.mjs → anthropic-stream-reducer-CILWF7JD.mjs} +931 -184
  5. package/dist/{api-registry-DWtPjzyn.d.mts → api-registry-ByUwIR0e.d.mts} +2 -2
  6. package/dist/assistant-output-tLt4H-iQ.mjs +16 -0
  7. package/dist/assistant-text-phase-C20rxWwP.mjs +55 -0
  8. package/dist/{azure-openai-responses-C5bZRfAP.mjs → azure-openai-responses-BAlqlKKc.mjs} +5 -5
  9. package/dist/{base64-CEFBpSkN.mjs → base64-D-su8YVo.mjs} +1 -27
  10. package/dist/{diagnostics-DfFyKeX_.mjs → diagnostics-QuErwCIl.mjs} +96 -21
  11. package/dist/diagnostics.d.mts +3 -1
  12. package/dist/diagnostics.mjs +3 -3
  13. package/dist/{event-stream-BhT5T1Ay.d.mts → event-stream-Bt5Y4Pav.d.mts} +11 -3
  14. package/dist/event-stream-C3WGFsum.d.mts +1 -0
  15. package/dist/{event-stream-BgDvQeum.mjs → event-stream-D8PARQfL.mjs} +45 -1
  16. package/dist/event-stream.d.mts +2 -2
  17. package/dist/event-stream.mjs +1 -1
  18. package/dist/{github-copilot-headers-NCJtz9i0.mjs → github-copilot-headers-B37TB3rB.mjs} +3 -10
  19. package/dist/github-copilot-request-facts-BTEBMeOv.mjs +16 -0
  20. package/dist/{google-4qeuE8iX.mjs → google-DPBAOaOW.mjs} +10 -10
  21. package/dist/google-messages-6JkpHrhJ.mjs +448 -0
  22. package/dist/google-shared-BvBeW9aq.mjs +185 -0
  23. package/dist/{google-vertex-O9BcnB6X.mjs → google-vertex-k-TMCAYD.mjs} +7 -6
  24. package/dist/{host-DjzGmdZ2.d.mts → host-4atIX-2V.d.mts} +5 -3
  25. package/dist/{host-CEvLw30U.mjs → host-B8YfDGd4.mjs} +181 -41
  26. package/dist/host-policy-Zcg_cNz8.mjs +37 -0
  27. package/dist/{index-FnHM2FcI.d.mts → index-DdD3qerf.d.mts} +4 -4
  28. package/dist/index.d.mts +7 -7
  29. package/dist/index.mjs +7 -6
  30. package/dist/internal/anthropic.d.mts +7 -7
  31. package/dist/internal/anthropic.mjs +4 -4
  32. package/dist/internal/google-model-family.d.mts +5 -0
  33. package/dist/internal/google-model-family.mjs +15 -0
  34. package/dist/internal/openai-responses-payload-policy.d.mts +3 -3
  35. package/dist/internal/openai-responses-payload-policy.mjs +3 -2
  36. package/dist/internal/openai.d.mts +8 -103
  37. package/dist/internal/openai.mjs +9 -10
  38. package/dist/internal/retry-after.d.mts +2 -4
  39. package/dist/internal/retry-after.mjs +57 -8
  40. package/dist/internal/runtime.d.mts +43 -7
  41. package/dist/internal/runtime.mjs +6 -7
  42. package/dist/internal/shared.d.mts +43 -3
  43. package/dist/internal/shared.mjs +5 -4
  44. package/dist/internal/tool-schema.d.mts +63 -0
  45. package/dist/internal/tool-schema.mjs +3 -0
  46. package/dist/{mistral-Tb6oalqH.mjs → mistral-CxUZ1jUb.mjs} +10 -37
  47. package/dist/model-transport-url-DKocrEsb.d.mts +28 -0
  48. package/dist/{openai-chatgpt-responses-yUXjPNfu.mjs → openai-chatgpt-responses-CgO6kZfo.mjs} +50 -41
  49. package/dist/{openai-completions-compat-CpjYUArk.d.mts → openai-completions-compat-eHgh5UPE.d.mts} +26 -4
  50. package/dist/{openai-completions-stream-BsrBe3Gg.mjs → openai-completions-stream-Da2vvl-S.mjs} +654 -453
  51. package/dist/openai-completions-yJuk7eis.mjs +187 -0
  52. package/dist/openai-prompt-cache-B4eYo2-I.d.mts +16 -0
  53. package/dist/openai-prompt-cache-Bds-n_9Q.mjs +220 -0
  54. package/dist/openai-provider-client-S2gCrM2Z.mjs +24 -0
  55. package/dist/{openai-responses-CCL41ALM.mjs → openai-responses-DaYwH05E.mjs} +14 -29
  56. package/dist/{openai-responses-compaction-window-BMVHFOtq.mjs → openai-responses-compaction-window-CIhBAkkq.mjs} +6 -246
  57. package/dist/{openai-responses-contracts-rF5DDRNS.d.mts → openai-responses-contracts-BjBAqAg_.d.mts} +5 -38
  58. package/dist/openai-responses-contracts-DDOHA62Y.mjs +245 -0
  59. package/dist/{openai-responses-prompt-observer-internal-D0bhBfgL.mjs → openai-responses-prompt-observer-internal-f8J7wpsk.mjs} +3 -3
  60. package/dist/{openai-responses-shared-Bmma_3Qc.mjs → openai-responses-shared-B8RdBPCv.mjs} +47 -118
  61. package/dist/openai-tool-projection-793cE3QX.d.mts +37 -0
  62. package/dist/{openai-tool-schema-_pTAJqKF.mjs → openai-tool-schema-CzjyYXun.mjs} +38 -556
  63. package/dist/openai-tool-schema-ynZBgqW-.d.mts +38 -0
  64. package/dist/openai-transport-params-9aPuV5YY.mjs +675 -0
  65. package/dist/positive-integer-41zhOdcV.mjs +8 -0
  66. package/dist/{provider-error-9TraxGvt.mjs → provider-error-BA-v_tKd.mjs} +70 -11
  67. package/dist/{provider-options-Bcc_p-TU.d.mts → provider-options-Ceqv1OKk.d.mts} +4 -39
  68. package/dist/{provider-replay-context-BuSUaAk5.mjs → provider-replay-context-CJ_YvcEW.mjs} +1 -1
  69. package/dist/{provider-transcript-transform-BaMbI1hr.mjs → provider-transcript-transform-V5YzU9zh.mjs} +1 -1
  70. package/dist/provider-transport-turn-state-D5EXOFL2.mjs +42 -0
  71. package/dist/provider-types-CVjKjsuq.d.mts +29 -0
  72. package/dist/provider-types.d.mts +6 -31
  73. package/dist/providers.d.mts +2 -2
  74. package/dist/providers.mjs +11 -11
  75. package/dist/{reasoning-tag-text-partitioner-DLCNXki6.mjs → reasoning-tag-text-partitioner-BcR5pztD.mjs} +19 -19
  76. package/dist/record-coerce-DwRYMj3t.mjs +32 -0
  77. package/dist/retry-after-CdCURCVg.d.mts +15 -0
  78. package/dist/session-affinity-Bcunsn4I.mjs +23 -0
  79. package/dist/{simple-options-BjHCCh4v.mjs → simple-options-BQbb4yQL.mjs} +24 -5
  80. package/dist/src-DDmEryvj.mjs +2 -0
  81. package/dist/{stream-first-event-timeout-DcNjoFQE.mjs → stream-first-event-timeout-2hfrquuz.mjs} +1 -1
  82. package/dist/string-coerce-fsri9iCu.mjs +34 -0
  83. package/dist/{string-normalization--fwJ4S2q.mjs → string-normalization-CmLIasuf.mjs} +1 -1
  84. package/dist/{tool-schema-json-projection-mJhXDcyz.mjs → tool-schema-json-projection-ClptDdAO.mjs} +2 -38
  85. package/dist/{transport-stream-shared-xnaqxmbP.d.mts → transport-stream-shared-DNvmoWnv.d.mts} +20 -36
  86. package/dist/{transport-stream-shared-CZqMhfIw.mjs → transport-stream-shared-zHll9BxO.mjs} +225 -13
  87. package/dist/transport-utils-zrYjICLZ.mjs +118 -0
  88. package/dist/transports.d.mts +137 -193
  89. package/dist/transports.mjs +204 -1334
  90. package/dist/types-DlfwzH3T.d.mts +1 -0
  91. package/dist/types-LFWwv0cF.mjs +8 -0
  92. package/dist/{types-CJ1-Ht7A.d.mts → types-Ntv5z2g2.d.mts} +74 -57
  93. package/dist/types.d.mts +6 -6
  94. package/dist/types.mjs +6 -5
  95. package/dist/{src-2qBGKg8O.mjs → usage-cost-BNWbbXav.mjs} +0 -1
  96. package/dist/utf16-slice-CvGodqok.mjs +29 -0
  97. package/dist/{validation-AKZBDGQd.d.mts → validation-B0t_G2H6.d.mts} +1 -1
  98. package/dist/{validation-CJZtym2g.mjs → validation-BDzVDnTs.mjs} +9 -1
  99. package/dist/validation.d.mts +1 -1
  100. package/dist/validation.mjs +1 -1
  101. package/package.json +13 -3
  102. package/dist/anthropic-BDdqdVLK.mjs +0 -886
  103. package/dist/event-stream-zctLx0yr.d.mts +0 -1
  104. package/dist/google-shared-CWeG8RIl.mjs +0 -636
  105. package/dist/google-thinking-level-C-V3tecN.mjs +0 -9
  106. package/dist/hash-CHgqbJmD.mjs +0 -16
  107. package/dist/json-parse-BuAJEbdW.mjs +0 -146
  108. package/dist/openai-completions-BIUV3RDT.mjs +0 -403
  109. package/dist/openai-prompt-cache-CGnVB74a.mjs +0 -21
  110. package/dist/openai-prompt-cache-CNoIfHYC.d.mts +0 -16
  111. package/dist/sanitize-unicode-D6xUvZaS.mjs +0 -83
  112. package/dist/transport-utils-7il795_9.mjs +0 -138
  113. package/dist/types-3Lnm-QSJ.d.mts +0 -1
  114. package/dist/types-BDdaOVi2.mjs +0 -6
  115. package/dist/utf16-slice-qz3nsy87.mjs +0 -84
@@ -1,62 +1,24 @@
1
- import { c as normalizeLowercaseStringOrEmpty, d as normalizeOptionalString, o as isRecord, t as truncateUtf16Safe } from "./utf16-slice-qz3nsy87.mjs";
2
- import { i as clampThinkingLevel, r as calculateCost } from "./sanitize-unicode-D6xUvZaS.mjs";
3
- import { a as describeToolResultMediaPlaceholder, c as extractToolResultText, d as isImageWithMediaPayload, n as getAiTransportHost } from "./host-CEvLw30U.mjs";
4
- import { i as stableStringify } from "./provider-error-9TraxGvt.mjs";
5
- import { r as asFiniteNumber } from "./base64-CEFBpSkN.mjs";
6
- import { d as stripSystemPromptCacheBoundary, m as sortPromptCacheToolsByName } from "./simple-options-BjHCCh4v.mjs";
7
- import { c as transformTransportMessages } from "./tool-schema-json-projection-mJhXDcyz.mjs";
8
- import { d as redactSensitiveText, p as sha256Hex, u as redactIdentifier } from "./transport-utils-7il795_9.mjs";
9
- import { _ as transportAbortError, c as finalizeTransportStream, g as sanitizeTransportPayloadText, h as sanitizeNonEmptyTransportPayloadText, m as parseTerminalToolCallArguments, o as failTransportStream, y as withProviderResponseHook } from "./transport-stream-shared-CZqMhfIw.mjs";
10
- import { r as parseStreamingJson, t as createToolArgumentPreviewSchedule } from "./json-parse-BuAJEbdW.mjs";
1
+ import { r as appendAssistantThinking } from "./event-stream-D8PARQfL.mjs";
2
+ import { a as normalizeOptionalString } from "./string-coerce-fsri9iCu.mjs";
3
+ import { M as clampThinkingLevel, _ as isImageWithMediaPayload, d as describeToolResultMediaPlaceholder, j as calculateCost, m as extractToolResultText, n as getAiTransportHost } from "./host-B8YfDGd4.mjs";
4
+ import { o as isRecord } from "./record-coerce-DwRYMj3t.mjs";
5
+ import { t as truncateUtf16Safe } from "./utf16-slice-CvGodqok.mjs";
6
+ import { i as stableStringify } from "./provider-error-BA-v_tKd.mjs";
7
+ import { a as resolveModelSseDebugMode, i as resolveModelPayloadDebugMode, r as emitModelTransportDebug } from "./diagnostics-QuErwCIl.mjs";
8
+ import { r as asFiniteNumber } from "./base64-D-su8YVo.mjs";
9
+ import { o as redactSensitiveText } from "./transport-utils-zrYjICLZ.mjs";
10
+ import { s as transformTransportMessages } from "./host-policy-Zcg_cNz8.mjs";
11
+ import { m as stripSystemPromptCacheBoundary, v as sortPromptCacheToolsByName } from "./simple-options-BQbb4yQL.mjs";
12
+ import { O as redactIdentifier, _ as createOpenAIProviderAcceptanceHook, b as log, f as projectOpenAITools, g as createModelStreamCooperativeScheduler, k as sha256Hex, u as resolveOpenAIStrictToolFlagWithDiagnostics } from "./openai-transport-params-9aPuV5YY.mjs";
13
+ import { E as parseStreamingJson, _ as sanitizeTransportPayloadText, b as withProviderResponseHook, g as sanitizeNonEmptyTransportPayloadText, h as parseTerminalToolCallArguments, k as shortHash, l as finalizeTransportStream, s as failTransportStream, t as IncompleteToolCallError, v as transportAbortError, w as createToolArgumentPreviewSchedule } from "./transport-stream-shared-zHll9BxO.mjs";
14
+ import { n as providerReplayContextMatches, t as buildProviderReplayContext } from "./provider-replay-context-CJ_YvcEW.mjs";
11
15
  import { t as notifyLlmRequestActivity } from "./llm-request-activity-BjtkplhG.mjs";
12
- import { t as shortHash } from "./hash-CHgqbJmD.mjs";
13
- import { n as providerReplayContextMatches, t as buildProviderReplayContext } from "./provider-replay-context-BuSUaAk5.mjs";
14
- import { C as createOpenAIProviderAcceptanceHook, E as log, S as createModelStreamCooperativeScheduler, a as resolveOpenAIProjectedToolsStrictToolFlag, r as normalizeOpenAIStrictToolParameters, t as findOpenAIStrictToolProjectionDiagnostics, v as projectOpenAITools } from "./openai-tool-schema-_pTAJqKF.mjs";
15
- import { a as withFirstStreamEventTimeout, i as getFirstStreamEventTimeoutMs, r as getFirstStreamEventTimeoutHandler, t as createFirstStreamEventAbortController } from "./stream-first-event-timeout-DcNjoFQE.mjs";
16
- import { t as transformProviderMessages } from "./provider-transcript-transform-BaMbI1hr.mjs";
17
- import { D as resolveOpenAIModelReasoningEfforts, O as resolveOpenAIReasoningEffortForModel, b as RESPONSE_FAILED_NO_DETAILS_MESSAGE, g as OPENAI_RESPONSES_RETAINED_COMPACTION_REPLAY_TYPE, h as OPENAI_RESPONSES_REASONING_REPLAY_META_KEY, j as supportsOpenAITemperature, m as OPENAI_RESPONSES_REASONING_REPLAY_BLOCK_META_KEY, n as isOpenAIResponsesCompactionOutput, p as OPENAI_RESPONSES_COMPACTION_REPLAY_TYPE, r as readOpenAIResponsesCompactionWindow } from "./openai-responses-compaction-window-BMVHFOtq.mjs";
16
+ import { a as withFirstStreamEventTimeout, i as getFirstStreamEventTimeoutMs, r as getFirstStreamEventTimeoutHandler, t as createFirstStreamEventAbortController } from "./stream-first-event-timeout-2hfrquuz.mjs";
17
+ import { t as transformProviderMessages } from "./provider-transcript-transform-V5YzU9zh.mjs";
18
+ import { C as supportsOpenAITemperature, a as OPENAI_RESPONSES_COMPACTION_REPLAY_TYPE, b as resolveOpenAIReasoningEffortForModel, c as OPENAI_RESPONSES_RETAINED_COMPACTION_REPLAY_TYPE, f as RESPONSE_FAILED_NO_DETAILS_MESSAGE, o as OPENAI_RESPONSES_REASONING_REPLAY_BLOCK_META_KEY, s as OPENAI_RESPONSES_REASONING_REPLAY_META_KEY, y as resolveOpenAIModelReasoningEfforts } from "./openai-responses-contracts-DDOHA62Y.mjs";
19
+ import { a as resolveOpenAIProjectedToolsStrictToolFlag, r as normalizeOpenAIStrictToolParameters } from "./openai-tool-schema-CzjyYXun.mjs";
20
+ import { n as isOpenAIResponsesCompactionOutput, r as readOpenAIResponsesCompactionWindow } from "./openai-responses-compaction-window-CIhBAkkq.mjs";
18
21
  import { createHash, randomUUID } from "node:crypto";
19
- //#region packages/ai/src/transports/model-transport-debug.ts
20
- /**
21
- * Environment-driven debug controls for model transport logging.
22
- *
23
- * Model adapters share these helpers so payload, SSE, and transport diagnostics
24
- * interpret OpenClaw debug environment variables consistently.
25
- */
26
- function isTruthyEnv(value) {
27
- const normalized = normalizeLowercaseStringOrEmpty(value);
28
- return normalized.length > 0 && normalized !== "0" && normalized !== "false" && normalized !== "off" && normalized !== "no";
29
- }
30
- /** Resolves model payload debug verbosity from `OPENCLAW_DEBUG_MODEL_PAYLOAD`. */
31
- function resolveModelPayloadDebugMode(env = process.env) {
32
- const normalized = normalizeLowercaseStringOrEmpty(env.OPENCLAW_DEBUG_MODEL_PAYLOAD);
33
- if (normalized === "tools" || normalized === "full-redacted") return normalized;
34
- if (normalized === "summary") return "summary";
35
- return "off";
36
- }
37
- /** Resolves SSE stream debug verbosity from `OPENCLAW_DEBUG_SSE`. */
38
- function resolveModelSseDebugMode(env = process.env) {
39
- const normalized = normalizeLowercaseStringOrEmpty(env.OPENCLAW_DEBUG_SSE);
40
- if (normalized === "peek") return "peek";
41
- if (normalized === "events" || isTruthyEnv(normalized)) return "events";
42
- return "off";
43
- }
44
- /** Returns whether any model transport debug channel is enabled. */
45
- function isModelTransportDebugEnabled(env = process.env) {
46
- return isTruthyEnv(env.OPENCLAW_DEBUG_MODEL_TRANSPORT) || resolveModelPayloadDebugMode(env) !== "off" || resolveModelSseDebugMode(env) !== "off" || isTruthyEnv(env.OPENCLAW_DEBUG_CODE_MODE);
47
- }
48
- function isModelFetchMetadataMessage(message) {
49
- return message.startsWith("[model-fetch]");
50
- }
51
- /** Emits model-fetch metadata at info level by default; other diagnostics require debug env. */
52
- function emitModelTransportDebug(log, message) {
53
- if (isModelFetchMetadataMessage(message) || isModelTransportDebugEnabled()) {
54
- log.info(message);
55
- return;
56
- }
57
- log.debug(message);
58
- }
59
- //#endregion
60
22
  //#region packages/ai/src/transports/openai-responses-replay.ts
61
23
  /** Resolves the assistant message id that can be replayed to OpenAI Responses. */
62
24
  function resolveReplayableResponsesMessageId(params) {
@@ -1422,7 +1384,7 @@ function resolveResponsesToolCallId(item, fallbackId) {
1422
1384
  return resolvedItemId ? `${generated}|${resolvedItemId}` : generated;
1423
1385
  }
1424
1386
  function resolveCompletedResponsesToolCall(item, streamed) {
1425
- if (item.status && item.status !== "completed") throw new Error("Responses stream completed with an incomplete terminal tool call");
1387
+ if (item.status && item.status !== "completed") throw new IncompleteToolCallError("Responses stream completed with an incomplete terminal tool call");
1426
1388
  const streamedName = streamed?.name?.trim() || void 0;
1427
1389
  const completedName = typeof item.name === "string" ? item.name.trim() || void 0 : void 0;
1428
1390
  if (streamedName && completedName && streamedName !== completedName) throw new Error(`Responses stream changed tool-call function name from ${streamedName} to ${completedName}`);
@@ -1736,7 +1698,7 @@ async function processResponsesStream(openaiStream, output, stream, model, optio
1736
1698
  for (const slot of outputSlots.values()) if (slot !== except && slot.type === "text") materializeDeferredTextSlot(slot);
1737
1699
  };
1738
1700
  const appendThinkingDelta = (slot, delta) => {
1739
- slot.block.thinking += delta;
1701
+ appendAssistantThinking(slot.block, delta);
1740
1702
  stream.push({
1741
1703
  type: "thinking_delta",
1742
1704
  contentIndex: slot.contentIndex,
@@ -2062,7 +2024,10 @@ async function processResponsesStream(openaiStream, output, stream, model, optio
2062
2024
  if (output.errorMessage) throw new Error(output.errorMessage);
2063
2025
  resolveCompletedResponsesToolCall(incompleteToolCall);
2064
2026
  }
2065
- if (event.type === "response.incomplete" && streamingToolCalls.hasActive()) throw new Error(output.errorMessage ?? "Responses stream completed with unresolved tool calls");
2027
+ if (event.type === "response.incomplete" && streamingToolCalls.hasActive()) {
2028
+ if (output.errorMessage) throw new Error(output.errorMessage);
2029
+ throw new IncompleteToolCallError("Responses stream completed with unresolved tool calls");
2030
+ }
2066
2031
  if (event.type === "response.completed" || output.stopReason === "length") {
2067
2032
  const items = event.response.output ?? [];
2068
2033
  const completeToolCall = event.type === "response.completed" ? prepareTerminalToolCalls(items) : void 0;
@@ -2088,26 +2053,26 @@ async function processResponsesStream(openaiStream, output, stream, model, optio
2088
2053
  }
2089
2054
  //#endregion
2090
2055
  //#region packages/ai/src/providers/openai-responses-tools.ts
2091
- const LOG_SUBSYSTEM = "llm/openai-responses";
2092
- const MAX_STRICT_TOOL_DOWNGRADE_DIAGNOSTIC_KEYS = 64;
2093
- const loggedStrictToolDowngradeDiagnosticKeys = /* @__PURE__ */ new Set();
2094
- /** Converts and returns the projection used to reconcile tool choices. */
2056
+ /** Projects direct provider descriptors before resolving their strict policy. */
2095
2057
  function convertResponsesToolPayload(tools, options) {
2096
- const projection = projectOpenAITools(tools);
2097
- const strict = resolveResponsesStrictToolFlag(projection, resolveResponsesStrictToolSetting(options), options?.model);
2098
- return {
2099
- projection,
2100
- tools: sortPromptCacheToolsByName(projection.tools).map((tool) => {
2101
- const result = {
2102
- type: "function",
2103
- name: tool.name,
2104
- description: tool.description,
2105
- parameters: normalizeOpenAIStrictToolParameters(tool.parameters, strict === true, options?.model?.compat)
2106
- };
2107
- if (strict !== void 0) result.strict = strict;
2108
- return result;
2109
- })
2110
- };
2058
+ return convertProjectedResponsesTools(projectOpenAITools(tools), resolveResponsesStrictToolSetting(options), options?.model);
2059
+ }
2060
+ /** Uses caller-prepared facts without rereading descriptors or resolving host policy again. */
2061
+ function convertProjectedResponsesTools(projection, strictSetting, model) {
2062
+ const strict = model ? resolveOpenAIStrictToolFlagWithDiagnostics(projection, strictSetting, {
2063
+ transport: "responses",
2064
+ model
2065
+ }) : resolveOpenAIProjectedToolsStrictToolFlag(projection, strictSetting);
2066
+ return sortPromptCacheToolsByName(projection.tools).map((tool) => {
2067
+ const result = {
2068
+ type: "function",
2069
+ name: tool.name,
2070
+ description: tool.description,
2071
+ parameters: normalizeOpenAIStrictToolParameters(tool.parameters, strict === true, model?.compat)
2072
+ };
2073
+ if (strict !== void 0) result.strict = strict;
2074
+ return result;
2075
+ });
2111
2076
  }
2112
2077
  function resolveResponsesStrictToolSetting(options) {
2113
2078
  if (options?.strict !== void 0) return options.strict;
@@ -2117,42 +2082,6 @@ function resolveResponsesStrictToolSetting(options) {
2117
2082
  });
2118
2083
  return false;
2119
2084
  }
2120
- function resolveResponsesStrictToolFlag(projection, strictSetting, model) {
2121
- const strict = resolveOpenAIProjectedToolsStrictToolFlag(projection, strictSetting);
2122
- if (strictSetting === true && strict === false && model) getAiTransportHost().logDebug(LOG_SUBSYSTEM, () => {
2123
- const diagnostics = findOpenAIStrictToolProjectionDiagnostics(projection);
2124
- if (!shouldLogStrictToolDowngradeDiagnostic(diagnostics, model)) return null;
2125
- const sample = diagnostics.slice(0, 5).map((entry) => ({
2126
- tool: entry.toolName ?? `tool[${entry.toolIndex}]`,
2127
- violations: entry.violations.slice(0, 8)
2128
- }));
2129
- return {
2130
- message: `OpenAI responses tool schema strict mode downgraded to strict=false for ${model.provider ?? "unknown"}/${model.id ?? "unknown"} because ${diagnostics.length} tool schema(s) are not strict-compatible`,
2131
- data: {
2132
- provider: model.provider,
2133
- model: model.id,
2134
- incompatibleToolCount: diagnostics.length,
2135
- sample
2136
- }
2137
- };
2138
- });
2139
- return strict;
2140
- }
2141
- function shouldLogStrictToolDowngradeDiagnostic(diagnostics, model) {
2142
- const key = createHash("sha256").update(JSON.stringify({
2143
- provider: model.provider,
2144
- model: model.id,
2145
- diagnostics: diagnostics.map((entry) => ({
2146
- toolIndex: entry.toolIndex,
2147
- toolName: entry.toolName ?? null,
2148
- violations: entry.violations
2149
- }))
2150
- })).digest("hex");
2151
- if (loggedStrictToolDowngradeDiagnosticKeys.has(key)) return false;
2152
- if (loggedStrictToolDowngradeDiagnosticKeys.size >= MAX_STRICT_TOOL_DOWNGRADE_DIAGNOSTIC_KEYS) loggedStrictToolDowngradeDiagnosticKeys.clear();
2153
- loggedStrictToolDowngradeDiagnosticKeys.add(key);
2154
- return true;
2155
- }
2156
2085
  //#endregion
2157
2086
  //#region packages/ai/src/providers/openai-responses-shared.ts
2158
2087
  function convertResponsesMessages(model, context, allowedToolCallProviders, options) {
@@ -2187,8 +2116,8 @@ function applyCommonResponsesParams(params, model, context, options, config) {
2187
2116
  if (options?.maxTokens) params.max_output_tokens = Math.max(options.maxTokens, 16);
2188
2117
  if (options?.temperature !== void 0 && supportsOpenAITemperature(model)) params.temperature = options.temperature;
2189
2118
  if (context.tools) {
2190
- const converted = convertResponsesToolPayload(context.tools, { model });
2191
- if (converted.tools.length > 0) params.tools = converted.tools;
2119
+ const tools = convertResponsesToolPayload(context.tools, { model });
2120
+ if (tools.length > 0) params.tools = tools;
2192
2121
  }
2193
2122
  if (!model.reasoning) return;
2194
2123
  const requestedEffort = options?.reasoningEffort ?? (options?.reasoningSummary ? "medium" : config?.setDefaultReasoningOff ?? true ? "off" : void 0);
@@ -2289,4 +2218,4 @@ async function runResponsesStreamLifecycle(params) {
2289
2218
  }
2290
2219
  }
2291
2220
  //#endregion
2292
- export { resolveModelPayloadDebugMode as $, OPENAI_RESPONSES_OUTPUT_TEXT_DELTA_EVENT_TYPE as A, resolveNextResponsesEncryptedContentAttempt as B, summarizeResponsesPayload as C, AZURE_RESPONSES_TEXT_CONTENT_PART_TYPE as D, readResponsesToolCallItemIdentity as E, resolveResponsesMessageSnapshotCollapse as F, responsesInputFingerprint as G, convertResponsesMessages$1 as H, commitResponsesEncryptedContentAttempt as I, captureOpenAIResponsesCompaction as J, CompactionReplayRefreshRequiredError as K, createResponsesStreamWithEncryptedContentRetry as L, isAzureResponsesTextDeltaEventType as M, isResponsesTextContentPartType as N, AZURE_RESPONSES_TEXT_DELTA_EVENT_TYPE as O, isResponsesTextDeltaEventType as P, emitModelTransportDebug as Q, isInvalidEncryptedContentError as R, summarizeResponsesFailedNoDetailsObservation as S, createResponsesToolCallTracker as T, createOpenAIResponsesAssistantOutput as U, buildResponsesInputMessage as V, recordResponsesInputReplay as W, suppressOpenAIResponsesCompaction as X, resolveNewestOpenAIResponsesCompactionReplay as Y, resolveReplayableResponsesMessageId as Z, normalizeResponsesFailedEvent as _, resolveResponsesReasoningEffort as a, stringifyRedactedPayload as b, convertResponsesToolPayload as c, readResponsesReasoningTokens as d, resolveModelSseDebugMode as et, resolveResponsesTerminalStopReason as f, logResponsesFailedNoDetails as g, buildResponsesFailedNoDetailsObservation as h, createResponsesAssistantOutput as i, isAzureResponsesTextDeltaEvent as j, OPENAI_RESPONSES_OUTPUT_TEXT_CONTENT_PART_TYPE as k, processResponsesStream as l, ResponsesStreamFailure as m, applyResponsesServiceTierPricing as n, resolveResponsesRequestReasoningEffort as o, observeResponsesStream as p, buildOpenAIResponsesReasoningReplayMetadata as q, convertResponsesMessages as r, runResponsesStreamLifecycle as s, applyCommonResponsesParams as t, mapResponsesTerminalUsage as u, safeDebugValue as v, summarizeResponsesTools as w, summarizeOpenAITransportError as x, stringifyRedactedEvent as y, resolveAzureOpenAIApiVersion as z };
2221
+ export { resolveResponsesMessageSnapshotCollapse as A, responsesInputFingerprint as B, AZURE_RESPONSES_TEXT_DELTA_EVENT_TYPE as C, isAzureResponsesTextDeltaEventType as D, isAzureResponsesTextDeltaEvent as E, resolveNextResponsesEncryptedContentAttempt as F, resolveNewestOpenAIResponsesCompactionReplay as G, buildOpenAIResponsesReasoningReplayMetadata as H, buildResponsesInputMessage as I, suppressOpenAIResponsesCompaction as K, convertResponsesMessages$1 as L, createResponsesStreamWithEncryptedContentRetry as M, isInvalidEncryptedContentError as N, isResponsesTextContentPartType as O, resolveAzureOpenAIApiVersion as P, createOpenAIResponsesAssistantOutput as R, AZURE_RESPONSES_TEXT_CONTENT_PART_TYPE as S, OPENAI_RESPONSES_OUTPUT_TEXT_DELTA_EVENT_TYPE as T, captureOpenAIResponsesCompaction as U, CompactionReplayRefreshRequiredError as V, isOpenAIResponsesReplayContext as W, safeDebugValue as _, resolveResponsesReasoningEffort as a, createResponsesToolCallTracker as b, convertProjectedResponsesTools as c, mapResponsesTerminalUsage as d, readResponsesReasoningTokens as f, logResponsesFailedNoDetails as g, ResponsesStreamFailure as h, createResponsesAssistantOutput as i, commitResponsesEncryptedContentAttempt as j, isResponsesTextDeltaEventType as k, convertResponsesToolPayload as l, observeResponsesStream as m, applyResponsesServiceTierPricing as n, resolveResponsesRequestReasoningEffort as o, resolveResponsesTerminalStopReason as p, resolveReplayableResponsesMessageId as q, convertResponsesMessages as r, runResponsesStreamLifecycle as s, applyCommonResponsesParams as t, processResponsesStream as u, summarizeOpenAITransportError as v, OPENAI_RESPONSES_OUTPUT_TEXT_CONTENT_PART_TYPE as w, readResponsesToolCallItemIdentity as x, summarizeResponsesPayload as y, recordResponsesInputReplay as z };
@@ -0,0 +1,37 @@
1
+ import OpenAI from "openai";
2
+ import { ResponseCreateParamsStreaming } from "openai/resources/responses/responses.js";
3
+ //#region packages/ai/src/providers/openai-tool-projection.d.ts
4
+ type OpenAIToolDescriptor = {
5
+ readonly name?: unknown;
6
+ readonly description?: unknown;
7
+ readonly parameters: unknown;
8
+ };
9
+ type OpenAIProjectedTool = {
10
+ readonly toolIndex: number;
11
+ readonly name: string;
12
+ readonly description?: string;
13
+ readonly parameters: Record<string, unknown>;
14
+ };
15
+ type OpenAIToolProjectionDiagnostic = {
16
+ readonly toolIndex: number;
17
+ readonly toolName?: string;
18
+ readonly violations: readonly string[];
19
+ };
20
+ type OpenAIToolProjection = {
21
+ readonly inputToolCount: number;
22
+ readonly tools: readonly OpenAIProjectedTool[];
23
+ readonly diagnostics: readonly OpenAIToolProjectionDiagnostic[];
24
+ };
25
+ type OpenAIResponsesToolChoice = ResponseCreateParamsStreaming["tool_choice"];
26
+ type OpenAICompletionsSdkToolChoice = OpenAI.Chat.Completions.ChatCompletionCreateParamsStreaming["tool_choice"];
27
+ type OpenAICompletionsToolChoice = Exclude<OpenAICompletionsSdkToolChoice, {
28
+ type: "custom";
29
+ }>;
30
+ /** Snapshots direct/custom tool descriptors before OpenAI payload construction. */
31
+ declare function projectOpenAITools(tools: readonly OpenAIToolDescriptor[]): OpenAIToolProjection;
32
+ /** Keeps Responses tool choices aligned with surviving function schemas. */
33
+ declare function reconcileOpenAIResponsesToolChoice(choice: OpenAIResponsesToolChoice, projection: OpenAIToolProjection): OpenAIResponsesToolChoice | undefined;
34
+ /** Keeps Chat Completions tool choices aligned with surviving function schemas. */
35
+ declare function reconcileOpenAICompletionsToolChoice(choice: OpenAICompletionsSdkToolChoice, projection: OpenAIToolProjection): OpenAICompletionsSdkToolChoice | undefined;
36
+ //#endregion
37
+ export { reconcileOpenAIResponsesToolChoice as a, reconcileOpenAICompletionsToolChoice as i, OpenAIToolProjection as n, projectOpenAITools as r, OpenAICompletionsToolChoice as t };