MCP methods
Kasm Session Runtime serves 68 methods over the Model Context Protocol (MCP) when it runs as kasm-session-runtime mcp. An outside agent, such as Claude Code, Codex or any other MCP client, uses them to drive the desktop directly. No scenario runs in this mode; your agent decides whether its task succeeded, and the report’s verdict covers the runtime’s own health. The same methods are available as plain HTTP calls at POST /v1/call/<method> (see HTTP API).
| Family | Methods |
|---|---|
| screen | 6 |
| windows | 5 |
| input | 8 |
| clipboard | 2 |
Processes, launch, shell, wait_while |
6 |
| Applications | 3 |
| recipes | 4 |
| dom | 21 |
| a11y | 8 |
| human | 1 |
| Files | 2 |
| Downloads | 2 |
Most of these methods need no model in the runtime. Three of them, screen.judge, screen.ground and screen.ask, use a vision backend, and recipes that declare screen.* steps use it too. The backend is the endpoint in KASM_RUNTIME_VISION_ENDPOINT (any OpenAI-compatible server). With no endpoint set, a signed-in Claude Code agent in the workspace answers screen.judge, screen.ground and screen.ask with a small Claude model on the same account, unless KASM_RUNTIME_HARNESS_VISION=off. Codex and OpenCode do not answer them. With neither, the three return a resolution error and every other method works as normal. The “Model” column in each table below says which is which.
Every call is recorded as one row in report.json’s steps[] with "backend": "rpc", the same record a scripted run leaves.
Transports and credentials
Section titled “Transports and credentials”| stdio | Streamable HTTP | |
|---|---|---|
| When | the default | KASM_RUNTIME_SESSION_TOKEN is set |
| Wire | JSON-RPC 2.0, one message per line | MCP Streamable HTTP at /mcp, port KASM_SESSION_RUNTIME_PORT (default 9434) |
| Protocol version | initialize must send 2024-11-05 |
chosen per request by the Mcp-Protocol-Version header; 2026-07-28 and later are stateless, earlier versions use initialize and Mcp-Session-Id |
| Credential | none; the pipe is the trust boundary | the session token in the X-Kasm-Runtime-Session-Token header, 401 if missing or wrong |
| Typical caller | a client that starts kasm-session-runtime mcp as a subprocess inside the session |
a client outside the container, reaching the session through Kasm’s reverse proxy |
The initialize reply’s instructions are the session guidance MCP clients can pass to their model: reuse running applications and start installed ones with apps.start, and for a request naming an application or service, prefer an installed desktop application found in apps.list to the website. They also carry the recipe protocol every harness needs (read the guide, recipes.index, trust only a verified receipt, answer a needs_decision with decision.resume_call plus decisions, receipt_path as an absolute path) the progress-update rules, and what the session is: a container with no systemd, the /v1/files/ and /v1/dirs/ routes as the one way files move in and out, and that only a persistent profile’s home directory or mapped storage outlives the session. stdio and HTTP send the same text. Claude Code’s launcher appends only a note about loading deferred tools.
No method has a credential of its own; the transport’s credential covers every method.
Coordinate spaces
Section titled “Coordinate spaces”Coordinates are screen pixels unless a request asks for the agent canvas with the header X-Kasm-Runtime-Coordinates: agent (stdio: KASM_RUNTIME_COORDINATES=agent). The managed Claude Code launcher sends it. The canvas is a fixed 1280×800: the screen is fitted into it at its own aspect ratio and centred, with black bars where its shape differs from 16:10. The runtime’s sidebar keeps the desktop at 16:10, so there are normally no bars.
screen.capturereturns the 1280×800 canvas withspace: "agent"and the realscreen_widthandscreen_height. Aregionis in canvas pixels; awindowcrop is the window’s visible rectangle on the canvas. A crop’s input point isorigin_x,origin_yplus the image point.- Points sent to
input.click,input.move,input.drag,input.scrollandinput.wait_forare canvas points; one in a bar is outside the screen.screen.groundpoints,a11y.actionclick points andinput.wait_forevents come back as canvas points. - Window
x,y,wandh(windows.list,windows.wait,windows.close,windows.move_resize) convert linearly, so off-screen positions keep their meaning. dom.*coordinates are page CSS pixels in either space.- A coordinate action is refused when the screen size changed since the caller’s last observation (a capture, window list or grounding); capture again. The check is best effort: it compares sizes, so a resize there and back, or any change that is not a resize, is not caught.
The token goes in a custom header because Kasm’s port-map proxy overwrites Authorization before forwarding. Through Kasm, the address is https://<host>/desktop/<kasm_id>/runtime/mcp, where runtime is the port-map service name and mcp is the runtime’s own path.
Calls are handled one at a time on both transports, and on HTTP a second call waits for the first to finish. The session has one display, and DOM calls can address pages in several registered applications.
tools/list returns the 68 methods in sorted order, each with its JSON Schema. The HTTP server stays off unless the session is started with KASM_RUNTIME_SESSION_TOKEN; see Enable the runtime on a workspace.
Some MCP clients list dotted names with underscores, so apps.start can appear as apps_start. Over /v1/call/ the dotted name is the one to use.
Errors
Section titled “Errors”A method that fails returns a normal tools/call result with isError: true. The message starts with the method name and says what went wrong. Failures fall into three classes.
| Class | Meaning | What to do |
|---|---|---|
| Malformed | bad or missing parameters; the call never touched the session | fix the parameters and retry |
| Resolution | a capability is unavailable, something was not found, or a wait timed out | retry, try something else, or give up |
| Environment | the runtime itself is broken: X11 unreachable, a command that cannot start, the model erroring | not retryable |
Over /v1/call/, the class decides the HTTP status: malformed is 400, resolution 422, environment 500. A refusal with structured detail, such as a mutation a modal dialog blocks (see a11y), also carries it: as error.data over /v1/call/, and as JSON after the message in an MCP result.
JSON-RPC protocol errors are used for unparsable input, unknown methods and shutdown. A call that arrives after the server has begun shutting down, or is still waiting its turn then, is refused with a JSON-RPC error whose message names “server shutting down” (code -32001 on stdio); that call never ran and records no step. A call already running when shutdown begins finishes and is recorded.
screen
Section titled “screen”| Method | Parameters | Returns | Model |
|---|---|---|---|
screen.capture |
optional, at most one of window (a reference from windows.list) or region ({x, y, width, height}, all required inside it) |
{Width, Height, JPEGBase64, origin_x, origin_y, scale_x, scale_y, screen_width, screen_height, window?, space?, artifact?}, at the size actually captured |
No |
screen.judge |
expectation (string, required) |
{Holds, Description} |
Yes |
screen.ground |
description (string, required) |
{Found, X, Y, Description} |
Yes |
screen.ask |
question (string, required) |
a plain-text answer | Yes |
screen.mark |
none | {frame, held} |
No |
screen.wait |
until (settled or changed) and timeout_s (required); since (a frame from screen.mark, required for changed); window |
{matched, elapsed_ms, changed_fraction, frames_compared} |
No |
screen.capture,screen.ground,screen.ask,screen.markandscreen.waitneed the X11 display; without it they return a resolution error (“no X connection”).- With no
windoworregion,screen.capturereturns the whole screen. Awindowcapture is the window’s visible rectangle, including anything that covers it. Aregionis in screen pixels. The image is never resized (scale_xandscale_yare 1), and a crop’s input point isorigin_x,origin_yplus the image point.artifactnames the saved file underscreenshots/, whichGET /artifacts/<file>serves. - The three vision methods use the endpoint in
KASM_RUNTIME_VISION_ENDPOINTwhen one is set. With none, a signed-in Claude Code agent in the workspace answers them through one stateless call per question, to a small Claude model on the same account; the frame goes to that provider. Codex and OpenCode do not answer them, andKASM_RUNTIME_HARNESS_VISION=offturns the fallback off. With no backend, or when the runtime has stopped calling the endpoint after repeated failures, they return a resolution error that names the endpoint and the fallback. An error from the model during the call is an environment error, except inscreen.ground, where a location the model cannot give is a resolution error. screen.groundreturns a location and does not click; pass itsXandYtoinput.click. They are screen pixels whatever answer convention the model uses. When the element is not visible it returnsFound: falsewith no point.screen.asksends the screenshot and, when available, text from the attached browser tab (title, URL, visible text, interactive elements) and the accessibility tree’s actionable elements.- Grounding accuracy depends on the model, capture settings and screen size. See Vision models.
screen.waitis the wait for an application with nothing else to wait on. Takescreen.markbefore acting and pass itsframeassince:changedthen matches when the screen differs from that frame by more than the settle threshold, even if the repaint finished before the wait began.settledmatches when two frames in a row agree.windowcompares only that window’s rectangle, so a video elsewhere does not keep the screen moving. A timeout ismatched: false, not an error. Marks are kept within 32 MiB, newest first; an expired frame is a resolution error. While it waits, no other call runs.changedsays the pixels changed, not which action changed them, andsettledsays the screen stopped moving, not that an operation finished. Measured on LibreOffice, GIMP, VLC and a Wine application, achangedafter a click, a key or a drag matched within 14 to 208 ms, and asettledtook about 200 to 400 ms.
windows
Section titled “windows”| Method | Parameters | Returns | Model |
|---|---|---|---|
windows.list |
application (optional) |
{windows: [{window, application, scope, for_application, modal, transient_for, blocked_by, xid, title, class, instance, pid, owner, type, x, y, w, h, active}], partial, reasons, cursor, serving, blocked_by, unresolved_blockers} (serving, blocked_by and unresolved_blockers only with application, and absent when empty; a row’s blocked_by absent when nothing blocks it) |
No |
windows.wait |
since (the cursor from windows.list) and timeout_s (required); exactly one of appear (application, for_application, title, class, type, all optional) or gone (a window reference) |
{matched, elapsed_ms, window, cursor} |
No |
windows.activate |
window (required); probe |
{window, active, confirmed_by, reason, frame} |
No |
windows.close |
window (required); timeout_s (default 2, at most 30) |
{window, status, method, elapsed_ms, cursor, row, reason} |
No |
windows.move_resize |
window (required); at least one of x, y, w, h |
{window, method, x, y, w, h} |
No |
- These methods need the X11 display.
windows.listgives each window awindowreference, which lasts until the window is closed (null when the window could not be watched), and its owner’sapplicationreference, the same referencesapps.listanddom.targetsuse, so an agent can tell which application a window or a page belongs to. The owner is taken from the X server’s own record of which program created the window (owner: x-resource). A window’s own claim to a process (owner: claimed) is shown inpidbut gives no reference.typetells an application’s windows (normal,dialog) from the desktop’s own (dock,desktop). Titles are redacted.scopeis the window’s accessibility frame oncewindows.activatehas mapped it, whicha11y.listanda11y.treetake.for_applicationis the application the window serves through its transient parent, as a file chooser serves the application that opened it. Withapplication, only that application’s windows are listed, and windows other programs show for it are listed apart underserving.partialandreasonssay when part of this could not be read.modalsays the window is marked modal (_NET_WM_STATE_MODAL), andtransient_fornames the window it belongs to (itsWM_TRANSIENT_FOR), as a file chooser belongs to the window that opened it. A row’sblocked_bylists the modal windows that block it. Withapplication,blocked_byandunresolved_blockersare that application’s modal blockers as seen on X; see the modality rule under a11y.windows.listalso returns acursor. Pass it towindows.waitassince: list, act, then wait, and a window that opened between the action and the wait still matches.appearmatches a window that opened after the cursor and meets every field given:applicationis the window’s owner,for_applicationthe application it serves through its transient parent (a file chooser serves the application that opened it),titlea substring,typedialog,normal, orpopupfor a menu or tooltip.gonematches the window being destroyed. A timeout ismatched: false. While it waits, no other call runs.- A toolkit can open a popup of its own before the one you want: on a right click LibreOffice opens a 10x10 popup off the screen, then its menu. Check the matched window’s position, and wait again from the returned
cursorif it is off the screen. - Qt hides a menu it closes and keeps the window, so
gonedoes not match a closed Qt menu. Takescreen.markbefore closing it and usescreen.waitchanged. windows.activateraises and focuses the window, then reads back which window is active:active, andconfirmed_byactive-window,pid(another window of the same application, such as its own dialog) ornonewith areason. It does not route input: keys go to whatever has the focus.frameis the window’s accessibility frame. While none is known for the window, the raise also maps the window to its frame:status: exactwith ascope, shown from then on bywindows.list, orunknownwith the reason. Measured on GTK3 applications and LibreOffice the mapping is exact; Qt applications such as VLC, and Wine applications, report no activation over the accessibility bus, so it staysunknown. A window that is already active cannot be mapped;probe: trueactivates another window first, which a person watching sees, and a session with a single window has no other to use.windows.closeasks the window to close, never kills it, and waitstimeout_sfor it to go.statusisclosed;pendingwhen it is still there, usually because the application is asking to save: wait for the question withwindows.waitfrom the result’scursor; orrefusedwhen the window cannot be asked and no window manager closed it. Measured: a LibreOffice drawing and a GIMP image with changes returnedpendingand their question matched at once; windows with nothing to save closed in under 200 ms.windows.move_resizereturns the geometry read back, which is what the window manager allowed. A maximised window does not move or resize under the Kasm images’ window manager; the result says so by returning the unchanged geometry.
| Method | Parameters | Returns | Model |
|---|---|---|---|
input.key |
chord (string, required), e.g. "ctrl+s" |
"pressed <chord>" |
No |
input.click |
x, y (integers, required): root-window pixels; optional button (left, middle, right), count (1 to 3), modifiers (ctrl, shift, alt, super) |
"clicked (x, y)" |
No |
input.move |
x, y (integers, required) |
{x, y} |
No |
input.drag |
from, to ({x, y}, required); optional button, modifiers, steps (2 to 200, default 10), hold_ms |
{from, to, steps, button, modifiers} |
No |
input.scroll |
x, y (integers, required); dy, dx (-50 to 50, one non-zero) |
{x, y, dy, dx} |
No |
input.type |
exactly one of ref or text; optional keystroke_ms, key_hold_ms |
"typed N character(s)" |
No |
input.cursor |
none | {cursor} |
No |
input.wait_for |
exactly one of text, key or click; optional since, timeout_ms, origin |
{matched, captured, events, cursor, dropped} |
No |
input.key,input.click,input.move,input.drag,input.scrollandinput.typeneed the X display (resolution error without it). An input the X server does not accept, or a point off the screen, is a resolution error. A non-integer or out-of-range number is malformed.input.clickpressescounttimes, each press, release and next pressclick_msafter the one before (so presses are twiceclick_msapart), withmodifiersheld around the clicks and released in reverse; its result names what is not the default ("clicked (10, 20): right, x2, ctrl+shift").input.moveadds no pause.input.dragmovesstepstimes along the line,drag_step_msapart, and releases atto.input.scrollturns the wheel in notches: negativedyup, positive down, negativedxleft, positive right. A cancelled click, drag or scroll still releases its button and modifiers.- Measured on LibreOffice, GIMP, VLC and Notepad++ under Wine: a double click selected the word under the pointer, in LibreOffice and under Wine; a drag drew and then moved a shape in LibreOffice Draw by exactly the distance dragged, painted in GIMP, and selected lines under Wine; three notches of
input.scrollmoved GIMP’s canvas; a shift-click drew GIMP’s straight line; andinput.moveonto a GIMP tool showed its tooltip half a second later. A right click opened the context menu in all four. input.typerecords only the length of what it typed. See ref or literal.input.typetypes one key per character: each key is heldkey_hold_ms(default 15) and the next pressedkeystroke_ms(default 30) after its release, so a character takes about 45 ms and 2,000 characters about 90 s. A call can set either:keystroke_msfrom 0 to 1000,key_hold_msfrom 0 to 249. A hold of 250 ms or more is malformed, because X repeats a key held past its autorepeat delay, which is 250 ms on some desktops. The operator’s defaults aretiming.input.keystroke_msandtiming.input.key_hold_ms.input.cursorandinput.wait_forneedKASM_RUNTIME_OBSERVE_INPUT=true. Without it they return a resolution error saying so.input.wait_forwaits for input the session receives from any source, the Kasm viewer included.clickis{button, x, y, radius}:buttondefaults to 1,radiusto 0, and leaving out bothxandymatches anywhere.timeout_msdefaults to 5000, at most 60000.originisexternal(the default: not the runtime’s own input),runtime(clicks only) orany.- On timeout
input.wait_forreturnsmatched: falsewith what was captured, without an error. Takeinput.cursorbefore acting and pass it assince, so input that arrives before the wait begins still matches.
clipboard
Section titled “clipboard”| Method | Parameters | Returns | Model |
|---|---|---|---|
clipboard.get |
none | {text, bytes} |
No |
clipboard.set |
exactly one of ref or text |
{bytes} |
No |
- Both need the X11 display.
clipboard.setholds the text until another application copies something or the session ends; paste it withinput.keyctrl+v. That is much faster thaninput.typefor long text, and safer for text with line breaks, which an editor’s completion can take. clipboard.getreads what an application copied, soctrl+cthenclipboard.getreads back text from an application with no accessibility tree. Measured with LibreOffice and with Notepad++ under Wine, in both directions. A Windows application copies line breaks as CR LF.textis redacted like everything the runtime returns;bytesis the clipboard’s own length. Neither method records the text in the report, only its length. The runtime reads the clipboard only whenclipboard.getis called.
Processes
Section titled “Processes”| Method | Parameters | Returns | Model |
|---|---|---|---|
proc.list |
match: substring of /proc/*/cmdline, "" for all |
the matching processes | No |
proc.spawn |
cmd (string, required) |
"spawned" |
No |
proc.kill |
match (required): a case-sensitive POSIX extended regular expression |
"sent" |
No |
launch |
cmd (required), env (object of strings, optional) |
"launched" |
No |
shell |
cmd (string, required) |
combined stdout and stderr | No |
wait_while |
kind (growing or process) and timeout_s (required); path or match; poll_s (default 0.5); quiet_polls (default 3) |
"quiesced" |
No |
- Processes start detached, as the session user.
launchalso records the process as the session’s launched app. launchandproc.spawnrefuse a command whose program is an installed application’s own, once both are resolved throughPATHand symlinks (a name alone never matches), and the error names theapps.startcall to use, with the command’s URL whenapps.starttakes it. The application’s launcher supplies its desktop and runtime settings, such as a browser’s password store and debugging endpoint, which a command built from the program skips. A command through the launcher itself, and a program no entry runs, start as before. This guides an agent; it is not a boundary, sinceshellruns anything.- A command that cannot start is an environment error. A
proc.killpattern that does not compile is malformed. shellruns a command line withsh -cto completion and returns stdout and stderr together. Underkasm-session-runtime mcpit has no time limit of its own unless the operator set a maximum session lifetime, so give a slow command its owntimeout. The output is cut atevidence.shell_output_chars(see the operator file) and registered secrets are removed from it. A nonzero exit is a resolution error that carries the output;shfailing to start is an environment error. A call holds the session’s one-call-at-a-time lock until it returns.wait_whileholds until a growing file or directory stops changing size, or no process matches, forquiet_pollssamples in a row. Iftimeout_spasses first, it is a resolution error.growingneedspath;processneedsmatch.
Applications
Section titled “Applications”The first two methods let an agent find out what the session can run and start it by name, with nothing told in advance. The catalogue is the workspace’s own application menu: one row per desktop entry, settings panels included, with its description, categories and the URL schemes it handles, plus the ways it can be driven once it runs.
| Method | Parameters | Returns | Model |
|---|---|---|---|
apps.list |
application (optional); include ("all", optional) |
{applications: [{name, source, profile, state, application, instances, display, generic, description, categories, schemes, drive, actions, registrations, pages, windows, scopes, related_surfaces, backends, blocked_by, unresolved_blockers}], unassociated, partial, reasons, hidden?} |
No |
apps.start |
name (required); action, url, timeout_s (default 20) |
{name, outcome, state, application, registrations, windows, waited_s, reason} |
No |
apps.handoff |
handoff (required): the token a mutation’s data.handoff gave; timeout_s (default 5, at most 30) |
{handoff, kind, status, surfaces, reason, origin_application, origin, origin_window, elapsed_ms, expires_in_s}: the handoff as it stands now |
No |
nameis the entry’s own identifier, such asgoogle-chromeorslack, and is whatapps.starttakes.registrationsare the namesdom.targetslists the application under once it runs; an agent recognises the registration that appears after a start from this field, not fromname.driveis a set ofcdp,accessibilityandscreen: how the application can be driven once it runs.screenis always there. On a workspace built with the launcher the set comes from what the image says about the application; elsewhere it is inferred from the entry’s categories.- Without
application, desktop settings panels (entries in theSettingscategory) that are not running are left out and counted inhidden;include: "all"lists them. A desktop image can carry over fifty, and a full listing grew past what an agent’s client shows it. A row for an application that is not running leaves out the fields that describe a running instance (instances,registrations,scopes,related_surfaces,backends,blocked_by,unresolved_blockers); on a running row an empty list means none. stateisinstalled,startingorrunning.runningneeds evidence: a registration that validates, or a window owned by the application’s program.startingis a start whose evidence has not arrived yet.- A running application’s row also has
scopes, its top-level accessibility windows, whicha11y.listanda11y.treetake asscope;related_surfaces, the dialogs other programs show for it and any accessibility tree only suspected to be its; andbackends, whethercdp,accessibilityandx11are available for it now, with the reason when not.blocked_bylists the modal dialogs that block it now andunresolved_blockersthe ones that may, each with its evidence; see the modality rule under a11y.partialis set when the accessibility bus was asked and failed, not when the scenario setsatspi: falseor the session has no session bus; theaccessibilitybackend says that. apps.startruns the entry’s own command, withurlin the place the entry leaves for one and nothing else substituted; it never composes a command. A URL whose scheme the application does not handle is malformed, withhttpandhttpsallowed for a browser, and afile:URL of a local path for an application whose entry lists a file type.startingis not a failure: callapps.listordom.targetsagain. Starting an application that already runs hands over to the running instance.- A running application no entry describes, such as one started from a shell, is listed too, from its registration or its window, with
sourcesaying which. Registrations that do not validate, and windows with neither an owner nor a class, go inunassociated, with reasons; a registration there also says itsprotocol. apps.handofflooks again at a menu or dialog an action was asked to watch for (see handoff), without repeating the action. A token lasts 60 seconds after the call that made it; after that, or for a token never given, the call fails and says to look withapps.listorwindows.listinstead.- An entry that wants a terminal says
terminal: true;apps.startrefuses it, since the runtime opens no terminal. Useshellfor such programs. display,genericanddescriptionare redacted like titles. Without the X11 display the windows are not read, andpartialsays so.
These methods act on the pages of the browsers and Electron applications a session runs, over the Chrome DevTools Protocol (CDP). None needs a model.
Every call names what it acts on. dom.targets lists the applications the runtime knows, each with its pages and a page reference for every page. The other methods take a page reference, or an element handle from dom.list_interactive, which carries its page. There is no current tab and no default: a call that names neither is malformed, even when only one page exists.
| Method | Parameters | Returns |
|---|---|---|
dom.targets |
none | {registrations: [{name, protocol, available, reason, hint?, generation, browser, profile, pages: [{page, target_id, type, title, url, application, window, window_relation, dialog?, fedcm?}]}], registry_dir, note?} |
dom.navigate |
page, url (both required), timeout_s |
{identity, data: {outcome, verification, url, kind, http_status?, download?}}: the URL reached, whether a new document committed or the response became a download, and the response’s HTTP status |
dom.url |
page (required) |
{identity, data: {url}} |
dom.query |
page, selector (CSS; both required) |
{identity, data}: the element’s tag, attributes, text, visibility and enabled state |
dom.read_text |
page, selector (CSS; both required); max_chars (default 4096, at most 65536); offset; snapshot (required with a nonzero offset) |
{identity, data: {text, total_chars, offset, truncated, next_offset?, snapshot}}: the section’s text |
dom.xpath |
page, expressions (1 to 32 XPath 1.0 strings, each at most 2048 characters; both required); root (CSS selector for one element); max_nodes (default 20, at most 100); max_chars (default 4096, at most 16384) |
{identity, data: {observation, xpath_version, main_document_only, results: [{index, kind, value?, truncated, nodes_truncated, text_truncated, total_nodes?, error?}]}}: one ordered entry per expression |
dom.list_interactive |
page (required), filter (case-insensitive substring of the name) |
{identity, data: {elements: [{handle, role, name, disabled}], truncated, hint, total}} |
dom.click |
element, or page with selector; button (left, middle or right); dispatch (input or script); expect; handoff |
{identity, data: {outcome, verification, element, method, button, at}}; with dispatch: script, method is HTMLElement.click() and there is no button or at; with handoff, also handoff |
dom.click_described |
page, description (both required); expect |
the same |
dom.fill |
element, or page with selector; exactly one of ref or value; dispatch (input or script); keystroke_ms; key_hold_ms; expect |
the same, with method, chars (the value’s length in characters), typing and field |
dom.key |
key (required); element or page; expect; handoff |
the same |
dom.type |
text or ref; element or page; dispatch (input or script); keystroke_ms; key_hold_ms; expect |
the same, with method, chars and typing |
dom.hover |
element, or page with selector; expect |
the same, with method and at |
dom.scroll |
element, or page with selector; or page with dy and dx (CSS pixels); expect |
the same, with method, and for a wheel at and scroll |
dom.set_files |
element, or page with selector; paths (required); expect |
the same, with method and files |
dom.dialog |
page, accept (both required); text or ref, for a prompt; expect |
the same, with method and dialog, the dialog answered; with an answer, chars |
dom.fedcm |
page (required); id, the fedcm.id the answer is for; exactly one of account (an index), button (continue, got_it or more_details) or dismiss: true; expect |
the same, with method and fedcm, the dialog answered |
dom.wait |
page, predicate (JavaScript boolean; both required), timeout_s |
{identity, data: {holds, elapsed_ms}} |
dom.attach |
page (required), raise |
{identity, raise?} |
dom.register |
name, profile (both required), pid |
{name, revision, replaced} |
dom.unregister |
name (required) |
{name, removed} |
Where the applications come from: on a nix image, every browser and Electron application of a runtime-driven session is listed under the name of its nix profile, such as chrome or slack. A browser started on a fixed debugging port, such as 9222 from APP_ARGS, is the registration named default, at KASM_RUNTIME_CDP_ENDPOINT. On a nix image that endpoint is the port APP_ARGS fixes, and absent when they fix none; elsewhere it is http://127.0.0.1:9222 unless set. An application you started yourself is added with dom.register, naming the profile directory it writes its DevToolsActivePort file in. dom.targets reads everything afresh on each call: call it first, and again after an application opens, restarts or closes.
dom.read_textreads the text of one section of a page, for prose too long fordom.query. It changes no focus, selection or clipboard. The selector searches the document and then open shadow roots. Form values, hidden content and regions declared sensitive are left out, block boundaries become newlines, and generated text and nested frame or shadow contents are not included. Counts are in Unicode code points. Whentruncatedis true, call again withoffsetset tonext_offsetand the previoussnapshot; if the document or the section changed in between, the call is refused. A section too large to read is refused; narrow the selector.dom.xpathevaluates up to 32 XPath expressions against one sanitized, detached copy of the page’s main document, in one pass. It works on CDP pages only and does not look into frames or shadow roots.root, when given, must match exactly one element, and an absolute path cannot leave it. Node text is the document’s text, not what is rendered. A link also returns itshref, whole or not at all withinmax_chars. Form controls, scripts, styles and hidden or sensitive regions are removed. Attributes are limited toid,class,role, thearia-label,aria-labelledbyandaria-describedbyattributes,alt,title,lang,dir,type,href,datetime,rel,componentkeyand the test-id attributesdata-testid,data-test-id,data-test,data-qaanddata-cy; hrefs keep the HTTP(S) path with no credentials, query or fragment.max_charsis one budget across an expression’s nodes in document order: the node where it runs out is cut and markedtext_truncated, later nodes are left out (nodes_truncated, withtotal_nodescounting every match), and no node comes back with empty text. A bad expression is reported in its own entry’serror; an oversized capture fails the call, so narrowroot. The response is at most 64 KiB.- Page read and mutation results carry
identitybeside theirdata: thepagethe call resolved to, the application’sname, itsgeneration, the CDPtarget_id, and the page’stitleandurl, read after the action for a mutation. A call that could not resolve its page reports no identity. - A reference belongs to one incarnation of its application. When the application restarts, its registration is replaced or removed, or the page closes, the reference is retired: the call fails before anything is sent, says why, and asks for a fresh
dom.targets. A retired reference never becomes valid again. - A handle names one element in one document. It is never matched by text: after a navigation the handle is stale and the call fails, naming the cause; list the page again.
dom.click_describedmatches the description against the listing’s names, exact first and then a unique substring. No match and more than one match are both errors that list what is on the page, with handles, and nothing is clicked. - An unfiltered listing of a page with more than 100 interactive elements is withheld, with a hint to pass
filter. With a filter,totalcounts the matches. outcomesays whether the action was dispatched:performed,not_performed, oroutcome_unknownwhen it was sent and the connection failed before the answer, in which case look at the page before repeating it.verificationis a separate claim about the effect:held,failed,unreadable, ornonewhen nothing was checked.dom.fillreads the field back,dom.typecompares the text before and after,dom.set_filesreads the input’s files back, anddom.click,dom.key,dom.hoveranddom.scrollhave no check of their own.expect, a JavaScript predicate with an optionaltimeout_s, adds a check of yours to any of them.dom.keyanddom.typereach the page over CDP, whether or not its window has focus on the desktop. Withelement, the element is focused first, and the call is refused with nothing sent if focus did not land on it. Withpage, the page’s focused control gets the input.- Typing.
dom.fillanddom.typetype their text one key per character over the browser’s debugging protocol, as a person types it: for each character the page sees a trustedkeydown,keypress,beforeinput,inputandkeyup, and its own key handlers,maxlengthand focus moves apply. A capital or a shifted symbol is typed with Shift held. A line break is the Enter key, which types a new line in a textarea or an editor and submits a form’s single-line input. A tab is the Tab key, which moves focus to the next control. Accented letters, other scripts and emoji are typed as keys too (measured on Chrome 154 and Firefox 156). Any other control character is malformed, with nothing sent. The pacing isinput.type’s:key_hold_msandkeystroke_ms, settable per call. The call’s time limit grows with the text, so a long text is not cut short.methodisInput.dispatchKeyEvent, orinput.performActionson abidipage. dom.fillsets a field to exactly the value. It focuses the field, clears it with Ctrl+A and Backspace if it holds text, types the value, and reads the field back. A read-only field, or one that does not take focus, is refused with nothing sent, and so is a value with a tab (its key would move focus to the next control) or a value with a line break for a single-line field (its Enter would submit the form). A page that formats or limits what is typed may leave the field different from the value: a card number grouped in fours, amaxlength, or a one-time-code box that moves focus to the next box as each digit arrives. The fill is stillperformed, andfieldsays what the field holds:matchesis whether it shows exactly the value, andlengthis its length in characters. The value and the field’s text never appear in a result.verificationisheldwhen the field could be read back, whatever it shows; checkfield.matches, or passexpect, when the exact value matters. A select, and a date, time, colour or range input, are not typed: their value is set directly, withmethodvalue setter.dom.typenever clears. Withpage, or anelementthat has focus, the text goes where the caret is, and a selection is replaced. Anelementwithout focus is focused and End pressed first (Ctrl+End in a textarea or an editor), so the text goes at the end;typing.movednames the key.typingin the result:typedandofare the characters typed as keys and the text’s length, counted ascharsis (a carriage return and line feed are two),keystroke_msandkey_hold_msthe pacing used,clearedthatdom.fillcleared the field first.- A page dialog that opens while typing (from a key handler) stops it: the call is
performed, its verificationunreadableand naming the dialog, andtyping.typedsays how many characters went in before the key that opened it. A key handler can put what was typed into its dialog, so while that dialog is up its message is reported only by its length, everywhere the dialog appears. dispatch: scriptondom.fillordom.typeuses the earlier way instead:dom.fillsets the value through the field’s value setter with untrustedinputandchangeevents (methodvalue setter), anddom.typeinserts the whole text at once (Input.insertTexton Chrome, a burst of keys on Firefox). A page can tell either apart from typing.- In
dom.targets, an unavailable registration of an installed application has ahint. With none of the application’s windows open, it is theapps.startcall that starts it through its launcher. With a window open, it says the application runs but its endpoint does not answer: it may still be starting, or it was started without the launcher, andapps.startwould not change that. Without a complete window list there is no hint. - In
dom.targets,protocolis what an application speaks on its debugging port:cdpfor Chromium-family browsers and Electron applications, orbidi(WebDriver BiDi) for Firefox. A record that says nothing iscdp. The fixed endpoint,default, is detected each time, so a Firefox started with--remote-debugging-port=9222isdefaultwithprotocol: bidi. - The
dom.*methods work the same on both, with two differences. Abidipage has no accessibility tree, sodom.list_interactiveanddom.click_describedfail there as environment errors, and there are no element handles: usepageandselector. And a mutation’smethodnames the BiDi command (input.performActions,input.setFiles,browsingContext.navigate,browsingContext.activate) where a Chromium page names the CDP one. - Firefox’s first page,
about:home, accepts onlydom.navigate: navigate somewhere first. - In
dom.targets, a page’sapplicationis the browser process behind it, as an application reference thatwindows.listandapps.listalso use. It is null when the runtime cannot confirm which process serves the page, such as for a remote endpoint. Itswindowis null and itswindow_relationisunknown: which of the browser’s windows shows the page is not established. Do not infer desktop focus or window ownership from a page title. dom.attachis never a prerequisite; every other method connects on its own. Withraise: trueit brings the page’s window to the front for a person watching, andraisesays whether the browser was asked and whether the desktop’s active window then belonged to the page’s application (confirmed: process), or nothing confirmed it (none, with the reason).- An application must have a debugging port. On a nix image whose launcher registers what it starts, every browser and Electron application has one. Elsewhere, the browser must be started with
--remote-debugging-portand a--user-data-dir(see Compatibility); a browser without one is listed as unavailable, with the reason. - An endpoint must be a loopback address unless
KASM_RUNTIME_CDP_ALLOW_REMOTE=true. - Selectors and shadow roots. A
selectorsearches the page’s own document first, then each open shadow root of a web component, depth-first in document order, and names the first match. It never names two elements, and a match in the page’s own document always wins. A selector matches within one tree:x-card #savedoes not reach a button insidex-card’s shadow root, so name the element by a selector that holds inside its own tree, such as#save. A closed shadow root cannot be searched by page script at all, so no selector reaches into one. A miss names the defined custom elements that show no open shadow root, as places a selector cannot search; a hyphenated tag the page never defined, such as a framework’sapp-root, is a plain element and is not named; on a Chromium pagedom.list_interactivelists the controls inside a closed root as handles. Apredicateindom.waitorexpectis your own JavaScript and runs as written:document.querySelectorthere searches only the page’s own document. http_statusindom.navigate’s result is the HTTP status of the response the new document was made from, after any redirects, as the browser’s own network events report it;urlis then the URL the redirects ended at. It is left out when it is not known: a same-document navigation (a fragment change) loads no document, andabout:blankhas no response. Chrome 154 and Firefox 156 both report adata:URL as 200. Firefox 156 reports 304 for a page it revalidated and then showed from its cache. A status of 400 or more is not an error: the navigation isperformedand the page that loaded is the server’s error page, so checkhttp_statusbefore reading the page as the one you asked for. A navigation that becomes a download (kind: download) reports the status of the response that became the file, as both browsers report it.- A missing parameter, or
elementcombined withpageorselector, is malformed. An element that is not found, a predicate that does not hold beforetimeout_s, and a navigation the browser refuses are resolution errors. - While a modal dialog blocks the page’s application, every method here that changes the page (
dom.click,dom.click_described,dom.fill,dom.key,dom.type,dom.hover,dom.scroll,dom.set_files,dom.navigate) fails asnot_performedand sends nothing, as the a11y modality rule says: the browser itself would let the click through behind a file chooser. Reads still work. - Page dialogs. A page’s own
alert,confirm,promptor “Leave site?” dialog is reported asdialog: {type, message, default_value?, controls?}. It appears in the page’sidentityon every result and on the page’s row indom.targets.controlsare the dialog’s buttons, and a prompt’s entry, as the browser’s accessibility tree lists them:{handle, role, name}, wherea11y.actiontakes the handle.- While a dialog is up: every method that changes the page is refused, with nothing sent. The refusal names the dialog and says how to answer it:
dom.dialog, or as a person would, whereinput.keyEscape dismisses it and Return accepts it, typing withinput.typeanswers a prompt, ora11y.actionpresses a button. - Answering it with
dom.dialog:accept: truepresses OK (or Leave),falseCancel (or Stay). A prompt’s answer istext, orreffor a scenario-provided value; it is never echoed back, andcharsis its length. The answer goes over the browser’s protocol, so nothing reaches the desktop and the modality rule does not apply. Verification isheldwhen the browser reports the dialog closed as asked,failedwhen it reports it closed otherwise or it is still up, withobservedsaying which. With no dialog up, ortextfor anything but a prompt, it is refused with nothing sent; a dialog that closed some other way just before is refused by the browser and reportednot_performed. - Reads: Chrome answers nothing on the page until the dialog closes, so reads fail at once the same way. Firefox keeps answering reads. The exception is a dialog that was already up before the runtime first connected to the page: Chrome then answers nothing on the new connection, so calls fail after 5 seconds, saying a dialog is the likely cause and naming its buttons when the accessibility tree shows it. Only the desktop answers that dialog. See the known issues.
- A dialog that opens during a call: the call ends at once, naming the dialog. A click whose handler calls
confirm()isperformed, withverification: unreadable. Anexpector a navigation’s wait ends the same way, and so does a navigation that a “Leave site?” dialog holds. - Frames: a dialog opened by a frame inside the page, cross-origin or not, is the page’s dialog on both browsers.
- Answering: the runtime never answers a dialog on its own.
- While a dialog is up: every method that changes the page is refused, with nothing sent. The refusal names the dialog and says how to answer it:
- A navigation that becomes a download. When the URL’s response is a file to save, such as one sent as an attachment,
dom.navigatereturnsoutcome: performedwithkind: downloadanddownload: {suggested_filename}, the name the browser proposed. No new document commits, and the page stays on its current URL. Take adownloads.listcursor before navigating and wait for the file withdownloads.wait(see Downloads). Chrome reports it in its answer to the navigation and Firefox in an event just before; both were measured on Chrome 154 and Firefox 156. - Federated sign-in (FedCM). On Chrome, a page’s “Sign in with …” prompt or
navigator.credentials.get({identity})opens the browser’s own account chooser. It is drawn by the browser, so the page’s DOM does not contain it. While one is up, the page’sidentityand its row indom.targetscarryfedcm: {id, type, title, subtitle?, accounts: [{index, email, name}]}.typeisaccount_chooser,auto_reauthn(the browser signing a returning account in by itself),confirm_idp_login(sign in to the provider first),error, orotherfor a type the runtime does not know.- The page is not blocked: reads and input keep working while the chooser is up, and the page’s sign-in request waits for an answer.
- Answering it with
dom.fedcm:accountsigns in with that account, by itsindexfromfedcm.accounts.buttonpressescontinueon aconfirm_idp_logindialog, orgot_itormore_detailson anerrordialog.dismiss: truecloses the dialog without signing in, and the page’s request is rejected. Passidwith thefedcm.idyou read the accounts from: the order of the accounts can change from one chooser to the next, and an answer whoseidis not the dialog up is refused with nothing sent. The answer goes over the browser’s protocol, so nothing reaches the desktop. Verification isheldwhen the browser reports the dialog closed. It isfailedwhen the dialog is still up, or when the browser shows its error dialog in place of the chooser after an account was chosen (the provider refused the sign-in);observedsays which. With no dialog up, anidfor another dialog, an index out of range, or a button the dialog does not have, it is refused with nothing sent. - Firefox: Firefox does not support FedCM. The page’s request is rejected at once, so no chooser opens, and
dom.fedcmis refused with nothing sent. - From the desktop: the chooser is also in the browser’s accessibility tree, as a scope named by its title with one button per account. Pressing an account with
a11y.actionworks, and so does a person’s click, while the runtime is connected to the page. An account new to the site then needs a second press on “Continue as …”.
dom.clickanddom.click_describedscroll the element into view and press and release the button (leftby default) at its centre over the browser’s debugging protocol, so the page receives the click as a person’s: trusted, with the pointer and mouse events before it, and with user activation.atis the point, in CSS pixels of the page’s viewport. The point is read from the element itself, so the screen’s resolution and the page’s scrolling do not move it. The click is refused, with nothing sent, when the pointer would miss the element: something covers its centre (the error names it; the element’s own label on top counts as the element, unless a link or button inside the label is at that point), it is not displayed, it is inside a closeddetails, it is an option of a closed select (set the select’s value withdom.fill), or it haspointer-events: none. A right click on a page that does not handle it opens the browser’s own context menu. The point is right at a browser zoom other than 100% (measured at 125% and 150% on Chrome 154, device scale factor 1): the event reached the element at the point given.dispatch: scriptondom.click(left button only) calls the element’s ownclick()in page script instead. The page can tell it apart: itsisTrustedis false, and no mouse events come before it. It has no user activation, so what needs one may not open: on Chrome, neither a file chooser nor a popup does. Use it only when that is what you want.- A click whose own handler opens the page’s
alert,confirmorpromptisperformedat once, and the result’s identity carries thedialog. Neither browser answers the click’s own command while that dialog is up, so its verification isunreadable, and the reason names the dialog and how to answer it. A dialog that opens as the pointer moves onto the element (from a hover handler) stops the click before its button: it isnot_performed, and the error names the dialog. dom.hovermoves the page’s pointer to the element’s centre over CDP; the desktop’s pointer does not move. A right or middle click and a hover are refused, with nothing sent, when the element has no size, is outside the viewport after scrolling, or has another element over its centre, since that element would get the event instead. A disabled element can be hovered and not clicked.dom.scrollwith an element scrolls it to the middle of the view. Withdyordxit sends one mouse wheel at the centre of the viewport, which scrolls whatever is under that point; positivedyscrolls down, and each is at most 10000. The result says what was sent, not how far the page moved.dom.set_filessets the files of an<input type=file>without opening a file chooser. Upload buttons usually hide their input, sopagewithselector: "input[type=file]"is the common form. Each path is~/<path>or/tmp/<path>and must be an existing file there, so upload it first withPUT /v1/files/; anything outside the home directory and/tmpis malformed and a missing file is a resolution error, and neither reaches the page. The input is read back: its file names must be the paths’ names. At least one path is required, so an input cannot be emptied this way.dom.set_fileschecks the files when it is called, but the browser opens them later, by name, when the page reads or submits them. So the method also refuses a symbolic link anywhere on the path, and any file or directory on it that another user owns: either could be swapped for a link to another of your files, such as an SSH key, between the check and the upload.- The first
dom.set_filescall on a page also stops the page’s own file chooser from opening, for anyone, while the runtime stays connected to that page. It ended whendom.unregisterclosed the runtime’s connection to the page, and a reload does not end it; a retired page, a lost connection or a stopped runtime close the same connection and are expected, not measured, to end it too. While it lasts, a click on the upload control does nothing the page can see: no chooser opens and the input fires neitherchangenorcancel, so a page that waits for the chooser’s outcome keeps waiting. Both were measured on Chrome 154. - These methods return page content as read. Registered secret values are removed from titles, URLs and element names, in identities, listings, results and errors, as from everything the runtime writes; nothing else is redacted. The text and attributes a query matches, and anything personal or sensitive the page shows, reach the caller as the page presents them. Grant
dom.*on an application on the assumption that the caller can read what a person signed in to it sees; see Secrets and evidence.
These methods use the application’s accessibility tree over AT-SPI. They need no model.
| Method | Parameters | Returns |
|---|---|---|
a11y.list |
exactly one of application, window or scope; filter (optional) |
{identity, data: {elements: [{handle, identity, role, name, window_title, window_active, states, description, text, text_truncated, editable, password, value, min, max, actions, blocked_by}], total, partial, unavailable, scopes, modal_scopes, dialogs, candidates, blocked_by, unresolved_blockers}}: the controls of what you named, read fresh |
a11y.tree |
exactly one of application, window or scope |
{identity, data: {scopes: [{scope, kind, name, parent, ..., elements: [...]}], nodes, partial, unavailable, dialogs, candidates, modal_scopes, blocked_by, unresolved_blockers}}: the same read, grouped by the windows, dialogs and open menus it found |
a11y.action |
element (required): a handle from a11y.list; action (one of the control’s actions); expect_state; expect_value (boolean, default true); allow_pointer (boolean, default false); handoff |
{identity, data: {outcome, verification, method, dispatch, element, at, verified_by, windows_opened, message, handoff}} |
a11y.set_text |
element (required); exactly one of text or ref |
as a11y.action: the field’s whole text replaced and read back into verification (a password field by length only) |
a11y.set_value |
element (required); value (required, number) |
as a11y.action: a slider or spin button set within its own range, read back |
a11y.select |
element (required) |
as a11y.action: a list, tree, tab or combo-box item selected through its container, read back |
a11y.read_text |
element (required): a native handle (a_...); max_chars (1 to 65536, default 16384) |
{identity, data}: a prefix of the element’s text, with whitespace kept and truncation reported |
a11y.wait |
exactly one of application, window or scope with appear: {role, name} (name optional); or element with state and value (boolean, default true); timeout_s (default 5, at most 30) |
{identity, data: {matched, element, scope, matches, elapsed_ms, timed_out, reason, reads, events, partial, unavailable, modal_scopes, blocked_by, unresolved_blockers}}: what appeared, or the state reached |
- Name exactly one thing to read.
applicationis anapp_reference fromapps.listorwindows.list;windowaw_reference fromwindows.list;scopeans_reference for one window, dialog or open menu, fromapps.list,windows.listor an earlier listing. There is no default application, and none is guessed from the scenario or the focused window. applicationreads only what that application’s own process publishes. A helper process’s tree, or one whose owner cannot be confirmed, is listed undercandidateswith its scopes and not read; you can still read it by itsscope. A dialog another program shows for the application, such as the desktop’s file chooser, is linked underdialogsand never mixed into the application’s controls.windowreads the window’s accessibility frame, which is known only afterwindows.activate(ordom.attachwithraise) has mapped it. Until then the result isunavailablewith the reason.- Every listed control has its own
handle(a_...) andidentity: theapplication, thescopeit sits in, thewindowwhen that scope is mapped to one, andfor_applicationwhen that window serves another application. A scope row says itskind(frame,dialog,menu,popup,window), its parent, itsowner, itswindowwithrelationandevidence, and itsoperations. - A handle and a scope name one object exactly, including when two controls or two menus share a name. When the object closes, its menu closes, its application exits or restarts, or the accessibility service restarts, the reference stops working with the reason, and the session never gives it to anything else. A same-named control that appears later has its own handle. References do not carry over to a new session.
- The mutations take
elementand nothing else: no name, no window title, and noapplication,windoworscopebeside it. Adom.*handle (e_...) is refused before anything is sent, and so is ana_handle passed to adom.*method. - Modality. Neither the accessibility service nor the browser stops an action behind a modal dialog, so the runtime refuses it, for
a11y.*anddom.*alike. A dialog blocks an application when it is one of the application’s own modal windows, or when it is marked modal and belongs (transient_for) to one of the application’s windows, whichever program shows it: the desktop’s file chooser blocks the browser that opened it. Such a dialog blocks the window it belongs to; when the runtime does not know which window an action would land in (a page whosewindow_relationisunknown, a control whose windowwindows.activatehas not mapped), any dialog blocking the application blocks the action. A modal window of the application’s own that belongs to no window, or one in a tree only suspected to be its, is listed underunresolved_blockersand blocks only where the window is not known. A dialog an application shows itself that its accessibility tree does not mark modal (Qt’s, as in VLC) blocks its pages, but its controls only whenwindows.activatehas mapped their window, since the tree cannot say which controls are in the dialog. A modal window of no known program blocks nothing. Inside the dialog, and for reads, nothing is blocked;input.*is never blocked. - Controls blocked this way carry
blocked_by(the dialog’sscope, or itswindowwhen no scope is known for it), and the mutations refuse them, asnot_performed: blocked by a modal dialog, until it closes.modal_scopeslists the modal dialogs up now, including one with no controls.blocked_byandunresolved_blockerson the result list the application’s blockers with their evidence, asapps.listdoes. The refusal’s detail (blocked_by, the blockers, whether the window was known, and which check refused) is in the error’s data; the report’s step row records it too. When the modal state cannot be read with a display there (the window watcher failed), or a page’s browser listens on this machine but its process could not be established at the call, the mutation is refused asmodal-state-unknownrather than sent; a page with no local browser to relate (a remote endpoint, or a listener this user cannot read) is not checked, and its step row says so (modality not checked:with the reason). - Everything the application publishes (names, window titles, descriptions, action names, field text) is returned with registered secrets redacted.
a11y.actioninvokes the control’s default action, or the oneactionnames, through the application’s own accessibility support: no coordinate is involved and its window need not be in front.methodisaccessibility. A control with no action of its own can only be clicked at the position it reports, and that is done only withallow_pointer: true, when its window has been mapped bywindows.activate, is in front, and contains the position; thenmethodispointerandatsays where. Otherwise nothing is clicked and the call fails asnot_performed: unsupported. A wxWidgets application’s default action goes through its accessible action unless the same conditions allow a real click.outcomeisperformed, oroutcome_unknownwhen the request was sent and the application never answered: check witha11y.listbefore repeating it. An error means nothing was done.verificationholds the read-back (the field’s text, the value, the selection) or, withexpect_state, the state read from the control acted on:held,failed, orunreadablewith the reason.unchangedmeans the state held before the action as well as after it: the control is as you asked, but nothing shows the action did anything, so check its effect another way if the next step depends on it. The call succeeds whenever the action was performed, so do not retry on a failed check: the action happened, and a toggle would flip back.- A password field is read back by length only:
verified_by: "length"means the length matches, not the contents. a11y.read_textreads a bounded text prefix from one native element through its text interface, past the shortenedtextthata11y.listshows. Registered secrets are removed, and a password field’s contents are never read. Reads still work behind a modal dialog, and no input is sent.a11y.set_valuerefuses a value outside the control’s range, and refuses when the range cannot be read.a11y.waitwaits for something to be there: a dialog, a menu or a control with theroleyou give (dialogalso matches a file chooser or an alert) and a name containingname, or a control’s state reachingvalue. It starts listening before it looks, so something already showing is found at once; after that, it looks again each time the application announces a window or control, and every fraction of a second in between, since some applications add a menu without announcing it. It means “there now or added later”, not “new since my last action”:windows.waitwith its cursor answers that. The match comes back asa11y.listlists it, with its handle or scope. Running out of time is a normal result,timed_out: truewith the reason, not an error. A modal dialog never blocks a wait.partialsays why a read stopped short (node cap,depth cap,time budget,unreadable children,unreadable identity); a window or control missing from a partial read may still be there.unreadable identitymeans a role or name read did not answer: the window or control is kept as it was, and no reference is retired for it.- Every
a11ymethod returns a resolution error if the loaded scenario setsatspi: false.
Handoff
Section titled “Handoff”dom.click, dom.key and a11y.action take handoff: {kind, timeout_s} to watch for the menu (kind: menu) or dialog (kind: dialog) the action opens, such as the File menu a click opens or the file chooser a menu command opens. The runtime starts watching before it sends the action, because a dialog can appear a tenth of a second later, and goes on for timeout_s (default 5, at most 30) afterwards. The result’s data.handoff says what appeared:
handoffis a token (h_...) thatapps.handofftakes to look again, for 60 seconds after the call.statusisreadywhen one menu or dialog appeared that is confirmed to belong to the application you acted on;ambiguouswhen several did, or when only ones nothing confirms appeared (they are all listed, and none is picked for you);pendingwhen nothing appeared in time;unavailablewhen nothing could be watched any longer; andclosedwhen what appeared has gone, or the application exited.surfaceslists each one with itsscope(fora11y.list) and itswindow(forwindows.*), either of which can be null, itsowner,for_application,relationandevidence.confirmedmeans the application’s own process shows it (process-incarnation), or it belongs to one of the application’s windows whichever program shows it (transient-parent: the desktop’s file chooser for the browser). Fordom.clickanddom.key, a page’s ownalert,confirm,promptor “Leave site?” dialog is akind: dialogsurface too,confirmedbypage-event: the browser’s protocol reported it on the page. It carriespageanddialog, anddom.dialoganswers it. A FedCM dialog the page opens is such a surface too, withpageandfedcm, anddom.fedcmanswers it.candidatewithevidence: handoffmeans only that it appeared while the runtime was watching. For a dialog,modal_onsays where it is marked modal.origin_applicationis the application the action was for. For a button inside a file chooser that is confirmed to serve a browser, that is the browser, not the chooser’s own program.
While it watches, the call holds the desktop: no other call runs until it returns, so keep timeout_s short and use apps.handoff to look again later. The status never changes the action’s own outcome, and nothing is done for you afterwards: read the surface by its scope and act on it like any other. The call is refused, with nothing sent, when the runtime cannot tie the page or control to an application on this machine, when it can watch neither the accessibility bus nor the windows (or is shutting down), or when 8 handoffs are already being watched (each ends 60 seconds after its call). A Chromium menu announces nothing, so the runtime reads the application’s tree again after the action; a handoff on a dom.* call connects the runtime to the accessibility bus to do so, which a dom.* call without one never does.
While a token lasts, a modal window that another program shows belonging to no window, and that appeared after the action, is listed under the application’s unresolved_blockers (evidence: handoff, with the token) and blocks the application’s actions where the window is not known, until it closes or the token expires.
| Method | Parameters | Returns |
|---|---|---|
human.ask |
question, or fields (typed: id, type of string, integer, number or boolean, required, enum, minimum, maximum, label); help; request_id; timeout_s (default 25); origin |
{request_id, state, closed_by, values, next, waited_s, remaining_s} |
- Asks the person supervising the session a question through the sidebar’s Messaging tab and waits for the answer. A plain
questiontakes a free-text answer;fieldsask for a choice, a number or a confirmation, such as abooleanfield nameddone. - One call waits up to
timeout_s. Ifstateis stillopenwhen it returns, call again with therequest_id, or with no arguments at all while one request is open, to keep waiting; the question is not asked twice. The answer comes back invalues, keyed by field id, withstate: closedandclosed_by: reply. A request that was cancelled, that ran out of its time, or whose run ended is closed too, withclosed_bysaying which (cancelled,timeout,run_ended). - The sidebar offers Not done or Stop on every question. When the person picks one, or answers a choice you offered with “Not done” or “Stop”,
closed_byisdeclinedandnexttells the agent to stop the task and wait for instructions. Use the choice["Done", "Not done"]only for a step the person must do on the desktop first, such as a sign-in. For a go or no-go, offer the action as one string field of two to four choices with the way out last. - In a Kasm session a question to a person has no deadline and spends no allowance, and
remaining_sis absent. Outside Kasm, the request’s time comes from the session’s human-in-the-loop allowance andremaining_ssays how much is left. - An answer that arrives after its asker stopped waiting is delivered to the main agent as a message. A delegated agent does not ask; it reports what it needs to the agent that started it. See The sidebar.
originis for recipe decisions:{kind: "recipe_decision", operation, decision, evidence}, whereevidencelists attachment IDs of images you uploaded.
recipes
Section titled “recipes”| Method | Parameters | Returns | Model |
|---|---|---|---|
recipes.index |
none | the installed catalogue’s guides, each with a guide_path, and the operations they cover |
No |
recipes.describe |
operation (required, app.operation); full |
the operation’s contract: what it does, effects, input_schema, output schema and checks. full: true returns the whole catalogue entry |
No |
recipes.guide |
path (required): a guide_path from recipes.index |
the application’s guide | No |
recipes.run |
operation (required); arguments; resume and decisions, only to answer a needs_decision; full |
a compact receipt: operation, outcome, reason, error, output, calls, duration_ms, one line for each child frame, the failed checks, receipt_path, and for needs_decision the decision essentials |
Optional |
- A recipe is a checked operation on an application.
recipes.indexandrecipes.guidechange nothing. Callrecipes.indexonce before driving an application by hand, and read the guide for the application. Theinitializeinstructions tell the client the same. - Only a receipt whose
outcomeisverifiedis success.unverifiedmeans the effects are unconfirmed: look before retrying.refusedmeans nothing was done.needs_decisionmeans the recipe stopped at a question: answer it withrecipes.runagain, usingdecision.resume_callplusdecisions: {<decision.id>: answer}, and copyresumeexactly, unquoted. Aneeds_decisionwhosedecision.audienceishumanhas already been asked in the sidebar; tell the person and resume withresumealone once they reply. receipt_pathis the absolute path of the full receipt under the run’s output directory.GET /artifacts/<file>serves the files in that directory.- A run holds the desktop for its whole duration, up to a few minutes, and uses the coordinate space of this call.
- A recipe’s own steps need no model. An operation that declares
screen.*steps needs a vision backend (see screen). - A row in the index that names
unavailablesays what the workspace lacks, such as an application that is not installed. Do not plan on it.
The receipt fields, the outcomes and the package format are on Recipes.
| Method | Parameters | Returns | Model |
|---|---|---|---|
file.get |
path |
{path, bytes, sha256, content_b64} |
No |
directory.get |
path |
{path, files, bytes, skipped, zip_bytes, sha256, zip_b64} |
No |
- A path is
~,~/<path>,/tmpor/tmp/<path>. An absolute path under the home directory is read as~/<path>. A path outside those roots, including one that leaves them through a symlink, is malformed. - Content comes back inline as base64, up to 5 MiB. A larger file or zip is a resolution error that names the streaming route to use instead,
GET /v1/files/orGET /v1/dirs/(HTTP API). Files are written over HTTP only (PUT /v1/files/). file.getreads regular files only; a directory, FIFO or device is refused without blocking.directory.getzips regular files and directories, and skips and counts symlinks and special files.
Downloads
Section titled “Downloads”| Method | Parameters | Returns | Model |
|---|---|---|---|
downloads.list |
none | {dir, downloads: [{path, name, bytes, state, modified}], truncated, total, cursor} |
No |
downloads.wait |
since (a cursor) and timeout_s (required); name (a glob on the file name) |
{matched, download: {path, name, bytes, sha256, sha256_skipped?, modified}, elapsed_ms, cursor, partial?, last_error?} |
No |
These two methods let an agent wait for a file a browser downloads and then read it with file.get. The pattern is the same as windows.list and windows.wait: list, act, then wait from the cursor.
downloads.listreturns acursor.- Click the link with
dom.click, or navigate to the file withdom.navigate. downloads.waitwithsinceset to that cursor returns the finished file. A download that finished between the action and the wait still matches.file.getwith the returnedpathreads it, up to 5 MiB;GET /v1/files/streams a larger one.
- The directory is the one the browsers save to:
~/Downloads, or the folderXDG_DOWNLOAD_DIRnames in~/.config/user-dirs.dirs. Symbolic links are followed, so a~/Downloadsthat links elsewhere lists where it leads. A folder that is really outside the home directory and/tmpis refused with the reason, sincefile.getcould not read it. A folder that does not exist yet lists as empty. On the Chrome and Firefox nix images it is~/Downloads. stateiscomplete, orpartialwhile a browser is still writing the file. Chrome writesUnconfirmed <number>.crdownload, or a hidden.com.google.Chrome.<letters>file, and renames it when the download finishes. Firefox writes<letters>.partbeside an empty file with the final name, and renames over it. An empty file is partial while any such file is in the folder, whatever its name.downloads.listlists the folder’s regular files, newest first, and changes nothing. It returns at most 500 rows:truncatedsays when there were more, andtotalcounts them; the cursor covers them all.- A match is a complete file that was not in the folder at the cursor, or has changed since. The wait reads the folder every 200 ms and takes a file once two reads in a row find it unchanged, so a match comes at least 200 ms after the file finished. That rule only catches a program that keeps growing a file under its final name; the browsers write under a partial name and rename.
sha256is the hash of the file as matched. It is empty, withsha256_skippedsaying why, for a file over the download limit (1 GiB by default) or one the wait’s time ran out reading;GET /v1/files/streams such a file with its digest.namenarrows the match with a glob such asreport*.csv: when a name is taken, Chrome savesreport (1).csvand Firefoxreport(1).csv.since: 0matches any complete file, including those already there. - Several downloads: with several matches the earliest finished is returned. The result’s
cursoris the old one plus that file, so a second wait from it returns the next file. - A timeout is
matched: false, withpartiallisting the files still being written, andcursorunchanged. A finished file the runtime cannot read, such as when every transfer slot is taken, ends the wait with that error instead. While it waits, no other call runs. - Cursors last as long as the runtime process; the newest 64 are kept. A cursor that is no longer kept is refused: take a new one from
downloads.list. - Chrome’s “Download multiple files” prompt. Chrome asks before a page starts a second download with no navigation in between. The download does not start, and nothing is written, until someone answers.
downloads.waitthen times out with no partial files. The prompt is in the browser’s accessibility tree as an alert titled “wants to: Download multiple files”, and a11y.actionon its Allow button lets the download go ahead. Chrome then remembers the answer for that site. Firefox did not ask. - A browser set to ask where to save shows its own Save dialog instead of downloading. Answer it with the desktop methods, as for any native dialog; the file is then wherever the dialog saved it.
- Measured on Chrome 154 and Firefox 156 on the nix images: a wait begun just after the click matched a 22-byte file in 200 to 400 ms, and a 50 MiB file, served over about 5 seconds, in 4 seconds, with its sha256 equal to what was served.
ref or literal
Section titled “ref or literal”input.type, clipboard.set and dom.fill each take exactly one of:
ref: the name of a value in the loaded scenario’sprovides:map. The runtime resolves it inside the session and never echoes it back.- a literal (
textforinput.typeandclipboard.set,valuefordom.fill) that your agent composes.
Giving both, or neither, is a malformed call. A ref with no scenario loaded, or a ref the scenario does not provide, is a resolution error. A scenario is loaded with KASM_RUNTIME_SCENARIO_B64; a driven session usually has none.
- HTTP API: the same methods as plain HTTP calls, plus file transfer and the observe routes.
- Your agent or script: how an outside agent connects and what it can call.
- Recipes: the receipt
recipes.runreturns. - Drive a session from Claude Code: these methods in use.