@openclaw/acpx 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.
- package/dist/config-schema-lrk5nlcV.js +39 -0
- package/dist/index.js +1049 -2
- package/dist/{process-reaper-cncoDfwV.js → process-reaper-CoGRyMJ_.js} +40 -50
- package/dist/{register.runtime-Yz704dK5.js → register.runtime-CysfMsSr.js} +1 -1
- package/dist/register.runtime.js +1 -1
- package/dist/{runtime-WjNm2DKO.js → runtime-BEOGc4Ik.js} +51 -54
- package/dist/{service-CzJr7Koj.js → service-DJchyiuU.js} +221 -49
- package/dist/setup-api.js +1 -1
- package/npm-shrinkwrap.json +299 -58
- package/openclaw.plugin.json +13 -3
- package/package.json +6 -5
- package/skills/acp-router/SKILL.md +1 -1
|
@@ -1,13 +1,18 @@
|
|
|
1
|
+
import { t as AcpxPluginConfigSchema } from "./config-schema-lrk5nlcV.js";
|
|
1
2
|
import "./process-lease-DiKkFj6F.js";
|
|
2
3
|
import { createRequire } from "node:module";
|
|
3
4
|
import { formatPluginConfigIssue } from "openclaw/plugin-sdk/extension-shared";
|
|
4
|
-
import path from "node:path";
|
|
5
5
|
import { normalizeLowercaseStringOrEmpty } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
6
|
-
import { execFile } from "node:child_process";
|
|
7
|
-
import { promisify } from "node:util";
|
|
8
6
|
import fs from "node:fs";
|
|
7
|
+
import path from "node:path";
|
|
8
|
+
import { runExec } from "openclaw/plugin-sdk/process-runtime";
|
|
9
9
|
import { fileURLToPath } from "node:url";
|
|
10
|
-
|
|
10
|
+
//#region extensions/acpx/src/codex-adapter.ts
|
|
11
|
+
const CODEX_ACP_PACKAGE = "@agentclientprotocol/codex-acp";
|
|
12
|
+
const CODEX_ACP_BIN = "codex-acp";
|
|
13
|
+
const LEGACY_CODEX_ACP_PACKAGE = "@zed-industries/codex-acp";
|
|
14
|
+
const OPENCLAW_CODEX_CONFIG_ARG = "--openclaw-codex-config";
|
|
15
|
+
//#endregion
|
|
11
16
|
//#region extensions/acpx/src/command-line.ts
|
|
12
17
|
/**
|
|
13
18
|
* Small shell-command helpers for ACPX-launched processes. Splitting supports
|
|
@@ -56,42 +61,6 @@ function splitCommandParts(value) {
|
|
|
56
61
|
return parts;
|
|
57
62
|
}
|
|
58
63
|
//#endregion
|
|
59
|
-
//#region extensions/acpx/src/config-schema.ts
|
|
60
|
-
/**
|
|
61
|
-
* ACPX plugin configuration schema and public config types. Runtime setup uses
|
|
62
|
-
* this file as the single source of truth for validation and defaulting.
|
|
63
|
-
*/
|
|
64
|
-
const ACPX_PERMISSION_MODES = [
|
|
65
|
-
"approve-all",
|
|
66
|
-
"approve-reads",
|
|
67
|
-
"deny-all"
|
|
68
|
-
];
|
|
69
|
-
const ACPX_NON_INTERACTIVE_POLICIES = ["deny", "fail"];
|
|
70
|
-
const nonEmptyTrimmedString = (message) => z.string({ error: message }).trim().min(1, { error: message });
|
|
71
|
-
const McpServerConfigSchema = z.object({
|
|
72
|
-
command: nonEmptyTrimmedString("command must be a non-empty string").describe("Command to run the MCP server"),
|
|
73
|
-
args: z.array(z.string({ error: "args must be an array of strings" }), { error: "args must be an array of strings" }).optional().describe("Arguments to pass to the command"),
|
|
74
|
-
env: z.record(z.string(), z.string({ error: "env values must be strings" }), { error: "env must be an object of strings" }).optional().describe("Environment variables for the MCP server")
|
|
75
|
-
});
|
|
76
|
-
/** Zod schema for validating raw ACPX plugin config from OpenClaw config. */
|
|
77
|
-
const AcpxPluginConfigSchema = z.strictObject({
|
|
78
|
-
cwd: nonEmptyTrimmedString("cwd must be a non-empty string").optional(),
|
|
79
|
-
stateDir: nonEmptyTrimmedString("stateDir must be a non-empty string").optional(),
|
|
80
|
-
probeAgent: nonEmptyTrimmedString("probeAgent must be a non-empty string").optional(),
|
|
81
|
-
permissionMode: z.enum(ACPX_PERMISSION_MODES, { error: `permissionMode must be one of: ${ACPX_PERMISSION_MODES.join(", ")}` }).optional(),
|
|
82
|
-
nonInteractivePermissions: z.enum(ACPX_NON_INTERACTIVE_POLICIES, { error: `nonInteractivePermissions must be one of: ${ACPX_NON_INTERACTIVE_POLICIES.join(", ")}` }).optional(),
|
|
83
|
-
pluginToolsMcpBridge: z.boolean({ error: "pluginToolsMcpBridge must be a boolean" }).optional(),
|
|
84
|
-
openClawToolsMcpBridge: z.boolean({ error: "openClawToolsMcpBridge must be a boolean" }).optional(),
|
|
85
|
-
strictWindowsCmdWrapper: z.boolean({ error: "strictWindowsCmdWrapper must be a boolean" }).optional(),
|
|
86
|
-
timeoutSeconds: z.number({ error: "timeoutSeconds must be a number >= 0.001" }).min(.001, { error: "timeoutSeconds must be a number >= 0.001" }).default(120),
|
|
87
|
-
queueOwnerTtlSeconds: z.number({ error: "queueOwnerTtlSeconds must be a number >= 0" }).min(0, { error: "queueOwnerTtlSeconds must be a number >= 0" }).optional(),
|
|
88
|
-
mcpServers: z.record(z.string(), McpServerConfigSchema).optional(),
|
|
89
|
-
agents: z.record(z.string(), z.strictObject({
|
|
90
|
-
command: nonEmptyTrimmedString("agents.<id>.command must be a non-empty string"),
|
|
91
|
-
args: z.array(z.string({ error: "args must be an array of strings" })).optional()
|
|
92
|
-
})).optional()
|
|
93
|
-
});
|
|
94
|
-
//#endregion
|
|
95
64
|
//#region extensions/acpx/src/config.ts
|
|
96
65
|
/**
|
|
97
66
|
* Resolves ACPX plugin config from raw user configuration. It locates the
|
|
@@ -260,7 +229,7 @@ function resolveAcpxPluginConfig(params) {
|
|
|
260
229
|
return {
|
|
261
230
|
cwd,
|
|
262
231
|
stateDir,
|
|
263
|
-
probeAgent:
|
|
232
|
+
probeAgent: normalized.probeAgent,
|
|
264
233
|
permissionMode: normalized.permissionMode ?? DEFAULT_PERMISSION_MODE,
|
|
265
234
|
nonInteractivePermissions: normalized.nonInteractivePermissions ?? DEFAULT_NON_INTERACTIVE_POLICY,
|
|
266
235
|
pluginToolsMcpBridge,
|
|
@@ -282,12 +251,13 @@ function resolveAcpxPluginConfig(params) {
|
|
|
282
251
|
* ACPX process ownership checks and cleanup. The reaper only terminates
|
|
283
252
|
* OpenClaw-owned wrapper trees after validating paths, packages, and lease ids.
|
|
284
253
|
*/
|
|
285
|
-
const execFileAsync = promisify(execFile);
|
|
286
254
|
const requireFromHere = createRequire(import.meta.url);
|
|
287
255
|
const GENERATED_WRAPPER_BASENAMES = /* @__PURE__ */ new Set(["codex-acp-wrapper.mjs", "claude-agent-acp-wrapper.mjs"]);
|
|
288
256
|
const OPENCLAW_PLUGIN_DEPS_MARKER = "/plugin-runtime-deps/";
|
|
257
|
+
const ACPX_PROCESS_LIST_TIMEOUT_MS = 2e3;
|
|
289
258
|
const OWNED_ACP_PACKAGE_NAMES = [
|
|
290
|
-
|
|
259
|
+
CODEX_ACP_PACKAGE,
|
|
260
|
+
LEGACY_CODEX_ACP_PACKAGE,
|
|
291
261
|
"@zed-industries/codex-acp-darwin-arm64",
|
|
292
262
|
"@zed-industries/codex-acp-darwin-x64",
|
|
293
263
|
"@zed-industries/codex-acp-linux-arm64",
|
|
@@ -297,7 +267,20 @@ const OWNED_ACP_PACKAGE_NAMES = [
|
|
|
297
267
|
"@agentclientprotocol/claude-agent-acp",
|
|
298
268
|
"acpx"
|
|
299
269
|
];
|
|
300
|
-
const
|
|
270
|
+
const PLUGIN_DEPS_CODEX_PACKAGE_NAMES = [
|
|
271
|
+
"@openai/codex",
|
|
272
|
+
"@openai/codex-darwin-arm64",
|
|
273
|
+
"@openai/codex-darwin-x64",
|
|
274
|
+
"@openai/codex-linux-arm64",
|
|
275
|
+
"@openai/codex-linux-x64",
|
|
276
|
+
"@openai/codex-win32-arm64",
|
|
277
|
+
"@openai/codex-win32-x64"
|
|
278
|
+
];
|
|
279
|
+
const ACP_PACKAGE_MARKERS = [
|
|
280
|
+
...OWNED_ACP_PACKAGE_NAMES.map((packageName) => `/node_modules/${packageName}/`),
|
|
281
|
+
...PLUGIN_DEPS_CODEX_PACKAGE_NAMES.map((packageName) => `/node_modules/${packageName}/`),
|
|
282
|
+
"/acpx/dist/"
|
|
283
|
+
];
|
|
301
284
|
function normalizePathLike(value) {
|
|
302
285
|
return value.replaceAll("\\", "/");
|
|
303
286
|
}
|
|
@@ -375,11 +358,14 @@ function parseProcessList(stdout) {
|
|
|
375
358
|
const processes = [];
|
|
376
359
|
for (const line of stdout.split(/\r?\n/)) {
|
|
377
360
|
const match = /^\s*(?<pid>\d+)\s+(?<ppid>\d+)\s+(?<command>.+?)\s*$/.exec(line);
|
|
378
|
-
|
|
361
|
+
const pid = match?.groups?.pid;
|
|
362
|
+
const ppid = match?.groups?.ppid;
|
|
363
|
+
const command = match?.groups?.command;
|
|
364
|
+
if (!pid || !ppid || !command) continue;
|
|
379
365
|
processes.push({
|
|
380
|
-
pid: Number.parseInt(
|
|
381
|
-
ppid: Number.parseInt(
|
|
382
|
-
command
|
|
366
|
+
pid: Number.parseInt(pid, 10),
|
|
367
|
+
ppid: Number.parseInt(ppid, 10),
|
|
368
|
+
command
|
|
383
369
|
});
|
|
384
370
|
}
|
|
385
371
|
return processes;
|
|
@@ -387,7 +373,11 @@ function parseProcessList(stdout) {
|
|
|
387
373
|
/** List host processes in the compact shape needed by ACPX cleanup. */
|
|
388
374
|
async function listPlatformProcesses() {
|
|
389
375
|
if (process.platform === "win32") return [];
|
|
390
|
-
const { stdout } = await
|
|
376
|
+
const { stdout } = await runExec("ps", ["-axo", "pid=,ppid=,command="], {
|
|
377
|
+
logOutput: false,
|
|
378
|
+
maxBuffer: 8 * 1024 * 1024,
|
|
379
|
+
timeoutMs: ACPX_PROCESS_LIST_TIMEOUT_MS
|
|
380
|
+
});
|
|
391
381
|
return parseProcessList(stdout);
|
|
392
382
|
}
|
|
393
383
|
function collectProcessTree(processes, rootPid) {
|
|
@@ -520,4 +510,4 @@ async function reapStaleOpenClawOwnedAcpxOrphans(params) {
|
|
|
520
510
|
};
|
|
521
511
|
}
|
|
522
512
|
//#endregion
|
|
523
|
-
export { resolveAcpxPluginRoot as a, splitCommandParts as c, resolveAcpxPluginConfig as i, isOpenClawLeaseAwareAcpxProcessCommand as n, toAcpMcpServers as o, reapStaleOpenClawOwnedAcpxOrphans as r, quoteCommandPart as s, cleanupOpenClawOwnedAcpxProcessTree as t };
|
|
513
|
+
export { resolveAcpxPluginRoot as a, splitCommandParts as c, LEGACY_CODEX_ACP_PACKAGE as d, OPENCLAW_CODEX_CONFIG_ARG as f, resolveAcpxPluginConfig as i, CODEX_ACP_BIN as l, isOpenClawLeaseAwareAcpxProcessCommand as n, toAcpMcpServers as o, reapStaleOpenClawOwnedAcpxOrphans as r, quoteCommandPart as s, cleanupOpenClawOwnedAcpxProcessTree as t, CODEX_ACP_PACKAGE 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-
|
|
203
|
+
const loadServiceModule = createLazyRuntimeModule(() => import("./service-DJchyiuU.js"));
|
|
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");
|
package/dist/register.runtime.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as createAcpxRuntimeService } from "./register.runtime-
|
|
1
|
+
import { t as createAcpxRuntimeService } from "./register.runtime-CysfMsSr.js";
|
|
2
2
|
export { createAcpxRuntimeService };
|
|
@@ -1,18 +1,20 @@
|
|
|
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-
|
|
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-CoGRyMJ_.js";
|
|
4
|
+
import { parseStrictPositiveInteger } from "openclaw/plugin-sdk/number-runtime";
|
|
5
|
+
import { normalizeStringEntries } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
4
6
|
import fs from "node:fs/promises";
|
|
5
7
|
import path, { resolve } from "node:path";
|
|
6
|
-
import { normalizeStringEntries } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
7
8
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
8
9
|
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";
|
|
10
10
|
import { redactSensitiveText } from "openclaw/plugin-sdk/security-runtime";
|
|
11
|
+
import { sliceUtf16Safe } from "openclaw/plugin-sdk/text-utility-runtime";
|
|
11
12
|
//#region extensions/acpx/src/runtime.ts
|
|
12
13
|
/**
|
|
13
14
|
* OpenClaw ACPX runtime adapter. It wraps the upstream acpx runtime with
|
|
14
15
|
* OpenClaw session metadata, lease tracking, model scoping, and cleanup policy.
|
|
15
16
|
*/
|
|
17
|
+
const ACPX_PLUGIN_TOOLS_MCP_SERVER_NAME = "openclaw-plugin-tools";
|
|
16
18
|
const ACPX_OPENCLAW_TOOLS_MCP_SERVER_NAME = "openclaw-tools";
|
|
17
19
|
const OPENCLAW_TOOLS_MCP_AGENT_SESSION_KEY_ENV = "OPENCLAW_TOOLS_MCP_AGENT_SESSION_KEY";
|
|
18
20
|
function withOpenClawManagedTurnTimeout(input) {
|
|
@@ -48,7 +50,7 @@ function isGenericInternalAcpError(error) {
|
|
|
48
50
|
async function readCodexWrapperStderrTail(params) {
|
|
49
51
|
if (!params.wrapperRoot || !params.leaseId) return "";
|
|
50
52
|
try {
|
|
51
|
-
return compactDiagnosticText(redactSensitiveText((await fs.readFile(path.join(params.wrapperRoot, codexWrapperStderrLogFileName(params.leaseId)), "utf8")
|
|
53
|
+
return compactDiagnosticText(redactSensitiveText(sliceUtf16Safe(await fs.readFile(path.join(params.wrapperRoot, codexWrapperStderrLogFileName(params.leaseId)), "utf8"), -6e3)));
|
|
52
54
|
} catch {
|
|
53
55
|
return "";
|
|
54
56
|
}
|
|
@@ -213,9 +215,14 @@ function isEnvAssignment(value) {
|
|
|
213
215
|
return /^[A-Za-z_][A-Za-z0-9_]*=/.test(value);
|
|
214
216
|
}
|
|
215
217
|
function unwrapEnvCommand(parts) {
|
|
216
|
-
|
|
218
|
+
const command = parts.at(0);
|
|
219
|
+
if (!command || basename(command) !== "env") return parts;
|
|
217
220
|
let index = 1;
|
|
218
|
-
while (
|
|
221
|
+
while (true) {
|
|
222
|
+
const part = parts.at(index);
|
|
223
|
+
if (!part || !isEnvAssignment(part)) break;
|
|
224
|
+
index += 1;
|
|
225
|
+
}
|
|
219
226
|
return parts.slice(index);
|
|
220
227
|
}
|
|
221
228
|
function matchesExecutableName(value, executableName) {
|
|
@@ -250,7 +257,7 @@ function isOpenClawBridgeCommand(command) {
|
|
|
250
257
|
}
|
|
251
258
|
function isCodexAcpCommand(command) {
|
|
252
259
|
return isAcpCommand(command, {
|
|
253
|
-
packageName:
|
|
260
|
+
packageName: CODEX_ACP_PACKAGE,
|
|
254
261
|
executableName: "codex-acp"
|
|
255
262
|
});
|
|
256
263
|
}
|
|
@@ -297,10 +304,6 @@ function normalizeCodexAcpModelOverride(rawModel, rawThinking) {
|
|
|
297
304
|
...reasoningEffort ? { reasoningEffort } : {}
|
|
298
305
|
};
|
|
299
306
|
}
|
|
300
|
-
function codexAcpSessionModelId(override) {
|
|
301
|
-
if (!override.model) return "";
|
|
302
|
-
return override.reasoningEffort ? `${override.model}/${override.reasoningEffort}` : override.model;
|
|
303
|
-
}
|
|
304
307
|
function normalizeClaudeAcpModelOverride(rawModel) {
|
|
305
308
|
const raw = rawModel?.trim();
|
|
306
309
|
if (!raw) return;
|
|
@@ -338,10 +341,12 @@ function quoteShellArg(value) {
|
|
|
338
341
|
return `'${value.replace(/'/g, "'\\''")}'`;
|
|
339
342
|
}
|
|
340
343
|
function appendCodexAcpConfigOverrides(command, override) {
|
|
341
|
-
const
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
344
|
+
const config = {
|
|
345
|
+
...override.model ? { model: override.model } : {},
|
|
346
|
+
...override.reasoningEffort ? { model_reasoning_effort: override.reasoningEffort } : {}
|
|
347
|
+
};
|
|
348
|
+
if (Object.keys(config).length === 0) return command;
|
|
349
|
+
return `${command} ${OPENCLAW_CODEX_CONFIG_ARG} ${quoteShellArg(JSON.stringify(config))}`;
|
|
345
350
|
}
|
|
346
351
|
function createModelScopedAgentRegistry(params) {
|
|
347
352
|
return {
|
|
@@ -362,13 +367,6 @@ function resolveAgentCommand(params) {
|
|
|
362
367
|
const resolvedCommand = params.agentRegistry.resolve(normalizedAgentName);
|
|
363
368
|
return typeof resolvedCommand === "string" ? resolvedCommand.trim() || void 0 : void 0;
|
|
364
369
|
}
|
|
365
|
-
function resolveProbeAgentName(options) {
|
|
366
|
-
const { probeAgent } = options;
|
|
367
|
-
return normalizeAgentName(typeof probeAgent === "string" ? probeAgent : void 0) ?? "codex";
|
|
368
|
-
}
|
|
369
|
-
function resolveAgentCommandForName(params) {
|
|
370
|
-
return resolveAgentCommand(params);
|
|
371
|
-
}
|
|
372
370
|
function shouldUseBridgeSafeDelegateForCommand(command) {
|
|
373
371
|
return isOpenClawBridgeCommand(command);
|
|
374
372
|
}
|
|
@@ -376,12 +374,14 @@ function shouldUseDistinctBridgeDelegate(options) {
|
|
|
376
374
|
const { mcpServers } = options;
|
|
377
375
|
return Array.isArray(mcpServers) && mcpServers.length > 0;
|
|
378
376
|
}
|
|
379
|
-
function
|
|
377
|
+
function withManagedToolsMcpSessionEnv(params) {
|
|
380
378
|
const sessionKey = params.sessionKey.trim();
|
|
381
|
-
if (!params.
|
|
379
|
+
if (!params.pluginToolsEnabled && !params.openclawToolsEnabled || !sessionKey || !params.mcpServers?.length) return params.mcpServers;
|
|
382
380
|
let changed = false;
|
|
383
381
|
const nextServers = params.mcpServers.map((server) => {
|
|
384
|
-
|
|
382
|
+
const isManagedPluginTools = params.pluginToolsEnabled && server.name === ACPX_PLUGIN_TOOLS_MCP_SERVER_NAME;
|
|
383
|
+
const isManagedOpenClawTools = params.openclawToolsEnabled && server.name === ACPX_OPENCLAW_TOOLS_MCP_SERVER_NAME;
|
|
384
|
+
if (!isManagedPluginTools && !isManagedOpenClawTools || !("command" in server)) return server;
|
|
385
385
|
changed = true;
|
|
386
386
|
const env = [...server.env.filter((entry) => entry.name !== OPENCLAW_TOOLS_MCP_AGENT_SESSION_KEY_ENV), {
|
|
387
387
|
name: OPENCLAW_TOOLS_MCP_AGENT_SESSION_KEY_ENV,
|
|
@@ -398,14 +398,16 @@ function withOpenClawToolsMcpSessionEnv(params) {
|
|
|
398
398
|
var AcpxRuntime = class {
|
|
399
399
|
constructor(options, testOptions) {
|
|
400
400
|
this.codexAcpModelOverrideScope = new AsyncLocalStorage();
|
|
401
|
-
this.
|
|
401
|
+
this.managedToolsSessionDelegates = /* @__PURE__ */ new Map();
|
|
402
402
|
this.launchLeaseScope = new AsyncLocalStorage();
|
|
403
403
|
const { openclawProcessCleanup, ...delegateTestOptions } = testOptions ?? {};
|
|
404
404
|
this.processCleanupDeps = openclawProcessCleanup;
|
|
405
405
|
this.wrapperRoot = options.openclawWrapperRoot;
|
|
406
406
|
this.gatewayInstanceId = options.openclawGatewayInstanceId;
|
|
407
407
|
this.processLeaseStore = options.openclawProcessLeaseStore;
|
|
408
|
+
this.pluginToolsMcpBridgeEnabled = options.pluginToolsMcpBridgeEnabled === true;
|
|
408
409
|
this.openclawToolsMcpBridgeEnabled = options.openclawToolsMcpBridgeEnabled === true;
|
|
410
|
+
this.managedToolsMcpBridgeEnabled = this.pluginToolsMcpBridgeEnabled || this.openclawToolsMcpBridgeEnabled;
|
|
409
411
|
this.cwd = options.cwd;
|
|
410
412
|
this.sessionStore = createResetAwareSessionStore(options.sessionStore, {
|
|
411
413
|
gatewayInstanceId: this.gatewayInstanceId,
|
|
@@ -430,44 +432,40 @@ var AcpxRuntime = class {
|
|
|
430
432
|
...sharedOptions,
|
|
431
433
|
mcpServers: []
|
|
432
434
|
}, this.delegateTestOptions) : this.delegate;
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
resolveDelegateForAgent(agentName) {
|
|
436
|
-
const command = resolveAgentCommandForName({
|
|
437
|
-
agentName,
|
|
435
|
+
const probeCommand = resolveAgentCommand({
|
|
436
|
+
agentName: normalizeAgentName(options.probeAgent) ?? "codex",
|
|
438
437
|
agentRegistry: this.agentRegistry
|
|
439
438
|
});
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
resolveDelegateForCommand(command) {
|
|
443
|
-
return shouldUseBridgeSafeDelegateForCommand(command) ? this.bridgeSafeDelegate : this.delegate;
|
|
439
|
+
const useBridgeSafeProbe = this.managedToolsMcpBridgeEnabled || shouldUseBridgeSafeDelegateForCommand(probeCommand);
|
|
440
|
+
this.probeDelegate = useBridgeSafeProbe ? this.bridgeSafeDelegate : this.delegate;
|
|
444
441
|
}
|
|
445
442
|
resolveDelegateForSession(params) {
|
|
446
443
|
if (shouldUseBridgeSafeDelegateForCommand(params.command)) return this.bridgeSafeDelegate;
|
|
447
|
-
return this.
|
|
444
|
+
return this.resolveManagedToolsDelegateForSession(params.sessionKey);
|
|
448
445
|
}
|
|
449
|
-
|
|
450
|
-
if (!this.
|
|
446
|
+
resolveManagedToolsDelegateForSession(sessionKey) {
|
|
447
|
+
if (!this.managedToolsMcpBridgeEnabled) return this.delegate;
|
|
451
448
|
const normalizedSessionKey = sessionKey.trim();
|
|
452
449
|
if (!normalizedSessionKey) return this.delegate;
|
|
453
|
-
const cached = this.
|
|
450
|
+
const cached = this.managedToolsSessionDelegates.get(normalizedSessionKey);
|
|
454
451
|
if (cached) return cached;
|
|
455
452
|
const delegate = new AcpxRuntime$1({
|
|
456
453
|
...this.delegateOptions,
|
|
457
|
-
mcpServers:
|
|
458
|
-
|
|
454
|
+
mcpServers: withManagedToolsMcpSessionEnv({
|
|
455
|
+
pluginToolsEnabled: this.pluginToolsMcpBridgeEnabled,
|
|
456
|
+
openclawToolsEnabled: this.openclawToolsMcpBridgeEnabled,
|
|
459
457
|
mcpServers: this.delegateOptions.mcpServers,
|
|
460
458
|
sessionKey: normalizedSessionKey
|
|
461
459
|
})
|
|
462
460
|
}, this.delegateTestOptions);
|
|
463
|
-
this.
|
|
461
|
+
this.managedToolsSessionDelegates.set(normalizedSessionKey, delegate);
|
|
464
462
|
return delegate;
|
|
465
463
|
}
|
|
466
|
-
|
|
467
|
-
if (!this.
|
|
464
|
+
releaseManagedToolsDelegateForSession(sessionKey) {
|
|
465
|
+
if (!this.managedToolsMcpBridgeEnabled) return;
|
|
468
466
|
const normalizedSessionKey = sessionKey.trim();
|
|
469
467
|
if (!normalizedSessionKey) return;
|
|
470
|
-
this.
|
|
468
|
+
this.managedToolsSessionDelegates.delete(normalizedSessionKey);
|
|
471
469
|
}
|
|
472
470
|
async resolveDelegateForHandle(handle) {
|
|
473
471
|
const record = await this.sessionStore.load(handle.acpxRecordId ?? handle.sessionKey);
|
|
@@ -479,7 +477,7 @@ var AcpxRuntime = class {
|
|
|
479
477
|
command: recordCommand,
|
|
480
478
|
sessionKey: handle.sessionKey
|
|
481
479
|
});
|
|
482
|
-
const command =
|
|
480
|
+
const command = resolveAgentCommand({
|
|
483
481
|
agentName: readAgentFromHandle(handle),
|
|
484
482
|
agentRegistry: this.agentRegistry
|
|
485
483
|
});
|
|
@@ -491,7 +489,7 @@ var AcpxRuntime = class {
|
|
|
491
489
|
async resolveCommandForHandle(handle) {
|
|
492
490
|
const recordCommand = readAgentCommandFromRecord(await this.sessionStore.load(handle.acpxRecordId ?? handle.sessionKey));
|
|
493
491
|
if (recordCommand) return recordCommand;
|
|
494
|
-
return
|
|
492
|
+
return resolveAgentCommand({
|
|
495
493
|
agentName: readAgentFromHandle(handle),
|
|
496
494
|
agentRegistry: this.agentRegistry
|
|
497
495
|
});
|
|
@@ -585,7 +583,7 @@ var AcpxRuntime = class {
|
|
|
585
583
|
await this.processLeaseStore?.markState(lease.leaseId, result.terminatedPids.length > 0 || result.skippedReason === "missing-root" ? "closed" : "lost");
|
|
586
584
|
return;
|
|
587
585
|
}
|
|
588
|
-
const rootCommand = readAgentCommandFromRecord(record) ??
|
|
586
|
+
const rootCommand = readAgentCommandFromRecord(record) ?? resolveAgentCommand({
|
|
589
587
|
agentName: readAgentFromHandle(handle),
|
|
590
588
|
agentRegistry: this.agentRegistry
|
|
591
589
|
});
|
|
@@ -611,7 +609,7 @@ var AcpxRuntime = class {
|
|
|
611
609
|
}
|
|
612
610
|
async ensureSession(input) {
|
|
613
611
|
assertSupportedRuntimeSessionMode(input.mode);
|
|
614
|
-
const command =
|
|
612
|
+
const command = resolveAgentCommand({
|
|
615
613
|
agentName: input.agent,
|
|
616
614
|
agentRegistry: this.agentRegistry
|
|
617
615
|
});
|
|
@@ -645,7 +643,7 @@ var AcpxRuntime = class {
|
|
|
645
643
|
});
|
|
646
644
|
const normalizedInput = {
|
|
647
645
|
...ensureInput,
|
|
648
|
-
...
|
|
646
|
+
...codexModelOverride.model ? { model: codexModelOverride.model } : {}
|
|
649
647
|
};
|
|
650
648
|
return await this.runWithLaunchLease({
|
|
651
649
|
sessionKey: input.sessionKey,
|
|
@@ -757,8 +755,8 @@ var AcpxRuntime = class {
|
|
|
757
755
|
}
|
|
758
756
|
};
|
|
759
757
|
}
|
|
760
|
-
getCapabilities() {
|
|
761
|
-
return this.delegate.getCapabilities();
|
|
758
|
+
getCapabilities(input) {
|
|
759
|
+
return this.delegate.getCapabilities(input);
|
|
762
760
|
}
|
|
763
761
|
async getStatus(input) {
|
|
764
762
|
return (await this.resolveDelegateForHandle(input.handle)).getStatus(input);
|
|
@@ -821,7 +819,7 @@ var AcpxRuntime = class {
|
|
|
821
819
|
} finally {
|
|
822
820
|
await this.cleanupProcessTreeForRecord(input.handle, record);
|
|
823
821
|
}
|
|
824
|
-
if (closeSucceeded) this.
|
|
822
|
+
if (closeSucceeded) this.releaseManagedToolsDelegateForSession(input.handle.sessionKey);
|
|
825
823
|
if (closeSucceeded && input.discardPersistentState) this.sessionStore.markFresh(input.handle.sessionKey);
|
|
826
824
|
}
|
|
827
825
|
};
|
|
@@ -829,7 +827,6 @@ var AcpxRuntime = class {
|
|
|
829
827
|
const testing = {
|
|
830
828
|
appendCodexAcpConfigOverrides,
|
|
831
829
|
assertSupportedRuntimeSessionMode,
|
|
832
|
-
codexAcpSessionModelId,
|
|
833
830
|
isClaudeAcpCommand,
|
|
834
831
|
isCodexAcpCommand,
|
|
835
832
|
normalizeClaudeAcpModelOverride,
|