@openclaw/codex 2026.7.1 → 2026.7.2-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.
Files changed (48) hide show
  1. package/README.md +27 -3
  2. package/dist/app-server-policy-Scc-Wevo.js +49 -0
  3. package/dist/{attempt-notifications-BGsEIIDI.js → attempt-notifications-BFmNhqFl.js} +3 -6
  4. package/dist/auth-binding-C1czuHPA.js +62 -0
  5. package/dist/cli-metadata.js +20 -0
  6. package/dist/{app-server-policy-C968Kgin.js → command-formatters-Dq9InZUK.js} +39 -51
  7. package/dist/{command-handlers-Dv-pzAmg.js → command-handlers-IgqmL_kv.js} +161 -61
  8. package/dist/{compact-4mVBriKT.js → compact-DCTmg3id.js} +39 -10
  9. package/dist/computer-use-CPcU8TjG.js +685 -0
  10. package/dist/conversation-control-CGkBlfc5.js +286 -0
  11. package/dist/doctor-contract-api.js +120 -81
  12. package/dist/{provider-capabilities-CDnHbmUZ.js → dynamic-tools-C_1tEs34.js} +6109 -5725
  13. package/dist/harness.js +59 -15
  14. package/dist/index.js +1460 -269
  15. package/dist/{media-understanding-provider-BHOu9-Gg.js → media-understanding-provider-D31dOJwb.js} +32 -15
  16. package/dist/media-understanding-provider.js +1 -1
  17. package/dist/{models-DDmO1zwd.js → models-uh26C8QU.js} +5 -9
  18. package/dist/notification-correlation-KmfV4EkP.js +67 -0
  19. package/dist/plugin-app-cache-key-Ceb-lm2c.js +315 -0
  20. package/dist/{provider-zjPfx5Fs.js → rate-limits-DyXaYAxU.js} +10 -266
  21. package/dist/request-B_oQsCXy.js +157 -0
  22. package/dist/{run-attempt-FUyOjGCV.js → run-attempt-MLzoMe_m.js} +7395 -6430
  23. package/dist/runtime-artifact-C2ITXdhM.js +488 -0
  24. package/dist/{sandbox-guard-DA2TQfZW.js → sandbox-guard-D1Wky__S.js} +10 -1
  25. package/dist/{config-CYEDnLJ2.js → session-binding-h1mmCGnl.js} +985 -31
  26. package/dist/session-catalog-CEvoXWHA.js +2412 -0
  27. package/dist/session-cli-XsEuWb_C.js +175 -0
  28. package/dist/{shared-client-4ICy3U6d.js → shared-client-JiAnW6pc.js} +2193 -1319
  29. package/dist/{side-question-N4OaDer2.js → side-question-DqDvIwSU.js} +140 -70
  30. package/dist/{thread-lifecycle-qWE88Dn2.js → thread-lifecycle-CN_pPtPh.js} +1826 -1188
  31. package/dist/{protocol-validators-dZQ-UTOa.js → transcript-mirror-D9rTxx2P.js} +485 -2
  32. package/dist/transport-stdio-DXgGZ7Ib.js +88 -0
  33. package/dist/usage-D5Rohxoc.js +25 -0
  34. package/dist/{web-search-provider.runtime-BSlriav6.js → web-search-provider.runtime-CKVBn3fP.js} +3 -3
  35. package/npm-shrinkwrap.json +56 -30
  36. package/openclaw.plugin.json +177 -14
  37. package/package.json +8 -6
  38. package/dist/command-rpc-eLM_mtC7.js +0 -784
  39. package/dist/computer-use-Bmaz333N.js +0 -377
  40. package/dist/notification-correlation-Bo7KB3ks.js +0 -35
  41. package/dist/plugin-app-cache-key-BrhVdeEf.js +0 -98
  42. package/dist/prompt-overlay.js +0 -15
  43. package/dist/protocol-2POPqAY4.js +0 -13
  44. package/dist/provider-catalog.js +0 -79
  45. package/dist/provider-discovery.js +0 -34
  46. package/dist/provider.js +0 -2
  47. package/dist/request-BcJyl8KL.js +0 -36
  48. package/dist/session-binding-C1ZXdP-x.js +0 -627
