@openclaw/codex 2026.7.2-beta.5 → 2026.7.33

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 (66) hide show
  1. package/README.md +3 -27
  2. package/dist/{command-formatters-ico4ZFnk.js → .setup/app-server-policy-C_qTMEMy.mjs} +51 -9
  3. package/dist/{attempt-notifications-CMR2_fmR.js → .setup/attempt-notifications-F8krwWL4.mjs} +6 -3
  4. package/dist/{command-handlers-CRmnwI2N.js → .setup/command-handlers-DSRFfor4.mjs} +1156 -1319
  5. package/dist/.setup/command-rpc-BvYsfQ7G.mjs +786 -0
  6. package/dist/{compact-dEN49UH6.js → .setup/compact-BNgh7I4t.mjs} +10 -40
  7. package/dist/.setup/computer-use-C3QkmSO3.mjs +377 -0
  8. package/dist/.setup/config-CYEDnLJ2.mjs +1138 -0
  9. package/dist/{conversation-binding-data-BHRpYbX3.js → .setup/conversation-binding-data-CrRxtDBu.mjs} +1 -1
  10. package/dist/{bounded-turn-FEbUXoYT.js → .setup/media-understanding-provider-EbJCyDqe.mjs} +193 -92
  11. package/dist/{models-BA01NEez.js → .setup/models-C_aZk03A.mjs} +11 -6
  12. package/dist/.setup/notification-correlation-iYs4WieS.mjs +35 -0
  13. package/dist/.setup/plugin-app-cache-key-DR8jV9oS.mjs +99 -0
  14. package/dist/.setup/protocol-2POPqAY4.mjs +13 -0
  15. package/dist/{protocol-validators-Dm4eXZmt.js → .setup/protocol-validators-dZQ-UTOa.mjs} +111 -334
  16. package/dist/{rate-limits-S_PXs0ul.js → .setup/provider-DGxDs6g8.mjs} +269 -13
  17. package/dist/{dynamic-tools-LIt9ojep.js → .setup/provider-capabilities-DS2N_zc1.mjs} +5465 -3399
  18. package/dist/.setup/request-DFR0JyoV.mjs +36 -0
  19. package/dist/.setup/run-attempt-C7xEKFVB.mjs +8180 -0
  20. package/dist/{sandbox-guard-D1Wky__S.js → .setup/sandbox-guard-DA2TQfZW.mjs} +1 -10
  21. package/dist/.setup/session-binding-DuihlMJc.mjs +628 -0
  22. package/dist/.setup/shared-client-B2KmLPRw.mjs +1854 -0
  23. package/dist/{side-question-CO12sHxo.js → .setup/side-question-Cv6JXWCS.mjs} +84 -159
  24. package/dist/{thread-lifecycle-DRg_FdzC.js → .setup/thread-lifecycle-u6CZdOOH.mjs} +1159 -1799
  25. package/dist/{web-search-provider.runtime-CaQMYDbp.js → .setup/web-search-provider.runtime-Ce2zOHxW.mjs} +3 -3
  26. package/dist/doctor-contract-api.js +122 -88
  27. package/dist/harness.js +20 -85
  28. package/dist/index.js +381 -1537
  29. package/dist/media-understanding-provider.js +1 -173
  30. package/dist/prompt-overlay.js +15 -0
  31. package/dist/provider-catalog.js +79 -0
  32. package/dist/provider-discovery.js +34 -0
  33. package/dist/provider.js +2 -0
  34. package/dist/web-search-contract-api.js +1 -1
  35. package/openclaw.plugin.json +178 -221
  36. package/package.json +8 -10
  37. package/dist/app-server-policy-BmDgseo_.js +0 -49
  38. package/dist/attempt-client-cleanup-Ia52yRWc.js +0 -127
  39. package/dist/auth-binding-B4FfbcCg.js +0 -62
  40. package/dist/capabilities-BHRSI6Cn.js +0 -36
  41. package/dist/cli-metadata.js +0 -20
  42. package/dist/computer-use-BjGylO-E.js +0 -695
  43. package/dist/conversation-control-DE7d9DOj.js +0 -287
  44. package/dist/event-projector-assistant-message-DTgnPPVF.js +0 -101
  45. package/dist/event-projector-usage-tvgb1NCX.js +0 -69
  46. package/dist/incognito-session-ET_ufDH-.js +0 -2
  47. package/dist/notification-correlation-Bj_Ak_jI.js +0 -67
  48. package/dist/plugin-app-cache-key-DSXX-rXO.js +0 -315
  49. package/dist/realtime-voice-api-BPcA1uN9.js +0 -494
  50. package/dist/realtime-voice-api.js +0 -2
  51. package/dist/request-CXpPennK.js +0 -157
  52. package/dist/run-attempt-C5GTPJOE.js +0 -11935
  53. package/dist/runtime-artifact-C2ITXdhM.js +0 -488
  54. package/dist/session-binding-DlVQ-Pxs.js +0 -2161
  55. package/dist/session-catalog-CP2oCcEb.js +0 -2444
  56. package/dist/session-cli-CqZ0Fp2a.js +0 -175
  57. package/dist/session-upstream-marker-QE-m5QFG.js +0 -82
  58. package/dist/settled-turn-finalizer-CA_2QXIE.js +0 -303
  59. package/dist/shared-client-BVKE40c-.js +0 -2952
  60. package/dist/transcript-mirror-uKA-A4tB.js +0 -550
  61. package/dist/transport-stdio-DXgGZ7Ib.js +0 -88
  62. package/dist/upstream-session-fork-_Vrz4WJr.js +0 -320
  63. package/dist/usage-UpVbdX5G.js +0 -25
  64. /package/dist/{rolldown-runtime-8H4AJuhK.js → .setup/rolldown-runtime-8H4AJuhK.mjs} +0 -0
  65. /package/dist/{session-binding-meta-B7aEMU7g.js → .setup/session-binding-meta-B7aEMU7g.mjs} +0 -0
  66. /package/dist/{web-search-provider.shared-BrZmlqyR.js → .setup/web-search-provider.shared-BrZmlqyR.mjs} +0 -0
