bajaclaw 0.10.1

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 (248) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +639 -0
  3. package/bin/bajaclaw.js +35 -0
  4. package/bin/create-bajaclaw.js +17 -0
  5. package/dist/agent.d.ts +29 -0
  6. package/dist/agent.js +231 -0
  7. package/dist/agent.js.map +1 -0
  8. package/dist/api/server.d.ts +15 -0
  9. package/dist/api/server.js +215 -0
  10. package/dist/api/server.js.map +1 -0
  11. package/dist/api/translate.d.ts +61 -0
  12. package/dist/api/translate.js +109 -0
  13. package/dist/api/translate.js.map +1 -0
  14. package/dist/banner.d.ts +7 -0
  15. package/dist/banner.js +31 -0
  16. package/dist/banner.js.map +1 -0
  17. package/dist/channels/gateway.d.ts +1 -0
  18. package/dist/channels/gateway.js +76 -0
  19. package/dist/channels/gateway.js.map +1 -0
  20. package/dist/claude.d.ts +9 -0
  21. package/dist/claude.js +170 -0
  22. package/dist/claude.js.map +1 -0
  23. package/dist/cli.d.ts +2 -0
  24. package/dist/cli.js +303 -0
  25. package/dist/cli.js.map +1 -0
  26. package/dist/commands/channel.d.ts +3 -0
  27. package/dist/commands/channel.js +27 -0
  28. package/dist/commands/channel.js.map +1 -0
  29. package/dist/commands/compact.d.ts +8 -0
  30. package/dist/commands/compact.js +60 -0
  31. package/dist/commands/compact.js.map +1 -0
  32. package/dist/commands/daemon.d.ts +7 -0
  33. package/dist/commands/daemon.js +129 -0
  34. package/dist/commands/daemon.js.map +1 -0
  35. package/dist/commands/dashboard.d.ts +1 -0
  36. package/dist/commands/dashboard.js +78 -0
  37. package/dist/commands/dashboard.js.map +1 -0
  38. package/dist/commands/doctor.d.ts +1 -0
  39. package/dist/commands/doctor.js +25 -0
  40. package/dist/commands/doctor.js.map +1 -0
  41. package/dist/commands/dry-run.d.ts +1 -0
  42. package/dist/commands/dry-run.js +5 -0
  43. package/dist/commands/dry-run.js.map +1 -0
  44. package/dist/commands/effort.d.ts +6 -0
  45. package/dist/commands/effort.js +33 -0
  46. package/dist/commands/effort.js.map +1 -0
  47. package/dist/commands/guide.d.ts +4 -0
  48. package/dist/commands/guide.js +52 -0
  49. package/dist/commands/guide.js.map +1 -0
  50. package/dist/commands/health.d.ts +1 -0
  51. package/dist/commands/health.js +20 -0
  52. package/dist/commands/health.js.map +1 -0
  53. package/dist/commands/init.d.ts +12 -0
  54. package/dist/commands/init.js +114 -0
  55. package/dist/commands/init.js.map +1 -0
  56. package/dist/commands/mcp.d.ts +9 -0
  57. package/dist/commands/mcp.js +63 -0
  58. package/dist/commands/mcp.js.map +1 -0
  59. package/dist/commands/migrate.d.ts +1 -0
  60. package/dist/commands/migrate.js +58 -0
  61. package/dist/commands/migrate.js.map +1 -0
  62. package/dist/commands/model.d.ts +5 -0
  63. package/dist/commands/model.js +31 -0
  64. package/dist/commands/model.js.map +1 -0
  65. package/dist/commands/persona.d.ts +6 -0
  66. package/dist/commands/persona.js +67 -0
  67. package/dist/commands/persona.js.map +1 -0
  68. package/dist/commands/port.d.ts +15 -0
  69. package/dist/commands/port.js +88 -0
  70. package/dist/commands/port.js.map +1 -0
  71. package/dist/commands/profile.d.ts +4 -0
  72. package/dist/commands/profile.js +41 -0
  73. package/dist/commands/profile.js.map +1 -0
  74. package/dist/commands/serve.d.ts +14 -0
  75. package/dist/commands/serve.js +62 -0
  76. package/dist/commands/serve.js.map +1 -0
  77. package/dist/commands/setup.d.ts +17 -0
  78. package/dist/commands/setup.js +228 -0
  79. package/dist/commands/setup.js.map +1 -0
  80. package/dist/commands/skill.d.ts +7 -0
  81. package/dist/commands/skill.js +137 -0
  82. package/dist/commands/skill.js.map +1 -0
  83. package/dist/commands/start.d.ts +6 -0
  84. package/dist/commands/start.js +25 -0
  85. package/dist/commands/start.js.map +1 -0
  86. package/dist/commands/status.d.ts +1 -0
  87. package/dist/commands/status.js +35 -0
  88. package/dist/commands/status.js.map +1 -0
  89. package/dist/commands/subagent.d.ts +14 -0
  90. package/dist/commands/subagent.js +173 -0
  91. package/dist/commands/subagent.js.map +1 -0
  92. package/dist/commands/trigger.d.ts +1 -0
  93. package/dist/commands/trigger.js +13 -0
  94. package/dist/commands/trigger.js.map +1 -0
  95. package/dist/commands/uninstall.d.ts +5 -0
  96. package/dist/commands/uninstall.js +165 -0
  97. package/dist/commands/uninstall.js.map +1 -0
  98. package/dist/commands/update.d.ts +7 -0
  99. package/dist/commands/update.js +49 -0
  100. package/dist/commands/update.js.map +1 -0
  101. package/dist/concurrency.d.ts +1 -0
  102. package/dist/concurrency.js +17 -0
  103. package/dist/concurrency.js.map +1 -0
  104. package/dist/config.d.ts +5 -0
  105. package/dist/config.js +42 -0
  106. package/dist/config.js.map +1 -0
  107. package/dist/db.d.ts +3 -0
  108. package/dist/db.js +124 -0
  109. package/dist/db.js.map +1 -0
  110. package/dist/delegation.d.ts +6 -0
  111. package/dist/delegation.js +21 -0
  112. package/dist/delegation.js.map +1 -0
  113. package/dist/health-check.d.ts +6 -0
  114. package/dist/health-check.js +38 -0
  115. package/dist/health-check.js.map +1 -0
  116. package/dist/logger.d.ts +11 -0
  117. package/dist/logger.js +53 -0
  118. package/dist/logger.js.map +1 -0
  119. package/dist/mcp/consumer.d.ts +15 -0
  120. package/dist/mcp/consumer.js +74 -0
  121. package/dist/mcp/consumer.js.map +1 -0
  122. package/dist/mcp/server.d.ts +6 -0
  123. package/dist/mcp/server.js +260 -0
  124. package/dist/mcp/server.js.map +1 -0
  125. package/dist/memory/claude-compat.d.ts +4 -0
  126. package/dist/memory/claude-compat.js +56 -0
  127. package/dist/memory/claude-compat.js.map +1 -0
  128. package/dist/memory/compact.d.ts +25 -0
  129. package/dist/memory/compact.js +195 -0
  130. package/dist/memory/compact.js.map +1 -0
  131. package/dist/memory/extract.d.ts +3 -0
  132. package/dist/memory/extract.js +56 -0
  133. package/dist/memory/extract.js.map +1 -0
  134. package/dist/memory/recall.d.ts +5 -0
  135. package/dist/memory/recall.js +47 -0
  136. package/dist/memory/recall.js.map +1 -0
  137. package/dist/model-picker.d.ts +33 -0
  138. package/dist/model-picker.js +104 -0
  139. package/dist/model-picker.js.map +1 -0
  140. package/dist/paths.d.ts +12 -0
  141. package/dist/paths.js +49 -0
  142. package/dist/paths.js.map +1 -0
  143. package/dist/persona-io.d.ts +5 -0
  144. package/dist/persona-io.js +29 -0
  145. package/dist/persona-io.js.map +1 -0
  146. package/dist/persona.d.ts +12 -0
  147. package/dist/persona.js +54 -0
  148. package/dist/persona.js.map +1 -0
  149. package/dist/prompt.d.ts +5 -0
  150. package/dist/prompt.js +56 -0
  151. package/dist/prompt.js.map +1 -0
  152. package/dist/safety.d.ts +17 -0
  153. package/dist/safety.js +47 -0
  154. package/dist/safety.js.map +1 -0
  155. package/dist/scheduler/cron.d.ts +4 -0
  156. package/dist/scheduler/cron.js +44 -0
  157. package/dist/scheduler/cron.js.map +1 -0
  158. package/dist/scheduler/index.d.ts +7 -0
  159. package/dist/scheduler/index.js +15 -0
  160. package/dist/scheduler/index.js.map +1 -0
  161. package/dist/scheduler/launchd.d.ts +4 -0
  162. package/dist/scheduler/launchd.js +73 -0
  163. package/dist/scheduler/launchd.js.map +1 -0
  164. package/dist/scheduler/schtasks.d.ts +4 -0
  165. package/dist/scheduler/schtasks.js +45 -0
  166. package/dist/scheduler/schtasks.js.map +1 -0
  167. package/dist/scheduler/systemd.d.ts +5 -0
  168. package/dist/scheduler/systemd.js +86 -0
  169. package/dist/scheduler/systemd.js.map +1 -0
  170. package/dist/self-improve.d.ts +4 -0
  171. package/dist/self-improve.js +48 -0
  172. package/dist/self-improve.js.map +1 -0
  173. package/dist/skills/auto-skiller.d.ts +21 -0
  174. package/dist/skills/auto-skiller.js +156 -0
  175. package/dist/skills/auto-skiller.js.map +1 -0
  176. package/dist/skills/loader.d.ts +3 -0
  177. package/dist/skills/loader.js +127 -0
  178. package/dist/skills/loader.js.map +1 -0
  179. package/dist/skills/matcher.d.ts +2 -0
  180. package/dist/skills/matcher.js +27 -0
  181. package/dist/skills/matcher.js.map +1 -0
  182. package/dist/skills/porter.d.ts +27 -0
  183. package/dist/skills/porter.js +109 -0
  184. package/dist/skills/porter.js.map +1 -0
  185. package/dist/types.d.ts +110 -0
  186. package/dist/types.js +2 -0
  187. package/dist/types.js.map +1 -0
  188. package/dist/updater.d.ts +25 -0
  189. package/dist/updater.js +185 -0
  190. package/dist/updater.js.map +1 -0
  191. package/package.json +53 -0
  192. package/scripts/postinstall.js +33 -0
  193. package/skills/configure-effort/SKILL.md +36 -0
  194. package/skills/configure-model/SKILL.md +41 -0
  195. package/skills/configure-tools/SKILL.md +51 -0
  196. package/skills/daily-briefing/SKILL.md +19 -0
  197. package/skills/delegate-to-subagent/SKILL.md +63 -0
  198. package/skills/email-triage/SKILL.md +21 -0
  199. package/skills/setup-api/SKILL.md +115 -0
  200. package/skills/setup-compaction/SKILL.md +102 -0
  201. package/skills/setup-daemon/SKILL.md +49 -0
  202. package/skills/setup-dashboard/SKILL.md +39 -0
  203. package/skills/setup-discord/SKILL.md +54 -0
  204. package/skills/setup-heartbeat/SKILL.md +51 -0
  205. package/skills/setup-mcp-port/SKILL.md +54 -0
  206. package/skills/setup-memory-sync/SKILL.md +45 -0
  207. package/skills/setup-profile/SKILL.md +44 -0
  208. package/skills/setup-self-update/SKILL.md +45 -0
  209. package/skills/setup-subagent/SKILL.md +102 -0
  210. package/skills/setup-telegram/SKILL.md +54 -0
  211. package/skills/setup-uninstall/SKILL.md +55 -0
  212. package/skills/web-research/SKILL.md +20 -0
  213. package/templates/code/AGENT.md +15 -0
  214. package/templates/code/HEARTBEAT.md +11 -0
  215. package/templates/code/SOUL.md +10 -0
  216. package/templates/code/bajaclaw.config.json +5 -0
  217. package/templates/code/scripts/launch.bat +4 -0
  218. package/templates/code/scripts/launch.sh +4 -0
  219. package/templates/custom/AGENT.md +14 -0
  220. package/templates/custom/HEARTBEAT.md +11 -0
  221. package/templates/custom/SOUL.md +10 -0
  222. package/templates/custom/bajaclaw.config.json +5 -0
  223. package/templates/custom/scripts/launch.bat +4 -0
  224. package/templates/custom/scripts/launch.sh +4 -0
  225. package/templates/outreach/AGENT.md +11 -0
  226. package/templates/outreach/HEARTBEAT.md +11 -0
  227. package/templates/outreach/SOUL.md +10 -0
  228. package/templates/outreach/bajaclaw.config.json +5 -0
  229. package/templates/outreach/scripts/launch.bat +4 -0
  230. package/templates/outreach/scripts/launch.sh +4 -0
  231. package/templates/research/AGENT.md +27 -0
  232. package/templates/research/HEARTBEAT.md +11 -0
  233. package/templates/research/SOUL.md +10 -0
  234. package/templates/research/bajaclaw.config.json +5 -0
  235. package/templates/research/scripts/launch.bat +4 -0
  236. package/templates/research/scripts/launch.sh +4 -0
  237. package/templates/social/AGENT.md +10 -0
  238. package/templates/social/HEARTBEAT.md +11 -0
  239. package/templates/social/SOUL.md +10 -0
  240. package/templates/social/bajaclaw.config.json +5 -0
  241. package/templates/social/scripts/launch.bat +4 -0
  242. package/templates/social/scripts/launch.sh +4 -0
  243. package/templates/support/AGENT.md +10 -0
  244. package/templates/support/HEARTBEAT.md +11 -0
  245. package/templates/support/SOUL.md +10 -0
  246. package/templates/support/bajaclaw.config.json +5 -0
  247. package/templates/support/scripts/launch.bat +4 -0
  248. package/templates/support/scripts/launch.sh +4 -0
