@openclaw/codex 2026.7.2-beta.5 → 2026.7.33

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (66) hide show
  1. package/README.md +3 -27
  2. package/dist/{command-formatters-ico4ZFnk.js → .setup/app-server-policy-C_qTMEMy.mjs} +51 -9
  3. package/dist/{attempt-notifications-CMR2_fmR.js → .setup/attempt-notifications-F8krwWL4.mjs} +6 -3
  4. package/dist/{command-handlers-CRmnwI2N.js → .setup/command-handlers-DSRFfor4.mjs} +1156 -1319
  5. package/dist/.setup/command-rpc-BvYsfQ7G.mjs +786 -0
  6. package/dist/{compact-dEN49UH6.js → .setup/compact-BNgh7I4t.mjs} +10 -40
  7. package/dist/.setup/computer-use-C3QkmSO3.mjs +377 -0
  8. package/dist/.setup/config-CYEDnLJ2.mjs +1138 -0
  9. package/dist/{conversation-binding-data-BHRpYbX3.js → .setup/conversation-binding-data-CrRxtDBu.mjs} +1 -1
  10. package/dist/{bounded-turn-FEbUXoYT.js → .setup/media-understanding-provider-EbJCyDqe.mjs} +193 -92
  11. package/dist/{models-BA01NEez.js → .setup/models-C_aZk03A.mjs} +11 -6
  12. package/dist/.setup/notification-correlation-iYs4WieS.mjs +35 -0
  13. package/dist/.setup/plugin-app-cache-key-DR8jV9oS.mjs +99 -0
  14. package/dist/.setup/protocol-2POPqAY4.mjs +13 -0
  15. package/dist/{protocol-validators-Dm4eXZmt.js → .setup/protocol-validators-dZQ-UTOa.mjs} +111 -334
  16. package/dist/{rate-limits-S_PXs0ul.js → .setup/provider-DGxDs6g8.mjs} +269 -13
  17. package/dist/{dynamic-tools-LIt9ojep.js → .setup/provider-capabilities-DS2N_zc1.mjs} +5465 -3399
  18. package/dist/.setup/request-DFR0JyoV.mjs +36 -0
  19. package/dist/.setup/run-attempt-C7xEKFVB.mjs +8180 -0
  20. package/dist/{sandbox-guard-D1Wky__S.js → .setup/sandbox-guard-DA2TQfZW.mjs} +1 -10
  21. package/dist/.setup/session-binding-DuihlMJc.mjs +628 -0
  22. package/dist/.setup/shared-client-B2KmLPRw.mjs +1854 -0
  23. package/dist/{side-question-CO12sHxo.js → .setup/side-question-Cv6JXWCS.mjs} +84 -159
  24. package/dist/{thread-lifecycle-DRg_FdzC.js → .setup/thread-lifecycle-u6CZdOOH.mjs} +1159 -1799
  25. package/dist/{web-search-provider.runtime-CaQMYDbp.js → .setup/web-search-provider.runtime-Ce2zOHxW.mjs} +3 -3
  26. package/dist/doctor-contract-api.js +122 -88
  27. package/dist/harness.js +20 -85
  28. package/dist/index.js +381 -1537
  29. package/dist/media-understanding-provider.js +1 -173
  30. package/dist/prompt-overlay.js +15 -0
  31. package/dist/provider-catalog.js +79 -0
  32. package/dist/provider-discovery.js +34 -0
  33. package/dist/provider.js +2 -0
  34. package/dist/web-search-contract-api.js +1 -1
  35. package/openclaw.plugin.json +178 -221
  36. package/package.json +8 -10
  37. package/dist/app-server-policy-BmDgseo_.js +0 -49
  38. package/dist/attempt-client-cleanup-Ia52yRWc.js +0 -127
  39. package/dist/auth-binding-B4FfbcCg.js +0 -62
  40. package/dist/capabilities-BHRSI6Cn.js +0 -36
  41. package/dist/cli-metadata.js +0 -20
  42. package/dist/computer-use-BjGylO-E.js +0 -695
  43. package/dist/conversation-control-DE7d9DOj.js +0 -287
  44. package/dist/event-projector-assistant-message-DTgnPPVF.js +0 -101
  45. package/dist/event-projector-usage-tvgb1NCX.js +0 -69
  46. package/dist/incognito-session-ET_ufDH-.js +0 -2
  47. package/dist/notification-correlation-Bj_Ak_jI.js +0 -67
  48. package/dist/plugin-app-cache-key-DSXX-rXO.js +0 -315
  49. package/dist/realtime-voice-api-BPcA1uN9.js +0 -494
  50. package/dist/realtime-voice-api.js +0 -2
  51. package/dist/request-CXpPennK.js +0 -157
  52. package/dist/run-attempt-C5GTPJOE.js +0 -11935
  53. package/dist/runtime-artifact-C2ITXdhM.js +0 -488
  54. package/dist/session-binding-DlVQ-Pxs.js +0 -2161
  55. package/dist/session-catalog-CP2oCcEb.js +0 -2444
  56. package/dist/session-cli-CqZ0Fp2a.js +0 -175
  57. package/dist/session-upstream-marker-QE-m5QFG.js +0 -82
  58. package/dist/settled-turn-finalizer-CA_2QXIE.js +0 -303
  59. package/dist/shared-client-BVKE40c-.js +0 -2952
  60. package/dist/transcript-mirror-uKA-A4tB.js +0 -550
  61. package/dist/transport-stdio-DXgGZ7Ib.js +0 -88
  62. package/dist/upstream-session-fork-_Vrz4WJr.js +0 -320
  63. package/dist/usage-UpVbdX5G.js +0 -25
  64. /package/dist/{rolldown-runtime-8H4AJuhK.js → .setup/rolldown-runtime-8H4AJuhK.mjs} +0 -0
  65. /package/dist/{session-binding-meta-B7aEMU7g.js → .setup/session-binding-meta-B7aEMU7g.mjs} +0 -0
  66. /package/dist/{web-search-provider.shared-BrZmlqyR.js → .setup/web-search-provider.shared-BrZmlqyR.mjs} +0 -0
