Writing scripts
How the agent runtime works, and how to read your job's inputs.
The agent runtime
Scripts run inside the agent runtime. It exposes four namespaces: actions (drive the UI), info (read state), control (flow), and arguments (your typed inputs).
Async actions
Every action returns a Promise — the device performs it, then resolves. Always await.
typescript
await agent.actions.tap(540, 1200);
const text = await agent.info.screenText();
if (text.includes("Welcome")) {
await agent.control.finish("success");
}Typed arguments
Inputs you declare in the project's schemas become fully-typed on agent.arguments — with IntelliSense in the editor.
typescript
const { targetUrl, retries } = agent.arguments.automationParameters;
await agent.control.retry(
() => agent.actions.open(targetUrl),
retries ?? 3,
);