import { type NormalizedHook } from "../../hooks/normalize"; import type { HookMessage } from "../../session/messages"; import type { SessionManager } from "../../session/session-manager"; import type { ExtensionFactory } from "../extensions/types"; 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; /** Canonical discovery descriptor when loaded from a known hook convention. */ normalization?: NormalizedHook; } /** * Result of loading hooks. */ export interface LoadHooksResult { /** Successfully loaded hooks */ hooks: LoadedHook[]; /** Errors encountered during loading */ errors: Array<{ path: string; error: string; }>; } export interface LoadHookExtensionsResult { factories: Array<{ factory: ExtensionFactory; name: string; }>; 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 canonical native GJC configuration. * Claude Code and Codex hook layouts remain registered capability providers for * explicit import and diagnostics, but are not competing runtime authorities. * * Plus any explicitly configured paths from settings. */ export declare function discoverAndLoadHooks(configuredPaths: string[], cwd: string): Promise; /** Load normalized directory hooks and adapt them into the authoritative ExtensionRunner path. */ export declare function discoverAndLoadHookExtensions(configuredPaths: string[], cwd: string): Promise; export {};