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.
Files changed (495) hide show
  1. package/NOTICE.md +110 -0
  2. package/README.md +87 -81
  3. package/dist/{_esm-BIN7VY2L.js → _esm-2KST7HQ7.js} +7 -7
  4. package/dist/alive-5TV22PNF.js +51 -0
  5. package/dist/auth-XI7BJFLW.js +47 -0
  6. package/dist/{auto-update-Y24UL56V.js → auto-update-7L24KDWA.js} +4 -5
  7. package/dist/balance-DFHC6XEU.js +71 -0
  8. package/dist/{ccip-DHDFKTQV.js → ccip-HOW3DZYF.js} +4 -4
  9. package/dist/chunk-24XKUN2S.js +202 -0
  10. package/dist/chunk-24XKUN2S.js.map +1 -0
  11. package/dist/chunk-2L7TDGLV.js +56 -0
  12. package/dist/chunk-2L7TDGLV.js.map +1 -0
  13. package/dist/{chunk-C2Q76BVM.js → chunk-2U7H35IP.js} +29 -7
  14. package/dist/chunk-2U7H35IP.js.map +1 -0
  15. package/dist/chunk-2W4DQQUU.js +176 -0
  16. package/dist/chunk-2W4DQQUU.js.map +1 -0
  17. package/dist/{chunk-LRW6S53P.js → chunk-34SAECKZ.js} +35 -11
  18. package/dist/chunk-34SAECKZ.js.map +1 -0
  19. package/dist/{chunk-2I4QTOLB.js → chunk-3MZ7DYRO.js} +1 -1
  20. package/dist/chunk-3MZ7DYRO.js.map +1 -0
  21. package/dist/{chunk-RVPYTUP4.js → chunk-3Y2EHT4F.js} +13 -9
  22. package/dist/chunk-3Y2EHT4F.js.map +1 -0
  23. package/dist/chunk-3Y6BHIN6.js +169 -0
  24. package/dist/chunk-3Y6BHIN6.js.map +1 -0
  25. package/dist/{chunk-4K7TQHNP.js → chunk-3YPL6T3P.js} +17 -33
  26. package/dist/chunk-3YPL6T3P.js.map +1 -0
  27. package/dist/{chunk-E7SW44LM.js → chunk-44MVIRZH.js} +121 -6
  28. package/dist/chunk-44MVIRZH.js.map +1 -0
  29. package/dist/chunk-45MMSBHA.js +321 -0
  30. package/dist/chunk-45MMSBHA.js.map +1 -0
  31. package/dist/{chunk-3FMZGI7I.js → chunk-4CE6TMI5.js} +1 -1
  32. package/dist/chunk-4CE6TMI5.js.map +1 -0
  33. package/dist/{chunk-QXP3Z3JN.js → chunk-4MBCJFY4.js} +35 -3
  34. package/dist/chunk-4MBCJFY4.js.map +1 -0
  35. package/dist/chunk-4TPL54KW.js +227 -0
  36. package/dist/chunk-4TPL54KW.js.map +1 -0
  37. package/dist/chunk-54ELBTKE.js +1615 -0
  38. package/dist/chunk-54ELBTKE.js.map +1 -0
  39. package/dist/{chunk-NDGZDTSJ.js → chunk-5F4OB5B3.js} +115 -57
  40. package/dist/chunk-5F4OB5B3.js.map +1 -0
  41. package/dist/chunk-5HN4KVQU.js +3348 -0
  42. package/dist/chunk-5HN4KVQU.js.map +1 -0
  43. package/dist/{chunk-ZDZERB6L.js → chunk-5J4E5GYI.js} +572 -407
  44. package/dist/chunk-5J4E5GYI.js.map +1 -0
  45. package/dist/{chunk-ZNNXRNFD.js → chunk-5N4GGUBN.js} +48 -6
  46. package/dist/chunk-5N4GGUBN.js.map +1 -0
  47. package/dist/chunk-5USBZ2MU.js +58 -0
  48. package/dist/chunk-5USBZ2MU.js.map +1 -0
  49. package/dist/chunk-64WOMNYR.js +183 -0
  50. package/dist/chunk-64WOMNYR.js.map +1 -0
  51. package/dist/{chunk-ILNIZ5I2.js → chunk-65RS4LQS.js} +1825 -1715
  52. package/dist/chunk-65RS4LQS.js.map +1 -0
  53. package/dist/{chunk-IE7P2BZE.js → chunk-6QMDUDF2.js} +3 -3
  54. package/dist/{chunk-IADZOXKN.js → chunk-7SLOTLO7.js} +19 -697
  55. package/dist/chunk-7SLOTLO7.js.map +1 -0
  56. package/dist/{chunk-WFSPCCVW.js → chunk-7V25UAQO.js} +99 -99
  57. package/dist/{chunk-WFSPCCVW.js.map → chunk-7V25UAQO.js.map} +1 -1
  58. package/dist/chunk-BGA4DO5M.js +719 -0
  59. package/dist/chunk-BGA4DO5M.js.map +1 -0
  60. package/dist/chunk-BVP7YK2J.js +706 -0
  61. package/dist/chunk-BVP7YK2J.js.map +1 -0
  62. package/dist/chunk-C265QIMJ.js +83 -0
  63. package/dist/chunk-C265QIMJ.js.map +1 -0
  64. package/dist/{chunk-XQJXNMSB.js → chunk-CRG54LEB.js} +1 -1
  65. package/dist/chunk-CRG54LEB.js.map +1 -0
  66. package/dist/{chunk-KG3D7FIF.js → chunk-CZJOMUBP.js} +2 -2
  67. package/dist/{chunk-36RVGZNY.js → chunk-D6M3ZK66.js} +22 -39
  68. package/dist/chunk-D6M3ZK66.js.map +1 -0
  69. package/dist/{chunk-3UCIG4TG.js → chunk-DI4QAGRZ.js} +1 -11
  70. package/dist/chunk-DI4QAGRZ.js.map +1 -0
  71. package/dist/{chunk-JKKAIPTU.js → chunk-DIH2G3YG.js} +47 -10
  72. package/dist/chunk-DIH2G3YG.js.map +1 -0
  73. package/dist/chunk-DJ36BM62.js +78 -0
  74. package/dist/chunk-DJ36BM62.js.map +1 -0
  75. package/dist/chunk-DTEWAVNE.js +114 -0
  76. package/dist/chunk-DTEWAVNE.js.map +1 -0
  77. package/dist/chunk-F2KJAJ7T.js +13 -0
  78. package/dist/chunk-F2KJAJ7T.js.map +1 -0
  79. package/dist/{chunk-BF4XHEQK.js → chunk-F3QPGYOY.js} +6 -6
  80. package/dist/chunk-F3QPGYOY.js.map +1 -0
  81. package/dist/{chunk-3GNJXKIT.js → chunk-F43CV6UC.js} +2 -2
  82. package/dist/{chunk-J57UC3DD.js → chunk-FKVJKLPI.js} +3 -3
  83. package/dist/{chunk-V2LQLN5H.js → chunk-FYFHH7V5.js} +59 -8
  84. package/dist/{chunk-V2LQLN5H.js.map → chunk-FYFHH7V5.js.map} +1 -1
  85. package/dist/chunk-GAJC4BQZ.js +1096 -0
  86. package/dist/chunk-GAJC4BQZ.js.map +1 -0
  87. package/dist/{chunk-DOQGNFHM.js → chunk-GH5UKMZD.js} +2 -12
  88. package/dist/{chunk-DOQGNFHM.js.map → chunk-GH5UKMZD.js.map} +1 -1
  89. package/dist/{chunk-WYXUQGOL.js → chunk-HAZAN4UM.js} +7 -6
  90. package/dist/chunk-HAZAN4UM.js.map +1 -0
  91. package/dist/chunk-HI5XQOX2.js +393 -0
  92. package/dist/chunk-HI5XQOX2.js.map +1 -0
  93. package/dist/chunk-HKGUKAQW.js +488 -0
  94. package/dist/chunk-HKGUKAQW.js.map +1 -0
  95. package/dist/{chunk-SO3XRZPX.js → chunk-HPRVFJPM.js} +6 -6
  96. package/dist/{chunk-L6JEXB3E.js → chunk-HQR4BWKX.js} +3 -131
  97. package/dist/chunk-HQR4BWKX.js.map +1 -0
  98. package/dist/chunk-HZKANST2.js +177 -0
  99. package/dist/chunk-HZKANST2.js.map +1 -0
  100. package/dist/{chunk-UUGOUOVT.js → chunk-I557SAOM.js} +8 -2
  101. package/dist/chunk-I557SAOM.js.map +1 -0
  102. package/dist/{chunk-TC2WZLSC.js → chunk-IGLWLH73.js} +8 -7
  103. package/dist/chunk-IGLWLH73.js.map +1 -0
  104. package/dist/chunk-ILWCKCOI.js +58 -0
  105. package/dist/chunk-ILWCKCOI.js.map +1 -0
  106. package/dist/{chunk-2GP3HRYK.js → chunk-INSIW65E.js} +182 -182
  107. package/dist/{chunk-MPZUYCAP.js → chunk-IULCDMVG.js} +12 -1
  108. package/dist/chunk-IULCDMVG.js.map +1 -0
  109. package/dist/{chunk-INTFHMU4.js → chunk-IVNSUAVC.js} +25 -26
  110. package/dist/chunk-IVNSUAVC.js.map +1 -0
  111. package/dist/chunk-JDQZCREI.js +87 -0
  112. package/dist/chunk-JDQZCREI.js.map +1 -0
  113. package/dist/chunk-JHFFUVON.js +1050 -0
  114. package/dist/chunk-JHFFUVON.js.map +1 -0
  115. package/dist/{chunk-RL5UUDT4.js → chunk-JNUKLSMZ.js} +3 -3
  116. package/dist/chunk-JTILUN4W.js +2933 -0
  117. package/dist/chunk-JTILUN4W.js.map +1 -0
  118. package/dist/{chunk-OJNTCYQQ.js → chunk-JTX3BUDK.js} +37 -53
  119. package/dist/chunk-JTX3BUDK.js.map +1 -0
  120. package/dist/{chunk-X5ZBP3IY.js → chunk-JUUBBBY5.js} +2 -2
  121. package/dist/chunk-JUUBBBY5.js.map +1 -0
  122. package/dist/chunk-JWAK7JQB.js +15 -0
  123. package/dist/chunk-JWAK7JQB.js.map +1 -0
  124. package/dist/{chunk-UXZONNEQ.js → chunk-K5KNGC4I.js} +34 -31
  125. package/dist/chunk-K5KNGC4I.js.map +1 -0
  126. package/dist/chunk-KAQ4Q3TO.js +135 -0
  127. package/dist/chunk-KAQ4Q3TO.js.map +1 -0
  128. package/dist/chunk-KFVJYLVL.js +125 -0
  129. package/dist/chunk-KFVJYLVL.js.map +1 -0
  130. package/dist/chunk-KGUE5AVX.js +69 -0
  131. package/dist/chunk-KGUE5AVX.js.map +1 -0
  132. package/dist/{chunk-FVIGCDSV.js → chunk-KLDMLWXT.js} +11 -85
  133. package/dist/chunk-KLDMLWXT.js.map +1 -0
  134. package/dist/chunk-KNKDMTHU.js +453 -0
  135. package/dist/chunk-KNKDMTHU.js.map +1 -0
  136. package/dist/chunk-LDA6TAYQ.js +95 -0
  137. package/dist/chunk-LDA6TAYQ.js.map +1 -0
  138. package/dist/chunk-LWSSIZOY.js +347 -0
  139. package/dist/chunk-LWSSIZOY.js.map +1 -0
  140. package/dist/{chunk-ZURZHELF.js → chunk-MAHNZA6C.js} +158 -41
  141. package/dist/chunk-MAHNZA6C.js.map +1 -0
  142. package/dist/chunk-MEWZCIA6.js +220 -0
  143. package/dist/chunk-MEWZCIA6.js.map +1 -0
  144. package/dist/{chunk-2SNUOHAT.js → chunk-MEZJ3I63.js} +49 -1
  145. package/dist/chunk-MEZJ3I63.js.map +1 -0
  146. package/dist/chunk-MJDO4EXD.js +353 -0
  147. package/dist/chunk-MJDO4EXD.js.map +1 -0
  148. package/dist/chunk-NJA6NT3A.js +6595 -0
  149. package/dist/chunk-NJA6NT3A.js.map +1 -0
  150. package/dist/{chunk-LHHMV4GU.js → chunk-NVSKJPRC.js} +1 -1
  151. package/dist/{chunk-LHHMV4GU.js.map → chunk-NVSKJPRC.js.map} +1 -1
  152. package/dist/{chunk-4YOZGGTZ.js → chunk-OC7K2DVZ.js} +5 -5
  153. package/dist/chunk-OC7K2DVZ.js.map +1 -0
  154. package/dist/chunk-ODRPASFP.js +2078 -0
  155. package/dist/chunk-ODRPASFP.js.map +1 -0
  156. package/dist/chunk-OJJFANO6.js +133 -0
  157. package/dist/chunk-OJJFANO6.js.map +1 -0
  158. package/dist/{chunk-JNJWBTU2.js → chunk-OQWPRFAC.js} +332 -882
  159. package/dist/chunk-OQWPRFAC.js.map +1 -0
  160. package/dist/chunk-P4I7BFNJ.js +11 -0
  161. package/dist/chunk-P4I7BFNJ.js.map +1 -0
  162. package/dist/{chunk-SNNSAGMT.js → chunk-P6YQWIT2.js} +4058 -4039
  163. package/dist/chunk-P6YQWIT2.js.map +1 -0
  164. package/dist/{chunk-JRGFKVAZ.js → chunk-PETQ5WEA.js} +2 -2
  165. package/dist/{chunk-HMWYAUA6.js → chunk-Q6RSJCXB.js} +29 -69
  166. package/dist/chunk-Q6RSJCXB.js.map +1 -0
  167. package/dist/{chunk-U3IKUGRP.js → chunk-QKEUKBRK.js} +17 -23
  168. package/dist/chunk-QKEUKBRK.js.map +1 -0
  169. package/dist/{chunk-2RWB7RKE.js → chunk-QKYUCITR.js} +174 -5814
  170. package/dist/chunk-QKYUCITR.js.map +1 -0
  171. package/dist/chunk-QQDPRTLP.js +127 -0
  172. package/dist/chunk-QQDPRTLP.js.map +1 -0
  173. package/dist/chunk-QQYCYAKI.js +79 -0
  174. package/dist/chunk-QQYCYAKI.js.map +1 -0
  175. package/dist/chunk-R4KDH477.js +1064 -0
  176. package/dist/chunk-R4KDH477.js.map +1 -0
  177. package/dist/chunk-R5TR2DIK.js +119 -0
  178. package/dist/chunk-R5TR2DIK.js.map +1 -0
  179. package/dist/chunk-R62PKTAG.js +66 -0
  180. package/dist/chunk-R62PKTAG.js.map +1 -0
  181. package/dist/{chunk-BFDQ4WNW.js → chunk-RFZA7PSM.js} +4 -5
  182. package/dist/chunk-RFZA7PSM.js.map +1 -0
  183. package/dist/chunk-RGCPELQN.js +219 -0
  184. package/dist/chunk-RGCPELQN.js.map +1 -0
  185. package/dist/chunk-RGVCOG2S.js +910 -0
  186. package/dist/chunk-RGVCOG2S.js.map +1 -0
  187. package/dist/chunk-SOLNJ3AZ.js +209 -0
  188. package/dist/chunk-SOLNJ3AZ.js.map +1 -0
  189. package/dist/chunk-TFT2X7SH.js +77 -0
  190. package/dist/chunk-TFT2X7SH.js.map +1 -0
  191. package/dist/chunk-TUCKEEXE.js +2 -0
  192. package/dist/chunk-TVWCLUBI.js +293 -0
  193. package/dist/chunk-TVWCLUBI.js.map +1 -0
  194. package/dist/chunk-U4TRWSVE.js +78 -0
  195. package/dist/chunk-U4TRWSVE.js.map +1 -0
  196. package/dist/chunk-UIB33QQP.js +379 -0
  197. package/dist/chunk-UIB33QQP.js.map +1 -0
  198. package/dist/chunk-V6GIVALQ.js +1889 -0
  199. package/dist/chunk-V6GIVALQ.js.map +1 -0
  200. package/dist/chunk-VHXCPXUS.js +366 -0
  201. package/dist/chunk-VHXCPXUS.js.map +1 -0
  202. package/dist/{chunk-HGZEPQUT.js → chunk-VU6GMWF6.js} +17 -8
  203. package/dist/chunk-VU6GMWF6.js.map +1 -0
  204. package/dist/chunk-VWZYE3NC.js +8415 -0
  205. package/dist/chunk-VWZYE3NC.js.map +1 -0
  206. package/dist/{chunk-AGMVASXZ.js → chunk-W2GXIARJ.js} +88 -11
  207. package/dist/chunk-W2GXIARJ.js.map +1 -0
  208. package/dist/chunk-W4G3K3V7.js +288 -0
  209. package/dist/chunk-W4G3K3V7.js.map +1 -0
  210. package/dist/chunk-W74LJ5OT.js +588 -0
  211. package/dist/chunk-W74LJ5OT.js.map +1 -0
  212. package/dist/chunk-W7ELYLYK.js +233 -0
  213. package/dist/chunk-W7ELYLYK.js.map +1 -0
  214. package/dist/{chunk-BPMWXTFX.js → chunk-WFZX352D.js} +7 -7
  215. package/dist/chunk-WXA3WTPF.js +20 -0
  216. package/dist/chunk-WXA3WTPF.js.map +1 -0
  217. package/dist/chunk-XRGFH7FI.js +454 -0
  218. package/dist/chunk-XRGFH7FI.js.map +1 -0
  219. package/dist/chunk-XSCGUO2U.js +330 -0
  220. package/dist/chunk-XSCGUO2U.js.map +1 -0
  221. package/dist/chunk-XWROSMI5.js +1039 -0
  222. package/dist/chunk-XWROSMI5.js.map +1 -0
  223. package/dist/chunk-Y2EXZ47H.js +40 -0
  224. package/dist/chunk-Y2EXZ47H.js.map +1 -0
  225. package/dist/chunk-YJGEVBKZ.js +47 -0
  226. package/dist/chunk-YJGEVBKZ.js.map +1 -0
  227. package/dist/{chunk-6CMM6YCB.js → chunk-YWWMISDY.js} +2 -2
  228. package/dist/{chunk-WXA2BWTE.js → chunk-ZCT5DJ3G.js} +2 -48
  229. package/dist/chunk-ZCT5DJ3G.js.map +1 -0
  230. package/dist/chunk-ZEYA2WWX.js +982 -0
  231. package/dist/chunk-ZEYA2WWX.js.map +1 -0
  232. package/dist/chunk-ZRC7Z5X3.js +82 -0
  233. package/dist/chunk-ZRC7Z5X3.js.map +1 -0
  234. package/dist/{chunk-3AIHRXKO.js → chunk-ZS7JIUJ3.js} +12 -10
  235. package/dist/chunk-ZS7JIUJ3.js.map +1 -0
  236. package/dist/{clack-EZ7TDWQU.js → clack-Q4RNC5VE.js} +2 -6
  237. package/dist/{claude-cli-2YKABJJZ.js → claude-cli-GIIHOBGT.js} +4 -2
  238. package/dist/claude-install-BAUSJMW3.js +64 -0
  239. package/dist/{cli-E36SPKBW.js → cli-QY4KKA3D.js} +632 -150
  240. package/dist/cli-QY4KKA3D.js.map +1 -0
  241. package/dist/client-3YQKORVK.js +710 -0
  242. package/dist/client-3YQKORVK.js.map +1 -0
  243. package/dist/{codex-event-ZO2GEFE6.js → codex-event-EUTCAOTQ.js} +3 -5
  244. package/dist/{codex-host-KECJVTA2.js → codex-host-ZON3S6HU.js} +7 -7
  245. package/dist/{codex-install-HQZDGFXW.js → codex-install-HZV2DOAB.js} +242 -88
  246. package/dist/codex-install-HZV2DOAB.js.map +1 -0
  247. package/dist/config-QZOBMTEL.js +57 -0
  248. package/dist/config-names-Z5NZD5R2.js +224 -0
  249. package/dist/config-names-Z5NZD5R2.js.map +1 -0
  250. package/dist/config-rules-YOYHS6YL.js +55 -0
  251. package/dist/config-subagents-WQV2ZAD5.js +362 -0
  252. package/dist/config-subagents-WQV2ZAD5.js.map +1 -0
  253. package/dist/connect-YDWTYU4B.js +1020 -0
  254. package/dist/connect-YDWTYU4B.js.map +1 -0
  255. package/dist/core-0a66n3e7-TTP554XV.js +127 -0
  256. package/dist/core-0a66n3e7-TTP554XV.js.map +1 -0
  257. package/dist/core-0bmnpbz2-C2JIRVZO.js +10790 -0
  258. package/dist/core-0bmnpbz2-C2JIRVZO.js.map +1 -0
  259. package/dist/core-9je8ee1j-74DGHWPV.js +30 -0
  260. package/dist/core-9je8ee1j-74DGHWPV.js.map +1 -0
  261. package/dist/core-wadgcjfh-TSZFQZGH.js +666 -0
  262. package/dist/core-wadgcjfh-TSZFQZGH.js.map +1 -0
  263. package/dist/core-zg882d22-LKV5DZYW.js +37 -0
  264. package/dist/core-zg882d22-LKV5DZYW.js.map +1 -0
  265. package/dist/decision-QSKHOGCO.js +145 -0
  266. package/dist/{doctor-I6XQEKWD.js → doctor-ZWJXRD75.js} +162 -148
  267. package/dist/doctor-ZWJXRD75.js.map +1 -0
  268. package/dist/{env-proxy-R6ZMLQTT.js → env-proxy-XLSLHBKQ.js} +2 -2
  269. package/dist/{ethersCompat-Df4a6QIZ-X6YZWAML.js → ethersCompat-Df4a6QIZ-K3DMHR6Y.js} +5 -5
  270. package/dist/explicit-ME2NRADQ.js +371 -0
  271. package/dist/explicit-ME2NRADQ.js.map +1 -0
  272. package/dist/flush-stdio-NYIJ3QXT.js +18 -0
  273. package/dist/fund-VF7TLDJH.js +722 -0
  274. package/dist/fund-VF7TLDJH.js.map +1 -0
  275. package/dist/hook-command-VZ27MGWO.js +49 -0
  276. package/dist/hosts/claude/.claude-plugin/marketplace.json +2 -2
  277. package/dist/hosts/claude/tenjin/.claude-plugin/plugin.json +2 -2
  278. package/dist/hosts/claude/tenjin/hooks/hook-data.ts +152 -0
  279. package/dist/hosts/claude/tenjin/hooks/hooks.json +7 -0
  280. package/dist/hosts/claude/tenjin/hooks/model-viewer.tsx +2987 -0
  281. package/dist/hosts/claude/tenjin/hooks/register.tsx +527 -56
  282. package/dist/hosts/claude/tenjin/skills/tenjin-pay/SKILL.md +14 -4
  283. package/dist/hosts/claude/tenjin/types/index.d.ts +144 -1
  284. package/dist/{hosts-DVQJ32QC.js → hosts-3EMTVM4H.js} +7 -6
  285. package/dist/index.js +18 -15
  286. package/dist/index.js.map +1 -1
  287. package/dist/install-ZA7L2UF3.js +115 -0
  288. package/dist/install-funding-JDGYTF72.js +30 -0
  289. package/dist/install-identity-FFAYEFLX.js +30 -0
  290. package/dist/{install-wallet-5M4OTYLX.js → install-wallet-2SFOVE3Q.js} +68 -53
  291. package/dist/install-wallet-2SFOVE3Q.js.map +1 -0
  292. package/dist/mcp-36S6MK3C.js +67642 -0
  293. package/dist/mcp-36S6MK3C.js.map +1 -0
  294. package/dist/new-install-5L4GY3LN.js +51 -0
  295. package/dist/{package-IJFGMWEV.js → package-BONDXSV3.js} +2 -2
  296. package/dist/{passphrase-IFTDS3CU.js → passphrase-T4ULBN4M.js} +16 -12
  297. package/dist/{paths-XCSAKISU.js → paths-O2KDWZ76.js} +18 -28
  298. package/dist/pay-CMV5KL74.js +74 -0
  299. package/dist/{payments-HFPPWHTV.js → payments-Z6UBZL4Z.js} +36 -26
  300. package/dist/payments-Z6UBZL4Z.js.map +1 -0
  301. package/dist/reclaim-subagent-credit-ABSF67SJ.js +105 -0
  302. package/dist/reclaim-subagent-credit-ABSF67SJ.js.map +1 -0
  303. package/dist/{redact-D7ASVWKL.js → redact-LOTHE5TS.js} +2 -8
  304. package/dist/redact-LOTHE5TS.js.map +1 -0
  305. package/dist/routing-quote-AHLAREXR.js +40 -0
  306. package/dist/routing-quote-AHLAREXR.js.map +1 -0
  307. package/dist/run-JH7ELYAM.js +88 -0
  308. package/dist/run-JH7ELYAM.js.map +1 -0
  309. package/dist/runtime-2GX4ALJP.js +410 -0
  310. package/dist/runtime-2GX4ALJP.js.map +1 -0
  311. package/dist/runtime-activate-IDQ2NCSP.js +39 -0
  312. package/dist/runtime-activate-IDQ2NCSP.js.map +1 -0
  313. package/dist/{runtime-fetch-ZSSSK72Y.js → runtime-fetch-6LOBHBEN.js} +4 -4
  314. package/dist/runtime-fetch-6LOBHBEN.js.map +1 -0
  315. package/dist/runtime-launchers-YAPKCBHV.js +31 -0
  316. package/dist/runtime-launchers-YAPKCBHV.js.map +1 -0
  317. package/dist/{runtime-layout-WIDILZ6K.js → runtime-layout-QHZQJV7C.js} +5 -4
  318. package/dist/runtime-layout-QHZQJV7C.js.map +1 -0
  319. package/dist/runtime-place-4POL4KK4.js +37 -0
  320. package/dist/runtime-place-4POL4KK4.js.map +1 -0
  321. package/dist/runtime-provenance-MNJGVBV2.js +12 -0
  322. package/dist/runtime-provenance-MNJGVBV2.js.map +1 -0
  323. package/dist/{secp256k1-ZZZT2CAX.js → secp256k1-N5P2GVGF.js} +3 -3
  324. package/dist/secp256k1-N5P2GVGF.js.map +1 -0
  325. package/dist/{send-GCVEAQKL.js → send-ELXFKEKY.js} +35 -32
  326. package/dist/send-ELXFKEKY.js.map +1 -0
  327. package/dist/status-FXUFWJDM.js +404 -0
  328. package/dist/status-FXUFWJDM.js.map +1 -0
  329. package/dist/{status-line-OPCXDHL2.js → status-line-IH5JBWBC.js} +51 -43
  330. package/dist/status-line-IH5JBWBC.js.map +1 -0
  331. package/dist/streamableHttp-CP2ZQBIK.js +768 -0
  332. package/dist/streamableHttp-CP2ZQBIK.js.map +1 -0
  333. package/dist/{uninstall-BAWRBXXQ.js → uninstall-LJZUKM4D.js} +76 -76
  334. package/dist/uninstall-LJZUKM4D.js.map +1 -0
  335. package/dist/update-EUIX72IX.js +68 -0
  336. package/dist/update-EUIX72IX.js.map +1 -0
  337. package/dist/usage-EKDC7LUC.js +180 -0
  338. package/dist/usage-EKDC7LUC.js.map +1 -0
  339. package/dist/{usdc-VG4CIOUK.js → usdc-YIHK2OMC.js} +8 -12
  340. package/dist/usdc-YIHK2OMC.js.map +1 -0
  341. package/dist/{viemAdapter-By13KInL-DOFTEIJV.js → viemAdapter-By13KInL-PRLSIESK.js} +5 -5
  342. package/dist/viemAdapter-By13KInL-PRLSIESK.js.map +1 -0
  343. package/dist/wallet-HSW757W6.js +80 -0
  344. package/dist/wallet-HSW757W6.js.map +1 -0
  345. package/dist/wallet-kdf-worker.mjs +1433 -818
  346. package/docs/agent-permissions.md +88 -155
  347. package/docs/router-reference.md +236 -0
  348. package/docs/safety-model.md +31 -33
  349. package/docs/subagents-internals.md +97 -0
  350. package/docs/subagents.md +348 -0
  351. package/docs/troubleshooting.md +10 -6
  352. package/package.json +12 -8
  353. package/scripts/installers/install.sh +7 -1
  354. package/dist/alive-GSOWKUOY.js +0 -38
  355. package/dist/chunk-2I4QTOLB.js.map +0 -1
  356. package/dist/chunk-2M2VPI2E.js +0 -560
  357. package/dist/chunk-2M2VPI2E.js.map +0 -1
  358. package/dist/chunk-2RWB7RKE.js.map +0 -1
  359. package/dist/chunk-2SNUOHAT.js.map +0 -1
  360. package/dist/chunk-3623BLPV.js +0 -184
  361. package/dist/chunk-3623BLPV.js.map +0 -1
  362. package/dist/chunk-36RVGZNY.js.map +0 -1
  363. package/dist/chunk-3AIHRXKO.js.map +0 -1
  364. package/dist/chunk-3FMZGI7I.js.map +0 -1
  365. package/dist/chunk-3UCIG4TG.js.map +0 -1
  366. package/dist/chunk-4K7TQHNP.js.map +0 -1
  367. package/dist/chunk-4LMUQMBH.js +0 -29
  368. package/dist/chunk-4LMUQMBH.js.map +0 -1
  369. package/dist/chunk-4USCZ2NI.js +0 -228
  370. package/dist/chunk-4USCZ2NI.js.map +0 -1
  371. package/dist/chunk-4YOZGGTZ.js.map +0 -1
  372. package/dist/chunk-62KNUYWD.js +0 -111
  373. package/dist/chunk-62KNUYWD.js.map +0 -1
  374. package/dist/chunk-A5GKIG5O.js +0 -2037
  375. package/dist/chunk-A5GKIG5O.js.map +0 -1
  376. package/dist/chunk-AGMVASXZ.js.map +0 -1
  377. package/dist/chunk-BF4XHEQK.js.map +0 -1
  378. package/dist/chunk-BFDQ4WNW.js.map +0 -1
  379. package/dist/chunk-C2Q76BVM.js.map +0 -1
  380. package/dist/chunk-CEXSOI5R.js +0 -808
  381. package/dist/chunk-CEXSOI5R.js.map +0 -1
  382. package/dist/chunk-E7SW44LM.js.map +0 -1
  383. package/dist/chunk-EDJWHDDL.js +0 -33
  384. package/dist/chunk-EDJWHDDL.js.map +0 -1
  385. package/dist/chunk-FVIGCDSV.js.map +0 -1
  386. package/dist/chunk-GTTUCOPD.js +0 -105
  387. package/dist/chunk-GTTUCOPD.js.map +0 -1
  388. package/dist/chunk-HDPUXS3Z.js +0 -122
  389. package/dist/chunk-HDPUXS3Z.js.map +0 -1
  390. package/dist/chunk-HGGWCP7W.js +0 -120
  391. package/dist/chunk-HGGWCP7W.js.map +0 -1
  392. package/dist/chunk-HGZEPQUT.js.map +0 -1
  393. package/dist/chunk-HMWYAUA6.js.map +0 -1
  394. package/dist/chunk-IADZOXKN.js.map +0 -1
  395. package/dist/chunk-ILNIZ5I2.js.map +0 -1
  396. package/dist/chunk-INTFHMU4.js.map +0 -1
  397. package/dist/chunk-JKKAIPTU.js.map +0 -1
  398. package/dist/chunk-JNJWBTU2.js.map +0 -1
  399. package/dist/chunk-KM7RY2ZS.js +0 -246
  400. package/dist/chunk-KM7RY2ZS.js.map +0 -1
  401. package/dist/chunk-KOGZDMHO.js +0 -21
  402. package/dist/chunk-KOGZDMHO.js.map +0 -1
  403. package/dist/chunk-L6JEXB3E.js.map +0 -1
  404. package/dist/chunk-LRW6S53P.js.map +0 -1
  405. package/dist/chunk-LXAYUOXI.js +0 -511
  406. package/dist/chunk-LXAYUOXI.js.map +0 -1
  407. package/dist/chunk-MEFB5KHA.js +0 -59
  408. package/dist/chunk-MEFB5KHA.js.map +0 -1
  409. package/dist/chunk-MPZUYCAP.js.map +0 -1
  410. package/dist/chunk-NDGZDTSJ.js.map +0 -1
  411. package/dist/chunk-OJNTCYQQ.js.map +0 -1
  412. package/dist/chunk-P3LFTKE7.js +0 -58
  413. package/dist/chunk-P3LFTKE7.js.map +0 -1
  414. package/dist/chunk-QXP3Z3JN.js.map +0 -1
  415. package/dist/chunk-RVPYTUP4.js.map +0 -1
  416. package/dist/chunk-SNNSAGMT.js.map +0 -1
  417. package/dist/chunk-TC2WZLSC.js.map +0 -1
  418. package/dist/chunk-TKPF35W6.js +0 -29
  419. package/dist/chunk-TKPF35W6.js.map +0 -1
  420. package/dist/chunk-U3IKUGRP.js.map +0 -1
  421. package/dist/chunk-UUGOUOVT.js.map +0 -1
  422. package/dist/chunk-UXZONNEQ.js.map +0 -1
  423. package/dist/chunk-WXA2BWTE.js.map +0 -1
  424. package/dist/chunk-WYXUQGOL.js.map +0 -1
  425. package/dist/chunk-X5ZBP3IY.js.map +0 -1
  426. package/dist/chunk-XKESD27X.js +0 -10
  427. package/dist/chunk-XKESD27X.js.map +0 -1
  428. package/dist/chunk-XQJXNMSB.js.map +0 -1
  429. package/dist/chunk-Y527D4TV.js +0 -56
  430. package/dist/chunk-Y527D4TV.js.map +0 -1
  431. package/dist/chunk-ZDZERB6L.js.map +0 -1
  432. package/dist/chunk-ZNNXRNFD.js.map +0 -1
  433. package/dist/chunk-ZURZHELF.js.map +0 -1
  434. package/dist/cli-E36SPKBW.js.map +0 -1
  435. package/dist/codex-install-HQZDGFXW.js.map +0 -1
  436. package/dist/config-HY2E4GGW.js +0 -55
  437. package/dist/doctor-I6XQEKWD.js.map +0 -1
  438. package/dist/fund-2QRO7OJL.js +0 -378
  439. package/dist/fund-2QRO7OJL.js.map +0 -1
  440. package/dist/hook-command-2UBCSZG6.js +0 -43
  441. package/dist/install-ILUX5C4A.js +0 -107
  442. package/dist/install-identity-TZKGY6LQ.js +0 -31
  443. package/dist/install-wallet-5M4OTYLX.js.map +0 -1
  444. package/dist/mcp-LE4DUS22.js +0 -14127
  445. package/dist/mcp-LE4DUS22.js.map +0 -1
  446. package/dist/pay-WCG3IH4R.js +0 -55
  447. package/dist/payments-HFPPWHTV.js.map +0 -1
  448. package/dist/plugin-registration-PZFI5GZW.js +0 -68
  449. package/dist/runtime-UZOKSUZX.js +0 -1321
  450. package/dist/runtime-UZOKSUZX.js.map +0 -1
  451. package/dist/send-GCVEAQKL.js.map +0 -1
  452. package/dist/status-HCVAOCN7.js +0 -150
  453. package/dist/status-HCVAOCN7.js.map +0 -1
  454. package/dist/status-line-OPCXDHL2.js.map +0 -1
  455. package/dist/uninstall-BAWRBXXQ.js.map +0 -1
  456. package/dist/update-CACXLQLR.js +0 -56
  457. package/dist/wallet-QL4UUXEZ.js +0 -55
  458. /package/dist/{_esm-BIN7VY2L.js.map → _esm-2KST7HQ7.js.map} +0 -0
  459. /package/dist/{alive-GSOWKUOY.js.map → alive-5TV22PNF.js.map} +0 -0
  460. /package/dist/{auto-update-Y24UL56V.js.map → auth-XI7BJFLW.js.map} +0 -0
  461. /package/dist/{ccip-DHDFKTQV.js.map → auto-update-7L24KDWA.js.map} +0 -0
  462. /package/dist/{clack-EZ7TDWQU.js.map → balance-DFHC6XEU.js.map} +0 -0
  463. /package/dist/{claude-cli-2YKABJJZ.js.map → ccip-HOW3DZYF.js.map} +0 -0
  464. /package/dist/{chunk-IE7P2BZE.js.map → chunk-6QMDUDF2.js.map} +0 -0
  465. /package/dist/{chunk-KG3D7FIF.js.map → chunk-CZJOMUBP.js.map} +0 -0
  466. /package/dist/{chunk-3GNJXKIT.js.map → chunk-F43CV6UC.js.map} +0 -0
  467. /package/dist/{chunk-J57UC3DD.js.map → chunk-FKVJKLPI.js.map} +0 -0
  468. /package/dist/{chunk-SO3XRZPX.js.map → chunk-HPRVFJPM.js.map} +0 -0
  469. /package/dist/{chunk-2GP3HRYK.js.map → chunk-INSIW65E.js.map} +0 -0
  470. /package/dist/{chunk-RL5UUDT4.js.map → chunk-JNUKLSMZ.js.map} +0 -0
  471. /package/dist/{chunk-JRGFKVAZ.js.map → chunk-PETQ5WEA.js.map} +0 -0
  472. /package/dist/{codex-event-ZO2GEFE6.js.map → chunk-TUCKEEXE.js.map} +0 -0
  473. /package/dist/{chunk-BPMWXTFX.js.map → chunk-WFZX352D.js.map} +0 -0
  474. /package/dist/{chunk-6CMM6YCB.js.map → chunk-YWWMISDY.js.map} +0 -0
  475. /package/dist/{codex-host-KECJVTA2.js.map → clack-Q4RNC5VE.js.map} +0 -0
  476. /package/dist/{config-HY2E4GGW.js.map → claude-cli-GIIHOBGT.js.map} +0 -0
  477. /package/dist/{env-proxy-R6ZMLQTT.js.map → claude-install-BAUSJMW3.js.map} +0 -0
  478. /package/dist/{ethersCompat-Df4a6QIZ-X6YZWAML.js.map → codex-event-EUTCAOTQ.js.map} +0 -0
  479. /package/dist/{hook-command-2UBCSZG6.js.map → codex-host-ZON3S6HU.js.map} +0 -0
  480. /package/dist/{hosts-DVQJ32QC.js.map → config-QZOBMTEL.js.map} +0 -0
  481. /package/dist/{install-ILUX5C4A.js.map → config-rules-YOYHS6YL.js.map} +0 -0
  482. /package/dist/{install-identity-TZKGY6LQ.js.map → decision-QSKHOGCO.js.map} +0 -0
  483. /package/dist/{package-IJFGMWEV.js.map → env-proxy-XLSLHBKQ.js.map} +0 -0
  484. /package/dist/{passphrase-IFTDS3CU.js.map → ethersCompat-Df4a6QIZ-K3DMHR6Y.js.map} +0 -0
  485. /package/dist/{paths-XCSAKISU.js.map → flush-stdio-NYIJ3QXT.js.map} +0 -0
  486. /package/dist/{pay-WCG3IH4R.js.map → hook-command-VZ27MGWO.js.map} +0 -0
  487. /package/dist/{plugin-registration-PZFI5GZW.js.map → hosts-3EMTVM4H.js.map} +0 -0
  488. /package/dist/{redact-D7ASVWKL.js.map → install-ZA7L2UF3.js.map} +0 -0
  489. /package/dist/{runtime-fetch-ZSSSK72Y.js.map → install-funding-JDGYTF72.js.map} +0 -0
  490. /package/dist/{runtime-layout-WIDILZ6K.js.map → install-identity-FFAYEFLX.js.map} +0 -0
  491. /package/dist/{secp256k1-ZZZT2CAX.js.map → new-install-5L4GY3LN.js.map} +0 -0
  492. /package/dist/{update-CACXLQLR.js.map → package-BONDXSV3.js.map} +0 -0
  493. /package/dist/{usdc-VG4CIOUK.js.map → passphrase-T4ULBN4M.js.map} +0 -0
  494. /package/dist/{viemAdapter-By13KInL-DOFTEIJV.js.map → paths-O2KDWZ76.js.map} +0 -0
  495. /package/dist/{wallet-QL4UUXEZ.js.map → pay-CMV5KL74.js.map} +0 -0
