@openclaw/codex 2026.5.26-beta.1 → 2026.5.26-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,15 @@
1
+ //#region extensions/codex/src/app-server/client-factory.ts
2
+ const defaultCodexAppServerClientFactory = (startOptions, authProfileId, agentDir, config) => import("./shared-client-8kIrP817.js").then((n) => n.s).then(({ getSharedCodexAppServerClient }) => getSharedCodexAppServerClient({
3
+ startOptions,
4
+ authProfileId,
5
+ agentDir,
6
+ config
7
+ }));
8
+ const defaultLeasedCodexAppServerClientFactory = (startOptions, authProfileId, agentDir, config) => import("./shared-client-8kIrP817.js").then((n) => n.s).then(({ getLeasedSharedCodexAppServerClient }) => getLeasedSharedCodexAppServerClient({
9
+ startOptions,
10
+ authProfileId,
11
+ agentDir,
12
+ config
13
+ }));
14
+ //#endregion
15
+ export { defaultLeasedCodexAppServerClientFactory as n, defaultCodexAppServerClientFactory as t };
@@ -1,12 +1,12 @@
1
1
  import { a as isCodexFastServiceTier, l as resolveCodexAppServerRuntimeOptions } from "./config-0-UN67Qg.js";
2
- import { n as listCodexAppServerModels, t as listAllCodexAppServerModels } from "./models-ASKu9eOY.js";
2
+ import { n as listCodexAppServerModels, t as listAllCodexAppServerModels } from "./models-_XwpqjR8.js";
3
3
  import { l as isJsonObject } from "./client-BVK_jmHW.js";
4
4
  import { i as readCodexAppServerBinding, o as writeCodexAppServerBinding, t as clearCodexAppServerBinding } from "./session-binding-UFjjws4k.js";
5
- import { i as describeControlFailure, r as CODEX_CONTROL_METHODS, t as requestCodexAppServerJson } from "./request-DmBkYLPy.js";
5
+ import { i as describeControlFailure, r as CODEX_CONTROL_METHODS, t as requestCodexAppServerJson } from "./request-OaxhR46w.js";
6
6
  import { _ as summarizeCodexAccountUsage, a as buildHelp, c as formatCodexStatus, d as formatModels, f as formatThreads, l as formatComputerUseStatus, o as formatAccount, p as readString$1, s as formatCodexDisplayText, u as formatList } from "./notification-correlation-YINts3PA.js";
7
7
  import { n as resolveCodexNativeExecutionBlock, r as resolveCodexNativeSandboxBlock } from "./sandbox-guard-CTnEWuor.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-BnnjOmgs.js";
9
- import { n as installCodexComputerUse, r as readCodexComputerUseStatus } from "./computer-use-CDDlIBhY.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-OjYqDwhw.js";
9
+ import { n as installCodexComputerUse, r as readCodexComputerUseStatus } from "./computer-use-DSdj1hJY.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";
@@ -1,4 +1,4 @@
1
- import { t as defaultCodexAppServerClientFactory } from "./client-factory-CaOpX89B.js";
1
+ import { t as defaultCodexAppServerClientFactory } from "./client-factory-fW4Hh9q_.js";
2
2
  import { l as resolveCodexAppServerRuntimeOptions } from "./config-0-UN67Qg.js";
3
3
  import { i as readCodexAppServerBinding } from "./session-binding-UFjjws4k.js";
4
4
  import { n as resolveCodexNativeExecutionBlock } from "./sandbox-guard-CTnEWuor.js";
@@ -61,6 +61,29 @@ function readAgentIdFromSessionKey(sessionKey) {
61
61
  return parts[1]?.trim() || void 0;
62
62
  }
63
63
  async function compactCodexNativeThread(params, options = {}) {
64
+ if (params.trigger !== "manual") {
65
+ embeddedAgentLog.info("skipping codex app-server compaction for non-manual trigger", {
66
+ sessionId: params.sessionId,
67
+ sessionKey: params.sessionKey,
68
+ trigger: params.trigger
69
+ });
70
+ return {
71
+ ok: true,
72
+ compacted: false,
73
+ reason: "codex app-server owns automatic compaction",
74
+ result: {
75
+ summary: "",
76
+ firstKeptEntryId: "",
77
+ tokensBefore: params.currentTokenCount ?? 0,
78
+ details: {
79
+ backend: "codex-app-server",
80
+ skipped: true,
81
+ reason: "non_manual_trigger",
82
+ trigger: params.trigger ?? "unknown"
83
+ }
84
+ }
85
+ };
86
+ }
64
87
  const nativeExecutionBlock = resolveCodexNativeExecutionBlock({
65
88
  config: params.config,
66
89
  sessionKey: params.sandboxSessionKey ?? params.sessionKey,
@@ -1,5 +1,5 @@
1
1
  import { l as resolveCodexAppServerRuntimeOptions, u as resolveCodexComputerUseConfig } from "./config-0-UN67Qg.js";
2
- import { i as describeControlFailure, t as requestCodexAppServerJson } from "./request-DmBkYLPy.js";
2
+ import { i as describeControlFailure, t as requestCodexAppServerJson } from "./request-OaxhR46w.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,10 +1,10 @@
1
1
  import { a as isCodexFastServiceTier, l as resolveCodexAppServerRuntimeOptions, r as codexSandboxPolicyForTurn } from "./config-0-UN67Qg.js";
2
2
  import { l as isJsonObject } from "./client-BVK_jmHW.js";
3
- import { t as CODEX_NATIVE_PERSONALITY_NONE } from "./thread-lifecycle-BapIT9Qs.js";
3
+ import { t as CODEX_NATIVE_PERSONALITY_NONE } from "./thread-lifecycle-CUXQezJL.js";
4
4
  import { i as readCodexAppServerBinding, n as isCodexAppServerNativeAuthProfile, o as writeCodexAppServerBinding, r as normalizeCodexAppServerBindingModelProvider, t as clearCodexAppServerBinding } from "./session-binding-UFjjws4k.js";
5
- import { r as CODEX_CONTROL_METHODS } from "./request-DmBkYLPy.js";
5
+ import { r as CODEX_CONTROL_METHODS } from "./request-OaxhR46w.js";
6
6
  import { i as readCodexNotificationTurnId, r as readCodexNotificationThreadId, s as formatCodexDisplayText } from "./notification-correlation-YINts3PA.js";
7
- import { i as getSharedCodexAppServerClient, u as resolveCodexAppServerAuthProfileIdForAgent } from "./shared-client-Fou5nAyt.js";
7
+ import { a as releaseLeasedSharedCodexAppServerClient, f as resolveCodexAppServerAuthProfileIdForAgent, i as getLeasedSharedCodexAppServerClient } from "./shared-client-8kIrP817.js";
8
8
  import { n as resolveCodexNativeExecutionBlock, r as resolveCodexNativeSandboxBlock } from "./sandbox-guard-CTnEWuor.js";
9
9
  import os from "node:os";
10
10
  import { asOptionalRecord, isRecord, normalizeSingleOrTrimmedStringList } from "openclaw/plugin-sdk/string-coerce-runtime";
@@ -98,15 +98,20 @@ async function stopCodexConversationTurn(params) {
98
98
  const runtime = resolveCodexAppServerRuntimeOptions({ pluginConfig: params.pluginConfig });
99
99
  const lookup = buildBindingLookup(params);
100
100
  const binding = await readCodexAppServerBinding(params.sessionFile, lookup);
101
- await (await getSharedCodexAppServerClient({
101
+ const client = await getLeasedSharedCodexAppServerClient({
102
102
  startOptions: runtime.start,
103
103
  timeoutMs: runtime.requestTimeoutMs,
104
104
  authProfileId: binding?.authProfileId,
105
105
  ...lookup
106
- })).request("turn/interrupt", {
107
- threadId: active.threadId,
108
- turnId: active.turnId
109
- }, { timeoutMs: runtime.requestTimeoutMs });
106
+ });
107
+ try {
108
+ await client.request("turn/interrupt", {
109
+ threadId: active.threadId,
110
+ turnId: active.turnId
111
+ }, { timeoutMs: runtime.requestTimeoutMs });
112
+ } finally {
113
+ releaseLeasedSharedCodexAppServerClient(client);
114
+ }
110
115
  return {
111
116
  stopped: true,
112
117
  message: "Codex stop requested."
@@ -126,20 +131,25 @@ async function steerCodexConversationTurn(params) {
126
131
  const runtime = resolveCodexAppServerRuntimeOptions({ pluginConfig: params.pluginConfig });
127
132
  const lookup = buildBindingLookup(params);
128
133
  const binding = await readCodexAppServerBinding(params.sessionFile, lookup);
129
- await (await getSharedCodexAppServerClient({
134
+ const client = await getLeasedSharedCodexAppServerClient({
130
135
  startOptions: runtime.start,
131
136
  timeoutMs: runtime.requestTimeoutMs,
132
137
  authProfileId: binding?.authProfileId,
133
138
  ...lookup
134
- })).request("turn/steer", {
135
- threadId: active.threadId,
136
- expectedTurnId: active.turnId,
137
- input: [{
138
- type: "text",
139
- text,
140
- text_elements: []
141
- }]
142
- }, { timeoutMs: runtime.requestTimeoutMs });
139
+ });
140
+ try {
141
+ await client.request("turn/steer", {
142
+ threadId: active.threadId,
143
+ expectedTurnId: active.turnId,
144
+ input: [{
145
+ type: "text",
146
+ text,
147
+ text_elements: []
148
+ }]
149
+ }, { timeoutMs: runtime.requestTimeoutMs });
150
+ } finally {
151
+ releaseLeasedSharedCodexAppServerClient(client);
152
+ }
143
153
  return {
144
154
  steered: true,
145
155
  message: "Sent steer message to Codex."
@@ -214,20 +224,25 @@ async function requireThreadBinding(sessionFile, lookup = {}) {
214
224
  }
215
225
  async function resumeThreadWithOverrides(params) {
216
226
  const runtime = resolveCodexAppServerRuntimeOptions({ pluginConfig: params.pluginConfig });
217
- return await (await getSharedCodexAppServerClient({
227
+ const client = await getLeasedSharedCodexAppServerClient({
218
228
  startOptions: runtime.start,
219
229
  timeoutMs: runtime.requestTimeoutMs,
220
230
  authProfileId: params.authProfileId,
221
231
  ...buildBindingLookup(params)
222
- })).request(CODEX_CONTROL_METHODS.resumeThread, {
223
- threadId: params.threadId,
224
- ...params.model ? { model: params.model } : {},
225
- approvalPolicy: params.approvalPolicy ?? runtime.approvalPolicy,
226
- sandbox: params.sandbox ?? runtime.sandbox,
227
- approvalsReviewer: runtime.approvalsReviewer,
228
- ...params.serviceTier ? { serviceTier: params.serviceTier } : {},
229
- persistExtendedHistory: true
230
- }, { timeoutMs: runtime.requestTimeoutMs });
232
+ });
233
+ try {
234
+ return await client.request(CODEX_CONTROL_METHODS.resumeThread, {
235
+ threadId: params.threadId,
236
+ ...params.model ? { model: params.model } : {},
237
+ approvalPolicy: params.approvalPolicy ?? runtime.approvalPolicy,
238
+ sandbox: params.sandbox ?? runtime.sandbox,
239
+ approvalsReviewer: runtime.approvalsReviewer,
240
+ ...params.serviceTier ? { serviceTier: params.serviceTier } : {},
241
+ persistExtendedHistory: true
242
+ }, { timeoutMs: runtime.requestTimeoutMs });
243
+ } finally {
244
+ releaseLeasedSharedCodexAppServerClient(client);
245
+ }
231
246
  }
232
247
  function buildBindingLookup(params) {
233
248
  const agentDir = params.agentDir?.trim();
@@ -1029,38 +1044,43 @@ async function attachExistingThread(params) {
1029
1044
  modelProvider: params.modelProvider,
1030
1045
  ...agentLookup
1031
1046
  });
1032
- const response = await (await getSharedCodexAppServerClient({
1047
+ const client = await getLeasedSharedCodexAppServerClient({
1033
1048
  startOptions: runtime.start,
1034
1049
  timeoutMs: runtime.requestTimeoutMs,
1035
1050
  authProfileId: params.authProfileId,
1036
1051
  ...agentLookup
1037
- })).request(CODEX_CONTROL_METHODS.resumeThread, {
1038
- threadId: params.threadId,
1039
- ...params.model ? { model: params.model } : {},
1040
- ...modelProvider ? { modelProvider } : {},
1041
- personality: CODEX_NATIVE_PERSONALITY_NONE,
1042
- approvalPolicy: params.approvalPolicy ?? runtime.approvalPolicy,
1043
- approvalsReviewer: runtime.approvalsReviewer,
1044
- sandbox: params.sandbox ?? runtime.sandbox,
1045
- ...params.serviceTier ?? runtime.serviceTier ? { serviceTier: params.serviceTier ?? runtime.serviceTier } : {},
1046
- persistExtendedHistory: true
1047
- }, { timeoutMs: runtime.requestTimeoutMs });
1048
- const thread = response.thread;
1049
- const runtimeApprovalPolicy = typeof runtime.approvalPolicy === "string" ? runtime.approvalPolicy : void 0;
1050
- await writeCodexAppServerBinding(params.sessionFile, {
1051
- threadId: thread.id,
1052
- cwd: thread.cwd ?? params.workspaceDir,
1053
- authProfileId: params.authProfileId,
1054
- model: response.model ?? params.model,
1055
- modelProvider: normalizeCodexAppServerBindingModelProvider({
1052
+ });
1053
+ try {
1054
+ const response = await client.request(CODEX_CONTROL_METHODS.resumeThread, {
1055
+ threadId: params.threadId,
1056
+ ...params.model ? { model: params.model } : {},
1057
+ ...modelProvider ? { modelProvider } : {},
1058
+ personality: CODEX_NATIVE_PERSONALITY_NONE,
1059
+ approvalPolicy: params.approvalPolicy ?? runtime.approvalPolicy,
1060
+ approvalsReviewer: runtime.approvalsReviewer,
1061
+ sandbox: params.sandbox ?? runtime.sandbox,
1062
+ ...params.serviceTier ?? runtime.serviceTier ? { serviceTier: params.serviceTier ?? runtime.serviceTier } : {},
1063
+ persistExtendedHistory: true
1064
+ }, { timeoutMs: runtime.requestTimeoutMs });
1065
+ const thread = response.thread;
1066
+ const runtimeApprovalPolicy = typeof runtime.approvalPolicy === "string" ? runtime.approvalPolicy : void 0;
1067
+ await writeCodexAppServerBinding(params.sessionFile, {
1068
+ threadId: thread.id,
1069
+ cwd: thread.cwd ?? params.workspaceDir,
1056
1070
  authProfileId: params.authProfileId,
1057
- modelProvider: response.modelProvider ?? params.modelProvider,
1058
- ...agentLookup
1059
- }),
1060
- approvalPolicy: params.approvalPolicy ?? runtimeApprovalPolicy,
1061
- sandbox: params.sandbox ?? runtime.sandbox,
1062
- serviceTier: params.serviceTier ?? runtime.serviceTier
1063
- }, { ...agentLookup });
1071
+ model: response.model ?? params.model,
1072
+ modelProvider: normalizeCodexAppServerBindingModelProvider({
1073
+ authProfileId: params.authProfileId,
1074
+ modelProvider: response.modelProvider ?? params.modelProvider,
1075
+ ...agentLookup
1076
+ }),
1077
+ approvalPolicy: params.approvalPolicy ?? runtimeApprovalPolicy,
1078
+ sandbox: params.sandbox ?? runtime.sandbox,
1079
+ serviceTier: params.serviceTier ?? runtime.serviceTier
1080
+ }, { ...agentLookup });
1081
+ } finally {
1082
+ releaseLeasedSharedCodexAppServerClient(client);
1083
+ }
1064
1084
  }
1065
1085
  async function createThread(params) {
1066
1086
  const runtime = resolveCodexAppServerRuntimeOptions({ pluginConfig: params.pluginConfig });
@@ -1073,39 +1093,44 @@ async function createThread(params) {
1073
1093
  modelProvider: params.modelProvider,
1074
1094
  ...agentLookup
1075
1095
  });
1076
- const response = await (await getSharedCodexAppServerClient({
1096
+ const client = await getLeasedSharedCodexAppServerClient({
1077
1097
  startOptions: runtime.start,
1078
1098
  timeoutMs: runtime.requestTimeoutMs,
1079
1099
  authProfileId: params.authProfileId,
1080
1100
  ...agentLookup
1081
- })).request("thread/start", {
1082
- cwd: params.workspaceDir,
1083
- ...params.model ? { model: params.model } : {},
1084
- ...modelProvider ? { modelProvider } : {},
1085
- personality: CODEX_NATIVE_PERSONALITY_NONE,
1086
- approvalPolicy: params.approvalPolicy ?? runtime.approvalPolicy,
1087
- approvalsReviewer: runtime.approvalsReviewer,
1088
- sandbox: params.sandbox ?? runtime.sandbox,
1089
- ...params.serviceTier ?? runtime.serviceTier ? { serviceTier: params.serviceTier ?? runtime.serviceTier } : {},
1090
- developerInstructions: "This Codex thread is bound to an OpenClaw conversation. Answer normally; OpenClaw will deliver your final response back to the conversation.",
1091
- experimentalRawEvents: true,
1092
- persistExtendedHistory: true
1093
- }, { timeoutMs: runtime.requestTimeoutMs });
1094
- const runtimeApprovalPolicy = typeof runtime.approvalPolicy === "string" ? runtime.approvalPolicy : void 0;
1095
- await writeCodexAppServerBinding(params.sessionFile, {
1096
- threadId: response.thread.id,
1097
- cwd: response.thread.cwd ?? params.workspaceDir,
1098
- authProfileId: params.authProfileId,
1099
- model: response.model ?? params.model,
1100
- modelProvider: normalizeCodexAppServerBindingModelProvider({
1101
+ });
1102
+ try {
1103
+ const response = await client.request("thread/start", {
1104
+ cwd: params.workspaceDir,
1105
+ ...params.model ? { model: params.model } : {},
1106
+ ...modelProvider ? { modelProvider } : {},
1107
+ personality: CODEX_NATIVE_PERSONALITY_NONE,
1108
+ approvalPolicy: params.approvalPolicy ?? runtime.approvalPolicy,
1109
+ approvalsReviewer: runtime.approvalsReviewer,
1110
+ sandbox: params.sandbox ?? runtime.sandbox,
1111
+ ...params.serviceTier ?? runtime.serviceTier ? { serviceTier: params.serviceTier ?? runtime.serviceTier } : {},
1112
+ developerInstructions: "This Codex thread is bound to an OpenClaw conversation. Answer normally; OpenClaw will deliver your final response back to the conversation.",
1113
+ experimentalRawEvents: true,
1114
+ persistExtendedHistory: true
1115
+ }, { timeoutMs: runtime.requestTimeoutMs });
1116
+ const runtimeApprovalPolicy = typeof runtime.approvalPolicy === "string" ? runtime.approvalPolicy : void 0;
1117
+ await writeCodexAppServerBinding(params.sessionFile, {
1118
+ threadId: response.thread.id,
1119
+ cwd: response.thread.cwd ?? params.workspaceDir,
1101
1120
  authProfileId: params.authProfileId,
1102
- modelProvider: response.modelProvider ?? params.modelProvider,
1103
- ...agentLookup
1104
- }),
1105
- approvalPolicy: params.approvalPolicy ?? runtimeApprovalPolicy,
1106
- sandbox: params.sandbox ?? runtime.sandbox,
1107
- serviceTier: params.serviceTier ?? runtime.serviceTier
1108
- }, { ...agentLookup });
1121
+ model: response.model ?? params.model,
1122
+ modelProvider: normalizeCodexAppServerBindingModelProvider({
1123
+ authProfileId: params.authProfileId,
1124
+ modelProvider: response.modelProvider ?? params.modelProvider,
1125
+ ...agentLookup
1126
+ }),
1127
+ approvalPolicy: params.approvalPolicy ?? runtimeApprovalPolicy,
1128
+ sandbox: params.sandbox ?? runtime.sandbox,
1129
+ serviceTier: params.serviceTier ?? runtime.serviceTier
1130
+ }, { ...agentLookup });
1131
+ } finally {
1132
+ releaseLeasedSharedCodexAppServerClient(client);
1133
+ }
1109
1134
  }
1110
1135
  async function runBoundTurn(params) {
1111
1136
  const runtime = resolveCodexAppServerRuntimeOptions({ pluginConfig: params.pluginConfig });
@@ -1113,7 +1138,7 @@ async function runBoundTurn(params) {
1113
1138
  const binding = await readCodexAppServerBinding(params.data.sessionFile, agentLookup);
1114
1139
  const threadId = binding?.threadId;
1115
1140
  if (!threadId) throw new Error("bound Codex conversation has no thread binding");
1116
- const client = await getSharedCodexAppServerClient({
1141
+ const client = await getLeasedSharedCodexAppServerClient({
1117
1142
  startOptions: runtime.start,
1118
1143
  timeoutMs: runtime.requestTimeoutMs,
1119
1144
  authProfileId: binding.authProfileId,
@@ -1167,6 +1192,7 @@ async function runBoundTurn(params) {
1167
1192
  } finally {
1168
1193
  notificationCleanup();
1169
1194
  requestCleanup();
1195
+ releaseLeasedSharedCodexAppServerClient(client);
1170
1196
  }
1171
1197
  }
1172
1198
  async function runBoundTurnWithMissingThreadRecovery(params) {
@@ -1,6 +1,6 @@
1
- import { E as sanitizeInlineImageDataUrl, w as invalidInlineImageText } from "./thread-lifecycle-BapIT9Qs.js";
1
+ import { E as sanitizeInlineImageDataUrl, w as invalidInlineImageText } from "./thread-lifecycle-CUXQezJL.js";
2
2
  import { asOptionalRecord, isRecord } from "openclaw/plugin-sdk/string-coerce-runtime";
3
- import { HEARTBEAT_RESPONSE_TOOL_NAME, createAgentToolResultMiddlewareRunner, createCodexAppServerToolResultExtensionRunner, extractToolResultMediaArtifact, filterToolResultMediaUrls, isMessagingTool, isMessagingToolSendAction, isToolWrappedWithBeforeToolCallHook, normalizeHeartbeatToolResponse, runAgentHarnessAfterToolCallHook, setBeforeToolCallDiagnosticsEnabled, wrapToolWithBeforeToolCallHook } from "openclaw/plugin-sdk/agent-harness-runtime";
3
+ import { HEARTBEAT_RESPONSE_TOOL_NAME, createAgentToolResultMiddlewareRunner, createCodexAppServerToolResultExtensionRunner, embeddedAgentLog, extractToolResultMediaArtifact, filterToolResultMediaUrls, isMessagingTool, isMessagingToolSendAction, isToolWrappedWithBeforeToolCallHook, normalizeHeartbeatToolResponse, projectRuntimeToolInputSchema, runAgentHarnessAfterToolCallHook, setBeforeToolCallDiagnosticsEnabled, wrapToolWithBeforeToolCallHook } from "openclaw/plugin-sdk/agent-harness-runtime";
4
4
  import { normalizeAgentId } from "openclaw/plugin-sdk/routing";
5
5
  //#region extensions/codex/src/app-server/dynamic-tool-profile.ts
6
6
  const CODEX_APP_SERVER_OWNED_DYNAMIC_TOOL_EXCLUDES = [
@@ -47,16 +47,26 @@ const DEFAULT_CODEX_DYNAMIC_TOOL_RESULT_MAX_CHARS = 16e3;
47
47
  function createCodexDynamicToolBridge(params) {
48
48
  const toolResultHookContext = toToolResultHookContext(params.hookContext);
49
49
  const toolResultMaxChars = resolveCodexDynamicToolResultMaxChars(params.hookContext);
50
- const tools = params.tools.map((tool) => {
50
+ const availableProjection = projectCodexDynamicTools(params.tools);
51
+ const registeredProjection = params.registeredTools ? projectCodexDynamicTools(params.registeredTools) : availableProjection;
52
+ const availableTools = availableProjection.tools.map(({ tool, inputSchema }) => {
51
53
  if (isToolWrappedWithBeforeToolCallHook(tool)) {
52
54
  setBeforeToolCallDiagnosticsEnabled(tool, false);
53
- return tool;
55
+ return {
56
+ tool,
57
+ inputSchema
58
+ };
54
59
  }
55
- return wrapToolWithBeforeToolCallHook(tool, params.hookContext, { emitDiagnostics: false });
60
+ return {
61
+ tool: wrapToolWithBeforeToolCallHook(tool, params.hookContext, { emitDiagnostics: false }),
62
+ inputSchema
63
+ };
56
64
  });
57
- const toolMap = new Map(tools.map((tool) => [tool.name, tool]));
58
- const registeredTools = params.registeredTools ?? tools;
65
+ const toolMap = new Map(availableTools.map(({ tool }) => [tool.name, tool]));
66
+ const registeredTools = registeredProjection.tools.map(({ tool }) => tool);
59
67
  const registeredToolNames = new Set(registeredTools.map((tool) => tool.name));
68
+ const quarantinedTools = dedupeQuarantinedDynamicTools([...availableProjection.quarantinedTools, ...registeredProjection.quarantinedTools]);
69
+ warnQuarantinedDynamicTools(quarantinedTools);
60
70
  const telemetry = {
61
71
  didSendViaMessagingTool: false,
62
72
  messagingToolSentTexts: [],
@@ -64,7 +74,8 @@ function createCodexDynamicToolBridge(params) {
64
74
  messagingToolSentTargets: [],
65
75
  messagingToolSourceReplyPayloads: [],
66
76
  toolMediaUrls: [],
67
- toolAudioAsVoice: false
77
+ toolAudioAsVoice: false,
78
+ quarantinedTools
68
79
  };
69
80
  const middlewareRunner = createAgentToolResultMiddlewareRunner({
70
81
  runtime: "codex",
@@ -73,13 +84,15 @@ function createCodexDynamicToolBridge(params) {
73
84
  const legacyExtensionRunner = createCodexAppServerToolResultExtensionRunner(toolResultHookContext);
74
85
  const directToolNames = new Set([...ALWAYS_DIRECT_DYNAMIC_TOOL_NAMES, ...params.directToolNames ?? []]);
75
86
  return {
76
- availableSpecs: tools.map((tool) => createCodexDynamicToolSpec({
87
+ availableSpecs: availableTools.map(({ tool, inputSchema }) => createCodexDynamicToolSpec({
77
88
  tool,
89
+ inputSchema,
78
90
  loading: params.loading ?? "searchable",
79
91
  directToolNames
80
92
  })),
81
- specs: registeredTools.map((tool) => createCodexDynamicToolSpec({
93
+ specs: registeredProjection.tools.map(({ tool, inputSchema }) => createCodexDynamicToolSpec({
82
94
  tool,
95
+ inputSchema,
83
96
  loading: params.loading ?? "searchable",
84
97
  directToolNames
85
98
  })),
@@ -192,7 +205,7 @@ function createCodexDynamicToolSpec(params) {
192
205
  const base = {
193
206
  name: params.tool.name,
194
207
  description: params.tool.description,
195
- inputSchema: toJsonValue(params.tool.parameters)
208
+ inputSchema: params.inputSchema
196
209
  };
197
210
  if (params.loading === "direct" || params.directToolNames.has(params.tool.name)) return base;
198
211
  return {
@@ -201,6 +214,43 @@ function createCodexDynamicToolSpec(params) {
201
214
  deferLoading: true
202
215
  };
203
216
  }
217
+ function projectCodexDynamicTools(tools) {
218
+ const projectedTools = [];
219
+ const quarantinedTools = [];
220
+ for (const tool of tools) {
221
+ const projection = projectRuntimeToolInputSchema(tool.parameters, `${tool.name}.inputSchema`);
222
+ if (projection.violations.length > 0) {
223
+ quarantinedTools.push({
224
+ tool: tool.name,
225
+ violations: projection.violations
226
+ });
227
+ continue;
228
+ }
229
+ projectedTools.push({
230
+ tool,
231
+ inputSchema: projection.schema
232
+ });
233
+ }
234
+ return {
235
+ tools: projectedTools,
236
+ quarantinedTools
237
+ };
238
+ }
239
+ function warnQuarantinedDynamicTools(tools) {
240
+ if (tools.length === 0) return;
241
+ const unique = /* @__PURE__ */ new Map();
242
+ for (const tool of tools) unique.set(tool.tool, tool.violations);
243
+ embeddedAgentLog.warn(`codex app-server quarantined ${unique.size} dynamic ${unique.size === 1 ? "tool" : "tools"} with unsupported input schemas: ${[...unique.keys()].join(", ")}`, { tools: [...unique.entries()].map(([tool, violations]) => ({
244
+ tool,
245
+ violations
246
+ })) });
247
+ }
248
+ function dedupeQuarantinedDynamicTools(tools) {
249
+ return [...new Map(tools.map((tool) => [tool.tool, {
250
+ tool: tool.tool,
251
+ violations: tool.violations
252
+ }])).values()];
253
+ }
204
254
  function toToolResultHookContext(ctx) {
205
255
  const { agentId, sessionId, sessionKey, runId, channelId } = ctx ?? {};
206
256
  return {
@@ -434,15 +484,6 @@ function convertToolContent(content) {
434
484
  imageUrl
435
485
  }];
436
486
  }
437
- function toJsonValue(value) {
438
- try {
439
- const text = JSON.stringify(value);
440
- if (!text) return {};
441
- return JSON.parse(text);
442
- } catch {
443
- return {};
444
- }
445
- }
446
487
  function jsonObjectToRecord(value) {
447
488
  if (!value || typeof value !== "object" || Array.isArray(value)) return {};
448
489
  return value;
package/dist/harness.js CHANGED
@@ -28,21 +28,21 @@ function createCodexAppServerAgentHarness(options) {
28
28
  };
29
29
  },
30
30
  runAttempt: async (params) => {
31
- const { runCodexAppServerAttempt } = await import("./run-attempt-CFBsGx1T.js");
31
+ const { runCodexAppServerAttempt } = await import("./run-attempt-D8Vxo-Jm.js");
32
32
  return runCodexAppServerAttempt(params, {
33
33
  pluginConfig: options?.resolvePluginConfig?.() ?? options?.pluginConfig,
34
34
  nativeHookRelay: { enabled: true }
35
35
  });
36
36
  },
37
37
  runSideQuestion: async (params) => {
38
- const { runCodexAppServerSideQuestion } = await import("./side-question-fq_T2d_x.js");
38
+ const { runCodexAppServerSideQuestion } = await import("./side-question-DU7en3_R.js");
39
39
  return runCodexAppServerSideQuestion(params, {
40
40
  pluginConfig: options?.resolvePluginConfig?.() ?? options?.pluginConfig,
41
41
  nativeHookRelay: { enabled: true }
42
42
  });
43
43
  },
44
44
  compact: async (params) => {
45
- const { maybeCompactCodexAppServerSession } = await import("./compact-CRI0BEc_.js");
45
+ const { maybeCompactCodexAppServerSession } = await import("./compact-C_1JAB4C.js");
46
46
  return maybeCompactCodexAppServerSession(params, { pluginConfig: options?.resolvePluginConfig?.() ?? options?.pluginConfig });
47
47
  },
48
48
  reset: async (params) => {
@@ -52,7 +52,7 @@ function createCodexAppServerAgentHarness(options) {
52
52
  }
53
53
  },
54
54
  dispose: async () => {
55
- const { clearSharedCodexAppServerClientAndWait } = await import("./shared-client-Fou5nAyt.js").then((n) => n.a);
55
+ const { clearSharedCodexAppServerClientAndWait } = await import("./shared-client-8kIrP817.js").then((n) => n.s);
56
56
  await clearSharedCodexAppServerClientAndWait();
57
57
  }
58
58
  };
package/dist/index.js CHANGED
@@ -1,12 +1,12 @@
1
1
  import { createCodexAppServerAgentHarness } from "./harness.js";
2
2
  import { c as readCodexPluginConfig, l as resolveCodexAppServerRuntimeOptions, t as CODEX_PLUGINS_MARKETPLACE_NAME } from "./config-0-UN67Qg.js";
3
3
  import { buildCodexProvider } from "./provider.js";
4
- import { C as defaultCodexAppInventoryCache, b as ensureCodexPluginActivation, x as pluginReadParams } from "./thread-lifecycle-BapIT9Qs.js";
4
+ import { C as defaultCodexAppInventoryCache, b as ensureCodexPluginActivation, x as pluginReadParams } from "./thread-lifecycle-CUXQezJL.js";
5
5
  import { buildCodexMediaUnderstandingProvider } from "./media-understanding-provider.js";
6
- import { i as describeControlFailure, n as buildCodexPluginAppCacheKey, t as requestCodexAppServerJson } from "./request-DmBkYLPy.js";
6
+ import { i as describeControlFailure, n as buildCodexPluginAppCacheKey, t as requestCodexAppServerJson } from "./request-OaxhR46w.js";
7
7
  import { s as formatCodexDisplayText } from "./notification-correlation-YINts3PA.js";
8
- import { c as resolveCodexAppServerAuthAccountCacheKey, d as resolveCodexAppServerFallbackApiKeyCacheKey, i as getSharedCodexAppServerClient, n as clearSharedCodexAppServerClientIfCurrentAndWait, u as resolveCodexAppServerAuthProfileIdForAgent } from "./shared-client-Fou5nAyt.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-BnnjOmgs.js";
8
+ import { a as releaseLeasedSharedCodexAppServerClient, f as resolveCodexAppServerAuthProfileIdForAgent, i as getLeasedSharedCodexAppServerClient, n as clearSharedCodexAppServerClientIfCurrentAndWait, p as resolveCodexAppServerFallbackApiKeyCacheKey, u as resolveCodexAppServerAuthAccountCacheKey } from "./shared-client-8kIrP817.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-OjYqDwhw.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";
@@ -47,7 +47,7 @@ async function handleCodexCommand(ctx, options = {}) {
47
47
  }
48
48
  }
49
49
  async function loadDefaultCodexSubcommandHandler() {
50
- const { handleCodexSubcommand } = await import("./command-handlers-D4C2y46B.js");
50
+ const { handleCodexSubcommand } = await import("./command-handlers-hYTtzAdy.js");
51
51
  return handleCodexSubcommand;
52
52
  }
53
53
  //#endregion
@@ -1182,7 +1182,7 @@ function prepareTargetCodexAppServer(ctx) {
1182
1182
  const appServer = resolveTargetCodexAppServer(ctx);
1183
1183
  const targets = resolveCodexMigrationTargets(ctx);
1184
1184
  let warmedClient;
1185
- const ready = getSharedCodexAppServerClient({
1185
+ const ready = getLeasedSharedCodexAppServerClient({
1186
1186
  startOptions: appServer.start,
1187
1187
  timeoutMs: 6e4,
1188
1188
  agentDir: targets.agentDir,
@@ -1192,6 +1192,7 @@ function prepareTargetCodexAppServer(ctx) {
1192
1192
  }, () => void 0);
1193
1193
  return { async dispose() {
1194
1194
  await ready;
1195
+ if (warmedClient) releaseLeasedSharedCodexAppServerClient(warmedClient);
1195
1196
  await clearSharedCodexAppServerClientIfCurrentAndWait(warmedClient, {
1196
1197
  exitTimeoutMs: 2e3,
1197
1198
  forceKillDelayMs: 250
@@ -1,10 +1,10 @@
1
1
  import { CODEX_PROVIDER_ID, FALLBACK_CODEX_MODELS } from "./provider-catalog.js";
2
- import "./client-factory-CaOpX89B.js";
2
+ import "./client-factory-fW4Hh9q_.js";
3
3
  import { l as resolveCodexAppServerRuntimeOptions } from "./config-0-UN67Qg.js";
4
- import { i as assertCodexTurnStartResponse, l as readCodexTurnCompletedNotification, o as readCodexErrorNotification, r as assertCodexThreadStartResponse } from "./protocol-validators-CSuFMLvY.js";
5
- import { i as readModelListResult } from "./models-ASKu9eOY.js";
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-_XwpqjR8.js";
6
6
  import { l as isJsonObject } from "./client-BVK_jmHW.js";
7
- import { r as buildCodexRuntimeThreadConfig } from "./thread-lifecycle-BapIT9Qs.js";
7
+ import { r as buildCodexRuntimeThreadConfig } from "./thread-lifecycle-CUXQezJL.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-Fou5nAyt.js").then((n) => n.a).then(({ createIsolatedCodexAppServerClient }) => createIsolatedCodexAppServerClient({
68
+ const client = params.options.clientFactory ? await params.options.clientFactory(appServer.start, params.profile) : await import("./shared-client-8kIrP817.js").then((n) => n.s).then(({ createIsolatedCodexAppServerClient }) => createIsolatedCodexAppServerClient({
69
69
  startOptions: appServer.start,
70
70
  timeoutMs,
71
71
  authProfileId: params.profile
@@ -1,5 +1,5 @@
1
1
  import { t as __exportAll } from "./rolldown-runtime-8H4AJuhK.js";
2
- import { s as readCodexModelListResponse } from "./protocol-validators-CSuFMLvY.js";
2
+ import { s as readCodexModelListResponse } from "./protocol-validators-DtjYmUw_.js";
3
3
  import { uniqueStrings } from "openclaw/plugin-sdk/string-coerce-runtime";
4
4
  //#region extensions/codex/src/app-server/models.ts
5
5
  var models_exports = /* @__PURE__ */ __exportAll({
@@ -40,8 +40,8 @@ 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, getSharedCodexAppServerClient } = await import("./shared-client-Fou5nAyt.js").then((n) => n.a);
44
- const client = useSharedClient ? await getSharedCodexAppServerClient({
43
+ const { createIsolatedCodexAppServerClient, getLeasedSharedCodexAppServerClient, releaseLeasedSharedCodexAppServerClient } = await import("./shared-client-8kIrP817.js").then((n) => n.s);
44
+ const client = useSharedClient ? await getLeasedSharedCodexAppServerClient({
45
45
  startOptions: options.startOptions,
46
46
  timeoutMs,
47
47
  authProfileId: options.authProfileId,
@@ -60,7 +60,8 @@ async function withCodexAppServerModelClient(options, run) {
60
60
  timeoutMs
61
61
  });
62
62
  } finally {
63
- if (!useSharedClient) client.close();
63
+ if (useSharedClient) releaseLeasedSharedCodexAppServerClient(client);
64
+ else client.close();
64
65
  }
65
66
  }
66
67
  async function requestModelListPage(client, options) {