Upstream: crates/rune/README.md § Agent tooling (headless, no window, same renderer, fixed virtual clock) at
65f8eb43f710, MIT © Anomaly. Bundled by build-rune-apps; links point at this snapshot or at GitHub at that rev.
Agent tooling (headless, no window, same renderer, fixed virtual clock)
Debug builds always take these arguments. A release build takes them with Rune's tooling
feature (rune = { ..., features = ["tooling"] }; Rune's examples have it); without it the app
links only its window, and a headless argument makes run fail saying so. --native --trace is
the window's own and works either way.
S=target/release/settings
$S --snap out.png [--scene light] [--at 0.4] [--size 620x520] [--scale 2] [--theme dark|light]
$S --list-scenes # default light dark reduced-motion toggles-off accent-pink slow
$S --script examples/settings/scripts/toggle.json --frames 30 --start 0.1 --out frames/
$S --script examples/settings/scripts/demo.json --video demo.mp4 [--fps 60] [--duration 3|auto]
$S --script demo.json --snap poster.png --at mark:end+0.5 # a time named by a script mark
$S --script examples/settings/scripts/keycaps.json --video keys.mp4 --keys [top-right] --pointer
$S --script examples/settings/scripts/keycaps.json --video keys.mov --keys --keys-theme light
$S --script examples/settings/scripts/demo.json --start 0.12 --frames 24 --every 3 --cols 4 \
--strip strip.png --crop 370,74,214,36 --crop 530,305,60,30 # crops stacked per frame
$S --tree tree.json [--at T] # key, path, role, label, text, presented rect, target, opacity,
# fill/text colour, hover/press, moving
$S --trace run.jsonl # motion-trace JSONL (the app trace format); keyed elements only
$S --native --trace run.jsonl --frames 240 # native submission timestamps, then close the traced window
L=target/release/launcher # every window of a multi-window app, composited over a backdrop
$L --desktop examples/launcher/backdrop.png --script examples/launcher/scripts/demo.json \
--video desktop.mp4 --keys --pointer
Scripts are timestamped
move,down,up,tap(hold),double-click(hold,gap, default 0.15 s between presses) anddrag(dx,dy,dur) events, atx,yin points or at an element bykey(or a path of keys such asslider/knob, where elements without keys between them don't count).{"reopen": true}reopens the app, as a click on its Dock icon (see "App lifetime").{"open_url": "myapp://…"}handsApp::on_open_urla link, as the system does when a link opens the app.menu-pick(with anid) andmenu-cancelanswer an open pop-up menu,file-dialog(with apath) andfile-dialog-cancelan open file dialog (see "File dialogs").drag_filesanddrop_filesdrag files in from another app (see "Dropping files in from other apps").Keys in scripts:
{"type": "key", "name": "Enter"}(withcmd,shift,alt,ctrl) and{"type": "type", "text": "hi"}reach the window even while the app has hidden it: headless there is no real window to hide, soon_keysees every key it would see in a focused window (first when nothing has focus, otherwise what the focused control and focus navigation leave).cmdwith any single character (a letter,1,,) arrives asKey::Command(c), lowercased, as in a window; other keys keep their modifiers inKeyEvent::mods." "givesKey::Command(' '), where a window sends Cmd-Space asKey::Text(" ")withmods.cmd, the onlyTextthat carriescmd;KeyEvent::is_command(' ')matches both."code": "7"(any key name{"physical": …}takes) adds the physical key behind a press, as a window sends it, for handlers that readtx.physical_key(); the key is released right after. With a"code","base": "a"setstx.key_base(); without it a one-character name pressed withoutshiftoraltis its own base, lowercased.{"physical": "cmd+k"}reaches onlyon_physical_inputhandlers.{"type": "key-up", "name": " "}releases a key foron_key_up.Canvas input in scripts:
{"type": "wheel", "dx": 0, "dy": -40}is one wheel delta (withcmdand the other modifiers,"phase": "began" | "moved" | "ended"and"precise", true by default), unlikescroll's eased swipe.{"type": "magnify", "delta": 0.1},{"type": "rotate", "degrees": 15}and{"type": "smart-magnify"}are trackpad gestures. Each lands atx,yorkey, else where the pointer is."button": "middle"(orback,forward,secondary) ondown,up,tapanddragpresses with that button.Window resize in scripts:
{"type": "resize", "dw": -300, "dh": 0, "dur": 0.5}is a person dragging the window's corner, one viewport step a frame with an eased hand, as a live resize delivers it (content at rest follows; unlikeTx::resize_window). The canvas keeps its size, so grow only after shrinking to see the whole window.Chords:
{"type": "shortcut", "chord": "cmd+space"}is the user pressing a chord system-wide (mod+spaceis ⌘ on macOS and Ctrl elsewhere, as in aChord). Register it withApp::global_shortcutorregister_shortcut. Only its shortcut handler runs, exactly as when the OS delivers it: it never reacheson_key, focused controls or physical-input handlers, even when the window is key. An unregistered chord fails the script. The older{"shortcut": "cmd+k"}has the same semantics. To send a window key instead, use{"type": "key", "cmd": true, "name": " "}.Keycaps:
--keys [CORNER]draws the script's keys over the frames, screencast style: typing within a second joins one cap, a repeated chord counts (↓ ×3), modifiers show as ⌃⌥⇧⌘ and named keys as glyphs (↩ ⎋ ⇥ ⌫ ␣). Caps spring in and fade out after 1.5 s, three at most, atbottom-left(default),bottom,bottom-right,top-left,toportop-right. Caps have one fixed screencast style, independent of the app's palette and fonts.--keys-theme auto|light|darkchooses its light or dark colours;auto(default) follows the app's root background, falling back to--themewhen the background is transparent.--pointeradds a ripple at each press. A separate runtime draws both after the app, so they appear in--video,--out,--snapand strips but never in--treeor--trace. That runtime is a secondRuntimein the exe (about 1.46 MB), so a release build draws them only with thekeys-overlayfeature (which includestooling; Rune's examples have it); debug builds always do.Desktop recordings:
--desktop BACKDROP.pngrenders all of a multi-window app's visible windows into one frame, so a launcher, its panel and the app's other windows record together the way a screen recording would show them. Each window renders with its own state into its own texture and is drawn at its frame:WindowOptions::position,place(), else centred on the primary display. Titled windows get 10 pt rounded corners; borderless and transparent windows keep their own shape and alpha. Each window casts a soft shadow from its visible pixels, larger for the key window, unlessMacWindowOptions::shadow(false). Always-on-top windows stay above the rest. The backdrop is scaled to cover the output, centred and cropped. The output is--sizepoints if given, else the script's primary display ({"displays": [...]}), else the backdrop's pixels ÷--scale, times--scalepixels; without scripted displays the window factory sees one display of that size. Scriptx,yandkeypositions are output points. A press goes to the topmost window under it that takes clicks, brings it to the front and gives it the keyboard; a press on the backdrop deactivates the app, as clicking the macOS desktop does: no window has focus and keys go nowhere until a press on a window or{"focus": true}. Keys go to the key window; shortcuts and menu picks go to the key window's app first, then the others. Show, hide, place, focus and close requests apply as they would natively, in the frame whose handlers made them, butquitdoesn't end the recording. When the key window hides, the topmost visible window that takes clicks gets the keyboard; a click-through window never does.--sizeand--scalemust be above 0, the output at most the GPU's texture size, and the backdrop at most 16384 pixels a side.--keysand--pointerdraw over the composite.--window KEYpicks the window--tree,--traceand--scenedescribe, and the tree adds awindowslist of every window's frame.headless_run()givesdesktop(), the window frames as they change (window_frames()) and as they stand at a time (windows_at(t)). The compositor draws no window chrome, so an app that wants a title bar or a menu bar in the recording draws one (examples/launcherdoes both).Rounded panels:
el().clip_rounded(radius)clips an element and its descendants to a rounded rectangle, so a recording of a view meant for a rounded window can round it in the frame the way the window would.Marks:
{"t": 3.2, "type": "mark", "name": "end"}names a time and does nothing else.--at mark:end,--at mark:end+0.5and--start mark:intro-0.2use a mark's time, and--duration auto(the default with--video) ends at theendmark, or one second after the last event without one. Apps read them withheadless_run().mark("end"). Exact names take precedence:mark:step-1selects the mark namedstep-1, if present;mark:step-1+0.5adds half a second. Offsets are numbers in seconds, without a unit suffix.Video:
--video out.mp4streams frames intoffmpeg(which must be onPATH) over a pipe:.mp4is H.264 yuv420p with+faststart,.movProRes 4444 with alpha,.webmVP9. It runs--frames Nor--duration SECONDSfrom--start(default: through theendmark, or one second after the script's last event). Readback keeps three frames in flight, so the GPU renders the next frame while the last one is copied out.--outPNGs share the readback and encode on worker threads, retaining theirframe_0000.pngnames and--everysampling. Video always includes every frame at--fps;--everyonly samples PNGs and strips. Missing ffmpeg fails before GPU startup; encoder errors fail the command with its exit status.--duration auto --out frames/also records headlessly;--outalone uses auto duration. Single-window apps honourwindow_optionstransparency and physical size;--sizeoverrides that size. PNG and ProRes preserve transparent backgrounds.The app can read the run:
rune::tooling::headless_run()isSomein a headless run, frominiton, and None in a window. It gives the script path and its events as Rune feeds them (tapexpanded to move, down and up;typeto one key per character),scale(),fps(),size(),start(),frames()written andend(), the last frame's time. One run serves every window of a multi-window app.use rune::tooling::ScriptEvent; if let Some(run) = rune::tooling::headless_run() { let typed = run.events().iter().filter(|e| matches!(e.event, ScriptEvent::Key { .. })).count(); let end_card = run.mark("end").unwrap_or(run.script_end() + 1.0); }Timing: every headless run prints per-frame CPU time (update, build and encode/submit, without readback).
Startup:
--first-pixelsemits a flushed marker after the first offscreen GPU readback. Buildtarget/perf/settingswith--profile perf. Thenpython3 scripts/bench-startup.py --out perf/startuptimes fresh process launch to that marker (one warmup, seven runs), including loader, app state, GPU work and readback, excluding PNG encoding. This measures process-cold startup with warm OS/driver caches, not physical display presentation.Motion gate:
rune::motion_gaterecords an app's realRuntimeframe by frame in its owncargo testand fails on motion a person would notice (pops, jumps, overshoot, flicker, motion that never settles) unless the app's allowlist gives a reason.scripts/motion-audit/gateruns it with a cell filter and dump or contact-sheet evidence; seescripts/motion-audit/README.md.Trace quality:
python3 scripts/trace-quality.py run.jsonlreports scene-edge error against analytic samples, inherited spatial spring velocity error at retarget, CPU budget excess, and virtual cadence. Growth/scroll are renderer-owned and excluded from the analytic edge metric; virtual timestamps do not measure display hitches. Diagnostics are enabled only with--trace.--native --tracerecords wall-clock CPU submission timestamps (not GPU completion or scanout). In a window factory,--window KEYselects the traced window; otherwise the first is traced. macOS windows and overlays acquire drawables on coalesced display-link ticks, stopping the link while idle or hidden.cargo run --profile perf -p rune --example pacing -- --native --trace pacing.jsonl --frames 240exercises spring retargets and hide/show; check it withpython3 scripts/check-native-pacing.py pacing.jsonlon a machine with a display. Trees expose inheritedopacity,scaleandblur(logical points); traces keep opacity in element rows and encode scale/blur as named scalar channels (cm/c/cg).Present times (macOS windows):
--native --traceframes also carrytarget_ms, the display link's target for the frame, andpresent_ms, the drawable's MetalpresentedTime(when it reached the screen), both in ms ont's clock.present_dt_msis the gap since the previous presented frame, written only when that frame asked for this one right away, so idle time isn't counted.present_msisnullwhen the system skipped the drawable and absent when no time arrived. Lines are written once their present time arrives, two or three frames late. When the trace ends, stderr gets a summary: present-interval p50/p95/max, intervals under 2 ms (frames bunched onto the screen together) and over 1.5 refresh periods (missed refreshes), and the lag from target to present. Overlays, other platforms and headless traces write no present fields. Without--tracenothing changes. Capture on a display, not headless:cargo run --profile perf -p rune --example pacing -- --native --trace pacing.jsonl --frames 240.