import type { BuildAssetKind } from "./build-cache.js";
export type JobStatus = "queued" | "running" | "completed" | "failed" | "cancelled" | "unknown";
/**
 * `generate-video` / `generate-music` are provider-backed jobs refreshed by
 * polling the provider. `build` / `render` are LOCAL jobs: long-running MCP
 * tool calls promoted to the background inside the MCP server process — their
 * records are updated in-process, so refresh just reads the file (plus orphan
 * detection when the owning process died).
 */
export type JobType = "generate-video" | "generate-music" | "build" | "render";
/** Local in-process jobs (see {@link JobType}). */
export declare function isLocalJob(record: Pick<JobRecord, "jobType">): boolean;
export type ProjectWorkflowStatus = "empty" | "ready" | "running" | "needs-author" | "failed" | "done" | "warn";
export type ProjectCurrentStage = "init" | "assets" | "compose" | "sync" | "render" | "review" | "done";
export interface JobRecord {
    schemaVersion: "1";
    id: string;
    jobType: JobType;
    status: JobStatus;
    providerStatus?: string;
    createdAt: string;
    updatedAt: string;
    projectDir: string;
    workingDirectory: string;
    command: string;
    provider: string;
    providerTaskId: string;
    providerTaskType?: "text2video" | "image2video";
    progress?: number;
    resultUrl?: string;
    beatId?: string;
    outputPath?: string;
    cachePath?: string;
    assetKind?: BuildAssetKind;
    assetCue?: string;
    assetOptions?: Record<string, unknown>;
    cacheKey?: string;
    canonicalPath?: string;
    metadataPath?: string;
    error?: string;
    promptPreview?: string;
    retryWith: string[];
    /** Owning process id — local jobs only; used for orphan detection. */
    pid?: number;
    /** Last liveness write by the owning process — local jobs only. */
    heartbeatAt?: string;
    /** Current pipeline stage label (e.g. "compose", "render") — local jobs. */
    stage?: string;
    /** Latest human-readable progress message — local jobs. */
    message?: string;
    /** Full tool result data, written when a local job completes. */
    resultPayload?: Record<string, unknown>;
}
export interface CreateJobRecordOptions {
    id?: string;
    now?: Date;
    jobType: JobType;
    status?: JobStatus;
    provider: string;
    providerTaskId: string;
    providerTaskType?: "text2video" | "image2video";
    projectDir?: string;
    workingDirectory?: string;
    command: string;
    prompt?: string;
    progress?: number;
    resultUrl?: string;
    beatId?: string;
    outputPath?: string;
    cachePath?: string;
    assetKind?: BuildAssetKind;
    assetCue?: string;
    assetOptions?: Record<string, unknown>;
    cacheKey?: string;
    canonicalPath?: string;
    metadataPath?: string;
    error?: string;
    pid?: number;
    heartbeatAt?: string;
    stage?: string;
    message?: string;
}
export interface RefreshJobOptions {
    wait?: boolean;
    output?: string;
    workingDirectory?: string;
    write?: boolean;
}
export interface JobStatusResult {
    schemaVersion: "1";
    kind: "job";
    id: string;
    jobType: JobType;
    status: JobStatus;
    provider: string;
    providerTaskId: string;
    providerTaskType?: "text2video" | "image2video";
    createdAt: string;
    updatedAt: string;
    progress?: JobProgress;
    result: JobResult | null;
    job: JobRecord;
    refreshed: boolean;
    live: {
        supported: boolean;
        error?: string;
    };
    warnings: string[];
    retryWith: string[];
}
export interface ProjectStatusResult {
    schemaVersion: "1";
    kind: "project";
    project: string;
    status: ProjectWorkflowStatus;
    currentStage: ProjectCurrentStage;
    beats: ProjectBeatReadiness;
    build: BuildSummary | null;
    review: ReviewSummary | null;
    jobs: {
        total: number;
        active: number;
        completed: number;
        failed: number;
        cancelled: number;
        unknown: number;
        latest: JobSummary[];
    };
    warnings: string[];
    retryWith: string[];
}
export interface BuildSummary {
    reportPath: string;
    kind?: string;
    success?: boolean;
    phase?: string;
    status?: string;
    currentStage?: string;
    selectedStage?: string;
    outputPath?: string;
    estimatedCostUsd?: number;
    costUsd?: number;
    beats?: ProjectBeatReadiness;
    updatedAt?: string;
    warnings: unknown[];
    retryWith: string[];
}
export interface ReviewSummary {
    reportPath: string;
    kind?: string;
    mode?: string;
    status?: string;
    score?: number;
    issueCount: number;
    errorCount: number;
    warningCount: number;
    infoCount: number;
    fixOwners: {
        vibe: number;
        hostAgent: number;
    };
    sourceReports: string[];
    updatedAt?: string;
    retryWith: string[];
}
export interface JobSummary {
    id: string;
    jobType: JobType;
    status: JobStatus;
    provider: string;
    providerTaskId: string;
    providerTaskType?: string;
    progress?: number;
    resultUrl?: string;
    beatId?: string;
    outputPath?: string;
    error?: string;
    createdAt: string;
    updatedAt: string;
    retryWith: string[];
}
export interface JobProgress {
    percent?: number;
    phase: string;
    providerStatus?: string;
}
export interface JobResult {
    url?: string;
    outputPath?: string;
    cachePath?: string;
    error?: string;
    /** Full tool result data for completed local build/render jobs. */
    payload?: Record<string, unknown>;
}
export interface ProjectBeatReadiness {
    total: number;
    assetsReady: number;
    compositionsReady: number;
    needsAuthor: string[];
}
export declare function findProjectRoot(start?: string): string;
export declare function jobsDir(projectDir: string): string;
export declare function normalizeJobStatus(status: unknown): JobStatus;
export declare function createJobRecord(opts: CreateJobRecordOptions): JobRecord;
export declare function createAndWriteJobRecord(opts: CreateJobRecordOptions): Promise<JobRecord>;
export declare function writeJobRecord(record: JobRecord): Promise<void>;
export declare function readJobRecord(jobId: string, projectDir?: string): Promise<JobRecord | null>;
export declare function listJobRecords(projectDir: string): Promise<JobRecord[]>;
export declare function refreshJobRecord(record: JobRecord, opts?: RefreshJobOptions): Promise<JobStatusResult>;
export declare function inspectProjectStatus(projectDirArg: string, opts?: {
    refresh?: boolean;
}): Promise<ProjectStatusResult>;
export declare function summarizeJob(record: JobRecord): JobSummary;
export declare function retryWithForJob(record: JobRecord): string[];
export declare function makeJobStatusResult(record: JobRecord, opts: {
    refreshed: boolean;
    live: {
        supported: boolean;
        error?: string;
    };
    warnings?: string[];
}): JobStatusResult;
