Skip to content

Commit 98a6bb4

Browse files
committed
Docs: dual engine guide, 18 providers catalog, base URL examples
- Recommend Claude Code CLI engine as primary (reuses subscription) - Document builtin engine with all 18 providers and 25+ models - Add custom base URL examples for Anthropic/OpenAI/Google formats - Add tool mapping table, mixed engine config, API format reference - Update architecture diagrams to show engine dispatch layer - Sync Chinese README with same updates
1 parent 083a3d6 commit 98a6bb4

2 files changed

Lines changed: 526 additions & 32 deletions

File tree

README.md

Lines changed: 261 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ Pure-shell AI agent runtime. No Node.js, no Python, no compiled binaries.
2222
<a href="#features">Features</a> &middot;
2323
<a href="#web-dashboard">Dashboard</a> &middot;
2424
<a href="#providers">Providers</a> &middot;
25+
<a href="#engines">Engines</a> &middot;
2526
<a href="#channels">Channels</a> &middot;
2627
<a href="#architecture">Architecture</a> &middot;
2728
<a href="README_CN.md">&#x4E2D;&#x6587;</a>
@@ -45,6 +46,23 @@ cd bashclaw && ./bashclaw doctor
4546

4647
## Quick Start
4748

49+
### Recommended: Claude Code CLI Engine
50+
51+
If you have a [Claude Code](https://docs.anthropic.com/en/docs/claude-code) subscription (Pro/Max/Team/Enterprise), BashClaw can use it directly as its backend -- no API keys, no per-token cost:
52+
53+
```sh
54+
bashclaw config set '.agents.defaults.engine' '"claude"'
55+
56+
bashclaw agent -m "What is the mass of the sun?" # one-shot
57+
bashclaw agent -i # interactive REPL
58+
```
59+
60+
This delegates all reasoning and tool execution to the `claude` CLI, reusing your existing subscription.
61+
62+
### Alternative: Builtin Engine with API Keys
63+
64+
For other providers or if you prefer direct API access:
65+
4866
```sh
4967
export ANTHROPIC_API_KEY="sk-ant-..." # or OPENAI_API_KEY, GOOGLE_API_KEY, etc.
5068

@@ -90,7 +108,8 @@ BashClaw targets Bash 3.2 deliberately: no `declare -A`, no `mapfile`, no `|&`.
90108

91109
- **Pure shell** -- Zero dependencies beyond bash 3.2, curl, jq. Already on your machine.
92110
- **Self-modifying** -- Agent hot-patches its own source at runtime. No compilation step.
93-
- **Multi-provider** -- 9 providers: Claude, GPT, Gemini, DeepSeek, Qwen, Zhipu GLM, Moonshot, MiniMax, OpenRouter.
111+
- **Dual engine** -- Claude Code CLI (reuses subscription) or builtin (direct API via curl). Per-agent configurable.
112+
- **Multi-provider** -- 18 providers: Claude, GPT, Gemini, DeepSeek, Qwen, Zhipu, Moonshot, MiniMax, Groq, xAI, Mistral, Ollama, vLLM, and more.
94113
- **Multi-channel** -- Telegram, Discord, Slack, Feishu/Lark. Each channel is one shell script.
95114
- **Web dashboard** -- Built-in browser UI for chat, config, and monitoring. No external tools.
96115
- **14 built-in tools** -- Web fetch, search, shell exec, memory, cron, file I/O, inter-agent messaging.
@@ -173,7 +192,32 @@ PUT /api/env Save API keys
173192

174193
## Providers
175194

176-
BashClaw supports 9 providers with data-driven routing. Adding a provider is a JSON entry -- no code changes.
195+
The builtin engine supports 18 providers with data-driven routing. All configuration is in `lib/models.json` -- adding a provider is a JSON entry, no code changes.
196+
197+
### Pre-configured Providers and Models
198+
199+
BashClaw ships with 25+ pre-configured models. Set the API key and go:
200+
201+
| Provider | API Key Env | Pre-configured Models | API Format |
202+
|----------|------------|----------------------|------------|
203+
| **Anthropic** | `ANTHROPIC_API_KEY` | claude-opus-4-6, claude-sonnet-4, claude-haiku-3 | Anthropic |
204+
| **OpenAI** | `OPENAI_API_KEY` | gpt-4o, gpt-4o-mini, o1, o3-mini | OpenAI |
205+
| **Google** | `GOOGLE_API_KEY` | gemini-2.0-flash, gemini-2.0-flash-lite, gemini-1.5-pro | Google |
206+
| **DeepSeek** | `DEEPSEEK_API_KEY` | deepseek-chat, deepseek-reasoner | OpenAI |
207+
| **Qwen** | `QWEN_API_KEY` | qwen-max, qwen-plus, qwq-plus | OpenAI |
208+
| **Zhipu** | `ZHIPU_API_KEY` | glm-5, glm-4-flash | OpenAI |
209+
| **Moonshot** | `MOONSHOT_API_KEY` | kimi-k2.5 | OpenAI |
210+
| **MiniMax** | `MINIMAX_API_KEY` | MiniMax-M2.5, MiniMax-M2.1 | OpenAI |
211+
| **Xiaomi** | `XIAOMI_API_KEY` | mimo-v2-flash | Anthropic |
212+
| **Baidu Qianfan** | `QIANFAN_API_KEY` | deepseek-v3.2, ernie-5.0-thinking-preview | OpenAI |
213+
| **NVIDIA** | `NVIDIA_API_KEY` | llama-3.1-nemotron-70b | OpenAI |
214+
| **Groq** | `GROQ_API_KEY` | llama-3.3-70b-versatile | OpenAI |
215+
| **xAI** | `XAI_API_KEY` | grok-3 | OpenAI |
216+
| **Mistral** | `MISTRAL_API_KEY` | mistral-large-latest | OpenAI |
217+
| **OpenRouter** | `OPENROUTER_API_KEY` | any model via OpenRouter | OpenAI |
218+
| **Together** | `TOGETHER_API_KEY` | any model via Together | OpenAI |
219+
| **Ollama** | -- | any local model | OpenAI |
220+
| **vLLM** | -- | any local model | OpenAI |
177221

178222
```sh
179223
# Anthropic (default)
@@ -213,11 +257,15 @@ MODEL_ID=glm-5 bashclaw agent -m "hello"
213257

214258
# Moonshot Kimi
215259
export MOONSHOT_API_KEY="sk-..."
216-
MODEL_ID=kimi-2.5 bashclaw agent -m "hello"
260+
MODEL_ID=kimi-k2.5 bashclaw agent -m "hello"
217261

218262
# MiniMax
219263
export MINIMAX_API_KEY="..."
220-
MODEL_ID=minimax-2.5 bashclaw agent -m "hello"
264+
MODEL_ID=MiniMax-M2.5 bashclaw agent -m "hello"
265+
266+
# Baidu Qianfan
267+
export QIANFAN_API_KEY="..."
268+
MODEL_ID=ernie-5.0-thinking-preview bashclaw agent -m "hello"
221269
```
222270

223271
</details>
@@ -226,19 +274,211 @@ MODEL_ID=minimax-2.5 bashclaw agent -m "hello"
226274
<summary><strong>Model aliases</strong></summary>
227275

228276
```sh
229-
MODEL_ID=fast # -> gemini-2.0-flash
230-
MODEL_ID=smart # -> claude-opus-4
277+
MODEL_ID=smart # -> claude-opus-4-6
231278
MODEL_ID=balanced # -> claude-sonnet-4
279+
MODEL_ID=fast # -> gemini-2.0-flash
232280
MODEL_ID=cheap # -> gpt-4o-mini
281+
MODEL_ID=opus # -> claude-opus-4-6
282+
MODEL_ID=sonnet # -> claude-sonnet-4
283+
MODEL_ID=haiku # -> claude-haiku-3
284+
MODEL_ID=gpt # -> gpt-4o
285+
MODEL_ID=gemini # -> gemini-2.0-flash
233286
MODEL_ID=deepseek # -> deepseek-chat
234287
MODEL_ID=qwen # -> qwen-max
235288
MODEL_ID=glm # -> glm-5
236-
MODEL_ID=kimi # -> kimi-2.5
237-
MODEL_ID=minimax # -> minimax-2.5
289+
MODEL_ID=kimi # -> kimi-k2.5
290+
MODEL_ID=minimax # -> MiniMax-M2.5
291+
MODEL_ID=grok # -> grok-3
292+
MODEL_ID=mistral # -> mistral-large-latest
238293
```
239294

240295
</details>
241296

297+
### Custom Base URL
298+
299+
Every provider supports base URL override via environment variable. This is useful for proxies, private deployments, or self-hosted models:
300+
301+
```sh
302+
# Anthropic-format endpoint (e.g., proxy or compatible service)
303+
export ANTHROPIC_API_KEY="your-key"
304+
export ANTHROPIC_BASE_URL="https://your-proxy.example.com/v1"
305+
bashclaw agent -m "hello"
306+
307+
# OpenAI-format endpoint (e.g., Azure OpenAI, LiteLLM, or any compatible service)
308+
export OPENAI_API_KEY="your-key"
309+
export OPENAI_BASE_URL="https://your-endpoint.example.com/v1"
310+
MODEL_ID=gpt-4o bashclaw agent -m "hello"
311+
312+
# Google-format endpoint
313+
export GOOGLE_API_KEY="your-key"
314+
export GOOGLE_AI_BASE_URL="https://your-proxy.example.com/v1beta"
315+
MODEL_ID=gemini-2.0-flash bashclaw agent -m "hello"
316+
317+
# Local Ollama (no API key needed)
318+
export OLLAMA_BASE_URL="http://localhost:11434/v1"
319+
MODEL_ID=llama3.3 bashclaw agent -m "hello"
320+
321+
# Local vLLM server
322+
export VLLM_BASE_URL="http://127.0.0.1:8000/v1"
323+
MODEL_ID=your-model bashclaw agent -m "hello"
324+
325+
# OpenRouter (access any model through a single API)
326+
export OPENROUTER_API_KEY="sk-or-..."
327+
MODEL_ID=meta-llama/llama-3.3-70b-instruct bashclaw agent -m "hello"
328+
```
329+
330+
If you provide a base URL without the version path (e.g., `http://localhost:8000`), BashClaw auto-appends `/v1` (or `/v1beta` for Google).
331+
332+
### Three API Formats
333+
334+
The builtin engine supports three API formats. Most providers use OpenAI-compatible format:
335+
336+
| Format | Endpoint | Providers |
337+
|--------|----------|-----------|
338+
| **Anthropic** | `POST /v1/messages` | Anthropic, Xiaomi |
339+
| **OpenAI** | `POST /v1/chat/completions` | OpenAI, DeepSeek, Qwen, Zhipu, Moonshot, MiniMax, Groq, xAI, Mistral, OpenRouter, Ollama, vLLM, Qianfan, NVIDIA, Together |
340+
| **Google** | `POST /v1beta/models/{model}:generateContent` | Google |
341+
342+
Any service that implements one of these formats works out of the box.
343+
344+
## Engines
345+
346+
BashClaw has a pluggable engine layer that determines how agent tasks are executed. Each agent can use a different engine.
347+
348+
### Claude Engine (Recommended)
349+
350+
The **claude** engine delegates execution to [Claude Code CLI](https://docs.anthropic.com/en/docs/claude-code). It reuses your existing Claude subscription -- no API keys needed, no per-token cost.
351+
352+
```sh
353+
# Set claude as the default engine
354+
bashclaw config set '.agents.defaults.engine' '"claude"'
355+
356+
# Use it
357+
bashclaw agent -m "Refactor this function for readability"
358+
```
359+
360+
**How it works:**
361+
- Invokes `claude -p --output-format json` as a subprocess
362+
- Claude Code handles the tool loop with its native tools (Read, Write, Bash, Glob, Grep, etc.)
363+
- BashClaw-specific tools (memory, cron, spawn, agent_message) are bridged via `bashclaw tool <name>` CLI calls
364+
- Session state tracked in both BashClaw JSONL and Claude Code's native session
365+
- Hooks bridged via `--settings` JSON injection
366+
367+
**Requirements:** `claude` CLI installed and authenticated (`claude login`).
368+
369+
<details>
370+
<summary><strong>Claude engine configuration</strong></summary>
371+
372+
```json
373+
{
374+
"agents": {
375+
"defaults": {
376+
"engine": "claude",
377+
"maxTurns": 50
378+
},
379+
"list": [
380+
{
381+
"id": "coder",
382+
"engine": "claude",
383+
"engineModel": "opus",
384+
"maxTurns": 30
385+
}
386+
]
387+
}
388+
}
389+
```
390+
391+
| Config Field | Description |
392+
|-------------|-------------|
393+
| `engine` | `"claude"` to use Claude Code CLI |
394+
| `engineModel` | Override model (e.g. `"opus"`, `"sonnet"`, `"haiku"`). If empty, uses your subscription's default. |
395+
| `maxTurns` | Max agentic turns per invocation |
396+
397+
| Environment Variable | Default | Purpose |
398+
|---------------------|---------|---------|
399+
| `ENGINE_CLAUDE_TIMEOUT` | `300` | Timeout (seconds) for Claude CLI execution |
400+
| `ENGINE_CLAUDE_MODEL` | -- | Override model (alternative to `engineModel` in config) |
401+
402+
</details>
403+
404+
### Builtin Engine
405+
406+
The **builtin** engine calls LLM APIs directly via curl. It supports 18 providers and 25+ pre-configured models, and works with any OpenAI-compatible endpoint.
407+
408+
```sh
409+
# Builtin is the default engine (no config change needed)
410+
export ANTHROPIC_API_KEY="sk-ant-..."
411+
bashclaw agent -m "hello"
412+
```
413+
414+
**How it works:**
415+
- Calls provider APIs directly (Anthropic, OpenAI, Google, and 15 more)
416+
- Runs BashClaw's own tool loop (max iterations configurable via `maxTurns`)
417+
- Handles context overflow with automatic compaction, model fallback, and session reset
418+
- Three API formats: Anthropic (`/v1/messages`), OpenAI-compatible (`/v1/chat/completions`), Google (`/v1beta/.../generateContent`)
419+
420+
### Auto Engine
421+
422+
Set `engine` to `"auto"` to let BashClaw detect: uses `claude` if the CLI is installed, otherwise falls back to `builtin`.
423+
424+
```sh
425+
bashclaw config set '.agents.defaults.engine' '"auto"'
426+
```
427+
428+
### Tool Mapping (Claude Engine)
429+
430+
When using the Claude engine, BashClaw tools are mapped to Claude Code's native equivalents where possible. Tools without a native counterpart are bridged through the CLI:
431+
432+
| BashClaw Tool | Claude Code Tool | Method |
433+
|---------------|-----------------|--------|
434+
| `web_fetch` | WebFetch | native |
435+
| `web_search` | WebSearch | native |
436+
| `shell` | Bash | native |
437+
| `read_file` | Read | native |
438+
| `write_file` | Write | native |
439+
| `list_files` | Glob | native |
440+
| `file_search` | Grep | native |
441+
| `memory` | -- | `bashclaw tool memory` |
442+
| `cron` | -- | `bashclaw tool cron` |
443+
| `agent_message` | -- | `bashclaw tool agent_message` |
444+
| `spawn` | -- | `bashclaw tool spawn` |
445+
446+
### Mixed Engine Configuration
447+
448+
Different agents can use different engines:
449+
450+
```json
451+
{
452+
"agents": {
453+
"defaults": { "engine": "claude" },
454+
"list": [
455+
{
456+
"id": "coder",
457+
"engine": "claude",
458+
"engineModel": "opus"
459+
},
460+
{
461+
"id": "chat",
462+
"engine": "builtin",
463+
"model": "gpt-4o"
464+
},
465+
{
466+
"id": "local",
467+
"engine": "builtin",
468+
"model": "llama-3.3-70b-versatile"
469+
}
470+
]
471+
}
472+
}
473+
```
474+
475+
**Both engines share the same:**
476+
- Lifecycle hooks (before_agent_start, pre_message, post_message, agent_end)
477+
- Session persistence (JSONL)
478+
- Workspace loading (SOUL.md, MEMORY.md, BOOT.md, IDENTITY.md)
479+
- Security layer (rate limiting, tool policies, RBAC)
480+
- Config format (`maxTurns`, tool allow/deny lists, tool profiles)
481+
242482
## Channels
243483

244484
Each channel is a standalone shell script under `channels/`.
@@ -308,12 +548,14 @@ bashclaw gateway
308548
+------+------+ +-------+-------+ +-------+-------+
309549
| Channels | | Core Engine | | Background |
310550
+------+------+ +-------+-------+ +-------+-------+
311-
| telegram.sh | | agent.sh | | heartbeat.sh |
312-
| discord.sh | | routing.sh | | cron.sh |
313-
| slack.sh | | session.sh | | events.sh |
314-
| feishu.sh | | tools.sh (14) | | process.sh |
315-
| (plugins) | | memory.sh | | daemon.sh |
316-
+-------------+ | config.sh | +---------------+
551+
| telegram.sh | | engine.sh | | heartbeat.sh |
552+
| discord.sh | | +- agent.sh | | cron.sh |
553+
| slack.sh | | +- claude.sh| | events.sh |
554+
| feishu.sh | | routing.sh | | process.sh |
555+
| (plugins) | | session.sh | | daemon.sh |
556+
+-------------+ | tools.sh (14) | +---------------+
557+
| memory.sh |
558+
| config.sh |
317559
+---------------+
318560
|
319561
+------------------------+------------------------+
@@ -345,6 +587,9 @@ Security Gate (rate limit -> pairing -> tool policy -> RBAC)
345587
Process Queue (main: 4, cron: 1, subagent: 8 concurrent lanes)
346588
|
347589
v
590+
Engine Dispatch (builtin: direct API | claude: Claude Code CLI)
591+
|
592+
v
348593
Agent Runtime
349594
1. Resolve model + provider (data-driven, models.json)
350595
2. Load workspace (SOUL.md, MEMORY.md, BOOT.md, IDENTITY.md)
@@ -365,6 +610,8 @@ bashclaw/
365610
install.sh # standalone installer
366611
lib/
367612
agent.sh # agent runtime, model/provider dispatch
613+
engine.sh # engine abstraction (builtin / claude / auto)
614+
engine_claude.sh # Claude Code CLI engine integration
368615
config.sh # JSON config (jq-based)
369616
session.sh # JSONL session persistence
370617
routing.sh # 7-level message routing

0 commit comments

Comments
 (0)