import type { Database } from "bun:sqlite";
import type { LockResult, Task } from "../types/index.js";
export declare function getBlockingDeps(id: string, db?: Database): Task[];
export declare function startTask(id: string, agentId: string, db?: Database): Task;
export declare function completeTask(id: string, agentId?: string, db?: Database, options?: {
    files_changed?: string[];
    test_results?: string;
    commit_hash?: string;
    notes?: string;
    attachment_ids?: string[];
    skip_recurrence?: boolean;
    confidence?: number;
    completed_at?: string;
}): Task;
export declare function lockTask(id: string, agentId: string, db?: Database): LockResult;
export declare function unlockTask(id: string, agentId?: string, db?: Database): boolean;
export interface TaskLockStatus {
    task_id: string;
    locked: boolean;
    locked_by: string | null;
    locked_at: string | null;
    expires_at: string | null;
    expired: boolean;
}
export declare function getTaskLockStatus(id: string, db?: Database): TaskLockStatus;
export declare function claimNextTask(agentId: string, filters?: {
    project_id?: string;
    task_list_id?: string;
    plan_id?: string;
    tags?: string[];
}, db?: Database): Task | null;
export declare function getNextTask(agentId?: string, filters?: {
    project_id?: string;
    task_list_id?: string;
    plan_id?: string;
    tags?: string[];
}, db?: Database): Task | null;
export interface ActiveWorkItem {
    id: string;
    short_id: string | null;
    title: string;
    priority: string;
    assigned_to: string | null;
    locked_by: string | null;
    locked_at: string | null;
    updated_at: string;
}
export declare function getActiveWork(filters?: {
    project_id?: string;
    task_list_id?: string;
}, db?: Database): ActiveWorkItem[];
export declare function getTasksChangedSince(since: string, filters?: {
    project_id?: string;
    task_list_id?: string;
}, db?: Database): Task[];
export declare function failTask(id: string, agentId?: string, reason?: string, options?: {
    retry?: boolean;
    retry_after?: string;
    error_code?: string;
}, db?: Database): {
    task: Task;
    retryTask?: Task;
};
export type StaleTaskQuery = number | {
    minutes?: number;
    hours?: number;
    project_id?: string;
    task_list_id?: string;
};
export declare function getStaleTasks(staleQuery?: StaleTaskQuery, filters?: {
    project_id?: string;
    task_list_id?: string;
}, db?: Database): Task[];
/**
 * Work-stealing: find the highest-priority stale in_progress task and reassign it to the given agent.
 * A task is stealable if it's in_progress and its lock/update is older than staleMinutes.
 */
export declare function stealTask(agentId: string, opts?: {
    stale_minutes?: number;
    project_id?: string;
    task_list_id?: string;
}, db?: Database): Task | null;
/**
 * Enhanced claim: try pending queue first, then steal from stale agents if nothing pending.
 */
export declare function claimOrSteal(agentId: string, filters?: {
    project_id?: string;
    task_list_id?: string;
    plan_id?: string;
    tags?: string[];
    stale_minutes?: number;
}, db?: Database): {
    task: Task;
    stolen: boolean;
} | null;
//# sourceMappingURL=task-lifecycle.d.ts.map