@openclaw/codex 2026.5.28 → 2026.5.30-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-DMXvboVu.js → client-B08x7Y93.js} +6 -0
  2. package/dist/client-factory-bqIbmRDu.js +20 -0
  3. package/dist/{command-handlers-C2t6-ChO.js → command-handlers-VSWuNdgc.js} +10 -10
  4. package/dist/{compact-Dlnt5G3v.js → compact-DJruF_vy.js} +3 -3
  5. package/dist/{computer-use-Ba4vW9fO.js → computer-use-Cq-EEnLL.js} +1 -1
  6. package/dist/{conversation-binding-CC9XMAwn.js → conversation-binding-DzF_JII7.js} +67 -90
  7. package/dist/harness.js +6 -10
  8. package/dist/index.js +16 -56
  9. package/dist/media-understanding-provider.js +5 -5
  10. package/dist/{models-QT-XOhE7.js → models-DuyStYTT.js} +1 -1
  11. package/dist/{native-hook-relay-B8qM8ZwR.js → native-hook-relay-zY7m-pAu.js} +74 -6
  12. package/dist/{notification-correlation-BDakP_d3.js → notification-correlation-DR9cQN_M.js} +3 -3
  13. package/dist/provider-catalog.js +2 -2
  14. package/dist/provider.js +1 -1
  15. package/dist/{request-CF4f5hWY.js → request-DGOj3AyX.js} +4 -4
  16. package/dist/{run-attempt-CuhGEh0u.js → run-attempt-lD4FLxNV.js} +424 -244
  17. package/dist/{sandbox-guard-mXE4_vE_.js → sandbox-guard-DMCJlzmz.js} +4 -1
  18. package/dist/{session-binding-ueMCn4om.js → session-binding-BGOpicy0.js} +17 -2
  19. package/dist/{shared-client-Duh1bHaP.js → shared-client-2d0XB7wz.js} +32 -3
  20. package/dist/{side-question-B-Cjb9wm.js → side-question-BsyY3v3K.js} +7 -7
  21. package/dist/{thread-lifecycle-Dv9Npl7a.js → thread-lifecycle-BR74qMaY.js} +32 -90
  22. package/npm-shrinkwrap.json +2 -2
  23. package/openclaw.plugin.json +4 -3
  24. package/package.json +4 -4
  25. package/dist/client-factory-qZvhyyXr.js +0 -15
@@ -367,6 +367,12 @@ var CodexAppServerClient = class CodexAppServerClient {
367
367
  this.notificationHandlers.add(handler);
368
368
  return () => this.notificationHandlers.delete(handler);
369
369
  }
