desktop object in place of a Playwright page. It finds windows and controls by name, sends real mouse and keyboard input, and hands off to the next node. No model runs.
This page is the contract a desktop script runs under. The parts it shares with browser scripts, such as asteroid.handoff, are in Script runtime and Script a step.
The entry function
A desktop script is a JavaScript (.js) file. It exports one async function, and the runtime calls it with a single object.
- On a Windows or Linux environment, every
.jsscript getsdesktop. There is nopage, and a function whose first parameter ispagefails. - A node with an input schema must destructure
args, or every run fails. - The return value works as it does in a browser script. The golden path is to return
asteroid.handoff(...). See What the script returns. asteroid.generateTotp,emit,requireConfirmationandwaitForReplywork unchanged.
What a script can reach
Without controls to find, a script drives an app with keyboard shortcuts, paste, and clicks at coordinates relative to its window. It cannot read the screen, so it cannot check what state the app is in. Script only the steps that always go the same way, and let the next node check the result.
Timeouts
Pass
{ timeout } to the one call that is slow. desktop.timeLeft() returns the milliseconds the script has left, and no call runs past it.
Waits on windows, controls, processes and files run on the desktop in one held call, so they react at once and cost one round trip. Prefer them to desktop.waitFor(fn), which polls.
Where the script runs
The script runs in Node.js in the execution’s sandbox, not on the desktop. Eachdesktop method is a call to the desktop, which takes about 150 to 400 ms. Make fewer, larger calls: read every match with one infos(), and wait for several states with one waitForAny.
node:fssees the sandbox, under/home/agent, as in Script runtime. Usedesktop.fsfor the desktop’s own disk.- Input is real. Clicks and keys go to the window in front, and they show on the recording. Focus the target window before you send input, and again after a dialog closes.
- Programs start in the signed-in user’s session. A window that
desktop.launchopens is visible and can be driven. - Files in and out. A file the caller staged is in the desktop’s Uploads folder. A file the app saves into the desktop’s Downloads folder reaches
/home/agent/downloads/within 5 to 10 seconds.
Secrets
Write##ITEM_KEY.FIELD## in the script, as in a browser script. The runtime fills the token in the sandbox before the script runs. The value reaches the desktop only as typed or pasted input. It is never written to the desktop’s disk.
fill()pastes a secret, and never reads a password field back.exec, the arguments oflaunch, anddesktop.fs.writerefuse a secret. The call throwsBAD_REQUEST.- Secret values are removed from console logs, errors and the call log.
Example
Launch a Windows app, sign in, handle the dialog that can follow, read a table and hand off.The desktop object
Windows
A match sets any of
title (a string, or a RegExp with no flag or i), process (case and .exe are ignored), pid, className, handle and dialog. Every field you set must match.
Controls
A locator query sets any of these. Every field you set must match.Waits
Input, screen and clipboard
Programs and files
Errors
A failed call throws an error with acode. Branch on the code, never on the message, and rethrow the rest: if (err.code !== 'NOT_FOUND') throw err;.
When a script fails
A thrown error fails the script, and the node’s failure action decides what follows, as for a browser script. See What happens when the script fails. With the default, the model runs the node from its instructions. It gets the error, everything the script logged, the last 20 desktop calls with the code of any that failed, and a screenshot of the desktop at the moment it failed. The desktop_run_script step of the execution shows the same.Limits
- No reading text from pixels. There is no OCR. A script finds controls only through
locator. - No controls on Linux. Use keys, paste and window-relative clicks there.
- No controls inside a remote app window, such as an app delivered through Citrix or RemoteApp. The app is one picture to the desktop.
- No controls in Java apps (AWT or Swing) yet.
- No Playwright inside a desktop app. There is no
pageon a desktop. - 5 minutes per script. Split a long flow across nodes, such as sign in, then select a clinic.
Related
Script a step
Attach a script, route from it, and pin its inputs
Script runtime
The browser contract, and the
asteroid module both shareEnvironments
Browser, Linux, and Windows, and what each one runs
Secrets & 2FA
How a
##ITEM_KEY.FIELD## token gets its value
