tenjin-cli 0.1.0-alpha.30 → 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 (280) hide show
  1. package/README.md +65 -116
  2. package/dist/{_esm-CE7KNONL.js → _esm-RLLC72MS.js} +127 -131
  3. package/dist/alive-MROUMFH3.js +38 -0
  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-3623BLPV.js +184 -0
  11. package/dist/chunk-3623BLPV.js.map +1 -0
  12. package/dist/chunk-3AIHRXKO.js +72 -0
  13. package/dist/chunk-3AIHRXKO.js.map +1 -0
  14. package/dist/chunk-3DIL66VX.js +120 -0
  15. package/dist/chunk-3DIL66VX.js.map +1 -0
  16. package/dist/{chunk-S4SAZ7OD.js → chunk-3FMZGI7I.js} +12 -2
  17. package/dist/{chunk-S4SAZ7OD.js.map → chunk-3FMZGI7I.js.map} +1 -1
  18. package/dist/chunk-3UCIG4TG.js +65 -0
  19. package/dist/chunk-3UCIG4TG.js.map +1 -0
  20. package/dist/{chunk-LFZJM56J.js → chunk-445VQTVM.js} +3 -3
  21. package/dist/{chunk-A36LQPHV.js → chunk-4LMUQMBH.js} +1 -1
  22. package/dist/{chunk-A36LQPHV.js.map → chunk-4LMUQMBH.js.map} +1 -1
  23. package/dist/{chunk-RAULEAZ6.js → chunk-4USCZ2NI.js} +3 -3
  24. package/dist/chunk-62KNUYWD.js +111 -0
  25. package/dist/chunk-62KNUYWD.js.map +1 -0
  26. package/dist/{chunk-POUWHWID.js → chunk-6CMM6YCB.js} +3 -3
  27. package/dist/{chunk-POUWHWID.js.map → chunk-6CMM6YCB.js.map} +1 -1
  28. package/dist/chunk-7WEQQJLG.js +68 -0
  29. package/dist/chunk-7WEQQJLG.js.map +1 -0
  30. package/dist/{chunk-3O2BQIF6.js → chunk-AD226HDR.js} +344 -534
  31. package/dist/chunk-AD226HDR.js.map +1 -0
  32. package/dist/chunk-ADV4LDTB.js +106 -0
  33. package/dist/chunk-ADV4LDTB.js.map +1 -0
  34. package/dist/{chunk-AWFUPKTM.js → chunk-AV5NZMYO.js} +15 -7
  35. package/dist/{chunk-AWFUPKTM.js.map → chunk-AV5NZMYO.js.map} +1 -1
  36. package/dist/chunk-B7EM4GGF.js +198 -0
  37. package/dist/chunk-B7EM4GGF.js.map +1 -0
  38. package/dist/chunk-BFDQ4WNW.js +119 -0
  39. package/dist/chunk-BFDQ4WNW.js.map +1 -0
  40. package/dist/{chunk-OSYTBCUC.js → chunk-BI673VEJ.js} +531 -503
  41. package/dist/chunk-BI673VEJ.js.map +1 -0
  42. package/dist/chunk-CEXSOI5R.js +808 -0
  43. package/dist/chunk-CEXSOI5R.js.map +1 -0
  44. package/dist/{chunk-OK2TDZQU.js → chunk-CISYM4EO.js} +9 -7
  45. package/dist/chunk-CISYM4EO.js.map +1 -0
  46. package/dist/{chunk-VFMQTSXG.js → chunk-D3ZURCG7.js} +3 -3
  47. package/dist/chunk-D5TOQSO4.js +474 -0
  48. package/dist/chunk-D5TOQSO4.js.map +1 -0
  49. package/dist/{chunk-P7LABKCW.js → chunk-DOQGNFHM.js} +33 -2
  50. package/dist/{chunk-P7LABKCW.js.map → chunk-DOQGNFHM.js.map} +1 -1
  51. package/dist/{chunk-QUVVWYJW.js → chunk-DRDUIZIA.js} +11 -9
  52. package/dist/{chunk-QUVVWYJW.js.map → chunk-DRDUIZIA.js.map} +1 -1
  53. package/dist/{chunk-O2FRQ2L2.js → chunk-DW4YTVR3.js} +5 -65
  54. package/dist/chunk-DW4YTVR3.js.map +1 -0
  55. package/dist/chunk-E7LGOMH6.js +449 -0
  56. package/dist/chunk-E7LGOMH6.js.map +1 -0
  57. package/dist/chunk-E7SW44LM.js +138 -0
  58. package/dist/chunk-E7SW44LM.js.map +1 -0
  59. package/dist/chunk-EDJWHDDL.js +33 -0
  60. package/dist/chunk-EDJWHDDL.js.map +1 -0
  61. package/dist/chunk-F3ED5WTR.js +13 -0
  62. package/dist/chunk-F3ED5WTR.js.map +1 -0
  63. package/dist/chunk-G75OPGAK.js +111 -0
  64. package/dist/chunk-G75OPGAK.js.map +1 -0
  65. package/dist/{chunk-YFQOA5AU.js → chunk-GAKUQHKA.js} +13 -17
  66. package/dist/{chunk-YFQOA5AU.js.map → chunk-GAKUQHKA.js.map} +1 -1
  67. package/dist/{chunk-PAYV4XUA.js → chunk-HDPUXS3Z.js} +20 -49
  68. package/dist/chunk-HDPUXS3Z.js.map +1 -0
  69. package/dist/{chunk-ORWL5BSN.js → chunk-HGZEPQUT.js} +2 -2
  70. package/dist/{chunk-HPWO4O6S.js → chunk-HREHWL32.js} +4 -4
  71. package/dist/{chunk-HPWO4O6S.js.map → chunk-HREHWL32.js.map} +1 -1
  72. package/dist/{chunk-VZGAONSJ.js → chunk-I5TDIUKM.js} +16 -35
  73. package/dist/chunk-I5TDIUKM.js.map +1 -0
  74. package/dist/{chunk-7QKHZQKW.js → chunk-IADZOXKN.js} +39 -6
  75. package/dist/chunk-IADZOXKN.js.map +1 -0
  76. package/dist/{chunk-U6YQ6FRI.js → chunk-IDTRSAHE.js} +32 -12
  77. package/dist/chunk-IDTRSAHE.js.map +1 -0
  78. package/dist/{chunk-SPAVAYSW.js → chunk-JEVQ5LKO.js} +7 -5
  79. package/dist/{chunk-SPAVAYSW.js.map → chunk-JEVQ5LKO.js.map} +1 -1
  80. package/dist/{chunk-EBVIKMCH.js → chunk-JKKAIPTU.js} +2 -2
  81. package/dist/chunk-JNJWBTU2.js +3497 -0
  82. package/dist/chunk-JNJWBTU2.js.map +1 -0
  83. package/dist/{chunk-TTBKWWTV.js → chunk-JRZBBPO6.js} +390 -146
  84. package/dist/chunk-JRZBBPO6.js.map +1 -0
  85. package/dist/{chunk-WVUSXNIE.js → chunk-MPZUYCAP.js} +9 -2
  86. package/dist/{chunk-WVUSXNIE.js.map → chunk-MPZUYCAP.js.map} +1 -1
  87. package/dist/{chunk-SJLTEINJ.js → chunk-OJNTCYQQ.js} +17 -1
  88. package/dist/chunk-OJNTCYQQ.js.map +1 -0
  89. package/dist/{chunk-IOODYAXL.js → chunk-OTWLERSW.js} +25 -6
  90. package/dist/chunk-OTWLERSW.js.map +1 -0
  91. package/dist/{chunk-AWQPGIR6.js → chunk-PJNENX2A.js} +1535 -422
  92. package/dist/chunk-PJNENX2A.js.map +1 -0
  93. package/dist/{chunk-KHE6L6TD.js → chunk-PKHI276N.js} +97 -11
  94. package/dist/chunk-PKHI276N.js.map +1 -0
  95. package/dist/{chunk-YHKXNYTB.js → chunk-QF3LSMGS.js} +2 -2
  96. package/dist/chunk-QXP3Z3JN.js +131 -0
  97. package/dist/chunk-QXP3Z3JN.js.map +1 -0
  98. package/dist/{chunk-XZKD7DIF.js → chunk-RL5UUDT4.js} +3 -3
  99. package/dist/{chunk-XZKD7DIF.js.map → chunk-RL5UUDT4.js.map} +1 -1
  100. package/dist/chunk-SFASB5FL.js +69 -0
  101. package/dist/chunk-SFASB5FL.js.map +1 -0
  102. package/dist/{chunk-WO5BJNIB.js → chunk-SNNSAGMT.js} +7273 -2741
  103. package/dist/chunk-SNNSAGMT.js.map +1 -0
  104. package/dist/{chunk-NZIP4PA2.js → chunk-SO3XRZPX.js} +3 -3
  105. package/dist/chunk-SYOS5CAC.js +176 -0
  106. package/dist/chunk-SYOS5CAC.js.map +1 -0
  107. package/dist/chunk-TAW4UFFF.js +293 -0
  108. package/dist/chunk-TAW4UFFF.js.map +1 -0
  109. package/dist/chunk-TF5HCP33.js +271 -0
  110. package/dist/chunk-TF5HCP33.js.map +1 -0
  111. package/dist/{chunk-AKWGE6JQ.js → chunk-UUGOUOVT.js} +37 -2
  112. package/dist/chunk-UUGOUOVT.js.map +1 -0
  113. package/dist/{chunk-AEG2PXBP.js → chunk-V2LQLN5H.js} +7 -7
  114. package/dist/{chunk-KYFZTGMC.js → chunk-VJUVFZ2D.js} +5 -3
  115. package/dist/{chunk-KYFZTGMC.js.map → chunk-VJUVFZ2D.js.map} +1 -1
  116. package/dist/{chunk-JMM6YE7J.js → chunk-VOZA6O7K.js} +708 -709
  117. package/dist/chunk-VOZA6O7K.js.map +1 -0
  118. package/dist/{chunk-5LJCEMFD.js → chunk-VUGQTZ2L.js} +209 -77
  119. package/dist/chunk-VUGQTZ2L.js.map +1 -0
  120. package/dist/chunk-WOM257PW.js +393 -0
  121. package/dist/chunk-WOM257PW.js.map +1 -0
  122. package/dist/chunk-WYXUQGOL.js +191 -0
  123. package/dist/chunk-WYXUQGOL.js.map +1 -0
  124. package/dist/chunk-X5ZBP3IY.js +97 -0
  125. package/dist/chunk-X5ZBP3IY.js.map +1 -0
  126. package/dist/chunk-XQJXNMSB.js +23 -0
  127. package/dist/chunk-XQJXNMSB.js.map +1 -0
  128. package/dist/chunk-Y527D4TV.js +56 -0
  129. package/dist/chunk-Y527D4TV.js.map +1 -0
  130. package/dist/{chunk-VUFAK2LW.js → chunk-YUY4SAGM.js} +17 -2
  131. package/dist/chunk-YUY4SAGM.js.map +1 -0
  132. package/dist/clack-EZ7TDWQU.js +19 -0
  133. package/dist/claude-cli-2YKABJJZ.js +31 -0
  134. package/dist/{cli-O5SN7ZJ4.js → cli-FB4LOA5A.js} +221 -68
  135. package/dist/{cli-O5SN7ZJ4.js.map → cli-FB4LOA5A.js.map} +1 -1
  136. package/dist/codex-event-TYVES3UX.js +16 -0
  137. package/dist/codex-host-WW4H2SKT.js +29 -0
  138. package/dist/codex-install-2C623HPW.js +393 -0
  139. package/dist/codex-install-2C623HPW.js.map +1 -0
  140. package/dist/{config-OJQI27LT.js → config-HOVJFEKD.js} +25 -15
  141. package/dist/doctor-NKU4V5OV.js +1312 -0
  142. package/dist/doctor-NKU4V5OV.js.map +1 -0
  143. package/dist/{env-proxy-XL4P73MZ.js → env-proxy-R6ZMLQTT.js} +6 -2
  144. package/dist/{ethersCompat-Df4a6QIZ-THAVUGIJ.js → ethersCompat-Df4a6QIZ-X6YZWAML.js} +3 -3
  145. package/dist/{fund-WEV6DMTD.js → fund-WEBHTZGN.js} +38 -30
  146. package/dist/{fund-WEV6DMTD.js.map → fund-WEBHTZGN.js.map} +1 -1
  147. package/dist/hook-command-ZA2PNKS6.js +44 -0
  148. package/dist/hosts/claude/.claude-plugin/marketplace.json +2 -2
  149. package/dist/hosts/claude/tenjin/.claude-plugin/plugin.json +3 -2
  150. package/dist/hosts/claude/tenjin/hooks/hooks.json +4 -1
  151. package/dist/hosts/claude/tenjin/hooks/register.tsx +589 -0
  152. package/dist/hosts/claude/tenjin/skills/tenjin-pay/SKILL.md +82 -0
  153. package/dist/hosts/claude/tenjin/types/index.d.ts +41 -0
  154. package/dist/hosts/codex/.agents/plugins/marketplace.json +20 -0
  155. package/dist/hosts/codex/tenjin/.codex-plugin/plugin.json +16 -0
  156. package/dist/hosts/codex/tenjin/.mcp.json +15 -0
  157. package/dist/hosts/codex/tenjin/hooks/hooks.json +98 -0
  158. package/dist/hosts-AV5MHBAU.js +38 -0
  159. package/dist/index.js +28 -8
  160. package/dist/index.js.map +1 -1
  161. package/dist/install-PT4EZS4R.js +100 -0
  162. package/dist/{install-identity-WHPNMNMQ.js → install-identity-5A4OE6YC.js} +13 -8
  163. package/dist/install-wallet-SAAPKB73.js +281 -0
  164. package/dist/install-wallet-SAAPKB73.js.map +1 -0
  165. package/dist/{mcp-QML7ZMPH.js → mcp-HAWKCTPQ.js} +909 -208
  166. package/dist/mcp-HAWKCTPQ.js.map +1 -0
  167. package/dist/{mine.wasm-6PIT3DK6.js → mine.wasm-QFAHIFPY.js} +2 -2
  168. package/dist/{mine.wasm-6PIT3DK6.js.map → mine.wasm-QFAHIFPY.js.map} +1 -1
  169. package/dist/{package-LGKYOEPV.js → package-SR2WB6MK.js} +4 -2
  170. package/dist/passphrase-IFTDS3CU.js +44 -0
  171. package/dist/{paths-POPTXJO6.js → paths-XCSAKISU.js} +10 -2
  172. package/dist/pay-OXC3WKYV.js +55 -0
  173. package/dist/pay-OXC3WKYV.js.map +1 -0
  174. package/dist/{payments-C44QUFXU.js → payments-3KHMP2MG.js} +18 -13
  175. package/dist/{payments-C44QUFXU.js.map → payments-3KHMP2MG.js.map} +1 -1
  176. package/dist/plugin-registration-N3GRIZVM.js +67 -0
  177. package/dist/plugin-registration-N3GRIZVM.js.map +1 -0
  178. package/dist/{redact-6W23GGJC.js → redact-D7ASVWKL.js} +2 -2
  179. package/dist/redact-D7ASVWKL.js.map +1 -0
  180. package/dist/runtime-UVNUA3AS.js +1203 -0
  181. package/dist/runtime-UVNUA3AS.js.map +1 -0
  182. package/dist/runtime-fetch-EKFRNR6Z.js +20 -0
  183. package/dist/runtime-fetch-EKFRNR6Z.js.map +1 -0
  184. package/dist/runtime-layout-BDWZG2TQ.js +25 -0
  185. package/dist/runtime-layout-BDWZG2TQ.js.map +1 -0
  186. package/dist/{send-KVJX4XIR.js → send-HMKJLT34.js} +26 -18
  187. package/dist/{send-KVJX4XIR.js.map → send-HMKJLT34.js.map} +1 -1
  188. package/dist/{status-S7C3WMSH.js → status-RWXIIWYS.js} +57 -22
  189. package/dist/status-RWXIIWYS.js.map +1 -0
  190. package/dist/{status-line-YR2T5HC4.js → status-line-77XYZP7E.js} +13 -8
  191. package/dist/{status-line-YR2T5HC4.js.map → status-line-77XYZP7E.js.map} +1 -1
  192. package/dist/uninstall-D5G67UJH.js +480 -0
  193. package/dist/uninstall-D5G67UJH.js.map +1 -0
  194. package/dist/update-LRNOEGSB.js +53 -0
  195. package/dist/update-LRNOEGSB.js.map +1 -0
  196. package/dist/{usdc-JK4RRFFQ.js → usdc-D6X7EIQ2.js} +7 -8
  197. package/dist/usdc-D6X7EIQ2.js.map +1 -0
  198. package/dist/{viemAdapter-By13KInL-X2VY6CY3.js → viemAdapter-By13KInL-RL742ETX.js} +3 -3
  199. package/dist/viemAdapter-By13KInL-RL742ETX.js.map +1 -0
  200. package/dist/wallet-XFYC27BR.js +55 -0
  201. package/dist/wallet-XFYC27BR.js.map +1 -0
  202. package/dist/wallet-kdf-worker.mjs +8 -8
  203. package/docs/agent-permissions.md +56 -22
  204. package/docs/safety-model.md +1 -1
  205. package/docs/troubleshooting.md +72 -1
  206. package/package.json +14 -1
  207. package/dist/alive-3J3CHOQP.js +0 -21
  208. package/dist/ccip-NLCSCHKI.js +0 -19
  209. package/dist/chunk-3O2BQIF6.js.map +0 -1
  210. package/dist/chunk-5IEP5EGE.js +0 -5332
  211. package/dist/chunk-5IEP5EGE.js.map +0 -1
  212. package/dist/chunk-5LJCEMFD.js.map +0 -1
  213. package/dist/chunk-6W5GYG3W.js +0 -128
  214. package/dist/chunk-6W5GYG3W.js.map +0 -1
  215. package/dist/chunk-7EKYXMUO.js +0 -7536
  216. package/dist/chunk-7EKYXMUO.js.map +0 -1
  217. package/dist/chunk-7QKHZQKW.js.map +0 -1
  218. package/dist/chunk-AKWGE6JQ.js.map +0 -1
  219. package/dist/chunk-AWQPGIR6.js.map +0 -1
  220. package/dist/chunk-EGELTSPU.js +0 -2865
  221. package/dist/chunk-EGELTSPU.js.map +0 -1
  222. package/dist/chunk-EL56RW2J.js +0 -7611
  223. package/dist/chunk-EL56RW2J.js.map +0 -1
  224. package/dist/chunk-HE2MS4QO.js +0 -256
  225. package/dist/chunk-HE2MS4QO.js.map +0 -1
  226. package/dist/chunk-IOODYAXL.js.map +0 -1
  227. package/dist/chunk-JMM6YE7J.js.map +0 -1
  228. package/dist/chunk-KHE6L6TD.js.map +0 -1
  229. package/dist/chunk-N35E6CM2.js +0 -1185
  230. package/dist/chunk-N35E6CM2.js.map +0 -1
  231. package/dist/chunk-O2FRQ2L2.js.map +0 -1
  232. package/dist/chunk-OK2TDZQU.js.map +0 -1
  233. package/dist/chunk-OSYTBCUC.js.map +0 -1
  234. package/dist/chunk-PAYV4XUA.js.map +0 -1
  235. package/dist/chunk-SJLTEINJ.js.map +0 -1
  236. package/dist/chunk-TTBKWWTV.js.map +0 -1
  237. package/dist/chunk-TTNESUPQ.js.map +0 -1
  238. package/dist/chunk-U6YQ6FRI.js.map +0 -1
  239. package/dist/chunk-VUFAK2LW.js.map +0 -1
  240. package/dist/chunk-VZGAONSJ.js.map +0 -1
  241. package/dist/chunk-WO5BJNIB.js.map +0 -1
  242. package/dist/doctor-IQQJHGGM.js +0 -590
  243. package/dist/doctor-IQQJHGGM.js.map +0 -1
  244. package/dist/hook-command-D2P3ILRV.js +0 -32
  245. package/dist/install-TUCRF32I.js +0 -60
  246. package/dist/install-wallet-MA27FTQ5.js +0 -113
  247. package/dist/install-wallet-MA27FTQ5.js.map +0 -1
  248. package/dist/mcp-QML7ZMPH.js.map +0 -1
  249. package/dist/pay-2C2UBBXJ.js +0 -51
  250. package/dist/status-S7C3WMSH.js.map +0 -1
  251. package/dist/uninstall-HY6LKIIT.js +0 -149
  252. package/dist/uninstall-HY6LKIIT.js.map +0 -1
  253. package/dist/update-OJV22LR3.js +0 -36
  254. package/dist/wallet-PD2IMZDU.js +0 -39
  255. /package/dist/{_esm-CE7KNONL.js.map → _esm-RLLC72MS.js.map} +0 -0
  256. /package/dist/{alive-3J3CHOQP.js.map → alive-MROUMFH3.js.map} +0 -0
  257. /package/dist/{ccip-7RMRLAGV.js.map → auto-update-OPWMRZLS.js.map} +0 -0
  258. /package/dist/{ccip-NLCSCHKI.js.map → ccip-DHDFKTQV.js.map} +0 -0
  259. /package/dist/{chunk-LFZJM56J.js.map → chunk-445VQTVM.js.map} +0 -0
  260. /package/dist/{chunk-RAULEAZ6.js.map → chunk-4USCZ2NI.js.map} +0 -0
  261. /package/dist/{chunk-VFMQTSXG.js.map → chunk-D3ZURCG7.js.map} +0 -0
  262. /package/dist/{chunk-ORWL5BSN.js.map → chunk-HGZEPQUT.js.map} +0 -0
  263. /package/dist/{chunk-EBVIKMCH.js.map → chunk-JKKAIPTU.js.map} +0 -0
  264. /package/dist/{chunk-YHKXNYTB.js.map → chunk-QF3LSMGS.js.map} +0 -0
  265. /package/dist/{chunk-NZIP4PA2.js.map → chunk-SO3XRZPX.js.map} +0 -0
  266. /package/dist/{chunk-AEG2PXBP.js.map → chunk-V2LQLN5H.js.map} +0 -0
  267. /package/dist/{config-OJQI27LT.js.map → clack-EZ7TDWQU.js.map} +0 -0
  268. /package/dist/{env-proxy-XL4P73MZ.js.map → claude-cli-2YKABJJZ.js.map} +0 -0
  269. /package/dist/{ethersCompat-Df4a6QIZ-THAVUGIJ.js.map → codex-event-TYVES3UX.js.map} +0 -0
  270. /package/dist/{hook-command-D2P3ILRV.js.map → codex-host-WW4H2SKT.js.map} +0 -0
  271. /package/dist/{install-TUCRF32I.js.map → config-HOVJFEKD.js.map} +0 -0
  272. /package/dist/{install-identity-WHPNMNMQ.js.map → env-proxy-R6ZMLQTT.js.map} +0 -0
  273. /package/dist/{package-LGKYOEPV.js.map → ethersCompat-Df4a6QIZ-X6YZWAML.js.map} +0 -0
  274. /package/dist/{paths-POPTXJO6.js.map → hook-command-ZA2PNKS6.js.map} +0 -0
  275. /package/dist/{pay-2C2UBBXJ.js.map → hosts-AV5MHBAU.js.map} +0 -0
  276. /package/dist/{redact-6W23GGJC.js.map → install-PT4EZS4R.js.map} +0 -0
  277. /package/dist/{update-OJV22LR3.js.map → install-identity-5A4OE6YC.js.map} +0 -0
  278. /package/dist/{usdc-JK4RRFFQ.js.map → package-SR2WB6MK.js.map} +0 -0
  279. /package/dist/{viemAdapter-By13KInL-X2VY6CY3.js.map → passphrase-IFTDS3CU.js.map} +0 -0
  280. /package/dist/{wallet-PD2IMZDU.js.map → paths-XCSAKISU.js.map} +0 -0
