@openclaw/codex 2026.9.3 → 2026.9.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/assets/activity.svg +30 -0
- package/assets/icon.png +0 -0
- package/dist/.setup/account-usage-runtime-C2MOIvfq.mjs +75 -0
- package/dist/{apply-B6el6hdO.js → .setup/apply-CJ0ZfmBG.mjs} +12 -13
- package/dist/.setup/async-questions-DdhOCwGi.mjs +27 -0
- package/dist/{attempt-client-cleanup-D6cR54TV.js → .setup/attempt-client-cleanup-BpYKdTA0.mjs} +30 -211
- package/dist/{attempt-context-AO4DSjE0.js → .setup/attempt-context-VXVwTCfS.mjs} +6 -6
- package/dist/.setup/attempt-terminal-gZrxQ35N.mjs +5 -0
- package/dist/{auth-binding-Co2Vfcf_.js → .setup/auth-binding-DhLWa_7K.mjs} +2 -2
- package/dist/{auth-cache-key-Kq6oerr6.js → .setup/auth-cache-key-QirmgiCo.mjs} +3 -3
- package/dist/{auth-profile-CwzO4_RG.js → .setup/auth-profile-WqZtZfXN.mjs} +1 -1
- package/dist/.setup/binding-connection-Bm38niE8.mjs +50 -0
- package/dist/.setup/binding-connection.runtime-CnRMC0ta.mjs +48 -0
- package/dist/{bounded-turn-lRpmZHFv.js → .setup/bounded-turn-BtlZcivC.mjs} +19 -14
- package/dist/{build-state-6RL6qohz.js → .setup/build-state-Xx9ybZqa.mjs} +1 -1
- package/dist/{capabilities-BeqLPbtM.js → .setup/capabilities-_vXcZGSx.mjs} +1 -1
- package/dist/{client-BEKu4yDx.js → .setup/client-vXs2929Q.mjs} +355 -164
- package/dist/{command-dispatch-CisT9Jqq.js → .setup/command-dispatch-naHIZwwF.mjs} +3 -3
- package/dist/{command-formatters-DeTfrapr.js → .setup/command-formatters-CGEkdawF.mjs} +4 -3
- package/dist/{command-handlers-BfIsJEuA.js → .setup/command-handlers-BtAJEW1X.mjs} +812 -152
- package/dist/{command-rpc-BMqRQOFX.js → .setup/command-rpc-DHFpn4le.mjs} +37 -21
- package/dist/{compact-CGJZ2rlb.js → .setup/compact-C3i3qlzj.mjs} +28 -43
- package/dist/{config-JDfTI4VI.js → .setup/config-CedDWjM-.mjs} +5 -4
- package/dist/{config-options-jnIFvwxD.js → .setup/config-options-BsanJ8QG.mjs} +9 -421
- package/dist/{protocol-CAAcVIKF.js → .setup/config-parsing-CcB9iPoq.mjs} +9 -51
- package/dist/{config-runtime-BWf6JLWG.js → .setup/config-runtime-CeAhl_h4.mjs} +2 -2
- package/dist/.setup/config-security-BRQ2mgW9.mjs +465 -0
- package/dist/{config-utils-C57JiJrU.js → .setup/config-utils-DujwEnhg.mjs} +2 -4
- package/dist/{conversation-binding-CxOlHiix.js → .setup/conversation-binding-DhzrpTM6.mjs} +60 -47
- package/dist/{conversation-binding-data-BiodpIzq.js → .setup/conversation-binding-data-CrcyZk6O.mjs} +1 -1
- package/dist/{conversation-control-CUCrSIQI.js → .setup/conversation-control-DN53ns41.mjs} +17 -13
- package/dist/.setup/cyber-failover-DYwbmf1o.mjs +123 -0
- package/dist/.setup/cyber-failover-notice-e9G3J9-e.mjs +17 -0
- package/dist/{dynamic-tools-D-JBoaLt.js → .setup/dynamic-tools-D16lOp67.mjs} +168 -61
- package/dist/{effective-mcp-catalog-J_5Ep5Um.js → .setup/effective-mcp-catalog-K6kLCN8X.mjs} +3 -3
- package/dist/{ephemeral-turn-DSwzP8YY.js → .setup/ephemeral-turn-R1gA8Sn6.mjs} +4 -5
- package/dist/{event-projector-assistant-message-BmBM4qBV.js → .setup/event-projector-assistant-message-DNUR1s0A.mjs} +6 -3
- package/dist/.setup/event-projector-items-DyTQ_XqL.mjs +200 -0
- package/dist/{attempt-notifications--H8zXR5-.js → .setup/event-projector-usage-C7Ntzs-f.mjs} +102 -9
- package/dist/{harness-FR6eQgyO.js → .setup/harness-rxaaoN-o.mjs} +90 -19
- package/dist/.setup/inference-context-fulhZuz8.mjs +94 -0
- package/dist/.setup/inference-proxy-CC15HuSi.mjs +311 -0
- package/dist/{isolated-completion-DHBefrzg.js → .setup/isolated-completion-B6srt48J.mjs} +7 -7
- package/dist/{launch-args-RXQwn8zV.js → .setup/launch-args-DnMak49W.mjs} +22 -1
- package/dist/{managed-binary-DrjjRRUD.js → .setup/managed-binary-DP6Rib3P.mjs} +11 -2
- package/dist/{managed-thread-store-D1t5jh3G.js → .setup/managed-thread-store-BMqgThVL.mjs} +48 -14
- package/dist/{model-catalog-B_6M04Wo.js → .setup/model-catalog-DkvUuBey.mjs} +35 -10
- package/dist/{models-P9k2qAof.js → .setup/models-BDFgm_G-.mjs} +3 -3
- package/dist/.setup/native-auth-BLZGqFjw.mjs +57 -0
- package/dist/.setup/native-subagent-history-YXaL6dMd.mjs +135 -0
- package/dist/.setup/native-subagent-monitor-B1hxzIOy.mjs +5031 -0
- package/dist/.setup/native-subagent-task-ids-DsuOonKv.mjs +411 -0
- package/dist/{node-cli-sessions-rj0ysJwM.js → .setup/node-cli-sessions-Cl8b2ZF3.mjs} +1 -1
- package/dist/{node-exec-server.runtime-BY_ctYnT.js → .setup/node-exec-server.runtime-BaViBKNz.mjs} +5 -5
- package/dist/{plan-BMJdMOEF.js → .setup/plan-xD7WKYTM.mjs} +331 -79
- package/dist/{plugin-activation-BQK-f5sV.js → .setup/plugin-activation-r8nq5Jzp.mjs} +24 -19
- package/dist/{plugin-app-cache-key-CdSQzWyX.js → .setup/plugin-app-cache-key-BOxKP7db.mjs} +29 -25
- package/dist/{plugin-approval-roundtrip-DeW95wB5.js → .setup/plugin-approval-roundtrip-CjfzafAZ.mjs} +1 -1
- package/dist/{plugin-inventory-CoRCzWW4.js → .setup/plugin-inventory-DUle8DLz.mjs} +12 -8
- package/dist/{plugin-marketplace-discovery-3akBizzF.js → .setup/plugin-marketplace-discovery-P-Vndfqq.mjs} +18 -15
- package/dist/{plugin-metadata-cache-DgNfRAGA.js → .setup/plugin-metadata-cache-DsS5buNa.mjs} +33 -14
- package/dist/{provider-capabilities-W4tfK5Y5.js → .setup/provider-capabilities-B8J4Dy-O.mjs} +2 -2
- package/dist/.setup/provider-fFh_-VR3.mjs +50 -0
- package/dist/{rate-limits-Bqnx1N4z.js → .setup/rate-limits-DOEGYRNs.mjs} +90 -46
- package/dist/.setup/request-BioXJLYa.mjs +292 -0
- package/dist/.setup/run-attempt-lifecycle-B7JbY4-F.mjs +71 -0
- package/dist/{run-attempt-DwKds3DN.js → .setup/run-attempt-rlA07pUv.mjs} +644 -491
- package/dist/{runtime-artifact-T-NwqeSH.js → .setup/runtime-artifact-Dy38Z5iU.mjs} +2 -2
- package/dist/{sandbox-guard-BcT66fWy.js → .setup/sandbox-guard-BBP-RbTf.mjs} +4 -3
- package/dist/{session-binding-CKSepwIC.js → .setup/session-binding-_0W_fHRr.mjs} +45 -63
- package/dist/{session-binding-record-CaZjYwNS.js → .setup/session-binding-record-TH3xA0zj.mjs} +181 -3
- package/dist/.setup/session-binding-sidecars-CKYEcfNn.mjs +543 -0
- package/dist/{session-catalog-adoption-BKLtSrwi.js → .setup/session-catalog-adoption-CR_whkEW.mjs} +6 -6
- package/dist/{session-catalog-archive-D0i2pGj2.js → .setup/session-catalog-archive-CwZaPacf.mjs} +6 -6
- package/dist/.setup/session-catalog-events-jMcYfQyd.mjs +250 -0
- package/dist/.setup/session-catalog-fUdWDx-U.mjs +2464 -0
- package/dist/.setup/session-catalog-index-B141u15s.mjs +1070 -0
- package/dist/.setup/session-catalog-index-order-Cc5BzlQr.mjs +48 -0
- package/dist/.setup/session-catalog-index-state-BAuDztHN.mjs +180 -0
- package/dist/{session-catalog-parsing-CdD3JhdM.js → .setup/session-catalog-native-projection-ChV3cCtm.mjs} +213 -21
- package/dist/{session-catalog-node-adoption-BUuDYY8R.js → .setup/session-catalog-node-adoption-BVRsYOSh.mjs} +3 -3
- package/dist/{session-catalog-node-continue-CBtc4wkI.js → .setup/session-catalog-node-continue-Dowv8osw.mjs} +7 -7
- package/dist/.setup/session-catalog-projection-C1Bj9Jl-.mjs +414 -0
- package/dist/{session-cli-CbgaHh0f.js → .setup/session-cli-DIj-IE-E.mjs} +4 -4
- package/dist/{session-history-Cz-tOOYj.js → .setup/session-history-C--SrLI8.mjs} +10 -5
- package/dist/{session-history-import-DFN7sWRU.js → .setup/session-history-import-JHXT5Xfi.mjs} +4 -4
- package/dist/{session-history-read-cxPUxyVV.js → .setup/session-history-read-B3ZfSUbF.mjs} +2 -2
- package/dist/{session-history.worker-CNEvGaU5.js → .setup/session-history.worker-CpNj7H_P.mjs} +192 -89
- package/dist/{session-initialization-Jo86C60I.js → .setup/session-initialization-DH1z6fXn.mjs} +2 -2
- package/dist/{session-permission-policy-B22InTp_.js → .setup/session-permission-policy-DhurXY0l.mjs} +2 -2
- package/dist/{session-retirement-BSNG_mhf.js → .setup/session-retirement-CU87AOg9.mjs} +6 -6
- package/dist/{settled-turn-context-Du6gdUDd.js → .setup/settled-turn-context-fmwouT5I.mjs} +2 -2
- package/dist/{settled-turn-finalizer-BuLUrZl2.js → .setup/settled-turn-finalizer-CiY2bLFK.mjs} +10 -10
- package/dist/{shared-client-CVhez2Uo.js → .setup/shared-client-BpTtuLQ5.mjs} +495 -156
- package/dist/{side-question-DLbr2vUU.js → .setup/side-question-DSCZyoBD.mjs} +64 -47
- package/dist/{source-Da-h6f7e.js → .setup/source-Bjp4UQij.mjs} +15 -14
- package/dist/{thread-archive-guard-D1bP04Tf.js → .setup/thread-archive-guard-jmecf6OJ.mjs} +1 -1
- package/dist/.setup/thread-history-page-BTx-4xsg.mjs +83 -0
- package/dist/{thread-lifecycle-D1pzRwHB.js → .setup/thread-lifecycle-Cik28qWn.mjs} +330 -150
- package/dist/{thread-ownership-D6oASVRu.js → .setup/thread-ownership-skomxnIt.mjs} +4 -4
- package/dist/{thread-policy-D8kI7yAO.js → .setup/thread-policy-Cjs4B8xf.mjs} +3 -3
- package/dist/{thread-resume-T5cveyxA.js → .setup/thread-resume-BkNpj9Pz.mjs} +8 -5
- package/dist/.setup/timeout-DZF05XrR.mjs +63 -0
- package/dist/{session-catalog-home-id-D7-aLiNt.js → .setup/transcript-history-projection-DHNBDhCU.mjs} +73 -20
- package/dist/{transcript-mirror-t5TOccct.js → .setup/transcript-mirror-D4qp_leP.mjs} +15 -6
- package/dist/{transcript-mirror-attestation-DibE0krH.js → .setup/transcript-mirror-attestation-CzM-94NC.mjs} +4 -1
- package/dist/{transport-stdio-BGjHoYLr.js → .setup/transport-stdio-Cmx94Oiy.mjs} +149 -44
- package/dist/{upstream-session-fork-De-sLJ2r.js → .setup/upstream-session-fork-D3UKxgVD.mjs} +27 -26
- package/dist/{usage-CPPTmBvZ.js → .setup/usage-BOgBEKso.mjs} +4 -4
- package/dist/.setup/usage-limit-error-C0ow7DOc.mjs +166 -0
- package/dist/{version-omm6IPI3.js → .setup/version-CoqzXPgK.mjs} +1 -1
- package/dist/{web-search-provider.runtime-CSVgQL0w.js → .setup/web-search-provider.runtime-CTGuJt6i.mjs} +3 -3
- package/dist/api.js +28 -20
- package/dist/cli-metadata.js +1 -1
- package/dist/doctor-contract-api.js +8 -528
- package/dist/harness.js +1 -1
- package/dist/index.js +130 -135
- package/dist/media-understanding-provider.js +3 -3
- package/dist/migration-provider-api.js +2 -0
- package/dist/native-tool-policy.js +12 -0
- package/dist/provider-discovery.js +18 -0
- package/dist/session-history-worker-runtime.js +23 -5
- package/dist/session-history.worker.js +2 -2
- package/dist/web-search-contract-api.js +1 -1
- package/openclaw.plugin.json +354 -68
- package/package.json +11 -8
- package/dist/binding-connection-QqgcPCgk.js +0 -60
- package/dist/event-projector-usage-CIyrYYid.js +0 -102
- package/dist/native-subagent-monitor-BbCUKRwC.js +0 -3350
- package/dist/request-CGvGOpeR.js +0 -198
- package/dist/session-catalog-HaDcp7Sv.js +0 -1533
- package/dist/session-catalog-provenance-DkJHo735.js +0 -124
- package/dist/timeout-BVw8aaM1.js +0 -33
- package/dist/{auth-profile-selection-DFu9e167.js → .setup/auth-profile-selection-DFu9e167.mjs} +0 -0
- package/dist/{context-compaction-activity-CMla5FPJ.js → .setup/context-compaction-activity-CMla5FPJ.mjs} +0 -0
- package/dist/{elicitation-input-DPoK8F7w.js → .setup/elicitation-input-DPoK8F7w.mjs} +0 -0
- package/dist/{history-rejection-B4nOXNXF.js → .setup/history-rejection-B4nOXNXF.mjs} +0 -0
- package/dist/{image-payload-sanitizer-tupAr-2o.js → .setup/image-payload-sanitizer-tupAr-2o.mjs} +0 -0
- package/dist/{incognito-session-uhrBF6wJ.js → .setup/incognito-session-uhrBF6wJ.mjs} +0 -0
- package/dist/{local-runtime-attribution-B_2mnqhb.js → .setup/local-runtime-attribution-B_2mnqhb.mjs} +0 -0
- package/dist/{native-execution-policy-umd0tgh4.js → .setup/native-execution-policy-YBMHSzC4.mjs} +1 -1
- /package/dist/{rolldown-runtime-8H4AJuhK.js → .setup/rolldown-runtime-8H4AJuhK.mjs} +0 -0
- /package/dist/{session-binding-meta-B7aEMU7g.js → .setup/session-binding-meta-B7aEMU7g.mjs} +0 -0
- /package/dist/{session-upstream-marker-D15C9NHp.js → .setup/session-upstream-marker-D15C9NHp.mjs} +0 -0
- /package/dist/{upstream-prompt-provenance-LphB8slG.js → .setup/upstream-prompt-provenance-LphB8slG.mjs} +0 -0
- /package/dist/{web-search-provider.shared-BrZmlqyR.js → .setup/web-search-provider.shared-BrZmlqyR.mjs} +0 -0
|
@@ -1,31 +1,62 @@
|
|
|
1
|
-
import { t as __exportAll } from "./rolldown-runtime-8H4AJuhK.
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { r as
|
|
6
|
-
import "./
|
|
7
|
-
import
|
|
1
|
+
import { t as __exportAll } from "./rolldown-runtime-8H4AJuhK.mjs";
|
|
2
|
+
import { _ as resolveCodexAppServerUserHomeDir, m as isJsonObject } from "./config-security-BRQ2mgW9.mjs";
|
|
3
|
+
import { a as closeCodexCatalogClientSource, l as recordCodexCatalogResponseSource, n as projectCodexCatalogNativeResponse, o as codexCatalogSourceForClient } from "./session-catalog-native-projection-ChV3cCtm.mjs";
|
|
4
|
+
import { r as MIN_SUPPORTED_CODEX_APP_SERVER_VERSION, t as CODEX_APP_SERVER_VERSION } from "./version-CoqzXPgK.mjs";
|
|
5
|
+
import { a as hasCodexAppServerNaturalExit, i as closeCodexAppServerTransportAndWait, r as closeCodexAppServerTransport, t as createStdioTransport } from "./transport-stdio-Cmx94Oiy.mjs";
|
|
6
|
+
import { i as CodexAppServerRpcError, r as CODEX_APP_SERVER_OVERLOADED_ERROR_CODE } from "./timeout-DZF05XrR.mjs";
|
|
7
|
+
import "./config-CedDWjM-.mjs";
|
|
8
|
+
import { n as resolveCodexAppServerRuntimeOptions } from "./config-runtime-CeAhl_h4.mjs";
|
|
8
9
|
import { isRecord, normalizeOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
9
10
|
import { randomUUID } from "node:crypto";
|
|
10
|
-
import { addTimerTimeoutGraceMs, parseStrictNonNegativeInteger } from "openclaw/plugin-sdk/number-runtime";
|
|
11
|
+
import { addSafeTimeoutDelayGraceMs, addTimerTimeoutGraceMs, parseStrictNonNegativeInteger } from "openclaw/plugin-sdk/number-runtime";
|
|
12
|
+
import { normalizeJsonSchemaForTypeBox } from "openclaw/plugin-sdk/json-schema-runtime";
|
|
11
13
|
import path from "node:path";
|
|
12
14
|
import { EventEmitter } from "node:events";
|
|
13
15
|
import { coerceErrorMessage, toStringifiedError } from "openclaw/plugin-sdk/error-runtime";
|
|
14
16
|
import { sliceUtf16Safe, truncateUtf16Safe } from "openclaw/plugin-sdk/text-utility-runtime";
|
|
17
|
+
import { hasPendingInternalDiagnosticEvent } from "openclaw/plugin-sdk/diagnostic-runtime";
|
|
18
|
+
import { createDeferred } from "openclaw/plugin-sdk/extension-shared";
|
|
15
19
|
import { OPENCLAW_VERSION, embeddedAgentLog, formatToolExecutionErrorMessage, normalizeQuestionTimeoutSeconds, resolveToolExecutionErrorKind } from "openclaw/plugin-sdk/agent-harness-runtime";
|
|
16
20
|
import { createInterface } from "node:readline";
|
|
17
21
|
import { parse } from "semver";
|
|
18
|
-
import {
|
|
22
|
+
import { sanitizeTerminalText } from "openclaw/plugin-sdk/text-chunking";
|
|
23
|
+
import { copyInternalToolResultState } from "openclaw/plugin-sdk/agent-harness-tool-runtime";
|
|
19
24
|
import { Compile } from "typebox/compile";
|
|
20
25
|
import net from "node:net";
|
|
21
26
|
import { PassThrough, Writable } from "node:stream";
|
|
22
27
|
import { StringDecoder } from "node:string_decoder";
|
|
23
|
-
import WebSocket from "
|
|
28
|
+
import { WebSocket } from "openclaw/plugin-sdk/websocket-runtime";
|
|
24
29
|
//#region extensions/codex/src/app-server/protocol-json.ts
|
|
25
30
|
function isRpcResponse(message) {
|
|
26
31
|
return "id" in message && !("method" in message);
|
|
27
32
|
}
|
|
28
33
|
//#endregion
|
|
34
|
+
//#region extensions/codex/src/app-server/client-response.ts
|
|
35
|
+
/** Settles one wire attempt and reports newly observed native execution. */
|
|
36
|
+
function dispatchCodexAppServerResponse(response, attempts, catalogResponses, source) {
|
|
37
|
+
const pending = attempts.get(response.id);
|
|
38
|
+
if (!pending) return false;
|
|
39
|
+
attempts.delete(response.id);
|
|
40
|
+
if (response.error) {
|
|
41
|
+
const error = new CodexAppServerRpcError(response.error, pending.method);
|
|
42
|
+
pending.reject(error, error.code === CODEX_APP_SERVER_OVERLOADED_ERROR_CODE);
|
|
43
|
+
return false;
|
|
44
|
+
}
|
|
45
|
+
const nativeExecution = pending.method === "thread/backgroundTerminals/list" && isJsonObject(response.result) && Array.isArray(response.result.data) && response.result.data.length > 0;
|
|
46
|
+
if (catalogResponses.has(pending) && isJsonObject(response.result) && Array.isArray(response.result.data)) {
|
|
47
|
+
const projection = catalogResponses.get(pending);
|
|
48
|
+
try {
|
|
49
|
+
response.result = projectCodexCatalogNativeResponse(response.result, sanitizeTerminalText, projection?.preview, projection?.remainingRows);
|
|
50
|
+
} catch (error) {
|
|
51
|
+
pending.reject(error instanceof Error ? error : new Error("Codex catalog projection failed", { cause: error }), false);
|
|
52
|
+
return false;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
recordCodexCatalogResponseSource(pending.method, response.result, source);
|
|
56
|
+
pending.resolve(response.result);
|
|
57
|
+
return nativeExecution;
|
|
58
|
+
}
|
|
59
|
+
//#endregion
|
|
29
60
|
//#region extensions/codex/src/app-server/dynamic-tool-response-state.ts
|
|
30
61
|
/** Retains the host-owned app preview without adding it to Codex's response payload. */
|
|
31
62
|
function withDynamicToolTranscriptDetails(response, details) {
|
|
@@ -153,7 +184,7 @@ function resolveCodexToolAbortTerminalReason(signal) {
|
|
|
153
184
|
*/
|
|
154
185
|
/** Default timeout for Codex dynamic tool calls. */
|
|
155
186
|
const CODEX_DYNAMIC_TOOL_TIMEOUT_MS = 9e4;
|
|
156
|
-
/** Hard cap for per-call Codex dynamic tool timeout overrides. */
|
|
187
|
+
/** Hard cap for ordinary per-call Codex dynamic tool timeout overrides. */
|
|
157
188
|
const CODEX_DYNAMIC_TOOL_MAX_TIMEOUT_MS = 6e5;
|
|
158
189
|
const CODEX_DYNAMIC_TOOL_TIMEOUT_SECONDS_GRACE_MS = 3e4;
|
|
159
190
|
const CODEX_DYNAMIC_IMAGE_GENERATION_TOOL_TIMEOUT_MS = 12e4;
|
|
@@ -227,7 +258,10 @@ async function handleDynamicToolCallWithTimeout(params) {
|
|
|
227
258
|
const terminalResolution = params.observeToolTerminal?.({
|
|
228
259
|
toolCallId: params.call.callId,
|
|
229
260
|
toolName: params.call.tool,
|
|
230
|
-
result: response,
|
|
261
|
+
result: copyInternalToolResultState(response, {
|
|
262
|
+
...response,
|
|
263
|
+
details: response.transcriptDetails
|
|
264
|
+
}),
|
|
231
265
|
arguments: response.executedArguments ?? executionSnapshot?.executedArguments ?? params.call.arguments,
|
|
232
266
|
...params.toolMeta ? { meta: params.toolMeta } : {},
|
|
233
267
|
...ownerKey ? { ownerMutation: { ownerKey } } : {},
|
|
@@ -413,6 +447,10 @@ function hasPendingDynamicToolTerminalDiagnostic(params) {
|
|
|
413
447
|
/** Resolves per-tool timeout, applying media/message defaults and hard caps. */
|
|
414
448
|
function resolveDynamicToolCallTimeoutMs(params) {
|
|
415
449
|
const args = isJsonObject(params.call.arguments) ? params.call.arguments : void 0;
|
|
450
|
+
if (params.call.tool === "node_exec") {
|
|
451
|
+
const executionTimeoutMs = params.toolBridge?.availableTools.find((tool) => tool.name === params.call.tool)?.getExecutionTimeoutMs?.(params.call.arguments);
|
|
452
|
+
if (executionTimeoutMs !== void 0) return addSafeTimeoutDelayGraceMs(executionTimeoutMs, CODEX_DYNAMIC_TOOL_TIMEOUT_SECONDS_GRACE_MS);
|
|
453
|
+
}
|
|
416
454
|
if (params.call.tool === "openclaw" || params.call.tool === "ask_user" || params.call.tool === "secrets" && args?.action === "request") try {
|
|
417
455
|
const timeoutSeconds = params.call.tool === "openclaw" ? void 0 : args?.timeoutSeconds;
|
|
418
456
|
return normalizeQuestionTimeoutSeconds(timeoutSeconds) * 1e3 + CODEX_DYNAMIC_TOOL_TIMEOUT_SECONDS_GRACE_MS;
|
|
@@ -459,7 +497,6 @@ function readConfiguredDynamicToolTimeoutMs(toolName, config) {
|
|
|
459
497
|
const capabilityTimeoutMs = readTimeoutSecondsAsMs(config?.tools?.media?.image?.timeoutSeconds);
|
|
460
498
|
return Math.max(capabilityTimeoutMs ?? CODEX_DYNAMIC_IMAGE_TOOL_TIMEOUT_MS, ...candidates.map((entry) => readTimeoutSecondsAsMs(entry.timeoutSeconds) ?? capabilityTimeoutMs ?? CODEX_DYNAMIC_IMAGE_TOOL_TIMEOUT_MS));
|
|
461
499
|
}
|
|
462
|
-
if (toolName === "message") return CODEX_DYNAMIC_MESSAGE_TOOL_TIMEOUT_MS;
|
|
463
500
|
}
|
|
464
501
|
function readTimeoutSecondsAsMs(value) {
|
|
465
502
|
const seconds = readPositiveFiniteTimeoutMs(value);
|
|
@@ -2808,60 +2845,16 @@ const threadStartResponseSchema = materializeCodexSchema(ThreadStartResponse_def
|
|
|
2808
2845
|
const turnCompletedNotificationSchema = materializeCodexSchema(TurnCompletedNotification_default);
|
|
2809
2846
|
const turnStartResponseSchema = materializeCodexSchema(TurnStartResponse_default);
|
|
2810
2847
|
function compileCodexSchema(schema) {
|
|
2811
|
-
|
|
2848
|
+
if (typeof schema !== "boolean" && !isRecord(schema)) throw new TypeError("Generated Codex schema must be an object or boolean");
|
|
2849
|
+
const validator = Compile(normalizeJsonSchemaForTypeBox(schema));
|
|
2812
2850
|
return {
|
|
2813
2851
|
check: (value) => validator.Check(value),
|
|
2814
2852
|
errors: (value) => [...validator.Errors(value)]
|
|
2815
2853
|
};
|
|
2816
2854
|
}
|
|
2817
|
-
const schemaMapKeywords = /* @__PURE__ */ new Set([
|
|
2818
|
-
"$defs",
|
|
2819
|
-
"definitions",
|
|
2820
|
-
"dependentSchemas",
|
|
2821
|
-
"patternProperties",
|
|
2822
|
-
"properties"
|
|
2823
|
-
]);
|
|
2824
|
-
const schemaValueKeywords = /* @__PURE__ */ new Set([
|
|
2825
|
-
"additionalItems",
|
|
2826
|
-
"additionalProperties",
|
|
2827
|
-
"contains",
|
|
2828
|
-
"else",
|
|
2829
|
-
"if",
|
|
2830
|
-
"items",
|
|
2831
|
-
"not",
|
|
2832
|
-
"propertyNames",
|
|
2833
|
-
"then",
|
|
2834
|
-
"unevaluatedItems",
|
|
2835
|
-
"unevaluatedProperties"
|
|
2836
|
-
]);
|
|
2837
|
-
const schemaArrayKeywords = /* @__PURE__ */ new Set([
|
|
2838
|
-
"allOf",
|
|
2839
|
-
"anyOf",
|
|
2840
|
-
"oneOf",
|
|
2841
|
-
"prefixItems"
|
|
2842
|
-
]);
|
|
2843
2855
|
function schemaTypeIncludes(schema, type) {
|
|
2844
2856
|
return schema.type === type || Array.isArray(schema.type) && schema.type.includes(type);
|
|
2845
2857
|
}
|
|
2846
|
-
function normalizeSchemaMap(value) {
|
|
2847
|
-
if (!isRecord(value)) return value;
|
|
2848
|
-
return Object.fromEntries(Object.entries(value).map(([key, entry]) => [key, normalizeJsonSchemaNode(entry)]));
|
|
2849
|
-
}
|
|
2850
|
-
function expandJsonSchemaTypeArray(schema) {
|
|
2851
|
-
const { type, ...rest } = schema;
|
|
2852
|
-
if (!Array.isArray(type)) return schema;
|
|
2853
|
-
return { anyOf: type.map((entry) => Object.assign({}, rest, { type: entry })) };
|
|
2854
|
-
}
|
|
2855
|
-
function normalizeJsonSchemaNode(schema) {
|
|
2856
|
-
if (Array.isArray(schema)) return schema.map((entry) => normalizeJsonSchemaNode(entry));
|
|
2857
|
-
if (!isRecord(schema)) return schema;
|
|
2858
|
-
const normalizedSchema = expandJsonSchemaTypeArray(schema);
|
|
2859
|
-
return Object.fromEntries(Object.entries(normalizedSchema).map(([key, value]) => {
|
|
2860
|
-
if (schemaMapKeywords.has(key)) return [key, normalizeSchemaMap(value)];
|
|
2861
|
-
if (schemaValueKeywords.has(key) || schemaArrayKeywords.has(key)) return [key, normalizeJsonSchemaNode(value)];
|
|
2862
|
-
return [key, value];
|
|
2863
|
-
}));
|
|
2864
|
-
}
|
|
2865
2858
|
function readDefault(schema) {
|
|
2866
2859
|
if (!isRecord(schema) || !Object.hasOwn(schema, "default")) return;
|
|
2867
2860
|
return structuredClone(schema.default);
|
|
@@ -3053,6 +3046,172 @@ function formatValidationErrors(validate, value) {
|
|
|
3053
3046
|
}).join("; ");
|
|
3054
3047
|
}
|
|
3055
3048
|
//#endregion
|
|
3049
|
+
//#region extensions/codex/src/app-server/request-attempt.ts
|
|
3050
|
+
/** One wire attempt; local waiter expiry need not imply a native response. */
|
|
3051
|
+
function createCodexRequestAttempt(params) {
|
|
3052
|
+
let pending = true;
|
|
3053
|
+
let mayHaveWritten = false;
|
|
3054
|
+
const waiters = /* @__PURE__ */ new Set();
|
|
3055
|
+
const diagnostics = params.diagnosticIdentity ? {
|
|
3056
|
+
...params.diagnosticIdentity,
|
|
3057
|
+
waiterOrdinal: 0,
|
|
3058
|
+
attemptCreatedAtMs: performance.now(),
|
|
3059
|
+
firstPossibleWriteAtMs: null,
|
|
3060
|
+
wireOutcomeAtWaiterSettlement: "retained-pending",
|
|
3061
|
+
wireObservedAtMs: null
|
|
3062
|
+
} : void 0;
|
|
3063
|
+
const finish = (outcome) => {
|
|
3064
|
+
if (!pending) return false;
|
|
3065
|
+
pending = false;
|
|
3066
|
+
if (diagnostics) {
|
|
3067
|
+
diagnostics.wireOutcomeAtWaiterSettlement = outcome;
|
|
3068
|
+
diagnostics.wireObservedAtMs = performance.now();
|
|
3069
|
+
}
|
|
3070
|
+
params.onSettled();
|
|
3071
|
+
return true;
|
|
3072
|
+
};
|
|
3073
|
+
const rejectWaiters = (error, outcome) => {
|
|
3074
|
+
for (const waiter of waiters) waiter.reject(error, outcome);
|
|
3075
|
+
};
|
|
3076
|
+
const currentWaiterError = (waiter) => {
|
|
3077
|
+
if (!params.retainWritten) return;
|
|
3078
|
+
if (waiter.signal?.aborted) return {
|
|
3079
|
+
error: params.cancellationError("aborted", mayHaveWritten, waiter.signal.reason),
|
|
3080
|
+
outcome: "aborted"
|
|
3081
|
+
};
|
|
3082
|
+
if (waiter.deadline !== void 0 && performance.now() >= waiter.deadline) return {
|
|
3083
|
+
error: params.cancellationError("timed out", mayHaveWritten),
|
|
3084
|
+
outcome: "timed-out"
|
|
3085
|
+
};
|
|
3086
|
+
try {
|
|
3087
|
+
waiter.assertCurrent?.();
|
|
3088
|
+
} catch (error) {
|
|
3089
|
+
return {
|
|
3090
|
+
error: toStringifiedError(error),
|
|
3091
|
+
outcome: "authority-rejected"
|
|
3092
|
+
};
|
|
3093
|
+
}
|
|
3094
|
+
if (waiter.signal?.aborted) return {
|
|
3095
|
+
error: params.cancellationError("aborted", mayHaveWritten, waiter.signal.reason),
|
|
3096
|
+
outcome: "aborted"
|
|
3097
|
+
};
|
|
3098
|
+
if (waiter.deadline !== void 0 && performance.now() >= waiter.deadline) return {
|
|
3099
|
+
error: params.cancellationError("timed out", mayHaveWritten),
|
|
3100
|
+
outcome: "timed-out"
|
|
3101
|
+
};
|
|
3102
|
+
};
|
|
3103
|
+
return {
|
|
3104
|
+
method: params.method,
|
|
3105
|
+
get pending() {
|
|
3106
|
+
return pending;
|
|
3107
|
+
},
|
|
3108
|
+
wait(options, deadline) {
|
|
3109
|
+
const { timeoutMs, signal, assertCurrent, disposition, overloadAttemptOrdinal } = options;
|
|
3110
|
+
let observe = options.attemptWaiterFinished;
|
|
3111
|
+
return new Promise((resolve, reject) => {
|
|
3112
|
+
if (!pending) {
|
|
3113
|
+
reject(/* @__PURE__ */ new Error("Codex request attempt is already settled"));
|
|
3114
|
+
return;
|
|
3115
|
+
}
|
|
3116
|
+
let timer;
|
|
3117
|
+
let removeAbort;
|
|
3118
|
+
const waiterOrdinal = diagnostics ? ++diagnostics.waiterOrdinal : 0;
|
|
3119
|
+
const waiterAttachedAtMs = diagnostics && observe ? performance.now() : 0;
|
|
3120
|
+
const cleanup = () => {
|
|
3121
|
+
clearTimeout(timer);
|
|
3122
|
+
timer = void 0;
|
|
3123
|
+
removeAbort?.();
|
|
3124
|
+
removeAbort = void 0;
|
|
3125
|
+
};
|
|
3126
|
+
const detach = (waiterOutcome) => {
|
|
3127
|
+
if (!waiters.delete(waiter)) return false;
|
|
3128
|
+
cleanup();
|
|
3129
|
+
if (waiters.size === 0 && (!params.retainWritten || !mayHaveWritten)) finish(mayHaveWritten ? "correlation-closed" : "not-written");
|
|
3130
|
+
const callback = observe;
|
|
3131
|
+
observe = void 0;
|
|
3132
|
+
if (diagnostics && callback) try {
|
|
3133
|
+
callback({
|
|
3134
|
+
...diagnostics,
|
|
3135
|
+
waiterOrdinal,
|
|
3136
|
+
disposition,
|
|
3137
|
+
overloadAttemptOrdinal,
|
|
3138
|
+
waiterAttachedAtMs,
|
|
3139
|
+
waiterSettledAtMs: performance.now(),
|
|
3140
|
+
waiterOutcome
|
|
3141
|
+
});
|
|
3142
|
+
} catch {}
|
|
3143
|
+
return true;
|
|
3144
|
+
};
|
|
3145
|
+
const waiter = {
|
|
3146
|
+
resolve: (value) => {
|
|
3147
|
+
if (!detach("resolved")) return;
|
|
3148
|
+
resolve(value);
|
|
3149
|
+
},
|
|
3150
|
+
reject: (error, outcome) => {
|
|
3151
|
+
if (detach(outcome)) reject(error);
|
|
3152
|
+
},
|
|
3153
|
+
cleanup,
|
|
3154
|
+
signal,
|
|
3155
|
+
...params.retainWritten ? {
|
|
3156
|
+
deadline,
|
|
3157
|
+
assertCurrent
|
|
3158
|
+
} : {}
|
|
3159
|
+
};
|
|
3160
|
+
waiters.add(waiter);
|
|
3161
|
+
if (params.retainWritten && deadline !== void 0 && performance.now() >= deadline) {
|
|
3162
|
+
waiter.reject(params.cancellationError("timed out", mayHaveWritten), "timed-out");
|
|
3163
|
+
return;
|
|
3164
|
+
}
|
|
3165
|
+
if (timeoutMs && Number.isFinite(timeoutMs) && timeoutMs > 0) {
|
|
3166
|
+
const remaining = params.retainWritten && deadline !== void 0 ? deadline - performance.now() : timeoutMs;
|
|
3167
|
+
timer = setTimeout(() => waiter.reject(params.cancellationError("timed out", mayHaveWritten), "timed-out"), Math.max(params.retainWritten ? 1 : 100, remaining));
|
|
3168
|
+
timer.unref?.();
|
|
3169
|
+
}
|
|
3170
|
+
if (signal) {
|
|
3171
|
+
const abort = () => waiter.reject(params.cancellationError("aborted", mayHaveWritten, signal.reason), "aborted");
|
|
3172
|
+
signal.addEventListener("abort", abort, { once: true });
|
|
3173
|
+
removeAbort = () => signal.removeEventListener("abort", abort);
|
|
3174
|
+
if (signal.aborted) abort();
|
|
3175
|
+
}
|
|
3176
|
+
});
|
|
3177
|
+
},
|
|
3178
|
+
resolve(value) {
|
|
3179
|
+
if (!finish("native-ok")) return;
|
|
3180
|
+
params.onResponse?.(mayHaveWritten);
|
|
3181
|
+
for (const waiter of waiters) {
|
|
3182
|
+
const error = currentWaiterError(waiter);
|
|
3183
|
+
if (error) waiter.reject(error.error, error.outcome);
|
|
3184
|
+
else waiter.resolve(value);
|
|
3185
|
+
}
|
|
3186
|
+
},
|
|
3187
|
+
reject(error, definitelyNotEnqueued = false) {
|
|
3188
|
+
if (finish(definitelyNotEnqueued ? "ingress-rejected" : "native-error")) {
|
|
3189
|
+
if (definitelyNotEnqueued) mayHaveWritten = false;
|
|
3190
|
+
params.onResponse?.(mayHaveWritten);
|
|
3191
|
+
for (const waiter of waiters) {
|
|
3192
|
+
const current = currentWaiterError(waiter);
|
|
3193
|
+
waiter.reject(current?.error ?? params.localError(error, mayHaveWritten), current?.outcome ?? "native-error");
|
|
3194
|
+
}
|
|
3195
|
+
}
|
|
3196
|
+
},
|
|
3197
|
+
close(error) {
|
|
3198
|
+
if (finish("correlation-closed")) rejectWaiters(params.localError(error, mayHaveWritten), "client-closed");
|
|
3199
|
+
},
|
|
3200
|
+
failLocal(error) {
|
|
3201
|
+
if (!pending) return;
|
|
3202
|
+
if (!params.retainWritten || !mayHaveWritten) finish(mayHaveWritten ? "correlation-closed" : "not-written");
|
|
3203
|
+
rejectWaiters(params.localError(error, mayHaveWritten), "local-failed");
|
|
3204
|
+
},
|
|
3205
|
+
markWritten() {
|
|
3206
|
+
mayHaveWritten = true;
|
|
3207
|
+
if (diagnostics && diagnostics.firstPossibleWriteAtMs === null) diagnostics.firstPossibleWriteAtMs = performance.now();
|
|
3208
|
+
},
|
|
3209
|
+
cleanup() {
|
|
3210
|
+
for (const waiter of waiters) waiter.cleanup();
|
|
3211
|
+
}
|
|
3212
|
+
};
|
|
3213
|
+
}
|
|
3214
|
+
//#endregion
|
|
3056
3215
|
//#region extensions/codex/src/app-server/transport-websocket.ts
|
|
3057
3216
|
/**
|
|
3058
3217
|
* Adapts a remote Codex app-server WebSocket endpoint to the shared stdio-like
|
|
@@ -3085,6 +3244,7 @@ function createWebSocketTransport(options) {
|
|
|
3085
3244
|
const stdinDecoder = new StringDecoder("utf8");
|
|
3086
3245
|
let pendingLine = "";
|
|
3087
3246
|
let killed = false;
|
|
3247
|
+
let exitCode = null;
|
|
3088
3248
|
let pingTimeout;
|
|
3089
3249
|
let pongTimeout;
|
|
3090
3250
|
let expectedPong;
|
|
@@ -3160,6 +3320,7 @@ function createWebSocketTransport(options) {
|
|
|
3160
3320
|
socket.once("close", (code, reason) => {
|
|
3161
3321
|
clearConnectionHealthTimers();
|
|
3162
3322
|
killed = true;
|
|
3323
|
+
exitCode = code;
|
|
3163
3324
|
events.emit("exit", code, reason.toString("utf8"));
|
|
3164
3325
|
});
|
|
3165
3326
|
socket.on("message", (data) => {
|
|
@@ -3196,12 +3357,17 @@ function createWebSocketTransport(options) {
|
|
|
3196
3357
|
get killed() {
|
|
3197
3358
|
return killed;
|
|
3198
3359
|
},
|
|
3199
|
-
|
|
3360
|
+
get exitCode() {
|
|
3361
|
+
return exitCode;
|
|
3362
|
+
},
|
|
3363
|
+
kill: (signal) => {
|
|
3200
3364
|
killed = true;
|
|
3201
3365
|
clearConnectionHealthTimers();
|
|
3202
|
-
socket.
|
|
3366
|
+
if (signal === "SIGKILL") socket.terminate();
|
|
3367
|
+
else socket.close();
|
|
3203
3368
|
},
|
|
3204
|
-
once: (event, listener) => events.once(event, listener)
|
|
3369
|
+
once: (event, listener) => events.once(event, listener),
|
|
3370
|
+
off: (event, listener) => events.off(event, listener)
|
|
3205
3371
|
};
|
|
3206
3372
|
}
|
|
3207
3373
|
/** Opens the owner-scoped Codex control socket used by the WebSocket upgrade. */
|
|
@@ -3248,7 +3414,6 @@ const CODEX_APP_SERVER_PARSE_LOG_MAX = 500;
|
|
|
3248
3414
|
const CODEX_APP_SERVER_PARSE_BUFFER_MAX = 8388608;
|
|
3249
3415
|
const CODEX_APP_SERVER_PARSE_BUFFER_MAX_LINES = 1e3;
|
|
3250
3416
|
const CODEX_APP_SERVER_STDERR_TAIL_MAX = 2e3;
|
|
3251
|
-
const CODEX_APP_SERVER_OVERLOADED_ERROR_CODE = -32001;
|
|
3252
3417
|
const CODEX_APP_SERVER_OVERLOAD_MAX_RETRIES = 3;
|
|
3253
3418
|
const CODEX_APP_SERVER_OVERLOAD_RETRY_BASE_MS = 50;
|
|
3254
3419
|
const CODEX_APP_SERVER_PENDING_STARTUP_WARNINGS_MAX = 32;
|
|
@@ -3267,11 +3432,12 @@ function resolveCodexAppServerClientInstanceId(client) {
|
|
|
3267
3432
|
}
|
|
3268
3433
|
/** Codex rejects this exact code before enqueueing, including mutating requests. */
|
|
3269
3434
|
function isCodexAppServerOverloadError(error) {
|
|
3270
|
-
return error instanceof CodexAppServerRpcError && error.code ===
|
|
3435
|
+
return error instanceof CodexAppServerRpcError && error.code === -32001;
|
|
3271
3436
|
}
|
|
3272
3437
|
var CodexAppServerLocalRequestCancellationError = class extends Error {
|
|
3273
|
-
constructor(method, reason, mayHaveWritten) {
|
|
3274
|
-
|
|
3438
|
+
constructor(method, reason, mayHaveWritten, cause) {
|
|
3439
|
+
const detail = cause instanceof Error || typeof cause === "string" ? coerceErrorMessage(cause) : void 0;
|
|
3440
|
+
super(`${method} ${reason}${detail ? `: ${detail}` : ""}`, { cause });
|
|
3275
3441
|
this.reason = reason;
|
|
3276
3442
|
this.mayHaveWritten = mayHaveWritten;
|
|
3277
3443
|
this.code = "CODEX_APP_SERVER_LOCAL_REQUEST_CANCELLED";
|
|
@@ -3322,6 +3488,7 @@ var CodexAppServerClient = class CodexAppServerClient {
|
|
|
3322
3488
|
constructor(child) {
|
|
3323
3489
|
this.instanceId = randomUUID();
|
|
3324
3490
|
this.pending = /* @__PURE__ */ new Map();
|
|
3491
|
+
this.catalogResponses = /* @__PURE__ */ new WeakMap();
|
|
3325
3492
|
this.requestHandlers = /* @__PURE__ */ new Set();
|
|
3326
3493
|
this.notificationHandlers = /* @__PURE__ */ new Set();
|
|
3327
3494
|
this.pendingStartupWarnings = [];
|
|
@@ -3333,13 +3500,16 @@ var CodexAppServerClient = class CodexAppServerClient {
|
|
|
3333
3500
|
this.transportExited = false;
|
|
3334
3501
|
this.nativeExecutionObserved = false;
|
|
3335
3502
|
this.stderrTail = "";
|
|
3503
|
+
this.privateTransportSecrets = /* @__PURE__ */ new Set();
|
|
3504
|
+
this.privateStderrPending = "";
|
|
3336
3505
|
this.child = child;
|
|
3337
3506
|
this.lines = createInterface({ input: child.stdout });
|
|
3338
3507
|
this.lines.on("line", (line) => this.handleLine(line));
|
|
3339
3508
|
this.lines.on("error", (error) => this.closeWithError(toStringifiedError(error)));
|
|
3340
3509
|
child.stdout.on("error", (error) => this.closeWithError(toStringifiedError(error)));
|
|
3341
3510
|
child.stderr.setEncoding("utf8");
|
|
3342
|
-
child.stderr.on("data", (
|
|
3511
|
+
child.stderr.on("data", (chunk) => {
|
|
3512
|
+
const text = this.redactPrivateStderr(chunk);
|
|
3343
3513
|
this.stderrTail = appendBoundedTail(this.stderrTail, text, CODEX_APP_SERVER_STDERR_TAIL_MAX);
|
|
3344
3514
|
const trimmed = text.trim();
|
|
3345
3515
|
if (trimmed) embeddedAgentLog.debug(`codex app-server stderr: ${trimmed}`);
|
|
@@ -3428,9 +3598,10 @@ var CodexAppServerClient = class CodexAppServerClient {
|
|
|
3428
3598
|
getModelCatalogRevision() {
|
|
3429
3599
|
return this.modelCatalogRevision;
|
|
3430
3600
|
}
|
|
3431
|
-
/** Installs the spawn-owner
|
|
3432
|
-
setThreadSessionRequestGuard(guard) {
|
|
3601
|
+
/** Installs the spawn-owner guard and retirement for config-loading thread requests. */
|
|
3602
|
+
setThreadSessionRequestGuard(guard, retireAfterIndeterminateRequest) {
|
|
3433
3603
|
this.threadSessionRequestGuard = guard;
|
|
3604
|
+
this.retireAfterIndeterminateThreadRequest = retireAfterIndeterminateRequest;
|
|
3434
3605
|
}
|
|
3435
3606
|
/** Returns the local transport PID for scoped child-process cleanup, when available. */
|
|
3436
3607
|
getTransportPid() {
|
|
@@ -3439,12 +3610,13 @@ var CodexAppServerClient = class CodexAppServerClient {
|
|
|
3439
3610
|
request(method, params, optionsInput) {
|
|
3440
3611
|
const options = optionsInput ?? {};
|
|
3441
3612
|
if (this.closed) return Promise.reject(this.closeError ?? /* @__PURE__ */ new Error("codex app-server client is closed"));
|
|
3442
|
-
if (options.signal?.aborted) return Promise.reject(new CodexAppServerLocalRequestCancellationError(method, "aborted", false));
|
|
3613
|
+
if (options.signal?.aborted) return Promise.reject(new CodexAppServerLocalRequestCancellationError(method, "aborted", false, options.signal?.reason));
|
|
3443
3614
|
const guard = method === "thread/start" || method === "thread/resume" || method === "thread/fork" ? this.threadSessionRequestGuard : void 0;
|
|
3444
3615
|
if (guard) {
|
|
3616
|
+
const retire = this.retireAfterIndeterminateThreadRequest;
|
|
3445
3617
|
if (!options.signal && !(options.timeoutMs !== void 0 && Number.isFinite(options.timeoutMs) && options.timeoutMs > 0)) return Promise.reject(/* @__PURE__ */ new TypeError(`${method} requires a positive finite timeout or abort signal`));
|
|
3446
3618
|
return (async () => {
|
|
3447
|
-
const guardStartedAt =
|
|
3619
|
+
const guardStartedAt = performance.now();
|
|
3448
3620
|
const timeoutMessage = `${method} timed out`;
|
|
3449
3621
|
const abortMessage = `${method} aborted`;
|
|
3450
3622
|
let releaseGuard;
|
|
@@ -3457,19 +3629,22 @@ var CodexAppServerClient = class CodexAppServerClient {
|
|
|
3457
3629
|
});
|
|
3458
3630
|
} catch (error) {
|
|
3459
3631
|
if (error instanceof Error && error.message === timeoutMessage) throw new CodexAppServerLocalRequestCancellationError(method, "timed out", false);
|
|
3460
|
-
if (error instanceof Error && error.message === abortMessage) throw new CodexAppServerLocalRequestCancellationError(method, "aborted", false);
|
|
3632
|
+
if (error instanceof Error && error.message === abortMessage) throw new CodexAppServerLocalRequestCancellationError(method, "aborted", false, options.signal?.reason);
|
|
3461
3633
|
throw error;
|
|
3462
3634
|
}
|
|
3463
3635
|
let released = false;
|
|
3636
|
+
let removeExitHandler;
|
|
3464
3637
|
const release = () => {
|
|
3465
3638
|
if (released) return;
|
|
3466
3639
|
released = true;
|
|
3640
|
+
removeExitHandler?.();
|
|
3467
3641
|
releaseGuard();
|
|
3468
3642
|
};
|
|
3469
3643
|
let releaseWhenRequestSettles = true;
|
|
3470
3644
|
let requestMayHaveWritten = false;
|
|
3645
|
+
let nativeResponded = false;
|
|
3471
3646
|
try {
|
|
3472
|
-
const elapsedMs =
|
|
3647
|
+
const elapsedMs = performance.now() - guardStartedAt;
|
|
3473
3648
|
const remainingTimeoutMs = options.timeoutMs === void 0 ? void 0 : options.timeoutMs - elapsedMs;
|
|
3474
3649
|
if (remainingTimeoutMs !== void 0 && remainingTimeoutMs <= 0) throw new CodexAppServerLocalRequestCancellationError(method, "timed out", false);
|
|
3475
3650
|
return await this.requestWithOverloadRetry(method, params, {
|
|
@@ -3477,11 +3652,17 @@ var CodexAppServerClient = class CodexAppServerClient {
|
|
|
3477
3652
|
...remainingTimeoutMs !== void 0 ? { timeoutMs: remainingTimeoutMs } : {}
|
|
3478
3653
|
}, (mayHaveWritten) => {
|
|
3479
3654
|
requestMayHaveWritten = mayHaveWritten;
|
|
3655
|
+
nativeResponded = !mayHaveWritten;
|
|
3656
|
+
}, () => {
|
|
3657
|
+
nativeResponded = true;
|
|
3658
|
+
if (!releaseWhenRequestSettles) release();
|
|
3480
3659
|
});
|
|
3481
3660
|
} catch (error) {
|
|
3482
3661
|
if (requestMayHaveWritten && !(error instanceof CodexAppServerRpcError)) {
|
|
3483
3662
|
releaseWhenRequestSettles = false;
|
|
3484
|
-
|
|
3663
|
+
if (nativeResponded) release();
|
|
3664
|
+
else removeExitHandler = this.addTransportExitHandler(release);
|
|
3665
|
+
if (!retire?.()) await this.closeAndRunAfterExit(release, method);
|
|
3485
3666
|
}
|
|
3486
3667
|
throw error;
|
|
3487
3668
|
} finally {
|
|
@@ -3491,17 +3672,17 @@ var CodexAppServerClient = class CodexAppServerClient {
|
|
|
3491
3672
|
}
|
|
3492
3673
|
return this.requestWithOverloadRetry(method, params, options);
|
|
3493
3674
|
}
|
|
3494
|
-
async requestWithOverloadRetry(method, params, options, onWriteStateChange) {
|
|
3495
|
-
const deadline = options.timeoutMs !== void 0 && Number.isFinite(options.timeoutMs) ?
|
|
3675
|
+
async requestWithOverloadRetry(method, params, options, onWriteStateChange, onResponse) {
|
|
3676
|
+
const deadline = options.timeoutMs !== void 0 && Number.isFinite(options.timeoutMs) ? performance.now() + options.timeoutMs : void 0;
|
|
3496
3677
|
for (let retry = 0;; retry += 1) {
|
|
3497
|
-
if (options.signal?.aborted) throw new CodexAppServerLocalRequestCancellationError(method, "aborted", false);
|
|
3498
|
-
const remainingTimeoutMs = deadline === void 0 ? void 0 : deadline -
|
|
3678
|
+
if (options.signal?.aborted) throw new CodexAppServerLocalRequestCancellationError(method, "aborted", false, options.signal?.reason);
|
|
3679
|
+
const remainingTimeoutMs = deadline === void 0 ? void 0 : deadline - performance.now();
|
|
3499
3680
|
if (remainingTimeoutMs !== void 0 && remainingTimeoutMs <= 0) throw new CodexAppServerLocalRequestCancellationError(method, "timed out", false);
|
|
3500
3681
|
try {
|
|
3501
3682
|
return await this.requestOnce(method, params, {
|
|
3502
3683
|
...options,
|
|
3503
3684
|
...remainingTimeoutMs !== void 0 ? { timeoutMs: remainingTimeoutMs } : {}
|
|
3504
|
-
}, onWriteStateChange);
|
|
3685
|
+
}, retry + 1, onWriteStateChange, deadline, onResponse);
|
|
3505
3686
|
} catch (error) {
|
|
3506
3687
|
if (!isCodexAppServerOverloadError(error) || retry >= CODEX_APP_SERVER_OVERLOAD_MAX_RETRIES) throw error;
|
|
3507
3688
|
onWriteStateChange?.(false);
|
|
@@ -3511,8 +3692,8 @@ var CodexAppServerClient = class CodexAppServerClient {
|
|
|
3511
3692
|
}
|
|
3512
3693
|
}
|
|
3513
3694
|
async waitForOverloadRetry(method, backoffMs, deadline, signal) {
|
|
3514
|
-
if (signal?.aborted) throw new CodexAppServerLocalRequestCancellationError(method, "aborted", false);
|
|
3515
|
-
const remainingMs = deadline === void 0 ? void 0 : deadline -
|
|
3695
|
+
if (signal?.aborted) throw new CodexAppServerLocalRequestCancellationError(method, "aborted", false, signal?.reason);
|
|
3696
|
+
const remainingMs = deadline === void 0 ? void 0 : deadline - performance.now();
|
|
3516
3697
|
if (remainingMs !== void 0 && remainingMs <= 0) throw new CodexAppServerLocalRequestCancellationError(method, "timed out", false);
|
|
3517
3698
|
const delayMs = remainingMs === void 0 ? backoffMs : Math.min(backoffMs, remainingMs);
|
|
3518
3699
|
await new Promise((resolve, reject) => {
|
|
@@ -3523,7 +3704,7 @@ var CodexAppServerClient = class CodexAppServerClient {
|
|
|
3523
3704
|
timer.unref?.();
|
|
3524
3705
|
const abortListener = () => {
|
|
3525
3706
|
cleanup();
|
|
3526
|
-
reject(new CodexAppServerLocalRequestCancellationError(method, "aborted", false));
|
|
3707
|
+
reject(new CodexAppServerLocalRequestCancellationError(method, "aborted", false, signal?.reason));
|
|
3527
3708
|
};
|
|
3528
3709
|
const cleanup = () => {
|
|
3529
3710
|
clearTimeout(timer);
|
|
@@ -3533,9 +3714,9 @@ var CodexAppServerClient = class CodexAppServerClient {
|
|
|
3533
3714
|
if (signal?.aborted) abortListener();
|
|
3534
3715
|
});
|
|
3535
3716
|
}
|
|
3536
|
-
requestOnce(method, params, options, onWriteStateChange) {
|
|
3717
|
+
requestOnce(method, params, options, overloadAttemptOrdinal, onWriteStateChange, deadline, onResponse) {
|
|
3537
3718
|
if (this.closed) return Promise.reject(this.closeError ?? /* @__PURE__ */ new Error("codex app-server client is closed"));
|
|
3538
|
-
if (options.signal?.aborted) return Promise.reject(new CodexAppServerLocalRequestCancellationError(method, "aborted", false));
|
|
3719
|
+
if (options.signal?.aborted) return Promise.reject(new CodexAppServerLocalRequestCancellationError(method, "aborted", false, options.signal?.reason));
|
|
3539
3720
|
const id = this.nextId++;
|
|
3540
3721
|
if (method === "account/login/start" || method === "account/logout" || method === "config/value/write" || method === "config/batchWrite") this.modelCatalogRevision += 1;
|
|
3541
3722
|
const message = {
|
|
@@ -3543,59 +3724,45 @@ var CodexAppServerClient = class CodexAppServerClient {
|
|
|
3543
3724
|
method,
|
|
3544
3725
|
params
|
|
3545
3726
|
};
|
|
3546
|
-
|
|
3547
|
-
|
|
3548
|
-
|
|
3549
|
-
|
|
3550
|
-
|
|
3551
|
-
|
|
3552
|
-
|
|
3553
|
-
|
|
3554
|
-
|
|
3555
|
-
|
|
3556
|
-
|
|
3557
|
-
|
|
3558
|
-
|
|
3559
|
-
|
|
3560
|
-
|
|
3561
|
-
|
|
3562
|
-
|
|
3563
|
-
|
|
3564
|
-
|
|
3565
|
-
|
|
3566
|
-
|
|
3567
|
-
}
|
|
3568
|
-
if (options.signal) {
|
|
3569
|
-
const abortListener = () => rejectPending(new CodexAppServerLocalRequestCancellationError(method, "aborted", mayHaveWritten));
|
|
3570
|
-
options.signal.addEventListener("abort", abortListener, { once: true });
|
|
3571
|
-
cleanupAbort = () => options.signal?.removeEventListener("abort", abortListener);
|
|
3572
|
-
}
|
|
3573
|
-
this.pending.set(id, {
|
|
3574
|
-
method,
|
|
3575
|
-
resolve: (value) => {
|
|
3576
|
-
cleanup();
|
|
3577
|
-
resolve(value);
|
|
3578
|
-
},
|
|
3579
|
-
reject: (error) => {
|
|
3580
|
-
cleanup();
|
|
3581
|
-
reject(mayHaveWritten && !(error instanceof CodexAppServerRpcError) && !isCodexAppServerIndeterminateRequestCancellationError(error) && !isCodexAppServerIndeterminateTransportError(error) ? new CodexAppServerIndeterminateTransportError(method, error) : error);
|
|
3582
|
-
},
|
|
3583
|
-
cleanup
|
|
3584
|
-
});
|
|
3585
|
-
if (options.signal?.aborted) {
|
|
3586
|
-
rejectPending(new CodexAppServerLocalRequestCancellationError(method, "aborted", false));
|
|
3587
|
-
return;
|
|
3588
|
-
}
|
|
3589
|
-
try {
|
|
3590
|
-
options.assertCurrent?.();
|
|
3591
|
-
this.writeMessage(message, (error) => rejectPending(error), () => {
|
|
3592
|
-
mayHaveWritten = true;
|
|
3593
|
-
onWriteStateChange?.(true);
|
|
3594
|
-
});
|
|
3595
|
-
} catch (error) {
|
|
3596
|
-
rejectPending(toStringifiedError(error));
|
|
3597
|
-
}
|
|
3727
|
+
const attempt = createCodexRequestAttempt({
|
|
3728
|
+
method,
|
|
3729
|
+
retainWritten: onResponse !== void 0,
|
|
3730
|
+
...method === "thread/list" ? { diagnosticIdentity: {
|
|
3731
|
+
clientInstanceId: this.instanceId,
|
|
3732
|
+
rpcId: id
|
|
3733
|
+
} } : {},
|
|
3734
|
+
onResponse: onResponse ? (mayHaveWritten) => {
|
|
3735
|
+
onWriteStateChange?.(mayHaveWritten);
|
|
3736
|
+
onResponse();
|
|
3737
|
+
} : void 0,
|
|
3738
|
+
onSettled: () => {
|
|
3739
|
+
if (this.pending.get(id) === attempt) this.pending.delete(id);
|
|
3740
|
+
},
|
|
3741
|
+
cancellationError: (reason, written, cause) => new CodexAppServerLocalRequestCancellationError(method, reason, written, cause),
|
|
3742
|
+
localError: (error, written) => written && !(error instanceof CodexAppServerRpcError) && !isCodexAppServerIndeterminateRequestCancellationError(error) && !isCodexAppServerIndeterminateTransportError(error) ? new CodexAppServerIndeterminateTransportError(method, error) : error
|
|
3743
|
+
});
|
|
3744
|
+
this.pending.set(id, attempt);
|
|
3745
|
+
if (options.catalogPreview && method === "thread/list") this.catalogResponses.set(attempt, {
|
|
3746
|
+
preview: options.catalogPreviewCache,
|
|
3747
|
+
remainingRows: options.catalogRows
|
|
3598
3748
|
});
|
|
3749
|
+
const result = attempt.wait({
|
|
3750
|
+
...options,
|
|
3751
|
+
assertCurrent: void 0,
|
|
3752
|
+
disposition: "new",
|
|
3753
|
+
overloadAttemptOrdinal
|
|
3754
|
+
}, deadline);
|
|
3755
|
+
if (!attempt.pending) return result;
|
|
3756
|
+
try {
|
|
3757
|
+
options.assertCurrent?.();
|
|
3758
|
+
if (attempt.pending) this.writeMessage(message, (error) => attempt.failLocal(error), () => {
|
|
3759
|
+
attempt.markWritten();
|
|
3760
|
+
onWriteStateChange?.(true);
|
|
3761
|
+
});
|
|
3762
|
+
} catch (error) {
|
|
3763
|
+
attempt.failLocal(toStringifiedError(error));
|
|
3764
|
+
}
|
|
3765
|
+
return result;
|
|
3599
3766
|
}
|
|
3600
3767
|
/** Sends a fire-and-forget JSON-RPC notification to the app-server. */
|
|
3601
3768
|
notify(method, params) {
|
|
@@ -3685,6 +3852,25 @@ var CodexAppServerClient = class CodexAppServerClient {
|
|
|
3685
3852
|
}
|
|
3686
3853
|
});
|
|
3687
3854
|
}
|
|
3855
|
+
/** Protect private loopback route capabilities before native diagnostics can mention them. */
|
|
3856
|
+
protectPrivateTransportSecret(secret) {
|
|
3857
|
+
if (!/^[A-Za-z0-9_-]{43}$/.test(secret) || this.privateTransportSecrets.size >= 8) {
|
|
3858
|
+
if (!this.privateTransportSecrets.has(secret)) throw new Error("Invalid private Codex transport capability");
|
|
3859
|
+
}
|
|
3860
|
+
this.privateTransportSecrets.add(secret);
|
|
3861
|
+
}
|
|
3862
|
+
redactPrivateText(text) {
|
|
3863
|
+
let redacted = text;
|
|
3864
|
+
for (const secret of this.privateTransportSecrets) redacted = redacted.replaceAll(secret, "[REDACTED]");
|
|
3865
|
+
return redacted;
|
|
3866
|
+
}
|
|
3867
|
+
redactPrivateStderr(chunk) {
|
|
3868
|
+
const text = this.redactPrivateText(this.privateStderrPending + chunk);
|
|
3869
|
+
let held = 0;
|
|
3870
|
+
for (const secret of this.privateTransportSecrets) for (let length = 1; length < secret.length; length++) if (text.endsWith(secret.slice(0, length))) held = Math.max(held, length);
|
|
3871
|
+
this.privateStderrPending = held ? text.slice(-held) : "";
|
|
3872
|
+
return held ? text.slice(0, -held) : text;
|
|
3873
|
+
}
|
|
3688
3874
|
handleLine(line) {
|
|
3689
3875
|
const rawLine = line.endsWith("\r") ? line.slice(0, -1) : line;
|
|
3690
3876
|
if (this.pendingParse) {
|
|
@@ -3756,15 +3942,7 @@ var CodexAppServerClient = class CodexAppServerClient {
|
|
|
3756
3942
|
});
|
|
3757
3943
|
}
|
|
3758
3944
|
handleResponse(response) {
|
|
3759
|
-
|
|
3760
|
-
if (!pending) return;
|
|
3761
|
-
this.pending.delete(response.id);
|
|
3762
|
-
if (response.error) {
|
|
3763
|
-
pending.reject(new CodexAppServerRpcError(response.error, pending.method));
|
|
3764
|
-
return;
|
|
3765
|
-
}
|
|
3766
|
-
if (pending.method === "thread/backgroundTerminals/list" && isJsonObject(response.result) && Array.isArray(response.result.data) && response.result.data.length > 0) this.nativeExecutionObserved = true;
|
|
3767
|
-
pending.resolve(response.result);
|
|
3945
|
+
this.nativeExecutionObserved = dispatchCodexAppServerResponse(response, this.pending, this.catalogResponses, codexCatalogSourceForClient(this)) || this.nativeExecutionObserved;
|
|
3768
3946
|
}
|
|
3769
3947
|
async handleServerRequest(request) {
|
|
3770
3948
|
try {
|
|
@@ -3799,30 +3977,42 @@ var CodexAppServerClient = class CodexAppServerClient {
|
|
|
3799
3977
|
async runServerRequestHandlers(request) {
|
|
3800
3978
|
const controller = new AbortController();
|
|
3801
3979
|
if (request.method !== "item/tool/call") return await this.runServerRequestHandlersWithoutTimeout(request, controller.signal);
|
|
3802
|
-
|
|
3803
|
-
const
|
|
3980
|
+
let timeoutMs = resolveDynamicToolServerRequestTimeoutMs(readCodexDynamicToolCallParams(request.params));
|
|
3981
|
+
const deadline = createDeferred();
|
|
3804
3982
|
let timeout;
|
|
3983
|
+
let settled = false;
|
|
3984
|
+
let executionTimeoutResolved = false;
|
|
3985
|
+
const armTimeout = () => {
|
|
3986
|
+
clearTimeout(timeout);
|
|
3987
|
+
timeout = setTimeout(() => {
|
|
3988
|
+
embeddedAgentLog.warn("codex app-server server request timed out", {
|
|
3989
|
+
id: request.id,
|
|
3990
|
+
method: request.method,
|
|
3991
|
+
timeoutMs
|
|
3992
|
+
});
|
|
3993
|
+
controller.abort(/* @__PURE__ */ new Error("codex app-server server request timed out"));
|
|
3994
|
+
deadline.resolve(timeoutServerRequestResponse(timeoutMs));
|
|
3995
|
+
}, timeoutMs);
|
|
3996
|
+
timeout.unref?.();
|
|
3997
|
+
};
|
|
3998
|
+
const setExecutionTimeoutMs = (executionTimeoutMs) => {
|
|
3999
|
+
if (settled || controller.signal.aborted || executionTimeoutResolved || !Number.isFinite(executionTimeoutMs) || executionTimeoutMs <= 0) return;
|
|
4000
|
+
executionTimeoutResolved = true;
|
|
4001
|
+
timeoutMs = addSafeTimeoutDelayGraceMs(executionTimeoutMs, 3e4);
|
|
4002
|
+
armTimeout();
|
|
4003
|
+
};
|
|
4004
|
+
armTimeout();
|
|
3805
4005
|
try {
|
|
3806
|
-
return await Promise.race([this.runServerRequestHandlersWithoutTimeout(request, controller.signal),
|
|
3807
|
-
timeout = setTimeout(() => {
|
|
3808
|
-
embeddedAgentLog.warn("codex app-server server request timed out", {
|
|
3809
|
-
id: request.id,
|
|
3810
|
-
method: request.method,
|
|
3811
|
-
timeoutMs
|
|
3812
|
-
});
|
|
3813
|
-
controller.abort(/* @__PURE__ */ new Error("codex app-server server request timed out"));
|
|
3814
|
-
resolve(timeoutResponse);
|
|
3815
|
-
}, timeoutMs);
|
|
3816
|
-
timeout.unref?.();
|
|
3817
|
-
})]);
|
|
4006
|
+
return await Promise.race([this.runServerRequestHandlersWithoutTimeout(request, controller.signal, setExecutionTimeoutMs), deadline.promise]);
|
|
3818
4007
|
} finally {
|
|
3819
|
-
|
|
4008
|
+
settled = true;
|
|
4009
|
+
clearTimeout(timeout);
|
|
3820
4010
|
}
|
|
3821
4011
|
}
|
|
3822
|
-
async runServerRequestHandlersWithoutTimeout(request, signal) {
|
|
4012
|
+
async runServerRequestHandlersWithoutTimeout(request, signal, setExecutionTimeoutMs) {
|
|
3823
4013
|
for (const handler of this.requestHandlers) {
|
|
3824
4014
|
if (signal.aborted) return;
|
|
3825
|
-
const result = await handler(request, signal);
|
|
4015
|
+
const result = await handler(request, signal, setExecutionTimeoutMs);
|
|
3826
4016
|
if (result !== void 0) return result;
|
|
3827
4017
|
}
|
|
3828
4018
|
}
|
|
@@ -3849,6 +4039,7 @@ var CodexAppServerClient = class CodexAppServerClient {
|
|
|
3849
4039
|
markClosed(error) {
|
|
3850
4040
|
if (this.closed) return false;
|
|
3851
4041
|
this.closed = true;
|
|
4042
|
+
closeCodexCatalogClientSource(this);
|
|
3852
4043
|
this.closeError = error;
|
|
3853
4044
|
this.lines.close();
|
|
3854
4045
|
this.rejectPendingRequests(error);
|
|
@@ -3857,7 +4048,7 @@ var CodexAppServerClient = class CodexAppServerClient {
|
|
|
3857
4048
|
rejectPendingRequests(error) {
|
|
3858
4049
|
for (const pending of this.pending.values()) {
|
|
3859
4050
|
pending.cleanup();
|
|
3860
|
-
pending.
|
|
4051
|
+
pending.close(error);
|
|
3861
4052
|
}
|
|
3862
4053
|
this.pending.clear();
|
|
3863
4054
|
for (const handler of this.closeHandlers) try {
|
|
@@ -3910,7 +4101,7 @@ function assertSupportedCodexAppServerVersion(response) {
|
|
|
3910
4101
|
if (!detectedVersion) throw new CodexAppServerVersionError(detectedVersion);
|
|
3911
4102
|
const detected = parse(detectedVersion);
|
|
3912
4103
|
if (!detected || detected.compare("0.149.0") < 0) throw new CodexAppServerVersionError(detectedVersion);
|
|
3913
|
-
if (detected.compare("0.
|
|
4104
|
+
if (detected.compare("0.154.0") > 0) embeddedAgentLog.warn("codex app-server is newer than OpenClaw's managed runtime; continuing with normal startup validation", {
|
|
3914
4105
|
detectedVersion,
|
|
3915
4106
|
validatedVersion: CODEX_APP_SERVER_VERSION
|
|
3916
4107
|
});
|