tenjin-cli 0.1.0-alpha.31 → 0.1.0-alpha.33
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +45 -26
- package/dist/{_esm-MEXZI5DL.js → _esm-BIN7VY2L.js} +128 -132
- package/dist/{alive-J64H46HI.js → alive-GSOWKUOY.js} +13 -6
- package/dist/auto-update-Y24UL56V.js +24 -0
- package/dist/{ccip-7RMRLAGV.js → ccip-DHDFKTQV.js} +2 -2
- package/dist/{chunk-TTNESUPQ.js → chunk-2GP3HRYK.js} +2120 -193
- package/dist/chunk-2GP3HRYK.js.map +1 -0
- package/dist/chunk-2M2VPI2E.js +560 -0
- package/dist/chunk-2M2VPI2E.js.map +1 -0
- package/dist/{chunk-D65GNPS3.js → chunk-2RWB7RKE.js} +288 -108
- package/dist/chunk-2RWB7RKE.js.map +1 -0
- package/dist/{chunk-AGZ7PJKY.js → chunk-36RVGZNY.js} +22 -5
- package/dist/chunk-36RVGZNY.js.map +1 -0
- package/dist/chunk-3AIHRXKO.js +72 -0
- package/dist/chunk-3AIHRXKO.js.map +1 -0
- package/dist/{chunk-S4SAZ7OD.js → chunk-3FMZGI7I.js} +12 -2
- package/dist/{chunk-S4SAZ7OD.js.map → chunk-3FMZGI7I.js.map} +1 -1
- package/dist/chunk-3GNJXKIT.js +198 -0
- package/dist/chunk-3GNJXKIT.js.map +1 -0
- package/dist/{chunk-UQUOVWBG.js → chunk-4K7TQHNP.js} +7 -7
- package/dist/{chunk-A36LQPHV.js → chunk-4LMUQMBH.js} +1 -1
- package/dist/{chunk-A36LQPHV.js.map → chunk-4LMUQMBH.js.map} +1 -1
- package/dist/{chunk-KXQ4UIP7.js → chunk-4USCZ2NI.js} +2 -2
- package/dist/chunk-4YOZGGTZ.js +247 -0
- package/dist/chunk-4YOZGGTZ.js.map +1 -0
- package/dist/chunk-62KNUYWD.js +111 -0
- package/dist/chunk-62KNUYWD.js.map +1 -0
- package/dist/{chunk-POUWHWID.js → chunk-6CMM6YCB.js} +3 -3
- package/dist/{chunk-POUWHWID.js.map → chunk-6CMM6YCB.js.map} +1 -1
- package/dist/{chunk-5MARFNSB.js → chunk-A5GKIG5O.js} +49 -30
- package/dist/chunk-A5GKIG5O.js.map +1 -0
- package/dist/{chunk-YFPY4ONH.js → chunk-AGMVASXZ.js} +4 -4
- package/dist/chunk-BF4XHEQK.js +116 -0
- package/dist/chunk-BF4XHEQK.js.map +1 -0
- package/dist/chunk-BFDQ4WNW.js +119 -0
- package/dist/chunk-BFDQ4WNW.js.map +1 -0
- package/dist/{chunk-P4NH7OUK.js → chunk-C2Q76BVM.js} +49 -50
- package/dist/chunk-C2Q76BVM.js.map +1 -0
- package/dist/chunk-CEXSOI5R.js +808 -0
- package/dist/chunk-CEXSOI5R.js.map +1 -0
- package/dist/{chunk-QSCPK4F5.js → chunk-E7SW44LM.js} +4 -11
- package/dist/chunk-E7SW44LM.js.map +1 -0
- package/dist/chunk-EDJWHDDL.js +33 -0
- package/dist/chunk-EDJWHDDL.js.map +1 -0
- package/dist/chunk-F3ED5WTR.js +13 -0
- package/dist/chunk-F3ED5WTR.js.map +1 -0
- package/dist/{chunk-K72RURN3.js → chunk-FVIGCDSV.js} +2 -2
- package/dist/chunk-FVIGCDSV.js.map +1 -0
- package/dist/{chunk-5K5W4S66.js → chunk-GTTUCOPD.js} +2 -2
- package/dist/{chunk-4ZZO6ULA.js → chunk-HDPUXS3Z.js} +19 -48
- package/dist/chunk-HDPUXS3Z.js.map +1 -0
- package/dist/{chunk-LEFIX6RS.js → chunk-HGGWCP7W.js} +31 -11
- package/dist/chunk-HGGWCP7W.js.map +1 -0
- package/dist/{chunk-ORWL5BSN.js → chunk-HGZEPQUT.js} +2 -2
- package/dist/chunk-HMWYAUA6.js +478 -0
- package/dist/chunk-HMWYAUA6.js.map +1 -0
- package/dist/{chunk-7QKHZQKW.js → chunk-IADZOXKN.js} +39 -6
- package/dist/chunk-IADZOXKN.js.map +1 -0
- package/dist/{chunk-7Q5FDF65.js → chunk-IE7P2BZE.js} +3 -3
- package/dist/{chunk-77TCKDEC.js → chunk-ILNIZ5I2.js} +788 -508
- package/dist/chunk-ILNIZ5I2.js.map +1 -0
- package/dist/{hosts-FWZOV26H.js → chunk-INTFHMU4.js} +79 -24
- package/dist/chunk-INTFHMU4.js.map +1 -0
- package/dist/{chunk-6E5R45ZO.js → chunk-J57UC3DD.js} +4 -4
- package/dist/{chunk-6E5R45ZO.js.map → chunk-J57UC3DD.js.map} +1 -1
- package/dist/chunk-JNJWBTU2.js +3497 -0
- package/dist/chunk-JNJWBTU2.js.map +1 -0
- package/dist/{chunk-7WU4OPLP.js → chunk-KM7RY2ZS.js} +5 -3
- package/dist/{chunk-7WU4OPLP.js.map → chunk-KM7RY2ZS.js.map} +1 -1
- package/dist/chunk-L6JEXB3E.js +293 -0
- package/dist/chunk-L6JEXB3E.js.map +1 -0
- package/dist/chunk-LRW6S53P.js +450 -0
- package/dist/chunk-LRW6S53P.js.map +1 -0
- package/dist/{chunk-UKY4CHNC.js → chunk-LXAYUOXI.js} +24 -11
- package/dist/chunk-LXAYUOXI.js.map +1 -0
- package/dist/{chunk-WJXLQXJY.js → chunk-MPZUYCAP.js} +4 -1
- package/dist/{chunk-WJXLQXJY.js.map → chunk-MPZUYCAP.js.map} +1 -1
- package/dist/chunk-NDGZDTSJ.js +393 -0
- package/dist/chunk-NDGZDTSJ.js.map +1 -0
- package/dist/{chunk-SJLTEINJ.js → chunk-OJNTCYQQ.js} +17 -1
- package/dist/chunk-OJNTCYQQ.js.map +1 -0
- package/dist/{chunk-OHRR5OYM.js → chunk-P3LFTKE7.js} +5 -10
- package/dist/chunk-P3LFTKE7.js.map +1 -0
- package/dist/{chunk-XZKD7DIF.js → chunk-RL5UUDT4.js} +3 -3
- package/dist/{chunk-XZKD7DIF.js.map → chunk-RL5UUDT4.js.map} +1 -1
- package/dist/{chunk-5C32RLTA.js → chunk-RVPYTUP4.js} +20 -5
- package/dist/chunk-RVPYTUP4.js.map +1 -0
- package/dist/{chunk-YVFXE7RR.js → chunk-SNNSAGMT.js} +7279 -2627
- package/dist/chunk-SNNSAGMT.js.map +1 -0
- package/dist/{chunk-WK7F3B2E.js → chunk-SO3XRZPX.js} +3 -3
- package/dist/{chunk-R5LCN54M.js → chunk-TC2WZLSC.js} +13 -17
- package/dist/{chunk-R5LCN54M.js.map → chunk-TC2WZLSC.js.map} +1 -1
- package/dist/{chunk-B7HUUJOK.js → chunk-TKPF35W6.js} +3 -3
- package/dist/{chunk-KXVP2VKA.js → chunk-U3IKUGRP.js} +32 -33
- package/dist/chunk-U3IKUGRP.js.map +1 -0
- package/dist/{chunk-AKWGE6JQ.js → chunk-UUGOUOVT.js} +37 -2
- package/dist/chunk-UUGOUOVT.js.map +1 -0
- package/dist/{chunk-2XLC3AEX.js → chunk-UXZONNEQ.js} +536 -510
- package/dist/chunk-UXZONNEQ.js.map +1 -0
- package/dist/{chunk-7ZRL2LBQ.js → chunk-V2LQLN5H.js} +6 -6
- package/dist/{chunk-NEFNKLBE.js → chunk-WFSPCCVW.js} +1536 -423
- package/dist/chunk-WFSPCCVW.js.map +1 -0
- package/dist/{chunk-27EPWVOY.js → chunk-WXA2BWTE.js} +7 -3
- package/dist/chunk-WXA2BWTE.js.map +1 -0
- package/dist/chunk-WYXUQGOL.js +191 -0
- package/dist/chunk-WYXUQGOL.js.map +1 -0
- package/dist/chunk-X5ZBP3IY.js +97 -0
- package/dist/chunk-X5ZBP3IY.js.map +1 -0
- package/dist/{chunk-MNXS2U45.js → chunk-ZDZERB6L.js} +206 -297
- package/dist/chunk-ZDZERB6L.js.map +1 -0
- package/dist/chunk-ZNNXRNFD.js +113 -0
- package/dist/chunk-ZNNXRNFD.js.map +1 -0
- package/dist/{chunk-FW75G2W4.js → chunk-ZURZHELF.js} +5 -5
- package/dist/{cli-D5OE3URZ.js → cli-E36SPKBW.js} +145 -64
- package/dist/{cli-D5OE3URZ.js.map → cli-E36SPKBW.js.map} +1 -1
- package/dist/{codex-event-PPNVRRDH.js → codex-event-ZO2GEFE6.js} +2 -2
- package/dist/{codex-host-2RJOJW2B.js → codex-host-KECJVTA2.js} +7 -6
- package/dist/codex-install-HQZDGFXW.js +436 -0
- package/dist/codex-install-HQZDGFXW.js.map +1 -0
- package/dist/{config-ZD4OB2DO.js → config-HY2E4GGW.js} +21 -17
- package/dist/doctor-I6XQEKWD.js +1323 -0
- package/dist/doctor-I6XQEKWD.js.map +1 -0
- package/dist/{env-proxy-XL4P73MZ.js → env-proxy-R6ZMLQTT.js} +6 -2
- package/dist/{ethersCompat-Df4a6QIZ-THAVUGIJ.js → ethersCompat-Df4a6QIZ-X6YZWAML.js} +3 -3
- package/dist/{fund-5ITKQGYF.js → fund-2QRO7OJL.js} +43 -37
- package/dist/{fund-5ITKQGYF.js.map → fund-2QRO7OJL.js.map} +1 -1
- package/dist/hook-command-2UBCSZG6.js +43 -0
- package/dist/hosts/claude/.claude-plugin/marketplace.json +2 -2
- package/dist/hosts/claude/tenjin/.claude-plugin/plugin.json +2 -2
- package/dist/hosts/claude/tenjin/hooks/register.tsx +51 -11
- package/dist/hosts/claude/tenjin/skills/tenjin-pay/SKILL.md +82 -0
- package/dist/hosts/claude/tenjin/types/index.d.ts +2 -1
- package/dist/hosts/codex/tenjin/.mcp.json +3 -0
- package/dist/hosts/codex/tenjin/hooks/hooks.json +51 -5
- package/dist/hosts-DVQJ32QC.js +38 -0
- package/dist/index.js +32 -11
- package/dist/index.js.map +1 -1
- package/dist/install-ILUX5C4A.js +107 -0
- package/dist/{install-identity-K7EJIQFP.js → install-identity-TZKGY6LQ.js} +11 -10
- package/dist/install-wallet-5M4OTYLX.js +281 -0
- package/dist/install-wallet-5M4OTYLX.js.map +1 -0
- package/dist/isows-native-Q2UDIVPT.js +9 -0
- package/dist/isows-native-Q2UDIVPT.js.map +1 -0
- package/dist/{mcp-3LIJSSJB.js → mcp-LE4DUS22.js} +785 -211
- package/dist/mcp-LE4DUS22.js.map +1 -0
- package/dist/{mine.wasm-6PIT3DK6.js → mine.wasm-QFAHIFPY.js} +2 -2
- package/dist/{mine.wasm-6PIT3DK6.js.map → mine.wasm-QFAHIFPY.js.map} +1 -1
- package/dist/{package-ZKQFDWLE.js → package-IJFGMWEV.js} +4 -2
- package/dist/passphrase-IFTDS3CU.js +44 -0
- package/dist/{paths-POPTXJO6.js → paths-XCSAKISU.js} +10 -2
- package/dist/{pay-WHBERZ3W.js → pay-WCG3IH4R.js} +29 -29
- package/dist/{payments-KVICEKD2.js → payments-HFPPWHTV.js} +15 -14
- package/dist/{payments-KVICEKD2.js.map → payments-HFPPWHTV.js.map} +1 -1
- package/dist/plugin-registration-PZFI5GZW.js +68 -0
- package/dist/{redact-6W23GGJC.js → redact-D7ASVWKL.js} +2 -2
- package/dist/runtime-UZOKSUZX.js +1321 -0
- package/dist/runtime-UZOKSUZX.js.map +1 -0
- package/dist/runtime-fetch-ZSSSK72Y.js +23 -0
- package/dist/runtime-layout-WIDILZ6K.js +25 -0
- package/dist/{send-7G7Y7DLN.js → send-GCVEAQKL.js} +24 -22
- package/dist/{send-7G7Y7DLN.js.map → send-GCVEAQKL.js.map} +1 -1
- package/dist/{status-OF7RH5HM.js → status-HCVAOCN7.js} +55 -25
- package/dist/status-HCVAOCN7.js.map +1 -0
- package/dist/{status-line-XOUE6MPL.js → status-line-OPCXDHL2.js} +10 -9
- package/dist/{status-line-XOUE6MPL.js.map → status-line-OPCXDHL2.js.map} +1 -1
- package/dist/uninstall-BAWRBXXQ.js +481 -0
- package/dist/uninstall-BAWRBXXQ.js.map +1 -0
- package/dist/update-CACXLQLR.js +56 -0
- package/dist/update-CACXLQLR.js.map +1 -0
- package/dist/{usdc-OGOGEHV2.js → usdc-VG4CIOUK.js} +6 -8
- package/dist/usdc-VG4CIOUK.js.map +1 -0
- package/dist/{viemAdapter-By13KInL-S3DA7DFW.js → viemAdapter-By13KInL-DOFTEIJV.js} +3 -3
- package/dist/viemAdapter-By13KInL-DOFTEIJV.js.map +1 -0
- package/dist/wallet-QL4UUXEZ.js +55 -0
- package/dist/wallet-QL4UUXEZ.js.map +1 -0
- package/dist/wallet-kdf-worker.mjs +8 -8
- package/docs/agent-permissions.md +50 -28
- package/docs/safety-model.md +1 -1
- package/docs/troubleshooting.md +72 -1
- package/package.json +17 -4
- package/scripts/installers/install.ps1 +67 -0
- package/scripts/installers/install.sh +68 -0
- package/dist/_esm-C5CRWCYU.js +0 -3737
- package/dist/_esm-C5CRWCYU.js.map +0 -1
- package/dist/ccip-NLCSCHKI.js +0 -19
- package/dist/chunk-27EPWVOY.js.map +0 -1
- package/dist/chunk-2XLC3AEX.js.map +0 -1
- package/dist/chunk-4ZZO6ULA.js.map +0 -1
- package/dist/chunk-5C32RLTA.js.map +0 -1
- package/dist/chunk-5IEP5EGE.js +0 -5332
- package/dist/chunk-5IEP5EGE.js.map +0 -1
- package/dist/chunk-5MARFNSB.js.map +0 -1
- package/dist/chunk-77TCKDEC.js.map +0 -1
- package/dist/chunk-7EKYXMUO.js +0 -7536
- package/dist/chunk-7EKYXMUO.js.map +0 -1
- package/dist/chunk-7QKHZQKW.js.map +0 -1
- package/dist/chunk-AGZ7PJKY.js.map +0 -1
- package/dist/chunk-AKWGE6JQ.js.map +0 -1
- package/dist/chunk-BL3332HQ.js +0 -7611
- package/dist/chunk-BL3332HQ.js.map +0 -1
- package/dist/chunk-D65GNPS3.js.map +0 -1
- package/dist/chunk-EGELTSPU.js +0 -2865
- package/dist/chunk-EGELTSPU.js.map +0 -1
- package/dist/chunk-GA7JETVM.js +0 -150
- package/dist/chunk-GA7JETVM.js.map +0 -1
- package/dist/chunk-I3EQFHCD.js +0 -175
- package/dist/chunk-I3EQFHCD.js.map +0 -1
- package/dist/chunk-K3I7C2MO.js +0 -1185
- package/dist/chunk-K3I7C2MO.js.map +0 -1
- package/dist/chunk-K72RURN3.js.map +0 -1
- package/dist/chunk-KXVP2VKA.js.map +0 -1
- package/dist/chunk-LEFIX6RS.js.map +0 -1
- package/dist/chunk-MNXS2U45.js.map +0 -1
- package/dist/chunk-NEFNKLBE.js.map +0 -1
- package/dist/chunk-OHRR5OYM.js.map +0 -1
- package/dist/chunk-P4NH7OUK.js.map +0 -1
- package/dist/chunk-QSCPK4F5.js.map +0 -1
- package/dist/chunk-SJLTEINJ.js.map +0 -1
- package/dist/chunk-TTNESUPQ.js.map +0 -1
- package/dist/chunk-UKY4CHNC.js.map +0 -1
- package/dist/chunk-V6BSF6OC.js +0 -260
- package/dist/chunk-V6BSF6OC.js.map +0 -1
- package/dist/chunk-YVFXE7RR.js.map +0 -1
- package/dist/codex-install-UUZ6QMBQ.js +0 -221
- package/dist/codex-install-UUZ6QMBQ.js.map +0 -1
- package/dist/doctor-KBR34Q4B.js +0 -601
- package/dist/doctor-KBR34Q4B.js.map +0 -1
- package/dist/hook-command-4TYCHHRL.js +0 -39
- package/dist/hosts-FWZOV26H.js.map +0 -1
- package/dist/install-XWGE4Q7L.js +0 -77
- package/dist/install-wallet-XQ6XFZV4.js +0 -117
- package/dist/install-wallet-XQ6XFZV4.js.map +0 -1
- package/dist/mcp-3LIJSSJB.js.map +0 -1
- package/dist/plugin-registration-5TIA564H.js +0 -54
- package/dist/status-OF7RH5HM.js.map +0 -1
- package/dist/uninstall-JXUAFNDB.js +0 -158
- package/dist/uninstall-JXUAFNDB.js.map +0 -1
- package/dist/update-ZKUERSO2.js +0 -44
- package/dist/wallet-2HA6W4R4.js +0 -43
- /package/dist/{_esm-MEXZI5DL.js.map → _esm-BIN7VY2L.js.map} +0 -0
- /package/dist/{alive-J64H46HI.js.map → alive-GSOWKUOY.js.map} +0 -0
- /package/dist/{ccip-7RMRLAGV.js.map → auto-update-Y24UL56V.js.map} +0 -0
- /package/dist/{ccip-NLCSCHKI.js.map → ccip-DHDFKTQV.js.map} +0 -0
- /package/dist/{chunk-UQUOVWBG.js.map → chunk-4K7TQHNP.js.map} +0 -0
- /package/dist/{chunk-KXQ4UIP7.js.map → chunk-4USCZ2NI.js.map} +0 -0
- /package/dist/{chunk-YFPY4ONH.js.map → chunk-AGMVASXZ.js.map} +0 -0
- /package/dist/{chunk-5K5W4S66.js.map → chunk-GTTUCOPD.js.map} +0 -0
- /package/dist/{chunk-ORWL5BSN.js.map → chunk-HGZEPQUT.js.map} +0 -0
- /package/dist/{chunk-7Q5FDF65.js.map → chunk-IE7P2BZE.js.map} +0 -0
- /package/dist/{chunk-WK7F3B2E.js.map → chunk-SO3XRZPX.js.map} +0 -0
- /package/dist/{chunk-B7HUUJOK.js.map → chunk-TKPF35W6.js.map} +0 -0
- /package/dist/{chunk-7ZRL2LBQ.js.map → chunk-V2LQLN5H.js.map} +0 -0
- /package/dist/{chunk-FW75G2W4.js.map → chunk-ZURZHELF.js.map} +0 -0
- /package/dist/{codex-event-PPNVRRDH.js.map → codex-event-ZO2GEFE6.js.map} +0 -0
- /package/dist/{codex-host-2RJOJW2B.js.map → codex-host-KECJVTA2.js.map} +0 -0
- /package/dist/{config-ZD4OB2DO.js.map → config-HY2E4GGW.js.map} +0 -0
- /package/dist/{env-proxy-XL4P73MZ.js.map → env-proxy-R6ZMLQTT.js.map} +0 -0
- /package/dist/{ethersCompat-Df4a6QIZ-THAVUGIJ.js.map → ethersCompat-Df4a6QIZ-X6YZWAML.js.map} +0 -0
- /package/dist/{hook-command-4TYCHHRL.js.map → hook-command-2UBCSZG6.js.map} +0 -0
- /package/dist/{install-XWGE4Q7L.js.map → hosts-DVQJ32QC.js.map} +0 -0
- /package/dist/{install-identity-K7EJIQFP.js.map → install-ILUX5C4A.js.map} +0 -0
- /package/dist/{package-ZKQFDWLE.js.map → install-identity-TZKGY6LQ.js.map} +0 -0
- /package/dist/{paths-POPTXJO6.js.map → package-IJFGMWEV.js.map} +0 -0
- /package/dist/{pay-WHBERZ3W.js.map → passphrase-IFTDS3CU.js.map} +0 -0
- /package/dist/{plugin-registration-5TIA564H.js.map → paths-XCSAKISU.js.map} +0 -0
- /package/dist/{redact-6W23GGJC.js.map → pay-WCG3IH4R.js.map} +0 -0
- /package/dist/{update-ZKUERSO2.js.map → plugin-registration-PZFI5GZW.js.map} +0 -0
- /package/dist/{usdc-OGOGEHV2.js.map → redact-D7ASVWKL.js.map} +0 -0
- /package/dist/{viemAdapter-By13KInL-S3DA7DFW.js.map → runtime-fetch-ZSSSK72Y.js.map} +0 -0
- /package/dist/{wallet-2HA6W4R4.js.map → runtime-layout-WIDILZ6K.js.map} +0 -0
|
@@ -1,53 +1,56 @@
|
|
|
1
1
|
import { createRequire as __tenjinCreateRequire } from 'node:module'; const require = __tenjinCreateRequire(import.meta.url);
|
|
2
|
-
import {
|
|
3
|
-
codexRouterEvent,
|
|
4
|
-
codexSession
|
|
5
|
-
} from "./chunk-OHRR5OYM.js";
|
|
6
2
|
import {
|
|
7
3
|
isPublicAddress
|
|
8
4
|
} from "./chunk-JKKAIPTU.js";
|
|
5
|
+
import {
|
|
6
|
+
codexRouterEvent,
|
|
7
|
+
codexSession
|
|
8
|
+
} from "./chunk-P3LFTKE7.js";
|
|
9
9
|
import {
|
|
10
10
|
UNREACHABLE_BACKOFF_MS,
|
|
11
11
|
clearRouterMemo,
|
|
12
12
|
readRouterMemo,
|
|
13
13
|
requestToolAccess,
|
|
14
14
|
writeRouterMemo
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-4USCZ2NI.js";
|
|
16
|
+
import {
|
|
17
|
+
canPayProvider,
|
|
18
|
+
canSign
|
|
19
|
+
} from "./chunk-62KNUYWD.js";
|
|
16
20
|
import {
|
|
17
21
|
readSpendSummary,
|
|
18
22
|
spentOf
|
|
19
|
-
} from "./chunk-
|
|
23
|
+
} from "./chunk-SO3XRZPX.js";
|
|
20
24
|
import {
|
|
21
25
|
ChoicesSchema,
|
|
22
26
|
OfferSpecSchema,
|
|
23
27
|
ROUTER_PATH,
|
|
24
28
|
requestDecision
|
|
25
|
-
} from "./chunk-
|
|
26
|
-
import {
|
|
27
|
-
launchedByPlugin,
|
|
28
|
-
requestToolName
|
|
29
|
-
} from "./chunk-WJXLQXJY.js";
|
|
29
|
+
} from "./chunk-LXAYUOXI.js";
|
|
30
30
|
import {
|
|
31
31
|
FEE_REQUIRED,
|
|
32
32
|
depositSentence,
|
|
33
|
-
firstNoticeFor,
|
|
34
33
|
isFeeRequired,
|
|
35
34
|
unpaidSentence
|
|
36
|
-
} from "./chunk-
|
|
35
|
+
} from "./chunk-HDPUXS3Z.js";
|
|
37
36
|
import {
|
|
38
37
|
evaluateSpendPolicy
|
|
39
38
|
} from "./chunk-2SNUOHAT.js";
|
|
39
|
+
import {
|
|
40
|
+
launchedByPlugin,
|
|
41
|
+
requestToolName
|
|
42
|
+
} from "./chunk-MPZUYCAP.js";
|
|
40
43
|
import {
|
|
41
44
|
mask
|
|
42
|
-
} from "./chunk-
|
|
45
|
+
} from "./chunk-IADZOXKN.js";
|
|
43
46
|
import {
|
|
44
|
-
augmentOf,
|
|
45
47
|
bindDecision,
|
|
46
|
-
|
|
48
|
+
claimNote,
|
|
47
49
|
claimRedirect,
|
|
48
|
-
|
|
50
|
+
markNoted,
|
|
49
51
|
markOffered,
|
|
50
52
|
newCallId,
|
|
53
|
+
noteOf,
|
|
51
54
|
noteSession,
|
|
52
55
|
pruneProgress,
|
|
53
56
|
pruneSessions,
|
|
@@ -55,48 +58,45 @@ import {
|
|
|
55
58
|
sessionDir,
|
|
56
59
|
wasOffered,
|
|
57
60
|
writeProgress
|
|
58
|
-
} from "./chunk-
|
|
61
|
+
} from "./chunk-C2Q76BVM.js";
|
|
59
62
|
import {
|
|
60
63
|
routerSettings
|
|
61
|
-
} from "./chunk-
|
|
62
|
-
import {
|
|
63
|
-
sessionServedByPlugin
|
|
64
|
-
} from "./chunk-I3EQFHCD.js";
|
|
65
|
-
import {
|
|
66
|
-
proxyVariable
|
|
67
|
-
} from "./chunk-S4SAZ7OD.js";
|
|
68
|
-
import {
|
|
69
|
-
composeUserAgent
|
|
70
|
-
} from "./chunk-AGZ7PJKY.js";
|
|
64
|
+
} from "./chunk-AGMVASXZ.js";
|
|
71
65
|
import {
|
|
72
66
|
resolveContextSettings
|
|
73
|
-
} from "./chunk-
|
|
67
|
+
} from "./chunk-KM7RY2ZS.js";
|
|
74
68
|
import {
|
|
75
69
|
parseUsdToAtomic,
|
|
76
70
|
toMoney
|
|
77
71
|
} from "./chunk-Y527D4TV.js";
|
|
78
72
|
import {
|
|
79
|
-
|
|
73
|
+
noticeCleared,
|
|
74
|
+
noticeFor,
|
|
75
|
+
readWalletFacts,
|
|
76
|
+
sessionServedByPlugin,
|
|
77
|
+
settleCurrent
|
|
78
|
+
} from "./chunk-NDGZDTSJ.js";
|
|
79
|
+
import {
|
|
80
|
+
WALLET_UNLOCKED,
|
|
81
|
+
agentFixFor
|
|
82
|
+
} from "./chunk-BFDQ4WNW.js";
|
|
83
|
+
import {
|
|
80
84
|
loadRawConfig,
|
|
81
85
|
resolveExperimentalBazaar,
|
|
82
86
|
resolveSettings
|
|
83
|
-
} from "./chunk-
|
|
84
|
-
import {
|
|
85
|
-
isSameDeployment
|
|
86
|
-
} from "./chunk-XQJXNMSB.js";
|
|
87
|
+
} from "./chunk-2M2VPI2E.js";
|
|
87
88
|
import {
|
|
88
89
|
rememberingBalanceReader
|
|
89
|
-
} from "./chunk-
|
|
90
|
+
} from "./chunk-WXA2BWTE.js";
|
|
91
|
+
import {
|
|
92
|
+
external_exports
|
|
93
|
+
} from "./chunk-SNNSAGMT.js";
|
|
90
94
|
import {
|
|
91
95
|
writeFileAtomic,
|
|
92
96
|
writeFileAtomicExclusive
|
|
93
97
|
} from "./chunk-7WEQQJLG.js";
|
|
94
|
-
import {
|
|
95
|
-
walletPath
|
|
96
|
-
} from "./chunk-SJLTEINJ.js";
|
|
97
98
|
|
|
98
99
|
// src/router/hooks.ts
|
|
99
|
-
import { readFile } from "node:fs/promises";
|
|
100
100
|
import { homedir } from "node:os";
|
|
101
101
|
|
|
102
102
|
// src/router/context.ts
|
|
@@ -511,6 +511,19 @@ async function readChoices(dataDir, id) {
|
|
|
511
511
|
await file.close().catch(() => void 0);
|
|
512
512
|
}
|
|
513
513
|
}
|
|
514
|
+
function labelPath(dataDir, id) {
|
|
515
|
+
return join2(dataDir, SPECS_DIR, `${digest(id)}.label.json`);
|
|
516
|
+
}
|
|
517
|
+
async function storeLabel(dataDir, id, label) {
|
|
518
|
+
try {
|
|
519
|
+
await writeFileAtomic(labelPath(dataDir, id), JSON.stringify({ id, label }), {
|
|
520
|
+
mode: 384,
|
|
521
|
+
dirMode: 448
|
|
522
|
+
});
|
|
523
|
+
} catch {
|
|
524
|
+
}
|
|
525
|
+
await prune(join2(dataDir, SPECS_DIR), SPEC_TTL_MS, Date.now());
|
|
526
|
+
}
|
|
514
527
|
var PaymentSchema = external_exports.discriminatedUnion("state", [
|
|
515
528
|
external_exports.strictObject({
|
|
516
529
|
state: external_exports.literal("paid"),
|
|
@@ -641,173 +654,6 @@ function savedPdfOf(result, sessionId) {
|
|
|
641
654
|
var GATE_TIMEOUT_MS = 3500;
|
|
642
655
|
var DEPOSIT_GATE_TIMEOUT_MS = 4500;
|
|
643
656
|
|
|
644
|
-
// src/router/augment.ts
|
|
645
|
-
import { spawn } from "node:child_process";
|
|
646
|
-
import { constants as constants2 } from "node:fs";
|
|
647
|
-
import { open as open3, rm as rm2 } from "node:fs/promises";
|
|
648
|
-
import { dirname as dirname2 } from "node:path";
|
|
649
|
-
var DOCS_QUERY_MAX = 500;
|
|
650
|
-
var PREFETCH_TIMEOUT_MS = 12e3;
|
|
651
|
-
var AUGMENT_WAIT_MS = 9e3;
|
|
652
|
-
var MAX_DOCS_CHARS = 1e5;
|
|
653
|
-
var MAX_BODY_BYTES = 1e6;
|
|
654
|
-
var POLL_MS = 100;
|
|
655
|
-
var PREFETCH_SCRIPT = [
|
|
656
|
-
"const { renameSync, rmSync, writeFileSync } = require('node:fs');",
|
|
657
|
-
"const { basename, dirname, join } = require('node:path');",
|
|
658
|
-
"const [url, out, agent, timeout, max] = process.argv.slice(1);",
|
|
659
|
-
"const tmp = join(dirname(out), '.' + basename(out) + '.' + process.pid + '.tmp');",
|
|
660
|
-
// The deadline is a plain timer that answers and exits, not an
|
|
661
|
-
// `AbortSignal.timeout`: that one's timer does not hold the process open, so
|
|
662
|
-
// a stalled lookup let it exit without writing anything.
|
|
663
|
-
"const timer = setTimeout(() => done(0, ''), Number(timeout));",
|
|
664
|
-
"const done = (status, text) => {",
|
|
665
|
-
" clearTimeout(timer);",
|
|
666
|
-
" try {",
|
|
667
|
-
" writeFileSync(tmp, JSON.stringify({ status, text }), { mode: 0o600, flag: 'wx' });",
|
|
668
|
-
" renameSync(tmp, out);",
|
|
669
|
-
" } catch {",
|
|
670
|
-
" try { rmSync(tmp, { force: true }); } catch {}",
|
|
671
|
-
" }",
|
|
672
|
-
" process.exit(0);",
|
|
673
|
-
"};",
|
|
674
|
-
"fetch(url, {",
|
|
675
|
-
" headers: { accept: 'text/plain', 'user-agent': agent },",
|
|
676
|
-
" redirect: 'error',",
|
|
677
|
-
"})",
|
|
678
|
-
" .then(async (res) => done(res.status, res.ok ? (await res.text()).slice(0, Number(max)) : ''))",
|
|
679
|
-
" .catch(() => done(0, ''));"
|
|
680
|
-
].join("\n");
|
|
681
|
-
function prefetchEnv(env) {
|
|
682
|
-
return proxyVariable(env) === void 0 ? env : { ...env, NODE_USE_ENV_PROXY: "1" };
|
|
683
|
-
}
|
|
684
|
-
function spawnPrefetch(job) {
|
|
685
|
-
const child = spawn(
|
|
686
|
-
process.execPath,
|
|
687
|
-
[
|
|
688
|
-
"-e",
|
|
689
|
-
PREFETCH_SCRIPT,
|
|
690
|
-
job.url,
|
|
691
|
-
job.out,
|
|
692
|
-
job.userAgent,
|
|
693
|
-
String(PREFETCH_TIMEOUT_MS),
|
|
694
|
-
String(MAX_DOCS_CHARS)
|
|
695
|
-
],
|
|
696
|
-
{
|
|
697
|
-
detached: true,
|
|
698
|
-
stdio: "ignore",
|
|
699
|
-
// Never the session's project: a live child would pin its worktree.
|
|
700
|
-
cwd: dirname2(job.out),
|
|
701
|
-
env: prefetchEnv(process.env),
|
|
702
|
-
windowsHide: true
|
|
703
|
-
}
|
|
704
|
-
);
|
|
705
|
-
child.on("error", () => void 0);
|
|
706
|
-
child.unref();
|
|
707
|
-
}
|
|
708
|
-
function onDeployment(value, baseUrl) {
|
|
709
|
-
let url;
|
|
710
|
-
let base;
|
|
711
|
-
try {
|
|
712
|
-
url = new URL(value);
|
|
713
|
-
base = new URL(baseUrl);
|
|
714
|
-
} catch {
|
|
715
|
-
return null;
|
|
716
|
-
}
|
|
717
|
-
if (url.username !== "" || url.password !== "") return null;
|
|
718
|
-
return isSameDeployment(url.origin, base.origin) ? url : null;
|
|
719
|
-
}
|
|
720
|
-
function docsUrl(endpoint, query, baseUrl) {
|
|
721
|
-
const url = onDeployment(endpoint, baseUrl);
|
|
722
|
-
if (url === null) return null;
|
|
723
|
-
url.searchParams.set("query", query.slice(0, DOCS_QUERY_MAX));
|
|
724
|
-
return url.toString();
|
|
725
|
-
}
|
|
726
|
-
function augmentTarget(offer, query, baseUrl) {
|
|
727
|
-
if (offer.delivery === "offer") return null;
|
|
728
|
-
if (offer.delivery === "augment") {
|
|
729
|
-
if (offer.augmentUrl === void 0) return null;
|
|
730
|
-
return onDeployment(offer.augmentUrl, baseUrl)?.toString() ?? null;
|
|
731
|
-
}
|
|
732
|
-
return docsUrl(offer.endpoint, query, baseUrl);
|
|
733
|
-
}
|
|
734
|
-
async function startAugment(call, offer, baseUrl, deps) {
|
|
735
|
-
if (call.toolUseId === void 0) return false;
|
|
736
|
-
const url = augmentTarget(offer, call.query, baseUrl);
|
|
737
|
-
if (url === null) return false;
|
|
738
|
-
const now = deps.now?.() ?? Date.now();
|
|
739
|
-
if (!await claimQuery(deps.dataDir, call.sessionId, call.agentId, call.query, now)) {
|
|
740
|
-
return false;
|
|
741
|
-
}
|
|
742
|
-
const out = await markAugment(
|
|
743
|
-
deps.dataDir,
|
|
744
|
-
call.sessionId,
|
|
745
|
-
call.toolUseId,
|
|
746
|
-
{ provider: offer.provider, ...offer.label !== void 0 ? { label: offer.label } : {} },
|
|
747
|
-
now
|
|
748
|
-
);
|
|
749
|
-
if (out === null) return false;
|
|
750
|
-
try {
|
|
751
|
-
(deps.prefetch ?? spawnPrefetch)({ url, out, userAgent: composeUserAgent() });
|
|
752
|
-
return true;
|
|
753
|
-
} catch {
|
|
754
|
-
return false;
|
|
755
|
-
}
|
|
756
|
-
}
|
|
757
|
-
async function finishAugment(call, deps) {
|
|
758
|
-
if (call.toolUseId === void 0) return null;
|
|
759
|
-
const now = deps.now?.() ?? Date.now();
|
|
760
|
-
const marker = await augmentOf(deps.dataDir, call.sessionId, call.toolUseId, now);
|
|
761
|
-
if (marker === null) return null;
|
|
762
|
-
if (call.search === null) return { updatedToolOutput: null };
|
|
763
|
-
const budget = Math.min(
|
|
764
|
-
deps.augmentWaitMs ?? AUGMENT_WAIT_MS,
|
|
765
|
-
PREFETCH_TIMEOUT_MS + 1e3 - (now - marker.at)
|
|
766
|
-
);
|
|
767
|
-
const answer = await awaitBody(marker.body, Date.now() + Math.max(0, budget));
|
|
768
|
-
await rm2(marker.body, { force: true }).catch(() => void 0);
|
|
769
|
-
const text = answer?.status === 200 ? answer.text.trim() : "";
|
|
770
|
-
if (text.length === 0) return { updatedToolOutput: null };
|
|
771
|
-
return {
|
|
772
|
-
updatedToolOutput: {
|
|
773
|
-
...call.search.raw,
|
|
774
|
-
results: [
|
|
775
|
-
docsLine(marker.label ?? `${marker.provider || "library"} docs`, text),
|
|
776
|
-
...call.search.results
|
|
777
|
-
]
|
|
778
|
-
}
|
|
779
|
-
};
|
|
780
|
-
}
|
|
781
|
-
function docsLine(name, text) {
|
|
782
|
-
return `Tenjin router added ${name} for this search (free). If they don't cover it, use the web results below.
|
|
783
|
-
|
|
784
|
-
${text}`;
|
|
785
|
-
}
|
|
786
|
-
async function awaitBody(path, deadline) {
|
|
787
|
-
for (; ; ) {
|
|
788
|
-
const body = await readBody(path);
|
|
789
|
-
if (body !== null) return body;
|
|
790
|
-
const left = deadline - Date.now();
|
|
791
|
-
if (left <= 0) return null;
|
|
792
|
-
await new Promise((resolve) => setTimeout(resolve, Math.min(POLL_MS, left)));
|
|
793
|
-
}
|
|
794
|
-
}
|
|
795
|
-
async function readBody(path) {
|
|
796
|
-
const file = await open3(path, constants2.O_RDONLY | constants2.O_NOFOLLOW).catch(() => void 0);
|
|
797
|
-
if (file === void 0) return null;
|
|
798
|
-
try {
|
|
799
|
-
if ((await file.stat()).size > MAX_BODY_BYTES) return { status: 0, text: "" };
|
|
800
|
-
const parsed = JSON.parse(await file.readFile("utf8"));
|
|
801
|
-
const { status, text } = parsed ?? {};
|
|
802
|
-
if (typeof status !== "number" || typeof text !== "string") return { status: 0, text: "" };
|
|
803
|
-
return { status, text: text.slice(0, MAX_DOCS_CHARS) };
|
|
804
|
-
} catch {
|
|
805
|
-
return { status: 0, text: "" };
|
|
806
|
-
} finally {
|
|
807
|
-
await file.close().catch(() => void 0);
|
|
808
|
-
}
|
|
809
|
-
}
|
|
810
|
-
|
|
811
657
|
// src/router/hooks.ts
|
|
812
658
|
var PromptEventSchema = external_exports.object({
|
|
813
659
|
session_id: external_exports.string().min(1).max(200),
|
|
@@ -877,7 +723,7 @@ function decodeEvent(raw) {
|
|
|
877
723
|
kind: "shortfall",
|
|
878
724
|
eventName: shortfall.data.hook_event_name,
|
|
879
725
|
nativeOutcome: shortfallOf(shortfall.data),
|
|
880
|
-
|
|
726
|
+
...shortfall.data.is_interrupt === true ? { interrupted: true } : {},
|
|
881
727
|
savedPdf: savedPdfIn(shortfall.data),
|
|
882
728
|
...nativeCallOf(shortfall.data)
|
|
883
729
|
};
|
|
@@ -973,13 +819,6 @@ function answersOf(response, input) {
|
|
|
973
819
|
}
|
|
974
820
|
return null;
|
|
975
821
|
}
|
|
976
|
-
function searchOf(event) {
|
|
977
|
-
if (event.hook_event_name !== "PostToolUse" || event.tool_name !== "WebSearch") return null;
|
|
978
|
-
const response = event.tool_response;
|
|
979
|
-
if (response === null || typeof response !== "object" || Array.isArray(response)) return null;
|
|
980
|
-
const raw = response;
|
|
981
|
-
return Array.isArray(raw.results) ? { raw, results: raw.results } : null;
|
|
982
|
-
}
|
|
983
822
|
function savedPdfIn(event) {
|
|
984
823
|
if (event.hook_event_name !== "PostToolUse" || event.tool_name !== "WebFetch") return null;
|
|
985
824
|
const response = event.tool_response;
|
|
@@ -1014,6 +853,9 @@ function savedPdfHint(path) {
|
|
|
1014
853
|
function shortfallOffer(tool, hint, host) {
|
|
1015
854
|
return `${HINT_SOURCE}: your ${tool} call came back short. Optional: ${toolNamed(hint, host)}`;
|
|
1016
855
|
}
|
|
856
|
+
function noteLine(line, host) {
|
|
857
|
+
return `${HINT_SOURCE}: your WebSearch call ran. Optional: ${toolNamed(line, host)}`;
|
|
858
|
+
}
|
|
1017
859
|
var NEAR_EMPTY_BYTES = 64;
|
|
1018
860
|
function shortfallOf(event) {
|
|
1019
861
|
if (event.hook_event_name === "PostToolUseFailure") {
|
|
@@ -1070,7 +912,7 @@ async function spendShortfall(decision, deps, deadline) {
|
|
|
1070
912
|
withheld: "offer needs approval",
|
|
1071
913
|
note: `Note: ${price} ${detail}; request will pay nothing and return needs_approval with what it costs.`
|
|
1072
914
|
});
|
|
1073
|
-
let
|
|
915
|
+
let policy;
|
|
1074
916
|
try {
|
|
1075
917
|
const settings = await resolveContextSettings(hookContext(deps));
|
|
1076
918
|
const ledger = await readSpendSummary(deps.dataDir, {
|
|
@@ -1081,37 +923,55 @@ async function spendShortfall(decision, deps, deadline) {
|
|
|
1081
923
|
creator: new URL(decision.endpoint).host,
|
|
1082
924
|
sessionSpentAtomic: ledger === null ? 0n : spentOf(ledger)
|
|
1083
925
|
});
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
926
|
+
policy = evaluation.decision !== "allow" ? approval(
|
|
927
|
+
evaluation.reason === "above_auto_spend" ? `is above this machine's automatic per-call limit ($${toMoney(settings.policy.maxAutoSpendAtomic.toString()).usd})` : "needs approval under this machine's spend limits"
|
|
928
|
+
) : { rpcUrl: settings.rpcUrl };
|
|
929
|
+
} catch {
|
|
930
|
+
policy = approval("needs approval under this machine's spend limits");
|
|
931
|
+
}
|
|
932
|
+
if (BigInt(decision.providerPriceAtomic) === 0n) return "rpcUrl" in policy ? null : policy;
|
|
933
|
+
const facts = await readWalletFacts(deps.dataDir, deps.env ?? process.env);
|
|
934
|
+
const sign = deps.signer?.() ?? canSign(facts);
|
|
935
|
+
if (sign.status === "blocked") return cannotSign(sign);
|
|
936
|
+
if (!("rpcUrl" in policy)) return policy;
|
|
937
|
+
const { rpcUrl } = policy;
|
|
938
|
+
let balance = null;
|
|
939
|
+
if (facts.address !== null && facts.envKey !== "valid") {
|
|
940
|
+
const readBalance = rememberingBalanceReader(deps.dataDir, {
|
|
941
|
+
...deps.now !== void 0 ? { now: deps.now } : {}
|
|
942
|
+
});
|
|
943
|
+
balance = await readBalance(facts.address, rpcUrl, {
|
|
944
|
+
timeoutMs: Math.min(BALANCE_TIMEOUT_MS, deadline - (deps.now?.() ?? Date.now())),
|
|
945
|
+
...deps.fetchImpl !== void 0 ? { fetchImpl: deps.fetchImpl } : {}
|
|
946
|
+
});
|
|
947
|
+
if (balance === null) {
|
|
948
|
+
(deps.warn ?? ((line) => process.stderr.write(`${line}
|
|
949
|
+
`)))(
|
|
950
|
+
`tenjin hook: the wallet's USDC balance could not be read from ${new URL(rpcUrl).host}, so the spend policy alone decides`
|
|
1087
951
|
);
|
|
1088
952
|
}
|
|
1089
|
-
rpcUrl = settings.rpcUrl;
|
|
1090
|
-
} catch {
|
|
1091
|
-
return approval("needs approval under this machine's spend limits");
|
|
1092
953
|
}
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
`)))(
|
|
1106
|
-
`tenjin hook: the wallet's USDC balance could not be read from ${new URL(rpcUrl).host}, so the spend policy alone decides`
|
|
1107
|
-
);
|
|
1108
|
-
return null;
|
|
954
|
+
const v = canPayProvider(
|
|
955
|
+
{ policy: { decision: "allow" }, sign, balanceAtomic: balance },
|
|
956
|
+
BigInt(decision.providerPriceAtomic)
|
|
957
|
+
);
|
|
958
|
+
if (v.status !== "blocked" || v.reason === "needs_approval") return null;
|
|
959
|
+
if (v.reason === "wallet_short") {
|
|
960
|
+
if (balance === null) return null;
|
|
961
|
+
const short = BigInt(decision.providerPriceAtomic) - balance;
|
|
962
|
+
return {
|
|
963
|
+
withheld: "wallet needs USDC",
|
|
964
|
+
note: `Note: the wallet holds $${toMoney(balance.toString()).usd}, $${toMoney(short.toString()).usd} short of its ${price}; fund it with \`tenjin wallet fund\`.`
|
|
965
|
+
};
|
|
1109
966
|
}
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
967
|
+
return cannotSign(v);
|
|
968
|
+
}
|
|
969
|
+
function cannotSign(v) {
|
|
970
|
+
return {
|
|
971
|
+
withheld: "wallet cannot sign",
|
|
972
|
+
note: `Note: Tenjin's wallet cannot pay for this (${v.detail}); ${agentFixFor(v.reason, v.fix)}`,
|
|
973
|
+
signBlocked: true
|
|
974
|
+
};
|
|
1115
975
|
}
|
|
1116
976
|
async function vetOffer(offer, deps, deadline, canAskUser) {
|
|
1117
977
|
const shortfall = await spendShortfall(termsOf(offer), deps, deadline);
|
|
@@ -1119,7 +979,7 @@ async function vetOffer(offer, deps, deadline, canAskUser) {
|
|
|
1119
979
|
const note = await overCapNote(offer, deps, canAskUser);
|
|
1120
980
|
return { offer: note === null ? offer : { ...offer, hint: `${offer.hint} ${note}` } };
|
|
1121
981
|
}
|
|
1122
|
-
if (offer.action === "discovered" && canAskUser) {
|
|
982
|
+
if (offer.action === "discovered" && canAskUser && shortfall.signBlocked !== true) {
|
|
1123
983
|
return { offer: { ...offer, hint: `${offer.hint} ${shortfall.note}` } };
|
|
1124
984
|
}
|
|
1125
985
|
return { withheld: shortfall.withheld };
|
|
@@ -1157,15 +1017,6 @@ async function overCapNote(offer, deps, canAskUser) {
|
|
|
1157
1017
|
const which = over.length > 1 ? "those services" : "that service";
|
|
1158
1018
|
return `Note: ${prices} ${over.length > 1 ? "are" : "is"} above this machine's automatic per-call limit ($${toMoney(cap.toString()).usd}), so request returns needs_approval for ${which}; ` + (canAskUser ? "prefer one within the limit." : "use one within the limit.");
|
|
1159
1019
|
}
|
|
1160
|
-
async function walletAddress(dataDir) {
|
|
1161
|
-
try {
|
|
1162
|
-
const record2 = JSON.parse(await readFile(walletPath(dataDir), "utf8"));
|
|
1163
|
-
const address = record2?.address;
|
|
1164
|
-
return typeof address === "string" && /^0x[0-9a-fA-F]{40}$/.test(address) ? address : null;
|
|
1165
|
-
} catch {
|
|
1166
|
-
return null;
|
|
1167
|
-
}
|
|
1168
|
-
}
|
|
1169
1020
|
function agentLookup(cwd, deps) {
|
|
1170
1021
|
return { ...cwd !== void 0 ? { cwd } : {}, homeDir: deps.homeDir ?? homedir() };
|
|
1171
1022
|
}
|
|
@@ -1199,7 +1050,14 @@ async function offerOnUserText(event, text, hookEventName, deps) {
|
|
|
1199
1050
|
);
|
|
1200
1051
|
const footer = await openFooter(deps, event.sessionId, "prompt");
|
|
1201
1052
|
const deadline = gateDeadline(deps);
|
|
1202
|
-
const outcome = await decide(
|
|
1053
|
+
const outcome = await decide(
|
|
1054
|
+
sealed,
|
|
1055
|
+
deps,
|
|
1056
|
+
router.config,
|
|
1057
|
+
event.sessionId,
|
|
1058
|
+
deadline,
|
|
1059
|
+
footer.unpaid
|
|
1060
|
+
);
|
|
1203
1061
|
if (!isOffer(outcome)) {
|
|
1204
1062
|
await footer.close(outcome);
|
|
1205
1063
|
return { response: null, ...outcome !== null ? { action: outcome.action } : {} };
|
|
@@ -1274,7 +1132,14 @@ async function routeNativeCall(event, pending, deps, opts = {}) {
|
|
|
1274
1132
|
}
|
|
1275
1133
|
const footer = await openFooter(deps, event.sessionId, opts.operation ?? "search");
|
|
1276
1134
|
const deadline = gateDeadline(deps);
|
|
1277
|
-
const outcome = await decide(
|
|
1135
|
+
const outcome = await decide(
|
|
1136
|
+
sealed,
|
|
1137
|
+
deps,
|
|
1138
|
+
router.config,
|
|
1139
|
+
event.sessionId,
|
|
1140
|
+
deadline,
|
|
1141
|
+
footer.unpaid
|
|
1142
|
+
);
|
|
1278
1143
|
if (!isOffer(outcome)) {
|
|
1279
1144
|
await footer.close(outcome);
|
|
1280
1145
|
return {
|
|
@@ -1283,8 +1148,8 @@ async function routeNativeCall(event, pending, deps, opts = {}) {
|
|
|
1283
1148
|
};
|
|
1284
1149
|
}
|
|
1285
1150
|
if (opts.passFree === true && isFree(outcome)) {
|
|
1286
|
-
|
|
1287
|
-
return { offer: outcome, free: true,
|
|
1151
|
+
const close = (shown) => footer.close(outcome, shown ? void 0 : { withheld: "free lookup, call runs" });
|
|
1152
|
+
return { offer: outcome, free: true, close };
|
|
1288
1153
|
}
|
|
1289
1154
|
const vetted = await vetOffer(
|
|
1290
1155
|
outcome,
|
|
@@ -1331,24 +1196,17 @@ async function runNativeHook(raw, deps) {
|
|
|
1331
1196
|
});
|
|
1332
1197
|
if (routed.offer === null) return routed.outcome;
|
|
1333
1198
|
if (routed.free === true) {
|
|
1334
|
-
const { pending } = event;
|
|
1335
|
-
const
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
...event.agentId !== void 0 ? { agentId: event.agentId } : {},
|
|
1340
|
-
...event.toolUseId !== void 0 ? { toolUseId: event.toolUseId } : {}
|
|
1341
|
-
},
|
|
1342
|
-
routed.offer,
|
|
1343
|
-
routed.baseUrl,
|
|
1344
|
-
deps
|
|
1345
|
-
);
|
|
1199
|
+
const { pending, toolUseId } = event;
|
|
1200
|
+
const now = deps.now?.() ?? Date.now();
|
|
1201
|
+
const { id, hint } = routed.offer;
|
|
1202
|
+
const noted = pending.tool === "WebSearch" && routed.offer.delivery === "note" && toolUseId !== void 0 && await claimNote(deps.dataDir, session, event.agentId, pending.query, now) && await markNoted(deps.dataDir, session, toolUseId, { offerId: id, line: hint }, now);
|
|
1203
|
+
await routed.close(noted);
|
|
1346
1204
|
return {
|
|
1347
1205
|
response: null,
|
|
1348
1206
|
action: "execute",
|
|
1349
1207
|
id: routed.offer.id,
|
|
1350
1208
|
free: true,
|
|
1351
|
-
...
|
|
1209
|
+
...noted ? { noted: true } : {}
|
|
1352
1210
|
};
|
|
1353
1211
|
}
|
|
1354
1212
|
if (event.toolUseId !== void 0) {
|
|
@@ -1406,6 +1264,7 @@ async function runAskHook(raw, deps) {
|
|
|
1406
1264
|
});
|
|
1407
1265
|
if (routed.offer === null) return routed.outcome;
|
|
1408
1266
|
if (routed.free === true) {
|
|
1267
|
+
await routed.close(false);
|
|
1409
1268
|
return { response: null, action: routed.offer.action, id: routed.offer.id, free: true };
|
|
1410
1269
|
}
|
|
1411
1270
|
if (event.toolUseId !== void 0) {
|
|
@@ -1422,28 +1281,28 @@ async function runAskHook(raw, deps) {
|
|
|
1422
1281
|
async function runShortfallHook(raw, deps) {
|
|
1423
1282
|
const event = eventOf(raw, deps);
|
|
1424
1283
|
if (event?.kind !== "shortfall") return { response: null };
|
|
1425
|
-
const
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
},
|
|
1431
|
-
deps
|
|
1284
|
+
const note = event.toolUseId === void 0 ? null : await noteOf(
|
|
1285
|
+
deps.dataDir,
|
|
1286
|
+
localSession(event.sessionId, deps),
|
|
1287
|
+
event.toolUseId,
|
|
1288
|
+
deps.now?.()
|
|
1432
1289
|
);
|
|
1433
|
-
if (
|
|
1290
|
+
if (note !== null) {
|
|
1291
|
+
if (event.interrupted === true) return { response: null };
|
|
1434
1292
|
return {
|
|
1435
1293
|
response: {
|
|
1436
1294
|
hookSpecificOutput: {
|
|
1437
|
-
hookEventName:
|
|
1438
|
-
|
|
1295
|
+
hookEventName: event.eventName,
|
|
1296
|
+
additionalContext: noteLine(note.line, hostOf(deps))
|
|
1439
1297
|
}
|
|
1440
1298
|
},
|
|
1441
|
-
|
|
1299
|
+
action: "execute",
|
|
1300
|
+
id: note.offerId,
|
|
1301
|
+
noted: true
|
|
1442
1302
|
};
|
|
1443
1303
|
}
|
|
1444
1304
|
if (event.savedPdf !== null) return await pointAtSavedPdf(event, event.savedPdf, deps);
|
|
1445
|
-
|
|
1446
|
-
return augment === null ? outcome : { ...outcome, augmented: "nothing" };
|
|
1305
|
+
return offerOnShortfall(event, deps);
|
|
1447
1306
|
}
|
|
1448
1307
|
async function pointAtSavedPdf(event, path, deps) {
|
|
1449
1308
|
if (await routerFor(event.cwd, deps) === null) return { response: null };
|
|
@@ -1457,7 +1316,7 @@ async function pointAtSavedPdf(event, path, deps) {
|
|
|
1457
1316
|
savedPdf: true
|
|
1458
1317
|
};
|
|
1459
1318
|
}
|
|
1460
|
-
async function offerOnShortfall(event, deps
|
|
1319
|
+
async function offerOnShortfall(event, deps) {
|
|
1461
1320
|
const { nativeOutcome, pending, eventName } = event;
|
|
1462
1321
|
if (nativeOutcome === null) return { response: null };
|
|
1463
1322
|
if (pending === null) return { response: null };
|
|
@@ -1471,8 +1330,6 @@ async function offerOnShortfall(event, deps, docsJustMissed = false) {
|
|
|
1471
1330
|
}
|
|
1472
1331
|
const routed = await routeNativeCall(event, pending, deps, { nativeOutcome });
|
|
1473
1332
|
if (routed.offer === null) return { ...routed.outcome, nativeOutcome };
|
|
1474
|
-
if (docsJustMissed && isFree(routed.offer))
|
|
1475
|
-
return { response: null, nativeOutcome, action: "execute" };
|
|
1476
1333
|
return {
|
|
1477
1334
|
response: {
|
|
1478
1335
|
hookSpecificOutput: {
|
|
@@ -1511,7 +1368,14 @@ async function runDelegationHook(raw, deps) {
|
|
|
1511
1368
|
if (sealed.packet.historyStatus !== "ok") return { response: null };
|
|
1512
1369
|
const footer = await openFooter(deps, event.sessionId, "delegate");
|
|
1513
1370
|
const deadline = gateDeadline(deps);
|
|
1514
|
-
const outcome = await decide(
|
|
1371
|
+
const outcome = await decide(
|
|
1372
|
+
sealed,
|
|
1373
|
+
deps,
|
|
1374
|
+
router.config,
|
|
1375
|
+
event.sessionId,
|
|
1376
|
+
deadline,
|
|
1377
|
+
footer.unpaid
|
|
1378
|
+
);
|
|
1515
1379
|
if (!isOffer(outcome)) {
|
|
1516
1380
|
await footer.close(outcome);
|
|
1517
1381
|
return { response: null, ...outcome !== null ? { action: outcome.action } : {} };
|
|
@@ -1553,7 +1417,11 @@ async function openFooter(deps, sessionId, operation) {
|
|
|
1553
1417
|
);
|
|
1554
1418
|
await pruneProgress(directory, now());
|
|
1555
1419
|
await pruneSessions(deps.dataDir, now());
|
|
1420
|
+
let unpaid;
|
|
1556
1421
|
return {
|
|
1422
|
+
unpaid: (why) => {
|
|
1423
|
+
unpaid = why;
|
|
1424
|
+
},
|
|
1557
1425
|
close: async (decision, opts) => {
|
|
1558
1426
|
const withheld = opts?.withheld;
|
|
1559
1427
|
await writeProgress(
|
|
@@ -1562,13 +1430,16 @@ async function openFooter(deps, sessionId, operation) {
|
|
|
1562
1430
|
{
|
|
1563
1431
|
phase: "done",
|
|
1564
1432
|
operation,
|
|
1565
|
-
outcome: withheld !== void 0 ? `native tools (${withheld})` : hookOutcome(decision)
|
|
1433
|
+
outcome: withheld !== void 0 ? `native tools (${withheld})` : hookOutcome(decision, unpaid)
|
|
1566
1434
|
},
|
|
1567
1435
|
now()
|
|
1568
1436
|
);
|
|
1569
1437
|
if (withheld === void 0 && isOffer(decision)) {
|
|
1570
1438
|
await bindDecision(deps.dataDir, sessionId, decision.id, now());
|
|
1571
1439
|
await storeSpecs(deps.dataDir, decision.specs);
|
|
1440
|
+
if (isFree(decision) && decision.label !== void 0) {
|
|
1441
|
+
await storeLabel(deps.dataDir, decision.id, decision.label);
|
|
1442
|
+
}
|
|
1572
1443
|
if (decision.action === "discovered" && decision.choices !== void 0) {
|
|
1573
1444
|
await storeChoices(deps.dataDir, decision.id, {
|
|
1574
1445
|
choices: decision.choices,
|
|
@@ -1579,13 +1450,16 @@ async function openFooter(deps, sessionId, operation) {
|
|
|
1579
1450
|
}
|
|
1580
1451
|
};
|
|
1581
1452
|
}
|
|
1582
|
-
function hookOutcome(decision) {
|
|
1583
|
-
if (decision === null) return "native tools (router unavailable)";
|
|
1453
|
+
function hookOutcome(decision, unpaid) {
|
|
1584
1454
|
if (isOffer(decision)) return `paid lookup offered (${termsOf(decision).provider})`;
|
|
1585
|
-
if (decision.action === "native")
|
|
1455
|
+
if (unpaid !== void 0 && (decision === null || decision.action === "native")) {
|
|
1456
|
+
return `fee unpaid: ${unpaid}`;
|
|
1457
|
+
}
|
|
1458
|
+
if (decision === null) return "native tools (router unavailable)";
|
|
1459
|
+
if (decision.action === "native") return "native tools (router chose native)";
|
|
1586
1460
|
return "needs input";
|
|
1587
1461
|
}
|
|
1588
|
-
async function decide({ packet }, deps, config, sessionId, deadline) {
|
|
1462
|
+
async function decide({ packet }, deps, config, sessionId, deadline, unpaid) {
|
|
1589
1463
|
const baseUrl = resolveBaseUrl(deps, config);
|
|
1590
1464
|
const warn = deps.warn ?? ((line) => process.stderr.write(`${line}
|
|
1591
1465
|
`));
|
|
@@ -1613,10 +1487,15 @@ async function decide({ packet }, deps, config, sessionId, deadline) {
|
|
|
1613
1487
|
const deposited = route?.deposited?.() ?? 0n;
|
|
1614
1488
|
if (deposited > 0n) deps.notice?.(depositSentence(deposited));
|
|
1615
1489
|
const why = outcome.status === "skipped" ? outcome.why : outcome.freePath ?? (outcome.status === "decided" && isFeeRequired(outcome.decision) ? FEE_REQUIRED : void 0);
|
|
1490
|
+
if (why !== void 0) unpaid?.(why);
|
|
1616
1491
|
const memoed = deps.route !== void 0 && route === null;
|
|
1617
1492
|
if (why !== void 0 && !(memoed && why === FEE_REQUIRED)) {
|
|
1618
1493
|
await tellOnce(deps, sessionId, why, now);
|
|
1619
1494
|
}
|
|
1495
|
+
if (route !== null && outcome.status === "decided" && outcome.freePath === void 0) {
|
|
1496
|
+
const cleared = await noticeCleared(deps.dataDir, sessionId, now).catch(() => null);
|
|
1497
|
+
if (cleared !== null) deps.notice?.(cleared);
|
|
1498
|
+
}
|
|
1620
1499
|
if (outcome.status === "decided" && isFeeRequired(outcome.decision)) {
|
|
1621
1500
|
await clearRouterMemo(deps.dataDir, "paid-path-absent", baseUrl);
|
|
1622
1501
|
}
|
|
@@ -1645,7 +1524,8 @@ async function decide({ packet }, deps, config, sessionId, deadline) {
|
|
|
1645
1524
|
async function tellOnce(deps, sessionId, why, now) {
|
|
1646
1525
|
const sentence = unpaidSentence(why);
|
|
1647
1526
|
if (sentence === null || deps.notice === void 0) return;
|
|
1648
|
-
|
|
1527
|
+
const told = await noticeFor(deps.dataDir, sessionId, why, now).catch(() => "quiet");
|
|
1528
|
+
if (told === "tell") deps.notice(sentence);
|
|
1649
1529
|
}
|
|
1650
1530
|
function nullStream() {
|
|
1651
1531
|
return { write: () => true };
|
|
@@ -1704,7 +1584,7 @@ async function runHookCommand(kind, io, deps) {
|
|
|
1704
1584
|
const raw = await (deps.readEvent ?? readStdin)();
|
|
1705
1585
|
const event = JSON.parse(raw);
|
|
1706
1586
|
if (deps.harness === "codex") {
|
|
1707
|
-
const { codexResponse } = await import("./codex-event-
|
|
1587
|
+
const { codexResponse } = await import("./codex-event-ZO2GEFE6.js");
|
|
1708
1588
|
response = codexResponse(await runHookKind(kind, event, deps));
|
|
1709
1589
|
} else {
|
|
1710
1590
|
if (!launchedByPlugin(deps.env) && await sessionServedByPlugin(deps.dataDir, event)) return;
|
|
@@ -1716,13 +1596,42 @@ async function runHookCommand(kind, io, deps) {
|
|
|
1716
1596
|
if (response !== null) io.stdout.write(`${JSON.stringify(response)}
|
|
1717
1597
|
`);
|
|
1718
1598
|
}
|
|
1599
|
+
function sessionIdOf(event) {
|
|
1600
|
+
if (event === null || typeof event !== "object") return null;
|
|
1601
|
+
const id = event.session_id;
|
|
1602
|
+
return typeof id === "string" && id.length > 0 && id.length <= 200 ? id : null;
|
|
1603
|
+
}
|
|
1719
1604
|
async function runHookKind(kind, event, hookDeps) {
|
|
1720
1605
|
const notices = /* @__PURE__ */ new Set();
|
|
1721
1606
|
const deps = { ...hookDeps, notice: (line) => notices.add(line) };
|
|
1722
|
-
const
|
|
1723
|
-
|
|
1607
|
+
const sessionId = sessionIdOf(event);
|
|
1608
|
+
const news = sessionId !== null && hookDeps.walletNews !== void 0 ? await hookDeps.walletNews(sessionId).catch(() => null) : null;
|
|
1609
|
+
for (const line of news?.lines ?? []) notices.add(line);
|
|
1610
|
+
let response;
|
|
1611
|
+
try {
|
|
1612
|
+
if (sessionId !== null && news?.lines.includes(WALLET_UNLOCKED) === true) {
|
|
1613
|
+
await settleCurrent(hookDeps.dataDir, sessionId, hookDeps.now?.() ?? Date.now()).catch(
|
|
1614
|
+
() => void 0
|
|
1615
|
+
);
|
|
1616
|
+
}
|
|
1617
|
+
if (sessionId !== null && news?.told !== void 0) {
|
|
1618
|
+
await noticeFor(hookDeps.dataDir, sessionId, news.told, hookDeps.now?.() ?? Date.now()).catch(
|
|
1619
|
+
() => void 0
|
|
1620
|
+
);
|
|
1621
|
+
}
|
|
1622
|
+
const outcome = kind === "prompt" ? await runPromptHook(event, deps) : kind === "native" ? await runNativeHook(event, deps) : kind === "shortfall" ? await runShortfallHook(event, deps) : kind === "ask" ? await runAskHook(event, deps) : kind === "answer" ? await runAnswerHook(event, deps) : await runDelegationHook(event, deps);
|
|
1623
|
+
response = withNotices(outcome.response, notices);
|
|
1624
|
+
} catch (err) {
|
|
1625
|
+
news?.release();
|
|
1626
|
+
throw err;
|
|
1627
|
+
}
|
|
1628
|
+
if (news !== null) await news.ack().catch(() => void 0);
|
|
1629
|
+
return response;
|
|
1630
|
+
}
|
|
1631
|
+
function withNotices(response, notices) {
|
|
1632
|
+
if (notices.size === 0) return response;
|
|
1724
1633
|
const systemMessage = [...notices].join("\n");
|
|
1725
|
-
return
|
|
1634
|
+
return response === null || typeof response !== "object" ? { systemMessage } : { ...response, systemMessage };
|
|
1726
1635
|
}
|
|
1727
1636
|
async function readStdin() {
|
|
1728
1637
|
return new Promise((resolve, reject) => {
|
|
@@ -1765,4 +1674,4 @@ export {
|
|
|
1765
1674
|
runHookCommand,
|
|
1766
1675
|
runHookKind
|
|
1767
1676
|
};
|
|
1768
|
-
//# sourceMappingURL=chunk-
|
|
1677
|
+
//# sourceMappingURL=chunk-ZDZERB6L.js.map
|