@openclaw/codex 2026.9.5 → 2026.9.6

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 (120) hide show
  1. package/dist/.setup/{account-usage-runtime-C2MOIvfq.mjs → account-usage-runtime-Eem_WGqY.mjs} +5 -5
  2. package/dist/.setup/{apply-CJ0ZfmBG.mjs → apply-DDOi8uNx.mjs} +22 -28
  3. package/dist/.setup/{attempt-client-cleanup-BpYKdTA0.mjs → attempt-client-cleanup-CEv1cKwF.mjs} +58 -43
  4. package/dist/.setup/attempt-workspace-context-DUVEn_CS.mjs +331 -0
  5. package/dist/.setup/{auth-cache-key-QirmgiCo.mjs → auth-cache-key-B2mpaI9D.mjs} +9 -81
  6. package/dist/.setup/auth-profile-health-oHizqgye.mjs +53 -0
  7. package/dist/.setup/auth-profile-recovery-BREezV0L.mjs +14 -0
  8. package/dist/.setup/{binding-connection-Bm38niE8.mjs → binding-connection-ThoatDcb.mjs} +1 -1
  9. package/dist/.setup/{binding-connection.runtime-CnRMC0ta.mjs → binding-connection.runtime-yoHrABt-.mjs} +4 -4
  10. package/dist/.setup/{bounded-turn-BtlZcivC.mjs → bounded-turn-B2HScEgT.mjs} +138 -32
  11. package/dist/.setup/{build-state-Xx9ybZqa.mjs → build-state-C7EnDVgr.mjs} +1 -1
  12. package/dist/.setup/{capabilities-_vXcZGSx.mjs → capabilities-CDXOOFdZ.mjs} +1 -1
  13. package/dist/.setup/{client-vXs2929Q.mjs → client-Cs08OXVQ.mjs} +583 -559
  14. package/dist/.setup/client-catalog-response-BMgt_4q4.mjs +285 -0
  15. package/dist/.setup/{command-dispatch-naHIZwwF.mjs → command-dispatch-B4JuOsOk.mjs} +8 -4
  16. package/dist/.setup/{command-formatters-CGEkdawF.mjs → command-formatters-Bmqvr9tO.mjs} +8 -4
  17. package/dist/.setup/{command-handlers-BtAJEW1X.mjs → command-handlers-DW7Lx9oH.mjs} +106 -172
  18. package/dist/.setup/{command-rpc-DHFpn4le.mjs → command-rpc-DixIj3HW.mjs} +36 -21
  19. package/dist/.setup/{compact-C3i3qlzj.mjs → compact-Du5UvtxA.mjs} +14 -21
  20. package/dist/.setup/{config-CedDWjM-.mjs → config-BoTP_mrL.mjs} +3 -3
  21. package/dist/.setup/{config-options-BsanJ8QG.mjs → config-options-BvaRs51b.mjs} +46 -30
  22. package/dist/.setup/{config-runtime-CeAhl_h4.mjs → config-runtime-C8Rw1m1m.mjs} +1 -1
  23. package/dist/.setup/{config-security-BRQ2mgW9.mjs → config-security-BEReZ6go.mjs} +35 -120
  24. package/dist/.setup/{conversation-binding-DhzrpTM6.mjs → conversation-binding-DP-gMrBP.mjs} +21 -32
  25. package/dist/.setup/{conversation-control-DN53ns41.mjs → conversation-control-uK9Jomlc.mjs} +28 -67
  26. package/dist/.setup/{dynamic-tools-D16lOp67.mjs → dynamic-tools-BDXl-8Cw.mjs} +848 -578
  27. package/dist/.setup/{effective-mcp-catalog-K6kLCN8X.mjs → effective-mcp-catalog-CvnvnGIe.mjs} +3 -3
  28. package/dist/.setup/{ephemeral-turn-R1gA8Sn6.mjs → ephemeral-turn-poidXgek.mjs} +9 -6
  29. package/dist/.setup/{event-projector-assistant-message-DNUR1s0A.mjs → event-projector-assistant-message-BsruvNrH.mjs} +2 -4
  30. package/dist/.setup/{event-projector-items-DyTQ_XqL.mjs → event-projector-items-C6L_5ZiT.mjs} +42 -8
  31. package/dist/.setup/{event-projector-usage-C7Ntzs-f.mjs → event-projector-usage-CnBS8Wa3.mjs} +1 -1
  32. package/dist/.setup/{harness-rxaaoN-o.mjs → harness-a_MsE4-_.mjs} +23 -17
  33. package/dist/.setup/{inference-context-fulhZuz8.mjs → inference-context-D96l9-ew.mjs} +1 -1
  34. package/dist/.setup/inference-proxy-b-aJMSxm.mjs +601 -0
  35. package/dist/.setup/{isolated-completion-B6srt48J.mjs → isolated-completion-BIZFhTNG.mjs} +17 -10
  36. package/dist/.setup/launch-args-DbFCehO7.mjs +196 -0
  37. package/dist/.setup/{managed-binary-DP6Rib3P.mjs → managed-binary-BnshlFag.mjs} +13 -2
  38. package/dist/.setup/{model-catalog-DkvUuBey.mjs → model-catalog-CfXJf9Ay.mjs} +9 -10
  39. package/dist/.setup/{models-BDFgm_G-.mjs → models-KnqBv0hE.mjs} +3 -3
  40. package/dist/.setup/{native-auth-BLZGqFjw.mjs → native-auth-rWbGbMn3.mjs} +4 -4
  41. package/dist/.setup/{native-subagent-history-YXaL6dMd.mjs → native-subagent-history-0nYYgo0k.mjs} +26 -13
  42. package/dist/.setup/{native-subagent-monitor-B1hxzIOy.mjs → native-subagent-monitor-D3filLY2.mjs} +145 -317
  43. package/dist/.setup/{native-subagent-task-ids-DsuOonKv.mjs → native-subagent-task-ids-wb8CKZGN.mjs} +69 -39
  44. package/dist/.setup/{node-cli-sessions-Cl8b2ZF3.mjs → node-cli-sessions-r3avj02l.mjs} +86 -68
  45. package/dist/.setup/node-exec-server.runtime-BDwWXVpK.mjs +247 -0
  46. package/dist/.setup/{plan-xD7WKYTM.mjs → plan-CN3VwfNU.mjs} +74 -76
  47. package/dist/.setup/{plugin-activation-r8nq5Jzp.mjs → plugin-activation-DT3MNtqj.mjs} +7 -16
  48. package/dist/.setup/{plugin-app-cache-key-BOxKP7db.mjs → plugin-app-cache-key-B2CsSdnV.mjs} +4 -20
  49. package/dist/.setup/{plugin-approval-roundtrip-CjfzafAZ.mjs → plugin-approval-roundtrip-C0MZzCuP.mjs} +1 -1
  50. package/dist/.setup/{plugin-inventory-DUle8DLz.mjs → plugin-inventory-BoRei8Z4.mjs} +16 -7
  51. package/dist/.setup/{plugin-marketplace-discovery-P-Vndfqq.mjs → plugin-marketplace-discovery-CDOi8IFs.mjs} +4 -1
  52. package/dist/.setup/{plugin-metadata-cache-DsS5buNa.mjs → plugin-metadata-cache-Ctmo83k_.mjs} +224 -154
  53. package/dist/.setup/protocol-CANUwXJ3.mjs +17 -0
  54. package/dist/.setup/{provider-fFh_-VR3.mjs → provider-BOsxQHOM.mjs} +9 -5
  55. package/dist/.setup/{provider-capabilities-B8J4Dy-O.mjs → provider-capabilities-BfE88FZ5.mjs} +31 -3
  56. package/dist/.setup/{rate-limits-DOEGYRNs.mjs → rate-limits-CMU3DUD0.mjs} +116 -137
  57. package/dist/.setup/{request-BioXJLYa.mjs → request-D2L0zMrq.mjs} +23 -15
  58. package/dist/.setup/{run-attempt-rlA07pUv.mjs → run-attempt-BHu11r7h.mjs} +1197 -617
  59. package/dist/.setup/{runtime-artifact-Dy38Z5iU.mjs → runtime-artifact-CLZ8udh-.mjs} +29 -45
  60. package/dist/.setup/{sandbox-guard-BBP-RbTf.mjs → sandbox-guard-C2sRMOEY.mjs} +1 -1
  61. package/dist/.setup/{session-binding-_0W_fHRr.mjs → session-binding-Cm0apEbd.mjs} +3 -32
  62. package/dist/.setup/{session-binding-record-TH3xA0zj.mjs → session-binding-record-BGoz8wOK.mjs} +22 -3
  63. package/dist/.setup/{session-binding-sidecars-CKYEcfNn.mjs → session-binding-sidecars-BlB5EvIS.mjs} +48 -45
  64. package/dist/.setup/{session-catalog-fUdWDx-U.mjs → session-catalog-Pno1xGcl.mjs} +482 -182
  65. package/dist/.setup/{session-catalog-adoption-CR_whkEW.mjs → session-catalog-adoption-BI6UTDZT.mjs} +57 -25
  66. package/dist/.setup/{session-catalog-archive-CwZaPacf.mjs → session-catalog-archive-lHBqzhaO.mjs} +6 -6
  67. package/dist/.setup/{session-catalog-events-jMcYfQyd.mjs → session-catalog-events-Bj6j94E_.mjs} +122 -25
  68. package/dist/.setup/{session-catalog-index-B141u15s.mjs → session-catalog-index-B9_VQIUz.mjs} +178 -78
  69. package/dist/.setup/{session-catalog-index-order-Cc5BzlQr.mjs → session-catalog-index-order-hcdz07yN.mjs} +2 -2
  70. package/dist/.setup/{session-catalog-index-state-BAuDztHN.mjs → session-catalog-index-state-Dgh8ORJm.mjs} +5 -2
  71. package/dist/.setup/{session-catalog-native-projection-ChV3cCtm.mjs → session-catalog-native-projection-DowriLid.mjs} +30 -13
  72. package/dist/.setup/{session-catalog-node-adoption-BVRsYOSh.mjs → session-catalog-node-adoption-ITddWx_X.mjs} +24 -12
  73. package/dist/.setup/{session-catalog-node-continue-Dowv8osw.mjs → session-catalog-node-continue-6g6qi4A9.mjs} +22 -13
  74. package/dist/.setup/{session-catalog-projection-C1Bj9Jl-.mjs → session-catalog-projection-zK_PUsiE.mjs} +13 -5
  75. package/dist/.setup/{session-cli-DIj-IE-E.mjs → session-cli-irrD-uo7.mjs} +4 -4
  76. package/dist/.setup/{session-history-C--SrLI8.mjs → session-history-BrqhSCf9.mjs} +17 -22
  77. package/dist/.setup/{session-history-import-JHXT5Xfi.mjs → session-history-import-D-3wAgOP.mjs} +4 -4
  78. package/dist/.setup/{session-history.worker-CpNj7H_P.mjs → session-history.worker-CaCh0xF_.mjs} +5 -18
  79. package/dist/.setup/{session-initialization-DH1z6fXn.mjs → session-initialization-rcgbZiid.mjs} +2 -2
  80. package/dist/.setup/{session-permission-policy-DhurXY0l.mjs → session-permission-policy-BI1QK_98.mjs} +2 -2
  81. package/dist/.setup/{session-retirement-CU87AOg9.mjs → session-retirement-BH-S6qkJ.mjs} +25 -6
  82. package/dist/.setup/{settled-turn-finalizer-CiY2bLFK.mjs → settled-turn-finalizer-DiAi6Kx6.mjs} +8 -8
  83. package/dist/.setup/{shared-client-BpTtuLQ5.mjs → shared-client-DA4VR4Eb.mjs} +59 -89
  84. package/dist/.setup/{side-question-DSCZyoBD.mjs → side-question-BJ1wSDcB.mjs} +147 -211
  85. package/dist/.setup/{source-Bjp4UQij.mjs → source-CUzJq5WN.mjs} +9 -9
  86. package/dist/.setup/spawn-error-CL3n6MAa.mjs +57 -0
  87. package/dist/.setup/{thread-archive-guard-jmecf6OJ.mjs → thread-archive-guard-C9frICzX.mjs} +10 -3
  88. package/dist/.setup/{thread-history-page-BTx-4xsg.mjs → thread-history-page-DoVpnHim.mjs} +1 -1
  89. package/dist/.setup/{thread-lifecycle-Cik28qWn.mjs → thread-lifecycle-B3mfz1TG.mjs} +172 -2271
  90. package/dist/.setup/{thread-ownership-skomxnIt.mjs → thread-ownership-DcTtAcXj.mjs} +4 -2
  91. package/dist/.setup/{thread-policy-Cjs4B8xf.mjs → thread-policy-DGuQsuFC.mjs} +19 -3
  92. package/dist/.setup/thread-requests-BLvGkP2R.mjs +2205 -0
  93. package/dist/.setup/{thread-resume-BkNpj9Pz.mjs → thread-resume-DIBXwOpE.mjs} +6 -6
  94. package/dist/.setup/{timeout-DZF05XrR.mjs → timeout-C910MdAB.mjs} +19 -2
  95. package/dist/.setup/{transcript-history-projection-DHNBDhCU.mjs → transcript-history-projection-ZZpkFkJ_.mjs} +94 -64
  96. package/dist/.setup/{transcript-mirror-D4qp_leP.mjs → transcript-mirror-BtHDBp1G.mjs} +218 -198
  97. package/dist/.setup/{transport-stdio-Cmx94Oiy.mjs → transport-stdio-h2VHOskC.mjs} +135 -55
  98. package/dist/.setup/{upstream-session-fork-D3UKxgVD.mjs → upstream-session-fork-BUr4OUbC.mjs} +44 -36
  99. package/dist/.setup/{usage-BOgBEKso.mjs → usage-BML0r-ua.mjs} +5 -4
  100. package/dist/.setup/{usage-limit-error-C0ow7DOc.mjs → usage-limit-error-DUMbefVY.mjs} +4 -4
  101. package/dist/.setup/{web-search-provider.runtime-CTGuJt6i.mjs → web-search-provider.runtime-CDKlN-Rv.mjs} +4 -3
  102. package/dist/api.js +23 -12
  103. package/dist/catalog-page-worker-entrypoint.js +12 -0
  104. package/dist/catalog-page.worker.js +9 -0
  105. package/dist/cli-metadata.js +1 -1
  106. package/dist/doctor-contract-api.js +2 -2
  107. package/dist/harness.js +1 -1
  108. package/dist/index.js +221 -170
  109. package/dist/media-understanding-provider.js +2 -2
  110. package/dist/migration-provider-api.js +1 -1
  111. package/dist/provider-discovery.js +1 -1
  112. package/dist/session-history-worker-runtime.js +15 -32
  113. package/dist/session-history.worker.js +1 -1
  114. package/package.json +9 -6
  115. package/dist/.setup/attempt-context-VXVwTCfS.mjs +0 -636
  116. package/dist/.setup/inference-proxy-CC15HuSi.mjs +0 -311
  117. package/dist/.setup/launch-args-DnMak49W.mjs +0 -111
  118. package/dist/.setup/node-exec-server.runtime-BaViBKNz.mjs +0 -226
  119. package/dist/.setup/version-CoqzXPgK.mjs +0 -12
  120. package/dist/.setup/{native-execution-policy-YBMHSzC4.mjs → native-execution-policy-umd0tgh4.mjs} +1 -1
