konoha-mcp 2.1.16 → 2.1.17

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 (246) hide show
  1. package/.agents/SOUL.md +1 -1
  2. package/.agents/skills/konoha/SKILL.md +30 -1
  3. package/.agents/skills.fingerprint +1 -1
  4. package/README.md +186 -219
  5. package/apps/web/build/adapter-node.js +1 -1
  6. package/apps/web/build/client/_app/immutable/assets/0.BGEsEaMd.css +2 -0
  7. package/apps/web/build/client/_app/immutable/assets/0.BGEsEaMd.css.br +0 -0
  8. package/apps/web/build/client/_app/immutable/assets/0.BGEsEaMd.css.gz +0 -0
  9. package/apps/web/build/client/_app/immutable/chunks/{D-Kujhko.js → 2WlqNq2Q.js} +1 -1
  10. package/apps/web/build/client/_app/immutable/chunks/2WlqNq2Q.js.br +0 -0
  11. package/apps/web/build/client/_app/immutable/chunks/2WlqNq2Q.js.gz +0 -0
  12. package/apps/web/build/client/_app/immutable/chunks/B9vY64pH.js +1 -0
  13. package/apps/web/build/client/_app/immutable/chunks/B9vY64pH.js.br +0 -0
  14. package/apps/web/build/client/_app/immutable/chunks/B9vY64pH.js.gz +0 -0
  15. package/apps/web/build/client/_app/immutable/chunks/{Dzm74gVd.js → BPX4jQ9l.js} +1 -1
  16. package/apps/web/build/client/_app/immutable/chunks/BPX4jQ9l.js.br +2 -0
  17. package/apps/web/build/client/_app/immutable/chunks/BPX4jQ9l.js.gz +0 -0
  18. package/apps/web/build/client/_app/immutable/chunks/{fbrtLByB.js → BXssplIZ.js} +1 -1
  19. package/apps/web/build/client/_app/immutable/chunks/BXssplIZ.js.br +0 -0
  20. package/apps/web/build/client/_app/immutable/chunks/BXssplIZ.js.gz +0 -0
  21. package/apps/web/build/client/_app/immutable/chunks/C-3vSv0T.js +1 -0
  22. package/apps/web/build/client/_app/immutable/chunks/C-3vSv0T.js.br +2 -0
  23. package/apps/web/build/client/_app/immutable/chunks/C-3vSv0T.js.gz +0 -0
  24. package/apps/web/build/client/_app/immutable/chunks/{PrdhfbrQ.js → C7jhkUmC.js} +1 -1
  25. package/apps/web/build/client/_app/immutable/chunks/C7jhkUmC.js.br +0 -0
  26. package/apps/web/build/client/_app/immutable/chunks/{PrdhfbrQ.js.gz → C7jhkUmC.js.gz} +0 -0
  27. package/apps/web/build/client/_app/immutable/chunks/{7LmsTWIo.js → CfrhQlXt.js} +1 -1
  28. package/apps/web/build/client/_app/immutable/chunks/CfrhQlXt.js.br +0 -0
  29. package/apps/web/build/client/_app/immutable/chunks/CfrhQlXt.js.gz +0 -0
  30. package/apps/web/build/client/_app/immutable/chunks/CgzsRqh3.js +1 -0
  31. package/apps/web/build/client/_app/immutable/chunks/CgzsRqh3.js.br +1 -0
  32. package/apps/web/build/client/_app/immutable/chunks/CgzsRqh3.js.gz +0 -0
  33. package/apps/web/build/client/_app/immutable/chunks/ChmznE4L.js +2 -0
  34. package/apps/web/build/client/_app/immutable/chunks/ChmznE4L.js.br +0 -0
  35. package/apps/web/build/client/_app/immutable/chunks/ChmznE4L.js.gz +0 -0
  36. package/apps/web/build/client/_app/immutable/entry/app.cdLMQHsN.js +2 -0
  37. package/apps/web/build/client/_app/immutable/entry/app.cdLMQHsN.js.br +0 -0
  38. package/apps/web/build/client/_app/immutable/entry/app.cdLMQHsN.js.gz +0 -0
  39. package/apps/web/build/client/_app/immutable/entry/{start.CNV5BTCO.js → start.CJ1ccVCA.js} +2 -2
  40. package/apps/web/build/client/_app/immutable/entry/start.CJ1ccVCA.js.br +0 -0
  41. package/apps/web/build/client/_app/immutable/entry/start.CJ1ccVCA.js.gz +0 -0
  42. package/apps/web/build/client/_app/immutable/nodes/0.ijG9ltjt.js +2 -0
  43. package/apps/web/build/client/_app/immutable/nodes/0.ijG9ltjt.js.br +0 -0
  44. package/apps/web/build/client/_app/immutable/nodes/0.ijG9ltjt.js.gz +0 -0
  45. package/apps/web/build/client/_app/immutable/nodes/1.i6MXc2Yb.js +1 -0
  46. package/apps/web/build/client/_app/immutable/nodes/1.i6MXc2Yb.js.br +2 -0
  47. package/apps/web/build/client/_app/immutable/nodes/1.i6MXc2Yb.js.gz +0 -0
  48. package/apps/web/build/client/_app/immutable/nodes/10.B0F7UoZ4.js +1 -0
  49. package/apps/web/build/client/_app/immutable/nodes/10.B0F7UoZ4.js.br +0 -0
  50. package/apps/web/build/client/_app/immutable/nodes/10.B0F7UoZ4.js.gz +0 -0
  51. package/apps/web/build/client/_app/immutable/nodes/{11.4dBWH00t.js → 11.BuH1S-Sa.js} +2 -2
  52. package/apps/web/build/client/_app/immutable/nodes/11.BuH1S-Sa.js.br +0 -0
  53. package/apps/web/build/client/_app/immutable/nodes/11.BuH1S-Sa.js.gz +0 -0
  54. package/apps/web/build/client/_app/immutable/nodes/12.DVFmb_G-.js +1 -0
  55. package/apps/web/build/client/_app/immutable/nodes/12.DVFmb_G-.js.br +0 -0
  56. package/apps/web/build/client/_app/immutable/nodes/12.DVFmb_G-.js.gz +0 -0
  57. package/apps/web/build/client/_app/immutable/nodes/13.0PJQyjqs.js +1 -0
  58. package/apps/web/build/client/_app/immutable/nodes/13.0PJQyjqs.js.br +0 -0
  59. package/apps/web/build/client/_app/immutable/nodes/13.0PJQyjqs.js.gz +0 -0
  60. package/apps/web/build/client/_app/immutable/nodes/14.ljEGDzwO.js +3 -0
  61. package/apps/web/build/client/_app/immutable/nodes/14.ljEGDzwO.js.br +0 -0
  62. package/apps/web/build/client/_app/immutable/nodes/14.ljEGDzwO.js.gz +0 -0
  63. package/apps/web/build/client/_app/immutable/nodes/15.DpXDNTPX.js +1 -0
  64. package/apps/web/build/client/_app/immutable/nodes/15.DpXDNTPX.js.br +0 -0
  65. package/apps/web/build/client/_app/immutable/nodes/15.DpXDNTPX.js.gz +0 -0
  66. package/apps/web/build/client/_app/immutable/nodes/16.qIEBxyps.js +17 -0
  67. package/apps/web/build/client/_app/immutable/nodes/16.qIEBxyps.js.br +0 -0
  68. package/apps/web/build/client/_app/immutable/nodes/16.qIEBxyps.js.gz +0 -0
  69. package/apps/web/build/client/_app/immutable/nodes/17.CmVvQa7x.js +1 -0
  70. package/apps/web/build/client/_app/immutable/nodes/17.CmVvQa7x.js.br +0 -0
  71. package/apps/web/build/client/_app/immutable/nodes/17.CmVvQa7x.js.gz +0 -0
  72. package/apps/web/build/client/_app/immutable/nodes/{2.Dr646Vs5.js → 2.lx602Ou_.js} +1 -1
  73. package/apps/web/build/client/_app/immutable/nodes/2.lx602Ou_.js.br +0 -0
  74. package/apps/web/build/client/_app/immutable/nodes/2.lx602Ou_.js.gz +0 -0
  75. package/apps/web/build/client/_app/immutable/nodes/3.B-axtlUy.js +1 -0
  76. package/apps/web/build/client/_app/immutable/nodes/3.B-axtlUy.js.br +0 -0
  77. package/apps/web/build/client/_app/immutable/nodes/3.B-axtlUy.js.gz +0 -0
  78. package/apps/web/build/client/_app/immutable/nodes/4.Cp9WmMgk.js +1 -0
  79. package/apps/web/build/client/_app/immutable/nodes/4.Cp9WmMgk.js.br +0 -0
  80. package/apps/web/build/client/_app/immutable/nodes/4.Cp9WmMgk.js.gz +0 -0
  81. package/apps/web/build/client/_app/immutable/nodes/5.CQxJe2vk.js +1 -0
  82. package/apps/web/build/client/_app/immutable/nodes/5.CQxJe2vk.js.br +0 -0
  83. package/apps/web/build/client/_app/immutable/nodes/5.CQxJe2vk.js.gz +0 -0
  84. package/apps/web/build/client/_app/immutable/nodes/6.5S6pozqG.js +1 -0
  85. package/apps/web/build/client/_app/immutable/nodes/6.5S6pozqG.js.br +0 -0
  86. package/apps/web/build/client/_app/immutable/nodes/6.5S6pozqG.js.gz +0 -0
  87. package/apps/web/build/client/_app/immutable/nodes/{7.CmbiPMU3.js → 7.B5ZeCLvS.js} +1 -1
  88. package/apps/web/build/client/_app/immutable/nodes/7.B5ZeCLvS.js.br +0 -0
  89. package/apps/web/build/client/_app/immutable/nodes/7.B5ZeCLvS.js.gz +0 -0
  90. package/apps/web/build/client/_app/immutable/nodes/8.M3fxLxa9.js +1 -0
  91. package/apps/web/build/client/_app/immutable/nodes/8.M3fxLxa9.js.br +0 -0
  92. package/apps/web/build/client/_app/immutable/nodes/8.M3fxLxa9.js.gz +0 -0
  93. package/apps/web/build/client/_app/immutable/nodes/9.CYkQmFMJ.js +21 -0
  94. package/apps/web/build/client/_app/immutable/nodes/9.CYkQmFMJ.js.br +0 -0
  95. package/apps/web/build/client/_app/immutable/nodes/9.CYkQmFMJ.js.gz +0 -0
  96. package/apps/web/build/client/_app/version.json +1 -1
  97. package/apps/web/build/client/_app/version.json.br +0 -0
  98. package/apps/web/build/client/_app/version.json.gz +0 -0
  99. package/apps/web/build/server/.vite/manifest.json +15 -1
  100. package/apps/web/build/server/_app/immutable/assets/_layout.BGEsEaMd.css +2 -0
  101. package/apps/web/build/server/chunks/api.js +4 -0
  102. package/apps/web/build/server/chunks/api.js.map +1 -1
  103. package/apps/web/build/server/chunks/instance.js +3 -3
  104. package/apps/web/build/server/chunks/internal.js +1 -1
  105. package/apps/web/build/server/entries/pages/_layout.svelte.js +7 -0
  106. package/apps/web/build/server/entries/pages/_layout.svelte.js.map +1 -1
  107. package/apps/web/build/server/entries/pages/agents/_page.svelte.js +6 -2
  108. package/apps/web/build/server/entries/pages/agents/_page.svelte.js.map +1 -1
  109. package/apps/web/build/server/entries/pages/docs/_page.svelte.js +86 -2
  110. package/apps/web/build/server/entries/pages/docs/_page.svelte.js.map +1 -1
  111. package/apps/web/build/server/entries/pages/remote/_page.svelte.js +73 -0
  112. package/apps/web/build/server/entries/pages/remote/_page.svelte.js.map +1 -0
  113. package/apps/web/build/server/manifest-full.js +15 -7
  114. package/apps/web/build/server/manifest.js +15 -7
  115. package/apps/web/build/server/nodes/0.js +2 -2
  116. package/apps/web/build/server/nodes/1.js +1 -1
  117. package/apps/web/build/server/nodes/10.js +1 -1
  118. package/apps/web/build/server/nodes/11.js +1 -1
  119. package/apps/web/build/server/nodes/12.js +2 -2
  120. package/apps/web/build/server/nodes/13.js +2 -2
  121. package/apps/web/build/server/nodes/14.js +2 -2
  122. package/apps/web/build/server/nodes/15.js +2 -2
  123. package/apps/web/build/server/nodes/16.js +2 -2
  124. package/apps/web/build/server/nodes/17.js +8 -0
  125. package/apps/web/build/server/nodes/2.js +1 -1
  126. package/apps/web/build/server/nodes/3.js +1 -1
  127. package/apps/web/build/server/nodes/4.js +1 -1
  128. package/apps/web/build/server/nodes/5.js +1 -1
  129. package/apps/web/build/server/nodes/6.js +1 -1
  130. package/apps/web/build/server/nodes/7.js +1 -1
  131. package/apps/web/build/server/nodes/8.js +1 -1
  132. package/apps/web/build/server/nodes/9.js +1 -1
  133. package/apps/web/build/server/server.js +15 -7
  134. package/apps/web/package.json +1 -1
  135. package/bin/cli.js +397 -33
  136. package/docs/ALL-WORKFLOW-DIAGRAMS.md +135 -0
  137. package/docs/ARCHITECTURE.md +23 -1
  138. package/docs/BENCHMARK.md +53 -33
  139. package/docs/CLOUDFLARE_TUNNEL_GUIDE.md +119 -0
  140. package/docs/SecurityCompliance/security_compliance_report_google_policy_2.1.17_2026-10-08.md +87 -0
  141. package/docs/TELEGRAM_INTEGRATION_GUIDE.md +146 -0
  142. package/docs/diagrams/README.md +6 -2
  143. package/docs/diagrams/konoha-architecture.drawio +121 -0
  144. package/docs/diagrams/konoha-enterprise-architecture.drawio +121 -0
  145. package/package.json +1 -1
  146. package/src/agent_manager.js +75 -8
  147. package/src/crypto_vault.js +157 -0
  148. package/src/db.js +186 -65
  149. package/src/db_agents.js +1 -1
  150. package/src/mcp/memory_reporting.js +19 -0
  151. package/src/mcp/skills.js +17 -15
  152. package/src/mcp/workflow.js +38 -0
  153. package/src/migrate.js +74 -6
  154. package/src/persona_memory.js +1 -1
  155. package/src/prompt_hook.js +40 -1
  156. package/src/queue/inbox.js +243 -0
  157. package/src/queue/worker.js +413 -0
  158. package/src/telegram/config.js +101 -0
  159. package/src/telegram/notifier.js +359 -0
  160. package/src/telegram/poller.js +548 -0
  161. package/src/telegram/session_manager.js +583 -0
  162. package/src/templates/SOUL.md +1 -1
  163. package/src/templates/skills/konoha/SKILL.md +30 -1
  164. package/src/tunnel/config.js +89 -0
  165. package/src/tunnel/manager.js +216 -0
  166. package/src/tunnel/security.js +225 -0
  167. package/src/vector_search.js +21 -11
  168. package/src/web_server.js +358 -10
  169. package/apps/web/build/client/_app/immutable/assets/0.Ch0v37a-.css +0 -2
  170. package/apps/web/build/client/_app/immutable/assets/0.Ch0v37a-.css.br +0 -0
  171. package/apps/web/build/client/_app/immutable/assets/0.Ch0v37a-.css.gz +0 -0
  172. package/apps/web/build/client/_app/immutable/chunks/7LmsTWIo.js.br +0 -0
  173. package/apps/web/build/client/_app/immutable/chunks/7LmsTWIo.js.gz +0 -0
  174. package/apps/web/build/client/_app/immutable/chunks/BH86Md_X.js +0 -1
  175. package/apps/web/build/client/_app/immutable/chunks/BH86Md_X.js.br +0 -2
  176. package/apps/web/build/client/_app/immutable/chunks/BH86Md_X.js.gz +0 -0
  177. package/apps/web/build/client/_app/immutable/chunks/C3-t9btS.js +0 -1
  178. package/apps/web/build/client/_app/immutable/chunks/C3-t9btS.js.br +0 -1
  179. package/apps/web/build/client/_app/immutable/chunks/C3-t9btS.js.gz +0 -0
  180. package/apps/web/build/client/_app/immutable/chunks/CBY268r4.js +0 -1
  181. package/apps/web/build/client/_app/immutable/chunks/CBY268r4.js.br +0 -3
  182. package/apps/web/build/client/_app/immutable/chunks/CBY268r4.js.gz +0 -0
  183. package/apps/web/build/client/_app/immutable/chunks/D-Kujhko.js.br +0 -0
  184. package/apps/web/build/client/_app/immutable/chunks/D-Kujhko.js.gz +0 -0
  185. package/apps/web/build/client/_app/immutable/chunks/Dzm74gVd.js.br +0 -0
  186. package/apps/web/build/client/_app/immutable/chunks/Dzm74gVd.js.gz +0 -0
  187. package/apps/web/build/client/_app/immutable/chunks/Lb3VuXoN.js +0 -2
  188. package/apps/web/build/client/_app/immutable/chunks/Lb3VuXoN.js.br +0 -0
  189. package/apps/web/build/client/_app/immutable/chunks/Lb3VuXoN.js.gz +0 -0
  190. package/apps/web/build/client/_app/immutable/chunks/PrdhfbrQ.js.br +0 -0
  191. package/apps/web/build/client/_app/immutable/chunks/fbrtLByB.js.br +0 -0
  192. package/apps/web/build/client/_app/immutable/chunks/fbrtLByB.js.gz +0 -0
  193. package/apps/web/build/client/_app/immutable/entry/app.BeU4olDP.js +0 -2
  194. package/apps/web/build/client/_app/immutable/entry/app.BeU4olDP.js.br +0 -0
  195. package/apps/web/build/client/_app/immutable/entry/app.BeU4olDP.js.gz +0 -0
  196. package/apps/web/build/client/_app/immutable/entry/start.CNV5BTCO.js.br +0 -0
  197. package/apps/web/build/client/_app/immutable/entry/start.CNV5BTCO.js.gz +0 -0
  198. package/apps/web/build/client/_app/immutable/nodes/0.CdOP7y9P.js +0 -2
  199. package/apps/web/build/client/_app/immutable/nodes/0.CdOP7y9P.js.br +0 -0
  200. package/apps/web/build/client/_app/immutable/nodes/0.CdOP7y9P.js.gz +0 -0
  201. package/apps/web/build/client/_app/immutable/nodes/1.BZu6jsAH.js +0 -1
  202. package/apps/web/build/client/_app/immutable/nodes/1.BZu6jsAH.js.br +0 -0
  203. package/apps/web/build/client/_app/immutable/nodes/1.BZu6jsAH.js.gz +0 -0
  204. package/apps/web/build/client/_app/immutable/nodes/10.CZKScTFN.js +0 -1
  205. package/apps/web/build/client/_app/immutable/nodes/10.CZKScTFN.js.br +0 -0
  206. package/apps/web/build/client/_app/immutable/nodes/10.CZKScTFN.js.gz +0 -0
  207. package/apps/web/build/client/_app/immutable/nodes/11.4dBWH00t.js.br +0 -0
  208. package/apps/web/build/client/_app/immutable/nodes/11.4dBWH00t.js.gz +0 -0
  209. package/apps/web/build/client/_app/immutable/nodes/12.CSShcv5z.js +0 -1
  210. package/apps/web/build/client/_app/immutable/nodes/12.CSShcv5z.js.br +0 -0
  211. package/apps/web/build/client/_app/immutable/nodes/12.CSShcv5z.js.gz +0 -0
  212. package/apps/web/build/client/_app/immutable/nodes/13.jWUWoBcs.js +0 -3
  213. package/apps/web/build/client/_app/immutable/nodes/13.jWUWoBcs.js.br +0 -0
  214. package/apps/web/build/client/_app/immutable/nodes/13.jWUWoBcs.js.gz +0 -0
  215. package/apps/web/build/client/_app/immutable/nodes/14.H-jSqqen.js +0 -1
  216. package/apps/web/build/client/_app/immutable/nodes/14.H-jSqqen.js.br +0 -0
  217. package/apps/web/build/client/_app/immutable/nodes/14.H-jSqqen.js.gz +0 -0
  218. package/apps/web/build/client/_app/immutable/nodes/15.CpAoyhzV.js +0 -17
  219. package/apps/web/build/client/_app/immutable/nodes/15.CpAoyhzV.js.br +0 -0
  220. package/apps/web/build/client/_app/immutable/nodes/15.CpAoyhzV.js.gz +0 -0
  221. package/apps/web/build/client/_app/immutable/nodes/16.DT_-MxCT.js +0 -1
  222. package/apps/web/build/client/_app/immutable/nodes/16.DT_-MxCT.js.br +0 -0
  223. package/apps/web/build/client/_app/immutable/nodes/16.DT_-MxCT.js.gz +0 -0
  224. package/apps/web/build/client/_app/immutable/nodes/2.Dr646Vs5.js.br +0 -0
  225. package/apps/web/build/client/_app/immutable/nodes/2.Dr646Vs5.js.gz +0 -0
  226. package/apps/web/build/client/_app/immutable/nodes/3.Cgc-xN3x.js +0 -1
  227. package/apps/web/build/client/_app/immutable/nodes/3.Cgc-xN3x.js.br +0 -0
  228. package/apps/web/build/client/_app/immutable/nodes/3.Cgc-xN3x.js.gz +0 -0
  229. package/apps/web/build/client/_app/immutable/nodes/4.CYJQ4bWz.js +0 -1
  230. package/apps/web/build/client/_app/immutable/nodes/4.CYJQ4bWz.js.br +0 -0
  231. package/apps/web/build/client/_app/immutable/nodes/4.CYJQ4bWz.js.gz +0 -0
  232. package/apps/web/build/client/_app/immutable/nodes/5.DbHL-3Es.js +0 -1
  233. package/apps/web/build/client/_app/immutable/nodes/5.DbHL-3Es.js.br +0 -0
  234. package/apps/web/build/client/_app/immutable/nodes/5.DbHL-3Es.js.gz +0 -0
  235. package/apps/web/build/client/_app/immutable/nodes/6.BvWH2qas.js +0 -1
  236. package/apps/web/build/client/_app/immutable/nodes/6.BvWH2qas.js.br +0 -0
  237. package/apps/web/build/client/_app/immutable/nodes/6.BvWH2qas.js.gz +0 -0
  238. package/apps/web/build/client/_app/immutable/nodes/7.CmbiPMU3.js.br +0 -0
  239. package/apps/web/build/client/_app/immutable/nodes/7.CmbiPMU3.js.gz +0 -0
  240. package/apps/web/build/client/_app/immutable/nodes/8.B9897Zm9.js +0 -1
  241. package/apps/web/build/client/_app/immutable/nodes/8.B9897Zm9.js.br +0 -0
  242. package/apps/web/build/client/_app/immutable/nodes/8.B9897Zm9.js.gz +0 -0
  243. package/apps/web/build/client/_app/immutable/nodes/9.CGMmeMVC.js +0 -14
  244. package/apps/web/build/client/_app/immutable/nodes/9.CGMmeMVC.js.br +0 -0
  245. package/apps/web/build/client/_app/immutable/nodes/9.CGMmeMVC.js.gz +0 -0
  246. package/apps/web/build/server/_app/immutable/assets/_layout.Ch0v37a-.css +0 -2
