/**
 * Following one device call (row CK9; custody design 4.3-4.5). Frames are handled in order: `hooked` is stored (W4')
 * only as the call's seq-0 frame while the stored request has no hooks applied (a late or unsolicited `hooked` never
 * rewrites the stored request), events are pushed as they arrive, and the terminal event is held until the row is
 * durably `ended` with the assembled message, then pushed, then acked. Silence is bounded with the loop's own numbers:
 * a liveness probe every half idle window re-attaches on progress, waits for a device offline longer than the resume
 * window, and cancels with `budget` after one idle window plus one resume window without progress. An events stream
 * that ends before the terminal frame is parked, so the probe (and with it the bound) keeps running. Open question
 * (design 4.4 "or stream-start bound without a first event"): the design names no value for that bound on this seam,
 * so the idle+resume bound also covers a call with no first event until CK1 exports the loop's stream-start constant.
 */
import type { DeviceId } from "@earendil-works/pi-agent-core";
import type { Api, AssistantMessageEventStream, Model } from "@earendil-works/pi-ai";
import type { EgressLedger } from "./ledger.ts";
import type { EgressCallRow } from "./ledger-schema.ts";
import type { Abortion, EgressClock, StepWaits, WaitConditionSource } from "./device-proxy-waits.ts";
import type { SignedPlacementClaim } from "./placement-claim.ts";
import type { ProviderCallChannel, ProviderCallStart } from "./wire.ts";
export type ClaimRefusal = "claim_expired" | "registry_key_revoked" | "registry_key_unknown";
export type CallOutcome = {
    readonly kind: "ended" | "mismatch" | "unknown";
    readonly row: EgressCallRow;
} | {
    readonly kind: "refused";
    readonly row: EgressCallRow;
    readonly code: ClaimRefusal;
    readonly message: string;
};
export interface DeviceRouteBounds {
    readonly idleMs: number;
    readonly resumeWindowMs: number;
    readonly deadlineMs: number;
}
export interface CallContext {
    readonly out: AssistantMessageEventStream;
    readonly model: Model<Api>;
    readonly ledger: EgressLedger;
    readonly channel: ProviderCallChannel;
    readonly offlineFor: (deviceId: DeviceId) => number;
    readonly waits: StepWaits;
    readonly conditions: WaitConditionSource;
    readonly clock: EgressClock;
    readonly bounds: DeviceRouteBounds;
    readonly signal: AbortSignal;
    /** The egress's own abort registry (one listener per signal). */
    readonly abortion: Abortion;
    readonly claim: () => Promise<SignedPlacementClaim>;
    /** The row a user abort must cancel; kept current as `hooked` and `ended` replace it. */
    readonly live: {
        row: EgressCallRow | undefined;
    };
}
/** Sends `start` (or, to resume a row the brain already dispatched, first asks the hand for its result) and follows it. */
export declare function followCall(ctx: CallContext, initial: EgressCallRow, begin: {
    readonly start: ProviderCallStart;
} | {
    readonly resume: true;
}): Promise<CallOutcome>;
//# sourceMappingURL=device-proxy-call.d.ts.map