Problem
CLI Bridge retains logical Claude, Codex, Pi, OpenCode, Kimi, and Prime session identity, but each chat turn still runs as a headless subprocess. A user cannot attach a terminal to the exact active process.
The proposed SessionRunner design covers persistent native bidirectional channels. Braid also needs an optional true terminal mode for direct human handoff. Re-running a CLI with a resume identifier is a different process and must be labeled resume, not attach.
Required behavior
Add one backend-neutral interactive-session surface:
- create an attachable PTY session from the exact materialized AgentProfile;
- return stable bridge run, provider session, process, and terminal identifiers;
- ordered output replay with cursor;
- input bytes;
- rows and columns resize;
- status, detach, reconnect, and acknowledged close;
- TTL, capacity, cleanup, and process-tree ownership;
- explicit capability per backend.
Runner-specific flags and PTY startup stay in backend adapters. The public route and event schema stay uniform.
Acceptance
- Claude Code, Codex, Pi, and OpenCode each pass the same PTY conformance test when supported.
- One client can attach, resize, detach, and reconnect without restarting the process.
- A second attachment follows an explicit single-writer or shared-input policy.
- Reader loss never cancels the run.
- Close reaps the full process tree and temporary profile materialization.
- Resume-new-process and attach-existing-process are distinct result modes.
- Write jail, network jail, cwd, auth, MCP, and AgentProfile bindings match the admitted run.
- Terminal output is bounded and secret-redacted only in retained diagnostics, never altered on the live byte stream.
- Unsupported backends fail closed with a concrete reason.
Problem
CLI Bridge retains logical Claude, Codex, Pi, OpenCode, Kimi, and Prime session identity, but each chat turn still runs as a headless subprocess. A user cannot attach a terminal to the exact active process.
The proposed SessionRunner design covers persistent native bidirectional channels. Braid also needs an optional true terminal mode for direct human handoff. Re-running a CLI with a resume identifier is a different process and must be labeled resume, not attach.
Required behavior
Add one backend-neutral interactive-session surface:
Runner-specific flags and PTY startup stay in backend adapters. The public route and event schema stay uniform.
Acceptance