clawmini 0.0.3 → 0.0.5

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 (333) hide show
  1. package/README.md +19 -0
  2. package/dist/adapter-discord/index.d.mts.map +1 -1
  3. package/dist/adapter-discord/index.mjs +398 -193
  4. package/dist/adapter-discord/index.mjs.map +1 -1
  5. package/dist/adapter-google-chat/index.d.mts +5 -0
  6. package/dist/adapter-google-chat/index.d.mts.map +1 -0
  7. package/dist/adapter-google-chat/index.mjs +1077 -0
  8. package/dist/adapter-google-chat/index.mjs.map +1 -0
  9. package/dist/cli/index.mjs +107 -14
  10. package/dist/cli/index.mjs.map +1 -1
  11. package/dist/cli/lite.mjs +175 -16
  12. package/dist/cli/lite.mjs.map +1 -1
  13. package/dist/cli/propose-policy.d.mts +1 -0
  14. package/dist/cli/propose-policy.mjs +7159 -0
  15. package/dist/cli/propose-policy.mjs.map +1 -0
  16. package/dist/daemon/index.d.mts.map +1 -1
  17. package/dist/daemon/index.mjs +1427 -513
  18. package/dist/daemon/index.mjs.map +1 -1
  19. package/dist/{lite-oSYSvaOr.mjs → lite-CBxOT1y5.mjs} +101 -24
  20. package/dist/lite-CBxOT1y5.mjs.map +1 -0
  21. package/dist/routing-D8rTxtaV.mjs +245 -0
  22. package/dist/routing-D8rTxtaV.mjs.map +1 -0
  23. package/dist/web/_app/immutable/assets/0.C-4eziNy.css +1 -0
  24. package/dist/web/_app/immutable/assets/4.Cc_xwLNl.css +1 -0
  25. package/dist/web/_app/immutable/chunks/B6YN0Nuq.js +1 -0
  26. package/dist/web/_app/immutable/chunks/{Dc-UOHw9.js → BmRlVmv6.js} +1 -1
  27. package/{web/.svelte-kit/output/client/_app/immutable/chunks/8YNcRyEk.js → dist/web/_app/immutable/chunks/C20lZMGz.js} +1 -1
  28. package/dist/web/_app/immutable/chunks/C9lbZ-kT.js +1 -0
  29. package/dist/web/_app/immutable/chunks/CK9JZLaG.js +2 -0
  30. package/dist/web/_app/immutable/chunks/CME08kGM.js +1 -0
  31. package/dist/web/_app/immutable/chunks/{BPy8HLo7.js → Ck-be5J2.js} +1 -1
  32. package/dist/web/_app/immutable/chunks/Ck3rYNON.js +1 -0
  33. package/dist/web/_app/immutable/chunks/DMtIqaiV.js +2 -0
  34. package/dist/web/_app/immutable/chunks/{B8yYFADm.js → DhD271EB.js} +1 -1
  35. package/dist/web/_app/immutable/chunks/{DcrmIfTj.js → DpuLqk8d.js} +1 -1
  36. package/dist/web/_app/immutable/chunks/{ZkLyk0mE.js → Drm9vgeP.js} +1 -1
  37. package/dist/web/_app/immutable/chunks/DsIToJCP.js +1 -0
  38. package/dist/web/_app/immutable/chunks/{CyNaE55B.js → Zeh-C-mx.js} +1 -1
  39. package/{web/.svelte-kit/output/client/_app/immutable/entry/app.DO5eYwVz.js → dist/web/_app/immutable/entry/app.BgB5VkRU.js} +2 -2
  40. package/dist/web/_app/immutable/entry/start.DuxJo6av.js +1 -0
  41. package/dist/web/_app/immutable/nodes/0.C9oFZP9h.js +1 -0
  42. package/dist/web/_app/immutable/nodes/1.BON2Wk6k.js +1 -0
  43. package/dist/web/_app/immutable/nodes/{2.CK3CLC0f.js → 2.BnwnD1Ki.js} +1 -1
  44. package/dist/web/_app/immutable/nodes/{3.ncP0xLO6.js → 3.CIs4tjjw.js} +1 -1
  45. package/dist/web/_app/immutable/nodes/4.DLarELN4.js +60 -0
  46. package/dist/web/_app/immutable/nodes/{5.BpJUN6QH.js → 5.CE_QKy_3.js} +1 -1
  47. package/dist/web/_app/version.json +1 -1
  48. package/dist/web/index.html +12 -12
  49. package/dist/{workspace-DjoNjhW0.mjs → workspace-BJmJBfKi.mjs} +103 -11
  50. package/dist/workspace-BJmJBfKi.mjs.map +1 -0
  51. package/docs/14_google_chat_adapter/development_log.md +40 -0
  52. package/docs/14_google_chat_adapter/notes.md +28 -0
  53. package/docs/14_google_chat_adapter/prd.md +35 -0
  54. package/docs/14_google_chat_adapter/questions.md +9 -0
  55. package/docs/14_google_chat_adapter/tickets.md +117 -0
  56. package/docs/15_sandbox_policies/tickets.md +33 -0
  57. package/docs/16_session_timeout/development_log.md +20 -0
  58. package/docs/16_session_timeout/notes.md +44 -0
  59. package/docs/16_session_timeout/prd.md +106 -0
  60. package/docs/16_session_timeout/questions.md +10 -0
  61. package/docs/16_session_timeout/tickets.md +64 -0
  62. package/docs/17_auto_approve_policy/development_log.md +29 -0
  63. package/docs/17_auto_approve_policy/notes.md +25 -0
  64. package/docs/17_auto_approve_policy/prd.md +34 -0
  65. package/docs/17_auto_approve_policy/questions.md +10 -0
  66. package/docs/17_auto_approve_policy/tickets.md +11 -0
  67. package/docs/18_clawmini_skills/development_log.md +36 -0
  68. package/docs/18_clawmini_skills/notes.md +8 -0
  69. package/docs/18_clawmini_skills/prd.md +45 -0
  70. package/docs/18_clawmini_skills/questions.md +10 -0
  71. package/docs/18_clawmini_skills/tickets.md +55 -0
  72. package/docs/19_subagents/development_log.md +69 -0
  73. package/docs/19_subagents/notes.md +18 -0
  74. package/docs/19_subagents/prd.md +156 -0
  75. package/docs/19_subagents/questions.md +13 -0
  76. package/docs/19_subagents/tickets.md +113 -0
  77. package/docs/20_chat_logs_cleanup/development_log.md +50 -0
  78. package/docs/20_chat_logs_cleanup/notes.md +43 -0
  79. package/docs/20_chat_logs_cleanup/prd.md +232 -0
  80. package/docs/20_chat_logs_cleanup/questions.md +2 -0
  81. package/docs/20_chat_logs_cleanup/tickets.md +98 -0
  82. package/docs/20_webui_markdown/development_log.md +36 -0
  83. package/docs/20_webui_markdown/notes.md +23 -0
  84. package/docs/20_webui_markdown/prd.md +49 -0
  85. package/docs/20_webui_markdown/questions.md +10 -0
  86. package/docs/20_webui_markdown/tickets.md +55 -0
  87. package/docs/21_adapter_filtering/development_log.md +29 -0
  88. package/docs/21_adapter_filtering/notes.md +25 -0
  89. package/docs/21_adapter_filtering/prd.md +44 -0
  90. package/docs/21_adapter_filtering/questions.md +12 -0
  91. package/docs/21_adapter_filtering/tickets.md +38 -0
  92. package/docs/21_built_in_routers/development_log.md +17 -0
  93. package/docs/21_built_in_routers/notes.md +27 -0
  94. package/docs/21_built_in_routers/prd.md +34 -0
  95. package/docs/21_built_in_routers/questions.md +4 -0
  96. package/docs/21_built_in_routers/tickets.md +25 -0
  97. package/docs/21_fancy_policies/development_log.md +38 -0
  98. package/docs/21_fancy_policies/notes.md +27 -0
  99. package/docs/21_fancy_policies/prd.md +58 -0
  100. package/docs/21_fancy_policies/questions.md +6 -0
  101. package/docs/21_fancy_policies/tickets.md +48 -0
  102. package/docs/22_adapter_multi_chat/development_log.md +76 -0
  103. package/docs/22_adapter_multi_chat/notes.md +42 -0
  104. package/docs/22_adapter_multi_chat/prd.md +76 -0
  105. package/docs/22_adapter_multi_chat/questions.md +16 -0
  106. package/docs/22_adapter_multi_chat/tickets.md +164 -0
  107. package/docs/23_custom_token_env/development_log.md +31 -0
  108. package/docs/23_custom_token_env/notes.md +16 -0
  109. package/docs/23_custom_token_env/prd.md +42 -0
  110. package/docs/23_custom_token_env/questions.md +8 -0
  111. package/docs/23_custom_token_env/tickets.md +54 -0
  112. package/docs/guides/discord_adapter_setup.md +15 -2
  113. package/docs/guides/google_chat_adapter_setup.md +145 -0
  114. package/napkin.md +5 -0
  115. package/package.json +7 -2
  116. package/src/adapter-discord/config.test.ts +27 -8
  117. package/src/adapter-discord/config.ts +6 -8
  118. package/src/adapter-discord/forwarder.test.ts +307 -114
  119. package/src/adapter-discord/forwarder.ts +260 -75
  120. package/src/adapter-discord/index.test.ts +278 -0
  121. package/src/adapter-discord/index.ts +160 -30
  122. package/src/adapter-discord/interactions.test.ts +96 -0
  123. package/src/adapter-discord/interactions.ts +156 -0
  124. package/src/adapter-discord/state.test.ts +9 -8
  125. package/src/adapter-discord/state.ts +51 -8
  126. package/src/adapter-google-chat/auth.test.ts +87 -0
  127. package/src/adapter-google-chat/auth.ts +132 -0
  128. package/src/adapter-google-chat/cards.ts +71 -0
  129. package/src/adapter-google-chat/client.test.ts +561 -0
  130. package/src/adapter-google-chat/client.ts +430 -0
  131. package/src/adapter-google-chat/config.test.ts +187 -0
  132. package/src/adapter-google-chat/config.ts +82 -0
  133. package/src/adapter-google-chat/cron.test.ts +143 -0
  134. package/src/adapter-google-chat/cron.ts +81 -0
  135. package/src/adapter-google-chat/forwarder.test.ts +537 -0
  136. package/src/adapter-google-chat/forwarder.ts +349 -0
  137. package/src/adapter-google-chat/index.test.ts +62 -0
  138. package/src/adapter-google-chat/index.ts +61 -0
  139. package/src/adapter-google-chat/state.test.ts +96 -0
  140. package/src/adapter-google-chat/state.ts +85 -0
  141. package/src/adapter-google-chat/subscriptions.ts +124 -0
  142. package/src/adapter-google-chat/upload.ts +88 -0
  143. package/src/adapter-google-chat/utils.test.ts +111 -0
  144. package/src/adapter-google-chat/utils.ts +133 -0
  145. package/src/cli/commands/init.ts +0 -7
  146. package/src/cli/commands/messages.ts +18 -3
  147. package/src/cli/commands/policies.ts +70 -0
  148. package/src/cli/commands/skills.ts +71 -0
  149. package/src/cli/commands/web-api/chats.ts +5 -1
  150. package/src/cli/e2e/basic.test.ts +1 -1
  151. package/src/cli/e2e/cron.test.ts +1 -1
  152. package/src/cli/e2e/daemon.test.ts +132 -4
  153. package/src/cli/e2e/export-lite-func.test.ts +54 -31
  154. package/src/cli/e2e/fallbacks.test.ts +8 -6
  155. package/src/cli/e2e/init.test.ts +7 -0
  156. package/src/cli/e2e/messages.test.ts +90 -55
  157. package/src/cli/e2e/propose-policy.test.ts +203 -0
  158. package/src/cli/e2e/requests.test.ts +15 -0
  159. package/src/cli/e2e/session-timeout.test.ts +192 -0
  160. package/src/cli/e2e/skills.test.ts +55 -0
  161. package/src/cli/e2e/slash-new.test.ts +93 -0
  162. package/src/cli/e2e/subagents.test.ts +106 -0
  163. package/src/cli/index.ts +4 -0
  164. package/src/cli/lite.ts +51 -11
  165. package/src/cli/propose-policy.ts +91 -0
  166. package/src/cli/subagent-commands.ts +215 -0
  167. package/src/daemon/agent/agent-context.ts +89 -0
  168. package/src/daemon/agent/agent-extractors.ts +68 -0
  169. package/src/daemon/agent/agent-runner.ts +153 -0
  170. package/src/daemon/agent/agent-session.ts +261 -0
  171. package/src/daemon/agent/chat-logger.test.ts +158 -0
  172. package/src/daemon/agent/chat-logger.ts +188 -0
  173. package/src/daemon/agent/task-scheduler.test.ts +202 -0
  174. package/src/daemon/agent/task-scheduler.ts +276 -0
  175. package/src/daemon/agent/types.ts +84 -0
  176. package/src/daemon/agent/utils.ts +7 -0
  177. package/src/daemon/api/agent-router.ts +166 -18
  178. package/src/daemon/api/index.test.ts +50 -18
  179. package/src/daemon/api/policy-request.test.ts +39 -2
  180. package/src/daemon/api/subagent-router.test.ts +108 -0
  181. package/src/daemon/api/subagent-router.ts +296 -0
  182. package/src/daemon/api/subagent-utils.test.ts +56 -0
  183. package/src/daemon/api/subagent-utils.ts +130 -0
  184. package/src/daemon/api/user-router.ts +30 -13
  185. package/src/daemon/auth.ts +1 -0
  186. package/src/daemon/chats.ts +6 -0
  187. package/src/daemon/cron.test.ts +66 -1
  188. package/src/daemon/cron.ts +35 -8
  189. package/src/daemon/index.ts +23 -0
  190. package/src/daemon/message-agent.test.ts +11 -25
  191. package/src/daemon/message-extraction.test.ts +10 -27
  192. package/src/daemon/message-fallbacks.test.ts +13 -35
  193. package/src/daemon/message-interruption.test.ts +70 -53
  194. package/src/daemon/message-jobs.test.ts +138 -0
  195. package/src/daemon/message-queue.test.ts +30 -43
  196. package/src/daemon/message-router.test.ts +12 -11
  197. package/src/daemon/message-session.test.ts +41 -28
  198. package/src/daemon/message-typing.test.ts +19 -6
  199. package/src/daemon/message.ts +103 -515
  200. package/src/daemon/policy-request-service.ts +8 -3
  201. package/src/daemon/policy-utils.ts +19 -1
  202. package/src/daemon/queue.ts +16 -0
  203. package/src/daemon/request-store.test.ts +4 -0
  204. package/src/daemon/routers/session-timeout.test.ts +122 -0
  205. package/src/daemon/routers/session-timeout.ts +71 -0
  206. package/src/daemon/routers/slash-new.ts +3 -1
  207. package/src/daemon/routers/slash-policies.test.ts +26 -13
  208. package/src/daemon/routers/slash-policies.ts +39 -29
  209. package/src/daemon/routers/types.ts +8 -0
  210. package/src/daemon/routers.ts +64 -2
  211. package/src/daemon/utils/spawn.ts +6 -8
  212. package/src/shared/adapters/commands.test.ts +155 -0
  213. package/src/shared/adapters/commands.ts +125 -0
  214. package/src/shared/adapters/filtering.test.ts +111 -0
  215. package/src/shared/adapters/filtering.ts +57 -0
  216. package/src/shared/adapters/routing.test.ts +144 -0
  217. package/src/shared/adapters/routing.ts +109 -0
  218. package/src/shared/agent-utils.ts +10 -0
  219. package/src/shared/chats.test.ts +145 -3
  220. package/src/shared/chats.ts +215 -18
  221. package/src/shared/config.ts +67 -15
  222. package/src/shared/lite.ts +22 -18
  223. package/src/shared/policies.ts +7 -0
  224. package/src/shared/workspace.test.ts +45 -1
  225. package/src/shared/workspace.ts +119 -6
  226. package/templates/debug/settings.json +5 -2
  227. package/templates/environments/cladding/env.json +2 -2
  228. package/templates/gemini/.gemini/hooks/check-subagents.mjs +23 -0
  229. package/templates/gemini/.gemini/hooks/clawmini-logging.sh +17 -0
  230. package/templates/gemini/.gemini/hooks/insert-pending.sh +9 -0
  231. package/templates/gemini/.gemini/settings.json +50 -0
  232. package/templates/gemini/settings.json +22 -8
  233. package/templates/gemini-claw/.gemini/base-system.md +100 -0
  234. package/templates/gemini-claw/.gemini/hooks/check-subagents.mjs +23 -0
  235. package/templates/gemini-claw/.gemini/hooks/clawmini-logging.sh +1 -1
  236. package/templates/gemini-claw/.gemini/settings.json +13 -0
  237. package/templates/gemini-claw/.gemini/subagent-system.md +7 -0
  238. package/templates/gemini-claw/.gemini/system.md +3 -99
  239. package/templates/gemini-claw/settings.json +27 -22
  240. package/templates/skills/clawmini-requests/SKILL.md +92 -0
  241. package/templates/skills/clawmini-subagents/SKILL.md +79 -0
  242. package/templates/skills/skill-creator/SKILL.md +60 -0
  243. package/tsdown.config.ts +10 -1
  244. package/web/.svelte-kit/generated/server/internal.js +2 -1
  245. package/web/.svelte-kit/non-ambient.d.ts +2 -0
  246. package/web/.svelte-kit/output/client/.vite/manifest.json +141 -138
  247. package/web/.svelte-kit/output/client/_app/immutable/assets/0.C-4eziNy.css +1 -0
  248. package/web/.svelte-kit/output/client/_app/immutable/assets/4.Cc_xwLNl.css +1 -0
  249. package/web/.svelte-kit/output/client/_app/immutable/chunks/B6YN0Nuq.js +1 -0
  250. package/web/.svelte-kit/output/client/_app/immutable/chunks/{Dc-UOHw9.js → BmRlVmv6.js} +1 -1
  251. package/{dist/web/_app/immutable/chunks/8YNcRyEk.js → web/.svelte-kit/output/client/_app/immutable/chunks/C20lZMGz.js} +1 -1
  252. package/web/.svelte-kit/output/client/_app/immutable/chunks/C9lbZ-kT.js +1 -0
  253. package/web/.svelte-kit/output/client/_app/immutable/chunks/CK9JZLaG.js +2 -0
  254. package/web/.svelte-kit/output/client/_app/immutable/chunks/CME08kGM.js +1 -0
  255. package/web/.svelte-kit/output/client/_app/immutable/chunks/{BPy8HLo7.js → Ck-be5J2.js} +1 -1
  256. package/web/.svelte-kit/output/client/_app/immutable/chunks/Ck3rYNON.js +1 -0
  257. package/web/.svelte-kit/output/client/_app/immutable/chunks/DMtIqaiV.js +2 -0
  258. package/web/.svelte-kit/output/client/_app/immutable/chunks/{B8yYFADm.js → DhD271EB.js} +1 -1
  259. package/web/.svelte-kit/output/client/_app/immutable/chunks/{DcrmIfTj.js → DpuLqk8d.js} +1 -1
  260. package/web/.svelte-kit/output/client/_app/immutable/chunks/{ZkLyk0mE.js → Drm9vgeP.js} +1 -1
  261. package/web/.svelte-kit/output/client/_app/immutable/chunks/DsIToJCP.js +1 -0
  262. package/web/.svelte-kit/output/client/_app/immutable/chunks/{CyNaE55B.js → Zeh-C-mx.js} +1 -1
  263. package/{dist/web/_app/immutable/entry/app.DO5eYwVz.js → web/.svelte-kit/output/client/_app/immutable/entry/app.BgB5VkRU.js} +2 -2
  264. package/web/.svelte-kit/output/client/_app/immutable/entry/start.DuxJo6av.js +1 -0
  265. package/web/.svelte-kit/output/client/_app/immutable/nodes/0.C9oFZP9h.js +1 -0
  266. package/web/.svelte-kit/output/client/_app/immutable/nodes/1.BON2Wk6k.js +1 -0
  267. package/web/.svelte-kit/output/client/_app/immutable/nodes/{2.CK3CLC0f.js → 2.BnwnD1Ki.js} +1 -1
  268. package/web/.svelte-kit/output/client/_app/immutable/nodes/{3.ncP0xLO6.js → 3.CIs4tjjw.js} +1 -1
  269. package/web/.svelte-kit/output/client/_app/immutable/nodes/4.DLarELN4.js +60 -0
  270. package/web/.svelte-kit/output/client/_app/immutable/nodes/{5.BpJUN6QH.js → 5.CE_QKy_3.js} +1 -1
  271. package/web/.svelte-kit/output/client/_app/version.json +1 -1
  272. package/web/.svelte-kit/output/server/.vite/manifest.json +12 -3
  273. package/web/.svelte-kit/output/server/_app/immutable/assets/_layout.C-4eziNy.css +1 -0
  274. package/web/.svelte-kit/output/server/_app/immutable/assets/_page.Cc_xwLNl.css +1 -0
  275. package/web/.svelte-kit/output/server/chunks/app-state.svelte.js +5 -0
  276. package/web/.svelte-kit/output/server/chunks/bot.js +4 -4
  277. package/web/.svelte-kit/output/server/chunks/client.js +2 -1
  278. package/web/.svelte-kit/output/server/chunks/exports.js +0 -1
  279. package/web/.svelte-kit/output/server/chunks/internal.js +2 -1
  280. package/web/.svelte-kit/output/server/chunks/root.js +482 -392
  281. package/web/.svelte-kit/output/server/entries/pages/_layout.svelte.js +57 -7
  282. package/web/.svelte-kit/output/server/entries/pages/chats/_id_/_page.svelte.js +234 -9
  283. package/web/.svelte-kit/output/server/index.js +82 -10
  284. package/web/.svelte-kit/output/server/manifest-full.js +1 -1
  285. package/web/.svelte-kit/output/server/manifest.js +1 -1
  286. package/web/.svelte-kit/output/server/nodes/0.js +2 -2
  287. package/web/.svelte-kit/output/server/nodes/1.js +1 -1
  288. package/web/.svelte-kit/output/server/nodes/2.js +1 -1
  289. package/web/.svelte-kit/output/server/nodes/3.js +1 -1
  290. package/web/.svelte-kit/output/server/nodes/4.js +2 -2
  291. package/web/.svelte-kit/output/server/nodes/5.js +1 -1
  292. package/web/.svelte-kit/types/src/routes/$types.d.ts +1 -2
  293. package/web/.svelte-kit/types/src/routes/agents/$types.d.ts +1 -2
  294. package/web/.svelte-kit/types/src/routes/chats/[id]/$types.d.ts +1 -2
  295. package/web/.svelte-kit/types/src/routes/chats/[id]/settings/$types.d.ts +1 -2
  296. package/web/package.json +8 -0
  297. package/web/src/lib/app-state.svelte.ts +5 -1
  298. package/web/src/lib/components/app/markdown-renderer.svelte +56 -0
  299. package/web/src/lib/components/app/markdown-renderer.svelte.spec.ts +44 -0
  300. package/web/src/lib/components/app/message-content.svelte +16 -0
  301. package/web/src/lib/types.ts +67 -3
  302. package/web/src/routes/+layout.svelte +31 -1
  303. package/web/src/routes/chats/[id]/+page.svelte +167 -18
  304. package/web/src/routes/chats/[id]/page.svelte.spec.ts +58 -7
  305. package/dist/lite-oSYSvaOr.mjs.map +0 -1
  306. package/dist/web/_app/immutable/assets/0.GI4C4dpV.css +0 -1
  307. package/dist/web/_app/immutable/chunks/B5abRDXp.js +0 -1
  308. package/dist/web/_app/immutable/chunks/Bi0jeV7Q.js +0 -1
  309. package/dist/web/_app/immutable/chunks/BmUXQ3wy.js +0 -2
  310. package/dist/web/_app/immutable/chunks/C3k55nDF.js +0 -1
  311. package/dist/web/_app/immutable/chunks/CpaGRn9L.js +0 -1
  312. package/dist/web/_app/immutable/chunks/DG5RZBw-.js +0 -2
  313. package/dist/web/_app/immutable/chunks/DQoygso7.js +0 -1
  314. package/dist/web/_app/immutable/entry/start.D48mVn1m.js +0 -1
  315. package/dist/web/_app/immutable/nodes/0.B-0CcADM.js +0 -1
  316. package/dist/web/_app/immutable/nodes/1.FixKgvRO.js +0 -1
  317. package/dist/web/_app/immutable/nodes/4.CQYJEgv8.js +0 -1
  318. package/dist/workspace-DjoNjhW0.mjs.map +0 -1
  319. package/src/daemon/message-verbosity.test.ts +0 -127
  320. package/web/.svelte-kit/output/client/_app/immutable/assets/0.GI4C4dpV.css +0 -1
  321. package/web/.svelte-kit/output/client/_app/immutable/chunks/B5abRDXp.js +0 -1
  322. package/web/.svelte-kit/output/client/_app/immutable/chunks/Bi0jeV7Q.js +0 -1
  323. package/web/.svelte-kit/output/client/_app/immutable/chunks/BmUXQ3wy.js +0 -2
  324. package/web/.svelte-kit/output/client/_app/immutable/chunks/C3k55nDF.js +0 -1
  325. package/web/.svelte-kit/output/client/_app/immutable/chunks/CpaGRn9L.js +0 -1
  326. package/web/.svelte-kit/output/client/_app/immutable/chunks/DG5RZBw-.js +0 -2
  327. package/web/.svelte-kit/output/client/_app/immutable/chunks/DQoygso7.js +0 -1
  328. package/web/.svelte-kit/output/client/_app/immutable/entry/start.D48mVn1m.js +0 -1
  329. package/web/.svelte-kit/output/client/_app/immutable/nodes/0.B-0CcADM.js +0 -1
  330. package/web/.svelte-kit/output/client/_app/immutable/nodes/1.FixKgvRO.js +0 -1
  331. package/web/.svelte-kit/output/client/_app/immutable/nodes/4.CQYJEgv8.js +0 -1
  332. package/web/.svelte-kit/output/server/_app/immutable/assets/_layout.GI4C4dpV.css +0 -1
  333. /package/templates/{gemini-claw/.gemini/skills → skills}/clawmini-jobs/SKILL.md +0 -0
