@openclaw/ai 2026.9.5 → 2026.9.6
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/dist/{anthropic-COtDvgtt.mjs → anthropic-DZQ_7gD1.mjs} +35 -35
- package/dist/{anthropic-payload-policy-5Erq1Nzy.d.mts → anthropic-payload-policy-DyfwikYJ.d.mts} +4 -4
- package/dist/{anthropic-stream-reducer-BvdYYWL8.mjs → anthropic-stream-reducer-D6ZI1wwj.mjs} +32 -16
- package/dist/{api-registry-Ba2Cv-ut.d.mts → api-registry-C2T3lTV7.d.mts} +2 -2
- package/dist/{assistant-output-BsEkB-vU.mjs → assistant-output-DM1JBNs1.mjs} +1 -1
- package/dist/{azure-openai-responses-YrgnD583.mjs → azure-openai-responses-DS86GYzq.mjs} +5 -5
- package/dist/{base64-BQOzsvUH.mjs → base64-CPmadnUf.mjs} +8 -8
- package/dist/{diagnostics-Dm4bisWG.mjs → diagnostics-CH8j2wIG.mjs} +55 -10
- package/dist/{diagnostics-CPeq9F7y.mjs → diagnostics-DzrF1h4J.mjs} +18 -1
- package/dist/diagnostics.d.mts +11 -5
- package/dist/diagnostics.mjs +4 -4
- package/dist/event-stream-C0nsgbj2.d.mts +1 -0
- package/dist/{event-stream-CCoa-qSI.d.mts → event-stream-CjnIZZst.d.mts} +1 -1
- package/dist/event-stream.d.mts +2 -2
- package/dist/{google-BuhpRO9r.mjs → google-BZJFjhuC.mjs} +5 -5
- package/dist/{google-messages-CyWnYlh0.mjs → google-messages-DB7GKkDk.mjs} +3 -3
- package/dist/{google-shared-BT5ZeNer.mjs → google-shared-Bok4I6zB.mjs} +5 -5
- package/dist/{google-vertex-C7EplRvt.mjs → google-vertex-3eVNR2qW.mjs} +4 -4
- package/dist/{host-FZ1RA_qD.d.mts → host-DH-Z-LDb.d.mts} +3 -3
- package/dist/{host-policy-DUnXSx0I.mjs → host-policy-DZO3oPPk.mjs} +1 -1
- package/dist/{host-B4MeUNBc.mjs → host-yTvBrYM2.mjs} +41 -7
- package/dist/{index-DaF2QbwS.d.mts → index-C25RT6bP.d.mts} +36 -8
- package/dist/index.d.mts +7 -7
- package/dist/index.mjs +4 -4
- package/dist/internal/anthropic.d.mts +12 -8
- package/dist/internal/anthropic.mjs +5 -5
- 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 +1 -1
- package/dist/internal/openai.d.mts +22 -8
- package/dist/internal/openai.mjs +11 -10
- package/dist/internal/runtime.d.mts +6 -6
- package/dist/internal/runtime.mjs +5 -5
- package/dist/internal/shared.d.mts +5 -4
- package/dist/internal/shared.mjs +4 -4
- package/dist/internal/tool-schema.d.mts +1 -1
- package/dist/internal/tool-schema.mjs +1 -1
- package/dist/{mistral-moA-mbwl.mjs → mistral-C_13dVBn.mjs} +5 -5
- package/dist/{model-transport-url-DKocrEsb.d.mts → model-transport-url-C5f59L3Y.d.mts} +1 -1
- package/dist/{openai-chatgpt-responses-DWID3EFO.mjs → openai-chatgpt-responses-sTxPl4zM.mjs} +107 -84
- package/dist/{openai-completions-DJ1Vm-CD.mjs → openai-completions-BO6D_hrB.mjs} +10 -10
- package/dist/{openai-completions-compat-CkwdxTZx.mjs → openai-completions-compat-CUollwl6.mjs} +1 -1
- package/dist/{openai-completions-compat-JE7gqxb9.d.mts → openai-completions-compat-DfJG1wSO.d.mts} +3 -3
- package/dist/{openai-completions-stream-Bu98b0Hv.mjs → openai-completions-stream-BpuJ0ZOA.mjs} +38 -25
- package/dist/{openai-prompt-cache-CJ_xEevu.d.mts → openai-prompt-cache-C4RHdN4n.d.mts} +2 -2
- package/dist/{openai-prompt-cache-1wfaIszn.mjs → openai-prompt-cache-CjV_2IRI.mjs} +1 -1
- package/dist/{openai-provider-client-DPo0Hmak.mjs → openai-provider-client-BP8J1aeg.mjs} +2 -2
- package/dist/{openai-reasoning-effort-NlFZmfEu.mjs → openai-reasoning-effort-ash8dPrd.mjs} +12 -4
- package/dist/{openai-responses-BejZzQCP.mjs → openai-responses-BJ_IEoMU.mjs} +7 -7
- package/dist/{openai-responses-compaction-window-D6P5oZP5.mjs → openai-responses-compaction-window-BiNCT0bS.mjs} +3 -3
- package/dist/{openai-responses-contracts-Dflvrfa8.d.mts → openai-responses-contracts-B1ENJFpI.d.mts} +4 -4
- package/dist/{openai-responses-prompt-observer-internal-C15_-OwV.mjs → openai-responses-prompt-observer-internal-DPHWgbBH.mjs} +14 -11
- package/dist/openai-responses-request-lifecycle-DFuyO1pQ.mjs +36 -0
- package/dist/{openai-responses-shared-CwsziD_m.mjs → openai-responses-shared-DvSqtJ6_.mjs} +481 -410
- package/dist/{openai-responses-terminal-usage-Dl3J6zrf.d.mts → openai-responses-terminal-usage-BNFbvY9f.d.mts} +2 -2
- package/dist/{openai-tool-schema-BO8rwyAD.mjs → openai-tool-schema-D4BMcj2D.mjs} +171 -95
- package/dist/{openai-transport-params-DQeuAvBl.mjs → openai-transport-params-DZKOTSfH.mjs} +9 -9
- package/dist/{positive-integer-DtjCkbue.mjs → positive-integer-BiUxrd71.mjs} +1 -1
- package/dist/{provider-error-DDqw9Qda.mjs → provider-error-CRhW7lkJ.mjs} +40 -7
- package/dist/{provider-error-CzNw4BWX.d.mts → provider-error-xumb1V3F.d.mts} +3 -1
- package/dist/{provider-options-DprLsWh9.d.mts → provider-options-DZYq53lj.d.mts} +6 -4
- package/dist/{provider-replay-context-CnUSOwhr.mjs → provider-replay-context-DPr3w20a.mjs} +1 -1
- package/dist/{provider-transcript-transform-BsRAhuWJ.mjs → provider-transcript-transform-BTocjCRs.mjs} +1 -1
- package/dist/{provider-transport-turn-state-CkGToCD2.mjs → provider-transport-turn-state-lrXEFkYr.mjs} +1 -1
- package/dist/{provider-types-CAKRC7N5.d.mts → provider-types-w1rEqrGP.d.mts} +3 -3
- package/dist/provider-types.d.mts +6 -6
- package/dist/providers.d.mts +2 -2
- package/dist/providers.mjs +10 -10
- package/dist/{reasoning-tag-text-partitioner-Dy9IO8Dc.mjs → reasoning-tag-text-partitioner-Di38crhI.mjs} +154 -35
- package/dist/{simple-options-C6cFWj_f.mjs → simple-options-np1XPuhm.mjs} +2 -2
- package/dist/{src-DeKjbE8I.mjs → src-DwGYYyZp.mjs} +15 -6
- package/dist/{stream-first-event-timeout-C9ZadkJW.mjs → stream-first-event-timeout-BeptfRL6.mjs} +1 -1
- package/dist/{transport-stream-shared-D-6FQSHm.mjs → transport-stream-shared-B5RioB_Q.mjs} +5 -13
- package/dist/{transport-stream-shared-BbUkFaHi.d.mts → transport-stream-shared-B7Z9oCYg.d.mts} +5 -5
- package/dist/{transport-utils-1cyq5Y7x.mjs → transport-utils-03Qi0CN2.mjs} +3 -3
- package/dist/transports.d.mts +11 -11
- package/dist/transports.mjs +70 -45
- package/dist/types-DTvddOfm.d.mts +1 -0
- package/dist/{types-4_uVs5WH.d.mts → types-qZFbaDbK.d.mts} +2 -0
- package/dist/types.d.mts +6 -6
- package/dist/types.mjs +3 -3
- package/dist/{validation-Ctzu2DhF.d.mts → validation-DhQhmt6t.d.mts} +1 -1
- package/dist/validation.d.mts +1 -1
- package/package.json +5 -5
- package/dist/event-stream-DmSCpi1T.d.mts +0 -1
- package/dist/types-DkJfb4W3.d.mts +0 -1
package/dist/{openai-chatgpt-responses-DWID3EFO.mjs → openai-chatgpt-responses-sTxPl4zM.mjs}
RENAMED
|
@@ -1,23 +1,86 @@
|
|
|
1
|
-
import { i as formatThrownValue, n as createAssistantMessageDiagnostic, t as appendAssistantMessageDiagnostic } from "./diagnostics-
|
|
1
|
+
import { i as formatThrownValue, n as createAssistantMessageDiagnostic, t as appendAssistantMessageDiagnostic } from "./diagnostics-DzrF1h4J.mjs";
|
|
2
2
|
import { t as AssistantMessageEventStream } from "./event-stream-D8PARQfL.mjs";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { n as
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
3
|
+
import { o as isRecord } from "./record-coerce-DwRYMj3t.mjs";
|
|
4
|
+
import { d as supportsOpenAITemperature } from "./openai-reasoning-effort-ash8dPrd.mjs";
|
|
5
|
+
import { A as headersToRecord, n as getAiTransportHost, r as resolveAiTransportHeaderSentinels } from "./host-yTvBrYM2.mjs";
|
|
6
|
+
import { n as clampOpenAIPromptCacheKey } from "./openai-prompt-cache-CjV_2IRI.mjs";
|
|
7
|
+
import { _ as extractErrorCodeOrErrno, o as WEBSOCKET_NON_RETRYABLE_CLOSE_ERROR_CODE, v as toErrorObject } from "./diagnostics-CH8j2wIG.mjs";
|
|
8
|
+
import { s as resolveTimerTimeoutMs } from "./base64-CPmadnUf.mjs";
|
|
9
|
+
import { t as MALFORMED_STREAMING_FRAGMENT_ERROR_MESSAGE } from "./transport-utils-03Qi0CN2.mjs";
|
|
9
10
|
import { parseRetryAfterHeadersSeconds } from "./internal/retry-after.mjs";
|
|
10
|
-
import { m as stripSystemPromptCacheBoundary, n as buildBaseOptions } from "./simple-options-
|
|
11
|
-
import { S as createResponseModelTracker, b as createOpenAIProviderAcceptanceHook, g as resolveOpenAISimpleReasoningEffort, h as resolveOpenAIRequestReasoning, x as createOpenAIResponseHook } from "./openai-transport-params-
|
|
11
|
+
import { m as stripSystemPromptCacheBoundary, n as buildBaseOptions } from "./simple-options-np1XPuhm.mjs";
|
|
12
|
+
import { S as createResponseModelTracker, b as createOpenAIProviderAcceptanceHook, g as resolveOpenAISimpleReasoningEffort, h as resolveOpenAIRequestReasoning, x as createOpenAIResponseHook } from "./openai-transport-params-DZKOTSfH.mjs";
|
|
12
13
|
import { n as getEnvApiKey } from "./env-api-keys-bktO00EJ.mjs";
|
|
13
|
-
import {
|
|
14
|
-
import { a as withFirstStreamEventTimeout, i as getFirstStreamEventTimeoutMs, r as getFirstStreamEventTimeoutHandler, t as createFirstStreamEventAbortController } from "./stream-first-event-timeout-
|
|
14
|
+
import { b as withProviderResponseHook, m as notifyProviderStreamOpened, n as assignTransportErrorDetails, v as transportAbortError } from "./transport-stream-shared-B5RioB_Q.mjs";
|
|
15
|
+
import { a as withFirstStreamEventTimeout, i as getFirstStreamEventTimeoutMs, r as getFirstStreamEventTimeoutHandler, t as createFirstStreamEventAbortController } from "./stream-first-event-timeout-BeptfRL6.mjs";
|
|
15
16
|
import { h as responsesPromptObserver } from "./openai-responses-contracts-DWrfMODE.mjs";
|
|
16
|
-
import {
|
|
17
|
+
import { D as ResponsesStreamFailure, E as resolveNextResponsesEncryptedContentAttempt, M as recordResponsesContextUsage, S as commitResponsesEncryptedContentAttempt, Z as suppressOpenAIResponsesCompaction, c as readOpenAIMisalignmentReview, i as createResponsesAssistantOutput, l as processResponsesStream, n as applyResponsesServiceTierPricing, o as convertResponsesToolPayload, q as buildOpenAIResponsesReasoningReplayMetadata, r as convertResponsesMessages, w as isInvalidEncryptedContentError } from "./openai-responses-shared-DvSqtJ6_.mjs";
|
|
17
18
|
import { t as createSseByteGuard } from "./streaming-byte-guard-CC-HMn_u.mjs";
|
|
18
19
|
import { n as registerSessionResourceCleanup } from "./session-resources-CkR4WWy1.mjs";
|
|
19
|
-
import { i as resolveOpenAIResponsesTextFormat, t as createResponsesPromptEgressObserver } from "./openai-responses-prompt-observer-internal-
|
|
20
|
+
import { i as resolveOpenAIResponsesTextFormat, t as createResponsesPromptEgressObserver } from "./openai-responses-prompt-observer-internal-DPHWgbBH.mjs";
|
|
21
|
+
import { n as withResponsesRequestAcceptance, t as responsesRequestLifecycle } from "./openai-responses-request-lifecycle-DFuyO1pQ.mjs";
|
|
20
22
|
import { n as resolveOpenAICodexAccountId } from "./openai-chatgpt-jwt-KWcgd0d_.mjs";
|
|
23
|
+
//#region packages/ai/src/providers/openai-chatgpt-responses-events.ts
|
|
24
|
+
var CodexApiError = class extends Error {
|
|
25
|
+
constructor(message, options) {
|
|
26
|
+
super(message);
|
|
27
|
+
this.name = "CodexApiError";
|
|
28
|
+
this.code = options?.code;
|
|
29
|
+
this.status = options?.status;
|
|
30
|
+
this.payload = options?.payload;
|
|
31
|
+
this.cause = options?.cause;
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
function extractCodexEventError(event) {
|
|
35
|
+
const nested = isRecord(event.error) ? event.error : void 0;
|
|
36
|
+
return {
|
|
37
|
+
code: typeof event.code === "string" ? event.code : typeof nested?.code === "string" ? nested.code : void 0,
|
|
38
|
+
message: typeof event.message === "string" ? event.message : typeof nested?.message === "string" ? nested.message : void 0
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
async function* mapCodexEvents(events, initialResponseHeaders, options) {
|
|
42
|
+
const responseModelTracker = createResponseModelTracker();
|
|
43
|
+
responseModelTracker.begin(initialResponseHeaders);
|
|
44
|
+
for await (const event of withResponsesRequestAcceptance(events, responsesRequestLifecycle.get(options), options?.signal)) {
|
|
45
|
+
responseModelTracker.observeEvent(event);
|
|
46
|
+
const type = typeof event.type === "string" ? event.type : void 0;
|
|
47
|
+
if (!type) continue;
|
|
48
|
+
if (type === "error") {
|
|
49
|
+
const { code, message } = extractCodexEventError(event);
|
|
50
|
+
throw new CodexApiError(`Codex error: ${message || code || JSON.stringify(event)}`, {
|
|
51
|
+
code,
|
|
52
|
+
payload: event
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
if (type === "response.done" || type === "response.completed" || type === "response.incomplete") {
|
|
56
|
+
const response = isRecord(event.response) ? event.response : void 0;
|
|
57
|
+
const normalizedResponse = response ? {
|
|
58
|
+
...response,
|
|
59
|
+
status: normalizeCodexStatus(response.status),
|
|
60
|
+
model: responseModelTracker.resolve()
|
|
61
|
+
} : response;
|
|
62
|
+
yield {
|
|
63
|
+
...event,
|
|
64
|
+
type: type === "response.done" ? "response.completed" : type,
|
|
65
|
+
response: normalizedResponse
|
|
66
|
+
};
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
yield event;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
function normalizeCodexStatus(status) {
|
|
73
|
+
switch (status) {
|
|
74
|
+
case "completed":
|
|
75
|
+
case "incomplete":
|
|
76
|
+
case "failed":
|
|
77
|
+
case "cancelled":
|
|
78
|
+
case "queued":
|
|
79
|
+
case "in_progress": return status;
|
|
80
|
+
default: return;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
//#endregion
|
|
21
84
|
//#region packages/ai/src/providers/openai-chatgpt-responses-protocol.ts
|
|
22
85
|
const OPENAI_CHATGPT_RESPONSES_SUCCESS_BODY_MAX_BYTES = 16777216;
|
|
23
86
|
var CodexProtocolError = class extends Error {
|
|
@@ -99,14 +162,6 @@ const RETRYABLE_WEBSOCKET_CLOSE_CODES = /* @__PURE__ */ new Set([
|
|
|
99
162
|
const WEBSOCKET_MESSAGE_TOO_BIG_CLOSE_CODE = 1009;
|
|
100
163
|
const WEBSOCKET_CONNECTION_LIMIT_REACHED_CODE = "websocket_connection_limit_reached";
|
|
101
164
|
const OPENAI_CHATGPT_RESPONSES_ERROR_BODY_MAX_BYTES = 16384;
|
|
102
|
-
const CODEX_RESPONSE_STATUSES = /* @__PURE__ */ new Set([
|
|
103
|
-
"completed",
|
|
104
|
-
"incomplete",
|
|
105
|
-
"failed",
|
|
106
|
-
"cancelled",
|
|
107
|
-
"queued",
|
|
108
|
-
"in_progress"
|
|
109
|
-
]);
|
|
110
165
|
function resolveRequestTimeoutMs(options) {
|
|
111
166
|
const timeoutMs = options?.timeoutMs;
|
|
112
167
|
return typeof timeoutMs === "number" && Number.isFinite(timeoutMs) && timeoutMs > 0 ? resolveTimerTimeoutMs(timeoutMs, 1) : void 0;
|
|
@@ -251,6 +306,12 @@ const streamOpenAICodexResponses = (model, context, options) => {
|
|
|
251
306
|
});
|
|
252
307
|
let attemptResponse;
|
|
253
308
|
try {
|
|
309
|
+
const lifecycle = responsesRequestLifecycle.get(options);
|
|
310
|
+
if (lifecycle) {
|
|
311
|
+
await lifecycle.beforeDispatch(activeSignal);
|
|
312
|
+
activeSignal?.throwIfAborted();
|
|
313
|
+
lifecycle.assertCurrent();
|
|
314
|
+
}
|
|
254
315
|
attemptResponse = await fetch(resolveCodexUrl(model.baseUrl), {
|
|
255
316
|
method: "POST",
|
|
256
317
|
headers: sseHeaders,
|
|
@@ -293,7 +354,7 @@ const streamOpenAICodexResponses = (model, context, options) => {
|
|
|
293
354
|
semanticAttempt = nextSemanticAttempt;
|
|
294
355
|
}
|
|
295
356
|
const hookedResponseStream = withProviderResponseHook({
|
|
296
|
-
stream: mapCodexEvents(parseOpenAIChatGptResponsesSse(response), response.headers),
|
|
357
|
+
stream: mapCodexEvents(parseOpenAIChatGptResponsesSse(response), response.headers, requestOptions),
|
|
297
358
|
signal: firstEventAbort.signal,
|
|
298
359
|
abort: firstEventAbort.abort,
|
|
299
360
|
hook: createOpenAIProviderAcceptanceHook(options, response, model),
|
|
@@ -325,6 +386,7 @@ const streamOpenAICodexResponses = (model, context, options) => {
|
|
|
325
386
|
});
|
|
326
387
|
stream.end();
|
|
327
388
|
} catch (error) {
|
|
389
|
+
await responsesRequestLifecycle.get(options)?.settle().catch(() => void 0);
|
|
328
390
|
const requestTimedOut = isRequestTimeoutError(error, options?.signal, requestTimeoutSignal, requestTimeoutMs) && requestTimeoutMs !== void 0;
|
|
329
391
|
const normalizedError = requestTimedOut && requestTimeoutMs !== void 0 ? formatRequestTimeoutError(requestTimeoutMs, error) : error;
|
|
330
392
|
for (const block of output.content) delete block.partialJson;
|
|
@@ -334,7 +396,8 @@ const streamOpenAICodexResponses = (model, context, options) => {
|
|
|
334
396
|
timestamp: Date.now(),
|
|
335
397
|
details: {
|
|
336
398
|
provider: "openai",
|
|
337
|
-
category: providerRefusal.category
|
|
399
|
+
category: providerRefusal.category,
|
|
400
|
+
...providerRefusal.review ? { review: providerRefusal.review } : {}
|
|
338
401
|
}
|
|
339
402
|
});
|
|
340
403
|
const terminal = assignTransportErrorDetails(output, normalizedError, options?.signal);
|
|
@@ -368,6 +431,8 @@ const streamSimpleOpenAICodexResponses = (model, context, options) => {
|
|
|
368
431
|
reasoningEffort: resolveOpenAISimpleReasoningEffort(model, options?.reasoning)
|
|
369
432
|
};
|
|
370
433
|
responsesPromptObserver.copy(options, resolvedOptions);
|
|
434
|
+
const lifecycle = responsesRequestLifecycle.get(options);
|
|
435
|
+
if (lifecycle) responsesRequestLifecycle.set(resolvedOptions, lifecycle);
|
|
371
436
|
return streamOpenAICodexResponses(model, context, resolvedOptions);
|
|
372
437
|
};
|
|
373
438
|
function buildRequestBody(model, context, options, replayMode = "checkpoint") {
|
|
@@ -432,80 +497,32 @@ function isJsonRecord(value) {
|
|
|
432
497
|
* Structured refusal code carried by the OpenAI Responses transport. Every
|
|
433
498
|
* terminal Responses path preserves it: a non-OK HTTP body parsed by
|
|
434
499
|
* {@link parseErrorResponse}, an SSE/WebSocket `error` event mapped by
|
|
435
|
-
* {@link
|
|
500
|
+
* {@link mapCodexEvents}, and a `response.failed` event normalized into
|
|
436
501
|
* {@link ResponsesStreamFailure}. Only the app-server surface carries the
|
|
437
502
|
* `codexErrorInfo` discriminator, so both shapes must be read here.
|
|
438
503
|
*/
|
|
439
|
-
const RESPONSES_CYBER_POLICY_ERROR_CODE = "cyber_policy";
|
|
440
504
|
function readCodexProviderRefusal(error) {
|
|
441
|
-
if (error instanceof ResponsesStreamFailure
|
|
442
|
-
|
|
443
|
-
if (error.code === RESPONSES_CYBER_POLICY_ERROR_CODE) return { category: "cyber" };
|
|
444
|
-
const payload = error.payload;
|
|
505
|
+
if (!(error instanceof ResponsesStreamFailure || error instanceof CodexApiError)) return;
|
|
506
|
+
const payload = error instanceof CodexApiError ? error.payload : isJsonRecord(error.response) ? error.response : void 0;
|
|
445
507
|
const nested = isJsonRecord(payload?.error) ? payload.error : void 0;
|
|
446
508
|
const codexErrorInfo = payload?.codexErrorInfo ?? nested?.codexErrorInfo;
|
|
447
|
-
if (codexErrorInfo === "cyberPolicy") return { category: "cyber" };
|
|
448
|
-
if (
|
|
509
|
+
if (error.code === "cyber_policy" || codexErrorInfo === "cyberPolicy") return { category: "cyber" };
|
|
510
|
+
if (error.code === "misalignment_policy_violation" || codexErrorInfo === "misalignmentPolicyViolation") {
|
|
511
|
+
const details = nested?.misalignment ?? payload?.misalignment;
|
|
512
|
+
const review = readOpenAIMisalignmentReview(details, true);
|
|
513
|
+
return {
|
|
514
|
+
category: "misalignment",
|
|
515
|
+
...review ? { review } : {}
|
|
516
|
+
};
|
|
517
|
+
}
|
|
449
518
|
return (typeof payload?.message === "string" ? payload.message : typeof nested?.message === "string" ? nested.message : "").startsWith("This content was flagged for possible biological risk.") ? { category: "bio" } : void 0;
|
|
450
519
|
}
|
|
451
|
-
var CodexApiError = class extends Error {
|
|
452
|
-
constructor(message, options) {
|
|
453
|
-
super(message);
|
|
454
|
-
this.name = "CodexApiError";
|
|
455
|
-
this.code = options?.code;
|
|
456
|
-
this.status = options?.status;
|
|
457
|
-
this.payload = options?.payload;
|
|
458
|
-
this.cause = options?.cause;
|
|
459
|
-
}
|
|
460
|
-
};
|
|
461
520
|
function isCodexNonTransportError(error) {
|
|
462
521
|
return error instanceof CodexApiError || error instanceof CodexProtocolError || error instanceof ResponsesStreamFailure;
|
|
463
522
|
}
|
|
464
523
|
function isWebSocketConnectionLimitReachedError(error) {
|
|
465
524
|
return error instanceof CodexApiError && error.code === WEBSOCKET_CONNECTION_LIMIT_REACHED_CODE;
|
|
466
525
|
}
|
|
467
|
-
function extractCodexEventError(event) {
|
|
468
|
-
const nested = event.error && typeof event.error === "object" ? event.error : void 0;
|
|
469
|
-
return {
|
|
470
|
-
code: typeof event.code === "string" ? event.code : typeof nested?.code === "string" ? nested.code : void 0,
|
|
471
|
-
message: typeof event.message === "string" ? event.message : typeof nested?.message === "string" ? nested.message : void 0
|
|
472
|
-
};
|
|
473
|
-
}
|
|
474
|
-
async function* mapCodexEvents(events, initialResponseHeaders) {
|
|
475
|
-
const responseModelTracker = createResponseModelTracker();
|
|
476
|
-
responseModelTracker.begin(initialResponseHeaders);
|
|
477
|
-
for await (const event of events) {
|
|
478
|
-
responseModelTracker.observeEvent(event);
|
|
479
|
-
const type = typeof event.type === "string" ? event.type : void 0;
|
|
480
|
-
if (!type) continue;
|
|
481
|
-
if (type === "error") {
|
|
482
|
-
const { code, message } = extractCodexEventError(event);
|
|
483
|
-
throw new CodexApiError(`Codex error: ${message || code || JSON.stringify(event)}`, {
|
|
484
|
-
code,
|
|
485
|
-
payload: event
|
|
486
|
-
});
|
|
487
|
-
}
|
|
488
|
-
if (type === "response.done" || type === "response.completed" || type === "response.incomplete") {
|
|
489
|
-
const response = event.response;
|
|
490
|
-
const normalizedResponse = response ? {
|
|
491
|
-
...response,
|
|
492
|
-
status: normalizeCodexStatus(response.status),
|
|
493
|
-
model: responseModelTracker.resolve()
|
|
494
|
-
} : response;
|
|
495
|
-
yield {
|
|
496
|
-
...event,
|
|
497
|
-
type: type === "response.done" ? "response.completed" : type,
|
|
498
|
-
response: normalizedResponse
|
|
499
|
-
};
|
|
500
|
-
return;
|
|
501
|
-
}
|
|
502
|
-
yield event;
|
|
503
|
-
}
|
|
504
|
-
}
|
|
505
|
-
function normalizeCodexStatus(status) {
|
|
506
|
-
if (typeof status !== "string") return;
|
|
507
|
-
return CODEX_RESPONSE_STATUSES.has(status) ? status : void 0;
|
|
508
|
-
}
|
|
509
526
|
const OPENAI_BETA_RESPONSES_WEBSOCKETS = "responses_websockets=2026-02-06";
|
|
510
527
|
const SESSION_WEBSOCKET_CACHE_TTL_MS = 3e5;
|
|
511
528
|
const SESSION_WEBSOCKET_MAX_AGE_MS = 33e5;
|
|
@@ -902,12 +919,18 @@ async function processWebSocketStream(url, body, headers, output, stream, model,
|
|
|
902
919
|
egress: "native-codex-websocket",
|
|
903
920
|
payloadVariant
|
|
904
921
|
});
|
|
922
|
+
const lifecycle = responsesRequestLifecycle.get(options);
|
|
923
|
+
if (lifecycle) {
|
|
924
|
+
await lifecycle.beforeDispatch(options?.signal);
|
|
925
|
+
options?.signal?.throwIfAborted();
|
|
926
|
+
lifecycle.assertCurrent();
|
|
927
|
+
}
|
|
905
928
|
socket.send(JSON.stringify({
|
|
906
929
|
type: "response.create",
|
|
907
930
|
...requestBody
|
|
908
931
|
}));
|
|
909
932
|
onRequestSent?.();
|
|
910
|
-
const terminal = await processResponsesStream(startWebSocketOutputOnFirstEvent(mapCodexEvents(parseWebSocket(socket, options?.signal)), output, stream, onFirstProviderEvent, () => notifyProviderStreamOpened({
|
|
933
|
+
const terminal = await processResponsesStream(startWebSocketOutputOnFirstEvent(mapCodexEvents(parseWebSocket(socket, options?.signal), void 0, options), output, stream, onFirstProviderEvent, () => notifyProviderStreamOpened({
|
|
911
934
|
options,
|
|
912
935
|
cancelStream: () => {
|
|
913
936
|
keepConnection = false;
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import { t as __exportAll } from "./rolldown-runtime-BhDjJH2R.mjs";
|
|
2
2
|
import { t as AssistantMessageEventStream } from "./event-stream-D8PARQfL.mjs";
|
|
3
|
-
import {
|
|
4
|
-
import { i as resolveOpenAICompletionsCompat } from "./openai-completions-compat-
|
|
3
|
+
import { N as clampThinkingLevel } from "./host-yTvBrYM2.mjs";
|
|
4
|
+
import { i as resolveOpenAICompletionsCompat } from "./openai-completions-compat-CUollwl6.mjs";
|
|
5
5
|
import { t as resolveCacheRetention } from "./cache-retention-0x979a5V.mjs";
|
|
6
|
-
import { n as buildBaseOptions, o as reasoningTagTextPolicy } from "./simple-options-
|
|
7
|
-
import { C as isOpenAICompletionsThinkingEnabled, b as createOpenAIProviderAcceptanceHook } from "./openai-transport-params-
|
|
6
|
+
import { n as buildBaseOptions, o as reasoningTagTextPolicy } from "./simple-options-np1XPuhm.mjs";
|
|
7
|
+
import { C as isOpenAICompletionsThinkingEnabled, b as createOpenAIProviderAcceptanceHook } from "./openai-transport-params-DZKOTSfH.mjs";
|
|
8
8
|
import { n as getEnvApiKey } from "./env-api-keys-bktO00EJ.mjs";
|
|
9
|
-
import { b as withProviderResponseHook, n as assignTransportErrorDetails, v as transportAbortError } from "./transport-stream-shared-
|
|
9
|
+
import { b as withProviderResponseHook, n as assignTransportErrorDetails, v as transportAbortError } from "./transport-stream-shared-B5RioB_Q.mjs";
|
|
10
10
|
import { a as tagUnresolvedTextAsCommentary, t as clearPendingCommentaryText } from "./assistant-text-phase-C20rxWwP.mjs";
|
|
11
|
-
import { t as createAssistantOutput } from "./assistant-output-
|
|
12
|
-
import { a as convertMessages, i as buildOpenAICompletionsRequest, s as finalizeOpenAICompletionsToolCalls, t as processCompletionsStream } from "./openai-completions-stream-
|
|
13
|
-
import { i as getFirstStreamEventTimeoutMs, r as getFirstStreamEventTimeoutHandler, t as createFirstStreamEventAbortController } from "./stream-first-event-timeout-
|
|
14
|
-
import { n as resolveProviderSimpleCompletionHeaders } from "./provider-transport-turn-state-
|
|
11
|
+
import { t as createAssistantOutput } from "./assistant-output-DM1JBNs1.mjs";
|
|
12
|
+
import { a as convertMessages, i as buildOpenAICompletionsRequest, s as finalizeOpenAICompletionsToolCalls, t as processCompletionsStream } from "./openai-completions-stream-BpuJ0ZOA.mjs";
|
|
13
|
+
import { i as getFirstStreamEventTimeoutMs, r as getFirstStreamEventTimeoutHandler, t as createFirstStreamEventAbortController } from "./stream-first-event-timeout-BeptfRL6.mjs";
|
|
14
|
+
import { n as resolveProviderSimpleCompletionHeaders } from "./provider-transport-turn-state-lrXEFkYr.mjs";
|
|
15
15
|
import { n as hasCopilotVisionInput, t as buildCopilotDynamicHeaders } from "./github-copilot-headers-B37TB3rB.mjs";
|
|
16
|
-
import { t as createOpenAIProviderClient } from "./openai-provider-client-
|
|
16
|
+
import { t as createOpenAIProviderClient } from "./openai-provider-client-BP8J1aeg.mjs";
|
|
17
17
|
//#region packages/ai/src/providers/openai-completions.ts
|
|
18
18
|
var openai_completions_exports = /* @__PURE__ */ __exportAll({
|
|
19
19
|
convertMessages: () => convertMessages,
|
package/dist/{openai-completions-compat-CkwdxTZx.mjs → openai-completions-compat-CUollwl6.mjs}
RENAMED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { o as isRecord } from "./record-coerce-DwRYMj3t.mjs";
|
|
2
|
-
import { a as resolveProviderRequestCapabilities } from "./host-policy-
|
|
2
|
+
import { a as resolveProviderRequestCapabilities } from "./host-policy-DZO3oPPk.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";
|
package/dist/{openai-completions-compat-JE7gqxb9.d.mts → openai-completions-compat-DfJG1wSO.d.mts}
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import "./index-
|
|
2
|
-
import { M as OpenAICompletionsCompat, O as Model } from "./types-
|
|
3
|
-
import { a as AiProviderRequestPolicyInput, i as AiProviderRequestCapabilities } from "./host-
|
|
1
|
+
import "./index-C25RT6bP.mjs";
|
|
2
|
+
import { M as OpenAICompletionsCompat, O as Model } from "./types-qZFbaDbK.mjs";
|
|
3
|
+
import { a as AiProviderRequestPolicyInput, i as AiProviderRequestCapabilities } from "./host-DH-Z-LDb.mjs";
|
|
4
4
|
//#region packages/ai/src/transports/openai-completions-compat.d.ts
|
|
5
5
|
type ProviderRequestCapabilities = AiProviderRequestCapabilities;
|
|
6
6
|
type OpenAICompletionsSessionAffinity = "none" | "openai" | "openrouter";
|
package/dist/{openai-completions-stream-Bu98b0Hv.mjs → openai-completions-stream-BpuJ0ZOA.mjs}
RENAMED
|
@@ -1,27 +1,27 @@
|
|
|
1
1
|
import { r as appendAssistantThinking } from "./event-stream-D8PARQfL.mjs";
|
|
2
2
|
import { o as isRecord } from "./record-coerce-DwRYMj3t.mjs";
|
|
3
|
-
import { n as isOpenAIGpt55Model, r as isOpenAIGpt56Model, t as isOpenAIGpt54MiniModel } from "./openai-reasoning-effort-
|
|
3
|
+
import { n as isOpenAIGpt55Model, r as isOpenAIGpt56Model, t as isOpenAIGpt54MiniModel } from "./openai-reasoning-effort-ash8dPrd.mjs";
|
|
4
4
|
import { r as uniqueStrings } from "./string-normalization-J9ZiLfGO.mjs";
|
|
5
|
-
import { _ as isImageWithMediaPayload, d as describeToolResultMediaPlaceholder, m as extractToolResultText, v as sanitizeSurrogates } from "./host-
|
|
5
|
+
import { _ as isImageWithMediaPayload, d as describeToolResultMediaPlaceholder, m as extractToolResultText, v as sanitizeSurrogates } from "./host-yTvBrYM2.mjs";
|
|
6
6
|
import { t as truncateUtf16Safe } from "./utf16-slice-CvGodqok.mjs";
|
|
7
|
-
import { r as resolveOpenAIPromptCacheParams } from "./openai-prompt-cache-
|
|
8
|
-
import { r as emitModelTransportDebug } from "./diagnostics-
|
|
9
|
-
import { i as asNonNegativeFiniteNumber } from "./base64-
|
|
10
|
-
import { c as supportsModelTools, r as estimateStringChars } from "./transport-utils-
|
|
11
|
-
import { c as shouldOmitOllamaCompatResponseFormat, n as isNativeOpenAIEndpoint, s as resolveOpenAICompletionsResponseFormat, t as detectOpenAICompletionsCompat } from "./openai-completions-compat-
|
|
12
|
-
import { i as resolveProviderEndpoint, r as resolveOpenAIStrictToolSetting } from "./host-policy-
|
|
7
|
+
import { r as resolveOpenAIPromptCacheParams } from "./openai-prompt-cache-CjV_2IRI.mjs";
|
|
8
|
+
import { r as emitModelTransportDebug } from "./diagnostics-CH8j2wIG.mjs";
|
|
9
|
+
import { i as asNonNegativeFiniteNumber } from "./base64-CPmadnUf.mjs";
|
|
10
|
+
import { c as supportsModelTools, r as estimateStringChars } from "./transport-utils-03Qi0CN2.mjs";
|
|
11
|
+
import { c as shouldOmitOllamaCompatResponseFormat, n as isNativeOpenAIEndpoint, s as resolveOpenAICompletionsResponseFormat, t as detectOpenAICompletionsCompat } from "./openai-completions-compat-CUollwl6.mjs";
|
|
12
|
+
import { i as resolveProviderEndpoint, r as resolveOpenAIStrictToolSetting } from "./host-policy-DZO3oPPk.mjs";
|
|
13
13
|
import { t as resolveCacheRetention } from "./cache-retention-0x979a5V.mjs";
|
|
14
|
-
import { f as splitSystemPromptCacheBoundary, h as stripSystemPromptRelocatableBoundary, m as stripSystemPromptCacheBoundary, p as splitSystemPromptRelocatableBoundary, v as sortPromptCacheToolsByName } from "./simple-options-
|
|
15
|
-
import { A as resolvePromptCacheKey, C as isOpenAICompletionsThinkingEnabled, D as readOpenAICompletionsContentDeltas, E as parseOpenAICompletionsUsage, O as readOpenAICompletionsReasoningBatch, T as measureUtf8AppendBytes, d as prepareOpenAITools, f as projectOpenAITools, g as resolveOpenAISimpleReasoningEffort, h as resolveOpenAIRequestReasoning, j as throwIfModelStreamAborted, p as reconcileOpenAICompletionsToolChoice, s as getCompat, u as resolveOpenAIStrictToolFlagWithDiagnostics, v as GEMINI_THOUGHT_SIGNATURE_VALIDATOR_SKIP, w as log, y as createModelStreamCooperativeScheduler } from "./openai-transport-params-
|
|
16
|
-
import { E as parseStreamingJson, c as finalizeTerminalToolCallArguments, w as createToolArgumentPreviewSchedule } from "./transport-stream-shared-
|
|
14
|
+
import { f as splitSystemPromptCacheBoundary, h as stripSystemPromptRelocatableBoundary, m as stripSystemPromptCacheBoundary, p as splitSystemPromptRelocatableBoundary, v as sortPromptCacheToolsByName } from "./simple-options-np1XPuhm.mjs";
|
|
15
|
+
import { A as resolvePromptCacheKey, C as isOpenAICompletionsThinkingEnabled, D as readOpenAICompletionsContentDeltas, E as parseOpenAICompletionsUsage, O as readOpenAICompletionsReasoningBatch, T as measureUtf8AppendBytes, d as prepareOpenAITools, f as projectOpenAITools, g as resolveOpenAISimpleReasoningEffort, h as resolveOpenAIRequestReasoning, j as throwIfModelStreamAborted, p as reconcileOpenAICompletionsToolChoice, s as getCompat, u as resolveOpenAIStrictToolFlagWithDiagnostics, v as GEMINI_THOUGHT_SIGNATURE_VALIDATOR_SKIP, w as log, y as createModelStreamCooperativeScheduler } from "./openai-transport-params-DZKOTSfH.mjs";
|
|
16
|
+
import { E as parseStreamingJson, c as finalizeTerminalToolCallArguments, w as createToolArgumentPreviewSchedule } from "./transport-stream-shared-B5RioB_Q.mjs";
|
|
17
17
|
import { a as tagUnresolvedTextAsCommentary, i as tagPendingCommentaryText, n as rememberPendingCommentaryTags, r as tagInterruptedTextPhases, t as clearPendingCommentaryText } from "./assistant-text-phase-C20rxWwP.mjs";
|
|
18
18
|
import { t as notifyLlmRequestActivity } from "./llm-request-activity-BjtkplhG.mjs";
|
|
19
|
-
import { a as withFirstStreamEventTimeout } from "./stream-first-event-timeout-
|
|
20
|
-
import { t as transformProviderMessages } from "./provider-transcript-transform-
|
|
21
|
-
import { f as withPreparedToolSchemaNormalization, r as normalizeOpenAIStrictToolParameters } from "./openai-tool-schema-
|
|
19
|
+
import { a as withFirstStreamEventTimeout } from "./stream-first-event-timeout-BeptfRL6.mjs";
|
|
20
|
+
import { t as transformProviderMessages } from "./provider-transcript-transform-BTocjCRs.mjs";
|
|
21
|
+
import { f as withPreparedToolSchemaNormalization, r as normalizeOpenAIStrictToolParameters } from "./openai-tool-schema-D4BMcj2D.mjs";
|
|
22
22
|
import { isGoogleGemini3FlashModel, isGoogleGemini3ProModel } from "./internal/google-model-family.mjs";
|
|
23
23
|
import { t as mapOpenAIStopReason } from "./openai-stop-reason-Drnn_6Qj.mjs";
|
|
24
|
-
import { t as createReasoningTagTextPartitioner } from "./reasoning-tag-text-partitioner-
|
|
24
|
+
import { t as createReasoningTagTextPartitioner } from "./reasoning-tag-text-partitioner-Di38crhI.mjs";
|
|
25
25
|
import { randomUUID } from "node:crypto";
|
|
26
26
|
//#region packages/ai/src/transports/deepseek-dsml-grammar.ts
|
|
27
27
|
const DEEPSEEK_DSML_MARKERS = [
|
|
@@ -255,10 +255,18 @@ function createOpenAIEncryptedToolCallReasoningTracker() {
|
|
|
255
255
|
const firstBlocks = /* @__PURE__ */ new Map();
|
|
256
256
|
const pendingDetails = /* @__PURE__ */ new Map();
|
|
257
257
|
return {
|
|
258
|
-
rememberToolCall(id, block) {
|
|
258
|
+
rememberToolCall(id, block, previousId = id) {
|
|
259
|
+
const previous = firstBlocks.get(previousId);
|
|
260
|
+
if (previousId !== id && previous?.block === block) {
|
|
261
|
+
firstBlocks.delete(previousId);
|
|
262
|
+
if (previous.signature && block.thoughtSignature === previous.signature) delete block.thoughtSignature;
|
|
263
|
+
}
|
|
259
264
|
if (!id || firstBlocks.has(id)) return;
|
|
260
|
-
firstBlocks.set(id, block);
|
|
261
265
|
const pendingDetail = pendingDetails.get(id);
|
|
266
|
+
firstBlocks.set(id, {
|
|
267
|
+
block,
|
|
268
|
+
signature: pendingDetail
|
|
269
|
+
});
|
|
262
270
|
if (pendingDetail) {
|
|
263
271
|
block.thoughtSignature = pendingDetail;
|
|
264
272
|
pendingDetails.delete(id);
|
|
@@ -270,8 +278,10 @@ function createOpenAIEncryptedToolCallReasoningTracker() {
|
|
|
270
278
|
if (!isRecord(detail) || detail.type !== "reasoning.encrypted" || typeof detail.id !== "string" || detail.id.length === 0 || typeof detail.data !== "string" || detail.data.length === 0) continue;
|
|
271
279
|
const serializedDetail = JSON.stringify(detail);
|
|
272
280
|
const matchingBlock = firstBlocks.get(detail.id);
|
|
273
|
-
if (matchingBlock)
|
|
274
|
-
|
|
281
|
+
if (matchingBlock) {
|
|
282
|
+
matchingBlock.signature = serializedDetail;
|
|
283
|
+
matchingBlock.block.thoughtSignature = serializedDetail;
|
|
284
|
+
} else pendingDetails.set(detail.id, serializedDetail);
|
|
275
285
|
}
|
|
276
286
|
}
|
|
277
287
|
};
|
|
@@ -337,7 +347,7 @@ function createOpenAICompletionsToolCallDeltaNormalizer() {
|
|
|
337
347
|
}];
|
|
338
348
|
}
|
|
339
349
|
const functionCall = delta.function_call;
|
|
340
|
-
if (sawModernToolCall) return [{
|
|
350
|
+
if (sawModernToolCall || !functionCall && !pendingLegacyToolCall) return [{
|
|
341
351
|
delta: ordinaryDelta,
|
|
342
352
|
toolCalls: []
|
|
343
353
|
}];
|
|
@@ -766,7 +776,9 @@ const REASONING_CONTENT_REPLAY_MODEL_IDS = /* @__PURE__ */ new Set([
|
|
|
766
776
|
"mimo-v2-omni",
|
|
767
777
|
"mimo-v2.5",
|
|
768
778
|
"mimo-v2.5-pro",
|
|
769
|
-
"mimo-v2.6-
|
|
779
|
+
"mimo-v2.6-flash",
|
|
780
|
+
"mimo-v2.6-pro",
|
|
781
|
+
"mimo-v2.6-pro-ultraspeed"
|
|
770
782
|
]);
|
|
771
783
|
const REASONING_CONTENT_REPLAY_TIER_SUFFIXES = [
|
|
772
784
|
"-free",
|
|
@@ -1414,7 +1426,7 @@ async function processCompletionsStream(responseStream, output, model, stream, o
|
|
|
1414
1426
|
let isFlushingPendingPostToolCallDeltas = false;
|
|
1415
1427
|
const toolCallBlocksByIndex = /* @__PURE__ */ new Map();
|
|
1416
1428
|
const toolCallBlocksById = /* @__PURE__ */ new Map();
|
|
1417
|
-
const encryptedReasoning =
|
|
1429
|
+
const encryptedReasoning = createOpenAIEncryptedToolCallReasoningTracker();
|
|
1418
1430
|
const toolArgumentPreviewSchedules = /* @__PURE__ */ new WeakMap();
|
|
1419
1431
|
const provisionalCommentaryTags = directMode ? options.provisionalCommentaryTags : /* @__PURE__ */ new Map();
|
|
1420
1432
|
const contentBlockIndices = /* @__PURE__ */ new WeakMap();
|
|
@@ -1749,7 +1761,7 @@ async function processCompletionsStream(responseStream, output, model, stream, o
|
|
|
1749
1761
|
partialArgs: "",
|
|
1750
1762
|
...initialSig ? { thoughtSignature: initialSig } : {}
|
|
1751
1763
|
};
|
|
1752
|
-
encryptedReasoning
|
|
1764
|
+
encryptedReasoning.rememberToolCall(block.id, block);
|
|
1753
1765
|
toolArgumentPreviewSchedules.set(block, createToolArgumentPreviewSchedule());
|
|
1754
1766
|
output.content.push(block);
|
|
1755
1767
|
toolCallBlockIndices.set(block, output.content.length - 1);
|
|
@@ -1761,9 +1773,10 @@ async function processCompletionsStream(responseStream, output, model, stream, o
|
|
|
1761
1773
|
}
|
|
1762
1774
|
if (streamIndex !== void 0 && !toolCallBlocksByIndex.has(streamIndex)) toolCallBlocksByIndex.set(streamIndex, block);
|
|
1763
1775
|
if (toolCall.id) {
|
|
1776
|
+
const previousId = block.id;
|
|
1764
1777
|
if (!directMode || !block.id) block.id = toolCall.id;
|
|
1765
1778
|
toolCallBlocksById.set(toolCall.id, block);
|
|
1766
|
-
if (block.id === toolCall.id) encryptedReasoning
|
|
1779
|
+
if (block.id === toolCall.id) encryptedReasoning.rememberToolCall(toolCall.id, block, previousId);
|
|
1767
1780
|
}
|
|
1768
1781
|
currentBlock = block;
|
|
1769
1782
|
const conflictingId = directMode && block.id && toolCall.id && block.id !== toolCall.id;
|
|
@@ -1783,7 +1796,7 @@ async function processCompletionsStream(responseStream, output, model, stream, o
|
|
|
1783
1796
|
});
|
|
1784
1797
|
}
|
|
1785
1798
|
}
|
|
1786
|
-
encryptedReasoning
|
|
1799
|
+
encryptedReasoning.consumeDetails(deltaFields.reasoning_details);
|
|
1787
1800
|
}
|
|
1788
1801
|
flushPendingPostToolCallDeltas();
|
|
1789
1802
|
emitReasoningUsageActivity(hasReasoningUsageActivity);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { M as OpenAICompletionsCompat, O as Model, l as CacheRetention } from "./types-
|
|
2
|
-
import "./types-
|
|
1
|
+
import { M as OpenAICompletionsCompat, O as Model, l as CacheRetention } from "./types-qZFbaDbK.mjs";
|
|
2
|
+
import "./types-DTvddOfm.mjs";
|
|
3
3
|
//#region packages/ai/src/providers/openai-prompt-cache.d.ts
|
|
4
4
|
/** Selects documented lifetime fields shared by Responses and Chat Completions. */
|
|
5
5
|
declare function resolveOpenAIPromptCacheParams(model: Pick<Model, "id" | "provider" | "baseUrl">, cacheRetention: CacheRetention, compat: Required<Pick<OpenAICompletionsCompat, "supportsPromptCacheKey" | "supportsLongCacheRetention">>): {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as isNativeOpenAIEndpoint } from "./openai-completions-compat-
|
|
1
|
+
import { n as isNativeOpenAIEndpoint } from "./openai-completions-compat-CUollwl6.mjs";
|
|
2
2
|
//#region packages/normalization-core/src/code-points.ts
|
|
3
3
|
/** Truncates to a nonnegative code-point budget; grapheme clusters may be split. */
|
|
4
4
|
function truncateCodePoints(text, maxCodePoints) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { n as getAiTransportHost } from "./host-
|
|
2
|
-
import { k as resolveOpenAIClientBaseUrl } from "./openai-transport-params-
|
|
1
|
+
import { n as getAiTransportHost } from "./host-yTvBrYM2.mjs";
|
|
2
|
+
import { k as resolveOpenAIClientBaseUrl } from "./openai-transport-params-DZKOTSfH.mjs";
|
|
3
3
|
import { i as resolveCloudflareBaseUrl, r as isCloudflareProvider } from "./github-copilot-headers-B37TB3rB.mjs";
|
|
4
4
|
import OpenAI from "openai";
|
|
5
5
|
//#region packages/ai/src/providers/openai-provider-client.ts
|
|
@@ -158,6 +158,11 @@ function isOpenAIGpt56Model(model) {
|
|
|
158
158
|
const name = normalizeModelId(typeof model.name === "string" ? model.name : void 0);
|
|
159
159
|
return /^gpt-5\.6(?:-|$)/u.test(id) || /^gpt-5\.6(?:\s|\(|-|$)/u.test(name);
|
|
160
160
|
}
|
|
161
|
+
/** Return whether a model has a known GPT-6 reasoning and sampling contract. */
|
|
162
|
+
function isOpenAIGpt6Model(model) {
|
|
163
|
+
const id = normalizeModelId(typeof model.id === "string" ? model.id : void 0);
|
|
164
|
+
return id === "gpt-6-astra" || id === "gpt-6-sol" || id === "gpt-6-luna";
|
|
165
|
+
}
|
|
161
166
|
/** Normalize user-facing reasoning effort names to API effort names. */
|
|
162
167
|
function normalizeOpenAIReasoningEffort(effort) {
|
|
163
168
|
const trimmed = effort.trim();
|
|
@@ -185,7 +190,10 @@ function resolveOpenAIModelReasoningEfforts(model) {
|
|
|
185
190
|
const id = normalizeModelId(typeof model.id === "string" ? model.id : void 0);
|
|
186
191
|
const api = resolveOpenAIThinkingApi(model.api);
|
|
187
192
|
const supportsMax = api !== "openai-completions";
|
|
188
|
-
if (
|
|
193
|
+
if (isOpenAIGpt6Model(model) && api !== "azure-openai-responses") {
|
|
194
|
+
if (id === "gpt-6-astra") return supportsMax ? GPT_6_ASTRA_REASONING_EFFORTS : GPT_CODEX_REASONING_EFFORTS;
|
|
195
|
+
return supportsMax ? GPT_56_REASONING_EFFORTS : GPT_52_REASONING_EFFORTS;
|
|
196
|
+
}
|
|
189
197
|
if (/^gpt-5\.6(?:-|$)/u.test(id)) return supportsMax ? GPT_56_REASONING_EFFORTS : GPT_52_REASONING_EFFORTS;
|
|
190
198
|
if (id === "gpt-5.1-codex-mini") return GPT_51_CODEX_MINI_REASONING_EFFORTS;
|
|
191
199
|
if (id === "gpt-5.1-codex-max") return GPT_51_CODEX_MAX_REASONING_EFFORTS;
|
|
@@ -197,7 +205,7 @@ function resolveOpenAIModelReasoningEfforts(model) {
|
|
|
197
205
|
if (/^gpt-5(?:-|$)/u.test(id)) return GPT_5_REASONING_EFFORTS;
|
|
198
206
|
}
|
|
199
207
|
/**
|
|
200
|
-
* Return whether a model accepts temperature. GPT-5.6 and GPT-6
|
|
208
|
+
* Return whether a model accepts temperature. GPT-5.6 and known GPT-6 models
|
|
201
209
|
* reject it with a 400; catalog compat can override per model.
|
|
202
210
|
*/
|
|
203
211
|
function supportsOpenAITemperature(model) {
|
|
@@ -207,7 +215,7 @@ function supportsOpenAITemperature(model) {
|
|
|
207
215
|
if (typeof declared === "boolean") return declared;
|
|
208
216
|
}
|
|
209
217
|
const id = normalizeModelId(typeof model.id === "string" ? model.id : void 0);
|
|
210
|
-
return (
|
|
218
|
+
return (!isOpenAIGpt6Model(model) || resolveOpenAIThinkingApi(model.api) === "azure-openai-responses") && !/^gpt-5\.6(?:-|$)/u.test(id);
|
|
211
219
|
}
|
|
212
220
|
/** Return whether a model accepts a requested reasoning effort. */
|
|
213
221
|
function supportsOpenAIReasoningEffort(model, effort) {
|
|
@@ -232,4 +240,4 @@ function resolveOpenAIReasoningEffortForModel(params) {
|
|
|
232
240
|
return (requestedRank < 0 ? void 0 : ranked.findLast((effort) => ENABLED_REASONING_EFFORTS.indexOf(effort) <= requestedRank) ?? ranked[0]) ?? supported.find((effort) => !isDisabledReasoningEffort(normalizeOpenAIReasoningEffort(effort)));
|
|
233
241
|
}
|
|
234
242
|
//#endregion
|
|
235
|
-
export {
|
|
243
|
+
export { normalizeOpenAIReasoningEffort as a, resolveOpenAIReasoningEffortMapping as c, supportsOpenAITemperature as d, MODEL_CATALOG_THINKING_LEVELS as f, isOpenAIGpt6Model as i, resolveOpenAISupportedReasoningEfforts as l, resolveOpenAIThinkingApi as m, isOpenAIGpt55Model as n, resolveOpenAIModelReasoningEfforts as o, listMappedModelThinkingLevels as p, isOpenAIGpt56Model as r, resolveOpenAIReasoningEffortForModel as s, isOpenAIGpt54MiniModel as t, supportsOpenAIReasoningEffort as u };
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { t as __exportAll } from "./rolldown-runtime-BhDjJH2R.mjs";
|
|
2
2
|
import { t as AssistantMessageEventStream } from "./event-stream-D8PARQfL.mjs";
|
|
3
|
-
import { n as clampOpenAIPromptCacheKey, r as resolveOpenAIPromptCacheParams } from "./openai-prompt-cache-
|
|
4
|
-
import { i as resolveOpenAICompletionsCompat } from "./openai-completions-compat-
|
|
3
|
+
import { n as clampOpenAIPromptCacheKey, r as resolveOpenAIPromptCacheParams } from "./openai-prompt-cache-CjV_2IRI.mjs";
|
|
4
|
+
import { i as resolveOpenAICompletionsCompat } from "./openai-completions-compat-CUollwl6.mjs";
|
|
5
5
|
import { t as resolveCacheRetention } from "./cache-retention-0x979a5V.mjs";
|
|
6
|
-
import { n as buildBaseOptions } from "./simple-options-
|
|
7
|
-
import { g as resolveOpenAISimpleReasoningEffort } from "./openai-transport-params-
|
|
6
|
+
import { n as buildBaseOptions } from "./simple-options-np1XPuhm.mjs";
|
|
7
|
+
import { g as resolveOpenAISimpleReasoningEffort } from "./openai-transport-params-DZKOTSfH.mjs";
|
|
8
8
|
import { n as getEnvApiKey } from "./env-api-keys-bktO00EJ.mjs";
|
|
9
|
-
import { n as resolveProviderSimpleCompletionHeaders } from "./provider-transport-turn-state-
|
|
10
|
-
import { a as runResponsesStreamLifecycle, i as createResponsesAssistantOutput, n as applyResponsesServiceTierPricing, r as convertResponsesMessages, t as applyCommonResponsesParams } from "./openai-responses-shared-
|
|
9
|
+
import { n as resolveProviderSimpleCompletionHeaders } from "./provider-transport-turn-state-lrXEFkYr.mjs";
|
|
10
|
+
import { a as runResponsesStreamLifecycle, i as createResponsesAssistantOutput, n as applyResponsesServiceTierPricing, r as convertResponsesMessages, t as applyCommonResponsesParams } from "./openai-responses-shared-DvSqtJ6_.mjs";
|
|
11
11
|
import { n as hasCopilotVisionInput, t as buildCopilotDynamicHeaders } from "./github-copilot-headers-B37TB3rB.mjs";
|
|
12
|
-
import { t as createOpenAIProviderClient } from "./openai-provider-client-
|
|
12
|
+
import { t as createOpenAIProviderClient } from "./openai-provider-client-BP8J1aeg.mjs";
|
|
13
13
|
//#region packages/ai/src/providers/openai-responses.ts
|
|
14
14
|
var openai_responses_exports = /* @__PURE__ */ __exportAll({
|
|
15
15
|
streamOpenAIResponses: () => streamOpenAIResponses,
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { i as normalizeOptionalLowercaseString, n as normalizeLowercaseStringOrEmpty, s as readStringValue } from "./string-coerce-fsri9iCu.mjs";
|
|
2
2
|
import { o as isRecord } from "./record-coerce-DwRYMj3t.mjs";
|
|
3
|
-
import {
|
|
4
|
-
import { t as canonicalizeBase64 } from "./base64-
|
|
5
|
-
import { t as parsePositiveInteger } from "./positive-integer-
|
|
3
|
+
import { u as supportsOpenAIReasoningEffort } from "./openai-reasoning-effort-ash8dPrd.mjs";
|
|
4
|
+
import { t as canonicalizeBase64 } from "./base64-CPmadnUf.mjs";
|
|
5
|
+
import { t as parsePositiveInteger } from "./positive-integer-BiUxrd71.mjs";
|
|
6
6
|
import { i as OPENAI_RESPONSES_APIS } from "./openai-responses-contracts-DWrfMODE.mjs";
|
|
7
7
|
import { t as createSseByteGuard } from "./streaming-byte-guard-CC-HMn_u.mjs";
|
|
8
8
|
//#region packages/model-catalog-core/src/provider-id.ts
|
package/dist/{openai-responses-contracts-Dflvrfa8.d.mts → openai-responses-contracts-B1ENJFpI.d.mts}
RENAMED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import "./index-
|
|
2
|
-
import { O as Model, j as ModelThinkingLevel, n as Api } from "./types-
|
|
3
|
-
import { a as BaseOpenAIStreamOptions, f as OpenAIReasoningEffort } from "./provider-options-
|
|
4
|
-
import "./types-
|
|
1
|
+
import "./index-C25RT6bP.mjs";
|
|
2
|
+
import { O as Model, j as ModelThinkingLevel, n as Api } from "./types-qZFbaDbK.mjs";
|
|
3
|
+
import { a as BaseOpenAIStreamOptions, f as OpenAIReasoningEffort } from "./provider-options-DZYq53lj.mjs";
|
|
4
|
+
import "./types-DTvddOfm.mjs";
|
|
5
5
|
import { ResponseCompactionItem, ResponseCreateParamsStreaming, ResponseInputItem } from "openai/resources/responses/responses.js";
|
|
6
6
|
//#region packages/ai/src/providers/openai-request-reasoning.d.ts
|
|
7
7
|
type OpenAIRequestReasoningEffort = ModelThinkingLevel | "none";
|