@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.
- package/README.md +1 -1
- package/dist/{anthropic-CZy5U0NY.mjs → anthropic-COtDvgtt.mjs} +16 -16
- package/dist/{anthropic-payload-policy-wuRCb6MH.d.mts → anthropic-payload-policy-5Erq1Nzy.d.mts} +3 -3
- package/dist/{anthropic-stream-reducer-B_yo_7pf.mjs → anthropic-stream-reducer-BvdYYWL8.mjs} +56 -47
- package/dist/{api-registry-CB1-1oQ2.d.mts → api-registry-Ba2Cv-ut.d.mts} +2 -2
- package/dist/{assistant-output-iqnlJCV2.mjs → assistant-output-BsEkB-vU.mjs} +1 -1
- package/dist/{azure-openai-responses-Crpa40QR.mjs → azure-openai-responses-YrgnD583.mjs} +6 -9
- package/dist/{base64-D-su8YVo.mjs → base64-BQOzsvUH.mjs} +4 -4
- package/dist/credential-redaction-BKv49aiv.d.mts +24 -0
- package/dist/{diagnostics-dV98PqIy.mjs → diagnostics-Dm4bisWG.mjs} +89 -2
- package/dist/diagnostics.d.mts +4 -23
- package/dist/diagnostics.mjs +3 -3
- package/dist/{event-stream-C1Z2piyk.d.mts → event-stream-CCoa-qSI.d.mts} +1 -1
- package/dist/event-stream-DmSCpi1T.d.mts +1 -0
- package/dist/event-stream.d.mts +2 -2
- package/dist/expect-lbe3Hgrh.mjs +8 -0
- package/dist/{google-BDPriaVe.mjs → google-BuhpRO9r.mjs} +7 -10
- package/dist/{google-messages-CVn9eFpF.mjs → google-messages-CyWnYlh0.mjs} +3 -4
- package/dist/{google-shared-BedY23XS.mjs → google-shared-BT5ZeNer.mjs} +13 -13
- package/dist/{google-vertex-DMz8XQCn.mjs → google-vertex-C7EplRvt.mjs} +5 -8
- package/dist/{host-CWuF-sS3.mjs → host-B4MeUNBc.mjs} +145 -12
- package/dist/{host-DK3wmS3e.d.mts → host-FZ1RA_qD.d.mts} +7 -3
- package/dist/{host-policy-CAopLRKA.mjs → host-policy-DUnXSx0I.mjs} +1 -1
- package/dist/{index-CQ6LTHw8.d.mts → index-DaF2QbwS.d.mts} +5 -10
- package/dist/index.d.mts +7 -8
- package/dist/index.mjs +5 -5
- package/dist/internal/anthropic.d.mts +6 -7
- package/dist/internal/anthropic.mjs +4 -4
- package/dist/internal/openai-completions-compat.d.mts +2 -0
- package/dist/internal/openai-completions-compat.mjs +2 -0
- package/dist/internal/openai-responses-payload-policy.d.mts +3 -3
- package/dist/internal/openai-responses-payload-policy.mjs +3 -2
- package/dist/internal/openai.d.mts +10 -53
- package/dist/internal/openai.mjs +11 -10
- package/dist/internal/runtime.d.mts +43 -10
- package/dist/internal/runtime.mjs +5 -11
- package/dist/internal/shared.d.mts +35 -5
- package/dist/internal/shared.mjs +4 -4
- package/dist/internal/tool-schema.d.mts +3 -3
- package/dist/internal/tool-schema.mjs +2 -2
- package/dist/{mistral--m-Jm6VZ.mjs → mistral-moA-mbwl.mjs} +9 -16
- package/dist/{openai-chatgpt-responses-nDZccFW-.mjs → openai-chatgpt-responses-DWID3EFO.mjs} +76 -33
- package/dist/{openai-completions-KuoZyx0d.mjs → openai-completions-DJ1Vm-CD.mjs} +12 -13
- package/dist/{openai-prompt-cache-BI0rkM-5.mjs → openai-completions-compat-CkwdxTZx.mjs} +5 -50
- package/dist/{openai-completions-compat-CXn3T1we.d.mts → openai-completions-compat-JE7gqxb9.d.mts} +4 -4
- package/dist/{openai-completions-stream-BQk3SkLD.mjs → openai-completions-stream-Bu98b0Hv.mjs} +128 -99
- package/dist/openai-prompt-cache-1wfaIszn.mjs +46 -0
- package/dist/{openai-prompt-cache-rrutvqxq.d.mts → openai-prompt-cache-CJ_xEevu.d.mts} +2 -2
- package/dist/{openai-provider-client-ha_WxTyj.mjs → openai-provider-client-DPo0Hmak.mjs} +2 -2
- package/dist/{openai-reasoning-effort-BK7FbcLT.mjs → openai-reasoning-effort-NlFZmfEu.mjs} +87 -19
- package/dist/{openai-responses-D99dOzKI.mjs → openai-responses-BejZzQCP.mjs} +9 -13
- package/dist/{openai-responses-compaction-window-D5jbzCi3.mjs → openai-responses-compaction-window-D6P5oZP5.mjs} +21 -140
- package/dist/openai-responses-contracts-DWrfMODE.mjs +81 -0
- package/dist/{openai-responses-contracts-B55afwRo.d.mts → openai-responses-contracts-Dflvrfa8.d.mts} +10 -39
- package/dist/{openai-responses-payload-policy-rLRPsSmB.d.mts → openai-responses-payload-policy-C7GsA1y0.d.mts} +5 -3
- package/dist/openai-responses-prompt-observer-internal-C15_-OwV.mjs +195 -0
- package/dist/{openai-responses-shared-ZyQEzS5i.mjs → openai-responses-shared-CwsziD_m.mjs} +390 -183
- package/dist/openai-responses-terminal-usage-Dl3J6zrf.d.mts +47 -0
- package/dist/{openai-tool-schema-CzjyYXun.mjs → openai-tool-schema-BO8rwyAD.mjs} +92 -68
- package/dist/{openai-transport-params-DNasp2fU.mjs → openai-transport-params-DQeuAvBl.mjs} +162 -51
- package/dist/positive-integer-DtjCkbue.mjs +8 -0
- package/dist/{provider-error-C6TbKiey.mjs → provider-error-DDqw9Qda.mjs} +140 -36
- package/dist/{provider-options-BXr9Ec83.d.mts → provider-options-DprLsWh9.d.mts} +9 -6
- package/dist/{provider-replay-context-BuSUaAk5.mjs → provider-replay-context-CnUSOwhr.mjs} +1 -1
- package/dist/{provider-transcript-transform-pPmUIwKt.mjs → provider-transcript-transform-BsRAhuWJ.mjs} +1 -1
- package/dist/provider-transport-turn-state-CkGToCD2.mjs +42 -0
- package/dist/{provider-types-CAV0Og3m.d.mts → provider-types-CAKRC7N5.d.mts} +3 -3
- package/dist/provider-types.d.mts +6 -7
- package/dist/providers.d.mts +2 -2
- package/dist/providers.mjs +10 -10
- package/dist/{reasoning-tag-text-partitioner-BQBi4B9d.mjs → reasoning-tag-text-partitioner-Dy9IO8Dc.mjs} +15 -14
- package/dist/{session-affinity-CCH7eYdB.mjs → session-affinity-Bcunsn4I.mjs} +5 -2
- package/dist/{simple-options-tcKOqnpF.mjs → simple-options-C6cFWj_f.mjs} +26 -5
- package/dist/{src-B2Q_6G8V.mjs → src-DeKjbE8I.mjs} +3 -6
- package/dist/{stream-first-event-timeout-2hfrquuz.mjs → stream-first-event-timeout-C9ZadkJW.mjs} +1 -1
- package/dist/{string-normalization-CmLIasuf.mjs → string-normalization-J9ZiLfGO.mjs} +13 -1
- package/dist/tool-schema-json-projection-CD9c_fK8.mjs +134 -0
- package/dist/{transport-stream-shared-DOxpGJ-H.d.mts → transport-stream-shared-BbUkFaHi.d.mts} +20 -36
- package/dist/{transport-stream-shared-Cu3ZPhNW.mjs → transport-stream-shared-D-6FQSHm.mjs} +223 -11
- package/dist/{transport-utils-CCooe-cr.mjs → transport-utils-1cyq5Y7x.mjs} +4 -7
- package/dist/transports.d.mts +51 -165
- package/dist/transports.mjs +172 -507
- package/dist/{types-Dy1q0CSu.d.mts → types-4_uVs5WH.d.mts} +49 -3
- package/dist/types-DkJfb4W3.d.mts +1 -0
- package/dist/types-LFWwv0cF.mjs +8 -0
- package/dist/types.d.mts +6 -7
- package/dist/types.mjs +4 -4
- package/dist/{validation-CaFUZN9B.d.mts → validation-Ctzu2DhF.d.mts} +1 -1
- package/dist/{validation-BDzVDnTs.mjs → validation-Dw7cb6BV.mjs} +1 -0
- package/dist/validation.d.mts +1 -1
- package/dist/validation.mjs +1 -1
- package/package.json +10 -5
- package/dist/diagnostics-DnPnOui6.d.mts +0 -29
- package/dist/event-stream-I_GlBsuZ.d.mts +0 -1
- package/dist/hash-CHgqbJmD.mjs +0 -16
- package/dist/json-parse-Dw_hnxsA.mjs +0 -146
- package/dist/openai-responses-prompt-observer-internal-tApyTLVu.mjs +0 -32
- package/dist/sanitize-unicode-Bb-v9meu.mjs +0 -83
- package/dist/tool-schema-json-projection-ClptDdAO.mjs +0 -82
- package/dist/types-BADKjDBI.d.mts +0 -1
- package/dist/types-BDdaOVi2.mjs +0 -6
package/dist/transports.mjs
CHANGED
|
@@ -1,34 +1,34 @@
|
|
|
1
|
-
import { _ as supportsClaudeAdaptiveThinking, h as resolveClaudeSonnet5ModelIdentity, m as resolveClaudeOpus5ModelIdentity } from "./src-
|
|
1
|
+
import { _ as supportsClaudeAdaptiveThinking, h as resolveClaudeSonnet5ModelIdentity, m as resolveClaudeOpus5ModelIdentity } from "./src-DeKjbE8I.mjs";
|
|
2
2
|
import { n as normalizeLowercaseStringOrEmpty, t as hasNonEmptyString } from "./string-coerce-fsri9iCu.mjs";
|
|
3
|
-
import { S as usesClaudeStreamingRefusalContract, _ as prepareClaudeNoPrefillRequestContext, h as defaultsClaudeAdaptiveThinking, m as applyClaudeRequestContract, n as getAiTransportHost, p as ANTHROPIC_CLAUDE_CODE_VERSION, r as resolveAiTransportHeaderSentinels, v as requiresClaudeAdaptiveThinking, x as usesClaudeFable5MessagesContract, y as resolveAnthropicThinkingEffort } from "./host-CWuF-sS3.mjs";
|
|
4
3
|
import { o as isRecord } from "./record-coerce-DwRYMj3t.mjs";
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import { a as
|
|
8
|
-
import "./
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import { i as resolveProviderEndpoint,
|
|
12
|
-
import { B as logAnthropicContextEdits, C as applyAnthropicThinkingBindingControls, D as ANTHROPIC_SERVER_SIDE_FALLBACKS, F as applyAnthropicPayloadPolicyToParams, G as resolveAnthropicServerCompactionPlan, H as resolveAnthropicContextManagementBetaHeader, I as applyAnthropicRequestCacheControl, J as usesFoundryBearerAuth, K as isAnthropicOAuthApiKey, L as buildAnthropicSystemBlocks, N as applyAnthropicContextManagementToRequest, O as ANTHROPIC_SERVER_SIDE_FALLBACK_BETA, P as applyAnthropicEphemeralCacheControlMarkers, R as isAnthropicServerToolClearingEnabled, U as resolveAnthropicEphemeralCacheControl, V as resolveAnthropicCacheOptions, W as resolveAnthropicPayloadPolicy, d as convertAnthropicTools, f as buildAnthropicReplayPlan, g as normalizeAnthropicToolCallId, h as suppressAnthropicCompaction, l as buildAnthropicGenerationParams, m as resolveNewestAnthropicCompaction, p as isAnthropicReplayRejection, q as omitFoundryBearerCredentialHeaders, t as consumeAnthropicStream, u as convertAnthropicMessages, z as isDirectAnthropicModel } from "./anthropic-stream-reducer-
|
|
4
|
+
import { E as resolveAnthropicThinkingEffort, O as usesClaudeFable5MessagesContract, S as defaultsClaudeAdaptiveThinking, T as requiresClaudeAdaptiveThinking, b as ANTHROPIC_CLAUDE_CODE_VERSION, k as usesClaudeStreamingRefusalContract, n as getAiTransportHost, r as resolveAiTransportHeaderSentinels, w as prepareClaudeNoPrefillRequestContext, x as applyClaudeRequestContract } from "./host-B4MeUNBc.mjs";
|
|
5
|
+
import { t as truncateUtf16Safe } from "./utf16-slice-CvGodqok.mjs";
|
|
6
|
+
import { a as redactDiagnosticText, o as stableStringify } from "./provider-error-DDqw9Qda.mjs";
|
|
7
|
+
import { a as resolveModelSseDebugMode, i as resolveModelPayloadDebugMode, m as toErrorObject, n as formatModelTransportDebugUrl, r as emitModelTransportDebug, t as formatModelTransportDebugBaseUrl } from "./diagnostics-Dm4bisWG.mjs";
|
|
8
|
+
import { a as readResponseTextSnippet, i as isCodeModeModelVisibleToolName, n as createAbortError$1, s as resolveModelHeaderSentinels, t as MALFORMED_STREAMING_FRAGMENT_ERROR_MESSAGE } from "./transport-utils-1cyq5Y7x.mjs";
|
|
9
|
+
import { a as resolveOpenAIPromptCacheKeySupport, i as resolveOpenAICompletionsCompat, n as isNativeOpenAIEndpoint, o as usesNativeOpenAICodexResponsesBackend, r as isOpenAICodexResponsesModel, t as detectOpenAICompletionsCompat } from "./openai-completions-compat-CkwdxTZx.mjs";
|
|
10
|
+
import { i as resolveProviderEndpoint, s as transformTransportMessages, t as buildGuardedModelFetch } from "./host-policy-DUnXSx0I.mjs";
|
|
11
|
+
import { B as logAnthropicContextEdits, C as applyAnthropicThinkingBindingControls, D as ANTHROPIC_SERVER_SIDE_FALLBACKS, F as applyAnthropicPayloadPolicyToParams, G as resolveAnthropicServerCompactionPlan, H as resolveAnthropicContextManagementBetaHeader, I as applyAnthropicRequestCacheControl, J as usesFoundryBearerAuth, K as isAnthropicOAuthApiKey, L as buildAnthropicSystemBlocks, N as applyAnthropicContextManagementToRequest, O as ANTHROPIC_SERVER_SIDE_FALLBACK_BETA, P as applyAnthropicEphemeralCacheControlMarkers, R as isAnthropicServerToolClearingEnabled, U as resolveAnthropicEphemeralCacheControl, V as resolveAnthropicCacheOptions, W as resolveAnthropicPayloadPolicy, d as convertAnthropicTools, f as buildAnthropicReplayPlan, g as normalizeAnthropicToolCallId, h as suppressAnthropicCompaction, l as buildAnthropicGenerationParams, m as resolveNewestAnthropicCompaction, p as isAnthropicReplayRejection, q as omitFoundryBearerCredentialHeaders, t as consumeAnthropicStream, u as convertAnthropicMessages, z as isDirectAnthropicModel } from "./anthropic-stream-reducer-BvdYYWL8.mjs";
|
|
13
12
|
import { t as resolveCacheRetention } from "./cache-retention-0x979a5V.mjs";
|
|
14
|
-
import { a as codeModeToolSurfaceObserver,
|
|
15
|
-
import {
|
|
13
|
+
import { a as codeModeToolSurfaceObserver, o as reasoningTagTextPolicy, t as adjustMaxTokensForThinking, v as sortPromptCacheToolsByName } from "./simple-options-C6cFWj_f.mjs";
|
|
14
|
+
import { A as resolvePromptCacheKey, C as isOpenAICompletionsThinkingEnabled, D as readOpenAICompletionsContentDeltas, E as parseOpenAICompletionsUsage, M as redactIdentifier, N as sha256Hex, O as readOpenAICompletionsReasoningBatch, S as createResponseModelTracker, T as measureUtf8AppendBytes, _ as resolveOpenAIReasoningEffortMap, a as enforceCodeModeResponsesToolSurface, b as createOpenAIProviderAcceptanceHook, c as readCodeModePayloadToolName, i as buildOpenAISdkRequestOptions, j as throwIfModelStreamAborted, k as resolveOpenAIClientBaseUrl, l as resolveCodeModeResponsesVisibleToolNames, n as buildOpenAIClientHeaders, o as filterCodeModePayloadTools, r as buildOpenAISdkClientOptions, s as getCompat, t as assertCodeModeResponsesToolSurface, u as resolveOpenAIStrictToolFlagWithDiagnostics, v as GEMINI_THOUGHT_SIGNATURE_VALIDATOR_SKIP, w as log, x as createOpenAIResponseHook, y as createModelStreamCooperativeScheduler } from "./openai-transport-params-DQeuAvBl.mjs";
|
|
16
15
|
import { n as getEnvApiKey } from "./env-api-keys-bktO00EJ.mjs";
|
|
17
|
-
import {
|
|
16
|
+
import { C as quoteUnsafeIntegerLiterals, S as parseJsonPreservingUnsafeIntegers, _ as sanitizeTransportPayloadText, a as createEmptyTransportUsage, b as withProviderResponseHook, c as finalizeTerminalToolCallArguments, d as mergeTransportMetadata, f as notifyProviderHttpMetadata, g as sanitizeNonEmptyTransportPayloadText, h as parseTerminalToolCallArguments, i as copyProviderAcceptanceObserver, l as finalizeTransportStream, m as notifyProviderStreamOpened, n as assignTransportErrorDetails, o as createWritableTransportEventStream, p as notifyProviderHttpResponse, r as coerceTransportToolCallArguments, s as failTransportStream, t as IncompleteToolCallError, u as mergeTransportHeaders, v as transportAbortError, x as parseJsonObjectPreservingUnsafeIntegers, y as withProviderAcceptanceObserver } from "./transport-stream-shared-D-6FQSHm.mjs";
|
|
18
17
|
import { t as createDeferredEventBuffer } from "./deferred-event-buffer-DAvyP7qA.mjs";
|
|
19
|
-
import { n as providerReplayContextMatches, t as buildProviderReplayContext } from "./provider-replay-context-
|
|
18
|
+
import { n as providerReplayContextMatches, t as buildProviderReplayContext } from "./provider-replay-context-CnUSOwhr.mjs";
|
|
20
19
|
import { a as tagUnresolvedTextAsCommentary } from "./assistant-text-phase-C20rxWwP.mjs";
|
|
21
|
-
import { t as createAssistantOutput } from "./assistant-output-
|
|
22
|
-
import {
|
|
23
|
-
import { c as flattenCompletionMessagesToStringContent, d as canonicalizeMaxTokensParam, f as resolveMaxTokensParam, l as stripCompletionMessagesToRoleContent, n as shouldEmitOpenAICompletionsReasoning, o as isAzureOpenAICompatibleHost, p as createDeepSeekTextFilter, r as buildOpenAICompletionsParams, s as finalizeOpenAICompletionsToolCalls, t as processCompletionsStream, u as applyCompletionsAnthropicCacheControl } from "./openai-completions-stream-
|
|
24
|
-
import { a as googleFlashSupportsMinimalThinking, i as consumeGoogleGenerateContentStream, n as projectGoogleMessages, r as requiresGoogleToolCallId, t as convertGoogleTools } from "./google-messages-
|
|
25
|
-
import { i as getFirstStreamEventTimeoutMs, r as getFirstStreamEventTimeoutHandler, t as createFirstStreamEventAbortController } from "./stream-first-event-timeout-
|
|
26
|
-
import { i as
|
|
27
|
-
import {
|
|
28
|
-
import {
|
|
20
|
+
import { t as createAssistantOutput } from "./assistant-output-BsEkB-vU.mjs";
|
|
21
|
+
import { n as resolveOpencodeSessionHeaders } from "./session-affinity-Bcunsn4I.mjs";
|
|
22
|
+
import { c as flattenCompletionMessagesToStringContent, d as canonicalizeMaxTokensParam, f as resolveMaxTokensParam, l as stripCompletionMessagesToRoleContent, n as shouldEmitOpenAICompletionsReasoning, o as isAzureOpenAICompatibleHost, p as createDeepSeekTextFilter, r as buildOpenAICompletionsParams, s as finalizeOpenAICompletionsToolCalls, t as processCompletionsStream, u as applyCompletionsAnthropicCacheControl } from "./openai-completions-stream-Bu98b0Hv.mjs";
|
|
23
|
+
import { a as googleFlashSupportsMinimalThinking, i as consumeGoogleGenerateContentStream, n as projectGoogleMessages, r as requiresGoogleToolCallId, t as convertGoogleTools } from "./google-messages-CyWnYlh0.mjs";
|
|
24
|
+
import { i as getFirstStreamEventTimeoutMs, r as getFirstStreamEventTimeoutHandler, t as createFirstStreamEventAbortController } from "./stream-first-event-timeout-C9ZadkJW.mjs";
|
|
25
|
+
import { d as OpenAIResponsesWebSocketSafeRetryError, i as OPENAI_RESPONSES_APIS, l as OpenAIResponsesWebSocketPostDispatchError, m as parseOpenAIResponsesWebSocketServerError, t as AZURE_RESPONSES_FIRST_EVENT_TIMEOUT_MS, u as OpenAIResponsesWebSocketPreDispatchError } from "./openai-responses-contracts-DWrfMODE.mjs";
|
|
26
|
+
import { r as resolveProviderTransportTurnState, t as filterProviderTurnHeadersForExplicitOpencodeSession } from "./provider-transport-turn-state-CkGToCD2.mjs";
|
|
27
|
+
import { a as applyOpenAIResponsesPayloadPolicy, c as resolveOpenAIResponsesServerCompactionPlan, i as sanitizeResponsesImagePayload, n as isOpenAIResponsesCompactionOutput, o as resolveOpenAIResponsesCompactEndpointPlan, s as resolveOpenAIResponsesPayloadPolicy, t as createBoundedOpenAIResponsesCompactionFetch } from "./openai-responses-compaction-window-D6P5oZP5.mjs";
|
|
28
|
+
import { A as resolveNextResponsesEncryptedContentAttempt, B as responsesContinuationPrefixFingerprint, D as createResponsesStreamWithEncryptedContentRetry, F as createOpenAIResponsesAssistantOutput, G as CompactionReplayRefreshRequiredError, H as isConfigurationUpdate, I as recordResponsesInputReplay, J as isOpenAIResponsesReplayContext, K as buildOpenAIResponsesReasoningReplayMetadata, L as responsesInputFingerprint, M as resolveResponsesContextUsageBoundary, O as isInvalidEncryptedContentError, R as claimOpenAIResponsesHttpContinuation, U as replayResponsesReasoningUpdates, V as responsesContinuationRequestFingerprint, W as supportsResponsesReasoningUpdate, X as suppressOpenAIResponsesCompaction, Y as resolveNewestOpenAIResponsesCompactionReplay, Z as resolveReplayableResponsesMessageId, c as processResponsesStream, d as logResponsesFailedNoDetails, f as safeDebugValue, j as recordResponsesContextUsage, k as resolveAzureOpenAIApiVersion, l as observeResponsesStream, m as summarizeResponsesPayload, n as applyResponsesServiceTierPricing, p as summarizeOpenAITransportError, q as captureOpenAIResponsesCompaction, u as ResponsesStreamFailure, z as resolveResponsesContinuationRequest } from "./openai-responses-shared-CwsziD_m.mjs";
|
|
29
29
|
import { i as resolveAzureDeploymentNameFromMap, t as isOpenAICompatibleAzureResponsesBaseUrl } from "./azure-openai-responses-client-compat-C7K7QfUE.mjs";
|
|
30
30
|
import { n as registerSessionResourceCleanup } from "./session-resources-CkR4WWy1.mjs";
|
|
31
|
-
import { t as createResponsesPromptEgressObserver } from "./openai-responses-prompt-observer-internal-
|
|
31
|
+
import { a as sanitizeOpenAICodexResponsesParams, n as buildOpenAIResponsesCompactSystemMessage, r as buildOpenAIResponsesParams, t as createResponsesPromptEgressObserver } from "./openai-responses-prompt-observer-internal-C15_-OwV.mjs";
|
|
32
32
|
import { randomUUID } from "node:crypto";
|
|
33
33
|
import OpenAI, { AzureOpenAI } from "openai";
|
|
34
34
|
import { ResponsesWS } from "openai/resources/responses/ws.js";
|
|
@@ -117,7 +117,6 @@ function readAnthropicSseChunk(reader, signal) {
|
|
|
117
117
|
if (settled) return;
|
|
118
118
|
settled = true;
|
|
119
119
|
signal.removeEventListener("abort", onAbort);
|
|
120
|
-
reader.cancel(signal.reason).catch(() => void 0);
|
|
121
120
|
reject(createAbortError(signal));
|
|
122
121
|
};
|
|
123
122
|
if (signal.aborted) {
|
|
@@ -182,7 +181,11 @@ async function* parseAnthropicSseBody(body, signal) {
|
|
|
182
181
|
if (data && data !== "[DONE]") yield parseAnthropicSseEventData(data);
|
|
183
182
|
}
|
|
184
183
|
} finally {
|
|
185
|
-
if (!completed)
|
|
184
|
+
if (!completed) {
|
|
185
|
+
const cancellation = reader.cancel(signal?.reason).catch(() => void 0);
|
|
186
|
+
if (signal?.aborted) getAiTransportHost().observePendingProviderWork?.(cancellation);
|
|
187
|
+
else await cancellation;
|
|
188
|
+
}
|
|
186
189
|
reader.releaseLock();
|
|
187
190
|
}
|
|
188
191
|
}
|
|
@@ -208,19 +211,20 @@ function createAnthropicMessagesClient(params) {
|
|
|
208
211
|
};
|
|
209
212
|
} } };
|
|
210
213
|
}
|
|
211
|
-
function
|
|
212
|
-
const retryAfterSeconds = parseRetryAfterHeadersSeconds(response.headers);
|
|
213
|
-
const retryAfterSuffix = Number.isFinite(retryAfterSeconds) ? `; Retry-After: ${Math.ceil(retryAfterSeconds ?? 0)} seconds` : "";
|
|
214
|
-
return `HTTP ${response.status}: ${detail || "Anthropic Messages request failed"}${retryAfterSuffix}`;
|
|
215
|
-
}
|
|
216
|
-
async function readAnthropicMessagesErrorBodySnippet(response) {
|
|
214
|
+
async function readAnthropicMessagesErrorBody(response) {
|
|
217
215
|
try {
|
|
218
|
-
|
|
216
|
+
const text = await readResponseTextSnippet(response, {
|
|
219
217
|
maxBytes: ANTHROPIC_MESSAGES_ERROR_BODY_MAX_BYTES,
|
|
220
|
-
maxChars:
|
|
218
|
+
maxChars: ANTHROPIC_MESSAGES_ERROR_BODY_MAX_BYTES,
|
|
221
219
|
chunkTimeoutMs: ANTHROPIC_MESSAGES_ERROR_BODY_READ_IDLE_TIMEOUT_MS,
|
|
222
220
|
onIdleTimeout: ({ chunkTimeoutMs }) => /* @__PURE__ */ new Error(`Anthropic Messages error response stalled: no data received for ${chunkTimeoutMs}ms`)
|
|
223
221
|
}) ?? "";
|
|
222
|
+
try {
|
|
223
|
+
return JSON.parse(text);
|
|
224
|
+
} catch {
|
|
225
|
+
const redacted = redactDiagnosticText(text);
|
|
226
|
+
return redacted.length > ANTHROPIC_MESSAGES_ERROR_BODY_MAX_CHARS ? `${truncateUtf16Safe(redacted, ANTHROPIC_MESSAGES_ERROR_BODY_MAX_CHARS)}…` : redacted;
|
|
227
|
+
}
|
|
224
228
|
} catch (error) {
|
|
225
229
|
if (error instanceof Error && error.message.startsWith("Anthropic Messages error response stalled:")) return error.message;
|
|
226
230
|
return "";
|
|
@@ -248,7 +252,7 @@ function createAnthropicTransportClient(params) {
|
|
|
248
252
|
isOAuthToken: false
|
|
249
253
|
};
|
|
250
254
|
}
|
|
251
|
-
if (usesFoundryBearerAuth(resolveModelHeaderSentinels
|
|
255
|
+
if (usesFoundryBearerAuth(resolveModelHeaderSentinels(model))) {
|
|
252
256
|
const betaFeatures = needsInterleavedBeta ? ["interleaved-thinking-2025-05-14"] : [];
|
|
253
257
|
return {
|
|
254
258
|
client: createAnthropicMessagesClient({
|
|
@@ -318,11 +322,14 @@ async function buildAnthropicParams(model, context, isOAuthToken, options) {
|
|
|
318
322
|
authProfileId: options?.authProfileId,
|
|
319
323
|
sessionId: options?.sessionId
|
|
320
324
|
});
|
|
325
|
+
const cacheBreakpointOptOutMessageIndexes = /* @__PURE__ */ new Set();
|
|
321
326
|
const messages = await convertAnthropicMessages(transformTransportMessages(replayPlan.messages, model, normalizeAnthropicToolCallId), model, isOAuthToken, {
|
|
322
327
|
profile: "transport",
|
|
323
328
|
allowReasoningContentReplay: supportsReasoningContentReplay(model),
|
|
329
|
+
allowEmptySignature: model.compat?.allowEmptySignature,
|
|
324
330
|
compaction: replayPlan.compaction,
|
|
325
|
-
replayThinkingEnabled
|
|
331
|
+
replayThinkingEnabled,
|
|
332
|
+
cacheBreakpointOptOutMessageIndexes
|
|
326
333
|
});
|
|
327
334
|
const params = {
|
|
328
335
|
model: resolveAnthropicRequestModelId(model),
|
|
@@ -342,7 +349,7 @@ async function buildAnthropicParams(model, context, isOAuthToken, options) {
|
|
|
342
349
|
toolProjection,
|
|
343
350
|
profile: "transport"
|
|
344
351
|
}));
|
|
345
|
-
applyAnthropicRequestCacheControl(params, cacheControl, supportsCacheControlOnTools);
|
|
352
|
+
applyAnthropicRequestCacheControl(params, cacheControl, supportsCacheControlOnTools, cacheBreakpointOptOutMessageIndexes);
|
|
346
353
|
return {
|
|
347
354
|
params,
|
|
348
355
|
toolProjection,
|
|
@@ -388,7 +395,7 @@ function resolveAnthropicTransportOptions(model, options, apiKey) {
|
|
|
388
395
|
}
|
|
389
396
|
if (!reasoning) {
|
|
390
397
|
resolved.thinkingEnabled = defaultsClaudeAdaptiveThinking(model);
|
|
391
|
-
if (resolved.thinkingEnabled) resolved.effort =
|
|
398
|
+
if (resolved.thinkingEnabled) resolved.effort = resolveAnthropicThinkingEffort(model, reasoning);
|
|
392
399
|
return resolved;
|
|
393
400
|
}
|
|
394
401
|
if (supportsClaudeAdaptiveThinking(model)) {
|
|
@@ -427,13 +434,12 @@ function createAnthropicMessagesTransportStreamFn() {
|
|
|
427
434
|
const builtParams = await buildAnthropicParams(model, requestContext, isOAuthToken, transportOptions);
|
|
428
435
|
usedCompactionReplay = builtParams.usedCompactionReplay;
|
|
429
436
|
let params = builtParams.params;
|
|
430
|
-
const toolProjection = builtParams.toolProjection;
|
|
431
437
|
applyAnthropicContextManagementToRequest(params, model, transportOptions, directApiKeyBetaHeader);
|
|
432
438
|
const nextParams = await transportOptions.onPayload?.(params, model);
|
|
433
439
|
if (nextParams !== void 0) params = nextParams;
|
|
434
440
|
applyClaudeRequestContract(params, model);
|
|
435
441
|
const betaHeader = resolveAnthropicContextManagementBetaHeader(params, directApiKeyBetaHeader);
|
|
436
|
-
const bindingHeaders = applyAnthropicThinkingBindingControls(params, betaHeader) ?? (betaHeader
|
|
442
|
+
const bindingHeaders = applyAnthropicThinkingBindingControls(params, betaHeader) ?? (betaHeader ? { "anthropic-beta": betaHeader } : void 0);
|
|
437
443
|
const { response, stream: anthropicStream } = await client.messages.stream({
|
|
438
444
|
...params,
|
|
439
445
|
stream: true
|
|
@@ -447,8 +453,12 @@ function createAnthropicMessagesTransportStreamFn() {
|
|
|
447
453
|
model
|
|
448
454
|
});
|
|
449
455
|
if (!response.ok) {
|
|
450
|
-
const
|
|
451
|
-
throw new Error(
|
|
456
|
+
const errorBody = await readAnthropicMessagesErrorBody(response);
|
|
457
|
+
throw Object.assign(/* @__PURE__ */ new Error(`${response.status} status code (no body)`), {
|
|
458
|
+
status: response.status,
|
|
459
|
+
headers: response.headers,
|
|
460
|
+
errorBody
|
|
461
|
+
});
|
|
452
462
|
}
|
|
453
463
|
await consumeAnthropicStream({
|
|
454
464
|
events: anthropicStream,
|
|
@@ -458,7 +468,7 @@ function createAnthropicMessagesTransportStreamFn() {
|
|
|
458
468
|
stream,
|
|
459
469
|
refusalBuffer,
|
|
460
470
|
isOAuthToken,
|
|
461
|
-
toolProjection,
|
|
471
|
+
toolProjection: builtParams.toolProjection,
|
|
462
472
|
profile: "transport"
|
|
463
473
|
});
|
|
464
474
|
finalizeTransportStream({
|
|
@@ -476,7 +486,7 @@ function createAnthropicMessagesTransportStreamFn() {
|
|
|
476
486
|
refusalBuffer.discard();
|
|
477
487
|
output.content = [];
|
|
478
488
|
} else output.content = output.content.filter((block) => block.type !== "toolCall");
|
|
479
|
-
if (usedCompactionReplay && isAnthropicReplayRejection(
|
|
489
|
+
if (usedCompactionReplay && isAnthropicReplayRejection(output)) suppressAnthropicCompaction(output, model, options);
|
|
480
490
|
for (const block of output.content) delete block.index;
|
|
481
491
|
}
|
|
482
492
|
});
|
|
@@ -562,8 +572,8 @@ function createSseDoneDetector() {
|
|
|
562
572
|
sawDone: () => sawDone
|
|
563
573
|
};
|
|
564
574
|
}
|
|
565
|
-
function createOpenAICompletionsClient(model,
|
|
566
|
-
const clientConfig = buildOpenAICompletionsClientConfig(model,
|
|
575
|
+
function createOpenAICompletionsClient(model, apiKey, headers, opts) {
|
|
576
|
+
const clientConfig = buildOpenAICompletionsClientConfig(model, headers);
|
|
567
577
|
return new OpenAI({
|
|
568
578
|
apiKey,
|
|
569
579
|
baseURL: clientConfig.baseURL,
|
|
@@ -574,8 +584,7 @@ function createOpenAICompletionsClient(model, context, apiKey, optionHeaders, op
|
|
|
574
584
|
...buildOpenAISdkClientOptions(model)
|
|
575
585
|
});
|
|
576
586
|
}
|
|
577
|
-
function buildOpenAICompletionsClientConfig(model,
|
|
578
|
-
const headers = buildOpenAIClientHeaders(model, context, optionHeaders);
|
|
587
|
+
function buildOpenAICompletionsClientConfig(model, headers) {
|
|
579
588
|
const defaultQuery = {};
|
|
580
589
|
let baseURL = model.baseUrl;
|
|
581
590
|
let isAzureHost = false;
|
|
@@ -632,6 +641,14 @@ function createOpenAICompletionsTransportStreamFn() {
|
|
|
632
641
|
let firstEventAbort;
|
|
633
642
|
try {
|
|
634
643
|
const apiKey = options?.apiKey || getEnvApiKey(model.provider) || "";
|
|
644
|
+
const turnState = resolveProviderTransportTurnState(model, {
|
|
645
|
+
sessionId: options?.sessionId,
|
|
646
|
+
turnId: randomUUID(),
|
|
647
|
+
attempt: 1,
|
|
648
|
+
transport: "stream"
|
|
649
|
+
});
|
|
650
|
+
const optionHeaders = resolveOpencodeSessionHeaders(model, options);
|
|
651
|
+
const turnHeaders = filterProviderTurnHeadersForExplicitOpencodeSession(model, options, turnState?.headers);
|
|
635
652
|
const doneDetector = createSseDoneDetector();
|
|
636
653
|
const baseFetch = buildGuardedModelFetch(model);
|
|
637
654
|
const doneDetectingFetch = async (url, init) => {
|
|
@@ -653,7 +670,11 @@ function createOpenAICompletionsTransportStreamFn() {
|
|
|
653
670
|
statusText: response.statusText
|
|
654
671
|
});
|
|
655
672
|
};
|
|
656
|
-
const
|
|
673
|
+
const cacheRetention = resolveCacheRetention(options?.cacheRetention);
|
|
674
|
+
const client = createOpenAICompletionsClient(model, apiKey, buildOpenAIClientHeaders(model, context, {
|
|
675
|
+
...turnHeaders,
|
|
676
|
+
...optionHeaders
|
|
677
|
+
}, void 0, resolvePromptCacheKey(options, cacheRetention), cacheRetention), { fetch: doneDetectingFetch });
|
|
657
678
|
let params = buildOpenAICompletionsParams(model, context, options);
|
|
658
679
|
const nextParams = await options?.onPayload?.(params, model);
|
|
659
680
|
if (nextParams !== void 0) params = nextParams;
|
|
@@ -710,374 +731,6 @@ function createOpenAICompletionsTransportStreamFn() {
|
|
|
710
731
|
};
|
|
711
732
|
}
|
|
712
733
|
//#endregion
|
|
713
|
-
//#region packages/ai/src/transports/openai-responses-params-internal.ts
|
|
714
|
-
const OPENAI_RESPONSES_TOOL_CALL_PROVIDERS = /* @__PURE__ */ new Set([
|
|
715
|
-
"openai",
|
|
716
|
-
"opencode",
|
|
717
|
-
"azure-openai-responses",
|
|
718
|
-
"github-copilot"
|
|
719
|
-
]);
|
|
720
|
-
function resolveOpenAIReasoningEffort(options) {
|
|
721
|
-
return normalizeOpenAIReasoningEffort(options?.reasoningEffort ?? options?.reasoning ?? "high");
|
|
722
|
-
}
|
|
723
|
-
function hasResponsesWebSearchTool(tools) {
|
|
724
|
-
if (!Array.isArray(tools)) return false;
|
|
725
|
-
return tools.some((tool) => {
|
|
726
|
-
if (!isRecord(tool)) return false;
|
|
727
|
-
if (tool.type === "web_search") return true;
|
|
728
|
-
if (tool.type === "function" && tool.name === "web_search") return true;
|
|
729
|
-
const fn = tool.function;
|
|
730
|
-
return isRecord(fn) && fn.name === "web_search";
|
|
731
|
-
});
|
|
732
|
-
}
|
|
733
|
-
function raiseMinimalReasoningForResponsesWebSearch(params) {
|
|
734
|
-
if (params.effort !== "minimal" || !hasResponsesWebSearchTool(params.tools)) return params.effort;
|
|
735
|
-
for (const effort of [
|
|
736
|
-
"low",
|
|
737
|
-
"medium",
|
|
738
|
-
"high"
|
|
739
|
-
]) {
|
|
740
|
-
const resolved = resolveOpenAIReasoningEffortForModel({
|
|
741
|
-
model: params.model,
|
|
742
|
-
effort
|
|
743
|
-
});
|
|
744
|
-
if (resolved && resolved !== "none" && resolved !== "minimal") return resolved;
|
|
745
|
-
}
|
|
746
|
-
return params.effort;
|
|
747
|
-
}
|
|
748
|
-
const OPENAI_CODEX_RESPONSES_UNSUPPORTED_PARAMS = [
|
|
749
|
-
"max_output_tokens",
|
|
750
|
-
"metadata",
|
|
751
|
-
"prompt_cache_retention",
|
|
752
|
-
"prompt_cache_options",
|
|
753
|
-
"service_tier",
|
|
754
|
-
"temperature",
|
|
755
|
-
"top_p"
|
|
756
|
-
];
|
|
757
|
-
function stripOpenAICodexResponsesUnsupportedTextFields(params) {
|
|
758
|
-
const text = params.text;
|
|
759
|
-
if (!text || typeof text !== "object" || Array.isArray(text)) return;
|
|
760
|
-
const sanitizedText = { ...text };
|
|
761
|
-
delete sanitizedText.format;
|
|
762
|
-
if (Object.keys(sanitizedText).length > 0) params.text = sanitizedText;
|
|
763
|
-
else delete params.text;
|
|
764
|
-
}
|
|
765
|
-
function sanitizeOpenAICodexResponsesParams(model, params) {
|
|
766
|
-
if (!usesNativeOpenAICodexResponsesBackend(model)) return params;
|
|
767
|
-
for (const key of OPENAI_CODEX_RESPONSES_UNSUPPORTED_PARAMS) delete params[key];
|
|
768
|
-
Object.assign(params, { store: false });
|
|
769
|
-
stripOpenAICodexResponsesUnsupportedTextFields(params);
|
|
770
|
-
return params;
|
|
771
|
-
}
|
|
772
|
-
function buildOpenAIResponsesInstructionsText(context) {
|
|
773
|
-
if (!context.systemPrompt) return;
|
|
774
|
-
return sanitizeTransportPayloadText(stripSystemPromptCacheBoundary(context.systemPrompt));
|
|
775
|
-
}
|
|
776
|
-
function resolveOpenAIResponsesInstructions(model, context, usesInstructionsField) {
|
|
777
|
-
if (!usesInstructionsField) return;
|
|
778
|
-
const instructions = buildOpenAIResponsesInstructionsText(context);
|
|
779
|
-
if (instructions && instructions.trim().length > 0) return instructions;
|
|
780
|
-
return usesNativeOpenAICodexResponsesBackend(model) ? OPENAI_CODEX_RESPONSES_DEFAULT_INSTRUCTIONS : void 0;
|
|
781
|
-
}
|
|
782
|
-
function buildOpenAIResponsesCompactSystemMessage(model, instructions) {
|
|
783
|
-
const compat = getCompat(model);
|
|
784
|
-
const supportsDeveloperRole = typeof compat.supportsDeveloperRole === "boolean" ? compat.supportsDeveloperRole : void 0;
|
|
785
|
-
const role = model.reasoning && supportsDeveloperRole !== false ? "developer" : "system";
|
|
786
|
-
return buildResponsesInputMessage(role, [{
|
|
787
|
-
type: "input_text",
|
|
788
|
-
text: instructions
|
|
789
|
-
}]);
|
|
790
|
-
}
|
|
791
|
-
function ensureOpenAIResponsesNonEmptyInput(messages, context) {
|
|
792
|
-
if (messages.length > 0 || !context.systemPrompt) return;
|
|
793
|
-
if (!buildOpenAIResponsesInstructionsText(context)) throw new Error("OpenAI Responses requires non-empty input when only systemPrompt is provided.");
|
|
794
|
-
messages.push(buildResponsesInputMessage("user", [{
|
|
795
|
-
type: "input_text",
|
|
796
|
-
text: " "
|
|
797
|
-
}]));
|
|
798
|
-
}
|
|
799
|
-
function resolveOpenAIResponsesTextFormat(responseFormat) {
|
|
800
|
-
if (responseFormat.type === "json_schema" && responseFormat.json_schema && typeof responseFormat.json_schema === "object" && !Array.isArray(responseFormat.json_schema)) return {
|
|
801
|
-
...responseFormat.json_schema,
|
|
802
|
-
type: "json_schema"
|
|
803
|
-
};
|
|
804
|
-
return responseFormat;
|
|
805
|
-
}
|
|
806
|
-
function convertOpenAIResponsesMessagesForRequest(model, context, options, replayMode) {
|
|
807
|
-
const isNativeCodexResponses = usesNativeOpenAICodexResponsesBackend(model);
|
|
808
|
-
const payloadPolicy = resolveOpenAIResponsesPayloadPolicy(model, { storeMode: "disable" });
|
|
809
|
-
const policyAllowsReplayIds = payloadPolicy.explicitStore !== false && !payloadPolicy.shouldStripStore;
|
|
810
|
-
const replayResponsesItemIds = !isNativeCodexResponses && (options?.replayResponsesItemIds ?? policyAllowsReplayIds);
|
|
811
|
-
return convertResponsesMessages(model, context, OPENAI_RESPONSES_TOOL_CALL_PROVIDERS, {
|
|
812
|
-
includeSystemPrompt: !payloadPolicy.usesInstructionsField,
|
|
813
|
-
replayReasoningItems: true,
|
|
814
|
-
replayResponsesItemIds,
|
|
815
|
-
authProfileId: options?.authProfileId,
|
|
816
|
-
sessionId: options?.sessionId,
|
|
817
|
-
replayMode
|
|
818
|
-
});
|
|
819
|
-
}
|
|
820
|
-
function buildOpenAIResponsesParams(model, context, options, metadata, replayMode = "checkpoint") {
|
|
821
|
-
const payloadPolicy = resolveOpenAIResponsesPayloadPolicy(model, { storeMode: "disable" });
|
|
822
|
-
const messages = convertOpenAIResponsesMessagesForRequest(model, context, options, replayMode);
|
|
823
|
-
ensureOpenAIResponsesNonEmptyInput(messages, context);
|
|
824
|
-
const cacheRetention = resolveCacheRetention(options?.cacheRetention);
|
|
825
|
-
const compat = getCompat(model);
|
|
826
|
-
const promptCacheKey = compat.supportsPromptCacheKey ? resolvePromptCacheKey(options, cacheRetention) : void 0;
|
|
827
|
-
const instructions = resolveOpenAIResponsesInstructions(model, context, payloadPolicy.usesInstructionsField);
|
|
828
|
-
const params = {
|
|
829
|
-
model: model.id,
|
|
830
|
-
input: messages,
|
|
831
|
-
stream: true,
|
|
832
|
-
prompt_cache_key: promptCacheKey,
|
|
833
|
-
...resolveOpenAIPromptCacheParams(model, cacheRetention, compat),
|
|
834
|
-
...instructions ? { instructions } : {},
|
|
835
|
-
...metadata ? { metadata } : {}
|
|
836
|
-
};
|
|
837
|
-
const effectiveMaxTokens = options?.maxTokens || model.maxTokens;
|
|
838
|
-
if (effectiveMaxTokens) params.max_output_tokens = Math.max(effectiveMaxTokens, 16);
|
|
839
|
-
if (options?.temperature !== void 0 && supportsOpenAITemperature(model)) params.temperature = options.temperature;
|
|
840
|
-
if (options?.topP !== void 0 && model.id !== "gpt-6-astra") params.top_p = options.topP;
|
|
841
|
-
if (options?.responseFormat !== void 0) params.text = {
|
|
842
|
-
...params.text,
|
|
843
|
-
format: resolveOpenAIResponsesTextFormat(options.responseFormat)
|
|
844
|
-
};
|
|
845
|
-
if (options?.serviceTier !== void 0 && payloadPolicy.allowsServiceTier) params.service_tier = options.serviceTier;
|
|
846
|
-
if (context.tools) {
|
|
847
|
-
const tools = context.tools;
|
|
848
|
-
const strict = resolveOpenAIStrictToolSetting(model, { transport: "stream" });
|
|
849
|
-
const projection = projectOpenAITools(tools);
|
|
850
|
-
const converted = convertProjectedResponsesTools(projection, strict, model);
|
|
851
|
-
if (converted.length > 0 || projection.inputToolCount === 0 && projection.diagnostics.length === 0) params.tools = converted;
|
|
852
|
-
if (options?.toolChoice) {
|
|
853
|
-
const toolChoice = reconcileOpenAIResponsesToolChoice(options.toolChoice, projection);
|
|
854
|
-
if (toolChoice !== void 0) params.tool_choice = toolChoice;
|
|
855
|
-
}
|
|
856
|
-
}
|
|
857
|
-
if (model.reasoning) {
|
|
858
|
-
if (options?.reasoningEffort || options?.reasoning || options?.reasoningSummary) {
|
|
859
|
-
const requestedReasoningEffort = resolveOpenAIReasoningEffort(options);
|
|
860
|
-
const resolvedReasoningEffort = resolveOpenAIReasoningEffortForModel({
|
|
861
|
-
model,
|
|
862
|
-
effort: requestedReasoningEffort
|
|
863
|
-
});
|
|
864
|
-
const reasoningEffort = resolvedReasoningEffort ? raiseMinimalReasoningForResponsesWebSearch({
|
|
865
|
-
model,
|
|
866
|
-
effort: resolvedReasoningEffort,
|
|
867
|
-
tools: params.tools
|
|
868
|
-
}) : void 0;
|
|
869
|
-
if (reasoningEffort) {
|
|
870
|
-
params.reasoning = {
|
|
871
|
-
effort: reasoningEffort,
|
|
872
|
-
...reasoningEffort === "none" ? {} : { summary: options?.reasoningSummary || "auto" }
|
|
873
|
-
};
|
|
874
|
-
if (reasoningEffort !== "none") params.include = ["reasoning.encrypted_content"];
|
|
875
|
-
}
|
|
876
|
-
} else if (model.provider !== "github-copilot") {
|
|
877
|
-
const reasoningEffort = resolveOpenAIReasoningEffortForModel({
|
|
878
|
-
model,
|
|
879
|
-
effort: "none"
|
|
880
|
-
});
|
|
881
|
-
if (reasoningEffort) params.reasoning = { effort: reasoningEffort };
|
|
882
|
-
}
|
|
883
|
-
}
|
|
884
|
-
applyOpenAIResponsesPayloadPolicy(params, payloadPolicy);
|
|
885
|
-
return sanitizeOpenAICodexResponsesParams(model, params);
|
|
886
|
-
}
|
|
887
|
-
//#endregion
|
|
888
|
-
//#region packages/ai/src/transports/openai-responses-reasoning-update.ts
|
|
889
|
-
function isConfigurationUpdate(value) {
|
|
890
|
-
return isRecord(value) && value.type === "configuration_update" && isRecord(value.reasoning) && typeof value.reasoning.effort === "string";
|
|
891
|
-
}
|
|
892
|
-
function isResponsesReasoningUpdateCompatible(request) {
|
|
893
|
-
const mode = isRecord(request.reasoning) ? request.reasoning.mode : void 0;
|
|
894
|
-
return request.model === "gpt-6-astra" && (mode === void 0 || mode === "standard") && (!isRecord(request.multi_agent) || request.multi_agent.enabled !== true) && request.truncation !== "auto" && (!Array.isArray(request.context_management) || !request.context_management.some((item) => isRecord(item) && item.type === "compaction"));
|
|
895
|
-
}
|
|
896
|
-
function supportsResponsesReasoningUpdate(request) {
|
|
897
|
-
return isResponsesReasoningUpdateCompatible(request) && isRecord(request.reasoning) && typeof request.reasoning.effort === "string";
|
|
898
|
-
}
|
|
899
|
-
function canReferenceResponsesReasoningHistory(previous, request) {
|
|
900
|
-
return !previous.input?.some(isConfigurationUpdate) || isResponsesReasoningUpdateCompatible(request);
|
|
901
|
-
}
|
|
902
|
-
/** Rehydrate input controls only provisionally; continuation must validate the full prefix. */
|
|
903
|
-
function replayResponsesReasoningUpdates(previous, request, previousOutputLength, steering) {
|
|
904
|
-
if (steering !== "required-input" && (!supportsResponsesReasoningUpdate(previous) || !supportsResponsesReasoningUpdate(request)) || !Array.isArray(previous.input) || !Array.isArray(request.input) || request.input.some(isConfigurationUpdate)) return request;
|
|
905
|
-
const input = [...request.input];
|
|
906
|
-
let activeEffort = isRecord(previous.reasoning) ? previous.reasoning.effort : void 0;
|
|
907
|
-
for (const [index, item] of previous.input.entries()) if (isConfigurationUpdate(item)) {
|
|
908
|
-
input.splice(index, 0, item);
|
|
909
|
-
activeEffort = item.reasoning.effort;
|
|
910
|
-
}
|
|
911
|
-
if (steering === "required-input") return input.length === request.input.length ? request : {
|
|
912
|
-
...request,
|
|
913
|
-
input
|
|
914
|
-
};
|
|
915
|
-
if (!isRecord(previous.reasoning) || !isRecord(request.reasoning) || typeof request.reasoning.effort !== "string") return request;
|
|
916
|
-
if (activeEffort !== request.reasoning.effort && steering !== "automatic") {
|
|
917
|
-
const baselineLength = previous.input.length + previousOutputLength;
|
|
918
|
-
const nextUser = input.findIndex((item, index) => index >= baselineLength && "role" in item && item.role === "user");
|
|
919
|
-
if (nextUser === -1) return request;
|
|
920
|
-
input.splice(nextUser, 0, {
|
|
921
|
-
type: "configuration_update",
|
|
922
|
-
reasoning: { effort: request.reasoning.effort }
|
|
923
|
-
});
|
|
924
|
-
}
|
|
925
|
-
if (input.length === request.input.length && activeEffort === request.reasoning.effort) return request;
|
|
926
|
-
return {
|
|
927
|
-
...request,
|
|
928
|
-
reasoning: {
|
|
929
|
-
...request.reasoning,
|
|
930
|
-
effort: previous.reasoning.effort
|
|
931
|
-
},
|
|
932
|
-
input
|
|
933
|
-
};
|
|
934
|
-
}
|
|
935
|
-
//#endregion
|
|
936
|
-
//#region packages/ai/src/transports/openai-responses-continuation.ts
|
|
937
|
-
const HTTP_CONTINUATION_IDLE_TTL_MS = 3e5;
|
|
938
|
-
const TURN_HEADERS = /* @__PURE__ */ new Set([
|
|
939
|
-
"traceparent",
|
|
940
|
-
"x-openclaw-turn-id",
|
|
941
|
-
"x-openclaw-turn-attempt"
|
|
942
|
-
]);
|
|
943
|
-
function jsonValuesEqual(left, right) {
|
|
944
|
-
const leftJson = JSON.stringify(left);
|
|
945
|
-
const normalizedLeft = stableStringify(JSON.parse(leftJson));
|
|
946
|
-
const rightJson = JSON.stringify(right);
|
|
947
|
-
return leftJson === rightJson || normalizedLeft === stableStringify(JSON.parse(rightJson));
|
|
948
|
-
}
|
|
949
|
-
function requestWithoutInput(request) {
|
|
950
|
-
const { input: _input, previous_response_id: _previousResponseId, instructions: _instructions, tools: _tools, ...rest } = request;
|
|
951
|
-
if (!isRecord(rest.metadata)) return rest;
|
|
952
|
-
const metadata = Object.fromEntries(Object.entries(rest.metadata).filter(([key]) => key !== "openclaw_turn_id" && key !== "openclaw_turn_attempt"));
|
|
953
|
-
return {
|
|
954
|
-
...rest,
|
|
955
|
-
metadata
|
|
956
|
-
};
|
|
957
|
-
}
|
|
958
|
-
function normalizeAssistantReplayInput(input, fromResponse = false) {
|
|
959
|
-
return input.map((item) => {
|
|
960
|
-
if (!isRecord(item)) return item;
|
|
961
|
-
if (item.type === "reasoning") return { type: "reasoning" };
|
|
962
|
-
if (item.type !== "function_call" && !(item.type === "message" && item.role === "assistant")) return item;
|
|
963
|
-
const { id: _id, status: _status, ...stableItem } = item;
|
|
964
|
-
if (fromResponse && item.type === "function_call") {
|
|
965
|
-
const args = parseJsonObjectPreservingUnsafeIntegers(stableItem.arguments);
|
|
966
|
-
stableItem.arguments = args ? JSON.stringify(args) : stableItem.arguments;
|
|
967
|
-
}
|
|
968
|
-
if (item.type === "message" && Array.isArray(stableItem.content)) stableItem.content = stableItem.content.map((part) => {
|
|
969
|
-
if (!isRecord(part) || part.type !== "output_text") return part;
|
|
970
|
-
const { annotations: _annotations, logprobs: _logprobs, ...stablePart } = part;
|
|
971
|
-
return stablePart;
|
|
972
|
-
});
|
|
973
|
-
return stableItem;
|
|
974
|
-
});
|
|
975
|
-
}
|
|
976
|
-
function responsesContinuationRequestFingerprint(request) {
|
|
977
|
-
const serialized = JSON.stringify(requestWithoutInput(request));
|
|
978
|
-
return sha256Hex(stableStringify(JSON.parse(serialized)));
|
|
979
|
-
}
|
|
980
|
-
function responsesContinuationPrefixFingerprint(input, output = []) {
|
|
981
|
-
const serialized = JSON.stringify([...normalizeAssistantReplayInput(input), ...normalizeAssistantReplayInput(output, true)]);
|
|
982
|
-
return sha256Hex(stableStringify(JSON.parse(serialized)));
|
|
983
|
-
}
|
|
984
|
-
function resolveResponsesContinuationRequest(continuation, request, steering) {
|
|
985
|
-
if (!continuation) return {
|
|
986
|
-
request,
|
|
987
|
-
continuationStatus: "no_previous_response"
|
|
988
|
-
};
|
|
989
|
-
if (request.previous_response_id) return {
|
|
990
|
-
request,
|
|
991
|
-
continuationStatus: "explicit_previous_response_id"
|
|
992
|
-
};
|
|
993
|
-
if (!canReferenceResponsesReasoningHistory(continuation.lastRequest, request)) return {
|
|
994
|
-
request,
|
|
995
|
-
continuationStatus: "request_changed"
|
|
996
|
-
};
|
|
997
|
-
const prepared = replayResponsesReasoningUpdates(continuation.lastRequest, request, continuation.lastResponseItems.length, steering);
|
|
998
|
-
if (steering !== "required-input" && !jsonValuesEqual(requestWithoutInput(prepared), requestWithoutInput(continuation.lastRequest))) return {
|
|
999
|
-
request,
|
|
1000
|
-
continuationStatus: "request_changed"
|
|
1001
|
-
};
|
|
1002
|
-
const currentInput = prepared.input ?? [];
|
|
1003
|
-
const previousInput = continuation.lastRequest.input ?? [];
|
|
1004
|
-
const baselineLength = previousInput.length + continuation.lastResponseItems.length;
|
|
1005
|
-
if (currentInput.length < baselineLength) return {
|
|
1006
|
-
request,
|
|
1007
|
-
continuationStatus: "history_shorter"
|
|
1008
|
-
};
|
|
1009
|
-
if (!jsonValuesEqual(normalizeAssistantReplayInput(currentInput.slice(0, previousInput.length)), normalizeAssistantReplayInput(previousInput)) || !jsonValuesEqual(normalizeAssistantReplayInput(currentInput.slice(previousInput.length, baselineLength)), normalizeAssistantReplayInput(continuation.lastResponseItems, true))) return {
|
|
1010
|
-
request,
|
|
1011
|
-
continuationStatus: "history_changed"
|
|
1012
|
-
};
|
|
1013
|
-
return {
|
|
1014
|
-
request: {
|
|
1015
|
-
...prepared,
|
|
1016
|
-
previous_response_id: continuation.lastResponseId,
|
|
1017
|
-
input: currentInput.slice(baselineLength)
|
|
1018
|
-
},
|
|
1019
|
-
...prepared !== request ? { fullRequest: prepared } : {},
|
|
1020
|
-
continuationStatus: "continued"
|
|
1021
|
-
};
|
|
1022
|
-
}
|
|
1023
|
-
const httpContinuationEntries = /* @__PURE__ */ new Map();
|
|
1024
|
-
function deleteHttpContinuationIfOwned(key, entry) {
|
|
1025
|
-
if (httpContinuationEntries.get(key) === entry) httpContinuationEntries.delete(key);
|
|
1026
|
-
}
|
|
1027
|
-
function connectionIdentity(params) {
|
|
1028
|
-
const headers = Object.entries(resolveAiTransportHeaderSentinels(params.headers) ?? {}).map(([name, value]) => [name.toLowerCase(), value]).filter(([name]) => !TURN_HEADERS.has(name)).toSorted(([a], [b]) => a.localeCompare(b));
|
|
1029
|
-
return sha256Hex(JSON.stringify([
|
|
1030
|
-
getAiTransportHost().resolveSecretSentinel(params.apiKey),
|
|
1031
|
-
params.baseUrl,
|
|
1032
|
-
headers
|
|
1033
|
-
]));
|
|
1034
|
-
}
|
|
1035
|
-
function claimOpenAIResponsesHttpContinuation(params) {
|
|
1036
|
-
const key = `${params.sessionId}\0${connectionIdentity(params)}`;
|
|
1037
|
-
const previous = httpContinuationEntries.get(key);
|
|
1038
|
-
if (previous?.kind === "claimed") return;
|
|
1039
|
-
if (previous?.kind === "ready") clearTimeout(previous.idleTimer);
|
|
1040
|
-
const claimed = {
|
|
1041
|
-
kind: "claimed",
|
|
1042
|
-
sessionId: params.sessionId
|
|
1043
|
-
};
|
|
1044
|
-
httpContinuationEntries.set(key, claimed);
|
|
1045
|
-
try {
|
|
1046
|
-
const request = previous?.kind === "ready" ? params.request : params.restoreRequest?.() ?? params.request;
|
|
1047
|
-
const resolved = resolveResponsesContinuationRequest(previous?.kind === "ready" ? previous.state : void 0, request);
|
|
1048
|
-
const fullRequest = resolved.fullRequest ?? request;
|
|
1049
|
-
return {
|
|
1050
|
-
request: params.request.store === false ? fullRequest : resolved.request,
|
|
1051
|
-
fullRequest,
|
|
1052
|
-
commit: (effectiveRequest, response) => {
|
|
1053
|
-
if (httpContinuationEntries.get(key) !== claimed) return;
|
|
1054
|
-
const ready = {
|
|
1055
|
-
...claimed,
|
|
1056
|
-
kind: "ready",
|
|
1057
|
-
state: {
|
|
1058
|
-
lastRequest: effectiveRequest,
|
|
1059
|
-
lastResponseId: response.id,
|
|
1060
|
-
lastResponseItems: response.output
|
|
1061
|
-
},
|
|
1062
|
-
idleTimer: setTimeout(() => deleteHttpContinuationIfOwned(key, ready), HTTP_CONTINUATION_IDLE_TTL_MS)
|
|
1063
|
-
};
|
|
1064
|
-
ready.idleTimer.unref?.();
|
|
1065
|
-
httpContinuationEntries.set(key, ready);
|
|
1066
|
-
},
|
|
1067
|
-
release: () => deleteHttpContinuationIfOwned(key, claimed)
|
|
1068
|
-
};
|
|
1069
|
-
} catch (error) {
|
|
1070
|
-
deleteHttpContinuationIfOwned(key, claimed);
|
|
1071
|
-
throw error;
|
|
1072
|
-
}
|
|
1073
|
-
}
|
|
1074
|
-
registerSessionResourceCleanup((sessionId) => {
|
|
1075
|
-
for (const [key, entry] of httpContinuationEntries) if (!sessionId || entry.sessionId === sessionId) {
|
|
1076
|
-
if (entry.kind === "ready") clearTimeout(entry.idleTimer);
|
|
1077
|
-
httpContinuationEntries.delete(key);
|
|
1078
|
-
}
|
|
1079
|
-
});
|
|
1080
|
-
//#endregion
|
|
1081
734
|
//#region packages/ai/src/transports/openai-responses-steering.ts
|
|
1082
735
|
function cloneWireRequest(request) {
|
|
1083
736
|
const serialized = JSON.stringify(request);
|
|
@@ -1699,34 +1352,27 @@ function combineWebSocketTimeoutSignal(signal, model, timeoutMs) {
|
|
|
1699
1352
|
if (resolvedTimeoutMs === void 0 || !Number.isFinite(resolvedTimeoutMs)) return signal;
|
|
1700
1353
|
return AbortSignal.any([signal, AbortSignal.timeout(Math.max(1, resolvedTimeoutMs))]);
|
|
1701
1354
|
}
|
|
1702
|
-
function
|
|
1703
|
-
const normalizedProvider = model.provider.trim().toLowerCase();
|
|
1704
|
-
const allowRuntimePluginLoad = normalizedProvider === "openai" || normalizedProvider === "azure-openai" || normalizedProvider === "azure-openai-responses";
|
|
1705
|
-
return getAiTransportHost().plugin.resolveTransportTurnState({
|
|
1706
|
-
provider: model.provider,
|
|
1707
|
-
modelId: model.id,
|
|
1708
|
-
allowRuntimePluginLoad,
|
|
1709
|
-
context: {
|
|
1710
|
-
provider: model.provider,
|
|
1711
|
-
modelId: model.id,
|
|
1712
|
-
model,
|
|
1713
|
-
sessionId: params.sessionId,
|
|
1714
|
-
turnId: params.turnId,
|
|
1715
|
-
attempt: params.attempt,
|
|
1716
|
-
transport: params.transport
|
|
1717
|
-
}
|
|
1718
|
-
});
|
|
1719
|
-
}
|
|
1720
|
-
function createOpenAIResponsesClient(model, context, apiKey, optionHeaders, turnHeaders, sessionId, fetchOverride) {
|
|
1355
|
+
function createOpenAIResponsesClient(model, apiKey, defaultHeaders, fetchOverride) {
|
|
1721
1356
|
return new OpenAI({
|
|
1722
1357
|
apiKey,
|
|
1723
1358
|
baseURL: resolveOpenAIClientBaseUrl(model),
|
|
1724
1359
|
dangerouslyAllowBrowser: true,
|
|
1725
|
-
defaultHeaders
|
|
1360
|
+
defaultHeaders,
|
|
1726
1361
|
fetch: fetchOverride ?? buildGuardedModelFetch(model),
|
|
1727
1362
|
...buildOpenAISdkClientOptions(model)
|
|
1728
1363
|
});
|
|
1729
1364
|
}
|
|
1365
|
+
function withDefaultResponsesStreamEncoding(fetch) {
|
|
1366
|
+
return (input, init) => {
|
|
1367
|
+
const headers = new Headers(init?.headers ?? (input instanceof Request ? input.headers : void 0));
|
|
1368
|
+
if (headers.has("accept-encoding")) return fetch(input, init);
|
|
1369
|
+
headers.set("accept-encoding", "identity");
|
|
1370
|
+
return fetch(input, {
|
|
1371
|
+
...init,
|
|
1372
|
+
headers
|
|
1373
|
+
});
|
|
1374
|
+
};
|
|
1375
|
+
}
|
|
1730
1376
|
function createResponsesTransportExecutor(config) {
|
|
1731
1377
|
return (model, context, options) => {
|
|
1732
1378
|
const responsesOptions = options;
|
|
@@ -1746,8 +1392,11 @@ function createResponsesTransportExecutor(config) {
|
|
|
1746
1392
|
transport: websocketMode ? "websocket" : "stream"
|
|
1747
1393
|
});
|
|
1748
1394
|
const websocketSessionPolicy = websocketMode ? turnState?.websocket : void 0;
|
|
1749
|
-
const
|
|
1750
|
-
const
|
|
1395
|
+
const httpTurnHeaders = filterProviderTurnHeadersForExplicitOpencodeSession(model, options, turnState?.headers);
|
|
1396
|
+
const websocketTurnHeaders = filterProviderTurnHeadersForExplicitOpencodeSession(model, options, websocketSessionPolicy?.headers);
|
|
1397
|
+
const websocketHeaders = websocketMode ? buildOpenAIClientHeaders(model, context, options?.headers, websocketTurnHeaders, options?.sessionId, options?.cacheRetention) : void 0;
|
|
1398
|
+
const httpHeaders = buildOpenAIClientHeaders(model, context, options?.headers, httpTurnHeaders, options?.sessionId, options?.cacheRetention);
|
|
1399
|
+
const client = config.createClient(model, apiKey, httpHeaders, compactRequest ? createBoundedOpenAIResponsesCompactionFetch(buildGuardedModelFetch(model)) : config.streamRequest ? withDefaultResponsesStreamEncoding(buildGuardedModelFetch(model)) : void 0);
|
|
1751
1400
|
const nativeAstra = model.id === "gpt-6-astra" && supportsNativeOpenAIResponsesEndpoint(model);
|
|
1752
1401
|
const asyncToolExecutionEligible = nativeAstra && options?.asyncToolExecution === true && !responsesOptions?.openclawCodeModeToolSurface;
|
|
1753
1402
|
const prepareRequest = async (request) => {
|
|
@@ -1791,16 +1440,16 @@ function createResponsesTransportExecutor(config) {
|
|
|
1791
1440
|
return;
|
|
1792
1441
|
}
|
|
1793
1442
|
const sessionId = options?.sessionId;
|
|
1794
|
-
if (config.httpContinuation && !websocketMode && !getAiTransportHost().requiresManagedTransport(model) && supportsNativeOpenAIResponsesEndpoint({
|
|
1443
|
+
if (config.httpContinuation && !websocketMode && !getAiTransportHost().requiresManagedTransport(model) && (supportsNativeOpenAIResponsesEndpoint({
|
|
1795
1444
|
provider: model.provider,
|
|
1796
1445
|
api: model.api,
|
|
1797
1446
|
baseUrl: model.baseUrl
|
|
1798
|
-
}) && sessionId && (params.store === true || supportsResponsesReasoningUpdate(params)) && !params.previous_response_id) {
|
|
1447
|
+
}) || resolveOpenAIResponsesPayloadPolicy(model).explicitContinuationOptIn) && sessionId && (params.store === true || supportsResponsesReasoningUpdate(params)) && !params.previous_response_id) {
|
|
1799
1448
|
continuationClaim = claimOpenAIResponsesHttpContinuation({
|
|
1800
1449
|
sessionId,
|
|
1801
1450
|
apiKey,
|
|
1802
1451
|
baseUrl: model.baseUrl,
|
|
1803
|
-
headers:
|
|
1452
|
+
headers: httpHeaders,
|
|
1804
1453
|
request: params,
|
|
1805
1454
|
restoreRequest: () => restoreResponsesReasoningState(context, model, responsesOptions, params)
|
|
1806
1455
|
});
|
|
@@ -1826,7 +1475,9 @@ function createResponsesTransportExecutor(config) {
|
|
|
1826
1475
|
});
|
|
1827
1476
|
const websocketSignal = combineWebSocketTimeoutSignal(firstEvent.signal, model, requestOptions?.timeout);
|
|
1828
1477
|
emitModelTransportDebug(log, `[responses] start provider=${model.provider} api=${model.api} model=${model.id} requestIdHash=${redactIdentifier(options?.requestId, { len: 64 })} baseUrl=${formatModelTransportDebugBaseUrl(model.baseUrl)} timeoutMs=${safeDebugValue(requestOptions?.timeout)} apiKey=${apiKey ? "present" : "missing"} ${summarizeResponsesPayload(params)}`);
|
|
1478
|
+
const responseModelTracker = createResponseModelTracker(isOpenAICodexResponsesModel(model));
|
|
1829
1479
|
let continuationBaseline;
|
|
1480
|
+
let contextUsageEligible = true;
|
|
1830
1481
|
const createSseStream = async (initialRequest = continuationClaim?.request ?? params, initialAttemptKind = "initial", initialRejectedCompaction) => {
|
|
1831
1482
|
const { stream: responseStream } = await createResponsesStreamWithEncryptedContentRetry({
|
|
1832
1483
|
client,
|
|
@@ -1840,9 +1491,11 @@ function createResponsesTransportExecutor(config) {
|
|
|
1840
1491
|
onCompactionRejected: (checkpoint) => suppressOpenAIResponsesCompaction(output, model, responsesOptions, checkpoint),
|
|
1841
1492
|
canRetryStream: () => output.content.length === 0,
|
|
1842
1493
|
wrapStream: ({ stream: rawResponseStream, response, attempt }) => {
|
|
1494
|
+
contextUsageEligible &&= attempt.kind === "initial";
|
|
1843
1495
|
continuationBaseline = attempt.request.previous_response_id ? params : attempt.request;
|
|
1496
|
+
const trackedResponseStream = responseModelTracker.track(response, rawResponseStream);
|
|
1844
1497
|
return withProviderResponseHook({
|
|
1845
|
-
stream: observeResponsesStream(
|
|
1498
|
+
stream: observeResponsesStream(trackedResponseStream, model, requestStartedAt),
|
|
1846
1499
|
signal: firstEvent.signal,
|
|
1847
1500
|
abort: firstEvent.abort,
|
|
1848
1501
|
hook: createOpenAIProviderAcceptanceHook(options, response, model),
|
|
@@ -1878,24 +1531,29 @@ function createResponsesTransportExecutor(config) {
|
|
|
1878
1531
|
callerSignal: options?.signal,
|
|
1879
1532
|
degradeCooldownMs: websocketSessionPolicy?.degradeCooldownMs,
|
|
1880
1533
|
onActiveResponse: nativeAstra && params.model === "gpt-6-astra" ? options?.onActiveResponse : void 0,
|
|
1881
|
-
steeringInput: (messages) =>
|
|
1882
|
-
|
|
1883
|
-
|
|
1884
|
-
|
|
1534
|
+
steeringInput: (messages) => {
|
|
1535
|
+
contextUsageEligible = false;
|
|
1536
|
+
return projectResponsesSteeringInput(params, () => buildRequest("checkpoint", {
|
|
1537
|
+
...context,
|
|
1538
|
+
messages: [...context.messages, ...messages]
|
|
1539
|
+
}));
|
|
1540
|
+
}
|
|
1885
1541
|
});
|
|
1886
1542
|
finishWebSocket = websocket.finish;
|
|
1887
1543
|
websocketBaseline = websocket.fullRequest;
|
|
1888
1544
|
recordResponsesInputReplay(output, websocket.inputReplay);
|
|
1545
|
+
contextUsageEligible &&= websocket.inputReplay === void 0;
|
|
1889
1546
|
observePrompt?.(websocket.request, {
|
|
1890
1547
|
egress: "responses-websocket",
|
|
1891
1548
|
payloadVariant: "initial"
|
|
1892
1549
|
});
|
|
1893
1550
|
transport = "websocket";
|
|
1894
1551
|
emitModelTransportDebug(log, `[responses] websocket_selected provider=${model.provider} api=${model.api} model=${model.id} mode=${websocketMode} reused=${websocket.reusedConnection} continuation=${websocket.continuationStatus === "continued"} continuationStatus=${websocket.continuationStatus} sessionIdHash=${redactIdentifier(options?.sessionId)} headersHash=${redactIdentifier(JSON.stringify(Object.entries(websocketHeaders ?? {}).toSorted(([a], [b]) => a.localeCompare(b))))}`);
|
|
1552
|
+
const trackedWebSocketStream = responseModelTracker.track(void 0, websocket.stream);
|
|
1895
1553
|
responseStream = { async *[Symbol.asyncIterator]() {
|
|
1896
1554
|
let providerAccepted = false;
|
|
1897
1555
|
try {
|
|
1898
|
-
for await (const event of
|
|
1556
|
+
for await (const event of trackedWebSocketStream) {
|
|
1899
1557
|
if (!providerAccepted) {
|
|
1900
1558
|
providerAccepted = true;
|
|
1901
1559
|
await notifyProviderStreamOpened({
|
|
@@ -1944,7 +1602,8 @@ function createResponsesTransportExecutor(config) {
|
|
|
1944
1602
|
authProfileId: responsesOptions?.authProfileId,
|
|
1945
1603
|
sessionId: options?.sessionId
|
|
1946
1604
|
}),
|
|
1947
|
-
asyncToolExecution: asyncTools
|
|
1605
|
+
asyncToolExecution: asyncTools,
|
|
1606
|
+
...responseModelTracker.terminalOptions
|
|
1948
1607
|
});
|
|
1949
1608
|
finishWebSocket?.();
|
|
1950
1609
|
if (options?.signal?.aborted) throw transportAbortError(options.signal);
|
|
@@ -1952,6 +1611,7 @@ function createResponsesTransportExecutor(config) {
|
|
|
1952
1611
|
const admitted = transport === "websocket" ? websocketBaseline : continuationBaseline;
|
|
1953
1612
|
if (terminal && admitted && supportsNativeOpenAIResponsesEndpoint(model)) recordResponsesReasoningState(output, model, responsesOptions, admitted, terminal.output);
|
|
1954
1613
|
if (continuationClaim && continuationBaseline && terminal) continuationClaim.commit(continuationBaseline, terminal);
|
|
1614
|
+
if (terminal && admitted && contextUsageEligible) recordResponsesContextUsage(output, model, responsesOptions, admitted, terminal.output, "transport");
|
|
1955
1615
|
} catch (error) {
|
|
1956
1616
|
finishWebSocket?.({ keep: false });
|
|
1957
1617
|
throw error;
|
|
@@ -2006,7 +1666,13 @@ function createAzureOpenAIResponsesTransportStreamFn() {
|
|
|
2006
1666
|
outputApi: "azure-openai-responses",
|
|
2007
1667
|
firstEventTimeoutMs: AZURE_RESPONSES_FIRST_EVENT_TIMEOUT_MS,
|
|
2008
1668
|
createClient: createAzureOpenAIClient,
|
|
2009
|
-
buildRequest: (model, context, options, metadata, replayMode) =>
|
|
1669
|
+
buildRequest: (model, context, options, metadata, replayMode) => {
|
|
1670
|
+
const deploymentName = resolveAzureDeploymentName(model);
|
|
1671
|
+
const params = buildOpenAIResponsesParams(model, context, options, metadata, replayMode);
|
|
1672
|
+
params.model = deploymentName;
|
|
1673
|
+
delete params.store;
|
|
1674
|
+
return params;
|
|
1675
|
+
}
|
|
2010
1676
|
});
|
|
2011
1677
|
}
|
|
2012
1678
|
function resolveAzureDeploymentName(model) {
|
|
@@ -2015,12 +1681,12 @@ function resolveAzureDeploymentName(model) {
|
|
|
2015
1681
|
deploymentMap: process.env.AZURE_OPENAI_DEPLOYMENT_NAME_MAP
|
|
2016
1682
|
});
|
|
2017
1683
|
}
|
|
2018
|
-
function createAzureOpenAIClient(model,
|
|
1684
|
+
function createAzureOpenAIClient(model, apiKey, defaultHeaders, fetchOverride) {
|
|
2019
1685
|
const baseURL = model.baseUrl.replace(/\/+$/, "");
|
|
2020
1686
|
const clientOptions = {
|
|
2021
1687
|
apiKey,
|
|
2022
1688
|
dangerouslyAllowBrowser: true,
|
|
2023
|
-
defaultHeaders
|
|
1689
|
+
defaultHeaders,
|
|
2024
1690
|
baseURL,
|
|
2025
1691
|
fetch: fetchOverride ?? buildGuardedModelFetch(model),
|
|
2026
1692
|
...buildOpenAISdkClientOptions(model)
|
|
@@ -2031,41 +1697,6 @@ function createAzureOpenAIClient(model, context, apiKey, optionHeaders, turnHead
|
|
|
2031
1697
|
apiVersion: resolveAzureOpenAIApiVersion()
|
|
2032
1698
|
});
|
|
2033
1699
|
}
|
|
2034
|
-
function buildAzureOpenAIResponsesParams(model, context, options, deploymentName, metadata, replayMode = "checkpoint") {
|
|
2035
|
-
const params = buildOpenAIResponsesParams(model, context, options, metadata, replayMode);
|
|
2036
|
-
params.model = deploymentName;
|
|
2037
|
-
delete params.store;
|
|
2038
|
-
return params;
|
|
2039
|
-
}
|
|
2040
|
-
//#endregion
|
|
2041
|
-
//#region packages/ai/src/transports/openai-responses-transport.ts
|
|
2042
|
-
/** OpenAI Responses transport facade. */
|
|
2043
|
-
const responsesTesting = {
|
|
2044
|
-
getCompat,
|
|
2045
|
-
assertCodeModeResponsesToolSurface,
|
|
2046
|
-
buildOpenAIResponsesParams,
|
|
2047
|
-
buildOpenAIClientHeaders,
|
|
2048
|
-
buildOpenAISdkClientOptions,
|
|
2049
|
-
buildOpenAISdkRequestOptions,
|
|
2050
|
-
createAzureOpenAIClient,
|
|
2051
|
-
createOpenAIResponsesClient,
|
|
2052
|
-
enforceCodeModeResponsesToolSurface,
|
|
2053
|
-
sanitizeOpenAICodexResponsesParams,
|
|
2054
|
-
processResponsesStream,
|
|
2055
|
-
formatModelTransportDebugBaseUrl,
|
|
2056
|
-
buildResponsesFailedNoDetailsObservation,
|
|
2057
|
-
buildOpenAIResponsesReasoningReplayMetadata,
|
|
2058
|
-
isInvalidEncryptedContentError,
|
|
2059
|
-
normalizeResponsesFailedEvent,
|
|
2060
|
-
createResponsesStreamWithEncryptedContentRetry,
|
|
2061
|
-
resolveAzureOpenAIApiVersion,
|
|
2062
|
-
summarizeResponsesFailedNoDetailsObservation,
|
|
2063
|
-
summarizeResponsesPayload,
|
|
2064
|
-
summarizeResponsesTools,
|
|
2065
|
-
stringifyRedactedEvent,
|
|
2066
|
-
stringifyRedactedPayload
|
|
2067
|
-
};
|
|
2068
|
-
if (process.env.VITEST || false) globalThis.openclawOpenAIResponsesTransportTestApi = responsesTesting;
|
|
2069
1700
|
//#endregion
|
|
2070
1701
|
//#region packages/ai/src/transports/provider-compaction-replay.ts
|
|
2071
1702
|
function isAssistantReplayMessage(message) {
|
|
@@ -2123,35 +1754,55 @@ function preserveCompactionReplayWindow(source, windowed, model, identity) {
|
|
|
2123
1754
|
providerReplay
|
|
2124
1755
|
}, ...windowed.filter((message) => suffix.has(message))];
|
|
2125
1756
|
}
|
|
2126
|
-
function
|
|
2127
|
-
|
|
2128
|
-
|
|
1757
|
+
function estimateResponsesContent(content, estimate, text) {
|
|
1758
|
+
if (typeof content === "string") return text(content);
|
|
1759
|
+
if (!Array.isArray(content)) return estimate.json(content);
|
|
1760
|
+
return content.reduce((tokens, block) => {
|
|
1761
|
+
if (!isRecord(block)) return tokens + estimate.json(block);
|
|
1762
|
+
if ((block.type === "input_text" || block.type === "output_text") && typeof block.text === "string") {
|
|
1763
|
+
const { text: value, ...metadata } = block;
|
|
1764
|
+
return tokens + text(value) + estimate.json(metadata);
|
|
1765
|
+
}
|
|
1766
|
+
if (block.type === "input_image") {
|
|
1767
|
+
const { image_url: url, ...metadata } = block;
|
|
1768
|
+
return tokens + estimate.image() + estimate.json(typeof url === "string" && url.startsWith("data:") ? metadata : block);
|
|
1769
|
+
}
|
|
1770
|
+
return tokens + estimate.json(block);
|
|
1771
|
+
}, 0);
|
|
1772
|
+
}
|
|
1773
|
+
function estimateResponsesInput(input, estimate) {
|
|
1774
|
+
return input.reduce((tokens, entry) => {
|
|
1775
|
+
if (!isRecord(entry)) return tokens + estimate.json(entry);
|
|
1776
|
+
if (entry.type === "compaction" && typeof entry.encrypted_content === "string") {
|
|
2129
1777
|
const { encrypted_content, ...metadata } = entry;
|
|
2130
1778
|
return tokens + estimate.text(encrypted_content) + estimate.json(metadata);
|
|
2131
1779
|
}
|
|
2132
|
-
|
|
2133
|
-
|
|
2134
|
-
|
|
2135
|
-
|
|
2136
|
-
|
|
2137
|
-
}
|
|
2138
|
-
|
|
2139
|
-
|
|
2140
|
-
|
|
2141
|
-
}
|
|
2142
|
-
return sum + estimate.json(block);
|
|
2143
|
-
}, 0);
|
|
1780
|
+
if (entry.type === "message") {
|
|
1781
|
+
const { content, ...metadata } = entry;
|
|
1782
|
+
return tokens + estimate.json(metadata) + estimateResponsesContent(content, estimate, (value) => estimate.text(value));
|
|
1783
|
+
}
|
|
1784
|
+
if (entry.type === "function_call_output" || entry.type === "custom_tool_call_output") {
|
|
1785
|
+
const { output, ...metadata } = entry;
|
|
1786
|
+
return tokens + estimate.json(metadata) + estimateResponsesContent(output, estimate, (value) => estimate.toolResult ? estimate.toolResult(value) : estimate.text(value));
|
|
1787
|
+
}
|
|
1788
|
+
return tokens + estimate.json(entry);
|
|
2144
1789
|
}, 0);
|
|
2145
1790
|
}
|
|
2146
1791
|
/** Estimate the canonical prefix and its tail once, independent of unbound usage snapshots. */
|
|
2147
|
-
function resolveCompactionReplayPressure(messages, model, identity, estimate) {
|
|
1792
|
+
function resolveCompactionReplayPressure(messages, model, identity, estimate, systemPrompt) {
|
|
2148
1793
|
const checkpoint = resolveCompactionSource(messages, model, identity);
|
|
2149
1794
|
if (!checkpoint) return;
|
|
2150
1795
|
if (checkpoint.family === "responses" && checkpoint.mode === "refresh-required") throw new CompactionReplayRefreshRequiredError();
|
|
2151
1796
|
const ownerIndex = messages.findIndex((message) => message === checkpoint.owner);
|
|
2152
1797
|
const owner = messages[ownerIndex];
|
|
2153
1798
|
if (!owner) return;
|
|
2154
|
-
const prefixTokens = checkpoint.family === "anthropic" ? estimate.text(checkpoint.summary) : checkpoint.mode === "complete-window" ?
|
|
1799
|
+
const prefixTokens = checkpoint.family === "anthropic" ? estimate.text(checkpoint.summary) : checkpoint.mode === "complete-window" ? estimateResponsesInput(checkpoint.output, estimate) : estimate.text(checkpoint.item.encrypted_content);
|
|
1800
|
+
const measuredBoundary = checkpoint.family === "responses" ? resolveResponsesContextUsageBoundary(messages, model, identity, systemPrompt) : void 0;
|
|
1801
|
+
if (measuredBoundary) return {
|
|
1802
|
+
messages: [],
|
|
1803
|
+
prefixTokens: measuredBoundary.totalTokens + estimateResponsesInput(measuredBoundary.suffix, estimate),
|
|
1804
|
+
measuredTokens: measuredBoundary.totalTokens
|
|
1805
|
+
};
|
|
2155
1806
|
const { contextUsage: _staleContextUsage, ...usage } = checkpoint.owner.usage;
|
|
2156
1807
|
const tail = [];
|
|
2157
1808
|
for (const message of messages.slice(ownerIndex + 1)) {
|
|
@@ -2322,6 +1973,18 @@ function buildTransportAwareSimpleStreamFn(model, ctx) {
|
|
|
2322
1973
|
}
|
|
2323
1974
|
//#endregion
|
|
2324
1975
|
//#region packages/ai/src/transports/simple-completion-transport.ts
|
|
1976
|
+
/**
|
|
1977
|
+
* Simple completion transport preparation.
|
|
1978
|
+
*
|
|
1979
|
+
* Registers provider-specific stream functions and rewrites models that need OpenClaw-managed transport semantics.
|
|
1980
|
+
*/
|
|
1981
|
+
/** Standalone completions have no durable session, but may require routing identity. */
|
|
1982
|
+
function prepareHeadersForSimpleCompletion(model, options) {
|
|
1983
|
+
return resolveOpencodeSessionHeaders(model, {
|
|
1984
|
+
...options,
|
|
1985
|
+
sessionId: options?.sessionId || randomUUID()
|
|
1986
|
+
});
|
|
1987
|
+
}
|
|
2325
1988
|
const PROVIDER_SIMPLE_COMPLETION_API_PREFIX = "openclaw-provider-simple:";
|
|
2326
1989
|
const PROVIDER_STREAM_API_PREFIX = "openclaw-provider-stream:";
|
|
2327
1990
|
const INVALID_CODEX_BASE_URL_MESSAGE = "OpenAI Codex Responses baseUrl must not include query parameters or fragments";
|
|
@@ -2416,7 +2079,9 @@ function prepareCodexSimpleTransportModel(registry, model, cfg) {
|
|
|
2416
2079
|
if (!registerCustomApi(registry, api, streamFn)) return;
|
|
2417
2080
|
return projectModel(transportModel, { api });
|
|
2418
2081
|
}
|
|
2419
|
-
function
|
|
2082
|
+
function resolveModelTransportSentinels(model, boundary) {
|
|
2083
|
+
const host = getAiTransportHost();
|
|
2084
|
+
if (host.unwrapModelTransportSentinels) return host.unwrapModelTransportSentinels(model, boundary);
|
|
2420
2085
|
const headers = resolveAiTransportHeaderSentinels(model.headers);
|
|
2421
2086
|
return headers === model.headers ? model : projectModel(model, { headers });
|
|
2422
2087
|
}
|
|
@@ -2425,7 +2090,7 @@ function wrapPluginProviderStream(streamFn) {
|
|
|
2425
2090
|
const host = getAiTransportHost();
|
|
2426
2091
|
const apiKey = options?.apiKey ? host.resolveSecretSentinel(options.apiKey) : options?.apiKey;
|
|
2427
2092
|
const headers = resolveAiTransportHeaderSentinels(options?.headers);
|
|
2428
|
-
return streamFn(
|
|
2093
|
+
return streamFn(resolveModelTransportSentinels(model, "plugin simple-completion stream egress"), context, apiKey === options?.apiKey && headers === options?.headers ? options : {
|
|
2429
2094
|
...options,
|
|
2430
2095
|
apiKey,
|
|
2431
2096
|
headers
|
|
@@ -2433,7 +2098,7 @@ function wrapPluginProviderStream(streamFn) {
|
|
|
2433
2098
|
};
|
|
2434
2099
|
}
|
|
2435
2100
|
function prepareProviderStreamModel(params) {
|
|
2436
|
-
const pluginModel =
|
|
2101
|
+
const pluginModel = resolveModelTransportSentinels(params.model, "plugin simple-completion stream construction");
|
|
2437
2102
|
const providerStreamFn = getAiTransportHost().plugin.resolveProviderStream({
|
|
2438
2103
|
provider: params.model.provider,
|
|
2439
2104
|
config: params.cfg,
|
|
@@ -2475,4 +2140,4 @@ function prepareModelForSimpleCompletion(params) {
|
|
|
2475
2140
|
return applyProviderSimpleCompletionWrapper(apiRegistry, model, cfg);
|
|
2476
2141
|
}
|
|
2477
2142
|
//#endregion
|
|
2478
|
-
export { CompactionReplayRefreshRequiredError, GEMINI_THOUGHT_SIGNATURE_VALIDATOR_SKIP, MALFORMED_STREAMING_FRAGMENT_ERROR_MESSAGE, applyAnthropicContextManagementToRequest, applyAnthropicEphemeralCacheControlMarkers, applyAnthropicPayloadPolicyToParams, applyAnthropicRequestCacheControl, applyCompletionsAnthropicCacheControl, applyOpenAIResponsesPayloadPolicy, assertCodeModeResponsesToolSurface, assignTransportErrorDetails, buildAnthropicSystemBlocks, buildOpenAIClientHeaders, buildOpenAICompletionsParams, buildOpenAISdkClientOptions, buildOpenAISdkRequestOptions, buildTransportAwareSimpleStreamFn, canonicalizeMaxTokensParam, captureOpenAIResponsesCompaction, coerceTransportToolCallArguments, consumeGoogleGenerateContentStream, convertGoogleTools, copyProviderAcceptanceObserver, createAnthropicMessagesTransportStreamFn, createAzureOpenAIResponsesTransportStreamFn, createBoundaryAwareStreamFnForModel, createDeepSeekTextFilter, createEmptyTransportUsage, createModelStreamCooperativeScheduler, createOpenAICompletionsTransportStreamFn, createOpenAIProviderAcceptanceHook, createOpenAIResponseHook, createOpenAIResponsesTransportStreamFn, createOpenClawTransportStreamFnForModel, createTransportAwareStreamFnForModel, createWritableTransportEventStream, detectOpenAICompletionsCompat, emitModelTransportDebug, enforceCodeModeResponsesToolSurface, failTransportStream, filterCodeModePayloadTools, finalizeTerminalToolCallArguments, finalizeTransportStream, flattenCompletionMessagesToStringContent, formatModelTransportDebugBaseUrl, formatModelTransportDebugUrl, getCompat, googleFlashSupportsMinimalThinking, hasOpenAICompatibleConversationTurn, isAnthropicServerToolClearingEnabled, isCodeModeModelVisibleToolName, isCompactionReplayCheckpoint, isDirectAnthropicModel, isNativeOpenAIEndpoint, isOpenAICodexResponsesModel, isOpenAICompletionsThinkingEnabled, log, logAnthropicContextEdits, measureUtf8AppendBytes, mergeTransportHeaders, mergeTransportMetadata, normalizeCodexResponsesBaseUrlForOpenAISdk, notifyProviderHttpMetadata, notifyProviderHttpResponse, notifyProviderStreamOpened, parseJsonObjectPreservingUnsafeIntegers, parseJsonPreservingUnsafeIntegers, parseOpenAICompletionsUsage, parseTerminalToolCallArguments, prepareModelForSimpleCompletion, prepareTransportAwareSimpleModel, preserveCompactionReplayWindow, projectGoogleMessages, quoteUnsafeIntegerLiterals, readCodeModePayloadToolName, readOpenAICompletionsContentDeltas, readOpenAICompletionsReasoningBatch, replaceCompactionReplayOwnerContent, requestPreparedOpenAIResponsesCompaction, requiresCompactionReplayRefresh, requiresGoogleToolCallId, resolveAnthropicCacheOptions, resolveAnthropicContextManagementBetaHeader, resolveAnthropicEphemeralCacheControl, resolveAnthropicMessagesUrl, resolveAnthropicPayloadPolicy, resolveAnthropicServerCompactionPlan, resolveCodeModeResponsesVisibleToolNames, resolveCompactionReplayEligibility, resolveCompactionReplayPressure, resolveMaxTokensParam, resolveModelPayloadDebugMode, resolveModelSseDebugMode, resolveOpenAIClientBaseUrl, resolveOpenAICompletionsCompat, resolveOpenAIPromptCacheKeySupport, resolveOpenAIReasoningEffortMap, resolveOpenAIResponsesCompactEndpointPlan, resolveOpenAIResponsesPayloadPolicy, resolveOpenAIResponsesServerCompactionPlan, resolveOpenAIStrictToolFlagWithDiagnostics, resolvePromptCacheKey, resolveReplayableResponsesMessageId, resolveTransportAwareSimpleApi, sanitizeNonEmptyTransportPayloadText, sanitizeResponsesImagePayload, sanitizeTransportPayloadText, sortPromptCacheToolsByName as sortTransportToolsByName, stripCompactionReplayCheckpoint, stripCompactionReplayCheckpointInPlace, stripCompletionMessagesToRoleContent, throwIfModelStreamAborted, transportAbortError, usesNativeOpenAICodexResponsesBackend, withProviderAcceptanceObserver, withProviderResponseHook };
|
|
2143
|
+
export { CompactionReplayRefreshRequiredError, GEMINI_THOUGHT_SIGNATURE_VALIDATOR_SKIP, IncompleteToolCallError, MALFORMED_STREAMING_FRAGMENT_ERROR_MESSAGE, applyAnthropicContextManagementToRequest, applyAnthropicEphemeralCacheControlMarkers, applyAnthropicPayloadPolicyToParams, applyAnthropicRequestCacheControl, applyCompletionsAnthropicCacheControl, applyOpenAIResponsesPayloadPolicy, assertCodeModeResponsesToolSurface, assignTransportErrorDetails, buildAnthropicSystemBlocks, buildOpenAIClientHeaders, buildOpenAICompletionsParams, buildOpenAISdkClientOptions, buildOpenAISdkRequestOptions, buildTransportAwareSimpleStreamFn, canonicalizeMaxTokensParam, captureOpenAIResponsesCompaction, coerceTransportToolCallArguments, consumeGoogleGenerateContentStream, convertGoogleTools, copyProviderAcceptanceObserver, createAnthropicMessagesTransportStreamFn, createAzureOpenAIResponsesTransportStreamFn, createBoundaryAwareStreamFnForModel, createDeepSeekTextFilter, createEmptyTransportUsage, createModelStreamCooperativeScheduler, createOpenAICompletionsTransportStreamFn, createOpenAIProviderAcceptanceHook, createOpenAIResponseHook, createOpenAIResponsesTransportStreamFn, createOpenClawTransportStreamFnForModel, createResponseModelTracker, createTransportAwareStreamFnForModel, createWritableTransportEventStream, detectOpenAICompletionsCompat, emitModelTransportDebug, enforceCodeModeResponsesToolSurface, failTransportStream, filterCodeModePayloadTools, finalizeTerminalToolCallArguments, finalizeTransportStream, flattenCompletionMessagesToStringContent, formatModelTransportDebugBaseUrl, formatModelTransportDebugUrl, getCompat, googleFlashSupportsMinimalThinking, hasOpenAICompatibleConversationTurn, isAnthropicServerToolClearingEnabled, isCodeModeModelVisibleToolName, isCompactionReplayCheckpoint, isDirectAnthropicModel, isNativeOpenAIEndpoint, isOpenAICodexResponsesModel, isOpenAICompletionsThinkingEnabled, log, logAnthropicContextEdits, measureUtf8AppendBytes, mergeTransportHeaders, mergeTransportMetadata, normalizeCodexResponsesBaseUrlForOpenAISdk, notifyProviderHttpMetadata, notifyProviderHttpResponse, notifyProviderStreamOpened, parseJsonObjectPreservingUnsafeIntegers, parseJsonPreservingUnsafeIntegers, parseOpenAICompletionsUsage, parseTerminalToolCallArguments, prepareHeadersForSimpleCompletion, prepareModelForSimpleCompletion, prepareTransportAwareSimpleModel, preserveCompactionReplayWindow, projectGoogleMessages, quoteUnsafeIntegerLiterals, readCodeModePayloadToolName, readOpenAICompletionsContentDeltas, readOpenAICompletionsReasoningBatch, replaceCompactionReplayOwnerContent, requestPreparedOpenAIResponsesCompaction, requiresCompactionReplayRefresh, requiresGoogleToolCallId, resolveAnthropicCacheOptions, resolveAnthropicContextManagementBetaHeader, resolveAnthropicEphemeralCacheControl, resolveAnthropicMessagesUrl, resolveAnthropicPayloadPolicy, resolveAnthropicServerCompactionPlan, resolveCodeModeResponsesVisibleToolNames, resolveCompactionReplayEligibility, resolveCompactionReplayPressure, resolveMaxTokensParam, resolveModelPayloadDebugMode, resolveModelSseDebugMode, resolveOpenAIClientBaseUrl, resolveOpenAICompletionsCompat, resolveOpenAIPromptCacheKeySupport, resolveOpenAIReasoningEffortMap, resolveOpenAIResponsesCompactEndpointPlan, resolveOpenAIResponsesPayloadPolicy, resolveOpenAIResponsesServerCompactionPlan, resolveOpenAIStrictToolFlagWithDiagnostics, resolvePromptCacheKey, resolveReplayableResponsesMessageId, resolveTransportAwareSimpleApi, sanitizeNonEmptyTransportPayloadText, sanitizeResponsesImagePayload, sanitizeTransportPayloadText, sortPromptCacheToolsByName as sortTransportToolsByName, stripCompactionReplayCheckpoint, stripCompactionReplayCheckpointInPlace, stripCompletionMessagesToRoleContent, throwIfModelStreamAborted, transportAbortError, usesNativeOpenAICodexResponsesBackend, withProviderAcceptanceObserver, withProviderResponseHook };
|