@openclaw/codex 2026.5.25-beta.1 → 2026.5.26-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.
Files changed (25) hide show
  1. package/dist/{client-SrtuTTVa.js → client-BVK_jmHW.js} +1 -1
  2. package/dist/{client-factory-A7DQkSLq.js → client-factory-CaOpX89B.js} +1 -1
  3. package/dist/{command-handlers-CLtPT37L.js → command-handlers-D4C2y46B.js} +8 -8
  4. package/dist/{compact-acCua7zr.js → compact-CRI0BEc_.js} +3 -3
  5. package/dist/{computer-use-CVfE2Vfb.js → computer-use-CDDlIBhY.js} +2 -2
  6. package/dist/{config-D6TUuyo2.js → config-0-UN67Qg.js} +2 -1
  7. package/dist/{conversation-binding-B-GevkEb.js → conversation-binding-BnnjOmgs.js} +7 -7
  8. package/dist/{dynamic-tools-BXAE1U1-.js → dynamic-tools-BG9ICyU4.js} +1 -1
  9. package/dist/harness.js +5 -5
  10. package/dist/index.js +8 -8
  11. package/dist/media-understanding-provider.js +7 -7
  12. package/dist/{models-CC2IusQs.js → models-ASKu9eOY.js} +2 -2
  13. package/dist/{notification-correlation-D7tJW3FW.js → notification-correlation-YINts3PA.js} +1 -1
  14. package/dist/{protocol-validators-_gKDcd0x.js → protocol-validators-CSuFMLvY.js} +138 -29
  15. package/dist/provider.js +2 -2
  16. package/dist/{request-BO0z3vA8.js → request-DmBkYLPy.js} +3 -3
  17. package/dist/{run-attempt-BjoI3hUJ.js → run-attempt-CFBsGx1T.js} +221 -62
  18. package/dist/{session-binding-CwNOIDP2.js → session-binding-UFjjws4k.js} +1 -1
  19. package/dist/{shared-client-CZP1DjaN.js → shared-client-Fou5nAyt.js} +65 -9
  20. package/dist/{side-question-Cb4COOQ9.js → side-question-fq_T2d_x.js} +9 -9
  21. package/dist/test-api.js +3 -3
  22. package/dist/{thread-lifecycle-CXMd9UgJ.js → thread-lifecycle-BapIT9Qs.js} +107 -20
  23. package/dist/{vision-tools-CETeQgze.js → vision-tools-B30YCKRK.js} +2 -2
  24. package/npm-shrinkwrap.json +7 -77
  25. package/package.json +5 -5
@@ -1,9 +1,10 @@
1
1
  import { t as __exportAll } from "./rolldown-runtime-8H4AJuhK.js";
2
- import { l as resolveCodexAppServerRuntimeOptions, n as codexAppServerStartOptionsKey } from "./config-D6TUuyo2.js";
3
- import { c as resolveCodexAppServerSpawnEnv, o as MANAGED_CODEX_APP_SERVER_PACKAGE, t as CodexAppServerClient } from "./client-SrtuTTVa.js";
2
+ import { l as resolveCodexAppServerRuntimeOptions, n as codexAppServerStartOptionsKey } from "./config-0-UN67Qg.js";
3
+ import { c as resolveCodexAppServerSpawnEnv, o as MANAGED_CODEX_APP_SERVER_PACKAGE, t as CodexAppServerClient } from "./client-BVK_jmHW.js";
4
4
  import { createRequire } from "node:module";
5
5
  import { createHash } from "node:crypto";
6
- import { constants, readFileSync } from "node:fs";
6
+ import fsSync, { constants, readFileSync } from "node:fs";
7
+ import os from "node:os";
7
8
  import fs, { access } from "node:fs/promises";
8
9
  import path from "node:path";
9
10
  import { ensureAuthProfileStore, ensureAuthProfileStoreWithoutExternalProfiles, loadAuthProfileStoreForSecretsRuntime, refreshOAuthCredentialForRuntime, resolveApiKeyForProfile, resolveAuthProfileOrder, resolveDefaultAgentDir, resolvePersistedAuthProfileOwnerAgentDir, resolveProviderIdForAuth } from "openclaw/plugin-sdk/agent-runtime";
@@ -18,6 +19,8 @@ const HOME_ENV_VAR = "HOME";
18
19
  const CODEX_APP_SERVER_HOME_DIRNAME = "codex-home";
19
20
  const CODEX_APP_SERVER_API_KEY_ENV_VARS = ["CODEX_API_KEY", "OPENAI_API_KEY"];
20
21
  const CODEX_APP_SERVER_HOME_ENV_VARS = [CODEX_HOME_ENV_VAR, HOME_ENV_VAR];
