/** * Read an agent's screen for a usage-limit state, record it, and answer * Claude Code's usage-limit menu. * * One entry point ({@link inspectUsageLimitScreen}) for every place that * already reads an agent's screen: the login/screen monitor's 30s sweep, the * orchestrator heartbeat, and the delivery wait for a prompt. Detection is * {@link detectUsageLimitScreen}; the state is {@link markUsageLimited}. * * The menu ("❯ 1. Stop and wait for limit to reset / 2. Wait here, then * continue automatically at 8pm") is answered with option 2, like the other * known start-up prompts are answered with the one right choice for an * unattended agent: the turn waits and goes on by itself at the reset, so * nobody has to come back and re-send it. Only while option 1 or 2 is the * highlighted one, once per state, and Enter is pressed only after the * screen shows option 2 highlighted. * * @module services/runtime-fallback/usage-limit-screen */ import { type UsageLimitedInfo } from './usage-limit-state.js'; /** Keys and screen access, to answer the menu. */ export interface UsageLimitMenuIO { sendKey(sessionName: string, key: string): Promise; sendEnter(sessionName: string): Promise; /** Current screen of the session */ capture(sessionName: string): string; } /** Minimal logger. */ export interface UsageLimitScreenLogger { info(message: string, context?: Record): void; warn(message: string, context?: Record): void; } /** Options of {@link inspectUsageLimitScreen}. */ export interface InspectUsageLimitOptions { /** Keys + capture; without it the menu is left alone */ io?: UsageLimitMenuIO; logger?: UsageLimitScreenLogger; now?: number; /** Zone for reset clock times that name none */ timeZone?: string; /** Hand a new detection to the runtime fallback (default true) */ reportToFallback?: boolean; } /** * Look at a session's screen for a usage-limit state. On a match the state * is recorded (a new one is logged and handed to the runtime fallback, which * may move the agent to another runtime) and an open usage-limit menu is * answered. Never throws. * * @param sessionName - Session * @param screen - Captured screen * @param runtime - Runtime the session runs (null when unknown: nothing is detected) * @param options - Keys, logger, clock * @returns The state in force (also one recorded earlier), or null * * @example * ```ts * const limited = await inspectUsageLimitScreen('crewly-orc', screen, 'claude-code', { io }); * if (limited) return; // do not restart / wait / write * ``` */ export declare function inspectUsageLimitScreen(sessionName: string, screen: string, runtime: string | null, options?: InspectUsageLimitOptions): Promise; //# sourceMappingURL=usage-limit-screen.d.ts.map