@@ -1,15 +1,17 @@
1
- import { D as ensureCodexAppServerClientRuntime, I as resolveCodexAppServerPreparedAuthHandoff, V as isJsonObject, a as getLeasedSharedCodexAppServerClient, c as releaseCodexAppServerClientLease, k as readRecentCodexRateLimits, m as withLeasedCodexAppServerClientStartSelectionRetry, y as isCodexAppServerApprovalRequest } from "./shared-client-BVKE40c-.js";
2
- import { D as resolveOpenClawExecPolicyForCodexAppServer, S as resolveCodexModelBackedReviewerPolicyContext, T as readCodexPluginConfig, b as canUseCodexModelBackedApprovalsReviewerForModel, l as sessionBindingIdentity, v as shouldAutoApproveCodexAppServerApprovals } from "./session-binding-DlVQ-Pxs.js";
3
- import { A as resolveCodexDynamicToolsLoading, C as readCodexSupportedReasoningEfforts, G as mergeCodexThreadConfigs, S as resolveReasoningEffort, T as filterCodexDynamicTools, V as buildCodexPluginAppsConfigPatchFromPolicyContext, _ as CODEX_NATIVE_PERSONALITY_NONE, f as buildCodexRuntimeThreadConfig, h as resolveCodexWebSearchPlan, v as resolveCodexAppServerModelProvider, x as resolveCodexBindingModelProviderFallback, y as resolveCodexAppServerRequestModelSelection } from "./thread-lifecycle-DRg_FdzC.js";
4
- import { a as assertCodexTurnStartResponse, l as readCodexTurn, n as assertCodexThreadForkResponse, o as readCodexDynamicToolCallParams } from "./protocol-validators-Dm4eXZmt.js";
5
- import { n as formatCodexUsageLimitErrorMessage } from "./rate-limits-S_PXs0ul.js";
6
- import { t as resolveCodexAppServerForModelProvider } from "./app-server-policy-BmDgseo_.js";
7
- import { n as resolveCodexNativeExecutionBlock } from "./sandbox-guard-D1Wky__S.js";
8
- import { a as resolveCodexBindingAppServerConnection, i as requireCodexSupervisionModelSelection, n as readCodexNotificationThreadId, r as readCodexNotificationTurnId } from "./notification-correlation-Bj_Ak_jI.js";
9
- import { C as CodexNativeToolLifecycleProjector, D as buildCodexNativeHookRelayDisabledConfig, E as buildCodexNativeHookRelayConfig, L as resolveDynamicToolCallTimeoutMs, N as handleDynamicToolCallWithTimeout, S as filterToolsForVisionInputs, U as resolveCodexToolAbortTerminalReason, _ as resolveCodexMessageToolProvider, a as emitDynamicToolStartedDiagnostic, c as resolveCodexProviderWebSearchSupportForClient, i as emitDynamicToolErrorDiagnostic, k as emitCodexNativePreToolUseFailureDiagnostic, n as handleCodexAppServerApprovalRequest, o as emitDynamicToolTerminalDiagnostic, r as handleCodexAppServerElicitationRequest, t as createCodexDynamicToolBridge, w as CODEX_NATIVE_HOOK_RELAY_EVENTS, y as shouldEnableCodexAppServerNativeToolSurface } from "./dynamic-tools-LIt9ojep.js";
10
- import { buildAgentHookContextChannelFields, embeddedAgentLog, formatErrorMessage, registerNativeHookRelay, resolveAgentDir, resolveAttemptSpawnWorkspaceDir, resolveModelAuthMode, resolveSandboxContext, resolveSessionAgentIds, supportsModelTools } from "openclaw/plugin-sdk/agent-harness-runtime";
1
+ import { r as isJsonObject } from "./protocol-2POPqAY4.mjs";
2
+ import { _ as shouldAutoApproveCodexAppServerApprovals, d as resolveCodexAppServerRuntimeOptions, g as resolveOpenClawExecPolicyForCodexAppServer, m as resolveCodexModelBackedReviewerPolicyContext, n as canUseCodexModelBackedApprovalsReviewerForModel, u as readCodexPluginConfig } from "./config-CYEDnLJ2.mjs";
3
+ import { a as readCodexDynamicToolCallParams, c as readCodexTurn, i as assertCodexTurnStartResponse, t as assertCodexThreadForkResponse } from "./protocol-validators-dZQ-UTOa.mjs";
4
+ import { C as filterCodexDynamicTools, E as resolveCodexDynamicToolsLoading, H as mergeCodexThreadConfigs, d as resolveCodexAppServerModelProvider, f as resolveCodexAppServerRequestModelSelection, h as resolveReasoningEffort, m as resolveCodexBindingModelProviderFallback, r as buildCodexRuntimeThreadConfig, t as CODEX_NATIVE_PERSONALITY_NONE, v as resolveCodexWebSearchPlan, z as buildCodexPluginAppsConfigPatchFromPolicyContext } from "./thread-lifecycle-u6CZdOOH.mjs";
5
+ import { a as readCodexSupportedReasoningEfforts, c as formatCodexUsageLimitErrorMessage } from "./provider-DGxDs6g8.mjs";
6
+ import { a as getLeasedSharedCodexAppServerClient, d as isCodexAppServerApprovalRequest, h as readRecentCodexRateLimits, o as releaseLeasedSharedCodexAppServerClient, p as ensureCodexAppServerClientRuntime } from "./shared-client-B2KmLPRw.mjs";
7
+ import { i as isCodexAppServerNativeAuthProfile, s as sessionBindingIdentity } from "./session-binding-DuihlMJc.mjs";
8
+ import { t as resolveCodexAppServerForModelProvider } from "./app-server-policy-C_qTMEMy.mjs";
9
+ import { n as resolveCodexNativeExecutionBlock } from "./sandbox-guard-DA2TQfZW.mjs";
10
+ import { n as readCodexNotificationThreadId, r as readCodexNotificationTurnId } from "./notification-correlation-iYs4WieS.mjs";
11
+ import { D as emitDynamicToolStartedDiagnostic, E as emitDynamicToolErrorDiagnostic, I as resolveCodexMessageToolProvider, O as emitDynamicToolTerminalDiagnostic, R as shouldEnableCodexAppServerNativeToolSurface, T as createCodexDynamicToolBridge, U as handleCodexAppServerApprovalRequest, V as filterToolsForVisionInputs, Z as handleDynamicToolCallWithTimeout, _ as buildCodexNativeHookRelayDisabledConfig, g as buildCodexNativeHookRelayConfig, i as CodexNativeToolLifecycleProjector, m as CODEX_NATIVE_HOOK_RELAY_EVENTS, n as resolveCodexProviderWebSearchSupportForClient, st as resolveCodexToolAbortTerminalReason, tt as resolveDynamicToolCallTimeoutMs, w as handleCodexAppServerElicitationRequest, y as emitCodexNativePreToolUseFailureDiagnostic } from "./provider-capabilities-DS2N_zc1.mjs";
11
12
  import { randomUUID } from "node:crypto";
