@humain/humain-code 0.5.4 → 0.6.1

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 (694) hide show
  1. package/CHANGELOG.md +170 -0
  2. package/dist/bundle/agent-monitor.js +1 -1
  3. package/dist/bundle/chunks/anthropic-messages-FGFIMZUF.js +66 -0
  4. package/dist/bundle/chunks/azure-openai-responses-6JNTC7KO.js +15 -0
  5. package/dist/bundle/chunks/bedrock-converse-stream.js +261 -237
  6. package/dist/bundle/chunks/chunk-2H3LUS62.js +1966 -0
  7. package/dist/bundle/chunks/{chunk-GEISZXXH.js → chunk-4ZBGTJJM.js} +1 -1
  8. package/dist/bundle/chunks/{chunk-QWXPGBAG.js → chunk-5JSLXC2A.js} +1 -1
  9. package/dist/bundle/chunks/{chunk-L2VKM23Q.js → chunk-6DE7LJKV.js} +21 -21
  10. package/dist/bundle/chunks/{chunk-V62QBESW.js → chunk-6E6RHNOU.js} +11 -10
  11. package/dist/bundle/chunks/chunk-7RZ5BS7U.js +2 -0
  12. package/dist/bundle/chunks/chunk-AHSNQWZU.js +24 -0
  13. package/dist/bundle/chunks/{chunk-UJLCKIMZ.js → chunk-AOH2O5CP.js} +3469 -3133
  14. package/dist/bundle/chunks/{chunk-ODJUBJK2.js → chunk-B7NJMF7B.js} +11 -11
  15. package/dist/bundle/chunks/chunk-BQ3TMEWD.js +7 -0
  16. package/dist/bundle/chunks/{chunk-KKCMWB63.js → chunk-C6VERWRZ.js} +1 -1
  17. package/dist/bundle/chunks/{chunk-CN3Q5UNB.js → chunk-CFHOPLW5.js} +658 -574
  18. package/dist/bundle/chunks/chunk-CVC2GV26.js +1986 -0
  19. package/dist/bundle/chunks/{chunk-DU6POZ7E.js → chunk-DHW3REC5.js} +1 -1
  20. package/dist/bundle/chunks/{chunk-UTNHGOFS.js → chunk-EDONIPUJ.js} +38 -38
  21. package/dist/bundle/chunks/{chunk-FO2NYB6O.js → chunk-FDGW5ZTG.js} +1147 -1110
  22. package/dist/bundle/chunks/{chunk-XQX7S3GM.js → chunk-GICL5V54.js} +1 -1
  23. package/dist/bundle/chunks/chunk-H7Y4QY7K.js +11 -0
  24. package/dist/bundle/chunks/chunk-HW6HMUXS.js +188 -0
  25. package/dist/bundle/chunks/chunk-I6AQOITY.js +53 -0
  26. package/dist/bundle/chunks/{chunk-ZI7TK7HM.js → chunk-IADQJFNH.js} +21 -17
  27. package/dist/bundle/chunks/chunk-J7AP2BUJ.js +3 -0
  28. package/dist/bundle/chunks/chunk-JFE52VSN.js +120 -0
  29. package/dist/bundle/chunks/{chunk-MIJHJNNQ.js → chunk-LDGCU6PD.js} +127 -3
  30. package/dist/bundle/chunks/{chunk-PS7DGA7B.js → chunk-M4CHQBAI.js} +1 -1
  31. package/dist/bundle/chunks/{chunk-YDBNMIA3.js → chunk-NN53K2QQ.js} +19 -1
  32. package/dist/bundle/chunks/{chunk-RTXDU3AA.js → chunk-ONR6Q3II.js} +255 -195
  33. package/dist/bundle/chunks/{chunk-Y3OPKKDR.js → chunk-P4P7OZ7R.js} +34 -32
  34. package/dist/bundle/chunks/{chunk-OZNC2W4B.js → chunk-PCTLFSQG.js} +444 -411
  35. package/dist/bundle/chunks/{chunk-YFBDR4IW.js → chunk-PNGNZXOI.js} +3 -3
  36. package/dist/bundle/chunks/{chunk-UDB6NI4G.js → chunk-RGUZULEE.js} +593 -481
  37. package/dist/bundle/chunks/chunk-RO5YPAJH.js +23 -0
  38. package/dist/bundle/chunks/{chunk-A6B2QMA7.js → chunk-RU7ADKA7.js} +176 -162
  39. package/dist/bundle/chunks/{chunk-JCXXRCP6.js → chunk-T3KDZFM4.js} +16 -16
  40. package/dist/bundle/chunks/{chunk-HT5YN3LX.js → chunk-TEOMXMW6.js} +3 -3
  41. package/dist/bundle/chunks/{chunk-HIZWUSPN.js → chunk-VEGJT52D.js} +77 -77
  42. package/dist/bundle/chunks/{chunk-IDU5BNNI.js → chunk-XMZGB3H4.js} +12 -3
  43. package/dist/bundle/chunks/chunk-YEPHPMQC.js +647 -0
  44. package/dist/bundle/chunks/{chunk-XA7CJAYH.js → chunk-YRUIJ5AH.js} +48 -42
  45. package/dist/bundle/chunks/{cli-ENEFJH2B.js → cli-BNCWK54K.js} +21 -17
  46. package/dist/bundle/chunks/{cloudflare-workers-ai-system-one-T7TPP7SQ.js → cloudflare-workers-ai-system-one-KI6W3USX.js} +1 -1
  47. package/dist/bundle/chunks/codemode-worker.js +81 -75
  48. package/dist/bundle/chunks/compat-I5VPOXFT.js +13 -0
  49. package/dist/bundle/chunks/dist-J5IUPLMH.js +37 -0
  50. package/dist/bundle/chunks/{dist-RKNCFFGM.js → dist-SKBR3C7C.js} +720 -696
  51. package/dist/bundle/chunks/dist-TVRQXUY6.js +8 -0
  52. package/dist/bundle/chunks/{dist-cjs-HTASUQXQ.js → dist-cjs-2SKN226B.js} +77 -77
  53. package/dist/bundle/chunks/{easter-egg-3d-YOPLCOVW.js → easter-egg-3d-673VRP6Y.js} +1 -1
  54. package/dist/bundle/chunks/{esm-R6HJ4QEG.js → esm-WPALMLUO.js} +3 -3
  55. package/dist/bundle/chunks/{event-streams-BR2IL6C5.js → event-streams-7YGFEPBZ.js} +1 -1
  56. package/dist/bundle/chunks/{execute-2JXEKQ2X.js → execute-PIUR5MUV.js} +23 -23
  57. package/dist/bundle/chunks/{extract-OTCGZGTL.js → extract-4O5Z5725.js} +74 -71
  58. package/dist/bundle/chunks/github-copilot.js +50 -51
  59. package/dist/bundle/chunks/google-generative-ai-635YZEHN.js +22 -0
  60. package/dist/bundle/chunks/google-vertex-I3ZJ3SB2.js +26 -0
  61. package/dist/bundle/chunks/host-OQOEIWHK.js +2 -0
  62. package/dist/bundle/chunks/image-resize-worker.js +3 -2
  63. package/dist/bundle/chunks/kimi-coding.js +13 -14
  64. package/dist/bundle/chunks/{llama-cpp-classify-B3G57LVR.js → llama-cpp-classify-PP63BYDF.js} +1 -1
  65. package/dist/bundle/chunks/meta.js +10 -10
  66. package/dist/bundle/chunks/mistral-conversations-OKG5GKXR.js +42 -0
  67. package/dist/bundle/chunks/{node-VSA4ZN7D.js → node-UGQUSQE6.js} +1 -1
  68. package/dist/bundle/chunks/{node-SJPZTR4K.js → node-UNHECG4X.js} +168 -157
  69. package/dist/bundle/chunks/openai-codex-responses-6JYZIFT4.js +100 -0
  70. package/dist/bundle/chunks/openai-completions-YBNI6CAP.js +82 -0
  71. package/dist/bundle/chunks/{openai-decisions-WOWUC65P.js → openai-decisions-5G5YBFRQ.js} +1 -1
  72. package/dist/bundle/chunks/openai-responses-C3APJ6MK.js +27 -0
  73. package/dist/bundle/chunks/{openrouter-images-5K47HDAT.js → openrouter-images-FCJT7C7I.js} +2 -2
  74. package/dist/bundle/chunks/{pdfjs-EK6K7CXX.js → pdfjs-AKD6EBKN.js} +196 -175
  75. package/dist/bundle/chunks/pdfjs-decoders-OFXX4HDZ.js +2 -0
  76. package/dist/bundle/chunks/pdfjs-jbig2-TXR26KRI.js +278 -0
  77. package/dist/bundle/chunks/pdfjs-jbig2_nowasm_fallback-FH3KJM4H.js +326 -0
  78. package/dist/bundle/chunks/pdfjs-openjpeg-SKR7C34X.js +671 -0
  79. package/dist/bundle/chunks/pdfjs-openjpeg_nowasm_fallback-VUBL7UEE.js +974 -0
  80. package/dist/bundle/chunks/pi-messages-UHYZYEOC.js +25 -0
  81. package/dist/bundle/chunks/radius.js +8 -8
  82. package/dist/bundle/chunks/{runtime-K3F2QDQP.js → runtime-KE3HDSRT.js} +1 -1
  83. package/dist/bundle/chunks/{turndown.cjs-U7XOXH4O.js → turndown.cjs-WKGZX7NZ.js} +1 -1
  84. package/dist/bundle/chunks/{typesafe-system-one-43OCHGKP.js → typesafe-system-one-VYVAMWQV.js} +1 -1
  85. package/dist/bundle/chunks/{undici-EK3EUI2E.js → undici-C6S56CGI.js} +1 -1
  86. package/dist/bundle/chunks/virtual-modules-KDUZIB3W.js +23 -0
  87. package/dist/bundle/cli-runtime.js +3 -3
  88. package/dist/bundle/flow/package.json +5 -5
  89. package/dist/bundle/index.js +10 -10
  90. package/dist/bundle/rpc-entry.js +3 -3
  91. package/dist/cli/args.d.ts.map +1 -1
  92. package/dist/cli/args.js +9 -8
  93. package/dist/cli/args.js.map +1 -1
  94. package/dist/config.d.ts +12 -0
  95. package/dist/config.d.ts.map +1 -1
  96. package/dist/config.js +29 -5
  97. package/dist/config.js.map +1 -1
  98. package/dist/coordination/adapter/tool.d.ts +8 -5
  99. package/dist/coordination/adapter/tool.d.ts.map +1 -1
  100. package/dist/coordination/adapter/tool.js +32 -6
  101. package/dist/coordination/adapter/tool.js.map +1 -1
  102. package/dist/coordination/client/client.d.ts.map +1 -1
  103. package/dist/coordination/client/client.js +19 -1
  104. package/dist/coordination/client/client.js.map +1 -1
  105. package/dist/core/agent-session-runtime.js +3 -3
  106. package/dist/core/agent-session-runtime.js.map +1 -1
  107. package/dist/core/agent-session.d.ts +23 -3
  108. package/dist/core/agent-session.d.ts.map +1 -1
  109. package/dist/core/agent-session.js +142 -39
  110. package/dist/core/agent-session.js.map +1 -1
  111. package/dist/core/anthropic-subscription-usage.d.ts +4 -0
  112. package/dist/core/anthropic-subscription-usage.d.ts.map +1 -1
  113. package/dist/core/anthropic-subscription-usage.js +71 -1
  114. package/dist/core/anthropic-subscription-usage.js.map +1 -1
  115. package/dist/core/bug-report.d.ts +4 -4
  116. package/dist/core/codex-reset.d.ts +45 -0
  117. package/dist/core/codex-reset.d.ts.map +1 -0
  118. package/dist/core/codex-reset.js +190 -0
  119. package/dist/core/codex-reset.js.map +1 -0
  120. package/dist/core/codex-usage.d.ts +4 -2
  121. package/dist/core/codex-usage.d.ts.map +1 -1
  122. package/dist/core/codex-usage.js +9 -4
  123. package/dist/core/codex-usage.js.map +1 -1
  124. package/dist/core/compaction/branch-summarization.d.ts +3 -1
  125. package/dist/core/compaction/branch-summarization.d.ts.map +1 -1
  126. package/dist/core/compaction/branch-summarization.js +25 -10
  127. package/dist/core/compaction/branch-summarization.js.map +1 -1
  128. package/dist/core/compaction/compaction.d.ts +37 -3
  129. package/dist/core/compaction/compaction.d.ts.map +1 -1
  130. package/dist/core/compaction/compaction.js +274 -65
  131. package/dist/core/compaction/compaction.js.map +1 -1
  132. package/dist/core/compaction/utils.d.ts +19 -6
  133. package/dist/core/compaction/utils.d.ts.map +1 -1
  134. package/dist/core/compaction/utils.js +49 -11
  135. package/dist/core/compaction/utils.js.map +1 -1
  136. package/dist/core/exec.d.ts +9 -1
  137. package/dist/core/exec.d.ts.map +1 -1
  138. package/dist/core/exec.js +105 -61
  139. package/dist/core/exec.js.map +1 -1
  140. package/dist/core/export-html/template.css +9 -0
  141. package/dist/core/export-html/template.html +2 -0
  142. package/dist/core/export-html/template.js +200 -62
  143. package/dist/core/export-html/tool-renderer.d.ts.map +1 -1
  144. package/dist/core/export-html/tool-renderer.js +3 -0
  145. package/dist/core/export-html/tool-renderer.js.map +1 -1
  146. package/dist/core/extensions/index.d.ts +1 -1
  147. package/dist/core/extensions/index.d.ts.map +1 -1
  148. package/dist/core/extensions/index.js.map +1 -1
  149. package/dist/core/extensions/loader.d.ts.map +1 -1
  150. package/dist/core/extensions/loader.js +7 -6
  151. package/dist/core/extensions/loader.js.map +1 -1
  152. package/dist/core/extensions/pi-ai-extension-view.d.ts +19 -0
  153. package/dist/core/extensions/pi-ai-extension-view.d.ts.map +1 -0
  154. package/dist/core/extensions/pi-ai-extension-view.js +22 -0
  155. package/dist/core/extensions/pi-ai-extension-view.js.map +1 -0
  156. package/dist/core/extensions/types.d.ts +27 -4
  157. package/dist/core/extensions/types.d.ts.map +1 -1
  158. package/dist/core/extensions/types.js.map +1 -1
  159. package/dist/core/extensions/virtual-modules.d.ts.map +1 -1
  160. package/dist/core/extensions/virtual-modules.js +8 -7
  161. package/dist/core/extensions/virtual-modules.js.map +1 -1
  162. package/dist/core/http-dispatcher.d.ts +7 -0
  163. package/dist/core/http-dispatcher.d.ts.map +1 -1
  164. package/dist/core/http-dispatcher.js +107 -0
  165. package/dist/core/http-dispatcher.js.map +1 -1
  166. package/dist/core/keybindings.d.ts +56 -0
  167. package/dist/core/keybindings.d.ts.map +1 -1
  168. package/dist/core/keybindings.js +14 -2
  169. package/dist/core/keybindings.js.map +1 -1
  170. package/dist/core/mcp-servers.d.ts +9 -4
  171. package/dist/core/mcp-servers.d.ts.map +1 -1
  172. package/dist/core/mcp-servers.js +15 -5
  173. package/dist/core/mcp-servers.js.map +1 -1
  174. package/dist/core/model-config.d.ts +1691 -2042
  175. package/dist/core/model-config.d.ts.map +1 -1
  176. package/dist/core/model-config.js +2 -3
  177. package/dist/core/model-config.js.map +1 -1
  178. package/dist/core/model-registry.d.ts +35 -4
  179. package/dist/core/model-registry.d.ts.map +1 -1
  180. package/dist/core/model-registry.js +70 -8
  181. package/dist/core/model-registry.js.map +1 -1
  182. package/dist/core/model-resolver.d.ts.map +1 -1
  183. package/dist/core/model-resolver.js +16 -10
  184. package/dist/core/model-resolver.js.map +1 -1
  185. package/dist/core/model-runtime.d.ts.map +1 -1
  186. package/dist/core/model-runtime.js +21 -17
  187. package/dist/core/model-runtime.js.map +1 -1
  188. package/dist/core/package-manager.d.ts +29 -0
  189. package/dist/core/package-manager.d.ts.map +1 -1
  190. package/dist/core/package-manager.js +311 -60
  191. package/dist/core/package-manager.js.map +1 -1
  192. package/dist/core/pi-ai-schemas.d.ts +164 -0
  193. package/dist/core/pi-ai-schemas.d.ts.map +1 -0
  194. package/dist/core/pi-ai-schemas.js +21 -0
  195. package/dist/core/pi-ai-schemas.js.map +1 -0
  196. package/dist/core/pi-manifest.d.ts +1 -0
  197. package/dist/core/pi-manifest.d.ts.map +1 -1
  198. package/dist/core/pi-manifest.js +4 -0
  199. package/dist/core/pi-manifest.js.map +1 -1
  200. package/dist/core/project-trust.js +1 -1
  201. package/dist/core/project-trust.js.map +1 -1
  202. package/dist/core/resource-loader.d.ts +4 -1
  203. package/dist/core/resource-loader.d.ts.map +1 -1
  204. package/dist/core/resource-loader.js +38 -23
  205. package/dist/core/resource-loader.js.map +1 -1
  206. package/dist/core/sdk.d.ts.map +1 -1
  207. package/dist/core/sdk.js +4 -1
  208. package/dist/core/sdk.js.map +1 -1
  209. package/dist/core/session-manager.d.ts +7 -0
  210. package/dist/core/session-manager.d.ts.map +1 -1
  211. package/dist/core/session-manager.js +66 -26
  212. package/dist/core/session-manager.js.map +1 -1
  213. package/dist/core/settings-defaults.d.ts +2 -0
  214. package/dist/core/settings-defaults.d.ts.map +1 -1
  215. package/dist/core/settings-defaults.js +2 -0
  216. package/dist/core/settings-defaults.js.map +1 -1
  217. package/dist/core/settings-manager.d.ts +19 -8
  218. package/dist/core/settings-manager.d.ts.map +1 -1
  219. package/dist/core/settings-manager.js +70 -16
  220. package/dist/core/settings-manager.js.map +1 -1
  221. package/dist/core/settings-schema.d.ts +15 -2
  222. package/dist/core/settings-schema.d.ts.map +1 -1
  223. package/dist/core/settings-schema.js +37 -3
  224. package/dist/core/settings-schema.js.map +1 -1
  225. package/dist/core/skills.d.ts.map +1 -1
  226. package/dist/core/skills.js +6 -14
  227. package/dist/core/skills.js.map +1 -1
  228. package/dist/core/slash-commands.js +2 -2
  229. package/dist/core/slash-commands.js.map +1 -1
  230. package/dist/core/source-info.d.ts +9 -0
  231. package/dist/core/source-info.d.ts.map +1 -1
  232. package/dist/core/source-info.js +13 -0
  233. package/dist/core/source-info.js.map +1 -1
  234. package/dist/core/subscription-credits.d.ts +14 -0
  235. package/dist/core/subscription-credits.d.ts.map +1 -0
  236. package/dist/core/subscription-credits.js +10 -0
  237. package/dist/core/subscription-credits.js.map +1 -0
  238. package/dist/core/subscription-reset-status.d.ts +10 -0
  239. package/dist/core/subscription-reset-status.d.ts.map +1 -0
  240. package/dist/core/subscription-reset-status.js +2 -0
  241. package/dist/core/subscription-reset-status.js.map +1 -0
  242. package/dist/core/system-prompt.d.ts.map +1 -1
  243. package/dist/core/system-prompt.js +5 -6
  244. package/dist/core/system-prompt.js.map +1 -1
  245. package/dist/core/tools/bash.d.ts +2 -2
  246. package/dist/core/tools/bash.d.ts.map +1 -1
  247. package/dist/core/tools/bash.js.map +1 -1
  248. package/dist/core/tools/edit.d.ts +3 -3
  249. package/dist/core/tools/edit.d.ts.map +1 -1
  250. package/dist/core/tools/edit.js +2 -4
  251. package/dist/core/tools/edit.js.map +1 -1
  252. package/dist/core/tools/find.d.ts +2 -2
  253. package/dist/core/tools/find.d.ts.map +1 -1
  254. package/dist/core/tools/find.js.map +1 -1
  255. package/dist/core/tools/grep.d.ts +2 -2
  256. package/dist/core/tools/grep.d.ts.map +1 -1
  257. package/dist/core/tools/grep.js +7 -3
  258. package/dist/core/tools/grep.js.map +1 -1
  259. package/dist/core/tools/ls.d.ts +2 -2
  260. package/dist/core/tools/ls.d.ts.map +1 -1
  261. package/dist/core/tools/ls.js.map +1 -1
  262. package/dist/core/tools/read.d.ts +2 -2
  263. package/dist/core/tools/read.d.ts.map +1 -1
  264. package/dist/core/tools/read.js.map +1 -1
  265. package/dist/core/tools/render-utils.d.ts +4 -0
  266. package/dist/core/tools/render-utils.d.ts.map +1 -1
  267. package/dist/core/tools/render-utils.js +42 -12
  268. package/dist/core/tools/render-utils.js.map +1 -1
  269. package/dist/core/tools/renderers/edit.d.ts.map +1 -1
  270. package/dist/core/tools/renderers/edit.js +3 -3
  271. package/dist/core/tools/renderers/edit.js.map +1 -1
  272. package/dist/core/tools/renderers/write.d.ts.map +1 -1
  273. package/dist/core/tools/renderers/write.js +37 -29
  274. package/dist/core/tools/renderers/write.js.map +1 -1
  275. package/dist/core/tools/subagent.d.ts +9 -8
  276. package/dist/core/tools/subagent.d.ts.map +1 -1
  277. package/dist/core/tools/subagent.js +8 -5
  278. package/dist/core/tools/subagent.js.map +1 -1
  279. package/dist/core/tools/tool-definition-wrapper.d.ts +11 -1
  280. package/dist/core/tools/tool-definition-wrapper.d.ts.map +1 -1
  281. package/dist/core/tools/tool-definition-wrapper.js.map +1 -1
  282. package/dist/core/tools/write.d.ts +2 -2
  283. package/dist/core/tools/write.d.ts.map +1 -1
  284. package/dist/core/tools/write.js.map +1 -1
  285. package/dist/core/trust-manager.d.ts.map +1 -1
  286. package/dist/core/trust-manager.js +14 -8
  287. package/dist/core/trust-manager.js.map +1 -1
  288. package/dist/core/usage-totals.d.ts.map +1 -1
  289. package/dist/core/usage-totals.js +2 -0
  290. package/dist/core/usage-totals.js.map +1 -1
  291. package/dist/extensions/codemode/renderer.d.ts.map +1 -1
  292. package/dist/extensions/codemode/renderer.js +17 -9
  293. package/dist/extensions/codemode/renderer.js.map +1 -1
  294. package/dist/extensions/codemode/tool.d.ts +2 -1
  295. package/dist/extensions/codemode/tool.d.ts.map +1 -1
  296. package/dist/extensions/codemode/tool.js +33 -8
  297. package/dist/extensions/codemode/tool.js.map +1 -1
  298. package/dist/extensions/llama/ui.d.ts.map +1 -1
  299. package/dist/extensions/llama/ui.js +16 -4
  300. package/dist/extensions/llama/ui.js.map +1 -1
  301. package/dist/extensions/mcp/cli.d.ts.map +1 -1
  302. package/dist/extensions/mcp/cli.js +34 -8
  303. package/dist/extensions/mcp/cli.js.map +1 -1
  304. package/dist/extensions/mcp/index.js +4 -3
  305. package/dist/extensions/mcp/index.js.map +1 -1
  306. package/dist/extensions/mcp/oauth.d.ts +1 -1
  307. package/dist/extensions/mcp/oauth.d.ts.map +1 -1
  308. package/dist/extensions/mcp/oauth.js +7 -3
  309. package/dist/extensions/mcp/oauth.js.map +1 -1
  310. package/dist/extensions/mcp/ui.d.ts +1 -0
  311. package/dist/extensions/mcp/ui.d.ts.map +1 -1
  312. package/dist/extensions/mcp/ui.js +56 -28
  313. package/dist/extensions/mcp/ui.js.map +1 -1
  314. package/dist/extensions/tool-search/tool.d.ts +21 -6
  315. package/dist/extensions/tool-search/tool.d.ts.map +1 -1
  316. package/dist/extensions/tool-search/tool.js +104 -36
  317. package/dist/extensions/tool-search/tool.js.map +1 -1
  318. package/dist/extensions/usage/confirmation.d.ts +40 -0
  319. package/dist/extensions/usage/confirmation.d.ts.map +1 -0
  320. package/dist/extensions/usage/confirmation.js +198 -0
  321. package/dist/extensions/usage/confirmation.js.map +1 -0
  322. package/dist/extensions/usage/index.d.ts +4 -4
  323. package/dist/extensions/usage/index.d.ts.map +1 -1
  324. package/dist/extensions/usage/index.js +352 -33
  325. package/dist/extensions/usage/index.js.map +1 -1
  326. package/dist/extensions/usage/overview.d.ts +8 -1
  327. package/dist/extensions/usage/overview.d.ts.map +1 -1
  328. package/dist/extensions/usage/overview.js +54 -11
  329. package/dist/extensions/usage/overview.js.map +1 -1
  330. package/dist/extensions/usage/popup.d.ts +37 -6
  331. package/dist/extensions/usage/popup.d.ts.map +1 -1
  332. package/dist/extensions/usage/popup.js +396 -45
  333. package/dist/extensions/usage/popup.js.map +1 -1
  334. package/dist/humain/bedrock-provider/vendor/index.bundle.mjs +564 -130
  335. package/dist/humain/node-provider.d.ts.map +1 -1
  336. package/dist/humain/node-provider.js +1 -0
  337. package/dist/humain/node-provider.js.map +1 -1
  338. package/dist/humain/web-access/host.d.ts +2 -1
  339. package/dist/humain/web-access/host.d.ts.map +1 -1
  340. package/dist/humain/web-access/host.js +1 -1
  341. package/dist/humain/web-access/host.js.map +1 -1
  342. package/dist/humain/web-access/vendor/brave-rate-limit.d.ts +2 -0
  343. package/dist/humain/web-access/vendor/brave-rate-limit.d.ts.map +1 -1
  344. package/dist/humain/web-access/vendor/brave-rate-limit.js +2 -2
  345. package/dist/humain/web-access/vendor/brave-rate-limit.js.map +1 -1
  346. package/dist/humain/web-access/vendor/cloudflare-search.d.ts +5 -0
  347. package/dist/humain/web-access/vendor/cloudflare-search.d.ts.map +1 -0
  348. package/dist/humain/web-access/vendor/cloudflare-search.js +230 -0
  349. package/dist/humain/web-access/vendor/cloudflare-search.js.map +1 -0
  350. package/dist/humain/web-access/vendor/curator-page.d.ts.map +1 -1
  351. package/dist/humain/web-access/vendor/curator-page.js +18 -1
  352. package/dist/humain/web-access/vendor/curator-page.js.map +1 -1
  353. package/dist/humain/web-access/vendor/curator-server.d.ts.map +1 -1
  354. package/dist/humain/web-access/vendor/curator-server.js +12 -0
  355. package/dist/humain/web-access/vendor/curator-server.js.map +1 -1
  356. package/dist/humain/web-access/vendor/duckduckgo-rate-limit.d.ts +33 -0
  357. package/dist/humain/web-access/vendor/duckduckgo-rate-limit.d.ts.map +1 -0
  358. package/dist/humain/web-access/vendor/duckduckgo-rate-limit.js +84 -0
  359. package/dist/humain/web-access/vendor/duckduckgo-rate-limit.js.map +1 -0
  360. package/dist/humain/web-access/vendor/duckduckgo.d.ts +3 -0
  361. package/dist/humain/web-access/vendor/duckduckgo.d.ts.map +1 -1
  362. package/dist/humain/web-access/vendor/duckduckgo.js +54 -49
  363. package/dist/humain/web-access/vendor/duckduckgo.js.map +1 -1
  364. package/dist/humain/web-access/vendor/exa.d.ts +8 -3
  365. package/dist/humain/web-access/vendor/exa.d.ts.map +1 -1
  366. package/dist/humain/web-access/vendor/exa.js +129 -14
  367. package/dist/humain/web-access/vendor/exa.js.map +1 -1
  368. package/dist/humain/web-access/vendor/extract.d.ts +1 -1
  369. package/dist/humain/web-access/vendor/extract.d.ts.map +1 -1
  370. package/dist/humain/web-access/vendor/extract.js +68 -10
  371. package/dist/humain/web-access/vendor/extract.js.map +1 -1
  372. package/dist/humain/web-access/vendor/fetch-params.d.ts +2 -1
  373. package/dist/humain/web-access/vendor/fetch-params.d.ts.map +1 -1
  374. package/dist/humain/web-access/vendor/fetch-params.js +2 -2
  375. package/dist/humain/web-access/vendor/fetch-params.js.map +1 -1
  376. package/dist/humain/web-access/vendor/field-extract.d.ts +38 -0
  377. package/dist/humain/web-access/vendor/field-extract.d.ts.map +1 -0
  378. package/dist/humain/web-access/vendor/field-extract.js +350 -0
  379. package/dist/humain/web-access/vendor/field-extract.js.map +1 -0
  380. package/dist/humain/web-access/vendor/gemini-search.d.ts +15 -4
  381. package/dist/humain/web-access/vendor/gemini-search.d.ts.map +1 -1
  382. package/dist/humain/web-access/vendor/gemini-search.js +198 -16
  383. package/dist/humain/web-access/vendor/gemini-search.js.map +1 -1
  384. package/dist/humain/web-access/vendor/github-api.js +1 -1
  385. package/dist/humain/web-access/vendor/github-api.js.map +1 -1
  386. package/dist/humain/web-access/vendor/github-extract.d.ts.map +1 -1
  387. package/dist/humain/web-access/vendor/github-extract.js +3 -2
  388. package/dist/humain/web-access/vendor/github-extract.js.map +1 -1
  389. package/dist/humain/web-access/vendor/index.d.ts.map +1 -1
  390. package/dist/humain/web-access/vendor/index.js +137 -118
  391. package/dist/humain/web-access/vendor/index.js.map +1 -1
  392. package/dist/humain/web-access/vendor/mistral-search.js +1 -1
  393. package/dist/humain/web-access/vendor/mistral-search.js.map +1 -1
  394. package/dist/humain/web-access/vendor/ninerouter.d.ts +4 -0
  395. package/dist/humain/web-access/vendor/ninerouter.d.ts.map +1 -0
  396. package/dist/humain/web-access/vendor/ninerouter.js +110 -0
  397. package/dist/humain/web-access/vendor/ninerouter.js.map +1 -0
  398. package/dist/humain/web-access/vendor/offtopic-judge.d.ts +27 -0
  399. package/dist/humain/web-access/vendor/offtopic-judge.d.ts.map +1 -0
  400. package/dist/humain/web-access/vendor/offtopic-judge.js +61 -0
  401. package/dist/humain/web-access/vendor/offtopic-judge.js.map +1 -0
  402. package/dist/humain/web-access/vendor/openai-search.d.ts +1 -1
  403. package/dist/humain/web-access/vendor/openai-search.d.ts.map +1 -1
  404. package/dist/humain/web-access/vendor/openai-search.js +39 -13
  405. package/dist/humain/web-access/vendor/openai-search.js.map +1 -1
  406. package/dist/humain/web-access/vendor/outcrawl.d.ts +4 -0
  407. package/dist/humain/web-access/vendor/outcrawl.d.ts.map +1 -0
  408. package/dist/humain/web-access/vendor/outcrawl.js +196 -0
  409. package/dist/humain/web-access/vendor/outcrawl.js.map +1 -0
  410. package/dist/humain/web-access/vendor/page-query.d.ts.map +1 -1
  411. package/dist/humain/web-access/vendor/page-query.js +13 -3
  412. package/dist/humain/web-access/vendor/page-query.js.map +1 -1
  413. package/dist/humain/web-access/vendor/pdf-extract.d.ts +1 -3
  414. package/dist/humain/web-access/vendor/pdf-extract.d.ts.map +1 -1
  415. package/dist/humain/web-access/vendor/pdf-extract.js +0 -2
  416. package/dist/humain/web-access/vendor/pdf-extract.js.map +1 -1
  417. package/dist/humain/web-access/vendor/perplexity.d.ts +3 -0
  418. package/dist/humain/web-access/vendor/perplexity.d.ts.map +1 -1
  419. package/dist/humain/web-access/vendor/perplexity.js.map +1 -1
  420. package/dist/humain/web-access/vendor/query-rewrite.d.ts +2 -2
  421. package/dist/humain/web-access/vendor/query-rewrite.d.ts.map +1 -1
  422. package/dist/humain/web-access/vendor/query-rewrite.js +39 -13
  423. package/dist/humain/web-access/vendor/query-rewrite.js.map +1 -1
  424. package/dist/humain/web-access/vendor/searchapi.d.ts +4 -0
  425. package/dist/humain/web-access/vendor/searchapi.d.ts.map +1 -0
  426. package/dist/humain/web-access/vendor/searchapi.js +195 -0
  427. package/dist/humain/web-access/vendor/searchapi.js.map +1 -0
  428. package/dist/humain/web-access/vendor/sofya.d.ts +4 -0
  429. package/dist/humain/web-access/vendor/sofya.d.ts.map +1 -0
  430. package/dist/humain/web-access/vendor/sofya.js +193 -0
  431. package/dist/humain/web-access/vendor/sofya.js.map +1 -0
  432. package/dist/humain/web-access/vendor/source-check.d.ts +5 -1
  433. package/dist/humain/web-access/vendor/source-check.d.ts.map +1 -1
  434. package/dist/humain/web-access/vendor/source-check.js +34 -16
  435. package/dist/humain/web-access/vendor/source-check.js.map +1 -1
  436. package/dist/humain/web-access/vendor/ssrf-protection.d.ts +7 -0
  437. package/dist/humain/web-access/vendor/ssrf-protection.d.ts.map +1 -1
  438. package/dist/humain/web-access/vendor/ssrf-protection.js +24 -1
  439. package/dist/humain/web-access/vendor/ssrf-protection.js.map +1 -1
  440. package/dist/humain/web-access/vendor/summary-model-scope.d.ts +8 -3
  441. package/dist/humain/web-access/vendor/summary-model-scope.d.ts.map +1 -1
  442. package/dist/humain/web-access/vendor/summary-model-scope.js +15 -1
  443. package/dist/humain/web-access/vendor/summary-model-scope.js.map +1 -1
  444. package/dist/humain/web-access/vendor/summary-review.d.ts +7 -2
  445. package/dist/humain/web-access/vendor/summary-review.d.ts.map +1 -1
  446. package/dist/humain/web-access/vendor/summary-review.js +32 -28
  447. package/dist/humain/web-access/vendor/summary-review.js.map +1 -1
  448. package/dist/humain/web-access/vendor/tabstack.d.ts +6 -0
  449. package/dist/humain/web-access/vendor/tabstack.d.ts.map +1 -0
  450. package/dist/humain/web-access/vendor/tabstack.js +236 -0
  451. package/dist/humain/web-access/vendor/tabstack.js.map +1 -0
  452. package/dist/humain/web-access/vendor/tool-arguments.js +1 -1
  453. package/dist/humain/web-access/vendor/tool-arguments.js.map +1 -1
  454. package/dist/humain/web-access/vendor/upgrade-notice.d.ts +8 -0
  455. package/dist/humain/web-access/vendor/upgrade-notice.d.ts.map +1 -0
  456. package/dist/humain/web-access/vendor/upgrade-notice.js +46 -0
  457. package/dist/humain/web-access/vendor/upgrade-notice.js.map +1 -0
  458. package/dist/humain/web-access/vendor/utils.d.ts +9 -0
  459. package/dist/humain/web-access/vendor/utils.d.ts.map +1 -1
  460. package/dist/humain/web-access/vendor/utils.js +113 -27
  461. package/dist/humain/web-access/vendor/utils.js.map +1 -1
  462. package/dist/humain/web-access/vendor/web-tool-contract.d.ts +4 -0
  463. package/dist/humain/web-access/vendor/web-tool-contract.d.ts.map +1 -1
  464. package/dist/humain/web-access/vendor/web-tool-contract.js.map +1 -1
  465. package/dist/humain/web-access/vendor/web-tool-core.d.ts +17 -1
  466. package/dist/humain/web-access/vendor/web-tool-core.d.ts.map +1 -1
  467. package/dist/humain/web-access/vendor/web-tool-core.js +99 -22
  468. package/dist/humain/web-access/vendor/web-tool-core.js.map +1 -1
  469. package/dist/humain/web-access/vendor/xai-search.d.ts +1 -1
  470. package/dist/humain/web-access/vendor/xai-search.d.ts.map +1 -1
  471. package/dist/humain/web-access/vendor/xai-search.js +6 -5
  472. package/dist/humain/web-access/vendor/xai-search.js.map +1 -1
  473. package/dist/index.d.ts +3 -3
  474. package/dist/index.d.ts.map +1 -1
  475. package/dist/index.js.map +1 -1
  476. package/dist/main.d.ts.map +1 -1
  477. package/dist/main.js +20 -9
  478. package/dist/main.js.map +1 -1
  479. package/dist/modes/interactive/components/assistant-code-block.d.ts +34 -0
  480. package/dist/modes/interactive/components/assistant-code-block.d.ts.map +1 -0
  481. package/dist/modes/interactive/components/assistant-code-block.js +160 -0
  482. package/dist/modes/interactive/components/assistant-code-block.js.map +1 -0
  483. package/dist/modes/interactive/components/assistant-message.d.ts +31 -10
  484. package/dist/modes/interactive/components/assistant-message.d.ts.map +1 -1
  485. package/dist/modes/interactive/components/assistant-message.js +276 -73
  486. package/dist/modes/interactive/components/assistant-message.js.map +1 -1
  487. package/dist/modes/interactive/components/compaction-summary-message.d.ts.map +1 -1
  488. package/dist/modes/interactive/components/compaction-summary-message.js +2 -1
  489. package/dist/modes/interactive/components/compaction-summary-message.js.map +1 -1
  490. package/dist/modes/interactive/components/config-selector.d.ts.map +1 -1
  491. package/dist/modes/interactive/components/config-selector.js +4 -17
  492. package/dist/modes/interactive/components/config-selector.js.map +1 -1
  493. package/dist/modes/interactive/components/custom-editor.d.ts.map +1 -1
  494. package/dist/modes/interactive/components/custom-editor.js +7 -0
  495. package/dist/modes/interactive/components/custom-editor.js.map +1 -1
  496. package/dist/modes/interactive/components/custom-entry.d.ts.map +1 -1
  497. package/dist/modes/interactive/components/custom-entry.js +2 -1
  498. package/dist/modes/interactive/components/custom-entry.js.map +1 -1
  499. package/dist/modes/interactive/components/custom-message.d.ts.map +1 -1
  500. package/dist/modes/interactive/components/custom-message.js +2 -1
  501. package/dist/modes/interactive/components/custom-message.js.map +1 -1
  502. package/dist/modes/interactive/components/diff.d.ts.map +1 -1
  503. package/dist/modes/interactive/components/diff.js +3 -1
  504. package/dist/modes/interactive/components/diff.js.map +1 -1
  505. package/dist/modes/interactive/components/extension-editor.d.ts +2 -0
  506. package/dist/modes/interactive/components/extension-editor.d.ts.map +1 -1
  507. package/dist/modes/interactive/components/extension-editor.js +4 -0
  508. package/dist/modes/interactive/components/extension-editor.js.map +1 -1
  509. package/dist/modes/interactive/components/footer.d.ts +4 -1
  510. package/dist/modes/interactive/components/footer.d.ts.map +1 -1
  511. package/dist/modes/interactive/components/footer.js +6 -5
  512. package/dist/modes/interactive/components/footer.js.map +1 -1
  513. package/dist/modes/interactive/components/login-dialog.d.ts +5 -0
  514. package/dist/modes/interactive/components/login-dialog.d.ts.map +1 -1
  515. package/dist/modes/interactive/components/login-dialog.js +107 -11
  516. package/dist/modes/interactive/components/login-dialog.js.map +1 -1
  517. package/dist/modes/interactive/components/markdown-transform.d.ts +2 -1
  518. package/dist/modes/interactive/components/markdown-transform.d.ts.map +1 -1
  519. package/dist/modes/interactive/components/markdown-transform.js +3 -2
  520. package/dist/modes/interactive/components/markdown-transform.js.map +1 -1
  521. package/dist/modes/interactive/components/mermaid.d.ts.map +1 -1
  522. package/dist/modes/interactive/components/mermaid.js +18 -6
  523. package/dist/modes/interactive/components/mermaid.js.map +1 -1
  524. package/dist/modes/interactive/components/model-selector.d.ts +1 -0
  525. package/dist/modes/interactive/components/model-selector.d.ts.map +1 -1
  526. package/dist/modes/interactive/components/model-selector.js +17 -6
  527. package/dist/modes/interactive/components/model-selector.js.map +1 -1
  528. package/dist/modes/interactive/components/oauth-selector.d.ts +1 -0
  529. package/dist/modes/interactive/components/oauth-selector.d.ts.map +1 -1
  530. package/dist/modes/interactive/components/oauth-selector.js +13 -4
  531. package/dist/modes/interactive/components/oauth-selector.js.map +1 -1
  532. package/dist/modes/interactive/components/scoped-models-selector.d.ts +1 -0
  533. package/dist/modes/interactive/components/scoped-models-selector.d.ts.map +1 -1
  534. package/dist/modes/interactive/components/scoped-models-selector.js +14 -3
  535. package/dist/modes/interactive/components/scoped-models-selector.js.map +1 -1
  536. package/dist/modes/interactive/components/session-selector-search.d.ts +4 -0
  537. package/dist/modes/interactive/components/session-selector-search.d.ts.map +1 -1
  538. package/dist/modes/interactive/components/session-selector-search.js +86 -22
  539. package/dist/modes/interactive/components/session-selector-search.js.map +1 -1
  540. package/dist/modes/interactive/components/session-selector.d.ts +2 -1
  541. package/dist/modes/interactive/components/session-selector.d.ts.map +1 -1
  542. package/dist/modes/interactive/components/session-selector.js +16 -24
  543. package/dist/modes/interactive/components/session-selector.js.map +1 -1
  544. package/dist/modes/interactive/components/settings-submenu.d.ts.map +1 -1
  545. package/dist/modes/interactive/components/settings-submenu.js +2 -0
  546. package/dist/modes/interactive/components/settings-submenu.js.map +1 -1
  547. package/dist/modes/interactive/components/tool-execution.d.ts +2 -0
  548. package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
  549. package/dist/modes/interactive/components/tool-execution.js +15 -5
  550. package/dist/modes/interactive/components/tool-execution.js.map +1 -1
  551. package/dist/modes/interactive/components/tree-selector.d.ts +1 -0
  552. package/dist/modes/interactive/components/tree-selector.d.ts.map +1 -1
  553. package/dist/modes/interactive/components/tree-selector.js +5 -6
  554. package/dist/modes/interactive/components/tree-selector.js.map +1 -1
  555. package/dist/modes/interactive/components/user-message-selector.d.ts +1 -0
  556. package/dist/modes/interactive/components/user-message-selector.d.ts.map +1 -1
  557. package/dist/modes/interactive/components/user-message-selector.js +9 -1
  558. package/dist/modes/interactive/components/user-message-selector.js.map +1 -1
  559. package/dist/modes/interactive/components/user-message.d.ts +4 -3
  560. package/dist/modes/interactive/components/user-message.d.ts.map +1 -1
  561. package/dist/modes/interactive/components/user-message.js +20 -18
  562. package/dist/modes/interactive/components/user-message.js.map +1 -1
  563. package/dist/modes/interactive/external-editor.d.ts +1 -0
  564. package/dist/modes/interactive/external-editor.d.ts.map +1 -1
  565. package/dist/modes/interactive/external-editor.js +16 -4
  566. package/dist/modes/interactive/external-editor.js.map +1 -1
  567. package/dist/modes/interactive/interactive-mode.d.ts +6 -0
  568. package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
  569. package/dist/modes/interactive/interactive-mode.js +259 -83
  570. package/dist/modes/interactive/interactive-mode.js.map +1 -1
  571. package/dist/modes/interactive/model-search.d.ts +10 -0
  572. package/dist/modes/interactive/model-search.d.ts.map +1 -1
  573. package/dist/modes/interactive/model-search.js +21 -0
  574. package/dist/modes/interactive/model-search.js.map +1 -1
  575. package/dist/modes/interactive/oauth-account-format.d.ts +10 -1
  576. package/dist/modes/interactive/oauth-account-format.d.ts.map +1 -1
  577. package/dist/modes/interactive/oauth-account-format.js +42 -0
  578. package/dist/modes/interactive/oauth-account-format.js.map +1 -1
  579. package/dist/modes/interactive/theme/theme.d.ts +10 -0
  580. package/dist/modes/interactive/theme/theme.d.ts.map +1 -1
  581. package/dist/modes/interactive/theme/theme.js +28 -24
  582. package/dist/modes/interactive/theme/theme.js.map +1 -1
  583. package/dist/modes/print-mode.d.ts.map +1 -1
  584. package/dist/modes/print-mode.js +3 -2
  585. package/dist/modes/print-mode.js.map +1 -1
  586. package/dist/package-manager-cli.d.ts.map +1 -1
  587. package/dist/package-manager-cli.js +55 -4
  588. package/dist/package-manager-cli.js.map +1 -1
  589. package/dist/utils/ansi.d.ts.map +1 -1
  590. package/dist/utils/ansi.js +5 -2
  591. package/dist/utils/ansi.js.map +1 -1
  592. package/dist/utils/clipboard-command.d.ts.map +1 -1
  593. package/dist/utils/clipboard-command.js +4 -0
  594. package/dist/utils/clipboard-command.js.map +1 -1
  595. package/dist/utils/clipboard-image.d.ts +8 -0
  596. package/dist/utils/clipboard-image.d.ts.map +1 -1
  597. package/dist/utils/clipboard-image.js +31 -1
  598. package/dist/utils/clipboard-image.js.map +1 -1
  599. package/dist/utils/git.d.ts +1 -1
  600. package/dist/utils/git.d.ts.map +1 -1
  601. package/dist/utils/git.js.map +1 -1
  602. package/dist/utils/image-resize-core.d.ts.map +1 -1
  603. package/dist/utils/image-resize-core.js +5 -3
  604. package/dist/utils/image-resize-core.js.map +1 -1
  605. package/dist/utils/open-browser.d.ts.map +1 -1
  606. package/dist/utils/open-browser.js +96 -6
  607. package/dist/utils/open-browser.js.map +1 -1
  608. package/dist/utils/paths.d.ts +17 -0
  609. package/dist/utils/paths.d.ts.map +1 -1
  610. package/dist/utils/paths.js +42 -1
  611. package/dist/utils/paths.js.map +1 -1
  612. package/dist/utils/shell.d.ts +2 -1
  613. package/dist/utils/shell.d.ts.map +1 -1
  614. package/dist/utils/shell.js +12 -2
  615. package/dist/utils/shell.js.map +1 -1
  616. package/dist/utils/syntax-highlight.d.ts +5 -0
  617. package/dist/utils/syntax-highlight.d.ts.map +1 -1
  618. package/dist/utils/syntax-highlight.js +156 -11
  619. package/dist/utils/syntax-highlight.js.map +1 -1
  620. package/dist/utils/tools-manager.d.ts.map +1 -1
  621. package/dist/utils/tools-manager.js +30 -35
  622. package/dist/utils/tools-manager.js.map +1 -1
  623. package/docs/cli.md +22 -12
  624. package/docs/compaction.md +32 -8
  625. package/docs/coordination.md +2 -0
  626. package/docs/custom-provider.md +4 -2
  627. package/docs/environment-variables.md +2 -0
  628. package/docs/extensions.md +3169 -229
  629. package/docs/flow.md +2 -0
  630. package/docs/keybindings.md +24 -2
  631. package/docs/llama-cpp.md +30 -19
  632. package/docs/mcp.md +4 -2
  633. package/docs/message-types.md +7 -7
  634. package/docs/packages.md +27 -1
  635. package/docs/sessions.md +11 -3
  636. package/docs/settings.md +21 -9
  637. package/docs/slash-commands.md +51 -11
  638. package/docs/terminal-setup.md +3 -1
  639. package/docs/tmux.md +6 -0
  640. package/docs/tui.md +3 -1
  641. package/docs/windows.md +27 -0
  642. package/examples/extensions/README.md +2 -1
  643. package/examples/extensions/custom-provider-anthropic/index.ts +27 -31
  644. package/examples/extensions/custom-provider-anthropic/package-lock.json +7 -7
  645. package/examples/extensions/custom-provider-anthropic/package.json +2 -2
  646. package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
  647. package/examples/extensions/debug-provider.ts +2 -2
  648. package/examples/extensions/gondolin/package-lock.json +14 -24
  649. package/examples/extensions/gondolin/package.json +2 -2
  650. package/examples/extensions/preset.ts +2 -0
  651. package/examples/extensions/reload-runtime.ts +17 -5
  652. package/examples/extensions/todo.ts +7 -0
  653. package/examples/extensions/tools.ts +2 -0
  654. package/examples/extensions/with-deps/package-lock.json +2 -2
  655. package/examples/extensions/with-deps/package.json +1 -1
  656. package/examples/tsconfig.json +252 -0
  657. package/npm-shrinkwrap.json +289 -277
  658. package/package.json +29 -29
  659. package/schemas/keybindings.schema.json +28 -0
  660. package/schemas/models.schema.json +36 -36
  661. package/schemas/settings.schema.json +49 -0
  662. package/src/humain/ponytail/UPSTREAM.md +16 -2
  663. package/src/humain/ponytail/upstream.json +4 -4
  664. package/src/humain/web-access/UPSTREAM.md +48 -1
  665. package/src/humain/web-access/upstream.json +9 -6
  666. package/src/humain/web-access/vendor/CHANGELOG.md +1223 -0
  667. package/dist/bundle/chunks/anthropic-messages-ZP5KUK52.js +0 -67
  668. package/dist/bundle/chunks/azure-openai-responses-QJFYQ3DF.js +0 -15
  669. package/dist/bundle/chunks/chunk-2GCMACT4.js +0 -1956
  670. package/dist/bundle/chunks/chunk-AO6FF5JL.js +0 -21
  671. package/dist/bundle/chunks/chunk-EY3LZOUP.js +0 -1963
  672. package/dist/bundle/chunks/chunk-M74U5X4S.js +0 -119
  673. package/dist/bundle/chunks/chunk-N7CQ3UV3.js +0 -80
  674. package/dist/bundle/chunks/chunk-OR25QDSS.js +0 -365
  675. package/dist/bundle/chunks/chunk-PH7UP57J.js +0 -6
  676. package/dist/bundle/chunks/chunk-QW6PTCAB.js +0 -10
  677. package/dist/bundle/chunks/chunk-ROZV2IYD.js +0 -125
  678. package/dist/bundle/chunks/chunk-YFOLLX5D.js +0 -23
  679. package/dist/bundle/chunks/chunk-ZR4GF4WU.js +0 -54
  680. package/dist/bundle/chunks/compat-CJBWWYHE.js +0 -13
  681. package/dist/bundle/chunks/dist-IBUWEKEE.js +0 -24
  682. package/dist/bundle/chunks/dist-YFMJEHPH.js +0 -8
  683. package/dist/bundle/chunks/google-generative-ai-HVPCGIZ6.js +0 -21
  684. package/dist/bundle/chunks/google-vertex-UM5MAALA.js +0 -25
  685. package/dist/bundle/chunks/host-ZHEL5XQW.js +0 -2
  686. package/dist/bundle/chunks/mistral-conversations-AH72RLXK.js +0 -44
  687. package/dist/bundle/chunks/openai-codex-responses-L366637C.js +0 -98
  688. package/dist/bundle/chunks/openai-completions-ZP62QXJX.js +0 -83
  689. package/dist/bundle/chunks/openai-responses-DXUGSUTN.js +0 -26
  690. package/dist/bundle/chunks/pi-messages-MOQQDZBK.js +0 -23
  691. package/dist/bundle/chunks/virtual-modules-5D6QIJPN.js +0 -5
  692. package/examples/extensions/sandbox/index.ts +0 -321
  693. package/examples/extensions/sandbox/package-lock.json +0 -66
  694. package/examples/extensions/sandbox/package.json +0 -19
