mirror of
https://github.com/morluto/rea.git
synced 2026-11-05 14:26:07 +00:00
Expose one plan/execute replay contract through both CLI and MCP with exact source, input, runtime, sandbox, limit, and export commitments. Run selected ESM and extracted CommonJS/Rspack factories in a disposable Linux x64 Bubblewrap namespace with a content-addressed Node ELF closure, architecture-checked seccomp, delegated systemd cgroup limits, bounded protocol capture, cancellation, and observable cleanup. Preserve left and right observations as Evidence, derive differential comparisons without erasing unknowns, add optional separately authorized reproducers, and fail closed on stale plans or unavailable host boundaries. Add source-owned parser, sanitizer, clipboard, denial, timeout, OOM, protocol-forgery, and cancellation coverage; a real Linux verifier and workflow; regenerated catalogs and TypeDoc; and updated the packaged REA analysis skill for the 83-tool inventory.
88 lines
2.8 KiB
TypeScript
88 lines
2.8 KiB
TypeScript
import { fileURLToPath } from "node:url";
|
|
|
|
import { Client } from "@modelcontextprotocol/client";
|
|
import { StdioClientTransport } from "@modelcontextprotocol/client/stdio";
|
|
import { describe, expect, it } from "vitest";
|
|
|
|
const mainPath = fileURLToPath(new URL("../dist/main.js", import.meta.url));
|
|
const fixturePath = fileURLToPath(
|
|
new URL("./fixtures/fakeLauncher.mjs", import.meta.url),
|
|
);
|
|
|
|
describe("production stdio runtime", () => {
|
|
it("starts the built entrypoint, lists 83 tools, calls one, and shuts down", async () => {
|
|
const transport = new StdioClientTransport({
|
|
command: process.execPath,
|
|
args: [mainPath],
|
|
cwd: process.cwd(),
|
|
env: {
|
|
PATH: process.env.PATH ?? "",
|
|
HOPPER_LAUNCHER_PATH: process.execPath,
|
|
HOPPER_TARGET_PATH: process.execPath,
|
|
HOPPER_LOADER_ARGS_JSON: JSON.stringify([fixturePath]),
|
|
},
|
|
stderr: "pipe",
|
|
});
|
|
let stderr = "";
|
|
transport.stderr?.on("data", (chunk: Buffer | string) => {
|
|
stderr += chunk.toString();
|
|
});
|
|
const client = new Client({ name: "runtime-smoke", version: "1.0.0" });
|
|
|
|
try {
|
|
await client.connect(transport);
|
|
const tools = await client.listTools();
|
|
expect(tools.tools).toHaveLength(83);
|
|
const result = await client.callTool({
|
|
name: "current_document",
|
|
arguments: {},
|
|
});
|
|
expect(result.isError === true).toBe(process.platform === "linux");
|
|
} finally {
|
|
await client.close();
|
|
await transport.close();
|
|
}
|
|
const records = stderr
|
|
.trim()
|
|
.split("\n")
|
|
.filter((line) => line.length > 0)
|
|
.map((line: string): unknown => JSON.parse(line));
|
|
expect(records).toContainEqual(
|
|
expect.objectContaining({
|
|
application: "rea",
|
|
mode: "mcp",
|
|
layer: "server",
|
|
tool: "current_document",
|
|
status: process.platform === "linux" ? "error" : "ok",
|
|
}),
|
|
);
|
|
expect(stderr).not.toContain("HOPPER_LOADER_ARGS_JSON");
|
|
expect(stderr).not.toContain(fixturePath);
|
|
}, 15_000);
|
|
|
|
it("honors the configured kind for an initial database target", async () => {
|
|
const transport = new StdioClientTransport({
|
|
command: process.execPath,
|
|
args: [mainPath],
|
|
cwd: process.cwd(),
|
|
env: {
|
|
PATH: process.env.PATH ?? "",
|
|
HOPPER_LAUNCHER_PATH: process.execPath,
|
|
HOPPER_TARGET_PATH: new URL(import.meta.url).pathname,
|
|
HOPPER_TARGET_KIND: "database",
|
|
HOPPER_LOADER_ARGS_JSON: JSON.stringify([fixturePath]),
|
|
},
|
|
stderr: "pipe",
|
|
});
|
|
const client = new Client({ name: "database-runtime", version: "1.0.0" });
|
|
|
|
try {
|
|
await client.connect(transport);
|
|
expect((await client.listTools()).tools).toHaveLength(83);
|
|
} finally {
|
|
await client.close();
|
|
await transport.close();
|
|
}
|
|
}, 15_000);
|
|
});
|