12
13
  import { loadExecApprovals } from "openclaw/plugin-sdk/exec-approvals-runtime";
14
+ import { buildAgentHookContextChannelFields, embeddedAgentLog, formatErrorMessage, registerNativeHookRelay, resolveAgentDir, resolveAttemptSpawnWorkspaceDir, resolveModelAuthMode, resolveSandboxContext, resolveSessionAgentIds, supportsModelTools } from "openclaw/plugin-sdk/agent-harness-runtime";
13
15
  //#region extensions/codex/src/app-server/side-question.ts
14
16
  const SIDE_QUESTION_COMPLETION_TIMEOUT_MS = 6e5;
15
17
  var CodexSideQuestionTimeoutError = class extends Error {
@@ -18,8 +20,8 @@ var CodexSideQuestionTimeoutError = class extends Error {
18
20
  this.name = "TimeoutError";
19
21
  }
20
22
  };
21
- const CODEX_SIDE_NATIVE_HOOK_RELAY_MIN_TTL_MS = 30 * 6e4;
22
- const CODEX_SIDE_NATIVE_HOOK_RELAY_TTL_GRACE_MS = 5 * 6e4;
23
+ const CODEX_SIDE_NATIVE_HOOK_RELAY_MIN_TTL_MS = 18e5;
24
+ const CODEX_SIDE_NATIVE_HOOK_RELAY_TTL_GRACE_MS = 3e5;
23
25
  const CODEX_SIDE_NATIVE_HOOK_RELAY_STARTUP_REQUEST_COUNT = 3;
24
26
  const CODEX_SIDE_NATIVE_HOOK_RELAY_EVENTS_WITH_APP_SERVER_APPROVALS = CODEX_NATIVE_HOOK_RELAY_EVENTS.filter((event) => event !== "permission_request");
