@openclaw/codex 2026.9.6 → 2026.9.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -0
- package/assets/icon.png +0 -0
- package/dist/.setup/{account-usage-runtime-Eem_WGqY.mjs → account-usage-runtime-DFhbh1zz.mjs} +5 -5
- package/dist/.setup/{apply-DDOi8uNx.mjs → apply-D3GcSoSa.mjs} +22 -36
- package/dist/.setup/{attempt-client-cleanup-CEv1cKwF.mjs → attempt-client-cleanup-DOP-cW5j.mjs} +128 -37
- package/dist/.setup/attempt-workspace-context-C5HigshI.mjs +164 -0
- package/dist/.setup/{auth-binding-DhLWa_7K.mjs → auth-binding-BLWz7stm.mjs} +14 -1
- package/dist/.setup/{auth-cache-key-B2mpaI9D.mjs → auth-cache-key-Dbvq-QgB.mjs} +36 -34
- package/dist/.setup/{auth-profile-WqZtZfXN.mjs → auth-profile-B0okYl2D.mjs} +1 -2
- package/dist/.setup/auth-start-options-BPIPeEX8.mjs +44 -0
- package/dist/.setup/{binding-connection-ThoatDcb.mjs → binding-connection-DTtN1KrX.mjs} +2 -2
- package/dist/.setup/{binding-connection.runtime-yoHrABt-.mjs → binding-connection.runtime-6TpgD1M6.mjs} +4 -4
- package/dist/.setup/{bounded-turn-B2HScEgT.mjs → bounded-turn-CbjoN2OW.mjs} +15 -18
- package/dist/.setup/bounded-turn-isolation-B8K_ylqk.mjs +14 -0
- package/dist/.setup/{build-state-C7EnDVgr.mjs → build-state-Da1_z0kd.mjs} +1 -1
- package/dist/.setup/{capabilities-CDXOOFdZ.mjs → capabilities-B3WEZl4e.mjs} +2 -10
- package/dist/.setup/{client-Cs08OXVQ.mjs → client-N0JpgSzF.mjs} +138 -399
- package/dist/.setup/{client-catalog-response-BMgt_4q4.mjs → client-catalog-response-5HHLdcde.mjs} +1 -1
- package/dist/.setup/{command-dispatch-B4JuOsOk.mjs → command-dispatch-BeAoaovI.mjs} +5 -8
- package/dist/.setup/{command-formatters-Bmqvr9tO.mjs → command-formatters-R3ckE3Co.mjs} +29 -61
- package/dist/.setup/{command-handlers-DW7Lx9oH.mjs → command-handlers-ylTMS00z.mjs} +222 -343
- package/dist/.setup/{command-rpc-DixIj3HW.mjs → command-rpc-CGJGUQ6Y.mjs} +15 -18
- package/dist/.setup/compact-C2WamavS.mjs +776 -0
- package/dist/.setup/{config-BoTP_mrL.mjs → config-DKhXquav.mjs} +26 -28
- package/dist/.setup/{config-options-BvaRs51b.mjs → config-options-CzyWLTJt.mjs} +24 -37
- package/dist/.setup/{config-parsing-CcB9iPoq.mjs → config-parsing-b088LyhT.mjs} +57 -60
- package/dist/.setup/{config-runtime-C8Rw1m1m.mjs → config-runtime-C0NbLms1.mjs} +2 -2
- package/dist/.setup/{config-security-BEReZ6go.mjs → config-security-CE-FcGw9.mjs} +32 -111
- package/dist/.setup/{config-utils-DujwEnhg.mjs → config-utils-D0CXecki.mjs} +3 -13
- package/dist/.setup/context-engine-projection-PezSESth.mjs +387 -0
- package/dist/.setup/{conversation-binding-DP-gMrBP.mjs → conversation-binding-3Min8qvP.mjs} +67 -90
- package/dist/.setup/{conversation-binding-data-CrcyZk6O.mjs → conversation-binding-data-C746z5Pn.mjs} +8 -12
- package/dist/.setup/{conversation-control-uK9Jomlc.mjs → conversation-control-CEP8X5JC.mjs} +8 -8
- package/dist/.setup/{cyber-failover-DYwbmf1o.mjs → cyber-failover-XV0nNRZu.mjs} +1 -1
- package/dist/.setup/{cyber-failover-notice-e9G3J9-e.mjs → cyber-failover-notice-RNpGpTyP.mjs} +1 -1
- package/dist/.setup/{dynamic-tools-BDXl-8Cw.mjs → dynamic-tools-DzlsLUuS.mjs} +2305 -2606
- package/dist/.setup/{effective-mcp-catalog-CvnvnGIe.mjs → effective-mcp-catalog-CxUtC-xG.mjs} +8 -17
- package/dist/.setup/{ephemeral-turn-poidXgek.mjs → ephemeral-turn-CDsPJOa2.mjs} +3 -3
- package/dist/.setup/event-projector-assistant-message-CigreO4K.mjs +69 -0
- package/dist/.setup/{event-projector-usage-CnBS8Wa3.mjs → event-projector-usage-03R0I2dM.mjs} +3 -25
- package/dist/.setup/event-projector-values-DJSz8BTk.mjs +106 -0
- package/dist/.setup/incognito-session-DWYapfwf.mjs +2 -0
- package/dist/.setup/{inference-context-D96l9-ew.mjs → inference-context-D-9gWlTR.mjs} +16 -18
- package/dist/.setup/inference-dispatch-CMZtjQyz.mjs +359 -0
- package/dist/.setup/inference-metadata-CgIf7sOx.mjs +81 -0
- package/dist/.setup/{inference-proxy-b-aJMSxm.mjs → inference-proxy-DhcXOgUE.mjs} +174 -214
- package/dist/.setup/{isolated-completion-BIZFhTNG.mjs → isolated-completion-Dm3PzxJk.mjs} +9 -12
- package/dist/.setup/{managed-binary-BnshlFag.mjs → managed-binary-kiWRhNRE.mjs} +8 -12
- package/dist/.setup/{model-catalog-CfXJf9Ay.mjs → model-catalog-PAuZgJC6.mjs} +11 -10
- package/dist/.setup/model-runtime-BdqzOMkU.mjs +11 -0
- package/dist/.setup/{models-KnqBv0hE.mjs → models-DHXZtVVk.mjs} +9 -18
- package/dist/.setup/{native-auth-rWbGbMn3.mjs → native-auth-CuG53tu4.mjs} +4 -4
- package/dist/.setup/{native-execution-policy-umd0tgh4.mjs → native-execution-policy-BxZJy5mP.mjs} +5 -30
- package/dist/.setup/{native-subagent-monitor-D3filLY2.mjs → native-subagent-monitor-Dpsmf2wz.mjs} +4395 -3609
- package/dist/.setup/native-subagent-pending-assignments-DwkCzLvD.mjs +203 -0
- package/dist/.setup/native-task-assignments-DMQ0g3hu.mjs +194 -0
- package/dist/.setup/{node-cli-sessions-r3avj02l.mjs → node-cli-sessions-HC4W6FLI.mjs} +19 -49
- package/dist/.setup/{node-exec-server.runtime-BDwWXVpK.mjs → node-exec-server.runtime-BgBfWQqo.mjs} +3 -6
- package/dist/.setup/{plan-CN3VwfNU.mjs → plan-Y-QIvrKB.mjs} +49 -92
- package/dist/.setup/{plugin-activation-DT3MNtqj.mjs → plugin-activation-cNHRfaxU.mjs} +8 -36
- package/dist/.setup/{plugin-app-cache-key-B2CsSdnV.mjs → plugin-app-cache-key-BL9B5H0L.mjs} +6 -23
- package/dist/.setup/{plugin-inventory-BoRei8Z4.mjs → plugin-inventory-Cky2XJUw.mjs} +21 -21
- package/dist/.setup/{plugin-marketplace-discovery-CDOi8IFs.mjs → plugin-marketplace-discovery-D_dV9FXa.mjs} +18 -24
- package/dist/.setup/{plugin-metadata-cache-Ctmo83k_.mjs → plugin-metadata-cache-DsjsL1dr.mjs} +115 -175
- package/dist/.setup/{provider-BOsxQHOM.mjs → provider-DH8NSzGt.mjs} +11 -14
- package/dist/.setup/{provider-capabilities-BfE88FZ5.mjs → provider-capabilities-CAxoF-X1.mjs} +13 -18
- package/dist/.setup/{rate-limits-CMU3DUD0.mjs → rate-limits-B7-X2TgG.mjs} +9 -31
- package/dist/.setup/{request-D2L0zMrq.mjs → request-BHZ1nz8d.mjs} +7 -6
- package/dist/.setup/responses-oauth-twnuTaAa.mjs +93 -0
- package/dist/.setup/rpc-error-BlD2vuzn.mjs +31 -0
- package/dist/.setup/{run-attempt-BHu11r7h.mjs → run-attempt-D8RZUOzY.mjs} +1035 -1023
- package/dist/.setup/{run-attempt-lifecycle-B7JbY4-F.mjs → run-attempt-lifecycle-C-6O3Exn.mjs} +10 -24
- package/dist/.setup/{runtime-artifact-CLZ8udh-.mjs → runtime-artifact-DDQ-HGXf.mjs} +16 -4
- package/dist/.setup/runtime-artifact-connection-D68qQn1m.mjs +78 -0
- package/dist/.setup/sandbox-guard-DjCz2eOw.mjs +126 -0
- package/dist/.setup/scope-DOC1Xjc8.mjs +6 -0
- package/dist/.setup/session-binding-DGCYAfvD.mjs +443 -0
- package/dist/.setup/{session-binding-record-BGoz8wOK.mjs → session-binding-record-Oe9L-CNY.mjs} +52 -130
- package/dist/.setup/{session-binding-sidecars-BlB5EvIS.mjs → session-binding-sidecars-jo6H8dFr.mjs} +196 -17
- package/dist/.setup/{session-catalog-Pno1xGcl.mjs → session-catalog-4sCdv5qx.mjs} +170 -324
- package/dist/.setup/{session-catalog-adoption-BI6UTDZT.mjs → session-catalog-adoption-BU_pHWG7.mjs} +7 -6
- package/dist/.setup/{session-catalog-archive-lHBqzhaO.mjs → session-catalog-archive-spHfihri.mjs} +6 -6
- package/dist/.setup/session-catalog-events-DePDzzjc.mjs +139 -0
- package/dist/.setup/session-catalog-home-id-vlih0B_g.mjs +22 -0
- package/dist/.setup/{session-catalog-index-B9_VQIUz.mjs → session-catalog-index-CZvDzC6z.mjs} +126 -122
- package/dist/.setup/{session-catalog-index-order-hcdz07yN.mjs → session-catalog-index-order-BcQpHks3.mjs} +1 -1
- package/dist/.setup/{session-catalog-index-state-Dgh8ORJm.mjs → session-catalog-index-state-TeO7EyO-.mjs} +3 -2
- package/dist/.setup/session-catalog-limits-DDxOsQeC.mjs +14 -0
- package/dist/.setup/session-catalog-list-request-CvtxrYSe.mjs +170 -0
- package/dist/.setup/session-catalog-native-projection-DjhwGL6x.mjs +178 -0
- package/dist/.setup/{session-catalog-node-adoption-ITddWx_X.mjs → session-catalog-node-adoption-DgXvSGu0.mjs} +10 -27
- package/dist/.setup/{session-catalog-node-continue-6g6qi4A9.mjs → session-catalog-node-continue-DjKXHBbi.mjs} +8 -10
- package/dist/.setup/session-catalog-node-lookup-CtAXI5W5.mjs +56 -0
- package/dist/.setup/{session-catalog-native-projection-DowriLid.mjs → session-catalog-parsing-CPGaPYr-.mjs} +11 -194
- package/dist/.setup/{session-catalog-projection-zK_PUsiE.mjs → session-catalog-projection-Cr5qP5Dj.mjs} +6 -4
- package/dist/.setup/session-catalog-provenance-DoAvktcj.mjs +95 -0
- package/dist/.setup/{session-cli-irrD-uo7.mjs → session-cli-Cn_nCqfq.mjs} +9 -22
- package/dist/.setup/{session-history-BrqhSCf9.mjs → session-history-D83lJWHG.mjs} +4 -6
- package/dist/.setup/{session-history-import-D-3wAgOP.mjs → session-history-import-WhX-X33a.mjs} +7 -10
- package/dist/.setup/session-history-read-Ov3StuL4.mjs +133 -0
- package/dist/.setup/{session-history.worker-CaCh0xF_.mjs → session-history.worker-MnPKncqP.mjs} +9 -5
- package/dist/.setup/session-initialization-6aveB9qb.mjs +22 -0
- package/dist/.setup/{session-permission-policy-BI1QK_98.mjs → session-permission-policy-Ci_fVX6y.mjs} +4 -8
- package/dist/.setup/{session-retirement-BH-S6qkJ.mjs → session-retirement-qMTxkNx2.mjs} +17 -17
- package/dist/.setup/{settled-turn-context-fmwouT5I.mjs → settled-turn-context-D4yj4rxf.mjs} +1 -1
- package/dist/.setup/{settled-turn-finalizer-DiAi6Kx6.mjs → settled-turn-finalizer-BsvEabkw.mjs} +14 -10
- package/dist/.setup/{shared-client-DA4VR4Eb.mjs → shared-client-DqyTMYug.mjs} +783 -412
- package/dist/.setup/shared-client-lifecycle-DJIgqgMw.mjs +153 -0
- package/dist/.setup/{side-question-BJ1wSDcB.mjs → side-question-C4kCmQy1.mjs} +79 -143
- package/dist/.setup/{source-CUzJq5WN.mjs → source-CS_7GFJZ.mjs} +80 -137
- package/dist/.setup/{thread-lifecycle-B3mfz1TG.mjs → thread-lifecycle-DPflntEJ.mjs} +294 -737
- package/dist/.setup/{incognito-session-uhrBF6wJ.mjs → thread-ownership-queue-Dp24d7-F.mjs} +1 -2
- package/dist/.setup/{thread-ownership-DcTtAcXj.mjs → thread-ownership-roNP0l1c.mjs} +45 -10
- package/dist/.setup/{thread-policy-DGuQsuFC.mjs → thread-policy-DTd-DtkX.mjs} +46 -7
- package/dist/.setup/{thread-requests-BLvGkP2R.mjs → thread-requests-B_bRnMGN.mjs} +199 -302
- package/dist/.setup/{thread-resume-DIBXwOpE.mjs → thread-resume-CdDaoc7T.mjs} +6 -6
- package/dist/.setup/{timeout-C910MdAB.mjs → timeout-CXOfNoaX.mjs} +1 -35
- package/dist/.setup/{transcript-history-projection-ZZpkFkJ_.mjs → transcript-history-projection-DRSifI-1.mjs} +17 -89
- package/dist/.setup/{transcript-mirror-attestation-CzM-94NC.mjs → transcript-mirror-attestation-YSegaktH.mjs} +3 -4
- package/dist/.setup/{transcript-mirror-BtHDBp1G.mjs → transcript-mirror-kxmCYsuF.mjs} +7 -9
- package/dist/.setup/{transport-stdio-h2VHOskC.mjs → transport-stdio-Bdegpn2V.mjs} +5 -22
- package/dist/.setup/transport-websocket-BTBE-LD9.mjs +211 -0
- package/dist/.setup/{upstream-prompt-provenance-LphB8slG.mjs → upstream-prompt-provenance-fXkKbPVC.mjs} +3 -9
- package/dist/.setup/{upstream-session-fork-BUr4OUbC.mjs → upstream-session-fork-CBeVjBpT.mjs} +23 -23
- package/dist/.setup/{usage-BML0r-ua.mjs → usage-BMzNxeR_.mjs} +4 -4
- package/dist/.setup/{usage-limit-error-DUMbefVY.mjs → usage-limit-error-QXerDo3i.mjs} +4 -19
- package/dist/.setup/{web-search-provider.runtime-CDKlN-Rv.mjs → web-search-provider.runtime-P77OUeoo.mjs} +8 -19
- package/dist/api.js +9 -11
- package/dist/catalog-page.worker.js +1 -1
- package/dist/cli-metadata.js +1 -1
- package/dist/doctor-contract-api.js +50 -8
- package/dist/harness.js +344 -1
- package/dist/index.js +193 -245
- package/dist/media-understanding-provider.js +9 -22
- package/dist/migration-provider-api.js +1 -1
- package/dist/provider-discovery.js +1 -1
- package/dist/session-history-worker-runtime.js +3 -3
- package/dist/session-history.worker.js +1 -1
- package/openclaw.plugin.json +14 -2
- package/package.json +7 -6
- package/dist/.setup/attempt-workspace-context-DUVEn_CS.mjs +0 -331
- package/dist/.setup/compact-Du5UvtxA.mjs +0 -680
- package/dist/.setup/event-projector-assistant-message-BsruvNrH.mjs +0 -103
- package/dist/.setup/event-projector-items-C6L_5ZiT.mjs +0 -234
- package/dist/.setup/harness-a_MsE4-_.mjs +0 -355
- package/dist/.setup/history-rejection-B4nOXNXF.mjs +0 -13
- package/dist/.setup/image-payload-sanitizer-tupAr-2o.mjs +0 -79
- package/dist/.setup/local-runtime-attribution-B_2mnqhb.mjs +0 -19
- package/dist/.setup/native-subagent-history-0nYYgo0k.mjs +0 -148
- package/dist/.setup/native-subagent-task-ids-wb8CKZGN.mjs +0 -441
- package/dist/.setup/plugin-approval-roundtrip-C0MZzCuP.mjs +0 -122
- package/dist/.setup/rolldown-runtime-8H4AJuhK.mjs +0 -14
- package/dist/.setup/sandbox-guard-C2sRMOEY.mjs +0 -166
- package/dist/.setup/session-binding-Cm0apEbd.mjs +0 -692
- package/dist/.setup/session-catalog-events-Bj6j94E_.mjs +0 -347
- package/dist/.setup/session-history-read-B3ZfSUbF.mjs +0 -50
- package/dist/.setup/session-initialization-rcgbZiid.mjs +0 -75
- package/dist/.setup/thread-history-page-DoVpnHim.mjs +0 -83
|
@@ -1,34 +1,32 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { p as resolveCodexAppServerUserHomeDir } from "./config-security-BEReZ6go.mjs";
|
|
3
|
-
import { d as recordCodexCatalogResponseSource, i as reuseCodexCatalogPreview, o as closeCodexCatalogClientSource, s as codexCatalogSourceForClient } from "./session-catalog-native-projection-DowriLid.mjs";
|
|
4
|
-
import { a as stringifyCodexAppServerMessage, c as isRpcResponse, i as readCodexCatalogDecodeRoute, n as projectCodexCatalogMessage, o as CodexAppServerMessageDecoder, r as listenCodexAppServerLines, s as redactCodexAppServerLinePreview } from "./client-catalog-response-BMgt_4q4.mjs";
|
|
1
|
+
import { a as stringifyCodexAppServerMessage, c as isRpcResponse, i as readCodexCatalogDecodeRoute, n as projectCodexCatalogMessage, o as CodexAppServerMessageDecoder, r as listenCodexAppServerLines, s as redactCodexAppServerLinePreview } from "./client-catalog-response-5HHLdcde.mjs";
|
|
5
2
|
import { i as isJsonObject } from "./protocol-CANUwXJ3.mjs";
|
|
6
|
-
import { c as MIN_SUPPORTED_CODEX_APP_SERVER_VERSION, s as CODEX_APP_SERVER_VERSION } from "./managed-binary-
|
|
7
|
-
import { a as closeCodexAppServerTransportAndWait, i as closeCodexAppServerTransport, o as hasCodexAppServerNaturalExit, t as createStdioTransport } from "./transport-stdio-
|
|
8
|
-
import {
|
|
9
|
-
import "./
|
|
10
|
-
import { n as resolveCodexAppServerRuntimeOptions } from "./config-runtime-
|
|
3
|
+
import { c as MIN_SUPPORTED_CODEX_APP_SERVER_VERSION, s as CODEX_APP_SERVER_VERSION } from "./managed-binary-kiWRhNRE.mjs";
|
|
4
|
+
import { a as closeCodexAppServerTransportAndWait, i as closeCodexAppServerTransport, o as hasCodexAppServerNaturalExit, t as createStdioTransport } from "./transport-stdio-Bdegpn2V.mjs";
|
|
5
|
+
import { n as CodexAppServerRpcError, t as CODEX_APP_SERVER_OVERLOADED_ERROR_CODE } from "./rpc-error-BlD2vuzn.mjs";
|
|
6
|
+
import { f as recordCodexCatalogResponseSource, i as reuseCodexCatalogPreview, o as closeCodexCatalogClientSource, s as codexCatalogSourceForClient } from "./session-catalog-native-projection-DjhwGL6x.mjs";
|
|
7
|
+
import { n as resolveCodexAppServerRuntimeOptions } from "./config-runtime-C0NbLms1.mjs";
|
|
11
8
|
import { codexCatalogPageWorkerEntrypoint } from "../catalog-page-worker-entrypoint.js";
|
|
9
|
+
import { t as createWebSocketTransport } from "./transport-websocket-BTBE-LD9.mjs";
|
|
10
|
+
import { t as __exportAll } from "./session-binding-sidecars-jo6H8dFr.mjs";
|
|
12
11
|
import { isRecord, normalizeOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
13
12
|
import { randomUUID } from "node:crypto";
|
|
14
|
-
import { addSafeTimeoutDelayGraceMs, addTimerTimeoutGraceMs, parseStrictNonNegativeInteger } from "openclaw/plugin-sdk/number-runtime";
|
|
15
13
|
import { normalizeJsonSchemaForTypeBox } from "openclaw/plugin-sdk/json-schema-runtime";
|
|
14
|
+
import { addSafeTimeoutDelayGraceMs, addTimerTimeoutGraceMs, parseStrictNonNegativeInteger } from "openclaw/plugin-sdk/number-runtime";
|
|
16
15
|
import path from "node:path";
|
|
17
|
-
import { EventEmitter } from "node:events";
|
|
18
16
|
import { coerceErrorMessage, toStringifiedError } from "openclaw/plugin-sdk/error-runtime";
|
|
19
17
|
import { sliceUtf16Safe, truncateUtf16Safe } from "openclaw/plugin-sdk/text-utility-runtime";
|
|
18
|
+
import { AsyncLocalStorage } from "node:async_hooks";
|
|
20
19
|
import { hasPendingInternalDiagnosticEvent } from "openclaw/plugin-sdk/diagnostic-runtime";
|
|
21
20
|
import { createDeferred } from "openclaw/plugin-sdk/extension-shared";
|
|
22
21
|
import { OPENCLAW_VERSION, embeddedAgentLog, formatToolExecutionErrorMessage, normalizeQuestionTimeoutSeconds, resolveToolExecutionErrorKind } from "openclaw/plugin-sdk/agent-harness-runtime";
|
|
23
22
|
import { parse } from "semver";
|
|
23
|
+
import { AsyncWorkScope } from "openclaw/plugin-sdk/concurrency-runtime";
|
|
24
24
|
import { copyInternalToolResultState, runWithAsyncWorkResources } from "openclaw/plugin-sdk/agent-harness-tool-runtime";
|
|
25
25
|
import { Compile } from "typebox/compile";
|
|
26
|
-
import net from "node:net";
|
|
27
|
-
import { PassThrough, Writable } from "node:stream";
|
|
28
|
-
import { StringDecoder } from "node:string_decoder";
|
|
29
|
-
import { WebSocket } from "openclaw/plugin-sdk/websocket-runtime";
|
|
30
26
|
//#region extensions/codex/src/app-server/client-catalog-worker.ts
|
|
31
27
|
const INLINE_CATALOG_MAX_BYTES = 65536;
|
|
28
|
+
const CATALOG_WORKER_IDLE_MS = 6e4;
|
|
29
|
+
const runInCatalogWorkerContext = AsyncLocalStorage.snapshot();
|
|
32
30
|
/** Late responses retain their decode route after cancellation removes the waiter. */
|
|
33
31
|
function codexCatalogRequestId(method, params, sequence, catalogPreview) {
|
|
34
32
|
const kind = catalogPreview ? method === "thread/list" ? "list" : method === "thread/read" && isJsonObject(params) && params.includeTurns !== true ? "thread" : void 0 : void 0;
|
|
@@ -37,6 +35,8 @@ function codexCatalogRequestId(method, params, sequence, catalogPreview) {
|
|
|
37
35
|
/** Each physical client owns one decoder, including incomplete-line recovery state. */
|
|
38
36
|
var CodexCatalogWorker = class {
|
|
39
37
|
constructor() {
|
|
38
|
+
this.setTimeoutFn = setTimeout;
|
|
39
|
+
this.clearTimeoutFn = clearTimeout;
|
|
40
40
|
this.closed = false;
|
|
41
41
|
}
|
|
42
42
|
get continuation() {
|
|
@@ -60,6 +60,10 @@ var CodexCatalogWorker = class {
|
|
|
60
60
|
}, projection?.preview);
|
|
61
61
|
}
|
|
62
62
|
}
|
|
63
|
+
this.clearTimeoutFn(this.idleTimer);
|
|
64
|
+
this.idleTimer = void 0;
|
|
65
|
+
await this.retirement;
|
|
66
|
+
if (this.closed) return;
|
|
63
67
|
if (!this.pool) {
|
|
64
68
|
const { resolveRuntimeWorkerUrl, WorkerTaskPool } = await import("openclaw/plugin-sdk/process-runtime");
|
|
65
69
|
if (this.closed) return;
|
|
@@ -94,12 +98,24 @@ var CodexCatalogWorker = class {
|
|
|
94
98
|
});
|
|
95
99
|
if (this.closed) return;
|
|
96
100
|
this.continuationRoute = decoded.pending ? route : void 0;
|
|
101
|
+
if (!decoded.pending) this.armIdleRetirement();
|
|
97
102
|
return decoded;
|
|
98
103
|
}
|
|
99
|
-
|
|
104
|
+
armIdleRetirement() {
|
|
105
|
+
this.idleTimer = runInCatalogWorkerContext(() => this.setTimeoutFn(() => {
|
|
106
|
+
this.idleTimer = void 0;
|
|
107
|
+
this.retirement = this.pool?.rotate();
|
|
108
|
+
this.retirement?.catch(() => void 0);
|
|
109
|
+
}, CATALOG_WORKER_IDLE_MS));
|
|
110
|
+
this.idleTimer.unref();
|
|
111
|
+
}
|
|
112
|
+
async close(error) {
|
|
100
113
|
this.closed = true;
|
|
114
|
+
this.clearTimeoutFn(this.idleTimer);
|
|
115
|
+
this.idleTimer = void 0;
|
|
101
116
|
this.continuationRoute = void 0;
|
|
102
|
-
|
|
117
|
+
await this.retirement?.catch(() => void 0);
|
|
118
|
+
await this.pool?.close(error);
|
|
103
119
|
}
|
|
104
120
|
};
|
|
105
121
|
//#endregion
|
|
@@ -198,6 +214,19 @@ function buildCodexAppServerInitializeParams() {
|
|
|
198
214
|
}
|
|
199
215
|
};
|
|
200
216
|
}
|
|
217
|
+
function buildCodexAppServerRuntimeIdentity(response, serverVersion) {
|
|
218
|
+
const userAgent = normalizeOptionalString(response.userAgent);
|
|
219
|
+
const codexHome = normalizeOptionalString(response.codexHome);
|
|
220
|
+
const platformFamily = normalizeOptionalString(response.platformFamily);
|
|
221
|
+
const platformOs = normalizeOptionalString(response.platformOs);
|
|
222
|
+
return {
|
|
223
|
+
serverVersion,
|
|
224
|
+
...userAgent ? { userAgent } : {},
|
|
225
|
+
...codexHome ? { codexHome } : {},
|
|
226
|
+
...platformFamily ? { platformFamily } : {},
|
|
227
|
+
...platformOs ? { platformOs } : {}
|
|
228
|
+
};
|
|
229
|
+
}
|
|
201
230
|
//#endregion
|
|
202
231
|
//#region extensions/codex/src/app-server/client-response.ts
|
|
203
232
|
/** Settles one wire attempt and reports newly observed native execution. */
|
|
@@ -232,14 +261,13 @@ function dispatchCodexAppServerResponse(response, attempts, catalogResponses, so
|
|
|
232
261
|
}
|
|
233
262
|
//#endregion
|
|
234
263
|
//#region extensions/codex/src/app-server/request-attempt.ts
|
|
235
|
-
/** One wire attempt; local waiter expiry need not imply a native response. */
|
|
264
|
+
/** One caller per wire attempt; local waiter expiry need not imply a native response. */
|
|
236
265
|
function createCodexRequestAttempt(params) {
|
|
237
266
|
let pending = true;
|
|
238
267
|
let mayHaveWritten = false;
|
|
239
|
-
|
|
268
|
+
let waiter;
|
|
240
269
|
const diagnostics = params.diagnosticIdentity ? {
|
|
241
270
|
...params.diagnosticIdentity,
|
|
242
|
-
waiterOrdinal: 0,
|
|
243
271
|
attemptCreatedAtMs: performance.now(),
|
|
244
272
|
firstPossibleWriteAtMs: null,
|
|
245
273
|
wireOutcomeAtWaiterSettlement: "retained-pending",
|
|
@@ -255,27 +283,8 @@ function createCodexRequestAttempt(params) {
|
|
|
255
283
|
params.onSettled();
|
|
256
284
|
return true;
|
|
257
285
|
};
|
|
258
|
-
const
|
|
259
|
-
|
|
260
|
-
};
|
|
261
|
-
const currentWaiterError = (waiter) => {
|
|
262
|
-
if (!params.retainWritten) return;
|
|
263
|
-
if (waiter.signal?.aborted) return {
|
|
264
|
-
error: params.cancellationError("aborted", mayHaveWritten, waiter.signal.reason),
|
|
265
|
-
outcome: "aborted"
|
|
266
|
-
};
|
|
267
|
-
if (waiter.deadline !== void 0 && performance.now() >= waiter.deadline) return {
|
|
268
|
-
error: params.cancellationError("timed out", mayHaveWritten),
|
|
269
|
-
outcome: "timed-out"
|
|
270
|
-
};
|
|
271
|
-
try {
|
|
272
|
-
waiter.assertCurrent?.();
|
|
273
|
-
} catch (error) {
|
|
274
|
-
return {
|
|
275
|
-
error: toStringifiedError(error),
|
|
276
|
-
outcome: "authority-rejected"
|
|
277
|
-
};
|
|
278
|
-
}
|
|
286
|
+
const currentWaiterError = () => {
|
|
287
|
+
if (!params.retainWritten || !waiter) return;
|
|
279
288
|
if (waiter.signal?.aborted) return {
|
|
280
289
|
error: params.cancellationError("aborted", mayHaveWritten, waiter.signal.reason),
|
|
281
290
|
outcome: "aborted"
|
|
@@ -291,7 +300,7 @@ function createCodexRequestAttempt(params) {
|
|
|
291
300
|
return pending;
|
|
292
301
|
},
|
|
293
302
|
wait(options, deadline) {
|
|
294
|
-
const { timeoutMs, signal,
|
|
303
|
+
const { timeoutMs, signal, overloadAttemptOrdinal } = options;
|
|
295
304
|
let observe = options.attemptWaiterFinished;
|
|
296
305
|
return new Promise((resolve, reject) => {
|
|
297
306
|
if (!pending) {
|
|
@@ -300,7 +309,6 @@ function createCodexRequestAttempt(params) {
|
|
|
300
309
|
}
|
|
301
310
|
let timer;
|
|
302
311
|
let removeAbort;
|
|
303
|
-
const waiterOrdinal = diagnostics ? ++diagnostics.waiterOrdinal : 0;
|
|
304
312
|
const waiterAttachedAtMs = diagnostics && observe ? performance.now() : 0;
|
|
305
313
|
const cleanup = () => {
|
|
306
314
|
clearTimeout(timer);
|
|
@@ -309,16 +317,17 @@ function createCodexRequestAttempt(params) {
|
|
|
309
317
|
removeAbort = void 0;
|
|
310
318
|
};
|
|
311
319
|
const detach = (waiterOutcome) => {
|
|
312
|
-
if (!
|
|
320
|
+
if (!waiter) return false;
|
|
321
|
+
waiter = void 0;
|
|
313
322
|
cleanup();
|
|
314
|
-
if (
|
|
323
|
+
if (!params.retainWritten || !mayHaveWritten) finish(mayHaveWritten ? "correlation-closed" : "not-written");
|
|
315
324
|
const callback = observe;
|
|
316
325
|
observe = void 0;
|
|
317
326
|
if (diagnostics && callback) try {
|
|
318
327
|
callback({
|
|
319
328
|
...diagnostics,
|
|
320
|
-
waiterOrdinal,
|
|
321
|
-
disposition,
|
|
329
|
+
waiterOrdinal: 1,
|
|
330
|
+
disposition: "new",
|
|
322
331
|
overloadAttemptOrdinal,
|
|
323
332
|
waiterAttachedAtMs,
|
|
324
333
|
waiterSettledAtMs: performance.now(),
|
|
@@ -327,7 +336,7 @@ function createCodexRequestAttempt(params) {
|
|
|
327
336
|
} catch {}
|
|
328
337
|
return true;
|
|
329
338
|
};
|
|
330
|
-
const
|
|
339
|
+
const localWaiter = {
|
|
331
340
|
resolve: (value) => {
|
|
332
341
|
if (!detach("resolved")) return;
|
|
333
342
|
resolve(value);
|
|
@@ -335,25 +344,21 @@ function createCodexRequestAttempt(params) {
|
|
|
335
344
|
reject: (error, outcome) => {
|
|
336
345
|
if (detach(outcome)) reject(error);
|
|
337
346
|
},
|
|
338
|
-
cleanup,
|
|
339
347
|
signal,
|
|
340
|
-
|
|
341
|
-
deadline,
|
|
342
|
-
assertCurrent
|
|
343
|
-
} : {}
|
|
348
|
+
deadline
|
|
344
349
|
};
|
|
345
|
-
|
|
350
|
+
waiter = localWaiter;
|
|
346
351
|
if (params.retainWritten && deadline !== void 0 && performance.now() >= deadline) {
|
|
347
|
-
|
|
352
|
+
localWaiter.reject(params.cancellationError("timed out", mayHaveWritten), "timed-out");
|
|
348
353
|
return;
|
|
349
354
|
}
|
|
350
355
|
if (timeoutMs && Number.isFinite(timeoutMs) && timeoutMs > 0) {
|
|
351
356
|
const remaining = params.retainWritten && deadline !== void 0 ? deadline - performance.now() : timeoutMs;
|
|
352
|
-
timer = setTimeout(() =>
|
|
357
|
+
timer = setTimeout(() => localWaiter.reject(params.cancellationError("timed out", mayHaveWritten), "timed-out"), Math.max(params.retainWritten ? 1 : 100, remaining));
|
|
353
358
|
timer.unref?.();
|
|
354
359
|
}
|
|
355
360
|
if (signal) {
|
|
356
|
-
const abort = () =>
|
|
361
|
+
const abort = () => localWaiter.reject(params.cancellationError("aborted", mayHaveWritten, signal.reason), "aborted");
|
|
357
362
|
signal.addEventListener("abort", abort, { once: true });
|
|
358
363
|
removeAbort = () => signal.removeEventListener("abort", abort);
|
|
359
364
|
if (signal.aborted) abort();
|
|
@@ -363,36 +368,29 @@ function createCodexRequestAttempt(params) {
|
|
|
363
368
|
resolve(value) {
|
|
364
369
|
if (!finish("native-ok")) return;
|
|
365
370
|
params.onResponse?.(mayHaveWritten);
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
else waiter.resolve(value);
|
|
370
|
-
}
|
|
371
|
+
const error = currentWaiterError();
|
|
372
|
+
if (error) waiter?.reject(error.error, error.outcome);
|
|
373
|
+
else waiter?.resolve(value);
|
|
371
374
|
},
|
|
372
375
|
reject(error, definitelyNotEnqueued = false) {
|
|
373
376
|
if (finish(definitelyNotEnqueued ? "ingress-rejected" : "native-error")) {
|
|
374
377
|
if (definitelyNotEnqueued) mayHaveWritten = false;
|
|
375
378
|
params.onResponse?.(mayHaveWritten);
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
waiter.reject(current?.error ?? params.localError(error, mayHaveWritten), current?.outcome ?? "native-error");
|
|
379
|
-
}
|
|
379
|
+
const current = currentWaiterError();
|
|
380
|
+
waiter?.reject(current?.error ?? params.localError(error, mayHaveWritten), current?.outcome ?? "native-error");
|
|
380
381
|
}
|
|
381
382
|
},
|
|
382
383
|
close(error) {
|
|
383
|
-
if (finish("correlation-closed"))
|
|
384
|
+
if (finish("correlation-closed")) waiter?.reject(params.localError(error, mayHaveWritten), "client-closed");
|
|
384
385
|
},
|
|
385
386
|
failLocal(error) {
|
|
386
387
|
if (!pending) return;
|
|
387
388
|
if (!params.retainWritten || !mayHaveWritten) finish(mayHaveWritten ? "correlation-closed" : "not-written");
|
|
388
|
-
|
|
389
|
+
waiter?.reject(params.localError(error, mayHaveWritten), "local-failed");
|
|
389
390
|
},
|
|
390
391
|
markWritten() {
|
|
391
392
|
mayHaveWritten = true;
|
|
392
393
|
if (diagnostics && diagnostics.firstPossibleWriteAtMs === null) diagnostics.firstPossibleWriteAtMs = performance.now();
|
|
393
|
-
},
|
|
394
|
-
cleanup() {
|
|
395
|
-
for (const waiter of waiters) waiter.cleanup();
|
|
396
394
|
}
|
|
397
395
|
};
|
|
398
396
|
}
|
|
@@ -452,21 +450,13 @@ function resolveCodexToolAbortTerminalReason(signal) {
|
|
|
452
450
|
}
|
|
453
451
|
//#endregion
|
|
454
452
|
//#region extensions/codex/src/app-server/dynamic-tool-execution.ts
|
|
455
|
-
/**
|
|
456
|
-
* Timeout, terminal-release, and diagnostic helpers for Codex dynamic tool
|
|
457
|
-
* calls.
|
|
458
|
-
*/
|
|
459
|
-
/** Default timeout for Codex dynamic tool calls. */
|
|
460
453
|
const CODEX_DYNAMIC_TOOL_TIMEOUT_MS = 9e4;
|
|
461
|
-
/** Hard cap for ordinary per-call Codex dynamic tool timeout overrides. */
|
|
462
454
|
const CODEX_DYNAMIC_TOOL_MAX_TIMEOUT_MS = 6e5;
|
|
463
455
|
const CODEX_DYNAMIC_TOOL_TIMEOUT_SECONDS_GRACE_MS = 3e4;
|
|
464
456
|
const CODEX_DYNAMIC_IMAGE_GENERATION_TOOL_TIMEOUT_MS = 12e4;
|
|
465
457
|
const CODEX_DYNAMIC_COMPUTER_GATEWAY_TIMEOUT_MS = 3e4;
|
|
466
458
|
const CODEX_DYNAMIC_COMPUTER_COMPLETION_GRACE_MS = 3e4;
|
|
467
|
-
/** Timeout for image-understanding style dynamic tool calls. */
|
|
468
459
|
const CODEX_DYNAMIC_IMAGE_TOOL_TIMEOUT_MS = 6e4;
|
|
469
|
-
/** Timeout for message-delivery dynamic tool calls. */
|
|
470
460
|
const CODEX_DYNAMIC_MESSAGE_TOOL_TIMEOUT_MS = 6e5;
|
|
471
461
|
/** Outer default for collector waits: full swarm budget plus completion grace. */
|
|
472
462
|
const CODEX_DYNAMIC_AGENTS_WAIT_TOOL_TIMEOUT_MS = 63e4;
|
|
@@ -576,16 +566,7 @@ async function executeDynamicToolCallWithTimeout(params, retainCleanup) {
|
|
|
576
566
|
const notifyFailedToolResult = (message, terminalReason = "failed") => {
|
|
577
567
|
notifyAgentToolResult({
|
|
578
568
|
toolName: params.call.tool,
|
|
579
|
-
result:
|
|
580
|
-
content: [{
|
|
581
|
-
type: "text",
|
|
582
|
-
text: message
|
|
583
|
-
}],
|
|
584
|
-
details: {
|
|
585
|
-
status: terminalReason,
|
|
586
|
-
error: message
|
|
587
|
-
}
|
|
588
|
-
},
|
|
569
|
+
result: failedToolResult(message, terminalReason),
|
|
589
570
|
isError: true
|
|
590
571
|
});
|
|
591
572
|
};
|
|
@@ -688,38 +669,31 @@ function toCodexDynamicToolProtocolResponse(response) {
|
|
|
688
669
|
function toCodexDynamicToolProgressResponse(response, protocolResponse) {
|
|
689
670
|
const transcriptDetails = isJsonObject(response.transcriptDetails) ? response.transcriptDetails : void 0;
|
|
690
671
|
const mcpAppPreview = isJsonObject(transcriptDetails?.mcpAppPreview) ? transcriptDetails.mcpAppPreview : void 0;
|
|
691
|
-
|
|
692
|
-
if (response.asyncStarted !== true && progressDetails === void 0) return protocolResponse;
|
|
672
|
+
if (response.asyncStarted !== true && !mcpAppPreview) return protocolResponse;
|
|
693
673
|
return {
|
|
694
674
|
...protocolResponse,
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
...progressDetails,
|
|
675
|
+
details: response.asyncStarted === true ? {
|
|
676
|
+
...mcpAppPreview ? { mcpAppPreview } : {},
|
|
698
677
|
async: true,
|
|
699
678
|
status: "started"
|
|
700
|
-
}
|
|
679
|
+
} : { mcpAppPreview }
|
|
701
680
|
};
|
|
702
681
|
}
|
|
703
|
-
/** Decides whether a terminal dynamic tool response can release the Codex turn. */
|
|
704
682
|
function shouldReleaseTurnAfterTerminalDynamicTool(state) {
|
|
705
683
|
return !state.completed && !state.aborted && state.responseSuccess && !state.currentTurnHadNonTerminalDynamicToolResult && state.activeAppServerTurnRequests === 0 && state.activeTurnItemIdsCount === 0 && state.pendingOpenClawDynamicToolCompletionIdsCount === 0;
|
|
706
684
|
}
|
|
707
|
-
/** Returns true when a non-async result should block terminal-release shortcuts. */
|
|
708
685
|
function shouldBlockTerminalReleaseForNonTerminalDynamicToolResult(response) {
|
|
709
686
|
return response.asyncStarted !== true;
|
|
710
687
|
}
|
|
711
|
-
/** Resolves whether terminal diagnostic state should release, wait, or stay idle. */
|
|
712
688
|
function resolveTerminalDynamicToolBatchAction(state) {
|
|
713
689
|
if (state.activeAppServerTurnRequests > 0 || state.activeTurnItemIdsCount > 0 || state.pendingOpenClawDynamicToolCompletionIdsCount > 0) return "wait";
|
|
714
690
|
if (state.currentTurnHadNonTerminalDynamicToolResult) return "clear-nonterminal-batch";
|
|
715
691
|
if (state.hasPendingTerminalDynamicToolRelease) return "release-pending-terminal";
|
|
716
692
|
return "idle";
|
|
717
693
|
}
|
|
718
|
-
/** Returns true for diagnostic events that terminate a dynamic tool call. */
|
|
719
694
|
function isDynamicToolTerminalDiagnosticEvent(event) {
|
|
720
695
|
return event.type === "tool.execution.completed" || event.type === "tool.execution.error" || event.type === "tool.execution.blocked";
|
|
721
696
|
}
|
|
722
|
-
/** Matches terminal diagnostics to a specific dynamic tool call id/name. */
|
|
723
697
|
function isMatchingDynamicToolTerminalDiagnostic(params) {
|
|
724
698
|
if (params.event.toolCallId !== params.call.callId || params.event.toolName !== params.call.tool) return false;
|
|
725
699
|
if (params.runId !== void 0) return params.event.runId === params.runId;
|
|
@@ -727,7 +701,6 @@ function isMatchingDynamicToolTerminalDiagnostic(params) {
|
|
|
727
701
|
if (params.sessionKey !== void 0) return params.event.sessionKey === params.sessionKey;
|
|
728
702
|
return params.event.runId === void 0 && params.event.sessionId === void 0 && params.event.sessionKey === void 0;
|
|
729
703
|
}
|
|
730
|
-
/** Checks pending diagnostics for a terminal event matching a tool call. */
|
|
731
704
|
function hasPendingDynamicToolTerminalDiagnostic(params) {
|
|
732
705
|
return hasPendingInternalDiagnosticEvent((event) => {
|
|
733
706
|
if (!isDynamicToolTerminalDiagnosticEvent(event)) return false;
|
|
@@ -740,7 +713,6 @@ function hasPendingDynamicToolTerminalDiagnostic(params) {
|
|
|
740
713
|
});
|
|
741
714
|
});
|
|
742
715
|
}
|
|
743
|
-
/** Resolves per-tool timeout, applying media/message defaults and hard caps. */
|
|
744
716
|
function resolveDynamicToolCallTimeoutMs(params) {
|
|
745
717
|
const args = isJsonObject(params.call.arguments) ? params.call.arguments : void 0;
|
|
746
718
|
if (params.call.tool === "node_exec") {
|
|
@@ -755,11 +727,8 @@ function resolveDynamicToolCallTimeoutMs(params) {
|
|
|
755
727
|
}
|
|
756
728
|
if (params.call.tool === "computer") return clampDynamicToolTimeoutMs(readComputerToolTimeoutMs(params.call.arguments));
|
|
757
729
|
if (params.call.tool === "message") return CODEX_DYNAMIC_MESSAGE_TOOL_TIMEOUT_MS;
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
return Math.max(1, Math.min(63e4, Math.floor(requestedMs)));
|
|
761
|
-
}
|
|
762
|
-
return clampDynamicToolTimeoutMs(readDynamicToolCallTimeoutMs(params.call.arguments) ?? readConfiguredDynamicToolTimeoutMs(params.call.tool, params.config) ?? CODEX_DYNAMIC_TOOL_TIMEOUT_MS);
|
|
730
|
+
const isCollectorWait = params.call.tool === "agents_wait";
|
|
731
|
+
return clampDynamicToolTimeoutMs(readDynamicToolCallTimeoutMs(params.call.arguments) ?? readConfiguredDynamicToolTimeoutMs(params.call.tool, params.config) ?? (isCollectorWait ? CODEX_DYNAMIC_AGENTS_WAIT_TOOL_TIMEOUT_MS : CODEX_DYNAMIC_TOOL_TIMEOUT_MS), isCollectorWait ? CODEX_DYNAMIC_AGENTS_WAIT_TOOL_TIMEOUT_MS : CODEX_DYNAMIC_TOOL_MAX_TIMEOUT_MS);
|
|
763
732
|
}
|
|
764
733
|
/** Transport guard stays outside the handler's bounded tool wait and completion grace. */
|
|
765
734
|
function resolveDynamicToolServerRequestTimeoutMs(call) {
|
|
@@ -805,8 +774,8 @@ function readDynamicToolTimeoutSecondsAsMs(value) {
|
|
|
805
774
|
function readPositiveFiniteTimeoutMs(value) {
|
|
806
775
|
return typeof value === "number" && Number.isFinite(value) && value > 0 ? Math.floor(value) : void 0;
|
|
807
776
|
}
|
|
808
|
-
function clampDynamicToolTimeoutMs(timeoutMs) {
|
|
809
|
-
return Math.max(1, Math.min(
|
|
777
|
+
function clampDynamicToolTimeoutMs(timeoutMs, maximum = CODEX_DYNAMIC_TOOL_MAX_TIMEOUT_MS) {
|
|
778
|
+
return Math.max(1, Math.min(maximum, Math.floor(timeoutMs)));
|
|
810
779
|
}
|
|
811
780
|
//#endregion
|
|
812
781
|
//#region extensions/codex/src/app-server/elicitation-response.ts
|
|
@@ -3088,10 +3057,15 @@ var TurnStartResponse_default = {
|
|
|
3088
3057
|
};
|
|
3089
3058
|
//#endregion
|
|
3090
3059
|
//#region extensions/codex/src/app-server/protocol-validators.ts
|
|
3091
|
-
|
|
3092
|
-
|
|
3093
|
-
|
|
3094
|
-
|
|
3060
|
+
function readSupervisionResponseThreadId(value) {
|
|
3061
|
+
const thread = isRecord(value) ? value.thread : void 0;
|
|
3062
|
+
return isRecord(thread) ? thread.id : void 0;
|
|
3063
|
+
}
|
|
3064
|
+
function resolveCodexThreadRolloutPath(thread) {
|
|
3065
|
+
const rolloutPath = thread.path?.trim();
|
|
3066
|
+
if (!rolloutPath || !path.isAbsolute(rolloutPath) || path.extname(rolloutPath) !== ".jsonl" || !path.basename(rolloutPath).includes(thread.id)) return;
|
|
3067
|
+
return rolloutPath;
|
|
3068
|
+
}
|
|
3095
3069
|
const externalDefinitionRefPrefix = "./CodexAppServerProtocolDefinitions.json#/definitions/";
|
|
3096
3070
|
const rootExternalDefinitionRefPrefix = "./v2/CodexAppServerProtocolDefinitions.json#/definitions/";
|
|
3097
3071
|
const localDefinitionRefPrefix = "#/definitions/";
|
|
@@ -3133,17 +3107,12 @@ function rewriteDefinitionRefs(value, externalRefPrefix) {
|
|
|
3133
3107
|
if (!isRecord(value)) return value;
|
|
3134
3108
|
return Object.fromEntries(Object.entries(value).map(([key, entry]) => [key, key === "$ref" && typeof entry === "string" && entry.startsWith(externalRefPrefix) ? `${localDefinitionRefPrefix}${entry.slice(externalRefPrefix.length)}` : rewriteDefinitionRefs(entry, externalRefPrefix)]));
|
|
3135
3109
|
}
|
|
3136
|
-
|
|
3137
|
-
const
|
|
3138
|
-
const modelListResponseSchema = materializeCodexSchema(ModelListResponse_default);
|
|
3139
|
-
const threadResumeResponseSchema = materializeCodexSchema(ThreadResumeResponse_default);
|
|
3140
|
-
const threadStartResponseSchema = materializeCodexSchema(ThreadStartResponse_default);
|
|
3141
|
-
const turnCompletedNotificationSchema = materializeCodexSchema(TurnCompletedNotification_default);
|
|
3142
|
-
const turnStartResponseSchema = materializeCodexSchema(TurnStartResponse_default);
|
|
3143
|
-
function compileCodexSchema(schema) {
|
|
3110
|
+
function compileCodexSchema(rawSchema, externalRefPrefix) {
|
|
3111
|
+
const schema = materializeCodexSchema(rawSchema, externalRefPrefix);
|
|
3144
3112
|
if (typeof schema !== "boolean" && !isRecord(schema)) throw new TypeError("Generated Codex schema must be an object or boolean");
|
|
3145
3113
|
const validator = Compile(normalizeJsonSchemaForTypeBox(schema));
|
|
3146
3114
|
return {
|
|
3115
|
+
schema,
|
|
3147
3116
|
check: (value) => validator.Check(value),
|
|
3148
3117
|
errors: (value) => [...validator.Errors(value)]
|
|
3149
3118
|
};
|
|
@@ -3183,10 +3152,7 @@ function applySchemaDefaults(schema, value, root = schema, resolvingRefs = /* @_
|
|
|
3183
3152
|
resolvingRefs.delete(schema.$ref);
|
|
3184
3153
|
}
|
|
3185
3154
|
}
|
|
3186
|
-
for (const
|
|
3187
|
-
const branches = schema[key];
|
|
3188
|
-
if (Array.isArray(branches)) for (const branch of branches) nextValue = applySchemaDefaults(branch, nextValue, root, resolvingRefs);
|
|
3189
|
-
}
|
|
3155
|
+
if (Array.isArray(schema.allOf)) for (const branch of schema.allOf) nextValue = applySchemaDefaults(branch, nextValue, root, resolvingRefs);
|
|
3190
3156
|
if (schemaTypeIncludes(schema, "object") && isRecord(nextValue) && isRecord(schema.properties)) {
|
|
3191
3157
|
for (const [key, propertySchema] of Object.entries(schema.properties)) {
|
|
3192
3158
|
const currentValue = nextValue[key];
|
|
@@ -3205,27 +3171,21 @@ function normalizeWithDefaults(schema, value) {
|
|
|
3205
3171
|
if (value === void 0 || value === null) return value;
|
|
3206
3172
|
return applySchemaDefaults(schema, structuredClone(value));
|
|
3207
3173
|
}
|
|
3208
|
-
const validateDynamicToolCallParams = compileCodexSchema(
|
|
3209
|
-
const validateErrorNotification = compileCodexSchema(
|
|
3210
|
-
const validateModelListResponse = compileCodexSchema(
|
|
3211
|
-
const validateThreadResumeResponse = compileCodexSchema(
|
|
3212
|
-
const validateThreadStartResponse = compileCodexSchema(
|
|
3213
|
-
const validateTurnCompletedNotification = compileCodexSchema(
|
|
3214
|
-
const validateTurnStartResponse = compileCodexSchema(
|
|
3215
|
-
/** Asserts and normalizes a Codex thread/start response. */
|
|
3174
|
+
const validateDynamicToolCallParams = compileCodexSchema(DynamicToolCallParams_default, rootExternalDefinitionRefPrefix);
|
|
3175
|
+
const validateErrorNotification = compileCodexSchema(ErrorNotification_default);
|
|
3176
|
+
const validateModelListResponse = compileCodexSchema(ModelListResponse_default);
|
|
3177
|
+
const validateThreadResumeResponse = compileCodexSchema(ThreadResumeResponse_default);
|
|
3178
|
+
const validateThreadStartResponse = compileCodexSchema(ThreadStartResponse_default);
|
|
3179
|
+
const validateTurnCompletedNotification = compileCodexSchema(TurnCompletedNotification_default);
|
|
3180
|
+
const validateTurnStartResponse = compileCodexSchema(TurnStartResponse_default);
|
|
3216
3181
|
function assertCodexThreadStartResponse(value) {
|
|
3217
|
-
|
|
3218
|
-
return assertCodexShape(validateThreadStartResponse, normalized, "thread/start response");
|
|
3182
|
+
return assertCodexShape(validateThreadStartResponse, value, "thread/start response");
|
|
3219
3183
|
}
|
|
3220
|
-
/** Asserts and normalizes a Codex thread/fork response. */
|
|
3221
3184
|
function assertCodexThreadForkResponse(value) {
|
|
3222
|
-
|
|
3223
|
-
return assertCodexShape(validateThreadStartResponse, normalized, "thread/fork response");
|
|
3185
|
+
return assertCodexShape(validateThreadStartResponse, value, "thread/fork response");
|
|
3224
3186
|
}
|
|
3225
|
-
/** Asserts and normalizes a Codex thread/resume response. */
|
|
3226
3187
|
function assertCodexThreadResumeResponse(value) {
|
|
3227
|
-
|
|
3228
|
-
return assertCodexShape(validateThreadResumeResponse, normalized, "thread/resume response");
|
|
3188
|
+
return assertCodexShape(validateThreadResumeResponse, value, "thread/resume response");
|
|
3229
3189
|
}
|
|
3230
3190
|
var CodexThreadDirectInputError = class extends Error {
|
|
3231
3191
|
constructor(threadId) {
|
|
@@ -3237,10 +3197,8 @@ var CodexThreadDirectInputError = class extends Error {
|
|
|
3237
3197
|
function assertCodexThreadAcceptsDirectInput(thread) {
|
|
3238
3198
|
if (thread.canAcceptDirectInput === false) throw new CodexThreadDirectInputError(thread.id);
|
|
3239
3199
|
}
|
|
3240
|
-
/** Asserts and normalizes a Codex turn/start response. */
|
|
3241
3200
|
function assertCodexTurnStartResponse(value) {
|
|
3242
|
-
|
|
3243
|
-
return assertCodexShape(validateTurnStartResponse, normalized, "turn/start response");
|
|
3201
|
+
return assertCodexShape(validateTurnStartResponse, value, "turn/start response");
|
|
3244
3202
|
}
|
|
3245
3203
|
/** Prompt echoes and attested managed-hook continuations cannot admit native capabilities. */
|
|
3246
3204
|
function assertCodexPassiveTurnItems(items, prompt, taskLabel, options = {}) {
|
|
@@ -3259,29 +3217,30 @@ function assertCodexPassiveTurnItems(items, prompt, taskLabel, options = {}) {
|
|
|
3259
3217
|
throw new Error(`Codex ${taskLabel} returned unexpected native item: ${item.type}`);
|
|
3260
3218
|
}
|
|
3261
3219
|
}
|
|
3262
|
-
/** Reads Codex dynamic-tool call params, returning undefined for invalid payloads. */
|
|
3263
3220
|
function readCodexDynamicToolCallParams(value) {
|
|
3264
|
-
return readCodexShape(validateDynamicToolCallParams,
|
|
3221
|
+
return readCodexShape(validateDynamicToolCallParams, value);
|
|
3265
3222
|
}
|
|
3266
|
-
/** Reads a Codex error notification payload if it matches the protocol schema. */
|
|
3267
3223
|
function readCodexErrorNotification(value) {
|
|
3268
|
-
return readCodexShape(validateErrorNotification,
|
|
3224
|
+
return readCodexShape(validateErrorNotification, value);
|
|
3269
3225
|
}
|
|
3270
|
-
/** Asserts and normalizes a Codex model/list response. */
|
|
3271
3226
|
function assertCodexModelListResponse(value) {
|
|
3272
|
-
return assertCodexShape(validateModelListResponse,
|
|
3227
|
+
return assertCodexShape(validateModelListResponse, value, "model/list response");
|
|
3273
3228
|
}
|
|
3274
|
-
/** Reads a Codex turn/completed notification payload if it matches the protocol schema. */
|
|
3275
3229
|
function readCodexTurnCompletedNotification(value) {
|
|
3276
|
-
const notification = readCodexShape(validateTurnCompletedNotification,
|
|
3230
|
+
const notification = readCodexShape(validateTurnCompletedNotification, value);
|
|
3277
3231
|
return notification?.turn.status === "inProgress" ? void 0 : notification;
|
|
3278
3232
|
}
|
|
3233
|
+
function assertExactSupervisionModelSelection(value, expected) {
|
|
3234
|
+
if (value.model !== expected.model || value.modelProvider !== expected.modelProvider) throw new Error(`Codex supervision ${expected.operation} changed native model selection: ${value.modelProvider ?? "unknown"}/${value.model ?? "unknown"}`);
|
|
3235
|
+
}
|
|
3279
3236
|
function assertCodexShape(validate, value, label) {
|
|
3280
|
-
|
|
3281
|
-
|
|
3237
|
+
const normalized = normalizeWithDefaults(validate.schema, value);
|
|
3238
|
+
if (validate.check(normalized)) return normalized;
|
|
3239
|
+
throw new Error(`Invalid Codex app-server ${label}: ${formatValidationErrors(validate, normalized)}`);
|
|
3282
3240
|
}
|
|
3283
3241
|
function readCodexShape(validate, value) {
|
|
3284
|
-
|
|
3242
|
+
const normalized = normalizeWithDefaults(validate.schema, value);
|
|
3243
|
+
return validate.check(normalized) ? normalized : void 0;
|
|
3285
3244
|
}
|
|
3286
3245
|
function formatValidationErrors(validate, value) {
|
|
3287
3246
|
const errors = validate.errors(value);
|
|
@@ -3304,6 +3263,8 @@ var CodexServerRequests = class {
|
|
|
3304
3263
|
constructor(respond) {
|
|
3305
3264
|
this.respond = respond;
|
|
3306
3265
|
this.handlers = /* @__PURE__ */ new Set();
|
|
3266
|
+
this.refreshWork = new AsyncWorkScope();
|
|
3267
|
+
this.closed = false;
|
|
3307
3268
|
this.active = /* @__PURE__ */ new Map();
|
|
3308
3269
|
}
|
|
3309
3270
|
resolve(params) {
|
|
@@ -3317,11 +3278,15 @@ var CodexServerRequests = class {
|
|
|
3317
3278
|
}
|
|
3318
3279
|
}
|
|
3319
3280
|
close(error) {
|
|
3281
|
+
this.closed = true;
|
|
3282
|
+
this.closing ??= this.refreshWork.drain();
|
|
3320
3283
|
const requests = [...this.active.values()];
|
|
3321
3284
|
this.active.clear();
|
|
3322
3285
|
for (const request of requests) request.controller.abort(error);
|
|
3286
|
+
return this.closing;
|
|
3323
3287
|
}
|
|
3324
3288
|
async handle(request) {
|
|
3289
|
+
if (this.closed) return;
|
|
3325
3290
|
const controller = new AbortController();
|
|
3326
3291
|
const entry = {
|
|
3327
3292
|
threadId: isJsonObject(request.params) ? request.params.threadId : void 0,
|
|
@@ -3364,7 +3329,8 @@ var CodexServerRequests = class {
|
|
|
3364
3329
|
}
|
|
3365
3330
|
};
|
|
3366
3331
|
try {
|
|
3367
|
-
const
|
|
3332
|
+
const work = request.method === "account/chatgptAuthTokens/refresh" ? this.refreshWork.track(run) : run();
|
|
3333
|
+
const result = await Promise.race([work, deadline.promise]);
|
|
3368
3334
|
if (this.active.get(request.id) === entry) this.respond({
|
|
3369
3335
|
id: request.id,
|
|
3370
3336
|
result: result === void 0 ? defaultServerRequestResponse(request) : result
|
|
@@ -3419,195 +3385,7 @@ function timeoutServerRequestResponse(timeoutMs) {
|
|
|
3419
3385
|
};
|
|
3420
3386
|
}
|
|
3421
3387
|
//#endregion
|
|
3422
|
-
//#region extensions/codex/src/app-server/transport-websocket.ts
|
|
3423
|
-
/**
|
|
3424
|
-
* Adapts a remote Codex app-server WebSocket endpoint to the shared stdio-like
|
|
3425
|
-
* transport interface.
|
|
3426
|
-
*/
|
|
3427
|
-
const WEBSOCKET_HANDSHAKE_TIMEOUT_MS = 1e4;
|
|
3428
|
-
const WEBSOCKET_PING_INTERVAL_MS = 2e4;
|
|
3429
|
-
const WEBSOCKET_PONG_TIMEOUT_MS = 2e4;
|
|
3430
|
-
const MAX_CONSECUTIVE_MISSED_WEBSOCKET_PONGS = 5;
|
|
3431
|
-
/** Opens a WebSocket app-server transport and maps newline-delimited frames to stdout/stdin. */
|
|
3432
|
-
function createWebSocketTransport(options) {
|
|
3433
|
-
if (!options.url) throw new Error("codex app-server websocket transport requires plugins.entries.codex.config.appServer.url");
|
|
3434
|
-
const events = new EventEmitter();
|
|
3435
|
-
const stdout = new PassThrough();
|
|
3436
|
-
const stderr = new PassThrough();
|
|
3437
|
-
const websocketOptions = {
|
|
3438
|
-
headers: {
|
|
3439
|
-
...options.headers,
|
|
3440
|
-
...options.authToken ? { Authorization: `Bearer ${options.authToken}` } : {}
|
|
3441
|
-
},
|
|
3442
|
-
perMessageDeflate: false,
|
|
3443
|
-
...options.transport === "websocket" ? { handshakeTimeout: WEBSOCKET_HANDSHAKE_TIMEOUT_MS } : {}
|
|
3444
|
-
};
|
|
3445
|
-
const unixSocketPath = resolveCodexAppServerUnixSocketPath(options);
|
|
3446
|
-
const socket = unixSocketPath ? new WebSocket("ws://localhost/", {
|
|
3447
|
-
...websocketOptions,
|
|
3448
|
-
createConnection: () => connectCodexAppServerUnixSocket(unixSocketPath)
|
|
3449
|
-
}) : new WebSocket(options.url, websocketOptions);
|
|
3450
|
-
const pendingFrames = [];
|
|
3451
|
-
const stdinDecoder = new StringDecoder("utf8");
|
|
3452
|
-
let pendingLine = "";
|
|
3453
|
-
let killed = false;
|
|
3454
|
-
let exitCode = null;
|
|
3455
|
-
let pingTimeout;
|
|
3456
|
-
let pongTimeout;
|
|
3457
|
-
let expectedPong;
|
|
3458
|
-
let consecutiveMissedPongs = 0;
|
|
3459
|
-
let heartbeatSequence = 0;
|
|
3460
|
-
const clearConnectionHealthTimers = () => {
|
|
3461
|
-
if (pingTimeout) {
|
|
3462
|
-
clearTimeout(pingTimeout);
|
|
3463
|
-
pingTimeout = void 0;
|
|
3464
|
-
}
|
|
3465
|
-
if (pongTimeout) {
|
|
3466
|
-
clearTimeout(pongTimeout);
|
|
3467
|
-
pongTimeout = void 0;
|
|
3468
|
-
}
|
|
3469
|
-
expectedPong = void 0;
|
|
3470
|
-
};
|
|
3471
|
-
const sendHeartbeatPing = () => {
|
|
3472
|
-
if (socket.readyState !== WebSocket.OPEN || pongTimeout) return;
|
|
3473
|
-
const payload = Buffer.from(`openclaw-codex-${++heartbeatSequence}`);
|
|
3474
|
-
expectedPong = payload;
|
|
3475
|
-
pongTimeout = setTimeout(() => {
|
|
3476
|
-
pongTimeout = void 0;
|
|
3477
|
-
expectedPong = void 0;
|
|
3478
|
-
consecutiveMissedPongs += 1;
|
|
3479
|
-
if (consecutiveMissedPongs >= MAX_CONSECUTIVE_MISSED_WEBSOCKET_PONGS) {
|
|
3480
|
-
socket.terminate();
|
|
3481
|
-
return;
|
|
3482
|
-
}
|
|
3483
|
-
sendHeartbeatPing();
|
|
3484
|
-
}, WEBSOCKET_PONG_TIMEOUT_MS);
|
|
3485
|
-
pongTimeout.unref();
|
|
3486
|
-
socket.ping(payload, void 0, (error) => {
|
|
3487
|
-
if (error) socket.terminate();
|
|
3488
|
-
});
|
|
3489
|
-
};
|
|
3490
|
-
const scheduleHeartbeatPing = () => {
|
|
3491
|
-
if (options.transport !== "websocket" || socket.readyState !== WebSocket.OPEN || pingTimeout || pongTimeout) return;
|
|
3492
|
-
pingTimeout = setTimeout(() => {
|
|
3493
|
-
pingTimeout = void 0;
|
|
3494
|
-
sendHeartbeatPing();
|
|
3495
|
-
}, WEBSOCKET_PING_INTERVAL_MS);
|
|
3496
|
-
pingTimeout.unref();
|
|
3497
|
-
};
|
|
3498
|
-
const recordConnectionActivity = () => {
|
|
3499
|
-
consecutiveMissedPongs = 0;
|
|
3500
|
-
if (pongTimeout) {
|
|
3501
|
-
clearTimeout(pongTimeout);
|
|
3502
|
-
pongTimeout = void 0;
|
|
3503
|
-
}
|
|
3504
|
-
expectedPong = void 0;
|
|
3505
|
-
scheduleHeartbeatPing();
|
|
3506
|
-
};
|
|
3507
|
-
const sendFrame = (frame) => {
|
|
3508
|
-
const trimmed = frame.trim();
|
|
3509
|
-
if (!trimmed) return;
|
|
3510
|
-
if (socket.readyState === WebSocket.OPEN) {
|
|
3511
|
-
socket.send(trimmed);
|
|
3512
|
-
return;
|
|
3513
|
-
}
|
|
3514
|
-
pendingFrames.push(trimmed);
|
|
3515
|
-
};
|
|
3516
|
-
socket.once("open", () => {
|
|
3517
|
-
for (const frame of pendingFrames.splice(0)) socket.send(frame);
|
|
3518
|
-
scheduleHeartbeatPing();
|
|
3519
|
-
});
|
|
3520
|
-
socket.on("pong", (payload) => {
|
|
3521
|
-
if (expectedPong?.equals(payload)) recordConnectionActivity();
|
|
3522
|
-
});
|
|
3523
|
-
socket.once("error", (error) => {
|
|
3524
|
-
clearConnectionHealthTimers();
|
|
3525
|
-
events.emit("error", error);
|
|
3526
|
-
});
|
|
3527
|
-
socket.once("close", (code, reason) => {
|
|
3528
|
-
clearConnectionHealthTimers();
|
|
3529
|
-
killed = true;
|
|
3530
|
-
exitCode = code;
|
|
3531
|
-
events.emit("exit", code, reason.toString("utf8"));
|
|
3532
|
-
});
|
|
3533
|
-
socket.on("message", (data) => {
|
|
3534
|
-
if (options.transport === "websocket") recordConnectionActivity();
|
|
3535
|
-
const frame = websocketFrameToBuffer(data);
|
|
3536
|
-
const writable = stdout.write(frame);
|
|
3537
|
-
const delimited = frame.at(-1) === 10 || stdout.write(Buffer.from("\n"));
|
|
3538
|
-
if (!writable || !delimited) socket.pause();
|
|
3539
|
-
});
|
|
3540
|
-
stdout.on("drain", () => {
|
|
3541
|
-
if (socket.readyState === WebSocket.OPEN) socket.resume();
|
|
3542
|
-
});
|
|
3543
|
-
const stdin = new Writable({
|
|
3544
|
-
write(chunk, _encoding, callback) {
|
|
3545
|
-
pendingLine += stdinDecoder.write(chunk);
|
|
3546
|
-
const lines = pendingLine.split("\n");
|
|
3547
|
-
pendingLine = lines.pop() ?? "";
|
|
3548
|
-
for (const frame of lines) sendFrame(frame);
|
|
3549
|
-
callback();
|
|
3550
|
-
},
|
|
3551
|
-
final(callback) {
|
|
3552
|
-
pendingLine += stdinDecoder.end();
|
|
3553
|
-
if (pendingLine) sendFrame(pendingLine);
|
|
3554
|
-
pendingLine = "";
|
|
3555
|
-
callback();
|
|
3556
|
-
}
|
|
3557
|
-
});
|
|
3558
|
-
const closeSocket = () => {
|
|
3559
|
-
if (socket.readyState === WebSocket.CLOSED || socket.readyState === WebSocket.CLOSING) return;
|
|
3560
|
-
socket.close();
|
|
3561
|
-
};
|
|
3562
|
-
stdin.once("finish", closeSocket);
|
|
3563
|
-
stdin.once("close", closeSocket);
|
|
3564
|
-
return {
|
|
3565
|
-
maxFrameBytes: 16777216,
|
|
3566
|
-
stdin,
|
|
3567
|
-
stdout,
|
|
3568
|
-
stderr,
|
|
3569
|
-
get killed() {
|
|
3570
|
-
return killed;
|
|
3571
|
-
},
|
|
3572
|
-
get exitCode() {
|
|
3573
|
-
return exitCode;
|
|
3574
|
-
},
|
|
3575
|
-
kill: (signal) => {
|
|
3576
|
-
killed = true;
|
|
3577
|
-
clearConnectionHealthTimers();
|
|
3578
|
-
if (signal === "SIGKILL") socket.terminate();
|
|
3579
|
-
else socket.close();
|
|
3580
|
-
},
|
|
3581
|
-
once: (event, listener) => events.once(event, listener),
|
|
3582
|
-
off: (event, listener) => events.off(event, listener)
|
|
3583
|
-
};
|
|
3584
|
-
}
|
|
3585
|
-
/** Opens the owner-scoped Codex control socket used by the WebSocket upgrade. */
|
|
3586
|
-
function connectCodexAppServerUnixSocket(socketPath) {
|
|
3587
|
-
return net.createConnection(socketPath);
|
|
3588
|
-
}
|
|
3589
|
-
/** Resolves the canonical or explicitly configured Codex control socket. */
|
|
3590
|
-
function resolveCodexAppServerUnixSocketPath(options) {
|
|
3591
|
-
if (options.transport !== "unix") {
|
|
3592
|
-
if (options.url?.startsWith("unix://")) throw new Error("codex app-server unix URL requires unix transport");
|
|
3593
|
-
return;
|
|
3594
|
-
}
|
|
3595
|
-
const url = options.url ?? "unix://";
|
|
3596
|
-
if (!url.startsWith("unix://")) throw new Error("codex app-server unix transport requires a unix:// URL");
|
|
3597
|
-
return url.slice(7) || path.join(resolveCodexAppServerUserHomeDir(options.env ?? process.env), "app-server-control", "app-server-control.sock");
|
|
3598
|
-
}
|
|
3599
|
-
function websocketFrameToBuffer(data) {
|
|
3600
|
-
if (typeof data === "string") return Buffer.from(data);
|
|
3601
|
-
if (Buffer.isBuffer(data)) return data;
|
|
3602
|
-
if (Array.isArray(data)) return Buffer.concat(data);
|
|
3603
|
-
return Buffer.from(data);
|
|
3604
|
-
}
|
|
3605
|
-
//#endregion
|
|
3606
3388
|
//#region extensions/codex/src/app-server/client.ts
|
|
3607
|
-
/**
|
|
3608
|
-
* JSON-RPC client for Codex app-server transports, including request/response
|
|
3609
|
-
* routing, notification fanout, server request handlers, and version checks.
|
|
3610
|
-
*/
|
|
3611
3389
|
var client_exports = /* @__PURE__ */ __exportAll({
|
|
3612
3390
|
CodexAppServerClient: () => CodexAppServerClient,
|
|
3613
3391
|
getCodexAppServerClientInstanceId: () => getCodexAppServerClientInstanceId,
|
|
@@ -3685,13 +3463,11 @@ function isCodexAppServerPrewriteRequestCancellationError(error) {
|
|
|
3685
3463
|
function isCodexAppServerIndeterminateTransportError(error) {
|
|
3686
3464
|
return error instanceof Error && "code" in error && error.code === "CODEX_APP_SERVER_REQUEST_TRANSPORT_INDETERMINATE" && "mayHaveWritten" in error && error.mayHaveWritten === true;
|
|
3687
3465
|
}
|
|
3688
|
-
/** Returns true for errors that mean the app-server transport is closed. */
|
|
3689
3466
|
function isCodexAppServerConnectionClosedError(error) {
|
|
3690
3467
|
if (!(error instanceof Error)) return false;
|
|
3691
3468
|
if (isCodexAppServerIndeterminateTransportError(error)) return true;
|
|
3692
3469
|
return error.message === "codex app-server client is closed" || error.message.startsWith("codex app-server exited:");
|
|
3693
3470
|
}
|
|
3694
|
-
/** Stateful app-server JSON-RPC client over stdio or websocket transport. */
|
|
3695
3471
|
var CodexAppServerClient = class CodexAppServerClient {
|
|
3696
3472
|
constructor(child) {
|
|
3697
3473
|
this.instanceId = randomUUID();
|
|
@@ -3731,7 +3507,6 @@ var CodexAppServerClient = class CodexAppServerClient {
|
|
|
3731
3507
|
});
|
|
3732
3508
|
child.stdin.on?.("error", (error) => this.closeWithError(toStringifiedError(error)));
|
|
3733
3509
|
}
|
|
3734
|
-
/** Starts a new app-server client using resolved runtime start options. */
|
|
3735
3510
|
static async start(options, assertCurrent) {
|
|
3736
3511
|
const defaults = resolveCodexAppServerRuntimeOptions().start;
|
|
3737
3512
|
const startOptions = {
|
|
@@ -3754,25 +3529,21 @@ var CodexAppServerClient = class CodexAppServerClient {
|
|
|
3754
3529
|
throw stderr ? new Error(`${coerceErrorMessage(error)}; stderr=${JSON.stringify(stderr)}`, { cause: error }) : error;
|
|
3755
3530
|
}
|
|
3756
3531
|
}
|
|
3757
|
-
/** Builds a client around a fake transport for tests. */
|
|
3758
3532
|
static fromTransportForTests(child) {
|
|
3759
3533
|
return new CodexAppServerClient(child);
|
|
3760
3534
|
}
|
|
3761
|
-
/** Performs the app-server initialize handshake and validates protocol version. */
|
|
3762
3535
|
async initialize() {
|
|
3763
3536
|
if (this.initialized) return;
|
|
3764
3537
|
const response = await this.request("initialize", buildCodexAppServerInitializeParams());
|
|
3765
3538
|
this.child.startupFailure?.complete();
|
|
3766
|
-
|
|
3767
|
-
this.runtimeIdentity = buildCodexAppServerRuntimeIdentity(response,
|
|
3539
|
+
const serverVersion = assertSupportedCodexAppServerVersion(response);
|
|
3540
|
+
this.runtimeIdentity = buildCodexAppServerRuntimeIdentity(response, serverVersion);
|
|
3768
3541
|
this.notify("initialized");
|
|
3769
3542
|
this.initialized = true;
|
|
3770
3543
|
}
|
|
3771
|
-
/** Returns the version detected during initialize. */
|
|
3772
3544
|
getServerVersion() {
|
|
3773
|
-
return this.serverVersion;
|
|
3545
|
+
return this.runtimeIdentity?.serverVersion;
|
|
3774
3546
|
}
|
|
3775
|
-
/** Returns runtime metadata detected during initialize. */
|
|
3776
3547
|
getRuntimeIdentity() {
|
|
3777
3548
|
return this.runtimeIdentity ? { ...this.runtimeIdentity } : void 0;
|
|
3778
3549
|
}
|
|
@@ -3942,8 +3713,6 @@ var CodexAppServerClient = class CodexAppServerClient {
|
|
|
3942
3713
|
});
|
|
3943
3714
|
const result = attempt.wait({
|
|
3944
3715
|
...options,
|
|
3945
|
-
assertCurrent: void 0,
|
|
3946
|
-
disposition: "new",
|
|
3947
3716
|
overloadAttemptOrdinal
|
|
3948
3717
|
}, deadline);
|
|
3949
3718
|
if (!attempt.pending) return result;
|
|
@@ -3958,25 +3727,21 @@ var CodexAppServerClient = class CodexAppServerClient {
|
|
|
3958
3727
|
}
|
|
3959
3728
|
return result;
|
|
3960
3729
|
}
|
|
3961
|
-
/** Sends a fire-and-forget JSON-RPC notification to the app-server. */
|
|
3962
3730
|
notify(method, params) {
|
|
3963
3731
|
this.writeMessage({
|
|
3964
3732
|
method,
|
|
3965
3733
|
params
|
|
3966
3734
|
});
|
|
3967
3735
|
}
|
|
3968
|
-
/** Registers a handler for app-server requests sent back to OpenClaw. */
|
|
3969
3736
|
addRequestHandler(handler) {
|
|
3970
3737
|
this.serverRequests.handlers.add(handler);
|
|
3971
3738
|
return () => this.serverRequests.handlers.delete(handler);
|
|
3972
3739
|
}
|
|
3973
|
-
/** Registers a notification handler and returns its disposer. */
|
|
3974
3740
|
addNotificationHandler(handler) {
|
|
3975
3741
|
this.notificationHandlers.add(handler);
|
|
3976
3742
|
for (const notification of this.pendingStartupWarnings.splice(0)) this.handleNotification(notification);
|
|
3977
3743
|
return () => this.notificationHandlers.delete(handler);
|
|
3978
3744
|
}
|
|
3979
|
-
/** Registers a close handler and returns its disposer. */
|
|
3980
3745
|
addCloseHandler(handler) {
|
|
3981
3746
|
this.closeHandlers.add(handler);
|
|
3982
3747
|
return () => this.closeHandlers.delete(handler);
|
|
@@ -3991,33 +3756,26 @@ var CodexAppServerClient = class CodexAppServerClient {
|
|
|
3991
3756
|
this.child.once("exit", onExit);
|
|
3992
3757
|
return () => this.child.off?.("exit", onExit);
|
|
3993
3758
|
}
|
|
3994
|
-
/** Closes the transport without waiting for process/socket shutdown. */
|
|
3995
3759
|
close() {
|
|
3996
|
-
|
|
3997
|
-
closeCodexAppServerTransport(this.child);
|
|
3760
|
+
this.closeWithError(/* @__PURE__ */ new Error("codex app-server client is closed"));
|
|
3998
3761
|
}
|
|
3999
|
-
/** Closes the transport and waits for shutdown according to transport policy. */
|
|
4000
3762
|
async closeAndWait(options) {
|
|
4001
3763
|
this.markClosed(/* @__PURE__ */ new Error("codex app-server client is closed"));
|
|
4002
|
-
const [result] = await Promise.all([closeCodexAppServerTransportAndWait(this.child, options), this.
|
|
3764
|
+
const [result] = await Promise.all([closeCodexAppServerTransportAndWait(this.child, options), this.waitForCloseWork()]);
|
|
4003
3765
|
return this.nativeExecutionObserved ? {
|
|
4004
3766
|
...result,
|
|
4005
3767
|
cleanup: "uncertain"
|
|
4006
3768
|
} : result;
|
|
4007
3769
|
}
|
|
3770
|
+
/** Joins local settlement already started by close without changing transport policy. */
|
|
3771
|
+
async waitForCloseWork() {
|
|
3772
|
+
await this.serverRequestsClosed;
|
|
3773
|
+
await this.catalogWorkerClosed;
|
|
3774
|
+
}
|
|
4008
3775
|
/** Closes this transport and runs cleanup only after physical process exit. */
|
|
4009
3776
|
async closeAndRunAfterExit(onExit, operation) {
|
|
4010
|
-
|
|
4011
|
-
|
|
4012
|
-
if (settled) return;
|
|
4013
|
-
settled = true;
|
|
4014
|
-
onExit();
|
|
4015
|
-
};
|
|
4016
|
-
if (this.transportExited) {
|
|
4017
|
-
runOnExit();
|
|
4018
|
-
return;
|
|
4019
|
-
}
|
|
4020
|
-
this.child.once("exit", runOnExit);
|
|
3777
|
+
this.addTransportExitHandler(onExit);
|
|
3778
|
+
if (this.transportExited) return;
|
|
4021
3779
|
try {
|
|
4022
3780
|
await this.closeAndWait();
|
|
4023
3781
|
} catch (closeError) {
|
|
@@ -4128,15 +3886,12 @@ var CodexAppServerClient = class CodexAppServerClient {
|
|
|
4128
3886
|
this.catalogWorkerClosed?.catch((closeError) => {
|
|
4129
3887
|
embeddedAgentLog.warn("codex catalog worker shutdown failed", { error: closeError });
|
|
4130
3888
|
});
|
|
4131
|
-
this.serverRequests.close(error);
|
|
3889
|
+
this.serverRequestsClosed = this.serverRequests.close(error);
|
|
4132
3890
|
this.rejectPendingRequests(error);
|
|
4133
3891
|
return true;
|
|
4134
3892
|
}
|
|
4135
3893
|
rejectPendingRequests(error) {
|
|
4136
|
-
for (const pending of this.pending.values())
|
|
4137
|
-
pending.cleanup();
|
|
4138
|
-
pending.close(error);
|
|
4139
|
-
}
|
|
3894
|
+
for (const pending of this.pending.values()) pending.close(error);
|
|
4140
3895
|
this.pending.clear();
|
|
4141
3896
|
for (const handler of this.closeHandlers) try {
|
|
4142
3897
|
handler(this);
|
|
@@ -4145,7 +3900,6 @@ var CodexAppServerClient = class CodexAppServerClient {
|
|
|
4145
3900
|
}
|
|
4146
3901
|
}
|
|
4147
3902
|
};
|
|
4148
|
-
/** Raised when the initialize handshake detects an unsupported app-server version. */
|
|
4149
3903
|
var CodexAppServerVersionError = class extends Error {
|
|
4150
3904
|
constructor(detectedVersion) {
|
|
4151
3905
|
const detected = detectedVersion ? `detected ${detectedVersion}` : "OpenClaw could not determine the running Codex version";
|
|
@@ -4159,7 +3913,7 @@ function assertSupportedCodexAppServerVersion(response) {
|
|
|
4159
3913
|
if (!detectedVersion) throw new CodexAppServerVersionError(detectedVersion);
|
|
4160
3914
|
const detected = parse(detectedVersion);
|
|
4161
3915
|
if (!detected || detected.compare("0.149.0") < 0) throw new CodexAppServerVersionError(detectedVersion);
|
|
4162
|
-
if (detected.compare("0.
|
|
3916
|
+
if (detected.compare("0.158.0") > 0) embeddedAgentLog.warn("codex app-server is newer than OpenClaw's managed runtime; continuing with normal startup validation", {
|
|
4163
3917
|
detectedVersion,
|
|
4164
3918
|
validatedVersion: CODEX_APP_SERVER_VERSION
|
|
4165
3919
|
});
|
|
@@ -4168,20 +3922,6 @@ function assertSupportedCodexAppServerVersion(response) {
|
|
|
4168
3922
|
function isUnsupportedCodexAppServerVersionError(error) {
|
|
4169
3923
|
return error instanceof CodexAppServerVersionError;
|
|
4170
3924
|
}
|
|
4171
|
-
function buildCodexAppServerRuntimeIdentity(response, serverVersion) {
|
|
4172
|
-
const userAgent = normalizeOptionalString(response.userAgent);
|
|
4173
|
-
const codexHome = normalizeOptionalString(response.codexHome);
|
|
4174
|
-
const platformFamily = normalizeOptionalString(response.platformFamily);
|
|
4175
|
-
const platformOs = normalizeOptionalString(response.platformOs);
|
|
4176
|
-
return {
|
|
4177
|
-
serverVersion,
|
|
4178
|
-
...userAgent ? { userAgent } : {},
|
|
4179
|
-
...codexHome ? { codexHome } : {},
|
|
4180
|
-
...platformFamily ? { platformFamily } : {},
|
|
4181
|
-
...platformOs ? { platformOs } : {}
|
|
4182
|
-
};
|
|
4183
|
-
}
|
|
4184
|
-
/** Extracts the Codex version from the app-server initialize user-agent field. */
|
|
4185
3925
|
function readCodexVersionFromUserAgent(userAgent) {
|
|
4186
3926
|
return (userAgent?.match(/^[^/]+\/(\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?)(?:[\s(]|$)/))?.[1];
|
|
4187
3927
|
}
|
|
@@ -4190,9 +3930,8 @@ const CODEX_APP_SERVER_APPROVAL_REQUEST_METHODS = /* @__PURE__ */ new Set([
|
|
|
4190
3930
|
"item/fileChange/requestApproval",
|
|
4191
3931
|
"item/permissions/requestApproval"
|
|
4192
3932
|
]);
|
|
4193
|
-
/** Returns true for app-server approval request methods OpenClaw can answer. */
|
|
4194
3933
|
function isCodexAppServerApprovalRequest(method) {
|
|
4195
3934
|
return CODEX_APP_SERVER_APPROVAL_REQUEST_METHODS.has(method);
|
|
4196
3935
|
}
|
|
4197
3936
|
//#endregion
|
|
4198
|
-
export {
|
|
3937
|
+
export { handleDynamicToolCallWithTimeout as A, resolveCodexToolAbortTerminalReason as B, assertExactSupervisionModelSelection as C, readSupervisionResponseThreadId as D, readCodexTurnCompletedNotification as E, resolveTerminalDynamicToolBatchAction as F, failedToolResult as H, shouldBlockTerminalReleaseForNonTerminalDynamicToolResult as I, shouldReleaseTurnAfterTerminalDynamicTool as L, isDynamicToolTerminalDiagnosticEvent as M, isMatchingDynamicToolTerminalDiagnostic as N, resolveCodexThreadRolloutPath as O, resolveDynamicToolCallTimeoutMs as P, toCodexDynamicToolProgressResponse as R, assertCodexTurnStartResponse as S, readCodexErrorNotification as T, CODEX_APP_SERVER_OPT_OUT_NOTIFICATION_METHODS as U, createFailedDynamicToolResponse as V, assertCodexPassiveTurnItems as _, isCodexAppServerBrokenPipeError as a, assertCodexThreadResumeResponse as b, isCodexAppServerIndeterminateTransportError as c, isCodexAppServerRequestTimeoutError as d, isUnsupportedCodexAppServerVersionError as f, assertCodexModelListResponse as g, CodexThreadDirectInputError as h, isCodexAppServerApprovalRequest as i, hasPendingDynamicToolTerminalDiagnostic as j, createCodexElicitationResponse as k, isCodexAppServerOverloadError as l, CodexServerRequestResolvedError as m, client_exports as n, isCodexAppServerConnectionClosedError as o, resolveCodexAppServerClientInstanceId as p, getCodexAppServerClientInstanceId as r, isCodexAppServerIndeterminateRequestCancellationError as s, CodexAppServerClient as t, isCodexAppServerPrewriteRequestCancellationError as u, assertCodexThreadAcceptsDirectInput as v, readCodexDynamicToolCallParams as w, assertCodexThreadStartResponse as x, assertCodexThreadForkResponse as y, toCodexDynamicToolProtocolResponse as z };
|