@@ -1,10 +1,11 @@
1
- import { V as isJsonObject, _ as CodexAppServerRpcError, a as getLeasedSharedCodexAppServerClient, l as releaseLeasedSharedCodexAppServerClient } from "./shared-client-BVKE40c-.js";
2
- import { l as sessionBindingIdentity, t as CODEX_APP_SERVER_BINDING_GUARDED_REQUEST_TIMEOUT_MS } from "./session-binding-DlVQ-Pxs.js";
3
- import { _ as readCodexNotificationItem } from "./attempt-notifications-CMR2_fmR.js";
4
- import { n as resolveCodexNativeExecutionBlock } from "./sandbox-guard-D1Wky__S.js";
5
- import { a as resolveCodexBindingAppServerConnection, n as readCodexNotificationThreadId, r as readCodexNotificationTurnId } from "./notification-correlation-Bj_Ak_jI.js";
1
+ import { r as isJsonObject } from "./protocol-2POPqAY4.mjs";
2
+ import { _ as readCodexNotificationItem } from "./attempt-notifications-F8krwWL4.mjs";
3
+ import { d as resolveCodexAppServerRuntimeOptions } from "./config-CYEDnLJ2.mjs";
4
+ import { a as getLeasedSharedCodexAppServerClient, o as releaseLeasedSharedCodexAppServerClient, u as CodexAppServerRpcError } from "./shared-client-B2KmLPRw.mjs";
5
+ import { s as sessionBindingIdentity, t as CODEX_APP_SERVER_BINDING_GUARDED_REQUEST_TIMEOUT_MS } from "./session-binding-DuihlMJc.mjs";
6
+ import { n as resolveCodexNativeExecutionBlock } from "./sandbox-guard-DA2TQfZW.mjs";
7
+ import { n as readCodexNotificationThreadId, r as readCodexNotificationTurnId } from "./notification-correlation-iYs4WieS.mjs";
6
8
  import { embeddedAgentLog, resolveCompactionTimeoutMs } from "openclaw/plugin-sdk/agent-harness-runtime";