@@ -1,14 +1,12 @@
1
- import { r as isJsonObject } from "./protocol-2POPqAY4.js";
2
- import { _ as shouldAutoApproveCodexAppServerApprovals, d as resolveCodexAppServerRuntimeOptions, g as resolveOpenClawExecPolicyForCodexAppServer, m as resolveCodexModelBackedReviewerPolicyContext, n as canUseCodexModelBackedApprovalsReviewerForModel, u as readCodexPluginConfig } from "./config-CYEDnLJ2.js";
3
- import { a as readCodexDynamicToolCallParams, c as readCodexTurn, i as assertCodexTurnStartResponse, t as assertCodexThreadForkResponse } from "./protocol-validators-dZQ-UTOa.js";
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-qWE88Dn2.js";
5
- import { a as readCodexSupportedReasoningEfforts, c as formatCodexUsageLimitErrorMessage } from "./provider-zjPfx5Fs.js";
6
- import { a as getLeasedSharedCodexAppServerClient, d as isCodexAppServerApprovalRequest, h as readRecentCodexRateLimits, o as releaseLeasedSharedCodexAppServerClient, p as ensureCodexAppServerClientRuntime } from "./shared-client-4ICy3U6d.js";
7
- import { i as isCodexAppServerNativeAuthProfile, s as sessionBindingIdentity } from "./session-binding-C1ZXdP-x.js";
8
- import { t as resolveCodexAppServerForModelProvider } from "./app-server-policy-C968Kgin.js";
9
- import { n as resolveCodexNativeExecutionBlock } from "./sandbox-guard-DA2TQfZW.js";
10
- import { n as readCodexNotificationThreadId, r as readCodexNotificationTurnId } from "./notification-correlation-Bo7KB3ks.js";
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-CDnHbmUZ.js";
1
+ import { B as isCodexAppServerApprovalRequest, T as resolveCodexAppServerPreparedAuthHandoff, Z as isJsonObject, a as getLeasedSharedCodexAppServerClient, g as ensureCodexAppServerClientRuntime, p as withLeasedCodexAppServerClientStartSelectionRetry, s as releaseCodexAppServerClientLease, v as readRecentCodexRateLimits } from "./shared-client-JiAnW6pc.js";
2
+ import { D as resolveOpenClawExecPolicyForCodexAppServer, O as shouldAutoApproveCodexAppServerApprovals, c as sessionBindingIdentity, p as canUseCodexModelBackedApprovalsReviewerForModel, w as resolveCodexModelBackedReviewerPolicyContext, y as readCodexPluginConfig } from "./session-binding-h1mmCGnl.js";
3
+ import { f as assertCodexTurnStartResponse, g as readCodexTurn, l as assertCodexThreadForkResponse, p as readCodexDynamicToolCallParams } from "./transcript-mirror-D9rTxx2P.js";
4
+ import { E as resolveCodexDynamicToolsLoading, J as mergeCodexThreadConfigs, W as buildCodexPluginAppsConfigPatchFromPolicyContext, _ as resolveCodexBindingModelProviderFallback, d as resolveCodexWebSearchPlan, h as resolveCodexAppServerRequestModelSelection, l as buildCodexRuntimeThreadConfig, m as resolveCodexAppServerModelProvider, p as CODEX_NATIVE_PERSONALITY_NONE, v as resolveReasoningEffort, x as filterCodexDynamicTools, y as readCodexSupportedReasoningEfforts } from "./thread-lifecycle-CN_pPtPh.js";
5
+ import { n as formatCodexUsageLimitErrorMessage } from "./rate-limits-DyXaYAxU.js";
6
+ import { t as resolveCodexAppServerForModelProvider } from "./app-server-policy-Scc-Wevo.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-KmfV4EkP.js";
9
+ import { A as CODEX_NATIVE_HOOK_RELAY_EVENTS, F as emitCodexNativePreToolUseFailureDiagnostic, M as buildCodexNativeHookRelayConfig, N as buildCodexNativeHookRelayDisabledConfig, S as filterToolsForVisionInputs, U as resolveDynamicToolCallTimeoutMs, Y as resolveCodexToolAbortTerminalReason, _ as resolveCodexMessageToolProvider, a as emitDynamicToolStartedDiagnostic, c as resolveCodexProviderWebSearchSupportForClient, i as emitDynamicToolErrorDiagnostic, k as CodexNativeToolLifecycleProjector, n as handleCodexAppServerApprovalRequest, o as emitDynamicToolTerminalDiagnostic, r as handleCodexAppServerElicitationRequest, t as createCodexDynamicToolBridge, y as shouldEnableCodexAppServerNativeToolSurface, z as handleDynamicToolCallWithTimeout } from "./dynamic-tools-C_1tEs34.js";
12
10
  import { randomUUID } from "node:crypto";