@@ -0,0 +1,247 @@
1
+ import { i as resolveManagedCodexNativeCommand, r as resolveManagedCodexAppServerStartOptions, t as isManagedCodexDesktopCommand } from "./managed-binary-BnshlFag.mjs";
2
+ import { a as closeCodexAppServerTransportAndWait, t as createStdioTransport } from "./transport-stdio-h2VHOskC.mjs";
3
+ import { isRecord } from "openclaw/plugin-sdk/string-coerce-runtime";
4
+ import { stripVTControlCharacters } from "node:util";
5
+ import { killProcessTree } from "openclaw/plugin-sdk/process-runtime";
6
+ import path from "node:path";
7
+ import { mkdir } from "node:fs/promises";
8
+ import { once } from "node:events";
9
+ import { resolvePreferredOpenClawTmpDir, tempWorkspace } from "openclaw/plugin-sdk/temp-path";
10
+ import { createDeferred } from "openclaw/plugin-sdk/extension-shared";
11
+ import { StringDecoder } from "node:string_decoder";
12
+ import { sanitizeEnvVars } from "openclaw/plugin-sdk/sandbox";
13
+ //#region extensions/codex/src/node-exec-server.runtime.ts
14
+ const MAX_CODEX_EXEC_SERVER_MESSAGE_BYTES = 67108864;
15
+ const MAX_CODEX_EXEC_SERVER_STDERR_BYTES = 4096;
16
+ const CODEX_EXEC_SERVER_READY_LINE = "codex_exec_server::server::transport: codex-exec-server listening on stdio";
17
+ const CODEX_EXEC_SERVER_TERMINATION_GRACE_MS = 1e3;
18
+ const CODEX_EXEC_SERVER_REAP_TIMEOUT_MS = 5e3;
19
+ const NODE_EXEC_SERVER_PLATFORM_ENVIRONMENT = /^(?:SYSTEMROOT|WINDIR|COMSPEC|PATHEXT|TEMP|TMP|TMPDIR)$/iu;
20
+ function validateNodeExecServerMessage(message) {
21
+ if (message.byteLength === 0 || message.byteLength > MAX_CODEX_EXEC_SERVER_MESSAGE_BYTES) throw new Error("Codex exec-server JSON-RPC message exceeds its 64 MiB limit.");
22
+ const encoded = Buffer.from(message.buffer, message.byteOffset, message.byteLength);
23
+ if (encoded.includes(10) || encoded.includes(13)) throw new Error("Codex exec-server JSON-RPC frames must contain exactly one message.");
24
+ let decoded;
25
+ try {
26
+ const text = new TextDecoder("utf-8", { fatal: true }).decode(encoded);
27
+ decoded = JSON.parse(text);
28
+ } catch {
29
+ throw new Error("Codex exec-server received malformed UTF-8 or JSON-RPC.");
30
+ }
31
+ if (!isRecord(decoded) || decoded.jsonrpc !== void 0 && decoded.jsonrpc !== "2.0" || typeof decoded.method !== "string" && !("id" in decoded && ("result" in decoded || "error" in decoded))) throw new Error("Codex exec-server received an invalid JSON-RPC message.");
32
+ return encoded;
33
+ }
34
+ function nodeExecServerAbortError(signal) {
35
+ return signal.reason instanceof Error ? signal.reason : /* @__PURE__ */ new Error("Codex node exec-server connection closed.");
36
+ }
37
+ function writeNodeExecServerMessage(child, message, signal) {
38
+ if (signal.aborted) throw nodeExecServerAbortError(signal);
39
+ const payload = Buffer.concat([message, Buffer.from("\n")]);
40
+ if (!child.stdin.write(payload)) return once(child.stdin, "drain", { signal }).then(() => void 0);
41
+ }
42
+ async function relayNodeExecServerOutput(child, send) {
43
+ let fragments = [];
44
+ let pendingBytes = 0;
45
+ for await (const rawChunk of child.stdout) {
46
+ const chunk = Buffer.isBuffer(rawChunk) ? rawChunk : Buffer.from(rawChunk);
47
+ let offset = 0;
48
+ while (offset < chunk.byteLength) {
49
+ const newline = chunk.indexOf(10, offset);
50
+ const fragment = chunk.subarray(offset, newline === -1 ? chunk.byteLength : newline);
51
+ const nextLength = pendingBytes + fragment.byteLength;
52
+ if (nextLength > 67108865) throw new Error("Codex exec-server stdout message exceeds its 64 MiB limit.");
53
+ if (fragment.byteLength > 0) fragments.push(fragment);
54
+ pendingBytes = nextLength;
55
+ if (newline === -1) {
56
+ if (pendingBytes > MAX_CODEX_EXEC_SERVER_MESSAGE_BYTES && fragment[fragment.byteLength - 1] !== 13) throw new Error("Codex exec-server stdout message exceeds its 64 MiB limit.");
57
+ break;
58
+ }
59
+ const trailing = fragments.at(-1);
60
+ if (trailing?.[trailing.byteLength - 1] === 13) {
61
+ pendingBytes -= 1;
62
+ if (trailing.byteLength === 1) fragments.pop();
63
+ else fragments[fragments.length - 1] = trailing.subarray(0, trailing.byteLength - 1);
64
+ }
65
+ const message = validateNodeExecServerMessage(fragments.length === 1 ? fragments[0] : Buffer.concat(fragments, pendingBytes));
66
+ fragments = [];
67
+ pendingBytes = 0;
68
+ await send(message);
69
+ offset = newline + 1;
70
+ }
71
+ }
72
+ if (pendingBytes > 0) throw new Error("Codex exec-server stdout ended with an unterminated JSON-RPC message.");
73
+ }
74
+ function createNodeExecServerProcessOwner(child, closed, releaseResources, activeProcesses) {
75
+ let termination;
76
+ let hasClosed = false;
77
+ const settled = closed.then(async () => {
78
+ hasClosed = true;
79
+ await termination?.catch(() => {});
80
+ await releaseResources();
81
+ activeProcesses.delete(terminate);
82
+ });
83
+ settled.catch(() => {});
84
+ const terminate = async () => {
85
+ if (!hasClosed) await (termination ??= (async () => {
86
+ if (process.platform === "win32" && child.pid) killProcessTree(child.pid, { graceMs: CODEX_EXEC_SERVER_TERMINATION_GRACE_MS });
87
+ const { exited } = await closeCodexAppServerTransportAndWait(child, {
88
+ forceKillDelayMs: CODEX_EXEC_SERVER_TERMINATION_GRACE_MS,
89
+ exitTimeoutMs: CODEX_EXEC_SERVER_REAP_TIMEOUT_MS
90
+ });
91
+ if (!exited) throw new Error("Codex node exec-server process tree did not terminate.");
92
+ })());
93
+ await settled;
94
+ };
95
+ activeProcesses.add(terminate);
96
+ return terminate;
97
+ }
98
+ /** Runs the one-connection paired-node exec-server after lightweight command admission. */
99
+ async function runCodexNodeExecServer(params) {
100
+ const { io, workspace } = params;
101
+ const frames = io.frames;
102
+ const cwd = workspace.workspaceDir;
103
+ let writes;
104
+ let output;
105
+ let temporaryHome;
106
+ let unsubscribe;
107
+ const releaseResources = async () => {
108
+ try {
109
+ await Promise.allSettled([output, writes]);
110
+ await temporaryHome?.cleanup();
111
+ } finally {
112
+ workspace.release();
113
+ }
114
+ };
115
+ let close = releaseResources;
116
+ let rejectDisconnected;
117
+ const disconnected = new Promise((_resolve, reject) => {
118
+ rejectDisconnected = reject;
119
+ });
120
+ disconnected.catch(() => {});
121
+ const onAbort = () => {
122
+ const error = nodeExecServerAbortError(io.signal);
123
+ rejectDisconnected(error);
124
+ };
125
+ io.signal.addEventListener("abort", onAbort, { once: true });
126
+ try {
127
+ if (!frames) throw new Error("Codex node exec-server requires duplex frames.");
128
+ if (io.signal.aborted) throw nodeExecServerAbortError(io.signal);
129
+ temporaryHome = await tempWorkspace({
130
+ rootDir: resolvePreferredOpenClawTmpDir(),
131
+ prefix: "codex-node-exec-server-"
132
+ });
133
+ const { dir } = temporaryHome;
134
+ const codexHome = path.join(dir, ".codex");
135
+ await mkdir(codexHome, {
136
+ recursive: true,
137
+ mode: 448
138
+ });
139
+ const resolved = await resolveManagedCodexAppServerStartOptions({
140
+ transport: "stdio",
141
+ command: "codex",
142
+ commandSource: "managed",
143
+ managedCommandOrder: "package-first",
144
+ args: [
145
+ "exec-server",
146
+ "--listen",
147
+ "stdio"
148
+ ],
149
+ headers: {}
150
+ });
151
+ const native = resolveManagedCodexNativeCommand(resolved.command);
152
+ if (!native || isManagedCodexDesktopCommand(resolved.command)) throw new Error("Codex node exec-server requires the pinned managed package binary.");
153
+ const baseEnv = sanitizeEnvVars(process.env, {
154
+ strictMode: true,
155
+ customAllowedPatterns: [NODE_EXEC_SERVER_PLATFORM_ENVIRONMENT]
156
+ }).allowed;
157
+ if (io.signal.aborted) throw nodeExecServerAbortError(io.signal);
158
+ params.assertExecAuthorized();
159
+ const nativeReady = createDeferred();
160
+ const exit = createDeferred();
161
+ let stderr = Buffer.alloc(0);
162
+ let startupSettled = false;
163
+ let pendingLine = "";
164
+ const decoder = new StringDecoder("utf8");
165
+ const child = await createStdioTransport({
166
+ transport: "stdio",
167
+ command: native,
168
+ commandSource: "resolved-managed",
169
+ args: resolved.args,
170
+ headers: {},
171
+ cwd,
172
+ env: {
173
+ HOME: workspace.homeDir ?? dir,
174
+ CODEX_HOME: codexHome,
175
+ RUST_LOG: "error,opentelemetry_sdk=off,opentelemetry_otlp=off,codex_exec_server::server::transport=info",
176
+ ...process.platform === "win32" ? { USERPROFILE: workspace.homeDir ?? dir } : {}
177
+ },
178
+ clearEnv: ["NODE_OPTIONS"]
179
+ }, baseEnv, () => {
180
+ if (io.signal.aborted) throw nodeExecServerAbortError(io.signal);
181
+ params.assertExecAuthorized();
182
+ }, (spawned) => {
183
+ spawned.once("close", (code, signal) => exit.resolve({
184
+ code,
185
+ signal
186
+ }));
187
+ close = createNodeExecServerProcessOwner(spawned, exit.promise, releaseResources, params.activeProcesses);
188
+ output = relayNodeExecServerOutput(spawned, frames.send.bind(frames));
189
+ output.catch((error) => {
190
+ rejectDisconnected(error instanceof Error ? error : new Error(String(error)));
191
+ });
192
+ spawned.once("error", rejectDisconnected);
193
+ spawned.stdin.on("error", rejectDisconnected);
194
+ spawned.stderr.on("data", (chunk) => {
195
+ const next = Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk);
196
+ stderr = Buffer.concat([stderr, next.subarray(-4096)]).subarray(-4096);
197
+ if (startupSettled) return;
198
+ const lines = (pendingLine + decoder.write(next)).split("\n");
199
+ pendingLine = lines.pop();
200
+ for (const line of [...lines, pendingLine]) if (Buffer.byteLength(line, "utf8") > MAX_CODEX_EXEC_SERVER_STDERR_BYTES) {
201
+ startupSettled = true;
202
+ pendingLine = "";
203
+ rejectDisconnected(/* @__PURE__ */ new Error("Codex node startup diagnostic line exceeded 4 KiB."));
204
+ return;
205
+ }
206
+ if (lines.some((line) => stripVTControlCharacters(line).trimEnd().endsWith(CODEX_EXEC_SERVER_READY_LINE))) {
207
+ startupSettled = true;
208
+ pendingLine = "";
209
+ nativeReady.resolve();
210
+ }
211
+ });
212
+ });
213
+ const stopped = exit.promise.then((outcome) => {
214
+ const diagnostic = stderr.toString("utf8").trim();
215
+ throw new Error(`Codex node exec-server exited (code ${outcome.code ?? "none"}, signal ${outcome.signal ?? "none"})${diagnostic ? `: ${diagnostic}` : "."}`);
216
+ });
217
+ await Promise.race([
218
+ nativeReady.promise,
219
+ stopped,
220
+ disconnected
221
+ ]);
222
+ if (io.signal.aborted) throw nodeExecServerAbortError(io.signal);
223
+ if (child.exitCode !== null || child.signalCode !== null) await stopped;
224
+ params.assertExecAuthorized();
225
+ unsubscribe = frames.onMessage((message) => {
226
+ const encoded = validateNodeExecServerMessage(message);
227
+ const operation = writes ? writes.then(() => writeNodeExecServerMessage(child, encoded, io.signal)) : writeNodeExecServerMessage(child, encoded, io.signal);
228
+ if (!operation) return;
229
+ const observed = operation.catch(() => {});
230
+ writes = observed;
231
+ observed.then(() => {
232
+ if (writes === observed) writes = void 0;
233
+ });
234
+ return operation;
235
+ });
236
+ return await Promise.race([stopped, disconnected]);
237
+ } finally {
238
+ io.signal.removeEventListener("abort", onAbort);
239
+ try {
240
+ unsubscribe?.();
241
+ } finally {
242
+ await close();
243
+ }
244
+ }
245
+ }
246
+ //#endregion
247
+ export { runCodexNodeExecServer };
@@ -1,6 +1,6 @@
1
- import { c as CODEX_PLUGINS_MARKETPLACE_NAME } from "./plugin-inventory-DUle8DLz.mjs";
2
- import "./config-CedDWjM-.mjs";
3
- import { c as resolveHomePath, i as hasCodexSource, l as sanitizeName, n as defaultCodexHome, o as exists, r as discoverCodexSource, s as readJsonObject, t as codexPluginMigrationSubscriptionWarning } from "./source-Bjp4UQij.mjs";
1
+ import { c as CODEX_PLUGINS_MARKETPLACE_NAME } from "./plugin-inventory-BoRei8Z4.mjs";
2
+ import "./config-BoTP_mrL.mjs";
3
+ import { c as sanitizeName, i as hasCodexSource, n as defaultCodexHome, o as exists, r as discoverCodexSource, s as readJsonObject, t as codexPluginMigrationSubscriptionWarning } from "./source-CUzJq5WN.mjs";
4
4
  import { asBoolean, asOptionalRecord, isRecord, normalizeOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime";
5
5
  import { createHash } from "node:crypto";
6
6
  import { runCommandBuffered } from "openclaw/plugin-sdk/process-runtime";
@@ -9,10 +9,11 @@ import fs from "node:fs/promises";
9
9
  import { canonicalPathFromExistingAncestor, isPathInside } from "openclaw/plugin-sdk/file-access-runtime";
10
10
  import { readSecretFile } from "openclaw/plugin-sdk/secret-file";
11
11
  import { fileURLToPath } from "node:url";
12
- import { loadAuthProfileStoreWithoutExternalProfiles, resolveAgentConfig, resolveAgentWorkspaceDir, resolveDefaultAgentId } from "openclaw/plugin-sdk/agent-runtime";
12
+ import { loadAuthProfileStoreWithoutExternalProfiles } from "openclaw/plugin-sdk/agent-runtime";
13
13
  import { applyAuthProfileConfig, buildApiKeyCredential, buildOauthProviderAuthResult, buildOpenAICodexCredentialExtra, hasUsableOAuthCredential, resolveOpenAICodexAuthIdentity, resolveOpenAICodexImportProfileName, updateAuthProfileStoreWithLock } from "openclaw/plugin-sdk/provider-auth";
14
14
  import { extractErrorCode } from "openclaw/plugin-sdk/security-runtime";
15
15
  import { MIGRATION_REASON_TARGET_EXISTS, createMigrationItem, createMigrationManualItem, hasMigrationConfigPatchConflict, markMigrationItemConflict, markMigrationItemError, markMigrationItemSkipped, mergeMigrationConfigValue, readMigrationConfigPath, resolveMigrationConfigRuntime, summarizeMigrationItems } from "openclaw/plugin-sdk/migration";
16
+ import { resolvePlannedMigrationTargets } from "openclaw/plugin-sdk/migration-runtime";
16
17
  import { decodeOpenAICodexJwtPayload } from "openclaw/plugin-sdk/provider-oauth-runtime";
17
18
  //#region extensions/codex/src/migration/auth-profile-target.ts
18
19
  const OPENAI_PROVIDER_ID$1 = "openai";
@@ -91,15 +92,16 @@ async function readDirectKeyring(home, signal) {
91
92
  return;
92
93
  }
93
94
  }
