@openclaw/codex 2026.8.1-beta.2 → 2026.8.1

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 (64) hide show
  1. package/dist/api.js +146 -0
  2. package/dist/{attempt-client-cleanup-DMLXUfa8.js → attempt-client-cleanup-CVPvp9dL.js} +47 -5
  3. package/dist/{auth-binding-B4FfbcCg.js → auth-binding-Ds_QVm-X.js} +18 -3
  4. package/dist/{binding-connection-I5Bo-AsX.js → binding-connection-CCQFs8lf.js} +15 -3
  5. package/dist/{bounded-turn-qgZmzy_4.js → bounded-turn-rq5tiSXk.js} +27 -26
  6. package/dist/{capabilities-CybGI1oz.js → capabilities-CGm_94eL.js} +1 -1
  7. package/dist/cli-metadata.js +1 -1
  8. package/dist/{command-formatters-B1AEz8ZA.js → command-formatters-C54Yg3eA.js} +2 -2
  9. package/dist/{command-handlers-Db8pu_ds.js → command-handlers-BvOAHTrA.js} +111 -67
  10. package/dist/{compact-LspQaGfl.js → compact-Hd7SAc0N.js} +35 -30
  11. package/dist/{session-binding-DPxIvMgE.js → config-Cxw3Cl3k.js} +361 -1161
  12. package/dist/context-compaction-activity-BOeJf7yo.js +58 -0
  13. package/dist/doctor-contract-api.js +128 -26
  14. package/dist/{dynamic-tools-BVdyWkUD.js → dynamic-tools-BFoUcRdx.js} +1341 -1464
  15. package/dist/{effective-mcp-catalog-DIIhAtOZ.js → effective-mcp-catalog-BTJHnDSx.js} +2 -2
  16. package/dist/elicitation-input-DMkeki8d.js +71 -0
  17. package/dist/{event-projector-assistant-message-BwxV4d6N.js → event-projector-assistant-message-C5-Ds8mA.js} +18 -1
  18. package/dist/{event-projector-usage-e5huIQWu.js → event-projector-usage-D3PHFFXh.js} +18 -18
  19. package/dist/harness-DVfUQBlQ.js +248 -0
  20. package/dist/harness.js +2 -226
  21. package/dist/index.js +405 -299
  22. package/dist/{isolated-completion-C58NbL40.js → isolated-completion-Cbbx_5Ed.js} +4 -4
  23. package/dist/launch-args-sXOAg0SX.js +84 -0
  24. package/dist/managed-binary-ZkGodW19.js +248 -0
  25. package/dist/media-understanding-provider.js +2 -2
  26. package/dist/model-catalog-o6Cgjoss.js +101 -0
  27. package/dist/{models-BFlpn1Ex.js → models-DgFWSuxA.js} +25 -28
  28. package/dist/{native-subagent-monitor-DyTGmTUx.js → native-subagent-monitor-CwFyoylz.js} +385 -94
  29. package/dist/node-exec-server.runtime-DXrqpw1c.js +195 -0
  30. package/dist/plugin-approval-roundtrip-D80UZiJ_.js +95 -0
  31. package/dist/{plugin-marketplace-discovery-CzrGJdCR.js → plugin-marketplace-discovery-mdmScYOj.js} +60 -55
  32. package/dist/{plugin-metadata-cache-CNJPj4_b.js → plugin-metadata-cache-CulOABwu.js} +164 -134
  33. package/dist/{protocol-validators-B4F7L8Rf.js → protocol-validators-Bg5rpNxk.js} +203 -7
  34. package/dist/{rate-limits-DZXmOL8-.js → rate-limits-hFtzt2Up.js} +1 -1
  35. package/dist/{sandbox-guard-Cmwc9eIk.js → request-CCm4LaED.js} +207 -20
  36. package/dist/{run-attempt-P8BdxC1I.js → run-attempt-BwNQDH2u.js} +1506 -836
  37. package/dist/{runtime-artifact-BVSPdd6g.js → runtime-artifact-DeBvleJw.js} +4 -7
  38. package/dist/session-binding-q2WSTVmC.js +947 -0
  39. package/dist/{session-catalog-xwNi_SDM.js → session-catalog-C2Tae4rI.js} +1698 -1346
  40. package/dist/session-catalog-home-id-DAKUrm3C.js +112 -0
  41. package/dist/{session-cli-7hgXZDV7.js → session-cli-BuDjm5Ou.js} +20 -7
  42. package/dist/session-permission-policy-gLm40Vtq.js +160 -0
  43. package/dist/session-retirement-CdkI0bvb.js +90 -0
  44. package/dist/{session-upstream-marker-CrIFX06J.js → session-upstream-marker-Bcy33kam.js} +2 -3
  45. package/dist/{settled-turn-finalizer-BRWBO4MO.js → settled-turn-finalizer-B8JJcxCi.js} +27 -22
  46. package/dist/{shared-client-kIBbGjk4.js → shared-client-kNkljY-R.js} +2023 -607
  47. package/dist/{side-question-9HAL26l9.js → side-question-GwD73tX6.js} +109 -57
  48. package/dist/{thread-lifecycle-Bu1BTDXr.js → thread-lifecycle-Ss-uwnC4.js} +1208 -497
  49. package/dist/{thread-ownership-6kOQHlyC.js → thread-ownership-CeYBqg_4.js} +18 -8
  50. package/dist/{plugin-app-cache-key-C3H2CVp6.js → thread-resume-DF54hagX.js} +64 -6
  51. package/dist/{transcript-mirror-B9gGgnJS.js → transcript-mirror-CkEQIna-.js} +158 -41
  52. package/dist/transport-stdio-C7-s9TLG.js +708 -0
  53. package/dist/{upstream-prompt-provenance-ClRBije0.js → upstream-prompt-provenance-CFmsKwr9.js} +12 -14
  54. package/dist/{upstream-session-fork-CE-_LdnP.js → upstream-session-fork-BACGlOFa.js} +86 -88
  55. package/dist/{usage-CHlV0e-o.js → usage-C2l8Mils.js} +3 -3
  56. package/dist/{web-search-provider.runtime-DRw2Vl42.js → web-search-provider.runtime-B2XgRdFv.js} +3 -3
  57. package/openclaw.plugin.json +50 -2
  58. package/package.json +9 -8
  59. package/dist/app-server-policy-zcBDc1JU.js +0 -49
  60. package/dist/incognito-session-ET_ufDH-.js +0 -2
  61. package/dist/request-BRl5_UfX.js +0 -157
  62. package/dist/session-retirement-DoMMJFKm.js +0 -36
  63. package/dist/thread-resume-CPrJNQVM.js +0 -30
  64. package/dist/transport-stdio-DIImwDVS.js +0 -99