@@ -0,0 +1,1039 @@
1
+ import { createRequire as __tenjinCreateRequire } from 'node:module'; const require = __tenjinCreateRequire(import.meta.url);
2
+ import {
3
+ persist,
4
+ resolveFromContext
5
+ } from "./chunk-W74LJ5OT.js";
6
+ import {
7
+ POLICY_INVALID_TEXT,
8
+ REPLACEMENT_NAME,
9
+ SAVED_HERE,
10
+ SAVED_PREFIX,
11
+ blockedBy,
12
+ connectedLabels,
13
+ describeBlock,
14
+ describeLimits,
15
+ describeOnly,
16
+ describePrefer,
17
+ describeReplacement,
18
+ describeRules,
19
+ describeSpeed,
20
+ either,
21
+ flagFor,
22
+ list,
23
+ nameOf,
24
+ namesCommand,
25
+ onlyResetCommand,
26
+ preferResetCommand,
27
+ replacementSupport,
28
+ scopeFlag,
29
+ settingsReadback,
30
+ shellWord,
31
+ summarizeRule,
32
+ unblockCommand
33
+ } from "./chunk-KNKDMTHU.js";
34
+ import {
35
+ KIND_NOUN,
36
+ cachedIdentities,
37
+ entriesOf,
38
+ fetchIdentities,
39
+ folded,
40
+ labelOf,
41
+ resolveName,
42
+ servicesNaming,
43
+ speedTasks,
44
+ tasksOf
45
+ } from "./chunk-3Y6BHIN6.js";
46
+ import {
47
+ normalised
48
+ } from "./chunk-R62PKTAG.js";
49
+ import {
50
+ paint
51
+ } from "./chunk-KLDMLWXT.js";
52
+ import {
53
+ routerSettings
54
+ } from "./chunk-W2GXIARJ.js";
55
+ import {
56
+ savedAccountsIn
57
+ } from "./chunk-TFT2X7SH.js";
58
+ import {
59
+ editSources,
60
+ loadRawConfig,
61
+ readPersonalRouter
62
+ } from "./chunk-UIB33QQP.js";
63
+ import {
64
+ BUILT_IN_SOURCE,
65
+ ONLY_DIMENSIONS,
66
+ POLICY_VERSION,
67
+ ReplacementProvidersSchema,
68
+ SETTINGS_LIMITS,
69
+ SavedPolicySchema,
70
+ TARGET_KINDS,
71
+ hasRules,
72
+ onlyKey,
73
+ scopeKey,
74
+ targetKey,
75
+ wirePolicy
76
+ } from "./chunk-RGCPELQN.js";
77
+ import {
78
+ CliError
79
+ } from "./chunk-DI4QAGRZ.js";
80
+
81
+ // src/commands/config-rules.ts
82
+ function wantedOf(flags, kinds = TARGET_KINDS) {
83
+ return kinds.flatMap(
84
+ (kind) => (flags[kind] ?? []).map((name) => ({ kind, name: name.trim() }))
85
+ );
86
+ }
87
+ function usage(message, fix, details) {
88
+ throw new CliError("USAGE", message, {
89
+ ...fix !== void 0 ? { fix } : {},
90
+ ...details !== void 0 ? { details } : {}
91
+ });
92
+ }
93
+ var SCOPE_KINDS = ["task", "category"];
94
+ var PREFERRED_KINDS = ["provider", "service", "source"];
95
+ var CAPABILITY_KINDS = ["category", "task"];
96
+ var WHO_KINDS = ["provider", "seller", "service"];
97
+ var helpFor = (operation) => `\`tenjin config ${operation} --help\` shows its flags and examples.`;
98
+ var one = (values) => values[0];
99
+ async function liveIdentities(ctx, deps) {
100
+ const { baseUrl } = await resolveFromContext(ctx);
101
+ const read = await fetchIdentities(ctx, {
102
+ baseUrl: baseUrl.value,
103
+ ...deps.fetchImpl !== void 0 ? { fetchImpl: deps.fetchImpl } : {}
104
+ });
105
+ if (!read.ok) {
106
+ throw new CliError(
107
+ read.unreachable === true ? "API_UNREACHABLE" : "NETWORK_ERROR",
108
+ `Tenjin couldn't look up those names right now, so nothing was saved. (${read.reason})`,
109
+ {
110
+ fix: "Try again in a moment. Showing your settings, pausing Tenjin, unblocking and resetting all work without the network."
111
+ }
112
+ );
113
+ }
114
+ return read.identities;
115
+ }
116
+ async function freshIdentities(ctx, deps) {
117
+ try {
118
+ return await liveIdentities(ctx, deps);
119
+ } catch {
120
+ return void 0;
121
+ }
122
+ }
123
+ var shown = (entries) => entries.map(({ id, label }) => label === id ? label : `${label} (${id})`).join(", ");
124
+ var suggested = (entries) => entries.map(({ id, label }) => folded(label) === folded(id) ? id : `${label} (${id})`).join(", ");
125
+ var article = (noun) => /^[aeiou]/.test(noun) ? `an ${noun}` : `a ${noun}`;
126
+ function elsewhereHint(name, elsewhere) {
127
+ if (elsewhere.length === 0) return [];
128
+ const nouns = elsewhere.map(({ kind }) => KIND_NOUN[kind]);
129
+ return [
130
+ `${shellWord(name)} is ${article(either.format(nouns))}: use ${either.format(elsewhere.map(flagFor))}.`
131
+ ];
132
+ }
133
+ function resolveAll(identities, wanted, allowed = TARGET_KINDS) {
134
+ const resolved = [];
135
+ for (const { kind, name } of wanted) {
136
+ const noun = KIND_NOUN[kind];
137
+ const found = resolveName(identities, kind, name);
138
+ if (found.status === "ambiguous") {
139
+ usage(
140
+ `"${name}" matches more than one ${noun}: ${shown(found.candidates)}. Nothing was saved.`,
141
+ "Run it again with the id in parentheses of the one meant.",
142
+ { kind, name, candidates: found.candidates }
143
+ );
144
+ }
145
+ if (found.status === "unknown") {
146
+ const elsewhere = found.elsewhere.filter((target) => allowed.includes(target.kind));
147
+ const names = namesCommand(name);
148
+ usage(
149
+ `Tenjin has no ${noun} named "${name}". Nothing was saved.`,
150
+ [
151
+ ...elsewhereHint(name, elsewhere),
152
+ ...elsewhere.length === 0 && found.candidates.length > 0 ? [`Did you mean: ${suggested(found.candidates)}?`] : [],
153
+ `See every name: ${names}`
154
+ ].join(" "),
155
+ { kind, name, candidates: found.candidates, elsewhere, names }
156
+ );
157
+ }
158
+ if (!resolved.some(({ target }) => targetKey(target) === targetKey(found.target))) {
159
+ resolved.push({ target: found.target, label: found.label });
160
+ }
161
+ }
162
+ return resolved;
163
+ }
164
+ function savedPolicyOf(existing) {
165
+ const raw = existing.router?.policy;
166
+ if (raw === void 0) return { version: POLICY_VERSION };
167
+ const parsed = SavedPolicySchema.safeParse(raw);
168
+ if (parsed.success) return parsed.data;
169
+ const [issue] = parsed.error.issues;
170
+ const problem = `router.policy.${(issue?.path ?? []).join(".")}: ${issue?.message ?? "invalid"}`;
171
+ throw new CliError("CONFIG_INVALID", `${POLICY_INVALID_TEXT} (${problem}) Nothing was changed.`, {
172
+ fix: "Clear the saved rules with `tenjin config reset --all`, then set them again.",
173
+ details: { problem }
174
+ });
175
+ }
176
+ function withPolicy(existing, policy) {
177
+ const router = { ...existing.router ?? {} };
178
+ delete router.policy;
179
+ const rules = wirePolicy(policy);
180
+ return {
181
+ ...existing,
182
+ router: {
183
+ ...router,
184
+ ...hasRules(rules) ? { policy: { version: policy.version, ...rules } } : {}
185
+ }
186
+ };
187
+ }
188
+ function upsert(rules, rule, slot) {
189
+ const saved = rules ?? [];
190
+ const replaced = saved.find((entry) => slot(entry) === slot(rule));
191
+ return {
192
+ next: replaced !== void 0 ? saved.map((entry) => entry === replaced ? rule : entry) : [...saved, rule],
193
+ replaced
194
+ };
195
+ }
196
+ function checkSavable(policy) {
197
+ const saved = SavedPolicySchema.safeParse(policy);
198
+ if (saved.success) return;
199
+ const [issue] = saved.error.issues;
200
+ throw new CliError(
201
+ "REFUSED",
202
+ `That change would leave settings Tenjin can't use (${issue?.message ?? "invalid"}). Nothing was saved.`,
203
+ {
204
+ fix: "Remove a rule you no longer need first: `tenjin config` shows what is saved.",
205
+ details: saved.error.issues
206
+ }
207
+ );
208
+ }
209
+ function refuseBlocked(targets, policy, identities) {
210
+ for (const target of targets) {
211
+ const block = blockedBy(target, policy, identities);
212
+ if (block !== void 0) conflict(target, block, identities);
213
+ }
214
+ }
215
+ function conflict(target, block, identities) {
216
+ const name = labelOf(target, identities);
217
+ const why = targetKey(target) === targetKey(block) ? `${name} is blocked in your settings` : `${name} is covered by your block on ${labelOf(block, identities)}`;
218
+ throw new CliError("REFUSED", `${why}, so it can't be chosen here. Nothing was saved.`, {
219
+ fix: `Blocks win over every other rule. To use it again, the user can run \`${unblockCommand(block)}\` first.`,
220
+ details: { target, block }
221
+ });
222
+ }
223
+ async function readBack(ctx, deps) {
224
+ const router = await routerSettings({ cwd: deps.cwd ?? process.cwd(), dataDir: ctx.dataDir });
225
+ const { maxAutoSpend, sessionBudget } = await resolveFromContext(ctx);
226
+ return {
227
+ router,
228
+ limits: describeLimits(maxAutoSpend.value, sessionBudget.value),
229
+ support: await replacementSupport(ctx.dataDir)
230
+ };
231
+ }
232
+ function replacementNote({ router, support }) {
233
+ if (router.nativeReplacement.mode === "off")
234
+ return `${REPLACEMENT_NAME} is off, and this doesn't turn it on.`;
235
+ return support.supported ? `${REPLACEMENT_NAME} is on, so this also holds for the searches and fetches Tenjin runs in place.` : `${REPLACEMENT_NAME} is on. ${support.why}`;
236
+ }
237
+ function replyLines(ctx, reply, reset, unreadable) {
238
+ const problems = [...reply.problems ?? [], ...unreadable].map(
239
+ (problem) => paint(ctx.io, "yellow", `! ${problem}`)
240
+ );
241
+ if (reply.done === void 0) return [...reply.said, ...problems];
242
+ return [
243
+ `${paint(ctx.io, "green", "\u2713")} ${reply.done}`,
244
+ ...reply.said.map((line) => ` ${line}`),
245
+ ...reset !== void 0 ? [` ${paint(ctx.io, "dim", `Undo: ${reset}`)}`] : [],
246
+ ...problems
247
+ ];
248
+ }
249
+ var sentence = (text) => text.charAt(0).toUpperCase() + text.slice(1);
250
+ async function answer(outcome, ctx, deps, identities, read) {
251
+ const { router, limits, support } = read ?? await readBack(ctx, deps);
252
+ const settings = settingsReadback(router, identities, limits, support);
253
+ const unreadable = router.policy.status === "invalid" ? [`${POLICY_INVALID_TEXT} ${router.policy.problem}.`] : [];
254
+ return {
255
+ data: {
256
+ operation: outcome.operation,
257
+ changed: outcome.changed,
258
+ saved: SAVED_HERE,
259
+ scope: outcome.scope,
260
+ ...outcome.rule !== void 0 ? { rule: outcome.rule } : {},
261
+ ...outcome.effective !== void 0 ? { effective: outcome.effective } : {},
262
+ ...outcome.removed !== void 0 ? { removed: outcome.removed } : {},
263
+ explanation: outcome.explanation.join(" "),
264
+ ...outcome.reset !== void 0 ? { reset: outcome.reset } : {},
265
+ ...outcome.extra,
266
+ settings: settings.data
267
+ },
268
+ humanLines: outcome.human !== void 0 ? replyLines(ctx, outcome.human, outcome.reset, unreadable) : [
269
+ ...outcome.explanation,
270
+ ...unreadable,
271
+ ...outcome.reset !== void 0 ? [`To undo: \`${outcome.reset}\``] : []
272
+ ]
273
+ };
274
+ }
275
+ var said = (rule) => rule.inactive !== void 0 ? `${rule.text} (${rule.inactive})` : rule.text;
276
+ async function runConfigPrefer(flags, ctx, deps = {}) {
277
+ if (flags.seller?.length) {
278
+ usage(
279
+ "A preference names providers, services or your accounts: use --provider, --service or --source.",
280
+ helpFor("prefer")
281
+ );
282
+ }
283
+ const kinds = ["provider", "service", "source"].filter((kind2) => flags[kind2]?.length);
284
+ if (kinds.length === 0)
285
+ usage("Name what to prefer with --provider, --service or --source.", helpFor("prefer"));
286
+ if (kinds.length > 1)
287
+ usage(
288
+ "One preference is one kind: providers, services or accounts. Run prefer once for the kind you mean."
289
+ );
290
+ const kind = one(kinds);
291
+ const tasks = flags.task ?? [];
292
+ const categories = flags.category ?? [];
293
+ if (tasks.length + categories.length > 1)
294
+ usage("A preference is for one task or one category: name it once.");
295
+ if (flags.global === true && tasks.length + categories.length > 0)
296
+ usage("--global and --task or --category name different scopes: use one.");
297
+ if (tasks.length + categories.length === 0 && kind !== "source") {
298
+ usage(
299
+ `A ${kind} preference is for one task or category: add --task "<task>" or --category <category>.`,
300
+ "Only your accounts can be preferred across every task (--source without --task)."
301
+ );
302
+ }
303
+ const identities = await liveIdentities(ctx, deps);
304
+ const where = tasks.length > 0 ? one(resolveAll(identities, [{ kind: "task", name: one(tasks) }], SCOPE_KINDS)) : categories.length > 0 ? one(resolveAll(identities, [{ kind: "category", name: one(categories) }], SCOPE_KINDS)) : void 0;
305
+ const targets = resolveAll(identities, wantedOf(flags, [kind]), PREFERRED_KINDS).map(
306
+ ({ target }) => target
307
+ );
308
+ const scope = where === void 0 ? { kind: "global" } : where.target.kind === "task" ? { kind: "task", id: where.target.id } : { kind: "category", id: where.target.id };
309
+ const rule = { scope, targets };
310
+ let after = { version: POLICY_VERSION };
311
+ let replaced;
312
+ await persist(ctx.dataDir, (existing) => {
313
+ const policy = savedPolicyOf(existing);
314
+ refuseBlocked(targets, policy, identities);
315
+ const prefer = upsert(policy.prefer, rule, (entry) => scopeKey(entry.scope));
316
+ replaced = prefer.replaced;
317
+ after = { ...policy, prefer: prefer.next };
318
+ checkSavable(after);
319
+ return withPolicy(existing, after);
320
+ });
321
+ const effective = describePrefer(rule, after, identities);
322
+ const read = await readBack(ctx, deps);
323
+ const summary = summarizeRule(effective, identities, read.router.accounts.saved);
324
+ const names = either.format(targets.map((target) => nameOf(target, identities)));
325
+ return answer(
326
+ {
327
+ operation: "prefer",
328
+ changed: true,
329
+ scope: "user",
330
+ rule,
331
+ explanation: [`${SAVED_PREFIX} ${said(effective)}`, replacementNote(read)],
332
+ human: {
333
+ done: `${summary.name} ${summary.does}`,
334
+ said: [
335
+ targets.every(({ kind: kind2 }) => kind2 === "source") ? `${targets.length === 1 ? "Its plan pays" : "Their plans pay"}. Other tools still run when ${names} can't do the job.` : `Other tools still run when ${names} can't do the job.`
336
+ ],
337
+ ...effective.inactive !== void 0 ? { problems: [sentence(effective.inactive)] } : {}
338
+ },
339
+ effective: [effective],
340
+ ...replaced !== void 0 ? { removed: [replaced] } : {},
341
+ // A replaced list comes back as it was; a new one is removed.
342
+ reset: replaced !== void 0 ? recreate(replaced) : preferResetCommand(scope)
343
+ },
344
+ ctx,
345
+ deps,
346
+ identities,
347
+ read
348
+ );
349
+ }
350
+ async function runConfigOnly(flags, ctx, deps = {}) {
351
+ if (flags.source?.length) {
352
+ usage(
353
+ 'There is no only for accounts: "only use my account for X" is a preference, `tenjin config prefer --category <X> --source <account>`. To stop Tenjin offering its own tools on its own: `tenjin config block --source tenjin`.'
354
+ );
355
+ }
356
+ const people = ["provider", "seller", "service"].filter((kind) => flags[kind]?.length);
357
+ if (people.length > 1) {
358
+ usage(
359
+ "One only rule limits one thing: providers, sellers or services. Run only once for each.",
360
+ helpFor("only")
361
+ );
362
+ }
363
+ let scope;
364
+ let dimension;
365
+ let wanted;
366
+ if (flags.global === true) {
367
+ const capability = wantedOf(flags, ["category", "task"]);
368
+ if (capability.length > 0 && people.length > 0) {
369
+ usage(
370
+ "Tasks and categories are one rule, providers, sellers or services another: run only once for each.",
371
+ helpFor("only")
372
+ );
373
+ }
374
+ if (capability.length === 0 && people.length === 0)
375
+ usage(
376
+ "Name what to allow: --category or --task, or --provider, --seller or --service.",
377
+ helpFor("only")
378
+ );
379
+ scope = { kind: "global" };
380
+ dimension = people.length > 0 ? one(people) : "capability";
381
+ wanted = people.length > 0 ? wantedOf(flags, people) : capability;
382
+ } else {
383
+ if (flags.category?.length) {
384
+ usage(
385
+ "A category rule limits which tasks Tenjin does anywhere: add --global.",
386
+ "tenjin config only --global --category images"
387
+ );
388
+ }
389
+ const tasks = flags.task ?? [];
390
+ if (tasks.length === 0 || people.length === 0) {
391
+ usage(
392
+ 'Say where the rule applies: --task "<task>" with --provider, --seller or --service limits who does that task; --global with --category or --task limits which tasks Tenjin does.',
393
+ helpFor("only")
394
+ );
395
+ }
396
+ if (tasks.length > 1) {
397
+ usage(
398
+ "A provider, seller or service rule is for one task: name it once, or use --global to limit which tasks Tenjin does."
399
+ );
400
+ }
401
+ dimension = one(people);
402
+ wanted = wantedOf(flags, people);
403
+ }
404
+ const identities = await liveIdentities(ctx, deps);
405
+ if (scope === void 0) {
406
+ const task = one(
407
+ resolveAll(identities, [{ kind: "task", name: one(flags.task ?? []) }], ["task"])
408
+ );
409
+ scope = { kind: "task", id: task.target.id };
410
+ }
411
+ const targets = resolveAll(
412
+ identities,
413
+ wanted,
414
+ dimension === "capability" ? CAPABILITY_KINDS : WHO_KINDS
415
+ ).map(({ target }) => target);
416
+ const rule = { scope, dimension, targets };
417
+ let after = { version: POLICY_VERSION };
418
+ let replaced;
419
+ await persist(ctx.dataDir, (existing) => {
420
+ const policy = savedPolicyOf(existing);
421
+ refuseBlocked(targets, policy, identities);
422
+ const only = upsert(policy.only, rule, onlyKey);
423
+ replaced = only.replaced;
424
+ after = { ...policy, only: only.next };
425
+ checkSavable(after);
426
+ return withPolicy(existing, after);
427
+ });
428
+ const effective = describeOnly(rule, after, identities);
429
+ const read = await readBack(ctx, deps);
430
+ const summary = summarizeRule(effective, identities);
431
+ return answer(
432
+ {
433
+ operation: "only",
434
+ changed: true,
435
+ scope: "user",
436
+ rule,
437
+ explanation: [`${SAVED_PREFIX} ${said(effective)}`, replacementNote(read)],
438
+ human: {
439
+ ...onlyReply(rule, summary, identities),
440
+ ...effective.inactive !== void 0 ? { problems: [sentence(effective.inactive)] } : {}
441
+ },
442
+ effective: [effective],
443
+ ...replaced !== void 0 ? { removed: [replaced] } : {},
444
+ reset: replaced !== void 0 ? recreate(replaced) : onlyResetCommand(rule)
445
+ },
446
+ ctx,
447
+ deps,
448
+ identities,
449
+ read
450
+ );
451
+ }
452
+ function onlyReply(rule, summary, identities) {
453
+ if (rule.dimension === "capability") {
454
+ const jobs = new Set(
455
+ rule.targets.flatMap(
456
+ (target) => target.kind === "category" ? tasksOf(target.id, identities) : [target.id]
457
+ )
458
+ );
459
+ return {
460
+ done: `Tenjin offers ${summary.short} on its own`,
461
+ said: [
462
+ `${jobs.size > 0 ? `${jobs.size} ${jobs.size === 1 ? "kind" : "kinds"} of job. ` : ""}Anything else still runs when you ask for it by name.`
463
+ ]
464
+ };
465
+ }
466
+ const global = rule.scope.kind === "global";
467
+ return {
468
+ done: global ? `Only ${summary.name}, for every job` : sentence(summary.short),
469
+ said: [
470
+ `If ${summary.name} can't do ${global ? "a job" : "it"}, Tenjin offers nothing for it. You can still ask for any tool by name.`
471
+ ]
472
+ };
473
+ }
474
+ async function runConfigBlock(flags, ctx, deps = {}) {
475
+ const wanted = wantedOf(flags);
476
+ if (wanted.length === 0) {
477
+ usage(
478
+ "Name what to block: --provider, --seller, --service, --task, --category or --source.",
479
+ helpFor("block")
480
+ );
481
+ }
482
+ const identities = await liveIdentities(ctx, deps);
483
+ const targets = resolveAll(identities, wanted).map(({ target }) => target);
484
+ let before = { version: POLICY_VERSION };
485
+ let after = { version: POLICY_VERSION };
486
+ const added = [];
487
+ await persist(ctx.dataDir, (existing) => {
488
+ const policy = savedPolicyOf(existing);
489
+ before = policy;
490
+ const saved = new Set((policy.block ?? []).map(targetKey));
491
+ added.push(...targets.filter((target) => !saved.has(targetKey(target))));
492
+ if (added.length === 0) return existing;
493
+ after = { ...policy, block: [...policy.block ?? [], ...added] };
494
+ checkSavable(after);
495
+ return withPolicy(existing, after);
496
+ });
497
+ const read = await readBack(ctx, deps);
498
+ const accounts = connectedLabels(read.router);
499
+ const effective = targets.map((target) => describeBlock(target, identities, accounts));
500
+ const wasActive = new Set(
501
+ describeRules(before, identities).filter(({ inactive }) => inactive === void 0).map(({ rule }) => JSON.stringify(rule))
502
+ );
503
+ const nowInactive = added.length === 0 ? [] : describeRules(after, identities).filter(
504
+ ({ kind, inactive, rule }) => kind !== "block" && inactive !== void 0 && wasActive.has(JSON.stringify(rule))
505
+ );
506
+ const fresh = new Set(added.map(targetKey));
507
+ const already = targets.filter((target) => !fresh.has(targetKey(target))).map((target) => `${blockName(target, identities)} was already blocked.`);
508
+ const human = added.length === 0 ? { said: already.map(sentence) } : {
509
+ done: `Blocked ${list.format(added.map((target) => blockName(target, identities)))}`,
510
+ said: [blockMeans(added, identities, accounts), ...already.map(sentence)],
511
+ problems: nowInactive.map(
512
+ (rule) => `This makes a saved rule inactive: ${summarizeRule(rule, identities, read.router.accounts.saved).short}`
513
+ )
514
+ };
515
+ const explanation = [
516
+ ...added.map((target) => describeBlock(target, identities, accounts).text).map((text, index) => index === 0 ? `${SAVED_PREFIX} ${text}` : text),
517
+ ...targets.filter((target) => !fresh.has(targetKey(target))).map((target) => `${labelOf(target, identities)} was already blocked.`),
518
+ ...nowInactive.map(
519
+ (rule) => `This leaves a saved rule unusable, kept as it is: ${rule.text} (${rule.inactive})`
520
+ )
521
+ ];
522
+ return answer(
523
+ {
524
+ operation: "block",
525
+ changed: added.length > 0,
526
+ scope: "user",
527
+ rule: added,
528
+ explanation,
529
+ human,
530
+ effective,
531
+ ...added.length > 0 ? { reset: added.map((target) => unblockCommand(target)).join(" && ") } : {},
532
+ extra: { inactive: nowInactive }
533
+ },
534
+ ctx,
535
+ deps,
536
+ identities,
537
+ read
538
+ );
539
+ }
540
+ function blockName(target, identities) {
541
+ if (target.kind !== "source") return labelOf(target, identities);
542
+ return target.id === BUILT_IN_SOURCE ? "Tenjin's own tools" : `your ${labelOf(target, identities)} account`;
543
+ }
544
+ function blockMeans(added, identities, accounts) {
545
+ const BY_NAME = "You can still ask for one by name.";
546
+ if (added.length > 1) return `Tenjin won't offer them on its own. ${BY_NAME}`;
547
+ const target = added[0];
548
+ if (target.kind === "source" && target.id === BUILT_IN_SOURCE) {
549
+ return accounts.length > 0 ? `Tenjin now offers only your ${list.format(accounts)} ${accounts.length === 1 ? "account" : "accounts"}. Ask for one of Tenjin's tools by name to use it.` : "With no connected accounts, Tenjin offers nothing on its own for now. Ask for a tool by name to use it.";
550
+ }
551
+ if (target.kind === "category") {
552
+ const jobs = tasksOf(target.id, identities).length;
553
+ return `Tenjin won't offer ${jobs > 0 ? `its ${jobs} kinds of job` : "anything in it"} on its own, or any added later. You can still ask by name.`;
554
+ }
555
+ if (target.kind === "task")
556
+ return "Tenjin won't offer it on its own, whoever could do it. You can still ask by name.";
557
+ const tools = target.kind === "source" ? 0 : servicesNaming(target, identities).length;
558
+ return tools > 1 ? `Tenjin won't offer its ${tools} tools on its own. ${BY_NAME}` : "Tenjin won't offer it on its own. You can still ask for it by name.";
559
+ }
560
+ function savedMatch(wanted, saved, identities) {
561
+ const ofKind = saved.filter(({ kind }) => kind === wanted.kind);
562
+ const direct = ofKind.find(({ id }) => id === wanted.name) ?? ofKind.find(({ id }) => folded(id) === folded(wanted.name));
563
+ if (direct !== void 0) return direct;
564
+ const entries = entriesOf(identities, wanted.kind);
565
+ for (const same of [folded, normalised]) {
566
+ const typed = same(wanted.name);
567
+ const ids = new Set(entries.filter(({ label }) => same(label) === typed).map(({ id }) => id));
568
+ const matches = ofKind.filter(({ id }) => same(id) === typed || ids.has(id));
569
+ if (matches.length === 1) return matches[0];
570
+ if (matches.length > 1) return void 0;
571
+ }
572
+ return void 0;
573
+ }
574
+ async function runConfigUnblock(flags, ctx, deps = {}) {
575
+ const wanted = wantedOf(flags);
576
+ if (wanted.length === 0) {
577
+ usage(
578
+ "Name what to unblock: --provider, --seller, --service, --task, --category or --source.",
579
+ helpFor("unblock")
580
+ );
581
+ }
582
+ const identities = await cachedIdentities(ctx.dataDir);
583
+ const removed = [];
584
+ const missing = [];
585
+ let remaining = [];
586
+ await persist(ctx.dataDir, (existing) => {
587
+ const policy = savedPolicyOf(existing);
588
+ const saved = policy.block ?? [];
589
+ for (const name of wanted) {
590
+ const match = savedMatch(name, saved, identities);
591
+ if (match === void 0) missing.push(name);
592
+ else if (!removed.includes(match)) removed.push(match);
593
+ }
594
+ remaining = saved.filter((target) => !removed.includes(target));
595
+ return removed.length === 0 ? existing : withPolicy(existing, { ...policy, block: remaining });
596
+ });
597
+ const names = removed.map((target) => labelOf(target, identities));
598
+ const explanation = [
599
+ ...removed.length > 0 ? [
600
+ `${SAVED_PREFIX} ${list.format(names)} ${removed.length === 1 ? "is" : "are"} no longer blocked. Your other rules stay as they are.`
601
+ ] : [],
602
+ ...missing.map(
603
+ ({ kind, name }) => `Nothing saved blocks a ${KIND_NOUN[kind]} named "${name}", so nothing changed for it.`
604
+ ),
605
+ ...missing.length > 0 && remaining.length > 0 ? [`Saved blocks: ${remaining.map((target) => labelOf(target, identities)).join(", ")}.`] : []
606
+ ];
607
+ const nothing = missing.map(
608
+ ({ kind, name }) => `Nothing blocks a ${KIND_NOUN[kind]} named "${name}".`
609
+ );
610
+ const human = removed.length === 0 ? { said: [...nothing, "Nothing changed."] } : {
611
+ done: `Unblocked ${list.format(removed.map((target) => blockName(target, identities)))}`,
612
+ said: [
613
+ `Tenjin can offer ${removed.length === 1 ? "it" : "them"} on its own again.`,
614
+ ...nothing
615
+ ]
616
+ };
617
+ return answer(
618
+ {
619
+ operation: "unblock",
620
+ changed: removed.length > 0,
621
+ scope: "user",
622
+ rule: removed,
623
+ explanation,
624
+ human,
625
+ removed,
626
+ ...removed.length > 0 ? { reset: `tenjin config block ${removed.map((target) => flagFor(target)).join(" ")}` } : {},
627
+ extra: { missing }
628
+ },
629
+ ctx,
630
+ deps,
631
+ identities
632
+ );
633
+ }
634
+ function savedScope(wanted, scopes, identities) {
635
+ const typed = scopes.flatMap(
636
+ (scope) => scope.kind === wanted.kind ? [{ kind: wanted.kind, id: scope.id }] : []
637
+ );
638
+ const match = savedMatch(wanted, typed, identities);
639
+ if (match === void 0) return void 0;
640
+ return match.kind === "task" ? { kind: "task", id: match.id } : { kind: "category", id: match.id };
641
+ }
642
+ async function runConfigReset(flags, ctx, deps = {}) {
643
+ const modes = ["all", "preference", "restriction", "capabilities"].filter(
644
+ (mode2) => flags[mode2] === true
645
+ );
646
+ if (modes.length !== 1) {
647
+ usage(
648
+ "Say what to reset: --preference, --restriction, --capabilities or --all.",
649
+ 'tenjin config reset --task "web research" --preference'
650
+ );
651
+ }
652
+ const mode = one(modes);
653
+ const scopes = wantedOf(flags, ["task", "category"]);
654
+ const targets = wantedOf(flags, ["provider", "service", "source", "seller"]);
655
+ if (scopes.length > 1) usage("Reset one scope at a time: name one task or one category.");
656
+ if (flags.global === true && scopes.length > 0)
657
+ usage("--global and --task or --category name different scopes: use one.");
658
+ if (flags.dimension !== void 0 && mode !== "restriction")
659
+ usage("--dimension goes with --restriction.");
660
+ const dimension = flags.dimension;
661
+ if (dimension !== void 0 && !ONLY_DIMENSIONS.includes(dimension)) {
662
+ usage(
663
+ `--dimension is one of ${ONLY_DIMENSIONS.join(", ")}; got "${flags.dimension}".`,
664
+ 'tenjin config reset --task "web research" --restriction --dimension provider'
665
+ );
666
+ }
667
+ if (mode === "all" && (scopes.length > 0 || targets.length > 0 || flags.global === true))
668
+ usage("--all resets every saved routing rule and takes nothing else.");
669
+ if (mode === "capabilities" && (scopes.length > 0 || targets.length > 0))
670
+ usage("--capabilities resets the global task and category limit and takes nothing else.");
671
+ if (mode === "restriction") {
672
+ if (targets.length > 0)
673
+ usage("--restriction resets a whole rule: name its scope and, optionally, --dimension.");
674
+ if (scopes.some(({ kind }) => kind === "category"))
675
+ usage("A restriction is global or for one task: use --task or --global.");
676
+ if (scopes.length === 0 && flags.global !== true)
677
+ usage('Say which restriction: --task "<task>" or --global.', helpFor("reset"));
678
+ }
679
+ if (mode === "preference") {
680
+ if (targets.some(({ kind }) => kind === "seller"))
681
+ usage("A preference holds providers, services or accounts.");
682
+ if (scopes.length === 0 && flags.global !== true && targets.length === 0)
683
+ usage(
684
+ 'Say which preference: --task "<task>", --category <category>, --global, or --source <account>.',
685
+ helpFor("reset")
686
+ );
687
+ }
688
+ const identities = await cachedIdentities(ctx.dataDir);
689
+ const removed = [];
690
+ const touched = [];
691
+ let missing;
692
+ await persist(ctx.dataDir, (existing) => {
693
+ if (mode === "all") {
694
+ const { policy: gone, ...router } = existing.router ?? {};
695
+ if (gone === void 0) {
696
+ missing = "There are no saved routing rules to reset.";
697
+ return existing;
698
+ }
699
+ removed.push(gone);
700
+ return { ...existing, router };
701
+ }
702
+ const policy = savedPolicyOf(existing);
703
+ const only = policy.only ?? [];
704
+ const prefer = policy.prefer ?? [];
705
+ const named = scopes.length > 0 ? one(scopes) : void 0;
706
+ if (mode === "capabilities" || mode === "restriction") {
707
+ const scope2 = mode === "capabilities" || flags.global === true ? { kind: "global" } : named !== void 0 ? savedScope(
708
+ named,
709
+ only.map(({ scope: s }) => s),
710
+ identities
711
+ ) : void 0;
712
+ const want = mode === "capabilities" ? "capability" : dimension;
713
+ const drop2 = only.filter(
714
+ (entry2) => scope2 !== void 0 && scopeKey(entry2.scope) === scopeKey(scope2) && (want === void 0 || entry2.dimension === want)
715
+ );
716
+ if (drop2.length === 0) {
717
+ const where = scope2?.kind === "task" ? labelOf({ kind: "task", id: scope2.id }, identities) : named?.name ?? "every task";
718
+ missing = mode === "capabilities" ? "There is no saved limit on which tasks Tenjin does to reset." : `There is no saved ${want !== void 0 ? `${want} ` : ""}restriction for ${where} to reset.`;
719
+ return existing;
720
+ }
721
+ removed.push(...drop2);
722
+ touched.push(...drop2);
723
+ return withPolicy(existing, {
724
+ ...policy,
725
+ only: only.filter((entry2) => !drop2.includes(entry2))
726
+ });
727
+ }
728
+ const scope = named !== void 0 ? savedScope(
729
+ named,
730
+ prefer.map(({ scope: s }) => s),
731
+ identities
732
+ ) : { kind: "global" };
733
+ const entry = scope === void 0 ? void 0 : prefer.find((candidate) => scopeKey(candidate.scope) === scopeKey(scope));
734
+ if (entry === void 0) {
735
+ missing = named !== void 0 ? `There is no saved preference for ${named.name} to reset.` : "There is no saved account-wide preference to reset.";
736
+ return existing;
737
+ }
738
+ touched.push(entry);
739
+ if (targets.length === 0) {
740
+ removed.push(entry);
741
+ return withPolicy(existing, { ...policy, prefer: prefer.filter((rule) => rule !== entry) });
742
+ }
743
+ const drop = targets.flatMap((name) => savedMatch(name, entry.targets, identities) ?? []);
744
+ if (drop.length === 0) {
745
+ touched.length = 0;
746
+ missing = `${targets.map(({ name }) => name).join(", ")} ${targets.length === 1 ? "is" : "are"} not in that preference.`;
747
+ return existing;
748
+ }
749
+ removed.push(...drop);
750
+ const kept = entry.targets.filter((target) => !drop.includes(target));
751
+ return withPolicy(existing, {
752
+ ...policy,
753
+ prefer: kept.length === 0 ? prefer.filter((rule) => rule !== entry) : prefer.map((rule) => rule === entry ? { ...entry, targets: kept } : rule)
754
+ });
755
+ });
756
+ const explanation = missing !== void 0 ? [`${missing} Nothing changed.`] : mode === "all" ? [
757
+ `${SAVED_PREFIX} removed every saved routing rule, including your blocks, restrictions, preferences and the speed setting, so anything you blocked can be used again. ${REPLACEMENT_NAME} and your spending limits stay as they are.`
758
+ ] : [
759
+ `${SAVED_PREFIX} removed ${describeRemoved(mode, removed, identities)}. Your blocks, limits and other rules stay as they are.`
760
+ ];
761
+ const human = missing !== void 0 ? { said: [`${missing} Nothing changed.`] } : mode === "all" ? {
762
+ done: "Removed all your rules",
763
+ said: ["Automatic picks and your limits are unchanged."]
764
+ } : {
765
+ done: `Removed ${describeRemoved(mode, removed, identities)}`,
766
+ said: ["Your other rules are unchanged."]
767
+ };
768
+ return answer(
769
+ {
770
+ operation: "reset",
771
+ changed: missing === void 0,
772
+ scope: "user",
773
+ explanation,
774
+ human,
775
+ removed,
776
+ ...missing === void 0 && touched.length > 0 ? { reset: touched.map((rule) => recreate(rule)).join(" && ") } : {}
777
+ },
778
+ ctx,
779
+ deps,
780
+ identities
781
+ );
782
+ }
783
+ function recreate(rule) {
784
+ const targets = rule.targets.map((target) => flagFor(target)).join(" ");
785
+ if ("dimension" in rule) return `tenjin config only ${scopeFlag(rule.scope)} ${targets}`;
786
+ const where = rule.scope.kind === "global" ? "" : scopeFlag(rule.scope);
787
+ return ["tenjin config prefer", where, targets].filter((part) => part.length > 0).join(" ");
788
+ }
789
+ function describeRemoved(mode, removed, identities) {
790
+ if (mode === "preference") {
791
+ const [first] = removed;
792
+ if (first !== null && typeof first === "object" && "scope" in first) {
793
+ const rule = first;
794
+ return rule.scope.kind === "global" ? "your account-wide preference" : `your preference for ${labelOf({ kind: rule.scope.kind, id: rule.scope.id }, identities)}`;
795
+ }
796
+ return `${list.format(removed.map((target) => labelOf(target, identities)))} from that preference`;
797
+ }
798
+ return list.format(
799
+ removed.map((rule) => {
800
+ const where = rule.scope.kind === "global" ? "" : ` for ${labelOf({ kind: rule.scope.kind, id: rule.scope.id }, identities)}`;
801
+ return rule.dimension === "capability" ? "the limit on which tasks Tenjin does" : `the ${rule.dimension} restriction${where}`;
802
+ })
803
+ );
804
+ }
805
+ async function runConfigSpeed(args, ctx, deps = {}) {
806
+ if (args.state !== "on" && args.state !== "off")
807
+ usage(`speed takes on or off; got "${args.state}".`, "tenjin config speed on");
808
+ const on = args.state === "on";
809
+ let was = false;
810
+ await persist(ctx.dataDir, (existing) => {
811
+ const policy = savedPolicyOf(existing);
812
+ was = policy.preferSpeed === true;
813
+ if (was === on) return existing;
814
+ const next = { ...policy };
815
+ if (on) next.preferSpeed = true;
816
+ else delete next.preferSpeed;
817
+ return withPolicy(existing, next);
818
+ });
819
+ const changed = was !== on;
820
+ const identities = on ? await freshIdentities(ctx, deps) ?? await cachedIdentities(ctx.dataDir) : await cachedIdentities(ctx.dataDir);
821
+ const effective = describeSpeed(identities);
822
+ const explanation = on ? [`${SAVED_PREFIX} ${effective.text}`] : [
823
+ `${SAVED_PREFIX} Tenjin offers a paid tool only when your agent's own tools can't do the job as well. Your other rules stay as they are.`
824
+ ];
825
+ const marked = speedTasks(identities)?.map(
826
+ (label) => label.charAt(0).toLowerCase() + label.slice(1)
827
+ );
828
+ const human = !changed ? { said: [`Speed is already ${on ? "on" : "off"}.`] } : on ? {
829
+ done: "Speed on",
830
+ said: [
831
+ marked === void 0 ? "Tenjin also offers faster paid tools where they're as accurate. Your limits still apply." : marked.length === 0 ? "No jobs are marked faster yet, so nothing changes for now." : `Tenjin also offers faster paid tools for ${list.format(marked)}. Your limits still apply.`
832
+ ]
833
+ } : {
834
+ done: "Speed off",
835
+ said: ["Tenjin offers a paid tool only when your agent's own can't do the job as well."]
836
+ };
837
+ return answer(
838
+ {
839
+ operation: "speed",
840
+ changed,
841
+ scope: "user",
842
+ rule: { preferSpeed: on },
843
+ explanation,
844
+ human,
845
+ ...on ? { effective: [effective] } : {},
846
+ // Only a change has an undo, and it puts the switch back as it was.
847
+ ...changed ? { reset: `tenjin config speed ${was ? "on" : "off"}` } : {}
848
+ },
849
+ ctx,
850
+ deps,
851
+ identities
852
+ );
853
+ }
854
+ function restoreReplacement(before) {
855
+ if (before.mode === "off") return "tenjin config replacement off";
856
+ return before.providers !== void 0 ? `tenjin config replacement on ${before.providers.map((target) => flagFor(target)).join(" ")}` : "tenjin config replacement on --all-providers";
857
+ }
858
+ async function runConfigReplacement(args, ctx, deps = {}) {
859
+ const providers = args.provider ?? [];
860
+ if (args.state !== "on" && args.state !== "off")
861
+ usage(`replacement takes on or off; got "${args.state}".`, "tenjin config replacement off");
862
+ if (args.state === "off" && (providers.length > 0 || args.allProviders === true))
863
+ usage("replacement off takes nothing else; a saved provider choice is kept.");
864
+ if (args.state === "on" && providers.length > 0 === (args.allProviders === true)) {
865
+ usage(
866
+ "Say which providers: --provider <provider> (repeatable), or --all-providers for any allowed provider.",
867
+ "tenjin config replacement on --provider exa"
868
+ );
869
+ }
870
+ const narrowed = args.state === "on" && providers.length > 0;
871
+ const identities = narrowed ? await liveIdentities(ctx, deps) : await cachedIdentities(ctx.dataDir);
872
+ const scope = narrowed && identities !== void 0 ? resolveAll(
873
+ identities,
874
+ providers.map((name) => ({ kind: "provider", name: name.trim() })),
875
+ ["provider"]
876
+ ).map(({ target }) => target) : void 0;
877
+ if (scope !== void 0 && !ReplacementProvidersSchema.safeParse(scope).success) {
878
+ usage(
879
+ `Automatic use can be narrowed to at most ${SETTINGS_LIMITS.targets} providers; that names ${scope.length}. Nothing was saved.`,
880
+ "Name fewer providers, or use --all-providers for any allowed provider.",
881
+ { limit: SETTINGS_LIMITS.targets, providers: scope }
882
+ );
883
+ }
884
+ let before = { mode: "off" };
885
+ let after = { mode: "off" };
886
+ await persist(ctx.dataDir, (existing) => {
887
+ const router2 = { ...existing.router ?? {} };
888
+ before = readPersonalRouter(router2).nativeReplacement;
889
+ if (args.state === "off") {
890
+ router2.nativeReplacement = "off";
891
+ if (router2.nativeReplacementProviders !== void 0 && !ReplacementProvidersSchema.safeParse(router2.nativeReplacementProviders).success) {
892
+ delete router2.nativeReplacementProviders;
893
+ }
894
+ } else {
895
+ if (scope !== void 0) {
896
+ const policy = SavedPolicySchema.safeParse(router2.policy);
897
+ refuseBlocked(scope, policy.success ? policy.data : {}, identities);
898
+ router2.nativeReplacementProviders = scope;
899
+ } else {
900
+ delete router2.nativeReplacementProviders;
901
+ }
902
+ router2.nativeReplacement = "when-routed";
903
+ }
904
+ after = readPersonalRouter(router2).nativeReplacement;
905
+ return JSON.stringify(after) === JSON.stringify(before) ? existing : { ...existing, router: router2 };
906
+ });
907
+ const changed = JSON.stringify(after) !== JSON.stringify(before);
908
+ const read = await readBack(ctx, deps);
909
+ const { router, support, limits } = read;
910
+ const effective = describeReplacement(router.nativeReplacement, identities, support);
911
+ const explanation = args.state === "off" ? [
912
+ `${SAVED_PREFIX} ${effective.text} Tenjin's offers and the requests you make stay available; to stop Tenjin altogether, run \`tenjin config set router.enabled false\`.`
913
+ ] : [
914
+ `${SAVED_PREFIX} ${REPLACEMENT_NAME} is on${scope !== void 0 ? `, only when Tenjin picks ${either.format(scope.map((target) => labelOf(target, identities)))}` : " for any allowed provider"}.`,
915
+ "When Tenjin picks a service for a web search or page fetch your agent is about to make, it runs that pick in place of the search or fetch instead of offering it first, so each one is a charge you are not asked about separately. Each one names the service, its price and the search or fetch it answered.",
916
+ `Your limits still apply (${limits.perCall} a call, ${limits.daily === null ? "no daily limit" : `${limits.daily} a day`}, Tenjin balance): a call over them is not run in place; it is offered as usual and asks first.`,
917
+ accountsNote(router, scope !== void 0),
918
+ "This picks no provider ahead of another and changes nothing about what is allowed: add a preference or a rule for that.",
919
+ support.why
920
+ ];
921
+ const named = scope !== void 0 ? `, only for ${either.format(scope.map((target) => labelOf(target, identities)))}` : "";
922
+ const human = !changed ? { said: [`Automatic picks are already ${args.state}.`] } : args.state === "on" ? {
923
+ done: `Automatic picks on${named}`,
924
+ said: [
925
+ "In Claude Code, Tenjin now runs its pick in place of a web search or page fetch, and says what it ran and what it cost. Your limits still apply."
926
+ ]
927
+ } : { done: "Automatic picks off", said: ["Tenjin goes back to offering its picks first."] };
928
+ return answer(
929
+ {
930
+ operation: "replacement",
931
+ changed,
932
+ human,
933
+ scope: "machine",
934
+ rule: {
935
+ mode: router.nativeReplacement.mode,
936
+ ...router.nativeReplacement.providers !== void 0 ? { providers: router.nativeReplacement.providers } : {}
937
+ },
938
+ explanation,
939
+ // Off before and after is the same behaviour (a repair of an unreadable
940
+ // value, say): there is nothing to put back.
941
+ ...changed && (before.mode !== "off" || after.mode !== "off") ? { reset: restoreReplacement(before) } : {},
942
+ extra: { replacement: effective }
943
+ },
944
+ ctx,
945
+ deps,
946
+ identities,
947
+ read
948
+ );
949
+ }
950
+ function accountsNote(router, narrowed) {
951
+ const names = router.accounts.saved.filter((account) => account.mapped === true && router.accounts.connected.includes(account.id)).map(({ label }) => label);
952
+ const within = narrowed ? " within the same provider choice" : "";
953
+ if (names.length === 0)
954
+ return `An account you connect with \`tenjin connect\` runs this way too${within}, and its own plan pays, not the Tenjin balance.`;
955
+ const yours = `your ${new Intl.ListFormat("en", { type: "conjunction" }).format(names)} ${names.length === 1 ? "account" : "accounts"}`;
956
+ return `It also runs ${yours} this way${within}: those calls bill your own plan, not the Tenjin balance, and don't count toward these limits.`;
957
+ }
958
+ async function runConfigFallback(args, ctx, deps = {}) {
959
+ if (args.state !== "on" && args.state !== "off")
960
+ usage(
961
+ `fallback takes on or off; got "${args.state}".`,
962
+ "tenjin config fallback on --source apify"
963
+ );
964
+ const names = (args.source ?? []).map((name) => name.trim()).filter((name) => name.length > 0);
965
+ if (names.length !== 1)
966
+ usage("Name one connected account with --source.", "tenjin config fallback on --source apify");
967
+ const wanted = names[0].toLowerCase();
968
+ const find = (router) => savedAccountsIn(router).find(
969
+ (account) => account.id === wanted || account.label.toLowerCase() === wanted
970
+ );
971
+ const before = find((await loadRawConfig(ctx.dataDir)).router);
972
+ if (before === void 0) {
973
+ usage(
974
+ `"${names[0]}" isn't one of your connected accounts, so nothing was saved.`,
975
+ "Connect it first with `tenjin connect <name>`."
976
+ );
977
+ }
978
+ const on = args.state === "on";
979
+ await persist(
980
+ ctx.dataDir,
981
+ (existing) => editSources(
982
+ existing,
983
+ (saved) => saved.map((entry) => {
984
+ if (entry.id !== before.id) return entry;
985
+ const next = { ...entry };
986
+ if (on) next.onRefusal = "tenjin";
987
+ else delete next.onRefusal;
988
+ return next;
989
+ })
990
+ )
991
+ );
992
+ const after = find((await loadRawConfig(ctx.dataDir)).router) ?? before;
993
+ const { label, id } = after;
994
+ const changed = before.onRefusal === "tenjin" !== on;
995
+ const human = !changed ? { said: [`Fallback is already ${args.state} for ${label}.`] } : on ? {
996
+ done: `Fallback on for ${label}`,
997
+ said: [
998
+ `When ${label} refuses a call, Tenjin's own tool runs instead, on your Tenjin balance.`
999
+ ]
1000
+ } : {
1001
+ done: `Fallback off for ${label}`,
1002
+ said: [
1003
+ `When ${label} refuses a call, Tenjin offers its own tool and runs it only when you say so.`
1004
+ ]
1005
+ };
1006
+ const explanation = on ? [
1007
+ `${SAVED_PREFIX} when your ${label} account refuses a call (its sign-in expired, or its plan or rate limit ran out), Tenjin runs its own tool for the same job instead. It is paid from your Tenjin balance within your limits, and the receipt says so.`,
1008
+ `A call your ${label} account ran and then failed is never run again on Tenjin's tool: your ${label} plan may already have paid for it.`
1009
+ ] : [
1010
+ `${SAVED_PREFIX} when your ${label} account refuses a call, Tenjin stops and offers its own tool for the job with its price, and runs it only when you say so.`
1011
+ ];
1012
+ return answer(
1013
+ {
1014
+ operation: "fallback",
1015
+ changed,
1016
+ scope: "user",
1017
+ explanation,
1018
+ human,
1019
+ ...on ? { reset: `tenjin config fallback off --source ${id}` } : {},
1020
+ extra: { account: { id, label, onRefusal: on ? "tenjin" : "ask" } }
1021
+ },
1022
+ ctx,
1023
+ deps,
1024
+ await cachedIdentities(ctx.dataDir)
1025
+ );
1026
+ }
1027
+
1028
+ export {
1029
+ answer,
1030
+ runConfigPrefer,
1031
+ runConfigOnly,
1032
+ runConfigBlock,
1033
+ runConfigUnblock,
1034
+ runConfigReset,
1035
+ runConfigSpeed,
1036
+ runConfigReplacement,
1037
+ runConfigFallback
1038
+ };
1039
+ //# sourceMappingURL=chunk-XWROSMI5.js.map