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
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/lib/held-lock.ts","../src/lib/held-lock-sqlite.ts"],"sourcesContent":["import {\n closeSync,\n constants,\n fstatSync,\n openSync,\n statSync,\n unlinkSync,\n type Stats,\n} from 'node:fs';\nimport { opendir } from 'node:fs/promises';\nimport { join } from 'node:path';\nimport { performance } from 'node:perf_hooks';\nimport { setTimeout as delay } from 'node:timers/promises';\nimport { hasCode } from './errno';\nimport { loadSqlite, sqliteAttempt } from './held-lock-sqlite';\nimport { LockTimeoutError } from './lock';\n\n/**\n * A LOCK THAT ENDS WITH THE PROCESS THAT HOLDS IT. Nothing is ever taken over from a live\n * process, and a dead holder never blocks for good:\n *\n * - macOS and Windows: an exclusive open of the never-written `<path>.held` file. The system\n * drops the lock when the holder's process ends, at whatever line it dies.\n * - Linux: an exclusive SQLite transaction on the same never-written file (`node:sqlite`, see\n * `held-lock-sqlite.ts`), which the kernel drops when the holder's process ends.\n *\n * Callers pass the lock path WITHOUT the suffix and never branch on the platform. A held lock\n * file is never opened, read or deleted by anything else in a process that may hold it: on\n * Windows a second open fails, and on every platform a sweep may remove a lock file only through\n * {@link discardHeldLock}.\n */\n\n/** The platform or filesystem cannot lock. */\nexport class LockUnavailableError extends Error {\n constructor(message: string) {\n super(message);\n this.name = 'LockUnavailableError';\n }\n}\n\n/** The wait for a held lock ran out. A live process holds it, so nothing here is stale. */\nexport class HeldLockTimeoutError extends LockTimeoutError {\n constructor(lockPath: string, timeoutMs: number) {\n super(lockPath, timeoutMs);\n const held = `${lockPath}.held`;\n // The lock file itself is what is held: it is never removed by hand.\n (this as { lockPath: string }).lockPath = held;\n this.message = `Timed out waiting for lock ${held} after ${timeoutMs}ms. Another Tenjin process holds it, and the lock ends when that process ends; do not delete the file.`;\n }\n}\n\nexport interface HeldLockOptions {\n /** Give up after this long (ms), on a monotonic clock. 0 is one attempt, a probe. Default 5000. */\n timeoutMs?: number;\n /** Poll interval while the lock is held (ms). Default 25. */\n retryMs?: number;\n /** Stops waiting. Once the lock is held, the caller owns cancellation. */\n signal?: AbortSignal;\n}\n\n/** One acquisition: `tryOnce` is one attempt, and `abandon` cleans up after a failed wait. */\nexport interface Attempt {\n tryOnce(): (() => void) | null;\n abandon(): void;\n}\nexport type AttemptFactory = (heldPath: string) => Attempt;\n\n/** Whether a file name in a store is a lock file. */\nexport const isHeldLockName = (name: string) => name.endsWith('.held');\n\n/** The exclusive-open flags, numeric because Node exports neither `O_EXLOCK` nor libuv's. */\nconst O_EXLOCK_DARWIN = 0x20;\nconst UV_FS_O_EXLOCK_WIN32 = 0x10000000;\n\nexport interface OpenDeps {\n platform: 'darwin' | 'win32';\n open(path: string, flags: number, mode: number): number;\n close(fd: number): void;\n fstat(fd: number): Stats;\n stat(path: string): Stats;\n}\n\nexport const systemOpenDeps = (platform: 'darwin' | 'win32'): OpenDeps => ({\n platform,\n open: openSync,\n close: closeSync,\n fstat: fstatSync,\n stat: (path) => statSync(path),\n});\n\n/** The error that says the file is held by another exclusive open. */\nconst isHeld = (platform: 'darwin' | 'win32', error: unknown) =>\n platform === 'darwin'\n ? hasCode(error, 'EAGAIN') || hasCode(error, 'EWOULDBLOCK')\n : hasCode(error, 'EBUSY');\n\nconst INODE_RETRIES = 5;\n/** Once per process: a Node that ignores the flag fails every later lock the same way. */\nlet selfTestState: 'untested' | 'passed' | 'failed' = 'untested';\n\n/** Exclusive open of `file`, for macOS and Windows. */\nexport function openAttempt(file: string, deps: OpenDeps): Attempt {\n const flags =\n deps.platform === 'darwin'\n ? constants.O_RDWR |\n constants.O_CREAT |\n constants.O_NOFOLLOW |\n constants.O_NONBLOCK |\n O_EXLOCK_DARWIN\n : constants.O_RDWR | constants.O_CREAT | UV_FS_O_EXLOCK_WIN32;\n const openOnce = (): number | null => {\n try {\n return deps.open(file, flags, 0o600);\n } catch (error) {\n if (isHeld(deps.platform, error)) return null;\n // The filesystem has no locks: fail closed with a name for it.\n if (hasCode(error, 'EOPNOTSUPP') || hasCode(error, 'ENOTSUP'))\n throw new LockUnavailableError(`This filesystem cannot lock ${file}`);\n throw error;\n }\n };\n return {\n tryOnce() {\n for (let attempt = 0; attempt < INODE_RETRIES; attempt++) {\n if (selfTestState === 'failed') throw new LockUnavailableError(NO_FLAG);\n const fd = openOnce();\n if (fd === null) return null;\n // A file deleted (or replaced) between the open and now is another inode: the lock on\n // this one guards nothing, so open again.\n let same: boolean;\n try {\n same = deps.fstat(fd).ino === deps.stat(file).ino;\n } catch {\n same = false;\n }\n if (!same) {\n deps.close(fd);\n continue;\n }\n if (selfTestState === 'untested') {\n selfTest(fd, openOnce, deps);\n selfTestState = 'passed';\n }\n let closed = false;\n return () => {\n if (closed) return;\n closed = true;\n deps.close(fd);\n };\n }\n return null;\n },\n abandon() {\n // Nothing is held between attempts.\n },\n };\n}\n\nconst NO_FLAG = 'This Node does not honour the exclusive-open flag, so Tenjin cannot lock files.';\n\n/** A second exclusive open of the held file must fail as held; a Node that ignores the flag fails loudly. */\nfunction selfTest(fd: number, openOnce: () => number | null, deps: OpenDeps) {\n let second: number | null;\n try {\n second = openOnce();\n } catch (error) {\n deps.close(fd);\n throw error;\n }\n if (second === null) return;\n deps.close(second);\n deps.close(fd);\n selfTestState = 'failed';\n throw new LockUnavailableError(NO_FLAG);\n}\n\n/** Forgets the self-test result. For tests only. */\nexport function resetSelfTest() {\n selfTestState = 'untested';\n}\n\nfunction defaultFactory(): AttemptFactory {\n const { platform } = process;\n if (platform === 'darwin' || platform === 'win32')\n return (held) => openAttempt(held, systemOpenDeps(platform));\n if (platform === 'linux')\n return (held) => {\n const sqlite = loadSqlite();\n if (!sqlite) throw new LockUnavailableError(SQLITE_MISSING);\n return sqliteAttempt(held, sqlite);\n };\n return () => {\n throw new LockUnavailableError(`Tenjin cannot lock files on ${platform}`);\n };\n}\nconst factory = defaultFactory();\n\nconst SQLITE_MISSING = `Subagent workers on Linux need Node 22.13 or later; this is Node ${process.versions.node}.`;\n\n/**\n * Whether this platform and Node can take a held lock, and if not, one sentence why. Linux needs\n * the built-in node:sqlite (Node 22.13 or later); macOS and Windows need nothing.\n */\nexport function lockSupport(): { ok: true } | { ok: false; reason: string } {\n const { platform } = process;\n if (platform === 'darwin' || platform === 'win32') return { ok: true };\n if (platform === 'linux')\n return loadSqlite() ? { ok: true } : { ok: false, reason: SQLITE_MISSING };\n return { ok: false, reason: `Tenjin cannot lock files on ${platform}.` };\n}\n\n/**\n * The wait loop shared by every platform. Takes the lock, or throws {@link HeldLockTimeoutError}\n * after `timeoutMs` on a monotonic clock, or throws the signal's reason once it aborts. The\n * returned release is idempotent.\n */\nexport async function holdLockWith(\n make: AttemptFactory,\n lockPath: string,\n o: HeldLockOptions = {},\n): Promise<() => void> {\n const { timeoutMs = 5000, retryMs = 25, signal } = o;\n const deadline = performance.now() + timeoutMs;\n const attempt = make(`${lockPath}.held`);\n try {\n for (;;) {\n signal?.throwIfAborted();\n const release = attempt.tryOnce();\n if (release) return release;\n if (performance.now() >= deadline) throw new HeldLockTimeoutError(lockPath, timeoutMs);\n await delay(retryMs, undefined, { signal });\n }\n } catch (error) {\n attempt.abandon();\n throw error;\n }\n}\n\nexport const holdLock = (lockPath: string, o?: HeldLockOptions) =>\n holdLockWith(factory, lockPath, o);\n\nexport async function withHeldLock<T>(\n lockPath: string,\n fn: () => Promise<T>,\n o?: HeldLockOptions,\n): Promise<T> {\n const release = await holdLock(lockPath, o);\n try {\n return await fn();\n } finally {\n release();\n }\n}\n\n/**\n * Removes a lock file no one holds, for the job sweep, except on Linux, where lock files are\n * never removed and this returns false: macOS and Linux probe, unlink while\n * holding and then close (an opener that resolved the old file notices its inode changed and\n * starts over); Windows probes, closes and then unlinks, ignoring a lost race. A lock that is\n * held is left alone. True when the lock is gone afterwards.\n */\nexport async function discardHeldLock(lockPath: string): Promise<boolean> {\n const held = `${lockPath}.held`;\n // Linux keeps every lock file. A deleted lock file can still be locked by the process that\n // opened it before the delete, while another process creates and locks its replacement: two\n // holders at once, with no way to see it from the path. If no code deletes a lock file, that\n // cannot happen. The cost is one empty file for each job.\n if (process.platform === 'linux') return false;\n let release: () => void;\n try {\n release = await holdLockWith(factory, lockPath, { timeoutMs: 0 });\n } catch (error) {\n if (error instanceof LockTimeoutError) return false;\n throw error;\n }\n if (process.platform !== 'win32') {\n try {\n unlinkSync(held);\n return true;\n } catch (error) {\n return hasCode(error, 'ENOENT');\n } finally {\n release();\n }\n }\n release();\n try {\n unlinkSync(held);\n return true;\n } catch (error) {\n // An opener slipped in and keeps a valid lock.\n return hasCode(error, 'ENOENT');\n }\n}\n\n/**\n * Housekeeping for the lock files in `dir`: a `*.held` name is discarded through\n * {@link discardHeldLock} when `eligible` says so (the sweep passes only what belongs to a job\n * that is final and idle). Never throws.\n */\nexport async function sweepHeldLocks(\n dir: string,\n eligible: (name: string) => Promise<boolean>,\n limit = 50_000,\n): Promise<void> {\n try {\n let seen = 0;\n for await (const entry of await opendir(dir)) {\n if (++seen > limit) return;\n const path = join(dir, entry.name);\n if (!entry.name.endsWith('.held')) continue;\n if (await eligible(entry.name).catch(() => false))\n await discardHeldLock(path.slice(0, -'.held'.length)).catch(() => false);\n }\n } catch {\n // Housekeeping only.\n }\n}\n","import { chmodSync, statSync } from 'node:fs';\nimport type { DatabaseSync } from 'node:sqlite';\nimport type { Attempt } from './held-lock';\n\n/**\n * THE LINUX HALF OF A HELD LOCK. Node's standard library has no file lock the system releases\n * when its process ends, except through `node:sqlite`: an exclusive SQLite transaction on a\n * dedicated, never-written, never-deleted-while-held file. SQLite takes a POSIX byte-range lock\n * on it, which the kernel drops when the holder's process ends (a crash, SIGKILL, a container\n * restart) and which holds across pid namespaces. Nothing is taken over, no pid is read.\n *\n * FILE RULES. Nothing but this module opens, reads or writes the lock file in a process that may\n * hold it: closing ANY other descriptor of the file drops the process's POSIX locks. SQLite's own\n * connections are safe. A lock database is never written, so it has no journal.\n */\nexport type Sqlite = typeof import('node:sqlite');\n\nlet loaded: Sqlite | null | undefined;\n/** Forgets what was loaded. For tests only. */\nexport function forgetSqlite() {\n loaded = undefined;\n}\n/**\n * `node:sqlite`, loaded the first time a Linux lock is needed and nowhere else: null when this\n * Node has none (before 22.13 it needs a flag). Node 22.13 to 24.14 print an ExperimentalWarning\n * on load, which would reach hook or MCP stderr, so that one warning is dropped.\n */\nexport function loadSqlite(): Sqlite | null {\n if (loaded !== undefined) return loaded;\n const original = process.emitWarning;\n process.emitWarning = ((warning: string | Error, ...rest: unknown[]) => {\n const text = typeof warning === 'string' ? warning : (warning?.message ?? '');\n if (/sqlite/i.test(text)) return;\n return (original as (...args: unknown[]) => void).call(process, warning, ...rest);\n }) as typeof process.emitWarning;\n try {\n loaded = process.getBuiltinModule?.('node:sqlite') ?? null;\n } catch {\n loaded = null;\n } finally {\n process.emitWarning = original;\n }\n return loaded;\n}\n\n/** SQLITE_BUSY (5), including its extended codes. */\nfunction isBusy(error: unknown): boolean {\n if (typeof error !== 'object' || error === null) return false;\n const { errcode, message } = error as { errcode?: unknown; message?: unknown };\n if (typeof errcode === 'number') return errcode % 256 === 5;\n return typeof message === 'string' && /database is locked/i.test(message);\n}\n\nconst inoOf = (file: string): number | undefined => {\n try {\n return statSync(file).ino;\n } catch {\n return undefined;\n }\n};\n\n/** One acquisition: one connection, `BEGIN EXCLUSIVE` retried on it, `ROLLBACK` and close to release. */\nexport function sqliteAttempt(file: string, sqlite: Sqlite): Attempt {\n let db: DatabaseSync | undefined;\n let ino: number | undefined;\n const close = () => {\n try {\n db?.close();\n } catch {\n // Already closed.\n }\n db = undefined;\n };\n return {\n tryOnce() {\n // The parent folder must exist. Opening creates the zero-byte file and takes no lock.\n if (!db) {\n db = new sqlite.DatabaseSync(file);\n // SQLite creates the file with the umask's mode; the lock file is the user's alone. A\n // chmod opens no descriptor, so it cannot drop a lock this process holds.\n chmodSync(file, 0o600);\n ino = inoOf(file);\n }\n try {\n db.exec('BEGIN EXCLUSIVE');\n } catch (error) {\n if (isBusy(error)) return null;\n // SQLite refuses a file that was moved or deleted under it (a disk I/O error): the lock\n // file is a new one, so start over on it.\n const moved = inoOf(file) !== ino;\n close();\n if (moved) return this.tryOnce();\n throw error;\n }\n // A file deleted after this connection opened it (by the job sweep) is another inode: the\n // lock held on this one guards nothing, so start over on the new file.\n if (inoOf(file) !== ino) {\n try {\n db.exec('ROLLBACK');\n } finally {\n close();\n }\n return this.tryOnce();\n }\n const held = db;\n db = undefined;\n let released = false;\n return () => {\n if (released) return;\n released = true;\n try {\n held.exec('ROLLBACK');\n } finally {\n held.close();\n }\n };\n },\n abandon: close,\n };\n}\n"],"mappings":";;;;;;;;;AAAA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,YAAAA;AAAA,EACA;AAAA,OAEK;AACP,SAAS,eAAe;AACxB,SAAS,YAAY;AACrB,SAAS,mBAAmB;AAC5B,SAAS,cAAc,aAAa;;;ACZpC,SAAS,WAAW,gBAAgB;AAiBpC,IAAI;AAUG,SAAS,aAA4B;AAC1C,MAAI,W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
+
import { createRequire as __tenjinCreateRequire } from 'node:module'; const require = __tenjinCreateRequire(import.meta.url);
|
|
2
|
+
|
|
3
|
+
// src/lib/open-url.ts
|
|
4
|
+
import { execFile } from "node:child_process";
|
|
5
|
+
import { existsSync } from "node:fs";
|
|
6
|
+
import { homedir } from "node:os";
|
|
7
|
+
import { join } from "node:path";
|
|
8
|
+
var OPEN_TIMEOUT_MS = 5e3;
|
|
9
|
+
var MAC_OPEN = "/usr/bin/open";
|
|
10
|
+
var XDG_OPEN_CANDIDATES = [
|
|
11
|
+
"/usr/bin/xdg-open",
|
|
12
|
+
"/bin/xdg-open",
|
|
13
|
+
"/usr/local/bin/xdg-open"
|
|
14
|
+
];
|
|
15
|
+
var BUNDLE_ID = /^[A-Za-z0-9][A-Za-z0-9.-]*$/;
|
|
16
|
+
function openerFor(platform, existsImpl = existsSync) {
|
|
17
|
+
if (platform === "darwin") return { cmd: MAC_OPEN, args: [] };
|
|
18
|
+
if (platform === "win32") return { cmd: "rundll32", args: ["url.dll,FileProtocolHandler"] };
|
|
19
|
+
const found = XDG_OPEN_CANDIDATES.find((p) => existsImpl(p));
|
|
20
|
+
return { cmd: found ?? XDG_OPEN_CANDIDATES[0], args: [] };
|
|
21
|
+
}
|
|
22
|
+
function openerEnv(base) {
|
|
23
|
+
const env = { ...base };
|
|
24
|
+
delete env.BROWSER;
|
|
25
|
+
return env;
|
|
26
|
+
}
|
|
27
|
+
async function macDefaultBrowserBundleId(run, homeDir, env) {
|
|
28
|
+
const plist = join(
|
|
29
|
+
homeDir,
|
|
30
|
+
"Library/Preferences/com.apple.LaunchServices/com.apple.launchservices.secure.plist"
|
|
31
|
+
);
|
|
32
|
+
const out = await new Promise((resolve) => {
|
|
33
|
+
run(
|
|
34
|
+
"/usr/bin/plutil",
|
|
35
|
+
["-convert", "json", "-o", "-", plist],
|
|
36
|
+
{ timeout: OPEN_TIMEOUT_MS, env },
|
|
37
|
+
(err, stdout) => resolve(err === null ? String(stdout) : void 0)
|
|
38
|
+
);
|
|
39
|
+
});
|
|
40
|
+
if (out === void 0) return void 0;
|
|
41
|
+
try {
|
|
42
|
+
const parsed = JSON.parse(out);
|
|
43
|
+
if (!Array.isArray(parsed.LSHandlers)) return void 0;
|
|
44
|
+
for (const entry of parsed.LSHandlers) {
|
|
45
|
+
const scheme = entry.LSHandlerURLScheme;
|
|
46
|
+
if (typeof scheme !== "string" || scheme.toLowerCase() !== "https") continue;
|
|
47
|
+
const id = entry.LSHandlerRoleAll ?? entry.LSHandlerRoleViewer;
|
|
48
|
+
if (typeof id === "string" && BUNDLE_ID.test(id)) return id;
|
|
49
|
+
}
|
|
50
|
+
} catch {
|
|
51
|
+
return void 0;
|
|
52
|
+
}
|
|
53
|
+
return void 0;
|
|
54
|
+
}
|
|
55
|
+
async function openInBrowser(url, opts = {}) {
|
|
56
|
+
const platform = opts.platform ?? process.platform;
|
|
57
|
+
const run = opts.execFileImpl ?? execFile;
|
|
58
|
+
const env = openerEnv(opts.env ?? process.env);
|
|
59
|
+
const { cmd, args } = openerFor(platform, opts.existsImpl);
|
|
60
|
+
const launch = (extra) => new Promise((resolve) => {
|
|
61
|
+
run(
|
|
62
|
+
cmd,
|
|
63
|
+
[...args, ...extra, url],
|
|
64
|
+
{ timeout: OPEN_TIMEOUT_MS, windowsHide: true, env },
|
|
65
|
+
(err) => resolve(err === null)
|
|
66
|
+
);
|
|
67
|
+
});
|
|
68
|
+
if (platform === "darwin") {
|
|
69
|
+
const bundleId = await macDefaultBrowserBundleId(run, opts.homeDir ?? homedir(), env);
|
|
70
|
+
if (bundleId !== void 0 && await launch(["-b", bundleId])) return true;
|
|
71
|
+
}
|
|
72
|
+
return await launch([]);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export {
|
|
76
|
+
openInBrowser
|
|
77
|
+
};
|
|
78
|
+
//# sourceMappingURL=chunk-U4TRWSVE.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/lib/open-url.ts"],"sourcesContent":["import { execFile } from 'node:child_process';\nimport { existsSync } from 'node:fs';\nimport { homedir } from 'node:os';\nimport { join } from 'node:path';\n\n/**\n * Open a URL in the user's real default browser, best-effort. Follows the\n * passphrase.ts subprocess rules: an argv array (never a shell), a hard\n * timeout, and failure as a return value rather than a throw — callers print\n * the URL first, so a machine without an opener degrades to copy/paste.\n *\n * The opener is an absolute system path, never a bare name looked up on PATH,\n * and the BROWSER variable and other host-provided hints are dropped from the\n * child's environment. An agent host (Claude Desktop, an IDE) can put a shim on\n * PATH or set BROWSER to route the link into its own embedded view, where Apple\n * Pay and Google Pay cannot complete. On macOS the system's default https\n * handler is looked up and named explicitly with `open -b`. If the default\n * browser is itself an embedded view there is nothing more this can do, and the\n * caller's printed link and QR remain the way out.\n *\n * Windows uses rundll32's FileProtocolHandler because `start` exists only\n * inside cmd.exe, and spawning a shell around an attacker-influenced string is\n * the injection shape this module exists to avoid.\n */\n\nexport interface OpenUrlOptions {\n platform?: NodeJS.Platform;\n execFileImpl?: typeof execFile;\n /** Test seam for the Linux opener search. */\n existsImpl?: (path: string) => boolean;\n /** Test seam for the macOS LaunchServices preferences location. */\n homeDir?: string;\n /** Test seam for the environment handed to the child. */\n env?: NodeJS.ProcessEnv;\n}\n\nconst OPEN_TIMEOUT_MS = 5000;\nconst MAC_OPEN = '/usr/bin/open';\nconst XDG_OPEN_CANDIDATES = [\n '/usr/bin/xdg-open',\n '/bin/xdg-open',\n '/usr/local/bin/xdg-open',\n] as const;\n/** What a bundle id may look like; keeps a hostile preference value from becoming a flag. */\nconst BUNDLE_ID = /^[A-Za-z0-9][A-Za-z0-9.-]*$/;\n\nexport function openerFor(\n platform: NodeJS.Platform,\n existsImpl: (path: string) => boolean = existsSync,\n): { cmd: string; args: string[] } {\n if (platform === 'darwin') return { cmd: MAC_OPEN, args: [] };\n if (platform === 'win32') return { cmd: 'rundll32', args: ['url.dll,FileProtocolHandler'] };\n const found = XDG_OPEN_CANDIDATES.find((p) => existsImpl(p));\n return { cmd: found ?? XDG_OPEN_CANDIDATES[0], args: [] };\n}\n\n/** The child's environment without BROWSER, which xdg-open and others honor over the system default. */\nfunction openerEnv(base: NodeJS.ProcessEnv): NodeJS.ProcessEnv {\n const env = { ...base };\n delete env.BROWSER;\n return env;\n}\n\n/**\n * The bundle id of the default https handler, read from the user's LaunchServices\n * preferences, or undefined when none is recorded (the OS default then applies)\n * or anything about the read fails.\n */\nasync function macDefaultBrowserBundleId(\n run: typeof execFile,\n homeDir: string,\n env: NodeJS.ProcessEnv,\n): Promise<string | undefined> {\n const plist = join(\n homeDir,\n 'Library/Preferences/com.apple.LaunchServices/com.apple.launchservices.secure.plist',\n );\n const out = await new Promise<string | undefined>((resolve) => {\n run(\n '/usr/bin/plutil',\n ['-convert', 'json', '-o', '-', plist],\n { timeout: OPEN_TIMEOUT_MS, env },\n (err, stdout) => resolve(err === null ? String(stdout) : undefined),\n );\n });\n if (out === undefined) return undefined;\n try {\n const parsed = JSON.parse(out) as { LSHandlers?: unknown };\n if (!Array.isArray(parsed.LSHandlers)) return undefined;\n for (const entry of parsed.LSHandlers as Record<string, unknown>[]) {\n const scheme = entry.LSHandlerURLScheme;\n if (typeof scheme !== 'string' || scheme.toLowerCase() !== 'https') continue;\n const id = entry.LSHandlerRoleAll ?? entry.LSHandlerRoleViewer;\n if (typeof id === 'string' && BUNDLE_ID.test(id)) return id;\n }\n } catch {\n return undefined;\n }\n return undefined;\n}\n\nexport async function openInBrowser(url: string, opts: OpenUrlOptions = {}): Promise<boolean> {\n const platform = opts.platform ?? process.platform;\n const run = opts.execFileImpl ?? execFile;\n const env = openerEnv(opts.env ?? process.env);\n const { cmd, args } = openerFor(platform, opts.existsImpl);\n const launch = (extra: string[]): Promise<boolean> =>\n new Promise((resolve) => {\n run(\n cmd,\n [...args, ...extra, url],\n { timeout: OPEN_TIMEOUT_MS, windowsHide: true, env },\n (err) => resolve(err === null),\n );\n });\n\n if (platform === 'darwin') {\n const bundleId = await macDefaultBrowserBundleId(run, opts.homeDir ?? homedir(), env);\n if (bundleId !== undefined && (await launch(['-b', bundleId]))) return true;\n }\n return await launch([]);\n}\n"],"mappings":";;;AAAA,SAAS,gBAAgB;AACzB,SAAS,kBAAkB;AAC3B,SAAS,eAAe;AACxB,SAAS,YAAY;AAiCrB,IAAM,kBAAkB;AACxB,IAAM,WAAW;AACjB,IAAM,sBAAsB;AAAA,EAC1B;AAAA,EACA;AAAA,EACA;AACF;AAEA,IAAM,YAAY;AAEX,SAAS,UACd,UACA,aAAwC,YACP;AACjC,MAAI,aAAa,SAAU,QAAO,EAAE,KAAK,UAAU,MAAM,CAAC,EAAE;AAC5D,MAAI,aAAa,QAAS,QAAO,EAAE,KAAK,YAAY,MAAM,CAAC,6BAA6B,EAAE;AAC1F,QAAM,QAAQ,oBAAoB,KAAK,CAAC,MAAM,WAAW,CAAC,CAAC;AAC3D,SAAO,EAAE,KAAK,SAAS,oBAAoB,CAAC,GAAG,MAAM,CAAC,EAAE;AAC1D;AAGA,SAAS,UAAU,MAA4C;AAC7D,QAAM,MAAM,EAAE,GAAG,KAAK;AACtB,SAAO,IAAI;AACX,SAAO;AACT;AAOA,eAAe,0BACb,KACA,SACA,KAC6B;AAC7B,QAAM,QAAQ;AAAA,IACZ;AAAA,IACA;AAAA,EACF;AACA,QAAM,MAAM,MAAM,IAAI,QAA4B,CAAC,YAAY;AAC7D;AAAA,MACE;AAAA,MACA,CAAC,YAAY,QAAQ,MAAM,KAAK,KAAK;AAAA,MACrC,EAAE,SAAS,iBAAiB,IAAI;AAAA,MAChC,CAAC,KAAK,WAAW,QAAQ,QAAQ,OAAO,OAAO,MAAM,IAAI,MAAS;AAAA,IACpE;AAAA,EACF,CAAC;AACD,MAAI,QAAQ,OAAW,QAAO;AAC9B,MAAI;AACF,UAAM,SAAS,KAAK,MAAM,GAAG;AAC7B,QAAI,CAAC,MAAM,QAAQ,OAAO,UAAU,EAAG,QAAO;AAC9C,eAAW,SAAS,OAAO,YAAyC;AAClE,YAAM,SAAS,MAAM;AACrB,UAAI,OAAO,WAAW,YAAY,OAAO,YAAY,MAAM,QAAS;AACpE,YAAM,KAAK,MAAM,oBAAoB,MAAM;AAC3C,UAAI,OAAO,OAAO,YAAY,UAAU,KAAK,EAAE,EAAG,QAAO;AAAA,IAC3D;AAAA,EACF,QAAQ;AACN,WAAO;AAAA,EACT;AACA,SAAO;AACT;AAEA,eAAsB,cAAc,KAAa,OAAuB,CAAC,GAAqB;AAC5F,QAAM,WAAW,KAAK,YAAY,QAAQ;AAC1C,QAAM,MAAM,KAAK,gBAAgB;AACjC,QAAM,MAAM,UAAU,KAAK,OAAO,QAAQ,GAAG;AAC7C,QAAM,EAAE,KAAK,KAAK,IAAI,UAAU,UAAU,KAAK,UAAU;AACzD,QAAM,SAAS,CAAC,UACd,IAAI,QAAQ,CAAC,YAAY;AACvB;AAAA,MACE;AAAA,MACA,CAAC,GAAG,MAAM,GAAG,OAAO,GAAG;AAAA,MACvB,EAAE,SAAS,iBAAiB,aAAa,MAAM,IAAI;AAAA,MACnD,CAAC,QAAQ,QAAQ,QAAQ,IAAI;AAAA,IAC/B;AAAA,EACF,CAAC;AAEH,MAAI,aAAa,UAAU;AACzB,UAAM,WAAW,MAAM,0BAA0B,KAAK,KAAK,WAAW,QAAQ,GAAG,GAAG;AACpF,QAAI,aAAa,UAAc,MAAM,OAAO,CAAC,MAAM,QAAQ,CAAC,EAAI,QAAO;AAAA,EACzE;AACA,SAAO,MAAM,OAAO,CAAC,CAAC;AACxB;","names":[]}
|
|
@@ -0,0 +1,379 @@
|
|
|
1
|
+
import { createRequire as __tenjinCreateRequire } from 'node:module'; const require = __tenjinCreateRequire(import.meta.url);
|
|
2
|
+
import {
|
|
3
|
+
DEFAULT_RPC_URL
|
|
4
|
+
} from "./chunk-ZCT5DJ3G.js";
|
|
5
|
+
import {
|
|
6
|
+
hasCode
|
|
7
|
+
} from "./chunk-3MZ7DYRO.js";
|
|
8
|
+
import {
|
|
9
|
+
configPath
|
|
10
|
+
} from "./chunk-JTX3BUDK.js";
|
|
11
|
+
import {
|
|
12
|
+
BUILT_IN_SOURCE,
|
|
13
|
+
REPLACEMENT_MODES,
|
|
14
|
+
ReplacementProvidersSchema,
|
|
15
|
+
SETTINGS_LIMITS,
|
|
16
|
+
SavedPolicySchema,
|
|
17
|
+
TargetIdSchema
|
|
18
|
+
} from "./chunk-RGCPELQN.js";
|
|
19
|
+
import {
|
|
20
|
+
PRODUCTION_ORIGIN
|
|
21
|
+
} from "./chunk-CRG54LEB.js";
|
|
22
|
+
import {
|
|
23
|
+
external_exports
|
|
24
|
+
} from "./chunk-P6YQWIT2.js";
|
|
25
|
+
import {
|
|
26
|
+
CliError
|
|
27
|
+
} from "./chunk-DI4QAGRZ.js";
|
|
28
|
+
|
|
29
|
+
// src/lib/config.ts
|
|
30
|
+
import { readFile } from "node:fs/promises";
|
|
31
|
+
var atomicString = external_exports.string().regex(/^\d+$/, "expected an atomic USDC integer string");
|
|
32
|
+
var ROUTER_CONTEXTS = ["session", "turn"];
|
|
33
|
+
var RouterLayerSchema = external_exports.object({
|
|
34
|
+
enabled: external_exports.boolean().optional(),
|
|
35
|
+
context: external_exports.enum(ROUTER_CONTEXTS).optional(),
|
|
36
|
+
subagents: external_exports.boolean().optional()
|
|
37
|
+
});
|
|
38
|
+
var RouterGlobalSchema = RouterLayerSchema.extend({ improve: external_exports.boolean().optional() });
|
|
39
|
+
var RouterConfigSchema = RouterGlobalSchema.required();
|
|
40
|
+
var SourceDescriptorSchema = external_exports.looseObject({ id: TargetIdSchema });
|
|
41
|
+
var SourcesSchema = external_exports.array(SourceDescriptorSchema).max(SETTINGS_LIMITS.sources).superRefine((sources, ctx) => {
|
|
42
|
+
const seen = /* @__PURE__ */ new Set();
|
|
43
|
+
sources.forEach(({ id }, at) => {
|
|
44
|
+
if (id === BUILT_IN_SOURCE)
|
|
45
|
+
ctx.addIssue({ code: "custom", path: [at, "id"], message: `${id} is built in` });
|
|
46
|
+
if (seen.has(id))
|
|
47
|
+
ctx.addIssue({ code: "custom", path: [at, "id"], message: "an account is saved twice" });
|
|
48
|
+
seen.add(id);
|
|
49
|
+
});
|
|
50
|
+
});
|
|
51
|
+
function firstProblem(key, error) {
|
|
52
|
+
const [issue] = error.issues;
|
|
53
|
+
const path = [key, ...(issue?.path ?? []).map(String)].join(".");
|
|
54
|
+
return `${path}: ${issue?.message ?? "invalid"}`;
|
|
55
|
+
}
|
|
56
|
+
var ReplacementModeSchema = external_exports.enum(REPLACEMENT_MODES).optional();
|
|
57
|
+
function readPersonalRouter(router) {
|
|
58
|
+
const block = router !== null && typeof router === "object" ? router : {};
|
|
59
|
+
const policy = block.policy === void 0 ? void 0 : SavedPolicySchema.safeParse(block.policy);
|
|
60
|
+
const mode = ReplacementModeSchema.safeParse(block.nativeReplacement);
|
|
61
|
+
const providers = ReplacementProvidersSchema.optional().safeParse(
|
|
62
|
+
block.nativeReplacementProviders
|
|
63
|
+
);
|
|
64
|
+
const sources = SourcesSchema.optional().safeParse(block.sources);
|
|
65
|
+
const problem = !mode.success ? firstProblem("router.nativeReplacement", mode.error) : !providers.success ? firstProblem("router.nativeReplacementProviders", providers.error) : void 0;
|
|
66
|
+
return {
|
|
67
|
+
policy: policy === void 0 ? { status: "none" } : policy.success ? { status: "ok", saved: policy.data } : { status: "invalid", problem: firstProblem("router.policy", policy.error) },
|
|
68
|
+
nativeReplacement: problem !== void 0 ? { mode: "off", problem } : {
|
|
69
|
+
mode: mode.data ?? "off",
|
|
70
|
+
...providers.data !== void 0 ? { providers: providers.data } : {}
|
|
71
|
+
},
|
|
72
|
+
sources: sources.success ? { status: "ok", saved: sources.data ?? [] } : { status: "invalid", problem: firstProblem("router.sources", sources.error) }
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
function savedDescriptors(router) {
|
|
76
|
+
const sources = readPersonalRouter(router).sources;
|
|
77
|
+
if (sources.status === "invalid") {
|
|
78
|
+
throw new CliError(
|
|
79
|
+
"CONFIG_INVALID",
|
|
80
|
+
`Your saved accounts can't be read (${sources.problem}), so nothing was changed.`,
|
|
81
|
+
{ fix: "Fix or remove router.sources in your Tenjin config, then run the command again." }
|
|
82
|
+
);
|
|
83
|
+
}
|
|
84
|
+
return sources.saved;
|
|
85
|
+
}
|
|
86
|
+
function editSources(existing, edit) {
|
|
87
|
+
const router = { ...existing.router ?? {} };
|
|
88
|
+
const sources = edit(savedDescriptors(router));
|
|
89
|
+
if (sources.length > 0) router.sources = sources;
|
|
90
|
+
else delete router.sources;
|
|
91
|
+
return { ...existing, router };
|
|
92
|
+
}
|
|
93
|
+
function parseRouterLayer(json, path) {
|
|
94
|
+
if (json === null || typeof json !== "object" || Array.isArray(json)) {
|
|
95
|
+
throw new CliError("CONFIG_INVALID", `Config at ${path} is not a JSON object`, {
|
|
96
|
+
fix: `Fix ${path}, or delete it.`
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
const parsed = RouterLayerSchema.safeParse(json.router ?? {});
|
|
100
|
+
if (!parsed.success) {
|
|
101
|
+
throw new CliError("CONFIG_INVALID", `Config at ${path} has an invalid router block`, {
|
|
102
|
+
fix: `Use router.enabled true|false and router.context "session"|"turn" in ${path}, or delete it.`,
|
|
103
|
+
details: parsed.error.issues
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
const { enabled, context, subagents } = parsed.data;
|
|
107
|
+
return {
|
|
108
|
+
...enabled !== void 0 ? { enabled } : {},
|
|
109
|
+
...subagents !== void 0 ? { subagents } : {},
|
|
110
|
+
...context !== void 0 ? { context } : {}
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
var UpdateModeSchema = external_exports.enum(["auto", "nudge", "off"]);
|
|
114
|
+
var OnOffSchema = external_exports.enum(["on", "off"]);
|
|
115
|
+
var ExperimentalConfigSchema = external_exports.object({ bazaar: OnOffSchema });
|
|
116
|
+
function parseOnOffFlag(value, keyName) {
|
|
117
|
+
const parsed = OnOffSchema.safeParse(value);
|
|
118
|
+
if (parsed.success) return parsed.data;
|
|
119
|
+
throw new CliError("USAGE", `Invalid ${keyName}: ${JSON.stringify(value)}`, {
|
|
120
|
+
fix: 'Use "on" or "off".'
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
var UpdateConfigSchema = external_exports.object({
|
|
124
|
+
mode: UpdateModeSchema
|
|
125
|
+
});
|
|
126
|
+
function parseUpdateModeFlag(value, flagName) {
|
|
127
|
+
const parsed = UpdateModeSchema.safeParse(value);
|
|
128
|
+
if (parsed.success) return parsed.data;
|
|
129
|
+
throw new CliError("USAGE", `Invalid ${flagName} ${JSON.stringify(value)}`, {
|
|
130
|
+
fix: 'Use "auto", "nudge" or "off".'
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
var InstallConfigSchema = external_exports.object({
|
|
134
|
+
/**
|
|
135
|
+
* Absolute directories a `tenjin install --project` wired, so `tenjin update`
|
|
136
|
+
* can refresh them. It spawns `install --refresh` from the HOME directory,
|
|
137
|
+
* which is the one place a project install can never be found by looking
|
|
138
|
+
* around: without this list a project-only machine refreshed nothing and
|
|
139
|
+
* reported success while its hooks stayed on the old build.
|
|
140
|
+
*
|
|
141
|
+
* A LIST, because one machine can wire several projects, and entries are
|
|
142
|
+
* dropped by `tenjin uninstall --project` and by any refresh that finds the
|
|
143
|
+
* project's settings file no longer carries our entries.
|
|
144
|
+
*/
|
|
145
|
+
routerProjects: external_exports.array(external_exports.string()),
|
|
146
|
+
/** A new profile whose subagent question is still to be asked; neither consent nor an enabled feature. */
|
|
147
|
+
freshSetup: external_exports.literal(true).optional()
|
|
148
|
+
});
|
|
149
|
+
var ConfigSchema = external_exports.object({
|
|
150
|
+
maxAutoSpend: atomicString,
|
|
151
|
+
sessionBudget: external_exports.union([atomicString, external_exports.literal("none")]),
|
|
152
|
+
/**
|
|
153
|
+
* Hard per-send cap for `tenjin wallet send`, NOT satisfiable by --yes or a prompt
|
|
154
|
+
* (the spend-policy posture): an atomic amount caps each send, "0" disables
|
|
155
|
+
* the verb entirely, and "none" = explicitly uncapped (send exists to drain
|
|
156
|
+
* the wallet, but uncapped is an opt-in, never a default). The key has NO
|
|
157
|
+
* usable default: absent from config.json, `tenjin wallet send` refuses until it is
|
|
158
|
+
* set (see resolveSendMaxAmount). Client-enforced like every spend key (see
|
|
159
|
+
* the note above).
|
|
160
|
+
*/
|
|
161
|
+
sendMaxAmount: external_exports.union([external_exports.literal("none"), atomicString]),
|
|
162
|
+
allowlistCreators: external_exports.array(external_exports.string()),
|
|
163
|
+
/** The router's base URL: the Tenjin deployment every router call goes to. */
|
|
164
|
+
baseUrl: external_exports.url(),
|
|
165
|
+
rpcUrl: external_exports.url(),
|
|
166
|
+
/** x402 discovery registries (facilitator base URLs) the direct pay lane
|
|
167
|
+
* verifies a seller's listing against. */
|
|
168
|
+
bazaarRegistries: external_exports.array(external_exports.url()),
|
|
169
|
+
install: InstallConfigSchema,
|
|
170
|
+
update: UpdateConfigSchema,
|
|
171
|
+
router: RouterConfigSchema,
|
|
172
|
+
experimental: ExperimentalConfigSchema
|
|
173
|
+
});
|
|
174
|
+
var RawConfigSchema = ConfigSchema.partial().extend({
|
|
175
|
+
install: InstallConfigSchema.partial().passthrough().optional(),
|
|
176
|
+
update: UpdateConfigSchema.partial().passthrough().optional(),
|
|
177
|
+
// The personal keys ride as data here and are read by
|
|
178
|
+
// `readPersonalRouter`, so one this build cannot read never makes the
|
|
179
|
+
// whole file unreadable.
|
|
180
|
+
router: RouterGlobalSchema.extend({
|
|
181
|
+
subagents: external_exports.unknown().optional(),
|
|
182
|
+
subagentConsent: external_exports.unknown().optional(),
|
|
183
|
+
windowsWorker: external_exports.unknown().optional(),
|
|
184
|
+
policy: external_exports.unknown().optional(),
|
|
185
|
+
nativeReplacement: external_exports.unknown().optional(),
|
|
186
|
+
nativeReplacementProviders: external_exports.unknown().optional(),
|
|
187
|
+
sources: external_exports.unknown().optional()
|
|
188
|
+
}).passthrough().optional(),
|
|
189
|
+
experimental: ExperimentalConfigSchema.partial().passthrough().optional()
|
|
190
|
+
}).passthrough();
|
|
191
|
+
var SEND_MAX_UNSET = "unset";
|
|
192
|
+
var DEFAULT_BAZAAR_REGISTRIES = [
|
|
193
|
+
"https://api.cdp.coinbase.com/platform/v2/x402",
|
|
194
|
+
"https://facilitator.ultravioletadao.xyz",
|
|
195
|
+
"https://facilitator.payai.network"
|
|
196
|
+
];
|
|
197
|
+
var DEFAULT_MAX_AUTO_SPEND = "1000000";
|
|
198
|
+
var DEFAULT_SESSION_BUDGET = "5000000";
|
|
199
|
+
var CONFIG_DEFAULTS = {
|
|
200
|
+
maxAutoSpend: DEFAULT_MAX_AUTO_SPEND,
|
|
201
|
+
sessionBudget: DEFAULT_SESSION_BUDGET,
|
|
202
|
+
// A type placeholder only, never honored: Config requires every key (and
|
|
203
|
+
// CONFIG_KEYS derives from these). resolveSendMaxAmount never reads it — an
|
|
204
|
+
// absent key resolves to SEND_MAX_UNSET and `tenjin wallet send` refuses until the
|
|
205
|
+
// cap is set. '0' (send disabled) rather than 'none' (uncapped) so that if a
|
|
206
|
+
// future caller ever DOES read the cap through loadConfig/fileOrDefault, the
|
|
207
|
+
// leak fails closed instead of silently running uncapped.
|
|
208
|
+
sendMaxAmount: "0",
|
|
209
|
+
allowlistCreators: [],
|
|
210
|
+
baseUrl: PRODUCTION_ORIGIN,
|
|
211
|
+
rpcUrl: DEFAULT_RPC_URL,
|
|
212
|
+
bazaarRegistries: DEFAULT_BAZAAR_REGISTRIES,
|
|
213
|
+
install: { routerProjects: [] },
|
|
214
|
+
update: { mode: "auto" },
|
|
215
|
+
router: { enabled: true, context: "session", improve: false, subagents: false },
|
|
216
|
+
experimental: { bazaar: "off" }
|
|
217
|
+
};
|
|
218
|
+
var NESTED_CONFIG_KEYS = /* @__PURE__ */ new Set([
|
|
219
|
+
"install",
|
|
220
|
+
"update",
|
|
221
|
+
"router",
|
|
222
|
+
"experimental"
|
|
223
|
+
]);
|
|
224
|
+
var CONFIG_KEYS = Object.keys(CONFIG_DEFAULTS).filter(
|
|
225
|
+
(key) => !NESTED_CONFIG_KEYS.has(key)
|
|
226
|
+
);
|
|
227
|
+
var UPDATE_CONFIG_KEYS = ["update.mode"];
|
|
228
|
+
var EXPERIMENTAL_CONFIG_KEYS = ["experimental.bazaar"];
|
|
229
|
+
var ROUTER_CONFIG_KEYS = [
|
|
230
|
+
"router.enabled",
|
|
231
|
+
"router.context",
|
|
232
|
+
"router.improve",
|
|
233
|
+
"router.subagents"
|
|
234
|
+
];
|
|
235
|
+
var PERSONAL_ROUTER_KEYS = [
|
|
236
|
+
"router.policy",
|
|
237
|
+
"router.nativeReplacement",
|
|
238
|
+
"router.nativeReplacementProviders",
|
|
239
|
+
"router.sources"
|
|
240
|
+
];
|
|
241
|
+
var SETTING_SCOPES = {
|
|
242
|
+
"router.policy": "user",
|
|
243
|
+
"router.sources": "user",
|
|
244
|
+
"router.nativeReplacement": "machine",
|
|
245
|
+
"router.nativeReplacementProviders": "machine",
|
|
246
|
+
"router.enabled": "machine",
|
|
247
|
+
"router.context": "machine",
|
|
248
|
+
maxAutoSpend: "machine",
|
|
249
|
+
sessionBudget: "machine",
|
|
250
|
+
allowlistCreators: "machine"
|
|
251
|
+
};
|
|
252
|
+
var RETIRED_PAYMENT_KEYS = ["bazaarPay", "confirm"];
|
|
253
|
+
var RETIRED_PAYMENT_GUIDANCE = "Retired payment settings no longer control payments. Use router.enabled, maxAutoSpend and sessionBudget for automatic routing; manual pay always requires consent. Run tenjin install to remove retired keys.";
|
|
254
|
+
function retiredPaymentKeys(raw) {
|
|
255
|
+
return RETIRED_PAYMENT_KEYS.filter((key) => Object.hasOwn(raw, key));
|
|
256
|
+
}
|
|
257
|
+
async function loadRawConfig(dir) {
|
|
258
|
+
const path = configPath(dir);
|
|
259
|
+
let raw;
|
|
260
|
+
try {
|
|
261
|
+
raw = await readFile(path, "utf8");
|
|
262
|
+
} catch (err) {
|
|
263
|
+
if (hasCode(err, "ENOENT")) return {};
|
|
264
|
+
throw new CliError("CONFIG_INVALID", `Could not read config at ${path}`, {
|
|
265
|
+
fix: `Check file permissions on ${path}.`,
|
|
266
|
+
cause: err
|
|
267
|
+
});
|
|
268
|
+
}
|
|
269
|
+
let json;
|
|
270
|
+
try {
|
|
271
|
+
json = JSON.parse(raw);
|
|
272
|
+
} catch (err) {
|
|
273
|
+
throw new CliError("CONFIG_INVALID", `Config at ${path} is not valid JSON`, {
|
|
274
|
+
fix: `Fix the JSON syntax in ${path}, or delete it to restore defaults.`,
|
|
275
|
+
cause: err
|
|
276
|
+
});
|
|
277
|
+
}
|
|
278
|
+
const parsed = RawConfigSchema.safeParse(json);
|
|
279
|
+
if (!parsed.success) {
|
|
280
|
+
throw new CliError("CONFIG_INVALID", `Config at ${path} is invalid`, {
|
|
281
|
+
fix: `Correct the reported keys in ${path}, or delete it to restore defaults.`,
|
|
282
|
+
details: parsed.error.issues
|
|
283
|
+
});
|
|
284
|
+
}
|
|
285
|
+
return parsed.data;
|
|
286
|
+
}
|
|
287
|
+
async function loadConfig(dir) {
|
|
288
|
+
const raw = { ...await loadRawConfig(dir) };
|
|
289
|
+
for (const key of retiredPaymentKeys(raw)) delete raw[key];
|
|
290
|
+
return {
|
|
291
|
+
...CONFIG_DEFAULTS,
|
|
292
|
+
...raw,
|
|
293
|
+
install: {
|
|
294
|
+
routerProjects: raw.install?.routerProjects ?? CONFIG_DEFAULTS.install.routerProjects
|
|
295
|
+
},
|
|
296
|
+
update: { mode: raw.update?.mode ?? CONFIG_DEFAULTS.update.mode },
|
|
297
|
+
router: {
|
|
298
|
+
subagents: raw.router?.subagents === true,
|
|
299
|
+
enabled: raw.router?.enabled ?? CONFIG_DEFAULTS.router.enabled,
|
|
300
|
+
context: raw.router?.context ?? CONFIG_DEFAULTS.router.context,
|
|
301
|
+
improve: raw.router?.improve ?? CONFIG_DEFAULTS.router.improve
|
|
302
|
+
},
|
|
303
|
+
experimental: {
|
|
304
|
+
bazaar: raw.experimental?.bazaar ?? CONFIG_DEFAULTS.experimental.bazaar
|
|
305
|
+
}
|
|
306
|
+
};
|
|
307
|
+
}
|
|
308
|
+
function resolveSettings(input) {
|
|
309
|
+
const { config, flags, env } = input;
|
|
310
|
+
return {
|
|
311
|
+
maxAutoSpend: fileOrDefault("maxAutoSpend", config),
|
|
312
|
+
sessionBudget: fileOrDefault("sessionBudget", config),
|
|
313
|
+
sendMaxAmount: resolveSendMaxAmount(config),
|
|
314
|
+
allowlistCreators: fileOrDefault("allowlistCreators", config),
|
|
315
|
+
baseUrl: resolveBaseUrl(config, flags, env),
|
|
316
|
+
rpcUrl: fileOrDefault("rpcUrl", config),
|
|
317
|
+
bazaarRegistries: fileOrDefault("bazaarRegistries", config),
|
|
318
|
+
updateMode: resolveUpdateMode(config),
|
|
319
|
+
experimentalBazaar: resolveExperimentalBazaar(config)
|
|
320
|
+
};
|
|
321
|
+
}
|
|
322
|
+
function resolveExperimentalBazaar(config) {
|
|
323
|
+
const fromFile = config.experimental?.bazaar;
|
|
324
|
+
if (fromFile !== void 0) return { value: fromFile, source: "file" };
|
|
325
|
+
return { value: CONFIG_DEFAULTS.experimental.bazaar, source: "default" };
|
|
326
|
+
}
|
|
327
|
+
function resolveUpdateMode(config) {
|
|
328
|
+
const fromFile = config.update?.mode;
|
|
329
|
+
if (fromFile !== void 0) return { value: fromFile, source: "file" };
|
|
330
|
+
return { value: CONFIG_DEFAULTS.update.mode, source: "default" };
|
|
331
|
+
}
|
|
332
|
+
function resolveSendMaxAmount(config) {
|
|
333
|
+
if (config.sendMaxAmount !== void 0) return { value: config.sendMaxAmount, source: "file" };
|
|
334
|
+
return { value: SEND_MAX_UNSET, source: "default" };
|
|
335
|
+
}
|
|
336
|
+
function fileOrDefault(key, config) {
|
|
337
|
+
const fromFile = config[key];
|
|
338
|
+
if (fromFile !== void 0) return { value: fromFile, source: "file" };
|
|
339
|
+
return { value: CONFIG_DEFAULTS[key], source: "default" };
|
|
340
|
+
}
|
|
341
|
+
function resolveBaseUrl(config, flags, env) {
|
|
342
|
+
if (flags.baseUrl !== void 0 && flags.baseUrl.length > 0) {
|
|
343
|
+
return { value: flags.baseUrl, source: "flag" };
|
|
344
|
+
}
|
|
345
|
+
const fromEnv = env.TENJIN_BASE_URL;
|
|
346
|
+
if (fromEnv !== void 0 && fromEnv.length > 0) {
|
|
347
|
+
return { value: fromEnv, source: "env" };
|
|
348
|
+
}
|
|
349
|
+
if (config.baseUrl !== void 0) return { value: config.baseUrl, source: "file" };
|
|
350
|
+
return { value: CONFIG_DEFAULTS.baseUrl, source: "default" };
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
export {
|
|
354
|
+
ROUTER_CONTEXTS,
|
|
355
|
+
readPersonalRouter,
|
|
356
|
+
savedDescriptors,
|
|
357
|
+
editSources,
|
|
358
|
+
parseRouterLayer,
|
|
359
|
+
parseOnOffFlag,
|
|
360
|
+
parseUpdateModeFlag,
|
|
361
|
+
RawConfigSchema,
|
|
362
|
+
SEND_MAX_UNSET,
|
|
363
|
+
DEFAULT_MAX_AUTO_SPEND,
|
|
364
|
+
DEFAULT_SESSION_BUDGET,
|
|
365
|
+
CONFIG_DEFAULTS,
|
|
366
|
+
CONFIG_KEYS,
|
|
367
|
+
UPDATE_CONFIG_KEYS,
|
|
368
|
+
EXPERIMENTAL_CONFIG_KEYS,
|
|
369
|
+
ROUTER_CONFIG_KEYS,
|
|
370
|
+
PERSONAL_ROUTER_KEYS,
|
|
371
|
+
SETTING_SCOPES,
|
|
372
|
+
RETIRED_PAYMENT_GUIDANCE,
|
|
373
|
+
retiredPaymentKeys,
|
|
374
|
+
loadRawConfig,
|
|
375
|
+
loadConfig,
|
|
376
|
+
resolveSettings,
|
|
377
|
+
resolveExperimentalBazaar
|
|
378
|
+
};
|
|
379
|
+
//# sourceMappingURL=chunk-UIB33QQP.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/lib/config.ts"],"sourcesContent":["import { readFile } from 'node:fs/promises';\nimport { z } from 'zod';\nimport { hasCode } from './errno';\nimport { CliError } from './errors';\nimport { PRODUCTION_ORIGIN } from './production-origin';\nimport { configPath } from './paths';\nimport { DEFAULT_RPC_URL } from './usdc-balance';\nimport {\n BUILT_IN_SOURCE,\n REPLACEMENT_MODES,\n ReplacementProvidersSchema,\n SETTINGS_LIMITS,\n SavedPolicySchema,\n TargetIdSchema,\n type ReplacementMode,\n type SavedPolicy,\n type Target,\n} from '../router/settings-wire';\n\n/** A non-negative integer string in USDC atomic units (6-decimal base). */\nconst atomicString = z.string().regex(/^\\d+$/, 'expected an atomic USDC integer string');\n\n/** How much conversation a router hook packet carries. */\nexport const ROUTER_CONTEXTS = ['session', 'turn'] as const;\nexport type RouterContext = (typeof ROUTER_CONTEXTS)[number];\n\n/**\n * The router's own block: `enabled` is the off switch every router hook and the\n * `request` tool honour, and `context` is how much conversation a hook packet\n * carries (`session`, up to six prior messages, or `turn`, none). THE ONE SCHEMA\n * for it: the global file validates it here, and a project's\n * `.tenjin/config.json` and `config.local.json` go through\n * {@link parseRouterLayer}. Both keys only ever tighten, which is why a\n * project file may carry them; a key that loosens (spend, allowlist, enabling,\n * base URL) must never join this object. `routerSettings` in\n * router/settings.ts is the one reader of the resolved values.\n */\nexport const RouterLayerSchema = z.object({\n enabled: z.boolean().optional(),\n context: z.enum(ROUTER_CONTEXTS).optional(),\n subagents: z.boolean().optional(),\n});\nexport type RouterLayer = z.infer<typeof RouterLayerSchema>;\n/**\n * The global file's router block: the project keys, and `improve`, \"Help\n * improve routing\", which only this file carries. It is the person's consent\n * for the router to keep the masked text of the turns it sees, so a file a\n * repository commits can never give it ({@link parseRouterLayer} drops it).\n */\nconst RouterGlobalSchema = RouterLayerSchema.extend({ improve: z.boolean().optional() });\nconst RouterConfigSchema = RouterGlobalSchema.required();\n\n/**\n * ONE SAVED ACCOUNT DESCRIPTOR (`router.sources`, plan 37): a safe id, and\n * whatever else `tenjin connect` wrote beside it (its name, its server, how\n * it signs in), read leniently by `accounts/saved.ts`. Never a credential: a\n * descriptor alone connects nothing, and whether an account is connected is\n * this machine's own state, its vault (`accounts/presence.ts`). User scope,\n * like the rules.\n */\nexport const SourceDescriptorSchema = z.looseObject({ id: TargetIdSchema });\nexport type SourceDescriptor = z.infer<typeof SourceDescriptorSchema>;\n\nconst SourcesSchema = z\n .array(SourceDescriptorSchema)\n .max(SETTINGS_LIMITS.sources)\n .superRefine((sources, ctx) => {\n const seen = new Set<string>();\n sources.forEach(({ id }, at) => {\n if (id === BUILT_IN_SOURCE)\n ctx.addIssue({ code: 'custom', path: [at, 'id'], message: `${id} is built in` });\n if (seen.has(id))\n ctx.addIssue({ code: 'custom', path: [at, 'id'], message: 'an account is saved twice' });\n seen.add(id);\n });\n });\n\n/**\n * The global file's personal router keys, read one by one and never through\n * {@link RawConfigSchema}: a hand edit this build cannot read fails only what\n * reads rules (fail closed), while `tenjin config`, pause and reset keep\n * working on the rest of the file.\n */\nexport interface PersonalRouter {\n policy:\n | { status: 'none' }\n | { status: 'ok'; saved: SavedPolicy }\n | { status: 'invalid'; problem: string };\n /** An unreadable mode or scope reads as off: never on by accident. */\n nativeReplacement: { mode: ReplacementMode; providers?: Target[]; problem?: string };\n /** The saved account descriptors. A list this build cannot read is\n * `invalid`: no account is named to the router from it (fail closed). */\n sources: { status: 'ok'; saved: SourceDescriptor[] } | { status: 'invalid'; problem: string };\n}\n\nfunction firstProblem(key: string, error: z.ZodError): string {\n const [issue] = error.issues;\n const path = [key, ...(issue?.path ?? []).map(String)].join('.');\n return `${path}: ${issue?.message ?? 'invalid'}`;\n}\n\nconst ReplacementModeSchema = z.enum(REPLACEMENT_MODES).optional();\n\nexport function readPersonalRouter(router: unknown): PersonalRouter {\n const block =\n router !== null && typeof router === 'object' ? (router as Record<string, unknown>) : {};\n const policy = block.policy === undefined ? undefined : SavedPolicySchema.safeParse(block.policy);\n const mode = ReplacementModeSchema.safeParse(block.nativeReplacement);\n const providers = ReplacementProvidersSchema.optional().safeParse(\n block.nativeReplacementProviders,\n );\n const sources = SourcesSchema.optional().safeParse(block.sources);\n const problem = !mode.success\n ? firstProblem('router.nativeReplacement', mode.error)\n : !providers.success\n ? firstProblem('router.nativeReplacementProviders', providers.error)\n : undefined;\n return {\n policy:\n policy === undefined\n ? { status: 'none' }\n : policy.success\n ? { status: 'ok', saved: policy.data }\n : { status: 'invalid', problem: firstProblem('router.policy', policy.error) },\n nativeReplacement:\n problem !== undefined\n ? { mode: 'off', problem }\n : {\n mode: mode.data ?? 'off',\n ...(providers.data !== undefined ? { providers: providers.data } : {}),\n },\n sources: sources.success\n ? { status: 'ok', saved: sources.data ?? [] }\n : { status: 'invalid', problem: firstProblem('router.sources', sources.error) },\n };\n}\n\n/** The saved account descriptors in a router block, or a refusal when the\n * saved list can't be read: nothing is changed on a list this build can't\n * read. */\nexport function savedDescriptors(router: unknown): SourceDescriptor[] {\n const sources = readPersonalRouter(router).sources;\n if (sources.status === 'invalid') {\n throw new CliError(\n 'CONFIG_INVALID',\n `Your saved accounts can't be read (${sources.problem}), so nothing was changed.`,\n { fix: 'Fix or remove router.sources in your Tenjin config, then run the command again.' },\n );\n }\n return sources.saved;\n}\n\n/**\n * `existing` with its saved account descriptors replaced by what `edit` makes\n * of them, the key dropped once none is left. Read through\n * {@link readPersonalRouter}, so a list this build can't read is refused, as\n * {@link savedDescriptors} refuses it, and never edited as if it were empty.\n */\nexport function editSources(\n existing: PartialConfig,\n edit: (saved: SourceDescriptor[]) => Record<string, unknown>[],\n): PartialConfig {\n const router = { ...((existing.router ?? {}) as Record<string, unknown>) };\n const sources = edit(savedDescriptors(router));\n if (sources.length > 0) router.sources = sources;\n else delete router.sources;\n return { ...existing, router };\n}\n\n/**\n * The `router` block of one project file's parsed JSON, and nothing else: an\n * unknown key, inside the block or beside it, is never read. CONFIG_INVALID,\n * naming the file, when the file is not an object or a key has the wrong type.\n */\nexport function parseRouterLayer(json: unknown, path: string): RouterLayer {\n if (json === null || typeof json !== 'object' || Array.isArray(json)) {\n throw new CliError('CONFIG_INVALID', `Config at ${path} is not a JSON object`, {\n fix: `Fix ${path}, or delete it.`,\n });\n }\n const parsed = RouterLayerSchema.safeParse((json as { router?: unknown }).router ?? {});\n if (!parsed.success) {\n throw new CliError('CONFIG_INVALID', `Config at ${path} has an invalid router block`, {\n fix: `Use router.enabled true|false and router.context \"session\"|\"turn\" in ${path}, or delete it.`,\n details: parsed.error.issues,\n });\n }\n const { enabled, context, subagents } = parsed.data;\n return {\n ...(enabled !== undefined ? { enabled } : {}),\n ...(subagents !== undefined ? { subagents } : {}),\n ...(context !== undefined ? { context } : {}),\n };\n}\n\n/**\n * What the daily update check is allowed to do about a newer version.\n *\n * `auto` installs it in the background where Tenjin's runtime is set up for the\n * default data dir (see lib/auto-update), and elsewhere behaves as `nudge`: the\n * runtime is the deferred-activation window a self-update needs, since versions\n * sit side by side and a running session keeps the one it started on. `nudge`\n * only reports it — one dim line for a human at a terminal, and an\n * `updateAvailable` field on the JSON envelope for everyone else, which is how\n * an agent learns to run `tenjin update` itself. `off` neither reports nor asks\n * npm.\n */\nexport const UpdateModeSchema = z.enum(['auto', 'nudge', 'off']);\n\n/** An on/off switch, as `experimental.*` keys take it. */\nexport const OnOffSchema = z.enum(['on', 'off']);\nexport type OnOff = z.infer<typeof OnOffSchema>;\n\n/**\n * `experimental.*`: features that ship off. `bazaar` widens the third-party\n * services the router may offer from Tenjin's reviewed list (always on) to the\n * open x402 Bazaar: unreviewed sellers. Off, the client never asks for them.\n */\nexport const ExperimentalConfigSchema = z.object({ bazaar: OnOffSchema });\nexport type ExperimentalConfig = z.infer<typeof ExperimentalConfigSchema>;\n\nexport function parseOnOffFlag(value: string, keyName: string): OnOff {\n const parsed = OnOffSchema.safeParse(value);\n if (parsed.success) return parsed.data;\n throw new CliError('USAGE', `Invalid ${keyName}: ${JSON.stringify(value)}`, {\n fix: 'Use \"on\" or \"off\".',\n });\n}\n\nexport type UpdateMode = z.infer<typeof UpdateModeSchema>;\n\nconst UpdateConfigSchema = z.object({\n mode: UpdateModeSchema,\n});\n\nexport function parseUpdateModeFlag(value: string, flagName: string): UpdateMode {\n const parsed = UpdateModeSchema.safeParse(value);\n if (parsed.success) return parsed.data;\n throw new CliError('USAGE', `Invalid ${flagName} ${JSON.stringify(value)}`, {\n fix: 'Use \"auto\", \"nudge\" or \"off\".',\n });\n}\n\n/** What `install` records about itself. Written by `install`, not a `config set` key. */\nconst InstallConfigSchema = z.object({\n /**\n * Absolute directories a `tenjin install --project` wired, so `tenjin update`\n * can refresh them. It spawns `install --refresh` from the HOME directory,\n * which is the one place a project install can never be found by looking\n * around: without this list a project-only machine refreshed nothing and\n * reported success while its hooks stayed on the old build.\n *\n * A LIST, because one machine can wire several projects, and entries are\n * dropped by `tenjin uninstall --project` and by any refresh that finds the\n * project's settings file no longer carries our entries.\n */\n routerProjects: z.array(z.string()),\n /** A new profile whose subagent question is still to be asked; neither consent nor an enabled feature. */\n freshSetup: z.literal(true).optional(),\n});\n\n/**\n * The persisted config shape. Spend keys are stored atomic (accepted as decimal\n * USD at the command edge, see lib/money). These are client-enforced guardrails, not a\n * security boundary — any process that runs the CLI can also edit this file.\n */\nexport const ConfigSchema = z.object({\n maxAutoSpend: atomicString,\n sessionBudget: z.union([atomicString, z.literal('none')]),\n /**\n * Hard per-send cap for `tenjin wallet send`, NOT satisfiable by --yes or a prompt\n * (the spend-policy posture): an atomic amount caps each send, \"0\" disables\n * the verb entirely, and \"none\" = explicitly uncapped (send exists to drain\n * the wallet, but uncapped is an opt-in, never a default). The key has NO\n * usable default: absent from config.json, `tenjin wallet send` refuses until it is\n * set (see resolveSendMaxAmount). Client-enforced like every spend key (see\n * the note above).\n */\n sendMaxAmount: z.union([z.literal('none'), atomicString]),\n allowlistCreators: z.array(z.string()),\n /** The router's base URL: the Tenjin deployment every router call goes to. */\n baseUrl: z.url(),\n rpcUrl: z.url(),\n /** x402 discovery registries (facilitator base URLs) the direct pay lane\n * verifies a seller's listing against. */\n bazaarRegistries: z.array(z.url()),\n install: InstallConfigSchema,\n update: UpdateConfigSchema,\n router: RouterConfigSchema,\n experimental: ExperimentalConfigSchema,\n});\nexport type Config = z.infer<typeof ConfigSchema>;\n\n/**\n * Values as they may appear in config.json — every known key optional; absent =\n * default. `.passthrough()` PRESERVES unknown keys through load + persist: a key\n * a newer CLI wrote survives an older binary's `config set`, and so does a key\n * an earlier release wrote and this one no longer reads (the shelf's `publish`,\n * `hooks`, `loop`, `team`, `publicShelfUrl`, `shelfBypassSecret`, `evalCohort`,\n * and `install.harness`/`install.grantDeclined`). Known keys are still\n * validated; unknown keys ride along untouched and are never read.\n */\nexport const RawConfigSchema = ConfigSchema.partial()\n // Each block is itself partial + passthrough, for the same reason: `config\n // set` writes one subkey, and a sibling it does not know survives.\n .extend({\n install: InstallConfigSchema.partial().passthrough().optional(),\n update: UpdateConfigSchema.partial().passthrough().optional(),\n // The personal keys ride as data here and are read by\n // `readPersonalRouter`, so one this build cannot read never makes the\n // whole file unreadable.\n router: RouterGlobalSchema.extend({\n subagents: z.unknown().optional(),\n subagentConsent: z.unknown().optional(),\n windowsWorker: z.unknown().optional(),\n policy: z.unknown().optional(),\n nativeReplacement: z.unknown().optional(),\n nativeReplacementProviders: z.unknown().optional(),\n sources: z.unknown().optional(),\n })\n .passthrough()\n .optional(),\n experimental: ExperimentalConfigSchema.partial().passthrough().optional(),\n })\n .passthrough();\nexport type PartialConfig = z.infer<typeof RawConfigSchema>;\n\n/**\n * The resolved-view sentinel for an absent sendMaxAmount. Never a persistable\n * value (ConfigSchema rejects it, and `config set` has no way to produce it);\n * while the resolved value is this sentinel, `tenjin wallet send` refuses —\n * require-set-before-first-send.\n */\nexport const SEND_MAX_UNSET = 'unset';\n\n/**\n * Registries verified keyless (CDP/UV on 2026-08-14, PayAI on 2026-08-18): all\n * answer GET /discovery/resources with no credential in the Bazaar envelope\n * the sweep parses. CDP's Bazaar is settlement-derived (it indexes what its\n * facilitator settles, Tenjin's endpoints included); UltraVioleta is the\n * registry Tenjin also announces to; PayAI's facilitator is settlement-derived\n * like CDP's (26k+ listings at verification). PayAI's /discovery/search is\n * keyword-only (measured 2026-10-02), so a natural-language query finds nothing\n * there. It also ignores payTo filters, as UV and CDP do, which the query\n * sweep's per-registry errors and the stored-sweep evidence cover.\n */\nexport const DEFAULT_BAZAAR_REGISTRIES = [\n 'https://api.cdp.coinbase.com/platform/v2/x402',\n 'https://facilitator.ultravioletadao.xyz',\n 'https://facilitator.payai.network',\n];\n\n/**\n * THE TWO SPEND LIMITS, IN EFFECT WHETHER OR NOT ANYONE ANSWERED. The daily\n * budget ($5) is the control; the per-call ceiling ($1) is the runaway\n * guard; the wallet balance is the hard stop. Install asks once, these or your\n * own limits, and an install nobody answered still runs on these. A call\n * priced above the ceiling is approved once, for that call.\n */\nexport const DEFAULT_MAX_AUTO_SPEND = '1000000';\nexport const DEFAULT_SESSION_BUDGET = '5000000';\n\nexport const CONFIG_DEFAULTS: Config = {\n maxAutoSpend: DEFAULT_MAX_AUTO_SPEND,\n sessionBudget: DEFAULT_SESSION_BUDGET,\n // A type placeholder only, never honored: Config requires every key (and\n // CONFIG_KEYS derives from these). resolveSendMaxAmount never reads it — an\n // absent key resolves to SEND_MAX_UNSET and `tenjin wallet send` refuses until the\n // cap is set. '0' (send disabled) rather than 'none' (uncapped) so that if a\n // future caller ever DOES read the cap through loadConfig/fileOrDefault, the\n // leak fails closed instead of silently running uncapped.\n sendMaxAmount: '0',\n allowlistCreators: [],\n baseUrl: PRODUCTION_ORIGIN,\n rpcUrl: DEFAULT_RPC_URL,\n bazaarRegistries: DEFAULT_BAZAAR_REGISTRIES,\n install: { routerProjects: [] },\n update: { mode: 'auto' },\n router: { enabled: true, context: 'session', improve: false, subagents: false },\n experimental: { bazaar: 'off' },\n};\n\n/**\n * Scalar keys `config get/set/list` render one line each. The nested blocks are\n * excluded: `update`, `router` and `experimental` are addressed by their dotted\n * keys, and `install` is a record `install` writes about itself rather than a\n * setting to hand-edit, so none is ever a bare scalar.\n */\nexport type ScalarConfigKey = Exclude<\n keyof Config,\n 'install' | 'update' | 'router' | 'experimental'\n>;\nconst NESTED_CONFIG_KEYS: ReadonlySet<string> = new Set([\n 'install',\n 'update',\n 'router',\n 'experimental',\n]);\nexport const CONFIG_KEYS = (Object.keys(CONFIG_DEFAULTS) as Array<keyof Config>).filter(\n (key): key is ScalarConfigKey => !NESTED_CONFIG_KEYS.has(key),\n);\n\n/** The dotted key `config get/set` accepts for the nested update block. */\nexport const UPDATE_CONFIG_KEYS = ['update.mode'] as const;\nexport type UpdateConfigKey = (typeof UPDATE_CONFIG_KEYS)[number];\n\n/** The dotted key `config get/set` accepts for the experimental block. */\nexport const EXPERIMENTAL_CONFIG_KEYS = ['experimental.bazaar'] as const;\nexport type ExperimentalConfigKey = (typeof EXPERIMENTAL_CONFIG_KEYS)[number];\n\n/** The dotted keys `config get/set` accept for the router block. The rules\n * and automatic use are not among them: they change only through their own\n * operations (`tenjin config prefer|only|block|unblock|reset|speed|\n * replacement`), which validate what they couple. */\nexport const ROUTER_CONFIG_KEYS = [\n 'router.enabled',\n 'router.context',\n 'router.improve',\n 'router.subagents',\n] as const;\nexport type RouterConfigKey = (typeof ROUTER_CONFIG_KEYS)[number];\n\n/** The personal router keys that only their own operations write. */\nexport const PERSONAL_ROUTER_KEYS = [\n 'router.policy',\n 'router.nativeReplacement',\n 'router.nativeReplacementProviders',\n 'router.sources',\n] as const;\n\n/**\n * WHERE A SETTING BELONGS, declared once rather than labelled on each saved\n * value. Everything is local today: `user` is the person's intent, which a\n * later sync could carry between machines (none exists; readback says \"not\n * synced\"); `machine` is this machine's own; `project` is a repository's\n * `.tenjin/config.json` or `config.local.json`, which only tightens.\n */\nexport type SettingScope = 'user' | 'machine' | 'project';\n\nexport const SETTING_SCOPES = {\n 'router.policy': 'user',\n 'router.sources': 'user',\n 'router.nativeReplacement': 'machine',\n 'router.nativeReplacementProviders': 'machine',\n 'router.enabled': 'machine',\n 'router.context': 'machine',\n maxAutoSpend: 'machine',\n sessionBudget: 'machine',\n allowlistCreators: 'machine',\n} as const satisfies Record<string, SettingScope>;\n\nexport const RETIRED_PAYMENT_KEYS = ['bazaarPay', 'confirm'] as const;\nexport const RETIRED_PAYMENT_GUIDANCE =\n 'Retired payment settings no longer control payments. Use router.enabled, maxAutoSpend and sessionBudget for automatic routing; manual pay always requires consent. Run tenjin install to remove retired keys.';\n\nexport function retiredPaymentKeys(raw: PartialConfig): string[] {\n return RETIRED_PAYMENT_KEYS.filter((key) => Object.hasOwn(raw, key));\n}\n\n/**\n * Read and validate config.json WITHOUT applying defaults, so provenance can\n * distinguish \"present in file\" from \"absent\". Missing file is fine (returns\n * {}); malformed JSON or a failed schema is CONFIG_INVALID with a fix.\n */\nexport async function loadRawConfig(dir: string): Promise<PartialConfig> {\n const path = configPath(dir);\n let raw: string;\n try {\n raw = await readFile(path, 'utf8');\n } catch (err) {\n if (hasCode(err, 'ENOENT')) return {};\n throw new CliError('CONFIG_INVALID', `Could not read config at ${path}`, {\n fix: `Check file permissions on ${path}.`,\n cause: err,\n });\n }\n let json: unknown;\n try {\n json = JSON.parse(raw);\n } catch (err) {\n throw new CliError('CONFIG_INVALID', `Config at ${path} is not valid JSON`, {\n fix: `Fix the JSON syntax in ${path}, or delete it to restore defaults.`,\n cause: err,\n });\n }\n const parsed = RawConfigSchema.safeParse(json);\n if (!parsed.success) {\n throw new CliError('CONFIG_INVALID', `Config at ${path} is invalid`, {\n fix: `Correct the reported keys in ${path}, or delete it to restore defaults.`,\n details: parsed.error.issues,\n });\n }\n return parsed.data;\n}\n\n/** File values merged over defaults — the effective persisted config. Each\n * nested block is merged per-subkey, so a file that sets one subkey keeps the\n * defaults of its siblings (a shallow spread would drop them). */\nexport async function loadConfig(dir: string): Promise<Config> {\n const raw = { ...(await loadRawConfig(dir)) };\n for (const key of retiredPaymentKeys(raw)) delete raw[key];\n // loadConfig's job is the effective Config object, so an absent key is its\n // default here; the provenance question lives in resolve* below.\n return {\n ...CONFIG_DEFAULTS,\n ...raw,\n install: {\n routerProjects: raw.install?.routerProjects ?? CONFIG_DEFAULTS.install.routerProjects,\n },\n update: { mode: raw.update?.mode ?? CONFIG_DEFAULTS.update.mode },\n router: {\n subagents: raw.router?.subagents === true,\n enabled: raw.router?.enabled ?? CONFIG_DEFAULTS.router.enabled,\n context: raw.router?.context ?? CONFIG_DEFAULTS.router.context,\n improve: raw.router?.improve ?? CONFIG_DEFAULTS.router.improve,\n },\n experimental: {\n bazaar: raw.experimental?.bazaar ?? CONFIG_DEFAULTS.experimental.bazaar,\n },\n };\n}\n\n/** `local` is a project's personal `.tenjin/config.local.json` (router keys only). */\nexport type Provenance = 'default' | 'file' | 'project' | 'local' | 'env' | 'flag';\n\nexport interface ResolvedSetting<T> {\n value: T;\n source: Provenance;\n}\n\n/** Effective value + where it came from, per key. What `config` (bare) renders. */\nexport interface EffectiveSettings {\n maxAutoSpend: ResolvedSetting<string>;\n sessionBudget: ResolvedSetting<string>;\n sendMaxAmount: ResolvedSetting<string>;\n allowlistCreators: ResolvedSetting<string[]>;\n baseUrl: ResolvedSetting<string>;\n rpcUrl: ResolvedSetting<string>;\n bazaarRegistries: ResolvedSetting<string[]>;\n updateMode: ResolvedSetting<UpdateMode>;\n experimentalBazaar: ResolvedSetting<OnOff>;\n}\n\n/** CLI flags that participate in settings precedence (`--base-url`). */\nexport interface SettingsFlags {\n baseUrl?: string;\n}\n\nexport interface ResolveSettingsInput {\n /** Raw file values (present keys only) — from loadRawConfig, not loadConfig. */\n config: PartialConfig;\n flags: SettingsFlags;\n env: NodeJS.ProcessEnv;\n}\n\n/**\n * Apply precedence flag > env > file > default per key, returning each effective\n * value with its source. Only baseUrl has flag/env overrides (`--base-url`,\n * TENJIN_BASE_URL); the rest resolve file-or-default.\n */\nexport function resolveSettings(input: ResolveSettingsInput): EffectiveSettings {\n const { config, flags, env } = input;\n return {\n maxAutoSpend: fileOrDefault('maxAutoSpend', config),\n sessionBudget: fileOrDefault('sessionBudget', config),\n sendMaxAmount: resolveSendMaxAmount(config),\n allowlistCreators: fileOrDefault('allowlistCreators', config),\n baseUrl: resolveBaseUrl(config, flags, env),\n rpcUrl: fileOrDefault('rpcUrl', config),\n bazaarRegistries: fileOrDefault('bazaarRegistries', config),\n updateMode: resolveUpdateMode(config),\n experimentalBazaar: resolveExperimentalBazaar(config),\n };\n}\n\n/** experimental.bazaar: file or default (off), no env or flag. */\nexport function resolveExperimentalBazaar(config: PartialConfig): ResolvedSetting<OnOff> {\n const fromFile = config.experimental?.bazaar;\n if (fromFile !== undefined) return { value: fromFile, source: 'file' };\n return { value: CONFIG_DEFAULTS.experimental.bazaar, source: 'default' };\n}\n\n/** update.mode: file or default, no env or flag. Every surface that reports a\n * newer version reads this one resolved value, so they cannot disagree. */\nfunction resolveUpdateMode(config: PartialConfig): ResolvedSetting<UpdateMode> {\n const fromFile = config.update?.mode;\n if (fromFile !== undefined) return { value: fromFile, source: 'file' };\n return { value: CONFIG_DEFAULTS.update.mode, source: 'default' };\n}\n\n/**\n * sendMaxAmount deliberately bypasses fileOrDefault: it has no usable default\n * (the operator's require-set-before-first-send posture). Absent from\n * config.json it resolves to the SEND_MAX_UNSET sentinel with source 'default',\n * which `tenjin wallet send` refuses outright — the cap must be set to an amount, \"0\"\n * (disable), or an explicit \"none\" (uncapped opt-in) before the first send.\n */\nfunction resolveSendMaxAmount(config: PartialConfig): ResolvedSetting<string> {\n if (config.sendMaxAmount !== undefined) return { value: config.sendMaxAmount, source: 'file' };\n return { value: SEND_MAX_UNSET, source: 'default' };\n}\n\nfunction fileOrDefault<K extends keyof Config>(\n key: K,\n config: PartialConfig,\n): ResolvedSetting<Config[K]> {\n const fromFile = config[key];\n // PartialConfig[K] is Config[K] | undefined; narrowing an indexed access of a\n // type parameter doesn't refine K, so assert the excluded-undefined type.\n if (fromFile !== undefined) return { value: fromFile as Config[K], source: 'file' };\n return { value: CONFIG_DEFAULTS[key], source: 'default' };\n}\n\nfunction resolveBaseUrl(\n config: PartialConfig,\n flags: SettingsFlags,\n env: NodeJS.ProcessEnv,\n): ResolvedSetting<string> {\n if (flags.baseUrl !== undefined && flags.baseUrl.length > 0) {\n return { value: flags.baseUrl, source: 'flag' };\n }\n const fromEnv = env.TENJIN_BASE_URL;\n if (fromEnv !== undefined && fromEnv.length > 0) {\n return { value: fromEnv, source: 'env' };\n }\n if (config.baseUrl !== undefined) return { value: config.baseUrl, source: 'file' };\n return { value: CONFIG_DEFAULTS.baseUrl, source: 'default' };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAAS,gBAAgB;AAoBzB,IAAM,eAAe,iBAAE,OAAO,EAAE,MAAM,SAAS,wCAAwC;AAGhF,IAAM,kBAAkB,CAAC,WAAW,MAAM;AAc1C,IAAM,oBAAoB,iBAAE,OAAO;AAAA,EACxC,SAAS,iBAAE,QAAQ,EAAE,SAAS;AAAA,EAC9B,SAAS,iBAAE,KAAK,eAAe,EAAE,SAAS;AAAA,EAC1C,WAAW,iBAAE,QAAQ,EAAE,SAAS;AAClC,CAAC;AAQD,IAAM,qBAAqB,kBAAkB,OAAO,EAAE,SAAS,iBAAE,QAAQ,EAAE,SAAS,EAAE,CAAC;AACvF,IAAM,qBAAqB,mBAAmB,SAAS;AAUhD,IAAM,yBAAyB,iBAAE,YAAY,EAAE,IAAI,eAAe,CAAC;AAG1E,IAAM,gBAAgB,iBACnB,MAAM,sBAAsB,EAC5B,IAAI,gBAAgB,OAAO,EAC3B,YAAY,CAAC,SAAS,QAAQ;AAC7B,QAAM,OAAO,oBAAI,IAAY;AAC7B,UAAQ,QAAQ,CAAC,EAAE,GAAG,GAAG,OAAO;AAC9B,QAAI,OAAO;AACT,UAAI,SAAS,EAAE,MAAM,UAAU,MAAM,CAAC,IAAI,IAAI,GAAG,SAAS,GAAG,EAAE,eAAe,CAAC;AACjF,QAAI,KAAK,IAAI,EAAE;AACb,UAAI,SAAS,EAAE,MAAM,UAAU,MAAM,CAAC,IAAI,IAAI,GAAG,SAAS,4BAA4B,CAAC;AACzF,SAAK,IAAI,EAAE;AAAA,EACb,CAAC;AACH,CAAC;AAo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