@openparachute/agent 0.1.0

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 (501) hide show
  1. package/.claude/scheduled_tasks.lock +1 -0
  2. package/.claude/settings.json +5 -0
  3. package/.claude/skills/add-atomic-chat-tool/SKILL.md +243 -0
  4. package/.claude/skills/add-atomic-chat-tool/atomic-chat-mcp-stdio.ts +229 -0
  5. package/.claude/skills/add-codex/SKILL.md +161 -0
  6. package/.claude/skills/add-dashboard/SKILL.md +138 -0
  7. package/.claude/skills/add-dashboard/resources/dashboard-pusher.ts +495 -0
  8. package/.claude/skills/add-emacs/SKILL.md +296 -0
  9. package/.claude/skills/add-gcal-tool/SKILL.md +210 -0
  10. package/.claude/skills/add-gchat/REMOVE.md +6 -0
  11. package/.claude/skills/add-gchat/SKILL.md +92 -0
  12. package/.claude/skills/add-gchat/VERIFY.md +3 -0
  13. package/.claude/skills/add-github/REMOVE.md +6 -0
  14. package/.claude/skills/add-github/SKILL.md +148 -0
  15. package/.claude/skills/add-github/VERIFY.md +3 -0
  16. package/.claude/skills/add-gmail-tool/SKILL.md +229 -0
  17. package/.claude/skills/add-imessage/REMOVE.md +6 -0
  18. package/.claude/skills/add-imessage/SKILL.md +113 -0
  19. package/.claude/skills/add-imessage/VERIFY.md +3 -0
  20. package/.claude/skills/add-karpathy-llm-wiki/SKILL.md +110 -0
  21. package/.claude/skills/add-karpathy-llm-wiki/llm-wiki.md +75 -0
  22. package/.claude/skills/add-linear/REMOVE.md +6 -0
  23. package/.claude/skills/add-linear/SKILL.md +168 -0
  24. package/.claude/skills/add-linear/VERIFY.md +3 -0
  25. package/.claude/skills/add-macos-statusbar/SKILL.md +133 -0
  26. package/.claude/skills/add-macos-statusbar/add/src/statusbar.swift +147 -0
  27. package/.claude/skills/add-matrix/REMOVE.md +6 -0
  28. package/.claude/skills/add-matrix/SKILL.md +148 -0
  29. package/.claude/skills/add-matrix/VERIFY.md +3 -0
  30. package/.claude/skills/add-ollama-provider/SKILL.md +179 -0
  31. package/.claude/skills/add-ollama-tool/SKILL.md +193 -0
  32. package/.claude/skills/add-opencode/SKILL.md +229 -0
  33. package/.claude/skills/add-parallel/SKILL.md +290 -0
  34. package/.claude/skills/add-resend/REMOVE.md +6 -0
  35. package/.claude/skills/add-resend/SKILL.md +93 -0
  36. package/.claude/skills/add-resend/VERIFY.md +3 -0
  37. package/.claude/skills/add-signal/REMOVE.md +13 -0
  38. package/.claude/skills/add-signal/SKILL.md +318 -0
  39. package/.claude/skills/add-signal/VERIFY.md +5 -0
  40. package/.claude/skills/add-slack/REMOVE.md +6 -0
  41. package/.claude/skills/add-slack/SKILL.md +112 -0
  42. package/.claude/skills/add-slack/VERIFY.md +3 -0
  43. package/.claude/skills/add-teams/REMOVE.md +6 -0
  44. package/.claude/skills/add-teams/SKILL.md +207 -0
  45. package/.claude/skills/add-teams/VERIFY.md +3 -0
  46. package/.claude/skills/add-vercel/SKILL.md +147 -0
  47. package/.claude/skills/add-vercel/container-skills/vercel-cli/SKILL.md +103 -0
  48. package/.claude/skills/add-webex/REMOVE.md +6 -0
  49. package/.claude/skills/add-webex/SKILL.md +88 -0
  50. package/.claude/skills/add-webex/VERIFY.md +3 -0
  51. package/.claude/skills/add-wechat/REMOVE.md +49 -0
  52. package/.claude/skills/add-wechat/SKILL.md +170 -0
  53. package/.claude/skills/add-wechat/scripts/wire-dm.ts +172 -0
  54. package/.claude/skills/add-whatsapp/SKILL.md +264 -0
  55. package/.claude/skills/add-whatsapp-cloud/REMOVE.md +6 -0
  56. package/.claude/skills/add-whatsapp-cloud/SKILL.md +95 -0
  57. package/.claude/skills/add-whatsapp-cloud/VERIFY.md +3 -0
  58. package/.claude/skills/claw/SKILL.md +131 -0
  59. package/.claude/skills/claw/scripts/claw +374 -0
  60. package/.claude/skills/convert-to-apple-container/SKILL.md +212 -0
  61. package/.claude/skills/customize/SKILL.md +110 -0
  62. package/.claude/skills/debug/SKILL.md +349 -0
  63. package/.claude/skills/get-qodo-rules/SKILL.md +122 -0
  64. package/.claude/skills/get-qodo-rules/references/output-format.md +41 -0
  65. package/.claude/skills/get-qodo-rules/references/pagination.md +33 -0
  66. package/.claude/skills/get-qodo-rules/references/repository-scope.md +26 -0
  67. package/.claude/skills/init-first-agent/SKILL.md +120 -0
  68. package/.claude/skills/init-onecli/SKILL.md +270 -0
  69. package/.claude/skills/manage-channels/SKILL.md +87 -0
  70. package/.claude/skills/manage-mounts/SKILL.md +47 -0
  71. package/.claude/skills/migrate-from-openclaw/MIGRATE_CRONS.md +100 -0
  72. package/.claude/skills/migrate-from-openclaw/SKILL.md +447 -0
  73. package/.claude/skills/migrate-from-openclaw/scripts/discover-openclaw.ts +734 -0
  74. package/.claude/skills/migrate-from-openclaw/scripts/extract-channel-credentials.ts +476 -0
  75. package/.claude/skills/migrate-nanoclaw/SKILL.md +484 -0
  76. package/.claude/skills/migrate-nanoclaw/diagnostics.md +51 -0
  77. package/.claude/skills/qodo-pr-resolver/SKILL.md +326 -0
  78. package/.claude/skills/qodo-pr-resolver/resources/providers.md +329 -0
  79. package/.claude/skills/update-nanoclaw/SKILL.md +243 -0
  80. package/.claude/skills/update-nanoclaw/diagnostics.md +48 -0
  81. package/.claude/skills/update-skills/SKILL.md +130 -0
  82. package/.claude/skills/use-native-credential-proxy/SKILL.md +167 -0
  83. package/.claude/skills/x-integration/SKILL.md +417 -0
  84. package/.claude/skills/x-integration/agent.ts +243 -0
  85. package/.claude/skills/x-integration/host.ts +155 -0
  86. package/.claude/skills/x-integration/lib/browser.ts +148 -0
  87. package/.claude/skills/x-integration/lib/config.ts +62 -0
  88. package/.claude/skills/x-integration/scripts/like.ts +56 -0
  89. package/.claude/skills/x-integration/scripts/post.ts +66 -0
  90. package/.claude/skills/x-integration/scripts/quote.ts +80 -0
  91. package/.claude/skills/x-integration/scripts/reply.ts +74 -0
  92. package/.claude/skills/x-integration/scripts/retweet.ts +62 -0
  93. package/.claude/skills/x-integration/scripts/setup.ts +87 -0
  94. package/.github/CODEOWNERS +10 -0
  95. package/.github/PULL_REQUEST_TEMPLATE.md +18 -0
  96. package/.github/workflows/bump-version.yml +35 -0
  97. package/.github/workflows/ci.yml +39 -0
  98. package/.github/workflows/label-pr.yml +40 -0
  99. package/.github/workflows/update-tokens.yml +43 -0
  100. package/.husky/pre-commit +1 -0
  101. package/.mcp.json +3 -0
  102. package/.nvmrc +1 -0
  103. package/.parachute/module.json +14 -0
  104. package/.prettierrc +4 -0
  105. package/CHANGELOG.md +215 -0
  106. package/CLAUDE.md +307 -0
  107. package/CODE_OF_CONDUCT.md +128 -0
  108. package/CONTRIBUTING.md +159 -0
  109. package/CONTRIBUTORS.md +26 -0
  110. package/LICENSE +21 -0
  111. package/README.md +190 -0
  112. package/README_ja.md +194 -0
  113. package/README_zh.md +194 -0
  114. package/assets/nanoclaw-favicon.png +0 -0
  115. package/assets/nanoclaw-icon.png +0 -0
  116. package/assets/nanoclaw-logo-dark.png +0 -0
  117. package/assets/nanoclaw-logo.png +0 -0
  118. package/assets/nanoclaw-profile.jpeg +0 -0
  119. package/assets/nanoclaw-sales.png +0 -0
  120. package/assets/social-preview.jpg +0 -0
  121. package/config-examples/mount-allowlist.json +25 -0
  122. package/container/.dockerignore +2 -0
  123. package/container/CLAUDE.md +21 -0
  124. package/container/Dockerfile +121 -0
  125. package/container/agent-runner/bun.lock +243 -0
  126. package/container/agent-runner/package.json +22 -0
  127. package/container/agent-runner/scripts/sdk-signal-probe.ts +169 -0
  128. package/container/agent-runner/src/config.ts +55 -0
  129. package/container/agent-runner/src/db/connection.ts +267 -0
  130. package/container/agent-runner/src/db/index.ts +20 -0
  131. package/container/agent-runner/src/db/messages-in.ts +138 -0
  132. package/container/agent-runner/src/db/messages-out.ts +143 -0
  133. package/container/agent-runner/src/db/session-routing.ts +30 -0
  134. package/container/agent-runner/src/db/session-state.test.ts +100 -0
  135. package/container/agent-runner/src/db/session-state.ts +79 -0
  136. package/container/agent-runner/src/destinations.ts +135 -0
  137. package/container/agent-runner/src/formatter.test.ts +167 -0
  138. package/container/agent-runner/src/formatter.ts +260 -0
  139. package/container/agent-runner/src/index.ts +110 -0
  140. package/container/agent-runner/src/integration.test.ts +121 -0
  141. package/container/agent-runner/src/mcp-tools/agents.instructions.md +26 -0
  142. package/container/agent-runner/src/mcp-tools/agents.ts +66 -0
  143. package/container/agent-runner/src/mcp-tools/core.instructions.md +27 -0
  144. package/container/agent-runner/src/mcp-tools/core.ts +262 -0
  145. package/container/agent-runner/src/mcp-tools/index.ts +22 -0
  146. package/container/agent-runner/src/mcp-tools/interactive.instructions.md +22 -0
  147. package/container/agent-runner/src/mcp-tools/interactive.ts +169 -0
  148. package/container/agent-runner/src/mcp-tools/scheduling.instructions.md +40 -0
  149. package/container/agent-runner/src/mcp-tools/scheduling.ts +299 -0
  150. package/container/agent-runner/src/mcp-tools/self-mod.instructions.md +25 -0
  151. package/container/agent-runner/src/mcp-tools/self-mod.ts +120 -0
  152. package/container/agent-runner/src/mcp-tools/server.ts +54 -0
  153. package/container/agent-runner/src/mcp-tools/types.ts +6 -0
  154. package/container/agent-runner/src/poll-loop.test.ts +248 -0
  155. package/container/agent-runner/src/poll-loop.ts +437 -0
  156. package/container/agent-runner/src/providers/claude.ts +379 -0
  157. package/container/agent-runner/src/providers/factory.test.ts +19 -0
  158. package/container/agent-runner/src/providers/factory.ts +13 -0
  159. package/container/agent-runner/src/providers/index.ts +6 -0
  160. package/container/agent-runner/src/providers/mock.ts +77 -0
  161. package/container/agent-runner/src/providers/provider-registry.ts +33 -0
  162. package/container/agent-runner/src/providers/types.ts +82 -0
  163. package/container/agent-runner/src/scheduling/task-script.ts +121 -0
  164. package/container/agent-runner/src/timezone.test.ts +93 -0
  165. package/container/agent-runner/src/timezone.ts +107 -0
  166. package/container/agent-runner/tsconfig.json +14 -0
  167. package/container/build.sh +48 -0
  168. package/container/entrypoint.sh +16 -0
  169. package/container/skills/agent-browser/SKILL.md +159 -0
  170. package/container/skills/frontend-engineer/SKILL.md +157 -0
  171. package/container/skills/self-customize/SKILL.md +87 -0
  172. package/container/skills/slack-formatting/SKILL.md +94 -0
  173. package/container/skills/vercel-cli/SKILL.md +111 -0
  174. package/container/skills/welcome/SKILL.md +85 -0
  175. package/docs/APPLE-CONTAINER-NETWORKING.md +90 -0
  176. package/docs/BRANCH-FORK-MAINTENANCE.md +81 -0
  177. package/docs/README.md +25 -0
  178. package/docs/SDK_DEEP_DIVE.md +643 -0
  179. package/docs/SECURITY.md +162 -0
  180. package/docs/agent-runner-details.md +749 -0
  181. package/docs/api-details.md +365 -0
  182. package/docs/architecture-diagram.html +422 -0
  183. package/docs/architecture-diagram.md +215 -0
  184. package/docs/architecture.md +751 -0
  185. package/docs/audit/2026-04-30-channel-endpoint-audit.md +36 -0
  186. package/docs/build-and-runtime.md +80 -0
  187. package/docs/cross-mount-stress/README.md +112 -0
  188. package/docs/cross-mount-stress/container-writer-retry.mjs +55 -0
  189. package/docs/cross-mount-stress/container-writer-slow.mjs +42 -0
  190. package/docs/cross-mount-stress/container-writer.mjs +47 -0
  191. package/docs/cross-mount-stress/host-writer-retry.mjs +55 -0
  192. package/docs/cross-mount-stress/host-writer-slow.mjs +43 -0
  193. package/docs/cross-mount-stress/host-writer.mjs +47 -0
  194. package/docs/db-central.md +316 -0
  195. package/docs/db-session.md +183 -0
  196. package/docs/db.md +119 -0
  197. package/docs/design/2026-04-29-vault-management-ui.md +231 -0
  198. package/docs/design/2026-04-30-channel-wiring-rework.md +234 -0
  199. package/docs/design/2026-05-01-channel-wiring-approvals-deep-dive.md +272 -0
  200. package/docs/design/2026-05-02-channel-policy-and-approval-routing.md +250 -0
  201. package/docs/docker-sandboxes.md +359 -0
  202. package/docs/isolation-model.md +88 -0
  203. package/docs/ollama.md +79 -0
  204. package/docs/parachute-integration.md +109 -0
  205. package/docs/post-night-rebirth-reflections.md +151 -0
  206. package/eslint.config.js +32 -0
  207. package/package.json +54 -0
  208. package/pnpm-workspace.yaml +8 -0
  209. package/repo-tokens/README.md +113 -0
  210. package/repo-tokens/action.yml +186 -0
  211. package/repo-tokens/badge.svg +23 -0
  212. package/repo-tokens/examples/green.svg +14 -0
  213. package/repo-tokens/examples/red.svg +14 -0
  214. package/repo-tokens/examples/yellow-green.svg +14 -0
  215. package/repo-tokens/examples/yellow.svg +14 -0
  216. package/scripts/chat.ts +101 -0
  217. package/scripts/cleanup-sessions.sh +150 -0
  218. package/scripts/init-cli-agent.ts +171 -0
  219. package/scripts/init-first-agent.ts +377 -0
  220. package/scripts/parachute.ts +158 -0
  221. package/scripts/run-migrations.ts +105 -0
  222. package/scripts/sanity-live-poll.ts +95 -0
  223. package/scripts/seed-discord.ts +79 -0
  224. package/scripts/test-v2-agent.ts +106 -0
  225. package/scripts/test-v2-channel-e2e.ts +265 -0
  226. package/scripts/test-v2-host.ts +184 -0
  227. package/src/channels/adapter.ts +214 -0
  228. package/src/channels/ask-question.ts +46 -0
  229. package/src/channels/channel-registry.test.ts +421 -0
  230. package/src/channels/channel-registry.ts +313 -0
  231. package/src/channels/chat-sdk-bridge.test.ts +84 -0
  232. package/src/channels/chat-sdk-bridge.ts +652 -0
  233. package/src/channels/cli.ts +276 -0
  234. package/src/channels/discord.ts +90 -0
  235. package/src/channels/index.ts +17 -0
  236. package/src/channels/telegram-markdown-sanitize.test.ts +78 -0
  237. package/src/channels/telegram-markdown-sanitize.ts +55 -0
  238. package/src/channels/telegram-pairing.test.ts +254 -0
  239. package/src/channels/telegram-pairing.ts +339 -0
  240. package/src/channels/telegram.ts +279 -0
  241. package/src/channels/trust-hint.test.ts +48 -0
  242. package/src/channels/trust-hint.ts +75 -0
  243. package/src/claude-md-compose.migrate.test.ts +64 -0
  244. package/src/claude-md-compose.ts +205 -0
  245. package/src/command-gate.ts +63 -0
  246. package/src/config.test.ts +93 -0
  247. package/src/config.ts +108 -0
  248. package/src/container-config.ts +167 -0
  249. package/src/container-runner.test.ts +32 -0
  250. package/src/container-runner.ts +576 -0
  251. package/src/container-runtime.test.ts +169 -0
  252. package/src/container-runtime.ts +92 -0
  253. package/src/db/_bun-sqlite-shim.ts +88 -0
  254. package/src/db/agent-activity.test.ts +155 -0
  255. package/src/db/agent-activity.ts +121 -0
  256. package/src/db/agent-groups.ts +77 -0
  257. package/src/db/connection.migrate.test.ts +143 -0
  258. package/src/db/connection.ts +224 -0
  259. package/src/db/db-v2.test.ts +440 -0
  260. package/src/db/dropped-messages.ts +44 -0
  261. package/src/db/index.ts +40 -0
  262. package/src/db/messaging-groups.ts +252 -0
  263. package/src/db/migrations/001-initial.ts +112 -0
  264. package/src/db/migrations/002-chat-sdk-state.ts +36 -0
  265. package/src/db/migrations/008-dropped-messages.ts +27 -0
  266. package/src/db/migrations/009-drop-pending-credentials.ts +13 -0
  267. package/src/db/migrations/010-engage-modes.ts +103 -0
  268. package/src/db/migrations/011-pending-sender-approvals.ts +40 -0
  269. package/src/db/migrations/012-channel-registration.ts +48 -0
  270. package/src/db/migrations/013-approval-render-metadata.ts +27 -0
  271. package/src/db/migrations/014-secrets.ts +44 -0
  272. package/src/db/migrations/015-secrets-drop-host-pattern.ts +18 -0
  273. package/src/db/migrations/016-secret-assignments.ts +30 -0
  274. package/src/db/migrations/017-agent-activity.ts +40 -0
  275. package/src/db/migrations/018-oauth-app-configs.ts +34 -0
  276. package/src/db/migrations/019-oauth-app-connections.ts +48 -0
  277. package/src/db/migrations/020-agent-app-connections.ts +28 -0
  278. package/src/db/migrations/021-pending-oauth-states.ts +35 -0
  279. package/src/db/migrations/022-app-connections-provider.ts +25 -0
  280. package/src/db/migrations/023-agent-group-secret-mode.test.ts +124 -0
  281. package/src/db/migrations/023-agent-group-secret-mode.ts +65 -0
  282. package/src/db/migrations/024-collapse-approvals.test.ts +249 -0
  283. package/src/db/migrations/024-collapse-approvals.ts +182 -0
  284. package/src/db/migrations/025-secret-mode-check.test.ts +155 -0
  285. package/src/db/migrations/025-secret-mode-check.ts +49 -0
  286. package/src/db/migrations/026-user-dms-bot-id.test.ts +116 -0
  287. package/src/db/migrations/026-user-dms-bot-id.ts +54 -0
  288. package/src/db/migrations/027-provider-credentials.ts +41 -0
  289. package/src/db/migrations/_test-helpers.ts +41 -0
  290. package/src/db/migrations/index.ts +127 -0
  291. package/src/db/migrations/module-agent-to-agent-destinations.ts +84 -0
  292. package/src/db/migrations/module-approvals-pending-approvals.ts +42 -0
  293. package/src/db/migrations/module-approvals-title-options.ts +40 -0
  294. package/src/db/schema.ts +258 -0
  295. package/src/db/session-db.test.ts +93 -0
  296. package/src/db/session-db.ts +325 -0
  297. package/src/db/sessions.ts +241 -0
  298. package/src/delivery.test.ts +148 -0
  299. package/src/delivery.ts +445 -0
  300. package/src/env.ts +74 -0
  301. package/src/group-folder.test.ts +35 -0
  302. package/src/group-folder.ts +44 -0
  303. package/src/group-init.ts +92 -0
  304. package/src/host-core.test.ts +456 -0
  305. package/src/host-sweep.test.ts +146 -0
  306. package/src/host-sweep.ts +287 -0
  307. package/src/index.ts +227 -0
  308. package/src/install-slug.ts +33 -0
  309. package/src/log.test.ts +81 -0
  310. package/src/log.ts +117 -0
  311. package/src/mcp/http.ts +72 -0
  312. package/src/mcp/server.ts +92 -0
  313. package/src/mcp/stdio.ts +51 -0
  314. package/src/mcp/tools/activity.ts +88 -0
  315. package/src/mcp/tools/agent-groups.ts +183 -0
  316. package/src/mcp/tools/approvals.ts +122 -0
  317. package/src/mcp/tools/channels.ts +199 -0
  318. package/src/mcp/tools/index.ts +27 -0
  319. package/src/mcp/tools/oauth.ts +48 -0
  320. package/src/mcp/tools/secrets.ts +169 -0
  321. package/src/mcp/tools/sessions.ts +135 -0
  322. package/src/mcp/types.ts +51 -0
  323. package/src/modules/agent-to-agent/agent-route.test.ts +46 -0
  324. package/src/modules/agent-to-agent/agent-route.ts +223 -0
  325. package/src/modules/agent-to-agent/create-agent.ts +127 -0
  326. package/src/modules/agent-to-agent/db/agent-destinations.ts +135 -0
  327. package/src/modules/agent-to-agent/index.ts +22 -0
  328. package/src/modules/agent-to-agent/write-destinations.ts +59 -0
  329. package/src/modules/approvals/agent.md +45 -0
  330. package/src/modules/approvals/index.ts +21 -0
  331. package/src/modules/approvals/picks.test.ts +291 -0
  332. package/src/modules/approvals/primitive.ts +279 -0
  333. package/src/modules/approvals/project.md +27 -0
  334. package/src/modules/approvals/response-handler.ts +87 -0
  335. package/src/modules/index.ts +24 -0
  336. package/src/modules/interactive/agent.md +21 -0
  337. package/src/modules/interactive/index.ts +69 -0
  338. package/src/modules/interactive/project.md +12 -0
  339. package/src/modules/mount-security/index.ts +448 -0
  340. package/src/modules/mount-security/migrate.test.ts +91 -0
  341. package/src/modules/permissions/access.ts +28 -0
  342. package/src/modules/permissions/channel-approval.test.ts +389 -0
  343. package/src/modules/permissions/channel-approval.ts +188 -0
  344. package/src/modules/permissions/db/agent-group-members.ts +44 -0
  345. package/src/modules/permissions/db/pending-channel-approvals.test.ts +86 -0
  346. package/src/modules/permissions/db/pending-channel-approvals.ts +66 -0
  347. package/src/modules/permissions/db/pending-sender-approvals.ts +60 -0
  348. package/src/modules/permissions/db/user-dms.ts +58 -0
  349. package/src/modules/permissions/db/user-roles.ts +85 -0
  350. package/src/modules/permissions/db/users.ts +38 -0
  351. package/src/modules/permissions/index.ts +421 -0
  352. package/src/modules/permissions/permissions.test.ts +358 -0
  353. package/src/modules/permissions/sender-approval.test.ts +470 -0
  354. package/src/modules/permissions/sender-approval.ts +165 -0
  355. package/src/modules/permissions/user-dm.ts +200 -0
  356. package/src/modules/provider-credentials/db.ts +121 -0
  357. package/src/modules/provider-credentials/index.ts +12 -0
  358. package/src/modules/provider-credentials/spawn.test.ts +206 -0
  359. package/src/modules/provider-credentials/spawn.ts +114 -0
  360. package/src/modules/scheduling/actions.ts +113 -0
  361. package/src/modules/scheduling/db.test.ts +282 -0
  362. package/src/modules/scheduling/db.ts +148 -0
  363. package/src/modules/scheduling/index.ts +34 -0
  364. package/src/modules/scheduling/recurrence.test.ts +98 -0
  365. package/src/modules/scheduling/recurrence.ts +54 -0
  366. package/src/modules/self-mod/agent.md +30 -0
  367. package/src/modules/self-mod/apply.ts +85 -0
  368. package/src/modules/self-mod/index.ts +30 -0
  369. package/src/modules/self-mod/project.md +39 -0
  370. package/src/modules/self-mod/request.ts +91 -0
  371. package/src/modules/typing/index.ts +165 -0
  372. package/src/oauth/agent-app-connections.ts +103 -0
  373. package/src/oauth/app-configs.test.ts +64 -0
  374. package/src/oauth/app-configs.ts +114 -0
  375. package/src/oauth/app-connections.test.ts +109 -0
  376. package/src/oauth/app-connections.ts +178 -0
  377. package/src/oauth/crypto.ts +56 -0
  378. package/src/oauth/flow.ts +104 -0
  379. package/src/oauth/providers/google.test.ts +38 -0
  380. package/src/oauth/providers/google.ts +46 -0
  381. package/src/oauth/providers/index.ts +48 -0
  382. package/src/oauth/state-store.test.ts +54 -0
  383. package/src/oauth/state-store.ts +93 -0
  384. package/src/parachute/README.md +27 -0
  385. package/src/parachute/create-agent.test.ts +83 -0
  386. package/src/parachute/create-agent.ts +122 -0
  387. package/src/parachute/group-status.test.ts +165 -0
  388. package/src/parachute/group-status.ts +136 -0
  389. package/src/parachute/types.ts +41 -0
  390. package/src/parachute/vault-mcp.test.ts +251 -0
  391. package/src/parachute/vault-mcp.ts +232 -0
  392. package/src/platform-id.test.ts +104 -0
  393. package/src/platform-id.ts +109 -0
  394. package/src/providers/index.ts +6 -0
  395. package/src/providers/provider-container-registry.ts +58 -0
  396. package/src/response-registry.ts +45 -0
  397. package/src/router.ts +530 -0
  398. package/src/secrets/crypto.test.ts +45 -0
  399. package/src/secrets/crypto.ts +55 -0
  400. package/src/secrets/index.ts +355 -0
  401. package/src/secrets/master-key.ts +70 -0
  402. package/src/secrets/secrets.test.ts +354 -0
  403. package/src/session-manager.migrate.test.ts +59 -0
  404. package/src/session-manager.ts +433 -0
  405. package/src/startup-bootstrap.test.ts +226 -0
  406. package/src/startup-bootstrap.ts +207 -0
  407. package/src/state-sqlite.ts +182 -0
  408. package/src/timezone.test.ts +64 -0
  409. package/src/timezone.ts +37 -0
  410. package/src/types.ts +230 -0
  411. package/src/web/auth.test.ts +335 -0
  412. package/src/web/auth.ts +214 -0
  413. package/src/web/discord-validate.test.ts +77 -0
  414. package/src/web/discord-validate.ts +88 -0
  415. package/src/web/hub-discovery.test.ts +98 -0
  416. package/src/web/hub-discovery.ts +69 -0
  417. package/src/web/routes/activity.ts +106 -0
  418. package/src/web/routes/agent-provider.test.ts +282 -0
  419. package/src/web/routes/agent-provider.ts +309 -0
  420. package/src/web/routes/approvals.ts +185 -0
  421. package/src/web/routes/apps.ts +434 -0
  422. package/src/web/routes/channels-mg-detail.test.ts +324 -0
  423. package/src/web/routes/channels-mga-detail.test.ts +425 -0
  424. package/src/web/routes/channels.ts +489 -0
  425. package/src/web/routes/oauth-providers.ts +42 -0
  426. package/src/web/routes/secrets.test.ts +175 -0
  427. package/src/web/routes/secrets.ts +282 -0
  428. package/src/web/routes/sessions.ts +123 -0
  429. package/src/web/routes/settings.test.ts +106 -0
  430. package/src/web/routes/settings.ts +247 -0
  431. package/src/web/routes/setup-status.ts +205 -0
  432. package/src/web/routes/vaults.test.ts +389 -0
  433. package/src/web/routes/vaults.ts +225 -0
  434. package/src/web/server-version.test.ts +16 -0
  435. package/src/web/server.ts +1003 -0
  436. package/src/web/services-manifest.test.ts +120 -0
  437. package/src/web/services-manifest.ts +61 -0
  438. package/src/web/static-serve.test.ts +255 -0
  439. package/src/web/static-serve.ts +104 -0
  440. package/src/web/telegram-validate.test.ts +116 -0
  441. package/src/web/telegram-validate.ts +107 -0
  442. package/src/web/vault-proxy.test.ts +214 -0
  443. package/src/web/vault-proxy.ts +120 -0
  444. package/src/web/wire-channel.ts +181 -0
  445. package/src/webhook-server.ts +134 -0
  446. package/tsconfig.json +21 -0
  447. package/vitest.config.ts +18 -0
  448. package/web/README.md +63 -0
  449. package/web/ui/index.html +13 -0
  450. package/web/ui/package.json +35 -0
  451. package/web/ui/pnpm-lock.yaml +2164 -0
  452. package/web/ui/scripts/verify-base.mjs +31 -0
  453. package/web/ui/src/App.tsx +88 -0
  454. package/web/ui/src/components/ActivityFeed.tsx +444 -0
  455. package/web/ui/src/components/AgentGroupPicker.tsx +263 -0
  456. package/web/ui/src/components/AgentProviderCards.tsx +220 -0
  457. package/web/ui/src/components/CredentialForm.tsx +214 -0
  458. package/web/ui/src/components/ScopeGrants.tsx +74 -0
  459. package/web/ui/src/components/StatusDot.tsx +43 -0
  460. package/web/ui/src/components/VaultPicker.tsx +127 -0
  461. package/web/ui/src/components/setup/AdapterInstallStep.tsx +178 -0
  462. package/web/ui/src/components/setup/AgentGroupStep.tsx +43 -0
  463. package/web/ui/src/components/setup/ChannelPickStep.tsx +74 -0
  464. package/web/ui/src/components/setup/DoneStep.tsx +49 -0
  465. package/web/ui/src/components/setup/PrereqStep.tsx +129 -0
  466. package/web/ui/src/components/setup/TestConnectionStep.tsx +108 -0
  467. package/web/ui/src/components/setup/TestMessageStep.tsx +104 -0
  468. package/web/ui/src/components/setup/WireChannelStep.tsx +166 -0
  469. package/web/ui/src/components/setup/types.ts +105 -0
  470. package/web/ui/src/lib/api.test.ts +410 -0
  471. package/web/ui/src/lib/api.ts +1210 -0
  472. package/web/ui/src/lib/auth.test.ts +139 -0
  473. package/web/ui/src/lib/auth.ts +348 -0
  474. package/web/ui/src/lib/channel-adapters.ts +136 -0
  475. package/web/ui/src/main.tsx +19 -0
  476. package/web/ui/src/routes/ApprovalsList.tsx +294 -0
  477. package/web/ui/src/routes/Apps.tsx +613 -0
  478. package/web/ui/src/routes/ChannelWireDetail.test.tsx +233 -0
  479. package/web/ui/src/routes/ChannelWireDetail.tsx +403 -0
  480. package/web/ui/src/routes/ChannelsList.tsx +158 -0
  481. package/web/ui/src/routes/GroupDetail.tsx +755 -0
  482. package/web/ui/src/routes/GroupList.tsx +187 -0
  483. package/web/ui/src/routes/MessagingGroupDetail.test.tsx +233 -0
  484. package/web/ui/src/routes/MessagingGroupDetail.tsx +306 -0
  485. package/web/ui/src/routes/NewGroupWizard.tsx +390 -0
  486. package/web/ui/src/routes/OAuthCallback.tsx +56 -0
  487. package/web/ui/src/routes/SecretsList.tsx +921 -0
  488. package/web/ui/src/routes/SessionsList.tsx +220 -0
  489. package/web/ui/src/routes/SettingsAgentProvider.tsx +109 -0
  490. package/web/ui/src/routes/SettingsApprovals.tsx +234 -0
  491. package/web/ui/src/routes/SetupWizard.tsx +219 -0
  492. package/web/ui/src/routes/VaultDetail.test.tsx +361 -0
  493. package/web/ui/src/routes/VaultDetail.tsx +960 -0
  494. package/web/ui/src/routes/VaultsList.tsx +295 -0
  495. package/web/ui/src/routes/WireChannelPage.tsx +413 -0
  496. package/web/ui/src/styles.css +608 -0
  497. package/web/ui/src/test/setup.ts +23 -0
  498. package/web/ui/src/vite-env.d.ts +10 -0
  499. package/web/ui/tsconfig.json +20 -0
  500. package/web/ui/vite.config.ts +34 -0
  501. package/web/ui/vitest.config.ts +25 -0
