import type { HookMessage } from "../../session/messages"; import type { SessionManager } from "../../session/session-manager"; import type { HookMessageRenderer, RegisteredCommand } from "./types"; /** * Generic handler function type. */ type HandlerFn = (...args: unknown[]) => Promise; /** * Send message handler type for pi.sendMessage(). */ export type SendMessageHandler = (message: Pick, "customType" | "content" | "display" | "details" | "attribution">, options?: { triggerTurn?: boolean; deliverAs?: "steer" | "followUp"; }) => void; /** * Append entry handler type for pi.appendEntry(). */ export type AppendEntryHandler = (customType: string, data?: T) => void; /** * New session handler type for ctx.newSession() in HookCommandContext. */ export type NewSessionHandler = (options?: { parentSession?: string; setup?: (sessionManager: SessionManager) => Promise; }) => Promise<{ cancelled: boolean; }>; /** * Branch handler type for ctx.branch() in HookCommandContext. */ export type BranchHandler = (entryId: string) => Promise<{ cancelled: boolean; }>; /** * Navigate tree handler type for ctx.navigateTree() in HookCommandContext. */ export type NavigateTreeHandler = (targetId: string, options?: { summarize?: boolean; }) => Promise<{ cancelled: boolean; }>; /** * Registered handlers for a loaded hook. */ export interface LoadedHook { /** Original path from config */ path: string; /** Resolved absolute path */ resolvedPath: string; /** Map of event type to handler functions */ handlers: Map; /** Map of customType to hook message renderer */ messageRenderers: Map; /** Map of command name to registered command */ commands: Map; /** Set the send message handler for this hook's pi.sendMessage() */ setSendMessageHandler: (handler: SendMessageHandler) => void; /** Set the append entry handler for this hook's pi.appendEntry() */ setAppendEntryHandler: (handler: AppendEntryHandler) => void; } /** * Result of loading hooks. */ export interface LoadHooksResult { /** Successfully loaded hooks */ hooks: LoadedHook[]; /** Errors encountered during loading */ errors: Array<{ path: string; error: string; }>; } /** * Load all hooks from configuration. * @param paths - Array of hook file paths * @param cwd - Current working directory for resolving relative paths */ export declare function loadHooks(paths: string[], cwd: string): Promise; /** * Discover and load hooks from all registered providers. * Uses the capability API to discover hook paths from: * 1. OMP native configs (.omp/.pi hooks/) * 2. Installed plugins * 3. Other editor/IDE configurations * * Plus any explicitly configured paths from settings. */ export declare function discoverAndLoadHooks(configuredPaths: string[], cwd: string): Promise; export {};