25
27
  const SIDE_BOUNDARY_PROMPT = `Side conversation boundary.
@@ -65,28 +67,10 @@ async function runCodexAppServerSideQuestion(params, options) {
65
67
  config: params.cfg,
66
68
  agentId: sessionAgentId
67
69
  });
68
- const usesSupervisionConnection = binding.connectionScope === "supervision";
69
- const supervisionModelSelection = usesSupervisionConnection ? requireCodexSupervisionModelSelection(binding) : void 0;
70
- const preparedRuntimeAuth = params.preparedRuntimeAuth;
71
- const { authProfileId, nativeAuthProfile: preparedNativeAuthProfile, preparedAuth: startupPreparedAuth } = usesSupervisionConnection ? {
72
- authProfileId: void 0,
73
- nativeAuthProfile: true,
74
- preparedAuth: void 0
75
- } : await resolveCodexAppServerPreparedAuthHandoff({
76
- authRequirement: preparedRuntimeAuth.plan.modelRoute?.authRequirement,
77
- resolvedApiKey: preparedRuntimeAuth.resolvedApiKey,
78
- authProfileId: preparedRuntimeAuth.plan.forwardedAuthProfileId,
79
- authProfileStore: preparedRuntimeAuth.authProfileStore,
80
- agentDir: params.agentDir,
81
- ...pluginConfig.appServer?.homeScope ? { homeScope: pluginConfig.appServer.homeScope } : {},
82
- config: params.cfg,
83
- subscriptionProfileRequiredError: "Prepared Codex subscription route requires a scoped native OAuth or token profile.",
84
- subscriptionProfileUnusableError: `Prepared Codex auth profile "${preparedRuntimeAuth.plan.forwardedAuthProfileId}" is unusable.`
85
- });
86
- const modelProvider = supervisionModelSelection ? supervisionModelSelection.modelProvider : resolveCodexAppServerModelProvider({
70
+ const authProfileId = params.authProfileId ?? binding.authProfileId;
71
+ const modelProvider = resolveCodexAppServerModelProvider({
87
72
  provider: params.provider,
88
73
  authProfileId,
89
- authProfileStore: preparedRuntimeAuth.authProfileStore,
90
74
  agentDir: params.agentDir,
91
75
  config: params.cfg
92
76
  }) ?? resolveCodexBindingModelProviderFallback({
@@ -96,23 +80,24 @@ async function runCodexAppServerSideQuestion(params, options) {
96
80
  bindingModelProvider: binding.modelProvider
97
81
  });
98
82
  const modelSelection = resolveCodexAppServerRequestModelSelection({
99
- model: supervisionModelSelection?.model ?? params.model,
83
+ model: params.model,
100
84
  modelProvider,
101
85
  authProfileId,
102
- authProfileStore: preparedRuntimeAuth.authProfileStore,
103
86
  agentDir: params.agentDir,
104
87
  config: params.cfg
105
88
  });
106
89
  const reviewerPolicyContext = resolveCodexModelBackedReviewerPolicyContext({
107
- provider: usesSupervisionConnection ? "codex" : params.provider,
108
- model: supervisionModelSelection?.model ?? params.model,
90
+ provider: params.provider,
91
+ model: params.model,
109
92
  bindingModelProvider: binding.modelProvider,
110
93
  bindingModel: binding.model,
111
- nativeAuthProfile: usesSupervisionConnection || preparedNativeAuthProfile
94
+ nativeAuthProfile: isCodexAppServerNativeAuthProfile({
95
+ authProfileId,
96
+ agentDir: params.agentDir,
97
+ config: params.cfg
98
+ })
112
99
  });
113
- const connection = resolveCodexBindingAppServerConnection({
114
- binding,
115
- authProfileId,
100
+ const appServer = resolveCodexAppServerRuntimeOptions({
116
101
  pluginConfig,
117
102
  execPolicy,
118
103
  modelProvider: reviewerPolicyContext.modelProvider,
@@ -120,29 +105,9 @@ async function runCodexAppServerSideQuestion(params, options) {
120
105
  config: params.cfg,
121
106
  agentDir: params.agentDir
122
107
  });
123
- const appServer = connection.appServer;
124
108
  const cwd = binding.cwd || params.workspaceDir || process.cwd();
125
109
  const runId = params.opts?.runId ?? randomUUID();
126
- const effectiveParams = supervisionModelSelection ? {
127
- ...params,
128
- provider: supervisionModelSelection.modelProvider,
129
- model: supervisionModelSelection.model,
130
- runtimeModel: {
131
- id: supervisionModelSelection.model,
132
- name: supervisionModelSelection.model,
133
- provider: supervisionModelSelection.modelProvider,
134
- api: "openai-chatgpt-responses",
135
- reasoning: true,
136
- input: ["text", "image"],
137
- cost: {
138
- input: 0,
139
- output: 0,
140
- cacheRead: 0,
141
- cacheWrite: 0
142
- }
143
- }
144
- } : params;
145
- const sideRunParams = buildSideRunAttemptParams(effectiveParams, {
110
+ const sideRunParams = buildSideRunAttemptParams(params, {
146
111
  cwd,
147
112
  authProfileId,
148
113
  runId
@@ -156,17 +121,13 @@ async function runCodexAppServerSideQuestion(params, options) {
156
121
  if (nativeExecutionBlock) throw new Error(nativeExecutionBlock);
157
122
  const nativeToolSurfaceEnabled = shouldEnableCodexAppServerNativeToolSurface(sideRunParams);
158
123
  if (!nativeToolSurfaceEnabled) throw new Error("Codex-native /btw side-question mode is unavailable because the effective tool policy restricts Codex native tools for this session.");
159
- const clientOptions = {
124
+ const client = await getLeasedSharedCodexAppServerClient({
160
125
  startOptions: appServer.start,
161
126
  timeoutMs: appServer.requestTimeoutMs,
162
- authRequirement: preparedRuntimeAuth.plan.modelRoute?.authRequirement,
163
- ...startupPreparedAuth ? { preparedAuth: startupPreparedAuth } : { authProfileId: connection.clientAuthProfileId },
127
+ authProfileId,
164
128
  agentDir: params.agentDir,
165
- config: params.cfg,
166
- ...params.opts?.abortSignal ? { abandonSignal: params.opts.abortSignal } : {}
167
- };
168
- let client = await getLeasedSharedCodexAppServerClient(clientOptions);
169
- const clientLease = { client };
129
+ config: params.cfg
130
+ });
170
131
  const collector = new CodexSideQuestionCollector(params, () => readRecentCodexRateLimits(client));
171
132
  const runAbortController = new AbortController();
172
133
  let nativeToolLifecycleProjector;
@@ -196,7 +157,7 @@ async function runCodexAppServerSideQuestion(params, options) {
196
157
  }
197
158
  flushPendingNativePreToolUseFailures();
198
159
  };
199
- const handleNotification = (notification) => {
160
+ const removeNotificationHandler = client.addNotificationHandler((notification) => {
200
161
  collector.handleNotification(notification);
201
162
  if (notification.method !== "item/started" && notification.method !== "item/completed" && notification.method !== "rawResponseItem/completed" && notification.method !== "turn/completed") return;
202
163
  if (!nativeToolLifecycleProjector) {
@@ -204,8 +165,7 @@ async function runCodexAppServerSideQuestion(params, options) {
204
165
  return;
205
166
  }
206
167
  nativeToolLifecycleProjector.handleNotification(notification);
207
- };
208
- let removeNotificationHandler = client.addNotificationHandler(handleNotification);
168
+ });
209
169
  const abortFromUpstream = () => runAbortController.abort(params.opts?.abortSignal?.reason ?? "codex_side_question_abort");
210
170
  if (params.opts?.abortSignal?.aborted) abortFromUpstream();
211
171
  else params.opts?.abortSignal?.addEventListener("abort", abortFromUpstream, { once: true });
@@ -213,7 +173,6 @@ async function runCodexAppServerSideQuestion(params, options) {
213
173
  let turnId;
214
174
  let removeRequestHandler;
215
175
  let nativeHookRelay;
216
- const activeDynamicToolCalls = /* @__PURE__ */ new Set();
217
176
  try {
218
177
  const modelScopedAppServer = resolveCodexAppServerForModelProvider({
219
178
  appServer,
@@ -233,7 +192,7 @@ async function runCodexAppServerSideQuestion(params, options) {
233
192
  const approvalPolicy = useModelScopedPolicy ? modelScopedAppServer.approvalPolicy : binding.approvalPolicy ?? modelScopedAppServer.approvalPolicy;
234
193
  const sandbox = useModelScopedPolicy ? modelScopedAppServer.sandbox : binding.sandbox ?? modelScopedAppServer.sandbox;
235
194
  const { toolBridge, webSearchPlan } = await createCodexSideToolBridge({
236
- params: effectiveParams,
195
+ params,
237
196
  cwd,
238
197
  pluginConfig,
239
198
  sessionAgentId,
@@ -252,14 +211,10 @@ async function runCodexAppServerSideQuestion(params, options) {
252
211
  });
253
212
  ensureCodexAppServerClientRuntime(client, {
254
213
  agentDir: params.agentDir,
255
- authProfileId: startupPreparedAuth?.kind === "api-key" ? void 0 : connection.requestAuthProfileId,
256
- ...!usesSupervisionConnection ? {
257
- authProfileStore: preparedRuntimeAuth.authProfileStore,
258
- authMode: startupPreparedAuth?.kind === "api-key" ? "prepared-api-key" : "profile"
259
- } : {},
214
+ authProfileId,
260
215
  config: params.cfg
261
216
  });
262
- const registerRequestHandler = (targetClient) => targetClient.addRequestHandler(async (request) => {
217
+ removeRequestHandler = client.addRequestHandler(async (request) => {
263
218
  if (!childThreadId || !turnId) return;
264
219
  if (request.method === "mcpServer/elicitation/request") return handleCodexAppServerElicitationRequest({
265
220
  requestParams: request.params,
@@ -277,6 +232,9 @@ async function runCodexAppServerSideQuestion(params, options) {
277
232
  threadId: childThreadId,
278
233
  turnId,
279
234
  nativeHookRelay,
235
+ execPolicy,
236
+ execReviewerAgentId: sessionAgentId,
237
+ internalExecAutoReview: modelScopedAppServer.approvalsReviewer === "user",
280
238
  autoApprove: shouldAutoApproveCodexAppServerApprovals({
281
239
  approvalPolicy,
282
240
  networkProxy: modelScopedAppServer.networkProxy,
@@ -301,16 +259,13 @@ async function runCodexAppServerSideQuestion(params, options) {
301
259
  sessionKey: params.sessionKey
302
260
  };
303
261
  emitDynamicToolStartedDiagnostic(diagnosticContext);
304
- const toolCall = handleDynamicToolCallWithTimeout({
305
- call,
306
- toolBridge,
307
- signal: runAbortController.signal,
308
- timeoutMs,
309
- observeToolTerminal: sideRunParams.observeToolTerminal
310
- });
311
- activeDynamicToolCalls.add(toolCall);
312
262
  try {
313
- const response = await toolCall;
263
+ const response = await handleDynamicToolCallWithTimeout({
264
+ call,
265
+ toolBridge,
266
+ signal: runAbortController.signal,
267
+ timeoutMs
268
+ });
314
269
  emitDynamicToolTerminalDiagnostic({
315
270
  ...diagnosticContext,
316
271
  response,
@@ -327,23 +282,8 @@ async function runCodexAppServerSideQuestion(params, options) {
327
282
  terminalReason: runAbortController.signal.aborted ? resolveCodexToolAbortTerminalReason(runAbortController.signal) : "failed"
328
283
  });
329
284
  throw error;
330
- } finally {
331
- activeDynamicToolCalls.delete(toolCall);
332
285
  }
333
286
  });
334
- removeRequestHandler = registerRequestHandler(client);
335
- const rebindClientHandlers = (nextClient) => {
336
- removeRequestHandler?.();
337
- removeNotificationHandler();
338
- client = nextClient;
339
- ensureCodexAppServerClientRuntime(client, {
340
- agentDir: params.agentDir,
341
- authProfileId: connection.requestAuthProfileId,
342
- config: params.cfg
343
- });
344
- removeNotificationHandler = client.addNotificationHandler(handleNotification);
345
- removeRequestHandler = registerRequestHandler(client);
346
- };
347
287
  const serviceTier = binding.serviceTier ?? appServer.serviceTier;
348
288
  const nativeHookRelayEvents = resolveCodexSideNativeHookRelayEvents({
349
289
  configuredEvents: options.nativeHookRelay?.events,
@@ -365,7 +305,6 @@ async function runCodexAppServerSideQuestion(params, options) {
365
305
  }).channelId,
366
306
  requestTimeoutMs: appServer.requestTimeoutMs,
367
307
  completionTimeoutMs: Math.max(appServer.turnCompletionIdleTimeoutMs, SIDE_QUESTION_COMPLETION_TIMEOUT_MS),
368
- loopDetectionPreToolUseRelay: appServer.loopDetectionPreToolUseRelay,
369
308
  signal: runAbortController.signal,
370
309
  onPreToolUseFailure: (failure) => {
371
310
  if (nativePreToolUseFailureFallbackActive) emitNativePreToolUseFailure(failure);
@@ -377,36 +316,32 @@ async function runCodexAppServerSideQuestion(params, options) {
377
316
  relay: nativeHookRelay,
378
317
  events: nativeHookRelayEvents,
379
318
  hookTimeoutSec: options.nativeHookRelay?.hookTimeoutSec,
380
- clearOmittedEvents: true,
381
- loopDetectionPreToolUseRelay: appServer.loopDetectionPreToolUseRelay
319
+ clearOmittedEvents: true
382
320
  }) : options.nativeHookRelay?.enabled === false ? buildCodexNativeHookRelayDisabledConfig() : void 0;
383
321
  const runtimeThreadConfig = buildCodexRuntimeThreadConfig(webSearchPlan.threadConfig, {
384
322
  nativeCodeModeEnabled: nativeToolSurfaceEnabled,
385
323
  nativeCodeModeOnlyEnabled: appServer.codeModeOnly
386
324
  });
387
- const threadConfig = mergeCodexThreadConfigs(nativeHookRelayConfig, runtimeThreadConfig, binding.pluginAppPolicyContext ? buildCodexPluginAppsConfigPatchFromPolicyContext(binding.pluginAppPolicyContext) : void 0, modelScopedAppServer.networkProxy?.configPatch) ?? runtimeThreadConfig;
388
- const forkResponse = assertCodexThreadForkResponse(await withLeasedCodexAppServerClientStartSelectionRetry({
389
- lease: clientLease,
390
- options: clientOptions,
391
- signal: params.opts?.abortSignal,
392
- run: async (forkClient, requestOptions) => await forkCodexSideThread(forkClient, {
393
- threadId: binding.threadId,
394
- model: modelSelection.model,
395
- ...modelSelection.modelProvider ? { modelProvider: modelSelection.modelProvider } : {},
396
- cwd,
397
- approvalPolicy,
398
- approvalsReviewer: modelScopedAppServer.approvalsReviewer,
399
- ...modelScopedAppServer.networkProxy ? {} : { sandbox },
400
- ...serviceTier ? { serviceTier } : {},
401
- config: threadConfig,
402
- developerInstructions: SIDE_DEVELOPER_INSTRUCTIONS,
403
- ephemeral: true,
404
- threadSource: "user"
405
- }, requestOptions),
406
- onClientChange: rebindClientHandlers
407
- }));
408
- childThreadId = forkResponse.thread.id;
409
- if (supervisionModelSelection && (forkResponse.model !== supervisionModelSelection.model || forkResponse.modelProvider !== supervisionModelSelection.modelProvider)) throw new Error("Codex supervised side thread did not preserve its native model and provider");
325
+ const pluginAppsConfigPatch = binding.pluginAppPolicyContext ? buildCodexPluginAppsConfigPatchFromPolicyContext(binding.pluginAppPolicyContext) : void 0;
326
+ const threadConfig = mergeCodexThreadConfigs(nativeHookRelayConfig, runtimeThreadConfig, pluginAppsConfigPatch, modelScopedAppServer.networkProxy?.configPatch) ?? runtimeThreadConfig;
327
+ childThreadId = assertCodexThreadForkResponse(await forkCodexSideThread(client, {
328
+ threadId: binding.threadId,
329
+ model: modelSelection.model,
330
+ ...modelSelection.modelProvider ? { modelProvider: modelSelection.modelProvider } : {},
331
+ personality: CODEX_NATIVE_PERSONALITY_NONE,
332
+ cwd,
333
+ approvalPolicy,
334
+ approvalsReviewer: modelScopedAppServer.approvalsReviewer,
335
+ ...modelScopedAppServer.networkProxy ? {} : { sandbox },
336
+ ...serviceTier ? { serviceTier } : {},
337
+ config: threadConfig,
338
+ developerInstructions: SIDE_DEVELOPER_INSTRUCTIONS,
339
+ ephemeral: true,
340
+ threadSource: "user"
341
+ }, {
342
+ timeoutMs: appServer.requestTimeoutMs,
343
+ signal: params.opts?.abortSignal
344
+ })).thread.id;
410
345
  await client.request("thread/inject_items", {
411
346
  threadId: childThreadId,
412
347
  items: [sideBoundaryPromptItem()]
@@ -414,7 +349,7 @@ async function runCodexAppServerSideQuestion(params, options) {
414
349
  timeoutMs: appServer.requestTimeoutMs,
415
350
  signal: params.opts?.abortSignal
416
351
  });
417
- const effort = usesSupervisionConnection ? void 0 : resolveReasoningEffort(params.resolvedThinkLevel ?? "off", modelSelection.model, readCodexSupportedReasoningEfforts(params.runtimeModel?.compat));
352
+ const effort = resolveReasoningEffort(params.resolvedThinkLevel ?? "off", modelSelection.model, readCodexSupportedReasoningEfforts(params.runtimeModel?.compat));
418
353
  turnId = assertCodexTurnStartResponse(await client.request("turn/start", {
419
354
  threadId: childThreadId,
420
355
  input: [{
@@ -424,17 +359,15 @@ async function runCodexAppServerSideQuestion(params, options) {
424
359
  }],
425
360
  cwd,
426
361
  model: modelSelection.model,
427
- ...usesSupervisionConnection ? {} : { personality: CODEX_NATIVE_PERSONALITY_NONE },
362
+ personality: CODEX_NATIVE_PERSONALITY_NONE,
428
363
  ...serviceTier ? { serviceTier } : {},
429
- ...usesSupervisionConnection ? {} : {
430
- effort,
431
- collaborationMode: {
432
- mode: "default",
433
- settings: {
434
- model: modelSelection.model,
435
- reasoning_effort: effort,
436
- developer_instructions: null
437
- }
364
+ effort,
365
+ collaborationMode: {
366
+ mode: "default",
367
+ settings: {
368
+ model: modelSelection.model,
369
+ reasoning_effort: effort,
370
+ developer_instructions: null
438
371
  }
439
372
  }
440
373
  }, {
@@ -470,7 +403,6 @@ async function runCodexAppServerSideQuestion(params, options) {
470
403
  params.opts?.abortSignal?.removeEventListener("abort", abortFromUpstream);
471
404
  removeRequestHandler?.();
472
405
  if (!runAbortController.signal.aborted) runAbortController.abort("codex_side_question_finished");
473
- await Promise.allSettled(activeDynamicToolCalls);
474
406
  try {
475
407
  await cleanupCodexSideThread(client, {
476
408
  threadId: childThreadId,
@@ -488,7 +420,7 @@ async function runCodexAppServerSideQuestion(params, options) {
488
420
  }
489
421
  } finally {
490
422
  flushPendingNativePreToolUseFailures();
491
- releaseCodexAppServerClientLease(clientLease);
423
+ releaseLeasedSharedCodexAppServerClient(client);
492
424
  nativeHookRelay?.unregister();
493
425
  }
494
426
  }
@@ -508,7 +440,6 @@ function registerCodexSideNativeHookRelay(params) {
508
440
  runId: params.runId,
509
441
  ...params.channelId ? { channelId: params.channelId } : {},
510
442
  allowedEvents: params.events,
511
- preToolUseLoopDetection: params.loopDetectionPreToolUseRelay,
512
443
  ttlMs: resolveCodexSideNativeHookRelayTtlMs({
513
444
  explicitTtlMs: params.options.ttlMs,
514
445
  requestTimeoutMs: params.requestTimeoutMs,
@@ -542,12 +473,9 @@ function buildSideRunAttemptParams(params, options) {
542
473
  agentId: params.agentId,
543
474
  ...params.messageChannel ? { messageChannel: params.messageChannel } : {},
544
475
  ...params.messageProvider ? { messageProvider: params.messageProvider } : {},
545
- ...params.chatType ? { chatType: params.chatType } : {},
546
476
  ...params.agentAccountId ? { agentAccountId: params.agentAccountId } : {},
547
477
  ...params.messageTo ? { messageTo: params.messageTo } : {},
548
478
  ...params.messageThreadId !== void 0 ? { messageThreadId: params.messageThreadId } : {},
549
- ...params.chatId ? { chatId: params.chatId } : {},
550
- ...params.messageActionTurnCapability ? { messageActionTurnCapability: params.messageActionTurnCapability } : {},
551
479
  ...params.groupId !== void 0 ? { groupId: params.groupId } : {},
552
480
  ...params.groupChannel !== void 0 ? { groupChannel: params.groupChannel } : {},
553
481
  ...params.groupSpace !== void 0 ? { groupSpace: params.groupSpace } : {},
@@ -562,13 +490,12 @@ function buildSideRunAttemptParams(params, options) {
562
490
  ...params.toolsAllow ? { toolsAllow: params.toolsAllow } : {},
563
491
  workspaceDir: options.cwd,
564
492
  authProfileId: options.authProfileId,
565
- authProfileIdSource: options.authProfileId ? params.preparedRuntimeAuth.plan.forwardedAuthProfileSource : void 0,
493
+ authProfileIdSource: params.authProfileIdSource,
566
494
  thinkLevel: params.resolvedThinkLevel ?? "off",
567
495
  resolvedReasoningLevel: params.resolvedReasoningLevel,
568
- authStorage: params.preparedRuntimeAuth.authStorage,
569
- authProfileStore: params.preparedRuntimeAuth.authProfileStore,
570
- modelRegistry: params.preparedRuntimeAuth.modelRegistry,
571
- ...params.preparedRuntimeAuth.resolvedApiKey ? { resolvedApiKey: params.preparedRuntimeAuth.resolvedApiKey } : {},
496
+ authStorage: void 0,
497
+ authProfileStore: void 0,
498
+ modelRegistry: void 0,
572
499
  runId: options.runId,
573
500
  abortSignal: params.opts?.abortSignal,
574
501
  onAgentEvent: (event) => {
@@ -593,7 +520,7 @@ async function createCodexSideToolBridge(input) {
593
520
  sessionKey: sandboxSessionKey,
594
521
  workspaceDir: input.cwd
595
522
  });
596
- tools = filterToolsForVisionInputs(filterCodexDynamicTools(createOpenClawCodingTools({
523
+ const allTools = createOpenClawCodingTools({
597
524
  agentId: input.sessionAgentId,
598
525
  sessionKey: sandboxSessionKey,
599
526
  runSessionKey: input.params.sessionKey && input.params.sessionKey !== sandboxSessionKey ? input.params.sessionKey : void 0,
@@ -618,12 +545,9 @@ async function createCodexSideToolBridge(input) {
618
545
  messageProvider: messageToolProvider,
619
546
  toolPolicyMessageProvider: input.params.messageProvider ?? input.params.messageChannel
620
547
  } : {},
621
- ...input.params.chatType ? { chatType: input.params.chatType } : {},
622
548
  ...input.params.agentAccountId ? { agentAccountId: input.params.agentAccountId } : {},
623
549
  ...input.params.messageTo ? { messageTo: input.params.messageTo } : {},
624
550
  ...input.params.messageThreadId !== void 0 ? { messageThreadId: input.params.messageThreadId } : {},
625
- ...input.params.chatId ? { nativeChannelId: input.params.chatId } : {},
626
- ...input.params.messageActionTurnCapability ? { messageActionTurnCapability: input.params.messageActionTurnCapability } : {},
627
551
  ...input.params.groupId !== void 0 ? { groupId: input.params.groupId } : {},
628
552
  ...input.params.groupChannel !== void 0 ? { groupChannel: input.params.groupChannel } : {},
629
553
  ...input.params.groupSpace !== void 0 ? { groupSpace: input.params.groupSpace } : {},
@@ -645,7 +569,9 @@ async function createCodexSideToolBridge(input) {
645
569
  emitBeforeToolCallDiagnostics: false,
646
570
  modelHasVision: runtimeModel.input?.includes("image") ?? false,
647
571
  requireExplicitMessageTarget: true
648
- }), input.pluginConfig), {
572
+ });
573
+ const codexFilteredTools = filterCodexDynamicTools(allTools, input.pluginConfig);
574
+ tools = filterToolsForVisionInputs(codexFilteredTools, {
649
575
  modelHasVision: runtimeModel.input?.includes("image") ?? false,
650
576
  hasInboundImages: false
651
577
  });
@@ -660,7 +586,7 @@ async function createCodexSideToolBridge(input) {
660
586
  config: input.params.cfg,
661
587
  webSearchAllowed: false
662
588
  }) : requestedWebSearchPlan;
663
- const exposedTools = tools.filter((tool) => tool.name !== "web_search" && tool.name !== "computer");
589
+ const exposedTools = tools.filter((tool) => tool.name !== "web_search");
664
590
  const hookChannelFields = buildAgentHookContextChannelFields({
665
591
  sessionKey: input.params.sessionKey,
666
592
  messageChannel: input.params.messageChannel,
@@ -675,7 +601,6 @@ async function createCodexSideToolBridge(input) {
675
601
  hookContext: {
676
602
  agentId: input.sessionAgentId,
677
603
  config: input.params.cfg,
678
- contextWindowTokens: runtimeModel.contextWindow,
679
604
  sessionId: input.params.sessionId,
680
605
  sessionKey: input.params.sessionKey,
681
606
  runId: input.runId,