7
- import { resolveAgentDir as resolveAgentDir$1, resolveDefaultAgentId } from "openclaw/plugin-sdk/agent-runtime";
8
9
  //#region extensions/codex/src/app-server/compact.ts
9
10
  /**
10
11
  * Native Codex app-server compaction bridge for bound OpenClaw sessions.
@@ -261,7 +262,6 @@ function readIgnoredCompactionOverridePaths(params) {
261
262
  const inheritedProvider = !localProvider && typeof entry.inheritedRecord?.provider === "string" ? entry.inheritedRecord.provider.trim() : "";
262
263
  const providerPath = localProvider ? `${entry.path}.compaction.provider` : inheritedProvider && entry.inheritedPath ? `${entry.inheritedPath}.compaction.provider` : void 0;
263
264
  if (typeof entry.record.model === "string" && entry.record.model.trim()) ignored.add(`${entry.path}.compaction.model`);
264
- if (typeof entry.record.thinkingLevel === "string" && entry.record.thinkingLevel.trim()) ignored.add(`${entry.path}.compaction.thinkingLevel`);
265
265
  if (providerPath) ignored.add(providerPath);
266
266
  }
267
267
  return [...ignored];
@@ -331,6 +331,7 @@ async function compactCodexNativeThread(params, options) {
331
331
  compacted: false,
332
332
  reason: nativeExecutionBlock
333
333
  };
334
+ const appServer = resolveCodexAppServerRuntimeOptions({ pluginConfig: options.pluginConfig });
334
335
  const bindingIdentity = sessionBindingIdentity({
335
336
  sessionId: params.sessionId,
336
337
  sessionKey: params.sessionKey,
@@ -344,48 +345,18 @@ async function compactCodexNativeThread(params, options) {
344
345
  });
345
346
  let binding = initialBinding;
346
347
  const requestedAuthProfileId = params.authProfileId?.trim() || void 0;
347
- let connection;
348
- try {
349
- const config = params.config ?? {};
350
- const agentId = params.agentId ?? readAgentIdFromSessionKey(params.sessionKey) ?? resolveDefaultAgentId(config);
351
- connection = resolveCodexBindingAppServerConnection({
352
- binding,
353
- authProfileId: requestedAuthProfileId ?? binding.authProfileId,
354
- pluginConfig: options.pluginConfig,
355
- config,
356
- agentDir: resolveAgentDir$1(config, agentId)
357
- });
358
- } catch (error) {
359
- return {
360
- ok: false,
361
- compacted: false,
362
- reason: formatCompactionError(error)
363
- };
364
- }
365
- const { appServer, usesSupervisionConnection } = connection;
366
- if (!usesSupervisionConnection && requestedAuthProfileId && binding.authProfileId && binding.authProfileId !== requestedAuthProfileId) return {
348
+ if (requestedAuthProfileId && binding.authProfileId && binding.authProfileId !== requestedAuthProfileId) return {
367
349
  ok: false,
368
350
  compacted: false,
369
351
  reason: "auth profile mismatch for session binding"
370
352
  };
371
353
  const shouldReleaseDefaultLease = !options.clientFactory;
372
354
  const clientFactory = options.clientFactory ?? getLeasedSharedCodexAppServerClient;
373
- const runtimeAuthPlan = params.runtimeAuthPlan ?? params.runtimePlan?.auth;
374
- const usesPreparedApiKey = !usesSupervisionConnection && appServer.start.homeScope !== "user" && runtimeAuthPlan?.modelRoute?.authRequirement === "api-key";
375
- const preparedApiKey = usesPreparedApiKey ? params.resolvedApiKey?.trim() : void 0;
376
- if (usesPreparedApiKey && !preparedApiKey) return {
377
- ok: false,
378
- compacted: false,
379
- reason: "Prepared Codex Platform compaction route is missing its resolved API key."
380
- };
381
355
  try {
382
356
  return await runExclusiveCodexNativeCompaction(binding.threadId, params.abortSignal, async () => {
383
357
  const client = await clientFactory({
384
358
  startOptions: appServer.start,
385
- ...preparedApiKey ? { preparedAuth: {
386
- kind: "api-key",
387
- apiKey: preparedApiKey
388
- } } : { authProfileId: connection.clientAuthProfileId },
359
+ authProfileId: requestedAuthProfileId ?? binding.authProfileId,
389
360
  agentDir: params.agentDir,
390
361
  config: params.config
391
362
  });
@@ -404,7 +375,6 @@ async function compactCodexNativeThread(params, options) {
404
375
  if (transportStopped) return;
405
376
  throw new Error("failed to stop unconfirmed codex app-server process");
406
377
  }
407
- if (usesSupervisionConnection) throw new Error("cannot detach an unconfirmed supervised codex thread");
408
378
  if (await options.bindingStore.mutate(bindingIdentity, {
409
379
  kind: "clear",
410
380
  threadId: binding.threadId
@@ -0,0 +1,377 @@
1
+ import { d as resolveCodexAppServerRuntimeOptions, p as resolveCodexComputerUseConfig } from "./config-CYEDnLJ2.mjs";
2
+ import { i as describeControlFailure } from "./plugin-app-cache-key-DR8jV9oS.mjs";
3
+ import { t as requestCodexAppServerJson } from "./request-DFR0JyoV.mjs";
4
+ import { existsSync } from "node:fs";
5
+ //#region extensions/codex/src/app-server/computer-use.ts
6
+ /**
7
+ * Computer Use plugin/MCP readiness checks and optional install flow for Codex
8
+ * app-server sessions.
9
+ */
10
+ var CodexComputerUseSetupError = class extends Error {
11
+ constructor(status) {
12
+ super(status.message);
13
+ this.name = "CodexComputerUseSetupError";
14
+ this.status = status;
15
+ }
16
+ };
17
+ const CURATED_MARKETPLACE_POLL_INTERVAL_MS = 2e3;
18
+ const COMPUTER_USE_MARKETPLACE_NAME_PRIORITY = [
19
+ "openai-bundled",
20
+ "openai-curated",
21
+ "local"
22
+ ];
23
+ const DEFAULT_CODEX_BUNDLED_MARKETPLACE_PATH = "/Applications/Codex.app/Contents/Resources/plugins/openai-bundled";
24
+ /** Reads Computer Use readiness without installing or mutating app-server state. */
25
+ async function readCodexComputerUseStatus(params = {}) {
26
+ const config = resolveComputerUseConfig(params);
27
+ if (!config.enabled) return disabledStatus(config);
28
+ try {
29
+ return await inspectCodexComputerUse({
30
+ ...params,
31
+ config,
32
+ installPlugin: false
33
+ });
34
+ } catch (error) {
35
+ return unavailableStatus(config, "check_failed", `Computer Use check failed: ${describeControlFailure(error)}`);
36
+ }
37
+ }
38
+ /**
39
+ * Ensures Computer Use is ready when enabled, optionally installing when config
40
+ * allows safe auto-install.
41
+ */
42
+ async function ensureCodexComputerUse(params = {}) {
43
+ const config = resolveComputerUseConfig(params);
44
+ if (!config.enabled) return disabledStatus(config);
45
+ const status = await inspectCodexComputerUse({
46
+ ...params,
47
+ config,
48
+ installPlugin: false
49
+ });
50
+ if (status.ready) return status;
51
+ if (config.autoInstall) {
52
+ const blockedAutoInstallStatus = blockUnsafeAutoInstallStatus(config);
53
+ if (blockedAutoInstallStatus) throw new CodexComputerUseSetupError(blockedAutoInstallStatus);
54
+ const installedStatus = await inspectCodexComputerUse({
55
+ ...params,
56
+ config,
57
+ installPlugin: true
58
+ });
59
+ if (!installedStatus.ready) throw new CodexComputerUseSetupError(installedStatus);
60
+ return installedStatus;
61
+ }
62
+ if (!status.ready) throw new CodexComputerUseSetupError(status);
63
+ return status;
64
+ }
65
+ /** Forces Computer Use plugin installation and returns the ready status. */
66
+ async function installCodexComputerUse(params = {}) {
67
+ const config = resolveComputerUseConfig({
68
+ ...params,
69
+ forceEnable: true,
70
+ overrides: {
71
+ ...params.overrides,
72
+ enabled: true,
73
+ autoInstall: true
74
+ }
75
+ });
76
+ const status = await inspectCodexComputerUse({
77
+ ...params,
78
+ config,
79
+ installPlugin: true
80
+ });
81
+ if (!status.ready) throw new CodexComputerUseSetupError(status);
82
+ return status;
83
+ }
84
+ async function inspectCodexComputerUse(params) {
85
+ const request = createComputerUseRequest(params);
86
+ if (params.installPlugin) await request("experimentalFeature/enablement/set", { enablement: { plugins: true } });
87
+ const marketplace = await resolveMarketplaceRef({
88
+ request,
89
+ config: params.config,
90
+ allowAdd: params.installPlugin,
91
+ signal: params.signal,
92
+ defaultBundledMarketplacePath: params.defaultBundledMarketplacePath
93
+ });
94
+ if (!marketplace.marketplace) return unavailableStatus(params.config, "marketplace_missing", marketplace.message ?? `No Codex marketplace containing ${params.config.pluginName} is registered. Configure computerUse.marketplaceSource or computerUse.marketplacePath, then run /codex computer-use install.`);
95
+ const pluginInspection = await ensureComputerUsePlugin({
96
+ request,
97
+ config: params.config,
98
+ marketplace: marketplace.marketplace,
99
+ installPlugin: params.installPlugin
100
+ });
101
+ if (!pluginInspection.ok) return pluginInspection.status;
102
+ return await readComputerUseTools({
103
+ request,
104
+ config: params.config,
105
+ plugin: pluginInspection.plugin,
106
+ installPlugin: params.installPlugin
107
+ });
108
+ }
109
+ async function ensureComputerUsePlugin(params) {
110
+ let plugin = await readComputerUsePlugin(params.request, params.marketplace, params.config.pluginName);
111
+ if (!plugin.summary.installed || !plugin.summary.enabled) {
112
+ if (!params.installPlugin) return {
113
+ ok: false,
114
+ status: statusFromPlugin({
115
+ config: params.config,
116
+ plugin,
117
+ tools: [],
118
+ reason: pluginSetupReason(plugin, params.marketplace),
119
+ message: pluginSetupMessage(params.config, plugin, params.marketplace)
120
+ })
121
+ };
122
+ if (params.marketplace.kind === "remote") return {
123
+ ok: false,
124
+ status: statusFromPlugin({
125
+ config: params.config,
126
+ plugin,
127
+ tools: [],
128
+ reason: "remote_install_unsupported",
129
+ message: remoteInstallUnsupportedMessage(plugin, params.marketplace)
130
+ })
131
+ };
132
+ await params.request("plugin/install", pluginRequestParams(params.marketplace, params.config.pluginName));
133
+ await reloadMcpServers(params.request);
134
+ plugin = await readComputerUsePlugin(params.request, params.marketplace, params.config.pluginName);
135
+ }
136
+ if (!plugin.summary.installed || !plugin.summary.enabled) return {
137
+ ok: false,
138
+ status: statusFromPlugin({
139
+ config: params.config,
140
+ plugin,
141
+ tools: [],
142
+ reason: pluginSetupReason(plugin, params.marketplace),
143
+ message: pluginSetupMessage(params.config, plugin, params.marketplace)
144
+ })
145
+ };
146
+ return {
147
+ ok: true,
148
+ plugin
149
+ };
150
+ }
151
+ async function readComputerUseTools(params) {
152
+ let server = await readMcpServerStatus(params.request, params.config.mcpServerName);
153
+ if (!server && params.installPlugin) {
154
+ await reloadMcpServers(params.request);
155
+ server = await readMcpServerStatus(params.request, params.config.mcpServerName);
156
+ }
157
+ if (!server) return statusFromPlugin({
158
+ config: params.config,
159
+ plugin: params.plugin,
160
+ tools: [],
161
+ reason: "mcp_missing",
162
+ message: `Computer Use is installed, but the ${params.config.mcpServerName} MCP server is not available.`
163
+ });
164
+ return statusFromPlugin({
165
+ config: params.config,
166
+ plugin: params.plugin,
167
+ tools: Object.keys(server.tools).toSorted(),
168
+ reason: "ready",
169
+ message: "Computer Use is ready."
170
+ });
171
+ }
172
+ async function resolveMarketplaceRef(params) {
173
+ let preferredMarketplaceName = params.config.marketplaceName;
174
+ if (params.config.marketplaceSource && params.allowAdd) {
175
+ const added = await params.request("marketplace/add", { source: params.config.marketplaceSource });
176
+ preferredMarketplaceName ??= added.marketplaceName;
177
+ }
178
+ if (params.config.marketplacePath) return { marketplace: preferredMarketplaceName ? {
179
+ kind: "local",
180
+ name: preferredMarketplaceName,
181
+ path: params.config.marketplacePath
182
+ } : {
183
+ kind: "local",
184
+ path: params.config.marketplacePath
185
+ } };
186
+ let candidates = await listComputerUseMarketplaceCandidates(params.request, params.config);
187
+ if (candidates.length === 0 && shouldAddBundledComputerUseMarketplace(params)) {
188
+ const bundledMarketplacePath = params.defaultBundledMarketplacePath ?? DEFAULT_CODEX_BUNDLED_MARKETPLACE_PATH;
189
+ const added = await params.request("marketplace/add", { source: bundledMarketplacePath });
190
+ preferredMarketplaceName ??= added.marketplaceName;
191
+ candidates = await listComputerUseMarketplaceCandidates(params.request, params.config);
192
+ }
193
+ const waitUntil = marketplaceDiscoveryWaitUntil(params);
194
+ while (candidates.length === 0) {
195
+ if (Date.now() >= waitUntil) break;
196
+ await delay(Math.min(CURATED_MARKETPLACE_POLL_INTERVAL_MS, waitUntil - Date.now()), params.signal);
197
+ candidates = await listComputerUseMarketplaceCandidates(params.request, params.config);
198
+ }
199
+ if (preferredMarketplaceName) {
200
+ const preferred = candidates.find((candidate) => candidate.name === preferredMarketplaceName);
201
+ if (preferred) return { marketplace: preferred };
202
+ return { message: `Configured Codex marketplace ${preferredMarketplaceName} was not found or does not contain ${params.config.pluginName}. Run /codex computer-use install with a source or path to install from a new marketplace.` };
203
+ }
204
+ if (candidates.length > 1) {
205
+ const preferred = chooseKnownComputerUseMarketplace(candidates);
206
+ if (preferred) return { marketplace: preferred };
207
+ return { message: `Multiple Codex marketplaces contain ${params.config.pluginName}. Configure computerUse.marketplaceName or computerUse.marketplacePath to choose one.` };
208
+ }
209
+ if (params.config.marketplaceSource && !params.allowAdd && candidates.length === 0) return { message: "Computer Use marketplace source is configured but has not been registered. Run /codex computer-use install to register it." };
210
+ const marketplace = candidates[0];
211
+ return marketplace ? { marketplace } : {};
212
+ }
213
+ async function listComputerUseMarketplaceCandidates(request, config) {
214
+ return findComputerUseMarketplaces(await request("plugin/list", { cwds: [] }), config.pluginName);
215
+ }
216
+ function blockUnsafeAutoInstallStatus(config) {
217
+ if (!config.marketplaceSource) return;
218
+ return unavailableStatus(config, "auto_install_blocked", "Computer Use auto-install only uses marketplaces Codex app-server has already discovered. Run /codex computer-use install to install from a configured marketplace source.");
219
+ }
220
+ function shouldAddBundledComputerUseMarketplace(params) {
221
+ const bundledMarketplacePath = params.defaultBundledMarketplacePath ?? DEFAULT_CODEX_BUNDLED_MARKETPLACE_PATH;
222
+ return params.allowAdd && !params.config.marketplaceSource && !params.config.marketplacePath && !params.config.marketplaceName && existsSync(bundledMarketplacePath);
223
+ }
224
+ function findComputerUseMarketplaces(listed, pluginName) {
225
+ return listed.marketplaces.filter((marketplace) => marketplace.plugins.some((plugin) => plugin.name === pluginName || plugin.id === pluginName || plugin.id === `${pluginName}@${marketplace.name}`)).map((marketplace) => {
226
+ if (marketplace.path) return {
227
+ kind: "local",
228
+ name: marketplace.name,
229
+ path: marketplace.path
230
+ };
231
+ return {
232
+ kind: "remote",
233
+ name: marketplace.name,
234
+ remoteMarketplaceName: marketplace.name
235
+ };
236
+ });
237
+ }
238
+ function chooseKnownComputerUseMarketplace(candidates) {
239
+ for (const marketplaceName of COMPUTER_USE_MARKETPLACE_NAME_PRIORITY) {
240
+ const candidate = candidates.find((marketplace) => marketplace.name === marketplaceName);
241
+ if (candidate) return candidate;
242
+ }
243
+ }
244
+ function marketplaceDiscoveryWaitUntil(params) {
245
+ if (params.allowAdd && !params.config.marketplaceSource && !params.config.marketplacePath && !params.config.marketplaceName) return Date.now() + params.config.marketplaceDiscoveryTimeoutMs;
246
+ return 0;
247
+ }
248
+ async function delay(ms, signal) {
249
+ if (signal?.aborted) throw abortError(signal);
250
+ await new Promise((resolve, reject) => {
251
+ const onAbort = () => {
252
+ clearTimeout(timer);
253
+ signal?.removeEventListener("abort", onAbort);
254
+ reject(abortError(signal));
255
+ };
256
+ const timer = setTimeout(() => {
257
+ signal?.removeEventListener("abort", onAbort);
258
+ resolve();
259
+ }, ms);
260
+ signal?.addEventListener("abort", onAbort, { once: true });
261
+ });
262
+ }
263
+ function abortError(signal) {
264
+ const reason = signal?.reason;
265
+ return reason instanceof Error ? reason : /* @__PURE__ */ new Error("Computer Use setup was aborted.");
266
+ }
267
+ async function readComputerUsePlugin(request, marketplace, pluginName) {
268
+ return (await request("plugin/read", pluginRequestParams(marketplace, pluginName))).plugin;
269
+ }
270
+ async function readMcpServerStatus(request, serverName) {
271
+ let cursor;
272
+ do {
273
+ const response = await request("mcpServerStatus/list", {
274
+ cursor,
275
+ limit: 100,
276
+ detail: "toolsAndAuthOnly"
277
+ });
278
+ const found = response.data.find((server) => server.name === serverName);
279
+ if (found) return found;
280
+ cursor = response.nextCursor;
281
+ } while (cursor);
282
+ }
283
+ async function reloadMcpServers(request) {
284
+ await request("config/mcpServer/reload", void 0);
285
+ }
286
+ function pluginRequestParams(marketplace, pluginName) {
287
+ return {
288
+ ...marketplace.kind === "local" ? { marketplacePath: marketplace.path } : {},
289
+ ...marketplace.kind === "remote" ? { remoteMarketplaceName: marketplace.remoteMarketplaceName } : {},
290
+ pluginName
291
+ };
292
+ }
293
+ function pluginSetupReason(plugin, marketplace) {
294
+ if (marketplace.kind === "remote") return "remote_install_unsupported";
295
+ return plugin.summary.installed ? "plugin_disabled" : "plugin_not_installed";
296
+ }
297
+ function pluginSetupMessage(config, plugin, marketplace) {
298
+ if (marketplace.kind === "remote") return remoteInstallUnsupportedMessage(plugin, marketplace);
299
+ if (!plugin.summary.installed) return "Computer Use is available but not installed. Run /codex computer-use install or enable computerUse.autoInstall.";
300
+ return `Computer Use is installed, but the ${config.pluginName} plugin is disabled. Run /codex computer-use install or enable computerUse.autoInstall to re-enable it.`;
301
+ }
302
+ function remoteInstallUnsupportedMessage(plugin, marketplace) {
303
+ const marketplaceName = marketplace.name ?? plugin.marketplaceName;
304
+ return `Computer Use is ${plugin.summary.installed ? "installed but disabled" : "available"} in remote Codex marketplace ${marketplaceName}, but Codex app-server does not support remote plugin install yet. Configure computerUse.marketplaceSource or computerUse.marketplacePath for a local marketplace, then run /codex computer-use install.`;
305
+ }
306
+ function statusFromPlugin(params) {
307
+ return {
308
+ enabled: true,
309
+ ready: params.plugin.summary.installed && params.plugin.summary.enabled && params.tools.length > 0,
310
+ reason: params.reason,
311
+ installed: params.plugin.summary.installed,
312
+ pluginEnabled: params.plugin.summary.enabled,
313
+ mcpServerAvailable: params.tools.length > 0,
314
+ pluginName: params.config.pluginName,
315
+ mcpServerName: params.config.mcpServerName,
316
+ marketplaceName: params.plugin.marketplaceName,
317
+ ...params.plugin.marketplacePath ? { marketplacePath: params.plugin.marketplacePath } : {},
318
+ tools: params.tools,
319
+ message: params.message
320
+ };
321
+ }
322
+ function disabledStatus(config) {
323
+ return {
324
+ enabled: false,
325
+ ready: false,
326
+ reason: "disabled",
327
+ installed: false,
328
+ pluginEnabled: false,
329
+ mcpServerAvailable: false,
330
+ pluginName: config.pluginName,
331
+ mcpServerName: config.mcpServerName,
332
+ tools: [],
333
+ message: "Computer Use is disabled."
334
+ };
335
+ }
336
+ function unavailableStatus(config, reason, message) {
337
+ return {
338
+ enabled: true,
339
+ ready: false,
340
+ reason,
341
+ installed: false,
342
+ pluginEnabled: false,
343
+ mcpServerAvailable: false,
344
+ pluginName: config.pluginName,
345
+ mcpServerName: config.mcpServerName,
346
+ ...config.marketplaceName ? { marketplaceName: config.marketplaceName } : {},
347
+ ...config.marketplacePath ? { marketplacePath: config.marketplacePath } : {},
348
+ tools: [],
349
+ message
350
+ };
351
+ }
352
+ function createComputerUseRequest(params) {
353
+ if (params.request) return params.request;
354
+ if (params.client) return async (method, requestParams) => await params.client.request(method, requestParams, {
355
+ timeoutMs: params.timeoutMs,
356
+ signal: params.signal
357
+ });
358
+ const runtime = resolveCodexAppServerRuntimeOptions({ pluginConfig: params.pluginConfig });
359
+ return async (method, requestParams) => await requestCodexAppServerJson({
360
+ method,
361
+ requestParams,
362
+ timeoutMs: params.timeoutMs ?? runtime.requestTimeoutMs,
363
+ startOptions: runtime.start
364
+ });
365
+ }
366
+ function resolveComputerUseConfig(params) {
367
+ const overrides = params.forceEnable ? {
368
+ ...params.overrides,
369
+ enabled: true
370
+ } : params.overrides;
371
+ return resolveCodexComputerUseConfig({
372
+ pluginConfig: params.pluginConfig,
373
+ overrides
374
+ });
375
+ }
376
+ //#endregion
377
+ export { installCodexComputerUse as n, readCodexComputerUseStatus as r, ensureCodexComputerUse as t };