autoclaw 1.3.3 โ†’ 1.3.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,289 +1,303 @@
1
- # AutoClaw ๐Ÿฆž
2
-
3
- [![NPM Version](https://img.shields.io/npm/v/autoclaw.svg?style=flat-square)](https://www.npmjs.com/package/autoclaw)
4
- [![NPM Downloads](https://img.shields.io/npm/dm/autoclaw.svg?style=flat-square)](https://www.npmjs.com/package/autoclaw)
5
- [![GitHub](https://img.shields.io/badge/GitHub-Repository-blue?logo=github&style=flat-square)](https://github.com/tsingliuwin/autoclaw)
6
- [![License](https://img.shields.io/npm/l/autoclaw.svg?style=flat-square)](https://github.com/tsingliuwin/autoclaw/blob/main/LICENSE)
7
- [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](http://makeapullrequest.com)
8
-
9
- **The Engineering-First Headless Agent Framework: Stable, Scalable Automation for the Post-Vision Era.**
10
-
11
- English | [็ฎ€ไฝ“ไธญๆ–‡](./README.zh-CN.md)
12
-
13
- ---
14
-
15
- ๐Ÿ”— **GitHub Repository**: [https://github.com/tsingliuwin/autoclaw](https://github.com/tsingliuwin/autoclaw)
16
-
17
- ---
18
-
19
- AutoClaw is a high-stability, open-source automation framework specifically engineered for **headless systems**.
20
-
21
- Unlike "screen-seeing" agents (such as OpenClaw) that rely on visual interpretation, AutoClaw is built on a foundation of precise command-driven execution. This makes it significantly more **stable**, **robust from an engineering perspective**, and **easier to scale** across complex environmentsโ€”whether it's a local server, a CI/CD pipeline, or thousands of containerized nodes.
22
-
23
- ## Why AutoClaw?
24
- - ๐Ÿณ **Docker Native**: Built to run safely inside containers. Minimal footprint (Node.js/Alpine friendly).
25
- - ๐Ÿš€ **Better Engineering**: Operates via precise system APIs and shell commands rather than unstable visual recognition, ensuring deterministic outcomes.
26
- - ๐Ÿ›ก๏ธ **Superior Stability**: Immune to issues like UI rendering, screen resolution, or network lag that plague vision-based agents.
27
- - ๐Ÿ“ˆ **Massive Scalability**: Low resource consumption allows orchestrating thousands of instances (e.g., in K8s) for true automation swarms.
28
- - ๐Ÿ”Œ **Swarm Ready**: Stateless design allows for easy orchestration via K8s, Docker Swarm, or simple shell loops.
29
- - ๐Ÿงฉ **Extensible Integrations**: Built-in support for Web Search (Tavily), Email (SMTP), and Notification Webhooks (Feishu, DingTalk, WeCom).
30
-
31
- ## Features
32
-
33
- - ๐Ÿ“œ **Headless Execution**: No GUI required โ€” pure terminal efficiency. Core operation is shell + file I/O; the optional web tools run in headless Chromium.
34
- - ๐Ÿค– **Non-Interactive Mode**: Intelligent flag handling (`-y`, `--no-interactive`) for zero-touch automation.
35
- - ๐Ÿ“‚ **Universal Control**: From simple file I/O to complex system administration.
36
- - ๐Ÿ›ก๏ธ **Runaway Protection**: Max-step cap per task, API retries with exponential backoff, shell command timeouts, and tool output truncation to keep the model context bounded.
37
- - ๐Ÿง  **Context Aware**: Provides accurate OS, system and time context so relative dates ("today", "next Monday") are handled correctly.
38
- - ๐ŸŒ **Web Search**: Integrated with Tavily for real-time information retrieval.
39
- - ๐ŸŒ **Web Reading & Screenshots**: Extract article content and capture page screenshots (requires `npx playwright install chromium`).
40
- - ๐ŸŽจ **Image Generation**: DALL-E compatible image generation via any OpenAI-compatible images API.
41
- - ๐Ÿ•’ **Time Accuracy**: Built-in tool to get precise system date and time for correct temporal context.
42
- - ๐Ÿ“ง **Communication**: Send emails and push notifications to chat groups automatically.
43
-
44
- ## Tech Stack
45
- - **Runtime**: Node.js
46
- - **Language**: TypeScript
47
- - **Framework**: Commander.js
48
- - **UI**: Inquirer (interactivity), Chalk (styling), Ora (spinners)
49
- - **AI**: OpenAI SDK (any OpenAI-compatible endpoint: DeepSeek, Kimi, Qwen, GLM, Ollama, โ€ฆ)
50
- - **Web tools**: Playwright (headless Chromium for `read_website` / `take_screenshot`)
51
-
52
- ## Installation
53
-
54
- ### User Installation
55
- Install globally via npm:
56
- ```bash
57
- npm install -g autoclaw
58
- ```
59
-
60
- ### Development Installation
61
- 1. Clone the repository:
62
- ```bash
63
- git clone https://github.com/tsingliuwin/autoclaw.git
64
- cd autoclaw
65
- ```
66
- 2. Install dependencies:
67
- ```bash
68
- npm install
69
- ```
70
- 3. Build the project:
71
- ```bash
72
- npm run build
73
- ```
74
- 4. Link globally (optional):
75
- ```bash
76
- npm link
77
- ```
78
-
79
- ## Quick Start
80
-
81
- 1. **Setup**: Run the interactive setup wizard to configure your API keys and integrations. The wizard runs a live connection test (failures map to the likely wrong field: 401 = key, 404 = base URL, 400 = model name) and can list the provider's models for you to pick from.
82
- ```bash
83
- autoclaw setup
84
- ```
85
- 2. **Run**: Start the agent in interactive mode.
86
- ```bash
87
- autoclaw
88
- ```
89
-
90
- ## Usage
91
-
92
- ### Interactive Mode
93
- Simply run `autoclaw` to enter the chat loop.
94
- ```bash
95
- autoclaw
96
- > List all TypeScript files in the src folder.
97
- ```
98
- Interactive commands: `exit` / `quit` to leave, and `/view` to open the full output of the last tool result in a pager โ€” tool output longer than 20 lines is folded on screen and saved to `~/.autoclaw/output/`.
99
-
100
- ### Headless Mode (One-Shot)
101
- Run a single command and exit.
102
- ```bash
103
- autoclaw "Check disk usage and save the report to usage.txt" --no-interactive
104
- ```
105
- The exit code reports the outcome for orchestrators: `0` completed, `1` hard failure (e.g. API error), `2` step cap reached (task unfinished).
106
-
107
- ### Machine-Readable Output (--json)
108
- Add `--json` to print one JSON event per line on stdout (run_start, tool_call, tool_result, usage, run_end); human output moves to stderr, including anything tools print themselves.
109
- ```bash
110
- autoclaw "Deploy and report" -y -n --json
111
- ```
112
- Token usage is collected only when `AUTOCLOW_INCLUDE_USAGE=1` (or `true`) is set โ€” it is opt-in because not every OpenAI-compatible provider accepts `stream_options.include_usage`.
113
-
114
- ### Batch Mode (Swarm Worker)
115
- Feed a JSONL manifest of tasks; each task runs in a fresh, isolated agent (one task's context never leaks into another) and per-task results are written as JSONL:
116
- ```bash
117
- autoclaw batch tasks.jsonl -y # results -> tasks.results.jsonl
118
- autoclaw batch tasks.jsonl -o out.jsonl --fail-fast
119
- ```
120
- Manifest lines are `{"id": "...", "task": "..."}` โ€” `id` is optional (defaults to `task-N`); blank lines and `#` comments are skipped. Optional per-task overrides: `maxSteps`, `model`, `provider`.
121
-
122
- One failing task does not stop the batch (use `--fail-fast` for that). The process exits `0` when every task completed, `1` otherwise, so cron and K8s Jobs can detect bad batches. Task output stays human-readable on stdout โ€” the results file is the machine-readable contract, with `status`, `steps`, `message`, `error` and `usage` per task.
123
-
124
- Long batches can stop and pick up where they left off, and can use local parallelism:
125
- ```bash
126
- autoclaw batch big.jsonl -y --resume # skip tasks already completed in the results file
127
- autoclaw batch big.jsonl -y -c 4 # run up to 4 tasks in parallel
128
- ```
129
- Unattempted tasks are simply absent from the results file, so `--fail-fast` followed by `--resume` is a natural retry loop.
130
-
131
- AutoClaw also keeps its own prompt lean: optional tools (web search, email, group notifications, image generation) only register once their credentials are configured, and in long loops older tool results in the model context are replaced by short excerpts.
132
-
133
- ### Recipes
134
-
135
- Daily ops sweep on Linux (crontab):
136
- ```cron
137
- 0 9 * * * autoclaw batch /opt/ops/daily.jsonl -y -n --resume >> /var/log/autoclaw.log 2>&1
138
- ```
139
-
140
- Scheduled sweep on Windows (Task Scheduler):
141
- ```bash
142
- schtasks /create /tn "AutoClaw Daily" /tr "autoclaw batch C:\ops\daily.jsonl -y -n" /sc daily /st 09:00
143
- ```
144
-
145
- Pipeline inside one manifest โ€” each task writes files the next task reads:
146
- ```jsonl
147
- {"id": "sweep", "task": "ๆฃ€ๆŸฅ็ฃ็›˜ไธŽๅ…ณ้”ฎๆœๅŠก็Šถๆ€,ๆŠฅๅ‘Šๅ†™ๅ…ฅ report/sweep.md"}
148
- {"id": "notify", "task": "่ฏปๅ– report/sweep.md,็”จไธ‰ๅฅ่ฏๆ€ป็ป“ๅŽๆŽจ้€ๅˆฐ้ฃžไนฆ"}
149
- ```
150
-
151
- Diagnostics on a fresh machine or in CI:
152
- ```bash
153
- autoclaw doctor # exit 0 = ready; exit 1 = what's missing is printed
154
- ```
155
-
156
- ### Auto-Confirm (CI/CD)
157
- Automatically approve all tool executions (dangerous, use with caution or in sandboxes).
158
- ```bash
159
- autoclaw "Refactor src/index.ts to use ES modules" -y
160
- ```
161
-
162
- ### CLI Options
163
- - `-m, --model <model>`: Specify the LLM model (default: `gpt-5.6`).
164
- - `-P, --provider <name>`: Use a provider preset (see [Providers](#providers)).
165
- - `-n, --no-interactive`: Exit after processing the initial query (Headless mode).
166
- - `-y, --yes`: Auto-confirm all tool executions (e.g., shell commands).
167
- - `--allow-dangerous`: Let `-y` run clearly destructive commands (rm -rf, format, shutdown, ...) that the built-in safety gate would block.
168
- - `--json`: Emit NDJSON events on stdout (for orchestrators; use with `-n`).
169
-
170
- ### Diagnostics
171
- `autoclaw doctor` checks everything headlessly and prints โœ“/โœ— per item: config files, resolved provider/baseUrl/model, API key, a live connection test, resolved shell, registered tools, and playwright browser status. Exit `0` = ready, `1` = a critical item failed (the failing item is printed). Ideal for CI or a fresh machine.
172
-
173
- ### Providers
174
- AutoClaw works with any OpenAI-compatible endpoint. Built-in presets fill in the base URL and a default model for you:
175
- ```bash
176
- autoclaw -P deepseek "Check disk usage and save a report" -y -n
177
- ```
178
- Available presets: `openai`, `deepseek`, `moonshot` (Kimi), `dashscope` (Qwen), `zhipu` (GLM), `ark` (Volcano Ark), `siliconflow`, `openrouter`, `ollama` (local). You can still override the model with `-m` or config. When `OPENAI_API_KEY` is not set, the API key is read from the provider's own env var (e.g. `DEEPSEEK_API_KEY`, `MOONSHOT_API_KEY`, `DASHSCOPE_API_KEY`, `ZHIPU_API_KEY`, `ARK_API_KEY`, `SILICONFLOW_API_KEY`, `OPENROUTER_API_KEY`).
179
-
180
- ## Configuration
181
-
182
- AutoClaw uses a hierarchical configuration system.
183
-
184
- **Priority Order (Highest to Lowest):**
185
- 1. **CLI Arguments**: (e.g., `-m gpt-5.6`)
186
- 2. **Environment Variables**: (`OPENAI_API_KEY`, `.env` file)
187
- 3. **Project Config**: (`./.autoclaw/setting.json` in current directory)
188
- 4. **Global Config**: (`~/.autoclaw/setting.json`)
189
-
190
- ### Supported Configuration Keys (JSON)
191
- - `provider`: Provider preset name (e.g. `deepseek`).
192
- - `apiKey`: Your OpenAI API Key.
193
- - `baseUrl`: Custom Base URL (e.g., for DeepSeek or LocalLLM).
194
- - `model`: Default model to use.
195
- - `maxSteps`: Max LLM turns per task before the agent stops (default: `25`).
196
- - `shellTimeout`: Shell command timeout in milliseconds (default: `120000`).
197
- - `shell`: Force a shell for `execute_shell_command` (`bash`, `powershell`, `cmd`, `sh`; default: auto-detect โ€” Git Bash > PowerShell > cmd on Windows).
198
- - `tavilyApiKey`: API Key for Tavily Web Search.
199
- - `smtpHost`, `smtpPort`, `smtpUser`, `smtpPass`, `smtpFrom`: SMTP Email settings.
200
- - `feishuWebhook`, `dingtalkWebhook`, `wecomWebhook`: Notification webhooks.
201
-
202
- ### Project-Level Config Example
203
- Create a file at `.autoclaw/setting.json`:
204
- ```json
205
- {
206
- "model": "gpt-5.6",
207
- "baseUrl": "https://api.deepseek.com/v1"
208
- }
209
- ```
210
-
211
- > **โš ๏ธ Security Warning**: If you store your `apiKey` or secrets in `.autoclaw/setting.json`, make sure to add `.autoclaw/` to your `.gitignore` file to prevent leaking secrets!
212
-
213
- ### Environment Variables
214
- - `OPENAI_API_KEY`, `OPENAI_BASE_URL`, `OPENAI_MODEL`: main LLM settings.
215
- - `AUTOCLOW_PROVIDER`: provider preset used when `-P` is not passed.
216
- - `AUTOCLOW_MAX_STEPS`, `AUTOCLOW_SHELL_TIMEOUT`: reliability limits (max LLM turns per task; shell timeout in ms).
217
- - `AUTOCLOW_SHELL`: force the shell for shell commands (`bash`, `powershell`, `cmd`, `sh`).
218
- - `AUTOCLOW_INCLUDE_USAGE`: set to `1`/`true` to request token usage from the API (opt-in).
219
- - `TAVILY_API_KEY`, `SMTP_HOST`/`SMTP_PORT`/`SMTP_USER`/`SMTP_PASS`, `FEISHU_WEBHOOK`/`FEISHU_KEYWORD`, `DINGTALK_WEBHOOK`/`DINGTALK_KEYWORD`, `WECOM_WEBHOOK`/`WECOM_KEYWORD`: tool credentials as an alternative to setup.
220
-
221
- ## Integrations
222
-
223
- ### Web Search (Tavily)
224
- AutoClaw can search the web if you provide a Tavily API Key during setup or in config.
225
- - **Usage**: "Search for the latest Node.js release notes."
226
-
227
- ### Email (SMTP)
228
- Configure SMTP settings to let the agent send emails.
229
- - **Usage**: "Send an email to user@example.com with the summary of the log file."
230
-
231
- ### Notifications (Feishu/DingTalk/WeCom)
232
- Configure webhooks to receive alerts or reports in your team chat apps.
233
- - **Usage**: "Notify the team on Feishu that the build has finished."
234
-
235
- ### Date & Time
236
- Built-in utility to provide the agent with the current system time, ensuring accurate handling of relative time requests.
237
- - **Usage**: "What's the date today?" or "Remind me to check the logs next Monday."
238
-
239
- ## Docker Support
240
-
241
- ### Build & Run
242
- The repository ships a multi-stage `Dockerfile` (node:22-alpine, browser downloads skipped to keep the image slim). The container runs headless one-shot tasks against the mounted directory:
243
- ```bash
244
- docker build -t autoclaw .
245
- docker run --rm -v "$PWD":/workspace -w /workspace -e OPENAI_API_KEY=sk-... autoclaw "Check disk usage and save a report" -y -n
246
- ```
247
- Note: browser-based tools (`read_website` / `take_screenshot`) are not functional in the default image since browsers are not bundled โ€” they return a friendly install hint instead.
248
-
249
- ### Chinese Font Issues in Screenshots
250
- When running AutoClaw inside a Docker container (especially Alpine or Debian Slim), screenshots of Chinese websites may display text as square boxes ("tofu") due to missing fonts. Emojis (e.g., ๐Ÿ”ฅ) may also appear as squares.
251
-
252
- **Solution:** Install CJK (Chinese/Japanese/Korean) and Emoji fonts in your container.
253
-
254
- **For Debian/Ubuntu:**
255
- ```bash
256
- apt-get update && apt-get install -y fonts-noto-cjk fonts-wqy-zenhei fonts-noto-color-emoji
257
- ```
258
-
259
- **For Alpine Linux:**
260
- ```bash
261
- apk add font-noto-cjk font-noto-emoji
262
- ```
263
-
264
- ## License
265
-
266
- MIT
267
-
268
- ## Contributing
269
-
270
- Contributions are welcome! Please feel free to submit a Pull Request.
271
-
272
- 1. Fork the Project
273
- 2. Create your Feature Branch (`git checkout -b feature/AmazingFeature`)
274
- 3. Commit your Changes (`git commit -m 'Add some AmazingFeature'`)
275
- 4. Push to the Branch (`git push origin feature/AmazingFeature`)
276
- 5. Open a Pull Request
277
-
278
- ---
279
- GitHub: [https://github.com/tsingliuwin/autoclaw](https://github.com/tsingliuwin/autoclaw)
280
-
281
- ## Star History
282
-
283
- <a href="https://www.star-history.com/?repos=tsingliuwin%2Fautoclaw&type=date&legend=top-left">
284
- <picture>
285
- <source media="(prefers-color-scheme: dark)" srcset="https://api.star-history.com/chart?repos=tsingliuwin/autoclaw&type=date&theme=dark&legend=top-left" />
286
- <source media="(prefers-color-scheme: light)" srcset="https://api.star-history.com/chart?repos=tsingliuwin/autoclaw&type=date&legend=top-left" />
287
- <img alt="Star History Chart" src="https://api.star-history.com/chart?repos=tsingliuwin/autoclaw&type=date&legend=top-left" />
288
- </picture>
289
- </a>
1
+ # AutoClaw ๐Ÿฆž
2
+
3
+ [![NPM Version](https://img.shields.io/npm/v/autoclaw.svg?style=flat-square)](https://www.npmjs.com/package/autoclaw)
4
+ [![NPM Downloads](https://img.shields.io/npm/dm/autoclaw.svg?style=flat-square)](https://www.npmjs.com/package/autoclaw)
5
+ [![GitHub](https://img.shields.io/badge/GitHub-Repository-blue?logo=github&style=flat-square)](https://github.com/tsingliuwin/autoclaw)
6
+ [![License](https://img.shields.io/npm/l/autoclaw.svg?style=flat-square)](https://github.com/tsingliuwin/autoclaw/blob/main/LICENSE)
7
+ [![Safety](https://img.shields.io/badge/Safety-Notice-yellow?style=flat-square)](./SAFETY.md)
8
+ [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](http://makeapullrequest.com)
9
+
10
+ **The Engineering-First Headless Agent Framework: Stable, Scalable Automation for the Post-Vision Era.**
11
+
12
+ English | [็ฎ€ไฝ“ไธญๆ–‡](./README.zh-CN.md)
13
+
14
+ ---
15
+
16
+ ๐Ÿ”— **GitHub Repository**: [https://github.com/tsingliuwin/autoclaw](https://github.com/tsingliuwin/autoclaw)
17
+
18
+ ---
19
+
20
+ AutoClaw is a high-stability, open-source automation framework specifically engineered for **headless systems**.
21
+
22
+ Unlike "screen-seeing" agents (such as OpenClaw) that rely on visual interpretation, AutoClaw is built on a foundation of precise command-driven execution. This makes it significantly more **stable**, **robust from an engineering perspective**, and **easier to scale** across complex environmentsโ€”whether it's a local server, a CI/CD pipeline, or thousands of containerized nodes.
23
+
24
+ ## Why AutoClaw?
25
+ - ๐Ÿณ **Docker Native**: Built to run safely inside containers. Minimal footprint (Node.js/Alpine friendly).
26
+ - ๐Ÿš€ **Better Engineering**: Operates via precise system APIs and shell commands rather than unstable visual recognition, ensuring deterministic outcomes.
27
+ - ๐Ÿ›ก๏ธ **Superior Stability**: Immune to issues like UI rendering, screen resolution, or network lag that plague vision-based agents.
28
+ - ๐Ÿ“ˆ **Massive Scalability**: Low resource consumption allows orchestrating thousands of instances (e.g., in K8s) for true automation swarms.
29
+ - ๐Ÿ”Œ **Swarm Ready**: Stateless design allows for easy orchestration via K8s, Docker Swarm, or simple shell loops.
30
+ - ๐Ÿงฉ **Extensible Integrations**: Built-in support for Web Search (Tavily), Email (SMTP), and Notification Webhooks (Feishu, DingTalk, WeCom).
31
+
32
+ ## Features
33
+
34
+ - ๐Ÿ“œ **Headless Execution**: No GUI required โ€” pure terminal efficiency. Core operation is shell + file I/O; the optional web tools run in headless Chromium.
35
+ - ๐Ÿค– **Non-Interactive Mode**: Intelligent flag handling (`-y`, `--no-interactive`) for zero-touch automation.
36
+ - ๐Ÿ“‚ **Universal Control**: From simple file I/O to complex system administration.
37
+ - ๐Ÿ–ฅ๏ธ **Background Processes**: start long-lived commands (dev servers, watchers) detached and poll their output without blocking the run.
38
+ - ๐Ÿ›ก๏ธ **Safety Rails**: destructive-command gate, credential-file guard, step cap, wall-clock timeout, and API retries โ€” designed for machines nobody is watching.
39
+ - ๐Ÿง  **Context Aware**: Provides accurate OS, system and time context so relative dates ("today", "next Monday") are handled correctly.
40
+ - ๐ŸŒ **Web Search**: Integrated with Tavily for real-time information retrieval.
41
+ - ๐ŸŒ **Web Reading & Screenshots**: Extract article content and capture page screenshots (requires `npx playwright install chromium`).
42
+ - ๐ŸŽจ **Image Generation**: DALL-E compatible image generation via any OpenAI-compatible images API.
43
+ - ๐Ÿ•’ **Time Accuracy**: Built-in tool to get precise system date and time for correct temporal context.
44
+ - ๐Ÿ“ง **Communication**: Send emails and push notifications to chat groups automatically.
45
+
46
+ ## Tech Stack
47
+ - **Runtime**: Node.js
48
+ - **Language**: TypeScript
49
+ - **Framework**: Commander.js
50
+ - **UI**: Inquirer (interactivity), Chalk (styling), Ora (spinners)
51
+ - **AI**: OpenAI SDK (any OpenAI-compatible endpoint: DeepSeek, Kimi, Qwen, GLM, Ollama, โ€ฆ)
52
+ - **Web tools**: Playwright (headless Chromium for `read_website` / `take_screenshot`)
53
+
54
+ ## Installation
55
+
56
+ ### User Installation
57
+ Install globally via npm:
58
+ ```bash
59
+ npm install -g autoclaw
60
+ ```
61
+
62
+ ### Development Installation
63
+ 1. Clone the repository:
64
+ ```bash
65
+ git clone https://github.com/tsingliuwin/autoclaw.git
66
+ cd autoclaw
67
+ ```
68
+ 2. Install dependencies:
69
+ ```bash
70
+ npm install
71
+ ```
72
+ 3. Build the project:
73
+ ```bash
74
+ npm run build
75
+ ```
76
+ 4. Link globally (optional):
77
+ ```bash
78
+ npm link
79
+ ```
80
+
81
+ ## Quick Start
82
+
83
+ 1. **Setup**: Run the interactive setup wizard to configure your API keys and integrations. The wizard runs a live connection test (failures map to the likely wrong field: 401 = key, 404 = base URL, 400 = model name) and can list the provider's models for you to pick from.
84
+ ```bash
85
+ autoclaw setup
86
+ ```
87
+ 2. **Run**: Start the agent in interactive mode.
88
+ ```bash
89
+ autoclaw
90
+ ```
91
+
92
+ ## Usage
93
+
94
+ ### Interactive Mode
95
+ Simply run `autoclaw` to enter the chat loop.
96
+ ```bash
97
+ autoclaw
98
+ > List all TypeScript files in the src folder.
99
+ ```
100
+ Interactive commands: `exit` / `quit` to leave, and `/view` to open the full output of the last tool result in a pager โ€” tool output longer than 20 lines is folded on screen and saved to `~/.autoclaw/output/`.
101
+
102
+ ### Headless Mode (One-Shot)
103
+ Run a single command and exit.
104
+ ```bash
105
+ autoclaw "Check disk usage and save the report to usage.txt" --no-interactive
106
+ ```
107
+ The exit code reports the outcome for orchestrators: `0` completed, `1` hard failure (e.g. API error), `2` step cap reached (task unfinished).
108
+
109
+ ### Machine-Readable Output (--json)
110
+ Add `--json` to print one JSON event per line on stdout (run_start, tool_call, tool_result, usage, run_end); human output moves to stderr, including anything tools print themselves.
111
+ ```bash
112
+ autoclaw "Deploy and report" -y -n --json
113
+ ```
114
+ Token usage is collected only when `AUTOCLOW_INCLUDE_USAGE=1` (or `true`) is set โ€” it is opt-in because not every OpenAI-compatible provider accepts `stream_options.include_usage`.
115
+
116
+ ### Batch Mode (Swarm Worker)
117
+ Feed a JSONL manifest of tasks; each task runs in a fresh, isolated agent (one task's context never leaks into another) and per-task results are written as JSONL:
118
+ ```bash
119
+ autoclaw batch tasks.jsonl -y # results -> tasks.results.jsonl
120
+ autoclaw batch tasks.jsonl -o out.jsonl --fail-fast
121
+ ```
122
+ Manifest lines are `{"id": "...", "task": "..."}` โ€” `id` is optional (defaults to `task-N`); blank lines and `#` comments are skipped. Optional per-task overrides: `maxSteps`, `model`, `provider`.
123
+
124
+ One failing task does not stop the batch (use `--fail-fast` for that). The process exits `0` when every task completed, `1` otherwise, so cron and K8s Jobs can detect bad batches. Task output stays human-readable on stdout โ€” the results file is the machine-readable contract, with `status`, `steps`, `message`, `error` and `usage` per task.
125
+
126
+ Long batches can stop and pick up where they left off, and can use local parallelism:
127
+ ```bash
128
+ autoclaw batch big.jsonl -y --resume # skip tasks already completed in the results file
129
+ autoclaw batch big.jsonl -y -c 4 # run up to 4 tasks in parallel
130
+ ```
131
+ Unattempted tasks are simply absent from the results file, so `--fail-fast` followed by `--resume` is a natural retry loop.
132
+
133
+ AutoClaw also keeps its own prompt lean: optional tools (web search, email, group notifications, image generation) only register once their credentials are configured, and in long loops older tool results in the model context are replaced by short excerpts.
134
+
135
+ ### Recipes
136
+
137
+ Daily ops sweep on Linux (crontab):
138
+ ```cron
139
+ 0 9 * * * autoclaw batch /opt/ops/daily.jsonl -y -n --resume >> /var/log/autoclaw.log 2>&1
140
+ ```
141
+
142
+ Scheduled sweep on Windows (Task Scheduler):
143
+ ```bash
144
+ schtasks /create /tn "AutoClaw Daily" /tr "autoclaw batch C:\ops\daily.jsonl -y -n" /sc daily /st 09:00
145
+ ```
146
+
147
+ Pipeline inside one manifest โ€” each task writes files the next task reads:
148
+ ```jsonl
149
+ {"id": "sweep", "task": "ๆฃ€ๆŸฅ็ฃ็›˜ไธŽๅ…ณ้”ฎๆœๅŠก็Šถๆ€,ๆŠฅๅ‘Šๅ†™ๅ…ฅ report/sweep.md"}
150
+ {"id": "notify", "task": "่ฏปๅ– report/sweep.md,็”จไธ‰ๅฅ่ฏๆ€ป็ป“ๅŽๆŽจ้€ๅˆฐ้ฃžไนฆ"}
151
+ ```
152
+
153
+ Diagnostics on a fresh machine or in CI:
154
+ ```bash
155
+ autoclaw doctor # exit 0 = ready; exit 1 = what's missing is printed
156
+ ```
157
+
158
+ ### Auto-Confirm (CI/CD)
159
+ Automatically approve all tool executions (dangerous, use with caution or in sandboxes).
160
+ ```bash
161
+ autoclaw "Refactor src/index.ts to use ES modules" -y
162
+ ```
163
+
164
+ ### CLI Options
165
+ - `-m, --model <model>`: Specify the LLM model (default: `gpt-5.6`).
166
+ - `-P, --provider <name>`: Use a provider preset (see [Providers](#providers)).
167
+ - `-n, --no-interactive`: Exit after processing the initial query (Headless mode).
168
+ - `-y, --yes`: Auto-confirm all tool executions (e.g., shell commands).
169
+ - `--allow-dangerous`: Let `-y` run clearly destructive commands (rm -rf, format, shutdown, ...) that the built-in safety gate would block.
170
+ - `--json`: Emit NDJSON events on stdout (for orchestrators; use with `-n`).
171
+
172
+ ### Diagnostics
173
+ `autoclaw doctor` checks everything headlessly and prints โœ“/โœ— per item: config files, resolved provider/baseUrl/model, API key, a live connection test, resolved shell, registered tools, and playwright browser status. Exit `0` = ready, `1` = a critical item failed (the failing item is printed). Ideal for CI or a fresh machine.
174
+
175
+ ### Sandbox
176
+ Command execution can be confined with `config.sandbox` / `AUTOCLOW_SANDBOX` (vocabulary borrowed from DeepSeek Harness):
177
+ - `danger-full-access` (default): commands run unconstrained.
178
+ - `workspace-write`: commands can write only inside the current working directory and `/tmp`.
179
+ - `read-only`: commands cannot write anywhere.
180
+
181
+ Backends: bubblewrap on Linux (`apt install bubblewrap`), `sandbox-exec` on macOS. **Windows has no backend yet** โ€” non-default modes fail closed (commands are refused with a clear error) instead of pretending to confine; run with `danger-full-access` there for now. Reads and network are not confined by this vocabulary.
182
+
183
+ ### Providers
184
+ AutoClaw works with any OpenAI-compatible endpoint. Built-in presets fill in the base URL and a default model for you:
185
+ ```bash
186
+ autoclaw -P deepseek "Check disk usage and save a report" -y -n
187
+ ```
188
+ Available presets: `openai`, `deepseek`, `moonshot` (Kimi), `dashscope` (Qwen), `zhipu` (GLM), `ark` (Volcano Ark), `siliconflow`, `openrouter`, `ollama` (local). You can still override the model with `-m` or config. When `OPENAI_API_KEY` is not set, the API key is read from the provider's own env var (e.g. `DEEPSEEK_API_KEY`, `MOONSHOT_API_KEY`, `DASHSCOPE_API_KEY`, `ZHIPU_API_KEY`, `ARK_API_KEY`, `SILICONFLOW_API_KEY`, `OPENROUTER_API_KEY`).
189
+
190
+ ## Configuration
191
+
192
+ AutoClaw uses a hierarchical configuration system.
193
+
194
+ **Priority Order (Highest to Lowest):**
195
+ 1. **CLI Arguments**: (e.g., `-m gpt-5.6`)
196
+ 2. **Environment Variables**: (`OPENAI_API_KEY`, `.env` file)
197
+ 3. **Project Config**: (`./.autoclaw/setting.json` in current directory)
198
+ 4. **Global Config**: (`~/.autoclaw/setting.json`)
199
+
200
+ ### Supported Configuration Keys (JSON)
201
+ - `provider`: Provider preset name (e.g. `deepseek`).
202
+ - `apiKey`: Your OpenAI API Key.
203
+ - `baseUrl`: Custom Base URL (e.g., for DeepSeek or LocalLLM).
204
+ - `model`: Default model to use.
205
+ - `maxSteps`: Max LLM turns per task before the agent stops (default: `25`).
206
+ - `shellTimeout`: Shell command timeout in milliseconds (default: `120000`).
207
+ - `taskTimeoutMs`: Whole-task wall-clock timeout in milliseconds (off by default; aborts in-flight API calls and stops with `timeout` status).
208
+ - `sandbox`: Confine shell commands (`read-only`, `workspace-write`, `danger-full-access`; default: `danger-full-access`).
209
+ - `shell`: Force a shell for `execute_shell_command` (`bash`, `powershell`, `cmd`, `sh`; default: auto-detect โ€” Git Bash > PowerShell > cmd on Windows).
210
+ - `tavilyApiKey`: API Key for Tavily Web Search.
211
+ - `smtpHost`, `smtpPort`, `smtpUser`, `smtpPass`, `smtpFrom`: SMTP Email settings.
212
+ - `feishuWebhook`, `dingtalkWebhook`, `wecomWebhook`: Notification webhooks.
213
+
214
+ ### Project-Level Config Example
215
+ Create a file at `.autoclaw/setting.json`:
216
+ ```json
217
+ {
218
+ "model": "gpt-5.6",
219
+ "baseUrl": "https://api.deepseek.com/v1"
220
+ }
221
+ ```
222
+
223
+ > **โš ๏ธ Security Warning**: If you store your `apiKey` or secrets in `.autoclaw/setting.json`, make sure to add `.autoclaw/` to your `.gitignore` file to prevent leaking secrets!
224
+
225
+ ### Environment Variables
226
+ - `OPENAI_API_KEY`, `OPENAI_BASE_URL`, `OPENAI_MODEL`: main LLM settings.
227
+ - `AUTOCLOW_PROVIDER`: provider preset used when `-P` is not passed.
228
+ - `AUTOCLOW_MAX_STEPS`, `AUTOCLOW_SHELL_TIMEOUT`: reliability limits (max LLM turns per task; shell timeout in ms).
229
+ - `AUTOCLOW_TASK_TIMEOUT_MS`: whole-task wall-clock timeout in ms.
230
+ - `AUTOCLOW_SANDBOX`: confine shell commands (`read-only`, `workspace-write`, `danger-full-access`).
231
+ - `AUTOCLOW_SHELL`: force the shell for shell commands (`bash`, `powershell`, `cmd`, `sh`).
232
+ - `AUTOCLOW_INCLUDE_USAGE`: set to `1`/`true` to request token usage from the API (opt-in).
233
+ - `TAVILY_API_KEY`, `SMTP_HOST`/`SMTP_PORT`/`SMTP_USER`/`SMTP_PASS`, `FEISHU_WEBHOOK`/`FEISHU_KEYWORD`, `DINGTALK_WEBHOOK`/`DINGTALK_KEYWORD`, `WECOM_WEBHOOK`/`WECOM_KEYWORD`: tool credentials as an alternative to setup.
234
+
235
+ ## Integrations
236
+
237
+ ### Web Search (Tavily)
238
+ AutoClaw can search the web if you provide a Tavily API Key during setup or in config.
239
+ - **Usage**: "Search for the latest Node.js release notes."
240
+
241
+ ### Email (SMTP)
242
+ Configure SMTP settings to let the agent send emails.
243
+ - **Usage**: "Send an email to user@example.com with the summary of the log file."
244
+
245
+ ### Notifications (Feishu/DingTalk/WeCom)
246
+ Configure webhooks to receive alerts or reports in your team chat apps.
247
+ - **Usage**: "Notify the team on Feishu that the build has finished."
248
+
249
+ ### Date & Time
250
+ Built-in utility to provide the agent with the current system time, ensuring accurate handling of relative time requests.
251
+ - **Usage**: "What's the date today?" or "Remind me to check the logs next Monday."
252
+
253
+ ## Docker Support
254
+
255
+ ### Build & Run
256
+ The repository ships a multi-stage `Dockerfile` (node:22-alpine, browser downloads skipped to keep the image slim). The container runs headless one-shot tasks against the mounted directory:
257
+ ```bash
258
+ docker build -t autoclaw .
259
+ docker run --rm -v "$PWD":/workspace -w /workspace -e OPENAI_API_KEY=sk-... autoclaw "Check disk usage and save a report" -y -n
260
+ ```
261
+ Note: browser-based tools (`read_website` / `take_screenshot`) are not functional in the default image since browsers are not bundled โ€” they return a friendly install hint instead.
262
+
263
+ ### Chinese Font Issues in Screenshots
264
+ When running AutoClaw inside a Docker container (especially Alpine or Debian Slim), screenshots of Chinese websites may display text as square boxes ("tofu") due to missing fonts. Emojis (e.g., ๐Ÿ”ฅ) may also appear as squares.
265
+
266
+ **Solution:** Install CJK (Chinese/Japanese/Korean) and Emoji fonts in your container.
267
+
268
+ **For Debian/Ubuntu:**
269
+ ```bash
270
+ apt-get update && apt-get install -y fonts-noto-cjk fonts-wqy-zenhei fonts-noto-color-emoji
271
+ ```
272
+
273
+ **For Alpine Linux:**
274
+ ```bash
275
+ apk add font-noto-cjk font-noto-emoji
276
+ ```
277
+
278
+ ## License
279
+
280
+ MIT
281
+
282
+ ## Contributing
283
+
284
+ Contributions are welcome! Please feel free to submit a Pull Request.
285
+
286
+ 1. Fork the Project
287
+ 2. Create your Feature Branch (`git checkout -b feature/AmazingFeature`)
288
+ 3. Commit your Changes (`git commit -m 'Add some AmazingFeature'`)
289
+ 4. Push to the Branch (`git push origin feature/AmazingFeature`)
290
+ 5. Open a Pull Request
291
+
292
+ ---
293
+ GitHub: [https://github.com/tsingliuwin/autoclaw](https://github.com/tsingliuwin/autoclaw)
294
+
295
+ ## Star History
296
+
297
+ <a href="https://www.star-history.com/?repos=tsingliuwin%2Fautoclaw&type=date&legend=top-left">
298
+ <picture>
299
+ <source media="(prefers-color-scheme: dark)" srcset="https://api.star-history.com/chart?repos=tsingliuwin/autoclaw&type=date&theme=dark&legend=top-left" />
300
+ <source media="(prefers-color-scheme: light)" srcset="https://api.star-history.com/chart?repos=tsingliuwin/autoclaw&type=date&legend=top-left" />
301
+ <img alt="Star History Chart" src="https://api.star-history.com/chart?repos=tsingliuwin/autoclaw&type=date&legend=top-left" />
302
+ </picture>
303
+ </a>