@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,34 +0,0 @@
1
- export function throwIfAborted(signal?: AbortSignal): void {
2
- if (!signal?.aborted) return;
3
- throw signal.reason instanceof Error ? signal.reason : new Error(String(signal.reason ?? "MCP request aborted"));
4
- }
5
-
6
- export async function abortable<T>(promise: Promise<T>, signal?: AbortSignal): Promise<T> {
7
- if (!signal) return promise;
8
- throwIfAborted(signal);
9
- return await new Promise<T>((resolve, reject) => {
10
- let settled = false;
11
- const cleanup = () => signal.removeEventListener("abort", onAbort);
12
- const onAbort = () => {
13
- if (settled) return;
14
- settled = true;
15
- cleanup();
16
- reject(signal.reason instanceof Error ? signal.reason : new Error(String(signal.reason ?? "MCP request aborted")));
17
- };
18
- signal.addEventListener("abort", onAbort, { once: true });
19
- promise.then(
20
- value => {
21
- if (settled) return;
22
- settled = true;
23
- cleanup();
24
- resolve(value);
25
- },
26
- error => {
27
- if (settled) return;
28
- settled = true;
29
- cleanup();
30
- reject(error);
31
- },
32
- );
33
- });
34
- }
@@ -1,68 +0,0 @@
1
- import { readFileSync } from "node:fs";
2
- import { homedir } from "node:os";
3
- import { join, resolve } from "node:path";
4
-
5
- export function getConfigDirName(): string {
6
- const configDir = readPiConfig()?.configDir;
7
- return typeof configDir === "string" && configDir.trim() ? configDir.trim() : ".pi";
8
- }
9
-
10
- export function getAgentDir(): string {
11
- const piConfig = readPiConfig();
12
- const name = piConfig?.name;
13
- const appName = typeof name === "string" && name.trim() ? name.trim() : "pi";
14
- const configured = process.env[`${appName.toUpperCase()}_CODING_AGENT_DIR`]?.trim();
15
- if (!configured) {
16
- return join(homedir(), getConfigDirName(), "agent");
17
- }
18
- if (configured === "~") {
19
- return homedir();
20
- }
21
- if (configured.startsWith("~/")) {
22
- return resolve(homedir(), configured.slice(2));
23
- }
24
- return resolve(configured);
25
- }
26
-
27
- export function getAgentPath(...segments: string[]): string {
28
- return join(getAgentDir(), ...segments);
29
- }
30
-
31
- /**
32
- * What the host calls itself.
33
- *
34
- * pi supports rebranding through `piConfig.name` in the package.json that its
35
- * `getPackageDir()` resolves, and distributions built on pi (arc, tau, …) point
36
- * `PI_PACKAGE_DIR` at their own manifest. Read that manifest directly rather
37
- * than importing pi: this package deliberately depends on pi-ai and pi-tui
38
- * only, and `getAgentDir()` above reads its env var the same self-contained way.
39
- *
40
- * Falls back to "pi", which is what pi's own APP_NAME resolves to.
41
- */
42
- function readPiConfig(): { name?: unknown; configDir?: unknown; clientUri?: unknown } | undefined {
43
- const dir = process.env.PI_PACKAGE_DIR?.trim()
44
- if (!dir) return undefined
45
- try {
46
- const manifest = JSON.parse(readFileSync(join(resolve(dir), "package.json"), "utf8")) as {
47
- piConfig?: { name?: unknown; configDir?: unknown; clientUri?: unknown }
48
- }
49
- return manifest.piConfig
50
- } catch {
51
- return undefined
52
- }
53
- }
54
-
55
- export function getAppName(): string {
56
- const name = readPiConfig()?.name
57
- return typeof name === "string" && name.trim() ? name.trim() : "pi"
58
- }
59
-
60
- /**
61
- * Home page the host declares for itself, via `piConfig.clientUri` in the same
62
- * manifest that carries `piConfig.name`. Only the distribution knows its own
63
- * URL, so this is the one place it can come from without guessing.
64
- */
65
- export function getAppClientUri(): string | undefined {
66
- const uri = readPiConfig()?.clientUri
67
- return typeof uri === "string" && uri.trim() ? uri.trim() : undefined
68
- }
@@ -1,416 +0,0 @@
1
- import { existsSync, readFileSync, realpathSync, statSync } from "node:fs";
2
- import { dirname, isAbsolute, resolve } from "node:path";
3
- import { getAgentPath } from "./agent-dir.ts";
4
- import { markBuiltInAgentPlugin } from "./agent-plugin-provenance.ts";
5
- import type { McpConfig, ServerEntry } from "./types.ts";
6
- import { resolveRealContainedPath } from "./utils.ts";
7
-
8
- const PLUGIN_SCHEMA = "https://agent-plugins.org/schemas/1.0.0/plugin.schema.json";
9
- const MCP_SCHEMA = "https://agent-plugins.org/schemas/1.0.0/mcp.schema.json";
10
- const PLUGIN_NAME_PATTERN = /^(?!.*(?:--|\.\.))[a-z0-9](?:[a-z0-9.-]*[a-z0-9])?$/;
11
- const PLUGIN_MANIFEST_FIELDS = new Set([
12
- "$schema",
13
- "name",
14
- "version",
15
- "description",
16
- "author",
17
- "homepage",
18
- "repository",
19
- "license",
20
- "keywords",
21
- "extensions",
22
- ]);
23
- const MCP_CONFIG_FIELDS = new Set(["$schema", "mcpServers"]);
24
- const STDIO_FIELDS = new Set(["type", "command", "args", "env", "cwd"]);
25
- const HTTP_FIELDS = new Set(["type", "url", "headers"]);
26
- const STRING_MANIFEST_FIELDS = ["version", "description", "homepage", "repository", "license"] as const;
27
- const AUTHOR_FIELDS = new Set(["name", "email", "url"]);
28
-
29
- interface AgentPluginManifest {
30
- name: string;
31
- }
32
-
33
- export interface AgentPluginSummary {
34
- path: string;
35
- name?: string;
36
- serverCount: number;
37
- }
38
-
39
- export function loadAgentPluginConfigs(paths: unknown, cwd = process.cwd()): McpConfig {
40
- const mcpServers: Record<string, ServerEntry> = {};
41
- for (const pluginPath of getPluginPaths(paths)) {
42
- const loaded = loadAgentPluginMcpConfig(pluginPath, cwd);
43
- if (!loaded) continue;
44
- for (const [serverName, server] of Object.entries(loaded.mcpServers)) {
45
- if (mcpServers[serverName]) {
46
- console.warn(`Agent Plugin at ${resolvePluginPath(pluginPath, cwd)} skips duplicate normalized MCP server ${serverName}`);
47
- continue;
48
- }
49
- mcpServers[serverName] = server;
50
- }
51
- }
52
- return { mcpServers };
53
- }
54
-
55
- export function getAgentPluginSummaries(paths: unknown, cwd = process.cwd()): AgentPluginSummary[] {
56
- return getPluginPaths(paths).map(path => {
57
- const pluginRoot = resolvePluginRoot(path, cwd);
58
- const loaded = loadAgentPluginMcpConfig(path, cwd);
59
- const manifest = loaded ? readPluginManifest(pluginRoot, false) : null;
60
- return {
61
- path: pluginRoot,
62
- ...(manifest?.name ? { name: manifest.name } : {}),
63
- serverCount: loaded ? Object.keys(loaded.mcpServers).length : 0,
64
- };
65
- });
66
- }
67
-
68
- function getPluginPaths(paths: unknown): string[] {
69
- return Array.isArray(paths) ? paths.filter((path): path is string => typeof path === "string") : [];
70
- }
71
-
72
- function loadAgentPluginMcpConfig(path: string, cwd: string): McpConfig | null {
73
- const pluginRoot = resolvePluginRoot(path, cwd);
74
- const manifest = readPluginManifest(pluginRoot, true);
75
- if (!manifest) return null;
76
-
77
- const mcpPath = resolve(pluginRoot, "mcp.json");
78
- if (!existsSync(mcpPath)) return { mcpServers: {} };
79
- if (!statSync(mcpPath).isFile()) {
80
- console.warn(`Agent Plugin ${manifest.name} has invalid MCP config: mcp.json is not a regular file`);
81
- return { mcpServers: {} };
82
- }
83
- const resolvedMcpPath = resolveRealContainedPath(pluginRoot, mcpPath);
84
- if (!resolvedMcpPath) {
85
- console.warn(`Agent Plugin ${manifest.name} has invalid MCP config: mcp.json must stay inside the plugin directory`);
86
- return { mcpServers: {} };
87
- }
88
-
89
- let raw: unknown;
90
- try {
91
- raw = JSON.parse(readFileSync(resolvedMcpPath, "utf8"));
92
- } catch (error) {
93
- console.warn(`Agent Plugin ${manifest.name} has invalid MCP config: failed to parse mcp.json`, error);
94
- return { mcpServers: {} };
95
- }
96
-
97
- return translateAgentPluginMcpConfig(raw, manifest, pluginRoot);
98
- }
99
-
100
- function readPluginManifest(pluginRoot: string, report: boolean): AgentPluginManifest | null {
101
- const manifestPath = resolve(pluginRoot, "plugin.json");
102
- if (!existsSync(manifestPath)) {
103
- if (report) console.warn(`Agent Plugin at ${pluginRoot} is invalid: missing plugin.json`);
104
- return null;
105
- }
106
- if (!statSync(manifestPath).isFile()) {
107
- if (report) console.warn(`Agent Plugin at ${pluginRoot} is invalid: plugin.json is not a regular file`);
108
- return null;
109
- }
110
- const resolvedManifestPath = resolveRealContainedPath(pluginRoot, manifestPath);
111
- if (!resolvedManifestPath) {
112
- if (report) console.warn(`Agent Plugin at ${pluginRoot} is invalid: plugin.json must stay inside the plugin directory`);
113
- return null;
114
- }
115
-
116
- let raw: unknown;
117
- try {
118
- raw = JSON.parse(readFileSync(resolvedManifestPath, "utf8"));
119
- } catch (error) {
120
- if (report) console.warn(`Agent Plugin at ${pluginRoot} is invalid: failed to parse plugin.json`, error);
121
- return null;
122
- }
123
- if (!raw || typeof raw !== "object" || Array.isArray(raw)) {
124
- if (report) console.warn(`Agent Plugin at ${pluginRoot} is invalid: plugin.json must be an object`);
125
- return null;
126
- }
127
-
128
- const manifest = raw as Record<string, unknown>;
129
- for (const key of Object.keys(manifest)) {
130
- if (!PLUGIN_MANIFEST_FIELDS.has(key) && report) {
131
- console.warn(`Agent Plugin at ${pluginRoot} ignores unknown plugin.json field: ${key}`);
132
- }
133
- }
134
- if (manifest.$schema !== PLUGIN_SCHEMA) {
135
- if (report) console.warn(`Agent Plugin at ${pluginRoot} is invalid: unsupported plugin.json $schema`);
136
- return null;
137
- }
138
- if (typeof manifest.name !== "string" || manifest.name.length < 1 || manifest.name.length > 64 || !PLUGIN_NAME_PATTERN.test(manifest.name)) {
139
- if (report) console.warn(`Agent Plugin at ${pluginRoot} is invalid: plugin.json name is invalid`);
140
- return null;
141
- }
142
- for (const field of STRING_MANIFEST_FIELDS) {
143
- if (manifest[field] !== undefined && typeof manifest[field] !== "string") {
144
- if (report) console.warn(`Agent Plugin ${manifest.name} is invalid: plugin.json ${field} must be a string`);
145
- return null;
146
- }
147
- }
148
- if (manifest.keywords !== undefined && (!Array.isArray(manifest.keywords) || manifest.keywords.some(value => typeof value !== "string"))) {
149
- if (report) console.warn(`Agent Plugin ${manifest.name} is invalid: plugin.json keywords must be an array of strings`);
150
- return null;
151
- }
152
- if (manifest.author !== undefined && !isValidManifestAuthor(manifest.author)) {
153
- if (report) console.warn(`Agent Plugin ${manifest.name} is invalid: plugin.json author is invalid`);
154
- return null;
155
- }
156
- if (manifest.extensions !== undefined && (!manifest.extensions || typeof manifest.extensions !== "object" || Array.isArray(manifest.extensions))) {
157
- if (report) console.warn(`Agent Plugin ${manifest.name} ignores non-object plugin.json extensions`);
158
- }
159
-
160
- return { name: manifest.name };
161
- }
162
-
163
- function translateAgentPluginMcpConfig(raw: unknown, manifest: AgentPluginManifest, pluginRoot: string): McpConfig {
164
- if (!raw || typeof raw !== "object" || Array.isArray(raw)) {
165
- console.warn(`Agent Plugin ${manifest.name} has invalid MCP config: mcp.json must be an object`);
166
- return { mcpServers: {} };
167
- }
168
-
169
- const mcpConfig = raw as Record<string, unknown>;
170
- for (const key of Object.keys(mcpConfig)) {
171
- if (!MCP_CONFIG_FIELDS.has(key)) {
172
- console.warn(`Agent Plugin ${manifest.name} has invalid MCP config: unknown top-level field ${key}`);
173
- return { mcpServers: {} };
174
- }
175
- }
176
- if (mcpConfig.$schema !== MCP_SCHEMA) {
177
- console.warn(`Agent Plugin ${manifest.name} has invalid MCP config: unsupported mcp.json $schema`);
178
- return { mcpServers: {} };
179
- }
180
- if (!mcpConfig.mcpServers || typeof mcpConfig.mcpServers !== "object" || Array.isArray(mcpConfig.mcpServers)) {
181
- console.warn(`Agent Plugin ${manifest.name} has invalid MCP config: mcpServers must be an object`);
182
- return { mcpServers: {} };
183
- }
184
-
185
- const mcpServers: Record<string, ServerEntry> = {};
186
- for (const [serverName, entry] of Object.entries(mcpConfig.mcpServers)) {
187
- const translated = translateAgentPluginServer(manifest, pluginRoot, serverName, entry);
188
- if (!translated) continue;
189
-
190
- const normalizedName = formatAgentPluginServerName(manifest.name, serverName);
191
- if (mcpServers[normalizedName]) {
192
- console.warn(`Agent Plugin ${manifest.name} skips invalid MCP server ${serverName}: normalized server name ${normalizedName} already exists`);
193
- continue;
194
- }
195
- mcpServers[normalizedName] = translated;
196
- }
197
- return { mcpServers };
198
- }
199
-
200
- function translateAgentPluginServer(
201
- manifest: AgentPluginManifest,
202
- pluginRoot: string,
203
- serverName: string,
204
- entry: unknown,
205
- ): ServerEntry | null {
206
- if (!entry || typeof entry !== "object" || Array.isArray(entry)) {
207
- console.warn(`Agent Plugin ${manifest.name} skips invalid MCP server ${serverName}: entry must be an object`);
208
- return null;
209
- }
210
-
211
- const raw = entry as Record<string, unknown>;
212
- if (raw.type === "stdio") return translateStdioServer(manifest, pluginRoot, serverName, raw);
213
- if (raw.type === "streamable-http" || raw.type === "sse") return translateHttpServer(manifest, serverName, raw, raw.type);
214
-
215
- console.warn(`Agent Plugin ${manifest.name} skips invalid MCP server ${serverName}: unsupported type`);
216
- return null;
217
- }
218
-
219
- function translateStdioServer(
220
- manifest: AgentPluginManifest,
221
- pluginRoot: string,
222
- serverName: string,
223
- raw: Record<string, unknown>,
224
- ): ServerEntry | null {
225
- for (const key of Object.keys(raw)) {
226
- if (!STDIO_FIELDS.has(key)) return skipServer(manifest, serverName, `unknown field ${key}`);
227
- }
228
- if (typeof raw.command !== "string" || raw.command.length === 0) return skipServer(manifest, serverName, "command must be a non-empty string");
229
- if (!isBareCommand(raw.command) && !raw.command.startsWith("./")) return skipServer(manifest, serverName, "command must be bare or plugin-relative");
230
-
231
- const args = translateStringArray(raw.args, manifest, serverName, "args");
232
- if (args === null) return null;
233
- const env = translateEnv(raw.env, manifest, serverName);
234
- if (env === null) return null;
235
-
236
- const command = raw.command.startsWith("./") ? resolveRealContainedPath(pluginRoot, resolve(pluginRoot, raw.command)) : raw.command;
237
- if (command === null) return skipServer(manifest, serverName, "command must resolve to an accessible path inside the plugin directory");
238
-
239
- const pluginDataDir = getAgentPath("agent-plugin-data", manifest.name);
240
- const cwd = resolvePluginCwd(raw.cwd, pluginRoot, pluginDataDir);
241
- if (cwd === null) return skipServer(manifest, serverName, "cwd must resolve from an allowed root and stay contained");
242
-
243
- return markBuiltInAgentPlugin({
244
- command,
245
- args: args.map(value => expandPluginPlaceholders(value, pluginRoot, pluginDataDir)),
246
- env: {
247
- ...Object.fromEntries(Object.entries(env).map(([key, value]) => [key, expandPluginPlaceholders(value, pluginRoot, pluginDataDir)])),
248
- PLUGIN_ROOT: pluginRoot,
249
- PLUGIN_DATA: pluginDataDir,
250
- },
251
- cwd,
252
- pluginDataDir,
253
- literalEnv: true,
254
- }, ["args", "env", "cwd"]);
255
- }
256
-
257
- function translateHttpServer(
258
- manifest: AgentPluginManifest,
259
- serverName: string,
260
- raw: Record<string, unknown>,
261
- type: "streamable-http" | "sse",
262
- ): ServerEntry | null {
263
- for (const key of Object.keys(raw)) {
264
- if (!HTTP_FIELDS.has(key)) return skipServer(manifest, serverName, `unknown field ${key}`);
265
- }
266
- if (typeof raw.url !== "string" || raw.url.length === 0) return skipServer(manifest, serverName, "url must be a non-empty string");
267
- if (!isValidAgentPluginUrl(raw.url)) return skipServer(manifest, serverName, "url must be an allowed absolute HTTP(S) URL");
268
- const headers = translateHeaders(raw.headers, manifest, serverName);
269
- if (headers === null) return null;
270
-
271
- return markBuiltInAgentPlugin({
272
- url: raw.url,
273
- httpTransport: type,
274
- ...(headers ? { headers } : {}),
275
- }, headers ? ["headers"] : []);
276
- }
277
-
278
- function formatAgentPluginServerName(pluginName: string, serverName: string): string {
279
- const pluginPart = pluginName.replace(/[^A-Za-z0-9_-]+/g, "_").replace(/^[_-]+|[_-]+$/g, "") || "plugin";
280
- const serverPart = serverName.replace(/[^A-Za-z0-9_-]+/g, "_").replace(/^[_-]+|[_-]+$/g, "") || "server";
281
- return `${pluginPart}__${serverPart}`;
282
- }
283
-
284
- function skipServer(manifest: AgentPluginManifest, serverName: string, reason: string): null {
285
- console.warn(`Agent Plugin ${manifest.name} skips invalid MCP server ${serverName}: ${reason}`);
286
- return null;
287
- }
288
-
289
- function translateStringArray(value: unknown, manifest: AgentPluginManifest, serverName: string, field: string): string[] | null {
290
- if (value === undefined) return [];
291
- if (!Array.isArray(value) || value.some(item => typeof item !== "string")) {
292
- console.warn(`Agent Plugin ${manifest.name} skips invalid MCP server ${serverName}: ${field} must be an array of strings`);
293
- return null;
294
- }
295
- return value;
296
- }
297
-
298
- function translateEnv(value: unknown, manifest: AgentPluginManifest, serverName: string): Record<string, string> | null {
299
- if (value === undefined) return {};
300
- if (!value || typeof value !== "object" || Array.isArray(value)) {
301
- console.warn(`Agent Plugin ${manifest.name} skips invalid MCP server ${serverName}: env must be an object of strings`);
302
- return null;
303
- }
304
- const entries: Array<[string, string]> = [];
305
- for (const [key, entry] of Object.entries(value)) {
306
- if (key === "PLUGIN_ROOT" || key === "PLUGIN_DATA") {
307
- console.warn(`Agent Plugin ${manifest.name} skips invalid MCP server ${serverName}: env must not define ${key}`);
308
- return null;
309
- }
310
- if (typeof entry !== "string") {
311
- console.warn(`Agent Plugin ${manifest.name} skips invalid MCP server ${serverName}: env values must be strings`);
312
- return null;
313
- }
314
- entries.push([key, entry]);
315
- }
316
- return Object.fromEntries(entries);
317
- }
318
-
319
- function translateHeaders(value: unknown, manifest: AgentPluginManifest, serverName: string): Record<string, string> | undefined | null {
320
- if (value === undefined) return undefined;
321
- if (!value || typeof value !== "object" || Array.isArray(value)) {
322
- console.warn(`Agent Plugin ${manifest.name} skips invalid MCP server ${serverName}: headers must be an object of strings`);
323
- return null;
324
- }
325
- const entries: Array<[string, string]> = [];
326
- const seen = new Set<string>();
327
- for (const [key, entry] of Object.entries(value)) {
328
- if (typeof entry !== "string") {
329
- console.warn(`Agent Plugin ${manifest.name} skips invalid MCP server ${serverName}: header values must be strings`);
330
- return null;
331
- }
332
- const normalized = key.toLowerCase();
333
- if (seen.has(normalized)) {
334
- console.warn(`Agent Plugin ${manifest.name} skips invalid MCP server ${serverName}: duplicate header ${key}`);
335
- return null;
336
- }
337
- seen.add(normalized);
338
- entries.push([key, entry]);
339
- }
340
- const headers = Object.fromEntries(entries);
341
- try {
342
- new Headers(headers);
343
- } catch {
344
- console.warn(`Agent Plugin ${manifest.name} skips invalid MCP server ${serverName}: headers are not valid HTTP fields`);
345
- return null;
346
- }
347
- return Object.keys(headers).length > 0 ? headers : undefined;
348
- }
349
-
350
- function resolvePluginPath(path: string, cwd: string): string {
351
- if (path === "~") return resolve(process.env.HOME ?? "", ".");
352
- if (path.startsWith("~/")) return resolve(process.env.HOME ?? "", path.slice(2));
353
- return isAbsolute(path) ? resolve(path) : resolve(cwd, path);
354
- }
355
-
356
- function resolvePluginRoot(path: string, cwd: string): string {
357
- const resolved = resolvePluginPath(path, cwd);
358
- try {
359
- return realpathSync(resolved);
360
- } catch {
361
- return resolved;
362
- }
363
- }
364
-
365
- function isValidManifestAuthor(value: unknown): boolean {
366
- if (!value || typeof value !== "object" || Array.isArray(value)) return false;
367
- return Object.entries(value).every(([key, entry]) => AUTHOR_FIELDS.has(key) && typeof entry === "string");
368
- }
369
-
370
- function isBareCommand(command: string): boolean {
371
- return !command.includes("/") && !command.includes("\\") && !command.includes("${PLUGIN_ROOT}") && !command.includes("${PLUGIN_DATA}");
372
- }
373
-
374
- function resolvePluginCwd(value: unknown, pluginRoot: string, pluginDataDir: string): string | null {
375
- if (value === undefined) return pluginRoot;
376
- if (typeof value !== "string") return null;
377
- const expanded = expandPluginPlaceholders(value, pluginRoot, pluginDataDir);
378
- if (value.startsWith("./") || value === "${PLUGIN_ROOT}" || value.startsWith("${PLUGIN_ROOT}/")) {
379
- return resolveRealContainedPath(pluginRoot, resolve(pluginRoot, expanded));
380
- }
381
- if (value === "${PLUGIN_DATA}" || value.startsWith("${PLUGIN_DATA}/")) {
382
- return resolvePluginDataCwd(pluginDataDir, expanded);
383
- }
384
- return null;
385
- }
386
-
387
- function resolvePluginDataCwd(pluginDataDir: string, expanded: string): string | null {
388
- if (existsSync(pluginDataDir) && !resolveRealContainedPath(dirname(pluginDataDir), pluginDataDir)) return null;
389
- return resolveRealContainedPath(pluginDataDir, resolve(pluginDataDir, expanded), true);
390
- }
391
-
392
- function expandPluginPlaceholders(value: string, pluginRoot: string, pluginDataDir: string): string {
393
- return value.replace(/\$\{PLUGIN_(ROOT|DATA)\}/g, (_, name: string) => name === "ROOT" ? pluginRoot : pluginDataDir);
394
- }
395
-
396
- function isValidAgentPluginUrl(value: string): boolean {
397
- if (value.includes("${") || value.includes("$env:") || value.includes("{env:")) return false;
398
-
399
- let url: URL;
400
- try {
401
- url = new URL(value);
402
- } catch {
403
- return false;
404
- }
405
- if (url.protocol !== "http:" && url.protocol !== "https:") return false;
406
- if (url.username || url.password || url.hash) return false;
407
- if (url.protocol === "https:") return true;
408
- return isLoopbackHost(url.hostname);
409
- }
410
-
411
- function isLoopbackHost(hostname: string): boolean {
412
- const host = hostname.toLowerCase();
413
- if (host === "localhost" || host === "127.0.0.1" || host === "::1" || host === "[::1]") return true;
414
- if (/^127(?:\.\d{1,3}){3}$/.test(host)) return true;
415
- return false;
416
- }
@@ -1,36 +0,0 @@
1
- import type { ServerEntry } from "./types.ts";
2
-
3
- const LITERAL_PLUGIN_FIELDS = ["args", "env", "cwd", "headers"] as const;
4
- type LiteralPluginField = typeof LITERAL_PLUGIN_FIELDS[number];
5
- const BUILT_IN_AGENT_PLUGIN = Symbol("built-in-agent-plugin");
6
- type BuiltInAgentPluginEntry = ServerEntry & { [BUILT_IN_AGENT_PLUGIN]?: ReadonlySet<LiteralPluginField> };
7
-
8
- /** @internal */
9
- export function markBuiltInAgentPlugin(definition: ServerEntry, fields: LiteralPluginField[]): ServerEntry {
10
- (definition as BuiltInAgentPluginEntry)[BUILT_IN_AGENT_PLUGIN] = new Set(fields);
11
- return definition;
12
- }
13
-
14
- /** @internal */
15
- export function isBuiltInAgentPlugin(definition: ServerEntry, field: LiteralPluginField): boolean {
16
- return (definition as BuiltInAgentPluginEntry)[BUILT_IN_AGENT_PLUGIN]?.has(field) === true;
17
- }
18
-
19
- /** @internal */
20
- export function cloneBuiltInAgentPluginEntry(source: ServerEntry): ServerEntry | undefined {
21
- const fields = LITERAL_PLUGIN_FIELDS.filter(field => Object.hasOwn(source, field) && isBuiltInAgentPlugin(source, field));
22
- if (fields.length === 0) return undefined;
23
- return markBuiltInAgentPlugin(structuredClone(source), fields);
24
- }
25
-
26
- /** @internal */
27
- export function mergeBuiltInAgentPluginEntries(base: ServerEntry, next: ServerEntry): ServerEntry {
28
- const merged = { ...base, ...next };
29
- delete (merged as BuiltInAgentPluginEntry)[BUILT_IN_AGENT_PLUGIN];
30
- const fields = LITERAL_PLUGIN_FIELDS.filter(field => {
31
- const owner = Object.hasOwn(next, field) ? next : base;
32
- return Object.hasOwn(owner, field) && isBuiltInAgentPlugin(owner, field);
33
- });
34
- if (fields.length > 0) markBuiltInAgentPlugin(merged, fields);
35
- return merged;
36
- }