/** * Confirmed prompt delivery. * * Delivering a task prompt to a subagent's TUI is two steps: paste the text, * then press Enter to submit. The failure this module fixes: the text is * pasted correctly but the Enter is dropped by the TUI (it arrives a beat * before the input widget is ready to translate it into a submit), leaving the * prompt sitting unsubmitted in the input box indefinitely. Codex v0.144.6 * can additionally discard the initial paste during startup; a harness may * opt into one capture-guarded re-paste when no prompt text is visible. The previous * mitigation — a fixed `sleep` then a blind double-Enter — is open-loop: it * never checks whether submission actually happened, so a dropped Enter is * unrecoverable. * * The fix is a closed loop. The authoritative proof that a prompt was * submitted is that the harness session file gains a new entry: both pi and * cmd append the user turn to the session JSONL synchronously at submit time, * BEFORE the assistant responds (verified against real cmd session files). So * we paste ONCE, then re-send Enter — polling the session-file entry count * after each — until the count grows (submission confirmed) or an attempt * budget is exhausted. Re-pasting is never needed: the reported symptom is a * dropped Enter, not lost text, and re-sending Enter is the exact remedy. We * stop the instant submission is confirmed, so a successful first Enter never * triggers a stray second one. * * When no session-file signal is available (e.g. a harness without * `analyzeSession`, or a session file not yet resolved), we fall back to the * legacy open-loop double-Enter — best-effort, since there is nothing to * verify against. */ import type { CodingHarness, HarnessEnvironment } from "#src/harness/interface"; import type { TmuxManager } from "#src/tmux-manager"; export interface DeliverPromptOptions { tmux: TmuxManager; harness: CodingHarness; /** Environment bag — `sessionFilePath` is the confirmation signal source. */ env: HarnessEnvironment; sessionName: string; /** Window NAME (renumber-safe), never a numeric index. Fallback when `windowId` is absent. */ windowName: string; /** Stable tmux window ID captured at creation. Preferred target when present. */ windowId?: string; prompt: string; /** Abort signal — aborts the retry loop between/within attempts. */ signal?: AbortSignal; /** Max Enter attempts on the confirmable path. Default 6. */ maxAttempts?: number; /** Per-attempt wait for confirmation (ms). Default 1200. */ confirmTimeoutMs?: number; /** Poll interval while confirming (ms). Default 150. */ pollMs?: number; } export interface DeliverPromptResult { /** True once a session-file entry-count increase confirmed the submit. */ submitted: boolean; /** * Whether a confirmation signal was available at all. `false` means we took * the open-loop fallback (no session file / no analyzer) — `submitted` is * then always `false` because there was nothing to verify. */ confirmable: boolean; /** Number of Enter keypresses sent. */ attempts: number; } /** * Deliver a prompt to a subagent's TUI and confirm it was actually submitted. * See the module header for the rationale. */ export declare function deliverPromptConfirmed(opts: DeliverPromptOptions): Promise; //# sourceMappingURL=prompt-delivery.d.ts.map