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,7 +1,7 @@
|
|
|
1
1
|
import { createRequire as __tenjinCreateRequire } from 'node:module'; const require = __tenjinCreateRequire(import.meta.url);
|
|
2
2
|
import {
|
|
3
3
|
CliError
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-DI4QAGRZ.js";
|
|
5
5
|
|
|
6
6
|
// src/lib/destination.ts
|
|
7
7
|
import { lookup } from "node:dns/promises";
|
|
@@ -43,6 +43,37 @@ function isPublicAddress(value) {
|
|
|
43
43
|
if (kind === 4) return !blockedV4.check(value, "ipv4");
|
|
44
44
|
return kind === 6 && /^[23]/i.test(value) && !blockedV6.check(value, "ipv6");
|
|
45
45
|
}
|
|
46
|
+
var loopbackNet = new BlockList();
|
|
47
|
+
loopbackNet.addSubnet("127.0.0.0", 8, "ipv4");
|
|
48
|
+
loopbackNet.addAddress("::1", "ipv6");
|
|
49
|
+
var privateNet = new BlockList();
|
|
50
|
+
for (const [base, prefix] of [
|
|
51
|
+
["10.0.0.0", 8],
|
|
52
|
+
["172.16.0.0", 12],
|
|
53
|
+
["192.168.0.0", 16]
|
|
54
|
+
]) {
|
|
55
|
+
privateNet.addSubnet(base, prefix, "ipv4");
|
|
56
|
+
}
|
|
57
|
+
privateNet.addSubnet("fc00::", 7, "ipv6");
|
|
58
|
+
var metadataV6 = new BlockList();
|
|
59
|
+
metadataV6.addAddress("fd00:ec2::254", "ipv6");
|
|
60
|
+
var familyOf = (address) => isIP(address) === 6 ? "ipv6" : "ipv4";
|
|
61
|
+
var isLoopbackAddress = (address) => isIP(address) !== 0 && loopbackNet.check(address, familyOf(address));
|
|
62
|
+
var isPrivateAddress = (address) => isIP(address) !== 0 && privateNet.check(address, familyOf(address)) && !metadataV6.check(address, familyOf(address));
|
|
63
|
+
function inReach(address, allow) {
|
|
64
|
+
if (isPublicAddress(address)) return true;
|
|
65
|
+
if (allow === "loopback") return isLoopbackAddress(address);
|
|
66
|
+
if (allow === "private") return isPrivateAddress(address);
|
|
67
|
+
return false;
|
|
68
|
+
}
|
|
69
|
+
function isLoopbackHost(hostname) {
|
|
70
|
+
const host = hostname.replace(/^\[|\]$/g, "").toLowerCase();
|
|
71
|
+
return host === "localhost" || isLoopbackAddress(host);
|
|
72
|
+
}
|
|
73
|
+
function addressClassOf(hostname) {
|
|
74
|
+
if (isLoopbackHost(hostname)) return "loopback";
|
|
75
|
+
return isPrivateAddress(hostname.replace(/^\[|\]$/g, "")) ? "private" : "public";
|
|
76
|
+
}
|
|
46
77
|
var LOCAL_SUFFIX = /(?:^|\.)(?:localhost|local|internal|home|lan)$/i;
|
|
47
78
|
function refuse(message, details) {
|
|
48
79
|
throw new CliError("USAGE", message, {
|
|
@@ -50,20 +81,23 @@ function refuse(message, details) {
|
|
|
50
81
|
...details !== void 0 ? { details } : {}
|
|
51
82
|
});
|
|
52
83
|
}
|
|
53
|
-
function assertPublicHttpsUrl(raw) {
|
|
84
|
+
function assertPublicHttpsUrl(raw, allow) {
|
|
54
85
|
let url;
|
|
55
86
|
try {
|
|
56
87
|
url = new URL(raw);
|
|
57
88
|
} catch {
|
|
58
89
|
return refuse(`Invalid URL: ${JSON.stringify(raw.slice(0, 200))}`);
|
|
59
90
|
}
|
|
60
|
-
|
|
91
|
+
const host = url.hostname.replace(/^\[|\]$/g, "");
|
|
92
|
+
const local = allow === "loopback" && isLoopbackHost(host);
|
|
93
|
+
if (!(url.protocol === "https:" || url.protocol === "http:" && local) || url.username !== "" || url.password !== "" || url.hash !== "" || allow === void 0 && url.port !== "" && url.port !== "443" || raw.length > 16384) {
|
|
61
94
|
refuse("Only public HTTPS endpoints without credentials, fragments or custom ports are paid.");
|
|
62
95
|
}
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
96
|
+
if (!(local && host === "localhost")) {
|
|
97
|
+
if (!host.includes(".") && isIP(host) === 0) refuse("The endpoint host is not a public name.");
|
|
98
|
+
if (LOCAL_SUFFIX.test(host)) refuse("Private or local destinations are not paid.");
|
|
99
|
+
}
|
|
100
|
+
if (isIP(host) !== 0 && !inReach(host, allow)) {
|
|
67
101
|
refuse("Private or reserved IP destinations are not paid.");
|
|
68
102
|
}
|
|
69
103
|
return url;
|
|
@@ -72,7 +106,7 @@ async function assertPublicDestination(raw, options = {}) {
|
|
|
72
106
|
return (await resolvePublicDestination(raw, options)).url;
|
|
73
107
|
}
|
|
74
108
|
async function resolvePublicDestination(raw, options = {}) {
|
|
75
|
-
const url = assertPublicHttpsUrl(raw);
|
|
109
|
+
const url = assertPublicHttpsUrl(raw, options.allow);
|
|
76
110
|
const host = url.hostname.replace(/^\[|\]$/g, "");
|
|
77
111
|
if (isIP(host) !== 0) return { url, address: host, family: isIP(host) === 6 ? 6 : 4 };
|
|
78
112
|
const resolve = options.resolveHostname ?? ((name) => lookup(name, { all: true }));
|
|
@@ -92,7 +126,8 @@ async function resolvePublicDestination(raw, options = {}) {
|
|
|
92
126
|
cause: err instanceof Error ? err.message : String(err)
|
|
93
127
|
});
|
|
94
128
|
}
|
|
95
|
-
|
|
129
|
+
const fits = (address) => url.protocol === "http:" ? isLoopbackAddress(address) : inReach(address, options.allow);
|
|
130
|
+
if (addresses.length === 0 || addresses.some((entry) => !fits(entry.address))) {
|
|
96
131
|
refuse(`The endpoint host ${host} resolves to a private or unsupported network address.`);
|
|
97
132
|
}
|
|
98
133
|
const first = addresses[0];
|
|
@@ -101,8 +136,10 @@ async function resolvePublicDestination(raw, options = {}) {
|
|
|
101
136
|
|
|
102
137
|
export {
|
|
103
138
|
isPublicAddress,
|
|
139
|
+
isLoopbackHost,
|
|
140
|
+
addressClassOf,
|
|
104
141
|
assertPublicHttpsUrl,
|
|
105
142
|
assertPublicDestination,
|
|
106
143
|
resolvePublicDestination
|
|
107
144
|
};
|
|
108
|
-
//# sourceMappingURL=chunk-
|
|
145
|
+
//# sourceMappingURL=chunk-DIH2G3YG.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/lib/destination.ts"],"sourcesContent":["import { lookup } from 'node:dns/promises';\nimport { BlockList, isIP } from 'node:net';\nimport { CliError } from './errors';\n\n/**\n * Where this CLI is willing to send a paid request. Shared, so the router's\n * provider call and `tenjin pay` answer the question the same way.\n *\n * TWO CHECKS, BOTH NEEDED. The lexical one refuses a URL shape that cannot be a\n * public endpoint (a scheme, credentials, a fragment, a literal private\n * address). The DNS one refuses a public-looking NAME that resolves onto the\n * local network, which is the shape a hostile registry listing or a hostile\n * routing decision would take.\n *\n * WHAT IT IS NOT. A resolved address is checked, NOT PINNED. `fetch` resolves\n * the name again on its own, so a host that answers publicly here and privately\n * a moment later is not closed by this, and neither is a remote scraper\n * following its own redirects on its own server. Closing the first needs a\n * transport that connects to the address it validated (`node:https` with a\n * `lookup` override, as the draft experiment's `safeHttpsTransport` did), which\n * the plan for this release left unported for the paid leg. The router's media\n * download, a job's poll and a connected account's requests to a host its\n * server named do connect that way: each pins its socket to the address\n * {@link resolvePublicDestination} validated (`router/paid.ts`'s\n * `pinnedHttp`). What this does remove\n * is the easy local target: `http://`, credentials, a custom port, a literal\n * private address, a `.localhost`/`.internal` name, and a public name whose\n * only answers are private. Documented in docs/safety-model.md as a bound.\n *\n * AN ACCOUNT'S REACH ({@link DestinationOptions.allow}) is wider, for the user's\n * own servers (`router/accounts/fetch.ts`): any port, and besides public\n * addresses either this machine's loopback, where `http` is taken too, or the\n * private network. Link-local addresses (cloud metadata among them) are never\n * reached, whatever the reach.\n */\n\nconst blockedV4 = new BlockList();\nfor (const [base, prefix] of [\n ['0.0.0.0', 8],\n ['10.0.0.0', 8],\n ['100.64.0.0', 10],\n ['127.0.0.0', 8],\n ['169.254.0.0', 16],\n ['172.16.0.0', 12],\n ['192.0.0.0', 24],\n ['192.0.2.0', 24],\n ['192.168.0.0', 16],\n ['198.18.0.0', 15],\n ['198.51.100.0', 24],\n ['203.0.113.0', 24],\n ['224.0.0.0', 4],\n ['240.0.0.0', 4],\n] as const) {\n blockedV4.addSubnet(base, prefix, 'ipv4');\n}\n\nconst blockedV6 = new BlockList();\nfor (const [base, prefix] of [\n ['::', 128],\n ['::1', 128],\n ['64:ff9b::', 96],\n ['100::', 64],\n ['2001:db8::', 32],\n ['fc00::', 7],\n ['fe80::', 10],\n ['ff00::', 8],\n] as const) {\n blockedV6.addSubnet(base, prefix, 'ipv6');\n}\n\n/** Is this literal address one a paid request may be sent to? IPv6 additionally\n * has to sit in the globally routable 2000::/3 range. */\nexport function isPublicAddress(value: string): boolean {\n const kind = isIP(value);\n if (kind === 4) return !blockedV4.check(value, 'ipv4');\n return kind === 6 && /^[23]/i.test(value) && !blockedV6.check(value, 'ipv6');\n}\n\n/**\n * Which addresses an account request may reach besides public ones: none,\n * this machine's loopback, or the private network, never both. A server on\n * this machine is not let name a host on the network, nor one on the network\n * a host on this machine.\n */\nexport type AddressClass = 'public' | 'loopback' | 'private';\n\nconst loopbackNet = new BlockList();\nloopbackNet.addSubnet('127.0.0.0', 8, 'ipv4');\nloopbackNet.addAddress('::1', 'ipv6');\n\nconst privateNet = new BlockList();\nfor (const [base, prefix] of [\n ['10.0.0.0', 8],\n ['172.16.0.0', 12],\n ['192.168.0.0', 16],\n] as const) {\n privateNet.addSubnet(base, prefix, 'ipv4');\n}\nprivateNet.addSubnet('fc00::', 7, 'ipv6');\n/** Inside fc00::/7 and still never reached: AWS's IPv6 instance metadata. */\nconst metadataV6 = new BlockList();\nmetadataV6.addAddress('fd00:ec2::254', 'ipv6');\n\nconst familyOf = (address: string) => (isIP(address) === 6 ? 'ipv6' : 'ipv4');\nconst isLoopbackAddress = (address: string) =>\n isIP(address) !== 0 && loopbackNet.check(address, familyOf(address));\nconst isPrivateAddress = (address: string) =>\n isIP(address) !== 0 &&\n privateNet.check(address, familyOf(address)) &&\n !metadataV6.check(address, familyOf(address));\n\n/** Is this literal address one a request with this reach may go to? */\nfunction inReach(address: string, allow: AddressClass | undefined): boolean {\n if (isPublicAddress(address)) return true;\n if (allow === 'loopback') return isLoopbackAddress(address);\n if (allow === 'private') return isPrivateAddress(address);\n return false;\n}\n\n/** `localhost`, or a literal loopback address (`[::1]` with or without its\n * brackets): a host on this machine by its name alone, no lookup. */\nexport function isLoopbackHost(hostname: string): boolean {\n const host = hostname.replace(/^\\[|\\]$/g, '').toLowerCase();\n return host === 'localhost' || isLoopbackAddress(host);\n}\n\n/**\n * The reach a server the user typed gives the hosts its sign-in names\n * (`router/accounts/fetch.ts`): loopback for one on this machine, private for\n * a literal private address, and public for any other, a `.local` name\n * included.\n */\nexport function addressClassOf(hostname: string): AddressClass {\n if (isLoopbackHost(hostname)) return 'loopback';\n return isPrivateAddress(hostname.replace(/^\\[|\\]$/g, '')) ? 'private' : 'public';\n}\n\nconst LOCAL_SUFFIX = /(?:^|\\.)(?:localhost|local|internal|home|lan)$/i;\n\nfunction refuse(message: string, details?: Record<string, unknown>): never {\n throw new CliError('USAGE', message, {\n fix: 'Paid requests go to public HTTPS endpoints only; nothing was signed.',\n ...(details !== undefined ? { details } : {}),\n });\n}\n\n/** The lexical half: the URL shape alone, no network. Returns the parsed URL.\n * `allow` is an account request's reach ({@link DestinationOptions.allow}). */\nexport function assertPublicHttpsUrl(raw: string, allow?: AddressClass): URL {\n let url: URL;\n try {\n url = new URL(raw);\n } catch {\n return refuse(`Invalid URL: ${JSON.stringify(raw.slice(0, 200))}`);\n }\n const host = url.hostname.replace(/^\\[|\\]$/g, '');\n // ON THIS MACHINE, for a reach that takes it: `localhost` by name, and http.\n const local = allow === 'loopback' && isLoopbackHost(host);\n if (\n !(url.protocol === 'https:' || (url.protocol === 'http:' && local)) ||\n url.username !== '' ||\n url.password !== '' ||\n url.hash !== '' ||\n (allow === undefined && url.port !== '' && url.port !== '443') ||\n raw.length > 16_384\n ) {\n refuse('Only public HTTPS endpoints without credentials, fragments or custom ports are paid.');\n }\n if (!(local && host === 'localhost')) {\n if (!host.includes('.') && isIP(host) === 0) refuse('The endpoint host is not a public name.');\n if (LOCAL_SUFFIX.test(host)) refuse('Private or local destinations are not paid.');\n }\n if (isIP(host) !== 0 && !inReach(host, allow)) {\n refuse('Private or reserved IP destinations are not paid.');\n }\n return url;\n}\n\nexport interface DestinationOptions {\n /** Resolver seam; production leaves it unset and uses `dns.lookup`. */\n resolveHostname?: (hostname: string) => Promise<{ address: string; family: number }[]>;\n /** One deadline for the whole resolution, not per address. */\n timeoutMs?: number;\n /**\n * AN ACCOUNT REQUEST'S REACH (`router/accounts/fetch.ts`): any port, and\n * public addresses plus the class named (`loopback`, where `http` to a\n * loopback host is taken too, or `private`). Unset, a paid request's: public\n * HTTPS on 443 alone.\n */\n allow?: AddressClass;\n}\n\n/**\n * The full preflight: the lexical check, then DNS. A literal address answered\n * the DNS question already and skips the lookup.\n */\nexport async function assertPublicDestination(\n raw: string,\n options: DestinationOptions = {},\n): Promise<URL> {\n return (await resolvePublicDestination(raw, options)).url;\n}\n\n/**\n * The same preflight, returning the ONE address it validated, for a transport\n * that connects to exactly that address instead of resolving the name again\n * (see the module comment). Every answer must be in reach, as above; the\n * first is the one to pin.\n */\nexport async function resolvePublicDestination(\n raw: string,\n options: DestinationOptions = {},\n): Promise<{ url: URL; address: string; family: 4 | 6 }> {\n const url = assertPublicHttpsUrl(raw, options.allow);\n const host = url.hostname.replace(/^\\[|\\]$/g, '');\n if (isIP(host) !== 0) return { url, address: host, family: isIP(host) === 6 ? 6 : 4 };\n const resolve = options.resolveHostname ?? ((name: string) => lookup(name, { all: true }));\n const signal = AbortSignal.timeout(options.timeoutMs ?? 5_000);\n let addresses: { address: string; family: number }[];\n try {\n addresses = await Promise.race([\n resolve(host),\n new Promise<never>((_, reject) => {\n signal.addEventListener('abort', () => reject(new Error('DNS lookup timed out.')), {\n once: true,\n });\n }),\n ]);\n } catch (err) {\n return refuse(`The endpoint host ${host} could not be resolved.`, {\n cause: err instanceof Error ? err.message : String(err),\n });\n }\n // Plain http goes to this machine alone, whatever else the reach takes.\n const fits = (address: string) =>\n url.protocol === 'http:' ? isLoopbackAddress(address) : inReach(address, options.allow);\n if (addresses.length === 0 || addresses.some((entry) => !fits(entry.address))) {\n refuse(`The endpoint host ${host} resolves to a private or unsupported network address.`);\n }\n const first = addresses[0]!;\n return { url, address: first.address, family: isIP(first.address) === 6 ? 6 : 4 };\n}\n"],"mappings":";;;;;;AAAA,SAAS,cAAc;AACvB,SAAS,WAAW,YAAY;AAmChC,IAAM,YAAY,IAAI,UAAU;AAChC,WAAW,CAAC,MAAM,MAAM,KAAK;AAAA,EAC3B,CAAC,WAAW,CAAC;AAAA,EACb,CAAC,YAAY,CAAC;AAAA,EACd,CAAC,cAAc,EAAE;AAAA,EACjB,CAAC,aAAa,CAAC;AAAA,EACf,CAAC,eAAe,EAAE;AAAA,EAClB,CAAC,cAAc,EAAE;AAAA,EACjB,CAAC,aAAa,EAAE;AAAA,EAChB,CAAC,aAAa,EAAE;AAAA,EAChB,CAAC,eAAe,EAAE;AAAA,EAClB,CAAC,cAAc,EAAE;AAAA,EACjB,CAAC,gBAAgB,EAAE;AAAA,EACnB,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D,CAAC;AAAA,EACH;AAEA,QAAM,OAAO,CAAC,YACZ,IAAI,aAAa,UAAU,kBAAkB,OAAO,IAAI,QAAQ,SAAS,QAAQ,KAAK;AACxF,MAAI,UAAU,WAAW,KAAK,UAAU,KAAK,CAAC,UAAU,CAAC,KAAK,MAAM,OAAO,CAAC,GAAG;AAC7E,WAAO,qBAAqB,IAAI,wDAAwD;AAAA,EAC1F;AACA,QAAM,QAAQ,UAAU,CAAC;AACzB,SAAO,EAAE,KAAK,SAAS,MAAM,SAAS,QAAQ,KAAK,MAAM,OAAO,MAAM,IAAI,IAAI,EAAE;AAClF;","names":[]}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { createRequire as __tenjinCreateRequire } from 'node:module'; const require = __tenjinCreateRequire(import.meta.url);
|
|
2
|
+
import {
|
|
3
|
+
style
|
|
4
|
+
} from "./chunk-KLDMLWXT.js";
|
|
5
|
+
|
|
6
|
+
// src/lib/live-line.ts
|
|
7
|
+
var FRAMES = "\u280B\u2819\u2839\u2838\u283C\u2834\u2826\u2827\u2807\u280F";
|
|
8
|
+
var FRAME_MS = 80;
|
|
9
|
+
var DETAIL_COLUMN = 26;
|
|
10
|
+
var CLEAR_LINE = "\r\x1B[2K";
|
|
11
|
+
function liveLine(stream, opts = {}) {
|
|
12
|
+
const tty = opts.tty ?? stream.isTTY === true;
|
|
13
|
+
const every = opts.setInterval ?? ((fn, ms) => setInterval(fn, ms).unref());
|
|
14
|
+
const cancel = opts.clearInterval ?? ((h) => clearInterval(h));
|
|
15
|
+
const paint = (format, text) => style(format, text, stream);
|
|
16
|
+
const write = (text) => {
|
|
17
|
+
try {
|
|
18
|
+
stream.write(text);
|
|
19
|
+
} catch {
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
let timer;
|
|
23
|
+
let frame = 0;
|
|
24
|
+
let current;
|
|
25
|
+
let lastPlain;
|
|
26
|
+
const draw = () => {
|
|
27
|
+
if (current === void 0) return;
|
|
28
|
+
const glyph = paint("blue", FRAMES[frame % FRAMES.length]);
|
|
29
|
+
const aside = current.aside !== void 0 ? ` ${paint("dim", current.aside)}` : "";
|
|
30
|
+
write(`${CLEAR_LINE} ${glyph} ${current.text}${aside}`);
|
|
31
|
+
frame++;
|
|
32
|
+
};
|
|
33
|
+
const clear = () => {
|
|
34
|
+
if (timer !== void 0) {
|
|
35
|
+
cancel(timer);
|
|
36
|
+
timer = void 0;
|
|
37
|
+
}
|
|
38
|
+
if (tty && current !== void 0) write(CLEAR_LINE);
|
|
39
|
+
current = void 0;
|
|
40
|
+
};
|
|
41
|
+
const keep = (text) => {
|
|
42
|
+
clear();
|
|
43
|
+
write(`${text}
|
|
44
|
+
`);
|
|
45
|
+
};
|
|
46
|
+
return {
|
|
47
|
+
spin(text, aside) {
|
|
48
|
+
if (!tty) {
|
|
49
|
+
if (lastPlain !== text) write(` \u2026 ${text}${aside !== void 0 ? ` ${aside}` : ""}
|
|
50
|
+
`);
|
|
51
|
+
lastPlain = text;
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
current = { text, ...aside !== void 0 ? { aside } : {} };
|
|
55
|
+
if (timer === void 0) timer = every(draw, FRAME_MS);
|
|
56
|
+
draw();
|
|
57
|
+
},
|
|
58
|
+
ok(text, detail) {
|
|
59
|
+
lastPlain = void 0;
|
|
60
|
+
const pad = " ".repeat(Math.max(2, DETAIL_COLUMN - text.length));
|
|
61
|
+
keep(` ${paint("green", "\u2713")} ${text}${detail !== void 0 ? `${pad}${detail}` : ""}`);
|
|
62
|
+
},
|
|
63
|
+
warn(text) {
|
|
64
|
+
lastPlain = void 0;
|
|
65
|
+
keep(` ${paint("yellow", "!")} ${text}`);
|
|
66
|
+
},
|
|
67
|
+
line(text) {
|
|
68
|
+
lastPlain = void 0;
|
|
69
|
+
keep(text);
|
|
70
|
+
},
|
|
71
|
+
stop: clear
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export {
|
|
76
|
+
liveLine
|
|
77
|
+
};
|
|
78
|
+
//# sourceMappingURL=chunk-DJ36BM62.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/lib/live-line.ts"],"sourcesContent":["import { style, type StyleFormat } from './output';\n\n/**\n * ONE STATUS LINE THAT REWRITES ITSELF IN PLACE, for a wait a person watches\n * (`tenjin fund`, `tenjin balance --wait`). On a terminal the current state\n * spins with braille frames every 80 ms and is replaced by the next; a state\n * that is done is printed as a `✓` line that stays. Anywhere else (stderr\n * redirected to a file) each new state is one plain `…` line, written once,\n * so a log reads as the same story without a frame per tick.\n *\n * Everything goes to the stream it is given (stderr): stdout keeps the\n * command's own result, and nothing here ever throws.\n */\n\nconst FRAMES = '⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏';\nconst FRAME_MS = 80;\n/** Where a `✓` line's detail starts, so amounts line up under each other. */\nconst DETAIL_COLUMN = 26;\nconst CLEAR_LINE = '\\r\\x1b[2K';\n\nexport interface LiveLine {\n /** The state now in progress, with an optional quiet aside (the link's time left). */\n spin(text: string, aside?: string): void;\n /** A finished state, kept on screen: `✓ text detail`. */\n ok(text: string, detail?: string): void;\n /** A state that needs a word but is not a failure of this command: `! text`. */\n warn(text: string): void;\n /** Any other line, kept on screen. */\n line(text: string): void;\n /** Clear the spinning line, if any. Safe to call twice. */\n stop(): void;\n}\n\nexport interface LiveLineOptions {\n /** Draw frames in place. Defaults to the stream's own `isTTY`. */\n tty?: boolean;\n /** Test seams for the frame timer. */\n setInterval?: (fn: () => void, ms: number) => unknown;\n clearInterval?: (handle: unknown) => void;\n}\n\nexport function liveLine(stream: NodeJS.WritableStream, opts: LiveLineOptions = {}): LiveLine {\n const tty = opts.tty ?? (stream as { isTTY?: unknown }).isTTY === true;\n const every = opts.setInterval ?? ((fn, ms) => setInterval(fn, ms).unref());\n const cancel = opts.clearInterval ?? ((h) => clearInterval(h as NodeJS.Timeout));\n const paint = (format: StyleFormat, text: string) => style(format, text, stream);\n const write = (text: string) => {\n try {\n stream.write(text);\n } catch {\n // A status line that cannot be drawn changes nothing about the wait.\n }\n };\n\n let timer: unknown;\n let frame = 0;\n let current: { text: string; aside?: string } | undefined;\n let lastPlain: string | undefined;\n\n const draw = () => {\n if (current === undefined) return;\n const glyph = paint('blue', FRAMES[frame % FRAMES.length]!);\n const aside = current.aside !== undefined ? ` ${paint('dim', current.aside)}` : '';\n write(`${CLEAR_LINE} ${glyph} ${current.text}${aside}`);\n frame++;\n };\n const clear = () => {\n if (timer !== undefined) {\n cancel(timer);\n timer = undefined;\n }\n if (tty && current !== undefined) write(CLEAR_LINE);\n current = undefined;\n };\n const keep = (text: string) => {\n clear();\n write(`${text}\\n`);\n };\n\n return {\n spin(text, aside) {\n if (!tty) {\n if (lastPlain !== text) write(` … ${text}${aside !== undefined ? ` ${aside}` : ''}\\n`);\n lastPlain = text;\n return;\n }\n current = { text, ...(aside !== undefined ? { aside } : {}) };\n if (timer === undefined) timer = every(draw, FRAME_MS);\n draw();\n },\n ok(text, detail) {\n lastPlain = undefined;\n const pad = ' '.repeat(Math.max(2, DETAIL_COLUMN - text.length));\n keep(` ${paint('green', '✓')} ${text}${detail !== undefined ? `${pad}${detail}` : ''}`);\n },\n warn(text) {\n lastPlain = undefined;\n keep(` ${paint('yellow', '!')} ${text}`);\n },\n line(text) {\n lastPlain = undefined;\n keep(text);\n },\n stop: clear,\n };\n}\n"],"mappings":";;;;;;AAcA,IAAM,SAAS;AACf,IAAM,WAAW;AAEjB,IAAM,gBAAgB;AACtB,IAAM,aAAa;AAuBZ,SAAS,SAAS,QAA+B,OAAwB,CAAC,GAAa;AAC5F,QAAM,MAAM,KAAK,OAAQ,OAA+B,UAAU;AAClE,QAAM,QAAQ,KAAK,gBAAgB,CAAC,IAAI,OAAO,YAAY,IAAI,EAAE,EAAE,MAAM;AACzE,QAAM,SAAS,KAAK,kBAAkB,CAAC,MAAM,cAAc,CAAmB;AAC9E,QAAM,QAAQ,CAAC,QAAqB,SAAiB,MAAM,QAAQ,MAAM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,GAAG,GAAG,GAAG,MAAM,KAAK,EAAE,EAAE;AAAA,IACzF;AAAA,IACA,KAAK,MAAM;AACT,kBAAY;AACZ,WAAK,KAAK,MAAM,UAAU,GAAG,CAAC,IAAI,IAAI,EAAE;AAAA,IAC1C;AAAA,IACA,KAAK,MAAM;AACT,kBAAY;AACZ,WAAK,IAAI;AAAA,IACX;AAAA,IACA,MAAM;AAAA,EACR;AACF;","names":[]}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { createRequire as __tenjinCreateRequire } from 'node:module'; const require = __tenjinCreateRequire(import.meta.url);
|
|
2
|
+
import {
|
|
3
|
+
SEND_MAX_UNSET,
|
|
4
|
+
loadRawConfig,
|
|
5
|
+
resolveSettings
|
|
6
|
+
} from "./chunk-UIB33QQP.js";
|
|
7
|
+
|
|
8
|
+
// src/lib/settings.ts
|
|
9
|
+
import { readFile, stat } from "node:fs/promises";
|
|
10
|
+
import { homedir } from "node:os";
|
|
11
|
+
import { basename, dirname, join, resolve, sep } from "node:path";
|
|
12
|
+
async function resolveContextSettings(ctx) {
|
|
13
|
+
const config = await loadRawConfig(ctx.dataDir);
|
|
14
|
+
const s = resolveSettings({ config, flags: { baseUrl: ctx.flags.baseUrl }, env: process.env });
|
|
15
|
+
return {
|
|
16
|
+
baseUrl: s.baseUrl.value,
|
|
17
|
+
rpcUrl: s.rpcUrl.value,
|
|
18
|
+
bazaarRegistries: s.bazaarRegistries.value,
|
|
19
|
+
experimentalBazaar: s.experimentalBazaar.value === "on",
|
|
20
|
+
sendMaxAmountAtomic: s.sendMaxAmount.value === SEND_MAX_UNSET ? SEND_MAX_UNSET : s.sendMaxAmount.value === "none" ? null : BigInt(s.sendMaxAmount.value),
|
|
21
|
+
policy: {
|
|
22
|
+
maxAutoSpendAtomic: BigInt(s.maxAutoSpend.value),
|
|
23
|
+
sessionBudgetAtomic: s.sessionBudget.value === "none" ? null : BigInt(s.sessionBudget.value),
|
|
24
|
+
allowlistCreators: s.allowlistCreators.value
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
async function findNearestProjectFiles(cwd, names, deps = {}) {
|
|
29
|
+
return (await walkUp(cwd, names, deps, true)).levels[0] ?? null;
|
|
30
|
+
}
|
|
31
|
+
function findAllProjectFiles(cwd, names, deps = {}) {
|
|
32
|
+
return walkUp(cwd, names, deps, false);
|
|
33
|
+
}
|
|
34
|
+
async function walkUp(cwd, names, deps, nearest) {
|
|
35
|
+
const homeDir = deps.homeDir ?? homedir();
|
|
36
|
+
const levels = [];
|
|
37
|
+
let dir = cwd;
|
|
38
|
+
for (; ; ) {
|
|
39
|
+
if (dir === homeDir && deps.homeIsProject === false) return { levels, gitRoot: null };
|
|
40
|
+
const found = await ownedCandidates(dir, names, deps);
|
|
41
|
+
if (found.length > 0) {
|
|
42
|
+
levels.push({ dir, found });
|
|
43
|
+
if (nearest) return { levels, gitRoot: null };
|
|
44
|
+
}
|
|
45
|
+
if (await pathExists(join(dir, ".git"))) return { levels, gitRoot: dir };
|
|
46
|
+
if (dir === homeDir) return { levels, gitRoot: null };
|
|
47
|
+
const parent = dirname(dir);
|
|
48
|
+
if (parent === dir) return { levels, gitRoot: null };
|
|
49
|
+
dir = parent;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
async function mainWorktreeOf(gitRoot, homeDir = homedir()) {
|
|
53
|
+
try {
|
|
54
|
+
const dotGit = join(gitRoot, ".git");
|
|
55
|
+
if (!(await stat(dotGit)).isFile()) return null;
|
|
56
|
+
const line = /^gitdir:\s*(.+?)\s*$/m.exec(await readFile(dotGit, "utf8"));
|
|
57
|
+
if (line === null) return null;
|
|
58
|
+
const gitdir = resolve(gitRoot, line[1]);
|
|
59
|
+
const commonDir = resolve(gitdir, (await readFile(join(gitdir, "commondir"), "utf8")).trim());
|
|
60
|
+
if (basename(commonDir) !== ".git" || !(await stat(commonDir)).isDirectory()) return null;
|
|
61
|
+
const main = dirname(commonDir);
|
|
62
|
+
if (main === gitRoot || !main.startsWith(`${homeDir}${sep}`)) return null;
|
|
63
|
+
return main;
|
|
64
|
+
} catch {
|
|
65
|
+
return null;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
async function ownedCandidates(dir, names, deps = {}) {
|
|
69
|
+
const isForeignOwned = deps.isForeignOwned ?? defaultIsForeignOwned;
|
|
70
|
+
const warn = deps.warn ?? ((message) => process.stderr.write(`${message}
|
|
71
|
+
`));
|
|
72
|
+
const found = [];
|
|
73
|
+
for (const name of names) {
|
|
74
|
+
const candidate = join(dir, name);
|
|
75
|
+
if (!await pathExists(candidate)) continue;
|
|
76
|
+
if (await isForeignOwned(candidate)) {
|
|
77
|
+
warn(`Ignoring ${candidate}: not owned by the current user.`);
|
|
78
|
+
} else {
|
|
79
|
+
found.push(candidate);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
return found;
|
|
83
|
+
}
|
|
84
|
+
async function projectRoot(cwd, homeDir = homedir()) {
|
|
85
|
+
return (await walkUp(cwd, [], { homeDir }, false)).gitRoot ?? cwd;
|
|
86
|
+
}
|
|
87
|
+
async function defaultIsForeignOwned(filePath) {
|
|
88
|
+
const uid = process.getuid?.();
|
|
89
|
+
if (uid === void 0) return false;
|
|
90
|
+
try {
|
|
91
|
+
return (await stat(filePath)).uid !== uid;
|
|
92
|
+
} catch {
|
|
93
|
+
return false;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
async function pathExists(path) {
|
|
97
|
+
try {
|
|
98
|
+
await stat(path);
|
|
99
|
+
return true;
|
|
100
|
+
} catch {
|
|
101
|
+
return false;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
export {
|
|
106
|
+
resolveContextSettings,
|
|
107
|
+
findNearestProjectFiles,
|
|
108
|
+
findAllProjectFiles,
|
|
109
|
+
mainWorktreeOf,
|
|
110
|
+
ownedCandidates,
|
|
111
|
+
projectRoot,
|
|
112
|
+
pathExists
|
|
113
|
+
};
|
|
114
|
+
//# sourceMappingURL=chunk-DTEWAVNE.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/lib/settings.ts"],"sourcesContent":["import { readFile, stat } from 'node:fs/promises';\nimport { homedir } from 'node:os';\nimport { basename, dirname, join, resolve, sep } from 'node:path';\nimport { SEND_MAX_UNSET, loadRawConfig, resolveSettings } from './config';\nimport type { SpendPolicy } from './policy';\nimport type { CommandContext } from '../context';\n\n/**\n * The effective runtime settings a command needs, resolved once through the\n * same precedence (flag > env > file > default) `config` uses. Spend values\n * arrive atomic from config and are handed on as bigint for the policy layer.\n */\nexport interface ResolvedSettings {\n /** The router's base URL. */\n baseUrl: string;\n rpcUrl: string;\n policy: SpendPolicy;\n /** x402 discovery registries the direct pay lane verifies against. */\n bazaarRegistries: string[];\n /** `experimental.bazaar`: whether the router may also offer the open Bazaar's\n * unreviewed sellers. Tenjin's reviewed list is always requested; only\n * `router.enabled false` stops every offer. */\n experimentalBazaar: boolean;\n /**\n * Hard per-send cap for `tenjin wallet send`: SEND_MAX_UNSET = never configured\n * (send refuses until `config set sendMaxAmount`), null = explicit \"none\"\n * (uncapped opt-in), 0n = disabled, otherwise the atomic cap.\n */\n sendMaxAmountAtomic: bigint | null | typeof SEND_MAX_UNSET;\n}\n\nexport async function resolveContextSettings(ctx: CommandContext): Promise<ResolvedSettings> {\n const config = await loadRawConfig(ctx.dataDir);\n const s = resolveSettings({ config, flags: { baseUrl: ctx.flags.baseUrl }, env: process.env });\n return {\n baseUrl: s.baseUrl.value,\n rpcUrl: s.rpcUrl.value,\n bazaarRegistries: s.bazaarRegistries.value,\n experimentalBazaar: s.experimentalBazaar.value === 'on',\n sendMaxAmountAtomic:\n s.sendMaxAmount.value === SEND_MAX_UNSET\n ? SEND_MAX_UNSET\n : s.sendMaxAmount.value === 'none'\n ? null\n : BigInt(s.sendMaxAmount.value),\n policy: {\n maxAutoSpendAtomic: BigInt(s.maxAutoSpend.value),\n sessionBudgetAtomic: s.sessionBudget.value === 'none' ? null : BigInt(s.sessionBudget.value),\n allowlistCreators: s.allowlistCreators.value,\n },\n };\n}\n\nexport interface ProjectWalkDeps {\n /** Ownership seam; defaults to stat().uid vs process uid. Gates a planted file. */\n isForeignOwned?: (filePath: string) => Promise<boolean>;\n /** One-line stderr warning sink; defaults to process.stderr. */\n warn?: (message: string) => void;\n /** Upper bound of the walk; defaults to the user's home directory. */\n homeDir?: string;\n}\n\nexport interface ProjectWalkHit {\n /** The directory the walk stopped in. */\n dir: string;\n /** Every candidate present there and owned by this user, in `names` order. */\n found: string[];\n}\n\n/**\n * THE ONE WALK UP FROM A WORKING DIRECTORY to the router's `.tenjin/config.json`\n * pair: the nearest directory, walking up from `cwd`, that holds at least one of\n * `names` (paths relative to that directory). `homeIsProject: false` stops\n * before looking in $HOME itself, for a file whose home copy is the global one.\n */\nexport async function findNearestProjectFiles(\n cwd: string,\n names: readonly string[],\n deps: ProjectWalkDeps & { homeIsProject?: boolean } = {},\n): Promise<ProjectWalkHit | null> {\n return (await walkUp(cwd, names, deps, true)).levels[0] ?? null;\n}\n\n/**\n * EVERY directory from `cwd` up to the git root (inclusive) that holds one of\n * `names`, nearest first, under the same bounds as\n * {@link findNearestProjectFiles}; `gitRoot` is null outside a repository.\n * For layers that each only tighten, where reading one more can never loosen.\n */\nexport function findAllProjectFiles(\n cwd: string,\n names: readonly string[],\n deps: ProjectWalkDeps & { homeIsProject?: boolean } = {},\n): Promise<{ levels: ProjectWalkHit[]; gitRoot: string | null }> {\n return walkUp(cwd, names, deps, false);\n}\n\n/**\n * The walk itself, up from `cwd`: it stops at a git root, at $HOME (a\n * shared-host trust boundary) and at the filesystem root, whichever comes\n * first, and with `nearest` at the first directory holding one of `names`.\n */\nasync function walkUp(\n cwd: string,\n names: readonly string[],\n deps: ProjectWalkDeps & { homeIsProject?: boolean },\n nearest: boolean,\n): Promise<{ levels: ProjectWalkHit[]; gitRoot: string | null }> {\n const homeDir = deps.homeDir ?? homedir();\n const levels: ProjectWalkHit[] = [];\n let dir = cwd;\n for (;;) {\n if (dir === homeDir && deps.homeIsProject === false) return { levels, gitRoot: null };\n const found = await ownedCandidates(dir, names, deps);\n if (found.length > 0) {\n levels.push({ dir, found });\n if (nearest) return { levels, gitRoot: null };\n }\n if (await pathExists(join(dir, '.git'))) return { levels, gitRoot: dir };\n if (dir === homeDir) return { levels, gitRoot: null };\n const parent = dirname(dir);\n if (parent === dir) return { levels, gitRoot: null };\n dir = parent;\n }\n}\n\n/**\n * The main working tree behind a git worktree whose root is `gitRoot`, or null\n * when `gitRoot` is not a linked worktree. Filesystem only, no `git` process:\n * the worktree's `.git` FILE names its gitdir, whose `commondir` names the\n * main repository's `.git`. A bare common dir, one that resolves outside\n * $HOME, and a submodule (a gitdir with no `commondir`) all give null.\n */\nexport async function mainWorktreeOf(\n gitRoot: string,\n homeDir: string = homedir(),\n): Promise<string | null> {\n try {\n const dotGit = join(gitRoot, '.git');\n if (!(await stat(dotGit)).isFile()) return null;\n const line = /^gitdir:\\s*(.+?)\\s*$/m.exec(await readFile(dotGit, 'utf8'));\n if (line === null) return null;\n const gitdir = resolve(gitRoot, line[1]!);\n const commonDir = resolve(gitdir, (await readFile(join(gitdir, 'commondir'), 'utf8')).trim());\n if (basename(commonDir) !== '.git' || !(await stat(commonDir)).isDirectory()) return null;\n const main = dirname(commonDir);\n if (main === gitRoot || !main.startsWith(`${homeDir}${sep}`)) return null;\n return main;\n } catch {\n return null;\n }\n}\n\n/** The candidates present in `dir` and owned by this user, in `names` order. */\nexport async function ownedCandidates(\n dir: string,\n names: readonly string[],\n deps: ProjectWalkDeps = {},\n): Promise<string[]> {\n const isForeignOwned = deps.isForeignOwned ?? defaultIsForeignOwned;\n const warn = deps.warn ?? ((message: string) => process.stderr.write(`${message}\\n`));\n const found: string[] = [];\n for (const name of names) {\n const candidate = join(dir, name);\n if (!(await pathExists(candidate))) continue;\n if (await isForeignOwned(candidate)) {\n // A file owned by another user (e.g. /tmp/.tenjin/config.json on a shared box)\n // must never become the honored layer; skip it and keep walking.\n warn(`Ignoring ${candidate}: not owned by the current user.`);\n } else {\n found.push(candidate);\n }\n }\n return found;\n}\n\n/**\n * The directory a project file belongs in when none exists yet: the git root\n * above `cwd`, or `cwd` itself outside a repository. Same bounds as the walk.\n */\nexport async function projectRoot(cwd: string, homeDir: string = homedir()): Promise<string> {\n return (await walkUp(cwd, [], { homeDir }, false)).gitRoot ?? cwd;\n}\n\n/**\n * True when the file is owned by a different uid than the process. On a platform\n * without a uid model (Windows: process.getuid is undefined) this is always\n * false — the ownership gate is a POSIX shared-host protection.\n */\nasync function defaultIsForeignOwned(filePath: string): Promise<boolean> {\n const uid = process.getuid?.();\n if (uid === undefined) return false;\n try {\n return (await stat(filePath)).uid !== uid;\n } catch {\n return false;\n }\n}\n\n/** True when a path exists (of any type). */\nexport async function pathExists(path: string): Promise<boolean> {\n try {\n await stat(path);\n return true;\n } catch {\n return false;\n }\n}\n"],"mappings":";;;;;;;;AAAA,SAAS,UAAU,YAAY;AAC/B,SAAS,eAAe;AACxB,SAAS,UAAU,SAAS,MAAM,SAAS,WAAW;AA6BtD,eAAsB,uBAAuB,KAAgD;AAC3F,QAAM,SAAS,MAAM,cAAc,IAAI,OAAO;AAC9C,QAAM,IAAI,gBAAgB,EAAE,QAAQ,OAAO,EAAE,SAAS,IAAI,MAAM,QAAQ,GAAG,KAAK,QAAQ,IAAI,CAAC;AAC7F,SAAO;AAAA,IACL,SAAS,EAAE,QAAQ;AAAA,IACnB,QAAQ,EAAE,OAAO;AAAA,IACjB,kBAAkB,EAAE,iBAAiB;AAAA,IACrC,oBAAoB,EAAE,mBAAmB,UAAU;AAAA,IACnD,qBACE,EAAE,cAAc,UAAU,iBACtB,iBACA,EAAE,cAAc,UAAU,SACxB,OACA,OAAO,EAAE,cAAc,KAAK;AAAA,IACpC,QAAQ;AAAA,MACN,oBAAoB,OAAO,EAAE,aAAa,KAAK;AAAA,MAC/C,qBAAqB,EAAE,cAAc,UAAU,SAAS,OAAO,OAAO,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,EACT,QAAQ;AACN,WAAO;AAAA,EACT;AACF;","names":[]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { createRequire as __tenjinCreateRequire } from 'node:module'; const require = __tenjinCreateRequire(import.meta.url);
|
|
2
|
+
|
|
3
|
+
// src/router/gate.ts
|
|
4
|
+
var GATE_TIMEOUT_MS = 3500;
|
|
5
|
+
var UNPAID_GATE_TIMEOUT_MS = 3500;
|
|
6
|
+
var DEPOSIT_GATE_TIMEOUT_MS = 4500;
|
|
7
|
+
|
|
8
|
+
export {
|
|
9
|
+
GATE_TIMEOUT_MS,
|
|
10
|
+
UNPAID_GATE_TIMEOUT_MS,
|
|
11
|
+
DEPOSIT_GATE_TIMEOUT_MS
|
|
12
|
+
};
|
|
13
|
+
//# sourceMappingURL=chunk-F2KJAJ7T.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/router/gate.ts"],"sourcesContent":["/**\n * THE HOOK'S TIME BUDGET, which is the only thing this module still owns.\n *\n * There is no separate gate call any more: the hook asks the paid route,\n * `POST /api/x402-router/route`, for the one decision, and the backend answers\n * as soon as the native-versus-paid question is settled, binding whatever it\n * chose in the background. What used to live here, the `/prepare` client and the\n * category-shaped hint validator, went with that second round trip.\n */\n\n/**\n * The hook's whole budget is 5 s (`ROUTE_HOOK_TIMEOUT_SECONDS`, the timeout\n * `install` writes for each routing leg), and a paid decision gets 3.5 s of it.\n * Inside `tenjin mcp` those 3.5 s hold the paid route too: the 402, the SDK's\n * chain read and the paid request, or a wait for the background top-up that\n * funds the channel (`routing-payer.ts`). 1.5 s are left for startup, the\n * transcript read and the reply, and 500 ms on a call that carries a deposit,\n * which only a router with no `warm` form gets ({@link DEPOSIT_GATE_TIMEOUT_MS});\n * `wire.test.ts` pins the sums.\n * The expected wait is about 1 s: the backend answers on the gate question and\n * binds afterwards.\n *\n * AN ABORT HERE IS A LOST HINT, not a lost turn. The hook falls back to one\n * line telling the model to call `request` with its own query, and the tool\n * makes the decision instead. One of four live prompts was swallowed at a 1.5 s\n * abort against a backend measured at 0.4 to 0.5 s, so this holds the slack the\n * harness budget was already leaving unused.\n */\nexport const GATE_TIMEOUT_MS = 3_500;\n\n/** A hook without the MCP payer keeps the same 3.5 s decision wait.\n * The server gets only the time left when the decision request is sent. */\nexport const UNPAID_GATE_TIMEOUT_MS = 3_500;\n\n/**\n * A CALL THAT CARRIES A DEPOSIT gets the rest of the hook leg instead: the\n * first paid call on a channel waits on verify, the gate and the on-chain\n * deposit in a row (5.0 s measured on Base), so 3.5 s cut it short. It is the\n * leg's 5 s less the 500 ms for startup, the transcript read and the reply,\n * so the leg still never runs past the timeout `install` writes; `wire.test.ts`\n * pins that. A leg carries a deposit only while the router has no `warm`\n * form: otherwise the background top-up makes every deposit.\n */\nexport const DEPOSIT_GATE_TIMEOUT_MS = 4_500;\n"],"mappings":";;;AA4BO,IAAM,kBAAkB;AAIxB,IAAM,yBAAyB;AAW/B,IAAM,0BAA0B;","names":[]}
|
|
@@ -3,18 +3,18 @@ import {
|
|
|
3
3
|
nodeBinPath,
|
|
4
4
|
readRuntimeState,
|
|
5
5
|
versionEntry
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-5N4GGUBN.js";
|
|
7
7
|
import {
|
|
8
8
|
configPath,
|
|
9
|
-
|
|
9
|
+
isDefaultDataDir,
|
|
10
10
|
runtimeDir
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-JTX3BUDK.js";
|
|
12
12
|
|
|
13
13
|
// src/lib/auto-update.ts
|
|
14
14
|
import { spawn } from "node:child_process";
|
|
15
15
|
import { closeSync, existsSync, openSync, readFileSync, renameSync, writeFileSync } from "node:fs";
|
|
16
16
|
import { homedir } from "node:os";
|
|
17
|
-
import { join
|
|
17
|
+
import { join } from "node:path";
|
|
18
18
|
var AUTO_UPDATE_FILE = "auto-update.json";
|
|
19
19
|
var AUTO_UPDATE_LOG = "auto-update.log";
|
|
20
20
|
var DAY_MS = 864e5;
|
|
@@ -25,7 +25,7 @@ function maybeAutoUpdate(o) {
|
|
|
25
25
|
if (env.CI !== void 0 && env.CI.length > 0) return;
|
|
26
26
|
if (env.TENJIN_NO_UPDATE_CHECK === "1") return;
|
|
27
27
|
const home = o.home ?? homedir();
|
|
28
|
-
if (
|
|
28
|
+
if (!isDefaultDataDir(o.dataDir, home)) return;
|
|
29
29
|
if (!autoMode(o.dataDir)) return;
|
|
30
30
|
const root = runtimeDir(o.dataDir);
|
|
31
31
|
const state = readRuntimeState(root);
|
|
@@ -113,4 +113,4 @@ export {
|
|
|
113
113
|
recordAutoUpdate,
|
|
114
114
|
autoUpdateLine
|
|
115
115
|
};
|
|
116
|
-
//# sourceMappingURL=chunk-
|
|
116
|
+
//# sourceMappingURL=chunk-F3QPGYOY.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/lib/auto-update.ts"],"sourcesContent":["import { spawn } from 'node:child_process';\nimport { closeSync, existsSync, openSync, readFileSync, renameSync, writeFileSync } from 'node:fs';\nimport { homedir } from 'node:os';\nimport { join } from 'node:path';\nimport { configPath, isDefaultDataDir, runtimeDir } from './paths';\nimport { nodeBinPath, readRuntimeState, versionEntry } from './runtime-layout';\n\n/**\n * BACKGROUND AUTO-UPDATE, the way Claude Code's native installer does it:\n * downloaded in the background, used from the next session. At most once a\n * day, at the start of a Claude Code or Codex session, this starts\n * `tenjin update --background` DETACHED on the runtime's own Node and current\n * entry, and returns: the caller adds no latency and never waits.\n * The child is `tenjin update`'s runtime branch (the release's build\n * provenance is checked before it is downloaded and the build before the\n * switch, the previous version stays, an older one is never switched to, the\n * runtime lock is held), except that it takes only a release published at\n * least a day ago (`BACKGROUND_COOLDOWN_MS` in commands/update). So npm and PATH\n * are never involved, and a running session keeps its version until the next\n * one. Codex has no SessionStart hook, so `tenjin mcp --harness codex` starts\n * it as the server starts; its routing legs are `mcp_tool` calls into that\n * server, so the switch moves nothing the session is using, and the launcher\n * it rewrites starts the next session's server.\n *\n * `node:*`, the paths and the runtime layout only: the `alive` leg and\n * `tenjin mcp` load this, and neither may pay for zod, the config schema or\n * the runtime's writer. The config is read raw for the same reason.\n *\n * <root>/auto-update.json when the last run started, and how it ended\n * <root>/auto-update.log the last run's output, overwritten each run\n */\n\nexport const AUTO_UPDATE_FILE = 'auto-update.json';\nexport const AUTO_UPDATE_LOG = 'auto-update.log';\n\nconst DAY_MS = 86_400_000;\n\n/** Why no background update starts while Node checks no TLS certificate. */\nexport const TLS_OFF =\n 'TLS certificate checks are turned off (NODE_TLS_REJECT_UNAUTHORIZED=0); set NODE_EXTRA_CA_CERTS instead';\n\nexport interface AutoUpdateRecord {\n /** When the last background run was started (ISO). */\n startedAt?: string;\n /** When it finished (ISO); absent while it runs, or if it died. */\n finishedAt?: string;\n outcome?: 'updated' | 'current' | 'failed' | 'skipped';\n from?: string;\n to?: string;\n reason?: string;\n}\n\ntype Spawn = typeof spawn;\n\n/**\n * Start the background update if one is due. Synchronous and never throws:\n * every gate that does not hold returns without spawning, and so does any\n * error, since the session it rides on must start regardless.\n */\nexport function maybeAutoUpdate(o: {\n dataDir: string;\n env: NodeJS.ProcessEnv;\n home?: string;\n now?: () => number;\n spawnImpl?: Spawn;\n}): void {\n try {\n const { env } = o;\n // The same two doors the update nudge has (lib/update-check).\n if (env.CI !== undefined && env.CI.length > 0) return;\n if (env.TENJIN_NO_UPDATE_CHECK === '1') return;\n const home = o.home ?? homedir();\n if (!isDefaultDataDir(o.dataDir, home)) return;\n if (!autoMode(o.dataDir)) return;\n\n const root = runtimeDir(o.dataDir);\n const state = readRuntimeState(root);\n if (state === null) return;\n const node = nodeBinPath(root, state.current.node);\n const entry = versionEntry(root, state.current.cli);\n if (!existsSync(node) || !existsSync(entry)) return;\n\n const nowMs = (o.now ?? Date.now)();\n const previous = readAutoUpdate(root);\n const started = Date.parse(previous?.startedAt ?? '');\n // A start in the future (a clock set back) counts as due, not as a day away.\n if (!Number.isNaN(started) && nowMs - started >= 0 && nowMs - started < DAY_MS) return;\n\n // NOT WITH TLS CERTIFICATE CHECKS TURNED OFF: the child inherits this\n // environment, and then anyone on the network path can answer for the\n // registry, the dist-tags, the attestations and the tarball alike, so no\n // check the update makes would hold. Recorded as a run, once a day, so\n // doctor names the cause and the fix.\n if (env.NODE_TLS_REJECT_UNAUTHORIZED === '0') {\n const at = new Date(nowMs).toISOString();\n writeRecord(root, { startedAt: at, finishedAt: at, outcome: 'skipped', reason: TLS_OFF });\n return;\n }\n\n // Stamped BEFORE the spawn, so a second session starting in the same\n // second finds it and stays put. The last result is kept for doctor.\n writeRecord(root, { ...previous, startedAt: new Date(nowMs).toISOString() });\n const fd = openSync(join(root, AUTO_UPDATE_LOG), 'w', 0o600);\n try {\n const child = (o.spawnImpl ?? spawn)(node, [entry, 'update', '--background'], {\n detached: true,\n stdio: ['ignore', fd, fd],\n cwd: home,\n windowsHide: true,\n // The child's own nudge would ask npm again for what it just learned.\n env: { ...env, TENJIN_NO_UPDATE_CHECK: '1' },\n });\n child.on('error', () => undefined);\n child.unref();\n } finally {\n closeSync(fd);\n }\n } catch {\n // Never the session's business.\n }\n}\n\n/**\n * `update.mode` as stored, read without the config schema: absent (the\n * default) or `auto` runs; `nudge` and `off` were typed by the person, and an\n * unparsable file is not read as consent. A missing file is the default.\n */\nfunction autoMode(dataDir: string): boolean {\n let text: string;\n try {\n text = readFileSync(configPath(dataDir), 'utf8');\n } catch {\n return true;\n }\n const raw = JSON.parse(text) as { update?: { mode?: unknown } } | null;\n const mode = raw?.update?.mode;\n return mode === undefined || mode === 'auto';\n}\n\n/** The last run's record, or null when there is none or it is unreadable. */\nexport function readAutoUpdate(root: string): AutoUpdateRecord | null {\n try {\n const raw = JSON.parse(readFileSync(join(root, AUTO_UPDATE_FILE), 'utf8')) as unknown;\n return typeof raw === 'object' && raw !== null && !Array.isArray(raw)\n ? (raw as AutoUpdateRecord)\n : null;\n } catch {\n return null;\n }\n}\n\n/**\n * Replace the record with how a run ended, keeping when it started, so no\n * field of an earlier run survives into this one. Throws; the caller decides.\n */\nexport function recordAutoUpdate(root: string, result: Omit<AutoUpdateRecord, 'startedAt'>): void {\n const startedAt = readAutoUpdate(root)?.startedAt;\n writeRecord(root, { ...(startedAt !== undefined ? { startedAt } : {}), ...result });\n}\n\nfunction writeRecord(root: string, record: AutoUpdateRecord): void {\n const path = join(root, AUTO_UPDATE_FILE);\n const tmp = `${path}.${process.pid}.tmp`;\n writeFileSync(tmp, `${JSON.stringify(record, null, 2)}\\n`, { mode: 0o600 });\n renameSync(tmp, path);\n}\n\n/** Doctor's one line about the last finished run, or null when there is none. */\nexport function autoUpdateLine(root: string): string | null {\n const r = readAutoUpdate(root);\n if (r === null || r.finishedAt === undefined) return null;\n const when = r.finishedAt.slice(0, 10);\n if (r.outcome === 'updated') return `Auto-update: ${when} updated ${r.from} -> ${r.to}`;\n if (r.outcome === 'current') return `Auto-update: ${when} up to date (${r.to ?? r.from})`;\n if (r.outcome === 'failed') return `Auto-update: ${when} failed: ${r.reason ?? 'unknown'}`;\n // A run that chose to wait (a release under a day old, TLS checks turned\n // off) says why, so the person sees what holds the update back.\n if (r.outcome === 'skipped' && r.reason !== undefined) {\n return `Auto-update: ${when} skipped: ${r.reason}`;\n }\n return null;\n}\n"],"mappings":";;;;;;;;;;;;;AAAA,SAAS,aAAa;AACtB,SAAS,WAAW,YAAY,UAAU,cAAc,YAAY,qBAAqB;AACzF,SAAS,eAAe;AACxB,SAAS,YAAY;AA6Bd,IAAM,mBAAmB;AACzB,IAAM,kBAAkB;AAE/B,IAAM,SAAS;AAGR,IAAM,UACX;AAoBK,SAAS,gBAAgB,GAMvB;AACP,MAAI;AACF,UAAM,EAAE,IAAI,IAAI;AAEhB,QAAI,IAAI,OAAO,UAAa,IAAI,GAAG,SAAS,EAAG;AAC/C,QAAI,IAAI,2BAA2B,IAAK;AACxC,UAAM,OAAO,EAAE,QAAQ,QAAQ;AAC/B,QAAI,CAAC,iBAAiB,EAAE,SAAS,IAAI,EAAG;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AAO,gBAAgB,IAAI,YAAY,EAAE,UAAU,SAAS;AAGxF,MAAI,EAAE,YAAY,aAAa,EAAE,WAAW,QAAW;AACrD,WAAO,gBAAgB,IAAI,aAAa,EAAE,MAAM;AAAA,EAClD;AACA,SAAO;AACT;","names":[]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createRequire as __tenjinCreateRequire } from 'node:module'; const require = __tenjinCreateRequire(import.meta.url);
|
|
2
2
|
import {
|
|
3
3
|
package_default
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-3Y2EHT4F.js";
|
|
5
5
|
|
|
6
6
|
// src/router/mcp-processes.ts
|
|
7
7
|
import { execFile } from "node:child_process";
|
|
@@ -195,4 +195,4 @@ export {
|
|
|
195
195
|
readProcessSnapshot,
|
|
196
196
|
readMcpServers
|
|
197
197
|
};
|
|
198
|
-
//# sourceMappingURL=chunk-
|
|
198
|
+
//# sourceMappingURL=chunk-F43CV6UC.js.map
|
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
p,
|
|
6
6
|
r,
|
|
7
7
|
t
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-JNUKLSMZ.js";
|
|
9
9
|
|
|
10
10
|
// node_modules/.pnpm/@signinwithethereum+siwe@4.2.0_viem@2.55.2_typescript@6.0.3_zod@4.6.7_/node_modules/@signinwithethereum/siwe/dist/viemAdapter-By13KInL.js
|
|
11
11
|
var a2 = /* @__PURE__ */ t({ createViemConfig: () => s });
|
|
@@ -28,7 +28,7 @@ var o = [{
|
|
|
28
28
|
async function s(e) {
|
|
29
29
|
let a3;
|
|
30
30
|
try {
|
|
31
|
-
a3 = await import("./_esm-
|
|
31
|
+
a3 = await import("./_esm-2KST7HQ7.js");
|
|
32
32
|
} catch {
|
|
33
33
|
throw new r(i.MISSING_PROVIDER_LIBRARY, "viem installed (npm install viem)", "viem not found");
|
|
34
34
|
}
|
|
@@ -67,4 +67,4 @@ export {
|
|
|
67
67
|
a2 as a,
|
|
68
68
|
s
|
|
69
69
|
};
|
|
70
|
-
//# sourceMappingURL=chunk-
|
|
70
|
+
//# sourceMappingURL=chunk-FKVJKLPI.js.map
|
|
@@ -5,19 +5,19 @@ import {
|
|
|
5
5
|
emptyLedger,
|
|
6
6
|
readLedger,
|
|
7
7
|
spentOf
|
|
8
|
-
} from "./chunk-
|
|
9
|
-
import {
|
|
10
|
-
evaluateSpendPolicy
|
|
11
|
-
} from "./chunk-2SNUOHAT.js";
|
|
8
|
+
} from "./chunk-HPRVFJPM.js";
|
|
12
9
|
import {
|
|
13
10
|
withFileLock
|
|
14
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-2W4DQQUU.js";
|
|
12
|
+
import {
|
|
13
|
+
evaluateSpendPolicy
|
|
14
|
+
} from "./chunk-MEZJ3I63.js";
|
|
15
15
|
import {
|
|
16
16
|
writeFileAtomic
|
|
17
17
|
} from "./chunk-7WEQQJLG.js";
|
|
18
18
|
import {
|
|
19
19
|
spendLedgerPath
|
|
20
|
-
} from "./chunk-
|
|
20
|
+
} from "./chunk-JTX3BUDK.js";
|
|
21
21
|
|
|
22
22
|
// src/lib/wallet/spend.ts
|
|
23
23
|
import { mkdir } from "node:fs/promises";
|
|
@@ -184,9 +184,60 @@ async function releaseUnchargedExposure(dir, nonce, opts = {}) {
|
|
|
184
184
|
return null;
|
|
185
185
|
}
|
|
186
186
|
}
|
|
187
|
+
async function creditRefundedExposure(dir, run, refundedAtomic, opts = {}) {
|
|
188
|
+
const path = spendLedgerPath(dir);
|
|
189
|
+
const nowMs = (opts.now ?? Date.now)();
|
|
190
|
+
try {
|
|
191
|
+
return await withFileLock(`${path}.lock`, async () => {
|
|
192
|
+
const { ledger } = await readLedger(path);
|
|
193
|
+
if (ledger === null || nowMs - ledger.windowStartMs >= (opts.windowMs ?? DEFAULT_WINDOW_MS)) {
|
|
194
|
+
return 0n;
|
|
195
|
+
}
|
|
196
|
+
const exposures = ledger.exposures ?? [];
|
|
197
|
+
const own = exposures.filter((e) => e.nonce.startsWith(run.prefix) && e.mode !== "manual");
|
|
198
|
+
if (own.length === 0) return 0n;
|
|
199
|
+
const counted = own.reduce((sum, e) => sum + BigInt(e.amountAtomic), 0n);
|
|
200
|
+
const amount = refundedAtomic < counted ? refundedAtomic : counted;
|
|
201
|
+
const less = (value, fallback) => {
|
|
202
|
+
const current = BigInt(value ?? fallback);
|
|
203
|
+
return (current > amount ? current - amount : 0n).toString();
|
|
204
|
+
};
|
|
205
|
+
await writeFileAtomic(
|
|
206
|
+
path,
|
|
207
|
+
`${JSON.stringify(
|
|
208
|
+
{
|
|
209
|
+
...ledger,
|
|
210
|
+
committedAtomic: less(ledger.committedAtomic, "0"),
|
|
211
|
+
automaticCommittedAtomic: less(ledger.automaticCommittedAtomic, ledger.committedAtomic),
|
|
212
|
+
settledAtomic: less(ledger.settledAtomic, ledger.committedAtomic),
|
|
213
|
+
exposures: [
|
|
214
|
+
...exposures.filter((e) => !own.includes(e)),
|
|
215
|
+
...counted > amount ? [
|
|
216
|
+
{
|
|
217
|
+
nonce: run.kept,
|
|
218
|
+
amountAtomic: (counted - amount).toString(),
|
|
219
|
+
atMs: nowMs,
|
|
220
|
+
mode: "automatic"
|
|
221
|
+
}
|
|
222
|
+
] : []
|
|
223
|
+
]
|
|
224
|
+
},
|
|
225
|
+
null,
|
|
226
|
+
2
|
|
227
|
+
)}
|
|
228
|
+
`,
|
|
229
|
+
{ mode: 384, dirMode: 448 }
|
|
230
|
+
);
|
|
231
|
+
return amount;
|
|
232
|
+
});
|
|
233
|
+
} catch {
|
|
234
|
+
return null;
|
|
235
|
+
}
|
|
236
|
+
}
|
|
187
237
|
|
|
188
238
|
export {
|
|
189
239
|
createLocalSpendAuthorizer,
|
|
190
|
-
releaseUnchargedExposure
|
|
240
|
+
releaseUnchargedExposure,
|
|
241
|
+
creditRefundedExposure
|
|
191
242
|
};
|
|
192
|
-
//# sourceMappingURL=chunk-
|
|
243
|
+
//# sourceMappingURL=chunk-FYFHH7V5.js.map
|