Integration · @namzu/computer-use
Namzu × Computer use.Screen, keyboard and pointer control.
Screenshots, mouse and keyboard through platform-native tools, behind one adapter interface.
Install.
pnpm add @namzu/sdk @namzu/computer-use@namzu/sdk is a peer dependency, so install both. The SDK needs zod@^3 too.
Why pair the kernel with computer use.
Driving a desktop is a capability where the runtime around the model matters as much as the model. This package is the host: it owns the pixels and the input events. The SDK's computer_use tool owns what the model sees, how big a screenshot is, and what a coordinate means.
- Which backend serves a call depends on the platform:
screencaptureandosascripton macOS (cliclickfor move and drag),xdotoolandmaimon Linux X11,grim,wtypeandydotoolon Wayland, and cua-driver with a PowerShell fallback on Windows. Inside WSL it selects the paired Windows desktop. - What a platform cannot do is reported as a capability, not discovered as a failure. Adapters publish an exact
supportedActionssubset, and the SDK tool advertises only those and rejects unsupported gestures before touching the desktop. - If a click, drag, scroll, text entry or key subprocess starts but does not report a clean completion, the host throws
ComputerUseOutcomeUnknownError. The SDK returns that to the model withretrySafety: 'unsafe'instead of inviting an automatic replay. - Coordinates cross the host in physical pixels. The tool fits each capture to a size the model can answer in and maps its coordinates back, so a click lands where the model looked.
- On Windows the first
initialize()downloads a pinned cua-driver, checks its SHA-256, and runs it with its telemetry and release check switched off.NAMZU_CUA_DRIVER=offkeeps it out.
Scope.This package controls the desktop the host runs on. For an isolated desktop, give a Pal its own computer: see local Pal computers.
Example.
import {
SubprocessComputerUseHost,
type SubprocessComputerUseHostOptions,
} from '@namzu/computer-use'
import { createComputerUseTool, toolset } from '@namzu/sdk'
const options: SubprocessComputerUseHostOptions = {
env: process.env,
platform: process.platform,
}
const host = new SubprocessComputerUseHost(options)
await host.initialize()
console.log(host.capabilities)
// { displayServer: 'darwin', screenshot: true, mouse: true, keyboard: true,
// cursorPosition: false, // unless `cliclick` is installed
// clipboard: true }
const tools = toolset('computer-use', [createComputerUseTool(host)])
// Pass `tools` to runAgent in its `toolsets`, and call host.dispose() when the session ends.Configure.
SubprocessComputerUseHost options
- envNodeJS.ProcessEnv
- The environment the host reads, for example to find a display server.
- platformNodeJS.Platform
- The platform to select adapters for.
- windows.backend'auto' | 'cua-driver' | 'powershell'
autotries cua-driver and falls back to PowerShell;cua-driverhas no fallback.- windows.downloadboolean
- Set false to use a cached or configured cua-driver only.
- NAMZU_CUA_DRIVERenvironment variable
offkeeps cua-driver out and downloads nothing; a path runs thatcua-driver.exeinstead of the pinned build.
What the host reports in capabilities
- displayServer, screenshot, mouse, keyboard, cursorPosition, clipboard
- The basics, per platform.
- windows, windowCapture
- Window list and focus, and a capture of one named window with input bound to it. Windows with cua-driver.
- uiTreeexperimental
- Read a window's accessibility tree and act on a control by reference.
Where it runs.
- macOSScreenshot, keyboard and click; move and drag need cliclick; no scrolling
- LinuxX11 and Wayland
- Windowscua-driver, PowerShell fallback
- WSLDrives the paired Windows desktop
Ship Computer use agents on a runtime you can own.
The platform owns the desktop. Namzu owns the runtime. The package is a thin adapter, not a wrapper, so you keep everything Computer use ships and add the kernel concerns you do not get from the model API alone.