tenjin-cli 0.1.0-alpha.31 → 0.1.0-alpha.33

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 (270) hide show
  1. package/README.md +45 -26
  2. package/dist/{_esm-MEXZI5DL.js → _esm-BIN7VY2L.js} +128 -132
  3. package/dist/{alive-J64H46HI.js → alive-GSOWKUOY.js} +13 -6
  4. package/dist/auto-update-Y24UL56V.js +24 -0
  5. package/dist/{ccip-7RMRLAGV.js → ccip-DHDFKTQV.js} +2 -2
  6. package/dist/{chunk-TTNESUPQ.js → chunk-2GP3HRYK.js} +2120 -193
  7. package/dist/chunk-2GP3HRYK.js.map +1 -0
  8. package/dist/chunk-2M2VPI2E.js +560 -0
  9. package/dist/chunk-2M2VPI2E.js.map +1 -0
  10. package/dist/{chunk-D65GNPS3.js → chunk-2RWB7RKE.js} +288 -108
  11. package/dist/chunk-2RWB7RKE.js.map +1 -0
  12. package/dist/{chunk-AGZ7PJKY.js → chunk-36RVGZNY.js} +22 -5
  13. package/dist/chunk-36RVGZNY.js.map +1 -0
  14. package/dist/chunk-3AIHRXKO.js +72 -0
  15. package/dist/chunk-3AIHRXKO.js.map +1 -0
  16. package/dist/{chunk-S4SAZ7OD.js → chunk-3FMZGI7I.js} +12 -2
  17. package/dist/{chunk-S4SAZ7OD.js.map → chunk-3FMZGI7I.js.map} +1 -1
  18. package/dist/chunk-3GNJXKIT.js +198 -0
  19. package/dist/chunk-3GNJXKIT.js.map +1 -0
  20. package/dist/{chunk-UQUOVWBG.js → chunk-4K7TQHNP.js} +7 -7
  21. package/dist/{chunk-A36LQPHV.js → chunk-4LMUQMBH.js} +1 -1
  22. package/dist/{chunk-A36LQPHV.js.map → chunk-4LMUQMBH.js.map} +1 -1
  23. package/dist/{chunk-KXQ4UIP7.js → chunk-4USCZ2NI.js} +2 -2
  24. package/dist/chunk-4YOZGGTZ.js +247 -0
  25. package/dist/chunk-4YOZGGTZ.js.map +1 -0
  26. package/dist/chunk-62KNUYWD.js +111 -0
  27. package/dist/chunk-62KNUYWD.js.map +1 -0
  28. package/dist/{chunk-POUWHWID.js → chunk-6CMM6YCB.js} +3 -3
  29. package/dist/{chunk-POUWHWID.js.map → chunk-6CMM6YCB.js.map} +1 -1
  30. package/dist/{chunk-5MARFNSB.js → chunk-A5GKIG5O.js} +49 -30
  31. package/dist/chunk-A5GKIG5O.js.map +1 -0
  32. package/dist/{chunk-YFPY4ONH.js → chunk-AGMVASXZ.js} +4 -4
  33. package/dist/chunk-BF4XHEQK.js +116 -0
  34. package/dist/chunk-BF4XHEQK.js.map +1 -0
  35. package/dist/chunk-BFDQ4WNW.js +119 -0
  36. package/dist/chunk-BFDQ4WNW.js.map +1 -0
  37. package/dist/{chunk-P4NH7OUK.js → chunk-C2Q76BVM.js} +49 -50
  38. package/dist/chunk-C2Q76BVM.js.map +1 -0
  39. package/dist/chunk-CEXSOI5R.js +808 -0
  40. package/dist/chunk-CEXSOI5R.js.map +1 -0
  41. package/dist/{chunk-QSCPK4F5.js → chunk-E7SW44LM.js} +4 -11
  42. package/dist/chunk-E7SW44LM.js.map +1 -0
  43. package/dist/chunk-EDJWHDDL.js +33 -0
  44. package/dist/chunk-EDJWHDDL.js.map +1 -0
  45. package/dist/chunk-F3ED5WTR.js +13 -0
  46. package/dist/chunk-F3ED5WTR.js.map +1 -0
  47. package/dist/{chunk-K72RURN3.js → chunk-FVIGCDSV.js} +2 -2
  48. package/dist/chunk-FVIGCDSV.js.map +1 -0
  49. package/dist/{chunk-5K5W4S66.js → chunk-GTTUCOPD.js} +2 -2
  50. package/dist/{chunk-4ZZO6ULA.js → chunk-HDPUXS3Z.js} +19 -48
  51. package/dist/chunk-HDPUXS3Z.js.map +1 -0
  52. package/dist/{chunk-LEFIX6RS.js → chunk-HGGWCP7W.js} +31 -11
  53. package/dist/chunk-HGGWCP7W.js.map +1 -0
  54. package/dist/{chunk-ORWL5BSN.js → chunk-HGZEPQUT.js} +2 -2
  55. package/dist/chunk-HMWYAUA6.js +478 -0
  56. package/dist/chunk-HMWYAUA6.js.map +1 -0
  57. package/dist/{chunk-7QKHZQKW.js → chunk-IADZOXKN.js} +39 -6
  58. package/dist/chunk-IADZOXKN.js.map +1 -0
  59. package/dist/{chunk-7Q5FDF65.js → chunk-IE7P2BZE.js} +3 -3
  60. package/dist/{chunk-77TCKDEC.js → chunk-ILNIZ5I2.js} +788 -508
  61. package/dist/chunk-ILNIZ5I2.js.map +1 -0
  62. package/dist/{hosts-FWZOV26H.js → chunk-INTFHMU4.js} +79 -24
  63. package/dist/chunk-INTFHMU4.js.map +1 -0
  64. package/dist/{chunk-6E5R45ZO.js → chunk-J57UC3DD.js} +4 -4
  65. package/dist/{chunk-6E5R45ZO.js.map → chunk-J57UC3DD.js.map} +1 -1
  66. package/dist/chunk-JNJWBTU2.js +3497 -0
  67. package/dist/chunk-JNJWBTU2.js.map +1 -0
  68. package/dist/{chunk-7WU4OPLP.js → chunk-KM7RY2ZS.js} +5 -3
  69. package/dist/{chunk-7WU4OPLP.js.map → chunk-KM7RY2ZS.js.map} +1 -1
  70. package/dist/chunk-L6JEXB3E.js +293 -0
  71. package/dist/chunk-L6JEXB3E.js.map +1 -0
  72. package/dist/chunk-LRW6S53P.js +450 -0
  73. package/dist/chunk-LRW6S53P.js.map +1 -0
  74. package/dist/{chunk-UKY4CHNC.js → chunk-LXAYUOXI.js} +24 -11
  75. package/dist/chunk-LXAYUOXI.js.map +1 -0
  76. package/dist/{chunk-WJXLQXJY.js → chunk-MPZUYCAP.js} +4 -1
  77. package/dist/{chunk-WJXLQXJY.js.map → chunk-MPZUYCAP.js.map} +1 -1
  78. package/dist/chunk-NDGZDTSJ.js +393 -0
  79. package/dist/chunk-NDGZDTSJ.js.map +1 -0
  80. package/dist/{chunk-SJLTEINJ.js → chunk-OJNTCYQQ.js} +17 -1
  81. package/dist/chunk-OJNTCYQQ.js.map +1 -0
  82. package/dist/{chunk-OHRR5OYM.js → chunk-P3LFTKE7.js} +5 -10
  83. package/dist/chunk-P3LFTKE7.js.map +1 -0
  84. package/dist/{chunk-XZKD7DIF.js → chunk-RL5UUDT4.js} +3 -3
  85. package/dist/{chunk-XZKD7DIF.js.map → chunk-RL5UUDT4.js.map} +1 -1
  86. package/dist/{chunk-5C32RLTA.js → chunk-RVPYTUP4.js} +20 -5
  87. package/dist/chunk-RVPYTUP4.js.map +1 -0
  88. package/dist/{chunk-YVFXE7RR.js → chunk-SNNSAGMT.js} +7279 -2627
  89. package/dist/chunk-SNNSAGMT.js.map +1 -0
  90. package/dist/{chunk-WK7F3B2E.js → chunk-SO3XRZPX.js} +3 -3
  91. package/dist/{chunk-R5LCN54M.js → chunk-TC2WZLSC.js} +13 -17
  92. package/dist/{chunk-R5LCN54M.js.map → chunk-TC2WZLSC.js.map} +1 -1
  93. package/dist/{chunk-B7HUUJOK.js → chunk-TKPF35W6.js} +3 -3
  94. package/dist/{chunk-KXVP2VKA.js → chunk-U3IKUGRP.js} +32 -33
  95. package/dist/chunk-U3IKUGRP.js.map +1 -0
  96. package/dist/{chunk-AKWGE6JQ.js → chunk-UUGOUOVT.js} +37 -2
  97. package/dist/chunk-UUGOUOVT.js.map +1 -0
  98. package/dist/{chunk-2XLC3AEX.js → chunk-UXZONNEQ.js} +536 -510
  99. package/dist/chunk-UXZONNEQ.js.map +1 -0
  100. package/dist/{chunk-7ZRL2LBQ.js → chunk-V2LQLN5H.js} +6 -6
  101. package/dist/{chunk-NEFNKLBE.js → chunk-WFSPCCVW.js} +1536 -423
  102. package/dist/chunk-WFSPCCVW.js.map +1 -0
  103. package/dist/{chunk-27EPWVOY.js → chunk-WXA2BWTE.js} +7 -3
  104. package/dist/chunk-WXA2BWTE.js.map +1 -0
  105. package/dist/chunk-WYXUQGOL.js +191 -0
  106. package/dist/chunk-WYXUQGOL.js.map +1 -0
  107. package/dist/chunk-X5ZBP3IY.js +97 -0
  108. package/dist/chunk-X5ZBP3IY.js.map +1 -0
  109. package/dist/{chunk-MNXS2U45.js → chunk-ZDZERB6L.js} +206 -297
  110. package/dist/chunk-ZDZERB6L.js.map +1 -0
  111. package/dist/chunk-ZNNXRNFD.js +113 -0
  112. package/dist/chunk-ZNNXRNFD.js.map +1 -0
  113. package/dist/{chunk-FW75G2W4.js → chunk-ZURZHELF.js} +5 -5
  114. package/dist/{cli-D5OE3URZ.js → cli-E36SPKBW.js} +145 -64
  115. package/dist/{cli-D5OE3URZ.js.map → cli-E36SPKBW.js.map} +1 -1
  116. package/dist/{codex-event-PPNVRRDH.js → codex-event-ZO2GEFE6.js} +2 -2
  117. package/dist/{codex-host-2RJOJW2B.js → codex-host-KECJVTA2.js} +7 -6
  118. package/dist/codex-install-HQZDGFXW.js +436 -0
  119. package/dist/codex-install-HQZDGFXW.js.map +1 -0
  120. package/dist/{config-ZD4OB2DO.js → config-HY2E4GGW.js} +21 -17
  121. package/dist/doctor-I6XQEKWD.js +1323 -0
  122. package/dist/doctor-I6XQEKWD.js.map +1 -0
  123. package/dist/{env-proxy-XL4P73MZ.js → env-proxy-R6ZMLQTT.js} +6 -2
  124. package/dist/{ethersCompat-Df4a6QIZ-THAVUGIJ.js → ethersCompat-Df4a6QIZ-X6YZWAML.js} +3 -3
  125. package/dist/{fund-5ITKQGYF.js → fund-2QRO7OJL.js} +43 -37
  126. package/dist/{fund-5ITKQGYF.js.map → fund-2QRO7OJL.js.map} +1 -1
  127. package/dist/hook-command-2UBCSZG6.js +43 -0
  128. package/dist/hosts/claude/.claude-plugin/marketplace.json +2 -2
  129. package/dist/hosts/claude/tenjin/.claude-plugin/plugin.json +2 -2
  130. package/dist/hosts/claude/tenjin/hooks/register.tsx +51 -11
  131. package/dist/hosts/claude/tenjin/skills/tenjin-pay/SKILL.md +82 -0
  132. package/dist/hosts/claude/tenjin/types/index.d.ts +2 -1
  133. package/dist/hosts/codex/tenjin/.mcp.json +3 -0
  134. package/dist/hosts/codex/tenjin/hooks/hooks.json +51 -5
  135. package/dist/hosts-DVQJ32QC.js +38 -0
  136. package/dist/index.js +32 -11
  137. package/dist/index.js.map +1 -1
  138. package/dist/install-ILUX5C4A.js +107 -0
  139. package/dist/{install-identity-K7EJIQFP.js → install-identity-TZKGY6LQ.js} +11 -10
  140. package/dist/install-wallet-5M4OTYLX.js +281 -0
  141. package/dist/install-wallet-5M4OTYLX.js.map +1 -0
  142. package/dist/isows-native-Q2UDIVPT.js +9 -0
  143. package/dist/isows-native-Q2UDIVPT.js.map +1 -0
  144. package/dist/{mcp-3LIJSSJB.js → mcp-LE4DUS22.js} +785 -211
  145. package/dist/mcp-LE4DUS22.js.map +1 -0
  146. package/dist/{mine.wasm-6PIT3DK6.js → mine.wasm-QFAHIFPY.js} +2 -2
  147. package/dist/{mine.wasm-6PIT3DK6.js.map → mine.wasm-QFAHIFPY.js.map} +1 -1
  148. package/dist/{package-ZKQFDWLE.js → package-IJFGMWEV.js} +4 -2
  149. package/dist/passphrase-IFTDS3CU.js +44 -0
  150. package/dist/{paths-POPTXJO6.js → paths-XCSAKISU.js} +10 -2
  151. package/dist/{pay-WHBERZ3W.js → pay-WCG3IH4R.js} +29 -29
  152. package/dist/{payments-KVICEKD2.js → payments-HFPPWHTV.js} +15 -14
  153. package/dist/{payments-KVICEKD2.js.map → payments-HFPPWHTV.js.map} +1 -1
  154. package/dist/plugin-registration-PZFI5GZW.js +68 -0
  155. package/dist/{redact-6W23GGJC.js → redact-D7ASVWKL.js} +2 -2
  156. package/dist/runtime-UZOKSUZX.js +1321 -0
  157. package/dist/runtime-UZOKSUZX.js.map +1 -0
  158. package/dist/runtime-fetch-ZSSSK72Y.js +23 -0
  159. package/dist/runtime-layout-WIDILZ6K.js +25 -0
  160. package/dist/{send-7G7Y7DLN.js → send-GCVEAQKL.js} +24 -22
  161. package/dist/{send-7G7Y7DLN.js.map → send-GCVEAQKL.js.map} +1 -1
  162. package/dist/{status-OF7RH5HM.js → status-HCVAOCN7.js} +55 -25
  163. package/dist/status-HCVAOCN7.js.map +1 -0
  164. package/dist/{status-line-XOUE6MPL.js → status-line-OPCXDHL2.js} +10 -9
  165. package/dist/{status-line-XOUE6MPL.js.map → status-line-OPCXDHL2.js.map} +1 -1
  166. package/dist/uninstall-BAWRBXXQ.js +481 -0
  167. package/dist/uninstall-BAWRBXXQ.js.map +1 -0
  168. package/dist/update-CACXLQLR.js +56 -0
  169. package/dist/update-CACXLQLR.js.map +1 -0
  170. package/dist/{usdc-OGOGEHV2.js → usdc-VG4CIOUK.js} +6 -8
  171. package/dist/usdc-VG4CIOUK.js.map +1 -0
  172. package/dist/{viemAdapter-By13KInL-S3DA7DFW.js → viemAdapter-By13KInL-DOFTEIJV.js} +3 -3
  173. package/dist/viemAdapter-By13KInL-DOFTEIJV.js.map +1 -0
  174. package/dist/wallet-QL4UUXEZ.js +55 -0
  175. package/dist/wallet-QL4UUXEZ.js.map +1 -0
  176. package/dist/wallet-kdf-worker.mjs +8 -8
  177. package/docs/agent-permissions.md +50 -28
  178. package/docs/safety-model.md +1 -1
  179. package/docs/troubleshooting.md +72 -1
  180. package/package.json +17 -4
  181. package/scripts/installers/install.ps1 +67 -0
  182. package/scripts/installers/install.sh +68 -0
  183. package/dist/_esm-C5CRWCYU.js +0 -3737
  184. package/dist/_esm-C5CRWCYU.js.map +0 -1
  185. package/dist/ccip-NLCSCHKI.js +0 -19
  186. package/dist/chunk-27EPWVOY.js.map +0 -1
  187. package/dist/chunk-2XLC3AEX.js.map +0 -1
  188. package/dist/chunk-4ZZO6ULA.js.map +0 -1
  189. package/dist/chunk-5C32RLTA.js.map +0 -1
  190. package/dist/chunk-5IEP5EGE.js +0 -5332
  191. package/dist/chunk-5IEP5EGE.js.map +0 -1
  192. package/dist/chunk-5MARFNSB.js.map +0 -1
  193. package/dist/chunk-77TCKDEC.js.map +0 -1
  194. package/dist/chunk-7EKYXMUO.js +0 -7536
  195. package/dist/chunk-7EKYXMUO.js.map +0 -1
  196. package/dist/chunk-7QKHZQKW.js.map +0 -1
  197. package/dist/chunk-AGZ7PJKY.js.map +0 -1
  198. package/dist/chunk-AKWGE6JQ.js.map +0 -1
  199. package/dist/chunk-BL3332HQ.js +0 -7611
  200. package/dist/chunk-BL3332HQ.js.map +0 -1
  201. package/dist/chunk-D65GNPS3.js.map +0 -1
  202. package/dist/chunk-EGELTSPU.js +0 -2865
  203. package/dist/chunk-EGELTSPU.js.map +0 -1
  204. package/dist/chunk-GA7JETVM.js +0 -150
  205. package/dist/chunk-GA7JETVM.js.map +0 -1
  206. package/dist/chunk-I3EQFHCD.js +0 -175
  207. package/dist/chunk-I3EQFHCD.js.map +0 -1
  208. package/dist/chunk-K3I7C2MO.js +0 -1185
  209. package/dist/chunk-K3I7C2MO.js.map +0 -1
  210. package/dist/chunk-K72RURN3.js.map +0 -1
  211. package/dist/chunk-KXVP2VKA.js.map +0 -1
  212. package/dist/chunk-LEFIX6RS.js.map +0 -1
  213. package/dist/chunk-MNXS2U45.js.map +0 -1
  214. package/dist/chunk-NEFNKLBE.js.map +0 -1
  215. package/dist/chunk-OHRR5OYM.js.map +0 -1
  216. package/dist/chunk-P4NH7OUK.js.map +0 -1
  217. package/dist/chunk-QSCPK4F5.js.map +0 -1
  218. package/dist/chunk-SJLTEINJ.js.map +0 -1
  219. package/dist/chunk-TTNESUPQ.js.map +0 -1
  220. package/dist/chunk-UKY4CHNC.js.map +0 -1
  221. package/dist/chunk-V6BSF6OC.js +0 -260
  222. package/dist/chunk-V6BSF6OC.js.map +0 -1
  223. package/dist/chunk-YVFXE7RR.js.map +0 -1
  224. package/dist/codex-install-UUZ6QMBQ.js +0 -221
  225. package/dist/codex-install-UUZ6QMBQ.js.map +0 -1
  226. package/dist/doctor-KBR34Q4B.js +0 -601
  227. package/dist/doctor-KBR34Q4B.js.map +0 -1
  228. package/dist/hook-command-4TYCHHRL.js +0 -39
  229. package/dist/hosts-FWZOV26H.js.map +0 -1
  230. package/dist/install-XWGE4Q7L.js +0 -77
  231. package/dist/install-wallet-XQ6XFZV4.js +0 -117
  232. package/dist/install-wallet-XQ6XFZV4.js.map +0 -1
  233. package/dist/mcp-3LIJSSJB.js.map +0 -1
  234. package/dist/plugin-registration-5TIA564H.js +0 -54
  235. package/dist/status-OF7RH5HM.js.map +0 -1
  236. package/dist/uninstall-JXUAFNDB.js +0 -158
  237. package/dist/uninstall-JXUAFNDB.js.map +0 -1
  238. package/dist/update-ZKUERSO2.js +0 -44
  239. package/dist/wallet-2HA6W4R4.js +0 -43
  240. /package/dist/{_esm-MEXZI5DL.js.map → _esm-BIN7VY2L.js.map} +0 -0
  241. /package/dist/{alive-J64H46HI.js.map → alive-GSOWKUOY.js.map} +0 -0
  242. /package/dist/{ccip-7RMRLAGV.js.map → auto-update-Y24UL56V.js.map} +0 -0
  243. /package/dist/{ccip-NLCSCHKI.js.map → ccip-DHDFKTQV.js.map} +0 -0
  244. /package/dist/{chunk-UQUOVWBG.js.map → chunk-4K7TQHNP.js.map} +0 -0
  245. /package/dist/{chunk-KXQ4UIP7.js.map → chunk-4USCZ2NI.js.map} +0 -0
  246. /package/dist/{chunk-YFPY4ONH.js.map → chunk-AGMVASXZ.js.map} +0 -0
  247. /package/dist/{chunk-5K5W4S66.js.map → chunk-GTTUCOPD.js.map} +0 -0
  248. /package/dist/{chunk-ORWL5BSN.js.map → chunk-HGZEPQUT.js.map} +0 -0
  249. /package/dist/{chunk-7Q5FDF65.js.map → chunk-IE7P2BZE.js.map} +0 -0
  250. /package/dist/{chunk-WK7F3B2E.js.map → chunk-SO3XRZPX.js.map} +0 -0
  251. /package/dist/{chunk-B7HUUJOK.js.map → chunk-TKPF35W6.js.map} +0 -0
  252. /package/dist/{chunk-7ZRL2LBQ.js.map → chunk-V2LQLN5H.js.map} +0 -0
  253. /package/dist/{chunk-FW75G2W4.js.map → chunk-ZURZHELF.js.map} +0 -0
  254. /package/dist/{codex-event-PPNVRRDH.js.map → codex-event-ZO2GEFE6.js.map} +0 -0
  255. /package/dist/{codex-host-2RJOJW2B.js.map → codex-host-KECJVTA2.js.map} +0 -0
  256. /package/dist/{config-ZD4OB2DO.js.map → config-HY2E4GGW.js.map} +0 -0
  257. /package/dist/{env-proxy-XL4P73MZ.js.map → env-proxy-R6ZMLQTT.js.map} +0 -0
  258. /package/dist/{ethersCompat-Df4a6QIZ-THAVUGIJ.js.map → ethersCompat-Df4a6QIZ-X6YZWAML.js.map} +0 -0
  259. /package/dist/{hook-command-4TYCHHRL.js.map → hook-command-2UBCSZG6.js.map} +0 -0
  260. /package/dist/{install-XWGE4Q7L.js.map → hosts-DVQJ32QC.js.map} +0 -0
  261. /package/dist/{install-identity-K7EJIQFP.js.map → install-ILUX5C4A.js.map} +0 -0
  262. /package/dist/{package-ZKQFDWLE.js.map → install-identity-TZKGY6LQ.js.map} +0 -0
  263. /package/dist/{paths-POPTXJO6.js.map → package-IJFGMWEV.js.map} +0 -0
  264. /package/dist/{pay-WHBERZ3W.js.map → passphrase-IFTDS3CU.js.map} +0 -0
  265. /package/dist/{plugin-registration-5TIA564H.js.map → paths-XCSAKISU.js.map} +0 -0
  266. /package/dist/{redact-6W23GGJC.js.map → pay-WCG3IH4R.js.map} +0 -0
  267. /package/dist/{update-ZKUERSO2.js.map → plugin-registration-PZFI5GZW.js.map} +0 -0
  268. /package/dist/{usdc-OGOGEHV2.js.map → redact-D7ASVWKL.js.map} +0 -0
  269. /package/dist/{viemAdapter-By13KInL-S3DA7DFW.js.map → runtime-fetch-ZSSSK72Y.js.map} +0 -0
  270. /package/dist/{wallet-2HA6W4R4.js.map → runtime-layout-WIDILZ6K.js.map} +0 -0
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/lib/permissions.ts"],"sourcesContent":["/**\n * The recommended HARNESS permission allowlist: the exact rule lines an operator\n * pastes into Claude Code (or an equivalent harness) so auto mode stops denying\n * the free Tenjin verbs, and so the one paying verb is cleared deliberately\n * rather than by accident.\n *\n * This is a HARNESS-side allowlist (which shell commands the agent may run at\n * all). It is NOT the CLI's spend policy and shares nothing with it: the shipped\n * `allowlistCreators` config key gates WHO you may pay, this file gates WHICH\n * COMMANDS the harness will run without a prompt. The two are deliberately kept\n * apart in name and in code — clearing `Bash(tenjin buy:*)` here never raises a\n * spend cap. That is a claim about this file, NOT a claim that the spend policy\n * stops an allowlisted `buy`: `--yes` is an ordinary flag on an allowlisted verb\n * and `confirmSpend` returns true on it before any TTY check\n * (src/commands/buy.ts), so under CONFIG_DEFAULTS nothing denies. See\n * OPT_IN_ALLOWLIST's note for the walk-through.\n *\n * These are static, shipped constants on purpose: there is NO config key for\n * them. An operator-editable \"which commands may run\" list stored next to the\n * spend policy would be a second, weaker copy of a control the harness already\n * owns, and a CLI that could widen its own permission grant is exactly the shape\n * this file exists to avoid.\n *\n * Scope: `tenjin mcp` exposes the same command cores over MCP, where the harness\n * gates TOOLS, not Bash lines. These rules say nothing about that surface, which\n * is why `tenjin mcp` is itself never recommended here: clearing it would route\n * around every rule below. MCP_CAVEAT names the tools to leave gated for an\n * operator who runs the server anyway.\n *\n * LIMIT OF A PREFIX RULE, read this before adding an entry: the rule constrains\n * the VERB and nothing else. `addGlobalFlags` (src/cli.ts) puts `--json`,\n * `--timeout`, and `--base-url` on every leaf command, so every rule below also\n * clears `--base-url <url>` in trailing position. `--base-url` is validated as a\n * URL and nothing more, and it wins settings precedence, so it re-points the\n * trust boundary itself: the `search` question goes to that host, `doctor` probes\n * it, and `assertOnBaseOrigin` only checks that a resource URL shares an origin\n * with the CONFIGURED base, so an attacker-controlled pair satisfies the pin. No\n * prefix syntax expresses \"this verb but not that flag\", so the mitigation is\n * disclosure rather than a narrower rule: FLAG_CAVEAT rides the `--json` payload\n * and docs/agent-permissions.md, every human surface points at that page, and the\n * skills tell the agent never to pass `--base-url` on an allowlisted verb. Pinning\n * the paying path to a constant origin instead is the real fix and is an\n * x402/payments-semantics change, tracked separately.\n */\n\nimport type { PublishMode } from './config';\n\n/** One pasteable allowlist rule plus why it is safe (or what it costs). */\nexport interface AllowlistEntry {\n /** The exact line to add to the harness permission allowlist. */\n rule: string;\n /** The verb it clears. */\n command: string;\n /** Why it is safe to pre-clear, or what the operator is opting into. */\n note: string;\n}\n\n/** A verb deliberately kept OUT of the recommended allowlist, and why. */\nexport interface ExcludedVerb {\n command: string;\n reason: string;\n}\n\n/**\n * FREE verbs: they CANNOT SPEND. That is the whole definition of this tier, and\n * it is deliberately narrower than the older \"no wallet, no signing, no\n * payment\" — which stopped being true the moment `read` gained the ability to\n * recover an owned piece. `read` signs, with a P-256 delegation, and mints one\n * with a wallet signature when none is live; what it cannot do is produce the\n * secp256k1/EIP-712 signature a payment authorization needs (wrong curve), which\n * is test-pinned by its import graph never reaching the payment module. Money\n * stays out of reach; a signature, and the keystore access behind minting one,\n * no longer do, so the tier says what it means. `doctor` decrypts locally to\n * check the wallet still opens.\n *\n * What the tier does NOT claim, because it is not true: that the read scope\n * limits what a leaked delegation is worth. Scope is enforced only on the request\n * shape that carries both a session signature and the delegation header; the same\n * delegation replayed as a plain `SIGN-IN-WITH-X` takes a different server path\n * where no scope logic runs. So a session file is a wallet-derived credential\n * with the authority of the wallet behind it, and the mitigations that actually\n * hold are the ones in this repo: it is 0600, short-lived (≤24h, server-clamped),\n * bound to the origin it was minted for, and never presented off that origin.\n * Treat \"read is allowlisted\" as \"read may transmit that credential to the\n * configured origin\", and see FLAG_CAVEAT for why the configured origin is not\n * automatically the one you configured.\n *\n * Not all of them are read-only, and the difference is disclosed rather than\n * papered over — `search` POSTs the (generalized, anonymous) question off-machine\n * and records it locally, `outcome` POSTs a report that moves the marketplace's\n * reuse signal (both unauthenticated remote writes), and `read` writes locally,\n * saving a delivered piece to the library, and `doctor` decrypts the keystore\n * locally to check it opens. Pre-clearing them is defensible because they cost\n * nothing and none of it leaves the machine; calling them read-only to justify it\n * would not be.\n *\n * Rules are PREFIX rules: `Bash(tenjin search:*)` clears commands that start with\n * `tenjin search` and nothing else. The narrow `wallet show` / `wallet balance` /\n * The `config get` form is deliberate: a `Bash(tenjin wallet:*)`\n * or `Bash(tenjin config:*)` rule would silently swallow `wallet create` and\n * `config set`, and `config set` can raise the spend caps.\n *\n * Two known gaps, both fail-closed (denied, never wrongly allowed):\n * - Bare `tenjin config` (runConfigList) is as read-only as `config get`, but no\n * prefix rule reaches it without also covering `config set`, so it stays out.\n * Use `tenjin config get <key>`, which is a different supported command rather\n * than a reworded one.\n * - Group-level flag forms like `tenjin wallet --json show` are not covered.\n * Put global flags AFTER the leaf verb (`tenjin wallet show --json`); the\n * CLI parses either, and only the trailing form matches these rules.\n */\nexport const ALWAYS_SAFE_ALLOWLIST: readonly AllowlistEntry[] = [\n {\n rule: 'Bash(tenjin search:*)',\n command: 'tenjin search',\n note:\n 'Free anonymous marketplace search. No wallet, no signing, no payment. ' +\n 'Not read-only: it POSTs the generalized question off-machine and records ' +\n 'the search locally.',\n },\n {\n rule: 'Bash(tenjin wallet fund:*)',\n command: 'tenjin wallet fund',\n note:\n 'Owner call (2026-08-12): free on both surfaces, because the command just opens the ' +\n 'fund modal. Minting moves no money: the destination is server-pinned to the wallet ' +\n 'that signed, the CLI refuses any checkout host but pay.coinbase.com, and payment ' +\n 'happens behind Coinbase\\u2019s own human gate. The usual --base-url caveat does not ' +\n 'apply: fund is pinned to the production origin and takes no override from flag, ' +\n 'env, or config.',\n },\n {\n rule: 'Bash(tenjin inspect:*)',\n command: 'tenjin inspect',\n note: 'Free pre-purchase card and preview. Never signs, never pays, never saves.',\n },\n {\n rule: 'Bash(tenjin read:*)',\n command: 'tenjin read',\n note:\n 'Free-only delivery: free pieces, local-library re-reads, and pieces this ' +\n 'wallet already owns. Cannot spend: the payment module is absent from its ' +\n 'import graph, and the key it signs with is a P-256 delegation, the wrong ' +\n 'curve to authorize a payment. OPENS THE KEYSTORE (one wallet signature) ' +\n 'when an owned piece is not on this machine and no session key is live, ' +\n 'minting the same ≤24h read-scoped delegation `publish` and `edit` mint; ' +\n 'every later owned read reuses it and asks for nothing. TRANSMITS A ' +\n 'CREDENTIAL: that wallet-derived delegation goes to the server on a cold ' +\n '402. It is minted and presented only for the origin of the piece being ' +\n 'read, and never for a second origin while one for another is cached, ' +\n 'which is what bounds a stray `--base-url`; no scope on it limits what a ' +\n 'holder could do with it. Not read-only: a freshly delivered piece is ' +\n 'saved to the library.',\n },\n {\n rule: 'Bash(tenjin outcome:*)',\n command: 'tenjin outcome',\n note:\n 'Free honest outcome report on a past search. No wallet, no payment. ' +\n 'Not read-only: it POSTs a report that moves the marketplace reuse signal.',\n },\n {\n rule: 'Bash(tenjin doctor:*)',\n command: 'tenjin doctor',\n note:\n 'Local environment and API reachability diagnostics. Decrypts the wallet ' +\n 'locally to check it still opens; signs nothing and sends nothing.',\n },\n {\n rule: 'Bash(tenjin wallet show:*)',\n command: 'tenjin wallet show',\n note: 'Prints the wallet address and key source. Never prints the key.',\n },\n {\n rule: 'Bash(tenjin wallet balance:*)',\n command: 'tenjin wallet balance',\n note: 'Read-only USDC balance query on Base.',\n },\n {\n rule: 'Bash(tenjin config get:*)',\n command: 'tenjin config get',\n note:\n 'Reads one effective config value. `config set` is excluded on purpose. ' +\n 'Note `config get rpcUrl` returns your RPC URL, which commonly embeds a ' +\n 'provider API key: no wallet secret, but a credential-adjacent read.',\n },\n];\n\n/**\n * The verbs offered as EXPLICIT opt-in lines rather than shipped in the safe set:\n * the one that spends, and the one that opens the keystore.\n *\n * Read the buy note carefully before pasting the line: on the DEFAULT config this\n * rule authorizes unattended spending up to the wallet balance. Walking\n * `--yes` clears confirmation only. Zero daily budget refuses positive payments,\n * finite budgets cap cumulative exposure, and `none` explicitly removes that cap.\n */\nexport const OPT_IN_ALLOWLIST: readonly AllowlistEntry[] = [\n {\n rule: 'Bash(tenjin buy:*)',\n command: 'tenjin buy',\n note:\n 'SPENDS USDC on Base, unrefundably. This authorizes UNATTENDED purchases: ' +\n '`--yes` is an ordinary flag on the same allowlisted verb and it clears the ' +\n 'confirm gate only. Manual purchases do not obey maxAutoSpend or sessionBudget; those limits apply only to automatic router spending. ' +\n 'This permission never raises a spend cap, but those automatic caps do not bound this verb. Use --max-price for an explicit per-purchase ceiling and require consent for the quoted purchase.',\n },\n {\n rule: 'Bash(tenjin pay:*)',\n command: 'tenjin pay',\n note:\n 'SPENDS USDC on Base, unrefundably. Only for explicit user-requested payments with consent for the live quote; never an autonomous router-refusal workaround. Automatic router limits do not apply. Registry lookup failures or listed-term mismatches require --ignore-warnings ' +\n 'for that invocation, and --yes confirms payment only. Both still obey an explicit --max-price, ' +\n 'balance and destination checks. maxAutoSpend and sessionBudget apply only to automatic router spending. Every paid call can spend again.',\n },\n];\n\n/**\n * The one rule that is neither always-safe nor a standing opt-in: it exists only\n * while `publish.mode` is `auto` or `full-auto`.\n *\n * The mode IS the consent. An operator who set auto has already said a clean\n * publish should proceed without asking; leaving the harness prompt in front of\n * it asks the same question a second time, in a place the mode cannot answer,\n * and the agent that hits it does the only safe thing and stops. That was the\n * observed failure: a session ran `tenjin config get publish.mode` mid-publish to\n * discover it had permission it had already been given (#161).\n *\n * NOT part of {@link recommendedRules}, and not a tier an operator picks from.\n * There is no line to paste and no flag that adds it: `install` writes it when\n * the mode it just settled is auto or full-auto, takes it back when the mode is\n * review, and `uninstall` reclaims it like every other rule this CLI wrote.\n */\nexport const PUBLISH_MODE_ALLOWLIST: readonly AllowlistEntry[] = [\n {\n rule: 'Bash(tenjin publish:*)',\n command: 'tenjin publish',\n note:\n 'PUBLISHES PUBLICLY under your identity, and is cleared only while publish.mode is ' +\n 'auto or full-auto: the mode is the consent, and the harness prompt would ask for it ' +\n 'twice. Three things it clears that the free tier never did. It OPENS THE KEYSTORE: ' +\n 'publish always resolves a signer, and with no usable session it mints one at ' +\n 'read+write scope, which is strictly broader than the read-only key `tenjin read` ' +\n 'mints to recover an owned piece. It publishes the contents ' +\n 'of ANY REGULAR LOCAL FILE the agent can read, gated only by the heuristic scan. And it is a ' +\n 'PREFIX rule, so it pins the verb and not the flags: `--base-url` rides it (see the ' +\n 'flag caveat), and `--yes` is an ordinary flag on the same verb that clears exactly ' +\n 'the WARN findings auto stopped on, so a re-run collapses auto into full-auto with ' +\n 'nobody asked. The local scan is warn-only now and every finding routes through the ' +\n 'same consent flow this mode already governs; what still refuses a publish outright is ' +\n 'the SERVER’s ingest gate (vendor tokens, private keys, seed phrases, DB passwords, ' +\n 'bearer headers), which no mode and no flag clears. The skills hold the rest of that ' +\n 'line. Set publish.mode back to review and the rule is retracted.',\n },\n {\n rule: 'Bash(tenjin edit:*)',\n command: 'tenjin edit',\n note:\n 'Updates posts your wallet ALREADY OWNS: reprices, refreshes an as-of date, repairs an ' +\n 'answer card, and flips status both ways, so it CAN PROMOTE A DRAFT TO PUBLISHED under ' +\n 'this same gate (promotion re-runs the block-tier secret scan over the stored body). ' +\n 'Owner-scoped on both legs (GET and PUT /api/posts/<id> are signed and owner-only), ' +\n 'spends nothing, moves no keys, and mints no new posts: a narrower blast radius than ' +\n 'the publish rule beside it, though promotion means existing drafts can go public. It ' +\n 'rides the same mode for the same reason: edit runs the identical publish.mode consent ' +\n 'gate in the CLI (lib/consent.ts needsConfirmation), so a mode that publishes ' +\n 'unattended and then cannot fix its own post\\u2019s price is the asymmetry the mode ' +\n 'exists to remove. It opens the keystore on the same terms as the publish rule beside ' +\n 'it, and takes the same prefix-rule caveats. Removed by the same return to review.',\n },\n];\n\n/** The mode-gated rules in effect for `mode`; empty on review. */\nexport function modeGatedAllowlist(mode: PublishMode): AllowlistEntry[] {\n return mode === 'review' ? [] : PUBLISH_MODE_ALLOWLIST.map((e) => ({ ...e }));\n}\n\n/**\n * Verbs that must NEVER appear in the recommended allowlist, with the reason each\n * one is a human decision. `tenjin wallet send` is the wallet escape hatch\n * (tenjin-agent #40) and heads this list: it moves USDC to an arbitrary address,\n * outside the spend policy that bounds `buy`. Naming it here is load-bearing even\n * in versions where the verb does not exist yet — the exclusion ships before the\n * verb does.\n *\n * `tenjin publish` stays on this list under its own terms: nothing RECOMMENDS it,\n * and no line here or on the doc page adds it. {@link PUBLISH_MODE_ALLOWLIST} is\n * not a recommendation — it is what one specific operator choice already means.\n */\nexport const NEVER_ALLOWLISTED: readonly ExcludedVerb[] = [\n {\n command: 'tenjin wallet send',\n reason:\n 'Moves USDC out of the wallet to an arbitrary address (the escape hatch, #40). ' +\n 'Irreversible and not bounded by the buy spend policy. Always a human decision.',\n },\n {\n command: 'tenjin publish',\n reason:\n 'Puts your content on a public marketplace under your identity. Never pre-cleared by the ' +\n 'free tier or an opt-in line: the only thing that clears it is `publish.mode` auto or ' +\n 'full-auto, which is the same human decision said once instead of twice (see ' +\n 'PUBLISH_MODE_ALLOWLIST). Back on review, `install` takes the rule away again.',\n },\n {\n command: 'tenjin edit',\n reason:\n 'Write-capable despite the no-flag form reading as a pure show: it edits live posts ' +\n 'and answer cards under your identity, and moves prices. A prefix rule pins the verb, ' +\n 'not the flags, so no rule can clear the read half without clearing the write half. ' +\n 'Never pre-cleared as a recommendation: like `tenjin publish`, the only thing that ' +\n 'clears it is `publish.mode` auto or full-auto, whose consent gate it already shares ' +\n '(see PUBLISH_MODE_ALLOWLIST). Back on review, `install` takes the rule away again.',\n },\n {\n command: 'tenjin delete',\n reason:\n 'Destroys a published piece. It is the one write verb `publish.mode` deliberately does NOT ' +\n 'carry: the mode is consent to publish, and reading it as consent to destroy would let one ' +\n 'decision authorize a different, irreversible one. So no mode ever clears this rule, and ' +\n 'the CLI confirms on every run regardless — a prefix rule here would only remove the ' +\n 'harness prompt in front of a command that asks its own question anyway. Reach for ' +\n '`tenjin edit --status draft` when the piece should come down reversibly.',\n },\n {\n command: 'tenjin wallet create',\n reason: 'Creates the payment credential; a stray run is a wallet you did not mean to have.',\n },\n {\n command: 'tenjin config set',\n reason:\n 'Can raise maxAutoSpend / sessionBudget, i.e. widen the agent’s own spend policy — ' +\n 'and, through shelfBypassSecret + baseUrl, put the machine in team mode, where a publish ' +\n 'skips the scan’s warn tier (except secret-assignment, and hex32-value, the warn form a ' +\n 'block-tier check demotes to) and prices at 0. It also writes ' +\n 'publish.ackServerWarnings on, the most direct consent-loosening write on this verb: ' +\n 'it lets one --yes cover the marketplace’s own scan findings, which no payload had ' +\n 'rendered when that yes was given.',\n },\n {\n command: 'tenjin install',\n reason: 'Writes into harness config and skills directories.',\n },\n {\n command: 'tenjin mcp',\n reason:\n 'Long-running server that re-exposes every command core over stdio; ' +\n 'clearing it would indirectly clear everything above.',\n },\n {\n command: 'tenjin update',\n reason:\n 'Replaces the tenjin binary the agent then runs, with whatever npm serves ' +\n 'next. Which build an agent executes is an operator decision, not something ' +\n 'a rule pre-clears. `--check` only reports, but a prefix rule pins the verb, ' +\n 'not the flags.',\n },\n];\n\n/**\n * The flag-surface caveat. A prefix rule pins the verb, never the flags, and the\n * flag that matters is `--base-url`: it is accepted on every leaf, validated only\n * as a URL, and it wins settings precedence, so it moves the destination of every\n * allowlisted verb. Printed with the rules everywhere they are printed, because\n * an operator who only reads the verb list would never learn it.\n */\nexport const FLAG_CAVEAT: readonly string[] = [\n 'Caveat: a prefix rule pins the VERB, not the flags. Every line above also clears',\n '`--base-url <url>` on that verb, which re-points where the question, the probe, the',\n 'session key `read` mints and presents, and (for buy) the signature and payment go.',\n 'Signed and credential-bearing traffic is NOT confined to the paying verb: `read` is in',\n 'the safe tier and both mints a wallet-derived delegation and transmits it, which is why',\n 'that delegation is bound to the origin it was minted for and refused elsewhere.',\n 'Allowlist these verbs only if you are content for the agent to choose the destination',\n 'host, and set the base URL in config instead of letting it be an argument. The skills',\n 'tell agents never to pass --base-url on an allowlisted verb, but that is a convention,',\n 'not an enforced boundary.',\n 'This covers the two rules your publish.mode carries as well, and bites hardest there:',\n '`tenjin publish --base-url <host>` is cleared by default on auto, and it signs against',\n 'the host it is given.',\n];\n\n/**\n * The MCP caveat. `tenjin mcp` is never recommended as a Bash rule, but an\n * operator who registers the server anyway is on a different permission surface\n * (tools, not command strings) where three excluded verbs come back.\n */\nexport const MCP_CAVEAT: readonly string[] = [\n 'Note the asymmetry: publish.mode writes the Bash rules for `publish` and `edit`, and',\n 'deliberately does not touch the MCP tool grants below. The mode is a CLI-side consent',\n 'gate, and nothing reads it on the MCP surface, so clearing those tools would hand out',\n 'the same authority with none of the same gate. Aligning the two is tracked separately.',\n 'Running the local MCP server (`tenjin mcp`) instead? That is a different permission',\n 'surface: the harness gates TOOLS there, and these Bash rules do not apply. Leave',\n '`mcp__tenjin__tenjin_publish`, `mcp__tenjin__tenjin_edit`,',\n '`mcp__tenjin__tenjin_delete`, and `mcp__tenjin__tenjin_wallet` gated. `tenjin_buy` is',\n 'the same opt-in decision as the buy line above. `tenjin_delete` is the one whose own',\n 'core still confirms even if you clear it: it never reads publish.mode.',\n];\n\n/** The machine shape emitted by `tenjin doctor --json` and `tenjin install --json`. */\nexport interface RecommendedPermissions {\n alwaysSafe: AllowlistEntry[];\n optIn: AllowlistEntry[];\n neverAllowlisted: ExcludedVerb[];\n /**\n * Rules the CURRENT publish.mode carries, empty on review. Separate from the\n * three tiers above because it is not a recommendation to weigh: it is what\n * this machine's mode already means, so a consumer that renders it beside the\n * others would be offering a choice that has been made.\n */\n modeGated: AllowlistEntry[];\n /**\n * Whether any harness on THIS machine can carry the rules above. They are\n * `Bash(...)` lines, Claude Code's grammar; a reader that took this payload\n * for a description of a Codex-only machine concluded `publish.mode=auto`\n * was in force while Codex was rejecting `tenjin publish` before the CLI ran\n * (tenjin-agent#342). The document still ships for a harness you have not\n * installed yet, so check this before treating any rule below as granted.\n */\n effective: boolean;\n /** Caveats that qualify the rules above; never omit them when rendering. */\n caveats: { flags: string[]; mcp: string[] };\n}\n\n/**\n * `mode` defaults to the shipped `review`, i.e. no mode-gated rules.\n * `effective` defaults to FALSE, so a caller that has not established such a\n * harness cannot have the payload claim one by omission.\n */\nexport function recommendedPermissions(\n mode: PublishMode = 'review',\n effective = false,\n): RecommendedPermissions {\n return {\n alwaysSafe: ALWAYS_SAFE_ALLOWLIST.map((e) => ({ ...e })),\n optIn: OPT_IN_ALLOWLIST.map((e) => ({ ...e })),\n neverAllowlisted: NEVER_ALLOWLISTED.map((e) => ({ ...e })),\n modeGated: modeGatedAllowlist(mode),\n effective,\n caveats: { flags: [...FLAG_CAVEAT], mcp: [...MCP_CAVEAT] },\n };\n}\n\n/** Every rule this module recommends adding (safe + opt-in). */\nexport function recommendedRules(): string[] {\n return [...ALWAYS_SAFE_ALLOWLIST, ...OPT_IN_ALLOWLIST].map((e) => e.rule);\n}\n\n/**\n * The permission caveats' one home. `doctor` used to print the whole thing —\n * nine rules, both opt-in notes, every exclusion, the flag caveat and the MCP\n * caveat, ~60 lines ahead of the check list it was actually run for. No doctor\n * command in the wider ecosystem carries security prose, and an operator reading\n * a wall of it in a terminal cannot paste from it, search it, or link a colleague\n * to a section. The page can do all three, so it is where the caveats live and\n * where every human surface points; `--json` still carries them as data\n * (`recommendedPermissions`), which is what an agent reads.\n */\nexport const PERMISSIONS_DOC_URL =\n 'https://github.com/BackTrackCo/tenjin-agent/blob/main/docs/agent-permissions.md';\n\n/**\n * The rules the current mode is missing, or null when it needs none. This one\n * DOES name them: they are not a tier to weigh and paste, they\n * are lines that should already be in the operator's settings file, and an\n * operator whose agent is being prompted for work the mode said not to ask about\n * needs to see exactly which rules are missing.\n *\n * CONSULTS THE MACHINE. Rendering from the mode alone told operators to add\n * rules their settings file already had, and named a remedy that in one case\n * would not have written anything — a nag that is wrong twice over on a line\n * whose whole job is to prevent an agent stalling on a prompt (#161).\n */\nexport function modeGatedPointer(\n mode: PublishMode,\n /** The mode-gated rules this machine is actually MISSING. Empty renders nothing. */\n missing: readonly string[],\n /**\n * The command that would fix it. `tenjin install` for the ordinary case; a\n * mode coming from TENJIN_PUBLISH_MODE needs `config set` instead, because\n * install resolves the mode from the global file and would write nothing.\n */\n remedy = 'tenjin install',\n): string | null {\n if (modeGatedAllowlist(mode).length === 0 || missing.length === 0) return null;\n return `publish.mode=${mode} also needs ${missing.join(' and ')} in your harness allowlist, or it will prompt anyway; \\`${remedy}\\` writes them.`;\n}\n"],"mappings":";;;AAyOO,IAAM,yBAAoD;AAAA,EAC/D;AAAA,IACE,MAAM;AAAA,IACN,SAAS;AAAA,IACT,MACE;AAAA,EAeJ;AAAA,EACA;AAAA,IACE,MAAM;AAAA,IACN,SAAS;AAAA,IACT,MACE;AAAA,EAWJ;AACF;AAGO,SAAS,mBAAmB,MAAqC;AACtE,SAAO,SAAS,WAAW,CAAC,IAAI,uBAAuB,IAAI,CAAC,OAAO,EAAE,GAAG,EAAE,EAAE;AAC9E;AAwLO,IAAM,sBACX;AAcK,SAAS,iBACd,MAEA,SAMA,SAAS,kBACM;AACf,MAAI,mBAAmB,IAAI,EAAE,WAAW,KAAK,QAAQ,WAAW,EAAG,QAAO;AAC1E,SAAO,gBAAgB,IAAI,eAAe,QAAQ,KAAK,OAAO,CAAC,2DAA2D,MAAM;AAClI;","names":[]}
1
+ {"version":3,"sources":["../src/lib/permissions.ts"],"sourcesContent":["/**\n * The recommended HARNESS permission allowlist: the exact rule lines an operator\n * pastes into Claude Code (or an equivalent harness) so auto mode stops denying\n * the free Tenjin verbs, and so the one paying verb is cleared deliberately\n * rather than by accident.\n *\n * This is a HARNESS-side allowlist (which shell commands the agent may run at\n * all). It is NOT the CLI's spend policy and shares nothing with it: the shipped\n * `allowlistCreators` config key gates WHO you may pay, this file gates WHICH\n * COMMANDS the harness will run without a prompt. The two are deliberately kept\n * apart in name and in code — clearing `Bash(tenjin buy:*)` here never raises a\n * spend cap. That is a claim about this file, NOT a claim that the spend policy\n * stops an allowlisted `buy`: `--yes` is an ordinary flag on an allowlisted verb\n * and `confirmSpend` returns true on it before any TTY check\n * (src/commands/buy.ts), so under CONFIG_DEFAULTS nothing denies. See\n * OPT_IN_ALLOWLIST's note for the walk-through.\n *\n * These are static, shipped constants on purpose: there is NO config key for\n * them. An operator-editable \"which commands may run\" list stored next to the\n * spend policy would be a second, weaker copy of a control the harness already\n * owns, and a CLI that could widen its own permission grant is exactly the shape\n * this file exists to avoid.\n *\n * Scope: `tenjin mcp` exposes the same command cores over MCP, where the harness\n * gates TOOLS, not Bash lines. These rules say nothing about that surface, which\n * is why `tenjin mcp` is itself never recommended here: clearing it would route\n * around every rule below. MCP_CAVEAT names the tools to leave gated for an\n * operator who runs the server anyway.\n *\n * LIMIT OF A PREFIX RULE, read this before adding an entry: the rule constrains\n * the VERB and nothing else. `addGlobalFlags` (src/cli.ts) puts `--json`,\n * `--timeout`, and `--base-url` on every leaf command, so every rule below also\n * clears `--base-url <url>` in trailing position. `--base-url` is validated as a\n * URL and nothing more, and it wins settings precedence, so it re-points the\n * trust boundary itself: the `search` question goes to that host, `doctor` probes\n * it, and `assertOnBaseOrigin` only checks that a resource URL shares an origin\n * with the CONFIGURED base, so an attacker-controlled pair satisfies the pin. No\n * prefix syntax expresses \"this verb but not that flag\", so the mitigation is\n * disclosure rather than a narrower rule: FLAG_CAVEAT rides the `--json` payload\n * and docs/agent-permissions.md, every human surface points at that page, and the\n * skills tell the agent never to pass `--base-url` on an allowlisted verb. Pinning\n * the paying path to a constant origin instead is the real fix and is an\n * x402/payments-semantics change, tracked separately.\n */\n\nimport type { PublishMode } from './config';\n\n/** One pasteable allowlist rule plus why it is safe (or what it costs). */\nexport interface AllowlistEntry {\n /** The exact line to add to the harness permission allowlist. */\n rule: string;\n /** The verb it clears. */\n command: string;\n /** Why it is safe to pre-clear, or what the operator is opting into. */\n note: string;\n}\n\n/** A verb deliberately kept OUT of the recommended allowlist, and why. */\nexport interface ExcludedVerb {\n command: string;\n reason: string;\n}\n\n/**\n * FREE verbs: they CANNOT SPEND. That is the whole definition of this tier, and\n * it is deliberately narrower than the older \"no wallet, no signing, no\n * payment\" — which stopped being true the moment `read` gained the ability to\n * recover an owned piece. `read` signs, with a P-256 delegation, and mints one\n * with a wallet signature when none is live; what it cannot do is produce the\n * secp256k1/EIP-712 signature a payment authorization needs (wrong curve), which\n * is test-pinned by its import graph never reaching the payment module. Money\n * stays out of reach; a signature, and the keystore access behind minting one,\n * no longer do, so the tier says what it means. `doctor` decrypts locally to\n * check the wallet still opens.\n *\n * What the tier does NOT claim, because it is not true: that the read scope\n * limits what a leaked delegation is worth. Scope is enforced only on the request\n * shape that carries both a session signature and the delegation header; the same\n * delegation replayed as a plain `SIGN-IN-WITH-X` takes a different server path\n * where no scope logic runs. So a session file is a wallet-derived credential\n * with the authority of the wallet behind it, and the mitigations that actually\n * hold are the ones in this repo: it is 0600, short-lived (≤24h, server-clamped),\n * bound to the origin it was minted for, and never presented off that origin.\n * Treat \"read is allowlisted\" as \"read may transmit that credential to the\n * configured origin\", and see FLAG_CAVEAT for why the configured origin is not\n * automatically the one you configured.\n *\n * Not all of them are read-only, and the difference is disclosed rather than\n * papered over — `search` POSTs the (generalized, anonymous) question off-machine\n * and records it locally, `outcome` POSTs a report that moves the marketplace's\n * reuse signal (both unauthenticated remote writes), and `read` writes locally,\n * saving a delivered piece to the library, and `doctor` decrypts the keystore\n * locally to check it opens. Pre-clearing them is defensible because they cost\n * nothing and none of it leaves the machine; calling them read-only to justify it\n * would not be.\n *\n * Rules are PREFIX rules: `Bash(tenjin search:*)` clears commands that start with\n * `tenjin search` and nothing else. The narrow `wallet show` / `wallet balance` /\n * The `config get` form is deliberate: a `Bash(tenjin wallet:*)`\n * or `Bash(tenjin config:*)` rule would silently swallow `wallet create` and\n * `config set`, and `config set` can raise the spend caps.\n *\n * Two known gaps, both fail-closed (denied, never wrongly allowed):\n * - Bare `tenjin config` (runConfigList) is as read-only as `config get`, but no\n * prefix rule reaches it without also covering `config set`, so it stays out.\n * Use `tenjin config get <key>`, which is a different supported command rather\n * than a reworded one.\n * - Group-level flag forms like `tenjin wallet --json show` are not covered.\n * Put global flags AFTER the leaf verb (`tenjin wallet show --json`); the\n * CLI parses either, and only the trailing form matches these rules.\n */\nexport const ALWAYS_SAFE_ALLOWLIST: readonly AllowlistEntry[] = [\n {\n rule: 'Bash(tenjin search:*)',\n command: 'tenjin search',\n note:\n 'Free anonymous marketplace search. No wallet, no signing, no payment. ' +\n 'Not read-only: it POSTs the generalized question off-machine and records ' +\n 'the search locally.',\n },\n {\n rule: 'Bash(tenjin wallet fund:*)',\n command: 'tenjin wallet fund',\n note:\n 'Owner call (2026-08-12): free on both surfaces, because the command just opens the ' +\n 'fund modal. Minting moves no money: the destination is server-pinned to the wallet ' +\n 'that signed, the CLI refuses any checkout host but pay.coinbase.com, and payment ' +\n 'happens behind Coinbase\\u2019s own human gate. The usual --base-url caveat does not ' +\n 'apply: fund is pinned to the production origin and takes no override from flag, ' +\n 'env, or config.',\n },\n {\n rule: 'Bash(tenjin inspect:*)',\n command: 'tenjin inspect',\n note: 'Free pre-purchase card and preview. Never signs, never pays, never saves.',\n },\n {\n rule: 'Bash(tenjin read:*)',\n command: 'tenjin read',\n note:\n 'Free-only delivery: free pieces, local-library re-reads, and pieces this ' +\n 'wallet already owns. Cannot spend: the payment module is absent from its ' +\n 'import graph, and the key it signs with is a P-256 delegation, the wrong ' +\n 'curve to authorize a payment. OPENS THE KEYSTORE (one wallet signature) ' +\n 'when an owned piece is not on this machine and no session key is live, ' +\n 'minting the same ≤24h read-scoped delegation `publish` and `edit` mint; ' +\n 'every later owned read reuses it and asks for nothing. TRANSMITS A ' +\n 'CREDENTIAL: that wallet-derived delegation goes to the server on a cold ' +\n '402. It is minted and presented only for the origin of the piece being ' +\n 'read, and never for a second origin while one for another is cached, ' +\n 'which is what bounds a stray `--base-url`; no scope on it limits what a ' +\n 'holder could do with it. Not read-only: a freshly delivered piece is ' +\n 'saved to the library.',\n },\n {\n rule: 'Bash(tenjin outcome:*)',\n command: 'tenjin outcome',\n note:\n 'Free honest outcome report on a past search. No wallet, no payment. ' +\n 'Not read-only: it POSTs a report that moves the marketplace reuse signal.',\n },\n {\n rule: 'Bash(tenjin doctor:*)',\n command: 'tenjin doctor',\n note:\n 'Local environment and API reachability diagnostics. Decrypts the wallet ' +\n 'locally to check it still opens; signs nothing and sends nothing.',\n },\n {\n rule: 'Bash(tenjin wallet show:*)',\n command: 'tenjin wallet show',\n note: 'Prints the wallet address and key source. Never prints the key.',\n },\n {\n rule: 'Bash(tenjin wallet balance:*)',\n command: 'tenjin wallet balance',\n note: 'Read-only USDC balance query on Base.',\n },\n {\n rule: 'Bash(tenjin config get:*)',\n command: 'tenjin config get',\n note:\n 'Reads one effective config value. `config set` is excluded on purpose. ' +\n 'Note `config get rpcUrl` returns your RPC URL, which commonly embeds a ' +\n 'provider API key: no wallet secret, but a credential-adjacent read.',\n },\n];\n\n/**\n * The verbs offered as EXPLICIT opt-in lines rather than shipped in the safe set:\n * the one that spends, and the one that opens the keystore.\n *\n * Read the buy note carefully before pasting the line: on the DEFAULT config this\n * rule authorizes unattended spending up to the wallet balance. Walking\n * `--yes` clears confirmation only. Zero daily budget refuses positive payments,\n * finite budgets cap cumulative exposure, and `none` explicitly removes that cap.\n */\nexport const OPT_IN_ALLOWLIST: readonly AllowlistEntry[] = [\n {\n rule: 'Bash(tenjin buy:*)',\n command: 'tenjin buy',\n note:\n 'SPENDS USDC on Base, unrefundably. This authorizes UNATTENDED purchases: ' +\n '`--yes` is an ordinary flag on the same allowlisted verb and it clears the ' +\n 'confirm gate only. Manual purchases do not obey maxAutoSpend or sessionBudget; those limits apply only to automatic router spending. ' +\n 'This permission never raises a spend cap, but those automatic caps do not bound this verb. Use --max-price for an explicit per-purchase ceiling and require consent for the quoted purchase.',\n },\n {\n rule: 'Bash(tenjin pay:*)',\n command: 'tenjin pay',\n note:\n 'SPENDS USDC on Base, unrefundably. Only for explicit user-requested payments with consent for the live quote; never an autonomous router-refusal workaround. Automatic router limits do not apply. Registry lookup failures or listed-term mismatches require --ignore-warnings ' +\n 'for that invocation, and --yes confirms payment only. Both still obey an explicit --max-price, ' +\n 'balance and destination checks. maxAutoSpend and sessionBudget apply only to automatic router spending. Every paid call can spend again.',\n },\n];\n\n/**\n * The one rule that is neither always-safe nor a standing opt-in: it exists only\n * while `publish.mode` is `auto` or `full-auto`.\n *\n * The mode IS the consent. An operator who set auto has already said a clean\n * publish should proceed without asking; leaving the harness prompt in front of\n * it asks the same question a second time, in a place the mode cannot answer,\n * and the agent that hits it does the only safe thing and stops. That was the\n * observed failure: a session ran `tenjin config get publish.mode` mid-publish to\n * discover it had permission it had already been given (#161).\n *\n * NOT part of {@link recommendedRules}, and not a tier an operator picks from.\n * There is no line to paste and no flag that adds it: `install` writes it when\n * the mode it just settled is auto or full-auto, takes it back when the mode is\n * review, and `uninstall` reclaims it like every other rule this CLI wrote.\n */\nexport const PUBLISH_MODE_ALLOWLIST: readonly AllowlistEntry[] = [\n {\n rule: 'Bash(tenjin publish:*)',\n command: 'tenjin publish',\n note:\n 'PUBLISHES PUBLICLY under your identity, and is cleared only while publish.mode is ' +\n 'auto or full-auto: the mode is the consent, and the harness prompt would ask for it ' +\n 'twice. Three things it clears that the free tier never did. It OPENS THE KEYSTORE: ' +\n 'publish always resolves a signer, and with no usable session it mints one at ' +\n 'read+write scope, which is strictly broader than the read-only key `tenjin read` ' +\n 'mints to recover an owned piece. It publishes the contents ' +\n 'of ANY REGULAR LOCAL FILE the agent can read, gated only by the heuristic scan. And it is a ' +\n 'PREFIX rule, so it pins the verb and not the flags: `--base-url` rides it (see the ' +\n 'flag caveat), and `--yes` is an ordinary flag on the same verb that clears exactly ' +\n 'the WARN findings auto stopped on, so a re-run collapses auto into full-auto with ' +\n 'nobody asked. The local scan is warn-only now and every finding routes through the ' +\n 'same consent flow this mode already governs; what still refuses a publish outright is ' +\n 'the SERVER’s ingest gate (vendor tokens, private keys, seed phrases, DB passwords, ' +\n 'bearer headers), which no mode and no flag clears. The skills hold the rest of that ' +\n 'line. Set publish.mode back to review and the rule is retracted.',\n },\n {\n rule: 'Bash(tenjin edit:*)',\n command: 'tenjin edit',\n note:\n 'Updates posts your wallet ALREADY OWNS: reprices, refreshes an as-of date, repairs an ' +\n 'answer card, and flips status both ways, so it CAN PROMOTE A DRAFT TO PUBLISHED under ' +\n 'this same gate (promotion re-runs the block-tier secret scan over the stored body). ' +\n 'Owner-scoped on both legs (GET and PUT /api/posts/<id> are signed and owner-only), ' +\n 'spends nothing, moves no keys, and mints no new posts: a narrower blast radius than ' +\n 'the publish rule beside it, though promotion means existing drafts can go public. It ' +\n 'rides the same mode for the same reason: edit runs the identical publish.mode consent ' +\n 'gate in the CLI (lib/consent.ts needsConfirmation), so a mode that publishes ' +\n 'unattended and then cannot fix its own post\\u2019s price is the asymmetry the mode ' +\n 'exists to remove. It opens the keystore on the same terms as the publish rule beside ' +\n 'it, and takes the same prefix-rule caveats. Removed by the same return to review.',\n },\n];\n\n/** The mode-gated rules in effect for `mode`; empty on review. */\nexport function modeGatedAllowlist(mode: PublishMode): AllowlistEntry[] {\n return mode === 'review' ? [] : PUBLISH_MODE_ALLOWLIST.map((e) => ({ ...e }));\n}\n\n/**\n * Verbs that must NEVER appear in the recommended allowlist, with the reason each\n * one is a human decision. `tenjin wallet send` is the wallet escape hatch\n * (tenjin-agent #40) and heads this list: it moves USDC to an arbitrary address,\n * outside the spend policy that bounds `buy`. Naming it here is load-bearing even\n * in versions where the verb does not exist yet — the exclusion ships before the\n * verb does.\n *\n * `tenjin publish` stays on this list under its own terms: nothing RECOMMENDS it,\n * and no line here or on the doc page adds it. {@link PUBLISH_MODE_ALLOWLIST} is\n * not a recommendation — it is what one specific operator choice already means.\n */\nexport const NEVER_ALLOWLISTED: readonly ExcludedVerb[] = [\n {\n command: 'tenjin wallet send',\n reason:\n 'Moves USDC out of the wallet to an arbitrary address (the escape hatch, #40). ' +\n 'Irreversible and not bounded by the buy spend policy. Always a human decision.',\n },\n {\n command: 'tenjin publish',\n reason:\n 'Puts your content on a public marketplace under your identity. Never pre-cleared by the ' +\n 'free tier or an opt-in line: the only thing that clears it is `publish.mode` auto or ' +\n 'full-auto, which is the same human decision said once instead of twice (see ' +\n 'PUBLISH_MODE_ALLOWLIST). Back on review, `install` takes the rule away again.',\n },\n {\n command: 'tenjin edit',\n reason:\n 'Write-capable despite the no-flag form reading as a pure show: it edits live posts ' +\n 'and answer cards under your identity, and moves prices. A prefix rule pins the verb, ' +\n 'not the flags, so no rule can clear the read half without clearing the write half. ' +\n 'Never pre-cleared as a recommendation: like `tenjin publish`, the only thing that ' +\n 'clears it is `publish.mode` auto or full-auto, whose consent gate it already shares ' +\n '(see PUBLISH_MODE_ALLOWLIST). Back on review, `install` takes the rule away again.',\n },\n {\n command: 'tenjin delete',\n reason:\n 'Destroys a published piece. It is the one write verb `publish.mode` deliberately does NOT ' +\n 'carry: the mode is consent to publish, and reading it as consent to destroy would let one ' +\n 'decision authorize a different, irreversible one. So no mode ever clears this rule, and ' +\n 'the CLI confirms on every run regardless — a prefix rule here would only remove the ' +\n 'harness prompt in front of a command that asks its own question anyway. Reach for ' +\n '`tenjin edit --status draft` when the piece should come down reversibly.',\n },\n {\n command: 'tenjin wallet create',\n reason: 'Creates the payment credential; a stray run is a wallet you did not mean to have.',\n },\n {\n command: 'tenjin wallet repair',\n reason:\n 'Saves the passphrase that unlocks the payment credential, typed by a person; a rule ' +\n 'would let an agent overwrite the stored passphrase without the person seeing it.',\n },\n {\n command: 'tenjin config set',\n reason:\n 'Can raise maxAutoSpend / sessionBudget, i.e. widen the agent’s own spend policy — ' +\n 'and, through shelfBypassSecret + baseUrl, put the machine in team mode, where a publish ' +\n 'skips the scan’s warn tier (except secret-assignment, and hex32-value, the warn form a ' +\n 'block-tier check demotes to) and prices at 0. It also writes ' +\n 'publish.ackServerWarnings on, the most direct consent-loosening write on this verb: ' +\n 'it lets one --yes cover the marketplace’s own scan findings, which no payload had ' +\n 'rendered when that yes was given.',\n },\n {\n command: 'tenjin install',\n reason: 'Writes into harness config and skills directories.',\n },\n {\n command: 'tenjin mcp',\n reason:\n 'Long-running server that re-exposes every command core over stdio; ' +\n 'clearing it would indirectly clear everything above.',\n },\n {\n command: 'tenjin update',\n reason:\n 'Replaces the tenjin binary the agent then runs, with whatever npm serves ' +\n 'next. Which build an agent executes is an operator decision, not something ' +\n 'a rule pre-clears. `--check` only reports, but a prefix rule pins the verb, ' +\n 'not the flags.',\n },\n];\n\n/**\n * The flag-surface caveat. A prefix rule pins the verb, never the flags, and the\n * flag that matters is `--base-url`: it is accepted on every leaf, validated only\n * as a URL, and it wins settings precedence, so it moves the destination of every\n * allowlisted verb. Printed with the rules everywhere they are printed, because\n * an operator who only reads the verb list would never learn it.\n */\nexport const FLAG_CAVEAT: readonly string[] = [\n 'Caveat: a prefix rule pins the VERB, not the flags. Every line above also clears',\n '`--base-url <url>` on that verb, which re-points where the question, the probe, the',\n 'session key `read` mints and presents, and (for buy) the signature and payment go.',\n 'Signed and credential-bearing traffic is NOT confined to the paying verb: `read` is in',\n 'the safe tier and both mints a wallet-derived delegation and transmits it, which is why',\n 'that delegation is bound to the origin it was minted for and refused elsewhere.',\n 'Allowlist these verbs only if you are content for the agent to choose the destination',\n 'host, and set the base URL in config instead of letting it be an argument. The skills',\n 'tell agents never to pass --base-url on an allowlisted verb, but that is a convention,',\n 'not an enforced boundary.',\n 'This covers the two rules your publish.mode carries as well, and bites hardest there:',\n '`tenjin publish --base-url <host>` is cleared by default on auto, and it signs against',\n 'the host it is given.',\n];\n\n/**\n * The MCP caveat. `tenjin mcp` is never recommended as a Bash rule, but an\n * operator who registers the server anyway is on a different permission surface\n * (tools, not command strings) where three excluded verbs come back.\n */\nexport const MCP_CAVEAT: readonly string[] = [\n 'Note the asymmetry: publish.mode writes the Bash rules for `publish` and `edit`, and',\n 'deliberately does not touch the MCP tool grants below. The mode is a CLI-side consent',\n 'gate, and nothing reads it on the MCP surface, so clearing those tools would hand out',\n 'the same authority with none of the same gate. Aligning the two is tracked separately.',\n 'Running the local MCP server (`tenjin mcp`) instead? That is a different permission',\n 'surface: the harness gates TOOLS there, and these Bash rules do not apply. Leave',\n '`mcp__tenjin__tenjin_publish`, `mcp__tenjin__tenjin_edit`,',\n '`mcp__tenjin__tenjin_delete`, and `mcp__tenjin__tenjin_wallet` gated. `tenjin_buy` is',\n 'the same opt-in decision as the buy line above. `tenjin_delete` is the one whose own',\n 'core still confirms even if you clear it: it never reads publish.mode.',\n];\n\n/** The machine shape emitted by `tenjin doctor --json` and `tenjin install --json`. */\nexport interface RecommendedPermissions {\n alwaysSafe: AllowlistEntry[];\n optIn: AllowlistEntry[];\n neverAllowlisted: ExcludedVerb[];\n /**\n * Rules the CURRENT publish.mode carries, empty on review. Separate from the\n * three tiers above because it is not a recommendation to weigh: it is what\n * this machine's mode already means, so a consumer that renders it beside the\n * others would be offering a choice that has been made.\n */\n modeGated: AllowlistEntry[];\n /**\n * Whether any harness on THIS machine can carry the rules above. They are\n * `Bash(...)` lines, Claude Code's grammar; a reader that took this payload\n * for a description of a Codex-only machine concluded `publish.mode=auto`\n * was in force while Codex was rejecting `tenjin publish` before the CLI ran\n * (tenjin-agent#342). The document still ships for a harness you have not\n * installed yet, so check this before treating any rule below as granted.\n */\n effective: boolean;\n /** Caveats that qualify the rules above; never omit them when rendering. */\n caveats: { flags: string[]; mcp: string[] };\n}\n\n/**\n * `mode` defaults to the shipped `review`, i.e. no mode-gated rules.\n * `effective` defaults to FALSE, so a caller that has not established such a\n * harness cannot have the payload claim one by omission.\n */\nexport function recommendedPermissions(\n mode: PublishMode = 'review',\n effective = false,\n): RecommendedPermissions {\n return {\n alwaysSafe: ALWAYS_SAFE_ALLOWLIST.map((e) => ({ ...e })),\n optIn: OPT_IN_ALLOWLIST.map((e) => ({ ...e })),\n neverAllowlisted: NEVER_ALLOWLISTED.map((e) => ({ ...e })),\n modeGated: modeGatedAllowlist(mode),\n effective,\n caveats: { flags: [...FLAG_CAVEAT], mcp: [...MCP_CAVEAT] },\n };\n}\n\n/** Every rule this module recommends adding (safe + opt-in). */\nexport function recommendedRules(): string[] {\n return [...ALWAYS_SAFE_ALLOWLIST, ...OPT_IN_ALLOWLIST].map((e) => e.rule);\n}\n\n/**\n * The permission caveats' one home. `doctor` used to print the whole thing —\n * nine rules, both opt-in notes, every exclusion, the flag caveat and the MCP\n * caveat, ~60 lines ahead of the check list it was actually run for. No doctor\n * command in the wider ecosystem carries security prose, and an operator reading\n * a wall of it in a terminal cannot paste from it, search it, or link a colleague\n * to a section. The page can do all three, so it is where the caveats live and\n * where every human surface points; `--json` still carries them as data\n * (`recommendedPermissions`), which is what an agent reads.\n */\nexport const PERMISSIONS_DOC_URL =\n 'https://github.com/BackTrackCo/tenjin-agent/blob/main/docs/agent-permissions.md';\n\n/**\n * The rules the current mode is missing, or null when it needs none. This one\n * DOES name them: they are not a tier to weigh and paste, they\n * are lines that should already be in the operator's settings file, and an\n * operator whose agent is being prompted for work the mode said not to ask about\n * needs to see exactly which rules are missing.\n *\n * CONSULTS THE MACHINE. Rendering from the mode alone told operators to add\n * rules their settings file already had, and named a remedy that in one case\n * would not have written anything — a nag that is wrong twice over on a line\n * whose whole job is to prevent an agent stalling on a prompt (#161).\n */\nexport function modeGatedPointer(\n mode: PublishMode,\n /** The mode-gated rules this machine is actually MISSING. Empty renders nothing. */\n missing: readonly string[],\n /**\n * The command that would fix it. `tenjin install` for the ordinary case; a\n * mode coming from TENJIN_PUBLISH_MODE needs `config set` instead, because\n * install resolves the mode from the global file and would write nothing.\n */\n remedy = 'tenjin install',\n): string | null {\n if (modeGatedAllowlist(mode).length === 0 || missing.length === 0) return null;\n return `publish.mode=${mode} also needs ${missing.join(' and ')} in your harness allowlist, or it will prompt anyway; \\`${remedy}\\` writes them.`;\n}\n"],"mappings":";;;AAyOO,IAAM,yBAAoD;AAAA,EAC/D;AAAA,IACE,MAAM;AAAA,IACN,SAAS;AAAA,IACT,MACE;AAAA,EAeJ;AAAA,EACA;AAAA,IACE,MAAM;AAAA,IACN,SAAS;AAAA,IACT,MACE;AAAA,EAWJ;AACF;AAGO,SAAS,mBAAmB,MAAqC;AACtE,SAAO,SAAS,WAAW,CAAC,IAAI,uBAAuB,IAAI,CAAC,OAAO,EAAE,GAAG,EAAE,EAAE;AAC9E;AA8LO,IAAM,sBACX;AAcK,SAAS,iBACd,MAEA,SAMA,SAAS,kBACM;AACf,MAAI,mBAAmB,IAAI,EAAE,WAAW,KAAK,QAAQ,WAAW,EAAG,QAAO;AAC1E,SAAO,gBAAgB,IAAI,eAAe,QAAQ,KAAK,OAAO,CAAC,2DAA2D,MAAM;AAClI;","names":[]}
@@ -3,7 +3,7 @@ import {
3
3
  LEGACY_MCP_SERVER_NAME,
4
4
  LEGACY_REQUEST_TOOL,
5
5
  requestToolName
6
- } from "./chunk-WJXLQXJY.js";
6
+ } from "./chunk-MPZUYCAP.js";
7
7
  import {
8
8
  writeFileAtomic
9
9
  } from "./chunk-7WEQQJLG.js";