22
+ const CODEX_AUTH_JSON_FILENAME = "auth.json";
23
+ const CODEX_HOME_DIRNAME = ".codex";
21
24
  async function bridgeCodexAppServerStartOptions(params) {
22
25
  if (params.startOptions.transport !== "stdio") return params.startOptions;
23
26
  const isolatedStartOptions = await withAgentCodexHomeEnvironment(params.startOptions, params.agentDir);
@@ -132,6 +135,10 @@ function resolveCodexAppServerEnvApiKeyCacheKey(params) {
132
135
  hash.update(apiKey.value);
133
136
  return `${apiKey.key}:sha256:${hash.digest("hex")}`;
134
137
  }
138
+ function resolveCodexAppServerFallbackApiKeyCacheKey(params) {
139
+ if (params.startOptions.transport !== "stdio") return;
140
+ return resolveCodexAppServerEnvApiKeyCacheKey(params) ?? resolveCodexCliAuthFileApiKeyCacheKey(params.baseEnv ?? process.env);
141
+ }
135
142
  function fingerprintApiKeyAuthProfileCacheKey(apiKey) {
136
143
  const hash = createHash("sha256");
137
144
  hash.update("openclaw:codex:app-server-auth-profile-api-key:v1");
@@ -146,6 +153,13 @@ function fingerprintTokenAuthProfileCacheKey(accessToken) {
146
153
  hash.update(accessToken);
147
154
  return `token:sha256:${hash.digest("hex")}`;
148
155
  }
156
+ function fingerprintCodexCliAuthFileApiKeyCacheKey(apiKey) {
157
+ const hash = createHash("sha256");
158
+ hash.update("openclaw:codex:app-server-cli-auth-json-api-key:v1");
159
+ hash.update("\0");
160
+ hash.update(apiKey);
161
+ return `CODEX_AUTH_JSON:sha256:${hash.digest("hex")}`;
162
+ }
149
163
  function resolveCodexAppServerHomeDir(agentDir) {
150
164
  return path.join(path.resolve(agentDir), CODEX_APP_SERVER_HOME_DIRNAME);
151
165
  }
@@ -183,9 +197,10 @@ async function applyCodexAppServerAuthProfile(params) {
183
197
  if (!loginParams) {
184
198
  if (params.startOptions?.transport !== "stdio") return;
185
199
  const env = resolveCodexAppServerSpawnEnv(params.startOptions, process.env);
186
- const fallbackLoginParams = await resolveCodexAppServerEnvApiKeyLoginParams({
200
+ const fallbackLoginParams = await resolveCodexAppServerFallbackApiKeyLoginParams({
187
201
  client: params.client,
188
- env
202
+ env,
203
+ codexCliAuthEnv: process.env
189
204
  });
190
205
  if (fallbackLoginParams) await params.client.request("account/login/start", fallbackLoginParams);
191
206
  return;
@@ -230,8 +245,8 @@ async function resolveCodexAppServerAuthProfileLoginParamsInternal(params) {
230
245
  if (!loginParams) throw new Error(`Codex app-server auth profile "${profileId}" does not contain usable credentials.`);
231
246
  return loginParams;
232
247
  }
233
- async function resolveCodexAppServerEnvApiKeyLoginParams(params) {
234
- const apiKey = readFirstNonEmptyEnv(params.env, CODEX_APP_SERVER_API_KEY_ENV_VARS);
248
+ async function resolveCodexAppServerFallbackApiKeyLoginParams(params) {
249
+ const apiKey = readFirstNonEmptyEnv(params.env, CODEX_APP_SERVER_API_KEY_ENV_VARS) ?? await readCodexCliAuthFileApiKey(params.codexCliAuthEnv);
235
250
  if (!apiKey) return;
236
251
  if ((await params.client.request("account/read", { refreshToken: false })).account) return;
237
252
  return {
@@ -239,6 +254,45 @@ async function resolveCodexAppServerEnvApiKeyLoginParams(params) {
239
254
  apiKey
240
255
  };
241
256
  }
257
+ function resolveCodexCliAuthFilePath(env) {
258
+ const configuredCodexHome = env[CODEX_HOME_ENV_VAR]?.trim();
259
+ if (configuredCodexHome) return path.join(resolveHomeRelativePath(configuredCodexHome, env), CODEX_AUTH_JSON_FILENAME);
260
+ const home = env[HOME_ENV_VAR]?.trim() || env.USERPROFILE?.trim() || os.homedir();
261
+ return path.join(home, CODEX_HOME_DIRNAME, CODEX_AUTH_JSON_FILENAME);
262
+ }
263
+ function resolveHomeRelativePath(value, env) {
264
+ if (value === "~" || value.startsWith("~/") || value.startsWith("~\\")) {
265
+ const home = env[HOME_ENV_VAR]?.trim() || env.USERPROFILE?.trim() || os.homedir();
266
+ return path.join(home, value.slice(value === "~" ? 1 : 2));
267
+ }
268
+ return value;
269
+ }
270
+ function parseCodexCliAuthFileApiKey(raw) {
271
+ let parsed;
272
+ try {
273
+ parsed = JSON.parse(raw);
274
+ } catch {
275
+ return;
276
+ }
277
+ if (!parsed || typeof parsed !== "object") return;
278
+ const apiKey = parsed.OPENAI_API_KEY;
279
+ return typeof apiKey === "string" && apiKey.trim() ? apiKey.trim() : void 0;
280
+ }
281
+ async function readCodexCliAuthFileApiKey(env) {
282
+ try {
283
+ return parseCodexCliAuthFileApiKey(await fs.readFile(resolveCodexCliAuthFilePath(env), "utf8"));
284
+ } catch {
285
+ return;
286
+ }
287
+ }
288
+ function resolveCodexCliAuthFileApiKeyCacheKey(env) {
289
+ try {
290
+ const apiKey = parseCodexCliAuthFileApiKey(fsSync.readFileSync(resolveCodexCliAuthFilePath(env), "utf8"));
291
+ return apiKey ? fingerprintCodexCliAuthFileApiKeyCacheKey(apiKey) : void 0;
292
+ } catch {
293
+ return;
294
+ }
295
+ }
242
296
  async function resolveLoginParamsForCredential(profileId, credential, params) {
243
297
  if (credential.type === "api_key") {
244
298
  const apiKey = (await resolveApiKeyForProfile({
@@ -513,9 +567,11 @@ async function getSharedCodexAppServerClient(options) {
513
567
  authProfileId: usesNativeAuth ? null : authProfileId,
514
568
  config: options?.config
515
569
  });
570
+ const fallbackApiKeyCacheKey = authProfileId ? void 0 : resolveCodexAppServerFallbackApiKeyCacheKey({ startOptions });
516
571
  const key = codexAppServerStartOptionsKey(startOptions, {
517
572
  authProfileId,
518
- agentDir: usesNativeAuth ? void 0 : agentDir
573
+ agentDir: usesNativeAuth ? void 0 : agentDir,
574
+ fallbackApiKeyCacheKey
519
575
  });
520
576
  const state = getSharedCodexAppServerClientState();
521
577
  const entry = getOrCreateSharedClientEntry(state, key);
@@ -627,4 +683,4 @@ function collectSharedClients(state) {
627
683
  return [...new Set([...state.clients.values()].map((entry) => entry.client).filter((client) => Boolean(client)))];
628
684
  }
629
685
  //#endregion
630
- export { shared_client_exports as a, resolveCodexAppServerAuthAccountCacheKey as c, resolveCodexAppServerEnvApiKeyCacheKey as d, resolveCodexAppServerHomeDir as f, getSharedCodexAppServerClient as i, resolveCodexAppServerAuthProfileId as l, clearSharedCodexAppServerClientIfCurrentAndWait as n, withTimeout$1 as o, createIsolatedCodexAppServerClient as r, refreshCodexAppServerAuthTokens as s, clearSharedCodexAppServerClientIfCurrent as t, resolveCodexAppServerAuthProfileIdForAgent as u };
686
+ export { shared_client_exports as a, resolveCodexAppServerAuthAccountCacheKey as c, resolveCodexAppServerFallbackApiKeyCacheKey as d, resolveCodexAppServerHomeDir as f, getSharedCodexAppServerClient as i, resolveCodexAppServerAuthProfileId as l, clearSharedCodexAppServerClientIfCurrentAndWait as n, withTimeout$1 as o, createIsolatedCodexAppServerClient as r, refreshCodexAppServerAuthTokens as s, clearSharedCodexAppServerClientIfCurrent as t, resolveCodexAppServerAuthProfileIdForAgent as u };
@@ -1,13 +1,13 @@
1
- import { c as readCodexPluginConfig, f as shouldAutoApproveCodexAppServerApprovals, l as resolveCodexAppServerRuntimeOptions } from "./config-D6TUuyo2.js";
2
- import { a as readCodexDynamicToolCallParams, c as readCodexTurn, i as assertCodexTurnStartResponse, t as assertCodexThreadForkResponse } from "./protocol-validators-_gKDcd0x.js";
3
- import { i as isCodexAppServerApprovalRequest, l as isJsonObject } from "./client-SrtuTTVa.js";
4
- import { _ as mergeCodexThreadConfigs, f as resolveCodexAppServerModelProvider, p as resolveReasoningEffort, r as buildCodexRuntimeThreadConfig, t as CODEX_NATIVE_PERSONALITY_NONE } from "./thread-lifecycle-CXMd9UgJ.js";
5
- import { i as readCodexAppServerBinding } from "./session-binding-CwNOIDP2.js";
6
- import { i as readCodexNotificationTurnId, m as formatCodexUsageLimitErrorMessage, r as readCodexNotificationThreadId } from "./notification-correlation-D7tJW3FW.js";
7
- import { i as getSharedCodexAppServerClient, s as refreshCodexAppServerAuthTokens } from "./shared-client-CZP1DjaN.js";
1
+ import { c as readCodexPluginConfig, f as shouldAutoApproveCodexAppServerApprovals, l as resolveCodexAppServerRuntimeOptions } from "./config-0-UN67Qg.js";
2
+ import { a as readCodexDynamicToolCallParams, c as readCodexTurn, i as assertCodexTurnStartResponse, t as assertCodexThreadForkResponse } from "./protocol-validators-CSuFMLvY.js";
3
+ import { i as isCodexAppServerApprovalRequest, l as isJsonObject } from "./client-BVK_jmHW.js";
4
+ import { f as resolveCodexAppServerModelProvider, p as resolveReasoningEffort, r as buildCodexRuntimeThreadConfig, t as CODEX_NATIVE_PERSONALITY_NONE, v as mergeCodexThreadConfigs } from "./thread-lifecycle-BapIT9Qs.js";
5
+ import { i as readCodexAppServerBinding } from "./session-binding-UFjjws4k.js";
6
+ import { i as readCodexNotificationTurnId, m as formatCodexUsageLimitErrorMessage, r as readCodexNotificationThreadId } from "./notification-correlation-YINts3PA.js";
7
+ import { i as getSharedCodexAppServerClient, s as refreshCodexAppServerAuthTokens } from "./shared-client-Fou5nAyt.js";
8
8
  import { n as resolveCodexNativeExecutionBlock } from "./sandbox-guard-CTnEWuor.js";
9
- import { a as resolveCodexDynamicToolsLoading, n as filterCodexDynamicTools, t as createCodexDynamicToolBridge } from "./dynamic-tools-BXAE1U1-.js";
10
- import { a as handleCodexAppServerElicitationRequest, c as emitDynamicToolTerminalDiagnostic, i as buildCodexNativeHookRelayDisabledConfig, l as handleCodexAppServerApprovalRequest, n as CODEX_NATIVE_HOOK_RELAY_EVENTS, o as emitDynamicToolErrorDiagnostic, r as buildCodexNativeHookRelayConfig, s as emitDynamicToolStartedDiagnostic, t as filterToolsForVisionInputs } from "./vision-tools-CETeQgze.js";
9
+ import { a as resolveCodexDynamicToolsLoading, n as filterCodexDynamicTools, t as createCodexDynamicToolBridge } from "./dynamic-tools-BG9ICyU4.js";
10
+ import { a as handleCodexAppServerElicitationRequest, c as emitDynamicToolTerminalDiagnostic, i as buildCodexNativeHookRelayDisabledConfig, l as handleCodexAppServerApprovalRequest, n as CODEX_NATIVE_HOOK_RELAY_EVENTS, o as emitDynamicToolErrorDiagnostic, r as buildCodexNativeHookRelayConfig, s as emitDynamicToolStartedDiagnostic, t as filterToolsForVisionInputs } from "./vision-tools-B30YCKRK.js";
11
11
  import { n as rememberCodexRateLimits, t as readRecentCodexRateLimits } from "./rate-limit-cache-N66I-Rd7.js";
12
12
  import { buildAgentHookContextChannelFields, embeddedAgentLog, formatErrorMessage, registerNativeHookRelay, resolveAgentDir, resolveAttemptSpawnWorkspaceDir, resolveModelAuthMode, resolveSandboxContext, resolveSessionAgentIds, supportsModelTools } from "openclaw/plugin-sdk/agent-harness-runtime";
13
13
  //#region extensions/codex/src/app-server/side-question.ts
package/dist/test-api.js CHANGED
@@ -1,6 +1,6 @@
1
- import { l as resolveCodexAppServerRuntimeOptions } from "./config-D6TUuyo2.js";
2
- import { a as buildDeveloperInstructions, l as buildTurnStartParams, o as buildThreadResumeParams, s as buildThreadStartParams } from "./thread-lifecycle-CXMd9UgJ.js";
3
- import { n as filterCodexDynamicTools, t as createCodexDynamicToolBridge } from "./dynamic-tools-BXAE1U1-.js";
1
+ import { l as resolveCodexAppServerRuntimeOptions } from "./config-0-UN67Qg.js";
2
+ import { a as buildDeveloperInstructions, l as buildTurnStartParams, o as buildThreadResumeParams, s as buildThreadStartParams } from "./thread-lifecycle-BapIT9Qs.js";
3
+ import { n as filterCodexDynamicTools, t as createCodexDynamicToolBridge } from "./dynamic-tools-BG9ICyU4.js";
4
4
  //#region extensions/codex/test-api.ts
5
5
  function resolveCodexPromptSnapshotAppServerOptions(pluginConfig) {
6
6
  return resolveCodexAppServerRuntimeOptions({
@@ -1,9 +1,9 @@
1
- import { d as resolveCodexPluginsPolicy, r as codexSandboxPolicyForTurn, t as CODEX_PLUGINS_MARKETPLACE_NAME } from "./config-D6TUuyo2.js";
2
- import { n as assertCodexThreadResumeResponse, r as assertCodexThreadStartResponse } from "./protocol-validators-_gKDcd0x.js";
3
- import { a as isCodexAppServerConnectionClosedError, l as isJsonObject } from "./client-SrtuTTVa.js";
1
+ import { d as resolveCodexPluginsPolicy, r as codexSandboxPolicyForTurn, t as CODEX_PLUGINS_MARKETPLACE_NAME } from "./config-0-UN67Qg.js";
2
+ import { n as assertCodexThreadResumeResponse, r as assertCodexThreadStartResponse } from "./protocol-validators-CSuFMLvY.js";
3
+ import { a as isCodexAppServerConnectionClosedError, l as isJsonObject } from "./client-BVK_jmHW.js";
4
4
  import { CODEX_GPT5_HEARTBEAT_PROMPT_OVERLAY } from "./prompt-overlay.js";
5
5
  import { isModernCodexModel } from "./provider.js";
6
- import { i as readCodexAppServerBinding, n as isCodexAppServerNativeAuthProfile, o as writeCodexAppServerBinding, t as clearCodexAppServerBinding } from "./session-binding-CwNOIDP2.js";
6
+ import { i as readCodexAppServerBinding, n as isCodexAppServerNativeAuthProfile, o as writeCodexAppServerBinding, t as clearCodexAppServerBinding } from "./session-binding-UFjjws4k.js";
7
7
  import crypto from "node:crypto";
8
8
  import { isRecord } from "openclaw/plugin-sdk/string-coerce-runtime";
9
9
  import { embeddedAgentLog, isActiveHarnessContextEngine } from "openclaw/plugin-sdk/agent-harness-runtime";
@@ -12,6 +12,7 @@ import { listRegisteredPluginAgentPromptGuidance } from "openclaw/plugin-sdk/plu
12
12
  import { redactSensitiveFieldValue, redactToolPayloadText } from "openclaw/plugin-sdk/logging-core";
13
13
  import "node:fs/promises";
14
14
  import "node:path";
15
+ import { isDiagnosticFlagEnabled } from "openclaw/plugin-sdk/diagnostic-runtime";
15
16
  //#region extensions/codex/src/app-server/context-engine-projection.ts
16
17
  const CONTEXT_HEADER = "OpenClaw assembled context for this turn:";
17
18
  const CONTEXT_OPEN = "<conversation_context>";
@@ -1067,6 +1068,12 @@ function stableStringify(value) {
1067
1068
  return JSON.stringify(value);
1068
1069
  }
1069
1070
  //#endregion
1071
+ //#region extensions/codex/src/app-server/profiler-flag.ts
1072
+ const PROFILER_FLAGS = ["profiler", "codex.profiler"];
1073
+ function isCodexAppServerProfilerEnabled(config, env = process.env) {
1074
+ return PROFILER_FLAGS.some((flag) => isDiagnosticFlagEnabled(flag, config, env));
1075
+ }
1076
+ //#endregion
1070
1077
  //#region extensions/codex/src/app-server/thread-lifecycle.ts
1071
1078
  const CODEX_NATIVE_PERSONALITY_NONE = "none";
1072
1079
  const CODEX_CODE_MODE_THREAD_CONFIG = {
@@ -1078,17 +1085,81 @@ const CODEX_CODE_MODE_DISABLED_THREAD_CONFIG = {
1078
1085
  "features.code_mode_only": false
1079
1086
  };
1080
1087
  const CODEX_LIGHTWEIGHT_CONTEXT_THREAD_CONFIG = { project_doc_max_bytes: 0 };
1088
+ const CODEX_THREAD_LIFECYCLE_TIMING_WARN_TOTAL_MS = 1e3;
1089
+ const CODEX_THREAD_LIFECYCLE_TIMING_WARN_STAGE_MS = 500;
1090
+ function createCodexThreadLifecycleTimingTracker(options = {}) {
1091
+ if (!options.enabled) return {
1092
+ async measure(_name, run) {
1093
+ return await run();
1094
+ },
1095
+ measureSync(_name, run) {
1096
+ return run();
1097
+ },
1098
+ logIfSlow() {}
1099
+ };
1100
+ const startedAt = Date.now();
1101
+ let didLog = false;
1102
+ const spans = [];
1103
+ const toMs = (value) => Math.max(0, Math.round(value));
1104
+ const record = (name, spanStartedAt) => {
1105
+ spans.push({
1106
+ name,
1107
+ durationMs: toMs(Date.now() - spanStartedAt),
1108
+ elapsedMs: toMs(Date.now() - startedAt)
1109
+ });
1110
+ };
1111
+ const snapshot = () => ({
1112
+ totalMs: toMs(Date.now() - startedAt),
1113
+ spans: spans.slice()
1114
+ });
1115
+ const shouldLog = (summary) => summary.totalMs >= CODEX_THREAD_LIFECYCLE_TIMING_WARN_TOTAL_MS || summary.spans.some((span) => span.durationMs >= CODEX_THREAD_LIFECYCLE_TIMING_WARN_STAGE_MS);
1116
+ const formatSpans = (summary) => summary.spans.length > 0 ? summary.spans.map((span) => `${span.name}:${span.durationMs}ms@${span.elapsedMs}ms`).join(",") : "none";
1117
+ return {
1118
+ async measure(name, run) {
1119
+ const spanStartedAt = Date.now();
1120
+ try {
1121
+ return await run();
1122
+ } finally {
1123
+ record(name, spanStartedAt);
1124
+ }
1125
+ },
1126
+ measureSync(name, run) {
1127
+ const spanStartedAt = Date.now();
1128
+ try {
1129
+ return run();
1130
+ } finally {
1131
+ record(name, spanStartedAt);
1132
+ }
1133
+ },
1134
+ logIfSlow(params) {
1135
+ if (didLog) return;
1136
+ const summary = snapshot();
1137
+ if (!shouldLog(summary)) return;
1138
+ didLog = true;
1139
+ embeddedAgentLog.warn(`codex app-server thread lifecycle timings runId=${params.runId} sessionId=${params.sessionId} sessionKey=${params.sessionKey ?? "unknown"} action=${params.action} totalMs=${summary.totalMs} stages=${formatSpans(summary)}`, {
1140
+ runId: params.runId,
1141
+ sessionId: params.sessionId,
1142
+ sessionKey: params.sessionKey,
1143
+ action: params.action,
1144
+ threadId: params.threadId,
1145
+ totalMs: summary.totalMs,
1146
+ spans: summary.spans
1147
+ });
1148
+ }
1149
+ };
1150
+ }
1081
1151
  async function startOrResumeThread(params) {
1082
- const dynamicToolsFingerprint = fingerprintDynamicTools(params.dynamicTools);
1083
- const contextEngineBinding = buildContextEngineBinding(params.params, params.contextEngineProjection);
1152
+ const lifecycleTiming = createCodexThreadLifecycleTimingTracker({ enabled: isCodexAppServerProfilerEnabled(params.params.config) });
1153
+ const dynamicToolsFingerprint = lifecycleTiming.measureSync("fingerprint_dynamic_tools", () => fingerprintDynamicTools(params.dynamicTools));
1154
+ const contextEngineBinding = lifecycleTiming.measureSync("context_engine_binding", () => buildContextEngineBinding(params.params, params.contextEngineProjection));
1084
1155
  const userMcpServersConfigPatch = params.userMcpServersEnabled === false ? void 0 : buildCodexUserMcpServersThreadConfigPatch(params.params.config, { agentId: params.agentId ?? params.params.agentId });
1085
1156
  const userMcpServersFingerprint = fingerprintUserMcpServersConfigPatch(userMcpServersConfigPatch);
1086
1157
  const environmentSelectionFingerprint = fingerprintEnvironmentSelection(params.environmentSelection);
1087
- let binding = await readCodexAppServerBinding(params.params.sessionFile, {
1158
+ let binding = await lifecycleTiming.measure("read_binding", () => readCodexAppServerBinding(params.params.sessionFile, {
1088
1159
  authProfileStore: params.params.authProfileStore,
1089
1160
  agentDir: params.params.agentDir,
1090
1161
  config: params.params.config
1091
- });
1162
+ }));
1092
1163
  let preserveExistingBinding = false;
1093
1164
  let rotatedContextEngineBinding = false;
1094
1165
  let prebuiltPluginThreadConfig;
@@ -1142,7 +1213,7 @@ async function startOrResumeThread(params) {
1142
1213
  binding,
1143
1214
  pluginThreadConfig: params.pluginThreadConfig
1144
1215
  })) try {
1145
- prebuiltPluginThreadConfig = await params.pluginThreadConfig?.build();
1216
+ prebuiltPluginThreadConfig = await lifecycleTiming.measure("plugin_config_recovery", () => params.pluginThreadConfig?.build());
1146
1217
  pluginBindingStale = prebuiltPluginThreadConfig?.fingerprint !== binding.pluginAppsFingerprint;
1147
1218
  } catch (error) {
1148
1219
  embeddedAgentLog.warn("codex app-server plugin app config recovery check failed", {
@@ -1174,7 +1245,7 @@ async function startOrResumeThread(params) {
1174
1245
  } else try {
1175
1246
  const authProfileId = params.params.authProfileId ?? binding.authProfileId;
1176
1247
  const resumeConfig = mergeCodexThreadConfigs(params.config, userMcpServersConfigPatch, params.finalConfigPatch);
1177
- const response = assertCodexThreadResumeResponse(await params.client.request("thread/resume", buildThreadResumeParams(params.params, {
1248
+ const resumeParams = lifecycleTiming.measureSync("thread_resume_params", () => buildThreadResumeParams(params.params, {
1178
1249
  threadId: binding.threadId,
1179
1250
  authProfileId,
1180
1251
  appServer: params.appServer,
@@ -1183,7 +1254,8 @@ async function startOrResumeThread(params) {
1183
1254
  config: resumeConfig,
1184
1255
  nativeCodeModeEnabled: params.nativeCodeModeEnabled,
1185
1256
  nativeCodeModeOnlyEnabled: params.nativeCodeModeOnlyEnabled
1186
- })));
1257
+ }));
1258
+ const response = assertCodexThreadResumeResponse(await lifecycleTiming.measure("thread_resume_request", () => params.client.request("thread/resume", resumeParams)));
1187
1259
  const boundAuthProfileId = authProfileId;
1188
1260
  const fallbackModelProvider = resolveCodexAppServerModelProvider({
1189
1261
  provider: params.params.provider,
@@ -1193,7 +1265,7 @@ async function startOrResumeThread(params) {
1193
1265
  config: params.params.config
1194
1266
  });
1195
1267
  const nextMcpServersFingerprint = params.mcpServersFingerprintEvaluated === true ? params.mcpServersFingerprint : binding.mcpServersFingerprint;
1196
- await writeCodexAppServerBinding(params.params.sessionFile, {
1268
+ await lifecycleTiming.measure("thread_resume_write_binding", () => writeCodexAppServerBinding(params.params.sessionFile, {
1197
1269
  threadId: response.thread.id,
1198
1270
  cwd: params.cwd,
1199
1271
  authProfileId: boundAuthProfileId,
@@ -1212,7 +1284,7 @@ async function startOrResumeThread(params) {
1212
1284
  authProfileStore: params.params.authProfileStore,
1213
1285
  agentDir: params.params.agentDir,
1214
1286
  config: params.params.config
1215
- });
1287
+ }));
1216
1288
  if (contextEngineBinding) embeddedAgentLog.info("codex app-server wrote context-engine thread binding", {
1217
1289
  sessionId: params.params.sessionId,
1218
1290
  sessionKey: params.params.sessionKey,
@@ -1222,6 +1294,13 @@ async function startOrResumeThread(params) {
1222
1294
  fingerprint: contextEngineBinding.projection?.fingerprint,
1223
1295
  action: "resumed"
1224
1296
  });
1297
+ lifecycleTiming.logIfSlow({
1298
+ runId: params.params.runId,
1299
+ sessionId: params.params.sessionId,
1300
+ sessionKey: params.params.sessionKey,
1301
+ threadId: response.thread.id,
1302
+ action: "resumed"
1303
+ });
1225
1304
  return {
1226
1305
  ...binding,
1227
1306
  threadId: response.thread.id,
@@ -1244,9 +1323,9 @@ async function startOrResumeThread(params) {
1244
1323
  embeddedAgentLog.warn("codex app-server thread resume failed; starting a new thread", { error });
1245
1324
  await clearCodexAppServerBinding(params.params.sessionFile);
1246
1325
  }
1247
- const pluginThreadConfig = params.pluginThreadConfig?.enabled ? prebuiltPluginThreadConfig ?? await params.pluginThreadConfig.build() : void 0;
1248
- const config = mergeCodexThreadConfigs(params.config, userMcpServersConfigPatch, pluginThreadConfig?.configPatch, params.finalConfigPatch);
1249
- const response = assertCodexThreadStartResponse(await params.client.request("thread/start", buildThreadStartParams(params.params, {
1326
+ const pluginThreadConfig = params.pluginThreadConfig?.enabled ? prebuiltPluginThreadConfig ?? await lifecycleTiming.measure("plugin_config_build", () => params.pluginThreadConfig?.build()) : void 0;
1327
+ const config = lifecycleTiming.measureSync("merge_thread_config", () => mergeCodexThreadConfigs(params.config, userMcpServersConfigPatch, pluginThreadConfig?.configPatch, params.finalConfigPatch));
1328
+ const startParams = lifecycleTiming.measureSync("thread_start_params", () => buildThreadStartParams(params.params, {
1250
1329
  cwd: params.cwd,
1251
1330
  dynamicTools: params.dynamicTools,
1252
1331
  appServer: params.appServer,
@@ -1255,7 +1334,8 @@ async function startOrResumeThread(params) {
1255
1334
  nativeCodeModeEnabled: params.nativeCodeModeEnabled,
1256
1335
  nativeCodeModeOnlyEnabled: params.nativeCodeModeOnlyEnabled,
1257
1336
  environmentSelection: params.environmentSelection
1258
- })));
1337
+ }));
1338
+ const response = assertCodexThreadStartResponse(await lifecycleTiming.measure("thread_start_request", () => params.client.request("thread/start", startParams)));
1259
1339
  const modelProvider = resolveCodexAppServerModelProvider({
1260
1340
  provider: params.params.provider,
1261
1341
  authProfileId: params.params.authProfileId,
@@ -1266,7 +1346,7 @@ async function startOrResumeThread(params) {
1266
1346
  const createdAt = (/* @__PURE__ */ new Date()).toISOString();
1267
1347
  const nextMcpServersFingerprint = params.mcpServersFingerprintEvaluated === true ? params.mcpServersFingerprint : void 0;
1268
1348
  if (!preserveExistingBinding) {
1269
- await writeCodexAppServerBinding(params.params.sessionFile, {
1349
+ await lifecycleTiming.measure("thread_start_write_binding", () => writeCodexAppServerBinding(params.params.sessionFile, {
1270
1350
  threadId: response.thread.id,
1271
1351
  cwd: params.cwd,
1272
1352
  authProfileId: params.params.authProfileId,
@@ -1285,7 +1365,7 @@ async function startOrResumeThread(params) {
1285
1365
  authProfileStore: params.params.authProfileStore,
1286
1366
  agentDir: params.params.agentDir,
1287
1367
  config: params.params.config
1288
- });
1368
+ }));
1289
1369
  if (contextEngineBinding) embeddedAgentLog.info("codex app-server wrote context-engine thread binding", {
1290
1370
  sessionId: params.params.sessionId,
1291
1371
  sessionKey: params.params.sessionKey,
@@ -1296,6 +1376,13 @@ async function startOrResumeThread(params) {
1296
1376
  action: rotatedContextEngineBinding ? "rotated" : "started"
1297
1377
  });
1298
1378
  }
1379
+ lifecycleTiming.logIfSlow({
1380
+ runId: params.params.runId,
1381
+ sessionId: params.params.sessionId,
1382
+ sessionKey: params.params.sessionKey,
1383
+ threadId: response.thread.id,
1384
+ action: rotatedContextEngineBinding ? "rotated" : "started"
1385
+ });
1299
1386
  return {
1300
1387
  schemaVersion: 1,
1301
1388
  threadId: response.thread.id,
@@ -1623,4 +1710,4 @@ function resolveReasoningEffort(thinkLevel, modelId) {
1623
1710
  return null;
1624
1711
  }
1625
1712
  //#endregion
1626
- export { invalidInlineImageText as C, resolveCodexContextEngineProjectionMaxChars as D, projectContextEngineAssemblyForCodex as E, resolveCodexContextEngineProjectionReserveTokens as O, defaultCodexAppInventoryCache as S, sanitizeInlineImageDataUrl as T, mergeCodexThreadConfigs as _, buildDeveloperInstructions as a, pluginReadParams as b, buildTurnCollaborationMode as c, isContextEngineBindingCompatible as d, resolveCodexAppServerModelProvider as f, buildCodexPluginThreadConfigInputFingerprint as g, buildCodexPluginThreadConfig as h, buildContextEngineBinding as i, buildTurnStartParams as l, startOrResumeThread as m, areCodexDynamicToolFingerprintsCompatible as n, buildThreadResumeParams as o, resolveReasoningEffort as p, buildCodexRuntimeThreadConfig as r, buildThreadStartParams as s, CODEX_NATIVE_PERSONALITY_NONE as t, codexDynamicToolsFingerprint as u, shouldBuildCodexPluginThreadConfig as v, sanitizeCodexHistoryImagePayloads as w, buildCodexAppInventoryCacheKey as x, ensureCodexPluginActivation as y };
1713
+ export { defaultCodexAppInventoryCache as C, projectContextEngineAssemblyForCodex as D, sanitizeInlineImageDataUrl as E, resolveCodexContextEngineProjectionMaxChars as O, buildCodexAppInventoryCacheKey as S, sanitizeCodexHistoryImagePayloads as T, buildCodexPluginThreadConfigInputFingerprint as _, buildDeveloperInstructions as a, ensureCodexPluginActivation as b, buildTurnCollaborationMode as c, isContextEngineBindingCompatible as d, resolveCodexAppServerModelProvider as f, buildCodexPluginThreadConfig as g, isCodexAppServerProfilerEnabled as h, buildContextEngineBinding as i, resolveCodexContextEngineProjectionReserveTokens as k, buildTurnStartParams as l, startOrResumeThread as m, areCodexDynamicToolFingerprintsCompatible as n, buildThreadResumeParams as o, resolveReasoningEffort as p, buildCodexRuntimeThreadConfig as r, buildThreadStartParams as s, CODEX_NATIVE_PERSONALITY_NONE as t, codexDynamicToolsFingerprint as u, mergeCodexThreadConfigs as v, invalidInlineImageText as w, pluginReadParams as x, shouldBuildCodexPluginThreadConfig as y };
@@ -1,5 +1,5 @@
1
- import { l as isJsonObject } from "./client-SrtuTTVa.js";
2
- import { s as formatCodexDisplayText } from "./notification-correlation-D7tJW3FW.js";
1
+ import { l as isJsonObject } from "./client-BVK_jmHW.js";
2
+ import { s as formatCodexDisplayText } from "./notification-correlation-YINts3PA.js";
3
3
  import { createHash } from "node:crypto";
4
4
  import { normalizeTrimmedStringList } from "openclaw/plugin-sdk/string-coerce-runtime";
5
5
  import { buildAgentHookContextChannelFields, callGatewayTool, embeddedAgentLog, formatApprovalDisplayPath, hasNativeHookRelayInvocation, invokeNativeHookRelay, runBeforeToolCallHook } from "openclaw/plugin-sdk/agent-harness-runtime";
@@ -1,16 +1,16 @@
1
1
  {
2
2
  "name": "@openclaw/codex",
3
- "version": "2026.5.25-beta.1",
3
+ "version": "2026.5.26-beta.1",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "@openclaw/codex",
9
- "version": "2026.5.25-beta.1",
9
+ "version": "2026.5.26-beta.1",
10
10
  "dependencies": {
11
11
  "@earendil-works/pi-coding-agent": "0.75.5",
12
12
  "@openai/codex": "0.133.0",
13
- "ajv": "8.20.0",
13
+ "typebox": "1.1.38",
14
14
  "ws": "8.21.0",
15
15
  "zod": "4.4.3"
16
16
  }
@@ -274,23 +274,6 @@
274
274
  "node": ">=20.0.0"
275
275
  }
276
276
  },
277
- "node_modules/@aws-sdk/credential-provider-sso/node_modules/@aws-sdk/token-providers": {
278
- "version": "3.1052.0",
279
- "resolved": "https://registry.npmjs.org/@aws-sdk/token-providers/-/token-providers-3.1052.0.tgz",
280
- "integrity": "sha512-QqZNB3so7UIDxZtroc85TQaLVxdZRFm0eWM1CSR2N+b06as9TOrilvrlTZuj3guYlxMs6yLOgGxnklJ5qMYtTw==",
281
- "license": "Apache-2.0",
282
- "dependencies": {
283
- "@aws-sdk/core": "^3.974.13",
284
- "@aws-sdk/nested-clients": "^3.997.11",
285
- "@aws-sdk/types": "^3.973.9",
286
- "@smithy/core": "^3.24.3",
287
- "@smithy/types": "^4.14.2",
288
- "tslib": "^2.6.2"
289
- },
290
- "engines": {
291
- "node": ">=20.0.0"
292
- }
293
- },
294
277
  "node_modules/@aws-sdk/credential-provider-web-identity": {
295
278
  "version": "3.972.43",
296
279
  "resolved": "https://registry.npmjs.org/@aws-sdk/credential-provider-web-identity/-/credential-provider-web-identity-3.972.43.tgz",
@@ -963,12 +946,12 @@
963
946
  }
964
947
  },
965
948
  "node_modules/@smithy/node-http-handler": {
966
- "version": "4.7.3",
967
- "resolved": "https://registry.npmjs.org/@smithy/node-http-handler/-/node-http-handler-4.7.3.tgz",
968
- "integrity": "sha512-/jPhevcTFPMVl6KNjbaI47iOg1zxC7IsnX4PQDGVZKMFceOXtB8IEYaB7a9VvkP/3oC60WzTeKocvSI7vLT0vA==",
949
+ "version": "4.7.4",
950
+ "resolved": "https://registry.npmjs.org/@smithy/node-http-handler/-/node-http-handler-4.7.4.tgz",
951
+ "integrity": "sha512-HIeF+1vrDGzPkkv39Hj2vlHSXHY3p958jd/8ZnePIY6+ZOsQX8coyEUKO5yQu4r0bQIVsbpotVIrXXwyycMStQ==",
969
952
  "license": "Apache-2.0",
970
953
  "dependencies": {
971
- "@smithy/core": "^3.24.3",
954
+ "@smithy/core": "^3.24.4",
972
955
  "@smithy/types": "^4.14.2",
973
956
  "tslib": "^2.6.2"
974
957
  },
@@ -1049,22 +1032,6 @@
1049
1032
  "node": ">= 14"
1050
1033
  }
1051
1034
  },
1052
- "node_modules/ajv": {
1053
- "version": "8.20.0",
1054
- "resolved": "https://registry.npmjs.org/ajv/-/ajv-8.20.0.tgz",
1055
- "integrity": "sha512-Thbli+OlOj+iMPYFBVBfJ3OmCAnaSyNn4M1vz9T6Gka5Jt9ba/HIR56joy65tY6kx/FCF5VXNB819Y7/GUrBGA==",
1056
- "license": "MIT",
1057
- "dependencies": {
1058
- "fast-deep-equal": "^3.1.3",
1059
- "fast-uri": "^3.0.1",
1060
- "json-schema-traverse": "^1.0.0",
1061
- "require-from-string": "^2.0.2"
1062
- },
1063
- "funding": {
1064
- "type": "github",
1065
- "url": "https://github.com/sponsors/epoberezkin"
1066
- }
1067
- },
1068
1035
  "node_modules/balanced-match": {
1069
1036
  "version": "4.0.4",
1070
1037
  "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-4.0.4.tgz",
@@ -1203,34 +1170,12 @@
1203
1170
  "integrity": "sha512-fjquC59cD7CyW6urNXK0FBufkZcoiGG80wTuPujX590cB5Ttln20E2UB4S/WARVqhXffZl2LNgS+gQdPIIim/g==",
1204
1171
  "license": "MIT"
1205
1172
  },
1206
- "node_modules/fast-deep-equal": {
1207
- "version": "3.1.3",
1208
- "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz",
1209
- "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==",
1210
- "license": "MIT"
1211
- },
1212
1173
  "node_modules/fast-sha256": {
1213
1174
  "version": "1.3.0",
1214
1175
  "resolved": "https://registry.npmjs.org/fast-sha256/-/fast-sha256-1.3.0.tgz",
1215
1176
  "integrity": "sha512-n11RGP/lrWEFI/bWdygLxhI+pVeo1ZYIVwvvPkW7azl/rOy+F3HYRZ2K5zeE9mmkhQppyv9sQFx0JM9UabnpPQ==",
1216
1177
  "license": "Unlicense"
1217
1178
  },
1218
- "node_modules/fast-uri": {
1219
- "version": "3.1.2",
1220
- "resolved": "https://registry.npmjs.org/fast-uri/-/fast-uri-3.1.2.tgz",
1221
- "integrity": "sha512-rVjf7ArG3LTk+FS6Yw81V1DLuZl1bRbNrev6Tmd/9RaroeeRRJhAt7jg/6YFxbvAQXUCavSoZhPPj6oOx+5KjQ==",
1222
- "funding": [
1223
- {
1224
- "type": "github",
1225
- "url": "https://github.com/sponsors/fastify"
1226
- },
1227
- {
1228
- "type": "opencollective",
1229
- "url": "https://opencollective.com/fastify"
1230
- }
1231
- ],
1232
- "license": "BSD-3-Clause"
1233
- },
1234
1179
  "node_modules/fast-xml-builder": {
1235
1180
  "version": "1.2.0",
1236
1181
  "resolved": "https://registry.npmjs.org/fast-xml-builder/-/fast-xml-builder-1.2.0.tgz",
@@ -1485,12 +1430,6 @@
1485
1430
  "node": ">=16"
1486
1431
  }
1487
1432
  },
1488
- "node_modules/json-schema-traverse": {
1489
- "version": "1.0.0",
1490
- "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-1.0.0.tgz",
1491
- "integrity": "sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug==",
1492
- "license": "MIT"
1493
- },
1494
1433
  "node_modules/jwa": {
1495
1434
  "version": "2.0.1",
1496
1435
  "resolved": "https://registry.npmjs.org/jwa/-/jwa-2.0.1.tgz",
@@ -1710,15 +1649,6 @@
1710
1649
  "node": ">=12.0.0"
1711
1650
  }
1712
1651
  },
1713
- "node_modules/require-from-string": {
1714
- "version": "2.0.2",
1715
- "resolved": "https://registry.npmjs.org/require-from-string/-/require-from-string-2.0.2.tgz",
1716
- "integrity": "sha512-Xf0nWe6RseziFMu+Ap9biiUbmplq6S9/p+7w7YXP/JBHhrUDDUhwa+vANyubuqfZWTveU//DYVGsDG7RKL/vEw==",
1717
- "license": "MIT",
1718
- "engines": {
1719
- "node": ">=0.10.0"
1720
- }
1721
- },
1722
1652
  "node_modules/retry": {
1723
1653
  "version": "0.13.1",
1724
1654
  "resolved": "https://registry.npmjs.org/retry/-/retry-0.13.1.tgz",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openclaw/codex",
3
- "version": "2026.5.25-beta.1",
3
+ "version": "2026.5.26-beta.1",
4
4
  "description": "OpenClaw Codex harness and model provider plugin",
5
5
  "repository": {
6
6
  "type": "git",
@@ -10,7 +10,7 @@
10
10
  "dependencies": {
11
11
  "@earendil-works/pi-coding-agent": "0.75.5",
12
12
  "@openai/codex": "0.133.0",
13
- "ajv": "8.20.0",
13
+ "typebox": "1.1.38",
14
14
  "ws": "8.21.0",
15
15
  "zod": "4.4.3"
16
16
  },
@@ -27,10 +27,10 @@
27
27
  "minHostVersion": ">=2026.5.1-beta.1"
28
28
  },
29
29
  "compat": {
30
- "pluginApi": ">=2026.5.25-beta.1"
30
+ "pluginApi": ">=2026.5.26-beta.1"
31
31
  },
32
32
  "build": {
33
- "openclawVersion": "2026.5.25-beta.1"
33
+ "openclawVersion": "2026.5.26-beta.1"
34
34
  },
35
35
  "release": {
36
36
  "publishToClawHub": true,
@@ -47,7 +47,7 @@
47
47
  "npm-shrinkwrap.json"
48
48
  ],
49
49
  "peerDependencies": {
50
- "openclaw": ">=2026.5.25-beta.1"
50
+ "openclaw": ">=2026.5.26-beta.1"
51
51
  },
52
52
  "peerDependenciesMeta": {
53
53
  "openclaw": {