A minimal SDK implementation of Anthropic's Computer Use loop that drives Kernel browsers using screenshots from Kernel's Computer Controls API.
- Install dependencies:
pnpm install- Set environment variables by creating a
.envfile in the project root:
ANTHROPIC_API_KEY=your-anthropic-api-key
KERNEL_API_KEY=your-kernel-api-key # Optional if configured elsewhereAlternatively, you can export them in your shell:
export ANTHROPIC_API_KEY="your-anthropic-api-key"
export KERNEL_API_KEY="your-kernel-api-key" # Optional if configured elsewhereRun the Computer Use loop with a prompt:
npx tsx index.ts "Your task prompt here"Example:
npx tsx index.ts "Navigate to google.com and search for TypeScript"- Creates a Kernel browser session
- Captures screenshots using Kernel's Computer Controls API
- Sends screenshots to Claude with the Computer Use tool
- Executes the actions returned by Claude (clicks, typing, scrolling, etc.)
- Repeats until the task is complete or max iterations reached
The loop supports:
- Mouse clicks
- Typing text
- Pressing keys
- Scrolling
- Dragging
- Node.js 18+
- Anthropic API key
- Kernel API key