Skip to content

feat(sessions): retain attachable native terminal processes #140

Description

@drewstone

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

  1. Claude Code, Codex, Pi, and OpenCode each pass the same PTY conformance test when supported.
  2. One client can attach, resize, detach, and reconnect without restarting the process.
  3. A second attachment follows an explicit single-writer or shared-input policy.
  4. Reader loss never cancels the run.
  5. Close reaps the full process tree and temporary profile materialization.
  6. Resume-new-process and attach-existing-process are distinct result modes.
  7. Write jail, network jail, cwd, auth, MCP, and AgentProfile bindings match the admitted run.
  8. Terminal output is bounded and secret-redacted only in retained diagnostics, never altered on the live byte stream.
  9. Unsupported backends fail closed with a concrete reason.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions