# `Condukt.Sandbox.Terminal`
[🔗](https://github.com/tuist/tuist/blob/condukt@3.0.0/condukt/lib/condukt/sandbox/terminal.ex#L1)

A shell in a sandbox that people type into, shared while an agent works.

The shell is a sandbox process (`c:Condukt.Sandbox.start_process/4`) with
stdin and a pseudo-terminal, run through util-linux `script`, so it needs
`c:Condukt.Sandbox.write_process/4`. The terminal process follows its
output and sends each subscriber `{Condukt.Sandbox.Terminal, id, {:output,
chunk}}`, and `{Condukt.Sandbox.Terminal, id, {:exit, status}}` once the
shell ends. Input is written at the offset the terminal tracks, so a write
repeated after a lost reply lands once.

    {:ok, term} = Condukt.Sandbox.Terminal.start_link(sandbox, id: "pairing")
    :ok = Condukt.Sandbox.Terminal.subscribe(term)
    :ok = Condukt.Sandbox.Terminal.write(term, "make test\r")

A subscriber that joins late gets the last 64 KiB from `subscribe/1`'s
reply first. The shell's size is the pseudo-terminal's default, 80x24:
resizing needs a PTY the sandbox's node controls, which none offers yet.
Stopping the terminal kills the shell.

# `child_spec`

Returns a specification to start this module under a supervisor.

See `Supervisor`.

# `start_link`

Starts a shell. Options: `:id` (the sandbox process id, default a new
one), `:shell` (default `bash -il`), `:cwd`, and `:env`.

# `stop`

Stops the terminal and kills its shell.

# `subscribe`

Subscribes the caller and returns the scrollback so far.

# `write`

Writes input, as typed: a newline is `\r`.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
