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

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 (495) hide show
  1. package/NOTICE.md +110 -0
  2. package/README.md +87 -81
  3. package/dist/{_esm-BIN7VY2L.js → _esm-2KST7HQ7.js} +7 -7
  4. package/dist/alive-5TV22PNF.js +51 -0
  5. package/dist/auth-XI7BJFLW.js +47 -0
  6. package/dist/{auto-update-Y24UL56V.js → auto-update-7L24KDWA.js} +4 -5
  7. package/dist/balance-DFHC6XEU.js +71 -0
  8. package/dist/{ccip-DHDFKTQV.js → ccip-HOW3DZYF.js} +4 -4
  9. package/dist/chunk-24XKUN2S.js +202 -0
  10. package/dist/chunk-24XKUN2S.js.map +1 -0
  11. package/dist/chunk-2L7TDGLV.js +56 -0
  12. package/dist/chunk-2L7TDGLV.js.map +1 -0
  13. package/dist/{chunk-C2Q76BVM.js → chunk-2U7H35IP.js} +29 -7
  14. package/dist/chunk-2U7H35IP.js.map +1 -0
  15. package/dist/chunk-2W4DQQUU.js +176 -0
  16. package/dist/chunk-2W4DQQUU.js.map +1 -0
  17. package/dist/{chunk-LRW6S53P.js → chunk-34SAECKZ.js} +35 -11
  18. package/dist/chunk-34SAECKZ.js.map +1 -0
  19. package/dist/{chunk-2I4QTOLB.js → chunk-3MZ7DYRO.js} +1 -1
  20. package/dist/chunk-3MZ7DYRO.js.map +1 -0
  21. package/dist/{chunk-RVPYTUP4.js → chunk-3Y2EHT4F.js} +13 -9
  22. package/dist/chunk-3Y2EHT4F.js.map +1 -0
  23. package/dist/chunk-3Y6BHIN6.js +169 -0
  24. package/dist/chunk-3Y6BHIN6.js.map +1 -0
  25. package/dist/{chunk-4K7TQHNP.js → chunk-3YPL6T3P.js} +17 -33
  26. package/dist/chunk-3YPL6T3P.js.map +1 -0
  27. package/dist/{chunk-E7SW44LM.js → chunk-44MVIRZH.js} +121 -6
  28. package/dist/chunk-44MVIRZH.js.map +1 -0
  29. package/dist/chunk-45MMSBHA.js +321 -0
  30. package/dist/chunk-45MMSBHA.js.map +1 -0
  31. package/dist/{chunk-3FMZGI7I.js → chunk-4CE6TMI5.js} +1 -1
  32. package/dist/chunk-4CE6TMI5.js.map +1 -0
  33. package/dist/{chunk-QXP3Z3JN.js → chunk-4MBCJFY4.js} +35 -3
  34. package/dist/chunk-4MBCJFY4.js.map +1 -0
  35. package/dist/chunk-4TPL54KW.js +227 -0
  36. package/dist/chunk-4TPL54KW.js.map +1 -0
  37. package/dist/chunk-54ELBTKE.js +1615 -0
  38. package/dist/chunk-54ELBTKE.js.map +1 -0
  39. package/dist/{chunk-NDGZDTSJ.js → chunk-5F4OB5B3.js} +115 -57
  40. package/dist/chunk-5F4OB5B3.js.map +1 -0
  41. package/dist/chunk-5HN4KVQU.js +3348 -0
  42. package/dist/chunk-5HN4KVQU.js.map +1 -0
  43. package/dist/{chunk-ZDZERB6L.js → chunk-5J4E5GYI.js} +572 -407
  44. package/dist/chunk-5J4E5GYI.js.map +1 -0
  45. package/dist/{chunk-ZNNXRNFD.js → chunk-5N4GGUBN.js} +48 -6
  46. package/dist/chunk-5N4GGUBN.js.map +1 -0
  47. package/dist/chunk-5USBZ2MU.js +58 -0
  48. package/dist/chunk-5USBZ2MU.js.map +1 -0
  49. package/dist/chunk-64WOMNYR.js +183 -0
  50. package/dist/chunk-64WOMNYR.js.map +1 -0
  51. package/dist/{chunk-ILNIZ5I2.js → chunk-65RS4LQS.js} +1825 -1715
  52. package/dist/chunk-65RS4LQS.js.map +1 -0
  53. package/dist/{chunk-IE7P2BZE.js → chunk-6QMDUDF2.js} +3 -3
  54. package/dist/{chunk-IADZOXKN.js → chunk-7SLOTLO7.js} +19 -697
  55. package/dist/chunk-7SLOTLO7.js.map +1 -0
  56. package/dist/{chunk-WFSPCCVW.js → chunk-7V25UAQO.js} +99 -99
  57. package/dist/{chunk-WFSPCCVW.js.map → chunk-7V25UAQO.js.map} +1 -1
  58. package/dist/chunk-BGA4DO5M.js +719 -0
  59. package/dist/chunk-BGA4DO5M.js.map +1 -0
  60. package/dist/chunk-BVP7YK2J.js +706 -0
  61. package/dist/chunk-BVP7YK2J.js.map +1 -0
  62. package/dist/chunk-C265QIMJ.js +83 -0
  63. package/dist/chunk-C265QIMJ.js.map +1 -0
  64. package/dist/{chunk-XQJXNMSB.js → chunk-CRG54LEB.js} +1 -1
  65. package/dist/chunk-CRG54LEB.js.map +1 -0
  66. package/dist/{chunk-KG3D7FIF.js → chunk-CZJOMUBP.js} +2 -2
  67. package/dist/{chunk-36RVGZNY.js → chunk-D6M3ZK66.js} +22 -39
  68. package/dist/chunk-D6M3ZK66.js.map +1 -0
  69. package/dist/{chunk-3UCIG4TG.js → chunk-DI4QAGRZ.js} +1 -11
  70. package/dist/chunk-DI4QAGRZ.js.map +1 -0
  71. package/dist/{chunk-JKKAIPTU.js → chunk-DIH2G3YG.js} +47 -10
  72. package/dist/chunk-DIH2G3YG.js.map +1 -0
  73. package/dist/chunk-DJ36BM62.js +78 -0
  74. package/dist/chunk-DJ36BM62.js.map +1 -0
  75. package/dist/chunk-DTEWAVNE.js +114 -0
  76. package/dist/chunk-DTEWAVNE.js.map +1 -0
  77. package/dist/chunk-F2KJAJ7T.js +13 -0
  78. package/dist/chunk-F2KJAJ7T.js.map +1 -0
  79. package/dist/{chunk-BF4XHEQK.js → chunk-F3QPGYOY.js} +6 -6
  80. package/dist/chunk-F3QPGYOY.js.map +1 -0
  81. package/dist/{chunk-3GNJXKIT.js → chunk-F43CV6UC.js} +2 -2
  82. package/dist/{chunk-J57UC3DD.js → chunk-FKVJKLPI.js} +3 -3
  83. package/dist/{chunk-V2LQLN5H.js → chunk-FYFHH7V5.js} +59 -8
  84. package/dist/{chunk-V2LQLN5H.js.map → chunk-FYFHH7V5.js.map} +1 -1
  85. package/dist/chunk-GAJC4BQZ.js +1096 -0
  86. package/dist/chunk-GAJC4BQZ.js.map +1 -0
  87. package/dist/{chunk-DOQGNFHM.js → chunk-GH5UKMZD.js} +2 -12
  88. package/dist/{chunk-DOQGNFHM.js.map → chunk-GH5UKMZD.js.map} +1 -1
  89. package/dist/{chunk-WYXUQGOL.js → chunk-HAZAN4UM.js} +7 -6
  90. package/dist/chunk-HAZAN4UM.js.map +1 -0
  91. package/dist/chunk-HI5XQOX2.js +393 -0
  92. package/dist/chunk-HI5XQOX2.js.map +1 -0
  93. package/dist/chunk-HKGUKAQW.js +488 -0
  94. package/dist/chunk-HKGUKAQW.js.map +1 -0
  95. package/dist/{chunk-SO3XRZPX.js → chunk-HPRVFJPM.js} +6 -6
  96. package/dist/{chunk-L6JEXB3E.js → chunk-HQR4BWKX.js} +3 -131
  97. package/dist/chunk-HQR4BWKX.js.map +1 -0
  98. package/dist/chunk-HZKANST2.js +177 -0
  99. package/dist/chunk-HZKANST2.js.map +1 -0
  100. package/dist/{chunk-UUGOUOVT.js → chunk-I557SAOM.js} +8 -2
  101. package/dist/chunk-I557SAOM.js.map +1 -0
  102. package/dist/{chunk-TC2WZLSC.js → chunk-IGLWLH73.js} +8 -7
  103. package/dist/chunk-IGLWLH73.js.map +1 -0
  104. package/dist/chunk-ILWCKCOI.js +58 -0
  105. package/dist/chunk-ILWCKCOI.js.map +1 -0
  106. package/dist/{chunk-2GP3HRYK.js → chunk-INSIW65E.js} +182 -182
  107. package/dist/{chunk-MPZUYCAP.js → chunk-IULCDMVG.js} +12 -1
  108. package/dist/chunk-IULCDMVG.js.map +1 -0
  109. package/dist/{chunk-INTFHMU4.js → chunk-IVNSUAVC.js} +25 -26
  110. package/dist/chunk-IVNSUAVC.js.map +1 -0
  111. package/dist/chunk-JDQZCREI.js +87 -0
  112. package/dist/chunk-JDQZCREI.js.map +1 -0
  113. package/dist/chunk-JHFFUVON.js +1050 -0
  114. package/dist/chunk-JHFFUVON.js.map +1 -0
  115. package/dist/{chunk-RL5UUDT4.js → chunk-JNUKLSMZ.js} +3 -3
  116. package/dist/chunk-JTILUN4W.js +2933 -0
  117. package/dist/chunk-JTILUN4W.js.map +1 -0
  118. package/dist/{chunk-OJNTCYQQ.js → chunk-JTX3BUDK.js} +37 -53
  119. package/dist/chunk-JTX3BUDK.js.map +1 -0
  120. package/dist/{chunk-X5ZBP3IY.js → chunk-JUUBBBY5.js} +2 -2
  121. package/dist/chunk-JUUBBBY5.js.map +1 -0
  122. package/dist/chunk-JWAK7JQB.js +15 -0
  123. package/dist/chunk-JWAK7JQB.js.map +1 -0
  124. package/dist/{chunk-UXZONNEQ.js → chunk-K5KNGC4I.js} +34 -31
  125. package/dist/chunk-K5KNGC4I.js.map +1 -0
  126. package/dist/chunk-KAQ4Q3TO.js +135 -0
  127. package/dist/chunk-KAQ4Q3TO.js.map +1 -0
  128. package/dist/chunk-KFVJYLVL.js +125 -0
  129. package/dist/chunk-KFVJYLVL.js.map +1 -0
  130. package/dist/chunk-KGUE5AVX.js +69 -0
  131. package/dist/chunk-KGUE5AVX.js.map +1 -0
  132. package/dist/{chunk-FVIGCDSV.js → chunk-KLDMLWXT.js} +11 -85
  133. package/dist/chunk-KLDMLWXT.js.map +1 -0
  134. package/dist/chunk-KNKDMTHU.js +453 -0
  135. package/dist/chunk-KNKDMTHU.js.map +1 -0
  136. package/dist/chunk-LDA6TAYQ.js +95 -0
  137. package/dist/chunk-LDA6TAYQ.js.map +1 -0
  138. package/dist/chunk-LWSSIZOY.js +347 -0
  139. package/dist/chunk-LWSSIZOY.js.map +1 -0
  140. package/dist/{chunk-ZURZHELF.js → chunk-MAHNZA6C.js} +158 -41
  141. package/dist/chunk-MAHNZA6C.js.map +1 -0
  142. package/dist/chunk-MEWZCIA6.js +220 -0
  143. package/dist/chunk-MEWZCIA6.js.map +1 -0
  144. package/dist/{chunk-2SNUOHAT.js → chunk-MEZJ3I63.js} +49 -1
  145. package/dist/chunk-MEZJ3I63.js.map +1 -0
  146. package/dist/chunk-MJDO4EXD.js +353 -0
  147. package/dist/chunk-MJDO4EXD.js.map +1 -0
  148. package/dist/chunk-NJA6NT3A.js +6595 -0
  149. package/dist/chunk-NJA6NT3A.js.map +1 -0
  150. package/dist/{chunk-LHHMV4GU.js → chunk-NVSKJPRC.js} +1 -1
  151. package/dist/{chunk-LHHMV4GU.js.map → chunk-NVSKJPRC.js.map} +1 -1
  152. package/dist/{chunk-4YOZGGTZ.js → chunk-OC7K2DVZ.js} +5 -5
  153. package/dist/chunk-OC7K2DVZ.js.map +1 -0
  154. package/dist/chunk-ODRPASFP.js +2078 -0
  155. package/dist/chunk-ODRPASFP.js.map +1 -0
  156. package/dist/chunk-OJJFANO6.js +133 -0
  157. package/dist/chunk-OJJFANO6.js.map +1 -0
  158. package/dist/{chunk-JNJWBTU2.js → chunk-OQWPRFAC.js} +332 -882
  159. package/dist/chunk-OQWPRFAC.js.map +1 -0
  160. package/dist/chunk-P4I7BFNJ.js +11 -0
  161. package/dist/chunk-P4I7BFNJ.js.map +1 -0
  162. package/dist/{chunk-SNNSAGMT.js → chunk-P6YQWIT2.js} +4058 -4039
  163. package/dist/chunk-P6YQWIT2.js.map +1 -0
  164. package/dist/{chunk-JRGFKVAZ.js → chunk-PETQ5WEA.js} +2 -2
  165. package/dist/{chunk-HMWYAUA6.js → chunk-Q6RSJCXB.js} +29 -69
  166. package/dist/chunk-Q6RSJCXB.js.map +1 -0
  167. package/dist/{chunk-U3IKUGRP.js → chunk-QKEUKBRK.js} +17 -23
  168. package/dist/chunk-QKEUKBRK.js.map +1 -0
  169. package/dist/{chunk-2RWB7RKE.js → chunk-QKYUCITR.js} +174 -5814
  170. package/dist/chunk-QKYUCITR.js.map +1 -0
  171. package/dist/chunk-QQDPRTLP.js +127 -0
  172. package/dist/chunk-QQDPRTLP.js.map +1 -0
  173. package/dist/chunk-QQYCYAKI.js +79 -0
  174. package/dist/chunk-QQYCYAKI.js.map +1 -0
  175. package/dist/chunk-R4KDH477.js +1064 -0
  176. package/dist/chunk-R4KDH477.js.map +1 -0
  177. package/dist/chunk-R5TR2DIK.js +119 -0
  178. package/dist/chunk-R5TR2DIK.js.map +1 -0
  179. package/dist/chunk-R62PKTAG.js +66 -0
  180. package/dist/chunk-R62PKTAG.js.map +1 -0
  181. package/dist/{chunk-BFDQ4WNW.js → chunk-RFZA7PSM.js} +4 -5
  182. package/dist/chunk-RFZA7PSM.js.map +1 -0
  183. package/dist/chunk-RGCPELQN.js +219 -0
  184. package/dist/chunk-RGCPELQN.js.map +1 -0
  185. package/dist/chunk-RGVCOG2S.js +910 -0
  186. package/dist/chunk-RGVCOG2S.js.map +1 -0
  187. package/dist/chunk-SOLNJ3AZ.js +209 -0
  188. package/dist/chunk-SOLNJ3AZ.js.map +1 -0
  189. package/dist/chunk-TFT2X7SH.js +77 -0
  190. package/dist/chunk-TFT2X7SH.js.map +1 -0
  191. package/dist/chunk-TUCKEEXE.js +2 -0
  192. package/dist/chunk-TVWCLUBI.js +293 -0
  193. package/dist/chunk-TVWCLUBI.js.map +1 -0
  194. package/dist/chunk-U4TRWSVE.js +78 -0
  195. package/dist/chunk-U4TRWSVE.js.map +1 -0
  196. package/dist/chunk-UIB33QQP.js +379 -0
  197. package/dist/chunk-UIB33QQP.js.map +1 -0
  198. package/dist/chunk-V6GIVALQ.js +1889 -0
  199. package/dist/chunk-V6GIVALQ.js.map +1 -0
  200. package/dist/chunk-VHXCPXUS.js +366 -0
  201. package/dist/chunk-VHXCPXUS.js.map +1 -0
  202. package/dist/{chunk-HGZEPQUT.js → chunk-VU6GMWF6.js} +17 -8
  203. package/dist/chunk-VU6GMWF6.js.map +1 -0
  204. package/dist/chunk-VWZYE3NC.js +8415 -0
  205. package/dist/chunk-VWZYE3NC.js.map +1 -0
  206. package/dist/{chunk-AGMVASXZ.js → chunk-W2GXIARJ.js} +88 -11
  207. package/dist/chunk-W2GXIARJ.js.map +1 -0
  208. package/dist/chunk-W4G3K3V7.js +288 -0
  209. package/dist/chunk-W4G3K3V7.js.map +1 -0
  210. package/dist/chunk-W74LJ5OT.js +588 -0
  211. package/dist/chunk-W74LJ5OT.js.map +1 -0
  212. package/dist/chunk-W7ELYLYK.js +233 -0
  213. package/dist/chunk-W7ELYLYK.js.map +1 -0
  214. package/dist/{chunk-BPMWXTFX.js → chunk-WFZX352D.js} +7 -7
  215. package/dist/chunk-WXA3WTPF.js +20 -0
  216. package/dist/chunk-WXA3WTPF.js.map +1 -0
  217. package/dist/chunk-XRGFH7FI.js +454 -0
  218. package/dist/chunk-XRGFH7FI.js.map +1 -0
  219. package/dist/chunk-XSCGUO2U.js +330 -0
  220. package/dist/chunk-XSCGUO2U.js.map +1 -0
  221. package/dist/chunk-XWROSMI5.js +1039 -0
  222. package/dist/chunk-XWROSMI5.js.map +1 -0
  223. package/dist/chunk-Y2EXZ47H.js +40 -0
  224. package/dist/chunk-Y2EXZ47H.js.map +1 -0
  225. package/dist/chunk-YJGEVBKZ.js +47 -0
  226. package/dist/chunk-YJGEVBKZ.js.map +1 -0
  227. package/dist/{chunk-6CMM6YCB.js → chunk-YWWMISDY.js} +2 -2
  228. package/dist/{chunk-WXA2BWTE.js → chunk-ZCT5DJ3G.js} +2 -48
  229. package/dist/chunk-ZCT5DJ3G.js.map +1 -0
  230. package/dist/chunk-ZEYA2WWX.js +982 -0
  231. package/dist/chunk-ZEYA2WWX.js.map +1 -0
  232. package/dist/chunk-ZRC7Z5X3.js +82 -0
  233. package/dist/chunk-ZRC7Z5X3.js.map +1 -0
  234. package/dist/{chunk-3AIHRXKO.js → chunk-ZS7JIUJ3.js} +12 -10
  235. package/dist/chunk-ZS7JIUJ3.js.map +1 -0
  236. package/dist/{clack-EZ7TDWQU.js → clack-Q4RNC5VE.js} +2 -6
  237. package/dist/{claude-cli-2YKABJJZ.js → claude-cli-GIIHOBGT.js} +4 -2
  238. package/dist/claude-install-BAUSJMW3.js +64 -0
  239. package/dist/{cli-E36SPKBW.js → cli-QY4KKA3D.js} +632 -150
  240. package/dist/cli-QY4KKA3D.js.map +1 -0
  241. package/dist/client-3YQKORVK.js +710 -0
  242. package/dist/client-3YQKORVK.js.map +1 -0
  243. package/dist/{codex-event-ZO2GEFE6.js → codex-event-EUTCAOTQ.js} +3 -5
  244. package/dist/{codex-host-KECJVTA2.js → codex-host-ZON3S6HU.js} +7 -7
  245. package/dist/{codex-install-HQZDGFXW.js → codex-install-HZV2DOAB.js} +242 -88
  246. package/dist/codex-install-HZV2DOAB.js.map +1 -0
  247. package/dist/config-QZOBMTEL.js +57 -0
  248. package/dist/config-names-Z5NZD5R2.js +224 -0
  249. package/dist/config-names-Z5NZD5R2.js.map +1 -0
  250. package/dist/config-rules-YOYHS6YL.js +55 -0
  251. package/dist/config-subagents-WQV2ZAD5.js +362 -0
  252. package/dist/config-subagents-WQV2ZAD5.js.map +1 -0
  253. package/dist/connect-YDWTYU4B.js +1020 -0
  254. package/dist/connect-YDWTYU4B.js.map +1 -0
  255. package/dist/core-0a66n3e7-TTP554XV.js +127 -0
  256. package/dist/core-0a66n3e7-TTP554XV.js.map +1 -0
  257. package/dist/core-0bmnpbz2-C2JIRVZO.js +10790 -0
  258. package/dist/core-0bmnpbz2-C2JIRVZO.js.map +1 -0
  259. package/dist/core-9je8ee1j-74DGHWPV.js +30 -0
  260. package/dist/core-9je8ee1j-74DGHWPV.js.map +1 -0
  261. package/dist/core-wadgcjfh-TSZFQZGH.js +666 -0
  262. package/dist/core-wadgcjfh-TSZFQZGH.js.map +1 -0
  263. package/dist/core-zg882d22-LKV5DZYW.js +37 -0
  264. package/dist/core-zg882d22-LKV5DZYW.js.map +1 -0
  265. package/dist/decision-QSKHOGCO.js +145 -0
  266. package/dist/{doctor-I6XQEKWD.js → doctor-ZWJXRD75.js} +162 -148
  267. package/dist/doctor-ZWJXRD75.js.map +1 -0
  268. package/dist/{env-proxy-R6ZMLQTT.js → env-proxy-XLSLHBKQ.js} +2 -2
  269. package/dist/{ethersCompat-Df4a6QIZ-X6YZWAML.js → ethersCompat-Df4a6QIZ-K3DMHR6Y.js} +5 -5
  270. package/dist/explicit-ME2NRADQ.js +371 -0
  271. package/dist/explicit-ME2NRADQ.js.map +1 -0
  272. package/dist/flush-stdio-NYIJ3QXT.js +18 -0
  273. package/dist/fund-VF7TLDJH.js +722 -0
  274. package/dist/fund-VF7TLDJH.js.map +1 -0
  275. package/dist/hook-command-VZ27MGWO.js +49 -0
  276. package/dist/hosts/claude/.claude-plugin/marketplace.json +2 -2
  277. package/dist/hosts/claude/tenjin/.claude-plugin/plugin.json +2 -2
  278. package/dist/hosts/claude/tenjin/hooks/hook-data.ts +152 -0
  279. package/dist/hosts/claude/tenjin/hooks/hooks.json +7 -0
  280. package/dist/hosts/claude/tenjin/hooks/model-viewer.tsx +2987 -0
  281. package/dist/hosts/claude/tenjin/hooks/register.tsx +527 -56
  282. package/dist/hosts/claude/tenjin/skills/tenjin-pay/SKILL.md +14 -4
  283. package/dist/hosts/claude/tenjin/types/index.d.ts +144 -1
  284. package/dist/{hosts-DVQJ32QC.js → hosts-3EMTVM4H.js} +7 -6
  285. package/dist/index.js +18 -15
  286. package/dist/index.js.map +1 -1
  287. package/dist/install-ZA7L2UF3.js +115 -0
  288. package/dist/install-funding-JDGYTF72.js +30 -0
  289. package/dist/install-identity-FFAYEFLX.js +30 -0
  290. package/dist/{install-wallet-5M4OTYLX.js → install-wallet-2SFOVE3Q.js} +68 -53
  291. package/dist/install-wallet-2SFOVE3Q.js.map +1 -0
  292. package/dist/mcp-36S6MK3C.js +67642 -0
  293. package/dist/mcp-36S6MK3C.js.map +1 -0
  294. package/dist/new-install-5L4GY3LN.js +51 -0
  295. package/dist/{package-IJFGMWEV.js → package-BONDXSV3.js} +2 -2
  296. package/dist/{passphrase-IFTDS3CU.js → passphrase-T4ULBN4M.js} +16 -12
  297. package/dist/{paths-XCSAKISU.js → paths-O2KDWZ76.js} +18 -28
  298. package/dist/pay-CMV5KL74.js +74 -0
  299. package/dist/{payments-HFPPWHTV.js → payments-Z6UBZL4Z.js} +36 -26
  300. package/dist/payments-Z6UBZL4Z.js.map +1 -0
  301. package/dist/reclaim-subagent-credit-ABSF67SJ.js +105 -0
  302. package/dist/reclaim-subagent-credit-ABSF67SJ.js.map +1 -0
  303. package/dist/{redact-D7ASVWKL.js → redact-LOTHE5TS.js} +2 -8
  304. package/dist/redact-LOTHE5TS.js.map +1 -0
  305. package/dist/routing-quote-AHLAREXR.js +40 -0
  306. package/dist/routing-quote-AHLAREXR.js.map +1 -0
  307. package/dist/run-JH7ELYAM.js +88 -0
  308. package/dist/run-JH7ELYAM.js.map +1 -0
  309. package/dist/runtime-2GX4ALJP.js +410 -0
  310. package/dist/runtime-2GX4ALJP.js.map +1 -0
  311. package/dist/runtime-activate-IDQ2NCSP.js +39 -0
  312. package/dist/runtime-activate-IDQ2NCSP.js.map +1 -0
  313. package/dist/{runtime-fetch-ZSSSK72Y.js → runtime-fetch-6LOBHBEN.js} +4 -4
  314. package/dist/runtime-fetch-6LOBHBEN.js.map +1 -0
  315. package/dist/runtime-launchers-YAPKCBHV.js +31 -0
  316. package/dist/runtime-launchers-YAPKCBHV.js.map +1 -0
  317. package/dist/{runtime-layout-WIDILZ6K.js → runtime-layout-QHZQJV7C.js} +5 -4
  318. package/dist/runtime-layout-QHZQJV7C.js.map +1 -0
  319. package/dist/runtime-place-4POL4KK4.js +37 -0
  320. package/dist/runtime-place-4POL4KK4.js.map +1 -0
  321. package/dist/runtime-provenance-MNJGVBV2.js +12 -0
  322. package/dist/runtime-provenance-MNJGVBV2.js.map +1 -0
  323. package/dist/{secp256k1-ZZZT2CAX.js → secp256k1-N5P2GVGF.js} +3 -3
  324. package/dist/secp256k1-N5P2GVGF.js.map +1 -0
  325. package/dist/{send-GCVEAQKL.js → send-ELXFKEKY.js} +35 -32
  326. package/dist/send-ELXFKEKY.js.map +1 -0
  327. package/dist/status-FXUFWJDM.js +404 -0
  328. package/dist/status-FXUFWJDM.js.map +1 -0
  329. package/dist/{status-line-OPCXDHL2.js → status-line-IH5JBWBC.js} +51 -43
  330. package/dist/status-line-IH5JBWBC.js.map +1 -0
  331. package/dist/streamableHttp-CP2ZQBIK.js +768 -0
  332. package/dist/streamableHttp-CP2ZQBIK.js.map +1 -0
  333. package/dist/{uninstall-BAWRBXXQ.js → uninstall-LJZUKM4D.js} +76 -76
  334. package/dist/uninstall-LJZUKM4D.js.map +1 -0
  335. package/dist/update-EUIX72IX.js +68 -0
  336. package/dist/update-EUIX72IX.js.map +1 -0
  337. package/dist/usage-EKDC7LUC.js +180 -0
  338. package/dist/usage-EKDC7LUC.js.map +1 -0
  339. package/dist/{usdc-VG4CIOUK.js → usdc-YIHK2OMC.js} +8 -12
  340. package/dist/usdc-YIHK2OMC.js.map +1 -0
  341. package/dist/{viemAdapter-By13KInL-DOFTEIJV.js → viemAdapter-By13KInL-PRLSIESK.js} +5 -5
  342. package/dist/viemAdapter-By13KInL-PRLSIESK.js.map +1 -0
  343. package/dist/wallet-HSW757W6.js +80 -0
  344. package/dist/wallet-HSW757W6.js.map +1 -0
  345. package/dist/wallet-kdf-worker.mjs +1433 -818
  346. package/docs/agent-permissions.md +88 -155
  347. package/docs/router-reference.md +236 -0
  348. package/docs/safety-model.md +31 -33
  349. package/docs/subagents-internals.md +97 -0
  350. package/docs/subagents.md +348 -0
  351. package/docs/troubleshooting.md +10 -6
  352. package/package.json +12 -8
  353. package/scripts/installers/install.sh +7 -1
  354. package/dist/alive-GSOWKUOY.js +0 -38
  355. package/dist/chunk-2I4QTOLB.js.map +0 -1
  356. package/dist/chunk-2M2VPI2E.js +0 -560
  357. package/dist/chunk-2M2VPI2E.js.map +0 -1
  358. package/dist/chunk-2RWB7RKE.js.map +0 -1
  359. package/dist/chunk-2SNUOHAT.js.map +0 -1
  360. package/dist/chunk-3623BLPV.js +0 -184
  361. package/dist/chunk-3623BLPV.js.map +0 -1
  362. package/dist/chunk-36RVGZNY.js.map +0 -1
  363. package/dist/chunk-3AIHRXKO.js.map +0 -1
  364. package/dist/chunk-3FMZGI7I.js.map +0 -1
  365. package/dist/chunk-3UCIG4TG.js.map +0 -1
  366. package/dist/chunk-4K7TQHNP.js.map +0 -1
  367. package/dist/chunk-4LMUQMBH.js +0 -29
  368. package/dist/chunk-4LMUQMBH.js.map +0 -1
  369. package/dist/chunk-4USCZ2NI.js +0 -228
  370. package/dist/chunk-4USCZ2NI.js.map +0 -1
  371. package/dist/chunk-4YOZGGTZ.js.map +0 -1
  372. package/dist/chunk-62KNUYWD.js +0 -111
  373. package/dist/chunk-62KNUYWD.js.map +0 -1
  374. package/dist/chunk-A5GKIG5O.js +0 -2037
  375. package/dist/chunk-A5GKIG5O.js.map +0 -1
  376. package/dist/chunk-AGMVASXZ.js.map +0 -1
  377. package/dist/chunk-BF4XHEQK.js.map +0 -1
  378. package/dist/chunk-BFDQ4WNW.js.map +0 -1
  379. package/dist/chunk-C2Q76BVM.js.map +0 -1
  380. package/dist/chunk-CEXSOI5R.js +0 -808
  381. package/dist/chunk-CEXSOI5R.js.map +0 -1
  382. package/dist/chunk-E7SW44LM.js.map +0 -1
  383. package/dist/chunk-EDJWHDDL.js +0 -33
  384. package/dist/chunk-EDJWHDDL.js.map +0 -1
  385. package/dist/chunk-FVIGCDSV.js.map +0 -1
  386. package/dist/chunk-GTTUCOPD.js +0 -105
  387. package/dist/chunk-GTTUCOPD.js.map +0 -1
  388. package/dist/chunk-HDPUXS3Z.js +0 -122
  389. package/dist/chunk-HDPUXS3Z.js.map +0 -1
  390. package/dist/chunk-HGGWCP7W.js +0 -120
  391. package/dist/chunk-HGGWCP7W.js.map +0 -1
  392. package/dist/chunk-HGZEPQUT.js.map +0 -1
  393. package/dist/chunk-HMWYAUA6.js.map +0 -1
  394. package/dist/chunk-IADZOXKN.js.map +0 -1
  395. package/dist/chunk-ILNIZ5I2.js.map +0 -1
  396. package/dist/chunk-INTFHMU4.js.map +0 -1
  397. package/dist/chunk-JKKAIPTU.js.map +0 -1
  398. package/dist/chunk-JNJWBTU2.js.map +0 -1
  399. package/dist/chunk-KM7RY2ZS.js +0 -246
  400. package/dist/chunk-KM7RY2ZS.js.map +0 -1
  401. package/dist/chunk-KOGZDMHO.js +0 -21
  402. package/dist/chunk-KOGZDMHO.js.map +0 -1
  403. package/dist/chunk-L6JEXB3E.js.map +0 -1
  404. package/dist/chunk-LRW6S53P.js.map +0 -1
  405. package/dist/chunk-LXAYUOXI.js +0 -511
  406. package/dist/chunk-LXAYUOXI.js.map +0 -1
  407. package/dist/chunk-MEFB5KHA.js +0 -59
  408. package/dist/chunk-MEFB5KHA.js.map +0 -1
  409. package/dist/chunk-MPZUYCAP.js.map +0 -1
  410. package/dist/chunk-NDGZDTSJ.js.map +0 -1
  411. package/dist/chunk-OJNTCYQQ.js.map +0 -1
  412. package/dist/chunk-P3LFTKE7.js +0 -58
  413. package/dist/chunk-P3LFTKE7.js.map +0 -1
  414. package/dist/chunk-QXP3Z3JN.js.map +0 -1
  415. package/dist/chunk-RVPYTUP4.js.map +0 -1
  416. package/dist/chunk-SNNSAGMT.js.map +0 -1
  417. package/dist/chunk-TC2WZLSC.js.map +0 -1
  418. package/dist/chunk-TKPF35W6.js +0 -29
  419. package/dist/chunk-TKPF35W6.js.map +0 -1
  420. package/dist/chunk-U3IKUGRP.js.map +0 -1
  421. package/dist/chunk-UUGOUOVT.js.map +0 -1
  422. package/dist/chunk-UXZONNEQ.js.map +0 -1
  423. package/dist/chunk-WXA2BWTE.js.map +0 -1
  424. package/dist/chunk-WYXUQGOL.js.map +0 -1
  425. package/dist/chunk-X5ZBP3IY.js.map +0 -1
  426. package/dist/chunk-XKESD27X.js +0 -10
  427. package/dist/chunk-XKESD27X.js.map +0 -1
  428. package/dist/chunk-XQJXNMSB.js.map +0 -1
  429. package/dist/chunk-Y527D4TV.js +0 -56
  430. package/dist/chunk-Y527D4TV.js.map +0 -1
  431. package/dist/chunk-ZDZERB6L.js.map +0 -1
  432. package/dist/chunk-ZNNXRNFD.js.map +0 -1
  433. package/dist/chunk-ZURZHELF.js.map +0 -1
  434. package/dist/cli-E36SPKBW.js.map +0 -1
  435. package/dist/codex-install-HQZDGFXW.js.map +0 -1
  436. package/dist/config-HY2E4GGW.js +0 -55
  437. package/dist/doctor-I6XQEKWD.js.map +0 -1
  438. package/dist/fund-2QRO7OJL.js +0 -378
  439. package/dist/fund-2QRO7OJL.js.map +0 -1
  440. package/dist/hook-command-2UBCSZG6.js +0 -43
  441. package/dist/install-ILUX5C4A.js +0 -107
  442. package/dist/install-identity-TZKGY6LQ.js +0 -31
  443. package/dist/install-wallet-5M4OTYLX.js.map +0 -1
  444. package/dist/mcp-LE4DUS22.js +0 -14127
  445. package/dist/mcp-LE4DUS22.js.map +0 -1
  446. package/dist/pay-WCG3IH4R.js +0 -55
  447. package/dist/payments-HFPPWHTV.js.map +0 -1
  448. package/dist/plugin-registration-PZFI5GZW.js +0 -68
  449. package/dist/runtime-UZOKSUZX.js +0 -1321
  450. package/dist/runtime-UZOKSUZX.js.map +0 -1
  451. package/dist/send-GCVEAQKL.js.map +0 -1
  452. package/dist/status-HCVAOCN7.js +0 -150
  453. package/dist/status-HCVAOCN7.js.map +0 -1
  454. package/dist/status-line-OPCXDHL2.js.map +0 -1
  455. package/dist/uninstall-BAWRBXXQ.js.map +0 -1
  456. package/dist/update-CACXLQLR.js +0 -56
  457. package/dist/wallet-QL4UUXEZ.js +0 -55
  458. /package/dist/{_esm-BIN7VY2L.js.map → _esm-2KST7HQ7.js.map} +0 -0
  459. /package/dist/{alive-GSOWKUOY.js.map → alive-5TV22PNF.js.map} +0 -0
  460. /package/dist/{auto-update-Y24UL56V.js.map → auth-XI7BJFLW.js.map} +0 -0
  461. /package/dist/{ccip-DHDFKTQV.js.map → auto-update-7L24KDWA.js.map} +0 -0
  462. /package/dist/{clack-EZ7TDWQU.js.map → balance-DFHC6XEU.js.map} +0 -0
  463. /package/dist/{claude-cli-2YKABJJZ.js.map → ccip-HOW3DZYF.js.map} +0 -0
  464. /package/dist/{chunk-IE7P2BZE.js.map → chunk-6QMDUDF2.js.map} +0 -0
  465. /package/dist/{chunk-KG3D7FIF.js.map → chunk-CZJOMUBP.js.map} +0 -0
  466. /package/dist/{chunk-3GNJXKIT.js.map → chunk-F43CV6UC.js.map} +0 -0
  467. /package/dist/{chunk-J57UC3DD.js.map → chunk-FKVJKLPI.js.map} +0 -0
  468. /package/dist/{chunk-SO3XRZPX.js.map → chunk-HPRVFJPM.js.map} +0 -0
  469. /package/dist/{chunk-2GP3HRYK.js.map → chunk-INSIW65E.js.map} +0 -0
  470. /package/dist/{chunk-RL5UUDT4.js.map → chunk-JNUKLSMZ.js.map} +0 -0
  471. /package/dist/{chunk-JRGFKVAZ.js.map → chunk-PETQ5WEA.js.map} +0 -0
  472. /package/dist/{codex-event-ZO2GEFE6.js.map → chunk-TUCKEEXE.js.map} +0 -0
  473. /package/dist/{chunk-BPMWXTFX.js.map → chunk-WFZX352D.js.map} +0 -0
  474. /package/dist/{chunk-6CMM6YCB.js.map → chunk-YWWMISDY.js.map} +0 -0
  475. /package/dist/{codex-host-KECJVTA2.js.map → clack-Q4RNC5VE.js.map} +0 -0
  476. /package/dist/{config-HY2E4GGW.js.map → claude-cli-GIIHOBGT.js.map} +0 -0
  477. /package/dist/{env-proxy-R6ZMLQTT.js.map → claude-install-BAUSJMW3.js.map} +0 -0
  478. /package/dist/{ethersCompat-Df4a6QIZ-X6YZWAML.js.map → codex-event-EUTCAOTQ.js.map} +0 -0
  479. /package/dist/{hook-command-2UBCSZG6.js.map → codex-host-ZON3S6HU.js.map} +0 -0
  480. /package/dist/{hosts-DVQJ32QC.js.map → config-QZOBMTEL.js.map} +0 -0
  481. /package/dist/{install-ILUX5C4A.js.map → config-rules-YOYHS6YL.js.map} +0 -0
  482. /package/dist/{install-identity-TZKGY6LQ.js.map → decision-QSKHOGCO.js.map} +0 -0
  483. /package/dist/{package-IJFGMWEV.js.map → env-proxy-XLSLHBKQ.js.map} +0 -0
  484. /package/dist/{passphrase-IFTDS3CU.js.map → ethersCompat-Df4a6QIZ-K3DMHR6Y.js.map} +0 -0
  485. /package/dist/{paths-XCSAKISU.js.map → flush-stdio-NYIJ3QXT.js.map} +0 -0
  486. /package/dist/{pay-WCG3IH4R.js.map → hook-command-VZ27MGWO.js.map} +0 -0
  487. /package/dist/{plugin-registration-PZFI5GZW.js.map → hosts-3EMTVM4H.js.map} +0 -0
  488. /package/dist/{redact-D7ASVWKL.js.map → install-ZA7L2UF3.js.map} +0 -0
  489. /package/dist/{runtime-fetch-ZSSSK72Y.js.map → install-funding-JDGYTF72.js.map} +0 -0
  490. /package/dist/{runtime-layout-WIDILZ6K.js.map → install-identity-FFAYEFLX.js.map} +0 -0
  491. /package/dist/{secp256k1-ZZZT2CAX.js.map → new-install-5L4GY3LN.js.map} +0 -0
  492. /package/dist/{update-CACXLQLR.js.map → package-BONDXSV3.js.map} +0 -0
  493. /package/dist/{usdc-VG4CIOUK.js.map → passphrase-T4ULBN4M.js.map} +0 -0
  494. /package/dist/{viemAdapter-By13KInL-DOFTEIJV.js.map → paths-O2KDWZ76.js.map} +0 -0
  495. /package/dist/{wallet-QL4UUXEZ.js.map → pay-CMV5KL74.js.map} +0 -0
