@ashx-j/lunr 0.1.0 → 0.1.2

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 (869) hide show
  1. package/dist/builtin-extensions/ashxj-spinners.d.ts +1 -1
  2. package/dist/builtin-extensions/ashxj-spinners.d.ts.map +1 -1
  3. package/dist/builtin-extensions/ashxj-spinners.js.map +1 -1
  4. package/dist/builtin-extensions/ashxj-thinking.d.ts +5 -5
  5. package/dist/builtin-extensions/ashxj-thinking.d.ts.map +1 -1
  6. package/dist/builtin-extensions/ashxj-thinking.js +3 -3
  7. package/dist/builtin-extensions/ashxj-thinking.js.map +1 -1
  8. package/dist/builtin-extensions/ashxj-tui.d.ts +2 -2
  9. package/dist/builtin-extensions/ashxj-tui.d.ts.map +1 -1
  10. package/dist/builtin-extensions/ashxj-tui.js +2 -2
  11. package/dist/builtin-extensions/ashxj-tui.js.map +1 -1
  12. package/dist/builtin-extensions/lunr-cron.d.ts +1 -1
  13. package/dist/builtin-extensions/lunr-cron.d.ts.map +1 -1
  14. package/dist/builtin-extensions/lunr-cron.js.map +1 -1
  15. package/dist/builtin-extensions/lunr-local-providers/index.d.ts +1 -1
  16. package/dist/builtin-extensions/lunr-local-providers/index.d.ts.map +1 -1
  17. package/dist/builtin-extensions/lunr-local-providers/index.js.map +1 -1
  18. package/dist/builtin-extensions/lunr-local-providers/local-servers.d.ts +1 -1
  19. package/dist/builtin-extensions/lunr-local-providers/local-servers.d.ts.map +1 -1
  20. package/dist/builtin-extensions/lunr-local-providers/local-servers.js.map +1 -1
  21. package/dist/builtin-extensions/lunr-plan-tools.d.ts +1 -1
  22. package/dist/builtin-extensions/lunr-plan-tools.d.ts.map +1 -1
  23. package/dist/builtin-extensions/lunr-plan-tools.js +1 -1
  24. package/dist/builtin-extensions/lunr-plan-tools.js.map +1 -1
  25. package/dist/builtin-extensions/lunr-skill-creator/index.d.ts +1 -1
  26. package/dist/builtin-extensions/lunr-skill-creator/index.d.ts.map +1 -1
  27. package/dist/builtin-extensions/lunr-skill-creator/index.js.map +1 -1
  28. package/dist/builtin-extensions/lunr-todos.d.ts +1 -1
  29. package/dist/builtin-extensions/lunr-todos.d.ts.map +1 -1
  30. package/dist/builtin-extensions/lunr-todos.js +1 -1
  31. package/dist/builtin-extensions/lunr-todos.js.map +1 -1
  32. package/dist/builtin-extensions/narumiruna-pi-goal/src/accounting.d.ts.map +1 -1
  33. package/dist/builtin-extensions/narumiruna-pi-goal/src/accounting.js.map +1 -1
  34. package/dist/builtin-extensions/narumiruna-pi-goal/src/goal.d.ts +1 -1
  35. package/dist/builtin-extensions/narumiruna-pi-goal/src/goal.d.ts.map +1 -1
  36. package/dist/builtin-extensions/narumiruna-pi-goal/src/goal.js.map +1 -1
  37. package/dist/builtin-extensions/narumiruna-pi-goal/src/runtime.d.ts +2 -2
  38. package/dist/builtin-extensions/narumiruna-pi-goal/src/runtime.d.ts.map +1 -1
  39. package/dist/builtin-extensions/narumiruna-pi-goal/src/runtime.js +1 -1
  40. package/dist/builtin-extensions/narumiruna-pi-goal/src/runtime.js.map +1 -1
  41. package/dist/builtin-extensions/pi-intercom/index.d.ts +1 -1
  42. package/dist/builtin-extensions/pi-intercom/index.d.ts.map +1 -1
  43. package/dist/builtin-extensions/pi-intercom/index.js +2 -2
  44. package/dist/builtin-extensions/pi-intercom/index.js.map +1 -1
  45. package/dist/builtin-extensions/pi-intercom/ui/compose.d.ts +2 -2
  46. package/dist/builtin-extensions/pi-intercom/ui/compose.d.ts.map +1 -1
  47. package/dist/builtin-extensions/pi-intercom/ui/compose.js +1 -1
  48. package/dist/builtin-extensions/pi-intercom/ui/compose.js.map +1 -1
  49. package/dist/builtin-extensions/pi-intercom/ui/inline-message.d.ts +2 -2
  50. package/dist/builtin-extensions/pi-intercom/ui/inline-message.d.ts.map +1 -1
  51. package/dist/builtin-extensions/pi-intercom/ui/inline-message.js +1 -1
  52. package/dist/builtin-extensions/pi-intercom/ui/inline-message.js.map +1 -1
  53. package/dist/builtin-extensions/pi-intercom/ui/session-list.d.ts +2 -2
  54. package/dist/builtin-extensions/pi-intercom/ui/session-list.d.ts.map +1 -1
  55. package/dist/builtin-extensions/pi-intercom/ui/session-list.js +1 -1
  56. package/dist/builtin-extensions/pi-intercom/ui/session-list.js.map +1 -1
  57. package/dist/builtin-extensions/pi-lsp-extension/bemol-extension/index.d.ts +1 -1
  58. package/dist/builtin-extensions/pi-lsp-extension/bemol-extension/index.d.ts.map +1 -1
  59. package/dist/builtin-extensions/pi-lsp-extension/bemol-extension/index.js.map +1 -1
  60. package/dist/builtin-extensions/pi-lsp-extension/src/index.d.ts +1 -1
  61. package/dist/builtin-extensions/pi-lsp-extension/src/index.d.ts.map +1 -1
  62. package/dist/builtin-extensions/pi-lsp-extension/src/index.js +1 -1
  63. package/dist/builtin-extensions/pi-lsp-extension/src/index.js.map +1 -1
  64. package/dist/builtin-extensions/pi-lsp-extension/src/tools/code-actions.d.ts +1 -1
  65. package/dist/builtin-extensions/pi-lsp-extension/src/tools/code-actions.d.ts.map +1 -1
  66. package/dist/builtin-extensions/pi-lsp-extension/src/tools/code-actions.js +1 -1
  67. package/dist/builtin-extensions/pi-lsp-extension/src/tools/code-actions.js.map +1 -1
  68. package/dist/builtin-extensions/pi-lsp-extension/src/tools/code-overview.d.ts +1 -1
  69. package/dist/builtin-extensions/pi-lsp-extension/src/tools/code-overview.d.ts.map +1 -1
  70. package/dist/builtin-extensions/pi-lsp-extension/src/tools/code-overview.js +1 -1
  71. package/dist/builtin-extensions/pi-lsp-extension/src/tools/code-overview.js.map +1 -1
  72. package/dist/builtin-extensions/pi-lsp-extension/src/tools/code-rewrite.d.ts +1 -1
  73. package/dist/builtin-extensions/pi-lsp-extension/src/tools/code-rewrite.d.ts.map +1 -1
  74. package/dist/builtin-extensions/pi-lsp-extension/src/tools/code-rewrite.js.map +1 -1
  75. package/dist/builtin-extensions/pi-lsp-extension/src/tools/code-search.d.ts +1 -1
  76. package/dist/builtin-extensions/pi-lsp-extension/src/tools/code-search.d.ts.map +1 -1
  77. package/dist/builtin-extensions/pi-lsp-extension/src/tools/code-search.js.map +1 -1
  78. package/dist/builtin-extensions/pi-lsp-extension/src/tools/completions.d.ts +1 -1
  79. package/dist/builtin-extensions/pi-lsp-extension/src/tools/completions.d.ts.map +1 -1
  80. package/dist/builtin-extensions/pi-lsp-extension/src/tools/completions.js +1 -1
  81. package/dist/builtin-extensions/pi-lsp-extension/src/tools/completions.js.map +1 -1
  82. package/dist/builtin-extensions/pi-lsp-extension/src/tools/definition.d.ts +1 -1
  83. package/dist/builtin-extensions/pi-lsp-extension/src/tools/definition.d.ts.map +1 -1
  84. package/dist/builtin-extensions/pi-lsp-extension/src/tools/definition.js +1 -1
  85. package/dist/builtin-extensions/pi-lsp-extension/src/tools/definition.js.map +1 -1
  86. package/dist/builtin-extensions/pi-lsp-extension/src/tools/diagnostics.d.ts +1 -1
  87. package/dist/builtin-extensions/pi-lsp-extension/src/tools/diagnostics.d.ts.map +1 -1
  88. package/dist/builtin-extensions/pi-lsp-extension/src/tools/diagnostics.js +1 -1
  89. package/dist/builtin-extensions/pi-lsp-extension/src/tools/diagnostics.js.map +1 -1
  90. package/dist/builtin-extensions/pi-lsp-extension/src/tools/hover.d.ts +1 -1
  91. package/dist/builtin-extensions/pi-lsp-extension/src/tools/hover.d.ts.map +1 -1
  92. package/dist/builtin-extensions/pi-lsp-extension/src/tools/hover.js +1 -1
  93. package/dist/builtin-extensions/pi-lsp-extension/src/tools/hover.js.map +1 -1
  94. package/dist/builtin-extensions/pi-lsp-extension/src/tools/references.d.ts +1 -1
  95. package/dist/builtin-extensions/pi-lsp-extension/src/tools/references.d.ts.map +1 -1
  96. package/dist/builtin-extensions/pi-lsp-extension/src/tools/references.js +1 -1
  97. package/dist/builtin-extensions/pi-lsp-extension/src/tools/references.js.map +1 -1
  98. package/dist/builtin-extensions/pi-lsp-extension/src/tools/rename.d.ts +1 -1
  99. package/dist/builtin-extensions/pi-lsp-extension/src/tools/rename.d.ts.map +1 -1
  100. package/dist/builtin-extensions/pi-lsp-extension/src/tools/rename.js +1 -1
  101. package/dist/builtin-extensions/pi-lsp-extension/src/tools/rename.js.map +1 -1
  102. package/dist/builtin-extensions/pi-lsp-extension/src/tools/symbols.d.ts +1 -1
  103. package/dist/builtin-extensions/pi-lsp-extension/src/tools/symbols.d.ts.map +1 -1
  104. package/dist/builtin-extensions/pi-lsp-extension/src/tools/symbols.js +1 -1
  105. package/dist/builtin-extensions/pi-lsp-extension/src/tools/symbols.js.map +1 -1
  106. package/dist/builtin-extensions/pi-mcp-adapter/commands.d.ts +1 -1
  107. package/dist/builtin-extensions/pi-mcp-adapter/commands.d.ts.map +1 -1
  108. package/dist/builtin-extensions/pi-mcp-adapter/commands.js.map +1 -1
  109. package/dist/builtin-extensions/pi-mcp-adapter/direct-tools.d.ts +1 -1
  110. package/dist/builtin-extensions/pi-mcp-adapter/direct-tools.d.ts.map +1 -1
  111. package/dist/builtin-extensions/pi-mcp-adapter/direct-tools.js.map +1 -1
  112. package/dist/builtin-extensions/pi-mcp-adapter/elicitation-handler.d.ts +1 -1
  113. package/dist/builtin-extensions/pi-mcp-adapter/elicitation-handler.d.ts.map +1 -1
  114. package/dist/builtin-extensions/pi-mcp-adapter/elicitation-handler.js.map +1 -1
  115. package/dist/builtin-extensions/pi-mcp-adapter/index.d.ts +1 -1
  116. package/dist/builtin-extensions/pi-mcp-adapter/index.d.ts.map +1 -1
  117. package/dist/builtin-extensions/pi-mcp-adapter/index.js.map +1 -1
  118. package/dist/builtin-extensions/pi-mcp-adapter/init.d.ts +1 -1
  119. package/dist/builtin-extensions/pi-mcp-adapter/init.d.ts.map +1 -1
  120. package/dist/builtin-extensions/pi-mcp-adapter/init.js.map +1 -1
  121. package/dist/builtin-extensions/pi-mcp-adapter/mcp-panel.d.ts.map +1 -1
  122. package/dist/builtin-extensions/pi-mcp-adapter/mcp-panel.js +1 -1
  123. package/dist/builtin-extensions/pi-mcp-adapter/mcp-panel.js.map +1 -1
  124. package/dist/builtin-extensions/pi-mcp-adapter/mcp-setup-panel.d.ts.map +1 -1
  125. package/dist/builtin-extensions/pi-mcp-adapter/mcp-setup-panel.js +1 -1
  126. package/dist/builtin-extensions/pi-mcp-adapter/mcp-setup-panel.js.map +1 -1
  127. package/dist/builtin-extensions/pi-mcp-adapter/panel-keys.d.ts.map +1 -1
  128. package/dist/builtin-extensions/pi-mcp-adapter/panel-keys.js +1 -1
  129. package/dist/builtin-extensions/pi-mcp-adapter/panel-keys.js.map +1 -1
  130. package/dist/builtin-extensions/pi-mcp-adapter/proxy-modes.d.ts +1 -1
  131. package/dist/builtin-extensions/pi-mcp-adapter/proxy-modes.d.ts.map +1 -1
  132. package/dist/builtin-extensions/pi-mcp-adapter/proxy-modes.js.map +1 -1
  133. package/dist/builtin-extensions/pi-mcp-adapter/sampling-handler.d.ts +2 -2
  134. package/dist/builtin-extensions/pi-mcp-adapter/sampling-handler.d.ts.map +1 -1
  135. package/dist/builtin-extensions/pi-mcp-adapter/sampling-handler.js +1 -1
  136. package/dist/builtin-extensions/pi-mcp-adapter/sampling-handler.js.map +1 -1
  137. package/dist/builtin-extensions/pi-mcp-adapter/state.d.ts +1 -1
  138. package/dist/builtin-extensions/pi-mcp-adapter/state.d.ts.map +1 -1
  139. package/dist/builtin-extensions/pi-mcp-adapter/state.js.map +1 -1
  140. package/dist/builtin-extensions/pi-mcp-adapter/tool-result-renderer.d.ts +2 -2
  141. package/dist/builtin-extensions/pi-mcp-adapter/tool-result-renderer.d.ts.map +1 -1
  142. package/dist/builtin-extensions/pi-mcp-adapter/tool-result-renderer.js +1 -1
  143. package/dist/builtin-extensions/pi-mcp-adapter/tool-result-renderer.js.map +1 -1
  144. package/dist/builtin-extensions/pi-mcp-adapter/types.d.ts +1 -1
  145. package/dist/builtin-extensions/pi-mcp-adapter/types.d.ts.map +1 -1
  146. package/dist/builtin-extensions/pi-mcp-adapter/types.js.map +1 -1
  147. package/dist/builtin-extensions/pi-mcp-adapter/utils.d.ts +1 -1
  148. package/dist/builtin-extensions/pi-mcp-adapter/utils.d.ts.map +1 -1
  149. package/dist/builtin-extensions/pi-mcp-adapter/utils.js.map +1 -1
  150. package/dist/builtin-extensions/pi-ollama-cloud/index.d.ts +1 -1
  151. package/dist/builtin-extensions/pi-ollama-cloud/index.d.ts.map +1 -1
  152. package/dist/builtin-extensions/pi-ollama-cloud/index.js.map +1 -1
  153. package/dist/builtin-extensions/pi-ollama-cloud/models.d.ts +1 -1
  154. package/dist/builtin-extensions/pi-ollama-cloud/models.d.ts.map +1 -1
  155. package/dist/builtin-extensions/pi-ollama-cloud/models.generated.d.ts +1 -1
  156. package/dist/builtin-extensions/pi-ollama-cloud/models.generated.d.ts.map +1 -1
  157. package/dist/builtin-extensions/pi-ollama-cloud/models.generated.js.map +1 -1
  158. package/dist/builtin-extensions/pi-ollama-cloud/models.js.map +1 -1
  159. package/dist/builtin-extensions/pi-ollama-cloud/thinking-levels.d.ts +1 -1
  160. package/dist/builtin-extensions/pi-ollama-cloud/thinking-levels.d.ts.map +1 -1
  161. package/dist/builtin-extensions/pi-ollama-cloud/thinking-levels.js.map +1 -1
  162. package/dist/builtin-extensions/pi-prompt-template-model/deterministic-renderer.d.ts +2 -2
  163. package/dist/builtin-extensions/pi-prompt-template-model/deterministic-renderer.d.ts.map +1 -1
  164. package/dist/builtin-extensions/pi-prompt-template-model/deterministic-renderer.js +1 -1
  165. package/dist/builtin-extensions/pi-prompt-template-model/deterministic-renderer.js.map +1 -1
  166. package/dist/builtin-extensions/pi-prompt-template-model/index.d.ts +1 -1
  167. package/dist/builtin-extensions/pi-prompt-template-model/index.d.ts.map +1 -1
  168. package/dist/builtin-extensions/pi-prompt-template-model/index.js.map +1 -1
  169. package/dist/builtin-extensions/pi-prompt-template-model/loop-utils.d.ts +1 -1
  170. package/dist/builtin-extensions/pi-prompt-template-model/loop-utils.d.ts.map +1 -1
  171. package/dist/builtin-extensions/pi-prompt-template-model/loop-utils.js.map +1 -1
  172. package/dist/builtin-extensions/pi-prompt-template-model/model-selection.d.ts +1 -1
  173. package/dist/builtin-extensions/pi-prompt-template-model/model-selection.d.ts.map +1 -1
  174. package/dist/builtin-extensions/pi-prompt-template-model/model-selection.js.map +1 -1
  175. package/dist/builtin-extensions/pi-prompt-template-model/notifications.d.ts +1 -1
  176. package/dist/builtin-extensions/pi-prompt-template-model/notifications.d.ts.map +1 -1
  177. package/dist/builtin-extensions/pi-prompt-template-model/notifications.js.map +1 -1
  178. package/dist/builtin-extensions/pi-prompt-template-model/prompt-execution.d.ts +1 -1
  179. package/dist/builtin-extensions/pi-prompt-template-model/prompt-execution.d.ts.map +1 -1
  180. package/dist/builtin-extensions/pi-prompt-template-model/prompt-execution.js.map +1 -1
  181. package/dist/builtin-extensions/pi-prompt-template-model/prompt-loader.d.ts +1 -1
  182. package/dist/builtin-extensions/pi-prompt-template-model/prompt-loader.d.ts.map +1 -1
  183. package/dist/builtin-extensions/pi-prompt-template-model/prompt-loader.js +1 -1
  184. package/dist/builtin-extensions/pi-prompt-template-model/prompt-loader.js.map +1 -1
  185. package/dist/builtin-extensions/pi-prompt-template-model/skill-loaded-renderer.d.ts +2 -2
  186. package/dist/builtin-extensions/pi-prompt-template-model/skill-loaded-renderer.d.ts.map +1 -1
  187. package/dist/builtin-extensions/pi-prompt-template-model/skill-loaded-renderer.js +1 -1
  188. package/dist/builtin-extensions/pi-prompt-template-model/skill-loaded-renderer.js.map +1 -1
  189. package/dist/builtin-extensions/pi-prompt-template-model/subagent-renderer.d.ts +2 -2
  190. package/dist/builtin-extensions/pi-prompt-template-model/subagent-renderer.d.ts.map +1 -1
  191. package/dist/builtin-extensions/pi-prompt-template-model/subagent-renderer.js +1 -1
  192. package/dist/builtin-extensions/pi-prompt-template-model/subagent-renderer.js.map +1 -1
  193. package/dist/builtin-extensions/pi-prompt-template-model/subagent-step.d.ts +3 -3
  194. package/dist/builtin-extensions/pi-prompt-template-model/subagent-step.d.ts.map +1 -1
  195. package/dist/builtin-extensions/pi-prompt-template-model/subagent-step.js +1 -1
  196. package/dist/builtin-extensions/pi-prompt-template-model/subagent-step.js.map +1 -1
  197. package/dist/builtin-extensions/pi-prompt-template-model/subagent-widget.d.ts +2 -2
  198. package/dist/builtin-extensions/pi-prompt-template-model/subagent-widget.d.ts.map +1 -1
  199. package/dist/builtin-extensions/pi-prompt-template-model/subagent-widget.js +1 -1
  200. package/dist/builtin-extensions/pi-prompt-template-model/subagent-widget.js.map +1 -1
  201. package/dist/builtin-extensions/pi-prompt-template-model/tool-manager.d.ts +1 -1
  202. package/dist/builtin-extensions/pi-prompt-template-model/tool-manager.d.ts.map +1 -1
  203. package/dist/builtin-extensions/pi-prompt-template-model/tool-manager.js +1 -1
  204. package/dist/builtin-extensions/pi-prompt-template-model/tool-manager.js.map +1 -1
  205. package/dist/builtin-extensions/pi-subagents/src/agents/agent-management.d.ts +2 -2
  206. package/dist/builtin-extensions/pi-subagents/src/agents/agent-management.d.ts.map +1 -1
  207. package/dist/builtin-extensions/pi-subagents/src/agents/agent-management.js.map +1 -1
  208. package/dist/builtin-extensions/pi-subagents/src/extension/control-notices.d.ts +1 -1
  209. package/dist/builtin-extensions/pi-subagents/src/extension/control-notices.d.ts.map +1 -1
  210. package/dist/builtin-extensions/pi-subagents/src/extension/control-notices.js.map +1 -1
  211. package/dist/builtin-extensions/pi-subagents/src/extension/fanout-child.d.ts +1 -1
  212. package/dist/builtin-extensions/pi-subagents/src/extension/fanout-child.d.ts.map +1 -1
  213. package/dist/builtin-extensions/pi-subagents/src/extension/fanout-child.js.map +1 -1
  214. package/dist/builtin-extensions/pi-subagents/src/extension/index.d.ts +1 -1
  215. package/dist/builtin-extensions/pi-subagents/src/extension/index.d.ts.map +1 -1
  216. package/dist/builtin-extensions/pi-subagents/src/extension/index.js +2 -2
  217. package/dist/builtin-extensions/pi-subagents/src/extension/index.js.map +1 -1
  218. package/dist/builtin-extensions/pi-subagents/src/extension/rpc.d.ts +2 -2
  219. package/dist/builtin-extensions/pi-subagents/src/extension/rpc.d.ts.map +1 -1
  220. package/dist/builtin-extensions/pi-subagents/src/extension/rpc.js.map +1 -1
  221. package/dist/builtin-extensions/pi-subagents/src/extension/steering-notices.d.ts +1 -1
  222. package/dist/builtin-extensions/pi-subagents/src/extension/steering-notices.d.ts.map +1 -1
  223. package/dist/builtin-extensions/pi-subagents/src/extension/steering-notices.js.map +1 -1
  224. package/dist/builtin-extensions/pi-subagents/src/intercom/native-supervisor-channel.d.ts +1 -1
  225. package/dist/builtin-extensions/pi-subagents/src/intercom/native-supervisor-channel.d.ts.map +1 -1
  226. package/dist/builtin-extensions/pi-subagents/src/intercom/native-supervisor-channel.js.map +1 -1
  227. package/dist/builtin-extensions/pi-subagents/src/profiles/profiles.d.ts +1 -1
  228. package/dist/builtin-extensions/pi-subagents/src/profiles/profiles.d.ts.map +1 -1
  229. package/dist/builtin-extensions/pi-subagents/src/profiles/profiles.js.map +1 -1
  230. package/dist/builtin-extensions/pi-subagents/src/runs/background/async-execution.d.ts +1 -1
  231. package/dist/builtin-extensions/pi-subagents/src/runs/background/async-execution.d.ts.map +1 -1
  232. package/dist/builtin-extensions/pi-subagents/src/runs/background/async-execution.js.map +1 -1
  233. package/dist/builtin-extensions/pi-subagents/src/runs/background/async-job-tracker.d.ts +1 -1
  234. package/dist/builtin-extensions/pi-subagents/src/runs/background/async-job-tracker.d.ts.map +1 -1
  235. package/dist/builtin-extensions/pi-subagents/src/runs/background/async-job-tracker.js.map +1 -1
  236. package/dist/builtin-extensions/pi-subagents/src/runs/background/auto-drain.d.ts +1 -1
  237. package/dist/builtin-extensions/pi-subagents/src/runs/background/auto-drain.d.ts.map +1 -1
  238. package/dist/builtin-extensions/pi-subagents/src/runs/background/auto-drain.js.map +1 -1
  239. package/dist/builtin-extensions/pi-subagents/src/runs/background/fleet-view.d.ts +1 -1
  240. package/dist/builtin-extensions/pi-subagents/src/runs/background/fleet-view.d.ts.map +1 -1
  241. package/dist/builtin-extensions/pi-subagents/src/runs/background/fleet-view.js.map +1 -1
  242. package/dist/builtin-extensions/pi-subagents/src/runs/background/notify.d.ts +1 -1
  243. package/dist/builtin-extensions/pi-subagents/src/runs/background/notify.d.ts.map +1 -1
  244. package/dist/builtin-extensions/pi-subagents/src/runs/background/notify.js.map +1 -1
  245. package/dist/builtin-extensions/pi-subagents/src/runs/background/run-status.d.ts +1 -1
  246. package/dist/builtin-extensions/pi-subagents/src/runs/background/run-status.d.ts.map +1 -1
  247. package/dist/builtin-extensions/pi-subagents/src/runs/background/run-status.js.map +1 -1
  248. package/dist/builtin-extensions/pi-subagents/src/runs/background/scheduled-runs.d.ts +2 -2
  249. package/dist/builtin-extensions/pi-subagents/src/runs/background/scheduled-runs.d.ts.map +1 -1
  250. package/dist/builtin-extensions/pi-subagents/src/runs/background/scheduled-runs.js.map +1 -1
  251. package/dist/builtin-extensions/pi-subagents/src/runs/background/subagent-runner.d.ts.map +1 -1
  252. package/dist/builtin-extensions/pi-subagents/src/runs/background/subagent-runner.js.map +1 -1
  253. package/dist/builtin-extensions/pi-subagents/src/runs/background/subagent-wait.d.ts +1 -1
  254. package/dist/builtin-extensions/pi-subagents/src/runs/background/subagent-wait.d.ts.map +1 -1
  255. package/dist/builtin-extensions/pi-subagents/src/runs/background/subagent-wait.js.map +1 -1
  256. package/dist/builtin-extensions/pi-subagents/src/runs/background/wait-tool.d.ts +1 -1
  257. package/dist/builtin-extensions/pi-subagents/src/runs/background/wait-tool.d.ts.map +1 -1
  258. package/dist/builtin-extensions/pi-subagents/src/runs/background/wait-tool.js.map +1 -1
  259. package/dist/builtin-extensions/pi-subagents/src/runs/foreground/async-steering-action.d.ts +1 -1
  260. package/dist/builtin-extensions/pi-subagents/src/runs/foreground/async-steering-action.d.ts.map +1 -1
  261. package/dist/builtin-extensions/pi-subagents/src/runs/foreground/async-steering-action.js.map +1 -1
  262. package/dist/builtin-extensions/pi-subagents/src/runs/foreground/chain-clarify.d.ts +2 -2
  263. package/dist/builtin-extensions/pi-subagents/src/runs/foreground/chain-clarify.d.ts.map +1 -1
  264. package/dist/builtin-extensions/pi-subagents/src/runs/foreground/chain-clarify.js +1 -1
  265. package/dist/builtin-extensions/pi-subagents/src/runs/foreground/chain-clarify.js.map +1 -1
  266. package/dist/builtin-extensions/pi-subagents/src/runs/foreground/chain-execution.d.ts +2 -2
  267. package/dist/builtin-extensions/pi-subagents/src/runs/foreground/chain-execution.d.ts.map +1 -1
  268. package/dist/builtin-extensions/pi-subagents/src/runs/foreground/chain-execution.js.map +1 -1
  269. package/dist/builtin-extensions/pi-subagents/src/runs/foreground/execution.d.ts.map +1 -1
  270. package/dist/builtin-extensions/pi-subagents/src/runs/foreground/execution.js.map +1 -1
  271. package/dist/builtin-extensions/pi-subagents/src/runs/foreground/subagent-executor.d.ts +2 -2
  272. package/dist/builtin-extensions/pi-subagents/src/runs/foreground/subagent-executor.d.ts.map +1 -1
  273. package/dist/builtin-extensions/pi-subagents/src/runs/foreground/subagent-executor.js.map +1 -1
  274. package/dist/builtin-extensions/pi-subagents/src/runs/shared/completion-guard.d.ts +1 -1
  275. package/dist/builtin-extensions/pi-subagents/src/runs/shared/completion-guard.d.ts.map +1 -1
  276. package/dist/builtin-extensions/pi-subagents/src/runs/shared/completion-guard.js.map +1 -1
  277. package/dist/builtin-extensions/pi-subagents/src/runs/shared/pi-spawn.d.ts +1 -1
  278. package/dist/builtin-extensions/pi-subagents/src/runs/shared/pi-spawn.d.ts.map +1 -1
  279. package/dist/builtin-extensions/pi-subagents/src/runs/shared/pi-spawn.js +1 -1
  280. package/dist/builtin-extensions/pi-subagents/src/runs/shared/pi-spawn.js.map +1 -1
  281. package/dist/builtin-extensions/pi-subagents/src/runs/shared/single-output.d.ts +1 -1
  282. package/dist/builtin-extensions/pi-subagents/src/runs/shared/single-output.d.ts.map +1 -1
  283. package/dist/builtin-extensions/pi-subagents/src/runs/shared/single-output.js.map +1 -1
  284. package/dist/builtin-extensions/pi-subagents/src/runs/shared/subagent-prompt-runtime.d.ts +1 -1
  285. package/dist/builtin-extensions/pi-subagents/src/runs/shared/subagent-prompt-runtime.d.ts.map +1 -1
  286. package/dist/builtin-extensions/pi-subagents/src/runs/shared/subagent-prompt-runtime.js.map +1 -1
  287. package/dist/builtin-extensions/pi-subagents/src/shared/child-transcript.d.ts +1 -1
  288. package/dist/builtin-extensions/pi-subagents/src/shared/child-transcript.d.ts.map +1 -1
  289. package/dist/builtin-extensions/pi-subagents/src/shared/child-transcript.js.map +1 -1
  290. package/dist/builtin-extensions/pi-subagents/src/shared/fork-context.d.ts.map +1 -1
  291. package/dist/builtin-extensions/pi-subagents/src/shared/fork-context.js +1 -1
  292. package/dist/builtin-extensions/pi-subagents/src/shared/fork-context.js.map +1 -1
  293. package/dist/builtin-extensions/pi-subagents/src/shared/types.d.ts +3 -3
  294. package/dist/builtin-extensions/pi-subagents/src/shared/types.d.ts.map +1 -1
  295. package/dist/builtin-extensions/pi-subagents/src/shared/types.js.map +1 -1
  296. package/dist/builtin-extensions/pi-subagents/src/shared/utils.d.ts +1 -1
  297. package/dist/builtin-extensions/pi-subagents/src/shared/utils.d.ts.map +1 -1
  298. package/dist/builtin-extensions/pi-subagents/src/shared/utils.js +1 -1
  299. package/dist/builtin-extensions/pi-subagents/src/shared/utils.js.map +1 -1
  300. package/dist/builtin-extensions/pi-subagents/src/slash/prompt-workflows.d.ts +1 -1
  301. package/dist/builtin-extensions/pi-subagents/src/slash/prompt-workflows.d.ts.map +1 -1
  302. package/dist/builtin-extensions/pi-subagents/src/slash/prompt-workflows.js.map +1 -1
  303. package/dist/builtin-extensions/pi-subagents/src/slash/slash-bridge.d.ts +2 -2
  304. package/dist/builtin-extensions/pi-subagents/src/slash/slash-bridge.d.ts.map +1 -1
  305. package/dist/builtin-extensions/pi-subagents/src/slash/slash-bridge.js.map +1 -1
  306. package/dist/builtin-extensions/pi-subagents/src/slash/slash-commands.d.ts +1 -1
  307. package/dist/builtin-extensions/pi-subagents/src/slash/slash-commands.d.ts.map +1 -1
  308. package/dist/builtin-extensions/pi-subagents/src/slash/slash-commands.js +2 -2
  309. package/dist/builtin-extensions/pi-subagents/src/slash/slash-commands.js.map +1 -1
  310. package/dist/builtin-extensions/pi-subagents/src/slash/slash-live-state.d.ts +1 -1
  311. package/dist/builtin-extensions/pi-subagents/src/slash/slash-live-state.d.ts.map +1 -1
  312. package/dist/builtin-extensions/pi-subagents/src/slash/slash-live-state.js.map +1 -1
  313. package/dist/builtin-extensions/pi-subagents/src/tui/fleet.d.ts +2 -2
  314. package/dist/builtin-extensions/pi-subagents/src/tui/fleet.d.ts.map +1 -1
  315. package/dist/builtin-extensions/pi-subagents/src/tui/fleet.js +1 -1
  316. package/dist/builtin-extensions/pi-subagents/src/tui/fleet.js.map +1 -1
  317. package/dist/builtin-extensions/pi-subagents/src/tui/render-helpers.d.ts +1 -1
  318. package/dist/builtin-extensions/pi-subagents/src/tui/render-helpers.d.ts.map +1 -1
  319. package/dist/builtin-extensions/pi-subagents/src/tui/render-helpers.js +1 -1
  320. package/dist/builtin-extensions/pi-subagents/src/tui/render-helpers.js.map +1 -1
  321. package/dist/builtin-extensions/pi-subagents/src/tui/render.d.ts +3 -3
  322. package/dist/builtin-extensions/pi-subagents/src/tui/render.d.ts.map +1 -1
  323. package/dist/builtin-extensions/pi-subagents/src/tui/render.js +2 -2
  324. package/dist/builtin-extensions/pi-subagents/src/tui/render.js.map +1 -1
  325. package/dist/builtin-extensions/pi-subagents/src/watchdog/model-selection.d.ts +1 -1
  326. package/dist/builtin-extensions/pi-subagents/src/watchdog/model-selection.d.ts.map +1 -1
  327. package/dist/builtin-extensions/pi-subagents/src/watchdog/model-selection.js.map +1 -1
  328. package/dist/builtin-extensions/pi-subagents/src/watchdog/register-child.d.ts +1 -1
  329. package/dist/builtin-extensions/pi-subagents/src/watchdog/register-child.d.ts.map +1 -1
  330. package/dist/builtin-extensions/pi-subagents/src/watchdog/register-child.js.map +1 -1
  331. package/dist/builtin-extensions/pi-subagents/src/watchdog/register-main.d.ts +1 -1
  332. package/dist/builtin-extensions/pi-subagents/src/watchdog/register-main.d.ts.map +1 -1
  333. package/dist/builtin-extensions/pi-subagents/src/watchdog/register-main.js +1 -1
  334. package/dist/builtin-extensions/pi-subagents/src/watchdog/register-main.js.map +1 -1
  335. package/dist/builtin-extensions/pi-subagents/src/watchdog/render.d.ts +1 -1
  336. package/dist/builtin-extensions/pi-subagents/src/watchdog/render.d.ts.map +1 -1
  337. package/dist/builtin-extensions/pi-subagents/src/watchdog/render.js +1 -1
  338. package/dist/builtin-extensions/pi-subagents/src/watchdog/render.js.map +1 -1
  339. package/dist/builtin-extensions/pi-subagents/src/watchdog/review.d.ts +3 -3
  340. package/dist/builtin-extensions/pi-subagents/src/watchdog/review.d.ts.map +1 -1
  341. package/dist/builtin-extensions/pi-subagents/src/watchdog/review.js +3 -3
  342. package/dist/builtin-extensions/pi-subagents/src/watchdog/review.js.map +1 -1
  343. package/dist/builtin-extensions/pi-subagents/src/watchdog/runtime.d.ts +1 -1
  344. package/dist/builtin-extensions/pi-subagents/src/watchdog/runtime.d.ts.map +1 -1
  345. package/dist/builtin-extensions/pi-subagents/src/watchdog/runtime.js.map +1 -1
  346. package/dist/builtin-extensions/pi-subagents/src/watchdog/tool-actions.d.ts +2 -2
  347. package/dist/builtin-extensions/pi-subagents/src/watchdog/tool-actions.d.ts.map +1 -1
  348. package/dist/builtin-extensions/pi-subagents/src/watchdog/tool-actions.js.map +1 -1
  349. package/dist/builtin-extensions/pi-tps.d.ts +1 -1
  350. package/dist/builtin-extensions/pi-tps.d.ts.map +1 -1
  351. package/dist/builtin-extensions/pi-tps.js.map +1 -1
  352. package/dist/builtin-extensions/pi-web-access/gemini-search.d.ts +1 -1
  353. package/dist/builtin-extensions/pi-web-access/gemini-search.d.ts.map +1 -1
  354. package/dist/builtin-extensions/pi-web-access/gemini-search.js.map +1 -1
  355. package/dist/builtin-extensions/pi-web-access/index.d.ts +1 -1
  356. package/dist/builtin-extensions/pi-web-access/index.d.ts.map +1 -1
  357. package/dist/builtin-extensions/pi-web-access/index.js +2 -2
  358. package/dist/builtin-extensions/pi-web-access/index.js.map +1 -1
  359. package/dist/builtin-extensions/pi-web-access/openai-search.d.ts +1 -1
  360. package/dist/builtin-extensions/pi-web-access/openai-search.d.ts.map +1 -1
  361. package/dist/builtin-extensions/pi-web-access/openai-search.js +1 -1
  362. package/dist/builtin-extensions/pi-web-access/openai-search.js.map +1 -1
  363. package/dist/builtin-extensions/pi-web-access/storage.d.ts +1 -1
  364. package/dist/builtin-extensions/pi-web-access/storage.d.ts.map +1 -1
  365. package/dist/builtin-extensions/pi-web-access/storage.js.map +1 -1
  366. package/dist/builtin-extensions/pi-web-access/summary-review.d.ts +1 -1
  367. package/dist/builtin-extensions/pi-web-access/summary-review.d.ts.map +1 -1
  368. package/dist/builtin-extensions/pi-web-access/summary-review.js +1 -1
  369. package/dist/builtin-extensions/pi-web-access/summary-review.js.map +1 -1
  370. package/dist/bun/cli.d.ts.map +1 -1
  371. package/dist/bun/cli.js +1 -1
  372. package/dist/bun/cli.js.map +1 -1
  373. package/dist/bun/register-bedrock.d.ts.map +1 -1
  374. package/dist/bun/register-bedrock.js +2 -2
  375. package/dist/bun/register-bedrock.js.map +1 -1
  376. package/dist/catalog/models.json +1 -1
  377. package/dist/catalog/providers/opencode-go.json +1 -1
  378. package/dist/catalog/providers/openrouter.json +1 -1
  379. package/dist/catalog/providers/qwen-token-plan-cn.json +1 -1
  380. package/dist/catalog/providers/qwen-token-plan.json +1 -1
  381. package/dist/catalog/publication.json +3 -3
  382. package/dist/cli/args.d.ts +1 -1
  383. package/dist/cli/args.d.ts.map +1 -1
  384. package/dist/cli/args.js.map +1 -1
  385. package/dist/cli/config-selector.d.ts.map +1 -1
  386. package/dist/cli/config-selector.js +1 -1
  387. package/dist/cli/config-selector.js.map +1 -1
  388. package/dist/cli/file-processor.d.ts +1 -1
  389. package/dist/cli/file-processor.d.ts.map +1 -1
  390. package/dist/cli/file-processor.js.map +1 -1
  391. package/dist/cli/initial-message.d.ts +1 -1
  392. package/dist/cli/initial-message.d.ts.map +1 -1
  393. package/dist/cli/initial-message.js.map +1 -1
  394. package/dist/cli/list-models.d.ts.map +1 -1
  395. package/dist/cli/list-models.js +1 -1
  396. package/dist/cli/list-models.js.map +1 -1
  397. package/dist/cli/session-picker.d.ts.map +1 -1
  398. package/dist/cli/session-picker.js +1 -1
  399. package/dist/cli/session-picker.js.map +1 -1
  400. package/dist/cli/startup-ui.d.ts +1 -1
  401. package/dist/cli/startup-ui.d.ts.map +1 -1
  402. package/dist/cli/startup-ui.js +2 -2
  403. package/dist/cli/startup-ui.js.map +1 -1
  404. package/dist/config.d.ts.map +1 -1
  405. package/dist/config.js +1 -1
  406. package/dist/config.js.map +1 -1
  407. package/dist/core/agent-session-services.d.ts +2 -2
  408. package/dist/core/agent-session-services.d.ts.map +1 -1
  409. package/dist/core/agent-session-services.js.map +1 -1
  410. package/dist/core/agent-session.d.ts +2 -2
  411. package/dist/core/agent-session.d.ts.map +1 -1
  412. package/dist/core/agent-session.js +1 -1
  413. package/dist/core/agent-session.js.map +1 -1
  414. package/dist/core/auth-storage.d.ts +1 -1
  415. package/dist/core/auth-storage.d.ts.map +1 -1
  416. package/dist/core/auth-storage.js.map +1 -1
  417. package/dist/core/cache-stats.d.ts +1 -1
  418. package/dist/core/cache-stats.d.ts.map +1 -1
  419. package/dist/core/cache-stats.js.map +1 -1
  420. package/dist/core/catalog-merge.d.ts +1 -1
  421. package/dist/core/catalog-merge.d.ts.map +1 -1
  422. package/dist/core/catalog-merge.js +7 -1
  423. package/dist/core/catalog-merge.js.map +1 -1
  424. package/dist/core/compaction/branch-summarization.d.ts +2 -2
  425. package/dist/core/compaction/branch-summarization.d.ts.map +1 -1
  426. package/dist/core/compaction/branch-summarization.js +1 -1
  427. package/dist/core/compaction/branch-summarization.js.map +1 -1
  428. package/dist/core/compaction/compaction.d.ts +2 -2
  429. package/dist/core/compaction/compaction.d.ts.map +1 -1
  430. package/dist/core/compaction/compaction.js +1 -1
  431. package/dist/core/compaction/compaction.js.map +1 -1
  432. package/dist/core/compaction/utils.d.ts +2 -2
  433. package/dist/core/compaction/utils.d.ts.map +1 -1
  434. package/dist/core/compaction/utils.js.map +1 -1
  435. package/dist/core/context-breakdown.d.ts +1 -1
  436. package/dist/core/context-breakdown.d.ts.map +1 -1
  437. package/dist/core/context-breakdown.js.map +1 -1
  438. package/dist/core/defaults.d.ts +1 -1
  439. package/dist/core/defaults.d.ts.map +1 -1
  440. package/dist/core/defaults.js.map +1 -1
  441. package/dist/core/export-html/index.d.ts +1 -1
  442. package/dist/core/export-html/index.d.ts.map +1 -1
  443. package/dist/core/export-html/index.js.map +1 -1
  444. package/dist/core/export-html/tool-renderer.d.ts.map +1 -1
  445. package/dist/core/export-html/tool-renderer.js.map +1 -1
  446. package/dist/core/extensions/loader.d.ts.map +1 -1
  447. package/dist/core/extensions/loader.js +25 -25
  448. package/dist/core/extensions/loader.js.map +1 -1
  449. package/dist/core/extensions/runner.d.ts +3 -3
  450. package/dist/core/extensions/runner.d.ts.map +1 -1
  451. package/dist/core/extensions/runner.js.map +1 -1
  452. package/dist/core/extensions/types.d.ts +5 -5
  453. package/dist/core/extensions/types.d.ts.map +1 -1
  454. package/dist/core/extensions/types.js.map +1 -1
  455. package/dist/core/extensions/wrapper.d.ts +1 -1
  456. package/dist/core/extensions/wrapper.d.ts.map +1 -1
  457. package/dist/core/extensions/wrapper.js.map +1 -1
  458. package/dist/core/grok-cli-auth.d.ts +32 -0
  459. package/dist/core/grok-cli-auth.d.ts.map +1 -0
  460. package/dist/core/grok-cli-auth.js +218 -0
  461. package/dist/core/grok-cli-auth.js.map +1 -0
  462. package/dist/core/keybindings.d.ts +2 -2
  463. package/dist/core/keybindings.d.ts.map +1 -1
  464. package/dist/core/keybindings.js +1 -1
  465. package/dist/core/keybindings.js.map +1 -1
  466. package/dist/core/live-catalog.d.ts +1 -1
  467. package/dist/core/live-catalog.d.ts.map +1 -1
  468. package/dist/core/live-catalog.js.map +1 -1
  469. package/dist/core/messages.d.ts +3 -3
  470. package/dist/core/messages.d.ts.map +1 -1
  471. package/dist/core/messages.js.map +1 -1
  472. package/dist/core/model-registry.d.ts +1 -1
  473. package/dist/core/model-registry.d.ts.map +1 -1
  474. package/dist/core/model-registry.js.map +1 -1
  475. package/dist/core/model-resolver.d.ts +2 -2
  476. package/dist/core/model-resolver.d.ts.map +1 -1
  477. package/dist/core/model-resolver.js +1 -1
  478. package/dist/core/model-resolver.js.map +1 -1
  479. package/dist/core/model-runtime.d.ts +10 -1
  480. package/dist/core/model-runtime.d.ts.map +1 -1
  481. package/dist/core/model-runtime.js +24 -5
  482. package/dist/core/model-runtime.js.map +1 -1
  483. package/dist/core/models-store.d.ts +1 -1
  484. package/dist/core/models-store.d.ts.map +1 -1
  485. package/dist/core/models-store.js.map +1 -1
  486. package/dist/core/official-catalog.d.ts +1 -1
  487. package/dist/core/official-catalog.d.ts.map +1 -1
  488. package/dist/core/official-catalog.js.map +1 -1
  489. package/dist/core/provider-attribution.d.ts +1 -1
  490. package/dist/core/provider-attribution.d.ts.map +1 -1
  491. package/dist/core/provider-attribution.js.map +1 -1
  492. package/dist/core/provider-composer.d.ts +1 -1
  493. package/dist/core/provider-composer.d.ts.map +1 -1
  494. package/dist/core/provider-composer.js +2 -2
  495. package/dist/core/provider-composer.js.map +1 -1
  496. package/dist/core/runtime-credentials.d.ts +1 -1
  497. package/dist/core/runtime-credentials.d.ts.map +1 -1
  498. package/dist/core/runtime-credentials.js.map +1 -1
  499. package/dist/core/sdk.d.ts +3 -3
  500. package/dist/core/sdk.d.ts.map +1 -1
  501. package/dist/core/sdk.js +3 -3
  502. package/dist/core/sdk.js.map +1 -1
  503. package/dist/core/session-manager.d.ts +2 -2
  504. package/dist/core/session-manager.d.ts.map +1 -1
  505. package/dist/core/session-manager.js +1 -1
  506. package/dist/core/session-manager.js.map +1 -1
  507. package/dist/core/settings-manager.d.ts +2 -2
  508. package/dist/core/settings-manager.d.ts.map +1 -1
  509. package/dist/core/settings-manager.js.map +1 -1
  510. package/dist/core/subscriptions.d.ts +1 -1
  511. package/dist/core/subscriptions.d.ts.map +1 -1
  512. package/dist/core/subscriptions.js.map +1 -1
  513. package/dist/core/tools/bash.d.ts +1 -1
  514. package/dist/core/tools/bash.d.ts.map +1 -1
  515. package/dist/core/tools/bash.js +1 -1
  516. package/dist/core/tools/bash.js.map +1 -1
  517. package/dist/core/tools/edit.d.ts +2 -2
  518. package/dist/core/tools/edit.d.ts.map +1 -1
  519. package/dist/core/tools/edit.js +1 -1
  520. package/dist/core/tools/edit.js.map +1 -1
  521. package/dist/core/tools/find.d.ts +1 -1
  522. package/dist/core/tools/find.d.ts.map +1 -1
  523. package/dist/core/tools/find.js +1 -1
  524. package/dist/core/tools/find.js.map +1 -1
  525. package/dist/core/tools/grep.d.ts +1 -1
  526. package/dist/core/tools/grep.d.ts.map +1 -1
  527. package/dist/core/tools/grep.js +1 -1
  528. package/dist/core/tools/grep.js.map +1 -1
  529. package/dist/core/tools/index.d.ts +1 -1
  530. package/dist/core/tools/index.d.ts.map +1 -1
  531. package/dist/core/tools/index.js.map +1 -1
  532. package/dist/core/tools/ls.d.ts +1 -1
  533. package/dist/core/tools/ls.d.ts.map +1 -1
  534. package/dist/core/tools/ls.js +1 -1
  535. package/dist/core/tools/ls.js.map +1 -1
  536. package/dist/core/tools/read.d.ts +1 -1
  537. package/dist/core/tools/read.d.ts.map +1 -1
  538. package/dist/core/tools/read.js +1 -1
  539. package/dist/core/tools/read.js.map +1 -1
  540. package/dist/core/tools/render-utils.d.ts +1 -1
  541. package/dist/core/tools/render-utils.d.ts.map +1 -1
  542. package/dist/core/tools/render-utils.js +1 -1
  543. package/dist/core/tools/render-utils.js.map +1 -1
  544. package/dist/core/tools/tool-definition-wrapper.d.ts +1 -1
  545. package/dist/core/tools/tool-definition-wrapper.d.ts.map +1 -1
  546. package/dist/core/tools/tool-definition-wrapper.js.map +1 -1
  547. package/dist/core/tools/write.d.ts +1 -1
  548. package/dist/core/tools/write.d.ts.map +1 -1
  549. package/dist/core/tools/write.js +1 -1
  550. package/dist/core/tools/write.js.map +1 -1
  551. package/dist/core/usage-adapters/openai-codex.d.ts.map +1 -1
  552. package/dist/core/usage-adapters/openai-codex.js.map +1 -1
  553. package/dist/core/usage-adapters/xai.d.ts.map +1 -1
  554. package/dist/core/usage-adapters/xai.js +4 -0
  555. package/dist/core/usage-adapters/xai.js.map +1 -1
  556. package/dist/core/usage-history.d.ts.map +1 -1
  557. package/dist/core/usage-history.js.map +1 -1
  558. package/dist/core/usage-service.d.ts +11 -1
  559. package/dist/core/usage-service.d.ts.map +1 -1
  560. package/dist/core/usage-service.js +45 -9
  561. package/dist/core/usage-service.js.map +1 -1
  562. package/dist/core/user-models.d.ts +1 -1
  563. package/dist/core/user-models.d.ts.map +1 -1
  564. package/dist/core/user-models.js.map +1 -1
  565. package/dist/gateway/agent-bridge.d.ts +3 -3
  566. package/dist/gateway/agent-bridge.d.ts.map +1 -1
  567. package/dist/gateway/agent-bridge.js.map +1 -1
  568. package/dist/gateway/commands.d.ts.map +1 -1
  569. package/dist/gateway/commands.js.map +1 -1
  570. package/dist/gateway/cron.d.ts.map +1 -1
  571. package/dist/gateway/cron.js.map +1 -1
  572. package/dist/main.d.ts.map +1 -1
  573. package/dist/main.js +1 -1
  574. package/dist/main.js.map +1 -1
  575. package/dist/modes/interactive/components/armin.d.ts +1 -1
  576. package/dist/modes/interactive/components/armin.d.ts.map +1 -1
  577. package/dist/modes/interactive/components/armin.js.map +1 -1
  578. package/dist/modes/interactive/components/assistant-message.d.ts +2 -2
  579. package/dist/modes/interactive/components/assistant-message.d.ts.map +1 -1
  580. package/dist/modes/interactive/components/assistant-message.js +1 -1
  581. package/dist/modes/interactive/components/assistant-message.js.map +1 -1
  582. package/dist/modes/interactive/components/bash-execution.d.ts +1 -1
  583. package/dist/modes/interactive/components/bash-execution.d.ts.map +1 -1
  584. package/dist/modes/interactive/components/bash-execution.js +1 -1
  585. package/dist/modes/interactive/components/bash-execution.js.map +1 -1
  586. package/dist/modes/interactive/components/boot-screen.d.ts +1 -1
  587. package/dist/modes/interactive/components/boot-screen.d.ts.map +1 -1
  588. package/dist/modes/interactive/components/boot-screen.js +1 -1
  589. package/dist/modes/interactive/components/boot-screen.js.map +1 -1
  590. package/dist/modes/interactive/components/bordered-loader.d.ts +1 -1
  591. package/dist/modes/interactive/components/bordered-loader.d.ts.map +1 -1
  592. package/dist/modes/interactive/components/bordered-loader.js +1 -1
  593. package/dist/modes/interactive/components/bordered-loader.js.map +1 -1
  594. package/dist/modes/interactive/components/branch-summary-message.d.ts +1 -1
  595. package/dist/modes/interactive/components/branch-summary-message.d.ts.map +1 -1
  596. package/dist/modes/interactive/components/branch-summary-message.js +1 -1
  597. package/dist/modes/interactive/components/branch-summary-message.js.map +1 -1
  598. package/dist/modes/interactive/components/compaction-summary-message.d.ts +1 -1
  599. package/dist/modes/interactive/components/compaction-summary-message.d.ts.map +1 -1
  600. package/dist/modes/interactive/components/compaction-summary-message.js +1 -1
  601. package/dist/modes/interactive/components/compaction-summary-message.js.map +1 -1
  602. package/dist/modes/interactive/components/config-selector.d.ts +1 -1
  603. package/dist/modes/interactive/components/config-selector.d.ts.map +1 -1
  604. package/dist/modes/interactive/components/config-selector.js +1 -1
  605. package/dist/modes/interactive/components/config-selector.js.map +1 -1
  606. package/dist/modes/interactive/components/countdown-timer.d.ts +1 -1
  607. package/dist/modes/interactive/components/countdown-timer.d.ts.map +1 -1
  608. package/dist/modes/interactive/components/countdown-timer.js.map +1 -1
  609. package/dist/modes/interactive/components/custom-editor.d.ts +1 -1
  610. package/dist/modes/interactive/components/custom-editor.d.ts.map +1 -1
  611. package/dist/modes/interactive/components/custom-editor.js +1 -1
  612. package/dist/modes/interactive/components/custom-editor.js.map +1 -1
  613. package/dist/modes/interactive/components/custom-entry.d.ts +1 -1
  614. package/dist/modes/interactive/components/custom-entry.d.ts.map +1 -1
  615. package/dist/modes/interactive/components/custom-entry.js +1 -1
  616. package/dist/modes/interactive/components/custom-entry.js.map +1 -1
  617. package/dist/modes/interactive/components/custom-message.d.ts +1 -1
  618. package/dist/modes/interactive/components/custom-message.d.ts.map +1 -1
  619. package/dist/modes/interactive/components/custom-message.js +1 -1
  620. package/dist/modes/interactive/components/custom-message.js.map +1 -1
  621. package/dist/modes/interactive/components/daxnuts.d.ts +1 -1
  622. package/dist/modes/interactive/components/daxnuts.d.ts.map +1 -1
  623. package/dist/modes/interactive/components/daxnuts.js.map +1 -1
  624. package/dist/modes/interactive/components/dynamic-border.d.ts +1 -1
  625. package/dist/modes/interactive/components/dynamic-border.d.ts.map +1 -1
  626. package/dist/modes/interactive/components/dynamic-border.js.map +1 -1
  627. package/dist/modes/interactive/components/earendil-announcement.d.ts +1 -1
  628. package/dist/modes/interactive/components/earendil-announcement.d.ts.map +1 -1
  629. package/dist/modes/interactive/components/earendil-announcement.js +1 -1
  630. package/dist/modes/interactive/components/earendil-announcement.js.map +1 -1
  631. package/dist/modes/interactive/components/extension-editor.d.ts +1 -1
  632. package/dist/modes/interactive/components/extension-editor.d.ts.map +1 -1
  633. package/dist/modes/interactive/components/extension-editor.js +1 -1
  634. package/dist/modes/interactive/components/extension-editor.js.map +1 -1
  635. package/dist/modes/interactive/components/extension-input.d.ts +1 -1
  636. package/dist/modes/interactive/components/extension-input.d.ts.map +1 -1
  637. package/dist/modes/interactive/components/extension-input.js +1 -1
  638. package/dist/modes/interactive/components/extension-input.js.map +1 -1
  639. package/dist/modes/interactive/components/extension-selector.d.ts +1 -1
  640. package/dist/modes/interactive/components/extension-selector.d.ts.map +1 -1
  641. package/dist/modes/interactive/components/extension-selector.js +1 -1
  642. package/dist/modes/interactive/components/extension-selector.js.map +1 -1
  643. package/dist/modes/interactive/components/first-time-setup.d.ts +1 -1
  644. package/dist/modes/interactive/components/first-time-setup.d.ts.map +1 -1
  645. package/dist/modes/interactive/components/first-time-setup.js +1 -1
  646. package/dist/modes/interactive/components/first-time-setup.js.map +1 -1
  647. package/dist/modes/interactive/components/footer.d.ts +1 -1
  648. package/dist/modes/interactive/components/footer.d.ts.map +1 -1
  649. package/dist/modes/interactive/components/footer.js +1 -1
  650. package/dist/modes/interactive/components/footer.js.map +1 -1
  651. package/dist/modes/interactive/components/injected-prompt-message.d.ts +1 -1
  652. package/dist/modes/interactive/components/injected-prompt-message.d.ts.map +1 -1
  653. package/dist/modes/interactive/components/injected-prompt-message.js +1 -1
  654. package/dist/modes/interactive/components/injected-prompt-message.js.map +1 -1
  655. package/dist/modes/interactive/components/keybinding-hints.d.ts +1 -1
  656. package/dist/modes/interactive/components/keybinding-hints.d.ts.map +1 -1
  657. package/dist/modes/interactive/components/keybinding-hints.js +1 -1
  658. package/dist/modes/interactive/components/keybinding-hints.js.map +1 -1
  659. package/dist/modes/interactive/components/login-dialog.d.ts +2 -2
  660. package/dist/modes/interactive/components/login-dialog.d.ts.map +1 -1
  661. package/dist/modes/interactive/components/login-dialog.js +1 -1
  662. package/dist/modes/interactive/components/login-dialog.js.map +1 -1
  663. package/dist/modes/interactive/components/model-selector.d.ts +2 -2
  664. package/dist/modes/interactive/components/model-selector.d.ts.map +1 -1
  665. package/dist/modes/interactive/components/model-selector.js +2 -2
  666. package/dist/modes/interactive/components/model-selector.js.map +1 -1
  667. package/dist/modes/interactive/components/oauth-selector.d.ts +2 -2
  668. package/dist/modes/interactive/components/oauth-selector.d.ts.map +1 -1
  669. package/dist/modes/interactive/components/oauth-selector.js +1 -1
  670. package/dist/modes/interactive/components/oauth-selector.js.map +1 -1
  671. package/dist/modes/interactive/components/processes-selector.d.ts +1 -1
  672. package/dist/modes/interactive/components/processes-selector.d.ts.map +1 -1
  673. package/dist/modes/interactive/components/processes-selector.js +1 -1
  674. package/dist/modes/interactive/components/processes-selector.js.map +1 -1
  675. package/dist/modes/interactive/components/scoped-models-selector.d.ts +2 -2
  676. package/dist/modes/interactive/components/scoped-models-selector.d.ts.map +1 -1
  677. package/dist/modes/interactive/components/scoped-models-selector.js +1 -1
  678. package/dist/modes/interactive/components/scoped-models-selector.js.map +1 -1
  679. package/dist/modes/interactive/components/session-selector-search.d.ts.map +1 -1
  680. package/dist/modes/interactive/components/session-selector-search.js +1 -1
  681. package/dist/modes/interactive/components/session-selector-search.js.map +1 -1
  682. package/dist/modes/interactive/components/session-selector.d.ts +1 -1
  683. package/dist/modes/interactive/components/session-selector.d.ts.map +1 -1
  684. package/dist/modes/interactive/components/session-selector.js +1 -1
  685. package/dist/modes/interactive/components/session-selector.js.map +1 -1
  686. package/dist/modes/interactive/components/settings-selector.d.ts +3 -3
  687. package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -1
  688. package/dist/modes/interactive/components/settings-selector.js +1 -1
  689. package/dist/modes/interactive/components/settings-selector.js.map +1 -1
  690. package/dist/modes/interactive/components/show-images-selector.d.ts +1 -1
  691. package/dist/modes/interactive/components/show-images-selector.d.ts.map +1 -1
  692. package/dist/modes/interactive/components/show-images-selector.js +1 -1
  693. package/dist/modes/interactive/components/show-images-selector.js.map +1 -1
  694. package/dist/modes/interactive/components/skill-invocation-message.d.ts +1 -1
  695. package/dist/modes/interactive/components/skill-invocation-message.d.ts.map +1 -1
  696. package/dist/modes/interactive/components/skill-invocation-message.js +1 -1
  697. package/dist/modes/interactive/components/skill-invocation-message.js.map +1 -1
  698. package/dist/modes/interactive/components/status-indicator.d.ts +1 -1
  699. package/dist/modes/interactive/components/status-indicator.d.ts.map +1 -1
  700. package/dist/modes/interactive/components/status-indicator.js +1 -1
  701. package/dist/modes/interactive/components/status-indicator.js.map +1 -1
  702. package/dist/modes/interactive/components/theme-selector.d.ts +1 -1
  703. package/dist/modes/interactive/components/theme-selector.d.ts.map +1 -1
  704. package/dist/modes/interactive/components/theme-selector.js +1 -1
  705. package/dist/modes/interactive/components/theme-selector.js.map +1 -1
  706. package/dist/modes/interactive/components/thinking-selector.d.ts +2 -2
  707. package/dist/modes/interactive/components/thinking-selector.d.ts.map +1 -1
  708. package/dist/modes/interactive/components/thinking-selector.js +1 -1
  709. package/dist/modes/interactive/components/thinking-selector.js.map +1 -1
  710. package/dist/modes/interactive/components/thinking-summary.d.ts +1 -1
  711. package/dist/modes/interactive/components/thinking-summary.d.ts.map +1 -1
  712. package/dist/modes/interactive/components/thinking-summary.js.map +1 -1
  713. package/dist/modes/interactive/components/thinking-tail.d.ts +1 -1
  714. package/dist/modes/interactive/components/thinking-tail.d.ts.map +1 -1
  715. package/dist/modes/interactive/components/thinking-tail.js +1 -1
  716. package/dist/modes/interactive/components/thinking-tail.js.map +1 -1
  717. package/dist/modes/interactive/components/tool-execution.d.ts +1 -1
  718. package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
  719. package/dist/modes/interactive/components/tool-execution.js +1 -1
  720. package/dist/modes/interactive/components/tool-execution.js.map +1 -1
  721. package/dist/modes/interactive/components/tree-selector.d.ts +1 -1
  722. package/dist/modes/interactive/components/tree-selector.d.ts.map +1 -1
  723. package/dist/modes/interactive/components/tree-selector.js +1 -1
  724. package/dist/modes/interactive/components/tree-selector.js.map +1 -1
  725. package/dist/modes/interactive/components/trust-selector.d.ts +1 -1
  726. package/dist/modes/interactive/components/trust-selector.d.ts.map +1 -1
  727. package/dist/modes/interactive/components/trust-selector.js +1 -1
  728. package/dist/modes/interactive/components/trust-selector.js.map +1 -1
  729. package/dist/modes/interactive/components/usage-view.d.ts.map +1 -1
  730. package/dist/modes/interactive/components/usage-view.js +1 -1
  731. package/dist/modes/interactive/components/usage-view.js.map +1 -1
  732. package/dist/modes/interactive/components/user-message-selector.d.ts +1 -1
  733. package/dist/modes/interactive/components/user-message-selector.d.ts.map +1 -1
  734. package/dist/modes/interactive/components/user-message-selector.js +1 -1
  735. package/dist/modes/interactive/components/user-message-selector.js.map +1 -1
  736. package/dist/modes/interactive/components/user-message.d.ts +1 -1
  737. package/dist/modes/interactive/components/user-message.d.ts.map +1 -1
  738. package/dist/modes/interactive/components/user-message.js +1 -1
  739. package/dist/modes/interactive/components/user-message.js.map +1 -1
  740. package/dist/modes/interactive/components/visual-truncate.d.ts.map +1 -1
  741. package/dist/modes/interactive/components/visual-truncate.js +1 -1
  742. package/dist/modes/interactive/components/visual-truncate.js.map +1 -1
  743. package/dist/modes/interactive/interactive-mode.d.ts +1 -1
  744. package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
  745. package/dist/modes/interactive/interactive-mode.js +29 -4
  746. package/dist/modes/interactive/interactive-mode.js.map +1 -1
  747. package/dist/modes/interactive/smooth-streaming.d.ts +1 -1
  748. package/dist/modes/interactive/smooth-streaming.d.ts.map +1 -1
  749. package/dist/modes/interactive/smooth-streaming.js.map +1 -1
  750. package/dist/modes/interactive/theme/theme-controller.d.ts +1 -1
  751. package/dist/modes/interactive/theme/theme-controller.d.ts.map +1 -1
  752. package/dist/modes/interactive/theme/theme-controller.js.map +1 -1
  753. package/dist/modes/interactive/theme/theme.d.ts +2 -2
  754. package/dist/modes/interactive/theme/theme.d.ts.map +1 -1
  755. package/dist/modes/interactive/theme/theme.js +2 -2
  756. package/dist/modes/interactive/theme/theme.js.map +1 -1
  757. package/dist/modes/print-mode.d.ts +1 -1
  758. package/dist/modes/print-mode.d.ts.map +1 -1
  759. package/dist/modes/print-mode.js.map +1 -1
  760. package/dist/modes/rpc/rpc-client.d.ts +2 -2
  761. package/dist/modes/rpc/rpc-client.d.ts.map +1 -1
  762. package/dist/modes/rpc/rpc-client.js.map +1 -1
  763. package/dist/modes/rpc/rpc-types.d.ts +2 -2
  764. package/dist/modes/rpc/rpc-types.d.ts.map +1 -1
  765. package/dist/modes/rpc/rpc-types.js.map +1 -1
  766. package/examples/extensions/auto-commit-on-exit.ts +1 -1
  767. package/examples/extensions/bash-spawn-hook.ts +2 -2
  768. package/examples/extensions/bookmark.ts +1 -1
  769. package/examples/extensions/border-status-editor.ts +3 -3
  770. package/examples/extensions/built-in-tool-renderer.ts +3 -3
  771. package/examples/extensions/claude-rules.ts +1 -1
  772. package/examples/extensions/commands.ts +1 -1
  773. package/examples/extensions/confirm-destructive.ts +1 -1
  774. package/examples/extensions/custom-compaction.ts +3 -3
  775. package/examples/extensions/custom-footer.ts +3 -3
  776. package/examples/extensions/custom-header.ts +2 -2
  777. package/examples/extensions/custom-provider-anthropic/index.ts +2 -2
  778. package/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
  779. package/examples/extensions/custom-provider-anthropic/package.json +1 -1
  780. package/examples/extensions/custom-provider-gitlab-duo/index.ts +2 -2
  781. package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
  782. package/examples/extensions/custom-provider-gitlab-duo/test.ts +1 -1
  783. package/examples/extensions/dirty-repo-guard.ts +1 -1
  784. package/examples/extensions/doom-overlay/doom-component.ts +2 -2
  785. package/examples/extensions/doom-overlay/doom-keys.ts +1 -1
  786. package/examples/extensions/doom-overlay/index.ts +1 -1
  787. package/examples/extensions/dynamic-resources/index.ts +1 -1
  788. package/examples/extensions/dynamic-tools.ts +1 -1
  789. package/examples/extensions/entry-renderer.ts +2 -2
  790. package/examples/extensions/event-bus.ts +1 -1
  791. package/examples/extensions/file-trigger.ts +1 -1
  792. package/examples/extensions/git-checkpoint.ts +1 -1
  793. package/examples/extensions/git-merge-and-resolve.ts +1 -1
  794. package/examples/extensions/github-issue-autocomplete.ts +2 -2
  795. package/examples/extensions/gondolin/index.ts +2 -2
  796. package/examples/extensions/gondolin/package-lock.json +2 -2
  797. package/examples/extensions/gondolin/package.json +1 -1
  798. package/examples/extensions/handoff.ts +4 -4
  799. package/examples/extensions/hello.ts +2 -2
  800. package/examples/extensions/hidden-thinking-label.ts +1 -1
  801. package/examples/extensions/inline-bash.ts +1 -1
  802. package/examples/extensions/input-transform-streaming.ts +1 -1
  803. package/examples/extensions/input-transform.ts +1 -1
  804. package/examples/extensions/interactive-shell.ts +1 -1
  805. package/examples/extensions/kimi-deferred-tools.ts +1 -1
  806. package/examples/extensions/mac-system-theme.ts +1 -1
  807. package/examples/extensions/message-renderer.ts +2 -2
  808. package/examples/extensions/minimal-mode.ts +3 -3
  809. package/examples/extensions/modal-editor.ts +2 -2
  810. package/examples/extensions/model-status.ts +1 -1
  811. package/examples/extensions/notify.ts +1 -1
  812. package/examples/extensions/overlay-qa-tests.ts +3 -3
  813. package/examples/extensions/overlay-test.ts +2 -2
  814. package/examples/extensions/permission-gate.ts +1 -1
  815. package/examples/extensions/pirate.ts +1 -1
  816. package/examples/extensions/plan-mode/index.ts +4 -4
  817. package/examples/extensions/preset.ts +4 -4
  818. package/examples/extensions/project-trust.ts +1 -1
  819. package/examples/extensions/prompt-customizer.ts +1 -1
  820. package/examples/extensions/protected-paths.ts +1 -1
  821. package/examples/extensions/provider-payload.ts +1 -1
  822. package/examples/extensions/qna.ts +3 -3
  823. package/examples/extensions/question.ts +2 -2
  824. package/examples/extensions/questionnaire.ts +2 -2
  825. package/examples/extensions/rainbow-editor.ts +1 -1
  826. package/examples/extensions/reload-runtime.ts +1 -1
  827. package/examples/extensions/rpc-demo.ts +1 -1
  828. package/examples/extensions/sandbox/index.ts +2 -2
  829. package/examples/extensions/send-user-message.ts +1 -1
  830. package/examples/extensions/session-name.ts +1 -1
  831. package/examples/extensions/shutdown-command.ts +1 -1
  832. package/examples/extensions/snake.ts +2 -2
  833. package/examples/extensions/space-invaders.ts +2 -2
  834. package/examples/extensions/ssh.ts +2 -2
  835. package/examples/extensions/status-line.ts +1 -1
  836. package/examples/extensions/structured-output.ts +2 -2
  837. package/examples/extensions/subagent/agents.ts +1 -1
  838. package/examples/extensions/subagent/index.ts +5 -5
  839. package/examples/extensions/summarize.ts +4 -4
  840. package/examples/extensions/system-prompt-header.ts +1 -1
  841. package/examples/extensions/tic-tac-toe.ts +3 -3
  842. package/examples/extensions/timed-confirm.ts +1 -1
  843. package/examples/extensions/titlebar-spinner.ts +1 -1
  844. package/examples/extensions/todo.ts +3 -3
  845. package/examples/extensions/tool-override.ts +2 -2
  846. package/examples/extensions/tools.ts +3 -3
  847. package/examples/extensions/trigger-compact.ts +1 -1
  848. package/examples/extensions/truncated-tool.ts +3 -3
  849. package/examples/extensions/widget-placement.ts +1 -1
  850. package/examples/extensions/with-deps/index.ts +1 -1
  851. package/examples/extensions/with-deps/package-lock.json +2 -2
  852. package/examples/extensions/with-deps/package.json +1 -1
  853. package/examples/extensions/working-indicator.ts +1 -1
  854. package/examples/extensions/working-message-test.ts +1 -1
  855. package/examples/rpc-extension-ui.ts +1 -1
  856. package/examples/sdk/01-minimal.ts +1 -1
  857. package/examples/sdk/02-custom-model.ts +2 -2
  858. package/examples/sdk/03-custom-prompt.ts +1 -1
  859. package/examples/sdk/04-skills.ts +1 -1
  860. package/examples/sdk/05-tools.ts +1 -1
  861. package/examples/sdk/06-extensions.ts +2 -2
  862. package/examples/sdk/07-context-files.ts +1 -1
  863. package/examples/sdk/08-prompt-templates.ts +1 -1
  864. package/examples/sdk/09-api-keys-and-oauth.ts +1 -1
  865. package/examples/sdk/10-settings.ts +1 -1
  866. package/examples/sdk/11-sessions.ts +1 -1
  867. package/examples/sdk/12-full-control.ts +2 -2
  868. package/examples/sdk/13-session-runtime.ts +1 -1
  869. package/package.json +4 -4
