tenjin-cli 0.1.0-alpha.31 → 0.1.0-alpha.33
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/README.md +45 -26
- package/dist/{_esm-MEXZI5DL.js → _esm-BIN7VY2L.js} +128 -132
- package/dist/{alive-J64H46HI.js → alive-GSOWKUOY.js} +13 -6
- package/dist/auto-update-Y24UL56V.js +24 -0
- package/dist/{ccip-7RMRLAGV.js → ccip-DHDFKTQV.js} +2 -2
- package/dist/{chunk-TTNESUPQ.js → chunk-2GP3HRYK.js} +2120 -193
- package/dist/chunk-2GP3HRYK.js.map +1 -0
- package/dist/chunk-2M2VPI2E.js +560 -0
- package/dist/chunk-2M2VPI2E.js.map +1 -0
- package/dist/{chunk-D65GNPS3.js → chunk-2RWB7RKE.js} +288 -108
- package/dist/chunk-2RWB7RKE.js.map +1 -0
- package/dist/{chunk-AGZ7PJKY.js → chunk-36RVGZNY.js} +22 -5
- package/dist/chunk-36RVGZNY.js.map +1 -0
- package/dist/chunk-3AIHRXKO.js +72 -0
- package/dist/chunk-3AIHRXKO.js.map +1 -0
- package/dist/{chunk-S4SAZ7OD.js → chunk-3FMZGI7I.js} +12 -2
- package/dist/{chunk-S4SAZ7OD.js.map → chunk-3FMZGI7I.js.map} +1 -1
- package/dist/chunk-3GNJXKIT.js +198 -0
- package/dist/chunk-3GNJXKIT.js.map +1 -0
- package/dist/{chunk-UQUOVWBG.js → chunk-4K7TQHNP.js} +7 -7
- package/dist/{chunk-A36LQPHV.js → chunk-4LMUQMBH.js} +1 -1
- package/dist/{chunk-A36LQPHV.js.map → chunk-4LMUQMBH.js.map} +1 -1
- package/dist/{chunk-KXQ4UIP7.js → chunk-4USCZ2NI.js} +2 -2
- package/dist/chunk-4YOZGGTZ.js +247 -0
- package/dist/chunk-4YOZGGTZ.js.map +1 -0
- package/dist/chunk-62KNUYWD.js +111 -0
- package/dist/chunk-62KNUYWD.js.map +1 -0
- package/dist/{chunk-POUWHWID.js → chunk-6CMM6YCB.js} +3 -3
- package/dist/{chunk-POUWHWID.js.map → chunk-6CMM6YCB.js.map} +1 -1
- package/dist/{chunk-5MARFNSB.js → chunk-A5GKIG5O.js} +49 -30
- package/dist/chunk-A5GKIG5O.js.map +1 -0
- package/dist/{chunk-YFPY4ONH.js → chunk-AGMVASXZ.js} +4 -4
- package/dist/chunk-BF4XHEQK.js +116 -0
- package/dist/chunk-BF4XHEQK.js.map +1 -0
- package/dist/chunk-BFDQ4WNW.js +119 -0
- package/dist/chunk-BFDQ4WNW.js.map +1 -0
- package/dist/{chunk-P4NH7OUK.js → chunk-C2Q76BVM.js} +49 -50
- package/dist/chunk-C2Q76BVM.js.map +1 -0
- package/dist/chunk-CEXSOI5R.js +808 -0
- package/dist/chunk-CEXSOI5R.js.map +1 -0
- package/dist/{chunk-QSCPK4F5.js → chunk-E7SW44LM.js} +4 -11
- package/dist/chunk-E7SW44LM.js.map +1 -0
- package/dist/chunk-EDJWHDDL.js +33 -0
- package/dist/chunk-EDJWHDDL.js.map +1 -0
- package/dist/chunk-F3ED5WTR.js +13 -0
- package/dist/chunk-F3ED5WTR.js.map +1 -0
- package/dist/{chunk-K72RURN3.js → chunk-FVIGCDSV.js} +2 -2
- package/dist/chunk-FVIGCDSV.js.map +1 -0
- package/dist/{chunk-5K5W4S66.js → chunk-GTTUCOPD.js} +2 -2
- package/dist/{chunk-4ZZO6ULA.js → chunk-HDPUXS3Z.js} +19 -48
- package/dist/chunk-HDPUXS3Z.js.map +1 -0
- package/dist/{chunk-LEFIX6RS.js → chunk-HGGWCP7W.js} +31 -11
- package/dist/chunk-HGGWCP7W.js.map +1 -0
- package/dist/{chunk-ORWL5BSN.js → chunk-HGZEPQUT.js} +2 -2
- package/dist/chunk-HMWYAUA6.js +478 -0
- package/dist/chunk-HMWYAUA6.js.map +1 -0
- package/dist/{chunk-7QKHZQKW.js → chunk-IADZOXKN.js} +39 -6
- package/dist/chunk-IADZOXKN.js.map +1 -0
- package/dist/{chunk-7Q5FDF65.js → chunk-IE7P2BZE.js} +3 -3
- package/dist/{chunk-77TCKDEC.js → chunk-ILNIZ5I2.js} +788 -508
- package/dist/chunk-ILNIZ5I2.js.map +1 -0
- package/dist/{hosts-FWZOV26H.js → chunk-INTFHMU4.js} +79 -24
- package/dist/chunk-INTFHMU4.js.map +1 -0
- package/dist/{chunk-6E5R45ZO.js → chunk-J57UC3DD.js} +4 -4
- package/dist/{chunk-6E5R45ZO.js.map → chunk-J57UC3DD.js.map} +1 -1
- package/dist/chunk-JNJWBTU2.js +3497 -0
- package/dist/chunk-JNJWBTU2.js.map +1 -0
- package/dist/{chunk-7WU4OPLP.js → chunk-KM7RY2ZS.js} +5 -3
- package/dist/{chunk-7WU4OPLP.js.map → chunk-KM7RY2ZS.js.map} +1 -1
- package/dist/chunk-L6JEXB3E.js +293 -0
- package/dist/chunk-L6JEXB3E.js.map +1 -0
- package/dist/chunk-LRW6S53P.js +450 -0
- package/dist/chunk-LRW6S53P.js.map +1 -0
- package/dist/{chunk-UKY4CHNC.js → chunk-LXAYUOXI.js} +24 -11
- package/dist/chunk-LXAYUOXI.js.map +1 -0
- package/dist/{chunk-WJXLQXJY.js → chunk-MPZUYCAP.js} +4 -1
- package/dist/{chunk-WJXLQXJY.js.map → chunk-MPZUYCAP.js.map} +1 -1
- package/dist/chunk-NDGZDTSJ.js +393 -0
- package/dist/chunk-NDGZDTSJ.js.map +1 -0
- package/dist/{chunk-SJLTEINJ.js → chunk-OJNTCYQQ.js} +17 -1
- package/dist/chunk-OJNTCYQQ.js.map +1 -0
- package/dist/{chunk-OHRR5OYM.js → chunk-P3LFTKE7.js} +5 -10
- package/dist/chunk-P3LFTKE7.js.map +1 -0
- package/dist/{chunk-XZKD7DIF.js → chunk-RL5UUDT4.js} +3 -3
- package/dist/{chunk-XZKD7DIF.js.map → chunk-RL5UUDT4.js.map} +1 -1
- package/dist/{chunk-5C32RLTA.js → chunk-RVPYTUP4.js} +20 -5
- package/dist/chunk-RVPYTUP4.js.map +1 -0
- package/dist/{chunk-YVFXE7RR.js → chunk-SNNSAGMT.js} +7279 -2627
- package/dist/chunk-SNNSAGMT.js.map +1 -0
- package/dist/{chunk-WK7F3B2E.js → chunk-SO3XRZPX.js} +3 -3
- package/dist/{chunk-R5LCN54M.js → chunk-TC2WZLSC.js} +13 -17
- package/dist/{chunk-R5LCN54M.js.map → chunk-TC2WZLSC.js.map} +1 -1
- package/dist/{chunk-B7HUUJOK.js → chunk-TKPF35W6.js} +3 -3
- package/dist/{chunk-KXVP2VKA.js → chunk-U3IKUGRP.js} +32 -33
- package/dist/chunk-U3IKUGRP.js.map +1 -0
- package/dist/{chunk-AKWGE6JQ.js → chunk-UUGOUOVT.js} +37 -2
- package/dist/chunk-UUGOUOVT.js.map +1 -0
- package/dist/{chunk-2XLC3AEX.js → chunk-UXZONNEQ.js} +536 -510
- package/dist/chunk-UXZONNEQ.js.map +1 -0
- package/dist/{chunk-7ZRL2LBQ.js → chunk-V2LQLN5H.js} +6 -6
- package/dist/{chunk-NEFNKLBE.js → chunk-WFSPCCVW.js} +1536 -423
- package/dist/chunk-WFSPCCVW.js.map +1 -0
- package/dist/{chunk-27EPWVOY.js → chunk-WXA2BWTE.js} +7 -3
- package/dist/chunk-WXA2BWTE.js.map +1 -0
- package/dist/chunk-WYXUQGOL.js +191 -0
- package/dist/chunk-WYXUQGOL.js.map +1 -0
- package/dist/chunk-X5ZBP3IY.js +97 -0
- package/dist/chunk-X5ZBP3IY.js.map +1 -0
- package/dist/{chunk-MNXS2U45.js → chunk-ZDZERB6L.js} +206 -297
- package/dist/chunk-ZDZERB6L.js.map +1 -0
- package/dist/chunk-ZNNXRNFD.js +113 -0
- package/dist/chunk-ZNNXRNFD.js.map +1 -0
- package/dist/{chunk-FW75G2W4.js → chunk-ZURZHELF.js} +5 -5
- package/dist/{cli-D5OE3URZ.js → cli-E36SPKBW.js} +145 -64
- package/dist/{cli-D5OE3URZ.js.map → cli-E36SPKBW.js.map} +1 -1
- package/dist/{codex-event-PPNVRRDH.js → codex-event-ZO2GEFE6.js} +2 -2
- package/dist/{codex-host-2RJOJW2B.js → codex-host-KECJVTA2.js} +7 -6
- package/dist/codex-install-HQZDGFXW.js +436 -0
- package/dist/codex-install-HQZDGFXW.js.map +1 -0
- package/dist/{config-ZD4OB2DO.js → config-HY2E4GGW.js} +21 -17
- package/dist/doctor-I6XQEKWD.js +1323 -0
- package/dist/doctor-I6XQEKWD.js.map +1 -0
- package/dist/{env-proxy-XL4P73MZ.js → env-proxy-R6ZMLQTT.js} +6 -2
- package/dist/{ethersCompat-Df4a6QIZ-THAVUGIJ.js → ethersCompat-Df4a6QIZ-X6YZWAML.js} +3 -3
- package/dist/{fund-5ITKQGYF.js → fund-2QRO7OJL.js} +43 -37
- package/dist/{fund-5ITKQGYF.js.map → fund-2QRO7OJL.js.map} +1 -1
- package/dist/hook-command-2UBCSZG6.js +43 -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/register.tsx +51 -11
- package/dist/hosts/claude/tenjin/skills/tenjin-pay/SKILL.md +82 -0
- package/dist/hosts/claude/tenjin/types/index.d.ts +2 -1
- package/dist/hosts/codex/tenjin/.mcp.json +3 -0
- package/dist/hosts/codex/tenjin/hooks/hooks.json +51 -5
- package/dist/hosts-DVQJ32QC.js +38 -0
- package/dist/index.js +32 -11
- package/dist/index.js.map +1 -1
- package/dist/install-ILUX5C4A.js +107 -0
- package/dist/{install-identity-K7EJIQFP.js → install-identity-TZKGY6LQ.js} +11 -10
- package/dist/install-wallet-5M4OTYLX.js +281 -0
- package/dist/install-wallet-5M4OTYLX.js.map +1 -0
- package/dist/isows-native-Q2UDIVPT.js +9 -0
- package/dist/isows-native-Q2UDIVPT.js.map +1 -0
- package/dist/{mcp-3LIJSSJB.js → mcp-LE4DUS22.js} +785 -211
- package/dist/mcp-LE4DUS22.js.map +1 -0
- package/dist/{mine.wasm-6PIT3DK6.js → mine.wasm-QFAHIFPY.js} +2 -2
- package/dist/{mine.wasm-6PIT3DK6.js.map → mine.wasm-QFAHIFPY.js.map} +1 -1
- package/dist/{package-ZKQFDWLE.js → package-IJFGMWEV.js} +4 -2
- package/dist/passphrase-IFTDS3CU.js +44 -0
- package/dist/{paths-POPTXJO6.js → paths-XCSAKISU.js} +10 -2
- package/dist/{pay-WHBERZ3W.js → pay-WCG3IH4R.js} +29 -29
- package/dist/{payments-KVICEKD2.js → payments-HFPPWHTV.js} +15 -14
- package/dist/{payments-KVICEKD2.js.map → payments-HFPPWHTV.js.map} +1 -1
- package/dist/plugin-registration-PZFI5GZW.js +68 -0
- package/dist/{redact-6W23GGJC.js → redact-D7ASVWKL.js} +2 -2
- package/dist/runtime-UZOKSUZX.js +1321 -0
- package/dist/runtime-UZOKSUZX.js.map +1 -0
- package/dist/runtime-fetch-ZSSSK72Y.js +23 -0
- package/dist/runtime-layout-WIDILZ6K.js +25 -0
- package/dist/{send-7G7Y7DLN.js → send-GCVEAQKL.js} +24 -22
- package/dist/{send-7G7Y7DLN.js.map → send-GCVEAQKL.js.map} +1 -1
- package/dist/{status-OF7RH5HM.js → status-HCVAOCN7.js} +55 -25
- package/dist/status-HCVAOCN7.js.map +1 -0
- package/dist/{status-line-XOUE6MPL.js → status-line-OPCXDHL2.js} +10 -9
- package/dist/{status-line-XOUE6MPL.js.map → status-line-OPCXDHL2.js.map} +1 -1
- package/dist/uninstall-BAWRBXXQ.js +481 -0
- package/dist/uninstall-BAWRBXXQ.js.map +1 -0
- package/dist/update-CACXLQLR.js +56 -0
- package/dist/update-CACXLQLR.js.map +1 -0
- package/dist/{usdc-OGOGEHV2.js → usdc-VG4CIOUK.js} +6 -8
- package/dist/usdc-VG4CIOUK.js.map +1 -0
- package/dist/{viemAdapter-By13KInL-S3DA7DFW.js → viemAdapter-By13KInL-DOFTEIJV.js} +3 -3
- package/dist/viemAdapter-By13KInL-DOFTEIJV.js.map +1 -0
- package/dist/wallet-QL4UUXEZ.js +55 -0
- package/dist/wallet-QL4UUXEZ.js.map +1 -0
- package/dist/wallet-kdf-worker.mjs +8 -8
- package/docs/agent-permissions.md +50 -28
- package/docs/safety-model.md +1 -1
- package/docs/troubleshooting.md +72 -1
- package/package.json +17 -4
- package/scripts/installers/install.ps1 +67 -0
- package/scripts/installers/install.sh +68 -0
- package/dist/_esm-C5CRWCYU.js +0 -3737
- package/dist/_esm-C5CRWCYU.js.map +0 -1
- package/dist/ccip-NLCSCHKI.js +0 -19
- package/dist/chunk-27EPWVOY.js.map +0 -1
- package/dist/chunk-2XLC3AEX.js.map +0 -1
- package/dist/chunk-4ZZO6ULA.js.map +0 -1
- package/dist/chunk-5C32RLTA.js.map +0 -1
- package/dist/chunk-5IEP5EGE.js +0 -5332
- package/dist/chunk-5IEP5EGE.js.map +0 -1
- package/dist/chunk-5MARFNSB.js.map +0 -1
- package/dist/chunk-77TCKDEC.js.map +0 -1
- package/dist/chunk-7EKYXMUO.js +0 -7536
- package/dist/chunk-7EKYXMUO.js.map +0 -1
- package/dist/chunk-7QKHZQKW.js.map +0 -1
- package/dist/chunk-AGZ7PJKY.js.map +0 -1
- package/dist/chunk-AKWGE6JQ.js.map +0 -1
- package/dist/chunk-BL3332HQ.js +0 -7611
- package/dist/chunk-BL3332HQ.js.map +0 -1
- package/dist/chunk-D65GNPS3.js.map +0 -1
- package/dist/chunk-EGELTSPU.js +0 -2865
- package/dist/chunk-EGELTSPU.js.map +0 -1
- package/dist/chunk-GA7JETVM.js +0 -150
- package/dist/chunk-GA7JETVM.js.map +0 -1
- package/dist/chunk-I3EQFHCD.js +0 -175
- package/dist/chunk-I3EQFHCD.js.map +0 -1
- package/dist/chunk-K3I7C2MO.js +0 -1185
- package/dist/chunk-K3I7C2MO.js.map +0 -1
- package/dist/chunk-K72RURN3.js.map +0 -1
- package/dist/chunk-KXVP2VKA.js.map +0 -1
- package/dist/chunk-LEFIX6RS.js.map +0 -1
- package/dist/chunk-MNXS2U45.js.map +0 -1
- package/dist/chunk-NEFNKLBE.js.map +0 -1
- package/dist/chunk-OHRR5OYM.js.map +0 -1
- package/dist/chunk-P4NH7OUK.js.map +0 -1
- package/dist/chunk-QSCPK4F5.js.map +0 -1
- package/dist/chunk-SJLTEINJ.js.map +0 -1
- package/dist/chunk-TTNESUPQ.js.map +0 -1
- package/dist/chunk-UKY4CHNC.js.map +0 -1
- package/dist/chunk-V6BSF6OC.js +0 -260
- package/dist/chunk-V6BSF6OC.js.map +0 -1
- package/dist/chunk-YVFXE7RR.js.map +0 -1
- package/dist/codex-install-UUZ6QMBQ.js +0 -221
- package/dist/codex-install-UUZ6QMBQ.js.map +0 -1
- package/dist/doctor-KBR34Q4B.js +0 -601
- package/dist/doctor-KBR34Q4B.js.map +0 -1
- package/dist/hook-command-4TYCHHRL.js +0 -39
- package/dist/hosts-FWZOV26H.js.map +0 -1
- package/dist/install-XWGE4Q7L.js +0 -77
- package/dist/install-wallet-XQ6XFZV4.js +0 -117
- package/dist/install-wallet-XQ6XFZV4.js.map +0 -1
- package/dist/mcp-3LIJSSJB.js.map +0 -1
- package/dist/plugin-registration-5TIA564H.js +0 -54
- package/dist/status-OF7RH5HM.js.map +0 -1
- package/dist/uninstall-JXUAFNDB.js +0 -158
- package/dist/uninstall-JXUAFNDB.js.map +0 -1
- package/dist/update-ZKUERSO2.js +0 -44
- package/dist/wallet-2HA6W4R4.js +0 -43
- /package/dist/{_esm-MEXZI5DL.js.map → _esm-BIN7VY2L.js.map} +0 -0
- /package/dist/{alive-J64H46HI.js.map → alive-GSOWKUOY.js.map} +0 -0
- /package/dist/{ccip-7RMRLAGV.js.map → auto-update-Y24UL56V.js.map} +0 -0
- /package/dist/{ccip-NLCSCHKI.js.map → ccip-DHDFKTQV.js.map} +0 -0
- /package/dist/{chunk-UQUOVWBG.js.map → chunk-4K7TQHNP.js.map} +0 -0
- /package/dist/{chunk-KXQ4UIP7.js.map → chunk-4USCZ2NI.js.map} +0 -0
- /package/dist/{chunk-YFPY4ONH.js.map → chunk-AGMVASXZ.js.map} +0 -0
- /package/dist/{chunk-5K5W4S66.js.map → chunk-GTTUCOPD.js.map} +0 -0
- /package/dist/{chunk-ORWL5BSN.js.map → chunk-HGZEPQUT.js.map} +0 -0
- /package/dist/{chunk-7Q5FDF65.js.map → chunk-IE7P2BZE.js.map} +0 -0
- /package/dist/{chunk-WK7F3B2E.js.map → chunk-SO3XRZPX.js.map} +0 -0
- /package/dist/{chunk-B7HUUJOK.js.map → chunk-TKPF35W6.js.map} +0 -0
- /package/dist/{chunk-7ZRL2LBQ.js.map → chunk-V2LQLN5H.js.map} +0 -0
- /package/dist/{chunk-FW75G2W4.js.map → chunk-ZURZHELF.js.map} +0 -0
- /package/dist/{codex-event-PPNVRRDH.js.map → codex-event-ZO2GEFE6.js.map} +0 -0
- /package/dist/{codex-host-2RJOJW2B.js.map → codex-host-KECJVTA2.js.map} +0 -0
- /package/dist/{config-ZD4OB2DO.js.map → config-HY2E4GGW.js.map} +0 -0
- /package/dist/{env-proxy-XL4P73MZ.js.map → env-proxy-R6ZMLQTT.js.map} +0 -0
- /package/dist/{ethersCompat-Df4a6QIZ-THAVUGIJ.js.map → ethersCompat-Df4a6QIZ-X6YZWAML.js.map} +0 -0
- /package/dist/{hook-command-4TYCHHRL.js.map → hook-command-2UBCSZG6.js.map} +0 -0
- /package/dist/{install-XWGE4Q7L.js.map → hosts-DVQJ32QC.js.map} +0 -0
- /package/dist/{install-identity-K7EJIQFP.js.map → install-ILUX5C4A.js.map} +0 -0
- /package/dist/{package-ZKQFDWLE.js.map → install-identity-TZKGY6LQ.js.map} +0 -0
- /package/dist/{paths-POPTXJO6.js.map → package-IJFGMWEV.js.map} +0 -0
- /package/dist/{pay-WHBERZ3W.js.map → passphrase-IFTDS3CU.js.map} +0 -0
- /package/dist/{plugin-registration-5TIA564H.js.map → paths-XCSAKISU.js.map} +0 -0
- /package/dist/{redact-6W23GGJC.js.map → pay-WCG3IH4R.js.map} +0 -0
- /package/dist/{update-ZKUERSO2.js.map → plugin-registration-PZFI5GZW.js.map} +0 -0
- /package/dist/{usdc-OGOGEHV2.js.map → redact-D7ASVWKL.js.map} +0 -0
- /package/dist/{viemAdapter-By13KInL-S3DA7DFW.js.map → runtime-fetch-ZSSSK72Y.js.map} +0 -0
- /package/dist/{wallet-2HA6W4R4.js.map → runtime-layout-WIDILZ6K.js.map} +0 -0
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { createRequire as __tenjinCreateRequire } from 'node:module'; const require = __tenjinCreateRequire(import.meta.url);
|
|
2
|
+
import {
|
|
3
|
+
package_default
|
|
4
|
+
} from "./chunk-RVPYTUP4.js";
|
|
2
5
|
import {
|
|
3
6
|
PRODUCTION_ORIGIN
|
|
4
7
|
} from "./chunk-XQJXNMSB.js";
|
|
5
8
|
import {
|
|
6
9
|
CliError
|
|
7
10
|
} from "./chunk-3UCIG4TG.js";
|
|
8
|
-
import {
|
|
9
|
-
package_default
|
|
10
|
-
} from "./chunk-5C32RLTA.js";
|
|
11
11
|
|
|
12
12
|
// src/lib/client-meta.ts
|
|
13
13
|
var TENJIN_PRODUCT = `tenjin-cli/${package_default.version}`;
|
|
@@ -90,6 +90,22 @@ var CREDENTIAL_HEADERS = /* @__PURE__ */ new Set([
|
|
|
90
90
|
function carriesSignedMaterial(headers) {
|
|
91
91
|
return Object.keys(headers).some((name) => CREDENTIAL_HEADERS.has(name.toLowerCase()));
|
|
92
92
|
}
|
|
93
|
+
function isReservedRequestHeader(name) {
|
|
94
|
+
const lowered = name.toLowerCase();
|
|
95
|
+
return CREDENTIAL_HEADERS.has(lowered) || lowered === SHELF_BYPASS_HEADER || lowered === INSTALL_ID_HEADER || lowered.startsWith("payment-") || lowered.startsWith("x-payment");
|
|
96
|
+
}
|
|
97
|
+
var HEADER_NAME = /^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/;
|
|
98
|
+
var TRANSPORT_HEADERS = /* @__PURE__ */ new Set(["host", "content-length", "content-type", "user-agent"]);
|
|
99
|
+
function requestHeaderProblem(name, value, ownContentType = false) {
|
|
100
|
+
if (!HEADER_NAME.test(name) || value.length === 0) return "name";
|
|
101
|
+
const lowered = name.toLowerCase();
|
|
102
|
+
const contentType = ownContentType && lowered === "content-type";
|
|
103
|
+
if (isReservedRequestHeader(lowered) || TRANSPORT_HEADERS.has(lowered) && !contentType) {
|
|
104
|
+
return "reserved";
|
|
105
|
+
}
|
|
106
|
+
if (value.length > 1024 || /[\r\n]/.test(value)) return "value";
|
|
107
|
+
return null;
|
|
108
|
+
}
|
|
93
109
|
function timeoutFailure(url, timeoutMs) {
|
|
94
110
|
return {
|
|
95
111
|
ok: false,
|
|
@@ -136,7 +152,7 @@ function prepareRequest(url, opts) {
|
|
|
136
152
|
} else if (opts.rawBody !== void 0) {
|
|
137
153
|
body = opts.rawBody;
|
|
138
154
|
}
|
|
139
|
-
const wantsAccept = opts.method === "POST" || opts.method === "PUT" || body !== void 0;
|
|
155
|
+
const wantsAccept = opts.method === "POST" || opts.method === "PUT" || opts.method === "PATCH" || body !== void 0;
|
|
140
156
|
if (wantsAccept && !merged.has("accept")) merged.set("accept", "application/json");
|
|
141
157
|
const headers = Object.fromEntries(applyUserAgent(merged, opts.callerUserAgent).entries());
|
|
142
158
|
const signed = carriesSignedMaterial(headers);
|
|
@@ -319,8 +335,9 @@ function oversizedHeaderFailure(url) {
|
|
|
319
335
|
export {
|
|
320
336
|
composeUserAgent,
|
|
321
337
|
setTenjinIdentity,
|
|
338
|
+
requestHeaderProblem,
|
|
322
339
|
isBinaryContentType,
|
|
323
340
|
httpRequest,
|
|
324
341
|
fetchFailureToCliError
|
|
325
342
|
};
|
|
326
|
-
//# sourceMappingURL=chunk-
|
|
343
|
+
//# sourceMappingURL=chunk-36RVGZNY.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/lib/client-meta.ts","../src/lib/http.ts"],"sourcesContent":["import pkg from '../../package.json';\nimport { PRODUCTION_ORIGIN } from './production-origin';\n\n/**\n * The RFC 9110 product token naming this CLI. It leads every User-Agent the\n * shared transport sends, because the server's `parseUserAgentProduct()` (tenjin\n * PR #544) attributes on the FIRST product only and the CLI is the user agent\n * that constructed and sent the request.\n */\nexport const TENJIN_PRODUCT = `tenjin-cli/${pkg.version}`;\n\n/** The product NAME alone, which is what identifies a copy of us in a handoff. */\nexport const TENJIN_PRODUCT_NAME = 'tenjin-cli';\n\n/**\n * The product the WebSearch hook leads with, so a ridealong query is separable\n * from a deliberate `tenjin search`. Leading is the mechanism: the server\n * attributes on the FIRST User-Agent product, landing here in `client_name`.\n *\n * The separation is the deliverable, not any one consumer: whatever judges hook\n * demand needs these populations distinguishable at ingest (tenjin#704,\n * tenjin-agent#179). A rename breaks no filter today, it merges them again. */\nexport const WEBSEARCH_HOOK_PRODUCT_NAME = 'tenjin-websearch-hook';\nexport const WEBSEARCH_HOOK_PRODUCT = `${WEBSEARCH_HOOK_PRODUCT_NAME}/${pkg.version}`;\n\n/** Every identity of ours a handoff may carry, which composition drops rather\n * than duplicate, whichever product is leading. */\nexport const OWN_PRODUCT_NAMES = [TENJIN_PRODUCT_NAME, WEBSEARCH_HOOK_PRODUCT_NAME];\n\n/**\n * The identifying comment. It rides LAST so a caller's products keep the order\n * they were handed off in, and so stripping it is enough to recover the caller's\n * sequence from an already-composed field (see `composeUserAgent`).\n */\nexport const TENJIN_COMMENT = `(+${PRODUCTION_ORIGIN})`;\n\n/**\n * The CLI's identity on every HTTP request, sent as the standard `User-Agent`\n * header from the shared transport (`http.ts`). `X-Tenjin-Client` is retired and\n * this CLI sends it nowhere.\n */\nexport const TENJIN_USER_AGENT = `${TENJIN_PRODUCT} ${TENJIN_COMMENT}`;\n\n/** The same field for the WebSearch hook, which identifies as its own product. */\nexport const WEBSEARCH_HOOK_USER_AGENT = `${WEBSEARCH_HOOK_PRODUCT} ${TENJIN_COMMENT}`;\n\n/** The handoff seam for an agent that launches the CLI as a subprocess. */\nexport const CALLER_USER_AGENT_ENV = 'TENJIN_CALLER_USER_AGENT';\n\n/** The server's bound: a longer field is discarded whole, never truncated. */\nexport const USER_AGENT_MAX_LENGTH = 512;\n\n/**\n * One RFC 9110 product: a token, optionally `/token`. The handoff accepts a\n * sequence of these and nothing else (no comments, no free text), which is what\n * structurally keeps a user, wallet, session, hostname, or machine identifier\n * out of the field rather than a blocklist that has to guess at one.\n */\nexport const PRODUCT_RE = /^[!#$%&'*+.^_`|~0-9A-Za-z-]+(?:\\/[!#$%&'*+.^_`|~0-9A-Za-z-]+)?$/;\n\n/** Printable ASCII, the only range the server parses; also excludes CR/LF/tab. */\nexport const PRINTABLE_ASCII_RE = /^[\\x20-\\x7e]*$/;\n\nexport interface ComposeUserAgentInput {\n /** A caller's product sequence, passed programmatically; wins over the env. */\n caller?: string | undefined;\n /** Environment seam; defaults to `process.env`. */\n env?: NodeJS.ProcessEnv;\n /** The product to lead with; the WebSearch hook passes its own. */\n product?: string;\n}\n\n/**\n * Compose the field the transport sends: the Tenjin product, then the caller's\n * products in their original order, then the Tenjin comment. The handoff is\n * SELF-REPORTED TELEMETRY and never trusted policy input; nothing here or on the\n * server may read it to decide entitlement, spend, or trust.\n *\n * Idempotent by construction: the caller value is decomposed into tokens, our own\n * product and comment are dropped from it, and the field is rebuilt from\n * `TENJIN_PRODUCT`, so re-composing an already-composed field (a retry, a nested\n * helper, an agent re-exporting the env it received) yields the same string\n * rather than a second `tenjin-cli` token. Caller products survive byte for byte.\n *\n * Rejection is total, never partial: a non-printable, non-product, or overlong\n * handoff is OMITTED and the Tenjin identity travels alone, because truncating a\n * product token would mint a different, false identity.\n */\nexport function composeUserAgent(input: ComposeUserAgentInput = {}): string {\n const product = input.product ?? TENJIN_PRODUCT;\n const alone = `${product} ${TENJIN_COMMENT}`;\n const raw = input.caller ?? (input.env ?? process.env)[CALLER_USER_AGENT_ENV];\n const products = callerProducts(raw);\n if (products.length === 0) return alone;\n const composed = `${product} ${products.join(' ')} ${TENJIN_COMMENT}`;\n return composed.length <= USER_AGENT_MAX_LENGTH ? composed : alone;\n}\n\n/** The caller's products, or none at all when any part of the handoff is unusable. */\nfunction callerProducts(raw: string | undefined): string[] {\n if (raw === undefined || !PRINTABLE_ASCII_RE.test(raw)) return [];\n // Printable ASCII leaves the space as the only whitespace, so it is the only\n // separator a product sequence can have.\n const tokens = raw.split(' ').filter((token) => token.length > 0 && !isOwnIdentity(token));\n return tokens.every((token) => PRODUCT_RE.test(token)) ? tokens : [];\n}\n\n/**\n * Our own identity inside a caller value, matched case-insensitively: a product\n * token is case-sensitive to the server, but a copy of ours in any casing is\n * still a duplicate identity, and dropping it is what makes composition total.\n */\nfunction isOwnIdentity(token: string): boolean {\n const lower = token.toLowerCase();\n // Both sides are lowered: comparing a lowered token against a constant that is\n // merely all-lowercase TODAY would break silently the day either gains a\n // capital, and it fails safe (the stale copy stops matching, then fails\n // PRODUCT_RE, and the whole handoff drops), so nothing would notice.\n if (lower === TENJIN_COMMENT.toLowerCase()) return true;\n return OWN_PRODUCT_NAMES.some((name) => {\n const own = name.toLowerCase();\n return lower === own || lower.startsWith(`${own}/`);\n });\n}\n","import { CliError } from './errors';\nimport { composeUserAgent } from './client-meta';\n\n/**\n * The single JSON client the whole CLI grows on: `doctor` uses it in B1, `search`\n * reuses it in B2. It never throws on a transport/protocol failure — it returns a\n * discriminated result so callers decide how each failure class maps to a check\n * or an error. `fetchImpl` is injectable so tests never touch the network.\n */\nexport interface FetchJsonOptions {\n /** Abort the request after this many milliseconds. */\n timeoutMs: number;\n /** Override global fetch (tests inject a stub returning canned Responses). */\n fetchImpl?: typeof fetch;\n /** Optional request headers, merged onto the User-Agent this module always sends. */\n headers?: Record<string, string>;\n /** The team shelf's bypass secret and its origin; see {@link ShelfBypass}. */\n bypass?: ShelfBypass;\n /**\n * INTERNAL. A caller's own product sequence, composed BEHIND the CLI's\n * identity (see `composeUserAgent`). The package ships a `bin` and no\n * `exports` map, so this is not a supported seam for code outside this repo:\n * the documented handoff is the `TENJIN_CALLER_USER_AGENT` environment\n * variable, which is what a subprocess launcher sets and what this falls back\n * to. Kept as an option so an in-repo caller can pass a value the environment\n * does not carry.\n */\n callerUserAgent?: string;\n}\n\n/**\n * The team shelf's Vercel \"Protection Bypass for Automation\" header.\n *\n * A door key for a protected preview deployment, not a credential of anyone's:\n * it gets a request past Deployment Protection and authenticates nobody. It is\n * NOT in {@link CREDENTIAL_HEADERS}, whose members are wallet-signed material a\n * redirect target could REPLAY — this one cannot be replayed into a signature.\n * It is still a secret, and DISCLOSING it is the whole harm: whoever holds it\n * walks into the team shelf. So it pins redirects exactly as a signed header\n * does (see {@link carriesBypassKey}), and where it may go is decided here and\n * nowhere else.\n */\nexport const SHELF_BYPASS_HEADER = 'x-vercel-protection-bypass';\n\n/**\n * A bypass secret and the origin it belongs to.\n *\n * THE ORIGIN IS PART OF THE VALUE, and that is the whole design. The CLI talks\n * to two shelves in team mode — the team's own deployment and the public\n * marketplace — and a caller that decides \"this request is to the team shelf, so\n * attach the key\" is a caller that eventually gets it wrong once. So callers\n * pass the pair and this transport does the compare: the header is attached from\n * the REQUEST URL, so a request to any other host cannot carry it, whatever the\n * call site believed.\n */\nexport interface ShelfBypass {\n /** `URL.origin` of the shelf the secret opens (the configured `baseUrl`). */\n origin: string;\n secret: string;\n}\n\n/** The bypass header for `url`, or nothing. Exported for the hook-script mirror\n * test, which runs the generated copy of this rule against this one. */\nexport function shelfBypassHeaders(\n url: string,\n bypass: ShelfBypass | undefined,\n): Record<string, string> {\n if (bypass === undefined || bypass.secret.length === 0) return {};\n let origin: string;\n try {\n origin = new URL(url).origin;\n } catch {\n return {};\n }\n if (origin !== bypass.origin) return {};\n return { [SHELF_BYPASS_HEADER]: bypass.secret };\n}\n\n/**\n * Whether the request being assembled actually carries the door key.\n *\n * A request that carries it MUST NOT follow a redirect. `fetch`'s default\n * `redirect: 'follow'` re-sends request headers verbatim to the new host (Node\n * strips only `Authorization`), so a single 3xx anywhere on the shelf origin —\n * the Vercel Authentication interstitial a rotated bypass secret gets, a domain\n * alias, a CDN rule — would hand the team shelf's key to whatever `Location`\n * names. Nothing else is needed to walk in afterwards, so the key never leaves\n * the origin it was paired with, not even one hop.\n *\n * Read off the BUILT headers rather than off `opts.bypass`, for the same reason\n * {@link CREDENTIAL_HEADERS} is matched by name: attaching the secret is what\n * arms the protection, so an off-origin request (which gets no header) keeps\n * ordinary transport and a call site cannot forget to ask for the pin.\n */\nfunction carriesBypassKey(headers: Record<string, string>): boolean {\n return Object.keys(headers).some((name) => name.toLowerCase() === SHELF_BYPASS_HEADER);\n}\n\n/** The anonymous install id: a random UUID minted once per data dir. */\nexport const INSTALL_ID_HEADER = 'tenjin-install-id';\n\n/**\n * Who is using the router, for Tenjin's own request telemetry: an anonymous\n * install id, random and tied to nothing but the data dir.\n *\n * Same shape as {@link ShelfBypass}, for the same reason: the transport decides\n * where it goes, from the REQUEST URL, so a call site cannot send it to a\n * provider by believing it is talking to Tenjin. `pay` runs over this transport\n * to third-party sellers, and none of them gets the header.\n *\n * Process-wide rather than a per-call option because it is not a per-call\n * decision: every request to Tenjin carries it, and threading it through forty\n * call sites is forty chances to forget one. Set only by the two process entries\n * (the CLI's `index.ts` and the daemon), so an in-process test that never sets\n * it sends exactly what it always did.\n *\n * Redirects are left to the request's usual transport: an unpinned request\n * follows them as `fetch` does, headers and all. Tenjin's origins redirect only\n * to Tenjin's own hosts, and the id is not a credential, so it is not worth the\n * redirect pin the bypass key and signed headers get.\n */\nexport interface TenjinIdentity {\n /** The origins that are Tenjin's own for this process. */\n origins: () => Promise<readonly string[]>;\n /** The install id; absent when it could not be read or created. */\n installId: () => Promise<string | undefined>;\n}\n\nlet tenjinIdentity: TenjinIdentity | undefined;\n\nexport function setTenjinIdentity(identity: TenjinIdentity | undefined): void {\n tenjinIdentity = identity;\n}\n\n/**\n * The telemetry headers for `url`, or nothing. NEVER THROWS: a data dir that\n * cannot be read costs the request its telemetry and nothing else.\n */\nexport async function tenjinIdentityHeaders(url: string): Promise<Record<string, string>> {\n const identity = tenjinIdentity;\n if (identity === undefined) return {};\n try {\n if (!(await identity.origins()).includes(new URL(url).origin)) return {};\n const id = await identity.installId();\n return id !== undefined ? { [INSTALL_ID_HEADER]: id } : {};\n } catch {\n return {};\n }\n}\n\n/**\n * The one place the identity is written for anything that can import it; both\n * transports funnel their Headers through it, so a third entry point on this\n * side cannot ship without it. `.set` on a Headers\n * object is what makes this total: a caller header spelled `User-Agent` in any\n * case lands in the same slot and is overwritten, never duplicated, so a\n * call-specific header cannot erase the composed field or add a second one.\n */\nfunction applyUserAgent(headers: Headers, callerUserAgent?: string): Headers {\n headers.set('user-agent', composeUserAgent({ caller: callerUserAgent }));\n return headers;\n}\n\n/** The same write for `fetchJson`'s plain-object headers; Headers.entries() is lowercase-keyed. */\nfunction withUserAgent(\n callerHeaders?: Record<string, string>,\n callerUserAgent?: string,\n): Record<string, string> {\n return Object.fromEntries(\n applyUserAgent(new Headers(callerHeaders ?? {}), callerUserAgent).entries(),\n );\n}\n\n/** A successful 2xx whose body parsed as JSON. */\nexport interface FetchJsonSuccess {\n ok: true;\n status: number;\n json: unknown;\n /** The server's `x-request-id`, when it sent one — useful in error reports. */\n requestId?: string;\n}\n\n/**\n * A failed request, tagged by class so the caller maps it deliberately:\n * `network`/`timeout` (never reached the server or no answer), `http` (a non-2xx\n * status), `invalid-json` (2xx but the body was not JSON).\n */\nexport interface FetchJsonFailure {\n ok: false;\n kind: 'network' | 'timeout' | 'http' | 'invalid-json' | 'blocked-redirect' | 'oversized-header';\n status?: number;\n requestId?: string;\n message: string;\n /**\n * On `invalid-json`, and on `http` when the status is 401/403: the response\n * looks like an access-protection or sign-in page rather than an API answer.\n * See {@link accessGateSignals} for what \"looks like\" means. Callers use it to\n * point at the missing credential instead of at the base URL, which is the one\n * setting that was already correct (#218).\n */\n gateSuspected?: boolean;\n /**\n * Present (true) only where the response left the host that was asked for:\n * `gateSuspected`'s STRONGER signal (the final URL's host differs), or, on\n * `blocked-redirect`, a `Location` that resolves to another host. An HTML\n * content-type alone proves a page came back, not who sent it, and a 3xx\n * alone proves only that the URL moved; leaving the host is what lets a\n * caller name access protection outright.\n */\n gateOffOrigin?: boolean;\n /**\n * On `network`: the layer the error chain names, when it names one. The\n * origin never answered, so a caller that blames it (or its base URL) gives\n * the wrong fix. See {@link transportFailure}.\n */\n transport?: TransportFailure;\n /**\n * On a `timeout` that came after the response headers did (`httpRequest`\n * only): a case-insensitive lookup over them. A seller can name where a long\n * job's result will be with its first byte, and only the body ran out of time.\n */\n header?: (name: string) => string | undefined;\n}\n\n/** Which layer refused a request that never reached the origin. */\nexport interface TransportFailure {\n layer: 'proxy' | 'dns' | 'tls' | 'connect';\n /** The socket's own error code, for every layer but `proxy`. */\n code?: string;\n /** What the proxy answered to `CONNECT`, for `proxy` only. */\n proxyStatus?: number;\n}\n\n/**\n * Does this response read as a protection page rather than as an API answer?\n *\n * Two independent signals, reported separately because they prove different\n * amounts (the caller's wording must not outrun the evidence):\n *\n * - an HTML content-type, because a Vercel Deployment Protection interstitial\n * and every sign-in wall answer with a page;\n * - a final URL whose host is not the one asked for, because a gate that\n * redirects to sign in lands the probe on another host and `fetch` follows it\n * silently on the unpinned requests this function serves.\n *\n * Decided HERE because this transport is the only place holding the `Response`;\n * a caller re-deriving it from the failure message would be guessing. An\n * unreadable final URL is NOT suspicion: `res.url` is empty on a synthesized\n * Response, so only a host that reads AND differs counts.\n */\nfunction accessGateSignals(\n requestedUrl: string,\n res: Response,\n): { gateSuspected: boolean; gateOffOrigin?: true } {\n const html = /^\\s*text\\/html\\b/i.test(res.headers.get('content-type') ?? '');\n let offOrigin = false;\n if (res.url.length > 0) {\n try {\n offOrigin = new URL(requestedUrl).host !== new URL(res.url).host;\n } catch {\n offOrigin = false;\n }\n }\n return {\n gateSuspected: html || offOrigin,\n ...(offOrigin ? { gateOffOrigin: true as const } : {}),\n };\n}\n\n/**\n * Does an unfollowed 3xx point off the host that was asked for?\n *\n * The pinned branch never follows, so `res.url` is still the requested URL and\n * `Location` is the only evidence about where the hop went. That distinction\n * carries the whole verdict downstream: a gate's sign-in interstitial lands on\n * another host, while an `http://` base URL that 301s to https, or a host\n * normalising to its canonical name, does not, and reading either as a refused\n * credential blames the wrong setting. A relative target resolves against the\n * request, so it is same-host by construction; a missing or unparseable one is\n * NOT an off-host claim.\n */\nfunction redirectLeavesHost(requestedUrl: string, location: string | null): boolean {\n if (location === null || location.length === 0) return false;\n try {\n return new URL(requestedUrl).host !== new URL(location, requestedUrl).host;\n } catch {\n return false;\n }\n}\n\n/**\n * Header names that carry wallet-signed material.\n *\n * A request bearing any of these must NEVER follow a redirect. `resource-ref`\n * pins the invariant — \"nothing signed may leave for a host the user did not\n * configure\" — but `assertOnBaseOrigin` only checks the URL the caller asked\n * for, and `fetch`'s default `redirect: 'follow'` re-sends request headers\n * verbatim to the new host (Node strips only `Authorization`). A 3xx anywhere on\n * the configured origin would therefore hand a signature BOUND TO THE REAL\n * DOMAIN to whoever `Location` points at, replayable against it for the\n * signature's lifetime.\n *\n * Detected by header NAME rather than by a caller-supplied \"this is signed\" flag\n * so the protection cannot be forgotten at a call site: attaching the credential\n * is what arms it. Matched case-insensitively. Kept as literals so the base\n * transport keeps its single dependency; `http.test.ts` pins them against the\n * real constants in `lib/siwx` and the x402 payment headers.\n *\n * All three wallet-signed families this CLI sends are here: the SIWX auth\n * header, the x402 payment header (`payment-signature` for x402 v2, plus\n * `x-payment`, the v1 spelling `@x402/core` can emit, as drift insurance even\n * though `read-client` pins v2), and `tenjin-session-delegation` — a REUSABLE\n * session-lifetime SIWX signature `session-key` attaches to every session-signed\n * write, which makes it the most replayable credential of the set. The RFC 9421\n * `Signature`/`Signature-Input` pair riding alongside it is deliberately absent:\n * it covers method, URL, and body digest, so it is not usefully replayable at\n * another host.\n */\nconst CREDENTIAL_HEADERS = new Set([\n 'sign-in-with-x',\n 'payment-signature',\n 'x-payment',\n 'tenjin-session-delegation',\n]);\n\nfunction carriesSignedMaterial(headers: Record<string, string>): boolean {\n return Object.keys(headers).some((name) => CREDENTIAL_HEADERS.has(name.toLowerCase()));\n}\n\n/**\n * A request header name this client sets itself and an operator may not: the\n * wallet-signed material above, the shelf bypass secret, this install's\n * identity, and the x402 payment namespace. Kept beside the set so the two\n * cannot drift.\n */\nexport function isReservedRequestHeader(name: string): boolean {\n const lowered = name.toLowerCase();\n return (\n CREDENTIAL_HEADERS.has(lowered) ||\n lowered === SHELF_BYPASS_HEADER ||\n lowered === INSTALL_ID_HEADER ||\n lowered.startsWith('payment-') ||\n lowered.startsWith('x-payment')\n );\n}\n\n/** One header name, as RFC 9110 spells a token. */\nconst HEADER_NAME = /^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/;\n/** Names the transport or the body encoding own. */\nconst TRANSPORT_HEADERS = new Set(['host', 'content-length', 'content-type', 'user-agent']);\n\n/**\n * Why a request header someone else names (an operator's `-H`, a catalog\n * spec) cannot ride a paid request, or null when it can: `name` for a name\n * that is not a token or a value that is empty, `reserved` for a name this\n * client signs or sets itself or the transport owns, `value` for a value over\n * 1,024 characters or one that spans lines. `ownContentType` lets the caller\n * name `content-type`, for a body this client does not encode.\n */\nexport function requestHeaderProblem(\n name: string,\n value: string,\n ownContentType = false,\n): 'name' | 'reserved' | 'value' | null {\n if (!HEADER_NAME.test(name) || value.length === 0) return 'name';\n const lowered = name.toLowerCase();\n const contentType = ownContentType && lowered === 'content-type';\n if (isReservedRequestHeader(lowered) || (TRANSPORT_HEADERS.has(lowered) && !contentType)) {\n return 'reserved';\n }\n if (value.length > 1_024 || /[\\r\\n]/.test(value)) return 'value';\n return null;\n}\n\nexport type FetchJsonResult = FetchJsonSuccess | FetchJsonFailure;\n\nexport async function fetchJson(url: string, opts: FetchJsonOptions): Promise<FetchJsonResult> {\n const doFetch = opts.fetchImpl ?? fetch;\n const controller = new AbortController();\n let timedOut = false;\n // The timer stays armed until the body is fully consumed (cleared in the outer\n // finally), so a server that sends headers then stalls the body still trips the\n // deadline instead of hanging forever on res.json().\n const timer = setTimeout(() => {\n timedOut = true;\n controller.abort();\n }, opts.timeoutMs);\n\n try {\n let res: Response;\n // `new Headers` throws on a malformed caller header, so building them stays\n // inside the catch that turns any pre-flight refusal into the same\n // discriminated network failure a dead socket gets.\n let pinned = false;\n try {\n const headers = withUserAgent(\n { ...opts.headers, ...shelfBypassHeaders(url, opts.bypass) },\n opts.callerUserAgent,\n );\n // fetchJson sends no signed material — doctor's probes and the contract\n // checks are anonymous — so the door key is the one thing here worth\n // pinning, and it pins the same way it does in httpRequest.\n pinned = carriesBypassKey(headers);\n res = await doFetch(url, {\n signal: controller.signal,\n headers: { ...headers, ...(await tenjinIdentityHeaders(url)) },\n ...(pinned ? { redirect: 'manual' as const } : {}),\n });\n } catch (err) {\n // A timeout is a network failure the AbortController induced; distinguish it\n // from an organic one so the caller can say \"timed out\" rather than a raw\n // AbortError message.\n return timedOut\n ? timeoutFailure(url, opts.timeoutMs)\n : { ok: false, kind: 'network', message: `Request to ${url} failed: ${errorMessage(err)}` };\n }\n\n const requestId = res.headers.get('x-request-id') ?? undefined;\n\n // Fail CLOSED, ahead of the ordinary non-2xx branch, so an unfollowed 3xx is\n // never reported as a plain HTTP status a caller might retry by hand.\n if (pinned && res.status >= 300 && res.status < 400) {\n return {\n ok: false,\n kind: 'blocked-redirect',\n status: res.status,\n ...(requestId !== undefined ? { requestId } : {}),\n // Where it pointed, not that it pointed: only a hop that leaves the host\n // asked for is evidence about the key. Same-host 3xx happens to a base\n // URL that needs fixing, with a perfectly good key.\n ...(redirectLeavesHost(url, res.headers.get('location'))\n ? { gateOffOrigin: true as const }\n : {}),\n message:\n `Request to ${url} was redirected (${res.status}) while carrying the team shelf's ` +\n 'bypass key; refusing to follow it, because the key opens only the configured origin.',\n };\n }\n\n if (!res.ok) {\n return {\n ok: false,\n kind: 'http',\n status: res.status,\n ...(requestId !== undefined ? { requestId } : {}),\n // 401/403 is one of the three shapes deployment protection answers with\n // (200 HTML and a 30x interstitial are the others), so the gate signals\n // ride here too. Other statuses stay unmarked: a 404 or 500 HTML page is\n // an ordinary broken deployment, not a credential problem.\n ...(res.status === 401 || res.status === 403 ? accessGateSignals(url, res) : {}),\n message: `Request to ${url} failed with status ${res.status}`,\n };\n }\n\n let json: unknown;\n try {\n json = await res.json();\n } catch (err) {\n // The body read can fail three ways. A timeout wins first: the abort fires\n // synchronously with `timedOut`, so any abort-induced rejection here is our\n // deadline. Otherwise a SyntaxError is a genuine parse failure (invalid\n // JSON); anything else is a transport failure mid-body (network).\n if (timedOut) return timeoutFailure(url, opts.timeoutMs);\n if (err instanceof SyntaxError) {\n return {\n ok: false,\n kind: 'invalid-json',\n status: res.status,\n ...(requestId !== undefined ? { requestId } : {}),\n ...accessGateSignals(url, res),\n message: `Response from ${url} was not valid JSON`,\n };\n }\n return {\n ok: false,\n kind: 'network',\n status: res.status,\n ...(requestId !== undefined ? { requestId } : {}),\n message: `Request to ${url} failed while reading the response body: ${errorMessage(err)}`,\n };\n }\n\n return {\n ok: true,\n status: res.status,\n json,\n ...(requestId !== undefined ? { requestId } : {}),\n };\n } finally {\n clearTimeout(timer);\n }\n}\n\nfunction timeoutFailure(url: string, timeoutMs: number): FetchJsonFailure {\n return {\n ok: false,\n kind: 'timeout',\n message: `Request to ${url} timed out after ${timeoutMs}ms`,\n };\n}\n\n/**\n * A full HTTP round trip that surfaces the STATUS, headers, and best-effort JSON\n * body for ANY status. Unlike fetchJson (2xx-only), the B2 read/pay flow needs\n * the body on a 402 (the leak-safe preview) and a 409 (the owned-re-pay gate),\n * and search/outcome need a 4xx validation envelope. A transport/timeout failure\n * still returns the discriminated FetchJsonFailure so callers map it uniformly.\n */\nexport interface HttpRequestOptions {\n method?: 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';\n timeoutMs: number;\n headers?: Record<string, string>;\n /** The team shelf's bypass secret and its origin; see {@link ShelfBypass}. */\n bypass?: ShelfBypass;\n /** INTERNAL; see `FetchJsonOptions.callerUserAgent`. */\n callerUserAgent?: string;\n /** A JSON body (POST); serialized with a content-type header set automatically. */\n jsonBody?: unknown;\n /**\n * A body the CALLER already encoded, sent byte for byte with no content-type\n * of this transport's choosing: the router's provider leg is handed a request\n * the server built, and re-encoding it would make the bytes signed for and\n * the bytes sent two different things. The caller's own `headers` carry the\n * content type. Ignored when `jsonBody` is set.\n */\n rawBody?: string;\n fetchImpl?: typeof fetch;\n /**\n * A caller's own abort, combined with (never replacing) `timeoutMs`. The loop's\n * legs pass the fire's signal here so a harness that closed its socket stops the\n * request in flight; a caller with no such signal is unchanged.\n */\n signal?: AbortSignal;\n /**\n * Refuse redirects even when the request carries no signed header. For a\n * caller whose response becomes a durable local artifact (`fetchRead`: the\n * 200 is written to the library as an entitlement record under the\n * server-chosen id/slug), following a cross-origin redirect would let\n * another host's bytes be recorded as if the configured origin served them.\n * Off by default so search/outcome/publish/doctor keep normal transport.\n */\n blockRedirects?: boolean;\n /**\n * Keep a binary body as bytes. A sound, an image or any other non-text\n * payload decoded as text is corrupted, so with this set a response whose\n * content type is not text ({@link isBinaryContentType}) comes back with\n * `bytes` and an empty `text`. The router's provider leg sets it; every other\n * caller reads text as before.\n */\n binaryBody?: boolean;\n /** The cap on such a body; over it the response is a failure, never a\n * buffer that grows without bound. Defaults to {@link MAX_BINARY_BODY_BYTES}. */\n maxBinaryBytes?: number;\n /**\n * Send no install id, and mint none. For a request that checks the network\n * rather than uses Tenjin (the reachability probe), so it never counts as an\n * install in request telemetry.\n */\n anonymous?: boolean;\n}\n\n/** The same cap the router's linked-media download uses. */\nexport const MAX_BINARY_BODY_BYTES = 200 * 1024 * 1024;\n\n/**\n * The body's bytes, read chunk by chunk and abandoned the moment they pass\n * `max`; null over the cap. A declared length over it is refused unread.\n */\nasync function readCapped(res: Response, max: number): Promise<Uint8Array | null> {\n const declared = Number(res.headers.get('content-length') ?? '0');\n if (Number.isFinite(declared) && declared > max) {\n await res.body?.cancel().catch(() => undefined);\n return null;\n }\n if (res.body === null) return new Uint8Array();\n const reader = res.body.getReader();\n const chunks: Uint8Array[] = [];\n let size = 0;\n for (;;) {\n const { done, value } = await reader.read();\n if (done) break;\n size += value.byteLength;\n if (size > max) {\n await reader.cancel().catch(() => undefined);\n return null;\n }\n chunks.push(value);\n }\n return new Uint8Array(Buffer.concat(chunks));\n}\n\n/**\n * A content type whose body is not text: anything that is not `text/*` and\n * not a JSON, XML, JavaScript, YAML or form type. An absent header is text, as\n * it always was here.\n */\nexport function isBinaryContentType(contentType: string | undefined): boolean {\n const type = (contentType ?? '').split(';')[0]!.trim().toLowerCase();\n if (type.length === 0) return false;\n if (type.startsWith('text/')) return false;\n return !/(?:json|xml|javascript|ecmascript|yaml|x-www-form-urlencoded)/.test(type);\n}\n\nexport interface HttpResponse {\n ok: true;\n status: number;\n /** Case-insensitive header lookup over the response. */\n header(name: string): string | undefined;\n /** Parsed JSON body, or undefined when the body was empty or not JSON. */\n json: unknown;\n /** The raw body text; what a non-JSON endpoint actually said (`pay` delivers it). */\n text: string;\n /** The body's bytes, only for a binary body read with `binaryBody`; `text`\n * is then empty. */\n bytes?: Uint8Array;\n requestId?: string;\n}\n\nexport type HttpResult = HttpResponse | FetchJsonFailure;\n\n/** The wire form of one request: what to send, and whether it may follow a redirect. */\ninterface PreparedRequest {\n ok: true;\n headers: Record<string, string>;\n body: string | undefined;\n signed: boolean;\n bypassed: boolean;\n pinned: boolean;\n}\n\n/**\n * Assemble the request and DERIVE its redirect decision from the headers that\n * were actually built, in one place and one pass. The redirect flags are\n * returned rather than assigned, so they have no value until the headers do:\n * there is no state in which `pinned` is readable but not yet computed, which\n * is what would let a signed request follow a 3xx to another host. Anything\n * that refuses here (`new Headers` throws on a malformed caller header) becomes\n * the same discriminated failure a dead socket does, because this transport\n * documents a returned failure for every refusal, not an exception.\n */\nfunction prepareRequest(url: string, opts: HttpRequestOptions): PreparedRequest | FetchJsonFailure {\n try {\n let body: string | undefined;\n // The bypass rides in with the caller's headers rather than being set after\n // them, so a caller cannot spell it a second way and win the slot.\n const merged = new Headers({ ...opts.headers, ...shelfBypassHeaders(url, opts.bypass) });\n if (opts.jsonBody !== undefined) {\n body = JSON.stringify(opts.jsonBody);\n merged.set('content-type', 'application/json');\n } else if (opts.rawBody !== undefined) {\n body = opts.rawBody;\n }\n const wantsAccept =\n opts.method === 'POST' ||\n opts.method === 'PUT' ||\n opts.method === 'PATCH' ||\n body !== undefined;\n if (wantsAccept && !merged.has('accept')) merged.set('accept', 'application/json');\n // An `accept`/`content-type` set here wins the slot regardless of how a\n // caller cased its own copy.\n const headers = Object.fromEntries(applyUserAgent(merged, opts.callerUserAgent).entries());\n\n // Signed requests opt out of redirect following entirely; see CREDENTIAL_HEADERS.\n // So does a request carrying the team shelf's bypass key: it cannot be\n // replayed, but a 3xx would DISCLOSE it, and that is the whole harm (see\n // carriesBypassKey). A caller can also pin an unsigned, keyless request\n // (blockRedirects) when the response it gets back becomes a durable local record.\n const signed = carriesSignedMaterial(headers);\n const bypassed = carriesBypassKey(headers);\n return {\n ok: true,\n headers,\n body,\n signed,\n bypassed,\n pinned: signed || bypassed || opts.blockRedirects === true,\n };\n } catch (err) {\n return {\n ok: false,\n kind: 'network',\n message: `Request to ${url} failed: ${errorMessage(err)}`,\n };\n }\n}\n\nexport async function httpRequest(url: string, opts: HttpRequestOptions): Promise<HttpResult> {\n const doFetch = opts.fetchImpl ?? fetch;\n const controller = new AbortController();\n let timedOut = false;\n const timer = setTimeout(() => {\n timedOut = true;\n controller.abort();\n }, opts.timeoutMs);\n // The caller's abort is combined with the timeout rather than chosen between:\n // whichever fires first ends the request, and `timedOut` still says which.\n const signal =\n opts.signal === undefined\n ? controller.signal\n : AbortSignal.any([controller.signal, opts.signal]);\n\n try {\n const prepared = prepareRequest(url, opts);\n if (!prepared.ok) return prepared;\n const { headers, body, signed, bypassed, pinned } = prepared;\n\n let res: Response;\n try {\n res = await doFetch(url, {\n method: opts.method ?? 'GET',\n headers:\n opts.anonymous === true ? headers : { ...headers, ...(await tenjinIdentityHeaders(url)) },\n body,\n signal,\n ...(pinned ? { redirect: 'manual' as const } : {}),\n });\n } catch (err) {\n if (timedOut) return timeoutFailure(url, opts.timeoutMs);\n if (isHeaderOverflow(err)) return oversizedHeaderFailure(url);\n const transport = transportFailure(err);\n return {\n ok: false,\n kind: 'network',\n message: `Request to ${url} failed: ${errorMessage(err)}`,\n ...(transport !== undefined ? { transport } : {}),\n };\n }\n\n const requestId = res.headers.get('x-request-id') ?? undefined;\n\n // Fail CLOSED on a redirect the request was not allowed to follow. This\n // returns a failure rather than the 3xx response so no caller can mistake an\n // unfollowed redirect for a normal status and retry it by hand.\n if (pinned && res.status >= 300 && res.status < 400) {\n return {\n ok: false,\n kind: 'blocked-redirect',\n status: res.status,\n ...(requestId !== undefined ? { requestId } : {}),\n message: signed\n ? `Request to ${url} was redirected (${res.status}) while carrying a signed header; ` +\n 'refusing to follow it, because the signature is bound to the configured origin.'\n : bypassed\n ? `Request to ${url} was redirected (${res.status}) while carrying the team shelf's ` +\n 'bypass key; refusing to follow it, because the key opens only the configured origin.'\n : `Request to ${url} was redirected (${res.status}); ` +\n 'refusing to follow it, because the response must come from the configured origin.',\n };\n }\n // Read the raw text once; parse best-effort. A non-JSON body (empty 202, an\n // HTML error page) yields `undefined` rather than a thrown parse, because a\n // 402/409 caller keys off the STATUS and only some statuses carry JSON.\n let text: string;\n let bytes: Uint8Array | undefined;\n try {\n if (opts.binaryBody === true && isBinaryContentType(res.headers.get('content-type') ?? '')) {\n const read = await readCapped(res, opts.maxBinaryBytes ?? MAX_BINARY_BODY_BYTES);\n if (read === null) {\n return {\n ok: false,\n kind: 'network',\n status: res.status,\n ...(requestId !== undefined ? { requestId } : {}),\n message: `Request to ${url} returned a file over the ${Math.round((opts.maxBinaryBytes ?? MAX_BINARY_BODY_BYTES) / 1_048_576)} MB cap; it was not kept.`,\n };\n }\n bytes = read;\n text = '';\n } else {\n text = await res.text();\n }\n } catch (err) {\n if (timedOut) {\n return {\n ...timeoutFailure(url, opts.timeoutMs),\n header: (name) => res.headers.get(name) ?? undefined,\n };\n }\n return {\n ok: false,\n kind: 'network',\n status: res.status,\n ...(requestId !== undefined ? { requestId } : {}),\n message: `Request to ${url} failed while reading the response body: ${errorMessage(err)}`,\n };\n }\n let json: unknown;\n if (text.length > 0) {\n try {\n json = JSON.parse(text);\n } catch {\n json = undefined;\n }\n }\n return {\n ok: true,\n status: res.status,\n header: (name) => res.headers.get(name) ?? undefined,\n json,\n text,\n ...(bytes !== undefined ? { bytes } : {}),\n ...(requestId !== undefined ? { requestId } : {}),\n };\n } finally {\n clearTimeout(timer);\n }\n}\n\nexport interface FailureToCliErrorOptions {\n fix?: string;\n details?: unknown;\n}\n\n/**\n * Normalize a fetch failure into the CLI error contract: network/timeout are a\n * NETWORK_ERROR, an `http` status (server reachable but errored — commonly 5xx)\n * is API_UNREACHABLE, and a 2xx that failed to parse when JSON was required is a\n * CONTRACT_MISMATCH. Callers that need a check-specific code (doctor) build their\n * own CliError; this is the default B2's passthrough leans on.\n */\nexport function fetchFailureToCliError(\n failure: FetchJsonFailure,\n opts: FailureToCliErrorOptions = {},\n): CliError {\n const code =\n failure.kind === 'network' || failure.kind === 'timeout'\n ? 'NETWORK_ERROR'\n : failure.kind === 'invalid-json'\n ? 'CONTRACT_MISMATCH'\n : failure.kind === 'oversized-header'\n ? 'CHALLENGE_TOO_LARGE'\n : 'API_UNREACHABLE';\n // The one failure with a remedy nobody can apply from inside the process, so\n // it names the operator's knob rather than suggesting a retry.\n // The knob, with no claim about payment: a caller that knows its leg passes\n // its own `fix` and says what happened to the money there.\n const fix =\n opts.fix ??\n (failure.kind === 'oversized-header'\n ? 'Raising `--max-http-header-size` on the node process that runs this CLI would let the header be read; that is an operator decision, not a default this build changes.'\n : undefined);\n return new CliError(code, failure.message, {\n ...(fix !== undefined ? { fix } : {}),\n ...(opts.details !== undefined ? { details: opts.details } : {}),\n });\n}\n\nfunction errorMessage(err: unknown): string {\n return err instanceof Error ? err.message : String(err);\n}\n\n/**\n * Does this transport failure mean the response HEADERS were too big for this\n * process to read?\n *\n * Node caps them at 16 KiB unless `--max-http-header-size` says otherwise, and\n * an x402 challenge is a header: a seller that embeds its whole output schema\n * in one can exceed the cap on its own (AnyAPI's is 52 KB, measured\n * 2026-09-22). undici then aborts the request and the generic path reported\n * `fetch failed` with no status and nothing naming the cause, which reads as\n * \"the endpoint is down\" for a seller that is answering perfectly.\n *\n * The message is undici's, matched on its stable text and on the code it\n * attaches; the CAUSE is the one that carries either, so both are checked.\n */\nfunction isHeaderOverflow(err: unknown): boolean {\n const seen = [err, (err as { cause?: unknown } | null)?.cause];\n return seen.some((candidate) => {\n if (candidate === null || typeof candidate !== 'object') return false;\n const code = (candidate as { code?: unknown }).code;\n if (code === 'UND_ERR_HEADERS_OVERFLOW' || code === 'HPE_HEADER_OVERFLOW') return true;\n const message = (candidate as { message?: unknown }).message;\n return typeof message === 'string' && /headers overflow|header overflow/i.test(message);\n });\n}\n\nconst DNS_CODES = new Set(['ENOTFOUND', 'EAI_AGAIN', 'EAI_FAIL', 'EAI_NODATA', 'EAI_NONAME']);\nconst CONNECT_CODES = new Set([\n 'ECONNREFUSED',\n 'ECONNRESET',\n 'EHOSTUNREACH',\n 'ENETUNREACH',\n 'ETIMEDOUT',\n 'UND_ERR_CONNECT_TIMEOUT',\n 'UND_ERR_SOCKET',\n]);\nconst TLS_CODE = /^(?:ERR_TLS_|ERR_SSL_|CERT_|UNABLE_TO_|SELF_SIGNED_|DEPTH_ZERO_)/;\n/** undici's text when a proxy answers `CONNECT` with anything but 200. */\nconst PROXY_REFUSAL = /Proxy response \\((\\d{3})\\)/;\n\n/**\n * The layer a `fetch failed` came from, read down the `cause` chain. fetch\n * wraps the real error twice: a proxy refusing the tunnel is\n * `TypeError: fetch failed`, then `Request was cancelled.`, then undici's\n * `UND_ERR_ABORTED` with the proxy's status in its message (Node 24.18,\n * measured 2026-10-05). Undefined when no link names a layer.\n */\nexport function transportFailure(err: unknown): TransportFailure | undefined {\n let link: unknown = err;\n for (let depth = 0; depth < 5 && link !== null && typeof link === 'object'; depth += 1) {\n const { code, message, cause } = link as { code?: unknown; message?: unknown; cause?: unknown };\n const proxy = typeof message === 'string' ? PROXY_REFUSAL.exec(message) : null;\n if (proxy !== null) return { layer: 'proxy', proxyStatus: Number(proxy[1]) };\n if (typeof code === 'string') {\n if (DNS_CODES.has(code)) return { layer: 'dns', code };\n if (TLS_CODE.test(code)) return { layer: 'tls', code };\n if (CONNECT_CODES.has(code)) return { layer: 'connect', code };\n }\n link = cause;\n }\n return undefined;\n}\n\n/**\n * The named refusal for that case. NOT a `network` failure: nothing is wrong\n * with the connection, and a caller that retries gets the same 52 KB again.\n *\n * SAYS NOTHING ABOUT PAYMENT. This transport serves the unpaid probe and the\n * paid retry alike and cannot tell them apart, so a message asserting either\n * way is wrong on one of them: it read as \"nothing was sent\" on a leg where a\n * signed authorization had already left. The leg adds that sentence, because\n * the leg is what knows; see `runPay`.\n */\nfunction oversizedHeaderFailure(url: string): FetchJsonFailure {\n let origin = url;\n try {\n origin = new URL(url).origin;\n } catch {\n // Keep the raw string; this is a diagnostic, not a destination.\n }\n return {\n ok: false,\n kind: 'oversized-header',\n message:\n `${origin} answered with a response header block larger than this process will read. ` +\n 'An x402 challenge travels in a header, and a seller that embeds its whole output ' +\n 'schema in one can exceed the limit, so the response could not be read.',\n };\n}\n"],"mappings":";;;;;;;;;;;;AASO,IAAM,iBAAiB,cAAc,gBAAI,OAAO;AAGhD,IAAM,sBAAsB;AAU5B,IAAM,8BAA8B;AACpC,IAAM,yBAAyB,GAAG,2BAA2B,IAAI,gBAAI,OAAO;AAI5E,IAAM,oBAAoB,CAAC,qBAAqB,2BAA2B;AAO3E,IAAM,iBAAiB,KAAK,iBAAiB;AAO7C,IAAM,oBAAoB,GAAG,cAAc,IAAI,cAAc;AAG7D,IAAM,4BAA4B,GAAG,sBAAsB,IAAI,cAAc;AAG7E,IAAM,wBAAwB;AAG9B,IAAM,wBAAwB;AAQ9B,IAAM,aAAa;AAGnB,IAAM,qB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SAAS,UAAU,SAAS,GAAG;AACtF,UAAM,EAAE,MAAM,SAAS,MAAM,IAAI;AACjC,UAAM,QAAQ,OAAO,YAAY,WAAW,cAAc,KAAK,OAAO,IAAI;AAC1E,QAAI,UAAU,KAAM,QAAO,EAAE,OAAO,SAAS,aAAa,OAAO,MAAM,CAAC,CAAC,EAAE;AAC3E,QAAI,OAAO,SAAS,UAAU;AAC5B,UAAI,UAAU,IAAI,IAAI,EAAG,QAAO,EAAE,OAAO,OAAO,KAAK;AACrD,UAAI,SAAS,KAAK,IAAI,EAAG,QAAO,EAAE,OAAO,OAAO,KAAK;AACrD,UAAI,cAAc,IAAI,IAAI,EAAG,QAAO,EAAE,OAAO,WAAW,KAAK;AAAA,IAC/D;AACA,WAAO;AAAA,EACT;AACA,SAAO;AACT;AAYA,SAAS,uBAAuB,KAA+B;AAC7D,MAAI,SAAS;AACb,MAAI;AACF,aAAS,IAAI,IAAI,GAAG,EAAE;AAAA,EACxB,QAAQ;AAAA,EAER;AACA,SAAO;AAAA,IACL,IAAI;AAAA,IACJ,MAAM;AAAA,IACN,SACE,GAAG,MAAM;AAAA,EAGb;AACF;","names":[]}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { createRequire as __tenjinCreateRequire } from 'node:module'; const require = __tenjinCreateRequire(import.meta.url);
|
|
2
|
+
import {
|
|
3
|
+
external_exports
|
|
4
|
+
} from "./chunk-SNNSAGMT.js";
|
|
5
|
+
import {
|
|
6
|
+
writeFileAtomic
|
|
7
|
+
} from "./chunk-7WEQQJLG.js";
|
|
8
|
+
import {
|
|
9
|
+
CliError
|
|
10
|
+
} from "./chunk-3UCIG4TG.js";
|
|
11
|
+
import {
|
|
12
|
+
passphraseRecordPath
|
|
13
|
+
} from "./chunk-OJNTCYQQ.js";
|
|
14
|
+
|
|
15
|
+
// src/lib/passphrase-record.ts
|
|
16
|
+
import { mkdir, readFile } from "node:fs/promises";
|
|
17
|
+
var PASSPHRASE_RECORD_SCHEMA_VERSION = 1;
|
|
18
|
+
var EntrySchema = external_exports.object({
|
|
19
|
+
store: external_exports.enum(["keychain", "secret-service", "dpapi", "file"]),
|
|
20
|
+
recordedAt: external_exports.string(),
|
|
21
|
+
by: external_exports.enum(["create", "repair", "replace"])
|
|
22
|
+
}).strict();
|
|
23
|
+
var RecordSchema = external_exports.object({
|
|
24
|
+
schemaVersion: external_exports.literal(PASSPHRASE_RECORD_SCHEMA_VERSION),
|
|
25
|
+
wallets: external_exports.record(external_exports.string(), external_exports.unknown())
|
|
26
|
+
}).strict();
|
|
27
|
+
var ADDRESS_RE = /^0x[0-9a-f]{40}$/;
|
|
28
|
+
async function readWallets(dir) {
|
|
29
|
+
try {
|
|
30
|
+
const parsed = RecordSchema.safeParse(
|
|
31
|
+
JSON.parse(await readFile(passphraseRecordPath(dir), "utf8"))
|
|
32
|
+
);
|
|
33
|
+
return parsed.success ? parsed.data.wallets : null;
|
|
34
|
+
} catch {
|
|
35
|
+
return null;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
async function readPassphraseRecord(dir, address) {
|
|
39
|
+
const key = address.toLowerCase();
|
|
40
|
+
if (!ADDRESS_RE.test(key)) return null;
|
|
41
|
+
const wallets = await readWallets(dir);
|
|
42
|
+
if (wallets === null) return null;
|
|
43
|
+
const raw = Object.entries(wallets).find(([k]) => k.toLowerCase() === key)?.[1];
|
|
44
|
+
const entry = EntrySchema.safeParse(raw);
|
|
45
|
+
return entry.success ? entry.data : null;
|
|
46
|
+
}
|
|
47
|
+
async function writePassphraseRecord(dir, address, entry, now = /* @__PURE__ */ new Date()) {
|
|
48
|
+
const key = address.toLowerCase();
|
|
49
|
+
if (!ADDRESS_RE.test(key)) {
|
|
50
|
+
throw new CliError("INTERNAL", `Not a wallet address: ${address}`);
|
|
51
|
+
}
|
|
52
|
+
const wallets = { ...await readWallets(dir) ?? {} };
|
|
53
|
+
for (const k of Object.keys(wallets)) if (k.toLowerCase() === key) delete wallets[k];
|
|
54
|
+
const record = {
|
|
55
|
+
store: entry.store,
|
|
56
|
+
recordedAt: now.toISOString(),
|
|
57
|
+
by: entry.by
|
|
58
|
+
};
|
|
59
|
+
wallets[key] = record;
|
|
60
|
+
await mkdir(dir, { recursive: true, mode: 448 });
|
|
61
|
+
await writeFileAtomic(
|
|
62
|
+
passphraseRecordPath(dir),
|
|
63
|
+
JSON.stringify({ schemaVersion: PASSPHRASE_RECORD_SCHEMA_VERSION, wallets }, null, 2) + "\n",
|
|
64
|
+
{ mode: 384, dirMode: 448 }
|
|
65
|
+
);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export {
|
|
69
|
+
readPassphraseRecord,
|
|
70
|
+
writePassphraseRecord
|
|
71
|
+
};
|
|
72
|
+
//# sourceMappingURL=chunk-3AIHRXKO.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/lib/passphrase-record.ts"],"sourcesContent":["import { mkdir, readFile } from 'node:fs/promises';\nimport { z } from 'zod';\nimport { writeFileAtomic } from './atomic-json';\nimport { CliError } from './errors';\nimport { passphraseRecordPath } from './paths';\nimport type { DurableStore } from './wallet-unlock';\n\n/**\n * WHERE EACH WALLET'S PASSPHRASE WAS SAVED, beside the wallet:\n * `<dataDir>/passphrase-store.json`, keyed by lowercase address.\n *\n * Why not a field in wallet.json: that file holds a funded key, and rewriting\n * it to record a storage choice risks the key for no gain. An older CLI also\n * reads wallet.json strictly, and must keep reading it after this one has\n * saved a passphrase somewhere new. So wallet.json is never touched, and the\n * choice lives here, where losing the file costs nothing: an absent,\n * unreadable, unparseable or newer-schema sidecar, or an unknown store value,\n * all read as \"no record\", which means today's lookup order.\n *\n * Hook-safe: `alive` and the hooks read it, so it imports only node, zod and\n * the lib modules the chunk graph allows. Reads never write (no lazy\n * migration): the router's read path stays free of side effects.\n *\n * Only `wallet create`, `wallet create --replace` and `wallet repair` write it,\n * and they hold `wallet.create.lock` while they do, so the read-modify-write\n * below never races another writer. An entry is never deleted in PR 1: a\n * restored archive (`mv wallet.<addr>.json.bak wallet.json`) finds its own\n * entry again by address.\n */\n\nexport const PASSPHRASE_RECORD_SCHEMA_VERSION = 1;\n\nexport interface PassphraseRecordEntry {\n store: DurableStore;\n recordedAt: string;\n by: 'create' | 'repair' | 'replace';\n}\n\nconst EntrySchema = z\n .object({\n store: z.enum(['keychain', 'secret-service', 'dpapi', 'file']),\n recordedAt: z.string(),\n by: z.enum(['create', 'repair', 'replace']),\n })\n .strict();\n\n/**\n * The envelope. Entries are checked one at a time ({@link EntrySchema}) so one\n * malformed entry hides only itself, and a write keeps every other address's\n * entry exactly as it found it.\n */\nconst RecordSchema = z\n .object({\n schemaVersion: z.literal(PASSPHRASE_RECORD_SCHEMA_VERSION),\n wallets: z.record(z.string(), z.unknown()),\n })\n .strict();\n\nconst ADDRESS_RE = /^0x[0-9a-f]{40}$/;\n\n/** The parsed sidecar's wallets, or null when there is none worth keeping. */\nasync function readWallets(dir: string): Promise<Record<string, unknown> | null> {\n try {\n const parsed = RecordSchema.safeParse(\n JSON.parse(await readFile(passphraseRecordPath(dir), 'utf8')),\n );\n return parsed.success ? parsed.data.wallets : null;\n } catch {\n return null;\n }\n}\n\n/**\n * This address's entry, or null for an absent file, unparseable JSON, a\n * `schemaVersion` other than 1, an unknown store value, or no entry for it.\n * Never throws: a sidecar Tenjin cannot read is the same as none.\n */\nexport async function readPassphraseRecord(\n dir: string,\n address: string,\n): Promise<PassphraseRecordEntry | null> {\n const key = address.toLowerCase();\n if (!ADDRESS_RE.test(key)) return null;\n const wallets = await readWallets(dir);\n if (wallets === null) return null;\n // Keys are written lowercase; a hand-edited mixed-case key still matches.\n const raw = Object.entries(wallets).find(([k]) => k.toLowerCase() === key)?.[1];\n const entry = EntrySchema.safeParse(raw);\n return entry.success ? entry.data : null;\n}\n\n/**\n * Record where `address`'s passphrase was saved, keeping every other entry.\n * The caller holds `wallet.create.lock`.\n *\n * A sidecar that does not parse is replaced by a fresh one holding only this\n * entry. That loses nothing a reader could use: a corrupt sidecar already\n * meant \"no record, today's behaviour\" for every address in it.\n */\nexport async function writePassphraseRecord(\n dir: string,\n address: string,\n entry: { store: DurableStore; by: PassphraseRecordEntry['by'] },\n now: Date = new Date(),\n): Promise<void> {\n const key = address.toLowerCase();\n if (!ADDRESS_RE.test(key)) {\n throw new CliError('INTERNAL', `Not a wallet address: ${address}`);\n }\n const wallets = { ...((await readWallets(dir)) ?? {}) };\n // One entry per address, however it was cased before.\n for (const k of Object.keys(wallets)) if (k.toLowerCase() === key) delete wallets[k];\n const record: PassphraseRecordEntry = {\n store: entry.store,\n recordedAt: now.toISOString(),\n by: entry.by,\n };\n wallets[key] = record;\n await mkdir(dir, { recursive: true, mode: 0o700 });\n await writeFileAtomic(\n passphraseRecordPath(dir),\n JSON.stringify({ schemaVersion: PASSPHRASE_RECORD_SCHEMA_VERSION, wallets }, null, 2) + '\\n',\n { mode: 0o600, dirMode: 0o700 },\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;AAAA,SAAS,OAAO,gBAAgB;AA8BzB,IAAM,mCAAmC;AAQhD,IAAM,cAAc,iBACjB,OAAO;AAAA,EACN,OAAO,iBAAE,KAAK,CAAC,YAAY,kBAAkB,SAAS,MAAM,CAAC;AAAA,EAC7D,YAAY,iBAAE,OAAO;AAAA,EACrB,IAAI,iBAAE,KAAK,CAAC,UAAU,UAAU,SAAS,CAAC;AAC5C,CAAC,EACA,OAAO;AAOV,IAAM,eAAe,iBAClB,OAAO;AAAA,EACN,eAAe,iBAAE,QAAQ,gCAAgC;AAAA,EACzD,SAAS,iBAAE,OAAO,iBAAE,OAAO,GAAG,iBAAE,QAAQ,CAAC;AAC3C,CAAC,EACA,OAAO;AAEV,IAAM,aAAa;AAGnB,eAAe,YAAY,KAAsD;AAC/E,MAAI;AACF,UAAM,SAAS,aAAa;AAAA,MAC1B,KAAK,MAAM,MAAM,SAAS,qBAAqB,GAAG,GAAG,MAAM,CAAC;AAAA,IAC9D;AACA,WAAO,OAAO,UAAU,OAAO,KAAK,U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";
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
|
+
function proxySkipped(env, supported = envProxySupported()) {
|
|
24
|
+
const name = proxyVariable(env);
|
|
25
|
+
if (name === void 0 || supported) return null;
|
|
26
|
+
return `this shell sets ${name}, which Node ${process.versions.node} cannot send downloads through`;
|
|
27
|
+
}
|
|
28
|
+
function proxyNodeStep(command) {
|
|
29
|
+
return `run \`${command}\` once with Node 24.14 or newer, which uses the proxy; Tenjin's own Node does from then on`;
|
|
30
|
+
}
|
|
23
31
|
|
|
24
32
|
export {
|
|
25
33
|
PROXY_VARIABLES,
|
|
26
34
|
proxyVariable,
|
|
27
35
|
envProxySupported,
|
|
28
|
-
useEnvProxy
|
|
36
|
+
useEnvProxy,
|
|
37
|
+
proxySkipped,
|
|
38
|
+
proxyNodeStep
|
|
29
39
|
};
|
|
30
|
-
//# sourceMappingURL=chunk-
|
|
40
|
+
//# sourceMappingURL=chunk-3FMZGI7I.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/lib/env-proxy.ts"],"sourcesContent":["import * as http from 'node:http';\n\n/** Named, never quoted: a proxy URL can carry its own credentials. */\nexport const PROXY_VARIABLES = ['HTTPS_PROXY', 'https_proxy', 'HTTP_PROXY', 'http_proxy'] as const;\n\ntype SetGlobalProxy = (env: NodeJS.ProcessEnv) => () => void;\n\n/** Node 24.14 added it. `engines` admits 22.0, where it is absent. */\nconst nodeSetGlobalProxy = (http as { setGlobalProxyFromEnv?: SetGlobalProxy })\n .setGlobalProxyFromEnv;\n\n/** The first proxy variable this environment sets, or undefined. */\nexport function proxyVariable(env: NodeJS.ProcessEnv): string | undefined {\n return PROXY_VARIABLES.find((name) => (env[name] ?? '') !== '');\n}\n\n/** Can this Node route `fetch` through the proxy the environment names? */\nexport function envProxySupported(setGlobal: unknown = nodeSetGlobalProxy): boolean {\n return typeof setGlobal === 'function';\n}\n\nexport type EnvProxyResult = 'none' | 'set' | 'unsupported' | 'invalid';\n\n/**\n * Send `fetch` and `https.request` through the proxy the environment names.\n * Node's `fetch` ignores HTTPS_PROXY, HTTP_PROXY and NO_PROXY unless\n * NODE_USE_ENV_PROXY=1, so on a network where the proxy is the only way out the\n * harness reaches the internet and Tenjin does not. Called once by the bin\n * entry, so the CLI, the hooks and `tenjin mcp` all get it. Never throws: a\n * proxy URL Node cannot parse leaves the transport as it was.\n */\nexport function useEnvProxy(\n env: NodeJS.ProcessEnv,\n setGlobal: SetGlobalProxy | null = nodeSetGlobalProxy ?? null,\n): EnvProxyResult {\n if (proxyVariable(env) === undefined) return 'none';\n if (typeof setGlobal !== 'function') return 'unsupported';\n try {\n setGlobal(env);\n return 'set';\n } catch {\n return 'invalid';\n }\n}\n"],"mappings":";;;AAAA,YAAY,UAAU;AAGf,IAAM,kBAAkB,CAAC,eAAe,eAAe,cAAc,YAAY;AAKxF,IAAM,qBACH;AAGI,SAAS,cAAc,KAA4C;AACxE,SAAO,gBAAgB,KAAK,CAAC,UAAU,IAAI,IAAI,KAAK,QAAQ,EAAE;AAChE;AAGO,SAAS,kBAAkB,YAAqB,oBAA6B;AAClF,SAAO,OAAO,cAAc;AAC9B;AAYO,SAAS,YACd,KACA,YAAmC,sBAAsB,MACzC;AAChB,MAAI,cAAc,GAAG,MAAM,OAAW,QAAO;AAC7C,MAAI,OAAO,cAAc,WAAY,QAAO;AAC5C,MAAI;AACF,cAAU,GAAG;AACb,WAAO;AAAA,EACT,QAAQ;AACN,WAAO;AAAA,EACT;AACF;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../src/lib/env-proxy.ts"],"sourcesContent":["import * as http from 'node:http';\n\n/** Named, never quoted: a proxy URL can carry its own credentials. */\nexport const PROXY_VARIABLES = ['HTTPS_PROXY', 'https_proxy', 'HTTP_PROXY', 'http_proxy'] as const;\n\ntype SetGlobalProxy = (env: NodeJS.ProcessEnv) => () => void;\n\n/** Node 24.14 added it. `engines` admits 22.0, where it is absent. */\nconst nodeSetGlobalProxy = (http as { setGlobalProxyFromEnv?: SetGlobalProxy })\n .setGlobalProxyFromEnv;\n\n/** The first proxy variable this environment sets, or undefined. */\nexport function proxyVariable(env: NodeJS.ProcessEnv): string | undefined {\n return PROXY_VARIABLES.find((name) => (env[name] ?? '') !== '');\n}\n\n/** Can this Node route `fetch` through the proxy the environment names? */\nexport function envProxySupported(setGlobal: unknown = nodeSetGlobalProxy): boolean {\n return typeof setGlobal === 'function';\n}\n\nexport type EnvProxyResult = 'none' | 'set' | 'unsupported' | 'invalid';\n\n/**\n * Send `fetch` and `https.request` through the proxy the environment names.\n * Node's `fetch` ignores HTTPS_PROXY, HTTP_PROXY and NO_PROXY unless\n * NODE_USE_ENV_PROXY=1, so on a network where the proxy is the only way out the\n * harness reaches the internet and Tenjin does not. Called once by the bin\n * entry, so the CLI, the hooks and `tenjin mcp` all get it. Never throws: a\n * proxy URL Node cannot parse leaves the transport as it was.\n */\nexport function useEnvProxy(\n env: NodeJS.ProcessEnv,\n setGlobal: SetGlobalProxy | null = nodeSetGlobalProxy ?? null,\n): EnvProxyResult {\n if (proxyVariable(env) === undefined) return 'none';\n if (typeof setGlobal !== 'function') return 'unsupported';\n try {\n setGlobal(env);\n return 'set';\n } catch {\n return 'invalid';\n }\n}\n\n/**\n * Why this Node's requests go past the proxy the environment names, or null\n * when none is named or this Node can use it. On a network whose only way out\n * is that proxy, a download then fails however often it is retried while the\n * same Node runs it, so a failure is said as this, never as a bare retry.\n */\nexport function proxySkipped(\n env: NodeJS.ProcessEnv,\n supported: boolean = envProxySupported(),\n): string | null {\n const name = proxyVariable(env);\n if (name === undefined || supported) return null;\n return `this shell sets ${name}, which Node ${process.versions.node} cannot send downloads through`;\n}\n\n/** The step that works once a download skipped the proxy: one run on a Node that uses it. */\nexport function proxyNodeStep(command: string): string {\n return `run \\`${command}\\` once with Node 24.14 or newer, which uses the proxy; Tenjin's own Node does from then on`;\n}\n"],"mappings":";;;AAAA,YAAY,UAAU;AAGf,IAAM,kBAAkB,CAAC,eAAe,eAAe,cAAc,YAAY;AAKxF,IAAM,qBACH;AAGI,SAAS,cAAc,KAA4C;AACxE,SAAO,gBAAgB,KAAK,CAAC,UAAU,IAAI,IAAI,KAAK,QAAQ,EAAE;AAChE;AAGO,SAAS,kBAAkB,YAAqB,oBAA6B;AAClF,SAAO,OAAO,cAAc;AAC9B;AAYO,SAAS,YACd,KACA,YAAmC,sBAAsB,MACzC;AAChB,MAAI,cAAc,GAAG,MAAM,OAAW,QAAO;AAC7C,MAAI,OAAO,cAAc,WAAY,QAAO;AAC5C,MAAI;AACF,cAAU,GAAG;AACb,WAAO;AAAA,EACT,QAAQ;AACN,WAAO;AAAA,EACT;AACF;AAQO,SAAS,aACd,KACA,YAAqB,kBAAkB,GACxB;AACf,QAAM,OAAO,cAAc,GAAG;AAC9B,MAAI,SAAS,UAAa,UAAW,QAAO;AAC5C,SAAO,mBAAmB,IAAI,gBAAgB,QAAQ,SAAS,IAAI;AACrE;AAGO,SAAS,cAAc,SAAyB;AACrD,SAAO,SAAS,OAAO;AACzB;","names":[]}
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
import { createRequire as __tenjinCreateRequire } from 'node:module'; const require = __tenjinCreateRequire(import.meta.url);
|
|
2
|
+
import {
|
|
3
|
+
package_default
|
|
4
|
+
} from "./chunk-RVPYTUP4.js";
|
|
5
|
+
|
|
6
|
+
// src/router/mcp-processes.ts
|
|
7
|
+
import { execFile } from "node:child_process";
|
|
8
|
+
import { stat } from "node:fs/promises";
|
|
9
|
+
import { dirname, join } from "node:path";
|
|
10
|
+
import { fileURLToPath } from "node:url";
|
|
11
|
+
import { promisify } from "node:util";
|
|
12
|
+
var exec = promisify(execFile);
|
|
13
|
+
var listProcesses = async () => {
|
|
14
|
+
if (process.platform === "win32" || typeof process.getuid !== "function") return null;
|
|
15
|
+
try {
|
|
16
|
+
const { stdout } = await exec(
|
|
17
|
+
"ps",
|
|
18
|
+
["-U", String(process.getuid()), "-o", "pid=,ppid=,stat=,lstart=,args="],
|
|
19
|
+
{ timeout: 5e3, env: { ...process.env, LC_ALL: "C" }, maxBuffer: 4 * 1024 * 1024 }
|
|
20
|
+
);
|
|
21
|
+
return parsePs(stdout, process.pid);
|
|
22
|
+
} catch {
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
var PS_LINE = /^\s*(\d+)\s+(\d+)\s+(\S+)\s+(\w{3}\s+\w{3}\s+\d{1,2}\s+\d{2}:\d{2}:\d{2}\s+\d{4})\s+(.*)$/;
|
|
27
|
+
var ANCESTRY_DEPTH = 10;
|
|
28
|
+
function parsePs(stdout, selfPid) {
|
|
29
|
+
const rows = [];
|
|
30
|
+
for (const line of stdout.split("\n")) {
|
|
31
|
+
const m = PS_LINE.exec(line);
|
|
32
|
+
if (m === null || m[3].startsWith("Z")) continue;
|
|
33
|
+
const startedAt = Date.parse(m[4].replace(/\s+/g, " "));
|
|
34
|
+
rows.push({
|
|
35
|
+
pid: Number(m[1]),
|
|
36
|
+
ppid: Number(m[2]),
|
|
37
|
+
startedAt: Number.isNaN(startedAt) ? null : startedAt,
|
|
38
|
+
args: m[5]
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
const byPid = new Map(rows.map((r) => [r.pid, r]));
|
|
42
|
+
const underClaude = (row) => {
|
|
43
|
+
let parent = byPid.get(row.ppid);
|
|
44
|
+
for (let i = 0; i < ANCESTRY_DEPTH && parent !== void 0; i += 1) {
|
|
45
|
+
if (isClaudeCode(parent.args)) return true;
|
|
46
|
+
if (parent.ppid === parent.pid) break;
|
|
47
|
+
parent = byPid.get(parent.ppid);
|
|
48
|
+
}
|
|
49
|
+
return false;
|
|
50
|
+
};
|
|
51
|
+
const routers = [];
|
|
52
|
+
const claude = [];
|
|
53
|
+
for (const row of rows) {
|
|
54
|
+
const mcp = row.pid !== selfPid ? tenjinMcp(row.args) : null;
|
|
55
|
+
if (mcp !== null) {
|
|
56
|
+
routers.push({
|
|
57
|
+
pid: row.pid,
|
|
58
|
+
startedAt: row.startedAt,
|
|
59
|
+
ppid: row.ppid,
|
|
60
|
+
kind: routerKind(row.args),
|
|
61
|
+
underClaude: underClaude(row),
|
|
62
|
+
...mcp.version !== void 0 ? { version: mcp.version } : {}
|
|
63
|
+
});
|
|
64
|
+
} else if (isClaudeCode(row.args)) {
|
|
65
|
+
claude.push({ pid: row.pid, startedAt: row.startedAt, ppid: row.ppid });
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
return { routers, claude };
|
|
69
|
+
}
|
|
70
|
+
function routerKind(args) {
|
|
71
|
+
const tokens = args.trim().split(/\s+/);
|
|
72
|
+
if (tokens.includes("--plugin")) return "plugin";
|
|
73
|
+
const harness = tokens.indexOf("--harness");
|
|
74
|
+
if (harness >= 0 && tokens[harness + 1] === "codex") return "codex";
|
|
75
|
+
if (tokens.includes("--harness=codex")) return "codex";
|
|
76
|
+
return "other";
|
|
77
|
+
}
|
|
78
|
+
var ONE_SHOT = /* @__PURE__ */ new Set(["mcp", "plugin", "config", "update", "doctor", "setup-token"]);
|
|
79
|
+
var INTERPRETER = /^(node|nodejs|bun)(\.exe)?$/i;
|
|
80
|
+
function isClaudePath(token) {
|
|
81
|
+
return isClaudeBinary(token) || token.includes("/claude/versions/") || token.includes("/claude-code/") || token.includes("@anthropic-ai/claude-code/cli.js");
|
|
82
|
+
}
|
|
83
|
+
function isClaudeBinary(path) {
|
|
84
|
+
const base = path.split(/[/\\]/).pop() ?? path;
|
|
85
|
+
return base === "claude" || base === "claude.exe";
|
|
86
|
+
}
|
|
87
|
+
function claudePathEnd(tokens, at) {
|
|
88
|
+
const first = tokens[at];
|
|
89
|
+
if (first === void 0) return -1;
|
|
90
|
+
if (isClaudePath(first)) return at + 1;
|
|
91
|
+
if (!/^(\/|[A-Za-z]:\\)/.test(first)) return -1;
|
|
92
|
+
let path = first;
|
|
93
|
+
for (let i = at + 1; i < tokens.length; i += 1) {
|
|
94
|
+
const next = tokens[i];
|
|
95
|
+
if (/^[-/\\]/.test(next)) return -1;
|
|
96
|
+
path = `${path} ${next}`;
|
|
97
|
+
if (isClaudeBinary(path)) return i + 1;
|
|
98
|
+
}
|
|
99
|
+
return -1;
|
|
100
|
+
}
|
|
101
|
+
function isClaudeCode(args) {
|
|
102
|
+
const tokens = args.trim().split(/\s+/);
|
|
103
|
+
let at = 0;
|
|
104
|
+
if (tokens[0] !== void 0 && INTERPRETER.test(tokens[0].split(/[/\\]/).pop() ?? "")) at = 1;
|
|
105
|
+
const end = claudePathEnd(tokens, at);
|
|
106
|
+
if (end < 0) return false;
|
|
107
|
+
const sub = tokens[end];
|
|
108
|
+
return sub === void 0 || !ONE_SHOT.has(sub);
|
|
109
|
+
}
|
|
110
|
+
var RUNTIME_ENTRY = /[/\\]runtime[/\\]versions[/\\]([^/\\]+)[/\\]dist[/\\]index\.js$/;
|
|
111
|
+
function tenjinMcp(args) {
|
|
112
|
+
const tokens = args.trim().split(/\s+/);
|
|
113
|
+
let version;
|
|
114
|
+
const bin = tokens.findIndex((t) => {
|
|
115
|
+
const runtime = RUNTIME_ENTRY.exec(t);
|
|
116
|
+
if (runtime !== null) {
|
|
117
|
+
version = runtime[1];
|
|
118
|
+
return true;
|
|
119
|
+
}
|
|
120
|
+
return /(^|[/\\])tenjin(\.js|\.cmd)?$/.test(t) || /[/\\]tenjin-cli[/\\]/.test(t) || /[/\\]hosts[/\\]claude[/\\]tenjin[/\\]\.\.[/\\]\.\.[/\\]\.\.[/\\]index\.js$/.test(t);
|
|
121
|
+
});
|
|
122
|
+
if (bin < 0 || tokens[bin + 1] !== "mcp") return null;
|
|
123
|
+
return version !== void 0 ? { version } : {};
|
|
124
|
+
}
|
|
125
|
+
var installedAt = async () => {
|
|
126
|
+
let dir = dirname(fileURLToPath(import.meta.url));
|
|
127
|
+
for (let i = 0; i < 6; i += 1) {
|
|
128
|
+
try {
|
|
129
|
+
const st = await stat(join(dir, "package.json"));
|
|
130
|
+
return Math.max(st.ctimeMs, st.mtimeMs);
|
|
131
|
+
} catch {
|
|
132
|
+
dir = dirname(dir);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
return null;
|
|
136
|
+
};
|
|
137
|
+
var RECONNECT_FIX = "Start a new Claude Code session: this one still runs the earlier Tenjin build.";
|
|
138
|
+
var NEW_SESSION_FIX = RECONNECT_FIX;
|
|
139
|
+
function mcpServersState(procs, installed, version = package_default.version, fix = RECONNECT_FIX) {
|
|
140
|
+
const check = (detail) => ({
|
|
141
|
+
stale: 0,
|
|
142
|
+
check: { name: "mcp server", status: "ok", required: false, detail }
|
|
143
|
+
});
|
|
144
|
+
const unchecked = (detail) => ({
|
|
145
|
+
stale: 0,
|
|
146
|
+
check: { name: "mcp server", status: "warn", required: false, detail, checked: false }
|
|
147
|
+
});
|
|
148
|
+
if (procs === null) {
|
|
149
|
+
return unchecked(
|
|
150
|
+
"could not check for `tenjin mcp` processes started before this install: they cannot be listed on this platform"
|
|
151
|
+
);
|
|
152
|
+
}
|
|
153
|
+
if (procs.length === 0) return check("none running (starts with the next session)");
|
|
154
|
+
if (installed === null && procs.some((p) => p.version === void 0)) {
|
|
155
|
+
return unchecked(`${procs.length} running; when this build was installed is unknown`);
|
|
156
|
+
}
|
|
157
|
+
const stale = procs.filter(
|
|
158
|
+
(p) => p.kind !== "codex" && p.underClaude !== false && (p.version !== void 0 ? p.version !== version : p.startedAt !== null && installed !== null && p.startedAt < installed)
|
|
159
|
+
).length;
|
|
160
|
+
if (stale === 0) {
|
|
161
|
+
return check(`${procs.length} running, all started after this install`);
|
|
162
|
+
}
|
|
163
|
+
const which = stale === 1 ? "process" : "processes";
|
|
164
|
+
return {
|
|
165
|
+
stale,
|
|
166
|
+
check: {
|
|
167
|
+
name: "mcp server",
|
|
168
|
+
status: "warn",
|
|
169
|
+
required: false,
|
|
170
|
+
detail: `${stale} running \`tenjin mcp\` ${which} started before this install (${version}), so ${stale === 1 ? "it runs" : "they run"} the older build, where the hooks can fail with "Tool hook not found"`,
|
|
171
|
+
fix
|
|
172
|
+
}
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
async function readProcessSnapshot(deps = {}) {
|
|
176
|
+
const list = deps.listProcesses ?? (deps.listMcpProcesses !== void 0 ? async () => {
|
|
177
|
+
const routers = await deps.listMcpProcesses();
|
|
178
|
+
return routers === null ? null : { routers, claude: [] };
|
|
179
|
+
} : listProcesses);
|
|
180
|
+
const [snapshot, installed] = await Promise.all([
|
|
181
|
+
list().catch(() => null),
|
|
182
|
+
(deps.installedAt ?? installedAt)().catch(() => null)
|
|
183
|
+
]);
|
|
184
|
+
return { snapshot, installed };
|
|
185
|
+
}
|
|
186
|
+
async function readMcpServers(deps = {}, opts = {}) {
|
|
187
|
+
const { snapshot, installed } = await readProcessSnapshot(deps);
|
|
188
|
+
const fix = opts.settingsInstallPending === true ? NEW_SESSION_FIX : RECONNECT_FIX;
|
|
189
|
+
return mcpServersState(snapshot?.routers ?? null, installed, opts.version ?? package_default.version, fix);
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
export {
|
|
193
|
+
RECONNECT_FIX,
|
|
194
|
+
mcpServersState,
|
|
195
|
+
readProcessSnapshot,
|
|
196
|
+
readMcpServers
|
|
197
|
+
};
|
|
198
|
+
//# sourceMappingURL=chunk-3GNJXKIT.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/router/mcp-processes.ts"],"sourcesContent":["import { execFile } from 'node:child_process';\nimport { stat } from 'node:fs/promises';\nimport { dirname, join } from 'node:path';\nimport { fileURLToPath } from 'node:url';\nimport { promisify } from 'node:util';\nimport pkg from '../../package.json';\nimport type { RouterCheck } from './reachability';\n\n/**\n * A `tenjin mcp` STARTED BEFORE THIS INSTALL still runs the code it started\n * with. Claude Code keeps its MCP servers for the life of a session, so after\n * an update the hooks the new install wrote can call a tool the old process\n * does not have (\"Tool hook not found\"), while every file on disk reads as\n * correct. This finds this user's running `tenjin mcp` processes and compares\n * each start time with the installed package's own `package.json`.\n */\n\nexport interface McpProcess {\n pid: number;\n /** Start time in epoch ms, or null when `ps` gave none this could read. */\n startedAt: number | null;\n /** The parent pid, when `ps` gave one. */\n ppid?: number;\n /**\n * What started it, from its own arguments: `plugin` (the plugin's `--plugin`\n * router), `codex` (`--harness codex`) or `other`. Absent on an injected\n * entry, which then counts as it always did.\n */\n kind?: 'plugin' | 'codex' | 'other';\n /**\n * Whether a Claude Code process is among its ancestors (up to 10 levels).\n * False for a router nothing Claude started: a `tenjin mcp` in a terminal, a\n * Codex one, a test harness. Absent (injected) counts as true.\n */\n underClaude?: boolean;\n /**\n * The CLI version it runs, when it runs from Tenjin's runtime\n * (`runtime/versions/<v>/dist/index.js`). Absent for any other launch.\n */\n version?: string;\n}\n\n/**\n * One `ps` read, in the two lists doctor and install need: this user's running\n * `tenjin mcp` routers (zombies and this process left out), and the Claude Code\n * sessions themselves, so a router's ancestry and a session's start time can\n * be told without a second `ps`.\n */\nexport interface ProcessSnapshot {\n routers: McpProcess[];\n claude: McpProcess[];\n}\n\n/** This user's running routers and Claude Code processes, or null where they cannot be listed. */\nexport type ListProcesses = () => Promise<ProcessSnapshot | null>;\n\n/** This user's running `tenjin mcp` processes, or null where they cannot be listed. */\nexport type ListMcpProcesses = () => Promise<McpProcess[] | null>;\n\n/** When the installed package was written, in epoch ms, or null. */\nexport type InstalledAt = () => Promise<number | null>;\n\nconst exec = promisify(execFile);\n\n/** `ps` on macOS and Linux; null on Windows or when `ps` fails, which is \"unknown\". */\nexport const listProcesses: ListProcesses = async () => {\n if (process.platform === 'win32' || typeof process.getuid !== 'function') return null;\n try {\n const { stdout } = await exec(\n 'ps',\n ['-U', String(process.getuid()), '-o', 'pid=,ppid=,stat=,lstart=,args='],\n { timeout: 5_000, env: { ...process.env, LC_ALL: 'C' }, maxBuffer: 4 * 1024 * 1024 },\n );\n return parsePs(stdout, process.pid);\n } catch {\n return null;\n }\n};\n\n/** The routers alone, as before the snapshot: kept so its callers and seams keep their shape. */\nexport const listMcpProcesses: ListMcpProcesses = async () =>\n (await listProcesses())?.routers ?? null;\n\nconst PS_LINE =\n /^\\s*(\\d+)\\s+(\\d+)\\s+(\\S+)\\s+(\\w{3}\\s+\\w{3}\\s+\\d{1,2}\\s+\\d{2}:\\d{2}:\\d{2}\\s+\\d{4})\\s+(.*)$/;\n\n/** How far up the parent chain a router is followed to find the Claude Code that started it. */\nconst ANCESTRY_DEPTH = 10;\n\ninterface PsRow {\n pid: number;\n ppid: number;\n startedAt: number | null;\n args: string;\n}\n\n/**\n * The `ps -o pid=,ppid=,stat=,lstart=,args=` lines as a {@link ProcessSnapshot}:\n * the `tenjin mcp` routers, this process left out, and the Claude Code\n * processes. A zombie (stat starting `Z`) is neither: it has exited, and its\n * pid may already name nothing.\n */\nexport function parsePs(stdout: string, selfPid: number): ProcessSnapshot {\n const rows: PsRow[] = [];\n for (const line of stdout.split('\\n')) {\n const m = PS_LINE.exec(line);\n if (m === null || m[3]!.startsWith('Z')) continue;\n const startedAt = Date.parse(m[4]!.replace(/\\s+/g, ' '));\n rows.push({\n pid: Number(m[1]),\n ppid: Number(m[2]),\n startedAt: Number.isNaN(startedAt) ? null : startedAt,\n args: m[5]!,\n });\n }\n const byPid = new Map(rows.map((r) => [r.pid, r]));\n const underClaude = (row: PsRow): boolean => {\n let parent = byPid.get(row.ppid);\n for (let i = 0; i < ANCESTRY_DEPTH && parent !== undefined; i += 1) {\n if (isClaudeCode(parent.args)) return true;\n if (parent.ppid === parent.pid) break;\n parent = byPid.get(parent.ppid);\n }\n return false;\n };\n const routers: McpProcess[] = [];\n const claude: McpProcess[] = [];\n for (const row of rows) {\n const mcp = row.pid !== selfPid ? tenjinMcp(row.args) : null;\n if (mcp !== null) {\n routers.push({\n pid: row.pid,\n startedAt: row.startedAt,\n ppid: row.ppid,\n kind: routerKind(row.args),\n underClaude: underClaude(row),\n ...(mcp.version !== undefined ? { version: mcp.version } : {}),\n });\n } else if (isClaudeCode(row.args)) {\n claude.push({ pid: row.pid, startedAt: row.startedAt, ppid: row.ppid });\n }\n }\n return { routers, claude };\n}\n\n/** Who started a router, read from the flags its starter passes. */\nfunction routerKind(args: string): 'plugin' | 'codex' | 'other' {\n const tokens = args.trim().split(/\\s+/);\n if (tokens.includes('--plugin')) return 'plugin';\n const harness = tokens.indexOf('--harness');\n if (harness >= 0 && tokens[harness + 1] === 'codex') return 'codex';\n if (tokens.includes('--harness=codex')) return 'codex';\n return 'other';\n}\n\n/**\n * `claude`'s own one-shot subcommands. Each starts, answers and exits; none is\n * a session. `claude mcp get` (doctor) and `claude mcp list` even start a\n * `tenjin mcp` of their own, and that router must never pass for one a\n * session started.\n */\nconst ONE_SHOT = new Set(['mcp', 'plugin', 'config', 'update', 'doctor', 'setup-token']);\n\n/** Interpreters a JS build of Claude Code runs under, as the first token. */\nconst INTERPRETER = /^(node|nodejs|bun)(\\.exe)?$/i;\n\n/** Is this path Claude Code's own binary or bundle? */\nfunction isClaudePath(token: string): boolean {\n return (\n isClaudeBinary(token) ||\n token.includes('/claude/versions/') ||\n token.includes('/claude-code/') ||\n token.includes('@anthropic-ai/claude-code/cli.js')\n );\n}\n\n/** Is this the `claude` binary itself (its basename), not just a path under Claude Code's folder? */\nfunction isClaudeBinary(path: string): boolean {\n const base = path.split(/[/\\\\]/).pop() ?? path;\n return base === 'claude' || base === 'claude.exe';\n}\n\n/**\n * Where Claude Code's path, starting at `tokens[at]`, ends: the index of the\n * first token after it, or -1 when it is not Claude Code. `ps` joins the\n * arguments with spaces, so a path that holds one (the desktop app's\n * `/Users/<u>/Library/Application Support/Claude/claude-code/<ver>/.../claude`)\n * spans several tokens. An absolute path is extended over the tokens after it\n * while none starts a new path or a flag, and a joined path counts only when\n * it ends at the `claude` binary itself.\n */\nfunction claudePathEnd(tokens: string[], at: number): number {\n const first = tokens[at];\n if (first === undefined) return -1;\n if (isClaudePath(first)) return at + 1;\n if (!/^(\\/|[A-Za-z]:\\\\)/.test(first)) return -1;\n let path = first;\n for (let i = at + 1; i < tokens.length; i += 1) {\n const next = tokens[i]!;\n if (/^[-/\\\\]/.test(next)) return -1;\n path = `${path} ${next}`;\n if (isClaudeBinary(path)) return i + 1;\n }\n return -1;\n}\n\n/**\n * A Claude Code SESSION, from its `ps` arguments: the first token is the\n * `claude` binary (or an installed version of it, whose path may hold\n * spaces), or an interpreter running Claude Code's bundle. Its one-shot\n * subcommands (`claude mcp get`, `claude plugin list`, `claude update`, ...)\n * are not sessions, and are left out.\n */\nexport function isClaudeCode(args: string): boolean {\n const tokens = args.trim().split(/\\s+/);\n let at = 0;\n if (tokens[0] !== undefined && INTERPRETER.test(tokens[0].split(/[/\\\\]/).pop() ?? '')) at = 1;\n const end = claudePathEnd(tokens, at);\n if (end < 0) return false;\n const sub = tokens[end];\n return sub === undefined || !ONE_SHOT.has(sub);\n}\n\n/**\n * A runtime build's entry, `<root>/runtime/versions/<v>/dist/index.js`, with\n * the version. Anchored at the token's end, because `ps` joins arguments with\n * spaces: a data dir under a home with a space splits the path, and its last\n * token still ends this way.\n */\nconst RUNTIME_ENTRY = /[/\\\\]runtime[/\\\\]versions[/\\\\]([^/\\\\]+)[/\\\\]dist[/\\\\]index\\.js$/;\n\n/**\n * `tenjin mcp`, however the bin was invoked: `node /path/bin/tenjin mcp`,\n * `tenjin mcp`, the npm folder plugin's `node <plugin root>/../../../index.js\n * mcp`, or the runtime plugin's `<runtime node> <runtime>/versions/<v>/dist/index.js\n * mcp`, which also says the version it runs. Null when it is none of these.\n */\nfunction tenjinMcp(args: string): { version?: string } | null {\n const tokens = args.trim().split(/\\s+/);\n let version: string | undefined;\n const bin = tokens.findIndex((t) => {\n const runtime = RUNTIME_ENTRY.exec(t);\n if (runtime !== null) {\n version = runtime[1];\n return true;\n }\n return (\n /(^|[/\\\\])tenjin(\\.js|\\.cmd)?$/.test(t) ||\n /[/\\\\]tenjin-cli[/\\\\]/.test(t) ||\n /[/\\\\]hosts[/\\\\]claude[/\\\\]tenjin[/\\\\]\\.\\.[/\\\\]\\.\\.[/\\\\]\\.\\.[/\\\\]index\\.js$/.test(t)\n );\n });\n if (bin < 0 || tokens[bin + 1] !== 'mcp') return null;\n return version !== undefined ? { version } : {};\n}\n\n/**\n * When this build's `package.json`, the nearest one above this module, was\n * written. Its ctime, not its mtime: npm extracts a package with the\n * tarball's fixed 1985 mtimes, and setting them is what moves the ctime to\n * the moment of the install.\n */\nexport const installedAt: InstalledAt = async () => {\n let dir = dirname(fileURLToPath(import.meta.url));\n for (let i = 0; i < 6; i += 1) {\n try {\n const st = await stat(join(dir, 'package.json'));\n return Math.max(st.ctimeMs, st.mtimeMs);\n } catch {\n dir = dirname(dir);\n }\n }\n return null;\n};\n\n/** How many running servers predate the install, and what doctor says about it. */\nexport interface McpServersState {\n stale: number;\n check: RouterCheck;\n}\n\n/**\n * Worded for the session the person is in, never a terminal. Only a new\n * session: `/reload-plugins` reconnects the server but does not run the\n * plugin's `SessionStart`, and while a settings install is still here it would\n * load the plugin beside a pre-upgrade `x402` server, so every event would\n * route twice.\n */\nexport const RECONNECT_FIX =\n 'Start a new Claude Code session: this one still runs the earlier Tenjin build.';\n/** The same step while a settings install is still here; kept as its own export for its callers. */\nexport const NEW_SESSION_FIX = RECONNECT_FIX;\n\n/**\n * The `mcp server` check from a process list and the install time. Never a\n * failure.\n *\n * STALE MEANS A CLAUDE CODE SESSION IS STILL RUNNING THE OLD BUILD. A router\n * launched from Tenjin's runtime says its version, so it is stale when that is\n * not `version`, whenever it started: the runtime switches builds without any\n * package being written. Any other router is stale when it started before the\n * install. A Codex\n * router (`kind: 'codex'`) and one nothing Claude started (`underClaude:\n * false`: a terminal, a test) are not this check's business, so they are not\n * counted. An injected entry without those fields counts, as it always did.\n *\n * What this cannot see is said as not checked (`checked: false`), never as a\n * pass: a platform without `ps`, or an install time it could not read.\n */\nexport function mcpServersState(\n procs: McpProcess[] | null,\n installed: number | null,\n version: string = pkg.version,\n fix: string = RECONNECT_FIX,\n): McpServersState {\n const check = (detail: string): McpServersState => ({\n stale: 0,\n check: { name: 'mcp server', status: 'ok', required: false, detail },\n });\n const unchecked = (detail: string): McpServersState => ({\n stale: 0,\n check: { name: 'mcp server', status: 'warn', required: false, detail, checked: false },\n });\n if (procs === null) {\n return unchecked(\n 'could not check for `tenjin mcp` processes started before this install: they cannot be listed on this platform',\n );\n }\n if (procs.length === 0) return check('none running (starts with the next session)');\n if (installed === null && procs.some((p) => p.version === undefined)) {\n return unchecked(`${procs.length} running; when this build was installed is unknown`);\n }\n const stale = procs.filter(\n (p) =>\n p.kind !== 'codex' &&\n p.underClaude !== false &&\n (p.version !== undefined\n ? p.version !== version\n : p.startedAt !== null && installed !== null && p.startedAt < installed),\n ).length;\n if (stale === 0) {\n return check(`${procs.length} running, all started after this install`);\n }\n const which = stale === 1 ? 'process' : 'processes';\n return {\n stale,\n check: {\n name: 'mcp server',\n status: 'warn',\n required: false,\n detail: `${stale} running \\`tenjin mcp\\` ${which} started before this install (${version}), so ${stale === 1 ? 'it runs' : 'they run'} the older build, where the hooks can fail with \"Tool hook not found\"`,\n fix,\n },\n };\n}\n\n/** The process seams doctor and install take; each defaults to this machine. */\nexport interface ProcessDeps {\n /** The whole snapshot; wins over `listMcpProcesses`. */\n listProcesses?: ListProcesses;\n /**\n * The routers alone (the older seam). Injected without `listProcesses`, it\n * stands for a snapshot with these routers and no Claude Code process.\n */\n listMcpProcesses?: ListMcpProcesses;\n installedAt?: InstalledAt;\n}\n\n/**\n * ONE `ps` AND THE INSTALL TIME, read once and shared: doctor's `mcp server`,\n * `claude session` and `plugin` rows all decide from the same snapshot, so a\n * process that starts between two reads cannot make them disagree. Never\n * rejects: a failing source is null, which every reader says as not checked.\n */\nexport async function readProcessSnapshot(\n deps: ProcessDeps = {},\n): Promise<{ snapshot: ProcessSnapshot | null; installed: number | null }> {\n const list: ListProcesses =\n deps.listProcesses ??\n (deps.listMcpProcesses !== undefined\n ? async () => {\n const routers = await deps.listMcpProcesses!();\n return routers === null ? null : { routers, claude: [] };\n }\n : listProcesses);\n const [snapshot, installed] = await Promise.all([\n list().catch(() => null),\n (deps.installedAt ?? installedAt)().catch(() => null),\n ]);\n return { snapshot, installed };\n}\n\n/**\n * The check, read from this machine (or the injected sources). `version` is\n * the build the plugin now runs, when that is not this one: `tenjin update`'s\n * parent names the version it just moved the runtime to.\n */\nexport async function readMcpServers(\n deps: ProcessDeps = {},\n opts: { settingsInstallPending?: boolean; version?: string } = {},\n): Promise<McpServersState> {\n const { snapshot, installed } = await readProcessSnapshot(deps);\n const fix = opts.settingsInstallPending === true ? NEW_SESSION_FIX : RECONNECT_FIX;\n return mcpServersState(snapshot?.routers ?? null, installed, opts.version ?? pkg.version, fix);\n}\n"],"mappings":";;;;;;AAAA,SAAS,gBAAgB;AACzB,SAAS,YAAY;AACrB,SAAS,SAAS,YAAY;AAC9B,SAAS,qBAAqB;AAC9B,SAAS,iBAAiB;AA0D1B,IAAM,OAAO,UAAU,QAAQ;AAGxB,IAAM,gBAA+B,YAAY;AACtD,MAAI,QAAQ,aAAa,WAAW,OAAO,QAAQ,WAAW,WAAY,QAAO;AACjF,MAAI;AACF,UAAM,EAAE,OAAO,IAAI,MAAM;AAAA,MACvB;AAAA,MACA,CAAC,MAAM,OAAO,QAAQ,OAAO,CAAC,GAAG,MAAM,gCAAgC;AAAA,MACvE,EAAE,SAAS,KAAO,KAAK,EAAE,GAAG,QAAQ,KAAK,QAAQ,IAAI,GAAG,WAAW,IAAI,OAAO,KAAK;AAAA,IACrF;AACA,WAAO,QAAQ,QAAQ,QAAQ,GAAG;AAAA,EACpC,QAAQ;AACN,WAAO;AAAA,EACT;AACF;AAMA,IAAM,UACJ;AAGF,IAAM,iBAAiB;AAehB,SAAS,QAAQ,QAAgB,SAAkC;AACxE,QAAM,OAAgB,CAAC;AACvB,aAAW,QAAQ,OAAO,MAAM,IAAI,GAAG;AACrC,UAAM,IAAI,QAAQ,KAAK,IAAI;AAC3B,QAAI,MAAM,QAAQ,EAAE,CAAC,EAAG,WAAW,GAAG,EAAG;AACzC,UAAM,YAAY,KAAK,MAAM,EAAE,CAAC,EAAG,QA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AI;AAAA,EACtD,CAAC;AACD,SAAO,EAAE,UAAU,UAAU;AAC/B;AAOA,eAAsB,eACpB,OAAoB,CAAC,GACrB,OAA+D,CAAC,GACtC;AAC1B,QAAM,EAAE,UAAU,UAAU,IAAI,MAAM,oBAAoB,IAAI;AAC9D,QAAM,MAAM,KAAK,2BAA2B,OAAO,kBAAkB;AACrE,SAAO,gBAAgB,UAAU,WAAW,MAAM,WAAW,KAAK,WAAW,gBAAI,SAAS,GAAG;AAC/F;","names":[]}
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import { createRequire as __tenjinCreateRequire } from 'node:module'; const require = __tenjinCreateRequire(import.meta.url);
|
|
2
2
|
import {
|
|
3
3
|
setTenjinIdentity
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-36RVGZNY.js";
|
|
5
|
+
import {
|
|
6
|
+
isTeamModeConfig
|
|
7
|
+
} from "./chunk-KM7RY2ZS.js";
|
|
5
8
|
import {
|
|
6
9
|
hasCode
|
|
7
10
|
} from "./chunk-2I4QTOLB.js";
|
|
8
|
-
import {
|
|
9
|
-
isTeamModeConfig
|
|
10
|
-
} from "./chunk-7WU4OPLP.js";
|
|
11
11
|
import {
|
|
12
12
|
loadRawConfig,
|
|
13
13
|
resolveSettings
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-2M2VPI2E.js";
|
|
15
15
|
import {
|
|
16
16
|
knownDeploymentOrigins
|
|
17
17
|
} from "./chunk-XQJXNMSB.js";
|
|
@@ -20,7 +20,7 @@ import {
|
|
|
20
20
|
} from "./chunk-7WEQQJLG.js";
|
|
21
21
|
import {
|
|
22
22
|
installIdPath
|
|
23
|
-
} from "./chunk-
|
|
23
|
+
} from "./chunk-OJNTCYQQ.js";
|
|
24
24
|
|
|
25
25
|
// src/lib/install-identity.ts
|
|
26
26
|
import { randomUUID } from "node:crypto";
|
|
@@ -111,4 +111,4 @@ export {
|
|
|
111
111
|
enableCliIdentity,
|
|
112
112
|
enableDaemonIdentity
|
|
113
113
|
};
|
|
114
|
-
//# sourceMappingURL=chunk-
|
|
114
|
+
//# sourceMappingURL=chunk-4K7TQHNP.js.map
|