{"_id":"@ai-sdk-utils/computer-use","_rev":"2-2c0dff87a5276b57bb13b0e521518630","name":"@ai-sdk-utils/computer-use","dist-tags":{"latest":"0.0.3"},"versions":{"0.0.1":{"name":"@ai-sdk-utils/computer-use","version":"0.0.1","keywords":["ai-sdk","anthropic","computer-use","desktop-automation","screen-capture","nut-js"],"license":"MIT","_id":"@ai-sdk-utils/computer-use@0.0.1","maintainers":[{"name":"inakineitor","email":"arangoinaki@gmail.com"}],"homepage":"https://github.com/inakineitor/ai-tui#readme","bugs":{"url":"https://github.com/inakineitor/ai-tui/issues"},"dist":{"shasum":"cdfdec50a560b0b851e42eb903574b785433cf06","tarball":"https://registry.npmjs.org/@ai-sdk-utils/computer-use/-/computer-use-0.0.1.tgz","fileCount":8,"integrity":"sha512-IoGsG/6jBZ3Pl2KXmpJiHKpKULlgoDpd0CldP7zQ6UBGAo2vSo1zmZEAJxlaO0Takb7LbRMFA8z5Gi6//DNsnA==","signatures":[{"sig":"MEQCIDkLfMm+8TLkOY/9ppmWAmiiG85zusPwAJsM1IRZyI1nAiB7vcysnNPUNY+GAYiH+xa32tNQg9+sHHEC4aRKsOgR0w==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":97066},"main":"./dist/index.cjs","type":"module","_from":"file:ai-sdk-utils-computer-use-0.0.1.tgz","types":"./dist/index.d.mts","module":"./dist/index.mjs","engines":{"node":">=20"},"exports":{".":{"import":{"types":"./dist/index.d.mts","default":"./dist/index.mjs"},"require":{"types":"./dist/index.d.cts","default":"./dist/index.cjs"}},"./package.json":"./package.json"},"scripts":{"dev":"tsdown --watch","build":"tsdown","clean":"rm -rf .turbo && rm -rf node_modules && rm -rf dist","check-types":"tsc --noEmit","lint:package":"publint"},"_npmUser":{"name":"inakineitor","email":"arangoinaki@gmail.com"},"_resolved":"/private/var/folders/w4/pc4blp8n3gg3wv2k2g24062m0000gn/T/b761d57cd264034469c8288a57fc528d/ai-sdk-utils-computer-use-0.0.1.tgz","_integrity":"sha512-IoGsG/6jBZ3Pl2KXmpJiHKpKULlgoDpd0CldP7zQ6UBGAo2vSo1zmZEAJxlaO0Takb7LbRMFA8z5Gi6//DNsnA==","repository":{"url":"git+https://github.com/inakineitor/ai-tui.git","type":"git","directory":"packages/computer-use"},"_npmVersion":"10.9.2","description":"Desktop automation tool for Anthropic computer use with the Vercel AI SDK","directories":{},"sideEffects":false,"_nodeVersion":"23.11.1","dependencies":{"sharp":"^0.34.5","node-screenshots":"^0.2.8","@nut-tree-fork/nut-js":"^4.2.2","@ai-sdk/provider-utils":"^4.0.23"},"publishConfig":{"access":"public","provenance":false},"_hasShrinkwrap":false,"devDependencies":{"ai":"^6.0.68","tsdown":"^0.20.1","typescript":"^5","@types/node":"^22.0.0","@ai-tui/tsconfig":"0.0.0","@ai-sdk/anthropic":"^3.0.67"},"peerDependencies":{"@ai-sdk/anthropic":">=3.0.0"},"_npmOperationalInternal":{"tmp":"tmp/computer-use_0.0.1_1775520693568_0.40095210513025226","host":"s3://npm-registry-packages-npm-production"}},"0.0.3":{"name":"@ai-sdk-utils/computer-use","version":"0.0.3","description":"Desktop automation tool for Anthropic computer use with the Vercel AI SDK","type":"module","main":"./dist/index.cjs","module":"./dist/index.mjs","types":"./dist/index.d.mts","exports":{".":{"import":{"types":"./dist/index.d.mts","default":"./dist/index.mjs"},"require":{"types":"./dist/index.d.cts","default":"./dist/index.cjs"}},"./package.json":"./package.json"},"sideEffects":false,"license":"MIT","peerDependencies":{"@ai-sdk/anthropic":">=3.0.0"},"dependencies":{"@ai-sdk/provider-utils":"^4.0.23","@nut-tree-fork/nut-js":"^4.2.2","node-screenshots":"^0.2.8","sharp":"^0.34.5"},"devDependencies":{"@ai-sdk/anthropic":"^3.0.67","@types/node":"^22.0.0","ai":"^6.0.68","tsdown":"^0.20.1","typescript":"^5","@ai-tui/tsconfig":"0.0.0"},"engines":{"node":">=20"},"repository":{"type":"git","url":"git+https://github.com/inakineitor/ai-tui.git","directory":"packages/computer-use"},"keywords":["ai-sdk","anthropic","computer-use","desktop-automation","screen-capture","nut-js"],"publishConfig":{"access":"public","provenance":true},"scripts":{"build":"tsdown","dev":"tsdown --watch","check-types":"tsc --noEmit","lint:package":"publint","clean":"rm -rf .turbo && rm -rf node_modules && rm -rf dist"},"_id":"@ai-sdk-utils/computer-use@0.0.3","bugs":{"url":"https://github.com/inakineitor/ai-tui/issues"},"homepage":"https://github.com/inakineitor/ai-tui#readme","_integrity":"sha512-tJZxUd7KRwP3vMrnsay/IVgAH5JgOwYNSkqMPFF73SyTE0DgjQpQMkYaxVj/T5Z7VacPp8ivq2fCl09iEBEQJQ==","_resolved":"/tmp/7a04b7557b9430f9ca1b9edc645df4ce/ai-sdk-utils-computer-use-0.0.3.tgz","_from":"file:ai-sdk-utils-computer-use-0.0.3.tgz","_nodeVersion":"24.14.1","_npmVersion":"11.11.0","dist":{"integrity":"sha512-tJZxUd7KRwP3vMrnsay/IVgAH5JgOwYNSkqMPFF73SyTE0DgjQpQMkYaxVj/T5Z7VacPp8ivq2fCl09iEBEQJQ==","shasum":"b7e4bf018270dfc516c340eb6d72b5a09940e04b","tarball":"https://registry.npmjs.org/@ai-sdk-utils/computer-use/-/computer-use-0.0.3.tgz","fileCount":9,"unpackedSize":103637,"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@ai-sdk-utils%2fcomputer-use@0.0.3","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQC5O/HWlHMT1FbldEJScmIOneJwt0l2eQeUFKsMY3l0+wIgO7QNKbEDblLq7xWNeI/vMwhYWN2CSOpqynA+vuGljpU="}]},"_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:9417b7d7-5627-4861-b416-5edcead54cfb"}},"directories":{},"maintainers":[{"name":"inakineitor","email":"arangoinaki@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/computer-use_0.0.3_1775521583610_0.1598053217881421"},"_hasShrinkwrap":false}},"time":{"created":"2026-04-07T00:11:33.412Z","modified":"2026-04-07T00:26:24.182Z","0.0.1":"2026-04-07T00:11:33.729Z","0.0.3":"2026-04-07T00:26:23.833Z"},"bugs":{"url":"https://github.com/inakineitor/ai-tui/issues"},"license":"MIT","homepage":"https://github.com/inakineitor/ai-tui#readme","keywords":["ai-sdk","anthropic","computer-use","desktop-automation","screen-capture","nut-js"],"repository":{"type":"git","url":"git+https://github.com/inakineitor/ai-tui.git","directory":"packages/computer-use"},"description":"Desktop automation tool for Anthropic computer use with the Vercel AI SDK","maintainers":[{"name":"inakineitor","email":"arangoinaki@gmail.com"}],"readme":"# @ai-sdk-utils/computer-use\n\n[![npm version](https://img.shields.io/npm/v/@ai-sdk-utils/computer-use?style=flat-square)](https://www.npmjs.com/package/@ai-sdk-utils/computer-use)\n[![License: MIT](https://img.shields.io/badge/License-MIT-blue?style=flat-square)](https://opensource.org/licenses/MIT)\n[![Node.js](https://img.shields.io/badge/Node.js-≥20-green?style=flat-square)](https://nodejs.org)\n\nDesktop automation tool for [Anthropic computer use](https://docs.anthropic.com/en/docs/agents-and-tools/computer-use) with the [Vercel AI SDK](https://sdk.vercel.ai).\n\n[Get started](#getting-started) | [API](#api) | [Configuration](#configuration) | [Capture targets](#capture-targets)\n\n---\n\n## Overview\n\nThis package bridges the Anthropic computer use tool with real desktop automation. It captures screenshots, moves the mouse, clicks, types, scrolls, and drags — all driven by Claude through the Vercel AI SDK.\n\nUnder the hood it uses [`node-screenshots`](https://github.com/nicehash/node-screenshots) for screen capture and [`nut-js`](https://nutjs.dev) for input simulation, with [`sharp`](https://sharp.pixelplumbing.com) for image processing.\n\n**Key features:**\n\n- Full support for Anthropic computer use tool versions `20251124` and `20250124`\n- Screenshot scaling to Anthropic-recommended resolutions (XGA/WXGA/FWXGA) for better accuracy and lower token usage\n- Flexible capture targets: full desktop, specific monitor, or individual window\n- HiDPI / Retina display support with automatic coordinate translation\n- Auto-screenshot after actions for continuous visual feedback\n- Animated or instant mouse movement modes\n- Zoom action support (cropped region screenshots)\n\n## Getting started\n\n### Prerequisites\n\n- Node.js 20 or later\n- An [Anthropic API key](https://console.anthropic.com/)\n- **macOS**: Grant accessibility and screen recording permissions to your terminal\n\n### Installation\n\n```bash\nnpm install @ai-sdk-utils/computer-use @ai-sdk/anthropic ai\n```\n\n### Quick example\n\n```typescript\nimport { anthropic } from \"@ai-sdk/anthropic\";\nimport { generateText, stepCountIs } from \"ai\";\nimport { createComputerTool } from \"@ai-sdk-utils/computer-use\";\n\nconst { tool, displaySize } = createComputerTool();\n\nconst result = await generateText({\n  model: anthropic(\"claude-opus-4-6\"),\n  tools: { computer: tool },\n  stopWhen: stepCountIs(30),\n  system: `You are controlling a desktop. The screen is ${displaySize.width}x${displaySize.height} pixels.`,\n  prompt: \"Open the calculator app and compute 42 * 17.\",\n});\n\nconsole.log(result.text);\n```\n\n> [!IMPORTANT]\n> On macOS, your terminal app needs **Accessibility** and **Screen & System Audio Recording** permissions in System Settings > Privacy & Security.\n\n## API\n\n### `createComputerTool(options?)`\n\nCreates an Anthropic computer use tool ready to pass to the AI SDK.\n\n```typescript\nconst { tool, displaySize, scaling, refreshSource } = createComputerTool({\n  target: { mode: \"desktop\" },\n  scalingEnabled: true,\n});\n```\n\n**Returns:**\n\n| Property | Type | Description |\n|---|---|---|\n| `tool` | AI SDK Tool | The tool object to pass to `generateText` / `streamText` |\n| `displaySize` | `{ width, height }` | Screen dimensions reported to the model |\n| `scaling` | `ScalingInfo` | Scaling info with `toNative()` and `toApi()` converters |\n| `refreshSource` | `() => void` | Re-resolve the capture source (useful for window mode) |\n\n### `listMonitors()`\n\nReturns an array of all available monitors with their id, position, dimensions, scale factor, and primary status. Useful for choosing a capture target.\n\n### `listWindows()`\n\nReturns an array of all available windows with their id, title, position, dimensions, and z-order.\n\n### `computeScaling(width, height)`\n\nComputes the optimal scaling info for the given native resolution, targeting Anthropic-recommended resolutions.\n\n### `parseKeys(keyString)`\n\nParses an Anthropic key string (e.g. `\"ctrl+s\"`, `\"Return\"`) into nut-js `Key` values. Follows xdotool / X11 keysym naming conventions.\n\n## Configuration\n\nAll options for `createComputerTool` are optional:\n\n| Option | Type | Default | Description |\n|---|---|---|---|\n| `target` | `CaptureTarget` | `{ mode: \"desktop\" }` | What to capture and scope mouse actions to |\n| `animated` | `boolean` | `false` | Smooth mouse movement vs instant teleport |\n| `toolVersion` | `\"20251124\" \\| \"20250124\"` | `\"20251124\"` | Anthropic tool version (`20251124` for Opus, `20250124` for Sonnet) |\n| `enableZoom` | `boolean` | `true` | Enable zoom action (tool version `20251124` only) |\n| `scalingEnabled` | `boolean` | `true` | Scale screenshots to standard resolutions |\n| `autoScreenshot` | `boolean` | `true` | Capture screenshot after each action |\n| `mouseSpeed` | `number` | `1500` | Mouse speed in px/sec (animated mode only) |\n| `mouseAutoDelayMs` | `number` | `50` | Delay after mouse ops (animated mode only) |\n| `keyboardAutoDelayMs` | `number` | `10` | Delay after keyboard ops (animated mode only) |\n| `typeCharDelayMs` | `number` | `8` | Per-character typing delay (non-animated mode) |\n| `displayNumber` | `number` | — | X11 display number (Linux only) |\n\n## Capture targets\n\nControl what part of the screen is captured and where mouse actions are scoped:\n\n```typescript\n// Full desktop (primary monitor) — default\ncreateComputerTool({ target: { mode: \"desktop\" } });\n\n// Specific monitor by index\ncreateComputerTool({ target: { mode: \"monitor\", by: \"index\", index: 1 } });\n\n// Specific monitor by id\ncreateComputerTool({ target: { mode: \"monitor\", by: \"id\", id: 42 } });\n\n// Monitor at a screen coordinate\ncreateComputerTool({ target: { mode: \"monitor\", by: \"point\", x: 100, y: 200 } });\n\n// Window by id\ncreateComputerTool({ target: { mode: \"window\", by: \"id\", id: 12345 } });\n\n// Window by title (substring match, case-insensitive)\ncreateComputerTool({ target: { mode: \"window\", by: \"title\", title: \"Photoshop\" } });\n```\n\n> [!TIP]\n> Use `listMonitors()` and `listWindows()` to discover available targets at runtime.\n\n## Supported actions\n\nThe tool handles all Anthropic computer use actions:\n\n| Category | Actions |\n|---|---|\n| **Screenshots** | `screenshot`, `zoom` |\n| **Mouse** | `mouse_move`, `left_click`, `right_click`, `middle_click`, `double_click`, `triple_click` |\n| **Fine-grained mouse** | `left_mouse_down`, `left_mouse_up`, `left_click_drag` |\n| **Scroll** | `scroll` (up, down, left, right) |\n| **Keyboard** | `type`, `key`, `hold_key` |\n| **Utility** | `cursor_position`, `wait` |\n\nAll click actions support modifier keys (e.g. `ctrl`, `shift`, `cmd`) and optional coordinates.\n","readmeFilename":"README.md"}