autoclaw 1.3.4 โ†’ 1.3.6

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.
Files changed (37) hide show
  1. package/README.md +356 -291
  2. package/README.zh-CN.md +69 -4
  3. package/dist/agent.js +47 -2
  4. package/dist/index.js +75 -1
  5. package/dist/sandbox.js +94 -0
  6. package/dist/shell.js +55 -32
  7. package/dist/skills.js +276 -0
  8. package/dist/tools/background.js +165 -0
  9. package/dist/tools/core.js +17 -1
  10. package/dist/tools/index.js +9 -1
  11. package/dist/tools/render-image.js +135 -0
  12. package/dist/tools/render-pdf.js +111 -0
  13. package/dist/tools/takumi-fonts.js +61 -0
  14. package/dist/zip.js +149 -0
  15. package/package.json +5 -2
  16. package/skills/code2media/SKILL.md +82 -0
  17. package/skills/code2media/references/syntax-guide.md +63 -0
  18. package/skills/code2media/scripts/package.json +10 -0
  19. package/skills/code2media/scripts/render.mjs +177 -0
  20. package/skills/code2media/templates/animation.html +19 -0
  21. package/skills/code2media/templates/badge.html +6 -0
  22. package/skills/code2media/templates/certificate.html +9 -0
  23. package/skills/code2media/templates/metrics-card.html +25 -0
  24. package/skills/code2media/templates/weekly-report.html +86 -0
  25. package/skills/invoice-maker/SKILL.md +65 -0
  26. package/skills/invoice-maker/references/syntax-guide.md +63 -0
  27. package/skills/invoice-maker/scripts/package.json +10 -0
  28. package/skills/invoice-maker/scripts/render.mjs +177 -0
  29. package/skills/invoice-maker/templates/invoice.html +26 -0
  30. package/skills/invoice-maker/templates/quote.html +68 -0
  31. package/skills/poster-maker/SKILL.md +62 -0
  32. package/skills/poster-maker/references/syntax-guide.md +63 -0
  33. package/skills/poster-maker/scripts/package.json +10 -0
  34. package/skills/poster-maker/scripts/render.mjs +177 -0
  35. package/skills/poster-maker/templates/cover.html +13 -0
  36. package/skills/poster-maker/templates/og-card.html +17 -0
  37. package/skills/poster-maker/templates/social-post.html +14 -0