@@ -225,4 +225,4 @@ export {
225
225
  writeRouterMemo,
226
226
  clearRouterMemo
227
227
  };
228
- //# sourceMappingURL=chunk-KXQ4UIP7.js.map
228
+ //# sourceMappingURL=chunk-4USCZ2NI.js.map
@@ -0,0 +1,247 @@
1
+ import { createRequire as __tenjinCreateRequire } from 'node:module'; const require = __tenjinCreateRequire(import.meta.url);
2
+ import {
3
+ proxyVariable
4
+ } from "./chunk-3FMZGI7I.js";
5
+ import {
6
+ CliError
7
+ } from "./chunk-3UCIG4TG.js";
8
+
9
+ // src/lib/runtime-fetch.ts
10
+ import { spawn } from "node:child_process";
11
+ import { createHash, randomBytes } from "node:crypto";
12
+ import { open, readFile, rm, stat } from "node:fs/promises";
13
+ import { join, posix, win32 } from "node:path";
14
+ var MIN_GLIBC = [2, 28];
15
+ var KEYS = /* @__PURE__ */ new Set([
16
+ "darwin-arm64",
17
+ "darwin-x64",
18
+ "linux-x64",
19
+ "linux-arm64",
20
+ "win-x64",
21
+ "win-arm64"
22
+ ]);
23
+ function glibcAtLeast(glibc, min) {
24
+ const m = /^(\d+)\.(\d+)/.exec(glibc);
25
+ if (m === null) return false;
26
+ const major = Number(m[1]);
27
+ const minor = Number(m[2]);
28
+ return major > min[0] || major === min[0] && minor >= min[1];
29
+ }
30
+ function nodeKey(platform, arch, glibc) {
31
+ const os = platform === "win32" ? "win" : platform;
32
+ const key = `${os}-${arch}`;
33
+ if (!KEYS.has(key)) return null;
34
+ if (platform === "linux" && (typeof glibc !== "string" || !glibcAtLeast(glibc, MIN_GLIBC))) {
35
+ return null;
36
+ }
37
+ return key;
38
+ }
39
+ function unpinnedPlatform(platform, arch, glibc) {
40
+ if (nodeKey(platform, arch, glibc) !== null) return null;
41
+ const key = `${platform === "win32" ? "win" : platform}-${arch}`;
42
+ if (platform !== "linux" || !KEYS.has(key)) return key;
43
+ return typeof glibc === "string" ? `${key} with glibc ${glibc}, older than ${MIN_GLIBC.join(".")}` : `${key} with musl, not glibc`;
44
+ }
45
+ function runningGlibc() {
46
+ try {
47
+ const report = process.report.getReport();
48
+ return report.header?.glibcVersionRuntime ?? null;
49
+ } catch {
50
+ return null;
51
+ }
52
+ }
53
+ function nodeArtifact(version, key) {
54
+ const base = `node-v${version}-${key}`;
55
+ const windows = key.startsWith("win-");
56
+ const file = `${base}.${windows ? "zip" : "tar.gz"}`;
57
+ return {
58
+ key,
59
+ url: `https://nodejs.org/dist/v${version}/${file}`,
60
+ file,
61
+ member: windows ? `${base}/node.exe` : `${base}/bin/node`
62
+ };
63
+ }
64
+ function isHttps(url) {
65
+ try {
66
+ return new URL(url).protocol === "https:";
67
+ } catch {
68
+ return false;
69
+ }
70
+ }
71
+ async function download(url, o) {
72
+ if (!isHttps(url)) {
73
+ throw new CliError("UPDATE_FAILED", `refused to download ${url}: only https is allowed`);
74
+ }
75
+ const file = join(o.dir, `dl-${randomBytes(6).toString("hex")}`);
76
+ const handle = await open(file, "wx", 384);
77
+ let closed = false;
78
+ try {
79
+ let res;
80
+ try {
81
+ res = await (o.fetchImpl ?? fetch)(url, { signal: AbortSignal.timeout(o.timeoutMs) });
82
+ } catch (err) {
83
+ throw new CliError("NETWORK_ERROR", `could not download ${url}: ${messageOf(err)}`, {
84
+ cause: err
85
+ });
86
+ }
87
+ if (res.url !== "" && !isHttps(res.url)) {
88
+ throw new CliError("UPDATE_FAILED", `refused ${url}: it redirected to ${res.url}`);
89
+ }
90
+ if (!res.ok || res.body === null) {
91
+ throw new CliError("NETWORK_ERROR", `could not download ${url}: HTTP ${res.status}`);
92
+ }
93
+ const tooLarge = () => new CliError("UPDATE_FAILED", `the download from ${url} is larger than ${o.maxBytes} bytes`);
94
+ if (Number(res.headers.get("content-length") ?? 0) > o.maxBytes) throw tooLarge();
95
+ const hash = createHash(o.hash);
96
+ let size = 0;
97
+ try {
98
+ for await (const chunk of res.body) {
99
+ size += chunk.byteLength;
100
+ if (size > o.maxBytes) throw tooLarge();
101
+ hash.update(chunk);
102
+ try {
103
+ await handle.write(chunk);
104
+ } catch (err) {
105
+ throw new CliError("UPDATE_FAILED", `could not write ${file}: ${codeOf(err)}`, {
106
+ cause: err
107
+ });
108
+ }
109
+ }
110
+ } catch (err) {
111
+ if (err instanceof CliError) throw err;
112
+ throw new CliError("NETWORK_ERROR", `could not download ${url}: ${messageOf(err)}`, {
113
+ cause: err
114
+ });
115
+ }
116
+ await handle.close();
117
+ closed = true;
118
+ return { file, digest: hash.digest() };
119
+ } catch (err) {
120
+ if (!closed) await handle.close().catch(() => void 0);
121
+ await rm(file, { force: true }).catch(() => void 0);
122
+ throw err;
123
+ }
124
+ }
125
+ async function downloadViaCurl(url, o) {
126
+ if (!isHttps(url)) throw new CliError("UPDATE_FAILED", "Only HTTPS downloads are allowed.");
127
+ const proxy = proxyVariable(o.env);
128
+ const env = proxy === void 0 ? o.env : { ...o.env, HTTPS_PROXY: o.env[proxy] };
129
+ const file = join(o.dir, `dl-${randomBytes(6).toString("hex")}`);
130
+ const handle = await open(file, "wx", 384);
131
+ await handle.close();
132
+ try {
133
+ await new Promise((done, fail) => {
134
+ const child = spawn(
135
+ process.platform === "win32" ? "curl.exe" : "curl",
136
+ [
137
+ "-q",
138
+ "--proto",
139
+ "=https",
140
+ "--proto-redir",
141
+ "=https",
142
+ "--fail",
143
+ "--location",
144
+ "--silent",
145
+ "--show-error",
146
+ "--connect-timeout",
147
+ "30",
148
+ "--max-time",
149
+ String(Math.max(1, Math.ceil(o.timeoutMs / 1e3))),
150
+ "--max-filesize",
151
+ String(o.maxBytes),
152
+ "--output",
153
+ file,
154
+ url
155
+ ],
156
+ // In Tenjin's own tmp folder: Windows looks for `curl.exe` in the
157
+ // working directory before PATH, and Tenjin runs from whatever folder
158
+ // the person is in, a cloned repository included. The output path is
159
+ // already absolute.
160
+ { cwd: o.dir, env, stdio: "ignore", windowsHide: true, timeout: o.timeoutMs + 1e3 }
161
+ );
162
+ child.once(
163
+ "error",
164
+ () => fail(
165
+ new CliError(
166
+ "NETWORK_ERROR",
167
+ "Could not start curl for the proxy download. Use the shell or PowerShell installer."
168
+ )
169
+ )
170
+ );
171
+ child.once(
172
+ "close",
173
+ (code) => code === 0 ? done() : fail(
174
+ new CliError(
175
+ "NETWORK_ERROR",
176
+ "The download through the configured proxy failed. Check the connection and retry installation."
177
+ )
178
+ )
179
+ );
180
+ });
181
+ if ((await stat(file)).size > o.maxBytes)
182
+ throw new CliError("UPDATE_FAILED", "The Node download is too large.");
183
+ return {
184
+ file,
185
+ digest: createHash("sha256").update(await readFile(file)).digest()
186
+ };
187
+ } catch (error) {
188
+ await rm(file, { force: true });
189
+ throw error;
190
+ }
191
+ }
192
+ function codeOf(err) {
193
+ const code = err?.code;
194
+ return typeof code === "string" ? code : messageOf(err);
195
+ }
196
+ function messageOf(err) {
197
+ if (err instanceof Error) {
198
+ return err.name === "TimeoutError" ? "it timed out" : err.message;
199
+ }
200
+ return String(err);
201
+ }
202
+ var spawnTar = (command, args, o) => new Promise((resolve, reject) => {
203
+ const child = spawn(command, args, {
204
+ cwd: o.cwd,
205
+ shell: false,
206
+ stdio: ["ignore", "ignore", "pipe"],
207
+ windowsHide: true
208
+ });
209
+ let stderr = "";
210
+ child.stderr.setEncoding("utf8");
211
+ child.stderr.on("data", (chunk) => {
212
+ if (stderr.length < 4096) stderr += chunk;
213
+ });
214
+ child.on("error", reject);
215
+ child.on("close", (code) => resolve({ code, stderr }));
216
+ });
217
+ async function extract(archive, dest, o = {}) {
218
+ const windows = (o.platform ?? process.platform) === "win32";
219
+ const command = windows ? win32.join(process.env.SystemRoot ?? "C:\\Windows", "System32", "tar.exe") : "tar";
220
+ const path = windows ? win32 : posix;
221
+ const cwd = path.dirname(archive);
222
+ const into = path.relative(cwd, dest);
223
+ const args = [
224
+ windows ? "-xf" : "-xzf",
225
+ path.basename(archive),
226
+ "-C",
227
+ into === "" ? "." : into.startsWith("..") || path.isAbsolute(into) ? dest : into,
228
+ ...o.strip !== void 0 && o.strip > 0 ? [`--strip-components=${o.strip}`] : [],
229
+ ...o.member !== void 0 ? [o.member] : []
230
+ ];
231
+ const run = await (o.spawnImpl ?? spawnTar)(command, args, { cwd });
232
+ if (run.code !== 0) {
233
+ const said = run.stderr.trim().slice(0, 300);
234
+ throw new Error(`tar could not unpack ${archive} (exit ${run.code})${said ? `: ${said}` : ""}`);
235
+ }
236
+ }
237
+
238
+ export {
239
+ nodeKey,
240
+ unpinnedPlatform,
241
+ runningGlibc,
242
+ nodeArtifact,
243
+ download,
244
+ downloadViaCurl,
245
+ extract
246
+ };
247
+ //# sourceMappingURL=chunk-4YOZGGTZ.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/lib/runtime-fetch.ts"],"sourcesContent":["import { spawn } from 'node:child_process';\nimport { createHash, randomBytes } from 'node:crypto';\nimport { open, readFile, rm, stat } from 'node:fs/promises';\nimport { join, posix, win32 } from 'node:path';\nimport { CliError } from './errors';\nimport { proxyVariable } from './env-proxy';\n\n/**\n * WHAT THE RUNTIME DOWNLOADS, AND HOW: Node's own release archive and the npm\n * tarball of a tenjin-cli version, over https only, streamed to disk while\n * hashed, capped in size and time, and unpacked by the system's `tar` in exec\n * form. The checksums themselves are the caller's: the pin in `package.json`\n * for Node, the registry's `dist.integrity` for a tarball.\n */\n\n/** The oldest glibc Node 24's prebuilt Linux binaries run on. */\nconst MIN_GLIBC = [2, 28] as const;\n\n/** Node's release archives, by `nodeKey`. Anything else has no pinned build. */\nconst KEYS = new Set([\n 'darwin-arm64',\n 'darwin-x64',\n 'linux-x64',\n 'linux-arm64',\n 'win-x64',\n 'win-arm64',\n]);\n\nfunction glibcAtLeast(glibc: string, min: readonly [number, number]): boolean {\n const m = /^(\\d+)\\.(\\d+)/.exec(glibc);\n if (m === null) return false;\n const major = Number(m[1]);\n const minor = Number(m[2]);\n return major > min[0] || (major === min[0] && minor >= min[1]);\n}\n\n/**\n * The release-archive key for this machine, or null where Tenjin pins no Node:\n * musl (no glibc version at all), a glibc older than 2.28, and every platform\n * and architecture outside the six keys. A Rosetta x64 Node asks for\n * `darwin-x64`, which runs under Rosetta too.\n */\nexport function nodeKey(\n platform: NodeJS.Platform,\n arch: string,\n glibc: string | null | undefined,\n): string | null {\n const os = platform === 'win32' ? 'win' : platform;\n const key = `${os}-${arch}`;\n if (!KEYS.has(key)) return null;\n if (platform === 'linux' && (typeof glibc !== 'string' || !glibcAtLeast(glibc, MIN_GLIBC))) {\n return null;\n }\n return key;\n}\n\n/**\n * Why Tenjin pins no Node for this machine, or null when it pins one: the\n * platform and architecture, and on Linux the C library that rules it out.\n * Said by install and doctor so the cause is named, never a pinned key.\n */\nexport function unpinnedPlatform(\n platform: NodeJS.Platform,\n arch: string,\n glibc: string | null | undefined,\n): string | null {\n if (nodeKey(platform, arch, glibc) !== null) return null;\n const key = `${platform === 'win32' ? 'win' : platform}-${arch}`;\n if (platform !== 'linux' || !KEYS.has(key)) return key;\n return typeof glibc === 'string'\n ? `${key} with glibc ${glibc}, older than ${MIN_GLIBC.join('.')}`\n : `${key} with musl, not glibc`;\n}\n\n/** The glibc this Node runs on, or null: musl, or a report that cannot be read. */\nexport function runningGlibc(): string | null {\n try {\n const report = process.report.getReport() as { header?: { glibcVersionRuntime?: string } };\n return report.header?.glibcVersionRuntime ?? null;\n } catch {\n return null;\n }\n}\n\nexport interface NodeArtifact {\n key: string;\n url: string;\n /** The archive's name in the release, the name `SHASUMS256.txt` lists. */\n file: string;\n /** The one archive member the runtime keeps: the `node` binary. */\n member: string;\n}\n\nexport function nodeArtifact(version: string, key: string): NodeArtifact {\n const base = `node-v${version}-${key}`;\n const windows = key.startsWith('win-');\n const file = `${base}.${windows ? 'zip' : 'tar.gz'}`;\n return {\n key,\n url: `https://nodejs.org/dist/v${version}/${file}`,\n file,\n member: windows ? `${base}/node.exe` : `${base}/bin/node`,\n };\n}\n\nfunction isHttps(url: string): boolean {\n try {\n return new URL(url).protocol === 'https:';\n } catch {\n return false;\n }\n}\n\n/**\n * Stream `url` into a fresh file under `dir`, hashing as it goes. Refuses a URL\n * (or a redirect's final URL) that is not https, aborts past `maxBytes` or\n * `timeoutMs`, and unlinks the file on any failure, so a caller never finds a\n * half download. A transport failure (the fetch, or reading the body) is\n * `NETWORK_ERROR`, and the caller adds its fix; a write to disk that fails\n * (ENOSPC, EACCES) is not the network's, and says which file and why.\n */\nexport async function download(\n url: string,\n o: {\n dir: string;\n maxBytes: number;\n timeoutMs: number;\n hash: 'sha256' | 'sha512';\n fetchImpl?: typeof fetch;\n },\n): Promise<{ file: string; digest: Buffer }> {\n if (!isHttps(url)) {\n throw new CliError('UPDATE_FAILED', `refused to download ${url}: only https is allowed`);\n }\n const file = join(o.dir, `dl-${randomBytes(6).toString('hex')}`);\n const handle = await open(file, 'wx', 0o600);\n let closed = false;\n try {\n let res: Response;\n try {\n res = await (o.fetchImpl ?? fetch)(url, { signal: AbortSignal.timeout(o.timeoutMs) });\n } catch (err) {\n throw new CliError('NETWORK_ERROR', `could not download ${url}: ${messageOf(err)}`, {\n cause: err,\n });\n }\n if (res.url !== '' && !isHttps(res.url)) {\n throw new CliError('UPDATE_FAILED', `refused ${url}: it redirected to ${res.url}`);\n }\n if (!res.ok || res.body === null) {\n throw new CliError('NETWORK_ERROR', `could not download ${url}: HTTP ${res.status}`);\n }\n const tooLarge = () =>\n new CliError('UPDATE_FAILED', `the download from ${url} is larger than ${o.maxBytes} bytes`);\n if (Number(res.headers.get('content-length') ?? 0) > o.maxBytes) throw tooLarge();\n const hash = createHash(o.hash);\n let size = 0;\n try {\n for await (const chunk of res.body as AsyncIterable<Uint8Array>) {\n size += chunk.byteLength;\n if (size > o.maxBytes) throw tooLarge();\n hash.update(chunk);\n try {\n await handle.write(chunk);\n } catch (err) {\n throw new CliError('UPDATE_FAILED', `could not write ${file}: ${codeOf(err)}`, {\n cause: err,\n });\n }\n }\n } catch (err) {\n if (err instanceof CliError) throw err;\n throw new CliError('NETWORK_ERROR', `could not download ${url}: ${messageOf(err)}`, {\n cause: err,\n });\n }\n await handle.close();\n closed = true;\n return { file, digest: hash.digest() };\n } catch (err) {\n if (!closed) await handle.close().catch(() => undefined);\n await rm(file, { force: true }).catch(() => undefined);\n throw err;\n }\n}\n\n/** Old npm Node releases cannot use environment proxies; curl keeps the first install working there. */\nexport async function downloadViaCurl(\n url: string,\n o: {\n dir: string;\n maxBytes: number;\n timeoutMs: number;\n env: NodeJS.ProcessEnv;\n },\n): Promise<{ file: string; digest: Buffer }> {\n if (!isHttps(url)) throw new CliError('UPDATE_FAILED', 'Only HTTPS downloads are allowed.');\n const proxy = proxyVariable(o.env);\n const env = proxy === undefined ? o.env : { ...o.env, HTTPS_PROXY: o.env[proxy] };\n const file = join(o.dir, `dl-${randomBytes(6).toString('hex')}`);\n const handle = await open(file, 'wx', 0o600);\n await handle.close();\n try {\n await new Promise<void>((done, fail) => {\n const child = spawn(\n process.platform === 'win32' ? 'curl.exe' : 'curl',\n [\n '-q',\n '--proto',\n '=https',\n '--proto-redir',\n '=https',\n '--fail',\n '--location',\n '--silent',\n '--show-error',\n '--connect-timeout',\n '30',\n '--max-time',\n String(Math.max(1, Math.ceil(o.timeoutMs / 1000))),\n '--max-filesize',\n String(o.maxBytes),\n '--output',\n file,\n url,\n ],\n // In Tenjin's own tmp folder: Windows looks for `curl.exe` in the\n // working directory before PATH, and Tenjin runs from whatever folder\n // the person is in, a cloned repository included. The output path is\n // already absolute.\n { cwd: o.dir, env, stdio: 'ignore', windowsHide: true, timeout: o.timeoutMs + 1000 },\n );\n child.once('error', () =>\n fail(\n new CliError(\n 'NETWORK_ERROR',\n 'Could not start curl for the proxy download. Use the shell or PowerShell installer.',\n ),\n ),\n );\n child.once('close', (code) =>\n code === 0\n ? done()\n : fail(\n new CliError(\n 'NETWORK_ERROR',\n 'The download through the configured proxy failed. Check the connection and retry installation.',\n ),\n ),\n );\n });\n if ((await stat(file)).size > o.maxBytes)\n throw new CliError('UPDATE_FAILED', 'The Node download is too large.');\n return {\n file,\n digest: createHash('sha256')\n .update(await readFile(file))\n .digest(),\n };\n } catch (error) {\n await rm(file, { force: true });\n throw error;\n }\n}\n\n/** A file-system error's errno code (ENOSPC, EACCES), or its message when it has none. */\nfunction codeOf(err: unknown): string {\n const code = (err as { code?: unknown } | null)?.code;\n return typeof code === 'string' ? code : messageOf(err);\n}\n\nfunction messageOf(err: unknown): string {\n if (err instanceof Error) {\n return err.name === 'TimeoutError' ? 'it timed out' : err.message;\n }\n return String(err);\n}\n\n/** How `extract` runs `tar`: exec form, no shell, in `cwd`. A seam for tests. */\nexport type ExtractSpawn = (\n command: string,\n args: string[],\n o: { cwd: string },\n) => Promise<{ code: number | null; stderr: string }>;\n\nconst spawnTar: ExtractSpawn = (command, args, o) =>\n new Promise((resolve, reject) => {\n const child = spawn(command, args, {\n cwd: o.cwd,\n shell: false,\n stdio: ['ignore', 'ignore', 'pipe'],\n windowsHide: true,\n });\n let stderr = '';\n child.stderr.setEncoding('utf8');\n child.stderr.on('data', (chunk: string) => {\n if (stderr.length < 4096) stderr += chunk;\n });\n child.on('error', reject);\n child.on('close', (code) => resolve({ code, stderr }));\n });\n\n/**\n * Unpack `archive` into `dest` with the system's `tar`: `tar -xzf` on POSIX,\n * and on Windows `System32\\tar.exe -xf`, which is bsdtar and reads a `.zip`\n * (Git's GNU tar, earlier on many PATHs, does not). `member` limits it to one\n * file, `strip` drops leading folders. A non-zero exit throws with what tar said.\n *\n * TAR RUNS IN THE ARCHIVE'S FOLDER and is given names relative to it. bsdtar\n * reads its argv in the ANSI code page, so a user folder named outside it\n * (Cyrillic on cp1252, an emoji) would reach it as `?`; the working directory\n * goes to Windows as a wide string, and the names it is given are the\n * runtime's own ASCII ones.\n */\nexport async function extract(\n archive: string,\n dest: string,\n o: { member?: string; strip?: number; platform?: NodeJS.Platform; spawnImpl?: ExtractSpawn } = {},\n): Promise<void> {\n const windows = (o.platform ?? process.platform) === 'win32';\n const command = windows\n ? win32.join(process.env.SystemRoot ?? 'C:\\\\Windows', 'System32', 'tar.exe')\n : 'tar';\n const path = windows ? win32 : posix;\n const cwd = path.dirname(archive);\n const into = path.relative(cwd, dest);\n const args = [\n windows ? '-xf' : '-xzf',\n path.basename(archive),\n '-C',\n into === '' ? '.' : into.startsWith('..') || path.isAbsolute(into) ? dest : into,\n ...(o.strip !== undefined && o.strip > 0 ? [`--strip-components=${o.strip}`] : []),\n ...(o.member !== undefined ? [o.member] : []),\n ];\n const run = await (o.spawnImpl ?? spawnTar)(command, args, { cwd });\n if (run.code !== 0) {\n const said = run.stderr.trim().slice(0, 300);\n throw new Error(`tar could not unpack ${archive} (exit ${run.code})${said ? `: ${said}` : ''}`);\n }\n}\n"],"mappings":";;;;;;;;;AAAA,SAAS,aAAa;AACtB,SAAS,YAAY,mBAAmB;AACxC,SAAS,MAAM,UAAU,IAAI,YAAY;AACzC,SAAS,MAAM,OAAO,aAAa;AAanC,IAAM,YAAY,CAAC,GAAG,EAAE;AAGxB,IAAM,OAAO,oBAAI,IAAI;AAAA,EACnB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,CAAC;AAED,SAAS,aAAa,OAAe,KAAyC;AAC5E,QAAM,IAAI,gBAAgB,KAAK,KAAK;AACpC,MAAI,MAAM,KAAM,QAAO;AACvB,QAAM,QAAQ,OAAO,EAAE,CAAC,CAAC;AACzB,QAAM,QAAQ,OAAO,EAAE,CAAC,CAAC;AACzB,SAAO,QAAQ,IAAI,CAAC,KAAM,UAAU,IAAI,CAAC,KAAK,SAAS,IAAI,CAAC;AAC9D;AAQO,SAAS,QACd,UACA,MACA,OACe;AACf,QAAM,KAAK,aAAa,UAAU,QAAQ;AAC1C,QAAM,MAAM,GAAG,EAAE,IAAI,IAAI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(import.meta.url);
2
+ import {
3
+ CHANNEL_DEPOSIT_ATOMIC,
4
+ ROUTING_FEE_ATOMIC,
5
+ unpaid
6
+ } from "./chunk-HDPUXS3Z.js";
7
+ import {
8
+ UNKNOWN_DETAIL,
9
+ WALLET_REASONS
10
+ } from "./chunk-BFDQ4WNW.js";
11
+ import {
12
+ DEFINITE_UNLOCK
13
+ } from "./chunk-X5ZBP3IY.js";
14
+
15
+ // src/router/eligibility.ts
16
+ function unlockBlocked(reason, fix) {
17
+ const r = WALLET_REASONS[reason];
18
+ return { status: "blocked", reason, detail: r.reason, fix: fix ?? r.fix };
19
+ }
20
+ function unknown(reason, detail) {
21
+ return {
22
+ status: "unknown",
23
+ reason,
24
+ detail: UNKNOWN_DETAIL[reason] ?? detail ?? UNKNOWN_DETAIL["check_failed"]
25
+ };
26
+ }
27
+ function ready(source, warning) {
28
+ return {
29
+ status: "ready",
30
+ ...source !== void 0 ? { source } : {},
31
+ ...warning !== void 0 ? { warning } : {}
32
+ };
33
+ }
34
+ function moneyBlocked(reason) {
35
+ const u = unpaid(reason);
36
+ return {
37
+ status: "blocked",
38
+ reason,
39
+ detail: u?.reason ?? reason,
40
+ fix: u?.fix ?? "Run `tenjin doctor`."
41
+ };
42
+ }
43
+ function canSign(f) {
44
+ if (f.envKey === "valid") return ready("key-env");
45
+ if (f.envKey === "malformed") return unlockBlocked("env_key_invalid");
46
+ if (f.walletFile === "absent") return unlockBlocked("no_wallet");
47
+ if (f.walletFile === "unparsable") return unlockBlocked("wallet_corrupt");
48
+ const envPassphraseSet = f.envPassphraseSet === true;
49
+ if (f.unlock !== void 0) {
50
+ if (f.unlock.ok) return ready(f.unlock.source, f.unlock.warning);
51
+ const { reason } = f.unlock;
52
+ if (reason === "passphrase_missing" && envPassphraseSet) return unknown("not_checked");
53
+ if (reason !== "wallet_locked" && DEFINITE_UNLOCK.has(reason)) {
54
+ return unlockBlocked(reason, f.unlock.fix);
55
+ }
56
+ return unknown(reason, f.unlock.detail);
57
+ }
58
+ if (f.passphraseFileMissing === true && !envPassphraseSet) {
59
+ return unlockBlocked("passphrase_missing");
60
+ }
61
+ return unknown("not_checked");
62
+ }
63
+ function canPayRouting(r) {
64
+ if (r.feeRefusal !== null) return moneyBlocked(r.feeRefusal);
65
+ if (r.sign.status === "blocked") return r.sign;
66
+ if ((r.creditAtomic ?? 0n) >= ROUTING_FEE_ATOMIC) return r.sign;
67
+ if (r.depositRefusal !== null) return moneyBlocked(r.depositRefusal);
68
+ if (r.balanceAtomic !== null && r.balanceAtomic < CHANNEL_DEPOSIT_ATOMIC) {
69
+ return moneyBlocked("wallet_low");
70
+ }
71
+ if (r.sign.status === "unknown") return r.sign;
72
+ if (r.balanceAtomic === null) return unknown("balance_unreadable");
73
+ return r.sign;
74
+ }
75
+ function canPayProvider(p, priceAtomic) {
76
+ if (p.policy.decision !== "allow") {
77
+ return {
78
+ status: "blocked",
79
+ reason: "needs_approval",
80
+ detail: "",
81
+ fix: "",
82
+ policyReason: p.policy.reason
83
+ };
84
+ }
85
+ if (p.sign.status === "blocked") return p.sign;
86
+ if (p.balanceAtomic !== null && p.balanceAtomic < priceAtomic) {
87
+ return { status: "blocked", reason: "wallet_short", detail: "", fix: "" };
88
+ }
89
+ if (p.sign.status === "unknown") return p.sign;
90
+ if (p.balanceAtomic === null) return unknown("balance_unreadable");
91
+ return p.sign;
92
+ }
93
+ function signFromVerification(v) {
94
+ if (v === null || v === void 0) return unknown("not_checked");
95
+ if (v.status === "verified") return ready(v.source, v.warning);
96
+ if (v.status === "broken") return unlockBlocked(v.reason ?? "passphrase_wrong");
97
+ if (v.reason !== void 0 && DEFINITE_UNLOCK.has(v.reason)) return unlockBlocked(v.reason);
98
+ return unknown(v.reason ?? "wallet_locked", v.detail);
99
+ }
100
+ function isDefiniteBlock(v) {
101
+ return v.status === "blocked";
102
+ }
103
+
104
+ export {
105
+ canSign,
106
+ canPayRouting,
107
+ canPayProvider,
108
+ signFromVerification,
109
+ isDefiniteBlock
110
+ };
111
+ //# sourceMappingURL=chunk-62KNUYWD.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/router/eligibility.ts"],"sourcesContent":["import type { PolicyReason } from '../lib/policy';\nimport type { WalletFacts } from '../lib/wallet-facts';\nimport type { WalletVerification } from '../lib/wallet/provider';\nimport { DEFINITE_UNLOCK, type SigningSource, type UnlockReason } from '../lib/wallet-unlock';\nimport { CHANNEL_DEPOSIT_ATOMIC, ROUTING_FEE_ATOMIC, unpaid } from './fee';\nimport { UNKNOWN_DETAIL, WALLET_REASONS } from './wallet-reasons';\n\n/**\n * CAN THIS WALLET SIGN, PAY THE ROUTING FEE, PAY A PROVIDER: three pure answers\n * from facts someone else gathered. The payer, the hooks, doctor and install\n * all decide from these, so a wallet one of them calls blocked is blocked to\n * every other.\n *\n * Every answer is one of three, never a boolean:\n * - `ready`: it will work, as far as anything here can tell;\n * - `blocked`: it DEFINITELY will not until a person fixes something, and the\n * verdict says what and how;\n * - `unknown`: nothing definite either way (a keychain that did not answer, a\n * balance that could not be read, an unlock not tried yet).\n *\n * ONLY `blocked` GATES. An unknown never withholds an offer, never skips a\n * routing attempt, and never renders as ok. Two invariants follow, and the\n * property test holds them: nothing is ready while signing is not ready, and\n * nothing is blocked from an unknown input alone.\n *\n * Pure and hook-safe: types, fee.ts's constants and wording, and the reason\n * strings. The I/O that fills these facts in lives in `eligibility-check.ts`\n * (doctor) and in the payer and hooks themselves.\n */\nexport type Verdict<R extends string = string> =\n | { status: 'ready'; source?: SigningSource; warning?: string }\n | { status: 'blocked'; reason: R; detail: string; fix: string }\n | { status: 'unknown'; reason: string; detail: string };\n\nexport type SignVerdict = Verdict<UnlockReason>;\n\nexport type { SigningSource };\n\nexport interface SignFacts {\n envKey: WalletFacts['envKey'];\n walletFile: WalletFacts['walletFile'];\n passphraseFileMissing?: boolean;\n /** S13: with this set, canSign never returns blocked passphrase_missing. */\n envPassphraseSet?: boolean;\n unlock?:\n | { ok: true; source?: SigningSource; warning?: string }\n | { ok: false; reason: UnlockReason | 'wallet_locked'; detail?: string; fix?: string };\n}\n\nexport interface RoutingFacts {\n feeRefusal: string | null;\n sign: SignVerdict;\n creditAtomic: bigint | null;\n depositRefusal: string | null;\n balanceAtomic: bigint | null;\n}\n\nexport interface ProviderFacts {\n policy: { decision: 'allow' } | { decision: 'refuse'; reason: PolicyReason };\n sign: SignVerdict;\n balanceAtomic: bigint | null;\n}\n\n/** A definite unlock block, worded from WALLET_REASONS: the fragment as the\n * detail, the PERSON fix (decision 15) unless the caller supplied its own. */\nfunction unlockBlocked(reason: UnlockReason, fix?: string): SignVerdict {\n const r = WALLET_REASONS[reason as keyof typeof WALLET_REASONS];\n return { status: 'blocked', reason, detail: r.reason, fix: fix ?? r.fix };\n}\n\n/** An unknown, worded from UNKNOWN_DETAIL, else the caller's detail. */\nfunction unknown(\n reason: string,\n detail?: string,\n): { status: 'unknown'; reason: string; detail: string } {\n return {\n status: 'unknown',\n reason,\n detail: UNKNOWN_DETAIL[reason] ?? detail ?? UNKNOWN_DETAIL['check_failed']!,\n };\n}\n\n/** A ready verdict carrying only the fields that are set. */\nfunction ready(\n source?: SigningSource,\n warning?: string,\n): { status: 'ready'; source?: SigningSource; warning?: string } {\n return {\n status: 'ready',\n ...(source !== undefined ? { source } : {}),\n ...(warning !== undefined ? { warning } : {}),\n };\n}\n\n/**\n * A money or policy block in TODAY'S words (S5): `detail` and `fix` are fee.ts's\n * `unpaid(reason)`, byte for byte. No new fee or funding wording comes from here.\n */\nfunction moneyBlocked(reason: string): Verdict {\n const u = unpaid(reason);\n return {\n status: 'blocked',\n reason,\n detail: u?.reason ?? reason,\n fix: u?.fix ?? 'Run `tenjin doctor`.',\n };\n}\n\n/**\n * CAN THIS WALLET SIGN, first match wins (section 2.4).\n *\n * The file facts that are definite come first (a malformed key, no wallet, a\n * wallet.json nobody can read), then what an actual unlock said, then the one\n * file fact that is definite only without the env variable: the sidecar names\n * the file store and the file is gone.\n *\n * S13: a set TENJIN_WALLET_PASSPHRASE is itself a passphrase source, so \"no\n * passphrase can be reached\" is never definite while it is set. Until an\n * unlock has actually tried it, the answer is unknown.\n */\nexport function canSign(f: SignFacts): SignVerdict {\n if (f.envKey === 'valid') return ready('key-env');\n if (f.envKey === 'malformed') return unlockBlocked('env_key_invalid');\n if (f.walletFile === 'absent') return unlockBlocked('no_wallet');\n if (f.walletFile === 'unparsable') return unlockBlocked('wallet_corrupt');\n const envPassphraseSet = f.envPassphraseSet === true;\n if (f.unlock !== undefined) {\n if (f.unlock.ok) return ready(f.unlock.source, f.unlock.warning);\n const { reason } = f.unlock;\n if (reason === 'passphrase_missing' && envPassphraseSet) return unknown('not_checked');\n if (reason !== 'wallet_locked' && DEFINITE_UNLOCK.has(reason)) {\n return unlockBlocked(reason, f.unlock.fix);\n }\n return unknown(reason, f.unlock.detail);\n }\n if (f.passphraseFileMissing === true && !envPassphraseSet) {\n return unlockBlocked('passphrase_missing');\n }\n return unknown('not_checked');\n}\n\n/**\n * CAN THE NEXT ROUTING CALL PAY ITS FEE, first match wins (section 2.4).\n *\n * Definite money facts come AHEAD of an unknown signer (decision 11): a\n * command-mode hook cannot unlock, so its signer is always unknown, and a\n * balance below the deposit must still withhold there as it does today. A\n * channel that already holds the fee needs no deposit, so neither the deposit\n * policy nor the balance matters to it (checklist item 8: $0 with credit).\n */\nexport function canPayRouting(r: RoutingFacts): Verdict {\n if (r.feeRefusal !== null) return moneyBlocked(r.feeRefusal);\n if (r.sign.status === 'blocked') return r.sign;\n if ((r.creditAtomic ?? 0n) >= ROUTING_FEE_ATOMIC) return r.sign;\n if (r.depositRefusal !== null) return moneyBlocked(r.depositRefusal);\n if (r.balanceAtomic !== null && r.balanceAtomic < CHANNEL_DEPOSIT_ATOMIC) {\n return moneyBlocked('wallet_low');\n }\n if (r.sign.status === 'unknown') return r.sign;\n if (r.balanceAtomic === null) return unknown('balance_unreadable');\n return r.sign;\n}\n\n/**\n * CAN THIS WALLET PAY A PROVIDER `priceAtomic`, first match wins (section 2.4).\n *\n * `needs_approval` keeps the policy's own reason, and it and `wallet_short`\n * carry empty text on purpose: the hooks render them with today's Shortfall\n * strings, and nothing here may invent new ones.\n */\nexport function canPayProvider(\n p: ProviderFacts,\n priceAtomic: bigint,\n): Verdict<UnlockReason | 'needs_approval' | 'wallet_short'> & { policyReason?: PolicyReason } {\n if (p.policy.decision !== 'allow') {\n return {\n status: 'blocked',\n reason: 'needs_approval',\n detail: '',\n fix: '',\n policyReason: p.policy.reason,\n };\n }\n if (p.sign.status === 'blocked') return p.sign;\n if (p.balanceAtomic !== null && p.balanceAtomic < priceAtomic) {\n return { status: 'blocked', reason: 'wallet_short', detail: '', fix: '' };\n }\n if (p.sign.status === 'unknown') return p.sign;\n if (p.balanceAtomic === null) return unknown('balance_unreadable');\n return p.sign;\n}\n\n/**\n * A provider's `verify()` answer as a sign verdict.\n *\n * verified is ready (with its source and warning); broken is blocked\n * (`reason`, else `passphrase_wrong`, the one thing today's broken verdicts\n * all were before they carried one); unverified is blocked only with a\n * DEFINITE reason, and unknown otherwise; no answer at all is unknown.\n *\n * A blocked verdict is worded from WALLET_REASONS, not from the verification's\n * own `detail` and `fix`: those predate B1 and can tell a person to set\n * TENJIN_WALLET_PASSPHRASE, and doctor shows the WALLET_REASONS person fix for\n * every unlock reason (decision 15).\n */\nexport function signFromVerification(v: WalletVerification | null | undefined): SignVerdict {\n if (v === null || v === undefined) return unknown('not_checked');\n if (v.status === 'verified') return ready(v.source, v.warning);\n if (v.status === 'broken') return unlockBlocked(v.reason ?? 'passphrase_wrong');\n if (v.reason !== undefined && DEFINITE_UNLOCK.has(v.reason)) return unlockBlocked(v.reason);\n return unknown(v.reason ?? 'wallet_locked', v.detail);\n}\n\n/** True only for a definite block: the one status any caller may gate on. */\nexport function isDefiniteBlock(v: Verdict): v is Extract<Verdict, { status: 'blocked' }> {\n return v.status === 'blocked';\n}\n"],"mappings":";;;;;;;;;;;;;;;AAiEA,SAAS,cAAc,QAAsB,KAA2B;AACtE,QAAM,IAA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AQ,EAAE,OAAO;AAC7D,MAAI,EAAE,WAAW,SAAU,QAAO,cAAc,EAAE,UAAU,kBAAkB;AAC9E,MAAI,EAAE,WAAW,UAAa,gBAAgB,IAAI,EAAE,MAAM,EAAG,QAAO,cAAc,EAAE,MAAM;AAC1F,SAAO,QAAQ,EAAE,UAAU,iBAAiB,EAAE,MAAM;AACtD;AAGO,SAAS,gBAAgB,GAA0D;AACxF,SAAO,EAAE,WAAW;AACtB;","names":[]}
@@ -5,9 +5,9 @@ import {
5
5
  p,
6
6
  r,
7
7
  t
8
- } from "./chunk-XZKD7DIF.js";
8
+ } from "./chunk-RL5UUDT4.js";
9
9
 
