import { type GitRunner } from './project.js';
import { type LinkedPr } from './dashboard/gh.js';
import { type HandoffResult } from './dashboard/agent-handoff.js';
import { type AgentMeta, type ArchivePatch } from './store/index.js';
/** How long after its start a run is still asked about: safely past any cloud session's life. */
export declare const CLOUD_ADOPTION_WINDOW_MS: number;
/** What one adoption did, for the daemon to say out loud. */
export interface CloudAdoption {
    agentId: string;
    branch: string;
    /** The PR now on the run's record, when one was found or opened. */
    pr?: {
        number: number;
        url: string;
    };
    /** True when the PR above was opened by this pass (the armed draft), not found. */
    opened?: boolean;
}
/** What {@link adoptCloudWork} did to one project. */
export interface CloudWorkResult {
    adopted: CloudAdoption[];
    /** Failures worth a log line; unmatched runs are not one, they are the normal waiting state. */
    failed: {
        agentId: string;
        error: string;
    }[];
}
/** Injectable seams so the pass is unit-testable off disk, off the network and off GitHub. */
export interface CloudWorkDeps {
    git?: GitRunner;
    /** The branch's full PR history; a listing that fails must throw (default {@link ghPrsForBranchOrThrow}). */
    prs?: (cwd: string, branch: string) => Promise<LinkedPr[]>;
    /** The project's run records, none older than `since` in epoch ms (default {@link listAgents}). */
    agents?: (cwd: string, since: number) => Promise<AgentMeta[]>;
    /** Record the adopted branch and PR on the run's archive (default {@link patchArchivedAgentOnDataBranch}). */
    patch?: (cwd: string, agentId: string, patch: ArchivePatch, message: string) => Promise<boolean>;
    /** Open the armed draft PR for a remote-only branch (default {@link openRemoteBranchPullRequest}). */
    openPr?: (cwd: string, agent: AgentMeta, branch: string) => Promise<HandoffResult>;
    /** The current time in ms (injected so tests can age runs deterministically). */
    now?: () => number;
}
/**
 * Adopt one project's cloud work (#1601): match each waiting web run to the `claude/*` head
 * descending from its hand-off anchor, and record the branch and its PR onto the run's archive —
 * opening the armed draft PR when the session never did. Never throws: a repo with no remote
 * (or offline) adopts nothing, and every unmatched run is retried next pass.
 */
export declare function adoptCloudWork(cwd: string, deps?: CloudWorkDeps): Promise<CloudWorkResult>;
/** A running adoption pass, in the shape the daemon's other background services use. */
export interface CloudWorkAdoption {
    /** Run one pass now, awaiting it. Exposed for tests and for a caller that wants it on demand. */
    tick: () => Promise<void>;
    stop: () => void;
}
/** What {@link startCloudWorkAdoption} needs from the daemon. */
export interface CloudWorkAdoptionOptions {
    /** The registered projects to pass over. */
    projects: () => Promise<readonly {
        path: string;
    }[]>;
    log: (message: string) => void;
    /** The per-project pass (default {@link adoptCloudWork}). */
    adopt?: (cwd: string) => Promise<CloudWorkResult>;
}
/**
 * Adopt every registered project's cloud work (#1601), one turn per call.
 *
 * Adoptions and failures are said out loud, unmatched runs are not: a session that has not
 * pushed yet is the normal state of every run this watches, and a line per tick about it would
 * be noise. A run's row changing branch with no line explaining why would read as a bug.
 */
export declare function startCloudWorkAdoption(opts: CloudWorkAdoptionOptions): CloudWorkAdoption;
//# sourceMappingURL=cloud-work.d.ts.map