package/README.md CHANGED
@@ -1,291 +1,356 @@
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
- - `taskTimeoutMs`: Whole-task wall-clock timeout in milliseconds (off by default; aborts in-flight API calls and stops with `timeout` status).
198
- - `shell`: Force a shell for `execute_shell_command` (`bash`, `powershell`, `cmd`, `sh`; default: auto-detect โ€” Git Bash > PowerShell > cmd on Windows).
199
- - `tavilyApiKey`: API Key for Tavily Web Search.
200
- - `smtpHost`, `smtpPort`, `smtpUser`, `smtpPass`, `smtpFrom`: SMTP Email settings.
201
- - `feishuWebhook`, `dingtalkWebhook`, `wecomWebhook`: Notification webhooks.
202
-
203
- ### Project-Level Config Example
204
- Create a file at `.autoclaw/setting.json`:
205
- ```json
206
- {
207
- "model": "gpt-5.6",
208
- "baseUrl": "https://api.deepseek.com/v1"
209
- }
210
- ```
211
-
212
- > **โš ๏ธ 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!
213
-
214
- ### Environment Variables
215
- - `OPENAI_API_KEY`, `OPENAI_BASE_URL`, `OPENAI_MODEL`: main LLM settings.
216
- - `AUTOCLOW_PROVIDER`: provider preset used when `-P` is not passed.
217
- - `AUTOCLOW_MAX_STEPS`, `AUTOCLOW_SHELL_TIMEOUT`: reliability limits (max LLM turns per task; shell timeout in ms).
218
- - `AUTOCLOW_TASK_TIMEOUT_MS`: whole-task wall-clock timeout in ms.
219
- - `AUTOCLOW_SHELL`: force the shell for shell commands (`bash`, `powershell`, `cmd`, `sh`).
220
- - `AUTOCLOW_INCLUDE_USAGE`: set to `1`/`true` to request token usage from the API (opt-in).
221
- - `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.
222
-
223
- ## Integrations
224
-
225
- ### Web Search (Tavily)
226
- AutoClaw can search the web if you provide a Tavily API Key during setup or in config.
227
- - **Usage**: "Search for the latest Node.js release notes."
228
-
229
- ### Email (SMTP)
230
- Configure SMTP settings to let the agent send emails.
231
- - **Usage**: "Send an email to user@example.com with the summary of the log file."
232
-
233
- ### Notifications (Feishu/DingTalk/WeCom)
234
- Configure webhooks to receive alerts or reports in your team chat apps.
235
- - **Usage**: "Notify the team on Feishu that the build has finished."
236
-
237
- ### Date & Time
238
- Built-in utility to provide the agent with the current system time, ensuring accurate handling of relative time requests.
239
- - **Usage**: "What's the date today?" or "Remind me to check the logs next Monday."
240
-
241
- ## Docker Support
242
-
243
- ### Build & Run
244
- 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:
245
- ```bash
246
- docker build -t autoclaw .
247
- docker run --rm -v "$PWD":/workspace -w /workspace -e OPENAI_API_KEY=sk-... autoclaw "Check disk usage and save a report" -y -n
248
- ```
249
- 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.
250
-
251
- ### Chinese Font Issues in Screenshots
252
- 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.
253
-
254
- **Solution:** Install CJK (Chinese/Japanese/Korean) and Emoji fonts in your container.
255
-
256
- **For Debian/Ubuntu:**
257
- ```bash
258
- apt-get update && apt-get install -y fonts-noto-cjk fonts-wqy-zenhei fonts-noto-color-emoji
259
- ```
260
-
261
- **For Alpine Linux:**
262
- ```bash
263
- apk add font-noto-cjk font-noto-emoji
264
- ```
265
-
266
- ## License
267
-
268
- MIT
269
-
270
- ## Contributing
271
-
272
- Contributions are welcome! Please feel free to submit a Pull Request.
273
-
274
- 1. Fork the Project
275
- 2. Create your Feature Branch (`git checkout -b feature/AmazingFeature`)
276
- 3. Commit your Changes (`git commit -m 'Add some AmazingFeature'`)
277
- 4. Push to the Branch (`git push origin feature/AmazingFeature`)
278
- 5. Open a Pull Request
279
-
280
- ---
281
- GitHub: [https://github.com/tsingliuwin/autoclaw](https://github.com/tsingliuwin/autoclaw)
282
-
283
- ## Star History
284
-
285
- <a href="https://www.star-history.com/?repos=tsingliuwin%2Fautoclaw&type=date&legend=top-left">
286
- <picture>
287
- <source media="(prefers-color-scheme: dark)" srcset="https://api.star-history.com/chart?repos=tsingliuwin/autoclaw&type=date&theme=dark&legend=top-left" />
288
- <source media="(prefers-color-scheme: light)" srcset="https://api.star-history.com/chart?repos=tsingliuwin/autoclaw&type=date&legend=top-left" />
289
- <img alt="Star History Chart" src="https://api.star-history.com/chart?repos=tsingliuwin/autoclaw&type=date&legend=top-left" />
290
- </picture>
291
- </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
+ - ๐Ÿ–ผ๏ธ **Deterministic Image Rendering** (`render_image`): HTML + Tailwind templates rendered into PNG/JPEG/WebP/SVG, plus animations (animated WebP/GIF/APNG from CSS `@keyframes`). Fully offline, no browser, milliseconds per render โ€” for OG cards, banners, badges and data cards where exact text and layout matter.
44
+ - ๐Ÿ“„ **PDF Rendering** (`render_pdf`): HTML templates rendered into paged PDFs with selectable text, repeating headers/footers and page counters. Fully offline, no browser โ€” for invoices, reports and certificates.
45
+ - ๐Ÿ•’ **Time Accuracy**: Built-in tool to get precise system date and time for correct temporal context.
46
+ - ๐Ÿ“ง **Communication**: Send emails and push notifications to chat groups automatically.
47
+
48
+ ## Tech Stack
49
+ - **Runtime**: Node.js
50
+ - **Language**: TypeScript
51
+ - **Framework**: Commander.js
52
+ - **UI**: Inquirer (interactivity), Chalk (styling), Ora (spinners)
53
+ - **AI**: OpenAI SDK (any OpenAI-compatible endpoint: DeepSeek, Kimi, Qwen, GLM, Ollama, โ€ฆ)
54
+ - **Web tools**: Playwright (headless Chromium for `read_website` / `take_screenshot`)
55
+ - **Rendering**: Takumi (Rust engine via native binding โ€” powers `render_image` / `render_pdf`, no browser)
56
+
57
+ ## Installation
58
+
59
+ ### User Installation
60
+ Install globally via npm:
61
+ ```bash
62
+ npm install -g autoclaw
63
+ ```
64
+
65
+ ### Development Installation
66
+ 1. Clone the repository:
67
+ ```bash
68
+ git clone https://github.com/tsingliuwin/autoclaw.git
69
+ cd autoclaw
70
+ ```
71
+ 2. Install dependencies:
72
+ ```bash
73
+ npm install
74
+ ```
75
+ 3. Build the project:
76
+ ```bash
77
+ npm run build
78
+ ```
79
+ 4. Link globally (optional):
80
+ ```bash
81
+ npm link
82
+ ```
83
+
84
+ ## Quick Start
85
+
86
+ 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.
87
+ ```bash
88
+ autoclaw setup
89
+ ```
90
+ 2. **Run**: Start the agent in interactive mode.
91
+ ```bash
92
+ autoclaw
93
+ ```
94
+
95
+ ## Usage
96
+
97
+ ### Interactive Mode
98
+ Simply run `autoclaw` to enter the chat loop.
99
+ ```bash
100
+ autoclaw
101
+ > List all TypeScript files in the src folder.
102
+ ```
103
+ 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/`.
104
+
105
+ ### Headless Mode (One-Shot)
106
+ Run a single command and exit.
107
+ ```bash
108
+ autoclaw "Check disk usage and save the report to usage.txt" --no-interactive
109
+ ```
110
+ The exit code reports the outcome for orchestrators: `0` completed, `1` hard failure (e.g. API error), `2` step cap reached (task unfinished).
111
+
112
+ ### Machine-Readable Output (--json)
113
+ 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.
114
+ ```bash
115
+ autoclaw "Deploy and report" -y -n --json
116
+ ```
117
+ 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`.
118
+
119
+ ### Batch Mode (Swarm Worker)
120
+ 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:
121
+ ```bash
122
+ autoclaw batch tasks.jsonl -y # results -> tasks.results.jsonl
123
+ autoclaw batch tasks.jsonl -o out.jsonl --fail-fast
124
+ ```
125
+ 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`.
126
+
127
+ 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.
128
+
129
+ Long batches can stop and pick up where they left off, and can use local parallelism:
130
+ ```bash
131
+ autoclaw batch big.jsonl -y --resume # skip tasks already completed in the results file
132
+ autoclaw batch big.jsonl -y -c 4 # run up to 4 tasks in parallel
133
+ ```
134
+ Unattempted tasks are simply absent from the results file, so `--fail-fast` followed by `--resume` is a natural retry loop.
135
+
136
+ 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.
137
+
138
+ ### Skills (Portable Capability Packages)
139
+ AutoClaw runs `SKILL.md` skill packages โ€” the same format used by the WorkBuddy skill store, so one package runs both inside AutoClaw and on other platforms. The system prompt only carries a one-line manifest per skill; when a task matches, the agent reads that skill's `SKILL.md` and follows it with the normal file and shell tools. There is no privileged runtime: skill scripts pass through the same destructive-command gate, sandbox and step caps as any command.
140
+
141
+ Scopes (later shadows earlier on name collision): built-in `skills/` (ships with the npm package) โ†’ `~/.autoclaw/skills/` โ†’ `.autoclaw/skills/`.
142
+
143
+ ```bash
144
+ autoclaw skill list # show discovered skills with scope and version
145
+ autoclaw skill install <zip|dir|https-url> # install into ~/.autoclaw/skills/ (zip-slip protected)
146
+ autoclaw skill remove <name> # remove a user-installed skill (built-ins are protected)
147
+ autoclaw skill pack <dir> # zip a skill dir (skills/<name>/ root) for store upload
148
+ ```
149
+
150
+ Install accepts any SKILL.md-compatible package: a local directory, a local zip, or an https download URL. It tolerates third-party layout variance (SKILL.md at the zip root, a plain folder, or a `skills/<name>/` wrapper, macOS `__MACOSX`/`.DS_Store` junk) and always installs under the skill's frontmatter `name`, so discovery and the manifest stay consistent.
151
+
152
+ Three built-in skills, layered: [`code2media`](skills/code2media/SKILL.md) (Code to Media) is the universal rendering engine โ€” a standalone Node script turning any HTML into images/SVG/paged PDFs/animations; [`poster-maker`](skills/poster-maker/SKILL.md) and [`invoice-maker`](skills/invoice-maker/SKILL.md) are independently optimized scenario skills carrying platform size specs, document layout conventions and quality checklists. The same zips publish to any SKILL.md-compatible store. Skills compose with batch mode: one manifest line like `{"id":"inv-042","task":"็”จ invoice-maker ๆŠ€่ƒฝๆ นๆฎ orders-042.json ็”Ÿๆˆๅ‘็ฅจ invoices/042.pdf"}` drives an isolated swarm worker through the same skill.
153
+
154
+ ### Recipes
155
+
156
+ Daily ops sweep on Linux (crontab):
157
+ ```cron
158
+ 0 9 * * * autoclaw batch /opt/ops/daily.jsonl -y -n --resume >> /var/log/autoclaw.log 2>&1
159
+ ```
160
+
161
+ Scheduled sweep on Windows (Task Scheduler):
162
+ ```bash
163
+ schtasks /create /tn "AutoClaw Daily" /tr "autoclaw batch C:\ops\daily.jsonl -y -n" /sc daily /st 09:00
164
+ ```
165
+
166
+ Pipeline inside one manifest โ€” each task writes files the next task reads:
167
+ ```jsonl
168
+ {"id": "sweep", "task": "ๆฃ€ๆŸฅ็ฃ็›˜ไธŽๅ…ณ้”ฎๆœๅŠก็Šถๆ€,ๆŠฅๅ‘Šๅ†™ๅ…ฅ report/sweep.md"}
169
+ {"id": "notify", "task": "่ฏปๅ– report/sweep.md,็”จไธ‰ๅฅ่ฏๆ€ป็ป“ๅŽๆŽจ้€ๅˆฐ้ฃžไนฆ"}
170
+ ```
171
+
172
+ Diagnostics on a fresh machine or in CI:
173
+ ```bash
174
+ autoclaw doctor # exit 0 = ready; exit 1 = what's missing is printed
175
+ ```
176
+
177
+ ### Auto-Confirm (CI/CD)
178
+ Automatically approve all tool executions (dangerous, use with caution or in sandboxes).
179
+ ```bash
180
+ autoclaw "Refactor src/index.ts to use ES modules" -y
181
+ ```
182
+
183
+ ### CLI Options
184
+ - `-m, --model <model>`: Specify the LLM model (default: `gpt-5.6`).
185
+ - `-P, --provider <name>`: Use a provider preset (see [Providers](#providers)).
186
+ - `-n, --no-interactive`: Exit after processing the initial query (Headless mode).
187
+ - `-y, --yes`: Auto-confirm all tool executions (e.g., shell commands).
188
+ - `--allow-dangerous`: Let `-y` run clearly destructive commands (rm -rf, format, shutdown, ...) that the built-in safety gate would block.
189
+ - `--json`: Emit NDJSON events on stdout (for orchestrators; use with `-n`).
190
+
191
+ ### Diagnostics
192
+ `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.
193
+
194
+ ### Sandbox
195
+ Command execution can be confined with `config.sandbox` / `AUTOCLOW_SANDBOX` (vocabulary borrowed from DeepSeek Harness):
196
+ - `danger-full-access` (default): commands run unconstrained.
197
+ - `workspace-write`: commands can write only inside the current working directory and `/tmp`.
198
+ - `read-only`: commands cannot write anywhere.
199
+
200
+ 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.
201
+
202
+ ### Providers
203
+ AutoClaw works with any OpenAI-compatible endpoint. Built-in presets fill in the base URL and a default model for you:
204
+ ```bash
205
+ autoclaw -P deepseek "Check disk usage and save a report" -y -n
206
+ ```
207
+ 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`).
208
+
209
+ ## Configuration
210
+
211
+ AutoClaw uses a hierarchical configuration system.
212
+
213
+ **Priority Order (Highest to Lowest):**
214
+ 1. **CLI Arguments**: (e.g., `-m gpt-5.6`)
215
+ 2. **Environment Variables**: (`OPENAI_API_KEY`, `.env` file)
216
+ 3. **Project Config**: (`./.autoclaw/setting.json` in current directory)
217
+ 4. **Global Config**: (`~/.autoclaw/setting.json`)
218
+
219
+ ### Supported Configuration Keys (JSON)
220
+ - `provider`: Provider preset name (e.g. `deepseek`).
221
+ - `apiKey`: Your OpenAI API Key.
222
+ - `baseUrl`: Custom Base URL (e.g., for DeepSeek or LocalLLM).
223
+ - `model`: Default model to use.
224
+ - `maxSteps`: Max LLM turns per task before the agent stops (default: `25`).
225
+ - `shellTimeout`: Shell command timeout in milliseconds (default: `120000`).
226
+ - `taskTimeoutMs`: Whole-task wall-clock timeout in milliseconds (off by default; aborts in-flight API calls and stops with `timeout` status).
227
+ - `sandbox`: Confine shell commands (`read-only`, `workspace-write`, `danger-full-access`; default: `danger-full-access`).
228
+ - `skillsEnabled`: Set `false` to disable the skill system (default: `true`).
229
+ - `shell`: Force a shell for `execute_shell_command` (`bash`, `powershell`, `cmd`, `sh`; default: auto-detect โ€” Git Bash > PowerShell > cmd on Windows).
230
+ - `tavilyApiKey`: API Key for Tavily Web Search.
231
+ - `smtpHost`, `smtpPort`, `smtpUser`, `smtpPass`, `smtpFrom`: SMTP Email settings.
232
+ - `feishuWebhook`, `dingtalkWebhook`, `wecomWebhook`: Notification webhooks.
233
+
234
+ ### Project-Level Config Example
235
+ Create a file at `.autoclaw/setting.json`:
236
+ ```json
237
+ {
238
+ "model": "gpt-5.6",
239
+ "baseUrl": "https://api.deepseek.com/v1"
240
+ }
241
+ ```
242
+
243
+ > **โš ๏ธ 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!
244
+
245
+ ### Environment Variables
246
+ - `OPENAI_API_KEY`, `OPENAI_BASE_URL`, `OPENAI_MODEL`: main LLM settings.
247
+ - `AUTOCLOW_PROVIDER`: provider preset used when `-P` is not passed.
248
+ - `AUTOCLOW_MAX_STEPS`, `AUTOCLOW_SHELL_TIMEOUT`: reliability limits (max LLM turns per task; shell timeout in ms).
249
+ - `AUTOCLOW_TASK_TIMEOUT_MS`: whole-task wall-clock timeout in ms.
250
+ - `AUTOCLOW_SANDBOX`: confine shell commands (`read-only`, `workspace-write`, `danger-full-access`).
251
+ - `AUTOCLOW_SHELL`: force the shell for shell commands (`bash`, `powershell`, `cmd`, `sh`).
252
+ - `AUTOCLOW_INCLUDE_USAGE`: set to `1`/`true` to request token usage from the API (opt-in).
253
+ - `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.
254
+
255
+ ## Integrations
256
+
257
+ ### Web Search (Tavily)
258
+ AutoClaw can search the web if you provide a Tavily API Key during setup or in config.
259
+ - **Usage**: "Search for the latest Node.js release notes."
260
+
261
+ ### Email (SMTP)
262
+ Configure SMTP settings to let the agent send emails.
263
+ - **Usage**: "Send an email to user@example.com with the summary of the log file."
264
+
265
+ ### Notifications (Feishu/DingTalk/WeCom)
266
+ Configure webhooks to receive alerts or reports in your team chat apps.
267
+ - **Usage**: "Notify the team on Feishu that the build has finished."
268
+
269
+ ### Date & Time
270
+ Built-in utility to provide the agent with the current system time, ensuring accurate handling of relative time requests.
271
+ - **Usage**: "What's the date today?" or "Remind me to check the logs next Monday."
272
+
273
+ ### Deterministic Rendering (Takumi)
274
+ `render_image` turns HTML templates into precise images โ€” PNG, JPEG, WebP or vector SVG โ€” offline with no browser or AI model involved. `render_pdf` turns HTML templates into paged PDFs with selectable text, repeating header/footer bands, and `<span class="pageNumber">` / `<span class="totalPages">` counters. Templates are styled with inline CSS, `<style>` blocks, or Tailwind v4 utilities via the `tw` attribute (`<div tw="w-full h-full bg-blue-500">`); plain `class` attributes only match regular CSS selectors. Both tools auto-detect common system fonts (CJK/emoji included); register specific font files via `font_paths`.
275
+
276
+ Typical workflows โ€” describe the job in natural language and the agent writes the templates itself:
277
+
278
+ ```bash
279
+ # Blog SEO: one OG share image per post
280
+ autoclaw "Read the title and summary of every .md file in content/posts/ and render an OG share image (1200x630) for each into public/og/" -y -n
281
+
282
+ # Finance / e-commerce: invoice PDFs from an orders export, then email them out
283
+ autoclaw "Read orders.csv, render a PDF invoice for each order into invoices/ (A4, page-number footer), then email every invoice to the customer address in its row" -y
284
+
285
+ # HR / training: personalized completion certificates for an attendee list
286
+ autoclaw "Read attendees.json and render a completion certificate (1414x1000) for each attendee into certs/, numbered from AC-2026-0001" -y -n
287
+
288
+ # Ops reporting under cron/CI: deterministic output โ€” same input produces the same PDF
289
+ autoclaw "Aggregate this week's nginx access log into a one-page A4 PDF report with a metrics table and save it as report.pdf" -y -n
290
+ ```
291
+
292
+ Swarm scale via batch mode โ€” each task renders in its own isolated agent:
293
+
294
+ ```bash
295
+ cat > render-jobs.jsonl <<'EOF'
296
+ {"id": "og-001", "task": "Render an OG share image for post-001.md into public/og/001.png"}
297
+ {"id": "og-002", "task": "Render an OG share image for post-002.md into public/og/002.png"}
298
+ EOF
299
+ autoclaw batch render-jobs.jsonl -y -c 4
300
+ ```
301
+
302
+ Tool choice: use `render_image` / `render_pdf` when exact text, layout and branding matter (cards, banners, badges, documents); use `generate_image` for artistic or photographic imagery. Emoji in templates are fetched from the Twemoji CDN by default, so fully offline environments should keep templates text-only.
303
+
304
+ Runnable examples with committed previews: [examples/render](examples/render/README.md) (OG cards, social posters, KPI cards, weekly-report PDFs, SVG badges, certificates, animations, multi-page invoices โ€” plus a real agent one-shot run under `agent-run/`). The same capability ships as a portable [WorkBuddy skill](skills/code2media/SKILL.md) (`code2media-skill.zip`) that renders HTML โ†’ image/SVG/PDF/animation via a standalone Node script on any machine with Node >= 20.19.
305
+
306
+ ## Docker Support
307
+
308
+ ### Build & Run
309
+ 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:
310
+ ```bash
311
+ docker build -t autoclaw .
312
+ docker run --rm -v "$PWD":/workspace -w /workspace -e OPENAI_API_KEY=sk-... autoclaw "Check disk usage and save a report" -y -n
313
+ ```
314
+ 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.
315
+
316
+ ### Chinese Font Issues in Screenshots and Rendered Output
317
+ 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. The same affects `render_image` / `render_pdf` output containing CJK text.
318
+
319
+ **Solution:** Install CJK (Chinese/Japanese/Korean) and Emoji fonts in your container. The render tools auto-detect the same font paths, so installing these packages fixes both screenshots and rendered images/PDFs.
320
+
321
+ **For Debian/Ubuntu:**
322
+ ```bash
323
+ apt-get update && apt-get install -y fonts-noto-cjk fonts-wqy-zenhei fonts-noto-color-emoji
324
+ ```
325
+
326
+ **For Alpine Linux:**
327
+ ```bash
328
+ apk add font-noto-cjk font-noto-emoji
329
+ ```
330
+
331
+ ## License
332
+
333
+ MIT
334
+
335
+ ## Contributing
336
+
337
+ Contributions are welcome! Please feel free to submit a Pull Request.
338
+
339
+ 1. Fork the Project
340
+ 2. Create your Feature Branch (`git checkout -b feature/AmazingFeature`)
341
+ 3. Commit your Changes (`git commit -m 'Add some AmazingFeature'`)
342
+ 4. Push to the Branch (`git push origin feature/AmazingFeature`)
343
+ 5. Open a Pull Request
344
+
345
+ ---
346
+ GitHub: [https://github.com/tsingliuwin/autoclaw](https://github.com/tsingliuwin/autoclaw)
347
+
348
+ ## Star History
349
+
350
+ <a href="https://www.star-history.com/?repos=tsingliuwin%2Fautoclaw&type=date&legend=top-left">
351
+ <picture>
352
+ <source media="(prefers-color-scheme: dark)" srcset="https://api.star-history.com/chart?repos=tsingliuwin/autoclaw&type=date&theme=dark&legend=top-left" />
353
+ <source media="(prefers-color-scheme: light)" srcset="https://api.star-history.com/chart?repos=tsingliuwin/autoclaw&type=date&legend=top-left" />
354
+ <img alt="Star History Chart" src="https://api.star-history.com/chart?repos=tsingliuwin/autoclaw&type=date&legend=top-left" />
355
+ </picture>
356
+ </a>