import type { ISessionClient } from "../platform/ports/session-client.ts"; import type { NotificationConfig, NotificationTemplateVars } from "./types.ts"; export declare class NotificationManager { private globalConfig; private roleConfigs; private client; private dir; private scheduler; private throttle; private quietHours; /** Channel cache: keyed by agent (or GLOBAL_CHANNEL_KEY). Stores the * promise during creation, then the resolved array once done. */ private channelCache; private platform; constructor(opts: { globalConfig: NotificationConfig; roleConfigs: Map; client: ISessionClient; dir: string; }); /** * Resolve the effective `NotificationConfig` for a session. * * If `agent` is provided and a matching role config exists, the role * config is merged on top of the global config. Otherwise the bare * global config is returned. */ getConfigForSession(_sessionID: string, agent?: string): NotificationConfig; /** * The primary notification entry point. * * Applies guard checks (enabled, per-event enabled, quiet hours, throttle) * before building content and dispatching to all active channels. * NEVER throws — all errors are caught and logged at warn level. */ notify(opts: { sessionID: string; eventType: string; agent?: string; roleName?: string; questionText?: string; /** Extra template variables merged over the base vars (e.g. graph_id / node_id). */ templateVars?: NotificationTemplateVars; }): Promise; /** * Resolve notification channels for a cache key, lazily creating them * from the provided configs. The promise is cached to prevent races when * multiple notifications fire at the same time. */ private resolveChannels; /** Mark session activity (delegates to scheduler). */ markActivity(sessionID: string): void; /** * Schedule an idle notification for a session. * When the idle timer fires, calls `this.notify` with Idle event type. */ scheduleIdle(sessionID: string, agent?: string): void; /** Handle session deletion (clean up scheduler + throttle state). */ handleSessionDeleted(sessionID: string): void; /** Handle session errors by firing an Error notification. */ handleSessionError(sessionID: string, agent?: string): void; /** Handle message update by marking session activity. */ handleMessageUpdated(sessionID: string, _agent?: string): void; /** Handle chat message by marking session activity. */ handleChatMessage(sessionID: string, _agent?: string): void; /** * Handle tool-before events. If the tool name matches a configured * question tool name, extract the question text from args and fire * a Question notification. */ handleToolBefore(sessionID: string, tool: string, args?: unknown, agent?: string): void; /** Handle dispatch completion by firing a DispatchComplete notification. */ handleDispatchComplete(sessionID: string, agent?: string): void; /** Handle loop completion by firing a LoopComplete notification. */ handleLoopComplete(sessionID: string, agent?: string): void; /** * Handle a graph reaching a quiescent-blocked state (one or more nodes await * approval) by firing an ApprovalPending notification. Mirrors * {@link handleDispatchComplete}: goes through the standard `notify` path so * channel routing, quiet-hours, and throttle all apply. Passes `graph_id` / * `node_id` as template vars so the title/message templates can reference * them (e.g. "Approval gate waiting: {graph_id}/{node_id}"). * * @param sessionID - Owning (emperor/orchestrator) session id. * @param graphId - The blocked graph's id. * @param nodeId - The blocked node id, when known. The graph-terminal seam * is graph-level and may not carry a single node id, so this is optional. * @param agent - Optional agent tag for role-scoped config resolution. */ handleApprovalPending(sessionID: string, graphId: string, nodeId?: string, agent?: string): void; /** * Hot-reload the notification configuration. * * Updates global and role-level configs, recreates throttle and quiet * hours instances, updates the scheduler's idle delay, and clears the * channel cache. */ reloadConfig(global: NotificationConfig, roleConfigs: Map): void; /** * Dispose all resources: scheduler, throttle, and all cached channels. * Safe to call multiple times. */ dispose(): Promise; } //# sourceMappingURL=manager.d.ts.map