/** * Human-in-the-Loop (HITL) System * Pauses AI execution and prompts users for important decision paths * This is the ONLY HITL system in the repository */ import { EventEmitter } from 'node:events'; /** Result returned by the HitlPresenter when user selects. */ export interface HitlPresenterResult { selectedOptionId: string; userInput?: string; } /** * Presenter callback registered by the UI (InkPromptController). * When set, HITL renders inline through the main Ink app instead of * mounting a separate Ink instance that fights for stdin. */ export type HitlPresenter = (request: { title: string; description?: string; context?: string; options: Array<{ id: string; label: string; description?: string; }>; customId: string; }) => Promise; export declare function setHitlPresenter(p: HitlPresenter | null): void; export declare function getHitlPresenter(): HitlPresenter | null; /** * Module-level event bus that fires when a HITL prompt opens or closes. Other * subsystems subscribe to: * - pause their own run-timeouts so user think-time doesn't abort the agent * (see AgentController), * - hand the terminal off cleanly so the prompt and post-prompt I/O don't * fight (see UnifiedUIRenderer / interactiveShell). * * Always paired: every `prompt-open` is followed by exactly one `prompt-close`, * including on timeout, Ctrl+C, custom-input, and shutdown paths. */ export declare const hitlEvents: EventEmitter; export declare function isHITLPromptActive(): boolean; export interface DecisionOption { id: string; label: string; description: string; shortcut?: string; } export interface DecisionRequest { id: string; title: string; description: string; context: string; options: DecisionOption[]; defaultOptionId?: string; requiresExplicitChoice: boolean; metadata?: Record; } export interface DecisionResponse { requestId: string; selectedOptionId: string; userInput?: string; timestamp: Date; } export interface HITLConfig { /** * Whether to automatically pause execution for decisions * If false, decisions will be logged but execution continues */ autoPause: boolean; /** * Timeout in milliseconds before auto-proceeding with default * 0 means no timeout (wait indefinitely) */ timeoutMs: number; /** * Default option to choose if timeout occurs */ timeoutDefaultOptionId?: string; /** * Log level: 'none' | 'minimal' | 'detailed' */ logLevel: 'none' | 'minimal' | 'detailed'; } export declare class HITLSystem { private config; private pendingDecisions; private decisionHistory; private rl?; constructor(config?: Partial); /** * Request a human decision * @returns Promise that resolves with the selected option ID */ requestDecision(request: DecisionRequest): Promise; /** * Present the decision via the Ink-rendered HitlDecisionMenu. * Replaces the prior chalk + raw-mode arrow-key implementation; * Ink owns the alternate-screen frame, the keypress loop, and the * custom-input flow. */ private promptUserForDecision; private cleanupReadline; private getOptionLabel; private logDecisionRequest; private recordDecision; /** * Get decision history */ getHistory(): DecisionResponse[]; /** * Clear decision history */ clearHistory(): void; /** * Update configuration */ updateConfig(config: Partial): void; } /** * Get the global HITL instance */ export declare function getHITL(config?: Partial): HITLSystem; /** * Helper function for common decision patterns */ export declare const hitl: { /** * Request a yes/no decision */ askYesNo(title: string, description: string, context?: string, defaultYes?: boolean): Promise; /** * Request selection from multiple options */ selectOption(title: string, description: string, options: Array<{ id: string; label: string; description: string; }>, context?: string, defaultOptionId?: string): Promise; /** * Request approval for a risky operation */ requestApproval(title: string, riskDescription: string, operationDetails: string): Promise; }; //# sourceMappingURL=hitl.d.ts.map