@openclaw/codex 2026.5.7 → 2026.5.10-beta.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.
@@ -1,7 +1,8 @@
1
1
  import { t as __exportAll } from "./rolldown-runtime-DUslC3ob.js";
2
+ import { a as normalizeCodexServiceTier } from "./config-CT01BBDc.js";
2
3
  import { embeddedAgentLog } from "openclaw/plugin-sdk/agent-harness-runtime";
3
4
  import fs from "node:fs/promises";
4
- import { ensureAuthProfileStore, resolveOpenClawAgentDir as resolveOpenClawAgentDir$1, resolveProviderIdForAuth } from "openclaw/plugin-sdk/agent-runtime";
5
+ import { ensureAuthProfileStore, resolveDefaultAgentDir, resolveProviderIdForAuth } from "openclaw/plugin-sdk/agent-runtime";
5
6
  //#region extensions/codex/src/app-server/session-binding.ts
6
7
  var session_binding_exports = /* @__PURE__ */ __exportAll({
7
8
  clearCodexAppServerBinding: () => clearCodexAppServerBinding,
@@ -49,6 +50,9 @@ async function readCodexAppServerBinding(sessionFile, lookup = {}) {
49
50
  sandbox: readSandboxMode(parsed.sandbox),
50
51
  serviceTier: readServiceTier(parsed.serviceTier),
51
52
  dynamicToolsFingerprint: typeof parsed.dynamicToolsFingerprint === "string" ? parsed.dynamicToolsFingerprint : void 0,
53
+ pluginAppsFingerprint: typeof parsed.pluginAppsFingerprint === "string" ? parsed.pluginAppsFingerprint : void 0,
54
+ pluginAppsInputFingerprint: typeof parsed.pluginAppsInputFingerprint === "string" ? parsed.pluginAppsInputFingerprint : void 0,
55
+ pluginAppPolicyContext: readPluginAppPolicyContext(parsed.pluginAppPolicyContext),
52
56
  createdAt: typeof parsed.createdAt === "string" ? parsed.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
53
57
  updatedAt: typeof parsed.updatedAt === "string" ? parsed.updatedAt : (/* @__PURE__ */ new Date()).toISOString()
54
58
  };
@@ -78,11 +82,46 @@ async function writeCodexAppServerBinding(sessionFile, binding, lookup = {}) {
78
82
  sandbox: binding.sandbox,
79
83
  serviceTier: binding.serviceTier,
80
84
  dynamicToolsFingerprint: binding.dynamicToolsFingerprint,
85
+ pluginAppsFingerprint: binding.pluginAppsFingerprint,
86
+ pluginAppsInputFingerprint: binding.pluginAppsInputFingerprint,
87
+ pluginAppPolicyContext: binding.pluginAppPolicyContext,
81
88
  createdAt: binding.createdAt ?? now,
82
89
  updatedAt: now
83
90
  };
84
91
  await fs.writeFile(resolveCodexAppServerBindingPath(sessionFile), `${JSON.stringify(payload, null, 2)}\n`);
85
92
  }
93
+ function readPluginAppPolicyContext(value) {
94
+ if (!value || typeof value !== "object" || Array.isArray(value)) return;
95
+ const record = value;
96
+ if (typeof record.fingerprint !== "string") return;
97
+ const apps = record.apps;
98
+ if (!apps || typeof apps !== "object" || Array.isArray(apps)) return;
99
+ const parsedApps = {};
100
+ for (const [appId, rawEntry] of Object.entries(apps)) {
101
+ if (!rawEntry || typeof rawEntry !== "object" || Array.isArray(rawEntry)) return;
102
+ const entry = rawEntry;
103
+ if ("appId" in entry || typeof entry.configKey !== "string" || entry.marketplaceName !== "openai-curated" || typeof entry.pluginName !== "string" || typeof entry.allowDestructiveActions !== "boolean" || !Array.isArray(entry.mcpServerNames) || entry.mcpServerNames.some((serverName) => typeof serverName !== "string")) return;
104
+ parsedApps[appId] = {
105
+ configKey: entry.configKey,
106
+ marketplaceName: entry.marketplaceName,
107
+ pluginName: entry.pluginName,
108
+ allowDestructiveActions: entry.allowDestructiveActions,
109
+ mcpServerNames: entry.mcpServerNames
110
+ };
111
+ }
112
+ const parsedPluginAppIds = {};
113
+ const rawPluginAppIds = record.pluginAppIds;
114
+ if (rawPluginAppIds && (typeof rawPluginAppIds !== "object" || Array.isArray(rawPluginAppIds))) return;
115
+ if (rawPluginAppIds && typeof rawPluginAppIds === "object") for (const [configKey, appIds] of Object.entries(rawPluginAppIds)) {
116
+ if (!Array.isArray(appIds) || appIds.some((appId) => typeof appId !== "string")) return;
117
+ parsedPluginAppIds[configKey] = appIds;
118
+ }
119
+ return {
120
+ fingerprint: record.fingerprint,
121
+ apps: parsedApps,
122
+ pluginAppIds: parsedPluginAppIds
123
+ };
124
+ }
86
125
  async function clearCodexAppServerBinding(sessionFile) {
87
126
  try {
88
127
  await fs.unlink(resolveCodexAppServerBindingPath(sessionFile));
@@ -124,10 +163,10 @@ function normalizeCodexAppServerBindingModelProvider(params) {
124
163
  function resolveCodexAppServerAuthProfileCredential(lookup) {
125
164
  const authProfileId = lookup.authProfileId?.trim();
126
165
  if (!authProfileId) return;
127
- return (lookup.authProfileStore ?? loadCodexAppServerAuthProfileStore(lookup.agentDir)).profiles[authProfileId];
166
+ return (lookup.authProfileStore ?? loadCodexAppServerAuthProfileStore(lookup.agentDir, lookup.config)).profiles[authProfileId];
128
167
  }
129
- function loadCodexAppServerAuthProfileStore(agentDir) {
130
- return ensureAuthProfileStore(agentDir?.trim() || resolveOpenClawAgentDir$1(), { allowKeychainPrompt: false });
168
+ function loadCodexAppServerAuthProfileStore(agentDir, config) {
169
+ return ensureAuthProfileStore(agentDir?.trim() || resolveDefaultAgentDir(config ?? {}), { allowKeychainPrompt: false });
131
170
  }
132
171
  function isCodexAppServerNativeAuthProvider(params) {
133
172
  const provider = params.provider?.trim();
@@ -140,7 +179,7 @@ function readSandboxMode(value) {
140
179
  return value === "read-only" || value === "workspace-write" || value === "danger-full-access" ? value : void 0;
141
180
  }
142
181
  function readServiceTier(value) {
143
- return value === "fast" || value === "flex" ? value : void 0;
182
+ return normalizeCodexServiceTier(value);
144
183
  }
145
184
  //#endregion
146
185
  export { session_binding_exports as a, readCodexAppServerBinding as i, isCodexAppServerNativeAuthProfile as n, writeCodexAppServerBinding as o, normalizeCodexAppServerBindingModelProvider as r, clearCodexAppServerBinding as t };
@@ -1,13 +1,14 @@
1
1
  import { t as __exportAll } from "./rolldown-runtime-DUslC3ob.js";
2
- import { i as resolveCodexAppServerRuntimeOptions, t as codexAppServerStartOptionsKey } from "./config-ByrA30No.js";
3
- import { a as MANAGED_CODEX_APP_SERVER_PACKAGE, o as resolveCodexAppServerSpawnEnv, t as CodexAppServerClient } from "./client-BGbqC7jk.js";
2
+ import { n as codexAppServerStartOptionsKey, s as resolveCodexAppServerRuntimeOptions } from "./config-CT01BBDc.js";
3
+ import { a as MANAGED_CODEX_APP_SERVER_PACKAGE, o as resolveCodexAppServerSpawnEnv, t as CodexAppServerClient } from "./client-CTzy3Y6M.js";
4
4
  import { createRequire } from "node:module";
5
+ import { createHash } from "node:crypto";
6
+ import { constants, readFileSync } from "node:fs";
5
7
  import fs, { access } from "node:fs/promises";
6
8
  import path from "node:path";
7
- import { ensureAuthProfileStore, loadAuthProfileStoreForSecretsRuntime, resolveApiKeyForProfile, resolveAuthProfileOrder, resolveOpenClawAgentDir, resolvePersistedAuthProfileOwnerAgentDir, resolveProviderIdForAuth, saveAuthProfileStore } from "openclaw/plugin-sdk/agent-runtime";
8
- import { resolveOpenClawAgentDir as resolveOpenClawAgentDir$1 } from "openclaw/plugin-sdk/provider-auth";
9
- import { constants, readFileSync } from "node:fs";
9
+ import { ensureAuthProfileStore, loadAuthProfileStoreForSecretsRuntime, resolveApiKeyForProfile, resolveAuthProfileOrder, resolveDefaultAgentDir, resolvePersistedAuthProfileOwnerAgentDir, resolveProviderIdForAuth, saveAuthProfileStore } from "openclaw/plugin-sdk/agent-runtime";
10
10
  import { fileURLToPath } from "node:url";
11
+ import { withTimeout } from "openclaw/plugin-sdk/security-runtime";
11
12
  //#region extensions/codex/src/app-server/auth-bridge.ts
12
13
  const CODEX_APP_SERVER_AUTH_PROVIDER = "openai-codex";
13
14
  const OPENAI_CODEX_DEFAULT_PROFILE_ID = "openai-codex:default";
@@ -41,13 +42,68 @@ function resolveCodexAppServerAuthProfileId(params) {
41
42
  })[0]?.trim();
42
43
  }
43
44
  function resolveCodexAppServerAuthProfileIdForAgent(params) {
44
- const store = ensureAuthProfileStore(params.agentDir?.trim() || resolveOpenClawAgentDir(), { allowKeychainPrompt: false });
45
+ const store = ensureAuthProfileStore(params.agentDir?.trim() || resolveDefaultAgentDir(params.config ?? {}), { allowKeychainPrompt: false });
45
46
  return resolveCodexAppServerAuthProfileId({
46
47
  authProfileId: params.authProfileId,
47
48
  store,
48
49
  config: params.config
49
50
  });
50
51
  }
52
+ async function resolveCodexAppServerAuthAccountCacheKey(params) {
53
+ const agentDir = params.agentDir?.trim() || resolveDefaultAgentDir(params.config ?? {});
54
+ const store = params.authProfileStore ?? ensureAuthProfileStore(agentDir, { allowKeychainPrompt: false });
55
+ const profileId = resolveCodexAppServerAuthProfileId({
56
+ authProfileId: params.authProfileId,
57
+ store,
58
+ config: params.config
59
+ });
60
+ if (!profileId) return;
61
+ const credential = store.profiles[profileId];
62
+ if (!credential || !isCodexAppServerAuthProvider(credential.provider, params.config)) return;
63
+ if (credential.type === "api_key") {
64
+ const apiKey = (await resolveApiKeyForProfile({
65
+ store,
66
+ profileId,
67
+ agentDir
68
+ }))?.apiKey?.trim();
69
+ return apiKey ? `${resolveChatgptAccountId(profileId, credential)}:${fingerprintApiKeyAuthProfileCacheKey(apiKey)}` : resolveChatgptAccountId(profileId, credential);
70
+ }
71
+ if (credential.type === "token") {
72
+ const accessToken = (await resolveApiKeyForProfile({
73
+ store,
74
+ profileId,
75
+ agentDir
76
+ }))?.apiKey?.trim();
77
+ return accessToken ? `${resolveChatgptAccountId(profileId, credential)}:${fingerprintTokenAuthProfileCacheKey(accessToken)}` : resolveChatgptAccountId(profileId, credential);
78
+ }
79
+ return resolveChatgptAccountId(profileId, credential);
80
+ }
81
+ function resolveCodexAppServerEnvApiKeyCacheKey(params) {
82
+ if (params.startOptions.transport !== "stdio") return;
83
+ const apiKey = readFirstNonEmptyEnvEntry(resolveCodexAppServerSpawnEnv(params.startOptions, params.baseEnv ?? process.env, params.platform ?? process.platform), CODEX_APP_SERVER_API_KEY_ENV_VARS);
84
+ if (!apiKey) return;
85
+ const hash = createHash("sha256");
86
+ hash.update("openclaw:codex:app-server-env-api-key:v1");
87
+ hash.update("\0");
88
+ hash.update(apiKey.key);
89
+ hash.update("\0");
90
+ hash.update(apiKey.value);
91
+ return `${apiKey.key}:sha256:${hash.digest("hex")}`;
92
+ }
93
+ function fingerprintApiKeyAuthProfileCacheKey(apiKey) {
94
+ const hash = createHash("sha256");
95
+ hash.update("openclaw:codex:app-server-auth-profile-api-key:v1");
96
+ hash.update("\0");
97
+ hash.update(apiKey);
98
+ return `api_key:sha256:${hash.digest("hex")}`;
99
+ }
100
+ function fingerprintTokenAuthProfileCacheKey(accessToken) {
101
+ const hash = createHash("sha256");
102
+ hash.update("openclaw:codex:app-server-auth-profile-token:v1");
103
+ hash.update("\0");
104
+ hash.update(accessToken);
105
+ return `token:sha256:${hash.digest("hex")}`;
106
+ }
51
107
  function resolveCodexAppServerHomeDir(agentDir) {
52
108
  return path.join(path.resolve(agentDir), CODEX_APP_SERVER_HOME_DIRNAME);
53
109
  }
@@ -157,6 +213,7 @@ async function resolveLoginParamsForCredential(profileId, credential, params) {
157
213
  }))?.apiKey?.trim();
158
214
  return accessToken ? buildChatgptAuthTokensParams(profileId, credential, accessToken) : void 0;
159
215
  }
216
+ if (credential.type !== "oauth") return;
160
217
  const resolvedCredential = await resolveOAuthCredentialForCodexAppServer(profileId, credential, {
161
218
  agentDir: params.agentDir,
162
219
  forceRefresh: params.forceOAuthRefresh,
@@ -214,9 +271,15 @@ function withClearedEnvironmentVariables(startOptions, envVars) {
214
271
  };
215
272
  }
216
273
  function readFirstNonEmptyEnv(env, keys) {
274
+ return readFirstNonEmptyEnvEntry(env, keys)?.value;
275
+ }
276
+ function readFirstNonEmptyEnvEntry(env, keys) {
217
277
  for (const key of keys) {
218
278
  const value = env[key]?.trim();
219
- if (value) return value;
279
+ if (value) return {
280
+ key,
281
+ value
282
+ };
220
283
  }
221
284
  }
222
285
  function buildChatgptAuthTokensParams(profileId, credential, accessToken) {
@@ -339,16 +402,8 @@ async function commandPathExists(filePath, platform) {
339
402
  }
340
403
  //#endregion
341
404
  //#region extensions/codex/src/app-server/timeout.ts
342
- async function withTimeout(promise, timeoutMs, timeoutMessage) {
343
- if (!Number.isFinite(timeoutMs) || timeoutMs <= 0) return await promise;
344
- let timeout;
345
- try {
346
- return await Promise.race([promise, new Promise((_, reject) => {
347
- timeout = setTimeout(() => reject(new Error(timeoutMessage)), Math.max(1, timeoutMs));
348
- })]);
349
- } finally {
350
- if (timeout) clearTimeout(timeout);
351
- }
405
+ async function withTimeout$1(promise, timeoutMs, timeoutMessage) {
406
+ return await withTimeout(promise, timeoutMs, { message: timeoutMessage });
352
407
  }
353
408
  //#endregion
354
409
  //#region extensions/codex/src/app-server/shared-client.ts
@@ -367,7 +422,7 @@ function getSharedCodexAppServerClientState() {
367
422
  }
368
423
  async function getSharedCodexAppServerClient(options) {
369
424
  const state = getSharedCodexAppServerClientState();
370
- const agentDir = options?.agentDir ?? resolveOpenClawAgentDir$1();
425
+ const agentDir = options?.agentDir ?? resolveDefaultAgentDir(options?.config ?? {});
371
426
  const authProfileId = resolveCodexAppServerAuthProfileIdForAgent({
372
427
  authProfileId: options?.authProfileId,
373
428
  agentDir,
@@ -405,14 +460,14 @@ async function getSharedCodexAppServerClient(options) {
405
460
  }
406
461
  })());
407
462
  try {
408
- return await withTimeout(sharedPromise, options?.timeoutMs ?? 0, "codex app-server initialize timed out");
463
+ return await withTimeout$1(sharedPromise, options?.timeoutMs ?? 0, "codex app-server initialize timed out");
409
464
  } catch (error) {
410
465
  if (state.promise === sharedPromise && state.key === key) clearSharedCodexAppServerClient();
411
466
  throw error;
412
467
  }
413
468
  }
414
469
  async function createIsolatedCodexAppServerClient(options) {
415
- const agentDir = options?.agentDir ?? resolveOpenClawAgentDir$1();
470
+ const agentDir = options?.agentDir ?? resolveDefaultAgentDir(options?.config ?? {});
416
471
  const authProfileId = resolveCodexAppServerAuthProfileIdForAgent({
417
472
  authProfileId: options?.authProfileId,
418
473
  agentDir,
@@ -427,7 +482,7 @@ async function createIsolatedCodexAppServerClient(options) {
427
482
  const client = CodexAppServerClient.start(startOptions);
428
483
  const initialize = client.initialize();
429
484
  try {
430
- await withTimeout(initialize, options?.timeoutMs ?? 0, "codex app-server initialize timed out");
485
+ await withTimeout$1(initialize, options?.timeoutMs ?? 0, "codex app-server initialize timed out");
431
486
  await applyCodexAppServerAuthProfile({
432
487
  client,
433
488
  agentDir,
@@ -476,4 +531,4 @@ function clearSharedClientIfCurrent(client) {
476
531
  state.key = void 0;
477
532
  }
478
533
  //#endregion
479
- export { refreshCodexAppServerAuthTokens as a, withTimeout as i, getSharedCodexAppServerClient as n, resolveCodexAppServerAuthProfileId as o, shared_client_exports as r, resolveCodexAppServerAuthProfileIdForAgent as s, clearSharedCodexAppServerClientIfCurrent as t };
534
+ export { refreshCodexAppServerAuthTokens as a, resolveCodexAppServerAuthProfileIdForAgent as c, withTimeout$1 as i, resolveCodexAppServerEnvApiKeyCacheKey as l, getSharedCodexAppServerClient as n, resolveCodexAppServerAuthAccountCacheKey as o, shared_client_exports as r, resolveCodexAppServerAuthProfileId as s, clearSharedCodexAppServerClientIfCurrent as t, resolveCodexAppServerHomeDir as u };
package/dist/test-api.js CHANGED
@@ -1,10 +1,11 @@
1
- import { i as resolveCodexAppServerRuntimeOptions } from "./config-ByrA30No.js";
2
- import { a as buildTurnStartParams, c as createCodexDynamicToolBridge, i as buildThreadStartParams, l as applyCodexDynamicToolProfile, n as buildDeveloperInstructions, r as buildThreadResumeParams } from "./thread-lifecycle-CzllX4PU.js";
1
+ import { s as resolveCodexAppServerRuntimeOptions } from "./config-CT01BBDc.js";
2
+ import { a as buildTurnStartParams, d as createCodexDynamicToolBridge, f as filterCodexDynamicTools, i as buildThreadStartParams, n as buildDeveloperInstructions, r as buildThreadResumeParams } from "./thread-lifecycle-DtD_qoMW.js";
3
3
  //#region extensions/codex/test-api.ts
4
4
  function resolveCodexPromptSnapshotAppServerOptions(pluginConfig) {
5
5
  return resolveCodexAppServerRuntimeOptions({
6
6
  pluginConfig,
7
- env: {}
7
+ env: {},
8
+ requirementsToml: null
8
9
  });
9
10
  }
10
11
  function buildCodexHarnessPromptSnapshot(params) {
@@ -34,8 +35,10 @@ function buildCodexHarnessPromptSnapshot(params) {
34
35
  }
35
36
  function createCodexDynamicToolSpecsForPromptSnapshot(params) {
36
37
  return createCodexDynamicToolBridge({
37
- tools: applyCodexDynamicToolProfile(params.tools, params.pluginConfig ?? {}),
38
- signal: new AbortController().signal
38
+ tools: filterCodexDynamicTools(params.tools, params.pluginConfig ?? {}),
39
+ signal: new AbortController().signal,
40
+ loading: params.pluginConfig?.codexDynamicToolsLoading ?? "searchable",
41
+ directToolNames: params.directToolNames
39
42
  }).specs;
40
43
  }
41
44
  //#endregion