@openclaw/codex 2026.5.14-beta.1 → 2026.5.16-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.
@@ -0,0 +1,9 @@
1
+ //#region extensions/codex/src/app-server/client-factory.ts
2
+ const defaultCodexAppServerClientFactory = (startOptions, authProfileId, agentDir, config) => import("./shared-client-BwUqd3lh.js").then((n) => n.a).then(({ getSharedCodexAppServerClient }) => getSharedCodexAppServerClient({
3
+ startOptions,
4
+ authProfileId,
5
+ agentDir,
6
+ config
7
+ }));
8
+ //#endregion
9
+ export { defaultCodexAppServerClientFactory as t };
@@ -26,9 +26,13 @@ function shouldRefreshCodexRateLimitsForUsageLimitMessage(message) {
26
26
  return Boolean(text?.includes("You've reached your Codex subscription usage limit.") && !text.includes("Next reset "));
27
27
  }
28
28
  function summarizeCodexRateLimits(value, nowMs = Date.now()) {
29
- const snapshots = collectCodexRateLimitSnapshots(value);
29
+ const snapshots = collectCodexRateLimitSnapshots(value).filter(snapshotHasDisplayableData);
30
30
  if (snapshots.length === 0) return;
31
- return snapshots.slice(0, 4).map((snapshot) => summarizeRateLimitSnapshot(snapshot, nowMs)).join("; ");
31
+ const summaries = snapshots.slice(0, 4).map((snapshot) => summarizeRateLimitSnapshot(snapshot, nowMs)).filter((summary) => summary !== void 0);
32
+ return summaries.length > 0 ? summaries.join("; ") : void 0;
33
+ }
34
+ function hasCodexRateLimitSnapshots(value) {
35
+ return collectCodexRateLimitSnapshots(value).length > 0;
32
36
  }
33
37
  function summarizeCodexAccountRateLimits(value, nowMs = Date.now()) {
34
38
  const summary = summarizeCodexAccountUsage(value, nowMs);
@@ -40,7 +44,7 @@ function resolveCodexUsageLimitResetAtMs(value, nowMs = Date.now()) {
40
44
  return selectBlockingRateLimitReset(value, nowMs)?.resetsAtMs;
41
45
  }
42
46
  function summarizeCodexAccountUsage(value, nowMs = Date.now()) {
43
- const snapshots = collectCodexRateLimitSnapshots(value);
47
+ const snapshots = collectCodexRateLimitSnapshots(value).filter(snapshotHasDisplayableData);
44
48
  if (snapshots.length === 0) return;
45
49
  const usageSnapshot = snapshots.find(isCodexLimitSnapshot) ?? snapshots[0];
46
50
  const blockedSnapshots = snapshots.filter(snapshotHasLimitBlock);
@@ -86,7 +90,8 @@ function summarizeRateLimitSnapshot(snapshot, nowMs) {
86
90
  });
87
91
  const reachedType = readString$1(snapshot, "rateLimitReachedType") ?? readString$1(snapshot, "rate_limit_reached_type");
88
92
  const suffix = reachedType ? ` (${formatReachedType(reachedType)})` : "";
89
- return `${label}: ${windows.join(" · ") || "available"}${suffix}`;
93
+ if (windows.length > 0) return `${label}: ${windows.join(" · ")}${suffix}`;
94
+ if (reachedType) return `${label}: ${formatReachedType(reachedType)}`;
90
95
  }
91
96
  function collectCodexRateLimitSnapshots(value) {
92
97
  const snapshots = [];
@@ -143,6 +148,10 @@ function readRateLimitWindow(snapshot, key) {
143
148
  ...readOptionalNumberField(window, "windowDurationMins", "window_duration_mins", "windowMinutes", "window_minutes")
144
149
  };
145
150
  }
