@humain/terminal 0.0.2 → 0.0.3-beta.0

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 (680) hide show
  1. package/CHANGELOG.md +241 -24
  2. package/README.md +143 -119
  3. package/dist/cli/args.d.ts +4 -2
  4. package/dist/cli/args.d.ts.map +1 -1
  5. package/dist/cli/args.js +37 -39
  6. package/dist/cli/args.js.map +1 -1
  7. package/dist/cli/auth-check.d.ts +19 -0
  8. package/dist/cli/auth-check.d.ts.map +1 -0
  9. package/dist/cli/auth-check.js +50 -0
  10. package/dist/cli/auth-check.js.map +1 -0
  11. package/dist/cli/auth-command.d.ts +24 -0
  12. package/dist/cli/auth-command.d.ts.map +1 -0
  13. package/dist/cli/auth-command.js +103 -0
  14. package/dist/cli/auth-command.js.map +1 -0
  15. package/dist/cli/config-selector.d.ts.map +1 -1
  16. package/dist/cli/config-selector.js +2 -2
  17. package/dist/cli/config-selector.js.map +1 -1
  18. package/dist/cli/credential-print.d.ts +5 -15
  19. package/dist/cli/credential-print.d.ts.map +1 -1
  20. package/dist/cli/credential-print.js +42 -83
  21. package/dist/cli/credential-print.js.map +1 -1
  22. package/dist/cli/experimental/auth.d.ts +16 -0
  23. package/dist/cli/experimental/auth.d.ts.map +1 -0
  24. package/dist/cli/experimental/auth.js +13 -0
  25. package/dist/cli/experimental/auth.js.map +1 -0
  26. package/dist/cli/experimental/cli.d.ts +6 -0
  27. package/dist/cli/experimental/cli.d.ts.map +1 -0
  28. package/dist/cli/experimental/cli.js +5 -0
  29. package/dist/cli/experimental/cli.js.map +1 -0
  30. package/dist/cli/experimental/command-options.d.ts +17 -0
  31. package/dist/cli/experimental/command-options.d.ts.map +1 -0
  32. package/dist/cli/experimental/command-options.js +35 -0
  33. package/dist/cli/experimental/command-options.js.map +1 -0
  34. package/dist/cli/experimental/command.d.ts +63 -0
  35. package/dist/cli/experimental/command.d.ts.map +1 -0
  36. package/dist/cli/experimental/command.js +130 -0
  37. package/dist/cli/experimental/command.js.map +1 -0
  38. package/dist/cli/experimental/commands/client.d.ts +13 -0
  39. package/dist/cli/experimental/commands/client.d.ts.map +1 -0
  40. package/dist/cli/experimental/commands/client.js +25 -0
  41. package/dist/cli/experimental/commands/client.js.map +1 -0
  42. package/dist/cli/experimental/commands/pi.d.ts +15 -0
  43. package/dist/cli/experimental/commands/pi.d.ts.map +1 -0
  44. package/dist/cli/experimental/commands/pi.js +28 -0
  45. package/dist/cli/experimental/commands/pi.js.map +1 -0
  46. package/dist/cli/experimental/commands/server.d.ts +13 -0
  47. package/dist/cli/experimental/commands/server.d.ts.map +1 -0
  48. package/dist/cli/experimental/commands/server.js +25 -0
  49. package/dist/cli/experimental/commands/server.js.map +1 -0
  50. package/dist/cli/experimental/transport-address.d.ts +10 -0
  51. package/dist/cli/experimental/transport-address.d.ts.map +1 -0
  52. package/dist/cli/experimental/transport-address.js +38 -0
  53. package/dist/cli/experimental/transport-address.js.map +1 -0
  54. package/dist/cli/list-models.d.ts +1 -1
  55. package/dist/cli/list-models.d.ts.map +1 -1
  56. package/dist/cli/list-models.js +2 -2
  57. package/dist/cli/list-models.js.map +1 -1
  58. package/dist/cli/startup-ui.d.ts +1 -1
  59. package/dist/cli/startup-ui.d.ts.map +1 -1
  60. package/dist/cli/startup-ui.js +2 -2
  61. package/dist/cli/startup-ui.js.map +1 -1
  62. package/dist/client/index.d.ts +3 -0
  63. package/dist/client/index.d.ts.map +1 -0
  64. package/dist/client/index.js +3 -0
  65. package/dist/client/index.js.map +1 -0
  66. package/dist/client/remote-session.d.ts +53 -0
  67. package/dist/client/remote-session.d.ts.map +1 -0
  68. package/dist/client/remote-session.js +340 -0
  69. package/dist/client/remote-session.js.map +1 -0
  70. package/dist/client/transcript.d.ts +12 -0
  71. package/dist/client/transcript.d.ts.map +1 -0
  72. package/dist/client/transcript.js +98 -0
  73. package/dist/client/transcript.js.map +1 -0
  74. package/dist/core/agent-session-services.d.ts +1 -0
  75. package/dist/core/agent-session-services.d.ts.map +1 -1
  76. package/dist/core/agent-session-services.js +1 -0
  77. package/dist/core/agent-session-services.js.map +1 -1
  78. package/dist/core/agent-session.d.ts +1 -10
  79. package/dist/core/agent-session.d.ts.map +1 -1
  80. package/dist/core/agent-session.js +72 -70
  81. package/dist/core/agent-session.js.map +1 -1
  82. package/dist/core/auth-storage.d.ts +25 -9
  83. package/dist/core/auth-storage.d.ts.map +1 -1
  84. package/dist/core/auth-storage.js +237 -39
  85. package/dist/core/auth-storage.js.map +1 -1
  86. package/dist/core/extensions/index.d.ts +1 -1
  87. package/dist/core/extensions/index.d.ts.map +1 -1
  88. package/dist/core/extensions/index.js.map +1 -1
  89. package/dist/core/extensions/loader.d.ts.map +1 -1
  90. package/dist/core/extensions/loader.js +60 -41
  91. package/dist/core/extensions/loader.js.map +1 -1
  92. package/dist/core/extensions/runner.d.ts +2 -1
  93. package/dist/core/extensions/runner.d.ts.map +1 -1
  94. package/dist/core/extensions/runner.js +3 -0
  95. package/dist/core/extensions/runner.js.map +1 -1
  96. package/dist/core/extensions/types.d.ts +27 -4
  97. package/dist/core/extensions/types.d.ts.map +1 -1
  98. package/dist/core/extensions/types.js.map +1 -1
  99. package/dist/core/http-dispatcher.d.ts.map +1 -1
  100. package/dist/core/http-dispatcher.js +5 -0
  101. package/dist/core/http-dispatcher.js.map +1 -1
  102. package/dist/core/keybindings.d.ts +45 -5
  103. package/dist/core/keybindings.d.ts.map +1 -1
  104. package/dist/core/keybindings.js.map +1 -1
  105. package/dist/core/model-config.d.ts +29 -5
  106. package/dist/core/model-config.d.ts.map +1 -1
  107. package/dist/core/model-config.js +4 -0
  108. package/dist/core/model-config.js.map +1 -1
  109. package/dist/core/model-registry.d.ts +5 -3
  110. package/dist/core/model-registry.d.ts.map +1 -1
  111. package/dist/core/model-registry.js +13 -10
  112. package/dist/core/model-registry.js.map +1 -1
  113. package/dist/core/model-resolver.d.ts +4 -3
  114. package/dist/core/model-resolver.d.ts.map +1 -1
  115. package/dist/core/model-resolver.js +42 -10
  116. package/dist/core/model-resolver.js.map +1 -1
  117. package/dist/core/model-runtime.d.ts +30 -13
  118. package/dist/core/model-runtime.d.ts.map +1 -1
  119. package/dist/core/model-runtime.js +233 -73
  120. package/dist/core/model-runtime.js.map +1 -1
  121. package/dist/core/models-store.d.ts +12 -7
  122. package/dist/core/models-store.d.ts.map +1 -1
  123. package/dist/core/models-store.js +83 -14
  124. package/dist/core/models-store.js.map +1 -1
  125. package/dist/core/package-manager.d.ts +6 -3
  126. package/dist/core/package-manager.d.ts.map +1 -1
  127. package/dist/core/package-manager.js +80 -61
  128. package/dist/core/package-manager.js.map +1 -1
  129. package/dist/core/pi-manifest.d.ts +8 -0
  130. package/dist/core/pi-manifest.d.ts.map +1 -0
  131. package/dist/core/pi-manifest.js +28 -0
  132. package/dist/core/pi-manifest.js.map +1 -0
  133. package/dist/core/provider-composer.d.ts +4 -1
  134. package/dist/core/provider-composer.d.ts.map +1 -1
  135. package/dist/core/provider-composer.js +36 -15
  136. package/dist/core/provider-composer.js.map +1 -1
  137. package/dist/core/remote-catalog-provider.d.ts.map +1 -1
  138. package/dist/core/remote-catalog-provider.js +73 -67
  139. package/dist/core/remote-catalog-provider.js.map +1 -1
  140. package/dist/core/resource-loader.d.ts.map +1 -1
  141. package/dist/core/resource-loader.js +2 -2
  142. package/dist/core/resource-loader.js.map +1 -1
  143. package/dist/core/runtime-credentials.d.ts +5 -5
  144. package/dist/core/runtime-credentials.d.ts.map +1 -1
  145. package/dist/core/runtime-credentials.js +11 -8
  146. package/dist/core/runtime-credentials.js.map +1 -1
  147. package/dist/core/sdk.d.ts +1 -1
  148. package/dist/core/sdk.d.ts.map +1 -1
  149. package/dist/core/sdk.js +2 -2
  150. package/dist/core/sdk.js.map +1 -1
  151. package/dist/core/session-manager.d.ts.map +1 -1
  152. package/dist/core/session-manager.js +3 -1
  153. package/dist/core/session-manager.js.map +1 -1
  154. package/dist/core/settings-manager.d.ts +12 -0
  155. package/dist/core/settings-manager.d.ts.map +1 -1
  156. package/dist/core/settings-manager.js +40 -16
  157. package/dist/core/settings-manager.js.map +1 -1
  158. package/dist/core/system-prompt.d.ts.map +1 -1
  159. package/dist/core/system-prompt.js +8 -0
  160. package/dist/core/system-prompt.js.map +1 -1
  161. package/dist/core/tools/bash.d.ts +5 -1
  162. package/dist/core/tools/bash.d.ts.map +1 -1
  163. package/dist/core/tools/bash.js +16 -15
  164. package/dist/core/tools/bash.js.map +1 -1
  165. package/dist/core/tools/edit.d.ts +4 -0
  166. package/dist/core/tools/edit.d.ts.map +1 -1
  167. package/dist/core/tools/edit.js +11 -7
  168. package/dist/core/tools/edit.js.map +1 -1
  169. package/dist/core/tools/find.d.ts +7 -0
  170. package/dist/core/tools/find.d.ts.map +1 -1
  171. package/dist/core/tools/find.js +16 -19
  172. package/dist/core/tools/find.js.map +1 -1
  173. package/dist/core/tools/grep.d.ts +4 -0
  174. package/dist/core/tools/grep.d.ts.map +1 -1
  175. package/dist/core/tools/grep.js +5 -1
  176. package/dist/core/tools/grep.js.map +1 -1
  177. package/dist/core/tools/ls.d.ts +4 -0
  178. package/dist/core/tools/ls.d.ts.map +1 -1
  179. package/dist/core/tools/ls.js +5 -1
  180. package/dist/core/tools/ls.js.map +1 -1
  181. package/dist/core/tools/read.d.ts +4 -0
  182. package/dist/core/tools/read.d.ts.map +1 -1
  183. package/dist/core/tools/read.js +7 -3
  184. package/dist/core/tools/read.js.map +1 -1
  185. package/dist/core/tools/write.d.ts +4 -0
  186. package/dist/core/tools/write.d.ts.map +1 -1
  187. package/dist/core/tools/write.js +6 -2
  188. package/dist/core/tools/write.js.map +1 -1
  189. package/dist/extensions/llama/index.d.ts.map +1 -1
  190. package/dist/extensions/llama/index.js +11 -2
  191. package/dist/extensions/llama/index.js.map +1 -1
  192. package/dist/extensions/llama/provider.d.ts.map +1 -1
  193. package/dist/extensions/llama/provider.js +21 -7
  194. package/dist/extensions/llama/provider.js.map +1 -1
  195. package/dist/humain/agent-execution-protocol.d.ts +218 -0
  196. package/dist/humain/agent-execution-protocol.d.ts.map +1 -0
  197. package/dist/humain/agent-execution-protocol.js +204 -0
  198. package/dist/humain/agent-execution-protocol.js.map +1 -0
  199. package/dist/humain/agent-execution-runtime.d.ts +35 -0
  200. package/dist/humain/agent-execution-runtime.d.ts.map +1 -0
  201. package/dist/humain/agent-execution-runtime.js +170 -0
  202. package/dist/humain/agent-execution-runtime.js.map +1 -0
  203. package/dist/humain/index.d.ts.map +1 -1
  204. package/dist/humain/index.js +8 -7
  205. package/dist/humain/index.js.map +1 -1
  206. package/dist/humain/mcp-adapter/vendor/CHANGELOG.md +660 -0
  207. package/dist/humain/mcp-adapter/vendor/LICENSE +21 -0
  208. package/dist/humain/mcp-adapter/vendor/README.md +733 -0
  209. package/dist/humain/mcp-adapter/vendor/abort.ts +34 -0
  210. package/dist/humain/mcp-adapter/vendor/agent-dir.ts +60 -0
  211. package/dist/humain/mcp-adapter/vendor/agent-plugin-loader.ts +377 -0
  212. package/dist/humain/mcp-adapter/vendor/app-bridge.bundle.js +67 -0
  213. package/dist/humain/mcp-adapter/vendor/banner.png +0 -0
  214. package/dist/humain/mcp-adapter/vendor/cli.js +209 -0
  215. package/dist/humain/mcp-adapter/vendor/commands.ts +627 -0
  216. package/dist/humain/mcp-adapter/vendor/config.ts +1226 -0
  217. package/dist/humain/mcp-adapter/vendor/consent-manager.ts +64 -0
  218. package/dist/humain/mcp-adapter/vendor/direct-tools.ts +604 -0
  219. package/dist/humain/mcp-adapter/vendor/elicitation-handler.ts +348 -0
  220. package/dist/humain/mcp-adapter/vendor/error-signal.ts +21 -0
  221. package/dist/humain/mcp-adapter/vendor/errors.ts +223 -0
  222. package/dist/humain/mcp-adapter/vendor/glimpse-ui.ts +80 -0
  223. package/dist/humain/mcp-adapter/vendor/host-html-template.ts +461 -0
  224. package/dist/humain/mcp-adapter/vendor/index.bundle.d.mts +4 -0
  225. package/dist/humain/mcp-adapter/vendor/index.bundle.mjs +15923 -0
  226. package/dist/humain/mcp-adapter/vendor/index.ts +898 -0
  227. package/dist/humain/mcp-adapter/vendor/init.ts +649 -0
  228. package/dist/humain/mcp-adapter/vendor/json-schema-validator.ts +69 -0
  229. package/dist/humain/mcp-adapter/vendor/lifecycle.ts +147 -0
  230. package/dist/humain/mcp-adapter/vendor/logger.ts +169 -0
  231. package/dist/humain/mcp-adapter/vendor/mcp-auth-flow.ts +993 -0
  232. package/dist/humain/mcp-adapter/vendor/mcp-auth.ts +1000 -0
  233. package/dist/humain/mcp-adapter/vendor/mcp-callback-server.ts +510 -0
  234. package/dist/humain/mcp-adapter/vendor/mcp-code.ts +354 -0
  235. package/dist/humain/mcp-adapter/vendor/mcp-keyring-helper.cjs +89 -0
  236. package/dist/humain/mcp-adapter/vendor/mcp-oauth-provider.ts +616 -0
  237. package/dist/humain/mcp-adapter/vendor/mcp-output-guard.ts +408 -0
  238. package/dist/humain/mcp-adapter/vendor/mcp-panel.ts +1015 -0
  239. package/dist/humain/mcp-adapter/vendor/mcp-probe.ts +187 -0
  240. package/dist/humain/mcp-adapter/vendor/mcp-script-worker.mjs +130 -0
  241. package/dist/humain/mcp-adapter/vendor/mcp-setup-panel.ts +666 -0
  242. package/dist/humain/mcp-adapter/vendor/mcp-status.ts +109 -0
  243. package/dist/humain/mcp-adapter/vendor/mcp-trace.ts +306 -0
  244. package/dist/humain/mcp-adapter/vendor/metadata-cache.ts +353 -0
  245. package/dist/humain/mcp-adapter/vendor/npx-resolver.ts +543 -0
  246. package/dist/humain/mcp-adapter/vendor/oauth-handler.ts +30 -0
  247. package/dist/humain/mcp-adapter/vendor/oauth.ts +48 -0
  248. package/dist/humain/mcp-adapter/vendor/onboarding-state.ts +76 -0
  249. package/dist/humain/mcp-adapter/vendor/package.json +178 -0
  250. package/dist/humain/mcp-adapter/vendor/panel-keys.ts +53 -0
  251. package/dist/humain/mcp-adapter/vendor/prompts.ts +353 -0
  252. package/dist/humain/mcp-adapter/vendor/proxy-modes.ts +1331 -0
  253. package/dist/humain/mcp-adapter/vendor/resource-tools.ts +17 -0
  254. package/dist/humain/mcp-adapter/vendor/runtime-owner.ts +91 -0
  255. package/dist/humain/mcp-adapter/vendor/sampling-handler.ts +284 -0
  256. package/dist/humain/mcp-adapter/vendor/search-ranking.ts +206 -0
  257. package/dist/humain/mcp-adapter/vendor/server-manager.ts +1124 -0
  258. package/dist/humain/mcp-adapter/vendor/session-recovery.ts +151 -0
  259. package/dist/humain/mcp-adapter/vendor/skills/mcp-scripting/SKILL.md +38 -0
  260. package/dist/humain/mcp-adapter/vendor/state.ts +62 -0
  261. package/dist/humain/mcp-adapter/vendor/tool-approval.ts +182 -0
  262. package/dist/humain/mcp-adapter/vendor/tool-metadata.ts +276 -0
  263. package/dist/humain/mcp-adapter/vendor/tool-registrar.ts +253 -0
  264. package/dist/humain/mcp-adapter/vendor/tool-result-renderer.ts +423 -0
  265. package/dist/humain/mcp-adapter/vendor/ts-shape.ts +149 -0
  266. package/dist/humain/mcp-adapter/vendor/types.ts +859 -0
  267. package/dist/humain/mcp-adapter/vendor/ui-app-bridge-helpers.ts +40 -0
  268. package/dist/humain/mcp-adapter/vendor/ui-resource-handler.ts +250 -0
  269. package/dist/humain/mcp-adapter/vendor/ui-server.ts +866 -0
  270. package/dist/humain/mcp-adapter/vendor/ui-session.ts +570 -0
  271. package/dist/humain/mcp-adapter/vendor/ui-stream-types.ts +89 -0
  272. package/dist/humain/mcp-adapter/vendor/ui-tool-visibility.ts +25 -0
  273. package/dist/humain/mcp-adapter/vendor/unix-socket-transport.ts +85 -0
  274. package/dist/humain/mcp-adapter/vendor/utils.ts +310 -0
  275. package/dist/humain/mcp-adapter.d.ts +3 -0
  276. package/dist/humain/mcp-adapter.d.ts.map +1 -0
  277. package/dist/humain/mcp-adapter.js +5 -0
  278. package/dist/humain/mcp-adapter.js.map +1 -0
  279. package/dist/humain/pi-agent-execution-host.d.ts +34 -0
  280. package/dist/humain/pi-agent-execution-host.d.ts.map +1 -0
  281. package/dist/humain/pi-agent-execution-host.js +77 -0
  282. package/dist/humain/pi-agent-execution-host.js.map +1 -0
  283. package/dist/humain/web-access/host.d.ts +4 -0
  284. package/dist/humain/web-access/host.d.ts.map +1 -0
  285. package/dist/humain/web-access/host.js +3 -0
  286. package/dist/humain/web-access/host.js.map +1 -0
  287. package/dist/humain/web-access/index.d.ts +3 -0
  288. package/dist/humain/web-access/index.d.ts.map +1 -0
  289. package/dist/humain/web-access/index.js +5 -0
  290. package/dist/humain/web-access/index.js.map +1 -0
  291. package/dist/humain/web-access/vendor/activity.d.ts +34 -0
  292. package/dist/humain/web-access/vendor/activity.d.ts.map +1 -0
  293. package/dist/humain/web-access/vendor/activity.js +68 -0
  294. package/dist/humain/web-access/vendor/activity.js.map +1 -0
  295. package/dist/humain/web-access/vendor/anysearch.d.ts +8 -0
  296. package/dist/humain/web-access/vendor/anysearch.d.ts.map +1 -0
  297. package/dist/humain/web-access/vendor/anysearch.js +167 -0
  298. package/dist/humain/web-access/vendor/anysearch.js.map +1 -0
  299. package/dist/humain/web-access/vendor/bocha.d.ts +4 -0
  300. package/dist/humain/web-access/vendor/bocha.d.ts.map +1 -0
  301. package/dist/humain/web-access/vendor/bocha.js +219 -0
  302. package/dist/humain/web-access/vendor/bocha.js.map +1 -0
  303. package/dist/humain/web-access/vendor/brave.d.ts +4 -0
  304. package/dist/humain/web-access/vendor/brave.d.ts.map +1 -0
  305. package/dist/humain/web-access/vendor/brave.js +194 -0
  306. package/dist/humain/web-access/vendor/brave.js.map +1 -0
  307. package/dist/humain/web-access/vendor/brightdata-unlocker.d.ts +12 -0
  308. package/dist/humain/web-access/vendor/brightdata-unlocker.d.ts.map +1 -0
  309. package/dist/humain/web-access/vendor/brightdata-unlocker.js +230 -0
  310. package/dist/humain/web-access/vendor/brightdata-unlocker.js.map +1 -0
  311. package/dist/humain/web-access/vendor/brightdata.d.ts +8 -0
  312. package/dist/humain/web-access/vendor/brightdata.d.ts.map +1 -0
  313. package/dist/humain/web-access/vendor/brightdata.js +519 -0
  314. package/dist/humain/web-access/vendor/brightdata.js.map +1 -0
  315. package/dist/humain/web-access/vendor/chrome-cookies.d.ts +10 -0
  316. package/dist/humain/web-access/vendor/chrome-cookies.d.ts.map +1 -0
  317. package/dist/humain/web-access/vendor/chrome-cookies.js +438 -0
  318. package/dist/humain/web-access/vendor/chrome-cookies.js.map +1 -0
  319. package/dist/humain/web-access/vendor/content-find.d.ts +11 -0
  320. package/dist/humain/web-access/vendor/content-find.d.ts.map +1 -0
  321. package/dist/humain/web-access/vendor/content-find.js +117 -0
  322. package/dist/humain/web-access/vendor/content-find.js.map +1 -0
  323. package/dist/humain/web-access/vendor/credential-source.d.ts +28 -0
  324. package/dist/humain/web-access/vendor/credential-source.d.ts.map +1 -0
  325. package/dist/humain/web-access/vendor/credential-source.js +151 -0
  326. package/dist/humain/web-access/vendor/credential-source.js.map +1 -0
  327. package/dist/humain/web-access/vendor/curator-page.d.ts +29 -0
  328. package/dist/humain/web-access/vendor/curator-page.d.ts.map +1 -0
  329. package/dist/humain/web-access/vendor/curator-page.js +3554 -0
  330. package/dist/humain/web-access/vendor/curator-page.js.map +1 -0
  331. package/dist/humain/web-access/vendor/curator-server.d.ts +93 -0
  332. package/dist/humain/web-access/vendor/curator-server.d.ts.map +1 -0
  333. package/dist/humain/web-access/vendor/curator-server.js +688 -0
  334. package/dist/humain/web-access/vendor/curator-server.js.map +1 -0
  335. package/dist/humain/web-access/vendor/datalab-pdf-extract.d.ts +60 -0
  336. package/dist/humain/web-access/vendor/datalab-pdf-extract.d.ts.map +1 -0
  337. package/dist/humain/web-access/vendor/datalab-pdf-extract.js +416 -0
  338. package/dist/humain/web-access/vendor/datalab-pdf-extract.js.map +1 -0
  339. package/dist/humain/web-access/vendor/declared-web-links.d.ts +16 -0
  340. package/dist/humain/web-access/vendor/declared-web-links.d.ts.map +1 -0
  341. package/dist/humain/web-access/vendor/declared-web-links.js +168 -0
  342. package/dist/humain/web-access/vendor/declared-web-links.js.map +1 -0
  343. package/dist/humain/web-access/vendor/duckduckgo.d.ts +4 -0
  344. package/dist/humain/web-access/vendor/duckduckgo.d.ts.map +1 -0
  345. package/dist/humain/web-access/vendor/duckduckgo.js +123 -0
  346. package/dist/humain/web-access/vendor/duckduckgo.js.map +1 -0
  347. package/dist/humain/web-access/vendor/exa.d.ts +10 -0
  348. package/dist/humain/web-access/vendor/exa.d.ts.map +1 -0
  349. package/dist/humain/web-access/vendor/exa.js +426 -0
  350. package/dist/humain/web-access/vendor/exa.js.map +1 -0
  351. package/dist/humain/web-access/vendor/extract.d.ts +46 -0
  352. package/dist/humain/web-access/vendor/extract.d.ts.map +1 -0
  353. package/dist/humain/web-access/vendor/extract.js +1064 -0
  354. package/dist/humain/web-access/vendor/extract.js.map +1 -0
  355. package/dist/humain/web-access/vendor/feature-config.d.ts +3 -0
  356. package/dist/humain/web-access/vendor/feature-config.d.ts.map +1 -0
  357. package/dist/humain/web-access/vendor/feature-config.js +27 -0
  358. package/dist/humain/web-access/vendor/feature-config.js.map +1 -0
  359. package/dist/humain/web-access/vendor/fetch-params.d.ts +25 -0
  360. package/dist/humain/web-access/vendor/fetch-params.d.ts.map +1 -0
  361. package/dist/humain/web-access/vendor/fetch-params.js +57 -0
  362. package/dist/humain/web-access/vendor/fetch-params.js.map +1 -0
  363. package/dist/humain/web-access/vendor/firecrawl.d.ts +12 -0
  364. package/dist/humain/web-access/vendor/firecrawl.d.ts.map +1 -0
  365. package/dist/humain/web-access/vendor/firecrawl.js +239 -0
  366. package/dist/humain/web-access/vendor/firecrawl.js.map +1 -0
  367. package/dist/humain/web-access/vendor/gemini-api.d.ts +27 -0
  368. package/dist/humain/web-access/vendor/gemini-api.d.ts.map +1 -0
  369. package/dist/humain/web-access/vendor/gemini-api.js +230 -0
  370. package/dist/humain/web-access/vendor/gemini-api.js.map +1 -0
  371. package/dist/humain/web-access/vendor/gemini-pdf-extract.d.ts +9 -0
  372. package/dist/humain/web-access/vendor/gemini-pdf-extract.d.ts.map +1 -0
  373. package/dist/humain/web-access/vendor/gemini-pdf-extract.js +85 -0
  374. package/dist/humain/web-access/vendor/gemini-pdf-extract.js.map +1 -0
  375. package/dist/humain/web-access/vendor/gemini-search.d.ts +40 -0
  376. package/dist/humain/web-access/vendor/gemini-search.d.ts.map +1 -0
  377. package/dist/humain/web-access/vendor/gemini-search.js +814 -0
  378. package/dist/humain/web-access/vendor/gemini-search.js.map +1 -0
  379. package/dist/humain/web-access/vendor/gemini-url-context.d.ts +4 -0
  380. package/dist/humain/web-access/vendor/gemini-url-context.d.ts.map +1 -0
  381. package/dist/humain/web-access/vendor/gemini-url-context.js +101 -0
  382. package/dist/humain/web-access/vendor/gemini-url-context.js.map +1 -0
  383. package/dist/humain/web-access/vendor/gemini-web-config.d.ts +4 -0
  384. package/dist/humain/web-access/vendor/gemini-web-config.d.ts.map +1 -0
  385. package/dist/humain/web-access/vendor/gemini-web-config.js +42 -0
  386. package/dist/humain/web-access/vendor/gemini-web-config.js.map +1 -0
  387. package/dist/humain/web-access/vendor/gemini-web.d.ts +18 -0
  388. package/dist/humain/web-access/vendor/gemini-web.d.ts.map +1 -0
  389. package/dist/humain/web-access/vendor/gemini-web.js +385 -0
  390. package/dist/humain/web-access/vendor/gemini-web.js.map +1 -0
  391. package/dist/humain/web-access/vendor/github-api.d.ts +7 -0
  392. package/dist/humain/web-access/vendor/github-api.d.ts.map +1 -0
  393. package/dist/humain/web-access/vendor/github-api.js +160 -0
  394. package/dist/humain/web-access/vendor/github-api.js.map +1 -0
  395. package/dist/humain/web-access/vendor/github-extract.d.ts +13 -0
  396. package/dist/humain/web-access/vendor/github-extract.d.ts.map +1 -0
  397. package/dist/humain/web-access/vendor/github-extract.js +635 -0
  398. package/dist/humain/web-access/vendor/github-extract.js.map +1 -0
  399. package/dist/humain/web-access/vendor/index.d.ts +4 -0
  400. package/dist/humain/web-access/vendor/index.d.ts.map +1 -0
  401. package/dist/humain/web-access/vendor/index.js +3002 -0
  402. package/dist/humain/web-access/vendor/index.js.map +1 -0
  403. package/dist/humain/web-access/vendor/jina-search.d.ts +8 -0
  404. package/dist/humain/web-access/vendor/jina-search.d.ts.map +1 -0
  405. package/dist/humain/web-access/vendor/jina-search.js +255 -0
  406. package/dist/humain/web-access/vendor/jina-search.js.map +1 -0
  407. package/dist/humain/web-access/vendor/kagi.d.ts +15 -0
  408. package/dist/humain/web-access/vendor/kagi.d.ts.map +1 -0
  409. package/dist/humain/web-access/vendor/kagi.js +262 -0
  410. package/dist/humain/web-access/vendor/kagi.js.map +1 -0
  411. package/dist/humain/web-access/vendor/ollama.d.ts +15 -0
  412. package/dist/humain/web-access/vendor/ollama.d.ts.map +1 -0
  413. package/dist/humain/web-access/vendor/ollama.js +216 -0
  414. package/dist/humain/web-access/vendor/ollama.js.map +1 -0
  415. package/dist/humain/web-access/vendor/openai-search.d.ts +15 -0
  416. package/dist/humain/web-access/vendor/openai-search.d.ts.map +1 -0
  417. package/dist/humain/web-access/vendor/openai-search.js +459 -0
  418. package/dist/humain/web-access/vendor/openai-search.js.map +1 -0
  419. package/dist/humain/web-access/vendor/page-query.d.ts +16 -0
  420. package/dist/humain/web-access/vendor/page-query.d.ts.map +1 -0
  421. package/dist/humain/web-access/vendor/page-query.js +79 -0
  422. package/dist/humain/web-access/vendor/page-query.js.map +1 -0
  423. package/dist/humain/web-access/vendor/parallel.d.ts +12 -0
  424. package/dist/humain/web-access/vendor/parallel.d.ts.map +1 -0
  425. package/dist/humain/web-access/vendor/parallel.js +343 -0
  426. package/dist/humain/web-access/vendor/parallel.js.map +1 -0
  427. package/dist/humain/web-access/vendor/pdf-extract.d.ts +44 -0
  428. package/dist/humain/web-access/vendor/pdf-extract.d.ts.map +1 -0
  429. package/dist/humain/web-access/vendor/pdf-extract.js +298 -0
  430. package/dist/humain/web-access/vendor/pdf-extract.js.map +1 -0
  431. package/dist/humain/web-access/vendor/perplexity.d.ts +20 -0
  432. package/dist/humain/web-access/vendor/perplexity.d.ts.map +1 -0
  433. package/dist/humain/web-access/vendor/perplexity.js +159 -0
  434. package/dist/humain/web-access/vendor/perplexity.js.map +1 -0
  435. package/dist/humain/web-access/vendor/querit.d.ts +10 -0
  436. package/dist/humain/web-access/vendor/querit.d.ts.map +1 -0
  437. package/dist/humain/web-access/vendor/querit.js +335 -0
  438. package/dist/humain/web-access/vendor/querit.js.map +1 -0
  439. package/dist/humain/web-access/vendor/render-search-error.d.ts +57 -0
  440. package/dist/humain/web-access/vendor/render-search-error.d.ts.map +1 -0
  441. package/dist/humain/web-access/vendor/render-search-error.js +130 -0
  442. package/dist/humain/web-access/vendor/render-search-error.js.map +1 -0
  443. package/dist/humain/web-access/vendor/rsc-extract.d.ts +12 -0
  444. package/dist/humain/web-access/vendor/rsc-extract.d.ts.map +1 -0
  445. package/dist/humain/web-access/vendor/rsc-extract.js +329 -0
  446. package/dist/humain/web-access/vendor/rsc-extract.js.map +1 -0
  447. package/dist/humain/web-access/vendor/search1api.d.ts +10 -0
  448. package/dist/humain/web-access/vendor/search1api.d.ts.map +1 -0
  449. package/dist/humain/web-access/vendor/search1api.js +251 -0
  450. package/dist/humain/web-access/vendor/search1api.js.map +1 -0
  451. package/dist/humain/web-access/vendor/searchinfinity.d.ts +8 -0
  452. package/dist/humain/web-access/vendor/searchinfinity.d.ts.map +1 -0
  453. package/dist/humain/web-access/vendor/searchinfinity.js +229 -0
  454. package/dist/humain/web-access/vendor/searchinfinity.js.map +1 -0
  455. package/dist/humain/web-access/vendor/searxng.d.ts +4 -0
  456. package/dist/humain/web-access/vendor/searxng.d.ts.map +1 -0
  457. package/dist/humain/web-access/vendor/searxng.js +238 -0
  458. package/dist/humain/web-access/vendor/searxng.js.map +1 -0
  459. package/dist/humain/web-access/vendor/serpbase.d.ts +4 -0
  460. package/dist/humain/web-access/vendor/serpbase.d.ts.map +1 -0
  461. package/dist/humain/web-access/vendor/serpbase.js +211 -0
  462. package/dist/humain/web-access/vendor/serpbase.js.map +1 -0
  463. package/dist/humain/web-access/vendor/serpdive.d.ts +8 -0
  464. package/dist/humain/web-access/vendor/serpdive.d.ts.map +1 -0
  465. package/dist/humain/web-access/vendor/serpdive.js +267 -0
  466. package/dist/humain/web-access/vendor/serpdive.js.map +1 -0
  467. package/dist/humain/web-access/vendor/source-check.d.ts +99 -0
  468. package/dist/humain/web-access/vendor/source-check.d.ts.map +1 -0
  469. package/dist/humain/web-access/vendor/source-check.js +205 -0
  470. package/dist/humain/web-access/vendor/source-check.js.map +1 -0
  471. package/dist/humain/web-access/vendor/ssrf-protection.d.ts +50 -0
  472. package/dist/humain/web-access/vendor/ssrf-protection.d.ts.map +1 -0
  473. package/dist/humain/web-access/vendor/ssrf-protection.js +466 -0
  474. package/dist/humain/web-access/vendor/ssrf-protection.js.map +1 -0
  475. package/dist/humain/web-access/vendor/storage.d.ts +55 -0
  476. package/dist/humain/web-access/vendor/storage.d.ts.map +1 -0
  477. package/dist/humain/web-access/vendor/storage.js +485 -0
  478. package/dist/humain/web-access/vendor/storage.js.map +1 -0
  479. package/dist/humain/web-access/vendor/summary-model-scope.d.ts +25 -0
  480. package/dist/humain/web-access/vendor/summary-model-scope.d.ts.map +1 -0
  481. package/dist/humain/web-access/vendor/summary-model-scope.js +98 -0
  482. package/dist/humain/web-access/vendor/summary-model-scope.js.map +1 -0
  483. package/dist/humain/web-access/vendor/summary-review.d.ts +24 -0
  484. package/dist/humain/web-access/vendor/summary-review.d.ts.map +1 -0
  485. package/dist/humain/web-access/vendor/summary-review.js +341 -0
  486. package/dist/humain/web-access/vendor/summary-review.js.map +1 -0
  487. package/dist/humain/web-access/vendor/tavily.d.ts +8 -0
  488. package/dist/humain/web-access/vendor/tavily.d.ts.map +1 -0
  489. package/dist/humain/web-access/vendor/tavily.js +194 -0
  490. package/dist/humain/web-access/vendor/tavily.js.map +1 -0
  491. package/dist/humain/web-access/vendor/tinyfish.d.ts +11 -0
  492. package/dist/humain/web-access/vendor/tinyfish.d.ts.map +1 -0
  493. package/dist/humain/web-access/vendor/tinyfish.js +331 -0
  494. package/dist/humain/web-access/vendor/tinyfish.js.map +1 -0
  495. package/dist/humain/web-access/vendor/utils.d.ts +20 -0
  496. package/dist/humain/web-access/vendor/utils.d.ts.map +1 -0
  497. package/dist/humain/web-access/vendor/utils.js +91 -0
  498. package/dist/humain/web-access/vendor/utils.js.map +1 -0
  499. package/dist/humain/web-access/vendor/video-extract.d.ts +16 -0
  500. package/dist/humain/web-access/vendor/video-extract.d.ts.map +1 -0
  501. package/dist/humain/web-access/vendor/video-extract.js +335 -0
  502. package/dist/humain/web-access/vendor/video-extract.js.map +1 -0
  503. package/dist/humain/web-access/vendor/xai-search.d.ts +13 -0
  504. package/dist/humain/web-access/vendor/xai-search.d.ts.map +1 -0
  505. package/dist/humain/web-access/vendor/xai-search.js +331 -0
  506. package/dist/humain/web-access/vendor/xai-search.js.map +1 -0
  507. package/dist/humain/web-access/vendor/youtube-extract.d.ts +27 -0
  508. package/dist/humain/web-access/vendor/youtube-extract.d.ts.map +1 -0
  509. package/dist/humain/web-access/vendor/youtube-extract.js +282 -0
  510. package/dist/humain/web-access/vendor/youtube-extract.js.map +1 -0
  511. package/dist/index.d.ts +7 -4
  512. package/dist/index.d.ts.map +1 -1
  513. package/dist/index.js +5 -2
  514. package/dist/index.js.map +1 -1
  515. package/dist/main.d.ts +2 -2
  516. package/dist/main.d.ts.map +1 -1
  517. package/dist/main.js +169 -102
  518. package/dist/main.js.map +1 -1
  519. package/dist/modes/agent-exec-mode.d.ts +14 -0
  520. package/dist/modes/agent-exec-mode.d.ts.map +1 -0
  521. package/dist/modes/agent-exec-mode.js +92 -0
  522. package/dist/modes/agent-exec-mode.js.map +1 -0
  523. package/dist/modes/index.d.ts +4 -2
  524. package/dist/modes/index.d.ts.map +1 -1
  525. package/dist/modes/index.js +2 -1
  526. package/dist/modes/index.js.map +1 -1
  527. package/dist/modes/interactive/components/assistant-message.d.ts +5 -2
  528. package/dist/modes/interactive/components/assistant-message.d.ts.map +1 -1
  529. package/dist/modes/interactive/components/assistant-message.js +13 -4
  530. package/dist/modes/interactive/components/assistant-message.js.map +1 -1
  531. package/dist/modes/interactive/components/custom-editor.d.ts.map +1 -1
  532. package/dist/modes/interactive/components/custom-editor.js +7 -0
  533. package/dist/modes/interactive/components/custom-editor.js.map +1 -1
  534. package/dist/modes/interactive/components/earendil-announcement.d.ts +5 -0
  535. package/dist/modes/interactive/components/earendil-announcement.d.ts.map +1 -0
  536. package/dist/modes/interactive/components/earendil-announcement.js +40 -0
  537. package/dist/modes/interactive/components/earendil-announcement.js.map +1 -0
  538. package/dist/modes/interactive/components/footer.d.ts.map +1 -1
  539. package/dist/modes/interactive/components/footer.js +1 -1
  540. package/dist/modes/interactive/components/footer.js.map +1 -1
  541. package/dist/modes/interactive/components/markdown-transform.d.ts +3 -0
  542. package/dist/modes/interactive/components/markdown-transform.d.ts.map +1 -0
  543. package/dist/modes/interactive/components/markdown-transform.js +19 -0
  544. package/dist/modes/interactive/components/markdown-transform.js.map +1 -0
  545. package/dist/modes/interactive/components/mermaid.d.ts +11 -0
  546. package/dist/modes/interactive/components/mermaid.d.ts.map +1 -0
  547. package/dist/modes/interactive/components/mermaid.js +75 -0
  548. package/dist/modes/interactive/components/mermaid.js.map +1 -0
  549. package/dist/modes/interactive/components/model-selector.d.ts +1 -1
  550. package/dist/modes/interactive/components/model-selector.d.ts.map +1 -1
  551. package/dist/modes/interactive/components/model-selector.js +16 -4
  552. package/dist/modes/interactive/components/model-selector.js.map +1 -1
  553. package/dist/modes/interactive/components/scoped-models-selector.d.ts +4 -0
  554. package/dist/modes/interactive/components/scoped-models-selector.d.ts.map +1 -1
  555. package/dist/modes/interactive/components/scoped-models-selector.js +26 -0
  556. package/dist/modes/interactive/components/scoped-models-selector.js.map +1 -1
  557. package/dist/modes/interactive/components/settings-selector.d.ts +8 -2
  558. package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -1
  559. package/dist/modes/interactive/components/settings-selector.js +30 -0
  560. package/dist/modes/interactive/components/settings-selector.js.map +1 -1
  561. package/dist/modes/interactive/components/user-message.d.ts +3 -1
  562. package/dist/modes/interactive/components/user-message.d.ts.map +1 -1
  563. package/dist/modes/interactive/components/user-message.js +9 -2
  564. package/dist/modes/interactive/components/user-message.js.map +1 -1
  565. package/dist/modes/interactive/interactive-mode.d.ts +45 -9
  566. package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
  567. package/dist/modes/interactive/interactive-mode.js +581 -211
  568. package/dist/modes/interactive/interactive-mode.js.map +1 -1
  569. package/dist/modes/interactive/theme/dark.json +1 -0
  570. package/dist/modes/interactive/theme/light.json +1 -0
  571. package/dist/modes/interactive/theme/theme-controller.d.ts +3 -0
  572. package/dist/modes/interactive/theme/theme-controller.d.ts.map +1 -1
  573. package/dist/modes/interactive/theme/theme-controller.js +10 -1
  574. package/dist/modes/interactive/theme/theme-controller.js.map +1 -1
  575. package/dist/modes/interactive/theme/theme-schema.json +5 -1
  576. package/dist/modes/interactive/theme/theme.d.ts +2 -2
  577. package/dist/modes/interactive/theme/theme.d.ts.map +1 -1
  578. package/dist/modes/interactive/theme/theme.js +24 -6
  579. package/dist/modes/interactive/theme/theme.js.map +1 -1
  580. package/dist/modes/json-event.d.ts +28 -0
  581. package/dist/modes/json-event.d.ts.map +1 -0
  582. package/dist/modes/json-event.js +12 -0
  583. package/dist/modes/json-event.js.map +1 -0
  584. package/dist/modes/print-mode.d.ts.map +1 -1
  585. package/dist/modes/print-mode.js +12 -2
  586. package/dist/modes/print-mode.js.map +1 -1
  587. package/dist/modes/rpc/rpc-client.d.ts +12 -5
  588. package/dist/modes/rpc/rpc-client.d.ts.map +1 -1
  589. package/dist/modes/rpc/rpc-client.js +55 -1
  590. package/dist/modes/rpc/rpc-client.js.map +1 -1
  591. package/dist/modes/rpc/rpc-mode.d.ts +1 -1
  592. package/dist/modes/rpc/rpc-mode.d.ts.map +1 -1
  593. package/dist/modes/rpc/rpc-mode.js +13 -3
  594. package/dist/modes/rpc/rpc-mode.js.map +1 -1
  595. package/dist/modes/rpc/rpc-types.d.ts +15 -0
  596. package/dist/modes/rpc/rpc-types.d.ts.map +1 -1
  597. package/dist/modes/rpc/rpc-types.js.map +1 -1
  598. package/dist/package-manager-cli.d.ts.map +1 -1
  599. package/dist/package-manager-cli.js +11 -9
  600. package/dist/package-manager-cli.js.map +1 -1
  601. package/dist/rpc-entry.d.ts.map +1 -1
  602. package/dist/rpc-entry.js +3 -2
  603. package/dist/rpc-entry.js.map +1 -1
  604. package/dist/server/create-harness.d.ts +26 -0
  605. package/dist/server/create-harness.d.ts.map +1 -0
  606. package/dist/server/create-harness.js +104 -0
  607. package/dist/server/create-harness.js.map +1 -0
  608. package/dist/utils/abort.d.ts +5 -0
  609. package/dist/utils/abort.d.ts.map +1 -0
  610. package/dist/utils/abort.js +48 -0
  611. package/dist/utils/abort.js.map +1 -0
  612. package/dist/utils/clipboard.d.ts +1 -1
  613. package/dist/utils/clipboard.d.ts.map +1 -1
  614. package/dist/utils/clipboard.js +22 -2
  615. package/dist/utils/clipboard.js.map +1 -1
  616. package/dist/utils/management-http.d.ts +23 -0
  617. package/dist/utils/management-http.d.ts.map +1 -0
  618. package/dist/utils/management-http.js +50 -0
  619. package/dist/utils/management-http.js.map +1 -0
  620. package/dist/utils/paths.d.ts +3 -0
  621. package/dist/utils/paths.d.ts.map +1 -1
  622. package/dist/utils/paths.js +23 -1
  623. package/dist/utils/paths.js.map +1 -1
  624. package/dist/utils/tool-result-images.d.ts +19 -0
  625. package/dist/utils/tool-result-images.d.ts.map +1 -0
  626. package/dist/utils/tool-result-images.js +45 -0
  627. package/dist/utils/tool-result-images.js.map +1 -0
  628. package/dist/utils/tools-manager.d.ts.map +1 -1
  629. package/dist/utils/tools-manager.js +13 -25
  630. package/dist/utils/tools-manager.js.map +1 -1
  631. package/dist/utils/version-check.d.ts +4 -0
  632. package/dist/utils/version-check.d.ts.map +1 -1
  633. package/dist/utils/version-check.js +23 -5
  634. package/dist/utils/version-check.js.map +1 -1
  635. package/docs/compaction.md +2 -2
  636. package/docs/custom-provider.md +7 -5
  637. package/docs/extensions.md +30 -5
  638. package/docs/humain-terminal.md +21 -1
  639. package/docs/json.md +24 -19
  640. package/docs/keybindings.md +46 -14
  641. package/docs/models.md +32 -11
  642. package/docs/providers.md +9 -1
  643. package/docs/quickstart.md +39 -37
  644. package/docs/rpc.md +31 -11
  645. package/docs/sdk.md +21 -2
  646. package/docs/security.md +21 -21
  647. package/docs/session-format.md +14 -14
  648. package/docs/settings.md +4 -1
  649. package/docs/themes.md +5 -3
  650. package/docs/usage.md +7 -0
  651. package/examples/extensions/custom-compaction.ts +3 -18
  652. package/examples/extensions/custom-provider-anthropic/index.ts +5 -1
  653. package/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
  654. package/examples/extensions/custom-provider-anthropic/package.json +1 -1
  655. package/examples/extensions/custom-provider-gitlab-duo/index.ts +5 -1
  656. package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
  657. package/examples/extensions/doom-overlay/wad-finder.ts +7 -3
  658. package/examples/extensions/gondolin/package-lock.json +2 -2
  659. package/examples/extensions/gondolin/package.json +1 -1
  660. package/examples/extensions/handoff.ts +4 -13
  661. package/examples/extensions/qna.ts +5 -9
  662. package/examples/extensions/sandbox/package-lock.json +2 -2
  663. package/examples/extensions/sandbox/package.json +1 -1
  664. package/examples/extensions/summarize.ts +9 -20
  665. package/examples/extensions/with-deps/package-lock.json +2 -2
  666. package/examples/extensions/with-deps/package.json +1 -1
  667. package/examples/rpc-extension-ui.ts +11 -2
  668. package/examples/sdk/02-custom-model.ts +2 -3
  669. package/examples/sdk/09-api-keys-and-oauth.ts +1 -1
  670. package/examples/sdk/12-full-control.ts +1 -1
  671. package/examples/sdk/README.md +1 -1
  672. package/npm-shrinkwrap.json +2771 -535
  673. package/package.json +40 -11
  674. package/src/humain/mcp-adapter/UPSTREAM.md +15 -0
  675. package/src/humain/mcp-adapter/upstream.json +7 -0
  676. package/src/humain/mcp-adapter/vendor/CHANGELOG.md +660 -0
  677. package/src/humain/mcp-adapter/vendor/LICENSE +21 -0
  678. package/src/humain/web-access/UPSTREAM.md +17 -0
  679. package/src/humain/web-access/upstream.json +23 -0
  680. package/src/humain/web-access/vendor/LICENSE +21 -0
