/** * Flow-level hooks — fire-and-forget notifications on terminal run outcomes. * * Payload is summary-only (never transcripts / phase outputs). * Hook failure must never change run status. */ import type { RunState } from "./store.ts"; export type HookEvent = "complete" | "fail" | "blocked"; export type HookAction = { type: "webhook"; url: string; timeoutMs?: number; } | { type: "file"; path: string; } | { type: "command"; run: string[]; }; export interface FlowHooks { onComplete?: HookAction[]; onFail?: HookAction[]; onBlocked?: HookAction[]; } export interface HookPayload { schema: "taskflow.hook.v1"; event: HookEvent; runId: string; flowName: string; status: string; host?: string; packageVersion?: string; startedAt?: number; endedAt?: number; phaseCounts: { total: number; completed: number; failed: number; skipped: number; cached: number; }; usage?: { inputTokens?: number; outputTokens?: number; totalCost?: number; }; outputSourcePhaseId?: string; errorSummary?: string; approvalPhaseId?: string; } export interface HookDispatchResult { event: HookEvent; dispatched: number; errors: string[]; } /** Map run status → hook event (or undefined if no hook fires). */ export declare function hookEventForStatus(status: string): HookEvent | undefined; export declare function actionsForEvent(hooks: FlowHooks | undefined, event: HookEvent): HookAction[]; /** Build summary payload — never includes phase outputs. */ export declare function buildHookPayload(event: HookEvent, state: RunState): HookPayload; /** Validate a single hook action; returns error string or null. */ export declare function validateHookAction(action: unknown, index: number, event: string): string | null; export declare function validateWebhookUrl(url: string): string | null; /** Validate flow.hooks block; returns error strings. */ export declare function validateFlowHooks(hooks: unknown): string[]; /** * Dispatch hooks for a terminal run. Never throws; collects errors. */ export declare function dispatchHooks(state: RunState, opts: { cwd: string; hooks?: FlowHooks; }): Promise; //# sourceMappingURL=hooks.d.ts.map