@openclaw/acpx 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.
@@ -22,7 +22,11 @@ function normalizeAcpxGatewayInstanceRecord(value) {
22
22
  * Persistent lease store for ACPX wrapper processes. Leases let OpenClaw attach
23
23
  * gateway/session identity to spawned ACP processes and clean them up later.
24
24
  */
25
- /** CLI argument carrying the ACPX process lease id. */
25
+ /** Environment variable carrying the ACPX process lease id. */
26
+ const OPENCLAW_ACPX_LEASE_ID_ENV = "OPENCLAW_ACPX_LEASE_ID";
27
+ /** Environment variable carrying the owning gateway instance id. */
28
+ const OPENCLAW_GATEWAY_INSTANCE_ID_ENV = "OPENCLAW_GATEWAY_INSTANCE_ID";
29
+ /** CLI argument carrying the ACPX process lease id for platforms without env wrapping. */
26
30
  const OPENCLAW_ACPX_LEASE_ID_ARG = "--openclaw-acpx-lease-id";
27
31
  /** CLI argument carrying the owning gateway instance id. */
28
32
  const OPENCLAW_GATEWAY_INSTANCE_ID_ARG = "--openclaw-gateway-instance-id";
@@ -123,9 +127,15 @@ function appendAcpxLeaseArgs(params) {
123
127
  quoteEnvValue(params.gatewayInstanceId)
124
128
  ].join(" ");
125
129
  }
126
- /** Add ACPX lease identity to a command through portable wrapper arguments. */
130
+ /** Add ACPX lease identity to a command through env vars and portable args. */
127
131
  function withAcpxLeaseEnvironment(params) {
128
- return appendAcpxLeaseArgs(params);
132
+ if ((params.platform ?? process.platform) === "win32") return appendAcpxLeaseArgs(params);
133
+ return [
134
+ "env",
135
+ `${OPENCLAW_ACPX_LEASE_ID_ENV}=${quoteEnvValue(params.leaseId)}`,
136
+ `${OPENCLAW_GATEWAY_INSTANCE_ID_ENV}=${quoteEnvValue(params.gatewayInstanceId)}`,
137
+ appendAcpxLeaseArgs(params)
138
+ ].join(" ");
129
139
  }
130
140
  //#endregion
