/**
 * MaintenanceService — supervised self-test and self-fix pipeline.
 *
 * Flow:
 *   1. Cron triggers a maintenance run for a repo
 *   2. Runs configured checks (typecheck, test, lint) via shell
 *   3. Parses failures from output
 *   4. If failures found → creates a Plan with proposed fix tasks
 *   5. Broadcasts results via WS so the user can supervise
 *   6. Tasks stay "proposed" until the user approves & starts them
 *
 * The user stays in the loop: they see every run, every failure, and
 * every proposed fix before any agent thread touches code.
 */
import type { JaitDB } from "../db/connection.js";
import { scheduledJobRuns } from "../db/schema.js";
import type { PlanService } from "./plans.js";
import type { RepositoryService } from "./repositories.js";
export interface CheckResult {
    name: string;
    command: string;
    passed: boolean;
    output: string;
    durationMs: number;
}
export interface MaintenanceRunResult {
    id: string;
    jobId: string;
    repoId: string;
    repoName: string;
    checks: CheckResult[];
    allPassed: boolean;
    planId?: string;
    startedAt: string;
    completedAt: string;
}
export interface MaintenanceConfig {
    /** Shell commands to run, in order. Each must exit 0 to pass. */
    checks: Array<{
        name: string;
        command: string;
    }>;
    /** Max ms per check before it's killed. Default 120s. */
    timeoutMs?: number;
    /** Provider to suggest for fix threads. Default "codex". */
    preferredProvider?: string;
}
export declare class MaintenanceService {
    private db;
    private planService;
    private repoService;
    constructor(db: JaitDB, planService: PlanService, repoService: RepositoryService);
    /**
     * Run maintenance checks for ALL accessible repositories.
     * Skips repos whose paths don't exist locally.
     */
    runAll(jobId: string, config?: Partial<MaintenanceConfig>): Promise<MaintenanceRunResult[]>;
    /**
     * Run maintenance checks for a specific repository.
     * Returns structured results; creates a fix plan if anything failed.
     */
    runForRepo(repoId: string, jobId: string, config?: Partial<MaintenanceConfig>): Promise<MaintenanceRunResult>;
    /** Get recent runs, optionally filtered by jobId. */
    listRuns(jobId?: string, limit?: number): Array<typeof scheduledJobRuns.$inferSelect>;
    /** Get a single run by ID. */
    getRun(id: string): {
        id: string;
        jobId: string;
        status: string;
        triggeredBy: string;
        output: string | null;
        error: string | null;
        planId: string | null;
        startedAt: string;
        completedAt: string | null;
    } | undefined;
    /**
     * Parse check failures and create a Plan with proposed fix tasks.
     * Tasks are left as "proposed" — the user must approve before they run.
     */
    private createFixPlan;
}
//# sourceMappingURL=maintenance.d.ts.map