import { type AutoPmReport } from './auto-pm.js';
import type { ProjectErrors } from './project-errors.js';
import type { QuotaSource } from './dashboard/quota.js';
import type { StartAgentOptions, StartAgentResult } from './dashboard/types.js';
/** What the daemon needs back: the two shutdown phases, in the order the daemon's teardown needs them. */
export interface BackgroundServices {
    /**
     * Stop everything that could start or steer an agent, before the daemon suspends the agents it owns.
     * Ordered first on purpose: auto PM or a Discord message arriving mid-shutdown would otherwise
     * start an agent while we are busy stopping them.
     *
     * Resolves once the tick in flight has finished, so the sweeps are off the repo before the agents
     * are torn down — these jobs commit and push, and stopping their clock does not stop their turn.
     */
    quiesce: () => Promise<void>;
    /**
     * Rebuild the Discord services against freshly-read credentials (#1095), so a token pasted into
     * the dashboard takes effect now rather than at the next daemon start. Idempotent and safe to
     * call when nothing changed: the watchers re-seed their baseline on the first poll, so a restart
     * never replays the open backlog as new notifications.
     */
    reloadDiscord: () => Promise<void>;
    /**
     * Sweep now instead of at the next tick (#1161), because the `autoPm` preference was just
     * switched on. The sweep re-reads the preference itself, so this only changes *when* it
     * notices — but a ten-minute wait with nothing on screen is what made the toggle read as dead.
     *
     * `onDemand` is the dashboard's trigger button (#1210): that sweep runs even while the
     * preference is off, because the click itself is the ask the preference would otherwise record.
     *
     * Resolves when the tick does (#1433), so the trigger button can await the sweep and say what
     * it decided; the switched-on-preference wake simply does not await it.
     */
    wakeAutoPm: (opts?: {
        onDemand?: boolean;
        drainOnly?: boolean;
    }) => Promise<void>;
    /** What the last auto-PM sweep decided, for the usage panel to show (#1161). */
    autoPmReport: () => AutoPmReport;
}
/** What {@link startBackgroundServices} needs from the daemon. */
export interface BackgroundServiceDeps {
    /** The daemon's home workspace. Chat has no project picker, so a message with no run starts one here. */
    cwd: string;
    env: NodeJS.ProcessEnv;
    /** The dashboard's own URL, so a paused-agent item (#636) can link back to it. */
    dashboardUrl: string;
    /** The long-lived quota meter the usage panel draws; auto PM gates on the same reading. */
    quota: QuotaSource;
    /** Start an agent in a project. */
    startAgent: (prompt: string, options: StartAgentOptions, projectId: string) => Promise<StartAgentResult>;
    /** How many agents are live on a project, so a background job can tell idle from busy. */
    activeAgentCount: (projectId: string) => number;
    /**
     * The agents this daemon is still responsible for, whose checkouts the worktree sweep must leave
     * alone. See {@link MergedSweepOptions.busy}.
     */
    busyAgentIds: () => ReadonlySet<string>;
    /** Where a job records a project state the user must fix (#1500), for the dashboard to show. */
    projectErrors: ProjectErrors;
    log: (message: string) => void;
}
/**
 * One project's data-sync turn (#1599): pull the data branch, and set or clear the project's
 * `data-sync` error by the outcome. The clear is unconditional on success, so the error lives
 * exactly as long as the condition — the next tick after the user fixes the remote, it is gone.
 */
export declare function syncProjectData(path: string, errors: ProjectErrors, log: (message: string) => void): Promise<void>;
/**
 * The agent options a project's settings imply (#858): the user's global tier, then the repo's
 * committed `the-framework.yml` (#842) on top. The same mapping and the same two tiers the launcher
 * uses, so an agent started by the daemon and an agent started by hand differ only in who asked for it.
 * An unreadable tier falls back to empty rather than failing the start: the defaults are what the
 * run would have used anyway.
 *
 * Exported for the daemon's continuation starts (#1467): a dashboard Resume sends only its seed
 * (`resumeSession` + `continueAgentId`), so these are the base its options overlay.
 */
export declare function resolveProjectAgentOptions(id: string, env: NodeJS.ProcessEnv): Promise<StartAgentOptions>;
export declare function startBackgroundServices(deps: BackgroundServiceDeps): BackgroundServices;
//# sourceMappingURL=daemon-services.d.ts.map