@openclaw/codex 2026.9.1 → 2026.9.2

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.
Files changed (67) hide show
  1. package/dist/api.js +6 -6
  2. package/dist/{attempt-client-cleanup-DYHcRQAa.js → attempt-client-cleanup-Bp1ZOnk2.js} +76 -32
  3. package/dist/{attempt-context-DmQUNWwT.js → attempt-context-CSazkWns.js} +6 -6
  4. package/dist/{bounded-turn-wzJrwKKe.js → bounded-turn-DxGJRYbY.js} +46 -45
  5. package/dist/{capabilities-dIjNVCYH.js → capabilities-B1mgvpP8.js} +2 -1
  6. package/dist/cli-metadata.js +1 -1
  7. package/dist/{command-formatters-CLHhEB1Q.js → command-formatters-DSbGMXA0.js} +2 -2
  8. package/dist/{command-handlers-CTGb2csu.js → command-handlers-DOJvGv6-.js} +146 -74
  9. package/dist/{compact-_t0HQrUS.js → compact-Y_xBqrHN.js} +83 -48
  10. package/dist/{config-BhmfC1s6.js → config-CyapYSji.js} +47 -105
  11. package/dist/config-utils-C57JiJrU.js +69 -0
  12. package/dist/doctor-contract-api.js +4 -5
  13. package/dist/{dynamic-tools-BU9tmlYm.js → dynamic-tools-BwpvTxaX.js} +678 -638
  14. package/dist/{effective-mcp-catalog-DzYBW4h1.js → effective-mcp-catalog-CY9Jn4bA.js} +4 -3
  15. package/dist/{event-projector-assistant-message-DHRFXKbS.js → event-projector-assistant-message-B9kp6iGC.js} +11 -2
  16. package/dist/{event-projector-usage-C5mcrGjp.js → event-projector-usage-ZqEVbAEY.js} +30 -13
  17. package/dist/{harness-DXVZ5II5.js → harness-Czh2Sdoc.js} +36 -13
  18. package/dist/harness.js +1 -1
  19. package/dist/{image-payload-sanitizer-CnfoUPCE.js → image-payload-sanitizer-tupAr-2o.js} +29 -15
  20. package/dist/index.js +68 -84
  21. package/dist/{isolated-completion-kg9kv4iH.js → isolated-completion-CRh-51AK.js} +9 -21
  22. package/dist/{managed-binary-4-Vjz5GH.js → managed-binary-DcpnJF9x.js} +105 -73
  23. package/dist/media-understanding-provider.js +1 -1
  24. package/dist/{model-catalog-CUM68Hkl.js → model-catalog-DT5vo6qo.js} +5 -5
  25. package/dist/{models-sYnEc0gd.js → models-CcrgSMQR.js} +4 -4
  26. package/dist/{native-subagent-monitor-CnH147jH.js → native-subagent-monitor-B3bvQGcg.js} +12 -11
  27. package/dist/{node-exec-server.runtime-CstNHCmC.js → node-exec-server.runtime-nfbUOtUB.js} +3 -3
  28. package/dist/{plugin-approval-roundtrip-CNe-Xrjx.js → plugin-approval-roundtrip-aQVdyL5g.js} +1 -1
  29. package/dist/{plugin-marketplace-discovery-CfFlKqDl.js → plugin-marketplace-discovery-B7gHXJ3d.js} +35 -22
  30. package/dist/{plugin-metadata-cache-BFrPhb2c.js → plugin-metadata-cache-BwCLTY_U.js} +5 -5
  31. package/dist/{provider-capabilities-DW5p4k9w.js → provider-capabilities-BpG9Ltc5.js} +2 -2
  32. package/dist/{rate-limits-CawQJfUS.js → rate-limits-Fx_l4eNa.js} +1 -1
  33. package/dist/{request-DYAI5FQE.js → request-C8H22rPi.js} +2 -2
  34. package/dist/{run-attempt-D1hJO4fX.js → run-attempt-BzthFQSM.js} +977 -723
  35. package/dist/{runtime-artifact-C3jVimFn.js → runtime-artifact-Bh_gf6-t.js} +3 -3
  36. package/dist/{session-binding-BHuTCRZQ.js → session-binding-4Ki04sW-.js} +94 -282
  37. package/dist/session-binding-record-CyaXZvTe.js +270 -0
  38. package/dist/{session-catalog-yyvTWFOw.js → session-catalog-B47uwekb.js} +266 -114
  39. package/dist/{session-cli-CmFEXMAM.js → session-cli-BjLhpmS1.js} +1 -1
  40. package/dist/session-history-DWmMqiqW.js +93 -0
  41. package/dist/session-history-read-LHldwvyh.js +36 -0
  42. package/dist/session-history-worker-runtime.js +48 -0
  43. package/dist/{settled-turn-context-D3SNWtUn.js → session-history.worker-zZVcx0ME.js} +30 -31
  44. package/dist/session-history.worker.js +2 -0
  45. package/dist/{session-initialization-BeWzjGiR.js → session-initialization-BCFVnLL4.js} +2 -1
  46. package/dist/{session-permission-policy-DeWVTCMj.js → session-permission-policy-BaueHmSj.js} +1 -1
  47. package/dist/{session-retirement-BujDjXVF.js → session-retirement-DNdmYdFc.js} +7 -7
  48. package/dist/{session-upstream-marker-C351-5Qw.js → session-upstream-marker-DReTpGz6.js} +4 -3
  49. package/dist/settled-turn-context-BOM3Y1pl.js +45 -0
  50. package/dist/{settled-turn-finalizer-BVJx4yoc.js → settled-turn-finalizer-BI-b1sry.js} +53 -42
  51. package/dist/{shared-client-DxcfF9KX.js → shared-client-CKhX2kFt.js} +279 -268
  52. package/dist/{side-question-BTZAII4l.js → side-question-B6DWAw1A.js} +85 -36
  53. package/dist/{thread-lifecycle-DAcEJ_Om.js → thread-lifecycle-DPK30jad.js} +382 -388
  54. package/dist/{thread-ownership-zGokd8i1.js → thread-ownership-CbucAmmp.js} +5 -5
  55. package/dist/thread-policy-CTalhWFy.js +105 -0
  56. package/dist/{thread-resume-C7pyVKeW.js → thread-resume-BLgqkUc1.js} +7 -7
  57. package/dist/{transcript-mirror-DTUxFWa_.js → transcript-mirror-_njEB84z.js} +67 -125
  58. package/dist/transcript-mirror-attestation-Byl34PC-.js +76 -0
  59. package/dist/{transport-stdio-CyPldczm.js → transport-stdio-CzTngV0j.js} +10 -8
  60. package/dist/{upstream-session-fork-CYlBIGVt.js → upstream-session-fork-1fwbNKzQ.js} +85 -165
  61. package/dist/{usage-Bj-rrzkR.js → usage-i9fv5-4m.js} +3 -3
  62. package/dist/{web-search-provider.runtime-D2FWSK4w.js → web-search-provider.runtime-DKQn67A7.js} +3 -3
  63. package/package.json +6 -6
  64. package/dist/binding-connection-E6uDsPlx.js +0 -45
  65. package/dist/launch-args-RXQwn8zV.js +0 -90
  66. package/dist/session-history-C5J1AKzG.js +0 -87
  67. package/dist/thread-policy-g4KbJPzp.js +0 -54
