import { Config, Task } from './types';
import { TaskProvider } from './providers/base';
import { AIRunner, AIRunResult } from './ai/base';
import { ReviewThread } from './github';
export interface RunContext {
    config: Config;
    filter: string;
    taskCount: number;
}
export interface TaskContext {
    task: Task;
    config: Config;
    branchName: string;
    prompt: string;
}
export interface ResolveConflictsContext {
    task: Task;
    config: Config;
    branchName: string;
    conflictFiles: string[];
    prompt: string;
}
export interface NonCodeTaskContext {
    task: Task;
    config: Config;
    prompt: string;
}
export interface ThinkingTaskContext {
    task: Task;
    config: Config;
    branchName: string;
    subtasks: Array<{
        id: number | string;
        title: string;
        description: string;
        status: string;
    }>;
}
export interface ReviewTaskContext {
    task: Task;
    config: Config;
    branchName: string;
    threads: ReviewThread[];
    prompt: string;
}
export interface HookVM {
    /** Run a prompt through the first available AI runner */
    runAI(prompt: string): Promise<AIRunResult>;
    /** Post a comment on a task */
    postComment(taskId: string, text: string): Promise<void>;
    /** Update task status */
    updateStatus(taskId: string, status: string): Promise<void>;
    /** Get task comments */
    getComments(taskId: string): Promise<Array<{
        id: string;
        text: string;
        author: string;
    }>>;
    /** Access the logger */
    log: {
        info(msg: string): void;
        warn(msg: string): void;
        error(msg: string): void;
    };
}
export interface AidevHooks {
    /** Called before the run loop starts processing tasks */
    beforeRun?(context: RunContext, vm: HookVM): Promise<RunContext | void>;
    /** Called after the run loop finishes processing all tasks */
    afterRun?(context: RunContext & {
        processed: number;
        skipped: number;
    }, vm: HookVM): Promise<void>;
    /** Called before each task is implemented (code tasks) */
    beforeEachTask?(context: TaskContext, vm: HookVM): Promise<TaskContext | void>;
    /** Called after each task is implemented (code tasks) */
    afterEachTask?(context: TaskContext & {
        success: boolean;
    }, vm: HookVM): Promise<void>;
    /** Called before merge conflict resolution */
    beforeResolveConflicts?(context: ResolveConflictsContext, vm: HookVM): Promise<ResolveConflictsContext | void>;
    /** Called after merge conflict resolution */
    afterResolveConflicts?(context: ResolveConflictsContext & {
        resolved: boolean;
    }, vm: HookVM): Promise<void>;
    /** Called before each non-code task is executed */
    beforeNonCodeTask?(context: NonCodeTaskContext, vm: HookVM): Promise<NonCodeTaskContext | void>;
    /** Called after each non-code task is executed */
    afterNonCodeTask?(context: NonCodeTaskContext & {
        success: boolean;
        output: string;
    }, vm: HookVM): Promise<void>;
    /** Called before a thinking task is analyzed and planned */
    beforeThinkingTask?(context: ThinkingTaskContext, vm: HookVM): Promise<ThinkingTaskContext | void>;
    /** Called after all sub-tasks of a thinking task complete */
    afterThinkingTask?(context: ThinkingTaskContext & {
        success: boolean;
    }, vm: HookVM): Promise<void>;
    /** Called before a review task's unresolved threads are processed */
    beforeReviewTask?(context: ReviewTaskContext, vm: HookVM): Promise<ReviewTaskContext | void>;
    /** Called after a review task's threads have been processed */
    afterReviewTask?(context: ReviewTaskContext & {
        success: boolean;
        resolvedCount: number;
    }, vm: HookVM): Promise<void>;
}
/**
 * Loads hooks from the file path specified by AIDEV_HOOKS_PATH env var or
 * the config's hooksPath. Supports .ts (via jiti) and .js files.
 * Returns an empty object if no hooks file is configured or found. Exports that are not
 * known hook names are stripped so the returned object only contains hook functions.
 */
export declare function loadHooks(hooksPath: string): AidevHooks;
export declare function createHookVM(provider: TaskProvider, runners: AIRunner[]): HookVM;
/**
 * Safely execute a hook function. If the hook throws, the error propagates
 * to the caller (which should abort the operation). If the hook returns a
 * modified context, that context is returned; otherwise the original is.
 */
export declare function executeHook<T>(hooks: AidevHooks, hookName: keyof AidevHooks, context: T, vm: HookVM): Promise<T>;
//# sourceMappingURL=hooks.d.ts.map