Tomacco

Docs Operation reference runtime operations

runtime operations#

11 operations. Generated from assets/operations.json; all areas.

On this page (11)

runtime.start#

Connect native runtime

Start or reuse the single native display session for this device. Repeated calls return its existing session ID. Supports Android, physical iPhone from Linux, and Apple Simulator on an optional SSH Mac. With TOMACCO_FIXTURE_RUNTIME set, device fixture:NAME connects the offline scripted fixture of that name (transport fixture, evidence fixture), for tests and the benchmark runner only.

Annotations: writes, idempotent, open world.

ArgumentTypeRequiredDefaultDetails
platformstringyesone of android, ios
devicestringyesnon-empty, up to 200 characters
remotestringOptional configured Mac workspace for an Apple Simulator; omit for a physical iPhone on Linux.
serverstringOptional scrcpy 4.1 server JAR override.
fpsinteger601 to 60
bit_rateinteger12000000100000 to 50000000
runner_bundle_idstring""Installed WebDriverAgent runner identifier for a physical iPhone.
runner_modestring"xctest"one of xctest, external; xctest: start the signed WDA runner through go-ios; external: WDA is already running on the selected USB device.
audiobooleantrueForward Android output audio to this computer using a session-owned scrcpy playback job. Does not capture a microphone. Unsupported audio leaves video connected and reports audio failure.
tomaccoctl call runtime.start '{"platform":"android","device":"<device>"}'

runtime.list#

Native sessions

List native display sessions and connection status.

Annotations: read-only, idempotent, open world.

Takes no arguments.

tomaccoctl call runtime.list

runtime.audio#

Stream device audio

Start, stop or inspect Android output audio playback on this computer without restarting the app or display session. Repeated starts reuse one playback job. Stops restore the device audio route; they do not mute the device itself. Requires Android 11+ and scrcpy.

Annotations: writes, idempotent, open world.

ArgumentTypeRequiredDefaultDetails
sessionstringyesConnected Android runtime session ID.
actionstring"status"one of start, stop, status
tomaccoctl call runtime.audio '{"session":"<session>"}'

runtime.state#

Runtime status

Read actual runtime dimensions, video counters, transport errors and input_capabilities: whether touch streams live or is sent as an atomic trace, how many contacts, pinch, fill, rotate, capture and hierarchy.

Annotations: read-only, idempotent, open world.

ArgumentTypeRequiredDefaultDetails
sessionstringyesmatching ^[a-f0-9]{32}$; ID returned by runtime.start; separate from desktop preview sessions.
tomaccoctl call runtime.state '{"session":"<session>"}'

runtime.stop#

Disconnect runtime

Stop this display session and its private transport. The device and application remain running.

Annotations: writes, idempotent, open world.

ArgumentTypeRequiredDefaultDetails
sessionstringyesmatching ^[a-f0-9]{32}$; ID returned by runtime.start; separate from desktop preview sessions.
tomaccoctl call runtime.stop '{"session":"<session>"}'

runtime.input#

Native input

