import { type AgentStreamEvent } from "./agent-sdk-types.js";
export interface ForegroundTurnWaiter {
    turnId: string;
    callback: (event: AgentStreamEvent) => void;
    settled: boolean;
    settledPromise: Promise<void>;
    resolveSettled: () => void;
}
export interface PendingForegroundRun {
    token: string;
    started: boolean;
    settled: boolean;
    settledPromise: Promise<void>;
    resolveSettled: () => void;
}
export interface ForegroundRunAgentState {
    foregroundTurnWaiters: Set<ForegroundTurnWaiter>;
    finalizedForegroundTurnIds: Set<string>;
}
export declare class ForegroundRunState {
    private readonly pendingRuns;
    createPendingRun(agentId: string): PendingForegroundRun;
    getPendingRun(agentId: string): PendingForegroundRun | null;
    hasPendingRun(agentId: string): boolean;
    settlePendingRun(agentId: string, token?: string): void;
    createTurnStream(turnId: string): ForegroundTurnStream;
    addWaiter(agent: ForegroundRunAgentState, waiter: ForegroundTurnWaiter): void;
    deleteWaiter(agent: ForegroundRunAgentState, waiter: ForegroundTurnWaiter): void;
    settleWaiter(waiter: ForegroundTurnWaiter): void;
    getMatchingWaiters(agent: ForegroundRunAgentState, turnId: string | undefined): ForegroundTurnWaiter[];
    notifyWaiters(waiters: Iterable<ForegroundTurnWaiter>, event: AgentStreamEvent, options: {
        terminal: boolean;
    }): void;
    notifyAgentWaiters(agent: ForegroundRunAgentState, event: AgentStreamEvent, options?: {
        terminal?: boolean;
    }): void;
    cancelWaiters(agent: ForegroundRunAgentState, createEvent: (turnId: string) => AgentStreamEvent): void;
    clearAgent(agentId: string, agent: ForegroundRunAgentState): void;
    rememberFinalizedTurn(agent: ForegroundRunAgentState, turnId: string): void;
    hasFinalizedTurn(agent: ForegroundRunAgentState, turnId: string): boolean;
}
export declare class ForegroundTurnStream {
    private readonly queue;
    private queueResolve;
    readonly waiter: ForegroundTurnWaiter;
    constructor(turnId: string);
    events(isTerminalEvent: (event: AgentStreamEvent) => boolean): AsyncGenerator<AgentStreamEvent>;
    private wake;
}
//# sourceMappingURL=foreground-run-state.d.ts.map