clawmini 0.0.8 → 0.0.9

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 (367) hide show
  1. package/.changeset/README.md +8 -0
  2. package/.changeset/config.json +14 -0
  3. package/.github/workflows/release.yml +49 -0
  4. package/CHANGELOG.md +36 -0
  5. package/README.md +5 -4
  6. package/dist/adapter-discord/index.d.mts.map +1 -1
  7. package/dist/adapter-discord/index.mjs +465 -282
  8. package/dist/adapter-discord/index.mjs.map +1 -1
  9. package/dist/adapter-google-chat/index.mjs +367 -243
  10. package/dist/adapter-google-chat/index.mjs.map +1 -1
  11. package/dist/cli/index.mjs +684 -24
  12. package/dist/cli/index.mjs.map +1 -1
  13. package/dist/cli/lite.mjs +43 -13
  14. package/dist/cli/lite.mjs.map +1 -1
  15. package/dist/cli/{propose-policy.mjs → manage-policies.mjs} +270 -47
  16. package/dist/cli/manage-policies.mjs.map +1 -0
  17. package/dist/cli/run-host.d.mts +1 -0
  18. package/dist/cli/run-host.mjs +3090 -0
  19. package/dist/cli/run-host.mjs.map +1 -0
  20. package/dist/config-CPFQIGdG.mjs +57 -0
  21. package/dist/config-CPFQIGdG.mjs.map +1 -0
  22. package/dist/config-Dvl-Pov4.mjs +76 -0
  23. package/dist/config-Dvl-Pov4.mjs.map +1 -0
  24. package/dist/daemon/index.d.mts.map +1 -1
  25. package/dist/daemon/index.mjs +970 -332
  26. package/dist/daemon/index.mjs.map +1 -1
  27. package/dist/supervisor-actions-CiW56eLi.mjs +843 -0
  28. package/dist/supervisor-actions-CiW56eLi.mjs.map +1 -0
  29. package/dist/turn-log-buffer-DRgW53gl.mjs +767 -0
  30. package/dist/turn-log-buffer-DRgW53gl.mjs.map +1 -0
  31. package/dist/web/_app/immutable/chunks/{Drm9vgeP.js → 3AZlWB6U.js} +1 -1
  32. package/dist/web/_app/immutable/chunks/BhRSsUCh.js +2 -0
  33. package/dist/web/_app/immutable/chunks/BiLeM2i1.js +1 -0
  34. package/{web/.svelte-kit/output/client/_app/immutable/chunks/CME08kGM.js → dist/web/_app/immutable/chunks/BmBj85Ll.js} +1 -1
  35. package/dist/web/_app/immutable/chunks/BrERcKAH.js +1 -0
  36. package/dist/web/_app/immutable/chunks/Bv9252RM.js +1 -0
  37. package/dist/web/_app/immutable/chunks/CIXNBPKi.js +1 -0
  38. package/dist/web/_app/immutable/chunks/DISKL3GN.js +2 -0
  39. package/dist/web/_app/immutable/chunks/{Zeh-C-mx.js → DcpaLzmX.js} +1 -1
  40. package/dist/web/_app/immutable/chunks/DnQ3vS13.js +1 -0
  41. package/dist/web/_app/immutable/chunks/KsloHTKS.js +1 -0
  42. package/{web/.svelte-kit/output/client/_app/immutable/chunks/Ck-be5J2.js → dist/web/_app/immutable/chunks/RsHsUj-8.js} +2 -2
  43. package/dist/web/_app/immutable/chunks/{vDehDcuJ.js → wpfV79dV.js} +1 -1
  44. package/dist/web/_app/immutable/entry/app.CIw1Qj0n.js +2 -0
  45. package/dist/web/_app/immutable/entry/start.Di0-Jhte.js +1 -0
  46. package/dist/web/_app/immutable/nodes/{0.CUGC2p-K.js → 0.DYyUA1au.js} +1 -1
  47. package/dist/web/_app/immutable/nodes/1.D-3QEMMZ.js +1 -0
  48. package/dist/web/_app/immutable/nodes/{2.BnwnD1Ki.js → 2.4olHnH7U.js} +1 -1
  49. package/{web/.svelte-kit/output/client/_app/immutable/nodes/3.0arZe_Uf.js → dist/web/_app/immutable/nodes/3.4w0bE-m2.js} +3 -3
  50. package/dist/web/_app/immutable/nodes/4.CZvjhVHt.js +60 -0
  51. package/dist/web/_app/immutable/nodes/{5.Bq2JzCEj.js → 5.DLbPVJY2.js} +1 -1
  52. package/dist/web/_app/version.json +1 -1
  53. package/dist/web/index.html +12 -12
  54. package/dist/workspace-oWmVh5mi.mjs +1001 -0
  55. package/dist/workspace-oWmVh5mi.mjs.map +1 -0
  56. package/docs/23_adapter_slash_autocomplete/development_log.md +19 -0
  57. package/docs/23_adapter_slash_autocomplete/notes.md +18 -0
  58. package/docs/23_adapter_slash_autocomplete/prd.md +46 -0
  59. package/docs/23_adapter_slash_autocomplete/questions.md +6 -0
  60. package/docs/23_adapter_slash_autocomplete/tickets.md +21 -0
  61. package/docs/24_subagent_job_policy_fixes/development_log.md +22 -0
  62. package/docs/24_subagent_job_policy_fixes/notes.md +28 -0
  63. package/docs/24_subagent_job_policy_fixes/prd.md +59 -0
  64. package/docs/24_subagent_job_policy_fixes/questions.md +3 -0
  65. package/docs/24_subagent_job_policy_fixes/tickets.md +49 -0
  66. package/docs/25_e2e_test_improvements/development_log.md +30 -0
  67. package/docs/25_e2e_test_improvements/notes.md +29 -0
  68. package/docs/25_e2e_test_improvements/prd.md +43 -0
  69. package/docs/25_e2e_test_improvements/questions.md +12 -0
  70. package/docs/25_e2e_test_improvements/tickets-2.md +22 -0
  71. package/docs/25_e2e_test_improvements/tickets.md +22 -0
  72. package/docs/25_policy_cwd/development_log.md +30 -0
  73. package/docs/25_policy_cwd/notes.md +28 -0
  74. package/docs/25_policy_cwd/prd.md +77 -0
  75. package/docs/25_policy_cwd/questions.md +6 -0
  76. package/docs/25_policy_cwd/tickets.md +77 -0
  77. package/docs/CLI_REFERENCE.md +3 -1
  78. package/docs/PHILOSOPHY.md +35 -0
  79. package/docs/adapter-visibility/SPEC.md +461 -0
  80. package/docs/adapter-visibility/SPEC_v2.md +202 -0
  81. package/docs/auto-update/SPEC.md +344 -0
  82. package/docs/backups/SPEC.md +296 -0
  83. package/docs/backups/clawmini.gitignore +69 -0
  84. package/docs/guides/assets/clawmini-avatar.png +0 -0
  85. package/docs/guides/backups.md +332 -0
  86. package/docs/guides/discord_adapter_setup.md +1 -1
  87. package/docs/guides/google_chat_adapter_setup.md +81 -0
  88. package/docs/unified-startup/SPEC.md +203 -0
  89. package/e2e/_helpers/test-environment.test.ts +49 -0
  90. package/e2e/_helpers/test-environment.ts +548 -0
  91. package/e2e/adapters/_google-chat-fixtures.ts +340 -0
  92. package/{src/cli/e2e → e2e/adapters}/adapter-discord.test.ts +22 -23
  93. package/e2e/adapters/adapter-google-chat-downtime.test.ts +157 -0
  94. package/e2e/adapters/adapter-google-chat-inbound.test.ts +697 -0
  95. package/e2e/adapters/adapter-google-chat-outbound.test.ts +297 -0
  96. package/e2e/adapters/adapter-google-chat-roundtrip.test.ts +56 -0
  97. package/e2e/adapters/adapter-google-chat-threads.test.ts +1078 -0
  98. package/e2e/agents/custom-api-env.test.ts +80 -0
  99. package/e2e/agents/export-lite-func.test.ts +104 -0
  100. package/e2e/agents/fallbacks.test.ts +124 -0
  101. package/e2e/agents/interrupt.test.ts +50 -0
  102. package/e2e/agents/no-reply-necessary.test.ts +57 -0
  103. package/e2e/agents/session-timeout-subagents.test.ts +76 -0
  104. package/e2e/agents/subagent-authorization.test.ts +246 -0
  105. package/e2e/agents/subagent-env.test.ts +49 -0
  106. package/e2e/agents/subagent-lifecycle.test.ts +782 -0
  107. package/e2e/agents/subagents-depth.test.ts +47 -0
  108. package/e2e/cli/agents.test.ts +176 -0
  109. package/e2e/cli/auto-update.test.ts +741 -0
  110. package/e2e/cli/basic.test.ts +44 -0
  111. package/{src/cli/e2e → e2e/cli}/export-lite.test.ts +16 -12
  112. package/e2e/cli/init-gitignore.test.ts +86 -0
  113. package/e2e/cli/init.test.ts +76 -0
  114. package/e2e/cli/messages.test.ts +363 -0
  115. package/e2e/cli/serve.test.ts +76 -0
  116. package/{src/cli/e2e → e2e/cli}/skills.test.ts +11 -10
  117. package/{src/cli/e2e → e2e/daemon}/daemon.test.ts +57 -195
  118. package/e2e/jobs/agent-jobs.test.ts +216 -0
  119. package/e2e/jobs/cron.test.ts +64 -0
  120. package/e2e/jobs/restart.test.ts +108 -0
  121. package/e2e/policies/approval-session.test.ts +69 -0
  122. package/e2e/policies/auto-create-policies-file.test.ts +35 -0
  123. package/e2e/policies/builtin-manage-policies.test.ts +184 -0
  124. package/e2e/policies/builtin-run-host.test.ts +180 -0
  125. package/e2e/policies/environment-policies.test.ts +177 -0
  126. package/e2e/policies/manage-policies.test.ts +566 -0
  127. package/e2e/policies/output-size.test.ts +98 -0
  128. package/e2e/policies/policies-context-cwd.test.ts +160 -0
  129. package/e2e/policies/relative-script-path.test.ts +60 -0
  130. package/e2e/policies/requests-show.test.ts +135 -0
  131. package/e2e/policies/requests.test.ts +208 -0
  132. package/e2e/policies/slash-policies.test.ts +308 -0
  133. package/e2e/policies/startup-cleanup.test.ts +48 -0
  134. package/e2e/routers/session-timeout.test.ts +106 -0
  135. package/e2e/routers/slash-model.test.ts +152 -0
  136. package/e2e/routers/slash-new.test.ts +50 -0
  137. package/e2e/routers/slash-restart-adapter.test.ts +96 -0
  138. package/e2e/routers/slash-restart.test.ts +114 -0
  139. package/e2e/routers/slash-shutdown.test.ts +55 -0
  140. package/e2e/routers/slash-stop.test.ts +232 -0
  141. package/e2e/routers/slash-upgrade.test.ts +88 -0
  142. package/{src/cli/e2e → e2e/sandbox}/environments.test.ts +14 -13
  143. package/eslint.config.js +6 -0
  144. package/napkin.md +1 -1
  145. package/package.json +8 -3
  146. package/src/adapter-discord/commands.test.ts +42 -0
  147. package/src/adapter-discord/commands.ts +33 -0
  148. package/src/adapter-discord/config.ts +12 -0
  149. package/src/adapter-discord/forwarder.test.ts +499 -21
  150. package/src/adapter-discord/forwarder.ts +343 -124
  151. package/src/adapter-discord/inbound-cache.test.ts +47 -0
  152. package/src/adapter-discord/inbound-cache.ts +37 -0
  153. package/src/adapter-discord/index.test.ts +67 -2
  154. package/src/adapter-discord/index.ts +84 -216
  155. package/src/adapter-discord/interactions.test.ts +54 -3
  156. package/src/adapter-discord/interactions.ts +97 -53
  157. package/src/adapter-discord/processMessage.ts +239 -0
  158. package/src/adapter-discord/state.ts +1 -0
  159. package/src/adapter-google-chat/auth.test.ts +9 -5
  160. package/src/adapter-google-chat/auth.ts +29 -23
  161. package/src/adapter-google-chat/cards.ts +7 -2
  162. package/src/adapter-google-chat/client.test.ts +37 -2
  163. package/src/adapter-google-chat/client.ts +138 -38
  164. package/src/adapter-google-chat/config.ts +19 -0
  165. package/src/adapter-google-chat/forwarder.test.ts +81 -56
  166. package/src/adapter-google-chat/forwarder.ts +394 -185
  167. package/src/adapter-google-chat/inbound-cache.test.ts +61 -0
  168. package/src/adapter-google-chat/inbound-cache.ts +36 -0
  169. package/src/adapter-google-chat/state.test.ts +1 -0
  170. package/src/adapter-google-chat/state.ts +9 -1
  171. package/src/adapter-google-chat/subscriptions.ts +8 -6
  172. package/src/cli/builtin-policies.ts +44 -0
  173. package/src/cli/commands/agents.ts +59 -5
  174. package/src/cli/commands/down.ts +54 -2
  175. package/src/cli/commands/environments.ts +8 -2
  176. package/src/cli/commands/init.ts +31 -0
  177. package/src/cli/commands/logs.ts +116 -0
  178. package/src/cli/commands/policies.ts +6 -4
  179. package/src/cli/commands/serve.test.ts +67 -0
  180. package/src/cli/commands/serve.ts +284 -0
  181. package/src/cli/commands/up.ts +122 -2
  182. package/src/cli/commands/web-api/agents.ts +3 -2
  183. package/src/cli/index.ts +4 -0
  184. package/src/cli/install-detection.test.ts +72 -0
  185. package/src/cli/install-detection.ts +48 -0
  186. package/src/cli/lite.ts +54 -22
  187. package/src/cli/manage-policies-utils.ts +104 -0
  188. package/src/cli/manage-policies.ts +291 -0
  189. package/src/cli/run-host.ts +45 -0
  190. package/src/cli/supervisor-actions.ts +267 -0
  191. package/src/cli/supervisor-control.test.ts +129 -0
  192. package/src/cli/supervisor-control.ts +155 -0
  193. package/src/cli/supervisor-pid.ts +68 -0
  194. package/src/cli/supervisor.ts +277 -0
  195. package/src/daemon/agent/agent-context.ts +11 -11
  196. package/src/daemon/agent/agent-session.ts +8 -1
  197. package/src/daemon/agent/chat-logger.test.ts +78 -9
  198. package/src/daemon/agent/chat-logger.ts +25 -5
  199. package/src/daemon/agent/turn-registry.test.ts +89 -0
  200. package/src/daemon/agent/turn-registry.ts +94 -0
  201. package/src/daemon/agent/types.ts +2 -0
  202. package/src/daemon/api/agent-policy-endpoints.ts +263 -0
  203. package/src/daemon/api/agent-router.ts +47 -126
  204. package/src/daemon/api/index.test.ts +1 -0
  205. package/src/daemon/api/policy-request.test.ts +7 -5
  206. package/src/daemon/api/router-utils.ts +6 -5
  207. package/src/daemon/api/subagent-router.ts +110 -74
  208. package/src/daemon/api/subagent-utils.test.ts +60 -0
  209. package/src/daemon/api/subagent-utils.ts +113 -87
  210. package/src/daemon/api/user-router.ts +34 -8
  211. package/src/daemon/auth.ts +1 -0
  212. package/src/daemon/cron.test.ts +62 -4
  213. package/src/daemon/cron.ts +42 -16
  214. package/src/daemon/events.ts +65 -0
  215. package/src/daemon/index.ts +24 -1
  216. package/src/daemon/message-interruption.test.ts +1 -0
  217. package/src/daemon/message-jobs.test.ts +1 -0
  218. package/src/daemon/message.ts +78 -14
  219. package/src/daemon/observation.test.ts +26 -18
  220. package/src/daemon/pending-replies.test.ts +112 -0
  221. package/src/daemon/pending-replies.ts +162 -0
  222. package/src/daemon/policy-request-service.ts +3 -1
  223. package/src/daemon/policy-utils.test.ts +66 -1
  224. package/src/daemon/policy-utils.ts +126 -1
  225. package/src/daemon/request-store.ts +31 -0
  226. package/src/daemon/routers/session-timeout.ts +4 -0
  227. package/src/daemon/routers/slash-model.test.ts +344 -0
  228. package/src/daemon/routers/slash-model.ts +207 -0
  229. package/src/daemon/routers/slash-policies.test.ts +38 -32
  230. package/src/daemon/routers/slash-policies.ts +84 -33
  231. package/src/daemon/routers/slash-restart.test.ts +69 -0
  232. package/src/daemon/routers/slash-restart.ts +36 -0
  233. package/src/daemon/routers/slash-shutdown.test.ts +50 -0
  234. package/src/daemon/routers/slash-shutdown.ts +28 -0
  235. package/src/daemon/routers/slash-upgrade.test.ts +116 -0
  236. package/src/daemon/routers/slash-upgrade.ts +76 -0
  237. package/src/daemon/routers/types.ts +7 -0
  238. package/src/daemon/routers.ts +16 -0
  239. package/src/shared/adapters/blockquote.test.ts +28 -0
  240. package/src/shared/adapters/blockquote.ts +20 -0
  241. package/src/shared/adapters/filtering.test.ts +224 -10
  242. package/src/shared/adapters/filtering.ts +95 -7
  243. package/src/shared/adapters/inbound-cache.test.ts +48 -0
  244. package/src/shared/adapters/inbound-cache.ts +54 -0
  245. package/src/shared/adapters/turn-log-buffer.ts +266 -0
  246. package/src/shared/adapters/turn-log.test.ts +389 -0
  247. package/src/shared/adapters/turn-log.ts +357 -0
  248. package/src/shared/agent-utils.ts +12 -5
  249. package/src/shared/chats.test.ts +4 -0
  250. package/src/shared/chats.ts +9 -0
  251. package/src/shared/config.ts +16 -1
  252. package/src/shared/lite.ts +76 -2
  253. package/src/shared/policies.ts +26 -0
  254. package/src/shared/template-manifest.ts +267 -0
  255. package/src/shared/utils/shell.ts +61 -0
  256. package/src/shared/version.ts +34 -0
  257. package/src/shared/workspace.test.ts +217 -0
  258. package/src/shared/workspace.ts +626 -48
  259. package/templates/environments/cladding/allowlist-domain.mjs +125 -0
  260. package/templates/environments/cladding/env.json +21 -1
  261. package/templates/environments/cladding/run-with-network.mjs +54 -0
  262. package/templates/environments/macos-proxy/allowlist-domain.mjs +95 -0
  263. package/templates/environments/macos-proxy/env.json +8 -1
  264. package/templates/environments/macos-proxy/proxy.mjs +0 -1
  265. package/templates/gemini/template.json +5 -0
  266. package/templates/gemini-claw/template.json +13 -0
  267. package/templates/skills/clawmini-requests/SKILL.md +69 -10
  268. package/templates/skills/run-host/SKILL.md +51 -0
  269. package/templates/skills/skill-creator/SKILL.md +4 -3
  270. package/templates/skills/skill-creator/scripts/validate.sh +52 -0
  271. package/tsdown.config.ts +10 -1
  272. package/vitest.config.ts +2 -2
  273. package/web/.svelte-kit/ambient.d.ts +292 -118
  274. package/web/.svelte-kit/generated/server/internal.js +1 -1
  275. package/web/.svelte-kit/output/client/.vite/manifest.json +126 -136
  276. package/web/.svelte-kit/output/client/_app/immutable/chunks/{Drm9vgeP.js → 3AZlWB6U.js} +1 -1
  277. package/web/.svelte-kit/output/client/_app/immutable/chunks/BhRSsUCh.js +2 -0
  278. package/web/.svelte-kit/output/client/_app/immutable/chunks/BiLeM2i1.js +1 -0
  279. package/{dist/web/_app/immutable/chunks/CME08kGM.js → web/.svelte-kit/output/client/_app/immutable/chunks/BmBj85Ll.js} +1 -1
  280. package/web/.svelte-kit/output/client/_app/immutable/chunks/BrERcKAH.js +1 -0
  281. package/web/.svelte-kit/output/client/_app/immutable/chunks/Bv9252RM.js +1 -0
  282. package/web/.svelte-kit/output/client/_app/immutable/chunks/CIXNBPKi.js +1 -0
  283. package/web/.svelte-kit/output/client/_app/immutable/chunks/DISKL3GN.js +2 -0
  284. package/web/.svelte-kit/output/client/_app/immutable/chunks/{Zeh-C-mx.js → DcpaLzmX.js} +1 -1
  285. package/web/.svelte-kit/output/client/_app/immutable/chunks/DnQ3vS13.js +1 -0
  286. package/web/.svelte-kit/output/client/_app/immutable/chunks/KsloHTKS.js +1 -0
  287. package/{dist/web/_app/immutable/chunks/Ck-be5J2.js → web/.svelte-kit/output/client/_app/immutable/chunks/RsHsUj-8.js} +2 -2
  288. package/web/.svelte-kit/output/client/_app/immutable/chunks/{vDehDcuJ.js → wpfV79dV.js} +1 -1
  289. package/web/.svelte-kit/output/client/_app/immutable/entry/app.CIw1Qj0n.js +2 -0
  290. package/web/.svelte-kit/output/client/_app/immutable/entry/start.Di0-Jhte.js +1 -0
  291. package/web/.svelte-kit/output/client/_app/immutable/nodes/{0.CUGC2p-K.js → 0.DYyUA1au.js} +1 -1
  292. package/web/.svelte-kit/output/client/_app/immutable/nodes/1.D-3QEMMZ.js +1 -0
  293. package/web/.svelte-kit/output/client/_app/immutable/nodes/{2.BnwnD1Ki.js → 2.4olHnH7U.js} +1 -1
  294. package/{dist/web/_app/immutable/nodes/3.0arZe_Uf.js → web/.svelte-kit/output/client/_app/immutable/nodes/3.4w0bE-m2.js} +3 -3
  295. package/web/.svelte-kit/output/client/_app/immutable/nodes/4.CZvjhVHt.js +60 -0
  296. package/web/.svelte-kit/output/client/_app/immutable/nodes/{5.Bq2JzCEj.js → 5.DLbPVJY2.js} +1 -1
  297. package/web/.svelte-kit/output/client/_app/version.json +1 -1
  298. package/web/.svelte-kit/output/server/.vite/manifest.json +12 -10
  299. package/web/.svelte-kit/output/server/chunks/Icon.js +1 -1
  300. package/web/.svelte-kit/output/server/chunks/client.js +1 -1
  301. package/web/.svelte-kit/output/server/chunks/exports.js +1 -1
  302. package/web/.svelte-kit/output/server/chunks/index-server.js +2 -1
  303. package/web/.svelte-kit/output/server/chunks/internal.js +1 -1
  304. package/web/.svelte-kit/output/server/chunks/render-context.js +77 -0
  305. package/web/.svelte-kit/output/server/chunks/root.js +739 -788
  306. package/web/.svelte-kit/output/server/chunks/shared.js +234 -21
  307. package/web/.svelte-kit/output/server/index.js +126 -90
  308. package/web/.svelte-kit/output/server/manifest-full.js +1 -1
  309. package/web/.svelte-kit/output/server/manifest.js +1 -1
  310. package/web/.svelte-kit/output/server/nodes/0.js +1 -1
  311. package/web/.svelte-kit/output/server/nodes/1.js +1 -1
  312. package/web/.svelte-kit/output/server/nodes/2.js +1 -1
  313. package/web/.svelte-kit/output/server/nodes/3.js +1 -1
  314. package/web/.svelte-kit/output/server/nodes/4.js +1 -1
  315. package/web/.svelte-kit/output/server/nodes/5.js +1 -1
  316. package/web/.svelte-kit/output/server/remote-entry.js +245 -81
  317. package/web/.svelte-kit/tsconfig.json +4 -1
  318. package/dist/cli/propose-policy.mjs.map +0 -1
  319. package/dist/lite-CBxOT1y5.mjs +0 -241
  320. package/dist/lite-CBxOT1y5.mjs.map +0 -1
  321. package/dist/routing-D8rTxtaV.mjs +0 -245
  322. package/dist/routing-D8rTxtaV.mjs.map +0 -1
  323. package/dist/web/_app/immutable/chunks/B6YN0Nuq.js +0 -1
  324. package/dist/web/_app/immutable/chunks/BmRlVmv6.js +0 -1
  325. package/dist/web/_app/immutable/chunks/CK9JZLaG.js +0 -2
  326. package/dist/web/_app/immutable/chunks/Ck3rYNON.js +0 -1
  327. package/dist/web/_app/immutable/chunks/D5iV40bG.js +0 -1
  328. package/dist/web/_app/immutable/chunks/DMtIqaiV.js +0 -2
  329. package/dist/web/_app/immutable/chunks/DhD271EB.js +0 -1
  330. package/dist/web/_app/immutable/chunks/DpuLqk8d.js +0 -1
  331. package/dist/web/_app/immutable/chunks/DsIToJCP.js +0 -1
  332. package/dist/web/_app/immutable/entry/app.BCSV3nrG.js +0 -2
  333. package/dist/web/_app/immutable/entry/start.D4eLEZUM.js +0 -1
  334. package/dist/web/_app/immutable/nodes/1.CGC_42IQ.js +0 -1
  335. package/dist/web/_app/immutable/nodes/4.ClM1bXLE.js +0 -60
  336. package/dist/workspace-BJmJBfKi.mjs +0 -456
  337. package/dist/workspace-BJmJBfKi.mjs.map +0 -1
  338. package/src/cli/e2e/agents.test.ts +0 -140
  339. package/src/cli/e2e/basic.test.ts +0 -43
  340. package/src/cli/e2e/cron.test.ts +0 -132
  341. package/src/cli/e2e/export-lite-func.test.ts +0 -206
  342. package/src/cli/e2e/fallbacks.test.ts +0 -175
  343. package/src/cli/e2e/init.test.ts +0 -77
  344. package/src/cli/e2e/messages.test.ts +0 -332
  345. package/src/cli/e2e/propose-policy.test.ts +0 -203
  346. package/src/cli/e2e/requests.test.ts +0 -180
  347. package/src/cli/e2e/session-timeout.test.ts +0 -192
  348. package/src/cli/e2e/slash-new.test.ts +0 -93
  349. package/src/cli/e2e/subagents.test.ts +0 -106
  350. package/src/cli/e2e/utils.ts +0 -66
  351. package/src/cli/propose-policy.ts +0 -91
  352. package/web/.svelte-kit/output/client/_app/immutable/chunks/B6YN0Nuq.js +0 -1
  353. package/web/.svelte-kit/output/client/_app/immutable/chunks/BmRlVmv6.js +0 -1
  354. package/web/.svelte-kit/output/client/_app/immutable/chunks/CK9JZLaG.js +0 -2
  355. package/web/.svelte-kit/output/client/_app/immutable/chunks/Ck3rYNON.js +0 -1
  356. package/web/.svelte-kit/output/client/_app/immutable/chunks/D5iV40bG.js +0 -1
  357. package/web/.svelte-kit/output/client/_app/immutable/chunks/DMtIqaiV.js +0 -2
  358. package/web/.svelte-kit/output/client/_app/immutable/chunks/DhD271EB.js +0 -1
  359. package/web/.svelte-kit/output/client/_app/immutable/chunks/DpuLqk8d.js +0 -1
  360. package/web/.svelte-kit/output/client/_app/immutable/chunks/DsIToJCP.js +0 -1
  361. package/web/.svelte-kit/output/client/_app/immutable/entry/app.BCSV3nrG.js +0 -2
  362. package/web/.svelte-kit/output/client/_app/immutable/entry/start.D4eLEZUM.js +0 -1
  363. package/web/.svelte-kit/output/client/_app/immutable/nodes/1.CGC_42IQ.js +0 -1
  364. package/web/.svelte-kit/output/client/_app/immutable/nodes/4.ClM1bXLE.js +0 -60
  365. package/web/.svelte-kit/output/server/chunks/false.js +0 -4
  366. /package/dist/cli/{propose-policy.d.mts → manage-policies.d.mts} +0 -0
  367. /package/{src/cli/e2e → e2e/_helpers}/global-setup.ts +0 -0
