import type { AgentSession } from "../../core/agent-session.ts";
import type { AgentSessionRuntime } from "../../core/agent-session-runtime.ts";
import { type EffectActor, type EffectCommandKind, type EffectOutcome, type EffectState, type EffectStatus, type QueuedChangeAnswer, type RpcEffectRecord } from "./effect-record.ts";
/**
 * The session's most recent effect receipt, read from the transcript tail WITHOUT opening a ledger:
 * answering a status subscriber must never seal a stale receipt or restore queued input as a side effect.
 */
export declare function latestSessionEffect(session: AgentSession): EffectStatus | undefined;
export type EffectBegin = {
    readonly replay: EffectStatus;
} | {
    readonly record: RpcEffectRecord;
};
/**
 * One durable effect ledger per loaded session. Every non-input effect is written to the transcript as
 * `accepted` BEFORE it is applied, then moves forward by appending a newer entry (the newest entry per
 * id wins on read). Input effects are the existing admission receipts, read through the same status.
 */
export declare class EffectLedger {
    private readonly records;
    private readonly session;
    private readonly admissions;
    private readonly durableSessionId;
    private readonly unsubscribe;
    private constructor();
    /** Settle existing held effects while the outgoing transcript can still be written. */
    static sealOnReplace(runtime: AgentSessionRuntime): () => void;
    static forSession(session: AgentSession): EffectLedger;
    /**
     * A reopened session has no live turn, no teardown in flight and no pending model switch, so every
     * nonterminal effect it finds is stale by definition. Seal each one before the ledger is published,
     * so a same-id retry answers a terminal state and nothing stays pending forever.
     */
    private sealOnReopen;
    /**
     * Record a new effect as `accepted` (durably, before the caller applies it), or answer a replay.
     * Same id + same semantic payload replays the stored status and the caller performs nothing; same id
     * + a different payload throws `EffectIdConflict`.
     */
    begin(command: EffectCommandKind, effectId: string, payload: object, by: EffectActor): Promise<EffectBegin>;
    transition(effectId: string, state: EffectState, patch?: {
        readonly disposition?: string;
        readonly outcome?: EffectOutcome;
        readonly answer?: QueuedChangeAnswer;
        readonly dropped?: RpcEffectRecord["dropped"];
        readonly pending?: RpcEffectRecord["pending"];
    }): EffectStatus;
    /** The newest status of `effectId`: a non-input effect, or an input receipt under the same id. */
    status(effectId: string, sessionId?: string): EffectStatus | undefined;
    private statusOf;
    private append;
}
//# sourceMappingURL=effect-ledger.d.ts.map