94
- async function readSelectedCredentialStorage(options, requireApiKey) {
95
+ async function readCodexCliCredentialsAsync(options) {
95
96
  options.signal?.throwIfAborted();
97
+ if (!options.allowKeychainPrompt) return;
96
98
  const home = await fs.realpath(options.codexHome).catch(() => path.resolve(options.codexHome));
97
- const { CodexAppServerClient } = await import("./client-vXs2929Q.mjs").then((n) => n.n);
98
- const { resolveManagedCodexPackageEntrypoint, resolveManagedCodexNativeCommand } = await import("./managed-binary-DP6Rib3P.mjs").then((n) => n.n);
99
+ const { CodexAppServerClient } = await import("./client-Cs08OXVQ.mjs").then((n) => n.n);
100
+ const { resolveManagedCodexPackageEntrypoint, resolveManagedCodexNativeCommand } = await import("./managed-binary-BnshlFag.mjs").then((n) => n.n);
99
101
  const launcher = resolveManagedCodexPackageEntrypoint(path.dirname(fileURLToPath(import.meta.url)));
100
102
  const command = launcher ? resolveManagedCodexNativeCommand(launcher) : void 0;
101
103
  if (!command) return;
102
- const signal = AbortSignal.any([AbortSignal.timeout(options.allowKeychainPrompt && process.platform === "darwin" ? 6e4 : 5e3), ...options.signal ? [options.signal] : []]);
104
+ const signal = AbortSignal.any([AbortSignal.timeout(process.platform === "darwin" ? 6e4 : 5e3), ...options.signal ? [options.signal] : []]);
103
105
  const client = await CodexAppServerClient.start({
104
106
  transport: "stdio",
105
107
  command,
@@ -121,7 +123,7 @@ async function readSelectedCredentialStorage(options, requireApiKey) {
121
123
  signal.addEventListener("abort", abort, { once: true });
122
124
  let credential;
123
125
  try {
124
- credential = await readNativeCredential(client, home, requireApiKey, options, signal);
126
+ credential = await readNativeCredential(client, home, options, signal);
125
127
  } catch {}
126
128
  signal.removeEventListener("abort", abort);
127
129
  const closed = await client.closeAndWait({
@@ -132,15 +134,11 @@ async function readSelectedCredentialStorage(options, requireApiKey) {
132
134
  options.signal?.throwIfAborted();
133
135
  return credential;
134
136
  }
135
- async function readNativeCredential(client, home, requireApiKey, options, signal) {
137
+ async function readNativeCredential(client, home, options, signal) {
136
138
  signal.throwIfAborted();
137
139
  await client.initialize();
138
140
  if (client.getRuntimeIdentity()?.codexHome !== home) return;
139
141
  const revision = client.getModelCatalogRevision();
140
- if (requireApiKey) {
141
- const account = await client.request("account/read", { refreshToken: false }, { signal });
142
- if (asOptionalRecord(account.account)?.type !== "apiKey" || account.requiresOpenaiAuth !== true) return;
143
- }
144
142
  const configured = await client.request("config/read", {
145
143
  includeLayers: false,
146
144
  cwd: home
@@ -148,7 +146,7 @@ async function readNativeCredential(client, home, requireApiKey, options, signal
148
146
  const mode = (await client.request("configRequirements/read", {}, { signal })).requirements?.cli_auth_credentials_store ?? configured.config.cli_auth_credentials_store ?? "file";
149
147
  let record;
150
148
  if (mode === "file") record = await readAuthFile(home);
151
- else if ((mode === "keyring" || mode === "auto") && process.platform === "darwin" && options.allowKeychainPrompt) {
149
+ else if ((mode === "keyring" || mode === "auto") && process.platform === "darwin") {
152
150
  let cursor;
153
151
  let encrypted;
154
152
  do {
@@ -167,7 +165,18 @@ async function readNativeCredential(client, home, requireApiKey, options, signal
167
165
  record = await readDirectKeyring(home, signal);
168
166
  }
169
167
  signal.throwIfAborted();
170
- return !client.getCloseError() && client.getModelCatalogRevision() === revision ? record : void 0;
168
+ if (!record) return;
169
+ const oauth = options.credentialKind === "api_key" ? void 0 : parseOAuthCredential(record);
170
+ let apiKey = options.credentialKind === "oauth" ? void 0 : parseApiKeyCredential(record);
171
+ if (apiKey) {
172
+ const account = await client.request("account/read", { refreshToken: false }, { signal }).catch(() => void 0);
173
+ if (account?.account?.type !== "apiKey" || !account.requiresOpenaiAuth) apiKey = void 0;
174
+ }
175
+ signal.throwIfAborted();
176
+ return !client.getCloseError() && client.getModelCatalogRevision() === revision ? {
177
+ ...oauth ? { oauth } : {},
178
+ ...apiKey ? { apiKey } : {}
179
+ } : void 0;
171
180
  }
172
181
  function jwtExpiry(token) {
173
182
  try {
@@ -177,10 +186,9 @@ function jwtExpiry(token) {
177
186
  return;
178
187
  }
179
188
  }
180
- async function readCodexCliCredentialsAsync(options) {
181
- const data = await readSelectedCredentialStorage(options, false);
182
- const mode = typeof data?.auth_mode === "string" ? data.auth_mode.toLowerCase() : void 0;
183
- if (!data || mode !== void 0 && mode !== "chatgpt" && mode !== "chatgptauthtokens") return;
189
+ function parseOAuthCredential(data) {
190
+ const mode = typeof data.auth_mode === "string" ? data.auth_mode.toLowerCase() : void 0;
191
+ if (mode !== void 0 && mode !== "chatgpt" && mode !== "chatgptauthtokens") return;
184
192
  const tokens = asOptionalRecord(data.tokens);
185
193
  if (typeof tokens?.access_token !== "string" || !tokens.access_token || typeof tokens.refresh_token !== "string" || !tokens.refresh_token) return;
186
194
  const lastRefresh = typeof data.last_refresh === "string" ? Date.parse(data.last_refresh) : NaN;
@@ -194,10 +202,9 @@ async function readCodexCliCredentialsAsync(options) {
194
202
  ...typeof tokens.id_token === "string" ? { idToken: tokens.id_token } : {}
195
203
  };
196
204
  }
197
- async function readCodexCliActiveApiKeyAsync(options) {
198
- const data = await readSelectedCredentialStorage(options, true);
199
- const mode = typeof data?.auth_mode === "string" ? data.auth_mode.toLowerCase() : void 0;
200
- if (!data || mode !== void 0 && mode !== "apikey" && mode !== "api_key") return;
205
+ function parseApiKeyCredential(data) {
206
+ const mode = typeof data.auth_mode === "string" ? data.auth_mode.toLowerCase() : void 0;
207
+ if (mode !== void 0 && mode !== "apikey" && mode !== "api_key") return;
201
208
  const key = typeof data.OPENAI_API_KEY === "string" ? data.OPENAI_API_KEY.trim() : "";
202
209
  return key ? {
203
210
  type: "api_key",
@@ -245,13 +252,7 @@ async function readModelRefs(source) {
245
252
  refs.add(OPENAI_CODEX_DEFAULT_MODEL);
246
253
  return [...refs].toSorted();
247
254
  }
248
- async function buildCodexOAuthCredential(source, includeConfigPatch, options) {
249
- const credential = await readCodexCliCredentialsAsync({
250
- codexHome: source.codexHome,
251
- allowKeychainPrompt: options.allowKeychainPrompt,
252
- ...options.signal ? { signal: options.signal } : {}
253
- });
254
- if (!credential) return null;
255
+ async function buildCodexOAuthCredential(source, credential, includeConfigPatch) {
255
256
  const identity = resolveOpenAICodexAuthIdentity({
256
257
  access: credential.access,
257
258
  accountId: credential.accountId
@@ -281,25 +282,19 @@ async function buildCodexOAuthCredential(source, includeConfigPatch, options) {
281
282
  result
282
283
  } : null;
283
284
  }
284
- async function buildCodexApiKeyCredential(source, allowKeychainPrompt, signal) {
285
- const credential = await readCodexCliActiveApiKeyAsync({
285
+ async function readCodexAuthCredentials(source, options) {
286
+ const credentials = await readCodexCliCredentialsAsync({
286
287
  codexHome: source.codexHome,
287
- allowKeychainPrompt,
288
- ...signal ? { signal } : {}
288
+ credentialKind: options.credentialKind,
289
+ allowKeychainPrompt: options.allowKeychainPrompt,
290
+ ...options.signal ? { signal: options.signal } : {}
289
291
  });
290
- if (!credential) return null;
291
- return {
292
+ return [credentials?.oauth ? await buildCodexOAuthCredential(source, credentials.oauth, options.includeConfigPatch) : null, credentials?.apiKey ? {
292
293
  kind: "api_key",
293
294
  provider: OPENAI_PROVIDER_ID,
294
295
  profileId: "openai:codex-import",
295
- key: credential.key
296
- };
297
- }
298
- async function readCodexAuthCredentials(source, options) {
299
- return [options.credentialKind === "api_key" ? null : await buildCodexOAuthCredential(source, options.includeConfigPatch, {
300
- allowKeychainPrompt: options.allowKeychainPrompt,
301
- ...options.signal ? { signal: options.signal } : {}
302
- }), options.credentialKind === "oauth" ? null : await buildCodexApiKeyCredential(source, options.allowKeychainPrompt, options.signal)].filter((entry) => entry !== null);
296
+ key: credentials.apiKey.key
297
+ } : null].filter((entry) => entry !== null);
303
298
  }
304
299
  function replaceConfigDraft(draft, next) {
305
300
  for (const key of Object.keys(draft)) delete draft[key];
@@ -366,7 +361,8 @@ function resolveCodexConfigPatchMode(ctx) {
366
361
  return mode === "none" || mode === "return" ? mode : "apply";
367
362
  }
368
363
  function allowCodexKeychainPrompt(ctx) {
369
- return ctx.providerOptions?.allowKeychainPrompt === true;
364
+ const explicit = ctx.providerOptions?.allowKeychainPrompt;
365
+ return typeof explicit === "boolean" ? explicit : ctx.includeSecrets === true;
370
366
  }
371
367
  function resolveRequestedCredentialKind(ctx) {
372
368
  const kind = ctx.providerOptions?.credentialKind;
@@ -417,31 +413,31 @@ function applyCredentialConfig(config, credential, profileId) {
417
413
  }
418
414
  async function buildCodexAuthItems(params) {
419
415
  const configPatchMode = resolveCodexConfigPatchMode(params.ctx);
416
+ const allowKeychainPrompt = allowCodexKeychainPrompt(params.ctx);
420
417
  const credentials = await readCodexAuthCredentials(params.source, {
421
418
  credentialKind: resolveRequestedCredentialKind(params.ctx),
422
419
  includeConfigPatch: configPatchMode !== "none",
423
- allowKeychainPrompt: allowCodexKeychainPrompt(params.ctx),
420
+ allowKeychainPrompt,
424
421
  signal: params.ctx.signal
425
422
  });
426
423
  if (credentials.length === 0) {
427
424
  const requestedKind = resolveRequestedCredentialKind(params.ctx);
428
- if (!requestedKind) return [];
429
- const credentialKind = requestedKind;
430
- return [createMigrationItem({
431
- id: credentialKind === "oauth" ? OPENAI_OAUTH_ITEM_ID : OPENAI_API_KEY_ITEM_ID,
425
+ if (!requestedKind && allowKeychainPrompt) return [];
426
+ return (requestedKind ? [requestedKind] : ["oauth", "api_key"]).map((credentialKind) => createMigrationItem({
427
+ id: credentialKind === "api_key" ? OPENAI_API_KEY_ITEM_ID : OPENAI_OAUTH_ITEM_ID,
432
428
  kind: "auth",
433
429
  action: "skip",
434
430
  source: params.source.codexHome,
435
431
  status: "skipped",
436
432
  sensitive: true,
437
- reason: CODEX_REASON_AUTH_STORAGE_NOT_IMPORTABLE,
438
- message: "No supported Codex credential could be imported. Continue with sign-in to connect OpenClaw.",
433
+ reason: allowKeychainPrompt ? CODEX_REASON_AUTH_STORAGE_NOT_IMPORTABLE : void 0,
434
+ message: allowKeychainPrompt ? "No supported Codex credential could be imported. Continue with sign-in to connect OpenClaw." : "Codex credentials have not been inspected. Confirm credential import to check the current Codex sign-in.",
439
435
  details: {
440
436
  provider: OPENAI_PROVIDER_ID,
441
437
  credentialKind,
442
438
  credentialImportUnavailable: true
443
439
  }
444
- })];
440
+ }));
445
441
  }
446
442
  const store = loadAuthProfileStoreWithoutExternalProfiles(params.targets.agentDir);
447
443
  const skipped = !params.ctx.includeSecrets;
@@ -475,7 +471,24 @@ async function buildCodexAuthItems(params) {
475
471
  });
476
472
  });
477
473
  }
478
- async function applyCodexAuthItems(params) {
474
+ function createCodexAuthItemApplier(params) {
475
+ const { items, ...context } = params;
476
+ const selectedKinds = new Set(items.filter((item) => item.kind === "auth" && item.status === "planned").map((item) => item.details?.credentialKind));
477
+ const selectedKind = selectedKinds.size === 1 ? selectedKinds.values().next().value : void 0;
478
+ let snapshot;
479
+ const readCredentials = () => snapshot ??= readCodexAuthCredentials(context.source, {
480
+ credentialKind: selectedKind === "oauth" || selectedKind === "api_key" ? selectedKind : void 0,
481
+ includeConfigPatch: resolveCodexConfigPatchMode(context.ctx) !== "none",
482
+ allowKeychainPrompt: allowCodexKeychainPrompt(context.ctx),
483
+ signal: context.ctx.signal
484
+ });
485
+ return (item) => applyCodexAuthItem({
486
+ ...context,
487
+ item,
488
+ readCredentials
489
+ });
490
+ }
491
+ async function applyCodexAuthItem(params) {
479
492
  const { ctx, item, source, targets } = params;
480
493
  if (item.status !== "planned") return [item];
481
494
  const profileId = typeof item.details?.profileId === "string" ? item.details.profileId : "";
@@ -484,12 +497,10 @@ async function applyCodexAuthItems(params) {
484
497
  const credentialKind = item.details?.credentialKind;
485
498
  if (!profileId || !provider || credentialKind !== "oauth" && credentialKind !== "api_key") return [markMigrationItemError(item, CODEX_REASON_MISSING_AUTH_METADATA)];
486
499
  const configPatchMode = resolveCodexConfigPatchMode(ctx);
487
- const credential = (await readCodexAuthCredentials(source, {
488
- credentialKind,
489
- includeConfigPatch: configPatchMode !== "none",
490
- allowKeychainPrompt: allowCodexKeychainPrompt(ctx),
491
- signal: ctx.signal
492
- })).find((candidate) => candidate.provider === provider && candidate.kind === credentialKind && (!sourceProfileId || candidate.profileId === sourceProfileId));
500
+ ctx.signal?.throwIfAborted();
501
+ const credentials = await params.readCredentials();
502
+ ctx.signal?.throwIfAborted();
503
+ const credential = credentials.find((candidate) => candidate.provider === provider && candidate.kind === credentialKind && (!sourceProfileId || candidate.profileId === sourceProfileId));
493
504
  if (!credential) return [markMigrationItemSkipped(item, CODEX_REASON_AUTH_NO_LONGER_PRESENT)];
494
505
  if (item.details?.sourceCredentialFingerprint !== sourceCredentialFingerprint(credential)) return [markMigrationItemSkipped(item, CODEX_REASON_AUTH_NO_LONGER_PRESENT)];
495
506
  if (item.details?.legacyNativeHome !== void 0 && (item.details.legacyNativeHome !== source.codexHome || source.codexHome !== defaultCodexHome())) return [markMigrationItemSkipped(item, CODEX_REASON_AUTH_NO_LONGER_PRESENT)];
@@ -580,18 +591,6 @@ function buildCodexAuthConfigPatchItems(ctx, item, credential, profileId) {
580
591
  return items;
581
592
  }
582
593
  //#endregion
583
- //#region extensions/codex/src/migration/targets.ts
584
- function resolveCodexMigrationTargets(ctx) {
585
- const cfg = ctx.config;
586
- const agentId = ctx.targetAgentId ?? resolveDefaultAgentId(cfg);
587
- const workspaceDir = resolveAgentWorkspaceDir(cfg, agentId);
588
- const configuredAgentDir = resolveAgentConfig(cfg, agentId)?.agentDir?.trim();
589
- return {
590
- workspaceDir,
591
- agentDir: ctx.runtime?.agent?.resolveAgentDir(cfg, agentId) ?? (configuredAgentDir ? resolveHomePath(configuredAgentDir) : void 0) ?? path.join(ctx.stateDir, "agents", agentId, "agent")
592
- };
593
- }
594
- //#endregion
595
594
  //#region extensions/codex/src/migration/plan.ts
596
595
  const CODEX_PLUGIN_CONFIG_ITEM_ID = "config:codex-plugins";
597
596
  const CODEX_PLUGIN_CONFIG_PATH = [
@@ -896,7 +895,7 @@ function buildPluginConfigItem(ctx, pluginItems) {
896
895
  });
897
896
  }
898
897
  async function buildCodexMigrationPlan(ctx) {
899
- const targets = resolveCodexMigrationTargets(ctx);
898
+ const targets = resolvePlannedMigrationTargets(ctx);
900
899
  const memoryOnly = ctx.itemKinds !== void 0 && ctx.itemKinds.length > 0 && ctx.itemKinds.every((kind) => kind === "memory");
901
900
  const authOnly = ctx.itemKinds !== void 0 && ctx.itemKinds.length > 0 && ctx.itemKinds.every((kind) => kind === "auth");
902
901
  const source = await discoverCodexSource({
@@ -938,7 +937,6 @@ async function buildCodexMigrationPlan(ctx) {
938
937
  }));
939
938
  }
940
939
  const warnings = [
941
- ...!ctx.includeSecrets && items.some((item) => item.kind === "auth") ? ["Auth credentials were detected but skipped. Re-run interactively or pass --include-secrets to import supported credentials."] : [],
942
940
  ...items.some((item) => item.status === "conflict") ? ["Conflicts were found. Re-run with --overwrite to replace conflicting migration targets after item-level backups."] : [],
943
941
  ...source.pluginDiscoveryError ? [`Codex app-server plugin inventory discovery failed: ${source.pluginDiscoveryError}. Cached plugin bundles, if any, are advisory only.`] : [],
944
942
  ...source.plugins.some((plugin) => plugin.migrationBlock?.code === "codex_subscription_required") ? [codexPluginMigrationSubscriptionWarning()] : []
@@ -960,4 +958,4 @@ async function buildCodexMigrationPlan(ctx) {
960
958
  };
961
959
  }
962
960
  //#endregion
963
- export { CODEX_PLUGIN_CONFIG_ITEM_ID, CODEX_PLUGIN_CONFIG_PATH, buildCodexMigrationPlan, buildCodexPluginsConfigValue, hasCodexPluginConfigConflict, applyCodexAuthItems as n, resolveCodexConfigPatchMode as r, readCodexPluginMigrationConfigEntry, resolveCodexMigrationTargets as t };
961
+ export { CODEX_PLUGIN_CONFIG_ITEM_ID, CODEX_PLUGIN_CONFIG_PATH, buildCodexMigrationPlan, buildCodexPluginsConfigValue, hasCodexPluginConfigConflict, resolveCodexConfigPatchMode as n, readCodexPluginMigrationConfigEntry, createCodexAuthItemApplier as t };
@@ -1,6 +1,6 @@
1
- import { c as CODEX_PLUGINS_MARKETPLACE_NAME, i as pluginReadParams, n as isOpenAiCuratedMarketplace, r as isOpenAiCuratedMarketplaceName, t as findCodexMarketplacePluginSummary } from "./plugin-inventory-DUle8DLz.mjs";
2
- import { i as CodexAppServerRpcError } from "./timeout-DZF05XrR.mjs";
3
- import "./config-CedDWjM-.mjs";
1
+ import { c as CODEX_PLUGINS_MARKETPLACE_NAME, i as pluginReadParams, n as isOpenAiCuratedMarketplace, r as isOpenAiCuratedMarketplaceName, t as findCodexMarketplacePluginSummary } from "./plugin-inventory-BoRei8Z4.mjs";
2
+ import { o as CodexAppServerRpcError } from "./timeout-C910MdAB.mjs";
3
+ import "./config-BoTP_mrL.mjs";
4
4
  import { coerceErrorMessage } from "openclaw/plugin-sdk/error-runtime";
5
5
  //#region extensions/codex/src/app-server/plugin-activation.ts
6
6
  /**
@@ -45,7 +45,6 @@ async function ensureCodexPluginActivation(params) {
45
45
  diagnostics: [{ message: `Codex plugin install failed: ${coerceErrorMessage(error)}` }]
46
46
  };
47
47
  }
48
- if (params.metadataCache && params.appCacheKey) params.metadataCache.invalidate(params.appCacheKey);
49
48
  const refreshDiagnostics = [];
50
49
  let refreshFailed = false;
51
50
  try {
@@ -53,6 +52,7 @@ async function ensureCodexPluginActivation(params) {
53
52
  request: params.request,
54
53
  appCache: params.appCache,
55
54
  appCacheKey: params.appCacheKey,
55
+ appInventoryCacheKey: params.appInventoryCacheKey,
56
56
  configCwd: params.configCwd,
57
57
  metadataCache: params.metadataCache,
58
58
  deferAppInventoryRefresh: params.deferAppInventoryRefresh,
@@ -74,25 +74,16 @@ async function ensureCodexPluginActivation(params) {
74
74
  diagnostics: [...refreshDiagnostics, ...installResponse.appsNeedingAuth.map((app) => ({ message: `${app.name} requires app authentication before plugin tools are exposed.` }))]
75
75
  };
76
76
  }
77
- /** Forces Codex plugin, skill, hook, MCP, and app inventory refreshes after activation. */
77
+ /** Refreshes OpenClaw inventories after Codex installs a plugin. */
78
78
  async function refreshCodexPluginRuntimeState(params) {
79
79
  const diagnostics = [];
80
+ if (params.appCacheKey) params.metadataCache?.invalidate(params.appCacheKey);
80
81
  await listCuratedCodexPluginMetadata(params, { forceRefetch: true });
81
- await params.request("skills/list", {
82
- cwds: params.configCwd ? [params.configCwd] : [],
83
- forceReload: true
84
- });
85
- try {
86
- await params.request("hooks/list", { cwds: params.configCwd ? [params.configCwd] : [] });
87
- } catch (error) {
88
- diagnostics.push({ message: `Codex hooks refresh skipped: ${coerceErrorMessage(error)}` });
89
- }
90
- await params.request("config/mcpServer/reload", void 0);
91
82
  if (params.appCache && params.appCacheKey) try {
92
83
  await refreshCodexAppRuntimeState({
93
84
  ...params,
94
85
  appCache: params.appCache,
95
- appCacheKey: params.appCacheKey
86
+ appCacheKey: params.appInventoryCacheKey ?? params.appCacheKey
96
87
  });
97
88
  } catch (error) {
98
89
  diagnostics.push({ message: `Codex app inventory refresh skipped: ${coerceErrorMessage(error)}` });
@@ -1,4 +1,4 @@
1
- import { _ as resolveCodexAppServerUserHomeDir, g as resolveCodexAppServerLocalHomeDir, h as resolveCodexAppServerHomeDir } from "./config-security-BRQ2mgW9.mjs";
1
+ import { d as resolveCodexAppServerHomeDir, f as resolveCodexAppServerLocalHomeDir, p as resolveCodexAppServerUserHomeDir } from "./config-security-BEReZ6go.mjs";
2
2
  import { createRequire } from "node:module";
3
3
  import { isRecord } from "openclaw/plugin-sdk/string-coerce-runtime";
4
4
  import { createHash } from "node:crypto";
@@ -287,23 +287,7 @@ async function readInstalledApps(request, options) {
287
287
  return {
288
288
  apps: apps.flatMap((installedApp) => {
289
289
  const metadata = metadataById.get(installedApp.id);
290
- if (!metadata) return [];
291
- return [{
292
- id: installedApp.id,
293
- name: metadata.name,
294
- description: metadata.description ?? null,
295
- logoUrl: metadata.iconUrl ?? null,
296
- logoUrlDark: metadata.iconUrlDark ?? null,
297
- distributionChannel: metadata.distributionChannel ?? null,
298
- branding: null,
299
- appMetadata: null,
300
- labels: null,
301
- installUrl: metadata.installUrl ?? null,
302
- isAccessible: true,
303
- isEnabled: installedApp.enabled,
304
- pluginDisplayNames: metadata.pluginDisplayNames,
305
- ...metadata.toolSummaries ? { toolSummaries: metadata.toolSummaries } : {}
306
- }];
290
+ return metadata ? [metadata] : [];
307
291
  }),
308
292
  installedApps: apps
309
293
  };
@@ -388,7 +372,7 @@ function buildCodexAppServerConnectionFingerprint(appServer, agentDir) {
388
372
  });
389
373
  }
390
374
  function resolveCodexAppServerConnectionHome(start, agentDir) {
391
- const configured = start.env?.CODEX_HOME?.trim();
375
+ const configured = start.codexHome ?? start.env?.CODEX_HOME?.trim();
392
376
  if (configured) return configured;
393
377
  if (start.transport === "unix" && (!start.url || start.url === "unix://")) return resolveCodexAppServerUserHomeDir(start.env ?? process.env);
394
378
  if (start.transport !== "stdio") return null;
@@ -407,7 +391,7 @@ function resolveCodexPluginAppCacheEndpoint(appServer) {
407
391
  }
408
392
  /** Resolves the CODEX_HOME value that scopes local app-server inventory. */
409
393
  function resolveCodexPluginAppCacheCodexHome(appServer, agentDir) {
410
- const configuredCodexHome = appServer.start.env?.CODEX_HOME?.trim();
394
+ const configuredCodexHome = appServer.start.codexHome ?? appServer.start.env?.CODEX_HOME?.trim();
411
395
  if (configuredCodexHome) return configuredCodexHome;
412
396
  return appServer.start.transport === "stdio" && agentDir ? resolveCodexAppServerHomeDir(agentDir) : void 0;
413
397
  }