espressostreamdocs
On this page

Agent recordings

An AI coding agent or a CI job runs commands where no one is watching. espresso can record such a session without a terminal, log every program it runs, mask secrets, and keep the result private by default. Later you can replay what happened.

Recording without a terminal

espresso rec --headless -c 'make test' test.cast
espresso rec --agent -c 'claude -p "fix the failing tests"' session.cast
  • --headless gives the command a fixed-size terminal (--window-size, default 120x40). It shows nothing and ignores standard input. espresso exits with the command's exit code.
  • --agent is shorthand for --headless --trace-exec --redact-default, and it marks the recording as an agent recording in its header.

The exec trace (Linux)

--trace-exec records every program the session starts (path, arguments, working directory, parent process, start and end time, exit status or signal) into a sidecar file next to the recording: session.cast.trace.jsonl. It also adds a marker $ <command> for each top-level command, so the player shows them as chapters.

  • It uses ptrace. The tracer stops the traced process only when it starts, runs a new program, or exits. Measured overhead: up to about 2 ms per program started.
  • Environment variables are never recorded.
  • If ptrace is blocked (some containers, Yama ptrace_scope 3), espresso prints a warning and records without a trace.
  • Ctrl-Z and other job-control stops are resumed at once while tracing. Processes still running when the command ends are killed with it, and their records have "end": null.
  • macOS and Windows: not supported (espresso says so and records without a trace).

The web player shows the trace next to the recording when it is uploaded with it. The record format is described in File format → Exec trace.

Secrets

--redact-default (on with --agent) masks secrets in the trace's arguments, in step labels and in markers as they are written. --redact RE adds your own patterns. The terminal output in the .cast file is not masked when recording. It is masked:

  • by espresso upload, for agent recordings (unless you pass --no-redact),
  • by espresso stream, before anything leaves the machine, for agent streams, and
  • whenever you run espresso edit --redact-default.

See CLI guide → Privacy for what the built-in patterns cover.

Private by default

Uploads of agent recordings and --agent streams default to private visibility: only you can see them, when signed in. Pass --visibility unlisted or public to share them.

For a CI job, create an upload-only token. It can upload and call /api/v1/me, nothing else:

espresso-server admin create-token ci-bot --label github-actions --scope upload

Marking steps from scripts

Inside a recording, espresso mark talks to the recorder through a private control socket (path in $ESPRESSO_CONTROL):

espresso mark "install dependencies"   # marker + start of a step
npm ci
espresso mark --exit $?                # end of the step, with its exit status

Steps go into the trace file. Outside a recording espresso mark does nothing and exits 0.

Claude Code hooks

espresso agent-hooks claude-code

prints a hooks configuration that runs espresso mark -q --hook claude-code before and after every Bash tool call. Merge it into your Claude Code settings yourself (for example .claude/settings.local.json in a project); espresso never edits them. Then run the agent inside a recording:

espresso rec --agent session.cast -c 'claude -p "fix the tests"'

Each Bash tool call becomes a marker $ <command> and a step with its exit status. Outside a recording the hook does nothing.

Watching live

espresso stream --agent -c './long-job.sh'              # through your server, private
espresso stream --local 0.0.0.0:8080 --agent -c './job'  # viewer served from this machine, no login

The output is masked before it is sent. See CLI guide → stream.