import type { PeerIdentity } from "./request-origin.js";
import type { OriginPane } from "./dispatch.js";
import { z } from "zod";
import { type ConductorRecord, type ConductorSuccession } from "./conductor-role.js";
import { peerRequest, type HookPeer } from "./peers.js";
import { type DispatchHost } from "./dispatch-hosts.js";
import { type Json, type Target } from "./protocol.js";
declare const actions: z.ZodEnum<{
    approve: "approve";
    dispatch: "dispatch";
    "grants-add": "grants-add";
    "grants-list": "grants-list";
    "grants-remove": "grants-remove";
    hand_off: "hand_off";
    returns: "returns";
}>;
type Action = z.infer<typeof actions>;
export type ConductorExecutor = (action: Action, data: Json, origin: OriginPane, remote?: boolean) => Promise<Json>;
interface Options {
    root: string;
    computer: {
        id: string;
        name: string;
    };
    peers?: () => Promise<HookPeer[]>;
    request?: typeof peerRequest;
    validate: (target: Target) => Promise<Json>;
    isSuccessor?: (origin: {
        server: string;
        pane: string;
    }, id: string) => Promise<boolean>;
    snapshot: (server: string) => Promise<Json>;
    deliver: (target: Target, text: string, deliveryId: string) => Promise<Json>;
    /** All existing worker computers must be reachable before reserving a move. */
    checkWorkers: (from: Target) => Promise<void>;
}
/** Check the original Hook's actual receipts over its own pinned directory,
 * before any role reservation, hand-off or successor launch. */
export declare function preflightConductorWorkers(from: Target, computerId: string, peers?: () => Promise<HookPeer[]>, request?: typeof peerRequest): Promise<void>;
/** A owns the generation and every receipt/approval/grant. B holds only a
 * delegated pane and operation outbox. No login or bearer credential crosses
 * Hooks. Peer writes are authenticated by fetching their intent back over
 * our own enrolled, pinned SSH account, rather than trusting a claimed alias. */
export declare class ConductorSuccessionService {
    private readonly options;
    private readonly peers;
    private readonly request;
    private readonly reservedCallers;
    private readonly operations;
    constructor(options: Options);
    /** Synchronous admission also pauses conductor calls during preflight. */
    reserveCaller(target: {
        server: string;
        pane: string;
    }): () => void;
    private assertCallerAvailable;
    private file;
    private save;
    status(id: string): Promise<ConductorSuccession>;
    /** Identity is supplied only by the scoped SSH gateway, never the body. */
    authorize(id: string, caller: PeerIdentity | undefined, preparingOrigin?: string): Promise<void>;
    private workerIdentities;
    private connection;
    private change;
    begin(id: string, expected: ConductorRecord, from: Target, destination: DispatchHost, computerId: string, resume?: Json): Promise<ConductorSuccession>;
    ensurePrepared(id: string): Promise<void>;
    prepare(input: unknown): Promise<Json>;
    /** The prepared successor pulls the canonical launch over its own pin.
     * An unrelated enrolled peer cannot pre-empt a known move id with a brief. */
    saveLaunch(id: string, input: Json): Promise<void>;
    launchIntent(id: string): Promise<Json>;
    verifiedLaunch(input: Json): Promise<Json>;
    prepared(id: string, target: Target): Promise<void>;
    commit(id: string): Promise<ConductorSuccession>;
    private transition;
    activate(input: unknown): Promise<Json>;
    private activateOnce;
    finish(id: string): Promise<void>;
    private finishOnce;
    /** Explicit owner revocation on A ends delegation without restoring the
     * old chat. This is distinct from rolling back an uncertain commit. */
    stopOrigin(pane?: unknown): Promise<Json | undefined>;
    abort(id: string): Promise<void>;
    call(action: Action, data: Json, origin: unknown, execute: () => Promise<Json>): Promise<Json>;
    private identifyComputer;
    private resolveComputer;
    /** Automatic failover has no authority from the fenced old pane. Its
     * generation is checked against the live successor before executing at A. */
    automatic(action: Action, data: Json, origin: unknown, execute: () => Promise<Json>): Promise<Json>;
    outgoing(id: string, operationId: string): Promise<Json>;
    operate(input: unknown, execute: ConductorExecutor): Promise<Json>;
    acknowledge(input: unknown, acknowledge: (rows: Json[]) => Promise<void>): Promise<Json>;
    forward(origin: unknown, text: string, deliveryId: string): Promise<{
        delivered: boolean;
    } | undefined>;
    notice(input: unknown): Promise<Json>;
    notification(id: string, deliveryId: string): Promise<Json>;
    reconcile(): Promise<void>;
}
export {};
