@openclaw/codex 2026.7.1 → 2026.7.2-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. package/README.md +27 -3
  2. package/dist/app-server-policy-Scc-Wevo.js +49 -0
  3. package/dist/{attempt-notifications-BGsEIIDI.js → attempt-notifications-BFmNhqFl.js} +3 -6
  4. package/dist/auth-binding-C1czuHPA.js +62 -0
  5. package/dist/cli-metadata.js +20 -0
  6. package/dist/{app-server-policy-C968Kgin.js → command-formatters-Dq9InZUK.js} +39 -51
  7. package/dist/{command-handlers-Dv-pzAmg.js → command-handlers-IgqmL_kv.js} +161 -61
  8. package/dist/{compact-4mVBriKT.js → compact-DCTmg3id.js} +39 -10
  9. package/dist/computer-use-CPcU8TjG.js +685 -0
  10. package/dist/conversation-control-CGkBlfc5.js +286 -0
  11. package/dist/doctor-contract-api.js +120 -81
  12. package/dist/{provider-capabilities-CDnHbmUZ.js → dynamic-tools-C_1tEs34.js} +6109 -5725
  13. package/dist/harness.js +59 -15
  14. package/dist/index.js +1460 -269
  15. package/dist/{media-understanding-provider-BHOu9-Gg.js → media-understanding-provider-D31dOJwb.js} +32 -15
  16. package/dist/media-understanding-provider.js +1 -1
  17. package/dist/{models-DDmO1zwd.js → models-uh26C8QU.js} +5 -9
  18. package/dist/notification-correlation-KmfV4EkP.js +67 -0
  19. package/dist/plugin-app-cache-key-Ceb-lm2c.js +315 -0
  20. package/dist/{provider-zjPfx5Fs.js → rate-limits-DyXaYAxU.js} +10 -266
  21. package/dist/request-B_oQsCXy.js +157 -0
  22. package/dist/{run-attempt-FUyOjGCV.js → run-attempt-MLzoMe_m.js} +7395 -6430
  23. package/dist/runtime-artifact-C2ITXdhM.js +488 -0
  24. package/dist/{sandbox-guard-DA2TQfZW.js → sandbox-guard-D1Wky__S.js} +10 -1
  25. package/dist/{config-CYEDnLJ2.js → session-binding-h1mmCGnl.js} +985 -31
  26. package/dist/session-catalog-CEvoXWHA.js +2412 -0
  27. package/dist/session-cli-XsEuWb_C.js +175 -0
  28. package/dist/{shared-client-4ICy3U6d.js → shared-client-JiAnW6pc.js} +2193 -1319
  29. package/dist/{side-question-N4OaDer2.js → side-question-DqDvIwSU.js} +140 -70
  30. package/dist/{thread-lifecycle-qWE88Dn2.js → thread-lifecycle-CN_pPtPh.js} +1826 -1188
  31. package/dist/{protocol-validators-dZQ-UTOa.js → transcript-mirror-D9rTxx2P.js} +485 -2
  32. package/dist/transport-stdio-DXgGZ7Ib.js +88 -0
  33. package/dist/usage-D5Rohxoc.js +25 -0
  34. package/dist/{web-search-provider.runtime-BSlriav6.js → web-search-provider.runtime-CKVBn3fP.js} +3 -3
  35. package/npm-shrinkwrap.json +56 -30
  36. package/openclaw.plugin.json +177 -14
  37. package/package.json +8 -6
  38. package/dist/command-rpc-eLM_mtC7.js +0 -784
  39. package/dist/computer-use-Bmaz333N.js +0 -377
  40. package/dist/notification-correlation-Bo7KB3ks.js +0 -35
  41. package/dist/plugin-app-cache-key-BrhVdeEf.js +0 -98
  42. package/dist/prompt-overlay.js +0 -15
  43. package/dist/protocol-2POPqAY4.js +0 -13
  44. package/dist/provider-catalog.js +0 -79
  45. package/dist/provider-discovery.js +0 -34
  46. package/dist/provider.js +0 -2
  47. package/dist/request-BcJyl8KL.js +0 -36
  48. package/dist/session-binding-C1ZXdP-x.js +0 -627