131
- export { hashAcpxProcessCommand as a, openAcpxProcessLeaseStateStore as c, ACPX_GATEWAY_INSTANCE_NAMESPACE as d, ACPX_LEGACY_GATEWAY_INSTANCE_FILE as f, createAcpxProcessLeaseStore as i, withAcpxLeaseEnvironment as l, normalizeAcpxGatewayInstanceRecord as m, OPENCLAW_GATEWAY_INSTANCE_ID_ARG as n, normalizeAcpxProcessLease as o, ACPX_LEGACY_PROCESS_LEASE_FILE as p, createAcpxProcessLeaseId as r, normalizeAcpxProcessLeaseFile as s, OPENCLAW_ACPX_LEASE_ID_ARG as t, ACPX_GATEWAY_INSTANCE_KEY as u };
141
+ export { createAcpxProcessLeaseStore as a, normalizeAcpxProcessLeaseFile as c, ACPX_GATEWAY_INSTANCE_KEY as d, ACPX_GATEWAY_INSTANCE_NAMESPACE as f, normalizeAcpxGatewayInstanceRecord as h, createAcpxProcessLeaseId as i, openAcpxProcessLeaseStateStore as l, ACPX_LEGACY_PROCESS_LEASE_FILE as m, OPENCLAW_ACPX_LEASE_ID_ENV as n, hashAcpxProcessCommand as o, ACPX_LEGACY_GATEWAY_INSTANCE_FILE as p, OPENCLAW_GATEWAY_INSTANCE_ID_ARG as r, normalizeAcpxProcessLease as s, OPENCLAW_ACPX_LEASE_ID_ARG as t, withAcpxLeaseEnvironment as u };
@@ -200,7 +200,7 @@ function createLazyAcpRuntimeProxy(resolveRuntime) {
200
200
  * immediately, then imports the heavier service only when a session needs it.
201
201
  */
202
202
  const ACPX_BACKEND_ID = "acpx";
203
- const loadServiceModule = createLazyRuntimeModule(() => import("./service-DOsKw_R1.js"));
203
+ const loadServiceModule = createLazyRuntimeModule(() => import("./service-CE4bgxXH.mjs").then((n) => n.t));
204
204
  async function startRealService(state) {
205
205
  if (state.realRuntime) return state.realRuntime;
206
206
  if (!state.ctx) throw new Error("ACPX runtime service is not started");
@@ -1,20 +1,18 @@
1
- import { a as hashAcpxProcessCommand, l as withAcpxLeaseEnvironment, r as createAcpxProcessLeaseId } from "./process-lease-CU1cFI4I.js";
2
- import { AcpRuntimeError } from "./runtime-api.js";
3
- import { c as splitCommandParts, f as OPENCLAW_CODEX_CONFIG_ARG, n as isOpenClawLeaseAwareAcpxProcessCommand, t as cleanupOpenClawOwnedAcpxProcessTree, u as CODEX_ACP_PACKAGE } from "./process-reaper-BIOtp_Ek.js";
4
- import { parseStrictPositiveInteger } from "openclaw/plugin-sdk/number-runtime";
5
- import { normalizeStringEntries } from "openclaw/plugin-sdk/string-coerce-runtime";
6
- import { sliceUtf16Safe } from "openclaw/plugin-sdk/text-utility-runtime";
1
+ import { i as createAcpxProcessLeaseId, o as hashAcpxProcessCommand, u as withAcpxLeaseEnvironment } from "./process-lease-DiKkFj6F.mjs";
2
+ import { AcpRuntimeError } from "../runtime-api.js";
3
+ import { i as splitCommandParts, n as cleanupOpenClawOwnedAcpxProcessTree, r as isOpenClawLeaseAwareAcpxProcessCommand } from "./service-CE4bgxXH.mjs";
7
4
  import fs from "node:fs/promises";
8
5
  import path, { resolve } from "node:path";
6
+ import { normalizeStringEntries } from "openclaw/plugin-sdk/string-coerce-runtime";
9
7
  import { AsyncLocalStorage } from "node:async_hooks";
10
8
  import { ACPX_BACKEND_ID, AcpxRuntime as AcpxRuntime$1, createAcpRuntime, createAgentRegistry, createFileSessionStore, decodeAcpxRuntimeHandleState, encodeAcpxRuntimeHandleState, isRequestedModelUnsupportedError } from "acpx/runtime";
9
+ import { parseStrictPositiveInteger } from "openclaw/plugin-sdk/number-runtime";
11
10
  import { redactSensitiveText } from "openclaw/plugin-sdk/security-runtime";
12
11
  //#region extensions/acpx/src/runtime.ts
13
12
  /**
14
13
  * OpenClaw ACPX runtime adapter. It wraps the upstream acpx runtime with
15
14
  * OpenClaw session metadata, lease tracking, model scoping, and cleanup policy.
16
15
  */
17
- const ACPX_PLUGIN_TOOLS_MCP_SERVER_NAME = "openclaw-plugin-tools";
18
16
  const ACPX_OPENCLAW_TOOLS_MCP_SERVER_NAME = "openclaw-tools";
19
17
  const OPENCLAW_TOOLS_MCP_AGENT_SESSION_KEY_ENV = "OPENCLAW_TOOLS_MCP_AGENT_SESSION_KEY";
20
18
  function withOpenClawManagedTurnTimeout(input) {
@@ -50,7 +48,8 @@ function isGenericInternalAcpError(error) {
50
48
  async function readCodexWrapperStderrTail(params) {
51
49
  if (!params.wrapperRoot || !params.leaseId) return "";
52
50
  try {
53
- return compactDiagnosticText(redactSensitiveText(sliceUtf16Safe(await fs.readFile(path.join(params.wrapperRoot, codexWrapperStderrLogFileName(params.leaseId)), "utf8"), -6e3)));
51
+ const text = await fs.readFile(path.join(params.wrapperRoot, codexWrapperStderrLogFileName(params.leaseId)), "utf8");
52
+ return compactDiagnosticText(redactSensitiveText(text.slice(-6e3)));
54
53
  } catch {
55
54
  return "";
56
55
  }
@@ -166,6 +165,12 @@ const OPENCLAW_BRIDGE_SUBCOMMAND = "acp";
166
165
  const CODEX_ACP_AGENT_ID = "codex";
167
166
  const CODEX_ACP_OPENCLAW_PREFIX = "openai/";
168
167
  const CLAUDE_ACP_OPENCLAW_PREFIX = "anthropic/";
168
+ const CODEX_ACP_REASONING_EFFORTS = /* @__PURE__ */ new Set([
169
+ "low",
170
+ "medium",
171
+ "high",
172
+ "xhigh"
173
+ ]);
169
174
  const CODEX_ACP_THINKING_ALIASES = /* @__PURE__ */ new Map([
170
175
  ["off", void 0],
171
176
  ["minimal", "low"],
@@ -209,14 +214,9 @@ function isEnvAssignment(value) {
209
214
  return /^[A-Za-z_][A-Za-z0-9_]*=/.test(value);
210
215
  }
211
216
  function unwrapEnvCommand(parts) {
212
- const command = parts.at(0);
213
- if (!command || basename(command) !== "env") return parts;
217
+ if (!parts.length || basename(parts[0]) !== "env") return parts;
214
218
  let index = 1;
215
- while (true) {
216
- const part = parts.at(index);
217
- if (!part || !isEnvAssignment(part)) break;
218
- index += 1;
219
- }
219
+ while (index < parts.length && isEnvAssignment(parts[index])) index += 1;
220
220
  return parts.slice(index);
221
221
  }
222
222
  function matchesExecutableName(value, executableName) {
@@ -251,7 +251,7 @@ function isOpenClawBridgeCommand(command) {
251
251
  }
252
252
  function isCodexAcpCommand(command) {
253
253
  return isAcpCommand(command, {
254
- packageName: CODEX_ACP_PACKAGE,
254
+ packageName: "@zed-industries/codex-acp",
255
255
  executableName: "codex-acp"
256
256
  });
257
257
  }
@@ -280,50 +280,27 @@ function normalizeCodexAcpReasoningEffort(rawThinking) {
280
280
  if (!CODEX_ACP_THINKING_ALIASES.has(normalized)) failUnsupportedCodexAcpThinking(rawThinking ?? "");
281
281
  return CODEX_ACP_THINKING_ALIASES.get(normalized);
282
282
  }
283
- function isCodexAcpReasoningEffortAlias(value) {
284
- const normalized = value?.trim().toLowerCase();
285
- return Boolean(normalized && CODEX_ACP_THINKING_ALIASES.has(normalized));
286
- }
287
- function classifyCodexAcpModelRequest(rawModel, rawThinking) {
283
+ function normalizeCodexAcpModelOverride(rawModel, rawThinking) {
288
284
  const raw = rawModel?.trim();
289
285
  const thinkingReasoningEffort = normalizeCodexAcpReasoningEffort(rawThinking);
290
- const thinkingOnlyOverride = thinkingReasoningEffort ? { reasoningEffort: thinkingReasoningEffort } : void 0;
291
- if (!raw) return {
292
- kind: "override",
293
- override: thinkingOnlyOverride ?? {}
294
- };
286
+ if (!raw) return thinkingReasoningEffort ? { reasoningEffort: thinkingReasoningEffort } : void 0;
295
287
  let value = raw;
296
- let hadOpenAiQualifier = false;
297
- if (value.toLowerCase().startsWith(CODEX_ACP_OPENCLAW_PREFIX)) {
298
- value = value.slice(7);
299
- hadOpenAiQualifier = true;
300
- }
301
- let model = value.trim();
302
- let modelReasoningEffort;
303
- const slashIndex = value.lastIndexOf("/");
304
- if (slashIndex >= 0 && isCodexAcpReasoningEffortAlias(value.slice(slashIndex + 1))) {
305
- modelReasoningEffort = normalizeCodexAcpReasoningEffort(value.slice(slashIndex + 1));
306
- model = value.slice(0, slashIndex).trim();
307
- }
308
- if (hadOpenAiQualifier && (!model || model.includes("/"))) failUnsupportedCodexAcpModel(raw, `Codex ACP model "${raw}" is not supported. Use openai/<model> or <model>/<reasoning-effort>.`);
309
- if (!model || model.includes("/")) return thinkingOnlyOverride ? {
310
- kind: "unsupported",
311
- thinkingOverride: thinkingOnlyOverride
312
- } : { kind: "unsupported" };
288
+ if (value.toLowerCase().startsWith(CODEX_ACP_OPENCLAW_PREFIX)) value = value.slice(7);
289
+ const parts = value.split("/");
290
+ if (parts.length > 2) failUnsupportedCodexAcpModel(raw, `Codex ACP model "${raw}" is not supported. Use openai/<model> or <model>/<reasoning-effort>.`);
291
+ const model = (parts[0] ?? "").trim();
292
+ const modelReasoningEffort = normalizeCodexAcpReasoningEffort(parts[1]);
293
+ if (!model) failUnsupportedCodexAcpModel(raw, `Codex ACP model "${raw}" is not supported. Use openai/<model> or <model>/<reasoning-effort>.`);
313
294
  const reasoningEffort = thinkingReasoningEffort ?? modelReasoningEffort;
295
+ if (reasoningEffort && !CODEX_ACP_REASONING_EFFORTS.has(reasoningEffort)) failUnsupportedCodexAcpThinking(reasoningEffort);
314
296
  return {
315
- kind: "override",
316
- override: {
317
- model,
318
- ...reasoningEffort ? { reasoningEffort } : {}
319
- }
297
+ model,
298
+ ...reasoningEffort ? { reasoningEffort } : {}
320
299
  };
321
300
  }
322
- function withCodexSessionModel(input, override) {
323
- const next = { ...input };
324
- if (override?.model) next.model = override.model;
325
- else delete next.model;
326
- return next;
301
+ function codexAcpSessionModelId(override) {
302
+ if (!override.model) return "";
303
+ return override.reasoningEffort ? `${override.model}/${override.reasoningEffort}` : override.model;
327
304
  }
328
305
  function normalizeClaudeAcpModelOverride(rawModel) {
329
306
  const raw = rawModel?.trim();
@@ -338,9 +315,8 @@ function withAcpxSessionOptions(input) {
338
315
  ...existingOptions,
339
316
  model
340
317
  } : existingOptions;
341
- const { modelExplicit: _modelExplicit, ...rest } = input;
342
318
  return {
343
- ...rest,
319
+ ...input,
344
320
  ...sessionOptions ? { sessionOptions } : {}
345
321
  };
346
322
  }
@@ -363,12 +339,10 @@ function quoteShellArg(value) {
363
339
  return `'${value.replace(/'/g, "'\\''")}'`;
364
340
  }
365
341
  function appendCodexAcpConfigOverrides(command, override) {
366
- const config = {
367
- ...override.model ? { model: override.model } : {},
368
- ...override.reasoningEffort ? { model_reasoning_effort: override.reasoningEffort } : {}
369
- };
370
- if (Object.keys(config).length === 0) return command;
371
- return `${command} ${OPENCLAW_CODEX_CONFIG_ARG} ${quoteShellArg(JSON.stringify(config))}`;
342
+ const configArgs = override.model ? [`model=${override.model}`] : [];
343
+ if (override.reasoningEffort) configArgs.push(`model_reasoning_effort=${override.reasoningEffort}`);
344
+ if (configArgs.length === 0) return command;
345
+ return `${command} ${configArgs.map((arg) => `-c ${quoteShellArg(arg)}`).join(" ")}`;
372
346
  }
373
347
  function createModelScopedAgentRegistry(params) {
374
348
  return {
@@ -389,6 +363,13 @@ function resolveAgentCommand(params) {
389
363
  const resolvedCommand = params.agentRegistry.resolve(normalizedAgentName);
390
364
  return typeof resolvedCommand === "string" ? resolvedCommand.trim() || void 0 : void 0;
391
365
  }
366
+ function resolveProbeAgentName(options) {
367
+ const { probeAgent } = options;
368
+ return normalizeAgentName(typeof probeAgent === "string" ? probeAgent : void 0) ?? "codex";
369
+ }
370
+ function resolveAgentCommandForName(params) {
371
+ return resolveAgentCommand(params);
372
+ }
392
373
  function shouldUseBridgeSafeDelegateForCommand(command) {
393
374
  return isOpenClawBridgeCommand(command);
394
375
  }
@@ -396,14 +377,12 @@ function shouldUseDistinctBridgeDelegate(options) {
396
377
  const { mcpServers } = options;
397
378
  return Array.isArray(mcpServers) && mcpServers.length > 0;
398
379
  }
399
- function withManagedToolsMcpSessionEnv(params) {
380
+ function withOpenClawToolsMcpSessionEnv(params) {
400
381
  const sessionKey = params.sessionKey.trim();
401
- if (!params.pluginToolsEnabled && !params.openclawToolsEnabled || !sessionKey || !params.mcpServers?.length) return params.mcpServers;
382
+ if (!params.enabled || !sessionKey || !params.mcpServers?.length) return params.mcpServers;
402
383
  let changed = false;
403
384
  const nextServers = params.mcpServers.map((server) => {
404
- const isManagedPluginTools = params.pluginToolsEnabled && server.name === ACPX_PLUGIN_TOOLS_MCP_SERVER_NAME;
405
- const isManagedOpenClawTools = params.openclawToolsEnabled && server.name === ACPX_OPENCLAW_TOOLS_MCP_SERVER_NAME;
406
- if (!isManagedPluginTools && !isManagedOpenClawTools || !("command" in server)) return server;
385
+ if (server.name !== ACPX_OPENCLAW_TOOLS_MCP_SERVER_NAME || !("command" in server)) return server;
407
386
  changed = true;
408
387
  const env = [...server.env.filter((entry) => entry.name !== OPENCLAW_TOOLS_MCP_AGENT_SESSION_KEY_ENV), {
409
388
  name: OPENCLAW_TOOLS_MCP_AGENT_SESSION_KEY_ENV,
@@ -420,16 +399,14 @@ function withManagedToolsMcpSessionEnv(params) {
420
399
  var AcpxRuntime = class {
421
400
  constructor(options, testOptions) {
422
401
  this.codexAcpModelOverrideScope = new AsyncLocalStorage();
423
- this.managedToolsSessionDelegates = /* @__PURE__ */ new Map();
402
+ this.openclawToolsSessionDelegates = /* @__PURE__ */ new Map();
424
403
  this.launchLeaseScope = new AsyncLocalStorage();
425
404
  const { openclawProcessCleanup, ...delegateTestOptions } = testOptions ?? {};
426
405
  this.processCleanupDeps = openclawProcessCleanup;
427
406
  this.wrapperRoot = options.openclawWrapperRoot;
428
407
  this.gatewayInstanceId = options.openclawGatewayInstanceId;
429
408
  this.processLeaseStore = options.openclawProcessLeaseStore;
430
- this.pluginToolsMcpBridgeEnabled = options.pluginToolsMcpBridgeEnabled === true;
431
409
  this.openclawToolsMcpBridgeEnabled = options.openclawToolsMcpBridgeEnabled === true;
432
- this.managedToolsMcpBridgeEnabled = this.pluginToolsMcpBridgeEnabled || this.openclawToolsMcpBridgeEnabled;
433
410
  this.cwd = options.cwd;
434
411
  this.sessionStore = createResetAwareSessionStore(options.sessionStore, {
435
412
  gatewayInstanceId: this.gatewayInstanceId,
@@ -454,40 +431,44 @@ var AcpxRuntime = class {
454
431
  ...sharedOptions,
455
432
  mcpServers: []
456
433
  }, this.delegateTestOptions) : this.delegate;
457
- const probeCommand = resolveAgentCommand({
458
- agentName: normalizeAgentName(options.probeAgent) ?? "codex",
434
+ this.probeDelegate = this.openclawToolsMcpBridgeEnabled ? this.bridgeSafeDelegate : this.resolveDelegateForAgent(resolveProbeAgentName(options));
435
+ }
436
+ resolveDelegateForAgent(agentName) {
437
+ const command = resolveAgentCommandForName({
438
+ agentName,
459
439
  agentRegistry: this.agentRegistry
460
440
  });
461
- const useBridgeSafeProbe = this.managedToolsMcpBridgeEnabled || shouldUseBridgeSafeDelegateForCommand(probeCommand);
462
- this.probeDelegate = useBridgeSafeProbe ? this.bridgeSafeDelegate : this.delegate;
441
+ return this.resolveDelegateForCommand(command);
442
+ }
443
+ resolveDelegateForCommand(command) {
444
+ return shouldUseBridgeSafeDelegateForCommand(command) ? this.bridgeSafeDelegate : this.delegate;
463
445
  }
464
446
  resolveDelegateForSession(params) {
465
447
  if (shouldUseBridgeSafeDelegateForCommand(params.command)) return this.bridgeSafeDelegate;
466
- return this.resolveManagedToolsDelegateForSession(params.sessionKey);
448
+ return this.resolveOpenClawToolsDelegateForSession(params.sessionKey);
467
449
  }
468
- resolveManagedToolsDelegateForSession(sessionKey) {
469
- if (!this.managedToolsMcpBridgeEnabled) return this.delegate;
450
+ resolveOpenClawToolsDelegateForSession(sessionKey) {
451
+ if (!this.openclawToolsMcpBridgeEnabled) return this.delegate;
470
452
  const normalizedSessionKey = sessionKey.trim();
471
453
  if (!normalizedSessionKey) return this.delegate;
472
- const cached = this.managedToolsSessionDelegates.get(normalizedSessionKey);
454
+ const cached = this.openclawToolsSessionDelegates.get(normalizedSessionKey);
473
455
  if (cached) return cached;
474
456
  const delegate = new AcpxRuntime$1({
475
457
  ...this.delegateOptions,
476
- mcpServers: withManagedToolsMcpSessionEnv({
477
- pluginToolsEnabled: this.pluginToolsMcpBridgeEnabled,
478
- openclawToolsEnabled: this.openclawToolsMcpBridgeEnabled,
458
+ mcpServers: withOpenClawToolsMcpSessionEnv({
459
+ enabled: this.openclawToolsMcpBridgeEnabled,
479
460
  mcpServers: this.delegateOptions.mcpServers,
480
461
  sessionKey: normalizedSessionKey
481
462
  })
482
463
  }, this.delegateTestOptions);
483
- this.managedToolsSessionDelegates.set(normalizedSessionKey, delegate);
464
+ this.openclawToolsSessionDelegates.set(normalizedSessionKey, delegate);
484
465
  return delegate;
485
466
  }
486
- releaseManagedToolsDelegateForSession(sessionKey) {
487
- if (!this.managedToolsMcpBridgeEnabled) return;
467
+ releaseOpenClawToolsDelegateForSession(sessionKey) {
468
+ if (!this.openclawToolsMcpBridgeEnabled) return;
488
469
  const normalizedSessionKey = sessionKey.trim();
489
470
  if (!normalizedSessionKey) return;
490
- this.managedToolsSessionDelegates.delete(normalizedSessionKey);
471
+ this.openclawToolsSessionDelegates.delete(normalizedSessionKey);
491
472
  }
492
473
  async resolveDelegateForHandle(handle) {
493
474
  const record = await this.sessionStore.load(handle.acpxRecordId ?? handle.sessionKey);
@@ -499,7 +480,7 @@ var AcpxRuntime = class {
499
480
  command: recordCommand,
500
481
  sessionKey: handle.sessionKey
501
482
  });
502
- const command = resolveAgentCommand({
483
+ const command = resolveAgentCommandForName({
503
484
  agentName: readAgentFromHandle(handle),
504
485
  agentRegistry: this.agentRegistry
505
486
  });
@@ -511,7 +492,7 @@ var AcpxRuntime = class {
511
492
  async resolveCommandForHandle(handle) {
512
493
  const recordCommand = readAgentCommandFromRecord(await this.sessionStore.load(handle.acpxRecordId ?? handle.sessionKey));
513
494
  if (recordCommand) return recordCommand;
514
- return resolveAgentCommand({
495
+ return resolveAgentCommandForName({
515
496
  agentName: readAgentFromHandle(handle),
516
497
  agentRegistry: this.agentRegistry
517
498
  });
@@ -605,7 +586,7 @@ var AcpxRuntime = class {
605
586
  await this.processLeaseStore?.markState(lease.leaseId, result.terminatedPids.length > 0 || result.skippedReason === "missing-root" ? "closed" : "lost");
606
587
  return;
607
588
  }
608
- const rootCommand = readAgentCommandFromRecord(record) ?? resolveAgentCommand({
589
+ const rootCommand = readAgentCommandFromRecord(record) ?? resolveAgentCommandForName({
609
590
  agentName: readAgentFromHandle(handle),
610
591
  agentRegistry: this.agentRegistry
611
592
  });
@@ -631,7 +612,7 @@ var AcpxRuntime = class {
631
612
  }
632
613
  async ensureSession(input) {
633
614
  assertSupportedRuntimeSessionMode(input.mode);
634
- const command = resolveAgentCommand({
615
+ const command = resolveAgentCommandForName({
635
616
  agentName: input.agent,
636
617
  agentRegistry: this.agentRegistry
637
618
  });
@@ -639,18 +620,9 @@ var AcpxRuntime = class {
639
620
  command,
640
621
  sessionKey: input.sessionKey
641
622
  });
642
- const isCodexAcp = normalizeAgentName(input.agent) === CODEX_ACP_AGENT_ID && isCodexAcpCommand(command);
643
623
  const claudeModelOverride = isClaudeAcpCommand(command) ? normalizeClaudeAcpModelOverride(input.model) : void 0;
644
- const codexClassification = isCodexAcp ? classifyCodexAcpModelRequest(input.model, input.thinking) : void 0;
645
- if (codexClassification?.kind === "unsupported" && input.modelExplicit) failUnsupportedCodexAcpModel(input.model ?? "");
646
- const classifiedCodexOverride = codexClassification?.kind === "override" ? codexClassification.override : codexClassification?.thinkingOverride;
647
- const codexModelOverride = classifiedCodexOverride && Object.keys(classifiedCodexOverride).length > 0 ? classifiedCodexOverride : void 0;
648
- const requestedModel = input.model?.trim();
649
- const appliedModel = isCodexAcp && requestedModel ? codexModelOverride?.model ? {
650
- kind: "applied",
651
- model: requestedModel
652
- } : { kind: "dropped" } : void 0;
653
- const ensureInput = isCodexAcp ? withCodexSessionModel(input, codexModelOverride) : claudeModelOverride ? {
624
+ const codexModelOverride = normalizeAgentName(input.agent) === CODEX_ACP_AGENT_ID && isCodexAcpCommand(command) ? normalizeCodexAcpModelOverride(input.model, input.thinking) : void 0;
625
+ const ensureInput = claudeModelOverride ? {
654
626
  ...input,
655
627
  model: claudeModelOverride
656
628
  } : input;
@@ -662,7 +634,7 @@ var AcpxRuntime = class {
662
634
  command: stableLaunchCommand,
663
635
  resumeSessionId: input.resumeSessionId
664
636
  });
665
- const handle = !codexModelOverride ? await this.runWithLaunchLease({
637
+ if (!codexModelOverride) return await this.runWithLaunchLease({
666
638
  sessionKey: ensureInput.sessionKey,
667
639
  command: stableLaunchCommand,
668
640
  enabled: shouldStartWithLease,
@@ -671,20 +643,21 @@ var AcpxRuntime = class {
671
643
  fallbackCode: "ACP_SESSION_INIT_FAILED",
672
644
  run: () => ensureDelegateSessionWithModelFallback(delegate, ensureInput)
673
645
  })
674
- }) : await this.runWithLaunchLease({
646
+ });
647
+ const normalizedInput = {
648
+ ...ensureInput,
649
+ ...codexAcpSessionModelId(codexModelOverride) ? { model: codexAcpSessionModelId(codexModelOverride) } : {}
650
+ };
651
+ return await this.runWithLaunchLease({
675
652
  sessionKey: input.sessionKey,
676
653
  command: stableLaunchCommand,
677
654
  enabled: shouldStartWithLease,
678
655
  run: () => this.codexAcpModelOverrideScope.run(codexModelOverride, () => this.withCodexWrapperDiagnostics({
679
656
  command: stableLaunchCommand,
680
657
  fallbackCode: "ACP_SESSION_INIT_FAILED",
681
- run: () => delegate.ensureSession(withAcpxSessionOptions(ensureInput))
658
+ run: () => delegate.ensureSession(withAcpxSessionOptions(normalizedInput))
682
659
  }))
683
660
  });
684
- return appliedModel ? {
685
- ...handle,
686
- appliedModel
687
- } : handle;
688
661
  }
689
662
  async *runTurn(input) {
690
663
  const command = await this.resolveCommandForHandle(input.handle);
@@ -785,8 +758,8 @@ var AcpxRuntime = class {
785
758
  }
786
759
  };
787
760
  }
788
- getCapabilities(input) {
789
- return this.delegate.getCapabilities(input);
761
+ getCapabilities() {
762
+ return this.delegate.getCapabilities();
790
763
  }
791
764
  async getStatus(input) {
792
765
  return (await this.resolveDelegateForHandle(input.handle)).getStatus(input);
@@ -801,32 +774,22 @@ var AcpxRuntime = class {
801
774
  const isCodexAcp = isCodexAcpCommand(command);
802
775
  if (WIRE_TIMEOUT_CONFIG_KEYS.has(key) && (isCodexAcp || isClaudeAcpCommand(command))) return;
803
776
  if (isCodexAcp) {
804
- if (key === "model") {
805
- const classification = classifyCodexAcpModelRequest(input.value);
806
- if (classification.kind === "unsupported") failUnsupportedCodexAcpModel(input.value);
807
- const { override } = classification;
808
- if (override.model) await delegate.setConfigOption({
809
- ...input,
810
- key: "model",
811
- value: override.model
812
- });
813
- if (override.reasoningEffort) await delegate.setConfigOption({
814
- ...input,
815
- key: "reasoning_effort",
816
- value: override.reasoningEffort
817
- });
818
- return;
819
- }
820
- if (key === "thinking" || key === "thought_level" || key === "reasoning_effort") {
821
- const classification = classifyCodexAcpModelRequest(void 0, input.value);
822
- const reasoningEffort = classification.kind === "override" ? classification.override.reasoningEffort : void 0;
823
- if (!reasoningEffort) return;
824
- await delegate.setConfigOption({
825
- ...input,
826
- key: "reasoning_effort",
827
- value: reasoningEffort
828
- });
829
- return;
777
+ if (key === "model" || key === "thinking" || key === "thought_level" || key === "reasoning_effort") {
778
+ const override = key === "model" ? normalizeCodexAcpModelOverride(input.value) : normalizeCodexAcpModelOverride(void 0, input.value);
779
+ if (!override && key !== "model") return;
780
+ if (override) {
781
+ if (override.model) await delegate.setConfigOption({
782
+ ...input,
783
+ key: "model",
784
+ value: override.model
785
+ });
786
+ if (override.reasoningEffort) await delegate.setConfigOption({
787
+ ...input,
788
+ key: "reasoning_effort",
789
+ value: override.reasoningEffort
790
+ });
791
+ return;
792
+ }
830
793
  }
831
794
  }
832
795
  if (isClaudeAcpCommand(command) && key === "model") {
@@ -859,7 +822,7 @@ var AcpxRuntime = class {
859
822
  } finally {
860
823
  await this.cleanupProcessTreeForRecord(input.handle, record);
861
824
  }
862
- if (closeSucceeded) this.releaseManagedToolsDelegateForSession(input.handle.sessionKey);
825
+ if (closeSucceeded) this.releaseOpenClawToolsDelegateForSession(input.handle.sessionKey);
863
826
  if (closeSucceeded && input.discardPersistentState) this.sessionStore.markFresh(input.handle.sessionKey);
864
827
  }
865
828
  };
@@ -867,10 +830,11 @@ var AcpxRuntime = class {
867
830
  const testing = {
868
831
  appendCodexAcpConfigOverrides,
869
832
  assertSupportedRuntimeSessionMode,
870
- classifyCodexAcpModelRequest,
833
+ codexAcpSessionModelId,
871
834
  isClaudeAcpCommand,
872
835
  isCodexAcpCommand,
873
- normalizeClaudeAcpModelOverride
836
+ normalizeClaudeAcpModelOverride,
837
+ normalizeCodexAcpModelOverride
874
838
  };
875
839
  //#endregion
876
840
  export { ACPX_BACKEND_ID, AcpxRuntime, testing as __testing, testing, createAcpRuntime, createAgentRegistry, createFileSessionStore, decodeAcpxRuntimeHandleState, encodeAcpxRuntimeHandleState };