@@ -1 +1 @@
1
- {"version":3,"file":"proxy-modes.d.ts","sourceRoot":"","sources":["../../../src/builtin-extensions/pi-mcp-adapter/proxy-modes.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,QAAQ,EAAE,MAAM,iCAAiC,CAAC;AAGjF,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAYpD,KAAK,eAAe,GAAG,eAAe,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;AAmGhE,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,iBAAiB,GAAG,eAAe,CA4E3E;AAED,wBAAgB,aAAa,CAAC,KAAK,EAAE,iBAAiB,GAAG,eAAe,CAsDvE;AAED,wBAAsB,gBAAgB,CAAC,KAAK,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC,CAoC7G;AAED,wBAAsB,mBAAmB,CAAC,KAAK,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC,CA+B/H;AAED,wBAAgB,eAAe,CAAC,KAAK,EAAE,iBAAiB,EAAE,QAAQ,EAAE,MAAM,GAAG,eAAe,CAuC3F;AAED,wBAAgB,aAAa,CAC3B,KAAK,EAAE,iBAAiB,EACxB,KAAK,EAAE,MAAM,EACb,KAAK,CAAC,EAAE,OAAO,EACf,MAAM,CAAC,EAAE,MAAM,EACf,cAAc,CAAC,EAAE,OAAO,GACvB,eAAe,CAwGjB;AAED,wBAAgB,WAAW,CAAC,KAAK,EAAE,iBAAiB,EAAE,MAAM,EAAE,MAAM,GAAG,eAAe,CAqDrF;AAED,wBAAsB,cAAc,CAAC,KAAK,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,eAAe,CAAC,CAqDjI;AAED,wBAAsB,WAAW,CAC/B,KAAK,EAAE,iBAAiB,EACxB,QAAQ,EAAE,MAAM,EAChB,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC9B,cAAc,CAAC,EAAE,MAAM,EACvB,UAAU,CAAC,EAAE,MAAM,QAAQ,EAAE,EAC7B,MAAM,CAAC,EAAE,WAAW,GACnB,OAAO,CAAC,eAAe,CAAC,CAyW1B","sourcesContent":["// @ts-nocheck\nimport type { AgentToolResult, ToolInfo } from \"@earendil-works/pi-coding-agent\";\nimport { UrlElicitationRequiredError } from \"@modelcontextprotocol/sdk/types.js\";\nimport { checkSync } from \"recheck\";\nimport type { McpExtensionState } from \"./state.ts\";\nimport type { ToolMetadata, McpContent } from \"./types.ts\";\nimport { getServerPrefix, parseUiPromptHandoff } from \"./types.ts\";\nimport { lazyConnect, updateServerMetadata, updateMetadataCache, getFailureAgeSeconds, updateStatusBar } from \"./init.ts\";\nimport { abortable, throwIfAborted } from \"./abort.ts\";\nimport { buildToolMetadata, getToolNames, findToolByName, formatSchema } from \"./tool-metadata.ts\";\nimport { resolveMcpResultContent, transformMcpContent } from \"./tool-registrar.ts\";\nimport { guardMcpOutput, guardedMcpDetails, resolveMcpOutputGuardOptions } from \"./mcp-output-guard.ts\";\nimport { maybeStartUiSession, type UiSessionRuntime } from \"./ui-session.ts\";\nimport { formatAuthRequiredMessage, truncateAtWord } from \"./utils.ts\";\nimport { authenticate, completeAuthFromInput, startAuth, supportsOAuth } from \"./mcp-auth-flow.ts\";\n\ntype ProxyToolResult = AgentToolResult<Record<string, unknown>>;\n\nconst MAX_REGEX_SEARCH_QUERY_LENGTH = 256;\nconst REGEX_SAFETY_CHECK_PARAMS = {\n attackTimeout: 50,\n incubationTimeout: 50,\n timeout: 250,\n} as const;\n\ntype AutoAuthResult =\n | { status: \"skipped\" }\n | { status: \"success\" }\n | { status: \"failed\"; message: string };\n\nfunction getAuthRequiredMessage(\n state: McpExtensionState,\n serverName: string,\n defaultMessage = `Server \"${serverName}\" requires OAuth authentication. Run mcp({ action: \"auth-start\", server: \"${serverName}\" }) to get a browser URL, or /mcp-auth ${serverName} in an interactive local session.`,\n): string {\n return formatAuthRequiredMessage(state.config, serverName, defaultMessage);\n}\n\nfunction getAuthFailedMessage(state: McpExtensionState, serverName: string, message: string): string {\n const customGuidance = state.config.settings?.authRequiredMessage;\n if (customGuidance) {\n return `OAuth authentication failed for \"${serverName}\": ${message}. ${getAuthRequiredMessage(state, serverName)}`;\n }\n return `OAuth authentication failed for \"${serverName}\": ${message}. Run mcp({ action: \"auth-start\", server: \"${serverName}\" }) to get a browser URL, or /mcp-auth ${serverName} in an interactive local session.`;\n}\n\nfunction getRedirectPort(authorizationUrl: string): number | undefined {\n try {\n const redirectUri = new URL(authorizationUrl).searchParams.get(\"redirect_uri\");\n if (!redirectUri) return undefined;\n const port = Number.parseInt(new URL(redirectUri).port, 10);\n return Number.isInteger(port) ? port : undefined;\n } catch {\n return undefined;\n }\n}\n\nfunction formatManualAuthInstructions(serverName: string, authorizationUrl: string): string {\n const port = getRedirectPort(authorizationUrl);\n const portNote = port\n ? `\\nThe redirect URL will use local port ${port}. On a remote server it is expected for that localhost page to fail locally; copy the address bar URL anyway.`\n : \"\";\n\n return [\n `MCP OAuth required for \"${serverName}\".`,\n \"\",\n \"Open this URL in your local browser:\",\n \"\",\n authorizationUrl,\n \"\",\n \"After approving, copy the full redirected localhost URL from your browser address bar and send it back with:\",\n `mcp({ action: \"auth-complete\", server: \"${serverName}\", args: '{\"redirectUrl\":\"PASTE_REDIRECT_URL_HERE\"}' })`,\n \"\",\n \"You can also pass just the `code` query parameter as `args: '{\\\"code\\\":\\\"PASTE_CODE_HERE\\\"}'`.\",\n portNote.trimEnd(),\n ].filter(Boolean).join(\"\\n\");\n}\n\nasync function attemptAutoAuth(\n state: McpExtensionState,\n serverName: string,\n): Promise<AutoAuthResult> {\n if (state.config.settings?.autoAuth !== true) {\n return { status: \"skipped\" };\n }\n\n const definition = state.config.mcpServers[serverName];\n if (!definition || !supportsOAuth(definition) || !definition.url) {\n return { status: \"skipped\" };\n }\n\n const grantType = definition.oauth ? definition.oauth.grantType ?? \"authorization_code\" : \"authorization_code\";\n if (!state.ui && grantType !== \"client_credentials\") {\n return {\n status: \"failed\",\n message: getAuthRequiredMessage(\n state,\n serverName,\n `Server \"${serverName}\" requires OAuth authentication. Run mcp({ action: \"auth-start\", server: \"${serverName}\" }) to get a browser URL, or /mcp-auth ${serverName} in an interactive local session.`,\n ),\n };\n }\n\n try {\n await authenticate(serverName, definition.url, definition);\n return { status: \"success\" };\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error);\n return {\n status: \"failed\",\n message: getAuthFailedMessage(state, serverName, message),\n };\n }\n}\n\nexport function executeUiMessages(state: McpExtensionState): ProxyToolResult {\n const sessions = state.completedUiSessions;\n\n if (sessions.length === 0) {\n return {\n content: [{ type: \"text\" as const, text: \"No UI session messages available.\" }],\n details: { sessions: 0 },\n };\n }\n\n const output: string[] = [];\n output.push(`UI Session Messages (${sessions.length} session${sessions.length > 1 ? \"s\" : \"\"}):\\n`);\n\n const allPrompts: string[] = [];\n const allIntents = sessions.flatMap((session) => session.messages.intents);\n const parsedHandoffs: Array<{ intent: string; params: Record<string, unknown>; raw: string }> = [];\n\n for (const session of sessions) {\n const timestamp = session.completedAt.toLocaleTimeString();\n output.push(`\\n## ${session.serverName} / ${session.toolName} (${timestamp}, ${session.reason})`);\n\n const plainPrompts: string[] = [];\n for (const prompt of session.messages.prompts) {\n allPrompts.push(prompt);\n const handoff = parseUiPromptHandoff(prompt);\n if (handoff) {\n parsedHandoffs.push(handoff);\n } else {\n plainPrompts.push(prompt);\n }\n }\n\n if (plainPrompts.length > 0) {\n output.push(\"\\n### Prompts:\");\n for (const prompt of plainPrompts) {\n output.push(`- ${prompt}`);\n }\n }\n\n const intentsForSession = [\n ...session.messages.intents,\n ...session.messages.prompts\n .map((prompt) => parseUiPromptHandoff(prompt))\n .filter((handoff): handoff is NonNullable<typeof handoff> => !!handoff)\n .map((handoff) => ({ intent: handoff.intent, params: handoff.params })),\n ];\n\n if (intentsForSession.length > 0) {\n output.push(\"\\n### Intents:\");\n for (const intent of intentsForSession) {\n const params = intent.params ? ` (${JSON.stringify(intent.params)})` : \"\";\n output.push(`- ${intent.intent}${params}`);\n }\n }\n\n if (session.messages.notifications.length > 0) {\n output.push(\"\\n### Notifications:\");\n for (const notification of session.messages.notifications) {\n output.push(`- ${notification}`);\n }\n }\n }\n\n const count = sessions.length;\n state.completedUiSessions = [];\n\n return {\n content: [{ type: \"text\" as const, text: output.join(\"\\n\") }],\n details: {\n sessions: count,\n prompts: allPrompts,\n intents: [...allIntents, ...parsedHandoffs.map(({ intent, params }) => ({ intent, params }))],\n handoffs: parsedHandoffs,\n cleared: true,\n },\n };\n}\n\nexport function executeStatus(state: McpExtensionState): ProxyToolResult {\n const servers: Array<{ name: string; status: string; toolCount: number; failedAgo: number | null }> = [];\n\n for (const name of Object.keys(state.config.mcpServers)) {\n const connection = state.manager.getConnection(name);\n const metadata = state.toolMetadata.get(name);\n const toolCount = metadata?.length ?? 0;\n const failedAgo = getFailureAgeSeconds(state, name);\n let status = \"not connected\";\n if (connection?.status === \"connected\") {\n status = \"connected\";\n } else if (connection?.status === \"needs-auth\") {\n status = \"needs-auth\";\n } else if (failedAgo !== null) {\n status = \"failed\";\n } else if (metadata !== undefined) {\n status = \"cached\";\n }\n\n servers.push({ name, status, toolCount, failedAgo });\n }\n\n const totalTools = servers.reduce((sum, s) => sum + s.toolCount, 0);\n const connectedCount = servers.filter(s => s.status === \"connected\").length;\n\n let text = `MCP: ${connectedCount}/${servers.length} servers, ${totalTools} tools\\n\\n`;\n for (const server of servers) {\n if (server.status === \"connected\") {\n text += `✓ ${server.name} (${server.toolCount} tools)\\n`;\n continue;\n }\n if (server.status === \"needs-auth\") {\n text += `⚠ ${server.name} (needs auth)\\n`;\n continue;\n }\n if (server.status === \"cached\") {\n text += `○ ${server.name} (${server.toolCount} tools, cached)\\n`;\n continue;\n }\n if (server.status === \"failed\") {\n text += `✗ ${server.name} (failed ${server.failedAgo ?? 0}s ago)\\n`;\n continue;\n }\n text += `○ ${server.name} (not connected)\\n`;\n }\n\n if (servers.length > 0) {\n text += `\\nmcp({ server: \"name\" }) to list tools, mcp({ search: \"...\" }) to search`;\n }\n\n return {\n content: [{ type: \"text\" as const, text: text.trim() }],\n details: { mode: \"status\", servers, totalTools, connectedCount },\n };\n}\n\nexport async function executeAuthStart(state: McpExtensionState, serverName: string): Promise<ProxyToolResult> {\n const definition = state.config.mcpServers[serverName];\n if (!definition) {\n return {\n content: [{ type: \"text\" as const, text: `Server \"${serverName}\" not found. Use mcp({}) to see available servers.` }],\n details: { mode: \"auth-start\", error: \"not_found\", server: serverName },\n };\n }\n\n if (!definition.url || !supportsOAuth(definition)) {\n return {\n content: [{ type: \"text\" as const, text: `Server \"${serverName}\" is not configured for OAuth over HTTP.` }],\n details: { mode: \"auth-start\", error: \"oauth_not_supported\", server: serverName },\n };\n }\n\n try {\n const { authorizationUrl } = await startAuth(serverName, definition.url, definition);\n if (!authorizationUrl) {\n return {\n content: [{ type: \"text\" as const, text: `OAuth authentication successful for \"${serverName}\".` }],\n details: { mode: \"auth-start\", server: serverName, authenticated: true },\n };\n }\n\n return {\n content: [{ type: \"text\" as const, text: formatManualAuthInstructions(serverName, authorizationUrl) }],\n details: { mode: \"auth-start\", server: serverName, authorizationUrl },\n };\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error);\n return {\n content: [{ type: \"text\" as const, text: `Failed to start OAuth for \"${serverName}\": ${message}` }],\n details: { mode: \"auth-start\", error: \"auth_start_failed\", server: serverName, message },\n };\n }\n}\n\nexport async function executeAuthComplete(state: McpExtensionState, serverName: string, input: string): Promise<ProxyToolResult> {\n if (!state.config.mcpServers[serverName]) {\n return {\n content: [{ type: \"text\" as const, text: `Server \"${serverName}\" not found. Use mcp({}) to see available servers.` }],\n details: { mode: \"auth-complete\", error: \"not_found\", server: serverName },\n };\n }\n\n try {\n const status = await completeAuthFromInput(serverName, input);\n if (status !== \"authenticated\") {\n return {\n content: [{ type: \"text\" as const, text: `OAuth authentication did not complete for \"${serverName}\".` }],\n details: { mode: \"auth-complete\", error: \"not_authenticated\", server: serverName, status },\n };\n }\n\n await state.manager.close(serverName);\n state.failureTracker.delete(serverName);\n updateStatusBar(state);\n return {\n content: [{ type: \"text\" as const, text: `OAuth authentication successful for \"${serverName}\". Run mcp({ connect: \"${serverName}\" }) to connect with the new token.` }],\n details: { mode: \"auth-complete\", server: serverName, authenticated: true },\n };\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error);\n return {\n content: [{ type: \"text\" as const, text: `Failed to complete OAuth for \"${serverName}\": ${message}` }],\n details: { mode: \"auth-complete\", error: \"auth_complete_failed\", server: serverName, message },\n };\n }\n}\n\nexport function executeDescribe(state: McpExtensionState, toolName: string): ProxyToolResult {\n let serverName: string | undefined;\n let toolMeta: ToolMetadata | undefined;\n\n for (const [server, metadata] of state.toolMetadata.entries()) {\n const found = findToolByName(metadata, toolName);\n if (found) {\n serverName = server;\n toolMeta = found;\n break;\n }\n }\n\n if (!serverName || !toolMeta) {\n return {\n content: [{ type: \"text\" as const, text: `Tool \"${toolName}\" not found. Use mcp({ search: \"...\" }) to search.` }],\n details: { mode: \"describe\", error: \"tool_not_found\", requestedTool: toolName },\n };\n }\n\n let text = `${toolMeta.name}\\n`;\n text += `Server: ${serverName}\\n`;\n if (toolMeta.resourceUri) {\n text += `Type: Resource (reads from ${toolMeta.resourceUri})\\n`;\n }\n text += `\\n${toolMeta.description || \"(no description)\"}\\n`;\n\n if (toolMeta.inputSchema && !toolMeta.resourceUri) {\n text += `\\nParameters:\\n${formatSchema(toolMeta.inputSchema)}`;\n } else if (toolMeta.resourceUri) {\n text += `\\nNo parameters required (resource tool).`;\n } else {\n text += `\\nNo parameters defined.`;\n }\n\n return {\n content: [{ type: \"text\" as const, text: text.trim() }],\n details: { mode: \"describe\", tool: toolMeta, server: serverName },\n };\n}\n\nexport function executeSearch(\n state: McpExtensionState,\n query: string,\n regex?: boolean,\n server?: string,\n includeSchemas?: boolean,\n): ProxyToolResult {\n const showSchemas = includeSchemas !== false;\n\n const matches: Array<{ server: string; tool: ToolMetadata }> = [];\n\n let pattern: RegExp;\n try {\n if (regex) {\n if (query.length > MAX_REGEX_SEARCH_QUERY_LENGTH) {\n return {\n content: [{ type: \"text\" as const, text: `Regex query is too long; maximum length is ${MAX_REGEX_SEARCH_QUERY_LENGTH} characters.` }],\n details: { mode: \"search\", error: \"query_too_long\", query, maxLength: MAX_REGEX_SEARCH_QUERY_LENGTH },\n };\n }\n\n pattern = new RegExp(query, \"i\");\n let safety;\n try {\n safety = checkSync(query, \"i\", REGEX_SAFETY_CHECK_PARAMS);\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error);\n return {\n content: [{ type: \"text\" as const, text: \"Regex query rejected because safety analysis failed.\" }],\n details: { mode: \"search\", error: \"unsafe_pattern\", query, reason: message },\n };\n }\n if (safety.status !== \"safe\") {\n return {\n content: [{ type: \"text\" as const, text: `Regex query rejected as unsafe (${safety.status}).` }],\n details: { mode: \"search\", error: \"unsafe_pattern\", query, safetyStatus: safety.status },\n };\n }\n } else {\n const terms = query.trim().split(/\\s+/).filter(t => t.length > 0);\n if (terms.length === 0) {\n return {\n content: [{ type: \"text\" as const, text: \"Search query cannot be empty\" }],\n details: { mode: \"search\", error: \"empty_query\" },\n };\n }\n const escaped = terms.map(t => t.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\"));\n pattern = new RegExp(escaped.join(\"|\"), \"i\");\n }\n } catch {\n return {\n content: [{ type: \"text\" as const, text: `Invalid regex: ${query}` }],\n details: { mode: \"search\", error: \"invalid_pattern\", query },\n };\n }\n\n for (const [serverName, metadata] of state.toolMetadata.entries()) {\n if (server && serverName !== server) continue;\n for (const tool of metadata) {\n if (pattern.test(tool.name) || pattern.test(tool.description)) {\n matches.push({\n server: serverName,\n tool,\n });\n }\n }\n }\n\n const totalCount = matches.length;\n\n if (totalCount === 0) {\n const msg = server\n ? `No tools matching \"${query}\" in \"${server}\"`\n : `No tools matching \"${query}\"`;\n return {\n content: [{ type: \"text\" as const, text: msg }],\n details: { mode: \"search\", matches: [], count: 0, query },\n };\n }\n\n let text = `Found ${totalCount} tool${totalCount === 1 ? \"\" : \"s\"} matching \"${query}\":\\n\\n`;\n\n for (const match of matches) {\n if (showSchemas) {\n text += `${match.tool.name}\\n`;\n text += ` ${match.tool.description || \"(no description)\"}\\n`;\n if (match.tool.inputSchema && !match.tool.resourceUri) {\n text += `\\n Parameters:\\n${formatSchema(match.tool.inputSchema, \" \")}\\n`;\n } else if (match.tool.resourceUri) {\n text += ` No parameters (resource tool).\\n`;\n }\n text += \"\\n\";\n } else {\n text += `- ${match.tool.name}`;\n if (match.tool.description) {\n text += ` - ${truncateAtWord(match.tool.description, 50)}`;\n }\n text += \"\\n\";\n }\n }\n\n return {\n content: [{ type: \"text\" as const, text: text.trim() }],\n details: {\n mode: \"search\",\n matches: matches.map(m => ({ server: m.server, tool: m.tool.name })),\n count: totalCount,\n query,\n },\n };\n}\n\nexport function executeList(state: McpExtensionState, server: string): ProxyToolResult {\n if (!state.config.mcpServers[server]) {\n return {\n content: [{ type: \"text\" as const, text: `Server \"${server}\" not found. Use mcp({}) to see available servers.` }],\n details: { mode: \"list\", server, tools: [], count: 0, error: \"not_found\" },\n };\n }\n\n const metadata = state.toolMetadata.get(server);\n const toolNames = metadata?.map(m => m.name) ?? [];\n const connection = state.manager.getConnection(server);\n\n if (toolNames.length === 0) {\n if (connection?.status === \"connected\") {\n return {\n content: [{ type: \"text\" as const, text: `Server \"${server}\" has no tools.` }],\n details: { mode: \"list\", server, tools: [], count: 0 },\n };\n }\n if (metadata !== undefined) {\n return {\n content: [{ type: \"text\" as const, text: `Server \"${server}\" has no cached tools (not connected).` }],\n details: { mode: \"list\", server, tools: [], count: 0, cached: true },\n };\n }\n return {\n content: [{ type: \"text\" as const, text: `Server \"${server}\" is configured but not connected. Use mcp({ connect: \"${server}\" }) or /mcp reconnect ${server} to retry.` }],\n details: { mode: \"list\", server, tools: [], count: 0, error: \"not_connected\" },\n };\n }\n\n const cachedNote = connection?.status === \"connected\" ? \"\" : \" (not connected, cached)\";\n let text = `${server} (${toolNames.length} tools${cachedNote}):\\n\\n`;\n\n const descMap = new Map<string, string>();\n if (metadata) {\n for (const m of metadata) {\n descMap.set(m.name, m.description);\n }\n }\n\n for (const tool of toolNames) {\n const desc = descMap.get(tool) ?? \"\";\n const truncated = truncateAtWord(desc, 50);\n text += `- ${tool}`;\n if (truncated) text += ` - ${truncated}`;\n text += \"\\n\";\n }\n\n return {\n content: [{ type: \"text\" as const, text: text.trim() }],\n details: { mode: \"list\", server, tools: toolNames, count: toolNames.length },\n };\n}\n\nexport async function executeConnect(state: McpExtensionState, serverName: string, signal?: AbortSignal): Promise<ProxyToolResult> {\n throwIfAborted(signal);\n const definition = state.config.mcpServers[serverName];\n if (!definition) {\n return {\n content: [{ type: \"text\" as const, text: `Server \"${serverName}\" not found. Use mcp({}) to see available servers.` }],\n details: { mode: \"connect\", error: \"not_found\", server: serverName },\n };\n }\n\n try {\n if (state.ui) {\n state.ui.setStatus(\"mcp\", `MCP: connecting to ${serverName}...`);\n }\n let connection = await state.manager.connect(serverName, definition, signal);\n if (connection.status === \"needs-auth\") {\n const autoAuth = await attemptAutoAuth(state, serverName);\n if (autoAuth.status === \"failed\") {\n return {\n content: [{ type: \"text\" as const, text: autoAuth.message }],\n details: { mode: \"connect\", error: \"auth_required\", server: serverName, message: autoAuth.message },\n };\n }\n if (autoAuth.status === \"success\") {\n await state.manager.close(serverName);\n connection = await state.manager.connect(serverName, definition, signal);\n }\n if (connection.status === \"needs-auth\") {\n const message = getAuthRequiredMessage(state, serverName);\n return {\n content: [{ type: \"text\" as const, text: message }],\n details: { mode: \"connect\", error: \"auth_required\", server: serverName, message },\n };\n }\n }\n const prefix = state.config.settings?.toolPrefix ?? \"server\";\n const { metadata } = buildToolMetadata(connection.tools, connection.resources, definition, serverName, prefix);\n state.toolMetadata.set(serverName, metadata);\n updateMetadataCache(state, serverName);\n state.failureTracker.delete(serverName);\n updateStatusBar(state);\n return executeList(state, serverName);\n } catch (error) {\n if (!signal?.aborted) {\n state.failureTracker.set(serverName, Date.now());\n }\n updateStatusBar(state);\n const message = error instanceof Error ? error.message : String(error);\n return {\n content: [{ type: \"text\" as const, text: `Failed to connect to \"${serverName}\": ${message}` }],\n details: { mode: \"connect\", error: signal?.aborted ? \"aborted\" : \"connect_failed\", server: serverName, message },\n };\n }\n}\n\nexport async function executeCall(\n state: McpExtensionState,\n toolName: string,\n args?: Record<string, unknown>,\n serverOverride?: string,\n getPiTools?: () => ToolInfo[],\n signal?: AbortSignal,\n): Promise<ProxyToolResult> {\n throwIfAborted(signal);\n let serverName: string | undefined = serverOverride;\n let toolMeta: ToolMetadata | undefined;\n let autoAuthAttempted = false;\n const prefixMode = state.config.settings?.toolPrefix ?? \"server\";\n\n if (serverName && !state.config.mcpServers[serverName]) {\n return {\n content: [{ type: \"text\" as const, text: `Server \"${serverName}\" not found. Use mcp({}) to see available servers.` }],\n details: { mode: \"call\", error: \"server_not_found\", server: serverName },\n };\n }\n\n if (serverName) {\n toolMeta = findToolByName(state.toolMetadata.get(serverName), toolName);\n } else {\n for (const [server, metadata] of state.toolMetadata.entries()) {\n const found = findToolByName(metadata, toolName);\n if (found) {\n serverName = server;\n toolMeta = found;\n break;\n }\n }\n }\n\n if (serverName && !toolMeta) {\n const connected = await lazyConnect(state, serverName, signal);\n if (connected) {\n toolMeta = findToolByName(state.toolMetadata.get(serverName), toolName);\n } else {\n const needsAuthConnection = state.manager.getConnection(serverName);\n if (needsAuthConnection?.status === \"needs-auth\") {\n if (!autoAuthAttempted) {\n autoAuthAttempted = true;\n const autoAuth = await attemptAutoAuth(state, serverName);\n if (autoAuth.status === \"failed\") {\n return {\n content: [{ type: \"text\" as const, text: autoAuth.message }],\n details: { mode: \"call\", error: \"auth_required\", server: serverName, message: autoAuth.message },\n };\n }\n if (autoAuth.status === \"success\") {\n await state.manager.close(serverName);\n state.failureTracker.delete(serverName);\n const connectedAfterAuth = await lazyConnect(state, serverName, signal);\n if (connectedAfterAuth) {\n toolMeta = findToolByName(state.toolMetadata.get(serverName), toolName);\n if (!toolMeta) {\n return {\n content: [{ type: \"text\" as const, text: `Tool \"${toolName}\" not found on \"${serverName}\" after reconnect.` }],\n details: { mode: \"call\", error: \"tool_not_found_after_reconnect\", requestedTool: toolName },\n };\n }\n }\n }\n }\n\n if (!toolMeta && state.manager.getConnection(serverName)?.status === \"needs-auth\") {\n const message = getAuthRequiredMessage(state, serverName);\n return {\n content: [{ type: \"text\" as const, text: message }],\n details: { mode: \"call\", error: \"auth_required\", server: serverName, message },\n };\n }\n }\n\n if (!toolMeta) {\n const failedAgo = getFailureAgeSeconds(state, serverName);\n if (failedAgo !== null) {\n return {\n content: [{ type: \"text\" as const, text: `Server \"${serverName}\" not available (last failed ${failedAgo}s ago)` }],\n details: { mode: \"call\", error: \"server_backoff\", server: serverName },\n };\n }\n }\n }\n }\n\n let prefixMatchedServer: string | undefined;\n\n if (!serverName && !toolMeta && prefixMode !== \"none\") {\n const candidates = Object.keys(state.config.mcpServers)\n .map(name => ({ name, prefix: getServerPrefix(name, prefixMode) }))\n .filter(c => c.prefix && toolName.startsWith(c.prefix + \"_\"))\n .sort((a, b) => b.prefix.length - a.prefix.length);\n\n for (const { name: configuredServer } of candidates) {\n const existingConnection = state.manager.getConnection(configuredServer);\n const failedAgo = getFailureAgeSeconds(state, configuredServer);\n if (failedAgo !== null && existingConnection?.status !== \"needs-auth\") continue;\n\n let connected = await lazyConnect(state, configuredServer, signal);\n if (!connected && state.manager.getConnection(configuredServer)?.status === \"needs-auth\" && !autoAuthAttempted) {\n autoAuthAttempted = true;\n const autoAuth = await attemptAutoAuth(state, configuredServer);\n if (autoAuth.status === \"failed\") {\n return {\n content: [{ type: \"text\" as const, text: autoAuth.message }],\n details: { mode: \"call\", error: \"auth_required\", server: configuredServer, message: autoAuth.message },\n };\n }\n if (autoAuth.status === \"success\") {\n await state.manager.close(configuredServer);\n state.failureTracker.delete(configuredServer);\n connected = await lazyConnect(state, configuredServer, signal);\n }\n }\n\n if (!connected) continue;\n if (!prefixMatchedServer) prefixMatchedServer = configuredServer;\n toolMeta = findToolByName(state.toolMetadata.get(configuredServer), toolName);\n if (toolMeta) {\n serverName = configuredServer;\n break;\n }\n }\n }\n\n if (!serverName || !toolMeta) {\n const nativeTool = !serverOverride\n ? getPiTools?.().find((tool) => tool.name === toolName && tool.name !== \"mcp\")\n : undefined;\n if (nativeTool) {\n return {\n content: [{ type: \"text\" as const, text: `\"${toolName}\" is a native Pi tool. Call ${toolName} directly instead of using mcp({ tool: \"${toolName}\" }).` }],\n details: { mode: \"call\", error: \"native_tool\", requestedTool: toolName },\n };\n }\n\n const hintServer = serverName ?? prefixMatchedServer;\n const available = hintServer ? getToolNames(state, hintServer) : [];\n let msg = `Tool \"${toolName}\" not found.`;\n if (available.length > 0) {\n msg += ` Server \"${hintServer}\" has: ${available.join(\", \")}`;\n } else {\n msg += ` Use mcp({ search: \"...\" }) to search.`;\n }\n return {\n content: [{ type: \"text\" as const, text: msg }],\n details: { mode: \"call\", error: \"tool_not_found\", requestedTool: toolName, hintServer },\n };\n }\n\n let connection = state.manager.getConnection(serverName);\n if (connection?.status === \"needs-auth\") {\n if (!autoAuthAttempted) {\n autoAuthAttempted = true;\n const autoAuth = await attemptAutoAuth(state, serverName);\n if (autoAuth.status === \"failed\") {\n return {\n content: [{ type: \"text\" as const, text: autoAuth.message }],\n details: { mode: \"call\", error: \"auth_required\", server: serverName, message: autoAuth.message },\n };\n }\n if (autoAuth.status === \"success\") {\n await state.manager.close(serverName);\n state.failureTracker.delete(serverName);\n connection = state.manager.getConnection(serverName);\n }\n }\n\n if (connection?.status === \"needs-auth\") {\n const message = getAuthRequiredMessage(state, serverName);\n return {\n content: [{ type: \"text\" as const, text: message }],\n details: { mode: \"call\", error: \"auth_required\", server: serverName, message },\n };\n }\n }\n if (!connection || connection.status !== \"connected\") {\n const failedAgo = getFailureAgeSeconds(state, serverName);\n if (failedAgo !== null) {\n return {\n content: [{ type: \"text\" as const, text: `Server \"${serverName}\" not available (last failed ${failedAgo}s ago)` }],\n details: { mode: \"call\", error: \"server_backoff\", server: serverName },\n };\n }\n\n const definition = state.config.mcpServers[serverName];\n if (!definition) {\n return {\n content: [{ type: \"text\" as const, text: `Server \"${serverName}\" not connected` }],\n details: { mode: \"call\", error: \"server_not_connected\", server: serverName },\n };\n }\n\n try {\n if (state.ui) {\n state.ui.setStatus(\"mcp\", `MCP: connecting to ${serverName}...`);\n }\n connection = await state.manager.connect(serverName, definition, signal);\n if (connection.status === \"needs-auth\") {\n if (!autoAuthAttempted) {\n autoAuthAttempted = true;\n const autoAuth = await attemptAutoAuth(state, serverName);\n if (autoAuth.status === \"failed\") {\n return {\n content: [{ type: \"text\" as const, text: autoAuth.message }],\n details: { mode: \"call\", error: \"auth_required\", server: serverName, message: autoAuth.message },\n };\n }\n if (autoAuth.status === \"success\") {\n await state.manager.close(serverName);\n connection = await state.manager.connect(serverName, definition, signal);\n }\n }\n\n if (connection.status === \"needs-auth\") {\n const message = getAuthRequiredMessage(state, serverName);\n return {\n content: [{ type: \"text\" as const, text: message }],\n details: { mode: \"call\", error: \"auth_required\", server: serverName, message },\n };\n }\n }\n state.failureTracker.delete(serverName);\n updateServerMetadata(state, serverName);\n updateMetadataCache(state, serverName);\n updateStatusBar(state);\n toolMeta = findToolByName(state.toolMetadata.get(serverName), toolName);\n if (!toolMeta) {\n const available = getToolNames(state, serverName);\n const hint = available.length > 0\n ? `Available tools on \"${serverName}\": ${available.join(\", \")}`\n : `Server \"${serverName}\" has no tools.`;\n return {\n content: [{ type: \"text\" as const, text: `Tool \"${toolName}\" not found on \"${serverName}\" after reconnect. ${hint}` }],\n details: { mode: \"call\", error: \"tool_not_found_after_reconnect\", requestedTool: toolName },\n };\n }\n } catch (error) {\n if (!signal?.aborted) {\n state.failureTracker.set(serverName, Date.now());\n }\n updateStatusBar(state);\n const message = error instanceof Error ? error.message : String(error);\n return {\n content: [{ type: \"text\" as const, text: `Failed to connect to \"${serverName}\": ${message}` }],\n details: { mode: \"call\", error: signal?.aborted ? \"aborted\" : \"connect_failed\", message },\n };\n }\n }\n\n let uiSession: UiSessionRuntime | null = null;\n const requestOptions = state.manager.getRequestOptions?.(serverName, signal) ?? (signal ? { signal } : undefined);\n\n const outputGuardOptions = resolveMcpOutputGuardOptions(state.config.settings);\n\n try {\n state.manager.touch(serverName);\n state.manager.incrementInFlight(serverName);\n\n if (toolMeta.resourceUri) {\n const result = await connection.client.readResource({ uri: toolMeta.resourceUri }, requestOptions);\n const content = (result.contents ?? []).map(c => ({\n type: \"text\" as const,\n text: \"text\" in c ? c.text : (\"blob\" in c ? `[Binary data: ${(c as { mimeType?: string }).mimeType ?? \"unknown\"}]` : JSON.stringify(c)),\n }));\n const guarded = await guardMcpOutput(content.length > 0 ? content : [{ type: \"text\" as const, text: \"(empty resource)\" }], outputGuardOptions);\n return {\n content: guarded.content,\n details: { mode: \"call\", resourceUri: toolMeta.resourceUri, server: serverName, ...guardedMcpDetails(guarded) },\n };\n }\n\n uiSession = toolMeta.uiResourceUri\n ? await maybeStartUiSession(state, {\n serverName,\n toolName: toolMeta.originalName,\n toolArgs: args ?? {},\n uiResourceUri: toolMeta.uiResourceUri,\n streamMode: toolMeta.uiStreamMode,\n })\n : null;\n\n const resultPromise = connection.client.callTool({\n name: toolMeta.originalName,\n arguments: args ?? {},\n _meta: uiSession?.requestMeta,\n }, undefined, requestOptions);\n\n if (toolMeta.uiResourceUri) {\n const result = await abortable(resultPromise, signal);\n uiSession?.sendToolResult(result as unknown as import(\"@modelcontextprotocol/sdk/types.js\").CallToolResult);\n\n if (result.isError) {\n const mcpContent = (result.content ?? []) as McpContent[];\n const content = transformMcpContent(mcpContent);\n const outputContent = content.length > 0 ? content : [{ type: \"text\" as const, text: \"(empty result)\" }];\n const schemaText = toolMeta.inputSchema ? `\\n\\nExpected parameters:\\n${formatSchema(toolMeta.inputSchema)}` : \"\";\n const guarded = await guardMcpOutput(outputContent, { ...outputGuardOptions, prefix: \"Error: \", suffix: schemaText, emptyTextFallback: \"Tool execution failed\", rawMcpResult: result });\n return {\n content: guarded.content,\n details: { mode: \"call\", error: \"tool_error\", ...guardedMcpDetails(guarded) },\n };\n }\n\n const content = resolveMcpResultContent(result as Record<string, unknown>);\n const outputContent = content.length > 0 ? content : [{ type: \"text\" as const, text: \"(empty result)\" }];\n const uiMessage = uiSession?.reused\n ? \"Updated the open UI.\"\n : \"📺 Interactive UI is now open in your browser. I'll respond to your prompts and intents as you interact with it.\";\n const guarded = await guardMcpOutput(outputContent, { ...outputGuardOptions, suffix: `\\n\\n${uiMessage}`, rawMcpResult: result });\n return {\n content: guarded.content,\n details: { mode: \"call\", ...guardedMcpDetails(guarded), server: serverName, tool: toolMeta.originalName, uiOpen: true },\n };\n }\n\n const result = await abortable(resultPromise, signal);\n\n if (result.isError) {\n const mcpContent = (result.content ?? []) as McpContent[];\n const content = transformMcpContent(mcpContent);\n const outputContent = content.length > 0 ? content : [{ type: \"text\" as const, text: \"(empty result)\" }];\n const schemaText = toolMeta.inputSchema ? `\\n\\nExpected parameters:\\n${formatSchema(toolMeta.inputSchema)}` : \"\";\n const guarded = await guardMcpOutput(outputContent, { ...outputGuardOptions, prefix: \"Error: \", suffix: schemaText, emptyTextFallback: \"Tool execution failed\", rawMcpResult: result });\n return {\n content: guarded.content,\n details: { mode: \"call\", error: \"tool_error\", ...guardedMcpDetails(guarded) },\n };\n }\n\n const content = resolveMcpResultContent(result as Record<string, unknown>);\n const outputContent = content.length > 0 ? content : [{ type: \"text\" as const, text: \"(empty result)\" }];\n const guarded = await guardMcpOutput(outputContent, { ...outputGuardOptions, rawMcpResult: result });\n return {\n content: guarded.content,\n details: { mode: \"call\", ...guardedMcpDetails(guarded), server: serverName, tool: toolMeta.originalName },\n };\n } catch (error) {\n if (error instanceof UrlElicitationRequiredError) {\n const action = await state.manager.handleUrlElicitationRequired(serverName, error);\n const message = action === \"accept\"\n ? \"The original MCP tool did not run. Complete the opened browser interaction, then retry the tool.\"\n : `The URL interaction was ${action === \"decline\" ? \"declined\" : \"cancelled\"}.`;\n uiSession?.sendToolCancelled(message);\n return {\n content: [{ type: \"text\" as const, text: message }],\n details: { mode: \"call\", error: \"url_elicitation_required\", server: serverName, action },\n };\n }\n const message = error instanceof Error ? error.message : String(error);\n uiSession?.sendToolCancelled(message);\n\n const schemaText = toolMeta.inputSchema ? `\\n\\nExpected parameters:\\n${formatSchema(toolMeta.inputSchema)}` : \"\";\n const guarded = await guardMcpOutput([{ type: \"text\" as const, text: message }], { ...outputGuardOptions, prefix: \"Failed to call tool: \", suffix: schemaText });\n\n return {\n content: guarded.content,\n details: { mode: \"call\", error: \"call_failed\", message: guarded.outputGuard ? \"output truncated; see outputGuard.fullOutputPath\" : message, ...guardedMcpDetails(guarded) },\n };\n } finally {\n if (uiSession?.reused) {\n uiSession.close();\n }\n state.manager.decrementInFlight(serverName);\n state.manager.touch(serverName);\n }\n}\n"]}
1
+ {"version":3,"file":"proxy-modes.d.ts","sourceRoot":"","sources":["../../../src/builtin-extensions/pi-mcp-adapter/proxy-modes.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,QAAQ,EAAE,MAAM,iCAAiC,CAAC;AAGjF,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAYpD,KAAK,eAAe,GAAG,eAAe,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;AAmGhE,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,iBAAiB,GAAG,eAAe,CA4E3E;AAED,wBAAgB,aAAa,CAAC,KAAK,EAAE,iBAAiB,GAAG,eAAe,CAsDvE;AAED,wBAAsB,gBAAgB,CAAC,KAAK,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC,CAoC7G;AAED,wBAAsB,mBAAmB,CAAC,KAAK,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC,CA+B/H;AAED,wBAAgB,eAAe,CAAC,KAAK,EAAE,iBAAiB,EAAE,QAAQ,EAAE,MAAM,GAAG,eAAe,CAuC3F;AAED,wBAAgB,aAAa,CAC3B,KAAK,EAAE,iBAAiB,EACxB,KAAK,EAAE,MAAM,EACb,KAAK,CAAC,EAAE,OAAO,EACf,MAAM,CAAC,EAAE,MAAM,EACf,cAAc,CAAC,EAAE,OAAO,GACvB,eAAe,CAwGjB;AAED,wBAAgB,WAAW,CAAC,KAAK,EAAE,iBAAiB,EAAE,MAAM,EAAE,MAAM,GAAG,eAAe,CAqDrF;AAED,wBAAsB,cAAc,CAAC,KAAK,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,eAAe,CAAC,CAqDjI;AAED,wBAAsB,WAAW,CAC/B,KAAK,EAAE,iBAAiB,EACxB,QAAQ,EAAE,MAAM,EAChB,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC9B,cAAc,CAAC,EAAE,MAAM,EACvB,UAAU,CAAC,EAAE,MAAM,QAAQ,EAAE,EAC7B,MAAM,CAAC,EAAE,WAAW,GACnB,OAAO,CAAC,eAAe,CAAC,CAyW1B","sourcesContent":["// @ts-nocheck\nimport type { AgentToolResult, ToolInfo } from \"@ashx-j/lunr\";\nimport { UrlElicitationRequiredError } from \"@modelcontextprotocol/sdk/types.js\";\nimport { checkSync } from \"recheck\";\nimport type { McpExtensionState } from \"./state.ts\";\nimport type { ToolMetadata, McpContent } from \"./types.ts\";\nimport { getServerPrefix, parseUiPromptHandoff } from \"./types.ts\";\nimport { lazyConnect, updateServerMetadata, updateMetadataCache, getFailureAgeSeconds, updateStatusBar } from \"./init.ts\";\nimport { abortable, throwIfAborted } from \"./abort.ts\";\nimport { buildToolMetadata, getToolNames, findToolByName, formatSchema } from \"./tool-metadata.ts\";\nimport { resolveMcpResultContent, transformMcpContent } from \"./tool-registrar.ts\";\nimport { guardMcpOutput, guardedMcpDetails, resolveMcpOutputGuardOptions } from \"./mcp-output-guard.ts\";\nimport { maybeStartUiSession, type UiSessionRuntime } from \"./ui-session.ts\";\nimport { formatAuthRequiredMessage, truncateAtWord } from \"./utils.ts\";\nimport { authenticate, completeAuthFromInput, startAuth, supportsOAuth } from \"./mcp-auth-flow.ts\";\n\ntype ProxyToolResult = AgentToolResult<Record<string, unknown>>;\n\nconst MAX_REGEX_SEARCH_QUERY_LENGTH = 256;\nconst REGEX_SAFETY_CHECK_PARAMS = {\n attackTimeout: 50,\n incubationTimeout: 50,\n timeout: 250,\n} as const;\n\ntype AutoAuthResult =\n | { status: \"skipped\" }\n | { status: \"success\" }\n | { status: \"failed\"; message: string };\n\nfunction getAuthRequiredMessage(\n state: McpExtensionState,\n serverName: string,\n defaultMessage = `Server \"${serverName}\" requires OAuth authentication. Run mcp({ action: \"auth-start\", server: \"${serverName}\" }) to get a browser URL, or /mcp-auth ${serverName} in an interactive local session.`,\n): string {\n return formatAuthRequiredMessage(state.config, serverName, defaultMessage);\n}\n\nfunction getAuthFailedMessage(state: McpExtensionState, serverName: string, message: string): string {\n const customGuidance = state.config.settings?.authRequiredMessage;\n if (customGuidance) {\n return `OAuth authentication failed for \"${serverName}\": ${message}. ${getAuthRequiredMessage(state, serverName)}`;\n }\n return `OAuth authentication failed for \"${serverName}\": ${message}. Run mcp({ action: \"auth-start\", server: \"${serverName}\" }) to get a browser URL, or /mcp-auth ${serverName} in an interactive local session.`;\n}\n\nfunction getRedirectPort(authorizationUrl: string): number | undefined {\n try {\n const redirectUri = new URL(authorizationUrl).searchParams.get(\"redirect_uri\");\n if (!redirectUri) return undefined;\n const port = Number.parseInt(new URL(redirectUri).port, 10);\n return Number.isInteger(port) ? port : undefined;\n } catch {\n return undefined;\n }\n}\n\nfunction formatManualAuthInstructions(serverName: string, authorizationUrl: string): string {\n const port = getRedirectPort(authorizationUrl);\n const portNote = port\n ? `\\nThe redirect URL will use local port ${port}. On a remote server it is expected for that localhost page to fail locally; copy the address bar URL anyway.`\n : \"\";\n\n return [\n `MCP OAuth required for \"${serverName}\".`,\n \"\",\n \"Open this URL in your local browser:\",\n \"\",\n authorizationUrl,\n \"\",\n \"After approving, copy the full redirected localhost URL from your browser address bar and send it back with:\",\n `mcp({ action: \"auth-complete\", server: \"${serverName}\", args: '{\"redirectUrl\":\"PASTE_REDIRECT_URL_HERE\"}' })`,\n \"\",\n \"You can also pass just the `code` query parameter as `args: '{\\\"code\\\":\\\"PASTE_CODE_HERE\\\"}'`.\",\n portNote.trimEnd(),\n ].filter(Boolean).join(\"\\n\");\n}\n\nasync function attemptAutoAuth(\n state: McpExtensionState,\n serverName: string,\n): Promise<AutoAuthResult> {\n if (state.config.settings?.autoAuth !== true) {\n return { status: \"skipped\" };\n }\n\n const definition = state.config.mcpServers[serverName];\n if (!definition || !supportsOAuth(definition) || !definition.url) {\n return { status: \"skipped\" };\n }\n\n const grantType = definition.oauth ? definition.oauth.grantType ?? \"authorization_code\" : \"authorization_code\";\n if (!state.ui && grantType !== \"client_credentials\") {\n return {\n status: \"failed\",\n message: getAuthRequiredMessage(\n state,\n serverName,\n `Server \"${serverName}\" requires OAuth authentication. Run mcp({ action: \"auth-start\", server: \"${serverName}\" }) to get a browser URL, or /mcp-auth ${serverName} in an interactive local session.`,\n ),\n };\n }\n\n try {\n await authenticate(serverName, definition.url, definition);\n return { status: \"success\" };\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error);\n return {\n status: \"failed\",\n message: getAuthFailedMessage(state, serverName, message),\n };\n }\n}\n\nexport function executeUiMessages(state: McpExtensionState): ProxyToolResult {\n const sessions = state.completedUiSessions;\n\n if (sessions.length === 0) {\n return {\n content: [{ type: \"text\" as const, text: \"No UI session messages available.\" }],\n details: { sessions: 0 },\n };\n }\n\n const output: string[] = [];\n output.push(`UI Session Messages (${sessions.length} session${sessions.length > 1 ? \"s\" : \"\"}):\\n`);\n\n const allPrompts: string[] = [];\n const allIntents = sessions.flatMap((session) => session.messages.intents);\n const parsedHandoffs: Array<{ intent: string; params: Record<string, unknown>; raw: string }> = [];\n\n for (const session of sessions) {\n const timestamp = session.completedAt.toLocaleTimeString();\n output.push(`\\n## ${session.serverName} / ${session.toolName} (${timestamp}, ${session.reason})`);\n\n const plainPrompts: string[] = [];\n for (const prompt of session.messages.prompts) {\n allPrompts.push(prompt);\n const handoff = parseUiPromptHandoff(prompt);\n if (handoff) {\n parsedHandoffs.push(handoff);\n } else {\n plainPrompts.push(prompt);\n }\n }\n\n if (plainPrompts.length > 0) {\n output.push(\"\\n### Prompts:\");\n for (const prompt of plainPrompts) {\n output.push(`- ${prompt}`);\n }\n }\n\n const intentsForSession = [\n ...session.messages.intents,\n ...session.messages.prompts\n .map((prompt) => parseUiPromptHandoff(prompt))\n .filter((handoff): handoff is NonNullable<typeof handoff> => !!handoff)\n .map((handoff) => ({ intent: handoff.intent, params: handoff.params })),\n ];\n\n if (intentsForSession.length > 0) {\n output.push(\"\\n### Intents:\");\n for (const intent of intentsForSession) {\n const params = intent.params ? ` (${JSON.stringify(intent.params)})` : \"\";\n output.push(`- ${intent.intent}${params}`);\n }\n }\n\n if (session.messages.notifications.length > 0) {\n output.push(\"\\n### Notifications:\");\n for (const notification of session.messages.notifications) {\n output.push(`- ${notification}`);\n }\n }\n }\n\n const count = sessions.length;\n state.completedUiSessions = [];\n\n return {\n content: [{ type: \"text\" as const, text: output.join(\"\\n\") }],\n details: {\n sessions: count,\n prompts: allPrompts,\n intents: [...allIntents, ...parsedHandoffs.map(({ intent, params }) => ({ intent, params }))],\n handoffs: parsedHandoffs,\n cleared: true,\n },\n };\n}\n\nexport function executeStatus(state: McpExtensionState): ProxyToolResult {\n const servers: Array<{ name: string; status: string; toolCount: number; failedAgo: number | null }> = [];\n\n for (const name of Object.keys(state.config.mcpServers)) {\n const connection = state.manager.getConnection(name);\n const metadata = state.toolMetadata.get(name);\n const toolCount = metadata?.length ?? 0;\n const failedAgo = getFailureAgeSeconds(state, name);\n let status = \"not connected\";\n if (connection?.status === \"connected\") {\n status = \"connected\";\n } else if (connection?.status === \"needs-auth\") {\n status = \"needs-auth\";\n } else if (failedAgo !== null) {\n status = \"failed\";\n } else if (metadata !== undefined) {\n status = \"cached\";\n }\n\n servers.push({ name, status, toolCount, failedAgo });\n }\n\n const totalTools = servers.reduce((sum, s) => sum + s.toolCount, 0);\n const connectedCount = servers.filter(s => s.status === \"connected\").length;\n\n let text = `MCP: ${connectedCount}/${servers.length} servers, ${totalTools} tools\\n\\n`;\n for (const server of servers) {\n if (server.status === \"connected\") {\n text += `✓ ${server.name} (${server.toolCount} tools)\\n`;\n continue;\n }\n if (server.status === \"needs-auth\") {\n text += `⚠ ${server.name} (needs auth)\\n`;\n continue;\n }\n if (server.status === \"cached\") {\n text += `○ ${server.name} (${server.toolCount} tools, cached)\\n`;\n continue;\n }\n if (server.status === \"failed\") {\n text += `✗ ${server.name} (failed ${server.failedAgo ?? 0}s ago)\\n`;\n continue;\n }\n text += `○ ${server.name} (not connected)\\n`;\n }\n\n if (servers.length > 0) {\n text += `\\nmcp({ server: \"name\" }) to list tools, mcp({ search: \"...\" }) to search`;\n }\n\n return {\n content: [{ type: \"text\" as const, text: text.trim() }],\n details: { mode: \"status\", servers, totalTools, connectedCount },\n };\n}\n\nexport async function executeAuthStart(state: McpExtensionState, serverName: string): Promise<ProxyToolResult> {\n const definition = state.config.mcpServers[serverName];\n if (!definition) {\n return {\n content: [{ type: \"text\" as const, text: `Server \"${serverName}\" not found. Use mcp({}) to see available servers.` }],\n details: { mode: \"auth-start\", error: \"not_found\", server: serverName },\n };\n }\n\n if (!definition.url || !supportsOAuth(definition)) {\n return {\n content: [{ type: \"text\" as const, text: `Server \"${serverName}\" is not configured for OAuth over HTTP.` }],\n details: { mode: \"auth-start\", error: \"oauth_not_supported\", server: serverName },\n };\n }\n\n try {\n const { authorizationUrl } = await startAuth(serverName, definition.url, definition);\n if (!authorizationUrl) {\n return {\n content: [{ type: \"text\" as const, text: `OAuth authentication successful for \"${serverName}\".` }],\n details: { mode: \"auth-start\", server: serverName, authenticated: true },\n };\n }\n\n return {\n content: [{ type: \"text\" as const, text: formatManualAuthInstructions(serverName, authorizationUrl) }],\n details: { mode: \"auth-start\", server: serverName, authorizationUrl },\n };\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error);\n return {\n content: [{ type: \"text\" as const, text: `Failed to start OAuth for \"${serverName}\": ${message}` }],\n details: { mode: \"auth-start\", error: \"auth_start_failed\", server: serverName, message },\n };\n }\n}\n\nexport async function executeAuthComplete(state: McpExtensionState, serverName: string, input: string): Promise<ProxyToolResult> {\n if (!state.config.mcpServers[serverName]) {\n return {\n content: [{ type: \"text\" as const, text: `Server \"${serverName}\" not found. Use mcp({}) to see available servers.` }],\n details: { mode: \"auth-complete\", error: \"not_found\", server: serverName },\n };\n }\n\n try {\n const status = await completeAuthFromInput(serverName, input);\n if (status !== \"authenticated\") {\n return {\n content: [{ type: \"text\" as const, text: `OAuth authentication did not complete for \"${serverName}\".` }],\n details: { mode: \"auth-complete\", error: \"not_authenticated\", server: serverName, status },\n };\n }\n\n await state.manager.close(serverName);\n state.failureTracker.delete(serverName);\n updateStatusBar(state);\n return {\n content: [{ type: \"text\" as const, text: `OAuth authentication successful for \"${serverName}\". Run mcp({ connect: \"${serverName}\" }) to connect with the new token.` }],\n details: { mode: \"auth-complete\", server: serverName, authenticated: true },\n };\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error);\n return {\n content: [{ type: \"text\" as const, text: `Failed to complete OAuth for \"${serverName}\": ${message}` }],\n details: { mode: \"auth-complete\", error: \"auth_complete_failed\", server: serverName, message },\n };\n }\n}\n\nexport function executeDescribe(state: McpExtensionState, toolName: string): ProxyToolResult {\n let serverName: string | undefined;\n let toolMeta: ToolMetadata | undefined;\n\n for (const [server, metadata] of state.toolMetadata.entries()) {\n const found = findToolByName(metadata, toolName);\n if (found) {\n serverName = server;\n toolMeta = found;\n break;\n }\n }\n\n if (!serverName || !toolMeta) {\n return {\n content: [{ type: \"text\" as const, text: `Tool \"${toolName}\" not found. Use mcp({ search: \"...\" }) to search.` }],\n details: { mode: \"describe\", error: \"tool_not_found\", requestedTool: toolName },\n };\n }\n\n let text = `${toolMeta.name}\\n`;\n text += `Server: ${serverName}\\n`;\n if (toolMeta.resourceUri) {\n text += `Type: Resource (reads from ${toolMeta.resourceUri})\\n`;\n }\n text += `\\n${toolMeta.description || \"(no description)\"}\\n`;\n\n if (toolMeta.inputSchema && !toolMeta.resourceUri) {\n text += `\\nParameters:\\n${formatSchema(toolMeta.inputSchema)}`;\n } else if (toolMeta.resourceUri) {\n text += `\\nNo parameters required (resource tool).`;\n } else {\n text += `\\nNo parameters defined.`;\n }\n\n return {\n content: [{ type: \"text\" as const, text: text.trim() }],\n details: { mode: \"describe\", tool: toolMeta, server: serverName },\n };\n}\n\nexport function executeSearch(\n state: McpExtensionState,\n query: string,\n regex?: boolean,\n server?: string,\n includeSchemas?: boolean,\n): ProxyToolResult {\n const showSchemas = includeSchemas !== false;\n\n const matches: Array<{ server: string; tool: ToolMetadata }> = [];\n\n let pattern: RegExp;\n try {\n if (regex) {\n if (query.length > MAX_REGEX_SEARCH_QUERY_LENGTH) {\n return {\n content: [{ type: \"text\" as const, text: `Regex query is too long; maximum length is ${MAX_REGEX_SEARCH_QUERY_LENGTH} characters.` }],\n details: { mode: \"search\", error: \"query_too_long\", query, maxLength: MAX_REGEX_SEARCH_QUERY_LENGTH },\n };\n }\n\n pattern = new RegExp(query, \"i\");\n let safety;\n try {\n safety = checkSync(query, \"i\", REGEX_SAFETY_CHECK_PARAMS);\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error);\n return {\n content: [{ type: \"text\" as const, text: \"Regex query rejected because safety analysis failed.\" }],\n details: { mode: \"search\", error: \"unsafe_pattern\", query, reason: message },\n };\n }\n if (safety.status !== \"safe\") {\n return {\n content: [{ type: \"text\" as const, text: `Regex query rejected as unsafe (${safety.status}).` }],\n details: { mode: \"search\", error: \"unsafe_pattern\", query, safetyStatus: safety.status },\n };\n }\n } else {\n const terms = query.trim().split(/\\s+/).filter(t => t.length > 0);\n if (terms.length === 0) {\n return {\n content: [{ type: \"text\" as const, text: \"Search query cannot be empty\" }],\n details: { mode: \"search\", error: \"empty_query\" },\n };\n }\n const escaped = terms.map(t => t.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\"));\n pattern = new RegExp(escaped.join(\"|\"), \"i\");\n }\n } catch {\n return {\n content: [{ type: \"text\" as const, text: `Invalid regex: ${query}` }],\n details: { mode: \"search\", error: \"invalid_pattern\", query },\n };\n }\n\n for (const [serverName, metadata] of state.toolMetadata.entries()) {\n if (server && serverName !== server) continue;\n for (const tool of metadata) {\n if (pattern.test(tool.name) || pattern.test(tool.description)) {\n matches.push({\n server: serverName,\n tool,\n });\n }\n }\n }\n\n const totalCount = matches.length;\n\n if (totalCount === 0) {\n const msg = server\n ? `No tools matching \"${query}\" in \"${server}\"`\n : `No tools matching \"${query}\"`;\n return {\n content: [{ type: \"text\" as const, text: msg }],\n details: { mode: \"search\", matches: [], count: 0, query },\n };\n }\n\n let text = `Found ${totalCount} tool${totalCount === 1 ? \"\" : \"s\"} matching \"${query}\":\\n\\n`;\n\n for (const match of matches) {\n if (showSchemas) {\n text += `${match.tool.name}\\n`;\n text += ` ${match.tool.description || \"(no description)\"}\\n`;\n if (match.tool.inputSchema && !match.tool.resourceUri) {\n text += `\\n Parameters:\\n${formatSchema(match.tool.inputSchema, \" \")}\\n`;\n } else if (match.tool.resourceUri) {\n text += ` No parameters (resource tool).\\n`;\n }\n text += \"\\n\";\n } else {\n text += `- ${match.tool.name}`;\n if (match.tool.description) {\n text += ` - ${truncateAtWord(match.tool.description, 50)}`;\n }\n text += \"\\n\";\n }\n }\n\n return {\n content: [{ type: \"text\" as const, text: text.trim() }],\n details: {\n mode: \"search\",\n matches: matches.map(m => ({ server: m.server, tool: m.tool.name })),\n count: totalCount,\n query,\n },\n };\n}\n\nexport function executeList(state: McpExtensionState, server: string): ProxyToolResult {\n if (!state.config.mcpServers[server]) {\n return {\n content: [{ type: \"text\" as const, text: `Server \"${server}\" not found. Use mcp({}) to see available servers.` }],\n details: { mode: \"list\", server, tools: [], count: 0, error: \"not_found\" },\n };\n }\n\n const metadata = state.toolMetadata.get(server);\n const toolNames = metadata?.map(m => m.name) ?? [];\n const connection = state.manager.getConnection(server);\n\n if (toolNames.length === 0) {\n if (connection?.status === \"connected\") {\n return {\n content: [{ type: \"text\" as const, text: `Server \"${server}\" has no tools.` }],\n details: { mode: \"list\", server, tools: [], count: 0 },\n };\n }\n if (metadata !== undefined) {\n return {\n content: [{ type: \"text\" as const, text: `Server \"${server}\" has no cached tools (not connected).` }],\n details: { mode: \"list\", server, tools: [], count: 0, cached: true },\n };\n }\n return {\n content: [{ type: \"text\" as const, text: `Server \"${server}\" is configured but not connected. Use mcp({ connect: \"${server}\" }) or /mcp reconnect ${server} to retry.` }],\n details: { mode: \"list\", server, tools: [], count: 0, error: \"not_connected\" },\n };\n }\n\n const cachedNote = connection?.status === \"connected\" ? \"\" : \" (not connected, cached)\";\n let text = `${server} (${toolNames.length} tools${cachedNote}):\\n\\n`;\n\n const descMap = new Map<string, string>();\n if (metadata) {\n for (const m of metadata) {\n descMap.set(m.name, m.description);\n }\n }\n\n for (const tool of toolNames) {\n const desc = descMap.get(tool) ?? \"\";\n const truncated = truncateAtWord(desc, 50);\n text += `- ${tool}`;\n if (truncated) text += ` - ${truncated}`;\n text += \"\\n\";\n }\n\n return {\n content: [{ type: \"text\" as const, text: text.trim() }],\n details: { mode: \"list\", server, tools: toolNames, count: toolNames.length },\n };\n}\n\nexport async function executeConnect(state: McpExtensionState, serverName: string, signal?: AbortSignal): Promise<ProxyToolResult> {\n throwIfAborted(signal);\n const definition = state.config.mcpServers[serverName];\n if (!definition) {\n return {\n content: [{ type: \"text\" as const, text: `Server \"${serverName}\" not found. Use mcp({}) to see available servers.` }],\n details: { mode: \"connect\", error: \"not_found\", server: serverName },\n };\n }\n\n try {\n if (state.ui) {\n state.ui.setStatus(\"mcp\", `MCP: connecting to ${serverName}...`);\n }\n let connection = await state.manager.connect(serverName, definition, signal);\n if (connection.status === \"needs-auth\") {\n const autoAuth = await attemptAutoAuth(state, serverName);\n if (autoAuth.status === \"failed\") {\n return {\n content: [{ type: \"text\" as const, text: autoAuth.message }],\n details: { mode: \"connect\", error: \"auth_required\", server: serverName, message: autoAuth.message },\n };\n }\n if (autoAuth.status === \"success\") {\n await state.manager.close(serverName);\n connection = await state.manager.connect(serverName, definition, signal);\n }\n if (connection.status === \"needs-auth\") {\n const message = getAuthRequiredMessage(state, serverName);\n return {\n content: [{ type: \"text\" as const, text: message }],\n details: { mode: \"connect\", error: \"auth_required\", server: serverName, message },\n };\n }\n }\n const prefix = state.config.settings?.toolPrefix ?? \"server\";\n const { metadata } = buildToolMetadata(connection.tools, connection.resources, definition, serverName, prefix);\n state.toolMetadata.set(serverName, metadata);\n updateMetadataCache(state, serverName);\n state.failureTracker.delete(serverName);\n updateStatusBar(state);\n return executeList(state, serverName);\n } catch (error) {\n if (!signal?.aborted) {\n state.failureTracker.set(serverName, Date.now());\n }\n updateStatusBar(state);\n const message = error instanceof Error ? error.message : String(error);\n return {\n content: [{ type: \"text\" as const, text: `Failed to connect to \"${serverName}\": ${message}` }],\n details: { mode: \"connect\", error: signal?.aborted ? \"aborted\" : \"connect_failed\", server: serverName, message },\n };\n }\n}\n\nexport async function executeCall(\n state: McpExtensionState,\n toolName: string,\n args?: Record<string, unknown>,\n serverOverride?: string,\n getPiTools?: () => ToolInfo[],\n signal?: AbortSignal,\n): Promise<ProxyToolResult> {\n throwIfAborted(signal);\n let serverName: string | undefined = serverOverride;\n let toolMeta: ToolMetadata | undefined;\n let autoAuthAttempted = false;\n const prefixMode = state.config.settings?.toolPrefix ?? \"server\";\n\n if (serverName && !state.config.mcpServers[serverName]) {\n return {\n content: [{ type: \"text\" as const, text: `Server \"${serverName}\" not found. Use mcp({}) to see available servers.` }],\n details: { mode: \"call\", error: \"server_not_found\", server: serverName },\n };\n }\n\n if (serverName) {\n toolMeta = findToolByName(state.toolMetadata.get(serverName), toolName);\n } else {\n for (const [server, metadata] of state.toolMetadata.entries()) {\n const found = findToolByName(metadata, toolName);\n if (found) {\n serverName = server;\n toolMeta = found;\n break;\n }\n }\n }\n\n if (serverName && !toolMeta) {\n const connected = await lazyConnect(state, serverName, signal);\n if (connected) {\n toolMeta = findToolByName(state.toolMetadata.get(serverName), toolName);\n } else {\n const needsAuthConnection = state.manager.getConnection(serverName);\n if (needsAuthConnection?.status === \"needs-auth\") {\n if (!autoAuthAttempted) {\n autoAuthAttempted = true;\n const autoAuth = await attemptAutoAuth(state, serverName);\n if (autoAuth.status === \"failed\") {\n return {\n content: [{ type: \"text\" as const, text: autoAuth.message }],\n details: { mode: \"call\", error: \"auth_required\", server: serverName, message: autoAuth.message },\n };\n }\n if (autoAuth.status === \"success\") {\n await state.manager.close(serverName);\n state.failureTracker.delete(serverName);\n const connectedAfterAuth = await lazyConnect(state, serverName, signal);\n if (connectedAfterAuth) {\n toolMeta = findToolByName(state.toolMetadata.get(serverName), toolName);\n if (!toolMeta) {\n return {\n content: [{ type: \"text\" as const, text: `Tool \"${toolName}\" not found on \"${serverName}\" after reconnect.` }],\n details: { mode: \"call\", error: \"tool_not_found_after_reconnect\", requestedTool: toolName },\n };\n }\n }\n }\n }\n\n if (!toolMeta && state.manager.getConnection(serverName)?.status === \"needs-auth\") {\n const message = getAuthRequiredMessage(state, serverName);\n return {\n content: [{ type: \"text\" as const, text: message }],\n details: { mode: \"call\", error: \"auth_required\", server: serverName, message },\n };\n }\n }\n\n if (!toolMeta) {\n const failedAgo = getFailureAgeSeconds(state, serverName);\n if (failedAgo !== null) {\n return {\n content: [{ type: \"text\" as const, text: `Server \"${serverName}\" not available (last failed ${failedAgo}s ago)` }],\n details: { mode: \"call\", error: \"server_backoff\", server: serverName },\n };\n }\n }\n }\n }\n\n let prefixMatchedServer: string | undefined;\n\n if (!serverName && !toolMeta && prefixMode !== \"none\") {\n const candidates = Object.keys(state.config.mcpServers)\n .map(name => ({ name, prefix: getServerPrefix(name, prefixMode) }))\n .filter(c => c.prefix && toolName.startsWith(c.prefix + \"_\"))\n .sort((a, b) => b.prefix.length - a.prefix.length);\n\n for (const { name: configuredServer } of candidates) {\n const existingConnection = state.manager.getConnection(configuredServer);\n const failedAgo = getFailureAgeSeconds(state, configuredServer);\n if (failedAgo !== null && existingConnection?.status !== \"needs-auth\") continue;\n\n let connected = await lazyConnect(state, configuredServer, signal);\n if (!connected && state.manager.getConnection(configuredServer)?.status === \"needs-auth\" && !autoAuthAttempted) {\n autoAuthAttempted = true;\n const autoAuth = await attemptAutoAuth(state, configuredServer);\n if (autoAuth.status === \"failed\") {\n return {\n content: [{ type: \"text\" as const, text: autoAuth.message }],\n details: { mode: \"call\", error: \"auth_required\", server: configuredServer, message: autoAuth.message },\n };\n }\n if (autoAuth.status === \"success\") {\n await state.manager.close(configuredServer);\n state.failureTracker.delete(configuredServer);\n connected = await lazyConnect(state, configuredServer, signal);\n }\n }\n\n if (!connected) continue;\n if (!prefixMatchedServer) prefixMatchedServer = configuredServer;\n toolMeta = findToolByName(state.toolMetadata.get(configuredServer), toolName);\n if (toolMeta) {\n serverName = configuredServer;\n break;\n }\n }\n }\n\n if (!serverName || !toolMeta) {\n const nativeTool = !serverOverride\n ? getPiTools?.().find((tool) => tool.name === toolName && tool.name !== \"mcp\")\n : undefined;\n if (nativeTool) {\n return {\n content: [{ type: \"text\" as const, text: `\"${toolName}\" is a native Pi tool. Call ${toolName} directly instead of using mcp({ tool: \"${toolName}\" }).` }],\n details: { mode: \"call\", error: \"native_tool\", requestedTool: toolName },\n };\n }\n\n const hintServer = serverName ?? prefixMatchedServer;\n const available = hintServer ? getToolNames(state, hintServer) : [];\n let msg = `Tool \"${toolName}\" not found.`;\n if (available.length > 0) {\n msg += ` Server \"${hintServer}\" has: ${available.join(\", \")}`;\n } else {\n msg += ` Use mcp({ search: \"...\" }) to search.`;\n }\n return {\n content: [{ type: \"text\" as const, text: msg }],\n details: { mode: \"call\", error: \"tool_not_found\", requestedTool: toolName, hintServer },\n };\n }\n\n let connection = state.manager.getConnection(serverName);\n if (connection?.status === \"needs-auth\") {\n if (!autoAuthAttempted) {\n autoAuthAttempted = true;\n const autoAuth = await attemptAutoAuth(state, serverName);\n if (autoAuth.status === \"failed\") {\n return {\n content: [{ type: \"text\" as const, text: autoAuth.message }],\n details: { mode: \"call\", error: \"auth_required\", server: serverName, message: autoAuth.message },\n };\n }\n if (autoAuth.status === \"success\") {\n await state.manager.close(serverName);\n state.failureTracker.delete(serverName);\n connection = state.manager.getConnection(serverName);\n }\n }\n\n if (connection?.status === \"needs-auth\") {\n const message = getAuthRequiredMessage(state, serverName);\n return {\n content: [{ type: \"text\" as const, text: message }],\n details: { mode: \"call\", error: \"auth_required\", server: serverName, message },\n };\n }\n }\n if (!connection || connection.status !== \"connected\") {\n const failedAgo = getFailureAgeSeconds(state, serverName);\n if (failedAgo !== null) {\n return {\n content: [{ type: \"text\" as const, text: `Server \"${serverName}\" not available (last failed ${failedAgo}s ago)` }],\n details: { mode: \"call\", error: \"server_backoff\", server: serverName },\n };\n }\n\n const definition = state.config.mcpServers[serverName];\n if (!definition) {\n return {\n content: [{ type: \"text\" as const, text: `Server \"${serverName}\" not connected` }],\n details: { mode: \"call\", error: \"server_not_connected\", server: serverName },\n };\n }\n\n try {\n if (state.ui) {\n state.ui.setStatus(\"mcp\", `MCP: connecting to ${serverName}...`);\n }\n connection = await state.manager.connect(serverName, definition, signal);\n if (connection.status === \"needs-auth\") {\n if (!autoAuthAttempted) {\n autoAuthAttempted = true;\n const autoAuth = await attemptAutoAuth(state, serverName);\n if (autoAuth.status === \"failed\") {\n return {\n content: [{ type: \"text\" as const, text: autoAuth.message }],\n details: { mode: \"call\", error: \"auth_required\", server: serverName, message: autoAuth.message },\n };\n }\n if (autoAuth.status === \"success\") {\n await state.manager.close(serverName);\n connection = await state.manager.connect(serverName, definition, signal);\n }\n }\n\n if (connection.status === \"needs-auth\") {\n const message = getAuthRequiredMessage(state, serverName);\n return {\n content: [{ type: \"text\" as const, text: message }],\n details: { mode: \"call\", error: \"auth_required\", server: serverName, message },\n };\n }\n }\n state.failureTracker.delete(serverName);\n updateServerMetadata(state, serverName);\n updateMetadataCache(state, serverName);\n updateStatusBar(state);\n toolMeta = findToolByName(state.toolMetadata.get(serverName), toolName);\n if (!toolMeta) {\n const available = getToolNames(state, serverName);\n const hint = available.length > 0\n ? `Available tools on \"${serverName}\": ${available.join(\", \")}`\n : `Server \"${serverName}\" has no tools.`;\n return {\n content: [{ type: \"text\" as const, text: `Tool \"${toolName}\" not found on \"${serverName}\" after reconnect. ${hint}` }],\n details: { mode: \"call\", error: \"tool_not_found_after_reconnect\", requestedTool: toolName },\n };\n }\n } catch (error) {\n if (!signal?.aborted) {\n state.failureTracker.set(serverName, Date.now());\n }\n updateStatusBar(state);\n const message = error instanceof Error ? error.message : String(error);\n return {\n content: [{ type: \"text\" as const, text: `Failed to connect to \"${serverName}\": ${message}` }],\n details: { mode: \"call\", error: signal?.aborted ? \"aborted\" : \"connect_failed\", message },\n };\n }\n }\n\n let uiSession: UiSessionRuntime | null = null;\n const requestOptions = state.manager.getRequestOptions?.(serverName, signal) ?? (signal ? { signal } : undefined);\n\n const outputGuardOptions = resolveMcpOutputGuardOptions(state.config.settings);\n\n try {\n state.manager.touch(serverName);\n state.manager.incrementInFlight(serverName);\n\n if (toolMeta.resourceUri) {\n const result = await connection.client.readResource({ uri: toolMeta.resourceUri }, requestOptions);\n const content = (result.contents ?? []).map(c => ({\n type: \"text\" as const,\n text: \"text\" in c ? c.text : (\"blob\" in c ? `[Binary data: ${(c as { mimeType?: string }).mimeType ?? \"unknown\"}]` : JSON.stringify(c)),\n }));\n const guarded = await guardMcpOutput(content.length > 0 ? content : [{ type: \"text\" as const, text: \"(empty resource)\" }], outputGuardOptions);\n return {\n content: guarded.content,\n details: { mode: \"call\", resourceUri: toolMeta.resourceUri, server: serverName, ...guardedMcpDetails(guarded) },\n };\n }\n\n uiSession = toolMeta.uiResourceUri\n ? await maybeStartUiSession(state, {\n serverName,\n toolName: toolMeta.originalName,\n toolArgs: args ?? {},\n uiResourceUri: toolMeta.uiResourceUri,\n streamMode: toolMeta.uiStreamMode,\n })\n : null;\n\n const resultPromise = connection.client.callTool({\n name: toolMeta.originalName,\n arguments: args ?? {},\n _meta: uiSession?.requestMeta,\n }, undefined, requestOptions);\n\n if (toolMeta.uiResourceUri) {\n const result = await abortable(resultPromise, signal);\n uiSession?.sendToolResult(result as unknown as import(\"@modelcontextprotocol/sdk/types.js\").CallToolResult);\n\n if (result.isError) {\n const mcpContent = (result.content ?? []) as McpContent[];\n const content = transformMcpContent(mcpContent);\n const outputContent = content.length > 0 ? content : [{ type: \"text\" as const, text: \"(empty result)\" }];\n const schemaText = toolMeta.inputSchema ? `\\n\\nExpected parameters:\\n${formatSchema(toolMeta.inputSchema)}` : \"\";\n const guarded = await guardMcpOutput(outputContent, { ...outputGuardOptions, prefix: \"Error: \", suffix: schemaText, emptyTextFallback: \"Tool execution failed\", rawMcpResult: result });\n return {\n content: guarded.content,\n details: { mode: \"call\", error: \"tool_error\", ...guardedMcpDetails(guarded) },\n };\n }\n\n const content = resolveMcpResultContent(result as Record<string, unknown>);\n const outputContent = content.length > 0 ? content : [{ type: \"text\" as const, text: \"(empty result)\" }];\n const uiMessage = uiSession?.reused\n ? \"Updated the open UI.\"\n : \"📺 Interactive UI is now open in your browser. I'll respond to your prompts and intents as you interact with it.\";\n const guarded = await guardMcpOutput(outputContent, { ...outputGuardOptions, suffix: `\\n\\n${uiMessage}`, rawMcpResult: result });\n return {\n content: guarded.content,\n details: { mode: \"call\", ...guardedMcpDetails(guarded), server: serverName, tool: toolMeta.originalName, uiOpen: true },\n };\n }\n\n const result = await abortable(resultPromise, signal);\n\n if (result.isError) {\n const mcpContent = (result.content ?? []) as McpContent[];\n const content = transformMcpContent(mcpContent);\n const outputContent = content.length > 0 ? content : [{ type: \"text\" as const, text: \"(empty result)\" }];\n const schemaText = toolMeta.inputSchema ? `\\n\\nExpected parameters:\\n${formatSchema(toolMeta.inputSchema)}` : \"\";\n const guarded = await guardMcpOutput(outputContent, { ...outputGuardOptions, prefix: \"Error: \", suffix: schemaText, emptyTextFallback: \"Tool execution failed\", rawMcpResult: result });\n return {\n content: guarded.content,\n details: { mode: \"call\", error: \"tool_error\", ...guardedMcpDetails(guarded) },\n };\n }\n\n const content = resolveMcpResultContent(result as Record<string, unknown>);\n const outputContent = content.length > 0 ? content : [{ type: \"text\" as const, text: \"(empty result)\" }];\n const guarded = await guardMcpOutput(outputContent, { ...outputGuardOptions, rawMcpResult: result });\n return {\n content: guarded.content,\n details: { mode: \"call\", ...guardedMcpDetails(guarded), server: serverName, tool: toolMeta.originalName },\n };\n } catch (error) {\n if (error instanceof UrlElicitationRequiredError) {\n const action = await state.manager.handleUrlElicitationRequired(serverName, error);\n const message = action === \"accept\"\n ? \"The original MCP tool did not run. Complete the opened browser interaction, then retry the tool.\"\n : `The URL interaction was ${action === \"decline\" ? \"declined\" : \"cancelled\"}.`;\n uiSession?.sendToolCancelled(message);\n return {\n content: [{ type: \"text\" as const, text: message }],\n details: { mode: \"call\", error: \"url_elicitation_required\", server: serverName, action },\n };\n }\n const message = error instanceof Error ? error.message : String(error);\n uiSession?.sendToolCancelled(message);\n\n const schemaText = toolMeta.inputSchema ? `\\n\\nExpected parameters:\\n${formatSchema(toolMeta.inputSchema)}` : \"\";\n const guarded = await guardMcpOutput([{ type: \"text\" as const, text: message }], { ...outputGuardOptions, prefix: \"Failed to call tool: \", suffix: schemaText });\n\n return {\n content: guarded.content,\n details: { mode: \"call\", error: \"call_failed\", message: guarded.outputGuard ? \"output truncated; see outputGuard.fullOutputPath\" : message, ...guardedMcpDetails(guarded) },\n };\n } finally {\n if (uiSession?.reused) {\n uiSession.close();\n }\n state.manager.decrementInFlight(serverName);\n state.manager.touch(serverName);\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"proxy-modes.js","sourceRoot":"","sources":["../../../src/builtin-extensions/pi-mcp-adapter/proxy-modes.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,2BAA2B,EAAE,MAAM,oCAAoC,CAAC;AACjF,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAGpC,OAAO,EAAE,eAAe,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AACnE,OAAO,EAAE,WAAW,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAC1H,OAAO,EAAE,SAAS,EAAE,cAAc,EAA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AE;SAC5K,CAAC;IACJ,CAAC;YAAS,CAAC;QACT,IAAI,SAAS,EAAE,MAAM,EAAE,CAAC;YACtB,SAAS,CAAC,KAAK,EAAE,CAAC;QACpB,CAAC;QACD,KAAK,CAAC,OAAO,CAAC,iBAAiB,CAAC,UAAU,CAAC,CAAC;QAC5C,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;IAClC,CAAC;AAAA,CACF","sourcesContent":["// @ts-nocheck\nimport type { AgentToolResult, ToolInfo } from \"@earendil-works/pi-coding-agent\";\nimport { UrlElicitationRequiredError } from \"@modelcontextprotocol/sdk/types.js\";\nimport { checkSync } from \"recheck\";\nimport type { McpExtensionState } from \"./state.ts\";\nimport type { ToolMetadata, McpContent } from \"./types.ts\";\nimport { getServerPrefix, parseUiPromptHandoff } from \"./types.ts\";\nimport { lazyConnect, updateServerMetadata, updateMetadataCache, getFailureAgeSeconds, updateStatusBar } from \"./init.ts\";\nimport { abortable, throwIfAborted } from \"./abort.ts\";\nimport { buildToolMetadata, getToolNames, findToolByName, formatSchema } from \"./tool-metadata.ts\";\nimport { resolveMcpResultContent, transformMcpContent } from \"./tool-registrar.ts\";\nimport { guardMcpOutput, guardedMcpDetails, resolveMcpOutputGuardOptions } from \"./mcp-output-guard.ts\";\nimport { maybeStartUiSession, type UiSessionRuntime } from \"./ui-session.ts\";\nimport { formatAuthRequiredMessage, truncateAtWord } from \"./utils.ts\";\nimport { authenticate, completeAuthFromInput, startAuth, supportsOAuth } from \"./mcp-auth-flow.ts\";\n\ntype ProxyToolResult = AgentToolResult<Record<string, unknown>>;\n\nconst MAX_REGEX_SEARCH_QUERY_LENGTH = 256;\nconst REGEX_SAFETY_CHECK_PARAMS = {\n attackTimeout: 50,\n incubationTimeout: 50,\n timeout: 250,\n} as const;\n\ntype AutoAuthResult =\n | { status: \"skipped\" }\n | { status: \"success\" }\n | { status: \"failed\"; message: string };\n\nfunction getAuthRequiredMessage(\n state: McpExtensionState,\n serverName: string,\n defaultMessage = `Server \"${serverName}\" requires OAuth authentication. Run mcp({ action: \"auth-start\", server: \"${serverName}\" }) to get a browser URL, or /mcp-auth ${serverName} in an interactive local session.`,\n): string {\n return formatAuthRequiredMessage(state.config, serverName, defaultMessage);\n}\n\nfunction getAuthFailedMessage(state: McpExtensionState, serverName: string, message: string): string {\n const customGuidance = state.config.settings?.authRequiredMessage;\n if (customGuidance) {\n return `OAuth authentication failed for \"${serverName}\": ${message}. ${getAuthRequiredMessage(state, serverName)}`;\n }\n return `OAuth authentication failed for \"${serverName}\": ${message}. Run mcp({ action: \"auth-start\", server: \"${serverName}\" }) to get a browser URL, or /mcp-auth ${serverName} in an interactive local session.`;\n}\n\nfunction getRedirectPort(authorizationUrl: string): number | undefined {\n try {\n const redirectUri = new URL(authorizationUrl).searchParams.get(\"redirect_uri\");\n if (!redirectUri) return undefined;\n const port = Number.parseInt(new URL(redirectUri).port, 10);\n return Number.isInteger(port) ? port : undefined;\n } catch {\n return undefined;\n }\n}\n\nfunction formatManualAuthInstructions(serverName: string, authorizationUrl: string): string {\n const port = getRedirectPort(authorizationUrl);\n const portNote = port\n ? `\\nThe redirect URL will use local port ${port}. On a remote server it is expected for that localhost page to fail locally; copy the address bar URL anyway.`\n : \"\";\n\n return [\n `MCP OAuth required for \"${serverName}\".`,\n \"\",\n \"Open this URL in your local browser:\",\n \"\",\n authorizationUrl,\n \"\",\n \"After approving, copy the full redirected localhost URL from your browser address bar and send it back with:\",\n `mcp({ action: \"auth-complete\", server: \"${serverName}\", args: '{\"redirectUrl\":\"PASTE_REDIRECT_URL_HERE\"}' })`,\n \"\",\n \"You can also pass just the `code` query parameter as `args: '{\\\"code\\\":\\\"PASTE_CODE_HERE\\\"}'`.\",\n portNote.trimEnd(),\n ].filter(Boolean).join(\"\\n\");\n}\n\nasync function attemptAutoAuth(\n state: McpExtensionState,\n serverName: string,\n): Promise<AutoAuthResult> {\n if (state.config.settings?.autoAuth !== true) {\n return { status: \"skipped\" };\n }\n\n const definition = state.config.mcpServers[serverName];\n if (!definition || !supportsOAuth(definition) || !definition.url) {\n return { status: \"skipped\" };\n }\n\n const grantType = definition.oauth ? definition.oauth.grantType ?? \"authorization_code\" : \"authorization_code\";\n if (!state.ui && grantType !== \"client_credentials\") {\n return {\n status: \"failed\",\n message: getAuthRequiredMessage(\n state,\n serverName,\n `Server \"${serverName}\" requires OAuth authentication. Run mcp({ action: \"auth-start\", server: \"${serverName}\" }) to get a browser URL, or /mcp-auth ${serverName} in an interactive local session.`,\n ),\n };\n }\n\n try {\n await authenticate(serverName, definition.url, definition);\n return { status: \"success\" };\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error);\n return {\n status: \"failed\",\n message: getAuthFailedMessage(state, serverName, message),\n };\n }\n}\n\nexport function executeUiMessages(state: McpExtensionState): ProxyToolResult {\n const sessions = state.completedUiSessions;\n\n if (sessions.length === 0) {\n return {\n content: [{ type: \"text\" as const, text: \"No UI session messages available.\" }],\n details: { sessions: 0 },\n };\n }\n\n const output: string[] = [];\n output.push(`UI Session Messages (${sessions.length} session${sessions.length > 1 ? \"s\" : \"\"}):\\n`);\n\n const allPrompts: string[] = [];\n const allIntents = sessions.flatMap((session) => session.messages.intents);\n const parsedHandoffs: Array<{ intent: string; params: Record<string, unknown>; raw: string }> = [];\n\n for (const session of sessions) {\n const timestamp = session.completedAt.toLocaleTimeString();\n output.push(`\\n## ${session.serverName} / ${session.toolName} (${timestamp}, ${session.reason})`);\n\n const plainPrompts: string[] = [];\n for (const prompt of session.messages.prompts) {\n allPrompts.push(prompt);\n const handoff = parseUiPromptHandoff(prompt);\n if (handoff) {\n parsedHandoffs.push(handoff);\n } else {\n plainPrompts.push(prompt);\n }\n }\n\n if (plainPrompts.length > 0) {\n output.push(\"\\n### Prompts:\");\n for (const prompt of plainPrompts) {\n output.push(`- ${prompt}`);\n }\n }\n\n const intentsForSession = [\n ...session.messages.intents,\n ...session.messages.prompts\n .map((prompt) => parseUiPromptHandoff(prompt))\n .filter((handoff): handoff is NonNullable<typeof handoff> => !!handoff)\n .map((handoff) => ({ intent: handoff.intent, params: handoff.params })),\n ];\n\n if (intentsForSession.length > 0) {\n output.push(\"\\n### Intents:\");\n for (const intent of intentsForSession) {\n const params = intent.params ? ` (${JSON.stringify(intent.params)})` : \"\";\n output.push(`- ${intent.intent}${params}`);\n }\n }\n\n if (session.messages.notifications.length > 0) {\n output.push(\"\\n### Notifications:\");\n for (const notification of session.messages.notifications) {\n output.push(`- ${notification}`);\n }\n }\n }\n\n const count = sessions.length;\n state.completedUiSessions = [];\n\n return {\n content: [{ type: \"text\" as const, text: output.join(\"\\n\") }],\n details: {\n sessions: count,\n prompts: allPrompts,\n intents: [...allIntents, ...parsedHandoffs.map(({ intent, params }) => ({ intent, params }))],\n handoffs: parsedHandoffs,\n cleared: true,\n },\n };\n}\n\nexport function executeStatus(state: McpExtensionState): ProxyToolResult {\n const servers: Array<{ name: string; status: string; toolCount: number; failedAgo: number | null }> = [];\n\n for (const name of Object.keys(state.config.mcpServers)) {\n const connection = state.manager.getConnection(name);\n const metadata = state.toolMetadata.get(name);\n const toolCount = metadata?.length ?? 0;\n const failedAgo = getFailureAgeSeconds(state, name);\n let status = \"not connected\";\n if (connection?.status === \"connected\") {\n status = \"connected\";\n } else if (connection?.status === \"needs-auth\") {\n status = \"needs-auth\";\n } else if (failedAgo !== null) {\n status = \"failed\";\n } else if (metadata !== undefined) {\n status = \"cached\";\n }\n\n servers.push({ name, status, toolCount, failedAgo });\n }\n\n const totalTools = servers.reduce((sum, s) => sum + s.toolCount, 0);\n const connectedCount = servers.filter(s => s.status === \"connected\").length;\n\n let text = `MCP: ${connectedCount}/${servers.length} servers, ${totalTools} tools\\n\\n`;\n for (const server of servers) {\n if (server.status === \"connected\") {\n text += `✓ ${server.name} (${server.toolCount} tools)\\n`;\n continue;\n }\n if (server.status === \"needs-auth\") {\n text += `⚠ ${server.name} (needs auth)\\n`;\n continue;\n }\n if (server.status === \"cached\") {\n text += `○ ${server.name} (${server.toolCount} tools, cached)\\n`;\n continue;\n }\n if (server.status === \"failed\") {\n text += `✗ ${server.name} (failed ${server.failedAgo ?? 0}s ago)\\n`;\n continue;\n }\n text += `○ ${server.name} (not connected)\\n`;\n }\n\n if (servers.length > 0) {\n text += `\\nmcp({ server: \"name\" }) to list tools, mcp({ search: \"...\" }) to search`;\n }\n\n return {\n content: [{ type: \"text\" as const, text: text.trim() }],\n details: { mode: \"status\", servers, totalTools, connectedCount },\n };\n}\n\nexport async function executeAuthStart(state: McpExtensionState, serverName: string): Promise<ProxyToolResult> {\n const definition = state.config.mcpServers[serverName];\n if (!definition) {\n return {\n content: [{ type: \"text\" as const, text: `Server \"${serverName}\" not found. Use mcp({}) to see available servers.` }],\n details: { mode: \"auth-start\", error: \"not_found\", server: serverName },\n };\n }\n\n if (!definition.url || !supportsOAuth(definition)) {\n return {\n content: [{ type: \"text\" as const, text: `Server \"${serverName}\" is not configured for OAuth over HTTP.` }],\n details: { mode: \"auth-start\", error: \"oauth_not_supported\", server: serverName },\n };\n }\n\n try {\n const { authorizationUrl } = await startAuth(serverName, definition.url, definition);\n if (!authorizationUrl) {\n return {\n content: [{ type: \"text\" as const, text: `OAuth authentication successful for \"${serverName}\".` }],\n details: { mode: \"auth-start\", server: serverName, authenticated: true },\n };\n }\n\n return {\n content: [{ type: \"text\" as const, text: formatManualAuthInstructions(serverName, authorizationUrl) }],\n details: { mode: \"auth-start\", server: serverName, authorizationUrl },\n };\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error);\n return {\n content: [{ type: \"text\" as const, text: `Failed to start OAuth for \"${serverName}\": ${message}` }],\n details: { mode: \"auth-start\", error: \"auth_start_failed\", server: serverName, message },\n };\n }\n}\n\nexport async function executeAuthComplete(state: McpExtensionState, serverName: string, input: string): Promise<ProxyToolResult> {\n if (!state.config.mcpServers[serverName]) {\n return {\n content: [{ type: \"text\" as const, text: `Server \"${serverName}\" not found. Use mcp({}) to see available servers.` }],\n details: { mode: \"auth-complete\", error: \"not_found\", server: serverName },\n };\n }\n\n try {\n const status = await completeAuthFromInput(serverName, input);\n if (status !== \"authenticated\") {\n return {\n content: [{ type: \"text\" as const, text: `OAuth authentication did not complete for \"${serverName}\".` }],\n details: { mode: \"auth-complete\", error: \"not_authenticated\", server: serverName, status },\n };\n }\n\n await state.manager.close(serverName);\n state.failureTracker.delete(serverName);\n updateStatusBar(state);\n return {\n content: [{ type: \"text\" as const, text: `OAuth authentication successful for \"${serverName}\". Run mcp({ connect: \"${serverName}\" }) to connect with the new token.` }],\n details: { mode: \"auth-complete\", server: serverName, authenticated: true },\n };\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error);\n return {\n content: [{ type: \"text\" as const, text: `Failed to complete OAuth for \"${serverName}\": ${message}` }],\n details: { mode: \"auth-complete\", error: \"auth_complete_failed\", server: serverName, message },\n };\n }\n}\n\nexport function executeDescribe(state: McpExtensionState, toolName: string): ProxyToolResult {\n let serverName: string | undefined;\n let toolMeta: ToolMetadata | undefined;\n\n for (const [server, metadata] of state.toolMetadata.entries()) {\n const found = findToolByName(metadata, toolName);\n if (found) {\n serverName = server;\n toolMeta = found;\n break;\n }\n }\n\n if (!serverName || !toolMeta) {\n return {\n content: [{ type: \"text\" as const, text: `Tool \"${toolName}\" not found. Use mcp({ search: \"...\" }) to search.` }],\n details: { mode: \"describe\", error: \"tool_not_found\", requestedTool: toolName },\n };\n }\n\n let text = `${toolMeta.name}\\n`;\n text += `Server: ${serverName}\\n`;\n if (toolMeta.resourceUri) {\n text += `Type: Resource (reads from ${toolMeta.resourceUri})\\n`;\n }\n text += `\\n${toolMeta.description || \"(no description)\"}\\n`;\n\n if (toolMeta.inputSchema && !toolMeta.resourceUri) {\n text += `\\nParameters:\\n${formatSchema(toolMeta.inputSchema)}`;\n } else if (toolMeta.resourceUri) {\n text += `\\nNo parameters required (resource tool).`;\n } else {\n text += `\\nNo parameters defined.`;\n }\n\n return {\n content: [{ type: \"text\" as const, text: text.trim() }],\n details: { mode: \"describe\", tool: toolMeta, server: serverName },\n };\n}\n\nexport function executeSearch(\n state: McpExtensionState,\n query: string,\n regex?: boolean,\n server?: string,\n includeSchemas?: boolean,\n): ProxyToolResult {\n const showSchemas = includeSchemas !== false;\n\n const matches: Array<{ server: string; tool: ToolMetadata }> = [];\n\n let pattern: RegExp;\n try {\n if (regex) {\n if (query.length > MAX_REGEX_SEARCH_QUERY_LENGTH) {\n return {\n content: [{ type: \"text\" as const, text: `Regex query is too long; maximum length is ${MAX_REGEX_SEARCH_QUERY_LENGTH} characters.` }],\n details: { mode: \"search\", error: \"query_too_long\", query, maxLength: MAX_REGEX_SEARCH_QUERY_LENGTH },\n };\n }\n\n pattern = new RegExp(query, \"i\");\n let safety;\n try {\n safety = checkSync(query, \"i\", REGEX_SAFETY_CHECK_PARAMS);\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error);\n return {\n content: [{ type: \"text\" as const, text: \"Regex query rejected because safety analysis failed.\" }],\n details: { mode: \"search\", error: \"unsafe_pattern\", query, reason: message },\n };\n }\n if (safety.status !== \"safe\") {\n return {\n content: [{ type: \"text\" as const, text: `Regex query rejected as unsafe (${safety.status}).` }],\n details: { mode: \"search\", error: \"unsafe_pattern\", query, safetyStatus: safety.status },\n };\n }\n } else {\n const terms = query.trim().split(/\\s+/).filter(t => t.length > 0);\n if (terms.length === 0) {\n return {\n content: [{ type: \"text\" as const, text: \"Search query cannot be empty\" }],\n details: { mode: \"search\", error: \"empty_query\" },\n };\n }\n const escaped = terms.map(t => t.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\"));\n pattern = new RegExp(escaped.join(\"|\"), \"i\");\n }\n } catch {\n return {\n content: [{ type: \"text\" as const, text: `Invalid regex: ${query}` }],\n details: { mode: \"search\", error: \"invalid_pattern\", query },\n };\n }\n\n for (const [serverName, metadata] of state.toolMetadata.entries()) {\n if (server && serverName !== server) continue;\n for (const tool of metadata) {\n if (pattern.test(tool.name) || pattern.test(tool.description)) {\n matches.push({\n server: serverName,\n tool,\n });\n }\n }\n }\n\n const totalCount = matches.length;\n\n if (totalCount === 0) {\n const msg = server\n ? `No tools matching \"${query}\" in \"${server}\"`\n : `No tools matching \"${query}\"`;\n return {\n content: [{ type: \"text\" as const, text: msg }],\n details: { mode: \"search\", matches: [], count: 0, query },\n };\n }\n\n let text = `Found ${totalCount} tool${totalCount === 1 ? \"\" : \"s\"} matching \"${query}\":\\n\\n`;\n\n for (const match of matches) {\n if (showSchemas) {\n text += `${match.tool.name}\\n`;\n text += ` ${match.tool.description || \"(no description)\"}\\n`;\n if (match.tool.inputSchema && !match.tool.resourceUri) {\n text += `\\n Parameters:\\n${formatSchema(match.tool.inputSchema, \" \")}\\n`;\n } else if (match.tool.resourceUri) {\n text += ` No parameters (resource tool).\\n`;\n }\n text += \"\\n\";\n } else {\n text += `- ${match.tool.name}`;\n if (match.tool.description) {\n text += ` - ${truncateAtWord(match.tool.description, 50)}`;\n }\n text += \"\\n\";\n }\n }\n\n return {\n content: [{ type: \"text\" as const, text: text.trim() }],\n details: {\n mode: \"search\",\n matches: matches.map(m => ({ server: m.server, tool: m.tool.name })),\n count: totalCount,\n query,\n },\n };\n}\n\nexport function executeList(state: McpExtensionState, server: string): ProxyToolResult {\n if (!state.config.mcpServers[server]) {\n return {\n content: [{ type: \"text\" as const, text: `Server \"${server}\" not found. Use mcp({}) to see available servers.` }],\n details: { mode: \"list\", server, tools: [], count: 0, error: \"not_found\" },\n };\n }\n\n const metadata = state.toolMetadata.get(server);\n const toolNames = metadata?.map(m => m.name) ?? [];\n const connection = state.manager.getConnection(server);\n\n if (toolNames.length === 0) {\n if (connection?.status === \"connected\") {\n return {\n content: [{ type: \"text\" as const, text: `Server \"${server}\" has no tools.` }],\n details: { mode: \"list\", server, tools: [], count: 0 },\n };\n }\n if (metadata !== undefined) {\n return {\n content: [{ type: \"text\" as const, text: `Server \"${server}\" has no cached tools (not connected).` }],\n details: { mode: \"list\", server, tools: [], count: 0, cached: true },\n };\n }\n return {\n content: [{ type: \"text\" as const, text: `Server \"${server}\" is configured but not connected. Use mcp({ connect: \"${server}\" }) or /mcp reconnect ${server} to retry.` }],\n details: { mode: \"list\", server, tools: [], count: 0, error: \"not_connected\" },\n };\n }\n\n const cachedNote = connection?.status === \"connected\" ? \"\" : \" (not connected, cached)\";\n let text = `${server} (${toolNames.length} tools${cachedNote}):\\n\\n`;\n\n const descMap = new Map<string, string>();\n if (metadata) {\n for (const m of metadata) {\n descMap.set(m.name, m.description);\n }\n }\n\n for (const tool of toolNames) {\n const desc = descMap.get(tool) ?? \"\";\n const truncated = truncateAtWord(desc, 50);\n text += `- ${tool}`;\n if (truncated) text += ` - ${truncated}`;\n text += \"\\n\";\n }\n\n return {\n content: [{ type: \"text\" as const, text: text.trim() }],\n details: { mode: \"list\", server, tools: toolNames, count: toolNames.length },\n };\n}\n\nexport async function executeConnect(state: McpExtensionState, serverName: string, signal?: AbortSignal): Promise<ProxyToolResult> {\n throwIfAborted(signal);\n const definition = state.config.mcpServers[serverName];\n if (!definition) {\n return {\n content: [{ type: \"text\" as const, text: `Server \"${serverName}\" not found. Use mcp({}) to see available servers.` }],\n details: { mode: \"connect\", error: \"not_found\", server: serverName },\n };\n }\n\n try {\n if (state.ui) {\n state.ui.setStatus(\"mcp\", `MCP: connecting to ${serverName}...`);\n }\n let connection = await state.manager.connect(serverName, definition, signal);\n if (connection.status === \"needs-auth\") {\n const autoAuth = await attemptAutoAuth(state, serverName);\n if (autoAuth.status === \"failed\") {\n return {\n content: [{ type: \"text\" as const, text: autoAuth.message }],\n details: { mode: \"connect\", error: \"auth_required\", server: serverName, message: autoAuth.message },\n };\n }\n if (autoAuth.status === \"success\") {\n await state.manager.close(serverName);\n connection = await state.manager.connect(serverName, definition, signal);\n }\n if (connection.status === \"needs-auth\") {\n const message = getAuthRequiredMessage(state, serverName);\n return {\n content: [{ type: \"text\" as const, text: message }],\n details: { mode: \"connect\", error: \"auth_required\", server: serverName, message },\n };\n }\n }\n const prefix = state.config.settings?.toolPrefix ?? \"server\";\n const { metadata } = buildToolMetadata(connection.tools, connection.resources, definition, serverName, prefix);\n state.toolMetadata.set(serverName, metadata);\n updateMetadataCache(state, serverName);\n state.failureTracker.delete(serverName);\n updateStatusBar(state);\n return executeList(state, serverName);\n } catch (error) {\n if (!signal?.aborted) {\n state.failureTracker.set(serverName, Date.now());\n }\n updateStatusBar(state);\n const message = error instanceof Error ? error.message : String(error);\n return {\n content: [{ type: \"text\" as const, text: `Failed to connect to \"${serverName}\": ${message}` }],\n details: { mode: \"connect\", error: signal?.aborted ? \"aborted\" : \"connect_failed\", server: serverName, message },\n };\n }\n}\n\nexport async function executeCall(\n state: McpExtensionState,\n toolName: string,\n args?: Record<string, unknown>,\n serverOverride?: string,\n getPiTools?: () => ToolInfo[],\n signal?: AbortSignal,\n): Promise<ProxyToolResult> {\n throwIfAborted(signal);\n let serverName: string | undefined = serverOverride;\n let toolMeta: ToolMetadata | undefined;\n let autoAuthAttempted = false;\n const prefixMode = state.config.settings?.toolPrefix ?? \"server\";\n\n if (serverName && !state.config.mcpServers[serverName]) {\n return {\n content: [{ type: \"text\" as const, text: `Server \"${serverName}\" not found. Use mcp({}) to see available servers.` }],\n details: { mode: \"call\", error: \"server_not_found\", server: serverName },\n };\n }\n\n if (serverName) {\n toolMeta = findToolByName(state.toolMetadata.get(serverName), toolName);\n } else {\n for (const [server, metadata] of state.toolMetadata.entries()) {\n const found = findToolByName(metadata, toolName);\n if (found) {\n serverName = server;\n toolMeta = found;\n break;\n }\n }\n }\n\n if (serverName && !toolMeta) {\n const connected = await lazyConnect(state, serverName, signal);\n if (connected) {\n toolMeta = findToolByName(state.toolMetadata.get(serverName), toolName);\n } else {\n const needsAuthConnection = state.manager.getConnection(serverName);\n if (needsAuthConnection?.status === \"needs-auth\") {\n if (!autoAuthAttempted) {\n autoAuthAttempted = true;\n const autoAuth = await attemptAutoAuth(state, serverName);\n if (autoAuth.status === \"failed\") {\n return {\n content: [{ type: \"text\" as const, text: autoAuth.message }],\n details: { mode: \"call\", error: \"auth_required\", server: serverName, message: autoAuth.message },\n };\n }\n if (autoAuth.status === \"success\") {\n await state.manager.close(serverName);\n state.failureTracker.delete(serverName);\n const connectedAfterAuth = await lazyConnect(state, serverName, signal);\n if (connectedAfterAuth) {\n toolMeta = findToolByName(state.toolMetadata.get(serverName), toolName);\n if (!toolMeta) {\n return {\n content: [{ type: \"text\" as const, text: `Tool \"${toolName}\" not found on \"${serverName}\" after reconnect.` }],\n details: { mode: \"call\", error: \"tool_not_found_after_reconnect\", requestedTool: toolName },\n };\n }\n }\n }\n }\n\n if (!toolMeta && state.manager.getConnection(serverName)?.status === \"needs-auth\") {\n const message = getAuthRequiredMessage(state, serverName);\n return {\n content: [{ type: \"text\" as const, text: message }],\n details: { mode: \"call\", error: \"auth_required\", server: serverName, message },\n };\n }\n }\n\n if (!toolMeta) {\n const failedAgo = getFailureAgeSeconds(state, serverName);\n if (failedAgo !== null) {\n return {\n content: [{ type: \"text\" as const, text: `Server \"${serverName}\" not available (last failed ${failedAgo}s ago)` }],\n details: { mode: \"call\", error: \"server_backoff\", server: serverName },\n };\n }\n }\n }\n }\n\n let prefixMatchedServer: string | undefined;\n\n if (!serverName && !toolMeta && prefixMode !== \"none\") {\n const candidates = Object.keys(state.config.mcpServers)\n .map(name => ({ name, prefix: getServerPrefix(name, prefixMode) }))\n .filter(c => c.prefix && toolName.startsWith(c.prefix + \"_\"))\n .sort((a, b) => b.prefix.length - a.prefix.length);\n\n for (const { name: configuredServer } of candidates) {\n const existingConnection = state.manager.getConnection(configuredServer);\n const failedAgo = getFailureAgeSeconds(state, configuredServer);\n if (failedAgo !== null && existingConnection?.status !== \"needs-auth\") continue;\n\n let connected = await lazyConnect(state, configuredServer, signal);\n if (!connected && state.manager.getConnection(configuredServer)?.status === \"needs-auth\" && !autoAuthAttempted) {\n autoAuthAttempted = true;\n const autoAuth = await attemptAutoAuth(state, configuredServer);\n if (autoAuth.status === \"failed\") {\n return {\n content: [{ type: \"text\" as const, text: autoAuth.message }],\n details: { mode: \"call\", error: \"auth_required\", server: configuredServer, message: autoAuth.message },\n };\n }\n if (autoAuth.status === \"success\") {\n await state.manager.close(configuredServer);\n state.failureTracker.delete(configuredServer);\n connected = await lazyConnect(state, configuredServer, signal);\n }\n }\n\n if (!connected) continue;\n if (!prefixMatchedServer) prefixMatchedServer = configuredServer;\n toolMeta = findToolByName(state.toolMetadata.get(configuredServer), toolName);\n if (toolMeta) {\n serverName = configuredServer;\n break;\n }\n }\n }\n\n if (!serverName || !toolMeta) {\n const nativeTool = !serverOverride\n ? getPiTools?.().find((tool) => tool.name === toolName && tool.name !== \"mcp\")\n : undefined;\n if (nativeTool) {\n return {\n content: [{ type: \"text\" as const, text: `\"${toolName}\" is a native Pi tool. Call ${toolName} directly instead of using mcp({ tool: \"${toolName}\" }).` }],\n details: { mode: \"call\", error: \"native_tool\", requestedTool: toolName },\n };\n }\n\n const hintServer = serverName ?? prefixMatchedServer;\n const available = hintServer ? getToolNames(state, hintServer) : [];\n let msg = `Tool \"${toolName}\" not found.`;\n if (available.length > 0) {\n msg += ` Server \"${hintServer}\" has: ${available.join(\", \")}`;\n } else {\n msg += ` Use mcp({ search: \"...\" }) to search.`;\n }\n return {\n content: [{ type: \"text\" as const, text: msg }],\n details: { mode: \"call\", error: \"tool_not_found\", requestedTool: toolName, hintServer },\n };\n }\n\n let connection = state.manager.getConnection(serverName);\n if (connection?.status === \"needs-auth\") {\n if (!autoAuthAttempted) {\n autoAuthAttempted = true;\n const autoAuth = await attemptAutoAuth(state, serverName);\n if (autoAuth.status === \"failed\") {\n return {\n content: [{ type: \"text\" as const, text: autoAuth.message }],\n details: { mode: \"call\", error: \"auth_required\", server: serverName, message: autoAuth.message },\n };\n }\n if (autoAuth.status === \"success\") {\n await state.manager.close(serverName);\n state.failureTracker.delete(serverName);\n connection = state.manager.getConnection(serverName);\n }\n }\n\n if (connection?.status === \"needs-auth\") {\n const message = getAuthRequiredMessage(state, serverName);\n return {\n content: [{ type: \"text\" as const, text: message }],\n details: { mode: \"call\", error: \"auth_required\", server: serverName, message },\n };\n }\n }\n if (!connection || connection.status !== \"connected\") {\n const failedAgo = getFailureAgeSeconds(state, serverName);\n if (failedAgo !== null) {\n return {\n content: [{ type: \"text\" as const, text: `Server \"${serverName}\" not available (last failed ${failedAgo}s ago)` }],\n details: { mode: \"call\", error: \"server_backoff\", server: serverName },\n };\n }\n\n const definition = state.config.mcpServers[serverName];\n if (!definition) {\n return {\n content: [{ type: \"text\" as const, text: `Server \"${serverName}\" not connected` }],\n details: { mode: \"call\", error: \"server_not_connected\", server: serverName },\n };\n }\n\n try {\n if (state.ui) {\n state.ui.setStatus(\"mcp\", `MCP: connecting to ${serverName}...`);\n }\n connection = await state.manager.connect(serverName, definition, signal);\n if (connection.status === \"needs-auth\") {\n if (!autoAuthAttempted) {\n autoAuthAttempted = true;\n const autoAuth = await attemptAutoAuth(state, serverName);\n if (autoAuth.status === \"failed\") {\n return {\n content: [{ type: \"text\" as const, text: autoAuth.message }],\n details: { mode: \"call\", error: \"auth_required\", server: serverName, message: autoAuth.message },\n };\n }\n if (autoAuth.status === \"success\") {\n await state.manager.close(serverName);\n connection = await state.manager.connect(serverName, definition, signal);\n }\n }\n\n if (connection.status === \"needs-auth\") {\n const message = getAuthRequiredMessage(state, serverName);\n return {\n content: [{ type: \"text\" as const, text: message }],\n details: { mode: \"call\", error: \"auth_required\", server: serverName, message },\n };\n }\n }\n state.failureTracker.delete(serverName);\n updateServerMetadata(state, serverName);\n updateMetadataCache(state, serverName);\n updateStatusBar(state);\n toolMeta = findToolByName(state.toolMetadata.get(serverName), toolName);\n if (!toolMeta) {\n const available = getToolNames(state, serverName);\n const hint = available.length > 0\n ? `Available tools on \"${serverName}\": ${available.join(\", \")}`\n : `Server \"${serverName}\" has no tools.`;\n return {\n content: [{ type: \"text\" as const, text: `Tool \"${toolName}\" not found on \"${serverName}\" after reconnect. ${hint}` }],\n details: { mode: \"call\", error: \"tool_not_found_after_reconnect\", requestedTool: toolName },\n };\n }\n } catch (error) {\n if (!signal?.aborted) {\n state.failureTracker.set(serverName, Date.now());\n }\n updateStatusBar(state);\n const message = error instanceof Error ? error.message : String(error);\n return {\n content: [{ type: \"text\" as const, text: `Failed to connect to \"${serverName}\": ${message}` }],\n details: { mode: \"call\", error: signal?.aborted ? \"aborted\" : \"connect_failed\", message },\n };\n }\n }\n\n let uiSession: UiSessionRuntime | null = null;\n const requestOptions = state.manager.getRequestOptions?.(serverName, signal) ?? (signal ? { signal } : undefined);\n\n const outputGuardOptions = resolveMcpOutputGuardOptions(state.config.settings);\n\n try {\n state.manager.touch(serverName);\n state.manager.incrementInFlight(serverName);\n\n if (toolMeta.resourceUri) {\n const result = await connection.client.readResource({ uri: toolMeta.resourceUri }, requestOptions);\n const content = (result.contents ?? []).map(c => ({\n type: \"text\" as const,\n text: \"text\" in c ? c.text : (\"blob\" in c ? `[Binary data: ${(c as { mimeType?: string }).mimeType ?? \"unknown\"}]` : JSON.stringify(c)),\n }));\n const guarded = await guardMcpOutput(content.length > 0 ? content : [{ type: \"text\" as const, text: \"(empty resource)\" }], outputGuardOptions);\n return {\n content: guarded.content,\n details: { mode: \"call\", resourceUri: toolMeta.resourceUri, server: serverName, ...guardedMcpDetails(guarded) },\n };\n }\n\n uiSession = toolMeta.uiResourceUri\n ? await maybeStartUiSession(state, {\n serverName,\n toolName: toolMeta.originalName,\n toolArgs: args ?? {},\n uiResourceUri: toolMeta.uiResourceUri,\n streamMode: toolMeta.uiStreamMode,\n })\n : null;\n\n const resultPromise = connection.client.callTool({\n name: toolMeta.originalName,\n arguments: args ?? {},\n _meta: uiSession?.requestMeta,\n }, undefined, requestOptions);\n\n if (toolMeta.uiResourceUri) {\n const result = await abortable(resultPromise, signal);\n uiSession?.sendToolResult(result as unknown as import(\"@modelcontextprotocol/sdk/types.js\").CallToolResult);\n\n if (result.isError) {\n const mcpContent = (result.content ?? []) as McpContent[];\n const content = transformMcpContent(mcpContent);\n const outputContent = content.length > 0 ? content : [{ type: \"text\" as const, text: \"(empty result)\" }];\n const schemaText = toolMeta.inputSchema ? `\\n\\nExpected parameters:\\n${formatSchema(toolMeta.inputSchema)}` : \"\";\n const guarded = await guardMcpOutput(outputContent, { ...outputGuardOptions, prefix: \"Error: \", suffix: schemaText, emptyTextFallback: \"Tool execution failed\", rawMcpResult: result });\n return {\n content: guarded.content,\n details: { mode: \"call\", error: \"tool_error\", ...guardedMcpDetails(guarded) },\n };\n }\n\n const content = resolveMcpResultContent(result as Record<string, unknown>);\n const outputContent = content.length > 0 ? content : [{ type: \"text\" as const, text: \"(empty result)\" }];\n const uiMessage = uiSession?.reused\n ? \"Updated the open UI.\"\n : \"📺 Interactive UI is now open in your browser. I'll respond to your prompts and intents as you interact with it.\";\n const guarded = await guardMcpOutput(outputContent, { ...outputGuardOptions, suffix: `\\n\\n${uiMessage}`, rawMcpResult: result });\n return {\n content: guarded.content,\n details: { mode: \"call\", ...guardedMcpDetails(guarded), server: serverName, tool: toolMeta.originalName, uiOpen: true },\n };\n }\n\n const result = await abortable(resultPromise, signal);\n\n if (result.isError) {\n const mcpContent = (result.content ?? []) as McpContent[];\n const content = transformMcpContent(mcpContent);\n const outputContent = content.length > 0 ? content : [{ type: \"text\" as const, text: \"(empty result)\" }];\n const schemaText = toolMeta.inputSchema ? `\\n\\nExpected parameters:\\n${formatSchema(toolMeta.inputSchema)}` : \"\";\n const guarded = await guardMcpOutput(outputContent, { ...outputGuardOptions, prefix: \"Error: \", suffix: schemaText, emptyTextFallback: \"Tool execution failed\", rawMcpResult: result });\n return {\n content: guarded.content,\n details: { mode: \"call\", error: \"tool_error\", ...guardedMcpDetails(guarded) },\n };\n }\n\n const content = resolveMcpResultContent(result as Record<string, unknown>);\n const outputContent = content.length > 0 ? content : [{ type: \"text\" as const, text: \"(empty result)\" }];\n const guarded = await guardMcpOutput(outputContent, { ...outputGuardOptions, rawMcpResult: result });\n return {\n content: guarded.content,\n details: { mode: \"call\", ...guardedMcpDetails(guarded), server: serverName, tool: toolMeta.originalName },\n };\n } catch (error) {\n if (error instanceof UrlElicitationRequiredError) {\n const action = await state.manager.handleUrlElicitationRequired(serverName, error);\n const message = action === \"accept\"\n ? \"The original MCP tool did not run. Complete the opened browser interaction, then retry the tool.\"\n : `The URL interaction was ${action === \"decline\" ? \"declined\" : \"cancelled\"}.`;\n uiSession?.sendToolCancelled(message);\n return {\n content: [{ type: \"text\" as const, text: message }],\n details: { mode: \"call\", error: \"url_elicitation_required\", server: serverName, action },\n };\n }\n const message = error instanceof Error ? error.message : String(error);\n uiSession?.sendToolCancelled(message);\n\n const schemaText = toolMeta.inputSchema ? `\\n\\nExpected parameters:\\n${formatSchema(toolMeta.inputSchema)}` : \"\";\n const guarded = await guardMcpOutput([{ type: \"text\" as const, text: message }], { ...outputGuardOptions, prefix: \"Failed to call tool: \", suffix: schemaText });\n\n return {\n content: guarded.content,\n details: { mode: \"call\", error: \"call_failed\", message: guarded.outputGuard ? \"output truncated; see outputGuard.fullOutputPath\" : message, ...guardedMcpDetails(guarded) },\n };\n } finally {\n if (uiSession?.reused) {\n uiSession.close();\n }\n state.manager.decrementInFlight(serverName);\n state.manager.touch(serverName);\n }\n}\n"]}
1
+ {"version":3,"file":"proxy-modes.js","sourceRoot":"","sources":["../../../src/builtin-extensions/pi-mcp-adapter/proxy-modes.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,2BAA2B,EAAE,MAAM,oCAAoC,CAAC;AACjF,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAGpC,OAAO,EAAE,eAAe,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AACnE,OAAO,EAAE,WAAW,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAC1H,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AACvD,OAAO,EAAE,iBAAiB,EAAE,YAAY,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,oB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C,KAAK,EAAE,CAAC;QACpB,CAAC;QACD,KAAK,CAAC,OAAO,CAAC,iBAAiB,CAAC,UAAU,CAAC,CAAC;QAC5C,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;IAClC,CAAC;AAAA,CACF","sourcesContent":["// @ts-nocheck\nimport type { AgentToolResult, ToolInfo } from \"@ashx-j/lunr\";\nimport { UrlElicitationRequiredError } from \"@modelcontextprotocol/sdk/types.js\";\nimport { checkSync } from \"recheck\";\nimport type { McpExtensionState } from \"./state.ts\";\nimport type { ToolMetadata, McpContent } from \"./types.ts\";\nimport { getServerPrefix, parseUiPromptHandoff } from \"./types.ts\";\nimport { lazyConnect, updateServerMetadata, updateMetadataCache, getFailureAgeSeconds, updateStatusBar } from \"./init.ts\";\nimport { abortable, throwIfAborted } from \"./abort.ts\";\nimport { buildToolMetadata, getToolNames, findToolByName, formatSchema } from \"./tool-metadata.ts\";\nimport { resolveMcpResultContent, transformMcpContent } from \"./tool-registrar.ts\";\nimport { guardMcpOutput, guardedMcpDetails, resolveMcpOutputGuardOptions } from \"./mcp-output-guard.ts\";\nimport { maybeStartUiSession, type UiSessionRuntime } from \"./ui-session.ts\";\nimport { formatAuthRequiredMessage, truncateAtWord } from \"./utils.ts\";\nimport { authenticate, completeAuthFromInput, startAuth, supportsOAuth } from \"./mcp-auth-flow.ts\";\n\ntype ProxyToolResult = AgentToolResult<Record<string, unknown>>;\n\nconst MAX_REGEX_SEARCH_QUERY_LENGTH = 256;\nconst REGEX_SAFETY_CHECK_PARAMS = {\n attackTimeout: 50,\n incubationTimeout: 50,\n timeout: 250,\n} as const;\n\ntype AutoAuthResult =\n | { status: \"skipped\" }\n | { status: \"success\" }\n | { status: \"failed\"; message: string };\n\nfunction getAuthRequiredMessage(\n state: McpExtensionState,\n serverName: string,\n defaultMessage = `Server \"${serverName}\" requires OAuth authentication. Run mcp({ action: \"auth-start\", server: \"${serverName}\" }) to get a browser URL, or /mcp-auth ${serverName} in an interactive local session.`,\n): string {\n return formatAuthRequiredMessage(state.config, serverName, defaultMessage);\n}\n\nfunction getAuthFailedMessage(state: McpExtensionState, serverName: string, message: string): string {\n const customGuidance = state.config.settings?.authRequiredMessage;\n if (customGuidance) {\n return `OAuth authentication failed for \"${serverName}\": ${message}. ${getAuthRequiredMessage(state, serverName)}`;\n }\n return `OAuth authentication failed for \"${serverName}\": ${message}. Run mcp({ action: \"auth-start\", server: \"${serverName}\" }) to get a browser URL, or /mcp-auth ${serverName} in an interactive local session.`;\n}\n\nfunction getRedirectPort(authorizationUrl: string): number | undefined {\n try {\n const redirectUri = new URL(authorizationUrl).searchParams.get(\"redirect_uri\");\n if (!redirectUri) return undefined;\n const port = Number.parseInt(new URL(redirectUri).port, 10);\n return Number.isInteger(port) ? port : undefined;\n } catch {\n return undefined;\n }\n}\n\nfunction formatManualAuthInstructions(serverName: string, authorizationUrl: string): string {\n const port = getRedirectPort(authorizationUrl);\n const portNote = port\n ? `\\nThe redirect URL will use local port ${port}. On a remote server it is expected for that localhost page to fail locally; copy the address bar URL anyway.`\n : \"\";\n\n return [\n `MCP OAuth required for \"${serverName}\".`,\n \"\",\n \"Open this URL in your local browser:\",\n \"\",\n authorizationUrl,\n \"\",\n \"After approving, copy the full redirected localhost URL from your browser address bar and send it back with:\",\n `mcp({ action: \"auth-complete\", server: \"${serverName}\", args: '{\"redirectUrl\":\"PASTE_REDIRECT_URL_HERE\"}' })`,\n \"\",\n \"You can also pass just the `code` query parameter as `args: '{\\\"code\\\":\\\"PASTE_CODE_HERE\\\"}'`.\",\n portNote.trimEnd(),\n ].filter(Boolean).join(\"\\n\");\n}\n\nasync function attemptAutoAuth(\n state: McpExtensionState,\n serverName: string,\n): Promise<AutoAuthResult> {\n if (state.config.settings?.autoAuth !== true) {\n return { status: \"skipped\" };\n }\n\n const definition = state.config.mcpServers[serverName];\n if (!definition || !supportsOAuth(definition) || !definition.url) {\n return { status: \"skipped\" };\n }\n\n const grantType = definition.oauth ? definition.oauth.grantType ?? \"authorization_code\" : \"authorization_code\";\n if (!state.ui && grantType !== \"client_credentials\") {\n return {\n status: \"failed\",\n message: getAuthRequiredMessage(\n state,\n serverName,\n `Server \"${serverName}\" requires OAuth authentication. Run mcp({ action: \"auth-start\", server: \"${serverName}\" }) to get a browser URL, or /mcp-auth ${serverName} in an interactive local session.`,\n ),\n };\n }\n\n try {\n await authenticate(serverName, definition.url, definition);\n return { status: \"success\" };\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error);\n return {\n status: \"failed\",\n message: getAuthFailedMessage(state, serverName, message),\n };\n }\n}\n\nexport function executeUiMessages(state: McpExtensionState): ProxyToolResult {\n const sessions = state.completedUiSessions;\n\n if (sessions.length === 0) {\n return {\n content: [{ type: \"text\" as const, text: \"No UI session messages available.\" }],\n details: { sessions: 0 },\n };\n }\n\n const output: string[] = [];\n output.push(`UI Session Messages (${sessions.length} session${sessions.length > 1 ? \"s\" : \"\"}):\\n`);\n\n const allPrompts: string[] = [];\n const allIntents = sessions.flatMap((session) => session.messages.intents);\n const parsedHandoffs: Array<{ intent: string; params: Record<string, unknown>; raw: string }> = [];\n\n for (const session of sessions) {\n const timestamp = session.completedAt.toLocaleTimeString();\n output.push(`\\n## ${session.serverName} / ${session.toolName} (${timestamp}, ${session.reason})`);\n\n const plainPrompts: string[] = [];\n for (const prompt of session.messages.prompts) {\n allPrompts.push(prompt);\n const handoff = parseUiPromptHandoff(prompt);\n if (handoff) {\n parsedHandoffs.push(handoff);\n } else {\n plainPrompts.push(prompt);\n }\n }\n\n if (plainPrompts.length > 0) {\n output.push(\"\\n### Prompts:\");\n for (const prompt of plainPrompts) {\n output.push(`- ${prompt}`);\n }\n }\n\n const intentsForSession = [\n ...session.messages.intents,\n ...session.messages.prompts\n .map((prompt) => parseUiPromptHandoff(prompt))\n .filter((handoff): handoff is NonNullable<typeof handoff> => !!handoff)\n .map((handoff) => ({ intent: handoff.intent, params: handoff.params })),\n ];\n\n if (intentsForSession.length > 0) {\n output.push(\"\\n### Intents:\");\n for (const intent of intentsForSession) {\n const params = intent.params ? ` (${JSON.stringify(intent.params)})` : \"\";\n output.push(`- ${intent.intent}${params}`);\n }\n }\n\n if (session.messages.notifications.length > 0) {\n output.push(\"\\n### Notifications:\");\n for (const notification of session.messages.notifications) {\n output.push(`- ${notification}`);\n }\n }\n }\n\n const count = sessions.length;\n state.completedUiSessions = [];\n\n return {\n content: [{ type: \"text\" as const, text: output.join(\"\\n\") }],\n details: {\n sessions: count,\n prompts: allPrompts,\n intents: [...allIntents, ...parsedHandoffs.map(({ intent, params }) => ({ intent, params }))],\n handoffs: parsedHandoffs,\n cleared: true,\n },\n };\n}\n\nexport function executeStatus(state: McpExtensionState): ProxyToolResult {\n const servers: Array<{ name: string; status: string; toolCount: number; failedAgo: number | null }> = [];\n\n for (const name of Object.keys(state.config.mcpServers)) {\n const connection = state.manager.getConnection(name);\n const metadata = state.toolMetadata.get(name);\n const toolCount = metadata?.length ?? 0;\n const failedAgo = getFailureAgeSeconds(state, name);\n let status = \"not connected\";\n if (connection?.status === \"connected\") {\n status = \"connected\";\n } else if (connection?.status === \"needs-auth\") {\n status = \"needs-auth\";\n } else if (failedAgo !== null) {\n status = \"failed\";\n } else if (metadata !== undefined) {\n status = \"cached\";\n }\n\n servers.push({ name, status, toolCount, failedAgo });\n }\n\n const totalTools = servers.reduce((sum, s) => sum + s.toolCount, 0);\n const connectedCount = servers.filter(s => s.status === \"connected\").length;\n\n let text = `MCP: ${connectedCount}/${servers.length} servers, ${totalTools} tools\\n\\n`;\n for (const server of servers) {\n if (server.status === \"connected\") {\n text += `✓ ${server.name} (${server.toolCount} tools)\\n`;\n continue;\n }\n if (server.status === \"needs-auth\") {\n text += `⚠ ${server.name} (needs auth)\\n`;\n continue;\n }\n if (server.status === \"cached\") {\n text += `○ ${server.name} (${server.toolCount} tools, cached)\\n`;\n continue;\n }\n if (server.status === \"failed\") {\n text += `✗ ${server.name} (failed ${server.failedAgo ?? 0}s ago)\\n`;\n continue;\n }\n text += `○ ${server.name} (not connected)\\n`;\n }\n\n if (servers.length > 0) {\n text += `\\nmcp({ server: \"name\" }) to list tools, mcp({ search: \"...\" }) to search`;\n }\n\n return {\n content: [{ type: \"text\" as const, text: text.trim() }],\n details: { mode: \"status\", servers, totalTools, connectedCount },\n };\n}\n\nexport async function executeAuthStart(state: McpExtensionState, serverName: string): Promise<ProxyToolResult> {\n const definition = state.config.mcpServers[serverName];\n if (!definition) {\n return {\n content: [{ type: \"text\" as const, text: `Server \"${serverName}\" not found. Use mcp({}) to see available servers.` }],\n details: { mode: \"auth-start\", error: \"not_found\", server: serverName },\n };\n }\n\n if (!definition.url || !supportsOAuth(definition)) {\n return {\n content: [{ type: \"text\" as const, text: `Server \"${serverName}\" is not configured for OAuth over HTTP.` }],\n details: { mode: \"auth-start\", error: \"oauth_not_supported\", server: serverName },\n };\n }\n\n try {\n const { authorizationUrl } = await startAuth(serverName, definition.url, definition);\n if (!authorizationUrl) {\n return {\n content: [{ type: \"text\" as const, text: `OAuth authentication successful for \"${serverName}\".` }],\n details: { mode: \"auth-start\", server: serverName, authenticated: true },\n };\n }\n\n return {\n content: [{ type: \"text\" as const, text: formatManualAuthInstructions(serverName, authorizationUrl) }],\n details: { mode: \"auth-start\", server: serverName, authorizationUrl },\n };\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error);\n return {\n content: [{ type: \"text\" as const, text: `Failed to start OAuth for \"${serverName}\": ${message}` }],\n details: { mode: \"auth-start\", error: \"auth_start_failed\", server: serverName, message },\n };\n }\n}\n\nexport async function executeAuthComplete(state: McpExtensionState, serverName: string, input: string): Promise<ProxyToolResult> {\n if (!state.config.mcpServers[serverName]) {\n return {\n content: [{ type: \"text\" as const, text: `Server \"${serverName}\" not found. Use mcp({}) to see available servers.` }],\n details: { mode: \"auth-complete\", error: \"not_found\", server: serverName },\n };\n }\n\n try {\n const status = await completeAuthFromInput(serverName, input);\n if (status !== \"authenticated\") {\n return {\n content: [{ type: \"text\" as const, text: `OAuth authentication did not complete for \"${serverName}\".` }],\n details: { mode: \"auth-complete\", error: \"not_authenticated\", server: serverName, status },\n };\n }\n\n await state.manager.close(serverName);\n state.failureTracker.delete(serverName);\n updateStatusBar(state);\n return {\n content: [{ type: \"text\" as const, text: `OAuth authentication successful for \"${serverName}\". Run mcp({ connect: \"${serverName}\" }) to connect with the new token.` }],\n details: { mode: \"auth-complete\", server: serverName, authenticated: true },\n };\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error);\n return {\n content: [{ type: \"text\" as const, text: `Failed to complete OAuth for \"${serverName}\": ${message}` }],\n details: { mode: \"auth-complete\", error: \"auth_complete_failed\", server: serverName, message },\n };\n }\n}\n\nexport function executeDescribe(state: McpExtensionState, toolName: string): ProxyToolResult {\n let serverName: string | undefined;\n let toolMeta: ToolMetadata | undefined;\n\n for (const [server, metadata] of state.toolMetadata.entries()) {\n const found = findToolByName(metadata, toolName);\n if (found) {\n serverName = server;\n toolMeta = found;\n break;\n }\n }\n\n if (!serverName || !toolMeta) {\n return {\n content: [{ type: \"text\" as const, text: `Tool \"${toolName}\" not found. Use mcp({ search: \"...\" }) to search.` }],\n details: { mode: \"describe\", error: \"tool_not_found\", requestedTool: toolName },\n };\n }\n\n let text = `${toolMeta.name}\\n`;\n text += `Server: ${serverName}\\n`;\n if (toolMeta.resourceUri) {\n text += `Type: Resource (reads from ${toolMeta.resourceUri})\\n`;\n }\n text += `\\n${toolMeta.description || \"(no description)\"}\\n`;\n\n if (toolMeta.inputSchema && !toolMeta.resourceUri) {\n text += `\\nParameters:\\n${formatSchema(toolMeta.inputSchema)}`;\n } else if (toolMeta.resourceUri) {\n text += `\\nNo parameters required (resource tool).`;\n } else {\n text += `\\nNo parameters defined.`;\n }\n\n return {\n content: [{ type: \"text\" as const, text: text.trim() }],\n details: { mode: \"describe\", tool: toolMeta, server: serverName },\n };\n}\n\nexport function executeSearch(\n state: McpExtensionState,\n query: string,\n regex?: boolean,\n server?: string,\n includeSchemas?: boolean,\n): ProxyToolResult {\n const showSchemas = includeSchemas !== false;\n\n const matches: Array<{ server: string; tool: ToolMetadata }> = [];\n\n let pattern: RegExp;\n try {\n if (regex) {\n if (query.length > MAX_REGEX_SEARCH_QUERY_LENGTH) {\n return {\n content: [{ type: \"text\" as const, text: `Regex query is too long; maximum length is ${MAX_REGEX_SEARCH_QUERY_LENGTH} characters.` }],\n details: { mode: \"search\", error: \"query_too_long\", query, maxLength: MAX_REGEX_SEARCH_QUERY_LENGTH },\n };\n }\n\n pattern = new RegExp(query, \"i\");\n let safety;\n try {\n safety = checkSync(query, \"i\", REGEX_SAFETY_CHECK_PARAMS);\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error);\n return {\n content: [{ type: \"text\" as const, text: \"Regex query rejected because safety analysis failed.\" }],\n details: { mode: \"search\", error: \"unsafe_pattern\", query, reason: message },\n };\n }\n if (safety.status !== \"safe\") {\n return {\n content: [{ type: \"text\" as const, text: `Regex query rejected as unsafe (${safety.status}).` }],\n details: { mode: \"search\", error: \"unsafe_pattern\", query, safetyStatus: safety.status },\n };\n }\n } else {\n const terms = query.trim().split(/\\s+/).filter(t => t.length > 0);\n if (terms.length === 0) {\n return {\n content: [{ type: \"text\" as const, text: \"Search query cannot be empty\" }],\n details: { mode: \"search\", error: \"empty_query\" },\n };\n }\n const escaped = terms.map(t => t.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\"));\n pattern = new RegExp(escaped.join(\"|\"), \"i\");\n }\n } catch {\n return {\n content: [{ type: \"text\" as const, text: `Invalid regex: ${query}` }],\n details: { mode: \"search\", error: \"invalid_pattern\", query },\n };\n }\n\n for (const [serverName, metadata] of state.toolMetadata.entries()) {\n if (server && serverName !== server) continue;\n for (const tool of metadata) {\n if (pattern.test(tool.name) || pattern.test(tool.description)) {\n matches.push({\n server: serverName,\n tool,\n });\n }\n }\n }\n\n const totalCount = matches.length;\n\n if (totalCount === 0) {\n const msg = server\n ? `No tools matching \"${query}\" in \"${server}\"`\n : `No tools matching \"${query}\"`;\n return {\n content: [{ type: \"text\" as const, text: msg }],\n details: { mode: \"search\", matches: [], count: 0, query },\n };\n }\n\n let text = `Found ${totalCount} tool${totalCount === 1 ? \"\" : \"s\"} matching \"${query}\":\\n\\n`;\n\n for (const match of matches) {\n if (showSchemas) {\n text += `${match.tool.name}\\n`;\n text += ` ${match.tool.description || \"(no description)\"}\\n`;\n if (match.tool.inputSchema && !match.tool.resourceUri) {\n text += `\\n Parameters:\\n${formatSchema(match.tool.inputSchema, \" \")}\\n`;\n } else if (match.tool.resourceUri) {\n text += ` No parameters (resource tool).\\n`;\n }\n text += \"\\n\";\n } else {\n text += `- ${match.tool.name}`;\n if (match.tool.description) {\n text += ` - ${truncateAtWord(match.tool.description, 50)}`;\n }\n text += \"\\n\";\n }\n }\n\n return {\n content: [{ type: \"text\" as const, text: text.trim() }],\n details: {\n mode: \"search\",\n matches: matches.map(m => ({ server: m.server, tool: m.tool.name })),\n count: totalCount,\n query,\n },\n };\n}\n\nexport function executeList(state: McpExtensionState, server: string): ProxyToolResult {\n if (!state.config.mcpServers[server]) {\n return {\n content: [{ type: \"text\" as const, text: `Server \"${server}\" not found. Use mcp({}) to see available servers.` }],\n details: { mode: \"list\", server, tools: [], count: 0, error: \"not_found\" },\n };\n }\n\n const metadata = state.toolMetadata.get(server);\n const toolNames = metadata?.map(m => m.name) ?? [];\n const connection = state.manager.getConnection(server);\n\n if (toolNames.length === 0) {\n if (connection?.status === \"connected\") {\n return {\n content: [{ type: \"text\" as const, text: `Server \"${server}\" has no tools.` }],\n details: { mode: \"list\", server, tools: [], count: 0 },\n };\n }\n if (metadata !== undefined) {\n return {\n content: [{ type: \"text\" as const, text: `Server \"${server}\" has no cached tools (not connected).` }],\n details: { mode: \"list\", server, tools: [], count: 0, cached: true },\n };\n }\n return {\n content: [{ type: \"text\" as const, text: `Server \"${server}\" is configured but not connected. Use mcp({ connect: \"${server}\" }) or /mcp reconnect ${server} to retry.` }],\n details: { mode: \"list\", server, tools: [], count: 0, error: \"not_connected\" },\n };\n }\n\n const cachedNote = connection?.status === \"connected\" ? \"\" : \" (not connected, cached)\";\n let text = `${server} (${toolNames.length} tools${cachedNote}):\\n\\n`;\n\n const descMap = new Map<string, string>();\n if (metadata) {\n for (const m of metadata) {\n descMap.set(m.name, m.description);\n }\n }\n\n for (const tool of toolNames) {\n const desc = descMap.get(tool) ?? \"\";\n const truncated = truncateAtWord(desc, 50);\n text += `- ${tool}`;\n if (truncated) text += ` - ${truncated}`;\n text += \"\\n\";\n }\n\n return {\n content: [{ type: \"text\" as const, text: text.trim() }],\n details: { mode: \"list\", server, tools: toolNames, count: toolNames.length },\n };\n}\n\nexport async function executeConnect(state: McpExtensionState, serverName: string, signal?: AbortSignal): Promise<ProxyToolResult> {\n throwIfAborted(signal);\n const definition = state.config.mcpServers[serverName];\n if (!definition) {\n return {\n content: [{ type: \"text\" as const, text: `Server \"${serverName}\" not found. Use mcp({}) to see available servers.` }],\n details: { mode: \"connect\", error: \"not_found\", server: serverName },\n };\n }\n\n try {\n if (state.ui) {\n state.ui.setStatus(\"mcp\", `MCP: connecting to ${serverName}...`);\n }\n let connection = await state.manager.connect(serverName, definition, signal);\n if (connection.status === \"needs-auth\") {\n const autoAuth = await attemptAutoAuth(state, serverName);\n if (autoAuth.status === \"failed\") {\n return {\n content: [{ type: \"text\" as const, text: autoAuth.message }],\n details: { mode: \"connect\", error: \"auth_required\", server: serverName, message: autoAuth.message },\n };\n }\n if (autoAuth.status === \"success\") {\n await state.manager.close(serverName);\n connection = await state.manager.connect(serverName, definition, signal);\n }\n if (connection.status === \"needs-auth\") {\n const message = getAuthRequiredMessage(state, serverName);\n return {\n content: [{ type: \"text\" as const, text: message }],\n details: { mode: \"connect\", error: \"auth_required\", server: serverName, message },\n };\n }\n }\n const prefix = state.config.settings?.toolPrefix ?? \"server\";\n const { metadata } = buildToolMetadata(connection.tools, connection.resources, definition, serverName, prefix);\n state.toolMetadata.set(serverName, metadata);\n updateMetadataCache(state, serverName);\n state.failureTracker.delete(serverName);\n updateStatusBar(state);\n return executeList(state, serverName);\n } catch (error) {\n if (!signal?.aborted) {\n state.failureTracker.set(serverName, Date.now());\n }\n updateStatusBar(state);\n const message = error instanceof Error ? error.message : String(error);\n return {\n content: [{ type: \"text\" as const, text: `Failed to connect to \"${serverName}\": ${message}` }],\n details: { mode: \"connect\", error: signal?.aborted ? \"aborted\" : \"connect_failed\", server: serverName, message },\n };\n }\n}\n\nexport async function executeCall(\n state: McpExtensionState,\n toolName: string,\n args?: Record<string, unknown>,\n serverOverride?: string,\n getPiTools?: () => ToolInfo[],\n signal?: AbortSignal,\n): Promise<ProxyToolResult> {\n throwIfAborted(signal);\n let serverName: string | undefined = serverOverride;\n let toolMeta: ToolMetadata | undefined;\n let autoAuthAttempted = false;\n const prefixMode = state.config.settings?.toolPrefix ?? \"server\";\n\n if (serverName && !state.config.mcpServers[serverName]) {\n return {\n content: [{ type: \"text\" as const, text: `Server \"${serverName}\" not found. Use mcp({}) to see available servers.` }],\n details: { mode: \"call\", error: \"server_not_found\", server: serverName },\n };\n }\n\n if (serverName) {\n toolMeta = findToolByName(state.toolMetadata.get(serverName), toolName);\n } else {\n for (const [server, metadata] of state.toolMetadata.entries()) {\n const found = findToolByName(metadata, toolName);\n if (found) {\n serverName = server;\n toolMeta = found;\n break;\n }\n }\n }\n\n if (serverName && !toolMeta) {\n const connected = await lazyConnect(state, serverName, signal);\n if (connected) {\n toolMeta = findToolByName(state.toolMetadata.get(serverName), toolName);\n } else {\n const needsAuthConnection = state.manager.getConnection(serverName);\n if (needsAuthConnection?.status === \"needs-auth\") {\n if (!autoAuthAttempted) {\n autoAuthAttempted = true;\n const autoAuth = await attemptAutoAuth(state, serverName);\n if (autoAuth.status === \"failed\") {\n return {\n content: [{ type: \"text\" as const, text: autoAuth.message }],\n details: { mode: \"call\", error: \"auth_required\", server: serverName, message: autoAuth.message },\n };\n }\n if (autoAuth.status === \"success\") {\n await state.manager.close(serverName);\n state.failureTracker.delete(serverName);\n const connectedAfterAuth = await lazyConnect(state, serverName, signal);\n if (connectedAfterAuth) {\n toolMeta = findToolByName(state.toolMetadata.get(serverName), toolName);\n if (!toolMeta) {\n return {\n content: [{ type: \"text\" as const, text: `Tool \"${toolName}\" not found on \"${serverName}\" after reconnect.` }],\n details: { mode: \"call\", error: \"tool_not_found_after_reconnect\", requestedTool: toolName },\n };\n }\n }\n }\n }\n\n if (!toolMeta && state.manager.getConnection(serverName)?.status === \"needs-auth\") {\n const message = getAuthRequiredMessage(state, serverName);\n return {\n content: [{ type: \"text\" as const, text: message }],\n details: { mode: \"call\", error: \"auth_required\", server: serverName, message },\n };\n }\n }\n\n if (!toolMeta) {\n const failedAgo = getFailureAgeSeconds(state, serverName);\n if (failedAgo !== null) {\n return {\n content: [{ type: \"text\" as const, text: `Server \"${serverName}\" not available (last failed ${failedAgo}s ago)` }],\n details: { mode: \"call\", error: \"server_backoff\", server: serverName },\n };\n }\n }\n }\n }\n\n let prefixMatchedServer: string | undefined;\n\n if (!serverName && !toolMeta && prefixMode !== \"none\") {\n const candidates = Object.keys(state.config.mcpServers)\n .map(name => ({ name, prefix: getServerPrefix(name, prefixMode) }))\n .filter(c => c.prefix && toolName.startsWith(c.prefix + \"_\"))\n .sort((a, b) => b.prefix.length - a.prefix.length);\n\n for (const { name: configuredServer } of candidates) {\n const existingConnection = state.manager.getConnection(configuredServer);\n const failedAgo = getFailureAgeSeconds(state, configuredServer);\n if (failedAgo !== null && existingConnection?.status !== \"needs-auth\") continue;\n\n let connected = await lazyConnect(state, configuredServer, signal);\n if (!connected && state.manager.getConnection(configuredServer)?.status === \"needs-auth\" && !autoAuthAttempted) {\n autoAuthAttempted = true;\n const autoAuth = await attemptAutoAuth(state, configuredServer);\n if (autoAuth.status === \"failed\") {\n return {\n content: [{ type: \"text\" as const, text: autoAuth.message }],\n details: { mode: \"call\", error: \"auth_required\", server: configuredServer, message: autoAuth.message },\n };\n }\n if (autoAuth.status === \"success\") {\n await state.manager.close(configuredServer);\n state.failureTracker.delete(configuredServer);\n connected = await lazyConnect(state, configuredServer, signal);\n }\n }\n\n if (!connected) continue;\n if (!prefixMatchedServer) prefixMatchedServer = configuredServer;\n toolMeta = findToolByName(state.toolMetadata.get(configuredServer), toolName);\n if (toolMeta) {\n serverName = configuredServer;\n break;\n }\n }\n }\n\n if (!serverName || !toolMeta) {\n const nativeTool = !serverOverride\n ? getPiTools?.().find((tool) => tool.name === toolName && tool.name !== \"mcp\")\n : undefined;\n if (nativeTool) {\n return {\n content: [{ type: \"text\" as const, text: `\"${toolName}\" is a native Pi tool. Call ${toolName} directly instead of using mcp({ tool: \"${toolName}\" }).` }],\n details: { mode: \"call\", error: \"native_tool\", requestedTool: toolName },\n };\n }\n\n const hintServer = serverName ?? prefixMatchedServer;\n const available = hintServer ? getToolNames(state, hintServer) : [];\n let msg = `Tool \"${toolName}\" not found.`;\n if (available.length > 0) {\n msg += ` Server \"${hintServer}\" has: ${available.join(\", \")}`;\n } else {\n msg += ` Use mcp({ search: \"...\" }) to search.`;\n }\n return {\n content: [{ type: \"text\" as const, text: msg }],\n details: { mode: \"call\", error: \"tool_not_found\", requestedTool: toolName, hintServer },\n };\n }\n\n let connection = state.manager.getConnection(serverName);\n if (connection?.status === \"needs-auth\") {\n if (!autoAuthAttempted) {\n autoAuthAttempted = true;\n const autoAuth = await attemptAutoAuth(state, serverName);\n if (autoAuth.status === \"failed\") {\n return {\n content: [{ type: \"text\" as const, text: autoAuth.message }],\n details: { mode: \"call\", error: \"auth_required\", server: serverName, message: autoAuth.message },\n };\n }\n if (autoAuth.status === \"success\") {\n await state.manager.close(serverName);\n state.failureTracker.delete(serverName);\n connection = state.manager.getConnection(serverName);\n }\n }\n\n if (connection?.status === \"needs-auth\") {\n const message = getAuthRequiredMessage(state, serverName);\n return {\n content: [{ type: \"text\" as const, text: message }],\n details: { mode: \"call\", error: \"auth_required\", server: serverName, message },\n };\n }\n }\n if (!connection || connection.status !== \"connected\") {\n const failedAgo = getFailureAgeSeconds(state, serverName);\n if (failedAgo !== null) {\n return {\n content: [{ type: \"text\" as const, text: `Server \"${serverName}\" not available (last failed ${failedAgo}s ago)` }],\n details: { mode: \"call\", error: \"server_backoff\", server: serverName },\n };\n }\n\n const definition = state.config.mcpServers[serverName];\n if (!definition) {\n return {\n content: [{ type: \"text\" as const, text: `Server \"${serverName}\" not connected` }],\n details: { mode: \"call\", error: \"server_not_connected\", server: serverName },\n };\n }\n\n try {\n if (state.ui) {\n state.ui.setStatus(\"mcp\", `MCP: connecting to ${serverName}...`);\n }\n connection = await state.manager.connect(serverName, definition, signal);\n if (connection.status === \"needs-auth\") {\n if (!autoAuthAttempted) {\n autoAuthAttempted = true;\n const autoAuth = await attemptAutoAuth(state, serverName);\n if (autoAuth.status === \"failed\") {\n return {\n content: [{ type: \"text\" as const, text: autoAuth.message }],\n details: { mode: \"call\", error: \"auth_required\", server: serverName, message: autoAuth.message },\n };\n }\n if (autoAuth.status === \"success\") {\n await state.manager.close(serverName);\n connection = await state.manager.connect(serverName, definition, signal);\n }\n }\n\n if (connection.status === \"needs-auth\") {\n const message = getAuthRequiredMessage(state, serverName);\n return {\n content: [{ type: \"text\" as const, text: message }],\n details: { mode: \"call\", error: \"auth_required\", server: serverName, message },\n };\n }\n }\n state.failureTracker.delete(serverName);\n updateServerMetadata(state, serverName);\n updateMetadataCache(state, serverName);\n updateStatusBar(state);\n toolMeta = findToolByName(state.toolMetadata.get(serverName), toolName);\n if (!toolMeta) {\n const available = getToolNames(state, serverName);\n const hint = available.length > 0\n ? `Available tools on \"${serverName}\": ${available.join(\", \")}`\n : `Server \"${serverName}\" has no tools.`;\n return {\n content: [{ type: \"text\" as const, text: `Tool \"${toolName}\" not found on \"${serverName}\" after reconnect. ${hint}` }],\n details: { mode: \"call\", error: \"tool_not_found_after_reconnect\", requestedTool: toolName },\n };\n }\n } catch (error) {\n if (!signal?.aborted) {\n state.failureTracker.set(serverName, Date.now());\n }\n updateStatusBar(state);\n const message = error instanceof Error ? error.message : String(error);\n return {\n content: [{ type: \"text\" as const, text: `Failed to connect to \"${serverName}\": ${message}` }],\n details: { mode: \"call\", error: signal?.aborted ? \"aborted\" : \"connect_failed\", message },\n };\n }\n }\n\n let uiSession: UiSessionRuntime | null = null;\n const requestOptions = state.manager.getRequestOptions?.(serverName, signal) ?? (signal ? { signal } : undefined);\n\n const outputGuardOptions = resolveMcpOutputGuardOptions(state.config.settings);\n\n try {\n state.manager.touch(serverName);\n state.manager.incrementInFlight(serverName);\n\n if (toolMeta.resourceUri) {\n const result = await connection.client.readResource({ uri: toolMeta.resourceUri }, requestOptions);\n const content = (result.contents ?? []).map(c => ({\n type: \"text\" as const,\n text: \"text\" in c ? c.text : (\"blob\" in c ? `[Binary data: ${(c as { mimeType?: string }).mimeType ?? \"unknown\"}]` : JSON.stringify(c)),\n }));\n const guarded = await guardMcpOutput(content.length > 0 ? content : [{ type: \"text\" as const, text: \"(empty resource)\" }], outputGuardOptions);\n return {\n content: guarded.content,\n details: { mode: \"call\", resourceUri: toolMeta.resourceUri, server: serverName, ...guardedMcpDetails(guarded) },\n };\n }\n\n uiSession = toolMeta.uiResourceUri\n ? await maybeStartUiSession(state, {\n serverName,\n toolName: toolMeta.originalName,\n toolArgs: args ?? {},\n uiResourceUri: toolMeta.uiResourceUri,\n streamMode: toolMeta.uiStreamMode,\n })\n : null;\n\n const resultPromise = connection.client.callTool({\n name: toolMeta.originalName,\n arguments: args ?? {},\n _meta: uiSession?.requestMeta,\n }, undefined, requestOptions);\n\n if (toolMeta.uiResourceUri) {\n const result = await abortable(resultPromise, signal);\n uiSession?.sendToolResult(result as unknown as import(\"@modelcontextprotocol/sdk/types.js\").CallToolResult);\n\n if (result.isError) {\n const mcpContent = (result.content ?? []) as McpContent[];\n const content = transformMcpContent(mcpContent);\n const outputContent = content.length > 0 ? content : [{ type: \"text\" as const, text: \"(empty result)\" }];\n const schemaText = toolMeta.inputSchema ? `\\n\\nExpected parameters:\\n${formatSchema(toolMeta.inputSchema)}` : \"\";\n const guarded = await guardMcpOutput(outputContent, { ...outputGuardOptions, prefix: \"Error: \", suffix: schemaText, emptyTextFallback: \"Tool execution failed\", rawMcpResult: result });\n return {\n content: guarded.content,\n details: { mode: \"call\", error: \"tool_error\", ...guardedMcpDetails(guarded) },\n };\n }\n\n const content = resolveMcpResultContent(result as Record<string, unknown>);\n const outputContent = content.length > 0 ? content : [{ type: \"text\" as const, text: \"(empty result)\" }];\n const uiMessage = uiSession?.reused\n ? \"Updated the open UI.\"\n : \"📺 Interactive UI is now open in your browser. I'll respond to your prompts and intents as you interact with it.\";\n const guarded = await guardMcpOutput(outputContent, { ...outputGuardOptions, suffix: `\\n\\n${uiMessage}`, rawMcpResult: result });\n return {\n content: guarded.content,\n details: { mode: \"call\", ...guardedMcpDetails(guarded), server: serverName, tool: toolMeta.originalName, uiOpen: true },\n };\n }\n\n const result = await abortable(resultPromise, signal);\n\n if (result.isError) {\n const mcpContent = (result.content ?? []) as McpContent[];\n const content = transformMcpContent(mcpContent);\n const outputContent = content.length > 0 ? content : [{ type: \"text\" as const, text: \"(empty result)\" }];\n const schemaText = toolMeta.inputSchema ? `\\n\\nExpected parameters:\\n${formatSchema(toolMeta.inputSchema)}` : \"\";\n const guarded = await guardMcpOutput(outputContent, { ...outputGuardOptions, prefix: \"Error: \", suffix: schemaText, emptyTextFallback: \"Tool execution failed\", rawMcpResult: result });\n return {\n content: guarded.content,\n details: { mode: \"call\", error: \"tool_error\", ...guardedMcpDetails(guarded) },\n };\n }\n\n const content = resolveMcpResultContent(result as Record<string, unknown>);\n const outputContent = content.length > 0 ? content : [{ type: \"text\" as const, text: \"(empty result)\" }];\n const guarded = await guardMcpOutput(outputContent, { ...outputGuardOptions, rawMcpResult: result });\n return {\n content: guarded.content,\n details: { mode: \"call\", ...guardedMcpDetails(guarded), server: serverName, tool: toolMeta.originalName },\n };\n } catch (error) {\n if (error instanceof UrlElicitationRequiredError) {\n const action = await state.manager.handleUrlElicitationRequired(serverName, error);\n const message = action === \"accept\"\n ? \"The original MCP tool did not run. Complete the opened browser interaction, then retry the tool.\"\n : `The URL interaction was ${action === \"decline\" ? \"declined\" : \"cancelled\"}.`;\n uiSession?.sendToolCancelled(message);\n return {\n content: [{ type: \"text\" as const, text: message }],\n details: { mode: \"call\", error: \"url_elicitation_required\", server: serverName, action },\n };\n }\n const message = error instanceof Error ? error.message : String(error);\n uiSession?.sendToolCancelled(message);\n\n const schemaText = toolMeta.inputSchema ? `\\n\\nExpected parameters:\\n${formatSchema(toolMeta.inputSchema)}` : \"\";\n const guarded = await guardMcpOutput([{ type: \"text\" as const, text: message }], { ...outputGuardOptions, prefix: \"Failed to call tool: \", suffix: schemaText });\n\n return {\n content: guarded.content,\n details: { mode: \"call\", error: \"call_failed\", message: guarded.outputGuard ? \"output truncated; see outputGuard.fullOutputPath\" : message, ...guardedMcpDetails(guarded) },\n };\n } finally {\n if (uiSession?.reused) {\n uiSession.close();\n }\n state.manager.decrementInFlight(serverName);\n state.manager.touch(serverName);\n }\n}\n"]}
@@ -1,5 +1,5 @@
1
- import { type Api, type Model } from "@earendil-works/pi-ai/compat";
2
- import type { ExtensionUIContext, ModelRegistry } from "@earendil-works/pi-coding-agent";
1
+ import { type Api, type Model } from "@ashx-j/lunr-ai/compat";
2
+ import type { ExtensionUIContext, ModelRegistry } from "@ashx-j/lunr";
3
3
  import type { Client } from "@modelcontextprotocol/sdk/client/index.js";
4
4
  import { type CreateMessageRequest, type CreateMessageResult } from "@modelcontextprotocol/sdk/types.js";
5
5
  export interface SamplingHandlerOptions {