13
11
  import { loadExecApprovals } from "openclaw/plugin-sdk/exec-approvals-runtime";
14
12
  import { buildAgentHookContextChannelFields, embeddedAgentLog, formatErrorMessage, registerNativeHookRelay, resolveAgentDir, resolveAttemptSpawnWorkspaceDir, resolveModelAuthMode, resolveSandboxContext, resolveSessionAgentIds, supportsModelTools } from "openclaw/plugin-sdk/agent-harness-runtime";
@@ -67,10 +65,27 @@ async function runCodexAppServerSideQuestion(params, options) {
67
65
  config: params.cfg,
68
66
  agentId: sessionAgentId
69
67
  });
70
- const authProfileId = params.authProfileId ?? binding.authProfileId;
71
- const modelProvider = resolveCodexAppServerModelProvider({
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
+ config: params.cfg,
82
+ subscriptionProfileRequiredError: "Prepared Codex subscription route requires a scoped native OAuth or token profile.",
83
+ subscriptionProfileUnusableError: `Prepared Codex auth profile "${preparedRuntimeAuth.plan.forwardedAuthProfileId}" is unusable.`
84
+ });
85
+ const modelProvider = supervisionModelSelection ? supervisionModelSelection.modelProvider : resolveCodexAppServerModelProvider({
72
86
  provider: params.provider,
73
87
  authProfileId,
88
+ authProfileStore: preparedRuntimeAuth.authProfileStore,
74
89
  agentDir: params.agentDir,
75
90
  config: params.cfg
76
91
  }) ?? resolveCodexBindingModelProviderFallback({
@@ -80,24 +95,23 @@ async function runCodexAppServerSideQuestion(params, options) {
80
95
  bindingModelProvider: binding.modelProvider
81
96
  });
82
97
  const modelSelection = resolveCodexAppServerRequestModelSelection({
83
- model: params.model,
98
+ model: supervisionModelSelection?.model ?? params.model,
84
99
  modelProvider,
85
100
  authProfileId,
101
+ authProfileStore: preparedRuntimeAuth.authProfileStore,
86
102
  agentDir: params.agentDir,
87
103
  config: params.cfg
88
104
  });
89
105
  const reviewerPolicyContext = resolveCodexModelBackedReviewerPolicyContext({
90
- provider: params.provider,
91
- model: params.model,
106
+ provider: usesSupervisionConnection ? "codex" : params.provider,
107
+ model: supervisionModelSelection?.model ?? params.model,
92
108
  bindingModelProvider: binding.modelProvider,
93
109
  bindingModel: binding.model,
94
- nativeAuthProfile: isCodexAppServerNativeAuthProfile({
95
- authProfileId,
96
- agentDir: params.agentDir,
97
- config: params.cfg
98
- })
110
+ nativeAuthProfile: usesSupervisionConnection || preparedNativeAuthProfile
99
111
  });
100
- const appServer = resolveCodexAppServerRuntimeOptions({
112
+ const connection = resolveCodexBindingAppServerConnection({
113
+ binding,
114
+ authProfileId,
101
115
  pluginConfig,
102
116
  execPolicy,
103
117
  modelProvider: reviewerPolicyContext.modelProvider,
@@ -105,9 +119,29 @@ async function runCodexAppServerSideQuestion(params, options) {
105
119
  config: params.cfg,
106
120
  agentDir: params.agentDir
107
121
  });
122
+ const appServer = connection.appServer;
108
123
  const cwd = binding.cwd || params.workspaceDir || process.cwd();
109
124
  const runId = params.opts?.runId ?? randomUUID();
110
- const sideRunParams = buildSideRunAttemptParams(params, {
125
+ const effectiveParams = supervisionModelSelection ? {
126
+ ...params,
127
+ provider: supervisionModelSelection.modelProvider,
128
+ model: supervisionModelSelection.model,
129
+ runtimeModel: {
130
+ id: supervisionModelSelection.model,
131
+ name: supervisionModelSelection.model,
132
+ provider: supervisionModelSelection.modelProvider,
133
+ api: "openai-chatgpt-responses",
134
+ reasoning: true,
135
+ input: ["text", "image"],
136
+ cost: {
137
+ input: 0,
138
+ output: 0,
139
+ cacheRead: 0,
140
+ cacheWrite: 0
141
+ }
142
+ }
143
+ } : params;
144
+ const sideRunParams = buildSideRunAttemptParams(effectiveParams, {
111
145
  cwd,
112
146
  authProfileId,
113
147
  runId
@@ -121,13 +155,17 @@ async function runCodexAppServerSideQuestion(params, options) {
121
155
  if (nativeExecutionBlock) throw new Error(nativeExecutionBlock);
122
156
  const nativeToolSurfaceEnabled = shouldEnableCodexAppServerNativeToolSurface(sideRunParams);
123
157
  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.");
124
- const client = await getLeasedSharedCodexAppServerClient({
158
+ const clientOptions = {
125
159
  startOptions: appServer.start,
126
160
  timeoutMs: appServer.requestTimeoutMs,
127
- authProfileId,
161
+ authRequirement: preparedRuntimeAuth.plan.modelRoute?.authRequirement,
162
+ ...startupPreparedAuth ? { preparedAuth: startupPreparedAuth } : { authProfileId: connection.clientAuthProfileId },
128
163
  agentDir: params.agentDir,
129
- config: params.cfg
130
- });
164
+ config: params.cfg,
165
+ ...params.opts?.abortSignal ? { abandonSignal: params.opts.abortSignal } : {}
166
+ };
167
+ let client = await getLeasedSharedCodexAppServerClient(clientOptions);
168
+ const clientLease = { client };
131
169
  const collector = new CodexSideQuestionCollector(params, () => readRecentCodexRateLimits(client));
132
170
  const runAbortController = new AbortController();
133
171
  let nativeToolLifecycleProjector;
@@ -157,7 +195,7 @@ async function runCodexAppServerSideQuestion(params, options) {
157
195
  }
158
196
  flushPendingNativePreToolUseFailures();
159
197
  };
160
- const removeNotificationHandler = client.addNotificationHandler((notification) => {
198
+ const handleNotification = (notification) => {
161
199
  collector.handleNotification(notification);
162
200
  if (notification.method !== "item/started" && notification.method !== "item/completed" && notification.method !== "rawResponseItem/completed" && notification.method !== "turn/completed") return;
163
201
  if (!nativeToolLifecycleProjector) {
@@ -165,7 +203,8 @@ async function runCodexAppServerSideQuestion(params, options) {
165
203
  return;
166
204
  }
167
205
  nativeToolLifecycleProjector.handleNotification(notification);
168
- });
206
+ };
207
+ let removeNotificationHandler = client.addNotificationHandler(handleNotification);
169
208
  const abortFromUpstream = () => runAbortController.abort(params.opts?.abortSignal?.reason ?? "codex_side_question_abort");
170
209
  if (params.opts?.abortSignal?.aborted) abortFromUpstream();
171
210
  else params.opts?.abortSignal?.addEventListener("abort", abortFromUpstream, { once: true });
@@ -192,7 +231,7 @@ async function runCodexAppServerSideQuestion(params, options) {
192
231
  const approvalPolicy = useModelScopedPolicy ? modelScopedAppServer.approvalPolicy : binding.approvalPolicy ?? modelScopedAppServer.approvalPolicy;
193
232
  const sandbox = useModelScopedPolicy ? modelScopedAppServer.sandbox : binding.sandbox ?? modelScopedAppServer.sandbox;
194
233
  const { toolBridge, webSearchPlan } = await createCodexSideToolBridge({
195
- params,
234
+ params: effectiveParams,
196
235
  cwd,
197
236
  pluginConfig,
198
237
  sessionAgentId,
@@ -211,10 +250,14 @@ async function runCodexAppServerSideQuestion(params, options) {
211
250
  });
212
251
  ensureCodexAppServerClientRuntime(client, {
213
252
  agentDir: params.agentDir,
214
- authProfileId,
253
+ authProfileId: startupPreparedAuth?.kind === "api-key" ? void 0 : connection.requestAuthProfileId,
254
+ ...!usesSupervisionConnection ? {
255
+ authProfileStore: preparedRuntimeAuth.authProfileStore,
256
+ authMode: startupPreparedAuth?.kind === "api-key" ? "prepared-api-key" : "profile"
257
+ } : {},
215
258
  config: params.cfg
216
259
  });
217
- removeRequestHandler = client.addRequestHandler(async (request) => {
260
+ const registerRequestHandler = (targetClient) => targetClient.addRequestHandler(async (request) => {
218
261
  if (!childThreadId || !turnId) return;
219
262
  if (request.method === "mcpServer/elicitation/request") return handleCodexAppServerElicitationRequest({
220
263
  requestParams: request.params,
@@ -232,9 +275,6 @@ async function runCodexAppServerSideQuestion(params, options) {
232
275
  threadId: childThreadId,
233
276
  turnId,
234
277
  nativeHookRelay,
235
- execPolicy,
236
- execReviewerAgentId: sessionAgentId,
237
- internalExecAutoReview: modelScopedAppServer.approvalsReviewer === "user",
238
278
  autoApprove: shouldAutoApproveCodexAppServerApprovals({
239
279
  approvalPolicy,
240
280
  networkProxy: modelScopedAppServer.networkProxy,
@@ -264,7 +304,8 @@ async function runCodexAppServerSideQuestion(params, options) {
264
304
  call,
265
305
  toolBridge,
266
306
  signal: runAbortController.signal,
267
- timeoutMs
307
+ timeoutMs,
308
+ observeToolTerminal: sideRunParams.observeToolTerminal
268
309
  });
269
310
  emitDynamicToolTerminalDiagnostic({
270
311
  ...diagnosticContext,
@@ -284,6 +325,19 @@ async function runCodexAppServerSideQuestion(params, options) {
284
325
  throw error;
285
326
  }
286
327
  });
328
+ removeRequestHandler = registerRequestHandler(client);
329
+ const rebindClientHandlers = (nextClient) => {
330
+ removeRequestHandler?.();
331
+ removeNotificationHandler();
332
+ client = nextClient;
333
+ ensureCodexAppServerClientRuntime(client, {
334
+ agentDir: params.agentDir,
335
+ authProfileId: connection.requestAuthProfileId,
336
+ config: params.cfg
337
+ });
338
+ removeNotificationHandler = client.addNotificationHandler(handleNotification);
339
+ removeRequestHandler = registerRequestHandler(client);
340
+ };
287
341
  const serviceTier = binding.serviceTier ?? appServer.serviceTier;
288
342
  const nativeHookRelayEvents = resolveCodexSideNativeHookRelayEvents({
289
343
  configuredEvents: options.nativeHookRelay?.events,
@@ -305,6 +359,7 @@ async function runCodexAppServerSideQuestion(params, options) {
305
359
  }).channelId,
306
360
  requestTimeoutMs: appServer.requestTimeoutMs,
307
361
  completionTimeoutMs: Math.max(appServer.turnCompletionIdleTimeoutMs, SIDE_QUESTION_COMPLETION_TIMEOUT_MS),
362
+ loopDetectionPreToolUseRelay: appServer.loopDetectionPreToolUseRelay,
308
363
  signal: runAbortController.signal,
309
364
  onPreToolUseFailure: (failure) => {
310
365
  if (nativePreToolUseFailureFallbackActive) emitNativePreToolUseFailure(failure);
@@ -316,31 +371,36 @@ async function runCodexAppServerSideQuestion(params, options) {
316
371
  relay: nativeHookRelay,
317
372
  events: nativeHookRelayEvents,
318
373
  hookTimeoutSec: options.nativeHookRelay?.hookTimeoutSec,
319
- clearOmittedEvents: true
374
+ clearOmittedEvents: true,
375
+ loopDetectionPreToolUseRelay: appServer.loopDetectionPreToolUseRelay
320
376
  }) : options.nativeHookRelay?.enabled === false ? buildCodexNativeHookRelayDisabledConfig() : void 0;
321
377
  const runtimeThreadConfig = buildCodexRuntimeThreadConfig(webSearchPlan.threadConfig, {
322
378
  nativeCodeModeEnabled: nativeToolSurfaceEnabled,
323
379
  nativeCodeModeOnlyEnabled: appServer.codeModeOnly
324
380
  });
325
381
  const threadConfig = mergeCodexThreadConfigs(nativeHookRelayConfig, runtimeThreadConfig, binding.pluginAppPolicyContext ? buildCodexPluginAppsConfigPatchFromPolicyContext(binding.pluginAppPolicyContext) : void 0, modelScopedAppServer.networkProxy?.configPatch) ?? runtimeThreadConfig;
326
- childThreadId = assertCodexThreadForkResponse(await forkCodexSideThread(client, {
327
- threadId: binding.threadId,
328
- model: modelSelection.model,
329
- ...modelSelection.modelProvider ? { modelProvider: modelSelection.modelProvider } : {},
330
- personality: CODEX_NATIVE_PERSONALITY_NONE,
331
- cwd,
332
- approvalPolicy,
333
- approvalsReviewer: modelScopedAppServer.approvalsReviewer,
334
- ...modelScopedAppServer.networkProxy ? {} : { sandbox },
335
- ...serviceTier ? { serviceTier } : {},
336
- config: threadConfig,
337
- developerInstructions: SIDE_DEVELOPER_INSTRUCTIONS,
338
- ephemeral: true,
339
- threadSource: "user"
340
- }, {
341
- timeoutMs: appServer.requestTimeoutMs,
342
- signal: params.opts?.abortSignal
343
- })).thread.id;
382
+ const forkResponse = assertCodexThreadForkResponse(await withLeasedCodexAppServerClientStartSelectionRetry({
383
+ lease: clientLease,
384
+ options: clientOptions,
385
+ signal: params.opts?.abortSignal,
386
+ run: async (forkClient, requestOptions) => await forkCodexSideThread(forkClient, {
387
+ threadId: binding.threadId,
388
+ model: modelSelection.model,
389
+ ...modelSelection.modelProvider ? { modelProvider: modelSelection.modelProvider } : {},
390
+ cwd,
391
+ approvalPolicy,
392
+ approvalsReviewer: modelScopedAppServer.approvalsReviewer,
393
+ ...modelScopedAppServer.networkProxy ? {} : { sandbox },
394
+ ...serviceTier ? { serviceTier } : {},
395
+ config: threadConfig,
396
+ developerInstructions: SIDE_DEVELOPER_INSTRUCTIONS,
397
+ ephemeral: true,
398
+ threadSource: "user"
399
+ }, requestOptions),
400
+ onClientChange: rebindClientHandlers
401
+ }));
402
+ childThreadId = forkResponse.thread.id;
403
+ 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");
344
404
  await client.request("thread/inject_items", {
345
405
  threadId: childThreadId,
346
406
  items: [sideBoundaryPromptItem()]
@@ -348,7 +408,7 @@ async function runCodexAppServerSideQuestion(params, options) {
348
408
  timeoutMs: appServer.requestTimeoutMs,
349
409
  signal: params.opts?.abortSignal
350
410
  });
351
- const effort = resolveReasoningEffort(params.resolvedThinkLevel ?? "off", modelSelection.model, readCodexSupportedReasoningEfforts(params.runtimeModel?.compat));
411
+ const effort = usesSupervisionConnection ? void 0 : resolveReasoningEffort(params.resolvedThinkLevel ?? "off", modelSelection.model, readCodexSupportedReasoningEfforts(params.runtimeModel?.compat));
352
412
  turnId = assertCodexTurnStartResponse(await client.request("turn/start", {
353
413
  threadId: childThreadId,
354
414
  input: [{
@@ -358,15 +418,17 @@ async function runCodexAppServerSideQuestion(params, options) {
358
418
  }],
359
419
  cwd,
360
420
  model: modelSelection.model,
361
- personality: CODEX_NATIVE_PERSONALITY_NONE,
421
+ ...usesSupervisionConnection ? {} : { personality: CODEX_NATIVE_PERSONALITY_NONE },
362
422
  ...serviceTier ? { serviceTier } : {},
363
- effort,
364
- collaborationMode: {
365
- mode: "default",
366
- settings: {
367
- model: modelSelection.model,
368
- reasoning_effort: effort,
369
- developer_instructions: null
423
+ ...usesSupervisionConnection ? {} : {
424
+ effort,
425
+ collaborationMode: {
426
+ mode: "default",
427
+ settings: {
428
+ model: modelSelection.model,
429
+ reasoning_effort: effort,
430
+ developer_instructions: null
431
+ }
370
432
  }
371
433
  }
372
434
  }, {
@@ -419,7 +481,7 @@ async function runCodexAppServerSideQuestion(params, options) {
419
481
  }
420
482
  } finally {
421
483
  flushPendingNativePreToolUseFailures();
422
- releaseLeasedSharedCodexAppServerClient(client);
484
+ releaseCodexAppServerClientLease(clientLease);
423
485
  nativeHookRelay?.unregister();
424
486
  }
425
487
  }
@@ -439,6 +501,7 @@ function registerCodexSideNativeHookRelay(params) {
439
501
  runId: params.runId,
440
502
  ...params.channelId ? { channelId: params.channelId } : {},
441
503
  allowedEvents: params.events,
504
+ preToolUseLoopDetection: params.loopDetectionPreToolUseRelay,
442
505
  ttlMs: resolveCodexSideNativeHookRelayTtlMs({
443
506
  explicitTtlMs: params.options.ttlMs,
444
507
  requestTimeoutMs: params.requestTimeoutMs,
@@ -472,9 +535,12 @@ function buildSideRunAttemptParams(params, options) {
472
535
  agentId: params.agentId,
473
536
  ...params.messageChannel ? { messageChannel: params.messageChannel } : {},
474
537
  ...params.messageProvider ? { messageProvider: params.messageProvider } : {},
538
+ ...params.chatType ? { chatType: params.chatType } : {},
475
539
  ...params.agentAccountId ? { agentAccountId: params.agentAccountId } : {},
476
540
  ...params.messageTo ? { messageTo: params.messageTo } : {},
477
541
  ...params.messageThreadId !== void 0 ? { messageThreadId: params.messageThreadId } : {},
542
+ ...params.chatId ? { chatId: params.chatId } : {},
543
+ ...params.messageActionTurnCapability ? { messageActionTurnCapability: params.messageActionTurnCapability } : {},
478
544
  ...params.groupId !== void 0 ? { groupId: params.groupId } : {},
479
545
  ...params.groupChannel !== void 0 ? { groupChannel: params.groupChannel } : {},
480
546
  ...params.groupSpace !== void 0 ? { groupSpace: params.groupSpace } : {},
@@ -489,12 +555,13 @@ function buildSideRunAttemptParams(params, options) {
489
555
  ...params.toolsAllow ? { toolsAllow: params.toolsAllow } : {},
490
556
  workspaceDir: options.cwd,
491
557
  authProfileId: options.authProfileId,
492
- authProfileIdSource: params.authProfileIdSource,
558
+ authProfileIdSource: options.authProfileId ? params.preparedRuntimeAuth.plan.forwardedAuthProfileSource : void 0,
493
559
  thinkLevel: params.resolvedThinkLevel ?? "off",
494
560
  resolvedReasoningLevel: params.resolvedReasoningLevel,
495
- authStorage: void 0,
496
- authProfileStore: void 0,
497
- modelRegistry: void 0,
561
+ authStorage: params.preparedRuntimeAuth.authStorage,
562
+ authProfileStore: params.preparedRuntimeAuth.authProfileStore,
563
+ modelRegistry: params.preparedRuntimeAuth.modelRegistry,
564
+ ...params.preparedRuntimeAuth.resolvedApiKey ? { resolvedApiKey: params.preparedRuntimeAuth.resolvedApiKey } : {},
498
565
  runId: options.runId,
499
566
  abortSignal: params.opts?.abortSignal,
500
567
  onAgentEvent: (event) => {
@@ -544,9 +611,12 @@ async function createCodexSideToolBridge(input) {
544
611
  messageProvider: messageToolProvider,
545
612
  toolPolicyMessageProvider: input.params.messageProvider ?? input.params.messageChannel
546
613
  } : {},
614
+ ...input.params.chatType ? { chatType: input.params.chatType } : {},
547
615
  ...input.params.agentAccountId ? { agentAccountId: input.params.agentAccountId } : {},
548
616
  ...input.params.messageTo ? { messageTo: input.params.messageTo } : {},
549
617
  ...input.params.messageThreadId !== void 0 ? { messageThreadId: input.params.messageThreadId } : {},
618
+ ...input.params.chatId ? { nativeChannelId: input.params.chatId } : {},
619
+ ...input.params.messageActionTurnCapability ? { messageActionTurnCapability: input.params.messageActionTurnCapability } : {},
550
620
  ...input.params.groupId !== void 0 ? { groupId: input.params.groupId } : {},
551
621
  ...input.params.groupChannel !== void 0 ? { groupChannel: input.params.groupChannel } : {},
552
622
  ...input.params.groupSpace !== void 0 ? { groupSpace: input.params.groupSpace } : {},
@@ -583,7 +653,7 @@ async function createCodexSideToolBridge(input) {
583
653
  config: input.params.cfg,
584
654
  webSearchAllowed: false
585
655
  }) : requestedWebSearchPlan;
586
- const exposedTools = tools.filter((tool) => tool.name !== "web_search");
656
+ const exposedTools = tools.filter((tool) => tool.name !== "web_search" && tool.name !== "computer");
587
657
  const hookChannelFields = buildAgentHookContextChannelFields({
588
658
  sessionKey: input.params.sessionKey,
589
659
  messageChannel: input.params.messageChannel,