@@ -1,91 +1,11 @@
1
- import { g as resolveCodexAppServerRuntimeOptions, v as resolveCodexComputerUseConfig } from "./session-binding-DPxIvMgE.js";
2
- import { M as isCodexAppServerConnectionClosedError, N as isCodexAppServerIndeterminateRequestCancellationError, P as isCodexAppServerIndeterminateTransportError, a as getLeasedSharedCodexAppServerClient, l as releaseLeasedSharedCodexAppServerClient, lt as resolveFirstExistingMacOSDesktopCodexBundledMarketplacePath, u as resolveCodexNativeConfigFenceKey, v as acquireCodexNativeConfigFence } from "./shared-client-kIBbGjk4.js";
3
- import { n as describeControlFailure } from "./capabilities-CybGI1oz.js";
4
- import { r as requestCodexAppServerJson } from "./request-BRl5_UfX.js";
1
+ import { P as resolveCodexAppServerHomeDir, i as resolveCodexAppServerRuntimeOptions, o as resolveCodexComputerUseConfig } from "./config-Cxw3Cl3k.js";
2
+ import { At as reconcileCodexComputerUseStartArtifacts, G as isCodexAppServerConnectionClosedError, K as isCodexAppServerIndeterminateRequestCancellationError, O as acquireCodexNativeConfigFence, S as waitForCodexAppServerClientDesktopGenerationDrain, Ut as resolveCodexManagedBundledMarketplacePath, Wt as assertNotSymlink, c as getLeasedSharedCodexAppServerClient, d as readCodexAppServerClientDesktopGeneration, g as resolveCodexNativeConfigFenceKey, h as releaseLeasedSharedCodexAppServerClient, p as readCodexAppServerClientProcessIdentity, q as isCodexAppServerIndeterminateTransportError, t as assertCodexAppServerClientStartSelectionCurrent, u as isCodexAppServerStartSelectionChangedError } from "./shared-client-kNkljY-R.js";
3
+ import { l as resolveMacOSDesktopCodexBundledMarketplaceCandidates, s as resolveFirstExistingMacOSDesktopCodexBundledMarketplacePath, t as isManagedCodexDesktopCommand } from "./managed-binary-ZkGodW19.js";
4
+ import { i as requestCodexAppServerJson } from "./request-CCm4LaED.js";
5
+ import { n as describeControlFailure } from "./capabilities-CGm_94eL.js";
6
+ import fs from "node:fs/promises";
7
+ import path from "node:path";
5
8
  import { existsSync } from "node:fs";
