Skip to main content
A terminal gives an agent the same primitives a human gets: a stateful shell, working directory, environment, real interactive programs. The agent writes keystrokes, reads bytes, decides the next command.
.env

1. Create a machine and open a terminal

2. Bridge stdin/stdout for the agent

The agent writes a command, you send it as a Binary frame, you collect the bytes that come back until the shell prints a fresh prompt, then you hand the captured output to the agent.

3. Loop the agent against the shell

Notes

  • Why a terminal and not executions? State persists across commands. cd /tmp && ls followed by pwd returns /tmp. Executions are independent and lose that.
  • Resize the PTY before running TUI programs (top, htop, less): send a Text frame {"cols": 200, "rows": 50}.
  • Stripping ANSI is only for the prompt-detection heuristic. If the agent itself benefits from colors and cursor codes (e.g., parsing git status output), pass the raw bytes through.
  • Detect the prompt robustly by setting PS1 to a known sentinel (export PS1='__DEDALUS_PROMPT__$ ') at the start of the session. Regex against that instead of \$\s$.
  • Timeouts: wrap readUntilPrompt in a Promise.race against a timer; long-running commands (apt-get install) don’t return a prompt for a while.
Last modified on May 12, 2026