export interface BgWaitGuard { /** Re-arm timers after a chained continuation reported new remaining counts. * rearm(0, 0) settles immediately. No-op once settled. */ rearm(running: number, undelivered: number): void; /** Idempotent: clears timers and releases the busy bracket exactly once. */ settle(): void; readonly settled: boolean; } export interface BgWaitGuardOpts { running: number; undelivered: number; /** Busy bracket (trackPendingTask). +1 at start, -1 on settle. */ track: (delta: number) => void; /** Fired when undelivered-only work produced no notification within the grace period. */ onGraceTimeout: () => void; /** Fired when running work exceeded the max-wait cap. */ onMaxWait: () => void; graceMs?: number; maxWaitMs?: number; /** Injectable timers for tests. Production timers are unref'd (never hold the loop). */ timers?: { set: (fn: () => void, ms: number) => unknown; clear: (h: unknown) => void; }; } import { getBgGraceMs, getBgMaxWaitMs } from '../agent-adapter/bg-wait.js'; export { getBgGraceMs, getBgMaxWaitMs }; export declare function startBgWaitGuard(opts: BgWaitGuardOpts): BgWaitGuard;