@@ -0,0 +1,41 @@
1
+ ---
2
+ name: configure-model
3
+ description: Change which backend model a BajaClaw profile uses
4
+ version: 0.1.0
5
+ tools: [Bash, Read, Edit]
6
+ triggers: ["change model", "switch model", "use opus", "use sonnet", "use haiku", "which model", "upgrade model"]
7
+ effort: low
8
+ ---
9
+
10
+ ## When to use
11
+ User wants a different model for a profile — e.g. Opus for deep reasoning,
12
+ Haiku for fast heartbeat triage, Sonnet as a balanced default.
13
+
14
+ ## Quick reference
15
+ - Stored in `~/.bajaclaw/profiles/<profile>/config.json` → `"model"`.
16
+ - Special value: `auto` routes per-task (haiku / sonnet / opus).
17
+ - Known ids: `claude-opus-4-7`, `claude-sonnet-4-6`, `claude-haiku-4-5`.
18
+ Any string is accepted — the backend CLI validates against your
19
+ subscription.
20
+ - Tradeoffs: Opus > Sonnet > Haiku in capability; Haiku > Sonnet > Opus in
21
+ speed and cost.
22
+
23
+ ## Procedure
24
+ 1. Show current: `bajaclaw model <profile>` (prints current + known models).
25
+ 2. Set: `bajaclaw model <new-model> <profile>`.
26
+ - Examples: `bajaclaw model auto`,
27
+ `bajaclaw model claude-opus-4-7`,
28
+ `bajaclaw model claude-haiku-4-5 researcher`.
29
+ 3. Or edit `~/.bajaclaw/profiles/<profile>/config.json` directly and set
30
+ `"model": "<id>"`.
31
+ 4. Change takes effect on the next cycle.
32
+
33
+ ## Pitfalls
34
+ - If the id is unknown to the backend, cycles will fail with a model-not-
35
+ found error. Fall back to a known-good id.
36
+ - Opus burns tokens fast — for daily heartbeats, Sonnet or Haiku is usually
37
+ the right call. Save Opus for reflection cycles or hard reasoning tasks.
38
+
39
+ ## Verification
40
+ - `bajaclaw model <profile>` shows the new id.
41
+ - Next cycle's `command:` line (via `--dry-run`) includes `--model <id>`.
@@ -0,0 +1,51 @@
1
+ ---
2
+ name: configure-tools
3
+ description: Edit the allowed and disallowed tool list for a BajaClaw profile
4
+ version: 0.1.0
5
+ tools: [Read, Edit, Write]
6
+ triggers: ["allowed tools", "disallowed tools", "restrict tools", "tool access", "tool permissions", "toolbox", "allow write", "disable bash"]
7
+ effort: low
8
+ ---
9
+
10
+ ## When to use
11
+ User wants to tighten or loosen the tools an agent can call — e.g. remove
12
+ `Bash` from a research agent, or add `Write` to a support agent that was
13
+ set up read-only.
14
+
15
+ ## Quick reference
16
+ - Stored in `~/.bajaclaw/profiles/<profile>/config.json`:
17
+ - `allowedTools`: string[] — passes to `claude --allowedTools`
18
+ - `disallowedTools`: string[] — passes to `claude --disallowedTools`
19
+ - Defaults come from the template (see `src/commands/init.ts`).
20
+ - Standard tool names: `Read`, `Write`, `Edit`, `Bash`, `Grep`, `Glob`,
21
+ `WebSearch`, `WebFetch`. Plus any MCP tools you've configured.
22
+
23
+ ## Procedure
24
+ 1. Show the current state: open
25
+ `~/.bajaclaw/profiles/<profile>/config.json` and find the `allowedTools`
26
+ and `disallowedTools` fields.
27
+ 2. Decide which way they want to go:
28
+ - **Tighten** (deny specific tools): add them to `disallowedTools`.
29
+ Example: `"disallowedTools": ["Bash"]`.
30
+ - **Loosen** (allow only specific tools): set `allowedTools` to a
31
+ concrete list. Anything not in the list is forbidden.
32
+ - **Full access**: remove both fields entirely (or set to `[]`).
33
+ 3. Save the file. Changes take effect on the next cycle — no daemon
34
+ restart needed.
35
+ 4. Verify with a dry-run: `bajaclaw start <profile> --dry-run` and check
36
+ the `command:` line for `--allowedTools` / `--disallowedTools` flags.
37
+
38
+ ## Pitfalls
39
+ - Both fields can be set together. `allowedTools` is an allowlist;
40
+ `disallowedTools` is a denylist applied within that allowlist.
41
+ - The MCP tools inherited from merged config are subject to the same
42
+ restrictions. Add the MCP tool name if you want to block one specifically.
43
+ - `code`-template agents have read-only tools by design — they delegate
44
+ writes to a sub-agent via `delegateCoding`. Don't lift those unless you
45
+ know you want the orchestrator itself writing code.
46
+
47
+ ## Verification
48
+ - `bajaclaw start <profile> --dry-run` shows the expected flags in the
49
+ `command:` line.
50
+ - A cycle confirms the agent respects the restriction — check cycle logs
51
+ for tool use events matching only permitted tools.
@@ -0,0 +1,19 @@
1
+ ---
2
+ name: daily-briefing
3
+ description: Produce a concise morning briefing covering schedule, priorities, and open threads
4
+ version: 0.1.0
5
+ tools: [Read]
6
+ triggers: ["daily briefing", "morning update", "standup"]
7
+ effort: medium
8
+ ---
9
+
10
+ ## Instructions
11
+
12
+ Produce a briefing with these sections:
13
+ 1. **Top of mind** — 1-3 items the user should know before anything else.
14
+ 2. **Today's schedule** — if calendar data is available, list blocks with time + title.
15
+ 3. **Waiting on others** — threads where the ball is in someone else's court.
16
+ 4. **Follow-ups due** — items the user promised to do and hasn't yet.
17
+
18
+ Keep the whole thing under 250 words. Lead with what changed since yesterday.
19
+ Do not invent items. If you have no data for a section, omit it silently.
@@ -0,0 +1,63 @@
1
+ ---
2
+ name: delegate-to-subagent
3
+ description: Route a task to a specialized sub-agent when the main agent doesn't have the tools or permissions
4
+ version: 0.1.0
5
+ tools: [Bash, Read]
6
+ triggers: ["delegate", "ask the subagent", "hand off", "check my email", "look in my inbox", "look at my calendar", "check my messages", "read the file for me"]
7
+ effort: low
8
+ ---
9
+
10
+ ## When to use
11
+ You are the orchestrator. The user asked you to do something that requires
12
+ tools or access you do not have. A specialized sub-agent does have them.
13
+ Delegate the task to that sub-agent instead of trying it yourself or
14
+ refusing.
15
+
16
+ Signals that a task belongs to a sub-agent:
17
+ - It touches data you do not have an MCP server for (email, calendar,
18
+ private file stores, a customer DB, etc.) but the user has told you a
19
+ sub-agent owns that data.
20
+ - It is outside the scope of your `allowedTools` / `disallowedTools`.
21
+ - It is the kind of thing that happens often and the user has a named
22
+ helper for it.
23
+
24
+ ## Quick reference
25
+ - List sub-agents: `bajaclaw subagent list <your-profile>` (via Bash).
26
+ - Delegate: `bajaclaw delegate <subagent-name> "<task>"`.
27
+ - The sub-agent runs one cycle with its own tools, memory, and persona,
28
+ then returns its final response text on stdout.
29
+ - You capture the response and use it in your own reply to the user.
30
+
31
+ ## Procedure
32
+ 1. Identify which sub-agent owns the capability. Ask yourself: *which
33
+ tool does this task require?* If the sub-agent named in your config
34
+ has that tool and you don't, delegate.
35
+ 2. Phrase the task for the sub-agent. Be specific. Pass along whatever
36
+ filter, range, or query the user gave you. Don't just forward the
37
+ raw user message verbatim — rephrase if useful.
38
+ 3. Run the delegation via Bash:
39
+ ```
40
+ bajaclaw delegate <subagent> "<specific task>"
41
+ ```
42
+ 4. Read the stdout response carefully. Summarize or quote back to the
43
+ user as appropriate.
44
+ 5. If the sub-agent's response contains sensitive data (account numbers,
45
+ PII, auth tokens), follow your own don'ts — don't echo that verbatim
46
+ in your reply. Summarize.
47
+
48
+ ## Pitfalls
49
+ - Do NOT invoke `bajaclaw start <subagent>` to trigger a cycle for the
50
+ sub-agent — that pulls from the sub-agent's queue, not your task.
51
+ Use `bajaclaw delegate` instead.
52
+ - Do NOT loop: if the sub-agent fails, report the failure to the user.
53
+ Don't retry indefinitely.
54
+ - Each delegation is a full cycle — one backend call with memory/skill
55
+ load. Don't delegate for trivial answers you already have.
56
+ - A sub-agent has its own memory and skills. If you need it to see
57
+ context from your conversation, include that context in the task
58
+ string you pass.
59
+
60
+ ## Verification
61
+ - The sub-agent's stdout response is the final answer or the next step.
62
+ - `bajaclaw status <subagent>` shows the cycle count incremented.
63
+ - `bajaclaw daemon logs <subagent>` shows the delegation entry.
@@ -0,0 +1,21 @@
1
+ ---
2
+ name: email-triage
3
+ description: Classify inbox messages, draft replies for routine items, surface urgent ones
4
+ version: 0.1.0
5
+ tools: [Read, Write]
6
+ triggers: ["check email", "triage inbox", "email"]
7
+ effort: medium
8
+ ---
9
+
10
+ ## Instructions
11
+
12
+ For each message:
13
+ 1. Classify as `urgent`, `routine`, `fyi`, or `spam`.
14
+ 2. For `urgent`: write one-line summary + draft holding reply.
15
+ 3. For `routine`: draft a full reply in plain text.
16
+ 4. For `fyi`: note the item in the daily briefing queue, no reply.
17
+ 5. For `spam`: skip silently.
18
+
19
+ Never send. Every draft goes to the tasks queue with `status=awaiting_approval`.
20
+ If a message mentions PII, account numbers, or secrets, do not echo them in the
21
+ draft. Summarize the request without the sensitive details.
@@ -0,0 +1,115 @@
1
+ ---
2
+ name: setup-api
3
+ description: Expose BajaClaw as an OpenAI-compatible HTTP endpoint for external clients
4
+ version: 0.1.0
5
+ tools: [Bash, Read, Write, Edit]
6
+ triggers: ["api endpoint", "openai api", "http api", "expose api", "serve bajaclaw", "llm endpoint", "openai compatible", "bajaclaw server", "base_url", "connect cursor", "connect langchain"]
7
+ effort: medium
8
+ ---
9
+
10
+ ## When to use
11
+ The user wants to call BajaClaw from anything that speaks the OpenAI chat
12
+ API — Cursor, Open WebUI, LangChain, LlamaIndex, curl, a python script, a
13
+ web app. They'll point the client at `http://localhost:8765/v1` and
14
+ treat BajaClaw as an LLM.
15
+
16
+ ## Quick reference
17
+ - Start: `bajaclaw serve` (binds 127.0.0.1:8765 by default)
18
+ - Endpoints:
19
+ - `GET /v1/models` — lists BajaClaw profiles as model ids
20
+ - `POST /v1/chat/completions` — OpenAI chat (stream + non-stream)
21
+ - `POST /v1/bajaclaw/cycle` — native full CycleOutput
22
+ - `POST /v1/bajaclaw/tasks` — enqueue a task without waiting
23
+ - `GET /health` — liveness
24
+ - Auth: optional bearer token via `--api-key <secret>` or
25
+ `api.apiKey` in `~/.bajaclaw/api.json`.
26
+ - Non-localhost bind requires an API key (refuses otherwise).
27
+
28
+ ## Procedure
29
+
30
+ ### 1. Start the server
31
+ ```
32
+ bajaclaw serve # default: 127.0.0.1:8765
33
+ bajaclaw serve --port 9000 # custom port
34
+ bajaclaw serve --api-key $(openssl rand -hex 32) # with auth
35
+ bajaclaw serve --host 0.0.0.0 --api-key <secret> # bind all interfaces (auth required)
36
+ bajaclaw serve --expose default research # allowlist specific profiles
37
+ ```
38
+
39
+ ### 2. Hit it from any OpenAI-compatible client
40
+
41
+ **curl:**
42
+ ```
43
+ curl http://localhost:8765/v1/chat/completions \
44
+ -H "Content-Type: application/json" \
45
+ -d '{
46
+ "model": "default",
47
+ "messages": [{"role": "user", "content": "summarize my last three cycles"}]
48
+ }'
49
+ ```
50
+
51
+ **python `openai` SDK:**
52
+ ```python
53
+ from openai import OpenAI
54
+ client = OpenAI(base_url="http://localhost:8765/v1", api_key="any")
55
+ r = client.chat.completions.create(
56
+ model="default",
57
+ messages=[{"role": "user", "content": "hello"}],
58
+ )
59
+ print(r.choices[0].message.content)
60
+ ```
61
+
62
+ **Cursor / VSCode / Open WebUI / LibreChat / etc.**
63
+ Point their "OpenAI-compatible" settings at `http://localhost:8765/v1`
64
+ and use any profile name as the "model".
65
+
66
+ ### 3. Streaming
67
+ Add `"stream": true` to the request. The server runs the cycle to
68
+ completion, then streams the response as OpenAI-format SSE
69
+ `chat.completion.chunk` events (word-grouped, small inter-chunk delay).
70
+ Each request is a full cycle — memory recall, skill matching, MCP
71
+ inheritance, post-cycle extract — then the result is chunked out.
72
+
73
+ ### 4. Persist the config (optional)
74
+ Instead of CLI flags, put defaults in `~/.bajaclaw/api.json`:
75
+ ```json
76
+ {
77
+ "host": "127.0.0.1",
78
+ "port": 8765,
79
+ "apiKey": "your-long-secret",
80
+ "exposedProfiles": ["default"],
81
+ "streamDelayMs": 20
82
+ }
83
+ ```
84
+ `bajaclaw serve` picks it up automatically; CLI flags override it.
85
+
86
+ ### 5. Run it under the daemon or a service manager
87
+ Pair with `bajaclaw daemon` for the heartbeat, and wrap `bajaclaw serve`
88
+ with launchd/systemd/pm2 if you want the HTTP API to stay up across
89
+ restarts. It's a long-running foreground process.
90
+
91
+ ## Pitfalls
92
+ - **Non-localhost binds require an API key.** The server refuses to
93
+ bind 0.0.0.0 or a real interface without one. This is the default
94
+ protection — don't disable it.
95
+ - Each API request = one full cycle = one backend call. That bills
96
+ against the `claude` CLI's subscription/credits. Consider rate
97
+ limiting in front (an nginx/caddy proxy is easy).
98
+ - Model name in the request maps to a profile. Unknown profile → 404
99
+ with `{"error": {"message": "unknown profile: <x>"}}`. Use
100
+ `/v1/models` to see what's available.
101
+ - The streaming is pseudo-streaming: the full cycle runs before the
102
+ first chunk is emitted. Clients won't see real token-by-token
103
+ streaming in this release.
104
+ - BajaClaw's memory, skills, and MCP servers apply to every API
105
+ request — they're not a "fresh" chat. If a caller expects stateless
106
+ completions, their results will still be influenced by BajaClaw's
107
+ accumulated memory. This is a feature, not a bug.
108
+
109
+ ## Verification
110
+ - `curl http://localhost:8765/health` returns `{"status": "ok"}`.
111
+ - `curl http://localhost:8765/v1/models` lists the exposed profiles.
112
+ - A non-streaming chat request returns a proper OpenAI
113
+ ChatCompletion with `choices[0].message.content` populated.
114
+ - A streaming request produces a series of `data: {...}` SSE lines
115
+ ending with `data: [DONE]`.
@@ -0,0 +1,102 @@
1
+ ---
2
+ name: setup-compaction
3
+ description: Configure when BajaClaw auto-compacts its memory pool so recall stays sharp over time
4
+ version: 0.1.0
5
+ tools: [Bash, Read, Edit, Write]
6
+ triggers: ["compact memory", "memory compaction", "auto compact", "context window", "memory cleanup", "auto-compact", "memory full", "compaction schedule", "shrink memory", "prune memory"]
7
+ effort: low
8
+ ---
9
+
10
+ ## When to use
11
+ User wants to control how often BajaClaw shrinks its memory pool — either
12
+ on a size threshold (percentage of the model's context window), on a
13
+ daily UTC schedule, both, or off.
14
+
15
+ ## Core idea — why this is different from chat-app compaction
16
+ BajaClaw runs **stateless cycles**. Each cycle rebuilds the prompt from
17
+ memory + skills + task. The model's context window never "fills up"
18
+ across cycles because nothing carries over in-model. What grows is the
19
+ **memory database** (`~/.bajaclaw/profiles/<p>/bajaclaw.db`).
20
+
21
+ Compaction is therefore memory hygiene, not conversation truncation:
22
+ - Summarize old memories into denser rows so the recall surface stays
23
+ crisp.
24
+ - Prune stale cycle-log rows (older than N days).
25
+ - VACUUM the SQLite file to reclaim space.
26
+
27
+ ## Defaults
28
+ - **Schedule**: `both` — trigger on threshold OR daily.
29
+ - **Threshold**: `0.75` of a 200k-token reference window (~600k chars).
30
+ - **Daily time**: `00:00` UTC.
31
+ - **Keep per kind**: 25 newest memories per kind (fact / decision /
32
+ preference / todo / reference) stay verbatim. Older ones are
33
+ eligible for summarization.
34
+ - **Prune cycles older than**: 30 days.
35
+
36
+ ## Procedure
37
+
38
+ ### Via the command
39
+ ```
40
+ bajaclaw compact --dry-run # show policy + trigger state
41
+ bajaclaw compact # run if a trigger fires
42
+ bajaclaw compact --force # run regardless
43
+ bajaclaw compact --schedule both # set schedule mode
44
+ bajaclaw compact --threshold 0.6 # trigger earlier
45
+ bajaclaw compact --daily-at 04:00 # set UTC time
46
+ bajaclaw compact --keep 40 # keep more verbatim per kind
47
+ bajaclaw compact --prune-days 60 # longer cycle-log retention
48
+ bajaclaw compact --disable # turn off entirely
49
+ bajaclaw compact --enable # turn back on
50
+ ```
51
+ All mutate the profile's `config.json` under the `compaction` key.
52
+
53
+ ### Via the setup wizard
54
+ ```
55
+ bajaclaw setup --interactive
56
+ ```
57
+ Re-runs the persona wizard and the compaction wizard together.
58
+
59
+ ### Via config.json directly
60
+ ```
61
+ ~/.bajaclaw/profiles/<profile>/config.json
62
+ ```
63
+ ```json
64
+ {
65
+ "compaction": {
66
+ "enabled": true,
67
+ "threshold": 0.75,
68
+ "schedule": "both",
69
+ "dailyAtUtc": "00:00",
70
+ "keepRecentPerKind": 25,
71
+ "pruneCycleDays": 30
72
+ }
73
+ }
74
+ ```
75
+
76
+ ## Modes
77
+ | schedule | trigger |
78
+ |-------------|---------|
79
+ | `threshold` | memory pool > `threshold` × reference context window |
80
+ | `daily` | first cycle after today's `dailyAtUtc` if not already run |
81
+ | `both` | either of the above |
82
+ | `off` | never |
83
+
84
+ ## Pitfalls
85
+ - A very low threshold (e.g. 0.2) means compaction runs often — each
86
+ run costs ~1 Haiku call per memory batch. Default 0.75 is fine for
87
+ almost everyone.
88
+ - `dailyAtUtc` is UTC, not local. If you're in Pacific, `00:00` is
89
+ 5pm the previous day.
90
+ - Compaction makes a Haiku call per ~40-memory batch to summarize.
91
+ Keep it enabled unless you want full verbatim history.
92
+ - `pruneCycleDays: 0` disables cycle-log pruning entirely — the DB
93
+ will keep every cycle row forever.
94
+
95
+ ## Verification
96
+ - `bajaclaw compact --dry-run` shows current pool size, trigger state,
97
+ and policy.
98
+ - After a run: `bajaclaw status` — cycle count drops if rows were
99
+ pruned; `memories` row count drops; `bajaclaw.db` file shrinks after
100
+ VACUUM.
101
+ - The profile log (`logs/bajaclaw.log`) emits `compact.trigger` and
102
+ `compact.done` lines.
@@ -0,0 +1,49 @@
1
+ ---
2
+ name: setup-daemon
3
+ description: Start, stop, inspect, and auto-install the BajaClaw heartbeat daemon
4
+ version: 0.1.0
5
+ tools: [Bash, Read]
6
+ triggers: ["daemon", "background run", "start daemon", "keep running", "run forever"]
7
+ effort: low
8
+ ---
9
+
10
+ ## When to use
11
+ User wants BajaClaw running in the background: reacting to inbound channel
12
+ messages, processing the task queue, and handling the OS scheduler's
13
+ heartbeat triggers.
14
+
15
+ ## Quick reference
16
+ - Launcher: `bin/bajaclaw.js daemon …`
17
+ - Pid file: `~/.bajaclaw/profiles/<profile>/daemon.pid`
18
+ - Log: `~/.bajaclaw/profiles/<profile>/daemon.log`
19
+ - Supervisor loop: exponential backoff on crash, 1s → 5min.
20
+ - OS-scheduler entry: `daemon install` drops a plist/unit/cron/schtasks.
21
+
22
+ ## Procedure
23
+ 1. Start in foreground (debugging): `bajaclaw daemon start <profile> --fg`
24
+ 2. Start backgrounded: `bajaclaw daemon start <profile>`
25
+ - Writes pid file; detaches; unrefs.
26
+ 3. Check status: `bajaclaw daemon status <profile>`
27
+ - `running (pid N)` or `stale pid N` or `stopped`.
28
+ 4. Tail logs: `bajaclaw daemon logs <profile> --lines 100`
29
+ 5. Restart: `bajaclaw daemon restart <profile>`
30
+ 6. Stop: `bajaclaw daemon stop <profile>` (SIGTERM + pid cleanup).
31
+ 7. Auto-start on login: `bajaclaw daemon install <profile>` — creates a
32
+ `*/15 * * * *` OS-scheduler entry that invokes `bajaclaw start <profile>`.
33
+
34
+ ## Pitfalls
35
+ - Two daemons per profile are not supported. `start` detects a running pid
36
+ and refuses.
37
+ - A stale pid file survives OS reboots occasionally. If `status` reports
38
+ "stale", delete the pid file and retry.
39
+ - The OS-scheduler entry installed by `daemon install` runs `bajaclaw
40
+ start` (a one-shot cycle), not the supervisor loop itself. For a long-
41
+ running supervisor, use `daemon start`. Use both together for
42
+ belt-and-suspenders.
43
+
44
+ ## Verification
45
+ - `bajaclaw daemon status <profile>` → `running (pid N)`
46
+ - `bajaclaw daemon logs <profile>` → cycle events
47
+ - After OS-scheduler install: `crontab -l` / `launchctl list` /
48
+ `schtasks /Query` / `systemctl --user list-timers` shows a `bajaclaw-*`
49
+ entry.
@@ -0,0 +1,39 @@
1
+ ---
2
+ name: setup-dashboard
3
+ description: Launch the BajaClaw dashboard and configure its port
4
+ version: 0.1.0
5
+ tools: [Bash, Read, Edit, Write]
6
+ triggers: ["dashboard", "web ui", "show ui", "open dashboard", "launch dashboard"]
7
+ effort: low
8
+ ---
9
+
10
+ ## When to use
11
+ User wants a browser-visible view of cycles, memories, schedules, and
12
+ tasks.
13
+
14
+ ## Quick reference
15
+ - Single-page HTML at `src/dashboard.html`, vanilla JS + Tailwind CDN.
16
+ - Server: `src/commands/dashboard.ts`.
17
+ - Port: profile config's `dashboardPort` (default 7337).
18
+ - Data: read directly from the profile's SQLite DB via `/api/*` routes.
19
+
20
+ ## Procedure
21
+ 1. Run: `bajaclaw dashboard <profile>` (profile defaults to `default`).
22
+ 2. Open http://localhost:7337/ in a browser.
23
+ 3. To change the port: edit
24
+ `~/.bajaclaw/profiles/<profile>/config.json` and set
25
+ `"dashboardPort": <N>`. Restart the command.
26
+
27
+ ## Pitfalls
28
+ - If port 7337 is taken, the server will fail to bind. Change the port or
29
+ free it.
30
+ - The dashboard is a raw HTTP server with no auth. Only bind it to
31
+ localhost (default behavior). Don't expose it to a LAN without a proxy +
32
+ auth in front.
33
+ - Refresh happens every 5s. If the tab sits open for days, the browser
34
+ keeps the connection pool tight — not a bug, just a long-run caveat.
35
+
36
+ ## Verification
37
+ - `curl -s http://localhost:<PORT>/api/summary` returns JSON including the
38
+ profile name.
39
+ - Browser tab at `/` shows the cycles panel populated after any cycle runs.
@@ -0,0 +1,54 @@
1
+ ---
2
+ name: setup-discord
3
+ description: Walk the user through adding a Discord bot adapter to BajaClaw
4
+ version: 0.1.0
5
+ tools: [Bash, Read, Write, Edit]
6
+ triggers: ["setup discord", "help me with discord", "connect discord", "discord bot", "add discord", "discord setup"]
7
+ effort: medium
8
+ ---
9
+
10
+ ## When to use
11
+ The user asks you to connect Discord, wire up a Discord bot, route messages
12
+ from a channel into BajaClaw, or reply from BajaClaw back to Discord.
13
+
14
+ ## Quick reference
15
+ - Adapter: `src/channels/gateway.ts`, uses `discord.js` (optional dep)
16
+ - Token source: Discord Developer Portal → Applications → New Application →
17
+ Bot → Reset Token
18
+ - Required bot intents: Guilds, GuildMessages, MessageContent, DirectMessages
19
+ - Channel id: right-click a channel in Discord (Developer Mode on) →
20
+ "Copy Channel ID"
21
+
22
+ ## Procedure
23
+ 1. Ask if the user already has a Discord bot token + invited the bot to
24
+ their server.
25
+ - If not: walk them to https://discord.com/developers/applications. Steps:
26
+ New Application → Bot tab → Reset Token → copy. Under "Privileged Gateway
27
+ Intents", enable "MESSAGE CONTENT INTENT". Under OAuth2 → URL Generator,
28
+ tick `bot` + `applications.commands`, plus the message permissions,
29
+ and visit the generated URL to add the bot to their server.
30
+ 2. Ask for the channel id where the bot should listen (Discord Developer
31
+ Mode must be on: Settings → Advanced → Developer Mode).
32
+ 3. Ask for the user's numeric Discord user id (right-click own avatar →
33
+ Copy User ID). This goes in the allowlist.
34
+ 4. Run: `bajaclaw channel add <profile> discord --token <TOKEN> --channel-id <CHANNEL_ID>`
35
+ 5. Edit `~/.bajaclaw/profiles/<profile>/config.json` and add the numeric
36
+ user id to `channels[].allowlist` for the discord entry: `[<USER_ID>]`.
37
+ 6. Start the gateway: `bajaclaw daemon start <profile>`.
38
+ 7. Send a test message in the channel; expect it to appear as a task.
39
+
40
+ ## Pitfalls
41
+ - `npm install discord.js` if the dep is missing (optional).
42
+ - The bot must be added to the server BEFORE it can read messages — OAuth2
43
+ URL step is not optional.
44
+ - Without the MessageContent intent enabled in the Developer Portal AND in
45
+ the code (`discord.js` GatewayIntentBits.MessageContent), message bodies
46
+ will be empty strings. The adapter already sets the intent; double-check
47
+ the portal side.
48
+ - DMs: set `channelId` to the user's DM channel id OR remove the
49
+ `channelId` filter in the config to accept any channel the bot sees.
50
+
51
+ ## Verification
52
+ - `bajaclaw channel list <profile>` shows the discord entry.
53
+ - Logs contain `gateway.discord.msg` entries after test messages.
54
+ - `bajaclaw status <profile>` shows incremented pending-tasks count.
@@ -0,0 +1,51 @@
1
+ ---
2
+ name: setup-heartbeat
3
+ description: Schedule a recurring heartbeat cycle via the OS-native scheduler
4
+ version: 0.1.0
5
+ tools: [Bash, Read, Write, Edit]
6
+ triggers: ["setup heartbeat", "schedule bajaclaw", "auto run", "cron", "daily cycle", "install heartbeat", "recurring task"]
7
+ effort: low
8
+ ---
9
+
10
+ ## When to use
11
+ The user wants BajaClaw to run on its own — daily briefing, periodic inbox
12
+ triage, background research — without them typing `bajaclaw start`.
13
+
14
+ ## Quick reference
15
+ - Adapters: `src/scheduler/` — launchd (macOS), systemd-user or crontab
16
+ (Linux), schtasks (Windows). `pickAdapter()` auto-selects.
17
+ - Entry: `bajaclaw daemon install <profile>` creates a `*/15 * * * *`
18
+ heartbeat by default.
19
+ - Heartbeat tasks live in `HEARTBEAT.md` in the profile directory,
20
+ line-separated as `<cron> | <task>`.
21
+ - Supervisor loop: `bajaclaw daemon start <profile>` (backgrounds itself).
22
+
23
+ ## Procedure
24
+ 1. Ask how often they want cycles to run. Common picks:
25
+ - every 15 min: `*/15 * * * *` (default)
26
+ - every hour: `0 * * * *`
27
+ - daily at 9am: `0 9 * * *`
28
+ - weekdays at 9am: `0 9 * * 1-5`
29
+ 2. Ask what the heartbeat should do. "Check pending tasks" is a safe default.
30
+ 3. Open `~/.bajaclaw/profiles/<profile>/HEARTBEAT.md` and add a line like:
31
+ `0 9 * * * | Run the daily briefing and surface anything urgent.`
32
+ 4. Run `bajaclaw daemon install <profile>` to register the OS scheduler
33
+ entry. (This uses `*/15 * * * *` — adjust via the adapter's install call
34
+ or by installing a custom cron entry manually.)
35
+ 5. Run `bajaclaw daemon start <profile>` to start the supervisor loop. It
36
+ auto-restarts with exponential backoff on crash.
37
+ 6. Verify: `bajaclaw daemon status <profile>` shows a running pid.
38
+
39
+ ## Pitfalls
40
+ - On Linux without a user systemd bus, the adapter falls back to crontab.
41
+ - launchd plists use a simplified cron → HH:MM conversion; complex cron
42
+ expressions degrade to "first run" only.
43
+ - `schtasks` needs an interactive desktop session for the first run on some
44
+ Windows configurations.
45
+ - If the daemon's pid file is stale (`bajaclaw daemon status` says "stale
46
+ pid"), delete `~/.bajaclaw/profiles/<profile>/daemon.pid` and retry.
47
+
48
+ ## Verification
49
+ - `bajaclaw daemon status <profile>` → `running (pid N)`
50
+ - `bajaclaw daemon logs <profile>` → periodic `cycle.ok` entries
51
+ - `bajaclaw status <profile>` → cycles count rising over time
@@ -0,0 +1,54 @@
1
+ ---
2
+ name: setup-mcp-port
3
+ description: Port MCP servers from the desktop CLI into BajaClaw's isolated MCP config
4
+ version: 0.1.0
5
+ tools: [Bash, Read, Edit]
6
+ triggers: ["port mcp", "copy mcp", "setup mcp", "mcp servers", "import mcp", "share mcp", "use desktop mcp"]
7
+ effort: low
8
+ ---
9
+
10
+ ## When to use
11
+ User has MCP servers configured for their desktop CLI (Filesystem, GitHub,
12
+ Slack, Google Drive, etc.) and wants BajaClaw cycles to use them too.
13
+
14
+ ## Quick reference
15
+ - BajaClaw MCP is isolated by default. Desktop MCP config is not inherited.
16
+ - User-global BajaClaw MCP lives at `~/.bajaclaw/mcp-config.json`.
17
+ - Profile-scoped: `~/.bajaclaw/profiles/<profile>/mcp-config.json`.
18
+ - Agent-scoped: `~/.bajaclaw/profiles/<profile>/agent-mcp-config.json`.
19
+ - Merge order per cycle: agent > profile > user > desktop (desktop only
20
+ with `mergeDesktopMcp: true` in profile config).
21
+
22
+ ## Procedure
23
+ 1. Preview what's on the desktop side:
24
+ `bajaclaw mcp port --list`
25
+ 2. Port every server (except BajaClaw's own self-reference):
26
+ `bajaclaw mcp port`
27
+ 3. Or port a specific subset:
28
+ `bajaclaw mcp port --names filesystem github`
29
+ 4. To overwrite existing BajaClaw entries:
30
+ `bajaclaw mcp port --force`
31
+ 5. Confirm the result:
32
+ `bajaclaw mcp list <profile>` — shows the merged view for that profile.
33
+
34
+ ## Alternative: permanent auto-inherit
35
+ If the user wants every desktop MCP server auto-inherited on every cycle
36
+ (without an explicit port), edit the profile's config.json:
37
+ ```json
38
+ { "mergeDesktopMcp": true }
39
+ ```
40
+ This reverts to the pre-0.4 behavior, per profile.
41
+
42
+ ## Pitfalls
43
+ - BajaClaw's own `bajaclaw` MCP entry is always skipped during port — no
44
+ self-references.
45
+ - Port copies the server entry verbatim, including `env` vars. If a desktop
46
+ entry has env secrets, those travel with the port. Review before sharing
47
+ the config file.
48
+ - `--force` overwrites entries with the same name. Use when updating a
49
+ previously-ported entry.
50
+
51
+ ## Verification
52
+ - `ls ~/.bajaclaw/mcp-config.json` exists and contains the expected entries
53
+ - A subsequent cycle shows the MCP tools available in `bajaclaw start --dry-run`
54
+ output under the `--mcp-config` path