@@ -0,0 +1,859 @@
1
+ // types.ts - Core type definitions
2
+ import type {
3
+ ContentBlock as McpContentBlock,
4
+ ListPromptsResult,
5
+ ListResourcesResult,
6
+ ListToolsResult,
7
+ Transport as McpTransport,
8
+ } from "@modelcontextprotocol/client";
9
+ import type { TextContent, ImageContent } from "@earendil-works/pi-ai";
10
+ import type { UiStreamMode } from "./ui-stream-types.ts";
11
+ import type { UiToolVisibility } from "./ui-tool-visibility.ts";
12
+
13
+ export type Transport = McpTransport;
14
+
15
+ /** Versioned shared-event-bus channel for read-only MCP runtime snapshots. */
16
+ export const MCP_STATUS_EVENT = "pi-mcp-adapter/status/v1";
17
+
18
+ export const MCP_STATUS_SNAPSHOT_VERSION = 1 as const;
19
+
20
+ export type McpServerRuntimeStatus =
21
+ | "connected"
22
+ | "cached"
23
+ | "failed"
24
+ | "needs-auth"
25
+ | "not-connected"
26
+ | "disabled";
27
+
28
+ export interface McpServerStatusSnapshot {
29
+ readonly name: string;
30
+ readonly status: McpServerRuntimeStatus;
31
+ readonly toolCount: number;
32
+ readonly resourceCount?: number;
33
+ readonly failedAgoSeconds?: number;
34
+ readonly disabled: boolean;
35
+ }
36
+
37
+ export interface McpStatusSnapshot {
38
+ readonly version: typeof MCP_STATUS_SNAPSHOT_VERSION;
39
+ readonly servers: ReadonlyArray<McpServerStatusSnapshot>;
40
+ readonly totalTools: number;
41
+ readonly totalResources: number;
42
+ readonly connectedCount: number;
43
+ readonly disabledCount: number;
44
+ }
45
+
46
+ // Import sources for config
47
+ export type ImportKind =
48
+ | "cursor"
49
+ | "claude-code"
50
+ | "claude-desktop"
51
+ | "codex"
52
+ | "opencode"
53
+ | "windsurf"
54
+ | "vscode";
55
+
56
+ type SdkTool = ListToolsResult["tools"][number];
57
+ type SdkResource = ListResourcesResult["resources"][number];
58
+ type SdkPrompt = ListPromptsResult["prompts"][number];
59
+ type SdkPromptArgument = NonNullable<SdkPrompt["arguments"]>[number];
60
+
61
+ // MCP wire definitions derive their field types from the installed SDK while
62
+ // retaining the adapter's deliberately smaller public surface.
63
+ export interface McpTool {
64
+ name: SdkTool["name"];
65
+ title?: SdkTool["title"];
66
+ description?: SdkTool["description"];
67
+ inputSchema?: SdkTool["inputSchema"]; // JSON Schema
68
+ _meta?: SdkTool["_meta"];
69
+ }
70
+
71
+ export interface McpResource {
72
+ uri: SdkResource["uri"];
73
+ name: SdkResource["name"];
74
+ description?: SdkResource["description"];
75
+ mimeType?: SdkResource["mimeType"];
76
+ _meta?: SdkResource["_meta"];
77
+ }
78
+
79
+ export interface McpPromptArgument {
80
+ name: SdkPromptArgument["name"];
81
+ description?: SdkPromptArgument["description"];
82
+ required?: SdkPromptArgument["required"];
83
+ }
84
+
85
+ export interface McpPrompt {
86
+ name: SdkPrompt["name"];
87
+ title?: SdkPrompt["title"];
88
+ description?: SdkPrompt["description"];
89
+ arguments?: SdkPrompt["arguments"];
90
+ _meta?: SdkPrompt["_meta"];
91
+ }
92
+
93
+ export interface UiResourceMeta {
94
+ csp?: UiResourceCsp;
95
+ permissions?: UiResourcePermissions;
96
+ domain?: string;
97
+ prefersBorder?: boolean;
98
+ }
99
+
100
+ export interface UiResourceContent {
101
+ uri: string;
102
+ html: string;
103
+ mimeType?: string;
104
+ meta: UiResourceMeta;
105
+ }
106
+
107
+ export interface UiProxyRequestBody<TParams> {
108
+ token: string;
109
+ params: TParams;
110
+ }
111
+
112
+ export interface UiProxyResult<T = Record<string, unknown>> {
113
+ ok: boolean;
114
+ result?: T;
115
+ error?: string;
116
+ }
117
+
118
+ export interface UiResourceCsp {
119
+ resourceDomains?: string[];
120
+ connectDomains?: string[];
121
+ frameDomains?: string[];
122
+ baseUriDomains?: string[];
123
+ }
124
+
125
+ export interface UiResourcePermissions {
126
+ camera?: {};
127
+ microphone?: {};
128
+ geolocation?: {};
129
+ clipboardWrite?: {};
130
+ }
131
+
132
+ export interface UiToolInfo {
133
+ id?: string | number;
134
+ tool: {
135
+ name: string;
136
+ description?: string;
137
+ inputSchema?: unknown;
138
+ };
139
+ }
140
+
141
+ export interface UiHostContext {
142
+ toolInfo?: UiToolInfo;
143
+ theme?: "light" | "dark";
144
+ styles?: Record<string, unknown>;
145
+ displayMode?: UiDisplayMode;
146
+ availableDisplayModes?: UiDisplayMode[];
147
+ containerDimensions?: {
148
+ width?: number;
149
+ maxWidth?: number;
150
+ height?: number;
151
+ maxHeight?: number;
152
+ };
153
+ [key: string]: unknown;
154
+ }
155
+
156
+ export type UiDisplayMode = "inline" | "fullscreen" | "pip";
157
+
158
+ // Re-export stream types from the shared lightweight module.
159
+ // This allows the example package to import stream schemas without pulling the full types.ts dependency graph.
160
+ export {
161
+ UI_STREAM_HOST_CONTEXT_KEY,
162
+ UI_STREAM_REQUEST_META_KEY,
163
+ UI_STREAM_RESULT_PATCH_METHOD,
164
+ SERVER_STREAM_RESULT_PATCH_METHOD,
165
+ UI_STREAM_STRUCTURED_CONTENT_KEY,
166
+ uiStreamModeSchema,
167
+ visualizationStreamPhaseSchema,
168
+ visualizationStreamFrameTypeSchema,
169
+ visualizationStreamStatusSchema,
170
+ uiStreamHostContextSchema,
171
+ visualizationStreamEnvelopeSchema,
172
+ uiStreamCallToolResultSchema,
173
+ uiStreamResultPatchNotificationSchema,
174
+ serverStreamResultPatchNotificationSchema,
175
+ getUiStreamHostContext,
176
+ getVisualizationStreamEnvelope,
177
+ type UiStreamMode,
178
+ type VisualizationStreamPhase,
179
+ type VisualizationStreamFrameType,
180
+ type VisualizationStreamStatus,
181
+ type UiStreamHostContext,
182
+ type VisualizationStreamEnvelope,
183
+ type UiStreamCallToolResult,
184
+ type UiStreamResultPatchNotification,
185
+ type ServerStreamResultPatchNotification,
186
+ type UiStreamSummary,
187
+ } from "./ui-stream-types.ts";
188
+
189
+ export interface UiMessageParams {
190
+ role?: string;
191
+ content?: unknown[];
192
+ type?: "prompt" | "notify" | "intent" | "message";
193
+ message?: string;
194
+ prompt?: string;
195
+ intent?: string;
196
+ params?: Record<string, unknown>;
197
+ [key: string]: unknown;
198
+ }
199
+
200
+ /**
201
+ * Extract prompt text from either legacy MCP UI message shapes or native AppBridge user messages.
202
+ */
203
+ export function extractUiPromptText(params: UiMessageParams): string | undefined {
204
+ if (params.type === "prompt" || params.prompt) {
205
+ const prompt = params.prompt ?? String(params.message ?? "");
206
+ return prompt || undefined;
207
+ }
208
+
209
+ if (params.role === "user" && Array.isArray(params.content)) {
210
+ const text = params.content
211
+ .map((block) => (block && typeof block === "object" && "text" in block ? String((block as { text?: unknown }).text ?? "") : ""))
212
+ .filter(Boolean)
213
+ .join("\n\n");
214
+ return text || undefined;
215
+ }
216
+
217
+ return undefined;
218
+ }
219
+
220
+ /**
221
+ * Structured UI handoff recovered from a canonical prompt envelope.
222
+ */
223
+ export interface UiPromptHandoff {
224
+ intent: string;
225
+ params: Record<string, unknown>;
226
+ raw: string;
227
+ }
228
+
229
+ /**
230
+ * Parse a canonical named UI handoff encoded as `intent\n{json}`.
231
+ */
232
+ export function parseUiPromptHandoff(prompt: string): UiPromptHandoff | undefined {
233
+ const newlineIndex = prompt.indexOf("\n");
234
+ if (newlineIndex <= 0) {
235
+ return undefined;
236
+ }
237
+
238
+ const intent = prompt.slice(0, newlineIndex).trim();
239
+ const payloadText = prompt.slice(newlineIndex + 1).trim();
240
+ if (!intent || !payloadText) {
241
+ return undefined;
242
+ }
243
+
244
+ if (!/^[A-Za-z][A-Za-z0-9_-]*$/.test(intent)) {
245
+ return undefined;
246
+ }
247
+
248
+ try {
249
+ const parsed = JSON.parse(payloadText);
250
+ if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
251
+ return undefined;
252
+ }
253
+ return {
254
+ intent,
255
+ params: parsed as Record<string, unknown>,
256
+ raw: prompt,
257
+ };
258
+ } catch {
259
+ return undefined;
260
+ }
261
+ }
262
+
263
+ /**
264
+ * Accumulated messages from a UI session.
265
+ * Collected during the session and available when it ends.
266
+ */
267
+ export interface UiSessionMessages {
268
+ prompts: string[];
269
+ notifications: string[];
270
+ intents: Array<{ intent: string; params?: Record<string, unknown> }>;
271
+ contexts: UiModelContextUpdate[];
272
+ }
273
+
274
+ export interface UiModelContextUpdate {
275
+ summary: string;
276
+ truncated: boolean;
277
+ payload?: Record<string, unknown>;
278
+ }
279
+
280
+ export interface UiModelContextParams {
281
+ content?: McpContentBlock[];
282
+ structuredContent?: Record<string, unknown>;
283
+ }
284
+
285
+ export function createUiModelContextUpdate(params: UiModelContextParams, maxChars = 12_000): UiModelContextUpdate | undefined {
286
+ const payload = Object.fromEntries(
287
+ Object.entries(params).filter(([, value]) => value !== undefined),
288
+ );
289
+ if (Object.keys(payload).length === 0) return undefined;
290
+
291
+ const serialized = JSON.stringify(payload);
292
+ if (serialized.length <= maxChars) {
293
+ return { payload, summary: serialized, truncated: false };
294
+ }
295
+
296
+ return {
297
+ summary: `${serialized.slice(0, Math.max(0, maxChars - 1))}…`,
298
+ truncated: true,
299
+ };
300
+ }
301
+
302
+ export interface UiOpenLinkResult {
303
+ isError?: boolean;
304
+ [key: string]: unknown;
305
+ }
306
+
307
+ export interface UiDisplayModeRequest {
308
+ mode?: UiDisplayMode;
309
+ }
310
+
311
+ export interface UiDisplayModeResult {
312
+ mode: UiDisplayMode;
313
+ [key: string]: unknown;
314
+ }
315
+
316
+ // Content types from MCP
317
+ export interface McpContent {
318
+ type: "text" | "image" | "audio" | "resource" | "resource_link";
319
+ text?: string;
320
+ data?: string;
321
+ mimeType?: string;
322
+ resource?: {
323
+ uri: string;
324
+ text?: string;
325
+ blob?: string;
326
+ };
327
+ uri?: string;
328
+ name?: string;
329
+ description?: string;
330
+ }
331
+
332
+ // Pi content block type
333
+ export type ContentBlock = TextContent | ImageContent;
334
+
335
+ // OAuth configuration (SDK handles auto-discovery and dynamic registration)
336
+ export interface OAuthConfig {
337
+ /** OAuth grant type (defaults to authorization_code) */
338
+ grantType?: "authorization_code" | "client_credentials";
339
+ /** Pre-registered client ID (optional, dynamic registration used if not provided) */
340
+ clientId?: string;
341
+ /** Client secret for confidential clients */
342
+ clientSecret?: string;
343
+ /** Requested OAuth scopes */
344
+ scope?: string;
345
+ /** Extra authorization URL parameters for provider-specific extensions. Flow-owned parameters cannot be overridden. */
346
+ authorizationParams?: Record<string, string>;
347
+ /** Exact authorization-code redirect URI for pre-registered clients */
348
+ redirectUri?: string;
349
+ /** Client display name for dynamic registration */
350
+ clientName?: string;
351
+ /** Client homepage URI for dynamic registration */
352
+ clientUri?: string;
353
+ /** Client logo URL for dynamic registration; shown on consent screens */
354
+ logoUri?: string;
355
+ /** Security-weakening escape hatch for known-misconfigured authorization servers. */
356
+ skipIssuerMetadataValidation?: boolean;
357
+ }
358
+
359
+ // Server configuration
360
+ export interface ServerEntry {
361
+ command?: string;
362
+ args?: string[];
363
+ /** Explicit rmcp-mux Unix-domain socket path. Mutually exclusive with command and url. */
364
+ socket?: string;
365
+ env?: Record<string, string>;
366
+ cwd?: string;
367
+ // HTTP fields
368
+ url?: string;
369
+ headers?: Record<string, string>;
370
+ /**
371
+ * Authentication type:
372
+ * - 'oauth' - Use OAuth 2.1 (auto-discovers endpoints, supports dynamic client registration)
373
+ * - 'bearer' - Use static Bearer token
374
+ * - false - Disable authentication
375
+ * If not specified and url is present, OAuth will be auto-detected unless custom headers are configured
376
+ */
377
+ auth?: "oauth" | "bearer" | false;
378
+ bearerToken?: string;
379
+ bearerTokenEnv?: string;
380
+ /**
381
+ * OAuth configuration (optional).
382
+ * If not provided, the SDK will attempt dynamic client registration.
383
+ * Set to false to explicitly disable OAuth for this server.
384
+ */
385
+ oauth?: OAuthConfig | false;
386
+ lifecycle?: "keep-alive" | "lazy" | "lazy-keep-alive" | "eager";
387
+ idleTimeout?: number; // minutes, overrides global setting
388
+ requestTimeoutMs?: number; // milliseconds, overrides global request timeout when > 0
389
+ // Resource handling
390
+ exposeResources?: boolean;
391
+ // Direct tool registration
392
+ directTools?: boolean | string[];
393
+ // Override settings.toolPrefix for this server.
394
+ toolPrefix?: ToolPrefix;
395
+ // Include/exclude specific MCP tools/resources by original or prefixed name
396
+ includeTools?: string[];
397
+ excludeTools?: string[];
398
+ /**
399
+ * Extra search keywords per tool, keyed by original name, prefixed name, or
400
+ * glob (same matching rules as includeTools/excludeTools). Keywords boost
401
+ * mcp({ search }) ranking only — they never appear in tool schemas,
402
+ * describe output, or the metadata cache.
403
+ */
404
+ searchKeywords?: Record<string, string[]>;
405
+ // Require interactive approval before calling matching MCP tools/resources.
406
+ approveTools?: boolean | string[];
407
+ // Debug
408
+ debug?: boolean; // Show server stderr (default: false)
409
+ /** Enable metadata-only JSONL protocol tracing for this server. */
410
+ trace?: boolean;
411
+ /** Force a specific HTTP MCP transport. Used by Agent Plugins, whose `type` declares the transport and forbids client fallback. */
412
+ httpTransport?: "streamable-http" | "sse";
413
+ /** Client-managed persistent data directory for Agent Plugin stdio servers. */
414
+ pluginDataDir?: string;
415
+ /** Treat env values as already resolved literals. Used for Agent Plugin env rules. */
416
+ literalEnv?: boolean;
417
+ /**
418
+ * MCP protocol era negotiation for this server. Defaults to `"legacy"`
419
+ * (byte-equivalent to pre-2026 behavior — no `versionNegotiation` is sent).
420
+ * `"auto"` offers the SDK's default 2026-07-28+ modern versions with
421
+ * legacy fallback; `"2026-07-28"` pins the connection to that revision
422
+ * with no fallback. `auto` and `2026-07-28` must be set explicitly.
423
+ */
424
+ protocolVersion?: "legacy" | "auto" | "2026-07-28";
425
+ // Keep configuration visible without allowing connections or execution.
426
+ disabled?: boolean;
427
+ }
428
+
429
+ /** Only the literal boolean `true` disables a server. */
430
+ export function isServerDisabled(definition: ServerEntry | undefined): boolean {
431
+ return definition?.disabled === true;
432
+ }
433
+
434
+ // Output guard tuning (settings.outputGuard object form)
435
+ export interface McpOutputGuardSettings {
436
+ /** Maximum inline MCP text output bytes before truncation/spill-to-disk. Defaults to 51200 (50 KiB). */
437
+ maxBytes?: number;
438
+ /** Maximum inline MCP text output lines before truncation/spill-to-disk. Defaults to 2000. */
439
+ maxLines?: number;
440
+ /** Maximum details.mcpResult JSON bytes kept raw; larger results are summarized and spilled to disk. Defaults to 16384 (16 KiB). */
441
+ detailsMaxBytes?: number;
442
+ }
443
+
444
+ // Settings
445
+ export type ToolPrefix = "server" | "none" | "short" | "mcp";
446
+ export type HostConfigDiscovery = "off" | "prompt" | "on";
447
+ export type McpFooterStatus = "full" | "compact" | "off";
448
+
449
+ export interface McpTraceSettings {
450
+ /** Enable tracing for all servers unless a server sets trace to false. */
451
+ enabled?: boolean;
452
+ /** JSONL destination; relative paths are resolved from the session cwd. */
453
+ file?: string;
454
+ /** Maximum per-session trace file size in bytes. */
455
+ maxBytes?: number;
456
+ /** Maximum events retained in the per-session trace file. */
457
+ maxEvents?: number;
458
+ }
459
+
460
+ export const MCP_TOOL_APPROVAL_REQUEST_EVENT = "pi-mcp-adapter:tool-approval-request" as const;
461
+
462
+ export type McpToolApprovalOrigin = "proxy" | "direct" | "script" | "resource" | "iframe";
463
+ export type McpToolApprovalDecision = "allow_once" | "allow_for_session" | "deny" | "abstain";
464
+ export type McpToolApprovalHandler = () => McpToolApprovalDecision | Promise<McpToolApprovalDecision>;
465
+
466
+ export interface McpToolApprovalRequest {
467
+ requestId: string;
468
+ serverName: string;
469
+ originalToolName: string;
470
+ prefixedToolName: string;
471
+ args: Record<string, unknown>;
472
+ origin: McpToolApprovalOrigin;
473
+ signal?: AbortSignal;
474
+ claim(handler: McpToolApprovalHandler): boolean;
475
+ }
476
+
477
+ export interface McpSettings {
478
+ toolPrefix?: ToolPrefix;
479
+ /** Show the plug prefix in MCP status and connection text (default: true). Set to false to disable it. */
480
+ showStatusIcon?: boolean;
481
+ /** Footer status verbosity: full details, compact connected/enabled count, or no footer status. Defaults to full. */
482
+ mcpFooterStatus?: McpFooterStatus;
483
+ /** Show successful startup connection notifications. Defaults to true. */
484
+ notifyOnStartupConnect?: boolean;
485
+ /** Discover detected host-specific MCP configs only when explicitly enabled. */
486
+ hostConfigDiscovery?: HostConfigDiscovery;
487
+ /** Agent Plugin package directories to load MCP servers from. */
488
+ agentPluginPaths?: string[];
489
+ idleTimeout?: number; // minutes, default 10, 0 to disable
490
+ requestTimeoutMs?: number; // milliseconds, overrides the SDK request timeout when > 0
491
+ directTools?: boolean;
492
+ /** Register the trusted MCP-only JavaScript scripting tool. Defaults to true; set false to hide it. */
493
+ scriptMode?: boolean;
494
+ /** Render MCP tool results as compact self-rendered rows by default, or as the legacy boxed row. */
495
+ toolResultRendering?: "compact" | "boxed";
496
+ /** Number of result text lines to show before expansion. Supports 1, 2, or 3. Defaults to 1 in compact mode and 3 in boxed mode. */
497
+ collapsedResultLines?: 1 | 2 | 3;
498
+ /** Default approval gate for matching tools/resources; per-server settings override it. */
499
+ approveTools?: boolean | string[];
500
+ disableProxyTool?: boolean;
501
+ /** Freeze direct-tool registration after the initial sync. Automatic metadata updates
502
+ * (reconnects, lazy-connect, tool-list-changed) won't rebuild the system prompt,
503
+ * preserving the prompt-cache prefix. The agent rediscovers explicitly via
504
+ * mcp({ connect: "server" }). Default: false. */
505
+ freezeDirectTools?: boolean;
506
+ autoAuth?: boolean;
507
+ sampling?: boolean;
508
+ samplingAutoApprove?: boolean;
509
+ elicitation?: boolean;
510
+ /**
511
+ * Guard oversized MCP tool/resource output before it is returned to the model.
512
+ * Defaults to true (50 KiB / 2,000 lines inline text, 16 KiB details.mcpResult).
513
+ * Set to false to restore raw MCP output behavior, or pass an object to tune
514
+ * the limits. Env kill switch: MCP_OUTPUT_GUARD=0.
515
+ */
516
+ outputGuard?: boolean | McpOutputGuardSettings;
517
+ /**
518
+ * Opt-in metadata-only MCP protocol tracing. Payloads, prompts, tool
519
+ * arguments/results, authorization data, and URLs are never persisted.
520
+ */
521
+ trace?: McpTraceSettings;
522
+ /**
523
+ * Message returned in tool results when a server needs (re-)authentication.
524
+ * "${server}" is substituted with the server name. Defaults to a TUI
525
+ * instruction when unset.
526
+ */
527
+ authRequiredMessage?: string;
528
+ /**
529
+ * Legacy OAuth tokens.json import directory.
530
+ * Relative paths are resolved from the project root (cwd).
531
+ * Takes precedence over the agent's mcp-oauth/ legacy import directory but
532
+ * can still be overridden by the MCP_OAUTH_DIR env variable.
533
+ *
534
+ * Persistent OAuth credentials are stored in the operating system credential
535
+ * store, not this directory. Existing plaintext tokens.json files found here
536
+ * are imported once and removed.
537
+ */
538
+ oauthDir?: string;
539
+ }
540
+
541
+ // Root config
542
+ export interface McpConfig {
543
+ mcpServers: Record<string, ServerEntry>;
544
+ imports?: ImportKind[];
545
+ settings?: McpSettings;
546
+ }
547
+
548
+ export interface McpAdapterOptions {
549
+ config?: McpConfig;
550
+ configPath?: string;
551
+ }
552
+
553
+ // Alias for clarity
554
+ export type ServerDefinition = ServerEntry;
555
+
556
+ export interface ToolMetadata {
557
+ name: string; // Prefixed tool name (e.g., "xcodebuild_list_sims")
558
+ originalName: string; // Original MCP tool name (e.g., "list_sims")
559
+ description: string;
560
+ resourceUri?: string; // For resource tools: the URI to read
561
+ uiResourceUri?: string; // For app-enabled tools: the UI resource URI
562
+ uiVisibility?: UiToolVisibility[];
563
+ inputSchema?: unknown; // JSON Schema for parameters (stored for describe/errors)
564
+ uiStreamMode?: UiStreamMode;
565
+ }
566
+
567
+ export interface PromptMetadata {
568
+ serverName: string;
569
+ originalName: string;
570
+ commandName: string;
571
+ title?: string;
572
+ description: string;
573
+ arguments: McpPromptArgument[];
574
+ }
575
+
576
+ export interface DirectToolSpec {
577
+ serverName: string;
578
+ originalName: string;
579
+ prefixedName: string;
580
+ description: string;
581
+ inputSchema?: unknown;
582
+ resourceUri?: string;
583
+ uiResourceUri?: string;
584
+ uiStreamMode?: UiStreamMode;
585
+ }
586
+
587
+ export interface ServerProvenance {
588
+ path: string;
589
+ kind: "user" | "project" | "import";
590
+ importKind?: string;
591
+ }
592
+
593
+ export interface McpAuthResult {
594
+ ok: boolean;
595
+ message?: string;
596
+ }
597
+
598
+ export interface CachedTool {
599
+ name: string;
600
+ description?: string;
601
+ inputSchema?: unknown;
602
+ uiResourceUri?: string;
603
+ uiVisibility?: UiToolVisibility[];
604
+ uiStreamMode?: "eager" | "stream-first";
605
+ }
606
+
607
+ export interface CachedResource {
608
+ uri: string;
609
+ name: string;
610
+ description?: string;
611
+ }
612
+
613
+ export interface CachedPrompt {
614
+ name: string;
615
+ title?: string;
616
+ description?: string;
617
+ arguments?: { name: string; description?: string; required?: boolean }[];
618
+ }
619
+
620
+ export interface ServerCacheEntry {
621
+ configHash: string;
622
+ tools: CachedTool[];
623
+ resources: CachedResource[];
624
+ prompts?: CachedPrompt[];
625
+ instructions?: string;
626
+ cachedAt: number;
627
+ }
628
+
629
+ export interface MetadataCache {
630
+ version: number;
631
+ servers: Record<string, ServerCacheEntry>;
632
+ }
633
+
634
+ export interface McpPanelCallbacks {
635
+ reconnect: (serverName: string) => Promise<boolean>;
636
+ canAuthenticate: (serverName: string) => boolean;
637
+ authenticate: (serverName: string) => Promise<McpAuthResult>;
638
+ getConnectionStatus: (serverName: string) => "connected" | "idle" | "failed" | "needs-auth" | "disabled";
639
+ getFailureMessage?: (serverName: string) => string | null;
640
+ refreshCacheAfterReconnect: (serverName: string) => ServerCacheEntry | null;
641
+ }
642
+
643
+ export interface McpPanelResult {
644
+ changes: Map<string, true | string[] | false>;
645
+ cancelled: boolean;
646
+ }
647
+
648
+ /**
649
+ * Get server prefix based on tool prefix mode.
650
+ */
651
+ function sanitizeServerPrefix(serverName: string, preserveProviderValid = true): string {
652
+ const validCharacters = preserveProviderValid ? /^[A-Za-z0-9_-]$/ : /^[A-Za-z0-9]$/;
653
+ return Array.from(serverName, char =>
654
+ validCharacters.test(char) ? char : `_${char.codePointAt(0)!.toString(16)}_`,
655
+ ).join("");
656
+ }
657
+
658
+ export function getServerPrefix(
659
+ serverName: string,
660
+ mode: ToolPrefix
661
+ ): string {
662
+ if (mode === "none") return "";
663
+ if (mode === "short") {
664
+ let short = sanitizeServerPrefix(serverName.replace(/-?mcp$/i, ""));
665
+ if (!short) short = "mcp";
666
+ return short;
667
+ }
668
+ if (mode === "mcp") return `mcp__${sanitizeServerPrefix(serverName)}`;
669
+ return sanitizeServerPrefix(serverName);
670
+ }
671
+
672
+ /**
673
+ * Format a tool name with server prefix.
674
+ */
675
+ export function formatToolName(
676
+ toolName: string,
677
+ serverName: string,
678
+ prefix: ToolPrefix
679
+ ): string {
680
+ const p = getServerPrefix(serverName, prefix);
681
+ const sanitized = toolName.replace(/\./g, "_");
682
+ return p ? `${p}_${sanitized}` : sanitized;
683
+ }
684
+
685
+ export function resolveToolPrefix(
686
+ definition?: Pick<ServerEntry, "toolPrefix">,
687
+ globalPrefix?: ToolPrefix,
688
+ ): ToolPrefix {
689
+ return definition?.toolPrefix ?? globalPrefix ?? "server";
690
+ }
691
+
692
+
693
+ /**
694
+ * Resolve a configured MCP server name from a prefixed tool name.
695
+ *
696
+ * When the proxy tool is addressed with a fully-qualified name such as
697
+ * `searxng_searxng_web_search`, downstream policy systems (for example a
698
+ * permission gate) need to recover the owning server so they can evaluate
699
+ * server-scoped rules against the bare server name. This performs the inverse
700
+ * of {@link getServerPrefix}: it finds the longest configured server prefix
701
+ * that the tool name starts with and returns that server's name.
702
+ *
703
+ * @param toolName - the tool name as passed to the proxy `mcp({ tool })` call.
704
+ * @param serverNames - the configured MCP server names (keys of `mcpServers`).
705
+ * @param prefix - the active tool-prefix mode.
706
+ * @returns the resolved server name, or `undefined` when no prefix matches or
707
+ * the prefix mode is `"none"`.
708
+ */
709
+ export function resolveServerFromToolName(
710
+ toolName: string,
711
+ serverNames: Iterable<string>,
712
+ prefix: ToolPrefix,
713
+ ): string | undefined {
714
+ if (prefix === "none") return undefined;
715
+ const candidates: { name: string; prefix: string }[] = [];
716
+ for (const name of serverNames) {
717
+ const p = getServerPrefix(name, prefix);
718
+ if (p && toolName.startsWith(p + "_")) candidates.push({ name, prefix: p });
719
+ }
720
+ if (candidates.length === 0) return undefined;
721
+ candidates.sort((a, b) => b.prefix.length - a.prefix.length);
722
+ const best = candidates[0];
723
+ // Fail safe: short mode can intentionally map names such as foo and foo-mcp
724
+ // to the same prefix. Return undefined so a downstream permission gate uses
725
+ // its existing wildcard path rather than enforcing a rule against the wrong server.
726
+ if (candidates.some((c) => c.prefix === best!.prefix && c.name !== best!.name)) {
727
+ return undefined;
728
+ }
729
+ return best?.name;
730
+ }
731
+
732
+ export function sanitizePromptName(name: string): string {
733
+ const cleaned = name.replace(/[^A-Za-z0-9_-]+/g, "_").replace(/^[_-]+|[_-]+$/g, "");
734
+ if (!cleaned) return "prompt";
735
+ return /^[0-9]/.test(cleaned) ? `_${cleaned}` : cleaned;
736
+ }
737
+
738
+ export function formatPromptCommandName(
739
+ promptName: string,
740
+ serverName: string,
741
+ prefix: ToolPrefix,
742
+ ): string {
743
+ const serverPart = getServerPrefix(serverName, prefix) || sanitizeServerPrefix(serverName) || "server";
744
+ return `mcp__${serverPart}__${sanitizePromptName(promptName)}`;
745
+ }
746
+
747
+ function getLegacyServerPrefix(serverName: string, mode: ToolPrefix): string {
748
+ if (mode === "none") return "";
749
+ if (mode === "short") return sanitizeServerPrefix(serverName.replace(/-?mcp$/i, ""), false) || "mcp";
750
+ if (mode === "mcp") return `mcp__${sanitizeServerPrefix(serverName, false)}`;
751
+ return sanitizeServerPrefix(serverName, false);
752
+ }
753
+
754
+ function formatLegacyToolName(toolName: string, serverName: string, prefix: ToolPrefix): string {
755
+ const serverPrefix = getLegacyServerPrefix(serverName, prefix);
756
+ const sanitizedToolName = toolName.replace(/[.-]/g, "_");
757
+ return serverPrefix ? `${serverPrefix}_${sanitizedToolName}` : sanitizedToolName;
758
+ }
759
+
760
+ export function getToolNameCandidates(toolName: string, serverName: string, prefix: ToolPrefix, includeLegacy = true): Set<string> {
761
+ const candidates = new Set<string>([
762
+ toolName,
763
+ formatToolName(toolName, serverName, prefix),
764
+ formatToolName(toolName, serverName, "server"),
765
+ formatToolName(toolName, serverName, "short"),
766
+ formatToolName(toolName, serverName, "mcp"),
767
+ ]);
768
+ if (includeLegacy) {
769
+ const legacyToolName = toolName.replace(/-/g, "_");
770
+ candidates.add(legacyToolName);
771
+ candidates.add(formatToolName(legacyToolName, serverName, prefix));
772
+ candidates.add(formatToolName(legacyToolName, serverName, "server"));
773
+ candidates.add(formatToolName(legacyToolName, serverName, "short"));
774
+ candidates.add(formatToolName(legacyToolName, serverName, "mcp"));
775
+ candidates.add(formatLegacyToolName(toolName, serverName, prefix));
776
+ candidates.add(formatLegacyToolName(toolName, serverName, "server"));
777
+ candidates.add(formatLegacyToolName(toolName, serverName, "short"));
778
+ candidates.add(formatLegacyToolName(toolName, serverName, "mcp"));
779
+ candidates.add(formatToolName(toolName, serverName, prefix).replace(/-/g, "_"));
780
+ candidates.add(formatToolName(toolName, serverName, "server").replace(/-/g, "_"));
781
+ candidates.add(formatToolName(toolName, serverName, "short").replace(/-/g, "_"));
782
+ candidates.add(formatToolName(toolName, serverName, "mcp").replace(/-/g, "_"));
783
+ }
784
+ return candidates;
785
+ }
786
+
787
+ function globToRegExp(pattern: string): RegExp {
788
+ const escaped = pattern.replace(/[.+^${}()|[\]\\]/g, "\\$&").replace(/\*/g, ".*").replace(/\?/g, ".");
789
+ return new RegExp(`^${escaped}$`);
790
+ }
791
+
792
+ export function matchesToolPattern(candidates: Set<string>, patterns?: unknown): boolean {
793
+ if (!Array.isArray(patterns) || patterns.length === 0) return false;
794
+
795
+ for (const pattern of patterns) {
796
+ if (typeof pattern !== "string") continue;
797
+ if (!pattern.includes("*") && !pattern.includes("?") && candidates.has(pattern)) {
798
+ return true;
799
+ }
800
+ if ((pattern.includes("*") || pattern.includes("?")) && [...candidates].some(candidate => globToRegExp(pattern).test(candidate))) {
801
+ return true;
802
+ }
803
+ }
804
+
805
+ return false;
806
+ }
807
+
808
+ function matchesToolSelector(
809
+ toolName: string,
810
+ serverName: string,
811
+ prefix: ToolPrefix,
812
+ patterns: unknown,
813
+ otherCurrentCandidates?: Set<string>,
814
+ ): boolean {
815
+ const currentCandidates = getToolNameCandidates(toolName, serverName, prefix, false);
816
+ if (matchesToolPattern(currentCandidates, patterns)) return true;
817
+ if (!otherCurrentCandidates) return matchesToolPattern(getToolNameCandidates(toolName, serverName, prefix), patterns);
818
+ const legacyCandidates = getToolNameCandidates(toolName, serverName, prefix);
819
+ for (const candidate of currentCandidates) legacyCandidates.delete(candidate);
820
+ if (!Array.isArray(patterns)) return false;
821
+ return patterns.some(pattern =>
822
+ typeof pattern === "string"
823
+ && !matchesToolPattern(otherCurrentCandidates, [pattern])
824
+ && matchesToolPattern(legacyCandidates, [pattern]),
825
+ );
826
+ }
827
+
828
+ export function isToolIncluded(
829
+ toolName: string,
830
+ serverName: string,
831
+ prefix: ToolPrefix,
832
+ includeTools?: unknown,
833
+ otherCurrentCandidates?: Set<string>,
834
+ ): boolean {
835
+ if (!Array.isArray(includeTools) || includeTools.length === 0) return true;
836
+ return matchesToolSelector(toolName, serverName, prefix, includeTools, otherCurrentCandidates);
837
+ }
838
+
839
+ export function isToolExcluded(
840
+ toolName: string,
841
+ serverName: string,
842
+ prefix: ToolPrefix,
843
+ excludeTools?: unknown,
844
+ otherCurrentCandidates?: Set<string>,
845
+ ): boolean {
846
+ return matchesToolSelector(toolName, serverName, prefix, excludeTools, otherCurrentCandidates);
847
+ }
848
+
849
+ export function isToolAllowed(
850
+ toolName: string,
851
+ serverName: string,
852
+ prefix: ToolPrefix,
853
+ includeTools?: unknown,
854
+ excludeTools?: unknown,
855
+ otherCurrentCandidates?: Set<string>,
856
+ ): boolean {
857
+ return isToolIncluded(toolName, serverName, prefix, includeTools, otherCurrentCandidates)
858
+ && !isToolExcluded(toolName, serverName, prefix, excludeTools, otherCurrentCandidates);
859
+ }