/** * Dispatch layer extracted from runtime.ts. * * Owns the hook bucket lookup, alias-deduped tool dispatch (P1-14), * single-flight + queueing per `(event, sessionID)` (P1-13, P2 #23), and * the `executeHook` -> `executeAction` invocation chain. Behaviour is * preserved verbatim from the pre-split implementation. The runtime * passes its mutable state (dispatchStates, asyncQueues, * actionRecursionGuards, the bound glob matcher) and a host adapter into * the entry points. */ import type { AsyncLocalStorage } from "node:async_hooks"; import type { BashExecutionRequest, BashHookResult } from "../bash-types.js"; import { type AsyncQueueState } from "./async-queue.js"; import { type GlobMatcher } from "./path-filter.js"; import type { HookExecutionResult, RuntimeActionContext } from "../runtime.js"; import type { SessionStateStore } from "../session-state.js"; import type { FileChange, HookEvent, HookMap, HostAdapter } from "../types.js"; type ExecuteBashHook = (request: BashExecutionRequest) => Promise; export interface DispatchState { active: boolean; pending: DispatchRequest[]; } export interface DispatchRequest { readonly context: RuntimeActionContext; readonly options: { canBlock?: boolean; }; readonly resolve?: (result: HookExecutionResult) => void; readonly reject?: (error: unknown) => void; readonly recursionGuardStore?: Set; } export declare function dispatchToolHooks(hooks: HookMap, state: SessionStateStore, host: HostAdapter, projectDir: string, runBashHook: ExecuteBashHook, dispatchStates: Map, actionRecursionGuards: AsyncLocalStorage>, asyncQueues: Map, warnedAsyncStopSources: Set, phase: "before" | "after", toolName: string, sessionID: string, context: RuntimeActionContext, globMatcher?: GlobMatcher): Promise; export declare function dispatchHooks(hooks: HookMap, state: SessionStateStore, host: HostAdapter, projectDir: string, runBashHook: ExecuteBashHook, event: HookEvent, sessionID: string, context: RuntimeActionContext | undefined, options: { canBlock?: boolean; } | undefined, dispatchStates: Map, actionRecursionGuards: AsyncLocalStorage>, asyncQueues: Map, warnedAsyncStopSources: Set, globMatcher?: GlobMatcher): Promise; export declare function summarizeChanges(changes: readonly FileChange[]): Array>; export {};