Expand description
PTY shell HTTP handlers. Split out of server/mod.rs unchanged (SPEC_LARGE_FILE_MODULE_ANALYSIS_2026_09_30.md §4.1).
Functions§
- answer_
conpty_ 🔒handshake_ if_ seen - Answer Windows ConPTY’s own startup handshake, if seen, before the
caller proceeds. Discovered live (not assumed): the moment a Windows
ConPTY is created, it queries the cursor position (
ESC[6n, Device Status Report) and blocks its own internal state — and therefore every later write — until it sees aESC[<row>;<col>Rreply. A human-facingtermpane gets this for free because xterm.js, running in the browser, answers real cursor queries as part of being an actual terminal emulator; this headless facility has nothing playing that role, so without this the PTY would sit permanently stuck before printing even its first prompt — confirmed by a live round trip that hung indefinitely until this was added.ESC[1;1R(cursor at row 1, col 1) is a plausible-enough fixed answer: nothing here has rendered anything yet, so “top-left” is as true as any other coordinate, and ConPTY only wants to reconcile its internal buffer, not validate the value against anything a person would see. - handle_
pty_ 🔒shell_ create POST /api/v1/ptyshell/create— attach to (creating if needed) “this pane’s one shell.”- handle_
pty_ 🔒shell_ input POST /api/v1/ptyshell/input— write raw text to the PTY, as if typed. Unlike/api/v1/shell/input, no newline is appended: a real terminal doesn’t add one either, and PTY programs (readline, Sharprompt) expect the caller to send exactly what a keyboard would (e.g."y\n"to answer a prompt and press Enter, or"\x03"for Ctrl+C — the OS PTY layer translates that raw byte into a real interrupt delivered to the foreground process, same as a human pressing Ctrl+C in a real terminal, without ending the shell).- handle_
pty_ 🔒shell_ read POST /api/v1/ptyshell/read— read back the shell’s raw output tail.- handle_
pty_ 🔒shell_ resize POST /api/v1/ptyshell/resize— resize the PTY. Some TUIs render differently or wrap badly at the fallback geometry (25x200).- handle_
pty_ 🔒shell_ status POST /api/v1/ptyshell/status— query whether the shell is still running.- handle_
pty_ 🔒shell_ stop POST /api/v1/ptyshell/stop— release the agent’s lock immediately, without waiting forAGENT_LOCK_WINDOW_MSto lapse on its own.- lock_
shell_ 🔒for_ agent - Lock
shell_idout from human keyboard input forAGENT_LOCK_WINDOW_MSfrom now — called BEFORE every agent write (input/resize), not after (see the call sites’ own comment for why the ordering matters). Best-effort: a failure to write the lock meta just means the human’s input isn’t blocked this time, not that the agent’s write itself failed. - running_
shell_ 🔒conflict - The 409 for a pane whose agent shell is running (or starting, created by
this run) on another connection than
connection, checked without touching the shell; the same casestry_attach_to_existing_shellrefuses.