@openclaw/ai 2026.10.2 → 2026.10.5-beta.2
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 +6 -0
- package/dist/{anthropic-C4qygbtf.mjs → anthropic-BalhAzs-.mjs} +33 -63
- package/dist/{anthropic-payload-policy-DD7vzpxE.d.mts → anthropic-payload-policy-DGblkHL5.d.mts} +19 -19
- package/dist/{anthropic-stream-reducer-CWyWE21W.mjs → anthropic-stream-reducer-DkKeXXx4.mjs} +215 -297
- package/dist/{api-registry-B3rC2qu3.d.mts → api-registry-BhXXYdRA.d.mts} +2 -2
- package/dist/assistant-message-events-CHMJgbhs.mjs +18 -0
- package/dist/{assistant-output-D5762GPH.mjs → assistant-output-BuhRpLeD.mjs} +2 -2
- package/dist/{assistant-text-phase-DVZOxbuR.mjs → assistant-text-phase-Bn1hbvK9.mjs} +7 -6
- package/dist/{azure-openai-responses-DO-Fv8ha.mjs → azure-openai-responses-DfT9Ndd8.mjs} +8 -9
- package/dist/{credential-redaction-BKv49aiv.d.mts → credential-redaction-BHxruEH6.d.mts} +3 -1
- package/dist/{diagnostics-Caj-4RBA.mjs → diagnostics-tQasYct1.mjs} +10 -3
- package/dist/diagnostics.d.mts +7 -7
- package/dist/diagnostics.mjs +3 -3
- package/dist/{env-api-keys-CyX4VKGO.mjs → env-api-keys-CrxwdylR.mjs} +24 -35
- package/dist/event-stream-6UNs-AhN.d.mts +1 -0
- package/dist/{event-stream-DrRM_90c.d.mts → event-stream-BcqWLo_u.d.mts} +1 -1
- package/dist/{event-stream-C5AbCAaZ.mjs → event-stream-X2gmsUWv.mjs} +5 -8
- package/dist/event-stream.d.mts +2 -2
- package/dist/event-stream.mjs +1 -1
- package/dist/{google-interactions-DNXzPPwQ.mjs → google-interactions-9SSqsJg9.mjs} +52 -84
- package/dist/{google-messages-l7wgIF5I.mjs → google-messages-DsB7fmoQ.mjs} +26 -35
- package/dist/google-provider-stream-CcEI2-MC.mjs +58 -0
- package/dist/google-sYI2wnY6.mjs +20 -0
- package/dist/{google-shared-V8jogVPq.mjs → google-shared-zGR0QUyS.mjs} +6 -15
- package/dist/google-vertex-Dw_abY1w.mjs +40 -0
- package/dist/{host-u3o8XiAp.mjs → host-Bf3NjYNj.mjs} +3 -2
- package/dist/{host-DiPhRjrc.d.mts → host-CTDz7LXD.d.mts} +6 -3
- package/dist/{host-policy-BwhNNGQR.mjs → host-policy-BzZluO6_.mjs} +1 -1
- package/dist/{index-D27wAoOr.d.mts → index-BYDvopUB.d.mts} +8 -7
- package/dist/index.d.mts +7 -7
- package/dist/index.mjs +7 -6
- package/dist/internal/anthropic.d.mts +5 -5
- package/dist/internal/anthropic.mjs +4 -4
- 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 +2 -2
- package/dist/internal/openai-responses-payload-policy.mjs +2 -3
- package/dist/internal/openai.d.mts +9 -9
- package/dist/internal/openai.mjs +9 -11
- package/dist/internal/runtime.d.mts +31 -13
- package/dist/internal/runtime.mjs +10 -13
- package/dist/internal/shared.d.mts +5 -5
- package/dist/internal/shared.mjs +6 -7
- package/dist/internal/tool-schema.mjs +2 -2
- package/dist/{llm-request-activity-D8f_oxHj.mjs → llm-request-activity-CfMuh5cC.mjs} +2 -2
- package/dist/{mistral-cnoBDSIg.mjs → mistral-dCDCR5ur.mjs} +71 -146
- package/dist/{model-transport-url-C5f59L3Y.d.mts → model-transport-url-BrsjjdjR.d.mts} +5 -1
- package/dist/{number-coercion-V8-BhME4.mjs → number-coercion-C3hztWoY.mjs} +5 -4
- package/dist/{openai-chatgpt-responses-CHdn8YJ_.mjs → openai-chatgpt-responses-V4iP0dv5.mjs} +118 -194
- package/dist/{openai-completions-BZfHIaZ7.mjs → openai-completions-BY-kr5IS.mjs} +7 -6
- package/dist/{openai-completions-compat-GMN8A0fm.mjs → openai-completions-compat-CYX18uDk.mjs} +10 -6
- package/dist/{openai-completions-compat-BgPg1BRs.d.mts → openai-completions-compat-i-nLZxFy.d.mts} +10 -11
- package/dist/{openai-completions-transport-CuoQfnKV.mjs → openai-completions-transport-v38m71Oq.mjs} +1449 -294
- package/dist/{openai-prompt-cache-CFviG_D4.d.mts → openai-prompt-cache-DIPMrMFy.d.mts} +2 -2
- package/dist/{openai-prompt-cache-BK6E2g4Q.mjs → openai-prompt-cache-r93BJhjm.mjs} +1 -1
- package/dist/{openai-responses-BhAZFsL9.mjs → openai-responses-D5oiAUOG.mjs} +9 -10
- package/dist/{openai-responses-compaction-replay-BBNo098-.d.mts → openai-responses-compaction-replay-B2FE4Nw8.d.mts} +4 -4
- package/dist/{openai-responses-contracts-D5yVZBp-.d.mts → openai-responses-contracts-DKqMJ1Ct.d.mts} +9 -4
- package/dist/{openai-responses-contracts-BKu8O7l4.mjs → openai-responses-contracts-DlKMMTxK.mjs} +26 -6
- package/dist/{openai-responses-compaction-window-tA4QkU0o.mjs → openai-responses-endpoint-CinGh4VZ.mjs} +17 -7
- package/dist/{openai-responses-payload-policy-s1apQlZZ.d.mts → openai-responses-payload-policy-C7GsA1y0.d.mts} +2 -4
- package/dist/{openai-responses-prompt-observer-internal-CefUzh8M.mjs → openai-responses-request-lifecycle-NSIJo9jY.mjs} +39 -4
- package/dist/{openai-responses-shared-CKNmC3vC.mjs → openai-responses-shared-D-aDYAkJ.mjs} +1037 -328
- package/dist/{openai-responses-terminal-usage-CempLedn.d.mts → openai-responses-terminal-usage-BygjiAdi.d.mts} +2 -2
- package/dist/{openai-tool-schema-BIrI0mrA.mjs → openai-tool-schema-DDPXsvJP.mjs} +220 -400
- package/dist/{positive-integer-CwLi8LUL.mjs → positive-integer-CqWjqSi9.mjs} +1 -1
- package/dist/{provider-error-DQBE1bUQ.mjs → provider-error-CF9GWCs2.mjs} +5 -3
- package/dist/{provider-options-CkieKvNJ.d.mts → provider-options-CVrXZBtA.d.mts} +6 -10
- package/dist/{provider-transport-turn-state-BX6TfCyW.mjs → provider-transport-turn-state-BOpxgm-J.mjs} +2 -2
- package/dist/{provider-types-v3bmqsfg.d.mts → provider-types-CHtRx0dI.d.mts} +3 -3
- package/dist/provider-types.d.mts +6 -6
- package/dist/providers.d.mts +2 -2
- package/dist/providers.mjs +12 -12
- package/dist/{reasoning-tag-text-partitioner-Ju9VpUGl.mjs → reasoning-tag-text-partitioner-CpOy9-IQ.mjs} +374 -235
- package/dist/{required-api-key-D4kn3252.mjs → required-api-key-CFJvcFy_.mjs} +1 -1
- package/dist/{simple-options-7QuSKriJ.mjs → simple-options-BAu4B54D.mjs} +9 -11
- package/dist/{src-VWy9E7DZ.mjs → src-C44MKrW5.mjs} +20 -9
- package/dist/{stream-DFaRxi2D.mjs → stream-Dd8DwRFL.mjs} +12 -21
- package/dist/{stream-first-event-timeout-D9ZmL_s9.mjs → stream-first-event-timeout-Dc42hKv6.mjs} +8 -21
- package/dist/{streaming-byte-guard-CC-HMn_u.mjs → streaming-byte-guard-DBXr1XYn.mjs} +16 -1
- package/dist/{string-normalization-PN10hf6d.mjs → string-normalization-I3ux50s9.mjs} +1 -1
- package/dist/{text-signature-D_vRrx-z.mjs → text-signature-Drb4Erb8.mjs} +32 -5
- package/dist/{tool-schema-json-projection-Ct8SeBeJ.mjs → tool-schema-json-projection-B8sG1I9v.mjs} +29 -23
- package/dist/{transport-stream-shared-DW-7-qLR.d.mts → transport-stream-shared-BmpzDtdQ.d.mts} +4 -4
- package/dist/{transport-stream-shared-CCR7hSW0.mjs → transport-stream-shared-CWGOuLcA.mjs} +8 -16
- package/dist/transports.d.mts +34 -23
- package/dist/transports.mjs +76 -1235
- package/dist/{types-DvzmWW8J.d.mts → types-Bd2T86VJ.d.mts} +5 -23
- package/dist/types-Kdfw_04V.d.mts +1 -0
- package/dist/types.d.mts +6 -6
- package/dist/types.mjs +5 -4
- package/dist/{validation-B3lQt_VE.d.mts → validation-DdGB1yy3.d.mts} +1 -1
- package/dist/{validation-DbqlIfDn.mjs → validation-ZX_sPVV0.mjs} +3 -9
- package/dist/validation.d.mts +1 -1
- package/dist/validation.mjs +1 -1
- package/package.json +4 -9
- package/dist/env-api-keys-BR0MUYYD.d.mts +0 -17
- package/dist/event-stream-DqDQWqiy.d.mts +0 -1
- package/dist/google-B2g_Xn4d.mjs +0 -54
- package/dist/google-vertex-_khoip47.mjs +0 -88
- package/dist/internal/env-api-keys.d.mts +0 -2
- package/dist/internal/env-api-keys.mjs +0 -2
- package/dist/openai-responses-endpoint-TV0y50fb.mjs +0 -11
- package/dist/openai-responses-request-lifecycle-Fsag-IGZ.mjs +0 -36
- package/dist/openai-transport-params-D7JMUPjf.mjs +0 -735
- package/dist/openai-web-search-tools-Cfu0uLyN.mjs +0 -14
- package/dist/provider-replay-context-CO_Eplnc.mjs +0 -25
- package/dist/types-UlNana-2.d.mts +0 -1
package/dist/{openai-chatgpt-responses-CHdn8YJ_.mjs → openai-chatgpt-responses-V4iP0dv5.mjs}
RENAMED
|
@@ -1,25 +1,24 @@
|
|
|
1
1
|
import { i as formatThrownValue, n as createAssistantMessageDiagnostic, t as appendAssistantMessageDiagnostic } from "./diagnostics-DzrF1h4J.mjs";
|
|
2
|
-
import { t as AssistantMessageEventStream } from "./event-stream-
|
|
2
|
+
import { t as AssistantMessageEventStream } from "./event-stream-X2gmsUWv.mjs";
|
|
3
3
|
import { o as isRecord } from "./record-coerce-CNDovvft.mjs";
|
|
4
|
-
import {
|
|
5
|
-
import { E as headersToRecord, a as resolveAiTransportHeaderSentinels, r as getAiTransportHost } from "./host-
|
|
6
|
-
import {
|
|
4
|
+
import { i as clampPositiveTimerTimeoutMs } from "./number-coercion-C3hztWoY.mjs";
|
|
5
|
+
import { E as headersToRecord, a as resolveAiTransportHeaderSentinels, r as getAiTransportHost } from "./host-Bf3NjYNj.mjs";
|
|
6
|
+
import { h as responsesPromptObserver, k as supportsOpenAITemperature } from "./openai-responses-contracts-DlKMMTxK.mjs";
|
|
7
7
|
import { r as registerSessionResourceCleanup } from "./session-resources-D1wgDQ8C.mjs";
|
|
8
|
-
import
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
8
|
+
import "./provider-error-CF9GWCs2.mjs";
|
|
9
|
+
import { n as clampOpenAIPromptCacheKey } from "./openai-prompt-cache-r93BJhjm.mjs";
|
|
10
|
+
import { s as WEBSOCKET_NON_RETRYABLE_CLOSE_ERROR_CODE, v as extractErrorCodeOrErrno, y as toErrorObject } from "./diagnostics-tQasYct1.mjs";
|
|
11
|
+
import { a as MALFORMED_STREAMING_FRAGMENT_ERROR_MESSAGE, d as streamFragmentError, p as consumeResponseBytes } from "./text-signature-Drb4Erb8.mjs";
|
|
11
12
|
import { parseRetryAfterHeadersSeconds } from "./internal/retry-after.mjs";
|
|
12
|
-
import { c as resolveOpenAIResponsesTextFormat } from "./openai-completions-compat-
|
|
13
|
-
import { n as buildManagedModelFetch } from "./host-policy-
|
|
14
|
-
import { S as withProviderResponseHook, b as transportAbortError, h as notifyProviderStreamOpened, n as assignTransportErrorDetails } from "./transport-stream-shared-
|
|
15
|
-
import { C as stripSystemPromptCacheBoundary, n as buildBaseOptions } from "./simple-options-
|
|
16
|
-
import {
|
|
17
|
-
import { t as createAssistantOutput } from "./assistant-output-
|
|
18
|
-
import { a as withFirstStreamEventTimeout, i as getFirstStreamEventTimeoutMs, r as getFirstStreamEventTimeoutHandler, t as createFirstStreamEventAbortController } from "./stream-first-event-timeout-
|
|
19
|
-
import {
|
|
20
|
-
import { t as
|
|
21
|
-
import { n as withResponsesRequestAcceptance, t as responsesRequestLifecycle } from "./openai-responses-request-lifecycle-Fsag-IGZ.mjs";
|
|
22
|
-
import { t as requireApiKey } from "./required-api-key-D4kn3252.mjs";
|
|
13
|
+
import { c as resolveOpenAIResponsesTextFormat } from "./openai-completions-compat-CYX18uDk.mjs";
|
|
14
|
+
import { n as buildManagedModelFetch } from "./host-policy-BzZluO6_.mjs";
|
|
15
|
+
import { S as withProviderResponseHook, b as transportAbortError, h as notifyProviderStreamOpened, n as assignTransportErrorDetails } from "./transport-stream-shared-CWGOuLcA.mjs";
|
|
16
|
+
import { C as stripSystemPromptCacheBoundary, n as buildBaseOptions } from "./simple-options-BAu4B54D.mjs";
|
|
17
|
+
import { Dt as createResponseModelTracker, E as ResponsesStreamFailure, Et as createOpenAIResponseHook, F as convertProviderResponsesMessages, S as isInvalidEncryptedContentError, T as resolveNextResponsesEncryptedContentAttempt, Tt as createOpenAIProviderAcceptanceHook, _t as resolveOpenAISimpleReasoningEffort, at as suppressOpenAIResponsesCompaction, b as commitResponsesEncryptedContentAttempt, gt as resolveOpenAIRequestReasoning, i as convertResponsesToolPayload, j as recordResponsesContextUsage, n as applyResponsesServiceTierPricing, nt as buildOpenAIResponsesReasoningReplayMetadata, o as readOpenAIMisalignmentReview, s as processResponsesStream } from "./openai-responses-shared-D-aDYAkJ.mjs";
|
|
18
|
+
import { t as createAssistantOutput } from "./assistant-output-BuhRpLeD.mjs";
|
|
19
|
+
import { a as withFirstStreamEventTimeout, i as getFirstStreamEventTimeoutMs, r as getFirstStreamEventTimeoutHandler, t as createFirstStreamEventAbortController } from "./stream-first-event-timeout-Dc42hKv6.mjs";
|
|
20
|
+
import { n as withResponsesRequestAcceptance, r as createResponsesPromptEgressObserver, t as responsesRequestLifecycle } from "./openai-responses-request-lifecycle-NSIJo9jY.mjs";
|
|
21
|
+
import { t as requireApiKey } from "./required-api-key-CFJvcFy_.mjs";
|
|
23
22
|
import { n as resolveOpenAICodexAccountId } from "./openai-chatgpt-jwt-KWcgd0d_.mjs";
|
|
24
23
|
//#region packages/ai/src/providers/openai-chatgpt-responses-events.ts
|
|
25
24
|
var CodexApiError = class extends Error {
|
|
@@ -34,9 +33,10 @@ var CodexApiError = class extends Error {
|
|
|
34
33
|
};
|
|
35
34
|
function extractCodexEventError(event) {
|
|
36
35
|
const nested = isRecord(event.error) ? event.error : void 0;
|
|
36
|
+
const read = (field) => typeof event[field] === "string" ? event[field] : typeof nested?.[field] === "string" ? nested[field] : void 0;
|
|
37
37
|
return {
|
|
38
|
-
code:
|
|
39
|
-
message:
|
|
38
|
+
code: read("code"),
|
|
39
|
+
message: read("message")
|
|
40
40
|
};
|
|
41
41
|
}
|
|
42
42
|
async function* mapCodexEvents(events, initialResponseHeaders, options) {
|
|
@@ -130,8 +130,7 @@ async function* parseOpenAIChatGptResponsesSse(response) {
|
|
|
130
130
|
try {
|
|
131
131
|
event = JSON.parse(data);
|
|
132
132
|
} catch (cause) {
|
|
133
|
-
|
|
134
|
-
throw new CodexProtocolError(MALFORMED_STREAMING_FRAGMENT_ERROR_MESSAGE, { cause });
|
|
133
|
+
throw streamFragmentError(cause, CodexProtocolError);
|
|
135
134
|
}
|
|
136
135
|
yield event;
|
|
137
136
|
}
|
|
@@ -163,17 +162,16 @@ function resolveCodexWebSocketUrl(baseUrl) {
|
|
|
163
162
|
//#endregion
|
|
164
163
|
//#region packages/ai/src/providers/openai-chatgpt-responses-websocket-authority.ts
|
|
165
164
|
const OPENAI_BETA_RESPONSES_WEBSOCKETS = "responses_websockets=2026-02-06";
|
|
166
|
-
function
|
|
165
|
+
function resolveCodexWebSocketAuthority(params) {
|
|
166
|
+
if (params.transport === "sse") return;
|
|
167
|
+
const headers = params.headers();
|
|
167
168
|
return {
|
|
168
|
-
transportHost,
|
|
169
|
-
url: resolveCodexWebSocketUrl(baseUrl),
|
|
169
|
+
transportHost: params.transportHost,
|
|
170
|
+
url: resolveCodexWebSocketUrl(params.baseUrl),
|
|
170
171
|
headers,
|
|
171
172
|
normalizedHeaders: Array.from(headers.entries()).filter(([name]) => name !== "traceparent")
|
|
172
173
|
};
|
|
173
174
|
}
|
|
174
|
-
function resolveCodexWebSocketAuthority(params) {
|
|
175
|
-
return params.transport === "sse" ? void 0 : createCodexWebSocketAuthority(params.transportHost, params.baseUrl, params.headers());
|
|
176
|
-
}
|
|
177
175
|
function buildCodexWebSocketHeaders(baseHeaders, requestId) {
|
|
178
176
|
baseHeaders.delete("accept");
|
|
179
177
|
baseHeaders.delete("content-type");
|
|
@@ -375,6 +373,30 @@ const streamOpenAICodexResponses = (model, context, options) => {
|
|
|
375
373
|
...options,
|
|
376
374
|
signal: activeSignal
|
|
377
375
|
};
|
|
376
|
+
const processStream = (events, streamOptions, activitySignal) => processResponsesStream(events, output, stream, model, {
|
|
377
|
+
serviceTier: streamOptions?.serviceTier,
|
|
378
|
+
firstEventTimeoutMs: getFirstStreamEventTimeoutMs(streamOptions),
|
|
379
|
+
abortFirstEventStream: firstEventAbort?.abort,
|
|
380
|
+
onFirstEventTimeout: getFirstStreamEventTimeoutHandler(streamOptions),
|
|
381
|
+
signal: activitySignal ?? streamOptions?.signal,
|
|
382
|
+
reasoningReplayMetadata: buildOpenAIResponsesReasoningReplayMetadata(model, {
|
|
383
|
+
sessionId: streamOptions?.sessionId,
|
|
384
|
+
authProfileId: streamOptions?.authProfileId
|
|
385
|
+
}),
|
|
386
|
+
resolveServiceTier: resolveCodexServiceTier,
|
|
387
|
+
applyServiceTierPricing: (usage, serviceTier) => applyResponsesServiceTierPricing(usage, serviceTier, model)
|
|
388
|
+
});
|
|
389
|
+
const completeStream = (terminal, attempt, ErrorType) => {
|
|
390
|
+
if (activeSignal?.aborted) throw transportAbortError(activeSignal);
|
|
391
|
+
if (output.stopReason === "aborted" || output.stopReason === "error") throw new ErrorType(output.errorMessage ?? "An unknown error occurred");
|
|
392
|
+
if (terminal && attempt.kind === "initial") recordResponsesContextUsage(output, model, options, attempt.request, terminal.output, "provider");
|
|
393
|
+
stream.push({
|
|
394
|
+
type: "done",
|
|
395
|
+
reason: output.stopReason,
|
|
396
|
+
message: output
|
|
397
|
+
});
|
|
398
|
+
stream.end();
|
|
399
|
+
};
|
|
378
400
|
const transport = options?.transport || "auto";
|
|
379
401
|
let websocketAuthority;
|
|
380
402
|
if (!transportHost.requiresManagedTransport(model)) try {
|
|
@@ -402,22 +424,13 @@ const streamOpenAICodexResponses = (model, context, options) => {
|
|
|
402
424
|
const dispatch = {};
|
|
403
425
|
websocketStarted = false;
|
|
404
426
|
try {
|
|
405
|
-
|
|
427
|
+
completeStream(await processWebSocketStream(websocketState, websocketAuthority, activeAttempt.request, output, stream, model, () => {
|
|
406
428
|
websocketStarted = true;
|
|
407
429
|
}, () => {
|
|
408
430
|
commitSemanticAttempt(activeAttempt);
|
|
409
|
-
}, requestOptions,
|
|
431
|
+
}, requestOptions, processStream, observePromptEgress, activeAttempt.kind, (request) => {
|
|
410
432
|
dispatch.request = request;
|
|
411
|
-
}, options?.signal);
|
|
412
|
-
if (activeSignal?.aborted) throw transportAbortError(activeSignal);
|
|
413
|
-
if (output.stopReason === "aborted" || output.stopReason === "error") throw new CodexApiError(output.errorMessage ?? "An unknown error occurred");
|
|
414
|
-
if (terminal && activeAttempt.kind === "initial") recordResponsesContextUsage(output, model, options, activeAttempt.request, terminal.output, "provider");
|
|
415
|
-
stream.push({
|
|
416
|
-
type: "done",
|
|
417
|
-
reason: output.stopReason,
|
|
418
|
-
message: output
|
|
419
|
-
});
|
|
420
|
-
stream.end();
|
|
433
|
+
}, options?.signal), activeAttempt, CodexApiError);
|
|
421
434
|
return;
|
|
422
435
|
} catch (error) {
|
|
423
436
|
const aborted = activeSignal?.aborted;
|
|
@@ -427,7 +440,7 @@ const streamOpenAICodexResponses = (model, context, options) => {
|
|
|
427
440
|
retriedWebSocketRejection = false;
|
|
428
441
|
continue;
|
|
429
442
|
}
|
|
430
|
-
const reconnectBeforeStart = !websocketStarted && isWebSocketConnectionLimitReachedError(error) ||
|
|
443
|
+
const reconnectBeforeStart = !websocketStarted && (isWebSocketConnectionLimitReachedError(error) || dispatch.request?.previous_response_id && error instanceof CodexApiError && error.message === WEBSOCKET_REPLAY_REJECTION);
|
|
431
444
|
if (!aborted && reconnectBeforeStart && !retriedWebSocketRejection) {
|
|
432
445
|
retriedWebSocketRejection = true;
|
|
433
446
|
continue;
|
|
@@ -510,7 +523,7 @@ const streamOpenAICodexResponses = (model, context, options) => {
|
|
|
510
523
|
if (!nextSemanticAttempt) throw terminalResponseError;
|
|
511
524
|
semanticAttempt = nextSemanticAttempt;
|
|
512
525
|
}
|
|
513
|
-
|
|
526
|
+
completeStream(await processStream(withProviderResponseHook({
|
|
514
527
|
stream: mapCodexEvents(parseOpenAIChatGptResponsesSse(response), response.headers, requestOptions),
|
|
515
528
|
signal: firstEventAbort.signal,
|
|
516
529
|
abort: firstEventAbort.abort,
|
|
@@ -519,29 +532,7 @@ const streamOpenAICodexResponses = (model, context, options) => {
|
|
|
519
532
|
type: "start",
|
|
520
533
|
partial: output
|
|
521
534
|
})
|
|
522
|
-
});
|
|
523
|
-
const terminal = await processResponsesStream(hookedResponseStream, output, stream, model, {
|
|
524
|
-
serviceTier: options?.serviceTier,
|
|
525
|
-
firstEventTimeoutMs: getFirstStreamEventTimeoutMs(options),
|
|
526
|
-
abortFirstEventStream: firstEventAbort.abort,
|
|
527
|
-
onFirstEventTimeout: getFirstStreamEventTimeoutHandler(options),
|
|
528
|
-
signal: options?.signal,
|
|
529
|
-
reasoningReplayMetadata: buildOpenAIResponsesReasoningReplayMetadata(model, {
|
|
530
|
-
sessionId: options?.sessionId,
|
|
531
|
-
authProfileId: options?.authProfileId
|
|
532
|
-
}),
|
|
533
|
-
resolveServiceTier: resolveCodexServiceTier,
|
|
534
|
-
applyServiceTierPricing: (usage, serviceTier) => applyResponsesServiceTierPricing(usage, serviceTier, model)
|
|
535
|
-
});
|
|
536
|
-
if (activeSignal?.aborted) throw transportAbortError(activeSignal);
|
|
537
|
-
if (output.stopReason === "aborted" || output.stopReason === "error") throw new Error(output.errorMessage ?? "An unknown error occurred");
|
|
538
|
-
if (terminal && semanticAttempt.kind === "initial") recordResponsesContextUsage(output, model, options, semanticAttempt.request, terminal.output, "provider");
|
|
539
|
-
stream.push({
|
|
540
|
-
type: "done",
|
|
541
|
-
reason: output.stopReason,
|
|
542
|
-
message: output
|
|
543
|
-
});
|
|
544
|
-
stream.end();
|
|
535
|
+
}), options), semanticAttempt, Error);
|
|
545
536
|
} catch (error) {
|
|
546
537
|
await responsesRequestLifecycle.get(options)?.settle().catch(() => void 0);
|
|
547
538
|
const requestTimedOut = isRequestTimeoutError(error, options?.signal, requestTimeoutSignal, requestTimeoutMs) && requestTimeoutMs !== void 0;
|
|
@@ -715,33 +706,18 @@ async function connectWebSocket(url, headers, signal) {
|
|
|
715
706
|
reject(error instanceof Error ? error : new Error(String(error)));
|
|
716
707
|
return;
|
|
717
708
|
}
|
|
718
|
-
const
|
|
709
|
+
const settle = (error, aborted = false) => {
|
|
719
710
|
if (settled) return;
|
|
720
711
|
settled = true;
|
|
721
712
|
cleanup();
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
const error = extractWebSocketError(event);
|
|
726
|
-
if (settled) return;
|
|
727
|
-
settled = true;
|
|
728
|
-
cleanup();
|
|
729
|
-
reject(error);
|
|
730
|
-
};
|
|
731
|
-
const onClose = (event) => {
|
|
732
|
-
const error = extractWebSocketCloseError(event);
|
|
733
|
-
if (settled) return;
|
|
734
|
-
settled = true;
|
|
735
|
-
cleanup();
|
|
736
|
-
reject(error);
|
|
737
|
-
};
|
|
738
|
-
const onAbort = () => {
|
|
739
|
-
if (settled) return;
|
|
740
|
-
settled = true;
|
|
741
|
-
cleanup();
|
|
742
|
-
socket.close(1e3, "aborted");
|
|
743
|
-
reject(/* @__PURE__ */ new Error("Request was aborted"));
|
|
713
|
+
if (aborted) socket.close(1e3, "aborted");
|
|
714
|
+
if (error) reject(error);
|
|
715
|
+
else resolve(socket);
|
|
744
716
|
};
|
|
717
|
+
const onOpen = () => settle();
|
|
718
|
+
const onError = (event) => settle(extractWebSocketError(event));
|
|
719
|
+
const onClose = (event) => settle(extractWebSocketCloseError(event));
|
|
720
|
+
const onAbort = () => settle(/* @__PURE__ */ new Error("Request was aborted"), true);
|
|
745
721
|
const cleanup = () => {
|
|
746
722
|
socket.removeEventListener("open", onOpen);
|
|
747
723
|
socket.removeEventListener("error", onError);
|
|
@@ -854,12 +830,15 @@ async function* parseWebSocket(socket, signal) {
|
|
|
854
830
|
pending = null;
|
|
855
831
|
resolve();
|
|
856
832
|
};
|
|
833
|
+
const finish = (error) => {
|
|
834
|
+
if (error) failed = error;
|
|
835
|
+
done = true;
|
|
836
|
+
wake();
|
|
837
|
+
};
|
|
857
838
|
const onMessage = (event) => {
|
|
858
839
|
const data = event && typeof event === "object" && "data" in event ? event.data : void 0;
|
|
859
840
|
if (typeof data !== "string") {
|
|
860
|
-
|
|
861
|
-
done = true;
|
|
862
|
-
wake();
|
|
841
|
+
finish(new CodexProtocolError(MALFORMED_STREAMING_FRAGMENT_ERROR_MESSAGE, { payload: data }));
|
|
863
842
|
return;
|
|
864
843
|
}
|
|
865
844
|
try {
|
|
@@ -872,34 +851,15 @@ async function* parseWebSocket(socket, signal) {
|
|
|
872
851
|
queue.push(parsed);
|
|
873
852
|
wake();
|
|
874
853
|
} catch (cause) {
|
|
875
|
-
|
|
854
|
+
finish(new CodexProtocolError(`Invalid Codex WebSocket JSON: ${formatThrownValue(cause)}`, {
|
|
876
855
|
cause,
|
|
877
856
|
payload: data
|
|
878
|
-
});
|
|
879
|
-
done = true;
|
|
880
|
-
wake();
|
|
881
|
-
}
|
|
882
|
-
};
|
|
883
|
-
const onError = (event) => {
|
|
884
|
-
failed = extractWebSocketError(event);
|
|
885
|
-
done = true;
|
|
886
|
-
wake();
|
|
887
|
-
};
|
|
888
|
-
const onClose = (event) => {
|
|
889
|
-
if (sawCompletion) {
|
|
890
|
-
done = true;
|
|
891
|
-
wake();
|
|
892
|
-
return;
|
|
857
|
+
}));
|
|
893
858
|
}
|
|
894
|
-
if (!failed) failed = extractWebSocketCloseError(event);
|
|
895
|
-
done = true;
|
|
896
|
-
wake();
|
|
897
|
-
};
|
|
898
|
-
const onAbort = () => {
|
|
899
|
-
failed = /* @__PURE__ */ new Error("Request was aborted");
|
|
900
|
-
done = true;
|
|
901
|
-
wake();
|
|
902
859
|
};
|
|
860
|
+
const onError = (event) => finish(extractWebSocketError(event));
|
|
861
|
+
const onClose = (event) => finish(!sawCompletion && !failed ? extractWebSocketCloseError(event) : void 0);
|
|
862
|
+
const onAbort = () => finish(/* @__PURE__ */ new Error("Request was aborted"));
|
|
903
863
|
socket.addEventListener("message", onMessage);
|
|
904
864
|
socket.addEventListener("error", onError);
|
|
905
865
|
socket.addEventListener("close", onClose);
|
|
@@ -926,58 +886,52 @@ async function* parseWebSocket(socket, signal) {
|
|
|
926
886
|
signal?.removeEventListener("abort", onAbort);
|
|
927
887
|
}
|
|
928
888
|
}
|
|
929
|
-
function
|
|
889
|
+
function serializeRequestContext(body) {
|
|
930
890
|
const { input: _input, previous_response_id: _previousResponseId, ...rest } = body;
|
|
931
|
-
return rest;
|
|
932
|
-
}
|
|
933
|
-
function requestBodiesMatchExceptInput(a, b) {
|
|
934
|
-
return JSON.stringify(requestBodyWithoutInput(a)) === JSON.stringify(requestBodyWithoutInput(b));
|
|
935
|
-
}
|
|
936
|
-
function getCachedWebSocketInputDelta(body, continuation) {
|
|
937
|
-
if (!requestBodiesMatchExceptInput(body, continuation.lastRequestBody)) return;
|
|
938
|
-
const currentInput = body.input ?? [];
|
|
939
|
-
const baseline = [...continuation.lastRequestBody.input ?? [], ...continuation.lastResponseItems];
|
|
940
|
-
if (currentInput.length < baseline.length) return;
|
|
941
|
-
const prefix = currentInput.slice(0, baseline.length);
|
|
942
|
-
if (JSON.stringify(prefix) !== JSON.stringify(baseline)) return;
|
|
943
|
-
return currentInput.slice(baseline.length);
|
|
891
|
+
return JSON.stringify(rest);
|
|
944
892
|
}
|
|
945
893
|
function buildCachedWebSocketRequestBody(entry, body) {
|
|
946
894
|
const continuation = entry.continuation;
|
|
947
895
|
if (!continuation) return body;
|
|
948
|
-
const
|
|
949
|
-
|
|
896
|
+
const currentInput = body.input ?? [];
|
|
897
|
+
const baseline = [...continuation.lastRequestBody.input ?? [], ...continuation.lastResponseItems];
|
|
898
|
+
if (!continuation.lastResponseId || serializeRequestContext(body) !== serializeRequestContext(continuation.lastRequestBody) || currentInput.length < baseline.length || JSON.stringify(currentInput.slice(0, baseline.length)) !== JSON.stringify(baseline)) {
|
|
950
899
|
entry.continuation = void 0;
|
|
951
900
|
return body;
|
|
952
901
|
}
|
|
953
902
|
return {
|
|
954
903
|
...body,
|
|
955
904
|
previous_response_id: continuation.lastResponseId,
|
|
956
|
-
input:
|
|
905
|
+
input: currentInput.slice(baseline.length)
|
|
957
906
|
};
|
|
958
907
|
}
|
|
959
|
-
async function
|
|
960
|
-
let started = false;
|
|
961
|
-
for await (const event of events) {
|
|
962
|
-
if (!started) {
|
|
963
|
-
started = true;
|
|
964
|
-
onFirstProviderEvent();
|
|
965
|
-
onStart();
|
|
966
|
-
await reportStreamOpened();
|
|
967
|
-
stream.push({
|
|
968
|
-
type: "start",
|
|
969
|
-
partial: output
|
|
970
|
-
});
|
|
971
|
-
}
|
|
972
|
-
yield event;
|
|
973
|
-
}
|
|
974
|
-
}
|
|
975
|
-
async function processWebSocketStream(state, authority, body, output, stream, model, onFirstProviderEvent, onStart, options, abortFirstEventStream, observePromptEgress, payloadVariant = "initial", onRequestSent, activitySignal) {
|
|
908
|
+
async function processWebSocketStream(state, authority, body, output, stream, model, onFirstProviderEvent, onStart, options, processStream, observePromptEgress, payloadVariant = "initial", onRequestSent, activitySignal) {
|
|
976
909
|
const { socket, entry, release } = await acquireWebSocket(state, authority, options?.sessionId, options?.signal);
|
|
977
910
|
let keepConnection = true;
|
|
978
911
|
const useCachedContext = options?.transport === "websocket-cached" || options?.transport === "auto";
|
|
979
|
-
const
|
|
980
|
-
|
|
912
|
+
const requestBody = useCachedContext && entry ? buildCachedWebSocketRequestBody(entry, body) : body;
|
|
913
|
+
async function* acceptedEvents() {
|
|
914
|
+
let started = false;
|
|
915
|
+
for await (const event of mapCodexEvents(parseWebSocket(socket, options?.signal), void 0, options)) {
|
|
916
|
+
if (!started) {
|
|
917
|
+
started = true;
|
|
918
|
+
onFirstProviderEvent();
|
|
919
|
+
onStart();
|
|
920
|
+
await notifyProviderStreamOpened({
|
|
921
|
+
options,
|
|
922
|
+
cancelStream: () => {
|
|
923
|
+
keepConnection = false;
|
|
924
|
+
closeWebSocketSilently(socket);
|
|
925
|
+
}
|
|
926
|
+
});
|
|
927
|
+
stream.push({
|
|
928
|
+
type: "start",
|
|
929
|
+
partial: output
|
|
930
|
+
});
|
|
931
|
+
}
|
|
932
|
+
yield event;
|
|
933
|
+
}
|
|
934
|
+
}
|
|
981
935
|
try {
|
|
982
936
|
if (options?.signal?.aborted) throw transportAbortError(options.signal);
|
|
983
937
|
observePromptEgress?.(requestBody, {
|
|
@@ -995,25 +949,7 @@ async function processWebSocketStream(state, authority, body, output, stream, mo
|
|
|
995
949
|
...requestBody
|
|
996
950
|
}));
|
|
997
951
|
onRequestSent?.(requestBody);
|
|
998
|
-
const terminal = await
|
|
999
|
-
options,
|
|
1000
|
-
cancelStream: () => {
|
|
1001
|
-
keepConnection = false;
|
|
1002
|
-
closeWebSocketSilently(socket);
|
|
1003
|
-
}
|
|
1004
|
-
}), onStart), output, stream, model, {
|
|
1005
|
-
serviceTier: options?.serviceTier,
|
|
1006
|
-
firstEventTimeoutMs: getFirstStreamEventTimeoutMs(options),
|
|
1007
|
-
abortFirstEventStream,
|
|
1008
|
-
onFirstEventTimeout: getFirstStreamEventTimeoutHandler(options),
|
|
1009
|
-
signal: activitySignal ?? options?.signal,
|
|
1010
|
-
reasoningReplayMetadata: buildOpenAIResponsesReasoningReplayMetadata(model, {
|
|
1011
|
-
sessionId: options?.sessionId,
|
|
1012
|
-
authProfileId: options?.authProfileId
|
|
1013
|
-
}),
|
|
1014
|
-
resolveServiceTier: resolveCodexServiceTier,
|
|
1015
|
-
applyServiceTierPricing: (usage, serviceTier) => applyResponsesServiceTierPricing(usage, serviceTier, model)
|
|
1016
|
-
});
|
|
952
|
+
const terminal = await processStream(acceptedEvents(), options, activitySignal);
|
|
1017
953
|
if (options?.signal?.aborted) keepConnection = false;
|
|
1018
954
|
else if (useCachedContext && entry && output.responseId) {
|
|
1019
955
|
const responseItems = convertProviderResponsesMessages(model, { messages: [output] }, CODEX_TOOL_CALL_PROVIDERS, {
|
|
@@ -1023,7 +959,7 @@ async function processWebSocketStream(state, authority, body, output, stream, mo
|
|
|
1023
959
|
authProfileId: options?.authProfileId
|
|
1024
960
|
}).filter((item) => item.type !== "function_call_output");
|
|
1025
961
|
entry.continuation = {
|
|
1026
|
-
lastRequestBody:
|
|
962
|
+
lastRequestBody: body,
|
|
1027
963
|
lastResponseId: output.responseId,
|
|
1028
964
|
lastResponseItems: responseItems
|
|
1029
965
|
};
|
|
@@ -1041,9 +977,7 @@ async function readChatGptResponsesErrorTextLimited(response, signal) {
|
|
|
1041
977
|
const reader = response.body?.getReader();
|
|
1042
978
|
if (!reader) return "";
|
|
1043
979
|
const decoder = new TextDecoder();
|
|
1044
|
-
let total = 0;
|
|
1045
980
|
let text = "";
|
|
1046
|
-
let reachedLimit = false;
|
|
1047
981
|
let completed = false;
|
|
1048
982
|
let cancelPromise;
|
|
1049
983
|
const cancel = () => {
|
|
@@ -1056,27 +990,17 @@ async function readChatGptResponsesErrorTextLimited(response, signal) {
|
|
|
1056
990
|
if (signal?.aborted) onAbort();
|
|
1057
991
|
else signal?.addEventListener("abort", onAbort, { once: true });
|
|
1058
992
|
try {
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
}
|
|
1071
|
-
const chunk = value.byteLength > remaining ? value.subarray(0, remaining) : value;
|
|
1072
|
-
total += chunk.byteLength;
|
|
1073
|
-
text += decoder.decode(chunk, { stream: true });
|
|
1074
|
-
if (total >= OPENAI_CHATGPT_RESPONSES_ERROR_BODY_MAX_BYTES) {
|
|
1075
|
-
reachedLimit = true;
|
|
1076
|
-
break;
|
|
1077
|
-
}
|
|
1078
|
-
}
|
|
1079
|
-
if (!reachedLimit) text += decoder.decode();
|
|
993
|
+
const { truncated } = await consumeResponseBytes({
|
|
994
|
+
maxBytes: OPENAI_CHATGPT_RESPONSES_ERROR_BODY_MAX_BYTES,
|
|
995
|
+
stopAtLimit: true,
|
|
996
|
+
read: () => reader.read(),
|
|
997
|
+
onChunk: (chunk) => {
|
|
998
|
+
text += decoder.decode(chunk, { stream: true });
|
|
999
|
+
},
|
|
1000
|
+
onLimit: () => {}
|
|
1001
|
+
});
|
|
1002
|
+
completed = !truncated;
|
|
1003
|
+
if (completed) text += decoder.decode();
|
|
1080
1004
|
} finally {
|
|
1081
1005
|
signal?.removeEventListener("abort", onAbort);
|
|
1082
1006
|
if (!completed) await cancel();
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { t as __exportAll } from "./rolldown-runtime-BhDjJH2R.mjs";
|
|
2
|
-
import { k as clampThinkingLevel } from "./host-
|
|
3
|
-
import { n as buildBaseOptions } from "./simple-options-
|
|
4
|
-
import {
|
|
5
|
-
import { t as requireApiKey } from "./required-api-key-
|
|
2
|
+
import { k as clampThinkingLevel } from "./host-Bf3NjYNj.mjs";
|
|
3
|
+
import { n as buildBaseOptions } from "./simple-options-BAu4B54D.mjs";
|
|
4
|
+
import { c as convertMessages, n as streamOpenAICompletionsRequest } from "./openai-completions-transport-v38m71Oq.mjs";
|
|
5
|
+
import { t as requireApiKey } from "./required-api-key-CFJvcFy_.mjs";
|
|
6
6
|
//#region packages/ai/src/providers/openai-completions.ts
|
|
7
7
|
var openai_completions_exports = /* @__PURE__ */ __exportAll({
|
|
8
8
|
convertMessages: () => convertMessages,
|
|
@@ -14,11 +14,12 @@ const streamSimpleOpenAICompletions = (model, context, options) => {
|
|
|
14
14
|
const apiKey = requireApiKey(model.provider, options?.apiKey);
|
|
15
15
|
const base = buildBaseOptions(model, options, apiKey);
|
|
16
16
|
const clampedReasoning = options?.reasoning ? clampThinkingLevel(model, options.reasoning) : void 0;
|
|
17
|
-
const
|
|
17
|
+
const completionsOptions = options;
|
|
18
18
|
return streamOpenAICompletions(model, context, {
|
|
19
19
|
...base,
|
|
20
20
|
reasoningEffort: clampedReasoning,
|
|
21
|
-
toolChoice
|
|
21
|
+
toolChoice: completionsOptions?.toolChoice,
|
|
22
|
+
streaming: completionsOptions?.streaming
|
|
22
23
|
});
|
|
23
24
|
};
|
|
24
25
|
//#endregion
|
package/dist/{openai-completions-compat-GMN8A0fm.mjs → openai-completions-compat-CYX18uDk.mjs}
RENAMED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { o as isRecord } from "./record-coerce-CNDovvft.mjs";
|
|
2
|
-
import { a as resolveProviderRequestCapabilities } from "./host-policy-
|
|
2
|
+
import { a as resolveProviderRequestCapabilities } from "./host-policy-BzZluO6_.mjs";
|
|
3
3
|
//#region packages/ai/src/providers/openai-response-format.ts
|
|
4
4
|
const JSON_SCHEMA_RESPONSE_FORMAT_NAME = "openclaw_response";
|
|
5
5
|
const OLLAMA_CLOUD_ORIGIN = "https://ollama.com";
|
|
@@ -101,11 +101,12 @@ function resolveOpenAICompletionsCompatDefaults(input) {
|
|
|
101
101
|
const isNonStandard = endpointClass === "cerebras-native" || endpointClass === "chutes-native" || endpointClass === "deepseek-native" || endpointClass === "mistral-public" || endpointClass === "opencode-native" || endpointClass === "opencode-go-native" || endpointClass === "xai-native" || isXiaomi || isZai || isDefaultRoute && isDefaultRouteProvider(input.provider, "cerebras", "chutes", "deepseek", "opencode", "xai");
|
|
102
102
|
const isOpenRouterLike = input.provider === "openrouter" || endpointClass === "openrouter";
|
|
103
103
|
const isLocalEndpoint = endpointClass === "local";
|
|
104
|
-
const
|
|
104
|
+
const isMistral = knownProviderFamily === "mistral" || endpointClass === "mistral-public";
|
|
105
|
+
const usesMaxTokens = endpointClass === "chutes-native" || isMistral || isMoonshot || isCloudflareAiGateway || isZai || isTogether || isDefaultRoute && isDefaultRouteProvider(provider, "chutes");
|
|
105
106
|
return {
|
|
106
|
-
supportsStore: !isNonStandard &&
|
|
107
|
+
supportsStore: !isNonStandard && !isMistral && !usesExplicitProxyLikeEndpoint,
|
|
107
108
|
supportsDeveloperRole: !isNonStandard && !isMoonshotLike && !usesConfiguredNonOpenAIEndpoint,
|
|
108
|
-
supportsReasoningEffort: !isZai && !isTogether &&
|
|
109
|
+
supportsReasoningEffort: !isZai && !isTogether && !isMistral && endpointClass !== "xai-native" && (!usesExplicitProxyLikeEndpoint || input.reasoning === true),
|
|
109
110
|
supportsUsageInStreaming: supportsOpenAICompletionsStreamingUsageCompat || !isNonStandard && (isLocalEndpoint || !usesConfiguredNonOpenAIEndpoint || supportsNativeStreamingUsageCompat),
|
|
110
111
|
maxTokensField: usesMaxTokens ? "max_tokens" : "max_completion_tokens",
|
|
111
112
|
thinkingFormat: isDeepSeek || isXiaomi ? "deepseek" : isZai ? "zai" : isTogether ? "together" : isOpenRouterLike ? "openrouter" : "openai",
|
|
@@ -135,6 +136,7 @@ function detectOpenAICompletionsCompat(model, resolveCapabilities) {
|
|
|
135
136
|
defaults: resolveOpenAICompletionsCompatDefaults({
|
|
136
137
|
provider: model.provider,
|
|
137
138
|
modelId: model.id,
|
|
139
|
+
reasoning: model.reasoning,
|
|
138
140
|
baseUrl: model.baseUrl,
|
|
139
141
|
...capabilities
|
|
140
142
|
})
|
|
@@ -147,21 +149,23 @@ function resolveSessionAffinity(model, detectedFormat) {
|
|
|
147
149
|
}
|
|
148
150
|
/** Applies explicit model overrides once on top of the canonical transport defaults. */
|
|
149
151
|
function resolveOpenAICompletionsCompat(model, resolveCapabilities) {
|
|
150
|
-
const { defaults } = detectOpenAICompletionsCompat(model, resolveCapabilities);
|
|
152
|
+
const { defaults, capabilities } = detectOpenAICompletionsCompat(model, resolveCapabilities);
|
|
151
153
|
const configured = model.compat;
|
|
154
|
+
const thinkingFormat = configured?.thinkingFormat ?? defaults.thinkingFormat;
|
|
152
155
|
return {
|
|
153
156
|
supportsStore: configured?.supportsStore ?? defaults.supportsStore,
|
|
154
157
|
supportsDeveloperRole: configured?.supportsDeveloperRole ?? defaults.supportsDeveloperRole,
|
|
155
158
|
supportsReasoningEffort: configured?.supportsReasoningEffort ?? defaults.supportsReasoningEffort,
|
|
156
159
|
supportedReasoningEfforts: configured?.supportedReasoningEfforts,
|
|
157
160
|
reasoningEffortMap: configured?.reasoningEffortMap,
|
|
161
|
+
reasoningEffortForOff: capabilities.usesExplicitProxyLikeEndpoint && thinkingFormat === "openai" && !configured?.supportedReasoningEfforts?.includes("none") ? null : "none",
|
|
158
162
|
supportsUsageInStreaming: configured?.supportsUsageInStreaming ?? defaults.supportsUsageInStreaming,
|
|
159
163
|
maxTokensField: configured?.maxTokensField ?? defaults.maxTokensField,
|
|
160
164
|
requiresToolResultName: configured?.requiresToolResultName ?? false,
|
|
161
165
|
requiresAssistantAfterToolResult: configured?.requiresAssistantAfterToolResult ?? false,
|
|
162
166
|
requiresThinkingAsText: configured?.requiresThinkingAsText ?? false,
|
|
163
167
|
requiresReasoningContentOnAssistantMessages: configured?.requiresReasoningContentOnAssistantMessages ?? defaults.requiresReasoningContentOnAssistantMessages,
|
|
164
|
-
thinkingFormat
|
|
168
|
+
thinkingFormat,
|
|
165
169
|
openRouterRouting: configured?.openRouterRouting,
|
|
166
170
|
vercelGatewayRouting: configured?.vercelGatewayRouting ?? {},
|
|
167
171
|
zaiToolStream: configured?.zaiToolStream ?? false,
|
package/dist/{openai-completions-compat-BgPg1BRs.d.mts → openai-completions-compat-i-nLZxFy.d.mts}
RENAMED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import "./index-
|
|
2
|
-
import { N as OpenAICompletionsCompat, k as Model } from "./types-
|
|
3
|
-
import { a as AiProviderRequestPolicyInput, i as AiProviderRequestCapabilities } from "./host-
|
|
1
|
+
import "./index-BYDvopUB.mjs";
|
|
2
|
+
import { N as OpenAICompletionsCompat, k as Model } from "./types-Bd2T86VJ.mjs";
|
|
3
|
+
import { a as AiProviderRequestPolicyInput, i as AiProviderRequestCapabilities } from "./host-CTDz7LXD.mjs";
|
|
4
4
|
//#region packages/ai/src/transports/openai-completions-compat.d.ts
|
|
5
|
-
type ProviderRequestCapabilities = AiProviderRequestCapabilities;
|
|
6
5
|
type OpenAICompletionsSessionAffinity = "none" | "openai" | "openrouter";
|
|
7
6
|
type OpenAICompletionsCompatDefaults = {
|
|
8
7
|
supportsStore: boolean;
|
|
@@ -20,10 +19,6 @@ type OpenAICompletionsCompatDefaults = {
|
|
|
20
19
|
sessionAffinityFormat: Exclude<OpenAICompletionsSessionAffinity, "none">;
|
|
21
20
|
supportsLongCacheRetention: boolean;
|
|
22
21
|
};
|
|
23
|
-
type DetectedOpenAICompletionsCompat = {
|
|
24
|
-
capabilities: ProviderRequestCapabilities;
|
|
25
|
-
defaults: OpenAICompletionsCompatDefaults;
|
|
26
|
-
};
|
|
27
22
|
type ResolvedOpenAICompletionsCompat = Omit<Required<OpenAICompletionsCompat>, "cacheControlFormat" | "openRouterRouting" | "sendSessionAffinityHeaders" | "reasoningEffortMap" | "supportedReasoningEfforts"> & Pick<OpenAICompletionsCompat, "reasoningEffortMap" | "supportedReasoningEfforts"> & {
|
|
28
23
|
cacheControlFormat?: OpenAICompletionsCompat["cacheControlFormat"];
|
|
29
24
|
openRouterRouting?: OpenAICompletionsCompat["openRouterRouting"];
|
|
@@ -31,6 +26,7 @@ type ResolvedOpenAICompletionsCompat = Omit<Required<OpenAICompletionsCompat>, "
|
|
|
31
26
|
visibleReasoningDetailTypes: string[];
|
|
32
27
|
requiresNonEmptyUserOrAssistantMessage: boolean;
|
|
33
28
|
configuredSupportsLongCacheRetention?: boolean;
|
|
29
|
+
reasoningEffortForOff: "none" | null;
|
|
34
30
|
};
|
|
35
31
|
/** Native OpenAI defaults never apply to a configured proxy endpoint. */
|
|
36
32
|
declare function isNativeOpenAIEndpoint(model: {
|
|
@@ -54,12 +50,15 @@ declare function resolveOpenAIPromptCacheKeySupport(model: {
|
|
|
54
50
|
compat?: Pick<OpenAICompletionsCompat, "supportsPromptCacheKey" | "supportsLongCacheRetention"> | null;
|
|
55
51
|
}): boolean;
|
|
56
52
|
/** Detects endpoint capabilities and defaults for an OpenAI-completions model. */
|
|
57
|
-
declare function detectOpenAICompletionsCompat(model: Pick<Model<"openai-completions">, "provider" | "baseUrl" | "id"> & {
|
|
53
|
+
declare function detectOpenAICompletionsCompat(model: Pick<Model<"openai-completions">, "provider" | "baseUrl" | "id" | "reasoning"> & {
|
|
58
54
|
compat?: {
|
|
59
55
|
supportsStore?: boolean;
|
|
60
56
|
} | null;
|
|
61
|
-
}, resolveCapabilities?: (input: AiProviderRequestPolicyInput) =>
|
|
57
|
+
}, resolveCapabilities?: (input: AiProviderRequestPolicyInput) => AiProviderRequestCapabilities): {
|
|
58
|
+
capabilities: AiProviderRequestCapabilities;
|
|
59
|
+
defaults: OpenAICompletionsCompatDefaults;
|
|
60
|
+
};
|
|
62
61
|
/** Applies explicit model overrides once on top of the canonical transport defaults. */
|
|
63
|
-
declare function resolveOpenAICompletionsCompat(model: Pick<Model<"openai-completions">, "id" | "provider" | "baseUrl" | "compat">, resolveCapabilities?: (input: AiProviderRequestPolicyInput) =>
|
|
62
|
+
declare function resolveOpenAICompletionsCompat(model: Pick<Model<"openai-completions">, "id" | "provider" | "baseUrl" | "compat" | "reasoning">, resolveCapabilities?: (input: AiProviderRequestPolicyInput) => AiProviderRequestCapabilities): ResolvedOpenAICompletionsCompat;
|
|
64
63
|
//#endregion
|
|
65
64
|
export { resolveOpenAICompletionsCompat as a, isOpenAICodexResponsesModel as i, detectOpenAICompletionsCompat as n, resolveOpenAIPromptCacheKeySupport as o, isNativeOpenAIEndpoint as r, usesNativeOpenAICodexResponsesBackend as s, ResolvedOpenAICompletionsCompat as t };
|