Skip to main content
A terminal needs somewhere to keep its files, its state and its records. In Mirage, each of those is a separate backend set in the workspace config, and the agent sees the same terminal whichever one is behind it. This example builds a support agent’s terminal from services a team might already run.

Setup

The workspace mounts Postgres read-only at /db and a SQLite database at /notes, and keeps its sessions and jobs in Redis. The agent’s process sends a trace for each line to Langfuse.
workspace.yaml
Mirage sends a trace for each line once the process sets up an OpenTelemetry SDK. Langfuse accepts traces over OTLP, with the project’s public and secret keys as basic auth:
The agent runs its first lines in one process, then continues in a new one:

Files from Postgres and SQLite

Postgres shows each table as a folder with its schema.json and its rows as rows.jsonl. SQL keeps the files written under /notes in a SQLite database. The first process reads the refunded orders from Postgres and writes their customers to SQLite:

Sessions in Redis

With store.type: redis, the sessions and jobs live in Redis under support-agent, so any process that builds the same workspace picks them up. The second process starts where the first one stopped, with the same working directory and variables:

Command Logs

Mirage records every line the agent runs as a command log. Redis holds no command logs, so history reads them from disk under ~/.mirage/state, on the machine that ran the line. Langfuse gets the same lines as traces, the record to read across machines. Each line is a shell trace, with its command, exit code, output and session. See Spans for every attribute.

Swap a Backend

Each part changes on its own, in the config, with nothing changed in the agent:
  • Virtualize S3, Google Drive or another virtual filesystem at /notes instead of SQLite.
  • Set store.type to disk to keep the state on one machine, or move one store elsewhere, such as store.sessions. See Infrastructure.
  • Point the exporter at another OpenTelemetry backend, such as Jaeger or Honeycomb.