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 +303 -289
- package/README.zh-CN.md +15 -1
- package/dist/agent.js +92 -7
- package/dist/batch.js +2 -0
- package/dist/index.js +5 -4
- package/dist/sandbox.js +94 -0
- package/dist/shell.js +55 -32
- package/dist/tools/background.js +165 -0
- package/dist/tools/core.js +44 -3
- package/dist/tools/index.js +5 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,289 +1,303 @@
|
|
|
1
|
-
# AutoClaw ๐ฆ
|
|
2
|
-
|
|
3
|
-
[](https://www.npmjs.com/package/autoclaw)
|
|
4
|
-
[](https://www.npmjs.com/package/autoclaw)
|
|
5
|
-
[](https://github.com/tsingliuwin/autoclaw)
|
|
6
|
-
[](https://github.com/tsingliuwin/autoclaw/blob/main/LICENSE)
|
|
7
|
-
[](https://www.npmjs.com/package/autoclaw)
|
|
4
|
+
[](https://www.npmjs.com/package/autoclaw)
|
|
5
|
+
[](https://github.com/tsingliuwin/autoclaw)
|
|
6
|
+
[](https://github.com/tsingliuwin/autoclaw/blob/main/LICENSE)
|
|
7
|
+
[](./SAFETY.md)
|
|
8
|
+
[](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>
|