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/wallet/passphrase.ts"],"sourcesContent":["import { randomBytes } from 'node:crypto';\nimport { homedir } from 'node:os';\nimport { CliError } from '../errors';\nimport { readPassphraseRecord } from '../passphrase-record';\nimport {\n dataDir,\n passphraseBlobPath,\n passphraseBlobPathFor,\n passphraseFilePathFor,\n} from '../paths';\nimport {\n KEYCHAIN_SERVICE,\n StoreExecError,\n classifyStoreFailure,\n hiddenPrompt,\n osStoreByName,\n osStoreFor,\n storeNoun,\n type ExecFn,\n type OsStore,\n type PromptFn,\n type SecretSlot,\n type StoreCallOptions,\n type StoreProbe,\n type StoreRead,\n} from '../os-store';\nimport {\n FILE_STORE_FAILED_FIX,\n KEYCHAIN_LOCKED_FIX,\n KEYCHAIN_WAIT_LINE,\n REPAIR_IN_TERMINAL,\n unlockDetails,\n type DurableStore,\n} from '../wallet-unlock';\n\nexport type { DurableStore } from '../wallet-unlock';\nexport {\n StoreExecError,\n classifyStoreFailure,\n defaultExecFor,\n storeNoun,\n type ExecFn,\n type PromptFn,\n} from '../os-store';\n\n/**\n * Wallet passphrase resolution. The private key lives on disk as an encrypted\n * Keystore v3 document; the passphrase that unlocks it is resolved here, in a\n * fixed order, so signing works headlessly (env), transparently through the OS\n * store (macOS keychain, Windows DPAPI, desktop-Linux keyring), or interactively\n * (TTY). Every side-effecting seam — the store CLIs and the hidden-input prompt —\n * is injectable so tests never touch a real keychain or terminal.\n *\n * The passphrase never appears in any argv (which the OS process table can show):\n * reads come back on stdout, and writes pipe the secret over the child's stdin.\n * A failed store CLI never carries its stdout anywhere (for a read, that IS the\n * secret): it rejects with a {@link StoreExecError} holding only the exit code,\n * the signal and the stderr {@link classifyStoreFailure} reads, and every detail\n * built from it names only those.\n *\n * ONE ANNOUNCED PLAINTEXT EXCEPTION: where no OS store exists at all (headless\n * Linux, WSL, a sandbox; the probe says `absent`) or the user chose\n * `--insecure-storage`, the passphrase is saved to `passphrase.<address>.plain`\n * at 0600 in the 0700 data dir, the way the GitHub CLI keeps `hosts.yml`.\n * Create and repair say so in one line. A store that exists but is LOCKED never\n * routes there: a locked keychain is unlocked, not worked around. Everywhere\n * else no plaintext is written to disk (the Windows blob is DPAPI-encrypted, not\n * the passphrase itself).\n *\n * Durable entries are PER WALLET (account = lowercase address); the legacy\n * shared slot is only ever read, for migration (#32). Where each wallet's\n * passphrase went is recorded in the sidecar (`src/lib/passphrase-record.ts`),\n * so a recorded wallet reads exactly one store.\n */\n\n/**\n * The pre-per-wallet shared slot (service `tenjin-cli`, account `wallet`) that\n * every create used to `-U`-overwrite. Never written anymore; read only as a\n * migration fallback and removed only after a verified per-address copy exists.\n */\nconst LEGACY_ACCOUNT = 'wallet';\n\n/** A lowercase 0x-prefixed 20-byte hex address — the per-wallet store account. */\nconst ACCOUNT_ADDRESS_RE = /^0x[0-9a-f]{40}$/;\n\n/**\n * The OS-store account for a wallet address: lowercased (checksum-insensitive)\n * and validated as plain hex before it can reach the piped `security -i` line.\n */\nexport function walletStoreAccount(address: string): string {\n const account = address.toLowerCase();\n if (!ACCOUNT_ADDRESS_RE.test(account)) {\n throw new CliError('INTERNAL', `Not a valid wallet address for passphrase storage: ${address}`);\n }\n return account;\n}\n\nexport type PassphraseSource = 'env' | DurableStore | 'prompt';\n\nexport interface ResolvedPassphrase {\n passphrase: string;\n source: PassphraseSource;\n /**\n * Present ONLY when the passphrase came from the legacy shared slot. Call it\n * strictly AFTER proving the passphrase decrypts this wallet's keystore; it\n * re-keys the slot per migrateLegacyEntry's contract. On a decrypt failure\n * do NOT call it — surface the ambiguity and leave the legacy entry alone.\n */\n migrateLegacy?: () => Promise<boolean>;\n /** true when the sidecar named the store that served it. */\n recorded?: boolean;\n}\n\n/**\n * Store-operation deadlines (decision 7). Reads are NOT here: the router never\n * kills a store read; only verify (doctor, install) bounds one, at\n * `verifyReadMs`. Writes are bounded as a whole: pre-read, write and read-back\n * share one deadline, 10 s headless or 60 s at a terminal, where the person may\n * be answering an OS unlock prompt (`waitLineAfterMs` in, they are told so).\n */\nexport const STORE_TIMEOUTS = {\n verifyReadMs: 5000,\n writeMs: 10000,\n interactiveWriteMs: 60000,\n probeMs: 3000,\n waitLineAfterMs: 1000,\n} as const;\n\n/** {@link STORE_TIMEOUTS}' shape, as plain numbers a test may override. */\nexport type StoreTimeouts = Record<keyof typeof STORE_TIMEOUTS, number>;\n\nexport interface PassphraseDeps {\n env: NodeJS.ProcessEnv;\n /** Data dir that holds the sidecar, the DPAPI blob and the passphrase file; defaults to the resolved data dir. */\n dir?: string;\n /** Defaults to `process.platform`; selects the OS store (or none). */\n platform?: NodeJS.Platform;\n /** Whether an interactive prompt is possible; defaults to `process.stdin.isTTY`. */\n isTTY?: boolean;\n /** The store-CLI exec seam; defaults to a real execFile with stdin support. */\n exec?: ExecFn;\n /** The hidden-input prompt seam; defaults to a raw-mode TTY reader. */\n prompt?: PromptFn;\n /** Test override for {@link STORE_TIMEOUTS}. */\n timeouts?: Partial<StoreTimeouts>;\n /**\n * Read deadline for verify only (doctor and install pass\n * `STORE_TIMEOUTS.verifyReadMs`). Absent means reads are never killed, which\n * is what every signing caller must stay (B3).\n */\n readDeadlineMs?: number;\n /**\n * Create and repair at a TTY: called once with KEYCHAIN_WAIT_LINE when\n * storeDurablyDetailed has not settled after `waitLineAfterMs`. Commands wire it to\n * stderr.\n */\n onWait?: (line: string) => void;\n}\n\n/**\n * 'kept-existing': the pre-read found a different value and replaceIf said keep it (nothing written).\n * 'conflict': a different value with no replaceIf, or a read-back that differs after the write (S1).\n */\nexport type DurableWrite =\n | 'stored'\n | 'already-stored'\n | 'kept-existing'\n | 'conflict'\n | 'uncertain'\n | 'store-failed'\n | 'rejected-characters';\n\n/** A --replace archive write's outcome ({@link toStoreOutcome}); `no-store`: nowhere to write. */\nexport type StorePassphraseOutcome =\n 'stored' | 'no-store' | 'rejected-characters' | 'store-failed' | 'uncertain';\n\n/** The effective deadlines: STORE_TIMEOUTS with any test override applied. */\nfunction timeoutsOf(deps: PassphraseDeps): StoreTimeouts {\n return { ...STORE_TIMEOUTS, ...deps.timeouts };\n}\n\n/**\n * WHERE A WALLET'S PASSPHRASE LIVES in each OS store: per-wallet accounts are\n * the lowercase address (the keychain writer takes nothing else), the DPAPI\n * blob and plain file are named for it, and the legacy shared slot's blob is\n * the one pre-per-wallet file.\n */\nfunction walletSlot(deps: PassphraseDeps): SecretSlot {\n return {\n accountRe: ACCOUNT_ADDRESS_RE,\n label: (account) => `tenjin-cli wallet ${account}`,\n blobPath: (account) =>\n account === LEGACY_ACCOUNT\n ? passphraseBlobPath(deps.dir)\n : passphraseBlobPathFor(account, deps.dir),\n filePath: (account) => passphraseFilePathFor(account, deps.dir),\n };\n}\n\n/** The durable store for this platform, or null where no built-in one exists. */\nfunction storeFor(deps: PassphraseDeps): OsStore | null {\n return osStoreFor(walletSlot(deps), deps);\n}\n\n/** Any store by name, the file store included: what a sidecar entry or a chosen target names. */\nfunction storeByName(deps: PassphraseDeps, name: DurableStore): OsStore {\n return osStoreByName(walletSlot(deps), deps, name);\n}\n\n/** The 0600 passphrase file store. */\nfunction fileStore(deps: PassphraseDeps): OsStore {\n return storeByName(deps, 'file');\n}\n\n/**\n * One classified read of `address`'s entry in a named store (repair: \"does the\n * store the sidecar names already hold this passphrase?\"). Never throws.\n */\nexport function readStoredPassphrase(\n deps: PassphraseDeps,\n store: DurableStore,\n address: string,\n o?: StoreCallOptions,\n): Promise<StoreRead> {\n return storeByName(deps, store).read(walletStoreAccount(address), o);\n}\n\n/**\n * Resolve the passphrase to DECRYPT the existing wallet at `address`.\n *\n * 1. `TENJIN_WALLET_PASSPHRASE`, unless `skipEnv` (the wrong-env fallthrough).\n * 2. A sidecar entry: read ONLY that store's per-address entry. There is no\n * other-store fallback: the sidecar is the answer to \"where did it go\".\n * 3. No sidecar entry (every wallet made before the sidecar existed): today's\n * order, so alpha.30 keychain users read exactly the same entry. The OS store\n * per-address, then the legacy slot (only when the OS store exists), then the\n * 0600 file, then the prompt.\n *\n * A store that is LOCKED stops the chain, recorded or not: falling through to\n * the legacy slot or the prompt would answer \"did the keychain say no?\" with a\n * guess. At a TTY the person is asked instead; elsewhere it throws\n * `keychain_locked`, whose fix is to unlock the keychain, never plaintext (S3).\n * A locked LEGACY slot still lets the file be read, but a file miss after it is\n * `keychain_locked` too, never `passphrase_missing`.\n *\n * A legacy hit carries a `migrateLegacy` handle the caller invokes only after\n * proving the passphrase decrypts this wallet (see ResolvedPassphrase). Reads\n * pass `deps.readDeadlineMs` when it is set (verify only) and no deadline\n * otherwise (B3).\n */\nexport async function resolvePassphrase(\n deps: PassphraseDeps,\n address: string,\n opts: { skipEnv?: boolean; promptLabel?: string } = {},\n): Promise<ResolvedPassphrase> {\n if (opts.skipEnv !== true) {\n const fromEnv = envPassphrase(deps.env);\n if (fromEnv !== null) return { passphrase: fromEnv, source: 'env' };\n }\n\n const account = walletStoreAccount(address);\n const readOpts: StoreCallOptions | undefined =\n deps.readDeadlineMs !== undefined ? { timeoutMs: deps.readDeadlineMs } : undefined;\n const prompted = async (): Promise<ResolvedPassphrase> => {\n const entered = await promptOf(deps)(opts.promptLabel ?? 'Wallet passphrase: ');\n if (entered.length === 0) throw noPassphraseError();\n return { passphrase: entered, source: 'prompt' };\n };\n\n const entry = await readPassphraseRecord(deps.dir ?? dataDir(), account);\n if (entry !== null) {\n const got = await storeByName(deps, entry.store).read(account, readOpts);\n if (got.kind === 'hit') return { passphrase: got.value, source: entry.store, recorded: true };\n if (canPrompt(deps)) return prompted();\n if (got.kind === 'miss') {\n throw noPassphraseError(describeStoreLocation(entry.store, account, deps.dir));\n }\n throw storeLockedError(entry.store, account, got.detail, deps.dir, true);\n }\n\n const store = storeFor(deps);\n // A legacy slot that holds an entry but did not answer. The 0600 file is\n // still read (it may hold this wallet's passphrase, and the shared legacy\n // slot may hold another wallet's), but if it misses too the answer is\n // `keychain_locked`, never a definite `passphrase_missing` (Unknown never blocks).\n let legacyLocked: { source: DurableStore; detail: string } | null = null;\n if (store !== null) {\n const own = await store.read(account, readOpts);\n if (own.kind === 'hit') return { passphrase: own.value, source: store.source };\n if (own.kind === 'locked') {\n if (canPrompt(deps)) return prompted();\n throw storeLockedError(store.source, account, own.detail, deps.dir, false);\n }\n if (own.kind === 'miss') {\n const legacy = await store.read(LEGACY_ACCOUNT, readOpts);\n if (legacy.kind === 'hit') {\n return {\n passphrase: legacy.value,\n source: store.source,\n migrateLegacy: () => migrateLegacyEntry(legacyOps(store, deps), account, legacy.value),\n };\n }\n if (legacy.kind === 'locked') legacyLocked = { source: store.source, detail: legacy.detail };\n }\n }\n\n const file = await fileStore(deps).read(account);\n if (file.kind === 'hit') return { passphrase: file.value, source: 'file' };\n\n if (canPrompt(deps)) return prompted();\n if (legacyLocked !== null) {\n throw storeLockedError(\n legacyLocked.source,\n LEGACY_ACCOUNT,\n legacyLocked.detail,\n deps.dir,\n false,\n );\n }\n throw noPassphraseError();\n}\n\n/** The three store operations a legacy migration makes, each under the store write bound. */\ninterface LegacyOps {\n copy(account: string, value: string): Promise<boolean>;\n readBack(account: string): Promise<string | null>;\n removeLegacy(): Promise<boolean>;\n}\n\n/**\n * The legacy migration on the store API (S10). Each call passes the store WRITE\n * bound (`writeMs`): a migration is a write and its check, not a signing read,\n * and a killed read-back is not a hit, so the legacy slot stays. Nothing here\n * writes the sidecar: only create, repair and `--replace` do.\n */\nfunction legacyOps(store: OsStore, deps: PassphraseDeps): LegacyOps {\n const timeoutMs = timeoutsOf(deps).writeMs;\n return {\n async copy(account, value) {\n if (store.storable !== undefined && !store.storable(value)) return false;\n try {\n await store.store(account, value, { timeoutMs });\n return true;\n } catch {\n return false;\n }\n },\n async readBack(account) {\n const got = await store.read(account, { timeoutMs });\n return got.kind === 'hit' ? got.value : null;\n },\n removeLegacy: () => store.remove(LEGACY_ACCOUNT, { timeoutMs }),\n };\n}\n\n/**\n * Re-key the legacy shared slot under the owning wallet's own account: copy\n * first, verify the copy reads back byte-identical, and only then remove the\n * legacy entry. A failed copy or verify returns false with the legacy entry\n * still in place — the invariant is that at every step at least one durable\n * copy of the passphrase exists. The removal itself is best-effort: once the\n * copy has verified, a legacy entry that refuses to delete is redundant, not\n * unsafe (per-address reads win from then on), so it never fails the migration.\n */\nasync function migrateLegacyEntry(\n ops: LegacyOps,\n account: string,\n passphrase: string,\n): Promise<boolean> {\n if (!(await ops.copy(account, passphrase))) return false;\n if ((await ops.readBack(account)) !== passphrase) return false;\n await ops.removeLegacy();\n return true;\n}\n\n/** storeDurablyDetailed's outcome with the classified reason behind it, for the message. */\nexport interface DurableWriteResult {\n outcome: DurableWrite;\n /** Why it was not stored, built from the classified kind only (S2). Absent on success. */\n detail?: string;\n}\n\n/**\n * Save `secret` as `address`'s passphrase in `store`, and say only what a\n * read-back proves.\n *\n * (a) Pre-read. An equal value is `already-stored`. A different value is\n * `conflict` unless `replaceIf(existing)` says to replace it (repair, after\n * proving the old entry does not open the wallet), or `kept-existing` when it\n * says keep it. A locked or absent store is `uncertain` before any write.\n * (b) A value this store's writer refuses is `rejected-characters`.\n * (c) Exactly one write, of exactly this value.\n * (d) Always a read-back. Equal is `stored`; different is `conflict` (S1: some\n * other writer holds the entry, so this is never \"saved\"); a miss after a\n * killed write, or a store that does not answer the read-back, is\n * `uncertain`; a miss after any other write is `store-failed`.\n *\n * All three steps share ONE deadline (decision 7): 10 s headless, 60 s at a\n * terminal. Each call gets the time left; a step with none left is not\n * started. At a terminal, a write still unsettled after a second prints\n * KEYCHAIN_WAIT_LINE once through `onWait`. The file store never waits.\n */\nexport async function storeDurablyDetailed(\n deps: PassphraseDeps,\n storeName: DurableStore,\n address: string,\n secret: string,\n opts: { replaceIf?: (existing: string) => Promise<boolean> } = {},\n): Promise<DurableWriteResult> {\n const store = storeByName(deps, storeName);\n const account = walletStoreAccount(address);\n const t = timeoutsOf(deps);\n const end = Date.now() + (deps.isTTY === true ? t.interactiveWriteMs : t.writeMs);\n const left = (): number => end - Date.now();\n const outOfTime: DurableWriteResult = {\n outcome: 'uncertain',\n detail: `the ${storeNoun(storeName)} did not answer in time`,\n };\n\n let timer: NodeJS.Timeout | undefined;\n if (deps.isTTY === true && storeName !== 'file' && deps.onWait !== undefined) {\n const onWait = deps.onWait;\n timer = setTimeout(() => onWait(KEYCHAIN_WAIT_LINE), t.waitLineAfterMs);\n timer.unref?.();\n }\n try {\n if (left() <= 0) return outOfTime;\n const pre = await store.read(account, { timeoutMs: left() });\n if (pre.kind === 'locked' || pre.kind === 'absent') {\n return { outcome: 'uncertain', detail: pre.detail };\n }\n let update = false;\n if (pre.kind === 'hit') {\n if (pre.value === secret) return { outcome: 'already-stored' };\n if (opts.replaceIf === undefined) {\n return { outcome: 'conflict', detail: 'a different passphrase is already saved there' };\n }\n if (!(await opts.replaceIf(pre.value))) return { outcome: 'kept-existing' };\n update = true;\n }\n\n if (store.storable !== undefined && !store.storable(secret)) {\n return { outcome: 'rejected-characters' };\n }\n\n if (left() <= 0) return outOfTime;\n let writeError: unknown;\n let wrote = true;\n try {\n await store.store(account, secret, {\n timeoutMs: left(),\n ...(update ? { update: true } : {}),\n });\n } catch (err) {\n wrote = false;\n writeError = err;\n }\n\n if (left() <= 0) return outOfTime;\n const back = await store.read(account, { timeoutMs: left() });\n if (back.kind === 'hit') {\n return back.value === secret\n ? { outcome: 'stored' }\n : { outcome: 'conflict', detail: 'a different passphrase is saved there after the write' };\n }\n if (back.kind !== 'miss') return { outcome: 'uncertain', detail: back.detail };\n if (wrote) return { outcome: 'store-failed', detail: 'the saved passphrase did not read back' };\n const failure = classifyStoreFailure(storeName, writeError);\n if (isKilled(writeError)) {\n return { outcome: 'uncertain', detail: 'detail' in failure ? failure.detail : undefined };\n }\n return {\n outcome: 'store-failed',\n detail: writeFailureDetail(storeName, writeError, failure),\n };\n } finally {\n if (timer !== undefined) clearTimeout(timer);\n }\n}\n\n/** A write that was killed on its deadline: it may have committed, so only a read-back can say. */\nfunction isKilled(err: unknown): boolean {\n return err instanceof StoreExecError && (err.killed || err.signal !== null);\n}\n\n/** Why a write failed, in classified words: the read classification, or the fs errno for the file. */\nfunction writeFailureDetail(\n store: DurableStore,\n err: unknown,\n failure: Exclude<StoreRead, { kind: 'hit' }>,\n): string {\n if (store === 'file') {\n const code = (err as { code?: unknown } | null)?.code;\n return typeof code === 'string' && /^E[A-Z]+$/.test(code)\n ? `the passphrase file could not be written (${code})`\n : 'the passphrase file could not be written';\n }\n return 'detail' in failure ? failure.detail : `the ${storeNoun(store)} write failed`;\n}\n\n/**\n * S1: how the --replace archive writer (local.ts) maps storeDurablyDetailed's\n * DurableWrite. `stored` only ever means the store holds the intended value: a\n * store that holds a DIFFERENT one (`conflict`, or `kept-existing`, which that\n * writer never asks for since it passes no replaceIf) is `store-failed`.\n */\nexport function toStoreOutcome(w: DurableWrite): Exclude<StorePassphraseOutcome, 'no-store'> {\n switch (w) {\n case 'stored':\n return 'stored';\n case 'already-stored':\n return 'stored';\n case 'kept-existing':\n return 'store-failed';\n case 'conflict':\n return 'store-failed';\n case 'uncertain':\n return 'uncertain';\n case 'store-failed':\n return 'store-failed';\n case 'rejected-characters':\n return 'rejected-characters';\n }\n}\n\n/** What `resolvePassphraseForCreate` chose, and where the secret now lives. */\nexport interface CreatePassphraseResult {\n passphrase: string;\n source: DurableStore | 'env';\n origin: 'generated' | 'env';\n /** describeStoreLocation of the store, or `TENJIN_WALLET_PASSPHRASE` when nothing durable holds it. */\n location: string;\n /** false only for an env secret whose store write was uncertain or failed. */\n durable: boolean;\n /** Why the file store: the OS store probed absent (S4 line), or --insecure-storage. Absent otherwise. */\n fileReason?: 'no-keyring' | 'insecure-storage';\n /** durable:false only: the store the env secret could not be saved to (picks the passphraseNote wording). */\n attempted?: DurableStore;\n /** durable:false only: why it was not saved there (picks the passphraseNote wording). */\n notSaved?: Exclude<DurableWrite, 'stored' | 'already-stored'>;\n}\n\n/**\n * Is the platform's own store reachable, before create or repair picks a\n * target? `absent` is definite (no `secret-tool`, no D-Bus, no default\n * keychain, no PowerShell, or a platform with no OS store at all) and sends the\n * secret to the 0600 file. `uncertain` (killed at 3 s, refused, anything\n * unclear) is NOT absent: the store exists and may just be locked, so callers\n * refuse rather than fall to plaintext (S3). DPAPI has no lock, so its probe is\n * never `uncertain`: anything but a missing PowerShell is `available`.\n */\nexport async function probeDurableStore(\n deps: PassphraseDeps,\n): Promise<{ store: DurableStore; probe: StoreProbe; detail?: string }> {\n const store = storeFor(deps);\n if (store === null) {\n return { store: 'file', probe: 'absent', detail: 'this platform has no OS credential store' };\n }\n const result = await store.probe({ timeoutMs: timeoutsOf(deps).probeMs });\n return { store: store.source, ...result };\n}\n\n/**\n * Resolve the passphrase to ENCRYPT the new wallet at `address`. It NEVER\n * prompts (Q1): the secret is `TENJIN_WALLET_PASSPHRASE` when set, else 32\n * random bytes, chosen ONCE before any write. Users who want their own\n * passphrase set the variable.\n *\n * Where it goes: the file store with `insecureStorage`; otherwise the platform\n * store when its probe says available, the 0600 file when it says absent (S4),\n * and a refusal when it says uncertain (S3: a locked keychain is never routed\n * around). An env secret is saved durably too (Q2), so a one-shot agent install\n * with the variable set does not strand the wallet once the variable is gone.\n *\n * The write happens BEFORE the caller encrypts and is proven by reading it back\n * (storeDurablyDetailed), so a generated passphrase can never be lost between\n * generating it and persisting the encrypted key: a generated secret that is\n * not proven stored refuses the create. An env secret is still the user's to\n * keep, so its create goes ahead with `durable: false`. This path never touches\n * the legacy shared slot or any other wallet's entry.\n */\nexport async function resolvePassphraseForCreate(\n deps: PassphraseDeps,\n address: string,\n opts: { insecureStorage?: boolean } = {},\n): Promise<CreatePassphraseResult> {\n const fromEnv = envPassphrase(deps.env);\n const origin = fromEnv !== null ? 'env' : 'generated';\n const secret = fromEnv ?? randomBytes(32).toString('base64url');\n const account = walletStoreAccount(address);\n const envOnly = (\n attempted: DurableStore,\n notSaved: Exclude<DurableWrite, 'stored' | 'already-stored'>,\n ): CreatePassphraseResult => ({\n passphrase: secret,\n source: 'env',\n origin,\n location: 'TENJIN_WALLET_PASSPHRASE',\n durable: false,\n attempted,\n notSaved,\n });\n\n let target: DurableStore;\n let fileReason: CreatePassphraseResult['fileReason'];\n if (opts.insecureStorage === true) {\n target = 'file';\n fileReason = 'insecure-storage';\n } else {\n const probed = await probeDurableStore(deps);\n if (probed.probe === 'available') {\n target = probed.store;\n } else if (probed.probe === 'absent') {\n target = 'file';\n fileReason = 'no-keyring';\n } else {\n if (origin === 'env') return envOnly(probed.store, 'uncertain');\n throw new CliError(\n 'REFUSED',\n `The ${storeNoun(probed.store)} did not answer within ${Math.round(timeoutsOf(deps).probeMs / 1000)} s; it may be locked. No wallet was created.`,\n { fix: KEYCHAIN_LOCKED_FIX, details: unlockDetails('keychain_locked') },\n );\n }\n }\n\n const written = await storeDurablyDetailed(deps, target, address, secret);\n if (written.outcome === 'stored' || written.outcome === 'already-stored') {\n return {\n passphrase: secret,\n source: target,\n origin,\n location: describeStoreLocation(target, account, deps.dir),\n durable: true,\n ...(fileReason !== undefined ? { fileReason } : {}),\n };\n }\n if (origin === 'env') return envOnly(target, written.outcome);\n const detail = written.detail ?? `the ${storeNoun(target)} write failed`;\n if (target === 'file') {\n // Decision 6: there is no keychain to unlock here, so neither the fix nor\n // the details may point at one.\n const path = describeStoreLocation('file', account, deps.dir);\n throw new CliError(\n 'REFUSED',\n `Could not save the wallet passphrase to ${path} (${detail}); no wallet was created.`,\n {\n fix: FILE_STORE_FAILED_FIX(path),\n details: { passphraseStore: { kind: 'file-write-failed', path } },\n },\n );\n }\n throw new CliError(\n 'REFUSED',\n `Could not save the wallet passphrase to ${describeStoreLocation(target, account, deps.dir)} (${detail}); no wallet was created.`,\n { fix: KEYCHAIN_LOCKED_FIX, details: unlockDetails('keychain_locked', target) },\n );\n}\n\n/**\n * Where a store keeps `account`'s passphrase, in words an operator can find it\n * by. The file path shows the home directory as `~`.\n */\nexport function describeStoreLocation(store: DurableStore, account: string, dir?: string): string {\n switch (store) {\n case 'keychain':\n return `your macOS keychain (service ${KEYCHAIN_SERVICE}, account ${account})`;\n case 'secret-service':\n return `your Linux keyring (Secret Service, service ${KEYCHAIN_SERVICE}, account ${account})`;\n case 'dpapi':\n return `a DPAPI-encrypted file (passphrase.${account}.dpapi)`;\n case 'file':\n return tildePath(passphraseFilePathFor(account, dir));\n }\n}\n\n/** `path` with the home directory shown as `~`, as a person would type it. */\nfunction tildePath(path: string): string {\n const home = homedir();\n if (home.length > 1 && (path === home || path.startsWith(`${home}/`))) {\n return `~${path.slice(home.length)}`;\n }\n return path;\n}\n\n/** Ask for a passphrase at the hidden prompt (repair, and the `--replace` outgoing wallet). */\nexport function promptPassphrase(deps: PassphraseDeps, label: string): Promise<string> {\n return promptOf(deps)(label);\n}\n\n/**\n * Why `store`'s `storable` gate turned a value away, as a clause: the\n * keychain writer's printable-ASCII rule, or a line break at the end that the\n * other stores' reads strip, so the saved value would not read back.\n */\nexport function unstorableWhy(store: DurableStore): string {\n return store === 'keychain'\n ? 'the macOS keychain writer only stores printable ASCII passphrases'\n : `a passphrase that ends in a line break does not read back from the ${storeNoun(store)}`;\n}\n\n/** The env passphrase, non-empty and used exactly as given; null when unset/empty. */\nfunction envPassphrase(env: NodeJS.ProcessEnv): string | null {\n const value = env.TENJIN_WALLET_PASSPHRASE;\n return value !== undefined && value.length > 0 ? value : null;\n}\n\nfunction canPrompt(deps: PassphraseDeps): boolean {\n return deps.isTTY ?? Boolean(process.stdin.isTTY);\n}\n\nfunction promptOf(deps: PassphraseDeps): PromptFn {\n return deps.prompt ?? promptHidden;\n}\n\n/** The hidden prompt for a passphrase, whose Ctrl-C names the passphrase. */\nconst promptHidden: PromptFn = hiddenPrompt(\n () =>\n new CliError('USAGE', 'Passphrase entry was cancelled.', {\n fix: 'Run the command again, or set TENJIN_WALLET_PASSPHRASE.',\n }),\n);\n\n/**\n * No source holds a passphrase (`passphrase_missing`). The message keeps its\n * prefix (install-wallet matches on it); `location` names the recorded store\n * that came back empty. The fix sends the PERSON to repair (B1): never \"set\n * TENJIN_WALLET_PASSPHRASE\", which invites an agent to ask for the value.\n */\nfunction noPassphraseError(location?: string): CliError {\n return new CliError(\n 'USAGE',\n location === undefined\n ? 'No wallet passphrase is available.'\n : `No wallet passphrase is available: ${location} has no entry for this wallet.`,\n { fix: REPAIR_IN_TERMINAL, details: unlockDetails('passphrase_missing') },\n );\n}\n\n/**\n * A store that exists but did not answer (`keychain_locked`): unknown, never a\n * block, and its fix is to unlock it, never plaintext or another passphrase\n * (S3). `detail` is the classified one (S2). It also rides in\n * `details.storeDetail` so verify can word its row without parsing this message.\n */\nfunction storeLockedError(\n store: DurableStore,\n account: string,\n detail: string,\n dir: string | undefined,\n recorded: boolean,\n): CliError {\n const where = describeStoreLocation(store, account, dir);\n return new CliError(\n 'USAGE',\n `The passphrase store ${recorded ? 'recorded ' : ''}for this wallet, ${where}, did not answer (${detail}).`,\n {\n fix: KEYCHAIN_LOCKED_FIX,\n details: { ...unlockDetails('keychain_locked', store), storeDetail: detail },\n },\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;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E;AACF;AAQA,SAAS,iBACP,OACA,SACA,QACA,KACA,UACU;AACV,QAAM,QAAQ,sBAAsB,OAAO,SAAS,GAAG;AACvD,SAAO,IAAI;AAAA,IACT;AAAA,IACA,wBAAwB,WAAW,cAAc,EAAE,oBAAoB,KAAK,qBAAqB,MAAM;AAAA,IACvG;AAAA,MACE,KAAK;AAAA,MACL,SAAS,EAAE,GAAG,cAAc,mBAAmB,KAAK,GAAG,aAAa,OAAO;AAAA,IAC7E;AAAA,EACF;AACF;","names":[]}
|
|
@@ -0,0 +1,488 @@
|
|
|
1
|
+
import { createRequire as __tenjinCreateRequire } from 'node:module'; const require = __tenjinCreateRequire(import.meta.url);
|
|
2
|
+
import {
|
|
3
|
+
HARNESSES
|
|
4
|
+
} from "./chunk-IULCDMVG.js";
|
|
5
|
+
import {
|
|
6
|
+
personalSettingsAt
|
|
7
|
+
} from "./chunk-W2GXIARJ.js";
|
|
8
|
+
import {
|
|
9
|
+
writeFileAtomic,
|
|
10
|
+
writeFileAtomicExclusive
|
|
11
|
+
} from "./chunk-7WEQQJLG.js";
|
|
12
|
+
import {
|
|
13
|
+
AccountOfferSpecSchema,
|
|
14
|
+
ChoicesSchema,
|
|
15
|
+
OfferSpecSchema,
|
|
16
|
+
reportSpecOutcome
|
|
17
|
+
} from "./chunk-ZEYA2WWX.js";
|
|
18
|
+
import {
|
|
19
|
+
SettingsHashSchema
|
|
20
|
+
} from "./chunk-RGCPELQN.js";
|
|
21
|
+
import {
|
|
22
|
+
external_exports
|
|
23
|
+
} from "./chunk-P6YQWIT2.js";
|
|
24
|
+
|
|
25
|
+
// src/router/specs.ts
|
|
26
|
+
import { createHash, randomUUID } from "node:crypto";
|
|
27
|
+
import { constants } from "node:fs";
|
|
28
|
+
import { lstat, open, opendir, rm } from "node:fs/promises";
|
|
29
|
+
import { join } from "node:path";
|
|
30
|
+
var SPECS_DIR = join("progress", "specs");
|
|
31
|
+
var RESULTS_DIR = "results";
|
|
32
|
+
var MAX_SPEC_BYTES = 128 * 1024;
|
|
33
|
+
var SPEC_TTL_MS = 15 * 6e4;
|
|
34
|
+
var RESULT_TTL_MS = 24 * 60 * 6e4;
|
|
35
|
+
var digest = (value) => createHash("sha256").update(value).digest("hex");
|
|
36
|
+
function specPath(dataDir, id) {
|
|
37
|
+
return join(dataDir, SPECS_DIR, `${digest(id)}.json`);
|
|
38
|
+
}
|
|
39
|
+
var SHOWN_KEY = "shown";
|
|
40
|
+
var KeptSpecSchema = OfferSpecSchema.extend({
|
|
41
|
+
settingsHash: SettingsHashSchema.optional()
|
|
42
|
+
});
|
|
43
|
+
function shownInputField(spec) {
|
|
44
|
+
if (spec.output === "media") return null;
|
|
45
|
+
const held = spec.holds?.WebSearch ?? spec.holds?.WebFetch;
|
|
46
|
+
if (held !== void 0) return held;
|
|
47
|
+
const properties = spec.input.properties;
|
|
48
|
+
if (properties === null || typeof properties !== "object") return null;
|
|
49
|
+
const isString = (name) => properties[name]?.type === "string";
|
|
50
|
+
const required = Array.isArray(spec.input.required) ? spec.input.required.filter((name) => typeof name === "string") : [];
|
|
51
|
+
return required.find(isString) ?? Object.keys(properties).find(isString) ?? null;
|
|
52
|
+
}
|
|
53
|
+
var REPLACES_KEY = "replaces";
|
|
54
|
+
async function storeSpecs(dataDir, specs, settingsHash, opts = {}) {
|
|
55
|
+
if (specs === void 0 || specs.length === 0) return;
|
|
56
|
+
for (const spec of specs) {
|
|
57
|
+
try {
|
|
58
|
+
await writeKept(
|
|
59
|
+
dataDir,
|
|
60
|
+
spec,
|
|
61
|
+
settingsHash,
|
|
62
|
+
opts.replaces !== void 0 ? { [REPLACES_KEY]: opts.replaces } : {}
|
|
63
|
+
);
|
|
64
|
+
} catch {
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
await prune(join(dataDir, SPECS_DIR), SPEC_TTL_MS, Date.now());
|
|
68
|
+
}
|
|
69
|
+
async function writeKept(dataDir, spec, settingsHash, beside) {
|
|
70
|
+
const kept = {
|
|
71
|
+
...spec,
|
|
72
|
+
[SHOWN_KEY]: shownInputField(spec),
|
|
73
|
+
...beside
|
|
74
|
+
};
|
|
75
|
+
delete kept.settingsHash;
|
|
76
|
+
if (settingsHash !== void 0) kept.settingsHash = settingsHash;
|
|
77
|
+
await writeFileAtomic(specPath(dataDir, spec.id), JSON.stringify(kept), {
|
|
78
|
+
mode: 384,
|
|
79
|
+
dirMode: 448
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
async function readSpec(dataDir, id) {
|
|
83
|
+
return (await readKept(dataDir, id, (kept) => paidSpecOf(kept, id)))?.spec ?? null;
|
|
84
|
+
}
|
|
85
|
+
async function readKept(dataDir, id, read) {
|
|
86
|
+
const file = await open(specPath(dataDir, id), constants.O_RDONLY | constants.O_NOFOLLOW).catch(
|
|
87
|
+
() => void 0
|
|
88
|
+
);
|
|
89
|
+
if (file === void 0) return null;
|
|
90
|
+
try {
|
|
91
|
+
const stat = await file.stat();
|
|
92
|
+
if (Date.now() - stat.mtimeMs > SPEC_TTL_MS || stat.size > MAX_SPEC_BYTES) return null;
|
|
93
|
+
const kept = JSON.parse(await file.readFile("utf8"));
|
|
94
|
+
if (kept === null || typeof kept !== "object" || Array.isArray(kept)) return null;
|
|
95
|
+
return read(kept);
|
|
96
|
+
} catch {
|
|
97
|
+
return null;
|
|
98
|
+
} finally {
|
|
99
|
+
await file.close().catch(() => void 0);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
function paidSpecOf(kept, id) {
|
|
103
|
+
const replaces = kept[REPLACES_KEY];
|
|
104
|
+
const fields = { ...kept };
|
|
105
|
+
delete fields[SHOWN_KEY];
|
|
106
|
+
delete fields[REPLACES_KEY];
|
|
107
|
+
const parsed = KeptSpecSchema.safeParse(fields);
|
|
108
|
+
if (!parsed.success || parsed.data.id !== id) return null;
|
|
109
|
+
return {
|
|
110
|
+
spec: parsed.data,
|
|
111
|
+
...typeof replaces === "string" && replaces.length > 0 ? { replaces } : {}
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
async function storeAccountOffer(dataDir, lead, settingsHash) {
|
|
115
|
+
try {
|
|
116
|
+
await writeKept(dataDir, lead, settingsHash, {});
|
|
117
|
+
} catch {
|
|
118
|
+
}
|
|
119
|
+
await prune(join(dataDir, SPECS_DIR), SPEC_TTL_MS, Date.now());
|
|
120
|
+
}
|
|
121
|
+
async function readKeptSpec(dataDir, id) {
|
|
122
|
+
return readKept(dataDir, id, (kept) => paidSpecOf(kept, id) ?? accountSpecOf(kept, id));
|
|
123
|
+
}
|
|
124
|
+
function accountSpecOf(kept, id) {
|
|
125
|
+
const hash = SettingsHashSchema.optional().safeParse(kept.settingsHash);
|
|
126
|
+
const fields = { ...kept };
|
|
127
|
+
for (const key of [SHOWN_KEY, "settingsHash"]) delete fields[key];
|
|
128
|
+
const account = AccountOfferSpecSchema.safeParse(fields);
|
|
129
|
+
if (!account.success || account.data.id !== id || !hash.success) return null;
|
|
130
|
+
return {
|
|
131
|
+
spec: { ...account.data, ...hash.data !== void 0 ? { settingsHash: hash.data } : {} },
|
|
132
|
+
account: true
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
var KeptChoicesSchema = external_exports.strictObject({
|
|
136
|
+
choices: ChoicesSchema,
|
|
137
|
+
hint: external_exports.string().max(2e3)
|
|
138
|
+
});
|
|
139
|
+
function choicesPath(dataDir, id) {
|
|
140
|
+
return join(dataDir, SPECS_DIR, `${digest(id)}.choices.json`);
|
|
141
|
+
}
|
|
142
|
+
async function storeChoices(dataDir, id, kept) {
|
|
143
|
+
if (kept === void 0) return;
|
|
144
|
+
try {
|
|
145
|
+
await writeFileAtomic(choicesPath(dataDir, id), JSON.stringify(kept), {
|
|
146
|
+
mode: 384,
|
|
147
|
+
dirMode: 448
|
|
148
|
+
});
|
|
149
|
+
} catch {
|
|
150
|
+
}
|
|
151
|
+
await prune(join(dataDir, SPECS_DIR), SPEC_TTL_MS, Date.now());
|
|
152
|
+
}
|
|
153
|
+
async function readChoices(dataDir, id) {
|
|
154
|
+
const file = await open(
|
|
155
|
+
choicesPath(dataDir, id),
|
|
156
|
+
constants.O_RDONLY | constants.O_NOFOLLOW
|
|
157
|
+
).catch(() => void 0);
|
|
158
|
+
if (file === void 0) return null;
|
|
159
|
+
try {
|
|
160
|
+
const stat = await file.stat();
|
|
161
|
+
if (Date.now() - stat.mtimeMs > SPEC_TTL_MS || stat.size > MAX_SPEC_BYTES) return null;
|
|
162
|
+
const parsed = KeptChoicesSchema.safeParse(JSON.parse(await file.readFile("utf8")));
|
|
163
|
+
return parsed.success ? parsed.data : null;
|
|
164
|
+
} catch {
|
|
165
|
+
return null;
|
|
166
|
+
} finally {
|
|
167
|
+
await file.close().catch(() => void 0);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
function labelPath(dataDir, id) {
|
|
171
|
+
return join(dataDir, SPECS_DIR, `${digest(id)}.label.json`);
|
|
172
|
+
}
|
|
173
|
+
async function storeLabel(dataDir, id, label) {
|
|
174
|
+
try {
|
|
175
|
+
await writeFileAtomic(labelPath(dataDir, id), JSON.stringify({ id, label }), {
|
|
176
|
+
mode: 384,
|
|
177
|
+
dirMode: 448
|
|
178
|
+
});
|
|
179
|
+
} catch {
|
|
180
|
+
}
|
|
181
|
+
await prune(join(dataDir, SPECS_DIR), SPEC_TTL_MS, Date.now());
|
|
182
|
+
}
|
|
183
|
+
var PaymentSchema = external_exports.discriminatedUnion("state", [
|
|
184
|
+
external_exports.strictObject({
|
|
185
|
+
state: external_exports.literal("paid"),
|
|
186
|
+
at: external_exports.string().max(40),
|
|
187
|
+
amountAtomic: external_exports.string().regex(/^\d+$/),
|
|
188
|
+
txHash: external_exports.string().max(100).optional(),
|
|
189
|
+
owner: external_exports.string().max(64).optional()
|
|
190
|
+
}),
|
|
191
|
+
external_exports.strictObject({
|
|
192
|
+
state: external_exports.literal("possibly_paid"),
|
|
193
|
+
at: external_exports.string().max(40),
|
|
194
|
+
owner: external_exports.string().max(64).optional()
|
|
195
|
+
}),
|
|
196
|
+
external_exports.strictObject({ state: external_exports.literal("running"), at: external_exports.string().max(40) }),
|
|
197
|
+
external_exports.strictObject({ state: external_exports.literal("account"), at: external_exports.string().max(40) }),
|
|
198
|
+
external_exports.strictObject({
|
|
199
|
+
state: external_exports.literal("switched"),
|
|
200
|
+
at: external_exports.string().max(40),
|
|
201
|
+
to: external_exports.string().max(200)
|
|
202
|
+
})
|
|
203
|
+
]);
|
|
204
|
+
function paymentPath(dataDir, id) {
|
|
205
|
+
return join(dataDir, SPECS_DIR, `${digest(id)}.paid.json`);
|
|
206
|
+
}
|
|
207
|
+
async function claimSpecPayment(dataDir, id, now = Date.now()) {
|
|
208
|
+
const path = paymentPath(dataDir, id);
|
|
209
|
+
try {
|
|
210
|
+
await writeFileAtomicExclusive(
|
|
211
|
+
path,
|
|
212
|
+
JSON.stringify({ state: "running", at: new Date(now).toISOString() }),
|
|
213
|
+
{ mode: 384, dirMode: 448 }
|
|
214
|
+
);
|
|
215
|
+
return null;
|
|
216
|
+
} catch (err) {
|
|
217
|
+
if (err.code !== "EEXIST") return { state: "unrecorded" };
|
|
218
|
+
}
|
|
219
|
+
const file = await open(path, constants.O_RDONLY | constants.O_NOFOLLOW).catch(() => void 0);
|
|
220
|
+
if (file === void 0) return { state: "running" };
|
|
221
|
+
try {
|
|
222
|
+
const parsed = PaymentSchema.safeParse(JSON.parse(await file.readFile("utf8")));
|
|
223
|
+
return parsed.success ? parsed.data : { state: "running" };
|
|
224
|
+
} catch {
|
|
225
|
+
return { state: "running" };
|
|
226
|
+
} finally {
|
|
227
|
+
await file.close().catch(() => void 0);
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
async function settleSpecPayment(dataDir, id, left, now = Date.now()) {
|
|
231
|
+
const path = paymentPath(dataDir, id);
|
|
232
|
+
if (!left.signed && left.amountAtomic === 0n) {
|
|
233
|
+
await rm(path, { force: true }).catch(() => void 0);
|
|
234
|
+
return void 0;
|
|
235
|
+
}
|
|
236
|
+
const at = new Date(now).toISOString();
|
|
237
|
+
const owner = randomUUID();
|
|
238
|
+
const record = left.amountAtomic > 0n ? {
|
|
239
|
+
state: "paid",
|
|
240
|
+
at,
|
|
241
|
+
amountAtomic: left.amountAtomic.toString(),
|
|
242
|
+
...left.txHash !== void 0 ? { txHash: left.txHash } : {},
|
|
243
|
+
owner
|
|
244
|
+
} : { state: "possibly_paid", at, owner };
|
|
245
|
+
return writeFileAtomic(path, JSON.stringify(record), { mode: 384, dirMode: 448 }).then(
|
|
246
|
+
() => owner,
|
|
247
|
+
() => void 0
|
|
248
|
+
);
|
|
249
|
+
}
|
|
250
|
+
async function releaseSpecClaim(dataDir, id, owner) {
|
|
251
|
+
const path = paymentPath(dataDir, id);
|
|
252
|
+
const file = await open(path, constants.O_RDONLY | constants.O_NOFOLLOW).catch(() => void 0);
|
|
253
|
+
if (file === void 0) return;
|
|
254
|
+
let mine;
|
|
255
|
+
try {
|
|
256
|
+
const parsed = PaymentSchema.safeParse(JSON.parse(await file.readFile("utf8")));
|
|
257
|
+
mine = parsed.success && "owner" in parsed.data && parsed.data.owner === owner;
|
|
258
|
+
} catch {
|
|
259
|
+
mine = false;
|
|
260
|
+
} finally {
|
|
261
|
+
await file.close().catch(() => void 0);
|
|
262
|
+
}
|
|
263
|
+
if (mine) await rm(path, { force: true }).catch(() => void 0);
|
|
264
|
+
}
|
|
265
|
+
async function settleAccountRun(dataDir, id, ran, now = Date.now()) {
|
|
266
|
+
const path = paymentPath(dataDir, id);
|
|
267
|
+
if (ran === false) {
|
|
268
|
+
await rm(path, { force: true }).catch(() => void 0);
|
|
269
|
+
return;
|
|
270
|
+
}
|
|
271
|
+
const at = new Date(now).toISOString();
|
|
272
|
+
const record = ran === true ? { state: "account", at } : { state: "switched", at, to: ran.to };
|
|
273
|
+
await writeFileAtomic(path, JSON.stringify(record), { mode: 384, dirMode: 448 }).catch(
|
|
274
|
+
() => void 0
|
|
275
|
+
);
|
|
276
|
+
}
|
|
277
|
+
async function storeFullResult(dataDir, id, body) {
|
|
278
|
+
const path = join(dataDir, RESULTS_DIR, `${digest(id)}.json`);
|
|
279
|
+
try {
|
|
280
|
+
await writeFileAtomic(path, body, { mode: 384, dirMode: 448 });
|
|
281
|
+
} catch {
|
|
282
|
+
return null;
|
|
283
|
+
}
|
|
284
|
+
void prune(join(dataDir, RESULTS_DIR), RESULT_TTL_MS, Date.now());
|
|
285
|
+
return path;
|
|
286
|
+
}
|
|
287
|
+
async function prune(dir, ttlMs, now) {
|
|
288
|
+
try {
|
|
289
|
+
const directory = await opendir(dir);
|
|
290
|
+
for await (const entry of directory) {
|
|
291
|
+
if (!entry.isFile()) continue;
|
|
292
|
+
const path = join(dir, entry.name);
|
|
293
|
+
const stat = await lstat(path).catch(() => void 0);
|
|
294
|
+
if (stat === void 0 || now - stat.mtimeMs > ttlMs) {
|
|
295
|
+
await rm(path, { force: true }).catch(() => void 0);
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
} catch {
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
// src/router/settings-check.ts
|
|
303
|
+
var ASK_AGAIN = "Call request again with the query (request({query})) for an offer under the current settings.";
|
|
304
|
+
async function settingsRefusal(dataDir, decided) {
|
|
305
|
+
const now = await rulesNow(dataDir);
|
|
306
|
+
if ("problem" in now) return UNREADABLE;
|
|
307
|
+
for (const hash of decided) {
|
|
308
|
+
const refusal = hashRefusal(now.wire, hash);
|
|
309
|
+
if (refusal !== null) return refusal;
|
|
310
|
+
}
|
|
311
|
+
return null;
|
|
312
|
+
}
|
|
313
|
+
async function rulesNow(dataDir) {
|
|
314
|
+
let now;
|
|
315
|
+
try {
|
|
316
|
+
now = await personalSettingsAt(dataDir);
|
|
317
|
+
} catch (err) {
|
|
318
|
+
return { problem: err instanceof Error ? err.message : String(err) };
|
|
319
|
+
}
|
|
320
|
+
return now.wire.status === "invalid" ? { problem: now.wire.problem } : { wire: now.wire };
|
|
321
|
+
}
|
|
322
|
+
function hashRefusal(wire, hash) {
|
|
323
|
+
if (hash === void 0) {
|
|
324
|
+
if (!wire.hasRules) return null;
|
|
325
|
+
return {
|
|
326
|
+
code: "settings_unconfirmed",
|
|
327
|
+
reason: "Tenjin's router did not confirm it applied your Tenjin settings to this offer, so it was not run and nothing was sent or paid.",
|
|
328
|
+
nextStep: `${ASK_AGAIN} If Tenjin keeps answering without your settings, use your own tools for this.`
|
|
329
|
+
};
|
|
330
|
+
}
|
|
331
|
+
if (hash !== wire.settings.hash) {
|
|
332
|
+
return {
|
|
333
|
+
code: "settings_changed",
|
|
334
|
+
reason: "Your Tenjin settings changed after this offer was made, so it was not run and nothing was sent or paid.",
|
|
335
|
+
nextStep: ASK_AGAIN
|
|
336
|
+
};
|
|
337
|
+
}
|
|
338
|
+
return null;
|
|
339
|
+
}
|
|
340
|
+
var UNREADABLE = {
|
|
341
|
+
code: "settings_unreadable",
|
|
342
|
+
reason: "Your saved Tenjin rules can't be read, so Tenjin offers nothing.",
|
|
343
|
+
nextStep: "`tenjin config` shows the problem and `tenjin config reset --all` clears them; run either if the user asks."
|
|
344
|
+
};
|
|
345
|
+
|
|
346
|
+
// src/router/untaken.ts
|
|
347
|
+
import { createHash as createHash2 } from "node:crypto";
|
|
348
|
+
import { constants as constants2 } from "node:fs";
|
|
349
|
+
import { open as open2, opendir as opendir2, rm as rm2 } from "node:fs/promises";
|
|
350
|
+
import { join as join2 } from "node:path";
|
|
351
|
+
var UNTAKEN_DIR = join2("progress", "untaken");
|
|
352
|
+
var FILE_RE = /^[a-f0-9]{64}\.json$/;
|
|
353
|
+
var ID_RE = /^[A-Za-z0-9_-]{8,64}$/;
|
|
354
|
+
var MAX_IDS = 16;
|
|
355
|
+
var MAX_ENTRIES = 256;
|
|
356
|
+
var MAX_ENTRY_BYTES = 4096;
|
|
357
|
+
var digest2 = (value) => createHash2("sha256").update(value).digest("hex");
|
|
358
|
+
function offerScope(session, agentId) {
|
|
359
|
+
return digest2(JSON.stringify([session, agentId ?? ""]));
|
|
360
|
+
}
|
|
361
|
+
async function noteShown(dataDir, offer, now = Date.now()) {
|
|
362
|
+
if (!ID_RE.test(offer.id)) return;
|
|
363
|
+
const ids = [.../* @__PURE__ */ new Set([offer.id, ...offer.ids.filter((id) => ID_RE.test(id))])].slice(
|
|
364
|
+
0,
|
|
365
|
+
MAX_IDS
|
|
366
|
+
);
|
|
367
|
+
const entry = { version: 1, at: now, ...offer, ids };
|
|
368
|
+
await writeFileAtomic(
|
|
369
|
+
join2(dataDir, UNTAKEN_DIR, `${digest2(offer.id)}.json`),
|
|
370
|
+
JSON.stringify(entry),
|
|
371
|
+
{
|
|
372
|
+
mode: 384,
|
|
373
|
+
dirMode: 448
|
|
374
|
+
}
|
|
375
|
+
).catch(() => void 0);
|
|
376
|
+
}
|
|
377
|
+
async function markTaken(dataDir, id) {
|
|
378
|
+
const own = join2(dataDir, UNTAKEN_DIR, `${digest2(id)}.json`);
|
|
379
|
+
if ((await readEntry(own))?.ids.includes(id) === true) {
|
|
380
|
+
await rm2(own, { force: true }).catch(() => void 0);
|
|
381
|
+
return;
|
|
382
|
+
}
|
|
383
|
+
for (const { path, entry } of await entries(dataDir, Infinity)) {
|
|
384
|
+
if (entry?.ids.includes(id) === true) await rm2(path, { force: true }).catch(() => void 0);
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
async function claimIgnored(dataDir, o) {
|
|
388
|
+
const claimed = [];
|
|
389
|
+
for (const { path, entry } of await entries(dataDir)) {
|
|
390
|
+
if (entry === null) {
|
|
391
|
+
await rm2(path, { force: true }).catch(() => void 0);
|
|
392
|
+
continue;
|
|
393
|
+
}
|
|
394
|
+
const reason = o.now - entry.at > SPEC_TTL_MS ? "expired" : o.nativeScope !== void 0 && entry.scope === o.nativeScope && entry.at <= o.now ? "native_after_offer" : null;
|
|
395
|
+
if (reason === null) continue;
|
|
396
|
+
const won = await rm2(path).then(
|
|
397
|
+
() => true,
|
|
398
|
+
() => false
|
|
399
|
+
);
|
|
400
|
+
if (won) claimed.push({ id: entry.id, harness: entry.harness, reason });
|
|
401
|
+
}
|
|
402
|
+
return claimed;
|
|
403
|
+
}
|
|
404
|
+
function reportIgnored(claimed, deps) {
|
|
405
|
+
return Promise.all(
|
|
406
|
+
claimed.map(
|
|
407
|
+
({ id, harness, reason }) => reportSpecOutcome(
|
|
408
|
+
{ id, status: "ignored", reason },
|
|
409
|
+
{
|
|
410
|
+
ctx: deps.ctx,
|
|
411
|
+
baseUrl: deps.baseUrl,
|
|
412
|
+
harness,
|
|
413
|
+
...deps.fetchImpl !== void 0 ? { fetchImpl: deps.fetchImpl } : {}
|
|
414
|
+
}
|
|
415
|
+
)
|
|
416
|
+
)
|
|
417
|
+
).then(() => void 0);
|
|
418
|
+
}
|
|
419
|
+
async function entries(dataDir, limit = MAX_ENTRIES) {
|
|
420
|
+
const dir = join2(dataDir, UNTAKEN_DIR);
|
|
421
|
+
const found = [];
|
|
422
|
+
try {
|
|
423
|
+
const listing = await opendir2(dir);
|
|
424
|
+
for await (const item of listing) {
|
|
425
|
+
if (!item.isFile() || !FILE_RE.test(item.name)) continue;
|
|
426
|
+
const path = join2(dir, item.name);
|
|
427
|
+
found.push({ path, entry: await readEntry(path) });
|
|
428
|
+
if (found.length >= limit) break;
|
|
429
|
+
}
|
|
430
|
+
} catch {
|
|
431
|
+
}
|
|
432
|
+
return found;
|
|
433
|
+
}
|
|
434
|
+
async function readEntry(path) {
|
|
435
|
+
const file = await open2(path, constants2.O_RDONLY | constants2.O_NOFOLLOW).catch(() => void 0);
|
|
436
|
+
if (file === void 0) return null;
|
|
437
|
+
try {
|
|
438
|
+
if ((await file.stat()).size > MAX_ENTRY_BYTES) return null;
|
|
439
|
+
const row = JSON.parse(await file.readFile("utf8"));
|
|
440
|
+
const { at, id, ids, harness, scope } = row;
|
|
441
|
+
if (row.version !== 1 || typeof at !== "number" || !Number.isFinite(at)) return null;
|
|
442
|
+
if (typeof id !== "string" || !ID_RE.test(id)) return null;
|
|
443
|
+
if (!Array.isArray(ids) || !ids.every((v) => typeof v === "string")) return null;
|
|
444
|
+
if (!HARNESSES.includes(harness)) return null;
|
|
445
|
+
if (scope !== void 0 && (typeof scope !== "string" || !/^[a-f0-9]{64}$/.test(scope))) {
|
|
446
|
+
return null;
|
|
447
|
+
}
|
|
448
|
+
return {
|
|
449
|
+
version: 1,
|
|
450
|
+
at,
|
|
451
|
+
id,
|
|
452
|
+
ids,
|
|
453
|
+
harness,
|
|
454
|
+
...scope !== void 0 ? { scope } : {}
|
|
455
|
+
};
|
|
456
|
+
} catch {
|
|
457
|
+
return null;
|
|
458
|
+
} finally {
|
|
459
|
+
await file.close().catch(() => void 0);
|
|
460
|
+
}
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
export {
|
|
464
|
+
KeptSpecSchema,
|
|
465
|
+
storeSpecs,
|
|
466
|
+
readSpec,
|
|
467
|
+
storeAccountOffer,
|
|
468
|
+
readKeptSpec,
|
|
469
|
+
KeptChoicesSchema,
|
|
470
|
+
storeChoices,
|
|
471
|
+
readChoices,
|
|
472
|
+
storeLabel,
|
|
473
|
+
claimSpecPayment,
|
|
474
|
+
settleSpecPayment,
|
|
475
|
+
releaseSpecClaim,
|
|
476
|
+
settleAccountRun,
|
|
477
|
+
storeFullResult,
|
|
478
|
+
settingsRefusal,
|
|
479
|
+
rulesNow,
|
|
480
|
+
hashRefusal,
|
|
481
|
+
UNREADABLE,
|
|
482
|
+
offerScope,
|
|
483
|
+
noteShown,
|
|
484
|
+
markTaken,
|
|
485
|
+
claimIgnored,
|
|
486
|
+
reportIgnored
|
|
487
|
+
};
|
|
488
|
+
//# sourceMappingURL=chunk-HKGUKAQW.js.map
|