151
+ function snapshotHasDisplayableData(snapshot) {
152
+ if (readString$1(snapshot, "rateLimitReachedType") ?? readString$1(snapshot, "rate_limit_reached_type")) return true;
153
+ return readWindowEntries(snapshot).some((entry) => entry.window.usedPercent !== void 0 || entry.window.resetsAtMs > 0);
154
+ }
146
155
  function readOptionalNumberField(record, ...keys) {
147
156
  const value = keys.map((key) => readNumber(record, key)).find((entry) => entry !== void 0);
148
157
  if (value === void 0) return {};
@@ -454,16 +463,21 @@ function summarizeArrayLike(value) {
454
463
  return `${entries.length}`;
455
464
  }
456
465
  function formatCodexRateLimitSummary(value) {
457
- return formatCodexDisplayText(summarizeCodexRateLimits(value) ?? summarizeRateLimits(value));
466
+ const summary = summarizeCodexRateLimits(value);
467
+ if (summary) return formatCodexDisplayText(summary);
468
+ return formatCodexDisplayText(hasCodexRateLimitSnapshots(value) ? "none returned" : summarizeRateLimits(value));
458
469
  }
459
470
  function formatCodexRateLimitDetails(value) {
460
471
  const lines = summarizeCodexAccountRateLimits(value);
461
- if (!lines) return formatCodexDisplayText(summarizeRateLimits(value));
472
+ if (!lines) return formatCodexDisplayText(hasCodexRateLimitSnapshots(value) ? "none returned" : summarizeRateLimits(value));
462
473
  return lines.map(formatCodexDisplayText).join("\n");
463
474
  }
464
475
  function summarizeRateLimits(value) {
465
476
  const entries = extractArray(value);
466
- if (entries.length > 0) return `${entries.length}`;
477
+ if (entries.length > 0) {
478
+ const count = entries.filter(isMeaningfulRateLimitSnapshot).length;
479
+ return count > 0 ? `${count}` : "none returned";
480
+ }
467
481
  if (!isJsonObject(value)) return "none returned";
468
482
  const keyed = value.rateLimitsByLimitId;
469
483
  if (isJsonObject(keyed)) {
@@ -473,7 +487,12 @@ function summarizeRateLimits(value) {
473
487
  return isMeaningfulRateLimitSnapshot(value.rateLimits) ? "1" : "none returned";
474
488
  }
475
489
  function isMeaningfulRateLimitSnapshot(value) {
476
- return isJsonObject(value) && Object.values(value).some((entry) => entry != null);
490
+ if (!isJsonObject(value)) return false;
491
+ if (readString(value, "rateLimitReachedType") ?? readString(value, "rate_limit_reached_type")) return true;
492
+ return ["primary", "secondary"].some((key) => {
493
+ const window = value[key];
494
+ return isJsonObject(window) && Object.values(window).some((entry) => entry != null);
495
+ });
477
496
  }
478
497
  function extractArray(value) {
479
498
  if (Array.isArray(value)) return value;
@@ -1,12 +1,12 @@
1
1
  import { i as isCodexFastServiceTier, s as resolveCodexAppServerRuntimeOptions } from "./config-0rd3LnKg.js";
2
2
  import { n as listCodexAppServerModels, t as listAllCodexAppServerModels } from "./models-GCYf5s8J.js";
3
3
  import { t as isJsonObject } from "./protocol-C9UWI98H.js";
4
- import { n as CODEX_CONTROL_METHODS, r as describeControlFailure, t as requestCodexAppServerJson } from "./request-BxAP1uyw.js";
5
- import { a as formatComputerUseStatus, c as formatThreads, i as formatCodexStatus, l as readString$1, n as formatAccount, o as formatList, p as summarizeCodexAccountUsage, r as formatCodexDisplayText, s as formatModels, t as buildHelp } from "./command-formatters-CJH9-hFT.js";
4
+ import { i as describeControlFailure, r as CODEX_CONTROL_METHODS, t as requestCodexAppServerJson } from "./request-CKYiRqsN.js";
5
+ import { a as formatComputerUseStatus, c as formatThreads, i as formatCodexStatus, l as readString$1, n as formatAccount, o as formatList, p as summarizeCodexAccountUsage, r as formatCodexDisplayText, s as formatModels, t as buildHelp } from "./command-formatters-BRW7_Nu7.js";
6
6
  import { i as readCodexAppServerBinding, o as writeCodexAppServerBinding, t as clearCodexAppServerBinding } from "./session-binding-CMTXuyoz.js";
7
- import { _ as steerCodexConversationTurn, b as readCodexConversationBindingData, d as parseCodexFastModeArg, f as parseCodexPermissionsModeArg, g as setCodexConversationPermissions, h as setCodexConversationModel, l as startCodexConversationThread, m as setCodexConversationFastMode, p as readCodexConversationActiveTurn, r as formatCodexCliSessions, u as formatPermissionsMode, v as stopCodexConversationTurn, x as resolveCodexDefaultWorkspaceDir, y as createCodexCliNodeConversationBindingData } from "./node-cli-sessions-CV5Kmdwt.js";
8
- import { n as installCodexComputerUse, r as readCodexComputerUseStatus } from "./computer-use-DFdLwPQa.js";
9
- import { n as rememberCodexRateLimits } from "./rate-limit-cache-BFi-50LG.js";
7
+ import { _ as steerCodexConversationTurn, b as readCodexConversationBindingData, d as parseCodexFastModeArg, f as parseCodexPermissionsModeArg, g as setCodexConversationPermissions, h as setCodexConversationModel, l as startCodexConversationThread, m as setCodexConversationFastMode, p as readCodexConversationActiveTurn, r as formatCodexCliSessions, u as formatPermissionsMode, v as stopCodexConversationTurn, x as resolveCodexDefaultWorkspaceDir, y as createCodexCliNodeConversationBindingData } from "./node-cli-sessions-xstpFJmx.js";
8
+ import { n as installCodexComputerUse, r as readCodexComputerUseStatus } from "./computer-use-DsJxRRtm.js";
9
+ import { n as rememberCodexRateLimits } from "./rate-limit-cache-dvhq-4pi.js";
10
10
  import crypto from "node:crypto";
11
11
  import { ensureAuthProfileStore, findNormalizedProviderValue, resolveAuthProfileEligibility, resolveAuthProfileOrder, resolveDefaultAgentDir, resolveProfileUnusableUntilForDisplay } from "openclaw/plugin-sdk/agent-runtime";
12
12
  //#region extensions/codex/src/command-account.ts
@@ -1,67 +1,100 @@
1
1
  import { s as resolveCodexAppServerRuntimeOptions } from "./config-0rd3LnKg.js";
2
2
  import { t as isJsonObject } from "./protocol-C9UWI98H.js";
3
3
  import { i as readCodexAppServerBinding } from "./session-binding-CMTXuyoz.js";
4
- import { n as defaultCodexAppServerClientFactory, t as createCodexAppServerClientFactoryTestHooks } from "./client-factory-BB5hgnWH.js";
5
- import { embeddedAgentLog, formatErrorMessage, isActiveHarnessContextEngine, runHarnessContextEngineMaintenance } from "openclaw/plugin-sdk/agent-harness-runtime";
4
+ import { t as defaultCodexAppServerClientFactory } from "./client-factory-Be6RD28K.js";
5
+ import { embeddedAgentLog, formatErrorMessage, isActiveHarnessContextEngine, resolveContextEngineOwnerPluginId, runHarnessContextEngineMaintenance } from "openclaw/plugin-sdk/agent-harness-runtime";
6
6
  //#region extensions/codex/src/app-server/compact.ts
7
7
  const DEFAULT_CODEX_COMPACTION_WAIT_TIMEOUT_MS = 300 * 1e3;
8
- let clientFactory = defaultCodexAppServerClientFactory;
8
+ const warnedIgnoredCompactionOverrides = /* @__PURE__ */ new Set();
9
9
  async function maybeCompactCodexAppServerSession(params, options = {}) {
10
10
  const activeContextEngine = isActiveHarnessContextEngine(params.contextEngine) ? params.contextEngine : void 0;
11
- if (activeContextEngine?.info.ownsCompaction) {
12
- let primary;
13
- let primaryError;
14
- try {
15
- primary = await activeContextEngine.compact({
16
- sessionId: params.sessionId,
17
- sessionKey: params.sessionKey,
18
- sessionFile: params.sessionFile,
19
- tokenBudget: params.contextTokenBudget,
20
- currentTokenCount: params.currentTokenCount,
21
- compactionTarget: params.trigger === "manual" ? "threshold" : "budget",
22
- customInstructions: params.customInstructions,
23
- force: params.trigger === "manual",
24
- runtimeContext: params.contextEngineRuntimeContext
25
- });
26
- } catch (error) {
27
- primaryError = formatErrorMessage(error);
28
- embeddedAgentLog.warn("context engine compaction failed; attempting Codex native compaction", {
29
- sessionId: params.sessionId,
30
- engineId: activeContextEngine.info.id,
31
- error: primaryError
32
- });
33
- }
34
- if (primary?.ok && primary.compacted) try {
35
- await runHarnessContextEngineMaintenance({
36
- contextEngine: activeContextEngine,
37
- sessionId: params.sessionId,
38
- sessionKey: params.sessionKey,
39
- sessionFile: params.sessionFile,
40
- reason: "compaction",
41
- runtimeContext: params.contextEngineRuntimeContext,
42
- config: params.config
43
- });
44
- } catch (error) {
45
- embeddedAgentLog.warn("context engine compaction maintenance failed; continuing Codex native compaction", {
46
- sessionId: params.sessionId,
47
- engineId: activeContextEngine.info.id,
48
- error: formatErrorMessage(error)
49
- });
50
- }
51
- const nativeResult = await compactCodexNativeThread(params, options);
52
- if (!primary) return buildContextEngineCompactionFailureResult({
53
- primaryError,
54
- nativeResult,
55
- currentTokenCount: params.currentTokenCount
11
+ warnIfIgnoringOpenClawCompactionOverrides(params);
12
+ const nativeResult = await compactCodexNativeThread(params, options);
13
+ if (activeContextEngine && nativeResult?.ok && nativeResult.compacted) try {
14
+ await runHarnessContextEngineMaintenance({
15
+ contextEngine: activeContextEngine,
16
+ sessionId: params.sessionId,
17
+ sessionKey: params.sessionKey,
18
+ sessionFile: params.sessionFile,
19
+ reason: "compaction",
20
+ runtimeContext: params.contextEngineRuntimeContext,
21
+ config: params.config
22
+ });
23
+ } catch (error) {
24
+ embeddedAgentLog.warn("context engine compaction maintenance failed after Codex compaction", {
25
+ sessionId: params.sessionId,
26
+ engineId: activeContextEngine.info.id,
27
+ error: formatErrorMessage(error)
56
28
  });
57
- return {
58
- ok: primary.ok,
59
- compacted: primary.compacted,
60
- reason: primary.reason,
61
- result: buildContextEnginePrimaryResult(primary, nativeResult, params.currentTokenCount)
62
- };
63
29
  }
64
- return await compactCodexNativeThread(params, options);
30
+ return nativeResult;
31
+ }
32
+ function warnIfIgnoringOpenClawCompactionOverrides(params) {
33
+ const ignoredConfig = readIgnoredCompactionOverridePaths(params, isActiveHarnessContextEngine(params.contextEngine) ? params.contextEngine : void 0);
34
+ if (ignoredConfig.length === 0) return;
35
+ const warningKey = ignoredConfig.join("\0");
36
+ if (warnedIgnoredCompactionOverrides.has(warningKey)) return;
37
+ warnedIgnoredCompactionOverrides.add(warningKey);
38
+ embeddedAgentLog.warn("ignoring OpenClaw compaction overrides for Codex app-server compaction; Codex uses native server-side compaction", {
39
+ sessionId: params.sessionId,
40
+ sessionKey: params.sessionKey,
41
+ ignoredConfig
42
+ });
43
+ }
44
+ function readIgnoredCompactionOverridePaths(params, activeContextEngine) {
45
+ const ignored = /* @__PURE__ */ new Set();
46
+ const configuredContextEngine = readStringPath(params.config, [
47
+ "plugins",
48
+ "slots",
49
+ "contextEngine"
50
+ ]);
51
+ const runtimeContextEnginePlugin = typeof params.contextEngineRuntimeContext?.contextEnginePluginId === "string" ? params.contextEngineRuntimeContext.contextEnginePluginId.trim() : "";
52
+ const activeContextEnginePlugin = resolveContextEngineOwnerPluginId(activeContextEngine);
53
+ for (const entry of readCompactionOverrideEntries(params)) {
54
+ const localProvider = typeof entry.record.provider === "string" ? entry.record.provider.trim() : "";
55
+ const inheritedProvider = !localProvider && typeof entry.inheritedRecord?.provider === "string" ? entry.inheritedRecord.provider.trim() : "";
56
+ const provider = localProvider || inheritedProvider;
57
+ const providerPath = localProvider ? `${entry.path}.compaction.provider` : inheritedProvider && entry.inheritedPath ? `${entry.inheritedPath}.compaction.provider` : void 0;
58
+ if (provider.toLowerCase() === "lossless-claw" && (activeContextEnginePlugin === "lossless-claw" || runtimeContextEnginePlugin.toLowerCase() === "lossless-claw" || configuredContextEngine?.toLowerCase() === "lossless-claw")) continue;
59
+ if (typeof entry.record.model === "string" && entry.record.model.trim()) ignored.add(`${entry.path}.compaction.model`);
60
+ if (providerPath) ignored.add(providerPath);
61
+ }
62
+ return [...ignored];
63
+ }
64
+ function readCompactionOverrideEntries(params) {
65
+ const entries = [];
66
+ const defaultCompaction = readRecord(readRecord(params.config?.agents)?.defaults)?.compaction;
67
+ const defaultRecord = readRecord(defaultCompaction);
68
+ if (defaultRecord) entries.push({
69
+ path: "agents.defaults",
70
+ record: defaultRecord
71
+ });
72
+ const agentId = readAgentIdFromSessionKey(params.sessionKey ?? params.sandboxSessionKey);
73
+ if (!agentId) return entries;
74
+ const agentCompaction = readRecord((Array.isArray(params.config?.agents?.list) ? params.config.agents.list : []).find((agent) => {
75
+ return (typeof agent?.id === "string" ? agent.id.trim().toLowerCase() : "") === agentId;
76
+ }))?.compaction;
77
+ const agentRecord = readRecord(agentCompaction);
78
+ if (agentRecord) entries.push({
79
+ path: `agents.list.${agentId}`,
80
+ record: agentRecord,
81
+ inheritedRecord: defaultRecord,
82
+ inheritedPath: "agents.defaults"
83
+ });
84
+ return entries;
85
+ }
86
+ function readAgentIdFromSessionKey(sessionKey) {
87
+ const parts = sessionKey?.trim().toLowerCase().split(":").filter(Boolean) ?? [];
88
+ if (parts.length < 3 || parts[0] !== "agent") return;
89
+ return parts[1]?.trim() || void 0;
90
+ }
91
+ function readRecord(value) {
92
+ return value && typeof value === "object" && !Array.isArray(value) ? value : void 0;
93
+ }
94
+ function readStringPath(value, path) {
95
+ let current = value;
96
+ for (const segment of path) current = readRecord(current)?.[segment];
97
+ return typeof current === "string" && current.trim() ? current.trim() : void 0;
65
98
  }
66
99
  async function compactCodexNativeThread(params, options = {}) {
67
100
  const appServer = resolveCodexAppServerRuntimeOptions({ pluginConfig: options.pluginConfig });
@@ -77,7 +110,7 @@ async function compactCodexNativeThread(params, options = {}) {
77
110
  compacted: false,
78
111
  reason: "auth profile mismatch for session binding"
79
112
  };
80
- const client = await clientFactory(appServer.start, requestedAuthProfileId ?? binding.authProfileId, params.agentDir, params.config);
113
+ const client = await (options.clientFactory ?? defaultCodexAppServerClientFactory)(appServer.start, requestedAuthProfileId ?? binding.authProfileId, params.agentDir, params.config);
81
114
  const waiter = createCodexNativeCompactionWaiter(client, binding.threadId);
82
115
  let completion;
83
116
  try {
@@ -112,7 +145,6 @@ async function compactCodexNativeThread(params, options = {}) {
112
145
  tokensBefore: params.currentTokenCount ?? 0,
113
146
  details: {
114
147
  backend: "codex-app-server",
115
- ownsCompaction: params.contextEngine?.info?.ownsCompaction === true,
116
148
  threadId: binding.threadId,
117
149
  signal: completion.signal,
118
150
  turnId: completion.turnId,
@@ -121,60 +153,6 @@ async function compactCodexNativeThread(params, options = {}) {
121
153
  }
122
154
  };
123
155
  }
124
- function mergeCompactionDetails(primaryDetails, nativeResult, contextEngineCompaction) {
125
- const codexNativeCompaction = nativeResult ? nativeResult.ok && nativeResult.compacted ? {
126
- ok: true,
127
- compacted: true,
128
- details: nativeResult.result?.details
129
- } : {
130
- ok: false,
131
- compacted: false,
132
- reason: nativeResult.reason
133
- } : void 0;
134
- const extraDetails = {
135
- ...codexNativeCompaction ? { codexNativeCompaction } : {},
136
- ...contextEngineCompaction ? { contextEngineCompaction } : {}
137
- };
138
- if (primaryDetails && typeof primaryDetails === "object" && !Array.isArray(primaryDetails)) return {
139
- ...primaryDetails,
140
- ...extraDetails
141
- };
142
- return Object.keys(extraDetails).length > 0 ? extraDetails : primaryDetails;
143
- }
144
- function buildContextEnginePrimaryResult(primary, nativeResult, currentTokenCount) {
145
- if (primary.result) return {
146
- summary: primary.result.summary ?? "",
147
- firstKeptEntryId: primary.result.firstKeptEntryId ?? "",
148
- tokensBefore: primary.result.tokensBefore,
149
- tokensAfter: primary.result.tokensAfter,
150
- details: mergeCompactionDetails(primary.result.details, nativeResult)
151
- };
152
- const details = mergeCompactionDetails(void 0, nativeResult);
153
- return details ? {
154
- summary: "",
155
- firstKeptEntryId: "",
156
- tokensBefore: nativeResult?.result?.tokensBefore ?? currentTokenCount ?? 0,
157
- details
158
- } : void 0;
159
- }
160
- function buildContextEngineCompactionFailureResult(params) {
161
- const reason = params.primaryError ? `context engine compaction failed: ${params.primaryError}` : "context engine compaction failed";
162
- return {
163
- ok: false,
164
- compacted: params.nativeResult?.compacted ?? false,
165
- reason,
166
- result: {
167
- summary: params.nativeResult?.result?.summary ?? "",
168
- firstKeptEntryId: params.nativeResult?.result?.firstKeptEntryId ?? "",
169
- tokensBefore: params.nativeResult?.result?.tokensBefore ?? params.currentTokenCount ?? 0,
170
- tokensAfter: params.nativeResult?.result?.tokensAfter,
171
- details: mergeCompactionDetails(params.nativeResult?.result?.details, params.nativeResult, {
172
- ok: false,
173
- reason
174
- })
175
- }
176
- };
177
- }
178
156
  function createCodexNativeCompactionWaiter(client, threadId) {
179
157
  let settled = false;
180
158
  let removeHandler = () => {};
@@ -253,8 +231,5 @@ function formatCompactionError(error) {
253
231
  if (error instanceof Error) return error.message;
254
232
  return String(error);
255
233
  }
256
- createCodexAppServerClientFactoryTestHooks((factory) => {
257
- clientFactory = factory;
258
- });
259
234
  //#endregion
260
235
  export { maybeCompactCodexAppServerSession };
@@ -1,5 +1,5 @@
1
1
  import { c as resolveCodexComputerUseConfig, s as resolveCodexAppServerRuntimeOptions } from "./config-0rd3LnKg.js";
2
- import { r as describeControlFailure, t as requestCodexAppServerJson } from "./request-BxAP1uyw.js";
2
+ import { i as describeControlFailure, t as requestCodexAppServerJson } from "./request-CKYiRqsN.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 {
package/dist/harness.js CHANGED
@@ -18,15 +18,15 @@ function createCodexAppServerAgentHarness(options) {
18
18
  };
19
19
  },
20
20
  runAttempt: async (params) => {
21
- const { runCodexAppServerAttempt } = await import("./run-attempt-CN9AS7qv.js");
21
+ const { runCodexAppServerAttempt } = await import("./run-attempt-frGYsF9Y.js");
22
22
  return runCodexAppServerAttempt(params, { pluginConfig: options?.pluginConfig });
23
23
  },
24
24
  runSideQuestion: async (params) => {
25
- const { runCodexAppServerSideQuestion } = await import("./side-question-BsBqLpar.js");
25
+ const { runCodexAppServerSideQuestion } = await import("./side-question-CDcvaIKA.js");
26
26
  return runCodexAppServerSideQuestion(params, { pluginConfig: options?.pluginConfig });
27
27
  },
28
28
  compact: async (params) => {
29
- const { maybeCompactCodexAppServerSession } = await import("./compact-Ck9ckRkJ.js");
29
+ const { maybeCompactCodexAppServerSession } = await import("./compact-CKWfgifa.js");
30
30
  return maybeCompactCodexAppServerSession(params, { pluginConfig: options?.pluginConfig });
31
31
  },
32
32
  reset: async (params) => {
package/dist/index.js CHANGED
@@ -2,12 +2,11 @@ import { createCodexAppServerAgentHarness } from "./harness.js";
2
2
  import { o as readCodexPluginConfig, s as resolveCodexAppServerRuntimeOptions, t as CODEX_PLUGINS_MARKETPLACE_NAME } from "./config-0rd3LnKg.js";
3
3
  import { buildCodexMediaUnderstandingProvider } from "./media-understanding-provider.js";
4
4
  import { buildCodexProvider } from "./provider.js";
5
- import { r as describeControlFailure, t as requestCodexAppServerJson } from "./request-BxAP1uyw.js";
6
- import { r as formatCodexDisplayText } from "./command-formatters-CJH9-hFT.js";
5
+ import { i as describeControlFailure, n as buildCodexPluginAppCacheKey, t as requestCodexAppServerJson } from "./request-CKYiRqsN.js";
6
+ import { r as formatCodexDisplayText } from "./command-formatters-BRW7_Nu7.js";
7
7
  import { c as resolveCodexAppServerAuthAccountCacheKey, d as resolveCodexAppServerEnvApiKeyCacheKey, i as getSharedCodexAppServerClient, t as clearSharedCodexAppServerClientAndWait, u as resolveCodexAppServerAuthProfileIdForAgent } from "./shared-client-BwUqd3lh.js";
8
- import { a as resolveCodexCliSessionForBindingOnNode, c as handleCodexConversationInboundClaim, i as listCodexCliSessionsOnNode, n as createCodexCliSessionNodeInvokePolicies, o as resumeCodexCliSessionOnNode, s as handleCodexConversationBindingResolved, t as createCodexCliSessionNodeHostCommands } from "./node-cli-sessions-CV5Kmdwt.js";
9
- import { a as defaultCodexAppInventoryCache, n as pluginReadParams, t as ensureCodexPluginActivation } from "./plugin-activation-PXGqUjwY.js";
10
- import { t as buildCodexPluginAppCacheKey } from "./plugin-app-cache-key-DBlqE0gO.js";
8
+ import { a as resolveCodexCliSessionForBindingOnNode, c as handleCodexConversationInboundClaim, i as listCodexCliSessionsOnNode, n as createCodexCliSessionNodeInvokePolicies, o as resumeCodexCliSessionOnNode, s as handleCodexConversationBindingResolved, t as createCodexCliSessionNodeHostCommands } from "./node-cli-sessions-xstpFJmx.js";
9
+ import { a as defaultCodexAppInventoryCache, n as pluginReadParams, t as ensureCodexPluginActivation } from "./plugin-activation-aQOmRQwA.js";
11
10
  import { resolveLivePluginConfigObject } from "openclaw/plugin-sdk/plugin-config-runtime";
12
11
  import { definePluginEntry } from "openclaw/plugin-sdk/plugin-entry";
13
12
  import os from "node:os";
@@ -39,7 +38,7 @@ async function handleCodexCommand(ctx, options = {}) {
39
38
  }
40
39
  }
41
40
  async function loadDefaultCodexSubcommandHandler() {
42
- const { handleCodexSubcommand } = await import("./command-handlers-DIXo49aO.js");
41
+ const { handleCodexSubcommand } = await import("./command-handlers-CbJPJwK_.js");
43
42
  return handleCodexSubcommand;
44
43
  }
45
44
  //#endregion
@@ -725,11 +724,8 @@ async function buildCodexMigrationPlan(ctx) {
725
724
  }));
726
725
  const warnings = [
727
726
  ...items.some((item) => item.status === "conflict") ? ["Conflicts were found. Re-run with --overwrite to replace conflicting migration targets after item-level backups."] : [],
728
- ...source.plugins.some((plugin) => plugin.migratable) ? ["Codex source-installed openai-curated plugins are planned for native activation; cached plugin bundles remain manual-review only."] : [],
729
- ...source.plugins.some((plugin) => plugin.migratable && plugin.apps && plugin.apps.length > 0) && !shouldVerifyPluginApps(ctx) ? ["Codex app-backed plugins were planned without source app accessibility verification. Re-run with --verify-plugin-apps to force a fresh source app/list check before planning native plugin activation."] : [],
730
727
  ...source.pluginDiscoveryError ? [`Codex app-server plugin inventory discovery failed: ${source.pluginDiscoveryError}. Cached plugin bundles, if any, are advisory only.`] : [],
731
- ...source.plugins.some((plugin) => plugin.migrationBlock?.code === "codex_subscription_required") ? [codexPluginMigrationSubscriptionWarning()] : [],
732
- ...source.archivePaths.length > 0 ? ["Codex config and hook files are archive-only. They are preserved in the migration report, not loaded into OpenClaw automatically."] : []
728
+ ...source.plugins.some((plugin) => plugin.migrationBlock?.code === "codex_subscription_required") ? [codexPluginMigrationSubscriptionWarning()] : []
733
729
  ];
734
730
  return {
735
731
  providerId: "codex",
@@ -1,7 +1,7 @@
1
1
  import { i as isCodexFastServiceTier, r as codexSandboxPolicyForTurn, s as resolveCodexAppServerRuntimeOptions } from "./config-0rd3LnKg.js";
2
2
  import { t as isJsonObject } from "./protocol-C9UWI98H.js";
3
- import { n as CODEX_CONTROL_METHODS } from "./request-BxAP1uyw.js";
4
- import { r as formatCodexDisplayText } from "./command-formatters-CJH9-hFT.js";
3
+ import { r as CODEX_CONTROL_METHODS } from "./request-CKYiRqsN.js";
4
+ import { r as formatCodexDisplayText } from "./command-formatters-BRW7_Nu7.js";
5
5
  import { i as getSharedCodexAppServerClient, u as resolveCodexAppServerAuthProfileIdForAgent } from "./shared-client-BwUqd3lh.js";
6
6
  import { i as readCodexAppServerBinding, n as isCodexAppServerNativeAuthProfile, o as writeCodexAppServerBinding, r as normalizeCodexAppServerBindingModelProvider, t as clearCodexAppServerBinding } from "./session-binding-CMTXuyoz.js";
7
7
  import os from "node:os";
@@ -313,8 +313,12 @@ function marketplaceRef(marketplace) {
313
313
  //#region extensions/codex/src/app-server/plugin-activation.ts
314
314
  async function ensureCodexPluginActivation(params) {
315
315
  if (params.identity.marketplaceName !== "openai-curated") return activationFailure(params.identity, "marketplace_missing", { message: "Only " + CODEX_PLUGINS_MARKETPLACE_NAME + " plugins can be activated." });
316
- const resolved = findOpenAiCuratedPluginSummary(await params.request("plugin/list", { cwds: [] }), params.identity.pluginName);
317
- if (!resolved) return activationFailure(params.identity, "plugin_missing", { message: `${params.identity.pluginName} was not found in ${CODEX_PLUGINS_MARKETPLACE_NAME}.` });
316
+ const listed = await params.request("plugin/list", { cwds: [] });
317
+ const resolved = findOpenAiCuratedPluginSummary(listed, params.identity.pluginName);
318
+ if (!resolved) {
319
+ if (!listed.marketplaces.some((marketplace) => marketplace.name === "openai-curated")) return activationFailure(params.identity, "marketplace_missing", { message: `Codex marketplace ${CODEX_PLUGINS_MARKETPLACE_NAME} was not found.` });
320
+ return activationFailure(params.identity, "plugin_missing", { message: `${params.identity.pluginName} was not found in ${CODEX_PLUGINS_MARKETPLACE_NAME}.` });
321
+ }
318
322
  if (resolved.summary.installed && resolved.summary.enabled && !params.installEvenIfActive) return {
319
323
  identity: params.identity,
320
324
  ok: true,
@@ -1,6 +1,27 @@
1
- import { f as resolveCodexAppServerHomeDir } from "./shared-client-BwUqd3lh.js";
2
- import { i as buildCodexAppInventoryCacheKey } from "./plugin-activation-PXGqUjwY.js";
1
+ import { n as CodexAppServerRpcError } from "./client-CoctX13d.js";
2
+ import { f as resolveCodexAppServerHomeDir, i as getSharedCodexAppServerClient, o as withTimeout, r as createIsolatedCodexAppServerClient } from "./shared-client-BwUqd3lh.js";
3
+ import { i as buildCodexAppInventoryCacheKey } from "./plugin-activation-aQOmRQwA.js";
3
4
  import { createHash } from "node:crypto";
5
+ //#region extensions/codex/src/app-server/capabilities.ts
6
+ const CODEX_CONTROL_METHODS = {
7
+ account: "account/read",
8
+ compact: "thread/compact/start",
9
+ feedback: "feedback/upload",
10
+ listMcpServers: "mcpServerStatus/list",
11
+ listSkills: "skills/list",
12
+ listThreads: "thread/list",
13
+ rateLimits: "account/rateLimits/read",
14
+ resumeThread: "thread/resume",
15
+ review: "review/start"
16
+ };
17
+ function describeControlFailure(error) {
18
+ if (isUnsupportedControlError(error)) return "unsupported by this Codex app-server";
19
+ return error instanceof Error ? error.message : String(error);
20
+ }
21
+ function isUnsupportedControlError(error) {
22
+ return error instanceof CodexAppServerRpcError && error.code === -32601;
23
+ }
24
+ //#endregion
4
25
  //#region extensions/codex/src/app-server/plugin-app-cache-key.ts
5
26
  function buildCodexPluginAppCacheKey(params) {
6
27
  return buildCodexAppInventoryCacheKey({
@@ -43,4 +64,26 @@ function fingerprintCodexPluginAppCacheCredentials(startOptions) {
43
64
  return `sha256:${hash.digest("hex")}`;
44
65
  }
45
66
  //#endregion
46
- export { buildCodexPluginAppCacheKey as t };
67
+ //#region extensions/codex/src/app-server/request.ts
68
+ async function requestCodexAppServerJson(params) {
69
+ const timeoutMs = params.timeoutMs ?? 6e4;
70
+ return await withTimeout((async () => {
71
+ const client = await (params.isolated ? createIsolatedCodexAppServerClient : getSharedCodexAppServerClient)({
72
+ startOptions: params.startOptions,
73
+ timeoutMs,
74
+ authProfileId: params.authProfileId,
75
+ agentDir: params.agentDir,
76
+ config: params.config
77
+ });
78
+ try {
79
+ return await client.request(params.method, params.requestParams, { timeoutMs });
80
+ } finally {
81
+ if (params.isolated) await client.closeAndWait({
82
+ exitTimeoutMs: 2e3,
83
+ forceKillDelayMs: 250
84
+ });
85
+ }
86
+ })(), timeoutMs, `codex app-server ${params.method} timed out`);
87
+ }
88
+ //#endregion
89
+ export { describeControlFailure as i, buildCodexPluginAppCacheKey as n, CODEX_CONTROL_METHODS as r, requestCodexAppServerJson as t };
@@ -2,25 +2,23 @@ import { l as resolveCodexPluginsPolicy, o as readCodexPluginConfig, s as resolv
2
2
  import { a as readCodexDynamicToolCallParams, c as readCodexTurn, i as assertCodexTurnStartResponse } from "./protocol-validators-CSY0BFBo.js";
3
3
  import { t as isJsonObject } from "./protocol-C9UWI98H.js";
4
4
  import { i as isCodexAppServerConnectionClosedError, r as isCodexAppServerApprovalRequest } from "./client-CoctX13d.js";
5
- import { n as CODEX_CONTROL_METHODS } from "./request-BxAP1uyw.js";
6
- import { d as resolveCodexUsageLimitResetAtMs, f as shouldRefreshCodexRateLimitsForUsageLimitMessage, r as formatCodexDisplayText, u as formatCodexUsageLimitErrorMessage } from "./command-formatters-CJH9-hFT.js";
5
+ import { n as buildCodexPluginAppCacheKey, r as CODEX_CONTROL_METHODS } from "./request-CKYiRqsN.js";
6
+ import { d as resolveCodexUsageLimitResetAtMs, f as shouldRefreshCodexRateLimitsForUsageLimitMessage, r as formatCodexDisplayText, u as formatCodexUsageLimitErrorMessage } from "./command-formatters-BRW7_Nu7.js";
7
7
  import { c as resolveCodexAppServerAuthAccountCacheKey, d as resolveCodexAppServerEnvApiKeyCacheKey, l as resolveCodexAppServerAuthProfileId, n as clearSharedCodexAppServerClientIfCurrent, s as refreshCodexAppServerAuthTokens, u as resolveCodexAppServerAuthProfileIdForAgent } from "./shared-client-BwUqd3lh.js";
8
8
  import { i as readCodexAppServerBinding, t as clearCodexAppServerBinding } from "./session-binding-CMTXuyoz.js";
9
- import { a as defaultCodexAppInventoryCache } from "./plugin-activation-PXGqUjwY.js";
10
- import { t as buildCodexPluginAppCacheKey } from "./plugin-app-cache-key-DBlqE0gO.js";
11
- import { _ as resolveCodexContextEngineProjectionReserveTokens, b as normalizeCodexDynamicToolName, d as buildCodexPluginThreadConfig, f as buildCodexPluginThreadConfigInputFingerprint, g as resolveCodexContextEngineProjectionMaxChars, h as projectContextEngineAssemblyForCodex, m as shouldBuildCodexPluginThreadConfig, o as buildTurnStartParams, p as mergeCodexThreadConfigs, r as buildDeveloperInstructions, s as codexDynamicToolsFingerprint, t as areCodexDynamicToolFingerprintsCompatible, u as startOrResumeThread, v as createCodexDynamicToolBridge, y as filterCodexDynamicTools } from "./thread-lifecycle-B_oezv_0.js";
12
- import { n as defaultCodexAppServerClientFactory } from "./client-factory-BB5hgnWH.js";
13
- import { n as handleCodexAppServerElicitationRequest, r as handleCodexAppServerApprovalRequest, t as filterToolsForVisionInputs } from "./vision-tools-cbM0WkCZ.js";
14
- import { t as ensureCodexComputerUse } from "./computer-use-DFdLwPQa.js";
15
- import { n as rememberCodexRateLimits, t as readRecentCodexRateLimits } from "./rate-limit-cache-BFi-50LG.js";
9
+ import { a as defaultCodexAppInventoryCache } from "./plugin-activation-aQOmRQwA.js";
10
+ import { _ as resolveCodexContextEngineProjectionReserveTokens, b as normalizeCodexDynamicToolName, d as buildCodexPluginThreadConfig, f as buildCodexPluginThreadConfigInputFingerprint, g as resolveCodexContextEngineProjectionMaxChars, h as projectContextEngineAssemblyForCodex, m as shouldBuildCodexPluginThreadConfig, o as buildTurnStartParams, p as mergeCodexThreadConfigs, r as buildDeveloperInstructions, s as codexDynamicToolsFingerprint, t as areCodexDynamicToolFingerprintsCompatible, u as startOrResumeThread, v as createCodexDynamicToolBridge, y as filterCodexDynamicTools } from "./thread-lifecycle-BzY-GLGu.js";
11
+ import { t as defaultCodexAppServerClientFactory } from "./client-factory-Be6RD28K.js";
12
+ import { n as handleCodexAppServerElicitationRequest, r as handleCodexAppServerApprovalRequest, t as filterToolsForVisionInputs } from "./vision-tools-CyhFwJIY.js";
13
+ import { t as ensureCodexComputerUse } from "./computer-use-DsJxRRtm.js";
14
+ import { n as rememberCodexRateLimits, t as readRecentCodexRateLimits } from "./rate-limit-cache-dvhq-4pi.js";
16
15
  import { createHash } from "node:crypto";
17
16
  import nodeFs from "node:fs";
18
- import { TOOL_PROGRESS_OUTPUT_MAX_CHARS, acquireSessionWriteLock, appendSessionTranscriptMessage, assembleHarnessContextEngine, bootstrapHarnessContextEngine, buildEmbeddedAttemptToolRunContext, buildHarnessContextEngineRuntimeContext, buildHarnessContextEngineRuntimeContextFromUsage, classifyAgentHarnessTerminalOutcome, clearActiveEmbeddedRun, embeddedAgentLog, emitAgentEvent, emitSessionTranscriptUpdate, finalizeHarnessContextEngineTurn, formatErrorMessage, formatToolAggregate, formatToolProgressOutput, inferToolMetaFromArgs, isActiveHarnessContextEngine, isSubagentSessionKey, loadCodexBundleMcpThreadConfig, normalizeAgentRuntimeTools, normalizeUsage, registerNativeHookRelay, resolveAgentHarnessBeforePromptBuildResult, resolveAttemptSpawnWorkspaceDir, resolveBootstrapContextForRun, resolveModelAuthMode, resolveSandboxContext, resolveSessionAgentIds, resolveSessionWriteLockAcquireTimeoutMs, resolveUserPath, runAgentCleanupStep, runAgentHarnessAfterCompactionHook, runAgentHarnessAfterToolCallHook, runAgentHarnessAgentEndHook, runAgentHarnessBeforeCompactionHook, runAgentHarnessBeforeMessageWriteHook, runAgentHarnessLlmInputHook, runAgentHarnessLlmOutputHook, runHarnessContextEngineMaintenance, setActiveEmbeddedRun, supportsModelTools } from "openclaw/plugin-sdk/agent-harness-runtime";
17
+ import { TOOL_PROGRESS_OUTPUT_MAX_CHARS, acquireSessionWriteLock, appendSessionTranscriptMessage, assembleHarnessContextEngine, bootstrapHarnessContextEngine, buildEmbeddedAttemptToolRunContext, buildHarnessContextEngineRuntimeContext, buildHarnessContextEngineRuntimeContextFromUsage, classifyAgentHarnessTerminalOutcome, clearActiveEmbeddedRun, embeddedAgentLog, emitAgentEvent, emitSessionTranscriptUpdate, finalizeHarnessContextEngineTurn, formatErrorMessage, formatToolAggregate, formatToolProgressOutput, inferToolMetaFromArgs, isActiveHarnessContextEngine, isSubagentSessionKey, loadCodexBundleMcpThreadConfig, normalizeAgentRuntimeTools, normalizeUsage, registerNativeHookRelay, resolveAgentHarnessBeforePromptBuildResult, resolveAttemptSpawnWorkspaceDir, resolveBootstrapContextForRun, resolveContextEngineOwnerPluginId, resolveModelAuthMode, resolveSandboxContext, resolveSessionAgentIds, resolveSessionWriteLockAcquireTimeoutMs, resolveUserPath, runAgentCleanupStep, runAgentHarnessAfterCompactionHook, runAgentHarnessAfterToolCallHook, runAgentHarnessAgentEndHook, runAgentHarnessBeforeCompactionHook, runAgentHarnessBeforeMessageWriteHook, runAgentHarnessLlmInputHook, runAgentHarnessLlmOutputHook, runHarnessContextEngineMaintenance, setActiveEmbeddedRun, supportsModelTools } from "openclaw/plugin-sdk/agent-harness-runtime";
19
18
  import fs from "node:fs/promises";
20
19
  import path from "node:path";
21
20
  import { markAuthProfileBlockedUntil, resolveAgentDir as resolveAgentDir$1 } from "openclaw/plugin-sdk/agent-runtime";
22
21
  import { appendRegularFile, pathExists } from "openclaw/plugin-sdk/security-runtime";
23
- import { AsyncLocalStorage } from "node:async_hooks";
24
22
  import { emitTrustedDiagnosticEvent } from "openclaw/plugin-sdk/diagnostic-runtime";
25
23
  import { createRunningTaskRun, finalizeTaskRunByRunId, recordTaskRunProgressByRunId } from "openclaw/plugin-sdk/codex-native-task-runtime";
26
24
  import { buildSessionContext, migrateSessionEntries, parseSessionEntries } from "@earendil-works/pi-coding-agent";
@@ -349,6 +347,41 @@ function inferCodexDynamicToolMeta(call, detailMode) {
349
347
  //#endregion
350
348
  //#region extensions/codex/src/app-server/transcript-mirror.ts
351
349
  const MIRROR_IDENTITY_META_KEY = "mirrorIdentity";
350
+ function normalizeOptionalString(value) {
351
+ const normalized = value?.trim();
352
+ return normalized ? normalized : void 0;
353
+ }
354
+ function buildSenderLabel(params) {
355
+ const label = params.senderName ?? params.senderUsername ?? params.senderE164 ?? params.senderId;
356
+ if (!label) return;
357
+ if (!params.senderId || label.includes(params.senderId)) return label;
358
+ return `${label} (${params.senderId})`;
359
+ }
360
+ function buildCodexUserPromptMessage(params) {
361
+ const senderId = normalizeOptionalString(params.senderId);
362
+ const senderName = normalizeOptionalString(params.senderName);
363
+ const senderUsername = normalizeOptionalString(params.senderUsername);
364
+ const senderE164 = normalizeOptionalString(params.senderE164);
365
+ const senderLabel = buildSenderLabel({
366
+ senderId,
367
+ senderName,
368
+ senderUsername,
369
+ senderE164
370
+ });
371
+ const sourceChannel = normalizeOptionalString(params.inputProvenance?.sourceChannel ?? params.messageChannel ?? params.messageProvider);
372
+ return {
373
+ role: "user",
374
+ content: params.prompt,
375
+ timestamp: Date.now(),
376
+ ...params.inputProvenance ? { provenance: params.inputProvenance } : {},
377
+ ...sourceChannel ? { sourceChannel } : {},
378
+ ...senderId ? { senderId } : {},
379
+ ...senderName ? { senderName } : {},
380
+ ...senderUsername ? { senderUsername } : {},
381
+ ...senderE164 ? { senderE164 } : {},
382
+ ...senderLabel ? { senderLabel } : {}
383
+ };
384
+ }
352
385
  /**
353
386
  * Tag a message with a stable logical identity for mirror dedupe. Callers
354
387
  * should use a value that is invariant for the same logical message across
@@ -598,11 +631,7 @@ var CodexAppServerEventProjector = class {
598
631
  const planText = collectTextValues(this.planTextByItem).join("\n\n");
599
632
  const lastAssistant = assistantTexts.length > 0 ? this.createAssistantMessage(assistantTexts.join("\n\n")) : void 0;
600
633
  const turnId = this.turnId;
601
- const messagesSnapshot = [attachCodexMirrorIdentity({
602
- role: "user",
603
- content: this.params.prompt,
604
- timestamp: Date.now()
605
- }, `${turnId}:prompt`)];
634
+ const messagesSnapshot = [attachCodexMirrorIdentity(buildCodexUserPromptMessage(this.params), `${turnId}:prompt`)];
606
635
  if (reasoningText) messagesSnapshot.push(attachCodexMirrorIdentity(this.createAssistantMirrorMessage("Codex reasoning", reasoningText), `${turnId}:reasoning`));
607
636
  if (planText) messagesSnapshot.push(attachCodexMirrorIdentity(this.createAssistantMirrorMessage("Codex plan", planText), `${turnId}:plan`));
608
637
  messagesSnapshot.push(...this.toolTranscriptMessages);
@@ -1705,7 +1734,7 @@ const CODEX_HOOK_EVENT_BY_NATIVE_EVENT = {
1705
1734
  };
1706
1735
  function buildCodexNativeHookRelayConfig(params) {
1707
1736
  const events = params.events?.length ? params.events : CODEX_NATIVE_HOOK_RELAY_EVENTS;
1708
- const config = { "features.codex_hooks": true };
1737
+ const config = { "features.hooks": true };
1709
1738
  for (const event of events) {
1710
1739
  const codexEvent = CODEX_HOOK_EVENT_BY_NATIVE_EVENT[event];
1711
1740
  config[`hooks.${codexEvent}`] = [{
@@ -1723,7 +1752,7 @@ function buildCodexNativeHookRelayConfig(params) {
1723
1752
  }
1724
1753
  function buildCodexNativeHookRelayDisabledConfig() {
1725
1754
  return {
1726
- "features.codex_hooks": false,
1755
+ "features.hooks": false,
1727
1756
  "hooks.PreToolUse": [],
1728
1757
  "hooks.PostToolUse": [],
1729
1758
  "hooks.PermissionRequest": [],
@@ -2132,12 +2161,7 @@ const CODEX_BOOTSTRAP_CONTEXT_ORDER = new Map([
2132
2161
  ["memory.md", 60],
2133
2162
  ["heartbeat.md", 70]
2134
2163
  ]);
2135
- const testClientFactoryStorage = new AsyncLocalStorage();
2136
- const clientFactory = defaultCodexAppServerClientFactory;
2137
2164
  let openClawCodingToolsFactoryForTests;
2138
- function resolveCodexAppServerClientFactory() {
2139
- return testClientFactoryStorage.getStore() ?? clientFactory;
2140
- }
2141
2165
  function emitCodexAppServerEvent(params, event) {
2142
2166
  try {
2143
2167
  emitAgentEvent({
@@ -2293,7 +2317,7 @@ function restrictCodexAppServerSandboxForOpenClawSandbox(appServer, sandbox) {
2293
2317
  }
2294
2318
  async function runCodexAppServerAttempt(params, options = {}) {
2295
2319
  const attemptStartedAt = Date.now();
2296
- const attemptClientFactory = resolveCodexAppServerClientFactory();
2320
+ const attemptClientFactory = options.clientFactory ?? defaultCodexAppServerClientFactory;
2297
2321
  const pluginConfig = readCodexPluginConfig(options.pluginConfig);
2298
2322
  const configuredAppServer = resolveCodexAppServerRuntimeOptions({ pluginConfig });
2299
2323
  const resolvedWorkspace = resolveUserPath(params.workspaceDir);
@@ -2384,6 +2408,11 @@ async function runCodexAppServerAttempt(params, options = {}) {
2384
2408
  });
2385
2409
  const hadSessionFile = await pathExists(params.sessionFile);
2386
2410
  let historyMessages = await readMirroredSessionHistoryMessages(params.sessionFile) ?? [];
2411
+ const hookContextWindowFields = {
2412
+ ...params.contextWindowInfo?.tokens ? { contextTokenBudget: params.contextWindowInfo.tokens } : params.contextTokenBudget ? { contextTokenBudget: params.contextTokenBudget } : {},
2413
+ ...params.contextWindowInfo?.source ? { contextWindowSource: params.contextWindowInfo.source } : {},
2414
+ ...params.contextWindowInfo?.referenceTokens ? { contextWindowReferenceTokens: params.contextWindowInfo.referenceTokens } : {}
2415
+ };
2387
2416
  const hookContext = {
2388
2417
  runId: params.runId,
2389
2418
  agentId: sessionAgentId,
@@ -2392,9 +2421,11 @@ async function runCodexAppServerAttempt(params, options = {}) {
2392
2421
  workspaceDir: params.workspaceDir,
2393
2422
  messageProvider: params.messageProvider ?? void 0,
2394
2423
  trigger: params.trigger,
2395
- channelId: params.messageChannel ?? params.messageProvider ?? void 0
2424
+ channelId: params.messageChannel ?? params.messageProvider ?? void 0,
2425
+ ...hookContextWindowFields
2396
2426
  };
2397
2427
  if (activeContextEngine) {
2428
+ const activeContextEnginePluginId = resolveContextEngineOwnerPluginId(activeContextEngine);
2398
2429
  await bootstrapHarnessContextEngine({
2399
2430
  hadSessionFile,
2400
2431
  contextEngine: activeContextEngine,
@@ -2405,6 +2436,8 @@ async function runCodexAppServerAttempt(params, options = {}) {
2405
2436
  attempt: runtimeParams,
2406
2437
  workspaceDir: effectiveWorkspace,
2407
2438
  agentDir,
2439
+ activeAgentId: sessionAgentId,
2440
+ contextEnginePluginId: activeContextEnginePluginId,
2408
2441
  tokenBudget: params.contextTokenBudget
2409
2442
  }),
2410
2443
  runMaintenance: runHarnessContextEngineMaintenance,
@@ -2558,6 +2591,7 @@ async function runCodexAppServerAttempt(params, options = {}) {
2558
2591
  const threadLifecycleParams = {
2559
2592
  client: startupClient,
2560
2593
  params: runtimeParams,
2594
+ agentId: sessionAgentId,
2561
2595
  cwd: effectiveWorkspace,
2562
2596
  dynamicTools: toolBridge.specs,
2563
2597
  appServer: pluginAppServer,
@@ -2917,6 +2951,8 @@ async function runCodexAppServerAttempt(params, options = {}) {
2917
2951
  }
2918
2952
  if (isCurrentTurnNotification) updateActiveTurnItemIds(notification, activeTurnItemIds);
2919
2953
  const unblockedAssistantCompletionRelease = isCurrentTurnNotification && turnAssistantCompletionIdleWatchArmed && notification.method === "item/completed" && activeTurnItemIds.size === 0;
2954
+ const trackedDynamicToolCompletion = isTrackedOpenClawDynamicToolCompletionNotification(notification, activeOpenClawDynamicToolCallIds);
2955
+ const shouldRearmCompletionIdleWatchAfterLastCurrentTurnItem = isCurrentTurnNotification && notification.method === "item/completed" && activeTurnItemIds.size === 0 && !trackedDynamicToolCompletion && !isCompletedAssistantNotification(notification);
2920
2956
  if (isCurrentTurnNotification && notification.method === "error") {
2921
2957
  if (isRetryableErrorNotification(notification.params)) disarmTurnCompletionIdleWatch();
2922
2958
  else armTurnCompletionIdleWatch({ pinnedByTerminalError: true });
@@ -2924,8 +2960,9 @@ async function runCodexAppServerAttempt(params, options = {}) {
2924
2960
  } else if (isTurnCompletion) disarmTurnAssistantCompletionIdleWatch();
2925
2961
  else if (isCurrentTurnNotification && isCompletedAssistantNotification(notification)) armTurnAssistantCompletionIdleWatch(describeNotificationActivity(notification));
2926
2962
  else if (unblockedAssistantCompletionRelease) armTurnAssistantCompletionIdleWatch(describeNotificationActivity(notification));
2963
+ else if (shouldRearmCompletionIdleWatchAfterLastCurrentTurnItem) armTurnCompletionIdleWatch();
2927
2964
  else if (isCurrentTurnNotification && shouldDisarmAssistantCompletionIdleWatch(notification)) disarmTurnAssistantCompletionIdleWatch();
2928
- if (turnCompletionIdleWatchArmed && !turnCompletionIdleWatchPinnedByTerminalError && notification.method !== "turn/completed" && isCurrentTurnNotification && !isTrackedOpenClawDynamicToolCompletionNotification(notification, activeOpenClawDynamicToolCallIds)) disarmTurnCompletionIdleWatch();
2965
+ if (turnCompletionIdleWatchArmed && !turnCompletionIdleWatchPinnedByTerminalError && notification.method !== "turn/completed" && isCurrentTurnNotification && !trackedDynamicToolCompletion && !shouldRearmCompletionIdleWatchAfterLastCurrentTurnItem) disarmTurnCompletionIdleWatch();
2929
2966
  const isTurnAbortMarker = isCurrentTurnNotification && isCodexTurnAbortMarkerNotification(notification, { currentPromptText: promptBuild.prompt });
2930
2967
  const isTurnTerminal = isTurnCompletion || isTurnAbortMarker;
2931
2968
  try {
@@ -3090,11 +3127,10 @@ async function runCodexAppServerAttempt(params, options = {}) {
3090
3127
  historyMessages,
3091
3128
  imagesCount: params.images?.length ?? 0
3092
3129
  };
3093
- const turnStartFailureMessages = [...historyMessages, {
3094
- role: "user",
3095
- content: promptBuild.prompt,
3096
- timestamp: Date.now()
3097
- }];
3130
+ const turnStartFailureMessages = [...historyMessages, buildCodexUserPromptMessage({
3131
+ ...params,
3132
+ prompt: promptBuild.prompt
3133
+ })];
3098
3134
  let turn;
3099
3135
  const startCodexTurn = async () => assertCodexTurnStartResponse(await client.request("turn/start", buildTurnStartParams(params, {
3100
3136
  threadId: thread.threadId,
@@ -3174,6 +3210,7 @@ async function runCodexAppServerAttempt(params, options = {}) {
3174
3210
  sessionId: params.sessionId,
3175
3211
  provider: params.provider,
3176
3212
  model: params.modelId,
3213
+ ...hookContextWindowFields,
3177
3214
  resolvedRef: params.runtimePlan?.observability.resolvedRef ?? `${params.provider}/${params.modelId}`,
3178
3215
  ...params.runtimePlan?.observability.harnessId ? { harnessId: params.runtimePlan.observability.harnessId } : {},
3179
3216
  assistantTexts: []
@@ -3237,6 +3274,8 @@ async function runCodexAppServerAttempt(params, options = {}) {
3237
3274
  projector = new CodexAppServerEventProjector(params, thread.threadId, activeTurnId, { nativePostToolUseRelayEnabled: nativeHookRelay?.allowedEvents.includes("post_tool_use") === true });
3238
3275
  emitLifecycleStart();
3239
3276
  const activeProjector = projector;
3277
+ turnTerminalIdleWatchArmed = true;
3278
+ touchTurnCompletionActivity("turn:start", { arm: true });
3240
3279
  for (const notification of pendingNotifications.splice(0)) await enqueueNotification(notification);
3241
3280
  if (!completed && isTerminalTurnStatus(turn.turn.status)) await enqueueNotification({
3242
3281
  method: "turn/completed",
@@ -3263,8 +3302,6 @@ async function runCodexAppServerAttempt(params, options = {}) {
3263
3302
  abort: () => runAbortController.abort("aborted")
3264
3303
  };
3265
3304
  setActiveEmbeddedRun(params.sessionId, handle, params.sessionKey);
3266
- turnTerminalIdleWatchArmed = true;
3267
- touchTurnCompletionActivity("turn:start");
3268
3305
  const timeout = setTimeout(() => {
3269
3306
  timedOut = true;
3270
3307
  projector?.markTimedOut();
@@ -3342,6 +3379,7 @@ async function runCodexAppServerAttempt(params, options = {}) {
3342
3379
  ...finalAborted ? { aborted: true } : {}
3343
3380
  });
3344
3381
  if (activeContextEngine) {
3382
+ const activeContextEnginePluginId = resolveContextEngineOwnerPluginId(activeContextEngine);
3345
3383
  const finalMessages = await readMirroredSessionHistoryMessages(params.sessionFile) ?? historyMessages.concat(result.messagesSnapshot);
3346
3384
  await finalizeHarnessContextEngineTurn({
3347
3385
  contextEngine: activeContextEngine,
@@ -3358,6 +3396,8 @@ async function runCodexAppServerAttempt(params, options = {}) {
3358
3396
  attempt: runtimeParams,
3359
3397
  workspaceDir: effectiveWorkspace,
3360
3398
  agentDir,
3399
+ activeAgentId: sessionAgentId,
3400
+ contextEnginePluginId: activeContextEnginePluginId,
3361
3401
  tokenBudget: params.contextTokenBudget,
3362
3402
  lastCallUsage: result.attemptUsage,
3363
3403
  promptCache: result.promptCache
@@ -3373,6 +3413,7 @@ async function runCodexAppServerAttempt(params, options = {}) {
3373
3413
  sessionId: params.sessionId,
3374
3414
  provider: params.provider,
3375
3415
  model: params.modelId,
3416
+ ...hookContextWindowFields,
3376
3417
  resolvedRef: params.runtimePlan?.observability.resolvedRef ?? `${params.provider}/${params.modelId}`,
3377
3418
  ...params.runtimePlan?.observability.harnessId ? { harnessId: params.runtimePlan.observability.harnessId } : {},
3378
3419
  assistantTexts: result.assistantTexts,
@@ -3649,14 +3690,12 @@ function resolveOpenClawCodingToolsSessionKeys(params, sandboxSessionKey) {
3649
3690
  runSessionKey: params.sessionKey && params.sessionKey !== sandboxSessionKey ? params.sessionKey : void 0
3650
3691
  };
3651
3692
  }
3652
- async function buildDynamicTools(input) {
3693
+ function buildOpenClawCodingToolsOptions(input) {
3653
3694
  const { params } = input;
3654
- if (params.disableTools || !supportsModelTools(params.model)) return [];
3655
3695
  const modelHasVision = params.model.input?.includes("image") ?? false;
3656
3696
  const agentDir = params.agentDir ?? resolveAgentDir$1(params.config ?? {}, input.sessionAgentId);
3657
- const createOpenClawCodingTools = openClawCodingToolsFactoryForTests ?? (await import("openclaw/plugin-sdk/agent-harness")).createOpenClawCodingTools;
3658
3697
  const sessionKeys = resolveOpenClawCodingToolsSessionKeys(params, input.sandboxSessionKey);
3659
- const filteredTools = filterCodexDynamicToolsForAllowlist(filterToolsForVisionInputs(filterCodexDynamicTools(createOpenClawCodingTools({
3698
+ return {
3660
3699
  agentId: input.sessionAgentId,
3661
3700
  ...buildEmbeddedAttemptToolRunContext(params),
3662
3701
  exec: {
@@ -3720,10 +3759,17 @@ async function buildDynamicTools(input) {
3720
3759
  });
3721
3760
  input.runAbortController.abort("sessions_yield");
3722
3761
  }
3723
- }), input.pluginConfig), {
3724
- modelHasVision,
3762
+ };
3763
+ }
3764
+ async function buildDynamicTools(input) {
3765
+ const { params } = input;
3766
+ if (params.disableTools || !supportsModelTools(params.model)) return [];
3767
+ const createOpenClawCodingTools = openClawCodingToolsFactoryForTests ?? (await import("openclaw/plugin-sdk/agent-harness")).createOpenClawCodingTools;
3768
+ const toolOptions = buildOpenClawCodingToolsOptions(input);
3769
+ const filteredTools = filterCodexDynamicToolsForAllowlist(filterToolsForVisionInputs(filterCodexDynamicTools(createOpenClawCodingTools(toolOptions), input.pluginConfig), {
3770
+ modelHasVision: toolOptions.modelHasVision ?? false,
3725
3771
  hasInboundImages: (params.images?.length ?? 0) > 0
3726
- }), params.toolsAllow);
3772
+ }), includeForcedMessageToolAllow(params.toolsAllow, params));
3727
3773
  return normalizeAgentRuntimeTools({
3728
3774
  runtimePlan: params.runtimePlan,
3729
3775
  tools: filteredTools,
@@ -3736,6 +3782,12 @@ async function buildDynamicTools(input) {
3736
3782
  model: params.model
3737
3783
  });
3738
3784
  }
3785
+ function includeForcedMessageToolAllow(toolsAllow, params) {
3786
+ if (!shouldForceMessageTool(params)) return toolsAllow;
3787
+ if (toolsAllow === void 0) return toolsAllow;
3788
+ if (toolsAllow.length === 0) return ["message"];
3789
+ return new Set(toolsAllow.map((name) => normalizeCodexDynamicToolName(name))).has("message") ? toolsAllow : [...toolsAllow, "message"];
3790
+ }
3739
3791
  function filterCodexDynamicToolsForAllowlist(tools, toolsAllow) {
3740
3792
  if (!toolsAllow || toolsAllow.length === 0) return tools;
3741
3793
  const allowSet = new Set(toolsAllow.map((name) => normalizeCodexDynamicToolName(name)).filter(Boolean));
@@ -2,12 +2,12 @@ import { o as readCodexPluginConfig, s as resolveCodexAppServerRuntimeOptions }
2
2
  import { a as readCodexDynamicToolCallParams, i as assertCodexTurnStartResponse, l as readCodexTurnCompletedNotification, t as assertCodexThreadForkResponse } from "./protocol-validators-CSY0BFBo.js";
3
3
  import { t as isJsonObject } from "./protocol-C9UWI98H.js";
4
4
  import { r as isCodexAppServerApprovalRequest } from "./client-CoctX13d.js";
5
- import { u as formatCodexUsageLimitErrorMessage } from "./command-formatters-CJH9-hFT.js";
5
+ import { u as formatCodexUsageLimitErrorMessage } from "./command-formatters-BRW7_Nu7.js";
6
6
  import { i as getSharedCodexAppServerClient, s as refreshCodexAppServerAuthTokens } from "./shared-client-BwUqd3lh.js";
7
7
  import { i as readCodexAppServerBinding } from "./session-binding-CMTXuyoz.js";
8
- import { c as resolveCodexAppServerModelProvider, l as resolveReasoningEffort, n as buildCodexRuntimeThreadConfig, v as createCodexDynamicToolBridge, y as filterCodexDynamicTools } from "./thread-lifecycle-B_oezv_0.js";
9
- import { n as handleCodexAppServerElicitationRequest, r as handleCodexAppServerApprovalRequest, t as filterToolsForVisionInputs } from "./vision-tools-cbM0WkCZ.js";
10
- import { n as rememberCodexRateLimits, t as readRecentCodexRateLimits } from "./rate-limit-cache-BFi-50LG.js";
8
+ import { c as resolveCodexAppServerModelProvider, l as resolveReasoningEffort, n as buildCodexRuntimeThreadConfig, v as createCodexDynamicToolBridge, y as filterCodexDynamicTools } from "./thread-lifecycle-BzY-GLGu.js";
9
+ import { n as handleCodexAppServerElicitationRequest, r as handleCodexAppServerApprovalRequest, t as filterToolsForVisionInputs } from "./vision-tools-CyhFwJIY.js";
10
+ import { n as rememberCodexRateLimits, t as readRecentCodexRateLimits } from "./rate-limit-cache-dvhq-4pi.js";
11
11
  import { embeddedAgentLog, formatErrorMessage, resolveAgentDir, resolveAttemptSpawnWorkspaceDir, resolveModelAuthMode, resolveSandboxContext, resolveSessionAgentIds, supportsModelTools } from "openclaw/plugin-sdk/agent-harness-runtime";
12
12
  //#region extensions/codex/src/app-server/side-question.ts
13
13
  const CODEX_SIDE_DYNAMIC_TOOL_TIMEOUT_MS = 3e4;
package/dist/test-api.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { s as resolveCodexAppServerRuntimeOptions } from "./config-0rd3LnKg.js";
2
- import { a as buildThreadStartParams, i as buildThreadResumeParams, o as buildTurnStartParams, r as buildDeveloperInstructions, v as createCodexDynamicToolBridge, y as filterCodexDynamicTools } from "./thread-lifecycle-B_oezv_0.js";
2
+ import { a as buildThreadStartParams, i as buildThreadResumeParams, o as buildTurnStartParams, r as buildDeveloperInstructions, v as createCodexDynamicToolBridge, y as filterCodexDynamicTools } from "./thread-lifecycle-BzY-GLGu.js";
3
3
  //#region extensions/codex/test-api.ts
4
4
  function resolveCodexPromptSnapshotAppServerOptions(pluginConfig) {
5
5
  return resolveCodexAppServerRuntimeOptions({
@@ -5,7 +5,7 @@ import { CODEX_GPT5_HEARTBEAT_PROMPT_OVERLAY, renderCodexPromptOverlay } from ".
5
5
  import { isModernCodexModel } from "./provider.js";
6
6
  import { i as isCodexAppServerConnectionClosedError } from "./client-CoctX13d.js";
7
7
  import { i as readCodexAppServerBinding, n as isCodexAppServerNativeAuthProfile, o as writeCodexAppServerBinding, t as clearCodexAppServerBinding } from "./session-binding-CMTXuyoz.js";
8
- import { a as defaultCodexAppInventoryCache, r as readCodexPluginInventory, t as ensureCodexPluginActivation } from "./plugin-activation-PXGqUjwY.js";
8
+ import { a as defaultCodexAppInventoryCache, r as readCodexPluginInventory, t as ensureCodexPluginActivation } from "./plugin-activation-aQOmRQwA.js";
9
9
  import crypto from "node:crypto";
10
10
  import { HEARTBEAT_RESPONSE_TOOL_NAME, createAgentToolResultMiddlewareRunner, createCodexAppServerToolResultExtensionRunner, embeddedAgentLog, extractToolResultMediaArtifact, filterToolResultMediaUrls, isActiveHarnessContextEngine, isMessagingTool, isMessagingToolSendAction, isToolWrappedWithBeforeToolCallHook, normalizeHeartbeatToolResponse, runAgentHarnessAfterToolCallHook, wrapToolWithBeforeToolCallHook } from "openclaw/plugin-sdk/agent-harness-runtime";
11
11
  import { buildCodexUserMcpServersThreadConfigPatch } from "openclaw/plugin-sdk/codex-mcp-projection";
@@ -17,7 +17,11 @@ const CODEX_APP_SERVER_OWNED_DYNAMIC_TOOL_EXCLUDES = [
17
17
  "apply_patch",
18
18
  "exec",
19
19
  "process",
20
- "update_plan"
20
+ "update_plan",
21
+ "tool_search_code",
22
+ "tool_search",
23
+ "tool_describe",
24
+ "tool_call"
21
25
  ];
22
26
  const DYNAMIC_TOOL_NAME_ALIASES = {
23
27
  bash: "exec",
@@ -297,14 +301,33 @@ function readFirstString(record, keys) {
297
301
  }
298
302
  function collectMediaUrls(record) {
299
303
  const urls = [];
304
+ const pushMediaUrl = (value) => {
305
+ if (typeof value === "string" && value.trim()) urls.push(value.trim());
306
+ };
307
+ const pushAttachment = (value) => {
308
+ if (!value || typeof value !== "object" || Array.isArray(value)) return;
309
+ const attachment = value;
310
+ for (const key of [
311
+ "media",
312
+ "mediaUrl",
313
+ "path",
314
+ "filePath",
315
+ "fileUrl",
316
+ "url"
317
+ ]) pushMediaUrl(attachment[key]);
318
+ };
300
319
  for (const key of [
320
+ "media",
301
321
  "mediaUrl",
302
322
  "media_url",
323
+ "path",
324
+ "filePath",
325
+ "fileUrl",
303
326
  "imageUrl",
304
327
  "image_url"
305
328
  ]) {
306
329
  const value = record[key];
307
- if (typeof value === "string" && value.trim()) urls.push(value.trim());
330
+ pushMediaUrl(value);
308
331
  }
309
332
  for (const key of [
310
333
  "mediaUrls",
@@ -314,8 +337,10 @@ function collectMediaUrls(record) {
314
337
  ]) {
315
338
  const value = record[key];
316
339
  if (!Array.isArray(value)) continue;
317
- for (const entry of value) if (typeof entry === "string" && entry.trim()) urls.push(entry.trim());
340
+ for (const entry of value) pushMediaUrl(entry);
318
341
  }
342
+ const attachments = record.attachments;
343
+ if (Array.isArray(attachments)) for (const attachment of attachments) pushAttachment(attachment);
319
344
  return urls;
320
345
  }
321
346
  function isCronAddAction(args) {
@@ -680,10 +705,11 @@ const CODEX_CODE_MODE_THREAD_CONFIG = {
680
705
  "features.code_mode": true,
681
706
  "features.code_mode_only": true
682
707
  };
708
+ const CODEX_LIGHTWEIGHT_CONTEXT_THREAD_CONFIG = { project_doc_max_bytes: 0 };
683
709
  async function startOrResumeThread(params) {
684
710
  const dynamicToolsFingerprint = fingerprintDynamicTools(params.dynamicTools);
685
711
  const contextEngineBinding = buildContextEngineBinding(params.params);
686
- const userMcpServersConfigPatch = buildCodexUserMcpServersThreadConfigPatch(params.params.config);
712
+ const userMcpServersConfigPatch = buildCodexUserMcpServersThreadConfigPatch(params.params.config, { agentId: params.agentId ?? params.params.agentId });
687
713
  const userMcpServersFingerprint = fingerprintUserMcpServersConfigPatch(userMcpServersConfigPatch);
688
714
  let binding = await readCodexAppServerBinding(params.params.sessionFile, {
689
715
  authProfileStore: params.params.authProfileStore,
@@ -939,7 +965,7 @@ function buildThreadStartParams(params, options) {
939
965
  sandbox: options.appServer.sandbox,
940
966
  ...options.appServer.serviceTier ? { serviceTier: options.appServer.serviceTier } : {},
941
967
  serviceName: "OpenClaw",
942
- config: buildCodexRuntimeThreadConfig(options.config),
968
+ config: buildCodexRuntimeThreadConfigForRun(params, options.config),
943
969
  developerInstructions: options.developerInstructions ?? buildDeveloperInstructions(params),
944
970
  dynamicTools: options.dynamicTools,
945
971
  experimentalRawEvents: true,
@@ -962,7 +988,7 @@ function buildThreadResumeParams(params, options) {
962
988
  approvalsReviewer: options.appServer.approvalsReviewer,
963
989
  sandbox: options.appServer.sandbox,
964
990
  ...options.appServer.serviceTier ? { serviceTier: options.appServer.serviceTier } : {},
965
- config: buildCodexRuntimeThreadConfig(options.config),
991
+ config: buildCodexRuntimeThreadConfigForRun(params, options.config),
966
992
  developerInstructions: options.developerInstructions ?? buildDeveloperInstructions(params),
967
993
  persistExtendedHistory: true
968
994
  };
@@ -970,6 +996,14 @@ function buildThreadResumeParams(params, options) {
970
996
  function buildCodexRuntimeThreadConfig(config) {
971
997
  return mergeCodexThreadConfigs(config, CODEX_CODE_MODE_THREAD_CONFIG) ?? { ...CODEX_CODE_MODE_THREAD_CONFIG };
972
998
  }
999
+ function buildCodexRuntimeThreadConfigForRun(params, config) {
1000
+ const runtimeConfig = buildCodexRuntimeThreadConfig(config);
1001
+ if (params.bootstrapContextMode !== "lightweight") return runtimeConfig;
1002
+ return mergeCodexThreadConfigs(runtimeConfig, CODEX_LIGHTWEIGHT_CONTEXT_THREAD_CONFIG) ?? {
1003
+ ...runtimeConfig,
1004
+ ...CODEX_LIGHTWEIGHT_CONTEXT_THREAD_CONFIG
1005
+ };
1006
+ }
973
1007
  function buildTurnStartParams(params, options) {
974
1008
  return {
975
1009
  threadId: options.threadId,
@@ -1,5 +1,5 @@
1
1
  import { t as isJsonObject } from "./protocol-C9UWI98H.js";
2
- import { r as formatCodexDisplayText } from "./command-formatters-CJH9-hFT.js";
2
+ import { r as formatCodexDisplayText } from "./command-formatters-BRW7_Nu7.js";
3
3
  import { callGatewayTool, embeddedAgentLog, formatApprovalDisplayPath } from "openclaw/plugin-sdk/agent-harness-runtime";
4
4
  //#region extensions/codex/src/app-server/plugin-approval-roundtrip.ts
5
5
  const DEFAULT_CODEX_APPROVAL_TIMEOUT_MS = 12e4;
@@ -333,7 +333,7 @@
333
333
  },
334
334
  "appServer.turnCompletionIdleTimeoutMs": {
335
335
  "label": "Turn Completion Idle Timeout",
336
- "help": "Maximum quiet time after a turn-scoped Codex app-server request before OpenClaw interrupts the turn while waiting for turn/completed.",
336
+ "help": "Maximum quiet time after Codex accepts a turn or after a turn-scoped app-server request before OpenClaw interrupts the turn while waiting for turn/completed.",
337
337
  "advanced": true
338
338
  },
339
339
  "appServer.approvalPolicy": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openclaw/codex",
3
- "version": "2026.5.14-beta.1",
3
+ "version": "2026.5.16-beta.1",
4
4
  "description": "OpenClaw Codex harness and model provider plugin",
5
5
  "repository": {
6
6
  "type": "git",
@@ -11,7 +11,7 @@
11
11
  "@earendil-works/pi-coding-agent": "0.74.0",
12
12
  "@openai/codex": "0.130.0",
13
13
  "ajv": "8.20.0",
14
- "ws": "8.20.0",
14
+ "ws": "8.20.1",
15
15
  "zod": "4.4.3"
16
16
  },
17
17
  "devDependencies": {
@@ -27,10 +27,10 @@
27
27
  "minHostVersion": ">=2026.5.1-beta.1"
28
28
  },
29
29
  "compat": {
30
- "pluginApi": ">=2026.5.14-beta.1"
30
+ "pluginApi": ">=2026.5.16-beta.1"
31
31
  },
32
32
  "build": {
33
- "openclawVersion": "2026.5.14-beta.1"
33
+ "openclawVersion": "2026.5.16-beta.1"
34
34
  },
35
35
  "release": {
36
36
  "publishToClawHub": true,
@@ -45,7 +45,7 @@
45
45
  "openclaw.plugin.json"
46
46
  ],
47
47
  "peerDependencies": {
48
- "openclaw": ">=2026.5.14-beta.1"
48
+ "openclaw": ">=2026.5.16-beta.1"
49
49
  },
50
50
  "peerDependenciesMeta": {
51
51
  "openclaw": {
@@ -1,19 +0,0 @@
1
- //#region extensions/codex/src/app-server/client-factory.ts
2
- const defaultCodexAppServerClientFactory = (startOptions, authProfileId, agentDir, config) => import("./shared-client-BwUqd3lh.js").then((n) => n.a).then(({ getSharedCodexAppServerClient }) => getSharedCodexAppServerClient({
3
- startOptions,
4
- authProfileId,
5
- agentDir,
6
- config
7
- }));
8
- function createCodexAppServerClientFactoryTestHooks(setFactory) {
9
- return {
10
- setCodexAppServerClientFactoryForTests(factory) {
11
- setFactory(factory);
12
- },
13
- resetCodexAppServerClientFactoryForTests() {
14
- setFactory(defaultCodexAppServerClientFactory);
15
- }
16
- };
17
- }
18
- //#endregion
19
- export { defaultCodexAppServerClientFactory as n, createCodexAppServerClientFactoryTestHooks as t };
@@ -1,45 +0,0 @@
1
- import { n as CodexAppServerRpcError } from "./client-CoctX13d.js";
2
- import { i as getSharedCodexAppServerClient, o as withTimeout, r as createIsolatedCodexAppServerClient } from "./shared-client-BwUqd3lh.js";
3
- //#region extensions/codex/src/app-server/capabilities.ts
4
- const CODEX_CONTROL_METHODS = {
5
- account: "account/read",
6
- compact: "thread/compact/start",
7
- feedback: "feedback/upload",
8
- listMcpServers: "mcpServerStatus/list",
9
- listSkills: "skills/list",
10
- listThreads: "thread/list",
11
- rateLimits: "account/rateLimits/read",
12
- resumeThread: "thread/resume",
13
- review: "review/start"
14
- };
15
- function describeControlFailure(error) {
16
- if (isUnsupportedControlError(error)) return "unsupported by this Codex app-server";
17
- return error instanceof Error ? error.message : String(error);
18
- }
19
- function isUnsupportedControlError(error) {
20
- return error instanceof CodexAppServerRpcError && error.code === -32601;
21
- }
22
- //#endregion
23
- //#region extensions/codex/src/app-server/request.ts
24
- async function requestCodexAppServerJson(params) {
25
- const timeoutMs = params.timeoutMs ?? 6e4;
26
- return await withTimeout((async () => {
27
- const client = await (params.isolated ? createIsolatedCodexAppServerClient : getSharedCodexAppServerClient)({
28
- startOptions: params.startOptions,
29
- timeoutMs,
30
- authProfileId: params.authProfileId,
31
- agentDir: params.agentDir,
32
- config: params.config
33
- });
34
- try {
35
- return await client.request(params.method, params.requestParams, { timeoutMs });
36
- } finally {
37
- if (params.isolated) await client.closeAndWait({
38
- exitTimeoutMs: 2e3,
39
- forceKillDelayMs: 250
40
- });
41
- }
42
- })(), timeoutMs, `codex app-server ${params.method} timed out`);
43
- }
44
- //#endregion
45
- export { CODEX_CONTROL_METHODS as n, describeControlFailure as r, requestCodexAppServerJson as t };