@openclaw/acpx 2026.5.2-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.
- package/AGENTS.md +54 -0
- package/index.test.ts +119 -0
- package/index.ts +19 -0
- package/openclaw.plugin.json +170 -0
- package/package.json +38 -0
- package/register.runtime.ts +154 -0
- package/runtime-api.ts +46 -0
- package/setup-api.ts +18 -0
- package/skills/acp-router/SKILL.md +248 -0
- package/src/acpx-runtime-compat.d.ts +62 -0
- package/src/claude-agent-acp-completion.test.ts +129 -0
- package/src/codex-auth-bridge.test.ts +448 -0
- package/src/codex-auth-bridge.ts +385 -0
- package/src/config-schema.ts +117 -0
- package/src/config.test.ts +144 -0
- package/src/config.ts +273 -0
- package/src/manifest.test.ts +20 -0
- package/src/runtime-internals/error-format.mjs +6 -0
- package/src/runtime-internals/mcp-command-line.mjs +123 -0
- package/src/runtime-internals/mcp-command-line.test.ts +59 -0
- package/src/runtime-internals/mcp-proxy.mjs +113 -0
- package/src/runtime-internals/mcp-proxy.test.ts +114 -0
- package/src/runtime.test.ts +816 -0
- package/src/runtime.ts +613 -0
- package/src/service.test.ts +401 -0
- package/src/service.ts +278 -0
- package/tsconfig.json +16 -0
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { spawn } from "node:child_process";
|
|
2
|
+
import { chmod, mkdtemp, rm, writeFile } from "node:fs/promises";
|
|
3
|
+
import os from "node:os";
|
|
4
|
+
import path from "node:path";
|
|
5
|
+
import { bundledPluginFile } from "openclaw/plugin-sdk/test-fixtures";
|
|
6
|
+
import { afterEach, describe, expect, it } from "vitest";
|
|
7
|
+
|
|
8
|
+
const tempDirs: string[] = [];
|
|
9
|
+
const proxyPath = path.resolve(bundledPluginFile("acpx", "src/runtime-internals/mcp-proxy.mjs"));
|
|
10
|
+
|
|
11
|
+
async function makeTempScript(name: string, content: string): Promise<string> {
|
|
12
|
+
const dir = await mkdtemp(path.join(os.tmpdir(), "openclaw-acpx-mcp-proxy-"));
|
|
13
|
+
tempDirs.push(dir);
|
|
14
|
+
const scriptPath = path.join(dir, name);
|
|
15
|
+
await writeFile(scriptPath, content, "utf8");
|
|
16
|
+
await chmod(scriptPath, 0o755);
|
|
17
|
+
return scriptPath;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
afterEach(async () => {
|
|
21
|
+
while (tempDirs.length > 0) {
|
|
22
|
+
const dir = tempDirs.pop();
|
|
23
|
+
if (!dir) {
|
|
24
|
+
continue;
|
|
25
|
+
}
|
|
26
|
+
await rm(dir, { recursive: true, force: true });
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
describe("mcp-proxy", () => {
|
|
31
|
+
it("injects configured MCP servers into ACP session bootstrap requests", async () => {
|
|
32
|
+
const echoServerPath = await makeTempScript(
|
|
33
|
+
"echo-server.cjs",
|
|
34
|
+
String.raw`#!/usr/bin/env node
|
|
35
|
+
const { createInterface } = require("node:readline");
|
|
36
|
+
const rl = createInterface({ input: process.stdin });
|
|
37
|
+
rl.on("line", (line) => process.stdout.write(line + "\n"));
|
|
38
|
+
`,
|
|
39
|
+
);
|
|
40
|
+
|
|
41
|
+
const payload = Buffer.from(
|
|
42
|
+
JSON.stringify({
|
|
43
|
+
targetCommand: `${process.execPath} ${echoServerPath}`,
|
|
44
|
+
mcpServers: [
|
|
45
|
+
{
|
|
46
|
+
name: "canva",
|
|
47
|
+
command: "npx",
|
|
48
|
+
args: ["-y", "mcp-remote@latest", "https://mcp.canva.com/mcp"],
|
|
49
|
+
env: [{ name: "CANVA_TOKEN", value: "secret" }],
|
|
50
|
+
},
|
|
51
|
+
],
|
|
52
|
+
}),
|
|
53
|
+
"utf8",
|
|
54
|
+
).toString("base64url");
|
|
55
|
+
|
|
56
|
+
const child = spawn(process.execPath, [proxyPath, "--payload", payload], {
|
|
57
|
+
stdio: ["pipe", "pipe", "inherit"],
|
|
58
|
+
cwd: process.cwd(),
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
let stdout = "";
|
|
62
|
+
child.stdout.on("data", (chunk) => {
|
|
63
|
+
stdout += String(chunk);
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
child.stdin.write(
|
|
67
|
+
`${JSON.stringify({
|
|
68
|
+
jsonrpc: "2.0",
|
|
69
|
+
id: 1,
|
|
70
|
+
method: "session/new",
|
|
71
|
+
params: { cwd: process.cwd(), mcpServers: [] },
|
|
72
|
+
})}\n`,
|
|
73
|
+
);
|
|
74
|
+
child.stdin.write(
|
|
75
|
+
`${JSON.stringify({
|
|
76
|
+
jsonrpc: "2.0",
|
|
77
|
+
id: 2,
|
|
78
|
+
method: "session/load",
|
|
79
|
+
params: { cwd: process.cwd(), sessionId: "sid-1", mcpServers: [] },
|
|
80
|
+
})}\n`,
|
|
81
|
+
);
|
|
82
|
+
child.stdin.write(
|
|
83
|
+
`${JSON.stringify({
|
|
84
|
+
jsonrpc: "2.0",
|
|
85
|
+
id: 3,
|
|
86
|
+
method: "session/prompt",
|
|
87
|
+
params: { sessionId: "sid-1", prompt: [{ type: "text", text: "hello" }] },
|
|
88
|
+
})}\n`,
|
|
89
|
+
);
|
|
90
|
+
child.stdin.end();
|
|
91
|
+
|
|
92
|
+
const exitCode = await new Promise<number | null>((resolve) => {
|
|
93
|
+
child.once("close", (code) => resolve(code));
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
expect(exitCode).toBe(0);
|
|
97
|
+
const lines = stdout
|
|
98
|
+
.trim()
|
|
99
|
+
.split(/\r?\n/)
|
|
100
|
+
.map((line) => JSON.parse(line) as { method: string; params: Record<string, unknown> });
|
|
101
|
+
|
|
102
|
+
expect(lines[0].params.mcpServers).toEqual([
|
|
103
|
+
{
|
|
104
|
+
name: "canva",
|
|
105
|
+
command: "npx",
|
|
106
|
+
args: ["-y", "mcp-remote@latest", "https://mcp.canva.com/mcp"],
|
|
107
|
+
env: [{ name: "CANVA_TOKEN", value: "secret" }],
|
|
108
|
+
},
|
|
109
|
+
]);
|
|
110
|
+
expect(lines[1].params.mcpServers).toEqual(lines[0].params.mcpServers);
|
|
111
|
+
expect(lines[2].method).toBe("session/prompt");
|
|
112
|
+
expect(lines[2].params.mcpServers).toBeUndefined();
|
|
113
|
+
});
|
|
114
|
+
});
|