import type { HistoryReducer } from "./session-history-reduce.ts";
export declare const MAX_ENGINE_TURNS_PER_USER_INPUT = 0;
export declare const MAX_ENGINE_TURNS_PER_RESUME_WINDOW = 8;
export declare const MAX_TOOL_FREE_ENGINE_TURNS_PER_WINDOW = 12;
export declare const ENGINE_TURN_WINDOW_MS = 60000;
/** Appended when the engine starts a turn no user message asked for; the limits count these. */
export declare const ENGINE_TURN_START_ENTRY_TYPE = "engine-turn-start";
export declare const ENGINE_TURN_LIMIT_ENTRY_TYPE = "engine-turn-limit";
export declare const ENGINE_TURN_LIMIT_EVENT = "engine:turn-limit";
export type EngineTurnStopReason = "per-user-input" | "tool-free-rate" | "resume-window";
/** A limit of 0 turns that limit off. */
export interface EngineTurnLimits {
    readonly maxPerUserInput: number;
    readonly maxToolFreePerMinute: number;
    readonly maxPerResumeWindow?: number;
}
/** An engine turn this process started since the user's last message, kept even when the session file refuses writes. */
export interface EngineTurnStartRecord {
    readonly at: number;
    toolUsed: boolean;
}
export interface EngineTurnStop {
    readonly reason: EngineTurnStopReason;
    readonly sinceUserInput: number;
    readonly toolFreeInWindow: number;
}
export declare function engineTurnLimitNotice(stop: EngineTurnStop): string;
/** A `.` manual continue or a continue-from-leaf is the user's own request, not an automatic turn. */
export declare function isUserDirectedTurn(customType: string): boolean;
/** Recovering an interrupted run is not a new message that resets the unattended turn budget. */
export declare function resetsEngineTurnHistory(customType: string, details?: unknown): boolean;
/** The session's engine turns since the user's last message, in order: when each started and whether its reply called a tool. */
export interface EngineTurnHistory {
    readonly starts: EngineTurnStartRecord[];
}
/**
 * Folds the session history into `EngineTurnHistory` (senpi#2537): read once per load and extended per append, so a
 * stream of engine turns never materializes a compacted session's whole history. A tool call marks the latest start.
 */
export declare const engineTurnHistory: HistoryReducer<EngineTurnHistory>;
/**
 * Whether one more engine-started turn may begin. Only turns since the user's last message count, so any
 * message the user sends lifts a pause at once. Read from the session entries, so a host that rebuilds
 * extensions or reopens the session between turns is bounded too (senpi#2967). The per-minute breaker counts
 * only engine turns whose reply called no tool: measured goal runs never exceed it, while every observed
 * runaway has that shape.
 */
export declare function engineTurnStop(history: EngineTurnHistory, now: number, limits: EngineTurnLimits, inProcess?: readonly EngineTurnStartRecord[]): EngineTurnStop | null;
//# sourceMappingURL=engine-turn-limit.d.ts.map