@openclaw/acpx 2026.9.8 → 2026.10.1-beta.1

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.
@@ -1,159 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- /**
4
- * Stdio MCP proxy used by ACPX wrappers. It injects OpenClaw-provided MCP
5
- * servers into session creation/load/fork requests before forwarding to target.
6
- */
7
- import { spawn } from "node:child_process";
8
- import path from "node:path";
9
- import { createInterface } from "node:readline";
10
- import { pathToFileURL } from "node:url";
11
- import { splitCommandLine } from "./mcp-command-line.mjs";
12
-
13
- function formatErrorMessage(error) {
14
- if (error instanceof Error) {
15
- return error.message || error.name || "Error";
16
- }
17
- return String(error);
18
- }
19
-
20
- function decodePayload(argv) {
21
- const payloadIndex = argv.indexOf("--payload");
22
- if (payloadIndex < 0) {
23
- throw new Error("Missing --payload");
24
- }
25
- const encoded = argv[payloadIndex + 1];
26
- if (!encoded) {
27
- throw new Error("Missing MCP proxy payload value");
28
- }
29
- const parsed = JSON.parse(Buffer.from(encoded, "base64url").toString("utf8"));
30
- if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
31
- throw new Error("Invalid MCP proxy payload");
32
- }
33
- if (typeof parsed.targetCommand !== "string" || parsed.targetCommand.trim() === "") {
34
- throw new Error("MCP proxy payload missing targetCommand");
35
- }
36
- const mcpServers = Array.isArray(parsed.mcpServers) ? parsed.mcpServers : [];
37
- return {
38
- targetCommand: parsed.targetCommand,
39
- mcpServers,
40
- };
41
- }
42
-
43
- function shouldInject(method) {
44
- return method === "session/new" || method === "session/load" || method === "session/fork";
45
- }
46
-
47
- function rewriteLine(line, mcpServers) {
48
- if (!line.trim()) {
49
- return line;
50
- }
51
- try {
52
- const parsed = JSON.parse(line);
53
- if (
54
- !parsed ||
55
- typeof parsed !== "object" ||
56
- Array.isArray(parsed) ||
57
- !shouldInject(parsed.method) ||
58
- !parsed.params ||
59
- typeof parsed.params !== "object" ||
60
- Array.isArray(parsed.params)
61
- ) {
62
- return line;
63
- }
64
- const next = {
65
- ...parsed,
66
- params: {
67
- ...parsed.params,
68
- mcpServers,
69
- },
70
- };
71
- return JSON.stringify(next);
72
- } catch {
73
- return line;
74
- }
75
- }
76
-
77
- /** Build spawn options for the proxied MCP target process. */
78
- export function createTargetSpawnOptions(platform = process.platform) {
79
- const options = {
80
- stdio: ["pipe", "pipe", "inherit"],
81
- env: process.env,
82
- };
83
- if (platform === "win32") {
84
- options.windowsHide = true;
85
- }
86
- return options;
87
- }
88
-
89
- function isMainModule() {
90
- const mainPath = process.argv[1];
91
- if (!mainPath) {
92
- return false;
93
- }
94
- return import.meta.url === pathToFileURL(path.resolve(mainPath)).href;
95
- }
96
-
97
- function main() {
98
- const { targetCommand, mcpServers } = decodePayload(process.argv.slice(2));
99
- const target = splitCommandLine(targetCommand);
100
- const child = spawn(target.command, target.args, createTargetSpawnOptions());
101
-
102
- if (!child.stdin || !child.stdout) {
103
- throw new Error("Failed to create MCP proxy stdio pipes");
104
- }
105
-
106
- const input = createInterface({ input: process.stdin });
107
- let exiting = false;
108
-
109
- const exitWithError = (error) => {
110
- if (exiting) {
111
- return;
112
- }
113
- exiting = true;
114
- input.close();
115
- child.kill();
116
- process.stderr.write(`${formatErrorMessage(error)}\n`);
117
- process.exit(1);
118
- };
119
-
120
- child.stdin.on("error", exitWithError);
121
- process.stdout.on("error", exitWithError);
122
-
123
- input.on("line", (line) => {
124
- if (exiting) {
125
- return;
126
- }
127
- child.stdin.write(`${rewriteLine(line, mcpServers)}\n`, (error) => {
128
- if (error) {
129
- exitWithError(error);
130
- }
131
- });
132
- });
133
- input.on("close", () => {
134
- if (exiting || child.stdin.destroyed || child.stdin.writableEnded) {
135
- return;
136
- }
137
- child.stdin.end();
138
- });
139
-
140
- child.stdout.pipe(process.stdout);
141
-
142
- child.on("error", exitWithError);
143
-
144
- child.on("close", (code, signal) => {
145
- if (exiting) {
146
- return;
147
- }
148
- exiting = true;
149
- if (signal) {
150
- process.kill(process.pid, signal);
151
- return;
152
- }
153
- process.exit(code ?? 0);
154
- });
155
- }
156
-
157
- if (isMainModule()) {
158
- main();
159
- }
@@ -5,12 +5,12 @@ import path from "node:path";
5
5
  import { isRecord, normalizeBoundedOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime";
6
6
  import { resolveNodeHostExecutable } from "openclaw/plugin-sdk/node-host";
7
7
  import { createSessionCatalogFamily, importSessionCatalogHistory, isExternalUserText, listAdoptedSessionCatalogSessions, sessionCatalogAdoptedSessionKey } from "openclaw/plugin-sdk/session-catalog";
8
- import fs$1 from "node:fs/promises";
9
8
  import { resolveAcpSessionAvailability } from "openclaw/plugin-sdk/acp-runtime";
10
9
  import process from "node:process";
11
10
  import { resolveSessionAgentIdsStrict } from "openclaw/plugin-sdk/agent-scope-runtime";
12
11
  import { sessionCatalogPaging } from "openclaw/plugin-sdk/session-catalog-paging";
13
12
  import { safeParseJson, truncateUtf16Safe } from "openclaw/plugin-sdk/text-utility-runtime";
13
+ import fs$1 from "node:fs/promises";
14
14
  import { runTasksWithConcurrency } from "openclaw/plugin-sdk/concurrency-runtime";
15
15
  import { isPathStrictlyInside, readFileRangeAsync } from "openclaw/plugin-sdk/file-access-runtime";
16
16
  //#region extensions/acpx/src/pi-session-store.ts