/**
 * The host-side wire of the conditional idle handover: the `begin_handover` request a CLI sends,
 * the answers it gets, the refusal new work gets while a handover is pending, the identity fields
 * `get_protocol_info` gains, and the idle judgement over the session registry.
 *
 * `begin_handover` is answered with `success: true` whatever the verdict, so a client reads one
 * `data` shape: `{ state, operation_id, ... }` for an operation, `{ refused, detail }` for a refusal.
 */
import type { HandoverAnswer, HandoverOutcome, HandoverView, IdleHandoverRequest } from "./host-idle-handover.ts";
import type { RpcResponse } from "./rpc-types.ts";
import type { RpcSessionRegistry } from "./session-registry.ts";
import type { Duplex } from "node:stream";
export declare const BEGIN_HANDOVER_COMMAND = "begin_handover";
export declare function parseBeginHandover(record: Readonly<Record<string, unknown>>): IdleHandoverRequest | string;
export declare function beginHandoverResponse(id: unknown, answer: HandoverAnswer | string): Record<string, unknown>;
export declare function handoverWire(view: HandoverView): Record<string, unknown>;
/** What a command carrying new work gets while a handover holds it back. */
export declare function handoverRefusal(command: {
    readonly id?: string;
    readonly type: string;
}, view: HandoverView): object;
export declare function withHostIdentity(response: RpcResponse, runtimeBuildId: string | undefined, handover: HandoverView | undefined): object;
/**
 * The safe idle point: no session opening (an in-flight request without a session), and every
 * listed session open, without an in-flight request and not busy by its activity snapshot - the
 * same per-session judgement a drain parks by. A retained session with no work is idle.
 */
export declare function isHostIdle(registry: Pick<RpcSessionRegistry, "list" | "peek">, inFlight: ReadonlyMap<string | undefined, number>): boolean;
/**
 * Runs the handover the host decided on: the ordinary generation handoff, launched from the
 * runtime of the CLI that asked, with that CLI's daemon environment. The successor is told the
 * runtime it must report (`EXPECTED_RUNTIME_BUILD_ID_ENV`) and exits before it listens when it
 * computes another one, so a runtime changed since the request leaves this generation serving. The env is applied EXACTLY:
 * every name this host has and the CLI did not send is removed, so the successor does not inherit
 * the old runtime's view of the world.
 */
export declare function performIdleHandover(context: {
    readonly request: IdleHandoverRequest;
    readonly socket: string;
    readonly agentDir: string;
    /** Called only when the successor reaches its P7 (senpi#4602). */
    readonly presenterBootstrap?: () => Promise<Duplex | undefined>;
}): Promise<HandoverOutcome>;
//# sourceMappingURL=host-handover-wire.d.ts.map