@herbertgao/pi-extensions 2026.9.17 → 2026.9.18

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 (266) hide show
  1. package/README.md +14 -15
  2. package/node_modules/@herbertgao/pi-bark/package.json +2 -2
  3. package/node_modules/@herbertgao/pi-cc-extensions/README.en.md +4 -1
  4. package/node_modules/@herbertgao/pi-cc-extensions/README.md +4 -1
  5. package/node_modules/@herbertgao/pi-cc-extensions/package.json +75 -75
  6. package/node_modules/@herbertgao/pi-subagents/CHANGELOG.md +6 -0
  7. package/node_modules/@herbertgao/pi-subagents/package.json +7 -7
  8. package/node_modules/@herbertgao/resume-from/package.json +4 -2
  9. package/node_modules/@herbertgao/sol-pi/package.json +6 -6
  10. package/node_modules/@juicesharp/rpiv-ask-user-question/package.json +99 -99
  11. package/node_modules/@pi-plugins/fast-mode/package.json +1 -1
  12. package/node_modules/@tifan/pi-handoff/package.json +1 -1
  13. package/node_modules/@tifan/pi-handoff/src/index.ts +56 -26
  14. package/node_modules/@tifan/pi-mermaid-open/package.json +1 -1
  15. package/node_modules/@tifan/pi-preferred-thinking/package.json +1 -1
  16. package/node_modules/@tifan/pi-recap/package.json +1 -1
  17. package/node_modules/@tifan/pi-rename/package.json +1 -1
  18. package/node_modules/pi-antigravity/package.json +2 -2
  19. package/node_modules/pi-lens/package.json +158 -158
  20. package/node_modules/pi-multi-account/package.json +2 -2
  21. package/node_modules/pi-typesafe/README.md +1 -1
  22. package/node_modules/pi-typesafe/dist/auth.d.ts +9 -5
  23. package/node_modules/pi-typesafe/dist/auth.js +7 -3
  24. package/node_modules/pi-typesafe/dist/backends.d.ts +33 -3
  25. package/node_modules/pi-typesafe/dist/backends.js +95 -1
  26. package/node_modules/pi-typesafe/dist/client.d.ts +5 -5
  27. package/node_modules/pi-typesafe/dist/client.js +12 -9
  28. package/node_modules/pi-typesafe/dist/credentials.d.ts +14 -8
  29. package/node_modules/pi-typesafe/dist/credentials.js +10 -7
  30. package/node_modules/pi-typesafe/dist/errors.d.ts +2 -2
  31. package/node_modules/pi-typesafe/dist/index.d.ts +2 -2
  32. package/node_modules/pi-typesafe/dist/index.js +1 -1
  33. package/node_modules/pi-typesafe/dist/login.d.ts +2 -2
  34. package/node_modules/pi-typesafe/dist/login.js +2 -2
  35. package/node_modules/pi-typesafe/package.json +5 -5
  36. package/node_modules/pi-web-access/package.json +2 -2
  37. package/node_modules/remote-pi/package.json +5 -1
  38. package/package.json +16 -28
  39. package/node_modules/pi-mcp-adapter/CHANGELOG.md +0 -1013
  40. package/node_modules/pi-mcp-adapter/LICENSE +0 -21
  41. package/node_modules/pi-mcp-adapter/OAUTH.md +0 -369
  42. package/node_modules/pi-mcp-adapter/README.md +0 -1021
  43. package/node_modules/pi-mcp-adapter/abort.ts +0 -34
  44. package/node_modules/pi-mcp-adapter/agent-dir.ts +0 -68
  45. package/node_modules/pi-mcp-adapter/agent-plugin-loader.ts +0 -416
  46. package/node_modules/pi-mcp-adapter/agent-plugin-provenance.ts +0 -36
  47. package/node_modules/pi-mcp-adapter/app-bridge.bundle.js +0 -67
  48. package/node_modules/pi-mcp-adapter/banner.png +0 -0
  49. package/node_modules/pi-mcp-adapter/bearer-command-resolver.ts +0 -193
  50. package/node_modules/pi-mcp-adapter/claude-plugin-loader.ts +0 -365
  51. package/node_modules/pi-mcp-adapter/cli.js +0 -454
  52. package/node_modules/pi-mcp-adapter/commands.ts +0 -861
  53. package/node_modules/pi-mcp-adapter/config.ts +0 -1565
  54. package/node_modules/pi-mcp-adapter/consent-manager.ts +0 -95
  55. package/node_modules/pi-mcp-adapter/direct-tool-surface.ts +0 -244
  56. package/node_modules/pi-mcp-adapter/direct-tools.ts +0 -428
  57. package/node_modules/pi-mcp-adapter/dist/abort.d.ts +0 -2
  58. package/node_modules/pi-mcp-adapter/dist/abort.js +0 -36
  59. package/node_modules/pi-mcp-adapter/dist/abort.js.map +0 -1
  60. package/node_modules/pi-mcp-adapter/dist/agent-dir.d.ts +0 -10
  61. package/node_modules/pi-mcp-adapter/dist/agent-dir.js +0 -63
  62. package/node_modules/pi-mcp-adapter/dist/agent-dir.js.map +0 -1
  63. package/node_modules/pi-mcp-adapter/dist/agent-plugin-loader.d.ts +0 -8
  64. package/node_modules/pi-mcp-adapter/dist/agent-plugin-loader.js +0 -398
  65. package/node_modules/pi-mcp-adapter/dist/agent-plugin-loader.js.map +0 -1
  66. package/node_modules/pi-mcp-adapter/dist/agent-plugin-provenance.d.ts +0 -1
  67. package/node_modules/pi-mcp-adapter/dist/agent-plugin-provenance.js +0 -31
  68. package/node_modules/pi-mcp-adapter/dist/agent-plugin-provenance.js.map +0 -1
  69. package/node_modules/pi-mcp-adapter/dist/bearer-command-resolver.d.ts +0 -6
  70. package/node_modules/pi-mcp-adapter/dist/bearer-command-resolver.js +0 -194
  71. package/node_modules/pi-mcp-adapter/dist/bearer-command-resolver.js.map +0 -1
  72. package/node_modules/pi-mcp-adapter/dist/claude-plugin-loader.d.ts +0 -9
  73. package/node_modules/pi-mcp-adapter/dist/claude-plugin-loader.js +0 -362
  74. package/node_modules/pi-mcp-adapter/dist/claude-plugin-loader.js.map +0 -1
  75. package/node_modules/pi-mcp-adapter/dist/config.d.ts +0 -134
  76. package/node_modules/pi-mcp-adapter/dist/config.js +0 -1361
  77. package/node_modules/pi-mcp-adapter/dist/config.js.map +0 -1
  78. package/node_modules/pi-mcp-adapter/dist/consent-manager.d.ts +0 -18
  79. package/node_modules/pi-mcp-adapter/dist/consent-manager.js +0 -88
  80. package/node_modules/pi-mcp-adapter/dist/consent-manager.js.map +0 -1
  81. package/node_modules/pi-mcp-adapter/dist/elicitation-handler.d.ts +0 -17
  82. package/node_modules/pi-mcp-adapter/dist/elicitation-handler.js +0 -316
  83. package/node_modules/pi-mcp-adapter/dist/elicitation-handler.js.map +0 -1
  84. package/node_modules/pi-mcp-adapter/dist/errors.d.ts +0 -131
  85. package/node_modules/pi-mcp-adapter/dist/errors.js +0 -278
  86. package/node_modules/pi-mcp-adapter/dist/errors.js.map +0 -1
  87. package/node_modules/pi-mcp-adapter/dist/http-ca.d.ts +0 -8
  88. package/node_modules/pi-mcp-adapter/dist/http-ca.js +0 -88
  89. package/node_modules/pi-mcp-adapter/dist/http-ca.js.map +0 -1
  90. package/node_modules/pi-mcp-adapter/dist/jev-client.d.ts +0 -14
  91. package/node_modules/pi-mcp-adapter/dist/jev-client.js +0 -367
  92. package/node_modules/pi-mcp-adapter/dist/jev-client.js.map +0 -1
  93. package/node_modules/pi-mcp-adapter/dist/jev-contracts.d.ts +0 -77
  94. package/node_modules/pi-mcp-adapter/dist/jev-contracts.js +0 -2
  95. package/node_modules/pi-mcp-adapter/dist/jev-contracts.js.map +0 -1
  96. package/node_modules/pi-mcp-adapter/dist/jev-key-store.d.ts +0 -51
  97. package/node_modules/pi-mcp-adapter/dist/jev-key-store.js +0 -205
  98. package/node_modules/pi-mcp-adapter/dist/jev-key-store.js.map +0 -1
  99. package/node_modules/pi-mcp-adapter/dist/json-schema-validator.d.ts +0 -2
  100. package/node_modules/pi-mcp-adapter/dist/json-schema-validator.js +0 -68
  101. package/node_modules/pi-mcp-adapter/dist/json-schema-validator.js.map +0 -1
  102. package/node_modules/pi-mcp-adapter/dist/lifecycle.d.ts +0 -56
  103. package/node_modules/pi-mcp-adapter/dist/lifecycle.js +0 -410
  104. package/node_modules/pi-mcp-adapter/dist/lifecycle.js.map +0 -1
  105. package/node_modules/pi-mcp-adapter/dist/logger.d.ts +0 -51
  106. package/node_modules/pi-mcp-adapter/dist/logger.js +0 -131
  107. package/node_modules/pi-mcp-adapter/dist/logger.js.map +0 -1
  108. package/node_modules/pi-mcp-adapter/dist/mcp-auth-fetch.d.ts +0 -26
  109. package/node_modules/pi-mcp-adapter/dist/mcp-auth-fetch.js +0 -103
  110. package/node_modules/pi-mcp-adapter/dist/mcp-auth-fetch.js.map +0 -1
  111. package/node_modules/pi-mcp-adapter/dist/mcp-auth-flow.d.ts +0 -118
  112. package/node_modules/pi-mcp-adapter/dist/mcp-auth-flow.js +0 -1097
  113. package/node_modules/pi-mcp-adapter/dist/mcp-auth-flow.js.map +0 -1
  114. package/node_modules/pi-mcp-adapter/dist/mcp-auth.d.ts +0 -170
  115. package/node_modules/pi-mcp-adapter/dist/mcp-auth.js +0 -1142
  116. package/node_modules/pi-mcp-adapter/dist/mcp-auth.js.map +0 -1
  117. package/node_modules/pi-mcp-adapter/dist/mcp-bearer-store.d.ts +0 -24
  118. package/node_modules/pi-mcp-adapter/dist/mcp-bearer-store.js +0 -203
  119. package/node_modules/pi-mcp-adapter/dist/mcp-bearer-store.js.map +0 -1
  120. package/node_modules/pi-mcp-adapter/dist/mcp-callback-server.d.ts +0 -53
  121. package/node_modules/pi-mcp-adapter/dist/mcp-callback-server.js +0 -441
  122. package/node_modules/pi-mcp-adapter/dist/mcp-callback-server.js.map +0 -1
  123. package/node_modules/pi-mcp-adapter/dist/mcp-oauth-provider.d.ts +0 -148
  124. package/node_modules/pi-mcp-adapter/dist/mcp-oauth-provider.js +0 -689
  125. package/node_modules/pi-mcp-adapter/dist/mcp-oauth-provider.js.map +0 -1
  126. package/node_modules/pi-mcp-adapter/dist/mcp-probe.d.ts +0 -6
  127. package/node_modules/pi-mcp-adapter/dist/mcp-probe.js +0 -166
  128. package/node_modules/pi-mcp-adapter/dist/mcp-probe.js.map +0 -1
  129. package/node_modules/pi-mcp-adapter/dist/mcp-tasks.d.ts +0 -102
  130. package/node_modules/pi-mcp-adapter/dist/mcp-tasks.js +0 -369
  131. package/node_modules/pi-mcp-adapter/dist/mcp-tasks.js.map +0 -1
  132. package/node_modules/pi-mcp-adapter/dist/mcp-trace.d.ts +0 -95
  133. package/node_modules/pi-mcp-adapter/dist/mcp-trace.js +0 -242
  134. package/node_modules/pi-mcp-adapter/dist/mcp-trace.js.map +0 -1
  135. package/node_modules/pi-mcp-adapter/dist/metadata-cache.d.ts +0 -19
  136. package/node_modules/pi-mcp-adapter/dist/metadata-cache.js +0 -301
  137. package/node_modules/pi-mcp-adapter/dist/metadata-cache.js.map +0 -1
  138. package/node_modules/pi-mcp-adapter/dist/npx-resolver.d.ts +0 -6
  139. package/node_modules/pi-mcp-adapter/dist/npx-resolver.js +0 -505
  140. package/node_modules/pi-mcp-adapter/dist/npx-resolver.js.map +0 -1
  141. package/node_modules/pi-mcp-adapter/dist/package-mcp-loader.d.ts +0 -2
  142. package/node_modules/pi-mcp-adapter/dist/package-mcp-loader.js +0 -144
  143. package/node_modules/pi-mcp-adapter/dist/package-mcp-loader.js.map +0 -1
  144. package/node_modules/pi-mcp-adapter/dist/request-headers-command.d.ts +0 -10
  145. package/node_modules/pi-mcp-adapter/dist/request-headers-command.js +0 -312
  146. package/node_modules/pi-mcp-adapter/dist/request-headers-command.js.map +0 -1
  147. package/node_modules/pi-mcp-adapter/dist/resource-tools.d.ts +0 -1
  148. package/node_modules/pi-mcp-adapter/dist/resource-tools.js +0 -15
  149. package/node_modules/pi-mcp-adapter/dist/resource-tools.js.map +0 -1
  150. package/node_modules/pi-mcp-adapter/dist/runtime-owner.d.ts +0 -13
  151. package/node_modules/pi-mcp-adapter/dist/runtime-owner.js +0 -97
  152. package/node_modules/pi-mcp-adapter/dist/runtime-owner.js.map +0 -1
  153. package/node_modules/pi-mcp-adapter/dist/sampling-handler.d.ts +0 -17
  154. package/node_modules/pi-mcp-adapter/dist/sampling-handler.js +0 -203
  155. package/node_modules/pi-mcp-adapter/dist/sampling-handler.js.map +0 -1
  156. package/node_modules/pi-mcp-adapter/dist/secure-keyring.d.ts +0 -11
  157. package/node_modules/pi-mcp-adapter/dist/secure-keyring.js +0 -172
  158. package/node_modules/pi-mcp-adapter/dist/secure-keyring.js.map +0 -1
  159. package/node_modules/pi-mcp-adapter/dist/server-manager.d.ts +0 -157
  160. package/node_modules/pi-mcp-adapter/dist/server-manager.js +0 -1745
  161. package/node_modules/pi-mcp-adapter/dist/server-manager.js.map +0 -1
  162. package/node_modules/pi-mcp-adapter/dist/session-approvals.d.ts +0 -34
  163. package/node_modules/pi-mcp-adapter/dist/session-approvals.js +0 -140
  164. package/node_modules/pi-mcp-adapter/dist/session-approvals.js.map +0 -1
  165. package/node_modules/pi-mcp-adapter/dist/session-recovery.d.ts +0 -26
  166. package/node_modules/pi-mcp-adapter/dist/session-recovery.js +0 -142
  167. package/node_modules/pi-mcp-adapter/dist/session-recovery.js.map +0 -1
  168. package/node_modules/pi-mcp-adapter/dist/state.d.ts +0 -73
  169. package/node_modules/pi-mcp-adapter/dist/state.js +0 -2
  170. package/node_modules/pi-mcp-adapter/dist/state.js.map +0 -1
  171. package/node_modules/pi-mcp-adapter/dist/types.d.ts +0 -642
  172. package/node_modules/pi-mcp-adapter/dist/types.js +0 -331
  173. package/node_modules/pi-mcp-adapter/dist/types.js.map +0 -1
  174. package/node_modules/pi-mcp-adapter/dist/ui-app-bridge-helpers.d.ts +0 -6
  175. package/node_modules/pi-mcp-adapter/dist/ui-app-bridge-helpers.js +0 -37
  176. package/node_modules/pi-mcp-adapter/dist/ui-app-bridge-helpers.js.map +0 -1
  177. package/node_modules/pi-mcp-adapter/dist/ui-resource-handler.d.ts +0 -17
  178. package/node_modules/pi-mcp-adapter/dist/ui-resource-handler.js +0 -219
  179. package/node_modules/pi-mcp-adapter/dist/ui-resource-handler.js.map +0 -1
  180. package/node_modules/pi-mcp-adapter/dist/ui-stream-types.d.ts +0 -104
  181. package/node_modules/pi-mcp-adapter/dist/ui-stream-types.js +0 -59
  182. package/node_modules/pi-mcp-adapter/dist/ui-stream-types.js.map +0 -1
  183. package/node_modules/pi-mcp-adapter/dist/ui-tool-visibility.d.ts +0 -4
  184. package/node_modules/pi-mcp-adapter/dist/ui-tool-visibility.js +0 -27
  185. package/node_modules/pi-mcp-adapter/dist/ui-tool-visibility.js.map +0 -1
  186. package/node_modules/pi-mcp-adapter/dist/unix-socket-transport.d.ts +0 -15
  187. package/node_modules/pi-mcp-adapter/dist/unix-socket-transport.js +0 -85
  188. package/node_modules/pi-mcp-adapter/dist/unix-socket-transport.js.map +0 -1
  189. package/node_modules/pi-mcp-adapter/dist/utils.d.ts +0 -41
  190. package/node_modules/pi-mcp-adapter/dist/utils.js +0 -417
  191. package/node_modules/pi-mcp-adapter/dist/utils.js.map +0 -1
  192. package/node_modules/pi-mcp-adapter/elicitation-handler.ts +0 -358
  193. package/node_modules/pi-mcp-adapter/error-signal.ts +0 -32
  194. package/node_modules/pi-mcp-adapter/errors.ts +0 -364
  195. package/node_modules/pi-mcp-adapter/examples/jev-accessibility-loop.mjs +0 -85
  196. package/node_modules/pi-mcp-adapter/examples/jev-semantic-filter.mjs +0 -34
  197. package/node_modules/pi-mcp-adapter/failure-backoff.ts +0 -23
  198. package/node_modules/pi-mcp-adapter/glimpse-ui.ts +0 -80
  199. package/node_modules/pi-mcp-adapter/host-html-template.ts +0 -515
  200. package/node_modules/pi-mcp-adapter/http-ca.ts +0 -84
  201. package/node_modules/pi-mcp-adapter/index.ts +0 -2106
  202. package/node_modules/pi-mcp-adapter/init.ts +0 -721
  203. package/node_modules/pi-mcp-adapter/jev-client.ts +0 -300
  204. package/node_modules/pi-mcp-adapter/jev-contracts.ts +0 -53
  205. package/node_modules/pi-mcp-adapter/jev-key-store.ts +0 -192
  206. package/node_modules/pi-mcp-adapter/json-schema-validator.ts +0 -83
  207. package/node_modules/pi-mcp-adapter/lazy-loader.ts +0 -7
  208. package/node_modules/pi-mcp-adapter/lifecycle.ts +0 -457
  209. package/node_modules/pi-mcp-adapter/logger.ts +0 -169
  210. package/node_modules/pi-mcp-adapter/mcp-auth-fetch.ts +0 -113
  211. package/node_modules/pi-mcp-adapter/mcp-auth-flow.ts +0 -1296
  212. package/node_modules/pi-mcp-adapter/mcp-auth.ts +0 -1287
  213. package/node_modules/pi-mcp-adapter/mcp-bearer-store.ts +0 -250
  214. package/node_modules/pi-mcp-adapter/mcp-callback-server.ts +0 -534
  215. package/node_modules/pi-mcp-adapter/mcp-code.ts +0 -495
  216. package/node_modules/pi-mcp-adapter/mcp-install.ts +0 -60
  217. package/node_modules/pi-mcp-adapter/mcp-keyring-helper.cjs +0 -89
  218. package/node_modules/pi-mcp-adapter/mcp-oauth-provider.ts +0 -819
  219. package/node_modules/pi-mcp-adapter/mcp-output-guard.ts +0 -511
  220. package/node_modules/pi-mcp-adapter/mcp-panel-theme.ts +0 -104
  221. package/node_modules/pi-mcp-adapter/mcp-panel.ts +0 -1099
  222. package/node_modules/pi-mcp-adapter/mcp-probe.ts +0 -201
  223. package/node_modules/pi-mcp-adapter/mcp-references.ts +0 -373
  224. package/node_modules/pi-mcp-adapter/mcp-script-worker.mjs +0 -137
  225. package/node_modules/pi-mcp-adapter/mcp-setup-panel.ts +0 -747
  226. package/node_modules/pi-mcp-adapter/mcp-status.ts +0 -105
  227. package/node_modules/pi-mcp-adapter/mcp-tasks.ts +0 -467
  228. package/node_modules/pi-mcp-adapter/mcp-trace.ts +0 -306
  229. package/node_modules/pi-mcp-adapter/metadata-cache.ts +0 -362
  230. package/node_modules/pi-mcp-adapter/namespace-tools.ts +0 -334
  231. package/node_modules/pi-mcp-adapter/npx-resolver.ts +0 -543
  232. package/node_modules/pi-mcp-adapter/oauth-handler.ts +0 -30
  233. package/node_modules/pi-mcp-adapter/oauth.ts +0 -52
  234. package/node_modules/pi-mcp-adapter/onboarding-state.ts +0 -76
  235. package/node_modules/pi-mcp-adapter/package-mcp-loader.ts +0 -156
  236. package/node_modules/pi-mcp-adapter/package.json +0 -219
  237. package/node_modules/pi-mcp-adapter/panel-keys.ts +0 -53
  238. package/node_modules/pi-mcp-adapter/prompts.ts +0 -385
  239. package/node_modules/pi-mcp-adapter/proxy-modes.ts +0 -1735
  240. package/node_modules/pi-mcp-adapter/request-headers-command.ts +0 -333
  241. package/node_modules/pi-mcp-adapter/resource-tools.ts +0 -17
  242. package/node_modules/pi-mcp-adapter/runtime-owner.ts +0 -106
  243. package/node_modules/pi-mcp-adapter/sampling-handler.ts +0 -261
  244. package/node_modules/pi-mcp-adapter/sandbox-proxy-template.ts +0 -144
  245. package/node_modules/pi-mcp-adapter/search-ranking.ts +0 -309
  246. package/node_modules/pi-mcp-adapter/secure-keyring.ts +0 -170
  247. package/node_modules/pi-mcp-adapter/semantic-search.ts +0 -186
  248. package/node_modules/pi-mcp-adapter/server-manager.ts +0 -2088
  249. package/node_modules/pi-mcp-adapter/session-approvals.ts +0 -201
  250. package/node_modules/pi-mcp-adapter/session-recovery.ts +0 -158
  251. package/node_modules/pi-mcp-adapter/skills/mcp-scripting/SKILL.md +0 -49
  252. package/node_modules/pi-mcp-adapter/state.ts +0 -71
  253. package/node_modules/pi-mcp-adapter/tool-approval.ts +0 -205
  254. package/node_modules/pi-mcp-adapter/tool-metadata.ts +0 -302
  255. package/node_modules/pi-mcp-adapter/tool-registrar.ts +0 -255
  256. package/node_modules/pi-mcp-adapter/tool-result-renderer.ts +0 -573
  257. package/node_modules/pi-mcp-adapter/ts-shape.ts +0 -149
  258. package/node_modules/pi-mcp-adapter/types.ts +0 -1120
  259. package/node_modules/pi-mcp-adapter/ui-app-bridge-helpers.ts +0 -40
  260. package/node_modules/pi-mcp-adapter/ui-resource-handler.ts +0 -266
  261. package/node_modules/pi-mcp-adapter/ui-server.ts +0 -993
  262. package/node_modules/pi-mcp-adapter/ui-session.ts +0 -624
  263. package/node_modules/pi-mcp-adapter/ui-stream-types.ts +0 -89
  264. package/node_modules/pi-mcp-adapter/ui-tool-visibility.ts +0 -25
  265. package/node_modules/pi-mcp-adapter/unix-socket-transport.ts +0 -85
  266. package/node_modules/pi-mcp-adapter/utils.ts +0 -464