@@ -0,0 +1,43 @@
1
+ # Product Requirements Document: E2E Test Framework Improvements
2
+
3
+ ## Vision
4
+ To dramatically improve the speed, reliability, and developer experience of the Clawmini CLI end-to-end (E2E) test suite. By migrating from isolated, process-heavy polling tests to a modern, event-driven, shared-daemon architecture, we will reduce test execution time, eliminate filesystem flakiness, and provide a highly readable, declarative API for future test development.
5
+
6
+ ## Product / Market Background
7
+ Currently, the E2E tests for the Clawmini CLI rely on a heavily isolated setup where almost every test file spins up its own temporary directory and its own instance of the daemon. Tests rely on filesystem mutations (using `fs.readFileSync` and `fs.writeFileSync`) and manual polling of `.jsonl` log files to verify behavior.
8
+
9
+ This approach has led to:
10
+ 1. **Slow Execution:** Spawning new Node processes for the CLI and starting/stopping the daemon repeatedly is incredibly time-consuming.
11
+ 2. **Flakiness:** Polling the filesystem using `setTimeout` and `vi.waitFor` is susceptible to race conditions, OS-level I/O delays, and timeouts.
12
+ 3. **Poor Developer Experience (DX):** Writing new tests requires copying extensive boilerplate to manage file paths, sanitize JSON, and manually invoke the CLI for setup tasks.
13
+
14
+ ## Use Cases
15
+ 1. **Adding a New CLI Feature Test:** A developer needs to write an E2E test for a new feature (e.g., a new policy approval flow). They use a fluent `TestEnvironment` API to easily inject mock agents, trigger the flow, and seamlessly await specific system events.
16
+ 2. **Refactoring the Core Daemon:** A developer makes a sweeping change to message routing. They run the entire E2E suite locally, which now completes in seconds rather than minutes because it uses a shared background daemon.
17
+ 3. **Testing Subagent Behaviors:** A developer verifies that a subagent correctly spawns a child process. They rely on the framework to automatically inject `clawmini-lite.js` into the test agent's `$PATH`, abstracting away the complex setup logic.
18
+
19
+ ## Requirements
20
+
21
+ ### 1. Unified Test Environment API
22
+ - Introduce a high-level `TestEnvironment` or `TestFixture` class to manage E2E test setup.
23
+ - **CLI-First Setup:** The environment should prefer using standard CLI commands (e.g., `clawmini agents add`, `clawmini chats add`) to configure the workspace state, falling back to manual file edits (e.g., for `policies.json`) only when the CLI does not expose that capability.
24
+ - **Fluent Assertions/Waiters:** Provide domain-specific waiter functions (e.g., `await env.chat('default').waitForMessage({ role: 'system', event: 'policy_approved' })`) rather than relying on regex parsing of log files.
25
+
26
+ ### 2. Event-Driven State Verification (Replacing Filesystem Polling)
27
+ - Tests must **stop polling `chat.jsonl` files**.
28
+ - Leverage the existing Server-Sent Events (SSE) endpoint exposed by the daemon (currently used by adapters).
29
+ - The test framework should connect an SSE client to the daemon and buffer events, allowing tests to asynchronously await specific message events in real-time. This increases test speed and accurately simulates how adapters interact with the daemon.
30
+
31
+ ### 3. Shared Daemon Architecture
32
+ - Transition the test runner from a "one daemon per test suite" model to a "shared daemon" model.
33
+ - A single daemon instance should be started during Vitest's `globalSetup` (or via a shared before-all hook) and reused across multiple test suites where feasible.
34
+ - Tests must be designed to not fatally pollute the shared state. Where deep mutation is required, tests can run sequentially or utilize isolated chat/agent namespaces.
35
+
36
+ ### 4. Simplified Subagent Mocking
37
+ - Remove the manual, verbose setup logic previously required for testing subagents (e.g., manually exporting the lite script and symlinking it to a `bin` folder).
38
+ - Utilize the newly built-in feature where a designated test environment automatically exports `clawmini-lite.js` and injects it into the agent's `$PATH`.
39
+ - Provide a simple configuration toggle in the test fixture (e.g., `await env.enableSubagentEnvironment()`) to activate this feature.
40
+
41
+ ## Security & Privacy Concerns
42
+ - **Port Conflicts:** When running tests in parallel, ensure the shared daemon or any isolated daemons bind to random available ports (`port: 0`) to prevent `EADDRINUSE` errors. The test framework must accurately capture the bound port and route test API requests accordingly.
43
+ - **Isolation Boundaries:** If using a shared daemon, care must be taken to ensure test data (chats, agents, policies) does not leak between parallel runs in a way that causes false positives/negatives. Unique identifiers (e.g., UUID-suffixed chat names) should be generated by the `TestEnvironment` API.
@@ -0,0 +1,12 @@
1
+ # Questions
2
+
3
+ 1. **Test Environment API:** Do you agree that we should build a more robust `TestEnvironment` or `TestFixture` class/helper to encapsulate the boilerplate of setting up the `.clawmini` workspace (creating directories, editing `settings.json`, adding policies/agents) and managing the CLI/daemon lifecycle?
4
+ * **Answer:** Yes, this direction seems good.
5
+ 2. **Polling vs. Events:** Currently, we poll `.jsonl` files on disk. This is a bit slow and flaky. Would you prefer we keep polling (but maybe optimize the helper functions) or should we add a test-only event stream (like an SSE endpoint or a local IPC socket) to the daemon to push events to the test runner?
6
+ * **Answer:** Use the existing SSE endpoint that the daemon exposes for adapters. It would be faster and more realistic.
7
+ 3. **Daemon Lifecycle:** In many tests, we start and stop the daemon per test or per suite. It takes time. Are you open to running a shared daemon where possible, or do you prefer the strict isolation of a fresh daemon + fresh directory for every test suite (the current approach)?
8
+ * **Answer:** Yes, running one daemon would be a big win.
9
+ 4. **Subagents Mocking:** We use `clawmini-lite.js` inside shell commands to mock subagents. Is this approach considered realistic enough, or do we want to provide actual mocked subagent binaries/scripts as part of the test harness?
10
+ * **Answer:** The verbosity should be reduced by using the built-in feature where an environment exports `clawmini-lite.js` and adds it to the `$PATH` for the agent.
11
+ 5. **JSON/Filesystem Mutation Abstraction:** I noticed across `cron.test.ts`, `environments.test.ts`, and others, there's significant use of `fs.readFileSync` and `fs.writeFileSync` to write simple JSON configs or scripts. This confirms the need for an abstracted setup layer. Should this test harness layer expose high-level domain operations like `env.addAgent({ ... })` or low-level generic file editors like `env.writeJson('path', payload)`?
12
+ * **Answer:** Ideally expose high-level domain operations that use the CLI wherever possible, and fall back on file editing only where necessary.
@@ -0,0 +1,22 @@
1
+ # E2E Test Improvements Tickets (Part 2)
2
+
3
+ ## Step 1: Migrate Remaining Tests to the New API
4
+ - **Description**: Systematically refactor all remaining existing E2E tests to use the `TestEnvironment` API and the new SSE-based event waiting mechanism. Remove all manual file read/write polling.
5
+ - **Verification**:
6
+ - Ensure the full E2E test suite passes reliably.
7
+ - Run `npm run validate`.
8
+ - **Status**: not started
9
+
10
+ ## Step 2: Implement Shared Daemon Architecture
11
+ - **Description**: Transition the E2E suite to use a shared daemon model. The daemon should be spun up during Vitest's `globalSetup` (or a shared hook), binding to `port: 0` to prevent collisions. Ensure tests leverage the `TestEnvironment`'s unique namespaces to avoid state leakage.
12
+ - **Verification**:
13
+ - Run the entire test suite and verify a significant reduction in overall execution time. Check that tests pass without `EADDRINUSE` errors.
14
+ - Run `npm run validate`.
15
+ - **Status**: not started
16
+
17
+ ## Step 3: Simplified Subagent Mocking
18
+ - **Description**: Remove manual subagent shell-script scaffolding from tests. Introduce a configuration toggle (e.g., `enableSubagentEnvironment()`) in the test fixture to automatically inject `clawmini-lite.js` into the test agent's `$PATH` via the new built-in feature.
19
+ - **Verification**:
20
+ - Verify that tests involving subagents still pass with the new streamlined setup.
21
+ - Run `npm run validate`.
22
+ - **Status**: not started
@@ -0,0 +1,22 @@
1
+ # E2E Test Improvements Tickets (Part 1)
2
+
3
+ ## Step 1: Implement the Unified Test Environment API
4
+ - **Description**: Create a high-level `TestEnvironment` or `TestFixture` class that abstracts the setup of E2E tests. It should provide methods to configure the workspace using standard CLI commands (e.g., `clawmini agents add`, `clawmini chats add`) and fallback to file edits where necessary. It should handle generating unique namespaces/IDs for isolated testing.
5
+ - **Verification**:
6
+ - Write unit tests for the new `TestEnvironment` class to verify its setup logic.
7
+ - Run `npm run validate`.
8
+ - **Status**: complete
9
+
10
+ ## Step 2: Implement Event-Driven State Verification (SSE)
11
+ - **Description**: Extend the `TestEnvironment` class to connect an SSE client to the daemon's existing endpoint. Buffer incoming events and implement fluent assertion/waiter functions (e.g., `waitForMessage(predicate)`) to replace filesystem polling.
12
+ - **Verification**:
13
+ - Test the SSE client integration against a running daemon manually or via unit tests.
14
+ - Run `npm run validate`.
15
+ - **Status**: complete
16
+
17
+ ## Step 3: Migrate a Single Test to the New API
18
+ - **Description**: Refactor one specific E2E test file (e.g., `src/cli/e2e/messages.test.ts`) to use the `TestEnvironment` API and the new SSE-based event waiting mechanism. Remove all manual file read/write polling from this specific test.
19
+ - **Verification**:
20
+ - Ensure the migrated E2E test passes reliably.
21
+ - Run `npm run validate`.
22
+ - **Status**: complete
@@ -0,0 +1,30 @@
1
+ # Development Log
2
+
3
+ ## Ticket 1: Schema and Type Updates
4
+ Starting work on Ticket 1. Need to update:
5
+ - `src/shared/config.ts`
6
+ - `src/shared/policies.ts`
7
+ - `src/cli/lite.ts`
8
+ - `src/daemon/api/agent-router.ts`
9
+
10
+ **Update:** Completed updates to `EnvironmentSchema` (added `baseDir`) and `PolicyRequest` (added `cwd`). Updated `clawmini-lite.js` (`src/cli/lite.ts`) to capture `process.cwd()` and pass it to `createPolicyRequest.mutate()`. Also updated `src/daemon/policy-request-service.ts` to fix a strict TypeScript error (`exactOptionalPropertyTypes`) when setting `cwd` conditionally.
11
+ Ran `npm run validate` and all checks passed. Ticket 1 is complete.
12
+
13
+ ## Ticket 2: Smart Output Handling & CLI Output
14
+ This ticket was found to be completely implemented already via a previous PR (`src/daemon/policy-utils.ts` now intercepts `stdout/stderr` writing to `./tmp`, and the tests pass), so the status was marked Complete.
15
+
16
+ ## Ticket 3: Path Translation Logic
17
+ Implemented `translateSandboxPath(sandboxCwd, baseDir, agentDir)` in `src/daemon/policy-utils.ts`.
18
+ - Handles stripping `baseDir` from `sandboxCwd` properly.
19
+ - Checks if the resulting path stays within `agentDir` via `pathIsInsideDir` for security.
20
+ - Comprehensive unit tests added to `src/daemon/policy-utils.test.ts`.
21
+ - `npm run format` was executed.
22
+ - Executed `npm run validate` successfully. All checks and tests (including new ones) have passed. Ticket 3 is marked Complete.
23
+
24
+ ## Ticket 4: Context-Aware Execution Integration
25
+ - Found that `translateSandboxPath` was causing `ENOENT` in the `requests.test.ts` e2e test when `baseDir` was undefined and `sandboxCwd` was an absolute path outside the `agentDir`.
26
+ - Fixed the E2E test `requests.test.ts` by ensuring `lite-env-dumper` is executed within its `agentDir` rather than the `e2eDir`, allowing `pathIsInsideDir` to validate correctly.
27
+ - Confirmed the fix for the previous failure: `should synchronously output execution result for auto-approved policy`.
28
+ - Validated the E2E test `context-cwd.test.ts` where the agent navigates to a subdirectory (`cd foo`) and invokes a `print-cwd` policy, effectively checking context-aware execution logic in `slash-policies.ts`.
29
+ - Verified `hostCwd` fallback mapping to `agentDir`.
30
+ - Executed `npm run validate` and resolved all linter/format issues. All E2E and unit tests passed. Ticket 4 is marked Complete.
@@ -0,0 +1,28 @@
1
+ # Policy CWD & Output File Notes
2
+
3
+ ## Current Implementation
4
+
5
+ - `clawmini-lite.js` is the standalone client injected into environments. It runs inside the sandbox (e.g., Cladding, macOS).
6
+ - `clawmini-lite.js request <cmd>` is handled in `src/cli/lite.ts`, which calls `client.createPolicyRequest.mutate(...)` on the TRPC API.
7
+ - The `createPolicyRequest` procedure in `src/daemon/api/agent-router.ts` receives the command, args, and file mappings.
8
+ - The request is stored as a `PolicyRequest` (defined in `src/shared/policies.ts`).
9
+ - When a policy is approved, `src/daemon/routers/slash-policies.ts` executes the command using `executeRequest` (from `src/daemon/policy-utils.ts`), passing `getWorkspaceRoot()` as the `cwd`.
10
+ - `executeRequest` also uses `getWorkspaceRoot()` for auto-approved policies.
11
+
12
+ ## Path Translation
13
+
14
+ - `src/daemon/api/router-utils.ts` has `resolveAgentDir(agentId, workspaceRoot)` which returns the host directory for an agent.
15
+ - Environments are defined in `src/shared/config.ts` (`EnvironmentSchema`).
16
+ - The prompt suggests adding a property to environments (like `baseDir`) to indicate what the environment considers its root (e.g., `/home/user`).
17
+ - If an environment specifies `baseDir: '/home/user'`, and `clawmini-lite.js` reports `cwd` as `/home/user/project/src`, the daemon can translate this by stripping `/home/user` and resolving the rest against the agent's host directory (`agentDir`).
18
+ - How does the daemon know which environment the agent is running in? The chat settings or agent settings might define the environment.
19
+
20
+ ## Output File
21
+
22
+ - A new option `--output-file <path>` (or similar) will be added to `clawmini-lite.js request`.
23
+ - The prompt asks to figure out a standard way to pass the output of both stdout and stderr.
24
+ - Possibilities:
25
+ 1. Interleave stdout and stderr into one file.
26
+ 2. Output them as a JSON structure `{ "stdout": "...", "stderr": "..." }`.
27
+ 3. Support separate arguments like `--stdout-file <path>` and `--stderr-file <path>`.
28
+ 4. Write standard output to the file, and standard error to the console (or vice versa).
@@ -0,0 +1,77 @@
1
+ # Product Requirements Document (PRD): Policy Execution Context and Output Handling
2
+
3
+ ## Vision
4
+
5
+ To enhance the reliability and usability of policy requests within Clawmini's sandboxed environments. This is achieved by ensuring policies execute in the correct working directory relative to the agent's sandbox, and by improving how large policy execution outputs (stdout/stderr) are returned to the agent, preventing truncation issues and keeping the chat history clean.
6
+
7
+ ## Product / Market Background
8
+
9
+ Currently, when a sandboxed agent uses `clawmini-lite.js request <policy>`, the daemon executes the policy in the root directory of the workspace, regardless of where the agent invoked the command inside its sandbox. This causes friction, as agents often expect commands to run in their current working directory (`cwd`) and must resort to passing absolute paths as arguments.
10
+
11
+ Furthermore, if a policy generates a large amount of output, including it directly in the JSON response or chat message can overwhelm the context window or result in truncated logs. A robust mechanism to handle varying sizes of standard output and standard error is necessary.
12
+
13
+ ## Use Cases
14
+
15
+ 1. **Context-Aware Policy Execution:** An agent running in a macOS proxy environment navigates to `~/project/src` inside its sandbox and issues a policy request. The host daemon translates `~/project/src` to the corresponding host directory (e.g., `/Users/tbuckley/projects/agent-1/project/src`) and executes the policy command there.
16
+ 2. **Handling Large Output Logs:** A policy request performs a large build task that outputs 5000 characters to `stdout`. Instead of returning the massive text directly in the message, the daemon saves the output to a temporary file (e.g., `./tmp/stdout-<id>.txt` within the agent's directory) and responds with a summary: "stdout is 5000 characters, saved to ./tmp/stdout-<id>.txt".
17
+
18
+ ## Requirements
19
+
20
+ ### 1. Environment `baseDir` Configuration
21
+
22
+ - The `EnvironmentSchema` (in `src/shared/config.ts`) must be updated to include an optional `baseDir` string property.
23
+ - `baseDir` represents the root path _inside_ the sandbox that maps to the agent's root directory on the host.
24
+ - If `baseDir` is undefined, the system assumes the sandbox shares the host filesystem (no path translation required).
25
+
26
+ ### 2. Path Translation for Policy Execution
27
+
28
+ - `clawmini-lite.js` (specifically `src/cli/lite.ts`) must capture its current working directory (`process.cwd()`) and send it as part of the `createPolicyRequest` mutation.
29
+ - The `PolicyRequest` type must be updated to include an optional `cwd` property.
30
+ - When the daemon executes an approved policy (both manual and auto-approved), it must translate the requested `cwd` from the sandbox perspective to an absolute path on the host.
31
+ - **Translation Logic:** If the environment has a `baseDir` defined (e.g., `/home/user`), and the requested `cwd` starts with that `baseDir` (e.g., `/home/user/foo`), the daemon strips the `baseDir` and resolves the remainder (`/foo`) against the agent's root directory on the host (`agentDir`).
32
+ - The translated path must be validated to ensure it does not break out of the agent's allowed workspace directory. If it attempts to escape the directory, execution should fail safely.
33
+ - The policy must be executed with the translated directory as its `cwd` instead of `getWorkspaceRoot()`.
34
+
35
+ ### 3. Smart Output Handling
36
+
37
+ - The response mechanism for policy execution (both the CLI output from `clawmini-lite.js` and the chat messages sent back to the agent) must dynamically handle `stdout` and `stderr`.
38
+ - For `stdout` and `stderr` independently:
39
+ - If the output length is **less than 500 characters**, include it directly in the message payload as text.
40
+ - If the output length is **greater than or equal to 500 characters**, the daemon must:
41
+ 1. Create a file inside the agent's local `./tmp/` directory (e.g., `./tmp/stdout-<id>.txt` or `./tmp/stderr-<id>.txt`).
42
+ 2. Write the full output to this file.
43
+ 3. Include a reference string in the message payload instead of the raw text, formatted as: `stdout is <length> characters, saved to ./tmp/stdout-<id>.txt`. (Substitute `stderr` as appropriate).
44
+
45
+ ### 4. Updates to `clawmini-lite.js` Output
46
+
47
+ - `clawmini-lite.js request` must output the results to the terminal so the agent can read them.
48
+ - If the output was saved to a file, the CLI must print the reference string (e.g., "stdout is 1234 characters, saved to ./tmp/stdout-foo.txt") so the agent knows where to find the data.
49
+ - The `executeRequest` result must return the structured info needed to determine if the output was inline or saved to a file.
50
+
51
+ ## Technical Details & Architecture Notes
52
+
53
+ - Modifying `createPolicyRequest` in `src/daemon/api/agent-router.ts` to accept `cwd`.
54
+ - The `Environment` definition will be accessed via the active chat settings or agent definition to resolve `baseDir`.
55
+ - Update `src/daemon/routers/slash-policies.ts` and auto-approve logic to invoke the path translation helper.
56
+ - Update `executeSafe` or the caller in `executeRequest` to write to `./tmp/` and construct the modified response payload.
57
+
58
+ ## Privacy, Security, and Accessibility Concerns
59
+
60
+ - **Security (Path Traversal):** The path translation mechanism must rigorously ensure the final translated host path is strictly within the agent's assigned directory on the host (`pathIsInsideDir`). A malicious agent could manipulate the sandbox `cwd` to escape the directory if `baseDir` replacement isn't carefully validated.
61
+ - **Security (File Permissions):** Temporary output files written to `./tmp/` must be readable by the agent running within the sandbox.
62
+ - **Resource Limits:** Large outputs saved to `./tmp/` should be reasonably sized. While file limits aren't explicitly requested here, writing massive outputs should be monitored to prevent disk exhaustion.
63
+
64
+ ## Testing & Validation
65
+
66
+ We will use explicit End-to-End (E2E) tests leveraging the `debug` agent template (which echoes executed commands and their output) to validate this behavior:
67
+
68
+ 1. **Context-Aware `cwd` Test:**
69
+ - Define a policy that runs `pwd` and has autoApprove:true.
70
+ - Start an agent using the `debug` template.
71
+ - Using `clawmini-lite.js` within a sub-directory of the agent (e.g., `cd foo && clawmini-lite.js request pwd`), request the `pwd` policy.
72
+ - Validate that the policy prints the correct mapped subdirectory path (i.e. resolving to `foo` inside the agent's host directory, not the workspace root).
73
+ 2. **Smart Output Length Tests:**
74
+ - Define a policy that generates short output (< 500 chars) and one that generates long output (>= 500 chars), both with autoApprove:true.
75
+ - For the short output policy, validate that the output is included directly inline within the response.
76
+ - For the long output policy, validate that the direct output text is suppressed and instead the response contains the correctly formatted reference string: `stdout is <length> characters, saved to ./tmp/stdout-<id>.txt`. Ensure the file is created in the expected location.
77
+ - Ensure the agent can run `more ./tmp/stdout-<id>.txt` to read the contents.
@@ -0,0 +1,6 @@
1
+ # Questions
2
+
3
+ 1. What should we name the property in `EnvironmentSchema` that represents the base directory inside the sandbox? (e.g., `baseDir`, `sandboxRoot`, `targetDir`)
4
+ A: `baseDir`. It should be optional, and if unspecified we assume the environment and host share the same filesystem, so a path within the environment is the same as outside.
5
+ 2. Regarding the output file for `clawmini-lite.js request` ("We should figure out a standard way to pass the output of both stdout and stderr"): would you prefer separate flags (e.g., `--stdout-file` and `--stderr-file`), a single file interleaving both streams, or a single JSON file containing `{ "stdout": "...", "stderr": "..." }`?
6
+ A: Instead of letting it specify a file, we instead look at the length of stdout/stderr. For each, we check if it's <500 characters and include it in the message if so. If >=500 characters, we create a tmp file (like inside the agent's directory in a ./tmp/ folder) and include the path + total length of the output in the message, like "stdout is 1234 characters, saved to ./tmp/stdout-foo.txt".
@@ -0,0 +1,77 @@
1
+ # Policy CWD & Output Tickets
2
+
3
+ ## Ticket 1: Schema and Type Updates
4
+ **Status**: Complete
5
+
6
+ **Tasks:**
7
+ - Update `src/shared/config.ts` (`EnvironmentSchema`) to include an optional `baseDir` string property.
8
+ - Update `src/shared/policies.ts` (`PolicyRequest`) to include an optional `cwd` string property.
9
+ - Update `src/cli/lite.ts` to capture `process.cwd()` and include it when calling `createPolicyRequest.mutate(...)`.
10
+ - Update `src/daemon/api/agent-router.ts` (`createPolicyRequest` procedure) to accept the new `cwd` parameter.
11
+
12
+ **Verification:**
13
+ - Run `npm run validate` to ensure TypeScript compilation, linting, and formatting pass without errors.
14
+
15
+ ## Ticket 2: Smart Output Handling & CLI Output
16
+ **Status**: Complete
17
+
18
+ **Tasks:**
19
+ - Write an E2E test using the `debug` agent template that creates two auto-approved policies: one generating < 500 characters of output, and one generating >= 500 characters.
20
+ - Ensure the E2E test fails (Red phase).
21
+ - Update `executeRequest` (or the underlying execution logic in `src/daemon/policy-utils.ts`) to intercept `stdout` and `stderr`.
22
+ - If the output is < 500 chars, return it inline.
23
+ - If the output is >= 500 chars:
24
+ - Write it to `./tmp/stdout-<id>.txt` (or stderr) inside the agent's host directory.
25
+ - Return the summary string: `stdout is <length> characters, saved to ./tmp/stdout-<id>.txt`.
26
+ - Update `src/cli/lite.ts` to output the returned string or inline output to the terminal so the agent can read it.
27
+ - Ensure the E2E test passes (Green phase).
28
+
29
+ **Verification:**
30
+ - The new Smart Output E2E test passes.
31
+ - Run `npm run validate` to ensure all checks pass.
32
+
33
+ ## Ticket 3: Path Translation Logic
34
+ **Status**: Complete
35
+
36
+ **Tasks:**
37
+ - Create a path translation helper function (e.g., in `src/daemon/api/router-utils.ts` or `src/daemon/policy-utils.ts`) that takes the sandbox `cwd`, environment `baseDir`, and host `agentDir`.
38
+ - Implement logic to strip `baseDir` from `cwd` and resolve the remainder against `agentDir`.
39
+ - Implement security validation to ensure the resulting path does not escape `agentDir` (prevent path traversal/directory escape).
40
+ - Write comprehensive unit tests for this translation helper, testing valid paths, undefined `baseDir`, and malicious escape attempts.
41
+
42
+ **Verification:**
43
+ - Run the new unit tests and ensure they pass.
44
+ - Run `npm run validate` to ensure all checks pass.
45
+
46
+ ## Ticket 4: Context-Aware Execution Integration
47
+ **Status**: Complete
48
+
49
+ **Tasks:**
50
+ - Write an E2E test using the `debug` agent template where the agent navigates to a subdirectory (e.g., `cd foo`) and invokes a `pwd` policy.
51
+ - Ensure the E2E test fails (Red phase), as it will currently return the workspace root.
52
+ - Update `src/daemon/routers/slash-policies.ts` and the auto-approve logic to look up the active chat/agent's environment configuration.
53
+ - Use the path translation helper from Ticket 3 to determine the correct host `cwd` for the policy execution.
54
+ - Pass the translated host `cwd` into `executeRequest` instead of `getWorkspaceRoot()`.
55
+ - Ensure the E2E test passes (Green phase).
56
+
57
+ **Verification:**
58
+ - The new Context-Aware Execution E2E test passes.
59
+ - Run `npm run validate` to ensure all system checks pass.
60
+
61
+ ## Ticket 5: DRY Violation for host cwd resolution
62
+ **Status**: Complete
63
+
64
+ **Tasks:**
65
+ - The logic to resolve the host working directory using `getActiveEnvironmentInfo`, `readEnvironment`, and `translateSandboxPath` is duplicated identically in `src/daemon/api/agent-policy-endpoints.ts` and `src/daemon/routers/slash-policies.ts`. Extract this into a reusable function in `src/daemon/policy-utils.ts`.
66
+
67
+ **Verification:**
68
+ - Run `npm run validate` to ensure all checks pass.
69
+
70
+ ## Ticket 6: Leftover Debug Logs
71
+ **Status**: Complete
72
+
73
+ **Tasks:**
74
+ - `src/daemon/policy-utils.ts` contains `console.log` statements in `translateSandboxPath` that were likely meant for debugging and should be removed.
75
+
76
+ **Verification:**
77
+ - Run `npm run validate` to ensure all checks pass.
@@ -3,7 +3,9 @@
3
3
  ### Initialization & Daemon
4
4
  - `clawmini init`: Initialize a new `.clawmini` configuration folder.
5
5
  - `clawmini up`: Start the local daemon server in the background.
6
- - `clawmini down`: Stop the local daemon server.
6
+ - `clawmini serve [--detach] [--only <services>] [--exclude <services>]`: Run the daemon, web UI, and any configured adapters under a single supervisor with interleaved prefixed logs. Use `--detach` to run in the background. Adapters (`discord`, `google-chat`) are auto-detected by the presence of their config files.
7
+ - `clawmini logs [-f] [-s <service>] [-n <lines>]`: View logs from `clawmini serve` services.
8
+ - `clawmini down`: Stop the local supervisor (if running) or daemon.
7
9
  - `clawmini export-lite [--out <path>] [--stdout]`: Export the standalone `clawmini-lite` client script.
8
10
 
9
11
  ### Chat Management
@@ -0,0 +1,35 @@
1
+ Clawmini evolves agent CLIs (currently Gemini CLI and OpenCode, and in future Claude Code and Codex) into secure & proactive assistants.
2
+
3
+ - Secure: can only access the network through allowlisted commands and human approval
4
+ - Proactive: always available, always working
5
+ - Assistant: one consistent personality across a single long-running chat
6
+
7
+ The basics
8
+
9
+ - When users message an agent, Clawmini converts it into a shell command to run and replies with the output.
10
+ - Users most often message an agent through a chat app like Discord or Google Chat, though there is a built in web app and CLI for debugging.
11
+ - Agents are defined by (1) a command to run when messages are received, usually for an agent CLI; (2) a folder to use as cwd; (3) env vars to set.
12
+ - Most agent CLIs allow guiding their behavior via custom system prompts, per-folder AGENTS.md files, and Skills
13
+ - Most agent CLIs expose hooks to monitor and adjust their behavior as they run (ex log a tool call before it is run, inject notifications when a tool call finishes, or prevent a model from stopping by sending a next prompt)
14
+
15
+ Security model:
16
+
17
+ - The Clawmini daemon exposes separate APIs for users (trusted) and agents (untrusted)
18
+ - The Clawmini daemon runs agents inside a sandbox with no network access (except for LLM APIs), so they cannot exfiltrate private data by default; and limited file access so they cannot modify sensitive configuration data
19
+ - The Clawmini daemon stores its configuration inside a .clawmini folder within the workspace root, including sensitive files that the agent should not be able to edit like commands to execute; and potentially sensitive files that the agent should not be allowed to read like chats with other agents
20
+ - Agents are given a `clawmini-lite.js` script on their $PATH that allows them to interact with the daemon outside the sandbox through the untrusted agent API. The daemon distinguishes trusted (user) from untrusted (agent) callers via a per-workspace `CLAW_API_TOKEN` injected into the agent's environment.
21
+ - Agents can request the daemon run user-allowlisted commands outside the sandbox and receive the output. Users decide whether commands run automatically or require human review depending on the sensitivity (ex always ok to read emails or create drafts, but sending an email requires approval). An agent can even request to allowlist new commands!
22
+
23
+ Proactivity model:
24
+
25
+ - Agents can schedule messages to send themselves in the future (one-off or recurring), waking up to perform work. Users do not see these scheduled messages, only the agent’s output.
26
+ - Agents cannot do any blocking work so they always remain available for the user. For long-running tasks they delegate to a subagent and get notified when it finishes; subagents run to completion and may block on their own async work.
27
+ - To avoid huge costs, there is a limit to how many subagents can run in parallel.
28
+ - Agents receive any pending messages after each tool call, allowing for steering while the model is running
29
+ - If no message should be shared with the user, the agent can respond with NO_REPLY_NECESSARY
30
+
31
+ Memory model
32
+
33
+ - Users interact with an agent through a single ongoing chat. However, agent context is limited and quality degrades as it gets longer.
34
+ - The agent’s personality and memory are persisted via files; it is instructed to read the personality and recent memory files at the start, and search the memory when appropriate.
35
+ - We regularly clear the session after timeout and tell it to save anything important to memory files