@@ -0,0 +1,561 @@
1
+ import { describe, it, expect, vi, beforeEach } from 'vitest';
2
+ import { getTRPCClient, startGoogleChatIngestion } from './client.js';
3
+ import fs from 'node:fs';
4
+ import fsPromises from 'node:fs/promises';
5
+ import * as workspace from '../shared/workspace.js';
6
+ import { createTRPCClient } from '@trpc/client';
7
+ import * as utils from './utils.js';
8
+
9
+ vi.mock('node:fs');
10
+ vi.mock('./state.js', () => ({
11
+ readGoogleChatState: vi.fn().mockResolvedValue({
12
+ channelChatMap: { 'spaces/123': { chatId: 'default' } },
13
+ activeSpaceName: 'spaces/123',
14
+ }),
15
+ updateGoogleChatState: vi.fn().mockResolvedValue(undefined),
16
+ }));
17
+ vi.mock('node:fs/promises', () => ({
18
+ default: {
19
+ mkdir: vi.fn().mockResolvedValue(undefined),
20
+ writeFile: vi.fn().mockResolvedValue(undefined),
21
+ unlink: vi.fn().mockResolvedValue(undefined),
22
+ },
23
+ }));
24
+ vi.mock('../shared/workspace.js');
25
+ vi.mock('@trpc/client', () => ({
26
+ createTRPCClient: vi.fn().mockReturnValue({
27
+ ping: {
28
+ query: vi.fn().mockResolvedValue({ status: 'ok' }),
29
+ },
30
+ getChats: {
31
+ query: vi.fn().mockResolvedValue(['default', 'chat-1']),
32
+ },
33
+ getAgents: {
34
+ query: vi.fn().mockResolvedValue(['agent-1']),
35
+ },
36
+ sendMessage: {
37
+ mutate: vi.fn().mockResolvedValue({}),
38
+ },
39
+ }),
40
+ httpLink: vi.fn(),
41
+ splitLink: vi.fn(),
42
+ httpSubscriptionLink: vi.fn(),
43
+ }));
44
+ vi.mock('../shared/fetch.js', () => ({
45
+ createUnixSocketFetch: vi.fn(),
46
+ }));
47
+ vi.mock('./auth.js', () => ({
48
+ getAuthClient: vi.fn().mockResolvedValue({}),
49
+ getUserAuthClient: vi.fn().mockResolvedValue({
50
+ getAccessToken: vi.fn().mockResolvedValue({ token: 'mock-token' }),
51
+ }),
52
+ }));
53
+
54
+ const { mockSubscription } = vi.hoisted(() => ({
55
+ mockSubscription: {
56
+ on: vi.fn(),
57
+ },
58
+ }));
59
+
60
+ vi.mock('googleapis', () => ({
61
+ google: {
62
+ chat: vi.fn().mockReturnValue({
63
+ spaces: {
64
+ messages: {
65
+ create: vi.fn().mockResolvedValue({}),
66
+ update: vi.fn().mockResolvedValue({}),
67
+ list: vi.fn().mockResolvedValue({ data: { messages: [] } }),
68
+ },
69
+ },
70
+ }),
71
+ },
72
+ }));
73
+
74
+ vi.mock('@google-cloud/pubsub', () => {
75
+ return {
76
+ PubSub: class {
77
+ subscription = vi.fn().mockReturnValue(mockSubscription);
78
+ },
79
+ };
80
+ });
81
+ vi.mock('./utils.js', () => ({
82
+ downloadAttachment: vi.fn().mockResolvedValue(Buffer.from('mock-data')),
83
+ }));
84
+
85
+ describe('Google Chat Adapter Client', () => {
86
+ beforeEach(() => {
87
+ vi.clearAllMocks();
88
+ });
89
+
90
+ describe('getTRPCClient', () => {
91
+ it('should throw error if daemon socket does not exist', () => {
92
+ vi.mocked(workspace.getSocketPath).mockReturnValue('/tmp/test.sock');
93
+ vi.mocked(fs.existsSync).mockReturnValue(false);
94
+
95
+ expect(() => getTRPCClient()).toThrow(
96
+ 'Daemon not running. Socket not found at /tmp/test.sock'
97
+ );
98
+ });
99
+
100
+ it('should create TRPC client if daemon socket exists', () => {
101
+ vi.mocked(workspace.getSocketPath).mockReturnValue('/tmp/test.sock');
102
+ vi.mocked(fs.existsSync).mockReturnValue(true);
103
+
104
+ const client = getTRPCClient();
105
+ expect(client).toBeDefined();
106
+ expect(createTRPCClient).toHaveBeenCalled();
107
+ });
108
+ });
109
+
110
+ describe('startGoogleChatIngestion', () => {
111
+ let trpcClient: ReturnType<typeof getTRPCClient>;
112
+
113
+ beforeEach(() => {
114
+ vi.mocked(workspace.getSocketPath).mockReturnValue('/tmp/test.sock');
115
+ vi.mocked(workspace.getClawminiDir).mockReturnValue('/mock/dir');
116
+ vi.mocked(fs.existsSync).mockReturnValue(true);
117
+ trpcClient = getTRPCClient();
118
+
119
+ startGoogleChatIngestion(
120
+ {
121
+ projectId: 'test-project',
122
+ subscriptionName: 'test-sub',
123
+ topicName: 'test-topic',
124
+ authorizedUsers: ['user@example.com'],
125
+ requireMention: false,
126
+ maxAttachmentSizeMB: 25,
127
+ directMessageName: 'spaces/123',
128
+ },
129
+ trpcClient,
130
+ {}
131
+ );
132
+ });
133
+
134
+ it('should ignore non-MESSAGE events', async () => {
135
+ const onMessage = mockSubscription.on.mock.calls.find(
136
+ (c: unknown[]) => c[0] === 'message'
137
+ )![1] as (msg: unknown) => Promise<void>;
138
+ const mockMsg = {
139
+ data: Buffer.from(JSON.stringify({ type: 'UNKNOWN_EVENT' })),
140
+ ack: vi.fn(),
141
+ nack: vi.fn(),
142
+ };
143
+ await onMessage(mockMsg);
144
+
145
+ expect(mockMsg.ack).toHaveBeenCalled();
146
+ expect(trpcClient.sendMessage.mutate).not.toHaveBeenCalled();
147
+ });
148
+
149
+ it('should create subscription on ADDED_TO_SPACE for non-DM spaces', async () => {
150
+ const onMessage = mockSubscription.on.mock.calls.find(
151
+ (c: unknown[]) => c[0] === 'message'
152
+ )![1] as (msg: unknown) => Promise<void>;
153
+
154
+ const mockFetch = vi.fn().mockResolvedValue({
155
+ ok: true,
156
+ json: vi
157
+ .fn()
158
+ .mockResolvedValue({ name: 'subscriptions/123', expireTime: '2026-01-01T00:00:00Z' }),
159
+ });
160
+ globalThis.fetch = mockFetch;
161
+
162
+ const mockMsg = {
163
+ data: Buffer.from(
164
+ JSON.stringify({
165
+ type: 'ADDED_TO_SPACE',
166
+ space: { name: 'spaces/new-space', type: 'SPACE' },
167
+ user: { email: 'user@example.com' },
168
+ })
169
+ ),
170
+ ack: vi.fn(),
171
+ nack: vi.fn(),
172
+ };
173
+
174
+ const { updateGoogleChatState } = await import('./state.js');
175
+ vi.mocked(updateGoogleChatState).mockClear();
176
+
177
+ await onMessage(mockMsg);
178
+
179
+ expect(mockFetch).toHaveBeenCalledWith(
180
+ 'https://workspaceevents.googleapis.com/v1/subscriptions',
181
+ expect.objectContaining({ method: 'POST' })
182
+ );
183
+
184
+ expect(updateGoogleChatState).toHaveBeenCalled();
185
+ expect(mockMsg.ack).toHaveBeenCalled();
186
+ });
187
+
188
+ it('should delete subscription and update state on REMOVED_FROM_SPACE', async () => {
189
+ const onMessage = mockSubscription.on.mock.calls.find(
190
+ (c: unknown[]) => c[0] === 'message'
191
+ )![1] as (msg: unknown) => Promise<void>;
192
+
193
+ const mockFetch = vi.fn().mockResolvedValue({ ok: true });
194
+ globalThis.fetch = mockFetch;
195
+
196
+ // Ensure state has the subscription
197
+ const { readGoogleChatState } = await import('./state.js');
198
+ vi.mocked(readGoogleChatState).mockResolvedValueOnce({
199
+ channelChatMap: {
200
+ 'spaces/removed': { chatId: 'chat1', subscriptionId: 'subscriptions/456' },
201
+ },
202
+ });
203
+
204
+ const mockMsg = {
205
+ data: Buffer.from(
206
+ JSON.stringify({
207
+ type: 'REMOVED_FROM_SPACE',
208
+ space: { name: 'spaces/removed', type: 'SPACE' },
209
+ user: { email: 'user@example.com' },
210
+ })
211
+ ),
212
+ ack: vi.fn(),
213
+ nack: vi.fn(),
214
+ };
215
+
216
+ const { updateGoogleChatState } = await import('./state.js');
217
+ vi.mocked(updateGoogleChatState).mockClear();
218
+
219
+ await onMessage(mockMsg);
220
+
221
+ expect(mockFetch).toHaveBeenCalledWith(
222
+ 'https://workspaceevents.googleapis.com/v1/subscriptions/456',
223
+ expect.objectContaining({ method: 'DELETE' })
224
+ );
225
+
226
+ expect(updateGoogleChatState).toHaveBeenCalled();
227
+ expect(mockMsg.ack).toHaveBeenCalled();
228
+ });
229
+
230
+ it('should assign object shape when mapping chat on routing command', async () => {
231
+ const onMessage = mockSubscription.on.mock.calls.find(
232
+ (c: unknown[]) => c[0] === 'message'
233
+ )![1] as (msg: unknown) => Promise<void>;
234
+
235
+ const { updateGoogleChatState } = await import('./state.js');
236
+ vi.mocked(updateGoogleChatState).mockClear();
237
+
238
+ const mockMsg = {
239
+ data: Buffer.from(
240
+ JSON.stringify({
241
+ type: 'MESSAGE',
242
+ space: { name: 'spaces/new-space', type: 'SPACE' },
243
+ user: { email: 'user@example.com' },
244
+ message: { text: '/chat chat-1' },
245
+ })
246
+ ),
247
+ ack: vi.fn(),
248
+ nack: vi.fn(),
249
+ };
250
+
251
+ await onMessage(mockMsg);
252
+
253
+ expect(mockMsg.ack).toHaveBeenCalled();
254
+
255
+ const updateCalls = vi.mocked(updateGoogleChatState).mock.calls;
256
+ const lastCallArg = updateCalls[updateCalls.length - 1]![0];
257
+ const result =
258
+ typeof lastCallArg === 'function'
259
+ ? lastCallArg({ channelChatMap: {} } as import('./state.js').GoogleChatState)
260
+ : lastCallArg;
261
+
262
+ expect(result.channelChatMap!['spaces/new-space']).toEqual({ chatId: 'chat-1' });
263
+ });
264
+
265
+ it('should ignore messages from unauthorized users', async () => {
266
+ const onMessage = mockSubscription.on.mock.calls.find(
267
+ (c: unknown[]) => c[0] === 'message'
268
+ )![1] as (msg: unknown) => Promise<void>;
269
+ const mockMsg = {
270
+ data: Buffer.from(
271
+ JSON.stringify({
272
+ type: 'MESSAGE',
273
+ space: { name: 'spaces/123', type: 'DIRECT_MESSAGE', singleUserBotDm: true },
274
+ message: { sender: { email: 'bad@example.com' }, text: 'Hello' },
275
+ })
276
+ ),
277
+ ack: vi.fn(),
278
+ nack: vi.fn(),
279
+ };
280
+ await onMessage(mockMsg);
281
+
282
+ expect(mockMsg.ack).toHaveBeenCalled();
283
+ expect(trpcClient.sendMessage.mutate).not.toHaveBeenCalled();
284
+ });
285
+
286
+ it('should process authorized messages without attachments', async () => {
287
+ const onMessage = mockSubscription.on.mock.calls.find(
288
+ (c: unknown[]) => c[0] === 'message'
289
+ )![1] as (msg: unknown) => Promise<void>;
290
+ const mockMsg = {
291
+ data: Buffer.from(
292
+ JSON.stringify({
293
+ type: 'MESSAGE',
294
+ space: { name: 'spaces/123', type: 'DIRECT_MESSAGE', singleUserBotDm: true },
295
+ message: {
296
+ sender: { email: 'user@example.com' },
297
+ text: 'Hello world',
298
+ thread: { name: 'thread-123' },
299
+ },
300
+ })
301
+ ),
302
+ ack: vi.fn(),
303
+ nack: vi.fn(),
304
+ };
305
+ await onMessage(mockMsg);
306
+
307
+ expect(mockMsg.ack).toHaveBeenCalled();
308
+ expect(trpcClient.sendMessage.mutate).toHaveBeenCalledWith({
309
+ type: 'send-message',
310
+ client: 'cli',
311
+ data: {
312
+ message: 'Hello world',
313
+ chatId: 'default',
314
+ adapter: 'google-chat',
315
+ files: undefined,
316
+ noWait: true,
317
+ },
318
+ });
319
+ });
320
+
321
+ it('should process authorized messages with attachments', async () => {
322
+ const onMessage = mockSubscription.on.mock.calls.find(
323
+ (c: unknown[]) => c[0] === 'message'
324
+ )![1] as (msg: unknown) => Promise<void>;
325
+ const mockMsg = {
326
+ data: Buffer.from(
327
+ JSON.stringify({
328
+ type: 'MESSAGE',
329
+ space: { name: 'spaces/123', type: 'DIRECT_MESSAGE', singleUserBotDm: true },
330
+ message: {
331
+ sender: { email: 'user@example.com' },
332
+ text: 'Here is a file',
333
+ thread: { name: 'thread-123' },
334
+ attachment: [
335
+ {
336
+ contentName: 'test.png',
337
+ attachmentDataRef: { resourceName: 'spaces/123/messages/123/attachments/123' },
338
+ },
339
+ ],
340
+ },
341
+ })
342
+ ),
343
+ ack: vi.fn(),
344
+ nack: vi.fn(),
345
+ };
346
+ await onMessage(mockMsg);
347
+
348
+ expect(utils.downloadAttachment).toHaveBeenCalledWith(
349
+ 'spaces/123/messages/123/attachments/123',
350
+ 25
351
+ );
352
+ expect(fsPromises.mkdir).toHaveBeenCalledWith('/mock/dir/tmp/google-chat', {
353
+ recursive: true,
354
+ });
355
+ expect(fsPromises.writeFile).toHaveBeenCalled();
356
+
357
+ expect(mockMsg.ack).toHaveBeenCalled();
358
+ expect(trpcClient.sendMessage.mutate).toHaveBeenCalledWith(
359
+ expect.objectContaining({
360
+ type: 'send-message',
361
+ data: expect.objectContaining({
362
+ message: 'Here is a file',
363
+ chatId: 'default',
364
+ files: expect.any(Array),
365
+ adapter: 'google-chat',
366
+ noWait: true,
367
+ }),
368
+ })
369
+ );
370
+ });
371
+
372
+ it('should nack the message on unexpected error', async () => {
373
+ const onMessage = mockSubscription.on.mock.calls.find(
374
+ (c: unknown[]) => c[0] === 'message'
375
+ )![1] as (msg: unknown) => Promise<void>;
376
+ const mockMsg = {
377
+ data: Buffer.from(
378
+ JSON.stringify({
379
+ type: 'MESSAGE',
380
+ space: { name: 'spaces/123', type: 'DIRECT_MESSAGE', singleUserBotDm: true },
381
+ })
382
+ ),
383
+ ack: vi.fn(),
384
+ nack: vi.fn(),
385
+ };
386
+
387
+ // Force an error
388
+ vi.mocked(trpcClient.sendMessage.mutate).mockRejectedValueOnce(new Error('Network error'));
389
+
390
+ const authorizedMockMsg = {
391
+ ...mockMsg,
392
+ data: Buffer.from(
393
+ JSON.stringify({
394
+ type: 'MESSAGE',
395
+ space: { name: 'spaces/123', type: 'DIRECT_MESSAGE', singleUserBotDm: true },
396
+ message: {
397
+ sender: { email: 'user@example.com' },
398
+ text: 'Hello with error',
399
+ attachment: [
400
+ {
401
+ contentName: 'test.png',
402
+ attachmentDataRef: { resourceName: 'spaces/123/messages/123/attachments/123' },
403
+ },
404
+ ],
405
+ },
406
+ })
407
+ ),
408
+ };
409
+
410
+ await onMessage(authorizedMockMsg);
411
+
412
+ expect(authorizedMockMsg.nack).toHaveBeenCalled();
413
+ expect(authorizedMockMsg.ack).not.toHaveBeenCalled();
414
+ expect(fsPromises.unlink).toHaveBeenCalled();
415
+ });
416
+
417
+ it('should process Workspace Events properly', async () => {
418
+ const onMessage = mockSubscription.on.mock.calls.find(
419
+ (c: unknown[]) => c[0] === 'message'
420
+ )![1] as (msg: unknown) => Promise<void>;
421
+ const mockMsg = {
422
+ attributes: { 'ce-type': 'google.workspace.chat.message.v1.created' },
423
+ data: Buffer.from(
424
+ JSON.stringify({
425
+ message: {
426
+ name: 'spaces/123/messages/workspace-event',
427
+ sender: { email: 'user@example.com', type: 'USER' },
428
+ space: { name: 'spaces/123', type: 'DIRECT_MESSAGE', singleUserBotDm: true },
429
+ text: 'Hello from Workspace Event',
430
+ },
431
+ })
432
+ ),
433
+ ack: vi.fn(),
434
+ nack: vi.fn(),
435
+ };
436
+ await onMessage(mockMsg);
437
+
438
+ expect(mockMsg.ack).toHaveBeenCalled();
439
+ expect(trpcClient.sendMessage.mutate).toHaveBeenCalledWith(
440
+ expect.objectContaining({
441
+ type: 'send-message',
442
+ data: expect.objectContaining({
443
+ message: 'Hello from Workspace Event',
444
+ chatId: 'default',
445
+ }),
446
+ })
447
+ );
448
+ });
449
+
450
+ it('should drop duplicate messages within 60 seconds based on Message ID', async () => {
451
+ const onMessage = mockSubscription.on.mock.calls.find(
452
+ (c: unknown[]) => c[0] === 'message'
453
+ )![1] as (msg: unknown) => Promise<void>;
454
+ const mockMsg1 = {
455
+ data: Buffer.from(
456
+ JSON.stringify({
457
+ type: 'MESSAGE',
458
+ space: { name: 'spaces/123', type: 'DIRECT_MESSAGE', singleUserBotDm: true },
459
+ message: {
460
+ name: 'spaces/123/messages/duplicate-123',
461
+ sender: { email: 'user@example.com', type: 'USER' },
462
+ text: 'First message',
463
+ },
464
+ })
465
+ ),
466
+ ack: vi.fn(),
467
+ nack: vi.fn(),
468
+ };
469
+ await onMessage(mockMsg1);
470
+
471
+ const mockMsg2 = {
472
+ data: Buffer.from(
473
+ JSON.stringify({
474
+ type: 'MESSAGE',
475
+ space: { name: 'spaces/123', type: 'DIRECT_MESSAGE', singleUserBotDm: true },
476
+ message: {
477
+ name: 'spaces/123/messages/duplicate-123',
478
+ sender: { email: 'user@example.com', type: 'USER' },
479
+ text: 'Second message with same id',
480
+ },
481
+ })
482
+ ),
483
+ ack: vi.fn(),
484
+ nack: vi.fn(),
485
+ };
486
+ await onMessage(mockMsg2);
487
+
488
+ // The second message should be acked immediately but not sent to daemon
489
+ expect(mockMsg2.ack).toHaveBeenCalled();
490
+
491
+ // Mutate should have only been called once for the first message
492
+ expect(trpcClient.sendMessage.mutate).toHaveBeenCalledTimes(1);
493
+ });
494
+
495
+ it('should drop messages where sender type is BOT', async () => {
496
+ const onMessage = mockSubscription.on.mock.calls.find(
497
+ (c: unknown[]) => c[0] === 'message'
498
+ )![1] as (msg: unknown) => Promise<void>;
499
+ const mockMsg = {
500
+ data: Buffer.from(
501
+ JSON.stringify({
502
+ type: 'MESSAGE',
503
+ space: { name: 'spaces/123', type: 'DIRECT_MESSAGE', singleUserBotDm: true },
504
+ message: {
505
+ name: 'spaces/123/messages/bot-msg',
506
+ sender: { email: 'bot@example.com', type: 'BOT' },
507
+ text: 'I am a bot',
508
+ },
509
+ })
510
+ ),
511
+ ack: vi.fn(),
512
+ nack: vi.fn(),
513
+ };
514
+ await onMessage(mockMsg);
515
+
516
+ expect(mockMsg.ack).toHaveBeenCalled();
517
+ // mutate should not have been called because it's a BOT
518
+ expect(trpcClient.sendMessage.mutate).not.toHaveBeenCalled();
519
+ });
520
+
521
+ it('should bypass requireMention if the message is a thread reply to the bot', async () => {
522
+ const onMessage = mockSubscription.on.mock.calls.find(
523
+ (c: unknown[]) => c[0] === 'message'
524
+ )![1] as (msg: unknown) => Promise<void>;
525
+
526
+ const { readGoogleChatState } = await import('./state.js');
527
+ vi.mocked(readGoogleChatState).mockResolvedValue({
528
+ channelChatMap: { 'spaces/123': { chatId: 'default', requireMention: true } },
529
+ });
530
+
531
+ // Override the list mock for this test
532
+ const { google } = await import('googleapis');
533
+
534
+ vi.mocked(google.chat({ version: 'v1' }).spaces.messages.list).mockResolvedValueOnce({
535
+ data: { messages: [{ sender: { type: 'BOT' } }] },
536
+ } as any);
537
+
538
+ const mockMsg = {
539
+ data: Buffer.from(
540
+ JSON.stringify({
541
+ type: 'MESSAGE',
542
+ space: { name: 'spaces/123', type: 'SPACE' },
543
+ user: { email: 'user@example.com' },
544
+ message: {
545
+ name: 'spaces/123/messages/reply-msg',
546
+ text: 'This is a thread reply without mention',
547
+ threadReply: true,
548
+ thread: { name: 'spaces/123/threads/456' },
549
+ },
550
+ })
551
+ ),
552
+ ack: vi.fn(),
553
+ nack: vi.fn(),
554
+ };
555
+ await onMessage(mockMsg);
556
+
557
+ expect(mockMsg.ack).toHaveBeenCalled();
558
+ expect(trpcClient.sendMessage.mutate).toHaveBeenCalled();
559
+ });
560
+ });
561
+ });