import type { AgentMessage } from "@earendil-works/pi-agent-core";
import type { AgentEndEvent, ExtensionAPI, ExtensionContext } from "../../types.ts";
import { type Goal } from "./types.ts";
export declare const TODO_OWED_CUSTOM_TYPE = "senpi.todo-owed";
export declare const TODO_OWED_REMINDER_EVENT = "todo_owed_reminder";
export declare const TODO_OWED_CHAIN_LIMIT = 2;
export declare const TODO_OWED_SECOND_PREFIX = "Second and final reminder. ";
export type TodoOwedSuppression = "disabled" | "subagent" | "non-interactive" | "not-clean" | "length" | "no-open-tasks" | "waiting" | "goal-stopped" | "ask-user-call" | "question" | "cap";
/** What the backstop did at a turn end: delivered a nudge, hit the chain cap, or stood down for a reason. */
export type TodoOwedOutcome = "delivered" | "capped" | TodoOwedSuppression;
export type TodoOwedReminderEvent = {
    sessionId: string;
    chainCount: number;
    openTasks: number;
    now: string;
    next: string;
    reason: "delivered" | "capped" | "waiting";
    sources?: readonly string[];
};
export type TodoOwedInput = {
    readonly ctx: ExtensionContext;
    readonly event: AgentEndEvent;
    readonly goal: Goal | null;
    readonly continuationPending: boolean;
    readonly hasActiveWakeSources: boolean;
    readonly wakeSourceNames?: readonly string[];
};
export declare function collectOnDutySources(input: TodoOwedInput): string[];
export declare function buildTodoOwedReminder(anchors: {
    ask: string;
    now: string;
    next: string;
}, final: boolean): string;
/**
 * The one notice left after the automatic continuations ran out (#10026): what is unfinished, why
 * the agent stopped (it kept ending turns with work open), and the action that resumes it.
 */
export declare function buildTodoOwedStopNotice(openTasks: number, now: string, continuations: number): string;
/** True when the last non-empty paragraph of the text ends any sentence with `?`. */
export declare function endsWithQuestion(text: string): boolean;
export declare function calledAskUser(messages: readonly AgentMessage[]): boolean;
/**
 * The first clause that makes the ended turn NOT owe a nudge, or undefined when every
 * clause holds except the per-chain cap. Child sessions are untagged today (their header
 * carries no `parentSession`), so they pass the main-session clause and are treated as main.
 */
export declare function firstTodoOwedSuppression(input: TodoOwedInput): Exclude<TodoOwedSuppression, "cap"> | undefined;
/**
 * Per-session chain state. The chain counts nudges since the last accepted direct user
 * input (or `session_start` / `session_tree`); after two deliveries the third owed turn
 * notifies the user once and every later one stays silent until the chain resets.
 */
export declare class TodoOwedBackstop {
    #private;
    constructor(pi: ExtensionAPI);
    resetChain(): void;
    afterAgentEnd(input: TodoOwedInput): TodoOwedOutcome;
}
//# sourceMappingURL=todo-owed-backstop.d.ts.map