fix: align runtime startup and model events

This commit is contained in:
Wenxin Duan
2026-09-08 10:47:42 +08:00
parent 89ce7973c3
commit da7558ab49
8 changed files with 79 additions and 18 deletions
+5 -2
View File
@@ -1,4 +1,4 @@
import { HarnessError } from "@agent-studio/harness";
import { HarnessError, InMemoryEventStore } from "@agent-studio/harness";
import type { FastifyInstance } from "fastify";
import { vi } from "vitest";
import { buildApp } from "../src/app.js";
@@ -14,6 +14,7 @@ export function createTestApp(): {
};
attachmentStore: { add: ReturnType<typeof vi.fn>; remove: ReturnType<typeof vi.fn> };
approvalBroker: { approve: ReturnType<typeof vi.fn>; deny: ReturnType<typeof vi.fn> };
eventStore: InMemoryEventStore;
} {
const session = {
sessionId: "ses_1",
@@ -57,15 +58,17 @@ export function createTestApp(): {
approve: vi.fn((approvalId: string) => ({ approvalId, status: "approved" as const })),
deny: vi.fn((approvalId: string) => ({ approvalId, status: "denied" as const })),
};
const eventStore = new InMemoryEventStore();
const app = buildApp({
sessionRegistry: registry,
skillCatalog: { list: () => [{ name: "ads-analysis", description: "Analyze", source: "project", filePath: ".agents/skills/ads-analysis/SKILL.md", diagnostics: [] }] },
modelStore,
attachmentStore,
approvalBroker,
eventStore,
testModelConnection: () => Promise.resolve({ status: "deferred", message: "Saved; validation will occur on first run." }),
});
return { app, session, modelStore, attachmentStore, approvalBroker };
return { app, session, modelStore, attachmentStore, approvalBroker, eventStore };
}
export function makeSessionBusy(session: { startRun: ReturnType<typeof vi.fn> }): void {