export interface HookPayload { hook_event_name: "SessionStart" | "Stop" | "StopFailure" | "PreToolUse" | "PostToolUse" | string; session_id?: string; transcript_path?: string; cwd?: string; last_assistant_message?: string; tool_name?: string; /** Present on StopFailure: enum — rate_limit | authentication_failed | billing_error | invalid_request | server_error | max_output_tokens | unknown */ error?: string; error_details?: string; [k: string]: unknown; } type HookListener = (h: HookPayload) => void; type UnclaimedHookHandler = (jinnSessionId: string, h: HookPayload) => void; export declare class HookRegistry { private ttlMs; private unclaimedDelayMs; private listeners; private buffer; private sweepTimer; /** Fallback consumer for Stop hooks no turn ever claims (PTY-native turns * typed straight into the xterm view, or a Stop arriving past the late- * recovery window). Set once by the gateway. */ private unclaimedHandler; /** Per-session debounce timers for the unclaimed-Stop fallback. */ private unclaimedTimers; constructor(ttlMs?: number, sweepIntervalMs?: number, unclaimedDelayMs?: number); /** Install the fallback consumer for unclaimed Stop hooks. A Stop that lands * with no registered listener is buffered as usual AND starts/refreshes a * short timer; if the session is still unclaimed when it fires, the handler * receives the Stop (and the consumed Stops leave the buffer so a later * register() can't replay them into a NEW turn's resolver). */ setUnclaimedHookHandler(handler: UnclaimedHookHandler): void; register(jinnSessionId: string, listener: HookListener): void; unregister(jinnSessionId: string): void; deliver(jinnSessionId: string, payload: HookPayload): void; private armUnclaimedTimer; private cancelUnclaimedTimer; /** Timer expired with the session still unclaimed: hand the buffered Stop(s) * to the fallback handler. Consumed Stops are REMOVED from the buffer so a * later register() can't drain a stale Stop into a fresh turn's resolver. * Only the newest Stop is delivered — the handler syncs the transcript tail * from an anchor, so intermediate Stops are covered by the same sync. */ private fireUnclaimed; /** Drop buffered entries whose `at` is older than ttlMs. */ private sweep; /** Stop the periodic sweep timer. Call when shutting down the registry. */ dispose(): void; } export {}; //# sourceMappingURL=hook-registry.d.ts.map