@@ -0,0 +1,374 @@
1
+ #!/usr/bin/env python3
2
+ """
3
+ claw — NanoClaw CLI
4
+ Run a NanoClaw agent container from the command line.
5
+
6
+ Usage:
7
+ claw "What is 2+2?"
8
+ claw -g <channel_name> "Review this code"
9
+ claw -g "<channel name with spaces>" "What's the latest issue?"
10
+ claw -j "<chatJid>" "Hello"
11
+ claw -g <channel_name> -s <session-id> "Continue"
12
+ claw --list-groups
13
+ echo "prompt text" | claw --pipe -g <channel_name>
14
+ cat prompt.txt | claw --pipe
15
+ """
16
+
17
+ from __future__ import annotations
18
+
19
+ import argparse
20
+ import json
21
+ import os
22
+ import re
23
+ import sqlite3
24
+ import subprocess
25
+ import sys
26
+ import threading
27
+ from pathlib import Path
28
+
29
+ # ── Globals ─────────────────────────────────────────────────────────────────
30
+
31
+ VERBOSE = False
32
+
33
+ def dbg(*args):
34
+ if VERBOSE:
35
+ print("»", *args, file=sys.stderr)
36
+
37
+ # ── Config ──────────────────────────────────────────────────────────────────
38
+
39
+ def _find_nanoclaw_dir() -> Path:
40
+ """Locate the NanoClaw installation directory.
41
+
42
+ Resolution order:
43
+ 1. NANOCLAW_DIR env var
44
+ 2. The directory containing this script (if it looks like a NanoClaw install)
45
+ 3. ~/src/nanoclaw (legacy default)
46
+ """
47
+ if env := os.environ.get("NANOCLAW_DIR"):
48
+ return Path(env).expanduser()
49
+ # If this script lives inside the NanoClaw tree (e.g. scripts/claw), walk up
50
+ here = Path(__file__).resolve()
51
+ for parent in [here.parent, here.parent.parent]:
52
+ if (parent / "store" / "messages.db").exists() or (parent / ".env").exists():
53
+ return parent
54
+ return Path.home() / "src" / "nanoclaw"
55
+
56
+ NANOCLAW_DIR = _find_nanoclaw_dir()
57
+ DB_PATH = NANOCLAW_DIR / "store" / "messages.db"
58
+ ENV_FILE = NANOCLAW_DIR / ".env"
59
+ IMAGE = "nanoclaw-agent:latest"
60
+
61
+ SECRET_KEYS = [
62
+ "CLAUDE_CODE_OAUTH_TOKEN",
63
+ "ANTHROPIC_API_KEY",
64
+ "ANTHROPIC_BASE_URL",
65
+ "ANTHROPIC_AUTH_TOKEN",
66
+ "OLLAMA_HOST",
67
+ ]
68
+
69
+ # ── Helpers ──────────────────────────────────────────────────────────────────
70
+
71
+ def detect_runtime(preference: str | None) -> str:
72
+ if preference:
73
+ dbg(f"runtime: forced to {preference}")
74
+ return preference
75
+ for rt in ("container", "docker"):
76
+ result = subprocess.run(["which", rt], capture_output=True)
77
+ if result.returncode == 0:
78
+ dbg(f"runtime: auto-detected {rt} at {result.stdout.decode().strip()}")
79
+ return rt
80
+ sys.exit("error: neither 'container' nor 'docker' found. Install one or pass --runtime.")
81
+
82
+
83
+ def read_secrets(env_file: Path) -> dict:
84
+ secrets = {}
85
+ if not env_file.exists():
86
+ return secrets
87
+ for line in env_file.read_text().splitlines():
88
+ line = line.strip()
89
+ if not line or line.startswith("#"):
90
+ continue
91
+ if "=" in line:
92
+ key, _, val = line.partition("=")
93
+ key = key.strip()
94
+ if key in SECRET_KEYS:
95
+ secrets[key] = val.strip()
96
+ return secrets
97
+
98
+
99
+ def get_groups(db: Path) -> list[dict]:
100
+ conn = sqlite3.connect(db)
101
+ rows = conn.execute(
102
+ "SELECT jid, name, folder, is_main FROM registered_groups ORDER BY name"
103
+ ).fetchall()
104
+ conn.close()
105
+ return [{"jid": r[0], "name": r[1], "folder": r[2], "is_main": bool(r[3])} for r in rows]
106
+
107
+
108
+ def find_group(groups: list[dict], query: str) -> dict | None:
109
+ q = query.lower()
110
+ # Exact name match
111
+ for g in groups:
112
+ if g["name"].lower() == q or g["folder"].lower() == q:
113
+ return g
114
+ # Partial match
115
+ matches = [g for g in groups if q in g["name"].lower() or q in g["folder"].lower()]
116
+ if len(matches) == 1:
117
+ return matches[0]
118
+ if len(matches) > 1:
119
+ names = ", ".join(f'"{g["name"]}"' for g in matches)
120
+ sys.exit(f"error: ambiguous group '{query}'. Matches: {names}")
121
+ return None
122
+
123
+
124
+ def build_mounts(folder: str, is_main: bool) -> list[tuple[str, str, bool]]:
125
+ """Return list of (host_path, container_path, readonly) tuples."""
126
+ groups_dir = NANOCLAW_DIR / "groups"
127
+ data_dir = NANOCLAW_DIR / "data"
128
+ sessions_dir = data_dir / "sessions" / folder
129
+ ipc_dir = data_dir / "ipc" / folder
130
+
131
+ # Ensure required dirs exist
132
+ group_dir = groups_dir / folder
133
+ group_dir.mkdir(parents=True, exist_ok=True)
134
+ (sessions_dir / ".claude").mkdir(parents=True, exist_ok=True)
135
+ for sub in ("messages", "tasks", "input"):
136
+ (ipc_dir / sub).mkdir(parents=True, exist_ok=True)
137
+
138
+ agent_runner_src = sessions_dir / "agent-runner-src"
139
+ project_agent_runner = NANOCLAW_DIR / "container" / "agent-runner" / "src"
140
+ if not agent_runner_src.exists() and project_agent_runner.exists():
141
+ import shutil
142
+ shutil.copytree(project_agent_runner, agent_runner_src)
143
+
144
+ mounts: list[tuple[str, str, bool]] = []
145
+ if is_main:
146
+ mounts.append((str(NANOCLAW_DIR), "/workspace/project", True))
147
+ mounts.append((str(group_dir), "/workspace/group", False))
148
+ mounts.append((str(sessions_dir / ".claude"), "/home/node/.claude", False))
149
+ mounts.append((str(ipc_dir), "/workspace/ipc", False))
150
+ if agent_runner_src.exists():
151
+ mounts.append((str(agent_runner_src), "/app/src", False))
152
+ return mounts
153
+
154
+
155
+ def run_container(runtime: str, image: str, payload: dict,
156
+ folder: str | None = None, is_main: bool = False,
157
+ timeout: int = 300) -> None:
158
+ cmd = [runtime, "run", "-i", "--rm"]
159
+ if folder:
160
+ for host, container, readonly in build_mounts(folder, is_main):
161
+ if readonly:
162
+ cmd += ["--mount", f"type=bind,source={host},target={container},readonly"]
163
+ else:
164
+ cmd += ["-v", f"{host}:{container}"]
165
+ cmd.append(image)
166
+ dbg(f"cmd: {' '.join(cmd)}")
167
+
168
+ # Show payload sans secrets
169
+ if VERBOSE:
170
+ safe = {k: v for k, v in payload.items() if k != "secrets"}
171
+ safe["secrets"] = {k: "***" for k in payload.get("secrets", {})}
172
+ dbg(f"payload: {json.dumps(safe, indent=2)}")
173
+
174
+ proc = subprocess.Popen(
175
+ cmd,
176
+ stdin=subprocess.PIPE,
177
+ stdout=subprocess.PIPE,
178
+ stderr=subprocess.PIPE,
179
+ )
180
+ dbg(f"container pid: {proc.pid}")
181
+
182
+ # Write JSON payload and close stdin
183
+ proc.stdin.write(json.dumps(payload).encode())
184
+ proc.stdin.close()
185
+ dbg("stdin closed, waiting for response...")
186
+
187
+ stdout_lines: list[str] = []
188
+ stderr_lines: list[str] = []
189
+ done = threading.Event()
190
+
191
+ def stream_stderr():
192
+ for raw in proc.stderr:
193
+ line = raw.decode(errors="replace").rstrip()
194
+ if line.startswith("npm notice"):
195
+ continue
196
+ stderr_lines.append(line)
197
+ print(line, file=sys.stderr)
198
+
199
+ def stream_stdout():
200
+ for raw in proc.stdout:
201
+ line = raw.decode(errors="replace").rstrip()
202
+ stdout_lines.append(line)
203
+ dbg(f"stdout: {line}")
204
+ # Kill the container as soon as we see the closing sentinel —
205
+ # the Node.js event loop often keeps the process alive indefinitely.
206
+ if line.strip() == "---NANOCLAW_OUTPUT_END---":
207
+ dbg("output sentinel found, terminating container")
208
+ done.set()
209
+ try:
210
+ proc.terminate()
211
+ try:
212
+ proc.wait(timeout=5)
213
+ except subprocess.TimeoutExpired:
214
+ dbg("graceful stop timed out, force killing container")
215
+ proc.kill()
216
+ except ProcessLookupError:
217
+ pass
218
+ return
219
+
220
+ t_err = threading.Thread(target=stream_stderr, daemon=True)
221
+ t_out = threading.Thread(target=stream_stdout, daemon=True)
222
+ t_err.start()
223
+ t_out.start()
224
+
225
+ # Wait for sentinel or timeout
226
+ if not done.wait(timeout=timeout):
227
+ # Also check if process exited naturally
228
+ t_out.join(timeout=2)
229
+ if not done.is_set():
230
+ proc.kill()
231
+ sys.exit(f"error: container timed out after {timeout}s (no output sentinel received)")
232
+
233
+ t_err.join(timeout=5)
234
+ t_out.join(timeout=5)
235
+ proc.wait()
236
+ dbg(f"container done (rc={proc.returncode}), {len(stdout_lines)} stdout lines")
237
+ stdout = "\n".join(stdout_lines)
238
+
239
+ # Parse output block
240
+ match = re.search(
241
+ r"---NANOCLAW_OUTPUT_START---\n(.*?)\n---NANOCLAW_OUTPUT_END---",
242
+ stdout,
243
+ re.DOTALL,
244
+ )
245
+ success = False
246
+
247
+ if match:
248
+ try:
249
+ data = json.loads(match.group(1))
250
+ status = data.get("status", "unknown")
251
+ if status == "success":
252
+ print(data.get("result", ""))
253
+ session_id = data.get("newSessionId") or data.get("sessionId")
254
+ if session_id:
255
+ print(f"\n[session: {session_id}]", file=sys.stderr)
256
+ success = True
257
+ else:
258
+ print(f"[{status}] {data.get('result', '')}", file=sys.stderr)
259
+ sys.exit(1)
260
+ except json.JSONDecodeError:
261
+ print(match.group(1))
262
+ else:
263
+ # No structured output — print raw stdout
264
+ print(stdout)
265
+
266
+ if success:
267
+ return
268
+
269
+ if proc.returncode not in (0, None):
270
+ sys.exit(proc.returncode)
271
+
272
+
273
+ # ── Main ─────────────────────────────────────────────────────────────────────
274
+
275
+ def main():
276
+ parser = argparse.ArgumentParser(
277
+ prog="claw",
278
+ description="Run a NanoClaw agent from the command line.",
279
+ )
280
+ parser.add_argument("prompt", nargs="?", help="Prompt to send")
281
+ parser.add_argument("-g", "--group", help="Group name or folder (fuzzy match)")
282
+ parser.add_argument("-j", "--jid", help="Chat JID (exact)")
283
+ parser.add_argument("-s", "--session", help="Session ID to resume")
284
+ parser.add_argument("-p", "--pipe", action="store_true",
285
+ help="Read prompt from stdin (can be combined with a prompt arg as prefix)")
286
+ parser.add_argument("--runtime", choices=["docker", "container"],
287
+ help="Container runtime (default: auto-detect)")
288
+ parser.add_argument("--image", default=IMAGE, help=f"Container image (default: {IMAGE})")
289
+ parser.add_argument("--list-groups", action="store_true", help="List registered groups and exit")
290
+ parser.add_argument("--raw", action="store_true", help="Print raw JSON output")
291
+ parser.add_argument("--timeout", type=int, default=300, metavar="SECS",
292
+ help="Max seconds to wait for a response (default: 300)")
293
+ parser.add_argument("-v", "--verbose", action="store_true",
294
+ help="Show debug info: cmd, payload (secrets redacted), stdout lines, exit code")
295
+ args = parser.parse_args()
296
+
297
+ global VERBOSE
298
+ VERBOSE = args.verbose
299
+
300
+ groups = get_groups(DB_PATH) if DB_PATH.exists() else []
301
+
302
+ if args.list_groups:
303
+ print(f"{'NAME':<35} {'FOLDER':<30} {'JID'}")
304
+ print("-" * 100)
305
+ for g in groups:
306
+ main_tag = " [main]" if g["is_main"] else ""
307
+ print(f"{g['name']:<35} {g['folder']:<30} {g['jid']}{main_tag}")
308
+ return
309
+
310
+ # Resolve prompt: --pipe reads stdin, optionally prepended with positional arg
311
+ if args.pipe or (not sys.stdin.isatty() and not args.prompt):
312
+ stdin_text = sys.stdin.read().strip()
313
+ if args.prompt:
314
+ prompt = f"{args.prompt}\n\n{stdin_text}"
315
+ else:
316
+ prompt = stdin_text
317
+ else:
318
+ prompt = args.prompt
319
+
320
+ if not prompt:
321
+ parser.print_help()
322
+ sys.exit(1)
323
+
324
+ # Resolve group → jid
325
+ jid = args.jid
326
+ group_name = None
327
+ group_folder = None
328
+ is_main = False
329
+
330
+ if args.group:
331
+ g = find_group(groups, args.group)
332
+ if g is None:
333
+ sys.exit(f"error: group '{args.group}' not found. Run --list-groups to see options.")
334
+ jid = g["jid"]
335
+ group_name = g["name"]
336
+ group_folder = g["folder"]
337
+ is_main = g["is_main"]
338
+ elif not jid:
339
+ # Default: main group
340
+ mains = [g for g in groups if g["is_main"]]
341
+ if mains:
342
+ jid = mains[0]["jid"]
343
+ group_name = mains[0]["name"]
344
+ group_folder = mains[0]["folder"]
345
+ is_main = True
346
+ else:
347
+ sys.exit("error: no group specified and no main group found. Use -g or -j.")
348
+
349
+ runtime = detect_runtime(args.runtime)
350
+ secrets = read_secrets(ENV_FILE)
351
+
352
+ if not secrets:
353
+ print("warning: no secrets found in .env — agent may not be authenticated", file=sys.stderr)
354
+
355
+ payload: dict = {
356
+ "prompt": prompt,
357
+ "chatJid": jid,
358
+ "isMain": is_main,
359
+ "secrets": secrets,
360
+ }
361
+ if group_name:
362
+ payload["groupFolder"] = group_name
363
+ if args.session:
364
+ payload["sessionId"] = args.session
365
+ payload["resumeAt"] = "latest"
366
+
367
+ print(f"[{group_name or jid}] running via {runtime}...", file=sys.stderr)
368
+ run_container(runtime, args.image, payload,
369
+ folder=group_folder, is_main=is_main,
370
+ timeout=args.timeout)
371
+
372
+
373
+ if __name__ == "__main__":
374
+ main()
@@ -0,0 +1,212 @@
1
+ ---
2
+ name: convert-to-apple-container
3
+ description: Switch from Docker to Apple Container for macOS-native container isolation. Use when the user wants Apple Container instead of Docker, or is setting up on macOS and prefers the native runtime. Triggers on "apple container", "convert to apple container", "switch to apple container", or "use apple container".
4
+ ---
5
+
6
+ # Convert to Apple Container
7
+
8
+ This skill switches NanoClaw's container runtime from Docker to Apple Container (macOS-only). It uses the skills engine for deterministic code changes, then walks through verification.
9
+
10
+ **What this changes:**
11
+ - Container runtime binary: `docker` → `container`
12
+ - Mount syntax: `-v path:path:ro` → `--mount type=bind,source=...,target=...,readonly`
13
+ - Startup check: `docker info` → `container system status` (with auto-start)
14
+ - Orphan detection: `docker ps --filter` → `container ls --format json`
15
+ - Build script default: `docker` → `container`
16
+ - Dockerfile entrypoint: `.env` shadowing via `mount --bind` inside the container (Apple Container only supports directory mounts, not file mounts like Docker's `/dev/null` overlay)
17
+ - Container runner: main-group containers start as root for `mount --bind`, then drop privileges via `setpriv`
18
+
19
+ **What stays the same:**
20
+ - Mount security/allowlist validation
21
+ - All exported interfaces and IPC protocol
22
+ - Non-main container behavior (still uses `--user` flag)
23
+ - All other functionality
24
+
25
+ ## Prerequisites
26
+
27
+ Verify Apple Container is installed:
28
+
29
+ ```bash
30
+ container --version && echo "Apple Container ready" || echo "Install Apple Container first"
31
+ ```
32
+
33
+ If not installed:
34
+ - Download from https://github.com/apple/container/releases
35
+ - Install the `.pkg` file
36
+ - Verify: `container --version`
37
+
38
+ Apple Container requires macOS. It does not work on Linux.
39
+
40
+ ## Phase 1: Pre-flight
41
+
42
+ ### Check if already applied
43
+
44
+ ```bash
45
+ grep "CONTAINER_RUNTIME_BIN" src/container-runtime.ts
46
+ ```
47
+
48
+ If it already shows `'container'`, the runtime is already Apple Container. Skip to Phase 4.
49
+
50
+ ## Phase 2: Apply Code Changes
51
+
52
+ ### Ensure upstream remote
53
+
54
+ ```bash
55
+ git remote -v
56
+ ```
57
+
58
+ If `upstream` is missing, add it:
59
+
60
+ ```bash
61
+ git remote add upstream https://github.com/qwibitai/nanoclaw.git
62
+ ```
63
+
64
+ ### Merge the skill branch
65
+
66
+ ```bash
67
+ git fetch upstream skill/apple-container
68
+ git merge upstream/skill/apple-container
69
+ ```
70
+
71
+ This merges in:
72
+ - `src/container-runtime.ts` — Apple Container implementation (replaces Docker)
73
+ - `src/container-runtime.test.ts` — Apple Container-specific tests
74
+ - `src/container-runner.ts` — .env shadow mount fix and privilege dropping
75
+ - `container/Dockerfile` — entrypoint that shadows .env via `mount --bind`
76
+ - `container/build.sh` — default runtime set to `container`
77
+
78
+ If the merge reports conflicts, resolve them by reading the conflicted files and understanding the intent of both sides.
79
+
80
+ ### Validate code changes
81
+
82
+ ```bash
83
+ pnpm test
84
+ pnpm run build
85
+ ```
86
+
87
+ All tests must pass and build must be clean before proceeding.
88
+
89
+ ## Phase 3: Credential proxy network binding
90
+
91
+ Apple Container uses a bridge network (bridge100) that only exists while containers are running. The credential proxy must start before any container, so it cannot bind to the bridge IP. It must bind to `0.0.0.0`, which exposes port 3001 on all network interfaces — anyone on your local network could route API requests through the proxy using your credentials.
92
+
93
+ Use AskUserQuestion to ask the user:
94
+
95
+ **"The credential proxy needs to bind to all interfaces (0.0.0.0). Is this Mac on a trusted private network?"**
96
+
97
+ Options:
98
+ 1. **Yes, private/home network** — description: "No firewall rule needed."
99
+ 2. **No, shared/public network** — description: "Add a macOS firewall rule to block external access to port 3001."
100
+
101
+ For both options, add `CREDENTIAL_PROXY_HOST=0.0.0.0` to `.env`:
102
+
103
+ ```bash
104
+ grep -q 'CREDENTIAL_PROXY_HOST' .env 2>/dev/null || echo 'CREDENTIAL_PROXY_HOST=0.0.0.0' >> .env
105
+ ```
106
+
107
+ If they chose the public network option, set up and persist the firewall rule:
108
+
109
+ ```bash
110
+ echo "block in on en0 proto tcp to any port 3001" | sudo pfctl -ef -
111
+ ```
112
+
113
+ ```bash
114
+ grep -q 'nanoclaw proxy' /etc/pf.conf 2>/dev/null || echo '# nanoclaw proxy — block LAN access to credential proxy
115
+ block in on en0 proto tcp to any port 3001' | sudo tee -a /etc/pf.conf > /dev/null
116
+ ```
117
+
118
+ Verify the rule is working:
119
+
120
+ ```bash
121
+ curl -sf http://$(ipconfig getifaddr en0):3001 && echo "EXPOSED — rule not working" || echo "BLOCKED — rule active"
122
+ ```
123
+
124
+ If the verification shows "EXPOSED", warn the user and retry. If "BLOCKED", confirm success and continue.
125
+
126
+ ## Phase 4: Verify
127
+
128
+ ### Ensure Apple Container runtime is running
129
+
130
+ ```bash
131
+ container system status || container system start
132
+ ```
133
+
134
+ ### Build the container image
135
+
136
+ ```bash
137
+ ./container/build.sh
138
+ ```
139
+
140
+ ### Test basic execution
141
+
142
+ ```bash
143
+ echo '{}' | container run -i --entrypoint /bin/echo nanoclaw-agent:latest "Container OK"
144
+ ```
145
+
146
+ ### Test readonly mounts
147
+
148
+ ```bash
149
+ mkdir -p /tmp/test-ro && echo "test" > /tmp/test-ro/file.txt
150
+ container run --rm --entrypoint /bin/bash \
151
+ --mount type=bind,source=/tmp/test-ro,target=/test,readonly \
152
+ nanoclaw-agent:latest \
153
+ -c "cat /test/file.txt && touch /test/new.txt 2>&1 || echo 'Write blocked (expected)'"
154
+ rm -rf /tmp/test-ro
155
+ ```
156
+
157
+ Expected: Read succeeds, write fails with "Read-only file system".
158
+
159
+ ### Test read-write mounts
160
+
161
+ ```bash
162
+ mkdir -p /tmp/test-rw
163
+ container run --rm --entrypoint /bin/bash \
164
+ -v /tmp/test-rw:/test \
165
+ nanoclaw-agent:latest \
166
+ -c "echo 'test write' > /test/new.txt && cat /test/new.txt"
167
+ cat /tmp/test-rw/new.txt && rm -rf /tmp/test-rw
168
+ ```
169
+
170
+ Expected: Both operations succeed.
171
+
172
+ ### Full integration test
173
+
174
+ ```bash
175
+ pnpm run build
176
+ launchctl kickstart -k gui/$(id -u)/com.nanoclaw
177
+ ```
178
+
179
+ Send a message via WhatsApp and verify the agent responds.
180
+
181
+ ## Troubleshooting
182
+
183
+ **Apple Container not found:**
184
+ - Download from https://github.com/apple/container/releases
185
+ - Install the `.pkg` file
186
+ - Verify: `container --version`
187
+
188
+ **Runtime won't start:**
189
+ ```bash
190
+ container system start
191
+ container system status
192
+ ```
193
+
194
+ **Image build fails:**
195
+ ```bash
196
+ # Clean rebuild — Apple Container caches aggressively
197
+ container builder stop && container builder rm && container builder start
198
+ ./container/build.sh
199
+ ```
200
+
201
+ **Container can't write to mounted directories:**
202
+ Check directory permissions on the host. The container runs as uid 1000.
203
+
204
+ ## Summary of Changed Files
205
+
206
+ | File | Type of Change |
207
+ |------|----------------|
208
+ | `src/container-runtime.ts` | Full replacement — Docker → Apple Container API |
209
+ | `src/container-runtime.test.ts` | Full replacement — tests for Apple Container behavior |
210
+ | `src/container-runner.ts` | .env shadow mount removed, main containers start as root with privilege drop |
211
+ | `container/Dockerfile` | Entrypoint: `mount --bind` for .env shadowing, `setpriv` privilege drop |
212
+ | `container/build.sh` | Default runtime: `docker` → `container` |
@@ -0,0 +1,110 @@
1
+ ---
2
+ name: customize
3
+ description: Add new capabilities or modify NanoClaw behavior. Use when user wants to add channels (Telegram, Slack, email input), change triggers, add integrations, modify the router, or make any other customizations. This is an interactive skill that asks questions to understand what the user wants.
4
+ ---
5
+
6
+ # NanoClaw Customization
7
+
8
+ This skill helps users add capabilities or modify behavior. Use AskUserQuestion to understand what they want before making changes.
9
+
10
+ ## Workflow
11
+
12
+ 1. **Understand the request** - Ask clarifying questions
13
+ 3. **Plan the changes** - Identify files to modify. If a skill exists for the request (e.g., `/add-telegram` for adding Telegram), invoke it instead of implementing manually.
14
+ 4. **Implement** - Make changes directly to the code
15
+ 5. **Test guidance** - Tell user how to verify
16
+
17
+ ## Key Files
18
+
19
+ | File | Purpose |
20
+ |------|---------|
21
+ | `src/index.ts` | Orchestrator: state, message loop, agent invocation |
22
+ | `src/channels/whatsapp.ts` | WhatsApp connection, auth, send/receive |
23
+ | `src/ipc.ts` | IPC watcher and task processing |
24
+ | `src/router.ts` | Message formatting and outbound routing |
25
+ | `src/types.ts` | TypeScript interfaces (includes Channel) |
26
+ | `src/config.ts` | Assistant name, trigger pattern, directories |
27
+ | `src/db.ts` | Database initialization and queries |
28
+ | `src/whatsapp-auth.ts` | Standalone WhatsApp authentication script |
29
+ | `groups/CLAUDE.md` | Global memory/persona |
30
+
31
+ ## Common Customization Patterns
32
+
33
+ ### Adding a New Input Channel (e.g., Telegram, Slack, Email)
34
+
35
+ Questions to ask:
36
+ - Which channel? (Telegram, Slack, Discord, email, SMS, etc.)
37
+ - Same trigger word or different?
38
+ - Same memory hierarchy or separate?
39
+ - Should messages from this channel go to existing groups or new ones?
40
+
41
+ Implementation pattern:
42
+ 1. Create `src/channels/{name}.ts` implementing the `Channel` interface from `src/types.ts` (see `src/channels/whatsapp.ts` for reference)
43
+ 2. Add the channel instance to `main()` in `src/index.ts` and wire callbacks (`onMessage`, `onChatMetadata`)
44
+ 3. Messages are stored via the `onMessage` callback; routing is automatic via `ownsJid()`
45
+
46
+ ### Adding a New MCP Integration
47
+
48
+ Questions to ask:
49
+ - What service? (Calendar, Notion, database, etc.)
50
+ - What operations needed? (read, write, both)
51
+ - Which groups should have access?
52
+
53
+ Implementation:
54
+ 1. Add MCP server config to the container settings (see `src/container-runner.ts` for how MCP servers are mounted)
55
+ 2. Document available tools in `groups/CLAUDE.md`
56
+
57
+ ### Changing Assistant Behavior
58
+
59
+ Questions to ask:
60
+ - What aspect? (name, trigger, persona, response style)
61
+ - Apply to all groups or specific ones?
62
+
63
+ Simple changes → edit `src/config.ts`
64
+ Persona changes → edit `groups/CLAUDE.md`
65
+ Per-group behavior → edit specific group's `CLAUDE.md`
66
+
67
+ ### Adding New Commands
68
+
69
+ Questions to ask:
70
+ - What should the command do?
71
+ - Available in all groups or main only?
72
+ - Does it need new MCP tools?
73
+
74
+ Implementation:
75
+ 1. Commands are handled by the agent naturally — add instructions to `groups/CLAUDE.md` or the group's `CLAUDE.md`
76
+ 2. For trigger-level routing changes, modify `processGroupMessages()` in `src/index.ts`
77
+
78
+ ### Changing Deployment
79
+
80
+ Questions to ask:
81
+ - Target platform? (Linux server, Docker, different Mac)
82
+ - Service manager? (systemd, Docker, supervisord)
83
+
84
+ Implementation:
85
+ 1. Create appropriate service files
86
+ 2. Update paths in config
87
+ 3. Provide setup instructions
88
+
89
+ ## After Changes
90
+
91
+ Always tell the user:
92
+ ```bash
93
+ # Rebuild and restart
94
+ pnpm run build
95
+ # macOS:
96
+ launchctl unload ~/Library/LaunchAgents/com.nanoclaw.plist
97
+ launchctl load ~/Library/LaunchAgents/com.nanoclaw.plist
98
+ # Linux:
99
+ # systemctl --user restart nanoclaw
100
+ ```
101
+
102
+ ## Example Interaction
103
+
104
+ User: "Add Telegram as an input channel"
105
+
106
+ 1. Ask: "Should Telegram use the same @Andy trigger, or a different one?"
107
+ 2. Ask: "Should Telegram messages create separate conversation contexts, or share with WhatsApp groups?"
108
+ 3. Create `src/channels/telegram.ts` implementing the `Channel` interface (see `src/channels/whatsapp.ts`)
109
+ 4. Add the channel to `main()` in `src/index.ts`
110
+ 5. Tell user how to authenticate and test