6
- import { runExec } from "openclaw/plugin-sdk/process-runtime";
7
- //#region extensions/codex/src/app-server/computer-use-process-repair.ts
8
- const COMPUTER_USE_PROCESS_LIST_TIMEOUT_MS = 2e3;
9
- const COMPUTER_USE_PROCESS_LIST_MAX_BUFFER_BYTES = 5 * 1024 * 1024;
10
- function scopedRepairUnavailableStatus() {
11
- return {
12
- attempted: false,
13
- killedPids: [],
14
- warnings: ["Computer Use auto-repair skipped because no scoped Codex app-server process was available."],
15
- message: "Computer Use stale child repair requires a scoped local app-server PID."
16
- };
17
- }
18
- async function killStaleComputerUseMcpChildren(options = {}) {
19
- if (process.platform !== "darwin") return {
20
- attempted: true,
21
- killedPids: [],
22
- warnings: [`Computer Use stale child repair is currently macOS-only, not ${process.platform}.`],
23
- message: "Computer Use stale child repair skipped on this platform."
24
- };
25
- if (!options.ancestorPid || !Number.isSafeInteger(options.ancestorPid) || options.ancestorPid <= 0) return scopedRepairUnavailableStatus();
26
- let stdout;
27
- try {
28
- stdout = (await runExec("/bin/ps", ["-axo", "pid=,ppid=,command="], {
29
- logOutput: false,
30
- maxBuffer: COMPUTER_USE_PROCESS_LIST_MAX_BUFFER_BYTES,
31
- timeoutMs: COMPUTER_USE_PROCESS_LIST_TIMEOUT_MS
32
- })).stdout;
33
- } catch (error) {
34
- return {
35
- attempted: true,
36
- killedPids: [],
37
- warnings: [`Could not list processes for Computer Use repair: ${describeControlFailure(error)}`],
38
- message: "Computer Use stale child repair could not inspect running processes."
39
- };
40
- }
41
- const killedPids = [];
42
- const warnings = [];
43
- const processInfos = parsePsOutput(stdout);
44
- for (const processInfo of processInfos) {
45
- if (!isStaleComputerUseMcpChild(processInfo.command)) continue;
46
- if (!isDescendantOfPid(processInfo.pid, options.ancestorPid, processInfos)) continue;
47
- try {
48
- process.kill(processInfo.pid, "SIGTERM");
49
- killedPids.push(processInfo.pid);
50
- } catch (error) {
51
- warnings.push(`Could not terminate stale Computer Use MCP child pid ${processInfo.pid}: ${describeControlFailure(error)}`);
52
- }
53
- }
54
- return {
55
- attempted: true,
56
- killedPids,
57
- warnings,
58
- message: killedPids.length === 0 ? "No stale Computer Use MCP children were found under the scoped Codex app-server process." : `Terminated ${killedPids.length} stale Computer Use MCP child process${killedPids.length === 1 ? "" : "es"} under the scoped Codex app-server process.`
59
- };
60
- }
61
- function parsePsOutput(stdout) {
62
- return stdout.split(/\r?\n/u).flatMap((line) => {
63
- const match = /^\s*(\d+)\s+(\d+)\s+(.+)$/u.exec(line);
64
- if (!match) return [];
65
- return [{
66
- pid: Number(match[1]),
67
- ppid: Number(match[2]),
68
- command: match[3] ?? ""
69
- }];
70
- }).filter((processInfo) => Number.isSafeInteger(processInfo.pid) && processInfo.pid > 0 && Number.isSafeInteger(processInfo.ppid) && processInfo.ppid >= 0);
71
- }
72
- function isStaleComputerUseMcpChild(command) {
73
- return command.includes("SkyComputerUseClient") && /(?:^|\s)mcp(?:\s|$)/u.test(command);
74
- }
75
- function isDescendantOfPid(pid, ancestorPid, processInfos) {
76
- const parents = new Map(processInfos.map((processInfo) => [processInfo.pid, processInfo.ppid]));
77
- const seen = /* @__PURE__ */ new Set();
78
- let current = pid;
79
- while (!seen.has(current)) {
80
- seen.add(current);
81
- const parent = parents.get(current);
82
- if (!parent || parent <= 0) return false;
83
- if (parent === ancestorPid) return true;
84
- current = parent;
85
- }
86
- return false;
87
- }
88
- //#endregion
89
9
  //#region extensions/codex/src/app-server/computer-use.ts
