tenjin-cli 0.1.0-alpha.33 → 0.1.0-alpha.35
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/NOTICE.md +110 -0
- package/README.md +87 -81
- package/dist/{_esm-BIN7VY2L.js → _esm-2KST7HQ7.js} +7 -7
- package/dist/alive-5TV22PNF.js +51 -0
- package/dist/auth-XI7BJFLW.js +47 -0
- package/dist/{auto-update-Y24UL56V.js → auto-update-7L24KDWA.js} +4 -5
- package/dist/balance-DFHC6XEU.js +71 -0
- package/dist/{ccip-DHDFKTQV.js → ccip-HOW3DZYF.js} +4 -4
- package/dist/chunk-24XKUN2S.js +202 -0
- package/dist/chunk-24XKUN2S.js.map +1 -0
- package/dist/chunk-2L7TDGLV.js +56 -0
- package/dist/chunk-2L7TDGLV.js.map +1 -0
- package/dist/{chunk-C2Q76BVM.js → chunk-2U7H35IP.js} +29 -7
- package/dist/chunk-2U7H35IP.js.map +1 -0
- package/dist/chunk-2W4DQQUU.js +176 -0
- package/dist/chunk-2W4DQQUU.js.map +1 -0
- package/dist/{chunk-LRW6S53P.js → chunk-34SAECKZ.js} +35 -11
- package/dist/chunk-34SAECKZ.js.map +1 -0
- package/dist/{chunk-2I4QTOLB.js → chunk-3MZ7DYRO.js} +1 -1
- package/dist/chunk-3MZ7DYRO.js.map +1 -0
- package/dist/{chunk-RVPYTUP4.js → chunk-3Y2EHT4F.js} +13 -9
- package/dist/chunk-3Y2EHT4F.js.map +1 -0
- package/dist/chunk-3Y6BHIN6.js +169 -0
- package/dist/chunk-3Y6BHIN6.js.map +1 -0
- package/dist/{chunk-4K7TQHNP.js → chunk-3YPL6T3P.js} +17 -33
- package/dist/chunk-3YPL6T3P.js.map +1 -0
- package/dist/{chunk-E7SW44LM.js → chunk-44MVIRZH.js} +121 -6
- package/dist/chunk-44MVIRZH.js.map +1 -0
- package/dist/chunk-45MMSBHA.js +321 -0
- package/dist/chunk-45MMSBHA.js.map +1 -0
- package/dist/{chunk-3FMZGI7I.js → chunk-4CE6TMI5.js} +1 -1
- package/dist/chunk-4CE6TMI5.js.map +1 -0
- package/dist/{chunk-QXP3Z3JN.js → chunk-4MBCJFY4.js} +35 -3
- package/dist/chunk-4MBCJFY4.js.map +1 -0
- package/dist/chunk-4TPL54KW.js +227 -0
- package/dist/chunk-4TPL54KW.js.map +1 -0
- package/dist/chunk-54ELBTKE.js +1615 -0
- package/dist/chunk-54ELBTKE.js.map +1 -0
- package/dist/{chunk-NDGZDTSJ.js → chunk-5F4OB5B3.js} +115 -57
- package/dist/chunk-5F4OB5B3.js.map +1 -0
- package/dist/chunk-5HN4KVQU.js +3348 -0
- package/dist/chunk-5HN4KVQU.js.map +1 -0
- package/dist/{chunk-ZDZERB6L.js → chunk-5J4E5GYI.js} +572 -407
- package/dist/chunk-5J4E5GYI.js.map +1 -0
- package/dist/{chunk-ZNNXRNFD.js → chunk-5N4GGUBN.js} +48 -6
- package/dist/chunk-5N4GGUBN.js.map +1 -0
- package/dist/chunk-5USBZ2MU.js +58 -0
- package/dist/chunk-5USBZ2MU.js.map +1 -0
- package/dist/chunk-64WOMNYR.js +183 -0
- package/dist/chunk-64WOMNYR.js.map +1 -0
- package/dist/{chunk-ILNIZ5I2.js → chunk-65RS4LQS.js} +1825 -1715
- package/dist/chunk-65RS4LQS.js.map +1 -0
- package/dist/{chunk-IE7P2BZE.js → chunk-6QMDUDF2.js} +3 -3
- package/dist/{chunk-IADZOXKN.js → chunk-7SLOTLO7.js} +19 -697
- package/dist/chunk-7SLOTLO7.js.map +1 -0
- package/dist/{chunk-WFSPCCVW.js → chunk-7V25UAQO.js} +99 -99
- package/dist/{chunk-WFSPCCVW.js.map → chunk-7V25UAQO.js.map} +1 -1
- package/dist/chunk-BGA4DO5M.js +719 -0
- package/dist/chunk-BGA4DO5M.js.map +1 -0
- package/dist/chunk-BVP7YK2J.js +706 -0
- package/dist/chunk-BVP7YK2J.js.map +1 -0
- package/dist/chunk-C265QIMJ.js +83 -0
- package/dist/chunk-C265QIMJ.js.map +1 -0
- package/dist/{chunk-XQJXNMSB.js → chunk-CRG54LEB.js} +1 -1
- package/dist/chunk-CRG54LEB.js.map +1 -0
- package/dist/{chunk-KG3D7FIF.js → chunk-CZJOMUBP.js} +2 -2
- package/dist/{chunk-36RVGZNY.js → chunk-D6M3ZK66.js} +22 -39
- package/dist/chunk-D6M3ZK66.js.map +1 -0
- package/dist/{chunk-3UCIG4TG.js → chunk-DI4QAGRZ.js} +1 -11
- package/dist/chunk-DI4QAGRZ.js.map +1 -0
- package/dist/{chunk-JKKAIPTU.js → chunk-DIH2G3YG.js} +47 -10
- package/dist/chunk-DIH2G3YG.js.map +1 -0
- package/dist/chunk-DJ36BM62.js +78 -0
- package/dist/chunk-DJ36BM62.js.map +1 -0
- package/dist/chunk-DTEWAVNE.js +114 -0
- package/dist/chunk-DTEWAVNE.js.map +1 -0
- package/dist/chunk-F2KJAJ7T.js +13 -0
- package/dist/chunk-F2KJAJ7T.js.map +1 -0
- package/dist/{chunk-BF4XHEQK.js → chunk-F3QPGYOY.js} +6 -6
- package/dist/chunk-F3QPGYOY.js.map +1 -0
- package/dist/{chunk-3GNJXKIT.js → chunk-F43CV6UC.js} +2 -2
- package/dist/{chunk-J57UC3DD.js → chunk-FKVJKLPI.js} +3 -3
- package/dist/{chunk-V2LQLN5H.js → chunk-FYFHH7V5.js} +59 -8
- package/dist/{chunk-V2LQLN5H.js.map → chunk-FYFHH7V5.js.map} +1 -1
- package/dist/chunk-GAJC4BQZ.js +1096 -0
- package/dist/chunk-GAJC4BQZ.js.map +1 -0
- package/dist/{chunk-DOQGNFHM.js → chunk-GH5UKMZD.js} +2 -12
- package/dist/{chunk-DOQGNFHM.js.map → chunk-GH5UKMZD.js.map} +1 -1
- package/dist/{chunk-WYXUQGOL.js → chunk-HAZAN4UM.js} +7 -6
- package/dist/chunk-HAZAN4UM.js.map +1 -0
- package/dist/chunk-HI5XQOX2.js +393 -0
- package/dist/chunk-HI5XQOX2.js.map +1 -0
- package/dist/chunk-HKGUKAQW.js +488 -0
- package/dist/chunk-HKGUKAQW.js.map +1 -0
- package/dist/{chunk-SO3XRZPX.js → chunk-HPRVFJPM.js} +6 -6
- package/dist/{chunk-L6JEXB3E.js → chunk-HQR4BWKX.js} +3 -131
- package/dist/chunk-HQR4BWKX.js.map +1 -0
- package/dist/chunk-HZKANST2.js +177 -0
- package/dist/chunk-HZKANST2.js.map +1 -0
- package/dist/{chunk-UUGOUOVT.js → chunk-I557SAOM.js} +8 -2
- package/dist/chunk-I557SAOM.js.map +1 -0
- package/dist/{chunk-TC2WZLSC.js → chunk-IGLWLH73.js} +8 -7
- package/dist/chunk-IGLWLH73.js.map +1 -0
- package/dist/chunk-ILWCKCOI.js +58 -0
- package/dist/chunk-ILWCKCOI.js.map +1 -0
- package/dist/{chunk-2GP3HRYK.js → chunk-INSIW65E.js} +182 -182
- package/dist/{chunk-MPZUYCAP.js → chunk-IULCDMVG.js} +12 -1
- package/dist/chunk-IULCDMVG.js.map +1 -0
- package/dist/{chunk-INTFHMU4.js → chunk-IVNSUAVC.js} +25 -26
- package/dist/chunk-IVNSUAVC.js.map +1 -0
- package/dist/chunk-JDQZCREI.js +87 -0
- package/dist/chunk-JDQZCREI.js.map +1 -0
- package/dist/chunk-JHFFUVON.js +1050 -0
- package/dist/chunk-JHFFUVON.js.map +1 -0
- package/dist/{chunk-RL5UUDT4.js → chunk-JNUKLSMZ.js} +3 -3
- package/dist/chunk-JTILUN4W.js +2933 -0
- package/dist/chunk-JTILUN4W.js.map +1 -0
- package/dist/{chunk-OJNTCYQQ.js → chunk-JTX3BUDK.js} +37 -53
- package/dist/chunk-JTX3BUDK.js.map +1 -0
- package/dist/{chunk-X5ZBP3IY.js → chunk-JUUBBBY5.js} +2 -2
- package/dist/chunk-JUUBBBY5.js.map +1 -0
- package/dist/chunk-JWAK7JQB.js +15 -0
- package/dist/chunk-JWAK7JQB.js.map +1 -0
- package/dist/{chunk-UXZONNEQ.js → chunk-K5KNGC4I.js} +34 -31
- package/dist/chunk-K5KNGC4I.js.map +1 -0
- package/dist/chunk-KAQ4Q3TO.js +135 -0
- package/dist/chunk-KAQ4Q3TO.js.map +1 -0
- package/dist/chunk-KFVJYLVL.js +125 -0
- package/dist/chunk-KFVJYLVL.js.map +1 -0
- package/dist/chunk-KGUE5AVX.js +69 -0
- package/dist/chunk-KGUE5AVX.js.map +1 -0
- package/dist/{chunk-FVIGCDSV.js → chunk-KLDMLWXT.js} +11 -85
- package/dist/chunk-KLDMLWXT.js.map +1 -0
- package/dist/chunk-KNKDMTHU.js +453 -0
- package/dist/chunk-KNKDMTHU.js.map +1 -0
- package/dist/chunk-LDA6TAYQ.js +95 -0
- package/dist/chunk-LDA6TAYQ.js.map +1 -0
- package/dist/chunk-LWSSIZOY.js +347 -0
- package/dist/chunk-LWSSIZOY.js.map +1 -0
- package/dist/{chunk-ZURZHELF.js → chunk-MAHNZA6C.js} +158 -41
- package/dist/chunk-MAHNZA6C.js.map +1 -0
- package/dist/chunk-MEWZCIA6.js +220 -0
- package/dist/chunk-MEWZCIA6.js.map +1 -0
- package/dist/{chunk-2SNUOHAT.js → chunk-MEZJ3I63.js} +49 -1
- package/dist/chunk-MEZJ3I63.js.map +1 -0
- package/dist/chunk-MJDO4EXD.js +353 -0
- package/dist/chunk-MJDO4EXD.js.map +1 -0
- package/dist/chunk-NJA6NT3A.js +6595 -0
- package/dist/chunk-NJA6NT3A.js.map +1 -0
- package/dist/{chunk-LHHMV4GU.js → chunk-NVSKJPRC.js} +1 -1
- package/dist/{chunk-LHHMV4GU.js.map → chunk-NVSKJPRC.js.map} +1 -1
- package/dist/{chunk-4YOZGGTZ.js → chunk-OC7K2DVZ.js} +5 -5
- package/dist/chunk-OC7K2DVZ.js.map +1 -0
- package/dist/chunk-ODRPASFP.js +2078 -0
- package/dist/chunk-ODRPASFP.js.map +1 -0
- package/dist/chunk-OJJFANO6.js +133 -0
- package/dist/chunk-OJJFANO6.js.map +1 -0
- package/dist/{chunk-JNJWBTU2.js → chunk-OQWPRFAC.js} +332 -882
- package/dist/chunk-OQWPRFAC.js.map +1 -0
- package/dist/chunk-P4I7BFNJ.js +11 -0
- package/dist/chunk-P4I7BFNJ.js.map +1 -0
- package/dist/{chunk-SNNSAGMT.js → chunk-P6YQWIT2.js} +4058 -4039
- package/dist/chunk-P6YQWIT2.js.map +1 -0
- package/dist/{chunk-JRGFKVAZ.js → chunk-PETQ5WEA.js} +2 -2
- package/dist/{chunk-HMWYAUA6.js → chunk-Q6RSJCXB.js} +29 -69
- package/dist/chunk-Q6RSJCXB.js.map +1 -0
- package/dist/{chunk-U3IKUGRP.js → chunk-QKEUKBRK.js} +17 -23
- package/dist/chunk-QKEUKBRK.js.map +1 -0
- package/dist/{chunk-2RWB7RKE.js → chunk-QKYUCITR.js} +174 -5814
- package/dist/chunk-QKYUCITR.js.map +1 -0
- package/dist/chunk-QQDPRTLP.js +127 -0
- package/dist/chunk-QQDPRTLP.js.map +1 -0
- package/dist/chunk-QQYCYAKI.js +79 -0
- package/dist/chunk-QQYCYAKI.js.map +1 -0
- package/dist/chunk-R4KDH477.js +1064 -0
- package/dist/chunk-R4KDH477.js.map +1 -0
- package/dist/chunk-R5TR2DIK.js +119 -0
- package/dist/chunk-R5TR2DIK.js.map +1 -0
- package/dist/chunk-R62PKTAG.js +66 -0
- package/dist/chunk-R62PKTAG.js.map +1 -0
- package/dist/{chunk-BFDQ4WNW.js → chunk-RFZA7PSM.js} +4 -5
- package/dist/chunk-RFZA7PSM.js.map +1 -0
- package/dist/chunk-RGCPELQN.js +219 -0
- package/dist/chunk-RGCPELQN.js.map +1 -0
- package/dist/chunk-RGVCOG2S.js +910 -0
- package/dist/chunk-RGVCOG2S.js.map +1 -0
- package/dist/chunk-SOLNJ3AZ.js +209 -0
- package/dist/chunk-SOLNJ3AZ.js.map +1 -0
- package/dist/chunk-TFT2X7SH.js +77 -0
- package/dist/chunk-TFT2X7SH.js.map +1 -0
- package/dist/chunk-TUCKEEXE.js +2 -0
- package/dist/chunk-TVWCLUBI.js +293 -0
- package/dist/chunk-TVWCLUBI.js.map +1 -0
- package/dist/chunk-U4TRWSVE.js +78 -0
- package/dist/chunk-U4TRWSVE.js.map +1 -0
- package/dist/chunk-UIB33QQP.js +379 -0
- package/dist/chunk-UIB33QQP.js.map +1 -0
- package/dist/chunk-V6GIVALQ.js +1889 -0
- package/dist/chunk-V6GIVALQ.js.map +1 -0
- package/dist/chunk-VHXCPXUS.js +366 -0
- package/dist/chunk-VHXCPXUS.js.map +1 -0
- package/dist/{chunk-HGZEPQUT.js → chunk-VU6GMWF6.js} +17 -8
- package/dist/chunk-VU6GMWF6.js.map +1 -0
- package/dist/chunk-VWZYE3NC.js +8415 -0
- package/dist/chunk-VWZYE3NC.js.map +1 -0
- package/dist/{chunk-AGMVASXZ.js → chunk-W2GXIARJ.js} +88 -11
- package/dist/chunk-W2GXIARJ.js.map +1 -0
- package/dist/chunk-W4G3K3V7.js +288 -0
- package/dist/chunk-W4G3K3V7.js.map +1 -0
- package/dist/chunk-W74LJ5OT.js +588 -0
- package/dist/chunk-W74LJ5OT.js.map +1 -0
- package/dist/chunk-W7ELYLYK.js +233 -0
- package/dist/chunk-W7ELYLYK.js.map +1 -0
- package/dist/{chunk-BPMWXTFX.js → chunk-WFZX352D.js} +7 -7
- package/dist/chunk-WXA3WTPF.js +20 -0
- package/dist/chunk-WXA3WTPF.js.map +1 -0
- package/dist/chunk-XRGFH7FI.js +454 -0
- package/dist/chunk-XRGFH7FI.js.map +1 -0
- package/dist/chunk-XSCGUO2U.js +330 -0
- package/dist/chunk-XSCGUO2U.js.map +1 -0
- package/dist/chunk-XWROSMI5.js +1039 -0
- package/dist/chunk-XWROSMI5.js.map +1 -0
- package/dist/chunk-Y2EXZ47H.js +40 -0
- package/dist/chunk-Y2EXZ47H.js.map +1 -0
- package/dist/chunk-YJGEVBKZ.js +47 -0
- package/dist/chunk-YJGEVBKZ.js.map +1 -0
- package/dist/{chunk-6CMM6YCB.js → chunk-YWWMISDY.js} +2 -2
- package/dist/{chunk-WXA2BWTE.js → chunk-ZCT5DJ3G.js} +2 -48
- package/dist/chunk-ZCT5DJ3G.js.map +1 -0
- package/dist/chunk-ZEYA2WWX.js +982 -0
- package/dist/chunk-ZEYA2WWX.js.map +1 -0
- package/dist/chunk-ZRC7Z5X3.js +82 -0
- package/dist/chunk-ZRC7Z5X3.js.map +1 -0
- package/dist/{chunk-3AIHRXKO.js → chunk-ZS7JIUJ3.js} +12 -10
- package/dist/chunk-ZS7JIUJ3.js.map +1 -0
- package/dist/{clack-EZ7TDWQU.js → clack-Q4RNC5VE.js} +2 -6
- package/dist/{claude-cli-2YKABJJZ.js → claude-cli-GIIHOBGT.js} +4 -2
- package/dist/claude-install-BAUSJMW3.js +64 -0
- package/dist/{cli-E36SPKBW.js → cli-QY4KKA3D.js} +632 -150
- package/dist/cli-QY4KKA3D.js.map +1 -0
- package/dist/client-3YQKORVK.js +710 -0
- package/dist/client-3YQKORVK.js.map +1 -0
- package/dist/{codex-event-ZO2GEFE6.js → codex-event-EUTCAOTQ.js} +3 -5
- package/dist/{codex-host-KECJVTA2.js → codex-host-ZON3S6HU.js} +7 -7
- package/dist/{codex-install-HQZDGFXW.js → codex-install-HZV2DOAB.js} +242 -88
- package/dist/codex-install-HZV2DOAB.js.map +1 -0
- package/dist/config-QZOBMTEL.js +57 -0
- package/dist/config-names-Z5NZD5R2.js +224 -0
- package/dist/config-names-Z5NZD5R2.js.map +1 -0
- package/dist/config-rules-YOYHS6YL.js +55 -0
- package/dist/config-subagents-WQV2ZAD5.js +362 -0
- package/dist/config-subagents-WQV2ZAD5.js.map +1 -0
- package/dist/connect-YDWTYU4B.js +1020 -0
- package/dist/connect-YDWTYU4B.js.map +1 -0
- package/dist/core-0a66n3e7-TTP554XV.js +127 -0
- package/dist/core-0a66n3e7-TTP554XV.js.map +1 -0
- package/dist/core-0bmnpbz2-C2JIRVZO.js +10790 -0
- package/dist/core-0bmnpbz2-C2JIRVZO.js.map +1 -0
- package/dist/core-9je8ee1j-74DGHWPV.js +30 -0
- package/dist/core-9je8ee1j-74DGHWPV.js.map +1 -0
- package/dist/core-wadgcjfh-TSZFQZGH.js +666 -0
- package/dist/core-wadgcjfh-TSZFQZGH.js.map +1 -0
- package/dist/core-zg882d22-LKV5DZYW.js +37 -0
- package/dist/core-zg882d22-LKV5DZYW.js.map +1 -0
- package/dist/decision-QSKHOGCO.js +145 -0
- package/dist/{doctor-I6XQEKWD.js → doctor-ZWJXRD75.js} +162 -148
- package/dist/doctor-ZWJXRD75.js.map +1 -0
- package/dist/{env-proxy-R6ZMLQTT.js → env-proxy-XLSLHBKQ.js} +2 -2
- package/dist/{ethersCompat-Df4a6QIZ-X6YZWAML.js → ethersCompat-Df4a6QIZ-K3DMHR6Y.js} +5 -5
- package/dist/explicit-ME2NRADQ.js +371 -0
- package/dist/explicit-ME2NRADQ.js.map +1 -0
- package/dist/flush-stdio-NYIJ3QXT.js +18 -0
- package/dist/fund-VF7TLDJH.js +722 -0
- package/dist/fund-VF7TLDJH.js.map +1 -0
- package/dist/hook-command-VZ27MGWO.js +49 -0
- package/dist/hosts/claude/.claude-plugin/marketplace.json +2 -2
- package/dist/hosts/claude/tenjin/.claude-plugin/plugin.json +2 -2
- package/dist/hosts/claude/tenjin/hooks/hook-data.ts +152 -0
- package/dist/hosts/claude/tenjin/hooks/hooks.json +7 -0
- package/dist/hosts/claude/tenjin/hooks/model-viewer.tsx +2987 -0
- package/dist/hosts/claude/tenjin/hooks/register.tsx +527 -56
- package/dist/hosts/claude/tenjin/skills/tenjin-pay/SKILL.md +14 -4
- package/dist/hosts/claude/tenjin/types/index.d.ts +144 -1
- package/dist/{hosts-DVQJ32QC.js → hosts-3EMTVM4H.js} +7 -6
- package/dist/index.js +18 -15
- package/dist/index.js.map +1 -1
- package/dist/install-ZA7L2UF3.js +115 -0
- package/dist/install-funding-JDGYTF72.js +30 -0
- package/dist/install-identity-FFAYEFLX.js +30 -0
- package/dist/{install-wallet-5M4OTYLX.js → install-wallet-2SFOVE3Q.js} +68 -53
- package/dist/install-wallet-2SFOVE3Q.js.map +1 -0
- package/dist/mcp-36S6MK3C.js +67642 -0
- package/dist/mcp-36S6MK3C.js.map +1 -0
- package/dist/new-install-5L4GY3LN.js +51 -0
- package/dist/{package-IJFGMWEV.js → package-BONDXSV3.js} +2 -2
- package/dist/{passphrase-IFTDS3CU.js → passphrase-T4ULBN4M.js} +16 -12
- package/dist/{paths-XCSAKISU.js → paths-O2KDWZ76.js} +18 -28
- package/dist/pay-CMV5KL74.js +74 -0
- package/dist/{payments-HFPPWHTV.js → payments-Z6UBZL4Z.js} +36 -26
- package/dist/payments-Z6UBZL4Z.js.map +1 -0
- package/dist/reclaim-subagent-credit-ABSF67SJ.js +105 -0
- package/dist/reclaim-subagent-credit-ABSF67SJ.js.map +1 -0
- package/dist/{redact-D7ASVWKL.js → redact-LOTHE5TS.js} +2 -8
- package/dist/redact-LOTHE5TS.js.map +1 -0
- package/dist/routing-quote-AHLAREXR.js +40 -0
- package/dist/routing-quote-AHLAREXR.js.map +1 -0
- package/dist/run-JH7ELYAM.js +88 -0
- package/dist/run-JH7ELYAM.js.map +1 -0
- package/dist/runtime-2GX4ALJP.js +410 -0
- package/dist/runtime-2GX4ALJP.js.map +1 -0
- package/dist/runtime-activate-IDQ2NCSP.js +39 -0
- package/dist/runtime-activate-IDQ2NCSP.js.map +1 -0
- package/dist/{runtime-fetch-ZSSSK72Y.js → runtime-fetch-6LOBHBEN.js} +4 -4
- package/dist/runtime-fetch-6LOBHBEN.js.map +1 -0
- package/dist/runtime-launchers-YAPKCBHV.js +31 -0
- package/dist/runtime-launchers-YAPKCBHV.js.map +1 -0
- package/dist/{runtime-layout-WIDILZ6K.js → runtime-layout-QHZQJV7C.js} +5 -4
- package/dist/runtime-layout-QHZQJV7C.js.map +1 -0
- package/dist/runtime-place-4POL4KK4.js +37 -0
- package/dist/runtime-place-4POL4KK4.js.map +1 -0
- package/dist/runtime-provenance-MNJGVBV2.js +12 -0
- package/dist/runtime-provenance-MNJGVBV2.js.map +1 -0
- package/dist/{secp256k1-ZZZT2CAX.js → secp256k1-N5P2GVGF.js} +3 -3
- package/dist/secp256k1-N5P2GVGF.js.map +1 -0
- package/dist/{send-GCVEAQKL.js → send-ELXFKEKY.js} +35 -32
- package/dist/send-ELXFKEKY.js.map +1 -0
- package/dist/status-FXUFWJDM.js +404 -0
- package/dist/status-FXUFWJDM.js.map +1 -0
- package/dist/{status-line-OPCXDHL2.js → status-line-IH5JBWBC.js} +51 -43
- package/dist/status-line-IH5JBWBC.js.map +1 -0
- package/dist/streamableHttp-CP2ZQBIK.js +768 -0
- package/dist/streamableHttp-CP2ZQBIK.js.map +1 -0
- package/dist/{uninstall-BAWRBXXQ.js → uninstall-LJZUKM4D.js} +76 -76
- package/dist/uninstall-LJZUKM4D.js.map +1 -0
- package/dist/update-EUIX72IX.js +68 -0
- package/dist/update-EUIX72IX.js.map +1 -0
- package/dist/usage-EKDC7LUC.js +180 -0
- package/dist/usage-EKDC7LUC.js.map +1 -0
- package/dist/{usdc-VG4CIOUK.js → usdc-YIHK2OMC.js} +8 -12
- package/dist/usdc-YIHK2OMC.js.map +1 -0
- package/dist/{viemAdapter-By13KInL-DOFTEIJV.js → viemAdapter-By13KInL-PRLSIESK.js} +5 -5
- package/dist/viemAdapter-By13KInL-PRLSIESK.js.map +1 -0
- package/dist/wallet-HSW757W6.js +80 -0
- package/dist/wallet-HSW757W6.js.map +1 -0
- package/dist/wallet-kdf-worker.mjs +1433 -818
- package/docs/agent-permissions.md +88 -155
- package/docs/router-reference.md +236 -0
- package/docs/safety-model.md +31 -33
- package/docs/subagents-internals.md +97 -0
- package/docs/subagents.md +348 -0
- package/docs/troubleshooting.md +10 -6
- package/package.json +12 -8
- package/scripts/installers/install.sh +7 -1
- package/dist/alive-GSOWKUOY.js +0 -38
- package/dist/chunk-2I4QTOLB.js.map +0 -1
- package/dist/chunk-2M2VPI2E.js +0 -560
- package/dist/chunk-2M2VPI2E.js.map +0 -1
- package/dist/chunk-2RWB7RKE.js.map +0 -1
- package/dist/chunk-2SNUOHAT.js.map +0 -1
- package/dist/chunk-3623BLPV.js +0 -184
- package/dist/chunk-3623BLPV.js.map +0 -1
- package/dist/chunk-36RVGZNY.js.map +0 -1
- package/dist/chunk-3AIHRXKO.js.map +0 -1
- package/dist/chunk-3FMZGI7I.js.map +0 -1
- package/dist/chunk-3UCIG4TG.js.map +0 -1
- package/dist/chunk-4K7TQHNP.js.map +0 -1
- package/dist/chunk-4LMUQMBH.js +0 -29
- package/dist/chunk-4LMUQMBH.js.map +0 -1
- package/dist/chunk-4USCZ2NI.js +0 -228
- package/dist/chunk-4USCZ2NI.js.map +0 -1
- package/dist/chunk-4YOZGGTZ.js.map +0 -1
- package/dist/chunk-62KNUYWD.js +0 -111
- package/dist/chunk-62KNUYWD.js.map +0 -1
- package/dist/chunk-A5GKIG5O.js +0 -2037
- package/dist/chunk-A5GKIG5O.js.map +0 -1
- package/dist/chunk-AGMVASXZ.js.map +0 -1
- package/dist/chunk-BF4XHEQK.js.map +0 -1
- package/dist/chunk-BFDQ4WNW.js.map +0 -1
- package/dist/chunk-C2Q76BVM.js.map +0 -1
- package/dist/chunk-CEXSOI5R.js +0 -808
- package/dist/chunk-CEXSOI5R.js.map +0 -1
- package/dist/chunk-E7SW44LM.js.map +0 -1
- package/dist/chunk-EDJWHDDL.js +0 -33
- package/dist/chunk-EDJWHDDL.js.map +0 -1
- package/dist/chunk-FVIGCDSV.js.map +0 -1
- package/dist/chunk-GTTUCOPD.js +0 -105
- package/dist/chunk-GTTUCOPD.js.map +0 -1
- package/dist/chunk-HDPUXS3Z.js +0 -122
- package/dist/chunk-HDPUXS3Z.js.map +0 -1
- package/dist/chunk-HGGWCP7W.js +0 -120
- package/dist/chunk-HGGWCP7W.js.map +0 -1
- package/dist/chunk-HGZEPQUT.js.map +0 -1
- package/dist/chunk-HMWYAUA6.js.map +0 -1
- package/dist/chunk-IADZOXKN.js.map +0 -1
- package/dist/chunk-ILNIZ5I2.js.map +0 -1
- package/dist/chunk-INTFHMU4.js.map +0 -1
- package/dist/chunk-JKKAIPTU.js.map +0 -1
- package/dist/chunk-JNJWBTU2.js.map +0 -1
- package/dist/chunk-KM7RY2ZS.js +0 -246
- package/dist/chunk-KM7RY2ZS.js.map +0 -1
- package/dist/chunk-KOGZDMHO.js +0 -21
- package/dist/chunk-KOGZDMHO.js.map +0 -1
- package/dist/chunk-L6JEXB3E.js.map +0 -1
- package/dist/chunk-LRW6S53P.js.map +0 -1
- package/dist/chunk-LXAYUOXI.js +0 -511
- package/dist/chunk-LXAYUOXI.js.map +0 -1
- package/dist/chunk-MEFB5KHA.js +0 -59
- package/dist/chunk-MEFB5KHA.js.map +0 -1
- package/dist/chunk-MPZUYCAP.js.map +0 -1
- package/dist/chunk-NDGZDTSJ.js.map +0 -1
- package/dist/chunk-OJNTCYQQ.js.map +0 -1
- package/dist/chunk-P3LFTKE7.js +0 -58
- package/dist/chunk-P3LFTKE7.js.map +0 -1
- package/dist/chunk-QXP3Z3JN.js.map +0 -1
- package/dist/chunk-RVPYTUP4.js.map +0 -1
- package/dist/chunk-SNNSAGMT.js.map +0 -1
- package/dist/chunk-TC2WZLSC.js.map +0 -1
- package/dist/chunk-TKPF35W6.js +0 -29
- package/dist/chunk-TKPF35W6.js.map +0 -1
- package/dist/chunk-U3IKUGRP.js.map +0 -1
- package/dist/chunk-UUGOUOVT.js.map +0 -1
- package/dist/chunk-UXZONNEQ.js.map +0 -1
- package/dist/chunk-WXA2BWTE.js.map +0 -1
- package/dist/chunk-WYXUQGOL.js.map +0 -1
- package/dist/chunk-X5ZBP3IY.js.map +0 -1
- package/dist/chunk-XKESD27X.js +0 -10
- package/dist/chunk-XKESD27X.js.map +0 -1
- package/dist/chunk-XQJXNMSB.js.map +0 -1
- package/dist/chunk-Y527D4TV.js +0 -56
- package/dist/chunk-Y527D4TV.js.map +0 -1
- package/dist/chunk-ZDZERB6L.js.map +0 -1
- package/dist/chunk-ZNNXRNFD.js.map +0 -1
- package/dist/chunk-ZURZHELF.js.map +0 -1
- package/dist/cli-E36SPKBW.js.map +0 -1
- package/dist/codex-install-HQZDGFXW.js.map +0 -1
- package/dist/config-HY2E4GGW.js +0 -55
- package/dist/doctor-I6XQEKWD.js.map +0 -1
- package/dist/fund-2QRO7OJL.js +0 -378
- package/dist/fund-2QRO7OJL.js.map +0 -1
- package/dist/hook-command-2UBCSZG6.js +0 -43
- package/dist/install-ILUX5C4A.js +0 -107
- package/dist/install-identity-TZKGY6LQ.js +0 -31
- package/dist/install-wallet-5M4OTYLX.js.map +0 -1
- package/dist/mcp-LE4DUS22.js +0 -14127
- package/dist/mcp-LE4DUS22.js.map +0 -1
- package/dist/pay-WCG3IH4R.js +0 -55
- package/dist/payments-HFPPWHTV.js.map +0 -1
- package/dist/plugin-registration-PZFI5GZW.js +0 -68
- package/dist/runtime-UZOKSUZX.js +0 -1321
- package/dist/runtime-UZOKSUZX.js.map +0 -1
- package/dist/send-GCVEAQKL.js.map +0 -1
- package/dist/status-HCVAOCN7.js +0 -150
- package/dist/status-HCVAOCN7.js.map +0 -1
- package/dist/status-line-OPCXDHL2.js.map +0 -1
- package/dist/uninstall-BAWRBXXQ.js.map +0 -1
- package/dist/update-CACXLQLR.js +0 -56
- package/dist/wallet-QL4UUXEZ.js +0 -55
- /package/dist/{_esm-BIN7VY2L.js.map → _esm-2KST7HQ7.js.map} +0 -0
- /package/dist/{alive-GSOWKUOY.js.map → alive-5TV22PNF.js.map} +0 -0
- /package/dist/{auto-update-Y24UL56V.js.map → auth-XI7BJFLW.js.map} +0 -0
- /package/dist/{ccip-DHDFKTQV.js.map → auto-update-7L24KDWA.js.map} +0 -0
- /package/dist/{clack-EZ7TDWQU.js.map → balance-DFHC6XEU.js.map} +0 -0
- /package/dist/{claude-cli-2YKABJJZ.js.map → ccip-HOW3DZYF.js.map} +0 -0
- /package/dist/{chunk-IE7P2BZE.js.map → chunk-6QMDUDF2.js.map} +0 -0
- /package/dist/{chunk-KG3D7FIF.js.map → chunk-CZJOMUBP.js.map} +0 -0
- /package/dist/{chunk-3GNJXKIT.js.map → chunk-F43CV6UC.js.map} +0 -0
- /package/dist/{chunk-J57UC3DD.js.map → chunk-FKVJKLPI.js.map} +0 -0
- /package/dist/{chunk-SO3XRZPX.js.map → chunk-HPRVFJPM.js.map} +0 -0
- /package/dist/{chunk-2GP3HRYK.js.map → chunk-INSIW65E.js.map} +0 -0
- /package/dist/{chunk-RL5UUDT4.js.map → chunk-JNUKLSMZ.js.map} +0 -0
- /package/dist/{chunk-JRGFKVAZ.js.map → chunk-PETQ5WEA.js.map} +0 -0
- /package/dist/{codex-event-ZO2GEFE6.js.map → chunk-TUCKEEXE.js.map} +0 -0
- /package/dist/{chunk-BPMWXTFX.js.map → chunk-WFZX352D.js.map} +0 -0
- /package/dist/{chunk-6CMM6YCB.js.map → chunk-YWWMISDY.js.map} +0 -0
- /package/dist/{codex-host-KECJVTA2.js.map → clack-Q4RNC5VE.js.map} +0 -0
- /package/dist/{config-HY2E4GGW.js.map → claude-cli-GIIHOBGT.js.map} +0 -0
- /package/dist/{env-proxy-R6ZMLQTT.js.map → claude-install-BAUSJMW3.js.map} +0 -0
- /package/dist/{ethersCompat-Df4a6QIZ-X6YZWAML.js.map → codex-event-EUTCAOTQ.js.map} +0 -0
- /package/dist/{hook-command-2UBCSZG6.js.map → codex-host-ZON3S6HU.js.map} +0 -0
- /package/dist/{hosts-DVQJ32QC.js.map → config-QZOBMTEL.js.map} +0 -0
- /package/dist/{install-ILUX5C4A.js.map → config-rules-YOYHS6YL.js.map} +0 -0
- /package/dist/{install-identity-TZKGY6LQ.js.map → decision-QSKHOGCO.js.map} +0 -0
- /package/dist/{package-IJFGMWEV.js.map → env-proxy-XLSLHBKQ.js.map} +0 -0
- /package/dist/{passphrase-IFTDS3CU.js.map → ethersCompat-Df4a6QIZ-K3DMHR6Y.js.map} +0 -0
- /package/dist/{paths-XCSAKISU.js.map → flush-stdio-NYIJ3QXT.js.map} +0 -0
- /package/dist/{pay-WCG3IH4R.js.map → hook-command-VZ27MGWO.js.map} +0 -0
- /package/dist/{plugin-registration-PZFI5GZW.js.map → hosts-3EMTVM4H.js.map} +0 -0
- /package/dist/{redact-D7ASVWKL.js.map → install-ZA7L2UF3.js.map} +0 -0
- /package/dist/{runtime-fetch-ZSSSK72Y.js.map → install-funding-JDGYTF72.js.map} +0 -0
- /package/dist/{runtime-layout-WIDILZ6K.js.map → install-identity-FFAYEFLX.js.map} +0 -0
- /package/dist/{secp256k1-ZZZT2CAX.js.map → new-install-5L4GY3LN.js.map} +0 -0
- /package/dist/{update-CACXLQLR.js.map → package-BONDXSV3.js.map} +0 -0
- /package/dist/{usdc-VG4CIOUK.js.map → passphrase-T4ULBN4M.js.map} +0 -0
- /package/dist/{viemAdapter-By13KInL-DOFTEIJV.js.map → paths-O2KDWZ76.js.map} +0 -0
- /package/dist/{wallet-QL4UUXEZ.js.map → pay-CMV5KL74.js.map} +0 -0
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/router/codex-install.ts"],"sourcesContent":["import { execFile } from 'node:child_process';\nimport { existsSync } from 'node:fs';\nimport { stat } from 'node:fs/promises';\nimport { homedir } from 'node:os';\nimport { dirname, join, resolve } from 'node:path';\nimport { fileURLToPath } from 'node:url';\nimport pkg from '../../package.json';\nimport { persistRouterDefaults } from '../commands/config';\nimport { versionFreeEntry } from '../commands/update';\nimport type { WalletDeps, WalletOutcome } from '../commands/install-wallet';\nimport { autoUpdateLine } from '../lib/auto-update';\nimport { resolveCodex } from '../lib/codex-bin';\nimport { loadRawConfig } from '../lib/config';\nimport { CliError } from '../lib/errors';\nimport { runtimeDir } from '../lib/paths';\nimport type { RuntimeSetup, setupRuntime } from '../lib/runtime';\nimport type { CommandContext, CommandResult } from '../context';\nimport {\n at,\n CODEX_MARKETPLACE,\n CODEX_PLUGIN,\n codexHookRows,\n codexVersion,\n listCodexHooks,\n readCodexConfig,\n type CodexHookRows,\n WEB_VERIFIED_VERSION,\n} from './codex-host';\nimport { resolveContextSettings } from '../lib/settings';\nimport {\n approveLimits,\n assertPluginInstallation,\n continuationCommand,\n requireRuntime,\n defaultRuntime,\n effectiveLimits,\n hasRuntime,\n namedLimits,\n NOTHING_TO_REFRESH,\n runtimeData,\n runtimeLines,\n spendStepFor,\n tilde,\n type QuestionStep,\n type RouterInstallDeps,\n} from './install';\nimport { EVENT_LABEL, rowsOf, trustCodexHooks, type ListedHook } from '../lib/codex-trust';\nimport { readInstalledHosts, withNote } from './hosts';\nimport { CODEX_MCP_HOOKS_VERSION, renderCodexHooks } from './plugin-files';\nimport { shownLimits } from './spend-question';\n\n/**\n * `tenjin install|uninstall|doctor` for Codex. Codex's own commands do\n * every plugin write: `codex plugin marketplace add` and `codex plugin add`\n * copy the plugin from Tenjin's runtime, `~/.tenjin/runtime/codex`, which\n * install sets up as the Claude install does, or from this package's\n * `dist/hosts/codex` where there is none. The plugin's own `PermissionRequest`\n * hook allows the request tool, so install writes no Codex config: the\n * wallet, the spend defaults and the plugin. User scope only.\n */\n\nexport interface CodexArgs {\n project?: boolean;\n yes?: boolean;\n noWallet?: boolean;\n /** `--max-auto-spend`: the per-call limit, at least 0.25 USD. */\n maxAutoSpend?: string;\n /** `--session-budget`: the daily limit in USD, or none. */\n sessionBudget?: string;\n}\n\nexport interface CodexRun {\n code: number;\n stdout: string;\n stderr: string;\n}\n\nexport interface CodexSetupDeps\n extends WalletDeps, Pick<RouterInstallDeps, 'promptLimits' | 'promptAmount'> {\n /** One `codex` command, recorded in tests. */\n run?: (args: string[]) => Promise<CodexRun>;\n /** Codex's merged config (`config/read`), or null when it could not be read. */\n config?: () => Promise<unknown>;\n /** Codex's hook list (`hooks/list`). */\n hooks?: () => Promise<unknown>;\n version?: () => Promise<string | null>;\n /** The marketplace folder without a runtime, by default this package's `dist/hosts/codex`. */\n hostsDir?: string | null;\n isInteractive?: boolean;\n homeDir?: string;\n /** Sets up Tenjin's runtime for this build; tests inject it, production runs `setupRuntime`. */\n runtime?: (o: Parameters<typeof setupRuntime>[0]) => Promise<RuntimeSetup>;\n /** Trusts the listed rows through Codex's app server; tests inject it. */\n trust?: typeof trustCodexHooks;\n}\n\nconst RUN_TIMEOUT_MS = 30_000;\n\nfunction runCodex(args: string[]): Promise<CodexRun> {\n const codex = resolveCodex();\n if (codex === null) {\n return Promise.resolve({ code: 127, stdout: '', stderr: 'codex was not found on PATH' });\n }\n return new Promise((resolve) => {\n execFile(\n codex.cmd,\n [...codex.prefix, ...args],\n { timeout: RUN_TIMEOUT_MS, maxBuffer: 4_000_000, windowsHide: true },\n (err, stdout, stderr) => {\n const code = err === null ? 0 : typeof err.code === 'number' ? err.code : 127;\n resolve({ code, stdout: String(stdout), stderr: String(stderr) });\n },\n );\n });\n}\n\n/** This package's `dist/hosts/codex`, by its version-free path under pnpm. */\nexport async function codexHostsDir(\n moduleDir: string = dirname(fileURLToPath(import.meta.url)),\n): Promise<string | null> {\n const catalog = join(moduleDir, 'hosts', 'codex', '.agents', 'plugins', 'marketplace.json');\n const stable = versionFreeEntry(catalog) ?? catalog;\n if ((await stat(stable).catch(() => null))?.isFile() !== true) return null;\n return dirname(dirname(dirname(stable)));\n}\n\nfunction failed(step: string, out: CodexRun): CliError {\n const detail = (out.stderr || out.stdout).trim().split('\\n')[0] ?? '';\n return new CliError('REFUSED', `\\`codex ${step}\\` failed${detail ? `: ${detail}` : ''}.`, {\n fix: 'Check that Codex CLI is installed and on PATH (`codex --version`), then re-run.',\n });\n}\n\n/**\n * The runtime's Codex marketplace, when the runtime has one: a `kept` older\n * runtime may predate it.\n */\nfunction runtimeHosts(rt: RuntimeSetup): string | null {\n if (rt.state !== 'active' && rt.state !== 'current' && rt.state !== 'kept') return null;\n const hosts = join(rt.root, 'codex');\n return existsSync(join(hosts, '.agents', 'plugins', 'marketplace.json')) ? hosts : null;\n}\n\n/**\n * `registered` is the folder Codex's config names for the `tenjin`\n * marketplace. Codex keeps one marketplace by that name, so one added from\n * another folder (the package's, before the runtime) is removed first.\n */\nasync function addPlugin(\n run: (args: string[]) => Promise<CodexRun>,\n hosts: string | null,\n registered: unknown,\n previousEnabled: boolean,\n restoreRuntime?: () => Promise<void>,\n): Promise<void> {\n let removed = false;\n let added = false;\n const moved =\n typeof registered === 'string' && hosts !== null && resolve(registered) !== resolve(hosts);\n try {\n if (hosts === null)\n throw new CliError('UPDATE_FAILED', 'The verified runtime carries no Codex plugin folder.');\n if (moved) {\n const old = await run(['plugin', 'marketplace', 'remove', CODEX_MARKETPLACE]);\n removed = old.code === 0;\n }\n const market = await run(['plugin', 'marketplace', 'add', hosts, '--json']);\n if (market.code !== 0) throw failed('plugin marketplace add', market);\n added = true;\n const plugin = await run(['plugin', 'add', CODEX_PLUGIN, '--json']);\n if (plugin.code !== 0) throw failed('plugin add', plugin);\n } catch (error) {\n try {\n await restoreRuntime?.();\n const restore = async (args: string[]): Promise<void> => {\n const out = await run(args);\n if (out.code !== 0) throw failed(args.join(' '), out);\n };\n if (added && (moved || typeof registered !== 'string')) {\n await restore(['plugin', 'marketplace', 'remove', CODEX_MARKETPLACE]);\n }\n if (moved && (removed || added) && typeof registered === 'string') {\n await restore(['plugin', 'marketplace', 'add', registered, '--json']);\n }\n if (previousEnabled && (removed || added)) {\n await restore(['plugin', 'add', CODEX_PLUGIN, '--json']);\n }\n } catch {\n throw new CliError(\n 'UPDATE_FAILED',\n 'Codex plugin registration failed and the previous registration could not be fully restored.',\n {\n fix: 'Run tenjin install --harness codex again. Your payment keys and funds were kept.',\n cause: error,\n },\n );\n }\n throw error;\n }\n}\n\nconst TRUST_STEP =\n 'Open Codex, run /hooks and trust the five Tenjin hooks, then start a new session.';\n/** What a person reads when this Codex cannot run the plugin's routing hooks. */\nconst CODEX_TOO_OLD = `Routing in Codex needs Codex ${CODEX_MCP_HOOKS_VERSION} or later, so Tenjin left its Codex plugin as it was. Ask your agent to update Codex.`;\n/** What a person reads when an install or update turned the hooks on itself. */\nconst NEW_SESSION_STEP = 'Start a new Codex session: Codex reads hooks when a session starts.';\n\n/**\n * ONE OF THE PLUGIN'S OWN HOOKS, as `hooks/list` lists it: our plugin's hooks\n * file, and at that event, group and position exactly the handler this build\n * renders (an `mcp_tool` leg into `router`/`hook`, the deny, or the allow).\n * Anything else in the list, another plugin's row or a row that moved, is not\n * ours to trust.\n */\nexport function ownCodexRow(row: ListedHook): boolean {\n if (row.pluginId !== CODEX_PLUGIN) return false;\n if (typeof row.sourcePath !== 'string' || !/[\\\\/]hooks[\\\\/]hooks\\.json$/.test(row.sourcePath)) {\n return false;\n }\n const at = /:([a-z_]+):(\\d+):(\\d+)$/.exec(typeof row.key === 'string' ? row.key : '');\n if (at === null) return false;\n const event = Object.keys(EVENT_LABEL).find((e) => EVENT_LABEL[e] === at[1]);\n const group = (renderCodexHooks().hooks[event ?? ''] as Record<string, unknown>[] | undefined)?.[\n Number(at[2])\n ] as { matcher?: string; hooks: Record<string, unknown>[] } | undefined;\n const want = group?.hooks[Number(at[3])];\n if (group === undefined || want === undefined) return false;\n if ((row.matcher ?? null) !== (group.matcher ?? null)) return false;\n return want.type === 'mcp_tool'\n ? row.handlerType === 'mcpTool' && row.server === want.server && row.tool === want.tool\n : row.handlerType === 'command' &&\n (row.command === want.command || row.command === want.commandWindows);\n}\n\n/**\n * TURNS THE PLUGIN'S HOOKS ON, as installing a Claude Code plugin does:\n * through `lib/codex-trust.ts`, which echoes back the `currentHash` Codex\n * reports for each of our rows and verifies them trusted. A row the person\n * turned off in `/hooks` (the allow hook's opt-out) stays off. False when\n * Codex lists none of our rows or any step fails: the person then reviews\n * them in `/hooks`.\n */\nasync function trustPlugin(deps: CodexSetupDeps): Promise<boolean> {\n const list = await (deps.hooks ?? (() => listCodexHooks(process.cwd(), 5_000)))();\n const ours = rowsOf(list).filter(ownCodexRow);\n if (ours.length === 0) return false;\n const keys = ours\n .filter(\n (r) => r.enabled !== false && r.trustStatus !== 'trusted' && r.trustStatus !== 'managed',\n )\n .map((r) => r.key as string);\n const result = await (deps.trust ?? trustCodexHooks)(\n deps.homeDir ?? homedir(),\n keys,\n ownCodexRow,\n );\n return result.ok;\n}\n\n/** What `tenjin update` says about Codex, in person-facing words with no command. */\nexport const CODEX_REFRESH_LINES = {\n done: \"Tenjin updated its Codex hooks. They run in Codex's next new session.\",\n review:\n \"Tenjin updated its Codex hooks but could not turn them on. Open /hooks in Codex and approve Tenjin's hooks so routing works.\",\n old: CODEX_TOO_OLD,\n failed:\n 'Tenjin could not update its Codex hooks. Ask your agent to run the Tenjin doctor for Codex.',\n} as const;\n\n/**\n * A bare `install --refresh` with the Codex refresh beside it: the Codex one\n * runs whatever Claude Code's did. Only Claude Code's \"nothing to refresh\"\n * (a Codex-only machine) gives way to a Codex line; any other Claude Code\n * failure stands, so `tenjin update` still reports it with its fix.\n */\nexport async function alongsideCodexRefresh(\n claude: () => Promise<CommandResult>,\n codex: () => Promise<string | undefined>,\n): Promise<CommandResult> {\n let out: CommandResult;\n try {\n out = await claude();\n } catch (err) {\n const line = await codex();\n const nothing = err instanceof CliError && err.message.startsWith(NOTHING_TO_REFRESH);\n if (line === undefined || !nothing) throw err;\n return { data: { notices: [line] }, humanLines: [line] };\n }\n return withNote(out, await codex());\n}\n\n/**\n * THE CODEX REFRESH `tenjin update` RUNS, in the new build (`install\n * --refresh`). Only where Codex already has the Tenjin plugin with the\n * command legs of an older build: it re-adds the plugin from the same folder,\n * which replaces Codex's copy, then turns the new hooks on (`trustPlugin`).\n * It never installs the plugin anywhere it was not, never asks, and never\n * throws: what happened is one line, or nothing.\n */\nexport async function refreshCodexPlugin(\n ctx: CommandContext,\n deps: CodexSetupDeps = {},\n): Promise<string | undefined> {\n try {\n const version = await (deps.version ?? codexVersion)();\n if (version === null) {\n const recorded = (await readInstalledHosts(ctx.dataDir))?.includes('codex') === true;\n return recorded ? CODEX_REFRESH_LINES.failed : undefined;\n }\n const rows = codexHookRows(\n await (deps.hooks ?? (() => listCodexHooks(process.cwd(), 5_000)))(),\n );\n if (rows.state === 'absent') return undefined;\n if (rows.state === 'unknown') return CODEX_REFRESH_LINES.failed;\n if (rows.routing !== 'free') return undefined;\n if (!codexAtLeast(version, CODEX_MCP_HOOKS_VERSION)) return CODEX_REFRESH_LINES.old;\n const runtimeCodex = join(runtimeDir(ctx.dataDir), 'codex');\n const hosts = existsSync(join(runtimeCodex, '.agents', 'plugins', 'marketplace.json'))\n ? runtimeCodex\n : deps.hostsDir === undefined\n ? await codexHostsDir()\n : deps.hostsDir;\n const config = await (deps.config ?? (() => readCodexConfig(process.cwd(), 3_000)))();\n await addPlugin(\n deps.run ?? runCodex,\n hosts,\n at(config, 'marketplaces', CODEX_MARKETPLACE, 'source'),\n at(config, 'plugins', CODEX_PLUGIN, 'enabled') === true,\n );\n return (await trustPlugin(deps)) ? CODEX_REFRESH_LINES.done : CODEX_REFRESH_LINES.review;\n } catch {\n return CODEX_REFRESH_LINES.failed;\n }\n}\n\nfunction userScopeOnly(args: CodexArgs): void {\n if (args.project === true) {\n throw new CliError('USAGE', 'The Codex plugin installs for your user only; omit --project.');\n }\n}\n\nexport async function runCodexInstall(\n args: CodexArgs,\n ctx: CommandContext,\n deps: CodexSetupDeps = {},\n): Promise<CommandResult> {\n userScopeOnly(args);\n const run = deps.run ?? runCodex;\n const home = deps.homeDir ?? homedir();\n assertPluginInstallation(ctx.dataDir, home, deps.env ?? process.env);\n const config = await loadRawConfig(ctx.dataDir);\n const named = namedLimits(args);\n const humanOutput = ctx.flags.json === true ? false : (deps.isInteractive ?? ctx.io.isTTY);\n const canPrompt = humanOutput && (deps.isInteractive ?? Boolean(process.stdin.isTTY));\n // The Claude install's spend model: `--yes` takes the defaults, the two\n // amount flags set the person's own, and a terminal asks once, before any\n // write, only when the file names neither limit. With no answer nothing is\n // written, the defaults hold, and the question goes to whoever ran it.\n const answered = args.yes === true || named.keys.length > 0;\n const unasked = config.maxAutoSpend === undefined && config.sessionBudget === undefined;\n const limits =\n named.keys.length > 0\n ? { ...shownLimits(config), ...named.limits }\n : args.yes === true\n ? shownLimits(config)\n : canPrompt && unasked\n ? await approveLimits(deps)\n : {};\n\n const rt = await (deps.runtime ?? defaultRuntime)({\n dataDir: ctx.dataDir,\n home,\n env: deps.env ?? process.env,\n version: pkg.version,\n moduleDir: dirname(fileURLToPath(import.meta.url)),\n refresh: false,\n });\n requireRuntime(rt);\n const { resolveWallet, walletValue } = await import('../commands/install-wallet');\n const wallet: WalletOutcome = await resolveWallet(\n ctx,\n deps,\n args.noWallet === true ? 'flag' : undefined,\n false,\n );\n const spend = await persistRouterDefaults(ctx.dataDir, false, limits, named.keys);\n const fromRuntime = runtimeHosts(rt);\n const hosts =\n rt.state === 'skipped'\n ? deps.hostsDir === undefined\n ? await codexHostsDir()\n : deps.hostsDir\n : fromRuntime;\n // A Codex too old to run `mcp_tool` hooks keeps whatever copy it has: the\n // new hooks would be skipped, or the file refused. An unknown build installs.\n const version = await (deps.version ?? codexVersion)();\n const tooOld = version !== null && !codexAtLeast(version, CODEX_MCP_HOOKS_VERSION);\n let next: string = CODEX_TOO_OLD;\n if (!tooOld) {\n const codexConfig = await (deps.config ?? (() => readCodexConfig(process.cwd(), 3_000)))();\n await addPlugin(\n run,\n hosts,\n at(codexConfig, 'marketplaces', CODEX_MARKETPLACE, 'source'),\n at(codexConfig, 'plugins', CODEX_PLUGIN, 'enabled') === true,\n rt.restore,\n );\n next = (await trustPlugin(deps).catch(() => false)) ? NEW_SESSION_STEP : TRUST_STEP;\n }\n\n // Read back after the write, as the Claude install does.\n const effective = effectiveLimits((await resolveContextSettings(ctx)).policy);\n // Run again by the agent in Codex, a bare install finds Codex itself.\n const install = [\n `${continuationCommand(rt)} install`,\n ...(args.noWallet ? ['--no-wallet'] : []),\n ].join(' ');\n const spendAsk: QuestionStep | undefined =\n !canPrompt && !answered && unasked ? spendStepFor(install) : undefined;\n const daily =\n effective.sessionBudget === 'no daily ceiling'\n ? 'no daily limit'\n : `$${effective.sessionBudget} a day`;\n return {\n data: {\n plugin: CODEX_PLUGIN,\n wallet,\n spend: { ...spend, effective },\n runtime: runtimeData(rt),\n nextSteps: spendAsk !== undefined ? [spendAsk] : [],\n next,\n },\n humanLines: [\n `Wallet: ${walletValue(wallet)}`,\n tooOld\n ? `Codex plugin: left as it was (Codex ${version})`\n : `Codex plugin: ${CODEX_PLUGIN} added from ${fromRuntime !== null ? tilde(fromRuntime, home) : 'the package'}`,\n ...runtimeLines(ctx, rt, home),\n `Automatic router: up to $${effective.maxAutoSpend} per call; daily limit ${daily}`,\n ...(spendAsk !== undefined\n ? [\n ` Ask the person in this session: ${spendAsk.question}`,\n ...spendAsk.options.map(\n (o) => ` ${o.label}${o.recommended ? ' (recommended)' : ''}: ${o.command}`,\n ),\n ]\n : []),\n 'Request tool: its plugin hook allows it, under your wallet spend limits. Turn that hook off in /hooks to be asked first.',\n next,\n ],\n };\n}\n\nexport async function runCodexUninstall(\n args: CodexArgs,\n _ctx: CommandContext,\n deps: CodexSetupDeps = {},\n): Promise<CommandResult> {\n userScopeOnly(args);\n const run = deps.run ?? runCodex;\n const removed = await run(['plugin', 'remove', CODEX_PLUGIN, '--json']);\n if (removed.code !== 0) throw failed('plugin remove', removed);\n // Absent already is the state uninstall wants.\n await run(['plugin', 'marketplace', 'remove', CODEX_MARKETPLACE]);\n return {\n data: { removed: CODEX_PLUGIN, marketplace: CODEX_MARKETPLACE },\n humanLines: [\n `Codex plugin ${CODEX_PLUGIN} and its marketplace removed. The wallet and Claude setup are kept.`,\n ],\n };\n}\n\nconst PLUGIN_LINE: Record<CodexHookRows['state'], string> = {\n trusted: 'installed, its hooks on and trusted',\n review: `installed, its hooks need review. ${TRUST_STEP}`,\n absent: 'not installed or turned off. Run `tenjin install --harness codex`',\n unknown: \"could not read Codex's hook list\",\n};\n\n/**\n * What the plugin's hooks and server run, from the folder Codex's config names\n * for the marketplace: information only. Nothing when Codex names none, or\n * names another folder on a machine with no runtime to move to.\n */\nfunction runsFrom(ctx: CommandContext, deps: CodexSetupDeps, source: unknown): string | null {\n if (typeof source !== 'string') return null;\n const home = deps.homeDir ?? homedir();\n const hosts = join(runtimeDir(ctx.dataDir), 'codex');\n if (resolve(source) === resolve(hosts)) return `Tenjin's runtime (${tilde(hosts, home)})`;\n if (!hasRuntime(ctx.dataDir, home)) return null;\n return \"`tenjin` from your PATH; run `tenjin install --harness codex` to move it to Tenjin's runtime\";\n}\n\n/** Whether `version` (`x.y.z`, any suffix ignored) is `floor` or later. */\nexport function codexAtLeast(version: string, floor: string): boolean {\n const parts = (v: string) =>\n v\n .split(/[-+]/)[0]!\n .split('.')\n .map((n) => Number.parseInt(n, 10));\n const have = parts(version);\n for (const [i, least] of parts(floor).entries()) {\n const part = have[i] ?? 0;\n if (!Number.isFinite(part)) return false;\n if (part !== least) return part > least;\n }\n return true;\n}\n\nconst ROUTING_LINE: Record<CodexHookRows['routing'], string> = {\n paid: 'its routing hooks call the router MCP server, which pays the routing fee under your wallet spend limits',\n free: 'its routing hooks are commands from an older build, which cannot pay the routing fee, so they offer nothing. Run `tenjin update` or `tenjin install --harness codex` to replace them',\n unknown: \"could not read how Codex runs the plugin's routing hooks\",\n};\n\n/**\n * Reads Codex's view of the plugin and writes nothing. Routing compatibility\n * is read the same way, with nothing paid or sent: the legs must be `mcp_tool`\n * hooks into the plugin's server (`codexHookRows`), and the Codex build must\n * run them ({@link CODEX_MCP_HOOKS_VERSION}).\n */\nexport async function runCodexDoctor(\n args: CodexArgs,\n ctx: CommandContext,\n deps: CodexSetupDeps = {},\n): Promise<CommandResult> {\n userScopeOnly(args);\n const [list, config, version] = await Promise.all([\n (deps.hooks ?? (() => listCodexHooks(process.cwd(), 5_000)))(),\n (deps.config ?? (() => readCodexConfig(process.cwd(), 3_000)))(),\n (deps.version ?? codexVersion)(),\n ]);\n const hooks = codexHookRows(list);\n // With its allow hook off, `approval_policy = \"never\"` refuses the tool.\n const refused = hooks.allowOff && at(config, 'approval_policy') === 'never';\n // An unknown build is not failed on: only a known older one cannot run the legs.\n const tooOld = version !== null && !codexAtLeast(version, CODEX_MCP_HOOKS_VERSION);\n const routing = hooks.state === 'absent' ? null : hooks.routing;\n // Command legs from an older build warn without failing: `tenjin update`\n // replaces them, and Codex still runs the rest of the plugin.\n const ok = hooks.state === 'trusted' && !refused && routing !== 'unknown' && !tooOld;\n const runs = runsFrom(ctx, deps, at(config, 'marketplaces', CODEX_MARKETPLACE, 'source'));\n const auto = hasRuntime(ctx.dataDir, deps.homeDir ?? homedir())\n ? autoUpdateLine(runtimeDir(ctx.dataDir))\n : null;\n const lines = [\n `Codex plugin: ${PLUGIN_LINE[hooks.state]}`,\n `Request tool: ${refused ? 'refused: its allow hook is off in /hooks and approval_policy is never' : hooks.allowOff ? 'asks before each call (its allow hook is off in /hooks)' : 'allowed by its plugin hook, under your wallet spend limits'}`,\n ...(routing !== null\n ? [`${routing === 'free' ? '! ' : ''}Routing: ${ROUTING_LINE[routing]}`]\n : []),\n tooOld\n ? `Codex build: ${version}, which cannot run the plugin's routing hooks. Update Codex to ${CODEX_MCP_HOOKS_VERSION} or later`\n : `Codex build: ${version ?? 'unknown'} (web hooks last captured on ${WEB_VERIFIED_VERSION}; information only)`,\n ...(runs !== null ? [`Codex plugin runs: ${runs}`] : []),\n ...(auto !== null ? [auto] : []),\n ];\n const data = {\n plugin: CODEX_PLUGIN,\n hooks: hooks.state,\n allowOff: hooks.allowOff,\n routing,\n version,\n ok,\n };\n if (!ok) {\n throw new CliError('REFUSED', 'The Codex plugin is not ready.', {\n details: data,\n fix: lines.join('\\n'),\n });\n }\n return { data, humanLines: lines };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAAS,gBAAgB;AACzB,SAAS,kBAAkB;AAC3B,SAAS,YAAY;AACrB,SAAS,eAAe;AACxB,SAAS,SAAS,MAAM,eAAe;AACvC,SAAS,qBAAqB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M;AAAA,IAChB;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACA,MAAI,CAAC,IAAI;AACP,UAAM,IAAI,SAAS,WAAW,kCAAkC;AAAA,MAC9D,SAAS;AAAA,MACT,KAAK,MAAM,KAAK,IAAI;AAAA,IACtB,CAAC;AAAA,EACH;AACA,SAAO,EAAE,MAAM,YAAY,MAAM;AACnC;","names":["resolve","at"]}
|
package/dist/config-HY2E4GGW.js
DELETED
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import { createRequire as __tenjinCreateRequire } from 'node:module'; const require = __tenjinCreateRequire(import.meta.url);
|
|
2
|
-
import {
|
|
3
|
-
EXPERIMENTAL_BAZAAR_WARNING,
|
|
4
|
-
ROUTER_DEFAULTS,
|
|
5
|
-
persistGrantDeclined,
|
|
6
|
-
persistHookArm,
|
|
7
|
-
persistInstallHarness,
|
|
8
|
-
persistPublishMode,
|
|
9
|
-
persistRouterDefaults,
|
|
10
|
-
persistRouterProject,
|
|
11
|
-
runConfigGet,
|
|
12
|
-
runConfigList,
|
|
13
|
-
runConfigSet
|
|
14
|
-
} from "./chunk-A5GKIG5O.js";
|
|
15
|
-
import "./chunk-4LMUQMBH.js";
|
|
16
|
-
import "./chunk-3623BLPV.js";
|
|
17
|
-
import "./chunk-XKESD27X.js";
|
|
18
|
-
import "./chunk-FVIGCDSV.js";
|
|
19
|
-
import "./chunk-HDPUXS3Z.js";
|
|
20
|
-
import "./chunk-2SNUOHAT.js";
|
|
21
|
-
import "./chunk-E7SW44LM.js";
|
|
22
|
-
import "./chunk-F3ED5WTR.js";
|
|
23
|
-
import "./chunk-DOQGNFHM.js";
|
|
24
|
-
import "./chunk-MEFB5KHA.js";
|
|
25
|
-
import "./chunk-UUGOUOVT.js";
|
|
26
|
-
import "./chunk-MPZUYCAP.js";
|
|
27
|
-
import "./chunk-RVPYTUP4.js";
|
|
28
|
-
import "./chunk-AGMVASXZ.js";
|
|
29
|
-
import "./chunk-KM7RY2ZS.js";
|
|
30
|
-
import "./chunk-Y527D4TV.js";
|
|
31
|
-
import "./chunk-BFDQ4WNW.js";
|
|
32
|
-
import "./chunk-X5ZBP3IY.js";
|
|
33
|
-
import "./chunk-2I4QTOLB.js";
|
|
34
|
-
import "./chunk-2M2VPI2E.js";
|
|
35
|
-
import "./chunk-WXA2BWTE.js";
|
|
36
|
-
import "./chunk-XQJXNMSB.js";
|
|
37
|
-
import "./chunk-SNNSAGMT.js";
|
|
38
|
-
import "./chunk-7WEQQJLG.js";
|
|
39
|
-
import "./chunk-3UCIG4TG.js";
|
|
40
|
-
import "./chunk-OJNTCYQQ.js";
|
|
41
|
-
import "./chunk-ZXTAQYNA.js";
|
|
42
|
-
export {
|
|
43
|
-
EXPERIMENTAL_BAZAAR_WARNING,
|
|
44
|
-
ROUTER_DEFAULTS,
|
|
45
|
-
persistGrantDeclined,
|
|
46
|
-
persistHookArm,
|
|
47
|
-
persistInstallHarness,
|
|
48
|
-
persistPublishMode,
|
|
49
|
-
persistRouterDefaults,
|
|
50
|
-
persistRouterProject,
|
|
51
|
-
runConfigGet,
|
|
52
|
-
runConfigList,
|
|
53
|
-
runConfigSet
|
|
54
|
-
};
|
|
55
|
-
//# sourceMappingURL=config-HY2E4GGW.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/router/doctor.ts","../src/router/eligibility-check.ts"],"sourcesContent":["import { execFile } from 'node:child_process';\nimport { readFile, realpath, stat } from 'node:fs/promises';\nimport { homedir } from 'node:os';\nimport { dirname, join, posix, resolve, sep, win32 } from 'node:path';\nimport pkg from '../../package.json';\nimport { autoUpdateLine } from '../lib/auto-update';\nimport { hasCode } from '../lib/errno';\nimport { CliError } from '../lib/errors';\nimport { toMoney } from '../lib/money';\nimport { defaultDataDir, launcherDir, runtimeDir } from '../lib/paths';\nimport { readRuntimeState, runtimeBuild, type RuntimeState } from '../lib/runtime-layout';\nimport { resolveContextSettings } from '../lib/settings';\nimport { isNewer } from '../lib/update-check';\nimport type { WalletProvider } from '../lib/wallet';\nimport { createLocalProvider, type PassphraseOverrides } from '../lib/wallet/local';\nimport { describeStoreLocation } from '../lib/wallet/passphrase';\nimport { walletFileExists } from '../lib/wallet/store';\nimport type { SigningSource, UnlockReason } from '../lib/wallet-unlock';\nimport type { CommandContext, CommandResult } from '../context';\nimport { agentsWithoutRequestTool } from './agent-tools';\nimport { readAliveStamp, type AliveStamp } from './alive';\nimport {\n CLAUDE_CODE_FLOOR,\n claudeConfigDir,\n findClaudeBinary,\n jsonList,\n readClaudeCode,\n runClaude,\n type ClaudeBinary,\n type ClaudeCodeState,\n} from './claude-cli';\nimport { isDefiniteBlock } from './eligibility';\nimport { checkEligibility, type Eligibility, type EligibilityInput } from './eligibility-check';\nimport { CHANNEL_DEPOSIT_ATOMIC, ROUTING_FEE_ATOMIC, SUGGESTED_FUND_USD, unpaid, usd } from './fee';\nimport { NEW_SESSION_STEP, pluginProof, projectInstallHere, settingsInstallPaths } from './install';\nimport { inspectLegacyInstall, type LegacyInstall } from './legacy-install';\nimport { routerSettings, type RouterSettings } from './settings';\nimport { MARKETPLACE_NAME, MCP_SERVER_NAME, PLUGIN_ID, PLUGIN_SERVER, REQUEST_TOOL } from './names';\nimport { LAUNCHER_MARKER, PLUGIN_DIR, RUNTIME_MISSING_FIX } from './plugin-files';\nimport { folderState, readPluginListing, type PluginScope } from './plugin-registration';\nimport { probeRouter, type RouterCheck } from './reachability';\nimport {\n mcpServersState,\n readProcessSnapshot,\n RECONNECT_FIX,\n type InstalledAt,\n type ListMcpProcesses,\n type ListProcesses,\n type ProcessSnapshot,\n} from './mcp-processes';\nimport { clearRouterMemo, readRouterMemo, type RouterMemo } from './router-memo';\nimport {\n liveObservations,\n readObservations,\n servedObservations,\n type RouterObservation,\n} from './router-observation';\nimport {\n KEYCHAIN_LOCKED_FIX,\n NO_SESSION_CHECKED,\n REPAIR_CLAUSE,\n UNKNOWN_DETAIL,\n WALLET_REASONS,\n} from './wallet-reasons';\n\n/**\n * `tenjin doctor` for the router product: the things that decide whether a\n * lookup can happen at all, read and never written.\n *\n * THE PLUGIN IS ASKED ABOUT THROUGH CLAUDE CODE ITSELF: `claude --version`\n * against the floor, `claude plugin list --json` for the plugin and its\n * version, and `claude mcp get` for its `router` server. With no binary, the\n * plugin folder and the `alive` stamp stand in. A settings install of an\n * earlier release is reported with its migration state; doctor never migrates.\n *\n * THE RUNTIME CLAUDE CODE STARTS is read from the plugin it loads (the\n * marketplace `claude plugin marketplace list` names, and its `.mcp.json`),\n * run once with `--version`, and checked with the launcher a terminal needs.\n * Plugin installation uses the default data directory only.\n *\n * EVERY FIX IS A STEP THE AGENT TAKES IN THE SESSION: a command it runs, or a\n * slash command the person types there. None sends anyone out of Claude Code.\n *\n * THE SHELF'S DOCTOR IS NOT THIS ONE. It stays with the product it belongs to\n * (`src/commands/doctor.ts`, unregistered), and this one reports the router's\n * own wiring.\n */\n\nexport type { RouterCheck };\n\nexport interface RouterDoctorDeps {\n homeDir?: string;\n cwd?: string;\n /** Check the project install, as `install --project` registered it. Absent,\n * a project install in `cwd` is found ({@link projectInstallHere}). */\n project?: boolean;\n env?: NodeJS.ProcessEnv;\n /** Finds the `claude` binary; tests inject one. */\n findClaude?: (env: NodeJS.ProcessEnv) => ClaudeBinary | null;\n fetchImpl?: typeof fetch;\n /** Node's own version, for the floor check. */\n nodeVersion?: string;\n /** This user's running routers and Claude Code processes; tests inject them. */\n listProcesses?: ListProcesses;\n /** This user's running `tenjin mcp` processes alone (the older seam); tests inject them. */\n listMcpProcesses?: ListMcpProcesses;\n /** When this build was installed; tests inject it. */\n installedAt?: InstalledAt;\n now?: () => number;\n /** The one eligibility check doctor makes; tests inject it. Defaults to {@link checkEligibility}. */\n eligibility?: (input: EligibilityInput) => Promise<Eligibility>;\n /** What the running `tenjin mcp` processes wrote about themselves; tests inject it. */\n readObservations?: (dataDir: string) => Promise<RouterObservation[]>;\n /** Whether a pid is alive, when `ps` could not run; tests inject it. */\n isAlive?: (pid: number) => boolean;\n /**\n * Passphrase-resolution seam for the wallet's verify (keychain exec,\n * platform). Tests MUST set it, or inject `eligibility`, before a verify can\n * run: without it, a wallet's verify reads the developer's own keychain.\n */\n walletPassphrase?: PassphraseOverrides;\n /** Where Claude Code starts the router from, read from the plugin it loads; tests inject it. */\n readLaunch?: (binary: ClaudeBinary | null) => Promise<PluginLaunch | null>;\n /** Runs `<command> <entry> --version` as Claude Code would, with no shell; tests inject it. */\n runVersion?: (command: string, entry: string) => Promise<VersionRun>;\n /** The first `tenjin` on PATH and what it is; tests inject it. */\n pathTenjin?: () => Promise<PathTenjin | null>;\n /** This machine's platform when Tenjin pins no Node for it, else null; tests inject it. */\n unpinnedPlatform?: () => Promise<string | null>;\n}\n\n/** The plugin's `router` server as Claude Code will start it. */\nexport interface PluginLaunch {\n /** The marketplace folder, or the plugin folder of the folder fallback. */\n path: string;\n source: 'marketplace' | 'folder';\n /** Null when the folder holds no `router` server to read: its `.mcp.json` is gone or names none. */\n command: string | null;\n /** Its first argument, `${CLAUDE_PLUGIN_ROOT}` expanded; null when it has none. */\n entry: string | null;\n /**\n * The plugin's `.mcp.json` is not there at all: the folder Claude Code loads\n * was deleted (an npm prefix a Node upgrade took, or the runtime), so\n * nothing can start the router from it.\n */\n missing?: true;\n}\n\nexport interface VersionRun {\n code: number | null;\n stdout: string;\n stderr: string;\n timedOut: boolean;\n}\n\nexport interface PathTenjin {\n path: string;\n /** A launcher Tenjin wrote. */\n marked: boolean;\n version: string | null;\n /** A build that hands a terminal run to Tenjin's runtime (its package carries `tenjinRuntime`). */\n handsOff: boolean;\n /** No `tenjin-cli` package was identified behind it (a Volta or pnpm shim, or another program). */\n unknown?: true;\n}\n\nconst NODE_FLOOR = 22;\n\n/**\n * How Claude Code starts the router, which picks the fixes that fit:\n * Tenjin's runtime; the `node` on its PATH where `tenjin install` can move it\n * to the runtime; or that PATH where it cannot, on a platform Tenjin pins no\n * Node for or under a data dir of its own (decisions 15 and 18).\n */\ntype Layout = 'runtime' | 'path' | 'path-only';\n\n/** The line the PATH layout's fixes end with, where the runtime can end the dependence they describe. */\nconst moveToRuntime = (layout: Layout): string =>\n layout === 'path' ? ' Or run `tenjin install` to move Tenjin to its own runtime.' : '';\n\n/**\n * The stamp row's fix: a new session first, since a reload never stamps. On\n * the PATH layout, then the Node Claude Code runs; a running Claude Code keeps\n * the PATH it started with, so a new window is not enough there.\n */\nfunction stampFix(layout: Layout): string {\n const first =\n \"Start a new Claude Code session and run `tenjin doctor` again: `/reload-plugins` does not run the plugin's `SessionStart`, so only a new session writes the stamp.\";\n return layout !== 'runtime'\n ? `${first} If it still warns, run \\`node --version\\` in that session's shell: Claude Code starts the plugin with the Node on its own PATH, and it must be 22 or newer. After installing or updating Node, quit Claude Code fully, then start a new session.${moveToRuntime(layout)}`\n : first;\n}\n\nexport async function runRouterDoctor(\n ctx: CommandContext,\n deps: RouterDoctorDeps = {},\n): Promise<CommandResult> {\n const env = deps.env ?? process.env;\n const home = deps.homeDir ?? homedir();\n const cwd = deps.cwd ?? process.cwd();\n // WITHOUT THE FLAG, THE INSTALL THIS DIRECTORY HOLDS: a project install\n // found here is the one a session here runs, so it is the one checked.\n const project = deps.project ?? (await projectInstallHere(cwd, home, env));\n // From the directory doctor runs in, which is the one a session there would use.\n const router = await routerSettings(\n { cwd, dataDir: ctx.dataDir },\n deps.homeDir !== undefined ? { homeDir: deps.homeDir } : {},\n ).catch((err: unknown) => (err instanceof Error ? err : new Error(String(err))));\n const settings = await resolveContextSettings(ctx);\n const claude = await readClaudeCode(env, cwd, deps.findClaude ?? findClaudeBinary);\n const scope: PluginScope = project ? 'local' : 'user';\n const paths = settingsInstallPaths(project, env, home, cwd);\n const legacy = await inspectLegacyInstall(paths.settingsPath, paths.mcpFile);\n // THE PROCESSES AND WHAT THE ROUTERS SAW, READ FIRST: before `claude mcp\n // get` (serverCheck) starts a `tenjin mcp` of its own. That router serves no\n // hook, so it never reads as a session anyway (servedSession stays false,\n // B2), but nothing it does can reach this snapshot either.\n const [{ snapshot, installed }, observations] = await Promise.all([\n readProcessSnapshot(deps),\n (deps.readObservations ?? readObservations)(ctx.dataDir).catch(() => [] as RouterObservation[]),\n ]);\n const live = servedObservations(\n liveObservations(observations, snapshot?.routers ?? null, deps.isAlive),\n );\n\n // Only the default profile owns plugin registration and a private runtime.\n const runtime = resolve(ctx.dataDir) === resolve(defaultDataDir(home));\n const root = runtimeDir(ctx.dataDir);\n const state = runtime ? readRuntimeState(root) : null;\n const launch = await (\n deps.readLaunch ?? ((binary) => readPluginLaunch(binary, { env, home, cwd, scope }))\n )(claude.binary).catch(() => null);\n // A platform Tenjin pins no Node for never gets a runtime (decision 15).\n const unpinned = runtime ? await (deps.unpinnedPlatform ?? thisPlatformUnpinned)() : null;\n // Which fixes fit: the ones that blame the `node` on Claude Code's PATH only\n // when that is what starts the plugin, read from the folder Claude Code\n // loads. One under `runtime/claude` whose files are gone is the runtime's.\n // A folder that no longer holds the plugin is no PATH's fault, whichever it is.\n const fromPath =\n launch === null\n ? state === null\n : launch.command === null\n ? !(await pluginGone(launch, root))\n : launch.command === 'node';\n const layout: Layout = !fromPath\n ? 'runtime'\n : runtime && unpinned === null\n ? 'path'\n : 'path-only';\n\n const checks: RouterCheck[] = [nodeCheck(deps.nodeVersion ?? process.version)];\n checks.push(claudeCodeCheck(claude));\n const plugin = await pluginCheck(claude, {\n scope,\n env,\n home,\n cwd,\n dataDir: ctx.dataDir,\n legacy,\n installed,\n snapshot,\n live,\n layout,\n });\n checks.push(plugin.check);\n if (plugin.registered && runtime) {\n const onPath = state !== null ? await (deps.pathTenjin ?? (() => findPathTenjin(env)))() : null;\n checks.push(\n await runtimeCheck({ launch, state, root, home, env, project, onPath, unpinned, deps }),\n );\n const old = pathTenjinCheck(onPath, home);\n if (old !== null) checks.push(old);\n }\n if (plugin.registered && claude.binary !== null) {\n const serving = live.find(\n (o) =>\n o.harness === 'claude' &&\n o.launchedByPlugin &&\n o.cliVersion === pkg.version &&\n resolve(o.cwd) === resolve(cwd),\n );\n checks.push(\n serving !== undefined\n ? {\n name: 'router server',\n status: 'ok',\n required: true,\n detail: `${PLUGIN_SERVER} is serving a Claude Code session in this directory (pid ${serving.pid})`,\n }\n : await serverCheck(claude.binary, env, cwd, layout),\n );\n }\n if (legacy.present || legacy.unreadable !== undefined) {\n checks.push(await migrationCheck(legacy, claude, ctx.dataDir, env, cwd));\n }\n checks.push(routingCheck(router));\n checks.push(\n mcpServersState(snapshot?.routers ?? null, installed, pkg.version, RECONNECT_FIX).check,\n );\n checks.push(spendCheck(settings.policy.maxAutoSpendAtomic, settings.policy.sessionBudgetAtomic));\n checks.push(experimentalCheck(settings.experimentalBazaar));\n\n let host: string | null;\n try {\n host = new URL(settings.baseUrl).host;\n } catch {\n // The router check below names the bad base URL and its fix.\n host = null;\n }\n const e = await shellEligibility(ctx, deps, env, {\n policy: settings.policy,\n rpcUrl: settings.rpcUrl,\n host: host ?? '',\n });\n checks.push(host === null ? UNPARSED_BASE_URL_ROW : routingFeeRow(e, host));\n checks.push(walletRow(e, ctx.dataDir));\n checks.push(sessionRow(e, live, pkg.version));\n const now = deps.now?.() ?? Date.now();\n const probe = await probeRouter(settings.baseUrl, {\n timeoutMs: ctx.flags.timeout,\n env,\n ...(deps.fetchImpl !== undefined ? { fetchImpl: deps.fetchImpl } : {}),\n });\n // A probe the router answered ends the routing legs' backoff at once.\n if (probe.status === 'ok') {\n await clearRouterMemo(ctx.dataDir, 'unreachable', settings.baseUrl);\n checks.push(probe);\n } else {\n checks.push(\n withBackoff(\n probe,\n await readRouterMemo(ctx.dataDir, 'unreachable', settings.baseUrl, now),\n now,\n ),\n );\n }\n const agents = await subagentsCheck(cwd, home);\n if (agents !== null) checks.push(agents);\n\n const failure = checks.find((c) => c.status === 'fail' && c.required);\n const data = {\n checks,\n dataDir: ctx.dataDir,\n baseUrl: settings.baseUrl,\n scope,\n settingsPath: paths.settingsPath,\n session: { observed: live },\n eligibility: {\n canSign: e.canSign,\n canPayRouting: e.canPayRouting,\n savedSign: e.savedSign,\n balanceAtomic: e.balanceAtomic?.toString() ?? null,\n creditAtomic: e.creditAtomic?.toString() ?? null,\n },\n };\n if (failure !== undefined) {\n // REFUSED, the exit-3 class: a machine this command found unready is\n // understood and refused, not a runtime failure of the command itself.\n throw new CliError('REFUSED', failure.detail, {\n ...(failure.fix !== undefined ? { fix: failure.fix } : {}),\n details: data,\n });\n }\n // Information only, above the summary: how the last background update ended.\n const lines = doctorLines(checks);\n const auto = state !== null ? autoUpdateLine(root) : null;\n if (auto !== null) lines.splice(lines.length - 1, 0, auto);\n return { data, humanLines: lines };\n}\n\n/** The routing-fee row when there is no host to check it against. */\nconst UNPARSED_BASE_URL_ROW: RouterCheck = {\n name: 'routing fee',\n status: 'warn',\n required: false,\n detail: 'not checked, because the base URL is not a URL',\n checked: false,\n};\n\n/** `env` without TENJIN_WALLET_PASSPHRASE: what a Claude Code started without it would see. */\nfunction withoutEnvPassphrase(env: NodeJS.ProcessEnv): NodeJS.ProcessEnv {\n const rest = { ...env };\n delete rest.TENJIN_WALLET_PASSPHRASE;\n return rest;\n}\n\n/**\n * The wallet as this shell would open it: `resolveWalletProvider`'s provider,\n * built from doctor's own env (so a test's env, not the runner's, decides).\n * Nothing here prompts: `verify` forces `isTTY: false` and keeps its 5 s read\n * deadline, and `describe` never needs a passphrase.\n */\nfunction walletProviderFor(\n ctx: CommandContext,\n env: NodeJS.ProcessEnv,\n overrides: PassphraseOverrides | undefined,\n): WalletProvider {\n return createLocalProvider({\n dir: ctx.dataDir,\n env,\n passphrase: { ...overrides, isTTY: ctx.io.isTTY ? undefined : false },\n });\n}\n\n/**\n * THE ONE ELIGIBILITY CHECK, for the wallet, routing-fee and session rows.\n * Never rejects: a check that throws (an injected one included) reads as\n * \"could not check\" on every row it feeds, never as ok and never as a block.\n *\n * SAVED PASSPHRASE FIRST (S7, decision 19). With TENJIN_WALLET_PASSPHRASE set,\n * `verifySaved` asks the same question install's default signing check asks\n * first: does the keychain or the file open the wallet WITHOUT the variable?\n * So a correct variable that a store also holds reports that store, and the\n * session row can say whether a Claude Code started without it could sign.\n */\nasync function shellEligibility(\n ctx: CommandContext,\n deps: RouterDoctorDeps,\n env: NodeJS.ProcessEnv,\n s: { policy: EligibilityInput['policy']; rpcUrl: string; host: string },\n): Promise<Eligibility> {\n try {\n const keySet = (env.TENJIN_WALLET_KEY ?? '').trim().length > 0;\n const provider =\n keySet || (await walletFileExists(ctx.dataDir))\n ? walletProviderFor(ctx, env, deps.walletPassphrase)\n : null;\n const passphraseSet = (env.TENJIN_WALLET_PASSPHRASE ?? '').length > 0;\n return await (deps.eligibility ?? checkEligibility)({\n dataDir: ctx.dataDir,\n env,\n policy: s.policy,\n rpcUrl: s.rpcUrl,\n host: s.host,\n timeoutMs: ctx.flags.timeout,\n provider,\n ...(provider !== null && passphraseSet\n ? {\n verifySaved: () =>\n walletProviderFor(ctx, withoutEnvPassphrase(env), deps.walletPassphrase).verify?.() ??\n Promise.resolve(undefined),\n }\n : {}),\n ...(deps.fetchImpl !== undefined ? { fetchImpl: deps.fetchImpl } : {}),\n });\n } catch {\n const failed = {\n status: 'unknown' as const,\n reason: 'check_failed',\n detail: UNKNOWN_DETAIL['check_failed']!,\n };\n return {\n address: null,\n source: null,\n canSign: failed,\n canPayRouting: failed,\n savedSign: null,\n balanceAtomic: null,\n creditAtomic: null,\n describeError: null,\n };\n }\n}\n\n/**\n * The human report: one line a check, and under each row to look at, its fix,\n * as `--json` carries it. The summary counts what the person can act on apart\n * from what could not be checked: a check that could not answer\n * (`checked: false`) is shown as a warning but is nothing to fix.\n */\nexport function doctorLines(checks: RouterCheck[]): string[] {\n const act = checks.filter((c) => c.status !== 'ok' && c.checked !== false).length;\n const unchecked = checks.filter((c) => c.checked === false).length;\n const allPass = checks.every((c) => c.status === 'ok');\n return [\n ...checks.flatMap((c) => [\n `${c.status === 'ok' ? 'ok ' : c.status === 'warn' ? 'warn' : 'fail'} ${c.name}: ${c.detail}`,\n ...(c.status !== 'ok' && c.fix !== undefined ? [` fix: ${c.fix}`] : []),\n ]),\n allPass\n ? `${checks.length} checks, all pass.`\n : `${checks.length} checks, ${act} to act on${unchecked > 0 ? `, ${unchecked} not checked` : ''}.`,\n ];\n}\n\n/**\n * The routing legs' backoff, named on a router line whose probe failed too.\n * It ends by itself after its minute, or when a probe here reaches the router.\n */\nfunction withBackoff(check: RouterCheck, memo: RouterMemo | null, now: number): RouterCheck {\n if (memo === null) return check;\n const left = Math.max(1, Math.ceil((memo.until - now) / 1000));\n return {\n ...check,\n status: check.status === 'ok' ? 'warn' : check.status,\n detail: `${check.detail}; routing calls skip the router for ${left}s more, after one did not reach it`,\n };\n}\n\n/**\n * INFORMATIONAL, NEVER A FAILURE. A custom agent whose `tools:` leave the\n * request tool out is a choice its author may have meant, so this names those\n * agents and the one line that would change it, and counts as passing. It is\n * absent when there is nothing to name. The files are only read.\n */\nasync function subagentsCheck(cwd: string, homeDir: string): Promise<RouterCheck | null> {\n const excluded = await agentsWithoutRequestTool({ cwd, homeDir }, REQUEST_TOOL);\n if (excluded.length === 0) return null;\n return {\n name: 'subagents',\n status: 'ok',\n required: false,\n detail: `${excluded.join(', ')} ${excluded.length === 1 ? 'is' : 'are'} offered no paid lookups: add ${REQUEST_TOOL} to tools: to allow paid lookups there`,\n };\n}\n\nfunction nodeCheck(version: string): RouterCheck {\n const major = Number(/^v(\\d+)/.exec(version)?.[1] ?? '0');\n return major >= NODE_FLOOR\n ? { name: 'node', status: 'ok', required: true, detail: version }\n : {\n name: 'node',\n status: 'fail',\n required: true,\n detail: `${version} is below the Node ${NODE_FLOOR} floor.`,\n fix: `Install Node ${NODE_FLOOR} or newer, then re-run \\`tenjin doctor\\`.`,\n };\n}\n\n/** Claude Code's version against the plugin's floor. */\nfunction claudeCodeCheck(claude: ClaudeCodeState): RouterCheck {\n const name = 'claude code';\n if (claude.binary === null) {\n return {\n name,\n status: 'warn',\n required: false,\n detail:\n 'no claude binary on PATH or in CLAUDE_CODE_EXECPATH, so the plugin was checked from its folder only',\n fix: 'Run `tenjin doctor` from a Claude Code session, where CLAUDE_CODE_EXECPATH names the binary.',\n };\n }\n if (claude.version === null) {\n return {\n name,\n status: 'warn',\n required: false,\n detail: `${claude.binary.path} did not report a version`,\n };\n }\n if (!claude.meetsFloor) {\n return {\n name,\n status: 'fail',\n required: true,\n detail: `Claude Code ${claude.version} is older than ${CLAUDE_CODE_FLOOR}, which the Tenjin plugin needs`,\n ...(claude.fix !== undefined ? { fix: claude.fix } : {}),\n };\n }\n return {\n name,\n status: 'ok',\n required: true,\n detail: `${claude.version}${claude.binary.source === 'execpath' ? ' (from CLAUDE_CODE_EXECPATH)' : ''}`,\n };\n}\n\ninterface PluginContext {\n scope: PluginScope;\n env: NodeJS.ProcessEnv;\n home: string;\n cwd: string;\n dataDir: string;\n legacy: LegacyInstall;\n /** When this build was installed, for {@link pluginStart}. */\n installed: number | null;\n snapshot: ProcessSnapshot | null;\n /** The served live observations (B2). */\n live: RouterObservation[];\n /** How Claude Code starts the plugin, for the fixes that fit. */\n layout: Layout;\n}\n\n/** Whether a session has started the plugin at this version, as {@link pluginStart} tells it. */\nexport type PluginStart = 'proven' | 'pending' | 'did-not-start' | 'unknown';\n\n/**\n * The fix when a Claude Code started since this install did not start the\n * plugin: the `node` on its PATH on that layout, else a new session and then\n * the reinstall that rebuilds the runtime.\n */\nfunction didNotStartFix(layout: Layout): string {\n return layout !== 'runtime'\n ? `Claude Code starts the plugin with the \\`node\\` on its own PATH, which must be 22 or newer: run \\`node --version\\` in the shell it starts from, then quit Claude Code fully and start a new session.${moveToRuntime(layout)}`\n : `Start a new Claude Code session. If Tenjin still does not start: ${RUNTIME_MISSING_FIX}`;\n}\n\n/**\n * HAS A SESSION STARTED THE PLUGIN AT THIS VERSION, first match wins:\n *\n * 1. `proven`: the `alive` stamp is at or above `version`; or a router that\n * served a Claude session (B2) runs `version`; or a plugin router under a\n * Claude Code started at or after this install.\n * 2. `unknown`: no stamp, and no process list to look at (`ps` could not run).\n * 3. `did-not-start`: a Claude Code started at or after this install is\n * running and none of the above holds. Its plugin never came up: most\n * often the `node` on Claude Code's own PATH is too old.\n * 4. `pending`: nothing has started since the install; the next session will.\n *\n * Pure: the caller reads the stamp, the snapshot and the observations.\n */\nexport function pluginStart(i: {\n version: string;\n stamp: AliveStamp | null;\n installed: number | null;\n snapshot: ProcessSnapshot | null;\n live: RouterObservation[];\n}): PluginStart {\n const since = (startedAt: number | null): boolean =>\n i.installed !== null && startedAt !== null && startedAt >= i.installed;\n if (i.stamp !== null && !isNewer(i.version, i.stamp.version)) return 'proven';\n if (servedObservations(i.live).some((o) => o.cliVersion === i.version)) return 'proven';\n if (\n i.snapshot?.routers.some(\n (r) => r.kind === 'plugin' && r.underClaude !== false && since(r.startedAt),\n ) === true\n ) {\n return 'proven';\n }\n if (i.snapshot === null && i.stamp === null) return 'unknown';\n if (i.snapshot?.claude.some((c) => since(c.startedAt)) === true) return 'did-not-start';\n return 'pending';\n}\n\n/** Does any of `paths` name the same directory as `dir`, links resolved? */\nasync function sameDirAsAny(paths: string[], dir: string): Promise<boolean> {\n const real = (p: string) => realpath(p).catch(() => p);\n const here = await real(dir);\n for (const path of paths) if ((await real(path)) === here) return true;\n return false;\n}\n\n/**\n * The plugin: listed and enabled at this CLI's version and stamped by a\n * session at it, or, with no binary to ask, its folder and the `alive` stamp. A machine that still routes through a\n * settings install of an earlier release warns rather than fails.\n */\nasync function pluginCheck(\n claude: ClaudeCodeState,\n c: PluginContext,\n): Promise<{ check: RouterCheck; registered: boolean }> {\n const name = 'plugin';\n const missing = (detail: string): { check: RouterCheck; registered: boolean } => ({\n registered: false,\n check: c.legacy.present\n ? {\n name,\n status: 'warn',\n required: false,\n detail: `${detail}; the settings install of an earlier release still routes here`,\n fix: claude.meetsFloor\n ? `Run \\`tenjin install${c.scope === 'local' ? ' --project' : ''}\\` to move this machine to the plugin.`\n : `Run \\`claude update\\`, then \\`tenjin install${c.scope === 'local' ? ' --project' : ''}\\` to move this machine to the plugin.`,\n }\n : {\n name,\n status: 'fail',\n required: true,\n detail,\n fix: `Run \\`tenjin install${c.scope === 'local' ? ' --project' : ''}\\`.`,\n },\n });\n if (claude.binary !== null) {\n const listing = await readPluginListing(claude.binary, c.env, c.cwd);\n if (!listing.read) {\n return {\n registered: false,\n check: {\n name,\n status: 'warn',\n required: false,\n detail: \"Claude Code's plugin list could not be read, so the plugin was not checked\",\n fix: 'Run `tenjin doctor` again in a moment.',\n },\n };\n }\n if (listing.id === null) return missing(`${PLUGIN_ID} is not installed in Claude Code`);\n if (!listing.enabled) {\n // A PROJECT INSTALL MADE ELSEWHERE is listed from here as disabled.\n // Enabling it here is not the fix: it was meant for that project, and\n // there it is checked.\n if (listing.projects.length > 0 && !(await sameDirAsAny(listing.projects, c.cwd))) {\n return {\n registered: false,\n check: {\n name,\n status: 'fail',\n required: true,\n detail: `${listing.id} is installed for ${listing.projects.join(', ')} only, so nothing is routed from ${c.cwd}`,\n fix: `To check that install, run \\`tenjin doctor\\` from ${listing.projects[0]}.`,\n },\n };\n }\n return {\n registered: false,\n check: {\n name,\n status: 'fail',\n required: true,\n detail: `${listing.id} is installed but disabled, so no lookup is routed`,\n fix: `Run \\`claude plugin enable ${listing.id} --scope ${listing.scope ?? 'user'}\\`, then ${NEW_SESSION_STEP}.`,\n },\n };\n }\n if (listing.version !== pkg.version) {\n return {\n registered: true,\n check: {\n name,\n status: 'warn',\n required: false,\n detail: `${listing.id} is enabled at ${listing.version ?? 'an unknown version'}, and this CLI is ${pkg.version}`,\n fix: 'Run `tenjin install --refresh` to register this version.',\n },\n };\n }\n // Claude Code's own environment shows only in a real session: the `alive`\n // stamp its SessionStart leg writes, a router it started, or its absence\n // from a Claude Code started since. Doctor's PATH may find a Node that\n // Claude Code's does not.\n const stamp = await readAliveStamp(c.dataDir);\n const start = pluginStart({\n version: pkg.version,\n stamp,\n installed: c.installed,\n snapshot: c.snapshot,\n live: c.live,\n });\n const at = `${listing.id} ${pkg.version}`;\n const last = stamp !== null ? ` (last ${stamp.version}, at ${stamp.at})` : '';\n return {\n registered: true,\n check:\n start === 'proven'\n ? {\n name,\n status: 'ok',\n required: true,\n detail: `${at} enabled, and a session has started it`,\n }\n : start === 'pending'\n ? {\n name,\n status: 'ok',\n required: true,\n detail: `${at} enabled; the next Claude Code session starts it`,\n }\n : start === 'unknown'\n ? {\n name,\n status: 'warn',\n required: false,\n checked: false,\n detail: `${at} is enabled; whether a session has started it at this version could not be checked${last}`,\n fix: stampFix(c.layout),\n }\n : {\n name,\n status: 'warn',\n required: false,\n detail: `${at} is enabled, and the Claude Code started since this install has not started it${last}`,\n fix: didNotStartFix(c.layout),\n },\n };\n }\n const folder = await folderState(c.scope, c.env, c.home, c.cwd);\n if (folder.state === 'foreign') {\n return {\n registered: false,\n check: {\n name,\n status: 'fail',\n required: true,\n detail: `${folder.path} is there and is not a folder this CLI wrote, so the plugin cannot be written`,\n fix: `Move ${folder.path} aside, then run \\`tenjin install\\` again.`,\n },\n };\n }\n if (folder.state === 'ours') {\n const stamp = await readAliveStamp(c.dataDir);\n const start = pluginStart({\n version: pkg.version,\n stamp,\n installed: c.installed,\n snapshot: c.snapshot,\n live: c.live,\n });\n return {\n registered: true,\n check:\n start === 'proven'\n ? {\n name,\n status: 'ok',\n required: true,\n detail:\n stamp !== null\n ? `the plugin folder at ${folder.path} loaded, last at ${stamp.at}`\n : `the plugin folder at ${folder.path} is loaded, and a session has started it`,\n }\n : start === 'pending'\n ? {\n name,\n status: 'ok',\n required: true,\n detail: `the plugin folder is at ${folder.path}; the next Claude Code session starts it`,\n }\n : start === 'unknown'\n ? {\n name,\n status: 'warn',\n required: false,\n checked: false,\n detail: `the plugin folder is at ${folder.path}; whether a session has loaded it could not be checked`,\n fix: `To load it, ${NEW_SESSION_STEP}.`,\n }\n : {\n name,\n status: 'warn',\n required: false,\n detail: `the plugin folder is at ${folder.path}, and the Claude Code started since this install has not loaded it`,\n fix: didNotStartFix(c.layout),\n },\n };\n }\n if (await listedInClaudeFiles(c.env, c.home)) {\n return {\n registered: true,\n check: {\n name,\n status: 'warn',\n required: false,\n detail: `${PLUGIN_ID} is registered, and there is no claude binary here to check it`,\n fix: 'Run `tenjin doctor` from a Claude Code session to check it.',\n },\n };\n }\n return missing(`${PLUGIN_ID} is not registered`);\n}\n\n/** Claude Code's own record, read when no binary can be asked. */\nexport async function listedInClaudeFiles(env: NodeJS.ProcessEnv, home: string): Promise<boolean> {\n try {\n const raw = await readFile(\n join(claudeConfigDir(env, home), 'plugins', 'installed_plugins.json'),\n 'utf8',\n );\n const plugins = (JSON.parse(raw) as { plugins?: unknown }).plugins;\n return plugins !== null && typeof plugins === 'object' && PLUGIN_ID in plugins;\n } catch {\n return false;\n }\n}\n\n/**\n * The plugin's `router` server, through `claude mcp get`, which starts it the\n * way a session would and reports whether it answered. `claude mcp get` runs\n * with doctor's own environment, so it starts `node` from doctor's PATH, not\n * the PATH a running Claude Code started with: a connected server here does\n * not prove a session can start it. The `plugin` row's `alive` stamp is the\n * proof from a real session.\n */\nasync function serverCheck(\n binary: ClaudeBinary,\n env: NodeJS.ProcessEnv,\n cwd: string,\n layout: Layout,\n): Promise<RouterCheck> {\n const name = 'router server';\n const run = await runClaude(binary, ['mcp', 'get', PLUGIN_SERVER], {\n env,\n cwd,\n timeoutMs: 45_000,\n });\n const status = /Status:\\s*(.+)/.exec(run.stdout)?.[1]?.trim();\n if (\n run.code === 0 &&\n status !== undefined &&\n /connected/i.test(status) &&\n !/fail/i.test(status)\n ) {\n return { name, status: 'ok', required: true, detail: `${PLUGIN_SERVER} connected` };\n }\n return {\n name,\n status: 'fail',\n required: true,\n detail: `${PLUGIN_SERVER} did not connect${status !== undefined ? `: ${status.slice(0, 200)}` : ''}`,\n fix:\n layout !== 'runtime'\n ? `Quit Claude Code fully (from the tray, or sign out and in), then start a new session: the plugin starts the CLI with \\`node\\` from the PATH Claude Code started with, so a Claude Code opened before Node was installed cannot find it.${moveToRuntime(layout)}`\n : didNotStartFix(layout),\n };\n}\n\n/**\n * WHERE CLAUDE CODE STARTS THE ROUTER FROM: the `tenjin` marketplace's folder\n * as `claude plugin marketplace list` names it, or the folder fallback's, and\n * the `router` server in its `.mcp.json`. Never `installed_plugins.json`,\n * whose `installPath` goes stale once the marketplace is repointed.\n */\nexport async function readPluginLaunch(\n binary: ClaudeBinary | null,\n c: { env: NodeJS.ProcessEnv; home: string; cwd: string; scope: PluginScope },\n): Promise<PluginLaunch | null> {\n let found: { path: string; source: PluginLaunch['source']; plugin: string } | null = null;\n if (binary !== null) {\n const out = await runClaude(binary, ['plugin', 'marketplace', 'list', '--json'], {\n env: c.env,\n cwd: c.cwd,\n });\n const row = (out.code === 0 ? jsonList(out.stdout) : null)?.find(\n (m) => m.name === MARKETPLACE_NAME,\n );\n if (typeof row?.path === 'string') {\n found = { path: row.path, source: 'marketplace', plugin: join(row.path, PLUGIN_DIR) };\n }\n }\n if (found === null) {\n const folder = await folderState(c.scope, c.env, c.home, c.cwd);\n if (folder.state === 'ours')\n found = { path: folder.path, source: 'folder', plugin: folder.path };\n }\n if (found === null) return null;\n // A folder Claude Code still loads from, with its files gone (the runtime\n // deleted, or the npm prefix a Node upgrade took), is said as that: where\n // it loads from is known, and empty.\n let missing = false;\n const mcp = (await readFile(join(found.plugin, '.mcp.json'), 'utf8')\n .then((text) => JSON.parse(text) as unknown)\n .catch((err: unknown) => {\n missing = hasCode(err, 'ENOENT') || hasCode(err, 'ENOTDIR');\n return null;\n })) as {\n mcpServers?: Record<string, { command?: unknown; args?: unknown }>;\n } | null;\n const none = {\n path: found.path,\n source: found.source,\n command: null,\n entry: null,\n ...(missing ? { missing: true as const } : {}),\n };\n const server = mcp?.mcpServers?.[MCP_SERVER_NAME];\n if (typeof server?.command !== 'string') return none;\n const first = Array.isArray(server.args) ? server.args[0] : undefined;\n const entry =\n typeof first === 'string'\n ? resolve(first.split('${CLAUDE_PLUGIN_ROOT}').join(found.plugin))\n : null;\n return { path: found.path, source: found.source, command: server.command, entry };\n}\n\n/** `<command> <entry> --version`, in exec form: a `.cmd` is never spawned. */\nfunction runVersion(command: string, entry: string): Promise<VersionRun> {\n return new Promise((done) => {\n execFile(\n command,\n [entry, '--version'],\n { shell: false, timeout: 15_000, windowsHide: true },\n (err, stdout, stderr) => {\n const failure = err as\n (NodeJS.ErrnoException & { killed?: boolean; code?: unknown }) | null;\n done({\n code: failure === null ? 0 : typeof failure.code === 'number' ? failure.code : null,\n stdout: String(stdout),\n stderr: String(stderr),\n timedOut: failure?.killed === true,\n });\n },\n );\n });\n}\n\n/** Why Tenjin pins no Node for this machine, or null where it pins one. */\nasync function thisPlatformUnpinned(): Promise<string | null> {\n const { runningGlibc, unpinnedPlatform } = await import('../lib/runtime-fetch');\n const platform = process.platform;\n return unpinnedPlatform(platform, process.arch, platform === 'linux' ? runningGlibc() : null);\n}\n\n/** Is the folder Claude Code loads Tenjin's `runtime/claude`, whether or not its files are there? */\nasync function inRuntimeFolder(launch: PluginLaunch, root: string): Promise<boolean> {\n return launch.source === 'marketplace' && samePath(launch.path, join(root, 'claude'));\n}\n\n/**\n * Does the folder Claude Code loads hold no plugin at all: `runtime/claude`\n * with no router to read, or any folder whose `.mcp.json` is gone? Either\n * way the router cannot start, and only a reinstall puts it back.\n */\nasync function pluginGone(launch: PluginLaunch, root: string): Promise<boolean> {\n return (\n launch.command === null && (launch.missing === true || (await inRuntimeFolder(launch, root)))\n );\n}\n\nconst exists = async (path: string): Promise<boolean> =>\n (await stat(path).catch(() => null)) !== null;\nconst samePath = async (a: string, b: string): Promise<boolean> =>\n (await realpath(a).catch(() => resolve(a))) === (await realpath(b).catch(() => resolve(b)));\n\n/** `path` with the home folder written as `~`. */\nfunction tilde(path: string, home: string): string {\n return path === home || path.startsWith(`${home}${sep}`) ? `~${path.slice(home.length)}` : path;\n}\n\n/**\n * THE RUNTIME CLAUDE CODE STARTS, by what the plugin's `.mcp.json` names:\n *\n * - `runtime/claude` with no router to read, or any folder whose `.mcp.json`\n * is gone (the runtime deleted, or the npm prefix a Node upgrade took):\n * Claude Code cannot start the router (the one required failure);\n * - a marketplace outside `runtime/claude` while a runtime exists: an older\n * build moved it back (warn);\n * - an older npm installation on an unsupported platform (warn, with no retry);\n * - `node` from PATH: no runtime, so a Node upgrade or `npm rm -g` stops it\n * (warn);\n * - an absolute Node or entry that is not there, or that does not run: Claude\n * Code cannot start the router (the one required failure, where `router\n * server` fails too);\n * - otherwise ok, and the launcher a terminal needs is checked with it.\n */\nasync function runtimeCheck(i: {\n launch: PluginLaunch | null;\n state: RuntimeState | null;\n root: string;\n home: string;\n env: NodeJS.ProcessEnv;\n project: boolean;\n onPath: PathTenjin | null;\n /** This platform, when Tenjin pins no Node for it. */\n unpinned: string | null;\n deps: RouterDoctorDeps;\n}): Promise<RouterCheck> {\n const name = 'runtime';\n const flag = i.project ? ' --project' : '';\n const t = (p: string) => tilde(p, i.home);\n const failFix =\n RUNTIME_MISSING_FIX +\n (i.project\n ? ' For a project-only installation, pass `--project` to the installer from that project folder.'\n : '');\n const { launch } = i;\n const unread: RouterCheck = {\n name,\n status: 'warn',\n required: false,\n checked: false,\n detail: \"where Claude Code starts Tenjin from could not be read from the plugin's .mcp.json\",\n };\n if (launch === null) return unread;\n if (await pluginGone(launch, i.root)) {\n return {\n name,\n status: 'fail',\n required: true,\n detail: `Claude Code loads Tenjin from ${t(launch.path)}, which no longer holds its plugin, so the router cannot start`,\n fix: failFix,\n };\n }\n if (\n i.state !== null &&\n launch.source === 'marketplace' &&\n !(await samePath(launch.path, join(i.root, 'claude')))\n ) {\n return {\n name,\n status: 'warn',\n required: false,\n detail: `Claude Code loads Tenjin from ${t(launch.path)}, not Tenjin's runtime: an older tenjin-cli build registered it there`,\n fix: `Run \\`tenjin install${flag}\\`, then start a new Claude Code session.`,\n };\n }\n if (launch.command === null) return unread;\n if (launch.command === 'node' && i.unpinned !== null) {\n const from = launch.entry !== null ? ` at ${t(dirname(launch.entry))}` : '';\n return {\n name,\n status: 'warn',\n required: false,\n detail: `This older installation runs from npm's copy${from}; this platform (${i.unpinned}) does not support Tenjin's private runtime`,\n fix: 'Use macOS, Windows or glibc Linux 2.28+ on x64/arm64. This installation was left unchanged.',\n };\n }\n if (launch.command === 'node') {\n const from = launch.entry !== null ? `, from ${t(dirname(launch.entry))}` : '';\n return {\n name,\n status: 'warn',\n required: false,\n detail: `Claude Code starts Tenjin with the \\`node\\` on its PATH${from}, so a Node upgrade or \\`npm rm -g tenjin-cli\\` stops it`,\n fix: `Run \\`tenjin install${flag}\\` to move it to Tenjin's own runtime.`,\n };\n }\n const missing = [launch.command, ...(launch.entry !== null ? [launch.entry] : [])];\n const gone: string[] = [];\n for (const p of missing) if (!(await exists(p))) gone.push(t(p));\n if (launch.entry === null || gone.length > 0) {\n return {\n name,\n status: 'fail',\n required: true,\n detail:\n launch.entry === null\n ? `Claude Code starts Tenjin with ${t(launch.command)} and no entry script, so the router cannot start`\n : `Claude Code starts Tenjin with ${gone.join(' and ')}, which ${gone.length === 1 ? 'is' : 'are'} not there, so the router cannot start`,\n fix: failFix,\n };\n }\n const shown = `${t(launch.command)} ${t(launch.entry)} --version`;\n const run = await (i.deps.runVersion ?? runVersion)(launch.command, launch.entry);\n if (run.timedOut) {\n return {\n name,\n status: 'warn',\n required: false,\n checked: false,\n detail: `\\`${shown}\\` did not answer within 15 s`,\n };\n }\n if (run.code !== 0) {\n const said = (run.stderr || run.stdout).trim().slice(0, 200);\n return {\n name,\n status: 'fail',\n required: true,\n detail: `\\`${shown}\\` exited ${run.code ?? 'without a code'}${said.length > 0 ? `: ${said}` : ''}, so the router cannot start`,\n fix: failFix,\n };\n }\n const nodeVersion =\n /[\\\\/]node[\\\\/](\\d+\\.\\d+\\.\\d+)[\\\\/]/.exec(launch.command)?.[1] ??\n i.state?.current.node ??\n 'unknown';\n const from = runtimeBuild(dirname(launch.entry))?.root ?? i.root;\n const detail = `Claude Code starts tenjin ${run.stdout.trim()} on Node ${nodeVersion} from ${t(from)}`;\n // THE LAUNCHER A TERMINAL NEEDS once npm's copy is gone.\n const platform = process.platform;\n const launcher = join(launcherDir(i.home), platform === 'win32' ? 'tenjin.cmd' : 'tenjin');\n if (!(await exists(launcher))) {\n return {\n name,\n status: 'warn',\n required: false,\n detail: `${detail}; ${t(launcher)} is missing, so a terminal does not find Tenjin's \\`tenjin\\``,\n fix: `Run \\`tenjin install${flag}\\` to write it.`,\n };\n }\n // Off PATH is only worth a row when the terminal finds no `tenjin` at all: npm's\n // copy hands off to the runtime, and an old one gets its own row below.\n if (i.onPath === null && !launcherOnPath(launcherDir(i.home), i.env, platform)) {\n const { pathLine } = await import('../lib/runtime');\n return {\n name,\n status: 'warn',\n required: false,\n detail: `${detail}; ${t(launcherDir(i.home))} is not on your PATH, so a terminal does not find \\`tenjin\\` there`,\n fix: pathLine(i.env, i.home, platform),\n };\n }\n return {\n name,\n status: 'ok',\n required: true,\n detail: `${detail}; tenjin on PATH: ${t(i.onPath?.path ?? launcher)}`,\n };\n}\n\n/** Is `dir` on this environment's PATH, compared as `writeLaunchers` compares it? */\nfunction launcherOnPath(dir: string, env: NodeJS.ProcessEnv, platform: NodeJS.Platform): boolean {\n const p = platform === 'win32' ? win32 : posix;\n const norm = (value: string) => {\n const full = p.resolve(value).replace(/[\\\\/]+$/, '');\n return platform === 'win32' ? full.toLowerCase() : full;\n };\n const raw = (platform === 'win32' ? (env.Path ?? env.PATH) : env.PATH) ?? '';\n return raw\n .split(p.delimiter)\n .filter((entry) => entry.length > 0)\n .some((entry) => norm(entry) === norm(dir));\n}\n\n/**\n * THE FIRST `tenjin` ON PATH, and the package behind it: the nearest\n * `tenjin-cli` package above its realpath (npm's POSIX link), or\n * `node_modules/tenjin-cli` beside it (npm's Windows shim). A launcher Tenjin\n * wrote needs no package. One with no package identified (a Volta or pnpm\n * shim) is still the one a terminal runs, marked `unknown`. Null when there\n * is none.\n */\nexport async function findPathTenjin(\n env: NodeJS.ProcessEnv,\n platform: NodeJS.Platform = process.platform,\n): Promise<PathTenjin | null> {\n const raw = (platform === 'win32' ? (env.Path ?? env.PATH) : env.PATH) ?? '';\n const delimiter = platform === 'win32' ? win32.delimiter : posix.delimiter;\n const name = platform === 'win32' ? 'tenjin.cmd' : 'tenjin';\n for (const dir of raw.split(delimiter).filter((d) => d.length > 0)) {\n const path = join(dir, name);\n if ((await stat(path).catch(() => null))?.isFile() !== true) continue;\n const body = await readFile(path, 'utf8').catch(() => '');\n if (body.includes(LAUNCHER_MARKER))\n return { path, marked: true, version: null, handsOff: true };\n let root: string | null;\n if (platform === 'win32') root = join(dir, 'node_modules', 'tenjin-cli');\n else {\n const { packageRootOf } = await import('../lib/runtime');\n root = packageRootOf(dirname(await realpath(path).catch(() => path)));\n }\n // The first one on PATH is what a terminal runs, identified or not.\n const unknown = { path, marked: false, version: null, handsOff: false, unknown: true } as const;\n if (root === null) return unknown;\n const manifest = await readFile(join(root, 'package.json'), 'utf8')\n .then((t) => JSON.parse(t) as { name?: unknown; version?: unknown; tenjinRuntime?: unknown })\n .catch(() => null);\n if (manifest?.name !== 'tenjin-cli') return unknown;\n return {\n path,\n marked: false,\n version: typeof manifest.version === 'string' ? manifest.version : null,\n handsOff: manifest.tenjinRuntime !== undefined,\n };\n }\n return null;\n}\n\n/** An older npm copy a terminal runs instead of Tenjin's runtime, named; nothing else. */\nfunction pathTenjinCheck(found: PathTenjin | null, home: string): RouterCheck | null {\n if (found === null || found.marked || found.handsOff || found.unknown === true) return null;\n return {\n name: 'tenjin on PATH',\n status: 'warn',\n required: false,\n detail: `\\`tenjin\\` in a terminal runs tenjin-cli ${found.version ?? '(unknown version)'} at ${tilde(found.path, home)}, an older build that does not hand off to Tenjin's runtime`,\n fix: 'Remove it with `npm uninstall -g tenjin-cli` using the Node that installed it, or upgrade it with `npm i -g tenjin-cli@latest`.',\n };\n}\n\n/**\n * A settings install of an earlier release: what is left, and whether the\n * next `tenjin install` or `tenjin update` removes it. Never a failure, and\n * never written here.\n */\nasync function migrationCheck(\n legacy: LegacyInstall,\n claude: ClaudeCodeState,\n dataDir: string,\n env: NodeJS.ProcessEnv,\n cwd: string,\n): Promise<RouterCheck> {\n const name = 'settings install';\n if (legacy.unreadable !== undefined) {\n return { name, status: 'warn', required: false, detail: legacy.unreadable };\n }\n const parts = [\n ...(legacy.events.length > 0 ? [`hook entries (${legacy.events.join(', ')})`] : []),\n ...(legacy.allowRule || legacy.denyRule ? ['permission rules'] : []),\n ...(legacy.statusLine === 'ours' || legacy.statusLine === 'composed' ? ['a status line'] : []),\n ...(legacy.mcp === 'ok' ? ['the x402 MCP server'] : []),\n ];\n const found = `${parts.join(', ')} from an earlier release in ${legacy.settingsPath}`;\n const lookalikes =\n legacy.lookalikes.length > 0\n ? `; not Tenjin's and left alone: ${legacy.lookalikes.join(', ')}`\n : '';\n const proof = await pluginProof(claude, dataDir, env, cwd);\n return proof.proven\n ? {\n name,\n status: 'warn',\n required: false,\n detail: `${found}, ready to remove: the plugin has loaded here${lookalikes}`,\n fix: 'Run `tenjin install --refresh` to remove it.',\n }\n : {\n name,\n status: 'warn',\n required: false,\n detail: `${found}, kept until the plugin loads: ${proof.reason}${lookalikes}`,\n fix: claude.meetsFloor\n ? `To load the plugin, ${NEW_SESSION_STEP}; the next \\`tenjin install\\` or \\`tenjin update\\` then removes the old entries.`\n : 'Run `claude update`, then `tenjin install`: until then the old entries keep routing.',\n };\n}\n\n/**\n * WIRED BUT SWITCHED OFF is a choice, not a fault, so it warns and names the\n * file that made it.\n */\nfunction routingCheck(router: RouterSettings | Error): RouterCheck {\n const name = 'routing';\n if (router instanceof Error) {\n return {\n name,\n status: 'warn',\n required: false,\n detail: `the router is off here: ${router.message}`,\n fix: 'Fix or delete that file.',\n };\n }\n if (!router.enabled.value) {\n const file = router.enabled.path ?? 'the config';\n return {\n name,\n status: 'warn',\n required: false,\n detail: `router.enabled is false in ${file}, so nothing is routed from this directory`,\n fix:\n router.enabled.source === 'file'\n ? 'Run `tenjin config set router.enabled true` to route again.'\n : `Remove router.enabled from ${file} to route here again.`,\n };\n }\n return { name, status: 'ok', required: false, detail: 'on' };\n}\n\n/** The unlock reasons a routing-fee row words from WALLET_REASONS, with the PERSON fix (decision 15). */\nconst UNLOCK_WHY: ReadonlySet<string> = new Set([\n 'wallet_corrupt',\n 'env_key_invalid',\n 'passphrase_missing',\n 'passphrase_wrong',\n 'env_passphrase_wrong',\n 'keychain_locked',\n 'wallet_locked',\n]);\n\n/**\n * THE ROUTING FEE, AS THE NEXT PAID CALL WOULD MEET IT: `canPayRouting`, the\n * verdict the payer and the hooks reach on the same facts, in TODAY'S words\n * (S5). Never a failure: a call the fee cannot pay takes the free path.\n *\n * - ready: today's ok row, byte for byte;\n * - blocked by money or policy: today's `unpaid` detail, and today's fix\n * (`fixes[why]`, else fee.ts's own);\n * - blocked because the wallet cannot sign: the WALLET_REASONS fragment and\n * the verdict's PERSON fix, never `agentFix`: doctor is read by a person;\n * - unknown (a balance or a keychain that did not answer): \"could not check\",\n * never ok, never a fix.\n */\nexport function routingFeeRow(e: Pick<Eligibility, 'canPayRouting'>, host: string): RouterCheck {\n const name = 'routing fee';\n const v = e.canPayRouting;\n if (v.status === 'unknown') {\n return {\n name,\n status: 'warn',\n required: false,\n checked: false,\n detail: `could not check: ${v.detail}`,\n };\n }\n if (v.status === 'ready') {\n return {\n name,\n status: 'ok',\n required: false,\n detail: `$${usd(ROUTING_FEE_ATOMIC)} a call, paid from channel deposits of up to $${usd(CHANNEL_DEPOSIT_ATOMIC)} that count against the spend limits`,\n };\n }\n const why = v.reason;\n if (UNLOCK_WHY.has(why)) {\n return {\n name,\n status: 'warn',\n required: false,\n detail: `${WALLET_REASONS[why as keyof typeof WALLET_REASONS].reason}, so Tenjin is not routing calls`,\n fix: v.fix,\n };\n }\n const u = unpaid(why);\n const fixes: Record<string, string> = {\n no_wallet: `Run \\`tenjin wallet create\\`, then \\`tenjin wallet fund ${SUGGESTED_FUND_USD}\\`.`,\n limit_below_deposit: `Raise it with \\`tenjin config set maxAutoSpend ${usd(CHANNEL_DEPOSIT_ATOMIC)}\\`.`,\n budget_reached:\n 'Room comes back as the rolling day passes, or raise it with `tenjin config set sessionBudget <usd>`.',\n not_allowlisted: `Add ${host} to allowlistCreators, or clear the allowlist.`,\n };\n return {\n name,\n status: 'warn',\n required: false,\n detail: `${u?.reason ?? v.detail}, so Tenjin is not routing calls`,\n fix: fixes[why] ?? u?.fix ?? v.fix,\n };\n}\n\n/** INFORMATIONAL: which experiment is on, in one line. Either state passes. */\nfunction experimentalCheck(bazaar: boolean): RouterCheck {\n return {\n name: 'experimental',\n status: 'ok',\n required: false,\n detail: bazaar\n ? 'list: on; bazaar: on (experimental): the router may also suggest unreviewed sellers from the open x402 Bazaar'\n : 'list: on; bazaar: off (experimental): `tenjin config set experimental.bazaar on` to add the open x402 Bazaar',\n };\n}\n\n/**\n * The two limits: the daily budget is the control, the per-call ceiling the\n * runaway guard. A per-call limit an earlier release left below $0.25 shows\n * on the routing-fee row, which names the deposit it refuses.\n */\nfunction spendCheck(maxAutoSpendAtomic: bigint, sessionBudgetAtomic: bigint | null): RouterCheck {\n if (sessionBudgetAtomic === 0n) {\n return {\n name: 'spend',\n status: 'fail',\n required: true,\n detail: 'The daily limit is 0, so positive payments are refused even with --yes.',\n fix: 'Choose a daily limit with `tenjin config set sessionBudget <usd|none>`.',\n };\n }\n if (maxAutoSpendAtomic === 0n) {\n return {\n name: 'spend',\n status: 'fail',\n required: true,\n detail: 'maxAutoSpend is 0, so every lookup needs approval and none can pay',\n fix: `Raise it with \\`tenjin config set maxAutoSpend ${usd(CHANNEL_DEPOSIT_ATOMIC)}\\`.`,\n };\n }\n const budget =\n sessionBudgetAtomic === null\n ? 'no daily ceiling'\n : `${toMoney(sessionBudgetAtomic.toString()).usd} USD a day`;\n return {\n name: 'spend',\n status: sessionBudgetAtomic === null ? 'warn' : 'ok',\n required: false,\n detail: `automatic approval up to ${toMoney(maxAutoSpendAtomic.toString()).usd} USD a call, ${budget}`,\n ...(sessionBudgetAtomic === null\n ? { fix: 'Set one with `tenjin config set sessionBudget 1.00`.' }\n : {}),\n };\n}\n\n/** Where a ready wallet's passphrase (or key) came from, as the wallet row says it;\n * the passphrase file under `dataDir`, which `TENJIN_DATA_DIR` moves. */\nfunction signedFrom(source: SigningSource, address: string, dataDir: string): string {\n switch (source) {\n case 'keychain':\n return 'macOS keychain';\n case 'secret-service':\n return 'Linux keyring';\n case 'dpapi':\n return 'DPAPI file';\n case 'file':\n return `passphrase file ${describeStoreLocation('file', address.toLowerCase(), dataDir)}`;\n case 'key-env':\n return 'TENJIN_WALLET_KEY in this shell';\n case 'passphrase-env':\n return 'TENJIN_WALLET_PASSPHRASE in this shell';\n case 'legacy':\n return 'legacy keychain entry';\n }\n}\n\n/** The unlock reasons a wallet row warns about with the WALLET_REASONS person fix. */\nconst WARN_UNLOCK: ReadonlySet<string> = new Set<UnlockReason>([\n 'passphrase_missing',\n 'passphrase_wrong',\n 'env_passphrase_wrong',\n 'wallet_corrupt',\n]);\n\n/**\n * THE WALLET ROW: can this shell's wallet SIGN, and with what.\n *\n * Exit codes keep their meaning (S11): no wallet, a wallet.json `describe`\n * cannot read, and an invalid TENJIN_WALLET_KEY fail as required, exactly as\n * before. A wallet that is there but cannot be unlocked only warns: lookups\n * still run on the free path, and the fix is a person's, never `agentFix`\n * (decision 15), never \"set TENJIN_WALLET_PASSPHRASE\" and never the plaintext\n * file (B1, S3). A check that could not answer is said as not checked.\n */\nexport function walletRow(e: Eligibility, dataDir: string): RouterCheck {\n const name = 'wallet';\n const sign = e.canSign;\n if (e.describeError !== null && e.describeError !== undefined) {\n const err = e.describeError;\n return {\n name,\n status: 'fail',\n required: true,\n detail: err instanceof CliError ? err.message : String(err),\n ...(err instanceof CliError && err.fix !== undefined ? { fix: err.fix } : {}),\n };\n }\n if (sign.status === 'blocked' && sign.reason === 'no_wallet') {\n return {\n name,\n status: 'fail',\n required: true,\n detail: 'no wallet on this machine, so nothing can pay',\n fix: `Run \\`tenjin wallet create\\`, then \\`tenjin wallet fund ${SUGGESTED_FUND_USD}\\`.`,\n };\n }\n if (sign.status === 'blocked' && sign.reason === 'env_key_invalid') {\n return { name, status: 'fail', required: true, detail: sign.detail, fix: sign.fix };\n }\n const address = e.address ?? 'the wallet';\n if (sign.status === 'ready') {\n if (sign.warning !== undefined) {\n return {\n name,\n status: 'warn',\n required: false,\n detail: `${address} unlocks with the saved passphrase; TENJIN_WALLET_PASSPHRASE is set but wrong`,\n fix: 'Remove it from this shell and your shell profile: `unset TENJIN_WALLET_PASSPHRASE`.',\n };\n }\n return {\n name,\n status: 'ok',\n required: true,\n detail:\n sign.source !== undefined\n ? `${address} unlocks without a prompt (${signedFrom(sign.source, address, dataDir)})`\n : `${address} unlocks without a prompt`,\n };\n }\n if (sign.status === 'blocked') {\n const fix = WARN_UNLOCK.has(sign.reason)\n ? WALLET_REASONS[sign.reason as keyof typeof WALLET_REASONS].fix\n : sign.fix;\n return {\n name,\n status: 'warn',\n required: false,\n detail: `${address} cannot be unlocked: ${sign.detail}`,\n fix,\n };\n }\n return {\n name,\n status: 'warn',\n required: false,\n checked: false,\n detail: `could not check whether ${address} unlocks: ${sign.detail}`,\n ...(sign.reason === 'keychain_locked' ? { fix: KEYCHAIN_LOCKED_FIX } : {}),\n };\n}\n\n/** The S7 repair fix: the person saves the passphrase where every Claude Code can read it. */\nconst SAVE_FOR_EVERY_SESSION_FIX = `Run \\`tenjin wallet repair\\` yourself to save the passphrase where every Claude Code can read it ${REPAIR_CLAUSE}.`;\n\n/** `HH:MM`, local time, for a router's start. */\nfunction clock(ms: number): string {\n return new Date(ms).toTimeString().slice(0, 5);\n}\n\n/**\n * THE `claude session` ROW: what the router a running Claude Code started saw\n * when it tried to unlock this wallet, read from the observation it wrote.\n * Doctor's own shell is not that session: its environment, its PATH and its\n * keychain answer can all differ, which is the whole point of this row.\n *\n * Only a router that has served a Claude hook counts (B2): one started by\n * `claude mcp get` or `list`, a Codex one, or one prewarmed with no hook\n * served yet, is not \"the running Claude session\" and is ignored.\n *\n * With none, the row says what this shell alone can say, and is not checked,\n * except in the one case it can say more (S7): this shell signs only through\n * TENJIN_WALLET_PASSPHRASE and the saved stores DEFINITELY do not open the\n * wallet, so a Claude Code started without the variable cannot unlock it. An\n * unknown saved-store answer (a locked keychain) makes no such claim.\n *\n * Never a failure, and never new routing-fee wording (S5): the routing-fee\n * row says that.\n */\nexport function sessionRow(\n shell: Eligibility,\n live: RouterObservation[],\n version: string = pkg.version,\n): RouterCheck {\n const name = 'claude session';\n // At this version first, then the most recent: the router the next lookup most likely meets.\n const served = [...servedObservations(live)].sort(\n (a, b) =>\n Number(b.cliVersion === version) - Number(a.cliVersion === version) ||\n b.startedAt - a.startedAt,\n );\n if (served.length === 0) {\n const shellReady = shell.canSign.status === 'ready' && shell.canPayRouting.status === 'ready';\n const detail = shellReady ? NO_SESSION_CHECKED : 'no running Claude session checked';\n if (\n shell.source === 'passphrase-env' &&\n shell.savedSign !== null &&\n isDefiniteBlock(shell.savedSign)\n ) {\n return {\n name,\n status: 'warn',\n required: false,\n detail: `${detail}, and a Claude Code started without TENJIN_WALLET_PASSPHRASE cannot unlock the wallet`,\n fix: SAVE_FOR_EVERY_SESSION_FIX,\n };\n }\n return {\n name,\n status: 'warn',\n required: false,\n checked: false,\n detail,\n ...(shell.source === 'key-env'\n ? { fix: 'Start Claude Code from a shell that sets TENJIN_WALLET_KEY.' }\n : {}),\n };\n }\n\n const blocked = served.find((o) => o.sign.status === 'blocked');\n if (blocked !== undefined) {\n const reason = blocked.sign.reason ?? '';\n const wallet = Object.prototype.hasOwnProperty.call(WALLET_REASONS, reason)\n ? WALLET_REASONS[reason as keyof typeof WALLET_REASONS]\n : undefined;\n const detail = blocked.sign.detail ?? wallet?.reason ?? reason;\n const fix = wallet?.fix ?? blocked.sign.fix;\n return {\n name,\n status: 'warn',\n required: false,\n detail: `the router Claude Code started (pid ${blocked.pid}) cannot unlock the wallet: ${detail}`,\n ...(fix !== undefined ? { fix } : {}),\n };\n }\n\n const here = shell.address?.toLowerCase() ?? null;\n const other = served.find(\n (o) => o.address !== null && here !== null && o.address.toLowerCase() !== here,\n );\n if (other !== undefined) {\n return {\n name,\n status: 'warn',\n required: false,\n detail: `Claude Code's router uses ${other.address}, this shell ${shell.address}`,\n };\n }\n\n const waiting = served.find((o) => o.sign.status !== 'ready');\n if (waiting !== undefined) {\n const why =\n waiting.sign.status === 'pending'\n ? 'it has not tried to unlock yet'\n : (waiting.sign.detail ??\n UNKNOWN_DETAIL[waiting.sign.reason ?? ''] ??\n UNKNOWN_DETAIL['check_failed']!);\n return {\n name,\n status: 'warn',\n required: false,\n checked: false,\n detail: `could not check whether the router Claude Code started (pid ${waiting.pid}) unlocks the wallet: ${why}`,\n };\n }\n\n const o = served[0]!;\n return {\n name,\n status: 'ok',\n required: false,\n detail: `the router Claude Code started (pid ${o.pid}, since ${clock(o.startedAt)}, v${o.cliVersion}) unlocked ${o.address ?? shell.address ?? 'the wallet'}`,\n };\n}\n","import { evaluateSpendPolicy, type SpendPolicy } from '../lib/policy';\nimport { readSpendSummary, spentOf } from '../lib/spend-ledger';\nimport { readUsdcBalance } from '../lib/usdc-balance';\nimport { describeWallet } from '../lib/wallet';\nimport type { WalletProvider, WalletVerification } from '../lib/wallet/provider';\nimport { readWalletFacts, type WalletFacts } from '../lib/wallet-facts';\nimport type { SigningSource } from '../lib/wallet-unlock';\nimport { channelCredit } from './channel-credit';\nimport {\n canPayRouting,\n canSign as canSignFrom,\n signFromVerification,\n type SignVerdict,\n type Verdict,\n} from './eligibility';\nimport { CHANNEL_DEPOSIT_ATOMIC, feeRefusal, refusedWhy } from './fee';\nimport { UNKNOWN_DETAIL } from './wallet-reasons';\n\n/**\n * THE WHOLE ELIGIBILITY PICTURE FOR ONE SHELL, for `tenjin doctor`: gather the\n * facts with real I/O (the wallet files, a no-prompt verify, the spend ledger,\n * the routing channel, the chain balance), then decide with the pure rules in\n * `eligibility.ts`, so doctor's verdict is the payer's and the hooks' verdict\n * on the same facts.\n *\n * NOT hook-safe: it loads the wallet layer and the x402 channel storage. No\n * hook imports it, and nothing but doctor needs it (install checks signing\n * with `verify` alone and leaves funding as it is; S6).\n */\nexport interface EligibilityInput {\n dataDir: string;\n env: NodeJS.ProcessEnv;\n policy: SpendPolicy;\n rpcUrl: string;\n /** The router's host (the creator a deposit pays). */\n host: string;\n timeoutMs: number;\n /** null when there is no wallet file and no TENJIN_WALLET_KEY. */\n provider: WalletProvider | null;\n /** S7: verify with TENJIN_WALLET_PASSPHRASE removed from the env (a provider built from that env). Called first,\n * only when the variable is set and TENJIN_WALLET_KEY is not valid. Doctor supplies it; absent = today's single verify. */\n verifySaved?: () => Promise<WalletVerification | undefined>;\n fetchImpl?: typeof fetch;\n readBalance?: (\n address: string,\n rpcUrl: string,\n o: { timeoutMs: number; fetchImpl?: typeof fetch },\n ) => Promise<bigint | null>;\n readCredit?: (dataDir: string, address: string) => Promise<bigint>;\n readSpent?: (dataDir: string) => Promise<bigint>;\n}\n\nexport interface Eligibility {\n address: string | null;\n source: SigningSource | null;\n warning?: string;\n canSign: SignVerdict;\n canPayRouting: Verdict;\n /** S7: the verdict with TENJIN_WALLET_PASSPHRASE removed (verifySaved). null when it was not run. */\n savedSign: SignVerdict | null;\n balanceAtomic: bigint | null;\n creditAtomic: bigint | null;\n /** S11: what describeWallet(provider) rejected with (a corrupt wallet.json, an invalid key). Doctor keeps today's\n * required fail for it, so exit codes do not change. null when describe succeeded or there is no provider. */\n describeError: unknown | null;\n}\n\n/** An unknown verdict worded from UNKNOWN_DETAIL. */\nfunction unknownSign(reason: 'check_failed' | 'not_checked'): SignVerdict {\n return { status: 'unknown', reason, detail: UNKNOWN_DETAIL[reason]! };\n}\n\n/** The spent total the deposit is evaluated against: the ledger as an\n * authorization would see it, and nothing for an absent one. */\nasync function defaultReadSpent(dataDir: string): Promise<bigint> {\n const ledger = await readSpendSummary(dataDir);\n return ledger === null ? 0n : spentOf(ledger);\n}\n\n/**\n * Check what this shell's wallet can do. Never rejects: every step that can\n * fail is caught and becomes an unknown or a null, and the balance is read\n * even when signing is blocked (the address is cleartext, and \"locked AND\n * empty\" is two things to fix, not one).\n */\nexport async function checkEligibility(input: EligibilityInput): Promise<Eligibility> {\n let facts: WalletFacts | null = null;\n try {\n facts = await readWalletFacts(input.dataDir, input.env);\n return await check(input, facts);\n } catch {\n const failed = unknownSign('check_failed');\n return {\n address: facts?.address ?? null,\n source: null,\n canSign: failed,\n canPayRouting: failed,\n savedSign: null,\n balanceAtomic: null,\n creditAtomic: null,\n describeError: null,\n };\n }\n}\n\nasync function check(input: EligibilityInput, facts: WalletFacts): Promise<Eligibility> {\n const { provider } = input;\n let address = facts.address;\n let describeError: unknown | null = null;\n if (provider !== null) {\n try {\n address = (await describeWallet(provider)).address;\n } catch (err) {\n // S11: kept for doctor, which fails it as required exactly as today.\n describeError = err;\n }\n }\n\n const { sign, savedSign } = await signing(input, facts, describeError);\n const source = sign.status === 'ready' ? (sign.source ?? null) : null;\n\n const [spent, creditAtomic, balanceAtomic] = await Promise.all([\n (input.readSpent ?? defaultReadSpent)(input.dataDir).catch(() => null),\n address === null\n ? Promise.resolve(null)\n : (input.readCredit ?? channelCredit)(input.dataDir, address).catch(() => null),\n address === null\n ? Promise.resolve(null)\n : (input.readBalance ?? readUsdcBalance)(address, input.rpcUrl, {\n timeoutMs: input.timeoutMs,\n ...(input.fetchImpl !== undefined ? { fetchImpl: input.fetchImpl } : {}),\n }).catch(() => null),\n ]);\n\n // The deposit is always the full $0.25 and meets the whole policy once, as\n // the payer's `depositStrategy` meets it; an unreadable ledger counts as\n // nothing spent, as an absent one does.\n const deposit = evaluateSpendPolicy(input.policy, {\n mode: 'automatic',\n amountAtomic: CHANNEL_DEPOSIT_ATOMIC,\n creator: input.host,\n sessionSpentAtomic: spent ?? 0n,\n });\n const routing = canPayRouting({\n feeRefusal: feeRefusal(input.policy, input.host),\n sign,\n creditAtomic,\n depositRefusal: deposit.decision === 'allow' ? null : refusedWhy(deposit.reason),\n balanceAtomic,\n });\n\n return {\n address,\n source,\n ...(sign.status === 'ready' && sign.warning !== undefined ? { warning: sign.warning } : {}),\n canSign: sign,\n canPayRouting: routing,\n savedSign,\n balanceAtomic,\n creditAtomic,\n describeError,\n };\n}\n\n/**\n * The sign verdict, and S7's saved-passphrase verdict beside it.\n *\n * SAVED PASSPHRASE FIRST (S7, decision 19). With TENJIN_WALLET_PASSPHRASE set,\n * `verifySaved` asks whether the keychain or file opens the wallet WITHOUT the\n * variable, so a passphrase both hold is reported as that store, not as\n * `passphrase-env`, and doctor can say whether a Claude Code started without\n * the variable could sign. The full verify still runs after it, because only\n * the full env can see that the variable is wrong (ready with a warning).\n */\nasync function signing(\n input: EligibilityInput,\n facts: WalletFacts,\n describeError: unknown | null,\n): Promise<{ sign: SignVerdict; savedSign: SignVerdict | null }> {\n const { provider } = input;\n if (facts.envKey === 'malformed') {\n return {\n sign: canSignFrom({ envKey: 'malformed', walletFile: facts.walletFile }),\n savedSign: null,\n };\n }\n if (provider === null) {\n return { sign: canSignFrom({ envKey: 'absent', walletFile: 'absent' }), savedSign: null };\n }\n if (describeError !== null) return { sign: unknownSign('check_failed'), savedSign: null };\n\n let savedSign: SignVerdict | null = null;\n if (facts.envPassphraseSet && facts.envKey !== 'valid' && input.verifySaved !== undefined) {\n savedSign = await input\n .verifySaved()\n .then((v) => signFromVerification(v))\n .catch(() => unknownSign('check_failed'));\n }\n\n let full: SignVerdict;\n if (provider.verify === undefined) {\n full = unknownSign('not_checked');\n } else {\n full = await provider\n .verify()\n .then((v) => signFromVerification(v))\n .catch(() => unknownSign('check_failed'));\n }\n\n let sign = full;\n if (full.status === 'ready') {\n const source: SigningSource | undefined =\n facts.envKey === 'valid'\n ? 'key-env'\n : savedSign?.status === 'ready'\n ? savedSign.source\n : full.source;\n sign = {\n status: 'ready',\n ...(source !== undefined ? { source } : {}),\n ...(full.warning !== undefined ? { warning: full.warning } : {}),\n };\n } else if (\n facts.envPassphraseSet &&\n full.status === 'blocked' &&\n full.reason === 'passphrase_missing'\n ) {\n // S13: a set variable is a passphrase source, so \"none reachable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