tenjin-cli 0.1.0-alpha.34 → 0.1.0-alpha.35
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/NOTICE.md +30 -0
- package/README.md +20 -18
- package/dist/{_esm-MMYV66AX.js → _esm-2KST7HQ7.js} +4 -4
- package/dist/{alive-VOIL5W3I.js → alive-5TV22PNF.js} +13 -13
- package/dist/{auth-UHD3QFX4.js → auth-XI7BJFLW.js} +4 -4
- package/dist/balance-DFHC6XEU.js +71 -0
- package/dist/{ccip-CS7K5QRQ.js → ccip-HOW3DZYF.js} +3 -3
- package/dist/{chunk-RJ5HRPAZ.js → chunk-24XKUN2S.js} +68 -10
- package/dist/chunk-24XKUN2S.js.map +1 -0
- package/dist/chunk-2L7TDGLV.js +56 -0
- package/dist/chunk-2L7TDGLV.js.map +1 -0
- package/dist/{chunk-PZHBPGDE.js → chunk-34SAECKZ.js} +34 -10
- package/dist/chunk-34SAECKZ.js.map +1 -0
- package/dist/{chunk-EQZ2CCWC.js → chunk-3Y2EHT4F.js} +5 -2
- package/dist/chunk-3Y2EHT4F.js.map +1 -0
- package/dist/{chunk-FSYH7J75.js → chunk-3Y6BHIN6.js} +3 -3
- package/dist/{chunk-FZZWTDWP.js → chunk-3YPL6T3P.js} +6 -6
- package/dist/{chunk-JEZMWJEF.js → chunk-44MVIRZH.js} +4 -4
- package/dist/{chunk-27FIHFXF.js → chunk-45MMSBHA.js} +5 -5
- package/dist/{chunk-QXP3Z3JN.js → chunk-4MBCJFY4.js} +35 -3
- package/dist/chunk-4MBCJFY4.js.map +1 -0
- package/dist/chunk-4TPL54KW.js +227 -0
- package/dist/chunk-4TPL54KW.js.map +1 -0
- package/dist/{chunk-7JB6SYJX.js → chunk-54ELBTKE.js} +2 -2
- package/dist/{chunk-6J64MQFD.js → chunk-5F4OB5B3.js} +21 -15
- package/dist/chunk-5F4OB5B3.js.map +1 -0
- package/dist/{chunk-PYVQ74D5.js → chunk-5HN4KVQU.js} +189 -117
- package/dist/chunk-5HN4KVQU.js.map +1 -0
- package/dist/{chunk-VFKPIIV2.js → chunk-5J4E5GYI.js} +35 -32
- package/dist/chunk-5J4E5GYI.js.map +1 -0
- package/dist/chunk-5USBZ2MU.js +58 -0
- package/dist/chunk-5USBZ2MU.js.map +1 -0
- package/dist/chunk-64WOMNYR.js +183 -0
- package/dist/chunk-64WOMNYR.js.map +1 -0
- package/dist/{chunk-APWELUI7.js → chunk-65RS4LQS.js} +57 -43
- package/dist/chunk-65RS4LQS.js.map +1 -0
- package/dist/{chunk-HWZO6HYZ.js → chunk-6QMDUDF2.js} +3 -3
- package/dist/{chunk-FNBGRKS6.js → chunk-7V25UAQO.js} +2 -2
- package/dist/chunk-BGA4DO5M.js +719 -0
- package/dist/chunk-BGA4DO5M.js.map +1 -0
- package/dist/chunk-BVP7YK2J.js +706 -0
- package/dist/chunk-BVP7YK2J.js.map +1 -0
- package/dist/chunk-C265QIMJ.js +83 -0
- package/dist/chunk-C265QIMJ.js.map +1 -0
- package/dist/{chunk-MXN2ZEUB.js → chunk-D6M3ZK66.js} +2 -2
- package/dist/chunk-D6M3ZK66.js.map +1 -0
- package/dist/chunk-DJ36BM62.js +78 -0
- package/dist/chunk-DJ36BM62.js.map +1 -0
- package/dist/{chunk-JOKPBYXP.js → chunk-DTEWAVNE.js} +2 -2
- package/dist/chunk-F2KJAJ7T.js +13 -0
- package/dist/chunk-F2KJAJ7T.js.map +1 -0
- package/dist/{chunk-KAILF7QA.js → chunk-F43CV6UC.js} +2 -2
- package/dist/{chunk-ACO7ZCR2.js → chunk-FKVJKLPI.js} +2 -2
- package/dist/{chunk-43HLS2HM.js → chunk-FYFHH7V5.js} +54 -3
- package/dist/{chunk-43HLS2HM.js.map → chunk-FYFHH7V5.js.map} +1 -1
- package/dist/{chunk-2F5JUAHZ.js → chunk-GAJC4BQZ.js} +3 -3
- package/dist/{chunk-L7N73ZAW.js → chunk-HAZAN4UM.js} +2 -2
- package/dist/{chunk-6QJZA6EX.js → chunk-HI5XQOX2.js} +2 -2
- package/dist/{chunk-BOENA6XR.js → chunk-HKGUKAQW.js} +6 -6
- package/dist/{chunk-LJSCGIYH.js → chunk-HPRVFJPM.js} +2 -2
- package/dist/{chunk-OO6FIBL7.js → chunk-HZKANST2.js} +3 -6
- package/dist/chunk-HZKANST2.js.map +1 -0
- package/dist/{chunk-UVDJ5SSQ.js → chunk-I557SAOM.js} +8 -2
- package/dist/chunk-I557SAOM.js.map +1 -0
- package/dist/{chunk-SDUOJRSV.js → chunk-IGLWLH73.js} +3 -3
- package/dist/{chunk-3AKH7ODX.js → chunk-INSIW65E.js} +5 -5
- package/dist/{chunk-PNHNXUSL.js → chunk-IULCDMVG.js} +12 -1
- package/dist/chunk-IULCDMVG.js.map +1 -0
- package/dist/{chunk-JF4T4HCQ.js → chunk-IVNSUAVC.js} +10 -5
- package/dist/chunk-IVNSUAVC.js.map +1 -0
- package/dist/chunk-JDQZCREI.js +87 -0
- package/dist/chunk-JDQZCREI.js.map +1 -0
- package/dist/{chunk-2P3NJTHE.js → chunk-JHFFUVON.js} +23 -23
- package/dist/{chunk-7JVARP5R.js → chunk-JTILUN4W.js} +55 -29
- package/dist/{chunk-7JVARP5R.js.map → chunk-JTILUN4W.js.map} +1 -1
- package/dist/{chunk-2TO5F6CT.js → chunk-K5KNGC4I.js} +8 -8
- package/dist/{chunk-HUWTFKEM.js → chunk-KAQ4Q3TO.js} +3 -3
- package/dist/{chunk-E6VP6MQM.js → chunk-KGUE5AVX.js} +4 -4
- package/dist/chunk-KGUE5AVX.js.map +1 -0
- package/dist/{chunk-GS5RZF7U.js → chunk-KLDMLWXT.js} +2 -2
- package/dist/{chunk-HN2EN6P4.js → chunk-KNKDMTHU.js} +5 -5
- package/dist/chunk-LDA6TAYQ.js +95 -0
- package/dist/chunk-LDA6TAYQ.js.map +1 -0
- package/dist/chunk-LWSSIZOY.js +347 -0
- package/dist/chunk-LWSSIZOY.js.map +1 -0
- package/dist/{chunk-5VWQSCDO.js → chunk-MAHNZA6C.js} +89 -9
- package/dist/chunk-MAHNZA6C.js.map +1 -0
- package/dist/{chunk-46HAB26L.js → chunk-MEWZCIA6.js} +56 -9
- package/dist/chunk-MEWZCIA6.js.map +1 -0
- package/dist/{chunk-R2KMLONN.js → chunk-MJDO4EXD.js} +4 -4
- package/dist/{chunk-IHVUE3XF.js → chunk-NJA6NT3A.js} +3 -3
- package/dist/{chunk-TSIID2LV.js → chunk-ODRPASFP.js} +375 -1166
- package/dist/chunk-ODRPASFP.js.map +1 -0
- package/dist/{chunk-S3JKF3IK.js → chunk-OJJFANO6.js} +3 -3
- package/dist/{chunk-56SOPRM2.js → chunk-OQWPRFAC.js} +344 -4
- package/dist/chunk-OQWPRFAC.js.map +1 -0
- package/dist/{chunk-QEZZDIQT.js → chunk-P6YQWIT2.js} +4053 -4039
- package/dist/chunk-P6YQWIT2.js.map +1 -0
- package/dist/{chunk-GGGEGMWC.js → chunk-Q6RSJCXB.js} +9 -9
- package/dist/{chunk-OTIUEUIS.js → chunk-QKEUKBRK.js} +7 -7
- package/dist/{chunk-X52BVGCJ.js → chunk-QQDPRTLP.js} +5 -5
- package/dist/chunk-QQYCYAKI.js +79 -0
- package/dist/chunk-QQYCYAKI.js.map +1 -0
- package/dist/chunk-R4KDH477.js +1064 -0
- package/dist/chunk-R4KDH477.js.map +1 -0
- package/dist/{chunk-6AQSUBNR.js → chunk-RGCPELQN.js} +2 -2
- package/dist/{chunk-AXODGQ23.js → chunk-RGVCOG2S.js} +9 -2
- package/dist/{chunk-AXODGQ23.js.map → chunk-RGVCOG2S.js.map} +1 -1
- package/dist/chunk-SOLNJ3AZ.js +209 -0
- package/dist/chunk-SOLNJ3AZ.js.map +1 -0
- package/dist/{chunk-LQ33RLHL.js → chunk-TFT2X7SH.js} +3 -3
- package/dist/chunk-TVWCLUBI.js +293 -0
- package/dist/chunk-TVWCLUBI.js.map +1 -0
- package/dist/{chunk-VH7JMLTG.js → chunk-UIB33QQP.js} +25 -16
- package/dist/chunk-UIB33QQP.js.map +1 -0
- package/dist/chunk-V6GIVALQ.js +1889 -0
- package/dist/chunk-V6GIVALQ.js.map +1 -0
- package/dist/{chunk-IVHGQNIN.js → chunk-VHXCPXUS.js} +8 -8
- package/dist/{chunk-7DW7GAM6.js → chunk-VU6GMWF6.js} +2 -2
- package/dist/chunk-VWZYE3NC.js +8415 -0
- package/dist/chunk-VWZYE3NC.js.map +1 -0
- package/dist/{chunk-3X4GOMXT.js → chunk-W2GXIARJ.js} +12 -7
- package/dist/chunk-W2GXIARJ.js.map +1 -0
- package/dist/chunk-W4G3K3V7.js +288 -0
- package/dist/chunk-W4G3K3V7.js.map +1 -0
- package/dist/{chunk-FHXTEVO7.js → chunk-W74LJ5OT.js} +21 -28
- package/dist/chunk-W74LJ5OT.js.map +1 -0
- package/dist/{chunk-FOEPH67T.js → chunk-W7ELYLYK.js} +1 -74
- package/dist/chunk-W7ELYLYK.js.map +1 -0
- package/dist/{chunk-YU3DLVSQ.js → chunk-XSCGUO2U.js} +5 -5
- package/dist/{chunk-EPCIJLLU.js → chunk-XWROSMI5.js} +9 -9
- package/dist/{chunk-HMT6L65V.js → chunk-YJGEVBKZ.js} +4 -4
- package/dist/{chunk-7U3P4PB7.js → chunk-ZEYA2WWX.js} +4 -4
- package/dist/chunk-ZEYA2WWX.js.map +1 -0
- package/dist/chunk-ZRC7Z5X3.js +82 -0
- package/dist/chunk-ZRC7Z5X3.js.map +1 -0
- package/dist/{chunk-I47ARU5G.js → chunk-ZS7JIUJ3.js} +2 -2
- package/dist/{claude-cli-2YKABJJZ.js → claude-cli-GIIHOBGT.js} +4 -2
- package/dist/claude-install-BAUSJMW3.js +64 -0
- package/dist/{cli-BFDKEX53.js → cli-QY4KKA3D.js} +116 -49
- package/dist/cli-QY4KKA3D.js.map +1 -0
- package/dist/{client-XMWEKXX7.js → client-3YQKORVK.js} +4 -4
- package/dist/{codex-host-B6NAUWL6.js → codex-host-ZON3S6HU.js} +5 -5
- package/dist/{codex-install-GTGO5FYN.js → codex-install-HZV2DOAB.js} +62 -47
- package/dist/codex-install-HZV2DOAB.js.map +1 -0
- package/dist/{config-THJANIU5.js → config-QZOBMTEL.js} +18 -18
- package/dist/{config-names-JU54HYWY.js → config-names-Z5NZD5R2.js} +18 -18
- package/dist/{config-rules-VNU23RL4.js → config-rules-YOYHS6YL.js} +19 -19
- package/dist/config-subagents-WQV2ZAD5.js +362 -0
- package/dist/config-subagents-WQV2ZAD5.js.map +1 -0
- package/dist/{connect-HPWS7U63.js → connect-YDWTYU4B.js} +28 -27
- package/dist/{connect-HPWS7U63.js.map → connect-YDWTYU4B.js.map} +1 -1
- package/dist/core-0a66n3e7-TTP554XV.js +127 -0
- package/dist/core-0a66n3e7-TTP554XV.js.map +1 -0
- package/dist/core-0bmnpbz2-C2JIRVZO.js +10790 -0
- package/dist/core-0bmnpbz2-C2JIRVZO.js.map +1 -0
- package/dist/core-9je8ee1j-74DGHWPV.js +30 -0
- package/dist/core-9je8ee1j-74DGHWPV.js.map +1 -0
- package/dist/core-wadgcjfh-TSZFQZGH.js +666 -0
- package/dist/core-wadgcjfh-TSZFQZGH.js.map +1 -0
- package/dist/core-zg882d22-LKV5DZYW.js +37 -0
- package/dist/core-zg882d22-LKV5DZYW.js.map +1 -0
- package/dist/{decision-JIIHDTOF.js → decision-QSKHOGCO.js} +6 -6
- package/dist/{doctor-4MMHBRDU.js → doctor-ZWJXRD75.js} +67 -66
- package/dist/doctor-ZWJXRD75.js.map +1 -0
- package/dist/{explicit-AGENAX6E.js → explicit-ME2NRADQ.js} +45 -42
- package/dist/{explicit-AGENAX6E.js.map → explicit-ME2NRADQ.js.map} +1 -1
- package/dist/flush-stdio-NYIJ3QXT.js +18 -0
- package/dist/{fund-MLXUH24Q.js → fund-VF7TLDJH.js} +110 -34
- package/dist/fund-VF7TLDJH.js.map +1 -0
- package/dist/{hook-command-UB7FOEUL.js → hook-command-VZ27MGWO.js} +21 -20
- package/dist/hosts/claude/.claude-plugin/marketplace.json +2 -2
- package/dist/hosts/claude/tenjin/.claude-plugin/plugin.json +2 -2
- package/dist/hosts/claude/tenjin/hooks/hook-data.ts +152 -0
- package/dist/hosts/claude/tenjin/hooks/hooks.json +7 -0
- package/dist/hosts/claude/tenjin/hooks/model-viewer.tsx +2987 -0
- package/dist/hosts/claude/tenjin/hooks/register.tsx +265 -30
- package/dist/hosts/claude/tenjin/skills/tenjin-pay/SKILL.md +14 -4
- package/dist/hosts/claude/tenjin/types/index.d.ts +133 -0
- package/dist/{hosts-WNQKYKP2.js → hosts-3EMTVM4H.js} +5 -3
- package/dist/index.js +16 -13
- package/dist/index.js.map +1 -1
- package/dist/{install-Q5SHHEDH.js → install-ZA7L2UF3.js} +34 -30
- package/dist/{install-funding-EGSW2KEP.js → install-funding-JDGYTF72.js} +9 -13
- package/dist/{install-identity-OID43B4D.js → install-identity-FFAYEFLX.js} +8 -8
- package/dist/{install-wallet-TZFWY5GK.js → install-wallet-2SFOVE3Q.js} +48 -33
- package/dist/{install-wallet-TZFWY5GK.js.map → install-wallet-2SFOVE3Q.js.map} +1 -1
- package/dist/mcp-36S6MK3C.js +67642 -0
- package/dist/mcp-36S6MK3C.js.map +1 -0
- package/dist/new-install-5L4GY3LN.js +51 -0
- package/dist/{package-NRHU7HBR.js → package-BONDXSV3.js} +2 -2
- package/dist/{passphrase-3JEVW5XG.js → passphrase-T4ULBN4M.js} +4 -4
- package/dist/{pay-I47AIUQR.js → pay-CMV5KL74.js} +37 -30
- package/dist/{payments-A5FNI5GN.js → payments-Z6UBZL4Z.js} +10 -10
- package/dist/reclaim-subagent-credit-ABSF67SJ.js +105 -0
- package/dist/reclaim-subagent-credit-ABSF67SJ.js.map +1 -0
- package/dist/{routing-quote-QQW2I5MH.js → routing-quote-AHLAREXR.js} +16 -18
- package/dist/{run-4SHEOBIU.js → run-JH7ELYAM.js} +41 -38
- package/dist/{runtime-BABJMHY7.js → runtime-2GX4ALJP.js} +12 -12
- package/dist/{runtime-activate-N6VLQI2C.js → runtime-activate-IDQ2NCSP.js} +9 -9
- package/dist/{runtime-launchers-GMAUICRW.js → runtime-launchers-YAPKCBHV.js} +7 -7
- package/dist/{runtime-place-DOEWFTF3.js → runtime-place-4POL4KK4.js} +3 -3
- package/dist/{send-ECXS6JEO.js → send-ELXFKEKY.js} +17 -17
- package/dist/{status-AHE5HSR7.js → status-FXUFWJDM.js} +89 -36
- package/dist/status-FXUFWJDM.js.map +1 -0
- package/dist/{status-line-63XFJAXR.js → status-line-IH5JBWBC.js} +11 -11
- package/dist/{streamableHttp-Z3YF6LTQ.js → streamableHttp-CP2ZQBIK.js} +4 -4
- package/dist/{uninstall-YGQPRCVY.js → uninstall-LJZUKM4D.js} +42 -38
- package/dist/{uninstall-YGQPRCVY.js.map → uninstall-LJZUKM4D.js.map} +1 -1
- package/dist/{update-GTLMLFA3.js → update-EUIX72IX.js} +34 -30
- package/dist/{usage-FCWP2CHO.js → usage-EKDC7LUC.js} +13 -13
- package/dist/{usdc-25RNBYYR.js → usdc-YIHK2OMC.js} +5 -5
- package/dist/{viemAdapter-By13KInL-3CG63XDX.js → viemAdapter-By13KInL-PRLSIESK.js} +2 -2
- package/dist/viemAdapter-By13KInL-PRLSIESK.js.map +1 -0
- package/dist/wallet-HSW757W6.js +80 -0
- package/dist/wallet-HSW757W6.js.map +1 -0
- package/docs/agent-permissions.md +19 -11
- package/docs/router-reference.md +21 -12
- package/docs/safety-model.md +4 -2
- package/docs/subagents-internals.md +97 -0
- package/docs/subagents.md +348 -0
- package/package.json +4 -1
- package/dist/balance-RQW5T5FB.js +0 -55
- package/dist/chunk-3X4GOMXT.js.map +0 -1
- package/dist/chunk-46HAB26L.js.map +0 -1
- package/dist/chunk-56SOPRM2.js.map +0 -1
- package/dist/chunk-5VWQSCDO.js.map +0 -1
- package/dist/chunk-6J64MQFD.js.map +0 -1
- package/dist/chunk-7U3P4PB7.js.map +0 -1
- package/dist/chunk-APWELUI7.js.map +0 -1
- package/dist/chunk-E6VP6MQM.js.map +0 -1
- package/dist/chunk-EQZ2CCWC.js.map +0 -1
- package/dist/chunk-FHXTEVO7.js.map +0 -1
- package/dist/chunk-FOEPH67T.js.map +0 -1
- package/dist/chunk-IVXPIIZJ.js +0 -91
- package/dist/chunk-IVXPIIZJ.js.map +0 -1
- package/dist/chunk-JF4T4HCQ.js.map +0 -1
- package/dist/chunk-LPQNZKSG.js +0 -269
- package/dist/chunk-LPQNZKSG.js.map +0 -1
- package/dist/chunk-MXN2ZEUB.js.map +0 -1
- package/dist/chunk-OO6FIBL7.js.map +0 -1
- package/dist/chunk-PNHNXUSL.js.map +0 -1
- package/dist/chunk-PYVQ74D5.js.map +0 -1
- package/dist/chunk-PZHBPGDE.js.map +0 -1
- package/dist/chunk-QEZZDIQT.js.map +0 -1
- package/dist/chunk-QXP3Z3JN.js.map +0 -1
- package/dist/chunk-RJ5HRPAZ.js.map +0 -1
- package/dist/chunk-TSIID2LV.js.map +0 -1
- package/dist/chunk-UVDJ5SSQ.js.map +0 -1
- package/dist/chunk-VFKPIIV2.js.map +0 -1
- package/dist/chunk-VH7JMLTG.js.map +0 -1
- package/dist/claude-install-7CVYQ73E.js +0 -60
- package/dist/cli-BFDKEX53.js.map +0 -1
- package/dist/codex-install-GTGO5FYN.js.map +0 -1
- package/dist/doctor-4MMHBRDU.js.map +0 -1
- package/dist/fund-MLXUH24Q.js.map +0 -1
- package/dist/mcp-CC3H7LFO.js +0 -3655
- package/dist/mcp-CC3H7LFO.js.map +0 -1
- package/dist/status-AHE5HSR7.js.map +0 -1
- package/dist/wallet-CJGEHP2Q.js +0 -64
- /package/dist/{_esm-MMYV66AX.js.map → _esm-2KST7HQ7.js.map} +0 -0
- /package/dist/{alive-VOIL5W3I.js.map → alive-5TV22PNF.js.map} +0 -0
- /package/dist/{auth-UHD3QFX4.js.map → auth-XI7BJFLW.js.map} +0 -0
- /package/dist/{balance-RQW5T5FB.js.map → balance-DFHC6XEU.js.map} +0 -0
- /package/dist/{ccip-CS7K5QRQ.js.map → ccip-HOW3DZYF.js.map} +0 -0
- /package/dist/{chunk-FSYH7J75.js.map → chunk-3Y6BHIN6.js.map} +0 -0
- /package/dist/{chunk-FZZWTDWP.js.map → chunk-3YPL6T3P.js.map} +0 -0
- /package/dist/{chunk-JEZMWJEF.js.map → chunk-44MVIRZH.js.map} +0 -0
- /package/dist/{chunk-27FIHFXF.js.map → chunk-45MMSBHA.js.map} +0 -0
- /package/dist/{chunk-7JB6SYJX.js.map → chunk-54ELBTKE.js.map} +0 -0
- /package/dist/{chunk-HWZO6HYZ.js.map → chunk-6QMDUDF2.js.map} +0 -0
- /package/dist/{chunk-FNBGRKS6.js.map → chunk-7V25UAQO.js.map} +0 -0
- /package/dist/{chunk-JOKPBYXP.js.map → chunk-DTEWAVNE.js.map} +0 -0
- /package/dist/{chunk-KAILF7QA.js.map → chunk-F43CV6UC.js.map} +0 -0
- /package/dist/{chunk-ACO7ZCR2.js.map → chunk-FKVJKLPI.js.map} +0 -0
- /package/dist/{chunk-2F5JUAHZ.js.map → chunk-GAJC4BQZ.js.map} +0 -0
- /package/dist/{chunk-L7N73ZAW.js.map → chunk-HAZAN4UM.js.map} +0 -0
- /package/dist/{chunk-6QJZA6EX.js.map → chunk-HI5XQOX2.js.map} +0 -0
- /package/dist/{chunk-BOENA6XR.js.map → chunk-HKGUKAQW.js.map} +0 -0
- /package/dist/{chunk-LJSCGIYH.js.map → chunk-HPRVFJPM.js.map} +0 -0
- /package/dist/{chunk-SDUOJRSV.js.map → chunk-IGLWLH73.js.map} +0 -0
- /package/dist/{chunk-3AKH7ODX.js.map → chunk-INSIW65E.js.map} +0 -0
- /package/dist/{chunk-2P3NJTHE.js.map → chunk-JHFFUVON.js.map} +0 -0
- /package/dist/{chunk-2TO5F6CT.js.map → chunk-K5KNGC4I.js.map} +0 -0
- /package/dist/{chunk-HUWTFKEM.js.map → chunk-KAQ4Q3TO.js.map} +0 -0
- /package/dist/{chunk-GS5RZF7U.js.map → chunk-KLDMLWXT.js.map} +0 -0
- /package/dist/{chunk-HN2EN6P4.js.map → chunk-KNKDMTHU.js.map} +0 -0
- /package/dist/{chunk-R2KMLONN.js.map → chunk-MJDO4EXD.js.map} +0 -0
- /package/dist/{chunk-IHVUE3XF.js.map → chunk-NJA6NT3A.js.map} +0 -0
- /package/dist/{chunk-S3JKF3IK.js.map → chunk-OJJFANO6.js.map} +0 -0
- /package/dist/{chunk-GGGEGMWC.js.map → chunk-Q6RSJCXB.js.map} +0 -0
- /package/dist/{chunk-OTIUEUIS.js.map → chunk-QKEUKBRK.js.map} +0 -0
- /package/dist/{chunk-X52BVGCJ.js.map → chunk-QQDPRTLP.js.map} +0 -0
- /package/dist/{chunk-6AQSUBNR.js.map → chunk-RGCPELQN.js.map} +0 -0
- /package/dist/{chunk-LQ33RLHL.js.map → chunk-TFT2X7SH.js.map} +0 -0
- /package/dist/{chunk-IVHGQNIN.js.map → chunk-VHXCPXUS.js.map} +0 -0
- /package/dist/{chunk-7DW7GAM6.js.map → chunk-VU6GMWF6.js.map} +0 -0
- /package/dist/{chunk-YU3DLVSQ.js.map → chunk-XSCGUO2U.js.map} +0 -0
- /package/dist/{chunk-EPCIJLLU.js.map → chunk-XWROSMI5.js.map} +0 -0
- /package/dist/{chunk-HMT6L65V.js.map → chunk-YJGEVBKZ.js.map} +0 -0
- /package/dist/{chunk-I47ARU5G.js.map → chunk-ZS7JIUJ3.js.map} +0 -0
- /package/dist/{claude-cli-2YKABJJZ.js.map → claude-cli-GIIHOBGT.js.map} +0 -0
- /package/dist/{claude-install-7CVYQ73E.js.map → claude-install-BAUSJMW3.js.map} +0 -0
- /package/dist/{client-XMWEKXX7.js.map → client-3YQKORVK.js.map} +0 -0
- /package/dist/{codex-host-B6NAUWL6.js.map → codex-host-ZON3S6HU.js.map} +0 -0
- /package/dist/{config-THJANIU5.js.map → config-QZOBMTEL.js.map} +0 -0
- /package/dist/{config-names-JU54HYWY.js.map → config-names-Z5NZD5R2.js.map} +0 -0
- /package/dist/{config-rules-VNU23RL4.js.map → config-rules-YOYHS6YL.js.map} +0 -0
- /package/dist/{decision-JIIHDTOF.js.map → decision-QSKHOGCO.js.map} +0 -0
- /package/dist/{hook-command-UB7FOEUL.js.map → flush-stdio-NYIJ3QXT.js.map} +0 -0
- /package/dist/{hosts-WNQKYKP2.js.map → hook-command-VZ27MGWO.js.map} +0 -0
- /package/dist/{install-Q5SHHEDH.js.map → hosts-3EMTVM4H.js.map} +0 -0
- /package/dist/{install-funding-EGSW2KEP.js.map → install-ZA7L2UF3.js.map} +0 -0
- /package/dist/{install-identity-OID43B4D.js.map → install-funding-JDGYTF72.js.map} +0 -0
- /package/dist/{package-NRHU7HBR.js.map → install-identity-FFAYEFLX.js.map} +0 -0
- /package/dist/{passphrase-3JEVW5XG.js.map → new-install-5L4GY3LN.js.map} +0 -0
- /package/dist/{pay-I47AIUQR.js.map → package-BONDXSV3.js.map} +0 -0
- /package/dist/{routing-quote-QQW2I5MH.js.map → passphrase-T4ULBN4M.js.map} +0 -0
- /package/dist/{run-4SHEOBIU.js.map → pay-CMV5KL74.js.map} +0 -0
- /package/dist/{payments-A5FNI5GN.js.map → payments-Z6UBZL4Z.js.map} +0 -0
- /package/dist/{runtime-activate-N6VLQI2C.js.map → routing-quote-AHLAREXR.js.map} +0 -0
- /package/dist/{runtime-launchers-GMAUICRW.js.map → run-JH7ELYAM.js.map} +0 -0
- /package/dist/{runtime-BABJMHY7.js.map → runtime-2GX4ALJP.js.map} +0 -0
- /package/dist/{runtime-place-DOEWFTF3.js.map → runtime-activate-IDQ2NCSP.js.map} +0 -0
- /package/dist/{update-GTLMLFA3.js.map → runtime-launchers-YAPKCBHV.js.map} +0 -0
- /package/dist/{usdc-25RNBYYR.js.map → runtime-place-4POL4KK4.js.map} +0 -0
- /package/dist/{send-ECXS6JEO.js.map → send-ELXFKEKY.js.map} +0 -0
- /package/dist/{status-line-63XFJAXR.js.map → status-line-IH5JBWBC.js.map} +0 -0
- /package/dist/{streamableHttp-Z3YF6LTQ.js.map → streamableHttp-CP2ZQBIK.js.map} +0 -0
- /package/dist/{viemAdapter-By13KInL-3CG63XDX.js.map → update-EUIX72IX.js.map} +0 -0
- /package/dist/{usage-FCWP2CHO.js.map → usage-EKDC7LUC.js.map} +0 -0
- /package/dist/{wallet-CJGEHP2Q.js.map → usdc-YIHK2OMC.js.map} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/lib/wallet/spend.ts"],"sourcesContent":["import { mkdir } from 'node:fs/promises';\nimport { randomUUID } from 'node:crypto';\nimport { writeFileAtomic } from '../atomic-json';\nimport { withFileLock } from '../lock';\nimport { spendLedgerPath } from '../paths';\nimport {\n DEFAULT_WINDOW_MS,\n emptyLedger,\n readLedger,\n RESERVATION_TTL_MS,\n spentOf,\n type Ledger,\n type Reservation,\n} from '../spend-ledger';\nimport {\n evaluateSpendPolicy,\n type PolicyReason,\n type SpendDecision,\n type SpendPolicy,\n type PaymentMode,\n} from '../policy';\nimport type { PolicyEnforcement } from './provider';\n\n/**\n * The spend-policy enforcement seam, deliberately in the WALLET PROVIDER layer,\n * BEFORE any signing/payment path, so a future hosted provider (Privy, B5)\n * inherits it: policy moves provider-side by swapping this local authorizer for\n * one the hosted signer enforces. The local authorizer is `client-only` (any\n * process that runs the CLI can edit config or the ledger), and it says so.\n *\n * sessionBudget is enforced ATOMICALLY across the per-command CLI processes an\n * agent spawns: `authorize` takes the file lock and, when a spend may proceed,\n * writes a pending RESERVATION that counts against the budget immediately. Two\n * concurrent authorizations therefore each see the other's reservation and the\n * second is denied, closing the check-then-pay TOCTOU. `commit` finalizes a\n * reservation into committed spend after settlement; `release` drops an unused\n * one (a decline or a failed payment). A reservation left dangling (a crash\n * between authorize and commit) self-expires after RESERVATION_TTL_MS.\n */\n\nexport interface SpendRequest {\n mode?: PaymentMode;\n amountAtomic: bigint;\n creator: string;\n /** The caller's `--max-price` cap, if any. */\n maxPriceAtomic?: bigint;\n /**\n * THE SAME-TURN DUPLICATE GUARD. An opaque identity for the request being\n * paid for (its destination and its exact arguments), recorded on the\n * reservation. A second authorization carrying a key an unexpired reservation\n * already holds is DENIED rather than reserved, so one in-flight payment can\n * never become two because a caller retried, a harness re-fired, or a second\n * process asked for the same thing. Same lock and same file as the budget, so\n * the check is atomic across the per-command processes an agent spawns; the\n * reservation TTL is what bounds \"same turn\". Omit it and nothing changes.\n */\n requestKey?: string;\n}\n\nexport interface SpendAuthorization {\n decision: SpendDecision;\n reason: PolicyReason;\n message: string;\n amountAtomic: bigint;\n sessionSpentAtomic: bigint;\n sessionBudgetAtomic: bigint | null;\n policyEnforcement: PolicyEnforcement;\n /** The pending reservation to commit (on settlement) or release (on abort).\n * Present when the spend may proceed, including an unlimited budget. */\n reservationId?: string;\n}\n\nexport interface SpendAuthorizer {\n policyEnforcement: PolicyEnforcement;\n /** Evaluate a spend against policy + the rolling session ledger, atomically\n * reserving budget when the spend may proceed. */\n authorize(req: SpendRequest): Promise<SpendAuthorization>;\n /**\n * Finalize a reservation into committed spend after settlement. Runs only\n * post-settlement, so `amountAtomic` is authoritative: if the reservation\n * TTL-expired mid-confirm (a human can out-wait RESERVATION_TTL_MS at the\n * prompt), the settled amount is still recorded rather than silently lost\n * from the rolling budget.\n */\n commit(\n reservationId: string | undefined,\n amountAtomic: bigint,\n /** What the counterparty reported actually taking, when it said so at all.\n * Omitted means \"assume it took what was authorized\", the conservative\n * reading every caller had before the router began waiving fees. */\n opts?: { settledAtomic?: bigint; mode?: PaymentMode; nonce?: string },\n ): Promise<void>;\n /** Drop an unused reservation (a decline, a 409, or a failed payment). */\n release(reservationId: string | undefined): Promise<void>;\n}\n\nexport interface LocalSpendAuthorizerDeps {\n dir: string;\n policy: SpendPolicy;\n /** Rolling window length (ms); default 24h. Injectable for tests. */\n windowMs?: number;\n /** Clock seam for deterministic window tests. */\n now?: () => number;\n /**\n * Called at most ONCE per authorizer when the ledger file exists but cannot be\n * read back. The reset below is fail-open by design, and a silent one hands back\n * budget the operator believes is already spent — so the caller gets to say so.\n */\n onCorrupt?: (reason: string) => void;\n}\n\nexport function createLocalSpendAuthorizer(deps: LocalSpendAuthorizerDeps): SpendAuthorizer {\n const windowMs = deps.windowMs ?? DEFAULT_WINDOW_MS;\n const now = deps.now ?? Date.now;\n const path = spendLedgerPath(deps.dir);\n const lockPath = `${path}.lock`;\n // One notice per authorizer: authorize and commit each read the file, and the\n // reset is not persisted until something is written, so an unlatched warning\n // would fire twice for the same broken file within one command.\n let warnedCorrupt = false;\n\n // Roll the window and drop expired reservations; returns the live ledger.\n const freshen = (ledger: Ledger | null, nowMs: number): Ledger => {\n if (ledger === null || nowMs - ledger.windowStartMs >= windowMs) return emptyLedger(nowMs);\n return {\n ...ledger,\n reservations: ledger.reservations.filter((r) => nowMs - r.atMs < RESERVATION_TTL_MS),\n };\n };\n\n const persist = async (ledger: Ledger): Promise<void> => {\n await writeFileAtomic(path, `${JSON.stringify(ledger, null, 2)}\\n`, {\n mode: 0o600,\n dirMode: 0o700,\n });\n };\n\n async function withLedger<T>(fn: (ledger: Ledger, nowMs: number) => Promise<T> | T): Promise<T> {\n await mkdir(deps.dir, { recursive: true, mode: 0o700 });\n return withFileLock(lockPath, async () => {\n const nowMs = now();\n const read = await readLedger(path);\n if (read.corrupt !== undefined && !warnedCorrupt) {\n warnedCorrupt = true;\n deps.onCorrupt?.(read.corrupt);\n }\n const ledger = freshen(read.ledger, nowMs);\n return fn(ledger, nowMs);\n });\n }\n\n return {\n policyEnforcement: 'client-only',\n async authorize(req: SpendRequest): Promise<SpendAuthorization> {\n return withLedger(async (ledger) => {\n const sessionSpentAtomic = spentOf(ledger);\n if (\n req.requestKey !== undefined &&\n ledger.reservations.some((r) => r.requestKey === req.requestKey)\n ) {\n return {\n decision: 'deny',\n reason: 'duplicate_in_flight',\n message:\n 'An identical request already holds a reservation in this turn. No second payment was made.',\n amountAtomic: req.amountAtomic,\n sessionSpentAtomic,\n sessionBudgetAtomic: deps.policy.sessionBudgetAtomic,\n policyEnforcement: 'client-only',\n };\n }\n const evaluation = evaluateSpendPolicy(deps.policy, {\n mode: req.mode ?? 'automatic',\n amountAtomic: req.amountAtomic,\n creator: req.creator,\n ...(req.maxPriceAtomic !== undefined ? { maxPriceAtomic: req.maxPriceAtomic } : {}),\n sessionSpentAtomic,\n });\n const base: SpendAuthorization = {\n ...evaluation,\n amountAtomic: req.amountAtomic,\n sessionSpentAtomic,\n sessionBudgetAtomic: deps.policy.sessionBudgetAtomic,\n policyEnforcement: 'client-only',\n };\n // Unlimited budgets still reserve to prevent identical in-flight requests.\n if (evaluation.decision === 'deny') {\n return base;\n }\n const reservation: Reservation = {\n id: randomUUID(),\n mode: req.mode ?? 'automatic',\n amountAtomic: req.amountAtomic.toString(),\n atMs: now(),\n ...(req.requestKey !== undefined ? { requestKey: req.requestKey } : {}),\n };\n await persist({ ...ledger, reservations: [...ledger.reservations, reservation] });\n return { ...base, reservationId: reservation.id };\n });\n },\n async commit(\n reservationId: string | undefined,\n amountAtomic: bigint,\n opts: { settledAtomic?: bigint; mode?: PaymentMode; nonce?: string } = {},\n ): Promise<void> {\n // Record transmitted exposure even if its reservation has expired.\n await withLedger(async (ledger) => {\n const reservation =\n reservationId !== undefined\n ? ledger.reservations.find((r) => r.id === reservationId)\n : undefined;\n const exposure =\n reservation !== undefined ? BigInt(reservation.amountAtomic) : amountAtomic;\n // TWO NUMBERS, ON PURPOSE. The budget keeps counting what left; the\n // settled total records what was taken, and they differ whenever a\n // counterparty waives a fee against an authorization already sent.\n const settled = opts.settledAtomic ?? exposure;\n const settledSoFar = BigInt(ledger.settledAtomic ?? ledger.committedAtomic);\n const mode = reservation ? (reservation.mode ?? 'automatic') : (opts.mode ?? 'automatic');\n await persist({\n ...ledger,\n committedAtomic: (BigInt(ledger.committedAtomic) + exposure).toString(),\n automaticCommittedAtomic: (\n BigInt(ledger.automaticCommittedAtomic ?? ledger.committedAtomic) +\n (mode === 'manual' ? 0n : exposure)\n ).toString(),\n settledAtomic: (settledSoFar + settled).toString(),\n reservations:\n reservationId !== undefined\n ? ledger.reservations.filter((r) => r.id !== reservationId)\n : ledger.reservations,\n // Keyed by the authorization's nonce, so a reconcile that proves it\n // was never charged can release this amount and nothing else.\n ...(opts.nonce !== undefined\n ? {\n exposures: [\n ...(ledger.exposures ?? []),\n {\n nonce: opts.nonce.toLowerCase(),\n amountAtomic: exposure.toString(),\n atMs: now(),\n mode,\n },\n ],\n }\n : {}),\n });\n });\n },\n async release(reservationId: string | undefined): Promise<void> {\n if (reservationId === undefined) return;\n await withLedger(async (ledger) => {\n if (!ledger.reservations.some((r) => r.id === reservationId)) return;\n await persist({\n ...ledger,\n reservations: ledger.reservations.filter((r) => r.id !== reservationId),\n });\n });\n },\n };\n}\n\n/**\n * GIVE BACK A PAYMENT THE CHAIN PROVED WAS NEVER CHARGED: its authorization\n * expired unused. Exactly the exposure recorded under that nonce comes off the\n * committed totals, once; a nonce from an earlier window, from a ledger an\n * older build wrote, or one already released finds nothing and changes\n * nothing. Returns the amount released, or null when the ledger could not be\n * updated, so the caller keeps the payment open and asks again.\n */\nexport async function releaseUnchargedExposure(\n dir: string,\n nonce: string,\n opts: { now?: () => number; windowMs?: number } = {},\n): Promise<bigint | null> {\n const path = spendLedgerPath(dir);\n const nowMs = (opts.now ?? Date.now)();\n try {\n return await withFileLock(`${path}.lock`, async () => {\n const { ledger } = await readLedger(path);\n if (ledger === null || nowMs - ledger.windowStartMs >= (opts.windowMs ?? DEFAULT_WINDOW_MS)) {\n return 0n;\n }\n const key = nonce.toLowerCase();\n const entry = (ledger.exposures ?? []).find((e) => e.nonce === key);\n if (entry === undefined) return 0n;\n const amount = BigInt(entry.amountAtomic);\n const less = (value: string | undefined, fallback: string): string => {\n const current = BigInt(value ?? fallback);\n return (current > amount ? current - amount : 0n).toString();\n };\n await writeFileAtomic(\n path,\n `${JSON.stringify(\n {\n ...ledger,\n committedAtomic: less(ledger.committedAtomic, '0'),\n ...(entry.mode === 'manual'\n ? {}\n : {\n automaticCommittedAtomic: less(\n ledger.automaticCommittedAtomic,\n ledger.committedAtomic,\n ),\n }),\n settledAtomic: less(ledger.settledAtomic, ledger.committedAtomic),\n exposures: (ledger.exposures ?? []).filter((e) => e.nonce !== key),\n },\n null,\n 2,\n )}\\n`,\n { mode: 0o600, dirMode: 0o700 },\n );\n return amount;\n });\n } catch {\n return null;\n }\n}\n\nexport { readSpendSummary, type SpendSummary } from '../spend-ledger';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA,SAAS,aAAa;AACtB,SAAS,kBAAkB;AA8GpB,SAAS,2BAA2B,MAAiD;AAC1F,QAAM,WAAW,KAAK,YAAY;AAClC,QAAM,MAAM,KAAK,OAAO,KAAK;AAC7B,QAAM,OAAO,gBAAgB,KAAK,GAAG;AACrC,QAAM,WAAW,GAAG,IAAI;AAIxB,MAAI,gBAAgB;AAGpB,QAAM,UAAU,CAAC,QAAuB,UAA0B;AAChE,QAAI,WAAW,QAAQ,QAAQ,OAAO,iBAAiB,SAAU,QAAO,YAAY,KAAK;AACzF,WAAO;AAAA,MACL,GAAG;AAAA,MACH,cAAc,OAAO,aAAa,OAAO,CAAC,MAAM,QAAQ,EAAE,OAAO,kBAAkB;AAAA,IACrF;AAAA,EACF;AAEA,QAAM,UAAU,OAAO,WAAkC;AACvD,UAAM,gBAAgB,MAAM,GAAG,KAAK,UAAU,QAAQ,MAAM,CAAC,CAAC;AAAA,GAAM;AAAA,MAClE,MAAM;AAAA,MACN,SAAS;AAAA,IACX,CAAC;AAAA,EACH;AAEA,iBAAe,WAAc,IAAmE;AAC9F,UAAM,MAAM,KAAK,KAAK,EAAE,WAAW,MAAM,MAAM,IAAM,CAAC;AACtD,WAAO,aAAa,UAAU,YAAY;AACxC,YAAM,QAAQ,IAAI;AAClB,YAAM,OAAO,MAAM,WAAW,IAAI;AAClC,UAAI,KAAK,YAAY,UAAa,CAAC,eAAe;AAChD,wBAAgB;AAChB,aAAK,YAAY,KAAK,OAAO;AAAA,MAC/B;AACA,YAAM,S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;AACA,aAAO;AAAA,IACT,CAAC;AAAA,EACH,QAAQ;AACN,WAAO;AAAA,EACT;AACF;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../src/lib/wallet/spend.ts"],"sourcesContent":["import { mkdir } from 'node:fs/promises';\nimport { randomUUID } from 'node:crypto';\nimport { writeFileAtomic } from '../atomic-json';\nimport { withFileLock } from '../lock';\nimport { spendLedgerPath } from '../paths';\nimport {\n DEFAULT_WINDOW_MS,\n emptyLedger,\n readLedger,\n RESERVATION_TTL_MS,\n spentOf,\n type Ledger,\n type Reservation,\n} from '../spend-ledger';\nimport {\n evaluateSpendPolicy,\n type PolicyReason,\n type SpendDecision,\n type SpendPolicy,\n type PaymentMode,\n} from '../policy';\nimport type { PolicyEnforcement } from './provider';\n\n/**\n * The spend-policy enforcement seam, deliberately in the WALLET PROVIDER layer,\n * BEFORE any signing/payment path, so a future hosted provider (Privy, B5)\n * inherits it: policy moves provider-side by swapping this local authorizer for\n * one the hosted signer enforces. The local authorizer is `client-only` (any\n * process that runs the CLI can edit config or the ledger), and it says so.\n *\n * sessionBudget is enforced ATOMICALLY across the per-command CLI processes an\n * agent spawns: `authorize` takes the file lock and, when a spend may proceed,\n * writes a pending RESERVATION that counts against the budget immediately. Two\n * concurrent authorizations therefore each see the other's reservation and the\n * second is denied, closing the check-then-pay TOCTOU. `commit` finalizes a\n * reservation into committed spend after settlement; `release` drops an unused\n * one (a decline or a failed payment). A reservation left dangling (a crash\n * between authorize and commit) self-expires after RESERVATION_TTL_MS.\n */\n\nexport interface SpendRequest {\n mode?: PaymentMode;\n amountAtomic: bigint;\n creator: string;\n /** The caller's `--max-price` cap, if any. */\n maxPriceAtomic?: bigint;\n /**\n * THE SAME-TURN DUPLICATE GUARD. An opaque identity for the request being\n * paid for (its destination and its exact arguments), recorded on the\n * reservation. A second authorization carrying a key an unexpired reservation\n * already holds is DENIED rather than reserved, so one in-flight payment can\n * never become two because a caller retried, a harness re-fired, or a second\n * process asked for the same thing. Same lock and same file as the budget, so\n * the check is atomic across the per-command processes an agent spawns; the\n * reservation TTL is what bounds \"same turn\". Omit it and nothing changes.\n */\n requestKey?: string;\n}\n\nexport interface SpendAuthorization {\n decision: SpendDecision;\n reason: PolicyReason;\n message: string;\n amountAtomic: bigint;\n sessionSpentAtomic: bigint;\n sessionBudgetAtomic: bigint | null;\n policyEnforcement: PolicyEnforcement;\n /** The pending reservation to commit (on settlement) or release (on abort).\n * Present when the spend may proceed, including an unlimited budget. */\n reservationId?: string;\n}\n\nexport interface SpendAuthorizer {\n policyEnforcement: PolicyEnforcement;\n /** Evaluate a spend against policy + the rolling session ledger, atomically\n * reserving budget when the spend may proceed. */\n authorize(req: SpendRequest): Promise<SpendAuthorization>;\n /**\n * Finalize a reservation into committed spend after settlement. Runs only\n * post-settlement, so `amountAtomic` is authoritative: if the reservation\n * TTL-expired mid-confirm (a human can out-wait RESERVATION_TTL_MS at the\n * prompt), the settled amount is still recorded rather than silently lost\n * from the rolling budget.\n */\n commit(\n reservationId: string | undefined,\n amountAtomic: bigint,\n /** What the counterparty reported actually taking, when it said so at all.\n * Omitted means \"assume it took what was authorized\", the conservative\n * reading every caller had before the router began waiving fees. */\n opts?: { settledAtomic?: bigint; mode?: PaymentMode; nonce?: string },\n ): Promise<void>;\n /** Drop an unused reservation (a decline, a 409, or a failed payment). */\n release(reservationId: string | undefined): Promise<void>;\n}\n\nexport interface LocalSpendAuthorizerDeps {\n dir: string;\n policy: SpendPolicy;\n /** Rolling window length (ms); default 24h. Injectable for tests. */\n windowMs?: number;\n /** Clock seam for deterministic window tests. */\n now?: () => number;\n /**\n * Called at most ONCE per authorizer when the ledger file exists but cannot be\n * read back. The reset below is fail-open by design, and a silent one hands back\n * budget the operator believes is already spent — so the caller gets to say so.\n */\n onCorrupt?: (reason: string) => void;\n}\n\nexport function createLocalSpendAuthorizer(deps: LocalSpendAuthorizerDeps): SpendAuthorizer {\n const windowMs = deps.windowMs ?? DEFAULT_WINDOW_MS;\n const now = deps.now ?? Date.now;\n const path = spendLedgerPath(deps.dir);\n const lockPath = `${path}.lock`;\n // One notice per authorizer: authorize and commit each read the file, and the\n // reset is not persisted until something is written, so an unlatched warning\n // would fire twice for the same broken file within one command.\n let warnedCorrupt = false;\n\n // Roll the window and drop expired reservations; returns the live ledger.\n const freshen = (ledger: Ledger | null, nowMs: number): Ledger => {\n if (ledger === null || nowMs - ledger.windowStartMs >= windowMs) return emptyLedger(nowMs);\n return {\n ...ledger,\n reservations: ledger.reservations.filter((r) => nowMs - r.atMs < RESERVATION_TTL_MS),\n };\n };\n\n const persist = async (ledger: Ledger): Promise<void> => {\n await writeFileAtomic(path, `${JSON.stringify(ledger, null, 2)}\\n`, {\n mode: 0o600,\n dirMode: 0o700,\n });\n };\n\n async function withLedger<T>(fn: (ledger: Ledger, nowMs: number) => Promise<T> | T): Promise<T> {\n await mkdir(deps.dir, { recursive: true, mode: 0o700 });\n return withFileLock(lockPath, async () => {\n const nowMs = now();\n const read = await readLedger(path);\n if (read.corrupt !== undefined && !warnedCorrupt) {\n warnedCorrupt = true;\n deps.onCorrupt?.(read.corrupt);\n }\n const ledger = freshen(read.ledger, nowMs);\n return fn(ledger, nowMs);\n });\n }\n\n return {\n policyEnforcement: 'client-only',\n async authorize(req: SpendRequest): Promise<SpendAuthorization> {\n return withLedger(async (ledger) => {\n const sessionSpentAtomic = spentOf(ledger);\n if (\n req.requestKey !== undefined &&\n ledger.reservations.some((r) => r.requestKey === req.requestKey)\n ) {\n return {\n decision: 'deny',\n reason: 'duplicate_in_flight',\n message:\n 'An identical request already holds a reservation in this turn. No second payment was made.',\n amountAtomic: req.amountAtomic,\n sessionSpentAtomic,\n sessionBudgetAtomic: deps.policy.sessionBudgetAtomic,\n policyEnforcement: 'client-only',\n };\n }\n const evaluation = evaluateSpendPolicy(deps.policy, {\n mode: req.mode ?? 'automatic',\n amountAtomic: req.amountAtomic,\n creator: req.creator,\n ...(req.maxPriceAtomic !== undefined ? { maxPriceAtomic: req.maxPriceAtomic } : {}),\n sessionSpentAtomic,\n });\n const base: SpendAuthorization = {\n ...evaluation,\n amountAtomic: req.amountAtomic,\n sessionSpentAtomic,\n sessionBudgetAtomic: deps.policy.sessionBudgetAtomic,\n policyEnforcement: 'client-only',\n };\n // Unlimited budgets still reserve to prevent identical in-flight requests.\n if (evaluation.decision === 'deny') {\n return base;\n }\n const reservation: Reservation = {\n id: randomUUID(),\n mode: req.mode ?? 'automatic',\n amountAtomic: req.amountAtomic.toString(),\n atMs: now(),\n ...(req.requestKey !== undefined ? { requestKey: req.requestKey } : {}),\n };\n await persist({ ...ledger, reservations: [...ledger.reservations, reservation] });\n return { ...base, reservationId: reservation.id };\n });\n },\n async commit(\n reservationId: string | undefined,\n amountAtomic: bigint,\n opts: { settledAtomic?: bigint; mode?: PaymentMode; nonce?: string } = {},\n ): Promise<void> {\n // Record transmitted exposure even if its reservation has expired.\n await withLedger(async (ledger) => {\n const reservation =\n reservationId !== undefined\n ? ledger.reservations.find((r) => r.id === reservationId)\n : undefined;\n const exposure =\n reservation !== undefined ? BigInt(reservation.amountAtomic) : amountAtomic;\n // TWO NUMBERS, ON PURPOSE. The budget keeps counting what left; the\n // settled total records what was taken, and they differ whenever a\n // counterparty waives a fee against an authorization already sent.\n const settled = opts.settledAtomic ?? exposure;\n const settledSoFar = BigInt(ledger.settledAtomic ?? ledger.committedAtomic);\n const mode = reservation ? (reservation.mode ?? 'automatic') : (opts.mode ?? 'automatic');\n await persist({\n ...ledger,\n committedAtomic: (BigInt(ledger.committedAtomic) + exposure).toString(),\n automaticCommittedAtomic: (\n BigInt(ledger.automaticCommittedAtomic ?? ledger.committedAtomic) +\n (mode === 'manual' ? 0n : exposure)\n ).toString(),\n settledAtomic: (settledSoFar + settled).toString(),\n reservations:\n reservationId !== undefined\n ? ledger.reservations.filter((r) => r.id !== reservationId)\n : ledger.reservations,\n // Keyed by the authorization's nonce, so a reconcile that proves it\n // was never charged can release this amount and nothing else.\n ...(opts.nonce !== undefined\n ? {\n exposures: [\n ...(ledger.exposures ?? []),\n {\n nonce: opts.nonce.toLowerCase(),\n amountAtomic: exposure.toString(),\n atMs: now(),\n mode,\n },\n ],\n }\n : {}),\n });\n });\n },\n async release(reservationId: string | undefined): Promise<void> {\n if (reservationId === undefined) return;\n await withLedger(async (ledger) => {\n if (!ledger.reservations.some((r) => r.id === reservationId)) return;\n await persist({\n ...ledger,\n reservations: ledger.reservations.filter((r) => r.id !== reservationId),\n });\n });\n },\n };\n}\n\n/**\n * GIVE BACK A PAYMENT THE CHAIN PROVED WAS NEVER CHARGED: its authorization\n * expired unused. Exactly the exposure recorded under that nonce comes off the\n * committed totals, once; a nonce from an earlier window, from a ledger an\n * older build wrote, or one already released finds nothing and changes\n * nothing. Returns the amount released, or null when the ledger could not be\n * updated, so the caller keeps the payment open and asks again.\n */\nexport async function releaseUnchargedExposure(\n dir: string,\n nonce: string,\n opts: { now?: () => number; windowMs?: number } = {},\n): Promise<bigint | null> {\n const path = spendLedgerPath(dir);\n const nowMs = (opts.now ?? Date.now)();\n try {\n return await withFileLock(`${path}.lock`, async () => {\n const { ledger } = await readLedger(path);\n if (ledger === null || nowMs - ledger.windowStartMs >= (opts.windowMs ?? DEFAULT_WINDOW_MS)) {\n return 0n;\n }\n const key = nonce.toLowerCase();\n const entry = (ledger.exposures ?? []).find((e) => e.nonce === key);\n if (entry === undefined) return 0n;\n const amount = BigInt(entry.amountAtomic);\n const less = (value: string | undefined, fallback: string): string => {\n const current = BigInt(value ?? fallback);\n return (current > amount ? current - amount : 0n).toString();\n };\n await writeFileAtomic(\n path,\n `${JSON.stringify(\n {\n ...ledger,\n committedAtomic: less(ledger.committedAtomic, '0'),\n ...(entry.mode === 'manual'\n ? {}\n : {\n automaticCommittedAtomic: less(\n ledger.automaticCommittedAtomic,\n ledger.committedAtomic,\n ),\n }),\n settledAtomic: less(ledger.settledAtomic, ledger.committedAtomic),\n exposures: (ledger.exposures ?? []).filter((e) => e.nonce !== key),\n },\n null,\n 2,\n )}\\n`,\n { mode: 0o600, dirMode: 0o700 },\n );\n return amount;\n });\n } catch {\n return null;\n }\n}\n\n/**\n * GIVE BACK WHAT A CONFIRMED REFUND RETURNED. A worker run's own channel was closed and\n * the chain shows its unused deposit back in the wallet. The run's deposits were counted\n * in full as they were sent, under `run.prefix`; what came back comes off the committed\n * totals, so the budget counts what the run cost. Never more than those deposits still\n * count in this window: a refund cannot offset other spend or lift the budget above its\n * size. The run's entries are replaced by one for what it kept (`run.kept`), so a second\n * call for the same run, in this process or after a restart, finds nothing and changes\n * nothing, and so does one after the window rolled. Returns the amount given back, or\n * null when the ledger could not be updated, so the caller keeps the refund pending.\n */\nexport async function creditRefundedExposure(\n dir: string,\n run: { prefix: string; kept: string },\n refundedAtomic: bigint,\n opts: { now?: () => number; windowMs?: number } = {},\n): Promise<bigint | null> {\n const path = spendLedgerPath(dir);\n const nowMs = (opts.now ?? Date.now)();\n try {\n return await withFileLock(`${path}.lock`, async () => {\n const { ledger } = await readLedger(path);\n if (ledger === null || nowMs - ledger.windowStartMs >= (opts.windowMs ?? DEFAULT_WINDOW_MS)) {\n return 0n;\n }\n const exposures = ledger.exposures ?? [];\n // A run's deposits are automatic. Anything else under its prefix is not its deposit.\n const own = exposures.filter((e) => e.nonce.startsWith(run.prefix) && e.mode !== 'manual');\n if (own.length === 0) return 0n;\n const counted = own.reduce((sum, e) => sum + BigInt(e.amountAtomic), 0n);\n const amount = refundedAtomic < counted ? refundedAtomic : counted;\n const less = (value: string | undefined, fallback: string): string => {\n const current = BigInt(value ?? fallback);\n return (current > amount ? current - amount : 0n).toString();\n };\n await writeFileAtomic(\n path,\n `${JSON.stringify(\n {\n ...ledger,\n committedAtomic: less(ledger.committedAtomic, '0'),\n automaticCommittedAtomic: less(ledger.automaticCommittedAtomic, ledger.committedAtomic),\n settledAtomic: less(ledger.settledAtomic, ledger.committedAtomic),\n exposures: [\n ...exposures.filter((e) => !own.includes(e)),\n ...(counted > amount\n ? [\n {\n nonce: run.kept,\n amountAtomic: (counted - amount).toString(),\n atMs: nowMs,\n mode: 'automatic' as const,\n },\n ]\n : []),\n ],\n },\n null,\n 2,\n )}\\n`,\n { mode: 0o600, dirMode: 0o700 },\n );\n return amount;\n });\n } catch {\n return null;\n }\n}\n\nexport { readSpendSummary, type SpendSummary } from '../spend-ledger';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA,SAAS,aAAa;AACtB,SAAS,kBAAkB;AA8GpB,SAAS,2BAA2B,MAAiD;AAC1F,QAAM,WAAW,KAAK,YAAY;AAClC,QAAM,MAAM,KAAK,OAAO,KAAK;AAC7B,QAAM,OAAO,gBAAgB,KAAK,GAAG;AACrC,QAAM,WAAW,GAAG,IAAI;AAIxB,MAAI,gBAAgB;AAGpB,QAAM,UAAU,CAAC,QAAuB,UAA0B;AAChE,QAAI,WAAW,QAAQ,QAAQ,OAAO,iBAAiB,SAAU,QAAO,YAAY,KAAK;AACzF,WAAO;AAAA,MACL,GAAG;AAAA,MACH,cAAc,OAAO,aAAa,OAAO,CAAC,MAAM,QAAQ,EAAE,OAAO,kBAAkB;AAAA,IACrF;AAAA,EACF;AAEA,QAAM,UAAU,OAAO,WAAkC;AACvD,UAAM,gBAAgB,MAAM,GAAG,KAAK,UAAU,QAAQ,MAAM,CAAC,CAAC;AAAA,GAAM;AAAA,MAClE,MAAM;AAAA,MACN,SAAS;AAAA,IACX,CAAC;AAAA,EACH;AAEA,iBAAe,WAAc,IAAmE;AAC9F,UAAM,MAAM,KAAK,KAAK,EAAE,WAAW,MAAM,MAAM,IAAM,CAAC;AACtD,WAAO,aAAa,UAAU,YAAY;AACxC,YAAM,QAAQ,IAAI;AAClB,YAAM,OAAO,MAAM,WAAW,IAAI;AAClC,UAAI,KAAK,YAAY,UAAa,CAAC,eAAe;AAChD,wBAAgB;AAChB,aAAK,YAAY,KAAK,OAAO;AAAA,MAC/B;AACA,YAAM,SAAS,QAAQ,KAAK,QAAQ,KAAK;AACzC,aAAO,GAAG,QAAQ,KAAK;AAAA,IACzB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AA,cACF,IACA,CAAC;AAAA,YACP;AAAA,UACF;AAAA,UACA;AAAA,UACA;AAAA,QACF,CAAC;AAAA;AAAA,QACD,EAAE,MAAM,KAAO,SAAS,IAAM;AAAA,MAChC;AACA,aAAO;AAAA,IACT,CAAC;AAAA,EACH,QAAQ;AACN,WAAO;AAAA,EACT;AACF;","names":[]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createRequire as __tenjinCreateRequire } from 'node:module'; const require = __tenjinCreateRequire(import.meta.url);
|
|
2
2
|
import {
|
|
3
3
|
LATEST_PROTOCOL_VERSION
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-54ELBTKE.js";
|
|
5
5
|
import {
|
|
6
6
|
NEVER,
|
|
7
7
|
ZodIssueCode,
|
|
@@ -15,7 +15,7 @@ import {
|
|
|
15
15
|
object,
|
|
16
16
|
string,
|
|
17
17
|
url
|
|
18
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-P6YQWIT2.js";
|
|
19
19
|
|
|
20
20
|
// node_modules/.pnpm/pkce-challenge@5.0.1/node_modules/pkce-challenge/dist/index.node.js
|
|
21
21
|
var crypto;
|
|
@@ -1093,4 +1093,4 @@ export {
|
|
|
1093
1093
|
fetchToken,
|
|
1094
1094
|
registerClient
|
|
1095
1095
|
};
|
|
1096
|
-
//# sourceMappingURL=chunk-
|
|
1096
|
+
//# sourceMappingURL=chunk-GAJC4BQZ.js.map
|
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
} from "./chunk-3MZ7DYRO.js";
|
|
8
8
|
import {
|
|
9
9
|
external_exports
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-P6YQWIT2.js";
|
|
11
11
|
|
|
12
12
|
// src/router/router-observation.ts
|
|
13
13
|
import { readFile, readdir, rm } from "node:fs/promises";
|
|
@@ -189,4 +189,4 @@ export {
|
|
|
189
189
|
writeUnlockRecord,
|
|
190
190
|
markUnlockPending
|
|
191
191
|
};
|
|
192
|
-
//# sourceMappingURL=chunk-
|
|
192
|
+
//# sourceMappingURL=chunk-HAZAN4UM.js.map
|
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
} from "./chunk-XRGFH7FI.js";
|
|
11
11
|
import {
|
|
12
12
|
readPassphraseRecord
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-ZS7JIUJ3.js";
|
|
14
14
|
import {
|
|
15
15
|
FILE_STORE_FAILED_FIX,
|
|
16
16
|
KEYCHAIN_LOCKED_FIX,
|
|
@@ -390,4 +390,4 @@ export {
|
|
|
390
390
|
promptPassphrase,
|
|
391
391
|
unstorableWhy
|
|
392
392
|
};
|
|
393
|
-
//# sourceMappingURL=chunk-
|
|
393
|
+
//# sourceMappingURL=chunk-HI5XQOX2.js.map
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { createRequire as __tenjinCreateRequire } from 'node:module'; const require = __tenjinCreateRequire(import.meta.url);
|
|
2
2
|
import {
|
|
3
3
|
HARNESSES
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-IULCDMVG.js";
|
|
5
5
|
import {
|
|
6
6
|
personalSettingsAt
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-W2GXIARJ.js";
|
|
8
8
|
import {
|
|
9
9
|
writeFileAtomic,
|
|
10
10
|
writeFileAtomicExclusive
|
|
@@ -14,13 +14,13 @@ import {
|
|
|
14
14
|
ChoicesSchema,
|
|
15
15
|
OfferSpecSchema,
|
|
16
16
|
reportSpecOutcome
|
|
17
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-ZEYA2WWX.js";
|
|
18
18
|
import {
|
|
19
19
|
SettingsHashSchema
|
|
20
|
-
} from "./chunk-
|
|
20
|
+
} from "./chunk-RGCPELQN.js";
|
|
21
21
|
import {
|
|
22
22
|
external_exports
|
|
23
|
-
} from "./chunk-
|
|
23
|
+
} from "./chunk-P6YQWIT2.js";
|
|
24
24
|
|
|
25
25
|
// src/router/specs.ts
|
|
26
26
|
import { createHash, randomUUID } from "node:crypto";
|
|
@@ -485,4 +485,4 @@ export {
|
|
|
485
485
|
claimIgnored,
|
|
486
486
|
reportIgnored
|
|
487
487
|
};
|
|
488
|
-
//# sourceMappingURL=chunk-
|
|
488
|
+
//# sourceMappingURL=chunk-HKGUKAQW.js.map
|
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
} from "./chunk-JTX3BUDK.js";
|
|
8
8
|
import {
|
|
9
9
|
external_exports
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-P6YQWIT2.js";
|
|
11
11
|
|
|
12
12
|
// src/lib/spend-ledger.ts
|
|
13
13
|
import { readFile } from "node:fs/promises";
|
|
@@ -111,4 +111,4 @@ export {
|
|
|
111
111
|
readLedger,
|
|
112
112
|
readSpendSummary
|
|
113
113
|
};
|
|
114
|
-
//# sourceMappingURL=chunk-
|
|
114
|
+
//# sourceMappingURL=chunk-HPRVFJPM.js.map
|
|
@@ -8,15 +8,12 @@ import {
|
|
|
8
8
|
WALLET_REASONS,
|
|
9
9
|
agentFixFor
|
|
10
10
|
} from "./chunk-RFZA7PSM.js";
|
|
11
|
-
import {
|
|
12
|
-
MAX_AUTO_SPEND_FLOOR_ATOMIC
|
|
13
|
-
} from "./chunk-VH7JMLTG.js";
|
|
14
11
|
import {
|
|
15
12
|
DEPOSIT_DEFERRED,
|
|
16
13
|
NO_PAYER,
|
|
17
14
|
TOPPING_UP,
|
|
18
15
|
TOP_UP_UNAVAILABLE
|
|
19
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-ZEYA2WWX.js";
|
|
20
17
|
|
|
21
18
|
// src/router/fee.ts
|
|
22
19
|
import { join } from "node:path";
|
|
@@ -93,7 +90,7 @@ var UNPAID = {
|
|
|
93
90
|
// name the setting that is.
|
|
94
91
|
limit_below_deposit: {
|
|
95
92
|
reason: "the per-call spend limit cannot cover the routing fee or its deposit",
|
|
96
|
-
fix:
|
|
93
|
+
fix: "Your balance is fine; this is the per-call limit. Choose an amount that covers the routing fee or its deposit with `tenjin config set maxAutoSpend <usd>`."
|
|
97
94
|
},
|
|
98
95
|
budget_reached: {
|
|
99
96
|
reason: "today's spend limit is used up",
|
|
@@ -177,4 +174,4 @@ export {
|
|
|
177
174
|
payerDir,
|
|
178
175
|
usd
|
|
179
176
|
};
|
|
180
|
-
//# sourceMappingURL=chunk-
|
|
177
|
+
//# sourceMappingURL=chunk-HZKANST2.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/router/fee.ts"],"sourcesContent":["import { join } from 'node:path';\nimport { atomicToUsd, formatUsdDisplay } from '../lib/money';\nimport { evaluateSpendPolicy, type PolicyReason, type SpendPolicy } from '../lib/policy';\nimport {\n DEPOSIT_DEFERRED,\n NO_PAYER,\n TOP_UP_UNAVAILABLE,\n TOPPING_UP,\n type DecisionRoute,\n} from './decision';\nimport { agentFixFor, WALLET_REASONS } from './wallet-reasons';\n\n/**\n * THE ROUTING FEE, WITHOUT ANYTHING THAT PAYS. Every routing call goes to the\n * paid route and pays the fee its 402 quotes over x402 `batch-settlement`, and\n * the stock SDK client in `tenjin mcp` does all of it (`routing-payer.ts`).\n * Nothing else pays it: a call without that payer is skipped when the route\n * asks for it.\n *\n * THE SERVER QUOTES, THIS CLIENT CAPS. The fee is the server's to set, so no\n * fee amount lives here: only the ceiling a quote must not pass, like\n * EIP-1559's `maxFeePerGas`, and the spend limits that bound it beside that.\n *\n * Hook-safe: `tenjin hook` loads this module, and its chunk graph stays free\n * of the wallet and the x402 SDK (`dist-chunks.test.ts`).\n */\n\n/**\n * THE ROUTING FEE CEILING, atomic USDC ($0.25): the most one routing answer\n * pays, and the most one routing deposit holds ({@link MAX_CHANNEL_DEPOSIT_ATOMIC}).\n * The router quotes each answer its own fee, usually far below this; a quote\n * at or below it is paid inside the spend limits, and one above it is not\n * paid at all ({@link FEE_ABOVE_CEILING}). It is a limit, not a price.\n */\nexport const ROUTING_FEE_CEILING_ATOMIC = 250_000n;\n/**\n * THE ROUTER'S FIXED QUOTE ($0.003), which it still offers beside a per-answer\n * quote for the CLIs released before per-answer quotes. This client pays it\n * only when it is the 402's only routing offer (`routing-quote.ts`). An\n * estimate with no 402 in hand (doctor's funded-enough check, the fund line\n * under an empty wallet) sizes from it.\n */\nexport const LEGACY_ROUTING_QUOTE_ATOMIC = 3_000n;\n/** The skip reason for a quote above {@link ROUTING_FEE_CEILING_ATOMIC}. */\nexport const FEE_ABOVE_CEILING = 'fee_above_ceiling';\n/** The deposit hint ($0.05) when a 402 carries no `extra.minDeposit`: the\n * production server's own, and the one doctor sizes from with no 402. */\nexport const CHANNEL_DEPOSIT_ATOMIC = 50_000n;\n/** Tenjin's maximum deposit per top-up ($0.25), independent of the SDK's larger bound. */\nexport const MAX_CHANNEL_DEPOSIT_ATOMIC = 250_000n;\n/** Keep this much USDC outside the routing channel for provider payments. */\nexport const ROUTING_WALLET_RESERVE_ATOMIC = 10_000n;\n/** Buffered top-up for a wallet that cannot fit the normal SDK target. */\nexport const SMALL_CHANNEL_DEPOSIT_ATOMIC = 10_000n;\n/** Below ten cents liquid, use the small deposit even when the buffer fits. */\nexport const SMALL_WALLET_THRESHOLD_ATOMIC = 100_000n;\n\n/** Use the SDK target when it fits at ten cents or more; otherwise use the\n * small target, raised for a larger voucher deficit. Shrink to the balance\n * above the reserve; zero refuses less than the deficit. Null is doctor's estimate. */\nexport function routingDepositAtomic(o: {\n suggestedAtomic: bigint;\n neededAtomic: bigint;\n balanceAtomic: bigint | null;\n perCallAtomic: bigint;\n maxAtomic: bigint;\n}): bigint {\n const least = (a: bigint, b: bigint) => (b < a ? b : a);\n const target = least(least(o.suggestedAtomic, o.perCallAtomic), o.maxAtomic);\n if (o.balanceAtomic === null) return target;\n if (\n o.balanceAtomic >= SMALL_WALLET_THRESHOLD_ATOMIC &&\n o.balanceAtomic >= target + ROUTING_WALLET_RESERVE_ATOMIC\n )\n return target;\n const smaller = least(\n target,\n o.neededAtomic > SMALL_CHANNEL_DEPOSIT_ATOMIC ? o.neededAtomic : SMALL_CHANNEL_DEPOSIT_ATOMIC,\n );\n const available = o.balanceAtomic - ROUTING_WALLET_RESERVE_ATOMIC;\n const amount = least(smaller, available);\n return amount > 0n && amount >= o.neededAtomic ? amount : 0n;\n}\n\n/**\n * The top-up every \"add funds\" hint names, in USD: the checkout's Apple\n * Pay and Google Pay minimum, which covers the routing deposit and a few\n * hundred lookups. `tenjin fund` sends it to the checkout as a preset.\n */\nexport const SUGGESTED_FUND_USD = '5';\n/** The funding line a new wallet is told, after `tenjin wallet create`. */\nexport const FUNDING_LINE = `Add funds with \\`tenjin fund ${SUGGESTED_FUND_USD}\\`, or send USDC from a crypto wallet with \\`tenjin fund --usdc\\`.`;\n/** The funding line under a balance of exactly $0, in `tenjin balance` and `tenjin status`. */\nexport const FUND_COMMAND_LINE = 'Add funds with `tenjin fund`, or ask your agent.';\n\n/** The most a fund link's `need` may name as its price (the link route's bound). */\nconst NEED_PRICE_MAX_ATOMIC = 100_000_000n;\n/** A `--for` label: the link route takes 1 to 60 characters. */\nconst NEED_LABEL_MAX = 60;\n\n/**\n * THE COMMAND THAT OPENS CHECKOUT FOR ONE WAITING CALL: `tenjin fund 5 --for\n * \"X post read\" --price 0.006`, so the checkout page says what the money is\n * for. The amount is the suggested top-up, or the price in whole dollars when\n * that is more. The label keeps only characters that are inert inside double\n * quotes in any shell.\n */\nexport function fundForCommand(label: string, priceAtomic: bigint): string {\n const wholePrice = (priceAtomic + 999_999n) / 1_000_000n;\n const amount =\n wholePrice > BigInt(SUGGESTED_FUND_USD) ? wholePrice.toString() : SUGGESTED_FUND_USD;\n const safe = [\n ...label\n .replace(/[^\\p{L}\\p{N} .,:'()/+&-]/gu, ' ')\n .replace(/\\s+/g, ' ')\n .trim(),\n ]\n .slice(0, NEED_LABEL_MAX)\n .join('')\n .trim();\n const named =\n safe.length > 0 && priceAtomic > 0n && priceAtomic <= NEED_PRICE_MAX_ATOMIC\n ? ` --for \"${safe}\" --price ${atomicToUsd(priceAtomic.toString())}`\n : '';\n return `tenjin fund ${amount}${named}`;\n}\n\n/**\n * A PAID CALL REFUSED FOR LOW FUNDS, said with what the money is for: \"This X\n * post read costs $0.006, more than your Tenjin balance. Ask the person once\n * to add funds; on yes, run `tenjin fund 5 --for \"X post read\" --price\n * 0.006`.\" That command opens checkout with the call named on the page. A\n * service with no display label is named by its provider (\"A call to\n * BlockRun costs …\").\n */\nexport function shortOfFunds(o: {\n label?: string | undefined;\n provider: string;\n priceAtomic: bigint;\n}): string {\n const subject = o.label !== undefined ? `This ${o.label}` : `A call to ${o.provider}`;\n return `${subject} costs $${usd(o.priceAtomic)}, more than your Tenjin balance. Ask the person once to add funds; on yes, run \\`${fundForCommand(o.label ?? o.provider, o.priceAtomic)}\\`.`;\n}\n/** The spend ledger key a deposit's exposure is recorded under, before its id. */\nexport const ROUTING_DEPOSIT_KEY = 'routing-deposit:';\n\n/** A spend refusal, as the reason the call was not paid. */\nconst REFUSED: Partial<Record<PolicyReason, string>> = {\n not_allowlisted: 'not_allowlisted',\n session_budget_exceeded: 'budget_reached',\n above_auto_spend: 'limit_below_deposit',\n};\n\n/** The reason a spend refusal leaves a routing call unpaid. */\nexport function refusedWhy(reason: PolicyReason): string {\n return REFUSED[reason] ?? reason;\n}\n\n/**\n * THE DEPOSIT IS THE SPEND. It meets the whole policy once, the day's budget\n * included, when the SDK's `depositStrategy` reserves it. Each fee paid from\n * it then gets only the per-payment checks, at the amount quoted: the per-call\n * limit, the creator allowlist (the router's host) and an explicit zero daily\n * limit. It is never refused for the day's running total, which the deposit\n * already consumed. Null when those checks allow the fee.\n */\nexport function feeRefusal(policy: SpendPolicy, host: string, feeAtomic: bigint): string | null {\n const evaluation = evaluateSpendPolicy(\n { ...policy, sessionBudgetAtomic: policy.sessionBudgetAtomic === 0n ? 0n : null },\n { mode: 'automatic', amountAtomic: feeAtomic, creator: host, sessionSpentAtomic: 0n },\n );\n return evaluation.decision === 'allow' ? null : refusedWhy(evaluation.reason);\n}\n\n/** The payer's route for a call to the router at `baseUrl`. `tenjin mcp`\n * passes its payer's; absent, a call goes unpaid. */\nexport type RouteFor = (baseUrl: string) => DecisionRoute;\n\n/**\n * WHY A CALL WAS NOT PAID, for the user: the reason and the fix, keyed by the\n * payer's skip reason (or `no_payer`, when the route asked for the fee and\n * nothing could pay it). Null for a reason that is no fault and needs no\n * fix: another session's call on the channel, or a call queued past its own\n * budget, or a payment still out when the call's\n * budget ran out (it finishes in the background), or an unlock that did not\n * finish inside the call's budget (it keeps running, and the next call gets\n * its answer), or a balance read before a deposit that failed or ran out of\n * time (nothing was signed or sent), or a deposit the background top-up has\n * not made yet.\n *\n * THE WALLET'S OWN REASONS ARE `WALLET_REASONS`, spread in rather than written\n * twice, so a notice names the same cause in the same words as doctor. They\n * carry the PERSON `fix`, never `agentFix`: this sentence goes in the hook's\n * `systemMessage`, which the harness shows the person (B1, decision 15), and a\n * fix that names `tenjin wallet repair` says it asks in their own terminal.\n */\nconst WALLET_UNPAID: Record<string, { reason: string; fix: string }> = Object.fromEntries(\n Object.entries(WALLET_REASONS).map(([key, { reason, fix }]) => [key, { reason, fix }]),\n);\nconst UNPAID: Record<string, { reason: string; fix: string }> = {\n wallet_low: {\n // The least a wallet routes with ({@link routingDepositAtomic}): the\n // reserve kept for provider payments plus a deposit of one fixed quote,\n // $0.013. A dearer answer needs more, so the line says \"at least\".\n reason: `the wallet holds less than Tenjin needs to set aside for routing (at least $${usd(ROUTING_WALLET_RESERVE_ATOMIC + LEGACY_ROUTING_QUOTE_ATOMIC)})`,\n fix: `Add funds with \\`tenjin fund ${SUGGESTED_FUND_USD}\\`.`,\n },\n ...WALLET_UNPAID,\n // A SPEND LIMIT IS NEVER A FUNDING PROBLEM: adding money cannot help, so\n // these never point at checkout. They say the balance is not the cause and\n // name the setting that is.\n limit_below_deposit: {\n reason: 'the per-call spend limit cannot cover the routing fee or its deposit',\n fix: 'Your balance is fine; this is the per-call limit. Choose an amount that covers the routing fee or its deposit with `tenjin config set maxAutoSpend <usd>`.',\n },\n budget_reached: {\n reason: \"today's spend limit is used up\",\n fix: 'Your balance is fine, and adding funds would not help. The limit frees up as the 24 hours pass, or raise it with `tenjin config set sessionBudget <usd>`.',\n },\n not_allowlisted: {\n reason: 'allowlistCreators does not include the router',\n fix: 'Run `tenjin doctor`.',\n },\n payment_failed: {\n reason: 'the routing payment failed',\n fix: 'Run `tenjin doctor`.',\n },\n [FEE_ABOVE_CEILING]: {\n reason: 'the router asks more per call than this install agreed to pay',\n fix: 'Your usual tools still work.',\n },\n [NO_PAYER]: {\n reason: 'the router charges it, and this session cannot pay it',\n fix: 'Run `tenjin doctor`.',\n },\n};\nconst NO_FAULT = new Set([\n 'channel_busy',\n 'busy',\n 'no_call',\n 'deadline_after_payment_sent',\n 'unlock_timeout',\n 'balance_unreadable',\n TOPPING_UP,\n DEPOSIT_DEFERRED,\n TOP_UP_UNAVAILABLE,\n]);\n\n/** The reason and fix for an unpaid call, or null when it needs no word. */\nexport function unpaid(why: string): { reason: string; fix: string } | null {\n if (NO_FAULT.has(why)) return null;\n return UNPAID[why] ?? UNPAID['payment_failed']!;\n}\n\n/**\n * The deposit notice, on the next hook after a background top-up or on the\n * routing call that carried it. Each fee is the router's own quote, and the\n * deposit counts toward spend limits once, when it is sent ({@link feeRefusal}).\n */\nexport function depositSentence(amountAtomic: bigint): string {\n return `Tenjin set aside $${usd(amountAtomic)} for routing. It counts toward your spend limits.`;\n}\n\n/**\n * What a call the wallet could not fund says. Routing has not stopped: an\n * answer that needs no payment can still come, so the line says only that\n * this answer went unpaid, and opens no checkout (explicit balance, payment\n * and doctor results keep `unpaid().fix`).\n */\nexport const WALLET_LOW_SENTENCE =\n 'Your balance was too low for this routing fee. Free routing still works.';\n\n/**\n * The one line the user sees, once per session and reason, when a call was not\n * paid. Its reader picks the fix (B1): the person's by default; for the model\n * (the `request` tool's text) a wallet unlock reason's `agentFix`, which asks\n * the person to act and never for the passphrase, and any other reason's own.\n * A quote above the ceiling names the price quoted, when the payer read one.\n */\n/**\n * A spend limit, as the person reads it in chat: their agent raises it, so they\n * never get a command they did not type. The agent reader keeps the command.\n */\nconst PERSON_FIX: Partial<Record<string, string>> = {\n limit_below_deposit:\n 'Your balance is fine; this is the per-call limit. Ask your agent to raise it.',\n budget_reached:\n 'Your balance is fine, and adding funds would not help. The limit frees up as the 24 hours pass, or ask your agent to raise it.',\n};\n\nexport function unpaidSentence(\n why: string,\n reader: 'person' | 'agent' = 'person',\n quotedAtomic?: bigint,\n): string | null {\n const u = unpaid(why);\n if (u === null) return null;\n if (why === 'wallet_low') return WALLET_LOW_SENTENCE;\n const fix = reader === 'agent' ? agentFixFor(why, u.fix) : (PERSON_FIX[why] ?? u.fix);\n const reason =\n why === FEE_ABOVE_CEILING && quotedAtomic !== undefined\n ? `the router quoted $${usd(quotedAtomic)} a call, more than this install agreed to pay`\n : u.reason;\n return `Tenjin could not pay the routing fee (${reason}). Free routing still works. ${fix}`;\n}\n\nconst ADDRESS_RE = /^0x[0-9a-f]{40}$/;\n\n/** One wallet's folder: the SDK's file storage for its routing channel\n * (`client/<channelId>.json`). */\nexport function payerDir(dataDir: string, payer: string): string {\n const name = payer.toLowerCase();\n if (!ADDRESS_RE.test(name)) throw new Error(`not a wallet address: ${payer}`);\n return join(dataDir, 'router', 'fee', name);\n}\n\n/** Atomic USDC as dollars with at least two decimals, never a float. */\nexport function usd(atomic: bigint): string {\n return formatUsdDisplay(atomic.toString());\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA,SAAS,YAAY;AAkCd,IAAM,6BAA6B;AAQnC,IAAM,8BAA8B;AAEpC,IAAM,oBAAoB;AAG1B,IAAM,yBAAyB;AAE/B,IAAM,6BAA6B;AAEnC,IAAM,gCAAgC;AAEtC,IAAM,+BAA+B;AAErC,IAAM,gCAAgC;AAKtC,SAAS,qBAAqB,GAM1B;AACT,QAAM,QAAQ,CAAC,GAAW,MAAe,IAAI,IAAI,IAAI;AACrD,QAAM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A;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,CAAC;AAGM,SAAS,OAAO,KAAqD;AAC1E,MAAI,SAAS,IAAI,GAAG,EAAG,QAAO;AAC9B,SAAO,OAAO,GAAG,KAAK,OAAO,gBAAgB;AAC/C;AAOO,SAAS,gBAAgB,cAA8B;AAC5D,SAAO,qBAAqB,IAAI,YAAY,CAAC;AAC/C;AAQO,IAAM,sBACX;AAaF,IAAM,aAA8C;AAAA,EAClD,qBACE;AAAA,EACF,gBACE;AACJ;AAEO,SAAS,eACd,KACA,SAA6B,UAC7B,cACe;AACf,QAAM,IAAI,OAAO,GAAG;AACpB,MAAI,MAAM,KAAM,QAAO;AACvB,MAAI,QAAQ,aAAc,QAAO;AACjC,QAAM,MAAM,WAAW,UAAU,YAAY,KAAK,EAAE,GAAG,IAAK,WAAW,GAAG,KAAK,EAAE;AACjF,QAAM,SACJ,QAAQ,qBAAqB,iBAAiB,SAC1C,sBAAsB,IAAI,YAAY,CAAC,kDACvC,EAAE;AACR,SAAO,yCAAyC,MAAM,gCAAgC,GAAG;AAC3F;AAEA,IAAM,aAAa;AAIZ,SAAS,SAAS,SAAiB,OAAuB;AAC/D,QAAM,OAAO,MAAM,YAAY;AAC/B,MAAI,CAAC,WAAW,KAAK,IAAI,EAAG,OAAM,IAAI,MAAM,yBAAyB,KAAK,EAAE;AAC5E,SAAO,KAAK,SAAS,UAAU,OAAO,IAAI;AAC5C;AAGO,SAAS,IAAI,QAAwB;AAC1C,SAAO,iBAAiB,OAAO,SAAS,CAAC;AAC3C;","names":[]}
|
|
@@ -3,7 +3,13 @@ import { createRequire as __tenjinCreateRequire } from 'node:module'; const requ
|
|
|
3
3
|
// src/router/hook-tool.ts
|
|
4
4
|
var HOOK_KINDS = ["prompt", "native", "shortfall", "agent", "ask", "answer"];
|
|
5
5
|
var HOOK_TOOL = "hook";
|
|
6
|
-
var COMMON = [
|
|
6
|
+
var COMMON = [
|
|
7
|
+
"hook_event_name",
|
|
8
|
+
"session_id",
|
|
9
|
+
"transcript_path",
|
|
10
|
+
"cwd",
|
|
11
|
+
"permission_mode"
|
|
12
|
+
];
|
|
7
13
|
var CALL = ["tool_name", "tool_input", "tool_use_id", "agent_id", "agent_type"];
|
|
8
14
|
var FIELDS = {
|
|
9
15
|
prompt: [...COMMON, "prompt"],
|
|
@@ -81,4 +87,4 @@ export {
|
|
|
81
87
|
CODEX_HOOK_TOOL_FIELDS,
|
|
82
88
|
codexEventFromToolInput
|
|
83
89
|
};
|
|
84
|
-
//# sourceMappingURL=chunk-
|
|
90
|
+
//# sourceMappingURL=chunk-I557SAOM.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/router/hook-tool.ts"],"sourcesContent":["/**\n * THE HOOK EVENT, CARRIED BY AN `mcp_tool` ENTRY. Claude Code calls the `hook`\n * tool of the session's own `tenjin mcp` for each routing leg, with the event's\n * fields substituted into the entry's `input` (`${session_id}` and so on): a\n * string field arrives as written, an object one (`tool_input`,\n * `tool_response`) as its JSON text, a boolean as `true` or `false`, and a\n * field the event lacks as an empty string. This turns that back into the\n * event the handlers already read, and spells the `input` `install` writes.\n */\n\n/** The routing legs, one per hook entry `install` writes. */\nexport const HOOK_KINDS = ['prompt', 'native', 'shortfall', 'agent', 'ask', 'answer'] as const;\nexport type HookKind = (typeof HOOK_KINDS)[number];\n\n/** The tool `tenjin mcp` registers for the hook entries. */\nexport const HOOK_TOOL = 'hook';\n\n/** The event fields each leg reads, as Claude Code names them. */\nconst COMMON = [\n 'hook_event_name',\n 'session_id',\n 'transcript_path',\n 'cwd',\n 'permission_mode',\n] as const;\nconst CALL = ['tool_name', 'tool_input', 'tool_use_id', 'agent_id', 'agent_type'] as const;\n\nconst FIELDS: Record<HookKind, readonly string[]> = {\n prompt: [...COMMON, 'prompt'],\n native: [...COMMON, ...CALL],\n agent: [...COMMON, ...CALL],\n ask: [...COMMON, ...CALL],\n answer: [...COMMON, ...CALL, 'tool_response'],\n shortfall: [...COMMON, ...CALL, 'tool_response', 'error', 'is_interrupt'],\n};\n\n/** Fields whose value is an object or a boolean, sent as JSON text. */\nconst JSON_FIELDS = new Set(['tool_input', 'tool_response', 'is_interrupt']);\n\n/** The `input` of one leg's `mcp_tool` entry. */\nexport function hookToolInput(kind: HookKind): Record<string, string> {\n return Object.fromEntries([\n ['kind', kind],\n ...FIELDS[kind].map((field) => [field, `\\${${field}}`]),\n ]);\n}\n\n/** Every field any leg sends, for the tool's input schema. */\nexport const HOOK_TOOL_FIELDS: readonly string[] = [...new Set(Object.values(FIELDS).flat())];\n\n/**\n * The harness event from the tool's arguments: empty fields dropped (the\n * event did not carry them), the JSON ones parsed back. A JSON field that does\n * not parse is kept as the string it is.\n */\nexport function eventFromToolInput(args: Record<string, unknown>): Record<string, unknown> {\n const event: Record<string, unknown> = {};\n for (const field of HOOK_TOOL_FIELDS) {\n const value = args[field];\n if (typeof value !== 'string' || value.length === 0) continue;\n if (!JSON_FIELDS.has(field)) {\n event[field] = value;\n continue;\n }\n try {\n event[field] = JSON.parse(value) as unknown;\n } catch {\n event[field] = value;\n }\n }\n return event;\n}\n\n/**\n * THE SAME EVENT, CARRIED BY A CODEX `mcp_tool` ENTRY (Codex 0.149 and later).\n * Codex substitutes `${field}` from the event too, with two differences\n * (openai/codex `hooks/src/engine/mcp_runner.rs`): a whole placeholder keeps\n * the field's JSON type, so `tool_input` arrives as an object and a null\n * `transcript_path` as null; and a field the event lacks fails the hook. So\n * each leg names only the fields Codex always sends for its event, and the\n * optional `agent_id` is never one of them: the call's `threadId` metadata\n * tells a subagent's leg apart instead (`admitCodexHookEvent`).\n */\nexport const CODEX_HOOK_KINDS = ['prompt', 'native', 'shortfall'] as const;\nexport type CodexHookKind = (typeof CODEX_HOOK_KINDS)[number];\n\nconst CODEX_COMMON = [\n 'hook_event_name',\n 'session_id',\n 'turn_id',\n 'transcript_path',\n 'cwd',\n] as const;\nconst CODEX_CALL = ['tool_name', 'tool_input', 'tool_use_id'] as const;\n\nconst CODEX_FIELDS: Record<CodexHookKind, readonly string[]> = {\n prompt: [...CODEX_COMMON, 'prompt'],\n native: [...CODEX_COMMON, ...CODEX_CALL],\n shortfall: [...CODEX_COMMON, ...CODEX_CALL, 'tool_response'],\n};\n\n/** The `input` of one Codex leg's `mcp_tool` entry. */\nexport function codexHookToolInput(kind: CodexHookKind): Record<string, string> {\n return Object.fromEntries([\n ['kind', kind],\n ...CODEX_FIELDS[kind].map((field) => [field, `\\${${field}}`]),\n ]);\n}\n\n/** Every field any Codex leg sends, for the tool's input schema. */\nexport const CODEX_HOOK_TOOL_FIELDS: readonly string[] = [\n ...new Set(Object.values(CODEX_FIELDS).flat()),\n];\n\n/** The Codex event from the tool's arguments, each field as Codex typed it; nulls dropped. */\nexport function codexEventFromToolInput(args: Record<string, unknown>): Record<string, unknown> {\n const event: Record<string, unknown> = {};\n for (const field of CODEX_HOOK_TOOL_FIELDS) {\n const value = args[field];\n if (value !== undefined && value !== null) event[field] = value;\n }\n return event;\n}\n"],"mappings":";;;AAWO,IAAM,aAAa,CAAC,UAAU,UAAU,aAAa,SAAS,OAAO,QAAQ;AAI7E,IAAM,YAAY;AAGzB,IAAM,SAAS;AAAA,EACb;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AACA,IAAM,OAAO,CAAC,aAAa,cAAc,eAAe,YAAY,YAAY;AAEhF,IAAM,SAA8C;AAAA,EAClD,QAAQ,CAAC,GAAG,QAAQ,QAAQ;AAAA,EAC5B,QAAQ,CAAC,GAAG,QAAQ,GAAG,IAAI;AAAA,EAC3B,OAAO,CAAC,GAAG,QAAQ,GAAG,IAAI;AAAA,EAC1B,KAAK,CAAC,GAAG,QAAQ,GAAG,IAAI;AAAA,EACxB,QAAQ,CAAC,GAAG,QAAQ,GAAG,MAAM,eAAe;AAAA,EAC5C,WAAW,CAAC,GAAG,QAAQ,GAAG,MAAM,iBAAiB,SAAS,cAAc;AAC1E;AAGA,IAAM,cA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,CAAC;AACH;AAGO,IAAM,yBAA4C;AAAA,EACvD,GAAG,IAAI,IAAI,OAAO,OAAO,YAAY,EAAE,KAAK,CAAC;AAC/C;AAGO,SAAS,wBAAwB,MAAwD;AAC9F,QAAM,QAAiC,CAAC;AACxC,aAAW,SAAS,wBAAwB;AAC1C,UAAM,QAAQ,KAAK,KAAK;AACxB,QAAI,UAAU,UAAa,UAAU,KAAM,OAAM,KAAK,IAAI;AAAA,EAC5D;AACA,SAAO;AACT;","names":[]}
|
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
http,
|
|
10
10
|
serializeTransaction,
|
|
11
11
|
toRlp
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-7V25UAQO.js";
|
|
13
13
|
import {
|
|
14
14
|
InvalidAddressError,
|
|
15
15
|
concatHex,
|
|
@@ -20,7 +20,7 @@ import {
|
|
|
20
20
|
hexToNumber,
|
|
21
21
|
isAddress,
|
|
22
22
|
toHex
|
|
23
|
-
} from "./chunk-
|
|
23
|
+
} from "./chunk-INSIW65E.js";
|
|
24
24
|
import {
|
|
25
25
|
USDC_ADDRESS
|
|
26
26
|
} from "./chunk-ZCT5DJ3G.js";
|
|
@@ -320,4 +320,4 @@ export {
|
|
|
320
320
|
prepareUsdcSend,
|
|
321
321
|
broadcastUsdcSend
|
|
322
322
|
};
|
|
323
|
-
//# sourceMappingURL=chunk-
|
|
323
|
+
//# sourceMappingURL=chunk-IGLWLH73.js.map
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { createRequire as __tenjinCreateRequire } from 'node:module'; const require = __tenjinCreateRequire(import.meta.url);
|
|
2
|
-
import {
|
|
3
|
-
equalBytes
|
|
4
|
-
} from "./chunk-RBJPAZFI.js";
|
|
5
2
|
import {
|
|
6
3
|
keccak_256
|
|
7
4
|
} from "./chunk-CZJOMUBP.js";
|
|
5
|
+
import {
|
|
6
|
+
equalBytes
|
|
7
|
+
} from "./chunk-RBJPAZFI.js";
|
|
8
8
|
|
|
9
9
|
// node_modules/.pnpm/abitype@1.2.3_typescript@6.0.3_zod@4.6.7/node_modules/abitype/dist/esm/version.js
|
|
10
10
|
var version = "1.2.3";
|
|
@@ -7347,7 +7347,7 @@ async function call(client, args) {
|
|
|
7347
7347
|
if (isAbortError(err))
|
|
7348
7348
|
throw err;
|
|
7349
7349
|
const data2 = getRevertErrorData(err);
|
|
7350
|
-
const { offchainLookup: offchainLookup2, offchainLookupSignature: offchainLookupSignature2 } = await import("./ccip-
|
|
7350
|
+
const { offchainLookup: offchainLookup2, offchainLookupSignature: offchainLookupSignature2 } = await import("./ccip-HOW3DZYF.js");
|
|
7351
7351
|
if (client.ccipRead !== false && data2?.slice(0, 10) === offchainLookupSignature2 && to)
|
|
7352
7352
|
return {
|
|
7353
7353
|
data: await offchainLookup2(client, { data: data2, requestOptions, to })
|
|
@@ -8123,4 +8123,4 @@ export {
|
|
|
8123
8123
|
ccipRequest,
|
|
8124
8124
|
call
|
|
8125
8125
|
};
|
|
8126
|
-
//# sourceMappingURL=chunk-
|
|
8126
|
+
//# sourceMappingURL=chunk-INSIW65E.js.map
|
|
@@ -9,10 +9,19 @@ var SKILLS_DIR_PLUGIN_ID = `${PLUGIN_NAME}@skills-dir`;
|
|
|
9
9
|
var PLUGIN_SERVER = `plugin:${PLUGIN_NAME}:${MCP_SERVER_NAME}`;
|
|
10
10
|
var TOOL_PREFIX = `mcp__plugin_${PLUGIN_NAME}_${MCP_SERVER_NAME}`;
|
|
11
11
|
var REQUEST_TOOL = `${TOOL_PREFIX}__request`;
|
|
12
|
+
var SUBAGENT_TOOL = `${TOOL_PREFIX}__subagent`;
|
|
12
13
|
var PLUGIN_HOOK_TOOL = `${TOOL_PREFIX}__hook`;
|
|
13
14
|
var LEGACY_MCP_SERVER_NAME = "x402";
|
|
14
15
|
var LEGACY_REQUEST_TOOL = `mcp__${LEGACY_MCP_SERVER_NAME}__request`;
|
|
15
16
|
var LEGACY_HOOK_TOOL = `mcp__${LEGACY_MCP_SERVER_NAME}__hook`;
|
|
17
|
+
var CLAUDE_TENJIN_TOOLS = [
|
|
18
|
+
TOOL_PREFIX,
|
|
19
|
+
`mcp__${LEGACY_MCP_SERVER_NAME}`
|
|
20
|
+
].flatMap(
|
|
21
|
+
(server) => ["subagent", "subagent_activity", "request", "approve", "hook"].map(
|
|
22
|
+
(tool) => `${server}__${tool}`
|
|
23
|
+
)
|
|
24
|
+
);
|
|
16
25
|
function launchedByPlugin(env = process.env) {
|
|
17
26
|
const root = env.CLAUDE_PLUGIN_ROOT;
|
|
18
27
|
return typeof root === "string" && root.length > 0;
|
|
@@ -33,14 +42,16 @@ export {
|
|
|
33
42
|
SKILLS_DIR_PLUGIN_ID,
|
|
34
43
|
PLUGIN_SERVER,
|
|
35
44
|
REQUEST_TOOL,
|
|
45
|
+
SUBAGENT_TOOL,
|
|
36
46
|
PLUGIN_HOOK_TOOL,
|
|
37
47
|
LEGACY_MCP_SERVER_NAME,
|
|
38
48
|
LEGACY_REQUEST_TOOL,
|
|
39
49
|
LEGACY_HOOK_TOOL,
|
|
50
|
+
CLAUDE_TENJIN_TOOLS,
|
|
40
51
|
launchedByPlugin,
|
|
41
52
|
HARNESSES,
|
|
42
53
|
CODEX_REQUEST_TOOL,
|
|
43
54
|
CODEX_HOOK_TOOL,
|
|
44
55
|
requestToolName
|
|
45
56
|
};
|
|
46
|
-
//# sourceMappingURL=chunk-
|
|
57
|
+
//# sourceMappingURL=chunk-IULCDMVG.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/router/names.ts"],"sourcesContent":["/**\n * THE NAMES THE HARNESS KNOWS THE ROUTER BY, spelled once. `install` registers\n * the Claude Code plugin {@link PLUGIN_NAME}, whose MCP server is\n * {@link MCP_SERVER_NAME}, and Claude Code names a plugin's tools\n * `mcp__plugin_<plugin>_<server>__<tool>`. The plugin's hooks, the server's own\n * name and every hint line the hooks inject read these, so a rename moves them\n * together.\n *\n * A module of its own because the hooks need the tool name and must not load\n * `install` to get it: their chunk graph is the product's floor.\n */\nexport const PLUGIN_NAME = 'tenjin';\nexport const MCP_SERVER_NAME = 'router';\n/** The marketplace `install` adds from the package, so the plugin id is `tenjin@tenjin`. */\nexport const MARKETPLACE_NAME = 'tenjin';\nexport const PLUGIN_ID = `${PLUGIN_NAME}@${MARKETPLACE_NAME}`;\n/** The id Claude Code gives the same plugin loaded from a skills-directory folder. */\nexport const SKILLS_DIR_PLUGIN_ID = `${PLUGIN_NAME}@skills-dir`;\n/** How a plugin's `hooks.json` and `claude mcp` name the plugin's own server. */\nexport const PLUGIN_SERVER = `plugin:${PLUGIN_NAME}:${MCP_SERVER_NAME}`;\nconst TOOL_PREFIX = `mcp__plugin_${PLUGIN_NAME}_${MCP_SERVER_NAME}`;\nexport const REQUEST_TOOL = `${TOOL_PREFIX}__request`;\nexport const SUBAGENT_TOOL = `${TOOL_PREFIX}__subagent`;\n/** The tool the plugin's hook legs call, which its own deny hook keeps from the model. */\nexport const PLUGIN_HOOK_TOOL = `${TOOL_PREFIX}__hook`;\n\n/**\n * The settings-based install's names, for its migration and nothing else.\n * Older releases registered the server as `x402` through `claude mcp add` and\n * wrote seven hook entries and two permission rules into settings.json.\n *\n * SHIM: remove on or after 2026-12-01, the first release cut 30 or more days\n * after the plugin PR 2 ships. Doctor keeps naming an unmigrated machine after.\n */\nexport const LEGACY_MCP_SERVER_NAME = 'x402';\nexport const LEGACY_REQUEST_TOOL = `mcp__${LEGACY_MCP_SERVER_NAME}__request`;\nexport const LEGACY_HOOK_TOOL = `mcp__${LEGACY_MCP_SERVER_NAME}__hook`;\n/**\n * EVERY TENJIN MCP TOOL, under each name Tenjin registers its server by in Claude Code:\n * the plugin's, and the settings install's. A DeepSeek worker's model is offered none of\n * them, so a worker starts no DeepSeek worker and pays for nothing outside its job. A\n * `tenjin mcp` that starts inside a worker also has none of them but `hook`, whatever\n * name it is registered under (`buildRouterMcpServer`).\n */\nexport const CLAUDE_TENJIN_TOOLS: readonly string[] = [\n TOOL_PREFIX,\n `mcp__${LEGACY_MCP_SERVER_NAME}`,\n].flatMap((server) =>\n ['subagent', 'subagent_activity', 'request', 'approve', 'hook'].map(\n (tool) => `${server}__${tool}`,\n ),\n);\n\n/**\n * Is this process one Claude Code launched from the plugin? Claude Code sets\n * `CLAUDE_PLUGIN_ROOT` for a plugin's MCP server and its command hooks\n * (checked on 2.1.296), and not for a server registered in `~/.claude.json`.\n */\nexport function launchedByPlugin(env: NodeJS.ProcessEnv = process.env): boolean {\n const root = env.CLAUDE_PLUGIN_ROOT;\n return typeof root === 'string' && root.length > 0;\n}\n\n/** The agent hosts the router serves, as the CLI names them to the server. */\nexport const HARNESSES = ['claude', 'codex'] as const;\nexport type Harness = (typeof HARNESSES)[number];\n\n/**\n * Codex names an MCP tool `mcp__<server>__<tool>`, and its plugin's server is\n * {@link MCP_SERVER_NAME}, so the grant key and the tool name move together.\n */\nexport const CODEX_REQUEST_TOOL = `mcp__${MCP_SERVER_NAME}__request`;\n/** The tool the Codex plugin's routing legs call, which its own deny hook keeps from the model. */\nexport const CODEX_HOOK_TOOL = `mcp__${MCP_SERVER_NAME}__hook`;\n\n/**\n * The request tool's name as the host exposes it, so an offer line never names\n * a tool the model does not have. In Claude Code: the plugin's tool for a\n * server the plugin launched, and the `x402` server's tool for one a settings\n * install launched.\n *\n * SHIM: the Claude settings branch goes on or after 2026-12-01 (see\n * {@link LEGACY_MCP_SERVER_NAME}); Claude's name is then always {@link REQUEST_TOOL}.\n */\nexport function requestToolName(\n host: Harness = 'claude',\n env: NodeJS.ProcessEnv = process.env,\n): string {\n if (host === 'codex') return CODEX_REQUEST_TOOL;\n return launchedByPlugin(env) ? REQUEST_TOOL : LEGACY_REQUEST_TOOL;\n}\n"],"mappings":";;;AAWO,IAAM,cAAc;AACpB,IAAM,kBAAkB;AAExB,IAAM,mBAAmB;AACzB,IAAM,YAAY,GAAG,WAAW,IAAI,gBAAgB;AAEpD,IAAM,uBAAuB,GAAG,WAAW;AAE3C,IAAM,gBAAgB,UAAU,WAAW,IAAI,eAAe;AACrE,IAAM,cAAc,eAAe,WAAW,IAAI,eAAe;AAC1D,IAAM,eAAe,GAAG,WAAW;AACnC,IAAM,gBAAgB,GAAG,WAAW;AAEpC,IAAM,mBAAmB,GAAG,WAAW;AAUvC,IAAM,yBAAyB;AAC/B,IAAM,sBAAsB,QAAQ,sBAAsB;AAC1D,IAAM,mBAAmB,QAAQ,sBAAsB;AAQvD,IAAM,sBAAyC;AAAA,EACpD;AAAA,EACA,QAAQ,sBAAsB;AAChC,EAAE;AAAA,EAAQ,CAAC,WACT,CAAC,YAAY,qBAAqB,WAAW,WAAW,MAAM,EAAE;AAAA,IAC9D,CAAC,SAAS,GAAG,MAAM,KAAK,IAAI;AAAA,EAC9B;AACF;AAOO,SAAS,iBAAiB,MAAyB,QAAQ,KAAc;AAC9E,QAAM,OAAO,IAAI;AACjB,SAAO,OAAO,SAAS,YAAY,KAAK,SAAS;AACnD;AAGO,IAAM,YAAY,CAAC,UAAU,OAAO;AAOpC,IAAM,qBAAqB,QAAQ,eAAe;AAElD,IAAM,kBAAkB,QAAQ,eAAe;AAW/C,SAAS,gBACd,OAAgB,UAChB,MAAyB,QAAQ,KACzB;AACR,MAAI,SAAS,QAAS,QAAO;AAC7B,SAAO,iBAAiB,GAAG,IAAI,eAAe;AAChD;","names":[]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createRequire as __tenjinCreateRequire } from 'node:module'; const require = __tenjinCreateRequire(import.meta.url);
|
|
2
2
|
import {
|
|
3
3
|
HARNESSES
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-IULCDMVG.js";
|
|
5
5
|
import {
|
|
6
6
|
agentHost
|
|
7
7
|
} from "./chunk-WXA3WTPF.js";
|
|
@@ -43,9 +43,13 @@ async function writeHosts(dataDir, hosts) {
|
|
|
43
43
|
`, { mode: 384 });
|
|
44
44
|
}
|
|
45
45
|
async function claudePluginPresent(env = process.env, home = homedir()) {
|
|
46
|
-
const { claudeInstallAt } = await import("./claude-install-
|
|
46
|
+
const { claudeInstallAt } = await import("./claude-install-BAUSJMW3.js");
|
|
47
47
|
return claudeInstallAt("user", env, home, home, ["record", "folder"]);
|
|
48
48
|
}
|
|
49
|
+
async function claudeHostSetUp(dataDir, env = process.env, home = homedir()) {
|
|
50
|
+
const hosts = await readInstalledHosts(dataDir);
|
|
51
|
+
return hosts !== null ? hosts.includes("claude") : claudePluginPresent(env, home);
|
|
52
|
+
}
|
|
49
53
|
async function recordInstalledHost(dataDir, host, present = () => claudePluginPresent()) {
|
|
50
54
|
const recorded = await readInstalledHosts(dataDir);
|
|
51
55
|
const hosts = recorded ?? (host !== "claude" && await present().catch(() => false) ? ["claude"] : []);
|
|
@@ -65,8 +69,8 @@ async function forgetInstalledHost(dataDir, host) {
|
|
|
65
69
|
}
|
|
66
70
|
async function detectHosts(env) {
|
|
67
71
|
const [{ readClaudeCode }, { codexVersion }] = await Promise.all([
|
|
68
|
-
import("./claude-cli-
|
|
69
|
-
import("./codex-host-
|
|
72
|
+
import("./claude-cli-GIIHOBGT.js"),
|
|
73
|
+
import("./codex-host-ZON3S6HU.js")
|
|
70
74
|
]);
|
|
71
75
|
const [claude, codex] = await Promise.all([
|
|
72
76
|
readClaudeCode(env, process.cwd()).then(
|
|
@@ -251,6 +255,7 @@ export {
|
|
|
251
255
|
HOSTS_FILE,
|
|
252
256
|
readInstalledHosts,
|
|
253
257
|
claudePluginPresent,
|
|
258
|
+
claudeHostSetUp,
|
|
254
259
|
recordInstalledHost,
|
|
255
260
|
forgetInstalledHost,
|
|
256
261
|
detectHosts,
|
|
@@ -262,4 +267,4 @@ export {
|
|
|
262
267
|
uninstallEach,
|
|
263
268
|
checkEach
|
|
264
269
|
};
|
|
265
|
-
//# sourceMappingURL=chunk-
|
|
270
|
+
//# sourceMappingURL=chunk-IVNSUAVC.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/router/hosts.ts"],"sourcesContent":["import { readFile, rm } from 'node:fs/promises';\nimport { homedir } from 'node:os';\nimport { join } from 'node:path';\nimport type { CommandContext, CommandResult } from '../context';\nimport { writeFileAtomic } from '../lib/atomic-json';\nimport { CliError } from '../lib/errors';\nimport { agentHost } from '../lib/session';\nimport { HARNESSES, type Harness } from './names';\nimport type { UninstallTarget } from './uninstall';\n\n/**\n * WHICH AGENT HOSTS `install`, `doctor` AND `uninstall` SERVE. Nobody names a\n * host on the normal path: an agent's install goes to the host it runs in, a\n * terminal install to the hosts this machine has (asking when it has both),\n * and doctor and uninstall read the hosts install recorded. `--harness` only\n * overrides.\n */\n\n/** The record install writes in the Tenjin data dir: the hosts it set up. */\nexport const HOSTS_FILE = 'installed-hosts.json';\n\nconst LABEL: Record<Harness, string> = { claude: 'Claude Code', codex: 'Codex' };\n\n/** The hosts install recorded, or null on a machine set up before the record. */\nexport async function readInstalledHosts(dataDir: string): Promise<Harness[] | null> {\n let raw: string;\n try {\n raw = await readFile(join(dataDir, HOSTS_FILE), 'utf8');\n } catch {\n return null;\n }\n try {\n const hosts = (JSON.parse(raw) as { hosts?: unknown }).hosts;\n if (!Array.isArray(hosts)) return null;\n return HARNESSES.filter((h) => hosts.includes(h));\n } catch {\n return null;\n }\n}\n\nasync function writeHosts(dataDir: string, hosts: readonly Harness[]): Promise<void> {\n const path = join(dataDir, HOSTS_FILE);\n if (hosts.length === 0) {\n await rm(path, { force: true });\n return;\n }\n await writeFileAtomic(path, `${JSON.stringify({ hosts }, null, 2)}\\n`, { mode: 0o600 });\n}\n\n/**\n * Is the Claude Code plugin here already, from a release that wrote no record?\n * Claude Code's own plugin list file, as doctor reads it with no binary, or\n * the plugin folder of ours at user scope.\n */\nexport async function claudePluginPresent(\n env: NodeJS.ProcessEnv = process.env,\n home: string = homedir(),\n): Promise<boolean> {\n const { claudeInstallAt } = await import('./claude-install');\n return claudeInstallAt('user', env, home, home, ['record', 'folder']);\n}\n\n/**\n * Is Claude Code one of the hosts Tenjin is set up for here? DeepSeek workers run\n * there only. The record install wrote decides; a machine set up before the record\n * falls back to the plugin check.\n */\nexport async function claudeHostSetUp(\n dataDir: string,\n env: NodeJS.ProcessEnv = process.env,\n home: string = homedir(),\n): Promise<boolean> {\n const hosts = await readInstalledHosts(dataDir);\n return hosts !== null ? hosts.includes('claude') : claudePluginPresent(env, home);\n}\n\n/**\n * A host whose setup finished. The first record on a machine whose Claude\n * Code plugin came from a release before the record starts with Claude Code,\n * so doctor and uninstall keep covering it.\n */\nexport async function recordInstalledHost(\n dataDir: string,\n host: Harness,\n present: () => Promise<boolean> = () => claudePluginPresent(),\n): Promise<void> {\n const recorded = await readInstalledHosts(dataDir);\n const hosts =\n recorded ?? (host !== 'claude' && (await present().catch(() => false)) ? ['claude'] : []);\n if (hosts.includes(host)) return;\n await writeHosts(\n dataDir,\n HARNESSES.filter((h) => h === host || hosts.includes(h)),\n );\n}\n\nexport async function forgetInstalledHost(dataDir: string, host: Harness): Promise<void> {\n const hosts = await readInstalledHosts(dataDir);\n if (hosts === null || !hosts.includes(host)) return;\n await writeHosts(\n dataDir,\n hosts.filter((h) => h !== host),\n );\n}\n\n/** The hosts this machine can run: each counts only when its `--version` answers. */\nexport async function detectHosts(env: NodeJS.ProcessEnv): Promise<Harness[]> {\n const [{ readClaudeCode }, { codexVersion }] = await Promise.all([\n import('./claude-cli'),\n import('./codex-host'),\n ]);\n const [claude, codex] = await Promise.all([\n readClaudeCode(env, process.cwd()).then(\n (s) => s.version !== null,\n () => false,\n ),\n codexVersion().then(\n (v) => v !== null,\n () => false,\n ),\n ]);\n return HARNESSES.filter((h) => (h === 'claude' ? claude : codex));\n}\n\nasync function askHosts(found: readonly Harness[]): Promise<Harness[] | null> {\n const { selectMany } = await import('../lib/clack');\n return selectMany<Harness>({\n message: 'Set up Tenjin for which agents?',\n choices: found.map((h) => ({ value: h, label: LABEL[h] })),\n initialValues: found,\n });\n}\n\nexport interface HostDeps {\n env?: NodeJS.ProcessEnv;\n detect?: (env: NodeJS.ProcessEnv) => Promise<Harness[]>;\n ask?: (found: readonly Harness[]) => Promise<Harness[] | null>;\n isInteractive?: boolean;\n}\n\nexport interface InstallHostArgs {\n harness?: Harness;\n project?: boolean;\n refresh?: boolean;\n yes?: boolean;\n}\n\n/**\n * The hosts this install sets up. A refresh and a project install are Claude\n * Code's alone; an agent's install goes to its own host; a terminal install\n * goes to every host found, asking first when there are two and a person can\n * answer. A machine with neither gets the Claude Code setup, which needs no\n * `claude` binary.\n */\nexport async function installHosts(\n args: InstallHostArgs,\n ctx: CommandContext,\n deps: HostDeps = {},\n): Promise<Harness[]> {\n if (args.harness !== undefined) return [args.harness];\n if (args.refresh === true || args.project === true) return ['claude'];\n const env = deps.env ?? process.env;\n const agent = agentHost(env);\n if (agent !== undefined) return [agent];\n const found = await (deps.detect ?? detectHosts)(env);\n if (found.length === 0) return ['claude'];\n if (found.length === 1 || args.yes === true) return found;\n const interactive =\n ctx.flags.json !== true &&\n (deps.isInteractive ?? (ctx.io.isTTY && Boolean(process.stdin.isTTY)));\n if (!interactive) return found;\n const picked = await (deps.ask ?? askHosts)(found);\n if (picked === null || picked.length === 0) {\n throw new CliError('REFUSED', 'Install cancelled before anything was written.', {\n fix: 'Re-run `tenjin install` and pick at least one agent.',\n });\n }\n return HARNESSES.filter((h) => picked.includes(h));\n}\n\n/** Point to another available host without adding a setup question. */\nexport async function otherHostNote(\n args: InstallHostArgs,\n dataDir: string,\n deps: HostDeps = {},\n): Promise<string | undefined> {\n if (args.harness !== undefined || args.refresh === true || args.project === true)\n return undefined;\n const env = deps.env ?? process.env;\n const agent = agentHost(env);\n if (agent === undefined) return undefined;\n const other: Harness = agent === 'claude' ? 'codex' : 'claude';\n if ((await readInstalledHosts(dataDir))?.includes(other)) return undefined;\n if (!(await (deps.detect ?? detectHosts)(env)).includes(other)) return undefined;\n return `Tell the person: ${LABEL[other]} is also installed. To add Tenjin there${other === 'codex' ? ' (experimental support)' : ''}, ask ${LABEL[other]} to install it.`;\n}\n\n/** The install result with `note` in its `notices` and as its last line. */\nexport function withNote(out: CommandResult, note: string | undefined): CommandResult {\n if (note === undefined) return out;\n const data = (out.data ?? {}) as { notices?: unknown };\n const notices = Array.isArray(data.notices) ? (data.notices as string[]) : [];\n return {\n ...out,\n data: { ...data, notices: [...notices, note] },\n humanLines: [...(out.humanLines ?? []), note],\n };\n}\n\n/** The hosts doctor checks and uninstall removes: the record, else Claude Code. */\nexport async function recordedHosts(\n args: { harness?: Harness; project?: boolean },\n dataDir: string,\n): Promise<Harness[]> {\n if (args.harness !== undefined) return [args.harness];\n if (args.project === true) return ['claude'];\n const hosts = await readInstalledHosts(dataDir);\n return hosts === null || hosts.length === 0 ? ['claude'] : hosts;\n}\n\n/** One run per host, in order. One host keeps its own result shape. */\nexport async function runEach(\n hosts: readonly Harness[],\n run: (host: Harness) => Promise<CommandResult>,\n): Promise<CommandResult> {\n const [only] = hosts;\n if (hosts.length === 1 && only !== undefined) return run(only);\n const data: Record<string, unknown> = { hosts };\n const humanLines: string[] = [];\n for (const host of hosts) {\n const out = await run(host);\n data[host] = out.data;\n // Each host's whole receipt, tail included, under its name.\n humanLines.push(\n `${LABEL[host]}:`,\n ...[...(out.humanLines ?? []), ...(out.humanTail ?? [])].map((l) => ` ${l}`),\n );\n }\n return { data, humanLines };\n}\n\n/** What every install shares (Tenjin's runtime and its launcher), as uninstall settles it last. */\nexport interface SharedParts {\n /** Removes them; their result is appended to the run's. */\n remove: () => Promise<CommandResult>;\n /** Whether Claude Code still holds an install anywhere; asked only when this run did not remove Claude Code's. */\n claudeLeft: () => Promise<boolean>;\n /** The line saying they were kept for these hosts, or null where there are none (a data dir of its own). */\n keptFor: (hosts: string[]) => string | null;\n}\n\n/**\n * Uninstall over the hosts: a host leaves the record only once its removal\n * left nothing behind. Claude Code leaves it when no install of it is left in\n * any scope or project (its result's `remaining` is empty); Codex, user scope\n * only, when its removal succeeded. A host whose removal failed (it throws)\n * stays recorded, so a later uninstall or doctor still finds it, and every\n * host is tried before one aggregated refusal.\n *\n * `shared` IS SETTLED BY THE END STATE, last: removed only when every host\n * succeeded, no host is still recorded, and Claude Code holds no install\n * (this run's `remaining` is empty, or, when Claude Code was not part of this\n * run, it records none), so the last host removed takes them whichever it is.\n * Kept, and said so, when only another recorded host still uses them.\n */\nexport async function uninstallEach(\n hosts: readonly Harness[],\n dataDir: string,\n target: UninstallTarget,\n run: (host: Harness) => Promise<CommandResult>,\n shared?: SharedParts,\n): Promise<CommandResult> {\n const done: { host: Harness; out: CommandResult }[] = [];\n const failed: { host: Harness; err: CliError }[] = [];\n let claudeGone = false;\n for (const host of hosts) {\n try {\n const out = await run(host);\n done.push({ host, out });\n const gone = host === 'claude' ? nothingRemains(out.data) : target.kind !== 'project';\n if (gone) await forgetInstalledHost(dataDir, host);\n if (host === 'claude') claudeGone = gone;\n } catch (err) {\n if (!(err instanceof CliError)) throw err;\n failed.push({ host, err });\n }\n }\n const [only] = done;\n if (failed.length > 0) {\n const [first] = failed;\n if (hosts.length === 1 && first !== undefined) throw first.err;\n const data: Record<string, unknown> = { hosts };\n for (const { host, out } of done) data[host] = out.data;\n for (const { host, err } of failed) {\n data[host] = {\n error: err.message,\n ...(err.details !== undefined ? { details: err.details } : {}),\n };\n }\n throw new CliError(\n 'REFUSED',\n failed.map(({ host, err }) => `${LABEL[host]}: ${err.message}`).join(' '),\n {\n details: data,\n fix: failed.map(({ host, err }) => `${LABEL[host]}:\\n${err.fix ?? err.message}`).join('\\n'),\n },\n );\n }\n // One host keeps its own result shape, as runEach does.\n const out: CommandResult =\n hosts.length === 1 && only !== undefined\n ? only.out\n : {\n data: Object.fromEntries([['hosts', hosts], ...done.map((d) => [d.host, d.out.data])]),\n humanLines: done.flatMap((d) => [\n `${LABEL[d.host]}:`,\n ...(d.out.humanLines ?? []).map((l) => ` ${l}`),\n ]),\n };\n if (shared === undefined) return out;\n // Claude Code's own result already names what it keeps for its installs.\n const claudeRan = done.some((d) => d.host === 'claude');\n if (claudeRan ? !claudeGone : await shared.claudeLeft()) return out;\n const recorded = (await readInstalledHosts(dataDir)) ?? [];\n if (recorded.length > 0) {\n const line = shared.keptFor(recorded.map((h) => LABEL[h]));\n return line === null ? out : { ...out, humanLines: [...(out.humanLines ?? []), line] };\n }\n const removed = await shared.remove();\n return {\n data: {\n ...(out.data as Record<string, unknown>),\n ...(removed.data as Record<string, unknown>),\n },\n humanLines: [...(out.humanLines ?? []), ...(removed.humanLines ?? [])],\n };\n}\n\n/** The Claude Code removal's `remaining: []`: no install of it is left anywhere. */\nfunction nothingRemains(data: unknown): boolean {\n const remaining = (data as { remaining?: unknown } | null)?.remaining;\n return Array.isArray(remaining) && remaining.length === 0;\n}\n\n/**\n * Doctor over several hosts: every host is checked before any failure is\n * reported, and the failure names each host that failed.\n */\nexport async function checkEach(\n hosts: readonly Harness[],\n run: (host: Harness) => Promise<CommandResult>,\n): Promise<CommandResult> {\n const [only] = hosts;\n if (hosts.length === 1 && only !== undefined) return run(only);\n const data: Record<string, unknown> = { hosts };\n const humanLines: string[] = [];\n const failed: { host: Harness; err: CliError }[] = [];\n for (const host of hosts) {\n try {\n const out = await run(host);\n data[host] = out.data;\n humanLines.push(`${LABEL[host]}:`, ...(out.humanLines ?? []).map((l) => ` ${l}`));\n } catch (err) {\n if (!(err instanceof CliError)) throw err;\n data[host] = {\n error: err.message,\n ...(err.details !== undefined ? { details: err.details } : {}),\n };\n failed.push({ host, err });\n }\n }\n if (failed.length === 0) return { data, humanLines };\n throw new CliError(\n 'REFUSED',\n failed.map(({ host, err }) => `${LABEL[host]}: ${err.message}`).join(' '),\n {\n details: data,\n fix: failed.map(({ host, err }) => `${LABEL[host]}:\\n${err.fix ?? err.message}`).join('\\n'),\n },\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;AAAA,SAAS,UAAU,UAAU;AAC7B,SAAS,eAAe;AACxB,SAAS,YAAY;AAiBd,IAAM,aAAa;AAE1B,IAAM,QAAiC,EAAE,QAAQ,eAAe,OAAO,QAAQ;AAG/E,eAAsB,m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AA6C,CAAC;AACpD,aAAW,QAAQ,OAAO;AACxB,QAAI;AACF,YAAM,MAAM,MAAM,IAAI,IAAI;AAC1B,WAAK,IAAI,IAAI,IAAI;AACjB,iBAAW,KAAK,GAAG,MAAM,IAAI,CAAC,KAAK,IAAI,IAAI,cAAc,CAAC,GAAG,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;AAAA,IACnF,SAAS,KAAK;AACZ,UAAI,EAAE,eAAe,UAAW,OAAM;AACtC,WAAK,IAAI,IAAI;AAAA,QACX,OAAO,IAAI;AAAA,QACX,GAAI,IAAI,YAAY,SAAY,EAAE,SAAS,IAAI,QAAQ,IAAI,CAAC;AAAA,MAC9D;AACA,aAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AAAA,IAC3B;AAAA,EACF;AACA,MAAI,OAAO,WAAW,EAAG,QAAO,EAAE,MAAM,WAAW;AACnD,QAAM,IAAI;AAAA,IACR;AAAA,IACA,OAAO,IAAI,CAAC,EAAE,MAAM,IAAI,MAAM,GAAG,MAAM,IAAI,CAAC,KAAK,IAAI,OAAO,EAAE,EAAE,KAAK,GAAG;AAAA,IACxE;AAAA,MACE,SAAS;AAAA,MACT,KAAK,OAAO,IAAI,CAAC,EAAE,MAAM,IAAI,MAAM,GAAG,MAAM,IAAI,CAAC;AAAA,EAAM,IAAI,OAAO,IAAI,OAAO,EAAE,EAAE,KAAK,IAAI;AAAA,IAC5F;AAAA,EACF;AACF;","names":["out"]}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { createRequire as __tenjinCreateRequire } from 'node:module'; const require = __tenjinCreateRequire(import.meta.url);
|
|
2
|
+
import {
|
|
3
|
+
c,
|
|
4
|
+
ce,
|
|
5
|
+
n,
|
|
6
|
+
w
|
|
7
|
+
} from "./chunk-VWZYE3NC.js";
|
|
8
|
+
|
|
9
|
+
// node_modules/.pnpm/@anthropic-ai+claude-agent-sdk@0.3.325_@anthropic-ai+sdk@0.137.0_zod@4.6.7__@modelconte_6201ba81a17d8b6bc4087a6afdf0345f/node_modules/@anthropic-ai/claude-agent-sdk/core-x20yarwf.mjs
|
|
10
|
+
import { lstat as a, rm as u, rmdir as m, unlink as T } from "fs/promises";
|
|
11
|
+
import { createHash as h } from "crypto";
|
|
12
|
+
if (typeof Symbol.dispose !== "symbol") {
|
|
13
|
+
try {
|
|
14
|
+
Symbol.dispose = /* @__PURE__ */ Symbol.for("Symbol.dispose");
|
|
15
|
+
} catch {
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
if (typeof Symbol.asyncDispose !== "symbol") {
|
|
19
|
+
try {
|
|
20
|
+
Symbol.asyncDispose = /* @__PURE__ */ Symbol.for("Symbol.asyncDispose");
|
|
21
|
+
} catch {
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
var E = /* @__PURE__ */ new Set(["EPERM", "EACCES", "EBUSY"]);
|
|
25
|
+
var f = 50;
|
|
26
|
+
async function Kt(t) {
|
|
27
|
+
for (let r = 1; ; r++) {
|
|
28
|
+
let s = true;
|
|
29
|
+
try {
|
|
30
|
+
await u(t, { recursive: true, force: true });
|
|
31
|
+
} catch (i) {
|
|
32
|
+
if (n(i) !== "ENOTEMPTY") throw i;
|
|
33
|
+
s = false;
|
|
34
|
+
}
|
|
35
|
+
try {
|
|
36
|
+
await a(t);
|
|
37
|
+
} catch (i) {
|
|
38
|
+
if (ce(i) || s && process.platform === "win32" && E.has(n(i))) return;
|
|
39
|
+
throw i;
|
|
40
|
+
}
|
|
41
|
+
if (r === 3) throw Object.assign(new c(`'${t}' is still on disk after three tries to delete it. A program may be writing to it, such as a running Claude Code session, or you may not have permission to change it. Stop that program or fix the permissions, then delete it yourself.`, "removeTree: still on disk after three tries"), { code: "ENOTEMPTY" });
|
|
42
|
+
await w(r * f);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
var o = class {
|
|
46
|
+
resetters = [];
|
|
47
|
+
built = [];
|
|
48
|
+
lazy(t) {
|
|
49
|
+
let r, s = () => {
|
|
50
|
+
r = void 0;
|
|
51
|
+
};
|
|
52
|
+
return this.resetters.push(s), () => {
|
|
53
|
+
if (r === void 0) r = t(), this.built.push(s);
|
|
54
|
+
return r;
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
builtCount() {
|
|
58
|
+
return this.built.length;
|
|
59
|
+
}
|
|
60
|
+
releaseBuiltSince(t) {
|
|
61
|
+
for (let r of this.built.splice(t)) r();
|
|
62
|
+
}
|
|
63
|
+
reset() {
|
|
64
|
+
for (let t of this.resetters) t();
|
|
65
|
+
this.built.length = 0;
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
var l = new o();
|
|
69
|
+
function e(t) {
|
|
70
|
+
return l.lazy(t);
|
|
71
|
+
}
|
|
72
|
+
function Pe(t) {
|
|
73
|
+
if (typeof t !== "string" && !ArrayBuffer.isView(t)) throw Object.assign(TypeError("sha256Hex: the data is neither text nor bytes"), { code: "ERR_INVALID_ARG_TYPE" });
|
|
74
|
+
return h("sha256").update(t).digest("hex");
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export {
|
|
78
|
+
Kt,
|
|
79
|
+
e,
|
|
80
|
+
Pe
|
|
81
|
+
};
|
|
82
|
+
/*! Bundled license information:
|
|
83
|
+
|
|
84
|
+
@anthropic-ai/claude-agent-sdk/core-x20yarwf.mjs:
|
|
85
|
+
(*! symbol-dispose-prelude: defines Symbol.dispose and Symbol.asyncDispose if missing, for this bundle's `using`. *)
|
|
86
|
+
*/
|
|
87
|
+
//# sourceMappingURL=chunk-JDQZCREI.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../node_modules/.pnpm/@anthropic-ai+claude-agent-sdk@0.3.325_@anthropic-ai+sdk@0.137.0_zod@4.6.7__@modelconte_6201ba81a17d8b6bc4087a6afdf0345f/node_modules/@anthropic-ai/claude-agent-sdk/core-x20yarwf.mjs"],"sourcesContent":["// (c) Anthropic PBC. All rights reserved. Use is subject to the Legal Agreements outlined here: https://code.claude.com/docs/en/legal-and-compliance.\n\n// Version: 0.3.325\n\n//! symbol-dispose-prelude: defines Symbol.dispose and Symbol.asyncDispose if missing, for this bundle's `using`.\nif (typeof Symbol.dispose !== 'symbol') {\n try {\n Symbol.dispose = Symbol.for('Symbol.dispose')\n } catch {}\n}\nif (typeof Symbol.asyncDispose !== 'symbol') {\n try {\n Symbol.asyncDispose = Symbol.for('Symbol.asyncDispose')\n } catch {}\n}\nimport{c,n,ce,w}from\"./core-msnqqcc2.mjs\";import{lstat as a,rm as u,rmdir as m,unlink as T}from\"fs/promises\";var E=new Set([\"EPERM\",\"EACCES\",\"EBUSY\"]),f=50;async function Kt(t){for(let r=1;;r++){let s=!0;try{await u(t,{recursive:!0,force:!0})}catch(i){if(n(i)!==\"ENOTEMPTY\")throw i;s=!1}try{await a(t)}catch(i){if(ce(i)||s&&process.platform===\"win32\"&&E.has(n(i)))return;throw i}if(r===3)throw Object.assign(new c(`'${t}' is still on disk after three tries to delete it. A program may be writing to it, such as a running Claude Code session, or you may not have permission to change it. Stop that program or fix the permissions, then delete it yourself.`,\"removeTree: still on disk after three tries\"),{code:\"ENOTEMPTY\"});await w(r*f)}}class o{resetters=[];built=[];lazy(t){let r,s=()=>{r=void 0};return this.resetters.push(s),()=>{if(r===void 0)r=t(),this.built.push(s);return r}}builtCount(){return this.built.length}releaseBuiltSince(t){for(let r of this.built.splice(t))r()}reset(){for(let t of this.resetters)t();this.built.length=0}}var l=new o;function e(t){return l.lazy(t)}import{createHash as h}from\"crypto\";function Pe(t){if(typeof t!==\"string\"&&!ArrayBuffer.isView(t))throw Object.assign(TypeError(\"sha256Hex: the data is neither text nor bytes\"),{code:\"ERR_INVALID_ARG_TYPE\"});return h(\"sha256\").update(t).digest(\"hex\")}\nexport{Kt,e,Pe};\n"],"mappings":";;;;;;;;;AAe0C,SAAO,SAAS,GAAE,MAAM,GAAE,SAAS,GAAE,UAAU,SAAM;AAA29B,SAAO,cAAc,SAAM;AAVrlC,IAAI,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