90
10
  /**
91
11
  * Computer Use plugin/MCP readiness checks and optional install flow for Codex
@@ -99,8 +19,9 @@ var CodexComputerUseSetupError = class extends Error {
99
19
  }
100
20
  };
101
21
  const CURATED_MARKETPLACE_POLL_INTERVAL_MS = 2e3;
22
+ const BUNDLED_MARKETPLACE_NAME = "openai-bundled";
102
23
  const COMPUTER_USE_MARKETPLACE_NAME_PRIORITY = [
103
- "openai-bundled",
24
+ BUNDLED_MARKETPLACE_NAME,
104
25
  "openai-curated",
105
26
  "openai-api-curated",
106
27
  "openai-curated-remote",
@@ -172,71 +93,96 @@ async function installCodexComputerUse(params = {}) {
172
93
  }
173
94
  async function inspectCodexComputerUse(params) {
174
95
  if (!params.installPlugin) return await inspectCodexComputerUseWithoutFence(params);
175
- const runtime = params.client ? void 0 : resolveCodexAppServerRuntimeOptions({
96
+ const resolvedRuntime = resolveCodexAppServerRuntimeOptions({
176
97
  pluginConfig: params.pluginConfig,
177
98
  managedCommandOrder: "desktop-first"
178
99
  });
179
- const fenceKey = resolveCodexNativeConfigFenceKey({
180
- client: params.client,
181
- startOptions: runtime?.start,
182
- agentDir: params.agentDir,
183
- config: params.config
184
- });
185
- if (!fenceKey) return await inspectCodexComputerUseWithoutFence(params);
186
- const release = await acquireCodexNativeConfigFence(fenceKey, {
187
- signal: params.signal,
188
- timeoutMs: params.timeoutMs ?? runtime?.requestTimeoutMs,
189
- timeoutMessage: "Codex Computer Use install timed out waiting for native config",
190
- abortMessage: "Codex Computer Use install aborted waiting for native config"
191
- });
192
- let releaseFenceOnReturn = true;
100
+ const operationTimeoutMs = params.timeoutMs ?? resolvedRuntime.requestTimeoutMs;
101
+ const deadline = operationTimeoutMs > 0 ? Date.now() + operationTimeoutMs : void 0;
102
+ const remainingTimeoutMs = () => deadline === void 0 ? operationTimeoutMs : Math.max(1, deadline - Date.now());
193
103
  let leasedClient;
194
104
  try {
195
105
  let client = params.client;
196
106
  if (!client && !params.request) {
197
- if (!runtime) throw new Error("Computer Use install could not resolve its app-server runtime");
198
107
  client = await getLeasedSharedCodexAppServerClient({
199
- startOptions: runtime.start,
108
+ startOptions: resolvedRuntime.start,
200
109
  pluginConfig: params.pluginConfig,
201
- timeoutMs: params.timeoutMs ?? runtime.requestTimeoutMs,
110
+ timeoutMs: remainingTimeoutMs(),
202
111
  config: params.config,
203
112
  agentDir: params.agentDir,
204
113
  abandonSignal: params.signal
205
114
  });
206
115
  leasedClient = client;
207
116
  }
208
- try {
209
- return await inspectCodexComputerUseWithoutFence({
210
- ...params,
211
- ...client ? {
212
- client,
213
- timeoutMs: params.timeoutMs ?? runtime?.requestTimeoutMs
214
- } : {}
117
+ const explicitManagedInstall = client && !resolveCodexComputerUseConfig({ pluginConfig: params.pluginConfig }).autoInstall ? await resolveExplicitManagedComputerUseInstallContext({
118
+ ...params,
119
+ client
120
+ }) : void 0;
121
+ if (explicitManagedInstall) {
122
+ await waitForCodexAppServerClientDesktopGenerationDrain({
123
+ client: explicitManagedInstall.client,
124
+ timeoutMs: remainingTimeoutMs(),
125
+ ...params.signal ? { signal: params.signal } : {}
215
126
  });
216
- } catch (error) {
217
- if (client && (isCodexAppServerIndeterminateRequestCancellationError(error) || isCodexAppServerIndeterminateTransportError(error) || isCodexAppServerConnectionClosedError(error))) {
218
- releaseFenceOnReturn = false;
219
- await client.closeAndRunAfterExit(release, "Computer Use config mutation");
127
+ assertCodexAppServerClientStartSelectionCurrent({ client: explicitManagedInstall.client });
128
+ }
129
+ const inspectionParams = {
130
+ ...params,
131
+ ...client ? { client } : {},
132
+ timeoutMs: remainingTimeoutMs(),
133
+ ...explicitManagedInstall ? { explicitManagedInstall } : {}
134
+ };
135
+ const fenceKey = resolveCodexNativeConfigFenceKey({
136
+ client,
137
+ startOptions: resolvedRuntime.start,
138
+ agentDir: params.agentDir,
139
+ config: params.config
140
+ });
141
+ if (!fenceKey) return await inspectCodexComputerUseWithoutFence(inspectionParams);
142
+ const release = await acquireCodexNativeConfigFence(fenceKey, {
143
+ signal: params.signal,
144
+ timeoutMs: remainingTimeoutMs(),
145
+ timeoutMessage: "Codex Computer Use install timed out waiting for native config",
146
+ abortMessage: "Codex Computer Use install aborted waiting for native config"
147
+ });
148
+ let releaseFenceOnReturn = true;
149
+ try {
150
+ try {
151
+ return await inspectCodexComputerUseWithoutFence({
152
+ ...inspectionParams,
153
+ releaseNativeConfigFence: release
154
+ });
155
+ } catch (error) {
156
+ if (client && (isCodexAppServerIndeterminateRequestCancellationError(error) || isCodexAppServerIndeterminateTransportError(error) || isCodexAppServerConnectionClosedError(error))) {
157
+ releaseFenceOnReturn = false;
158
+ await client.closeAndRunAfterExit(release, "Computer Use config mutation");
159
+ }
160
+ throw error;
220
161
  }
221
- throw error;
222
162
  } finally {
223
- if (leasedClient) releaseLeasedSharedCodexAppServerClient(leasedClient);
163
+ if (releaseFenceOnReturn) release();
224
164
  }
225
165
  } finally {
226
- if (releaseFenceOnReturn) release();
166
+ if (leasedClient) releaseLeasedSharedCodexAppServerClient(leasedClient);
227
167
  }
228
168
  }
229
169
  async function inspectCodexComputerUseWithoutFence(params) {
230
170
  const request = createComputerUseRequest(params);
231
- const repairComputerUseMcpChildren = params.repairComputerUseMcpChildren ?? (params.client ? () => killStaleComputerUseMcpChildren({ ancestorPid: params.client?.getTransportPid() }) : void 0);
232
- if (params.installPlugin) await request("experimentalFeature/enablement/set", { enablement: { plugins: true } });
171
+ if (params.installPlugin) {
172
+ if (!resolveCodexComputerUseConfig({ pluginConfig: params.pluginConfig }).autoInstall) await prepareExplicitManagedComputerUseInstall(params);
173
+ await request("experimentalFeature/enablement/set", { enablement: { plugins: true } });
174
+ }
175
+ const managedMarketplacePath = await resolveClientManagedBundledMarketplacePath(params.client, params.agentDir);
176
+ const managedCodexHome = managedMarketplacePath ? params.client?.getRuntimeIdentity()?.codexHome : void 0;
177
+ if (params.installPlugin && managedCodexHome) await assertNotSymlink(path.join(managedCodexHome, "config.toml"), "Codex config");
233
178
  const marketplace = await resolveMarketplaceRef({
234
179
  request,
235
180
  config: params.computerUseConfig,
236
181
  allowAdd: params.installPlugin,
237
182
  signal: params.signal,
238
- defaultBundledMarketplacePath: params.defaultBundledMarketplacePath,
239
- defaultBundledMarketplacePathCandidates: params.defaultBundledMarketplacePathCandidates
183
+ defaultBundledMarketplacePath: params.defaultBundledMarketplacePath ?? managedMarketplacePath,
184
+ defaultBundledMarketplacePathCandidates: params.defaultBundledMarketplacePathCandidates,
185
+ managedCodexHome
240
186
  });
241
187
  if (!marketplace.marketplace) return unavailableStatus(params.computerUseConfig, "marketplace_missing", marketplace.message ?? `No Codex marketplace containing ${params.computerUseConfig.pluginName} is registered. Configure computerUse.marketplaceSource or computerUse.marketplacePath, then run /codex computer-use install.`);
242
188
  const pluginInspection = await ensureComputerUsePlugin({
@@ -251,9 +197,59 @@ async function inspectCodexComputerUseWithoutFence(params) {
251
197
  config: params.computerUseConfig,
252
198
  plugin: pluginInspection.plugin,
253
199
  installPlugin: params.installPlugin,
254
- repairComputerUseMcpChildren
200
+ releaseNativeConfigFence: params.releaseNativeConfigFence
255
201
  });
256
202
  }
203
+ async function prepareExplicitManagedComputerUseInstall(params) {
204
+ const context = params.explicitManagedInstall;
205
+ if (!context) return;
206
+ await reconcileCodexComputerUseStartArtifacts({
207
+ startOptions: {
208
+ transport: "stdio",
209
+ command: context.command,
210
+ commandSource: "resolved-managed",
211
+ args: ["app-server"],
212
+ headers: {},
213
+ env: { CODEX_HOME: context.codexHome }
214
+ },
215
+ agentDir: context.agentDir,
216
+ pluginConfig: { computerUse: {
217
+ ...params.computerUseConfig,
218
+ autoInstall: true
219
+ } },
220
+ ownsIsolatedCodexHome: true,
221
+ desktopGeneration: context.desktopGeneration,
222
+ forceCacheRefresh: true,
223
+ assertCurrent: () => assertCodexAppServerClientStartSelectionCurrent({ client: context.client })
224
+ });
225
+ }
226
+ async function resolveExplicitManagedComputerUseInstallContext(params) {
227
+ if (!params.agentDir) return;
228
+ const codexHome = params.client.getRuntimeIdentity()?.codexHome;
229
+ const processIdentity = readCodexAppServerClientProcessIdentity(params.client);
230
+ const command = processIdentity?.nativeCommand ?? (processIdentity && isManagedCodexDesktopCommand(processIdentity.command, "darwin") ? processIdentity.command : void 0);
231
+ if (!codexHome || !command) return;
232
+ const desktopGeneration = readCodexAppServerClientDesktopGeneration(params.client);
233
+ if (!desktopGeneration) throw new Error("Codex Computer Use install requires a desktop-generation-bound client; reconnect and retry.");
234
+ const expectedHome = resolveCodexAppServerHomeDir(params.agentDir);
235
+ const [actualRealHome, expectedRealHome] = await Promise.all([fs.realpath(codexHome).catch(() => void 0), fs.realpath(expectedHome).catch(() => void 0)]);
236
+ if (!actualRealHome || actualRealHome !== expectedRealHome) return;
237
+ return {
238
+ client: params.client,
239
+ agentDir: params.agentDir,
240
+ codexHome,
241
+ command,
242
+ desktopGeneration
243
+ };
244
+ }
245
+ async function resolveClientManagedBundledMarketplacePath(client, agentDir) {
246
+ const codexHome = client?.getRuntimeIdentity()?.codexHome;
247
+ if (!codexHome || !agentDir) return;
248
+ const [actualRealHome, expectedRealHome] = await Promise.all([fs.realpath(codexHome).catch(() => void 0), fs.realpath(resolveCodexAppServerHomeDir(agentDir)).catch(() => void 0)]);
249
+ if (!actualRealHome || actualRealHome !== expectedRealHome) return;
250
+ const managedPath = resolveCodexManagedBundledMarketplacePath(codexHome);
251
+ return existsSync(managedPath) ? managedPath : void 0;
252
+ }
257
253
  async function ensureComputerUsePlugin(params) {
258
254
  let plugin = await readComputerUsePlugin(params.request, params.marketplace, params.config.pluginName);
259
255
  if (!plugin.summary.installed || !plugin.summary.enabled) {
@@ -315,10 +311,10 @@ async function readComputerUseTools(params) {
315
311
  reason: "ready",
316
312
  message: "Computer Use is ready."
317
313
  });
314
+ params.releaseNativeConfigFence?.();
318
315
  const { liveTest, repair } = await runCodexComputerUseLiveTest({
319
316
  request: params.request,
320
- config: params.config,
321
- repairComputerUseMcpChildren: params.repairComputerUseMcpChildren
317
+ config: params.config
322
318
  });
323
319
  const compatibilityStartupAllowed = !liveTest.ok && !params.config.strictReadiness;
324
320
  return {
@@ -348,8 +344,6 @@ async function runCodexComputerUseLiveTest(params) {
348
344
  threadId = (await params.request("thread/start", {
349
345
  input: [],
350
346
  developerInstructions: COMPUTER_USE_LIVE_TEST_THREAD_NAME,
351
- sandbox: "danger-full-access",
352
- approvalPolicy: "never",
353
347
  ephemeral: true
354
348
  }, { timeoutMs: params.config.liveTestTimeoutMs })).thread.id;
355
349
  await params.request("mcpServer/tool/call", {
@@ -366,19 +360,19 @@ async function runCodexComputerUseLiveTest(params) {
366
360
  attempts: attempt + 1,
367
361
  timeoutMs: params.config.liveTestTimeoutMs,
368
362
  retried: attempt > 0,
369
- repaired: Boolean(repair?.attempted),
363
+ repaired: Boolean(repair?.attempted && repair.warnings.length === 0),
370
364
  durationMs: Math.max(0, Date.now() - startedAt),
371
365
  message: "Computer Use live test passed."
372
366
  },
373
367
  ...repair ? { repair } : {}
374
368
  };
375
369
  } catch (error) {
370
+ if (isCodexAppServerStartSelectionChangedError(error)) throw error;
376
371
  lastError = error;
377
- if (attempt >= COMPUTER_USE_LIVE_TEST_RETRY_COUNT) break;
378
- if (params.config.autoRepair) repair = params.repairComputerUseMcpChildren ? await params.repairComputerUseMcpChildren() : scopedRepairUnavailableStatus();
379
372
  } finally {
380
373
  if (threadId) await cleanupComputerUseProbeThread(params.request, threadId, params.config);
381
374
  }
375
+ if (attempt < COMPUTER_USE_LIVE_TEST_RETRY_COUNT && params.config.autoRepair) repair = await repairComputerUseMcpRuntime(params.request, params.config);
382
376
  }
383
377
  const errorMessage = describeControlFailure(lastError);
384
378
  return {
@@ -389,7 +383,7 @@ async function runCodexComputerUseLiveTest(params) {
389
383
  attempts: 2,
390
384
  timeoutMs: params.config.liveTestTimeoutMs,
391
385
  retried: true,
392
- repaired: Boolean(repair?.attempted),
386
+ repaired: Boolean(repair?.attempted && repair.warnings.length === 0),
393
387
  durationMs: Math.max(0, Date.now() - startedAt),
394
388
  message: `Computer Use live test failed after 2 attempts: ${errorMessage}`,
395
389
  error: errorMessage
@@ -397,6 +391,25 @@ async function runCodexComputerUseLiveTest(params) {
397
391
  ...repair ? { repair } : {}
398
392
  };
399
393
  }
394
+ async function repairComputerUseMcpRuntime(request, config) {
395
+ try {
396
+ await request("config/mcpServer/reload", void 0, { timeoutMs: config.liveTestTimeoutMs });
397
+ return {
398
+ attempted: true,
399
+ killedPids: [],
400
+ warnings: [],
401
+ message: "Reloaded Computer Use MCP servers through Codex app-server."
402
+ };
403
+ } catch (error) {
404
+ const message = `Could not reload Computer Use MCP servers: ${describeControlFailure(error)}`;
405
+ return {
406
+ attempted: true,
407
+ killedPids: [],
408
+ warnings: [message],
409
+ message
410
+ };
411
+ }
412
+ }
400
413
  async function cleanupComputerUseProbeThread(request, threadId, config) {
401
414
  await Promise.allSettled([request("thread/unsubscribe", { threadId }, { timeoutMs: config.liveTestTimeoutMs }), request("thread/archive", { threadId }, { timeoutMs: config.liveTestTimeoutMs })]);
402
415
  }
@@ -417,6 +430,12 @@ async function resolveMarketplaceRef(params) {
417
430
  let candidates = await listComputerUseMarketplaceCandidates(params.request, params.config);
418
431
  const bundledMarketplacePath = resolveBundledComputerUseMarketplacePath(params);
419
432
  if (candidates.length === 0 && bundledMarketplacePath && shouldAddBundledComputerUseMarketplace(params)) {
433
+ if (params.managedCodexHome) await migrateLegacyBundledMarketplaceSource({
434
+ request: params.request,
435
+ bundledMarketplacePath,
436
+ legacySources: params.defaultBundledMarketplacePathCandidates,
437
+ userConfigPath: path.join(params.managedCodexHome, "config.toml")
438
+ });
420
439
  const added = await params.request("marketplace/add", { source: bundledMarketplacePath });
421
440
  preferredMarketplaceName ??= added.marketplaceName;
422
441
  candidates = await listComputerUseMarketplaceCandidates(params.request, params.config);
@@ -441,6 +460,16 @@ async function resolveMarketplaceRef(params) {
441
460
  const marketplace = candidates[0];
442
461
  return marketplace ? { marketplace } : {};
443
462
  }
463
+ async function migrateLegacyBundledMarketplaceSource(params) {
464
+ const response = await params.request("config/read", { includeLayers: false });
465
+ const bundled = response.config.marketplaces?.[BUNDLED_MARKETPLACE_NAME];
466
+ const sourceOrigin = response.origins[`marketplaces.${BUNDLED_MARKETPLACE_NAME}.source`];
467
+ if (bundled?.source_type !== "local" || !bundled.source || sourceOrigin?.name.type !== "user" || sourceOrigin.name.profile !== null || path.resolve(sourceOrigin.name.file) !== path.resolve(params.userConfigPath)) return;
468
+ const configuredSource = path.resolve(bundled.source);
469
+ if (configuredSource === path.resolve(params.bundledMarketplacePath)) return;
470
+ if (!(params.legacySources ?? resolveMacOSDesktopCodexBundledMarketplaceCandidates()).some((source) => path.resolve(source) === configuredSource)) return;
471
+ await params.request("marketplace/remove", { marketplaceName: BUNDLED_MARKETPLACE_NAME });
472
+ }
444
473
  async function listComputerUseMarketplaceCandidates(request, config) {
445
474
  return findComputerUseMarketplaces(await request("plugin/list", { cwds: [] }), config.pluginName);
446
475
  }
@@ -453,6 +482,7 @@ function shouldAddBundledComputerUseMarketplace(params) {
453
482
  }
454
483
  function resolveBundledComputerUseMarketplacePath(params) {
455
484
  if (params.defaultBundledMarketplacePath) return existsSync(params.defaultBundledMarketplacePath) ? params.defaultBundledMarketplacePath : void 0;
485
+ if (!params.defaultBundledMarketplacePathCandidates) return;
456
486
  return resolveFirstExistingMacOSDesktopCodexBundledMarketplacePath({ candidates: params.defaultBundledMarketplacePathCandidates });
457
487
  }
458
488
  function findComputerUseMarketplaces(listed, pluginName) {
@@ -790,4 +820,4 @@ function buildMetadataCacheEntryKey(appCacheKey, queryKind, requestParams, catal
790
820
  ]);
791
821
  }
792
822
  //#endregion
793
- export { runCodexComputerUseLiveTest as a, readCodexComputerUseStatus as i, ensureCodexComputerUse as n, killStaleComputerUseMcpChildren as o, installCodexComputerUse as r, defaultCodexPluginMetadataCache as t };
823
+ export { runCodexComputerUseLiveTest as a, readCodexComputerUseStatus as i, ensureCodexComputerUse as n, installCodexComputerUse as r, defaultCodexPluginMetadataCache as t };