@@ -1,7 +1,7 @@
1
- import { At as retainCodexAppServerLiveThread, Et as isCodexAppServerLiveThreadClaimed, _ as retainSharedCodexAppServerClientByInstanceId, kt as releaseCodexAppServerLiveThread } from "./shared-client-DxcfF9KX.js";
2
- import { a as closeCodexStartupClientBestEffort, d as unsubscribeCodexThreadBestEffort, r as CodexAppServerUnsafeSubscriptionError } from "./attempt-client-cleanup-DYHcRQAa.js";
3
- import { isIncognitoSessionKey } from "openclaw/plugin-sdk/routing";
1
+ import { Mt as retainCodexAppServerLiveThread, Ot as isCodexAppServerLiveThreadClaimed, _ as retainSharedCodexAppServerClientByInstanceId, jt as releaseCodexAppServerLiveThread } from "./shared-client-CKhX2kFt.js";
2
+ import { a as closeCodexStartupClientBestEffort, d as unsubscribeCodexThreadBestEffort, r as CodexAppServerUnsafeSubscriptionError } from "./attempt-client-cleanup-Bp1ZOnk2.js";
4
3
  import { resolveGlobalSingleton } from "openclaw/plugin-sdk/global-singleton";
4
+ import { isIncognitoSessionKey } from "openclaw/plugin-sdk/routing";
5
5
  import { KeyedAsyncQueue } from "openclaw/plugin-sdk/keyed-async-queue";
6
6
  //#region extensions/codex/src/app-server/thread-ownership.ts
7
7
  const nativeThreadOwners = resolveGlobalSingleton(Symbol.for("openclaw.codexNativeThreadOwners"), () => new KeyedAsyncQueue());
@@ -71,10 +71,10 @@ async function releaseCodexAppServerBindingSubscription(binding, options = {}) {
71
71
  }
72
72
  /** Clears and releases one exact conversation generation without touching its replacement. */
