import type { Logger, ILogObj } from "tslog"; import type { RecoveryConfig } from "../../recovery/types.ts"; /** The lifecycle events a custom hook can listen to. */ export type HookEvent = "chat.message" | "tool.execute.before" | "tool.execute.after" | "system.transform" | "event"; /** Filter criteria to limit when a hook fires. */ export interface HookFilter { /** Only fire for these tool names (tool.execute.before/after only) */ tools?: string[]; /** Only fire for these event subtypes (event hook only: session.idle, session.error, etc.) */ eventTypes?: string[]; } /** A single custom hook declaration from role.yaml. */ export interface CustomHookConfig { name: string; description?: string; events: HookEvent[]; module: string; config?: Record; filter?: HookFilter; priority?: number; phase?: "before" | "after"; } /** The hooks block in role.yaml. */ export interface HooksBlock { builtin?: Record; custom?: CustomHookConfig[]; recovery?: RecoveryConfig; } export interface PromptBlock { tag: string; content: string; } export interface DispatchSnapshot { activeTaskCount: number; tasks: Array<{ id: string; status: string; subagent: string; }>; } export interface HookContext { hookName: string; config: Record | undefined; sessionID?: string; agent?: string; inject: (text: string) => void; log: Logger; replaceBlock?: (tag: string, newContent: string) => void; removeBlock?: (tag: string) => void; getBlocks?: () => PromptBlock[]; getFunctionState?: (fnName: string) => unknown | undefined; getDispatchState?: () => DispatchSnapshot | undefined; skip?: () => void; retry?: () => void; } /** The module interface that custom hook files must export. */ export interface HookModule { /** Called on chat.message hook */ onChatMessage?: (ctx: HookContext, input: { text: string; }) => void | Promise; /** Called on tool.execute.before hook */ onToolBefore?: (ctx: HookContext, input: { tool: string; args: unknown; }) => void | Promise; /** Called on tool.execute.after hook */ onToolAfter?: (ctx: HookContext, input: { tool: string; args: unknown; output: unknown; }) => void | Promise; /** Called on system.transform hook */ onSystemTransform?: (ctx: HookContext, input: { system: string[]; }) => void | Promise; /** Called on event hook (session.idle, session.error, etc.) */ onEvent?: (ctx: HookContext, input: { type: string; properties?: Record; }) => void | Promise; /** Called once when the hook is loaded (lifecycle) */ onLoad?: (ctx: HookContext) => void | Promise; /** Called once when the plugin disposes (lifecycle) */ onDispose?: (ctx: HookContext) => void | Promise; } //# sourceMappingURL=types.d.ts.map