createSession/attachWs/detachWs/writeInput/resize/kill; node-pty spawn (throws on failure/M4), onData->buffer+forward, onExit->exitedAt+exit+injected onExit; sendIfOpen guards readyState (M5); detach never kills PTY; write/resize no-op after exit (L4); detach-then-exit keeps session (L1). Tests vi.mock node-pty -> mock IPty (no real spawn): 19 tests. Full suite green.