# GenWorker

A desktop AI agent powered by Claude Computer Use. GenWorker takes natural-language tasks and executes them on your desktop by controlling the mouse, keyboard, and shell — using Claude's computer, bash, and text editor tools.

## Features

- **Computer Use** — mouse clicks, keyboard input, and screenshots via Claude's computer tool
- **Shell Execution** — runs PowerShell/CMD/bash commands
- **File Editing** — view, create, and edit files with the str_replace_editor tool
- **Multi-monitor support** — select which display to control
- **Adaptive screenshots** — fast for CLI, slower for GUI loads, with JPEG compression
- **Retry & error recovery** — exponential backoff on API errors, automatic recovery hints
- **Context management** — token tracking, smart compaction, and image pruning
- **Task timeout** — configurable time limit with graceful termination

## Installation

```bash
pip install genworker-ai
```

## Requirements

- Python 3.13+
- An [Anthropic API key](https://console.anthropic.com/)

## Quick start

1. Create a `.env` file (or export the variable):

   ```
   ANTHROPIC_API_KEY=sk-ant-...
   ```

2. Run a task:

   ```bash
   genworker "Open Notepad and write Hello World"
   ```

   Or start interactively:

   ```bash
   genworker
   ```

## Usage

```
genworker [OPTIONS] [TASK]
```

| Option | Description |
|---|---|
| `TASK` | Natural-language task to execute (interactive prompt if omitted) |
| `--monitor`, `-m` | Monitor index to use (default: `0`) |
| `--list-monitors`, `-l` | List available monitors and exit |
| `--no-thinking` | Disable Claude's extended thinking |
| `--timeout`, `-t` | Task timeout in seconds (default: `600`) |

You can also run it as a Python module:

```bash
python -m genworker "Open Chrome and search for Python docs"
```

## Configuration

All settings can be configured via environment variables or a `.env` file:

| Variable | Default | Description |
|---|---|---|
| `ANTHROPIC_API_KEY` | — | **Required.** Your Anthropic API key |
| `MODEL` | `claude-sonnet-4-5-20250929` | Claude model to use |
| `MAX_STEPS` | `100` | Maximum agent loop iterations |
| `TASK_TIMEOUT` | `600` | Task timeout in seconds |
| `THINKING_BUDGET` | `4096` | Token budget for extended thinking |
| `SCREENSHOT_INTERVAL` | `1.0` | Seconds between screenshots |
| `SCREENSHOT_QUALITY` | `75` | JPEG compression quality (1-100) |
| `MAX_CONTEXT_IMAGES` | `15` | Max screenshots kept in context |
| `BASH_TIMEOUT` | `30` | Shell command timeout in seconds |
| `MONITOR_INDEX` | `0` | Default monitor index |

## License

[MIT](LICENSE)
