/** * Completion-edge detection over session-list snapshots: a pure fold from * (previous running bits, running-start times) and one row view to the set * of sessions whose turn just finished. First observation only records the * running bit — mirroring the Host summary semantics where sessions already * idle at load never ring; sessions removed from the list drop their * bookkeeping. */ import type { SessionSummary } from '@deepseek-ai/dsh-client-runtime/client'; import type { NotifyRemind } from '../notify-settings.ts'; /** One turn completion that passed the timing and scope filters. */ export interface CompletionEdge { /** The session whose turn ended. */ sessionId: string; /** Observed turn duration in ms. */ durationMs: number; } /** Options controlling edge collection. */ export interface EdgeOptions { /** Current time in ms (injected for deterministic tests). */ now: number; /** Turns shorter than this (ms) never ring. */ minTurnMs: number; /** 'background-only' rings only sessions the Host marks completed (not selected). */ remind: NotifyRemind; } /** Fold result: the filtered edges plus the next bookkeeping maps. */ export interface EdgeFold { /** Completions that passed every filter. */ edges: CompletionEdge[]; /** Running bit per session for the next fold. */ nextRunning: Map; /** Running-start time per session for the next fold. */ nextSince: Map; } /** * Fold one list snapshot into edges plus next bookkeeping. * @param prevRunning - running bit per session from the previous fold. * @param prevSince - running-start time per session from the previous fold. * @param rows - current session summary rows. * @param options - timing and scope filters. * @returns the fold result. */ export declare function collectCompletionEdges(prevRunning: ReadonlyMap, prevSince: ReadonlyMap, rows: readonly SessionSummary[], options: EdgeOptions): EdgeFold;