@@ -1,573 +0,0 @@
1
- import type { AgentToolResult, ToolRenderResultOptions } from "@earendil-works/pi-coding-agent";
2
- import { type Component, Text, truncateToWidth, visibleWidth } from "@earendil-works/pi-tui";
3
-
4
- type McpToolResultDetails = Record<string, unknown> & { error?: unknown };
5
- type McpToolContentBlock = AgentToolResult<McpToolResultDetails>["content"][number];
6
-
7
- export interface RenderTheme {
8
- fg: (name: string, text: string) => string;
9
- bold?: (text: string) => string;
10
- }
11
-
12
- const plainTheme: RenderTheme = { fg: (_name, text) => text };
13
-
14
- export interface McpProxyToolCallInput {
15
- tool?: string;
16
- args?: string | Record<string, unknown>;
17
- connect?: string;
18
- describe?: string;
19
- search?: string;
20
- regex?: boolean;
21
- includeSchemas?: boolean;
22
- server?: string;
23
- action?: string;
24
- }
25
-
26
- interface McpToolRenderState {
27
- compactTitle?: string;
28
- compactInputPreview?: string;
29
- }
30
-
31
- export interface McpToolRenderContext {
32
- isError: boolean;
33
- isPartial?: boolean;
34
- expanded?: boolean;
35
- state?: McpToolRenderState;
36
- }
37
-
38
- export type McpToolResultRendering = "compact" | "boxed";
39
-
40
- export interface McpToolRenderOptions {
41
- resultRendering: McpToolResultRendering;
42
- collapsedResultLines: 1 | 2 | 3;
43
- }
44
-
45
- export interface McpToolRenderSettings {
46
- toolResultRendering?: unknown;
47
- collapsedResultLines?: unknown;
48
- }
49
-
50
- export interface McpToolResultDisplay {
51
- lines: string[];
52
- truncated: boolean;
53
- }
54
-
55
- const DEFAULT_MAX_CALL_INPUT_CHARS = 1500;
56
- const DEFAULT_MAX_COMPACT_INPUT_CHARS = 240;
57
- const DEFAULT_BOXED_COLLAPSED_LINES = 3;
58
- const DEFAULT_COMPACT_COLLAPSED_LINES = 1;
59
- const DEFAULT_MAX_COLLAPSED_CHARS = 8000;
60
- const COLLAPSED_RENDER_CHAR_SLACK = 8;
61
-
62
- class EmptyComponent implements Component {
63
- render(): string[] {
64
- return [];
65
- }
66
-
67
- invalidate(): void {}
68
- }
69
-
70
- class CompactMcpToolResult implements Component {
71
- private rendered: { width: number; lines: string[] } | null = null;
72
-
73
- constructor(
74
- private readonly title: string,
75
- private readonly inputPreview: string,
76
- private readonly display: McpToolResultDisplay,
77
- private readonly theme: RenderTheme,
78
- /** Shown after the title and never truncated; the title shrinks instead (e.g. `✗3`). */
79
- private readonly status = "",
80
- ) {}
81
-
82
- render(width: number): string[] {
83
- const safeWidth = Math.max(1, Math.floor(width));
84
- if (this.rendered?.width === safeWidth) return this.rendered.lines;
85
-
86
- const resultLines = this.display.lines.filter((line, index, lines) => {
87
- return !(this.display.truncated && index === lines.length - 1 && line === "…");
88
- });
89
- const lines = resultLines.length > 0 ? resultLines : [""];
90
- const bodies = lines.map((line, index) => {
91
- const prefix = index === 0 ? this.renderPrefix(safeWidth) : "";
92
- return `${prefix}${this.theme.fg("toolOutput", line)}`;
93
- });
94
- const hiddenText = this.display.truncated || bodies.some((body) => visibleWidth(body) > safeWidth);
95
- const rendered = bodies.map((body, index) => {
96
- const suffix = hiddenText && index === bodies.length - 1 ? " … (Ctrl+O to expand)" : "";
97
- if (!suffix) return truncateToWidth(body, safeWidth, "…");
98
- if (safeWidth >= suffix.length + 20) {
99
- return `${truncateToWidth(body, safeWidth - suffix.length, "…")}${this.theme.fg("muted", suffix)}`;
100
- }
101
- const shortSuffix = " (Ctrl+O)";
102
- if (safeWidth >= shortSuffix.length + 5) {
103
- return `${truncateToWidth(body, safeWidth - shortSuffix.length, "…")}${this.theme.fg("muted", shortSuffix)}`;
104
- }
105
- return truncateToWidth(this.theme.fg("muted", shortSuffix.trim()), safeWidth, "…");
106
- });
107
- this.rendered = { width: safeWidth, lines: rendered };
108
- return rendered;
109
- }
110
-
111
- invalidate(): void {
112
- this.rendered = null;
113
- }
114
-
115
- private renderPrefix(width: number): string {
116
- if (!this.title) return "";
117
- const arrow = " → ";
118
- const statusWidth = this.status ? visibleWidth(this.status) + 1 : 0;
119
- const head = (maxWidth?: number) => {
120
- const title = maxWidth === undefined
121
- ? this.title
122
- : truncateToWidth(this.title, Math.max(1, maxWidth - statusWidth), "…");
123
- const status = this.status ? ` ${this.theme.fg("error", this.status)}` : "";
124
- return `${this.theme.fg("toolTitle", title)}${status}`;
125
- };
126
- if (!this.inputPreview) return `${head()}${arrow}`;
127
-
128
- const maxPrefixWidth = Math.max(12, Math.floor(width * 0.55));
129
- const titleWidth = visibleWidth(this.title) + statusWidth;
130
- const inputWidth = Math.max(0, maxPrefixWidth - titleWidth - 1);
131
- if (inputWidth <= 3) return `${head(maxPrefixWidth)}${arrow}`;
132
-
133
- const input = truncateToWidth(this.inputPreview, inputWidth, "…");
134
- return `${head()} ${this.theme.fg("muted", input)}${arrow}`;
135
- }
136
- }
137
-
138
- class CollapsibleText implements Component {
139
- private readonly fullText: Text;
140
- private readonly footerText: Text;
141
- private collapsedText: { charBudget: number; fullyIncluded: boolean; text: Text } | null = null;
142
- private collapsedRender: { width: number; charBudget: number; lines: string[] } | null = null;
143
-
144
- constructor(
145
- private readonly text: string,
146
- private readonly expanded: boolean,
147
- private readonly maxCollapsedLines: number,
148
- ellipsis: string,
149
- expandHint: string,
150
- private readonly preTruncated = false,
151
- ) {
152
- this.fullText = new Text(text, 0, 0);
153
- this.footerText = new Text(`${ellipsis}\n${expandHint}`, 0, 0);
154
- }
155
-
156
- render(width: number): string[] {
157
- if (this.expanded) {
158
- return this.fullText.render(width);
159
- }
160
-
161
- const safeWidth = Math.max(1, Math.floor(width));
162
- const charBudget = safeWidth * (this.maxCollapsedLines + 1) * COLLAPSED_RENDER_CHAR_SLACK;
163
- if (!this.collapsedText || this.collapsedText.charBudget !== charBudget) {
164
- const prefix = this.text.length > charBudget
165
- ? this.text.slice(0, charBudget)
166
- : this.text;
167
- this.collapsedText = {
168
- charBudget,
169
- fullyIncluded: prefix === this.text,
170
- text: new Text(prefix, 0, 0),
171
- };
172
- this.collapsedRender = null;
173
- }
174
-
175
- const lines = this.collapsedText.text.render(width);
176
- if (!this.preTruncated && this.collapsedText.fullyIncluded && lines.length <= this.maxCollapsedLines) return lines;
177
- if (this.collapsedRender?.width === width && this.collapsedRender.charBudget === charBudget) {
178
- return this.collapsedRender.lines;
179
- }
180
-
181
- const rendered = [
182
- ...lines.slice(0, this.maxCollapsedLines),
183
- ...this.footerText.render(width),
184
- ];
185
- this.collapsedRender = { width, charBudget, lines: rendered };
186
- return rendered;
187
- }
188
-
189
- invalidate(): void {
190
- this.fullText.invalidate();
191
- this.footerText.invalidate();
192
- this.collapsedText?.text.invalidate();
193
- this.collapsedRender = null;
194
- }
195
- }
196
-
197
- function truncateText(value: string, maxChars: number): string {
198
- if (value.length <= maxChars) return value;
199
- return `${value.slice(0, Math.max(0, maxChars - 1))}…`;
200
- }
201
-
202
- function formatJsonish(value: unknown, maxChars: number): string {
203
- if (typeof value === "string") {
204
- try {
205
- return truncateText(JSON.stringify(JSON.parse(value), null, 2), maxChars);
206
- } catch {
207
- return truncateText(value, maxChars);
208
- }
209
- }
210
-
211
- try {
212
- return truncateText(JSON.stringify(value, null, 2), maxChars);
213
- } catch {
214
- return truncateText(String(value), maxChars);
215
- }
216
- }
217
-
218
- function hasUsefulObjectContent(value: unknown): boolean {
219
- return typeof value === "object" && value !== null && !Array.isArray(value) && Object.keys(value).length > 0;
220
- }
221
-
222
- export function formatMcpProxyToolCallLines(
223
- args: McpProxyToolCallInput,
224
- maxInputChars = DEFAULT_MAX_CALL_INPUT_CHARS,
225
- ): string[] {
226
- if (args.action === "ui-messages") return [`mcp ${args.action}`];
227
-
228
- if (args.tool) {
229
- const target = args.server ? `${args.tool} @ ${args.server}` : args.tool;
230
- const lines = [`mcp call ${target}`];
231
- if (args.args) lines.push(formatJsonish(args.args, maxInputChars));
232
- return lines;
233
- }
234
-
235
- if (args.connect) return [`mcp connect ${args.connect}`];
236
- if (args.describe) {
237
- const target = args.server ? `${args.describe} @ ${args.server}` : args.describe;
238
- return [`mcp describe ${target}`];
239
- }
240
-
241
- if (args.search) {
242
- let line = `mcp search ${args.search}`;
243
- if (args.server) line += ` @ ${args.server}`;
244
- if (args.regex === true) line += " (regex)";
245
- if (args.includeSchemas === false) line += " (schemas hidden)";
246
- return [line];
247
- }
248
-
249
- if (args.server) return [`mcp list ${args.server}`];
250
- if (args.action) return [`mcp ${args.action}`];
251
-
252
- return ["mcp status"];
253
- }
254
-
255
- export function formatMcpDirectToolCallLines(
256
- displayName: string,
257
- args: Record<string, unknown>,
258
- maxInputChars = DEFAULT_MAX_CALL_INPUT_CHARS,
259
- ): string[] {
260
- if (!hasUsefulObjectContent(args)) return [displayName];
261
- return [displayName, formatJsonish(args, maxInputChars)];
262
- }
263
-
264
- export function formatMcpScriptToolCallLines(
265
- args: { code: string },
266
- maxInputChars = DEFAULT_MAX_CALL_INPUT_CHARS,
267
- ): string[] {
268
- return ["mcpScript", truncateText(args.code, maxInputChars)];
269
- }
270
-
271
- function renderToolCallLines(lines: string[], theme?: RenderTheme) {
272
- const activeTheme = theme ?? plainTheme;
273
- const [title = "mcp", ...rest] = lines;
274
- const styledTitle = activeTheme.fg("toolTitle", activeTheme.bold ? activeTheme.bold(title) : title);
275
- const styledRest = rest.map(line => activeTheme.fg("muted", line));
276
- return new Text([styledTitle, ...styledRest].join("\n"), 0, 0);
277
- }
278
-
279
- function formatCompactInputPreview(lines: string[], maxChars = DEFAULT_MAX_COMPACT_INPUT_CHARS): string {
280
- return truncateText(lines.slice(1).join(" ").replace(/\s+/g, " ").trim(), maxChars);
281
- }
282
-
283
- export function resolveMcpToolRenderOptions(settings?: McpToolRenderSettings): McpToolRenderOptions {
284
- const resultRendering = settings?.toolResultRendering === "boxed" ? "boxed" : "compact";
285
- const collapsedLines = settings?.collapsedResultLines;
286
- const defaultLines = resultRendering === "boxed" ? DEFAULT_BOXED_COLLAPSED_LINES : DEFAULT_COMPACT_COLLAPSED_LINES;
287
- return {
288
- resultRendering,
289
- collapsedResultLines: collapsedLines === 1 || collapsedLines === 2 || collapsedLines === 3 ? collapsedLines : defaultLines,
290
- };
291
- }
292
-
293
- function shouldUseCompactFinalRender(options: McpToolRenderOptions, context?: McpToolRenderContext): boolean {
294
- return options.resultRendering === "compact"
295
- && context !== undefined
296
- && context.isPartial === false
297
- && context.expanded !== true
298
- && context.isError !== true;
299
- }
300
-
301
- function renderToolCall(
302
- lines: string[],
303
- theme: RenderTheme | undefined,
304
- context: McpToolRenderContext | undefined,
305
- options: McpToolRenderOptions,
306
- ) {
307
- if (context?.state) {
308
- context.state.compactTitle = lines[0] ?? "mcp";
309
- context.state.compactInputPreview = formatCompactInputPreview(lines);
310
- }
311
- if (shouldUseCompactFinalRender(options, context)) return new EmptyComponent();
312
- return renderToolCallLines(lines, theme);
313
- }
314
-
315
- export function renderMcpProxyToolCall(
316
- args: McpProxyToolCallInput,
317
- theme?: RenderTheme,
318
- context?: McpToolRenderContext,
319
- ) {
320
- return renderToolCall(formatMcpProxyToolCallLines(args), theme, context, resolveMcpToolRenderOptions());
321
- }
322
-
323
- export function createMcpProxyToolCallRenderer(options: McpToolRenderOptions) {
324
- return (args: McpProxyToolCallInput, theme?: RenderTheme, context?: McpToolRenderContext) => {
325
- return renderToolCall(formatMcpProxyToolCallLines(args), theme, context, options);
326
- };
327
- }
328
-
329
- export function createMcpDirectToolCallRenderer(displayName: string, options = resolveMcpToolRenderOptions()) {
330
- return (args: Record<string, unknown>, theme?: RenderTheme, context?: McpToolRenderContext) => {
331
- return renderToolCall(formatMcpDirectToolCallLines(displayName, args), theme, context, options);
332
- };
333
- }
334
-
335
- export function createMcpScriptToolCallRenderer(options = resolveMcpToolRenderOptions()) {
336
- return (args: { code: string }, theme?: RenderTheme, context?: McpToolRenderContext) => {
337
- // Compact mode hides this call row once the result lands, so leave a title for the result row.
338
- // The tool list comes from the result's `details.calls` trace (see formatMcpScriptCallSummary);
339
- // the script code itself is never copied into the compact row.
340
- if (context?.state) context.state.compactTitle = MCP_SCRIPT_TITLE;
341
- if (shouldUseCompactFinalRender(options, context)) return new EmptyComponent();
342
- return renderToolCallLines(formatMcpScriptToolCallLines(args), theme);
343
- };
344
- }
345
-
346
- const MCP_SCRIPT_TITLE = "mcpScript";
347
- const MCP_SCRIPT_SUMMARY_MAX_TOOLS = 4;
348
-
349
- export interface McpScriptCallSummary {
350
- /** Traced operations that failed; the compact row shows it as `mcpScript ✗N`. */
351
- failed: number;
352
- /** What the script touched; "" when it made no MCP operations. */
353
- preview: string;
354
- }
355
-
356
- const PLAIN_TOOL_PATH = /^[A-Za-z0-9_.\/:@-]+$/;
357
-
358
- /**
359
- * Traced paths are script-supplied. Only identifier-like paths (what MCP tool names look like)
360
- * are shown bare. Anything else is shown as a quoted, ASCII-escaped JSON string, so it cannot
361
- * break the row, cannot pass for summary syntax (`foo×2`, `a, b`, ` · `, `+1 more`), and stays
362
- * distinct from the clean path it may resemble (`demo_red` vs `"\u001b[31mdemo_red"`).
363
- */
364
- function formatTracedPath(path: string): string {
365
- if (PLAIN_TOOL_PATH.test(path)) return path;
366
- // JSON.stringify quotes and escapes C0 controls, quotes and backslashes; escaping all other
367
- // non-ASCII too rules out DEL, C1 controls, bidi overrides and invisible characters.
368
- return JSON.stringify(path).replace(/[^\x20-\x7e]/g, (char) => `\\u${char.charCodeAt(0).toString(16).padStart(4, "0")}`);
369
- }
370
-
371
- /**
372
- * Failure count and compact-row preview for an mcpScript run, from the `details.calls` trace.
373
- * The preview lists distinct tool paths in first-call order with repeat counts, then other
374
- * operation counts, e.g. `github_search_issues×6, slack_post_message · search`.
375
- * Scripts that only describe tools list the described paths instead (`describe a, b`).
376
- * The failure count is rendered as a title status, not in the preview: narrow rows drop the
377
- * preview first, and the status is never truncated (the title shrinks instead).
378
- * Returns null for non-script results.
379
- */
380
- export function formatMcpScriptCallSummary(
381
- details: McpToolResultDetails | undefined,
382
- maxTools = MCP_SCRIPT_SUMMARY_MAX_TOOLS,
383
- ): McpScriptCallSummary | null {
384
- if (details?.mode !== "script") return null;
385
- const operations = Array.isArray(details.calls) ? details.calls : [];
386
- const callCounts = new Map<string, number>();
387
- const describeCounts = new Map<string, number>();
388
- const metaCounts = new Map<string, number>();
389
- let failed = 0;
390
- for (const operation of operations) {
391
- if (typeof operation !== "object" || operation === null) continue;
392
- const { operation: kind, path, ok } = operation as { operation?: unknown; path?: unknown; ok?: unknown };
393
- if (typeof kind !== "string") continue;
394
- if (ok === false) failed += 1;
395
- const target = kind === "call" ? callCounts : kind === "describe" ? describeCounts : null;
396
- if (target && typeof path === "string") {
397
- target.set(path, (target.get(path) ?? 0) + 1);
398
- } else {
399
- metaCounts.set(kind, (metaCounts.get(kind) ?? 0) + 1);
400
- }
401
- }
402
-
403
- const withCount = (name: string, count: number) => (count > 1 ? `${name}×${count}` : name);
404
- const listPaths = (counts: Map<string, number>) => {
405
- const names = [...counts].map(([path, count]) => withCount(formatTracedPath(path), count));
406
- return names.length > maxTools
407
- ? [...names.slice(0, maxTools), `+${names.length - maxTools} more`].join(", ")
408
- : names.join(", ");
409
- };
410
-
411
- let tools = listPaths(callCounts);
412
- if (!tools && describeCounts.size > 0) {
413
- tools = `describe ${listPaths(describeCounts)}`;
414
- } else {
415
- const describes = [...describeCounts.values()].reduce((sum, count) => sum + count, 0);
416
- if (describes > 0) metaCounts.set("describe", describes);
417
- }
418
- const meta = [...metaCounts].map(([kind, count]) => withCount(kind, count)).join(", ");
419
- return { failed, preview: [tools, meta].filter(Boolean).join(" · ") };
420
- }
421
-
422
- function blockToLines(block: McpToolContentBlock): string[] {
423
- if (block.type === "text") {
424
- return block.text.split("\n");
425
- }
426
- return [`[image: ${block.mimeType}]`];
427
- }
428
-
429
- function collectCollapsedResultLines(
430
- content: AgentToolResult<McpToolResultDetails>["content"],
431
- maxLines: number,
432
- maxChars: number,
433
- ): McpToolResultDisplay {
434
- if (content.length === 0) return { lines: ["(empty result)"], truncated: false };
435
-
436
- const lines: string[] = [];
437
- let remainingChars = maxChars;
438
- let truncated = false;
439
-
440
- const appendLine = (line: string) => {
441
- if (lines.length === 0) {
442
- const previewWidth = Math.min(line.length, remainingChars);
443
- if (line.slice(0, previewWidth).trim() === "") {
444
- if (line.length >= remainingChars) {
445
- truncated = true;
446
- remainingChars = 0;
447
- return false;
448
- }
449
- remainingChars -= line.length + 1;
450
- return true;
451
- }
452
- }
453
-
454
- if (lines.length >= maxLines || remainingChars <= 0) {
455
- truncated = true;
456
- return false;
457
- }
458
-
459
- if (line.length > remainingChars) {
460
- lines.push(line.slice(0, remainingChars));
461
- truncated = true;
462
- remainingChars = 0;
463
- return false;
464
- }
465
-
466
- lines.push(line);
467
- remainingChars -= line.length + 1;
468
- return true;
469
- };
470
-
471
- for (const block of content) {
472
- if (block.type !== "text") {
473
- if (!appendLine(`[image: ${block.mimeType}]`)) break;
474
- continue;
475
- }
476
-
477
- let start = 0;
478
- while (start <= block.text.length) {
479
- const newline = block.text.indexOf("\n", start);
480
- const line = newline === -1 ? block.text.slice(start) : block.text.slice(start, newline);
481
- if (!appendLine(line)) break;
482
- if (newline === -1) break;
483
- start = newline + 1;
484
- }
485
-
486
- if (truncated) break;
487
- }
488
-
489
- if (lines.length === 0) lines.push(truncated ? "(leading blank output omitted)" : "");
490
- if (truncated && lines.length >= maxLines) lines.push("…");
491
- return { lines, truncated };
492
- }
493
-
494
- export function formatMcpToolResultIdentity(details: McpToolResultDetails | undefined): string | null {
495
- if (details?.mode !== "call") return null;
496
- const server = typeof details.server === "string"
497
- ? details.server
498
- : typeof details.hintServer === "string"
499
- ? details.hintServer
500
- : null;
501
- if (!server) return null;
502
- if (typeof details.tool === "string") return `MCP ${server}/${details.tool}`;
503
- if (typeof details.resourceUri === "string") return `MCP ${server} resource ${details.resourceUri}`;
504
- if (typeof details.requestedTool === "string") return `MCP ${server}/${details.requestedTool}`;
505
- return null;
506
- }
507
-
508
- export function formatMcpToolResultLines(
509
- result: Pick<AgentToolResult<McpToolResultDetails>, "content">,
510
- expanded: boolean,
511
- maxCollapsedLines = DEFAULT_BOXED_COLLAPSED_LINES,
512
- maxCollapsedChars = DEFAULT_MAX_COLLAPSED_CHARS,
513
- ): McpToolResultDisplay {
514
- if (!expanded) {
515
- return collectCollapsedResultLines(result.content, maxCollapsedLines, maxCollapsedChars);
516
- }
517
-
518
- const allLines = result.content.flatMap(blockToLines);
519
- const lines = allLines.length > 0 ? allLines : ["(empty result)"];
520
- return { lines, truncated: false };
521
- }
522
-
523
- export function renderMcpToolResult(
524
- result: AgentToolResult<McpToolResultDetails>,
525
- options: ToolRenderResultOptions,
526
- theme?: RenderTheme,
527
- context?: McpToolRenderContext,
528
- renderOptions = resolveMcpToolRenderOptions(),
529
- ) {
530
- const activeTheme = theme ?? plainTheme;
531
- if (options.isPartial) {
532
- return new Text(activeTheme.fg("warning", "Running MCP tool..."), 0, 0);
533
- }
534
-
535
- const hasErrorDetails = Boolean(result.details.error);
536
- const expanded = options.expanded || context?.isError === true || hasErrorDetails;
537
- if (!expanded && renderOptions.resultRendering === "compact") {
538
- const display = formatMcpToolResultLines(result, false, renderOptions.collapsedResultLines);
539
- const scriptSummary = formatMcpScriptCallSummary(result.details);
540
- if (scriptSummary) {
541
- const status = scriptSummary.failed > 0 ? `✗${scriptSummary.failed}` : "";
542
- return new CompactMcpToolResult(MCP_SCRIPT_TITLE, scriptSummary.preview, display, activeTheme, status);
543
- }
544
- const title = context?.state?.compactTitle ?? formatMcpToolResultIdentity(result.details) ?? "";
545
- const inputPreview = context?.state?.compactInputPreview ?? "";
546
- return new CompactMcpToolResult(title, inputPreview, display, activeTheme);
547
- }
548
-
549
- const display = formatMcpToolResultLines(result, expanded, renderOptions.collapsedResultLines);
550
- const identity = formatMcpToolResultIdentity(result.details);
551
- const output = [
552
- ...(identity ? [activeTheme.fg("muted", identity)] : []),
553
- ...display.lines.map((line) => activeTheme.fg("toolOutput", line)),
554
- ].join("\n");
555
-
556
- return new CollapsibleText(
557
- output,
558
- expanded,
559
- renderOptions.collapsedResultLines + (identity ? 1 : 0),
560
- activeTheme.fg("muted", "…"),
561
- activeTheme.fg("muted", "(Ctrl+O to expand)"),
562
- display.truncated,
563
- );
564
- }
565
-
566
- export function createMcpToolResultRenderer(renderOptions: McpToolRenderOptions) {
567
- return (
568
- result: AgentToolResult<McpToolResultDetails>,
569
- options: ToolRenderResultOptions,
570
- theme?: RenderTheme,
571
- context?: McpToolRenderContext,
572
- ) => renderMcpToolResult(result, options, theme, context, renderOptions);
573
- }