@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,32 +1,107 @@
|
|
|
1
|
-
import { t as __exportAll } from "./rolldown-runtime-8H4AJuhK.
|
|
2
|
-
import { n as defineCodexBuildState, t as codexBuildSymbol } from "./build-state-
|
|
3
|
-
import { t as CODEX_APP_SERVER_AUTH_PROVIDER } from "./auth-profile-selection-DFu9e167.
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { t as
|
|
7
|
-
import {
|
|
8
|
-
import { c as resolveMacOSDesktopCodexAppPathCandidates, i as resolveManagedCodexNativeCommand, l as resolveMacOSDesktopCodexBundledMarketplaceCandidates, r as resolveManagedCodexAppServerStartOptions, s as resolveFirstExistingMacOSDesktopCodexBundledMarketplacePath, t as isManagedCodexDesktopCommand, u as resolveMacOSDesktopCodexComputerUseServiceAppCandidates } from "./managed-binary-
|
|
9
|
-
import { _ as isCodexDesktopGenerationCurrent, a as readCodexCliAuthFileApiKey, c as resolveCodexAppServerPreparedApiKeyCacheKey, d as createCodexAppServerStartupLifetime, f as getCurrentSharedClientEntry, i as fingerprintTokenAuthProfileCacheKey, l as closeRetiredSharedClientEntry, m as retireSharedCodexAppServerClientIfCurrent, n as CODEX_AUTH_JSON_FILENAME, o as readFirstNonEmptyEnv, p as getSharedCodexAppServerClientState, r as fingerprintApiKeyAuthProfileCacheKey, s as resolveCodexAppServerFallbackApiKeyCacheKey, t as CODEX_APP_SERVER_API_KEY_ENV_VARS, u as closeRetiredSharedClientEntryIfIdle, v as waitForCodexDesktopGeneration } from "./auth-cache-key-
|
|
10
|
-
import { n as resolveCodexAppServerSpawnEnv } from "./transport-stdio-
|
|
11
|
-
import { n as withTimeout } from "./timeout-
|
|
12
|
-
import {
|
|
13
|
-
import { n as resolveCodexAppServerRuntimeOptions } from "./config-runtime-
|
|
14
|
-
import { a as resolveCodexAppServerAuthProfileStore, i as resolveCodexAppServerAuthProfileIdForAgent, r as resolveCodexAppServerAuthProfileId, t as isCodexAppServerNativeAuthProfile } from "./auth-profile-
|
|
1
|
+
import { t as __exportAll } from "./rolldown-runtime-8H4AJuhK.mjs";
|
|
2
|
+
import { n as defineCodexBuildState, t as codexBuildSymbol } from "./build-state-Xx9ybZqa.mjs";
|
|
3
|
+
import { t as CODEX_APP_SERVER_AUTH_PROVIDER } from "./auth-profile-selection-DFu9e167.mjs";
|
|
4
|
+
import { _ as resolveCodexAppServerUserHomeDir, g as resolveCodexAppServerLocalHomeDir, h as resolveCodexAppServerHomeDir, m as isJsonObject, v as withEphemeralCodexAuthStore } from "./config-security-BRQ2mgW9.mjs";
|
|
5
|
+
import { n as isCodexAppServerProxyLaunch } from "./launch-args-DnMak49W.mjs";
|
|
6
|
+
import { f as isUnsupportedCodexAppServerVersionError, t as CodexAppServerClient } from "./client-vXs2929Q.mjs";
|
|
7
|
+
import { a as resolveCodexAppServerStartOptionsForAgent, d as readCodexEffectiveConfig, o as resolveCodexComputerUseConfig, t as codexAppServerStartOptionsKey, u as CODEX_SESSION_OVERRIDABLE_LAYER_TYPES } from "./config-options-BsanJ8QG.mjs";
|
|
8
|
+
import { c as resolveMacOSDesktopCodexAppPathCandidates, i as resolveManagedCodexNativeCommand, l as resolveMacOSDesktopCodexBundledMarketplaceCandidates, r as resolveManagedCodexAppServerStartOptions, s as resolveFirstExistingMacOSDesktopCodexBundledMarketplacePath, t as isManagedCodexDesktopCommand, u as resolveMacOSDesktopCodexComputerUseServiceAppCandidates } from "./managed-binary-DP6Rib3P.mjs";
|
|
9
|
+
import { _ as isCodexDesktopGenerationCurrent, a as readCodexCliAuthFileApiKey, c as resolveCodexAppServerPreparedApiKeyCacheKey, d as createCodexAppServerStartupLifetime, f as getCurrentSharedClientEntry, i as fingerprintTokenAuthProfileCacheKey, l as closeRetiredSharedClientEntry, m as retireSharedCodexAppServerClientIfCurrent, n as CODEX_AUTH_JSON_FILENAME, o as readFirstNonEmptyEnv, p as getSharedCodexAppServerClientState, r as fingerprintApiKeyAuthProfileCacheKey, s as resolveCodexAppServerFallbackApiKeyCacheKey, t as CODEX_APP_SERVER_API_KEY_ENV_VARS, u as closeRetiredSharedClientEntryIfIdle, v as waitForCodexDesktopGeneration } from "./auth-cache-key-QirmgiCo.mjs";
|
|
10
|
+
import { n as resolveCodexAppServerSpawnEnv } from "./transport-stdio-Cmx94Oiy.mjs";
|
|
11
|
+
import { n as withTimeout } from "./timeout-DZF05XrR.mjs";
|
|
12
|
+
import { c as readCodexSessionMeta, n as observeCodexCatalogClient } from "./session-catalog-events-jMcYfQyd.mjs";
|
|
13
|
+
import { n as resolveCodexAppServerRuntimeOptions } from "./config-runtime-CeAhl_h4.mjs";
|
|
14
|
+
import { a as resolveCodexAppServerAuthProfileStore, i as resolveCodexAppServerAuthProfileIdForAgent, r as resolveCodexAppServerAuthProfileId, t as isCodexAppServerNativeAuthProfile } from "./auth-profile-WqZtZfXN.mjs";
|
|
15
15
|
import { isRecord } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
16
16
|
import { createHash } from "node:crypto";
|
|
17
|
+
import { isDeepStrictEqual } from "node:util";
|
|
17
18
|
import { AgentHarnessPreflightError, resolveDefaultAgentDir } from "openclaw/plugin-sdk/agent-harness-registration";
|
|
18
19
|
import { addTimerTimeoutGraceMs, resolveTimerTimeoutMs } from "openclaw/plugin-sdk/number-runtime";
|
|
19
20
|
import { runExec } from "openclaw/plugin-sdk/process-runtime";
|
|
20
21
|
import fs, { constants } from "node:fs";
|
|
21
22
|
import path from "node:path";
|
|
22
23
|
import fs$1 from "node:fs/promises";
|
|
23
|
-
import { pruneMapToMaxSize } from "openclaw/plugin-sdk/collection-runtime";
|
|
24
24
|
import { createDeferred } from "openclaw/plugin-sdk/extension-shared";
|
|
25
25
|
import { ensureAuthProfileStore, findPersistedAuthProfileCredential, refreshOAuthCredentialForRuntime, resolveApiKeyForProfile, resolvePersistedAuthProfileOwnerAgentDir } from "openclaw/plugin-sdk/agent-runtime";
|
|
26
26
|
import { AgentHarnessPreflightError as AgentHarnessPreflightError$1, embeddedAgentLog as embeddedAgentLog$1, formatErrorMessage } from "openclaw/plugin-sdk/agent-harness-runtime";
|
|
27
|
-
import { isDeepStrictEqual } from "node:util";
|
|
28
|
-
import { assertNoSymlinkParents } from "openclaw/plugin-sdk/security-runtime";
|
|
29
27
|
import { hasUsableOAuthCredential, resolveOpenAICodexAuthIdentity } from "openclaw/plugin-sdk/provider-auth";
|
|
28
|
+
import { pruneMapToMaxSize } from "openclaw/plugin-sdk/collection-runtime";
|
|
29
|
+
import { assertNoSymlinkParents } from "openclaw/plugin-sdk/security-runtime";
|
|
30
|
+
//#region extensions/codex/src/app-server/attempt-timeouts.ts
|
|
31
|
+
/**
|
|
32
|
+
* Timeout defaults and normalizers for Codex app-server startup and turn
|
|
33
|
+
* liveness watches.
|
|
34
|
+
*/
|
|
35
|
+
/** Minimum startup timeout accepted by the Codex app-server harness. */
|
|
36
|
+
const CODEX_APP_SERVER_STARTUP_TIMEOUT_FLOOR_MS = 100;
|
|
37
|
+
const TURN_TERMINAL_SETTLEMENT_TIMEOUT_MS = 12e4;
|
|
38
|
+
const TURN_FINALIZE_DRAIN_ABORT_GRACE_MS = 5e3;
|
|
39
|
+
var CodexAppServerStartupError = class extends Error {
|
|
40
|
+
constructor(reason, message = reason === "timed_out" ? "codex app-server startup timed out" : "codex app-server startup aborted") {
|
|
41
|
+
super(message);
|
|
42
|
+
this.reason = reason;
|
|
43
|
+
this.code = "CODEX_APP_SERVER_STARTUP_CANCELLED";
|
|
44
|
+
this.name = "CodexAppServerStartupError";
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
function isCodexAppServerStartupError(error, reason) {
|
|
48
|
+
return error instanceof Error && "code" in error && error.code === "CODEX_APP_SERVER_STARTUP_CANCELLED" && "reason" in error && (error.reason === "aborted" || error.reason === "timed_out") && (reason === void 0 || error.reason === reason);
|
|
49
|
+
}
|
|
50
|
+
function resolvePositiveIntegerTimeoutMs(value, fallbackMs) {
|
|
51
|
+
const fallback = resolveTimerTimeoutMs(fallbackMs, 1);
|
|
52
|
+
return resolveTimerTimeoutMs(value, fallback);
|
|
53
|
+
}
|
|
54
|
+
/** Runs startup work with abort and timeout handling plus optional cleanup. */
|
|
55
|
+
async function withCodexStartupTimeout(params) {
|
|
56
|
+
if (params.signal.aborted) throw new CodexAppServerStartupError("aborted");
|
|
57
|
+
let timeout;
|
|
58
|
+
let abortCleanup;
|
|
59
|
+
let timeoutError;
|
|
60
|
+
let timeoutCleanup;
|
|
61
|
+
try {
|
|
62
|
+
return await Promise.race([params.operation(), new Promise((_, reject) => {
|
|
63
|
+
const rejectOnce = (error) => {
|
|
64
|
+
if (timeout) {
|
|
65
|
+
clearTimeout(timeout);
|
|
66
|
+
timeout = void 0;
|
|
67
|
+
}
|
|
68
|
+
reject(error);
|
|
69
|
+
};
|
|
70
|
+
timeout = setTimeout(() => {
|
|
71
|
+
timeoutError = new CodexAppServerStartupError("timed_out");
|
|
72
|
+
timeoutCleanup = Promise.resolve(params.onTimeout?.()).then(() => void 0, () => void 0);
|
|
73
|
+
timeoutCleanup.finally(() => {
|
|
74
|
+
rejectOnce(timeoutError);
|
|
75
|
+
});
|
|
76
|
+
}, params.timeoutMs);
|
|
77
|
+
const abortListener = () => rejectOnce(new CodexAppServerStartupError("aborted"));
|
|
78
|
+
params.signal.addEventListener("abort", abortListener, { once: true });
|
|
79
|
+
abortCleanup = () => params.signal.removeEventListener("abort", abortListener);
|
|
80
|
+
})]);
|
|
81
|
+
} catch (error) {
|
|
82
|
+
if (timeoutError) {
|
|
83
|
+
await timeoutCleanup;
|
|
84
|
+
throw timeoutError;
|
|
85
|
+
}
|
|
86
|
+
throw error;
|
|
87
|
+
} finally {
|
|
88
|
+
if (timeout) clearTimeout(timeout);
|
|
89
|
+
abortCleanup?.();
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
/** Resolves startup timeout while honoring the configured floor. */
|
|
93
|
+
function resolveCodexStartupTimeoutMs(params) {
|
|
94
|
+
const timeoutFloorMs = resolvePositiveIntegerTimeoutMs(params.timeoutFloorMs, CODEX_APP_SERVER_STARTUP_TIMEOUT_FLOOR_MS);
|
|
95
|
+
const timeoutMs = resolvePositiveIntegerTimeoutMs(params.timeoutMs, timeoutFloorMs);
|
|
96
|
+
return Math.max(timeoutFloorMs, timeoutMs);
|
|
97
|
+
}
|
|
98
|
+
/** Adds gateway grace time to a caller timeout without overflowing invalid values. */
|
|
99
|
+
function resolveCodexGatewayTimeoutWithGraceMs(timeoutMs, graceMs = 1e4) {
|
|
100
|
+
const timeout = resolvePositiveIntegerTimeoutMs(timeoutMs, 1);
|
|
101
|
+
const grace = resolveTimerTimeoutMs(graceMs, 0, 0);
|
|
102
|
+
return addTimerTimeoutGraceMs(timeout, grace) ?? timeout;
|
|
103
|
+
}
|
|
104
|
+
//#endregion
|
|
30
105
|
//#region extensions/codex/src/app-server/computer-use-service-path.ts
|
|
31
106
|
/** Filesystem ownership guards for isolated Computer Use service provisioning. */
|
|
32
107
|
async function assertOwnedServicePath(params) {
|
|
@@ -238,6 +313,7 @@ async function ensureRealDirectoryCopy(cachePath, sourcePluginRoot, version, bou
|
|
|
238
313
|
let backupCreated = false;
|
|
239
314
|
try {
|
|
240
315
|
await fs$1.cp(sourcePluginRoot, stagedPath, { recursive: true });
|
|
316
|
+
await waitForCodexDesktopGeneration();
|
|
241
317
|
if (ownedParent) await assertDirectoryIdentityStable(ownedParent, "Computer Use plugin cache parent");
|
|
242
318
|
if (stat) {
|
|
243
319
|
boundary.assertCurrent?.();
|
|
@@ -523,7 +599,9 @@ async function ensureCodexComputerUseServiceAppOnce(params) {
|
|
|
523
599
|
if (!stagedIdentity || !identitiesMatch(stagedIdentity, sourceIdentity)) throw new Error(`Copied Computer Use service app at ${stagedPath} does not match its selected signed source.`);
|
|
524
600
|
const stagedSnapshot = await readServiceAppSnapshot(stagedPath, inspectServiceApp);
|
|
525
601
|
const currentSourceIdentity = await inspectServiceApp(sourcePath);
|
|
602
|
+
await waitForCodexDesktopGeneration();
|
|
526
603
|
await assertOwnedServiceParentStable(ownedParent);
|
|
604
|
+
await assertDirectoryIdentityStable(stagingRootIdentity, "Computer Use service staging directory");
|
|
527
605
|
if (!currentSourceIdentity || !identitiesMatch(currentSourceIdentity, sourceIdentity)) throw new Error("Selected Computer Use service source changed during refresh.");
|
|
528
606
|
await assertNotSymlink(operationTargetPath, "Computer Use service target");
|
|
529
607
|
if (await pathExists$1(operationTargetPath)) {
|
|
@@ -1016,7 +1094,9 @@ async function reconcileCodexComputerUseStartArtifactsOnce(params) {
|
|
|
1016
1094
|
const computerUseConfig = resolveCodexComputerUseConfig({ pluginConfig: params.pluginConfig });
|
|
1017
1095
|
const ownsIsolatedCodexHome = params.ownsIsolatedCodexHome ?? (params.startOptions.homeScope !== "user" && !params.startOptions.env?.[CODEX_HOME_ENV_VAR]?.trim());
|
|
1018
1096
|
const shouldProvisionComputerUse = computerUseConfig.enabled && computerUseConfig.autoInstall && ownsIsolatedCodexHome;
|
|
1019
|
-
|
|
1097
|
+
const provisioningAgentDir = shouldProvisionComputerUse ? params.agentDir : void 0;
|
|
1098
|
+
if (shouldProvisionComputerUse && !provisioningAgentDir) throw new Error("Managed Codex Computer Use requires an OpenClaw agent directory");
|
|
1099
|
+
if (provisioningAgentDir) await ensureOwnedCodexHome(codexHome, provisioningAgentDir);
|
|
1020
1100
|
else await fs$1.mkdir(codexHome, { recursive: true });
|
|
1021
1101
|
const desktopCandidates = resolveMacOSDesktopCodexAppPathCandidates();
|
|
1022
1102
|
const exactDesktopCandidate = desktopCandidates.find((candidate) => path.resolve(candidate.appServerCommandPath) === path.resolve(params.startOptions.command));
|
|
@@ -1027,12 +1107,12 @@ async function reconcileCodexComputerUseStartArtifactsOnce(params) {
|
|
|
1027
1107
|
needsBundledMarketplace
|
|
1028
1108
|
}) : exactDesktopCandidate;
|
|
1029
1109
|
params.assertCurrent();
|
|
1030
|
-
if (
|
|
1110
|
+
if (provisioningAgentDir) {
|
|
1031
1111
|
if (desktopCandidates.length > 0 && !artifactCandidate) throw new CodexComputerUseCandidateArtifactsUnavailableError();
|
|
1032
1112
|
try {
|
|
1033
1113
|
const marketplacePath = usesManagedBundledMarketplace ? await ensureCodexManagedBundledMarketplace({
|
|
1034
1114
|
codexHome,
|
|
1035
|
-
ownershipRoot:
|
|
1115
|
+
ownershipRoot: provisioningAgentDir,
|
|
1036
1116
|
...artifactCandidate ? {
|
|
1037
1117
|
appServerCommand: artifactCandidate.appServerCommandPath,
|
|
1038
1118
|
candidates: [artifactCandidate],
|
|
@@ -1111,11 +1191,12 @@ async function applyCodexAppServerAuthProfile(params) {
|
|
|
1111
1191
|
await assertNativeCodexAccountMatchesRoute(params.client, params.authRequirement, params.assertCurrent);
|
|
1112
1192
|
return;
|
|
1113
1193
|
}
|
|
1194
|
+
const agentDir = params.agentDir ?? resolveDefaultAgentDir(params.config ?? {});
|
|
1114
1195
|
let loginParams = params.preparedAuth?.kind === "profile" ? params.preparedAuth.snapshot.loginParams : params.preparedAuth?.kind === "api-key" ? {
|
|
1115
1196
|
type: "apiKey",
|
|
1116
1197
|
apiKey: params.preparedAuth.apiKey
|
|
1117
1198
|
} : await resolveCodexAppServerAuthProfileLoginParams({
|
|
1118
|
-
agentDir
|
|
1199
|
+
agentDir,
|
|
1119
1200
|
authProfileId: params.authProfileId ?? void 0,
|
|
1120
1201
|
authProfileStore: params.authProfileStore,
|
|
1121
1202
|
config: params.config
|
|
@@ -1462,6 +1543,65 @@ function resolveExplicitChatgptAccountId(credential) {
|
|
|
1462
1543
|
}
|
|
1463
1544
|
}
|
|
1464
1545
|
//#endregion
|
|
1546
|
+
//#region extensions/codex/src/app-server/client-thread-owner.ts
|
|
1547
|
+
function createThreadOwnerToken(threadId, onInvalidated) {
|
|
1548
|
+
const owner = {
|
|
1549
|
+
invalidated: false,
|
|
1550
|
+
invalidate: () => {
|
|
1551
|
+
if (owner.invalidated) return;
|
|
1552
|
+
owner.invalidated = true;
|
|
1553
|
+
try {
|
|
1554
|
+
onInvalidated?.();
|
|
1555
|
+
} catch (error) {
|
|
1556
|
+
embeddedAgentLog$1.warn("codex thread ownership invalidation failed", {
|
|
1557
|
+
threadId,
|
|
1558
|
+
reason: formatErrorMessage(error)
|
|
1559
|
+
});
|
|
1560
|
+
}
|
|
1561
|
+
}
|
|
1562
|
+
};
|
|
1563
|
+
return owner;
|
|
1564
|
+
}
|
|
1565
|
+
function hasThreadOwnership(runtime, threadId) {
|
|
1566
|
+
return runtime !== void 0 && !runtime.closed && (runtime.retainedThreads.get(threadId) !== void 0 || runtime.releasingThreads.get(threadId) !== void 0 || runtime.claimedThreads.get(threadId) !== void 0);
|
|
1567
|
+
}
|
|
1568
|
+
function hasSiblingThreadWork(runtime, threadId) {
|
|
1569
|
+
if (!runtime || runtime.closed) return false;
|
|
1570
|
+
if (runtime.protectedThreads.size > 0) return true;
|
|
1571
|
+
for (const [retainedThreadId, retained] of runtime.retainedThreads) if (retainedThreadId !== threadId && retained.ephemeralPolicy !== void 0) return true;
|
|
1572
|
+
for (const claimedThreadId of runtime.claimedThreads.keys()) if (claimedThreadId !== threadId) return true;
|
|
1573
|
+
return false;
|
|
1574
|
+
}
|
|
1575
|
+
function invalidateThreadOwnership(runtime, threadId) {
|
|
1576
|
+
const retainedOwner = runtime.retainedThreads.get(threadId)?.ownerToken;
|
|
1577
|
+
const claimedOwner = runtime.claimedThreads.get(threadId);
|
|
1578
|
+
const releasing = runtime.releasingThreads.get(threadId);
|
|
1579
|
+
if (releasing) releasing.invalidated = true;
|
|
1580
|
+
runtime.retainedThreads.delete(threadId);
|
|
1581
|
+
runtime.claimedThreads.delete(threadId);
|
|
1582
|
+
retainedOwner?.invalidate();
|
|
1583
|
+
claimedOwner?.invalidate();
|
|
1584
|
+
releasing?.retainedOwnerToken?.invalidate();
|
|
1585
|
+
}
|
|
1586
|
+
function forgetThreadOwnership(runtime, threadId, owner) {
|
|
1587
|
+
let forgotten = false;
|
|
1588
|
+
if (runtime.claimedThreads.get(threadId) === owner) {
|
|
1589
|
+
runtime.claimedThreads.delete(threadId);
|
|
1590
|
+
forgotten = true;
|
|
1591
|
+
}
|
|
1592
|
+
if (runtime.retainedThreads.get(threadId)?.ownerToken === owner) {
|
|
1593
|
+
runtime.retainedThreads.delete(threadId);
|
|
1594
|
+
forgotten = true;
|
|
1595
|
+
}
|
|
1596
|
+
const releasing = runtime.releasingThreads.get(threadId);
|
|
1597
|
+
if (releasing?.retainedOwnerToken === owner) {
|
|
1598
|
+
releasing.invalidated = true;
|
|
1599
|
+
forgotten = true;
|
|
1600
|
+
}
|
|
1601
|
+
if (forgotten) owner.invalidate();
|
|
1602
|
+
return forgotten;
|
|
1603
|
+
}
|
|
1604
|
+
//#endregion
|
|
1465
1605
|
//#region extensions/codex/src/app-server/rate-limit-cache.ts
|
|
1466
1606
|
const DEFAULT_CODEX_RATE_LIMIT_CACHE_MAX_AGE_MS = 6e5;
|
|
1467
1607
|
const SPARSE_ACCOUNT_METADATA_KEYS = [
|
|
@@ -1655,8 +1795,11 @@ function ensureCodexAppServerClientRuntime(client, context) {
|
|
|
1655
1795
|
clearTimeout(runtime.evictionTimer);
|
|
1656
1796
|
runtime.evictionTimer = void 0;
|
|
1657
1797
|
}
|
|
1658
|
-
|
|
1659
|
-
|
|
1798
|
+
for (const threadId of /* @__PURE__ */ new Set([
|
|
1799
|
+
...runtime.retainedThreads.keys(),
|
|
1800
|
+
...runtime.claimedThreads.keys(),
|
|
1801
|
+
...runtime.releasingThreads.keys()
|
|
1802
|
+
])) invalidateThreadOwnership(runtime, threadId);
|
|
1660
1803
|
runtime.protectedThreads.clear();
|
|
1661
1804
|
runtime.sessionMetadata.clear();
|
|
1662
1805
|
runtime.workspaceReferences.clear();
|
|
@@ -1664,6 +1807,7 @@ function ensureCodexAppServerClientRuntime(client, context) {
|
|
|
1664
1807
|
client.addRequestHandler(async (request) => {
|
|
1665
1808
|
if (request.method !== "account/chatgptAuthTokens/refresh") return;
|
|
1666
1809
|
if (runtime.context.authMode === "prepared-api-key") throw new Error("ChatGPT token refresh is unavailable for prepared Codex API-key auth.");
|
|
1810
|
+
if (!runtime.context.agentDir) throw new Error("ChatGPT token refresh requires an OpenClaw-owned auth profile.");
|
|
1667
1811
|
const previousAccountId = isJsonObject(request.params) && typeof request.params.previousAccountId === "string" ? request.params.previousAccountId.trim() || void 0 : void 0;
|
|
1668
1812
|
const authHandoff = runtime.authHandoff;
|
|
1669
1813
|
try {
|
|
@@ -1703,10 +1847,7 @@ function ensureCodexAppServerClientRuntime(client, context) {
|
|
|
1703
1847
|
if (notification.method === "thread/archived" || notification.method === "thread/deleted" || notification.method === "thread/closed") {
|
|
1704
1848
|
const threadId = notification.params?.threadId;
|
|
1705
1849
|
if (typeof threadId === "string") {
|
|
1706
|
-
|
|
1707
|
-
if (releasing) releasing.invalidated = true;
|
|
1708
|
-
runtime.retainedThreads.delete(threadId);
|
|
1709
|
-
runtime.claimedThreads.delete(threadId);
|
|
1850
|
+
invalidateThreadOwnership(runtime, threadId);
|
|
1710
1851
|
runtime.sessionMetadata.delete(threadId);
|
|
1711
1852
|
runtime.workspaceReferences.delete(threadId);
|
|
1712
1853
|
scheduleRetainedThreadEviction(client, runtime);
|
|
@@ -1747,14 +1888,18 @@ async function releaseRetainedThread(client, runtime, threadId, assertCurrent) {
|
|
|
1747
1888
|
}
|
|
1748
1889
|
runtime.retainedThreads.delete(threadId);
|
|
1749
1890
|
scheduleRetainedThreadEviction(client, runtime);
|
|
1750
|
-
const transition = {
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
|
|
1891
|
+
const transition = {
|
|
1892
|
+
retainedOwnerToken: retained.ownerToken,
|
|
1893
|
+
completion: Promise.resolve().then(() => {
|
|
1894
|
+
assertCurrent?.();
|
|
1895
|
+
return assertCurrent ? retained.release(threadId, assertCurrent) : retained.release(threadId);
|
|
1896
|
+
})
|
|
1897
|
+
};
|
|
1754
1898
|
runtime.releasingThreads.set(threadId, transition);
|
|
1755
1899
|
try {
|
|
1756
1900
|
await transition.completion;
|
|
1757
1901
|
runtime.workspaceReferences.delete(threadId);
|
|
1902
|
+
retained.ownerToken?.invalidate();
|
|
1758
1903
|
return true;
|
|
1759
1904
|
} catch (error) {
|
|
1760
1905
|
if (!runtime.closed && !transition.invalidated && runtime.releasingThreads.get(threadId) === transition && !runtime.retainedThreads.has(threadId) && !runtime.claimedThreads.has(threadId)) {
|
|
@@ -1788,14 +1933,17 @@ async function retainCodexAppServerLiveThread(client, threadId, releaseThread, c
|
|
|
1788
1933
|
const runtime = configuredClients.get(client);
|
|
1789
1934
|
if (!runtime || runtime.closed) return false;
|
|
1790
1935
|
const claimed = runtime.claimedThreads.get(threadId);
|
|
1791
|
-
|
|
1936
|
+
const ownerToken = releaseThread ? claimedThreadReleaseTokens.get(releaseThread) : void 0;
|
|
1937
|
+
if (claimed !== ownerToken || ownerToken?.invalidated) return false;
|
|
1792
1938
|
const pendingRelease = runtime.releasingThreads.get(threadId);
|
|
1793
1939
|
if (pendingRelease) {
|
|
1794
1940
|
await pendingRelease.completion;
|
|
1795
1941
|
return false;
|
|
1796
1942
|
}
|
|
1943
|
+
const previousOwner = runtime.retainedThreads.get(threadId)?.ownerToken;
|
|
1797
1944
|
runtime.retainedThreads.delete(threadId);
|
|
1798
1945
|
const retained = {
|
|
1946
|
+
ownerToken,
|
|
1799
1947
|
configFingerprint,
|
|
1800
1948
|
ephemeralPolicy,
|
|
1801
1949
|
serviceTier,
|
|
@@ -1805,6 +1953,7 @@ async function retainCodexAppServerLiveThread(client, threadId, releaseThread, c
|
|
|
1805
1953
|
})
|
|
1806
1954
|
};
|
|
1807
1955
|
runtime.retainedThreads.set(threadId, retained);
|
|
1956
|
+
if (previousOwner !== ownerToken) previousOwner?.invalidate();
|
|
1808
1957
|
try {
|
|
1809
1958
|
await evictExcessIdleThreads(client, runtime);
|
|
1810
1959
|
} catch (error) {
|
|
@@ -1834,8 +1983,8 @@ async function consumeCodexAppServerLiveThread(client, threadId, configFingerpri
|
|
|
1834
1983
|
if (!retained || configFingerprint !== void 0 && retained.configFingerprint !== configFingerprint) return;
|
|
1835
1984
|
return claimCodexAppServerThreadOwnership(client, runtime, threadId, retained);
|
|
1836
1985
|
}
|
|
1837
|
-
/** Claims an
|
|
1838
|
-
async function claimCodexAppServerLiveThread(client, threadId) {
|
|
1986
|
+
/** Claims an auto-subscription; invalidation ends the handle after replacement or release. */
|
|
1987
|
+
async function claimCodexAppServerLiveThread(client, threadId, onInvalidated) {
|
|
1839
1988
|
const runtime = configuredClients.get(client);
|
|
1840
1989
|
if (!runtime || runtime.closed || runtime.claimedThreads.has(threadId)) return;
|
|
1841
1990
|
const pendingRelease = runtime.releasingThreads.get(threadId);
|
|
@@ -1848,21 +1997,33 @@ async function claimCodexAppServerLiveThread(client, threadId) {
|
|
|
1848
1997
|
release: async (releasedThreadId, assertCurrent) => {
|
|
1849
1998
|
await unsubscribeCodexAppServerLiveThread(client, releasedThreadId, 5e3, assertCurrent);
|
|
1850
1999
|
}
|
|
1851
|
-
});
|
|
2000
|
+
}, onInvalidated);
|
|
1852
2001
|
}
|
|
1853
|
-
function claimCodexAppServerThreadOwnership(client, runtime, threadId, retained) {
|
|
2002
|
+
function claimCodexAppServerThreadOwnership(client, runtime, threadId, retained, onInvalidated) {
|
|
2003
|
+
const previousClaim = runtime.claimedThreads.get(threadId);
|
|
1854
2004
|
runtime.retainedThreads.delete(threadId);
|
|
1855
|
-
const claimed =
|
|
2005
|
+
const claimed = createThreadOwnerToken(threadId, onInvalidated);
|
|
1856
2006
|
runtime.claimedThreads.set(threadId, claimed);
|
|
2007
|
+
previousClaim?.invalidate();
|
|
2008
|
+
retained.ownerToken?.invalidate();
|
|
1857
2009
|
scheduleRetainedThreadEviction(client, runtime);
|
|
1858
2010
|
const assertCurrent = () => {
|
|
1859
|
-
if (runtime.closed || runtime.claimedThreads.get(threadId) !== claimed) throw new Error(`Codex thread subscription ownership changed: ${threadId}`);
|
|
2011
|
+
if (claimed.invalidated || runtime.closed || runtime.claimedThreads.get(threadId) !== claimed) throw new Error(`Codex thread subscription ownership changed: ${threadId}`);
|
|
1860
2012
|
};
|
|
1861
2013
|
const release = async (releasedThreadId, assertReleaseCurrent) => {
|
|
1862
|
-
if (releasedThreadId !== threadId ||
|
|
2014
|
+
if (releasedThreadId !== threadId || claimed.invalidated) {
|
|
1863
2015
|
assertReleaseCurrent?.();
|
|
1864
2016
|
return;
|
|
1865
2017
|
}
|
|
2018
|
+
if (runtime.claimedThreads.get(threadId) !== claimed) {
|
|
2019
|
+
if (runtime.retainedThreads.get(threadId)?.ownerToken === claimed) await releaseRetainedThread(client, runtime, threadId, assertReleaseCurrent);
|
|
2020
|
+
else {
|
|
2021
|
+
const pendingRelease = runtime.releasingThreads.get(threadId);
|
|
2022
|
+
if (pendingRelease?.retainedOwnerToken === claimed) await pendingRelease.completion;
|
|
2023
|
+
assertReleaseCurrent?.();
|
|
2024
|
+
}
|
|
2025
|
+
return;
|
|
2026
|
+
}
|
|
1866
2027
|
const pendingRelease = runtime.releasingThreads.get(threadId);
|
|
1867
2028
|
if (pendingRelease) {
|
|
1868
2029
|
await pendingRelease.completion;
|
|
@@ -1882,6 +2043,7 @@ function claimCodexAppServerThreadOwnership(client, runtime, threadId, retained)
|
|
|
1882
2043
|
if (runtime.claimedThreads.get(threadId) === claimed) {
|
|
1883
2044
|
runtime.claimedThreads.delete(threadId);
|
|
1884
2045
|
runtime.workspaceReferences.delete(threadId);
|
|
2046
|
+
claimed.invalidate();
|
|
1885
2047
|
}
|
|
1886
2048
|
} finally {
|
|
1887
2049
|
if (runtime.releasingThreads.get(threadId) === transition) runtime.releasingThreads.delete(threadId);
|
|
@@ -1894,18 +2056,26 @@ function claimCodexAppServerThreadOwnership(client, runtime, threadId, retained)
|
|
|
1894
2056
|
configFingerprint: retained.configFingerprint,
|
|
1895
2057
|
ephemeralPolicy: retained.ephemeralPolicy,
|
|
1896
2058
|
serviceTier: retained.serviceTier,
|
|
1897
|
-
release
|
|
2059
|
+
release,
|
|
2060
|
+
forget: () => {
|
|
2061
|
+
if (forgetThreadOwnership(runtime, threadId, claimed)) {
|
|
2062
|
+
runtime.workspaceReferences.delete(threadId);
|
|
2063
|
+
scheduleRetainedThreadEviction(client, runtime);
|
|
2064
|
+
}
|
|
2065
|
+
}
|
|
1898
2066
|
};
|
|
1899
2067
|
}
|
|
1900
2068
|
/** Distinguish active claimed ownership from an already-evicted idle subscription. */
|
|
1901
2069
|
function hasCodexAppServerLiveThread(client, threadId) {
|
|
1902
|
-
|
|
1903
|
-
return runtime !== void 0 && !runtime.closed && (runtime.retainedThreads.has(threadId) || runtime.releasingThreads.has(threadId) || runtime.claimedThreads.has(threadId));
|
|
2070
|
+
return hasThreadOwnership(configuredClients.get(client), threadId);
|
|
1904
2071
|
}
|
|
1905
2072
|
function isCodexAppServerLiveThreadClaimed(client, threadId) {
|
|
1906
2073
|
const runtime = configuredClients.get(client);
|
|
1907
2074
|
return runtime !== void 0 && !runtime.closed && runtime.claimedThreads.has(threadId);
|
|
1908
2075
|
}
|
|
2076
|
+
function hasCodexAppServerSiblingThreadWork(client, threadId) {
|
|
2077
|
+
return hasSiblingThreadWork(configuredClients.get(client), threadId);
|
|
2078
|
+
}
|
|
1909
2079
|
/** Release the exact physical subscription and finish only its observed ownership generation. */
|
|
1910
2080
|
async function unsubscribeCodexAppServerLiveThread(client, threadId, timeoutMs, assertCurrent) {
|
|
1911
2081
|
const runtime = configuredClients.get(client);
|
|
@@ -1943,9 +2113,13 @@ async function unsubscribeCodexAppServerLiveThread(client, threadId, timeoutMs,
|
|
|
1943
2113
|
await physicalRelease;
|
|
1944
2114
|
if (retained !== void 0 && runtime?.retainedThreads.get(threadId) === retained) {
|
|
1945
2115
|
runtime.retainedThreads.delete(threadId);
|
|
2116
|
+
retained.ownerToken?.invalidate();
|
|
1946
2117
|
scheduleRetainedThreadEviction(client, runtime);
|
|
1947
2118
|
}
|
|
1948
|
-
if (claimed !== void 0 && runtime?.claimedThreads.get(threadId) === claimed)
|
|
2119
|
+
if (claimed !== void 0 && runtime?.claimedThreads.get(threadId) === claimed) {
|
|
2120
|
+
runtime.claimedThreads.delete(threadId);
|
|
2121
|
+
claimed.invalidate();
|
|
2122
|
+
}
|
|
1949
2123
|
} finally {
|
|
1950
2124
|
if (ownsTransition && runtime.releasingThreads.get(threadId) === transition) runtime.releasingThreads.delete(threadId);
|
|
1951
2125
|
}
|
|
@@ -1986,81 +2160,6 @@ function protectCodexAppServerLiveThread(client, threadId) {
|
|
|
1986
2160
|
};
|
|
1987
2161
|
}
|
|
1988
2162
|
//#endregion
|
|
1989
|
-
//#region extensions/codex/src/app-server/attempt-timeouts.ts
|
|
1990
|
-
/**
|
|
1991
|
-
* Timeout defaults and normalizers for Codex app-server startup and turn
|
|
1992
|
-
* liveness watches.
|
|
1993
|
-
*/
|
|
1994
|
-
/** Minimum startup timeout accepted by the Codex app-server harness. */
|
|
1995
|
-
const CODEX_APP_SERVER_STARTUP_TIMEOUT_FLOOR_MS = 100;
|
|
1996
|
-
const TURN_TERMINAL_SETTLEMENT_TIMEOUT_MS = 12e4;
|
|
1997
|
-
const TURN_FINALIZE_DRAIN_ABORT_GRACE_MS = 5e3;
|
|
1998
|
-
var CodexAppServerStartupError = class extends Error {
|
|
1999
|
-
constructor(reason, message = reason === "timed_out" ? "codex app-server startup timed out" : "codex app-server startup aborted") {
|
|
2000
|
-
super(message);
|
|
2001
|
-
this.reason = reason;
|
|
2002
|
-
this.code = "CODEX_APP_SERVER_STARTUP_CANCELLED";
|
|
2003
|
-
this.name = "CodexAppServerStartupError";
|
|
2004
|
-
}
|
|
2005
|
-
};
|
|
2006
|
-
function isCodexAppServerStartupError(error, reason) {
|
|
2007
|
-
return error instanceof Error && "code" in error && error.code === "CODEX_APP_SERVER_STARTUP_CANCELLED" && "reason" in error && (error.reason === "aborted" || error.reason === "timed_out") && (reason === void 0 || error.reason === reason);
|
|
2008
|
-
}
|
|
2009
|
-
function resolvePositiveIntegerTimeoutMs(value, fallbackMs) {
|
|
2010
|
-
const fallback = resolveTimerTimeoutMs(fallbackMs, 1);
|
|
2011
|
-
return resolveTimerTimeoutMs(value, fallback);
|
|
2012
|
-
}
|
|
2013
|
-
/** Runs startup work with abort and timeout handling plus optional cleanup. */
|
|
2014
|
-
async function withCodexStartupTimeout(params) {
|
|
2015
|
-
if (params.signal.aborted) throw new CodexAppServerStartupError("aborted");
|
|
2016
|
-
let timeout;
|
|
2017
|
-
let abortCleanup;
|
|
2018
|
-
let timeoutError;
|
|
2019
|
-
let timeoutCleanup;
|
|
2020
|
-
try {
|
|
2021
|
-
return await Promise.race([params.operation(), new Promise((_, reject) => {
|
|
2022
|
-
const rejectOnce = (error) => {
|
|
2023
|
-
if (timeout) {
|
|
2024
|
-
clearTimeout(timeout);
|
|
2025
|
-
timeout = void 0;
|
|
2026
|
-
}
|
|
2027
|
-
reject(error);
|
|
2028
|
-
};
|
|
2029
|
-
timeout = setTimeout(() => {
|
|
2030
|
-
timeoutError = new CodexAppServerStartupError("timed_out");
|
|
2031
|
-
timeoutCleanup = Promise.resolve(params.onTimeout?.()).then(() => void 0, () => void 0);
|
|
2032
|
-
timeoutCleanup.finally(() => {
|
|
2033
|
-
rejectOnce(timeoutError);
|
|
2034
|
-
});
|
|
2035
|
-
}, params.timeoutMs);
|
|
2036
|
-
const abortListener = () => rejectOnce(new CodexAppServerStartupError("aborted"));
|
|
2037
|
-
params.signal.addEventListener("abort", abortListener, { once: true });
|
|
2038
|
-
abortCleanup = () => params.signal.removeEventListener("abort", abortListener);
|
|
2039
|
-
})]);
|
|
2040
|
-
} catch (error) {
|
|
2041
|
-
if (timeoutError) {
|
|
2042
|
-
await timeoutCleanup;
|
|
2043
|
-
throw timeoutError;
|
|
2044
|
-
}
|
|
2045
|
-
throw error;
|
|
2046
|
-
} finally {
|
|
2047
|
-
if (timeout) clearTimeout(timeout);
|
|
2048
|
-
abortCleanup?.();
|
|
2049
|
-
}
|
|
2050
|
-
}
|
|
2051
|
-
/** Resolves startup timeout while honoring the configured floor. */
|
|
2052
|
-
function resolveCodexStartupTimeoutMs(params) {
|
|
2053
|
-
const timeoutFloorMs = resolvePositiveIntegerTimeoutMs(params.timeoutFloorMs, CODEX_APP_SERVER_STARTUP_TIMEOUT_FLOOR_MS);
|
|
2054
|
-
const timeoutMs = resolvePositiveIntegerTimeoutMs(params.timeoutMs, timeoutFloorMs);
|
|
2055
|
-
return Math.max(timeoutFloorMs, timeoutMs);
|
|
2056
|
-
}
|
|
2057
|
-
/** Adds gateway grace time to a caller timeout without overflowing invalid values. */
|
|
2058
|
-
function resolveCodexGatewayTimeoutWithGraceMs(timeoutMs, graceMs = 1e4) {
|
|
2059
|
-
const timeout = resolvePositiveIntegerTimeoutMs(timeoutMs, 1);
|
|
2060
|
-
const grace = resolveTimerTimeoutMs(graceMs, 0, 0);
|
|
2061
|
-
return addTimerTimeoutGraceMs(timeout, grace) ?? timeout;
|
|
2062
|
-
}
|
|
2063
|
-
//#endregion
|
|
2064
2163
|
//#region extensions/codex/src/app-server/inference-routing.ts
|
|
2065
2164
|
const owners = defineCodexBuildState("openclaw.codexAppServerInferenceOwners", () => /* @__PURE__ */ new WeakMap())();
|
|
2066
2165
|
const MAX_ROUTES = 8;
|
|
@@ -2134,7 +2233,7 @@ async function prepareCodexInferenceRoute(params) {
|
|
|
2134
2233
|
let pending = owner.routes.get(key);
|
|
2135
2234
|
if (!pending) {
|
|
2136
2235
|
if (owner.routes.size >= MAX_ROUTES) throw new Error("Codex inference route limit reached");
|
|
2137
|
-
pending = import("./inference-proxy-
|
|
2236
|
+
pending = import("./inference-proxy-CC15HuSi.mjs").then(({ createCodexInferenceProxy }) => {
|
|
2138
2237
|
assertClient();
|
|
2139
2238
|
return createCodexInferenceProxy({
|
|
2140
2239
|
upstream: target,
|
|
@@ -2263,6 +2362,50 @@ async function waitForPreviousFence(previous, options) {
|
|
|
2263
2362
|
});
|
|
2264
2363
|
}
|
|
2265
2364
|
//#endregion
|
|
2365
|
+
//#region extensions/codex/src/app-server/native-hook-relay-state.ts
|
|
2366
|
+
const pending = /* @__PURE__ */ new Set();
|
|
2367
|
+
const closing = /* @__PURE__ */ new Set();
|
|
2368
|
+
/** Owns delayed hook-relay cleanup across runtime scheduling and test teardown. */
|
|
2369
|
+
const nativeHookRelayUnregisterQueue = {
|
|
2370
|
+
add(entry) {
|
|
2371
|
+
pending.add(entry);
|
|
2372
|
+
},
|
|
2373
|
+
delete(entry) {
|
|
2374
|
+
return pending.delete(entry);
|
|
2375
|
+
},
|
|
2376
|
+
track(operation) {
|
|
2377
|
+
closing.add(operation);
|
|
2378
|
+
operation.then(() => closing.delete(operation), () => closing.delete(operation));
|
|
2379
|
+
},
|
|
2380
|
+
async flush() {
|
|
2381
|
+
while (pending.size > 0) {
|
|
2382
|
+
const entry = pending.values().next().value;
|
|
2383
|
+
if (!entry) break;
|
|
2384
|
+
clearTimeout(entry.timeout);
|
|
2385
|
+
entry.unregister();
|
|
2386
|
+
}
|
|
2387
|
+
while (closing.size > 0) await Promise.allSettled(closing);
|
|
2388
|
+
},
|
|
2389
|
+
async clear() {
|
|
2390
|
+
for (const entry of pending) clearTimeout(entry.timeout);
|
|
2391
|
+
pending.clear();
|
|
2392
|
+
while (closing.size > 0) await Promise.allSettled(closing);
|
|
2393
|
+
}
|
|
2394
|
+
};
|
|
2395
|
+
//#endregion
|
|
2396
|
+
//#region extensions/codex/src/app-server/spawn-identity.ts
|
|
2397
|
+
/** Resolves non-secret spawn identity before startup; argv is represented only by its hash. */
|
|
2398
|
+
function resolveCodexAppServerSpawnIdentity(startOptions, resolvedNativeCommand) {
|
|
2399
|
+
const nativeCommand = resolvedNativeCommand ?? (startOptions.commandSource === "resolved-managed" ? resolveManagedCodexNativeCommand(startOptions.command) : void 0);
|
|
2400
|
+
return {
|
|
2401
|
+
command: startOptions.command,
|
|
2402
|
+
argsFingerprint: createHash("sha256").update(JSON.stringify(startOptions.args)).digest("hex"),
|
|
2403
|
+
...startOptions.commandSource ? { commandSource: startOptions.commandSource } : {},
|
|
2404
|
+
...startOptions.managedCommandOrder ? { managedCommandOrder: startOptions.managedCommandOrder } : {},
|
|
2405
|
+
...nativeCommand ? { nativeCommand } : {}
|
|
2406
|
+
};
|
|
2407
|
+
}
|
|
2408
|
+
//#endregion
|
|
2266
2409
|
//#region extensions/codex/src/app-server/thread-lifecycle-errors.ts
|
|
2267
2410
|
var CodexThreadStartRequestError = class extends Error {
|
|
2268
2411
|
constructor(cause) {
|
|
@@ -2270,6 +2413,12 @@ var CodexThreadStartRequestError = class extends Error {
|
|
|
2270
2413
|
this.name = "CodexThreadStartRequestError";
|
|
2271
2414
|
}
|
|
2272
2415
|
};
|
|
2416
|
+
var CodexThreadClientReplacementError = class extends AgentHarnessPreflightError$1 {
|
|
2417
|
+
constructor() {
|
|
2418
|
+
super("Codex did not confirm unloading its previous configuration after a settled failure; a fresh client is required.");
|
|
2419
|
+
this.name = "CodexThreadClientReplacementError";
|
|
2420
|
+
}
|
|
2421
|
+
};
|
|
2273
2422
|
var CodexThreadBindingConflictError = class extends Error {
|
|
2274
2423
|
constructor(threadId, operation) {
|
|
2275
2424
|
super(`Codex thread binding changed while ${operation}: ${threadId}`);
|
|
@@ -2305,7 +2454,6 @@ var shared_client_exports = /* @__PURE__ */ __exportAll({
|
|
|
2305
2454
|
readCodexAppServerClientProcessIdentity: () => readCodexAppServerClientProcessIdentity,
|
|
2306
2455
|
releaseCodexAppServerClientLease: () => releaseCodexAppServerClientLease,
|
|
2307
2456
|
releaseLeasedSharedCodexAppServerClient: () => releaseLeasedSharedCodexAppServerClient,
|
|
2308
|
-
resolveCodexAppServerSpawnIdentity: () => resolveCodexAppServerSpawnIdentity,
|
|
2309
2457
|
resolveCodexNativeConfigFenceKey: () => resolveCodexNativeConfigFenceKey,
|
|
2310
2458
|
retainSharedCodexAppServerClientByInstanceId: () => retainSharedCodexAppServerClientByInstanceId,
|
|
2311
2459
|
retainSharedCodexAppServerClientIfCurrent: () => retainSharedCodexAppServerClientIfCurrent,
|
|
@@ -2328,7 +2476,7 @@ async function prepareCodexAppServerClient(options) {
|
|
|
2328
2476
|
if (abandonSignal.aborted) throw new CodexAppServerStartupError("aborted", "codex app-server initialize aborted");
|
|
2329
2477
|
};
|
|
2330
2478
|
assertCurrent();
|
|
2331
|
-
const startedAt =
|
|
2479
|
+
const startedAt = performance.now();
|
|
2332
2480
|
return {
|
|
2333
2481
|
context: await withCodexAppServerAcquireDeadline(options?.timeoutMs ?? 0, ownCodexStartup(lifetime, resolveCodexAppServerClientStartContext(options)), abandonSignal),
|
|
2334
2482
|
lifetime,
|
|
@@ -2372,17 +2520,6 @@ async function waitForCodexAppServerClientDesktopGenerationDrain(params) {
|
|
|
2372
2520
|
drain.cancel();
|
|
2373
2521
|
}
|
|
2374
2522
|
}
|
|
2375
|
-
/** Resolves non-secret spawn identity before startup; argv is represented only by its hash. */
|
|
2376
|
-
function resolveCodexAppServerSpawnIdentity(startOptions, resolvedNativeCommand) {
|
|
2377
|
-
const nativeCommand = resolvedNativeCommand ?? (startOptions.commandSource === "resolved-managed" ? resolveManagedCodexNativeCommand(startOptions.command) : void 0);
|
|
2378
|
-
return {
|
|
2379
|
-
command: startOptions.command,
|
|
2380
|
-
argsFingerprint: createHash("sha256").update(JSON.stringify(startOptions.args)).digest("hex"),
|
|
2381
|
-
...startOptions.commandSource ? { commandSource: startOptions.commandSource } : {},
|
|
2382
|
-
...startOptions.managedCommandOrder ? { managedCommandOrder: startOptions.managedCommandOrder } : {},
|
|
2383
|
-
...nativeCommand ? { nativeCommand } : {}
|
|
2384
|
-
};
|
|
2385
|
-
}
|
|
2386
2523
|
var CodexAppServerStartSelectionChangedError = class extends Error {
|
|
2387
2524
|
constructor() {
|
|
2388
2525
|
super("Codex app-server managed executable selection changed during startup");
|
|
@@ -2417,8 +2554,7 @@ function resolveCodexNativeConfigFenceKey(params) {
|
|
|
2417
2554
|
const startOptions = metadata?.startOptions ?? params.startOptions;
|
|
2418
2555
|
if (!startOptions || startOptions.transport !== "stdio") return;
|
|
2419
2556
|
const configuredHome = startOptions.env?.CODEX_HOME?.trim();
|
|
2420
|
-
const
|
|
2421
|
-
const codexHome = configuredHome ? configuredHome : startOptions.homeScope === "user" ? resolveCodexAppServerUserHomeDir() : agentDir ? resolveCodexAppServerHomeDir(agentDir) : void 0;
|
|
2557
|
+
const codexHome = configuredHome ? configuredHome : startOptions.homeScope === "user" ? resolveCodexAppServerUserHomeDir() : resolveCodexAppServerHomeDir(params.agentDir ?? metadata?.agentDir ?? resolveDefaultAgentDir(params.config ?? {}));
|
|
2422
2558
|
return codexHome ? `codex-home:${path.resolve(codexHome)}` : void 0;
|
|
2423
2559
|
}
|
|
2424
2560
|
function inferAuthRequirement(preparedAuth) {
|
|
@@ -2426,8 +2562,8 @@ function inferAuthRequirement(preparedAuth) {
|
|
|
2426
2562
|
return preparedAuth?.kind === "profile" ? "subscription" : void 0;
|
|
2427
2563
|
}
|
|
2428
2564
|
async function resolveCodexAppServerClientStartContext(options) {
|
|
2429
|
-
const
|
|
2430
|
-
const
|
|
2565
|
+
const requestedStartOptions = options?.startOptions ?? resolveCodexAppServerRuntimeOptions({ pluginConfig: options?.pluginConfig }).start;
|
|
2566
|
+
const agentDir = options?.agentDir ?? (requestedStartOptions.homeScope === "user" ? void 0 : resolveDefaultAgentDir(options?.config ?? {}));
|
|
2431
2567
|
const desktopGeneration = shouldTrackDesktopGeneration(requestedStartOptions, options?.pluginConfig) ? await waitForCodexDesktopGeneration() : void 0;
|
|
2432
2568
|
const preparedAuth = options?.preparedAuth;
|
|
2433
2569
|
const preparedApiKey = preparedAuth?.kind === "api-key" ? preparedAuth.apiKey.trim() : void 0;
|
|
@@ -2527,11 +2663,11 @@ async function withLeasedCodexAppServerClientStartSelectionRetry(params) {
|
|
|
2527
2663
|
let client = params.lease.client;
|
|
2528
2664
|
if (!client) throw new Error("Codex app-server selection retry requires an active client lease");
|
|
2529
2665
|
const timeoutMs = params.options?.timeoutMs ?? 6e4;
|
|
2530
|
-
const deadline =
|
|
2666
|
+
const deadline = performance.now() + timeoutMs;
|
|
2531
2667
|
const signal = params.signal ?? params.options?.abandonSignal;
|
|
2532
2668
|
const requestOptions = () => {
|
|
2533
2669
|
if (signal?.aborted) throw new CodexAppServerStartupError("aborted", "Codex app-server selection retry aborted");
|
|
2534
|
-
const remainingTimeoutMs = deadline -
|
|
2670
|
+
const remainingTimeoutMs = deadline - performance.now();
|
|
2535
2671
|
if (remainingTimeoutMs <= 0) throw new CodexAppServerStartupError("timed_out", "Codex app-server selection retry timed out");
|
|
2536
2672
|
return {
|
|
2537
2673
|
timeoutMs: remainingTimeoutMs,
|
|
@@ -2680,7 +2816,7 @@ function buildCodexAppServerInitializeTimeoutError(client) {
|
|
|
2680
2816
|
}
|
|
2681
2817
|
function resolveRemainingAcquireTimeout(timeoutMs, startedAt) {
|
|
2682
2818
|
if (!(timeoutMs > 0)) return timeoutMs;
|
|
2683
|
-
const remaining = timeoutMs - (
|
|
2819
|
+
const remaining = timeoutMs - (performance.now() - startedAt);
|
|
2684
2820
|
if (remaining <= 0) throw new CodexAppServerStartupError("timed_out", "codex app-server initialize timed out");
|
|
2685
2821
|
return remaining;
|
|
2686
2822
|
}
|
|
@@ -2760,7 +2896,7 @@ function trackIsolatedCodexAppServerClient(client) {
|
|
|
2760
2896
|
});
|
|
2761
2897
|
}
|
|
2762
2898
|
async function startInitializedCodexAppServerClient(params) {
|
|
2763
|
-
const acquireStartedAt =
|
|
2899
|
+
const acquireStartedAt = performance.now();
|
|
2764
2900
|
const timeoutMs = params.timeoutMs ?? 0;
|
|
2765
2901
|
const abandonSignal = params.abandonSignal ? AbortSignal.any([params.lifetime.controller.signal, params.abandonSignal]) : params.lifetime.controller.signal;
|
|
2766
2902
|
const waitForStartup = (operation, timeoutMessage = CODEX_APP_SERVER_INITIALIZE_TIMEOUT_MESSAGE, timeoutErrorFactory) => {
|
|
@@ -2805,7 +2941,7 @@ async function startInitializedCodexAppServerClient(params) {
|
|
|
2805
2941
|
} finally {
|
|
2806
2942
|
artifactDrain?.cancel();
|
|
2807
2943
|
}
|
|
2808
|
-
const runtimeArtifactModule = params.runtimeArtifactMode ? await import("./runtime-artifact-
|
|
2944
|
+
const runtimeArtifactModule = params.runtimeArtifactMode ? await import("./runtime-artifact-Dy38Z5iU.mjs") : void 0;
|
|
2809
2945
|
const runtimeArtifactBeforeStart = runtimeArtifactModule ? await runtimeArtifactModule.captureCodexAppServerRuntimeArtifactBeforeStart({
|
|
2810
2946
|
startOptions,
|
|
2811
2947
|
spawnIdentity: resolveCodexAppServerSpawnIdentity(startOptions),
|
|
@@ -2847,6 +2983,10 @@ async function startInitializedCodexAppServerClient(params) {
|
|
|
2847
2983
|
}
|
|
2848
2984
|
assertStartupCurrent();
|
|
2849
2985
|
params.onInitializedClient?.();
|
|
2986
|
+
await waitForStartup(() => observeCodexCatalogClient(client, {
|
|
2987
|
+
startOptions: params.requestedStartOptions,
|
|
2988
|
+
agentDir: params.agentDir
|
|
2989
|
+
}));
|
|
2850
2990
|
let runtimeArtifact;
|
|
2851
2991
|
if (runtimeArtifactModule && runtimeArtifactBeforeStart) {
|
|
2852
2992
|
runtimeArtifact = await runtimeArtifactModule.finalizeCodexAppServerRuntimeArtifact({
|
|
@@ -2892,7 +3032,7 @@ async function startInitializedCodexAppServerClient(params) {
|
|
|
2892
3032
|
release();
|
|
2893
3033
|
throw error;
|
|
2894
3034
|
}
|
|
2895
|
-
});
|
|
3035
|
+
}, () => Boolean(retireSharedCodexAppServerClientIfCurrent(client)));
|
|
2896
3036
|
ready = true;
|
|
2897
3037
|
return client;
|
|
2898
3038
|
} finally {
|
|
@@ -2967,8 +3107,8 @@ function retainSharedCodexAppServerClientByInstanceId(clientId) {
|
|
|
2967
3107
|
function captureCodexAppServerClientLifetime(client, requiredOwnership) {
|
|
2968
3108
|
const state = getSharedCodexAppServerClientState();
|
|
2969
3109
|
const start = state.startMetadata.get(client)?.startOptions;
|
|
2970
|
-
if (requiredOwnership === "native-process" && (start?.transport !== "stdio" || isCodexAppServerProxyLaunch(start.args))) throw new AgentHarnessPreflightError("Codex
|
|
2971
|
-
const isCurrent = requiredOwnership
|
|
3110
|
+
if (requiredOwnership === "native-process" && (start?.transport !== "stdio" || isCodexAppServerProxyLaunch(start.args))) throw new AgentHarnessPreflightError("Codex manual thread adoption requires an OpenClaw-managed local stdio process, not an external socket or app-server proxy. No turn was sent; reconnect through managed local stdio before continuing.");
|
|
3111
|
+
const isCurrent = requiredOwnership !== "connection" && state.isolatedClients.has(client) ? () => state.isolatedClients.has(client) && !client.getCloseError() : captureSharedClientRegistration(client);
|
|
2972
3112
|
const assertCurrent = () => {
|
|
2973
3113
|
if (!isCurrent()) throw new CodexAdoptedThreadActiveError("Codex app-server connection changed during thread preparation; reconnect before continuing");
|
|
2974
3114
|
assertCodexAppServerClientStartSelectionCurrent({ client });
|
|
@@ -3044,6 +3184,7 @@ async function clearSharedCodexAppServerClientAndWait(options) {
|
|
|
3044
3184
|
try {
|
|
3045
3185
|
while (lifetime.pending.size > 0) await Promise.allSettled(lifetime.pending);
|
|
3046
3186
|
await closing;
|
|
3187
|
+
await nativeHookRelayUnregisterQueue.flush();
|
|
3047
3188
|
} finally {
|
|
3048
3189
|
if (state.startup === lifetime) state.startup = createCodexAppServerStartupLifetime();
|
|
3049
3190
|
}
|
|
@@ -3106,4 +3247,4 @@ function retirePendingSharedClientEntryIfUnclaimed(entry) {
|
|
|
3106
3247
|
closeRetiredSharedClientEntry(entry);
|
|
3107
3248
|
}
|
|
3108
3249
|
//#endregion
|
|
3109
|
-
export {
|
|
3250
|
+
export { assertNotSymlink as $, getCodexInferenceThread as A, prepareCodexWorkspaceReferences as B, CodexThreadBindingConflictError as C, acquireCodexNativeConfigFence as D, nativeHookRelayUnregisterQueue as E, forgetCodexWorkspaceReferences as F, unsubscribeCodexAppServerLiveThread as G, readCodexClientSessionMeta as H, hasCodexAppServerLiveThread as I, rememberCodexRateLimitsRead as J, readCodexRateLimitsRevision as K, hasCodexAppServerSiblingThreadWork as L, claimCodexAppServerLiveThread as M, consumeCodexAppServerLiveThread as N, assertCodexInferenceRouteConfig as O, ensureCodexAppServerClientRuntime as P, resolveCodexManagedBundledMarketplacePath as Q, isCodexAppServerClientRuntimeLive as R, CodexAdoptedThreadActiveError as S, CodexThreadStartRequestError as T, releaseCodexAppServerLiveThread as U, protectCodexAppServerLiveThread as V, retainCodexAppServerLiveThread as W, resolveCodexAppServerAuthAccountCacheKey as X, reconcileCodexComputerUseStartArtifacts as Y, resolveCodexAppServerPreparedAuthHandoff as Z, retainSharedCodexAppServerClientByInstanceId as _, clearSharedCodexAppServerClientIfCurrentAndUnclaimed as a, resolveCodexStartupTimeoutMs as at, waitForCodexAppServerClientDesktopGenerationDrain as b, getLeasedSharedCodexAppServerClient as c, readCodexAppServerClientDesktopGeneration as d, CodexAppServerStartupError as et, readCodexAppServerClientDesktopGenerationFingerprint as f, resolveCodexNativeConfigFenceKey as g, releaseLeasedSharedCodexAppServerClient as h, clearSharedCodexAppServerClientIfCurrent as i, resolveCodexGatewayTimeoutWithGraceMs as it, prepareCodexInferenceThreadConfig as j, bindCodexInferenceThread as k, getSharedCodexAppServerClient as l, releaseCodexAppServerClientLease as m, captureCodexAppServerClientLifetime as n, TURN_TERMINAL_SETTLEMENT_TIMEOUT_MS as nt, clearSharedCodexAppServerClientIfCurrentAndWait as o, withCodexStartupTimeout as ot, readCodexAppServerClientProcessIdentity as p, readRecentCodexRateLimits as q, captureSharedCodexAppServerCatalogLifetime as r, isCodexAppServerStartupError as rt, createIsolatedCodexAppServerClient as s, assertCodexAppServerClientStartSelectionCurrent as t, TURN_FINALIZE_DRAIN_ABORT_GRACE_MS as tt, isCodexAppServerStartSelectionChangedError as u, retainSharedCodexAppServerClientIfCurrent as v, CodexThreadClientReplacementError as w, withLeasedCodexAppServerClientStartSelectionRetry as x, shared_client_exports as y, isCodexAppServerLiveThreadClaimed as z };
|