/** * Gemini CLI hook event payload delivered on stdin. * * Gemini CLI invokes hooks as shell commands, passing JSON on stdin * and reading JSON from stdout. Exit code 2 blocks the action. * * Events: SessionStart, SessionEnd, BeforeAgent, AfterAgent, * BeforeModel, BeforeToolSelection, AfterModel, BeforeTool, AfterTool, * Notification, PreCompress. * * See: https://geminicli.com/docs/hooks/reference/ */ export interface GeminiHookInput { session_id: string; transcript_path: string; cwd: string; hook_event_name: string; timestamp?: string; source?: string; reason?: string; prompt?: string; prompt_response?: string; stop_hook_active?: boolean; tool_name?: string; tool_input?: Record; tool_response?: Record; mcp_context?: Record; original_request_name?: string; llm_request?: Record; llm_response?: Record; notification_type?: string; message?: string; details?: Record; trigger?: "auto" | "manual"; } /** * Gemini CLI hook output written to stdout. */ export interface GeminiHookOutput { decision?: "allow" | "deny" | "block"; reason?: string; systemMessage?: string; continue?: boolean; stopReason?: string; suppressOutput?: boolean; hookSpecificOutput?: GeminiHookSpecificOutput; } export interface GeminiHookSpecificOutput { /** BeforeTool: override tool arguments */ tool_input?: Record; /** AfterTool: append to tool result */ additionalContext?: string; /** AfterTool: chain a follow-up tool call */ tailToolCallRequest?: Record; /** AfterAgent: clear agent context */ clearContext?: boolean; /** BeforeModel: synthesize an llm_response and short-circuit the model call */ llm_response?: Record; /** BeforeToolSelection: restrict the tools the model can pick */ toolConfig?: { mode?: "AUTO" | "ANY" | "NONE"; allowedFunctionNames?: string[]; }; [key: string]: unknown; }