/** * Hooks System * * Event-triggered scripts that automate workflows, based on AGI CLI's hooks architecture. * Hooks can execute shell commands or query an LLM for decisions. */ /** * Hook event types */ export type HookEvent = 'PreToolUse' | 'PostToolUse' | 'PermissionRequest' | 'UserPromptSubmit' | 'SessionStart' | 'SessionEnd' | 'Stop' | 'SubagentStop' | 'Notification'; /** * Hook types */ export type HookType = 'command' | 'prompt'; /** * Hook definition */ export interface HookDefinition { /** Regex pattern to match tool names or events */ matcher?: string; /** Type of hook: 'command' for shell, 'prompt' for LLM */ type: HookType; /** Shell command to execute (for command hooks) */ command?: string; /** Prompt to send to LLM (for prompt hooks) */ prompt?: string; /** Timeout in milliseconds */ timeout?: number; } /** * Hook execution result */ export interface HookResult { success: boolean; output?: string; decision?: 'allow' | 'deny' | 'continue'; reason?: string; error?: string; blocked?: boolean; } /** * Hook execution context */ export interface HookContext { event: HookEvent; toolName?: string; toolArgs?: Record; toolResult?: string; userInput?: string; sessionId?: string; workingDir: string; } /** * Hooks configuration */ export interface HooksConfig { [event: string]: HookDefinition[]; } /** * Load hooks from settings files */ export declare function loadHooks(workingDir: string): HooksConfig; /** * HooksManager class for managing and executing hooks */ export declare class HooksManager { private hooks; private workingDir; constructor(workingDir: string); /** * Reload hooks from settings files */ reload(): void; /** * Check if hooks are configured for an event */ hasHooks(event: HookEvent): boolean; /** * Get all hooks for an event */ getHooks(event: HookEvent): HookDefinition[]; /** * Execute all matching hooks for an event */ executeHooks(context: HookContext): Promise; /** * Execute pre-tool hooks and check if tool should proceed */ executePreToolHooks(toolName: string, args: Record): Promise<{ allowed: boolean; results: HookResult[]; }>; /** * Execute post-tool hooks */ executePostToolHooks(toolName: string, args: Record, result: string): Promise; /** * Execute user prompt hooks */ executeUserPromptHooks(userInput: string): Promise<{ allowed: boolean; results: HookResult[]; }>; /** * Execute session lifecycle hooks */ executeSessionHook(event: 'SessionStart' | 'SessionEnd', sessionId: string): Promise; } /** * Create a hooks manager for the given working directory */ export declare function createHooksManager(workingDir: string): HooksManager; //# sourceMappingURL=hooks.d.ts.map