@openclaw/acpx 2026.6.11 → 2026.7.1-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.
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { t as createAcpxRuntimeService } from "./register.runtime-CmYbf9SF.js";
1
+ import { t as createAcpxRuntimeService } from "./register.runtime-Bcp4wC4g.js";
2
2
  import { tryDispatchAcpReplyHook } from "openclaw/plugin-sdk/acp-runtime-backend";
3
3
  //#region extensions/acpx/index.ts
4
4
  /**
@@ -1,17 +1,11 @@
1
1
  import { getAcpRuntimeBackend, registerAcpRuntimeBackend, unregisterAcpRuntimeBackend } from "openclaw/plugin-sdk/acp-runtime-backend";
2
+ import { createLazyRuntimeModule } from "openclaw/plugin-sdk/lazy-runtime";
3
+ import { createDeferred } from "openclaw/plugin-sdk/extension-shared";
2
4
  //#region extensions/acpx/src/runtime-turn.ts
3
- function createDeferredResult() {
4
- let resolve;
5
- let reject;
6
- return {
7
- promise: new Promise((resolvePromise, rejectPromise) => {
8
- resolve = resolvePromise;
9
- reject = rejectPromise;
10
- }),
11
- resolve,
12
- reject
13
- };
14
- }
5
+ /**
6
+ * ACPX turn adapters. Modern runtimes can expose startTurn directly; legacy
7
+ * runtimes that only stream runTurn events are adapted to the newer contract.
8
+ */
15
9
  var LegacyRunTurnEventQueue = class {
16
10
  constructor() {
17
11
  this.items = [];
@@ -62,7 +56,7 @@ var LegacyRunTurnEventQueue = class {
62
56
  }
63
57
  };
64
58
  function legacyRunTurnAsStartTurn(runtime, input) {
65
- const result = createDeferredResult();
59
+ const result = createDeferred();
66
60
  result.promise.catch(() => {});
67
61
  const queue = new LegacyRunTurnEventQueue();
68
62
  let resultSettled = false;
@@ -203,11 +197,7 @@ function createLazyAcpRuntimeProxy(resolveRuntime) {
203
197
  * immediately, then imports the heavier service only when a session needs it.
204
198
  */
205
199
  const ACPX_BACKEND_ID = "acpx";
206
- let serviceModulePromise = null;
207
- function loadServiceModule() {
208
- serviceModulePromise ??= import("./service-BqMIPoSJ.js");
209
- return serviceModulePromise;
210
- }
200
+ const loadServiceModule = createLazyRuntimeModule(() => import("./service-DrBh86Oc.js"));
211
201
  async function startRealService(state) {
212
202
  if (state.realRuntime) return state.realRuntime;
213
203
  if (!state.ctx) throw new Error("ACPX runtime service is not started");
@@ -1,2 +1,2 @@
1
- import { t as createAcpxRuntimeService } from "./register.runtime-CmYbf9SF.js";
1
+ import { t as createAcpxRuntimeService } from "./register.runtime-Bcp4wC4g.js";
2
2
  export { createAcpxRuntimeService };
@@ -1,6 +1,6 @@
1
1
  import { i as createAcpxProcessLeaseId, o as hashAcpxProcessCommand, u as withAcpxLeaseEnvironment } from "./process-lease-DiKkFj6F.js";
2
2
  import { AcpRuntimeError } from "./runtime-api.js";
3
- import { c as splitCommandParts, n as isOpenClawLeaseAwareAcpxProcessCommand, t as cleanupOpenClawOwnedAcpxProcessTree } from "./process-reaper-Dv_iMcOo.js";
3
+ import { c as splitCommandParts, n as isOpenClawLeaseAwareAcpxProcessCommand, t as cleanupOpenClawOwnedAcpxProcessTree } from "./process-reaper-_ttV4L1d.js";
4
4
  import fs from "node:fs/promises";
5
5
  import path, { resolve } from "node:path";
6
6
  import { normalizeStringEntries } from "openclaw/plugin-sdk/string-coerce-runtime";
@@ -13,6 +13,8 @@ import { redactSensitiveText } from "openclaw/plugin-sdk/security-runtime";
13
13
  * OpenClaw ACPX runtime adapter. It wraps the upstream acpx runtime with
14
14
  * OpenClaw session metadata, lease tracking, model scoping, and cleanup policy.
15
15
  */
16
+ const ACPX_OPENCLAW_TOOLS_MCP_SERVER_NAME = "openclaw-tools";
17
+ const OPENCLAW_TOOLS_MCP_AGENT_SESSION_KEY_ENV = "OPENCLAW_TOOLS_MCP_AGENT_SESSION_KEY";
16
18
  function withOpenClawManagedTurnTimeout(input) {
17
19
  return {
18
20
  ...input,
@@ -374,16 +376,36 @@ function shouldUseDistinctBridgeDelegate(options) {
374
376
  const { mcpServers } = options;
375
377
  return Array.isArray(mcpServers) && mcpServers.length > 0;
376
378
  }
379
+ function withOpenClawToolsMcpSessionEnv(params) {
380
+ const sessionKey = params.sessionKey.trim();
381
+ if (!params.enabled || !sessionKey || !params.mcpServers?.length) return params.mcpServers;
382
+ let changed = false;
383
+ const nextServers = params.mcpServers.map((server) => {
384
+ if (server.name !== ACPX_OPENCLAW_TOOLS_MCP_SERVER_NAME || !("command" in server)) return server;
385
+ changed = true;
386
+ const env = [...server.env.filter((entry) => entry.name !== OPENCLAW_TOOLS_MCP_AGENT_SESSION_KEY_ENV), {
387
+ name: OPENCLAW_TOOLS_MCP_AGENT_SESSION_KEY_ENV,
388
+ value: sessionKey
389
+ }];
390
+ return {
391
+ ...server,
392
+ env
393
+ };
394
+ });
395
+ return changed ? nextServers : params.mcpServers;
396
+ }
377
397
  /** OpenClaw-managed ACP runtime implementation backed by the upstream acpx runtime. */
378
398
  var AcpxRuntime = class {
379
399
  constructor(options, testOptions) {
380
400
  this.codexAcpModelOverrideScope = new AsyncLocalStorage();
401
+ this.openclawToolsSessionDelegates = /* @__PURE__ */ new Map();
381
402
  this.launchLeaseScope = new AsyncLocalStorage();
382
403
  const { openclawProcessCleanup, ...delegateTestOptions } = testOptions ?? {};
383
404
  this.processCleanupDeps = openclawProcessCleanup;
384
405
  this.wrapperRoot = options.openclawWrapperRoot;
385
406
  this.gatewayInstanceId = options.openclawGatewayInstanceId;
386
407
  this.processLeaseStore = options.openclawProcessLeaseStore;
408
+ this.openclawToolsMcpBridgeEnabled = options.openclawToolsMcpBridgeEnabled === true;
387
409
  this.cwd = options.cwd;
388
410
  this.sessionStore = createResetAwareSessionStore(options.sessionStore, {
389
411
  gatewayInstanceId: this.gatewayInstanceId,
@@ -401,12 +423,14 @@ var AcpxRuntime = class {
401
423
  sessionStore: this.sessionStore,
402
424
  agentRegistry: this.scopedAgentRegistry
403
425
  };
404
- this.delegate = new AcpxRuntime$1(sharedOptions, delegateTestOptions);
426
+ this.delegateOptions = sharedOptions;
427
+ this.delegateTestOptions = delegateTestOptions;
428
+ this.delegate = new AcpxRuntime$1(sharedOptions, this.delegateTestOptions);
405
429
  this.bridgeSafeDelegate = shouldUseDistinctBridgeDelegate(options) ? new AcpxRuntime$1({
406
430
  ...sharedOptions,
407
431
  mcpServers: []
408
- }, delegateTestOptions) : this.delegate;
409
- this.probeDelegate = this.resolveDelegateForAgent(resolveProbeAgentName(options));
432
+ }, this.delegateTestOptions) : this.delegate;
433
+ this.probeDelegate = this.openclawToolsMcpBridgeEnabled ? this.bridgeSafeDelegate : this.resolveDelegateForAgent(resolveProbeAgentName(options));
410
434
  }
411
435
  resolveDelegateForAgent(agentName) {
412
436
  const command = resolveAgentCommandForName({
@@ -418,14 +442,51 @@ var AcpxRuntime = class {
418
442
  resolveDelegateForCommand(command) {
419
443
  return shouldUseBridgeSafeDelegateForCommand(command) ? this.bridgeSafeDelegate : this.delegate;
420
444
  }
445
+ resolveDelegateForSession(params) {
446
+ if (shouldUseBridgeSafeDelegateForCommand(params.command)) return this.bridgeSafeDelegate;
447
+ return this.resolveOpenClawToolsDelegateForSession(params.sessionKey);
448
+ }
449
+ resolveOpenClawToolsDelegateForSession(sessionKey) {
450
+ if (!this.openclawToolsMcpBridgeEnabled) return this.delegate;
451
+ const normalizedSessionKey = sessionKey.trim();
452
+ if (!normalizedSessionKey) return this.delegate;
453
+ const cached = this.openclawToolsSessionDelegates.get(normalizedSessionKey);
454
+ if (cached) return cached;
455
+ const delegate = new AcpxRuntime$1({
456
+ ...this.delegateOptions,
457
+ mcpServers: withOpenClawToolsMcpSessionEnv({
458
+ enabled: this.openclawToolsMcpBridgeEnabled,
459
+ mcpServers: this.delegateOptions.mcpServers,
460
+ sessionKey: normalizedSessionKey
461
+ })
462
+ }, this.delegateTestOptions);
463
+ this.openclawToolsSessionDelegates.set(normalizedSessionKey, delegate);
464
+ return delegate;
465
+ }
466
+ releaseOpenClawToolsDelegateForSession(sessionKey) {
467
+ if (!this.openclawToolsMcpBridgeEnabled) return;
468
+ const normalizedSessionKey = sessionKey.trim();
469
+ if (!normalizedSessionKey) return;
470
+ this.openclawToolsSessionDelegates.delete(normalizedSessionKey);
471
+ }
421
472
  async resolveDelegateForHandle(handle) {
422
473
  const record = await this.sessionStore.load(handle.acpxRecordId ?? handle.sessionKey);
423
474
  return this.resolveDelegateForLoadedRecord(handle, record);
424
475
  }
425
476
  resolveDelegateForLoadedRecord(handle, record) {
426
477
  const recordCommand = readAgentCommandFromRecord(record);
427
- if (recordCommand) return this.resolveDelegateForCommand(recordCommand);
428
- return this.resolveDelegateForAgent(readAgentFromHandle(handle));
478
+ if (recordCommand) return this.resolveDelegateForSession({
479
+ command: recordCommand,
480
+ sessionKey: handle.sessionKey
481
+ });
482
+ const command = resolveAgentCommandForName({
483
+ agentName: readAgentFromHandle(handle),
484
+ agentRegistry: this.agentRegistry
485
+ });
486
+ return this.resolveDelegateForSession({
487
+ command,
488
+ sessionKey: handle.sessionKey
489
+ });
429
490
  }
430
491
  async resolveCommandForHandle(handle) {
431
492
  const recordCommand = readAgentCommandFromRecord(await this.sessionStore.load(handle.acpxRecordId ?? handle.sessionKey));
@@ -554,7 +615,10 @@ var AcpxRuntime = class {
554
615
  agentName: input.agent,
555
616
  agentRegistry: this.agentRegistry
556
617
  });
557
- const delegate = this.resolveDelegateForCommand(command);
618
+ const delegate = this.resolveDelegateForSession({
619
+ command,
620
+ sessionKey: input.sessionKey
621
+ });
558
622
  const claudeModelOverride = isClaudeAcpCommand(command) ? normalizeClaudeAcpModelOverride(input.model) : void 0;
559
623
  const codexModelOverride = normalizeAgentName(input.agent) === CODEX_ACP_AGENT_ID && isCodexAcpCommand(command) ? normalizeCodexAcpModelOverride(input.model, input.thinking) : void 0;
560
624
  const ensureInput = claudeModelOverride ? {
@@ -746,8 +810,9 @@ var AcpxRuntime = class {
746
810
  async close(input) {
747
811
  const record = await this.sessionStore.load(input.handle.acpxRecordId ?? input.handle.sessionKey);
748
812
  let closeSucceeded;
813
+ const delegate = this.resolveDelegateForLoadedRecord(input.handle, record);
749
814
  try {
750
- await this.resolveDelegateForLoadedRecord(input.handle, record).close({
815
+ await delegate.close({
751
816
  handle: input.handle,
752
817
  reason: input.reason,
753
818
  discardPersistentState: input.discardPersistentState
@@ -756,6 +821,7 @@ var AcpxRuntime = class {
756
821
  } finally {
757
822
  await this.cleanupProcessTreeForRecord(input.handle, record);
758
823
  }
824
+ if (closeSucceeded) this.releaseOpenClawToolsDelegateForSession(input.handle.sessionKey);
759
825
  if (closeSucceeded && input.discardPersistentState) this.sessionStore.markFresh(input.handle.sessionKey);
760
826
  }
761
827
  };
@@ -1,8 +1,9 @@
1
- import { n as createLazyAcpRuntimeProxy } from "./register.runtime-CmYbf9SF.js";
1
+ import { n as createLazyAcpRuntimeProxy } from "./register.runtime-Bcp4wC4g.js";
2
2
  import { a as createAcpxProcessLeaseStore, d as ACPX_GATEWAY_INSTANCE_KEY, f as ACPX_GATEWAY_INSTANCE_NAMESPACE, h as normalizeAcpxGatewayInstanceRecord, l as openAcpxProcessLeaseStateStore, n as OPENCLAW_ACPX_LEASE_ID_ENV, r as OPENCLAW_GATEWAY_INSTANCE_ID_ARG, t as OPENCLAW_ACPX_LEASE_ID_ARG } from "./process-lease-DiKkFj6F.js";
3
3
  import { registerAcpRuntimeBackend, unregisterAcpRuntimeBackend } from "./runtime-api.js";
4
- import { a as resolveAcpxPluginRoot, c as splitCommandParts, i as resolveAcpxPluginConfig, o as toAcpMcpServers, r as reapStaleOpenClawOwnedAcpxOrphans, s as quoteCommandPart, t as cleanupOpenClawOwnedAcpxProcessTree } from "./process-reaper-Dv_iMcOo.js";
4
+ import { a as resolveAcpxPluginRoot, c as splitCommandParts, i as resolveAcpxPluginConfig, o as toAcpMcpServers, r as reapStaleOpenClawOwnedAcpxOrphans, s as quoteCommandPart, t as cleanupOpenClawOwnedAcpxProcessTree } from "./process-reaper-_ttV4L1d.js";
5
5
  import { createRequire } from "node:module";
6
+ import { createLazyRuntimeModule } from "openclaw/plugin-sdk/lazy-runtime";
6
7
  import fs from "node:fs/promises";
7
8
  import path from "node:path";
8
9
  import { randomUUID } from "node:crypto";
@@ -851,11 +852,7 @@ async function prepareAcpxCodexAuthConfig(params) {
851
852
  const ENABLE_STARTUP_PROBE_ENV = "OPENCLAW_ACPX_RUNTIME_STARTUP_PROBE";
852
853
  const SKIP_RUNTIME_PROBE_ENV = "OPENCLAW_SKIP_ACPX_RUNTIME_PROBE";
853
854
  const ACPX_BACKEND_ID = "acpx";
854
- let runtimeModulePromise = null;
855
- function loadRuntimeModule() {
856
- runtimeModulePromise ??= import("./runtime-B1cHS4Li.js");
857
- return runtimeModulePromise;
858
- }
855
+ const loadRuntimeModule = createLazyRuntimeModule(() => import("./runtime-7Xuu2bcn.js"));
859
856
  /** Convert ACPX timeout seconds into timer-safe milliseconds. */
860
857
  function resolveAcpxTimerTimeoutMs(timeoutSeconds) {
861
858
  if (timeoutSeconds === void 0) return;
@@ -876,6 +873,7 @@ function createLazyDefaultRuntime(params) {
876
873
  agentRegistry: module.createAgentRegistry({ overrides: params.pluginConfig.agents }),
877
874
  probeAgent: params.pluginConfig.probeAgent,
878
875
  mcpServers: toAcpMcpServers(params.pluginConfig.mcpServers),
876
+ openclawToolsMcpBridgeEnabled: params.pluginConfig.openClawToolsMcpBridge,
879
877
  permissionMode: params.pluginConfig.permissionMode,
880
878
  nonInteractivePermissions: params.pluginConfig.nonInteractivePermissions,
881
879
  timeoutMs: resolveAcpxTimerTimeoutMs(params.pluginConfig.timeoutSeconds)
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@openclaw/acpx",
3
- "version": "2026.6.11",
3
+ "version": "2026.7.1-beta.2",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "@openclaw/acpx",
9
- "version": "2026.6.11",
9
+ "version": "2026.7.1-beta.2",
10
10
  "dependencies": {
11
11
  "@agentclientprotocol/claude-agent-acp": "0.39.0",
12
12
  "@zed-industries/codex-acp": "0.15.0",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openclaw/acpx",
3
- "version": "2026.6.11",
3
+ "version": "2026.7.1-beta.2",
4
4
  "description": "OpenClaw ACP runtime backend with plugin-owned session and transport management.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -26,10 +26,10 @@
26
26
  "minHostVersion": ">=2026.4.25"
27
27
  },
28
28
  "compat": {
29
- "pluginApi": ">=2026.6.11"
29
+ "pluginApi": ">=2026.7.1-beta.2"
30
30
  },
31
31
  "build": {
32
- "openclawVersion": "2026.6.11",
32
+ "openclawVersion": "2026.7.1-beta.2",
33
33
  "staticAssets": [
34
34
  {
35
35
  "source": "./src/runtime-internals/mcp-proxy.mjs",
@@ -58,7 +58,7 @@
58
58
  "skills/**"
59
59
  ],
60
60
  "peerDependencies": {
61
- "openclaw": ">=2026.6.11"
61
+ "openclaw": ">=2026.7.1-beta.2"
62
62
  },
63
63
  "peerDependenciesMeta": {
64
64
  "openclaw": {
@@ -1,12 +1,12 @@
1
1
  import "./process-lease-DiKkFj6F.js";
2
2
  import { createRequire } from "node:module";
3
+ import { formatPluginConfigIssue } from "openclaw/plugin-sdk/extension-shared";
3
4
  import path from "node:path";
4
5
  import { normalizeLowercaseStringOrEmpty } from "openclaw/plugin-sdk/string-coerce-runtime";
5
6
  import { execFile } from "node:child_process";
6
7
  import { promisify } from "node:util";
7
8
  import fsSync from "node:fs";
8
9
  import { fileURLToPath } from "node:url";
9
- import { formatPluginConfigIssue } from "openclaw/plugin-sdk/extension-shared";
10
10
  import { z } from "zod";
11
11
  //#region extensions/acpx/src/command-line.ts
12
12
  /**