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,982 @@
1
+ import { createRequire as __tenjinCreateRequire } from 'node:module'; const require = __tenjinCreateRequire(import.meta.url);
2
+ import {
3
+ isLoopbackHost
4
+ } from "./chunk-DIH2G3YG.js";
5
+ import {
6
+ MAX_BINARY_BODY_BYTES,
7
+ fetchFailureToCliError,
8
+ httpRequest
9
+ } from "./chunk-D6M3ZK66.js";
10
+ import {
11
+ BUILT_IN_SOURCE,
12
+ SETTINGS_ACCEPT,
13
+ SettingsHashSchema,
14
+ TargetIdSchema
15
+ } from "./chunk-RGCPELQN.js";
16
+ import {
17
+ external_exports
18
+ } from "./chunk-P6YQWIT2.js";
19
+
20
+ // src/router/decision.ts
21
+ var ROUTER_PATH = "/api/x402-router";
22
+ var ROUTE_PAID_PATH = "/api/x402-router/route";
23
+ var RequestSchema = external_exports.object({
24
+ url: external_exports.string().min(1).max(16384),
25
+ method: external_exports.enum(["GET", "POST", "PUT", "PATCH", "DELETE", "HEAD", "OPTIONS"]),
26
+ headers: external_exports.record(external_exports.string(), external_exports.string()),
27
+ body: external_exports.string().max(256 * 1024).optional()
28
+ });
29
+ var ContractSchema = external_exports.object({
30
+ /** Flat, for display and for the result check; never re-encoded into a call:
31
+ * the server built `request` from them and this client sends that verbatim. */
32
+ arguments: external_exports.record(external_exports.string(), external_exports.unknown()).optional(),
33
+ resultSchema: external_exports.record(external_exports.string(), external_exports.unknown()).optional(),
34
+ request: RequestSchema
35
+ });
36
+ var DiagnosticsSchema = external_exports.object({
37
+ reasonCode: external_exports.string().min(1).max(64),
38
+ stage: external_exports.string().min(1).max(32),
39
+ missing: external_exports.array(external_exports.string().max(200)).max(60),
40
+ nextAction: external_exports.string().max(500)
41
+ });
42
+ var IdSchema = external_exports.string().regex(/^[A-Za-z0-9_-]{8,64}$/).describe(
43
+ "The turn id, an OPAQUE HANDLE: it is the one piece of server text this client puts in a model-facing line, so the alphabet is pinned here rather than escaped later."
44
+ );
45
+ var RefusedSchema = external_exports.object({
46
+ reason: external_exports.string().max(2e3).optional(),
47
+ diagnostics: DiagnosticsSchema
48
+ });
49
+ var LabelSchema = external_exports.string().min(1).max(32);
50
+ var UNLABELLED = "Tenjin lookup";
51
+ var RequiresSchema = external_exports.array(external_exports.string().regex(/^[a-z][a-z0-9_-]{0,31}$/)).max(16).optional();
52
+ var CapabilityFields = {
53
+ capabilityId: external_exports.string().min(1).max(200),
54
+ category: external_exports.string().min(1).max(64),
55
+ /** The service's own name, not the x402 reseller in front of it. */
56
+ provider: external_exports.string().min(1).max(120),
57
+ label: LabelSchema.optional(),
58
+ capabilityDescription: external_exports.string().min(1).max(500),
59
+ /** What the provider charges, atomic USDC. The `request` tool refuses a live
60
+ * 402 above it; `gateSpend` still caps the amount actually signed. */
61
+ providerPriceAtomic: external_exports.string().regex(/^\d+$/),
62
+ requires: RequiresSchema
63
+ };
64
+ function checkHint(decision, ctx) {
65
+ if (/[\p{Cc}\p{Cf}]/u.test(decision.hint)) {
66
+ ctx.addIssue({ code: "custom", path: ["hint"], message: "a hint is one plain line" });
67
+ }
68
+ if (!decision.hint.includes("request({")) {
69
+ ctx.addIssue({ code: "custom", path: ["hint"], message: "a hint names the call to make" });
70
+ }
71
+ if (!decision.hint.includes(decision.id)) {
72
+ ctx.addIssue({
73
+ code: "custom",
74
+ path: ["hint"],
75
+ message: "a hint carries this answer's own id"
76
+ });
77
+ }
78
+ }
79
+ var DiscoveredCandidateSchema = external_exports.object({
80
+ source: external_exports.string().min(1).max(64),
81
+ provider: external_exports.string().min(1).max(120),
82
+ url: external_exports.string().min(1).max(2048),
83
+ method: external_exports.enum(["GET", "POST"]),
84
+ description: external_exports.string().max(500),
85
+ providerPriceAtomic: external_exports.string().regex(/^\d+$/),
86
+ network: external_exports.string().min(1).max(64),
87
+ payTo: external_exports.string().min(1).max(200),
88
+ input: external_exports.object({
89
+ location: external_exports.enum(["body", "query"]),
90
+ schema: external_exports.record(external_exports.string(), external_exports.unknown())
91
+ })
92
+ });
93
+ var OtherArm = external_exports.never().optional();
94
+ var JobField = external_exports.string().regex(/^[A-Za-z_][A-Za-z0-9_]{0,63}$/);
95
+ var JobFieldStateSchema = external_exports.object({
96
+ field: JobField,
97
+ values: external_exports.array(external_exports.string().min(1).max(64)).min(1).max(8)
98
+ });
99
+ var POLL_REFERENCE = /^\$(input|result)\.([A-Za-z_][A-Za-z0-9_]{0,63})$/;
100
+ var JobSchema = external_exports.object({
101
+ pollUrl: external_exports.union([
102
+ external_exports.object({
103
+ field: JobField.optional(),
104
+ header: external_exports.string().regex(/^[A-Za-z0-9-]{1,64}$/).optional(),
105
+ fixed: OtherArm
106
+ }).refine((at) => at.field !== void 0 || at.header !== void 0, "a field or a header"),
107
+ external_exports.object({ fixed: external_exports.string().min(1).max(2048), field: OtherArm, header: OtherArm })
108
+ ]),
109
+ /** Sent once like a poll after the result is saved, never after a save
110
+ * that failed: it frees the seller's copy (AiSpace's `/complete`). Its
111
+ * answer is ignored. */
112
+ completeUrl: external_exports.object({ fixed: external_exports.string().min(1).max(2048) }).optional(),
113
+ pollMethod: external_exports.enum(["GET", "POST"]),
114
+ pollBody: external_exports.record(JobField, external_exports.unknown()).refine(
115
+ (body) => Object.values(body).every(
116
+ (value) => typeof value !== "string" || !value.startsWith("$") || POLL_REFERENCE.test(value)
117
+ ),
118
+ "a $ value is $input.<field> or $result.<field>"
119
+ ).optional(),
120
+ running: external_exports.union([
121
+ external_exports.object({
122
+ httpStatus: external_exports.array(external_exports.number().int().min(200).max(299)).min(1).max(8),
123
+ field: OtherArm,
124
+ values: OtherArm
125
+ }),
126
+ JobFieldStateSchema.extend({ httpStatus: OtherArm })
127
+ ]),
128
+ failed: JobFieldStateSchema.optional(),
129
+ everyS: external_exports.number().int().min(1).max(30),
130
+ maxWaitS: external_exports.number().int().min(1).max(600),
131
+ keepH: external_exports.number().int().min(1).max(48),
132
+ always: external_exports.literal(true).optional()
133
+ }).refine((job) => !job.pollBody || job.pollMethod === "POST", "only a POST poll has a body");
134
+ var MAX_SPEC_TIMEOUT_S = 120;
135
+ var ToolSpecSchema = external_exports.object({
136
+ capabilityId: external_exports.string().min(1).max(200),
137
+ provider: external_exports.string().min(1).max(120),
138
+ /** The display name, on a catalog service's spec; a Bazaar spec has none. */
139
+ label: LabelSchema.optional(),
140
+ /** The input field that takes a pending search's query or fetch's URL. */
141
+ holds: external_exports.object({
142
+ WebSearch: external_exports.string().min(1).max(64).optional(),
143
+ WebFetch: external_exports.string().min(1).max(64).optional()
144
+ }).optional(),
145
+ /** What a paid result is. `media` means its files (bytes, links or inline
146
+ * base64) are saved locally; absent on a Bazaar spec. */
147
+ output: external_exports.enum(["json", "text", "media"]).optional(),
148
+ description: external_exports.string().min(1).max(500),
149
+ priceAtomic: external_exports.string().regex(/^\d+$/),
150
+ priceVaries: external_exports.boolean(),
151
+ maxAmountAtomic: external_exports.string().regex(/^\d+$/),
152
+ payTo: external_exports.string().min(1).max(200),
153
+ network: external_exports.string().min(1).max(64),
154
+ asset: external_exports.string().min(1).max(200),
155
+ request: external_exports.object({
156
+ method: external_exports.enum(["GET", "POST"]),
157
+ url: external_exports.string().min(1).max(2048),
158
+ fields: external_exports.record(external_exports.string(), external_exports.enum(["path", "query", "body"])),
159
+ location: external_exports.enum(["query", "body"]),
160
+ /** Fixed request headers the catalog decides for this service (a
161
+ * provider's beta opt-in, say), never the agent. The call refuses a name
162
+ * this client signs or sets itself; `accept` and `content-type` stay its own. */
163
+ headers: external_exports.record(external_exports.string().min(1).max(64), external_exports.string().min(1).max(1024)).refine((headers) => Object.keys(headers).length <= 8, "at most 8 headers").optional()
164
+ }),
165
+ input: external_exports.record(external_exports.string(), external_exports.unknown()),
166
+ pinned: external_exports.record(external_exports.string(), external_exports.unknown()),
167
+ example: external_exports.record(external_exports.string(), external_exports.unknown()).optional(),
168
+ returns: external_exports.string().min(1).max(200).optional(),
169
+ returnsExample: external_exports.unknown().optional(),
170
+ resultSchema: external_exports.record(external_exports.string(), external_exports.unknown()).optional(),
171
+ /** The fields the result promises (type, properties, items, required). The
172
+ * agent is handed only these; the whole body is saved to a file. */
173
+ outputSchema: external_exports.record(external_exports.string(), external_exports.unknown()).optional(),
174
+ /** How a call answered before its result is ready is finished. */
175
+ job: JobSchema.optional(),
176
+ /** A media service that runs several takes of one call: `count` up to `max`. */
177
+ takes: external_exports.object({ max: external_exports.number().int().min(2).max(5) }).optional(),
178
+ requires: RequiresSchema,
179
+ /** The provider call's own deadline in seconds: the unpaid probe's, and
180
+ * the least the paid leg waits. Absent, the CLI's `--timeout`. */
181
+ timeoutS: external_exports.number().int().min(1).max(MAX_SPEC_TIMEOUT_S).optional(),
182
+ /** The largest file the call may bring back, in bytes: a binary result,
183
+ * and each file a media result links to, though not yet a job's polled
184
+ * result. Absent, and at most, the {@link MAX_BINARY_BODY_BYTES} every
185
+ * call had. */
186
+ maxBytes: external_exports.number().int().min(1).max(MAX_BINARY_BODY_BYTES).optional()
187
+ });
188
+ var OfferSpecSchema = ToolSpecSchema.extend({ id: IdSchema });
189
+ var SpecsSchema = external_exports.array(OfferSpecSchema).min(1).max(8).optional();
190
+ var MCP_ACCEPT = "mcp";
191
+ var ACCOUNT_ID = /^[a-z0-9][a-z0-9-]{0,47}$/;
192
+ function isAccountId(id) {
193
+ return ACCOUNT_ID.test(id) && id !== BUILT_IN_SOURCE;
194
+ }
195
+ var McpToolSchema = external_exports.string().regex(/^[A-Za-z0-9_][A-Za-z0-9_.-]{0,127}$/);
196
+ var ACCOUNT_CALL_MAX_BYTES = 8 * 1024;
197
+ var ACCOUNT_RESULTS = ["structured", "json-text", "content"];
198
+ var RESULT_PATH = "[A-Za-z_][A-Za-z0-9_]{0,63}(?:\\.[A-Za-z_][A-Za-z0-9_]{0,63}){0,3}";
199
+ var INPUT_PLACEHOLDER = /^\{([A-Za-z_][A-Za-z0-9_]{0,63})\}$/;
200
+ var RESULT_PLACEHOLDER = new RegExp(`^\\{result\\.(${RESULT_PATH})\\}$`);
201
+ var AccountStateSchema = external_exports.object({
202
+ path: external_exports.string().regex(new RegExp(`^${RESULT_PATH}$`)),
203
+ values: external_exports.array(external_exports.string().min(1).max(64)).min(1).max(8)
204
+ });
205
+ var AccountCallFields = {
206
+ tool: McpToolSchema,
207
+ /** The tool's `arguments`, a template (above). */
208
+ args: external_exports.record(external_exports.string(), external_exports.unknown()),
209
+ result: external_exports.enum(ACCOUNT_RESULTS)
210
+ };
211
+ var AccountPollSchema = external_exports.object({
212
+ ...AccountCallFields,
213
+ running: AccountStateSchema,
214
+ failed: AccountStateSchema.optional(),
215
+ everyS: external_exports.number().int().min(1).max(30),
216
+ maxWaitS: external_exports.number().int().min(1).max(600)
217
+ });
218
+ var AccountStepSchema = external_exports.object({
219
+ when: AccountStateSchema.optional(),
220
+ poll: AccountPollSchema.optional(),
221
+ ...AccountCallFields
222
+ });
223
+ var AccountCallSchema = external_exports.object({
224
+ ...AccountCallFields,
225
+ next: AccountStepSchema.optional()
226
+ });
227
+ var AccountSpecFields = external_exports.object({
228
+ capabilityId: external_exports.string().min(1).max(200),
229
+ provider: external_exports.string().min(1).max(120),
230
+ label: LabelSchema.optional(),
231
+ holds: external_exports.object({
232
+ WebSearch: external_exports.string().min(1).max(64).optional(),
233
+ WebFetch: external_exports.string().min(1).max(64).optional()
234
+ }).optional(),
235
+ output: external_exports.enum(["json", "text", "media"]).optional(),
236
+ description: external_exports.string().min(1).max(500),
237
+ /** The connected account the call runs on: this client attaches the
238
+ * credential it holds for it, and only while it is connected here. */
239
+ source: external_exports.string().regex(ACCOUNT_ID),
240
+ /** The call on the account, in place of a paid spec's price and request. */
241
+ mcp: AccountCallSchema,
242
+ input: external_exports.record(external_exports.string(), external_exports.unknown()),
243
+ pinned: external_exports.record(external_exports.string(), external_exports.unknown()),
244
+ example: external_exports.record(external_exports.string(), external_exports.unknown()).optional(),
245
+ returns: external_exports.string().min(1).max(200).optional(),
246
+ returnsExample: external_exports.unknown().optional(),
247
+ resultSchema: external_exports.record(external_exports.string(), external_exports.unknown()).optional(),
248
+ outputSchema: external_exports.record(external_exports.string(), external_exports.unknown()).optional(),
249
+ requires: RequiresSchema,
250
+ // A paid spec's own keys: an object naming them is no account spec.
251
+ priceAtomic: OtherArm,
252
+ request: OtherArm,
253
+ payTo: OtherArm
254
+ });
255
+ function placeholders(value) {
256
+ if (typeof value === "string")
257
+ return INPUT_PLACEHOLDER.test(value) || RESULT_PLACEHOLDER.test(value) ? [value] : [];
258
+ if (Array.isArray(value)) return value.flatMap(placeholders);
259
+ if (value && typeof value === "object") return Object.values(value).flatMap(placeholders);
260
+ return [];
261
+ }
262
+ function accountSpecProblems(spec, ctx) {
263
+ const issue = (message, path) => ctx.addIssue({ code: "custom", message, path });
264
+ const { mcp } = spec;
265
+ if (spec.source === BUILT_IN_SOURCE)
266
+ issue(`an account service is never on ${BUILT_IN_SOURCE}`, ["source"]);
267
+ if (!(spec.requires ?? []).includes(MCP_ACCEPT))
268
+ issue(`an account spec requires ${MCP_ACCEPT}`, ["requires"]);
269
+ if (Buffer.byteLength(JSON.stringify(mcp), "utf8") > ACCOUNT_CALL_MAX_BYTES)
270
+ issue(`the call must serialize to at most ${ACCOUNT_CALL_MAX_BYTES} bytes`, ["mcp"]);
271
+ if (mcp.next?.poll?.tool === mcp.tool)
272
+ issue("the poll never repeats the call that bills", ["mcp", "next", "poll", "tool"]);
273
+ if (mcp.next?.tool === mcp.tool)
274
+ issue("the follow-up never repeats the call that bills", ["mcp", "next", "tool"]);
275
+ const properties = spec.input.properties;
276
+ const fields = new Set(
277
+ properties && typeof properties === "object" ? Object.keys(properties) : []
278
+ );
279
+ const calls = [
280
+ [["mcp", "args"], mcp.args, false]
281
+ ];
282
+ if (mcp.next?.poll) calls.push([["mcp", "next", "poll", "args"], mcp.next.poll.args, true]);
283
+ if (mcp.next) calls.push([["mcp", "next", "args"], mcp.next.args, true]);
284
+ for (const [path, args, followUp] of calls)
285
+ for (const value of placeholders(args)) {
286
+ const field = INPUT_PLACEHOLDER.exec(value)?.[1];
287
+ if (field === void 0 && !followUp) issue("only a follow-up reads the first result", path);
288
+ if (field !== void 0 && !fields.has(field))
289
+ issue(`${value} names no field of the input`, path);
290
+ }
291
+ }
292
+ var AccountSpecSchema = AccountSpecFields.superRefine(accountSpecProblems);
293
+ var AccountOfferSpecSchema = AccountSpecFields.extend({ id: IdSchema }).superRefine(
294
+ accountSpecProblems
295
+ );
296
+ var isAccountSpec = (spec) => "mcp" in spec && "source" in spec;
297
+ var ExecuteSpecsSchema = external_exports.array(external_exports.union([OfferSpecSchema, AccountOfferSpecSchema])).min(1).max(8).optional();
298
+ var PlainLine = (max) => external_exports.string().min(1).max(max).refine((text) => !/[\p{Cc}\p{Cf}]/u.test(text), "one plain line");
299
+ var ChoicesSchema = external_exports.object({
300
+ group: PlainLine(64),
301
+ default: PlainLine(64),
302
+ input: external_exports.array(PlainLine(64)).min(1).max(16),
303
+ options: external_exports.array(
304
+ external_exports.object({
305
+ key: PlainLine(64),
306
+ label: PlainLine(120),
307
+ strength: PlainLine(300),
308
+ id: IdSchema
309
+ })
310
+ ).min(2).max(4),
311
+ all: external_exports.object({ totalAtomic: external_exports.string().regex(/^\d+$/) })
312
+ });
313
+ var ALL_CHOICES = "all";
314
+ function checkChoices(decision, ctx) {
315
+ const { choices } = decision;
316
+ if (choices === void 0) return;
317
+ const issue = (message) => ctx.addIssue({ code: "custom", path: ["choices"], message });
318
+ const keys = choices.options.map((option) => option.key);
319
+ const ids = choices.options.map((option) => option.id);
320
+ if (new Set(keys).size !== keys.length) issue("each choice key is named once");
321
+ if (new Set(ids).size !== ids.length) issue("each choice id is named once");
322
+ if (keys.includes(ALL_CHOICES)) issue(`"${ALL_CHOICES}" runs every choice, so it is no key`);
323
+ const specIds = new Set((decision.specs ?? []).map((spec) => spec.id));
324
+ if (ids.some((id) => !specIds.has(id))) issue("every choice carries its spec");
325
+ const fallback = choices.options.find((option) => option.key === choices.default);
326
+ if (fallback === void 0) issue("the default is one of the choices");
327
+ else if (fallback.id !== decision.id) issue("the default choice is this answer's own offer");
328
+ }
329
+ var MAX_INPUT_BYTES = 16 * 1024;
330
+ var BoundSchema = external_exports.object({
331
+ id: IdSchema,
332
+ input: external_exports.record(external_exports.string(), external_exports.unknown()).refine(
333
+ (input) => Buffer.byteLength(JSON.stringify(input), "utf8") <= MAX_INPUT_BYTES,
334
+ `bound input must serialize to at most ${MAX_INPUT_BYTES} bytes`
335
+ )
336
+ });
337
+ var DiscoveredSchema = external_exports.object({
338
+ action: external_exports.literal("discovered"),
339
+ id: IdSchema,
340
+ candidate: DiscoveredCandidateSchema,
341
+ /** THE LINE, FINISHED, as on `execute`: it carries the seller's
342
+ * description and the input it takes. */
343
+ hint: external_exports.string().min(1).max(2e3),
344
+ specs: SpecsSchema,
345
+ choices: ChoicesSchema.optional(),
346
+ requires: RequiresSchema,
347
+ bound: BoundSchema.optional()
348
+ }).superRefine(checkHint).superRefine(checkChoices);
349
+ function checkExecute(decision, ctx) {
350
+ const issue = (message, path) => ctx.addIssue({ code: "custom", message, path });
351
+ const specs = decision.specs ?? [];
352
+ const lead = specs.find(({ id }) => id === decision.id);
353
+ if (!lead || !isAccountSpec(lead)) {
354
+ if (specs.some((spec) => isAccountSpec(spec)))
355
+ issue("an account service is only ever the lead", ["specs"]);
356
+ if (decision.endpoint === void 0) issue("an execute names the URL it pays", ["endpoint"]);
357
+ return;
358
+ }
359
+ if (specs.length > 1) issue("an account lead is offered alone", ["specs"]);
360
+ if (decision.endpoint !== void 0)
361
+ issue("an account lead names no endpoint: this client calls its own account", ["endpoint"]);
362
+ if (decision.capabilityId !== lead.capabilityId)
363
+ issue("the listing names the lead", ["capabilityId"]);
364
+ if (decision.providerPriceAtomic !== "0")
365
+ issue("the balance pays an account lead nothing", ["providerPriceAtomic"]);
366
+ if (decision.delivery === "augment" || decision.augmentUrl !== void 0)
367
+ issue("an account lead is an offer", ["delivery"]);
368
+ }
369
+ var HookDecisionSchema = external_exports.discriminatedUnion("action", [
370
+ external_exports.object({
371
+ action: external_exports.literal("execute"),
372
+ id: IdSchema,
373
+ ...CapabilityFields,
374
+ /** The x402 URL a lookup would pay, for the line the server writes. An
375
+ * account lead has none: this client calls the account it connected. */
376
+ endpoint: external_exports.string().min(1).max(2048).optional(),
377
+ /** What to pass in `query`, in the service's own terms. */
378
+ usage: external_exports.string().min(1).max(300),
379
+ /**
380
+ * THE LINE, FINISHED. The server writes it with the real id in it and, on a
381
+ * native call, the exact search or URL that was denied. The client injects
382
+ * it and composes nothing, which is why there is no hint builder here any
383
+ * more: two sides writing the same sentence is how they drift. The same
384
+ * bound as a discovered line's.
385
+ */
386
+ hint: external_exports.string().min(1).max(2e3),
387
+ specs: ExecuteSpecsSchema,
388
+ /**
389
+ * HOW THE OFFER IS DELIVERED, sent because this build lists `fields`.
390
+ * `note` is the free docs lookup before a search, for a client that
391
+ * also lists `note`: the line comes after the search. `augment` is the
392
+ * same offer for a client that does not, with the `augmentUrl` that
393
+ * client fetches. `offer` is every other line. This build shows only a
394
+ * `note` after a search; any other free offer before one, `augment`
395
+ * included, runs silent.
396
+ */
397
+ delivery: external_exports.enum(["offer", "augment", "note"]).optional(),
398
+ augmentUrl: external_exports.string().url().max(2048).optional(),
399
+ bound: BoundSchema.optional()
400
+ }).superRefine(checkHint).superRefine(checkExecute),
401
+ DiscoveredSchema,
402
+ RefusedSchema.extend({ action: external_exports.literal("native") }),
403
+ RefusedSchema.extend({ action: external_exports.literal("needs_input") })
404
+ ]);
405
+ var ToolDecisionSchema = external_exports.discriminatedUnion("action", [
406
+ external_exports.object({
407
+ action: external_exports.literal("execute"),
408
+ ...CapabilityFields,
409
+ contract: ContractSchema
410
+ }),
411
+ /**
412
+ * A query with no id, answered with the spec of the service the server
413
+ * picked under a fresh `id`: kept like a hook's, and never run in the same
414
+ * call. `hint` is the line, with the skeleton of the next call:
415
+ * `request({id, input: {...}})` with the required fields. What it needs
416
+ * this client to understand is its spec's `requires`.
417
+ */
418
+ external_exports.object({
419
+ action: external_exports.literal("spec"),
420
+ id: IdSchema,
421
+ spec: external_exports.union([ToolSpecSchema, AccountSpecSchema]),
422
+ hint: external_exports.string().min(1).max(2e3)
423
+ }).superRefine(checkHint),
424
+ DiscoveredSchema,
425
+ RefusedSchema.extend({ action: external_exports.literal("native") }),
426
+ RefusedSchema.extend({ action: external_exports.literal("needs_input") })
427
+ ]);
428
+ function envelope(decision) {
429
+ return external_exports.object({
430
+ schemaVersion: external_exports.literal(1),
431
+ routerVersion: external_exports.string().min(1).max(64),
432
+ /**
433
+ * The request's own settings hash, verbatim, on an answer the server
434
+ * decided under the user's rules (to a client that lists `settings` in
435
+ * `accepts`). The check before every call compares it with the rules
436
+ * saved now (`settings-check.ts`); it names a rule set and authorizes
437
+ * nothing.
438
+ */
439
+ settingsHash: SettingsHashSchema.optional(),
440
+ decision,
441
+ /** A plain sentence about the CALL, such as an id that had expired. Never a
442
+ * failure: the decision beside it ran anyway. */
443
+ note: external_exports.string().max(500).optional(),
444
+ jev: external_exports.object({ calls: external_exports.number(), latencyMs: external_exports.number() }).optional()
445
+ });
446
+ }
447
+ var HookResponseSchema = envelope(HookDecisionSchema);
448
+ var ToolResponseSchema = envelope(ToolDecisionSchema);
449
+ var BrowseRowSchema = external_exports.object({
450
+ id: external_exports.string().min(1).max(200).regex(/^[A-Za-z0-9._:-]+$/),
451
+ label: external_exports.string().min(1).max(120),
452
+ does: external_exports.string().min(1).max(500),
453
+ price: external_exports.string().min(1).max(32),
454
+ free: external_exports.boolean(),
455
+ kind: external_exports.string().min(1).max(120)
456
+ });
457
+ var BrowseResponseSchema = external_exports.object({
458
+ schemaVersion: external_exports.literal(1),
459
+ routerVersion: external_exports.string().min(1).max(64),
460
+ rows: external_exports.array(BrowseRowSchema).max(200)
461
+ });
462
+ var Labelled = { id: TargetIdSchema, label: external_exports.string().min(1).max(120) };
463
+ var SIGN_IN = ["oauth", "key"];
464
+ var KEY_SCHEMES = ["Bearer", "Key"];
465
+ function isAccountUrl(value, opts = {}) {
466
+ const url = URL.canParse(value) ? new URL(value) : void 0;
467
+ return url !== void 0 && (url.protocol === "https:" || opts.typed === true && url.protocol === "http:" && isLoopbackHost(url.hostname)) && !url.username && !url.password && !value.includes("?") && !value.includes("#") && !value.endsWith("/");
468
+ }
469
+ var twice = (keys) => new Set(keys).size !== keys.length;
470
+ var ConnectableSchema = external_exports.object({
471
+ mcpUrl: external_exports.string().max(2048).refine(
472
+ (value) => isAccountUrl(value),
473
+ "an https URL with no credentials, query, fragment or trailing slash"
474
+ ),
475
+ signIn: external_exports.array(external_exports.enum(SIGN_IN)).min(1).max(2),
476
+ keyScheme: external_exports.enum(KEY_SCHEMES).optional(),
477
+ expectTools: external_exports.array(McpToolSchema).min(1).max(64)
478
+ }).superRefine((connectable, ctx) => {
479
+ const issue = (message, path) => ctx.addIssue({ code: "custom", message, path });
480
+ if (twice(connectable.signIn)) issue("each sign-in is listed once", ["signIn"]);
481
+ if (connectable.signIn.includes("key") !== (connectable.keyScheme !== void 0))
482
+ issue("a key sign-in says how the key is sent, and only it does", ["keyScheme"]);
483
+ if (twice(connectable.expectTools)) issue("each tool is listed once", ["expectTools"]);
484
+ });
485
+ var IdentitiesResponseSchema = external_exports.object({
486
+ schemaVersion: external_exports.literal(1),
487
+ routerVersion: external_exports.string().min(1).max(64),
488
+ categories: external_exports.array(external_exports.object({ ...Labelled, tasks: external_exports.array(TargetIdSchema).max(256) })).max(256),
489
+ /** `speed`: a task the speed preference changes (it has a speed criterion). */
490
+ tasks: external_exports.array(
491
+ external_exports.object({
492
+ ...Labelled,
493
+ category: TargetIdSchema.optional(),
494
+ speed: external_exports.literal(true).optional()
495
+ })
496
+ ).max(1024),
497
+ providers: external_exports.array(external_exports.object(Labelled)).max(2048),
498
+ sellers: external_exports.array(external_exports.object(Labelled)).max(2048),
499
+ services: external_exports.array(
500
+ external_exports.object({
501
+ ...Labelled,
502
+ task: TargetIdSchema.optional(),
503
+ providers: external_exports.array(TargetIdSchema).max(16),
504
+ seller: TargetIdSchema.optional()
505
+ })
506
+ ).max(4096),
507
+ /** `connectable`, for a build that lists `mcp`: an account this client can
508
+ * connect, never `tenjin`. */
509
+ sources: external_exports.array(
510
+ external_exports.object({ ...Labelled, connectable: ConnectableSchema.optional() }).refine(
511
+ ({ id, connectable }) => connectable === void 0 || isAccountId(id),
512
+ "only an account id is connectable, never tenjin"
513
+ )
514
+ ).max(64)
515
+ });
516
+ function parseHookResponse(value) {
517
+ const parsed = HookResponseSchema.safeParse(value);
518
+ return parsed.success ? parsed.data : void 0;
519
+ }
520
+ function parseIdentities(value) {
521
+ const parsed = IdentitiesResponseSchema.safeParse(value);
522
+ return parsed.success ? parsed.data : void 0;
523
+ }
524
+ var REQUIRES_UNMET = "requires_unmet";
525
+ function withoutUnmet(decision) {
526
+ if (decision.action === "native" || decision.action === "needs_input") {
527
+ return { decision, skipped: [] };
528
+ }
529
+ const specs = "specs" in decision ? decision.specs ?? [] : [];
530
+ const own = [
531
+ ...unmetRequires("requires" in decision ? decision.requires : void 0),
532
+ ...decision.action === "spec" ? unmetRequires(decision.spec.requires) : [],
533
+ ..."id" in decision ? unmetRequires(specs.find((s) => s.id === decision.id)?.requires) : []
534
+ ];
535
+ if (own.length > 0) {
536
+ const missing = [...new Set(own)];
537
+ const id = "id" in decision ? decision.id : decision.capabilityId;
538
+ return { decision: unmetRefusal(missing), skipped: [{ id, missing }] };
539
+ }
540
+ const skipped = specs.flatMap((spec) => {
541
+ const missing = unmetRequires(spec.requires);
542
+ return missing.length > 0 ? [{ id: spec.id, missing }] : [];
543
+ });
544
+ if (skipped.length === 0) return { decision, skipped };
545
+ const options = new Set(
546
+ decision.action === "discovered" ? (decision.choices?.options ?? []).map((o) => o.id) : []
547
+ );
548
+ const hint = "hint" in decision ? decision.hint : "";
549
+ if (skipped.some((s) => options.has(s.id) || hint.includes(s.id))) {
550
+ const missing = [...new Set(skipped.flatMap((s) => s.missing))];
551
+ return { decision: unmetRefusal(missing), skipped };
552
+ }
553
+ const gone = new Set(skipped.map((s) => s.id));
554
+ return {
555
+ decision: { ...decision, specs: specs.filter((spec) => !gone.has(spec.id)) },
556
+ skipped
557
+ };
558
+ }
559
+ function unmetRefusal(missing) {
560
+ const named = missing.map((token) => `\`${token}\``).join(", ");
561
+ return {
562
+ action: "native",
563
+ reason: `This offer needs ${named}, which this build of tenjin-cli does not have, so it was skipped and no provider was paid.`,
564
+ diagnostics: {
565
+ reasonCode: REQUIRES_UNMET,
566
+ stage: "client",
567
+ missing,
568
+ nextAction: "Use your own tools for this one. A newer tenjin-cli (`tenjin update`) can run it."
569
+ }
570
+ };
571
+ }
572
+ var CLIENT_ACCEPTS = [
573
+ "catalog",
574
+ "spec",
575
+ "label",
576
+ "fields",
577
+ "jobs",
578
+ "headers",
579
+ "note",
580
+ "tolerant"
581
+ ];
582
+ var BAZAAR_ACCEPT = "bazaar";
583
+ var FREE_QUERY_ACCEPT = "free-query";
584
+ var CLIENT_FEATURES = /* @__PURE__ */ new Set([
585
+ ...CLIENT_ACCEPTS,
586
+ BAZAAR_ACCEPT,
587
+ FREE_QUERY_ACCEPT,
588
+ SETTINGS_ACCEPT,
589
+ MCP_ACCEPT
590
+ ]);
591
+ function unmetRequires(requires) {
592
+ return (requires ?? []).filter((token) => !CLIENT_FEATURES.has(token));
593
+ }
594
+ function acceptsFor(bazaar, settings = false) {
595
+ return [
596
+ ...CLIENT_ACCEPTS,
597
+ ...bazaar ? [BAZAAR_ACCEPT] : [],
598
+ ...settings ? [SETTINGS_ACCEPT, MCP_ACCEPT] : []
599
+ ];
600
+ }
601
+ function buildHookBody(packet, extras = {}) {
602
+ return {
603
+ schemaVersion: 1,
604
+ ...extras.sessionId !== void 0 ? { sessionId: extras.sessionId } : {},
605
+ ...extras.accepts !== void 0 ? { accepts: [...extras.accepts] } : {},
606
+ ...extras.harness !== void 0 ? { harness: extras.harness } : {},
607
+ ...extras.budgetMs !== void 0 ? { budgetMs: extras.budgetMs } : {},
608
+ packet,
609
+ ...extras.improve === true ? { improve: true } : {},
610
+ // A SIBLING OF THE PACKET, never inside it: the packet is what the
611
+ // server's model reads, and the user's settings are for code alone.
612
+ ...extras.settings !== void 0 ? { settings: extras.settings } : {}
613
+ };
614
+ }
615
+ function buildToolBody(request) {
616
+ return {
617
+ schemaVersion: 1,
618
+ ...request.query !== void 0 ? { query: request.query } : {},
619
+ ...request.id !== void 0 ? { id: request.id } : {},
620
+ ...request.gateHint !== void 0 ? { gateHint: request.gateHint } : {},
621
+ ...request.accepts !== void 0 ? { accepts: [...request.accepts] } : {},
622
+ ...request.harness !== void 0 ? { harness: request.harness } : {},
623
+ ...request.improve === true ? { improve: true } : {},
624
+ ...request.settings !== void 0 ? { settings: request.settings } : {}
625
+ };
626
+ }
627
+ function buildRefusedBody(request) {
628
+ return {
629
+ schemaVersion: 1,
630
+ refused: request.refused,
631
+ accepts: [...request.accepts],
632
+ ...request.harness !== void 0 ? { harness: request.harness } : {},
633
+ ...request.settings !== void 0 ? { settings: request.settings } : {}
634
+ };
635
+ }
636
+ function buildBrowseBody(request) {
637
+ return {
638
+ schemaVersion: 1,
639
+ browse: request.browse,
640
+ accepts: [...request.accepts],
641
+ ...request.harness !== void 0 ? { harness: request.harness } : {},
642
+ ...request.settings !== void 0 ? { settings: request.settings } : {}
643
+ };
644
+ }
645
+ function buildToolSpecBody(request) {
646
+ return {
647
+ schemaVersion: 1,
648
+ tool: request.tool,
649
+ ...request.query !== void 0 ? { query: request.query } : {},
650
+ accepts: [...request.accepts],
651
+ ...request.harness !== void 0 ? { harness: request.harness } : {},
652
+ ...request.settings !== void 0 ? { settings: request.settings } : {}
653
+ };
654
+ }
655
+ function buildIdentitiesBody() {
656
+ return { schemaVersion: 1, identities: true, accepts: acceptsFor(false, true) };
657
+ }
658
+ function buildWarmBody(extras = {}) {
659
+ return {
660
+ schemaVersion: 1,
661
+ warm: true,
662
+ ...extras.accepts !== void 0 ? { accepts: [...extras.accepts] } : {},
663
+ ...extras.harness !== void 0 ? { harness: extras.harness } : {}
664
+ };
665
+ }
666
+ var WarmResponseSchema = external_exports.object({
667
+ schemaVersion: external_exports.literal(1),
668
+ routerVersion: external_exports.string().min(1).max(64),
669
+ warm: external_exports.literal(true)
670
+ });
671
+ function isWarmAnswer(body) {
672
+ return WarmResponseSchema.safeParse(body).success;
673
+ }
674
+ function parseForTests(kind, value) {
675
+ const parsed = schemaFor(kind).safeParse(value);
676
+ return parsed.success ? { success: true, data: parsed.data } : { success: false };
677
+ }
678
+ function schemaFor(kind) {
679
+ return kind === "hook" ? HookResponseSchema : kind === "tool" ? ToolResponseSchema : BrowseResponseSchema;
680
+ }
681
+ var RouteSkipped = class extends Error {
682
+ constructor(why, opts = {}) {
683
+ super(`routing fee not paid: ${why}`);
684
+ this.why = why;
685
+ this.unreached = opts.unreached;
686
+ this.quotedAtomic = opts.quotedAtomic;
687
+ this.answered = opts.answered === true;
688
+ }
689
+ why;
690
+ /** `unreached`: the paid call could not reach the router
691
+ * ({@link isUnreachable}), so the call reads as that transport failure.
692
+ * `quotedAtomic`: the fee the router quoted, when the payer read one.
693
+ * `answered`: the router answered a request of this call (its 402, say). */
694
+ unreached;
695
+ quotedAtomic;
696
+ answered;
697
+ };
698
+ var CHANNEL_BUSY = "channel_busy";
699
+ var PAYMENT_FAILED = "payment_failed";
700
+ var DEADLINE_AFTER_PAYMENT_SENT = "deadline_after_payment_sent";
701
+ var NO_PAYER = "no_payer";
702
+ var TOPPING_UP = "topping_up";
703
+ var TOP_UP_UNAVAILABLE = "top_up_unavailable";
704
+ var DEPOSIT_DEFERRED = "deposit_deferred";
705
+ async function requestDecision(kind, request, deps) {
706
+ const url = new URL(ROUTE_PAID_PATH, deps.baseUrl).toString();
707
+ const timeoutMs = deps.timeoutMs ?? deps.ctx.flags.timeout;
708
+ const options = {
709
+ method: "POST",
710
+ timeoutMs,
711
+ blockRedirects: true,
712
+ jsonBody: kind === "hook" ? buildHookBody(request.packet, {
713
+ ...request.sessionId !== void 0 ? { sessionId: request.sessionId } : {},
714
+ accepts: acceptsFor(deps.acceptsBazaar === true, deps.settings !== void 0),
715
+ harness: deps.harness ?? "claude",
716
+ improve: deps.improve === true,
717
+ budgetMs: Math.min(5e3, Math.max(0, timeoutMs)),
718
+ ...deps.settings !== void 0 ? { settings: deps.settings } : {}
719
+ }) : buildToolBody({
720
+ ...request.query !== void 0 ? { query: request.query } : {},
721
+ ...request.id !== void 0 ? { id: request.id } : {},
722
+ ...request.gateHint !== void 0 ? { gateHint: request.gateHint } : {},
723
+ accepts: acceptsFor(deps.acceptsBazaar === true, deps.settings !== void 0),
724
+ harness: deps.harness ?? "claude",
725
+ improve: deps.improve === true,
726
+ ...deps.settings !== void 0 ? { settings: deps.settings } : {}
727
+ }),
728
+ ...deps.fetchImpl !== void 0 ? { fetchImpl: deps.fetchImpl } : {}
729
+ };
730
+ return kind === "hook" ? sendPaid(url, options, HookResponseSchema, deps) : sendPaid(url, options, ToolResponseSchema, deps);
731
+ }
732
+ async function requestRefused(refused, deps) {
733
+ const url = new URL(ROUTE_PAID_PATH, deps.baseUrl).toString();
734
+ return sendPaid(
735
+ url,
736
+ {
737
+ method: "POST",
738
+ timeoutMs: deps.timeoutMs ?? deps.ctx.flags.timeout,
739
+ blockRedirects: true,
740
+ jsonBody: buildRefusedBody({
741
+ refused,
742
+ accepts: acceptsFor(deps.acceptsBazaar === true, deps.settings !== void 0),
743
+ harness: deps.harness ?? "claude",
744
+ ...deps.settings !== void 0 ? { settings: deps.settings } : {}
745
+ }),
746
+ ...deps.fetchImpl !== void 0 ? { fetchImpl: deps.fetchImpl } : {}
747
+ },
748
+ ToolResponseSchema,
749
+ deps
750
+ );
751
+ }
752
+ async function sendPaid(url, options, schema, deps) {
753
+ let response;
754
+ try {
755
+ response = await (deps.route?.send ?? httpRequest)(url, options);
756
+ } catch (err) {
757
+ if (!(err instanceof RouteSkipped)) throw err;
758
+ if (err.unreached !== void 0) return readOffer(err.unreached, schema);
759
+ return {
760
+ status: "skipped",
761
+ why: err.why,
762
+ ...err.quotedAtomic !== void 0 ? { quotedAtomic: err.quotedAtomic } : {},
763
+ ...err.answered ? { answered: true } : {}
764
+ };
765
+ }
766
+ if (deps.route === void 0 && response.ok && response.status === 402) {
767
+ return { status: "skipped", why: NO_PAYER, answered: true };
768
+ }
769
+ return readOffer(response, schema);
770
+ }
771
+ async function requestBrowse(browse, deps) {
772
+ return readDecision(
773
+ await httpRequest(new URL(ROUTER_PATH, deps.baseUrl).toString(), {
774
+ method: "POST",
775
+ timeoutMs: deps.timeoutMs ?? deps.ctx.flags.timeout,
776
+ blockRedirects: true,
777
+ jsonBody: buildBrowseBody({
778
+ browse,
779
+ accepts: acceptsFor(deps.acceptsBazaar === true, deps.settings !== void 0),
780
+ harness: deps.harness ?? "claude",
781
+ ...deps.settings !== void 0 ? { settings: deps.settings } : {}
782
+ }),
783
+ ...deps.fetchImpl !== void 0 ? { fetchImpl: deps.fetchImpl } : {}
784
+ }),
785
+ BrowseResponseSchema
786
+ );
787
+ }
788
+ async function requestToolSpec(tool, deps, query) {
789
+ return readOffer(
790
+ await httpRequest(new URL(ROUTER_PATH, deps.baseUrl).toString(), {
791
+ method: "POST",
792
+ timeoutMs: deps.timeoutMs ?? deps.ctx.flags.timeout,
793
+ blockRedirects: true,
794
+ jsonBody: buildToolSpecBody({
795
+ tool,
796
+ ...query !== void 0 ? { query } : {},
797
+ accepts: [
798
+ ...acceptsFor(deps.acceptsBazaar === true, deps.settings !== void 0),
799
+ FREE_QUERY_ACCEPT
800
+ ],
801
+ harness: deps.harness ?? "claude",
802
+ ...deps.settings !== void 0 ? { settings: deps.settings } : {}
803
+ }),
804
+ ...deps.fetchImpl !== void 0 ? { fetchImpl: deps.fetchImpl } : {}
805
+ }),
806
+ ToolResponseSchema
807
+ );
808
+ }
809
+ async function requestIdentities(deps) {
810
+ return readDecision(
811
+ await httpRequest(new URL(ROUTER_PATH, deps.baseUrl).toString(), {
812
+ method: "POST",
813
+ timeoutMs: deps.timeoutMs ?? deps.ctx.flags.timeout,
814
+ blockRedirects: true,
815
+ jsonBody: buildIdentitiesBody(),
816
+ ...deps.fetchImpl !== void 0 ? { fetchImpl: deps.fetchImpl } : {}
817
+ }),
818
+ IdentitiesResponseSchema
819
+ );
820
+ }
821
+ var OUTCOME_TIMEOUT_MS = 3e3;
822
+ async function reportSpecOutcome(outcome, deps) {
823
+ try {
824
+ await httpRequest(new URL(ROUTER_PATH, deps.baseUrl).toString(), {
825
+ method: "POST",
826
+ timeoutMs: OUTCOME_TIMEOUT_MS,
827
+ blockRedirects: true,
828
+ jsonBody: buildOutcomeBody(outcome, deps.harness ?? "claude"),
829
+ ...deps.fetchImpl !== void 0 ? { fetchImpl: deps.fetchImpl } : {}
830
+ });
831
+ } catch {
832
+ }
833
+ }
834
+ function buildOutcomeBody(outcome, harness) {
835
+ const spec = outcome.status === "ignored" ? {} : outcome;
836
+ return {
837
+ schemaVersion: 1,
838
+ id: outcome.id,
839
+ ...harness !== void 0 ? { harness } : {},
840
+ status: outcome.status,
841
+ ...outcome.reason !== void 0 ? { reason: outcome.reason } : {},
842
+ ...spec.httpStatus !== void 0 ? { httpStatus: spec.httpStatus } : {},
843
+ ...spec.ms !== void 0 ? { ms: Math.max(0, Math.round(spec.ms)) } : {},
844
+ ...spec.via !== void 0 ? { via: spec.via } : {}
845
+ };
846
+ }
847
+ function buildForgetBody() {
848
+ return { schemaVersion: 1, forget: "samples" };
849
+ }
850
+ async function requestForget(deps) {
851
+ try {
852
+ const response = await httpRequest(new URL(ROUTER_PATH, deps.baseUrl).toString(), {
853
+ method: "POST",
854
+ timeoutMs: OUTCOME_TIMEOUT_MS,
855
+ blockRedirects: true,
856
+ jsonBody: buildForgetBody(),
857
+ ...deps.fetchImpl !== void 0 ? { fetchImpl: deps.fetchImpl } : {}
858
+ });
859
+ if (!response.ok) return { ok: false, reason: fetchFailureToCliError(response).message };
860
+ if (response.status >= 200 && response.status < 300) return { ok: true };
861
+ return { ok: false, reason: `the router endpoint answered ${response.status}` };
862
+ } catch (err) {
863
+ return { ok: false, reason: err instanceof Error ? err.message : String(err) };
864
+ }
865
+ }
866
+ function readDecision(response, schema) {
867
+ if (!response.ok) {
868
+ return {
869
+ status: "failed",
870
+ reason: fetchFailureToCliError(response).message,
871
+ ...isUnreachable(response) ? { unreachable: true } : {},
872
+ ...response.status === void 0 ? { noAnswer: true } : {}
873
+ };
874
+ }
875
+ if (response.status < 200 || response.status >= 300) {
876
+ const named = errorOf(response.json);
877
+ return {
878
+ status: "failed",
879
+ // The backend's own code and message, never a bare status line: a typed
880
+ // refusal the host could act on was arriving as "answered 400".
881
+ reason: named === null ? `The router endpoint answered ${response.status}.` : `The router endpoint answered ${response.status} (${named.code}): ${named.message}`,
882
+ ...named !== null ? { errorCode: named.code } : {}
883
+ };
884
+ }
885
+ const parsed = schema.safeParse(response.json);
886
+ if (!parsed.success) {
887
+ return { status: "failed", reason: "The router returned a decision this build cannot read." };
888
+ }
889
+ return { status: "decided", decision: parsed.data };
890
+ }
891
+ function readOffer(response, schema) {
892
+ const read = readDecision(response, schema);
893
+ if (read.status !== "decided") return read;
894
+ const { decision, skipped } = withoutUnmet(read.decision.decision);
895
+ return {
896
+ ...read,
897
+ decision: { ...read.decision, decision },
898
+ ...skipped.length > 0 ? { skipped } : {}
899
+ };
900
+ }
901
+ function errorOf(body) {
902
+ if (body === null || typeof body !== "object") return null;
903
+ const error = body.error;
904
+ if (error === null || typeof error !== "object") return null;
905
+ const { code, message } = error;
906
+ if (typeof code !== "string" || code.length === 0 || code.length > 64) return null;
907
+ const text = typeof message === "string" ? message.slice(0, 500) : "";
908
+ return { code, message: text };
909
+ }
910
+ var RESET_CODES = /* @__PURE__ */ new Set(["ECONNRESET", "UND_ERR_SOCKET"]);
911
+ function isUnreachable(failure) {
912
+ return failure.kind === "network" && failure.status === void 0 && failure.transport !== void 0 && !RESET_CODES.has(failure.transport.code ?? "");
913
+ }
914
+
915
+ export {
916
+ ROUTER_PATH,
917
+ ROUTE_PAID_PATH,
918
+ UNLABELLED,
919
+ POLL_REFERENCE,
920
+ JobSchema,
921
+ MAX_SPEC_TIMEOUT_S,
922
+ ToolSpecSchema,
923
+ OfferSpecSchema,
924
+ MCP_ACCEPT,
925
+ ACCOUNT_ID,
926
+ isAccountId,
927
+ McpToolSchema,
928
+ ACCOUNT_CALL_MAX_BYTES,
929
+ ACCOUNT_RESULTS,
930
+ INPUT_PLACEHOLDER,
931
+ RESULT_PLACEHOLDER,
932
+ AccountCallSchema,
933
+ AccountSpecSchema,
934
+ AccountOfferSpecSchema,
935
+ isAccountSpec,
936
+ ChoicesSchema,
937
+ ALL_CHOICES,
938
+ MAX_INPUT_BYTES,
939
+ BoundSchema,
940
+ SIGN_IN,
941
+ KEY_SCHEMES,
942
+ isAccountUrl,
943
+ ConnectableSchema,
944
+ parseHookResponse,
945
+ parseIdentities,
946
+ REQUIRES_UNMET,
947
+ withoutUnmet,
948
+ CLIENT_ACCEPTS,
949
+ BAZAAR_ACCEPT,
950
+ FREE_QUERY_ACCEPT,
951
+ unmetRequires,
952
+ acceptsFor,
953
+ buildHookBody,
954
+ buildToolBody,
955
+ buildRefusedBody,
956
+ buildBrowseBody,
957
+ buildToolSpecBody,
958
+ buildIdentitiesBody,
959
+ buildWarmBody,
960
+ isWarmAnswer,
961
+ parseForTests,
962
+ RouteSkipped,
963
+ CHANNEL_BUSY,
964
+ PAYMENT_FAILED,
965
+ DEADLINE_AFTER_PAYMENT_SENT,
966
+ NO_PAYER,
967
+ TOPPING_UP,
968
+ TOP_UP_UNAVAILABLE,
969
+ DEPOSIT_DEFERRED,
970
+ requestDecision,
971
+ requestRefused,
972
+ requestBrowse,
973
+ requestToolSpec,
974
+ requestIdentities,
975
+ OUTCOME_TIMEOUT_MS,
976
+ reportSpecOutcome,
977
+ buildOutcomeBody,
978
+ buildForgetBody,
979
+ requestForget,
980
+ isUnreachable
981
+ };
982
+ //# sourceMappingURL=chunk-ZEYA2WWX.js.map