/** * Async hook queue extracted from runtime.ts. * * Hooks declared `async: true` are not part of the dispatch loop — * they queue onto a per-(event|group)+session lane that respects the * configured concurrency limit. Behaviour preserved verbatim, including * the P3-1 simplification (`Promise.resolve().then(next)` over a sync * IIFE) for converting synchronous throws into rejected promises. */ import type { HookConfig } from "../types.js"; export interface AsyncQueueState { activeCount: number; pending: Array<() => Promise>; } export interface AsyncQueueWarning { readonly reason: "pending_limit" | "watchdog_timeout"; readonly queueKey: string; readonly pendingCount: number; readonly activeCount: number; readonly limit?: number; readonly timeoutMs?: number; } export interface AsyncQueueOptions { readonly maxPending?: number; readonly watchdogMs?: number; readonly onWarning?: (warning: AsyncQueueWarning) => void; } export declare function resolveAsyncExecutionConfig(hook: HookConfig, sessionID: string): { queueKey: string; concurrency: number; }; export declare function enqueueAsyncHook(asyncQueues: Map, config: { queueKey: string; concurrency: number; }, run: () => Promise, onError: (error: unknown) => void, options?: AsyncQueueOptions): void;