@openclaw/codex 2026.7.2-beta.7 → 2026.7.34
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -27
- package/dist/{command-formatters-C336eRVS.js → .setup/app-server-policy-C_qTMEMy.mjs} +51 -9
- package/dist/{attempt-notifications-AP-a-Q5k.js → .setup/attempt-notifications-F8krwWL4.mjs} +6 -3
- package/dist/{command-handlers-DAHUSry9.js → .setup/command-handlers-DSRFfor4.mjs} +1156 -1319
- package/dist/.setup/command-rpc-BvYsfQ7G.mjs +786 -0
- package/dist/{compact-D_uvHurS.js → .setup/compact-BNgh7I4t.mjs} +10 -40
- package/dist/.setup/computer-use-C3QkmSO3.mjs +377 -0
- package/dist/.setup/config-CYEDnLJ2.mjs +1138 -0
- package/dist/{conversation-binding-data-BHRpYbX3.js → .setup/conversation-binding-data-CrRxtDBu.mjs} +1 -1
- package/dist/{bounded-turn-D2ZAgZVz.js → .setup/media-understanding-provider-EbJCyDqe.mjs} +203 -109
- package/dist/{models-BBMKU4jA.js → .setup/models-C_aZk03A.mjs} +11 -6
- package/dist/.setup/notification-correlation-iYs4WieS.mjs +35 -0
- package/dist/.setup/plugin-app-cache-key-DR8jV9oS.mjs +99 -0
- package/dist/.setup/protocol-2POPqAY4.mjs +13 -0
- package/dist/{transcript-mirror-DzsdNCf5.js → .setup/protocol-validators-dZQ-UTOa.mjs} +112 -922
- package/dist/{rate-limits-CU-gVCCS.js → .setup/provider-DGxDs6g8.mjs} +269 -13
- package/dist/{dynamic-tools-D2gYkSBO.js → .setup/provider-capabilities-DS2N_zc1.mjs} +5632 -3953
- package/dist/.setup/request-DFR0JyoV.mjs +36 -0
- package/dist/.setup/run-attempt-C7xEKFVB.mjs +8180 -0
- package/dist/{sandbox-guard-NuhpXmPB.js → .setup/sandbox-guard-DA2TQfZW.mjs} +1 -14
- package/dist/.setup/session-binding-DuihlMJc.mjs +628 -0
- package/dist/.setup/shared-client-B2KmLPRw.mjs +1854 -0
- package/dist/{side-question-_ulBk1AL.js → .setup/side-question-Cv6JXWCS.mjs} +84 -159
- package/dist/.setup/thread-lifecycle-u6CZdOOH.mjs +2593 -0
- package/dist/{web-search-provider.runtime-CCFhg2z5.js → .setup/web-search-provider.runtime-Ce2zOHxW.mjs} +3 -3
- package/dist/doctor-contract-api.js +122 -88
- package/dist/harness.js +20 -89
- package/dist/index.js +436 -1615
- package/dist/media-understanding-provider.js +1 -173
- package/dist/prompt-overlay.js +15 -0
- package/dist/provider-catalog.js +79 -0
- package/dist/provider-discovery.js +34 -0
- package/dist/provider.js +2 -0
- package/dist/web-search-contract-api.js +1 -1
- package/openclaw.plugin.json +178 -221
- package/package.json +8 -9
- package/dist/app-server-policy-BSaO2JIT.js +0 -49
- package/dist/auth-binding-B4FfbcCg.js +0 -62
- package/dist/capabilities-BFDTVYr4.js +0 -36
- package/dist/cli-metadata.js +0 -20
- package/dist/computer-use-CYEc8U3w.js +0 -693
- package/dist/conversation-control-xsIeXbo4.js +0 -287
- package/dist/effective-mcp-catalog-Bbd98Inw.js +0 -114
- package/dist/event-projector-assistant-message-DTgnPPVF.js +0 -101
- package/dist/event-projector-usage-Xp4AlR2k.js +0 -86
- package/dist/incognito-session-ET_ufDH-.js +0 -2
- package/dist/notification-correlation-CU6_AnOb.js +0 -67
- package/dist/plugin-app-cache-key-DztPafOA.js +0 -408
- package/dist/request-qKh331yu.js +0 -157
- package/dist/run-attempt-CY9WlDLc.js +0 -12413
- package/dist/runtime-artifact-CmtG_t1L.js +0 -554
- package/dist/session-binding-BXpo9ymA.js +0 -2214
- package/dist/session-catalog-DyOgR4WH.js +0 -2668
- package/dist/session-cli-2PZaFLRh.js +0 -175
- package/dist/session-upstream-marker-B6U7tLw5.js +0 -82
- package/dist/settled-turn-finalizer-CXY2Z9dT.js +0 -316
- package/dist/shared-client-DTbvH-XV.js +0 -3069
- package/dist/thread-lifecycle-DF53ogiA.js +0 -3987
- package/dist/transport-stdio-DXgGZ7Ib.js +0 -88
- package/dist/upstream-session-fork-Dy4Xvuoj.js +0 -320
- package/dist/usage-CQ6GhD5-.js +0 -25
- /package/dist/{rolldown-runtime-8H4AJuhK.js → .setup/rolldown-runtime-8H4AJuhK.mjs} +0 -0
- /package/dist/{session-binding-meta-B7aEMU7g.js → .setup/session-binding-meta-B7aEMU7g.mjs} +0 -0
- /package/dist/{web-search-provider.shared-BrZmlqyR.js → .setup/web-search-provider.shared-BrZmlqyR.mjs} +0 -0
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
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
|
-
|
|
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
|
-
|
|
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 };
|