10
- // node_modules/.pnpm/@signinwithethereum+siwe@4.2.0_viem@2.55.2_typescript@6.0.3_zod@4.4.3_/node_modules/@signinwithethereum/siwe/dist/ethersCompat-Df4a6QIZ.js
10
+ // node_modules/.pnpm/@signinwithethereum+siwe@4.2.0_viem@2.55.2_typescript@6.0.3_zod@4.6.7_/node_modules/@signinwithethereum/siwe/dist/ethersCompat-Df4a6QIZ.js
11
11
  var a2 = "6492649264926492649264926492649264926492649264926492649264926492";
12
12
  var o = "0x608060405234801561001057600080fd5b5060405161069438038061069483398101604081905261002f9161051e565b600061003c848484610048565b9050806000526001601ff35b60007f64926492649264926492649264926492649264926492649264926492649264926100748361040c565b036101e7576000606080848060200190518101906100929190610577565b60405192955090935091506000906001600160a01b038516906100b69085906105dd565b6000604051808303816000865af19150503d80600081146100f3576040519150601f19603f3d011682016040523d82523d6000602084013e6100f8565b606091505b50509050876001600160a01b03163b60000361016057806101605760405162461bcd60e51b815260206004820152601e60248201527f5369676e617475726556616c696461746f723a206465706c6f796d656e74000060448201526064015b60405180910390fd5b604051630b135d3f60e11b808252906001600160a01b038a1690631626ba7e90610190908b9087906004016105f9565b602060405180830381865afa1580156101ad573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906101d19190610633565b6001600160e01b03191614945050505050610405565b6001600160a01b0384163b1561027a57604051630b135d3f60e11b808252906001600160a01b03861690631626ba7e9061022790879087906004016105f9565b602060405180830381865afa158015610244573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906102689190610633565b6001600160e01b031916149050610405565b81516041146102df5760405162461bcd60e51b815260206004820152603a602482015260008051602061067483398151915260448201527f3a20696e76616c6964207369676e6174757265206c656e6774680000000000006064820152608401610157565b6102e7610425565b5060208201516040808401518451859392600091859190811061030c5761030c61065d565b016020015160f81c9050601b811480159061032b57508060ff16601c14155b1561038c5760405162461bcd60e51b815260206004820152603b602482015260008051602061067483398151915260448201527f3a20696e76616c6964207369676e617475726520762076616c756500000000006064820152608401610157565b60408051600081526020810180835289905260ff83169181019190915260608101849052608081018390526001600160a01b0389169060019060a0016020604051602081039080840390855afa1580156103ea573d6000803e3d6000fd5b505050602060405103516001600160a01b0316149450505050505b9392505050565b600060208251101561041d57600080fd5b508051015190565b60405180606001604052806003906020820280368337509192915050565b6001600160a01b038116811461045857600080fd5b50565b634e487b7160e01b600052604160045260246000fd5b60005b8381101561048c578181015183820152602001610474565b50506000910152565b600082601f8301126104a657600080fd5b81516001600160401b038111156104bf576104bf61045b565b604051601f8201601f19908116603f011681016001600160401b03811182821017156104ed576104ed61045b565b60405281815283820160200185101561050557600080fd5b610516826020830160208701610471565b949350505050565b60008060006060848603121561053357600080fd5b835161053e81610443565b6020850151604086015191945092506001600160401b0381111561056157600080fd5b61056d86828701610495565b9150509250925092565b60008060006060848603121561058c57600080fd5b835161059781610443565b60208501519093506001600160401b038111156105b357600080fd5b6105bf86828701610495565b604086015190935090506001600160401b0381111561056157600080fd5b600082516105ef818460208701610471565b9190910192915050565b828152604060208201526000825180604084015261061e816060850160208701610471565b601f01601f1916919091016060019392505050565b60006020828403121561064557600080fd5b81516001600160e01b03198116811461040557600080fd5b634e487b7160e01b600052603260045260246000fdfe5369676e617475726556616c696461746f72237265636f7665725369676e6572";
13
13
  function s(e) {
@@ -80,4 +80,4 @@ export {
80
80
  c,
81
81
  f
82
82
  };
83
- //# sourceMappingURL=chunk-POUWHWID.js.map
83
+ //# sourceMappingURL=chunk-6CMM6YCB.js.map