@@ -0,0 +1,393 @@
1
+ import { createRequire as __tenjinCreateRequire } from 'node:module'; const require = __tenjinCreateRequire(import.meta.url);
2
+ import {
3
+ WALLET_CLASS,
4
+ sessionStartMessage,
5
+ walletClearedSentence
6
+ } from "./chunk-BFDQ4WNW.js";
7
+ import {
8
+ readPassphraseRecord
9
+ } from "./chunk-3AIHRXKO.js";
10
+ import {
11
+ PRIVATE_KEY_RE
12
+ } from "./chunk-X5ZBP3IY.js";
13
+ import {
14
+ hasCode
15
+ } from "./chunk-2I4QTOLB.js";
16
+ import {
17
+ DEFAULT_MAX_AUTO_SPEND
18
+ } from "./chunk-2GNOFONN.js";
19
+ import {
20
+ DEFAULT_RPC_URL,
21
+ rememberingBalanceReader
22
+ } from "./chunk-DW4YTVR3.js";
23
+ import {
24
+ writeFileAtomic
25
+ } from "./chunk-7WEQQJLG.js";
26
+ import {
27
+ configPath,
28
+ passphraseFilePathFor,
29
+ passphraseRecordPath,
30
+ walletPath
31
+ } from "./chunk-OJNTCYQQ.js";
32
+
33
+ // src/router/alive.ts
34
+ import { createHash as createHash2 } from "node:crypto";
35
+ import { mkdir as mkdir2, readdir as readdir2, readFile as readFile3, rm as rm2, rmdir, stat as stat2, writeFile } from "node:fs/promises";
36
+ import { join as join2 } from "node:path";
37
+
38
+ // src/lib/wallet-facts.ts
39
+ import { readFile, stat } from "node:fs/promises";
40
+ var ADDRESS_RE = /^0x[0-9a-fA-F]{40}$/;
41
+ async function readWalletFacts(dataDir, env) {
42
+ const key = env.TENJIN_WALLET_KEY?.trim() ?? "";
43
+ const envKey = key.length === 0 ? "absent" : PRIVATE_KEY_RE.test(key) ? "valid" : "malformed";
44
+ const passphrase = env.TENJIN_WALLET_PASSPHRASE;
45
+ const envPassphraseSet = passphrase !== void 0 && passphrase.length > 0;
46
+ const { walletFile, address } = await readWalletAddress(dataDir);
47
+ const [walletMtimeMs, sidecarMtimeMs] = await Promise.all([
48
+ mtimeOf(walletPath(dataDir)),
49
+ mtimeOf(passphraseRecordPath(dataDir))
50
+ ]);
51
+ let passphraseStore = null;
52
+ let passphraseFileMissing = false;
53
+ if (address !== null) {
54
+ passphraseStore = (await readPassphraseRecord(dataDir, address).catch(() => null))?.store ?? null;
55
+ if (passphraseStore === "file") {
56
+ passphraseFileMissing = await stat(passphraseFilePathFor(address.toLowerCase(), dataDir)).then(() => false).catch((err) => hasCode(err, "ENOENT"));
57
+ }
58
+ }
59
+ return {
60
+ envKey,
61
+ walletFile,
62
+ address,
63
+ envPassphraseSet,
64
+ passphraseStore,
65
+ passphraseFileMissing,
66
+ walletMtimeMs,
67
+ sidecarMtimeMs
68
+ };
69
+ }
70
+ function unlockStamp(f) {
71
+ return `${f.walletMtimeMs}:${f.sidecarMtimeMs}`;
72
+ }
73
+ async function readWalletAddress(dataDir) {
74
+ let text;
75
+ try {
76
+ text = await readFile(walletPath(dataDir), "utf8");
77
+ } catch (err) {
78
+ return { walletFile: hasCode(err, "ENOENT") ? "absent" : "unparsable", address: null };
79
+ }
80
+ try {
81
+ const record = JSON.parse(text);
82
+ const address = record?.address;
83
+ return typeof address === "string" && ADDRESS_RE.test(address) ? { walletFile: "present", address } : { walletFile: "unparsable", address: null };
84
+ } catch {
85
+ return { walletFile: "unparsable", address: null };
86
+ }
87
+ }
88
+ async function mtimeOf(path) {
89
+ try {
90
+ return (await stat(path)).mtimeMs;
91
+ } catch {
92
+ return null;
93
+ }
94
+ }
95
+
96
+ // src/router/notice-markers.ts
97
+ import { createHash, randomBytes } from "node:crypto";
98
+ import { mkdir, open, readFile as readFile2, readdir, rename, rm } from "node:fs/promises";
99
+ import { basename, dirname, join } from "node:path";
100
+ var NOTICE_KEEP_MS = 7 * 864e5;
101
+ var CLEARED = "cleared";
102
+ var UNLOCK_CLASS = [
103
+ "no_wallet",
104
+ "wallet_corrupt",
105
+ "env_key_invalid",
106
+ "passphrase_missing",
107
+ "passphrase_wrong",
108
+ "env_passphrase_wrong",
109
+ "keychain_locked",
110
+ "unlock_timeout",
111
+ "wallet_locked"
112
+ ];
113
+ function noticesDir(dataDir) {
114
+ return join(dataDir, "router", "notices");
115
+ }
116
+ function sessionHash(sessionId) {
117
+ return createHash("sha256").update(sessionId).digest("hex").slice(0, 32);
118
+ }
119
+ function reasonMarker(dataDir, sessionId, why) {
120
+ const reason = createHash("sha256").update(why).digest("hex").slice(0, 8);
121
+ return join(noticesDir(dataDir), `${sessionHash(sessionId)}-${reason}`);
122
+ }
123
+ function currentPath(dataDir, sessionId) {
124
+ return join(noticesDir(dataDir), `${sessionHash(sessionId)}.current`);
125
+ }
126
+ async function writeCurrent(dataDir, sessionId, now, why) {
127
+ await writeFileAtomic(currentPath(dataDir, sessionId), `${now}
128
+ ${why}`, {
129
+ mode: 384,
130
+ dirMode: 448
131
+ });
132
+ }
133
+ async function noticeFor(dataDir, sessionId, why, now) {
134
+ const created = await createExclusive(reasonMarker(dataDir, sessionId, why), String(now));
135
+ if (!created) return "quiet";
136
+ await writeCurrent(dataDir, sessionId, now, why);
137
+ await pruneNotices(dataDir, now);
138
+ return "tell";
139
+ }
140
+ async function noticeCleared(dataDir, sessionId, now) {
141
+ const text = await readFile2(currentPath(dataDir, sessionId), "utf8").catch(() => null);
142
+ if (text === null) return null;
143
+ const why = text.split("\n")[1] ?? "";
144
+ if (!WALLET_CLASS.has(why)) return null;
145
+ const marker = reasonMarker(dataDir, sessionId, why);
146
+ const claimed = join(
147
+ dirname(marker),
148
+ `.${basename(marker)}.${randomBytes(6).toString("hex")}.claimed`
149
+ );
150
+ try {
151
+ await rename(marker, claimed);
152
+ } catch {
153
+ return null;
154
+ }
155
+ await rm(claimed, { force: true }).catch(() => void 0);
156
+ await writeCurrent(dataDir, sessionId, now, CLEARED);
157
+ return walletClearedSentence(why);
158
+ }
159
+ async function settleCurrent(dataDir, sessionId, now) {
160
+ await writeCurrent(dataDir, sessionId, now, CLEARED);
161
+ await Promise.all(
162
+ UNLOCK_CLASS.map(
163
+ (why) => rm(reasonMarker(dataDir, sessionId, why), { force: true }).catch(() => void 0)
164
+ )
165
+ );
166
+ }
167
+ async function pruneNotices(dataDir, now) {
168
+ const dir = noticesDir(dataDir);
169
+ for (const entry of await readdir(dir).catch(() => [])) {
170
+ if (entry.startsWith(".")) continue;
171
+ const path = join(dir, entry);
172
+ const text = await readFile2(path, "utf8").catch(() => "NaN");
173
+ if (text.length === 0) continue;
174
+ const at = Number(text.split("\n")[0]);
175
+ if (!Number.isFinite(at) || now - at > NOTICE_KEEP_MS) await rm(path, { force: true });
176
+ }
177
+ }
178
+ async function createExclusive(path, body) {
179
+ try {
180
+ await mkdir(join(path, ".."), { recursive: true, mode: 448 });
181
+ const handle = await open(path, "wx", 384);
182
+ try {
183
+ await handle.writeFile(body);
184
+ } finally {
185
+ await handle.close();
186
+ }
187
+ return true;
188
+ } catch (err) {
189
+ if (hasCode(err, "EEXIST")) return false;
190
+ throw err;
191
+ }
192
+ }
193
+
194
+ // src/router/alive.ts
195
+ var MARKER_TTL_MS = 7 * 24 * 60 * 60 * 1e3;
196
+ var STAMP = "plugin-loaded.json";
197
+ var MAX_SESSION_ID = 200;
198
+ function aliveDir(dataDir) {
199
+ return join2(dataDir, "alive");
200
+ }
201
+ function markerName(sessionId) {
202
+ return createHash2("sha256").update(sessionId).digest("hex").slice(0, 32);
203
+ }
204
+ function sessionIdOf(event) {
205
+ if (event === null || typeof event !== "object") return null;
206
+ const id = event.session_id;
207
+ return typeof id === "string" && id.length > 0 && id.length <= MAX_SESSION_ID ? id : null;
208
+ }
209
+ async function runAliveHook(event, opts) {
210
+ const sessionId = sessionIdOf(event);
211
+ const now = opts.now ?? Date.now();
212
+ const dir = aliveDir(opts.dataDir);
213
+ try {
214
+ await mkdir2(dir, { recursive: true, mode: 448 });
215
+ if (sessionId !== null) {
216
+ await writeFile(join2(dir, markerName(sessionId)), `${new Date(now).toISOString()}
217
+ `);
218
+ }
219
+ const stamp = { at: new Date(now).toISOString(), version: opts.version };
220
+ await writeFile(join2(dir, STAMP), `${JSON.stringify(stamp)}
221
+ `);
222
+ await pruneMarkers(dir, now);
223
+ } catch {
224
+ }
225
+ try {
226
+ const reason = await walletAtStart(opts.dataDir, opts.env ?? process.env);
227
+ if (reason === null) return null;
228
+ const { systemMessage, additionalContext } = sessionStartMessage(reason);
229
+ if (sessionId !== null) {
230
+ await noticeFor(opts.dataDir, sessionId, reason, now).catch(() => void 0);
231
+ }
232
+ return {
233
+ systemMessage,
234
+ hookSpecificOutput: { hookEventName: "SessionStart", additionalContext }
235
+ };
236
+ } catch {
237
+ return null;
238
+ }
239
+ }
240
+ async function walletAtStart(dataDir, env) {
241
+ const facts = await readWalletFacts(dataDir, env);
242
+ if (facts.envKey !== "absent") return null;
243
+ if (facts.walletFile === "absent") return null;
244
+ if (facts.walletFile === "unparsable") return "wallet_corrupt";
245
+ if (facts.passphraseFileMissing && !facts.envPassphraseSet) return "passphrase_missing";
246
+ return null;
247
+ }
248
+ async function pruneMarkers(dir, now) {
249
+ for (const name of await readdir2(dir).catch(() => [])) {
250
+ if (!/^[0-9a-f]{32}$/.test(name)) continue;
251
+ const path = join2(dir, name);
252
+ const s = await stat2(path).catch(() => null);
253
+ if (s !== null && now - s.mtimeMs > MARKER_TTL_MS) await rm2(path, { force: true });
254
+ }
255
+ }
256
+ async function sessionServedByPlugin(dataDir, event) {
257
+ const sessionId = sessionIdOf(event);
258
+ if (sessionId === null) return false;
259
+ return await stat2(join2(aliveDir(dataDir), markerName(sessionId))).catch(() => null) !== null;
260
+ }
261
+ async function readAliveStamp(dataDir) {
262
+ try {
263
+ const parsed = JSON.parse(await readFile3(join2(aliveDir(dataDir), STAMP), "utf8"));
264
+ if (parsed === null || typeof parsed !== "object") return null;
265
+ const { at, version } = parsed;
266
+ return typeof at === "string" && typeof version === "string" ? { at, version } : null;
267
+ } catch {
268
+ return null;
269
+ }
270
+ }
271
+ async function removeAliveState(dataDir) {
272
+ const dir = aliveDir(dataDir);
273
+ const existed = await stat2(dir).catch(() => null) !== null;
274
+ if (!existed) return false;
275
+ for (const name of await readdir2(dir).catch(() => [])) {
276
+ if (name === STAMP || /^[0-9a-f]{32}$/.test(name)) await rm2(join2(dir, name), { force: true });
277
+ }
278
+ await rmdir(dir).catch(() => void 0);
279
+ return true;
280
+ }
281
+ var WALLET_READ_MS = 2e3;
282
+ async function walletNotice(dataDir, opts = {}) {
283
+ const wallet = await readJson(walletPath(dataDir));
284
+ const address = typeof wallet?.address === "string" ? wallet.address : void 0;
285
+ if (address === void 0 || !/^0x[0-9a-fA-F]{40}$/.test(address)) return null;
286
+ const config = await readJson(configPath(dataDir));
287
+ const rpcUrl = typeof config?.rpcUrl === "string" ? config.rpcUrl : DEFAULT_RPC_URL;
288
+ const timeoutMs = opts.timeoutMs ?? WALLET_READ_MS;
289
+ const read = rememberingBalanceReader(dataDir, {
290
+ ...opts.read !== void 0 ? { read: opts.read } : {}
291
+ });
292
+ const balance = await read(address, rpcUrl, { timeoutMs });
293
+ if (balance === null) return null;
294
+ const cap = BigInt(
295
+ typeof config?.maxAutoSpend === "string" && /^\d{1,30}$/.test(config.maxAutoSpend) ? config.maxAutoSpend : DEFAULT_MAX_AUTO_SPEND
296
+ );
297
+ if (balance > 0n && balance >= cap) return null;
298
+ return `Tenjin balance: $${dollars(balance)}. Ask your agent to add funds to Tenjin.`;
299
+ }
300
+ function dollars(atomic) {
301
+ const fraction = (atomic % 1000000n).toString().padStart(6, "0").replace(/0+$/, "");
302
+ return `${atomic / 1000000n}.${fraction.padEnd(2, "0")}`;
303
+ }
304
+ async function readJson(path) {
305
+ try {
306
+ const value = JSON.parse(await readFile3(path, "utf8"));
307
+ return value !== null && typeof value === "object" ? value : null;
308
+ } catch {
309
+ return null;
310
+ }
311
+ }
312
+ async function aliveMain(opts) {
313
+ const raw = await (opts.readEvent ?? (() => readStdin(1e3)))().catch(() => "");
314
+ const answer = await runAliveHook(parseEvent(raw), {
315
+ dataDir: opts.dataDir,
316
+ version: opts.version,
317
+ ...opts.env !== void 0 ? { env: opts.env } : {}
318
+ });
319
+ const notice = answer === null ? await walletNotice(opts.dataDir).catch(() => null) : null;
320
+ const payload = answer ?? (notice !== null ? { systemMessage: notice } : null);
321
+ if (payload === null) return;
322
+ const out = opts.stdout ?? process.stdout;
323
+ await new Promise((resolve) => {
324
+ try {
325
+ out.write(`${JSON.stringify(payload)}
326
+ `, () => resolve());
327
+ } catch {
328
+ resolve();
329
+ }
330
+ });
331
+ }
332
+ function parseEvent(raw) {
333
+ try {
334
+ return JSON.parse(raw);
335
+ } catch {
336
+ return null;
337
+ }
338
+ }
339
+ function readStdin(timeoutMs) {
340
+ return new Promise((resolve, reject) => {
341
+ const chunks = [];
342
+ let size = 0;
343
+ const timer = setTimeout(() => reject(new Error("no harness event")), timeoutMs);
344
+ process.stdin.on("data", (chunk) => {
345
+ size += chunk.length;
346
+ if (size > 1e6) {
347
+ clearTimeout(timer);
348
+ reject(new Error("harness event too large"));
349
+ return;
350
+ }
351
+ chunks.push(chunk);
352
+ });
353
+ process.stdin.once("end", () => {
354
+ clearTimeout(timer);
355
+ resolve(Buffer.concat(chunks).toString("utf8"));
356
+ });
357
+ process.stdin.once("error", () => {
358
+ clearTimeout(timer);
359
+ reject(new Error("harness event unreadable"));
360
+ });
361
+ });
362
+ }
363
+ async function markSessionServed(dataDir, event) {
364
+ const sessionId = sessionIdOf(event);
365
+ if (sessionId === null) return;
366
+ const path = join2(aliveDir(dataDir), markerName(sessionId));
367
+ if (await stat2(path).catch(() => null) !== null) return;
368
+ try {
369
+ await mkdir2(aliveDir(dataDir), { recursive: true, mode: 448 });
370
+ await writeFile(path, `${(/* @__PURE__ */ new Date()).toISOString()}
371
+ `);
372
+ } catch {
373
+ }
374
+ }
375
+
376
+ export {
377
+ readWalletFacts,
378
+ unlockStamp,
379
+ noticeFor,
380
+ noticeCleared,
381
+ settleCurrent,
382
+ aliveDir,
383
+ runAliveHook,
384
+ walletAtStart,
385
+ sessionServedByPlugin,
386
+ readAliveStamp,
387
+ removeAliveState,
388
+ WALLET_READ_MS,
389
+ walletNotice,
390
+ aliveMain,
391
+ markSessionServed
392
+ };
393
+ //# sourceMappingURL=chunk-WOM257PW.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/router/alive.ts","../src/lib/wallet-facts.ts","../src/router/notice-markers.ts"],"sourcesContent":["import { createHash } from 'node:crypto';\nimport { mkdir, readdir, readFile, rm, rmdir, stat, writeFile } from 'node:fs/promises';\nimport { join } from 'node:path';\nimport { DEFAULT_MAX_AUTO_SPEND } from '../lib/config';\nimport { configPath, walletPath } from '../lib/paths';\nimport {\n DEFAULT_RPC_URL,\n readUsdcBalanceWithFallback,\n rememberingBalanceReader,\n} from '../lib/usdc-balance';\nimport { readWalletFacts } from '../lib/wallet-facts';\nimport { noticeFor } from './notice-markers';\nimport { sessionStartMessage } from './wallet-reasons';\n\n/**\n * THE PLUGIN SAYS IT IS HERE. While a machine carries both the plugin and the\n * settings install it replaces, every event would run two sets of routing legs\n * and offer the same lookup twice. The plugin's `SessionStart` entry runs\n * `tenjin hook alive` before any other event of the session, and it writes:\n *\n * - a per-session marker, which every leg a settings install launched checks\n * first, staying silent in a session the plugin serves;\n * - a per-machine stamp, the proof the guarded migration waits for: the plugin\n * has loaded in a real session on this machine at least once, so the\n * settings install can be removed without leaving the machine unrouted.\n *\n * Outside `progress/`, whose files are pruned after ten minutes. Markers are\n * pruned here after a week, which outlasts any session that still matters.\n *\n * SHIM: the per-session check goes on or after 2026-12-01, the first release\n * cut 30 or more days after the plugin PR 2 ships; the stamp stays for doctor.\n *\n * It also says, once, when the wallet's FILES already show it cannot sign in\n * this session ({@link walletAtStart}). That is a file fact, not a verdict:\n * `alive` never unlocks, never execs, never reads a keychain and never replays\n * what a router saw (Q4). Everything else waits for the router's first notice.\n */\n\nconst MARKER_TTL_MS = 7 * 24 * 60 * 60 * 1000;\nconst STAMP = 'plugin-loaded.json';\n/** A session id names a file only through its hash, so any string is safe. */\nconst MAX_SESSION_ID = 200;\n\nexport function aliveDir(dataDir: string): string {\n return join(dataDir, 'alive');\n}\n\nfunction markerName(sessionId: string): string {\n return createHash('sha256').update(sessionId).digest('hex').slice(0, 32);\n}\n\nfunction sessionIdOf(event: unknown): string | null {\n if (event === null || typeof event !== 'object') return null;\n const id = (event as { session_id?: unknown }).session_id;\n return typeof id === 'string' && id.length > 0 && id.length <= MAX_SESSION_ID ? id : null;\n}\n\nexport interface AliveStamp {\n at: string;\n /** The CLI version whose plugin loaded. */\n version: string;\n}\n\n/** What a `SessionStart` hook prints when the wallet cannot sign: one line for\n * the person, one for the model. */\nexport interface AliveAnswer {\n systemMessage: string;\n hookSpecificOutput: { hookEventName: 'SessionStart'; additionalContext: string };\n}\n\n/**\n * The `alive` leg: marker, stamp, prune, then the wallet's files. It prints\n * only when the wallet file is unreadable or the saved passphrase file is gone\n * (with TENJIN_WALLET_PASSPHRASE unset), because a `SessionStart` hook's stdout\n * is added to the session's context and nothing else there is definite before\n * a router has tried to unlock; everything else waits for the router's first\n * notice. The answer carries the person's fix in `systemMessage` and the\n * model's `agentFix` in `additionalContext` (B1), and the reason's notice\n * marker is written so the session's first prompt leg does not say it again.\n * ({@link aliveMain} adds the balance notice as JSON when there is no answer.)\n * It never fails the session: every error is swallowed, and gives null.\n */\nexport async function runAliveHook(\n event: unknown,\n opts: { dataDir: string; version: string; now?: number; env?: NodeJS.ProcessEnv },\n): Promise<AliveAnswer | null> {\n const sessionId = sessionIdOf(event);\n const now = opts.now ?? Date.now();\n const dir = aliveDir(opts.dataDir);\n try {\n await mkdir(dir, { recursive: true, mode: 0o700 });\n if (sessionId !== null) {\n await writeFile(join(dir, markerName(sessionId)), `${new Date(now).toISOString()}\\n`);\n }\n const stamp: AliveStamp = { at: new Date(now).toISOString(), version: opts.version };\n await writeFile(join(dir, STAMP), `${JSON.stringify(stamp)}\\n`);\n await pruneMarkers(dir, now);\n } catch {\n // A marker that could not be written costs only a duplicate offer.\n }\n try {\n const reason = await walletAtStart(opts.dataDir, opts.env ?? process.env);\n if (reason === null) return null;\n const { systemMessage, additionalContext } = sessionStartMessage(reason);\n if (sessionId !== null) {\n await noticeFor(opts.dataDir, sessionId, reason, now).catch(() => undefined);\n }\n return {\n systemMessage,\n hookSpecificOutput: { hookEventName: 'SessionStart', additionalContext },\n };\n } catch {\n return null;\n }\n}\n\n/**\n * WHAT THE FILES ALONE SAY AT SESSION START, and only what is definite (Q4).\n * Filesystem only: one wallet.json read, the sidecar read and a few stats; no\n * exec, no keychain, no scrypt, and never the router's unlock-state, so it\n * cannot repeat a verdict that has since changed. In order:\n *\n * - a TENJIN_WALLET_KEY (valid or not) shadows the file, and whether it works\n * is the router's to report: null;\n * - no wallet.json: null, never `no_wallet`, because the person may have\n * installed with `--no-wallet` on purpose;\n * - a wallet.json nothing can read: `wallet_corrupt`;\n * - the sidecar names the file store, its `.plain` file is gone, and\n * TENJIN_WALLET_PASSPHRASE is unset: `passphrase_missing`;\n * - anything else: null.\n */\nexport async function walletAtStart(\n dataDir: string,\n env: NodeJS.ProcessEnv,\n): Promise<'wallet_corrupt' | 'passphrase_missing' | null> {\n const facts = await readWalletFacts(dataDir, env);\n if (facts.envKey !== 'absent') return null;\n if (facts.walletFile === 'absent') return null;\n if (facts.walletFile === 'unparsable') return 'wallet_corrupt';\n if (facts.passphraseFileMissing && !facts.envPassphraseSet) return 'passphrase_missing';\n return null;\n}\n\nasync function pruneMarkers(dir: string, now: number): Promise<void> {\n for (const name of await readdir(dir).catch(() => [] as string[])) {\n if (!/^[0-9a-f]{32}$/.test(name)) continue;\n const path = join(dir, name);\n const s = await stat(path).catch(() => null);\n if (s !== null && now - s.mtimeMs > MARKER_TTL_MS) await rm(path, { force: true });\n }\n}\n\n/** Has the plugin's `alive` leg marked this session? False on any doubt. */\nexport async function sessionServedByPlugin(dataDir: string, event: unknown): Promise<boolean> {\n const sessionId = sessionIdOf(event);\n if (sessionId === null) return false;\n return (await stat(join(aliveDir(dataDir), markerName(sessionId))).catch(() => null)) !== null;\n}\n\n/** The machine's stamp, or null when the plugin has never loaded here. */\nexport async function readAliveStamp(dataDir: string): Promise<AliveStamp | null> {\n try {\n const parsed = JSON.parse(await readFile(join(aliveDir(dataDir), STAMP), 'utf8')) as unknown;\n if (parsed === null || typeof parsed !== 'object') return null;\n const { at, version } = parsed as { at?: unknown; version?: unknown };\n return typeof at === 'string' && typeof version === 'string' ? { at, version } : null;\n } catch {\n return null;\n }\n}\n\n/** `uninstall`: the markers and the stamp, and nothing else under the data dir. */\nexport async function removeAliveState(dataDir: string): Promise<boolean> {\n const dir = aliveDir(dataDir);\n const existed = (await stat(dir).catch(() => null)) !== null;\n if (!existed) return false;\n for (const name of await readdir(dir).catch(() => [] as string[])) {\n if (name === STAMP || /^[0-9a-f]{32}$/.test(name)) await rm(join(dir, name), { force: true });\n }\n // Only when empty: a file somebody else put there keeps the folder.\n await rmdir(dir).catch(() => undefined);\n return true;\n}\n\n/** How long the leg waits on a balance read before it says nothing. */\nexport const WALLET_READ_MS = 2_000;\n\n/**\n * THE WALLET, SAID TO THE PERSON AT THE START OF A SESSION while it cannot\n * pay: the leg's `systemMessage`, which Claude Code shows the user and never\n * the model, on every surface and without the mod. Null when there is no\n * wallet, the balance could not be read in time, or the wallet holds at least\n * the per-call limit.\n */\nexport async function walletNotice(\n dataDir: string,\n opts: { read?: typeof readUsdcBalanceWithFallback; timeoutMs?: number } = {},\n): Promise<string | null> {\n const wallet = await readJson(walletPath(dataDir));\n const address = typeof wallet?.address === 'string' ? wallet.address : undefined;\n if (address === undefined || !/^0x[0-9a-fA-F]{40}$/.test(address)) return null;\n const config = await readJson(configPath(dataDir));\n const rpcUrl = typeof config?.rpcUrl === 'string' ? config.rpcUrl : DEFAULT_RPC_URL;\n const timeoutMs = opts.timeoutMs ?? WALLET_READ_MS;\n const read = rememberingBalanceReader(dataDir, {\n ...(opts.read !== undefined ? { read: opts.read } : {}),\n });\n const balance = await read(address, rpcUrl, { timeoutMs });\n if (balance === null) return null;\n // The per-call limit as the spend policy reads it: the file's, else the default.\n const cap = BigInt(\n typeof config?.maxAutoSpend === 'string' && /^\\d{1,30}$/.test(config.maxAutoSpend)\n ? config.maxAutoSpend\n : DEFAULT_MAX_AUTO_SPEND,\n );\n if (balance > 0n && balance >= cap) return null;\n // Only the person reads it, inside the session: they ask, the agent runs it.\n return `Tenjin balance: $${dollars(balance)}. Ask your agent to add funds to Tenjin.`;\n}\n\n/** `$0.00`, `$0.10`, `$0.007`: whole cents keep two decimals. */\nfunction dollars(atomic: bigint): string {\n const fraction = (atomic % 1_000_000n).toString().padStart(6, '0').replace(/0+$/, '');\n return `${atomic / 1_000_000n}.${fraction.padEnd(2, '0')}`;\n}\n\nasync function readJson(path: string): Promise<Record<string, unknown> | null> {\n try {\n const value: unknown = JSON.parse(await readFile(path, 'utf8'));\n return value !== null && typeof value === 'object' ? (value as Record<string, unknown>) : null;\n } catch {\n return null;\n }\n}\n\n/**\n * The command form's entry, read off stdin: `tenjin hook alive`. It writes the\n * answer, when there is one, as one JSON line and WAITS for the write to land:\n * on macOS stdout to a pipe is asynchronous, and `src/index.ts` calls\n * `process.exit(0)` right after this returns, which would drop it. With no\n * answer from the wallet's files, it prints the balance notice\n * ({@link walletNotice}) as a JSON `systemMessage`, which Claude Code shows the\n * user; plain text would be added to the session's context. A wallet that\n * cannot sign is told that, never to add funds.\n */\nexport async function aliveMain(opts: {\n dataDir: string;\n version: string;\n env?: NodeJS.ProcessEnv;\n /** Test seams: the harness event and the stream the answer goes to. */\n readEvent?: () => Promise<string>;\n stdout?: Pick<NodeJS.WritableStream, 'write'>;\n}): Promise<void> {\n const raw = await (opts.readEvent ?? (() => readStdin(1_000)))().catch(() => '');\n const answer = await runAliveHook(parseEvent(raw), {\n dataDir: opts.dataDir,\n version: opts.version,\n ...(opts.env !== undefined ? { env: opts.env } : {}),\n });\n const notice = answer === null ? await walletNotice(opts.dataDir).catch(() => null) : null;\n const payload = answer ?? (notice !== null ? { systemMessage: notice } : null);\n if (payload === null) return;\n const out = opts.stdout ?? process.stdout;\n await new Promise<void>((resolve) => {\n try {\n out.write(`${JSON.stringify(payload)}\\n`, () => resolve());\n } catch {\n resolve();\n }\n });\n}\n\nfunction parseEvent(raw: string): unknown {\n try {\n return JSON.parse(raw) as unknown;\n } catch {\n return null;\n }\n}\n\nfunction readStdin(timeoutMs: number): Promise<string> {\n return new Promise((resolve, reject) => {\n const chunks: Buffer[] = [];\n let size = 0;\n const timer = setTimeout(() => reject(new Error('no harness event')), timeoutMs);\n process.stdin.on('data', (chunk: Buffer) => {\n size += chunk.length;\n if (size > 1_000_000) {\n clearTimeout(timer);\n reject(new Error('harness event too large'));\n return;\n }\n chunks.push(chunk);\n });\n process.stdin.once('end', () => {\n clearTimeout(timer);\n resolve(Buffer.concat(chunks).toString('utf8'));\n });\n process.stdin.once('error', () => {\n clearTimeout(timer);\n reject(new Error('harness event unreadable'));\n });\n });\n}\n\n/**\n * A plugin leg marks its own session too, for a session that loaded the plugin\n * without a `SessionStart` (a `/reload-plugins` mid-session): from the next\n * event on, the settings install's legs there stay silent. A stat when the\n * marker is already there.\n */\nexport async function markSessionServed(dataDir: string, event: unknown): Promise<void> {\n const sessionId = sessionIdOf(event);\n if (sessionId === null) return;\n const path = join(aliveDir(dataDir), markerName(sessionId));\n if ((await stat(path).catch(() => null)) !== null) return;\n try {\n await mkdir(aliveDir(dataDir), { recursive: true, mode: 0o700 });\n await writeFile(path, `${new Date().toISOString()}\\n`);\n } catch {\n // Costs only a duplicate offer.\n }\n}\n","import { readFile, stat } from 'node:fs/promises';\nimport { hasCode } from './errno';\nimport { readPassphraseRecord } from './passphrase-record';\nimport { passphraseFilePathFor, passphraseRecordPath, walletPath } from './paths';\nimport { PRIVATE_KEY_RE, type DurableStore } from './wallet-unlock';\n\n/**\n * WHAT THE FILES SAY ABOUT THE WALLET, without unlocking it. The hooks, `alive`\n * and the routing payer's memo need to know \"is there a wallet, is it readable,\n * where was its passphrase saved, and did any of that change\" on every prompt,\n * and none of them may load the wallet layer (`src/router/dist-chunks.test.ts`)\n * or pay for a keychain read or an scrypt to find out.\n *\n * So this reads only: wallet.json's cleartext address, the sidecar, two or three\n * `stat`s, and the environment. It never execs and never throws; anything it\n * cannot read is reported as the fact it is (`unparsable`, null), and deciding\n * what that means is `src/router/eligibility.ts`'s job.\n */\nexport interface WalletFacts {\n /** TENJIN_WALLET_KEY trimmed vs PRIVATE_KEY_RE (S12); whitespace-only = absent. */\n envKey: 'absent' | 'valid' | 'malformed';\n /** unparsable = unreadable, bad JSON, or no valid address. */\n walletFile: 'present' | 'absent' | 'unparsable';\n /** Cleartext top-level address of wallet.json. */\n address: string | null;\n envPassphraseSet: boolean;\n /** Sidecar entry for `address`. */\n passphraseStore: DurableStore | null;\n /** Sidecar says 'file' and the .plain file is absent. */\n passphraseFileMissing: boolean;\n walletMtimeMs: number | null;\n sidecarMtimeMs: number | null;\n}\n\n/** The same address test `hooks.ts` applies to wallet.json's cleartext field. */\nconst ADDRESS_RE = /^0x[0-9a-fA-F]{40}$/;\n\n/**\n * Read {@link WalletFacts} for `dataDir` under `env`. Never rejects.\n *\n * `envKey` runs the exact test `loadCredential` (src/lib/wallet/local.ts)\n * runs, through the one shared {@link PRIVATE_KEY_RE}, so a key these facts\n * call valid is one the signer accepts. The env passphrase counts as set only\n * when non-empty, as the passphrase resolver treats it.\n */\nexport async function readWalletFacts(\n dataDir: string,\n env: NodeJS.ProcessEnv,\n): Promise<WalletFacts> {\n const key = env.TENJIN_WALLET_KEY?.trim() ?? '';\n const envKey: WalletFacts['envKey'] =\n key.length === 0 ? 'absent' : PRIVATE_KEY_RE.test(key) ? 'valid' : 'malformed';\n const passphrase = env.TENJIN_WALLET_PASSPHRASE;\n const envPassphraseSet = passphrase !== undefined && passphrase.length > 0;\n\n const { walletFile, address } = await readWalletAddress(dataDir);\n const [walletMtimeMs, sidecarMtimeMs] = await Promise.all([\n mtimeOf(walletPath(dataDir)),\n mtimeOf(passphraseRecordPath(dataDir)),\n ]);\n\n let passphraseStore: DurableStore | null = null;\n let passphraseFileMissing = false;\n if (address !== null) {\n passphraseStore =\n (await readPassphraseRecord(dataDir, address).catch(() => null))?.store ?? null;\n if (passphraseStore === 'file') {\n // Only a definite ENOENT is \"missing\". Any other stat failure says\n // nothing about whether the file is there, so it claims nothing.\n passphraseFileMissing = await stat(passphraseFilePathFor(address.toLowerCase(), dataDir))\n .then(() => false)\n .catch((err: unknown) => hasCode(err, 'ENOENT'));\n }\n }\n\n return {\n envKey,\n walletFile,\n address,\n envPassphraseSet,\n passphraseStore,\n passphraseFileMissing,\n walletMtimeMs,\n sidecarMtimeMs,\n };\n}\n\n/** `${walletMtimeMs}:${sidecarMtimeMs}`, the stamp the payer memo compares. */\nexport function unlockStamp(f: Pick<WalletFacts, 'walletMtimeMs' | 'sidecarMtimeMs'>): string {\n return `${f.walletMtimeMs}:${f.sidecarMtimeMs}`;\n}\n\n/** wallet.json's state and cleartext address. ENOENT is absent; any other\n * failure to read or understand it is unparsable. */\nasync function readWalletAddress(\n dataDir: string,\n): Promise<Pick<WalletFacts, 'walletFile' | 'address'>> {\n let text: string;\n try {\n text = await readFile(walletPath(dataDir), 'utf8');\n } catch (err) {\n return { walletFile: hasCode(err, 'ENOENT') ? 'absent' : 'unparsable', address: null };\n }\n try {\n const record: unknown = JSON.parse(text);\n const address = (record as { address?: unknown } | null)?.address;\n return typeof address === 'string' && ADDRESS_RE.test(address)\n ? { walletFile: 'present', address }\n : { walletFile: 'unparsable', address: null };\n } catch {\n return { walletFile: 'unparsable', address: null };\n }\n}\n\nasync function mtimeOf(path: string): Promise<number | null> {\n try {\n return (await stat(path)).mtimeMs;\n } catch {\n return null;\n }\n}\n","import { createHash, randomBytes } from 'node:crypto';\nimport { mkdir, open, readFile, readdir, rename, rm } from 'node:fs/promises';\nimport { basename, dirname, join } from 'node:path';\nimport { writeFileAtomic } from '../lib/atomic-json';\nimport { hasCode } from '../lib/errno';\nimport type { UnlockReason } from '../lib/wallet-unlock';\nimport { WALLET_CLASS, walletClearedSentence } from './wallet-reasons';\n\n/**\n * WHAT A SESSION HAS ALREADY BEEN TOLD, on disk, because every hook leg is its\n * own process (or a fresh call into `tenjin mcp`) and none of them remembers\n * the last. Under `<dataDir>/router/notices`:\n *\n * <sha32> the old once-per-session marker ({@link firstNoticeFor})\n * <sha32>-<sha8> told this session this reason ({@link noticeFor})\n * <sha32>.current `${at}\\n${why}`: the reason told last, or `cleared`\n *\n * `<sha32>` is the first 32 hex of sha256(session id) and `<sha8>` the first 8\n * of sha256(reason), so neither a session id nor a reason ever names a file.\n *\n * ONCE PER (SESSION, REASON), WITH A CLEAR LINE (decision 15). A wallet that\n * goes from \"no passphrase\" to \"wrong passphrase\" is news twice; the same\n * reason on every prompt is news once. Once a paid call succeeds after a\n * wallet-class reason was told, the session hears that it cleared, once\n * ({@link noticeCleared}), and the reason's marker goes with it, so a relapse is\n * told again.\n *\n * Every file's FIRST line is the time it was written, and pruning reads only\n * that line, so old markers, new ones and `.current` all age out the same way:\n * a week after they were last written.\n *\n * Hook-safe: node, `lib/atomic-json`, `lib/errno` and the reason strings.\n */\n\n/** How long a session's notice marker is kept. */\nconst NOTICE_KEEP_MS = 7 * 86_400_000;\n\n/** What `.current` says once the reason told last has been cleared. */\nconst CLEARED = 'cleared';\n\n/** Every reason {@link settleCurrent} clears: the unlock reasons and the\n * unclassified fallback, all of which \"Tenjin wallet unlocked.\" answers. */\nconst UNLOCK_CLASS: ReadonlyArray<UnlockReason | 'wallet_locked'> = [\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 'wallet_locked',\n];\n\nfunction noticesDir(dataDir: string): string {\n return join(dataDir, 'router', 'notices');\n}\n\nfunction sessionHash(sessionId: string): string {\n return createHash('sha256').update(sessionId).digest('hex').slice(0, 32);\n}\n\nfunction reasonMarker(dataDir: string, sessionId: string, why: string): string {\n const reason = createHash('sha256').update(why).digest('hex').slice(0, 8);\n return join(noticesDir(dataDir), `${sessionHash(sessionId)}-${reason}`);\n}\n\nfunction currentPath(dataDir: string, sessionId: string): string {\n return join(noticesDir(dataDir), `${sessionHash(sessionId)}.current`);\n}\n\n/** Record the reason told last (or `cleared`), atomically: two legs at once\n * leave one whole answer, never a torn one. */\nasync function writeCurrent(\n dataDir: string,\n sessionId: string,\n now: number,\n why: string,\n): Promise<void> {\n await writeFileAtomic(currentPath(dataDir, sessionId), `${now}\\n${why}`, {\n mode: 0o600,\n dirMode: 0o700,\n });\n}\n\n/**\n * 'tell' ONCE PER (SESSION, REASON): the first caller creates the marker,\n * records `why` as the reason told last, and gets 'tell'; every later caller\n * for the same pair gets 'quiet'. A new reason is a new marker, so it is told.\n * Rejects only on an I/O failure other than \"already there\"; callers treat\n * that as quiet.\n */\nexport async function noticeFor(\n dataDir: string,\n sessionId: string,\n why: string,\n now: number,\n): Promise<'tell' | 'quiet'> {\n const created = await createExclusive(reasonMarker(dataDir, sessionId, why), String(now));\n if (!created) return 'quiet';\n await writeCurrent(dataDir, sessionId, now, why);\n await pruneNotices(dataDir, now);\n return 'tell';\n}\n\n/**\n * THE CLEAR LINE, after a paid call succeeded: `Tenjin wallet unlocked.` or\n * `Tenjin wallet funded.` when the reason told last in this session was a\n * wallet-class one, else null.\n *\n * CLAIM BY UNLINK. Two legs can finish paid calls at once and both read the\n * same `.current`; only the one that takes that reason's marker away returns\n * the sentence, so it is said once. Removing the marker is also what lets the\n * reason be told again if the wallet relapses. The take is a rename to a name\n * of this caller's own, then a remove: two concurrent `unlink`s of one path\n * were both seen to succeed on macOS, and a rename of one source has exactly\n * one winner.\n */\nexport async function noticeCleared(\n dataDir: string,\n sessionId: string,\n now: number,\n): Promise<string | null> {\n const text = await readFile(currentPath(dataDir, sessionId), 'utf8').catch(() => null);\n if (text === null) return null;\n const why = text.split('\\n')[1] ?? '';\n if (!WALLET_CLASS.has(why)) return null;\n const marker = reasonMarker(dataDir, sessionId, why);\n const claimed = join(\n dirname(marker),\n `.${basename(marker)}.${randomBytes(6).toString('hex')}.claimed`,\n );\n try {\n await rename(marker, claimed);\n } catch {\n // Another leg claimed it (ENOENT), or it cannot be touched: say nothing.\n return null;\n }\n await rm(claimed, { force: true }).catch(() => undefined);\n await writeCurrent(dataDir, sessionId, now, CLEARED);\n return walletClearedSentence(why);\n}\n\n/**\n * The router's wallet news already said `Tenjin wallet unlocked.` on this\n * session's leg: mark the reason told last as cleared, so a later paid call\n * does not say it twice, and drop the markers of every unlock reason, so a\n * relapse is told again.\n */\nexport async function settleCurrent(\n dataDir: string,\n sessionId: string,\n now: number,\n): Promise<void> {\n await writeCurrent(dataDir, sessionId, now, CLEARED);\n await Promise.all(\n UNLOCK_CLASS.map((why) =>\n rm(reasonMarker(dataDir, sessionId, why), { force: true }).catch(() => undefined),\n ),\n );\n}\n\n/**\n * TRUE ONCE PER SESSION: the first caller for a session id creates its marker\n * and gets true; every later one gets false. Each marker holds the time it was\n * made, and those older than a week go on the way past, so the directory does\n * not grow with every session ever run.\n */\nexport async function firstNoticeFor(\n dataDir: string,\n sessionId: string,\n now: number,\n): Promise<boolean> {\n const created = await createExclusive(\n join(noticesDir(dataDir), sessionHash(sessionId)),\n String(now),\n );\n if (created) await pruneNotices(dataDir, now);\n return created;\n}\n\n/**\n * Remove every notice file whose first line is not a time, or is a time more\n * than a week before `now`. Only the first line: `.current` carries its reason\n * on the second, and must age like any marker rather than look malformed.\n *\n * Skipped: a dot-file (another leg's `.current` mid-rename) and an empty file\n * (another leg's marker between its exclusive create and its write), so a prune\n * never pulls a file out from under a writer.\n */\nasync function pruneNotices(dataDir: string, now: number): Promise<void> {\n const dir = noticesDir(dataDir);\n for (const entry of await readdir(dir).catch(() => [] as string[])) {\n if (entry.startsWith('.')) continue;\n const path = join(dir, entry);\n const text = await readFile(path, 'utf8').catch(() => 'NaN');\n if (text.length === 0) continue;\n const at = Number(text.split('\\n')[0]);\n if (!Number.isFinite(at) || now - at > NOTICE_KEEP_MS) await rm(path, { force: true });\n }\n}\n\n/** Create `path` holding `body`, only if it is not already there: true when\n * this call made it, false on EEXIST, and any other failure rethrown. */\nexport async function createExclusive(path: string, body: string): Promise<boolean> {\n try {\n await mkdir(join(path, '..'), { recursive: true, mode: 0o700 });\n const handle = await open(path, 'wx', 0o600);\n try {\n await handle.writeFile(body);\n } finally {\n await handle.close();\n }\n return true;\n } catch (err) {\n if (hasCode(err, 'EEXIST')) return false;\n throw err;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAAS,cAAAA,mBAAkB;AAC3B,SAAS,SAAAC,QAAO,WAAAC,UAAS,YAAAC,WAAU,MAAAC,KAAI,OAAO,QAAAC,OAAM,iBAAiB;AACrE,SAAS,QAAAC,aAAY;;;ACFrB,SAAS,UAAU,YAAY;AAmC/B,IAAM,aAAa;AAUnB,eAAsB,gBACpB,SACA,KACsB;AACtB,QAAM,MAAM,IAAI,mBAAmB,KAAK,KAAK;AAC7C,QAAM,SACJ,IAAI,WAAW,IAAI,WAAW,eAAe,KAAK,GAAG,IAAI,UAAU;AACrE,QAAM,aAAa,IAAI;AACvB,QAAM,mBAAmB,eAAe,UAAa,WAAW,SAAS;AAEzE,QAAM,EAAE,YAAY,QAAQ,IAAI,MAAM,kBAAkB,OAAO;AAC/D,QAAM,CAAC,eAAe,cAAc,IAAI,MAAM,QAAQ,IAAI;AAAA,IACxD,QAAQ,WAAW,OAAO,CAAC;AAAA,IAC3B,QAAQ,qBAAqB,OAAO,CAAC;AAAA,EACvC,CAAC;AAED,MAAI,kBAAuC;AAC3C,MAAI,wBAAwB;AAC5B,MAAI,YAAY,MAAM;AACpB,uBACG,MAAM,qBAAqB,SAAS,OAAO,EAAE,MAAM,MAAM,IAAI,IAAI,SAAS;AAC7E,QAAI,oBAAoB,QAAQ;AAG9B,8BAAwB,MAAM,KAAK,sBAAsB,QAAQ,YAAY,GAAG,OAAO,CAAC,EACrF,KAAK,MAAM,KAAK,EAChB,MAAM,CAAC,QAAiB,QAAQ,KAAK,QAAQ,CAAC;AAAA,IACnD;AAAA,EACF;AAEA,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EAC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AAG;AAAA,EACvB,QAAQ;AACN,WAAO;AAAA,EACT;AACF;AAEA,SAAS,UAAU,WAAoC;AACrD,SAAO,IAAI,QAAQ,CAAC,SAAS,WAAW;AACtC,UAAM,SAAmB,CAAC;AAC1B,QAAI,OAAO;AACX,UAAM,QAAQ,WAAW,MAAM,OAAO,IAAI,MAAM,kBAAkB,CAAC,GAAG,SAAS;AAC/E,YAAQ,MAAM,GAAG,QAAQ,CAAC,UAAkB;AAC1C,cAAQ,MAAM;AACd,UAAI,OAAO,KAAW;AACpB,qBAAa,KAAK;AAClB,eAAO,IAAI,MAAM,yBAAyB,CAAC;AAC3C;AAAA,MACF;AACA,aAAO,KAAK,KAAK;AAAA,IACnB,CAAC;AACD,YAAQ,MAAM,KAAK,OAAO,MAAM;AAC9B,mBAAa,KAAK;AAClB,cAAQ,OAAO,OAAO,MAAM,EAAE,SAAS,MAAM,CAAC;AAAA,IAChD,CAAC;AACD,YAAQ,MAAM,KAAK,SAAS,MAAM;AAChC,mBAAa,KAAK;AAClB,aAAO,IAAI,MAAM,0BAA0B,CAAC;AAAA,IAC9C,CAAC;AAAA,EACH,CAAC;AACH;AAQA,eAAsB,kBAAkB,SAAiB,OAA+B;AACtF,QAAM,YAAY,YAAY,KAAK;AACnC,MAAI,cAAc,KAAM;AACxB,QAAM,OAAON,MAAK,SAAS,OAAO,GAAG,WAAW,SAAS,CAAC;AAC1D,MAAK,MAAMI,MAAK,IAAI,EAAE,MAAM,MAAM,IAAI,MAAO,KAAM;AACnD,MAAI;AACF,UAAMF,OAAM,SAAS,OAAO,GAAG,EAAE,WAAW,MAAM,MAAM,IAAM,CAAC;AAC/D,UAAM,UAAU,MAAM,IAAG,oBAAI,KAAK,GAAE,YAAY,CAAC;AAAA,CAAI;AAAA,EACvD,QAAQ;AAAA,EAER;AACF;","names":["createHash","mkdir","readdir","readFile","rm","stat","join","readFile","readFile","readFile","join","createHash","mkdir","readdir","stat","rm","readFile"]}
@@ -0,0 +1,191 @@
1
+ import { createRequire as __tenjinCreateRequire } from 'node:module'; const require = __tenjinCreateRequire(import.meta.url);
2
+ import {
3
+ hasCode
4
+ } from "./chunk-2I4QTOLB.js";
5
+ import {
6
+ external_exports
7
+ } from "./chunk-SNNSAGMT.js";
8
+ import {
9
+ writeFileAtomic
10
+ } from "./chunk-7WEQQJLG.js";
11
+
12
+ // src/router/router-observation.ts
13
+ import { readFile, readdir, rm } from "node:fs/promises";
14
+ import { rmSync } from "node:fs";
15
+ import { join } from "node:path";
16
+ var SIGNING_SOURCES = [
17
+ "key-env",
18
+ "passphrase-env",
19
+ "keychain",
20
+ "secret-service",
21
+ "dpapi",
22
+ "file",
23
+ "legacy"
24
+ ];
25
+ var ObservationSchema = external_exports.object({
26
+ version: external_exports.literal(1),
27
+ pid: external_exports.number().int().positive(),
28
+ startedAt: external_exports.number(),
29
+ at: external_exports.number(),
30
+ cliVersion: external_exports.string(),
31
+ harness: external_exports.enum(["claude", "codex"]),
32
+ launchedByPlugin: external_exports.boolean(),
33
+ cwd: external_exports.string(),
34
+ address: external_exports.string().nullable(),
35
+ servedSession: external_exports.boolean(),
36
+ env: external_exports.object({ passphraseSet: external_exports.boolean(), keySet: external_exports.boolean() }),
37
+ sign: external_exports.object({
38
+ status: external_exports.enum(["ready", "blocked", "unknown", "pending"]),
39
+ reason: external_exports.string().optional(),
40
+ detail: external_exports.string().optional(),
41
+ fix: external_exports.string().optional(),
42
+ source: external_exports.enum(SIGNING_SOURCES).optional()
43
+ }),
44
+ routing: external_exports.object({
45
+ status: external_exports.enum(["ready", "blocked", "unknown"]),
46
+ reason: external_exports.string().optional(),
47
+ at: external_exports.number()
48
+ }).optional()
49
+ });
50
+ var UnlockRecordSchema = external_exports.object({
51
+ version: external_exports.literal(1),
52
+ address: external_exports.string(),
53
+ status: external_exports.enum(["ready", "blocked", "unknown", "awaiting_confirmation"]),
54
+ reason: external_exports.string().optional(),
55
+ at: external_exports.number(),
56
+ inputs: external_exports.object({
57
+ envPassphraseSet: external_exports.boolean(),
58
+ envKeySet: external_exports.boolean(),
59
+ walletMtimeMs: external_exports.number().nullable(),
60
+ sidecarMtimeMs: external_exports.number().nullable(),
61
+ cliVersion: external_exports.string()
62
+ }).optional()
63
+ });
64
+ var UnlockStateSchema = external_exports.object({
65
+ version: external_exports.literal(1),
66
+ wallets: external_exports.record(external_exports.string(), external_exports.unknown())
67
+ });
68
+ var OBSERVATION_NAME = /^(\d+)\.json$/;
69
+ var START_SLACK_MS = 2e3;
70
+ function liveDir(dataDir) {
71
+ return join(dataDir, "router", "live");
72
+ }
73
+ function observationPath(dataDir, pid) {
74
+ return join(liveDir(dataDir), `${pid}.json`);
75
+ }
76
+ function unlockStatePath(dataDir) {
77
+ return join(dataDir, "router", "unlock-state.json");
78
+ }
79
+ async function writeObservation(dataDir, obs) {
80
+ try {
81
+ await writeFileAtomic(observationPath(dataDir, obs.pid), JSON.stringify(obs) + "\n", {
82
+ mode: 384,
83
+ dirMode: 448
84
+ });
85
+ } catch {
86
+ }
87
+ }
88
+ function removeObservationSync(dataDir, pid) {
89
+ try {
90
+ rmSync(observationPath(dataDir, pid), { force: true });
91
+ } catch {
92
+ }
93
+ }
94
+ async function pruneDeadObservations(dataDir, isAlive = pidAlive) {
95
+ const dir = liveDir(dataDir);
96
+ const names = await readdir(dir).catch(() => []);
97
+ for (const name of names) {
98
+ const match = OBSERVATION_NAME.exec(name);
99
+ if (match === null) continue;
100
+ if (isAlive(Number(match[1]))) continue;
101
+ await rm(join(dir, name), { force: true }).catch(() => void 0);
102
+ }
103
+ }
104
+ async function readObservations(dataDir) {
105
+ const dir = liveDir(dataDir);
106
+ const names = await readdir(dir).catch(() => []);
107
+ const out = [];
108
+ for (const name of names.sort()) {
109
+ const match = OBSERVATION_NAME.exec(name);
110
+ if (match === null) continue;
111
+ try {
112
+ const parsed = ObservationSchema.safeParse(
113
+ JSON.parse(await readFile(join(dir, name), "utf8"))
114
+ );
115
+ if (parsed.success && parsed.data.pid === Number(match[1])) {
116
+ out.push(parsed.data);
117
+ }
118
+ } catch {
119
+ }
120
+ }
121
+ return out;
122
+ }
123
+ function servedObservations(obs) {
124
+ return obs.filter((o) => o.harness === "claude" && o.servedSession === true);
125
+ }
126
+ function liveObservations(obs, routers, alive = pidAlive) {
127
+ if (routers === null) return obs.filter((o) => alive(o.pid));
128
+ return obs.filter((o) => {
129
+ const router = routers.find((r) => r.pid === o.pid);
130
+ if (router === void 0) return false;
131
+ return router.startedAt === null || Math.abs(router.startedAt - o.startedAt) <= START_SLACK_MS;
132
+ });
133
+ }
134
+ function pidAlive(pid) {
135
+ if (!Number.isInteger(pid) || pid <= 0) return false;
136
+ try {
137
+ process.kill(pid, 0);
138
+ return true;
139
+ } catch (err) {
140
+ return hasCode(err, "EPERM");
141
+ }
142
+ }
143
+ async function readUnlockWallets(dataDir) {
144
+ try {
145
+ const parsed = UnlockStateSchema.safeParse(
146
+ JSON.parse(await readFile(unlockStatePath(dataDir), "utf8"))
147
+ );
148
+ return parsed.success ? parsed.data.wallets : null;
149
+ } catch {
150
+ return null;
151
+ }
152
+ }
153
+ async function readUnlockRecord(dataDir, address) {
154
+ const wallets = await readUnlockWallets(dataDir);
155
+ if (wallets === null) return null;
156
+ const parsed = UnlockRecordSchema.safeParse(wallets[address.toLowerCase()]);
157
+ return parsed.success ? parsed.data : null;
158
+ }
159
+ async function writeUnlockRecord(dataDir, rec) {
160
+ try {
161
+ const wallets = { ...await readUnlockWallets(dataDir) ?? {} };
162
+ wallets[rec.address.toLowerCase()] = rec;
163
+ await writeFileAtomic(
164
+ unlockStatePath(dataDir),
165
+ JSON.stringify({ version: 1, wallets }, null, 2) + "\n",
166
+ { mode: 384, dirMode: 448 }
167
+ );
168
+ } catch {
169
+ }
170
+ }
171
+ async function markUnlockPending(dataDir, address, now = Date.now()) {
172
+ await writeUnlockRecord(dataDir, {
173
+ version: 1,
174
+ address,
175
+ status: "awaiting_confirmation",
176
+ at: now
177
+ });
178
+ }
179
+
180
+ export {
181
+ writeObservation,
182
+ removeObservationSync,
183
+ pruneDeadObservations,
184
+ readObservations,
185
+ servedObservations,
186
+ liveObservations,
187
+ readUnlockRecord,
188
+ writeUnlockRecord,
189
+ markUnlockPending
190
+ };
191
+ //# sourceMappingURL=chunk-WYXUQGOL.js.map