import test from "node:test"; import assert from "node:assert/strict"; import { createBackgroundRegistry } from "./background-registry.ts"; import { createBackgroundStatusTool } from "./background-status-tool.ts"; test("status tool shows active runs by default and can query single run", async () => { const reg = createBackgroundRegistry(); reg.recordLaunch({ runId: "r1", preset: "p1", task: "t1" }); reg.recordLaunch({ runId: "r2", preset: "p2", task: "t2" }); reg.recordUpdate("r2", { status: "completed", exitCode: 0, finalText: "done" }); const tool = createBackgroundStatusTool({ registry: reg }); const resDefault: any = await tool.execute("id", {}, undefined, undefined, undefined); // default should show only active (running) runs assert.equal(resDefault.details.runs.length, 1); assert.equal(resDefault.details.runs[0].runId, "r1"); assert.match(resDefault.content[0].text, /Active runs: 1/); const resSingle: any = await tool.execute("id", { runId: "r2" }, undefined, undefined, undefined); assert.equal(resSingle.details.runs.length, 1); assert.equal(resSingle.details.runs[0].runId, "r2"); assert.match(resSingle.content[0].text, /status=completed/); const resNotFound: any = await tool.execute("id", { runId: "nope" }, undefined, undefined, undefined); assert.equal(resNotFound.details.runs.length, 0); assert.match(resNotFound.content[0].text, /No run found/); });