@@ -0,0 +1,583 @@
1
+ /**
2
+ * Konoha Telegram Multi-Session & Workspace Switcher.
3
+ * Enables selecting and routing tasks to active client sessions (Antigravity, Claude, Cursor, etc.)
4
+ * using simple numbered session indices: /session <number>.
5
+ */
6
+
7
+ 'use strict';
8
+
9
+ const fs = require('fs');
10
+ const path = require('path');
11
+ const os = require('os');
12
+ const dbModule = require('../db');
13
+
14
+ const CLIENT_DISPLAY_NAMES = {
15
+ antigravity: 'Antigravity IDE/CLI',
16
+ agy: 'Antigravity IDE/CLI',
17
+ claudecode: 'Claude Code',
18
+ claude: 'Claude Code',
19
+ cursor: 'Cursor',
20
+ codex: 'Codex',
21
+ opencode: 'OpenCode',
22
+ commandcode: 'Command Code',
23
+ pi: 'Pi Agent',
24
+ telegram: 'Telegram Bot'
25
+ };
26
+
27
+ const CANONICAL_CLIENT_MAP = {
28
+ agy: 'antigravity',
29
+ antigravity: 'antigravity',
30
+ claude: 'claudecode',
31
+ claudecode: 'claudecode',
32
+ codex: 'codex',
33
+ pi: 'pi',
34
+ opencode: 'opencode',
35
+ commandcode: 'commandcode',
36
+ cursor: 'cursor'
37
+ };
38
+
39
+ const IGNORED_CLIENTS = new Set(['unattributed', 'unknown', 'default']);
40
+ const IGNORED_PATHS = [
41
+ os.homedir(),
42
+ path.join(os.homedir(), '.konoha'),
43
+ path.normalize(os.tmpdir())
44
+ ];
45
+
46
+ /**
47
+ * Ensure telegram_session_targets table exists in database.
48
+ */
49
+ function ensureTable(conn) {
50
+ try {
51
+ conn.prepare(`
52
+ CREATE TABLE IF NOT EXISTS telegram_session_targets (
53
+ chat_id TEXT PRIMARY KEY,
54
+ client TEXT NOT NULL,
55
+ workspace_root TEXT NOT NULL,
56
+ session_id TEXT NOT NULL,
57
+ updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
58
+ )
59
+ `).run();
60
+ } catch (_) { /* intentional best-effort fallback */ }
61
+ }
62
+
63
+ /**
64
+ * Check if a workspace path is a real project workspace.
65
+ */
66
+ function isRealWorkspace(ws) {
67
+ if (!ws || typeof ws !== 'string') return false;
68
+ const norm = path.normalize(ws.trim());
69
+ if (IGNORED_PATHS.includes(norm)) return false;
70
+ if (norm.startsWith('/tmp') || norm.includes('/.konoha')) return false;
71
+ if (!fs.existsSync(norm)) return false;
72
+ try {
73
+ const stat = fs.statSync(norm);
74
+ return stat.isDirectory();
75
+ } catch (_) {
76
+ return false;
77
+ }
78
+ }
79
+
80
+ /**
81
+ * Format relative timestamp.
82
+ */
83
+ function formatTimeAgo(dateStr) {
84
+ if (!dateStr) return 'recently';
85
+ try {
86
+ const d = new Date(dateStr.endsWith('Z') ? dateStr : dateStr + 'Z');
87
+ const diffMs = Date.now() - d.getTime();
88
+ if (isNaN(diffMs) || diffMs < 0) return 'just now';
89
+ const diffSec = Math.floor(diffMs / 1000);
90
+ if (diffSec < 60) return `${diffSec}s ago`;
91
+ const diffMin = Math.floor(diffSec / 60);
92
+ if (diffMin < 60) return `${diffMin}m ago`;
93
+ const diffHour = Math.floor(diffMin / 60);
94
+ if (diffHour < 24) return `${diffHour}h ago`;
95
+ const diffDay = Math.floor(diffHour / 24);
96
+ return `${diffDay}d ago`;
97
+ } catch (_) {
98
+ return dateStr;
99
+ }
100
+ }
101
+
102
+ /**
103
+ * Check if a session is genuinely alive on the local workstation.
104
+ */
105
+ function isSessionAlive(sess, maxIdleMs = 45 * 60 * 1000) {
106
+ if (!sess || !sess.workspace_root) return false;
107
+ if (!isRealWorkspace(sess.workspace_root)) return false;
108
+
109
+ const now = Date.now();
110
+ const currentConvId = process.env.ANTIGRAVITY_CONVERSATION_ID ||
111
+ process.env.GEMINI_CONVERSATION_ID ||
112
+ null;
113
+ const cwd = path.normalize(process.cwd());
114
+
115
+ // 1. Current active environment session is always alive
116
+ if (currentConvId && sess.session_id === currentConvId && sess.workspace_root === cwd) {
117
+ return true;
118
+ }
119
+
120
+ // 2. Check last_active_at timestamp freshness
121
+ let lastActiveMs = 0;
122
+ if (sess.last_active_at) {
123
+ const d = new Date(sess.last_active_at.endsWith('Z') ? sess.last_active_at : sess.last_active_at + 'Z');
124
+ if (!isNaN(d.getTime())) {
125
+ lastActiveMs = d.getTime();
126
+ }
127
+ }
128
+
129
+ // If last_active_at is older than maxIdleMs, it is definitely not actively used
130
+ if (lastActiveMs > 0 && (now - lastActiveMs) > maxIdleMs) {
131
+ return false;
132
+ }
133
+
134
+ // 3. For Antigravity sessions, check brain directory and transcript freshness
135
+ const clientNorm = (sess.client || '').toLowerCase();
136
+ if (clientNorm === 'antigravity' || clientNorm === 'agy') {
137
+ if (sess.session_id && sess.session_id !== 'default') {
138
+ const brainCli = path.join(os.homedir(), '.gemini/antigravity-cli/brain', sess.session_id);
139
+ const brainIde = path.join(os.homedir(), '.gemini/antigravity-ide/brain', sess.session_id);
140
+ const brainDir = fs.existsSync(brainCli) ? brainCli : (fs.existsSync(brainIde) ? brainIde : null);
141
+
142
+ if (brainDir) {
143
+ let newestMtime = 0;
144
+ const transcriptPath = path.join(brainDir, '.system_generated', 'logs', 'transcript.jsonl');
145
+ const promptPath = path.join(brainDir, 'prompt.md');
146
+ if (fs.existsSync(transcriptPath)) {
147
+ try {
148
+ newestMtime = Math.max(newestMtime, fs.statSync(transcriptPath).mtimeMs);
149
+ } catch (_) {
150
+ /* file access error fallback */
151
+ }
152
+ }
153
+ if (fs.existsSync(promptPath)) {
154
+ try {
155
+ newestMtime = Math.max(newestMtime, fs.statSync(promptPath).mtimeMs);
156
+ } catch (_) {
157
+ /* file access error fallback */
158
+ }
159
+ }
160
+ if (newestMtime > 0) {
161
+ return (now - newestMtime) <= maxIdleMs;
162
+ }
163
+ }
164
+ }
165
+ }
166
+
167
+ // 4. For Claude Code sessions, check transcript freshness if path exists
168
+ if (clientNorm === 'claudecode' || clientNorm === 'claude') {
169
+ if (sess.transcript_path && fs.existsSync(sess.transcript_path)) {
170
+ try {
171
+ const mtime = fs.statSync(sess.transcript_path).mtimeMs;
172
+ return (now - mtime) <= maxIdleMs;
173
+ } catch (_) {
174
+ /* file access error fallback */
175
+ }
176
+ }
177
+ }
178
+
179
+ // 5. Fallback for manual or generic sessions: check last_active_at
180
+ return lastActiveMs > 0 && (now - lastActiveMs) <= maxIdleMs;
181
+ }
182
+
183
+ /**
184
+ * Automatically touch and register current active environment session into active_sessions.
185
+ */
186
+ function touchCurrentSession(conn) {
187
+ try {
188
+ const currentConvId = process.env.ANTIGRAVITY_CONVERSATION_ID ||
189
+ process.env.GEMINI_CONVERSATION_ID ||
190
+ null;
191
+ const cwd = path.normalize(process.cwd());
192
+ if (currentConvId && isRealWorkspace(cwd)) {
193
+ const now = new Date().toISOString();
194
+ conn.prepare(`
195
+ INSERT OR REPLACE INTO active_sessions (client, workspace_root, session_id, transcript_path, last_active_at)
196
+ VALUES (?, ?, ?, ?, ?)
197
+ `).run('antigravity', cwd, currentConvId, null, now);
198
+
199
+ conn.prepare(`
200
+ DELETE FROM active_sessions
201
+ WHERE workspace_root = ? AND client IN ('agy', 'antigravity') AND session_id != ?
202
+ `).run(cwd, currentConvId);
203
+ }
204
+ } catch (_) { /* ignore */ }
205
+ }
206
+
207
+ /**
208
+ * Retrieve ONLY genuinely active sessions from database.
209
+ */
210
+ function getActiveSessions() {
211
+ const conn = dbModule.getConnection();
212
+ ensureTable(conn);
213
+ touchCurrentSession(conn);
214
+
215
+ try {
216
+ const rows = conn.prepare(`
217
+ SELECT client, workspace_root, session_id, transcript_path, last_active_at
218
+ FROM active_sessions
219
+ ORDER BY last_active_at DESC
220
+ LIMIT 50
221
+ `).all();
222
+
223
+ const seen = new Set();
224
+ const sessions = [];
225
+
226
+ for (const r of rows) {
227
+ if (!r.client || IGNORED_CLIENTS.has(r.client.toLowerCase())) continue;
228
+ if (!isRealWorkspace(r.workspace_root)) continue;
229
+
230
+ // Filter: only genuinely active sessions
231
+ if (!isSessionAlive(r)) continue;
232
+
233
+ let normClient = CANONICAL_CLIENT_MAP[r.client.toLowerCase()] || r.client.toLowerCase();
234
+ const normWs = path.normalize(r.workspace_root);
235
+ const key = `${normClient}:${normWs}`;
236
+ if (seen.has(key)) continue;
237
+ seen.add(key);
238
+
239
+ sessions.push({
240
+ index: sessions.length + 1,
241
+ client: normClient,
242
+ workspace_root: normWs,
243
+ session_id: r.session_id || 'default',
244
+ last_active_at: r.last_active_at || ''
245
+ });
246
+ }
247
+
248
+ // Always ensure current workspace is present
249
+ const cwd = path.normalize(process.cwd());
250
+ const hasCwd = sessions.some(s => s.workspace_root === cwd);
251
+ const currentConvId = process.env.ANTIGRAVITY_CONVERSATION_ID ||
252
+ process.env.GEMINI_CONVERSATION_ID ||
253
+ 'default';
254
+ if (!hasCwd && isRealWorkspace(cwd)) {
255
+ sessions.unshift({
256
+ index: 1,
257
+ client: 'antigravity',
258
+ workspace_root: cwd,
259
+ session_id: currentConvId,
260
+ last_active_at: new Date().toISOString()
261
+ });
262
+ // Re-index
263
+ sessions.forEach((s, i) => { s.index = i + 1; });
264
+ }
265
+
266
+ if (sessions.length === 0) {
267
+ sessions.push({
268
+ index: 1,
269
+ client: 'antigravity',
270
+ workspace_root: cwd,
271
+ session_id: currentConvId,
272
+ last_active_at: new Date().toISOString()
273
+ });
274
+ }
275
+
276
+ return sessions;
277
+ } catch (_) {
278
+ const currentConvId = process.env.ANTIGRAVITY_CONVERSATION_ID ||
279
+ process.env.GEMINI_CONVERSATION_ID ||
280
+ 'default';
281
+ return [{
282
+ index: 1,
283
+ client: 'antigravity',
284
+ workspace_root: path.normalize(process.cwd()),
285
+ session_id: currentConvId,
286
+ last_active_at: new Date().toISOString()
287
+ }];
288
+ }
289
+ }
290
+
291
+ /**
292
+ * Get active target session for a Telegram chat.
293
+ */
294
+ function getTargetSession(chatId) {
295
+ const conn = dbModule.getConnection();
296
+ ensureTable(conn);
297
+ const cId = String(chatId);
298
+ const sessions = getActiveSessions();
299
+
300
+ try {
301
+ const row = conn.prepare(`
302
+ SELECT client, workspace_root, session_id, updated_at
303
+ FROM telegram_session_targets
304
+ WHERE chat_id = ?
305
+ `).get(cId);
306
+
307
+ if (row && row.workspace_root && isRealWorkspace(row.workspace_root)) {
308
+ const matched = sessions.find(s => s.session_id === row.session_id) ||
309
+ sessions.find(s => s.client === row.client && s.workspace_root === row.workspace_root);
310
+ if (matched) {
311
+ return {
312
+ client: matched.client,
313
+ workspace_root: matched.workspace_root,
314
+ session_id: matched.session_id
315
+ };
316
+ }
317
+ return {
318
+ client: row.client,
319
+ workspace_root: row.workspace_root,
320
+ session_id: row.session_id
321
+ };
322
+ }
323
+ } catch (_) { /* ignore */ }
324
+
325
+ if (sessions.length > 0) {
326
+ return {
327
+ client: sessions[0].client,
328
+ workspace_root: sessions[0].workspace_root,
329
+ session_id: sessions[0].session_id
330
+ };
331
+ }
332
+
333
+ const currentConvId = process.env.ANTIGRAVITY_CONVERSATION_ID ||
334
+ process.env.GEMINI_CONVERSATION_ID ||
335
+ 'default';
336
+ return {
337
+ client: 'antigravity',
338
+ workspace_root: process.cwd(),
339
+ session_id: currentConvId
340
+ };
341
+ }
342
+
343
+ /**
344
+ * Set target session by 1-based index number: /session <number>.
345
+ */
346
+ function setTargetSession(chatId, selector) {
347
+ if (!selector || typeof selector !== 'string' || !selector.trim()) {
348
+ return {
349
+ success: false,
350
+ error: 'Please specify a session number (e.g. /session 1).'
351
+ };
352
+ }
353
+
354
+ const clean = selector.trim();
355
+ const sessions = getActiveSessions();
356
+
357
+ // Strictly parse by 1-based index number
358
+ const idx = parseInt(clean, 10);
359
+ if (isNaN(idx) || idx < 1 || idx > sessions.length) {
360
+ return {
361
+ success: false,
362
+ error: `Invalid session number "${clean}". Choose a number between 1 and ${sessions.length}.`,
363
+ sessionsCount: sessions.length
364
+ };
365
+ }
366
+
367
+ const matched = sessions[idx - 1];
368
+ const conn = dbModule.getConnection();
369
+ ensureTable(conn);
370
+ const now = new Date().toISOString();
371
+
372
+ try {
373
+ conn.prepare(`
374
+ INSERT OR REPLACE INTO telegram_session_targets (chat_id, client, workspace_root, session_id, updated_at)
375
+ VALUES (?, ?, ?, ?, ?)
376
+ `).run(String(chatId), matched.client, matched.workspace_root, matched.session_id, now);
377
+
378
+ return {
379
+ success: true,
380
+ session: matched,
381
+ index: idx
382
+ };
383
+ } catch (err) {
384
+ return {
385
+ success: false,
386
+ error: `Failed to save session: ${err.message}`
387
+ };
388
+ }
389
+ }
390
+
391
+ /**
392
+ * Create/register and immediately target a session: /session create <client> <path>.
393
+ */
394
+ function createSession(chatId, clientInput, pathInput) {
395
+ if (!clientInput || typeof clientInput !== 'string' || !clientInput.trim()) {
396
+ return {
397
+ success: false,
398
+ error: 'Client name is required (e.g. agy, antigravity, claude, codex, pi, opencode, commandcode).'
399
+ };
400
+ }
401
+
402
+ const cleanClient = clientInput.trim().toLowerCase();
403
+ const canonicalClient = CANONICAL_CLIENT_MAP[cleanClient];
404
+ if (!canonicalClient) {
405
+ return {
406
+ success: false,
407
+ error: `Unsupported client "${clientInput}". Supported: agy, antigravity, claude, codex, pi, opencode, commandcode, cursor.`
408
+ };
409
+ }
410
+
411
+ if (!pathInput || typeof pathInput !== 'string' || !pathInput.trim()) {
412
+ return {
413
+ success: false,
414
+ error: 'Workspace directory path is required.'
415
+ };
416
+ }
417
+
418
+ let resolvedPath = pathInput.trim();
419
+ if ((resolvedPath.startsWith('"') && resolvedPath.endsWith('"')) ||
420
+ (resolvedPath.startsWith("'") && resolvedPath.endsWith("'"))) {
421
+ resolvedPath = resolvedPath.slice(1, -1).trim();
422
+ }
423
+
424
+ if (resolvedPath.startsWith('~/') || resolvedPath === '~') {
425
+ resolvedPath = path.join(os.homedir(), resolvedPath.slice(1));
426
+ } else if (!path.isAbsolute(resolvedPath)) {
427
+ resolvedPath = path.resolve(process.cwd(), resolvedPath);
428
+ }
429
+ resolvedPath = path.normalize(resolvedPath);
430
+
431
+ if (!fs.existsSync(resolvedPath)) {
432
+ return {
433
+ success: false,
434
+ error: `Directory does not exist: "${resolvedPath}".`
435
+ };
436
+ }
437
+
438
+ let stat;
439
+ try {
440
+ stat = fs.statSync(resolvedPath);
441
+ } catch (err) {
442
+ return {
443
+ success: false,
444
+ error: `Cannot access path "${resolvedPath}": ${err.message}`
445
+ };
446
+ }
447
+
448
+ if (!stat.isDirectory()) {
449
+ return {
450
+ success: false,
451
+ error: `Path is not a directory: "${resolvedPath}".`
452
+ };
453
+ }
454
+
455
+ if (resolvedPath === path.normalize(os.homedir())) {
456
+ return {
457
+ success: false,
458
+ error: `Cannot use home directory (${os.homedir()}) as project workspace.`
459
+ };
460
+ }
461
+
462
+ if (resolvedPath === path.normalize(os.tmpdir()) || resolvedPath === '/tmp' || resolvedPath.startsWith('/tmp/')) {
463
+ return {
464
+ success: false,
465
+ error: 'Cannot use /tmp directory as project workspace.'
466
+ };
467
+ }
468
+
469
+ if (resolvedPath.includes('/.konoha')) {
470
+ return {
471
+ success: false,
472
+ error: 'Cannot use internal .konoha directory as project workspace.'
473
+ };
474
+ }
475
+
476
+ const conn = dbModule.getConnection();
477
+ ensureTable(conn);
478
+ const now = new Date().toISOString();
479
+ const sessionId = `sess_${canonicalClient}_${Date.now()}`;
480
+
481
+ try {
482
+ conn.prepare(`
483
+ INSERT OR REPLACE INTO active_sessions (client, workspace_root, session_id, transcript_path, last_active_at)
484
+ VALUES (?, ?, ?, ?, ?)
485
+ `).run(canonicalClient, resolvedPath, sessionId, null, now);
486
+ } catch (err) {
487
+ return {
488
+ success: false,
489
+ error: `Failed to save session to active_sessions: ${err.message}`
490
+ };
491
+ }
492
+
493
+ try {
494
+ conn.prepare(`
495
+ INSERT OR REPLACE INTO telegram_session_targets (chat_id, client, workspace_root, session_id, updated_at)
496
+ VALUES (?, ?, ?, ?, ?)
497
+ `).run(String(chatId), canonicalClient, resolvedPath, sessionId, now);
498
+ } catch (err) {
499
+ return {
500
+ success: false,
501
+ error: `Failed to save session target: ${err.message}`
502
+ };
503
+ }
504
+
505
+ const sessions = getActiveSessions();
506
+ const found = sessions.find(s => s.workspace_root === resolvedPath && s.client === canonicalClient);
507
+ const idx = found ? found.index : 1;
508
+
509
+ return {
510
+ success: true,
511
+ session: {
512
+ client: canonicalClient,
513
+ workspace_root: resolvedPath,
514
+ session_id: sessionId
515
+ },
516
+ index: idx,
517
+ totalSessions: sessions.length
518
+ };
519
+ }
520
+
521
+ /**
522
+ * Format HTML list of active sessions for Telegram.
523
+ */
524
+ function formatSessionList(chatId) {
525
+ const sessions = getActiveSessions();
526
+ const current = getTargetSession(chatId);
527
+
528
+ const lines = [
529
+ '<b>🎛️ [ACTIVE SESSIONS & WORKSPACES]</b>',
530
+ '━━━━━━━━━━━━━━━━━━━━━━━━━━━━',
531
+ 'Select a session number to route tasks to that specific workspace & client.',
532
+ '',
533
+ '<b>📋 Available Active Sessions:</b>'
534
+ ];
535
+
536
+ let targetIndex = -1;
537
+ if (current) {
538
+ if (current.session_id && current.session_id !== 'default') {
539
+ targetIndex = sessions.findIndex(s => s.session_id === current.session_id);
540
+ }
541
+ if (targetIndex === -1 && current.client && current.workspace_root) {
542
+ targetIndex = sessions.findIndex(s => s.client === current.client && s.workspace_root === current.workspace_root);
543
+ }
544
+ if (targetIndex === -1 && sessions.length > 0) {
545
+ targetIndex = 0;
546
+ }
547
+ }
548
+
549
+ sessions.forEach((s, idx) => {
550
+ const isCurrent = (idx === targetIndex);
551
+ const clientName = CLIENT_DISPLAY_NAMES[s.client.toLowerCase()] || s.client;
552
+ const badge = isCurrent ? ' <b>(CURRENT TARGET)</b>' : '';
553
+ const timeAgo = formatTimeAgo(s.last_active_at);
554
+
555
+ lines.push(`<b>[${s.index}] ${clientName}</b>${badge}`);
556
+ lines.push(` 🔖 <b>Session ID:</b> <code>${s.session_id}</code>`);
557
+ lines.push(` 📂 <code>${s.workspace_root}</code>`);
558
+ lines.push(` 🕒 Active: ${timeAgo}`);
559
+ lines.push('');
560
+ });
561
+
562
+ lines.push('━━━━━━━━━━━━━━━━━━━━━━━━━━━━');
563
+ lines.push('<b>🎯 Usage:</b> <code>/session &lt;number&gt;</code>');
564
+ lines.push(`<b>💡 Example:</b> <code>/session 1</code>${sessions.length > 1 ? ` or <code>/session 2</code>` : ''}`);
565
+ lines.push('<b>➕ Create:</b> <code>/session create &lt;client&gt; &lt;path&gt;</code>');
566
+
567
+ return lines.join('\n');
568
+ }
569
+
570
+ module.exports = {
571
+ CLIENT_DISPLAY_NAMES,
572
+ CANONICAL_CLIENT_MAP,
573
+ ensureTable,
574
+ isRealWorkspace,
575
+ isSessionAlive,
576
+ touchCurrentSession,
577
+ getActiveSessions,
578
+ getTargetSession,
579
+ setTargetSession,
580
+ createSession,
581
+ formatSessionList,
582
+ formatTimeAgo
583
+ };
@@ -41,7 +41,7 @@ Every agent bearing the leaf headband—from the router Sannin to the frontline
41
41
  * **Stable Core Guard**: The local LLM Proxy Gateway, bridge servers, and bounded file token-savings flows are stable and sacred. Never refactor stable foundations without explicit orders.
