Skip to main content
A node on a Windows or Linux environment can run a script before any model call, the same way a browser node does. The script gets a 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 .js script gets desktop. There is no page, and a function whose first parameter is page fails.
  • 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, requireConfirmation and waitForReply work 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

The whole script has a hard limit of 5 minutes, as a browser script does. When it is reached, the run is killed and treated as a failure. Time spent waiting in requireConfirmation or waitForReply does not count.
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. Each desktop 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:fs sees the sandbox, under /home/agent, as in Script runtime. Use desktop.fs for 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.launch opens 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 of launch, and desktop.fs.write refuse a secret. The call throws BAD_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.
Log a marker for each action that must not repeat, such as CREDENTIALS_SUBMITTED=true. When the script fails, the node’s instructions run, and they can say “never submit the sign-in again”.

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 a code. 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 page on a desktop.
  • 5 minutes per script. Split a long flow across nodes, such as sign in, then select a clinic.

Script a step

Attach a script, route from it, and pin its inputs

Script runtime

The browser contract, and the asteroid module both share

Environments

Browser, Linux, and Windows, and what each one runs

Secrets & 2FA

How a ##ITEM_KEY.FIELD## token gets its value