@@ -1,377 +0,0 @@
1
- import { d as resolveCodexAppServerRuntimeOptions, p as resolveCodexComputerUseConfig } from "./config-CYEDnLJ2.js";
2
- import { i as describeControlFailure } from "./plugin-app-cache-key-BrhVdeEf.js";
3
- import { t as requestCodexAppServerJson } from "./request-BcJyl8KL.js";
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 };
@@ -1,35 +0,0 @@
1
- import { r as isJsonObject } from "./protocol-2POPqAY4.js";
2
- //#region extensions/codex/src/app-server/notification-correlation.ts
3
- /**
4
- * Correlates Codex app-server notifications with the active thread/turn so
5
- * projectors can ignore global or stale events without losing diagnostics.
6
- */
7
- /** Returns true when a notification payload belongs to the exact active thread and turn. */
8
- function isCodexNotificationForTurn(value, threadId, turnId) {
9
- if (!isJsonObject(value)) return false;
10
- return readCodexNotificationThreadId(value) === threadId && readCodexNotificationTurnId(value) === turnId;
11
- }
12
- /**
13
- * Reads a thread id from canonical top-level or nested thread payloads.
14
- * The generated v2 schemas require top-level `threadId` on turn/item-scoped
15
- * notifications and define `Turn` without one, so `turn.threadId` is not a
16
- * wire shape and is deliberately not read here.
17
- */
18
- function readCodexNotificationThreadId(record) {
19
- const thread = isJsonObject(record.thread) ? record.thread : void 0;
20
- return readString(record, "threadId") ?? (thread ? readString(thread, "id") : void 0);
21
- }
22
- /** Reads a turn id from either top-level notification params or nested turn payloads. */
23
- function readCodexNotificationTurnId(record) {
24
- return readNestedTurnId(record) ?? readString(record, "turnId");
25
- }
26
- function readNestedTurnId(record) {
27
- const turn = record.turn;
28
- return isJsonObject(turn) ? readString(turn, "id") : void 0;
29
- }
30
- function readString(record, key) {
31
- const value = record[key];
32
- return typeof value === "string" && value.trim() ? value.trim() : void 0;
33
- }
34
- //#endregion
35
- export { readCodexNotificationThreadId as n, readCodexNotificationTurnId as r, isCodexNotificationForTurn as t };
@@ -1,98 +0,0 @@
1
- import { K as buildCodexAppInventoryCacheKey } from "./thread-lifecycle-qWE88Dn2.js";
2
- import { u as CodexAppServerRpcError, x as resolveCodexAppServerHomeDir } from "./shared-client-4ICy3U6d.js";
3
- import { createRequire } from "node:module";
4
- import { createHash } from "node:crypto";
5
- import { OPENCLAW_VERSION } from "openclaw/plugin-sdk/agent-harness-runtime";
6
- import { readPluginPackageVersion } from "openclaw/plugin-sdk/extension-shared";
7
- //#region extensions/codex/src/app-server/capabilities.ts
8
- /**
9
- * Capability helpers for optional Codex app-server control-plane methods.
10
- */
11
- /** Known app-server methods used by OpenClaw control surfaces. */
12
- const CODEX_CONTROL_METHODS = {
13
- account: "account/read",
14
- compact: "thread/compact/start",
15
- feedback: "feedback/upload",
16
- forkThread: "thread/fork",
17
- listMcpServers: "mcpServerStatus/list",
18
- listSkills: "skills/list",
19
- listThreads: "thread/list",
20
- readThread: "thread/read",
21
- rateLimits: "account/rateLimits/read",
22
- archiveThread: "thread/archive",
23
- renameThread: "thread/name/set",
24
- resumeThread: "thread/resume",
25
- review: "review/start",
26
- unarchiveThread: "thread/unarchive"
27
- };
28
- /** Formats unsupported control calls differently from ordinary RPC failures. */
29
- function describeControlFailure(error) {
30
- if (isUnsupportedControlError(error)) return "unsupported by this Codex app-server";
31
- return error instanceof Error ? error.message : String(error);
32
- }
33
- function isUnsupportedControlError(error) {
34
- return error instanceof CodexAppServerRpcError && error.code === -32601;
35
- }
36
- //#endregion
37
- //#region extensions/codex/src/app-server/plugin-app-cache-key.ts
38
- /**
39
- * Builds stable Codex plugin/app inventory cache keys from app-server startup,
40
- * auth, account, and version inputs without storing secret material.
41
- */
42
- const CODEX_PLUGIN_VERSION = readPluginPackageVersion({ require: createRequire(import.meta.url) });
43
- /** Builds the full app inventory cache key for Codex plugin/app discovery. */
44
- function buildCodexPluginAppCacheKey(params) {
45
- return buildCodexAppInventoryCacheKey({
46
- codexHome: params.runtimeIdentity?.codexHome ?? resolveCodexPluginAppCacheCodexHome(params.appServer, params.agentDir),
47
- endpoint: resolveCodexPluginAppCacheEndpoint(params.appServer),
48
- authProfileId: params.authProfileId,
49
- accountId: params.accountId,
50
- envApiKeyFingerprint: params.envApiKeyFingerprint,
51
- appServerVersion: params.appServerVersion ?? params.runtimeIdentity?.serverVersion,
52
- runtimeIdentity: params.runtimeIdentity
53
- }, OPENCLAW_VERSION, CODEX_PLUGIN_VERSION);
54
- }
55
- /** Builds a durable thread-binding fingerprint for one initialized app-server runtime. */
56
- function buildCodexAppServerRuntimeFingerprint(params) {
57
- return JSON.stringify({
58
- endpoint: resolveCodexPluginAppCacheEndpoint(params.appServer),
59
- connectionClass: params.appServer.connectionClass,
60
- remoteWorkspaceRoot: params.appServer.remoteWorkspaceRoot ?? null,
61
- appServerVersion: params.appServerVersion ?? params.runtimeIdentity?.serverVersion ?? null,
62
- runtimeIdentity: params.runtimeIdentity ?? null
63
- });
64
- }
65
- /** Serializes app-server endpoint identity, including credential fingerprints. */
66
- function resolveCodexPluginAppCacheEndpoint(appServer) {
67
- return JSON.stringify({
68
- transport: appServer.start.transport,
69
- command: appServer.start.command,
70
- args: appServer.start.args,
71
- url: appServer.start.url ?? null,
72
- credentialFingerprint: fingerprintCodexPluginAppCacheCredentials(appServer.start)
73
- });
74
- }
75
- /** Resolves the CODEX_HOME value that scopes local app-server inventory. */
76
- function resolveCodexPluginAppCacheCodexHome(appServer, agentDir) {
77
- const configuredCodexHome = appServer.start.env?.CODEX_HOME?.trim();
78
- if (configuredCodexHome) return configuredCodexHome;
79
- return appServer.start.transport === "stdio" && agentDir ? resolveCodexAppServerHomeDir(agentDir) : void 0;
80
- }
81
- function fingerprintCodexPluginAppCacheCredentials(startOptions) {
82
- const authToken = startOptions.authToken ?? "";
83
- const headers = Object.entries(startOptions.headers).map(([key, value]) => [key.toLowerCase(), value]).toSorted(([left], [right]) => left.localeCompare(right));
84
- if (!authToken && headers.length === 0) return null;
85
- const hash = createHash("sha256");
86
- hash.update("openclaw:codex:plugin-app-cache-credentials:v1");
87
- hash.update("\0");
88
- hash.update(authToken);
89
- for (const [key, value] of headers) {
90
- hash.update("\0");
91
- hash.update(key);
92
- hash.update("\0");
93
- hash.update(value);
94
- }
95
- return `sha256:${hash.digest("hex")}`;
96
- }
97
- //#endregion
98
- export { describeControlFailure as i, buildCodexPluginAppCacheKey as n, CODEX_CONTROL_METHODS as r, buildCodexAppServerRuntimeFingerprint as t };
@@ -1,15 +0,0 @@
1
- import { GPT5_BEHAVIOR_CONTRACT, GPT5_HEARTBEAT_PROMPT_OVERLAY, resolveGpt5SystemPromptContribution } from "openclaw/plugin-sdk/provider-model-shared";
2
- //#region extensions/codex/prompt-overlay.ts
3
- /**
4
- * Codex prompt-overlay facade for GPT-5 behavior and heartbeat guidance.
5
- */
6
- /** GPT-5 behavior contract re-exported under the Codex provider namespace. */
7
- const CODEX_GPT5_BEHAVIOR_CONTRACT = GPT5_BEHAVIOR_CONTRACT;
8
- /** Heartbeat prompt overlay re-exported under the Codex provider namespace. */
9
- const CODEX_GPT5_HEARTBEAT_PROMPT_OVERLAY = GPT5_HEARTBEAT_PROMPT_OVERLAY;
10
- /** Resolves the Codex system-prompt contribution for GPT-5-family models. */
11
- function resolveCodexSystemPromptContribution(params) {
12
- return resolveGpt5SystemPromptContribution(params);
13
- }
14
- //#endregion
15
- export { CODEX_GPT5_BEHAVIOR_CONTRACT, CODEX_GPT5_HEARTBEAT_PROMPT_OVERLAY, resolveCodexSystemPromptContribution };
@@ -1,13 +0,0 @@
1
- //#region extensions/codex/src/app-server/protocol.ts
2
- function flattenCodexDynamicToolFunctions(tools) {
3
- return (tools ?? []).flatMap((tool) => tool.type === "namespace" ? tool.tools : [tool]);
4
- }
5
- const CODEX_INTERACTIVE_THREAD_SOURCE_KINDS = ["cli", "vscode"];
6
- function isJsonObject(value) {
7
- return Boolean(value && typeof value === "object" && !Array.isArray(value));
8
- }
9
- function isRpcResponse(message) {
10
- return "id" in message && !("method" in message);
11
- }
12
- //#endregion
13
- export { isRpcResponse as i, flattenCodexDynamicToolFunctions as n, isJsonObject as r, CODEX_INTERACTIVE_THREAD_SOURCE_KINDS as t };
@@ -1,79 +0,0 @@
1
- //#region extensions/codex/provider-catalog.ts
2
- /** Provider id used by Codex model refs. */
3
- const CODEX_PROVIDER_ID = "codex";
4
- /** Synthetic base URL used to route Codex app-server model requests. */
5
- const CODEX_BASE_URL = "https://chatgpt.com/backend-api";
6
- /** Synthetic auth marker understood by Codex app-server runtime paths. */
7
- const CODEX_APP_SERVER_AUTH_MARKER = "codex-app-server";
8
- const DEFAULT_CONTEXT_WINDOW = 272e3;
9
- const DEFAULT_MAX_TOKENS = 128e3;
10
- /** Offline fallback catalog used when live app-server discovery is unavailable. */
11
- const FALLBACK_CODEX_MODELS = [{
12
- id: "gpt-5.5",
13
- model: "gpt-5.5",
14
- displayName: "gpt-5.5",
15
- description: "Latest frontier agentic coding model.",
16
- isDefault: true,
17
- inputModalities: ["text", "image"],
18
- supportedReasoningEfforts: [
19
- "low",
20
- "medium",
21
- "high",
22
- "xhigh"
23
- ]
24
- }, {
25
- id: "gpt-5.4-mini",
26
- model: "gpt-5.4-mini",
27
- displayName: "GPT-5.4-Mini",
28
- description: "Smaller frontier agentic coding model.",
29
- inputModalities: ["text", "image"],
30
- supportedReasoningEfforts: [
31
- "low",
32
- "medium",
33
- "high",
34
- "xhigh"
35
- ]
36
- }];
37
- /**
38
- * Converts a Codex app-server model record into OpenClaw provider model config.
39
- */
40
- function buildCodexModelDefinition(model) {
41
- const id = model.id.trim() || model.model.trim();
42
- const supportedReasoningEfforts = model.supportedReasoningEfforts;
43
- return {
44
- id,
45
- name: model.displayName?.trim() || id,
46
- api: "openai-chatgpt-responses",
47
- reasoning: supportedReasoningEfforts !== void 0 ? supportedReasoningEfforts.length > 0 : shouldDefaultToReasoningModel(id),
48
- input: model.inputModalities.includes("image") ? ["text", "image"] : ["text"],
49
- cost: {
50
- input: 0,
51
- output: 0,
52
- cacheRead: 0,
53
- cacheWrite: 0
54
- },
55
- contextWindow: DEFAULT_CONTEXT_WINDOW,
56
- maxTokens: DEFAULT_MAX_TOKENS,
57
- compat: {
58
- ...supportedReasoningEfforts !== void 0 ? { supportsReasoningEffort: supportedReasoningEfforts.length > 0 } : {},
59
- ...supportedReasoningEfforts && supportedReasoningEfforts.length > 0 ? { supportedReasoningEfforts: [...supportedReasoningEfforts] } : {},
60
- supportsUsageInStreaming: true
61
- }
62
- };
63
- }
64
- /** Builds the synthetic Codex provider config for a model list. */
65
- function buildCodexProviderConfig(models) {
66
- return {
67
- baseUrl: CODEX_BASE_URL,
68
- apiKey: CODEX_APP_SERVER_AUTH_MARKER,
69
- auth: "token",
70
- api: "openai-chatgpt-responses",
71
- models: models.map(buildCodexModelDefinition)
72
- };
73
- }
74
- function shouldDefaultToReasoningModel(modelId) {
75
- const lower = modelId.toLowerCase();
76
- return lower.startsWith("gpt-5") || lower.startsWith("o1") || lower.startsWith("o3") || lower.startsWith("o4");
77
- }
78
- //#endregion
79
- export { CODEX_APP_SERVER_AUTH_MARKER, CODEX_BASE_URL, CODEX_PROVIDER_ID, FALLBACK_CODEX_MODELS, buildCodexModelDefinition, buildCodexProviderConfig };
@@ -1,34 +0,0 @@
1
- import { CODEX_APP_SERVER_AUTH_MARKER, CODEX_PROVIDER_ID, FALLBACK_CODEX_MODELS, buildCodexProviderConfig } from "./provider-catalog.js";
2
- //#region extensions/codex/provider-discovery.ts
3
- function resolveCodexPluginConfig(ctx) {
4
- return (ctx.config.plugins?.entries)?.codex?.config;
5
- }
6
- async function runCodexCatalog(ctx) {
7
- const { buildCodexProviderCatalog } = await import("./provider.js");
8
- return await buildCodexProviderCatalog({
9
- env: ctx.env,
10
- pluginConfig: resolveCodexPluginConfig(ctx)
11
- });
12
- }
13
- /** Provider discovery descriptor with static fallback and synthetic auth. */
14
- const codexProviderDiscovery = {
15
- id: CODEX_PROVIDER_ID,
16
- label: "Codex",
17
- docsPath: "/providers/models",
18
- auth: [],
19
- catalog: {
20
- order: "late",
21
- run: runCodexCatalog
22
- },
23
- staticCatalog: {
24
- order: "late",
25
- run: async () => ({ provider: buildCodexProviderConfig(FALLBACK_CODEX_MODELS) })
26
- },
27
- resolveSyntheticAuth: () => ({
28
- apiKey: CODEX_APP_SERVER_AUTH_MARKER,
29
- source: "codex-app-server",
30
- mode: "token"
31
- })
32
- };
33
- //#endregion
34
- export { codexProviderDiscovery, codexProviderDiscovery as default };
package/dist/provider.js DELETED
@@ -1,2 +0,0 @@
1
- import { a as readCodexSupportedReasoningEfforts, i as isModernCodexModel, n as buildCodexProviderCatalog, o as resolveCodexFallbackReasoningEfforts, r as isMaxReasoningCodexModel, s as resolveCodexSupportedReasoningEffort, t as buildCodexProvider } from "./provider-zjPfx5Fs.js";
2
- export { buildCodexProvider, buildCodexProviderCatalog, isMaxReasoningCodexModel, isModernCodexModel, readCodexSupportedReasoningEfforts, resolveCodexFallbackReasoningEfforts, resolveCodexSupportedReasoningEffort };