refactor(background): require registry in status tool
This commit is contained in:
@@ -4,7 +4,13 @@ import { createBackgroundRegistry } from "./background-registry.ts";
|
||||
|
||||
test("recordLaunch and counts update correctly", () => {
|
||||
const reg = createBackgroundRegistry();
|
||||
reg.recordLaunch({ runId: "r1", preset: "p1", task: "t1" });
|
||||
reg.recordLaunch({
|
||||
runId: "r1",
|
||||
preset: "p1",
|
||||
task: "t1",
|
||||
paths: { resultPath: "/tmp/r1/result.json" },
|
||||
meta: { source: "test" },
|
||||
});
|
||||
reg.recordLaunch({ runId: "r2", preset: "p2", task: "t2" });
|
||||
|
||||
let counts = reg.getCounts();
|
||||
@@ -21,7 +27,10 @@ test("recordLaunch and counts update correctly", () => {
|
||||
const r2 = reg.getRun("r2");
|
||||
assert.ok(r1);
|
||||
assert.ok(r2);
|
||||
assert.deepEqual(r1?.paths, { resultPath: "/tmp/r1/result.json" });
|
||||
assert.deepEqual(r1?.meta, { source: "test" });
|
||||
assert.equal(r2?.finalText, "done");
|
||||
assert.equal(reg.getRun("missing"), undefined);
|
||||
});
|
||||
|
||||
test("replay seeds registry and counts", () => {
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { BackgroundAgentStatusSchema } from "./background-schema.ts";
|
||||
import type { BackgroundRegistry } from "./background-registry.ts";
|
||||
|
||||
export function createBackgroundStatusTool(deps: { registry: BackgroundRegistry } | { registry?: BackgroundRegistry } = {}) {
|
||||
const registry = (deps as any).registry;
|
||||
export function createBackgroundStatusTool(deps: { registry: BackgroundRegistry }) {
|
||||
const { registry } = deps;
|
||||
|
||||
return {
|
||||
name: "background_agent_status",
|
||||
@@ -10,13 +10,6 @@ export function createBackgroundStatusTool(deps: { registry: BackgroundRegistry
|
||||
description: "Query background agent runs and their status.",
|
||||
parameters: BackgroundAgentStatusSchema,
|
||||
async execute(_toolCallId: string, params: any = {}, _signal: AbortSignal | undefined, _onUpdate: any, _ctx: any) {
|
||||
if (!registry) {
|
||||
return {
|
||||
content: [{ type: "text" as const, text: "Background registry not available" }],
|
||||
details: { runs: [] },
|
||||
isError: true,
|
||||
};
|
||||
}
|
||||
|
||||
const runId = typeof params.runId === "string" ? params.runId : undefined;
|
||||
const includeCompleted = Boolean(params.includeCompleted);
|
||||
|
||||
Reference in New Issue
Block a user