import type { TaskList } from "../../../task-list/dist/index.js";
import { spawn as defaultSpawn } from "../../../agent-spawn/dist/index.js";
import { runAttempt as defaultRunAttempt, type AttemptEvent, type AttemptOutcome } from "../agent/runner.js";
import type { DispatchValidationResult } from "../config/validate.js";
import { type EnsureWorkspaceResult } from "../workspace/manager.js";
import type { AttemptPhase } from "./phases.js";
import { type ReconcileResult } from "./reconcile.js";
import { type MaestroState } from "./state.js";
export type TickEvent = {
    type: "tick_started";
    running: number;
} | {
    type: "task_skipped";
    task_id: string;
    reason: "unsupported_kind";
    kind: string;
} | {
    type: "dispatch";
    task_id: string;
    attempt: number;
    workspace: string;
} | {
    type: "worker_exit";
    task_id: string;
    attempt: number;
    phase: WorkerExitPhase;
    outcome: AttemptOutcome;
} | {
    type: "retry_scheduled";
    task_id: string;
    attempt: number;
    due_at: number;
} | {
    type: "reconcile";
    task_id: string;
    action: ReconcileResult["action"];
} | {
    type: "validation_failed";
    result: Exclude<DispatchValidationResult, {
        ok: true;
    }>;
} | AttemptEvent;
type WorkerExitPhase = Extract<AttemptPhase, "succeeded" | "failed" | "canceled"> | "skipped";
export interface TrackedWorker {
    taskId: string;
    controller: AbortController;
    promise: Promise<void>;
}
export interface TickDeps {
    tasks: Pick<TaskList, "allTasks" | "get" | "list" | "lists">;
    validateDispatch?: (cfg: MaestroState["cfg"], taskList: Pick<TaskList, "lists">) => Promise<DispatchValidationResult>;
    reconcileRunning?: (state: MaestroState) => Promise<ReconcileResult[]>;
    ensureWorkspace?: (root: string, qualifiedId: string) => Promise<EnsureWorkspaceResult>;
    removeWorkspace?: (root: string, qualifiedId: string) => Promise<void>;
    runAttempt?: typeof defaultRunAttempt;
    spawn?: typeof defaultSpawn;
    taskPromptTemplate?: string;
    trackWorker?: (worker: TrackedWorker) => void;
    now?: () => number;
    abort?: AbortSignal;
    onEvent?: (event: TickEvent) => void;
    logger?: {
        error?(message: string, meta?: Record<string, unknown>): void;
        warn?(message: string, meta?: Record<string, unknown>): void;
    };
}
export declare function tick(state: MaestroState, deps: TickDeps): Promise<void>;
export {};
