@openclaw/codex 2026.9.4 → 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-CvT8tW5i.js → .setup/apply-CJ0ZfmBG.mjs} +11 -11
- package/dist/.setup/async-questions-DdhOCwGi.mjs +27 -0
- package/dist/{attempt-client-cleanup-DKHzbwt5.js → .setup/attempt-client-cleanup-BpYKdTA0.mjs} +29 -14
- package/dist/{attempt-context-D44yeDII.js → .setup/attempt-context-VXVwTCfS.mjs} +5 -5
- package/dist/.setup/attempt-terminal-gZrxQ35N.mjs +5 -0
- package/dist/{auth-binding-CWlKVccJ.js → .setup/auth-binding-DhLWa_7K.mjs} +1 -1
- package/dist/{auth-cache-key-7orQae_j.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-C_Hneydj.js → .setup/bounded-turn-BtlZcivC.mjs} +16 -11
- package/dist/{build-state-BCmg9-5p.js → .setup/build-state-Xx9ybZqa.mjs} +1 -1
- package/dist/{capabilities-8vx68WLH.js → .setup/capabilities-_vXcZGSx.mjs} +1 -1
- package/dist/{client-B57KWPQx.js → .setup/client-vXs2929Q.mjs} +332 -163
- package/dist/{command-dispatch-BpduNGVf.js → .setup/command-dispatch-naHIZwwF.mjs} +3 -3
- package/dist/{command-formatters-lxlkNZgU.js → .setup/command-formatters-CGEkdawF.mjs} +2 -2
- package/dist/{command-handlers-tiL9iWj7.js → .setup/command-handlers-BtAJEW1X.mjs} +59 -42
- package/dist/{command-rpc-CR5EOEZX.js → .setup/command-rpc-DHFpn4le.mjs} +22 -13
- package/dist/{compact-B_H3AOd7.js → .setup/compact-C3i3qlzj.mjs} +28 -43
- package/dist/{config-oIORaQ5T.js → .setup/config-CedDWjM-.mjs} +5 -4
- package/dist/{config-options-CXMq1T-C.js → .setup/config-options-BsanJ8QG.mjs} +6 -418
- package/dist/{protocol-5bh1G-H7.js → .setup/config-parsing-CcB9iPoq.mjs} +9 -51
- package/dist/{config-runtime-D0zGNIHu.js → .setup/config-runtime-CeAhl_h4.mjs} +2 -2
- package/dist/.setup/config-security-BRQ2mgW9.mjs +465 -0
- package/dist/{conversation-binding-DsB4-O7U.js → .setup/conversation-binding-DhzrpTM6.mjs} +23 -21
- package/dist/{conversation-binding-data-BiodpIzq.js → .setup/conversation-binding-data-CrcyZk6O.mjs} +1 -1
- package/dist/{conversation-control-CtUu1b3m.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-CmN5RAip.js → .setup/dynamic-tools-D16lOp67.mjs} +101 -55
- package/dist/{effective-mcp-catalog-Bd73bqA8.js → .setup/effective-mcp-catalog-K6kLCN8X.mjs} +3 -3
- package/dist/{ephemeral-turn-D78_VmzO.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/{event-projector-items-5VhsECCO.js → .setup/event-projector-items-DyTQ_XqL.mjs} +1 -1
- package/dist/{attempt-notifications-C9XufG6l.js → .setup/event-projector-usage-C7Ntzs-f.mjs} +102 -9
- package/dist/{harness-C7rRa7bm.js → .setup/harness-rxaaoN-o.mjs} +74 -20
- package/dist/{inference-context-Dr_mzvk4.js → .setup/inference-context-fulhZuz8.mjs} +1 -1
- package/dist/{inference-proxy-HGXKUIre.js → .setup/inference-proxy-CC15HuSi.mjs} +4 -4
- package/dist/{isolated-completion-DWVb5U2J.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-D22rNEcR.js → .setup/managed-binary-DP6Rib3P.mjs} +2 -2
- package/dist/{managed-thread-store-D1t5jh3G.js → .setup/managed-thread-store-BMqgThVL.mjs} +48 -14
- package/dist/{model-catalog-Dq2n8f_p.js → .setup/model-catalog-DkvUuBey.mjs} +35 -10
- package/dist/{models-PCKOim-h.js → .setup/models-BDFgm_G-.mjs} +3 -3
- package/dist/.setup/native-auth-BLZGqFjw.mjs +57 -0
- package/dist/{native-subagent-history-DjtPloaU.js → .setup/native-subagent-history-YXaL6dMd.mjs} +24 -29
- package/dist/.setup/native-subagent-monitor-B1hxzIOy.mjs +5031 -0
- package/dist/{native-subagent-task-ids-BzTdT0Uw.js → .setup/native-subagent-task-ids-DsuOonKv.mjs} +32 -8
- package/dist/{node-cli-sessions-DKaOmVUh.js → .setup/node-cli-sessions-Cl8b2ZF3.mjs} +1 -1
- package/dist/{node-exec-server.runtime-Cl2vapEi.js → .setup/node-exec-server.runtime-BaViBKNz.mjs} +3 -3
- package/dist/{plan-7uG-Fp36.js → .setup/plan-xD7WKYTM.mjs} +64 -48
- package/dist/{plugin-activation-BYQculil.js → .setup/plugin-activation-r8nq5Jzp.mjs} +3 -3
- package/dist/{plugin-app-cache-key-d0eKxy7b.js → .setup/plugin-app-cache-key-BOxKP7db.mjs} +29 -25
- package/dist/{plugin-approval-roundtrip-Bz3FT8W5.js → .setup/plugin-approval-roundtrip-CjfzafAZ.mjs} +1 -1
- package/dist/{plugin-inventory-oL4Na1ZG.js → .setup/plugin-inventory-DUle8DLz.mjs} +7 -6
- package/dist/{plugin-metadata-cache-ClPJpRio.js → .setup/plugin-metadata-cache-DsS5buNa.mjs} +29 -14
- package/dist/{provider-capabilities-BvCUL69A.js → .setup/provider-capabilities-B8J4Dy-O.mjs} +2 -2
- package/dist/{provider-MQ8PVkuE.js → .setup/provider-fFh_-VR3.mjs} +4 -4
- package/dist/{rate-limits-CBMmWBr9.js → .setup/rate-limits-DOEGYRNs.mjs} +90 -46
- package/dist/{request-B7hEkBGq.js → .setup/request-BioXJLYa.mjs} +113 -33
- package/dist/.setup/run-attempt-lifecycle-B7JbY4-F.mjs +71 -0
- package/dist/{run-attempt-CvsAAGa0.js → .setup/run-attempt-rlA07pUv.mjs} +580 -498
- package/dist/{runtime-artifact-BJ0rXBZ_.js → .setup/runtime-artifact-Dy38Z5iU.mjs} +2 -2
- package/dist/{sandbox-guard-BxgyoM8M.js → .setup/sandbox-guard-BBP-RbTf.mjs} +3 -3
- package/dist/{session-binding-CI8UuilT.js → .setup/session-binding-_0W_fHRr.mjs} +46 -64
- package/dist/{session-binding-record-Bcvslnhf.js → .setup/session-binding-record-TH3xA0zj.mjs} +181 -3
- package/dist/.setup/session-binding-sidecars-CKYEcfNn.mjs +543 -0
- package/dist/{session-catalog-adoption-tcZi1IfX.js → .setup/session-catalog-adoption-CR_whkEW.mjs} +6 -6
- package/dist/{session-catalog-archive-CwKg8Xz2.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/{thread-history-page-D0JIp48V.js → .setup/session-catalog-native-projection-ChV3cCtm.mjs} +206 -95
- package/dist/{session-catalog-node-adoption-B1tgDW-m.js → .setup/session-catalog-node-adoption-BVRsYOSh.mjs} +3 -3
- package/dist/{session-catalog-node-continue-Ci-DXyJP.js → .setup/session-catalog-node-continue-Dowv8osw.mjs} +7 -7
- package/dist/.setup/session-catalog-projection-C1Bj9Jl-.mjs +414 -0
- package/dist/{session-cli-DNN_jhGc.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-DwyijFI6.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-BeK1YOyT.js → .setup/session-history.worker-CpNj7H_P.mjs} +5 -6
- package/dist/{session-initialization-Ct0_Hzmg.js → .setup/session-initialization-DH1z6fXn.mjs} +2 -2
- package/dist/{session-permission-policy-BBmXA8Eg.js → .setup/session-permission-policy-DhurXY0l.mjs} +2 -2
- package/dist/{session-retirement-B2YfbAAT.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-Dn91stmc.js → .setup/settled-turn-finalizer-CiY2bLFK.mjs} +9 -9
- package/dist/{shared-client-CscigXXL.js → .setup/shared-client-BpTtuLQ5.mjs} +286 -145
- package/dist/{side-question-BGMJQf4U.js → .setup/side-question-DSCZyoBD.mjs} +64 -47
- package/dist/{source-CElXU0Oy.js → .setup/source-Bjp4UQij.mjs} +7 -6
- package/dist/{thread-archive-guard-DfpBr-Sz.js → .setup/thread-archive-guard-jmecf6OJ.mjs} +1 -1
- package/dist/.setup/thread-history-page-BTx-4xsg.mjs +83 -0
- package/dist/{thread-lifecycle-DXl1-I6b.js → .setup/thread-lifecycle-Cik28qWn.mjs} +256 -128
- package/dist/{thread-ownership-BsDRTsyp.js → .setup/thread-ownership-skomxnIt.mjs} +4 -4
- package/dist/{thread-policy-BuEQfE0g.js → .setup/thread-policy-Cjs4B8xf.mjs} +2 -2
- package/dist/{thread-resume-DsDOZpFg.js → .setup/thread-resume-BkNpj9Pz.mjs} +8 -5
- package/dist/.setup/timeout-DZF05XrR.mjs +63 -0
- package/dist/{transcript-history-projection-v17wXgdK.js → .setup/transcript-history-projection-DHNBDhCU.mjs} +8 -3
- package/dist/{transcript-mirror-C5CKgNy6.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-BZerMte_.js → .setup/upstream-session-fork-D3UKxgVD.mjs} +27 -26
- package/dist/{usage-tCk-mg_x.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-B7bGbGWq.js → .setup/web-search-provider.runtime-CTGuJt6i.mjs} +3 -3
- package/dist/api.js +6 -6
- 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 +123 -83
- package/dist/media-understanding-provider.js +3 -3
- package/dist/migration-provider-api.js +1 -1
- 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 -69
- package/package.json +11 -8
- package/dist/binding-connection-D3udKbIE.js +0 -60
- package/dist/event-projector-usage-BfXmpOec.js +0 -102
- package/dist/native-subagent-history-owner-Pcp7JuVF.js +0 -34
- package/dist/native-subagent-monitor-fQ7eIXEf.js +0 -2978
- package/dist/rpc-error-ttN_QjEm.js +0 -30
- package/dist/session-catalog-ct-AH01I.js +0 -1477
- package/dist/session-catalog-home-id-CwhLdC03.js +0 -18
- package/dist/session-catalog-provenance-D-dIfRAH.js +0 -96
- package/dist/timeout-BVw8aaM1.js +0 -33
- package/dist/{auth-profile-selection-DFu9e167.js → .setup/auth-profile-selection-DFu9e167.mjs} +0 -0
- package/dist/{config-utils-DujwEnhg.js → .setup/config-utils-DujwEnhg.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/{plugin-marketplace-discovery-P-Vndfqq.js → .setup/plugin-marketplace-discovery-P-Vndfqq.mjs} +0 -0
- /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 { t 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 = [];
|
|
@@ -3431,9 +3598,10 @@ var CodexAppServerClient = class CodexAppServerClient {
|
|
|
3431
3598
|
getModelCatalogRevision() {
|
|
3432
3599
|
return this.modelCatalogRevision;
|
|
3433
3600
|
}
|
|
3434
|
-
/** Installs the spawn-owner
|
|
3435
|
-
setThreadSessionRequestGuard(guard) {
|
|
3601
|
+
/** Installs the spawn-owner guard and retirement for config-loading thread requests. */
|
|
3602
|
+
setThreadSessionRequestGuard(guard, retireAfterIndeterminateRequest) {
|
|
3436
3603
|
this.threadSessionRequestGuard = guard;
|
|
3604
|
+
this.retireAfterIndeterminateThreadRequest = retireAfterIndeterminateRequest;
|
|
3437
3605
|
}
|
|
3438
3606
|
/** Returns the local transport PID for scoped child-process cleanup, when available. */
|
|
3439
3607
|
getTransportPid() {
|
|
@@ -3442,12 +3610,13 @@ var CodexAppServerClient = class CodexAppServerClient {
|
|
|
3442
3610
|
request(method, params, optionsInput) {
|
|
3443
3611
|
const options = optionsInput ?? {};
|
|
3444
3612
|
if (this.closed) return Promise.reject(this.closeError ?? /* @__PURE__ */ new Error("codex app-server client is closed"));
|
|
3445
|
-
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));
|
|
3446
3614
|
const guard = method === "thread/start" || method === "thread/resume" || method === "thread/fork" ? this.threadSessionRequestGuard : void 0;
|
|
3447
3615
|
if (guard) {
|
|
3616
|
+
const retire = this.retireAfterIndeterminateThreadRequest;
|
|
3448
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`));
|
|
3449
3618
|
return (async () => {
|
|
3450
|
-
const guardStartedAt =
|
|
3619
|
+
const guardStartedAt = performance.now();
|
|
3451
3620
|
const timeoutMessage = `${method} timed out`;
|
|
3452
3621
|
const abortMessage = `${method} aborted`;
|
|
3453
3622
|
let releaseGuard;
|
|
@@ -3460,19 +3629,22 @@ var CodexAppServerClient = class CodexAppServerClient {
|
|
|
3460
3629
|
});
|
|
3461
3630
|
} catch (error) {
|
|
3462
3631
|
if (error instanceof Error && error.message === timeoutMessage) throw new CodexAppServerLocalRequestCancellationError(method, "timed out", false);
|
|
3463
|
-
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);
|
|
3464
3633
|
throw error;
|
|
3465
3634
|
}
|
|
3466
3635
|
let released = false;
|
|
3636
|
+
let removeExitHandler;
|
|
3467
3637
|
const release = () => {
|
|
3468
3638
|
if (released) return;
|
|
3469
3639
|
released = true;
|
|
3640
|
+
removeExitHandler?.();
|
|
3470
3641
|
releaseGuard();
|
|
3471
3642
|
};
|
|
3472
3643
|
let releaseWhenRequestSettles = true;
|
|
3473
3644
|
let requestMayHaveWritten = false;
|
|
3645
|
+
let nativeResponded = false;
|
|
3474
3646
|
try {
|
|
3475
|
-
const elapsedMs =
|
|
3647
|
+
const elapsedMs = performance.now() - guardStartedAt;
|
|
3476
3648
|
const remainingTimeoutMs = options.timeoutMs === void 0 ? void 0 : options.timeoutMs - elapsedMs;
|
|
3477
3649
|
if (remainingTimeoutMs !== void 0 && remainingTimeoutMs <= 0) throw new CodexAppServerLocalRequestCancellationError(method, "timed out", false);
|
|
3478
3650
|
return await this.requestWithOverloadRetry(method, params, {
|
|
@@ -3480,11 +3652,17 @@ var CodexAppServerClient = class CodexAppServerClient {
|
|
|
3480
3652
|
...remainingTimeoutMs !== void 0 ? { timeoutMs: remainingTimeoutMs } : {}
|
|
3481
3653
|
}, (mayHaveWritten) => {
|
|
3482
3654
|
requestMayHaveWritten = mayHaveWritten;
|
|
3655
|
+
nativeResponded = !mayHaveWritten;
|
|
3656
|
+
}, () => {
|
|
3657
|
+
nativeResponded = true;
|
|
3658
|
+
if (!releaseWhenRequestSettles) release();
|
|
3483
3659
|
});
|
|
3484
3660
|
} catch (error) {
|
|
3485
3661
|
if (requestMayHaveWritten && !(error instanceof CodexAppServerRpcError)) {
|
|
3486
3662
|
releaseWhenRequestSettles = false;
|
|
3487
|
-
|
|
3663
|
+
if (nativeResponded) release();
|
|
3664
|
+
else removeExitHandler = this.addTransportExitHandler(release);
|
|
3665
|
+
if (!retire?.()) await this.closeAndRunAfterExit(release, method);
|
|
3488
3666
|
}
|
|
3489
3667
|
throw error;
|
|
3490
3668
|
} finally {
|
|
@@ -3494,17 +3672,17 @@ var CodexAppServerClient = class CodexAppServerClient {
|
|
|
3494
3672
|
}
|
|
3495
3673
|
return this.requestWithOverloadRetry(method, params, options);
|
|
3496
3674
|
}
|
|
3497
|
-
async requestWithOverloadRetry(method, params, options, onWriteStateChange) {
|
|
3498
|
-
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;
|
|
3499
3677
|
for (let retry = 0;; retry += 1) {
|
|
3500
|
-
if (options.signal?.aborted) throw new CodexAppServerLocalRequestCancellationError(method, "aborted", false);
|
|
3501
|
-
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();
|
|
3502
3680
|
if (remainingTimeoutMs !== void 0 && remainingTimeoutMs <= 0) throw new CodexAppServerLocalRequestCancellationError(method, "timed out", false);
|
|
3503
3681
|
try {
|
|
3504
3682
|
return await this.requestOnce(method, params, {
|
|
3505
3683
|
...options,
|
|
3506
3684
|
...remainingTimeoutMs !== void 0 ? { timeoutMs: remainingTimeoutMs } : {}
|
|
3507
|
-
}, onWriteStateChange);
|
|
3685
|
+
}, retry + 1, onWriteStateChange, deadline, onResponse);
|
|
3508
3686
|
} catch (error) {
|
|
3509
3687
|
if (!isCodexAppServerOverloadError(error) || retry >= CODEX_APP_SERVER_OVERLOAD_MAX_RETRIES) throw error;
|
|
3510
3688
|
onWriteStateChange?.(false);
|
|
@@ -3514,8 +3692,8 @@ var CodexAppServerClient = class CodexAppServerClient {
|
|
|
3514
3692
|
}
|
|
3515
3693
|
}
|
|
3516
3694
|
async waitForOverloadRetry(method, backoffMs, deadline, signal) {
|
|
3517
|
-
if (signal?.aborted) throw new CodexAppServerLocalRequestCancellationError(method, "aborted", false);
|
|
3518
|
-
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();
|
|
3519
3697
|
if (remainingMs !== void 0 && remainingMs <= 0) throw new CodexAppServerLocalRequestCancellationError(method, "timed out", false);
|
|
3520
3698
|
const delayMs = remainingMs === void 0 ? backoffMs : Math.min(backoffMs, remainingMs);
|
|
3521
3699
|
await new Promise((resolve, reject) => {
|
|
@@ -3526,7 +3704,7 @@ var CodexAppServerClient = class CodexAppServerClient {
|
|
|
3526
3704
|
timer.unref?.();
|
|
3527
3705
|
const abortListener = () => {
|
|
3528
3706
|
cleanup();
|
|
3529
|
-
reject(new CodexAppServerLocalRequestCancellationError(method, "aborted", false));
|
|
3707
|
+
reject(new CodexAppServerLocalRequestCancellationError(method, "aborted", false, signal?.reason));
|
|
3530
3708
|
};
|
|
3531
3709
|
const cleanup = () => {
|
|
3532
3710
|
clearTimeout(timer);
|
|
@@ -3536,9 +3714,9 @@ var CodexAppServerClient = class CodexAppServerClient {
|
|
|
3536
3714
|
if (signal?.aborted) abortListener();
|
|
3537
3715
|
});
|
|
3538
3716
|
}
|
|
3539
|
-
requestOnce(method, params, options, onWriteStateChange) {
|
|
3717
|
+
requestOnce(method, params, options, overloadAttemptOrdinal, onWriteStateChange, deadline, onResponse) {
|
|
3540
3718
|
if (this.closed) return Promise.reject(this.closeError ?? /* @__PURE__ */ new Error("codex app-server client is closed"));
|
|
3541
|
-
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));
|
|
3542
3720
|
const id = this.nextId++;
|
|
3543
3721
|
if (method === "account/login/start" || method === "account/logout" || method === "config/value/write" || method === "config/batchWrite") this.modelCatalogRevision += 1;
|
|
3544
3722
|
const message = {
|
|
@@ -3546,59 +3724,45 @@ var CodexAppServerClient = class CodexAppServerClient {
|
|
|
3546
3724
|
method,
|
|
3547
3725
|
params
|
|
3548
3726
|
};
|
|
3549
|
-
|
|
3550
|
-
|
|
3551
|
-
|
|
3552
|
-
|
|
3553
|
-
|
|
3554
|
-
|
|
3555
|
-
|
|
3556
|
-
|
|
3557
|
-
|
|
3558
|
-
|
|
3559
|
-
|
|
3560
|
-
|
|
3561
|
-
|
|
3562
|
-
|
|
3563
|
-
|
|
3564
|
-
|
|
3565
|
-
|
|
3566
|
-
|
|
3567
|
-
|
|
3568
|
-
|
|
3569
|
-
|
|
3570
|
-
}
|
|
3571
|
-
if (options.signal) {
|
|
3572
|
-
const abortListener = () => rejectPending(new CodexAppServerLocalRequestCancellationError(method, "aborted", mayHaveWritten));
|
|
3573
|
-
options.signal.addEventListener("abort", abortListener, { once: true });
|
|
3574
|
-
cleanupAbort = () => options.signal?.removeEventListener("abort", abortListener);
|
|
3575
|
-
}
|
|
3576
|
-
this.pending.set(id, {
|
|
3577
|
-
method,
|
|
3578
|
-
resolve: (value) => {
|
|
3579
|
-
cleanup();
|
|
3580
|
-
resolve(value);
|
|
3581
|
-
},
|
|
3582
|
-
reject: (error) => {
|
|
3583
|
-
cleanup();
|
|
3584
|
-
reject(mayHaveWritten && !(error instanceof CodexAppServerRpcError) && !isCodexAppServerIndeterminateRequestCancellationError(error) && !isCodexAppServerIndeterminateTransportError(error) ? new CodexAppServerIndeterminateTransportError(method, error) : error);
|
|
3585
|
-
},
|
|
3586
|
-
cleanup
|
|
3587
|
-
});
|
|
3588
|
-
if (options.signal?.aborted) {
|
|
3589
|
-
rejectPending(new CodexAppServerLocalRequestCancellationError(method, "aborted", false));
|
|
3590
|
-
return;
|
|
3591
|
-
}
|
|
3592
|
-
try {
|
|
3593
|
-
options.assertCurrent?.();
|
|
3594
|
-
this.writeMessage(message, (error) => rejectPending(error), () => {
|
|
3595
|
-
mayHaveWritten = true;
|
|
3596
|
-
onWriteStateChange?.(true);
|
|
3597
|
-
});
|
|
3598
|
-
} catch (error) {
|
|
3599
|
-
rejectPending(toStringifiedError(error));
|
|
3600
|
-
}
|
|
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
|
|
3601
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;
|
|
3602
3766
|
}
|
|
3603
3767
|
/** Sends a fire-and-forget JSON-RPC notification to the app-server. */
|
|
3604
3768
|
notify(method, params) {
|
|
@@ -3778,15 +3942,7 @@ var CodexAppServerClient = class CodexAppServerClient {
|
|
|
3778
3942
|
});
|
|
3779
3943
|
}
|
|
3780
3944
|
handleResponse(response) {
|
|
3781
|
-
|
|
3782
|
-
if (!pending) return;
|
|
3783
|
-
this.pending.delete(response.id);
|
|
3784
|
-
if (response.error) {
|
|
3785
|
-
pending.reject(new CodexAppServerRpcError(response.error, pending.method));
|
|
3786
|
-
return;
|
|
3787
|
-
}
|
|
3788
|
-
if (pending.method === "thread/backgroundTerminals/list" && isJsonObject(response.result) && Array.isArray(response.result.data) && response.result.data.length > 0) this.nativeExecutionObserved = true;
|
|
3789
|
-
pending.resolve(response.result);
|
|
3945
|
+
this.nativeExecutionObserved = dispatchCodexAppServerResponse(response, this.pending, this.catalogResponses, codexCatalogSourceForClient(this)) || this.nativeExecutionObserved;
|
|
3790
3946
|
}
|
|
3791
3947
|
async handleServerRequest(request) {
|
|
3792
3948
|
try {
|
|
@@ -3821,30 +3977,42 @@ var CodexAppServerClient = class CodexAppServerClient {
|
|
|
3821
3977
|
async runServerRequestHandlers(request) {
|
|
3822
3978
|
const controller = new AbortController();
|
|
3823
3979
|
if (request.method !== "item/tool/call") return await this.runServerRequestHandlersWithoutTimeout(request, controller.signal);
|
|
3824
|
-
|
|
3825
|
-
const
|
|
3980
|
+
let timeoutMs = resolveDynamicToolServerRequestTimeoutMs(readCodexDynamicToolCallParams(request.params));
|
|
3981
|
+
const deadline = createDeferred();
|
|
3826
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();
|
|
3827
4005
|
try {
|
|
3828
|
-
return await Promise.race([this.runServerRequestHandlersWithoutTimeout(request, controller.signal),
|
|
3829
|
-
timeout = setTimeout(() => {
|
|
3830
|
-
embeddedAgentLog.warn("codex app-server server request timed out", {
|
|
3831
|
-
id: request.id,
|
|
3832
|
-
method: request.method,
|
|
3833
|
-
timeoutMs
|
|
3834
|
-
});
|
|
3835
|
-
controller.abort(/* @__PURE__ */ new Error("codex app-server server request timed out"));
|
|
3836
|
-
resolve(timeoutResponse);
|
|
3837
|
-
}, timeoutMs);
|
|
3838
|
-
timeout.unref?.();
|
|
3839
|
-
})]);
|
|
4006
|
+
return await Promise.race([this.runServerRequestHandlersWithoutTimeout(request, controller.signal, setExecutionTimeoutMs), deadline.promise]);
|
|
3840
4007
|
} finally {
|
|
3841
|
-
|
|
4008
|
+
settled = true;
|
|
4009
|
+
clearTimeout(timeout);
|
|
3842
4010
|
}
|
|
3843
4011
|
}
|
|
3844
|
-
async runServerRequestHandlersWithoutTimeout(request, signal) {
|
|
4012
|
+
async runServerRequestHandlersWithoutTimeout(request, signal, setExecutionTimeoutMs) {
|
|
3845
4013
|
for (const handler of this.requestHandlers) {
|
|
3846
4014
|
if (signal.aborted) return;
|
|
3847
|
-
const result = await handler(request, signal);
|
|
4015
|
+
const result = await handler(request, signal, setExecutionTimeoutMs);
|
|
3848
4016
|
if (result !== void 0) return result;
|
|
3849
4017
|
}
|
|
3850
4018
|
}
|
|
@@ -3871,6 +4039,7 @@ var CodexAppServerClient = class CodexAppServerClient {
|
|
|
3871
4039
|
markClosed(error) {
|
|
3872
4040
|
if (this.closed) return false;
|
|
3873
4041
|
this.closed = true;
|
|
4042
|
+
closeCodexCatalogClientSource(this);
|
|
3874
4043
|
this.closeError = error;
|
|
3875
4044
|
this.lines.close();
|
|
3876
4045
|
this.rejectPendingRequests(error);
|
|
@@ -3879,7 +4048,7 @@ var CodexAppServerClient = class CodexAppServerClient {
|
|
|
3879
4048
|
rejectPendingRequests(error) {
|
|
3880
4049
|
for (const pending of this.pending.values()) {
|
|
3881
4050
|
pending.cleanup();
|
|
3882
|
-
pending.
|
|
4051
|
+
pending.close(error);
|
|
3883
4052
|
}
|
|
3884
4053
|
this.pending.clear();
|
|
3885
4054
|
for (const handler of this.closeHandlers) try {
|
|
@@ -3932,7 +4101,7 @@ function assertSupportedCodexAppServerVersion(response) {
|
|
|
3932
4101
|
if (!detectedVersion) throw new CodexAppServerVersionError(detectedVersion);
|
|
3933
4102
|
const detected = parse(detectedVersion);
|
|
3934
4103
|
if (!detected || detected.compare("0.149.0") < 0) throw new CodexAppServerVersionError(detectedVersion);
|
|
3935
|
-
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", {
|
|
3936
4105
|
detectedVersion,
|
|
3937
4106
|
validatedVersion: CODEX_APP_SERVER_VERSION
|
|
3938
4107
|
});
|