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

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 (258) hide show
  1. package/README.md +5 -5
  2. package/dist/{_esm-MEXZI5DL.js → _esm-RLLC72MS.js} +128 -132
  3. package/dist/{alive-J64H46HI.js → alive-MROUMFH3.js} +13 -6
  4. package/dist/auto-update-OPWMRZLS.js +22 -0
  5. package/dist/{ccip-7RMRLAGV.js → ccip-DHDFKTQV.js} +2 -2
  6. package/dist/chunk-2GNOFONN.js +560 -0
  7. package/dist/chunk-2GNOFONN.js.map +1 -0
  8. package/dist/{chunk-TTNESUPQ.js → chunk-2GP3HRYK.js} +2120 -193
  9. package/dist/chunk-2GP3HRYK.js.map +1 -0
  10. package/dist/chunk-3AIHRXKO.js +72 -0
  11. package/dist/chunk-3AIHRXKO.js.map +1 -0
  12. package/dist/{chunk-LEFIX6RS.js → chunk-3DIL66VX.js} +31 -11
  13. package/dist/chunk-3DIL66VX.js.map +1 -0
  14. package/dist/{chunk-S4SAZ7OD.js → chunk-3FMZGI7I.js} +12 -2
  15. package/dist/{chunk-S4SAZ7OD.js.map → chunk-3FMZGI7I.js.map} +1 -1
  16. package/dist/{chunk-7Q5FDF65.js → chunk-445VQTVM.js} +3 -3
  17. package/dist/{chunk-A36LQPHV.js → chunk-4LMUQMBH.js} +1 -1
  18. package/dist/{chunk-A36LQPHV.js.map → chunk-4LMUQMBH.js.map} +1 -1
  19. package/dist/{chunk-KXQ4UIP7.js → chunk-4USCZ2NI.js} +2 -2
  20. package/dist/chunk-62KNUYWD.js +111 -0
  21. package/dist/chunk-62KNUYWD.js.map +1 -0
  22. package/dist/{chunk-POUWHWID.js → chunk-6CMM6YCB.js} +3 -3
  23. package/dist/{chunk-POUWHWID.js.map → chunk-6CMM6YCB.js.map} +1 -1
  24. package/dist/{chunk-5MARFNSB.js → chunk-AD226HDR.js} +49 -30
  25. package/dist/chunk-AD226HDR.js.map +1 -0
  26. package/dist/chunk-ADV4LDTB.js +106 -0
  27. package/dist/chunk-ADV4LDTB.js.map +1 -0
  28. package/dist/{chunk-7WU4OPLP.js → chunk-AV5NZMYO.js} +5 -3
  29. package/dist/{chunk-7WU4OPLP.js.map → chunk-AV5NZMYO.js.map} +1 -1
  30. package/dist/chunk-B7EM4GGF.js +198 -0
  31. package/dist/chunk-B7EM4GGF.js.map +1 -0
  32. package/dist/chunk-BFDQ4WNW.js +119 -0
  33. package/dist/chunk-BFDQ4WNW.js.map +1 -0
  34. package/dist/{chunk-2XLC3AEX.js → chunk-BI673VEJ.js} +536 -510
  35. package/dist/chunk-BI673VEJ.js.map +1 -0
  36. package/dist/chunk-CEXSOI5R.js +808 -0
  37. package/dist/chunk-CEXSOI5R.js.map +1 -0
  38. package/dist/{chunk-FW75G2W4.js → chunk-CISYM4EO.js} +5 -5
  39. package/dist/{chunk-B7HUUJOK.js → chunk-D3ZURCG7.js} +3 -3
  40. package/dist/chunk-D5TOQSO4.js +474 -0
  41. package/dist/chunk-D5TOQSO4.js.map +1 -0
  42. package/dist/{chunk-UQUOVWBG.js → chunk-DRDUIZIA.js} +7 -7
  43. package/dist/{chunk-27EPWVOY.js → chunk-DW4YTVR3.js} +2 -2
  44. package/dist/chunk-E7LGOMH6.js +449 -0
  45. package/dist/chunk-E7LGOMH6.js.map +1 -0
  46. package/dist/{chunk-QSCPK4F5.js → chunk-E7SW44LM.js} +4 -11
  47. package/dist/chunk-E7SW44LM.js.map +1 -0
  48. package/dist/chunk-EDJWHDDL.js +33 -0
  49. package/dist/chunk-EDJWHDDL.js.map +1 -0
  50. package/dist/chunk-F3ED5WTR.js +13 -0
  51. package/dist/chunk-F3ED5WTR.js.map +1 -0
  52. package/dist/chunk-G75OPGAK.js +111 -0
  53. package/dist/chunk-G75OPGAK.js.map +1 -0
  54. package/dist/{chunk-R5LCN54M.js → chunk-GAKUQHKA.js} +13 -17
  55. package/dist/{chunk-R5LCN54M.js.map → chunk-GAKUQHKA.js.map} +1 -1
  56. package/dist/{chunk-4ZZO6ULA.js → chunk-HDPUXS3Z.js} +19 -48
  57. package/dist/chunk-HDPUXS3Z.js.map +1 -0
  58. package/dist/{chunk-ORWL5BSN.js → chunk-HGZEPQUT.js} +2 -2
  59. package/dist/{chunk-6E5R45ZO.js → chunk-HREHWL32.js} +4 -4
  60. package/dist/{chunk-6E5R45ZO.js.map → chunk-HREHWL32.js.map} +1 -1
  61. package/dist/{chunk-KXVP2VKA.js → chunk-I5TDIUKM.js} +15 -34
  62. package/dist/chunk-I5TDIUKM.js.map +1 -0
  63. package/dist/{chunk-7QKHZQKW.js → chunk-IADZOXKN.js} +39 -6
  64. package/dist/chunk-IADZOXKN.js.map +1 -0
  65. package/dist/{chunk-P4NH7OUK.js → chunk-IDTRSAHE.js} +2 -2
  66. package/dist/{chunk-YFPY4ONH.js → chunk-JEVQ5LKO.js} +4 -4
  67. package/dist/chunk-JNJWBTU2.js +3497 -0
  68. package/dist/chunk-JNJWBTU2.js.map +1 -0
  69. package/dist/{chunk-MNXS2U45.js → chunk-JRZBBPO6.js} +167 -86
  70. package/dist/chunk-JRZBBPO6.js.map +1 -0
  71. package/dist/{chunk-WJXLQXJY.js → chunk-MPZUYCAP.js} +4 -1
  72. package/dist/{chunk-WJXLQXJY.js.map → chunk-MPZUYCAP.js.map} +1 -1
  73. package/dist/{chunk-SJLTEINJ.js → chunk-OJNTCYQQ.js} +17 -1
  74. package/dist/chunk-OJNTCYQQ.js.map +1 -0
  75. package/dist/{chunk-AGZ7PJKY.js → chunk-OTWLERSW.js} +22 -5
  76. package/dist/chunk-OTWLERSW.js.map +1 -0
  77. package/dist/{chunk-NEFNKLBE.js → chunk-PJNENX2A.js} +1535 -422
  78. package/dist/chunk-PJNENX2A.js.map +1 -0
  79. package/dist/{chunk-UKY4CHNC.js → chunk-PKHI276N.js} +8 -4
  80. package/dist/chunk-PKHI276N.js.map +1 -0
  81. package/dist/{chunk-5K5W4S66.js → chunk-QF3LSMGS.js} +2 -2
  82. package/dist/{chunk-XZKD7DIF.js → chunk-RL5UUDT4.js} +3 -3
  83. package/dist/{chunk-XZKD7DIF.js.map → chunk-RL5UUDT4.js.map} +1 -1
  84. package/dist/{chunk-OHRR5OYM.js → chunk-SFASB5FL.js} +10 -4
  85. package/dist/chunk-SFASB5FL.js.map +1 -0
  86. package/dist/{chunk-YVFXE7RR.js → chunk-SNNSAGMT.js} +7279 -2627
  87. package/dist/chunk-SNNSAGMT.js.map +1 -0
  88. package/dist/{chunk-WK7F3B2E.js → chunk-SO3XRZPX.js} +3 -3
  89. package/dist/chunk-SYOS5CAC.js +176 -0
  90. package/dist/chunk-SYOS5CAC.js.map +1 -0
  91. package/dist/chunk-TAW4UFFF.js +293 -0
  92. package/dist/chunk-TAW4UFFF.js.map +1 -0
  93. package/dist/{hosts-FWZOV26H.js → chunk-TF5HCP33.js} +79 -24
  94. package/dist/chunk-TF5HCP33.js.map +1 -0
  95. package/dist/{chunk-AKWGE6JQ.js → chunk-UUGOUOVT.js} +37 -2
  96. package/dist/chunk-UUGOUOVT.js.map +1 -0
  97. package/dist/{chunk-7ZRL2LBQ.js → chunk-V2LQLN5H.js} +6 -6
  98. package/dist/{chunk-K72RURN3.js → chunk-VJUVFZ2D.js} +2 -2
  99. package/dist/{chunk-77TCKDEC.js → chunk-VOZA6O7K.js} +663 -477
  100. package/dist/chunk-VOZA6O7K.js.map +1 -0
  101. package/dist/{chunk-D65GNPS3.js → chunk-VUGQTZ2L.js} +208 -84
  102. package/dist/chunk-VUGQTZ2L.js.map +1 -0
  103. package/dist/chunk-WOM257PW.js +393 -0
  104. package/dist/chunk-WOM257PW.js.map +1 -0
  105. package/dist/chunk-WYXUQGOL.js +191 -0
  106. package/dist/chunk-WYXUQGOL.js.map +1 -0
  107. package/dist/chunk-X5ZBP3IY.js +97 -0
  108. package/dist/chunk-X5ZBP3IY.js.map +1 -0
  109. package/dist/{chunk-5C32RLTA.js → chunk-YUY4SAGM.js} +17 -2
  110. package/dist/chunk-YUY4SAGM.js.map +1 -0
  111. package/dist/{cli-D5OE3URZ.js → cli-FB4LOA5A.js} +144 -63
  112. package/dist/{cli-D5OE3URZ.js.map → cli-FB4LOA5A.js.map} +1 -1
  113. package/dist/{codex-event-PPNVRRDH.js → codex-event-TYVES3UX.js} +2 -2
  114. package/dist/{codex-host-2RJOJW2B.js → codex-host-WW4H2SKT.js} +7 -6
  115. package/dist/codex-install-2C623HPW.js +393 -0
  116. package/dist/codex-install-2C623HPW.js.map +1 -0
  117. package/dist/{config-ZD4OB2DO.js → config-HOVJFEKD.js} +21 -17
  118. package/dist/doctor-NKU4V5OV.js +1312 -0
  119. package/dist/doctor-NKU4V5OV.js.map +1 -0
  120. package/dist/{env-proxy-XL4P73MZ.js → env-proxy-R6ZMLQTT.js} +6 -2
  121. package/dist/{ethersCompat-Df4a6QIZ-THAVUGIJ.js → ethersCompat-Df4a6QIZ-X6YZWAML.js} +3 -3
  122. package/dist/{fund-5ITKQGYF.js → fund-WEBHTZGN.js} +37 -36
  123. package/dist/{fund-5ITKQGYF.js.map → fund-WEBHTZGN.js.map} +1 -1
  124. package/dist/hook-command-ZA2PNKS6.js +44 -0
  125. package/dist/hosts/claude/.claude-plugin/marketplace.json +2 -2
  126. package/dist/hosts/claude/tenjin/.claude-plugin/plugin.json +2 -2
  127. package/dist/hosts/claude/tenjin/skills/tenjin-pay/SKILL.md +82 -0
  128. package/dist/hosts/codex/tenjin/.mcp.json +3 -0
  129. package/dist/hosts/codex/tenjin/hooks/hooks.json +51 -5
  130. package/dist/hosts-AV5MHBAU.js +38 -0
  131. package/dist/index.js +28 -8
  132. package/dist/index.js.map +1 -1
  133. package/dist/{install-XWGE4Q7L.js → install-PT4EZS4R.js} +53 -30
  134. package/dist/{install-identity-K7EJIQFP.js → install-identity-5A4OE6YC.js} +11 -10
  135. package/dist/install-wallet-SAAPKB73.js +281 -0
  136. package/dist/install-wallet-SAAPKB73.js.map +1 -0
  137. package/dist/{mcp-3LIJSSJB.js → mcp-HAWKCTPQ.js} +785 -210
  138. package/dist/mcp-HAWKCTPQ.js.map +1 -0
  139. package/dist/{mine.wasm-6PIT3DK6.js → mine.wasm-QFAHIFPY.js} +2 -2
  140. package/dist/{mine.wasm-6PIT3DK6.js.map → mine.wasm-QFAHIFPY.js.map} +1 -1
  141. package/dist/{package-ZKQFDWLE.js → package-SR2WB6MK.js} +4 -2
  142. package/dist/passphrase-IFTDS3CU.js +44 -0
  143. package/dist/{paths-POPTXJO6.js → paths-XCSAKISU.js} +10 -2
  144. package/dist/{pay-WHBERZ3W.js → pay-OXC3WKYV.js} +29 -29
  145. package/dist/{payments-KVICEKD2.js → payments-3KHMP2MG.js} +15 -14
  146. package/dist/{payments-KVICEKD2.js.map → payments-3KHMP2MG.js.map} +1 -1
  147. package/dist/plugin-registration-N3GRIZVM.js +67 -0
  148. package/dist/{redact-6W23GGJC.js → redact-D7ASVWKL.js} +2 -2
  149. package/dist/runtime-UVNUA3AS.js +1203 -0
  150. package/dist/runtime-UVNUA3AS.js.map +1 -0
  151. package/dist/runtime-fetch-EKFRNR6Z.js +20 -0
  152. package/dist/runtime-layout-BDWZG2TQ.js +25 -0
  153. package/dist/{send-7G7Y7DLN.js → send-HMKJLT34.js} +24 -22
  154. package/dist/{send-7G7Y7DLN.js.map → send-HMKJLT34.js.map} +1 -1
  155. package/dist/{status-OF7RH5HM.js → status-RWXIIWYS.js} +55 -25
  156. package/dist/status-RWXIIWYS.js.map +1 -0
  157. package/dist/{status-line-XOUE6MPL.js → status-line-77XYZP7E.js} +10 -9
  158. package/dist/{status-line-XOUE6MPL.js.map → status-line-77XYZP7E.js.map} +1 -1
  159. package/dist/uninstall-D5G67UJH.js +480 -0
  160. package/dist/uninstall-D5G67UJH.js.map +1 -0
  161. package/dist/update-LRNOEGSB.js +53 -0
  162. package/dist/update-LRNOEGSB.js.map +1 -0
  163. package/dist/{usdc-OGOGEHV2.js → usdc-D6X7EIQ2.js} +6 -8
  164. package/dist/usdc-D6X7EIQ2.js.map +1 -0
  165. package/dist/{viemAdapter-By13KInL-S3DA7DFW.js → viemAdapter-By13KInL-RL742ETX.js} +3 -3
  166. package/dist/viemAdapter-By13KInL-RL742ETX.js.map +1 -0
  167. package/dist/wallet-XFYC27BR.js +55 -0
  168. package/dist/wallet-XFYC27BR.js.map +1 -0
  169. package/dist/wallet-kdf-worker.mjs +8 -8
  170. package/docs/agent-permissions.md +40 -22
  171. package/docs/safety-model.md +1 -1
  172. package/docs/troubleshooting.md +72 -1
  173. package/package.json +14 -1
  174. package/dist/ccip-NLCSCHKI.js +0 -19
  175. package/dist/chunk-2XLC3AEX.js.map +0 -1
  176. package/dist/chunk-4ZZO6ULA.js.map +0 -1
  177. package/dist/chunk-5C32RLTA.js.map +0 -1
  178. package/dist/chunk-5IEP5EGE.js +0 -5332
  179. package/dist/chunk-5IEP5EGE.js.map +0 -1
  180. package/dist/chunk-5MARFNSB.js.map +0 -1
  181. package/dist/chunk-77TCKDEC.js.map +0 -1
  182. package/dist/chunk-7EKYXMUO.js +0 -7536
  183. package/dist/chunk-7EKYXMUO.js.map +0 -1
  184. package/dist/chunk-7QKHZQKW.js.map +0 -1
  185. package/dist/chunk-AGZ7PJKY.js.map +0 -1
  186. package/dist/chunk-AKWGE6JQ.js.map +0 -1
  187. package/dist/chunk-BL3332HQ.js +0 -7611
  188. package/dist/chunk-BL3332HQ.js.map +0 -1
  189. package/dist/chunk-D65GNPS3.js.map +0 -1
  190. package/dist/chunk-EGELTSPU.js +0 -2865
  191. package/dist/chunk-EGELTSPU.js.map +0 -1
  192. package/dist/chunk-GA7JETVM.js +0 -150
  193. package/dist/chunk-GA7JETVM.js.map +0 -1
  194. package/dist/chunk-I3EQFHCD.js +0 -175
  195. package/dist/chunk-I3EQFHCD.js.map +0 -1
  196. package/dist/chunk-K3I7C2MO.js +0 -1185
  197. package/dist/chunk-K3I7C2MO.js.map +0 -1
  198. package/dist/chunk-KXVP2VKA.js.map +0 -1
  199. package/dist/chunk-LEFIX6RS.js.map +0 -1
  200. package/dist/chunk-MNXS2U45.js.map +0 -1
  201. package/dist/chunk-NEFNKLBE.js.map +0 -1
  202. package/dist/chunk-OHRR5OYM.js.map +0 -1
  203. package/dist/chunk-QSCPK4F5.js.map +0 -1
  204. package/dist/chunk-SJLTEINJ.js.map +0 -1
  205. package/dist/chunk-TTNESUPQ.js.map +0 -1
  206. package/dist/chunk-UKY4CHNC.js.map +0 -1
  207. package/dist/chunk-V6BSF6OC.js +0 -260
  208. package/dist/chunk-V6BSF6OC.js.map +0 -1
  209. package/dist/chunk-YVFXE7RR.js.map +0 -1
  210. package/dist/codex-install-UUZ6QMBQ.js +0 -221
  211. package/dist/codex-install-UUZ6QMBQ.js.map +0 -1
  212. package/dist/doctor-KBR34Q4B.js +0 -601
  213. package/dist/doctor-KBR34Q4B.js.map +0 -1
  214. package/dist/hook-command-4TYCHHRL.js +0 -39
  215. package/dist/hosts-FWZOV26H.js.map +0 -1
  216. package/dist/install-wallet-XQ6XFZV4.js +0 -117
  217. package/dist/install-wallet-XQ6XFZV4.js.map +0 -1
  218. package/dist/mcp-3LIJSSJB.js.map +0 -1
  219. package/dist/plugin-registration-5TIA564H.js +0 -54
  220. package/dist/status-OF7RH5HM.js.map +0 -1
  221. package/dist/uninstall-JXUAFNDB.js +0 -158
  222. package/dist/uninstall-JXUAFNDB.js.map +0 -1
  223. package/dist/update-ZKUERSO2.js +0 -44
  224. package/dist/wallet-2HA6W4R4.js +0 -43
  225. /package/dist/{_esm-MEXZI5DL.js.map → _esm-RLLC72MS.js.map} +0 -0
  226. /package/dist/{alive-J64H46HI.js.map → alive-MROUMFH3.js.map} +0 -0
  227. /package/dist/{ccip-7RMRLAGV.js.map → auto-update-OPWMRZLS.js.map} +0 -0
  228. /package/dist/{ccip-NLCSCHKI.js.map → ccip-DHDFKTQV.js.map} +0 -0
  229. /package/dist/{chunk-7Q5FDF65.js.map → chunk-445VQTVM.js.map} +0 -0
  230. /package/dist/{chunk-KXQ4UIP7.js.map → chunk-4USCZ2NI.js.map} +0 -0
  231. /package/dist/{chunk-FW75G2W4.js.map → chunk-CISYM4EO.js.map} +0 -0
  232. /package/dist/{chunk-B7HUUJOK.js.map → chunk-D3ZURCG7.js.map} +0 -0
  233. /package/dist/{chunk-UQUOVWBG.js.map → chunk-DRDUIZIA.js.map} +0 -0
  234. /package/dist/{chunk-27EPWVOY.js.map → chunk-DW4YTVR3.js.map} +0 -0
  235. /package/dist/{chunk-ORWL5BSN.js.map → chunk-HGZEPQUT.js.map} +0 -0
  236. /package/dist/{chunk-P4NH7OUK.js.map → chunk-IDTRSAHE.js.map} +0 -0
  237. /package/dist/{chunk-YFPY4ONH.js.map → chunk-JEVQ5LKO.js.map} +0 -0
  238. /package/dist/{chunk-5K5W4S66.js.map → chunk-QF3LSMGS.js.map} +0 -0
  239. /package/dist/{chunk-WK7F3B2E.js.map → chunk-SO3XRZPX.js.map} +0 -0
  240. /package/dist/{chunk-7ZRL2LBQ.js.map → chunk-V2LQLN5H.js.map} +0 -0
  241. /package/dist/{chunk-K72RURN3.js.map → chunk-VJUVFZ2D.js.map} +0 -0
  242. /package/dist/{codex-event-PPNVRRDH.js.map → codex-event-TYVES3UX.js.map} +0 -0
  243. /package/dist/{codex-host-2RJOJW2B.js.map → codex-host-WW4H2SKT.js.map} +0 -0
  244. /package/dist/{config-ZD4OB2DO.js.map → config-HOVJFEKD.js.map} +0 -0
  245. /package/dist/{env-proxy-XL4P73MZ.js.map → env-proxy-R6ZMLQTT.js.map} +0 -0
  246. /package/dist/{ethersCompat-Df4a6QIZ-THAVUGIJ.js.map → ethersCompat-Df4a6QIZ-X6YZWAML.js.map} +0 -0
  247. /package/dist/{hook-command-4TYCHHRL.js.map → hook-command-ZA2PNKS6.js.map} +0 -0
  248. /package/dist/{install-XWGE4Q7L.js.map → hosts-AV5MHBAU.js.map} +0 -0
  249. /package/dist/{install-identity-K7EJIQFP.js.map → install-PT4EZS4R.js.map} +0 -0
  250. /package/dist/{package-ZKQFDWLE.js.map → install-identity-5A4OE6YC.js.map} +0 -0
  251. /package/dist/{paths-POPTXJO6.js.map → package-SR2WB6MK.js.map} +0 -0
  252. /package/dist/{pay-WHBERZ3W.js.map → passphrase-IFTDS3CU.js.map} +0 -0
  253. /package/dist/{plugin-registration-5TIA564H.js.map → paths-XCSAKISU.js.map} +0 -0
  254. /package/dist/{redact-6W23GGJC.js.map → pay-OXC3WKYV.js.map} +0 -0
  255. /package/dist/{update-ZKUERSO2.js.map → plugin-registration-N3GRIZVM.js.map} +0 -0
  256. /package/dist/{usdc-OGOGEHV2.js.map → redact-D7ASVWKL.js.map} +0 -0
  257. /package/dist/{viemAdapter-By13KInL-S3DA7DFW.js.map → runtime-fetch-EKFRNR6Z.js.map} +0 -0
  258. /package/dist/{wallet-2HA6W4R4.js.map → runtime-layout-BDWZG2TQ.js.map} +0 -0
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/router/router-observation.ts"],"sourcesContent":["import { readFile, readdir, rm } from 'node:fs/promises';\nimport { rmSync } from 'node:fs';\nimport { join } from 'node:path';\nimport { z } from 'zod';\nimport { writeFileAtomic } from '../lib/atomic-json';\nimport { hasCode } from '../lib/errno';\nimport type { SigningSource } from '../lib/wallet-unlock';\n\n/**\n * WHAT THE RUNNING `tenjin mcp` SAW, for the processes that cannot ask it.\n * Doctor runs in a shell, `alive` and the hooks run as their own processes,\n * and none of them can see the router Claude Code started: its environment,\n * its keychain answer, its verdict. So the router writes them down:\n *\n * <dataDir>/router/live/<pid>.json one per running `tenjin mcp`; removed on exit\n * <dataDir>/router/unlock-state.json the latest unlock verdict per address;\n * survives the process\n *\n * Both are 0600 in a 0700 directory, and neither ever holds a passphrase, a\n * key, an env VALUE or a store's stdout: only whether a variable is set, the\n * address, the cwd and verdicts.\n *\n * A HEALTH-CHECK ROUTER IS NOT A SESSION (B2). `claude mcp get` and `claude mcp\n * list` start a `tenjin mcp` that serves no hook. Its observation says\n * `servedSession: false` until it serves a hook call carrying a valid\n * session_id, and every reader that means \"the running Claude session\" keeps\n * only `servedSession: true` ({@link servedObservations}). Only a served\n * router reads or writes unlock-state.\n *\n * Hook-safe: node, zod and `lib/atomic-json` only. Every reader treats any\n * I/O error as \"absent\", and the writers swallow theirs: these files are\n * advisory, and a router must never fail a lookup because it could not\n * describe itself.\n */\n\nexport interface RouterObservation {\n version: 1;\n pid: number;\n startedAt: number;\n at: number;\n cliVersion: string;\n harness: 'claude' | 'codex';\n launchedByPlugin: boolean;\n cwd: string;\n address: string | null;\n /** B2: false until this router has served a hook call carrying a valid session_id. Readers that mean\n * \"the running Claude session\" ignore false. */\n servedSession: boolean;\n env: { passphraseSet: boolean; keySet: boolean };\n sign: {\n status: 'ready' | 'blocked' | 'unknown' | 'pending';\n reason?: string;\n detail?: string;\n fix?: string;\n source?: SigningSource;\n };\n routing?: { status: 'ready' | 'blocked' | 'unknown'; reason?: string; at: number };\n}\n\nexport interface UnlockInputs {\n envPassphraseSet: boolean;\n envKeySet: boolean;\n walletMtimeMs: number | null;\n sidecarMtimeMs: number | null;\n cliVersion: string;\n}\n\nexport interface UnlockRecord {\n version: 1;\n address: string;\n status: 'ready' | 'blocked' | 'unknown' | 'awaiting_confirmation';\n reason?: string;\n at: number;\n inputs?: UnlockInputs;\n}\n\nconst SIGNING_SOURCES = [\n 'key-env',\n 'passphrase-env',\n 'keychain',\n 'secret-service',\n 'dpapi',\n 'file',\n 'legacy',\n] as const;\n\nconst ObservationSchema = z.object({\n version: z.literal(1),\n pid: z.number().int().positive(),\n startedAt: z.number(),\n at: z.number(),\n cliVersion: z.string(),\n harness: z.enum(['claude', 'codex']),\n launchedByPlugin: z.boolean(),\n cwd: z.string(),\n address: z.string().nullable(),\n servedSession: z.boolean(),\n env: z.object({ passphraseSet: z.boolean(), keySet: z.boolean() }),\n sign: z.object({\n status: z.enum(['ready', 'blocked', 'unknown', 'pending']),\n reason: z.string().optional(),\n detail: z.string().optional(),\n fix: z.string().optional(),\n source: z.enum(SIGNING_SOURCES).optional(),\n }),\n routing: z\n .object({\n status: z.enum(['ready', 'blocked', 'unknown']),\n reason: z.string().optional(),\n at: z.number(),\n })\n .optional(),\n});\n\nconst UnlockRecordSchema = z.object({\n version: z.literal(1),\n address: z.string(),\n status: z.enum(['ready', 'blocked', 'unknown', 'awaiting_confirmation']),\n reason: z.string().optional(),\n at: z.number(),\n inputs: z\n .object({\n envPassphraseSet: z.boolean(),\n envKeySet: z.boolean(),\n walletMtimeMs: z.number().nullable(),\n sidecarMtimeMs: z.number().nullable(),\n cliVersion: z.string(),\n })\n .optional(),\n});\n\n/** The envelope; records are checked one at a time so one bad entry hides only itself. */\nconst UnlockStateSchema = z.object({\n version: z.literal(1),\n wallets: z.record(z.string(), z.unknown()),\n});\n\nconst OBSERVATION_NAME = /^(\\d+)\\.json$/;\n/** How far a ps start time may sit from the observation's before the pid is another process. */\nconst START_SLACK_MS = 2000;\n\n/** Where the running routers' observations live. */\nexport function liveDir(dataDir: string): string {\n return join(dataDir, 'router', 'live');\n}\n\nfunction observationPath(dataDir: string, pid: number): string {\n return join(liveDir(dataDir), `${pid}.json`);\n}\n\nfunction unlockStatePath(dataDir: string): string {\n return join(dataDir, 'router', 'unlock-state.json');\n}\n\n/** Write this router's observation. Swallows errors: it is advisory. */\nexport async function writeObservation(dataDir: string, obs: RouterObservation): Promise<void> {\n try {\n await writeFileAtomic(observationPath(dataDir, obs.pid), JSON.stringify(obs) + '\\n', {\n mode: 0o600,\n dirMode: 0o700,\n });\n } catch {\n // A router that cannot describe itself still routes.\n }\n}\n\n/** Remove a router's observation, synchronously, for the process 'exit' handler. */\nexport function removeObservationSync(dataDir: string, pid: number): void {\n try {\n rmSync(observationPath(dataDir, pid), { force: true });\n } catch {\n // Nothing to do at exit; pruneDeadObservations clears it later.\n }\n}\n\n/**\n * Unlink the observations whose pid is no longer alive: a router killed\n * without running its exit handler (SIGKILL, a crash) leaves its file behind.\n */\nexport async function pruneDeadObservations(\n dataDir: string,\n isAlive: (pid: number) => boolean = pidAlive,\n): Promise<void> {\n const dir = liveDir(dataDir);\n const names = await readdir(dir).catch(() => [] as string[]);\n for (const name of names) {\n const match = OBSERVATION_NAME.exec(name);\n if (match === null) continue;\n if (isAlive(Number(match[1]))) continue;\n await rm(join(dir, name), { force: true }).catch(() => undefined);\n }\n}\n\n/**\n * Every well-formed observation on disk, shape-checked, with no liveness\n * filter (see {@link liveObservations}). Dropped: a file not named\n * `<digits>.json`, one whose `pid` is not its name, any version but 1, a\n * malformed shape, and one without a boolean `servedSession` (B2: an\n * observation that cannot say whether it served a session is not one).\n */\nexport async function readObservations(dataDir: string): Promise<RouterObservation[]> {\n const dir = liveDir(dataDir);\n const names = await readdir(dir).catch(() => [] as string[]);\n const out: RouterObservation[] = [];\n for (const name of names.sort()) {\n const match = OBSERVATION_NAME.exec(name);\n if (match === null) continue;\n try {\n const parsed = ObservationSchema.safeParse(\n JSON.parse(await readFile(join(dir, name), 'utf8')),\n );\n if (parsed.success && parsed.data.pid === Number(match[1])) {\n out.push(parsed.data as RouterObservation);\n }\n } catch {\n // Unreadable or not JSON: absent.\n }\n }\n return out;\n}\n\n/** The observations that count as a running Claude session: harness 'claude' and servedSession true (B2). */\nexport function servedObservations(obs: RouterObservation[]): RouterObservation[] {\n return obs.filter((o) => o.harness === 'claude' && o.servedSession === true);\n}\n\n/**\n * Keep the observations whose router is still running.\n *\n * With a ps snapshot, the pid must be a listed router (the snapshot lists only\n * live, non-zombie routers) whose start time is within 2 s of the\n * observation's own: a pid the OS has since handed to another router is not\n * this one. A listed router whose start time ps could not give (null) is kept\n * on the pid alone. Without a snapshot (null: ps could not run), `alive`.\n */\nexport function liveObservations(\n obs: RouterObservation[],\n routers: Array<{ pid: number; startedAt: number | null }> | null,\n alive: (pid: number) => boolean = pidAlive,\n): RouterObservation[] {\n if (routers === null) return obs.filter((o) => alive(o.pid));\n return obs.filter((o) => {\n const router = routers.find((r) => r.pid === o.pid);\n if (router === undefined) return false;\n return router.startedAt === null || Math.abs(router.startedAt - o.startedAt) <= START_SLACK_MS;\n });\n}\n\n/**\n * Whether a process with this pid exists: `kill(pid, 0)` sends nothing and\n * only checks. EPERM means it exists under another user, so it counts as\n * alive; ESRCH (and anything else) as gone. Never true for a pid that is not\n * a positive integer, since `kill(0, …)` addresses the whole process group.\n */\nexport function pidAlive(pid: number): boolean {\n if (!Number.isInteger(pid) || pid <= 0) return false;\n try {\n process.kill(pid, 0);\n return true;\n } catch (err) {\n return hasCode(err, 'EPERM');\n }\n}\n\nasync function readUnlockWallets(dataDir: string): Promise<Record<string, unknown> | null> {\n try {\n const parsed = UnlockStateSchema.safeParse(\n JSON.parse(await readFile(unlockStatePath(dataDir), 'utf8')),\n );\n return parsed.success ? parsed.data.wallets : null;\n } catch {\n return null;\n }\n}\n\n/** The latest unlock record for `address` (any case), or null. */\nexport async function readUnlockRecord(\n dataDir: string,\n address: string,\n): Promise<UnlockRecord | null> {\n const wallets = await readUnlockWallets(dataDir);\n if (wallets === null) return null;\n const parsed = UnlockRecordSchema.safeParse(wallets[address.toLowerCase()]);\n return parsed.success ? (parsed.data as UnlockRecord) : null;\n}\n\n/**\n * Record `rec` under its lowercase address, keeping every other address's\n * record. Swallows errors: unlock-state is advisory, and a repair that saved\n * the passphrase must not fail because this file could not be written. Two\n * routers writing at once can lose one update; the next verdict rewrites it.\n */\nexport async function writeUnlockRecord(dataDir: string, rec: UnlockRecord): Promise<void> {\n try {\n const wallets = { ...((await readUnlockWallets(dataDir)) ?? {}) };\n wallets[rec.address.toLowerCase()] = rec;\n await writeFileAtomic(\n unlockStatePath(dataDir),\n JSON.stringify({ version: 1, wallets }, null, 2) + '\\n',\n { mode: 0o600, dirMode: 0o700 },\n );\n } catch {\n // Advisory: see above.\n }\n}\n\n/**\n * After `tenjin wallet repair`: the next served router's verdict for this\n * address decides whether \"Tenjin wallet unlocked.\" is said (decision 14).\n */\nexport async function markUnlockPending(\n dataDir: string,\n address: string,\n now: number = Date.now(),\n): Promise<void> {\n await writeUnlockRecord(d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A,MACnD,EAAE,MAAM,KAAO,SAAS,IAAM;AAAA,IAChC;AAAA,EACF,QAAQ;AAAA,EAER;AACF;AAMA,eAAsB,kBACpB,SACA,SACA,MAAc,KAAK,IAAI,GACR;AACf,QAAM,kBAAkB,SAAS;AAAA,IAC/B,SAAS;AAAA,IACT;AAAA,IACA,QAAQ;AAAA,IACR,IAAI;AAAA,EACN,CAAC;AACH;","names":[]}
@@ -0,0 +1,97 @@
1
+ import { createRequire as __tenjinCreateRequire } from 'node:module'; const require = __tenjinCreateRequire(import.meta.url);
2
+ import {
3
+ CliError
4
+ } from "./chunk-3UCIG4TG.js";
5
+
6
+ // src/lib/wallet-unlock.ts
7
+ var UNLOCK_REASONS = /* @__PURE__ */ new Set([
8
+ "no_wallet",
9
+ "wallet_corrupt",
10
+ "env_key_invalid",
11
+ "passphrase_missing",
12
+ "passphrase_wrong",
13
+ "env_passphrase_wrong",
14
+ "keychain_locked",
15
+ "unlock_timeout"
16
+ ]);
17
+ var PASSPHRASE_LABELS = /* @__PURE__ */ new Set([
18
+ "env",
19
+ "keychain",
20
+ "secret-service",
21
+ "dpapi",
22
+ "file",
23
+ "legacy",
24
+ "prompt"
25
+ ]);
26
+ var DEFINITE_UNLOCK = /* @__PURE__ */ new Set([
27
+ "no_wallet",
28
+ "wallet_corrupt",
29
+ "env_key_invalid",
30
+ "passphrase_missing",
31
+ "passphrase_wrong",
32
+ "env_passphrase_wrong"
33
+ ]);
34
+ var ENV_PASSPHRASE_WRONG = "TENJIN_WALLET_PASSPHRASE is set but wrong; remove it.";
35
+ var REPAIR_CLAUSE = "(it asks for the passphrase in your terminal; never paste it into chat)";
36
+ var REPAIR_IN_TERMINAL = `Run \`tenjin wallet repair\` yourself ${REPAIR_CLAUSE}.`;
37
+ var KEYCHAIN_LOCKED_FIX = "Unlock your keychain (or log in to the desktop session) and retry.";
38
+ function FILE_STORE_FAILED_FIX(path) {
39
+ const dir = path.replace(/[/\\][^/\\]*$/, "") || "/";
40
+ return `Tenjin could not save the passphrase to ${path}; check that ${dir} is writable.`;
41
+ }
42
+ var KEYCHAIN_WAIT_LINE = "Waiting for the keychain\u2026";
43
+ function NO_KEYRING_LINE(path) {
44
+ return `No keyring reachable from this session; passphrase saved to ${path} (readable only by you).`;
45
+ }
46
+ var PRIVATE_KEY_RE = /^0x[0-9a-f]{64}$/i;
47
+ function unlockDetails(reason, source) {
48
+ return { unlock: source === void 0 ? { reason } : { reason, source } };
49
+ }
50
+ function isUnlockDetails(value) {
51
+ if (typeof value !== "object" || value === null) return false;
52
+ const { reason, source } = value;
53
+ if (typeof reason !== "string" || !UNLOCK_REASONS.has(reason)) return false;
54
+ return source === void 0 || typeof source === "string" && PASSPHRASE_LABELS.has(source);
55
+ }
56
+ function detailsOf(err) {
57
+ if (!(err instanceof CliError)) return void 0;
58
+ const unlock = err.details?.unlock;
59
+ return isUnlockDetails(unlock) ? unlock : void 0;
60
+ }
61
+ function classifyUnlockError(err) {
62
+ const unlock = detailsOf(err);
63
+ if (unlock !== void 0) {
64
+ return {
65
+ reason: unlock.reason,
66
+ definite: DEFINITE_UNLOCK.has(unlock.reason),
67
+ ...unlock.source !== void 0 ? { source: unlock.source } : {}
68
+ };
69
+ }
70
+ if (err instanceof CliError && err.code === "WALLET_MISSING") {
71
+ return { reason: "no_wallet", definite: true };
72
+ }
73
+ const name = err?.name;
74
+ if (name === "AbortError" || name === "TimeoutError") {
75
+ return { reason: "unlock_timeout", definite: false };
76
+ }
77
+ return { reason: "wallet_locked", definite: false };
78
+ }
79
+ function unlockReasonOf(err) {
80
+ return detailsOf(err)?.reason ?? null;
81
+ }
82
+
83
+ export {
84
+ DEFINITE_UNLOCK,
85
+ ENV_PASSPHRASE_WRONG,
86
+ REPAIR_CLAUSE,
87
+ REPAIR_IN_TERMINAL,
88
+ KEYCHAIN_LOCKED_FIX,
89
+ FILE_STORE_FAILED_FIX,
90
+ KEYCHAIN_WAIT_LINE,
91
+ NO_KEYRING_LINE,
92
+ PRIVATE_KEY_RE,
93
+ unlockDetails,
94
+ classifyUnlockError,
95
+ unlockReasonOf
96
+ };
97
+ //# sourceMappingURL=chunk-X5ZBP3IY.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/lib/wallet-unlock.ts"],"sourcesContent":["import { CliError } from './errors';\n\n/**\n * WHY A WALLET COULD NOT SIGN, AS ONE VOCABULARY. The wallet layer throws with\n * it, the routing payer skips with it, the hooks gate and word notices with it,\n * and doctor renders it, so every surface names the same cause the same way.\n *\n * HOOK-SAFE ON PURPOSE: it imports `./errors` and nothing else. `tenjin hook`,\n * `alive` and the status line read these reasons, and their chunk graph must\n * stay free of `src/lib/wallet/`, viem, ox and the x402 SDK\n * (`src/router/dist-chunks.test.ts`). That is why the reasons live here and not\n * beside the wallet code that produces them.\n *\n * Six reasons are DEFINITE (this wallet cannot sign until a person fixes\n * something) and two are not (`keychain_locked`, `unlock_timeout`: the store or\n * the clock did not answer, which says nothing about the wallet). Only a\n * definite reason may withhold an offer or skip a routing attempt.\n */\nexport type UnlockReason =\n | 'no_wallet'\n | 'wallet_corrupt'\n | 'env_key_invalid'\n | 'passphrase_missing'\n | 'passphrase_wrong'\n | 'env_passphrase_wrong'\n | 'keychain_locked'\n | 'unlock_timeout';\n\nconst UNLOCK_REASONS: ReadonlySet<string> = new Set<UnlockReason>([\n 'no_wallet',\n 'wallet_corrupt',\n 'env_key_invalid',\n 'passphrase_missing',\n 'passphrase_wrong',\n 'env_passphrase_wrong',\n 'keychain_locked',\n 'unlock_timeout',\n]);\n\n/** A store that keeps a wallet's passphrase across sessions: the platform's own\n * credential store, or the 0600 file where there is none. */\nexport type DurableStore = 'keychain' | 'secret-service' | 'dpapi' | 'file';\n\n/** Where a passphrase came from, for messages; 'legacy' = the pre-per-wallet shared slot. */\nexport type PassphraseLabel = 'env' | DurableStore | 'legacy' | 'prompt';\n\nconst PASSPHRASE_LABELS: ReadonlySet<string> = new Set<PassphraseLabel>([\n 'env',\n 'keychain',\n 'secret-service',\n 'dpapi',\n 'file',\n 'legacy',\n 'prompt',\n]);\n\n/**\n * What actually produced a signature, as doctor, install and the router report\n * it. Defined here rather than in `src/router/eligibility.ts` (which re-exports\n * it) because `src/lib/wallet/provider.ts` needs it too, and lib must not\n * import router.\n */\nexport type SigningSource = 'key-env' | 'passphrase-env' | DurableStore | 'legacy';\n\n/** The cause a wallet throw site attaches as `CliError.details.unlock`. */\nexport interface UnlockDetails {\n reason: UnlockReason;\n source?: PassphraseLabel;\n}\n\n/** Every reason except the two that say the store or the clock did not answer. */\nexport const DEFINITE_UNLOCK: ReadonlySet<UnlockReason> = new Set<UnlockReason>([\n 'no_wallet',\n 'wallet_corrupt',\n 'env_key_invalid',\n 'passphrase_missing',\n 'passphrase_wrong',\n 'env_passphrase_wrong',\n]);\n\n/** Said once when TENJIN_WALLET_PASSPHRASE did not open the wallet and a saved\n * passphrase did: the wallet works, the variable is the thing to remove. */\nexport const ENV_PASSPHRASE_WRONG = 'TENJIN_WALLET_PASSPHRASE is set but wrong; remove it.';\n\n/**\n * Carried by every person-facing string that names `tenjin wallet repair` (B1,\n * decision 15). A passphrase never goes on a command line or into chat: repair\n * asks for it at a hidden prompt, and this clause tells the person so before an\n * agent can suggest otherwise.\n */\nexport const REPAIR_CLAUSE =\n '(it asks for the passphrase in your terminal; never paste it into chat)';\n\n/** The person's fix for a wallet whose saved passphrase is gone or wrong. */\nexport const REPAIR_IN_TERMINAL =\n `Run \\`tenjin wallet repair\\` yourself ${REPAIR_CLAUSE}.` as const;\n\n/**\n * The only fix for a keychain that exists but did not answer (S3). It never\n * points at the plaintext file or at another passphrase: a locked keychain is\n * unlocked, not routed around.\n */\nexport const KEYCHAIN_LOCKED_FIX =\n 'Unlock your keychain (or log in to the desktop session) and retry.';\n\n/**\n * A failed FILE-store write at create or repair (decision 6). Never used for an\n * OS store: there is no keychain to unlock when the file could not be written.\n */\nexport function FILE_STORE_FAILED_FIX(path: string): string {\n // The file's own folder (`TENJIN_DATA_DIR` moves it), cut by hand: this module imports nothing.\n const dir = path.replace(/[/\\\\][^/\\\\]*$/, '') || '/';\n return `Tenjin could not save the passphrase to ${path}; check that ${dir} is writable.`;\n}\n\n/** Shown once when create or repair has waited on the keychain for a second at a terminal. */\nexport const KEYCHAIN_WAIT_LINE = 'Waiting for the keychain…';\n\n/** Why a passphrase went to the 0600 file: no OS store answered the probe as present (S4). */\nexport function NO_KEYRING_LINE(path: string): string {\n return `No keyring reachable from this session; passphrase saved to ${path} (readable only by you).`;\n}\n\n/**\n * THE one TENJIN_WALLET_KEY expression (S12): a 0x-prefixed 32-byte hex private\n * key, case-insensitive. Moved here from `src/lib/wallet/store.ts` unchanged, and\n * store.ts re-exports it, so the wallet layer's `loadCredential` and the\n * hook-safe `wallet-facts.ts` test exactly the same thing. Do not tighten it in\n * one place only: a key one accepts and the other rejects is a wallet doctor\n * calls fine and the hooks call broken.\n */\nexport const PRIVATE_KEY_RE = /^0x[0-9a-f]{64}$/i;\n\n/** `{ unlock: { reason, source } }`, the value every wallet throw site passes as CliError `details`. */\nexport function unlockDetails(\n reason: UnlockReason,\n source?: PassphraseLabel,\n): { unlock: UnlockDetails } {\n return { unlock: source === undefined ? { reason } : { reason, source } };\n}\n\n/** Whether `value` is a well-formed `details.unlock`: a known reason, and a known source if any. */\nfunction isUnlockDetails(value: unknown): value is UnlockDetails {\n if (typeof value !== 'object' || value === null) return false;\n const { reason, source } = value as { reason?: unknown; source?: unknown };\n if (typeof reason !== 'string' || !UNLOCK_REASONS.has(reason)) return false;\n return source === undefined || (typeof source === 'string' && PASSPHRASE_LABELS.has(source));\n}\n\n/** `details.unlock` of a CliError that carries a valid one, else undefined. */\nfunction detailsOf(err: unknown): UnlockDetails | undefined {\n if (!(err instanceof CliError)) return undefined;\n const unlock = (err.details as { unlock?: unknown } | null | undefined)?.unlock;\n return isUnlockDetails(unlock) ? unlock : undefined;\n}\n\n/**\n * WHAT AN UNLOCK FAILURE MEANS, for gating and wording. In order:\n * `details.unlock` when the thrower classified it; `WALLET_MISSING` is\n * `no_wallet`; an AbortError or TimeoutError is `unlock_timeout`. ANY other\n * error, an undetailed CliError included, is `wallet_locked`, which is never\n * definite: nobody said why, so nothing may be withheld on its account.\n *\n * It never matches on message text. A message is wording, free to change; a\n * reason that hung on it would turn a copy edit into a gating change.\n */\nexport function classifyUnlockError(err: unknown): {\n reason: UnlockReason | 'wallet_locked';\n definite: boolean;\n source?: PassphraseLabel;\n} {\n const unlock = detailsOf(err);\n if (unlock !== undefined) {\n return {\n reason: unlock.reason,\n definite: DEFINITE_UNLOCK.has(unlock.reason),\n ...(unlock.source !== undefined ? { source: unlock.source } : {}),\n };\n }\n if (err instanceof CliError && err.code === 'WALLET_MISSING') {\n return { reason: 'no_wallet', definite: true };\n }\n const name = (err as { name?: unknown } | null | undefined)?.name;\n // By name, not class: a DOMException from AbortSignal.timeout and a\n // hand-made Error named AbortError mean the same thing here.\n if (name === 'AbortError' || name === 'TimeoutError') {\n return { reason: 'unlock_timeout', definite: false };\n }\n return { reason: 'wallet_locked', definite: false };\n}\n\n/**\n * `details.unlock.reason` when `err` is a CliError carrying a valid\n * `details.unlock`; null for anything else (an undetailed WALLET_MISSING, an\n * AbortError, any other CliError or value).\n *\n * THE ONLY GATE for swapping a fix to its model-facing `agentFix` (B1). Not\n * {@link classifyUnlockError}: its `wallet_locked` fallback covers EVERY\n * undetailed error, a `REGISTRY_MISMATCH` or an HTTP failure included, and\n * swapping on it would replace those errors' own fixes with wallet advice.\n */\nexport function unlockReasonOf(err: unknown): UnlockReason | null {\n return detailsOf(err)?.reason ?? null;\n}\n"],"mappings":";;;;;;AA4BA,IAAM,iBAAsC,oBAAI,IAAkB;AAAA,EAChE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,CAAC;AASD,IAAM,oBAAyC,oBAAI,IAAqB;AAAA,EACtE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;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Ae,YAAY,IAAI,SAAS,kBAAkB;AAC5D,WAAO,EAAE,QAAQ,aAAa,UAAU,KAAK;AAAA,EAC/C;AACA,QAAM,OAAQ,KAA+C;AAG7D,MAAI,SAAS,gBAAgB,SAAS,gBAAgB;AACpD,WAAO,EAAE,QAAQ,kBAAkB,UAAU,MAAM;AAAA,EACrD;AACA,SAAO,EAAE,QAAQ,iBAAiB,UAAU,MAAM;AACpD;AAYO,SAAS,eAAe,KAAmC;AAChE,SAAO,UAAU,GAAG,GAAG,UAAU;AACnC;","names":[]}
@@ -2,7 +2,7 @@ import { createRequire as __tenjinCreateRequire } from 'node:module'; const requ
2
2
 
3
3
  // package.json
4
4
  var name = "tenjin-cli";
5
- var version = "0.1.0-alpha.31";
5
+ var version = "0.1.0-alpha.32";
6
6
  var type = "module";
7
7
  var description = "The tool router for coding agents. Tenjin picks the right tool when your agent needs one, and one wallet pays for every call.";
8
8
  var repository = {
@@ -33,6 +33,19 @@ var bin = {
33
33
  var engines = {
34
34
  node: ">=22.0.0"
35
35
  };
36
+ var tenjinRuntime = {
37
+ node: {
38
+ version: "24.22.1",
39
+ sha256: {
40
+ "darwin-arm64": "89c682593d76cd44233fa53b1563264e7de9cbb189cad169135c5b4fadfbc0a7",
41
+ "darwin-x64": "d132557e7ee2b85af08b0c8c34338e65c6430f2238d01f727728ef42dc83b035",
42
+ "linux-x64": "eb6728e77c576a35162c122c45ccadf224d89ff00abc8dae46cc2897c6002d7c",
43
+ "linux-arm64": "33c37be234ba8bee041961047b19160f4d7d0f164e8e246f78bdd10feff148b3",
44
+ "win-x64": "d2046d28c2c3dcd211ac5145c0bf30e2047ef9dfb306693c8c6e2eccd8b95fa5",
45
+ "win-arm64": "a0c807319fede24c4a0d8f84564c82a619bd313b16b10c007c383c2609e99171"
46
+ }
47
+ }
48
+ };
36
49
  var files = [
37
50
  "dist",
38
51
  "docs",
@@ -89,6 +102,7 @@ var package_default = {
89
102
  keywords,
90
103
  bin,
91
104
  engines,
105
+ tenjinRuntime,
92
106
  files,
93
107
  packageManager,
94
108
  scripts,
@@ -106,10 +120,11 @@ export {
106
120
  keywords,
107
121
  bin,
108
122
  engines,
123
+ tenjinRuntime,
109
124
  files,
110
125
  packageManager,
111
126
  scripts,
112
127
  devDependencies,
113
128
  package_default
114
129
  };
115
- //# sourceMappingURL=chunk-5C32RLTA.js.map
130
+ //# sourceMappingURL=chunk-YUY4SAGM.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../package.json"],"sourcesContent":["{\n \"name\": \"tenjin-cli\",\n \"version\": \"0.1.0-alpha.32\",\n \"type\": \"module\",\n \"description\": \"The tool router for coding agents. Tenjin picks the right tool when your agent needs one, and one wallet pays for every call.\",\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"git+https://github.com/BackTrackCo/tenjin-agent.git\"\n },\n \"homepage\": \"https://tenjin.sh/agents\",\n \"bugs\": \"https://github.com/BackTrackCo/tenjin-agent/issues\",\n \"keywords\": [\n \"claude-code\",\n \"coding-agents\",\n \"tool-router\",\n \"ai-agents\",\n \"agent-tools\",\n \"mcp\",\n \"x402\",\n \"usdc\",\n \"base\",\n \"micropayments\",\n \"agent-payments\",\n \"claude\",\n \"codex\",\n \"cli\"\n ],\n \"bin\": {\n \"tenjin\": \"dist/index.js\"\n },\n \"engines\": {\n \"node\": \">=22.0.0\"\n },\n \"tenjinRuntime\": {\n \"node\": {\n \"version\": \"24.22.1\",\n \"sha256\": {\n \"darwin-arm64\": \"89c682593d76cd44233fa53b1563264e7de9cbb189cad169135c5b4fadfbc0a7\",\n \"darwin-x64\": \"d132557e7ee2b85af08b0c8c34338e65c6430f2238d01f727728ef42dc83b035\",\n \"linux-x64\": \"eb6728e77c576a35162c122c45ccadf224d89ff00abc8dae46cc2897c6002d7c\",\n \"linux-arm64\": \"33c37be234ba8bee041961047b19160f4d7d0f164e8e246f78bdd10feff148b3\",\n \"win-x64\": \"d2046d28c2c3dcd211ac5145c0bf30e2047ef9dfb306693c8c6e2eccd8b95fa5\",\n \"win-arm64\": \"a0c807319fede24c4a0d8f84564c82a619bd313b16b10c007c383c2609e99171\"\n }\n }\n },\n \"files\": [\n \"dist\",\n \"docs\",\n \"NOTICE.md\"\n ],\n \"packageManager\": \"pnpm@11.11.0\",\n \"scripts\": {\n \"build\": \"rm -rf dist && tsup\",\n \"test\": \"vitest run\",\n \"typecheck\": \"tsc --noEmit\",\n \"lint\": \"eslint .\",\n \"format\": \"prettier --write .\",\n \"format:check\": \"prettier --check .\",\n \"check\": \"pnpm run build && pnpm run test\",\n \"sync:skill\": \"node scripts/sync-skill.mjs\",\n \"pack-smoke\": \"bash scripts/pack-smoke.sh\",\n \"changeset\": \"changeset\",\n \"prepublishOnly\": \"pnpm run build\",\n \"githooks\": \"git config core.hooksPath .githooks\"\n },\n \"devDependencies\": {\n \"@changesets/cli\": \"^3.0.3\",\n \"@clack/prompts\": \"^1.7.0\",\n \"@eslint/js\": \"^10\",\n \"@modelcontextprotocol/sdk\": \"1.32.0\",\n \"@types/node\": \"^22.20.5\",\n \"@x402/core\": \"2.28.0\",\n \"@x402/evm\": \"2.28.0\",\n \"@x402/extensions\": \"2.28.0\",\n \"@x402/fetch\": \"2.28.0\",\n \"ajv\": \"^8.20.0\",\n \"ajv-formats\": \"^3.0.1\",\n \"commander\": \"^14.0.1\",\n \"eslint\": \"^10\",\n \"eslint-config-prettier\": \"^10\",\n \"lean-qr\": \"^2.7.4\",\n \"ox\": \"0.14.30\",\n \"prettier\": \"^3\",\n \"tsup\": \"^8.5.0\",\n \"typescript\": \"^6\",\n \"typescript-eslint\": \"^8\",\n \"viem\": \"^2.53.1\",\n \"vitest\": \"^4.1.9\",\n \"zod\": \"^4.4.3\"\n }\n}\n"],"mappings":";;;AACE,WAAQ;AACR,cAAW;AACX,WAAQ;AACR,kBAAe;AACf,iBAAc;AAAA,EACZ,MAAQ;AAAA,EACR,KAAO;AACT;AACA,eAAY;AACZ,WAAQ;AACR,eAAY;AAAA,EACV;AAAA,EACA;AAAA,EAC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