Add ACP-backed role sessions
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
import assert from "node:assert/strict";
|
||||
import path from "node:path";
|
||||
import test from "node:test";
|
||||
import { AcpWorker } from "../src/acp/worker.js";
|
||||
import { parseConfig } from "../src/config.js";
|
||||
import { RoleRegistry } from "../src/roles/role-registry.js";
|
||||
|
||||
const fixture = path.resolve("test/fixtures/fake-acp-agent.mjs");
|
||||
|
||||
function makeWorker(promptTimeoutMs = 80) {
|
||||
const config = parseConfig({
|
||||
configVersion: 2,
|
||||
acp: { promptTimeoutMs, cancelGraceMs: 30 },
|
||||
backends: [{ id: "kimi", command: process.execPath, args: [fixture] }],
|
||||
defaultRole: "assistant",
|
||||
roles: [{ id: "assistant", backend: "kimi", workspace: path.resolve("."), policy: { permissionMode: "deny" } }],
|
||||
platforms: {}
|
||||
});
|
||||
let crashes = 0;
|
||||
const worker = new AcpWorker(config.backends[0], new RoleRegistry(config).get(), config.acp, () => { crashes++; });
|
||||
return { worker, crashes: () => crashes };
|
||||
}
|
||||
|
||||
test("worker times out a hung prompt and can be terminated", async () => {
|
||||
const { worker } = makeWorker();
|
||||
await worker.start();
|
||||
await assert.rejects(worker.prompt("hang"), /timed out/);
|
||||
await worker.terminate();
|
||||
});
|
||||
|
||||
test("worker reports an unexpected ACP subprocess exit", async () => {
|
||||
const current = makeWorker(500);
|
||||
await current.worker.start();
|
||||
await assert.rejects(current.worker.prompt("crash"));
|
||||
await new Promise((resolve) => setTimeout(resolve, 20));
|
||||
assert.equal(current.crashes(), 1);
|
||||
});
|
||||
Reference in New Issue
Block a user