tenjin-cli 0.1.0-alpha.33 → 0.1.0-alpha.35
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/NOTICE.md +110 -0
- package/README.md +87 -81
- package/dist/{_esm-BIN7VY2L.js → _esm-2KST7HQ7.js} +7 -7
- package/dist/alive-5TV22PNF.js +51 -0
- package/dist/auth-XI7BJFLW.js +47 -0
- package/dist/{auto-update-Y24UL56V.js → auto-update-7L24KDWA.js} +4 -5
- package/dist/balance-DFHC6XEU.js +71 -0
- package/dist/{ccip-DHDFKTQV.js → ccip-HOW3DZYF.js} +4 -4
- package/dist/chunk-24XKUN2S.js +202 -0
- package/dist/chunk-24XKUN2S.js.map +1 -0
- package/dist/chunk-2L7TDGLV.js +56 -0
- package/dist/chunk-2L7TDGLV.js.map +1 -0
- package/dist/{chunk-C2Q76BVM.js → chunk-2U7H35IP.js} +29 -7
- package/dist/chunk-2U7H35IP.js.map +1 -0
- package/dist/chunk-2W4DQQUU.js +176 -0
- package/dist/chunk-2W4DQQUU.js.map +1 -0
- package/dist/{chunk-LRW6S53P.js → chunk-34SAECKZ.js} +35 -11
- package/dist/chunk-34SAECKZ.js.map +1 -0
- package/dist/{chunk-2I4QTOLB.js → chunk-3MZ7DYRO.js} +1 -1
- package/dist/chunk-3MZ7DYRO.js.map +1 -0
- package/dist/{chunk-RVPYTUP4.js → chunk-3Y2EHT4F.js} +13 -9
- package/dist/chunk-3Y2EHT4F.js.map +1 -0
- package/dist/chunk-3Y6BHIN6.js +169 -0
- package/dist/chunk-3Y6BHIN6.js.map +1 -0
- package/dist/{chunk-4K7TQHNP.js → chunk-3YPL6T3P.js} +17 -33
- package/dist/chunk-3YPL6T3P.js.map +1 -0
- package/dist/{chunk-E7SW44LM.js → chunk-44MVIRZH.js} +121 -6
- package/dist/chunk-44MVIRZH.js.map +1 -0
- package/dist/chunk-45MMSBHA.js +321 -0
- package/dist/chunk-45MMSBHA.js.map +1 -0
- package/dist/{chunk-3FMZGI7I.js → chunk-4CE6TMI5.js} +1 -1
- package/dist/chunk-4CE6TMI5.js.map +1 -0
- package/dist/{chunk-QXP3Z3JN.js → chunk-4MBCJFY4.js} +35 -3
- package/dist/chunk-4MBCJFY4.js.map +1 -0
- package/dist/chunk-4TPL54KW.js +227 -0
- package/dist/chunk-4TPL54KW.js.map +1 -0
- package/dist/chunk-54ELBTKE.js +1615 -0
- package/dist/chunk-54ELBTKE.js.map +1 -0
- package/dist/{chunk-NDGZDTSJ.js → chunk-5F4OB5B3.js} +115 -57
- package/dist/chunk-5F4OB5B3.js.map +1 -0
- package/dist/chunk-5HN4KVQU.js +3348 -0
- package/dist/chunk-5HN4KVQU.js.map +1 -0
- package/dist/{chunk-ZDZERB6L.js → chunk-5J4E5GYI.js} +572 -407
- package/dist/chunk-5J4E5GYI.js.map +1 -0
- package/dist/{chunk-ZNNXRNFD.js → chunk-5N4GGUBN.js} +48 -6
- package/dist/chunk-5N4GGUBN.js.map +1 -0
- package/dist/chunk-5USBZ2MU.js +58 -0
- package/dist/chunk-5USBZ2MU.js.map +1 -0
- package/dist/chunk-64WOMNYR.js +183 -0
- package/dist/chunk-64WOMNYR.js.map +1 -0
- package/dist/{chunk-ILNIZ5I2.js → chunk-65RS4LQS.js} +1825 -1715
- package/dist/chunk-65RS4LQS.js.map +1 -0
- package/dist/{chunk-IE7P2BZE.js → chunk-6QMDUDF2.js} +3 -3
- package/dist/{chunk-IADZOXKN.js → chunk-7SLOTLO7.js} +19 -697
- package/dist/chunk-7SLOTLO7.js.map +1 -0
- package/dist/{chunk-WFSPCCVW.js → chunk-7V25UAQO.js} +99 -99
- package/dist/{chunk-WFSPCCVW.js.map → chunk-7V25UAQO.js.map} +1 -1
- package/dist/chunk-BGA4DO5M.js +719 -0
- package/dist/chunk-BGA4DO5M.js.map +1 -0
- package/dist/chunk-BVP7YK2J.js +706 -0
- package/dist/chunk-BVP7YK2J.js.map +1 -0
- package/dist/chunk-C265QIMJ.js +83 -0
- package/dist/chunk-C265QIMJ.js.map +1 -0
- package/dist/{chunk-XQJXNMSB.js → chunk-CRG54LEB.js} +1 -1
- package/dist/chunk-CRG54LEB.js.map +1 -0
- package/dist/{chunk-KG3D7FIF.js → chunk-CZJOMUBP.js} +2 -2
- package/dist/{chunk-36RVGZNY.js → chunk-D6M3ZK66.js} +22 -39
- package/dist/chunk-D6M3ZK66.js.map +1 -0
- package/dist/{chunk-3UCIG4TG.js → chunk-DI4QAGRZ.js} +1 -11
- package/dist/chunk-DI4QAGRZ.js.map +1 -0
- package/dist/{chunk-JKKAIPTU.js → chunk-DIH2G3YG.js} +47 -10
- package/dist/chunk-DIH2G3YG.js.map +1 -0
- package/dist/chunk-DJ36BM62.js +78 -0
- package/dist/chunk-DJ36BM62.js.map +1 -0
- package/dist/chunk-DTEWAVNE.js +114 -0
- package/dist/chunk-DTEWAVNE.js.map +1 -0
- package/dist/chunk-F2KJAJ7T.js +13 -0
- package/dist/chunk-F2KJAJ7T.js.map +1 -0
- package/dist/{chunk-BF4XHEQK.js → chunk-F3QPGYOY.js} +6 -6
- package/dist/chunk-F3QPGYOY.js.map +1 -0
- package/dist/{chunk-3GNJXKIT.js → chunk-F43CV6UC.js} +2 -2
- package/dist/{chunk-J57UC3DD.js → chunk-FKVJKLPI.js} +3 -3
- package/dist/{chunk-V2LQLN5H.js → chunk-FYFHH7V5.js} +59 -8
- package/dist/{chunk-V2LQLN5H.js.map → chunk-FYFHH7V5.js.map} +1 -1
- package/dist/chunk-GAJC4BQZ.js +1096 -0
- package/dist/chunk-GAJC4BQZ.js.map +1 -0
- package/dist/{chunk-DOQGNFHM.js → chunk-GH5UKMZD.js} +2 -12
- package/dist/{chunk-DOQGNFHM.js.map → chunk-GH5UKMZD.js.map} +1 -1
- package/dist/{chunk-WYXUQGOL.js → chunk-HAZAN4UM.js} +7 -6
- package/dist/chunk-HAZAN4UM.js.map +1 -0
- package/dist/chunk-HI5XQOX2.js +393 -0
- package/dist/chunk-HI5XQOX2.js.map +1 -0
- package/dist/chunk-HKGUKAQW.js +488 -0
- package/dist/chunk-HKGUKAQW.js.map +1 -0
- package/dist/{chunk-SO3XRZPX.js → chunk-HPRVFJPM.js} +6 -6
- package/dist/{chunk-L6JEXB3E.js → chunk-HQR4BWKX.js} +3 -131
- package/dist/chunk-HQR4BWKX.js.map +1 -0
- package/dist/chunk-HZKANST2.js +177 -0
- package/dist/chunk-HZKANST2.js.map +1 -0
- package/dist/{chunk-UUGOUOVT.js → chunk-I557SAOM.js} +8 -2
- package/dist/chunk-I557SAOM.js.map +1 -0
- package/dist/{chunk-TC2WZLSC.js → chunk-IGLWLH73.js} +8 -7
- package/dist/chunk-IGLWLH73.js.map +1 -0
- package/dist/chunk-ILWCKCOI.js +58 -0
- package/dist/chunk-ILWCKCOI.js.map +1 -0
- package/dist/{chunk-2GP3HRYK.js → chunk-INSIW65E.js} +182 -182
- package/dist/{chunk-MPZUYCAP.js → chunk-IULCDMVG.js} +12 -1
- package/dist/chunk-IULCDMVG.js.map +1 -0
- package/dist/{chunk-INTFHMU4.js → chunk-IVNSUAVC.js} +25 -26
- package/dist/chunk-IVNSUAVC.js.map +1 -0
- package/dist/chunk-JDQZCREI.js +87 -0
- package/dist/chunk-JDQZCREI.js.map +1 -0
- package/dist/chunk-JHFFUVON.js +1050 -0
- package/dist/chunk-JHFFUVON.js.map +1 -0
- package/dist/{chunk-RL5UUDT4.js → chunk-JNUKLSMZ.js} +3 -3
- package/dist/chunk-JTILUN4W.js +2933 -0
- package/dist/chunk-JTILUN4W.js.map +1 -0
- package/dist/{chunk-OJNTCYQQ.js → chunk-JTX3BUDK.js} +37 -53
- package/dist/chunk-JTX3BUDK.js.map +1 -0
- package/dist/{chunk-X5ZBP3IY.js → chunk-JUUBBBY5.js} +2 -2
- package/dist/chunk-JUUBBBY5.js.map +1 -0
- package/dist/chunk-JWAK7JQB.js +15 -0
- package/dist/chunk-JWAK7JQB.js.map +1 -0
- package/dist/{chunk-UXZONNEQ.js → chunk-K5KNGC4I.js} +34 -31
- package/dist/chunk-K5KNGC4I.js.map +1 -0
- package/dist/chunk-KAQ4Q3TO.js +135 -0
- package/dist/chunk-KAQ4Q3TO.js.map +1 -0
- package/dist/chunk-KFVJYLVL.js +125 -0
- package/dist/chunk-KFVJYLVL.js.map +1 -0
- package/dist/chunk-KGUE5AVX.js +69 -0
- package/dist/chunk-KGUE5AVX.js.map +1 -0
- package/dist/{chunk-FVIGCDSV.js → chunk-KLDMLWXT.js} +11 -85
- package/dist/chunk-KLDMLWXT.js.map +1 -0
- package/dist/chunk-KNKDMTHU.js +453 -0
- package/dist/chunk-KNKDMTHU.js.map +1 -0
- package/dist/chunk-LDA6TAYQ.js +95 -0
- package/dist/chunk-LDA6TAYQ.js.map +1 -0
- package/dist/chunk-LWSSIZOY.js +347 -0
- package/dist/chunk-LWSSIZOY.js.map +1 -0
- package/dist/{chunk-ZURZHELF.js → chunk-MAHNZA6C.js} +158 -41
- package/dist/chunk-MAHNZA6C.js.map +1 -0
- package/dist/chunk-MEWZCIA6.js +220 -0
- package/dist/chunk-MEWZCIA6.js.map +1 -0
- package/dist/{chunk-2SNUOHAT.js → chunk-MEZJ3I63.js} +49 -1
- package/dist/chunk-MEZJ3I63.js.map +1 -0
- package/dist/chunk-MJDO4EXD.js +353 -0
- package/dist/chunk-MJDO4EXD.js.map +1 -0
- package/dist/chunk-NJA6NT3A.js +6595 -0
- package/dist/chunk-NJA6NT3A.js.map +1 -0
- package/dist/{chunk-LHHMV4GU.js → chunk-NVSKJPRC.js} +1 -1
- package/dist/{chunk-LHHMV4GU.js.map → chunk-NVSKJPRC.js.map} +1 -1
- package/dist/{chunk-4YOZGGTZ.js → chunk-OC7K2DVZ.js} +5 -5
- package/dist/chunk-OC7K2DVZ.js.map +1 -0
- package/dist/chunk-ODRPASFP.js +2078 -0
- package/dist/chunk-ODRPASFP.js.map +1 -0
- package/dist/chunk-OJJFANO6.js +133 -0
- package/dist/chunk-OJJFANO6.js.map +1 -0
- package/dist/{chunk-JNJWBTU2.js → chunk-OQWPRFAC.js} +332 -882
- package/dist/chunk-OQWPRFAC.js.map +1 -0
- package/dist/chunk-P4I7BFNJ.js +11 -0
- package/dist/chunk-P4I7BFNJ.js.map +1 -0
- package/dist/{chunk-SNNSAGMT.js → chunk-P6YQWIT2.js} +4058 -4039
- package/dist/chunk-P6YQWIT2.js.map +1 -0
- package/dist/{chunk-JRGFKVAZ.js → chunk-PETQ5WEA.js} +2 -2
- package/dist/{chunk-HMWYAUA6.js → chunk-Q6RSJCXB.js} +29 -69
- package/dist/chunk-Q6RSJCXB.js.map +1 -0
- package/dist/{chunk-U3IKUGRP.js → chunk-QKEUKBRK.js} +17 -23
- package/dist/chunk-QKEUKBRK.js.map +1 -0
- package/dist/{chunk-2RWB7RKE.js → chunk-QKYUCITR.js} +174 -5814
- package/dist/chunk-QKYUCITR.js.map +1 -0
- package/dist/chunk-QQDPRTLP.js +127 -0
- package/dist/chunk-QQDPRTLP.js.map +1 -0
- package/dist/chunk-QQYCYAKI.js +79 -0
- package/dist/chunk-QQYCYAKI.js.map +1 -0
- package/dist/chunk-R4KDH477.js +1064 -0
- package/dist/chunk-R4KDH477.js.map +1 -0
- package/dist/chunk-R5TR2DIK.js +119 -0
- package/dist/chunk-R5TR2DIK.js.map +1 -0
- package/dist/chunk-R62PKTAG.js +66 -0
- package/dist/chunk-R62PKTAG.js.map +1 -0
- package/dist/{chunk-BFDQ4WNW.js → chunk-RFZA7PSM.js} +4 -5
- package/dist/chunk-RFZA7PSM.js.map +1 -0
- package/dist/chunk-RGCPELQN.js +219 -0
- package/dist/chunk-RGCPELQN.js.map +1 -0
- package/dist/chunk-RGVCOG2S.js +910 -0
- package/dist/chunk-RGVCOG2S.js.map +1 -0
- package/dist/chunk-SOLNJ3AZ.js +209 -0
- package/dist/chunk-SOLNJ3AZ.js.map +1 -0
- package/dist/chunk-TFT2X7SH.js +77 -0
- package/dist/chunk-TFT2X7SH.js.map +1 -0
- package/dist/chunk-TUCKEEXE.js +2 -0
- package/dist/chunk-TVWCLUBI.js +293 -0
- package/dist/chunk-TVWCLUBI.js.map +1 -0
- package/dist/chunk-U4TRWSVE.js +78 -0
- package/dist/chunk-U4TRWSVE.js.map +1 -0
- package/dist/chunk-UIB33QQP.js +379 -0
- package/dist/chunk-UIB33QQP.js.map +1 -0
- package/dist/chunk-V6GIVALQ.js +1889 -0
- package/dist/chunk-V6GIVALQ.js.map +1 -0
- package/dist/chunk-VHXCPXUS.js +366 -0
- package/dist/chunk-VHXCPXUS.js.map +1 -0
- package/dist/{chunk-HGZEPQUT.js → chunk-VU6GMWF6.js} +17 -8
- package/dist/chunk-VU6GMWF6.js.map +1 -0
- package/dist/chunk-VWZYE3NC.js +8415 -0
- package/dist/chunk-VWZYE3NC.js.map +1 -0
- package/dist/{chunk-AGMVASXZ.js → chunk-W2GXIARJ.js} +88 -11
- package/dist/chunk-W2GXIARJ.js.map +1 -0
- package/dist/chunk-W4G3K3V7.js +288 -0
- package/dist/chunk-W4G3K3V7.js.map +1 -0
- package/dist/chunk-W74LJ5OT.js +588 -0
- package/dist/chunk-W74LJ5OT.js.map +1 -0
- package/dist/chunk-W7ELYLYK.js +233 -0
- package/dist/chunk-W7ELYLYK.js.map +1 -0
- package/dist/{chunk-BPMWXTFX.js → chunk-WFZX352D.js} +7 -7
- package/dist/chunk-WXA3WTPF.js +20 -0
- package/dist/chunk-WXA3WTPF.js.map +1 -0
- package/dist/chunk-XRGFH7FI.js +454 -0
- package/dist/chunk-XRGFH7FI.js.map +1 -0
- package/dist/chunk-XSCGUO2U.js +330 -0
- package/dist/chunk-XSCGUO2U.js.map +1 -0
- package/dist/chunk-XWROSMI5.js +1039 -0
- package/dist/chunk-XWROSMI5.js.map +1 -0
- package/dist/chunk-Y2EXZ47H.js +40 -0
- package/dist/chunk-Y2EXZ47H.js.map +1 -0
- package/dist/chunk-YJGEVBKZ.js +47 -0
- package/dist/chunk-YJGEVBKZ.js.map +1 -0
- package/dist/{chunk-6CMM6YCB.js → chunk-YWWMISDY.js} +2 -2
- package/dist/{chunk-WXA2BWTE.js → chunk-ZCT5DJ3G.js} +2 -48
- package/dist/chunk-ZCT5DJ3G.js.map +1 -0
- package/dist/chunk-ZEYA2WWX.js +982 -0
- package/dist/chunk-ZEYA2WWX.js.map +1 -0
- package/dist/chunk-ZRC7Z5X3.js +82 -0
- package/dist/chunk-ZRC7Z5X3.js.map +1 -0
- package/dist/{chunk-3AIHRXKO.js → chunk-ZS7JIUJ3.js} +12 -10
- package/dist/chunk-ZS7JIUJ3.js.map +1 -0
- package/dist/{clack-EZ7TDWQU.js → clack-Q4RNC5VE.js} +2 -6
- package/dist/{claude-cli-2YKABJJZ.js → claude-cli-GIIHOBGT.js} +4 -2
- package/dist/claude-install-BAUSJMW3.js +64 -0
- package/dist/{cli-E36SPKBW.js → cli-QY4KKA3D.js} +632 -150
- package/dist/cli-QY4KKA3D.js.map +1 -0
- package/dist/client-3YQKORVK.js +710 -0
- package/dist/client-3YQKORVK.js.map +1 -0
- package/dist/{codex-event-ZO2GEFE6.js → codex-event-EUTCAOTQ.js} +3 -5
- package/dist/{codex-host-KECJVTA2.js → codex-host-ZON3S6HU.js} +7 -7
- package/dist/{codex-install-HQZDGFXW.js → codex-install-HZV2DOAB.js} +242 -88
- package/dist/codex-install-HZV2DOAB.js.map +1 -0
- package/dist/config-QZOBMTEL.js +57 -0
- package/dist/config-names-Z5NZD5R2.js +224 -0
- package/dist/config-names-Z5NZD5R2.js.map +1 -0
- package/dist/config-rules-YOYHS6YL.js +55 -0
- package/dist/config-subagents-WQV2ZAD5.js +362 -0
- package/dist/config-subagents-WQV2ZAD5.js.map +1 -0
- package/dist/connect-YDWTYU4B.js +1020 -0
- package/dist/connect-YDWTYU4B.js.map +1 -0
- package/dist/core-0a66n3e7-TTP554XV.js +127 -0
- package/dist/core-0a66n3e7-TTP554XV.js.map +1 -0
- package/dist/core-0bmnpbz2-C2JIRVZO.js +10790 -0
- package/dist/core-0bmnpbz2-C2JIRVZO.js.map +1 -0
- package/dist/core-9je8ee1j-74DGHWPV.js +30 -0
- package/dist/core-9je8ee1j-74DGHWPV.js.map +1 -0
- package/dist/core-wadgcjfh-TSZFQZGH.js +666 -0
- package/dist/core-wadgcjfh-TSZFQZGH.js.map +1 -0
- package/dist/core-zg882d22-LKV5DZYW.js +37 -0
- package/dist/core-zg882d22-LKV5DZYW.js.map +1 -0
- package/dist/decision-QSKHOGCO.js +145 -0
- package/dist/{doctor-I6XQEKWD.js → doctor-ZWJXRD75.js} +162 -148
- package/dist/doctor-ZWJXRD75.js.map +1 -0
- package/dist/{env-proxy-R6ZMLQTT.js → env-proxy-XLSLHBKQ.js} +2 -2
- package/dist/{ethersCompat-Df4a6QIZ-X6YZWAML.js → ethersCompat-Df4a6QIZ-K3DMHR6Y.js} +5 -5
- package/dist/explicit-ME2NRADQ.js +371 -0
- package/dist/explicit-ME2NRADQ.js.map +1 -0
- package/dist/flush-stdio-NYIJ3QXT.js +18 -0
- package/dist/fund-VF7TLDJH.js +722 -0
- package/dist/fund-VF7TLDJH.js.map +1 -0
- package/dist/hook-command-VZ27MGWO.js +49 -0
- package/dist/hosts/claude/.claude-plugin/marketplace.json +2 -2
- package/dist/hosts/claude/tenjin/.claude-plugin/plugin.json +2 -2
- package/dist/hosts/claude/tenjin/hooks/hook-data.ts +152 -0
- package/dist/hosts/claude/tenjin/hooks/hooks.json +7 -0
- package/dist/hosts/claude/tenjin/hooks/model-viewer.tsx +2987 -0
- package/dist/hosts/claude/tenjin/hooks/register.tsx +527 -56
- package/dist/hosts/claude/tenjin/skills/tenjin-pay/SKILL.md +14 -4
- package/dist/hosts/claude/tenjin/types/index.d.ts +144 -1
- package/dist/{hosts-DVQJ32QC.js → hosts-3EMTVM4H.js} +7 -6
- package/dist/index.js +18 -15
- package/dist/index.js.map +1 -1
- package/dist/install-ZA7L2UF3.js +115 -0
- package/dist/install-funding-JDGYTF72.js +30 -0
- package/dist/install-identity-FFAYEFLX.js +30 -0
- package/dist/{install-wallet-5M4OTYLX.js → install-wallet-2SFOVE3Q.js} +68 -53
- package/dist/install-wallet-2SFOVE3Q.js.map +1 -0
- package/dist/mcp-36S6MK3C.js +67642 -0
- package/dist/mcp-36S6MK3C.js.map +1 -0
- package/dist/new-install-5L4GY3LN.js +51 -0
- package/dist/{package-IJFGMWEV.js → package-BONDXSV3.js} +2 -2
- package/dist/{passphrase-IFTDS3CU.js → passphrase-T4ULBN4M.js} +16 -12
- package/dist/{paths-XCSAKISU.js → paths-O2KDWZ76.js} +18 -28
- package/dist/pay-CMV5KL74.js +74 -0
- package/dist/{payments-HFPPWHTV.js → payments-Z6UBZL4Z.js} +36 -26
- package/dist/payments-Z6UBZL4Z.js.map +1 -0
- package/dist/reclaim-subagent-credit-ABSF67SJ.js +105 -0
- package/dist/reclaim-subagent-credit-ABSF67SJ.js.map +1 -0
- package/dist/{redact-D7ASVWKL.js → redact-LOTHE5TS.js} +2 -8
- package/dist/redact-LOTHE5TS.js.map +1 -0
- package/dist/routing-quote-AHLAREXR.js +40 -0
- package/dist/routing-quote-AHLAREXR.js.map +1 -0
- package/dist/run-JH7ELYAM.js +88 -0
- package/dist/run-JH7ELYAM.js.map +1 -0
- package/dist/runtime-2GX4ALJP.js +410 -0
- package/dist/runtime-2GX4ALJP.js.map +1 -0
- package/dist/runtime-activate-IDQ2NCSP.js +39 -0
- package/dist/runtime-activate-IDQ2NCSP.js.map +1 -0
- package/dist/{runtime-fetch-ZSSSK72Y.js → runtime-fetch-6LOBHBEN.js} +4 -4
- package/dist/runtime-fetch-6LOBHBEN.js.map +1 -0
- package/dist/runtime-launchers-YAPKCBHV.js +31 -0
- package/dist/runtime-launchers-YAPKCBHV.js.map +1 -0
- package/dist/{runtime-layout-WIDILZ6K.js → runtime-layout-QHZQJV7C.js} +5 -4
- package/dist/runtime-layout-QHZQJV7C.js.map +1 -0
- package/dist/runtime-place-4POL4KK4.js +37 -0
- package/dist/runtime-place-4POL4KK4.js.map +1 -0
- package/dist/runtime-provenance-MNJGVBV2.js +12 -0
- package/dist/runtime-provenance-MNJGVBV2.js.map +1 -0
- package/dist/{secp256k1-ZZZT2CAX.js → secp256k1-N5P2GVGF.js} +3 -3
- package/dist/secp256k1-N5P2GVGF.js.map +1 -0
- package/dist/{send-GCVEAQKL.js → send-ELXFKEKY.js} +35 -32
- package/dist/send-ELXFKEKY.js.map +1 -0
- package/dist/status-FXUFWJDM.js +404 -0
- package/dist/status-FXUFWJDM.js.map +1 -0
- package/dist/{status-line-OPCXDHL2.js → status-line-IH5JBWBC.js} +51 -43
- package/dist/status-line-IH5JBWBC.js.map +1 -0
- package/dist/streamableHttp-CP2ZQBIK.js +768 -0
- package/dist/streamableHttp-CP2ZQBIK.js.map +1 -0
- package/dist/{uninstall-BAWRBXXQ.js → uninstall-LJZUKM4D.js} +76 -76
- package/dist/uninstall-LJZUKM4D.js.map +1 -0
- package/dist/update-EUIX72IX.js +68 -0
- package/dist/update-EUIX72IX.js.map +1 -0
- package/dist/usage-EKDC7LUC.js +180 -0
- package/dist/usage-EKDC7LUC.js.map +1 -0
- package/dist/{usdc-VG4CIOUK.js → usdc-YIHK2OMC.js} +8 -12
- package/dist/usdc-YIHK2OMC.js.map +1 -0
- package/dist/{viemAdapter-By13KInL-DOFTEIJV.js → viemAdapter-By13KInL-PRLSIESK.js} +5 -5
- package/dist/viemAdapter-By13KInL-PRLSIESK.js.map +1 -0
- package/dist/wallet-HSW757W6.js +80 -0
- package/dist/wallet-HSW757W6.js.map +1 -0
- package/dist/wallet-kdf-worker.mjs +1433 -818
- package/docs/agent-permissions.md +88 -155
- package/docs/router-reference.md +236 -0
- package/docs/safety-model.md +31 -33
- package/docs/subagents-internals.md +97 -0
- package/docs/subagents.md +348 -0
- package/docs/troubleshooting.md +10 -6
- package/package.json +12 -8
- package/scripts/installers/install.sh +7 -1
- package/dist/alive-GSOWKUOY.js +0 -38
- package/dist/chunk-2I4QTOLB.js.map +0 -1
- package/dist/chunk-2M2VPI2E.js +0 -560
- package/dist/chunk-2M2VPI2E.js.map +0 -1
- package/dist/chunk-2RWB7RKE.js.map +0 -1
- package/dist/chunk-2SNUOHAT.js.map +0 -1
- package/dist/chunk-3623BLPV.js +0 -184
- package/dist/chunk-3623BLPV.js.map +0 -1
- package/dist/chunk-36RVGZNY.js.map +0 -1
- package/dist/chunk-3AIHRXKO.js.map +0 -1
- package/dist/chunk-3FMZGI7I.js.map +0 -1
- package/dist/chunk-3UCIG4TG.js.map +0 -1
- package/dist/chunk-4K7TQHNP.js.map +0 -1
- package/dist/chunk-4LMUQMBH.js +0 -29
- package/dist/chunk-4LMUQMBH.js.map +0 -1
- package/dist/chunk-4USCZ2NI.js +0 -228
- package/dist/chunk-4USCZ2NI.js.map +0 -1
- package/dist/chunk-4YOZGGTZ.js.map +0 -1
- package/dist/chunk-62KNUYWD.js +0 -111
- package/dist/chunk-62KNUYWD.js.map +0 -1
- package/dist/chunk-A5GKIG5O.js +0 -2037
- package/dist/chunk-A5GKIG5O.js.map +0 -1
- package/dist/chunk-AGMVASXZ.js.map +0 -1
- package/dist/chunk-BF4XHEQK.js.map +0 -1
- package/dist/chunk-BFDQ4WNW.js.map +0 -1
- package/dist/chunk-C2Q76BVM.js.map +0 -1
- package/dist/chunk-CEXSOI5R.js +0 -808
- package/dist/chunk-CEXSOI5R.js.map +0 -1
- package/dist/chunk-E7SW44LM.js.map +0 -1
- package/dist/chunk-EDJWHDDL.js +0 -33
- package/dist/chunk-EDJWHDDL.js.map +0 -1
- package/dist/chunk-FVIGCDSV.js.map +0 -1
- package/dist/chunk-GTTUCOPD.js +0 -105
- package/dist/chunk-GTTUCOPD.js.map +0 -1
- package/dist/chunk-HDPUXS3Z.js +0 -122
- package/dist/chunk-HDPUXS3Z.js.map +0 -1
- package/dist/chunk-HGGWCP7W.js +0 -120
- package/dist/chunk-HGGWCP7W.js.map +0 -1
- package/dist/chunk-HGZEPQUT.js.map +0 -1
- package/dist/chunk-HMWYAUA6.js.map +0 -1
- package/dist/chunk-IADZOXKN.js.map +0 -1
- package/dist/chunk-ILNIZ5I2.js.map +0 -1
- package/dist/chunk-INTFHMU4.js.map +0 -1
- package/dist/chunk-JKKAIPTU.js.map +0 -1
- package/dist/chunk-JNJWBTU2.js.map +0 -1
- package/dist/chunk-KM7RY2ZS.js +0 -246
- package/dist/chunk-KM7RY2ZS.js.map +0 -1
- package/dist/chunk-KOGZDMHO.js +0 -21
- package/dist/chunk-KOGZDMHO.js.map +0 -1
- package/dist/chunk-L6JEXB3E.js.map +0 -1
- package/dist/chunk-LRW6S53P.js.map +0 -1
- package/dist/chunk-LXAYUOXI.js +0 -511
- package/dist/chunk-LXAYUOXI.js.map +0 -1
- package/dist/chunk-MEFB5KHA.js +0 -59
- package/dist/chunk-MEFB5KHA.js.map +0 -1
- package/dist/chunk-MPZUYCAP.js.map +0 -1
- package/dist/chunk-NDGZDTSJ.js.map +0 -1
- package/dist/chunk-OJNTCYQQ.js.map +0 -1
- package/dist/chunk-P3LFTKE7.js +0 -58
- package/dist/chunk-P3LFTKE7.js.map +0 -1
- package/dist/chunk-QXP3Z3JN.js.map +0 -1
- package/dist/chunk-RVPYTUP4.js.map +0 -1
- package/dist/chunk-SNNSAGMT.js.map +0 -1
- package/dist/chunk-TC2WZLSC.js.map +0 -1
- package/dist/chunk-TKPF35W6.js +0 -29
- package/dist/chunk-TKPF35W6.js.map +0 -1
- package/dist/chunk-U3IKUGRP.js.map +0 -1
- package/dist/chunk-UUGOUOVT.js.map +0 -1
- package/dist/chunk-UXZONNEQ.js.map +0 -1
- package/dist/chunk-WXA2BWTE.js.map +0 -1
- package/dist/chunk-WYXUQGOL.js.map +0 -1
- package/dist/chunk-X5ZBP3IY.js.map +0 -1
- package/dist/chunk-XKESD27X.js +0 -10
- package/dist/chunk-XKESD27X.js.map +0 -1
- package/dist/chunk-XQJXNMSB.js.map +0 -1
- package/dist/chunk-Y527D4TV.js +0 -56
- package/dist/chunk-Y527D4TV.js.map +0 -1
- package/dist/chunk-ZDZERB6L.js.map +0 -1
- package/dist/chunk-ZNNXRNFD.js.map +0 -1
- package/dist/chunk-ZURZHELF.js.map +0 -1
- package/dist/cli-E36SPKBW.js.map +0 -1
- package/dist/codex-install-HQZDGFXW.js.map +0 -1
- package/dist/config-HY2E4GGW.js +0 -55
- package/dist/doctor-I6XQEKWD.js.map +0 -1
- package/dist/fund-2QRO7OJL.js +0 -378
- package/dist/fund-2QRO7OJL.js.map +0 -1
- package/dist/hook-command-2UBCSZG6.js +0 -43
- package/dist/install-ILUX5C4A.js +0 -107
- package/dist/install-identity-TZKGY6LQ.js +0 -31
- package/dist/install-wallet-5M4OTYLX.js.map +0 -1
- package/dist/mcp-LE4DUS22.js +0 -14127
- package/dist/mcp-LE4DUS22.js.map +0 -1
- package/dist/pay-WCG3IH4R.js +0 -55
- package/dist/payments-HFPPWHTV.js.map +0 -1
- package/dist/plugin-registration-PZFI5GZW.js +0 -68
- package/dist/runtime-UZOKSUZX.js +0 -1321
- package/dist/runtime-UZOKSUZX.js.map +0 -1
- package/dist/send-GCVEAQKL.js.map +0 -1
- package/dist/status-HCVAOCN7.js +0 -150
- package/dist/status-HCVAOCN7.js.map +0 -1
- package/dist/status-line-OPCXDHL2.js.map +0 -1
- package/dist/uninstall-BAWRBXXQ.js.map +0 -1
- package/dist/update-CACXLQLR.js +0 -56
- package/dist/wallet-QL4UUXEZ.js +0 -55
- /package/dist/{_esm-BIN7VY2L.js.map → _esm-2KST7HQ7.js.map} +0 -0
- /package/dist/{alive-GSOWKUOY.js.map → alive-5TV22PNF.js.map} +0 -0
- /package/dist/{auto-update-Y24UL56V.js.map → auth-XI7BJFLW.js.map} +0 -0
- /package/dist/{ccip-DHDFKTQV.js.map → auto-update-7L24KDWA.js.map} +0 -0
- /package/dist/{clack-EZ7TDWQU.js.map → balance-DFHC6XEU.js.map} +0 -0
- /package/dist/{claude-cli-2YKABJJZ.js.map → ccip-HOW3DZYF.js.map} +0 -0
- /package/dist/{chunk-IE7P2BZE.js.map → chunk-6QMDUDF2.js.map} +0 -0
- /package/dist/{chunk-KG3D7FIF.js.map → chunk-CZJOMUBP.js.map} +0 -0
- /package/dist/{chunk-3GNJXKIT.js.map → chunk-F43CV6UC.js.map} +0 -0
- /package/dist/{chunk-J57UC3DD.js.map → chunk-FKVJKLPI.js.map} +0 -0
- /package/dist/{chunk-SO3XRZPX.js.map → chunk-HPRVFJPM.js.map} +0 -0
- /package/dist/{chunk-2GP3HRYK.js.map → chunk-INSIW65E.js.map} +0 -0
- /package/dist/{chunk-RL5UUDT4.js.map → chunk-JNUKLSMZ.js.map} +0 -0
- /package/dist/{chunk-JRGFKVAZ.js.map → chunk-PETQ5WEA.js.map} +0 -0
- /package/dist/{codex-event-ZO2GEFE6.js.map → chunk-TUCKEEXE.js.map} +0 -0
- /package/dist/{chunk-BPMWXTFX.js.map → chunk-WFZX352D.js.map} +0 -0
- /package/dist/{chunk-6CMM6YCB.js.map → chunk-YWWMISDY.js.map} +0 -0
- /package/dist/{codex-host-KECJVTA2.js.map → clack-Q4RNC5VE.js.map} +0 -0
- /package/dist/{config-HY2E4GGW.js.map → claude-cli-GIIHOBGT.js.map} +0 -0
- /package/dist/{env-proxy-R6ZMLQTT.js.map → claude-install-BAUSJMW3.js.map} +0 -0
- /package/dist/{ethersCompat-Df4a6QIZ-X6YZWAML.js.map → codex-event-EUTCAOTQ.js.map} +0 -0
- /package/dist/{hook-command-2UBCSZG6.js.map → codex-host-ZON3S6HU.js.map} +0 -0
- /package/dist/{hosts-DVQJ32QC.js.map → config-QZOBMTEL.js.map} +0 -0
- /package/dist/{install-ILUX5C4A.js.map → config-rules-YOYHS6YL.js.map} +0 -0
- /package/dist/{install-identity-TZKGY6LQ.js.map → decision-QSKHOGCO.js.map} +0 -0
- /package/dist/{package-IJFGMWEV.js.map → env-proxy-XLSLHBKQ.js.map} +0 -0
- /package/dist/{passphrase-IFTDS3CU.js.map → ethersCompat-Df4a6QIZ-K3DMHR6Y.js.map} +0 -0
- /package/dist/{paths-XCSAKISU.js.map → flush-stdio-NYIJ3QXT.js.map} +0 -0
- /package/dist/{pay-WCG3IH4R.js.map → hook-command-VZ27MGWO.js.map} +0 -0
- /package/dist/{plugin-registration-PZFI5GZW.js.map → hosts-3EMTVM4H.js.map} +0 -0
- /package/dist/{redact-D7ASVWKL.js.map → install-ZA7L2UF3.js.map} +0 -0
- /package/dist/{runtime-fetch-ZSSSK72Y.js.map → install-funding-JDGYTF72.js.map} +0 -0
- /package/dist/{runtime-layout-WIDILZ6K.js.map → install-identity-FFAYEFLX.js.map} +0 -0
- /package/dist/{secp256k1-ZZZT2CAX.js.map → new-install-5L4GY3LN.js.map} +0 -0
- /package/dist/{update-CACXLQLR.js.map → package-BONDXSV3.js.map} +0 -0
- /package/dist/{usdc-VG4CIOUK.js.map → passphrase-T4ULBN4M.js.map} +0 -0
- /package/dist/{viemAdapter-By13KInL-DOFTEIJV.js.map → paths-O2KDWZ76.js.map} +0 -0
- /package/dist/{wallet-QL4UUXEZ.js.map → pay-CMV5KL74.js.map} +0 -0
|
@@ -1,6 +1,27 @@
|
|
|
1
|
-
import type { EngineInterface, Register } from 'claude-code';
|
|
1
|
+
import type { EngineInterface, Register, ToolCallResult } from 'claude-code';
|
|
2
|
+
import {
|
|
3
|
+
asRecord,
|
|
4
|
+
HELD_NOT_STARTED,
|
|
5
|
+
HELD_WITH_OFFER,
|
|
6
|
+
keepDelegatedHint,
|
|
7
|
+
parseJson,
|
|
8
|
+
readJson,
|
|
9
|
+
tenjinDataDir,
|
|
10
|
+
textOf,
|
|
11
|
+
} from './hook-data';
|
|
2
12
|
|
|
3
13
|
import type { TenjinHeld, TenjinRow } from '../types';
|
|
14
|
+
import {
|
|
15
|
+
keptNative,
|
|
16
|
+
modelStep,
|
|
17
|
+
raisedByThisPlugin,
|
|
18
|
+
registerModelViewer,
|
|
19
|
+
rememberModelOffer,
|
|
20
|
+
watchContinuation,
|
|
21
|
+
sessionLives,
|
|
22
|
+
translateViewerContinuation,
|
|
23
|
+
VIEWER_TYPE,
|
|
24
|
+
} from './model-viewer';
|
|
4
25
|
|
|
5
26
|
/**
|
|
6
27
|
* THE TENJIN MOD: one line per paid lookup, drawn from documented props only.
|
|
@@ -13,6 +34,12 @@ import type { TenjinHeld, TenjinRow } from '../types';
|
|
|
13
34
|
* - A LOOKUP THAT REPLACED A NATIVE CALL draws where that call stood:
|
|
14
35
|
* `⏺ ~~Web Search~~("q") · Tenjin offered Exa search` while held, then in
|
|
15
36
|
* place `⏺ Exa search("q") · $0.007`, the dot carrying the state.
|
|
37
|
+
* - A LOOKUP RUN IN A NATIVE CALL'S PLACE (the swap, only when the user turned
|
|
38
|
+
* on "Run Tenjin's picks automatically") draws on that call's row:
|
|
39
|
+
* `⏺ Calling Exa search… · $0.007`, then `⏺ Exa search("q") · $0.007`, with
|
|
40
|
+
* `in place of Web Search` under it, and one transcript line says so.
|
|
41
|
+
* - AN OFFER MADE ON THE PROMPT is one dim line under the prompt row,
|
|
42
|
+
* `⎿ Tenjin offered Exa search`, the engine's own row drawn above it.
|
|
16
43
|
*
|
|
17
44
|
* An over-limit answer draws nothing, and the `approve` call that runs its
|
|
18
45
|
* quote draws as the lookup's own row. A free lookup the CLI named draws the
|
|
@@ -26,10 +53,12 @@ import type { TenjinHeld, TenjinRow } from '../types';
|
|
|
26
53
|
* here included. Its title there is the tool's static one. A row of a run
|
|
27
54
|
* this mod unfolded in the normal view stays compact.
|
|
28
55
|
*
|
|
29
|
-
* READ ONLY: the spec file, the choice set, the free label
|
|
30
|
-
*
|
|
31
|
-
* The mod writes nothing under the data dir
|
|
32
|
-
* or payment
|
|
56
|
+
* READ ONLY: the spec file, the choice set, the free label, the offer record
|
|
57
|
+
* and the automatic-use switch in the config (`src/router/mod-state.ts`), and
|
|
58
|
+
* the request tool's own envelope. The mod writes nothing under the data dir
|
|
59
|
+
* and decides nothing about routing or payment: with the switch on it asks the
|
|
60
|
+
* request tool's `decide` form, which decides, checks and runs everything, and
|
|
61
|
+
* the mod only answers the native call with what came back.
|
|
33
62
|
*/
|
|
34
63
|
|
|
35
64
|
const REQUEST_TOOL = 'mcp__plugin_tenjin_router__request';
|
|
@@ -37,13 +66,16 @@ const REQUEST_TOOL = 'mcp__plugin_tenjin_router__request';
|
|
|
37
66
|
const APPROVE_TOOL = 'mcp__plugin_tenjin_router__approve';
|
|
38
67
|
const OURS = new Set([REQUEST_TOOL, APPROVE_TOOL]);
|
|
39
68
|
/** The native tools a hook holds, by the names the engine draws them under. */
|
|
40
|
-
const NATIVE_NAMES:
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
};
|
|
69
|
+
const NATIVE_NAMES = { WebSearch: 'Web Search', WebFetch: 'Fetch' } as const;
|
|
70
|
+
type NativeTool = keyof typeof NATIVE_NAMES;
|
|
71
|
+
const isNative = (tool: string): tool is NativeTool => tool in NATIVE_NAMES;
|
|
44
72
|
const ROWS = { plugin: 'tenjin', key: 'rows' } as const;
|
|
45
73
|
const HELD = { plugin: 'tenjin', key: 'held' } as const;
|
|
46
74
|
const LINKS = { plugin: 'tenjin', key: 'links' } as const;
|
|
75
|
+
const PROMPTS = { plugin: 'tenjin', key: 'prompts' } as const;
|
|
76
|
+
const LAST_TURN_START = { plugin: 'tenjin', key: 'lastTurnStart' } as const;
|
|
77
|
+
/** Names a surface gives a lookup with no label of its own; never an offer's. */
|
|
78
|
+
const FALLBACK_LABELS = new Set(['Tenjin', 'Tenjin lookup']);
|
|
47
79
|
/**
|
|
48
80
|
* Calls of a run the ENGINE expanded (ctrl+o, --verbose), where our rows step
|
|
49
81
|
* aside for the engine's own. The module's own memory, not `$.state`: a drawing may
|
|
@@ -66,7 +98,7 @@ const SECRET_NAME = /(api[_-]?key|token|secret|passw|authorization|cookie|privat
|
|
|
66
98
|
const HIDDEN = new Set(['spec', 'discovered', 'native', 'browse', 'needs_input', 'needs_approval']);
|
|
67
99
|
/** Endings drawn with no state word. */
|
|
68
100
|
const PLAIN = new Set(['fulfilled', 'running']);
|
|
69
|
-
const ERRORS = new Set(['failed', 'interrupted', 'partial']);
|
|
101
|
+
const ERRORS = new Set(['failed', 'interrupted', 'partial', 'refused']);
|
|
70
102
|
/** What the price slot says for a lookup that costs nothing. */
|
|
71
103
|
const FREE = 'free';
|
|
72
104
|
|
|
@@ -80,8 +112,162 @@ type Shape = {
|
|
|
80
112
|
};
|
|
81
113
|
type Elements = ReturnType<Dollar['ui']['resolve']>;
|
|
82
114
|
|
|
115
|
+
/**
|
|
116
|
+
* A DEEPSEEK WORKER GETS THE HOOK EVENTS A NATIVE SUBAGENT GETS. A native subagent fires
|
|
117
|
+
* no `SessionStart` when it starts or resumes and no `UserPromptSubmit` for its prompts,
|
|
118
|
+
* so in a worker's process those two events end here, above the person's settings hooks
|
|
119
|
+
* and the plugins' command hooks: none of them runs, and no context they add reaches the
|
|
120
|
+
* worker. A compaction's `SessionStart` still runs, as it does in a native subagent, and
|
|
121
|
+
* so does every other event (`PreToolUse`, `PostToolUse`, `PermissionRequest`, `Stop`
|
|
122
|
+
* and the rest), untouched. Managed settings hooks sit above every mod and still run.
|
|
123
|
+
* Where the worker flag cannot be read, the event runs as before.
|
|
124
|
+
*/
|
|
125
|
+
async function inWorker($: Dollar): Promise<boolean> {
|
|
126
|
+
return (await $.env.get('TENJIN_MODEL_WORKER').catch(() => undefined)) === '1';
|
|
127
|
+
}
|
|
128
|
+
|
|
83
129
|
export const register: Register = (on) => {
|
|
130
|
+
on('classic.PreToolUse', async ($, e, next) => {
|
|
131
|
+
const input: Json = { ...e };
|
|
132
|
+
delete input.tool;
|
|
133
|
+
delete input.tool_use_id;
|
|
134
|
+
return keepDelegatedHint($, e.tool, input, await next(e));
|
|
135
|
+
});
|
|
136
|
+
on('classic.SessionStart', async ($, e, next) =>
|
|
137
|
+
(e.source === 'startup' || e.source === 'resume') && (await inWorker($)) ? {} : next(e),
|
|
138
|
+
);
|
|
139
|
+
on('classic.UserPromptSubmit', async ($, e, next) => ((await inWorker($)) ? {} : next(e)));
|
|
140
|
+
registerModelViewer(on);
|
|
141
|
+
on('tool.describe', { tool: ['Agent', 'Task'] }, async ($, e, next) => {
|
|
142
|
+
const data = await tenjinDataDir($);
|
|
143
|
+
const router = data ? asRecord((await readJson($, `${data}/config.json`))?.router) : undefined;
|
|
144
|
+
if (router?.subagents !== true) return next(e);
|
|
145
|
+
return {
|
|
146
|
+
description: `${e.description}\n\nCopy complete assignments verbatim, including the final line, literal commands and output format. Add only missing known context. Preserve all binding details, actors and scope; never truncate. Add no model/routing advice. Compare the full assignment with the source before calling.`,
|
|
147
|
+
};
|
|
148
|
+
});
|
|
149
|
+
on('tool.call', { tool: ['Agent', 'Task', 'SendMessage'] }, async ($, e, next) => {
|
|
150
|
+
// THE PLUGIN'S OWN AGENT IS NOT THE PARENT'S CALL. The host raises this mod's start of
|
|
151
|
+
// the worker's viewer agent as an Agent call too (seen live: a no-offer record,
|
|
152
|
+
// `input_filter:run_in_background`, at the second of every accept). It is never
|
|
153
|
+
// judged, offered or recorded: told by who raised it, and by its type.
|
|
154
|
+
if (raisedByThisPlugin(next.origin) || (e as Json).subagent_type === VIEWER_TYPE)
|
|
155
|
+
return next(e);
|
|
156
|
+
const { tool_use_id, ...raw } = e;
|
|
157
|
+
delete (raw as Json).tool;
|
|
158
|
+
// A NATIVE SUBAGENT'S CALL IS JUDGED AS THE MAIN LOOP'S, at any depth. The host
|
|
159
|
+
// adds the id of the loop that made a call to its event; that is no field of the
|
|
160
|
+
// call, so it leaves the input and goes as `agent`, the loop that gets the offer.
|
|
161
|
+
delete (raw as Json).agentId;
|
|
162
|
+
const translated = await translateViewerContinuation($, e.tool, raw);
|
|
163
|
+
const input = translated.input;
|
|
164
|
+
const owned = translated.owned || ownedContinuationAddress(input, e.tool);
|
|
165
|
+
const unavailable = () =>
|
|
166
|
+
heldAnswer(
|
|
167
|
+
e.tool,
|
|
168
|
+
'Tenjin continuation is unavailable. No continuation started. Do not retry this owned handle through native tools.',
|
|
169
|
+
);
|
|
170
|
+
if (translated.unavailable) return unavailable();
|
|
171
|
+
if (e.tool === 'SendMessage' && !owned) return next(e);
|
|
172
|
+
try {
|
|
173
|
+
const data = await tenjinDataDir($);
|
|
174
|
+
const router = data
|
|
175
|
+
? asRecord((await readJson($, `${data}/config.json`))?.router)
|
|
176
|
+
: undefined;
|
|
177
|
+
if (router?.subagents !== true || (await $.env.get('TENJIN_MODEL_WORKER')) === '1')
|
|
178
|
+
return owned ? unavailable() : next(e);
|
|
179
|
+
// A held call is never rewritten: the parent keeps it native by sending it
|
|
180
|
+
// again unchanged, and that repeat runs here as it was reviewed. The model
|
|
181
|
+
// request that made it tells that repeat from a second call of one response.
|
|
182
|
+
const step = modelStep(e.agentId);
|
|
183
|
+
const agent = e.agentId === undefined ? undefined : await callerOf($, e.agentId);
|
|
184
|
+
const response = await $.tool.call({
|
|
185
|
+
tool: 'mcp__plugin_tenjin_router__subagent',
|
|
186
|
+
capture: {
|
|
187
|
+
session_id: await $.session.id(),
|
|
188
|
+
tool_use_id,
|
|
189
|
+
input,
|
|
190
|
+
tool: e.tool,
|
|
191
|
+
...(step !== undefined ? { step } : {}),
|
|
192
|
+
...(agent !== undefined ? { agent } : {}),
|
|
193
|
+
},
|
|
194
|
+
});
|
|
195
|
+
const text = textOf(response.result) ?? response.text;
|
|
196
|
+
const offer = asRecord(parseJson(text));
|
|
197
|
+
if (offer?.action === 'native') await keptNative($, offer.settled);
|
|
198
|
+
// A MESSAGE THE WORKER TOOK is answered as a native send is: the call ran and succeeded.
|
|
199
|
+
// `delivered`: to a worker that runs, at its next turn. `continued`: a finished worker,
|
|
200
|
+
// resumed by the message, whose result arrives by itself as a background agent's does.
|
|
201
|
+
if (
|
|
202
|
+
e.tool === 'SendMessage' &&
|
|
203
|
+
(offer?.action === 'delivered' || offer?.action === 'continued') &&
|
|
204
|
+
typeof offer.message === 'string' &&
|
|
205
|
+
offer.message.trim().length > 0 &&
|
|
206
|
+
offer.message.length <= 2000
|
|
207
|
+
) {
|
|
208
|
+
if (
|
|
209
|
+
offer.action === 'continued' &&
|
|
210
|
+
typeof offer.offer_id === 'string' &&
|
|
211
|
+
/^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(
|
|
212
|
+
offer.offer_id,
|
|
213
|
+
)
|
|
214
|
+
) {
|
|
215
|
+
const offerId = offer.offer_id;
|
|
216
|
+
await rememberModelOffer($, offerId, { ...input, run_in_background: true }).catch(
|
|
217
|
+
() => undefined,
|
|
218
|
+
);
|
|
219
|
+
// THE FOLLOW-UP IS AN ACCEPTED JOB, so it has what one has: its agent-list entry with
|
|
220
|
+
// the activity and the stop control, tied to the calling agent, and its result handed
|
|
221
|
+
// over once it ends. The accept hook does not see it, so it is set up here.
|
|
222
|
+
await watchContinuation($, offerId, e.agentId).catch(() => undefined);
|
|
223
|
+
}
|
|
224
|
+
return { result: { success: true, message: offer.message } };
|
|
225
|
+
}
|
|
226
|
+
if (
|
|
227
|
+
offer?.action === 'refused' &&
|
|
228
|
+
offer.started === false &&
|
|
229
|
+
typeof offer.reason === 'string' &&
|
|
230
|
+
offer.reason.trim().length > 0 &&
|
|
231
|
+
offer.reason.length <= 4000 &&
|
|
232
|
+
typeof offer.instruction === 'string' &&
|
|
233
|
+
offer.instruction.trim().length > 0 &&
|
|
234
|
+
offer.instruction.length <= 4000
|
|
235
|
+
)
|
|
236
|
+
return heldAnswer(
|
|
237
|
+
e.tool,
|
|
238
|
+
JSON.stringify({
|
|
239
|
+
action: 'refused',
|
|
240
|
+
started: false,
|
|
241
|
+
reason: offer.reason,
|
|
242
|
+
instruction: offer.instruction,
|
|
243
|
+
}),
|
|
244
|
+
);
|
|
245
|
+
if (
|
|
246
|
+
offer?.action === 'offer' &&
|
|
247
|
+
offer.started === false &&
|
|
248
|
+
typeof offer.offer_id === 'string' &&
|
|
249
|
+
/^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(
|
|
250
|
+
offer.offer_id,
|
|
251
|
+
)
|
|
252
|
+
) {
|
|
253
|
+
await rememberModelOffer($, offer.offer_id, input).catch(() => undefined);
|
|
254
|
+
// The handoff marks a follow-up to an owned worker, whichever tool carried it.
|
|
255
|
+
const continuation = offer.continuation === true || e.tool === 'SendMessage';
|
|
256
|
+
return heldAnswer(e.tool, text ?? JSON.stringify(offer), {
|
|
257
|
+
offer: offer.offer_id,
|
|
258
|
+
context: heldOfferContext(offer, continuation),
|
|
259
|
+
continuation,
|
|
260
|
+
});
|
|
261
|
+
}
|
|
262
|
+
} catch {
|
|
263
|
+
/* An owned handle must never reach a native executor, including on local failure. */
|
|
264
|
+
}
|
|
265
|
+
return owned ? unavailable() : next(e);
|
|
266
|
+
});
|
|
267
|
+
|
|
84
268
|
on('tool.call', { tool: REQUEST_TOOL }, async ($, e, next) => {
|
|
269
|
+
// The swap's own `decide` call is drawn on the native call's row.
|
|
270
|
+
if (e.decide !== undefined) return next(e);
|
|
85
271
|
const row = await describeCall($, e);
|
|
86
272
|
const ref = { ...ROWS, id: e.tool_use_id };
|
|
87
273
|
if (row !== null) {
|
|
@@ -137,7 +323,10 @@ export const register: Register = (on) => {
|
|
|
137
323
|
|
|
138
324
|
// A native call the router held: its offer, from the CLI's record. One the
|
|
139
325
|
// router let run, for a held call with the same search to give way to.
|
|
326
|
+
// FIRST, with automatic use on, the swap: answered in place, or passed on.
|
|
140
327
|
on('tool.call', { tool: ['WebSearch', 'WebFetch'] }, async ($, e, next) => {
|
|
328
|
+
const swapped = await swap($, e);
|
|
329
|
+
if (swapped !== null) return swapped;
|
|
141
330
|
const ran = await next(e);
|
|
142
331
|
const key = nativeKey(e.tool, e);
|
|
143
332
|
const held = await offerRecord($, e.tool_use_id, key);
|
|
@@ -151,6 +340,50 @@ export const register: Register = (on) => {
|
|
|
151
340
|
return ran;
|
|
152
341
|
});
|
|
153
342
|
|
|
343
|
+
// The CLI's prompt hook keeps the record before this existing turn surface.
|
|
344
|
+
on('turn.start', async ($, e, next) => {
|
|
345
|
+
sessionLives();
|
|
346
|
+
if (e.agentId === undefined) {
|
|
347
|
+
const now = await $.clock.now();
|
|
348
|
+
const previous = (await $.state.get(LAST_TURN_START)).value;
|
|
349
|
+
if (e.text.length > 0) {
|
|
350
|
+
const record = await offerFile($, `prompt:${e.text}`);
|
|
351
|
+
const label = labelOf(record?.label);
|
|
352
|
+
const hash = await sha256Hex(e.text);
|
|
353
|
+
const offered =
|
|
354
|
+
label !== undefined &&
|
|
355
|
+
!FALLBACK_LABELS.has(label) &&
|
|
356
|
+
record?.priceAtomic !== '0' &&
|
|
357
|
+
typeof record?.at === 'number' &&
|
|
358
|
+
(typeof previous !== 'number' || record.at > previous) &&
|
|
359
|
+
record.at <= now;
|
|
360
|
+
const ref = { ...PROMPTS, id: hash };
|
|
361
|
+
if (offered || (await $.state.get(ref)).value) {
|
|
362
|
+
await $.state.set(ref, offered ? label : '');
|
|
363
|
+
$.ui.invalidate('ui.render');
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
await $.state.set(LAST_TURN_START, now);
|
|
367
|
+
}
|
|
368
|
+
return next(e);
|
|
369
|
+
});
|
|
370
|
+
|
|
371
|
+
// The prompt row as the engine draws it, the offer one dim line beneath.
|
|
372
|
+
on('ui.render', { component: 'UserMessage' }, async ($, e, next) => {
|
|
373
|
+
const { text, task, from } = e.props;
|
|
374
|
+
if (task !== undefined || from !== undefined) return next(e);
|
|
375
|
+
const { value: label } = await $.state.get({ ...PROMPTS, id: await sha256Hex(text) });
|
|
376
|
+
if (label === undefined || label === '') return next(e);
|
|
377
|
+
const own = await next(e);
|
|
378
|
+
const { Box, Text } = $.ui.resolve(e);
|
|
379
|
+
return (
|
|
380
|
+
<Box flexDirection="column">
|
|
381
|
+
{own}
|
|
382
|
+
<Text dimColor wrap="truncate-end">{`${GUTTER}Tenjin offered ${label}`}</Text>
|
|
383
|
+
</Box>
|
|
384
|
+
);
|
|
385
|
+
});
|
|
386
|
+
|
|
154
387
|
on('ui.render', { component: 'ToolGroup' }, async ($, e, next) => {
|
|
155
388
|
const { calls, isExpanded } = e.props;
|
|
156
389
|
const ids = calls.flatMap((c) => (c.tool_use_id !== undefined ? [c.tool_use_id] : []));
|
|
@@ -172,7 +405,7 @@ export const register: Register = (on) => {
|
|
|
172
405
|
const others = calls.filter((c) => !OURS.has(c.tool));
|
|
173
406
|
if (ours.length === 0) {
|
|
174
407
|
for (const c of others) {
|
|
175
|
-
if (c.tool
|
|
408
|
+
if (isNative(c.tool) && c.tool_use_id !== undefined) {
|
|
176
409
|
if ((await heldOf($, c.tool_use_id, nativeKey(c.tool, c.input))) !== null)
|
|
177
410
|
return unfold();
|
|
178
411
|
}
|
|
@@ -189,12 +422,13 @@ export const register: Register = (on) => {
|
|
|
189
422
|
|
|
190
423
|
on('ui.render', { component: 'ToolUse' }, async ($, e, next) => {
|
|
191
424
|
const { tool, tool_use_id, input, isInterrupted } = e.props;
|
|
192
|
-
if (tool
|
|
425
|
+
if (isNative(tool) && !isInterrupted) {
|
|
193
426
|
const key = nativeKey(tool, input);
|
|
194
427
|
const held = await heldOf($, tool_use_id, key);
|
|
195
428
|
if (held === null) return next(e);
|
|
196
429
|
const ui = $.ui.resolve(e);
|
|
197
430
|
const asked = nativeArgument(input);
|
|
431
|
+
if (held.swap === true) return swapRow(ui, tool, held, await row($, tool_use_id), asked);
|
|
198
432
|
const takerId = await link($, `take:${held.offerId}`);
|
|
199
433
|
const taker = takerId === undefined ? undefined : await row($, takerId);
|
|
200
434
|
if (
|
|
@@ -210,7 +444,7 @@ export const register: Register = (on) => {
|
|
|
210
444
|
const ran = await link($, `ran:${held.key}`);
|
|
211
445
|
if (ran !== undefined && ran !== tool_use_id) return <ui.Box display="none" />;
|
|
212
446
|
const offered = held.label !== undefined ? { tail: ` · Tenjin offered ${held.label}` } : {};
|
|
213
|
-
const name = NATIVE_NAMES[tool]
|
|
447
|
+
const name = NATIVE_NAMES[tool];
|
|
214
448
|
const argued = asked !== undefined ? { argument: asked } : {};
|
|
215
449
|
return line(ui, { state: 'running', name, ...offered, ...argued }, true);
|
|
216
450
|
}
|
|
@@ -242,12 +476,156 @@ export const register: Register = (on) => {
|
|
|
242
476
|
const unnamed = await unnamedCharge($, e.props.tool_use_id, e.props.output);
|
|
243
477
|
return unnamed ? next(e) : <Box display="none" />;
|
|
244
478
|
}
|
|
245
|
-
if (!(e.props.tool
|
|
479
|
+
if (!isNative(e.props.tool)) return next(e);
|
|
246
480
|
const held = await heldOf($, e.props.tool_use_id, undefined);
|
|
481
|
+
// A call answered in place shows its result wherever rows show in full.
|
|
482
|
+
if (held?.swap === true && e.props.isExpanded === true) return next(e);
|
|
247
483
|
return held === null ? next(e) : <Box display="none" />;
|
|
248
484
|
});
|
|
249
485
|
};
|
|
250
486
|
|
|
487
|
+
/** How often a native call being answered in place is redrawn, so its row
|
|
488
|
+
* names the pick once the CLI has recorded it. */
|
|
489
|
+
const SWAP_REDRAW_MS = 500;
|
|
490
|
+
|
|
491
|
+
/**
|
|
492
|
+
* THE SWAP, ONLY WHEN THE USER TURNED IT ON (`router.nativeReplacement:
|
|
493
|
+
* when-routed` in the global config the CLI writes): the request tool's
|
|
494
|
+
* `decide` form is asked about this native call before it runs. It answers
|
|
495
|
+
* with the lookup it ran in the call's place (`via: "swap"`), or hands the
|
|
496
|
+
* call back, and then null: the call takes the host's ordinary route. The mod
|
|
497
|
+
* builds no input, reads no hint and decides nothing; it only answers the
|
|
498
|
+
* native call with what came back. A fulfilled lookup is the native tool's
|
|
499
|
+
* own result shape carrying the request tool's whole text; anything else
|
|
500
|
+
* that ran is a refusal of the call carrying that text, so a failure is never
|
|
501
|
+
* read as a page or a search that worked, and nothing runs again natively.
|
|
502
|
+
*/
|
|
503
|
+
async function swap($: Dollar, e: Json): Promise<ToolCallResult | null> {
|
|
504
|
+
const tool = e.tool === 'WebSearch' || e.tool === 'WebFetch' ? e.tool : undefined;
|
|
505
|
+
if (tool === undefined || e.agentId !== undefined || typeof e.tool_use_id !== 'string') {
|
|
506
|
+
return null;
|
|
507
|
+
}
|
|
508
|
+
// A SEARCH LIMITED TO SOME DOMAINS keeps its own tool: the pick would not be.
|
|
509
|
+
if (hasEntries(e.allowed_domains) || hasEntries(e.blocked_domains)) return null;
|
|
510
|
+
const target = tool === 'WebSearch' ? e.query : e.url;
|
|
511
|
+
if (typeof target !== 'string' || target.length === 0) return null;
|
|
512
|
+
const dataDir = await tenjinDataDir($);
|
|
513
|
+
if (dataDir === null) return null;
|
|
514
|
+
const router = asRecord((await readJson($, `${dataDir}/config.json`))?.router);
|
|
515
|
+
if (router?.nativeReplacement !== 'when-routed' || router.enabled === false) return null;
|
|
516
|
+
const startedAt = await $.clock.now();
|
|
517
|
+
const redraw = $.clock.every(SWAP_REDRAW_MS, () => $.ui.invalidate('ui.render'));
|
|
518
|
+
let answer: ToolCallResult;
|
|
519
|
+
try {
|
|
520
|
+
answer = await $.tool.call({
|
|
521
|
+
tool: REQUEST_TOOL,
|
|
522
|
+
decide: {
|
|
523
|
+
tool,
|
|
524
|
+
input: tool === 'WebSearch' ? { query: target } : { url: target },
|
|
525
|
+
tool_use_id: e.tool_use_id,
|
|
526
|
+
session_id: await $.session.id(),
|
|
527
|
+
},
|
|
528
|
+
});
|
|
529
|
+
} catch {
|
|
530
|
+
return null;
|
|
531
|
+
} finally {
|
|
532
|
+
redraw.cancel();
|
|
533
|
+
}
|
|
534
|
+
const text = answer.text;
|
|
535
|
+
const envelope = envelopeOf(text);
|
|
536
|
+
if (text === undefined || envelope?.via !== 'swap') return null;
|
|
537
|
+
// THE LOOKUP RAN: from here the answer is its result, whatever the drawing
|
|
538
|
+
// makes of it, and the native call never runs as well. A connected account
|
|
539
|
+
// that refused before anything ran is drawn as refused, never as a lookup
|
|
540
|
+
// that ran; its words, and Tenjin's own tool, are the call's refusal.
|
|
541
|
+
const refused = asRecord(envelope.refused) !== undefined;
|
|
542
|
+
const ended = refused ? { ...endOf(envelope), status: 'refused' } : endOf(envelope);
|
|
543
|
+
await drawSwap($, e.tool_use_id, tool, e, ended, onAccount(envelope.cost)).catch(() => undefined);
|
|
544
|
+
const status = String(envelope.status);
|
|
545
|
+
if (status !== 'fulfilled' && status !== 'running') return { deny: text };
|
|
546
|
+
const elapsed = Math.max(0, (await $.clock.now().catch(() => startedAt)) - startedAt);
|
|
547
|
+
return tool === 'WebSearch'
|
|
548
|
+
? { result: { query: target, results: [text], durationSeconds: elapsed / 1000 } }
|
|
549
|
+
: {
|
|
550
|
+
result: {
|
|
551
|
+
url: target,
|
|
552
|
+
code: status === 'fulfilled' ? 200 : 202,
|
|
553
|
+
codeText: status === 'fulfilled' ? 'OK' : 'Accepted',
|
|
554
|
+
bytes: new TextEncoder().encode(text).length,
|
|
555
|
+
result: text,
|
|
556
|
+
durationMs: elapsed,
|
|
557
|
+
},
|
|
558
|
+
};
|
|
559
|
+
}
|
|
560
|
+
|
|
561
|
+
/** The row, its state and the one transcript line for a call answered in
|
|
562
|
+
* place. `account`: the user's own plan paid, which the row says. */
|
|
563
|
+
async function drawSwap(
|
|
564
|
+
$: Dollar,
|
|
565
|
+
id: string,
|
|
566
|
+
tool: 'WebSearch' | 'WebFetch',
|
|
567
|
+
e: Json,
|
|
568
|
+
ended: Partial<TenjinRow>,
|
|
569
|
+
account: boolean,
|
|
570
|
+
): Promise<void> {
|
|
571
|
+
const key = nativeKey(tool, e);
|
|
572
|
+
const held = await offerRecord($, id, key);
|
|
573
|
+
const label = ended.label ?? held?.label ?? 'Tenjin lookup';
|
|
574
|
+
const asked = nativeArgument(e);
|
|
575
|
+
const shown = held?.price ?? (account ? ACCOUNT_PRICE : undefined);
|
|
576
|
+
const price = shown !== undefined ? { price: shown } : {};
|
|
577
|
+
await $.state.set(
|
|
578
|
+
{ ...HELD, id },
|
|
579
|
+
{ offerId: held?.offerId ?? id, key: key ?? '', label, swap: true, ...price },
|
|
580
|
+
);
|
|
581
|
+
await $.state.set(
|
|
582
|
+
{ ...ROWS, id },
|
|
583
|
+
{ ...price, ...ended, label, ...(asked !== undefined ? { argument: asked } : {}) },
|
|
584
|
+
);
|
|
585
|
+
const native = NATIVE_NAMES[tool];
|
|
586
|
+
const cost = ended.paid ?? shown;
|
|
587
|
+
$.ui.log(
|
|
588
|
+
ended.status === 'refused'
|
|
589
|
+
? `Your account refused ${label}, so ${native} did not run`
|
|
590
|
+
: `Tenjin ran ${label} in place of ${native}${cost !== undefined ? ` · ${cost}` : ''}`,
|
|
591
|
+
);
|
|
592
|
+
$.ui.invalidate('ui.render');
|
|
593
|
+
}
|
|
594
|
+
|
|
595
|
+
/** What a row says a call on the user's own account cost: their plan paid it. */
|
|
596
|
+
const ACCOUNT_PRICE = 'your account';
|
|
597
|
+
|
|
598
|
+
/** A cost line saying the user's own account was billed, not the balance. */
|
|
599
|
+
function onAccount(cost: unknown): boolean {
|
|
600
|
+
return Array.isArray(cost) && /^billed to your .+ account\b/.test(String(cost[0]));
|
|
601
|
+
}
|
|
602
|
+
|
|
603
|
+
function hasEntries(value: unknown): boolean {
|
|
604
|
+
return Array.isArray(value) && value.length > 0;
|
|
605
|
+
}
|
|
606
|
+
|
|
607
|
+
/** A native call answered in place: the pick's own row where the call stood,
|
|
608
|
+
* and the one line saying what did not run. */
|
|
609
|
+
function swapRow(
|
|
610
|
+
ui: Elements,
|
|
611
|
+
tool: NativeTool,
|
|
612
|
+
held: TenjinHeld,
|
|
613
|
+
ended: TenjinRow | undefined,
|
|
614
|
+
asked: string | undefined,
|
|
615
|
+
) {
|
|
616
|
+
const name = ended?.label ?? held.label ?? NATIVE_NAMES[tool];
|
|
617
|
+
const shape: Shape =
|
|
618
|
+
ended?.status !== undefined
|
|
619
|
+
? { ...shapeOf(ended), name }
|
|
620
|
+
: {
|
|
621
|
+
state: 'running',
|
|
622
|
+
name: `Calling ${name}…`,
|
|
623
|
+
...(held.price !== undefined ? { tail: ` · ${held.price}` } : {}),
|
|
624
|
+
};
|
|
625
|
+
const head = line(ui, asked !== undefined ? { ...shape, argument: asked } : shape);
|
|
626
|
+
return block(ui, head, [`in place of ${NATIVE_NAMES[tool]}`]);
|
|
627
|
+
}
|
|
628
|
+
|
|
251
629
|
/** A call before it runs: `{id, input}` with a kept spec, `{id, choice,
|
|
252
630
|
* input}` with the choice set kept beside the line's id, or a free `{id,
|
|
253
631
|
* query}` whose name the CLI kept. Null for the router's own calls. */
|
|
@@ -302,8 +680,11 @@ async function describeFree(
|
|
|
302
680
|
};
|
|
303
681
|
}
|
|
304
682
|
|
|
305
|
-
/** What the specs cost together, `takes` times each: `$0.04`, or `up to $0.05`.
|
|
683
|
+
/** What the specs cost together, `takes` times each: `$0.04`, or `up to $0.05`.
|
|
684
|
+
* A service on the user's own account costs the balance nothing: its own
|
|
685
|
+
* plan pays, and the row says so. */
|
|
306
686
|
function priced(specs: (Json | null)[], takes: bigint): { price?: string } {
|
|
687
|
+
if (specs.length === 1 && asRecord(specs[0]?.mcp) !== undefined) return { price: ACCOUNT_PRICE };
|
|
307
688
|
let total = 0n;
|
|
308
689
|
let varies = false;
|
|
309
690
|
for (const spec of specs) {
|
|
@@ -356,13 +737,27 @@ async function rowOf(
|
|
|
356
737
|
): Promise<TenjinRow | null> {
|
|
357
738
|
const stored = await row($, id);
|
|
358
739
|
// A JOB POLL repeats the result and the cost of the call that started it.
|
|
359
|
-
|
|
740
|
+
// and the swap's `decide` call is drawn on the native call's own row.
|
|
741
|
+
const input = asRecord(call.input);
|
|
742
|
+
if (isJobPoll(input) || input?.decide !== undefined) return null;
|
|
360
743
|
const envelope = envelopeOf(textOf(call.output));
|
|
361
744
|
const ended =
|
|
362
745
|
envelope !== undefined ? endOf(envelope) : call.isInterrupted ? { status: 'interrupted' } : {};
|
|
363
746
|
const label = stored?.label ?? ended.label;
|
|
364
747
|
if (label === undefined) return null;
|
|
365
|
-
|
|
748
|
+
// A selected free call has no kept offer to supply its price before it runs.
|
|
749
|
+
const selectedFree =
|
|
750
|
+
typeof input?.tool === 'string' &&
|
|
751
|
+
typeof input.query === 'string' &&
|
|
752
|
+
envelope?.status === 'fulfilled' &&
|
|
753
|
+
labelOf(envelope.label) !== undefined &&
|
|
754
|
+
costAtomicOf(envelope.cost) === 0n;
|
|
755
|
+
const drawn: TenjinRow = {
|
|
756
|
+
...stored,
|
|
757
|
+
...ended,
|
|
758
|
+
...(selectedFree ? priceOf(0n, false) : {}),
|
|
759
|
+
label,
|
|
760
|
+
};
|
|
366
761
|
if (drawn.status !== undefined && HIDDEN.has(drawn.status)) return null;
|
|
367
762
|
if (
|
|
368
763
|
drawn.status !== undefined &&
|
|
@@ -466,16 +861,27 @@ async function offerRecord(
|
|
|
466
861
|
id: string,
|
|
467
862
|
key: string | undefined,
|
|
468
863
|
): Promise<TenjinHeld | null> {
|
|
864
|
+
const record = await offerFile($, id);
|
|
865
|
+
if (record === null) return null;
|
|
866
|
+
const label = labelOf(record.label);
|
|
867
|
+
const price = atomicOf(record.priceAtomic);
|
|
868
|
+
return {
|
|
869
|
+
offerId: record.offerId as string,
|
|
870
|
+
key: key ?? '',
|
|
871
|
+
...(label !== undefined ? { label } : {}),
|
|
872
|
+
...(record.swap === true ? { swap: true as const } : {}),
|
|
873
|
+
...(price !== undefined ? { price: `$${usd(BigInt(price))}` } : {}),
|
|
874
|
+
};
|
|
875
|
+
}
|
|
876
|
+
|
|
877
|
+
/** The CLI's offer record under `id`, of a version this mod reads; else null. */
|
|
878
|
+
async function offerFile($: Dollar, id: string): Promise<Json | null> {
|
|
469
879
|
const dataDir = await tenjinDataDir($);
|
|
470
880
|
if (dataDir === null) return null;
|
|
471
881
|
const session = await sha256Hex(await $.session.id());
|
|
472
|
-
const
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
);
|
|
476
|
-
if (record?.version !== 1 || typeof record.offerId !== 'string') return null;
|
|
477
|
-
const label = labelOf(record.label);
|
|
478
|
-
return { offerId: record.offerId, key: key ?? '', ...(label !== undefined ? { label } : {}) };
|
|
882
|
+
const path = `${dataDir}/progress/${session}/offer-${await sha256Hex(id)}.json`;
|
|
883
|
+
const record = await readJson($, path);
|
|
884
|
+
return record?.version === 1 && typeof record.offerId === 'string' ? record : null;
|
|
479
885
|
}
|
|
480
886
|
|
|
481
887
|
const row = async ($: Dollar, id: string) => (await $.state.get({ ...ROWS, id })).value;
|
|
@@ -555,11 +961,15 @@ async function unnamedCharge($: Dollar, id: string, output: unknown): Promise<bo
|
|
|
555
961
|
|
|
556
962
|
/** What the envelope's `cost` (`provider price 0.04 USD`) says left the wallet. */
|
|
557
963
|
function paidOf(cost: unknown): string | undefined {
|
|
964
|
+
const atomic = costAtomicOf(cost);
|
|
965
|
+
return atomic === undefined || atomic === 0n ? undefined : `$${usd(atomic)}`;
|
|
966
|
+
}
|
|
967
|
+
|
|
968
|
+
function costAtomicOf(cost: unknown): bigint | undefined {
|
|
558
969
|
const paid = Array.isArray(cost)
|
|
559
970
|
? /^provider price (\d+\.?\d*) USD$/.exec(String(cost[0]))
|
|
560
971
|
: null;
|
|
561
|
-
|
|
562
|
-
return atomic === 0n ? undefined : `$${usd(atomic)}`;
|
|
972
|
+
return paid === null ? undefined : BigInt(Math.round(Number(paid[1]) * 1e6));
|
|
563
973
|
}
|
|
564
974
|
|
|
565
975
|
/** The request tool's envelope: the JSON block whose `status` comes first. */
|
|
@@ -572,17 +982,6 @@ function envelopeOf(text: string | undefined): Json | undefined {
|
|
|
572
982
|
return undefined;
|
|
573
983
|
}
|
|
574
984
|
|
|
575
|
-
/** A stored result's text: a string, or MCP content blocks bare or in `content`. */
|
|
576
|
-
function textOf(output: unknown): string | undefined {
|
|
577
|
-
if (typeof output === 'string') return output;
|
|
578
|
-
const blocks = Array.isArray(output) ? output : asRecord(output)?.content;
|
|
579
|
-
if (!Array.isArray(blocks)) return undefined;
|
|
580
|
-
return blocks
|
|
581
|
-
.map((block) => asRecord(block)?.text)
|
|
582
|
-
.filter((text) => typeof text === 'string')
|
|
583
|
-
.join('');
|
|
584
|
-
}
|
|
585
|
-
|
|
586
985
|
/** USDC has 6 decimals; whole cents keep two. */
|
|
587
986
|
function usd(atomic: bigint): string {
|
|
588
987
|
const fraction = (atomic % 1_000_000n).toString().padStart(6, '0').replace(/0+$/, '');
|
|
@@ -593,34 +992,106 @@ function atomicOf(value: unknown): string | undefined {
|
|
|
593
992
|
return typeof value === 'string' && /^\d{1,30}$/.test(value) ? value : undefined;
|
|
594
993
|
}
|
|
595
994
|
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
995
|
+
/** Reserve address fields only; backend validation owns identity and follow-up semantics. */
|
|
996
|
+
function ownedContinuationAddress(input: Json, tool: string): boolean {
|
|
997
|
+
const addresses = tool === 'SendMessage' ? [input.to, input.recipient] : [input.resume];
|
|
998
|
+
return addresses
|
|
999
|
+
.flatMap((value) => (Array.isArray(value) ? value : [value]))
|
|
1000
|
+
.some((value) => typeof value === 'string' && /^tenjin-(worker|offer)-/i.test(value.trim()));
|
|
601
1001
|
}
|
|
602
1002
|
|
|
603
|
-
|
|
1003
|
+
/**
|
|
1004
|
+
* THE NATIVE SUBAGENT THAT MADE A CALL, as the host lists it: its id, the type it runs
|
|
1005
|
+
* as, the types of the agents above it (nearest first, '' for one no longer listed)
|
|
1006
|
+
* and the folder it works in. The CLI judges from these whether it can accept an offer
|
|
1007
|
+
* and whether a worker would run as its native child would. One the host does not list
|
|
1008
|
+
* goes by its id alone, and the CLI keeps its call native.
|
|
1009
|
+
*/
|
|
1010
|
+
async function callerOf($: Dollar, agentId: string): Promise<Json> {
|
|
604
1011
|
try {
|
|
605
|
-
|
|
1012
|
+
const agents = await $.agent.list();
|
|
1013
|
+
const own = agents.find((agent) => agent.id === agentId);
|
|
1014
|
+
if (!own) return { id: agentId };
|
|
1015
|
+
const parents: string[] = [];
|
|
1016
|
+
let above = own.parentId;
|
|
1017
|
+
while (above !== undefined) {
|
|
1018
|
+
const parent = parents.length < 16 ? agents.find((agent) => agent.id === above) : undefined;
|
|
1019
|
+
parents.push(parent?.type ?? '');
|
|
1020
|
+
above = parent?.parentId;
|
|
1021
|
+
}
|
|
1022
|
+
return { id: agentId, type: own.type, parents, cwd: own.cwd };
|
|
606
1023
|
} catch {
|
|
607
|
-
return
|
|
1024
|
+
return { id: agentId };
|
|
608
1025
|
}
|
|
609
1026
|
}
|
|
610
1027
|
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
1028
|
+
/**
|
|
1029
|
+
* A held call's answer. An Agent or Task call is refused, with the offer as the refusal's
|
|
1030
|
+
* text (`hook-data.ts` says why): the first line for a person, then what the parent is to
|
|
1031
|
+
* do with it, then what the hook would have added as context (a refusal carries none),
|
|
1032
|
+
* then the offer itself. A refusal reads as an error to a model, so the text says first
|
|
1033
|
+
* that nothing failed and names the only two moves; a parent that took a held call for a
|
|
1034
|
+
* failure once switched to another tool. THAT THE CALL WAS HELD AND DID NOT RUN IS SAID
|
|
1035
|
+
* HERE ONLY: the context line and the offer's instruction do not say it again.
|
|
1036
|
+
*/
|
|
1037
|
+
function heldAnswer(
|
|
1038
|
+
tool: string,
|
|
1039
|
+
offerText: string,
|
|
1040
|
+
held?: { offer: string; context: string[] | undefined; continuation?: boolean },
|
|
1041
|
+
) {
|
|
1042
|
+
// Native SendMessage refusals return this data shape; an offer is not a delivered message.
|
|
1043
|
+
if (tool === 'SendMessage')
|
|
1044
|
+
return {
|
|
1045
|
+
result: {
|
|
1046
|
+
success: false,
|
|
1047
|
+
// The statement of what happened comes first: the host shows a held call as a refusal.
|
|
1048
|
+
message: held
|
|
1049
|
+
? `Not delivered yet: the follow-up to the DeepSeek worker is held until you run it with subagent({offer_id}) or cancel it. ${offerText}`
|
|
1050
|
+
: offerText,
|
|
1051
|
+
},
|
|
1052
|
+
...(held?.context ? { context: held.context } : {}),
|
|
1053
|
+
};
|
|
1054
|
+
if (!held) return { deny: `${HELD_NOT_STARTED}.\n${offerText}` };
|
|
1055
|
+
return {
|
|
1056
|
+
deny: [
|
|
1057
|
+
`${HELD_WITH_OFFER} (offer ${held.offer}). It has not run.`,
|
|
1058
|
+
// A FOLLOW-UP TO A TENJIN WORKER HAS NO NATIVE FORM: its handle never reaches a native
|
|
1059
|
+
// tool, so the same call sent again is held again, as a new offer in place of this one.
|
|
1060
|
+
held.continuation
|
|
1061
|
+
? `This is not a failure, and there is nothing to recover or work around: the Tenjin plugin holds this follow-up to a DeepSeek worker until you choose. Your two moves are to run it with subagent({offer_id}), or to cancel it with subagent({cancel: offer_id}). Sending this same ${tool} call again does not run it: a Tenjin worker handle never runs natively, and the repeat is held again. Do not switch to another tool or do the work yourself because of this message.`
|
|
1062
|
+
: `This is not a failure, and there is nothing to recover or work around: the Tenjin plugin holds this ${tool} call until you choose. Your two moves are to accept the offer with subagent({offer_id}), or to send this same ${tool} call again unchanged, which runs it natively. Do not switch to another tool or do the work yourself because of this message.`,
|
|
1063
|
+
...(held.context ?? []),
|
|
1064
|
+
offerText,
|
|
1065
|
+
].join('\n'),
|
|
1066
|
+
};
|
|
618
1067
|
}
|
|
619
1068
|
|
|
620
|
-
function
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
1069
|
+
function heldOfferContext(offer: Json, continuation = false): string[] | undefined {
|
|
1070
|
+
const consent = asRecord(offer.consent);
|
|
1071
|
+
if (
|
|
1072
|
+
consent?.version !== 2 ||
|
|
1073
|
+
typeof consent.repository !== 'string' ||
|
|
1074
|
+
!consent.repository.trim() ||
|
|
1075
|
+
typeof consent.routerOrigin !== 'string' ||
|
|
1076
|
+
!/^https?:\/\/\S+$/.test(consent.routerOrigin) ||
|
|
1077
|
+
!Array.isArray(consent.recipients) ||
|
|
1078
|
+
consent.recipients.length !== 3 ||
|
|
1079
|
+
consent.recipients[0] !== 'Tenjin' ||
|
|
1080
|
+
consent.recipients[1] !== 'DeepSeek' ||
|
|
1081
|
+
consent.recipients[2] !== 'Exa' ||
|
|
1082
|
+
typeof offer.capAtomic !== 'string' ||
|
|
1083
|
+
!/^[1-9][0-9]*$/.test(offer.capAtomic) ||
|
|
1084
|
+
typeof offer.parentPolicy !== 'string' ||
|
|
1085
|
+
!offer.parentPolicy.trim()
|
|
1086
|
+
)
|
|
1087
|
+
return undefined;
|
|
1088
|
+
// This field is constructed by the local handoff, after its consent check.
|
|
1089
|
+
// Never promote the router's reason or other model/provider text into context.
|
|
1090
|
+
return [
|
|
1091
|
+
continuation
|
|
1092
|
+
? "This local Tenjin hook held the continuation; no continuation started. The user has installed Tenjin and turned DeepSeek subagents on. Run it with the subagent tool and this offer_id, or cancel it with that id. Its suitability is not judged again; the binding model, privacy and planning restrictions in the offer's parentPolicy still apply to its text. It reuses the worker's history and the original job's budget, with no routing fee."
|
|
1093
|
+
: "The user has installed Tenjin and turned DeepSeek subagents on. The offer's parentPolicy is local Tenjin guidance: apply it with the full assignment, the repository/configuration risk rules and the binding model/privacy restrictions.",
|
|
1094
|
+
];
|
|
624
1095
|
}
|
|
625
1096
|
|
|
626
1097
|
async function sha256Hex(text: string): Promise<string> {
|