wrec agent docs
This page is the operating contract for automation agents. Prefer the CLI, prefer JSON, select exact targets, and treat daemon job state as the source of truth.
Agent contract
| Rule | Reason |
|---|---|
| Use JSON | Pass --json on every command that supports it. Do not parse plain text when JSON exists. |
| Select exact targets | Run wrec targets --json, then pass --target display:<id> or --target window:<id>. |
| Treat ids as temporary | Target ids are stable only for the current target list. Refresh targets before a new task. |
| Trust job status | A recording is done only when its job status is completed, failed, or cancelled. |
| Follow error.next | JSON errors include code, message, recoverable, and next. Use next as the retry instruction. |
| Expect one active job | The daemon runs one active recording. Extra recordings queue by default unless --no-queue is passed. |
1. Discover targets
Always start here unless the user already supplied an exact target id from the current session.
wrec targets --json2. Record an exact target
Prefer --target kind:id over name matching. Foreground mode waits until the job is completed, failed, or cancelled.
wrec record start --target display:1 --duration 30s --json3. Submit and return
Use --detach when another process will monitor or control the job.
wrec record start --target window:438 --duration 5m --detach --json4. Inspect and control jobs
Use the job id from job_submitted or from wrec jobs --json.
wrec jobs --json
wrec job show 42 --json
wrec job stop 42 --jsonOverride capture settings
Overrides apply only to this run. They do not rewrite saved app settings.
wrec record start --app Safari --quality high --resolution native --fps 60 --codec hevc --out ~/Movies/Wrec --no-cursor --system-audio --hide-wrecNon-interactive duration recording
A duration recording keeps running if stdin closes, then finalizes when the duration elapses.
wrec record start --target window:438 --duration 30s --json </dev/nullTarget output
wrec targets --json returns a JSON array. Each item hasid, kind, and name. Valid kinds aredisplay and window.
[{"id":1,"kind":"display","name":"Display 1"}]Do not reuse ids across independent tasks. If a selector fails, rerunwrec targets --json and choose from the new list.
Recording output
wrec record start --json prints JSON lines. The first line is job_submitted. Foreground recordings then streamjob_event lines until the job reaches a terminal status.
{"event":"job_submitted","job":{"id":42,"status":"starting","output_path":null,"warnings":[],"events":[]}}
{"event":"job_event","job_id":42,"level":"info","message":"starting capture -> /Users/me/Movies/Wrec/wrec-2026.mov","metrics":null,"timestamp_ms":1790000000000}
{"event":"job_event","job_id":42,"level":"info","message":"capture engine exited: exit status: 0","metrics":null,"timestamp_ms":1790000030000}| Event | Fields |
|---|---|
job_submitted | First JSON line from record start --json. Contains job. |
job_event | Streaming foreground event with job_id, level, message, metrics, timestamp_ms. |
error | Command failure with code, message, recoverable, next. |
Job snapshots
wrec jobs --json returns jobs andactive_job_id. wrec job show <id> --jsonreturns job. Job control commands return the updatedjob.
{"jobs":[{"id":42,"status":"recording","output_path":"/Users/me/Movies/Wrec/wrec-2026.mov","queued_position":null}],"active_job_id":42}| Field | Meaning |
|---|---|
id | Job id for show/logs/pause/resume/stop/cancel. |
status | One of the job statuses below. |
target | Selected capture target when resolved. |
settings | Final settings after saved app config plus CLI overrides plus preset caps. |
output_path | Final .mov path once the capture engine reports it. |
queued_position | Queue position when waiting behind another job. |
warnings | Non-fatal issues with code, message, next. |
events | Job event history. |
Job statuses
| Status | Meaning |
|---|---|
queued | Waiting behind another recording. |
starting | Daemon accepted the job and is starting capture. |
recording | Capture is active. |
paused | Capture is paused. |
finishing | Stop requested; capture engine is finalizing the file. |
completed | Terminal success state. Output is finalized. |
failed | Terminal failure state. Inspect error events and daemon log. |
cancelled | Terminal failure state for a queued job cancelled before recording. |
Error handling
With --json, command failures print one errorobject. If recoverable is true, follow next. If it is false, stop and report the error.
{"event":"error","code":"target_not_found","message":"no window with id 438","recoverable":true,"next":"Run `wrec targets --json` and pass one of the listed `window` ids."}Foreground record start --json exits with code 0 forcompleted. It exits nonzero for failed orcancelled. Detached mode exits after submission; inspect the job later to determine final success.
Target selectors
Pass only one target selector. Name and app selectors resolve by exact, prefix, then contains match, and fail if more than one target matches. Agents should use name matching only as a fallback.
| Selector | Use |
|---|---|
--target display:1 | Best selector for agents when recording a display. |
--target window:438 | Best selector for agents when recording a window. |
--display 1 | Equivalent display-id form. |
--window 438 | Equivalent window-id form. |
--app Safari | Match one visible window by app name. Use only when id is unavailable. |
--target-name README | Match one display or window by name. Can fail on ambiguous matches. |
--display-name Studio | Match one display by name. |
--window-name README | Match one window by name. |
Record options
--fps 30|60Override frame rate.
--codec hevc|h264Override video codec.
--quality efficient|balanced|highOverride quality preset.
--resolution native|720p|1080p|2k|4kOverride output resolution.
--out <dir>Override output directory.
--duration <time>Stop after a duration like 500ms, 30s, 5m, or 1h.
--cursor / --no-cursorEnable or disable cursor capture.
--system-audio / --no-system-audioEnable or disable system audio capture.
--hide-wrec / --no-hide-wrecEnable or disable hiding wrec windows from capture.
--detachSubmit the job and return after job_submitted.
--queue / --no-queueQueue behind the active recording or fail instead.
--jsonEmit machine-readable output.
Preset caps
| Preset | Max resolution | Max frame rate |
|---|---|---|
| Efficient | 720p | 30 fps |
| Balanced | 1080p | 30 fps |
| High | Native, 2k, or 4k | 60 fps |
Saved settings and CLI overrides are capped by the selected preset before recording. Use --quality high when automation needs native resolution or 60 fps.
Defaults
Fresh config defaults to display capture, 30 fps, HEVC, Balanced, 1080p, cursor on, system audio on, hide wrec on, and~/Movies/Wrec as the output folder.
Command reference
wrec targets --jsonReturn the current capture targets as a JSON array.
wrec targets list --jsonExplicit form of target listing.
wrec list --jsonAlias for wrec targets --json.
wrec record start --jsonSubmit a recording job and, unless --detach is passed, stream job events until terminal status.
wrec record --jsonAlias for wrec record start --json.
wrec jobs --jsonList queued, active, and recent recording jobs.
wrec job show <id> --jsonInspect one job snapshot.
wrec job logs <id> --jsonRead job events.
wrec job pause <id> --jsonPause the active job.
wrec job resume <id> --jsonResume a paused job.
wrec job stop <id> --jsonStop the active job and finalize the file.
wrec job cancel <id> --jsonCancel a queued job.
wrec daemon status --jsonCheck the local coordinator.
wrec daemon stop --jsonStop the coordinator when no jobs are active or queued.
wrec help, -h, --helpPrint CLI help.
wrec -V, --versionPrint the CLI version.
+----------------+
| core |
| domain types |
+--------+-------+
|
+------------------+------------------+
| |
+-------v------+ +-------v------+
| wrec-app | | wrec CLI |
| GPUI client | | terminal UX |
+-------+------+ +------+-------+
| |
+---------------+--------------------+
|
+-----v------+
| control |
| IPC client |
| protocol |
+-----+------+
|
Unix socket
|
+-----v------+
| daemon |
| queue/jobs |
| settings |
| store I/O |
+-----+------+
|
+-----v------+
| macos |
| recorder |
+-----+------+
|
+-----v----------+
| capture-engine |
| SCK + writer |
+-----+----------+
|
ScreenCaptureKit -> AVAssetWriter -> .mov| Clients stay thin | The app and CLI own user interaction only. They do not import backend, macOS recorder, or capture-engine code. |
| Control is the contract | The control crate owns IPC request/response types, daemon discovery, daemon startup, job snapshots, errors, and protocol version checks. |
| Daemon owns recording state | The daemon is the source of truth for target listing, Screen Recording permission requests, one active job, queued jobs, pause/resume/stop, and persisted events. |
| Platform code stays below daemon | The macOS recorder and Swift capture engine are runtime internals. Agents should observe them only through daemon job events and errors. |
| Separate packages share one runtime shape | The app package carries wrec-app, daemon, and capture-engine. The standalone CLI package carries wrec, daemon, and capture-engine. |
| Agent rule | Use the CLI with --json, trust daemon job state, refresh target ids per task, and follow error.next for recoverable failures. |