/** * Detects an antigravity-cli (agy) session whose TUI keeps a "Running * command..." spinner although the command is long finished: the agy process * has no child process left. The agent then looks busy forever, so queued * owner messages are never delivered and a runtime switch (which waits for a * safe point) never happens. The fix that worked by hand is one Escape. * * Pure logic with injected inputs; the activity monitor feeds it one screen * per poll. * * @module services/agent/antigravity-stuck-command */ /** Inputs of one observation. */ export interface StuckCommandProbe { /** Bottom lines of the session's screen */ screen: string; /** PID of the PTY shell that launched agy (null when unknown) */ shellPid: number | null; /** Send Escape to the session */ sendEscape: () => void; } /** Injected behaviour (tests replace it). */ export interface StuckCommandDeps { now?: () => number; /** Child PIDs of a process (empty when none or when the check fails) */ childPids?: (pid: number) => number[]; logger?: { warn: (message: string, meta?: Record) => void; }; } /** * Direct children of a process, via `pgrep -P`. * * @param pid - Parent PID * @returns Child PIDs (empty when none, or when pgrep fails) */ export declare function pgrepChildren(pid: number): number[]; /** Tracks "Running command" spinners per session. */ export declare class AntigravityStuckCommandDetector { private readonly now; private readonly childPids; private readonly logger?; /** When the spinner was first seen in an unbroken run of observations */ private readonly firstSeen; /** When Escape was last sent */ private readonly lastEscape; /** * @param deps - Injected behaviour */ constructor(deps?: StuckCommandDeps); /** * Look at one screen of an antigravity-cli session. * * @param sessionName - Session * @param probe - Screen and hooks * @returns True when Escape was sent */ observe(sessionName: string, probe: StuckCommandProbe): boolean; /** * Is agy running a command? False when agy is not found under the shell * (not agy's hang to fix) or has no child process. * * @param shellPid - PTY shell PID * @returns True when the command may still be running (or agy cannot be found) */ private hasRunningCommand; /** * Forget a session (it ended). * * @param sessionName - Session */ clear(sessionName: string): void; } //# sourceMappingURL=antigravity-stuck-command.d.ts.map