import type { DelegationResult, DelegationStatus } from "../delegation/types.js"; export type CompletionSignal = "idle" | "error" | "deleted" | "timeout" | "cancelled"; export type CompletionResult = { signal: CompletionSignal; sessionID: string; error?: string; }; export declare class CompletionDetector { private readonly stabilityTimeoutMs; private watchers; private cachedResults; private dualSignalWatchers; private messageCounts; private stabilityTimers; private timerStartTimes; constructor(stabilityTimeoutMs?: number); feed(eventType: string, sessionID: string | undefined, error?: string): void; watch(sessionID: string, timeoutMs: number): Promise; /** * Watches a WaiterModel delegation until both native completion and terminal status signals arrive. * * @param delegationId - Delegation record identifier used by the coordination layer * @param childSessionId - Child session associated with the delegated native Task execution * @param callback - Callback invoked exactly once after both completion signals are present */ watchDualSignal(delegationId: string, _childSessionId: string, callback: (result: DelegationResult) => void): void; /** Marks that native Task completion was observed for a delegation. */ signalCompletionEvent(delegationId: string, result?: DelegationResult): void; /** Marks the latest lifecycle status for a delegation, completing only for terminal statuses. */ signalTerminalStatus(delegationId: string, status: DelegationStatus): void; /** Clears standard and WaiterModel completion state for the provided watcher key. */ unwatch(key: string): void; /** * Non-destructively peeks at a cached terminal signal without consuming it. * * Used by the SDK polling loop (Phase 36.1 re-wiring) so a poll cycle can * look ahead without losing the cached result if it decides not to act. * * @param sessionID - Child session ID being polled. * @returns The cached `CompletionResult`, or `undefined` if none is cached. */ peekCachedResult(sessionID: string): CompletionResult | undefined; /** * Consumes (reads + clears) a cached terminal signal for the given session. * * Used by the SDK polling loop (Phase 36.1 re-wiring) when a cached signal * has been acted on and should not fire a second time. Idempotent: returns * `undefined` if there is no cached result, or if a previous call already * consumed it. * * @param sessionID - Child session ID being polled. * @returns The previously cached `CompletionResult`, or `undefined`. */ consumeCachedResult(sessionID: string): CompletionResult | undefined; cancel(sessionID: string): void; feedMessageCount(sessionID: string, count: number): void; private startStabilityTimer; private clearStabilityTimer; /** * Removes stability timers that have been running longer than maxAgeMs. * Call periodically from the monitor/poll loop to prevent unbounded Map growth. * * @param maxAgeMs - Maximum age in milliseconds. Timers older than this are pruned. * @returns The number of timers that were pruned. */ pruneStaleTimers(maxAgeMs: number): number; private fireDualSignalIfReady; private mergeCompletionResult; private isTerminalStatus; } //# sourceMappingURL=detector.d.ts.map