namzu.aidocs

Computer Use

Add desktop screenshots, mouse input, and keyboard input to Namzu through @namzu/computer-use.

@namzu/computer-use is the published desktop-control package for Namzu. It provides a SubprocessComputerUseHost that plugs into createComputerUseTool(), so GUI automation stays inside the normal SDK tool pipeline instead of creating a second runtime path.

1. Install

pnpm add @namzu/sdk @namzu/computer-use

2. Minimal Setup

import { ToolRegistry, createComputerUseTool } from '@namzu/sdk'
import { SubprocessComputerUseHost } from '@namzu/computer-use'
 
const host = new SubprocessComputerUseHost()
await host.initialize()
 
const tools = new ToolRegistry()
tools.register(createComputerUseTool(host))

host.initialize() detects the current display server, loads the matching adapter, and freezes the capability map for the current session.

3. What the Host Actually Does

SubprocessComputerUseHost uses platform-native subprocesses instead of native addons. That gives the package a few deliberate properties:

  • no Rust or native build chain requirement
  • no prebuilt binary matrix to manage
  • capability detection tied to real host conditions
  • straightforward failure surfaces when system binaries or permissions are missing

4. Action Surface

The wrapped tool exposes a discriminated action union:

ActionPurpose
screenshotCapture the current display as PNG data
cursor_positionReturn the current cursor coordinates when supported
mouse_moveMove the pointer
mouse_clickClick at a target point
mouse_dragDrag from one point to another
scrollScroll in a direction by a requested amount
type_textType a text string
keySend a chord or single key such as cmd+shift+t or Return

Screenshots are returned as base64 PNG in ToolResult.output, with metadata such as MIME type and image dimensions in ToolResult.data.

Read Action Reference for the full per-action contract.

5. Capability Model

The package does not assume every host can do every action. Capabilities are frozen on initialization:

Capability fieldMeaning
displayServerHost environment such as darwin, x11, wayland, win32, or unknown
screenshotScreenshot capture is available
mouseMouse movement and click actions are available
keyboardTyping and key actions are available
cursorPositionCursor position lookup is available
clipboardClipboard access is available on the adapter

If an action targets a capability that is unavailable, the tool returns a clear failure instead of hanging.

6. Host Lifecycle

The recommended lifecycle is:

  1. construct the host
  2. call await host.initialize()
  3. inspect or log host.capabilities
  4. register createComputerUseTool(host) in a ToolRegistry
  5. dispose or recreate the host when the environment changes

Read Host Lifecycle for the detailed lifecycle and failure model.

7. Operational Notes

  • This package uses platform-native CLIs through subprocesses instead of native addons.
  • Recreate the host if you install missing system binaries mid-session; capabilities are not re-probed automatically.
  • Review Platform Support before rolling this out on multiple operating systems.
  • Treat screenshots as the primary grounding step before pointer actions.

On this page