import type { AgentMessage } from "@earendil-works/pi-agent-core";
import type { AgentSession } from "./agent-session.ts";
import type { Goal } from "./extensions/builtin/goal/types.ts";
import type { ExtensionRunner } from "./extensions/runner.ts";
import type { AgentEndEvent } from "./extensions/types.ts";
import { SessionLifecycleController } from "./session-lifecycle.ts";
import type { SessionLifecycleEvent } from "./session-lifecycle-types.ts";
import type { TurnDeadlineKind } from "./turn-deadline.ts";
interface LifecycleBindingHost {
    append(type: string, data: unknown): string;
    emit(event: SessionLifecycleEvent): void;
    holdInterruptedRun(): void;
    factsFailed(error: unknown): void;
}
/** Attaches durable lifecycle to the real session event/admission boundaries. */
export declare class LifecycleSessionBinding {
    readonly controller: SessionLifecycleController;
    readonly sessionId: string;
    private readonly session;
    private readonly host;
    private readonly unsubscribeHuman;
    private readonly unsubscribeAdmission;
    private readonly unsubscribeGoal;
    private lastEnd;
    /** The run each emitted agent_end belonged to, read when it was emitted, not when its queue reaches it. */
    private readonly boundEnds;
    private lastEndRunId;
    /** Captured once inside the bound end's own extension-processing window, never re-scanned by a later run. */
    private lastEndGuard;
    private refreshGeneration;
    private restored;
    private nextRunOrigin;
    private restoring;
    private retireFactEvents;
    /** After dispose() nothing the controller decides is written or emitted: the session file is no longer this session's. */
    private disposed;
    constructor(session: AgentSession, host: LifecycleBindingHost);
    bindFactEvents(runner: ExtensionRunner): void;
    prepareRun(): void;
    get isRestored(): boolean;
    startRun(): void;
    deadlineStopped(kind: TurnDeadlineKind, atMs: number): void;
    deadlineStopWriteFailed(): void;
    bindTurnEnd(end: object): void;
    consume(message: AgentMessage): string | undefined;
    consumedEntry(message: AgentMessage): string | undefined;
    /** `event` is the extension agent_end, never the session-level stamp; `end` is the core event bound at emission. */
    turnEnded(event: AgentEndEvent, end: object, guardStartLeafId?: string | null): Promise<void>;
    refreshFacts(changedGoal?: Goal | null): Promise<void>;
    idle(): Promise<void>;
    restore(): Promise<void>;
    private recover;
    private recordInterruptedTools;
    private hostAppendInterruption;
    /**
     * The single sink every write this binding makes goes through: the controller's records, custody and child
     * reports, its events, the consumed delivery's transcript entry, and the restore-time interruption records.
     * After dispose() nothing is written or emitted, because the session file is no longer this session's
     * (senpi#4120 review, senpi#4149).
     */
    private write;
    private observeWakeSource;
    dispose(): void;
}
export {};
//# sourceMappingURL=lifecycle-session-binding.d.ts.map