/** * notification-hub.ts — Cancellable completion notifications for index.ts. * * Owns the pending-nudge debounce (a completed agent's notification is held * briefly so get_subagent_result can consume the result first), individual * nudge emission, and lifetime usage → event-data mapping. Extracted from * index.ts so the entry point shrinks to wiring, not notification logic. */ import type { ExtensionAPI } from "@earendil-works/pi-coding-agent"; import type { AgentRecord } from "./types.js"; import type { AgentActivity } from "./ui/agent-ui-types.js"; /** Minimal widget surface the hub needs (avoids importing LiveWidgets class). */ export interface NotificationWidgets { markFinished(id: string): void; update(): void; } export interface NotificationHubDeps { pi: ExtensionAPI; /** Shared activity map — read for details, written on send. */ agentActivity: Map; /** Accessor because LiveWidgets is constructed after the hub in index.ts. */ getWidgets: () => NotificationWidgets | undefined; } export declare class NotificationHub { private readonly deps; private readonly pending; private static readonly NUDGE_HOLD_MS; constructor(deps: NotificationHubDeps); /** * Hold a notification briefly so get_subagent_result can cancel it before * it reaches pi.sendMessage (fire-and-forget). */ schedule(key: string, send: () => void, delay?: number): void; cancel(key: string): void; emitIndividual(record: AgentRecord): void; sendIndividual(record: AgentRecord): void; /** Lifetime-accumulated usage → lifecycle event payload. */ buildEventData(record: AgentRecord): { id: string; type: string; description: string; result: string | undefined; error: string | undefined; status: import("./types.js").AgentStatus; toolUses: number; durationMs: number; tokens: { input: number; output: number; total: number; } | undefined; }; dispose(): void; }