Refactor runtime around isolated bot instances
This commit is contained in:
@@ -3,21 +3,19 @@ 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";
|
||||
import { BotProfileResolver } 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: {}
|
||||
configVersion: 3,
|
||||
bot: { id: "test-bot", workspace: path.resolve("."), persona: "", agent: { id: "fake", command: process.execPath, args: [fixture] }, permissions: { mode: "deny" } },
|
||||
gateway: { platform: { type: "webhook", secret: "secret" } },
|
||||
runtime: { acp: { promptTimeoutMs, cancelGraceMs: 30 } }
|
||||
});
|
||||
let crashes = 0;
|
||||
const worker = new AcpWorker(config.backends[0], new RoleRegistry(config).get(), config.acp, () => { crashes++; });
|
||||
const worker = new AcpWorker(new BotProfileResolver(config).bot, config.runtime.acp, () => { crashes++; });
|
||||
return { worker, crashes: () => crashes };
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user