@openclaw/ai 2026.9.8 → 2026.10.1-beta.1
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 +4 -1
- package/dist/{anthropic-CTXJlfnS.mjs → anthropic-CZv6XFER.mjs} +52 -147
- package/dist/{anthropic-payload-policy-NIPVYXPq.d.mts → anthropic-payload-policy-BhCcgNdm.d.mts} +7 -4
- package/dist/{anthropic-stream-reducer-DrsBCsFY.mjs → anthropic-stream-reducer-BQ1tjd7x.mjs} +369 -233
- package/dist/{api-registry-D-nbmSqr.d.mts → api-registry-DpU0Rj-I.d.mts} +4 -4
- package/dist/{provider-transcript-transform-DjA5Fk2P.mjs → assistant-output-OLm-Oln0.mjs} +17 -17
- package/dist/{assistant-text-phase-C20rxWwP.mjs → assistant-text-phase-Bl1aDCB7.mjs} +2 -8
- package/dist/{azure-openai-responses-BBxv4QVI.mjs → azure-openai-responses-DH7bd3QT.mjs} +12 -17
- package/dist/{azure-openai-responses-client-compat-C7K7QfUE.mjs → azure-openai-responses-client-compat-D0dvJMbZ.mjs} +3 -10
- package/dist/{base64-C1PsYcRQ.mjs → base64-C8CdcsjU.mjs} +3 -45
- package/dist/cloudflare-5qSGvIUH.mjs +39 -0
- package/dist/{diagnostics-CJaB6g8J.mjs → diagnostics-Caj-4RBA.mjs} +19 -37
- package/dist/diagnostics.d.mts +4 -4
- package/dist/diagnostics.mjs +2 -2
- package/dist/{event-stream-vd9UnCAU.mjs → event-stream-C5AbCAaZ.mjs} +29 -1
- package/dist/event-stream-DqDQWqiy.d.mts +1 -0
- package/dist/{event-stream-DOPFYVqs.d.mts → event-stream-DrRM_90c.d.mts} +1 -1
- package/dist/event-stream.d.mts +2 -2
- package/dist/event-stream.mjs +1 -1
- package/dist/{github-copilot-request-facts-BTEBMeOv.mjs → github-copilot-request-facts-DEE6gcB9.mjs} +3 -1
- package/dist/{google-B3HEK0Ag.mjs → google-1WLOtb8w.mjs} +12 -9
- package/dist/{google-interactions-vMlEfPAA.mjs → google-interactions-wrnE6MLw.mjs} +39 -49
- package/dist/{google-messages-Dz2dAnGo.mjs → google-messages-BwPPycw6.mjs} +11 -17
- package/dist/{google-shared-B58i3c8H.mjs → google-shared-Eql1OMPU.mjs} +5 -6
- package/dist/{google-vertex-DYFXzEbh.mjs → google-vertex-0LrlRoO3.mjs} +11 -11
- package/dist/{host-rxlNaBwm.d.mts → host-BinBeGcQ.d.mts} +12 -4
- package/dist/{host-DwBmNMCC.mjs → host-DCW52iHe.mjs} +57 -9
- package/dist/{host-policy-wK-ay_RK.mjs → host-policy-B3jc4Rpn.mjs} +9 -2
- package/dist/{index-D6KsSE74.d.mts → index-a8e_oKnu.d.mts} +7 -5
- package/dist/index.d.mts +23 -7
- package/dist/index.mjs +7 -7
- package/dist/internal/anthropic.d.mts +6 -6
- package/dist/internal/anthropic.mjs +5 -5
- package/dist/internal/google-model-family.mjs +1 -1
- package/dist/internal/openai-completions-compat.d.mts +1 -1
- package/dist/internal/openai-completions-compat.mjs +1 -1
- package/dist/internal/openai-responses-payload-policy.d.mts +1 -1
- package/dist/internal/openai-responses-payload-policy.mjs +2 -2
- package/dist/internal/openai.d.mts +14 -10
- package/dist/internal/openai.mjs +12 -12
- package/dist/internal/runtime.d.mts +18 -9
- package/dist/internal/runtime.mjs +9 -9
- package/dist/internal/shared.d.mts +6 -4
- package/dist/internal/shared.mjs +6 -6
- package/dist/internal/tool-schema.mjs +1 -1
- package/dist/json-schema-Bp07Qui3.mjs +22 -0
- package/dist/{llm-request-activity-BjtkplhG.mjs → llm-request-activity-D8f_oxHj.mjs} +1 -2
- package/dist/{mistral-7wDWcjfF.mjs → mistral-DSt4vQAO.mjs} +18 -29
- package/dist/number-coercion-V8-BhME4.mjs +47 -0
- package/dist/{openai-chatgpt-responses-Bc7NZrQR.mjs → openai-chatgpt-responses-BC2x0Oqx.mjs} +215 -164
- package/dist/openai-completions-DNyHnXKg.mjs +25 -0
- package/dist/{openai-completions-compat-qJjmqQ71.d.mts → openai-completions-compat-BYdYpXhU.d.mts} +3 -3
- package/dist/{openai-completions-compat-BJf57ZxN.mjs → openai-completions-compat-BdmlhD4u.mjs} +30 -23
- package/dist/{openai-completions-stream-dju_5F3P.mjs → openai-completions-transport-DWM2mQDB.mjs} +389 -76
- package/dist/{openai-prompt-cache-CouErLh7.d.mts → openai-prompt-cache-45-AH_xv.d.mts} +2 -2
- package/dist/{openai-prompt-cache-BTMs80_O.mjs → openai-prompt-cache-I8YQTzf8.mjs} +1 -1
- package/dist/{openai-responses-compaction-replay-DiYn-gFM.d.mts → openai-responses-compaction-replay-BClApUIf.d.mts} +4 -4
- package/dist/{openai-responses-compaction-window-CYGCjAQz.mjs → openai-responses-compaction-window-m878aVpU.mjs} +25 -83
- package/dist/{openai-reasoning-effort-C_0p3psG.mjs → openai-responses-contracts-BKu8O7l4.mjs} +103 -4
- package/dist/{openai-responses-contracts-D1iZ0njF.d.mts → openai-responses-contracts-Br5IIw_h.d.mts} +16 -5
- package/dist/openai-responses-prompt-observer-internal-CCg7B6l4.mjs +32 -0
- package/dist/{openai-responses-shared-CIEHiKx7.mjs → openai-responses-shared-C7oVyjED.mjs} +297 -312
- package/dist/{openai-responses-terminal-usage-BE7lf7nW.d.mts → openai-responses-terminal-usage-DgImcyJu.d.mts} +2 -2
- package/dist/{openai-responses-DbPe3-Py.mjs → openai-responses-uZ5oWSp7.mjs} +12 -21
- package/dist/{openai-tool-schema-vsl-cE-n.mjs → openai-tool-schema-DYNePiF8.mjs} +66 -36
- package/dist/{openai-transport-params-DyFJ4cgR.mjs → openai-transport-params-JFsnIyto.mjs} +25 -30
- package/dist/openai-web-search-tools-Cfu0uLyN.mjs +14 -0
- package/dist/{positive-integer-CjN5OJbH.mjs → positive-integer-CwLi8LUL.mjs} +1 -1
- package/dist/{provider-error-CwT_j2v0.mjs → provider-error-DQBE1bUQ.mjs} +17 -28
- package/dist/{provider-options-Df7ov0K1.d.mts → provider-options-D5ABCV_l.d.mts} +2 -2
- package/dist/{provider-replay-context-Bs5aWE1d.mjs → provider-replay-context-C7Bmi84a.mjs} +6 -2
- package/dist/{provider-transport-turn-state-Dw7OtYUs.mjs → provider-transport-turn-state-_M2kLdUE.mjs} +25 -3
- package/dist/{provider-types-d4XnoZMd.d.mts → provider-types-F8Mqc9Ma.d.mts} +3 -3
- package/dist/provider-types.d.mts +6 -6
- package/dist/providers.d.mts +2 -2
- package/dist/providers.mjs +14 -26
- package/dist/{reasoning-tag-text-partitioner-B6FIIBt6.mjs → reasoning-tag-text-partitioner-Ju9VpUGl.mjs} +23 -37
- package/dist/required-api-key-D4kn3252.mjs +9 -0
- package/dist/sanitize-unicode-CjDG6jJx.d.mts +5 -0
- package/dist/{session-affinity-Bcunsn4I.mjs → session-affinity-DA4WHv1h.mjs} +2 -6
- package/dist/session-resources-D1wgDQ8C.mjs +40 -0
- package/dist/{simple-options-BkDPMuxw.mjs → simple-options-BkKTXxhp.mjs} +7 -11
- package/dist/{src-H4aXcFuX.mjs → src-B0NIt2UK.mjs} +7 -4
- package/dist/stream-DSdzKsDK.mjs +275 -0
- package/dist/{stream-first-event-timeout-B9o0S4SZ.mjs → stream-first-event-timeout-D9ZmL_s9.mjs} +3 -3
- package/dist/{string-coerce-fsri9iCu.mjs → string-coerce-CtgOVOSv.mjs} +5 -1
- package/dist/{string-normalization-J9ZiLfGO.mjs → string-normalization-PN10hf6d.mjs} +1 -1
- package/dist/{transport-utils-CqXzku3R.mjs → text-signature-MLwfi6fq.mjs} +18 -18
- package/dist/{transport-stream-shared-yYhXa4kX.d.mts → transport-stream-shared-BcAKh2XH.d.mts} +6 -19
- package/dist/{transport-stream-shared-BU5pwY6W.mjs → transport-stream-shared-CxXXz_Dd.mjs} +171 -56
- package/dist/transports.d.mts +22 -23
- package/dist/transports.mjs +251 -495
- package/dist/types-BuiEBM3u.d.mts +1 -0
- package/dist/types-CQc6JNG4.mjs +69 -0
- package/dist/{types-CLLR3eB4.d.mts → types-DvzmWW8J.d.mts} +58 -6
- package/dist/types.d.mts +6 -6
- package/dist/types.mjs +5 -5
- package/dist/usage-CJH5D6Ea.mjs +19 -0
- package/dist/{validation-Cat2wQsc.d.mts → validation-B3lQt_VE.d.mts} +1 -1
- package/dist/{validation-BFZc40Ig.mjs → validation-DbqlIfDn.mjs} +15 -30
- package/dist/validation.d.mts +1 -1
- package/dist/validation.mjs +1 -1
- package/package.json +4 -4
- package/dist/cache-retention-0x979a5V.mjs +0 -12
- package/dist/event-stream-CMQfX_yr.d.mts +0 -1
- package/dist/github-copilot-headers-B37TB3rB.mjs +0 -30
- package/dist/openai-completions-CHnwIV-W.mjs +0 -188
- package/dist/openai-provider-client-G8Otsq2Q.mjs +0 -24
- package/dist/openai-responses-contracts-CLxnqS9p.mjs +0 -81
- package/dist/openai-responses-prompt-observer-internal-BX3QTNSv.mjs +0 -198
- package/dist/sanitize-unicode-BZiVbGwK.d.mts +0 -24
- package/dist/session-resources-CkR4WWy1.mjs +0 -21
- package/dist/stream-DDsCBgd-.mjs +0 -68
- package/dist/types-CB-_vNyI.d.mts +0 -1
- package/dist/types-LFWwv0cF.mjs +0 -8
package/dist/transports.mjs
CHANGED
|
@@ -1,144 +1,50 @@
|
|
|
1
|
-
import { S as supportsClaudeAdaptiveThinking
|
|
1
|
+
import { S as supportsClaudeAdaptiveThinking } from "./src-B0NIt2UK.mjs";
|
|
2
2
|
import { o as isRecord } from "./record-coerce-CNDovvft.mjs";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import { a as
|
|
8
|
-
import {
|
|
9
|
-
import { r as
|
|
10
|
-
import {
|
|
11
|
-
import { t as
|
|
12
|
-
import {
|
|
13
|
-
import { D as
|
|
14
|
-
import {
|
|
3
|
+
import { n as normalizeLowercaseStringOrEmpty } from "./string-coerce-CtgOVOSv.mjs";
|
|
4
|
+
import { T as usesClaudeStreamingRefusalContract, _ as buildAnthropicClaudeCodeIdentity, a as resolveAiTransportHeaderSentinels, b as prepareClaudeNoPrefillRequestContext, r as getAiTransportHost } from "./host-DCW52iHe.mjs";
|
|
5
|
+
import { A as resolveOpenAIThinkingApi, D as supportsOpenAITemperature, b as isOpenAIGpt6Model, d as OpenAIResponsesWebSocketSafeRetryError, g as responsesServiceTierObserver, i as OPENAI_RESPONSES_APIS, l as OpenAIResponsesWebSocketPostDispatchError, m as parseOpenAIResponsesWebSocketServerError, r as OPENAI_CODEX_RESPONSES_DEFAULT_INSTRUCTIONS, t as AZURE_RESPONSES_FIRST_EVENT_TIMEOUT_MS, u as OpenAIResponsesWebSocketPreDispatchError } from "./openai-responses-contracts-BKu8O7l4.mjs";
|
|
6
|
+
import { n as getSessionResourceOwnerId, r as registerSessionResourceCleanup } from "./session-resources-D1wgDQ8C.mjs";
|
|
7
|
+
import { a as redactDiagnosticText, o as truncateUtf16Safe, s as stableStringify } from "./provider-error-DQBE1bUQ.mjs";
|
|
8
|
+
import { r as resolveOpenAIPromptCacheParams } from "./openai-prompt-cache-I8YQTzf8.mjs";
|
|
9
|
+
import { a as resolveModelSseDebugMode, i as resolveModelPayloadDebugMode, n as formatModelTransportDebugUrl, r as emitModelTransportDebug, t as formatModelTransportDebugBaseUrl, u as hasOnlyResponsesFunctionTools, v as toErrorObject } from "./diagnostics-Caj-4RBA.mjs";
|
|
10
|
+
import { a as readResponseTextSnippet, i as isCodeModeModelVisibleToolName, n as MALFORMED_STREAMING_FRAGMENT_ERROR_MESSAGE, s as resolveModelHeaderSentinels } from "./text-signature-MLwfi6fq.mjs";
|
|
11
|
+
import { a as resolveOpenAIPromptCacheKeySupport, c as resolveOpenAIResponsesTextFormat, i as resolveOpenAICompletionsCompat, n as isNativeOpenAIEndpoint, o as usesNativeOpenAICodexResponsesBackend, r as isOpenAICodexResponsesModel, t as detectOpenAICompletionsCompat } from "./openai-completions-compat-BdmlhD4u.mjs";
|
|
12
|
+
import { t as buildGuardedModelFetch } from "./host-policy-B3jc4Rpn.mjs";
|
|
13
|
+
import { A as buildAnthropicSystemBlocks, C as isAnthropicReplayRejection, D as applyAnthropicEphemeralCacheControlMarkers, E as applyAnthropicContextManagementToRequest, F as resolveAnthropicEphemeralCacheControl, I as resolveAnthropicPayloadPolicy, J as usesFoundryBearerAuth, K as isAnthropicOAuthApiKey, L as resolveAnthropicRequestBetaHeader, M as isDirectAnthropicModel, N as logAnthropicContextEdits, O as applyAnthropicPayloadPolicyToParams, P as resolveAnthropicCacheOptions, R as resolveAnthropicServerCompactionPlan, T as suppressAnthropicCompaction, d as resolveAnthropicTransportOptions, j as isAnthropicServerToolClearingEnabled, k as applyAnthropicRequestCacheControl, l as buildAnthropicRequest, q as omitFoundryBearerCredentialHeaders, t as consumeAnthropicStream, u as prepareAnthropicRequest, w as resolveNewestAnthropicCompaction, z as supportsAnthropicServerSideFallback } from "./anthropic-stream-reducer-BQ1tjd7x.mjs";
|
|
14
|
+
import { i as resolveCacheRetention } from "./cloudflare-5qSGvIUH.mjs";
|
|
15
|
+
import { C as parseJsonObjectPreservingUnsafeIntegers, M as racePromiseWithAbortSignal, S as withProviderResponseHook, T as quoteUnsafeIntegerLiterals, _ as sanitizeNonEmptyTransportPayloadText, a as createEmptyTransportUsage, b as transportAbortError, c as failTransportStream, d as iterateModelStream, f as mergeTransportHeaders, g as parseTerminalToolCallArguments, h as notifyProviderStreamOpened, i as copyProviderAcceptanceObserver, j as createAbortError$1, l as finalizeTerminalToolCallArguments, m as notifyProviderHttpResponse, n as assignTransportErrorDetails, o as createModelStreamCooperativeScheduler, p as notifyProviderHttpMetadata, r as coerceTransportToolCallArguments, s as createWritableTransportEventStream, t as IncompleteToolCallError, u as finalizeTransportStream, v as sanitizeTransportPayloadText, w as parseJsonPreservingUnsafeIntegers, x as withProviderAcceptanceObserver, y as throwIfModelStreamAborted } from "./transport-stream-shared-CxXXz_Dd.mjs";
|
|
16
|
+
import { C as stripSystemPromptCacheBoundary, D as sortPromptCacheToolsByName, l as codeModeToolSurfaceObserver, s as prepareModelRequestBody } from "./simple-options-BkKTXxhp.mjs";
|
|
17
|
+
import { A as redactIdentifier, C as log, D as readOpenAICompletionsReasoningBatch, E as readOpenAICompletionsContentDeltas, O as resolveOpenAIClientBaseUrl, S as isOpenAICompletionsThinkingEnabled, T as parseOpenAICompletionsUsage, _ as resolveOpenAIReasoningEffortMap, a as enforceCodeModeResponsesToolSurface, b as createOpenAIResponseHook, c as readCodeModePayloadToolName, g as resolveOpenAISimpleReasoningEffort, h as resolveOpenAIRequestReasoning, i as buildOpenAISdkRequestOptions, j as sha256Hex, k as resolvePromptCacheKey, l as resolveCodeModeResponsesVisibleToolNames, m as reconcileOpenAIResponsesToolChoice, 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 measureUtf8AppendBytes, x as createResponseModelTracker, y as createOpenAIProviderAcceptanceHook } from "./openai-transport-params-JFsnIyto.mjs";
|
|
15
18
|
import { n as getEnvApiKey } from "./env-api-keys-CyX4VKGO.mjs";
|
|
16
19
|
import { t as createDeferredEventBuffer } from "./deferred-event-buffer-DAvyP7qA.mjs";
|
|
17
|
-
import { n as providerReplayContextMatches, t as buildProviderReplayContext } from "./provider-replay-context-
|
|
18
|
-
import {
|
|
19
|
-
import { n as
|
|
20
|
-
import {
|
|
21
|
-
import {
|
|
22
|
-
import {
|
|
23
|
-
import { i as getFirstStreamEventTimeoutMs, r as getFirstStreamEventTimeoutHandler, t as createFirstStreamEventAbortController } from "./stream-first-event-timeout-
|
|
24
|
-
import {
|
|
25
|
-
import {
|
|
26
|
-
import {
|
|
27
|
-
import {
|
|
28
|
-
import {
|
|
29
|
-
import { n as registerSessionResourceCleanup } from "./session-resources-CkR4WWy1.mjs";
|
|
30
|
-
import { a as sanitizeOpenAICodexResponsesParams, n as buildOpenAIResponsesCompactSystemMessage, r as buildOpenAIResponsesParams, t as createResponsesPromptEgressObserver } from "./openai-responses-prompt-observer-internal-BX3QTNSv.mjs";
|
|
20
|
+
import { n as isProviderReplayContext, r as providerReplayContextMatches, t as buildProviderReplayContext } from "./provider-replay-context-C7Bmi84a.mjs";
|
|
21
|
+
import { t as createAssistantOutput } from "./assistant-output-OLm-Oln0.mjs";
|
|
22
|
+
import { n as resolveOpencodeSessionHeaders } from "./session-affinity-DA4WHv1h.mjs";
|
|
23
|
+
import { a as flattenCompletionMessagesToStringContent, c as hasOpenAICompatibleConversationTurn, d as createDeepSeekTextFilter, l as canonicalizeMaxTokensParam, o as stripCompletionMessagesToRoleContent, r as buildOpenAICompletionsParams, s as applyCompletionsAnthropicCacheControl, t as createOpenAICompletionsTransportStreamFn, u as resolveMaxTokensParam } from "./openai-completions-transport-DWM2mQDB.mjs";
|
|
24
|
+
import { a as googleFlashSupportsMinimalThinking, i as consumeGoogleGenerateContentStream, n as projectGoogleMessages, r as requiresGoogleToolCallId, t as convertGoogleTools } from "./google-messages-BwPPycw6.mjs";
|
|
25
|
+
import { r as resolveProviderTransportTurnState, t as filterProviderTurnHeadersForExplicitOpencodeSession } from "./provider-transport-turn-state-_M2kLdUE.mjs";
|
|
26
|
+
import { i as getFirstStreamEventTimeoutMs, r as getFirstStreamEventTimeoutHandler, t as createFirstStreamEventAbortController } from "./stream-first-event-timeout-D9ZmL_s9.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-m878aVpU.mjs";
|
|
28
|
+
import { $ as OPENAI_RESPONSES_FUNCTION_CALL_ITEM_ID_RE, A as recordResponsesContextUsage, B as recordResponsesContinuationState, C as resolveAzureOpenAIApiVersion, D as safeDebugValue, E as logResponsesFailedNoDetails, F as convertResponsesMessages, G as replayResponsesReasoningUpdates, H as responsesContinuationPrefixFingerprint, I as readResponsesInputReplayState, J as buildOpenAIResponsesReasoningReplayMetadata, K as supportsResponsesReasoningUpdate, L as recordResponsesInputReplay, N as buildResponsesInputMessage, O as summarizeOpenAITransportError, Q as OPENAI_RESPONSES_CALL_ID_RE, R as responsesInputFingerprint, S as isInvalidEncryptedContentError, T as ResponsesStreamFailure, U as responsesContinuationRequestFingerprint, V as resolveResponsesContinuationRequest, W as isConfigurationUpdate, X as resolveNewestOpenAIResponsesCompactionReplay, Y as captureOpenAIResponsesCompaction, Z as suppressOpenAIResponsesCompaction, a as prepareResponsesTools, c as observeResponsesStream, et as OPENAI_RESPONSES_ID_MAX_LENGTH, it as resolveReplayableResponsesMessageId, j as resolveResponsesContextUsageBoundary, k as summarizeResponsesPayload, n as applyResponsesServiceTierPricing, nt as shouldNormalizeOpenAIResponsesToolCallId, q as CompactionReplayRefreshRequiredError, rt as splitOpenAIFunctionCallPairing, s as processResponsesStream, tt as normalizeOpenAIResponsesFunctionCallId, w as resolveNextResponsesEncryptedContentAttempt, x as createResponsesStreamWithEncryptedContentRetry, z as claimOpenAIResponsesHttpContinuation } from "./openai-responses-shared-C7oVyjED.mjs";
|
|
29
|
+
import { i as resolveAzureDeploymentNameFromMap, t as isOpenAICompatibleAzureResponsesBaseUrl } from "./azure-openai-responses-client-compat-D0dvJMbZ.mjs";
|
|
30
|
+
import { t as hasResponsesWebSearchTool } from "./openai-web-search-tools-Cfu0uLyN.mjs";
|
|
31
|
+
import { t as createResponsesPromptEgressObserver } from "./openai-responses-prompt-observer-internal-CCg7B6l4.mjs";
|
|
31
32
|
import { n as withResponsesRequestAcceptance, t as responsesRequestLifecycle } from "./openai-responses-request-lifecycle-Fsag-IGZ.mjs";
|
|
32
33
|
import { randomUUID } from "node:crypto";
|
|
33
34
|
import OpenAI, { AzureOpenAI } from "openai";
|
|
34
35
|
import { ResponsesWS } from "openai/resources/responses/ws.js";
|
|
35
|
-
//#region packages/ai/src/transports/anthropic-transport-options.ts
|
|
36
|
-
const ANTHROPIC_MESSAGES_DEFAULT_MAX_TOKENS = 4096;
|
|
37
|
-
const ANTHROPIC_MESSAGES_FALLBACK_CONTEXT_DIVISOR = 4;
|
|
38
|
-
function resolvePositiveAnthropicTokenLimit(value) {
|
|
39
|
-
if (typeof value !== "number" || !Number.isFinite(value)) return;
|
|
40
|
-
const floored = Math.floor(value);
|
|
41
|
-
return floored > 0 ? floored : void 0;
|
|
42
|
-
}
|
|
43
|
-
function resolveAnthropicMessagesMaxTokens(params) {
|
|
44
|
-
const requested = resolvePositiveAnthropicTokenLimit(params.requestedMaxTokens);
|
|
45
|
-
if (requested !== void 0) return requested;
|
|
46
|
-
const modelMax = resolvePositiveAnthropicTokenLimit(params.modelMaxTokens);
|
|
47
|
-
if (modelMax !== void 0) return params.useModelDefault ? modelMax : Math.min(modelMax, 32e3);
|
|
48
|
-
if (params.modelMaxTokens !== void 0) return;
|
|
49
|
-
const contextWindow = resolvePositiveAnthropicTokenLimit(params.modelContextWindow);
|
|
50
|
-
return contextWindow === void 0 ? ANTHROPIC_MESSAGES_DEFAULT_MAX_TOKENS : Math.max(1, Math.min(ANTHROPIC_MESSAGES_DEFAULT_MAX_TOKENS, Math.floor(contextWindow / ANTHROPIC_MESSAGES_FALLBACK_CONTEXT_DIVISOR)));
|
|
51
|
-
}
|
|
52
|
-
function resolveAnthropicTransportOptions(model, options, apiKey) {
|
|
53
|
-
const baseMaxTokens = resolveAnthropicMessagesMaxTokens({
|
|
54
|
-
modelContextWindow: model.contextWindow,
|
|
55
|
-
modelMaxTokens: model.maxTokens,
|
|
56
|
-
requestedMaxTokens: options?.maxTokens,
|
|
57
|
-
useModelDefault: resolveClaudeSonnet5ModelIdentity(model) !== void 0 || resolveClaudeOpus5ModelIdentity(model) !== void 0
|
|
58
|
-
});
|
|
59
|
-
if (baseMaxTokens === void 0) throw new Error(`Anthropic Messages transport requires a positive maxTokens value for ${model.provider}/${model.id}`);
|
|
60
|
-
const reasoningModelMaxTokens = resolvePositiveAnthropicTokenLimit(model.maxTokens) ?? baseMaxTokens;
|
|
61
|
-
const mandatoryAdaptiveThinking = requiresClaudeAdaptiveThinking(model);
|
|
62
|
-
const reasoning = options?.reasoning === "off" && mandatoryAdaptiveThinking ? "low" : options?.reasoning;
|
|
63
|
-
const resolved = copyProviderAcceptanceObserver(options, {
|
|
64
|
-
temperature: options?.temperature,
|
|
65
|
-
stop: options?.stop,
|
|
66
|
-
maxTokens: baseMaxTokens,
|
|
67
|
-
signal: options?.signal,
|
|
68
|
-
apiKey,
|
|
69
|
-
cacheRetention: options?.cacheRetention,
|
|
70
|
-
sessionId: options?.sessionId,
|
|
71
|
-
headers: options?.headers,
|
|
72
|
-
onPayload: options?.onPayload,
|
|
73
|
-
onResponse: options?.onResponse,
|
|
74
|
-
maxRetryDelayMs: options?.maxRetryDelayMs,
|
|
75
|
-
metadata: options?.metadata,
|
|
76
|
-
interleavedThinking: options?.interleavedThinking,
|
|
77
|
-
toolChoice: options?.toolChoice,
|
|
78
|
-
thinkingBudgets: options?.thinkingBudgets,
|
|
79
|
-
thinkingDisplay: options?.thinkingDisplay,
|
|
80
|
-
reasoning,
|
|
81
|
-
anthropicServerCompaction: options?.anthropicServerCompaction,
|
|
82
|
-
anthropicCompactThreshold: options?.anthropicCompactThreshold,
|
|
83
|
-
cacheTtlPruning: options?.cacheTtlPruning,
|
|
84
|
-
...options?.authProfileId ? { authProfileId: options.authProfileId } : {}
|
|
85
|
-
});
|
|
86
|
-
if (reasoning === "off") {
|
|
87
|
-
resolved.thinkingEnabled = false;
|
|
88
|
-
return resolved;
|
|
89
|
-
}
|
|
90
|
-
if (!reasoning) {
|
|
91
|
-
resolved.thinkingEnabled = defaultsClaudeAdaptiveThinking(model);
|
|
92
|
-
if (resolved.thinkingEnabled) resolved.effort = resolveAnthropicThinkingEffort(model, reasoning);
|
|
93
|
-
return resolved;
|
|
94
|
-
}
|
|
95
|
-
if (supportsClaudeAdaptiveThinking(model)) {
|
|
96
|
-
resolved.thinkingEnabled = true;
|
|
97
|
-
resolved.effort = resolveAnthropicThinkingEffort(model, reasoning);
|
|
98
|
-
return resolved;
|
|
99
|
-
}
|
|
100
|
-
const adjusted = adjustMaxTokensForThinking(baseMaxTokens, reasoningModelMaxTokens, reasoning === "max" ? "high" : reasoning, options?.thinkingBudgets);
|
|
101
|
-
const thinkingEnabled = adjusted.thinkingBudget >= 1024;
|
|
102
|
-
resolved.maxTokens = adjusted.maxTokens;
|
|
103
|
-
resolved.thinkingEnabled = thinkingEnabled;
|
|
104
|
-
resolved.thinkingBudgetTokens = thinkingEnabled ? adjusted.thinkingBudget : void 0;
|
|
105
|
-
return resolved;
|
|
106
|
-
}
|
|
107
|
-
//#endregion
|
|
108
36
|
//#region packages/ai/src/transports/anthropic-transport-stream.ts
|
|
109
37
|
const ANTHROPIC_MESSAGES_ERROR_BODY_MAX_BYTES = 8192;
|
|
110
38
|
const ANTHROPIC_MESSAGES_ERROR_BODY_MAX_CHARS = 400;
|
|
111
39
|
const ANTHROPIC_MESSAGES_ERROR_BODY_READ_IDLE_TIMEOUT_MS = 1e4;
|
|
112
40
|
const ANTHROPIC_MESSAGES_SSE_PENDING_BUFFER_MAX_CHARS = 16777216;
|
|
113
|
-
function resolveAnthropicRequestModelId(model) {
|
|
114
|
-
if (isDirectAnthropicModel(model) && /^anthropic\//i.test(model.id)) return model.id.replace(/^anthropic\//i, "");
|
|
115
|
-
return model.id;
|
|
116
|
-
}
|
|
117
|
-
const EMPTY_ANTHROPIC_MESSAGES_FALLBACK_TEXT = ".";
|
|
118
41
|
function isKimiAnthropicProvider(provider) {
|
|
119
42
|
return /^kimi(?:-|$)/.test(normalizeLowercaseStringOrEmpty(provider ?? ""));
|
|
120
43
|
}
|
|
121
|
-
/**
|
|
122
|
-
* Server-side refusal fallback is a first-party Claude API beta: proxies and
|
|
123
|
-
* Bedrock/Vertex/Foundry reject the `fallbacks` param, and OAuth (Claude Code
|
|
124
|
-
* identity) requests are excluded until the beta is verified there.
|
|
125
|
-
*/
|
|
126
|
-
function useAnthropicServerSideFallback(model) {
|
|
127
|
-
return (usesClaudeFable5MessagesContract(model) || resolveClaudeOpus5ModelIdentity(model) !== void 0 || resolveClaudeSonnet55ModelIdentity(model) !== void 0) && isDirectAnthropicModel(model);
|
|
128
|
-
}
|
|
129
|
-
function supportsReasoningContentReplay(model) {
|
|
130
|
-
return resolveProviderEndpoint(model).endpointClass === "xiaomi-native";
|
|
131
|
-
}
|
|
132
44
|
function buildAnthropicBetaHeader(model, betaFeatures, params) {
|
|
133
45
|
if (!isDirectAnthropicModel(model)) return;
|
|
134
46
|
return params.oauth ? `claude-code-20250219,oauth-2025-04-20,${betaFeatures.join(",")}` : betaFeatures.join(",");
|
|
135
47
|
}
|
|
136
|
-
function ensureNonEmptyAnthropicMessages(messages) {
|
|
137
|
-
return messages.length > 0 ? messages : [{
|
|
138
|
-
role: "user",
|
|
139
|
-
content: EMPTY_ANTHROPIC_MESSAGES_FALLBACK_TEXT
|
|
140
|
-
}];
|
|
141
|
-
}
|
|
142
48
|
const DEFAULT_ANTHROPIC_BASE_URL = "https://api.anthropic.com";
|
|
143
49
|
/** Resolve the effective Anthropic API base URL from model or environment. */
|
|
144
50
|
function resolveAnthropicBaseUrl(baseUrl) {
|
|
@@ -324,7 +230,12 @@ function createAnthropicTransportClient(params) {
|
|
|
324
230
|
"anthropic-dangerous-direct-browser-access": "true",
|
|
325
231
|
...betaHeader ? { "anthropic-beta": betaHeader } : {},
|
|
326
232
|
...options?.sessionId && options.cacheRetention !== "none" && model.compat?.sendSessionAffinityHeaders === true ? { "x-session-affinity": options.sessionId } : {}
|
|
327
|
-
}, model.headers, optionHeaders)
|
|
233
|
+
}, model.headers, optionHeaders, getAiTransportHost().resolveProviderRequestHeaders({
|
|
234
|
+
provider: model.provider,
|
|
235
|
+
api: model.api,
|
|
236
|
+
baseUrl: model.baseUrl,
|
|
237
|
+
model
|
|
238
|
+
}));
|
|
328
239
|
return {
|
|
329
240
|
request: createAnthropicMessageRequest({
|
|
330
241
|
apiKey,
|
|
@@ -336,54 +247,6 @@ function createAnthropicTransportClient(params) {
|
|
|
336
247
|
directApiKeyBetaHeader: isDirectAnthropicModel(model) ? new Headers(defaultHeaders).get("anthropic-beta") ?? "" : void 0
|
|
337
248
|
};
|
|
338
249
|
}
|
|
339
|
-
async function buildAnthropicParams(model, context, isOAuthToken, options, claudeCodeVersion) {
|
|
340
|
-
const replayThinkingEnabled = requiresClaudeAdaptiveThinking(model) || options?.thinkingEnabled === true;
|
|
341
|
-
const maxTokens = resolveAnthropicMessagesMaxTokens({
|
|
342
|
-
modelContextWindow: model.contextWindow,
|
|
343
|
-
modelMaxTokens: model.maxTokens,
|
|
344
|
-
requestedMaxTokens: options?.maxTokens
|
|
345
|
-
});
|
|
346
|
-
if (maxTokens === void 0) throw new Error(`Anthropic Messages transport requires a positive maxTokens value for ${model.provider}/${model.id}`);
|
|
347
|
-
const { cacheControl, supportsCacheControlOnTools } = resolveAnthropicCacheOptions(model, options?.cacheRetention);
|
|
348
|
-
const replayPlan = buildAnthropicReplayPlan(context.messages, model, {
|
|
349
|
-
enabled: !isOAuthToken && options?.anthropicServerCompaction === true,
|
|
350
|
-
authProfileId: options?.authProfileId,
|
|
351
|
-
sessionId: options?.sessionId
|
|
352
|
-
});
|
|
353
|
-
const cacheBreakpointOptOutMessageIndexes = /* @__PURE__ */ new Set();
|
|
354
|
-
const messages = await convertAnthropicMessages(getAiTransportHost().transformTransportMessages(replayPlan.messages, model, normalizeAnthropicToolCallId, void 0), model, isOAuthToken, {
|
|
355
|
-
profile: "transport",
|
|
356
|
-
allowReasoningContentReplay: supportsReasoningContentReplay(model),
|
|
357
|
-
allowEmptySignature: model.compat?.allowEmptySignature,
|
|
358
|
-
compaction: replayPlan.compaction,
|
|
359
|
-
replayThinkingEnabled,
|
|
360
|
-
cacheBreakpointOptOutMessageIndexes
|
|
361
|
-
});
|
|
362
|
-
const params = {
|
|
363
|
-
model: resolveAnthropicRequestModelId(model),
|
|
364
|
-
messages: ensureNonEmptyAnthropicMessages(messages),
|
|
365
|
-
max_tokens: maxTokens,
|
|
366
|
-
stream: true
|
|
367
|
-
};
|
|
368
|
-
if (!isOAuthToken && useAnthropicServerSideFallback(model)) params.fallbacks = ANTHROPIC_SERVER_SIDE_FALLBACKS;
|
|
369
|
-
const system = buildAnthropicSystemBlocks(context.systemPrompt, isOAuthToken, cacheControl, claudeCodeVersion);
|
|
370
|
-
if (system) params.system = system;
|
|
371
|
-
const convertedTools = context.tools ? convertAnthropicTools(context.tools, isOAuthToken) : void 0;
|
|
372
|
-
const toolProjection = convertedTools?.projection;
|
|
373
|
-
Object.assign(params, buildAnthropicGenerationParams({
|
|
374
|
-
model,
|
|
375
|
-
options,
|
|
376
|
-
tools: convertedTools?.tools,
|
|
377
|
-
toolProjection,
|
|
378
|
-
profile: "transport"
|
|
379
|
-
}));
|
|
380
|
-
applyAnthropicRequestCacheControl(params, cacheControl, supportsCacheControlOnTools, cacheBreakpointOptOutMessageIndexes);
|
|
381
|
-
return {
|
|
382
|
-
params,
|
|
383
|
-
toolProjection,
|
|
384
|
-
usedCompactionReplay: replayPlan.compaction !== void 0
|
|
385
|
-
};
|
|
386
|
-
}
|
|
387
250
|
/** Create the stream function used by Anthropic Messages transport models. */
|
|
388
251
|
function createAnthropicMessagesTransportStreamFn() {
|
|
389
252
|
return (rawModel, context, rawOptions) => {
|
|
@@ -405,21 +268,15 @@ function createAnthropicMessagesTransportStreamFn() {
|
|
|
405
268
|
apiKey,
|
|
406
269
|
options: transportOptions
|
|
407
270
|
});
|
|
408
|
-
const builtParams = await
|
|
271
|
+
const builtParams = await buildAnthropicRequest(model, requestContext, transportOptions, "transport", isOAuthToken, !isOAuthToken && supportsAnthropicServerSideFallback(model), claudeCodeVersion);
|
|
409
272
|
usedCompactionReplay = builtParams.usedCompactionReplay;
|
|
410
|
-
|
|
411
|
-
applyAnthropicContextManagementToRequest(params, model, transportOptions, directApiKeyBetaHeader);
|
|
412
|
-
const nextParams = await transportOptions.onPayload?.(params, model);
|
|
413
|
-
if (nextParams !== void 0) params = nextParams;
|
|
414
|
-
applyClaudeRequestContract(params, model);
|
|
415
|
-
const betaHeader = resolveAnthropicRequestBetaHeader(params, directApiKeyBetaHeader);
|
|
416
|
-
const bindingHeaders = applyAnthropicThinkingBindingControls(params, betaHeader) ?? (betaHeader ? { "anthropic-beta": betaHeader } : void 0);
|
|
273
|
+
const { params, headers } = await prepareAnthropicRequest(builtParams.params, model, transportOptions, directApiKeyBetaHeader);
|
|
417
274
|
const { response, stream: anthropicStream } = await request({
|
|
418
275
|
...params,
|
|
419
276
|
stream: true
|
|
420
277
|
}, {
|
|
421
278
|
signal: transportOptions.signal,
|
|
422
|
-
headers
|
|
279
|
+
headers
|
|
423
280
|
});
|
|
424
281
|
await notifyProviderHttpResponse({
|
|
425
282
|
options: transportOptions,
|
|
@@ -470,221 +327,144 @@ function createAnthropicMessagesTransportStreamFn() {
|
|
|
470
327
|
};
|
|
471
328
|
}
|
|
472
329
|
//#endregion
|
|
473
|
-
//#region packages/ai/src/transports/openai-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
function
|
|
481
|
-
if (
|
|
482
|
-
const
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
330
|
+
//#region packages/ai/src/transports/openai-responses-params-internal.ts
|
|
331
|
+
const OPENAI_RESPONSES_TOOL_CALL_PROVIDERS = /* @__PURE__ */ new Set([
|
|
332
|
+
"openai",
|
|
333
|
+
"opencode",
|
|
334
|
+
"azure-openai-responses",
|
|
335
|
+
"github-copilot"
|
|
336
|
+
]);
|
|
337
|
+
function raiseMinimalReasoningForResponsesWebSearch(params) {
|
|
338
|
+
if (params.effort !== "minimal" || !hasResponsesWebSearchTool(params.tools)) return params.effort;
|
|
339
|
+
for (const effort of [
|
|
340
|
+
"low",
|
|
341
|
+
"medium",
|
|
342
|
+
"high"
|
|
343
|
+
]) {
|
|
344
|
+
const resolved = resolveOpenAIRequestReasoning(params.model, effort).effort;
|
|
345
|
+
if (resolved && resolved !== "none" && resolved !== "minimal") return resolved;
|
|
346
|
+
}
|
|
347
|
+
return params.effort;
|
|
348
|
+
}
|
|
349
|
+
const OPENAI_CODEX_RESPONSES_UNSUPPORTED_PARAMS = [
|
|
350
|
+
"max_output_tokens",
|
|
351
|
+
"metadata",
|
|
352
|
+
"prompt_cache_retention",
|
|
353
|
+
"prompt_cache_options",
|
|
354
|
+
"service_tier",
|
|
355
|
+
"temperature",
|
|
356
|
+
"top_p"
|
|
357
|
+
];
|
|
358
|
+
function stripOpenAICodexResponsesUnsupportedTextFields(params) {
|
|
359
|
+
const text = params.text;
|
|
360
|
+
if (!text || typeof text !== "object" || Array.isArray(text)) return;
|
|
361
|
+
const sanitizedText = { ...text };
|
|
362
|
+
delete sanitizedText.format;
|
|
363
|
+
if (Object.keys(sanitizedText).length > 0) params.text = sanitizedText;
|
|
364
|
+
else delete params.text;
|
|
365
|
+
}
|
|
366
|
+
function sanitizeOpenAICodexResponsesParams(model, params) {
|
|
367
|
+
if (!usesNativeOpenAICodexResponsesBackend(model)) return params;
|
|
368
|
+
for (const key of OPENAI_CODEX_RESPONSES_UNSUPPORTED_PARAMS) delete params[key];
|
|
369
|
+
Object.assign(params, { store: false });
|
|
370
|
+
stripOpenAICodexResponsesUnsupportedTextFields(params);
|
|
371
|
+
return params;
|
|
372
|
+
}
|
|
373
|
+
function buildOpenAIResponsesInstructionsText(context) {
|
|
374
|
+
if (!context.systemPrompt) return;
|
|
375
|
+
return sanitizeTransportPayloadText(stripSystemPromptCacheBoundary(context.systemPrompt));
|
|
376
|
+
}
|
|
377
|
+
function resolveOpenAIResponsesInstructions(model, context, usesInstructionsField) {
|
|
378
|
+
if (!usesInstructionsField) return;
|
|
379
|
+
const instructions = buildOpenAIResponsesInstructionsText(context);
|
|
380
|
+
if (instructions && instructions.trim().length > 0) return instructions;
|
|
381
|
+
return usesNativeOpenAICodexResponsesBackend(model) ? OPENAI_CODEX_RESPONSES_DEFAULT_INSTRUCTIONS : void 0;
|
|
382
|
+
}
|
|
383
|
+
function buildOpenAIResponsesCompactSystemMessage(model, instructions) {
|
|
384
|
+
const compat = getCompat(model);
|
|
385
|
+
const supportsDeveloperRole = typeof compat.supportsDeveloperRole === "boolean" ? compat.supportsDeveloperRole : void 0;
|
|
386
|
+
const role = model.reasoning && supportsDeveloperRole !== false ? "developer" : "system";
|
|
387
|
+
return buildResponsesInputMessage(role, [{
|
|
388
|
+
type: "input_text",
|
|
389
|
+
text: instructions
|
|
390
|
+
}]);
|
|
391
|
+
}
|
|
392
|
+
function ensureOpenAIResponsesNonEmptyInput(messages, context) {
|
|
393
|
+
if (messages.length > 0 || !context.systemPrompt) return;
|
|
394
|
+
if (!buildOpenAIResponsesInstructionsText(context)) throw new Error("OpenAI Responses requires non-empty input when only systemPrompt is provided.");
|
|
395
|
+
messages.push(buildResponsesInputMessage("user", [{
|
|
396
|
+
type: "input_text",
|
|
397
|
+
text: " "
|
|
398
|
+
}]));
|
|
399
|
+
}
|
|
400
|
+
function buildOpenAIResponsesParams(model, context, options, metadata, replayMode = "checkpoint") {
|
|
401
|
+
const payloadPolicy = resolveOpenAIResponsesPayloadPolicy(model, { storeMode: "transport-default" });
|
|
402
|
+
const policyAllowsReplayIds = payloadPolicy.explicitStore !== false && !payloadPolicy.shouldStripStore;
|
|
403
|
+
const replayResponsesItemIds = !usesNativeOpenAICodexResponsesBackend(model) && (options?.replayResponsesItemIds ?? policyAllowsReplayIds);
|
|
404
|
+
const messages = convertResponsesMessages(model, context, OPENAI_RESPONSES_TOOL_CALL_PROVIDERS, {
|
|
405
|
+
includeSystemPrompt: !payloadPolicy.usesInstructionsField,
|
|
406
|
+
replayReasoningItems: true,
|
|
407
|
+
replayResponsesItemIds,
|
|
408
|
+
authProfileId: options?.authProfileId,
|
|
409
|
+
sessionId: options?.sessionId,
|
|
410
|
+
replayMode
|
|
506
411
|
});
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
const
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
let lineOverflowed = false;
|
|
521
|
-
let sawDone = false;
|
|
522
|
-
const finishLine = () => {
|
|
523
|
-
if (!lineOverflowed && SSE_DONE_LINE_RE.test(line)) sawDone = true;
|
|
524
|
-
line = "";
|
|
525
|
-
lineOverflowed = false;
|
|
526
|
-
};
|
|
527
|
-
const observeText = (text) => {
|
|
528
|
-
for (const char of text) {
|
|
529
|
-
if (char === "\n" || char === "\r") {
|
|
530
|
-
finishLine();
|
|
531
|
-
continue;
|
|
532
|
-
}
|
|
533
|
-
if (!lineOverflowed && line.length < SSE_DONE_MAX_LINE_CHARS) line += char;
|
|
534
|
-
else lineOverflowed = true;
|
|
535
|
-
}
|
|
412
|
+
ensureOpenAIResponsesNonEmptyInput(messages, context);
|
|
413
|
+
const cacheRetention = resolveCacheRetention(options?.cacheRetention);
|
|
414
|
+
const compat = getCompat(model);
|
|
415
|
+
const promptCacheKey = compat.supportsPromptCacheKey ? resolvePromptCacheKey(options, cacheRetention) : void 0;
|
|
416
|
+
const instructions = resolveOpenAIResponsesInstructions(model, context, payloadPolicy.usesInstructionsField);
|
|
417
|
+
const params = {
|
|
418
|
+
model: model.id,
|
|
419
|
+
input: messages,
|
|
420
|
+
stream: true,
|
|
421
|
+
prompt_cache_key: promptCacheKey,
|
|
422
|
+
...resolveOpenAIPromptCacheParams(model, cacheRetention, compat),
|
|
423
|
+
...instructions ? { instructions } : {},
|
|
424
|
+
...metadata ? { metadata } : {}
|
|
536
425
|
};
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
if (line || lineOverflowed) finishLine();
|
|
545
|
-
},
|
|
546
|
-
sawDone: () => sawDone
|
|
426
|
+
const effectiveMaxTokens = options?.maxTokens || model.maxTokens;
|
|
427
|
+
if (effectiveMaxTokens) params.max_output_tokens = Math.max(effectiveMaxTokens, 16);
|
|
428
|
+
if (options?.temperature !== void 0 && supportsOpenAITemperature(model)) params.temperature = options.temperature;
|
|
429
|
+
if (options?.topP !== void 0 && (!isOpenAIGpt6Model(model) || resolveOpenAIThinkingApi(model.api) === "azure-openai-responses")) params.top_p = options.topP;
|
|
430
|
+
if (options?.responseFormat !== void 0) params.text = {
|
|
431
|
+
...params.text,
|
|
432
|
+
format: resolveOpenAIResponsesTextFormat(options.responseFormat)
|
|
547
433
|
};
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
dangerouslyAllowBrowser: true,
|
|
555
|
-
defaultHeaders: clientConfig.defaultHeaders,
|
|
556
|
-
defaultQuery: clientConfig.defaultQuery,
|
|
557
|
-
fetch: opts?.fetch ?? buildGuardedModelFetch(model),
|
|
558
|
-
...buildOpenAISdkClientOptions(model)
|
|
559
|
-
});
|
|
560
|
-
}
|
|
561
|
-
function buildOpenAICompletionsClientConfig(model, headers) {
|
|
562
|
-
const defaultQuery = {};
|
|
563
|
-
let baseURL = model.baseUrl;
|
|
564
|
-
let isAzureHost = false;
|
|
565
|
-
try {
|
|
566
|
-
const parsed = new URL(model.baseUrl);
|
|
567
|
-
isAzureHost = isAzureOpenAICompatibleHost(parsed.hostname.toLowerCase());
|
|
568
|
-
parsed.searchParams.forEach((value, key) => {
|
|
569
|
-
if (value) defaultQuery[key] = value;
|
|
434
|
+
if (options?.serviceTier !== void 0 && payloadPolicy.allowsServiceTier) params.service_tier = options.serviceTier;
|
|
435
|
+
if (context.tools) {
|
|
436
|
+
const tools = context.tools;
|
|
437
|
+
const strict = getAiTransportHost().resolveOpenAIStrictToolSetting(model, {
|
|
438
|
+
transport: "stream",
|
|
439
|
+
supportsStrictMode: compat.supportsStrictMode
|
|
570
440
|
});
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
if (apiVersionHeader) {
|
|
577
|
-
const apiVersion = headers[apiVersionHeader]?.trim();
|
|
578
|
-
delete headers[apiVersionHeader];
|
|
579
|
-
if (apiVersion && !defaultQuery["api-version"]) defaultQuery["api-version"] = apiVersion;
|
|
441
|
+
const { projection, tools: converted } = prepareResponsesTools(tools, strict, model);
|
|
442
|
+
if (converted.length > 0 || projection.inputToolCount === 0 && projection.diagnostics.length === 0) params.tools = converted;
|
|
443
|
+
if (options?.toolChoice) {
|
|
444
|
+
const toolChoice = reconcileOpenAIResponsesToolChoice(options.toolChoice, projection);
|
|
445
|
+
if (toolChoice !== void 0) params.tool_choice = toolChoice;
|
|
580
446
|
}
|
|
581
447
|
}
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
const
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
const optionHeaders = resolveOpencodeSessionHeaders(model, options);
|
|
603
|
-
const turnHeaders = filterProviderTurnHeadersForExplicitOpencodeSession(model, options, turnState?.headers);
|
|
604
|
-
const doneDetector = createSseDoneDetector();
|
|
605
|
-
const baseFetch = buildGuardedModelFetch(model);
|
|
606
|
-
const doneDetectingFetch = async (url, init) => {
|
|
607
|
-
const response = await baseFetch(url, init);
|
|
608
|
-
if (!response.body || !response.ok) return response;
|
|
609
|
-
if (typeof TransformStream === "undefined" || !response.body.pipeThrough) return response;
|
|
610
|
-
const transformed = response.body.pipeThrough(new TransformStream({
|
|
611
|
-
transform(chunk, controller) {
|
|
612
|
-
doneDetector.observe(chunk);
|
|
613
|
-
controller.enqueue(chunk);
|
|
614
|
-
},
|
|
615
|
-
flush() {
|
|
616
|
-
doneDetector.finish();
|
|
617
|
-
}
|
|
618
|
-
}));
|
|
619
|
-
return new Response(transformed, {
|
|
620
|
-
headers: response.headers,
|
|
621
|
-
status: response.status,
|
|
622
|
-
statusText: response.statusText
|
|
623
|
-
});
|
|
624
|
-
};
|
|
625
|
-
const cacheRetention = resolveCacheRetention(options?.cacheRetention);
|
|
626
|
-
const client = createOpenAICompletionsClient(model, apiKey, buildOpenAIClientHeaders(model, context, {
|
|
627
|
-
...turnHeaders,
|
|
628
|
-
...optionHeaders
|
|
629
|
-
}, void 0, resolvePromptCacheKey(options, cacheRetention), cacheRetention), { fetch: doneDetectingFetch });
|
|
630
|
-
let params = buildOpenAICompletionsParams(model, context, options);
|
|
631
|
-
const encodeBody = prepareModelRequestBody(options);
|
|
632
|
-
const nextParams = await options?.onPayload?.(params, model);
|
|
633
|
-
if (nextParams !== void 0) params = nextParams;
|
|
634
|
-
if (options?.openclawCodeModeToolSurface === true) {
|
|
635
|
-
const visibleToolNames = resolveCodeModeResponsesVisibleToolNames(context);
|
|
636
|
-
enforceCodeModeResponsesToolSurface(params, visibleToolNames, void 0, codeModeToolSurfaceObserver.get(options));
|
|
637
|
-
assertCodeModeResponsesToolSurface(params, visibleToolNames);
|
|
638
|
-
}
|
|
639
|
-
if (getCompat(model).requiresNonEmptyUserOrAssistantMessage) assertOpenAICompletionsPayloadHasConversationTurn(params, model);
|
|
640
|
-
const emitReasoning = shouldEmitOpenAICompletionsReasoning(model, options);
|
|
641
|
-
firstEventAbort = createFirstStreamEventAbortController(options?.signal);
|
|
642
|
-
const { data: responseStream, response } = await client.chat.completions.create(params, {
|
|
643
|
-
...buildOpenAISdkRequestOptions(model, firstEventAbort.signal, { timeoutMs: options?.timeoutMs }),
|
|
644
|
-
...await encodeBody(params)
|
|
645
|
-
}).withResponse();
|
|
646
|
-
const hookedResponseStream = withProviderResponseHook({
|
|
647
|
-
stream: responseStream,
|
|
648
|
-
signal: firstEventAbort.signal,
|
|
649
|
-
abort: firstEventAbort.abort,
|
|
650
|
-
hook: createOpenAIProviderAcceptanceHook(options, response, model),
|
|
651
|
-
onReady: () => stream.push({
|
|
652
|
-
type: "start",
|
|
653
|
-
partial: output
|
|
654
|
-
})
|
|
655
|
-
});
|
|
656
|
-
await processCompletionsStream(hookedResponseStream, output, model, stream, {
|
|
657
|
-
signal: options?.signal,
|
|
658
|
-
emitReasoning,
|
|
659
|
-
strictReasoningTags: reasoningTagTextPolicy.isStrict(options),
|
|
660
|
-
firstEventTimeoutMs: getFirstStreamEventTimeoutMs(options),
|
|
661
|
-
abortFirstEventStream: firstEventAbort.abort,
|
|
662
|
-
onFirstEventTimeout: getFirstStreamEventTimeoutHandler(options),
|
|
663
|
-
sawStreamDONE: doneDetector.sawDone
|
|
664
|
-
});
|
|
665
|
-
finalizeTransportStream({
|
|
666
|
-
stream,
|
|
667
|
-
output,
|
|
668
|
-
signal: options?.signal
|
|
669
|
-
});
|
|
670
|
-
} catch (error) {
|
|
671
|
-
failTransportStream({
|
|
672
|
-
stream,
|
|
673
|
-
output,
|
|
674
|
-
signal: options?.signal,
|
|
675
|
-
error,
|
|
676
|
-
cleanup: () => {
|
|
677
|
-
output.stopReason = options?.signal?.aborted ? "aborted" : "error";
|
|
678
|
-
finalizeOpenAICompletionsToolCalls(output, { allowSilentToolCallPromotion: false });
|
|
679
|
-
tagUnresolvedTextAsCommentary(output);
|
|
680
|
-
}
|
|
681
|
-
});
|
|
682
|
-
} finally {
|
|
683
|
-
firstEventAbort?.dispose();
|
|
684
|
-
}
|
|
685
|
-
})();
|
|
686
|
-
return eventStream;
|
|
687
|
-
};
|
|
448
|
+
if (model.reasoning) {
|
|
449
|
+
const reasoning = options?.reasoning;
|
|
450
|
+
const requestedEffort = options?.reasoningEffort ?? (reasoning === "none" ? "none" : resolveOpenAISimpleReasoningEffort(model, reasoning)) ?? (options?.reasoningSummary ? "high" : payloadPolicy.defaultManagedReasoningEffort);
|
|
451
|
+
const resolvedEffort = requestedEffort === void 0 ? void 0 : resolveOpenAIRequestReasoning(model, requestedEffort).effort;
|
|
452
|
+
if (resolvedEffort !== void 0) {
|
|
453
|
+
const effort = raiseMinimalReasoningForResponsesWebSearch({
|
|
454
|
+
model,
|
|
455
|
+
effort: resolvedEffort,
|
|
456
|
+
tools: params.tools
|
|
457
|
+
});
|
|
458
|
+
const summary = effort !== "none" && (options?.reasoningEffort || options?.reasoning || options?.reasoningSummary) ? options.reasoningSummary || "auto" : void 0;
|
|
459
|
+
params.reasoning = {
|
|
460
|
+
effort,
|
|
461
|
+
...summary ? { summary } : {}
|
|
462
|
+
};
|
|
463
|
+
if (summary) params.include = ["reasoning.encrypted_content"];
|
|
464
|
+
}
|
|
465
|
+
}
|
|
466
|
+
applyOpenAIResponsesPayloadPolicy(params, payloadPolicy);
|
|
467
|
+
return sanitizeOpenAICodexResponsesParams(model, params);
|
|
688
468
|
}
|
|
689
469
|
//#endregion
|
|
690
470
|
//#region packages/ai/src/transports/openai-responses-steering.ts
|
|
@@ -813,12 +593,8 @@ const websocketSessionCache = /* @__PURE__ */ new Map();
|
|
|
813
593
|
const degradedWebSocketConnections = /* @__PURE__ */ new Map();
|
|
814
594
|
function isOfficialOpenAIResponsesBaseUrl(baseUrl) {
|
|
815
595
|
if (!baseUrl) return false;
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
return url.origin === "https://api.openai.com" && url.username === "" && url.password === "" && url.search === "" && url.hash === "" && url.pathname.replace(/\/+$/, "") === "/v1";
|
|
819
|
-
} catch {
|
|
820
|
-
return false;
|
|
821
|
-
}
|
|
596
|
+
const url = URL.parse(baseUrl);
|
|
597
|
+
return url !== null && url.origin === "https://api.openai.com" && url.username === "" && url.password === "" && url.search === "" && url.hash === "" && url.pathname.replace(/\/+$/, "") === "/v1";
|
|
822
598
|
}
|
|
823
599
|
function supportsNativeOpenAIResponsesEndpoint(params) {
|
|
824
600
|
return params.provider.trim().toLowerCase() === "openai" && params.api === "openai-responses" && isOfficialOpenAIResponsesBaseUrl(params.baseUrl);
|
|
@@ -853,7 +629,8 @@ function scheduleSessionWebSocketExpiry(cacheKey, entry) {
|
|
|
853
629
|
function prepareWebSocketConnection(client, headers) {
|
|
854
630
|
if (!isOfficialOpenAIResponsesBaseUrl(client.baseURL)) throw new Error("OpenAI Responses WebSocket requires the official API endpoint");
|
|
855
631
|
if (typeof client.apiKey !== "string" || client.apiKey.length === 0) throw new Error("OpenAI Responses WebSocket requires an API key");
|
|
856
|
-
const
|
|
632
|
+
const owner = getAiTransportHost();
|
|
633
|
+
const resolvedApiKey = owner.resolveSecretSentinel(client.apiKey);
|
|
857
634
|
const resolvedHeaders = { ...resolveAiTransportHeaderSentinels(headers) };
|
|
858
635
|
for (const key of Object.keys(resolvedHeaders)) {
|
|
859
636
|
const normalizedKey = key.toLowerCase();
|
|
@@ -863,6 +640,8 @@ function prepareWebSocketConnection(client, headers) {
|
|
|
863
640
|
return {
|
|
864
641
|
client: client.withOptions({ apiKey: resolvedApiKey }),
|
|
865
642
|
headers: resolvedHeaders,
|
|
643
|
+
owner,
|
|
644
|
+
ownerId: getSessionResourceOwnerId(owner),
|
|
866
645
|
identity: sha256Hex(JSON.stringify([
|
|
867
646
|
resolvedApiKey,
|
|
868
647
|
client.baseURL,
|
|
@@ -909,7 +688,7 @@ function createCachedWebSocketLease(cacheKey, entry, reusedConnection) {
|
|
|
909
688
|
}
|
|
910
689
|
function acquireWebSocket(params, connection) {
|
|
911
690
|
if (!(params.mode !== "websocket" && Boolean(params.sessionId)) || !params.sessionId) return createTransientWebSocketLease(connection);
|
|
912
|
-
const cacheKey = `${params.sessionId}\0${connection.identity}`;
|
|
691
|
+
const cacheKey = `${connection.ownerId}\0${params.sessionId}\0${connection.identity}`;
|
|
913
692
|
const cached = websocketSessionCache.get(cacheKey);
|
|
914
693
|
if (cached) {
|
|
915
694
|
if (cached.idleTimer) {
|
|
@@ -928,6 +707,7 @@ function acquireWebSocket(params, connection) {
|
|
|
928
707
|
else closeWebSocketSilently(failedSocket, "transport_error");
|
|
929
708
|
}),
|
|
930
709
|
sessionId: params.sessionId,
|
|
710
|
+
owner: connection.owner,
|
|
931
711
|
busy: true,
|
|
932
712
|
createdAt: Date.now()
|
|
933
713
|
};
|
|
@@ -939,17 +719,8 @@ function sanitizeWebSocketRequest(request) {
|
|
|
939
719
|
return websocketRequest;
|
|
940
720
|
}
|
|
941
721
|
async function nextWebSocketMessage(iterator, signal) {
|
|
942
|
-
if (
|
|
943
|
-
|
|
944
|
-
let onAbort;
|
|
945
|
-
try {
|
|
946
|
-
return await Promise.race([iterator.next(), new Promise((_resolve, reject) => {
|
|
947
|
-
onAbort = () => reject(transportAbortError(signal));
|
|
948
|
-
signal.addEventListener("abort", onAbort, { once: true });
|
|
949
|
-
})]);
|
|
950
|
-
} finally {
|
|
951
|
-
if (onAbort) signal.removeEventListener("abort", onAbort);
|
|
952
|
-
}
|
|
722
|
+
if (signal?.aborted) throw transportAbortError(signal);
|
|
723
|
+
return await racePromiseWithAbortSignal(iterator.next(), signal, transportAbortError);
|
|
953
724
|
}
|
|
954
725
|
function readServerEvent(message) {
|
|
955
726
|
if (message.type === "message") return message.message;
|
|
@@ -960,17 +731,24 @@ function createOpenAIResponsesWebSocketStream(params) {
|
|
|
960
731
|
const connection = prepareWebSocketConnection(params.client, params.headers);
|
|
961
732
|
let fullRequest = sanitizeWebSocketRequest(params.request);
|
|
962
733
|
const requestModel = typeof fullRequest.model === "string" ? fullRequest.model : "";
|
|
963
|
-
const degradationKey = `${params.sessionId ?? ""}\0${connection.identity}\0${requestModel}`;
|
|
734
|
+
const degradationKey = `${connection.ownerId}\0${params.sessionId ?? ""}\0${connection.identity}\0${requestModel}`;
|
|
964
735
|
const degraded = degradedWebSocketConnections.get(degradationKey);
|
|
965
736
|
if (degraded && degraded.retryAt > Date.now()) throw new OpenAIResponsesWebSocketPreDispatchError(/* @__PURE__ */ new Error("OpenAI Responses WebSocket is cooling down after a transport failure"));
|
|
737
|
+
if (degraded) clearTimeout(degraded.expiryTimer);
|
|
966
738
|
degradedWebSocketConnections.delete(degradationKey);
|
|
967
739
|
const markDegraded = () => {
|
|
968
740
|
const cooldownMs = params.degradeCooldownMs;
|
|
969
741
|
if (cooldownMs === void 0 || !Number.isFinite(cooldownMs) || cooldownMs <= 0) return;
|
|
970
|
-
|
|
742
|
+
const entry = {
|
|
971
743
|
sessionId: params.sessionId,
|
|
972
|
-
|
|
973
|
-
|
|
744
|
+
owner: connection.owner,
|
|
745
|
+
retryAt: Date.now() + cooldownMs,
|
|
746
|
+
expiryTimer: setTimeout(() => {
|
|
747
|
+
if (degradedWebSocketConnections.get(degradationKey) === entry) degradedWebSocketConnections.delete(degradationKey);
|
|
748
|
+
}, cooldownMs)
|
|
749
|
+
};
|
|
750
|
+
entry.expiryTimer.unref?.();
|
|
751
|
+
degradedWebSocketConnections.set(degradationKey, entry);
|
|
974
752
|
};
|
|
975
753
|
let lease;
|
|
976
754
|
try {
|
|
@@ -1164,12 +942,15 @@ function createOpenAIResponsesWebSocketStream(params) {
|
|
|
1164
942
|
finish
|
|
1165
943
|
};
|
|
1166
944
|
}
|
|
1167
|
-
function closeOpenAIResponsesWebSocketSessions(sessionId) {
|
|
945
|
+
function closeOpenAIResponsesWebSocketSessions(sessionId, owner) {
|
|
1168
946
|
for (const [cacheKey, entry] of websocketSessionCache) {
|
|
1169
|
-
if (sessionId && entry.sessionId !== sessionId) continue;
|
|
947
|
+
if (owner && entry.owner !== owner || sessionId && entry.sessionId !== sessionId) continue;
|
|
1170
948
|
invalidateOwnedWebSocketSession(cacheKey, entry, "session_cleanup");
|
|
1171
949
|
}
|
|
1172
|
-
for (const [key, entry] of degradedWebSocketConnections) if (!sessionId || entry.sessionId === sessionId)
|
|
950
|
+
for (const [key, entry] of degradedWebSocketConnections) if ((!owner || entry.owner === owner) && (!sessionId || entry.sessionId === sessionId)) {
|
|
951
|
+
clearTimeout(entry.expiryTimer);
|
|
952
|
+
degradedWebSocketConnections.delete(key);
|
|
953
|
+
}
|
|
1173
954
|
}
|
|
1174
955
|
registerSessionResourceCleanup(closeOpenAIResponsesWebSocketSessions);
|
|
1175
956
|
//#endregion
|
|
@@ -1238,10 +1019,6 @@ async function requestPreparedOpenAIResponsesCompaction(streamFn, model, context
|
|
|
1238
1019
|
}
|
|
1239
1020
|
//#endregion
|
|
1240
1021
|
//#region packages/ai/src/transports/openai-responses-reasoning-state.ts
|
|
1241
|
-
function inputReplay(message) {
|
|
1242
|
-
const value = "openclawResponsesInputReplay" in message ? message.openclawResponsesInputReplay : void 0;
|
|
1243
|
-
return isRecord(value) ? value : void 0;
|
|
1244
|
-
}
|
|
1245
1022
|
/** Save only admitted settings and hashes, never another copy of the conversation. */
|
|
1246
1023
|
function recordResponsesReasoningState(message, model, identity, request, output) {
|
|
1247
1024
|
if (!supportsResponsesReasoningUpdate(request) || !isRecord(request.reasoning) || !request.input || request.previous_response_id || message.providerReplay || output.some((item) => isRecord(item) && item.type === "compaction")) return;
|
|
@@ -1258,17 +1035,17 @@ function recordResponsesReasoningState(message, model, identity, request, output
|
|
|
1258
1035
|
requestHash: responsesContinuationRequestFingerprint(request)
|
|
1259
1036
|
};
|
|
1260
1037
|
Object.assign(message, { openclawResponsesInputReplay: {
|
|
1261
|
-
...
|
|
1038
|
+
...readResponsesInputReplayState(message),
|
|
1262
1039
|
reasoning
|
|
1263
1040
|
} });
|
|
1264
1041
|
}
|
|
1265
1042
|
/** A cold transport can replay controls, but cannot resurrect a server response handle. */
|
|
1266
1043
|
function restoreResponsesReasoningState(context, model, identity, request) {
|
|
1267
1044
|
const latest = context.messages.findLast((message) => message.role === "assistant");
|
|
1268
|
-
const state = latest ?
|
|
1045
|
+
const state = latest ? readResponsesInputReplayState(latest)?.reasoning : void 0;
|
|
1269
1046
|
if (!isRecord(state)) return request;
|
|
1270
1047
|
const { effort, inputLength, outputLength, controls, prefixHash, requestHash } = state;
|
|
1271
|
-
if (!
|
|
1048
|
+
if (!isProviderReplayContext(state) || !providerReplayContextMatches(state, buildProviderReplayContext(model, identity)) || latest?.providerReplay || !supportsResponsesReasoningUpdate(request) || !isRecord(request.reasoning) || !request.input || request.previous_response_id || request.input.some(isConfigurationUpdate) || typeof effort !== "string" || typeof inputLength !== "number" || !Number.isSafeInteger(inputLength) || inputLength < 0 || typeof outputLength !== "number" || !Number.isSafeInteger(outputLength) || outputLength < 0 || !Array.isArray(controls) || controls.length > inputLength || inputLength + outputLength > request.input.length + controls.length) return request;
|
|
1272
1049
|
const previousInput = request.input.slice(0, inputLength - controls.length);
|
|
1273
1050
|
let lastIndex = -1;
|
|
1274
1051
|
for (const control of controls) {
|
|
@@ -1324,11 +1101,7 @@ function createResponsesRequestFetch(model, options) {
|
|
|
1324
1101
|
function resolveNativeOpenAIResponsesWebSocketMode(model, transport) {
|
|
1325
1102
|
if (transport !== "websocket" && transport !== "websocket-cached" && transport !== "auto") return;
|
|
1326
1103
|
if (getAiTransportHost().requiresManagedTransport(model)) return;
|
|
1327
|
-
return supportsNativeOpenAIResponsesEndpoint(
|
|
1328
|
-
provider: model.provider,
|
|
1329
|
-
api: model.api,
|
|
1330
|
-
baseUrl: model.baseUrl
|
|
1331
|
-
}) ? transport : void 0;
|
|
1104
|
+
return supportsNativeOpenAIResponsesEndpoint(model) ? transport : void 0;
|
|
1332
1105
|
}
|
|
1333
1106
|
function combineWebSocketTimeoutSignal(signal, model, timeoutMs) {
|
|
1334
1107
|
const resolvedTimeoutMs = timeoutMs !== void 0 && Number.isFinite(timeoutMs) && timeoutMs > 0 ? timeoutMs : getAiTransportHost().resolveModelRequestTimeoutMs(model);
|
|
@@ -1384,7 +1157,7 @@ function createResponsesTransportExecutor(config) {
|
|
|
1384
1157
|
if (nextParams !== void 0) params = nextParams;
|
|
1385
1158
|
params = sanitizeOpenAICodexResponsesParams(model, params);
|
|
1386
1159
|
params = sanitizeResponsesImagePayload(params);
|
|
1387
|
-
if (
|
|
1160
|
+
if (responsesOptions?.openclawCodeModeToolSurface === true) {
|
|
1388
1161
|
const visibleToolNames = resolveCodeModeResponsesVisibleToolNames(context);
|
|
1389
1162
|
const allowedHostedToolTypes = responsesOptions?.openclawCodeModeAllowedHostedToolTypes;
|
|
1390
1163
|
enforceCodeModeResponsesToolSurface(params, visibleToolNames, allowedHostedToolTypes, codeModeToolSurfaceObserver.get(options));
|
|
@@ -1418,11 +1191,7 @@ function createResponsesTransportExecutor(config) {
|
|
|
1418
1191
|
return;
|
|
1419
1192
|
}
|
|
1420
1193
|
const sessionId = options?.sessionId;
|
|
1421
|
-
if (config.httpContinuation && !websocketMode && !getAiTransportHost().requiresManagedTransport(model) && (supportsNativeOpenAIResponsesEndpoint({
|
|
1422
|
-
provider: model.provider,
|
|
1423
|
-
api: model.api,
|
|
1424
|
-
baseUrl: model.baseUrl
|
|
1425
|
-
}) || resolveOpenAIResponsesPayloadPolicy(model).explicitContinuationOptIn) && sessionId && (params.store === true || supportsResponsesReasoningUpdate(params)) && !params.previous_response_id) {
|
|
1194
|
+
if (config.httpContinuation && !websocketMode && !getAiTransportHost().requiresManagedTransport(model) && (supportsNativeOpenAIResponsesEndpoint(model) || resolveOpenAIResponsesPayloadPolicy(model).explicitContinuationOptIn) && sessionId && (params.store === true || supportsResponsesReasoningUpdate(params)) && !params.previous_response_id) {
|
|
1426
1195
|
continuationClaim = claimOpenAIResponsesHttpContinuation({
|
|
1427
1196
|
sessionId,
|
|
1428
1197
|
apiKey,
|
|
@@ -1457,6 +1226,7 @@ function createResponsesTransportExecutor(config) {
|
|
|
1457
1226
|
let continuationBaseline;
|
|
1458
1227
|
let dispatchedPreviousResponseId;
|
|
1459
1228
|
let contextUsageEligible = true;
|
|
1229
|
+
let requestedTier;
|
|
1460
1230
|
const createSseStream = async (initialRequest = continuationClaim?.request ?? params, initialAttemptKind = "initial", initialRejectedCompaction) => {
|
|
1461
1231
|
const { stream: responseStream } = await createResponsesStreamWithEncryptedContentRetry({
|
|
1462
1232
|
client,
|
|
@@ -1471,6 +1241,7 @@ function createResponsesTransportExecutor(config) {
|
|
|
1471
1241
|
onCompactionRejected: (checkpoint) => suppressOpenAIResponsesCompaction(output, model, responsesOptions, checkpoint),
|
|
1472
1242
|
canRetryStream: () => output.content.length === 0,
|
|
1473
1243
|
wrapStream: ({ stream: rawResponseStream, response, attempt }) => {
|
|
1244
|
+
requestedTier = attempt.request.service_tier;
|
|
1474
1245
|
contextUsageEligible &&= attempt.kind === "initial";
|
|
1475
1246
|
dispatchedPreviousResponseId = attempt.request.previous_response_id;
|
|
1476
1247
|
continuationBaseline = attempt.request.previous_response_id ? params : attempt.request;
|
|
@@ -1521,6 +1292,7 @@ function createResponsesTransportExecutor(config) {
|
|
|
1521
1292
|
}
|
|
1522
1293
|
});
|
|
1523
1294
|
finishWebSocket = websocket.finish;
|
|
1295
|
+
requestedTier = websocket.request.service_tier;
|
|
1524
1296
|
websocketBaseline = websocket.fullRequest;
|
|
1525
1297
|
recordResponsesInputReplay(output, websocket.inputReplay);
|
|
1526
1298
|
contextUsageEligible &&= websocket.inputReplay === void 0;
|
|
@@ -1577,6 +1349,7 @@ function createResponsesTransportExecutor(config) {
|
|
|
1577
1349
|
const terminal = await processResponsesStream(acceptedResponseStream, output, stream, model, {
|
|
1578
1350
|
canRetryIdentityConflict: () => hasOnlyResponsesFunctionTools(transport === "websocket" ? websocketBaseline : continuationBaseline),
|
|
1579
1351
|
...config.pricingOptions?.(responsesOptions, model),
|
|
1352
|
+
onServiceTier: (responseTier) => responsesServiceTierObserver.observe(options, requestedTier, responseTier),
|
|
1580
1353
|
firstEventTimeoutMs: getFirstStreamEventTimeoutMs(options) ?? config.firstEventTimeoutMs,
|
|
1581
1354
|
abortFirstEventStream: firstEvent.abort,
|
|
1582
1355
|
onFirstEventTimeout: getFirstStreamEventTimeoutHandler(options),
|
|
@@ -1618,7 +1391,8 @@ function createResponsesTransportExecutor(config) {
|
|
|
1618
1391
|
return;
|
|
1619
1392
|
}
|
|
1620
1393
|
if (error instanceof ResponsesStreamFailure && error.observation) logResponsesFailedNoDetails(error.observation);
|
|
1621
|
-
|
|
1394
|
+
const incompleteReason = output.diagnostics?.find(({ type }) => type === "openai_responses_terminal")?.details?.incompleteReason;
|
|
1395
|
+
log.warn(`[responses] error provider=${model.provider} api=${model.api} model=${model.id} ` + summarizeOpenAITransportError(error) + (typeof incompleteReason === "string" ? ` incompleteReason=${incompleteReason}` : ""));
|
|
1622
1396
|
failTransportStream({
|
|
1623
1397
|
stream,
|
|
1624
1398
|
output,
|
|
@@ -1651,7 +1425,10 @@ function createAzureOpenAIResponsesTransportStreamFn() {
|
|
|
1651
1425
|
firstEventTimeoutMs: AZURE_RESPONSES_FIRST_EVENT_TIMEOUT_MS,
|
|
1652
1426
|
createClient: createAzureOpenAIClient,
|
|
1653
1427
|
buildRequest: (model, context, options, metadata, replayMode) => {
|
|
1654
|
-
const deploymentName =
|
|
1428
|
+
const deploymentName = resolveAzureDeploymentNameFromMap({
|
|
1429
|
+
modelId: model.id,
|
|
1430
|
+
deploymentMap: process.env.AZURE_OPENAI_DEPLOYMENT_NAME_MAP
|
|
1431
|
+
});
|
|
1655
1432
|
const params = buildOpenAIResponsesParams(model, context, options, metadata, replayMode);
|
|
1656
1433
|
params.model = deploymentName;
|
|
1657
1434
|
delete params.store;
|
|
@@ -1659,12 +1436,6 @@ function createAzureOpenAIResponsesTransportStreamFn() {
|
|
|
1659
1436
|
}
|
|
1660
1437
|
});
|
|
1661
1438
|
}
|
|
1662
|
-
function resolveAzureDeploymentName(model) {
|
|
1663
|
-
return resolveAzureDeploymentNameFromMap({
|
|
1664
|
-
modelId: model.id,
|
|
1665
|
-
deploymentMap: process.env.AZURE_OPENAI_DEPLOYMENT_NAME_MAP
|
|
1666
|
-
});
|
|
1667
|
-
}
|
|
1668
1439
|
function createAzureOpenAIClient(model, apiKey, defaultHeaders, fetchOverride) {
|
|
1669
1440
|
const baseURL = model.baseUrl.replace(/\/+$/, "");
|
|
1670
1441
|
const clientOptions = {
|
|
@@ -1682,6 +1453,20 @@ function createAzureOpenAIClient(model, apiKey, defaultHeaders, fetchOverride) {
|
|
|
1682
1453
|
});
|
|
1683
1454
|
}
|
|
1684
1455
|
//#endregion
|
|
1456
|
+
//#region packages/ai/src/transports/provider-compaction-checkpoint.ts
|
|
1457
|
+
/** Whether provider replay state is a prefix-bound server compaction checkpoint. */
|
|
1458
|
+
function isCompactionReplayCheckpoint(replay) {
|
|
1459
|
+
const type = replay && typeof replay === "object" ? replay.type : void 0;
|
|
1460
|
+
return type === "anthropic-compaction" || type === "openai-responses-compaction" || type === "openai-responses-retained-compaction";
|
|
1461
|
+
}
|
|
1462
|
+
/** Strip prefix-bound checkpoints after local history rewrites. */
|
|
1463
|
+
function stripCompactionReplayCheckpoint(message) {
|
|
1464
|
+
if (!isCompactionReplayCheckpoint(message.providerReplay)) return message;
|
|
1465
|
+
const replaySafeMessage = { ...message };
|
|
1466
|
+
delete replaySafeMessage.providerReplay;
|
|
1467
|
+
return replaySafeMessage;
|
|
1468
|
+
}
|
|
1469
|
+
//#endregion
|
|
1685
1470
|
//#region packages/ai/src/transports/provider-compaction-replay.ts
|
|
1686
1471
|
function isAssistantReplayMessage(message) {
|
|
1687
1472
|
return message.role === "assistant";
|
|
@@ -1809,23 +1594,11 @@ function resolveCompactionReplayPressure(messages, model, identity, estimate, sy
|
|
|
1809
1594
|
prefixTokens
|
|
1810
1595
|
};
|
|
1811
1596
|
}
|
|
1812
|
-
/** Whether provider replay state is a prefix-bound server compaction checkpoint. */
|
|
1813
|
-
function isCompactionReplayCheckpoint(replay) {
|
|
1814
|
-
const type = replay && typeof replay === "object" ? replay.type : void 0;
|
|
1815
|
-
return type === "anthropic-compaction" || type === "openai-responses-compaction" || type === "openai-responses-retained-compaction";
|
|
1816
|
-
}
|
|
1817
|
-
/** Strip prefix-bound checkpoints after local history rewrites. */
|
|
1818
|
-
function stripCompactionReplayCheckpoint(message) {
|
|
1819
|
-
if (!isCompactionReplayCheckpoint(message.providerReplay)) return message;
|
|
1820
|
-
const replaySafeMessage = { ...message };
|
|
1821
|
-
delete replaySafeMessage.providerReplay;
|
|
1822
|
-
return replaySafeMessage;
|
|
1823
|
-
}
|
|
1824
1597
|
/** Strip prefix-bound checkpoint state from an in-place message rewrite. */
|
|
1825
1598
|
function stripCompactionReplayCheckpointInPlace(message) {
|
|
1826
1599
|
if (isCompactionReplayCheckpoint(message.providerReplay)) delete message.providerReplay;
|
|
1827
1600
|
}
|
|
1828
|
-
/**
|
|
1601
|
+
/** Preserve the covered prefix and reindex checkpoints after known content removals. */
|
|
1829
1602
|
function replaceCompactionReplayOwnerContent(message, content) {
|
|
1830
1603
|
const next = {
|
|
1831
1604
|
...message,
|
|
@@ -1836,6 +1609,7 @@ function replaceCompactionReplayOwnerContent(message, content) {
|
|
|
1836
1609
|
if (replay.type === "openai-responses-retained-compaction") return next;
|
|
1837
1610
|
const replayIndex = replay.replayIndex ?? 0;
|
|
1838
1611
|
if (content.length === 0 && message.content.length > 0 || replayIndex > message.content.length) return stripCompactionReplayCheckpoint(next);
|
|
1612
|
+
if (content.length === message.content.length && content.slice(0, replayIndex).every((block, index) => block === message.content[index])) return next;
|
|
1839
1613
|
let sourceIndex = 0;
|
|
1840
1614
|
let nextReplayIndex = 0;
|
|
1841
1615
|
if (!content.every((block) => {
|
|
@@ -1915,13 +1689,6 @@ function createTransportAwareStreamFnForModel(model, ctx) {
|
|
|
1915
1689
|
if (!streamFn) throw new Error(`Managed transport stream is unavailable for api "${model.api}"`);
|
|
1916
1690
|
return streamFn;
|
|
1917
1691
|
}
|
|
1918
|
-
/** Creates a managed OpenClaw transport stream for explicit fallback/runtime callers. */
|
|
1919
|
-
function createOpenClawTransportStreamFnForModel(model, ctx) {
|
|
1920
|
-
return createSupportedTransportStreamFn(model, ctx);
|
|
1921
|
-
}
|
|
1922
|
-
function createBoundaryAwareStreamFnForModel(model, ctx) {
|
|
1923
|
-
return createSupportedTransportStreamFn(model, ctx);
|
|
1924
|
-
}
|
|
1925
1692
|
function prepareTransportAwareSimpleModel(model, ctx) {
|
|
1926
1693
|
const streamFn = createTransportAwareStreamFnForModel(model, ctx);
|
|
1927
1694
|
const alias = resolveTransportAwareSimpleApi(model.api);
|
|
@@ -1931,16 +1698,8 @@ function prepareTransportAwareSimpleModel(model, ctx) {
|
|
|
1931
1698
|
api: alias
|
|
1932
1699
|
});
|
|
1933
1700
|
}
|
|
1934
|
-
function buildTransportAwareSimpleStreamFn(model, ctx) {
|
|
1935
|
-
return createTransportAwareStreamFnForModel(model, ctx);
|
|
1936
|
-
}
|
|
1937
1701
|
//#endregion
|
|
1938
1702
|
//#region packages/ai/src/transports/simple-completion-transport.ts
|
|
1939
|
-
/**
|
|
1940
|
-
* Simple completion transport preparation.
|
|
1941
|
-
*
|
|
1942
|
-
* Registers provider-specific stream functions and rewrites models that need OpenClaw-managed transport semantics.
|
|
1943
|
-
*/
|
|
1944
1703
|
/** Standalone completions have no durable session, but may require routing identity. */
|
|
1945
1704
|
function prepareHeadersForSimpleCompletion(model, options) {
|
|
1946
1705
|
return resolveOpencodeSessionHeaders(model, {
|
|
@@ -1966,32 +1725,29 @@ function resolveAnthropicVertexSimpleApi(baseUrl) {
|
|
|
1966
1725
|
}
|
|
1967
1726
|
function normalizeCodexResponsesBaseUrlForOpenAISdk(baseUrl) {
|
|
1968
1727
|
const normalized = baseUrl?.trim() || "https://chatgpt.com/backend-api";
|
|
1969
|
-
|
|
1970
|
-
|
|
1971
|
-
|
|
1972
|
-
|
|
1973
|
-
|
|
1974
|
-
|
|
1975
|
-
|
|
1976
|
-
|
|
1977
|
-
|
|
1978
|
-
|
|
1979
|
-
|
|
1980
|
-
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
|
|
1985
|
-
|
|
1728
|
+
const parsed = URL.parse(normalized);
|
|
1729
|
+
const pathname = parsed?.pathname.replace(/\/+$/u, "") ?? "";
|
|
1730
|
+
const path = pathname.toLowerCase();
|
|
1731
|
+
if (parsed?.hostname.toLowerCase() === "chatgpt.com" && [
|
|
1732
|
+
"/backend-api",
|
|
1733
|
+
"/backend-api/v1",
|
|
1734
|
+
"/backend-api/codex",
|
|
1735
|
+
"/backend-api/codex/v1",
|
|
1736
|
+
"/backend-api/codex/responses"
|
|
1737
|
+
].includes(path)) {
|
|
1738
|
+
parsed.pathname = "/backend-api/codex";
|
|
1739
|
+
parsed.search = "";
|
|
1740
|
+
parsed.hash = "";
|
|
1741
|
+
return parsed.toString().replace(/\/$/u, "");
|
|
1742
|
+
}
|
|
1743
|
+
if (normalized.includes("?") || normalized.includes("#")) throw new Error(INVALID_CODEX_BASE_URL_MESSAGE);
|
|
1744
|
+
if (parsed) {
|
|
1986
1745
|
parsed.pathname = path.endsWith("/codex/responses") ? pathname.slice(0, -10) : path.endsWith("/codex") ? pathname : `${pathname}/codex`;
|
|
1987
1746
|
return parsed.toString();
|
|
1988
|
-
} catch (error) {
|
|
1989
|
-
if (error instanceof Error && error.message === INVALID_CODEX_BASE_URL_MESSAGE) throw error;
|
|
1990
1747
|
}
|
|
1991
|
-
|
|
1992
|
-
|
|
1993
|
-
|
|
1994
|
-
return path.endsWith("/codex") ? path : `${path}/codex`;
|
|
1748
|
+
const customPath = normalized.replace(/\/+$/u, "");
|
|
1749
|
+
if (customPath.endsWith("/codex/responses")) return customPath.slice(0, -10);
|
|
1750
|
+
return customPath.endsWith("/codex") ? customPath : `${customPath}/codex`;
|
|
1995
1751
|
}
|
|
1996
1752
|
function resolveProviderSimpleCompletionApi(model, auth, agentId) {
|
|
1997
1753
|
const parts = [
|
|
@@ -2042,7 +1798,7 @@ function prepareCodexSimpleTransportModel(registry, model, cfg) {
|
|
|
2042
1798
|
if (model.provider !== "openai" || model.api !== "openai-chatgpt-responses") return;
|
|
2043
1799
|
const transportModel = projectModel(model, { baseUrl: normalizeCodexResponsesBaseUrlForOpenAISdk(model.baseUrl) });
|
|
2044
1800
|
const api = resolveTransportAwareSimpleApi(model.api);
|
|
2045
|
-
const streamFn =
|
|
1801
|
+
const streamFn = createSupportedTransportStreamFn(transportModel, { cfg });
|
|
2046
1802
|
if (!api || !streamFn) return;
|
|
2047
1803
|
if (!registerCustomApi(registry, api, streamFn)) return;
|
|
2048
1804
|
return projectModel(transportModel, { api });
|
|
@@ -2099,7 +1855,7 @@ function prepareModelForSimpleCompletion(params) {
|
|
|
2099
1855
|
if (codexTransportModel) return wrap(codexTransportModel);
|
|
2100
1856
|
const transportAwareModel = prepareTransportAwareSimpleModel(model, { cfg });
|
|
2101
1857
|
if (transportAwareModel !== model) {
|
|
2102
|
-
const streamFn =
|
|
1858
|
+
const streamFn = createTransportAwareStreamFnForModel(model, { cfg });
|
|
2103
1859
|
if (streamFn && registerCustomApi(apiRegistry, transportAwareModel.api, streamFn)) return wrap(transportAwareModel);
|
|
2104
1860
|
}
|
|
2105
1861
|
if (model.provider === "anthropic-vertex") {
|
|
@@ -2109,4 +1865,4 @@ function prepareModelForSimpleCompletion(params) {
|
|
|
2109
1865
|
return wrap(model);
|
|
2110
1866
|
}
|
|
2111
1867
|
//#endregion
|
|
2112
|
-
export { CompactionReplayRefreshRequiredError, GEMINI_THOUGHT_SIGNATURE_VALIDATOR_SKIP, IncompleteToolCallError, MALFORMED_STREAMING_FRAGMENT_ERROR_MESSAGE, OPENAI_RESPONSES_CALL_ID_RE, OPENAI_RESPONSES_FUNCTION_CALL_ITEM_ID_RE, OPENAI_RESPONSES_ID_MAX_LENGTH, 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,
|
|
1868
|
+
export { CompactionReplayRefreshRequiredError, GEMINI_THOUGHT_SIGNATURE_VALIDATOR_SKIP, IncompleteToolCallError, MALFORMED_STREAMING_FRAGMENT_ERROR_MESSAGE, OPENAI_RESPONSES_CALL_ID_RE, OPENAI_RESPONSES_FUNCTION_CALL_ITEM_ID_RE, OPENAI_RESPONSES_ID_MAX_LENGTH, applyAnthropicContextManagementToRequest, applyAnthropicEphemeralCacheControlMarkers, applyAnthropicPayloadPolicyToParams, applyAnthropicRequestCacheControl, applyCompletionsAnthropicCacheControl, applyOpenAIResponsesPayloadPolicy, assertCodeModeResponsesToolSurface, assignTransportErrorDetails, buildAnthropicSystemBlocks, buildOpenAIClientHeaders, buildOpenAICompletionsParams, buildOpenAISdkClientOptions, buildOpenAISdkRequestOptions, createTransportAwareStreamFnForModel as buildTransportAwareSimpleStreamFn, createTransportAwareStreamFnForModel, canonicalizeMaxTokensParam, captureOpenAIResponsesCompaction, coerceTransportToolCallArguments, consumeGoogleGenerateContentStream, convertGoogleTools, copyProviderAcceptanceObserver, createAnthropicMessagesTransportStreamFn, createAzureOpenAIResponsesTransportStreamFn, createSupportedTransportStreamFn as createBoundaryAwareStreamFnForModel, createSupportedTransportStreamFn as createOpenClawTransportStreamFnForModel, createDeepSeekTextFilter, createEmptyTransportUsage, createModelStreamCooperativeScheduler, createOpenAICompletionsTransportStreamFn, createOpenAIProviderAcceptanceHook, createOpenAIResponseHook, createOpenAIResponsesTransportStreamFn, createResponseModelTracker, createWritableTransportEventStream, detectOpenAICompletionsCompat, emitModelTransportDebug, enforceCodeModeResponsesToolSurface, failTransportStream, filterCodeModePayloadTools, finalizeTerminalToolCallArguments, finalizeTransportStream, flattenCompletionMessagesToStringContent, formatModelTransportDebugBaseUrl, formatModelTransportDebugUrl, getCompat, googleFlashSupportsMinimalThinking, hasOpenAICompatibleConversationTurn, isAnthropicServerToolClearingEnabled, isCodeModeModelVisibleToolName, isCompactionReplayCheckpoint, isDirectAnthropicModel, isNativeOpenAIEndpoint, isOpenAICodexResponsesModel, isOpenAICompletionsThinkingEnabled, iterateModelStream, log, logAnthropicContextEdits, measureUtf8AppendBytes, mergeTransportHeaders, normalizeCodexResponsesBaseUrlForOpenAISdk, normalizeOpenAIResponsesFunctionCallId, notifyProviderHttpMetadata, notifyProviderHttpResponse, notifyProviderStreamOpened, parseJsonObjectPreservingUnsafeIntegers, parseJsonPreservingUnsafeIntegers, parseOpenAICompletionsUsage, parseTerminalToolCallArguments, prepareHeadersForSimpleCompletion, prepareModelForSimpleCompletion, prepareTransportAwareSimpleModel, preserveCompactionReplayWindow, projectGoogleMessages, quoteUnsafeIntegerLiterals, readCodeModePayloadToolName, readOpenAICompletionsContentDeltas, readOpenAICompletionsReasoningBatch, replaceCompactionReplayOwnerContent, requestPreparedOpenAIResponsesCompaction, requiresCompactionReplayRefresh, requiresGoogleToolCallId, resolveAnthropicCacheOptions, resolveAnthropicEphemeralCacheControl, resolveAnthropicMessagesUrl, resolveAnthropicPayloadPolicy, resolveAnthropicRequestBetaHeader, resolveAnthropicServerCompactionPlan, resolveCodeModeResponsesVisibleToolNames, resolveCompactionReplayEligibility, resolveCompactionReplayPressure, resolveMaxTokensParam, resolveModelPayloadDebugMode, resolveModelSseDebugMode, resolveOpenAIClientBaseUrl, resolveOpenAICompletionsCompat, resolveOpenAIPromptCacheKeySupport, resolveOpenAIReasoningEffortMap, resolveOpenAIResponsesCompactEndpointPlan, resolveOpenAIResponsesPayloadPolicy, resolveOpenAIResponsesServerCompactionPlan, resolveOpenAIStrictToolFlagWithDiagnostics, resolvePromptCacheKey, resolveReplayableResponsesMessageId, resolveTransportAwareSimpleApi, sanitizeNonEmptyTransportPayloadText, sanitizeResponsesImagePayload, sanitizeTransportPayloadText, shouldNormalizeOpenAIResponsesToolCallId, sortPromptCacheToolsByName as sortTransportToolsByName, splitOpenAIFunctionCallPairing, stripCompactionReplayCheckpoint, stripCompactionReplayCheckpointInPlace, stripCompletionMessagesToRoleContent, supportsAnthropicServerSideFallback, throwIfModelStreamAborted, transportAbortError, usesNativeOpenAICodexResponsesBackend, withProviderAcceptanceObserver, withProviderResponseHook };
|