@@ -1,2037 +0,0 @@
1
- import { createRequire as __tenjinCreateRequire } from 'node:module'; const require = __tenjinCreateRequire(import.meta.url);
2
- import {
3
- modeGatedPointer
4
- } from "./chunk-4LMUQMBH.js";
5
- import {
6
- CONTEXT_MAX,
7
- HARNESS_MS,
8
- PATCH_TOOL,
9
- SHELL_TOOL,
10
- decode,
11
- encode,
12
- hasErrorMarker
13
- } from "./chunk-3623BLPV.js";
14
- import {
15
- AGENT_ID_RE
16
- } from "./chunk-XKESD27X.js";
17
- import {
18
- style
19
- } from "./chunk-FVIGCDSV.js";
20
- import {
21
- CHANNEL_DEPOSIT_ATOMIC,
22
- ROUTING_FEE_ATOMIC,
23
- usd
24
- } from "./chunk-HDPUXS3Z.js";
25
- import {
26
- withAppServer
27
- } from "./chunk-E7SW44LM.js";
28
- import {
29
- codexHome
30
- } from "./chunk-F3ED5WTR.js";
31
- import {
32
- confirmChoice
33
- } from "./chunk-DOQGNFHM.js";
34
- import {
35
- LockTimeoutError,
36
- withFileLock
37
- } from "./chunk-MEFB5KHA.js";
38
- import {
39
- HOOK_TOOL
40
- } from "./chunk-UUGOUOVT.js";
41
- import {
42
- LEGACY_MCP_SERVER_NAME
43
- } from "./chunk-MPZUYCAP.js";
44
- import {
45
- projectRouterPath,
46
- readProjectRouterFile,
47
- routerSettings
48
- } from "./chunk-AGMVASXZ.js";
49
- import {
50
- isTeamShelfOrigin,
51
- loadProjectConfig
52
- } from "./chunk-KM7RY2ZS.js";
53
- import {
54
- parseUsdToAtomic,
55
- toMoney
56
- } from "./chunk-Y527D4TV.js";
57
- import {
58
- hasCode
59
- } from "./chunk-2I4QTOLB.js";
60
- import {
61
- CONFIG_KEYS,
62
- DEFAULT_MAX_AUTO_SPEND,
63
- DEFAULT_SESSION_BUDGET,
64
- EXPERIMENTAL_CONFIG_KEYS,
65
- HARNESSES,
66
- HOOKS_CONFIG_KEYS,
67
- LOOP_CONFIG_KEYS,
68
- MAX_AUTO_SPEND_FLOOR_ATOMIC,
69
- MAX_AUTO_SPEND_FLOOR_WHY,
70
- PUBLISH_CONFIG_KEYS,
71
- PublishModeSchema,
72
- RETIRED_PAYMENT_GUIDANCE,
73
- ROUTER_CONFIG_KEYS,
74
- ROUTER_CONTEXTS,
75
- RawConfigSchema,
76
- SEND_MAX_UNSET,
77
- TEAM_CONFIG_KEYS,
78
- UPDATE_CONFIG_KEYS,
79
- loadRawConfig,
80
- parseAckServerWarnings,
81
- parseLoopValue,
82
- parsePublicFallbackFlag,
83
- parseUpdateModeFlag,
84
- resolveSettings,
85
- retiredPaymentKeys
86
- } from "./chunk-2M2VPI2E.js";
87
- import {
88
- PRODUCTION_ORIGIN,
89
- isSameDeployment
90
- } from "./chunk-XQJXNMSB.js";
91
- import {
92
- writeFileAtomic
93
- } from "./chunk-7WEQQJLG.js";
94
- import {
95
- CliError
96
- } from "./chunk-3UCIG4TG.js";
97
- import {
98
- configPath,
99
- hooksDir
100
- } from "./chunk-OJNTCYQQ.js";
101
-
102
- // src/commands/config.ts
103
- import { mkdir as mkdir2 } from "node:fs/promises";
104
- import { homedir } from "node:os";
105
- import { dirname as dirname3 } from "node:path";
106
-
107
- // src/lib/harness-permissions.ts
108
- import { chmod, lstat, mkdir, readFile, realpath, stat as stat2 } from "node:fs/promises";
109
- import { dirname, join as join2 } from "node:path";
110
-
111
- // src/lib/codex-rules.ts
112
- import { execFile } from "node:child_process";
113
- import { rm, stat } from "node:fs/promises";
114
- import { join } from "node:path";
115
- function codexRulesPath(home, env = process.env) {
116
- return join(codexHome(home, env), "rules", "tenjin.rules");
117
- }
118
- function prefixTokens(rule) {
119
- const m = /^Bash\(tenjin ((?:[a-z][a-z-]* )*[a-z][a-z-]*):\*\)$/.exec(rule);
120
- const verbs = m?.[1];
121
- if (verbs === void 0) return null;
122
- return ["tenjin", ...verbs.split(" ")];
123
- }
124
- function prefixRuleLine(tokens) {
125
- const pattern = tokens.map((t) => JSON.stringify(t)).join(", ");
126
- return `prefix_rule(pattern=[${pattern}], decision="allow")`;
127
- }
128
- function grantedPrefixes(rules) {
129
- return rules.map(prefixTokens).filter((t) => t !== null);
130
- }
131
- function rulesFileBody(rules) {
132
- const lines = [
133
- "# Written by `tenjin install`. Change it with `tenjin config set publish.mode`",
134
- "# or `tenjin uninstall`, not by hand: the next install rewrites it whole.",
135
- "# Your own rules live in default.rules and are never touched by Tenjin.",
136
- "",
137
- ...grantedPrefixes(rules).map(prefixRuleLine)
138
- ];
139
- return `${lines.join("\n")}
140
- `;
141
- }
142
- async function verifyPrefixAllowed(rulesPath, tokens, env = process.env, timeoutMs = VERIFY_MS) {
143
- return await new Promise((resolve2) => {
144
- execFile(
145
- "codex",
146
- ["execpolicy", "check", "--rules", rulesPath, ...tokens],
147
- { env, timeout: timeoutMs, windowsHide: true },
148
- (_err, stdout) => {
149
- if (typeof stdout !== "string" || stdout.length === 0) {
150
- resolve2(null);
151
- return;
152
- }
153
- try {
154
- const parsed = JSON.parse(stdout);
155
- const decision = typeof parsed === "object" && parsed !== null ? parsed.decision : void 0;
156
- resolve2(decision === "allow");
157
- } catch {
158
- resolve2(null);
159
- }
160
- }
161
- );
162
- });
163
- }
164
- var VERIFY_MS = 5e3;
165
- async function removeCodexGrant(home, env = process.env) {
166
- const path = codexRulesPath(home, env);
167
- const found = await stat(path).catch(() => null);
168
- if (found === null || !found.isFile()) return { path, removed: false };
169
- await rm(path, { force: true });
170
- return { path, removed: true };
171
- }
172
-
173
- // src/lib/harness-permissions.ts
174
- function claudeSettingsPath(homeDir) {
175
- return join2(homeDir, ".claude", "settings.json");
176
- }
177
- async function inspectClaudeGrant(homeDir, mode) {
178
- const found = await inspectAllowlist(homeDir, mode);
179
- if ("result" in found) {
180
- const refused = found.result;
181
- return {
182
- harness: "claude",
183
- state: "unknown",
184
- ...refused.path !== void 0 ? { path: refused.path } : {},
185
- rules: [],
186
- missing: [],
187
- detail: refused.warning ?? `${claudeSettingsPath(homeDir)} could not be read.`,
188
- ...refused.fix !== void 0 ? { fix: refused.fix } : {}
189
- };
190
- }
191
- const missing = [...found.added];
192
- return {
193
- harness: "claude",
194
- state: missing.length === 0 ? "granted" : "pending",
195
- path: found.path,
196
- rules: [...found.alreadyPresent],
197
- missing,
198
- detail: missing.length === 0 ? `${found.alreadyPresent.length} rules in ${found.path}` : `${missing.length} of this mode's rules are missing from ${found.path}`,
199
- ...missing.length === 0 ? {} : { fix: "tenjin install" }
200
- };
201
- }
202
- async function tighten(path) {
203
- if (process.platform === "win32") return;
204
- const found = await stat2(path).catch(() => null);
205
- if (found === null || (found.mode & 63) === 0) return;
206
- await chmod(path, 384).catch(() => void 0);
207
- }
208
- async function inspectCodexGrant(homeDir, mode, env = process.env) {
209
- const path = codexRulesPath(homeDir, env);
210
- const writable = rulesForPublishMode(mode);
211
- const want = rulesFileBody(writable);
212
- const rules = grantedPrefixes(writable).map((tokens) => tokens.join(" "));
213
- const found = await readFile(path, "utf8").catch(() => null);
214
- if (found !== want) {
215
- return {
216
- harness: "codex",
217
- state: "pending",
218
- path,
219
- rules: [],
220
- missing: rules,
221
- detail: found === null ? `no grant is installed at ${path}` : `${path} does not match what publish.mode ${mode} calls for`,
222
- fix: "tenjin install"
223
- };
224
- }
225
- const probe = grantedPrefixes(writable).at(-1);
226
- const agreed = probe === void 0 ? null : await verifyPrefixAllowed(path, probe, env);
227
- if (agreed === false) {
228
- return {
229
- harness: "codex",
230
- state: "pending",
231
- path,
232
- rules: [],
233
- missing: rules,
234
- detail: `${path} is installed but Codex does not read it as granting \`${probe?.join(" ")}\``,
235
- fix: "tenjin install"
236
- };
237
- }
238
- if (agreed === null) {
239
- return {
240
- harness: "codex",
241
- state: "unknown",
242
- path,
243
- rules,
244
- missing: [],
245
- detail: `${rules.length} prefixes written to ${path}, but codex could not be asked whether it reads them as a grant`,
246
- fix: "Check `codex execpolicy check --rules <file> tenjin publish x` on the machine itself."
247
- };
248
- }
249
- return {
250
- harness: "codex",
251
- state: "granted",
252
- path,
253
- rules,
254
- missing: [],
255
- detail: `${rules.length} prefixes in ${path}, confirmed by codex execpolicy`
256
- };
257
- }
258
- async function wireCodexGrant(homeDir, mode, env = process.env) {
259
- const path = codexRulesPath(homeDir, env);
260
- const rules = rulesForPublishMode(mode);
261
- const body = rulesFileBody(rules);
262
- const granted = grantedPrefixes(rules).map((t) => t.join(" "));
263
- try {
264
- await mkdir(dirname(path), { recursive: true });
265
- const current = await readFile(path, "utf8").catch(() => null);
266
- if (current === body) {
267
- await tighten(path);
268
- return { path, granted, wrote: false };
269
- }
270
- await writeFileAtomic(path, body, { mode: 384 });
271
- return { path, granted, wrote: true };
272
- } catch (err) {
273
- return {
274
- path,
275
- granted: [],
276
- wrote: false,
277
- error: err instanceof Error ? err.message : String(err)
278
- };
279
- }
280
- }
281
- var FREE_VERB_RULES = [
282
- "Bash(tenjin search:*)",
283
- "Bash(tenjin wallet fund:*)",
284
- "Bash(tenjin inspect:*)",
285
- "Bash(tenjin read:*)",
286
- "Bash(tenjin outcome:*)",
287
- "Bash(tenjin doctor:*)",
288
- "Bash(tenjin wallet show:*)",
289
- "Bash(tenjin wallet balance:*)",
290
- "Bash(tenjin config get:*)"
291
- ];
292
- var PUBLISH_MODE_RULE = "Bash(tenjin publish:*)";
293
- var EDIT_MODE_RULE = "Bash(tenjin edit:*)";
294
- var MODE_GATED_RULES = [PUBLISH_MODE_RULE, EDIT_MODE_RULE];
295
- function rulesForPublishMode(mode) {
296
- return mode === "review" ? FREE_VERB_RULES : [...FREE_VERB_RULES, ...MODE_GATED_RULES];
297
- }
298
- function retiredFor(mode) {
299
- const retired = new Set(LEGACY_ALLOWLIST_RULES);
300
- if (mode === "review") for (const rule of MODE_GATED_RULES) retired.add(rule);
301
- return retired;
302
- }
303
- var LEGACY_ALLOWLIST_RULES = [
304
- "Bash(tenjin candidate list:*)",
305
- "Bash(tenjin fund:*)"
306
- ];
307
- var MODE_GRANT_UNDO = [
308
- "tenjin install --publish-mode review",
309
- "tenjin config set publish.mode review",
310
- "tenjin uninstall"
311
- ];
312
- function modeGrantFor(mode, added, present, planned) {
313
- const wasAdded = MODE_GATED_RULES.filter((r) => added.includes(r));
314
- const wasPresent = MODE_GATED_RULES.filter((r) => present.includes(r));
315
- const rules = [...wasAdded, ...wasPresent];
316
- if (rules.length === 0) return void 0;
317
- const state = wasAdded.length === 0 ? "already-present" : wasPresent.length === 0 ? "added" : "mixed";
318
- const verb = state === "already-present" ? "already present" : state === "mixed" ? planned ? "would be in place" : "in place" : planned ? "would be added" : "added";
319
- return {
320
- rules: MODE_GATED_RULES.filter((r) => rules.includes(r)),
321
- state,
322
- disclosure: `${MODE_GATED_RULES.join(" and ")} ${verb}: on publish.mode ${mode} your agent can publish to the public marketplace under your identity, update its own posts, and open your wallet keystore to sign, without a harness prompt.`,
323
- undo: [...MODE_GRANT_UNDO]
324
- };
325
- }
326
- function fixFor(reason, harness = "claude") {
327
- switch (reason) {
328
- case "harness-unsupported":
329
- return `No permission rules were written: ${harness} has no surface for them.`;
330
- case "not-requested":
331
- case "declined":
332
- case "dry-run":
333
- return "Add them with `tenjin install`.";
334
- case "changed-since-read":
335
- return "Another process changed the file mid-run; re-run `tenjin install`.";
336
- default:
337
- return "Fix the reported file, then run `tenjin install`.";
338
- }
339
- }
340
- function tiers(added, alreadyPresent, mode, planned = false) {
341
- const gated = new Set(MODE_GATED_RULES);
342
- const grant = modeGrantFor(mode, added, alreadyPresent, planned);
343
- return {
344
- addedFree: added.filter((r) => !gated.has(r)),
345
- alreadyPresentFree: alreadyPresent.filter((r) => !gated.has(r)),
346
- ...grant !== void 0 ? { modeGrant: grant } : {}
347
- };
348
- }
349
- function skip(harness, path, reason, warning) {
350
- return {
351
- harness,
352
- ...path !== void 0 ? { path } : {},
353
- added: [],
354
- removed: [],
355
- alreadyPresent: [],
356
- addedFree: [],
357
- alreadyPresentFree: [],
358
- skipped: reason,
359
- ...warning !== void 0 ? { warning } : {},
360
- fix: fixFor(reason, harness)
361
- };
362
- }
363
- function isPlainObject(value) {
364
- return typeof value === "object" && value !== null && !Array.isArray(value);
365
- }
366
- async function writeSettings(path, next) {
367
- const current = await stat2(path).catch(() => null);
368
- await writeFileAtomic(
369
- path,
370
- `${JSON.stringify(next, null, 2)}
371
- `,
372
- current === null ? {} : { mode: current.mode & 511 }
373
- );
374
- }
375
- async function retractModeGatedRules(homeDir) {
376
- const found = await inspectAllowlist(homeDir, "review");
377
- if ("result" in found) {
378
- const refused = found.result;
379
- return {
380
- ...refused,
381
- fix: `${refused.path ?? claudeSettingsPath(homeDir)} could not be read, so ${MODE_GATED_RULES.join(" and ")} may still be allowed there. Remove those lines by hand, or run \`tenjin uninstall\`.`
382
- };
383
- }
384
- const { path, raw, settings, permissions, allow } = found;
385
- const gated = new Set(MODE_GATED_RULES);
386
- const removed = allow.filter((r) => typeof r === "string" && gated.has(r));
387
- if (removed.length === 0) {
388
- return {
389
- harness: "claude",
390
- path,
391
- added: [],
392
- alreadyPresent: [],
393
- addedFree: [],
394
- alreadyPresentFree: [],
395
- removed: []
396
- };
397
- }
398
- const kept = allow.filter((r) => !(typeof r === "string" && gated.has(r)));
399
- const next = { ...settings, permissions: { ...permissions, allow: kept } };
400
- const current = await readFile(path, "utf8").catch(() => null);
401
- if (current !== raw) {
402
- return skip(
403
- "claude",
404
- path,
405
- "changed-since-read",
406
- `${path} changed while it was being updated, so nothing was written. Re-run to retract ${MODE_GATED_RULES.join(" and ")}.`
407
- );
408
- }
409
- await writeSettings(path, next);
410
- return {
411
- harness: "claude",
412
- path,
413
- added: [],
414
- alreadyPresent: [],
415
- addedFree: [],
416
- alreadyPresentFree: [],
417
- removed
418
- };
419
- }
420
- async function wireFreeVerbAllowlist(homeDir, mode = "review") {
421
- const found = await inspectAllowlist(homeDir, mode);
422
- if ("result" in found) return found.result;
423
- const { path, raw, settings, permissions, allow, added, alreadyPresent } = found;
424
- const retired = retiredFor(mode);
425
- const removed = allow.filter((r) => typeof r === "string" && retired.has(r));
426
- if (added.length === 0 && removed.length === 0) {
427
- return {
428
- harness: "claude",
429
- path,
430
- added: [],
431
- alreadyPresent,
432
- ...tiers([], alreadyPresent, mode),
433
- removed: []
434
- };
435
- }
436
- const kept = allow.filter((r) => !(typeof r === "string" && retired.has(r)));
437
- const next = {
438
- ...settings,
439
- permissions: { ...permissions, allow: [...kept, ...added] }
440
- };
441
- const current = await readFile(path, "utf8").catch(() => null);
442
- if (current !== raw) {
443
- return skip(
444
- "claude",
445
- path,
446
- "changed-since-read",
447
- `${path} changed while it was being updated, so nothing was written. Re-run \`tenjin install\`.`
448
- );
449
- }
450
- await writeSettings(path, next);
451
- return {
452
- harness: "claude",
453
- path,
454
- added,
455
- alreadyPresent,
456
- ...tiers(added, alreadyPresent, mode),
457
- removed
458
- };
459
- }
460
- async function inspectFreeVerbRules(homeDir, mode = "review") {
461
- const found = await inspectAllowlist(homeDir, mode);
462
- if ("result" in found) return { pending: null };
463
- if (found.added.length > 0) return { pending: found.added };
464
- const retired = retiredFor(mode);
465
- if (found.allow.some((r) => typeof r === "string" && retired.has(r))) return { pending: [] };
466
- return {
467
- pending: [],
468
- satisfied: {
469
- harness: "claude",
470
- path: found.path,
471
- added: [],
472
- alreadyPresent: found.alreadyPresent,
473
- ...tiers([], found.alreadyPresent, mode),
474
- removed: []
475
- }
476
- };
477
- }
478
- async function inspectAllowlist(homeDir, mode) {
479
- return inspectAllowlistAt(claudeSettingsPath(homeDir), rulesForPublishMode(mode));
480
- }
481
- async function inspectAllowlistAt(declaredPath, rules, list = "allow") {
482
- const refuse = (p, reason, warning) => ({ result: skip("claude", p, reason, warning) });
483
- const entry = await lstat(declaredPath).catch(() => null);
484
- let path = declaredPath;
485
- if (entry !== null) {
486
- try {
487
- path = await realpath(declaredPath);
488
- } catch (err) {
489
- return refuse(
490
- declaredPath,
491
- "unresolvable",
492
- `${declaredPath} could not be resolved (${err.message}); it was left exactly as it is.`
493
- );
494
- }
495
- }
496
- let settings = {};
497
- let raw = null;
498
- if (entry !== null) {
499
- try {
500
- raw = await readFile(path, "utf8");
501
- } catch (err) {
502
- return refuse(
503
- path,
504
- "unreadable",
505
- `${path} could not be read (${err.message}); no permissions were written.`
506
- );
507
- }
508
- let parsed;
509
- try {
510
- parsed = JSON.parse(raw);
511
- } catch (err) {
512
- return refuse(
513
- path,
514
- "unparsable",
515
- `${path} is not valid JSON (${err.message}); it was left exactly as it is.`
516
- );
517
- }
518
- if (!isPlainObject(parsed)) {
519
- return refuse(
520
- path,
521
- "unexpected-shape",
522
- `${path} is not a JSON object; it was left exactly as it is.`
523
- );
524
- }
525
- settings = parsed;
526
- }
527
- const permissionsValue = settings.permissions;
528
- if (permissionsValue !== void 0 && !isPlainObject(permissionsValue)) {
529
- return refuse(
530
- path,
531
- "unexpected-shape",
532
- `${path} has a "permissions" key that is not an object; it was left exactly as it is.`
533
- );
534
- }
535
- const permissions = permissionsValue ?? {};
536
- const allowValue = permissions[list];
537
- if (allowValue !== void 0 && !Array.isArray(allowValue)) {
538
- return refuse(
539
- path,
540
- "unexpected-shape",
541
- `${path} has a "permissions.${list}" key that is not an array; it was left exactly as it is.`
542
- );
543
- }
544
- const allow = allowValue ?? [];
545
- const present = new Set(allow.filter((e) => typeof e === "string"));
546
- const added = rules.filter((rule) => !present.has(rule));
547
- const alreadyPresent = rules.filter((rule) => present.has(rule));
548
- return { path, raw, settings, permissions, allow, added, alreadyPresent: [...alreadyPresent] };
549
- }
550
-
551
- // src/lib/skill-wiring.ts
552
- import { existsSync, statSync } from "node:fs";
553
- import { constants, open } from "node:fs/promises";
554
- import { delimiter, join as join4 } from "node:path";
555
-
556
- // src/lib/skills-source.ts
557
- import { dirname as dirname2, join as join3 } from "node:path";
558
- var SKILL_NAMES = ["tenjin-search", "tenjin-publish", "tenjin"];
559
- var RETIRED_SKILL_NAMES = ["tenjin-pay"];
560
- var PACKAGED_SKILL_NAMES = [...SKILL_NAMES];
561
- var SHIPPED_SKILL_FILES = {
562
- "tenjin-search": ["SKILL.md", "references/permissions.md"],
563
- "tenjin-publish": ["SKILL.md", "references/maintain.md"],
564
- tenjin: ["SKILL.md"],
565
- "tenjin-pay": ["SKILL.md"]
566
- };
567
- var SENTINEL = join3("tenjin", "SKILL.md");
568
-
569
- // src/lib/skill-wiring.ts
570
- var CLI_SKILL_NAMES = [
571
- "tenjin-search",
572
- "tenjin-publish"
573
- ];
574
- function skillsDirsFor(home) {
575
- return [join4(home, ".claude", "skills"), join4(home, ".agents", "skills")];
576
- }
577
- function harnessTargetDir(home, harness) {
578
- if (harness === "claude") return join4(home, ".claude", "skills");
579
- return join4(home, ".agents", "skills");
580
- }
581
- function harnessFlagFor(home, dir) {
582
- if (dir === join4(home, ".claude", "skills")) return "claude";
583
- return "codex";
584
- }
585
- function harnessDetectedBy(home, harness, which) {
586
- const reasons = [];
587
- if (existsSync(join4(home, `.${harness}`))) reasons.push("home-dir");
588
- if (which(harness)) reasons.push("binary");
589
- return reasons;
590
- }
591
- function detectHarnesses(home, which) {
592
- return {
593
- claude: harnessDetectedBy(home, "claude", which).length > 0,
594
- codex: harnessDetectedBy(home, "codex", which).length > 0
595
- };
596
- }
597
- function harnessReads(home, dir, present) {
598
- if (harnessFlagFor(home, dir) === "claude") return present.claude;
599
- return present.codex;
600
- }
601
- function harnessRequested(home, dir, requested) {
602
- return requested.some((h) => harnessTargetDir(home, h) === dir);
603
- }
604
- function harnessInPlay(home, dir, present, requested) {
605
- if (requested.length > 0) return harnessRequested(home, dir, requested);
606
- return harnessReads(home, dir, present);
607
- }
608
- function onPath(bin, env) {
609
- const raw = env.PATH ?? "";
610
- const exts = process.platform === "win32" ? ["", ...(env.PATHEXT ?? ".EXE;.CMD;.BAT;.COM").split(";").filter((e) => e.length > 0)] : [""];
611
- for (const part of raw.split(delimiter)) {
612
- if (part.length === 0) continue;
613
- for (const ext of exts) {
614
- if (isFile(join4(part, bin + ext))) return true;
615
- }
616
- }
617
- return false;
618
- }
619
- function isFile(p) {
620
- try {
621
- return statSync(p).isFile();
622
- } catch {
623
- return false;
624
- }
625
- }
626
- async function readSkillFile(path) {
627
- let handle;
628
- try {
629
- handle = await open(path, constants.O_RDONLY | (constants.O_NONBLOCK ?? 0));
630
- } catch (err) {
631
- if (hasCode(err, "ENOENT")) return { kind: "absent" };
632
- return { kind: "unreadable", err };
633
- }
634
- try {
635
- if (!(await handle.stat()).isFile()) return { kind: "not-regular" };
636
- return { kind: "ok", bytes: await handle.readFile() };
637
- } catch (err) {
638
- return { kind: "unreadable", err };
639
- } finally {
640
- await handle.close().catch(() => void 0);
641
- }
642
- }
643
- function skillFrontmatterName(skillMd) {
644
- const frontmatter = extractFrontmatter(skillMd);
645
- if (frontmatter === null) return null;
646
- for (const line of frontmatter) {
647
- const m = /^name:\s*(.+?)\s*$/.exec(line);
648
- if (m !== null) return (m[1] ?? "").replace(/^["']|["']$/g, "");
649
- }
650
- return null;
651
- }
652
- function extractFrontmatter(text) {
653
- const lines = text.replace(/^\uFEFF/, "").split(/\r?\n/);
654
- const open2 = lines.findIndex((l) => l.trim().length > 0);
655
- if (open2 === -1 || lines[open2]?.trim() !== "---") return null;
656
- const end = lines.findIndex((l, i) => i > open2 && l.trim() === "---");
657
- if (end === -1) return null;
658
- return lines.slice(open2 + 1, end);
659
- }
660
-
661
- // src/adapters/claude.ts
662
- var NATIVE_TO_EVENT = {
663
- SessionStart: "session.start",
664
- UserPromptSubmit: "prompt",
665
- PreToolUse: "tool.before",
666
- PostToolUse: "tool.after",
667
- PostToolUseFailure: "tool.after",
668
- SubagentStart: "agent.start",
669
- SubagentStop: "agent.stop",
670
- Stop: "turn.end"
671
- };
672
- var TOOLS = {
673
- web: /^WebSearch$/,
674
- fetch: /^WebFetch$/,
675
- dispatch: /^(Agent|Task)$/,
676
- shell: /^Bash$/,
677
- edit: /^(Edit|Write|MultiEdit)$/,
678
- read: /^Read$/
679
- };
680
- function matcherOf(re) {
681
- return re.source.replace(/^\^\(?/, "").replace(/\)?\$$/, "");
682
- }
683
- var SESSION_START_MATCHER = "startup|clear|compact";
684
- function isRecord(v) {
685
- return typeof v === "object" && v !== null && !Array.isArray(v);
686
- }
687
- function str(v) {
688
- return typeof v === "string" ? v : void 0;
689
- }
690
- function toolKind(name) {
691
- for (const kind of Object.keys(TOOLS)) if (TOOLS[kind].test(name)) return kind;
692
- return "other";
693
- }
694
- function canonicalTool(name, input) {
695
- const kind = toolKind(name);
696
- switch (kind) {
697
- case "shell":
698
- return { name, kind, command: str(input.command) ?? "" };
699
- case "edit":
700
- case "read": {
701
- const path = str(input.file_path);
702
- return { name, kind, paths: path === void 0 ? [] : [path] };
703
- }
704
- case "dispatch": {
705
- const description = str(input.description);
706
- return {
707
- name,
708
- kind,
709
- task: str(input.prompt) ?? "",
710
- ...description !== void 0 ? { description } : {}
711
- };
712
- }
713
- case "web":
714
- return { name, kind, query: str(input.query) ?? "" };
715
- case "fetch":
716
- return { name, kind, url: str(input.url) ?? "", prompt: str(input.prompt) ?? "" };
717
- default:
718
- return { name, kind };
719
- }
720
- }
721
- function toolResult(v) {
722
- if (typeof v === "string") return { text: v };
723
- if (!isRecord(v)) return void 0;
724
- const out = {};
725
- const stdout = str(v.stdout);
726
- const stderr = str(v.stderr);
727
- const error = str(v.error);
728
- if (stdout !== void 0) out.stdout = stdout;
729
- if (stderr !== void 0) out.stderr = stderr;
730
- if (error !== void 0) out.error = error;
731
- if (stdout === void 0 && stderr === void 0 && error === void 0) {
732
- const text = str(v.text) ?? str(v.content) ?? str(v.result);
733
- if (text !== void 0) out.text = text;
734
- }
735
- return out;
736
- }
737
- function decode2(raw) {
738
- if (!isRecord(raw)) return null;
739
- const native = str(raw.hook_event_name);
740
- if (native === void 0) return null;
741
- const event = NATIVE_TO_EVENT[native];
742
- if (event === void 0) return null;
743
- const session = str(raw.session_id);
744
- if (session === void 0 || session.length === 0) return null;
745
- const input = {
746
- harness: "claude",
747
- event,
748
- native: { event: native },
749
- session,
750
- cwd: str(raw.cwd) ?? "",
751
- raw
752
- };
753
- if (raw.agent_id !== void 0 && raw.agent_id !== null) {
754
- const id = raw.agent_id;
755
- if (typeof id !== "string" || !AGENT_ID_RE.test(id)) return null;
756
- input.agent = id;
757
- }
758
- const turn = str(raw.prompt_id);
759
- if (turn !== void 0) input.turn = turn;
760
- const prompt = str(raw.prompt);
761
- if (prompt !== void 0) input.prompt = prompt;
762
- const agentType = str(raw.agent_type);
763
- if (agentType !== void 0) input.agentType = agentType;
764
- const lastMessage = str(raw.last_assistant_message);
765
- if (lastMessage !== void 0) input.lastMessage = lastMessage;
766
- if (typeof raw.stop_hook_active === "boolean") input.stopFuse = raw.stop_hook_active;
767
- const source = str(raw.source);
768
- if (source !== void 0) input.source = source;
769
- const path = str(raw.transcript_path);
770
- const agentPath = str(raw.agent_transcript_path);
771
- if (path !== void 0 || agentPath !== void 0) {
772
- input.transcript = {};
773
- if (path !== void 0) input.transcript.path = path;
774
- if (agentPath !== void 0) input.transcript.agentPath = agentPath;
775
- }
776
- if (event === "tool.before" || event === "tool.after") {
777
- const name = str(raw.tool_name) ?? "";
778
- const tool = canonicalTool(name, isRecord(raw.tool_input) ? raw.tool_input : {});
779
- const callId = str(raw.tool_use_id);
780
- if (callId !== void 0) tool.callId = callId;
781
- if (event === "tool.after") {
782
- if (native === "PostToolUseFailure") {
783
- tool.ok = false;
784
- if (typeof raw.error === "string") tool.result = { error: raw.error };
785
- else {
786
- const result = toolResult(raw.error);
787
- if (result !== void 0) tool.result = result;
788
- }
789
- } else {
790
- const result = toolResult(raw.tool_response);
791
- if (result !== void 0) tool.result = result;
792
- tool.ok = !(tool.kind === "shell" && hasErrorMarker((result?.stdout ?? "") + "\n" + (result?.stderr ?? "")));
793
- }
794
- if (typeof raw.is_interrupt === "boolean") tool.interrupted = raw.is_interrupt;
795
- }
796
- input.tool = tool;
797
- }
798
- return input;
799
- }
800
- function encode2(emit, input) {
801
- if (emit === null || emit.context === void 0 || emit.context.length === 0) return null;
802
- return {
803
- hookSpecificOutput: {
804
- hookEventName: input.native.event,
805
- additionalContext: emit.context.slice(0, CONTEXT_MAX)
806
- }
807
- };
808
- }
809
- function httpHandler(url, token, timeoutSeconds) {
810
- return {
811
- type: "http",
812
- url,
813
- headers: { Authorization: `Bearer ${token}` },
814
- timeout: timeoutSeconds
815
- };
816
- }
817
- function commandHandler(shimPath, timeoutSeconds) {
818
- return {
819
- type: "command",
820
- command: `node ${JSON.stringify(shimPath)} --harness claude`,
821
- timeout: timeoutSeconds
822
- };
823
- }
824
- var registrar = {
825
- configPath(home) {
826
- return claudeSettingsPath(home);
827
- },
828
- /**
829
- * 9 `http` entries and 2 `command` entries (02-redesign.md §4). SessionStart
830
- * and UserPromptSubmit run the shim because every turn begins with a prompt:
831
- * the daemon is then up before any tool-path fire of that turn.
832
- */
833
- plan({ url, token, shimPath, timeoutSeconds }) {
834
- const http = [httpHandler(url, token, timeoutSeconds)];
835
- const command = [commandHandler(shimPath, timeoutSeconds)];
836
- return [
837
- { event: "SessionStart", matcher: SESSION_START_MATCHER, hooks: command },
838
- { event: "UserPromptSubmit", hooks: command },
839
- // ONE entry for both web kinds. The arms are separate; the harness entry
840
- // is not, because a settings file with two PreToolUse entries whose
841
- // matchers overlap is two POSTs for one tool call.
842
- {
843
- event: "PreToolUse",
844
- matcher: `${matcherOf(TOOLS.web)}|${matcherOf(TOOLS.fetch)}`,
845
- hooks: http
846
- },
847
- { event: "PreToolUse", matcher: matcherOf(TOOLS.dispatch), hooks: http },
848
- {
849
- event: "PreToolUse",
850
- matcher: `${matcherOf(TOOLS.edit)}|${matcherOf(TOOLS.shell)}`,
851
- hooks: http
852
- },
853
- { event: "PostToolUse", matcher: matcherOf(TOOLS.shell), hooks: http },
854
- { event: "PostToolUse", matcher: matcherOf(TOOLS.read), hooks: http },
855
- { event: "PostToolUseFailure", matcher: matcherOf(TOOLS.shell), hooks: http },
856
- { event: "SubagentStart", hooks: http },
857
- { event: "SubagentStop", hooks: http },
858
- { event: "Stop", hooks: http }
859
- ];
860
- },
861
- grant: {
862
- path: claudeSettingsPath,
863
- inspect: inspectClaudeGrant,
864
- write: wireFreeVerbAllowlist
865
- }
866
- };
867
- var claudeAdapter = { id: "claude", decode: decode2, encode: encode2, registrar };
868
-
869
- // src/adapters/codex.ts
870
- import { join as join6 } from "node:path";
871
-
872
- // src/lib/codex-trust.ts
873
- import { join as join5 } from "node:path";
874
- var EVENT_LABEL = {
875
- PreToolUse: "pre_tool_use",
876
- PermissionRequest: "permission_request",
877
- PostToolUse: "post_tool_use",
878
- PreCompact: "pre_compact",
879
- PostCompact: "post_compact",
880
- SessionStart: "session_start",
881
- SessionEnd: "session_end",
882
- UserPromptSubmit: "user_prompt_submit",
883
- SubagentStart: "subagent_start",
884
- SubagentStop: "subagent_stop",
885
- Stop: "stop",
886
- Interrupt: "interrupt"
887
- };
888
- function codexConfigPath(home, env = process.env) {
889
- return join5(codexHome(home, env), "config.toml");
890
- }
891
- function isRecord2(v) {
892
- return typeof v === "object" && v !== null && !Array.isArray(v);
893
- }
894
- function foldTrust(rows, keys) {
895
- const wanted = new Set(keys);
896
- const mine = rows.filter((r) => typeof r.key === "string" && wanted.has(r.key));
897
- if (mine.length === 0) return "untrusted";
898
- const status = (r) => typeof r.trustStatus === "string" ? r.trustStatus : "unknown";
899
- if (mine.some((r) => r.enabled === false)) return "disabled";
900
- if (mine.some((r) => status(r) === "modified")) return "modified";
901
- const good = mine.filter((r) => status(r) === "trusted" || status(r) === "managed");
902
- if (good.length === 0) return "untrusted";
903
- if (good.length < keys.length) return "partial";
904
- return "trusted";
905
- }
906
- var PROBE_MS = 8e3;
907
- async function listHooksViaAppServer(home, env, timeoutMs) {
908
- return await withAppServer(home, env, timeoutMs, async (request) => {
909
- const result = await request("hooks/list", { cwds: [] });
910
- return result === void 0 ? null : rowsOf(result);
911
- });
912
- }
913
- function rowsOf(result) {
914
- if (!isRecord2(result) || !Array.isArray(result.data)) return [];
915
- const out = [];
916
- for (const group of result.data) {
917
- if (!isRecord2(group) || !Array.isArray(group.hooks)) continue;
918
- for (const hook of group.hooks) if (isRecord2(hook)) out.push(hook);
919
- }
920
- return out;
921
- }
922
- async function trustCodexHooks(home, keys, ownedBy, opts = {}) {
923
- const env = opts.env ?? process.env;
924
- const timeoutMs = opts.timeoutMs ?? PROBE_MS;
925
- if (keys.length === 0) return { ok: true, trusted: [] };
926
- const run = async (request) => {
927
- const before = await request("hooks/list", { cwds: [] });
928
- if (before === void 0) {
929
- return {
930
- ok: false,
931
- trusted: [],
932
- failedAt: "list",
933
- reason: "hooks/list did not answer"
934
- };
935
- }
936
- const wanted = new Set(keys);
937
- const mine = rowsOf(before).filter(
938
- (r) => typeof r.key === "string" && wanted.has(r.key) && ownedBy(r)
939
- );
940
- if (mine.length !== keys.length) {
941
- return {
942
- ok: false,
943
- trusted: [],
944
- failedAt: "list",
945
- reason: `Codex listed ${mine.length} of the ${keys.length} entries this install wrote`
946
- };
947
- }
948
- const value = {};
949
- for (const row of mine) {
950
- const hash = typeof row.currentHash === "string" ? row.currentHash : null;
951
- if (hash === null) {
952
- return {
953
- ok: false,
954
- trusted: [],
955
- failedAt: "list",
956
- reason: "Codex reported an entry with no currentHash"
957
- };
958
- }
959
- value[row.key] = { trusted_hash: hash, enabled: true };
960
- }
961
- const wrote = await request("config/batchWrite", {
962
- edits: [{ keyPath: "hooks.state", value, mergeStrategy: "upsert" }],
963
- reloadUserConfig: true
964
- });
965
- if (wrote === void 0) {
966
- return {
967
- ok: false,
968
- trusted: [],
969
- failedAt: "write",
970
- reason: "config/batchWrite was refused"
971
- };
972
- }
973
- const after = await request("hooks/list", { cwds: [] });
974
- if (after === void 0) {
975
- return {
976
- ok: false,
977
- trusted: [],
978
- failedAt: "verify",
979
- reason: "the verifying hooks/list did not answer"
980
- };
981
- }
982
- const confirmed = rowsOf(after).filter(
983
- (r) => typeof r.key === "string" && wanted.has(r.key) && ownedBy(r) && r.enabled !== false && (r.trustStatus === "trusted" || r.trustStatus === "managed") && r.currentHash === value[r.key]?.trusted_hash
984
- );
985
- if (confirmed.length !== keys.length) {
986
- return {
987
- ok: false,
988
- trusted: confirmed.map((r) => r.key),
989
- failedAt: "verify",
990
- reason: `Codex confirmed ${confirmed.length} of ${keys.length} entries as trusted after the write`
991
- };
992
- }
993
- return { ok: true, trusted: confirmed.map((r) => r.key) };
994
- };
995
- const outcome = opts.connect !== void 0 ? await run(opts.connect) : await withAppServer(home, env, timeoutMs, run);
996
- return outcome ?? {
997
- ok: false,
998
- trusted: [],
999
- failedAt: "list",
1000
- reason: "the codex app server could not be reached"
1001
- };
1002
- }
1003
- async function readCodexTrust(home, keys, opts = {}) {
1004
- const env = opts.env ?? process.env;
1005
- const configPath2 = codexConfigPath(home, env);
1006
- const base = { configPath: configPath2, trusted: 0, expected: keys.length };
1007
- if (keys.length === 0) return { ...base, state: "unknown", source: "none" };
1008
- const list = await (opts.listHooks ?? ((h, e) => listHooksViaAppServer(h, e, opts.timeoutMs ?? PROBE_MS)))(home, env);
1009
- if (list !== null) {
1010
- const state = foldTrust(list, keys);
1011
- const wanted = new Set(keys);
1012
- const trusted = list.filter(
1013
- (r) => typeof r.key === "string" && wanted.has(r.key) && (r.trustStatus === "trusted" || r.trustStatus === "managed")
1014
- ).length;
1015
- return { ...base, trusted, state, source: "app-server" };
1016
- }
1017
- return { ...base, state: "unknown", source: "none" };
1018
- }
1019
-
1020
- // src/adapters/codex.ts
1021
- function commandHandler2(shimPath, timeoutSeconds) {
1022
- return {
1023
- type: "command",
1024
- command: `node ${JSON.stringify(shimPath)} --harness codex`,
1025
- timeout: timeoutSeconds
1026
- };
1027
- }
1028
- var registrar2 = {
1029
- configPath(home, env) {
1030
- return join6(codexHome(home, env), "hooks.json");
1031
- },
1032
- /**
1033
- * Seven `command` entries, every one through the shim: a Codex handler
1034
- * carries no URL or token, so the daemon is ensured on each fire and the
1035
- * entry holds nothing worth protecting. The matchers are the two hooked
1036
- * tool names the arms read; a child's fires arrive through the same entries.
1037
- */
1038
- plan({ shimPath, timeoutSeconds }) {
1039
- const command = [commandHandler2(shimPath, timeoutSeconds)];
1040
- return [
1041
- { event: "SessionStart", hooks: command },
1042
- { event: "UserPromptSubmit", hooks: command },
1043
- { event: "PreToolUse", matcher: `${SHELL_TOOL}|${PATCH_TOOL}`, hooks: command },
1044
- { event: "PostToolUse", matcher: SHELL_TOOL, hooks: command },
1045
- { event: "SubagentStart", hooks: command },
1046
- { event: "SubagentStop", hooks: command },
1047
- { event: "Stop", hooks: command }
1048
- ];
1049
- },
1050
- /**
1051
- * Codex reads hooks once, at session start. `install` now trusts the entries
1052
- * it writes through Codex's own supported path (lib/codex-trust.ts), so the
1053
- * `/hooks` walkthrough this used to carry is gone; what is left is the one
1054
- * fact no installer can change, which is that the session already open still
1055
- * has the hook set it started with (tenjin-agent#343).
1056
- */
1057
- activation() {
1058
- return ["Start a new Codex session: hooks are read at session start."];
1059
- },
1060
- grant: {
1061
- path: codexRulesPath,
1062
- inspect: inspectCodexGrant,
1063
- write: wireCodexGrant,
1064
- remove: removeCodexGrant
1065
- },
1066
- trust: {
1067
- ensure: trustCodexHooks,
1068
- read: readCodexTrust
1069
- }
1070
- };
1071
- var codexAdapter = { id: "codex", decode, encode, registrar: registrar2 };
1072
-
1073
- // src/adapters/registry.ts
1074
- var ADAPTERS = {
1075
- claude: claudeAdapter,
1076
- codex: codexAdapter
1077
- };
1078
-
1079
- // src/lib/harness-hooks.ts
1080
- import { chmod as chmod2, lstat as lstat2, readFile as readFile2, realpath as realpath2, stat as stat3 } from "node:fs/promises";
1081
- import { resolve } from "node:path";
1082
- var OUR_HOOK_FILES = ["tenjin-daemon.mjs", "tenjin-shim.mjs"];
1083
- var OUR_HOOK_COMMAND = "tenjin hook ";
1084
- var LOOP_URL_RE = new RegExp(`^http://127\\.0\\.0\\.1:\\d+/hook/(?:${HARNESSES.join("|")})$`);
1085
- var HOOK_TIMEOUT_SECONDS = HARNESS_MS / 1e3;
1086
- function isPlainObject2(value) {
1087
- return typeof value === "object" && value !== null && !Array.isArray(value);
1088
- }
1089
- function ownsHandler(handler, dataDir2) {
1090
- if (!isPlainObject2(handler)) return false;
1091
- if (handler.type === "mcp_tool") {
1092
- return handler.server === LEGACY_MCP_SERVER_NAME && handler.tool === HOOK_TOOL;
1093
- }
1094
- const url = handler.url;
1095
- if (typeof url === "string" && LOOP_URL_RE.test(url)) return true;
1096
- const command = handler.command;
1097
- if (typeof command !== "string") return false;
1098
- if (command.includes(OUR_HOOK_COMMAND)) return true;
1099
- if (OUR_HOOK_FILES.some((file) => command.includes(file))) return true;
1100
- return command.includes(hooksDir(resolve(dataDir2)));
1101
- }
1102
- function ownsHookEntry(entry, dataDir2) {
1103
- if (!isPlainObject2(entry)) return false;
1104
- const handlers = entry.hooks;
1105
- if (!Array.isArray(handlers)) return false;
1106
- return handlers.some((h) => ownsHandler(h, dataDir2));
1107
- }
1108
- async function inspectHooksFile(declaredPath) {
1109
- const entry = await lstat2(declaredPath).catch(() => null);
1110
- let path = declaredPath;
1111
- if (entry !== null) {
1112
- try {
1113
- path = await realpath2(declaredPath);
1114
- } catch (err) {
1115
- return {
1116
- refusal: {
1117
- reason: "unresolvable",
1118
- path: declaredPath,
1119
- message: `${declaredPath} could not be resolved (${err.message}); its "hooks" key was left exactly as it is.`
1120
- }
1121
- };
1122
- }
1123
- }
1124
- let settings = {};
1125
- let raw = null;
1126
- if (entry !== null) {
1127
- try {
1128
- raw = await readFile2(path, "utf8");
1129
- } catch (err) {
1130
- return {
1131
- refusal: {
1132
- reason: "unreadable",
1133
- path,
1134
- message: `${path} could not be read (${err.message}); no hooks were registered.`
1135
- }
1136
- };
1137
- }
1138
- let parsed;
1139
- try {
1140
- parsed = JSON.parse(raw);
1141
- } catch (err) {
1142
- return {
1143
- refusal: {
1144
- reason: "unparsable",
1145
- path,
1146
- message: `${path} is not valid JSON (${err.message}); its "hooks" key was left exactly as it is.`
1147
- }
1148
- };
1149
- }
1150
- if (!isPlainObject2(parsed)) {
1151
- return {
1152
- refusal: {
1153
- reason: "unexpected-shape",
1154
- path,
1155
- message: `${path} is not a JSON object; its "hooks" key was left exactly as it is.`
1156
- }
1157
- };
1158
- }
1159
- settings = parsed;
1160
- }
1161
- const hooksValue = settings.hooks;
1162
- if (hooksValue !== void 0 && !isPlainObject2(hooksValue)) {
1163
- return {
1164
- refusal: {
1165
- reason: "unexpected-shape",
1166
- path,
1167
- message: `${path} has a "hooks" key that is not an object; its "hooks" key was left exactly as it is.`
1168
- }
1169
- };
1170
- }
1171
- const hooks = {};
1172
- for (const [event, list] of Object.entries(hooksValue ?? {})) {
1173
- if (!Array.isArray(list)) {
1174
- return {
1175
- refusal: {
1176
- reason: "unexpected-shape",
1177
- path,
1178
- message: `${path} has a "hooks.${event}" that is not an array of entries; its "hooks" key was left exactly as it is.`
1179
- }
1180
- };
1181
- }
1182
- hooks[event] = list;
1183
- }
1184
- return { path, raw, settings, hooks };
1185
- }
1186
- async function readHooksObject(path) {
1187
- try {
1188
- const parsed = JSON.parse(await readFile2(path, "utf8"));
1189
- const hooks = isPlainObject2(parsed) ? parsed.hooks : void 0;
1190
- return isPlainObject2(hooks) ? hooks : null;
1191
- } catch {
1192
- return null;
1193
- }
1194
- }
1195
- function urlPort(url) {
1196
- try {
1197
- const port = Number(new URL(url).port);
1198
- return Number.isFinite(port) && port > 0 ? port : null;
1199
- } catch {
1200
- return null;
1201
- }
1202
- }
1203
- async function registeredHooks(adapter, homeDir, dataDir2, env = process.env) {
1204
- const path = adapter.registrar.configPath(homeDir, env);
1205
- const hooks = await readHooksObject(path);
1206
- const out = { path, entries: 0, port: null, handlers: [] };
1207
- if (hooks === null) return out;
1208
- for (const [event, list] of Object.entries(hooks)) {
1209
- if (!Array.isArray(list)) continue;
1210
- list.forEach((entry, groupIndex) => {
1211
- if (!ownsHookEntry(entry, dataDir2)) return;
1212
- out.entries += 1;
1213
- entry.hooks.forEach((handler, handlerIndex) => {
1214
- if (!ownsHandler(handler, dataDir2)) return;
1215
- out.handlers.push({ event, groupIndex, handlerIndex });
1216
- if (!isPlainObject2(handler) || typeof handler.url !== "string") return;
1217
- out.port ??= urlPort(handler.url);
1218
- });
1219
- });
1220
- }
1221
- return out;
1222
- }
1223
-
1224
- // src/lib/harness-presence.ts
1225
- async function installedHarnessInPlay(adapter, home, dataDir2, options = {}) {
1226
- const env = options.env ?? process.env;
1227
- const which = options.which ?? ((bin) => onPath(bin, env));
1228
- if (harnessInPlay(
1229
- home,
1230
- harnessTargetDir(home, adapter.id),
1231
- detectHarnesses(home, which),
1232
- options.requested ?? []
1233
- )) {
1234
- return true;
1235
- }
1236
- return (await registeredHooks(adapter, home, dataDir2, env)).entries > 0;
1237
- }
1238
-
1239
- // src/router/spend-question.ts
1240
- var ROUTER_DEFAULTS = {
1241
- maxAutoSpend: DEFAULT_MAX_AUTO_SPEND,
1242
- sessionBudget: DEFAULT_SESSION_BUDGET
1243
- };
1244
- function shownLimits(config) {
1245
- return {
1246
- maxAutoSpend: config.maxAutoSpend ?? ROUTER_DEFAULTS.maxAutoSpend,
1247
- sessionBudget: config.sessionBudget ?? ROUTER_DEFAULTS.sessionBudget
1248
- };
1249
- }
1250
- function limitsUsd(limits) {
1251
- return {
1252
- maxAutoSpend: toMoney(limits.maxAutoSpend).usd,
1253
- sessionBudget: limits.sessionBudget === "none" ? "none" : toMoney(limits.sessionBudget).usd
1254
- };
1255
- }
1256
- var ROUTING_FEE_TERMS = `Routing costs $${usd(ROUTING_FEE_ATOMIC)} a call, paid from channel deposits of up to $${usd(CHANNEL_DEPOSIT_ATOMIC)} that stay yours until spent; each deposit counts against these limits.`;
1257
- var FEE_APPROVAL = "Either answer also approves the routing fee.";
1258
- var DEFAULTS_USD = limitsUsd(ROUTER_DEFAULTS);
1259
- var SPEND_QUESTION = `Use the defaults ($${DEFAULTS_USD.sessionBudget} a day, $${DEFAULTS_USD.maxAutoSpend} a call) or set your own limits.`;
1260
- function spendChoiceQuestion() {
1261
- return `${SPEND_QUESTION} ${ROUTING_FEE_TERMS} ${FEE_APPROVAL}`;
1262
- }
1263
- function spendOptions(install) {
1264
- return [
1265
- { id: "default", label: "Use the defaults", recommended: true, command: `${install} --yes` },
1266
- {
1267
- id: "custom",
1268
- label: "Set my own limits",
1269
- recommended: false,
1270
- ask: [
1271
- "The most Tenjin may pay in a day, in USD, or none for no daily limit",
1272
- "The most it may pay for one call, in USD, at least 0.25"
1273
- ],
1274
- command: `${install} --max-auto-spend <usd> --session-budget <usd|none>`
1275
- }
1276
- ];
1277
- }
1278
-
1279
- // src/commands/config.ts
1280
- var SHELF_KEYS = /* @__PURE__ */ new Set([
1281
- "allowlistCreators",
1282
- "publicShelfUrl",
1283
- "shelfBypassSecret",
1284
- "evalCohort",
1285
- ...PUBLISH_CONFIG_KEYS,
1286
- ...HOOKS_CONFIG_KEYS,
1287
- ...LOOP_CONFIG_KEYS,
1288
- ...TEAM_CONFIG_KEYS
1289
- ]);
1290
- var KEY_WIDTH = Math.max(
1291
- ...[...CONFIG_KEYS, ...UPDATE_CONFIG_KEYS, ...ROUTER_CONFIG_KEYS, ...EXPERIMENTAL_CONFIG_KEYS].filter((key) => !SHELF_KEYS.has(key)).map((key) => key.length)
1292
- );
1293
- var KEY_DESCRIPTIONS = {
1294
- maxAutoSpend: "automatic router limit per call, the runaway guard: at least 0.25 (the default); router.enabled false turns the router off",
1295
- sessionBudget: "automatic router daily limit, the main control (5 by default): 0 blocks automatic spend, none removes the ceiling",
1296
- sendMaxAmount: "hard cap per tenjin wallet send; unset = send refuses until set, 0 disables send, none = uncapped; never bypassed by --yes",
1297
- allowlistCreators: "only auto-pay these creators (empty = any)",
1298
- baseUrl: "Tenjin API base URL the router asks",
1299
- publicShelfUrl: "the public marketplace, consume-only: the second shelf a team-mode search falls through to",
1300
- shelfBypassSecret: "the team shelf's Vercel protection-bypass secret; setting it is what turns team mode on (printed as set/unset)",
1301
- rpcUrl: "Base RPC endpoint for balance reads",
1302
- evalCohort: "opt in to the search evaluation cohort",
1303
- bazaarRegistries: "x402 registries used to verify direct-payment listings",
1304
- "publish.mode": "review=always ask, auto=ask on findings, full-auto=only hard blocks stop it",
1305
- "publish.defaultPrice": "price used when none is given",
1306
- "publish.ackServerWarnings": "whether a yes covers the MARKETPLACE scan's warn findings: mode=only the ones an earlier render already showed you (full-auto still acks), on=any of them, off=never",
1307
- "hooks.prompt": "answer the prompt you just typed with what the shelves already know",
1308
- "hooks.web-search": "ask Tenjin before the agent runs a WebSearch",
1309
- "hooks.web-fetch": "ask Tenjin before the agent fetches a page",
1310
- "hooks.subagent": "ask Tenjin with a subagent work order (the most sensitive payload any hook sees) and hand the answer to the child at its start",
1311
- "hooks.failure": "answer a failing command with the fix this machine or a shelf already has",
1312
- "hooks.publish": "the turn-end ask to publish what this turn settled, spoken to you and to each subagent at its own end",
1313
- "hooks.primer": "one-paragraph search-first primer at session start",
1314
- "update.mode": "auto=update in the background where Tenjin's runtime is set up (else as nudge), nudge=report a newer version (stderr line, JSON envelope, hook output), off=neither report nor ask npm",
1315
- "loop.human_wait_ms": "ms a hook fire may take when a human is waiting on it (prompt, Stop, SessionStart)",
1316
- "loop.tool_wait_ms": "ms a hook fire may take when a tool call is waiting on it",
1317
- "loop.idle_exit_min": "minutes without a hook fire before the loop daemon exits",
1318
- "loop.port": "the loop daemon's loopback port; null derives one from the data dir (set only when doctor reports a foreign listener)",
1319
- "team.publicFallback": "on=a team-shelf miss falls through to the public marketplace, off=team-only (public-only lookup stages are dropped)",
1320
- "router.enabled": "false stops every router hook and the request tool; --project sets it for this repository, --project --local for you alone in it",
1321
- "router.context": "session=a hook packet carries up to six prior messages, turn=the current turn only; --project and --local as for router.enabled",
1322
- "experimental.bazaar": "EXPERIMENTAL. on=the router may also suggest unreviewed sellers from Coinbase's open x402 Bazaar, off=curated services and Tenjin's reviewed list only"
1323
- };
1324
- var EXPERIMENTAL_BAZAAR_WARNING = "Experimental: the router may now also suggest sellers from Coinbase's open x402 Bazaar. They are unreviewed third parties, Tenjin has not checked them, matches can be noisy, prices can vary with the input, and payments are real, under your spend limits. To find them, short snippets of your prompts are sent to Coinbase's public Bazaar search. Tenjin's reviewed list stays on either way. Turn this off with `tenjin config set experimental.bazaar off`.";
1325
- function isExperimentalKey(key) {
1326
- return EXPERIMENTAL_CONFIG_KEYS.includes(key);
1327
- }
1328
- function isLoopKey(key) {
1329
- return LOOP_CONFIG_KEYS.includes(key);
1330
- }
1331
- function isTeamKey(key) {
1332
- return TEAM_CONFIG_KEYS.includes(key);
1333
- }
1334
- function isRouterKey(key) {
1335
- return ROUTER_CONFIG_KEYS.includes(key);
1336
- }
1337
- function renderRouterSetting(key, settings) {
1338
- const { value, source, path } = key === "router.enabled" ? settings.enabled : settings.context;
1339
- return { value, source, ...path !== void 0 ? { path } : {} };
1340
- }
1341
- async function resolveRouterFromContext(ctx) {
1342
- return routerSettings({ cwd: process.cwd(), dataDir: ctx.dataDir });
1343
- }
1344
- function renderLoopSetting(key, settings) {
1345
- const field = key.slice("loop.".length);
1346
- const { value, source } = settings.loop[field];
1347
- return { value: value === null ? "null" : String(value), source };
1348
- }
1349
- function isPublishKey(key) {
1350
- return PUBLISH_CONFIG_KEYS.includes(key);
1351
- }
1352
- function isHooksKey(key) {
1353
- return HOOKS_CONFIG_KEYS.includes(key);
1354
- }
1355
- function isUpdateKey(key) {
1356
- return UPDATE_CONFIG_KEYS.includes(key);
1357
- }
1358
- async function runConfigList(ctx) {
1359
- const settings = await resolveFromContext(ctx);
1360
- const data = {};
1361
- const humanLines = [];
1362
- const show = (key, line) => {
1363
- if (!SHELF_KEYS.has(key)) humanLines.push(line);
1364
- };
1365
- for (const key of CONFIG_KEYS) {
1366
- const entry = renderSetting(key, settings[key].value, settings[key].source);
1367
- data[key] = entry;
1368
- show(key, describedLine(key, entry));
1369
- }
1370
- for (const key of PUBLISH_CONFIG_KEYS) {
1371
- const entry = renderPublishSetting(key, settings);
1372
- data[key] = entry;
1373
- show(key, describedLine(key, entry, downgradeNote(key, settings)));
1374
- }
1375
- for (const key of HOOKS_CONFIG_KEYS) {
1376
- const entry = renderHooksSetting(key, settings);
1377
- data[key] = entry;
1378
- show(key, describedLine(key, entry));
1379
- }
1380
- for (const key of UPDATE_CONFIG_KEYS) {
1381
- const entry = {
1382
- value: settings.updateMode.value,
1383
- source: settings.updateMode.source
1384
- };
1385
- data[key] = entry;
1386
- show(key, describedLine(key, entry));
1387
- }
1388
- for (const key of LOOP_CONFIG_KEYS) {
1389
- const entry = renderLoopSetting(key, settings);
1390
- data[key] = entry;
1391
- show(key, describedLine(key, entry));
1392
- }
1393
- for (const key of TEAM_CONFIG_KEYS) {
1394
- const entry = {
1395
- value: settings.teamPublicFallback.value,
1396
- source: settings.teamPublicFallback.source
1397
- };
1398
- data[key] = entry;
1399
- show(key, describedLine(key, entry));
1400
- }
1401
- const router = await resolveRouterFromContext(ctx);
1402
- for (const key of ROUTER_CONFIG_KEYS) {
1403
- const entry = renderRouterSetting(key, router);
1404
- data[key] = entry;
1405
- show(key, describedLine(key, entry));
1406
- }
1407
- for (const key of EXPERIMENTAL_CONFIG_KEYS) {
1408
- const entry = {
1409
- value: settings.experimentalBazaar.value,
1410
- source: settings.experimentalBazaar.source
1411
- };
1412
- data[key] = entry;
1413
- show(key, describedLine(key, entry));
1414
- }
1415
- return { data, humanLines };
1416
- }
1417
- async function runConfigGet({ key }, ctx) {
1418
- if (isPublishKey(key)) {
1419
- const settings2 = await resolveFromContext(ctx);
1420
- const entry2 = renderPublishSetting(key, settings2);
1421
- return {
1422
- data: { key, ...entry2 },
1423
- humanLines: [withNote(formatLine(key, entry2), downgradeNote(key, settings2))]
1424
- };
1425
- }
1426
- if (isHooksKey(key)) {
1427
- const entry2 = renderHooksSetting(key, await resolveFromContext(ctx));
1428
- return { data: { key, ...entry2 }, humanLines: [formatLine(key, entry2)] };
1429
- }
1430
- if (isUpdateKey(key)) {
1431
- const { updateMode } = await resolveFromContext(ctx);
1432
- const entry2 = { value: updateMode.value, source: updateMode.source };
1433
- return { data: { key, ...entry2 }, humanLines: [formatLine(key, entry2)] };
1434
- }
1435
- if (isLoopKey(key)) {
1436
- const entry2 = renderLoopSetting(key, await resolveFromContext(ctx));
1437
- return { data: { key, ...entry2 }, humanLines: [formatLine(key, entry2)] };
1438
- }
1439
- if (isTeamKey(key)) {
1440
- const { teamPublicFallback } = await resolveFromContext(ctx);
1441
- const entry2 = {
1442
- value: teamPublicFallback.value,
1443
- source: teamPublicFallback.source
1444
- };
1445
- return { data: { key, ...entry2 }, humanLines: [formatLine(key, entry2)] };
1446
- }
1447
- if (isRouterKey(key)) {
1448
- const entry2 = renderRouterSetting(key, await resolveRouterFromContext(ctx));
1449
- return { data: { key, ...entry2 }, humanLines: [formatLine(key, entry2)] };
1450
- }
1451
- if (isExperimentalKey(key)) {
1452
- const { experimentalBazaar } = await resolveFromContext(ctx);
1453
- const entry2 = {
1454
- value: experimentalBazaar.value,
1455
- source: experimentalBazaar.source
1456
- };
1457
- return { data: { key, ...entry2 }, humanLines: [formatLine(key, entry2)] };
1458
- }
1459
- const configKey = assertKey(key);
1460
- const settings = await resolveFromContext(ctx);
1461
- const entry = renderSetting(configKey, settings[configKey].value, settings[configKey].source);
1462
- return { data: { key: configKey, ...entry }, humanLines: [formatLine(configKey, entry)] };
1463
- }
1464
- async function runConfigSet({
1465
- key,
1466
- value,
1467
- project,
1468
- local
1469
- }, ctx, deps = {}) {
1470
- if (local === true && project !== true) {
1471
- throw new CliError("USAGE", "--local names the personal project file, so it needs --project", {
1472
- fix: `Run \`tenjin config set --project --local ${key} ${value}\`.`
1473
- });
1474
- }
1475
- if (isRouterKey(key)) {
1476
- return setRouterKey(key, value, ctx, project === true ? { local: local === true } : void 0);
1477
- }
1478
- if (project === true) {
1479
- throw new CliError("USAGE", `${key} is not a project key`, {
1480
- fix: `--project applies to ${ROUTER_CONFIG_KEYS.join(" and ")} only; drop it to set ${key} for this machine.`
1481
- });
1482
- }
1483
- if (isPublishKey(key)) return setPublishKey(key, value, ctx, deps);
1484
- if (isHooksKey(key)) return setHooksKey(key, value, ctx);
1485
- if (isUpdateKey(key)) return setUpdateKey(key, value, ctx);
1486
- if (isLoopKey(key)) return setLoopKey(key, value, ctx);
1487
- if (isTeamKey(key)) return setTeamKey(key, value, ctx);
1488
- if (isExperimentalKey(key)) return setExperimentalKey(key, value, ctx);
1489
- const configKey = assertKey(key);
1490
- const stored = parseValue(configKey, value);
1491
- await persist(ctx.dataDir, (existing) => ({ ...existing, [configKey]: stored }));
1492
- const entry = renderSetting(configKey, stored, "file");
1493
- const warning = await halfWiredTeamShelf(configKey, ctx.dataDir);
1494
- return {
1495
- data: { key: configKey, ...entry, ...warning !== void 0 ? { warning } : {} },
1496
- humanLines: [formatLine(configKey, entry), ...warning !== void 0 ? [warning] : []]
1497
- };
1498
- }
1499
- async function halfWiredTeamShelf(configKey, dataDir2) {
1500
- if (configKey !== "shelfBypassSecret" && configKey !== "baseUrl" && configKey !== "publicShelfUrl") {
1501
- return void 0;
1502
- }
1503
- const config = await loadRawConfig(dataDir2).catch(() => void 0);
1504
- if (config === void 0) return void 0;
1505
- const s = resolveSettings({ config, flags: {}, env: {} });
1506
- if (s.shelfBypassSecret.value.length === 0) return void 0;
1507
- const baseUrl = s.baseUrl.value;
1508
- if (isTeamShelfOrigin(new URL(baseUrl).origin, s.publicShelfUrl.value)) return void 0;
1509
- const isProduction = isSameDeployment(new URL(baseUrl).origin, PRODUCTION_ORIGIN);
1510
- const cause = isProduction ? `baseUrl is the public marketplace (${baseUrl})` : `baseUrl and publicShelfUrl are the same shelf (${baseUrl})`;
1511
- const fix = isProduction ? "Point baseUrl at the team deployment to finish team mode: `tenjin config set baseUrl <team shelf url>`." : `A team shelf must differ from the shelf it falls through to: \`tenjin config set publicShelfUrl ${PRODUCTION_ORIGIN}\`.`;
1512
- return `Warning: shelfBypassSecret is set, but ${cause}, so this machine stays in PUBLIC mode \u2014 publishes go to the marketplace with the scan\u2019s warn tier and the confirm cascade on. ` + fix;
1513
- }
1514
- async function setPublishKey(key, value, ctx, deps) {
1515
- const entry = key === "publish.mode" ? { value: parsePublishMode(value), source: "file" } : key === "publish.ackServerWarnings" ? { value: parseAckServerWarnings(value, key), source: "file" } : { value: toMoney(parseUsdToAtomic(value)), source: "file" };
1516
- const subkey = key === "publish.mode" ? "mode" : key === "publish.ackServerWarnings" ? "ackServerWarnings" : "defaultPrice";
1517
- const stored = key === "publish.defaultPrice" ? entry.value.atomic : entry.value;
1518
- const persistEntry = async () => persist(ctx.dataDir, (existing) => ({
1519
- ...existing,
1520
- publish: { ...existing.publish, [subkey]: stored }
1521
- }));
1522
- const humanLines = [formatLine(key, entry)];
1523
- if (key !== "publish.mode") {
1524
- await persistEntry();
1525
- return { data: { key, ...entry }, humanLines };
1526
- }
1527
- const allowlist = await syncPublishRule(entry.value, ctx, deps);
1528
- const failure = grantSyncFailure(allowlist);
1529
- if (failure !== void 0) {
1530
- throw new CliError(
1531
- "REFUSED",
1532
- `publish.mode was not changed because the ${failure.harness} grant could not be updated: ${failure.reason}`,
1533
- {
1534
- fix: failure.fix ?? `Fix the permissions for ${failure.path}, then re-run \`tenjin config set publish.mode ${entry.value}\`.`,
1535
- details: { key, value: entry.value, allowlist }
1536
- }
1537
- );
1538
- }
1539
- await persistEntry();
1540
- return {
1541
- data: { key, ...entry, allowlist },
1542
- humanLines: [...humanLines, ...allowlistLines(allowlist)]
1543
- };
1544
- }
1545
- function grantSyncFailure(sync) {
1546
- for (const [harness, result] of Object.entries(sync.byHarness)) {
1547
- if ("error" in result && result.error !== void 0) {
1548
- return { harness, path: result.path, reason: result.error };
1549
- }
1550
- if ("warning" in result && result.warning !== void 0) {
1551
- return {
1552
- harness,
1553
- path: result.path ?? "(unknown path)",
1554
- reason: result.warning,
1555
- ...result.fix !== void 0 ? { fix: result.fix } : {}
1556
- };
1557
- }
1558
- }
1559
- return void 0;
1560
- }
1561
- function publishRuleQuestion(mode, pending, harnesses) {
1562
- const gated = new Set(MODE_GATED_RULES);
1563
- const others = pending.filter((rule) => !gated.has(rule)).length;
1564
- const also = others > 0 ? ` Also adds the ${others} command-grant rule(s) \`tenjin install\` writes.` : "";
1565
- const targets = harnesses.map(
1566
- (harness) => harness === "claude" ? "Claude Code" : harness === "codex" ? "Codex" : harness
1567
- ).join(" and ");
1568
- return `publish.mode ${mode} is unattended only if ${targets} carries the matching grant for ${MODE_GATED_RULES.join(" and ")}. Update the ${targets} grant now?${also}`;
1569
- }
1570
- async function syncPublishRule(mode, ctx, deps) {
1571
- const home = deps.homeDir ?? homedir();
1572
- const nothing = { byHarness: {} };
1573
- const write = async () => {
1574
- const result = await (deps.wireAllowlist ?? wireFreeVerbAllowlist)(home, mode);
1575
- if (result.skipped !== void 0) {
1576
- return {
1577
- byHarness: { claude: result },
1578
- skipped: "unwritable",
1579
- ...result.fix !== void 0 ? { pointer: result.fix } : {}
1580
- };
1581
- }
1582
- return { byHarness: { claude: result } };
1583
- };
1584
- const adapters = deps.adapters ?? ADAPTERS;
1585
- const env = deps.env ?? process.env;
1586
- const which = deps.which ?? ((bin) => onPath(bin, env));
1587
- const requested = await loadRawConfig(ctx.dataDir).then((config) => config.install?.harness ?? []).catch(() => []);
1588
- const inPlay = deps.harnessesInPlay ?? (await Promise.all(
1589
- Object.values(adapters).map(async (adapter) => ({
1590
- adapter,
1591
- selected: await installedHarnessInPlay(adapter, home, ctx.dataDir, {
1592
- env,
1593
- which,
1594
- requested
1595
- })
1596
- }))
1597
- )).filter((entry) => entry.selected).map((entry) => entry.adapter.id);
1598
- const selectedAdapters = inPlay.map((harness) => adapters[harness]);
1599
- const isClaude = inPlay.includes("claude");
1600
- const withOtherGrants = async (sync) => {
1601
- const byHarness = { ...sync.byHarness };
1602
- for (const adapter of selectedAdapters) {
1603
- if (adapter.id === "claude" || adapter.registrar.grant === void 0) continue;
1604
- const result = await adapter.registrar.grant.write(home, mode, env);
1605
- byHarness[adapter.id] = result;
1606
- }
1607
- return { ...sync, byHarness };
1608
- };
1609
- if (selectedAdapters.every((adapter) => adapter.registrar.grant === void 0)) {
1610
- return { ...nothing, skipped: "not-claude" };
1611
- }
1612
- const probe = isClaude ? await (deps.inspectAllowlist ?? inspectFreeVerbRules)(home, mode) : { pending: [] };
1613
- const gated = new Set(MODE_GATED_RULES);
1614
- const missing = (probe.pending ?? []).filter((r) => gated.has(r));
1615
- const pointer = modeGatedPointer(mode, missing) ?? void 0;
1616
- if (mode === "review") {
1617
- const retracted = isClaude ? await (deps.retractModeGated ?? retractModeGatedRules)(home) : void 0;
1618
- if (retracted?.skipped !== void 0) {
1619
- return {
1620
- ...nothing,
1621
- skipped: "unwritable",
1622
- ...retracted.fix !== void 0 ? { pointer: retracted.fix } : {}
1623
- };
1624
- }
1625
- return await withOtherGrants({
1626
- byHarness: retracted === void 0 ? {} : { claude: retracted }
1627
- });
1628
- }
1629
- if (probe.satisfied !== void 0 && selectedAdapters.length === 1 && isClaude) return nothing;
1630
- const canPrompt = ctx.flags.json === true ? false : deps.isInteractive ?? Boolean(process.stdin.isTTY);
1631
- if (!canPrompt) {
1632
- return { ...nothing, skipped: "no-tty", ...pointer ? { pointer } : {} };
1633
- }
1634
- const confirm = deps.confirmRule ?? ((label) => confirmChoice(label, true));
1635
- const grantable = selectedAdapters.filter((adapter) => adapter.registrar.grant !== void 0).map((adapter) => adapter.id);
1636
- if (!await confirm(publishRuleQuestion(mode, probe.pending ?? [], grantable))) {
1637
- return { ...nothing, skipped: "declined", ...pointer ? { pointer } : {} };
1638
- }
1639
- return await withOtherGrants(isClaude ? await write() : nothing);
1640
- }
1641
- function allowlistLines(sync) {
1642
- const lines = [];
1643
- const claude = sync.byHarness.claude;
1644
- if ((claude?.added.length ?? 0) > 0) {
1645
- lines.push(`Added ${claude?.added.length ?? 0} harness rule(s) to your allowlist.`);
1646
- }
1647
- if ((claude?.removed.length ?? 0) > 0) {
1648
- lines.push(`Removed ${claude?.removed.join(", ")} from your allowlist.`);
1649
- }
1650
- const grant = sync.byHarness.codex;
1651
- if (grant !== void 0 && grant.error === void 0 && grant.wrote) {
1652
- lines.push(
1653
- `Codex now allows ${grant.granted.length} tenjin command prefix(es) in ${grant.path}.`
1654
- );
1655
- }
1656
- if (grant?.error !== void 0) {
1657
- lines.push(`Codex's grant at ${grant.path} could not be updated (${grant.error}).`);
1658
- }
1659
- if (sync.pointer !== void 0) lines.push(sync.pointer);
1660
- return lines;
1661
- }
1662
- async function setHooksKey(key, value, ctx) {
1663
- const arm = key.slice("hooks.".length);
1664
- const parsed = parseBoolean(value);
1665
- await persistHookArm(ctx.dataDir, arm, parsed);
1666
- const entry = { value: parsed, source: "file" };
1667
- return { data: { key, ...entry }, humanLines: [formatLine(key, entry)] };
1668
- }
1669
- async function setUpdateKey(key, value, ctx) {
1670
- const parsed = parseUpdateModeFlag(value, key);
1671
- await persist(ctx.dataDir, (existing) => ({
1672
- ...existing,
1673
- update: { ...existing.update, mode: parsed }
1674
- }));
1675
- const entry = { value: parsed, source: "file" };
1676
- return { data: { key, ...entry }, humanLines: [formatLine(key, entry)] };
1677
- }
1678
- async function setLoopKey(key, value, ctx) {
1679
- const parsed = parseLoopValue(key, value);
1680
- const field = key.slice("loop.".length);
1681
- await persist(ctx.dataDir, (existing) => ({
1682
- ...existing,
1683
- loop: { ...existing.loop, [field]: parsed }
1684
- }));
1685
- const entry = {
1686
- value: parsed === null ? "null" : String(parsed),
1687
- source: "file"
1688
- };
1689
- return { data: { key, ...entry }, humanLines: [formatLine(key, entry)] };
1690
- }
1691
- async function setTeamKey(key, value, ctx) {
1692
- const parsed = parsePublicFallbackFlag(value, key);
1693
- await persist(ctx.dataDir, (existing) => ({
1694
- ...existing,
1695
- team: { ...existing.team, publicFallback: parsed }
1696
- }));
1697
- const entry = { value: parsed, source: "file" };
1698
- return { data: { key, ...entry }, humanLines: [formatLine(key, entry)] };
1699
- }
1700
- async function setExperimentalKey(key, value, ctx) {
1701
- const parsed = parsePublicFallbackFlag(value, key);
1702
- await persist(ctx.dataDir, (existing) => ({
1703
- ...existing,
1704
- experimental: { ...existing.experimental, bazaar: parsed }
1705
- }));
1706
- const entry = { value: parsed, source: "file" };
1707
- const warning = parsed === "on" ? EXPERIMENTAL_BAZAAR_WARNING : void 0;
1708
- return {
1709
- data: { key, ...entry, ...warning !== void 0 ? { warning } : {} },
1710
- humanLines: [formatLine(key, entry), ...warning !== void 0 ? [warning] : []]
1711
- };
1712
- }
1713
- async function setRouterKey(key, value, ctx, project) {
1714
- const field = key === "router.enabled" ? "enabled" : "context";
1715
- const parsed = field === "enabled" ? parseBoolean(value) : parseRouterContext(value);
1716
- let written;
1717
- if (project === void 0) {
1718
- await persist(ctx.dataDir, (existing) => ({
1719
- ...existing,
1720
- router: { ...existing.router, [field]: parsed }
1721
- }));
1722
- written = { value: parsed, source: "file", path: configPath(ctx.dataDir) };
1723
- } else {
1724
- const path = await projectRouterPath({ cwd: process.cwd(), local: project.local });
1725
- await persistProjectRouter(path, field, parsed);
1726
- written = { value: parsed, source: project.local ? "local" : "project", path };
1727
- }
1728
- const effective = renderRouterSetting(key, await resolveRouterFromContext(ctx));
1729
- const humanLines = [formatLine(key, written)];
1730
- if (effective.value !== written.value) {
1731
- humanLines.push(
1732
- `Still ${String(effective.value)} here: ${effective.path ?? "the default"} is tighter, and a nearer file can only tighten an outer one.`
1733
- );
1734
- }
1735
- if (project?.local === true) {
1736
- humanLines.push("Keep .tenjin/config.local.json out of git: add it to .gitignore.");
1737
- }
1738
- return { data: { key, ...written, effective }, humanLines };
1739
- }
1740
- function parseRouterContext(value) {
1741
- const found = ROUTER_CONTEXTS.find((context) => context === value);
1742
- if (found !== void 0) return found;
1743
- throw new CliError("USAGE", `Invalid router.context: ${JSON.stringify(value)}`, {
1744
- fix: 'Use "session" or "turn".'
1745
- });
1746
- }
1747
- async function persistProjectRouter(path, field, value) {
1748
- await mkdir2(dirname3(path), { recursive: true, mode: 493 });
1749
- const lockPath = `${path}.lock`;
1750
- try {
1751
- await withFileLock(lockPath, () => mergeProjectRouter(path, field, value));
1752
- } catch (err) {
1753
- if (err instanceof LockTimeoutError) {
1754
- throw new CliError("INTERNAL", err.message, {
1755
- fix: `If no other tenjin process is running, remove ${lockPath} and retry.`,
1756
- cause: err
1757
- });
1758
- }
1759
- throw err;
1760
- }
1761
- }
1762
- async function mergeProjectRouter(path, field, value) {
1763
- const existing = await readProjectRouterFile(path);
1764
- const block = existing?.json.router;
1765
- const next = {
1766
- ...existing?.json ?? {},
1767
- router: { ...block !== void 0 ? block : {}, [field]: value }
1768
- };
1769
- await writeFileAtomic(path, `${JSON.stringify(next, null, 2)}
1770
- `, {
1771
- mode: 420,
1772
- dirMode: 493
1773
- });
1774
- }
1775
- function parsePublishMode(value) {
1776
- const parsed = PublishModeSchema.safeParse(value);
1777
- if (parsed.success) return parsed.data;
1778
- throw new CliError("USAGE", `Invalid publish mode: ${JSON.stringify(value)}`, {
1779
- fix: 'Use "review", "auto", or "full-auto".'
1780
- });
1781
- }
1782
- async function persistHookArm(dir, arm, value) {
1783
- await persist(dir, (existing) => ({
1784
- ...existing,
1785
- hooks: { ...existing.hooks, [arm]: value }
1786
- }));
1787
- }
1788
- async function persistPublishMode(dir, mode) {
1789
- await persist(dir, (existing) => ({
1790
- ...existing,
1791
- publish: { ...existing.publish, mode }
1792
- }));
1793
- }
1794
- async function persistRouterProject(dir, projectDir, present = true) {
1795
- await persist(dir, (existing) => {
1796
- const known = new Set(existing.install?.routerProjects ?? []);
1797
- if (present) known.add(projectDir);
1798
- else known.delete(projectDir);
1799
- return { ...existing, install: { ...existing.install, routerProjects: [...known].sort() } };
1800
- });
1801
- }
1802
- async function persistRouterDefaults(dir, refresh = false, limits = ROUTER_DEFAULTS, chosen = []) {
1803
- const result = { set: [], kept: [], removed: [] };
1804
- if (refresh && retiredPaymentKeys(await loadRawConfig(dir)).length === 0) return result;
1805
- await persist(dir, (existing) => {
1806
- const next = { ...existing };
1807
- result.removed = retiredPaymentKeys(existing);
1808
- for (const key of result.removed) delete next[key];
1809
- if (refresh) return next;
1810
- for (const key of Object.keys(ROUTER_DEFAULTS)) {
1811
- const value = limits[key];
1812
- if (existing[key] !== void 0 && !chosen.includes(key)) result.kept.push(key);
1813
- else if (value !== void 0) {
1814
- next[key] = value;
1815
- result.set.push(key);
1816
- }
1817
- }
1818
- return next;
1819
- });
1820
- return result;
1821
- }
1822
- async function persistInstallHarness(dir, harness) {
1823
- await persist(dir, (existing) => ({
1824
- ...existing,
1825
- install: { ...existing.install, harness: [...harness] }
1826
- }));
1827
- }
1828
- async function persistGrantDeclined(dir, declined) {
1829
- await persist(dir, (existing) => ({
1830
- ...existing,
1831
- install: { ...existing.install, grantDeclined: declined }
1832
- }));
1833
- }
1834
- async function resolveFromContext(ctx) {
1835
- const config = await loadRawConfig(ctx.dataDir);
1836
- const project = await loadProjectConfig(process.cwd());
1837
- return resolveSettings({
1838
- config,
1839
- flags: { baseUrl: ctx.flags.baseUrl },
1840
- env: process.env,
1841
- project: project?.layer
1842
- });
1843
- }
1844
- function assertKey(key) {
1845
- if (key === "bazaarPay" || key === "confirm") {
1846
- throw new CliError("USAGE", `Retired config key: ${key}`, { fix: RETIRED_PAYMENT_GUIDANCE });
1847
- }
1848
- if (CONFIG_KEYS.includes(key)) return key;
1849
- throw new CliError("USAGE", `Unknown config key: ${JSON.stringify(key)}`, {
1850
- fix: `Valid keys: ${[...CONFIG_KEYS, ...PUBLISH_CONFIG_KEYS, ...HOOKS_CONFIG_KEYS, ...ROUTER_CONFIG_KEYS, ...EXPERIMENTAL_CONFIG_KEYS].join(", ")}.`
1851
- });
1852
- }
1853
- function renderSetting(key, stored, source) {
1854
- return { ...renderValue(key, stored), source };
1855
- }
1856
- function renderPublishSetting(key, settings) {
1857
- if (key === "publish.mode") {
1858
- return { value: settings.publishMode.value, source: settings.publishMode.source };
1859
- }
1860
- if (key === "publish.ackServerWarnings") {
1861
- return {
1862
- value: settings.publishAckServerWarnings.value,
1863
- source: settings.publishAckServerWarnings.source
1864
- };
1865
- }
1866
- return {
1867
- value: toMoney(settings.publishDefaultPrice.value),
1868
- source: settings.publishDefaultPrice.source
1869
- };
1870
- }
1871
- function renderHooksSetting(key, settings) {
1872
- const { value, source } = settings.hooks[key.slice("hooks.".length)];
1873
- return { value, source };
1874
- }
1875
- function renderValue(key, stored) {
1876
- if (key === "shelfBypassSecret") {
1877
- return { value: typeof stored === "string" && stored.length > 0 ? "set" : "unset" };
1878
- }
1879
- if (Array.isArray(stored) || typeof stored === "boolean") return { value: stored };
1880
- if (key === "sessionBudget" && stored === "none") return { value: null };
1881
- if (key === "maxAutoSpend" || key === "sessionBudget") return { value: toMoney(stored) };
1882
- if (key === "sendMaxAmount") {
1883
- return { value: stored === "none" || stored === SEND_MAX_UNSET ? stored : toMoney(stored) };
1884
- }
1885
- return { value: stored };
1886
- }
1887
- function parseValue(key, value) {
1888
- switch (key) {
1889
- case "sessionBudget":
1890
- return value === "none" ? "none" : parseUsdToAtomic(value);
1891
- case "maxAutoSpend":
1892
- return parseAutoSpend(value);
1893
- case "sendMaxAmount":
1894
- return value === "none" ? "none" : parseUsdToAtomic(value);
1895
- case "allowlistCreators":
1896
- return parseAllowlist(value);
1897
- case "baseUrl":
1898
- case "publicShelfUrl":
1899
- case "rpcUrl":
1900
- return parseHttpUrl(value);
1901
- case "shelfBypassSecret":
1902
- return value.trim();
1903
- case "evalCohort":
1904
- return parseBoolean(value);
1905
- case "bazaarRegistries":
1906
- return parseRegistryList(value);
1907
- }
1908
- }
1909
- function parseAutoSpend(value) {
1910
- const atomic = parseUsdToAtomic(value);
1911
- if (BigInt(atomic) < MAX_AUTO_SPEND_FLOOR_ATOMIC) {
1912
- throw new CliError("USAGE", `maxAutoSpend ${value} is below the 0.25 USD minimum.`, {
1913
- fix: MAX_AUTO_SPEND_FLOOR_WHY
1914
- });
1915
- }
1916
- return atomic;
1917
- }
1918
- function parseRegistryList(value) {
1919
- return value.split(",").map((entry) => entry.trim()).filter((entry) => entry.length > 0).map((entry) => parseHttpUrl(entry));
1920
- }
1921
- function parseBoolean(value) {
1922
- if (value === "true" || value === "on") return true;
1923
- if (value === "false" || value === "off") return false;
1924
- throw new CliError("USAGE", `Invalid boolean value: ${JSON.stringify(value)}`, {
1925
- fix: 'Use "on" or "off" (or "true"/"false").'
1926
- });
1927
- }
1928
- function parseAllowlist(value) {
1929
- const entries = value.split(",").map((entry) => entry.trim()).filter((entry) => entry.length > 0);
1930
- for (const entry of entries) {
1931
- if (/\s/.test(entry)) {
1932
- throw new CliError("USAGE", `Invalid creator entry: ${JSON.stringify(entry)}`, {
1933
- fix: "Creator entries cannot contain spaces; separate multiple with commas."
1934
- });
1935
- }
1936
- }
1937
- return entries;
1938
- }
1939
- function parseHttpUrl(value) {
1940
- let url;
1941
- try {
1942
- url = new URL(value);
1943
- } catch {
1944
- throw new CliError("USAGE", `Invalid URL: ${JSON.stringify(value)}`, {
1945
- fix: `Pass an absolute http(s) URL like ${PRODUCTION_ORIGIN}.`
1946
- });
1947
- }
1948
- if (url.protocol !== "http:" && url.protocol !== "https:") {
1949
- throw new CliError("USAGE", `URL must be http or https: ${JSON.stringify(value)}`, {
1950
- fix: `Pass an absolute http(s) URL like ${PRODUCTION_ORIGIN}.`
1951
- });
1952
- }
1953
- return value;
1954
- }
1955
- async function persist(dir, merge) {
1956
- await mkdir2(dir, { recursive: true, mode: 448 });
1957
- const lockPath = `${configPath(dir)}.lock`;
1958
- try {
1959
- await withFileLock(lockPath, async () => {
1960
- const existing = await loadRawConfig(dir);
1961
- const merged = merge(existing);
1962
- const validated = RawConfigSchema.parse(merged);
1963
- await writeFileAtomic(configPath(dir), `${JSON.stringify(validated, null, 2)}
1964
- `, {
1965
- mode: 384,
1966
- dirMode: 448
1967
- });
1968
- });
1969
- } catch (err) {
1970
- if (err instanceof LockTimeoutError) {
1971
- throw new CliError("INTERNAL", err.message, {
1972
- fix: `If no other tenjin process is running, remove ${lockPath} and retry.`,
1973
- cause: err
1974
- });
1975
- }
1976
- throw err;
1977
- }
1978
- }
1979
- function formatLine(key, entry) {
1980
- const label = key.padEnd(KEY_WIDTH);
1981
- const where = entry.path !== void 0 && (entry.source === "project" || entry.source === "local") ? ` ${entry.path}` : "";
1982
- return ` ${label} ${displayValue(entry)} ${style("dim", `(${entry.source}${where})`)}`;
1983
- }
1984
- function describedLine(key, entry, note) {
1985
- const description = KEY_DESCRIPTIONS[key];
1986
- let line = formatLine(key, entry);
1987
- if (description !== void 0) line += ` ${style("dim", `- ${description}`)}`;
1988
- return withNote(line, note);
1989
- }
1990
- function withNote(line, note) {
1991
- return note !== void 0 ? `${line} ${style("dim", `(${note})`)}` : line;
1992
- }
1993
- function downgradeNote(key, settings) {
1994
- if (key !== "publish.mode" || settings.publishMode.downgradedWarning === void 0) {
1995
- return void 0;
1996
- }
1997
- return "downgraded from full-auto: committed .tenjin.json (gitignore it to opt in)";
1998
- }
1999
- function displayValue(entry) {
2000
- const { value } = entry;
2001
- if (Array.isArray(value)) return value.length > 0 ? value.join(", ") : "(empty)";
2002
- if (typeof value === "boolean") return value ? "true" : "false";
2003
- if (value === null) return "none (no daily limit)";
2004
- if (typeof value === "object") return `${value.usd} USD`;
2005
- return value;
2006
- }
2007
-
2008
- export {
2009
- RETIRED_SKILL_NAMES,
2010
- SHIPPED_SKILL_FILES,
2011
- CLI_SKILL_NAMES,
2012
- skillsDirsFor,
2013
- readSkillFile,
2014
- skillFrontmatterName,
2015
- EVENT_LABEL,
2016
- rowsOf,
2017
- trustCodexHooks,
2018
- inspectHooksFile,
2019
- ROUTER_DEFAULTS,
2020
- shownLimits,
2021
- ROUTING_FEE_TERMS,
2022
- FEE_APPROVAL,
2023
- SPEND_QUESTION,
2024
- spendChoiceQuestion,
2025
- spendOptions,
2026
- EXPERIMENTAL_BAZAAR_WARNING,
2027
- runConfigList,
2028
- runConfigGet,
2029
- runConfigSet,
2030
- persistHookArm,
2031
- persistPublishMode,
2032
- persistRouterProject,
2033
- persistRouterDefaults,
2034
- persistInstallHarness,
2035
- persistGrantDeclined
2036
- };
2037
- //# sourceMappingURL=chunk-A5GKIG5O.js.map