73
73
  async function retireCodexConversationThreadBinding(params) {
74
- const expected = await params.bindingStore.read(params.identity);
74
+ const expected = params.bindingStore.read(params.identity);
75
75
  if (!expected || params.expectedThreadId && expected.threadId !== params.expectedThreadId) return false;
76
76
  return await withCodexAppServerThreadMutation(expected.threadId, () => params.bindingStore.withLease(params.identity, async () => {
77
- const current = await params.bindingStore.read(params.identity);
77
+ const current = params.bindingStore.read(params.identity);
78
78
  if (!current || !isSameCodexAppServerThreadOwner(current, expected) || params.expectedStartId && current?.conversationStartId !== params.expectedStartId) return false;
79
79
  await releaseCodexAppServerBindingSubscription(current, { allowUntracked: params.allowUntracked });
80
80
  const cleared = await params.bindingStore.mutate(params.identity, {
@@ -0,0 +1,105 @@
1
+ import { O as readCodexPluginConfig, i as resolveCodexAppServerRuntimeOptions, s as resolveCodexSupervisionAppServerRuntimeOptions } from "./config-CyapYSji.js";
2
+ import { H as isCodexAppServerOverloadError, U as isCodexAppServerPrewriteRequestCancellationError } from "./shared-client-CKhX2kFt.js";
3
+ import { n as buildCodexAppServerConnectionFingerprint, o as resolveCodexCatalogConnectionHome } from "./thread-resume-BLgqkUc1.js";
4
+ import { r as requestCodexAppServerClientJson, t as CodexAppServerScopedRequestRejectedError } from "./request-C8H22rPi.js";
5
+ import { AgentHarnessPreflightError } from "openclaw/plugin-sdk/agent-harness-runtime";
6
+ //#region extensions/codex/src/app-server/binding-connection.ts
7
+ /** Prevents a prepared native session from becoming a fresh thread after its binding changes. */
8
+ function assertCodexSessionRuntimeOwnership(binding, expected) {
9
+ if (!expected) return;
10
+ const auth = binding?.connectionScope === "supervision" ? "native" : "host";
11
+ const hostModelChanged = expected.auth === "host" && (!expected.modelRef || binding?.model !== expected.modelRef.model || binding?.modelProvider !== expected.modelRef.provider);
12
+ if (binding?.preserveNativeModel !== true || auth !== expected.auth || hostModelChanged) throw new AgentHarnessPreflightError("Codex native session ownership is missing or changed. Reattach the original native session or create a new chat with a concrete model; no replacement thread was started.");
13
+ }
14
+ /** Requires the native model pair after a supervised pending branch has materialized. */
15
+ function requireCodexSupervisionModelSelection(binding) {
16
+ const model = binding.model?.trim();
17
+ const modelProvider = binding.modelProvider?.trim();
18
+ if (binding.connectionScope !== "supervision" || !model || !modelProvider) throw new Error("Codex supervised binding is missing its native model and provider; refusing request selection");
19
+ return {
20
+ model,
21
+ modelProvider
22
+ };
23
+ }
24
+ /** Resolves connection and auth ownership exclusively from the private thread binding. */
25
+ function resolveCodexBindingAppServerConnection(params) {
26
+ const { binding, authProfileId, ...runtimeParams } = params;
27
+ const usesSupervisionConnection = binding?.connectionScope === "supervision";
28
+ if (usesSupervisionConnection && readCodexPluginConfig(runtimeParams.pluginConfig).supervision?.enabled !== true) throw new Error("Codex supervision is disabled; refusing to open a native user-home supervised session");
29
+ let appServer = (usesSupervisionConnection ? resolveCodexSupervisionAppServerRuntimeOptions : resolveCodexAppServerRuntimeOptions)(runtimeParams);
30
+ if (usesSupervisionConnection) {
31
+ const persistedFingerprint = binding.pendingSupervisionBranch?.connectionFingerprint ?? binding.appServerRuntimeFingerprint;
32
+ const catalogHome = persistedFingerprint ? resolveCodexCatalogConnectionHome(persistedFingerprint, runtimeParams.agentDir) : void 0;
33
+ if (catalogHome) appServer = {
34
+ ...appServer,
35
+ start: {
36
+ ...appServer.start,
37
+ homeScope: "user",
38
+ env: {
39
+ ...appServer.start.env,
40
+ CODEX_HOME: catalogHome
41
+ }
42
+ }
43
+ };
44
+ const currentFingerprint = buildCodexAppServerConnectionFingerprint(appServer, runtimeParams.agentDir);
45
+ if (!persistedFingerprint || persistedFingerprint !== currentFingerprint) throw new Error("Codex supervision connection changed; refusing to operate on its bound native thread");
46
+ }
47
+ return {
48
+ appServer,
49
+ usesSupervisionConnection,
50
+ requestAuthProfileId: usesSupervisionConnection ? void 0 : authProfileId,
51
+ clientAuthProfileId: usesSupervisionConnection ? null : authProfileId
52
+ };
53
+ }
54
+ //#endregion
55
+ //#region extensions/codex/src/app-server/thread-policy.ts
56
+ /** A refusal, not a failed native write: the ephemeral conversation must stay alive. */
57
+ var CodexIncognitoPolicyChangeError = class extends AgentHarnessPreflightError {
58
+ constructor() {
59
+ super("Codex cannot change generic instructions in a live incognito conversation. No turn was sent and the conversation is preserved. Restore the previous instructions to continue it, or start a new incognito conversation for the changed policy.");
60
+ this.name = "CodexIncognitoPolicyChangeError";
61
+ }
62
+ };
63
+ /** Never replay a handoff: native persistence can precede an unsuccessful RPC response. */
64
+ var CodexThreadPolicyHandoffError = class extends AgentHarnessPreflightError {
65
+ constructor(outcome, cause) {
66
+ super(`Codex session policy handoff failed: ${cause instanceof Error ? cause.message : String(cause)}. The conversation is preserved; reconnect before retrying.`, { cause });
67
+ this.outcome = outcome;
68
+ this.name = "CodexThreadPolicyHandoffError";
69
+ }
70
+ };
71
+ /** The complete body remains generic configuration for compaction and native child inheritance. */
72
+ async function refreshCodexThreadPolicy(params) {
73
+ const text = "The following is the complete current OpenClaw-supplied generic instruction policy. It replaces earlier OpenClaw-supplied generic policy, including OpenClaw-carried workspace text and sections now absent. Independently supplied native managed, guardian, security, collaboration, and project instructions retain their authority. User requests retain their own authority.\n\n" + (params.developerInstructions === "" ? "The current OpenClaw generic policy is empty; earlier OpenClaw generic policy is withdrawn." : params.developerInstructions);
74
+ let outcome = "unknown";
75
+ try {
76
+ await requestCodexAppServerClientJson({
77
+ ...params,
78
+ method: "thread/inject_items",
79
+ requestParams: {
80
+ threadId: params.threadId,
81
+ items: [{
82
+ type: "message",
83
+ role: "developer",
84
+ content: [{
85
+ type: "input_text",
86
+ text
87
+ }]
88
+ }]
89
+ }
90
+ });
91
+ outcome = "acknowledged";
92
+ params.assertCurrent();
93
+ params.signal?.throwIfAborted();
94
+ } catch (cause) {
95
+ if (outcome !== "acknowledged" && (cause instanceof CodexAppServerScopedRequestRejectedError || isCodexAppServerPrewriteRequestCancellationError(cause) || isCodexAppServerOverloadError(cause))) outcome = "not-written";
96
+ throw new CodexThreadPolicyHandoffError(outcome, cause);
97
+ }
98
+ }
99
+ /** Native lineage classifies the exact bound thread; it never grants session authority. */
100
+ function assertCodexSupervisionThreadLineage(binding, thread) {
101
+ if (binding.connectionScope !== "supervision" || binding.pendingSupervisionBranch) return;
102
+ if (thread.id !== binding.threadId || !binding.supervisionSourceThreadId || thread.forkedFromId !== null && (typeof thread.forkedFromId !== "string" || !thread.forkedFromId.trim() || thread.forkedFromId === thread.id)) throw new Error("Codex supervision lineage could not be verified; reconnect before continuing.");
103
+ }
104
+ //#endregion
105
+ export { assertCodexSessionRuntimeOwnership as a, refreshCodexThreadPolicy as i, CodexThreadPolicyHandoffError as n, requireCodexSupervisionModelSelection as o, assertCodexSupervisionThreadLineage as r, resolveCodexBindingAppServerConnection as s, CodexIncognitoPolicyChangeError as t };
@@ -1,13 +1,13 @@
1
- import { $ as assertCodexThreadResumeResponse, H as isCodexAppServerOverloadError, M as isCodexAppServerStartupError, U as isCodexAppServerPrewriteRequestCancellationError, q as CodexAppServerRpcError, u as isCodexAppServerStartSelectionChangedError } from "./shared-client-DxcfF9KX.js";
2
- import { F as resolveCodexAppServerHomeDir, I as resolveCodexAppServerLocalHomeDir, L as resolveCodexAppServerUserHomeDir } from "./config-BhmfC1s6.js";
3
- import { d as unsubscribeCodexThreadBestEffort, i as assertCodexThreadResumeSubscription, r as CodexAppServerUnsafeSubscriptionError } from "./attempt-client-cleanup-DYHcRQAa.js";
4
- import { t as CodexAppServerScopedRequestRejectedError } from "./request-DYAI5FQE.js";
1
+ import { M as resolveCodexAppServerHomeDir, N as resolveCodexAppServerLocalHomeDir, P as resolveCodexAppServerUserHomeDir } from "./config-CyapYSji.js";
2
+ import { H as isCodexAppServerOverloadError, M as isCodexAppServerStartupError, U as isCodexAppServerPrewriteRequestCancellationError, q as CodexAppServerRpcError, tt as assertCodexThreadResumeResponse, u as isCodexAppServerStartSelectionChangedError } from "./shared-client-CKhX2kFt.js";
3
+ import { d as unsubscribeCodexThreadBestEffort, i as assertCodexThreadResumeSubscription, r as CodexAppServerUnsafeSubscriptionError } from "./attempt-client-cleanup-Bp1ZOnk2.js";
4
+ import { t as CodexAppServerScopedRequestRejectedError } from "./request-C8H22rPi.js";
5
5
  import { createRequire } from "node:module";
6
6
  import { isRecord } from "openclaw/plugin-sdk/string-coerce-runtime";
7
- import { readPluginPackageVersion } from "openclaw/plugin-sdk/extension-shared";
7
+ import { createHash } from "node:crypto";
8
8
  import { isFutureDateTimestampMs, resolveDateTimestampMs, resolveExpiresAtMsFromDurationMs } from "openclaw/plugin-sdk/number-runtime";
9
+ import { readPluginPackageVersion } from "openclaw/plugin-sdk/extension-shared";
9
10
  import { OPENCLAW_VERSION, embeddedAgentLog } from "openclaw/plugin-sdk/agent-harness-runtime";
10
- import { createHash } from "node:crypto";
11
11
  import { truncateUtf16Safe } from "openclaw/plugin-sdk/text-utility-runtime";
12
12
  //#region extensions/codex/src/app-server/app-inventory-cache.ts
13
13
  /**
@@ -472,4 +472,4 @@ async function resumeCodexAppServerThread(params) {
472
472
  return response;
473
473
  }
474
474
  //#endregion
475
- export { replaceCodexCatalogConnectionHomes as a, serializeCodexAppInventoryError as c, buildCodexPluginAppCacheKey as i, buildCodexAppServerConnectionFingerprint as n, resolveCodexCatalogConnectionHome as o, buildCodexAppServerRuntimeFingerprint as r, defaultCodexAppInventoryCache as s, resumeCodexAppServerThread as t };
475
+ export { replaceCodexCatalogConnectionHomes as a, defaultCodexAppInventoryCache as c, buildCodexPluginAppCacheKey as i, serializeCodexAppInventoryError as l, buildCodexAppServerConnectionFingerprint as n, resolveCodexCatalogConnectionHome as o, buildCodexAppServerRuntimeFingerprint as r, CodexAppInventoryCache as s, resumeCodexAppServerThread as t };
@@ -1,8 +1,9 @@
1
1
  import { i as readUpstreamUserText, n as attachUpstreamUserText, r as readMirrorIdentity, t as attachCodexMirrorIdentity } from "./upstream-prompt-provenance-LphB8slG.js";
2
- import { asOptionalRecord, normalizeOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime";
3
- import path from "node:path";
4
- import { deliverAgentHarnessUserInputPrompt, embeddedAgentLog, formatErrorMessage, projectAgentHarnessTranscriptMessageForDisplay, runAgentHarnessBeforeMessageWriteHook } from "openclaw/plugin-sdk/agent-harness-runtime";
2
+ import { i as fingerprintCodexMirrorSourceMessage, n as attachCodexMirrorAttestation, o as readCodexMirrorSourceFingerprint, r as attachCodexMirrorRunId } from "./transcript-mirror-attestation-Byl34PC-.js";
3
+ import { normalizeOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime";
5
4
  import { createHash } from "node:crypto";
5
+ import path from "node:path";
6
+ import { deliverAgentHarnessUserInputPrompt, embeddedAgentLog, formatErrorMessage, projectAgentHarnessTranscriptMessageForDisplay, restorePreparedUserTurnOperationalMetaForRuntime, runAgentHarnessBeforeMessageWriteHook } from "openclaw/plugin-sdk/agent-harness-runtime";
6
7
  import fsSync from "node:fs";
7
8
  import { truncateUtf8Prefix } from "openclaw/plugin-sdk/text-utility-runtime";
8
9
  import { withCodexSessionTranscriptMirrorWriteLock } from "openclaw/plugin-sdk/codex-session-transcript-runtime";
@@ -190,78 +191,6 @@ function projectBoundedCodexVisibleSessionHistory(entries) {
190
191
  return selectBoundedCodexHistoryTail(projected).map(({ responseItem }) => responseItem);
191
192
  }
192
193
  //#endregion
193
- //#region extensions/codex/src/app-server/transcript-mirror-attestation.ts
194
- const MIRROR_ORIGIN_META_KEY = "mirrorOrigin";
195
- const MIRROR_SOURCE_FINGERPRINT_META_KEY = "mirrorSourceFingerprint";
196
- const CODEX_APP_SERVER_MIRROR_ORIGIN = "codex-app-server";
197
- const CODEX_META_KEY = "__openclaw";
198
- function applyCodexTranscriptTaint(message, state) {
199
- if (message.role === "user") {
200
- state.tainted = false;
201
- return message;
202
- }
203
- const existing = CODEX_META_KEY in message ? message[CODEX_META_KEY] : void 0;
204
- const metadata = asOptionalRecord(existing);
205
- state.tainted ||= metadata?.turnTainted === true || metadata?.resultContentSource === "network";
206
- return message.role === "assistant" && state.tainted ? {
207
- ...message,
208
- __openclaw: {
209
- ...metadata,
210
- turnTainted: true
211
- }
212
- } : message;
213
- }
214
- function attachCodexMirrorAttestation(message, sourceFingerprint) {
215
- const existing = CODEX_META_KEY in message ? message[CODEX_META_KEY] : void 0;
216
- const baseMeta = existing && typeof existing === "object" && !Array.isArray(existing) ? existing : {};
217
- return {
218
- ...message,
219
- [CODEX_META_KEY]: {
220
- ...baseMeta,
221
- [MIRROR_ORIGIN_META_KEY]: CODEX_APP_SERVER_MIRROR_ORIGIN,
222
- ...sourceFingerprint ? { [MIRROR_SOURCE_FINGERPRINT_META_KEY]: sourceFingerprint } : {}
223
- }
224
- };
225
- }
226
- function attachCodexMirrorRunId(message, runId, terminal = false) {
227
- const existing = CODEX_META_KEY in message ? message[CODEX_META_KEY] : void 0;
228
- const { runTerminal: _staleTerminal, ...current } = asOptionalRecord(existing) ?? {};
229
- return {
230
- ...message,
231
- [CODEX_META_KEY]: {
232
- ...current,
233
- runId,
234
- ...terminal ? { runTerminal: true } : {}
235
- }
236
- };
237
- }
238
- function hasCodexMirrorOrigin(message) {
239
- const meta = CODEX_META_KEY in message ? message[CODEX_META_KEY] : void 0;
240
- return asOptionalRecord(meta)?.[MIRROR_ORIGIN_META_KEY] === CODEX_APP_SERVER_MIRROR_ORIGIN;
241
- }
242
- function readCodexMirrorSourceFingerprint(message) {
243
- const meta = CODEX_META_KEY in message ? message[CODEX_META_KEY] : void 0;
244
- if (!meta || typeof meta !== "object" || Array.isArray(meta)) return;
245
- const value = meta[MIRROR_SOURCE_FINGERPRINT_META_KEY];
246
- return typeof value === "string" && value ? value : void 0;
247
- }
248
- function serializeCodexMirrorSourceEvidence(message) {
249
- const content = "content" in message ? message.content : void 0;
250
- return JSON.stringify({
251
- role: message.role,
252
- content,
253
- ...message.role === "user" ? { upstreamUserText: readUpstreamUserText(message) } : {},
254
- ...message.role === "toolResult" ? {
255
- toolCallId: message.toolCallId,
256
- toolName: message.toolName,
257
- isError: message.isError
258
- } : {}
259
- });
260
- }
261
- function fingerprintCodexMirrorSourceMessage(message) {
262
- return createHash("sha256").update(serializeCodexMirrorSourceEvidence(message)).digest("hex").slice(0, 32);
263
- }
264
- //#endregion
265
194
  //#region extensions/codex/src/app-server/user-prompt-message.ts
266
195
  function buildSenderLabel(params) {
267
196
  const label = params.senderName ?? params.senderUsername ?? params.senderE164 ?? params.senderId;
@@ -306,6 +235,18 @@ function promptSnapshot(params, turnId, upstreamUserText) {
306
235
  async function buildResolvedCodexUserPromptMessage(params) {
307
236
  return buildFromPrepared(params, await params.userTurnTranscriptRecorder?.resolveMessage() ?? params.userTurnTranscriptRecorder?.message);
308
237
  }
238
+ async function resolveFinalCodexMirrorMessages(params) {
239
+ if (params.params.suppressNextUserMessagePersistence || !params.params.userTurnTranscriptRecorder) return params.messagesSnapshot;
240
+ const previousPrompt = params.messagesSnapshot.find((message) => message.role === "user");
241
+ const resolvedBase = attachCodexMirrorIdentity(await buildResolvedCodexUserPromptMessage(params.params), `${params.turnId}:prompt`);
242
+ const upstreamUserText = readUpstreamUserText(previousPrompt);
243
+ const resolvedPrompt = upstreamUserText ? attachUpstreamUserText(resolvedBase, upstreamUserText) : resolvedBase;
244
+ const firstUserIndex = params.messagesSnapshot.findIndex((message) => message.role === "user");
245
+ if (firstUserIndex === -1) return [resolvedPrompt, ...params.messagesSnapshot];
246
+ const messages = params.messagesSnapshot.slice();
247
+ messages[firstUserIndex] = resolvedPrompt;
248
+ return messages;
249
+ }
309
250
  //#endregion
310
251
  //#region extensions/codex/src/app-server/transcript-mirror.ts
311
252
  function isMirroredAgentMessage(message) {
@@ -350,7 +291,9 @@ async function mirrorBestEffort(params) {
350
291
  messagesSnapshot: params.result.messagesSnapshot,
351
292
  turnId: params.turnId
352
293
  });
294
+ params.assertWriteCurrent?.();
353
295
  const mirrorResult = await mirror({
296
+ assertWriteCurrent: params.assertWriteCurrent,
354
297
  agentId: params.agentId,
355
298
  sessionKey: params.sessionKey,
356
299
  sessionId: params.params.sessionId,
@@ -368,7 +311,7 @@ async function mirrorBestEffort(params) {
368
311
  config: params.params.config
369
312
  });
370
313
  for (const receipt of mirrorResult.userMessageReceipts) try {
371
- params.notifyUserMessagePersisted(receipt.message, receipt.anchor);
314
+ params.notifyUserMessagePersisted(receipt);
372
315
  } catch (error) {
373
316
  embeddedAgentLog.warn("failed to notify codex app-server user-message persistence", { error: formatErrorMessage(error) });
374
317
  }
@@ -406,26 +349,14 @@ async function mirrorBestEffort(params) {
406
349
  };
407
350
  }
408
351
  }
409
- async function resolveFinalCodexMirrorMessages(params) {
410
- if (params.params.suppressNextUserMessagePersistence || !params.params.userTurnTranscriptRecorder) return params.messagesSnapshot;
411
- const promptSnapshot = params.messagesSnapshot.find((message) => message.role === "user");
412
- const resolvedBase = attachCodexMirrorIdentity(await buildResolvedCodexUserPromptMessage(params.params), `${params.turnId}:prompt`);
413
- const upstreamUserText = readUpstreamUserText(promptSnapshot);
414
- const resolvedPrompt = upstreamUserText ? attachUpstreamUserText(resolvedBase, upstreamUserText) : resolvedBase;
415
- const firstUserIndex = params.messagesSnapshot.findIndex((message) => message.role === "user");
416
- if (firstUserIndex === -1) return [resolvedPrompt, ...params.messagesSnapshot];
417
- const messages = params.messagesSnapshot.slice();
418
- messages[firstUserIndex] = resolvedPrompt;
419
- return messages;
420
- }
421
352
  function createCodexAppServerUserMessagePersistenceNotifier(runParams) {
422
353
  let notified = false;
423
- return (message, anchor) => {
354
+ return (receipt) => {
424
355
  if (notified) return;
425
356
  notified = true;
426
- runParams.userTurnTranscriptRecorder?.markRuntimePersisted(message, anchor);
357
+ runParams.userTurnTranscriptRecorder?.markRuntimePersisted(receipt.message, receipt.anchor, receipt);
427
358
  try {
428
- runParams.onUserMessagePersisted?.(message);
359
+ runParams.onUserMessagePersisted?.(receipt.message);
429
360
  } catch (error) {
430
361
  embeddedAgentLog.warn("codex app-server user persistence notification failed", { error: formatErrorMessage(error) });
431
362
  }
@@ -439,7 +370,8 @@ async function mirrorPromptAtTurnStartBestEffort(params) {
439
370
  hidden: params.params.trigger === "memory",
440
371
  message: attachUpstreamUserText(attachCodexMirrorIdentity(await buildResolvedCodexUserPromptMessage(params.params), `${params.turnId}:prompt`), params.upstreamUserText)
441
372
  });
442
- if (params.params.userTurnTranscriptRecorder?.getAdmissionReceipt()) {
373
+ const recorder = params.params.userTurnTranscriptRecorder;
374
+ if (recorder?.getAdmissionReceipt() && recorder.getPersistedMessage?.()?.display !== false) {
443
375
  const annotate = params.params.hostCapabilities.annotateCurrentUserTurn;
444
376
  if (!annotate || userPromptMessage.role !== "user") throw new Error("current host admission is unavailable for native prompt annotation");
445
377
  await annotate({
@@ -462,7 +394,7 @@ async function mirrorPromptAtTurnStartBestEffort(params) {
462
394
  runMirrorIdentityPrefix: `${params.turnId}:`,
463
395
  config: params.params.config
464
396
  });
465
- for (const receipt of mirrorResult.userMessageReceipts) params.notifyUserMessagePersisted(receipt.message, receipt.anchor);
397
+ for (const receipt of mirrorResult.userMessageReceipts) params.notifyUserMessagePersisted(receipt);
466
398
  })();
467
399
  params.params.userTurnTranscriptRecorder?.markRuntimePersistencePending(mirrorPromise);
468
400
  await mirrorPromise;
@@ -491,8 +423,7 @@ async function mirror(params) {
491
423
  assistantMirrorIdentitiesOwned: [],
492
424
  anchorsByMirrorIdentity: /* @__PURE__ */ new Map(),
493
425
  messagesPresent: [],
494
- userMessageReceipts: [],
495
- userMessagesPresent: []
426
+ userMessageReceipts: []
496
427
  };
497
428
  const candidates = messages.map((message) => {
498
429
  const dedupeIdentity = buildMirrorDedupeIdentity(message);
@@ -506,28 +437,32 @@ async function mirror(params) {
506
437
  });
507
438
  const candidateIdempotencyKeys = candidates.flatMap(({ idempotencyKey }) => idempotencyKey ? [idempotencyKey] : []);
508
439
  const transcriptTarget = resolveCodexMirrorTranscriptTarget(params);
509
- params.assertCurrent?.();
440
+ const assertWritable = () => {
441
+ params.assertCurrent?.();
442
+ params.assertWriteCurrent?.();
443
+ };
444
+ assertWritable();
510
445
  const mirrorBatch = await withCodexSessionTranscriptMirrorWriteLock({
511
446
  ...transcriptTarget,
512
447
  config: params.config
513
448
  }, async (transcript) => {
514
- params.assertCurrent?.();
449
+ assertWritable();
515
450
  const nextAppendedUpdates = [];
516
451
  const nextAssistantMirrorIdentitiesAppended = /* @__PURE__ */ new Set();
517
452
  const nextAssistantMirrorIdentitiesOwned = /* @__PURE__ */ new Set();
518
453
  const nextAnchorsByMirrorIdentity = /* @__PURE__ */ new Map();
519
454
  const nextMessagesPresent = [];
520
455
  const nextUserMessageReceipts = [];
521
- const nextUserMessagesPresent = [];
522
456
  const mirrorFacts = await transcript.readMessageFacts({ idempotencyKeys: candidateIdempotencyKeys });
523
- params.assertCurrent?.();
457
+ assertWritable();
524
458
  for (const { dedupeIdentity, idempotencyKey, message, sourceFingerprint } of candidates) {
525
459
  const mirrorIdentity = readMirrorIdentity(message);
526
460
  const ownsRun = Boolean(params.runId && (!params.runMirrorIdentityPrefix || mirrorIdentity?.startsWith(params.runMirrorIdentityPrefix)));
527
461
  const terminalOwner = params.terminalAssistantOwner;
528
462
  const ownsTerminal = Boolean(ownsRun && terminalOwner && mirrorIdentity === terminalOwner.mirrorIdentity);
463
+ const ownedMessage = ownsRun && params.runId ? attachCodexMirrorRunId(message, params.runId, ownsTerminal) : message;
529
464
  const transcriptMessage = {
530
- ...attachCodexMirrorAttestation(ownsRun && params.runId ? attachCodexMirrorRunId(message, params.runId, ownsTerminal) : message, sourceFingerprint),
465
+ ...attachCodexMirrorAttestation(ownedMessage, sourceFingerprint),
531
466
  ...idempotencyKey ? { idempotencyKey } : {}
532
467
  };
533
468
  if (idempotencyKey && mirrorFacts.existingIdempotencyKeys.has(idempotencyKey)) {
@@ -535,18 +470,25 @@ async function mirror(params) {
535
470
  const persistedAnchor = mirrorFacts.anchorsByIdempotencyKey.get(idempotencyKey);
536
471
  if (persistedMessage && isMirroredAgentMessage(persistedMessage)) {
537
472
  nextMessagesPresent.push(persistedMessage);
538
- if (persistedMessage.role === "user") {
539
- nextUserMessagesPresent.push(persistedMessage);
540
- if (persistedAnchor) nextUserMessageReceipts.push({
541
- anchor: persistedAnchor,
542
- message: persistedMessage
543
- });
544
- }
473
+ if (persistedMessage.role === "user" && persistedAnchor) nextUserMessageReceipts.push({
474
+ anchor: persistedAnchor,
475
+ appended: false,
476
+ message: persistedMessage
477
+ });
545
478
  }
546
479
  if (persistedAnchor) nextAnchorsByMirrorIdentity.set(dedupeIdentity, persistedAnchor);
547
480
  if (message.role === "assistant") nextAssistantMirrorIdentitiesOwned.add(dedupeIdentity);
548
481
  continue;
549
482
  }
483
+ assertWritable();
484
+ const preparedUserMessage = transcriptMessage.role === "user" ? {
485
+ ...transcriptMessage,
486
+ __openclaw: { ...Reflect.get(transcriptMessage, "__openclaw") }
487
+ } : void 0;
488
+ if (preparedUserMessage?.["__openclaw"].humanMentions !== void 0) {
489
+ preparedUserMessage.content = structuredClone(preparedUserMessage.content);
490
+ preparedUserMessage["__openclaw"].humanMentions = structuredClone(preparedUserMessage["__openclaw"].humanMentions);
491
+ }
550
492
  const nextMessage = runAgentHarnessBeforeMessageWriteHook({
551
493
  message: transcriptMessage,
552
494
  agentId: params.agentId,
@@ -558,10 +500,14 @@ async function mirror(params) {
558
500
  if (message.role === "assistant") nextAssistantMirrorIdentitiesOwned.add(dedupeIdentity);
559
501
  continue;
560
502
  }
503
+ const restoredMessage = restorePreparedUserTurnOperationalMetaForRuntime({
504
+ runtimeMessage: nextMessage,
505
+ preparedMessage: preparedUserMessage
506
+ });
561
507
  let messageToAppend = idempotencyKey ? {
562
- ...attachCodexMirrorAttestation(nextMessage, sourceFingerprint),
508
+ ...attachCodexMirrorAttestation(restoredMessage, sourceFingerprint),
563
509
  idempotencyKey
564
- } : attachCodexMirrorAttestation(nextMessage, sourceFingerprint);
510
+ } : attachCodexMirrorAttestation(restoredMessage, sourceFingerprint);
565
511
  if (mirrorIdentity) messageToAppend = attachCodexMirrorIdentity(messageToAppend, mirrorIdentity);
566
512
  if (ownsRun && params.runId) messageToAppend = attachCodexMirrorRunId(messageToAppend, params.runId, ownsTerminal);
567
513
  if (message.role === "assistant" && message.openclawAsyncDelivery) messageToAppend = Object.assign(messageToAppend, { openclawAsyncDelivery: { itemId: message.openclawAsyncDelivery.itemId } });
@@ -569,11 +515,11 @@ async function mirror(params) {
569
515
  hidden: message.display === false,
570
516
  message: messageToAppend
571
517
  });
572
- params.assertCurrent?.();
518
+ assertWritable();
573
519
  const { messageSeq, result: appended } = await transcript.appendMessageWithMessageSequence({
574
520
  message: messageToAppend,
575
- ...params.assertCurrent ? { prepareMessageAfterIdempotencyCheck: (preparedMessage) => {
576
- params.assertCurrent?.();
521
+ ...params.assertCurrent || params.assertWriteCurrent ? { prepareMessageAfterIdempotencyCheck: (preparedMessage) => {
522
+ assertWritable();
577
523
  return preparedMessage;
578
524
  } } : {},
579
525
  idempotencyLookup: "scan",
@@ -588,13 +534,11 @@ async function mirror(params) {
588
534
  }
589
535
  if (message.role === "assistant") nextAssistantMirrorIdentitiesOwned.add(dedupeIdentity);
590
536
  if (appended.anchor) nextAnchorsByMirrorIdentity.set(dedupeIdentity, appended.anchor);
591
- if (appendedMessage.role === "user" && appended.anchor) {
592
- nextUserMessagesPresent.push(appendedMessage);
593
- nextUserMessageReceipts.push({
594
- anchor: appended.anchor,
595
- message: appendedMessage
596
- });
597
- }
537
+ if (appendedMessage.role === "user" && appended.anchor) nextUserMessageReceipts.push({
538
+ anchor: appended.anchor,
539
+ appended: appended.appended,
540
+ message: appendedMessage
541
+ });
598
542
  if (appended.appended) {
599
543
  if (message.role === "assistant") nextAssistantMirrorIdentitiesAppended.add(dedupeIdentity);
600
544
  nextAppendedUpdates.push({
@@ -614,12 +558,11 @@ async function mirror(params) {
614
558
  assistantMirrorIdentitiesOwned: [...nextAssistantMirrorIdentitiesOwned],
615
559
  anchorsByMirrorIdentity: nextAnchorsByMirrorIdentity,
616
560
  messagesPresent: nextMessagesPresent,
617
- userMessageReceipts: nextUserMessageReceipts,
618
- userMessagesPresent: nextUserMessagesPresent
561
+ userMessageReceipts: nextUserMessageReceipts
619
562
  };
620
563
  });
621
564
  params.assertCurrent?.();
622
- const { appendedUpdates, assistantMirrorIdentitiesAppended, assistantMirrorIdentitiesOwned, anchorsByMirrorIdentity, messagesPresent, userMessageReceipts, userMessagesPresent } = mirrorBatch;
565
+ const { appendedUpdates, assistantMirrorIdentitiesAppended, assistantMirrorIdentitiesOwned, anchorsByMirrorIdentity, messagesPresent, userMessageReceipts } = mirrorBatch;
623
566
  for (const update of appendedUpdates) try {
624
567
  const terminalOwner = params.terminalAssistantOwner;
625
568
  const terminalRunId = update.message.role === "assistant" && terminalOwner && readMirrorIdentity(update.message) === terminalOwner.mirrorIdentity ? terminalOwner.runId : void 0;
@@ -642,8 +585,7 @@ async function mirror(params) {
642
585
  assistantMirrorIdentitiesOwned,
643
586
  anchorsByMirrorIdentity,
644
587
  messagesPresent,
645
- userMessageReceipts,
646
- userMessagesPresent
588
+ userMessageReceipts
647
589
  };
648
590
  }
649
591
  async function deliverAsyncMessageBestEffort(params) {
@@ -728,4 +670,4 @@ function resolveCodexMirrorTranscriptTarget(params) {
728
670
  };
729
671
  }
730
672
  //#endregion
731
- export { buildCodexUserPromptMessage as a, fingerprintCodexMirrorSourceMessage as c, serializeCodexMirrorSourceEvidence as d, projectBoundedCodexThreadHistory as f, codexCatalogHomeId as g, canonicalCodexCatalogHome as h, mirrorPromptAtTurnStartBestEffort as i, hasCodexMirrorOrigin as l, projectCodexUserItemText as m, createCodexAppServerUserMessagePersistenceNotifier as n, promptSnapshot as o, projectBoundedCodexVisibleSessionHistory as p, importCodexThreadHistoryToTranscript as r, applyCodexTranscriptTaint as s, codexTranscriptMirrorRuntime as t, readCodexMirrorSourceFingerprint as u };
673
+ export { buildCodexUserPromptMessage as a, projectBoundedCodexVisibleSessionHistory as c, codexCatalogHomeId as d, mirrorPromptAtTurnStartBestEffort as i, projectCodexUserItemText as l, createCodexAppServerUserMessagePersistenceNotifier as n, promptSnapshot as o, importCodexThreadHistoryToTranscript as r, projectBoundedCodexThreadHistory as s, codexTranscriptMirrorRuntime as t, canonicalCodexCatalogHome as u };
@@ -0,0 +1,76 @@
1
+ import { i as readUpstreamUserText } from "./upstream-prompt-provenance-LphB8slG.js";
2
+ import { asOptionalRecord } from "openclaw/plugin-sdk/string-coerce-runtime";
3
+ import { createHash } from "node:crypto";
4
+ //#region extensions/codex/src/app-server/transcript-mirror-attestation.ts
5
+ const MIRROR_ORIGIN_META_KEY = "mirrorOrigin";
6
+ const MIRROR_SOURCE_FINGERPRINT_META_KEY = "mirrorSourceFingerprint";
7
+ const CODEX_APP_SERVER_MIRROR_ORIGIN = "codex-app-server";
8
+ const CODEX_META_KEY = "__openclaw";
9
+ function applyCodexTranscriptTaint(message, state) {
10
+ if (message.role === "user") {
11
+ state.tainted = false;
12
+ return message;
13
+ }
14
+ const existing = CODEX_META_KEY in message ? message[CODEX_META_KEY] : void 0;
15
+ const metadata = asOptionalRecord(existing);
16
+ state.tainted ||= metadata?.turnTainted === true || metadata?.resultContentSource === "network";
17
+ return message.role === "assistant" && state.tainted ? {
18
+ ...message,
19
+ __openclaw: {
20
+ ...metadata,
21
+ turnTainted: true
22
+ }
23
+ } : message;
24
+ }
25
+ function attachCodexMirrorAttestation(message, sourceFingerprint) {
26
+ const existing = CODEX_META_KEY in message ? message[CODEX_META_KEY] : void 0;
27
+ const baseMeta = existing && typeof existing === "object" && !Array.isArray(existing) ? existing : {};
28
+ return {
29
+ ...message,
30
+ [CODEX_META_KEY]: {
31
+ ...baseMeta,
32
+ [MIRROR_ORIGIN_META_KEY]: CODEX_APP_SERVER_MIRROR_ORIGIN,
33
+ ...sourceFingerprint ? { [MIRROR_SOURCE_FINGERPRINT_META_KEY]: sourceFingerprint } : {}
34
+ }
35
+ };
36
+ }
37
+ function attachCodexMirrorRunId(message, runId, terminal = false) {
38
+ const existing = CODEX_META_KEY in message ? message[CODEX_META_KEY] : void 0;
39
+ const { runTerminal: _staleTerminal, ...current } = asOptionalRecord(existing) ?? {};
40
+ return {
41
+ ...message,
42
+ [CODEX_META_KEY]: {
43
+ ...current,
44
+ runId,
45
+ ...terminal ? { runTerminal: true } : {}
46
+ }
47
+ };
48
+ }
49
+ function hasCodexMirrorOrigin(message) {
50
+ const meta = CODEX_META_KEY in message ? message[CODEX_META_KEY] : void 0;
51
+ return asOptionalRecord(meta)?.[MIRROR_ORIGIN_META_KEY] === CODEX_APP_SERVER_MIRROR_ORIGIN;
52
+ }
53
+ function readCodexMirrorSourceFingerprint(message) {
54
+ const meta = CODEX_META_KEY in message ? message[CODEX_META_KEY] : void 0;
55
+ if (!meta || typeof meta !== "object" || Array.isArray(meta)) return;
56
+ const value = meta[MIRROR_SOURCE_FINGERPRINT_META_KEY];
57
+ return typeof value === "string" && value ? value : void 0;
58
+ }
59
+ function serializeCodexMirrorSourceEvidence(message) {
60
+ const content = "content" in message ? message.content : void 0;
61
+ return JSON.stringify({
62
+ role: message.role,
63
+ content,
64
+ ...message.role === "user" ? { upstreamUserText: readUpstreamUserText(message) } : {},
65
+ ...message.role === "toolResult" ? {
66
+ toolCallId: message.toolCallId,
67
+ toolName: message.toolName,
68
+ isError: message.isError
69
+ } : {}
70
+ });
71
+ }
72
+ function fingerprintCodexMirrorSourceMessage(message) {
73
+ return createHash("sha256").update(serializeCodexMirrorSourceEvidence(message)).digest("hex").slice(0, 32);
74
+ }
75
+ //#endregion
76
+ export { hasCodexMirrorOrigin as a, fingerprintCodexMirrorSourceMessage as i, attachCodexMirrorAttestation as n, readCodexMirrorSourceFingerprint as o, attachCodexMirrorRunId as r, serializeCodexMirrorSourceEvidence as s, applyCodexTranscriptTaint as t };
@@ -1,8 +1,8 @@
1
- import { n as normalizeCodexAppServerArgs } from "./launch-args-RXQwn8zV.js";
2
- import { readFile, readdir } from "node:fs/promises";
1
+ import { p as normalizeCodexAppServerArgs } from "./managed-binary-DcpnJF9x.js";
3
2
  import { createHash, randomUUID } from "node:crypto";
4
- import { materializeWindowsSpawnProgram, resolveWindowsSpawnProgram } from "openclaw/plugin-sdk/windows-spawn";
5
3
  import { z } from "zod";
4
+ import { readFile, readdir } from "node:fs/promises";
5
+ import { materializeWindowsSpawnProgram, resolveWindowsSpawnProgram } from "openclaw/plugin-sdk/windows-spawn";
6
6
  import { execFile, spawn } from "node:child_process";
7
7
  import { once } from "node:events";
8
8
  import { setImmediate } from "node:timers/promises";
@@ -407,6 +407,7 @@ function signalProcess(pid, signal) {
407
407
  }
408
408
  //#endregion
409
409
  //#region extensions/codex/src/app-server/transport-process-registration.ts
410
+ const PROCESS_REGISTRATION_INSPECTION_MS = 1e4;
410
411
  const processIdentity = z.object({
411
412
  pid: z.number().int().positive().safe(),
412
413
  pgid: z.number().int().positive().safe(),
@@ -428,13 +429,13 @@ async function openProcessRegistrationStore() {
428
429
  overflowPolicy: "reject-new"
429
430
  });
430
431
  }
431
- async function reapRegisteredCodexAppServerOrphans(requestedDeadline) {
432
+ async function reapRegisteredCodexAppServerOrphans() {
432
433
  const store = await openProcessRegistrationStore();
433
- const deadline = requestedDeadline ?? Date.now() + 1e4;
434
+ const deadline = Date.now() + PROCESS_REGISTRATION_INSPECTION_MS;
434
435
  for (const entry of store.entries()) {
435
436
  if (Date.now() >= deadline) throw new Error("Codex orphan cleanup exceeded its startup budget. Retry to finish cleanup.");
436
437
  const registration = registrationSchema.parse(entry.value);
437
- const snapshot = await readCodexAppServerProcessSnapshot(void 0, [registration.parent.pid, registration.child.pid]);
438
+ const snapshot = await readCodexAppServerProcessSnapshot(deadline, [registration.parent.pid, registration.child.pid]);
438
439
  const parent = snapshot.find((row) => row.pid === registration.parent.pid);
439
440
  if (parent?.startedAt === registration.parent.startedAt && !parent.state.startsWith("Z")) continue;
440
441
  const child = snapshot.find((row) => row.pid === registration.child.pid);
@@ -479,11 +480,12 @@ async function prepareCodexAppServerProcessRegistration() {
479
480
  return async (child) => {
480
481
  await once(child, "spawn");
481
482
  if (!child.pid) throw new ProcessInspectionError("unavailable");
482
- const snapshot = await readCodexAppServerProcessSnapshot(void 0, [child.pid]);
483
+ const deadline = Date.now() + PROCESS_REGISTRATION_INSPECTION_MS;
484
+ const snapshot = await readCodexAppServerProcessSnapshot(deadline, [child.pid]);
483
485
  const parent = snapshot.find((row) => row.pid === process.pid);
484
486
  const spawned = snapshot.find((row) => row.pid === child.pid);
485
487
  if (!parent || !spawned || spawned.ppid !== process.pid) throw new Error("Cannot register the Codex child process: its direct-parent identity is unavailable. Retry.");
486
- const command = await readCodexAppServerProcessCommand(spawned, Date.now() + 2e3);
488
+ const command = await readCodexAppServerProcessCommand(spawned, deadline);
487
489
  if (child.exitCode !== null || child.signalCode !== null) throw new Error("Cannot register the Codex child process command: the child exited during inspection. Retry.");
488
490
  const key = randomUUID();
489
491
  store.register(key, {