@herbertgao/pi-extensions 2026.9.17 → 2026.9.19

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 (307) hide show
  1. package/README.md +31 -33
  2. package/THIRD_PARTY_NOTICES.md +1 -1
  3. package/node_modules/@herbertgao/pi-bark/package.json +2 -2
  4. package/node_modules/@herbertgao/pi-cc-extensions/README.en.md +4 -1
  5. package/node_modules/@herbertgao/pi-cc-extensions/README.md +4 -1
  6. package/node_modules/@herbertgao/pi-cc-extensions/extensions/feature/shell/working-message.ts +21 -6
  7. package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/index.ts +15 -4
  8. package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/tool/diff/index.ts +43 -7
  9. package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/tool/grouping.ts +7 -2
  10. package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/tool/result.ts +1 -1
  11. package/node_modules/@herbertgao/pi-cc-extensions/package.json +75 -75
  12. package/node_modules/@herbertgao/pi-subagents/CHANGELOG.md +6 -0
  13. package/node_modules/@herbertgao/pi-subagents/package.json +7 -7
  14. package/node_modules/@herbertgao/resume-from/package.json +4 -2
  15. package/node_modules/@herbertgao/sol-pi/package.json +6 -6
  16. package/node_modules/@juicesharp/rpiv-ask-user-question/package.json +99 -99
  17. package/node_modules/@pi-plugins/fast-mode/package.json +1 -1
  18. package/node_modules/@tifan/pi-handoff/package.json +1 -1
  19. package/node_modules/@tifan/pi-handoff/src/index.ts +56 -26
  20. package/node_modules/@tifan/pi-mermaid-open/package.json +1 -1
  21. package/node_modules/@tifan/pi-preferred-thinking/package.json +1 -1
  22. package/node_modules/@tifan/pi-recap/package.json +1 -1
  23. package/node_modules/@tifan/pi-rename/package.json +1 -1
  24. package/node_modules/pi-antigravity/README.md +29 -6
  25. package/node_modules/pi-antigravity/package.json +14 -9
  26. package/node_modules/pi-antigravity/src/auth/accounts.ts +327 -0
  27. package/node_modules/pi-antigravity/src/auth/index.ts +9 -0
  28. package/node_modules/pi-antigravity/src/client/client.ts +1 -1
  29. package/node_modules/pi-antigravity/src/image/image.ts +4 -4
  30. package/node_modules/pi-antigravity/src/index.ts +203 -13
  31. package/node_modules/pi-antigravity/src/search/index.ts +1 -0
  32. package/node_modules/pi-antigravity/src/search/search.ts +325 -0
  33. package/node_modules/pi-antigravity/src/stream/stream.ts +191 -14
  34. package/node_modules/pi-antigravity/src/types/enums.ts +45 -36
  35. package/node_modules/pi-antigravity/src/types/types.ts +5 -12
  36. package/node_modules/pi-antigravity/src/utils/http.ts +7 -2
  37. package/node_modules/pi-antigravity/src/utils/util.ts +31 -3
  38. package/node_modules/pi-lens/package.json +158 -158
  39. package/node_modules/pi-multi-account/package.json +2 -2
  40. package/node_modules/pi-typesafe/README.md +3 -1
  41. package/node_modules/pi-typesafe/dist/auth.d.ts +9 -5
  42. package/node_modules/pi-typesafe/dist/auth.js +7 -3
  43. package/node_modules/pi-typesafe/dist/backends.d.ts +33 -3
  44. package/node_modules/pi-typesafe/dist/backends.js +95 -1
  45. package/node_modules/pi-typesafe/dist/client.d.ts +5 -5
  46. package/node_modules/pi-typesafe/dist/client.js +12 -9
  47. package/node_modules/pi-typesafe/dist/credentials.d.ts +14 -8
  48. package/node_modules/pi-typesafe/dist/credentials.js +10 -7
  49. package/node_modules/pi-typesafe/dist/errors.d.ts +2 -2
  50. package/node_modules/pi-typesafe/dist/index.d.ts +2 -2
  51. package/node_modules/pi-typesafe/dist/index.js +1 -1
  52. package/node_modules/pi-typesafe/dist/login.d.ts +2 -2
  53. package/node_modules/pi-typesafe/dist/login.js +2 -2
  54. package/node_modules/pi-typesafe/package.json +6 -5
  55. package/node_modules/pi-web-access/CHANGELOG.md +72 -0
  56. package/node_modules/pi-web-access/README.md +34 -13
  57. package/node_modules/pi-web-access/chrome-cookies.ts +79 -25
  58. package/node_modules/pi-web-access/curator-page.ts +5 -1
  59. package/node_modules/pi-web-access/curator-server.ts +2 -0
  60. package/node_modules/pi-web-access/dist/index.js +1337 -1009
  61. package/node_modules/pi-web-access/exa.ts +20 -52
  62. package/node_modules/pi-web-access/extract.ts +41 -4
  63. package/node_modules/pi-web-access/gemini-search.ts +12 -4
  64. package/node_modules/pi-web-access/index.ts +29 -37
  65. package/node_modules/pi-web-access/openai-search.ts +35 -7
  66. package/node_modules/pi-web-access/package.json +8 -7
  67. package/node_modules/pi-web-access/page-query.ts +2 -2
  68. package/node_modules/pi-web-access/query-rewrite.ts +2 -3
  69. package/node_modules/pi-web-access/ssrf-protection.ts +27 -10
  70. package/node_modules/pi-web-access/storage.ts +48 -77
  71. package/node_modules/pi-web-access/summary-model-scope.ts +6 -77
  72. package/node_modules/pi-web-access/summary-review.ts +3 -4
  73. package/node_modules/pi-web-access/tavily.ts +67 -20
  74. package/node_modules/pi-web-access/tool-activation.ts +53 -33
  75. package/node_modules/pi-web-access/utils.ts +1 -1
  76. package/node_modules/pi-web-access/you.ts +164 -0
  77. package/node_modules/pi-web-access/zai.ts +161 -0
  78. package/node_modules/remote-pi/package.json +5 -1
  79. package/package.json +19 -31
  80. package/node_modules/pi-mcp-adapter/CHANGELOG.md +0 -1013
  81. package/node_modules/pi-mcp-adapter/LICENSE +0 -21
  82. package/node_modules/pi-mcp-adapter/OAUTH.md +0 -369
  83. package/node_modules/pi-mcp-adapter/README.md +0 -1021
  84. package/node_modules/pi-mcp-adapter/abort.ts +0 -34
  85. package/node_modules/pi-mcp-adapter/agent-dir.ts +0 -68
  86. package/node_modules/pi-mcp-adapter/agent-plugin-loader.ts +0 -416
  87. package/node_modules/pi-mcp-adapter/agent-plugin-provenance.ts +0 -36
  88. package/node_modules/pi-mcp-adapter/app-bridge.bundle.js +0 -67
  89. package/node_modules/pi-mcp-adapter/banner.png +0 -0
  90. package/node_modules/pi-mcp-adapter/bearer-command-resolver.ts +0 -193
  91. package/node_modules/pi-mcp-adapter/claude-plugin-loader.ts +0 -365
  92. package/node_modules/pi-mcp-adapter/cli.js +0 -454
  93. package/node_modules/pi-mcp-adapter/commands.ts +0 -861
  94. package/node_modules/pi-mcp-adapter/config.ts +0 -1565
  95. package/node_modules/pi-mcp-adapter/consent-manager.ts +0 -95
  96. package/node_modules/pi-mcp-adapter/direct-tool-surface.ts +0 -244
  97. package/node_modules/pi-mcp-adapter/direct-tools.ts +0 -428
  98. package/node_modules/pi-mcp-adapter/dist/abort.d.ts +0 -2
  99. package/node_modules/pi-mcp-adapter/dist/abort.js +0 -36
  100. package/node_modules/pi-mcp-adapter/dist/abort.js.map +0 -1
  101. package/node_modules/pi-mcp-adapter/dist/agent-dir.d.ts +0 -10
  102. package/node_modules/pi-mcp-adapter/dist/agent-dir.js +0 -63
  103. package/node_modules/pi-mcp-adapter/dist/agent-dir.js.map +0 -1
  104. package/node_modules/pi-mcp-adapter/dist/agent-plugin-loader.d.ts +0 -8
  105. package/node_modules/pi-mcp-adapter/dist/agent-plugin-loader.js +0 -398
  106. package/node_modules/pi-mcp-adapter/dist/agent-plugin-loader.js.map +0 -1
  107. package/node_modules/pi-mcp-adapter/dist/agent-plugin-provenance.d.ts +0 -1
  108. package/node_modules/pi-mcp-adapter/dist/agent-plugin-provenance.js +0 -31
  109. package/node_modules/pi-mcp-adapter/dist/agent-plugin-provenance.js.map +0 -1
  110. package/node_modules/pi-mcp-adapter/dist/bearer-command-resolver.d.ts +0 -6
  111. package/node_modules/pi-mcp-adapter/dist/bearer-command-resolver.js +0 -194
  112. package/node_modules/pi-mcp-adapter/dist/bearer-command-resolver.js.map +0 -1
  113. package/node_modules/pi-mcp-adapter/dist/claude-plugin-loader.d.ts +0 -9
  114. package/node_modules/pi-mcp-adapter/dist/claude-plugin-loader.js +0 -362
  115. package/node_modules/pi-mcp-adapter/dist/claude-plugin-loader.js.map +0 -1
  116. package/node_modules/pi-mcp-adapter/dist/config.d.ts +0 -134
  117. package/node_modules/pi-mcp-adapter/dist/config.js +0 -1361
  118. package/node_modules/pi-mcp-adapter/dist/config.js.map +0 -1
  119. package/node_modules/pi-mcp-adapter/dist/consent-manager.d.ts +0 -18
  120. package/node_modules/pi-mcp-adapter/dist/consent-manager.js +0 -88
  121. package/node_modules/pi-mcp-adapter/dist/consent-manager.js.map +0 -1
  122. package/node_modules/pi-mcp-adapter/dist/elicitation-handler.d.ts +0 -17
  123. package/node_modules/pi-mcp-adapter/dist/elicitation-handler.js +0 -316
  124. package/node_modules/pi-mcp-adapter/dist/elicitation-handler.js.map +0 -1
  125. package/node_modules/pi-mcp-adapter/dist/errors.d.ts +0 -131
  126. package/node_modules/pi-mcp-adapter/dist/errors.js +0 -278
  127. package/node_modules/pi-mcp-adapter/dist/errors.js.map +0 -1
  128. package/node_modules/pi-mcp-adapter/dist/http-ca.d.ts +0 -8
  129. package/node_modules/pi-mcp-adapter/dist/http-ca.js +0 -88
  130. package/node_modules/pi-mcp-adapter/dist/http-ca.js.map +0 -1
  131. package/node_modules/pi-mcp-adapter/dist/jev-client.d.ts +0 -14
  132. package/node_modules/pi-mcp-adapter/dist/jev-client.js +0 -367
  133. package/node_modules/pi-mcp-adapter/dist/jev-client.js.map +0 -1
  134. package/node_modules/pi-mcp-adapter/dist/jev-contracts.d.ts +0 -77
  135. package/node_modules/pi-mcp-adapter/dist/jev-contracts.js +0 -2
  136. package/node_modules/pi-mcp-adapter/dist/jev-contracts.js.map +0 -1
  137. package/node_modules/pi-mcp-adapter/dist/jev-key-store.d.ts +0 -51
  138. package/node_modules/pi-mcp-adapter/dist/jev-key-store.js +0 -205
  139. package/node_modules/pi-mcp-adapter/dist/jev-key-store.js.map +0 -1
  140. package/node_modules/pi-mcp-adapter/dist/json-schema-validator.d.ts +0 -2
  141. package/node_modules/pi-mcp-adapter/dist/json-schema-validator.js +0 -68
  142. package/node_modules/pi-mcp-adapter/dist/json-schema-validator.js.map +0 -1
  143. package/node_modules/pi-mcp-adapter/dist/lifecycle.d.ts +0 -56
  144. package/node_modules/pi-mcp-adapter/dist/lifecycle.js +0 -410
  145. package/node_modules/pi-mcp-adapter/dist/lifecycle.js.map +0 -1
  146. package/node_modules/pi-mcp-adapter/dist/logger.d.ts +0 -51
  147. package/node_modules/pi-mcp-adapter/dist/logger.js +0 -131
  148. package/node_modules/pi-mcp-adapter/dist/logger.js.map +0 -1
  149. package/node_modules/pi-mcp-adapter/dist/mcp-auth-fetch.d.ts +0 -26
  150. package/node_modules/pi-mcp-adapter/dist/mcp-auth-fetch.js +0 -103
  151. package/node_modules/pi-mcp-adapter/dist/mcp-auth-fetch.js.map +0 -1
  152. package/node_modules/pi-mcp-adapter/dist/mcp-auth-flow.d.ts +0 -118
  153. package/node_modules/pi-mcp-adapter/dist/mcp-auth-flow.js +0 -1097
  154. package/node_modules/pi-mcp-adapter/dist/mcp-auth-flow.js.map +0 -1
  155. package/node_modules/pi-mcp-adapter/dist/mcp-auth.d.ts +0 -170
  156. package/node_modules/pi-mcp-adapter/dist/mcp-auth.js +0 -1142
  157. package/node_modules/pi-mcp-adapter/dist/mcp-auth.js.map +0 -1
  158. package/node_modules/pi-mcp-adapter/dist/mcp-bearer-store.d.ts +0 -24
  159. package/node_modules/pi-mcp-adapter/dist/mcp-bearer-store.js +0 -203
  160. package/node_modules/pi-mcp-adapter/dist/mcp-bearer-store.js.map +0 -1
  161. package/node_modules/pi-mcp-adapter/dist/mcp-callback-server.d.ts +0 -53
  162. package/node_modules/pi-mcp-adapter/dist/mcp-callback-server.js +0 -441
  163. package/node_modules/pi-mcp-adapter/dist/mcp-callback-server.js.map +0 -1
  164. package/node_modules/pi-mcp-adapter/dist/mcp-oauth-provider.d.ts +0 -148
  165. package/node_modules/pi-mcp-adapter/dist/mcp-oauth-provider.js +0 -689
  166. package/node_modules/pi-mcp-adapter/dist/mcp-oauth-provider.js.map +0 -1
  167. package/node_modules/pi-mcp-adapter/dist/mcp-probe.d.ts +0 -6
  168. package/node_modules/pi-mcp-adapter/dist/mcp-probe.js +0 -166
  169. package/node_modules/pi-mcp-adapter/dist/mcp-probe.js.map +0 -1
  170. package/node_modules/pi-mcp-adapter/dist/mcp-tasks.d.ts +0 -102
  171. package/node_modules/pi-mcp-adapter/dist/mcp-tasks.js +0 -369
  172. package/node_modules/pi-mcp-adapter/dist/mcp-tasks.js.map +0 -1
  173. package/node_modules/pi-mcp-adapter/dist/mcp-trace.d.ts +0 -95
  174. package/node_modules/pi-mcp-adapter/dist/mcp-trace.js +0 -242
  175. package/node_modules/pi-mcp-adapter/dist/mcp-trace.js.map +0 -1
  176. package/node_modules/pi-mcp-adapter/dist/metadata-cache.d.ts +0 -19
  177. package/node_modules/pi-mcp-adapter/dist/metadata-cache.js +0 -301
  178. package/node_modules/pi-mcp-adapter/dist/metadata-cache.js.map +0 -1
  179. package/node_modules/pi-mcp-adapter/dist/npx-resolver.d.ts +0 -6
  180. package/node_modules/pi-mcp-adapter/dist/npx-resolver.js +0 -505
  181. package/node_modules/pi-mcp-adapter/dist/npx-resolver.js.map +0 -1
  182. package/node_modules/pi-mcp-adapter/dist/package-mcp-loader.d.ts +0 -2
  183. package/node_modules/pi-mcp-adapter/dist/package-mcp-loader.js +0 -144
  184. package/node_modules/pi-mcp-adapter/dist/package-mcp-loader.js.map +0 -1
  185. package/node_modules/pi-mcp-adapter/dist/request-headers-command.d.ts +0 -10
  186. package/node_modules/pi-mcp-adapter/dist/request-headers-command.js +0 -312
  187. package/node_modules/pi-mcp-adapter/dist/request-headers-command.js.map +0 -1
  188. package/node_modules/pi-mcp-adapter/dist/resource-tools.d.ts +0 -1
  189. package/node_modules/pi-mcp-adapter/dist/resource-tools.js +0 -15
  190. package/node_modules/pi-mcp-adapter/dist/resource-tools.js.map +0 -1
  191. package/node_modules/pi-mcp-adapter/dist/runtime-owner.d.ts +0 -13
  192. package/node_modules/pi-mcp-adapter/dist/runtime-owner.js +0 -97
  193. package/node_modules/pi-mcp-adapter/dist/runtime-owner.js.map +0 -1
  194. package/node_modules/pi-mcp-adapter/dist/sampling-handler.d.ts +0 -17
  195. package/node_modules/pi-mcp-adapter/dist/sampling-handler.js +0 -203
  196. package/node_modules/pi-mcp-adapter/dist/sampling-handler.js.map +0 -1
  197. package/node_modules/pi-mcp-adapter/dist/secure-keyring.d.ts +0 -11
  198. package/node_modules/pi-mcp-adapter/dist/secure-keyring.js +0 -172
  199. package/node_modules/pi-mcp-adapter/dist/secure-keyring.js.map +0 -1
  200. package/node_modules/pi-mcp-adapter/dist/server-manager.d.ts +0 -157
  201. package/node_modules/pi-mcp-adapter/dist/server-manager.js +0 -1745
  202. package/node_modules/pi-mcp-adapter/dist/server-manager.js.map +0 -1
  203. package/node_modules/pi-mcp-adapter/dist/session-approvals.d.ts +0 -34
  204. package/node_modules/pi-mcp-adapter/dist/session-approvals.js +0 -140
  205. package/node_modules/pi-mcp-adapter/dist/session-approvals.js.map +0 -1
  206. package/node_modules/pi-mcp-adapter/dist/session-recovery.d.ts +0 -26
  207. package/node_modules/pi-mcp-adapter/dist/session-recovery.js +0 -142
  208. package/node_modules/pi-mcp-adapter/dist/session-recovery.js.map +0 -1
  209. package/node_modules/pi-mcp-adapter/dist/state.d.ts +0 -73
  210. package/node_modules/pi-mcp-adapter/dist/state.js +0 -2
  211. package/node_modules/pi-mcp-adapter/dist/state.js.map +0 -1
  212. package/node_modules/pi-mcp-adapter/dist/types.d.ts +0 -642
  213. package/node_modules/pi-mcp-adapter/dist/types.js +0 -331
  214. package/node_modules/pi-mcp-adapter/dist/types.js.map +0 -1
  215. package/node_modules/pi-mcp-adapter/dist/ui-app-bridge-helpers.d.ts +0 -6
  216. package/node_modules/pi-mcp-adapter/dist/ui-app-bridge-helpers.js +0 -37
  217. package/node_modules/pi-mcp-adapter/dist/ui-app-bridge-helpers.js.map +0 -1
  218. package/node_modules/pi-mcp-adapter/dist/ui-resource-handler.d.ts +0 -17
  219. package/node_modules/pi-mcp-adapter/dist/ui-resource-handler.js +0 -219
  220. package/node_modules/pi-mcp-adapter/dist/ui-resource-handler.js.map +0 -1
  221. package/node_modules/pi-mcp-adapter/dist/ui-stream-types.d.ts +0 -104
  222. package/node_modules/pi-mcp-adapter/dist/ui-stream-types.js +0 -59
  223. package/node_modules/pi-mcp-adapter/dist/ui-stream-types.js.map +0 -1
  224. package/node_modules/pi-mcp-adapter/dist/ui-tool-visibility.d.ts +0 -4
  225. package/node_modules/pi-mcp-adapter/dist/ui-tool-visibility.js +0 -27
  226. package/node_modules/pi-mcp-adapter/dist/ui-tool-visibility.js.map +0 -1
  227. package/node_modules/pi-mcp-adapter/dist/unix-socket-transport.d.ts +0 -15
  228. package/node_modules/pi-mcp-adapter/dist/unix-socket-transport.js +0 -85
  229. package/node_modules/pi-mcp-adapter/dist/unix-socket-transport.js.map +0 -1
  230. package/node_modules/pi-mcp-adapter/dist/utils.d.ts +0 -41
  231. package/node_modules/pi-mcp-adapter/dist/utils.js +0 -417
  232. package/node_modules/pi-mcp-adapter/dist/utils.js.map +0 -1
  233. package/node_modules/pi-mcp-adapter/elicitation-handler.ts +0 -358
  234. package/node_modules/pi-mcp-adapter/error-signal.ts +0 -32
  235. package/node_modules/pi-mcp-adapter/errors.ts +0 -364
  236. package/node_modules/pi-mcp-adapter/examples/jev-accessibility-loop.mjs +0 -85
  237. package/node_modules/pi-mcp-adapter/examples/jev-semantic-filter.mjs +0 -34
  238. package/node_modules/pi-mcp-adapter/failure-backoff.ts +0 -23
  239. package/node_modules/pi-mcp-adapter/glimpse-ui.ts +0 -80
  240. package/node_modules/pi-mcp-adapter/host-html-template.ts +0 -515
  241. package/node_modules/pi-mcp-adapter/http-ca.ts +0 -84
  242. package/node_modules/pi-mcp-adapter/index.ts +0 -2106
  243. package/node_modules/pi-mcp-adapter/init.ts +0 -721
  244. package/node_modules/pi-mcp-adapter/jev-client.ts +0 -300
  245. package/node_modules/pi-mcp-adapter/jev-contracts.ts +0 -53
  246. package/node_modules/pi-mcp-adapter/jev-key-store.ts +0 -192
  247. package/node_modules/pi-mcp-adapter/json-schema-validator.ts +0 -83
  248. package/node_modules/pi-mcp-adapter/lazy-loader.ts +0 -7
  249. package/node_modules/pi-mcp-adapter/lifecycle.ts +0 -457
  250. package/node_modules/pi-mcp-adapter/logger.ts +0 -169
  251. package/node_modules/pi-mcp-adapter/mcp-auth-fetch.ts +0 -113
  252. package/node_modules/pi-mcp-adapter/mcp-auth-flow.ts +0 -1296
  253. package/node_modules/pi-mcp-adapter/mcp-auth.ts +0 -1287
  254. package/node_modules/pi-mcp-adapter/mcp-bearer-store.ts +0 -250
  255. package/node_modules/pi-mcp-adapter/mcp-callback-server.ts +0 -534
  256. package/node_modules/pi-mcp-adapter/mcp-code.ts +0 -495
  257. package/node_modules/pi-mcp-adapter/mcp-install.ts +0 -60
  258. package/node_modules/pi-mcp-adapter/mcp-keyring-helper.cjs +0 -89
  259. package/node_modules/pi-mcp-adapter/mcp-oauth-provider.ts +0 -819
  260. package/node_modules/pi-mcp-adapter/mcp-output-guard.ts +0 -511
  261. package/node_modules/pi-mcp-adapter/mcp-panel-theme.ts +0 -104
  262. package/node_modules/pi-mcp-adapter/mcp-panel.ts +0 -1099
  263. package/node_modules/pi-mcp-adapter/mcp-probe.ts +0 -201
  264. package/node_modules/pi-mcp-adapter/mcp-references.ts +0 -373
  265. package/node_modules/pi-mcp-adapter/mcp-script-worker.mjs +0 -137
  266. package/node_modules/pi-mcp-adapter/mcp-setup-panel.ts +0 -747
  267. package/node_modules/pi-mcp-adapter/mcp-status.ts +0 -105
  268. package/node_modules/pi-mcp-adapter/mcp-tasks.ts +0 -467
  269. package/node_modules/pi-mcp-adapter/mcp-trace.ts +0 -306
  270. package/node_modules/pi-mcp-adapter/metadata-cache.ts +0 -362
  271. package/node_modules/pi-mcp-adapter/namespace-tools.ts +0 -334
  272. package/node_modules/pi-mcp-adapter/npx-resolver.ts +0 -543
  273. package/node_modules/pi-mcp-adapter/oauth-handler.ts +0 -30
  274. package/node_modules/pi-mcp-adapter/oauth.ts +0 -52
  275. package/node_modules/pi-mcp-adapter/onboarding-state.ts +0 -76
  276. package/node_modules/pi-mcp-adapter/package-mcp-loader.ts +0 -156
  277. package/node_modules/pi-mcp-adapter/package.json +0 -219
  278. package/node_modules/pi-mcp-adapter/panel-keys.ts +0 -53
  279. package/node_modules/pi-mcp-adapter/prompts.ts +0 -385
  280. package/node_modules/pi-mcp-adapter/proxy-modes.ts +0 -1735
  281. package/node_modules/pi-mcp-adapter/request-headers-command.ts +0 -333
  282. package/node_modules/pi-mcp-adapter/resource-tools.ts +0 -17
  283. package/node_modules/pi-mcp-adapter/runtime-owner.ts +0 -106
  284. package/node_modules/pi-mcp-adapter/sampling-handler.ts +0 -261
  285. package/node_modules/pi-mcp-adapter/sandbox-proxy-template.ts +0 -144
  286. package/node_modules/pi-mcp-adapter/search-ranking.ts +0 -309
  287. package/node_modules/pi-mcp-adapter/secure-keyring.ts +0 -170
  288. package/node_modules/pi-mcp-adapter/semantic-search.ts +0 -186
  289. package/node_modules/pi-mcp-adapter/server-manager.ts +0 -2088
  290. package/node_modules/pi-mcp-adapter/session-approvals.ts +0 -201
  291. package/node_modules/pi-mcp-adapter/session-recovery.ts +0 -158
  292. package/node_modules/pi-mcp-adapter/skills/mcp-scripting/SKILL.md +0 -49
  293. package/node_modules/pi-mcp-adapter/state.ts +0 -71
  294. package/node_modules/pi-mcp-adapter/tool-approval.ts +0 -205
  295. package/node_modules/pi-mcp-adapter/tool-metadata.ts +0 -302
  296. package/node_modules/pi-mcp-adapter/tool-registrar.ts +0 -255
  297. package/node_modules/pi-mcp-adapter/tool-result-renderer.ts +0 -573
  298. package/node_modules/pi-mcp-adapter/ts-shape.ts +0 -149
  299. package/node_modules/pi-mcp-adapter/types.ts +0 -1120
  300. package/node_modules/pi-mcp-adapter/ui-app-bridge-helpers.ts +0 -40
  301. package/node_modules/pi-mcp-adapter/ui-resource-handler.ts +0 -266
  302. package/node_modules/pi-mcp-adapter/ui-server.ts +0 -993
  303. package/node_modules/pi-mcp-adapter/ui-session.ts +0 -624
  304. package/node_modules/pi-mcp-adapter/ui-stream-types.ts +0 -89
  305. package/node_modules/pi-mcp-adapter/ui-tool-visibility.ts +0 -25
  306. package/node_modules/pi-mcp-adapter/unix-socket-transport.ts +0 -85
  307. package/node_modules/pi-mcp-adapter/utils.ts +0 -464