@@ -1,5 +1,5 @@
1
1
  import { createRequire as __piCreateRequire } from "node:module"; const require = __piCreateRequire(import.meta.url);
2
- import{Container,Spacer,Text,getCapabilities,getImageDimensions,highlightCode,hyperlink,imageFallback,keyHint,markReportsChanges,markStableRender,reportRenderChange,truncateToWidth,visibleWidth,wrapTextWithAnsi}from"./chunk-CN3Q5UNB.js";import{sanitizeBinaryOutput}from"./chunk-YFOLLX5D.js";import{getDocsPath,resolvePath}from"./chunk-ZI7TK7HM.js";import{DEFAULT_MAX_AGENT_RETRY_DELAY_MS}from"./chunk-QW6PTCAB.js";import{typebox_exports}from"./chunk-HIZWUSPN.js";import{randomBytes}from"node:crypto";import{createWriteStream}from"node:fs";import{writeFile}from"node:fs/promises";import{tmpdir}from"node:os";import{join}from"node:path";var OUTPUT_FILE_MODE=384;function createOutputFilePath(prefix,extension){return join(tmpdir(),`${prefix}-${randomBytes(8).toString("hex")}${extension}`)}async function writeOutputFile(prefix,extension,data){let path=createOutputFilePath(prefix,extension);return await writeFile(path,data,{mode:OUTPUT_FILE_MODE,flag:"wx"}),path}
2
+ import{CodeHighlighter,Container,Spacer,Text,getCapabilities,getImageDimensions,hyperlink,imageFallback,keyHint,markReportsChanges,markStableRender,reportRenderChange,sanitizeTerminalText,sanitizeTerminalTextFrom,truncateToWidth,visibleWidth,wrapTextWithAnsi}from"./chunk-CFHOPLW5.js";import{sanitizeBinaryOutput}from"./chunk-RO5YPAJH.js";import{typebox_exports}from"./chunk-VEGJT52D.js";import{getDocsPath,resolvePath,shortenHomePath}from"./chunk-IADQJFNH.js";import{DEFAULT_MAX_AGENT_RETRY_DELAY_MS}from"./chunk-H7Y4QY7K.js";import{randomBytes}from"node:crypto";import{createWriteStream}from"node:fs";import{writeFile}from"node:fs/promises";import{tmpdir}from"node:os";import{join}from"node:path";var OUTPUT_FILE_MODE=384;function createOutputFilePath(prefix,extension){return join(tmpdir(),`${prefix}-${randomBytes(8).toString("hex")}${extension}`)}async function writeOutputFile(prefix,extension,data){let path=createOutputFilePath(prefix,extension);return await writeFile(path,data,{mode:OUTPUT_FILE_MODE,flag:"wx"}),path}
3
3
  function createOutputFileStream(prefix,extension){let path=createOutputFilePath(prefix,extension);return{path,stream:createWriteStream(path,{mode:OUTPUT_FILE_MODE,flags:"wx"})}}var DEFAULT_MAX_LINES=2e3,DEFAULT_MAX_BYTES=51200;function countLines(content){if(content.length===0)return 0;let lines=1;for(let i=content.indexOf(`
4
4
  `);i!==-1;i=content.indexOf(`
5
5
  `,i+1))lines++;return content.endsWith(`
@@ -16,35 +16,36 @@ copyString(content.slice(outputStart,contentEnd)),truncated:!0,truncatedBy,total
16
16
  return line.length<=maxChars?{text:line,wasTruncated:!1}:{text:`${line.slice(0,maxChars)}... [truncated]`,wasTruncated:!0}}function truncateMiddle(content,maxBytes){let buf=Buffer.from(content,"utf-8"),totalLines=countLines(content);if(buf.length<=maxBytes)return{content,truncated:!1,removedChars:0,totalBytes:buf.length,totalLines};let isBoundary=index=>index>=buf.length||(buf[index]&192)!==128,headEnd=Math.floor(maxBytes/2);for(;headEnd>0&&!isBoundary(headEnd);)headEnd--;let tailStart=buf.length-
17
17
  (maxBytes-Math.floor(maxBytes/2));for(;tailStart<buf.length&&!isBoundary(tailStart);)tailStart++;let head=buf.subarray(0,headEnd).toString("utf-8"),tail=buf.subarray(tailStart).toString("utf-8"),removed=buf.subarray(headEnd,tailStart).toString("utf-8"),removedChars=removed.length;return SURROGATE.test(removed)&&(removedChars-=removed.match(SURROGATE_PAIRS)?.length??0),{content:`${head}\u2026${removedChars} chars truncated\u2026${tail}`,truncated:!0,removedChars,totalBytes:buf.length,totalLines}}function createUsageTotals(){return{input:0,output:0,cacheRead:0,cacheWrite:0,cost:0}}function addUsageToTotals(totals,usage){usage.usageIncomplete&&(totals.usageIncomplete=!0),totals.input+=usage.input,totals.output+=usage.output,totals.cacheRead+=usage.cacheRead,totals.cacheWrite+=usage.cacheWrite,totals.cost+=usage.cost.total}function combineUsage(first,second){return{...first.usageIncomplete||second.usageIncomplete?{usageIncomplete:!0}:{},input:first.input+second.input,output:first.output+second.
18
18
  output,cacheRead:first.cacheRead+second.cacheRead,cacheWrite:first.cacheWrite+second.cacheWrite,...first.cacheWrite1h!==void 0||second.cacheWrite1h!==void 0?{cacheWrite1h:(first.cacheWrite1h??0)+(second.cacheWrite1h??0)}:{},...first.reasoning!==void 0||second.reasoning!==void 0?{reasoning:(first.reasoning??0)+(second.reasoning??0)}:{},totalTokens:first.totalTokens+second.totalTokens,cost:{input:first.cost.input+second.cost.input,output:first.cost.output+second.cost.output,cacheRead:first.cost.cacheRead+
19
- second.cost.cacheRead,cacheWrite:first.cost.cacheWrite+second.cost.cacheWrite,total:first.cost.total+second.cost.total}}}function normalizeUsage(usage){let result={input:0,output:0,cacheRead:0,cacheWrite:0,totalTokens:0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0},...usage?.usageIncomplete?{usageIncomplete:!0}:{}};for(let key of["input","output","cacheRead","cacheWrite"]){let count=usage?.[key];typeof count=="number"&&Number.isSafeInteger(count)&&count>=0?result[key]=count:result.usageIncomplete=
20
- !0;let cost2=usage?.cost?.[key];typeof cost2=="number"&&Number.isFinite(cost2)&&cost2>=0?result.cost[key]=cost2:result.usageIncomplete=!0}let totalTokens=usage?.totalTokens;(typeof totalTokens!="number"||!Number.isSafeInteger(totalTokens)||totalTokens<0)&&(result.usageIncomplete=!0),result.totalTokens=result.input+result.output+result.cacheRead+result.cacheWrite;let cost=usage?.cost?.total;return typeof cost=="number"&&Number.isFinite(cost)&&cost>=0?result.cost.total=cost:result.usageIncomplete=
21
- !0,result}function getSummaryUsage(usage,ids,kind,owners){if(ids===void 0||Array.isArray(ids)&&ids.length===0)return usage;let remaining=normalizeUsage(usage),ownerIds=Array.isArray(ids)?[...new Set(ids)]:[],covered=ownerIds.length>0,observed=createUsageTotals();for(let id of ownerIds){let owner=typeof id=="string"&&id.length>0?owners.find(entry=>entry.id===id):void 0;if(!owner||owner.kind!==kind){covered=!1;continue}let value=normalizeUsage(owner.usage);(typeof owner.provider!="string"||owner.provider.
22
- length===0||typeof owner.model!="string"||owner.model.length===0||value.usageIncomplete)&&(covered=!1),addUsageToTotals(observed,value)}if(covered&&!usage)return;covered&&!usage?.usageIncomplete&&delete remaining.usageIncomplete;let residual=remaining.cost.total-observed.cost,drift=Number.EPSILON*Math.max(remaining.cost.total,observed.cost)*(ownerIds.length+1);remaining.cost.total=residual>drift?residual:0;for(let key of["input","output","cacheRead","cacheWrite"])remaining[key]=Math.max(0,remaining[key]-
23
- observed[key]);return remaining.totalTokens=remaining.input+remaining.output+remaining.cacheRead+remaining.cacheWrite,(!covered||remaining.cost.total>0||remaining.totalTokens>0)&&(remaining.usageIncomplete=!0),remaining.usageIncomplete||remaining.cost.total>0||remaining.totalTokens>0?remaining:void 0}function getSessionUsage(entries){let owners=entries.filter(entry=>entry.type==="usage"),seen=new Set,summaries=new Map,result=[];for(let entry of entries){let usage;if(entry.type==="usage"){if(seen.
24
- has(entry.id))continue;seen.add(entry.id),usage=normalizeUsage(entry.usage)}else if(entry.type==="message"&&(entry.message.role==="assistant"||entry.message.role==="toolResult"))usage=entry.message.usage;else if((entry.type==="compaction"||entry.type==="branch_summary")&&(usage=getSummaryUsage(entry.usage,entry.usageEntryIds,entry.type==="compaction"?"compaction":"branchSummary",owners),Array.isArray(entry.usageEntryIds)&&entry.usageEntryIds.length>0)){let key=JSON.stringify([entry.type,[...new Set(
25
- entry.usageEntryIds)].sort()]),previous=summaries.get(key);usage&&(!previous||usage.cost.total>=previous.usage.cost.total)&&summaries.set(key,{entry,usage});continue}usage&&result.push({entry,usage})}return[...result,...summaries.values()]}function getUsageCostBreakdown(entries){let totalsByKey=new Map;for(let{entry,usage}of getSessionUsage(entries)){let key;if(entry.type==="message"&&entry.message.role==="assistant"?key=`${entry.message.provider}/${entry.message.responseModel??entry.message.model}`:
26
- entry.type==="usage"?key=`${entry.provider}/${entry.model}`:key="Tools/summaries",!key||!usage)continue;let totals=totalsByKey.get(key);totals||(totals=createUsageTotals(),totalsByKey.set(key,totals)),addUsageToTotals(totals,usage)}return Array.from(totalsByKey,([key,totals])=>({key,...totals.usageIncomplete?{usageIncomplete:!0}:{},cost:totals.cost,tokens:totals.input+totals.output+totals.cacheRead+totals.cacheWrite})).filter(entry=>entry.usageIncomplete||entry.cost>0||entry.tokens>0).sort((a,b)=>b.
27
- cost-a.cost)}function truncateToVisualLines(text,maxVisualLines,width,paddingX=0,keep="end"){if(!text)return{visualLines:[],skippedCount:0};let allVisualLines=new Text(text,paddingX,0).render(width);if(allVisualLines.length<=maxVisualLines)return{visualLines:allVisualLines,skippedCount:0};let truncatedLines=keep==="start"?allVisualLines.slice(0,maxVisualLines):allVisualLines.slice(-maxVisualLines),skippedCount=allVisualLines.length-maxVisualLines;return{visualLines:truncatedLines,skippedCount}}function truncateStyledLinesToVisualEnd(lines,styleLine,maxVisualLines,width){
19
+ second.cost.cacheRead,cacheWrite:first.cost.cacheWrite+second.cost.cacheWrite,total:first.cost.total+second.cost.total,totalFromProvider:first.cost.totalFromProvider===!0&&second.cost.totalFromProvider===!0}}}function normalizeUsage(usage){let result={input:0,output:0,cacheRead:0,cacheWrite:0,totalTokens:0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0},...usage?.usageIncomplete?{usageIncomplete:!0}:{}};for(let key of["input","output","cacheRead","cacheWrite"]){let count=usage?.[key];typeof count==
20
+ "number"&&Number.isSafeInteger(count)&&count>=0?result[key]=count:result.usageIncomplete=!0;let cost2=usage?.cost?.[key];typeof cost2=="number"&&Number.isFinite(cost2)&&cost2>=0?result.cost[key]=cost2:result.usageIncomplete=!0}let totalTokens=usage?.totalTokens;(typeof totalTokens!="number"||!Number.isSafeInteger(totalTokens)||totalTokens<0)&&(result.usageIncomplete=!0),result.totalTokens=result.input+result.output+result.cacheRead+result.cacheWrite;let cost=usage?.cost?.total;return typeof cost==
21
+ "number"&&Number.isFinite(cost)&&cost>=0?result.cost.total=cost:result.usageIncomplete=!0,result}function getSummaryUsage(usage,ids,kind,owners){if(ids===void 0||Array.isArray(ids)&&ids.length===0)return usage;let remaining=normalizeUsage(usage),ownerIds=Array.isArray(ids)?[...new Set(ids)]:[],covered=ownerIds.length>0,observed=createUsageTotals();for(let id of ownerIds){let owner=typeof id=="string"&&id.length>0?owners.find(entry=>entry.id===id):void 0;if(!owner||owner.kind!==kind){covered=!1;continue}
22
+ let value=normalizeUsage(owner.usage);(typeof owner.provider!="string"||owner.provider.length===0||typeof owner.model!="string"||owner.model.length===0||value.usageIncomplete)&&(covered=!1),addUsageToTotals(observed,value)}if(covered&&!usage)return;covered&&!usage?.usageIncomplete&&delete remaining.usageIncomplete;let residual=remaining.cost.total-observed.cost,drift=Number.EPSILON*Math.max(remaining.cost.total,observed.cost)*(ownerIds.length+1);remaining.cost.total=residual>drift?residual:0;for(let key of[
23
+ "input","output","cacheRead","cacheWrite"])remaining[key]=Math.max(0,remaining[key]-observed[key]);return remaining.totalTokens=remaining.input+remaining.output+remaining.cacheRead+remaining.cacheWrite,(!covered||remaining.cost.total>0||remaining.totalTokens>0)&&(remaining.usageIncomplete=!0),remaining.usageIncomplete||remaining.cost.total>0||remaining.totalTokens>0?remaining:void 0}function getSessionUsage(entries){let owners=entries.filter(entry=>entry.type==="usage"),seen=new Set,summaries=new Map,
24
+ result=[];for(let entry of entries){let usage;if(entry.type==="usage"){if(seen.has(entry.id))continue;seen.add(entry.id),usage=normalizeUsage(entry.usage)}else if(entry.type==="message"&&(entry.message.role==="assistant"||entry.message.role==="toolResult"))usage=entry.message.usage;else if((entry.type==="compaction"||entry.type==="branch_summary")&&(usage=getSummaryUsage(entry.usage,entry.usageEntryIds,entry.type==="compaction"?"compaction":"branchSummary",owners),Array.isArray(entry.usageEntryIds)&&
25
+ entry.usageEntryIds.length>0)){let key=JSON.stringify([entry.type,[...new Set(entry.usageEntryIds)].sort()]),previous=summaries.get(key);usage&&(!previous||usage.cost.total>=previous.usage.cost.total)&&summaries.set(key,{entry,usage});continue}usage&&result.push({entry,usage})}return[...result,...summaries.values()]}function getUsageCostBreakdown(entries){let totalsByKey=new Map;for(let{entry,usage}of getSessionUsage(entries)){let key;if(entry.type==="message"&&entry.message.role==="assistant"?key=
26
+ `${entry.message.provider}/${entry.message.responseModel??entry.message.model}`:entry.type==="usage"?key=`${entry.provider}/${entry.model}`:key="Tools/summaries",!key||!usage)continue;let totals=totalsByKey.get(key);totals||(totals=createUsageTotals(),totalsByKey.set(key,totals)),addUsageToTotals(totals,usage)}return Array.from(totalsByKey,([key,totals])=>({key,...totals.usageIncomplete?{usageIncomplete:!0}:{},cost:totals.cost,tokens:totals.input+totals.output+totals.cacheRead+totals.cacheWrite})).
27
+ filter(entry=>entry.usageIncomplete||entry.cost>0||entry.tokens>0).sort((a,b)=>b.cost-a.cost)}function truncateToVisualLines(text,maxVisualLines,width,paddingX=0,keep="end"){if(!text)return{visualLines:[],skippedCount:0};let allVisualLines=new Text(text,paddingX,0).render(width);if(allVisualLines.length<=maxVisualLines)return{visualLines:allVisualLines,skippedCount:0};let truncatedLines=keep==="start"?allVisualLines.slice(0,maxVisualLines):allVisualLines.slice(-maxVisualLines),skippedCount=allVisualLines.length-maxVisualLines;return{visualLines:truncatedLines,skippedCount}}function truncateStyledLinesToVisualEnd(lines,styleLine,maxVisualLines,width){
28
28
  if(lines.length===0)return{visualLines:[],skippedCount:0};let contentWidth=Math.max(1,width),visualCount=line=>{let normalized=line.replace(/\t/g," ");return normalized===""||visibleWidth(normalized)<=contentWidth?1:wrapTextWithAnsi(styleLine(normalized),contentWidth).length},start=lines.length,tailVisualLines=0;for(;start>0&&tailVisualLines<maxVisualLines;)start--,tailVisualLines+=visualCount(lines[start]);let headVisualLines=0;for(let i=0;i<start;i++)headVisualLines+=visualCount(lines[i]);let tail=new Text(
29
29
  lines.slice(start).map(styleLine).join(`
30
30
  `),0,0).render(width),total=headVisualLines+tail.length;return total<=maxVisualLines?{visualLines:tail,skippedCount:0}:{visualLines:tail.slice(-maxVisualLines),skippedCount:total-maxVisualLines}}var VisualLinePreview=class{options;cachedWidth;cachedLines;constructor(options){this.options=options}render(width){if(this.cachedLines===void 0||this.cachedWidth!==width){let options=this.options,{maxVisualLines,keep,formatHint}=options,preview="lines"in options?truncateStyledLinesToVisualEnd(options.lines,
31
31
  options.styleLine,maxVisualLines,width):truncateToVisualLines(options.text,maxVisualLines,width,0,keep),lines=preview.visualLines;if(preview.skippedCount>0){let hint=truncateToWidth(formatHint(preview.skippedCount),width,"...");this.cachedLines=keep==="start"?[...lines,hint]:[hint,...lines]}else this.cachedLines=lines;this.cachedWidth=width}return this.cachedLines}invalidate(){this.cachedWidth=void 0,this.cachedLines=void 0,reportRenderChange(this)}};markStableRender(VisualLinePreview);markReportsChanges(
32
- VisualLinePreview);import*as os from"node:os";import{pathToFileURL}from"node:url";var ST="(?:\\u0007|\\u001B\\u005C|\\u009C)",OSC_START="\\u001B\\]",CSI_START="[\\u001B\\u009B][[\\]()#;?]*(?:\\d{1,4}(?:[;:]\\d{0,4})*)?",CSI_FINAL="[\\dA-PR-TZcf-nq-uy=><~]",ansiRegex=new RegExp(`(?:${OSC_START}[\\s\\S]*?${ST})|${CSI_START}${CSI_FINAL}`,"g"),unfinishedAnsiAtEndRegex=new RegExp(`(?:${OSC_START}(?:[^\\u0007\\u009C\\u001B]|\\u001B(?!\\\\))*|${CSI_START})$`),MAX_PENDING_ANSI_LENGTH=256;function splitIncompleteAnsiSuffix(value){if(!value.includes("\x1B")&&!value.includes("\x9B"))return{
33
- complete:value,pending:""};let windowStart=Math.max(0,value.length-MAX_PENDING_ANSI_LENGTH),match=unfinishedAnsiAtEndRegex.exec(value.slice(windowStart));if(!match)return{complete:value,pending:""};let splitAt=windowStart+match.index;return{complete:value.slice(0,splitAt),pending:value.slice(splitAt)}}function stripAnsi(value){if(typeof value!="string")throw new TypeError(`Expected a \`string\`, got \`${typeof value}\``);return!value.includes("\x1B")&&!value.includes("\x9B")?value:value.replace(
34
- ansiRegex,"")}function shortenPath(path){if(typeof path!="string")return"";let home=os.homedir();return path.startsWith(home)?`~${path.slice(home.length)}`:path}function linkPath(styledText,rawPath,cwd){if(!getCapabilities().hyperlinks)return styledText;let absolutePath=resolvePath(rawPath,cwd);return hyperlink(styledText,pathToFileURL(absolutePath).href)}function str(value){return typeof value=="string"?value:value==null?"":null}function parseLineNumber(value){return typeof value=="string"&&value.trim()!==""&&
35
- (value=Number(value)),typeof value=="number"&&Number.isFinite(value)?value:void 0}function formatReadLineRange(offset,limit){if(offset==null&&limit==null)return"";let start=offset==null?1:parseLineNumber(offset);if(start===void 0)return"";if(limit==null)return`:${start}`;let count=parseLineNumber(limit);if(count===void 0)return"";let end=start+count-1;return`:${start}${end?`-${end}`:""}`}function replaceTabs(text){return text.replace(/\t/g," ")}function normalizeDisplayText(text){return text.replace(
36
- /\r/g,"")}function getTextOutput(result,showImages){if(!result)return"";let textBlocks=result.content.filter(c=>c.type==="text"),imageBlocks=result.content.filter(c=>c.type==="image"),output=textBlocks.map(c=>sanitizeBinaryOutput(stripAnsi(c.text||"")).replace(/\r/g,"")).join(`
32
+ VisualLinePreview);import{pathToFileURL}from"node:url";var ST="(?:\\u0007|\\u001B\\u005C|\\u009C)",OSC_START="\\u001B\\]",CSI_START="(?:(?:\\u001B\\[|\\u009B)[<=>]|[\\u001B\\u009B][[\\]()#;?]*)(?:\\d{1,4}(?:[;:]\\d{0,4})*)?",CSI_FINAL="[\\dA-PR-TZcf-nq-uy=><~]",ansiRegex=new RegExp(`(?:${OSC_START}[\\s\\S]*?${ST})|${CSI_START}${CSI_FINAL}`,"g"),unfinishedAnsiAtEndRegex=new RegExp(`(?:${OSC_START}(?:[^\\u0007\\u009C\\u001B]|\\u001B(?!\\\\))*|${CSI_START})$`),MAX_PENDING_ANSI_LENGTH=256;function splitIncompleteAnsiSuffix(value){if(!value.includes("\x1B")&&
33
+ !value.includes("\x9B"))return{complete:value,pending:""};let windowStart=Math.max(0,value.length-MAX_PENDING_ANSI_LENGTH),match=unfinishedAnsiAtEndRegex.exec(value.slice(windowStart));if(!match)return{complete:value,pending:""};let splitAt=windowStart+match.index;return{complete:value.slice(0,splitAt),pending:value.slice(splitAt)}}function stripAnsi(value){if(typeof value!="string")throw new TypeError(`Expected a \`string\`, got \`${typeof value}\``);return!value.includes("\x1B")&&!value.includes(
34
+ "\x9B")?value:value.replace(ansiRegex,"")}function shortenPath(path){return typeof path!="string"?"":shortenHomePath(path)}function linkPath(styledText,rawPath,cwd){if(!getCapabilities().hyperlinks)return styledText;let absolutePath=resolvePath(rawPath,cwd);return hyperlink(styledText,pathToFileURL(absolutePath).href)}function str(value){return typeof value=="string"?sanitizeArgument(value):value==null?"":null}var sanitizedArguments=[],SANITIZED_ARGUMENTS_KEPT=4,SANITIZED_ARGUMENT_MIN_LENGTH=1024;function sanitizeArgument(text){if(text.
35
+ length<SANITIZED_ARGUMENT_MIN_LENGTH)return sanitizeTerminalText(text);let previous;for(let i=sanitizedArguments.length-1;i>=0;i--){let entry=sanitizedArguments[i];if(text.length>=entry.raw.length&&text.startsWith(entry.raw)){previous=entry,sanitizedArguments.splice(i,1);break}}let sanitized=sanitizeTerminalTextFrom(text,previous);return sanitizedArguments.push(sanitized),sanitizedArguments.length>SANITIZED_ARGUMENTS_KEPT&&sanitizedArguments.shift(),sanitized.text}function parseLineNumber(value){
36
+ return typeof value=="string"&&value.trim()!==""&&(value=Number(value)),typeof value=="number"&&Number.isFinite(value)?value:void 0}function formatReadLineRange(offset,limit){if(offset==null&&limit==null)return"";let start=offset==null?1:parseLineNumber(offset);if(start===void 0)return"";if(limit==null)return`:${start}`;let count=parseLineNumber(limit);if(count===void 0)return"";let end=start+count-1;return`:${start}${end?`-${end}`:""}`}function replaceTabs(text){return text.replace(/\t/g," ")}
37
+ function normalizeDisplayText(text){return text.replace(/\r/g,"")}function getTextOutput(result,showImages){if(!result)return"";let textBlocks=result.content.filter(c=>c.type==="text"),imageBlocks=result.content.filter(c=>c.type==="image"),output=textBlocks.map(c=>sanitizeBinaryOutput(stripAnsi(c.text||"")).replace(/\r/g,"")).join(`
37
38
  `),caps=getCapabilities();if(imageBlocks.length>0&&(!caps.images||!showImages)){let imageIndicators=imageBlocks.map(img=>{let mimeType=img.mimeType??"image/unknown",dims=img.data&&img.mimeType?getImageDimensions(img.data,img.mimeType)??void 0:void 0;return imageFallback(mimeType,dims)}).join(`
38
39
  `);output=output?`${output}
39
- ${imageIndicators}`:imageIndicators}return output}var COLLAPSED_ARGS_CHARS=100;function formatToolCallWithArgs(title,args,theme,expanded){let header=theme.fg("toolTitle",theme.bold(title));if(args==null)return header;let entries=typeof args=="object"&&!Array.isArray(args)?Object.entries(args):[["args",args]];if(entries.length===0)return header;if(expanded){let lines=entries.map(([key,value])=>{let text=typeof value=="string"?value:JSON.stringify(value,null,2)??String(value);return` ${key}: ${replaceTabs(
40
- text).replace(/\r/g,"").split(`
40
+ ${imageIndicators}`:imageIndicators}return output}var COLLAPSED_ARGS_CHARS=100;function formatToolCallWithArgs(title,args,theme,expanded){let header=theme.fg("toolTitle",theme.bold(sanitizeTerminalText(title)));if(args==null)return header;let entries=typeof args=="object"&&!Array.isArray(args)?Object.entries(args):[["args",args]];if(entries.length===0)return header;if(expanded){let lines=entries.map(([key,value])=>{let text=typeof value=="string"?value:JSON.stringify(value,null,2)??String(value),
41
+ shown=replaceTabs(sanitizeTerminalText(text)).replace(/\r/g,"");return` ${sanitizeTerminalText(key)}: ${shown.split(`
41
42
  `).join(`
42
43
  `)}`});return`${header}
43
44
  ${theme.fg("muted",lines.join(`
44
- `))}`}let pairs=entries.map(([key,value])=>`${key}=${JSON.stringify(value)??String(value)}`).join(" "),preview=pairs.length>COLLAPSED_ARGS_CHARS?`${pairs.slice(0,COLLAPSED_ARGS_CHARS-3)}...`:pairs;return`${header} ${theme.fg("muted",preview)}`}function formatToolDuration(ms){let seconds=ms/1e3;if(seconds<60)return`${seconds.toFixed(1)}s`;let totalSeconds=Math.floor(seconds),minutes=Math.floor(totalSeconds/60),remainder=totalSeconds%60;return minutes<60?`${minutes}m ${remainder}s`:`${Math.floor(minutes/
45
- 60)}h ${minutes%60}m ${remainder}s`}function startToolTimer(context){let state=context.state;context.executionStarted&&state.startedAt===void 0&&(state.startedAt=Date.now(),state.endedAt=void 0)}function toolTimerText(context,isPartial){let state=context.state;if(state.startedAt!==void 0&&isPartial&&!state.interval&&(state.interval=setInterval(()=>context.invalidate(),1e3)),(!isPartial||context.isError)&&(state.endedAt??=Date.now(),state.interval&&(clearInterval(state.interval),state.interval=void 0)),
46
- !isPartial&&context.durationMs!==void 0)return`Took ${formatToolDuration(context.durationMs)}`;if(state.startedAt===void 0)return;let endTime=state.endedAt??Date.now();return`${isPartial?"Elapsed":"Took"} ${formatToolDuration(endTime-state.startedAt)}`}function invalidArgText(theme){return theme.fg("error","[invalid arg]")}function renderToolPath(rawPath,theme,cwd,options){if(rawPath===null)return invalidArgText(theme);let value=rawPath||options?.emptyFallback;return value?linkPath(theme.fg("acc\
47
- ent",shortenPath(value)),value,cwd):theme.fg("toolOutput","...")}function toCodemodeIdentifier(name){let identifier="";for(let char of name){let valid=identifier===""?/^[A-Za-z_$]$/.test(char):/^[A-Za-z0-9_$]$/.test(char);identifier+=valid?char:"_"}return identifier===""?"_":identifier}var IDENTIFIER=/^[A-Za-z_$][A-Za-z0-9_$]*$/,INDENT=" ",DEFAULT_INPUT_SCHEMA_MAX_CHARS=16e3,MAX_REF_EXPANSIONS=32,TAG_KEYWORDS=["minimum","exclusiveMinimum","maximum","exclusiveMaximum","multipleOf","minLength","maxLength","pattern","format","minItems","maxItems"],LOWER_BOUNDS=new Set(["minimum","exclusiveMinimum","minLength","minItems"]),UPPER_BOUNDS=new Set(["maximum","exclusiveMaximum","maxLength","maxItems"]),MAX_TAG_CHARS=80,LINE_TERMINATORS=/[\r\n\u2028\u2029]/g;function renderToolSignature(tool,options={}){let input=tool.inputSchema===void 0?"unknown":schemaToType(tool.inputSchema,{maxChars:options.inputMaxChars??DEFAULT_INPUT_SCHEMA_MAX_CHARS});return`${toCodemodeIdentifier(tool.name)}(args: ${input}): Promise<${renderToolOutputType(tool.outputSchema)}>;`}function renderToolSample(tool,options={}){let declaration=`declare const tools: { ${renderToolSignature(tool,options)} };`;return`${tool.description?.trim()??""}
45
+ `))}`}let pairs=entries.map(([key,value])=>`${key}=${JSON.stringify(value)??String(value)}`).join(" "),preview=pairs.length>COLLAPSED_ARGS_CHARS?`${pairs.slice(0,COLLAPSED_ARGS_CHARS-3)}...`:pairs;return`${header} ${theme.fg("muted",sanitizeTerminalText(preview))}`}function formatToolDuration(ms){let seconds=ms/1e3;if(seconds<60)return`${seconds.toFixed(1)}s`;let totalSeconds=Math.floor(seconds),minutes=Math.floor(totalSeconds/60),remainder=totalSeconds%60;return minutes<60?`${minutes}m ${remainder}\
46
+ s`:`${Math.floor(minutes/60)}h ${minutes%60}m ${remainder}s`}function startToolTimer(context){let state=context.state;context.executionStarted&&state.startedAt===void 0&&(state.startedAt=Date.now(),state.endedAt=void 0)}function toolTimerText(context,isPartial){let state=context.state;if(state.startedAt!==void 0&&isPartial&&!state.interval&&(state.interval=setInterval(()=>context.invalidate(),1e3)),(!isPartial||context.isError)&&(state.endedAt??=Date.now(),state.interval&&(clearInterval(state.interval),
47
+ state.interval=void 0)),!isPartial&&context.durationMs!==void 0)return`Took ${formatToolDuration(context.durationMs)}`;if(state.startedAt===void 0)return;let endTime=state.endedAt??Date.now();return`${isPartial?"Elapsed":"Took"} ${formatToolDuration(endTime-state.startedAt)}`}function invalidArgText(theme){return theme.fg("error","[invalid arg]")}function renderToolPath(rawPath,theme,cwd,options){if(rawPath===null)return invalidArgText(theme);let value=rawPath||options?.emptyFallback;return value?
48
+ linkPath(theme.fg("accent",shortenPath(value)),value,cwd):theme.fg("toolOutput","...")}function toCodemodeIdentifier(name){let identifier="";for(let char of name){let valid=identifier===""?/^[A-Za-z_$]$/.test(char):/^[A-Za-z0-9_$]$/.test(char);identifier+=valid?char:"_"}return identifier===""?"_":identifier}var IDENTIFIER=/^[A-Za-z_$][A-Za-z0-9_$]*$/,INDENT=" ",DEFAULT_INPUT_SCHEMA_MAX_CHARS=16e3,MAX_REF_EXPANSIONS=32,TAG_KEYWORDS=["minimum","exclusiveMinimum","maximum","exclusiveMaximum","multipleOf","minLength","maxLength","pattern","format","minItems","maxItems"],LOWER_BOUNDS=new Set(["minimum","exclusiveMinimum","minLength","minItems"]),UPPER_BOUNDS=new Set(["maximum","exclusiveMaximum","maxLength","maxItems"]),MAX_TAG_CHARS=80,LINE_TERMINATORS=/[\r\n\u2028\u2029]/g;function renderToolSignature(tool,options={}){let input=tool.inputSchema===void 0?"unknown":schemaToType(tool.inputSchema,{maxChars:options.inputMaxChars??DEFAULT_INPUT_SCHEMA_MAX_CHARS});return`${toCodemodeIdentifier(tool.name)}(args: ${input}): Promise<${renderToolOutputType(tool.outputSchema)}>;`}function renderToolSample(tool,options={}){let declaration=`declare const tools: { ${renderToolSignature(tool,options)} };`;return`${tool.description?.trim()??""}
48
49
 
49
50
  codemode tool declaration:
50
51
  \`\`\`ts
@@ -76,13 +77,16 @@ d fields ${SUPPORTED_FIELDS_TEXT}: ${error instanceof Error?error.message:String
76
77
  if(max_output_tokens!==void 0){if(!isSafeInteger(max_output_tokens))throw new CodemodeSourceError("@options field `max_output_tokens` must be a non-negative safe integer");options.maxOutputTokens=max_output_tokens}if(timeout_ms!==void 0){if(!isSafeInteger(timeout_ms)||timeout_ms===0||timeout_ms>2147483647)throw new CodemodeSourceError("@options field `timeout_ms` must be a positive integer up to 2147483647");options.timeoutMs=timeout_ms}return options}function parseCodemodeSource(input){if(input.
77
78
  trim()==="")throw new CodemodeSourceError('Expected JavaScript source text (non-empty). Provide JS only, optionally with a first line `// @options: {"max_output_tokens": 1000}`.');let lines=input.split(`
78
79
  `),misplaced=lines.findIndex((line,index)=>index>0&&line.trimStart().startsWith(CODEMODE_OPTIONS_PREFIX));if(misplaced!==-1)throw new CodemodeSourceError(`The ${CODEMODE_OPTIONS_PREFIX} line must be the first line of the input; found one on line ${misplaced+1}`);let newline=input.indexOf(`
79
- `),trimmed=lines[0].replace(/\r$/,"").trimStart();if(!trimmed.startsWith(CODEMODE_OPTIONS_PREFIX))return{code:input,options:{}};let code=newline===-1?"":input.slice(newline);if(code.trim()==="")throw new CodemodeSourceError("The @options line must be followed by JavaScript source on subsequent lines");return{code,options:parseOptions(trimmed.slice(CODEMODE_OPTIONS_PREFIX.length).trim())}}var TOOL_SEARCH_TOOL_NAME="tool_search",DEFAULT_TOOL_SEARCH_LIMIT=8,STOP_WORDS=new Set(["a","an","and","are","as","at","be","by","for","from","in","is","it","of","on","or","that","the","this","to","with"]);function stem(term){return term.length>4&&term.endsWith("ies")?`${term.slice(0,-3)}y`:term.length>4&&/(ches|shes|sses|xes|zes)$/.test(term)?term.slice(0,-2):term.length>3&&term.endsWith("s")&&!term.endsWith("ss")?term.slice(0,-1):term}function tokenize(text){return text.replace(/([a-z0-9])([A-Z])/g,
80
- "$1 $2").replace(/([A-Z]+)([A-Z][a-z])/g,"$1 $2").toLowerCase().split(/[^a-z0-9]+/).filter(term=>term.length>0&&!STOP_WORDS.has(term)).map(stem)}function isObject(value){return typeof value=="object"&&value!==null&&!Array.isArray(value)}function schemaText(schema,parts){if(isObject(schema)){if(typeof schema.description=="string"&&parts.push(schema.description),isObject(schema.properties))for(let[name,property]of Object.entries(schema.properties))parts.push(name),schemaText(property,parts);schemaText(
81
- schema.items,parts);for(let key of["anyOf","oneOf","allOf"]){let variants=schema[key];if(Array.isArray(variants))for(let variant of variants)schemaText(variant,parts)}}}function createToolSearchDocument(tool,namespace){let parts=[tool.name,tool.name.replaceAll("_"," "),tool.description];return schemaText(tool.parameters,parts),namespace&&parts.push(namespace.name,namespace.description??"",namespace.instructions??""),{name:tool.name,text:parts.filter(part=>part.trim()).join(" ")}}var Bm25Ranker=class{k1;b;constructor(options={}){
82
- this.k1=options.k1??1.2,this.b=options.b??.75}rank(query,documents,limit){let queryTerms=[...new Set(tokenize(query))];if(queryTerms.length===0||documents.length===0||limit<=0)return[];let termCounts=documents.map(document=>{let counts=new Map;for(let term of tokenize(document.text))counts.set(term,(counts.get(term)??0)+1);return counts}),lengths=termCounts.map(counts=>[...counts.values()].reduce((sum,count)=>sum+count,0)),averageLength=lengths.reduce((sum,length)=>sum+length,0)/documents.length||
83
- 1,idf=new Map(queryTerms.map(term=>{let frequency=termCounts.filter(counts=>counts.has(term)).length;return[term,Math.log(1+(documents.length-frequency+.5)/(frequency+.5))]})),matches=[];return documents.forEach((document,index)=>{let score=0;for(let term of queryTerms){let count=termCounts[index].get(term);if(!count)continue;let norm=this.k1*(1-this.b+this.b*lengths[index]/averageLength);score+=(idf.get(term)??0)*(count*(this.k1+1)/(count+norm))}score>0&&matches.push({name:document.name,score})}),
84
- matches.sort((a,b)=>b.score-a.score).slice(0,limit)}},toolSearchSchema=typebox_exports.Object({query:typebox_exports.String({description:"Search query for deferred tools."}),limit:typebox_exports.Optional(typebox_exports.Number({description:`Maximum number of tools to return. Defaults to ${DEFAULT_TOOL_SEARCH_LIMIT}.`}))});function isSearchable(exposure){return exposure==="codemode"||exposure==="deferred"}function searchAndLoad(tools,query,limit){let active=tools.getActiveTools(),candidates=tools.
85
- getAllTools().filter(tool=>isSearchable(tool.exposure)&&!active.includes(tool.name)),documents=candidates.map(tool=>createToolSearchDocument(tool,tool.namespace)),matches=new Bm25Ranker().rank(query,documents,limit);return matches.length>0&&tools.setActiveTools([...active,...matches.map(match=>match.name)]),matches.map(match=>({name:match.name,description:candidates.find(tool=>tool.name===match.name)?.description??""}))}var TOOL_SEARCH_DESCRIPTION=`# Tool discovery
80
+ `),trimmed=lines[0].replace(/\r$/,"").trimStart();if(!trimmed.startsWith(CODEMODE_OPTIONS_PREFIX))return{code:input,options:{}};let code=newline===-1?"":input.slice(newline);if(code.trim()==="")throw new CodemodeSourceError("The @options line must be followed by JavaScript source on subsequent lines");return{code,options:parseOptions(trimmed.slice(CODEMODE_OPTIONS_PREFIX.length).trim())}}var TOOL_SEARCH_TOOL_NAME="tool_search",DEFAULT_TOOL_SEARCH_LIMIT=8,wordSegmenter=new Intl.Segmenter(void 0,{granularity:"word"}),STOP_WORDS=new Set(["a","an","and","are","as","at","be","by","for","from","in","is","it","of","on","or","that","the","this","to","with"]);function stem(term){return term.length>4&&term.endsWith("ies")?`${term.slice(0,-3)}y`:term.length>4&&/(ches|shes|sses|xes|zes)$/.test(term)?term.slice(0,-2):term.length>3&&term.endsWith("s")&&!term.endsWith("ss")?term.slice(0,-1):term}
81
+ function tokenize(text){let normalized=text.normalize("NFC").replace(/([a-z0-9])([A-Z])/g,"$1 $2").replace(/([A-Z]+)([A-Z][a-z])/g,"$1 $2").toLowerCase().replace(/[^\p{L}\p{M}\p{N}]+/gu," ");return(/^[a-z0-9 ]*$/.test(normalized)?normalized.split(" "):Array.from(wordSegmenter.segment(normalized),segment=>segment.isWordLike?segment.segment:"")).filter(word=>word.length>0&&!STOP_WORDS.has(word)).map(word=>/^[a-z0-9]+$/.test(word)?stem(word):word)}function isObject(value){return typeof value=="obje\
82
+ ct"&&value!==null&&!Array.isArray(value)}function schemaText(schema,parts){if(isObject(schema)){if(typeof schema.description=="string"&&parts.push(schema.description),isObject(schema.properties))for(let[name,property]of Object.entries(schema.properties))parts.push(name),schemaText(property,parts);schemaText(schema.items,parts);for(let key of["anyOf","oneOf","allOf"]){let variants=schema[key];if(Array.isArray(variants))for(let variant of variants)schemaText(variant,parts)}}}function createToolSearchDocument(tool,namespace){
83
+ let parts=[tool.description];schemaText(tool.parameters,parts);let namespaceText=namespace?[namespace.name,namespace.description??"",namespace.instructions??""].join(" "):"";return{name:tool.name,text:parts.filter(part=>part.trim()).join(" "),namespaceText}}function normalizeName(name){return name.trim().toLowerCase().replace(/[^a-z0-9_$]/g,"_")}function isExactNameQuery(query,name){let normalized=normalizeName(name);return normalized===query||normalized.endsWith(`__${query}`)}function indexDocument(document){
84
+ let textCounts=new Map;for(let term of tokenize(document.text))textCounts.set(term,(textCounts.get(term)??0)+1);let segments=document.name.split("__");return{name:document.name,nameTerms:new Set(tokenize(document.name)),localNameTerms:[...new Set(tokenize(segments[segments.length-1]))],textCounts,textLength:[...textCounts.values()].reduce((sum,count)=>sum+count,0),namespaceTerms:new Set(tokenize(document.namespaceText??""))}}var NAME_WEIGHT=3,NAMESPACE_WEIGHT=.5,Bm25Ranker=class{k1;b;constructor(options={}){
85
+ this.k1=options.k1??1.2,this.b=options.b??.75}rank(query,documents,limit){let queryTerms=new Set(tokenize(query));if(queryTerms.size===0||documents.length===0||limit<=0)return[];let indexed=documents.map(indexDocument),averageLength=indexed.reduce((sum,document)=>sum+document.textLength,0)/indexed.length||1,idf=new Map([...queryTerms].map(term=>{let frequency=indexed.filter(document=>document.nameTerms.has(term)||document.textCounts.has(term)||document.namespaceTerms.has(term)).length;return[term,
86
+ Math.log(1+(indexed.length-frequency+.5)/(frequency+.5))]})),fullNameBonus=[...idf.values()].reduce((sum,value)=>sum+value,0),exactQuery=normalizeName(query),matches=[];for(let document of indexed){let norm=this.k1*(1-this.b+this.b*document.textLength/averageLength),score=0,covered=0;for(let term of queryTerms){let count=document.textCounts.get(term)??0,weight=(document.nameTerms.has(term)?NAME_WEIGHT:0)+(document.namespaceTerms.has(term)?NAMESPACE_WEIGHT:0)+count*(this.k1+1)/(count+norm);weight>
87
+ 0&&covered++,score+=(idf.get(term)??0)*weight}if(score===0)continue;let local=document.localNameTerms;local.length>0&&local.every(term=>queryTerms.has(term))&&(score+=fullNameBonus),matches.push({name:document.name,score,covered,exact:isExactNameQuery(exactQuery,document.name)})}return matches.sort((a,b)=>Number(b.exact)-Number(a.exact)||b.covered-a.covered||b.score-a.score).slice(0,limit).map(({name,score})=>({name,score}))}},toolSearchSchema=typebox_exports.Object({query:typebox_exports.String(
88
+ {description:"Search query for deferred tools."}),limit:typebox_exports.Optional(typebox_exports.Number({description:`Maximum number of tools to return. Defaults to ${DEFAULT_TOOL_SEARCH_LIMIT}.`}))});function isSearchable(exposure){return exposure==="codemode"||exposure==="deferred"}function searchAndLoad(tools,query,limit){let active=tools.getActiveTools(),candidates=tools.getAllTools().filter(tool=>isSearchable(tool.exposure)&&!active.includes(tool.name)),documents=candidates.map(tool=>createToolSearchDocument(
89
+ tool,tool.namespace)),matches=new Bm25Ranker().rank(query,documents,limit);return matches.length>0&&tools.setActiveTools([...active,...matches.map(match=>match.name)]),matches.map(match=>({name:match.name,description:candidates.find(tool=>tool.name===match.name)?.description??""}))}var TOOL_SEARCH_DESCRIPTION=`# Tool discovery
86
90
 
87
91
  Searches over deferred tool metadata with BM25 and exposes matching tools for the next model call.
88
92
 
@@ -90,14 +94,15 @@ Some of the tools, such as tools of MCP servers, may not have been provided to y
90
94
  exposure:"model-only",reachesTools:()=>"all",async execute(_toolCallId,{query,limit}){if(query.trim()==="")throw new Error("query must not be empty");let max=limit??DEFAULT_TOOL_SEARCH_LIMIT;if(!Number.isInteger(max)||max<=0)throw new Error("limit must be a positive integer");let tools=options.tools?searchAndLoad(options.tools,query,max):[];return{content:[{type:"text",text:tools.length===0?"No matching tools found.":`Loaded ${tools.length} tool${tools.length===1?"":"s"}. They are available from\
91
95
  your next call:
92
96
  ${tools.map(tool=>`- ${tool.name}: ${tool.description.trim().split(/\r?\n/)[0]}`).join(`
93
- `)}`}],details:{loaded:tools.map(tool=>tool.name)}}}}}import{join as join2}from"node:path";var SETTINGS_DEFAULTS={transport:"auto",sessionShareDestination:"auto",steeringMode:"one-at-a-time",followUpMode:"one-at-a-time",compaction:{enabled:!0,reserveTokens:16384,keepRecentTokens:2e4},branchSummary:{reserveTokens:16384,skipPrompt:!1},retry:{enabled:!0,maxRetries:3,baseDelayMs:2e3,maxAgentDelayMs:DEFAULT_MAX_AGENT_RETRY_DELAY_MS,provider:{maxRetryDelayMs:6e4}},hideThinkingBlock:!1,showCacheMissNotices:!1,quietStartup:!1,defaultProjectTrust:"ask",collapseChangelog:!1,enableInstallTelemetry:!0,
94
- enableAnalytics:!1,enableSkillCommands:!0,terminal:{showImages:!0,imageWidthCells:60,clearOnShrink:!1,showTerminalProgress:!1},images:{autoResize:!0,blockImages:!1},doubleEscapeAction:"tree",treeFilterMode:"default",editorPaddingX:0,outputPad:1,autocompleteMaxVisible:5,markdown:{codeBlockIndent:" ",mermaid:"streaming"},warnings:{anthropicExtraUsage:!0},codemode:{mode:"on",inlineBudget:3e3,flowImplementer:"only"},cacheWarming:"streaming",tuiMode:"fullscreen",fullscreenExitOutput:"transcript",fullscreenScrollbar:"\
95
- auto",fullscreenCopyOnSelect:!0,fullscreenWheelScrollLines:"auto"};function wrapToolDefinition(definition,ctxFactory){return{name:definition.name,label:definition.label,description:definition.description,parameters:definition.parameters,outputSchema:definition.outputSchema,constrainedSampling:definition.constrainedSampling,prepareArguments:definition.prepareArguments,executionMode:definition.executionMode,execute:(toolCallId,params,signal,onUpdate,ctx)=>definition.execute(toolCallId,params,signal,onUpdate,ctx??ctxFactory?.(toolCallId,signal))}}function createToolDefinitionFromAgentTool(tool){return{name:tool.name,label:tool.label,description:tool.description,parameters:tool.parameters,outputSchema:tool.outputSchema,constrainedSampling:tool.constrainedSampling,prepareArguments:tool.prepareArguments,executionMode:tool.executionMode,execute:async(toolCallId,params,signal,onUpdate)=>tool.execute(toolCallId,params,signal,onUpdate)}}var loadCodemodeExecutor=()=>import("./execute-2JXEKQ2X.js");var CODE_PREVIEW_LINES=10,CALL_PREVIEW_COUNT=8,OUTPUT_PREVIEW_LINES=5,COLLAPSED_ARGS_CHARS2=80,SCRIPT_HEADER=/^Script (completed|failed)\nWall time [\d.]+ seconds\nOutput:\n$/;function expandHint(theme,hidden,noun){return`${theme.fg("muted",`... (${hidden} more ${noun},`)} ${keyHint("app.tools.expand","to expand")}${theme.fg("muted",")")}`}function formatDuration(ms){return ms===void 0?"":ms<1e3?`${Math.round(ms)}ms`:`${(ms/1e3).toFixed(1)}s`}function formatCost(cost){return`$${cost>=.01?cost.toFixed(
96
- 2):cost.toPrecision(2)}`}function statusIcon(call,theme){switch(call.status){case"running":return theme.fg("warning","\u2026");case"ok":return theme.fg("success","\u2713");case"error":return theme.fg("error","\u2717");case"cancelled":return theme.fg("muted","\u2298")}}function formatCall(call,theme,expanded){let args=!expanded&&call.args.length>COLLAPSED_ARGS_CHARS2?`${call.args.slice(0,COLLAPSED_ARGS_CHARS2-3)}...`:call.args,duration=formatDuration(call.durationMs),line=`${statusIcon(call,theme)}\
97
- ${theme.fg("toolTitle",call.name)}`;return args&&(line+=` ${theme.fg("muted",args)}`),duration&&(line+=` ${theme.fg("dim",duration)}`),call.cost&&(line+=` ${theme.fg("dim",formatCost(call.cost))}`),expanded&&call.error&&(line+=`
98
- ${theme.fg("error",call.error.split(`
97
+ `)}`}],details:{loaded:tools.map(tool=>tool.name)}}}}}import{join as join2}from"node:path";var SETTINGS_DEFAULTS={transport:"auto",noProgressTimeoutMs:12e4,sessionShareDestination:"auto",steeringMode:"one-at-a-time",followUpMode:"one-at-a-time",compaction:{enabled:!0,reserveTokens:16384,keepRecentTokens:2e4,thresholdPercent:90},branchSummary:{reserveTokens:16384,skipPrompt:!1},retry:{enabled:!0,maxRetries:3,baseDelayMs:2e3,maxAgentDelayMs:DEFAULT_MAX_AGENT_RETRY_DELAY_MS,provider:{maxRetryDelayMs:6e4}},hideThinkingBlock:!1,showCacheMissNotices:!1,quietStartup:!1,defaultProjectTrust:"a\
98
+ sk",collapseChangelog:!1,enableInstallTelemetry:!0,enableAnalytics:!1,enableSkillCommands:!0,terminal:{showImages:!0,imageWidthCells:60,clearOnShrink:!1,showTerminalProgress:!1},images:{autoResize:!0,blockImages:!1},doubleEscapeAction:"tree",treeFilterMode:"default",editorPaddingX:0,outputPad:1,autocompleteMaxVisible:5,markdown:{codeBlockIndent:" ",mermaid:"streaming"},warnings:{anthropicExtraUsage:!0},codemode:{mode:"on",inlineBudget:3e3,flowImplementer:"only"},cacheWarming:"streaming",tuiMode:"\
99
+ fullscreen",fullscreenExitOutput:"transcript",fullscreenScrollbar:"auto",fullscreenCopyOnSelect:!0,fullscreenWheelScrollLines:"auto"};function wrapToolDefinition(definition,ctxFactory){return{name:definition.name,label:definition.label,description:definition.description,parameters:definition.parameters,outputSchema:definition.outputSchema,constrainedSampling:definition.constrainedSampling,prepareArguments:definition.prepareArguments,executionMode:definition.executionMode,execute:(toolCallId,params,signal,onUpdate,ctx)=>definition.execute(toolCallId,params,signal,onUpdate,ctx??ctxFactory?.(toolCallId,signal))}}function createToolDefinitionFromAgentTool(tool){return{name:tool.name,label:tool.label,description:tool.description,parameters:tool.parameters,outputSchema:tool.outputSchema,constrainedSampling:tool.constrainedSampling,prepareArguments:tool.prepareArguments,executionMode:tool.executionMode,execute:async(toolCallId,params,signal,onUpdate)=>tool.execute(toolCallId,params,signal,onUpdate)}}var loadCodemodeExecutor=()=>import("./execute-PIUR5MUV.js");var CODE_PREVIEW_LINES=10,CALL_PREVIEW_COUNT=8,OUTPUT_PREVIEW_LINES=5,COLLAPSED_ARGS_CHARS2=80,SCRIPT_HEADER=/^Script (completed|failed)\nWall time [\d.]+ seconds\nOutput:\n$/;function expandHint(theme,hidden,noun){return`${theme.fg("muted",`... (${hidden} more ${noun},`)} ${keyHint("app.tools.expand","to expand")}${theme.fg("muted",")")}`}function formatDuration(ms){return ms===void 0?"":ms<1e3?`${Math.round(ms)}ms`:`${(ms/1e3).toFixed(1)}s`}function formatCost(cost){return`$${cost>=.01?cost.toFixed(
100
+ 2):cost.toPrecision(2)}`}function statusIcon(call,theme){switch(call.status){case"running":return theme.fg("warning","\u2026");case"ok":return theme.fg("success","\u2713");case"error":return theme.fg("error","\u2717");case"cancelled":return theme.fg("muted","\u2298")}}function formatCall(call,theme,expanded){let callArgs=sanitizeTerminalText(call.args),args=!expanded&&callArgs.length>COLLAPSED_ARGS_CHARS2?`${callArgs.slice(0,COLLAPSED_ARGS_CHARS2-3)}...`:callArgs,duration=formatDuration(call.durationMs),
101
+ line=`${statusIcon(call,theme)} ${theme.fg("toolTitle",sanitizeTerminalText(call.name))}`;return args&&(line+=` ${theme.fg("muted",args)}`),duration&&(line+=` ${theme.fg("dim",duration)}`),call.cost&&(line+=` ${theme.fg("dim",formatCost(call.cost))}`),expanded&&call.error&&(line+=`
102
+ ${theme.fg("error",sanitizeTerminalText(call.error).split(`
99
103
  `).join(`
100
- `))}`),line}var codemodeRenderers={renderCall(args,theme,context){startToolTimer(context);let code=str(args?.code),title=theme.fg("toolTitle",theme.bold("codemode")),component=context.lastComponent??new Container;if(component.clear(),code===null)return component.addChild(new Text(`${title} ${theme.fg("error","[invalid arg]")}`,0,0)),component;if(component.addChild(new Text(title,0,0)),code){let highlighted=highlightCode(replaceTabs(code.replace(/\r/g,"").trimEnd()),"javascript").join(`
104
+ `))}`),line}var codemodeRenderers={renderCall(args,theme,context){startToolTimer(context);let code=str(args?.code),title=theme.fg("toolTitle",theme.bold("codemode")),component=context.lastComponent??new Container;if(component.clear(),code===null)return component.addChild(new Text(`${title} ${theme.fg("error","[invalid arg]")}`,0,0)),component;if(component.addChild(new Text(title,0,0)),code){let state=context.state;state.scriptHighlighter??=new CodeHighlighter;let highlighted=state.scriptHighlighter.
105
+ highlight(replaceTabs(code.replace(/\r/g,"").trimEnd()),"javascript").join(`
101
106
  `);component.addChild(context.expanded?new Text(highlighted,0,0):new VisualLinePreview({text:highlighted,maxVisualLines:CODE_PREVIEW_LINES,keep:"start",formatHint:hidden=>expandHint(theme,hidden,"lines")}))}return component},renderResult(result,options,theme,context){let timerText=toolTimerText(context,options.isPartial),component=context.lastComponent??new Container;component.clear();let calls=result.details?.calls??[];if(calls.length>0){let shown=options.expanded?calls:calls.slice(-CALL_PREVIEW_COUNT),
102
107
  lines=shown.map(call=>formatCall(call,theme,options.expanded));shown.length<calls.length&&lines.unshift(`${theme.fg("muted",`... (${calls.length-shown.length} earlier calls,`)} ${keyHint("app.tools.expand","to expand")}${theme.fg("muted",")")}`);let priced=calls.filter(call=>call.cost);if(priced.length>1){let total=priced.reduce((sum,call)=>sum+(call.cost??0),0);lines.push(theme.fg("muted",`Model calls: ${formatCost(total)}`))}component.addChild(new Spacer(1)),component.addChild(new Text(lines.join(
103
108
  `
@@ -121,12 +126,13 @@ ${description}`:""}`)}for(let entry of visible)toolSections.push(entry.section)}
121
126
 
122
127
  `)),sections.join(`
123
128
 
124
- `)}function describeFields(schema,depth){if(typeof schema!="object"||schema===null)return;let{type,properties,required}=schema;if(type!=="object"||typeof properties!="object"||properties===null)return;let requiredNames=new Set(Array.isArray(required)?required:[]);return`{ ${Object.entries(properties).map(([name,field])=>{let nested=depth>0?describeFields(field,depth-1):void 0;return`${name}${requiredNames.has(name)?"":"?"}${nested?`: ${nested}`:""}`}).join(", ")} }`}function describeOutput(schema){
125
- let type=renderToolOutputType(schema);return type==="string"?"a string":`\`${describeFields(schema,1)??type.replace(/\s+/g," ")}\``}function describeScriptCall(tool){return`${tool.description.trim()}
129
+ `)}function describeFields(schema,depth){if(typeof schema!="object"||schema===null)return;let{type,properties,required}=schema;if(type!=="object"||typeof properties!="object"||properties===null)return;let requiredNames=new Set(Array.isArray(required)?required:[]);return`{ ${Object.entries(properties).map(([name,field])=>{let constValue=field?.const,nested=constValue!==void 0?JSON.stringify(constValue):depth>0?describeFields(field,depth-1):void 0;return`${name}${requiredNames.has(name)?"":"?"}${nested?
130
+ `: ${nested}`:""}`}).join(", ")} }`}function describeOutput(name,schema){let type=renderToolOutputType(schema);if(type==="string")return"a string";let fields=describeFields(schema,1)??describeUnionFields(schema);return fields?`\`${fields}\``:type.includes(`
131
+ `)?`a value; \`await describeTool(${JSON.stringify(name)})\` shows its type`:`\`${type}\``}function describeUnionFields(schema){if(typeof schema!="object"||schema===null)return;let{anyOf,oneOf}=schema,variants=anyOf??oneOf;if(!Array.isArray(variants)||variants.length===0)return;let described=variants.map(variant=>describeFields(variant,0));return described.every(fields=>fields!==void 0)?described.join(" | "):void 0}function describeScriptCall(tool){return`${tool.description.trim()}
126
132
 
127
- Codemode: \`tools.${toCodemodeIdentifier(tool.name)}(args)\` resolves to ${describeOutput(toCodemodeDeclaration(tool).outputSchema)}.`}function prepareCodemodeLoadout(loadout,options){let mode=options.getMode?.()??SETTINGS_DEFAULTS.codemode.mode,isDirect=tool=>loadout.getExposure(tool.name)==="direct",callable=getCodemodeCallableTools(loadout.callable),callableNames=new Set(callable.map(tool=>tool.name)),descriptions={};if(mode==="on")for(let tool of loadout.declared)callableNames.has(tool.name)&&
128
- (descriptions[tool.name]=describeScriptCall(tool));let listed=mode==="only"?callable:callable.filter(tool=>!isDirect(tool)),namespaces=new Map(listed.flatMap(tool=>{let namespace=loadout.getNamespace(tool.name);return namespace?[[tool.name,namespace]]:[]})),guidelines=new Map(listed.map(tool=>[tool.name,loadout.getPromptGuidelines(tool.name)]));descriptions[CODEMODE_TOOL_NAME]=createCodemodeDescription(listed,{models:options.models===!0,namespaces,guidelines,deferred:new Set(listed.filter(tool=>loadout.
129
- getExposure(tool.name)==="deferred").map(tool=>tool.name)),inlineBudget:options.getInlineBudget?.()??DEFAULT_CODEMODE_INLINE_BUDGET});let declaredNames=new Set(loadout.declared.map(tool=>tool.name));return{descriptions,hiddenDeclarations:mode==="only"?callable.filter(tool=>isDirect(tool)&&declaredNames.has(tool.name)).map(tool=>tool.name):[]}}var DISCOVERY_GLOBALS=/\b(searchTools|describeNamespace|describeTool|ALL_TOOLS)\b/;function getScriptReach(code){return typeof code!="string"?[]:DISCOVERY_GLOBALS.
130
- test(code)?"all":code.match(/\w+/g)??[]}function createCodemodeToolDefinition(options={}){return{name:CODEMODE_TOOL_NAME,label:CODEMODE_TOOL_NAME,description:createCodemodeDescription([],{models:options.models===!0}),promptSnippet:codemodeToolSystemPromptContribution.snippet,promptGuidelines:[...codemodeToolSystemPromptContribution.guidelines],parameters:codemodeSchema,exposure:"model-only",prepareLoadout:loadout=>prepareCodemodeLoadout(loadout,options),reachesTools:input=>getScriptReach(input.code),
131
- constrainedSampling:{type:"grammar",variants:{openai_lark:CODEMODE_SOURCE_GRAMMAR}},execute:async(toolCallId,params,signal,onUpdate,ctx)=>(await loadCodemodeExecutor()).executeCodemode(toolCallId,params,signal,onUpdate,ctx,options),...codemodeRenderers}}export{SETTINGS_DEFAULTS,splitIncompleteAnsiSuffix,stripAnsi,writeOutputFile,createOutputFileStream,DEFAULT_MAX_LINES,DEFAULT_MAX_BYTES,formatSize,truncateHead,truncateTail,truncateLine,truncateMiddle,createUsageTotals,addUsageToTotals,combineUsage,getSummaryUsage,getSessionUsage,getUsageCostBreakdown,wrapToolDefinition,createToolDefinitionFromAgentTool,truncateToVisualLines,VisualLinePreview,shortenPath,str,formatReadLineRange,replaceTabs,normalizeDisplayText,getTextOutput,formatToolCallWithArgs,
133
+ Codemode: \`tools.${toCodemodeIdentifier(tool.name)}(args)\` resolves to ${describeOutput(tool.name,toCodemodeDeclaration(tool).outputSchema)}.`}function prepareCodemodeLoadout(loadout,options){let mode=options.getMode?.()??SETTINGS_DEFAULTS.codemode.mode,isDirect=tool=>loadout.getExposure(tool.name)==="direct",callable=getCodemodeCallableTools(loadout.callable),callableNames=new Set(callable.map(tool=>tool.name)),descriptions={};if(mode==="on")for(let tool of loadout.declared)callableNames.has(
134
+ tool.name)&&(descriptions[tool.name]=describeScriptCall(tool));let listed=mode==="only"?callable:callable.filter(tool=>!isDirect(tool)),namespaces=new Map(listed.flatMap(tool=>{let namespace=loadout.getNamespace(tool.name);return namespace?[[tool.name,namespace]]:[]})),guidelines=new Map(listed.map(tool=>[tool.name,loadout.getPromptGuidelines(tool.name)]));descriptions[CODEMODE_TOOL_NAME]=createCodemodeDescription(listed,{models:options.models===!0,namespaces,guidelines,deferred:new Set(listed.filter(
135
+ tool=>loadout.getExposure(tool.name)==="deferred").map(tool=>tool.name)),inlineBudget:options.getInlineBudget?.()??DEFAULT_CODEMODE_INLINE_BUDGET});let declaredNames=new Set(loadout.declared.map(tool=>tool.name));return{descriptions,hiddenDeclarations:mode==="only"?callable.filter(tool=>isDirect(tool)&&declaredNames.has(tool.name)).map(tool=>tool.name):[]}}var DISCOVERY_GLOBALS=/\b(searchTools|describeNamespace|describeTool|ALL_TOOLS)\b/;function getScriptReach(code){return typeof code!="string"?
136
+ []:DISCOVERY_GLOBALS.test(code)?"all":code.match(/\w+/g)??[]}function createCodemodeToolDefinition(options={}){return{name:CODEMODE_TOOL_NAME,label:CODEMODE_TOOL_NAME,description:createCodemodeDescription([],{models:options.models===!0}),promptSnippet:codemodeToolSystemPromptContribution.snippet,promptGuidelines:[...codemodeToolSystemPromptContribution.guidelines],parameters:codemodeSchema,exposure:"model-only",prepareLoadout:loadout=>prepareCodemodeLoadout(loadout,options),reachesTools:input=>getScriptReach(
137
+ input.code),constrainedSampling:{type:"grammar",variants:{openai_lark:CODEMODE_SOURCE_GRAMMAR}},execute:async(toolCallId,params,signal,onUpdate,ctx)=>(await loadCodemodeExecutor()).executeCodemode(toolCallId,params,signal,onUpdate,ctx,options),...codemodeRenderers}}export{SETTINGS_DEFAULTS,splitIncompleteAnsiSuffix,stripAnsi,writeOutputFile,createOutputFileStream,DEFAULT_MAX_LINES,DEFAULT_MAX_BYTES,formatSize,truncateHead,truncateTail,truncateLine,truncateMiddle,createUsageTotals,addUsageToTotals,combineUsage,getSummaryUsage,getSessionUsage,getUsageCostBreakdown,wrapToolDefinition,createToolDefinitionFromAgentTool,truncateToVisualLines,VisualLinePreview,shortenPath,str,formatReadLineRange,replaceTabs,normalizeDisplayText,getTextOutput,formatToolCallWithArgs,
132
138
  startToolTimer,toolTimerText,invalidArgText,renderToolPath,toCodemodeIdentifier,renderToolSample,parseCodemodeSource,TOOL_SEARCH_TOOL_NAME,DEFAULT_TOOL_SEARCH_LIMIT,createToolSearchDocument,Bm25Ranker,createToolSearchToolDefinition,CODEMODE_TOOL_NAME,CODEMODE_STORE_ENTRY_TYPE,CODEMODE_DOCS_PATH,toCodemodeDeclaration,getCodemodeCallableTools,createCodemodeToolDefinition};
@@ -1,12 +1,12 @@
1
1
  import { createRequire as __piCreateRequire } from "node:module"; const require = __piCreateRequire(import.meta.url);
2
- import{McpOAuthCredentialStore,McpServerConnection,McpServerLog,McpSignInCancelledError,createDefaultTransport,signInMcpServer}from"./chunk-Y3OPKKDR.js";import{ProjectTrustStore,addMcpServerConfig,loadMcpConfig,openBrowser,removeMcpServerConfig}from"./chunk-AO6FF5JL.js";import{source_default}from"./chunk-XQRYOCHA.js";import{getMcpToolExposure,validateMcpServerConfig}from"./chunk-L2VKM23Q.js";import"./chunk-YFOLLX5D.js";import{APP_COMMAND,CONFIG_DIR_NAME}from"./chunk-ZI7TK7HM.js";
2
+ import{McpOAuthCredentialStore,McpServerConnection,McpServerLog,McpSignInCancelledError,createDefaultTransport,signInMcpServer}from"./chunk-P4P7OZ7R.js";import{ProjectTrustStore,addMcpServerConfig,loadMcpConfig,openBrowser,removeMcpServerConfig}from"./chunk-AHSNQWZU.js";import{source_default}from"./chunk-XQRYOCHA.js";import{getMcpToolExposure,validateMcpServerConfig}from"./chunk-6DE7LJKV.js";import"./chunk-RO5YPAJH.js";import{APP_COMMAND,CONFIG_DIR_NAME}from"./chunk-IADQJFNH.js";
3
3
  import"./chunk-JXWJOIH4.js";import{existsSync}from"node:fs";import{join}from"node:path";import{createInterface}from"node:readline/promises";var HELP=`${source_default.bold("Usage:")}
4
4
  ${APP_COMMAND} mcp add <server> [options] -- <command> [args...]
5
5
  ${APP_COMMAND} mcp add <server> [options] --url <url>
6
6
  ${APP_COMMAND} mcp remove <server> [-l]
7
7
  ${APP_COMMAND} mcp list [--json]
8
- ${APP_COMMAND} mcp login <server> [--timeout <seconds>]
9
- ${APP_COMMAND} mcp logout <server>
8
+ ${APP_COMMAND} mcp login <server> [-l] [--timeout <seconds>]
9
+ ${APP_COMMAND} mcp logout <server> [-l]
10
10
 
11
11
  Configure and check MCP servers and sign in to OAuth servers without starting a session.
12
12
  Reads ~/${CONFIG_DIR_NAME}/agent/mcp.json and, in trusted projects, ${CONFIG_DIR_NAME}/mcp.json.
@@ -18,7 +18,7 @@ Commands:
18
18
  login <server> Sign in through the browser
19
19
  logout <server> Delete the stored OAuth credentials
20
20
 
21
- Options for add and remove:
21
+ Options for add, remove, login, and logout:
22
22
  -l, --local Use ${CONFIG_DIR_NAME}/mcp.json in the current project instead of the global file
23
23
 
24
24
  Options for add:
@@ -35,28 +35,32 @@ Options for add:
35
35
  Fixed OAuth callback port
36
36
  --oauth-client-name <name>
37
37
  Client name sent when registering with the OAuth server
38
+ --oauth-client-registration <mode>
39
+ auto (default), cimd, or dcr
38
40
  --exposure <mode> codemode (default), deferred, direct, or hidden
39
41
  --description <text> What the server offers, shown in the system prompt
40
42
 
41
43
  Other options:
42
44
  --json Print the list as JSON
43
45
  --timeout <seconds> Time limit for the whole sign-in (default: 300)`,HELP_HINT=source_default.dim(`Use "${APP_COMMAND} mcp --help" for usage.`),DEFAULT_LOGIN_TIMEOUT_SECONDS=300;function errorMessage(error){return error instanceof Error?error.message:String(error)}function describeTransport(entry){let{config}=entry;return"url"in config?config.url:[config.command,...config.args??[]].join(" ")}function createConnection(entry,options,credentials){return new McpServerConnection({entry,cwd:options.
44
- cwd,createTransport:createDefaultTransport,credentials,log:new McpServerLog(join(options.agentDir,"mcp.log")),onTools:()=>{}})}var OPTION_ALIASES=new Map([["-l","--local"]]);function parseOptions(args,known,error,maxPositionals=Number.POSITIVE_INFINITY){let positional=[],values=new Map,lists=new Map;for(let index=0;index<args.length;index++){let arg=OPTION_ALIASES.get(args[index])??args[index];if(arg==="--"||positional.length>=maxPositionals){positional.push(...args.slice(arg==="--"?index+1:index));
45
- break}if(!arg.startsWith("--")){positional.push(arg);continue}let name=arg.slice(2),kind=known[name];if(!kind){error(`Unknown option ${arg}.
46
+ cwd,createTransport:createDefaultTransport,credentials,log:new McpServerLog(join(options.agentDir,"mcp.log")),onTools:()=>{}})}var OPTION_ALIASES=new Map([["-l","--local"]]);function parseOptions(args,known,error,maxPositionals=Number.POSITIVE_INFINITY){let positional=[],values=new Map,lists=new Map;for(let index=0;index<args.length;index++){let typed=args[index],arg=OPTION_ALIASES.get(typed)??typed;if(arg==="--"||positional.length>=maxPositionals){positional.push(...args.slice(arg==="--"?index+
47
+ 1:index));break}if(!arg.startsWith("--")){positional.push(arg);continue}let name=arg.slice(2),kind=known[name];if(!kind){error(`Unknown option ${typed}.
46
48
  ${HELP_HINT}`);return}if(kind==="flag"){values.set(name,!0);continue}let value=args[++index];if(value===void 0){error(`${arg} needs a value.`);return}kind==="list"?lists.set(name,[...lists.get(name)??[],value]):values.set(name,value)}return{positional,values,lists}}async function runMcpCommand(args,options){let log=options.log??(line=>console.log(line)),error=options.error??(line=>console.error(line)),[command,...rest]=args;if(command===void 0||command==="help"||args.includes("--help")||args.includes(
47
49
  "-h"))return log(HELP),0;let projectConfig=join(options.cwd,CONFIG_DIR_NAME,"mcp.json");if(command==="add"||command==="remove")return command==="add"?add(rest,projectConfig,options,log,error):remove(rest,projectConfig,options,log,error);let projectTrusted=new ProjectTrustStore(options.agentDir).get(options.cwd)===!0,loaded=loadMcpConfig({agentDir:options.agentDir,cwd:options.cwd,projectTrusted}),untrustedNote=!projectTrusted&&existsSync(projectConfig)?`${projectConfig} is ignored because the pro\
48
50
  ject is not trusted. Start ${APP_COMMAND} in the project to trust it.`:void 0,credentials=options.credentials??new McpOAuthCredentialStore;switch(command){case"list":{let parsed=parseOptions(rest,{json:"flag"},error);return parsed?parsed.positional.length>0?(error(`Usage: ${APP_COMMAND} mcp list [--json]
49
- ${HELP_HINT}`),1):list(loaded,parsed.values.has("json"),untrustedNote,options,credentials,log):1}case"login":case"logout":{let parsed=parseOptions(rest,command==="login"?{timeout:"value"}:{},error);if(!parsed)return 1;let[name,...extra]=parsed.positional;if(!name||extra.length>0)return error(`Usage: ${APP_COMMAND} mcp ${command} <server>
50
- ${HELP_HINT}`),1;let entry=loaded.servers.find(server=>server.name===name);if(!entry)return error(`No MCP server named "${name}".${untrustedNote?` ${untrustedNote}`:""} Configured: ${loaded.servers.map(server=>server.name).join(", ")||"none"}.`),1;let connection=createConnection(entry,options,credentials),url=connection.oauthUrl;if(!url)return error(`MCP server "${name}" does not use OAuth. Only HTTP servers without an Authorization header do.`),1;if(command==="logout"){let removed=credentials.remove(
51
- name,url);return log(removed?`Signed out of MCP server "${name}".`:`No stored credentials for MCP server "${name}".`),0}let timeout=Number(parsed.values.get("timeout")??DEFAULT_LOGIN_TIMEOUT_SECONDS);if(!Number.isFinite(timeout)||timeout<=0)return error("--timeout must be a positive number of seconds."),1;try{return await login(entry,connection,url,timeout*1e3,options,credentials,log,error)}finally{await connection.close()}}default:return error(`Unknown mcp command "${command}".
52
- ${HELP_HINT}`),1}}function parsePairs(option,pairs,error){if(!pairs)return{};let record={};for(let pair of pairs){let separator=pair.indexOf("=");if(separator<=0){error(`--${option} expects KEY=VALUE, got "${pair}".`);return}record[pair.slice(0,separator)]=pair.slice(separator+1)}return record}function add(args,projectConfig,options,log,error){let usage=`Usage: ${APP_COMMAND} mcp add <server> [options] (--url <url> | -- <command> [args...])
53
- ${HELP_HINT}`,parsed=parseOptions(args,{local:"flag",url:"value",env:"list",cwd:"value",header:"list","bearer-token-env-var":"value","oauth-client-id":"value","oauth-client-secret":"value","oauth-callback-port":"value","oauth-client-name":"value",exposure:"value",description:"value"},error,2);if(!parsed)return 1;let{positional,values,lists}=parsed,[name,...command]=positional,url=values.get("url");if(!name||url===void 0==(command.length===0))return error(usage),1;let value=option=>{let found=values.
54
- get(option);return typeof found=="string"?found:void 0},exposure=value("exposure"),misplaced=(url===void 0?["header","bearer-token-env-var","oauth-client-id","oauth-client-secret","oauth-callback-port","oauth-client-name"]:["env","cwd"]).find(option=>values.has(option)||lists.has(option));if(misplaced)return error(`--${misplaced} only applies to ${url===void 0?"HTTP servers (--url)":"stdio servers"}.`),1;let config;if(typeof url=="string"){let headers=parsePairs("header",lists.get("header"),error);
55
- if(!headers)return 1;let bearer=value("bearer-token-env-var");bearer!==void 0&&(headers.Authorization=`Bearer \${${bearer}}`);let port=value("oauth-callback-port"),oauth={...value("oauth-client-id")===void 0?{}:{clientId:value("oauth-client-id")},...value("oauth-client-secret")===void 0?{}:{clientSecret:value("oauth-client-secret")},...port===void 0?{}:{callbackPort:Number(port)},...value("oauth-client-name")===void 0?{}:{clientName:value("oauth-client-name")}};config={url,...Object.keys(headers).
56
- length>0?{headers}:{},...Object.keys(oauth).length>0?{oauth}:{}}}else{let env=parsePairs("env",lists.get("env"),error);if(!env)return 1;let[executable,...commandArgs]=command;config={command:executable,...commandArgs.length>0?{args:commandArgs}:{},...Object.keys(env).length>0?{env}:{},...value("cwd")===void 0?{}:{cwd:value("cwd")}}}exposure!==void 0&&(config.exposure=exposure);let description=value("description");description!==void 0&&(config.description=description);let validated=validateMcpServerConfig(
57
- name,config);if(typeof validated=="string")return error(validated),1;let project=values.has("local"),path=project?projectConfig:join(options.agentDir,"mcp.json"),scope=project?"project":"global",replaced;try{replaced=addMcpServerConfig(path,name,validated)}catch(addError){return error(`Could not update ${path}: ${errorMessage(addError)}`),1}log(`${replaced?"Replaced":"Added"} ${scope} MCP server "${name}" in ${path}.`),project&&new ProjectTrustStore(options.agentDir).get(options.cwd)!==!0&&log(`\
58
- The project is not trusted, so ${path} is ignored until you start ${APP_COMMAND} in the project and trust it.`);let mayNeedSignIn="url"in validated&&!Object.keys(validated.headers??{}).some(header=>header.toLowerCase()==="authorization");return log(`Check it with: ${APP_COMMAND} mcp list${mayNeedSignIn?`. If it requires sign-in: ${APP_COMMAND} mcp login ${name}`:""}`),0}function remove(args,projectConfig,options,log,error){let parsed=parseOptions(args,{local:"flag"},error);if(!parsed)return 1;let[
59
- name,...extra]=parsed.positional;if(!name||extra.length>0)return error(`Usage: ${APP_COMMAND} mcp remove <server> [-l]
51
+ ${HELP_HINT}`),1):list(loaded,parsed.values.has("json"),untrustedNote,options,credentials,log):1}case"login":case"logout":{let parsed=parseOptions(rest,command==="login"?{local:"flag",timeout:"value"}:{local:"flag"},error);if(!parsed)return 1;let[name,...extra]=parsed.positional;if(!name||extra.length>0)return error(`Usage: ${APP_COMMAND} mcp ${command} <server> [-l]
52
+ ${HELP_HINT}`),1;let entry=loaded.servers.find(server=>server.name===name);if(!entry){let names=loaded.servers.map(server=>server.name),suggestion=names.find(candidate=>editDistance(candidate,name)<=2);return error(`No MCP server named "${name}".${suggestion?` Did you mean "${suggestion}"?`:""}${untrustedNote?` ${untrustedNote}`:""} Configured: ${names.join(", ")||"none"}.`),1}if(parsed.values.has("local")&&entry.scope!=="project")return error(`MCP server "${name}" is defined in ${entry.source},\
53
+ not in the project; omit --local.`),1;let connection=createConnection(entry,options,credentials),url=connection.oauthUrl;if(!url)return error(`MCP server "${name}" does not use OAuth. Only HTTP servers without an Authorization header do.`),1;if(command==="logout"){let removed=credentials.remove(name,url);return log(removed?`Signed out of MCP server "${name}".`:`No stored credentials for MCP server "${name}".`),0}let timeout=Number(parsed.values.get("timeout")??DEFAULT_LOGIN_TIMEOUT_SECONDS);if(!Number.
54
+ isFinite(timeout)||timeout<=0)return error("--timeout must be a positive number of seconds."),1;try{return await login(entry,connection,url,timeout*1e3,options,credentials,log,error)}finally{await connection.close()}}default:return error(`Unknown mcp command "${command}".
55
+ ${HELP_HINT}`),1}}function editDistance(a,b){let previous=Array.from({length:b.length+1},(_,index)=>index);for(let i=1;i<=a.length;i++){let current=[i];for(let j=1;j<=b.length;j++)current[j]=Math.min(previous[j]+1,current[j-1]+1,previous[j-1]+(a[i-1]===b[j-1]?0:1));previous=current}return previous[b.length]}function parsePairs(option,pairs,error){if(!pairs)return{};let record={};for(let pair of pairs){let separator=pair.indexOf("=");if(separator<=0){error(`--${option} expects KEY=VALUE, got "${pair}\
56
+ ".`);return}record[pair.slice(0,separator)]=pair.slice(separator+1)}return record}function add(args,projectConfig,options,log,error){let usage=`Usage: ${APP_COMMAND} mcp add <server> [options] (--url <url> | -- <command> [args...])
57
+ ${HELP_HINT}`,parsed=parseOptions(args,{local:"flag",url:"value",env:"list",cwd:"value",header:"list","bearer-token-env-var":"value","oauth-client-id":"value","oauth-client-secret":"value","oauth-callback-port":"value","oauth-client-name":"value","oauth-client-registration":"value",exposure:"value",description:"value"},error,2);if(!parsed)return 1;let{positional,values,lists}=parsed,[name,...command]=positional,url=values.get("url");if(!name||url===void 0==(command.length===0))return error(usage),
58
+ 1;let value=option=>{let found=values.get(option);return typeof found=="string"?found:void 0},exposure=value("exposure"),misplaced=(url===void 0?["header","bearer-token-env-var","oauth-client-id","oauth-client-secret","oauth-callback-port","oauth-client-name","oauth-client-registration"]:["env","cwd"]).find(option=>values.has(option)||lists.has(option));if(misplaced)return error(`--${misplaced} only applies to ${url===void 0?"HTTP servers (--url)":"stdio servers"}.`),1;let config;if(typeof url==
59
+ "string"){let headers=parsePairs("header",lists.get("header"),error);if(!headers)return 1;let bearer=value("bearer-token-env-var");bearer!==void 0&&(headers.Authorization=`Bearer \${${bearer}}`);let port=value("oauth-callback-port"),oauth={...value("oauth-client-id")===void 0?{}:{clientId:value("oauth-client-id")},...value("oauth-client-secret")===void 0?{}:{clientSecret:value("oauth-client-secret")},...port===void 0?{}:{callbackPort:Number(port)},...value("oauth-client-name")===void 0?{}:{clientName:value(
60
+ "oauth-client-name")},...value("oauth-client-registration")===void 0?{}:{clientRegistration:value("oauth-client-registration")}};config={url,...Object.keys(headers).length>0?{headers}:{},...Object.keys(oauth).length>0?{oauth}:{}}}else{let env=parsePairs("env",lists.get("env"),error);if(!env)return 1;let[executable,...commandArgs]=command;config={command:executable,...commandArgs.length>0?{args:commandArgs}:{},...Object.keys(env).length>0?{env}:{},...value("cwd")===void 0?{}:{cwd:value("cwd")}}}exposure!==
61
+ void 0&&(config.exposure=exposure);let description=value("description");description!==void 0&&(config.description=description);let validated=validateMcpServerConfig(name,config);if(typeof validated=="string")return error(validated),1;let project=values.has("local"),path=project?projectConfig:join(options.agentDir,"mcp.json"),scope=project?"project":"global",replaced;try{replaced=addMcpServerConfig(path,name,validated)}catch(addError){return error(`Could not update ${path}: ${errorMessage(addError)}`),
62
+ 1}log(`${replaced?"Replaced":"Added"} ${scope} MCP server "${name}" in ${path}.`),project&&new ProjectTrustStore(options.agentDir).get(options.cwd)!==!0&&log(`The project is not trusted, so ${path} is ignored until you start ${APP_COMMAND} in the project and trust it.`);let mayNeedSignIn="url"in validated&&!Object.keys(validated.headers??{}).some(header=>header.toLowerCase()==="authorization");return log(`Check it with: ${APP_COMMAND} mcp list${mayNeedSignIn?`. If it requires sign-in: ${APP_COMMAND}\
63
+ mcp login ${name}`:""}`),0}function remove(args,projectConfig,options,log,error){let parsed=parseOptions(args,{local:"flag"},error);if(!parsed)return 1;let[name,...extra]=parsed.positional;if(!name||extra.length>0)return error(`Usage: ${APP_COMMAND} mcp remove <server> [-l]
60
64
  ${HELP_HINT}`),1;let project=parsed.values.has("local"),globalConfig=join(options.agentDir,"mcp.json"),path=project?projectConfig:globalConfig,scope=project?"project":"global",removed;try{removed=removeMcpServerConfig(path,name)}catch(removeError){return error(`Could not update ${path}: ${errorMessage(removeError)}`),1}if(removed)return log(`Removed ${scope} MCP server "${name}" from ${path}.`),0;let other=loadMcpConfig({agentDir:options.agentDir,cwd:options.cwd,projectTrusted:!0}).servers.find(
61
65
  server=>server.name===name&&server.scope!==scope);return error(`No ${scope} MCP server named "${name}" in ${path}.${other?` It is defined in ${other.source}${other.scope==="project"?"; use --local":"; omit --local"}.`:""}`),1}async function list(loaded,json,untrustedNote,options,credentials,log){let reports=await Promise.all(loaded.servers.map(async entry=>{let report={name:entry.name,scope:entry.scope??"global",source:entry.source,...entry.override?{override:entry.override}:{},enabled:entry.config.
62
66
  enabled!==!1,exposure:entry.config.exposure??"codemode",transport:describeTransport(entry),state:"disabled",tools:[]};if(!report.enabled)return report;let connection=createConnection(entry,options,credentials);try{await connection.getClient()}catch{}report.state=connection.state,report.tools=connection.tools.map(tool=>tool.name);let overrides=connection.tools.flatMap(tool=>{let exposure=getMcpToolExposure(entry.config,tool.name);return exposure===report.exposure?[]:[[tool.name,exposure]]});return overrides.
@@ -1,4 +1,4 @@
1
1
  import { createRequire as __piCreateRequire } from "node:module"; const require = __piCreateRequire(import.meta.url);
2
- import{classifySystemOne}from"./chunk-DU6POZ7E.js";import{isRecord}from"./chunk-XQX7S3GM.js";import"./chunk-PH7UP57J.js";import"./chunk-HT5YN3LX.js";import"./chunk-QWXPGBAG.js";import"./chunk-UTNHGOFS.js";import"./chunk-IJYVMOB4.js";import"./chunk-IDU5BNNI.js";import"./chunk-JXWJOIH4.js";var LABEL="Cloudflare Workers AI";function cloudflareErrorMessage(errors){if(Array.isArray(errors)){let messages=errors.map(error=>isRecord(error)&&typeof error.message=="string"?error.message:void 0).filter(message=>message!==void 0);if(messages.length>0)return`${LABEL} error: ${messages.join("; ")}`}return`${LABEL} request failed`}var transport={api:"cloudflare-workers-ai-system-one",label:LABEL,detectCompat:model=>({imageInput:model.id.startsWith("@cf/cloudflare/clef")?"images":"assets",sendImageOptInHeader:!1}),
2
+ import{classifySystemOne}from"./chunk-DHW3REC5.js";import{isRecord}from"./chunk-GICL5V54.js";import"./chunk-BQ3TMEWD.js";import"./chunk-TEOMXMW6.js";import"./chunk-5JSLXC2A.js";import"./chunk-EDONIPUJ.js";import"./chunk-IJYVMOB4.js";import"./chunk-XMZGB3H4.js";import"./chunk-JXWJOIH4.js";var LABEL="Cloudflare Workers AI";function cloudflareErrorMessage(errors){if(Array.isArray(errors)){let messages=errors.map(error=>isRecord(error)&&typeof error.message=="string"?error.message:void 0).filter(message=>message!==void 0);if(messages.length>0)return`${LABEL} error: ${messages.join("; ")}`}return`${LABEL} request failed`}var transport={api:"cloudflare-workers-ai-system-one",label:LABEL,detectCompat:model=>({imageInput:model.id.startsWith("@cf/cloudflare/clef")?"images":"assets",sendImageOptInHeader:!1}),
3
3
  url:model=>new URL("run",`${model.baseUrl.replace(/\/+$/u,"")}/`),payload:(model,request)=>({model:model.id,input:request}),output:body=>{if(!isRecord(body))throw new Error(`${LABEL} returned an unexpected response`);if(body.success===!1)throw new Error(cloudflareErrorMessage(body.errors));let result=body.result;if(!isRecord(result))throw new Error(`${LABEL} returned an unexpected response`);if("answers"in result)return result;if(result.state!=="Completed")throw new Error(`${LABEL} run did not c\
4
4
  omplete (state: ${String(result.state)})`);if(!isRecord(result.result))throw new Error(`${LABEL} returned an unexpected response`);return result.result}},classify=(model,context,options)=>classifySystemOne(transport,model,context,options);export{classify};