Skip to main content
You’ll build a device that turns your own laptop into something the agent can operate from any channel: “take a screenshot”, “open Notes”, “lock my screen”. The finished script is about 80 lines, runs with npx tsx device.ts, and passes everything the model says to the operating system as arguments, never inside a shell command. You need Node 18 or later, an agent created with lua init, and on macOS the Screen Recording permission for your terminal. Verified against lua-cli 3.45.0.

What you’ll build

  • A device named my-laptop with six commands the model can call.
  • Screenshots uploaded to the CDN so the agent can share an image URL.
  • An allow-list for the applications the agent may open.
  • A notification, volume, and lock-screen command driven by sanitized arguments.
1

Create the credential

From the agent project, issue a device credential for device name my-laptop with the operations commands and assets.upload, written to the folder the device will run from. Then load it there and install the client.
2

Write the device

Model output reaches the OS only as execFileSync arguments or environment variables, and open_app checks an allow-list first.
device.ts
3

Run the device

Start the script and leave it running. It prints my-laptop connected; on macOS the first screenshot prompts for the Screen Recording permission.
4

Ask the agent

From the agent project, try each command. The model calls device__my_laptop__take_screenshot and replies with the image URL; open_app refuses anything outside the allow-list and the model reports the error.
Every command runs on your machine whenever the agent calls it, from any channel the agent is connected to. Keep the allow-list short and stop the script when you’re done.
5

Verify

Check the device state from the agent project.
It prints 🟢 Device 'my-laptop' is online; stop the script and it prints offline and the tools disappear from the agent.

What you learned

Next steps

Handle device triggers

Let the laptop wake the agent, for example on low battery.

Node device client

Every option and event of the client.