@@ -1,203 +0,0 @@
1
- import { truncateAtWord } from "./utils.js";
2
- import { throwIfAborted } from "./abort.js";
3
- export function registerSamplingHandler(client, options) {
4
- client.setRequestHandler("sampling/createMessage", request => {
5
- return handleSamplingRequest(options, request);
6
- });
7
- }
8
- export async function handleSamplingRequest(options, request) {
9
- const params = request.params;
10
- const signal = options.getSignal();
11
- throwIfAborted(signal);
12
- if ("task" in params && params.task) {
13
- throw new Error("MCP sampling tasks are not supported");
14
- }
15
- if (params.includeContext && params.includeContext !== "none") {
16
- throw new Error("MCP sampling context inclusion is not supported");
17
- }
18
- if (params.tools?.length) {
19
- throw new Error("MCP sampling tool use is not supported");
20
- }
21
- if (params.toolChoice) {
22
- throw new Error("MCP sampling tool choice is not supported");
23
- }
24
- if (params.stopSequences?.length) {
25
- throw new Error("MCP sampling stop sequences are not supported");
26
- }
27
- const messages = params.messages.map(convertSamplingMessage);
28
- const model = resolveSamplingModel(options, params.modelPreferences);
29
- throwIfAborted(signal);
30
- await confirmSampling(options, "Approve MCP sampling request", formatRequestApproval(options.serverName, `${model.provider}/${model.id}`, params.systemPrompt, messages));
31
- throwIfAborted(signal);
32
- const result = await options.modelRegistry.complete(model, {
33
- ...(params.systemPrompt !== undefined ? { systemPrompt: params.systemPrompt } : {}),
34
- messages,
35
- }, {
36
- maxTokens: params.maxTokens,
37
- ...(params.temperature !== undefined ? { temperature: params.temperature } : {}),
38
- ...(params.metadata !== undefined ? { metadata: params.metadata } : {}),
39
- ...(signal ? { signal } : {}),
40
- });
41
- const converted = convertAssistantResult(result);
42
- throwIfAborted(signal);
43
- await confirmSampling(options, "Return MCP sampling response", formatResponseApproval(options.serverName, converted));
44
- return converted;
45
- }
46
- function formatRequestApproval(serverName, modelName, systemPrompt, messages) {
47
- const lines = [`${serverName} wants to sample ${messages.length} message${messages.length === 1 ? "" : "s"} with ${modelName}.`];
48
- if (systemPrompt) {
49
- lines.push(`System: ${truncateAtWord(systemPrompt, 400)}`);
50
- }
51
- for (const [index, message] of messages.entries()) {
52
- lines.push(`${index + 1}. ${message.role}: ${truncateAtWord(messageText(message), 400)}`);
53
- }
54
- return lines.join("\n\n");
55
- }
56
- function formatResponseApproval(serverName, response) {
57
- const text = response.content.type === "text" ? response.content.text : `[${response.content.type} content]`;
58
- return `${serverName} will receive this response from ${response.model}:\n\n${truncateAtWord(text, 1000)}`;
59
- }
60
- function messageText(message) {
61
- if (typeof message.content === "string")
62
- return message.content;
63
- return message.content.map((block) => {
64
- if (block.type === "text")
65
- return block.text;
66
- if (block.type === "image")
67
- return `[image: ${block.mimeType}]`;
68
- if (block.type === "thinking")
69
- return "[thinking]";
70
- if (block.type === "toolCall")
71
- return `[tool call: ${block.name}]`;
72
- return "[content]";
73
- }).join("\n");
74
- }
75
- function resolveSamplingModel(options, modelPreferences) {
76
- const candidates = [];
77
- const availableModels = options.modelRegistry.getAvailable();
78
- for (const hint of modelPreferences?.hints ?? []) {
79
- const normalizedHint = hint.name?.trim().toLowerCase();
80
- if (!normalizedHint)
81
- continue;
82
- for (const model of availableModels) {
83
- const searchableNames = [`${model.provider}/${model.id}`, model.id, model.name];
84
- if (searchableNames.some((name) => name.toLowerCase().includes(normalizedHint))) {
85
- addSamplingCandidate(candidates, model);
86
- }
87
- }
88
- }
89
- const currentModel = options.getCurrentModel();
90
- if (currentModel)
91
- addSamplingCandidate(candidates, currentModel);
92
- for (const model of availableModels) {
93
- addSamplingCandidate(candidates, model);
94
- }
95
- const signal = options.getSignal();
96
- throwIfAborted(signal);
97
- const model = candidates[0];
98
- if (model)
99
- return model;
100
- throw new Error("No Pi model is available for MCP sampling");
101
- }
102
- function addSamplingCandidate(candidates, model) {
103
- if (!candidates.some((candidate) => candidate.provider === model.provider && candidate.id === model.id)) {
104
- candidates.push(model);
105
- }
106
- }
107
- async function confirmSampling(options, title, message) {
108
- if (options.autoApprove)
109
- return;
110
- if (!options.ui) {
111
- throw new Error("MCP sampling requires interactive approval. Set settings.samplingAutoApprove to true to allow it without UI.");
112
- }
113
- const approved = await options.ui.confirm(title, message);
114
- if (!approved) {
115
- throw new Error("MCP sampling request was declined");
116
- }
117
- }
118
- function convertSamplingMessage(message) {
119
- const blocks = Array.isArray(message.content) ? message.content : [message.content];
120
- if (message.role === "user") {
121
- return {
122
- role: "user",
123
- content: blocks.map(convertUserContent),
124
- timestamp: Date.now(),
125
- };
126
- }
127
- return {
128
- role: "assistant",
129
- content: blocks.map(convertAssistantContent),
130
- api: "mcp-sampling",
131
- provider: "mcp",
132
- model: "sampling-request",
133
- usage: zeroUsage(),
134
- stopReason: "stop",
135
- timestamp: Date.now(),
136
- };
137
- }
138
- function convertUserContent(block) {
139
- if (block.type === "text") {
140
- return { type: "text", text: block.text };
141
- }
142
- throw new Error(`MCP sampling ${block.type} content is not supported`);
143
- }
144
- function convertAssistantContent(block) {
145
- if (block.type === "text") {
146
- return { type: "text", text: block.text };
147
- }
148
- throw new Error(`MCP sampling assistant ${block.type} content is not supported`);
149
- }
150
- function convertAssistantResult(message) {
151
- if (message.stopReason === "error") {
152
- throw new Error(message.errorMessage ?? "MCP sampling model call failed");
153
- }
154
- if (message.stopReason === "aborted") {
155
- throw new Error(message.errorMessage ?? "MCP sampling model call was aborted");
156
- }
157
- const text = message.content
158
- .map((block) => {
159
- if (block.type === "text")
160
- return block.text;
161
- if (block.type === "thinking")
162
- return undefined;
163
- throw new Error(`MCP sampling result ${block.type} content is not supported`);
164
- })
165
- .filter((value) => value !== undefined)
166
- .join("\n\n")
167
- .trim();
168
- if (!text) {
169
- throw new Error("MCP sampling result did not contain text content");
170
- }
171
- return {
172
- role: "assistant",
173
- content: { type: "text", text },
174
- model: `${message.provider}/${message.model}`,
175
- stopReason: mapStopReason(message.stopReason),
176
- };
177
- }
178
- function mapStopReason(reason) {
179
- if (reason === "stop")
180
- return "endTurn";
181
- if (reason === "length")
182
- return "maxTokens";
183
- if (reason === "toolUse")
184
- return "toolUse";
185
- return reason;
186
- }
187
- function zeroUsage() {
188
- return {
189
- input: 0,
190
- output: 0,
191
- cacheRead: 0,
192
- cacheWrite: 0,
193
- totalTokens: 0,
194
- cost: {
195
- input: 0,
196
- output: 0,
197
- cacheRead: 0,
198
- cacheWrite: 0,
199
- total: 0,
200
- },
201
- };
202
- }
203
- //# sourceMappingURL=sampling-handler.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"sampling-handler.js","sourceRoot":"","sources":["../sampling-handler.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAC5C,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAyB5C,MAAM,UAAU,uBAAuB,CAAC,MAAc,EAAE,OAA+B;IACrF,MAAM,CAAC,iBAAiB,CAAC,wBAAwB,EAAE,OAAO,CAAC,EAAE;QAC3D,OAAO,qBAAqB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IACjD,CAAC,CAAC,CAAC;AACL,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,qBAAqB,CACzC,OAA+B,EAC/B,OAA6B;IAE7B,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAC9B,MAAM,MAAM,GAAG,OAAO,CAAC,SAAS,EAAE,CAAC;IACnC,cAAc,CAAC,MAAM,CAAC,CAAC;IAEvB,IAAI,MAAM,IAAI,MAAM,IAAI,MAAM,CAAC,IAAI,EAAE,CAAC;QACpC,MAAM,IAAI,KAAK,CAAC,sCAAsC,CAAC,CAAC;IAC1D,CAAC;IACD,IAAI,MAAM,CAAC,cAAc,IAAI,MAAM,CAAC,cAAc,KAAK,MAAM,EAAE,CAAC;QAC9D,MAAM,IAAI,KAAK,CAAC,iDAAiD,CAAC,CAAC;IACrE,CAAC;IACD,IAAI,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,CAAC;QACzB,MAAM,IAAI,KAAK,CAAC,wC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AAO,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE;QAC/B,KAAK,EAAE,GAAG,OAAO,CAAC,QAAQ,IAAI,OAAO,CAAC,KAAK,EAAE;QAC7C,UAAU,EAAE,aAAa,CAAC,OAAO,CAAC,UAAU,CAAC;KAC9C,CAAC;AACJ,CAAC;AAED,SAAS,aAAa,CAAC,MAAsC;IAC3D,IAAI,MAAM,KAAK,MAAM;QAAE,OAAO,SAAS,CAAC;IACxC,IAAI,MAAM,KAAK,QAAQ;QAAE,OAAO,WAAW,CAAC;IAC5C,IAAI,MAAM,KAAK,SAAS;QAAE,OAAO,SAAS,CAAC;IAC3C,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,SAAS,SAAS;IAChB,OAAO;QACL,KAAK,EAAE,CAAC;QACR,MAAM,EAAE,CAAC;QACT,SAAS,EAAE,CAAC;QACZ,UAAU,EAAE,CAAC;QACb,WAAW,EAAE,CAAC;QACd,IAAI,EAAE;YACJ,KAAK,EAAE,CAAC;YACR,MAAM,EAAE,CAAC;YACT,SAAS,EAAE,CAAC;YACZ,UAAU,EAAE,CAAC;YACb,KAAK,EAAE,CAAC;SACT;KACF,CAAC;AACJ,CAAC"}
@@ -1,11 +0,0 @@
1
- export interface SecureKeyringStore {
2
- read(account: string): string | undefined;
3
- write(account: string, payload: string): void;
4
- remove(account: string): void;
5
- }
6
- export declare function createSecureKeyringStore(service: string): SecureKeyringStore;
7
- export declare function resetTestSecureKeyring(): void;
8
- export declare function getTestSecureKeyringReadCount(): number;
9
- export declare function getTestSecureKeyringEntries(): [string, string][];
10
- export declare function setTestSecureKeyringEntry(service: string, account: string, payload: string): void;
11
- export declare function removeTestSecureKeyringEntry(service: string, account: string): void;
@@ -1,172 +0,0 @@
1
- import { spawnSync } from "node:child_process";
2
- import { existsSync } from "node:fs";
3
- import { createRequire } from "node:module";
4
- import { dirname, join } from "node:path";
5
- import { fileURLToPath } from "node:url";
6
- const require = createRequire(import.meta.url);
7
- const TEST_STORE_ENV = "PI_MCP_ADAPTER_TEST_AUTH_STORE";
8
- const memoryEntries = new Map();
9
- let memoryReadCount = 0;
10
- let KeyringEntryClass;
11
- function key(service, account) {
12
- return `${service}\0${account}`;
13
- }
14
- function nativeStore(service) {
15
- const entry = (account) => {
16
- try {
17
- KeyringEntryClass ??= loadKeyringEntryClass();
18
- return new KeyringEntryClass(service, account);
19
- }
20
- catch (error) {
21
- throw new Error("OS secure credential storage is unavailable. Configure or unlock the OS credential store and retry.", { cause: error });
22
- }
23
- };
24
- const run = (operation, account, payload) => {
25
- try {
26
- const credential = entry(account);
27
- if (operation === "read")
28
- return credential.getPassword() ?? undefined;
29
- if (operation === "write")
30
- credential.setPassword(payload);
31
- else
32
- credential.deleteCredential();
33
- return undefined;
34
- }
35
- catch (error) {
36
- if (!shouldRecoverKeyring(error))
37
- throw error;
38
- return recoverKeyring(operation, service, account, payload);
39
- }
40
- };
41
- return {
42
- read: account => run("read", account),
43
- write: (account, payload) => { run("write", account, payload); },
44
- remove: account => { run("remove", account); },
45
- };
46
- }
47
- function shouldRecoverKeyring(error) {
48
- if (process.platform !== "linux" || process.env.PI_MCP_ADAPTER_DISABLE_KEYRING_RECOVERY === "1")
49
- return false;
50
- const seen = new Set();
51
- for (let depth = 0; depth < 16 && error !== undefined && !seen.has(error); depth++) {
52
- seen.add(error);
53
- const candidate = typeof error === "object" && error !== null
54
- ? error
55
- : { message: error };
56
- if ([candidate.name, candidate.message, candidate.code].some(value => typeof value === "string" && /\b(?:KeyRevoked|key\s+(?:has been\s+)?revoked)\b/i.test(value)))
57
- return true;
58
- error = candidate.cause;
59
- }
60
- return false;
61
- }
62
- function recoverKeyring(operation, service, account, payload) {
63
- try {
64
- const adjacentHelper = new URL("./mcp-keyring-helper.cjs", import.meta.url);
65
- const helper = existsSync(adjacentHelper) ? adjacentHelper : new URL("../mcp-keyring-helper.cjs", import.meta.url);
66
- const result = spawnSync("keyctl", ["session", "-", process.execPath, fileURLToPath(helper)], {
67
- input: `${JSON.stringify({ operation, service, account, payload })}\n`,
68
- encoding: "utf8",
69
- stdio: "pipe",
70
- shell: false,
71
- timeout: 10_000,
72
- killSignal: "SIGKILL",
73
- maxBuffer: 1024 * 1024,
74
- windowsHide: true,
75
- });
76
- if (result.error || result.status !== 0 || result.signal)
77
- throw new Error();
78
- const response = JSON.parse(result.stdout);
79
- if (typeof response !== "object" || response === null || Array.isArray(response))
80
- throw new Error();
81
- const value = response;
82
- if (value.ok !== true)
83
- throw new Error();
84
- const allowedKeys = operation === "read" ? ["ok", "found", "value"] : ["ok"];
85
- if (Object.keys(response).some(key => !allowedKeys.includes(key)))
86
- throw new Error();
87
- if (operation === "read") {
88
- if (value.found === true && typeof value.value === "string")
89
- return value.value;
90
- if (value.found === false && value.value === undefined)
91
- return undefined;
92
- throw new Error();
93
- }
94
- return undefined;
95
- }
96
- catch {
97
- throw new Error("Linux keyring recovery failed. Configure or unlock the OS credential store and retry.");
98
- }
99
- }
100
- export function createSecureKeyringStore(service) {
101
- const mode = process.env[TEST_STORE_ENV];
102
- if (mode === "memory" || mode === "sizelimited") {
103
- return {
104
- read(account) { memoryReadCount++; return memoryEntries.get(key(service, account)); },
105
- write(account, payload) {
106
- if (mode === "sizelimited" && payload.length > 1280)
107
- throw new Error("secure credential value exceeds platform limit");
108
- memoryEntries.set(key(service, account), payload);
109
- },
110
- remove(account) { memoryEntries.delete(key(service, account)); },
111
- };
112
- }
113
- if (mode === "unavailable") {
114
- return {
115
- read() { memoryReadCount++; throw new Error("simulated secure credential store unavailable"); },
116
- write() { throw new Error("simulated secure credential store unavailable"); },
117
- remove() { throw new Error("simulated secure credential store unavailable"); },
118
- };
119
- }
120
- return nativeStore(service);
121
- }
122
- function loadKeyringEntryClass(keyringRequire = require, platform = process.platform, arch = process.arch) {
123
- try {
124
- return keyringRequire("@napi-rs/keyring").Entry;
125
- }
126
- catch (loaderError) {
127
- try {
128
- return loadKeyringNativeBindingFallback(keyringRequire, platform, arch).Entry;
129
- }
130
- catch (fallbackError) {
131
- const message = fallbackError instanceof Error ? fallbackError.message : String(fallbackError);
132
- throw new Error(`Failed to load @napi-rs/keyring; absolute-path native binding fallback also failed: ${message}`, { cause: loaderError });
133
- }
134
- }
135
- }
136
- function loadKeyringNativeBindingFallback(keyringRequire, platform, arch) {
137
- let lastError;
138
- for (const suffix of getKeyringNativeBindingSuffixes(platform, arch)) {
139
- try {
140
- const packageName = `@napi-rs/keyring-${suffix}`;
141
- const packageJsonPath = keyringRequire.resolve(`${packageName}/package.json`);
142
- return keyringRequire(join(dirname(packageJsonPath), `keyring.${suffix}.node`));
143
- }
144
- catch (error) {
145
- lastError = error;
146
- }
147
- }
148
- throw lastError instanceof Error ? lastError : new Error(String(lastError));
149
- }
150
- function getKeyringNativeBindingSuffixes(platform, arch) {
151
- if (platform === "darwin")
152
- return arch === "arm64" ? ["darwin-arm64"] : arch === "x64" ? ["darwin-x64"] : [];
153
- if (platform === "win32")
154
- return arch === "arm64" ? ["win32-arm64-msvc"] : arch === "x64" ? ["win32-x64-msvc"] : arch === "ia32" ? ["win32-ia32-msvc"] : [];
155
- if (platform === "linux") {
156
- if (arch === "arm64")
157
- return ["linux-arm64-gnu", "linux-arm64-musl"];
158
- if (arch === "arm")
159
- return ["linux-arm-gnueabihf"];
160
- if (arch === "riscv64")
161
- return ["linux-riscv64-gnu"];
162
- if (arch === "x64")
163
- return ["linux-x64-gnu", "linux-x64-musl"];
164
- }
165
- return platform === "freebsd" && arch === "x64" ? ["freebsd-x64"] : [];
166
- }
167
- export function resetTestSecureKeyring() { memoryEntries.clear(); memoryReadCount = 0; }
168
- export function getTestSecureKeyringReadCount() { return memoryReadCount; }
169
- export function getTestSecureKeyringEntries() { return [...memoryEntries.entries()]; }
170
- export function setTestSecureKeyringEntry(service, account, payload) { memoryEntries.set(key(service, account), payload); }
171
- export function removeTestSecureKeyringEntry(service, account) { memoryEntries.delete(key(service, account)); }
172
- //# sourceMappingURL=secure-keyring.js.map
@@ -1 +0,0 @@
1
-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AAG,CAAC,GAAG,CAAC,OAAO,EAAE,OAAO,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC;AACzJ,MAAM,UAAU,4BAA4B,CAAC,OAAe,EAAE,OAAe,IAAU,aAAa,CAAC,MAAM,CAAC,GAAG,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC"}
@@ -1,157 +0,0 @@
1
- import { Client, type GetPromptResult, type ListToolsResult, type ReadResourceResult, type McpSubscription, type SubscriptionFilter, type RequestOptions, type UrlElicitationRequiredError } from "@modelcontextprotocol/client";
2
- import { type McpTool, type McpResource, type McpPrompt, type ServerDefinition, type ServerStreamResultPatchNotification, type Transport, type McpTraceSettings, type McpListenState } from "./types.ts";
3
- import { type McpOAuthRuntime } from "./mcp-auth-flow.ts";
4
- import { type AuthStorageOptions } from "./mcp-auth.ts";
5
- import { type ServerSamplingConfig } from "./sampling-handler.ts";
6
- import { type ServerElicitationConfig } from "./elicitation-handler.ts";
7
- import { type RawRequestChannel } from "./mcp-tasks.ts";
8
- import type { TaskEnabledSession } from "@modelcontextprotocol/ext-tasks/client";
9
- export declare function isUnauthorizedHttpError(error: unknown): boolean;
10
- export interface ServerConnection {
11
- client: Client;
12
- transport: Transport;
13
- definition: ServerDefinition;
14
- tools: McpTool[];
15
- /** Cache hints from the server's aggregated tools/list result. */
16
- toolListHints?: Partial<Pick<ListToolsResult, "ttlMs" | "cacheScope">> | undefined;
17
- /** Monotonic guard against older refresh responses replacing newer notifications. */
18
- toolsRevision?: number;
19
- resources: McpResource[];
20
- /** True when resources were advertised but resources/list failed. */
21
- resourceDiscoveryFailed?: boolean;
22
- prompts: McpPrompt[];
23
- /** True when prompts were advertised but prompts/list failed. */
24
- promptDiscoveryFailed?: boolean;
25
- instructions?: string;
26
- lastUsedAt: number;
27
- inFlight: number;
28
- status: "connected" | "closed" | "needs-auth";
29
- /** Catalog subscription health, tracked independently from transport health. */
30
- listenState: McpListenState;
31
- /** ext-tasks requester session, attached when `tasks: true` and the server advertises the extension. */
32
- taskSession?: TaskEnabledSession;
33
- /** Raw JSON-RPC channel backing the task session on 2026-07-28 connections. */
34
- taskChannel?: RawRequestChannel;
35
- listenSubscription?: McpSubscription;
36
- /** Last requested filter; the server's honored filter may be a subset. */
37
- listenFilter?: SubscriptionFilter;
38
- /** True when recovery has an active listen but could not confirm every catalog list. */
39
- listenCatalogStale?: boolean;
40
- listenPromise?: Promise<void>;
41
- listenRetryAfter?: number;
42
- listenStopped?: boolean;
43
- recentResourceUris?: Map<string, number>;
44
- resourceReadRefreshUris?: Set<string>;
45
- /** True once this needs-auth episode discarded the cached credential. */
46
- credentialsInvalidated?: boolean;
47
- }
48
- type UiStreamListener = (serverName: string, notification: ServerStreamResultPatchNotification["params"]) => void;
49
- type MetadataListChangedListener = (serverName: string, reason: string) => void;
50
- type ListenStateChangedListener = (serverName: string, state: McpListenState) => void;
51
- type ResourceUpdatedListener = (serverName: string, uri: string) => void;
52
- export type ToolRefreshResult = "updated" | "unchanged" | "superseded" | "refresh-timeout";
53
- export declare function isTransientHttpConnectError(error: unknown): boolean;
54
- export declare class McpServerManager {
55
- private readonly defaultCwd?;
56
- private connections;
57
- private connectPromises;
58
- private connectOAuthAuthorities;
59
- private reconnectPromises;
60
- private reconnectOAuthAuthorities;
61
- private reconnectAttempts;
62
- private uiStreamListeners;
63
- private samplingConfig;
64
- private metadataListChangedListener;
65
- private listenStateChangedListener;
66
- private resourceUpdatedListeners;
67
- private pendingMetadataPublications;
68
- private elicitationConfig;
69
- private authStorageOptions;
70
- private oauthRuntime;
71
- private acceptedUrlElicitations;
72
- private defaultRequestTimeoutMs;
73
- private runtimeSignal;
74
- private closePromises;
75
- private closeGenerations;
76
- private connectAttempts;
77
- private traceSettings;
78
- private traceWriter;
79
- private stopped;
80
- /** Default cwd for stdio servers without an explicit config `cwd`. */
81
- constructor(defaultCwd?: string | undefined);
82
- setSamplingConfig(config: ServerSamplingConfig | undefined): void;
83
- setMetadataListChangedListener(listener: MetadataListChangedListener | undefined): void;
84
- setListenStateChangedListener(listener: ListenStateChangedListener | undefined): void;
85
- publishMetadataChanged(name: string, expectedConnection: ServerConnection, reason: string): boolean;
86
- setElicitationConfig(config: ServerElicitationConfig | undefined): void;
87
- setRuntimeSignal(signal: AbortSignal | undefined): void;
88
- setDefaultRequestTimeoutMs(timeoutMs: number | undefined): void;
89
- setTraceConfig(settings: McpTraceSettings | undefined): void;
90
- setAuthStorageOptions(options: AuthStorageOptions): void;
91
- setOAuthRuntime(runtime: McpOAuthRuntime): void;
92
- getRequestOptions(name: string, signal?: AbortSignal): RequestOptions | undefined;
93
- private getResolvedRequestTimeoutMs;
94
- private buildRequestOptions;
95
- private arbitrateConnectionAttempt;
96
- connect(name: string, definition: ServerDefinition, signal?: AbortSignal): Promise<ServerConnection>;
97
- /**
98
- * Reconnect a server whose connection was proven stale (e.g. by a 404
99
- * "session no longer exists" response). Single-flight per server name —
100
- * concurrent callers that raced to the same failure share one reconnect —
101
- * and identity-guarded: `staleConnection` is only torn down if it is
102
- * still the manager's current connection for `name`. If a concurrent
103
- * reconnect (or an unrelated connect()) already replaced it with a fresh
104
- * connection, that fresh connection is returned untouched.
105
- */
106
- reconnect(name: string, definition: ServerDefinition, staleConnection: ServerConnection, signal?: AbortSignal): Promise<ServerConnection>;
107
- /**
108
- * Fetch the authoritative tool catalog for a connection that still appears
109
- * connected. The SDK response cache is explicitly bypassed so this request
110
- * also proves the remote Streamable HTTP session is usable. Results are
111
- * identity-guarded: a late response from a replaced connection is ignored.
112
- */
113
- refreshTools(name: string, expectedConnection: ServerConnection, signal?: AbortSignal): Promise<ToolRefreshResult>;
114
- private retryPendingMetadataPublication;
115
- private setListenState;
116
- private catalogListenFilter;
117
- private currentListenFilter;
118
- private watchListenSubscription;
119
- /** Quietly repairs a modern catalog listen at an existing activity boundary. */
120
- ensureListen(name: string, expectedConnection: ServerConnection): Promise<void>;
121
- private reconcileCatalogAfterListen;
122
- prepareResourceUse(name: string, uri: string, expectedConnection: ServerConnection): Promise<boolean>;
123
- registerResourceUpdatedListener(token: string, serverName: string, uri: string, listener: ResourceUpdatedListener): void;
124
- removeResourceUpdatedListener(token: string): void;
125
- private doReconnect;
126
- private createConnection;
127
- private enrichHttpConnectionError;
128
- private connectClientWithAbort;
129
- private buildClientCapabilities;
130
- private createClient;
131
- private handleToolsListChanged;
132
- private handlePromptsListChanged;
133
- private handleResourcesListChanged;
134
- handleUrlElicitationRequired(serverName: string, error: UrlElicitationRequiredError): Promise<"accept" | "decline" | "cancel">;
135
- private rememberUrlElicitation;
136
- private connectHttpClient;
137
- private fetchAllTools;
138
- private fetchAllPrompts;
139
- private fetchAllResources;
140
- private attachAdapterNotificationHandlers;
141
- registerUiStreamListener(streamToken: string, listener: UiStreamListener): void;
142
- removeUiStreamListener(streamToken: string): void;
143
- getPrompt(name: string, promptName: string, args?: Record<string, string>, signal?: AbortSignal): Promise<GetPromptResult>;
144
- readResource(name: string, uri: string, signal?: AbortSignal): Promise<ReadResourceResult>;
145
- close(name: string): Promise<void>;
146
- private disposeConnection;
147
- closeAll(): Promise<void>;
148
- private containsCleanupFailure;
149
- isConnecting(name: string): boolean;
150
- getConnection(name: string): ServerConnection | undefined;
151
- getAllConnections(): Map<string, ServerConnection>;
152
- touch(name: string): void;
153
- incrementInFlight(name: string): void;
154
- decrementInFlight(name: string): void;
155
- isIdle(name: string, timeoutMs: number): boolean;
156
- }
157
- export {};