/**
 * Multi-machine API routes.
 *
 * Endpoints for inter-machine communication:
 *   POST /api/heartbeat          — Receive heartbeat from another machine
 *   POST /api/pair               — Handle pairing requests
 *   POST /api/handoff/challenge  — Generate challenge for handoff
 *   POST /api/handoff/request    — Request role handoff
 *   POST /api/secrets/challenge  — Generate challenge for secret sync
 *   POST /api/secrets/sync       — Receive encrypted secrets
 *   POST /api/sync/state         — Sync operational state
 *
 * All endpoints (except /api/pair) require machine-to-machine authentication.
 *
 * Part of Phases 4-5 of the multi-machine spec.
 */
import { Router } from 'express';
import type { MachineIdentityManager } from '../core/MachineIdentity.js';
import type { HeartbeatManager } from '../core/HeartbeatManager.js';
import type { SecurityLog } from '../core/SecurityLog.js';
import type { MachineAuthDeps } from './machineAuth.js';
import type { MessageRouter } from '../messaging/MessageRouter.js';
export interface MachineRouteContext {
    /** Machine identity manager */
    identityManager: MachineIdentityManager;
    /** Heartbeat manager for coordination */
    heartbeatManager: HeartbeatManager;
    /** Security log */
    securityLog: SecurityLog;
    /** Machine auth dependencies (for middleware) */
    authDeps: MachineAuthDeps;
    /** This machine's ID */
    localMachineId: string;
    /** This machine's signing private key (PEM) */
    localSigningKeyPem: string;
    /** Callback when this machine should demote to standby */
    onDemote?: () => void;
    /** Callback when this machine should promote to awake */
    onPromote?: () => void;
    /** Callback to get current handoff readiness */
    onHandoffRequest?: () => Promise<{
        ready: boolean;
        state?: unknown;
    }>;
    /** Message router for cross-machine message relay */
    messageRouter?: MessageRouter | null;
    /**
     * Callback when a peer broadcasts its fenced lease over the wire (spec §6).
     * Feeds the HttpLeaseTransport's recordObserved so the LeaseCoordinator can
     * fold the low-latency copy into its effective-epoch view.
     */
    onLeaseReceived?: (lease: unknown, fromMachineId: string) => void;
    /**
     * Callback to serve this machine's current effective-view lease for an active
     * PULL (`POST /api/lease/pull`, Cross-Machine Coherence). Returns the signed
     * effective-view `LeaseRecord` (which may name a THIRD machine as holder —
     * re-served) or null when this machine has no lease. The puller re-verifies via
     * `FencedLease.acceptTunnelLease`, so re-serving a third-party lease is safe.
     */
    onLeasePullRequest?: () => unknown | null;
    /**
     * Callback when the holder streams an encrypted live-tail flush over the wire
     * (spec §8 G3b/c). The server lifecycle decrypts it with this machine's X25519
     * private key, then applies it to the LiveTailBuffer (sequence-deduped). Throws
     * if decryption/auth fails (the route turns that into a 400 rejection). Returns
     * the apply outcome for observability.
     */
    onLiveTailReceived?: (flush: {
        topic: string;
        seq: number;
        enc: unknown;
        redactionVersion?: number;
    }, fromMachineId: string) => {
        applied: boolean;
        reason: string;
    } | void;
    /**
     * Callback when the INCOMING machine POSTs its verified-ack during a planned
     * handoff (spec §8 G3d). Delivers the echo to the outgoing machine's
     * HandoffWireTransport.recordAck so the pending awaitAck resolves.
     */
    onHandoffAck?: (ack: unknown, fromMachineId: string) => void;
    /**
     * Callback when the OUTGOING machine POSTs the explicit yield signal (spec §8
     * G3e). Triggers the incoming machine's lease-CAS acquisition — the ONLY path
     * by which the incoming attempts to take the lease in a planned handoff.
     */
    onHandoffYield?: (fromMachineId: string) => void;
    /**
     * Callback when the OUTGOING machine POSTs the begin signal that opens a planned
     * handoff (spec §8 G3d). Carries the outgoing's flush manifest (tailSeq +
     * ingressPosition + threadHistoryHash + the active topic) so the incoming machine
     * can echo it in its caught-up ack. Delivers to the incoming's HandoffReceiver.
     */
    onHandoffBegin?: (manifest: unknown, fromMachineId: string) => void;
    /**
     * Callback when a peer propagates a `reply_committed` marker (spec §8 G3a,
     * cross-machine exactly-once). Applies it to this machine's MessageProcessingLedger
     * via applyRemoteReplyMarker so a post-handoff redelivery of that event is deduped.
     */
    onReplyMarker?: (marker: unknown, fromMachineId: string) => void;
}
export declare function createMachineRoutes(ctx: MachineRouteContext): Router;
//# sourceMappingURL=machineRoutes.d.ts.map