bajaclaw 0.14.20 → 0.14.22
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 +503 -116
- package/dist/cli.js +20 -7
- package/dist/cli.js.map +1 -1
- package/dist/commands/chat.js +10 -1
- package/dist/commands/chat.js.map +1 -1
- package/dist/commands/setup.js +85 -1
- package/dist/commands/setup.js.map +1 -1
- package/dist/prompt.d.ts +1 -0
- package/dist/prompt.js +15 -0
- package/dist/prompt.js.map +1 -1
- package/package.json +1 -1
- package/scripts/postinstall.js +44 -9
package/README.md
CHANGED
|
@@ -7,14 +7,30 @@
|
|
|
7
7
|
██╔══██╗██╔══██║██ ██║██╔══██║ ██║ ██║ ██╔══██║██║███╗██║
|
|
8
8
|
██████╔╝██║ ██║╚█████╔╝██║ ██║ ╚██████╗███████╗██║ ██║╚███╔███╔╝
|
|
9
9
|
╚═════╝ ╚═╝ ╚═╝ ╚════╝ ╚═╝ ╚═╝ ╚═════╝╚══════╝╚═╝ ╚═╝ ╚══╝╚══╝
|
|
10
|
-
autonomous agents on your terms · MIT · v0.14.
|
|
10
|
+
autonomous agents on your terms · MIT · v0.14.22
|
|
11
11
|
```
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
## What BajaClaw is
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
BajaClaw is an agentic wrapper around the [Claude Code](https://claude.com/claude-code) CLI. It turns the one-shot `claude -p <prompt>` command into a long-running autonomous agent with persistent memory, matched skills, a schedule, chat channels, a local dashboard, and full MCP integration.
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
Every cycle is a subprocess of the real `claude` CLI. BajaClaw never calls the Anthropic API directly and never sees credentials. Whatever Anthropic login the `claude` CLI is using, the BajaClaw agent is using. No separate API key, no separate subscription, no extra rate limit. If Claude Code works on the account, BajaClaw works on the account.
|
|
18
|
+
|
|
19
|
+
Around that subprocess, BajaClaw adds:
|
|
20
|
+
|
|
21
|
+
- **Persistent memory.** An FTS5 full-text index of facts, decisions, preferences, todos, and references. Every non-Haiku cycle extracts new memories automatically. Every subsequent cycle pulls the top matches into the prompt as context.
|
|
22
|
+
- **Skill matching.** Each cycle scores installed skills against the task body and injects the top matches as `# Active Skills` in the prompt. Compatible with the Claude Code `SKILL.md` format plus `openclaw` and `hermes` variants.
|
|
23
|
+
- **OS-native scheduling.** Heartbeat cycles run on `launchd`, `systemd`, `cron`, or `schtasks`, depending on the host. Agents keep working when no terminal is open.
|
|
24
|
+
- **Chat channels.** Two-way bridges to Telegram and Discord. Inbound messages become tasks; outbound replies route back through the same channel. Photos and videos land as attachments the agent can read directly.
|
|
25
|
+
- **Local dashboard.** A single-page HTML UI at `http://localhost:7337` with a live cycle feed, in-browser chat, memory search, clickable cycle drilldown, task queue, schedule editor, skill inventory, channel config, and a settings form.
|
|
26
|
+
- **MCP integration, both ways.** BajaClaw exposes its own MCP server with resources (profiles, memories, cycles, schedules) and tools (memory search, task create, agent status, skill list). It is also an MCP consumer and can inherit or port servers from Claude Code.
|
|
27
|
+
- **OpenAI-compatible HTTP endpoint.** `bajaclaw serve` exposes `/v1/chat/completions`, so Cursor, Open WebUI, LibreChat, LangChain, the `openai` SDK, or any tool that speaks the OpenAI API can drive the agent.
|
|
28
|
+
- **Auto-routing between Haiku, Sonnet, and Opus.** New profiles default to `model: auto`. A heuristic classifier routes trivial tasks to Haiku, normal work to Sonnet, and planning/coding/deep research to Opus. Zero extra backend calls for the routing decision.
|
|
29
|
+
- **Self-configuration.** BajaClaw ships with built-in setup guides for Telegram, Discord, memory sync, MCP porting, heartbeat scheduling, model switching, and more. If the procedure for setting something up is unclear, ask the agent in plain language ("help me set up Telegram"). The matching guide fires, and the agent walks through the full configuration, running the correct `bajaclaw` subcommands as needed. The same guides are available at the CLI via `bajaclaw guide <topic>`.
|
|
30
|
+
|
|
31
|
+
Each agent is a self-contained directory. Delete the directory, that agent is gone. Back it up, it's portable.
|
|
32
|
+
|
|
33
|
+
---
|
|
18
34
|
|
|
19
35
|
## Install
|
|
20
36
|
|
|
@@ -22,215 +38,586 @@ Named after Baja Blast. The dashboard is that same teal on purpose.
|
|
|
22
38
|
npm install -g bajaclaw
|
|
23
39
|
```
|
|
24
40
|
|
|
25
|
-
|
|
41
|
+
On unix terminals, the postinstall hook opens `/dev/tty` and runs the interactive setup wizard directly. It asks for:
|
|
42
|
+
|
|
43
|
+
- Agent name and the name the agent calls you
|
|
44
|
+
- Voice/tone (concise, friendly, formal, playful, etc.)
|
|
45
|
+
- Timezone
|
|
46
|
+
- Focus (one or two sentences on what the agent is for)
|
|
47
|
+
- Topics of interest and hard "don't" rules
|
|
48
|
+
- Memory compaction schedule
|
|
49
|
+
- Default model and effort level
|
|
50
|
+
- Telegram and Discord channels (optional, can skip and add later)
|
|
26
51
|
|
|
27
|
-
|
|
52
|
+
On Windows, CI, or environments without a controlling terminal, the postinstall falls back to a silent scaffold. The first interactive `bajaclaw` run will then launch the wizard automatically.
|
|
28
53
|
|
|
29
|
-
|
|
54
|
+
**Requirements:** Node 22+, and the [`claude` CLI](https://docs.claude.com/en/docs/claude-code/setup) on `PATH`. BajaClaw drives the CLI as a subprocess and inherits its authentication.
|
|
55
|
+
|
|
56
|
+
**Bleeding edge:** `npm install -g github:backyarddd/BajaClaw` installs from main and runs the `prepare` script to build `dist/`.
|
|
57
|
+
|
|
58
|
+
To rerun the wizard later or repair a broken install:
|
|
59
|
+
|
|
60
|
+
```
|
|
61
|
+
bajaclaw setup --interactive
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
---
|
|
30
65
|
|
|
31
66
|
## First run
|
|
32
67
|
|
|
33
68
|
```
|
|
34
|
-
bajaclaw chat # interactive REPL
|
|
35
|
-
bajaclaw start # run one cycle
|
|
69
|
+
bajaclaw chat # interactive REPL with the default agent
|
|
70
|
+
bajaclaw start # run one scheduled cycle
|
|
36
71
|
bajaclaw dashboard # http://localhost:7337
|
|
37
|
-
bajaclaw daemon start #
|
|
72
|
+
bajaclaw daemon start # always-on background supervisor
|
|
38
73
|
```
|
|
39
74
|
|
|
40
|
-
The default profile has full tool access
|
|
75
|
+
The default profile has full tool access (`Read`, `Write`, `Edit`, `Bash`, `Grep`, `Glob`, `WebSearch`, `WebFetch`, plus any MCP tools), `model: auto`, `effort: max`, and a 10-minute per-cycle timeout. To tighten, edit `~/.bajaclaw/profiles/default/config.json`.
|
|
76
|
+
|
|
77
|
+
Or let the agent configure itself:
|
|
78
|
+
|
|
79
|
+
```
|
|
80
|
+
bajaclaw chat
|
|
81
|
+
> help me tighten the tool list to just Read, Write, Edit, and Bash
|
|
82
|
+
```
|
|
41
83
|
|
|
42
84
|
More: [docs/chat.md](docs/chat.md), [docs/commands.md](docs/commands.md).
|
|
43
85
|
|
|
44
|
-
|
|
86
|
+
---
|
|
45
87
|
|
|
46
|
-
|
|
88
|
+
## How a cycle works
|
|
47
89
|
|
|
48
|
-
|
|
90
|
+
A BajaClaw cycle is 13 steps. Defined in [`src/agent.ts`](src/agent.ts).
|
|
49
91
|
|
|
50
|
-
|
|
92
|
+
1. Load the profile config
|
|
93
|
+
2. Open the SQLite DB and apply migrations
|
|
94
|
+
3. Check the circuit breaker and rate limiter
|
|
95
|
+
4. Pop the next pending task (or use the heartbeat default)
|
|
96
|
+
5. Full-text recall the top relevant memories
|
|
97
|
+
6. Load `AGENT.md`, `SOUL.md`, `HEARTBEAT.md`
|
|
98
|
+
7. Score all skills against the task, inject the top matches
|
|
99
|
+
8. Merge the MCP config (user + profile + desktop if enabled)
|
|
100
|
+
9. Assemble the final prompt
|
|
101
|
+
10. Exec `claude -p` with `--model`, `--effort`, `--allowedTools`, `--disallowedTools`, `--mcp-config`, `--output-format json`
|
|
102
|
+
11. Parse the response, persist the cycle row
|
|
103
|
+
12. Extract 0-5 durable memories into the FTS index (skipped for Haiku)
|
|
104
|
+
13. Dispatch follow-ups (channel replies, queued tasks, reflection)
|
|
51
105
|
|
|
52
|
-
|
|
106
|
+
Run one manually:
|
|
53
107
|
|
|
54
108
|
```
|
|
55
|
-
bajaclaw
|
|
56
|
-
bajaclaw
|
|
109
|
+
bajaclaw start # execute against the default profile
|
|
110
|
+
bajaclaw start --dry-run # print the assembled prompt + argv, no exec
|
|
111
|
+
bajaclaw start researcher # different profile
|
|
57
112
|
```
|
|
58
113
|
|
|
59
|
-
|
|
114
|
+
Cycles are idempotent and safe to re-run. Deep dive: [docs/architecture.md](docs/architecture.md).
|
|
60
115
|
|
|
61
|
-
|
|
116
|
+
---
|
|
62
117
|
|
|
63
|
-
##
|
|
118
|
+
## Auto model routing
|
|
119
|
+
|
|
120
|
+
New profiles default to `model: auto`. A heuristic classifier runs before each cycle and routes the task:
|
|
121
|
+
|
|
122
|
+
| tier | when it fires | budget |
|
|
123
|
+
|--------|---------------------------------------------------------------------|---------------------------------|
|
|
124
|
+
| Haiku | triage, status checks, heartbeats, very short tasks | 3 memories, 1 skill |
|
|
125
|
+
| Sonnet | normal questions, summaries, small edits | 5 memories, 2 skills |
|
|
126
|
+
| Opus | planning, coding, refactoring, deep research, reflection | 7 memories, 3 skills |
|
|
64
127
|
|
|
65
|
-
|
|
128
|
+
Haiku cycles skip post-cycle memory extraction and auto-skill synthesis to keep cheap tasks cheap.
|
|
129
|
+
|
|
130
|
+
Override per profile:
|
|
66
131
|
|
|
67
132
|
```
|
|
68
|
-
bajaclaw
|
|
69
|
-
bajaclaw
|
|
70
|
-
bajaclaw
|
|
133
|
+
bajaclaw model # show current + list known
|
|
134
|
+
bajaclaw model auto # route per task
|
|
135
|
+
bajaclaw model claude-opus-4-7 # pin to a single model
|
|
136
|
+
bajaclaw effort max # biggest turn budget
|
|
71
137
|
```
|
|
72
138
|
|
|
73
|
-
|
|
139
|
+
---
|
|
74
140
|
|
|
75
|
-
|
|
141
|
+
## Profiles and templates
|
|
76
142
|
|
|
77
|
-
|
|
143
|
+
A profile is an agent. It has its own database, skills, schedule, logs, channels, and persona. Default comes scaffolded during install.
|
|
78
144
|
|
|
79
|
-
|
|
145
|
+
```
|
|
146
|
+
bajaclaw init researcher --template research
|
|
147
|
+
bajaclaw init triage --template support
|
|
148
|
+
bajaclaw init coder --template code
|
|
149
|
+
bajaclaw profile list
|
|
150
|
+
bajaclaw start researcher # run a cycle for one
|
|
151
|
+
BAJACLAW_PROFILE=triage bajaclaw daemon start # or pin via env
|
|
152
|
+
```
|
|
80
153
|
|
|
81
|
-
|
|
154
|
+
Templates:
|
|
82
155
|
|
|
83
|
-
|
|
156
|
+
| template | shape |
|
|
157
|
+
|------------|---------------------------------------------------------------------------|
|
|
158
|
+
| `custom` | blank slate, full tools (the default) |
|
|
159
|
+
| `research` | research + synthesis + artifact writing, full tools |
|
|
160
|
+
| `outreach` | email prospecting and drafting |
|
|
161
|
+
| `support` | inbox triage and reply drafts |
|
|
162
|
+
| `social` | content drafting and scheduling |
|
|
163
|
+
| `code` | orchestrator that delegates to a read-only coding sub-agent |
|
|
84
164
|
|
|
165
|
+
More: [docs/agents.md](docs/agents.md).
|
|
166
|
+
|
|
167
|
+
---
|
|
168
|
+
|
|
169
|
+
## Memory
|
|
170
|
+
|
|
171
|
+
Every cycle full-text-queries the profile's `memories` table against the current task text and injects the top matches as `# Recalled Memories`. After the cycle, a 1-turn Haiku pass reads the (task, response) pair and emits up to 5 structured facts:
|
|
172
|
+
|
|
173
|
+
```json
|
|
174
|
+
{
|
|
175
|
+
"memories": [
|
|
176
|
+
{ "kind": "decision", "content": "Use PostgreSQL 16 for the new service." },
|
|
177
|
+
{ "kind": "fact", "content": "Alice owns the billing pipeline." },
|
|
178
|
+
{ "kind": "preference", "content": "User prefers tabs over spaces in config files." }
|
|
179
|
+
]
|
|
180
|
+
}
|
|
85
181
|
```
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
182
|
+
|
|
183
|
+
Those facts become FTS-indexed rows with `source=cycle` and `source_cycle_id=<id>`. Kinds are a soft taxonomy: `fact`, `decision`, `preference`, `todo`, `reference`, `claude-code`, `imported`.
|
|
184
|
+
|
|
185
|
+
**Compaction.** The pool is auto-compacted so recall stays sharp. Defaults to both triggers: when the pool hits 75% of the 200k reference context, or daily at 00:00 UTC. Configurable in `config.json`:
|
|
186
|
+
|
|
187
|
+
```json
|
|
188
|
+
{
|
|
189
|
+
"compaction": {
|
|
190
|
+
"enabled": true,
|
|
191
|
+
"schedule": "both",
|
|
192
|
+
"threshold": 0.75,
|
|
193
|
+
"dailyAtUtc": "00:00",
|
|
194
|
+
"keepRecentPerKind": 25,
|
|
195
|
+
"pruneCycleDays": 30
|
|
196
|
+
}
|
|
197
|
+
}
|
|
89
198
|
```
|
|
90
199
|
|
|
91
|
-
|
|
200
|
+
**Claude Code memory sync** (opt-in). Set `"memorySync": true` in the profile config and BajaClaw will ingest new files from `~/.claude/memory/` before each cycle and write a digest to `~/.claude/memory/bajaclaw-<profile>.md` after each cycle, so Claude Code sessions see what BajaClaw has been learning.
|
|
92
201
|
|
|
93
|
-
|
|
202
|
+
More: [docs/memory.md](docs/memory.md), [docs/compaction.md](docs/compaction.md).
|
|
203
|
+
|
|
204
|
+
---
|
|
94
205
|
|
|
95
|
-
|
|
206
|
+
## Skills
|
|
207
|
+
|
|
208
|
+
A skill is a `SKILL.md` file with YAML frontmatter plus a markdown body. Drop one into a skill directory and the matcher picks it up on the next cycle.
|
|
96
209
|
|
|
97
210
|
```
|
|
98
|
-
bajaclaw
|
|
99
|
-
bajaclaw
|
|
211
|
+
bajaclaw skill list # what's loaded
|
|
212
|
+
bajaclaw skill new my-skill # scaffold a new one
|
|
213
|
+
bajaclaw skill install clawhub:<slug> # from the ClawHub registry
|
|
214
|
+
bajaclaw skill install <url> # from a tarball/zip/URL
|
|
215
|
+
bajaclaw skill install <local-path> # from a local dir
|
|
216
|
+
bajaclaw skill search <query> # search ClawHub
|
|
217
|
+
bajaclaw skill port # copy from ~/.claude/skills
|
|
218
|
+
bajaclaw skill port --link # symlink (live sync from Claude Code)
|
|
100
219
|
```
|
|
101
220
|
|
|
102
|
-
|
|
221
|
+
**Matching rules.** A skill is scored against the task text. Trigger phrase hit: +5. Name token hit: +2. Description token hit: +1. Top N (where N depends on model tier) are injected.
|
|
222
|
+
|
|
223
|
+
**Directory priority** (highest wins):
|
|
103
224
|
|
|
104
|
-
|
|
225
|
+
| priority | path |
|
|
226
|
+
|----------|----------------------------------------------|
|
|
227
|
+
| 1 | `<claude-agent-dir>/skills/` |
|
|
228
|
+
| 2 | `~/.bajaclaw/profiles/<name>/skills/` |
|
|
229
|
+
| 3 | `~/.bajaclaw/skills/` |
|
|
230
|
+
| 4 | `<repo>/skills/` (built-in) |
|
|
105
231
|
|
|
106
|
-
|
|
232
|
+
`~/.claude/skills/` is **not** read automatically. Use `bajaclaw skill port` to copy them in or `--link` to symlink.
|
|
107
233
|
|
|
234
|
+
**Auto-generated skills.** After any cycle that uses 5+ tools (configurable), BajaClaw asks the backend whether the procedure is worth saving. If yes, it writes a structured `SKILL.md` (When to use / Quick reference / Procedure / Pitfalls / Verification) and activates it immediately for future cycles.
|
|
235
|
+
|
|
236
|
+
```json
|
|
237
|
+
{
|
|
238
|
+
"autoSkill": {
|
|
239
|
+
"enabled": true,
|
|
240
|
+
"minToolUses": 5,
|
|
241
|
+
"maxPerDay": 10
|
|
242
|
+
}
|
|
243
|
+
}
|
|
108
244
|
```
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
245
|
+
|
|
246
|
+
**Foreign-format compat.** `SKILL.md` files from the `openclaw` and `hermes` ecosystems are read in their native metadata layouts (no conversion required). See [docs/skills.md](docs/skills.md).
|
|
247
|
+
|
|
248
|
+
---
|
|
249
|
+
|
|
250
|
+
## Channels (Telegram and Discord)
|
|
251
|
+
|
|
252
|
+
Connect the agent to a chat platform so it can be reached from a phone.
|
|
253
|
+
|
|
254
|
+
```
|
|
255
|
+
bajaclaw channel add default telegram --token <BOT_TOKEN>
|
|
256
|
+
bajaclaw channel add default discord --token <BOT_TOKEN> --channel-id <ID> --user-id <YOUR_ID>
|
|
257
|
+
bajaclaw channel list default
|
|
258
|
+
bajaclaw channel remove default telegram
|
|
113
259
|
```
|
|
114
260
|
|
|
115
|
-
|
|
261
|
+
For Telegram, `--user-id` is the numeric ID from `@userinfobot`; it's stored as the allowlist. For Discord, `--channel-id` is the server channel; `--user-id` is optional and restricts who the bot responds to.
|
|
116
262
|
|
|
117
|
-
|
|
263
|
+
Inbound messages (from allowlisted senders) are normalized into the tasks queue. The daemon picks them up on the next poll. Outbound replies route back through the same channel. Typing indicators appear while cycles run.
|
|
118
264
|
|
|
119
|
-
|
|
265
|
+
**Image and video attachments.** Telegram and Discord adapters download inline photos, image documents, videos, video notes, and video documents to a tmp path. Videos are pre-processed with `ffmpeg` and `ffprobe` into 8 evenly spaced frames. The agent receives the file paths in the task body and reads them with its `Read` tool.
|
|
120
266
|
|
|
121
|
-
|
|
267
|
+
**Live feedback on Sonnet/Opus channel cycles.** For multi-step tasks that route to Sonnet or Opus, the agent sends a short plan acknowledgment in its own voice before starting work, then optional milestone pings while it runs (capped at 3 per cycle). Short questions skip the ack and go straight to the final reply. The typing indicator stays on through both the pings and the final reply.
|
|
122
268
|
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
| Sonnet | normal work, answers, summaries |
|
|
127
|
-
| Opus | planning, coding, refactoring, deep research |
|
|
269
|
+
More: [docs/channels.md](docs/channels.md). Guided setup: `bajaclaw guide telegram` or `bajaclaw guide discord`.
|
|
270
|
+
|
|
271
|
+
---
|
|
128
272
|
|
|
129
|
-
|
|
273
|
+
## Scheduling and heartbeat
|
|
274
|
+
|
|
275
|
+
BajaClaw runs cycles on a schedule via OS-native scheduling.
|
|
130
276
|
|
|
131
277
|
```
|
|
132
|
-
bajaclaw
|
|
133
|
-
|
|
134
|
-
bajaclaw
|
|
278
|
+
bajaclaw daemon install # writes launchd plist (macOS) / systemd unit (linux)
|
|
279
|
+
# / cron entry / schtasks (windows)
|
|
280
|
+
bajaclaw daemon uninstall # removes the scheduler entry
|
|
281
|
+
bajaclaw daemon start # run the supervisor loop in the foreground
|
|
282
|
+
bajaclaw daemon stop # stop a background supervisor
|
|
283
|
+
bajaclaw daemon status # show pid + uptime
|
|
284
|
+
bajaclaw daemon logs # tail daemon.log
|
|
135
285
|
```
|
|
136
286
|
|
|
137
|
-
|
|
287
|
+
The heartbeat default prompt is "Heartbeat check. Review state, note anything worth action, and return a brief summary." Override by editing `HEARTBEAT.md` in the profile directory or adding cron-syntax schedule entries:
|
|
138
288
|
|
|
139
|
-
|
|
289
|
+
```
|
|
290
|
+
# ~/.bajaclaw/profiles/default/HEARTBEAT.md
|
|
291
|
+
*/30 * * * * | Check the inbox for new support emails and triage them.
|
|
292
|
+
0 9 * * 1-5 | Draft a morning summary of active projects.
|
|
293
|
+
```
|
|
140
294
|
|
|
141
|
-
|
|
295
|
+
More: [docs/heartbeat.md](docs/heartbeat.md).
|
|
142
296
|
|
|
143
|
-
|
|
297
|
+
---
|
|
144
298
|
|
|
145
299
|
## Dashboard
|
|
146
300
|
|
|
147
301
|
```
|
|
148
|
-
bajaclaw dashboard
|
|
302
|
+
bajaclaw dashboard # http://localhost:7337
|
|
149
303
|
```
|
|
150
304
|
|
|
151
|
-
|
|
305
|
+
A single HTML file served by an in-process HTTP server. Nine views via sidebar navigation:
|
|
306
|
+
|
|
307
|
+
- **Overview.** Stat cards (cycles today/week, spend, tokens, memories), recent cycles, pending tasks.
|
|
308
|
+
- **Chat.** In-browser chat with the agent. Each message shows model, duration, cost, tokens, cycle id. History is persisted in `localStorage`.
|
|
309
|
+
- **Cycles.** Recent history. Rows are clickable and open a drawer with the full task body, prompt preview, response, raw error text, model, cost, tokens, timing, and the originating task row if the cycle came from a queue.
|
|
310
|
+
- **Memory.** FTS-searchable memory browser with a client-side filter.
|
|
311
|
+
- **Tasks.** Pending/running/done task queue.
|
|
312
|
+
- **Schedules.** Heartbeat schedule editor.
|
|
313
|
+
- **Skills.** Installed skills with origin color coding (bajaclaw, openclaw, hermes). Inactive skills show the reason.
|
|
314
|
+
- **Channels.** Configured Telegram/Discord channels with masked tokens and allowlist.
|
|
315
|
+
- **Settings.** Whitelisted form editor for model, effort, context window, dashboard port, autostart, memory sync, max budget.
|
|
316
|
+
|
|
317
|
+
The daemon auto-starts the dashboard when it boots. Disable via `"dashboardAutostart": false` or change the port via `"dashboardPort"` in `config.json`. Auto-refreshes every 5s except on chat and settings views.
|
|
318
|
+
|
|
319
|
+
---
|
|
320
|
+
|
|
321
|
+
## MCP (both directions)
|
|
322
|
+
|
|
323
|
+
**Expose.** BajaClaw is itself an MCP server. `bajaclaw setup` auto-registers it with Claude Desktop. Any MCP client can then query BajaClaw state directly.
|
|
324
|
+
|
|
325
|
+
Resources:
|
|
326
|
+
|
|
327
|
+
- `bajaclaw://profiles` - list of configured profiles
|
|
328
|
+
- `bajaclaw://profile/<name>/agents` - agents in that profile
|
|
329
|
+
- `bajaclaw://profile/<name>/memories` - FTS-searchable memory
|
|
330
|
+
- `bajaclaw://profile/<name>/cycles` - recent cycle history
|
|
331
|
+
- `bajaclaw://profile/<name>/schedules` - heartbeat entries
|
|
332
|
+
|
|
333
|
+
Tools:
|
|
334
|
+
|
|
335
|
+
- `bajaclaw_memory_search({ query, limit, profile })`
|
|
336
|
+
- `bajaclaw_task_create({ agent, task, priority })`
|
|
337
|
+
- `bajaclaw_agent_status({ agent })`
|
|
338
|
+
- `bajaclaw_skill_list({ profile })`
|
|
339
|
+
|
|
340
|
+
Run the server manually:
|
|
341
|
+
|
|
342
|
+
```
|
|
343
|
+
bajaclaw mcp serve --stdio # for a client that expects stdio
|
|
344
|
+
bajaclaw mcp serve --port 8765 # HTTP/SSE on a port
|
|
345
|
+
bajaclaw mcp register # (re)register with Claude Desktop
|
|
346
|
+
```
|
|
152
347
|
|
|
153
|
-
|
|
348
|
+
**Consume.** BajaClaw uses its own MCP config by default. Claude Desktop's `mcpServers` list is **not** inherited unless opted in.
|
|
154
349
|
|
|
155
|
-
|
|
350
|
+
Merge order per cycle (highest wins):
|
|
156
351
|
|
|
157
|
-
-
|
|
158
|
-
|
|
159
|
-
-
|
|
160
|
-
|
|
161
|
-
- `bajaclaw uninstall` without `--yes` prints the teardown plan and changes nothing.
|
|
162
|
-
- Per-cycle USD cap via `maxBudgetUsd` in `config.json`.
|
|
163
|
-
- Per-cycle timeout via `cycleTimeoutMs` (default 10 min).
|
|
164
|
-
- No telemetry. The only outbound call on its own behalf is the once-per-24h update check to the npm registry.
|
|
352
|
+
1. `<profile>/agent-mcp-config.json`
|
|
353
|
+
2. `<profile>/mcp-config.json`
|
|
354
|
+
3. `~/.bajaclaw/mcp-config.json` (user-global BajaClaw)
|
|
355
|
+
4. Desktop config (only if `"mergeDesktopMcp": true` in the profile)
|
|
165
356
|
|
|
166
|
-
|
|
357
|
+
Port servers from Claude Code on demand:
|
|
358
|
+
|
|
359
|
+
```
|
|
360
|
+
bajaclaw mcp port --list # show what Claude Code has
|
|
361
|
+
bajaclaw mcp port # copy every server into BajaClaw
|
|
362
|
+
bajaclaw mcp port --names fs git # just these two
|
|
363
|
+
bajaclaw mcp port --force # overwrite existing entries
|
|
364
|
+
bajaclaw mcp list # what BajaClaw sees
|
|
365
|
+
bajaclaw mcp add <name> --command <cmd> # add one manually
|
|
366
|
+
bajaclaw mcp remove <name>
|
|
367
|
+
```
|
|
368
|
+
|
|
369
|
+
More: [docs/integration.md](docs/integration.md).
|
|
370
|
+
|
|
371
|
+
---
|
|
372
|
+
|
|
373
|
+
## OpenAI-compatible HTTP endpoint
|
|
374
|
+
|
|
375
|
+
`bajaclaw serve` exposes an OpenAI-shaped HTTP endpoint. Anything that speaks `POST /v1/chat/completions` works unmodified.
|
|
376
|
+
|
|
377
|
+
```
|
|
378
|
+
bajaclaw serve # 127.0.0.1:8765, no auth
|
|
379
|
+
bajaclaw serve --api-key $(openssl rand -hex 32) # with bearer auth
|
|
380
|
+
bajaclaw serve --host 0.0.0.0 --api-key <key> # bind all interfaces (auth required)
|
|
381
|
+
```
|
|
382
|
+
|
|
383
|
+
Each request is a full cycle: memory recall, skill matching, MCP inheritance, backend call, post-cycle extraction. The `model` field in the request is the BajaClaw profile name.
|
|
384
|
+
|
|
385
|
+
```bash
|
|
386
|
+
curl http://localhost:8765/v1/chat/completions \
|
|
387
|
+
-H "Content-Type: application/json" \
|
|
388
|
+
-d '{
|
|
389
|
+
"model": "default",
|
|
390
|
+
"messages": [{"role": "user", "content": "what is on my plate today"}]
|
|
391
|
+
}'
|
|
392
|
+
```
|
|
393
|
+
|
|
394
|
+
```python
|
|
395
|
+
from openai import OpenAI
|
|
396
|
+
client = OpenAI(base_url="http://localhost:8765/v1", api_key="any")
|
|
397
|
+
r = client.chat.completions.create(
|
|
398
|
+
model="default",
|
|
399
|
+
messages=[{"role": "user", "content": "hello"}],
|
|
400
|
+
)
|
|
401
|
+
print(r.choices[0].message.content)
|
|
402
|
+
```
|
|
403
|
+
|
|
404
|
+
Endpoints:
|
|
405
|
+
|
|
406
|
+
- `GET /health`
|
|
407
|
+
- `GET /v1/models`
|
|
408
|
+
- `POST /v1/chat/completions` (non-stream + SSE)
|
|
409
|
+
- `POST /v1/bajaclaw/cycle` (native full `CycleOutput`)
|
|
410
|
+
- `POST /v1/bajaclaw/tasks` (enqueue without waiting)
|
|
411
|
+
|
|
412
|
+
Non-localhost binds require `--api-key`. More: [docs/api.md](docs/api.md). Guided setup: `bajaclaw guide api`.
|
|
413
|
+
|
|
414
|
+
---
|
|
415
|
+
|
|
416
|
+
## Self-configuration via built-in guides
|
|
417
|
+
|
|
418
|
+
BajaClaw ships a set of built-in `SKILL.md` guides that describe how to set up each integration. When the matching trigger phrase fires, the agent sees the full procedure with Quick Reference / Procedure / Pitfalls / Verification sections, and walks through the configuration.
|
|
419
|
+
|
|
420
|
+
Ask the agent in plain language:
|
|
421
|
+
|
|
422
|
+
```
|
|
423
|
+
> help me set up Telegram
|
|
424
|
+
> walk me through connecting Discord
|
|
425
|
+
> switch to Opus for this profile
|
|
426
|
+
> turn on memory sync
|
|
427
|
+
> port all my Claude Code skills into BajaClaw
|
|
428
|
+
```
|
|
429
|
+
|
|
430
|
+
Print a guide directly from the CLI:
|
|
431
|
+
|
|
432
|
+
```
|
|
433
|
+
bajaclaw guide # list all built-in guides
|
|
434
|
+
bajaclaw guide telegram # the telegram setup walkthrough
|
|
435
|
+
bajaclaw guide mcp-port # the MCP port walkthrough
|
|
436
|
+
```
|
|
437
|
+
|
|
438
|
+
Available topics: `telegram`, `discord`, `heartbeat`, `daemon`, `dashboard`, `mcp-port`, `memory-sync`, `profile`, `self-update`, `uninstall`, `model`, `effort`, `tools`, `api`.
|
|
439
|
+
|
|
440
|
+
---
|
|
441
|
+
|
|
442
|
+
## Chat REPL
|
|
443
|
+
|
|
444
|
+
```
|
|
445
|
+
bajaclaw chat
|
|
446
|
+
```
|
|
447
|
+
|
|
448
|
+
Turn-by-turn conversation with the agent in the terminal. Per-turn metadata (model, tokens, cost, duration) appears under each response. History persists in-session.
|
|
449
|
+
|
|
450
|
+
Slash commands:
|
|
451
|
+
|
|
452
|
+
- `/help` - show all commands
|
|
453
|
+
- `/model [id]` - switch or show model
|
|
454
|
+
- `/effort [level]` - switch or show effort
|
|
455
|
+
- `/stats` - 5-hour and weekly usage
|
|
456
|
+
- `/compact` - manual memory compaction
|
|
457
|
+
- `/exit` - leave
|
|
458
|
+
|
|
459
|
+
More: [docs/chat.md](docs/chat.md).
|
|
460
|
+
|
|
461
|
+
---
|
|
462
|
+
|
|
463
|
+
## Safety and fair use
|
|
464
|
+
|
|
465
|
+
BajaClaw is a thin wrapper around the `claude` CLI. It never sees credentials, never calls the Anthropic API directly, and only uses documented CLI flags.
|
|
466
|
+
|
|
467
|
+
Built-in guards:
|
|
468
|
+
|
|
469
|
+
- **Circuit breaker.** 5 consecutive failed cycles open the breaker for 15 minutes.
|
|
470
|
+
- **Rate limiter.** 30 cycles/hour/profile by default.
|
|
471
|
+
- **Cycle serialization.** At most one `claude` subprocess per profile at a time (see [`src/concurrency.ts`](src/concurrency.ts)). HTTP API hits queue instead of spawning parallel processes.
|
|
472
|
+
- **Auto tier caps.** Haiku cycles get fewer memories, skills, and turns than Sonnet, and Sonnet fewer than Opus. Small tasks stay small.
|
|
473
|
+
- **Per-cycle USD cap.** `"maxBudgetUsd": 5.0` in `config.json` aborts the cycle cleanly if it would exceed the cap.
|
|
474
|
+
- **Per-cycle timeout.** `"cycleTimeoutMs": 600000` (default 10 min). Increase for long-running tasks.
|
|
475
|
+
- **Dry run.** `bajaclaw start --dry-run` prints the full prompt and argv without executing.
|
|
476
|
+
- **Dry install.** `bajaclaw uninstall` without `--yes` prints the teardown plan and changes nothing.
|
|
477
|
+
- **No shell string concat.** Every `execa` call uses an argv array with `shell: false`.
|
|
478
|
+
- **Skill install confirmation.** Skills require `BAJACLAW_CONFIRM=yes` in env; the full `SKILL.md` is printed before writing.
|
|
479
|
+
- **Env scrub on subprocess.** Claude Desktop's injected `CLAUDE_CODE_*` env vars are stripped when spawning the backend, so the daemon can't accidentally inherit a stale OAuth token.
|
|
480
|
+
- **No telemetry.** The only outbound call BajaClaw makes on its own behalf is the once-per-24h update check to the npm registry.
|
|
481
|
+
|
|
482
|
+
More: [docs/security.md](docs/security.md), [docs/fair-use.md](docs/fair-use.md).
|
|
483
|
+
|
|
484
|
+
---
|
|
167
485
|
|
|
168
486
|
## Setup, reset, uninstall
|
|
169
487
|
|
|
170
488
|
```
|
|
171
|
-
bajaclaw setup
|
|
172
|
-
bajaclaw
|
|
173
|
-
bajaclaw
|
|
174
|
-
bajaclaw uninstall
|
|
489
|
+
bajaclaw setup # idempotent bootstrap; safe to re-run
|
|
490
|
+
bajaclaw setup --interactive # force the wizard even if persona is set
|
|
491
|
+
bajaclaw setup --profile foo # use a different default profile name
|
|
492
|
+
bajaclaw uninstall # dry-run; prints the teardown plan
|
|
493
|
+
bajaclaw uninstall --yes # actually tear everything down
|
|
494
|
+
bajaclaw uninstall --yes --keep-data # remove integrations, keep ~/.bajaclaw/
|
|
175
495
|
```
|
|
176
496
|
|
|
497
|
+
`setup` is the repair button. If the MCP registration is missing, the agent descriptor is gone, or the home directory moved, rerunning `setup` fixes it without touching existing data.
|
|
498
|
+
|
|
499
|
+
`uninstall --yes` removes:
|
|
500
|
+
|
|
501
|
+
- Running daemons (via pid file)
|
|
502
|
+
- OS scheduler entries (launchd plist / systemd unit / crontab line / schtasks)
|
|
503
|
+
- `~/.claude/agents/<profile>/` directories for every profile
|
|
504
|
+
- The `bajaclaw` MCP entry from every desktop MCP config
|
|
505
|
+
- `~/.claude/memory/bajaclaw-*.md` sync files
|
|
506
|
+
- `~/.bajaclaw/` (unless `--keep-data`)
|
|
507
|
+
|
|
508
|
+
It does **not** `npm uninstall` itself. The final command to run by hand is printed at the end.
|
|
509
|
+
|
|
510
|
+
---
|
|
511
|
+
|
|
177
512
|
## On-disk layout
|
|
178
513
|
|
|
179
514
|
```
|
|
180
515
|
~/.bajaclaw/
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
516
|
+
├── profiles/
|
|
517
|
+
│ └── default/
|
|
518
|
+
│ ├── config.json # model, effort, tools, channels, budgets, timeouts
|
|
519
|
+
│ ├── bajaclaw.db # SQLite + FTS5 (memory, cycles, tasks, schedules)
|
|
520
|
+
│ ├── AGENT.md # operating guide (freely editable)
|
|
521
|
+
│ ├── SOUL.md # persona / voice / identity
|
|
522
|
+
│ ├── HEARTBEAT.md # cron-syntax schedule entries
|
|
523
|
+
│ ├── skills/ # profile-scoped skills
|
|
524
|
+
│ ├── logs/YYYY-MM-DD.jsonl # 30-day rotation
|
|
525
|
+
│ ├── mcp-config.json # profile-scoped MCP servers
|
|
526
|
+
│ ├── .mcp-merged.json # regenerated each cycle
|
|
527
|
+
│ └── daemon.pid / daemon.log # present when daemon is running
|
|
528
|
+
├── skills/ # user-global skills
|
|
529
|
+
├── mcp-config.json # user-global MCP servers
|
|
530
|
+
└── .update-check.json # 24h update-check cache
|
|
192
531
|
```
|
|
193
532
|
|
|
194
|
-
|
|
533
|
+
Every profile is self-contained. Remove its directory and that agent is gone. Back one up and it's portable to any machine.
|
|
534
|
+
|
|
535
|
+
---
|
|
536
|
+
|
|
537
|
+
## Command reference
|
|
538
|
+
|
|
539
|
+
Full detail in [docs/commands.md](docs/commands.md). Summary:
|
|
195
540
|
|
|
196
541
|
| command | purpose |
|
|
197
542
|
|---|---|
|
|
198
|
-
| `
|
|
543
|
+
| `setup` | idempotent bootstrap; run anytime to repair integrations |
|
|
544
|
+
| `uninstall` | full teardown (or `--keep-data` to keep profiles) |
|
|
545
|
+
| `init <name>` | scaffold a new named profile |
|
|
546
|
+
| `chat [profile]` | interactive REPL |
|
|
199
547
|
| `start [profile]` | run one cycle |
|
|
200
|
-
| `
|
|
201
|
-
| `
|
|
202
|
-
| `
|
|
203
|
-
| `
|
|
204
|
-
| `
|
|
205
|
-
| `
|
|
548
|
+
| `dry-run [profile]` | print assembled prompt and argv, no exec |
|
|
549
|
+
| `status [profile]` | per-profile stats |
|
|
550
|
+
| `health [profile]` | breaker + rate limit + recent cycles |
|
|
551
|
+
| `doctor` | toolchain + backend verification |
|
|
552
|
+
| `dashboard [profile]` | serve dashboard HTML |
|
|
553
|
+
| `daemon` | `start`/`stop`/`status`/`logs`/`install`/`run`/`restart` |
|
|
554
|
+
| `mcp` | `list`/`add`/`remove`/`serve`/`register`/`port` |
|
|
555
|
+
| `skill` | `list`/`new`/`install`/`search`/`review`/`promote`/`port` |
|
|
556
|
+
| `profile` | `list`/`create`/`switch`/`delete` |
|
|
557
|
+
| `channel` | `add`/`remove`/`list` Telegram + Discord bridges |
|
|
558
|
+
| `trigger [profile] <event>` | enqueue a task |
|
|
559
|
+
| `model [id] [profile]` | show/set the model |
|
|
560
|
+
| `effort [level] [profile]` | show/set effort |
|
|
561
|
+
| `guide [topic]` | print a built-in setup walkthrough |
|
|
562
|
+
| `persona [profile]` | edit the persona wizard answers |
|
|
563
|
+
| `compact [profile]` | manual memory compaction |
|
|
206
564
|
| `serve` | OpenAI-compatible HTTP endpoint |
|
|
207
|
-
| `
|
|
208
|
-
| `
|
|
565
|
+
| `update` | check for / install a newer version |
|
|
566
|
+
| `banner` | print the ASCII banner |
|
|
567
|
+
| `welcome` | print the welcome + next steps |
|
|
568
|
+
| `say <text>` | send a progress update (used from inside cycles) |
|
|
569
|
+
|
|
570
|
+
### Environment variables
|
|
571
|
+
|
|
572
|
+
| var | effect |
|
|
573
|
+
|---|---|
|
|
574
|
+
| `BAJACLAW_PROFILE` | default profile when `[profile]` is omitted |
|
|
575
|
+
| `BAJACLAW_DEFAULT_PROFILE` | override the literal name `"default"` |
|
|
576
|
+
| `BAJACLAW_HOME` | override `~/.bajaclaw/` |
|
|
577
|
+
| `CLAUDE_HOME` | override `~/.claude/` |
|
|
578
|
+
| `BAJACLAW_DRY_RUN=1` | force every cycle to dry-run |
|
|
579
|
+
| `BAJACLAW_VERBOSE=1` | mirror log events to stdout |
|
|
580
|
+
| `BAJACLAW_CONFIRM=yes` | allow `skill install` to write |
|
|
581
|
+
| `BAJACLAW_NO_UPDATE_NOTICE=1` | silence the post-command update notice |
|
|
582
|
+
| `CLAWHUB_REGISTRY` | override the ClawHub registry URL |
|
|
583
|
+
|
|
584
|
+
---
|
|
209
585
|
|
|
210
|
-
|
|
586
|
+
## Updating
|
|
211
587
|
|
|
212
|
-
|
|
588
|
+
BajaClaw checks the npm registry at most once per 24 hours. When a newer version is published, a one-line notice appears after any command.
|
|
589
|
+
|
|
590
|
+
```
|
|
591
|
+
bajaclaw update --check # print delta, don't install
|
|
592
|
+
bajaclaw update --yes # install immediately
|
|
593
|
+
```
|
|
594
|
+
|
|
595
|
+
On a global npm install, update runs `npm install -g bajaclaw@latest`. On a git clone, it runs `git pull && npm install && npm run build`. Silence the notice with `BAJACLAW_NO_UPDATE_NOTICE=1`.
|
|
596
|
+
|
|
597
|
+
---
|
|
213
598
|
|
|
214
599
|
## Docs
|
|
215
600
|
|
|
216
|
-
- [Architecture](docs/architecture.md)
|
|
217
|
-
- [Commands](docs/commands.md)
|
|
218
|
-
- [Agents and profiles](docs/agents.md)
|
|
601
|
+
- [Architecture](docs/architecture.md) - module map, cycle, on-disk layout
|
|
602
|
+
- [Commands](docs/commands.md) - full command reference
|
|
603
|
+
- [Agents and profiles](docs/agents.md) - `AGENT.md`, `SOUL.md`, `HEARTBEAT.md`, templates
|
|
219
604
|
- [Chat REPL](docs/chat.md)
|
|
220
|
-
- [Skills](docs/skills.md)
|
|
221
|
-
- [Memory](docs/memory.md)
|
|
605
|
+
- [Skills](docs/skills.md) - scoping, matching, foreign formats, auto-generation
|
|
606
|
+
- [Memory](docs/memory.md) - FTS5 recall, post-cycle extract, Claude Code sync
|
|
607
|
+
- [Compaction](docs/compaction.md)
|
|
222
608
|
- [Heartbeat and scheduling](docs/heartbeat.md)
|
|
223
|
-
- [Channels (
|
|
224
|
-
- [HTTP API](docs/api.md)
|
|
609
|
+
- [Channels (Telegram + Discord)](docs/channels.md)
|
|
610
|
+
- [HTTP API](docs/api.md) - OpenAI-compatible endpoint + native routes
|
|
225
611
|
- [Subagents](docs/subagents.md)
|
|
226
|
-
- [
|
|
227
|
-
- [
|
|
228
|
-
- [
|
|
229
|
-
- [Fair use](docs/fair-use.md)
|
|
612
|
+
- [Integration with Claude Code](docs/integration.md) - MCP seams in detail
|
|
613
|
+
- [Security](docs/security.md) - threat model + mitigations
|
|
614
|
+
- [Fair use](docs/fair-use.md) - how BajaClaw stays a thin wrapper
|
|
230
615
|
- [Troubleshooting](docs/troubleshooting.md)
|
|
231
616
|
- [FAQ](docs/faq.md)
|
|
232
|
-
- [Contributing](docs/contributing.md)
|
|
617
|
+
- [Contributing](docs/contributing.md) - dev setup, style, release
|
|
618
|
+
|
|
619
|
+
---
|
|
233
620
|
|
|
234
621
|
## License
|
|
235
622
|
|
|
236
|
-
MIT. No company attribution.
|
|
623
|
+
MIT. No company attribution. Users own what their agents produce.
|