File format
espresso stores recordings as asciicast files (.cast), the plain-text format that many terminal
recording tools use. It reads versions 2 and 3, and writes version 3 by default (--format v2 for the
older one). Files from other asciicast-compatible tools play in espresso, and espresso's files play in
theirs.
A .cast file is JSON Lines: the first line is a JSON object (the header),
and every following line is a JSON array (an event).
Version 3
{"version": 3, "term": {"cols": 80, "rows": 24, "type": "xterm-256color"}, "timestamp": 1764730000, "title": "Demo"}
[0.120, "o", "$ "]
[1.503, "o", "ls\r\n"]
[0.004, "o", "README.md go.mod\r\n$ "]
[2.000, "m", "after ls"]
[0.750, "r", "100x30"]
[1.100, "x", "0"]
Header keys
| Key | Required | Meaning |
|---|---|---|
version |
yes | 3 |
term.cols, term.rows |
yes | terminal size at the start |
term.type, term.version |
no | $TERM and the terminal program's version |
term.theme |
no | fg, bg (#rrggbb) and palette (8 or 16 colours separated by :) |
timestamp |
no | start time, Unix seconds |
idle_time_limit |
no | players shorten pauses longer than this many seconds |
command |
no | the command that was recorded |
title |
no | title |
env |
no | selected environment variables, e.g. SHELL |
tags |
no | list of strings |
Events are [interval, code, data]. In version 3 the first value is the time in seconds since the
previous event:
| Code | Data | Meaning |
|---|---|---|
o |
text | output written to the terminal (escape sequences included) |
i |
text | keyboard input (only with espresso rec --record-input) |
r |
"COLSxROWS" |
the terminal was resized |
m |
label | a marker (chapter); may be empty |
x |
exit status as text | the recorded program exited |
Lines starting with # are comments and are skipped.
Version 2
Version 2 differs in three ways:
- The header has
widthandheightinstead ofterm, andthemeat the top level. - The first value of each event is the time since the start of the recording, not since the previous event.
- There are no comment lines.
{"version": 2, "width": 80, "height": 24, "timestamp": 1764730000, "env": {"TERM": "xterm-256color"}}
[0.120, "o", "$ "]
[1.623, "o", "ls\r\n"]
espresso convert changes a file between the versions and loses nothing. When writing version 2,
espresso also keeps the version 3 fields (term.type, tags) under their version 3 names, which other
version 2 readers ignore. It also writes x events into version 2 files.
How espresso reads files
- Output must be valid UTF-8. espresso keeps a multi-byte character together when a recording splits it between two output chunks.
- A truncated last line (from a crash) is dropped, and the rest of the file still plays.
- Unknown header keys and unknown event codes are kept when espresso converts or edits a file.
- Times that go backwards are treated as no pause.
- Version 1 files (a single JSON document) are not supported.
espresso's additions
Two additions that other players can safely ignore:
- An
x-espressoobject in the header, written by agent recordings:{"agent": true, "trace": true, "redacted": true}. - Markers written by shell integration:
$ <command line>when a command starts andexit <status>when it ends. espresso's web player shows each pair as one chapter with the exit status.
Exec trace sidecar
espresso rec --trace-exec writes <file>.trace.jsonl next to <file>. It is JSON Lines, with one record
per program started and one per step marked with espresso mark:
{"type":"exec","id":1,"pid":4242,"ppid":4241,"argv":["make","test"],"cwd":"/src","start":0.51,"end":9.40,"exit":2}
{"type":"exec","id":2,"parent":1,"depth":1,"pid":4250,"ppid":4242,"argv":["go","test","./..."],"cwd":"/src","start":0.62,"end":9.31,"exit":1}
{"type":"step","id":3,"label":"$ make test","start":0.50,"end":9.50,"exit":2}
| Field | Meaning |
|---|---|
type |
exec (a program) or step (from espresso mark) |
id, parent, depth |
record id; the parent record's id and nesting depth |
pid, ppid |
process ids |
argv, cwd |
arguments and working directory (masked with --redact-default) |
label |
step label |
start, end |
seconds since the start of the recording, using the same clock as the events (paused time is left out). end is null if the process was still running when the recording ended |
exit / signal |
exit status, or the signal that killed it (e.g. "SIGKILL") |
replaced |
true when the process went on to run another program (a later exec record) |
Records are not sorted, because a parent usually ends after its children. Sort them by start.
Environment variables are never part of a trace.
Limits on the server
The server accepts files up to 50 MB (10 MB gzip-compressed), 6 hours, 5 million events, terminals up to 1000×500, and lines up to 1 MB.