Deliver native input using normalized 0..1 coordinates. Android supports touch/tap/swipe/key/text/rotate; text pastes UTF-8. Physical iPhone uses WDA for Unicode text/fill, tap/swipe/rotate, a two-finger pinch (x, y, scale, duration) and gestures committed as one atomic request on touch-up; shake/hinge are unsupported there. Android also takes pinch, as two scrcpy pointers. Apple Simulator supports ASCII HID text and Unicode accessible fill; extra gestures depend on the companion. Pass decoded width/height after Simulator rotation. An AirPlay session (device airplay) drives the iPhone as a Bluetooth pointer and US-layout keyboard once it is paired with Tomacco and AssistiveTouch is on: touch moves the pointer, cut into steps the phone can follow, hover moves it without a button, cancel lifts a held button where the pointer is; t on touch (the caller's clock in ms) lets a release after a rest stop instead of fling; swipe takes hold and rest (seconds still before the move and before the lift); tap, swipe, text and the keys home, back (a swipe in from the left edge), volume_up, volume_down, enter, escape, backspace, delete, tab and the arrows work; app_switcher, control_center, notifications and spotlight send the consumer keys iOS was found to act on, not yet tried from this receiver; scancode types a Linux evdev key code with HID modifiers through the phone's own keyboard layout. fill with verify_value checks the focused editor and reads its exact value back before answering verified (USB iPhone over WebDriverAgent and scripted fixtures; others answer fill_verification_unsupported). runtime.state answers input_capabilities per transport; runtime.gesture sends timestamped traces. With reservation_token it acts under a device reservation (device.reservation.acquire); with request_id it is recorded once in the request ledger, so a repeat after a lost answer is not sent again.

Annotations: writes, not idempotent, open world.

ArgumentTypeRequiredDefaultDetails
sessionstringyesmatching ^[a-f0-9]{32}$; ID returned by runtime.start; separate from desktop preview sessions.
actionstringyesone of touch, tap, swipe, key, text, fill, rotate, shake, pinch, hinge, scancode
phasestringone of down, move, up, cancel, hover
xnumber0 to 1
ynumber0 to 1
tnumberat least 0; For touch on AirPlay: the caller's clock in milliseconds when the pointer did this. A release that follows a rest waits as long (up to 120 ms) so the phone stops instead of flinging
x2number0 to 1
y2number0 to 1
durationnumber0.30.01 to 5
holdnumber0 to 1; For swipe on AirPlay: seconds the finger stays still after the press, as a long press before a drag
restnumber0 to 1; For swipe on AirPlay: seconds the finger stays still before it lifts; 0.12 or more stops without a fling
keystringone of home, back, escape, enter, backspace, delete, tab, up, down, left, right, power, volume_up, volume_down, apps, app_switcher, control_center, notifications, spotlight
codeinteger0 to 1023; For scancode: the Linux evdev key code (linux/input-event-codes.h) of the physical key
modifiersinteger0 to 255; For scancode: the HID modifier byte, bit 0 left Ctrl to bit 7 right GUI (0x02 Shift, 0x04 Alt, 0x40 AltGr)
textstringup to 16000 characters
orientationstringone of portrait, portrait_upside_down, landscape_left, landscape_right
scalenumber0.05 to 20
anglenumber0 to 180
widthinteger1 to 16384
heightinteger1 to 16384
verify_valuebooleanFor fill: verify it (off when left out). The editor that takes the focus after the tap must cover the tapped point (or be named by field_name) and be a supported text field; its value is read before writing (an already matching value is not typed again; a value equal to the placeholder never counts as entered text) and read back afterwards on the same session and element. Answers verified, or an error: nothing typed (field_not_focused, field_wrong_target, field_unsupported, field_stale, field_unobservable, field_tap_failed), or field_uncertain when text was sent and its effect is unknown; nothing is ever retyped. Secure fields are refused unread. Transports that cannot read an editor back answer fill_verification_unsupported and send nothing (input_capabilities.fill_verification)
field_namestringnon-empty, up to 256 characters; For a verified fill: the editor must have this accessibility identifier or label (for a field that moves as it takes the focus); otherwise it must cover the tapped point
focus_timeout_msinteger0 to 10000; For a verified fill: how long to wait for the editor to take the focus after the tap (2000 when left out)
submitbooleanFor a verified fill: send one Return to the field once its value is verified (or already matched) and it still has the focus; never on any other outcome. Check where it led with an expect postcondition or a fresh observation
reservation_tokenstringup to 200 characters; Act under this device reservation (device.reservation.acquire). A reserved device takes input only with its token; a token whose reservation expired, was released or was taken over is refused before anything is sent.
request_idstringnon-empty, up to 128 characters; matching ^[A-Za-z0-9][A-Za-z0-9_.:-]{0,127}$; Your identity for this action, unique per intent (order-42-submit). It is recorded with a digest of the arguments before anything is sent; repeating it with the same arguments answers the recorded outcome (retained: true) or request_outcome_unknown instead of sending again, with other arguments request_conflict. A refusal that sent nothing may be repeated under it. device.request.get shows the record.
tomaccoctl call runtime.input '{"session":"<session>","action":"touch"}'

runtime.capture#

Native capture

Capture a full-resolution PNG from the actual runtime to a local path.

Annotations: writes, not idempotent, open world.

ArgumentTypeRequiredDefaultDetails
sessionstringyesmatching ^[a-f0-9]{32}$; ID returned by runtime.start; separate from desktop preview sessions.
pathstringyesnon-empty
tomaccoctl call runtime.capture '{"session":"<session>","path":"<path>"}'

runtime.hierarchy#

Native accessibility tree

Read Android UI XML, the physical iPhone WDA XML hierarchy or the iOS Simulator accessibility tree for agent inspection.

Annotations: read-only, idempotent, open world.

ArgumentTypeRequiredDefaultDetails
sessionstringyesmatching ^[a-f0-9]{32}$; ID returned by runtime.start; separate from desktop preview sessions.
tomaccoctl call runtime.hierarchy '{"session":"<session>"}'

runtime.observe#

Observe a session

One fresh look at a connected session, for an agent about to act: a full-resolution PNG frame with its id (the first 16 hex digits of its SHA-256), captured_at, capture_ms and age_ms (0 at capture; add the time since captured_at before acting), the geometry the frame was taken in (width, height, orientation, rotation, and for an iPhone the point size and scale) with the coordinate spaces inputs and screen.* use, the foreground app with home_screen, the keyboard, the input focus, the transport's input_capabilities and a one-line context. Every part names its source. What the transport cannot observe is {available:false, reason}, never a guess: Android reads dumpsys window and dumpsys input_method, a USB iPhone asks WebDriverAgent for the active app, a keyboard element and the active element, the Simulator and AirPlay report no app or keyboard, and AirPlay captures no frame. Over MCP the PNG is embedded. A fixture session answers evidence fixture.

Annotations: writes, not idempotent, open world.

ArgumentTypeRequiredDefaultDetails
sessionstringyesmatching ^[a-f0-9]{32}$; ID returned by runtime.start; separate from desktop preview sessions.
pathstringnon-empty; Absolute PNG path for the frame; by default observe.png in the session's directory, replaced each time
contextbooleantrueAlso read the foreground app, keyboard and focus (one or two transport calls); false answers the frame and geometry only
tomaccoctl call runtime.observe '{"session":"<session>"}'

runtime.gesture#

Timestamped gesture trace

Deliver one or more contacts as timestamped traces in 0..1 of the frame: each contact's points with t_ms from its touch-down. The answer's mode says what the transport did: atomic_trace (a USB iPhone submits the whole trace as one WebDriverAgent actions request, deterministic but not live) or live (Android, the Simulator and the fixture replay the events with host timing, one contact after another by time). Multi-contact traces need a transport whose input_capabilities (runtime.state) allow it; AirPlay answers an error. Use runtime.input touch for an interactive drag that follows a pointer. With reservation_token it acts under a device reservation (device.reservation.acquire); with request_id it is recorded once in the request ledger, so a repeat after a lost answer is not sent again.

Annotations: writes, not idempotent, open world.

ArgumentTypeRequiredDefaultDetails
sessionstringyesmatching ^[a-f0-9]{32}$; ID returned by runtime.start; separate from desktop preview sessions.
contactsarray of objectyes1 to 5 items; The fingers, each a trace of 2 to 240 points
contacts[].pointsarray of objectyes2 to 240 items
contacts[].points[].xnumberyes0 to 1
contacts[].points[].ynumberyes0 to 1
contacts[].points[].t_msintegeryes0 to 10000; Milliseconds since this contact touched down; non-decreasing
reservation_tokenstringup to 200 characters; Act under this device reservation (device.reservation.acquire). A reserved device takes input only with its token; a token whose reservation expired, was released or was taken over is refused before anything is sent.
request_idstringnon-empty, up to 128 characters; matching ^[A-Za-z0-9][A-Za-z0-9_.:-]{0,127}$; Your identity for this action, unique per intent (order-42-submit). It is recorded with a digest of the arguments before anything is sent; repeating it with the same arguments answers the recorded outcome (retained: true) or request_outcome_unknown instead of sending again, with other arguments request_conflict. A refusal that sent nothing may be repeated under it. device.request.get shows the record.
tomaccoctl call runtime.gesture '{"session":"<session>","contacts":[{"points":[{"x":0,"y":0,"t_ms":0},{"x":0,"y":0,"t_ms":0}]}]}'

runtime.actions#

Ordered input batch

Run up to 50 input and wait steps in order on one session, in one call, with a result per step. A text step waits until a field has the focus (polling the session's focus and keyboard) before it types, so the first characters are not lost, and answers focus_timeout with nothing typed when no field takes it; where the transport cannot report focus it says so and settles briefly instead. A tap can name a mark from the last screen.marks of this session and is verified like screen.tap. A step may carry expect, a text that must appear or go afterwards: met makes the step verified, otherwise postcondition_failed stops the batch with the step still counted as applied. A fill step with verify_value is verified only when the field's exact value was read back; text sent with an unknown effect makes it uncertain (field_uncertain) and it is never sent again. The first failure stops the rest: the error's details list every step so far (steps), the indexes that reached the device (applied_steps), those whose effect is unknown (uncertain_steps) and those not run (skipped), so an agent never resends an applied step. The whole batch is bounded by timeout and by the client's cancellation. With frame (width, height, orientation from runtime.observe) the batch is refused with frame_stale and nothing sent when the screen's geometry changed since. observe_after appends a fresh runtime.observe. The answer's evidence is fixture on the offline fixture runtime. With reservation_token it acts under a device reservation (device.reservation.acquire); with request_id it is recorded once in the request ledger, so a repeat after a lost answer is not sent again.

Annotations: writes, not idempotent, open world.

ArgumentTypeRequiredDefaultDetails
sessionstringyesmatching ^[a-f0-9]{32}$; ID returned by runtime.start; separate from desktop preview sessions.
stepsarray of objectyes1 to 50 items
steps[].actionstringyesone of tap, swipe, key, text, fill, pinch, rotate, gesture, wait, wait_text, wait_text_gone, wait_stable, observe; tap (x, y or mark), swipe, key, text (after the field has the focus), fill (verify_value reads the value back), pinch, rotate and gesture change the device; wait, wait_text, wait_text_gone, wait_stable and observe only look
steps[].xnumber0 to 1; 0..1 of the frame's width
steps[].ynumber0 to 1; 0..1 of the frame's height
steps[].x2number0 to 1; Swipe end
steps[].y2number0 to 1; Swipe end
steps[].markinteger1 to 200; For tap: a mark number from the last screen.marks of this session, verified like screen.tap
steps[].verifybooleantrueFor tap by mark: check the mark still matches first
steps[].hold_msinteger100 to 5000; For tap: hold this long (a long press)
steps[].durationnumber0.01 to 5; Seconds for swipe and pinch
steps[].keystringone of home, back, escape, enter, backspace, delete, tab, up, down, left, right, power, volume_up, volume_down, apps
steps[].textstringup to 16000 characters; For text and fill: what to type; for wait_text and wait_text_gone: what to wait for
steps[].focusstring"wait"one of wait, require, none; For text: wait polls the session until a field has the focus (or the keyboard shows where focus is not reported) before typing, and answers focus_timeout with nothing typed when none does; require also fails when the transport cannot report focus; none types at once
steps[].focus_timeout_msinteger20000 to 60000; For text: how long to wait for a focused field. For a verified fill: how long to wait for the editor after the tap, at most 10000
steps[].settle_msinteger3000 to 5000; For text when focus cannot be observed: how long to wait before typing
steps[].orientationstringone of portrait, portrait_upside_down, landscape_left, landscape_right
steps[].scalenumber0.05 to 20
steps[].contactsarray of object1 to 5 items
steps[].contacts[].pointsarray of objectyes2 to 240 items
steps[].contacts[].points[].xnumberyes0 to 1
steps[].contacts[].points[].ynumberyes0 to 1
steps[].contacts[].points[].t_msintegeryes0 to 10000
steps[].msinteger0 to 10000; For wait
steps[].timeout_msinteger50000 to 300000; For wait_text, wait_text_gone and wait_stable
steps[].interval_msinteger20050 to 10000
steps[].stable_msinteger500100 to 60000
steps[].thresholdnumber0.0010 to 1
steps[].toleranceinteger240 to 255
steps[].ignorearray of objectup to 100 items
steps[].ignore[].xintegeryesat least 0
steps[].ignore[].yintegeryesat least 0
steps[].ignore[].widthintegeryesat least 1
steps[].ignore[].heightintegeryesat least 1
steps[].sourcestring"auto"one of auto, hierarchy, ocr
steps[].fuzzybooleanfalse
steps[].min_confidencenumber400 to 100
steps[].languagestring"eng"matching ^[A-Za-z0-9_+]+$
steps[].regionobject
steps[].region.xintegeryesat least 0
steps[].region.yintegeryesat least 0
steps[].region.widthintegeryesat least 1
steps[].region.heightintegeryesat least 1
steps[].contextbooleantrueFor observe: also read app, keyboard and focus
steps[].expectobjectA postcondition checked after the step: text that must appear (text) or go (text_gone) within timeout_ms; met makes the step verified, otherwise postcondition_failed stops the batch with the step still counted as applied
steps[].expect.textstringnon-empty
steps[].expect.text_gonestringnon-empty
steps[].expect.timeout_msinteger30000 to 300000
steps[].expect.interval_msinteger20050 to 10000
steps[].expect.sourcestring"auto"one of auto, hierarchy, ocr
steps[].expect.fuzzybooleanfalse
steps[].expect.min_confidencenumber400 to 100
steps[].expect.languagestring"eng"matching ^[A-Za-z0-9_+]+$
steps[].expect.regionobject
steps[].expect.region.xintegeryesat least 0
steps[].expect.region.yintegeryesat least 0
steps[].expect.region.widthintegeryesat least 1
steps[].expect.region.heightintegeryesat least 1
steps[].verify_valuebooleanFor fill: verify the editor and read its exact value back, as runtime.input does; verified makes the step verified, field_uncertain makes it uncertain (listed in uncertain_steps, never resent)
steps[].field_namestringnon-empty, up to 256 characters; For a verified fill: the editor must have this accessibility identifier or label (for a field that moves as it takes the focus); otherwise it must cover the tapped point
steps[].submitbooleanFor a verified fill: send one Return to the field once its value is verified (or already matched) and it still has the focus; never on any other outcome. Check where it led with an expect postcondition or a fresh observation
timeoutinteger301 to 300; Seconds for the whole batch, waits included
frameobjectThe frame the steps were planned on, from runtime.observe: refused with frame_stale when the screen's size or orientation differs now
frame.idstringup to 64 characters
frame.widthinteger1 to 16384
frame.heightinteger1 to 16384
frame.orientationstringone of portrait, landscape
observe_afterbooleanfalseAppend a fresh observation of the session to the answer
reservation_tokenstringup to 200 characters; Act under this device reservation (device.reservation.acquire). A reserved device takes input only with its token; a token whose reservation expired, was released or was taken over is refused before anything is sent.
request_idstringnon-empty, up to 128 characters; matching ^[A-Za-z0-9][A-Za-z0-9_.:-]{0,127}$; Your identity for this action, unique per intent (order-42-submit). It is recorded with a digest of the arguments before anything is sent; repeating it with the same arguments answers the recorded outcome (retained: true) or request_outcome_unknown instead of sending again, with other arguments request_conflict. A refusal that sent nothing may be repeated under it. device.request.get shows the record.
tomaccoctl call runtime.actions '{"session":"<session>","steps":[{"action":"tap"}]}'

View this page as Markdown on GitHub