/** * HandoffService — Phase 6 cross-session handoffs (G2). * * Lets an agent (session A) leave a structured handoff for a later agent * (session B). The handoff is persisted in the Handoff table AND * dual-written as a searchable `conversation` memory (FTS-discoverable * independently of the Handoff table). * * Contract (spec.md R1–R7, NF1–NF5): * - State machine: open → accepted | expired (both terminal). * - accept/cancel only valid on an `open` row; everything else is a * clear `{ok:false, reason}` failure (never a silent no-op). * - Silent degradation: optional LLM summary-polish is default-off and * best-effort; store/memory insert failures become `{ok:false}` * results. NEVER throws to the caller. * - Backend-polymorphic via the HandoffStore factory (no * `isPostgresEnabled()` short-circuit). * * Test-isolation (mirrors Phase-4 BootstrapService): the ctor accepts * injectable `store`, `memoryRepo`, `llm`, and `idFactory` seams. * Defaults resolve lazily at run time so the closed-MemoryRepository * landmine (memory-crud.test.ts) does not poison handoff tests. */ import { type HandoffRecord, type HandoffStore } from "../../data/handoff/handoff-repository.js"; import type { InsertMemoryInput } from "../../data/memory/memory-repository.js"; import type { LlmSurface } from "../memory/consolidator.js"; export interface BeginHandoffInput { projectId: string; sourceSessionId?: string; targetAgent?: string; summary?: string; openQuestions?: string[]; nextSteps?: string[]; files?: string[]; } export interface BeginResult { ok: boolean; id?: string; status?: "open"; memoryId?: string | null; reason?: string; } export interface AcceptCancelResult { ok: boolean; handoff?: HandoffRecord; reason?: string; } /** * Injectable memory-repository seam. The default implementation resolves * getMemoryRepository() lazily inside each method (test-isolation). */ export interface HandoffMemorySeam { insert(input: InsertMemoryInput): void | Promise; } export interface HandoffDeps { store?: HandoffStore; memoryRepo?: HandoffMemorySeam; llm?: LlmSurface; idFactory?: () => string; } export declare class HandoffService { private readonly store; private readonly memoryRepo; private readonly llm; private readonly idFactory; constructor(deps?: HandoffDeps); begin(input: BeginHandoffInput): Promise; private dualWrite; accept(params: { id: string; projectId?: string; }): Promise; cancel(params: { id: string; projectId?: string; }): Promise; private terminate; listPending(projectId: string, targetAgent?: string | null): HandoffRecord[]; } export declare function buildHandoffMemoryInput(memId: string, record: HandoffRecord): InsertMemoryInput; export declare function formatMemoryContent(record: HandoffRecord): string; export declare function getHandoffService(): HandoffService; export declare function resetHandoffService(): void; //# sourceMappingURL=handoff-service.d.ts.map