370
+ setActiveSharedLeaseCountProviderForUnscopedNotifications(provider) {
371
+ this.activeSharedLeaseCountProvider = provider;
372
+ }
373
+ getActiveSharedLeaseCountForUnscopedNotifications() {
374
+ return this.activeSharedLeaseCountProvider?.();
375
+ }
370
376
  addCloseHandler(handler) {
371
377
  this.closeHandlers.add(handler);
372
378
  return () => this.closeHandlers.delete(handler);
@@ -0,0 +1,20 @@
1
+ //#region extensions/codex/src/app-server/client-factory.ts
2
+ let sharedClientModulePromise = null;
3
+ const loadSharedClientModule = async () => {
4
+ sharedClientModulePromise ??= import("./shared-client-2d0XB7wz.js").then((n) => n.s);
5
+ return await sharedClientModulePromise;
6
+ };
7
+ const defaultCodexAppServerClientFactory = (startOptions, authProfileId, agentDir, config) => loadSharedClientModule().then(({ getSharedCodexAppServerClient }) => getSharedCodexAppServerClient({
8
+ startOptions,
9
+ authProfileId,
10
+ agentDir,
11
+ config
12
+ }));
13
+ const defaultLeasedCodexAppServerClientFactory = (startOptions, authProfileId, agentDir, config) => loadSharedClientModule().then(({ getLeasedSharedCodexAppServerClient }) => getLeasedSharedCodexAppServerClient({
14
+ startOptions,
15
+ authProfileId,
16
+ agentDir,
17
+ config
18
+ }));
19
+ //#endregion
20
+ export { defaultLeasedCodexAppServerClientFactory as n, defaultCodexAppServerClientFactory as t };
@@ -1,20 +1,20 @@
1
1
  import { a as isCodexFastServiceTier, l as resolveCodexAppServerRuntimeOptions } from "./config--tW89bHH.js";
2
- import { n as listCodexAppServerModels, t as listAllCodexAppServerModels } from "./models-QT-XOhE7.js";
3
- import { l as isJsonObject } from "./client-DMXvboVu.js";
4
- import { i as readCodexAppServerBinding, o as writeCodexAppServerBinding, t as clearCodexAppServerBinding } from "./session-binding-ueMCn4om.js";
5
- import { i as describeControlFailure, r as CODEX_CONTROL_METHODS, t as requestCodexAppServerJson } from "./request-CF4f5hWY.js";
6
- import { a as buildHelp, c as formatCodexStatus, d as formatModels, f as formatSkills, l as formatComputerUseStatus, m as readString$1, o as formatAccount, p as formatThreads, s as formatCodexDisplayText, u as formatList, v as summarizeCodexAccountUsage } from "./notification-correlation-BDakP_d3.js";
7
- import { n as resolveCodexNativeExecutionBlock, r as resolveCodexNativeSandboxBlock } from "./sandbox-guard-mXE4_vE_.js";
8
- import { _ as steerCodexConversationTurn, b as readCodexConversationBindingData, d as parseCodexFastModeArg, f as parseCodexPermissionsModeArg, g as setCodexConversationPermissions, h as setCodexConversationModel, m as setCodexConversationFastMode, o as formatCodexCliSessions, p as readCodexConversationActiveTurn, r as startCodexConversationThread, u as formatPermissionsMode, v as stopCodexConversationTurn, x as resolveCodexDefaultWorkspaceDir, y as createCodexCliNodeConversationBindingData } from "./conversation-binding-CC9XMAwn.js";
9
- import { n as installCodexComputerUse, r as readCodexComputerUseStatus } from "./computer-use-Ba4vW9fO.js";
2
+ import { n as listCodexAppServerModels, t as listAllCodexAppServerModels } from "./models-DuyStYTT.js";
3
+ import { l as isJsonObject } from "./client-B08x7Y93.js";
4
+ import { a as readCodexAppServerBinding, s as writeCodexAppServerBinding, t as clearCodexAppServerBinding } from "./session-binding-BGOpicy0.js";
5
+ import { i as describeControlFailure, r as CODEX_CONTROL_METHODS, t as requestCodexAppServerJson } from "./request-DGOj3AyX.js";
6
+ import { a as buildHelp, c as formatCodexStatus, d as formatModels, f as formatSkills, l as formatComputerUseStatus, m as readString$1, o as formatAccount, p as formatThreads, s as formatCodexDisplayText, u as formatList, v as summarizeCodexAccountUsage } from "./notification-correlation-DR9cQN_M.js";
7
+ import { n as resolveCodexNativeExecutionBlock, r as resolveCodexNativeSandboxBlock } from "./sandbox-guard-DMCJlzmz.js";
8
+ import { _ as steerCodexConversationTurn, b as readCodexConversationBindingData, d as parseCodexFastModeArg, f as parseCodexPermissionsModeArg, g as setCodexConversationPermissions, h as setCodexConversationModel, m as setCodexConversationFastMode, o as formatCodexCliSessions, p as readCodexConversationActiveTurn, r as startCodexConversationThread, u as formatPermissionsMode, v as stopCodexConversationTurn, x as resolveCodexDefaultWorkspaceDir, y as createCodexCliNodeConversationBindingData } from "./conversation-binding-DzF_JII7.js";
9
+ import { n as installCodexComputerUse, r as readCodexComputerUseStatus } from "./computer-use-Cq-EEnLL.js";
10
10
  import { n as rememberCodexRateLimits } from "./rate-limit-cache-N66I-Rd7.js";
11
11
  import crypto from "node:crypto";
12
12
  import { normalizeOptionalString, normalizeUniqueStringEntries } from "openclaw/plugin-sdk/string-coerce-runtime";
13
- import { ensureAuthProfileStore, findNormalizedProviderValue, resolveAgentDir, resolveAuthProfileEligibility, resolveAuthProfileOrder, resolveDefaultAgentDir, resolveProfileUnusableUntilForDisplay, resolveSessionAgentIds } from "openclaw/plugin-sdk/agent-runtime";
14
13
  import { parseStrictPositiveInteger } from "openclaw/plugin-sdk/number-runtime";
14
+ import { ensureAuthProfileStore, findNormalizedProviderValue, resolveAgentDir, resolveAuthProfileEligibility, resolveAuthProfileOrder, resolveDefaultAgentDir, resolveProfileUnusableUntilForDisplay, resolveSessionAgentIds } from "openclaw/plugin-sdk/agent-runtime";
15
15
  //#region extensions/codex/src/command-account.ts
16
16
  const OPENAI_PROVIDER_ID = "openai";
17
- const OPENAI_CODEX_PROVIDER_ID = "openai-codex";
17
+ const OPENAI_CODEX_PROVIDER_ID = OPENAI_PROVIDER_ID;
18
18
  async function readCodexAccountAuthOverview(params) {
19
19
  const config = params.ctx.config;
20
20
  const store = ensureAuthProfileStore(resolveDefaultAgentDir(config), {
@@ -1,7 +1,7 @@
1
- import { t as defaultCodexAppServerClientFactory } from "./client-factory-qZvhyyXr.js";
1
+ import { t as defaultCodexAppServerClientFactory } from "./client-factory-bqIbmRDu.js";
2
2
  import { l as resolveCodexAppServerRuntimeOptions } from "./config--tW89bHH.js";
3
- import { i as readCodexAppServerBinding } from "./session-binding-ueMCn4om.js";
4
- import { n as resolveCodexNativeExecutionBlock } from "./sandbox-guard-mXE4_vE_.js";
3
+ import { a as readCodexAppServerBinding } from "./session-binding-BGOpicy0.js";
4
+ import { n as resolveCodexNativeExecutionBlock } from "./sandbox-guard-DMCJlzmz.js";
5
5
  import { embeddedAgentLog } from "openclaw/plugin-sdk/agent-harness-runtime";
6
6
  //#region extensions/codex/src/app-server/compact.ts
7
7
  const warnedIgnoredCompactionOverrides = /* @__PURE__ */ new Set();
@@ -1,5 +1,5 @@
1
1
  import { l as resolveCodexAppServerRuntimeOptions, u as resolveCodexComputerUseConfig } from "./config--tW89bHH.js";
2
- import { i as describeControlFailure, t as requestCodexAppServerJson } from "./request-CF4f5hWY.js";
2
+ import { i as describeControlFailure, t as requestCodexAppServerJson } from "./request-DGOj3AyX.js";
3
3
  import { existsSync } from "node:fs";
4
4
  //#region extensions/codex/src/app-server/computer-use.ts
5
5
  var CodexComputerUseSetupError = class extends Error {
@@ -1,17 +1,18 @@
1
1
  import { a as isCodexFastServiceTier, f as resolveOpenClawExecPolicyForCodexAppServer, l as resolveCodexAppServerRuntimeOptions, r as codexSandboxPolicyForTurn } from "./config--tW89bHH.js";
2
- import { l as isJsonObject } from "./client-DMXvboVu.js";
3
- import { t as CODEX_NATIVE_PERSONALITY_NONE } from "./thread-lifecycle-Dv9Npl7a.js";
4
- import { i as readCodexAppServerBinding, n as isCodexAppServerNativeAuthProfile, o as writeCodexAppServerBinding, r as normalizeCodexAppServerBindingModelProvider, t as clearCodexAppServerBinding } from "./session-binding-ueMCn4om.js";
5
- import { r as CODEX_CONTROL_METHODS } from "./request-CF4f5hWY.js";
6
- import { i as readCodexNotificationTurnId, r as readCodexNotificationThreadId, s as formatCodexDisplayText } from "./notification-correlation-BDakP_d3.js";
7
- import { a as releaseLeasedSharedCodexAppServerClient, f as resolveCodexAppServerAuthProfileIdForAgent, i as getLeasedSharedCodexAppServerClient } from "./shared-client-Duh1bHaP.js";
8
- import { n as resolveCodexNativeExecutionBlock, r as resolveCodexNativeSandboxBlock } from "./sandbox-guard-mXE4_vE_.js";
2
+ import { l as isJsonObject } from "./client-B08x7Y93.js";
3
+ import { t as CODEX_NATIVE_PERSONALITY_NONE } from "./thread-lifecycle-BR74qMaY.js";
4
+ import { a as readCodexAppServerBinding, i as normalizeCodexAppServerBindingModelProvider, r as isCodexAppServerNativeAuthProfile, s as writeCodexAppServerBinding, t as clearCodexAppServerBinding } from "./session-binding-BGOpicy0.js";
5
+ import { r as CODEX_CONTROL_METHODS } from "./request-DGOj3AyX.js";
6
+ import { i as readCodexNotificationTurnId, r as readCodexNotificationThreadId, s as formatCodexDisplayText } from "./notification-correlation-DR9cQN_M.js";
7
+ import { a as releaseLeasedSharedCodexAppServerClient, f as resolveCodexAppServerAuthProfileIdForAgent, i as getLeasedSharedCodexAppServerClient } from "./shared-client-2d0XB7wz.js";
8
+ import { n as resolveCodexNativeExecutionBlock, r as resolveCodexNativeSandboxBlock } from "./sandbox-guard-DMCJlzmz.js";
9
9
  import os from "node:os";
10
10
  import { loadExecApprovals } from "openclaw/plugin-sdk/exec-approvals-runtime";
11
11
  import { asOptionalRecord, isRecord, normalizeSingleOrTrimmedStringList } from "openclaw/plugin-sdk/string-coerce-runtime";
12
12
  import { materializeWindowsSpawnProgram, resolveWindowsSpawnProgram } from "openclaw/plugin-sdk/windows-spawn";
13
13
  import { formatErrorMessage, resolveSandboxContext } from "openclaw/plugin-sdk/agent-harness-runtime";
14
14
  import { spawn } from "node:child_process";
15
+ import { timestampMsToIsoString } from "openclaw/plugin-sdk/number-runtime";
15
16
  import fs from "node:fs/promises";
16
17
  import path from "node:path";
17
18
  import { resolveSessionAgentIds as resolveSessionAgentIds$1 } from "openclaw/plugin-sdk/agent-runtime";
@@ -697,7 +698,7 @@ async function readHistorySessions(codexHome) {
697
698
  };
698
699
  entry.messageCount += 1;
699
700
  if (typeof parsed.text === "string" && parsed.text.trim()) entry.lastMessage = truncateText(parsed.text.trim(), 140);
700
- if (typeof parsed.ts === "number" && Number.isFinite(parsed.ts)) entry.updatedAt = (/* @__PURE__ */ new Date(parsed.ts * 1e3)).toISOString();
701
+ if (typeof parsed.ts === "number") entry.updatedAt = timestampMsToIsoString(parsed.ts * 1e3) ?? entry.updatedAt;
701
702
  summaries.set(sessionId, entry);
702
703
  }
703
704
  return summaries;
@@ -1066,7 +1067,7 @@ async function handleCodexConversationBindingResolved(event) {
1066
1067
  if (!data || data.kind !== "codex-app-server-session") return;
1067
1068
  await clearCodexAppServerBinding(data.sessionFile);
1068
1069
  }
1069
- async function attachExistingThread(params) {
1070
+ async function resolveThreadBindingRuntime(params) {
1070
1071
  const { execPolicy, runtime } = await resolveConversationAppServerRuntime({
1071
1072
  pluginConfig: params.pluginConfig,
1072
1073
  config: params.config,
@@ -1078,103 +1079,79 @@ async function attachExistingThread(params) {
1078
1079
  agentDir: params.agentDir,
1079
1080
  config: params.config
1080
1081
  });
1081
- const modelProvider = resolveThreadRequestModelProvider({
1082
- authProfileId: params.authProfileId,
1083
- modelProvider: params.modelProvider,
1084
- ...agentLookup
1085
- });
1086
- const client = await getLeasedSharedCodexAppServerClient({
1087
- startOptions: runtime.start,
1088
- timeoutMs: runtime.requestTimeoutMs,
1082
+ return {
1083
+ execPolicy,
1084
+ runtime,
1085
+ agentLookup,
1086
+ modelProvider: resolveThreadRequestModelProvider({
1087
+ authProfileId: params.authProfileId,
1088
+ modelProvider: params.modelProvider,
1089
+ ...agentLookup
1090
+ }),
1091
+ client: await getLeasedSharedCodexAppServerClient({
1092
+ startOptions: runtime.start,
1093
+ timeoutMs: runtime.requestTimeoutMs,
1094
+ authProfileId: params.authProfileId,
1095
+ ...agentLookup
1096
+ })
1097
+ };
1098
+ }
1099
+ function buildThreadRequestRuntimeOptions(params, resolved) {
1100
+ const serviceTier = params.serviceTier ?? resolved.runtime.serviceTier;
1101
+ return {
1102
+ approvalPolicy: resolved.execPolicy?.touched ? resolved.runtime.approvalPolicy : params.approvalPolicy ?? resolved.runtime.approvalPolicy,
1103
+ approvalsReviewer: resolved.runtime.approvalsReviewer,
1104
+ sandbox: resolved.execPolicy?.touched ? resolved.runtime.sandbox : params.sandbox ?? resolved.runtime.sandbox,
1105
+ ...serviceTier ? { serviceTier } : {}
1106
+ };
1107
+ }
1108
+ async function writeThreadBindingFromResponse(params, resolved, response) {
1109
+ const runtimeApprovalPolicy = typeof resolved.runtime.approvalPolicy === "string" ? resolved.runtime.approvalPolicy : void 0;
1110
+ await writeCodexAppServerBinding(params.sessionFile, {
1111
+ threadId: response.thread.id,
1112
+ cwd: response.thread.cwd ?? params.workspaceDir,
1089
1113
  authProfileId: params.authProfileId,
1090
- ...agentLookup
1091
- });
1114
+ model: response.model ?? params.model,
1115
+ modelProvider: normalizeCodexAppServerBindingModelProvider({
1116
+ authProfileId: params.authProfileId,
1117
+ modelProvider: response.modelProvider ?? params.modelProvider,
1118
+ ...resolved.agentLookup
1119
+ }),
1120
+ approvalPolicy: resolved.execPolicy?.touched ? runtimeApprovalPolicy : params.approvalPolicy ?? runtimeApprovalPolicy,
1121
+ sandbox: resolved.execPolicy?.touched ? resolved.runtime.sandbox : params.sandbox ?? resolved.runtime.sandbox,
1122
+ serviceTier: params.serviceTier ?? resolved.runtime.serviceTier
1123
+ }, { ...resolved.agentLookup });
1124
+ }
1125
+ async function attachExistingThread(params) {
1126
+ const resolved = await resolveThreadBindingRuntime(params);
1092
1127
  try {
1093
- const response = await client.request(CODEX_CONTROL_METHODS.resumeThread, {
1128
+ await writeThreadBindingFromResponse(params, resolved, await resolved.client.request(CODEX_CONTROL_METHODS.resumeThread, {
1094
1129
  threadId: params.threadId,
1095
1130
  ...params.model ? { model: params.model } : {},
1096
- ...modelProvider ? { modelProvider } : {},
1131
+ ...resolved.modelProvider ? { modelProvider: resolved.modelProvider } : {},
1097
1132
  personality: CODEX_NATIVE_PERSONALITY_NONE,
1098
- approvalPolicy: execPolicy?.touched ? runtime.approvalPolicy : params.approvalPolicy ?? runtime.approvalPolicy,
1099
- approvalsReviewer: runtime.approvalsReviewer,
1100
- sandbox: execPolicy?.touched ? runtime.sandbox : params.sandbox ?? runtime.sandbox,
1101
- ...params.serviceTier ?? runtime.serviceTier ? { serviceTier: params.serviceTier ?? runtime.serviceTier } : {},
1133
+ ...buildThreadRequestRuntimeOptions(params, resolved),
1102
1134
  persistExtendedHistory: true
1103
- }, { timeoutMs: runtime.requestTimeoutMs });
1104
- const thread = response.thread;
1105
- const runtimeApprovalPolicy = typeof runtime.approvalPolicy === "string" ? runtime.approvalPolicy : void 0;
1106
- await writeCodexAppServerBinding(params.sessionFile, {
1107
- threadId: thread.id,
1108
- cwd: thread.cwd ?? params.workspaceDir,
1109
- authProfileId: params.authProfileId,
1110
- model: response.model ?? params.model,
1111
- modelProvider: normalizeCodexAppServerBindingModelProvider({
1112
- authProfileId: params.authProfileId,
1113
- modelProvider: response.modelProvider ?? params.modelProvider,
1114
- ...agentLookup
1115
- }),
1116
- approvalPolicy: execPolicy?.touched ? runtimeApprovalPolicy : params.approvalPolicy ?? runtimeApprovalPolicy,
1117
- sandbox: execPolicy?.touched ? runtime.sandbox : params.sandbox ?? runtime.sandbox,
1118
- serviceTier: params.serviceTier ?? runtime.serviceTier
1119
- }, { ...agentLookup });
1135
+ }, { timeoutMs: resolved.runtime.requestTimeoutMs }));
1120
1136
  } finally {
1121
- releaseLeasedSharedCodexAppServerClient(client);
1137
+ releaseLeasedSharedCodexAppServerClient(resolved.client);
1122
1138
  }
1123
1139
  }
1124
1140
  async function createThread(params) {
1125
- const { execPolicy, runtime } = await resolveConversationAppServerRuntime({
1126
- pluginConfig: params.pluginConfig,
1127
- config: params.config,
1128
- agentId: params.agentId,
1129
- sessionKey: params.sessionKey,
1130
- workspaceDir: params.workspaceDir
1131
- });
1132
- const agentLookup = buildAgentLookup({
1133
- agentDir: params.agentDir,
1134
- config: params.config
1135
- });
1136
- const modelProvider = resolveThreadRequestModelProvider({
1137
- authProfileId: params.authProfileId,
1138
- modelProvider: params.modelProvider,
1139
- ...agentLookup
1140
- });
1141
- const client = await getLeasedSharedCodexAppServerClient({
1142
- startOptions: runtime.start,
1143
- timeoutMs: runtime.requestTimeoutMs,
1144
- authProfileId: params.authProfileId,
1145
- ...agentLookup
1146
- });
1141
+ const resolved = await resolveThreadBindingRuntime(params);
1147
1142
  try {
1148
- const response = await client.request("thread/start", {
1143
+ await writeThreadBindingFromResponse(params, resolved, await resolved.client.request("thread/start", {
1149
1144
  cwd: params.workspaceDir,
1150
1145
  ...params.model ? { model: params.model } : {},
1151
- ...modelProvider ? { modelProvider } : {},
1146
+ ...resolved.modelProvider ? { modelProvider: resolved.modelProvider } : {},
1152
1147
  personality: CODEX_NATIVE_PERSONALITY_NONE,
1153
- approvalPolicy: execPolicy?.touched ? runtime.approvalPolicy : params.approvalPolicy ?? runtime.approvalPolicy,
1154
- approvalsReviewer: runtime.approvalsReviewer,
1155
- sandbox: execPolicy?.touched ? runtime.sandbox : params.sandbox ?? runtime.sandbox,
1156
- ...params.serviceTier ?? runtime.serviceTier ? { serviceTier: params.serviceTier ?? runtime.serviceTier } : {},
1148
+ ...buildThreadRequestRuntimeOptions(params, resolved),
1157
1149
  developerInstructions: "This Codex thread is bound to an OpenClaw conversation. Answer normally; OpenClaw will deliver your final response back to the conversation.",
1158
1150
  experimentalRawEvents: true,
1159
1151
  persistExtendedHistory: true
1160
- }, { timeoutMs: runtime.requestTimeoutMs });
1161
- const runtimeApprovalPolicy = typeof runtime.approvalPolicy === "string" ? runtime.approvalPolicy : void 0;
1162
- await writeCodexAppServerBinding(params.sessionFile, {
1163
- threadId: response.thread.id,
1164
- cwd: response.thread.cwd ?? params.workspaceDir,
1165
- authProfileId: params.authProfileId,
1166
- model: response.model ?? params.model,
1167
- modelProvider: normalizeCodexAppServerBindingModelProvider({
1168
- authProfileId: params.authProfileId,
1169
- modelProvider: response.modelProvider ?? params.modelProvider,
1170
- ...agentLookup
1171
- }),
1172
- approvalPolicy: execPolicy?.touched ? runtimeApprovalPolicy : params.approvalPolicy ?? runtimeApprovalPolicy,
1173
- sandbox: execPolicy?.touched ? runtime.sandbox : params.sandbox ?? runtime.sandbox,
1174
- serviceTier: params.serviceTier ?? runtime.serviceTier
1175
- }, { ...agentLookup });
1152
+ }, { timeoutMs: resolved.runtime.requestTimeoutMs }));
1176
1153
  } finally {
1177
- releaseLeasedSharedCodexAppServerClient(client);
1154
+ releaseLeasedSharedCodexAppServerClient(resolved.client);
1178
1155
  }
1179
1156
  }
1180
1157
  async function runBoundTurn(params) {
@@ -1333,8 +1310,8 @@ function enqueueBoundTurn(key, run) {
1333
1310
  function resolveThreadRequestModelProvider(params) {
1334
1311
  const modelProvider = params.modelProvider?.trim();
1335
1312
  if (!modelProvider || modelProvider.toLowerCase() === "codex") return;
1336
- if (isCodexAppServerNativeAuthProfile(params) && (modelProvider.toLowerCase() === "openai" || modelProvider.toLowerCase() === "openai-codex")) return;
1337
- return modelProvider.toLowerCase() === "openai-codex" ? "openai" : modelProvider;
1313
+ if (isCodexAppServerNativeAuthProfile(params) && modelProvider.toLowerCase() === "openai") return;
1314
+ return modelProvider.toLowerCase() === "openai" ? "openai" : modelProvider;
1338
1315
  }
1339
1316
  function buildAgentLookup(params) {
1340
1317
  const agentDir = params.agentDir?.trim();
package/dist/harness.js CHANGED
@@ -1,9 +1,5 @@
1
1
  //#region extensions/codex/harness.ts
2
- const DEFAULT_CODEX_HARNESS_PROVIDER_IDS = new Set([
3
- "codex",
4
- "openai-codex",
5
- "openai"
6
- ]);
2
+ const DEFAULT_CODEX_HARNESS_PROVIDER_IDS = new Set(["codex", "openai"]);
7
3
  const CODEX_APP_SERVER_CONTEXT_ENGINE_HOST_CAPABILITIES = [
8
4
  "bootstrap",
9
5
  "assemble-before-prompt",
@@ -32,31 +28,31 @@ function createCodexAppServerAgentHarness(options) {
32
28
  };
33
29
  },
34
30
  runAttempt: async (params) => {
35
- const { runCodexAppServerAttempt } = await import("./run-attempt-CuhGEh0u.js");
31
+ const { runCodexAppServerAttempt } = await import("./run-attempt-lD4FLxNV.js");
36
32
  return runCodexAppServerAttempt(params, {
37
33
  pluginConfig: options?.resolvePluginConfig?.() ?? options?.pluginConfig,
38
34
  nativeHookRelay: { enabled: true }
39
35
  });
40
36
  },
41
37
  runSideQuestion: async (params) => {
42
- const { runCodexAppServerSideQuestion } = await import("./side-question-B-Cjb9wm.js");
38
+ const { runCodexAppServerSideQuestion } = await import("./side-question-BsyY3v3K.js");
43
39
  return runCodexAppServerSideQuestion(params, {
44
40
  pluginConfig: options?.resolvePluginConfig?.() ?? options?.pluginConfig,
45
41
  nativeHookRelay: { enabled: true }
46
42
  });
47
43
  },
48
44
  compact: async (params) => {
49
- const { maybeCompactCodexAppServerSession } = await import("./compact-Dlnt5G3v.js");
45
+ const { maybeCompactCodexAppServerSession } = await import("./compact-DJruF_vy.js");
50
46
  return maybeCompactCodexAppServerSession(params, { pluginConfig: options?.resolvePluginConfig?.() ?? options?.pluginConfig });
51
47
  },
52
48
  reset: async (params) => {
53
49
  if (params.sessionFile) {
54
- const { clearCodexAppServerBinding } = await import("./session-binding-ueMCn4om.js").then((n) => n.a);
50
+ const { clearCodexAppServerBinding } = await import("./session-binding-BGOpicy0.js").then((n) => n.o);
55
51
  await clearCodexAppServerBinding(params.sessionFile);
56
52
  }
57
53
  },
58
54
  dispose: async () => {
59
- const { clearSharedCodexAppServerClientAndWait } = await import("./shared-client-Duh1bHaP.js").then((n) => n.s);
55
+ const { clearSharedCodexAppServerClientAndWait } = await import("./shared-client-2d0XB7wz.js").then((n) => n.s);
60
56
  await clearSharedCodexAppServerClientAndWait();
61
57
  }
62
58
  };
package/dist/index.js CHANGED
@@ -1,25 +1,25 @@
1
1
  import { createCodexAppServerAgentHarness } from "./harness.js";
2
2
  import { c as readCodexPluginConfig, l as resolveCodexAppServerRuntimeOptions, t as CODEX_PLUGINS_MARKETPLACE_NAME } from "./config--tW89bHH.js";
3
3
  import { buildCodexProvider } from "./provider.js";
4
- import { v as ensureCodexPluginActivation, x as defaultCodexAppInventoryCache, y as pluginReadParams } from "./thread-lifecycle-Dv9Npl7a.js";
4
+ import { v as ensureCodexPluginActivation, x as defaultCodexAppInventoryCache, y as pluginReadParams } from "./thread-lifecycle-BR74qMaY.js";
5
5
  import { buildCodexMediaUnderstandingProvider } from "./media-understanding-provider.js";
6
- import { i as describeControlFailure, n as buildCodexPluginAppCacheKey, t as requestCodexAppServerJson } from "./request-CF4f5hWY.js";
7
- import { s as formatCodexDisplayText } from "./notification-correlation-BDakP_d3.js";
8
- import { a as releaseLeasedSharedCodexAppServerClient, f as resolveCodexAppServerAuthProfileIdForAgent, i as getLeasedSharedCodexAppServerClient, n as clearSharedCodexAppServerClientIfCurrentAndWait, p as resolveCodexAppServerFallbackApiKeyCacheKey, u as resolveCodexAppServerAuthAccountCacheKey } from "./shared-client-Duh1bHaP.js";
9
- import { a as createCodexCliSessionNodeInvokePolicies, c as resolveCodexCliSessionForBindingOnNode, i as createCodexCliSessionNodeHostCommands, l as resumeCodexCliSessionOnNode, n as handleCodexConversationInboundClaim, s as listCodexCliSessionsOnNode, t as handleCodexConversationBindingResolved } from "./conversation-binding-CC9XMAwn.js";
6
+ import { i as describeControlFailure, n as buildCodexPluginAppCacheKey, t as requestCodexAppServerJson } from "./request-DGOj3AyX.js";
7
+ import { s as formatCodexDisplayText } from "./notification-correlation-DR9cQN_M.js";
8
+ import { a as releaseLeasedSharedCodexAppServerClient, f as resolveCodexAppServerAuthProfileIdForAgent, i as getLeasedSharedCodexAppServerClient, n as clearSharedCodexAppServerClientIfCurrentAndWait, p as resolveCodexAppServerFallbackApiKeyCacheKey, u as resolveCodexAppServerAuthAccountCacheKey } from "./shared-client-2d0XB7wz.js";
9
+ import { a as createCodexCliSessionNodeInvokePolicies, c as resolveCodexCliSessionForBindingOnNode, i as createCodexCliSessionNodeHostCommands, l as resumeCodexCliSessionOnNode, n as handleCodexConversationInboundClaim, s as listCodexCliSessionsOnNode, t as handleCodexConversationBindingResolved } from "./conversation-binding-DzF_JII7.js";
10
10
  import { mutateConfigFile } from "openclaw/plugin-sdk/config-mutation";
11
11
  import { resolveLivePluginConfigObject } from "openclaw/plugin-sdk/plugin-config-runtime";
12
12
  import { definePluginEntry } from "openclaw/plugin-sdk/plugin-entry";
13
13
  import os from "node:os";
14
14
  import { asBoolean, isRecord, normalizeOptionalString, uniqueStrings } from "openclaw/plugin-sdk/string-coerce-runtime";
15
+ import { parseStrictNonNegativeInteger } from "openclaw/plugin-sdk/number-runtime";
15
16
  import fs from "node:fs/promises";
16
17
  import path from "node:path";
17
18
  import { loadAuthProfileStoreWithoutExternalProfiles, resolveAgentConfig, resolveAgentWorkspaceDir, resolveDefaultAgentId } from "openclaw/plugin-sdk/agent-runtime";
18
19
  import { pathExists } from "openclaw/plugin-sdk/security-runtime";
19
20
  import { MIGRATION_REASON_TARGET_EXISTS, applyMigrationManualItem, createMigrationItem, createMigrationManualItem, hasMigrationConfigPatchConflict, markMigrationItemConflict, markMigrationItemError, markMigrationItemSkipped, readMigrationConfigPath, summarizeMigrationItems, writeMigrationConfigPath } from "openclaw/plugin-sdk/migration";
20
21
  import { archiveMigrationItem, copyMigrationFileItem, withCachedMigrationConfigRuntime, writeMigrationReport } from "openclaw/plugin-sdk/migration-runtime";
21
- import { parseStrictNonNegativeInteger } from "openclaw/plugin-sdk/number-runtime";
22
- import { applyAuthProfileConfig, buildApiKeyCredential, buildOauthProviderAuthResult, readCodexCliCredentialsCached, updateAuthProfileStoreWithLock } from "openclaw/plugin-sdk/provider-auth";
22
+ import { applyAuthProfileConfig, buildApiKeyCredential, buildOauthProviderAuthResult, buildOpenAICodexCredentialExtra, readCodexCliCredentialsCached, resolveOpenAICodexAuthIdentity, resolveOpenAICodexImportProfileName, updateAuthProfileStoreWithLock } from "openclaw/plugin-sdk/provider-auth";
23
23
  import { readJsonFileWithFallback } from "openclaw/plugin-sdk/json-store";
24
24
  //#region extensions/codex/src/commands.ts
25
25
  function createCodexCommand(options) {
@@ -48,7 +48,7 @@ async function handleCodexCommand(ctx, options = {}) {
48
48
  }
49
49
  }
50
50
  async function loadDefaultCodexSubcommandHandler() {
51
- const { handleCodexSubcommand } = await import("./command-handlers-C2t6-ChO.js");
51
+ const { handleCodexSubcommand } = await import("./command-handlers-VSWuNdgc.js");
52
52
  return handleCodexSubcommand;
53
53
  }
54
54
  //#endregion
@@ -82,7 +82,6 @@ async function readJsonObject(filePath) {
82
82
  }
83
83
  //#endregion
84
84
  //#region extensions/codex/src/migration/auth.ts
85
- const OPENAI_CODEX_PROVIDER_ID = "openai-codex";
86
85
  const OPENAI_PROVIDER_ID = "openai";
87
86
  const OPENAI_CODEX_DEFAULT_MODEL = "openai/gpt-5.5";
88
87
  const CODEX_IMPORT_DISPLAY_NAME = "Codex import";
@@ -93,48 +92,6 @@ const CODEX_REASON_AUTH_NO_LONGER_PRESENT = "auth credential no longer present";
93
92
  const CODEX_REASON_MISSING_AUTH_METADATA = "missing auth metadata";
94
93
  const CODEX_CONFIG_PATCH_MODE_RETURN$1 = "return";
95
94
  var CodexAuthConfigConflict = class extends Error {};
96
- function decodeJwtPayload(token) {
97
- const payload = token.split(".")[1];
98
- if (!payload) return;
99
- try {
100
- const parsed = JSON.parse(Buffer.from(payload, "base64url").toString("utf8"));
101
- return isRecord(parsed) ? parsed : void 0;
102
- } catch {
103
- return;
104
- }
105
- }
106
- function resolveCodexIdentity(access, accountId) {
107
- const payload = decodeJwtPayload(access);
108
- const auth = isRecord(payload?.["https://api.openai.com/auth"]) ? payload["https://api.openai.com/auth"] : {};
109
- const email = normalizeOptionalString((isRecord(payload?.["https://api.openai.com/profile"]) ? payload["https://api.openai.com/profile"] : {}).email);
110
- const resolvedAccountId = accountId ?? normalizeOptionalString(auth.chatgpt_account_id);
111
- const chatgptPlanType = normalizeOptionalString(auth.chatgpt_plan_type);
112
- if (email) return {
113
- ...resolvedAccountId ? { accountId: resolvedAccountId } : {},
114
- ...chatgptPlanType ? { chatgptPlanType } : {},
115
- email,
116
- profileName: email
117
- };
118
- const stableSubject = normalizeOptionalString(auth.chatgpt_account_user_id) ?? normalizeOptionalString(auth.chatgpt_user_id) ?? normalizeOptionalString(auth.user_id) ?? normalizeOptionalString(payload?.sub) ?? resolvedAccountId;
119
- return {
120
- ...resolvedAccountId ? { accountId: resolvedAccountId } : {},
121
- ...chatgptPlanType ? { chatgptPlanType } : {},
122
- ...stableSubject ? { profileName: `id-${Buffer.from(stableSubject).toString("base64url")}` } : {}
123
- };
124
- }
125
- function credentialExtra(identity) {
126
- const extra = {
127
- ...identity.accountId ? { accountId: identity.accountId } : {},
128
- ...identity.chatgptPlanType ? { chatgptPlanType: identity.chatgptPlanType } : {},
129
- ...identity.idToken ? { idToken: identity.idToken } : {}
130
- };
131
- return Object.keys(extra).length > 0 ? extra : void 0;
132
- }
133
- function importProfileName(identity, fallback) {
134
- if (identity.accountId) return `account-${identity.accountId.replaceAll(/[^A-Za-z0-9._-]+/gu, "-")}`;
135
- if (identity.profileName?.startsWith("id-")) return identity.profileName;
136
- return fallback;
137
- }
138
95
  async function readModelRefs(source) {
139
96
  const cache = await readJsonObject(source.modelsCachePath);
140
97
  const models = Array.isArray(cache.models) ? cache.models : [];
@@ -159,19 +116,22 @@ async function buildCodexOAuthCredential(source) {
159
116
  ttlMs: 0
160
117
  });
161
118
  if (!credential) return null;
162
- const identity = resolveCodexIdentity(credential.access, credential.accountId);
119
+ const identity = resolveOpenAICodexAuthIdentity({
120
+ access: credential.access,
121
+ accountId: credential.accountId
122
+ });
163
123
  const modelRefs = await readModelRefs(source);
164
124
  const configPatch = { agents: { defaults: { models: Object.fromEntries(modelRefs.map((modelRef) => [modelRef, {}])) } } };
165
125
  const result = buildOauthProviderAuthResult({
166
- providerId: OPENAI_CODEX_PROVIDER_ID,
126
+ providerId: OPENAI_PROVIDER_ID,
167
127
  defaultModel: OPENAI_CODEX_DEFAULT_MODEL,
168
128
  access: credential.access,
169
129
  refresh: credential.refresh,
170
130
  expires: credential.expires,
171
131
  email: identity.email,
172
- profileName: importProfileName(identity, "codex-import"),
132
+ profileName: resolveOpenAICodexImportProfileName(identity, "codex-import"),
173
133
  displayName: CODEX_IMPORT_DISPLAY_NAME,
174
- credentialExtra: credentialExtra({
134
+ credentialExtra: buildOpenAICodexCredentialExtra({
175
135
  accountId: identity.accountId,
176
136
  chatgptPlanType: identity.chatgptPlanType,
177
137
  idToken: credential.idToken
@@ -181,7 +141,7 @@ async function buildCodexOAuthCredential(source) {
181
141
  const profile = result.profiles[0];
182
142
  return profile ? {
183
143
  kind: "oauth",
184
- provider: OPENAI_CODEX_PROVIDER_ID,
144
+ provider: OPENAI_PROVIDER_ID,
185
145
  profileId: profile.profileId,
186
146
  result,
187
147
  modelConfigs: readProviderAuthModelConfigs(result)
@@ -1,10 +1,10 @@
1
1
  import { CODEX_PROVIDER_ID, FALLBACK_CODEX_MODELS } from "./provider-catalog.js";
2
- import "./client-factory-qZvhyyXr.js";
2
+ import "./client-factory-bqIbmRDu.js";
3
3
  import { l as resolveCodexAppServerRuntimeOptions } from "./config--tW89bHH.js";
4
4
  import { i as assertCodexTurnStartResponse, l as readCodexTurnCompletedNotification, o as readCodexErrorNotification, r as assertCodexThreadStartResponse } from "./protocol-validators-DtjYmUw_.js";
5
- import { i as readModelListResult } from "./models-QT-XOhE7.js";
6
- import { l as isJsonObject } from "./client-DMXvboVu.js";
7
- import { r as buildCodexRuntimeThreadConfig } from "./thread-lifecycle-Dv9Npl7a.js";
5
+ import { i as readModelListResult } from "./models-DuyStYTT.js";
6
+ import { l as isJsonObject } from "./client-B08x7Y93.js";
7
+ import { r as buildCodexRuntimeThreadConfig } from "./thread-lifecycle-BR74qMaY.js";
8
8
  import { validateJsonSchemaValue } from "openclaw/plugin-sdk/json-schema-runtime";
9
9
  import "openclaw/plugin-sdk/media-understanding";
10
10
  //#region extensions/codex/media-understanding-provider.ts
@@ -65,7 +65,7 @@ async function runBoundedCodexVisionTurn(params) {
65
65
  const appServer = resolveCodexAppServerRuntimeOptions({ pluginConfig: params.options.pluginConfig });
66
66
  const timeoutMs = Math.max(100, params.timeoutMs);
67
67
  const ownsClient = !params.options.clientFactory;
68
- const client = params.options.clientFactory ? await params.options.clientFactory(appServer.start, params.profile) : await import("./shared-client-Duh1bHaP.js").then((n) => n.s).then(({ createIsolatedCodexAppServerClient }) => createIsolatedCodexAppServerClient({
68
+ const client = params.options.clientFactory ? await params.options.clientFactory(appServer.start, params.profile) : await import("./shared-client-2d0XB7wz.js").then((n) => n.s).then(({ createIsolatedCodexAppServerClient }) => createIsolatedCodexAppServerClient({
69
69
  startOptions: appServer.start,
70
70
  timeoutMs,
71
71
  authProfileId: params.profile
@@ -40,7 +40,7 @@ async function listAllCodexAppServerModels(options = {}) {
40
40
  async function withCodexAppServerModelClient(options, run) {
41
41
  const timeoutMs = options.timeoutMs ?? 2500;
42
42
  const useSharedClient = options.sharedClient !== false;
43
- const { createIsolatedCodexAppServerClient, getLeasedSharedCodexAppServerClient, releaseLeasedSharedCodexAppServerClient } = await import("./shared-client-Duh1bHaP.js").then((n) => n.s);
43
+ const { createIsolatedCodexAppServerClient, getLeasedSharedCodexAppServerClient, releaseLeasedSharedCodexAppServerClient } = await import("./shared-client-2d0XB7wz.js").then((n) => n.s);
44
44
  const client = useSharedClient ? await getLeasedSharedCodexAppServerClient({
45
45
  startOptions: options.startOptions,
46
46
  timeoutMs,
@@ -1,18 +1,86 @@
1
- import { l as isJsonObject } from "./client-DMXvboVu.js";
2
- import { S as invalidInlineImageText, w as sanitizeInlineImageDataUrl } from "./thread-lifecycle-Dv9Npl7a.js";
3
- import { s as formatCodexDisplayText } from "./notification-correlation-BDakP_d3.js";
1
+ import { l as isJsonObject } from "./client-B08x7Y93.js";
2
+ import { S as invalidInlineImageText, w as sanitizeInlineImageDataUrl } from "./thread-lifecycle-BR74qMaY.js";
3
+ import { s as formatCodexDisplayText } from "./notification-correlation-DR9cQN_M.js";
4
4
  import { createHash } from "node:crypto";
5
5
  import { normalizeAgentId } from "openclaw/plugin-sdk/routing";
6
6
  import { asOptionalRecord, isRecord, normalizeTrimmedStringList } from "openclaw/plugin-sdk/string-coerce-runtime";
7
7
  import { HEARTBEAT_RESPONSE_TOOL_NAME, buildAgentHookContextChannelFields, callGatewayTool, createAgentToolResultMiddlewareRunner, createCodexAppServerToolResultExtensionRunner, embeddedAgentLog, extractToolResultMediaArtifact, filterToolResultMediaUrls, formatApprovalDisplayPath, hasNativeHookRelayInvocation, invokeNativeHookRelay, isMessagingTool, isMessagingToolSendAction, isToolWrappedWithBeforeToolCallHook, normalizeHeartbeatToolResponse, projectRuntimeToolInputSchema, registerNativeHookRelay, resolveNativeHookRelayDeferredToolApproval, runAgentHarnessAfterToolCallHook, runBeforeToolCallHook, setBeforeToolCallDiagnosticsEnabled, wrapToolWithBeforeToolCallHook } from "openclaw/plugin-sdk/agent-harness-runtime";
8
+ import { addTimerTimeoutGraceMs, resolveTimerTimeoutMs } from "openclaw/plugin-sdk/number-runtime";
8
9
  import { emitTrustedDiagnosticEvent } from "openclaw/plugin-sdk/diagnostic-runtime";
10
+ const CODEX_TURN_COMPLETION_IDLE_TIMEOUT_MS = 6e4;
11
+ const CODEX_TURN_ASSISTANT_COMPLETION_IDLE_TIMEOUT_MS = 1e4;
12
+ const CODEX_POST_TOOL_RAW_ASSISTANT_COMPLETION_IDLE_TIMEOUT_MS = 5 * 6e4;
13
+ const CODEX_POST_REASONING_REPLY_IDLE_TIMEOUT_MS = 5 * 6e4;
14
+ const CODEX_TURN_TERMINAL_IDLE_TIMEOUT_MS = 30 * 6e4;
15
+ function resolvePositiveIntegerTimeoutMs(value, fallbackMs) {
16
+ return resolveTimerTimeoutMs(value, resolveTimerTimeoutMs(fallbackMs, 1));
17
+ }
18
+ async function withCodexStartupTimeout(params) {
19
+ if (params.signal.aborted) throw new Error("codex app-server startup aborted");
20
+ let timeout;
21
+ let abortCleanup;
22
+ let timeoutError;
23
+ let timeoutCleanup;
24
+ try {
25
+ return await Promise.race([params.operation(), new Promise((_, reject) => {
26
+ const rejectOnce = (error) => {
27
+ if (timeout) {
28
+ clearTimeout(timeout);
29
+ timeout = void 0;
30
+ }
31
+ reject(error);
32
+ };
33
+ timeout = setTimeout(() => {
34
+ timeoutError = /* @__PURE__ */ new Error("codex app-server startup timed out");
35
+ timeoutCleanup = Promise.resolve(params.onTimeout?.()).then(() => void 0, () => void 0);
36
+ timeoutCleanup.finally(() => {
37
+ rejectOnce(timeoutError);
38
+ });
39
+ }, params.timeoutMs);
40
+ const abortListener = () => rejectOnce(/* @__PURE__ */ new Error("codex app-server startup aborted"));
41
+ params.signal.addEventListener("abort", abortListener, { once: true });
42
+ abortCleanup = () => params.signal.removeEventListener("abort", abortListener);
43
+ })]);
44
+ } catch (error) {
45
+ if (timeoutError) {
46
+ await timeoutCleanup;
47
+ throw timeoutError;
48
+ }
49
+ throw error;
50
+ } finally {
51
+ if (timeout) clearTimeout(timeout);
52
+ abortCleanup?.();
53
+ }
54
+ }
55
+ function resolveCodexStartupTimeoutMs(params) {
56
+ const timeoutFloorMs = resolvePositiveIntegerTimeoutMs(params.timeoutFloorMs, 100);
57
+ const timeoutMs = resolvePositiveIntegerTimeoutMs(params.timeoutMs, timeoutFloorMs);
58
+ return Math.max(timeoutFloorMs, timeoutMs);
59
+ }
60
+ function resolveCodexTurnCompletionIdleTimeoutMs(value) {
61
+ return resolvePositiveIntegerTimeoutMs(value, CODEX_TURN_COMPLETION_IDLE_TIMEOUT_MS);
62
+ }
63
+ function resolveCodexTurnAssistantCompletionIdleTimeoutMs(value) {
64
+ return resolvePositiveIntegerTimeoutMs(value, CODEX_TURN_ASSISTANT_COMPLETION_IDLE_TIMEOUT_MS);
65
+ }
66
+ function resolveCodexPostToolRawAssistantCompletionIdleTimeoutMs(value, fallbackMs) {
67
+ return resolvePositiveIntegerTimeoutMs(value, Math.max(resolvePositiveIntegerTimeoutMs(void 0, fallbackMs), CODEX_POST_TOOL_RAW_ASSISTANT_COMPLETION_IDLE_TIMEOUT_MS));
68
+ }
69
+ function resolveCodexTurnTerminalIdleTimeoutMs(value) {
70
+ return resolvePositiveIntegerTimeoutMs(value, CODEX_TURN_TERMINAL_IDLE_TIMEOUT_MS);
71
+ }
72
+ function resolveCodexGatewayTimeoutWithGraceMs(timeoutMs, graceMs = 1e4) {
73
+ const timeout = resolvePositiveIntegerTimeoutMs(timeoutMs, 1);
74
+ return addTimerTimeoutGraceMs(timeout, resolveTimerTimeoutMs(graceMs, 0, 0)) ?? timeout;
75
+ }
76
+ //#endregion
9
77
  //#region extensions/codex/src/app-server/plugin-approval-roundtrip.ts
10
78
  const DEFAULT_CODEX_APPROVAL_TIMEOUT_MS = 12e4;
11
79
  const MAX_PLUGIN_APPROVAL_TITLE_LENGTH = 80;
12
80
  const MAX_PLUGIN_APPROVAL_DESCRIPTION_LENGTH = 256;
13
81
  async function requestPluginApproval(params) {
14
82
  const timeoutMs = DEFAULT_CODEX_APPROVAL_TIMEOUT_MS;
15
- return callGatewayTool("plugin.approval.request", { timeoutMs: 13e4 }, {
83
+ return callGatewayTool("plugin.approval.request", { timeoutMs: resolveCodexGatewayTimeoutWithGraceMs(timeoutMs) }, {
16
84
  pluginId: "openclaw-codex-app-server",
17
85
  title: truncateForGateway(params.title, MAX_PLUGIN_APPROVAL_TITLE_LENGTH),
18
86
  description: truncateForGateway(params.description, MAX_PLUGIN_APPROVAL_DESCRIPTION_LENGTH),
@@ -40,7 +108,7 @@ function approvalRequestExplicitlyUnavailable(result) {
40
108
  return descriptor !== void 0 && "value" in descriptor && descriptor.value === null;
41
109
  }
42
110
  async function waitForPluginApprovalDecision(params) {
43
- const waitPromise = callGatewayTool("plugin.approval.waitDecision", { timeoutMs: 13e4 }, { id: params.approvalId });
111
+ const waitPromise = callGatewayTool("plugin.approval.waitDecision", { timeoutMs: resolveCodexGatewayTimeoutWithGraceMs(DEFAULT_CODEX_APPROVAL_TIMEOUT_MS) }, { id: params.approvalId });
44
112
  if (!params.signal) return (await waitPromise)?.decision;
45
113
  let onAbort;
46
114
  const abortPromise = new Promise((_, reject) => {
@@ -2091,4 +2159,4 @@ function sortJsonValue(value) {
2091
2159
  return sorted;
2092
2160
  }
2093
2161
  //#endregion
2094
- export { normalizeCodexDynamicToolName as _, createCodexNativeHookRelay as a, scheduleCodexNativeHookRelayUnregister as c, emitDynamicToolErrorDiagnostic as d, emitDynamicToolStartedDiagnostic as f, isForcedPrivateQaCodexRuntime as g, filterCodexDynamicTools as h, buildCodexNativeHookRelayDisabledConfig as i, handleCodexAppServerElicitationRequest as l, filterToolsForVisionInputs as m, CODEX_NATIVE_HOOK_RELAY_TTL_GRACE_MS as n, resolveCodexNativeHookRelayEvents as o, emitDynamicToolTerminalDiagnostic as p, buildCodexNativeHookRelayConfig as r, resolveCodexNativeHookRelayTtlMs as s, CODEX_NATIVE_HOOK_RELAY_EVENTS as t, createCodexDynamicToolBridge as u, resolveCodexDynamicToolsLoading as v, handleCodexAppServerApprovalRequest as y };
2162
+ export { resolveCodexTurnAssistantCompletionIdleTimeoutMs as C, withCodexStartupTimeout as E, resolveCodexStartupTimeoutMs as S, resolveCodexTurnTerminalIdleTimeoutMs as T, normalizeCodexDynamicToolName as _, createCodexNativeHookRelay as a, CODEX_POST_REASONING_REPLY_IDLE_TIMEOUT_MS as b, scheduleCodexNativeHookRelayUnregister as c, emitDynamicToolErrorDiagnostic as d, emitDynamicToolStartedDiagnostic as f, isForcedPrivateQaCodexRuntime as g, filterCodexDynamicTools as h, buildCodexNativeHookRelayDisabledConfig as i, handleCodexAppServerElicitationRequest as l, filterToolsForVisionInputs as m, CODEX_NATIVE_HOOK_RELAY_TTL_GRACE_MS as n, resolveCodexNativeHookRelayEvents as o, emitDynamicToolTerminalDiagnostic as p, buildCodexNativeHookRelayConfig as r, resolveCodexNativeHookRelayTtlMs as s, CODEX_NATIVE_HOOK_RELAY_EVENTS as t, createCodexDynamicToolBridge as u, resolveCodexDynamicToolsLoading as v, resolveCodexTurnCompletionIdleTimeoutMs as w, resolveCodexPostToolRawAssistantCompletionIdleTimeoutMs as x, handleCodexAppServerApprovalRequest as y };