import { type AccountChoice, type AccountLimit, type AccountRoom } from "./account-choice.js";
import { type Receipt } from "./dispatch.js";
import { peerRequest, type HookPeer } from "./peers.js";
import { type Json } from "./protocol.js";
export interface ComputerRooms {
    computer: string;
    local: boolean;
    rooms: AccountRoom[];
}
export interface Continuation extends AccountChoice {
    computer: string;
}
/** A limit return older than this is history, not a worker to continue now. */
export declare const CONTINUE_WITHIN_MS: number;
/** When the account that just hit its limit gets room back: its exhausted window's reset, else the
 * reset of the window with the least room, else unknown (held for one 5-hour window). */
export declare function limitUntil(room: AccountRoom | undefined): string | undefined;
/**
 * Where a worker stopped on `computer` under `account` continues: the account
 * with the most room on the same computer, else the best one on another. The
 * stopped login is never chosen, here or on any computer where it is signed in
 * too (by its key), and neither is any other login the ledger holds back.
 */
export declare function planContinuation(stopped: {
    computer: string;
    account: string;
}, computers: readonly ComputerRooms[], limits: readonly AccountLimit[]): Continuation | {
    error: string;
};
/** The brief the continuing worker starts with: what stopped, where it was, its last reply, then the original brief. */
export declare function continuationBrief(receipt: Receipt, original: string | undefined, here: string, there: string): string;
/** Another agent's words in a brief, fenced as data so the next agent reads them and does not obey them. */
export declare function quoted(title: string, text: string): string[];
/** `head`, then the original brief, cut to fit `limit` with a note saying the full text is in `where`. */
export declare function withOriginalBrief(head: string, original: string, limit: number, where: string): string;
export interface AccountFailoverOptions {
    /** Every connected computer's Claude accounts with their room (`DispatchService.claudeRooms`). */
    rooms: () => Promise<ComputerRooms[]>;
    /** Places the continuing worker (`DispatchService.dispatch`); `continues` names the stopped dispatch. */
    dispatch: (input: Json, origin: unknown, continues: string) => Promise<Json>;
    peers?: () => Promise<HookPeer[]>;
    request?: typeof peerRequest;
    isLocal?: (computer: string) => boolean;
    localBrief?: (id: string) => Promise<string | undefined>;
    enabled?: () => boolean;
    now?: () => number;
}
/** Dispatching side: continues each dispatched Claude worker stopped by its usage limit, once. */
export declare class AccountFailover {
    private readonly options;
    private readonly running;
    constructor(options: AccountFailoverOptions);
    private get now();
    /** Called after each returns poll. */
    run(): Promise<void>;
    private continueOne;
    /** The stopped worker's brief, from the computer that ran it. */
    private brief;
    /** Records the outcome on the stopped dispatch and returns it again, unread, so the conductor reads "continued on account X". */
    private record;
}
