import type { ExtensionContext } from '@earendil-works/pi-coding-agent'; import type { HookCommand, HookEventName, HookGroup, HookRuntime } from './hooks-config.js'; /** JSON payload written to a hook command's stdin: Claude-Code field names plus snake/camel workspace-root aliases. */ export interface HookPayload extends Record { hook_event_name: HookEventName; cwd: string; session_id: string; transcript_path?: string | undefined; workspace_root?: string | undefined; workspaceRoot?: string | undefined; project_dir?: string | undefined; projectDir?: string | undefined; } /** Options for {@link createBasePayload}. */ export interface CreateBasePayloadOptions { eventName: HookEventName; ctx: ExtensionContext; runtime: HookRuntime; extra?: Record | undefined; } export interface RunHookOptions { eventName: HookEventName; matcherTarget: string; payload: HookPayload; runtime: HookRuntime; ctx: ExtensionContext; signal?: AbortSignal | undefined; stopAfterBlockingPreHook?: boolean | undefined; } export interface HookCommandResult { eventName: HookEventName; hook: HookCommand; code: number; stdout: string; stderr: string; timedOut: boolean; aborted: boolean; } /** * Runs every command hook whose group matches `options.matcherTarget`, in * manifest order, toggling the status line for the duration. With * `stopAfterBlockingPreHook` (PreToolUse only), stops at the first * blocking result. */ export declare function runMatchingHooks(options: RunHookOptions): Promise; /** True when `group.matcher` is absent (matches everything) or matches `target`; falls back to an exact-string match when the matcher isn't valid regex. */ export declare function matchesHookGroup(group: HookGroup, target: string): boolean; /** Builds the JSON payload written to a hook's stdin: Claude-Code field names plus snake/camel workspace-root aliases so both naming conventions work. */ export declare function createBasePayload(options: CreateBasePayloadOptions): HookPayload; /** Claude-Code hook matchers use PascalCase tool names (`Bash`, `Read`); pi's tool-call events use lowercase. */ export declare function getHookToolName(toolName: string): string; export declare function isBlockingPreToolResult(result: HookCommandResult): boolean; export declare function isFailedHookResult(result: HookCommandResult): boolean; export declare function formatHookFeedback(eventName: HookEventName, results: HookCommandResult[]): string; /** Formats a hook's captured stdout+stderr for feedback text, appending a truncation notice (line/byte counts) when the combined output exceeded the tool-output limits. */ export declare function formatHookOutput(result: HookCommandResult): string;