tenjin-cli 0.1.0-alpha.30 → 0.1.0-alpha.32
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 +65 -116
- package/dist/{_esm-CE7KNONL.js → _esm-RLLC72MS.js} +127 -131
- package/dist/alive-MROUMFH3.js +38 -0
- package/dist/auto-update-OPWMRZLS.js +22 -0
- package/dist/{ccip-7RMRLAGV.js → ccip-DHDFKTQV.js} +2 -2
- package/dist/chunk-2GNOFONN.js +560 -0
- package/dist/chunk-2GNOFONN.js.map +1 -0
- package/dist/{chunk-TTNESUPQ.js → chunk-2GP3HRYK.js} +2120 -193
- package/dist/chunk-2GP3HRYK.js.map +1 -0
- package/dist/chunk-3623BLPV.js +184 -0
- package/dist/chunk-3623BLPV.js.map +1 -0
- package/dist/chunk-3AIHRXKO.js +72 -0
- package/dist/chunk-3AIHRXKO.js.map +1 -0
- package/dist/chunk-3DIL66VX.js +120 -0
- package/dist/chunk-3DIL66VX.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-3UCIG4TG.js +65 -0
- package/dist/chunk-3UCIG4TG.js.map +1 -0
- package/dist/{chunk-LFZJM56J.js → chunk-445VQTVM.js} +3 -3
- 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-RAULEAZ6.js → chunk-4USCZ2NI.js} +3 -3
- 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-7WEQQJLG.js +68 -0
- package/dist/chunk-7WEQQJLG.js.map +1 -0
- package/dist/{chunk-3O2BQIF6.js → chunk-AD226HDR.js} +344 -534
- package/dist/chunk-AD226HDR.js.map +1 -0
- package/dist/chunk-ADV4LDTB.js +106 -0
- package/dist/chunk-ADV4LDTB.js.map +1 -0
- package/dist/{chunk-AWFUPKTM.js → chunk-AV5NZMYO.js} +15 -7
- package/dist/{chunk-AWFUPKTM.js.map → chunk-AV5NZMYO.js.map} +1 -1
- package/dist/chunk-B7EM4GGF.js +198 -0
- package/dist/chunk-B7EM4GGF.js.map +1 -0
- package/dist/chunk-BFDQ4WNW.js +119 -0
- package/dist/chunk-BFDQ4WNW.js.map +1 -0
- package/dist/{chunk-OSYTBCUC.js → chunk-BI673VEJ.js} +531 -503
- package/dist/chunk-BI673VEJ.js.map +1 -0
- package/dist/chunk-CEXSOI5R.js +808 -0
- package/dist/chunk-CEXSOI5R.js.map +1 -0
- package/dist/{chunk-OK2TDZQU.js → chunk-CISYM4EO.js} +9 -7
- package/dist/chunk-CISYM4EO.js.map +1 -0
- package/dist/{chunk-VFMQTSXG.js → chunk-D3ZURCG7.js} +3 -3
- package/dist/chunk-D5TOQSO4.js +474 -0
- package/dist/chunk-D5TOQSO4.js.map +1 -0
- package/dist/{chunk-P7LABKCW.js → chunk-DOQGNFHM.js} +33 -2
- package/dist/{chunk-P7LABKCW.js.map → chunk-DOQGNFHM.js.map} +1 -1
- package/dist/{chunk-QUVVWYJW.js → chunk-DRDUIZIA.js} +11 -9
- package/dist/{chunk-QUVVWYJW.js.map → chunk-DRDUIZIA.js.map} +1 -1
- package/dist/{chunk-O2FRQ2L2.js → chunk-DW4YTVR3.js} +5 -65
- package/dist/chunk-DW4YTVR3.js.map +1 -0
- package/dist/chunk-E7LGOMH6.js +449 -0
- package/dist/chunk-E7LGOMH6.js.map +1 -0
- package/dist/chunk-E7SW44LM.js +138 -0
- 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-G75OPGAK.js +111 -0
- package/dist/chunk-G75OPGAK.js.map +1 -0
- package/dist/{chunk-YFQOA5AU.js → chunk-GAKUQHKA.js} +13 -17
- package/dist/{chunk-YFQOA5AU.js.map → chunk-GAKUQHKA.js.map} +1 -1
- package/dist/{chunk-PAYV4XUA.js → chunk-HDPUXS3Z.js} +20 -49
- package/dist/chunk-HDPUXS3Z.js.map +1 -0
- package/dist/{chunk-ORWL5BSN.js → chunk-HGZEPQUT.js} +2 -2
- package/dist/{chunk-HPWO4O6S.js → chunk-HREHWL32.js} +4 -4
- package/dist/{chunk-HPWO4O6S.js.map → chunk-HREHWL32.js.map} +1 -1
- package/dist/{chunk-VZGAONSJ.js → chunk-I5TDIUKM.js} +16 -35
- package/dist/chunk-I5TDIUKM.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-U6YQ6FRI.js → chunk-IDTRSAHE.js} +32 -12
- package/dist/chunk-IDTRSAHE.js.map +1 -0
- package/dist/{chunk-SPAVAYSW.js → chunk-JEVQ5LKO.js} +7 -5
- package/dist/{chunk-SPAVAYSW.js.map → chunk-JEVQ5LKO.js.map} +1 -1
- package/dist/{chunk-EBVIKMCH.js → chunk-JKKAIPTU.js} +2 -2
- package/dist/chunk-JNJWBTU2.js +3497 -0
- package/dist/chunk-JNJWBTU2.js.map +1 -0
- package/dist/{chunk-TTBKWWTV.js → chunk-JRZBBPO6.js} +390 -146
- package/dist/chunk-JRZBBPO6.js.map +1 -0
- package/dist/{chunk-WVUSXNIE.js → chunk-MPZUYCAP.js} +9 -2
- package/dist/{chunk-WVUSXNIE.js.map → chunk-MPZUYCAP.js.map} +1 -1
- package/dist/{chunk-SJLTEINJ.js → chunk-OJNTCYQQ.js} +17 -1
- package/dist/chunk-OJNTCYQQ.js.map +1 -0
- package/dist/{chunk-IOODYAXL.js → chunk-OTWLERSW.js} +25 -6
- package/dist/chunk-OTWLERSW.js.map +1 -0
- package/dist/{chunk-AWQPGIR6.js → chunk-PJNENX2A.js} +1535 -422
- package/dist/chunk-PJNENX2A.js.map +1 -0
- package/dist/{chunk-KHE6L6TD.js → chunk-PKHI276N.js} +97 -11
- package/dist/chunk-PKHI276N.js.map +1 -0
- package/dist/{chunk-YHKXNYTB.js → chunk-QF3LSMGS.js} +2 -2
- package/dist/chunk-QXP3Z3JN.js +131 -0
- package/dist/chunk-QXP3Z3JN.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-SFASB5FL.js +69 -0
- package/dist/chunk-SFASB5FL.js.map +1 -0
- package/dist/{chunk-WO5BJNIB.js → chunk-SNNSAGMT.js} +7273 -2741
- package/dist/chunk-SNNSAGMT.js.map +1 -0
- package/dist/{chunk-NZIP4PA2.js → chunk-SO3XRZPX.js} +3 -3
- package/dist/chunk-SYOS5CAC.js +176 -0
- package/dist/chunk-SYOS5CAC.js.map +1 -0
- package/dist/chunk-TAW4UFFF.js +293 -0
- package/dist/chunk-TAW4UFFF.js.map +1 -0
- package/dist/chunk-TF5HCP33.js +271 -0
- package/dist/chunk-TF5HCP33.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-AEG2PXBP.js → chunk-V2LQLN5H.js} +7 -7
- package/dist/{chunk-KYFZTGMC.js → chunk-VJUVFZ2D.js} +5 -3
- package/dist/{chunk-KYFZTGMC.js.map → chunk-VJUVFZ2D.js.map} +1 -1
- package/dist/{chunk-JMM6YE7J.js → chunk-VOZA6O7K.js} +708 -709
- package/dist/chunk-VOZA6O7K.js.map +1 -0
- package/dist/{chunk-5LJCEMFD.js → chunk-VUGQTZ2L.js} +209 -77
- package/dist/chunk-VUGQTZ2L.js.map +1 -0
- package/dist/chunk-WOM257PW.js +393 -0
- package/dist/chunk-WOM257PW.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-XQJXNMSB.js +23 -0
- package/dist/chunk-XQJXNMSB.js.map +1 -0
- package/dist/chunk-Y527D4TV.js +56 -0
- package/dist/chunk-Y527D4TV.js.map +1 -0
- package/dist/{chunk-VUFAK2LW.js → chunk-YUY4SAGM.js} +17 -2
- package/dist/chunk-YUY4SAGM.js.map +1 -0
- package/dist/clack-EZ7TDWQU.js +19 -0
- package/dist/claude-cli-2YKABJJZ.js +31 -0
- package/dist/{cli-O5SN7ZJ4.js → cli-FB4LOA5A.js} +221 -68
- package/dist/{cli-O5SN7ZJ4.js.map → cli-FB4LOA5A.js.map} +1 -1
- package/dist/codex-event-TYVES3UX.js +16 -0
- package/dist/codex-host-WW4H2SKT.js +29 -0
- package/dist/codex-install-2C623HPW.js +393 -0
- package/dist/codex-install-2C623HPW.js.map +1 -0
- package/dist/{config-OJQI27LT.js → config-HOVJFEKD.js} +25 -15
- package/dist/doctor-NKU4V5OV.js +1312 -0
- package/dist/doctor-NKU4V5OV.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-WEV6DMTD.js → fund-WEBHTZGN.js} +38 -30
- package/dist/{fund-WEV6DMTD.js.map → fund-WEBHTZGN.js.map} +1 -1
- package/dist/hook-command-ZA2PNKS6.js +44 -0
- package/dist/hosts/claude/.claude-plugin/marketplace.json +2 -2
- package/dist/hosts/claude/tenjin/.claude-plugin/plugin.json +3 -2
- package/dist/hosts/claude/tenjin/hooks/hooks.json +4 -1
- package/dist/hosts/claude/tenjin/hooks/register.tsx +589 -0
- package/dist/hosts/claude/tenjin/skills/tenjin-pay/SKILL.md +82 -0
- package/dist/hosts/claude/tenjin/types/index.d.ts +41 -0
- package/dist/hosts/codex/.agents/plugins/marketplace.json +20 -0
- package/dist/hosts/codex/tenjin/.codex-plugin/plugin.json +16 -0
- package/dist/hosts/codex/tenjin/.mcp.json +15 -0
- package/dist/hosts/codex/tenjin/hooks/hooks.json +98 -0
- package/dist/hosts-AV5MHBAU.js +38 -0
- package/dist/index.js +28 -8
- package/dist/index.js.map +1 -1
- package/dist/install-PT4EZS4R.js +100 -0
- package/dist/{install-identity-WHPNMNMQ.js → install-identity-5A4OE6YC.js} +13 -8
- package/dist/install-wallet-SAAPKB73.js +281 -0
- package/dist/install-wallet-SAAPKB73.js.map +1 -0
- package/dist/{mcp-QML7ZMPH.js → mcp-HAWKCTPQ.js} +909 -208
- package/dist/mcp-HAWKCTPQ.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-LGKYOEPV.js → package-SR2WB6MK.js} +4 -2
- package/dist/passphrase-IFTDS3CU.js +44 -0
- package/dist/{paths-POPTXJO6.js → paths-XCSAKISU.js} +10 -2
- package/dist/pay-OXC3WKYV.js +55 -0
- package/dist/pay-OXC3WKYV.js.map +1 -0
- package/dist/{payments-C44QUFXU.js → payments-3KHMP2MG.js} +18 -13
- package/dist/{payments-C44QUFXU.js.map → payments-3KHMP2MG.js.map} +1 -1
- package/dist/plugin-registration-N3GRIZVM.js +67 -0
- package/dist/plugin-registration-N3GRIZVM.js.map +1 -0
- package/dist/{redact-6W23GGJC.js → redact-D7ASVWKL.js} +2 -2
- package/dist/redact-D7ASVWKL.js.map +1 -0
- package/dist/runtime-UVNUA3AS.js +1203 -0
- package/dist/runtime-UVNUA3AS.js.map +1 -0
- package/dist/runtime-fetch-EKFRNR6Z.js +20 -0
- package/dist/runtime-fetch-EKFRNR6Z.js.map +1 -0
- package/dist/runtime-layout-BDWZG2TQ.js +25 -0
- package/dist/runtime-layout-BDWZG2TQ.js.map +1 -0
- package/dist/{send-KVJX4XIR.js → send-HMKJLT34.js} +26 -18
- package/dist/{send-KVJX4XIR.js.map → send-HMKJLT34.js.map} +1 -1
- package/dist/{status-S7C3WMSH.js → status-RWXIIWYS.js} +57 -22
- package/dist/status-RWXIIWYS.js.map +1 -0
- package/dist/{status-line-YR2T5HC4.js → status-line-77XYZP7E.js} +13 -8
- package/dist/{status-line-YR2T5HC4.js.map → status-line-77XYZP7E.js.map} +1 -1
- package/dist/uninstall-D5G67UJH.js +480 -0
- package/dist/uninstall-D5G67UJH.js.map +1 -0
- package/dist/update-LRNOEGSB.js +53 -0
- package/dist/update-LRNOEGSB.js.map +1 -0
- package/dist/{usdc-JK4RRFFQ.js → usdc-D6X7EIQ2.js} +7 -8
- package/dist/usdc-D6X7EIQ2.js.map +1 -0
- package/dist/{viemAdapter-By13KInL-X2VY6CY3.js → viemAdapter-By13KInL-RL742ETX.js} +3 -3
- package/dist/viemAdapter-By13KInL-RL742ETX.js.map +1 -0
- package/dist/wallet-XFYC27BR.js +55 -0
- package/dist/wallet-XFYC27BR.js.map +1 -0
- package/dist/wallet-kdf-worker.mjs +8 -8
- package/docs/agent-permissions.md +56 -22
- package/docs/safety-model.md +1 -1
- package/docs/troubleshooting.md +72 -1
- package/package.json +14 -1
- package/dist/alive-3J3CHOQP.js +0 -21
- package/dist/ccip-NLCSCHKI.js +0 -19
- package/dist/chunk-3O2BQIF6.js.map +0 -1
- package/dist/chunk-5IEP5EGE.js +0 -5332
- package/dist/chunk-5IEP5EGE.js.map +0 -1
- package/dist/chunk-5LJCEMFD.js.map +0 -1
- package/dist/chunk-6W5GYG3W.js +0 -128
- package/dist/chunk-6W5GYG3W.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-AKWGE6JQ.js.map +0 -1
- package/dist/chunk-AWQPGIR6.js.map +0 -1
- package/dist/chunk-EGELTSPU.js +0 -2865
- package/dist/chunk-EGELTSPU.js.map +0 -1
- package/dist/chunk-EL56RW2J.js +0 -7611
- package/dist/chunk-EL56RW2J.js.map +0 -1
- package/dist/chunk-HE2MS4QO.js +0 -256
- package/dist/chunk-HE2MS4QO.js.map +0 -1
- package/dist/chunk-IOODYAXL.js.map +0 -1
- package/dist/chunk-JMM6YE7J.js.map +0 -1
- package/dist/chunk-KHE6L6TD.js.map +0 -1
- package/dist/chunk-N35E6CM2.js +0 -1185
- package/dist/chunk-N35E6CM2.js.map +0 -1
- package/dist/chunk-O2FRQ2L2.js.map +0 -1
- package/dist/chunk-OK2TDZQU.js.map +0 -1
- package/dist/chunk-OSYTBCUC.js.map +0 -1
- package/dist/chunk-PAYV4XUA.js.map +0 -1
- package/dist/chunk-SJLTEINJ.js.map +0 -1
- package/dist/chunk-TTBKWWTV.js.map +0 -1
- package/dist/chunk-TTNESUPQ.js.map +0 -1
- package/dist/chunk-U6YQ6FRI.js.map +0 -1
- package/dist/chunk-VUFAK2LW.js.map +0 -1
- package/dist/chunk-VZGAONSJ.js.map +0 -1
- package/dist/chunk-WO5BJNIB.js.map +0 -1
- package/dist/doctor-IQQJHGGM.js +0 -590
- package/dist/doctor-IQQJHGGM.js.map +0 -1
- package/dist/hook-command-D2P3ILRV.js +0 -32
- package/dist/install-TUCRF32I.js +0 -60
- package/dist/install-wallet-MA27FTQ5.js +0 -113
- package/dist/install-wallet-MA27FTQ5.js.map +0 -1
- package/dist/mcp-QML7ZMPH.js.map +0 -1
- package/dist/pay-2C2UBBXJ.js +0 -51
- package/dist/status-S7C3WMSH.js.map +0 -1
- package/dist/uninstall-HY6LKIIT.js +0 -149
- package/dist/uninstall-HY6LKIIT.js.map +0 -1
- package/dist/update-OJV22LR3.js +0 -36
- package/dist/wallet-PD2IMZDU.js +0 -39
- /package/dist/{_esm-CE7KNONL.js.map → _esm-RLLC72MS.js.map} +0 -0
- /package/dist/{alive-3J3CHOQP.js.map → alive-MROUMFH3.js.map} +0 -0
- /package/dist/{ccip-7RMRLAGV.js.map → auto-update-OPWMRZLS.js.map} +0 -0
- /package/dist/{ccip-NLCSCHKI.js.map → ccip-DHDFKTQV.js.map} +0 -0
- /package/dist/{chunk-LFZJM56J.js.map → chunk-445VQTVM.js.map} +0 -0
- /package/dist/{chunk-RAULEAZ6.js.map → chunk-4USCZ2NI.js.map} +0 -0
- /package/dist/{chunk-VFMQTSXG.js.map → chunk-D3ZURCG7.js.map} +0 -0
- /package/dist/{chunk-ORWL5BSN.js.map → chunk-HGZEPQUT.js.map} +0 -0
- /package/dist/{chunk-EBVIKMCH.js.map → chunk-JKKAIPTU.js.map} +0 -0
- /package/dist/{chunk-YHKXNYTB.js.map → chunk-QF3LSMGS.js.map} +0 -0
- /package/dist/{chunk-NZIP4PA2.js.map → chunk-SO3XRZPX.js.map} +0 -0
- /package/dist/{chunk-AEG2PXBP.js.map → chunk-V2LQLN5H.js.map} +0 -0
- /package/dist/{config-OJQI27LT.js.map → clack-EZ7TDWQU.js.map} +0 -0
- /package/dist/{env-proxy-XL4P73MZ.js.map → claude-cli-2YKABJJZ.js.map} +0 -0
- /package/dist/{ethersCompat-Df4a6QIZ-THAVUGIJ.js.map → codex-event-TYVES3UX.js.map} +0 -0
- /package/dist/{hook-command-D2P3ILRV.js.map → codex-host-WW4H2SKT.js.map} +0 -0
- /package/dist/{install-TUCRF32I.js.map → config-HOVJFEKD.js.map} +0 -0
- /package/dist/{install-identity-WHPNMNMQ.js.map → env-proxy-R6ZMLQTT.js.map} +0 -0
- /package/dist/{package-LGKYOEPV.js.map → ethersCompat-Df4a6QIZ-X6YZWAML.js.map} +0 -0
- /package/dist/{paths-POPTXJO6.js.map → hook-command-ZA2PNKS6.js.map} +0 -0
- /package/dist/{pay-2C2UBBXJ.js.map → hosts-AV5MHBAU.js.map} +0 -0
- /package/dist/{redact-6W23GGJC.js.map → install-PT4EZS4R.js.map} +0 -0
- /package/dist/{update-OJV22LR3.js.map → install-identity-5A4OE6YC.js.map} +0 -0
- /package/dist/{usdc-JK4RRFFQ.js.map → package-SR2WB6MK.js.map} +0 -0
- /package/dist/{viemAdapter-By13KInL-X2VY6CY3.js.map → passphrase-IFTDS3CU.js.map} +0 -0
- /package/dist/{wallet-PD2IMZDU.js.map → paths-XCSAKISU.js.map} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/router/router-observation.ts"],"sourcesContent":["import { readFile, readdir, rm } from 'node:fs/promises';\nimport { rmSync } from 'node:fs';\nimport { join } from 'node:path';\nimport { z } from 'zod';\nimport { writeFileAtomic } from '../lib/atomic-json';\nimport { hasCode } from '../lib/errno';\nimport type { SigningSource } from '../lib/wallet-unlock';\n\n/**\n * WHAT THE RUNNING `tenjin mcp` SAW, for the processes that cannot ask it.\n * Doctor runs in a shell, `alive` and the hooks run as their own processes,\n * and none of them can see the router Claude Code started: its environment,\n * its keychain answer, its verdict. So the router writes them down:\n *\n * <dataDir>/router/live/<pid>.json one per running `tenjin mcp`; removed on exit\n * <dataDir>/router/unlock-state.json the latest unlock verdict per address;\n * survives the process\n *\n * Both are 0600 in a 0700 directory, and neither ever holds a passphrase, a\n * key, an env VALUE or a store's stdout: only whether a variable is set, the\n * address, the cwd and verdicts.\n *\n * A HEALTH-CHECK ROUTER IS NOT A SESSION (B2). `claude mcp get` and `claude mcp\n * list` start a `tenjin mcp` that serves no hook. Its observation says\n * `servedSession: false` until it serves a hook call carrying a valid\n * session_id, and every reader that means \"the running Claude session\" keeps\n * only `servedSession: true` ({@link servedObservations}). Only a served\n * router reads or writes unlock-state.\n *\n * Hook-safe: node, zod and `lib/atomic-json` only. Every reader treats any\n * I/O error as \"absent\", and the writers swallow theirs: these files are\n * advisory, and a router must never fail a lookup because it could not\n * describe itself.\n */\n\nexport interface RouterObservation {\n version: 1;\n pid: number;\n startedAt: number;\n at: number;\n cliVersion: string;\n harness: 'claude' | 'codex';\n launchedByPlugin: boolean;\n cwd: string;\n address: string | null;\n /** B2: false until this router has served a hook call carrying a valid session_id. Readers that mean\n * \"the running Claude session\" ignore false. */\n servedSession: boolean;\n env: { passphraseSet: boolean; keySet: boolean };\n sign: {\n status: 'ready' | 'blocked' | 'unknown' | 'pending';\n reason?: string;\n detail?: string;\n fix?: string;\n source?: SigningSource;\n };\n routing?: { status: 'ready' | 'blocked' | 'unknown'; reason?: string; at: number };\n}\n\nexport interface UnlockInputs {\n envPassphraseSet: boolean;\n envKeySet: boolean;\n walletMtimeMs: number | null;\n sidecarMtimeMs: number | null;\n cliVersion: string;\n}\n\nexport interface UnlockRecord {\n version: 1;\n address: string;\n status: 'ready' | 'blocked' | 'unknown' | 'awaiting_confirmation';\n reason?: string;\n at: number;\n inputs?: UnlockInputs;\n}\n\nconst SIGNING_SOURCES = [\n 'key-env',\n 'passphrase-env',\n 'keychain',\n 'secret-service',\n 'dpapi',\n 'file',\n 'legacy',\n] as const;\n\nconst ObservationSchema = z.object({\n version: z.literal(1),\n pid: z.number().int().positive(),\n startedAt: z.number(),\n at: z.number(),\n cliVersion: z.string(),\n harness: z.enum(['claude', 'codex']),\n launchedByPlugin: z.boolean(),\n cwd: z.string(),\n address: z.string().nullable(),\n servedSession: z.boolean(),\n env: z.object({ passphraseSet: z.boolean(), keySet: z.boolean() }),\n sign: z.object({\n status: z.enum(['ready', 'blocked', 'unknown', 'pending']),\n reason: z.string().optional(),\n detail: z.string().optional(),\n fix: z.string().optional(),\n source: z.enum(SIGNING_SOURCES).optional(),\n }),\n routing: z\n .object({\n status: z.enum(['ready', 'blocked', 'unknown']),\n reason: z.string().optional(),\n at: z.number(),\n })\n .optional(),\n});\n\nconst UnlockRecordSchema = z.object({\n version: z.literal(1),\n address: z.string(),\n status: z.enum(['ready', 'blocked', 'unknown', 'awaiting_confirmation']),\n reason: z.string().optional(),\n at: z.number(),\n inputs: z\n .object({\n envPassphraseSet: z.boolean(),\n envKeySet: z.boolean(),\n walletMtimeMs: z.number().nullable(),\n sidecarMtimeMs: z.number().nullable(),\n cliVersion: z.string(),\n })\n .optional(),\n});\n\n/** The envelope; records are checked one at a time so one bad entry hides only itself. */\nconst UnlockStateSchema = z.object({\n version: z.literal(1),\n wallets: z.record(z.string(), z.unknown()),\n});\n\nconst OBSERVATION_NAME = /^(\\d+)\\.json$/;\n/** How far a ps start time may sit from the observation's before the pid is another process. */\nconst START_SLACK_MS = 2000;\n\n/** Where the running routers' observations live. */\nexport function liveDir(dataDir: string): string {\n return join(dataDir, 'router', 'live');\n}\n\nfunction observationPath(dataDir: string, pid: number): string {\n return join(liveDir(dataDir), `${pid}.json`);\n}\n\nfunction unlockStatePath(dataDir: string): string {\n return join(dataDir, 'router', 'unlock-state.json');\n}\n\n/** Write this router's observation. Swallows errors: it is advisory. */\nexport async function writeObservation(dataDir: string, obs: RouterObservation): Promise<void> {\n try {\n await writeFileAtomic(observationPath(dataDir, obs.pid), JSON.stringify(obs) + '\\n', {\n mode: 0o600,\n dirMode: 0o700,\n });\n } catch {\n // A router that cannot describe itself still routes.\n }\n}\n\n/** Remove a router's observation, synchronously, for the process 'exit' handler. */\nexport function removeObservationSync(dataDir: string, pid: number): void {\n try {\n rmSync(observationPath(dataDir, pid), { force: true });\n } catch {\n // Nothing to do at exit; pruneDeadObservations clears it later.\n }\n}\n\n/**\n * Unlink the observations whose pid is no longer alive: a router killed\n * without running its exit handler (SIGKILL, a crash) leaves its file behind.\n */\nexport async function pruneDeadObservations(\n dataDir: string,\n isAlive: (pid: number) => boolean = pidAlive,\n): Promise<void> {\n const dir = liveDir(dataDir);\n const names = await readdir(dir).catch(() => [] as string[]);\n for (const name of names) {\n const match = OBSERVATION_NAME.exec(name);\n if (match === null) continue;\n if (isAlive(Number(match[1]))) continue;\n await rm(join(dir, name), { force: true }).catch(() => undefined);\n }\n}\n\n/**\n * Every well-formed observation on disk, shape-checked, with no liveness\n * filter (see {@link liveObservations}). Dropped: a file not named\n * `<digits>.json`, one whose `pid` is not its name, any version but 1, a\n * malformed shape, and one without a boolean `servedSession` (B2: an\n * observation that cannot say whether it served a session is not one).\n */\nexport async function readObservations(dataDir: string): Promise<RouterObservation[]> {\n const dir = liveDir(dataDir);\n const names = await readdir(dir).catch(() => [] as string[]);\n const out: RouterObservation[] = [];\n for (const name of names.sort()) {\n const match = OBSERVATION_NAME.exec(name);\n if (match === null) continue;\n try {\n const parsed = ObservationSchema.safeParse(\n JSON.parse(await readFile(join(dir, name), 'utf8')),\n );\n if (parsed.success && parsed.data.pid === Number(match[1])) {\n out.push(parsed.data as RouterObservation);\n }\n } catch {\n // Unreadable or not JSON: absent.\n }\n }\n return out;\n}\n\n/** The observations that count as a running Claude session: harness 'claude' and servedSession true (B2). */\nexport function servedObservations(obs: RouterObservation[]): RouterObservation[] {\n return obs.filter((o) => o.harness === 'claude' && o.servedSession === true);\n}\n\n/**\n * Keep the observations whose router is still running.\n *\n * With a ps snapshot, the pid must be a listed router (the snapshot lists only\n * live, non-zombie routers) whose start time is within 2 s of the\n * observation's own: a pid the OS has since handed to another router is not\n * this one. A listed router whose start time ps could not give (null) is kept\n * on the pid alone. Without a snapshot (null: ps could not run), `alive`.\n */\nexport function liveObservations(\n obs: RouterObservation[],\n routers: Array<{ pid: number; startedAt: number | null }> | null,\n alive: (pid: number) => boolean = pidAlive,\n): RouterObservation[] {\n if (routers === null) return obs.filter((o) => alive(o.pid));\n return obs.filter((o) => {\n const router = routers.find((r) => r.pid === o.pid);\n if (router === undefined) return false;\n return router.startedAt === null || Math.abs(router.startedAt - o.startedAt) <= START_SLACK_MS;\n });\n}\n\n/**\n * Whether a process with this pid exists: `kill(pid, 0)` sends nothing and\n * only checks. EPERM means it exists under another user, so it counts as\n * alive; ESRCH (and anything else) as gone. Never true for a pid that is not\n * a positive integer, since `kill(0, …)` addresses the whole process group.\n */\nexport function pidAlive(pid: number): boolean {\n if (!Number.isInteger(pid) || pid <= 0) return false;\n try {\n process.kill(pid, 0);\n return true;\n } catch (err) {\n return hasCode(err, 'EPERM');\n }\n}\n\nasync function readUnlockWallets(dataDir: string): Promise<Record<string, unknown> | null> {\n try {\n const parsed = UnlockStateSchema.safeParse(\n JSON.parse(await readFile(unlockStatePath(dataDir), 'utf8')),\n );\n return parsed.success ? parsed.data.wallets : null;\n } catch {\n return null;\n }\n}\n\n/** The latest unlock record for `address` (any case), or null. */\nexport async function readUnlockRecord(\n dataDir: string,\n address: string,\n): Promise<UnlockRecord | null> {\n const wallets = await readUnlockWallets(dataDir);\n if (wallets === null) return null;\n const parsed = UnlockRecordSchema.safeParse(wallets[address.toLowerCase()]);\n return parsed.success ? (parsed.data as UnlockRecord) : null;\n}\n\n/**\n * Record `rec` under its lowercase address, keeping every other address's\n * record. Swallows errors: unlock-state is advisory, and a repair that saved\n * the passphrase must not fail because this file could not be written. Two\n * routers writing at once can lose one update; the next verdict rewrites it.\n */\nexport async function writeUnlockRecord(dataDir: string, rec: UnlockRecord): Promise<void> {\n try {\n const wallets = { ...((await readUnlockWallets(dataDir)) ?? {}) };\n wallets[rec.address.toLowerCase()] = rec;\n await writeFileAtomic(\n unlockStatePath(dataDir),\n JSON.stringify({ version: 1, wallets }, null, 2) + '\\n',\n { mode: 0o600, dirMode: 0o700 },\n );\n } catch {\n // Advisory: see above.\n }\n}\n\n/**\n * After `tenjin wallet repair`: the next served router's verdict for this\n * address decides whether \"Tenjin wallet unlocked.\" is said (decision 14).\n */\nexport async function markUnlockPending(\n dataDir: string,\n address: string,\n now: number = Date.now(),\n): Promise<void> {\n await writeUnlockRecord(dataDir, {\n version: 1,\n address,\n status: 'awaiting_confirmation',\n at: now,\n });\n}\n"],"mappings":";;;;;;;;;;;;AAAA,SAAS,UAAU,SAAS,UAAU;AACtC,SAAS,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KAAK,IAAI,GACR;AACf,QAAM,kBAAkB,SAAS;AAAA,IAC/B,SAAS;AAAA,IACT;AAAA,IACA,QAAQ;AAAA,IACR,IAAI;AAAA,EACN,CAAC;AACH;","names":[]}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { createRequire as __tenjinCreateRequire } from 'node:module'; const require = __tenjinCreateRequire(import.meta.url);
|
|
2
|
+
import {
|
|
3
|
+
CliError
|
|
4
|
+
} from "./chunk-3UCIG4TG.js";
|
|
5
|
+
|
|
6
|
+
// src/lib/wallet-unlock.ts
|
|
7
|
+
var UNLOCK_REASONS = /* @__PURE__ */ new Set([
|
|
8
|
+
"no_wallet",
|
|
9
|
+
"wallet_corrupt",
|
|
10
|
+
"env_key_invalid",
|
|
11
|
+
"passphrase_missing",
|
|
12
|
+
"passphrase_wrong",
|
|
13
|
+
"env_passphrase_wrong",
|
|
14
|
+
"keychain_locked",
|
|
15
|
+
"unlock_timeout"
|
|
16
|
+
]);
|
|
17
|
+
var PASSPHRASE_LABELS = /* @__PURE__ */ new Set([
|
|
18
|
+
"env",
|
|
19
|
+
"keychain",
|
|
20
|
+
"secret-service",
|
|
21
|
+
"dpapi",
|
|
22
|
+
"file",
|
|
23
|
+
"legacy",
|
|
24
|
+
"prompt"
|
|
25
|
+
]);
|
|
26
|
+
var DEFINITE_UNLOCK = /* @__PURE__ */ new Set([
|
|
27
|
+
"no_wallet",
|
|
28
|
+
"wallet_corrupt",
|
|
29
|
+
"env_key_invalid",
|
|
30
|
+
"passphrase_missing",
|
|
31
|
+
"passphrase_wrong",
|
|
32
|
+
"env_passphrase_wrong"
|
|
33
|
+
]);
|
|
34
|
+
var ENV_PASSPHRASE_WRONG = "TENJIN_WALLET_PASSPHRASE is set but wrong; remove it.";
|
|
35
|
+
var REPAIR_CLAUSE = "(it asks for the passphrase in your terminal; never paste it into chat)";
|
|
36
|
+
var REPAIR_IN_TERMINAL = `Run \`tenjin wallet repair\` yourself ${REPAIR_CLAUSE}.`;
|
|
37
|
+
var KEYCHAIN_LOCKED_FIX = "Unlock your keychain (or log in to the desktop session) and retry.";
|
|
38
|
+
function FILE_STORE_FAILED_FIX(path) {
|
|
39
|
+
const dir = path.replace(/[/\\][^/\\]*$/, "") || "/";
|
|
40
|
+
return `Tenjin could not save the passphrase to ${path}; check that ${dir} is writable.`;
|
|
41
|
+
}
|
|
42
|
+
var KEYCHAIN_WAIT_LINE = "Waiting for the keychain\u2026";
|
|
43
|
+
function NO_KEYRING_LINE(path) {
|
|
44
|
+
return `No keyring reachable from this session; passphrase saved to ${path} (readable only by you).`;
|
|
45
|
+
}
|
|
46
|
+
var PRIVATE_KEY_RE = /^0x[0-9a-f]{64}$/i;
|
|
47
|
+
function unlockDetails(reason, source) {
|
|
48
|
+
return { unlock: source === void 0 ? { reason } : { reason, source } };
|
|
49
|
+
}
|
|
50
|
+
function isUnlockDetails(value) {
|
|
51
|
+
if (typeof value !== "object" || value === null) return false;
|
|
52
|
+
const { reason, source } = value;
|
|
53
|
+
if (typeof reason !== "string" || !UNLOCK_REASONS.has(reason)) return false;
|
|
54
|
+
return source === void 0 || typeof source === "string" && PASSPHRASE_LABELS.has(source);
|
|
55
|
+
}
|
|
56
|
+
function detailsOf(err) {
|
|
57
|
+
if (!(err instanceof CliError)) return void 0;
|
|
58
|
+
const unlock = err.details?.unlock;
|
|
59
|
+
return isUnlockDetails(unlock) ? unlock : void 0;
|
|
60
|
+
}
|
|
61
|
+
function classifyUnlockError(err) {
|
|
62
|
+
const unlock = detailsOf(err);
|
|
63
|
+
if (unlock !== void 0) {
|
|
64
|
+
return {
|
|
65
|
+
reason: unlock.reason,
|
|
66
|
+
definite: DEFINITE_UNLOCK.has(unlock.reason),
|
|
67
|
+
...unlock.source !== void 0 ? { source: unlock.source } : {}
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
if (err instanceof CliError && err.code === "WALLET_MISSING") {
|
|
71
|
+
return { reason: "no_wallet", definite: true };
|
|
72
|
+
}
|
|
73
|
+
const name = err?.name;
|
|
74
|
+
if (name === "AbortError" || name === "TimeoutError") {
|
|
75
|
+
return { reason: "unlock_timeout", definite: false };
|
|
76
|
+
}
|
|
77
|
+
return { reason: "wallet_locked", definite: false };
|
|
78
|
+
}
|
|
79
|
+
function unlockReasonOf(err) {
|
|
80
|
+
return detailsOf(err)?.reason ?? null;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export {
|
|
84
|
+
DEFINITE_UNLOCK,
|
|
85
|
+
ENV_PASSPHRASE_WRONG,
|
|
86
|
+
REPAIR_CLAUSE,
|
|
87
|
+
REPAIR_IN_TERMINAL,
|
|
88
|
+
KEYCHAIN_LOCKED_FIX,
|
|
89
|
+
FILE_STORE_FAILED_FIX,
|
|
90
|
+
KEYCHAIN_WAIT_LINE,
|
|
91
|
+
NO_KEYRING_LINE,
|
|
92
|
+
PRIVATE_KEY_RE,
|
|
93
|
+
unlockDetails,
|
|
94
|
+
classifyUnlockError,
|
|
95
|
+
unlockReasonOf
|
|
96
|
+
};
|
|
97
|
+
//# sourceMappingURL=chunk-X5ZBP3IY.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/lib/wallet-unlock.ts"],"sourcesContent":["import { CliError } from './errors';\n\n/**\n * WHY A WALLET COULD NOT SIGN, AS ONE VOCABULARY. The wallet layer throws with\n * it, the routing payer skips with it, the hooks gate and word notices with it,\n * and doctor renders it, so every surface names the same cause the same way.\n *\n * HOOK-SAFE ON PURPOSE: it imports `./errors` and nothing else. `tenjin hook`,\n * `alive` and the status line read these reasons, and their chunk graph must\n * stay free of `src/lib/wallet/`, viem, ox and the x402 SDK\n * (`src/router/dist-chunks.test.ts`). That is why the reasons live here and not\n * beside the wallet code that produces them.\n *\n * Six reasons are DEFINITE (this wallet cannot sign until a person fixes\n * something) and two are not (`keychain_locked`, `unlock_timeout`: the store or\n * the clock did not answer, which says nothing about the wallet). Only a\n * definite reason may withhold an offer or skip a routing attempt.\n */\nexport type UnlockReason =\n | 'no_wallet'\n | 'wallet_corrupt'\n | 'env_key_invalid'\n | 'passphrase_missing'\n | 'passphrase_wrong'\n | 'env_passphrase_wrong'\n | 'keychain_locked'\n | 'unlock_timeout';\n\nconst UNLOCK_REASONS: ReadonlySet<string> = new Set<UnlockReason>([\n 'no_wallet',\n 'wallet_corrupt',\n 'env_key_invalid',\n 'passphrase_missing',\n 'passphrase_wrong',\n 'env_passphrase_wrong',\n 'keychain_locked',\n 'unlock_timeout',\n]);\n\n/** A store that keeps a wallet's passphrase across sessions: the platform's own\n * credential store, or the 0600 file where there is none. */\nexport type DurableStore = 'keychain' | 'secret-service' | 'dpapi' | 'file';\n\n/** Where a passphrase came from, for messages; 'legacy' = the pre-per-wallet shared slot. */\nexport type PassphraseLabel = 'env' | DurableStore | 'legacy' | 'prompt';\n\nconst PASSPHRASE_LABELS: ReadonlySet<string> = new Set<PassphraseLabel>([\n 'env',\n 'keychain',\n 'secret-service',\n 'dpapi',\n 'file',\n 'legacy',\n 'prompt',\n]);\n\n/**\n * What actually produced a signature, as doctor, install and the router report\n * it. Defined here rather than in `src/router/eligibility.ts` (which re-exports\n * it) because `src/lib/wallet/provider.ts` needs it too, and lib must not\n * import router.\n */\nexport type SigningSource = 'key-env' | 'passphrase-env' | DurableStore | 'legacy';\n\n/** The cause a wallet throw site attaches as `CliError.details.unlock`. */\nexport interface UnlockDetails {\n reason: UnlockReason;\n source?: PassphraseLabel;\n}\n\n/** Every reason except the two that say the store or the clock did not answer. */\nexport const DEFINITE_UNLOCK: ReadonlySet<UnlockReason> = new Set<UnlockReason>([\n 'no_wallet',\n 'wallet_corrupt',\n 'env_key_invalid',\n 'passphrase_missing',\n 'passphrase_wrong',\n 'env_passphrase_wrong',\n]);\n\n/** Said once when TENJIN_WALLET_PASSPHRASE did not open the wallet and a saved\n * passphrase did: the wallet works, the variable is the thing to remove. */\nexport const ENV_PASSPHRASE_WRONG = 'TENJIN_WALLET_PASSPHRASE is set but wrong; remove it.';\n\n/**\n * Carried by every person-facing string that names `tenjin wallet repair` (B1,\n * decision 15). A passphrase never goes on a command line or into chat: repair\n * asks for it at a hidden prompt, and this clause tells the person so before an\n * agent can suggest otherwise.\n */\nexport const REPAIR_CLAUSE =\n '(it asks for the passphrase in your terminal; never paste it into chat)';\n\n/** The person's fix for a wallet whose saved passphrase is gone or wrong. */\nexport const REPAIR_IN_TERMINAL =\n `Run \\`tenjin wallet repair\\` yourself ${REPAIR_CLAUSE}.` as const;\n\n/**\n * The only fix for a keychain that exists but did not answer (S3). It never\n * points at the plaintext file or at another passphrase: a locked keychain is\n * unlocked, not routed around.\n */\nexport const KEYCHAIN_LOCKED_FIX =\n 'Unlock your keychain (or log in to the desktop session) and retry.';\n\n/**\n * A failed FILE-store write at create or repair (decision 6). Never used for an\n * OS store: there is no keychain to unlock when the file could not be written.\n */\nexport function FILE_STORE_FAILED_FIX(path: string): string {\n // The file's own folder (`TENJIN_DATA_DIR` moves it), cut by hand: this module imports nothing.\n const dir = path.replace(/[/\\\\][^/\\\\]*$/, '') || '/';\n return `Tenjin could not save the passphrase to ${path}; check that ${dir} is writable.`;\n}\n\n/** Shown once when create or repair has waited on the keychain for a second at a terminal. */\nexport const KEYCHAIN_WAIT_LINE = 'Waiting for the keychain…';\n\n/** Why a passphrase went to the 0600 file: no OS store answered the probe as present (S4). */\nexport function NO_KEYRING_LINE(path: string): string {\n return `No keyring reachable from this session; passphrase saved to ${path} (readable only by you).`;\n}\n\n/**\n * THE one TENJIN_WALLET_KEY expression (S12): a 0x-prefixed 32-byte hex private\n * key, case-insensitive. Moved here from `src/lib/wallet/store.ts` unchanged, and\n * store.ts re-exports it, so the wallet layer's `loadCredential` and the\n * hook-safe `wallet-facts.ts` test exactly the same thing. Do not tighten it in\n * one place only: a key one accepts and the other rejects is a wallet doctor\n * calls fine and the hooks call broken.\n */\nexport const PRIVATE_KEY_RE = /^0x[0-9a-f]{64}$/i;\n\n/** `{ unlock: { reason, source } }`, the value every wallet throw site passes as CliError `details`. */\nexport function unlockDetails(\n reason: UnlockReason,\n source?: PassphraseLabel,\n): { unlock: UnlockDetails } {\n return { unlock: source === undefined ? { reason } : { reason, source } };\n}\n\n/** Whether `value` is a well-formed `details.unlock`: a known reason, and a known source if any. */\nfunction isUnlockDetails(value: unknown): value is UnlockDetails {\n if (typeof value !== 'object' || value === null) return false;\n const { reason, source } = value as { reason?: unknown; source?: unknown };\n if (typeof reason !== 'string' || !UNLOCK_REASONS.has(reason)) return false;\n return source === undefined || (typeof source === 'string' && PASSPHRASE_LABELS.has(source));\n}\n\n/** `details.unlock` of a CliError that carries a valid one, else undefined. */\nfunction detailsOf(err: unknown): UnlockDetails | undefined {\n if (!(err instanceof CliError)) return undefined;\n const unlock = (err.details as { unlock?: unknown } | null | undefined)?.unlock;\n return isUnlockDetails(unlock) ? unlock : undefined;\n}\n\n/**\n * WHAT AN UNLOCK FAILURE MEANS, for gating and wording. In order:\n * `details.unlock` when the thrower classified it; `WALLET_MISSING` is\n * `no_wallet`; an AbortError or TimeoutError is `unlock_timeout`. ANY other\n * error, an undetailed CliError included, is `wallet_locked`, which is never\n * definite: nobody said why, so nothing may be withheld on its account.\n *\n * It never matches on message text. A message is wording, free to change; a\n * reason that hung on it would turn a copy edit into a gating change.\n */\nexport function classifyUnlockError(err: unknown): {\n reason: UnlockReason | 'wallet_locked';\n definite: boolean;\n source?: PassphraseLabel;\n} {\n const unlock = detailsOf(err);\n if (unlock !== undefined) {\n return {\n reason: unlock.reason,\n definite: DEFINITE_UNLOCK.has(unlock.reason),\n ...(unlock.source !== undefined ? { source: unlock.source } : {}),\n };\n }\n if (err instanceof CliError && err.code === 'WALLET_MISSING') {\n return { reason: 'no_wallet', definite: true };\n }\n const name = (err as { name?: unknown } | null | undefined)?.name;\n // By name, not class: a DOMException from AbortSignal.timeout and a\n // hand-made Error named AbortError mean the same thing here.\n if (name === 'AbortError' || name === 'TimeoutError') {\n return { reason: 'unlock_timeout', definite: false };\n }\n return { reason: 'wallet_locked', definite: false };\n}\n\n/**\n * `details.unlock.reason` when `err` is a CliError carrying a valid\n * `details.unlock`; null for anything else (an undetailed WALLET_MISSING, an\n * AbortError, any other CliError or value).\n *\n * THE ONLY GATE for swapping a fix to its model-facing `agentFix` (B1). Not\n * {@link classifyUnlockError}: its `wallet_locked` fallback covers EVERY\n * undetailed error, a `REGISTRY_MISMATCH` or an HTTP failure included, and\n * swapping on it would replace those errors' own fixes with wallet advice.\n */\nexport function unlockReasonOf(err: unknown): UnlockReason | null {\n return detailsOf(err)?.reason ?? null;\n}\n"],"mappings":";;;;;;AA4BA,IAAM,iBAAsC,oBAAI,IAAkB;AAAA,EAChE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,CAAC;AASD,IAAM,oBAAyC,oBAAI,IAAqB;AAAA,EACtE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,CAAC;AAiBM,IAAM,kBAA6C,oBAAI,IAAkB;AAAA,EAC9E;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,CAAC;AAIM,IAAM,uBAAuB;AAQ7B,IAAM,gBACX;AAGK,IAAM,qBACX,yCAAyC,aAAa;AAOjD,IAAM,sBACX;AAMK,SAAS,sBAAsB,MAAsB;AAE1D,QAAM,MAAM,KAAK,QAAQ,iBAAiB,EAAE,KAAK;AACjD,SAAO,2CAA2C,IAAI,gBAAgB,GAAG;AAC3E;AAGO,IAAM,qBAAqB;AAG3B,SAAS,gBAAgB,MAAsB;AACpD,SAAO,+DAA+D,IAAI;AAC5E;AAUO,IAAM,iBAAiB;AAGvB,SAAS,cACd,QACA,QAC2B;AAC3B,SAAO,EAAE,QAAQ,WAAW,SAAY,EAAE,OAAO,IAAI,EAAE,QAAQ,OAAO,EAAE;AAC1E;AAGA,SAAS,gBAAgB,OAAwC;AAC/D,MAAI,OAAO,UAAU,YAAY,UAAU,KAAM,QAAO;AACxD,QAAM,EAAE,QAAQ,OAAO,IAAI;AAC3B,MAAI,OAAO,WAAW,YAAY,CAAC,eAAe,IAAI,MAAM,EAAG,QAAO;AACtE,SAAO,WAAW,UAAc,OAAO,WAAW,YAAY,kBAAkB,IAAI,MAAM;AAC5F;AAGA,SAAS,UAAU,KAAyC;AAC1D,MAAI,EAAE,eAAe,UAAW,QAAO;AACvC,QAAM,SAAU,IAAI,SAAqD;AACzE,SAAO,gBAAgB,MAAM,IAAI,SAAS;AAC5C;AAYO,SAAS,oBAAoB,KAIlC;AACA,QAAM,SAAS,UAAU,GAAG;AAC5B,MAAI,WAAW,QAAW;AACxB,WAAO;AAAA,MACL,QAAQ,OAAO;AAAA,MACf,UAAU,gBAAgB,IAAI,OAAO,MAAM;AAAA,MAC3C,GAAI,OAAO,WAAW,SAAY,EAAE,QAAQ,OAAO,OAAO,IAAI,CAAC;AAAA,IACjE;AAAA,EACF;AACA,MAAI,eAAe,YAAY,IAAI,SAAS,kBAAkB;AAC5D,WAAO,EAAE,QAAQ,aAAa,UAAU,KAAK;AAAA,EAC/C;AACA,QAAM,OAAQ,KAA+C;AAG7D,MAAI,SAAS,gBAAgB,SAAS,gBAAgB;AACpD,WAAO,EAAE,QAAQ,kBAAkB,UAAU,MAAM;AAAA,EACrD;AACA,SAAO,EAAE,QAAQ,iBAAiB,UAAU,MAAM;AACpD;AAYO,SAAS,eAAe,KAAmC;AAChE,SAAO,UAAU,GAAG,GAAG,UAAU;AACnC;","names":[]}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { createRequire as __tenjinCreateRequire } from 'node:module'; const require = __tenjinCreateRequire(import.meta.url);
|
|
2
|
+
|
|
3
|
+
// src/lib/production-origin.ts
|
|
4
|
+
var PRODUCTION_ORIGIN = "https://tenjin.sh";
|
|
5
|
+
var PRODUCTION_HOST = new URL(PRODUCTION_ORIGIN).host;
|
|
6
|
+
var KNOWN_DEPLOYMENT_ORIGINS = /* @__PURE__ */ new Set([
|
|
7
|
+
PRODUCTION_ORIGIN,
|
|
8
|
+
"https://tenjin.blog"
|
|
9
|
+
]);
|
|
10
|
+
function isSameDeployment(a, b) {
|
|
11
|
+
if (a === b) return true;
|
|
12
|
+
return KNOWN_DEPLOYMENT_ORIGINS.has(a) && KNOWN_DEPLOYMENT_ORIGINS.has(b);
|
|
13
|
+
}
|
|
14
|
+
function knownDeploymentOrigins() {
|
|
15
|
+
return [...KNOWN_DEPLOYMENT_ORIGINS];
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export {
|
|
19
|
+
PRODUCTION_ORIGIN,
|
|
20
|
+
isSameDeployment,
|
|
21
|
+
knownDeploymentOrigins
|
|
22
|
+
};
|
|
23
|
+
//# sourceMappingURL=chunk-XQJXNMSB.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/lib/production-origin.ts"],"sourcesContent":["/**\n * The one place the production Tenjin origin is written down. Every shipped\n * default, fallback, identity string, and piece of operator copy that names the\n * live site derives from here; `production-origin.test.ts` keeps it that way.\n *\n * This is NOT the base URL a command talks to. Ordinary requests resolve\n * `baseUrl` through config/flag/env precedence (`CONFIG_DEFAULTS.baseUrl` merely\n * starts from this value); `fund` alone pins production with no override surface\n * at all (owner decision, 2026-08-12) because its mint signs with the wallet key.\n * `fund.test.ts` and `client-meta.test.ts` each hold their own written-out copy,\n * so flipping this line alone reds the suite instead of moving the money path.\n */\nexport const PRODUCTION_ORIGIN = 'https://tenjin.sh';\n\n/**\n * The bare host, for prose and messages that name the site rather than link to\n * it. Derived, not written twice: a flip cannot leave the two disagreeing.\n */\nexport const PRODUCTION_HOST = new URL(PRODUCTION_ORIGIN).host;\n\n/**\n * Every origin the ONE production deployment answers on, as `URL.origin` spells\n * it. Membership means a request to any of them reaches the same server,\n * publishers, prices, and SIWX domain acceptance. It exists because the server\n * builds candidate URLs from its own `NEXT_PUBLIC_APP_URL`, not the request\n * host, so the moment tenjin#402 flips that global a CLI on the other origin\n * sees every candidate as off-origin (tenjin#738).\n *\n * Membership is NOT trust and NOT an allowlist of places the CLI may pay, but it\n * IS the widest set a wallet-signed credential can reach, so widening it is a\n * security change. Removal runbook: docs/safety-model.md.\n */\nconst KNOWN_DEPLOYMENT_ORIGINS: ReadonlySet<string> = new Set([\n PRODUCTION_ORIGIN,\n 'https://tenjin.blog',\n]);\n\n/**\n * Do these two origins name the same deployment? Exact match, or two members of\n * the set. BOTH sides must be members, so a self-hosted or preview base gains no\n * alias and keeps today's strict compare, and a differing scheme or port is a\n * different origin that aliases to nothing. Takes `URL.origin` strings; anything\n * else is not a member and falls through to the exact compare.\n */\nexport function isSameDeployment(a: string, b: string): boolean {\n if (a === b) return true;\n return KNOWN_DEPLOYMENT_ORIGINS.has(a) && KNOWN_DEPLOYMENT_ORIGINS.has(b);\n}\n\n/** The set as a plain array, for the generated hook script that cannot import. */\nexport function knownDeploymentOrigins(): string[] {\n return [...KNOWN_DEPLOYMENT_ORIGINS];\n}\n"],"mappings":";;;AAYO,IAAM,oBAAoB;AAM1B,IAAM,kBAAkB,IAAI,IAAI,iBAAiB,EAAE;AAc1D,IAAM,2BAAgD,oBAAI,IAAI;AAAA,EAC5D;AAAA,EACA;AACF,CAAC;AASM,SAAS,iBAAiB,GAAW,GAAoB;AAC9D,MAAI,MAAM,EAAG,QAAO;AACpB,SAAO,yBAAyB,IAAI,CAAC,KAAK,yBAAyB,IAAI,CAAC;AAC1E;AAGO,SAAS,yBAAmC;AACjD,SAAO,CAAC,GAAG,wBAAwB;AACrC;","names":[]}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { createRequire as __tenjinCreateRequire } from 'node:module'; const require = __tenjinCreateRequire(import.meta.url);
|
|
2
|
+
import {
|
|
3
|
+
CliError
|
|
4
|
+
} from "./chunk-3UCIG4TG.js";
|
|
5
|
+
|
|
6
|
+
// src/lib/ids.ts
|
|
7
|
+
var ATOMIC_RE = /^\d{1,39}$/;
|
|
8
|
+
|
|
9
|
+
// src/lib/money.ts
|
|
10
|
+
var USDC_DECIMALS = 6;
|
|
11
|
+
function parseUsdToAtomic(input) {
|
|
12
|
+
const trimmed = input.trim();
|
|
13
|
+
if (!/^\d+(\.\d+)?$/.test(trimmed)) {
|
|
14
|
+
throw new CliError("USAGE", `Invalid USD amount: ${JSON.stringify(input)}`, {
|
|
15
|
+
fix: "Pass a non-negative decimal like 0.25 or 5."
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
const [whole, frac = ""] = trimmed.split(".");
|
|
19
|
+
if (frac.length > USDC_DECIMALS) {
|
|
20
|
+
throw new CliError(
|
|
21
|
+
"USAGE",
|
|
22
|
+
`USD amount ${JSON.stringify(input)} has more than 6 decimal places`,
|
|
23
|
+
{
|
|
24
|
+
fix: "USDC supports at most 6 decimal places (micro-dollars)."
|
|
25
|
+
}
|
|
26
|
+
);
|
|
27
|
+
}
|
|
28
|
+
const atomic = BigInt(`${whole}${frac.padEnd(USDC_DECIMALS, "0")}`);
|
|
29
|
+
return atomic.toString();
|
|
30
|
+
}
|
|
31
|
+
function atomicToUsd(atomic) {
|
|
32
|
+
const trimmed = atomic.trim();
|
|
33
|
+
if (!/^\d+$/.test(trimmed)) {
|
|
34
|
+
throw new CliError("INTERNAL", `Malformed atomic amount: ${JSON.stringify(atomic)}`);
|
|
35
|
+
}
|
|
36
|
+
const value = BigInt(trimmed);
|
|
37
|
+
const base = 10n ** BigInt(USDC_DECIMALS);
|
|
38
|
+
const whole = value / base;
|
|
39
|
+
const frac = (value % base).toString().padStart(USDC_DECIMALS, "0").replace(/0+$/, "");
|
|
40
|
+
return frac.length > 0 ? `${whole}.${frac}` : whole.toString();
|
|
41
|
+
}
|
|
42
|
+
function toMoney(atomic) {
|
|
43
|
+
return { atomic, usd: atomicToUsd(atomic) };
|
|
44
|
+
}
|
|
45
|
+
function formatUsdDisplay(atomic) {
|
|
46
|
+
const [whole, frac = ""] = atomicToUsd(atomic).split(".");
|
|
47
|
+
return `${whole}.${frac.padEnd(2, "0")}`;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export {
|
|
51
|
+
ATOMIC_RE,
|
|
52
|
+
parseUsdToAtomic,
|
|
53
|
+
toMoney,
|
|
54
|
+
formatUsdDisplay
|
|
55
|
+
};
|
|
56
|
+
//# sourceMappingURL=chunk-Y527D4TV.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/lib/ids.ts","../src/lib/money.ts"],"sourcesContent":["/**\n * The shared identity patterns for server-controlled values that become file\n * paths, URL segments, or terminal output. One definition so a future change\n * (e.g. accepting uppercase ids) cannot be applied in one command and missed in\n * another. SLUG_RE must match the server's slugify charset (lib/posts.ts:\n * lowercase a-z0-9 groups joined by single hyphens, no leading/trailing hyphen).\n */\nexport const UUID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;\nexport const SLUG_RE = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;\n/** A non-negative atomic USDC integer string (6-decimal base units). */\nexport const ATOMIC_RE = /^\\d{1,39}$/;\n","import { CliError } from './errors';\nimport { ATOMIC_RE } from './ids';\nimport type { Money } from '../schemas';\n\n/** USDC is a 6-decimal token; one dollar is 1_000_000 atomic units. */\nconst USDC_DECIMALS = 6;\n\n/**\n * Decimal USD at the CLI edge -> atomic USDC string (O1). Accepts \"0\", \"0.25\",\n * \"5\"; rejects negatives, non-numeric input, and more than 6 decimal places as\n * USAGE so a fat-fingered amount fails loudly instead of truncating money.\n * String math throughout — a float would lose precision at the 6th decimal.\n */\nexport function parseUsdToAtomic(input: string): string {\n const trimmed = input.trim();\n if (!/^\\d+(\\.\\d+)?$/.test(trimmed)) {\n throw new CliError('USAGE', `Invalid USD amount: ${JSON.stringify(input)}`, {\n fix: 'Pass a non-negative decimal like 0.25 or 5.',\n });\n }\n const [whole, frac = ''] = trimmed.split('.');\n if (frac.length > USDC_DECIMALS) {\n throw new CliError(\n 'USAGE',\n `USD amount ${JSON.stringify(input)} has more than 6 decimal places`,\n {\n fix: 'USDC supports at most 6 decimal places (micro-dollars).',\n },\n );\n }\n const atomic = BigInt(`${whole}${frac.padEnd(USDC_DECIMALS, '0')}`);\n return atomic.toString();\n}\n\n/**\n * Atomic USDC string -> decimal USD string, trailing zeros trimmed (\"250000\" ->\n * \"0.25\", \"5000000\" -> \"5\", \"0\" -> \"0\"). Throws INTERNAL on a malformed atomic\n * value: atomic strings come from validated config or on-chain reads, so a bad\n * one is a bug, not user input.\n */\nexport function atomicToUsd(atomic: string): string {\n const trimmed = atomic.trim();\n if (!/^\\d+$/.test(trimmed)) {\n throw new CliError('INTERNAL', `Malformed atomic amount: ${JSON.stringify(atomic)}`);\n }\n const value = BigInt(trimmed);\n const base = 10n ** BigInt(USDC_DECIMALS);\n const whole = value / base;\n const frac = (value % base).toString().padStart(USDC_DECIMALS, '0').replace(/0+$/, '');\n return frac.length > 0 ? `${whole}.${frac}` : whole.toString();\n}\n\n/**\n * Whether an atomic price would actually cost something: true paid, false free,\n * null when the string is not an atomic amount at all and so cannot answer.\n *\n * A Tenjin piece may be priced at zero and is then delivered by `read` with no\n * payment, so \"there is a price field\" and \"there is a purchase to make\" are\n * different questions. The third state is not decoration: only the wire schema\n * enforces ATOMIC_RE, and the local search store types `price` as a bare string,\n * so a hand-edited or half-written entry can hold \"-1\" or \"0.1\". Those must not\n * read as \"free\", or corrupt local data would start refusing honest reports.\n * Never throws, which is why the check is a regex and not a BigInt compare.\n *\n * Matched against the RAW string, with no trimming. The contract carries the\n * canonical form and nothing else, so \" 0 \" did not come off the wire; padding is\n * evidence the value was edited, and normalizing it away would launder a corrupt\n * entry into a confident \"free\" and hand back the false refusal this avoids.\n */\nexport function isPaidPrice(atomic: string): boolean | null {\n if (!ATOMIC_RE.test(atomic)) return null;\n return /[1-9]/.test(atomic);\n}\n\n/** Dual-form money object for machine output. */\nexport function toMoney(atomic: string): Money {\n return { atomic, usd: atomicToUsd(atomic) };\n}\n\n/**\n * Canonical USD for human COPY (a price a person reads): always at least two\n * decimals (\"0.10\", \"5.00\"), keeping any finer precision below a cent\n * (\"0.000001\"). Distinct from `atomicToUsd`, which trims to the shortest exact\n * form for machine output; use this only where a dollar amount is shown to a human.\n */\nexport function formatUsdDisplay(atomic: string): string {\n const [whole, frac = ''] = atomicToUsd(atomic).split('.');\n return `${whole}.${frac.padEnd(2, '0')}`;\n}\n"],"mappings":";;;;;;AAUO,IAAM,YAAY;;;ACLzB,IAAM,gBAAgB;AAQf,SAAS,iBAAiB,OAAuB;AACtD,QAAM,UAAU,MAAM,KAAK;AAC3B,MAAI,CAAC,gBAAgB,KAAK,OAAO,GAAG;AAClC,UAAM,IAAI,SAAS,SAAS,uBAAuB,KAAK,UAAU,KAAK,CAAC,IAAI;AAAA,MAC1E,KAAK;AAAA,IACP,CAAC;AAAA,EACH;AACA,QAAM,CAAC,OAAO,OAAO,EAAE,IAAI,QAAQ,MAAM,GAAG;AAC5C,MAAI,KAAK,SAAS,eAAe;AAC/B,UAAM,IAAI;AAAA,MACR;AAAA,MACA,cAAc,KAAK,UAAU,KAAK,CAAC;AAAA,MACnC;AAAA,QACE,KAAK;AAAA,MACP;AAAA,IACF;AAAA,EACF;AACA,QAAM,SAAS,OAAO,GAAG,KAAK,GAAG,KAAK,OAAO,eAAe,GAAG,CAAC,EAAE;AAClE,SAAO,OAAO,SAAS;AACzB;AAQO,SAAS,YAAY,QAAwB;AAClD,QAAM,UAAU,OAAO,KAAK;AAC5B,MAAI,CAAC,QAAQ,KAAK,OAAO,GAAG;AAC1B,UAAM,IAAI,SAAS,YAAY,4BAA4B,KAAK,UAAU,MAAM,CAAC,EAAE;AAAA,EACrF;AACA,QAAM,QAAQ,OAAO,OAAO;AAC5B,QAAM,OAAO,OAAO,OAAO,aAAa;AACxC,QAAM,QAAQ,QAAQ;AACtB,QAAM,QAAQ,QAAQ,MAAM,SAAS,EAAE,SAAS,eAAe,GAAG,EAAE,QAAQ,OAAO,EAAE;AACrF,SAAO,KAAK,SAAS,IAAI,GAAG,KAAK,IAAI,IAAI,KAAK,MAAM,SAAS;AAC/D;AAyBO,SAAS,QAAQ,QAAuB;AAC7C,SAAO,EAAE,QAAQ,KAAK,YAAY,MAAM,EAAE;AAC5C;AAQO,SAAS,iBAAiB,QAAwB;AACvD,QAAM,CAAC,OAAO,OAAO,EAAE,IAAI,YAAY,MAAM,EAAE,MAAM,GAAG;AACxD,SAAO,GAAG,KAAK,IAAI,KAAK,OAAO,GAAG,GAAG,CAAC;AACxC;","names":[]}
|
|
@@ -2,7 +2,7 @@ import { createRequire as __tenjinCreateRequire } from 'node:module'; const requ
|
|
|
2
2
|
|
|
3
3
|
// package.json
|
|
4
4
|
var name = "tenjin-cli";
|
|
5
|
-
var version = "0.1.0-alpha.
|
|
5
|
+
var version = "0.1.0-alpha.32";
|
|
6
6
|
var type = "module";
|
|
7
7
|
var description = "The tool router for coding agents. Tenjin picks the right tool when your agent needs one, and one wallet pays for every call.";
|
|
8
8
|
var repository = {
|
|
@@ -33,6 +33,19 @@ var bin = {
|
|
|
33
33
|
var engines = {
|
|
34
34
|
node: ">=22.0.0"
|
|
35
35
|
};
|
|
36
|
+
var tenjinRuntime = {
|
|
37
|
+
node: {
|
|
38
|
+
version: "24.22.1",
|
|
39
|
+
sha256: {
|
|
40
|
+
"darwin-arm64": "89c682593d76cd44233fa53b1563264e7de9cbb189cad169135c5b4fadfbc0a7",
|
|
41
|
+
"darwin-x64": "d132557e7ee2b85af08b0c8c34338e65c6430f2238d01f727728ef42dc83b035",
|
|
42
|
+
"linux-x64": "eb6728e77c576a35162c122c45ccadf224d89ff00abc8dae46cc2897c6002d7c",
|
|
43
|
+
"linux-arm64": "33c37be234ba8bee041961047b19160f4d7d0f164e8e246f78bdd10feff148b3",
|
|
44
|
+
"win-x64": "d2046d28c2c3dcd211ac5145c0bf30e2047ef9dfb306693c8c6e2eccd8b95fa5",
|
|
45
|
+
"win-arm64": "a0c807319fede24c4a0d8f84564c82a619bd313b16b10c007c383c2609e99171"
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
};
|
|
36
49
|
var files = [
|
|
37
50
|
"dist",
|
|
38
51
|
"docs",
|
|
@@ -89,6 +102,7 @@ var package_default = {
|
|
|
89
102
|
keywords,
|
|
90
103
|
bin,
|
|
91
104
|
engines,
|
|
105
|
+
tenjinRuntime,
|
|
92
106
|
files,
|
|
93
107
|
packageManager,
|
|
94
108
|
scripts,
|
|
@@ -106,10 +120,11 @@ export {
|
|
|
106
120
|
keywords,
|
|
107
121
|
bin,
|
|
108
122
|
engines,
|
|
123
|
+
tenjinRuntime,
|
|
109
124
|
files,
|
|
110
125
|
packageManager,
|
|
111
126
|
scripts,
|
|
112
127
|
devDependencies,
|
|
113
128
|
package_default
|
|
114
129
|
};
|
|
115
|
-
//# sourceMappingURL=chunk-
|
|
130
|
+
//# sourceMappingURL=chunk-YUY4SAGM.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../package.json"],"sourcesContent":["{\n \"name\": \"tenjin-cli\",\n \"version\": \"0.1.0-alpha.32\",\n \"type\": \"module\",\n \"description\": \"The tool router for coding agents. Tenjin picks the right tool when your agent needs one, and one wallet pays for every call.\",\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"git+https://github.com/BackTrackCo/tenjin-agent.git\"\n },\n \"homepage\": \"https://tenjin.sh/agents\",\n \"bugs\": \"https://github.com/BackTrackCo/tenjin-agent/issues\",\n \"keywords\": [\n \"claude-code\",\n \"coding-agents\",\n \"tool-router\",\n \"ai-agents\",\n \"agent-tools\",\n \"mcp\",\n \"x402\",\n \"usdc\",\n \"base\",\n \"micropayments\",\n \"agent-payments\",\n \"claude\",\n \"codex\",\n \"cli\"\n ],\n \"bin\": {\n \"tenjin\": \"dist/index.js\"\n },\n \"engines\": {\n \"node\": \">=22.0.0\"\n },\n \"tenjinRuntime\": {\n \"node\": {\n \"version\": \"24.22.1\",\n \"sha256\": {\n \"darwin-arm64\": \"89c682593d76cd44233fa53b1563264e7de9cbb189cad169135c5b4fadfbc0a7\",\n \"darwin-x64\": \"d132557e7ee2b85af08b0c8c34338e65c6430f2238d01f727728ef42dc83b035\",\n \"linux-x64\": \"eb6728e77c576a35162c122c45ccadf224d89ff00abc8dae46cc2897c6002d7c\",\n \"linux-arm64\": \"33c37be234ba8bee041961047b19160f4d7d0f164e8e246f78bdd10feff148b3\",\n \"win-x64\": \"d2046d28c2c3dcd211ac5145c0bf30e2047ef9dfb306693c8c6e2eccd8b95fa5\",\n \"win-arm64\": \"a0c807319fede24c4a0d8f84564c82a619bd313b16b10c007c383c2609e99171\"\n }\n }\n },\n \"files\": [\n \"dist\",\n \"docs\",\n \"NOTICE.md\"\n ],\n \"packageManager\": \"pnpm@11.11.0\",\n \"scripts\": {\n \"build\": \"rm -rf dist && tsup\",\n \"test\": \"vitest run\",\n \"typecheck\": \"tsc --noEmit\",\n \"lint\": \"eslint .\",\n \"format\": \"prettier --write .\",\n \"format:check\": \"prettier --check .\",\n \"check\": \"pnpm run build && pnpm run test\",\n \"sync:skill\": \"node scripts/sync-skill.mjs\",\n \"pack-smoke\": \"bash scripts/pack-smoke.sh\",\n \"changeset\": \"changeset\",\n \"prepublishOnly\": \"pnpm run build\",\n \"githooks\": \"git config core.hooksPath .githooks\"\n },\n \"devDependencies\": {\n \"@changesets/cli\": \"^3.0.3\",\n \"@clack/prompts\": \"^1.7.0\",\n \"@eslint/js\": \"^10\",\n \"@modelcontextprotocol/sdk\": \"1.32.0\",\n \"@types/node\": \"^22.20.5\",\n \"@x402/core\": \"2.28.0\",\n \"@x402/evm\": \"2.28.0\",\n \"@x402/extensions\": \"2.28.0\",\n \"@x402/fetch\": \"2.28.0\",\n \"ajv\": \"^8.20.0\",\n \"ajv-formats\": \"^3.0.1\",\n \"commander\": \"^14.0.1\",\n \"eslint\": \"^10\",\n \"eslint-config-prettier\": \"^10\",\n \"lean-qr\": \"^2.7.4\",\n \"ox\": \"0.14.30\",\n \"prettier\": \"^3\",\n \"tsup\": \"^8.5.0\",\n \"typescript\": \"^6\",\n \"typescript-eslint\": \"^8\",\n \"viem\": \"^2.53.1\",\n \"vitest\": \"^4.1.9\",\n \"zod\": \"^4.4.3\"\n }\n}\n"],"mappings":";;;AACE,WAAQ;AACR,cAAW;AACX,WAAQ;AACR,kBAAe;AACf,iBAAc;AAAA,EACZ,MAAQ;AAAA,EACR,KAAO;AACT;AACA,eAAY;AACZ,WAAQ;AACR,eAAY;AAAA,EACV;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AACA,UAAO;AAAA,EACL,QAAU;AACZ;AACA,cAAW;AAAA,EACT,MAAQ;AACV;AACA,oBAAiB;AAAA,EACf,MAAQ;AAAA,IACN,SAAW;AAAA,IACX,QAAU;AAAA,MACR,gBAAgB;AAAA,MAChB,cAAc;AAAA,MACd,aAAa;AAAA,MACb,eAAe;AAAA,MACf,WAAW;AAAA,MACX,aAAa;AAAA,IACf;AAAA,EACF;AACF;AACA,YAAS;AAAA,EACP;AAAA,EACA;AAAA,EACA;AACF;AACA,qBAAkB;AAClB,cAAW;AAAA,EACT,OAAS;AAAA,EACT,MAAQ;AAAA,EACR,WAAa;AAAA,EACb,MAAQ;AAAA,EACR,QAAU;AAAA,EACV,gBAAgB;AAAA,EAChB,OAAS;AAAA,EACT,cAAc;AAAA,EACd,cAAc;AAAA,EACd,WAAa;AAAA,EACb,gBAAkB;AAAA,EAClB,UAAY;AACd;AACA,sBAAmB;AAAA,EACjB,mBAAmB;AAAA,EACnB,kBAAkB;AAAA,EAClB,cAAc;AAAA,EACd,6BAA6B;AAAA,EAC7B,eAAe;AAAA,EACf,cAAc;AAAA,EACd,aAAa;AAAA,EACb,oBAAoB;AAAA,EACpB,eAAe;AAAA,EACf,KAAO;AAAA,EACP,eAAe;AAAA,EACf,WAAa;AAAA,EACb,QAAU;AAAA,EACV,0BAA0B;AAAA,EAC1B,WAAW;AAAA,EACX,IAAM;AAAA,EACN,UAAY;AAAA,EACZ,MAAQ;AAAA,EACR,YAAc;AAAA,EACd,qBAAqB;AAAA,EACrB,MAAQ;AAAA,EACR,QAAU;AAAA,EACV,KAAO;AACT;AA1FF;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAIA;AAAA,EACA;AAAA,EACA;AAAA,EAgBA;AAAA,EAGA;AAAA,EAGA;AAAA,EAaA;AAAA,EAKA;AAAA,EACA;AAAA,EAcA;AAyBF;","names":[]}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { createRequire as __tenjinCreateRequire } from 'node:module'; const require = __tenjinCreateRequire(import.meta.url);
|
|
2
|
+
import {
|
|
3
|
+
askText,
|
|
4
|
+
confirmChoice,
|
|
5
|
+
intro,
|
|
6
|
+
outro,
|
|
7
|
+
selectMany,
|
|
8
|
+
selectOne
|
|
9
|
+
} from "./chunk-DOQGNFHM.js";
|
|
10
|
+
import "./chunk-ZXTAQYNA.js";
|
|
11
|
+
export {
|
|
12
|
+
askText,
|
|
13
|
+
confirmChoice,
|
|
14
|
+
intro,
|
|
15
|
+
outro,
|
|
16
|
+
selectMany,
|
|
17
|
+
selectOne
|
|
18
|
+
};
|
|
19
|
+
//# sourceMappingURL=clack-EZ7TDWQU.js.map
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { createRequire as __tenjinCreateRequire } from 'node:module'; const require = __tenjinCreateRequire(import.meta.url);
|
|
2
|
+
import {
|
|
3
|
+
CLAUDE_CODE_FLOOR,
|
|
4
|
+
CLAUDE_UPDATE_FIX,
|
|
5
|
+
claudeConfigDir,
|
|
6
|
+
findClaudeBinary,
|
|
7
|
+
jsonList,
|
|
8
|
+
jsonResult,
|
|
9
|
+
meetsFloor,
|
|
10
|
+
parseClaudeVersion,
|
|
11
|
+
readClaudeCode,
|
|
12
|
+
runClaude,
|
|
13
|
+
userMcpFile,
|
|
14
|
+
userSettingsPath
|
|
15
|
+
} from "./chunk-QXP3Z3JN.js";
|
|
16
|
+
import "./chunk-ZXTAQYNA.js";
|
|
17
|
+
export {
|
|
18
|
+
CLAUDE_CODE_FLOOR,
|
|
19
|
+
CLAUDE_UPDATE_FIX,
|
|
20
|
+
claudeConfigDir,
|
|
21
|
+
findClaudeBinary,
|
|
22
|
+
jsonList,
|
|
23
|
+
jsonResult,
|
|
24
|
+
meetsFloor,
|
|
25
|
+
parseClaudeVersion,
|
|
26
|
+
readClaudeCode,
|
|
27
|
+
runClaude,
|
|
28
|
+
userMcpFile,
|
|
29
|
+
userSettingsPath
|
|
30
|
+
};
|
|
31
|
+
//# sourceMappingURL=claude-cli-2YKABJJZ.js.map
|