42
42
 
43
43
  ### 4. Anti-Slop as a Moral Duty (Genuine Craftsmanship & Anti-Slop Matrix)
44
- * **Zero AI Clichés**: Eradicate robotic phrasing, corporate pleasantries, synthetic enthusiasm, lazy stubs (`TODO: implement`, `// add logic here`), and generic AI design clichés.
44
+ * **Zero AI Clichés**: Eradicate robotic phrasing, corporate pleasantries, synthetic enthusiasm, lazy stubs (unimplemented task stubs or empty placeholder logic), and generic AI design clichés.
45
45
  * **Meaningful Comments Only**: Never write self-evident syntax narration (`// increment i by 1`). Code must explain itself; comments must document non-obvious domain logic, invariants, and architectural rationale.
46
46
  * **Human-Grade Aesthetics**: Interfaces must breathe with intentional negative space, balanced typography, accessible contrast, and fluid micro-interactions. Zero dark fills, zero black text, and zero emoji soup in UI controls.
47
47
  * **Mandatory Agent Anti-Slop Matrix**: Every shinobi specialist is bound by specialized anti-slop skills matching their domain:
@@ -74,7 +74,7 @@ These standards apply to every build mode (`build_from_text`, clone-url flows, `
74
74
  - **Custom assets**: hand-craft favicon, OG image, and 404/error page with non-generic filenames (never `hero.webp`, `og-image.png`, `icon-1.svg`, scaffold-default names) — name them after the project brand.
75
75
  - **Icons**: Phosphor Icons or hand-exported inline SVGs only — never Lucide (see §7).
76
76
  - **No platform attribution badges** or "Deployed on X" links; keep the Build by Konoha footer credit exactly as-is.
77
- - **Hosting (advisory)**: when the user controls hosting, prefer self-hosted Node, Cloudflare Pages, or a VPS over Vercel/Netlify — Vercel/Netlify is itself scored as an AI-app-deployment signal.
77
+ - **Hosting (advisory)**: when the user controls hosting, prefer self-hosted Node, Cloudflare Pages, or a VPS over Vercel/Netlify — Vercel/Netlify is itself scored by detectors as an automated deployment signal.
78
78
  - **Per-framework styling fingerprints**:
79
79
  - *Next.js*: hand-modified fully custom Tailwind theme (custom spacing/colors/radii/fonts, no stock scale); no shadcn/ui API shapes — own primitives under `components/primitives`, never `components/ui`.
80
80
  - *SvelteKit*: no Tailwind at all — scoped `<style>` blocks + one hand-written global stylesheet; no shadcn-svelte or Skeleton.
@@ -466,4 +466,33 @@ These standards apply to every build mode (`build_from_text`, clone-url flows, `
466
466
  80. **Mandatory Release Permission Gate & Zero Auto-Release Invariant (v2.1.14+)**:
467
467
  - **Explicit User Confirmation Required**: When maintaining, updating, or fixing the Konoha repository or any client configurations, the agent MUST ALWAYS explicitly ask the user for permission before executing any release action (creating git release commits, git tags, git pushes to release branches, or triggering npm publish / CI release workflows).
468
468
  - **Zero Auto-Release Invariant**: Auto-releasing, automatic tagging, or unprompted publishing to npm or GitHub without prior explicit user request and authorization is strictly prohibited. Keep all changes local until explicitly instructed and approved by the user to release.
469
+ 81. **Telegram Bot Remote Notification & Outbound Reporter Invariants (v2.1.17)**:
470
+ - **Zero-Emoji Outbound Reporter**: Outbound task completion and error notifications via Telegram Bot API strictly adhere to the zero-emoji standard (`[KONOHA TASK REPORT]`, `[SUCCESS]`, `[FAILED]`, `[QUEUED]`, `[ERROR]`).
471
+ - **Configuration & Storage**: Bot token and target chat ID stored in `telegram_config` table in `~/.konoha/konoha.db`. Managed via CLI: `konoha telegram config --token <BOT_TOKEN> --chat-id <CHAT_ID>`, `konoha telegram enable`, `konoha telegram disable`, and `konoha telegram test`.
472
+ - **Native Long Polling & Whitelist Gate**: Long polling daemon (`src/telegram/poller.js`) runs with strict `chat_id` whitelist authorization (`telegram_config.chat_id`). Unauthorized sender messages are immediately dropped.
473
+ - **Daemon Commands**: Supports `/run <prompt>`, `/status`, `/savings`, `/kage`, `/cancel`, `/help`.
474
+ 82. **Public Tunnel & Cloudflare Zero Trust Ingress Security Invariants (v2.1.17)**:
475
+ - **Quick Tunnel & Named Domain Ingress**: Child process supervisor (`src/tunnel/manager.js`) manages `cloudflared tunnel --url http://localhost:1404` (or `ngrok`) with process lifecycle tracking and live public URL extraction (`trycloudflare.com`).
476
+ - **Edge Identity Mode A (No PIN)**: Web server routes validate Cloudflare Zero Trust identity header `Cf-Access-Authenticated-User-Email` when accessed via public tunnel while allowing unauthenticated local access on `localhost:1404`.
477
+ - **CLI Management**: `konoha tunnel start`, `konoha tunnel stop`, `konoha tunnel status`, `konoha tunnel config`.
478
+ 83. **Unified Prompt Queue & Asynchronous Inbox Architecture (v2.1.17)**:
479
+ - **SQLite Queue Engine**: Table `prompt_queue` maintains atomic prompt state (`pending` -> `processing` -> `completed` / `failed`) with retry count and priority.
480
+ - **Filesystem Mirror**: Mirrored into `~/.konoha/inbox/<session_id>.json` and `~/.konoha/inbox/latest.json` for coding client pickup.
481
+ - **Remote Access Web UI**: Integrated into SvelteKit dashboard (`/remote` and `RemoteAccess.svelte`) providing live status cards for Telegram, Cloudflare Tunnel, and real-time Inbound Prompt Queue.
482
+ 84. **Interactive Shell Execution & Subagent Direct Dispatch Invariant (v2.1.17)**:
483
+ - **Interactive Shell Execution**: Commands dispatched via `/sh <cmd>` or `/exec <cmd>` execute in the target workspace using the user's interactive shell (`userShell -i -c`) with full alias expansion from `~/.bashrc` (`kubectl`, `kc*`, `helm`, etc.).
484
+ - **Security Guardrail**: Dangerous or destructive commands (`rm -rf /`, `mkfs`, `dd`, `drop database`, `truncate table`, etc.) are unconditionally rejected by `isDangerousCommand`.
485
+ - **Subagent Direct Dispatch**: Slash commands (`/kage`, `/anbu`, `/jonin`, `/genin`, `/chunin`, `/tokubetsu_jonin`, `/sannin`) bypass general routing deliberation and directly assign prompts to specialized ninjas.
486
+ - **Multi-Client Workspace Switcher**: Manage and switch active client workspaces across Antigravity, Claude Code, Codex, Pi, OpenCode, and Command Code via `/session [number]` and register remote directories via `/session create <client> <path>`.
487
+ 85. **Operational vs. AI Routing in Autonomous Queue Worker (v2.1.17)**:
488
+ - **Operational Branch (0 LLM Tokens)**: Deterministic commands starting with `/sh`, direct commands (`kubectl`, `helm`, `docker`, `git`, `ssh`, etc.), or `kc*` shell aliases execute deterministically in interactive shell with 100% token elimination.
489
+ - **AI Coding Branch**: Complex coding and natural language prompts route through headless `agy -p ...` with structured task telemetry and Kage Reviewer confidence reporting.
490
+ - **Daemon Observability**: Structured diagnostic logging across poller (`src/telegram/poller.js`) and queue worker (`src/queue/worker.js`) ensures full audit visibility in `journalctl`.
491
+ 86. **Telegram One-Way Kage Gate Review Dispatch & Non-Blocking CLI Explorer (v2.1.17)**:
492
+ - **One-Way Kage Gate Notification**: In Telegram One-Way Mode (as well as Two-Way Mode), whenever any local workstation session (Antigravity IDE/CLI, terminal session, or background runner) passes Kage Final Gate Review (`APPROVED` with 100/100 zero-slop score and ≥98% confidence score), `notifyKageReviewPassed` in `src/telegram/notifier.js` is automatically triggered via `report_from_agent` in `src/mcp/memory_reporting.js`. The developer receives immediate, zero-polling completion notifications on their phone.
493
+ - **CLI Manual Notification**: Developers can test or trigger the gate notification via `konoha telegram notify-kage [summary]` or `konoha telegram test-gate`.
494
+ - **Non-Blocking Agent List**: `konoha agent list` renders a fast (<0.2s) static table by default. The interactive raw-mode terminal UI is strictly scoped behind `--tui`, `--interactive`, or `-i`, ensuring zero hangs in automated test runners, non-TTY environments, and PTY runners.
495
+ - **Safe Queue Worker Subprocesses**: `src/queue/worker.js` strictly executes tasks via `execFile(agyBin, agyArgs, ...)` with structured argument arrays and dynamic `resolveAgyBin()`, completely eliminating shell command injection risks.
496
+ - **Single Target Session Marker**: `src/telegram/session_manager.js` evaluates session indices to ensure strictly ONE session receives the `(CURRENT TARGET)` badge.
497
+
469
498