personal-bot 0.3.1 → 0.3.3

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 (436) hide show
  1. package/.claude-plugin/marketplace.json +2 -2
  2. package/.claude-plugin/plugin.json +2 -1
  3. package/DISCLAIMER.md +17 -0
  4. package/LICENSE +21 -0
  5. package/README.md +15 -5
  6. package/README.zh-CN.md +15 -5
  7. package/bin/pbot-pi-acp.mjs +27 -11
  8. package/bin/pbot.mjs +22 -2
  9. package/docs/README.md +3 -1
  10. package/docs/architecture/design.md +37 -24
  11. package/docs/architecture/extensibility.md +27 -19
  12. package/docs/architecture/model-context.md +4 -3
  13. package/docs/architecture/principles.md +5 -4
  14. package/docs/guides/capabilities.md +4 -4
  15. package/docs/guides/cross-harness-workers.md +3 -1
  16. package/docs/guides/history.md +73 -16
  17. package/docs/guides/workspace-configuration.md +35 -6
  18. package/docs/hosts/antigravity.md +2 -0
  19. package/docs/hosts/claude-code.md +1 -1
  20. package/docs/hosts/codex-qoder.md +63 -0
  21. package/docs/hosts/dsh.md +1 -1
  22. package/docs/hosts/pi.md +1 -1
  23. package/docs/maintainers/architecture-governance.md +78 -0
  24. package/hooks/hooks.json +3 -0
  25. package/lib/antigravity-plugin/DISCLAIMER.md +17 -0
  26. package/lib/antigravity-plugin/LICENSE +21 -0
  27. package/lib/antigravity-plugin/bin/pbot-pi-acp.mjs +36 -0
  28. package/lib/antigravity-plugin/hooks.json +7 -0
  29. package/lib/antigravity-plugin/lib/claude.js +2 -2
  30. package/lib/antigravity-plugin/lib/common/files.d.ts +2 -0
  31. package/lib/antigravity-plugin/lib/common/files.js +44 -0
  32. package/lib/antigravity-plugin/lib/common/validation.d.ts +4 -0
  33. package/lib/antigravity-plugin/lib/common/validation.js +8 -0
  34. package/lib/{extension/acp-member.d.ts → antigravity-plugin/lib/extension/acp/member.d.ts} +5 -5
  35. package/lib/{extension/acp-member.js → antigravity-plugin/lib/extension/acp/member.js} +6 -6
  36. package/lib/antigravity-plugin/lib/extension/acp-worker.js +222 -51
  37. package/lib/antigravity-plugin/lib/extension/hosts/dsh/acp-entry.d.ts +1 -0
  38. package/lib/antigravity-plugin/lib/extension/hosts/dsh/acp-entry.js +22 -0
  39. package/lib/{extension → antigravity-plugin/lib/extension/hosts}/dsh/acp-member.js +11 -25
  40. package/lib/{extension → antigravity-plugin/lib/extension/hosts}/dsh/files.js +3 -3
  41. package/lib/antigravity-plugin/lib/extension/hosts/pi/acp-member.d.ts +3 -0
  42. package/lib/antigravity-plugin/lib/extension/hosts/pi/acp-member.js +100 -0
  43. package/lib/antigravity-plugin/lib/extension/hosts/plugin-runtime.d.ts +12 -0
  44. package/lib/antigravity-plugin/lib/extension/hosts/plugin-runtime.js +101 -0
  45. package/lib/antigravity-plugin/lib/extension/hosts/workspace-mcp.d.ts +6 -0
  46. package/lib/antigravity-plugin/lib/extension/hosts/workspace-mcp.js +21 -0
  47. package/lib/antigravity-plugin/lib/extension/mcp.js +2705 -1348
  48. package/lib/antigravity-plugin/lib/extension/workspace-cli.js +20127 -0
  49. package/lib/antigravity-plugin/lib/integrations/agent-resources.d.ts +1 -0
  50. package/lib/antigravity-plugin/lib/integrations/agent-resources.js +6 -2
  51. package/lib/antigravity-plugin/lib/integrations/hosts/antigravity/adapter.d.ts +6 -0
  52. package/lib/antigravity-plugin/lib/integrations/hosts/antigravity/adapter.js +171 -0
  53. package/lib/antigravity-plugin/lib/integrations/hosts/{claude.d.ts → claude/adapter.d.ts} +1 -1
  54. package/lib/antigravity-plugin/lib/integrations/hosts/claude/adapter.js +36 -0
  55. package/lib/antigravity-plugin/lib/integrations/hosts/codex/adapter.d.ts +2 -0
  56. package/lib/antigravity-plugin/lib/integrations/hosts/codex/adapter.js +14 -0
  57. package/lib/{integrations → antigravity-plugin/lib/integrations/hosts}/dsh/mcp.d.ts +1 -1
  58. package/lib/{integrations → antigravity-plugin/lib/integrations/hosts}/dsh/resources.d.ts +1 -1
  59. package/lib/{integrations → antigravity-plugin/lib/integrations/hosts}/dsh/resources.js +4 -4
  60. package/lib/{integrations → antigravity-plugin/lib/integrations/hosts}/dsh/skills.js +1 -1
  61. package/lib/antigravity-plugin/lib/integrations/hosts/pi/agent-tools.d.ts +3 -0
  62. package/lib/antigravity-plugin/lib/integrations/hosts/pi/agent-tools.js +32 -0
  63. package/lib/antigravity-plugin/lib/integrations/hosts/pi/mcp.d.ts +4 -0
  64. package/lib/antigravity-plugin/lib/integrations/hosts/pi/mcp.js +23 -0
  65. package/lib/antigravity-plugin/lib/integrations/hosts/{registry.d.ts → plugin-registry.d.ts} +1 -0
  66. package/lib/{integrations/hosts/registry.js → antigravity-plugin/lib/integrations/hosts/plugin-registry.js} +10 -3
  67. package/lib/antigravity-plugin/lib/integrations/hosts/prompt-hooks.d.ts +76 -0
  68. package/lib/antigravity-plugin/lib/integrations/hosts/prompt-hooks.js +76 -0
  69. package/lib/antigravity-plugin/lib/integrations/hosts/qoder/adapter.d.ts +2 -0
  70. package/lib/antigravity-plugin/lib/integrations/hosts/qoder/adapter.js +16 -0
  71. package/lib/antigravity-plugin/lib/model/acp.d.ts +7 -3
  72. package/lib/antigravity-plugin/lib/model/acp.js +8 -0
  73. package/lib/antigravity-plugin/lib/model/agent.d.ts +121 -0
  74. package/lib/antigravity-plugin/lib/model/agent.js +4 -0
  75. package/lib/antigravity-plugin/lib/model/history.d.ts +179 -0
  76. package/lib/antigravity-plugin/lib/model/history.js +4 -0
  77. package/lib/antigravity-plugin/lib/model/plugin-host.d.ts +31 -0
  78. package/lib/antigravity-plugin/lib/model/workspace-config.d.ts +28 -7
  79. package/lib/antigravity-plugin/lib/model/workspace-config.js +2 -1
  80. package/lib/antigravity-plugin/lib/plugin.d.ts +2 -1
  81. package/lib/antigravity-plugin/lib/plugin.js +4 -4
  82. package/lib/antigravity-plugin/lib/services/history/history-capture.d.ts +4 -0
  83. package/lib/antigravity-plugin/lib/services/history/history-capture.js +98 -0
  84. package/lib/antigravity-plugin/lib/services/history/history-index.d.ts +17 -0
  85. package/lib/antigravity-plugin/lib/services/history/history-index.js +112 -0
  86. package/lib/antigravity-plugin/lib/services/history/summary-dimensions/monthly.d.ts +7 -0
  87. package/lib/antigravity-plugin/lib/services/history/summary-dimensions/monthly.js +121 -0
  88. package/lib/antigravity-plugin/lib/services/history/summary-dimensions/session.d.ts +7 -0
  89. package/lib/antigravity-plugin/lib/services/history/summary-dimensions/session.js +124 -0
  90. package/lib/antigravity-plugin/lib/services/history/summary-registry.d.ts +7 -0
  91. package/lib/antigravity-plugin/lib/services/history/summary-registry.js +35 -0
  92. package/lib/antigravity-plugin/lib/services/history/summary-runner.d.ts +34 -0
  93. package/lib/antigravity-plugin/lib/services/history/summary-runner.js +299 -0
  94. package/lib/antigravity-plugin/lib/services/history/workspace-history.d.ts +3 -0
  95. package/lib/antigravity-plugin/lib/services/history/workspace-history.js +6 -0
  96. package/lib/antigravity-plugin/lib/services/workspace/plugin-releases.d.ts +3 -0
  97. package/lib/antigravity-plugin/lib/services/workspace/plugin-releases.js +78 -0
  98. package/lib/antigravity-plugin/lib/services/workspace/workspace-config.d.ts +5 -1
  99. package/lib/antigravity-plugin/lib/services/workspace/workspace-config.js +77 -7
  100. package/lib/antigravity-plugin/lib/services/workspace/workspace-files.d.ts +2 -0
  101. package/lib/antigravity-plugin/lib/services/workspace/workspace-files.js +17 -0
  102. package/lib/antigravity-plugin/lib/services/workspace/workspace-mcp.d.ts +14 -0
  103. package/lib/antigravity-plugin/lib/services/workspace/workspace-mcp.js +193 -0
  104. package/lib/antigravity-plugin/lib/services/workspace/workspace-skills.d.ts +1 -0
  105. package/lib/antigravity-plugin/lib/services/workspace/workspace-skills.js +4 -2
  106. package/lib/antigravity-plugin/lib/storage/acp-files.d.ts +11 -0
  107. package/lib/antigravity-plugin/lib/storage/acp-files.js +75 -0
  108. package/lib/antigravity-plugin/lib/storage/agent-files.d.ts +31 -0
  109. package/lib/antigravity-plugin/lib/storage/agent-files.js +159 -0
  110. package/lib/antigravity-plugin/lib/storage/atomic-json.d.ts +3 -1
  111. package/lib/antigravity-plugin/lib/storage/atomic-json.js +43 -3
  112. package/lib/antigravity-plugin/lib/storage/file-access.d.ts +2 -0
  113. package/lib/antigravity-plugin/lib/storage/file-access.js +26 -0
  114. package/lib/antigravity-plugin/lib/storage/history-files.d.ts +55 -0
  115. package/lib/antigravity-plugin/lib/storage/history-files.js +473 -0
  116. package/lib/antigravity-plugin/lib/storage/history-format.d.ts +5 -0
  117. package/lib/antigravity-plugin/lib/storage/history-format.js +60 -0
  118. package/lib/antigravity-plugin/package.json +1 -1
  119. package/lib/antigravity-plugin/plugin.json +1 -1
  120. package/lib/antigravity-plugin/resources/prompts/history-monthly-summary.md +13 -0
  121. package/lib/antigravity-plugin/resources/prompts/history-summary.md +13 -0
  122. package/lib/antigravity-plugin/resources/prompts/plugin-coordinator.md +1 -0
  123. package/lib/antigravity-plugin/resources/skills/.claude-plugin/plugin.json +4 -0
  124. package/lib/antigravity-plugin/resources/skills/project-maintenance/SKILL.md +35 -0
  125. package/lib/antigravity-plugin/resources/skills/provider-connections/SKILL.md +52 -0
  126. package/lib/antigravity-plugin/skills/pbot/SKILL.md +11 -1
  127. package/lib/antigravity-plugin/skills/provider-connections/SKILL.md +22 -12
  128. package/lib/claude.js +2 -2
  129. package/lib/client.js +42 -60
  130. package/lib/codex-marketplace/.agents/plugins/marketplace.json +17 -0
  131. package/lib/codex-marketplace/plugins/personal-bot/.codex-plugin/plugin.json +7 -0
  132. package/lib/codex-marketplace/plugins/personal-bot/.mcp.json +17 -0
  133. package/lib/codex-marketplace/plugins/personal-bot/DISCLAIMER.md +17 -0
  134. package/lib/codex-marketplace/plugins/personal-bot/LICENSE +21 -0
  135. package/lib/codex-marketplace/plugins/personal-bot/hooks/hooks.json +37 -0
  136. package/lib/codex-marketplace/plugins/personal-bot/skills/pbot/SKILL.md +9 -0
  137. package/lib/codex-marketplace/plugins/personal-bot/skills/pbot/agents/openai.yaml +2 -0
  138. package/lib/common/validation.d.ts +4 -0
  139. package/lib/common/validation.js +8 -0
  140. package/lib/dsh.js +6 -6
  141. package/lib/extension/acp/member.d.ts +18 -0
  142. package/lib/extension/acp/member.js +44 -0
  143. package/lib/extension/acp/worker.js +384 -0
  144. package/lib/extension/acp-worker.js +222 -51
  145. package/lib/extension/history/command.d.ts +37 -0
  146. package/lib/extension/history/command.js +57 -0
  147. package/lib/extension/hosts/dsh/acp-entry.d.ts +1 -0
  148. package/lib/extension/hosts/dsh/acp-entry.js +22 -0
  149. package/lib/extension/hosts/dsh/acp-member.d.ts +4 -0
  150. package/lib/extension/hosts/dsh/acp-member.js +58 -0
  151. package/lib/extension/{dsh → hosts/dsh}/command.d.ts +1 -2
  152. package/lib/extension/{dsh → hosts/dsh}/command.js +9 -11
  153. package/lib/extension/hosts/dsh/files.d.ts +5 -0
  154. package/lib/extension/hosts/dsh/files.js +67 -0
  155. package/lib/extension/hosts/dsh/history.d.ts +4 -0
  156. package/lib/extension/hosts/dsh/history.js +62 -0
  157. package/lib/extension/{dsh → hosts/dsh}/management.d.ts +1 -1
  158. package/lib/extension/{dsh → hosts/dsh}/management.js +12 -10
  159. package/lib/extension/{dsh → hosts/dsh}/workspace.d.ts +3 -9
  160. package/lib/extension/{dsh → hosts/dsh}/workspace.js +30 -99
  161. package/lib/extension/hosts/pi/acp-member.d.ts +3 -0
  162. package/lib/extension/hosts/pi/acp-member.js +100 -0
  163. package/lib/extension/hosts/plugin-runtime.d.ts +12 -0
  164. package/lib/extension/hosts/plugin-runtime.js +101 -0
  165. package/lib/extension/hosts/workspace-mcp.d.ts +6 -0
  166. package/lib/extension/hosts/workspace-mcp.js +21 -0
  167. package/lib/extension/{mcp-bridge.d.ts → mcp/bridge.d.ts} +7 -9
  168. package/lib/extension/{mcp-bridge.js → mcp/bridge.js} +70 -88
  169. package/lib/extension/{mcp-workers.d.ts → mcp/tool-contract.d.ts} +129 -374
  170. package/lib/extension/mcp/tool-contract.js +441 -0
  171. package/lib/extension/mcp/workers.d.ts +487 -0
  172. package/lib/extension/mcp/workers.js +598 -0
  173. package/lib/extension/mcp.js +2705 -1348
  174. package/lib/extension/{setup-cli.js → setup/cli.js} +12 -9
  175. package/lib/extension/workspace-cli.js +20127 -0
  176. package/lib/integrations/acp/agents.d.ts +2 -3
  177. package/lib/integrations/acp/connection.d.ts +11 -10
  178. package/lib/integrations/acp/connection.js +6 -0
  179. package/lib/integrations/acp/harnesses/claude.js +1 -1
  180. package/lib/integrations/acp/harnesses/dsh.js +1 -1
  181. package/lib/integrations/acp/harnesses/presets.js +8 -0
  182. package/lib/integrations/acp/history-summary.d.ts +17 -0
  183. package/lib/integrations/acp/history-summary.js +101 -0
  184. package/lib/integrations/acp/launch.d.ts +2 -2
  185. package/lib/integrations/agent-resources.d.ts +1 -0
  186. package/lib/integrations/agent-resources.js +6 -2
  187. package/lib/integrations/hosts/antigravity/adapter.d.ts +6 -0
  188. package/lib/integrations/hosts/antigravity/adapter.js +171 -0
  189. package/lib/integrations/hosts/{claude.d.ts → claude/adapter.d.ts} +1 -1
  190. package/lib/integrations/hosts/claude/adapter.js +36 -0
  191. package/lib/integrations/hosts/codex/adapter.d.ts +2 -0
  192. package/lib/integrations/hosts/codex/adapter.js +14 -0
  193. package/lib/integrations/hosts/dsh/mcp.d.ts +4 -0
  194. package/lib/integrations/hosts/dsh/mcp.js +28 -0
  195. package/lib/integrations/hosts/dsh/messages.d.ts +36 -0
  196. package/lib/integrations/hosts/dsh/messages.js +11 -0
  197. package/lib/integrations/hosts/dsh/resources.d.ts +6 -0
  198. package/lib/integrations/hosts/dsh/resources.js +47 -0
  199. package/lib/integrations/hosts/dsh/root-agents.d.ts +4 -0
  200. package/lib/integrations/hosts/dsh/root-agents.js +3 -0
  201. package/lib/integrations/{dsh → hosts/dsh}/schema.js +1 -1
  202. package/lib/integrations/hosts/dsh/skills.d.ts +8 -0
  203. package/lib/integrations/hosts/dsh/skills.js +31 -0
  204. package/lib/integrations/hosts/pi/agent-tools.d.ts +3 -0
  205. package/lib/integrations/hosts/pi/agent-tools.js +32 -0
  206. package/lib/integrations/hosts/pi/mcp.d.ts +4 -0
  207. package/lib/integrations/hosts/pi/mcp.js +23 -0
  208. package/lib/integrations/hosts/{registry.d.ts → plugin-registry.d.ts} +1 -0
  209. package/lib/{antigravity-plugin/lib/integrations/hosts/registry.js → integrations/hosts/plugin-registry.js} +10 -3
  210. package/lib/integrations/hosts/prompt-hooks.d.ts +76 -0
  211. package/lib/integrations/hosts/prompt-hooks.js +76 -0
  212. package/lib/integrations/hosts/qoder/adapter.d.ts +2 -0
  213. package/lib/integrations/hosts/qoder/adapter.js +16 -0
  214. package/lib/integrations/installation/pi-setup.js +1 -1
  215. package/lib/model/acp.d.ts +7 -3
  216. package/lib/model/acp.js +8 -0
  217. package/lib/model/agent.d.ts +18 -4
  218. package/lib/model/agent.js +4 -1
  219. package/lib/model/history.d.ts +143 -34
  220. package/lib/model/history.js +4 -1
  221. package/lib/model/installation.js +1 -0
  222. package/lib/model/plugin-host.d.ts +31 -0
  223. package/lib/model/workspace-config.d.ts +28 -7
  224. package/lib/model/workspace-config.js +2 -1
  225. package/lib/plugin.d.ts +2 -1
  226. package/lib/plugin.js +4 -4
  227. package/lib/qoder-plugin/.mcp.json +17 -0
  228. package/lib/qoder-plugin/.qoder-plugin/plugin.json +7 -0
  229. package/lib/qoder-plugin/DISCLAIMER.md +17 -0
  230. package/lib/qoder-plugin/LICENSE +21 -0
  231. package/lib/qoder-plugin/hooks/hooks.json +37 -0
  232. package/lib/qoder-plugin/skills/pbot/SKILL.md +9 -0
  233. package/lib/services/agents/agent-run.d.ts +1 -1
  234. package/lib/services/agents/agent-service.d.ts +15 -45
  235. package/lib/services/agents/agent-service.js +22 -3
  236. package/lib/services/history/history-capture.d.ts +4 -0
  237. package/lib/services/history/history-capture.js +98 -0
  238. package/lib/services/history/history-index.d.ts +16 -7
  239. package/lib/services/history/history-index.js +48 -70
  240. package/lib/services/history/history-migrate.d.ts +12 -0
  241. package/lib/services/history/history-migrate.js +54 -0
  242. package/lib/services/history/history-query.d.ts +51 -0
  243. package/lib/services/history/history-query.js +352 -0
  244. package/lib/services/history/summary-command.d.ts +20 -0
  245. package/lib/services/history/summary-command.js +69 -0
  246. package/lib/services/history/summary-dimensions/monthly.d.ts +7 -0
  247. package/lib/services/history/summary-dimensions/monthly.js +121 -0
  248. package/lib/services/history/summary-dimensions/session.d.ts +7 -0
  249. package/lib/services/history/summary-dimensions/session.js +124 -0
  250. package/lib/services/history/summary-registry.d.ts +7 -0
  251. package/lib/services/history/summary-registry.js +35 -0
  252. package/lib/services/history/summary-runner.d.ts +34 -0
  253. package/lib/services/history/summary-runner.js +299 -0
  254. package/lib/services/history/workspace-history.d.ts +3 -0
  255. package/lib/services/history/workspace-history.js +6 -0
  256. package/lib/services/workspace/plugin-releases.d.ts +3 -0
  257. package/lib/services/workspace/plugin-releases.js +78 -0
  258. package/lib/services/workspace/workspace-config.d.ts +5 -1
  259. package/lib/services/workspace/workspace-config.js +77 -7
  260. package/lib/services/workspace/workspace-mcp.js +22 -29
  261. package/lib/services/workspace/workspace-skills.d.ts +1 -0
  262. package/lib/services/workspace/workspace-skills.js +4 -2
  263. package/lib/storage/acp-files.js +7 -12
  264. package/lib/storage/agent-files.js +6 -5
  265. package/lib/storage/atomic-json.d.ts +3 -1
  266. package/lib/storage/atomic-json.js +43 -3
  267. package/lib/storage/history-files.d.ts +46 -9
  268. package/lib/storage/history-files.js +382 -250
  269. package/lib/storage/history-format.d.ts +3 -13
  270. package/lib/storage/history-format.js +26 -52
  271. package/lib/tools/history/actions.d.ts +3 -68
  272. package/lib/tools/history/actions.js +7 -5
  273. package/lib/tools/history/contract.d.ts +16 -17
  274. package/lib/tools/history/contract.js +63 -22
  275. package/lib/tools/history/dsh-tool.d.ts +1 -2
  276. package/lib/tools/history/dsh-tool.js +11 -5
  277. package/lib/ui/dsh/elements.d.ts +2 -5
  278. package/lib/ui/dsh/elements.js +3 -16
  279. package/lib/ui/dsh/management.js +26 -13
  280. package/lib/ui/dsh/styles.d.ts +1 -1
  281. package/lib/ui/dsh/styles.js +5 -33
  282. package/package.json +4 -1
  283. package/resources/antigravity/skills/pbot/SKILL.md +11 -1
  284. package/resources/claude/skills/pbot/SKILL.md +11 -1
  285. package/resources/plugin/skills/pbot/SKILL.md +9 -0
  286. package/resources/prompts/history-coordinator.md +2 -1
  287. package/resources/prompts/history-monthly-summary.md +13 -0
  288. package/resources/prompts/history-summary.md +10 -4
  289. package/resources/prompts/plugin-coordinator.md +1 -0
  290. package/resources/skills/provider-connections/SKILL.md +22 -12
  291. package/scripts/README.md +3 -2
  292. package/src/claude.ts +2 -2
  293. package/src/common/validation.ts +10 -0
  294. package/src/dsh.ts +6 -6
  295. package/src/extension/{acp-member.ts → acp/member.ts} +7 -7
  296. package/src/extension/{acp-worker.ts → acp/worker.ts} +131 -17
  297. package/src/extension/history/command.ts +68 -0
  298. package/src/extension/hosts/dsh/acp-entry.ts +21 -0
  299. package/src/extension/{dsh → hosts/dsh}/acp-member.ts +12 -23
  300. package/src/extension/{dsh → hosts/dsh}/command.ts +10 -12
  301. package/src/extension/{dsh → hosts/dsh}/files.ts +3 -3
  302. package/src/extension/hosts/dsh/history.ts +67 -0
  303. package/src/extension/{dsh → hosts/dsh}/management.ts +11 -9
  304. package/src/extension/{dsh → hosts/dsh}/workspace.ts +31 -76
  305. package/src/extension/{pi-acp-member.ts → hosts/pi/acp-member.ts} +12 -18
  306. package/src/extension/{command.ts → hosts/pi/command.ts} +44 -11
  307. package/src/extension/{events.ts → hosts/pi/events.ts} +8 -4
  308. package/src/extension/hosts/pi/history.ts +45 -0
  309. package/src/extension/{lifecycle.ts → hosts/pi/lifecycle.ts} +9 -12
  310. package/src/extension/hosts/plugin-runtime.ts +96 -0
  311. package/src/extension/hosts/workspace-mcp.ts +25 -0
  312. package/src/extension/{mcp-bridge.ts → mcp/bridge.ts} +85 -85
  313. package/src/extension/mcp/tool-contract.ts +462 -0
  314. package/src/extension/{mcp-workers.ts → mcp/workers.ts} +151 -448
  315. package/src/extension/{setup-cli.ts → setup/cli.ts} +14 -11
  316. package/src/extension/setup/workspace-cli.ts +159 -0
  317. package/src/integrations/acp/agents.ts +2 -3
  318. package/src/integrations/acp/connection.ts +6 -0
  319. package/src/integrations/acp/harnesses/claude.ts +1 -1
  320. package/src/integrations/acp/harnesses/dsh.ts +1 -1
  321. package/src/integrations/acp/harnesses/presets.ts +8 -0
  322. package/src/integrations/acp/history-summary.ts +109 -0
  323. package/src/integrations/agent-resources.ts +7 -1
  324. package/src/integrations/hosts/antigravity/adapter.ts +161 -0
  325. package/src/integrations/hosts/claude/adapter.ts +39 -0
  326. package/src/integrations/hosts/codex/adapter.ts +16 -0
  327. package/src/integrations/{dsh → hosts/dsh}/mcp.ts +1 -1
  328. package/src/integrations/{dsh → hosts/dsh}/resources.ts +5 -5
  329. package/src/integrations/{dsh → hosts/dsh}/schema.ts +1 -1
  330. package/src/integrations/{dsh → hosts/dsh}/session.ts +2 -2
  331. package/src/integrations/{dsh → hosts/dsh}/skills.ts +1 -1
  332. package/src/integrations/{pi → hosts/pi}/mcp.ts +1 -1
  333. package/src/integrations/{pi → hosts/pi}/skills.ts +1 -1
  334. package/src/integrations/hosts/{registry.ts → plugin-registry.ts} +11 -3
  335. package/src/integrations/hosts/prompt-hooks.ts +72 -0
  336. package/src/integrations/hosts/qoder/adapter.ts +19 -0
  337. package/src/integrations/installation/cli-update.ts +116 -0
  338. package/src/integrations/installation/pi-bridge.ts +1 -1
  339. package/src/integrations/installation/pi-setup.ts +2 -2
  340. package/src/integrations/installation/processes.ts +1 -1
  341. package/src/mcp.ts +1 -1
  342. package/src/model/acp.ts +11 -3
  343. package/src/model/agent.ts +20 -4
  344. package/src/model/history.ts +156 -26
  345. package/src/model/installation.ts +41 -0
  346. package/src/model/plugin-host.ts +30 -2
  347. package/src/model/workspace-config.ts +31 -7
  348. package/src/pbot.ts +22 -50
  349. package/src/plugin.ts +4 -4
  350. package/src/services/agents/agent-service.ts +29 -17
  351. package/src/services/history/history-capture.ts +91 -0
  352. package/src/services/history/history-index.ts +48 -62
  353. package/src/services/history/history-migrate.ts +62 -0
  354. package/src/services/history/history-query.ts +401 -0
  355. package/src/services/history/summary-command.ts +70 -0
  356. package/src/services/history/summary-dimensions/monthly.ts +139 -0
  357. package/src/services/history/summary-dimensions/session.ts +149 -0
  358. package/src/services/history/summary-registry.ts +43 -0
  359. package/src/services/history/summary-runner.ts +343 -0
  360. package/src/services/history/workspace-history.ts +8 -0
  361. package/src/services/installation/setup-service.ts +2 -41
  362. package/src/services/workspace/plugin-releases.ts +68 -0
  363. package/src/services/workspace/workspace-config.ts +95 -8
  364. package/src/services/workspace/workspace-mcp.ts +23 -28
  365. package/src/services/workspace/workspace-skills.ts +5 -2
  366. package/src/storage/acp-files.ts +7 -12
  367. package/src/storage/agent-files.ts +6 -5
  368. package/src/storage/atomic-json.ts +31 -4
  369. package/src/storage/history-files.ts +416 -189
  370. package/src/storage/history-format.ts +45 -61
  371. package/src/tools/history/actions.ts +8 -6
  372. package/src/tools/history/contract.ts +70 -25
  373. package/src/tools/history/dsh-tool.ts +17 -8
  374. package/src/tools/history/pi-tool.ts +23 -0
  375. package/src/ui/dsh/elements.ts +5 -12
  376. package/src/ui/dsh/management.ts +36 -20
  377. package/src/ui/dsh/styles.ts +5 -33
  378. package/src/ui/{confirmation.ts → pi/confirmation.ts} +1 -1
  379. package/lib/antigravity-plugin/lib/extension/plugin-runtime.d.ts +0 -10
  380. package/lib/antigravity-plugin/lib/extension/plugin-runtime.js +0 -67
  381. package/lib/antigravity-plugin/lib/integrations/hosts/antigravity.d.ts +0 -4
  382. package/lib/antigravity-plugin/lib/integrations/hosts/antigravity.js +0 -79
  383. package/lib/antigravity-plugin/lib/integrations/hosts/claude.js +0 -60
  384. package/lib/extension/dsh/history.d.ts +0 -15
  385. package/lib/extension/dsh/history.js +0 -87
  386. package/lib/extension/mcp-workers.js +0 -882
  387. package/lib/extension/plugin-runtime.d.ts +0 -10
  388. package/lib/extension/plugin-runtime.js +0 -67
  389. package/lib/integrations/dsh/history-summary.d.ts +0 -11
  390. package/lib/integrations/dsh/history-summary.js +0 -36
  391. package/lib/integrations/dsh/history.d.ts +0 -16
  392. package/lib/integrations/dsh/history.js +0 -167
  393. package/lib/integrations/history-summary.d.ts +0 -4
  394. package/lib/integrations/history-summary.js +0 -32
  395. package/lib/integrations/hosts/antigravity.d.ts +0 -4
  396. package/lib/integrations/hosts/antigravity.js +0 -79
  397. package/lib/integrations/hosts/claude.js +0 -60
  398. package/lib/services/history/history-service.d.ts +0 -106
  399. package/lib/services/history/history-service.js +0 -242
  400. package/lib/storage/acp-history.d.ts +0 -10
  401. package/lib/storage/acp-history.js +0 -57
  402. package/lib/ui/presentation.d.ts +0 -3
  403. package/lib/ui/presentation.js +0 -12
  404. package/src/extension/dsh/history.ts +0 -74
  405. package/src/extension/history.ts +0 -26
  406. package/src/extension/plugin-runtime.ts +0 -63
  407. package/src/integrations/dsh/history-summary.ts +0 -39
  408. package/src/integrations/dsh/history.ts +0 -84
  409. package/src/integrations/history-summary.ts +0 -30
  410. package/src/integrations/hosts/antigravity.ts +0 -83
  411. package/src/integrations/hosts/claude.ts +0 -62
  412. package/src/integrations/pi/history.ts +0 -99
  413. package/src/services/history/history-service.ts +0 -195
  414. package/src/storage/acp-history.ts +0 -49
  415. package/src/tools/access.ts +0 -7
  416. package/src/tools/history/tool.ts +0 -19
  417. package/src/tools/register.ts +0 -22
  418. package/src/ui/presentation.ts +0 -12
  419. /package/lib/{extension → antigravity-plugin/lib/extension/hosts}/dsh/acp-member.d.ts +0 -0
  420. /package/lib/{extension → antigravity-plugin/lib/extension/hosts}/dsh/files.d.ts +0 -0
  421. /package/lib/{integrations → antigravity-plugin/lib/integrations/hosts}/dsh/mcp.js +0 -0
  422. /package/lib/{integrations → antigravity-plugin/lib/integrations/hosts}/dsh/messages.d.ts +0 -0
  423. /package/lib/{integrations → antigravity-plugin/lib/integrations/hosts}/dsh/messages.js +0 -0
  424. /package/lib/{integrations → antigravity-plugin/lib/integrations/hosts}/dsh/root-agents.d.ts +0 -0
  425. /package/lib/{integrations → antigravity-plugin/lib/integrations/hosts}/dsh/root-agents.js +0 -0
  426. /package/lib/{integrations → antigravity-plugin/lib/integrations/hosts}/dsh/skills.d.ts +0 -0
  427. /package/lib/extension/{acp-worker.d.ts → acp/worker.d.ts} +0 -0
  428. /package/lib/extension/{setup-guard.js → setup/guard.js} +0 -0
  429. /package/lib/integrations/acp/{claude.d.ts → claude-settings.d.ts} +0 -0
  430. /package/lib/integrations/acp/{claude.js → claude-settings.js} +0 -0
  431. /package/lib/integrations/{dsh → hosts/dsh}/schema.d.ts +0 -0
  432. /package/src/extension/{setup-guard.ts → setup/guard.ts} +0 -0
  433. /package/src/integrations/acp/{claude.ts → claude-settings.ts} +0 -0
  434. /package/src/integrations/{dsh → hosts/dsh}/messages.ts +0 -0
  435. /package/src/integrations/{dsh → hosts/dsh}/root-agents.ts +0 -0
  436. /package/src/integrations/{pi → hosts/pi}/agent-tools.ts +0 -0
@@ -1,397 +1,54 @@
1
1
  import { randomUUID } from "node:crypto";
2
+ import { existsSync } from "node:fs";
2
3
  import { realpath, stat } from "node:fs/promises";
3
4
  import { homedir } from "node:os";
4
5
  import { isAbsolute, join } from "node:path";
5
6
  import { setTimeout as delay } from "node:timers/promises";
6
- import { object } from "../common/json.js";
7
- import { isAcpBackend, requireThat } from "../common/validation.js";
8
- import { packageVersion } from "../common/version.js";
9
- import { AcpWorkerHost } from "../integrations/acp/agents.js";
10
- import { canonicalAcpBackend, inspectAcpBackends, knownAcpBackends } from "../integrations/acp/launch.js";
7
+ import { object } from "../../common/json.js";
8
+ import { isAcpBackend, isHistoryIdentifier, isOneOf, requireThat } from "../../common/validation.js";
9
+ import { resourceRoot } from "../../common/paths.js";
10
+ import { packageVersion } from "../../common/version.js";
11
+ import { AcpWorkerHost } from "../../integrations/acp/agents.js";
12
+ import { canonicalAcpBackend, inspectAcpBackends, knownAcpBackends } from "../../integrations/acp/launch.js";
13
+ import { pluginMcpWorkspaceRoot } from "../../integrations/hosts/plugin-registry.js";
11
14
  import {
12
15
  mcpWorkerToolNames,
13
16
  type AcpCommands,
14
- type AcpElicitationAction,
17
+ acpElicitationActions, isAcpElicitationValue,
15
18
  type AcpElicitationContent,
16
19
  type AcpModelSelection,
17
20
  type McpWorkerToolName,
18
- } from "../model/acp.js";
19
- import { workspaceMcpToolNames, type WorkspaceMcpToolName } from "../model/workspace-mcp.js";
20
- import type { AgentCycle, AgentOwner, AgentView } from "../model/agent.js";
21
- import { AgentService } from "../services/agents/agent-service.js";
22
- import { readWorkspaceConfig, workspaceDisabledMessage, workspaceFeatures } from "../services/workspace/workspace-config.js";
23
- import { WorkspaceMcpBridge } from "./mcp-bridge.js";
21
+ } from "../../model/acp.js";
22
+ import {
23
+ buildHistoryMcpTools, buildPbotWorkerTools, buildWorkspaceMcpTools, defaultWaitMs, discoverTargets,
24
+ maxWaitMs, parseMcpToolCall,
25
+ } from "./tool-contract.js";
26
+
27
+ import { historyPageLimits } from "../../model/history.js";
28
+ import type { AgentCycle, AgentOwner, AgentView } from "../../model/agent.js";
29
+ import { AgentService } from "../../services/agents/agent-service.js";
30
+ import { readWorkspaceHistory, searchWorkspaceHistory } from "../../services/history/history-query.js";
31
+ import { readWorkspaceConfig, workspaceDisabledMessage, workspaceFeatures } from "../../services/workspace/workspace-config.js";
32
+ import { WorkspaceMcpBridge } from "./bridge.js";
33
+
34
+ export { buildHistoryMcpTools, buildPbotWorkerTools, buildWorkspaceMcpTools, pbotWorkerTools } from "./tool-contract.js";
24
35
 
25
36
  const protocolVersion = "2025-03-26";
26
37
  const readyTimeoutMs = 45_000;
27
- const defaultWaitMs = 50_000;
28
- const maxWaitMs = 600_000;
29
38
  const reportPageSize = 16_000;
30
39
  const progressIntervalMs = 5_000;
31
40
 
32
- const responseActions = ["accept", "decline", "cancel"] as const;
33
- const discoverTargets = ["overview", "workers", "backends", "models"] as const;
34
- type DiscoverTarget = typeof discoverTargets[number];
35
-
36
- type AllMcpToolName = McpWorkerToolName | WorkspaceMcpToolName;
37
- const allMcpToolNames: readonly AllMcpToolName[] = [...mcpWorkerToolNames, ...workspaceMcpToolNames];
38
-
39
- const toolParams: Record<AllMcpToolName, ReadonlySet<string>> = {
40
- worker_create: new Set(["backend", "model", "thinking", "cwd", "workspace"]),
41
- worker_close: new Set(["workerId", "workspace"]),
42
- worker_request: new Set(["workerId", "message", "waitMs", "workspace"]),
43
- worker_response: new Set(["workerId", "action", "requestId", "optionId", "content", "waitMs", "workspace"]),
44
- worker_output: new Set(["workerId", "offset", "waitMs", "workspace"]),
45
- worker_discover: new Set(["target", "workerId", "backend", "model", "workspace"]),
46
- workspace_mcp_discover: new Set(["server", "workspace"]),
47
- workspace_mcp_call: new Set(["server", "tool", "arguments", "workspace"]),
48
- };
49
-
50
- const shortToolMap: Record<string, McpWorkerToolName> = {
51
- create: "worker_create",
52
- close: "worker_close",
53
- request: "worker_request",
54
- response: "worker_response",
55
- output: "worker_output",
56
- discover: "worker_discover",
57
- };
58
-
59
41
  export type ProgressReporter = (message: string) => void;
60
42
 
61
- export const mcpInstructions =
62
- "用于跨代理程序委派任务(worker_*)与调用工作区统一注册的外部 MCP 服务(workspace_mcp_*);未指定其他程序时,优先由当前程序或其原生子代理直接完成。\n" +
63
- "跨程序委派:worker_create 创建 worker(或用 worker_discover 复用已有 worker)→ worker_request 发送任务或后续消息 → 用完可用 worker_close 关闭;后台等待、超时续等(timedOut)或长报告翻页(nextOffset)用 worker_output;返回 needsResponse 时向用户确认后用 worker_response 回复。\n" +
64
- "工作区统一 MCP(.pbot/mcp.json):先用 workspace_mcp_discover 查看已注册服务或指定服务的工具清单,再用 workspace_mcp_call 调用目标工具;可与宿主原生 MCP 同时使用。";
65
-
66
- function formatBackendItem(entry: ReturnType<typeof inspectAcpBackends>[number], defaultBackend?: string): string {
67
- const tags: string[] = [];
68
- if (entry.label) tags.push(entry.label);
69
- if (entry.backend === defaultBackend) tags.push("当前");
70
- return tags.length ? `${entry.backend}(${tags.join(",")})` : entry.backend;
71
- }
72
-
73
- function summarizeBackends(commands: AcpCommands = {}, defaultBackend?: string) {
74
- const entries = inspectAcpBackends(commands);
75
- const available = entries.filter(item => item.available);
76
- const unavailable = entries.filter(item => !item.available);
77
- const availableText = available.map(item => formatBackendItem(item, defaultBackend)).join("、");
78
- const unavailableText = unavailable.map(item => formatBackendItem(item, defaultBackend)).join("、");
79
- const overview = available.length
80
- ? unavailable.length
81
- ? `可用 backend:${availableText};不可用:${unavailableText}。`
82
- : `可用 backend:${availableText}。`
83
- : `当前无可用 backend(不可用:${unavailableText})。`;
84
- const availableIds = available.map(item => item.backend).join("、");
85
- return { overview, availableIds };
86
- }
87
-
88
- function workspaceProperty(workspaceBound: boolean) {
89
- return {
90
- type: "string",
91
- description: workspaceBound
92
- ? "工作区根目录绝对路径;已默认绑定当前工作区,通常省略。"
93
- : "工作区根目录绝对路径(上下文提供 workspaceRoot 时传该路径);当前未默认绑定,请显式传入。",
94
- };
95
- }
43
+ export const mcpWorkerOnlyInstructions =
44
+ "提供跨助手协作能力(worker_*):可启动并调度其他外部 AI 助手在当前工作区中独立执行任务,适用于用户指定其他助手、需要特定模型或思考深度、获取独立审查/第二意见,或并行处理子任务。不需要借助其他助手时,优先自行完成或使用当前内置子代理。\n" +
45
+ "使用流程:用 worker_create 启动目标助手(或用 worker_discover 复用已有会话)→ 用 worker_request 派发任务或继续追问 → 任务完成后可用 worker_close 结束会话。后台等待、超时续等(timedOut)或长结果翻页(nextOffset)用 worker_output;助手请求授权或提问(needsResponse)时,先向用户确认,再用 worker_response 回复。";
96
46
 
97
- export function buildPbotWorkerTools(commands: AcpCommands = {}, defaultBackend?: string, workspaceBound = false) {
98
- const { overview, availableIds } = summarizeBackends(commands, defaultBackend);
99
- const modelsBackendHint = defaultBackend
100
- ? `省略时默认查 ${defaultBackend}`
101
- : "必填";
102
- const workspace = workspaceProperty(workspaceBound);
103
-
104
- return [
105
- {
106
- name: "worker_create",
107
- description:
108
- "创建一个新的 worker 并返回其 workerId(仅创建,不发送任务;随后用 worker_request 派发任务)。" +
109
- "未指定其他程序时优先由当前程序或其原生子代理完成。\n" +
110
- overview,
111
- annotations: {
112
- title: "Create Worker",
113
- readOnlyHint: false,
114
- destructiveHint: false,
115
- idempotentHint: false,
116
- openWorldHint: true,
117
- },
118
- inputSchema: {
119
- type: "object",
120
- additionalProperties: false,
121
- required: ["backend"],
122
- properties: {
123
- backend: {
124
- type: "string",
125
- description: "目标代理程序名称,不区分大小写,支持常见别名(如 claude-code、agy)。",
126
- },
127
- model: {
128
- type: "string",
129
- description: "仅用户明确指定模型时传入(支持模型 ID、显示名或 provider/model,不区分大小写);不确定合法值可用 worker_discover(target=\"models\") 查询;省略则使用目标默认。",
130
- },
131
- thinking: {
132
- type: "string",
133
- description: "仅用户明确指定思考力度时传入(如 low / medium / high / xhigh / max,不区分大小写);省略则使用目标默认。",
134
- },
135
- cwd: {
136
- type: "string",
137
- description: "worker 工作目录(相对工作区根目录或绝对路径),默认为工作区根目录。",
138
- },
139
- workspace,
140
- },
141
- },
142
- },
143
- {
144
- name: "worker_close",
145
- description:
146
- "关闭指定 worker。若该 worker 支持恢复(capabilities.resume 为 true),后续仍可直接用 worker_request 继续会话。",
147
- annotations: {
148
- title: "Close Worker",
149
- readOnlyHint: false,
150
- destructiveHint: true,
151
- idempotentHint: true,
152
- openWorldHint: false,
153
- },
154
- inputSchema: {
155
- type: "object",
156
- additionalProperties: false,
157
- required: ["workerId"],
158
- properties: {
159
- workerId: {
160
- type: "string",
161
- description: "要关闭的 worker ID(来自 worker_create 或 worker_discover)。",
162
- },
163
- workspace,
164
- },
165
- },
166
- },
167
- {
168
- name: "worker_request",
169
- description:
170
- "向指定 worker 发送任务或后续消息(若已关闭且支持恢复,会自动续接会话)。" +
171
- `默认最多等待 ${defaultWaitMs / 1000} 秒返回报告(waitMs 设为 0 立即返回并在后台执行);` +
172
- "若返回 timedOut 或报告含 nextOffset 用 worker_output 继续,返回 needsResponse 时向用户确认后用 worker_response 回复。",
173
- annotations: {
174
- title: "Send Request to Worker",
175
- readOnlyHint: false,
176
- destructiveHint: false,
177
- idempotentHint: false,
178
- openWorldHint: true,
179
- },
180
- inputSchema: {
181
- type: "object",
182
- additionalProperties: false,
183
- required: ["workerId", "message"],
184
- properties: {
185
- workerId: {
186
- type: "string",
187
- description: "目标 worker ID(来自 worker_create 或 worker_discover)。",
188
- },
189
- message: {
190
- type: "string",
191
- description: "发给 worker 的任务说明或后续消息。worker 看不到当前对话历史,首次派发时请写清目标、相关文件路径、约束和交付要求。",
192
- },
193
- waitMs: {
194
- type: "integer",
195
- minimum: 0,
196
- maximum: maxWaitMs,
197
- description: `最多等待的毫秒数(默认 ${defaultWaitMs});传 0 立即返回并在后台执行。`,
198
- },
199
- workspace,
200
- },
201
- },
202
- },
203
- {
204
- name: "worker_response",
205
- description:
206
- "回复 worker 返回 needsResponse: true 时的待处理请求(pendingRequests),用于权限审批(kind=\"permission\")、表单提问(kind=\"form\")和 URL 确认(kind=\"url\")。" +
207
- `回复前先向用户确认;回复后默认最多等待 ${defaultWaitMs / 1000} 秒返回后续结果(waitMs 设为 0 立即返回)。`,
208
- annotations: {
209
- title: "Respond to Worker Request",
210
- readOnlyHint: false,
211
- destructiveHint: false,
212
- idempotentHint: false,
213
- openWorldHint: true,
214
- },
215
- inputSchema: {
216
- type: "object",
217
- additionalProperties: false,
218
- required: ["workerId", "action"],
219
- properties: {
220
- workerId: {
221
- type: "string",
222
- description: "存在待处理请求的 worker ID。",
223
- },
224
- action: {
225
- type: "string",
226
- enum: [...responseActions],
227
- description: "accept:同意权限、提交表单或确认 URL;decline:拒绝;cancel:取消。",
228
- },
229
- requestId: {
230
- type: "string",
231
- description: "待回复的 pendingRequests[].requestId;仅一条请求时可省略,多条时必填。",
232
- },
233
- optionId: {
234
- type: "string",
235
- description: "仅 kind=\"permission\" 且 action 不为 cancel 时可用:指定 pendingRequests[].options[].optionId(省略时默认单次允许或拒绝)。",
236
- },
237
- content: {
238
- type: "object",
239
- additionalProperties: true,
240
- description: "仅 kind=\"form\" 且 action=\"accept\" 时可用:按 pendingRequests[].schema.properties 填写的答案对象(字段值支持字符串、数字、布尔或字符串数组)。",
241
- },
242
- waitMs: {
243
- type: "integer",
244
- minimum: 0,
245
- maximum: maxWaitMs,
246
- description: `回复后最多等待的毫秒数(默认 ${defaultWaitMs});传 0 立即返回。`,
247
- },
248
- workspace,
249
- },
250
- },
251
- },
252
- {
253
- name: "worker_output",
254
- description:
255
- "获取指定 worker 最新一轮的执行报告:仍在运行时等待其完成(也可能返回 timedOut 或 needsResponse),已结束则立即返回;报告含 nextOffset 时传入 offset 翻页续读。",
256
- annotations: {
257
- title: "Get Worker Output",
258
- readOnlyHint: true,
259
- destructiveHint: false,
260
- idempotentHint: true,
261
- openWorldHint: false,
262
- },
263
- inputSchema: {
264
- type: "object",
265
- additionalProperties: false,
266
- required: ["workerId"],
267
- properties: {
268
- workerId: {
269
- type: "string",
270
- description: "要等待或读取报告的 worker ID。",
271
- },
272
- offset: {
273
- type: "integer",
274
- minimum: 0,
275
- description: "报告字符偏移量(默认 0);翻页续读时传上次返回的 nextOffset。",
276
- },
277
- waitMs: {
278
- type: "integer",
279
- minimum: 0,
280
- maximum: maxWaitMs,
281
- description: `任务仍在运行时最多等待的毫秒数(默认 ${defaultWaitMs});已结束或翻页时立即返回。`,
282
- },
283
- workspace,
284
- },
285
- },
286
- },
287
- {
288
- name: "worker_discover",
289
- description:
290
- "查询可用 backend、当前会话已有 worker 的状态,或指定 backend 可选的模型与思考力度。" +
291
- "默认(target=\"overview\")返回可用 backend 与已有 worker;仅需确认模型或思考力度可选值时再查 target=\"models\"(耗时较长)。",
292
- annotations: {
293
- title: "Discover Workers, Backends & Models",
294
- readOnlyHint: true,
295
- destructiveHint: false,
296
- idempotentHint: true,
297
- openWorldHint: false,
298
- },
299
- inputSchema: {
300
- type: "object",
301
- additionalProperties: false,
302
- required: [],
303
- properties: {
304
- target: {
305
- type: "string",
306
- enum: [...discoverTargets],
307
- description: "查询范围,默认 \"overview\"(同时返回 backends 与 workers);\"workers\" 查全部或单个 worker 状态;\"backends\" 查可用 backend 列表;\"models\" 查指定 backend 的可选模型与思考力度。",
308
- },
309
- workerId: {
310
- type: "string",
311
- description: "仅 target=\"workers\" 可用:指定单个 worker ID;省略时列出全部。",
312
- },
313
- backend: {
314
- type: "string",
315
- description: availableIds
316
- ? `仅 target="models" 可用(${modelsBackendHint}):目标代理程序名称,支持常见别名;可用:${availableIds}。`
317
- : `仅 target="models" 可用(${modelsBackendHint}):目标代理程序名称,支持常见别名。`,
318
- },
319
- model: {
320
- type: "string",
321
- description: "仅 target=\"models\" 可用:指定模型以查询该模型支持的思考力度选项。",
322
- },
323
- workspace,
324
- },
325
- },
326
- },
327
- ];
328
- }
329
-
330
- export function buildWorkspaceMcpTools(workspaceBound = false) {
331
- const workspace = workspaceProperty(workspaceBound);
332
- return [
333
- {
334
- name: "workspace_mcp_discover",
335
- description:
336
- "查看工作区 .pbot/mcp.json 中统一注册的 MCP 服务列表;传入 server 时按需连接该服务并返回其全部工具及参数 schema。",
337
- annotations: {
338
- title: "Discover Workspace MCP Servers & Tools",
339
- readOnlyHint: true,
340
- destructiveHint: false,
341
- idempotentHint: true,
342
- openWorldHint: true,
343
- },
344
- inputSchema: {
345
- type: "object",
346
- additionalProperties: false,
347
- required: [],
348
- properties: {
349
- server: {
350
- type: "string",
351
- description: "目标 MCP 服务名(来自 .pbot/mcp.json 的键名);省略时仅列出已注册服务摘要。",
352
- },
353
- workspace,
354
- },
355
- },
356
- },
357
- {
358
- name: "workspace_mcp_call",
359
- description:
360
- "调用工作区 .pbot/mcp.json 中指定 MCP 服务的工具(首次调用按需连接并复用连接,配置变更自动热更新)。" +
361
- "不确定工具名或参数 schema 时,先用 workspace_mcp_discover(server) 查询。",
362
- annotations: {
363
- title: "Call Workspace MCP Tool",
364
- readOnlyHint: false,
365
- destructiveHint: false,
366
- idempotentHint: false,
367
- openWorldHint: true,
368
- },
369
- inputSchema: {
370
- type: "object",
371
- additionalProperties: false,
372
- required: ["server", "tool"],
373
- properties: {
374
- server: {
375
- type: "string",
376
- description: "目标 MCP 服务名(来自 .pbot/mcp.json)。",
377
- },
378
- tool: {
379
- type: "string",
380
- description: "要调用的下游 MCP 工具名称。",
381
- },
382
- arguments: {
383
- type: "object",
384
- additionalProperties: true,
385
- description: "传递给下游 MCP 工具的参数对象,省略时为空对象。",
386
- },
387
- workspace,
388
- },
389
- },
390
- },
391
- ];
392
- }
393
-
394
- export const pbotWorkerTools = buildPbotWorkerTools();
47
+ export const mcpInstructions =
48
+ "提供三类能力:\n" +
49
+ "1. 跨助手协作(worker_*):启动并调度其他外部 AI 助手在当前工作区中独立执行任务,适用于用户指定其他助手、需要特定模型或思考深度、获取独立审查/第二意见,或并行处理子任务。不需要借助其他助手时,优先自行完成或使用当前内置子代理。使用流程:worker_create 启动助手(或 worker_discover 复用已有会话)→ worker_request 派发任务或追问 → 完成后 worker_close 结束;后台等待、超时续等(timedOut)或长结果翻页(nextOffset)用 worker_output;返回 needsResponse 时先向用户确认,再用 worker_response 回复。\n" +
50
+ "2. 工作区共享外部工具(workspace_mcp_*):发现并调用当前工作区接入的外部工具服务与数据源(可与当前环境原生工具同时使用)。先用 workspace_mcp_discover 查看可用服务与工具说明,再用 workspace_mcp_call 调用。\n" +
51
+ "3. 跨宿主历史查询(history_search / history_read):只读检索当前工作区在 Pi、dsh、Claude Code、Antigravity 等宿主中记录的历史问答与摘要归档。";
395
52
 
396
53
  export function defaultWorkerDirectory(): string {
397
54
  if (process.env.PBOT_MCP_AGENT_DIR) return process.env.PBOT_MCP_AGENT_DIR;
@@ -399,12 +56,9 @@ export function defaultWorkerDirectory(): string {
399
56
  return join(homedir(), ".pbot/subagents");
400
57
  }
401
58
 
402
- function isKnownWorkerTool(name: string): name is McpWorkerToolName {
403
- return (mcpWorkerToolNames as readonly string[]).includes(name);
404
- }
405
-
406
- function isKnownTool(name: string): name is AllMcpToolName {
407
- return (allMcpToolNames as readonly string[]).includes(name);
59
+ function workerCommandTool(name: string): McpWorkerToolName | undefined {
60
+ const full = name.startsWith("worker_") ? name : `worker_${name}`;
61
+ return isOneOf(full, mcpWorkerToolNames) ? full : undefined;
408
62
  }
409
63
 
410
64
  /** Parse Pi/dsh `/pbot worker ...` CLI arguments into a canonical MCP tool call. */
@@ -436,8 +90,7 @@ export function parseWorkerCommand(raw: string): { tool: McpWorkerToolName; args
436
90
  if (trimmed.startsWith("{")) {
437
91
  const parsed: unknown = JSON.parse(trimmed);
438
92
  requireThat(object(parsed), 'worker 参数必须是 JSON 对象,例如:/pbot worker create {"backend":"codex"}');
439
- const rawTool = typeof parsed.tool === "string" ? parsed.tool : undefined;
440
- const resolved = rawTool ? (isKnownWorkerTool(rawTool) ? rawTool : shortToolMap[rawTool]) : undefined;
93
+ const resolved = typeof parsed.tool === "string" ? workerCommandTool(parsed.tool) : undefined;
441
94
  requireThat(resolved, `JSON 形式需包含有效 tool 字段(${mcpWorkerToolNames.join(", ")}),或使用 /pbot worker <工具名> <JSON>。`);
442
95
  const rest = Object.fromEntries(Object.entries(parsed).filter(([key]) => key !== "tool"));
443
96
  return { tool: resolved, args: rest };
@@ -445,22 +98,14 @@ export function parseWorkerCommand(raw: string): { tool: McpWorkerToolName; args
445
98
  const match = trimmed.match(/^(\S+)(?:\s+([\s\S]*))?$/);
446
99
  const verb = match?.[1] ?? "";
447
100
  const rest = (match?.[2] ?? "").trim();
448
- const tool = isKnownWorkerTool(verb) ? verb : shortToolMap[verb];
449
- requireThat(tool, `未知 worker 命令:${verb}(支持:overview | status | backends | models | create | request | response | output | close | discover)。`);
101
+ const tool = workerCommandTool(verb);
102
+ requireThat(tool, `未知 worker 命令:${verb}(支持:overview | status | backends | models | ${mcpWorkerToolNames.map(name => name.slice("worker_".length)).join(" | ")})。`);
450
103
  if (!rest) return { tool, args: {} };
451
104
  const parsed: unknown = JSON.parse(rest);
452
105
  requireThat(object(parsed), `${tool} 的参数必须是 JSON 对象。`);
453
106
  return { tool, args: parsed };
454
107
  }
455
108
 
456
- function rejectUnknownParams(tool: AllMcpToolName, rawArgs: Record<string, unknown>) {
457
- const allowed = toolParams[tool];
458
- const unknown = Object.entries(rawArgs)
459
- .filter(([key, value]) => value !== undefined && !allowed.has(key))
460
- .map(([key]) => key);
461
- requireThat(unknown.length === 0, `未知参数:${unknown.join(", ")}(${tool} 可用参数:${[...allowed].join(", ")})。`);
462
- }
463
-
464
109
  function asString(args: Record<string, unknown>, key: string, required = false): string | undefined {
465
110
  const value = args[key];
466
111
  if (value === undefined || value === null) {
@@ -484,11 +129,7 @@ function asContent(args: Record<string, unknown>, key: string): AcpElicitationCo
484
129
  if (value === undefined || value === null) return undefined;
485
130
  requireThat(object(value), `参数 ${key} 必须是 JSON 对象。`);
486
131
  for (const [field, entry] of Object.entries(value)) {
487
- const valid = typeof entry === "string"
488
- || (typeof entry === "number" && Number.isFinite(entry))
489
- || typeof entry === "boolean"
490
- || (Array.isArray(entry) && entry.every(item => typeof item === "string"));
491
- requireThat(valid, `参数 ${key}.${field} 必须是字符串、数字、布尔值或字符串数组。`);
132
+ requireThat(isAcpElicitationValue(entry), `参数 ${key}.${field} 必须是字符串、数字、布尔值或字符串数组。`);
492
133
  }
493
134
  return value as AcpElicitationContent;
494
135
  }
@@ -534,16 +175,49 @@ export class McpWorkerRuntime {
534
175
  readonly #sessionId: string;
535
176
  readonly #directory: string;
536
177
  readonly #defaultBackend: string | undefined;
537
- #closed = false;
178
+ readonly #nativeWorkspaceMcp: boolean;
179
+ readonly #nativeHistory: boolean;
180
+ #closing: Promise<void> | undefined;
538
181
 
539
182
  constructor(
540
183
  directory = defaultWorkerDirectory(),
541
184
  sessionId = process.env.PBOT_MCP_SESSION_ID || ("mcp-" + randomUUID()),
542
185
  defaultBackend = process.env.PBOT_HOST || undefined,
186
+ nativeWorkspaceMcp = /^(1|true)$/i.test(process.env.PBOT_NATIVE_WORKSPACE_MCP ?? ""),
187
+ nativeHistory = /^(1|true)$/i.test(process.env.PBOT_NATIVE_HISTORY ?? ""),
543
188
  ) {
544
189
  this.#directory = directory;
545
190
  this.#sessionId = sessionId;
546
191
  this.#defaultBackend = defaultBackend?.trim() || undefined;
192
+ this.#nativeWorkspaceMcp = nativeWorkspaceMcp;
193
+ this.#nativeHistory = nativeHistory;
194
+ }
195
+
196
+ /** Mount the stdio sibling with the same worker ownership as the native host command. */
197
+ nativeServer(root: string) {
198
+ const entry = join(resourceRoot, "../lib/extension/mcp.js");
199
+ if (!existsSync(entry)) return undefined;
200
+ requireThat(this.#defaultBackend, "原生 MCP 挂载需要宿主名称。");
201
+ return {
202
+ command: process.execPath,
203
+ args: [entry],
204
+ env: {
205
+ PBOT_HOST: this.#defaultBackend,
206
+ PBOT_WORKSPACE_ROOT: root,
207
+ PBOT_MCP_AGENT_DIR: this.#directory,
208
+ PBOT_MCP_SESSION_ID: this.#sessionId,
209
+ PBOT_NATIVE_WORKSPACE_MCP: "1",
210
+ PBOT_NATIVE_HISTORY: "1",
211
+ },
212
+ };
213
+ }
214
+
215
+ get nativeWorkspaceMcp(): boolean {
216
+ return this.#nativeWorkspaceMcp;
217
+ }
218
+
219
+ get nativeHistory(): boolean {
220
+ return this.#nativeHistory;
547
221
  }
548
222
 
549
223
  private resolveBackend(rawArgs: Record<string, unknown>, commands: AcpCommands | undefined, allowDefault: boolean): string {
@@ -555,21 +229,17 @@ export class McpWorkerRuntime {
555
229
  }
556
230
 
557
231
  private async resolveWorkspace(supplied?: string): Promise<string> {
558
- const target = supplied || process.env.CLAUDE_PROJECT_DIR || process.env.PBOT_WORKSPACE_ROOT || process.cwd();
232
+ const target = supplied || pluginMcpWorkspaceRoot() || process.cwd();
559
233
  requireThat(isAbsolute(target), "工作区需要绝对路径。");
560
234
  const root = await realpath(target);
561
235
  requireThat((await stat(root)).isDirectory(), "工作区路径不是目录。");
562
236
  return root;
563
237
  }
564
238
 
565
- private async workspace(supplied?: string) {
566
- requireThat(!this.#closed, "Personal Bot MCP 服务已关闭。");
567
- const root = await this.resolveWorkspace(supplied);
568
- const configuration = await readWorkspaceConfig(root);
569
- requireThat(configuration.enabled, workspaceDisabledMessage(configuration));
239
+ private workerService(root: string, commands: AcpCommands = {}) {
570
240
  let entry = this.#services.get(root);
571
241
  if (!entry) {
572
- const host = new AcpWorkerHost(this.#directory, configuration.acp);
242
+ const host = new AcpWorkerHost(this.#directory, commands);
573
243
  entry = {
574
244
  host,
575
245
  service: new AgentService(root, this.#directory, host),
@@ -577,27 +247,31 @@ export class McpWorkerRuntime {
577
247
  };
578
248
  this.#services.set(root, entry);
579
249
  } else {
580
- Object.assign(entry.host, { commands: configuration.acp ?? {} });
250
+ entry.host.commands = commands;
581
251
  }
582
- return { root, configuration, ...entry };
252
+ return entry;
583
253
  }
584
254
 
585
255
  async toolDefinitions() {
586
256
  let commands: AcpCommands | undefined;
587
- let includeWorkspaceMcp = true;
257
+ let includeWorkspaceMcp = !this.#nativeWorkspaceMcp;
258
+ let includeHistory = !this.#nativeHistory;
588
259
  try {
589
260
  const root = await this.resolveWorkspace();
590
261
  const configuration = await readWorkspaceConfig(root);
591
262
  if (configuration.enabled) {
592
263
  commands = configuration.acp;
593
- includeWorkspaceMcp = workspaceFeatures(configuration).mcp;
264
+ const features = workspaceFeatures(configuration);
265
+ includeWorkspaceMcp = !this.#nativeWorkspaceMcp && features.mcp;
266
+ includeHistory = !this.#nativeHistory && features.history;
594
267
  }
595
268
  } catch { /* Fall back to registered built-in harnesses when cwd is outside an enabled workspace. */ }
596
269
  const defaultBackend = this.#defaultBackend ? canonicalAcpBackend(this.#defaultBackend, commands) : undefined;
597
- const workspaceBound = Boolean(process.env.CLAUDE_PROJECT_DIR || process.env.PBOT_WORKSPACE_ROOT);
270
+ const workspaceBound = Boolean(pluginMcpWorkspaceRoot());
598
271
  return [
599
272
  ...buildPbotWorkerTools(commands, defaultBackend, workspaceBound),
600
273
  ...(includeWorkspaceMcp ? buildWorkspaceMcpTools(workspaceBound) : []),
274
+ ...(includeHistory ? buildHistoryMcpTools(workspaceBound) : []),
601
275
  ];
602
276
  }
603
277
 
@@ -613,7 +287,7 @@ export class McpWorkerRuntime {
613
287
  let lastProgressAt = 0;
614
288
  let lastMarker = "";
615
289
  for (;;) {
616
- requireThat(!this.#closed, "Personal Bot MCP 服务已关闭。");
290
+ requireThat(!this.#closing, "Personal Bot MCP 服务已关闭。");
617
291
  const current = service.status(workerId, owner);
618
292
  if (current.state === "error" || current.state === "stopped") {
619
293
  throw new Error(current.error || "worker 启动失败。");
@@ -646,23 +320,13 @@ export class McpWorkerRuntime {
646
320
  let lastProgressAt = 0;
647
321
  let lastMarker = "";
648
322
  for (;;) {
649
- requireThat(!this.#closed, "Personal Bot MCP 服务已关闭。");
650
- const current = service.status(workerId, owner);
651
- const cycles = service.cycles(workerId, owner);
652
- const latestRequest = requestId ?? service.files.messages(workerId)
653
- .filter(item => item.generation === current.generation)
654
- .at(-1)?.requestId;
655
- const targetCycle = latestRequest
656
- ? cycles.find(item => item.generation === current.generation && item.requestIds.includes(latestRequest))
657
- : current.cycle ?? cycles.at(-1);
658
- const settled = targetCycle && targetCycle.state !== "running";
659
- const terminalWithoutCycle = !latestRequest && (current.state === "stopped" || current.state === "error" || (current.state === "idle" && !targetCycle));
660
- const failedBeforeCycle = Boolean(latestRequest && !targetCycle && (current.state === "stopped" || current.state === "error"));
661
- if (settled) {
662
- const page = await service.read(workerId, owner, targetCycle.cycleId, offset, reportPageSize);
323
+ requireThat(!this.#closing, "Personal Bot MCP 服务已关闭。");
324
+ const { current, cycle, terminal } = service.outputStatus(workerId, owner, requestId);
325
+ if (cycle && cycle.state !== "running") {
326
+ const page = await service.read(workerId, owner, cycle.cycleId, offset, reportPageSize);
663
327
  return { settled: true, ...presentWorker(page) };
664
328
  }
665
- if (terminalWithoutCycle || failedBeforeCycle) {
329
+ if (terminal) {
666
330
  if (offset > 0) await service.read(workerId, owner, undefined, offset, reportPageSize);
667
331
  return { settled: true, ...presentWorker(current) };
668
332
  }
@@ -689,26 +353,65 @@ export class McpWorkerRuntime {
689
353
  }
690
354
  }
691
355
 
692
- async callTool(name: string, rawArgs: unknown, progress?: ProgressReporter): Promise<unknown> {
693
- requireThat(isKnownTool(name), `未知工具:${name}(可用:${allMcpToolNames.join(", ")})。`);
694
- requireThat(object(rawArgs), "工具参数必须是对象。");
695
- rejectUnknownParams(name, rawArgs);
696
- const { root, configuration, host, service, owner } = await this.workspace(asString(rawArgs, "workspace"));
356
+ async callTool(toolName: string, input: unknown, progress?: ProgressReporter): Promise<unknown> {
357
+ const { name, args: rawArgs } = parseMcpToolCall(toolName, input);
358
+ requireThat(!this.#closing, "Personal Bot MCP 服务已关闭。");
359
+ const root = await this.resolveWorkspace(asString(rawArgs, "workspace"));
360
+ const configuration = await readWorkspaceConfig(root);
361
+ requireThat(!this.#closing, "Personal Bot MCP 服务已关闭。");
362
+ requireThat(configuration.enabled, workspaceDisabledMessage(configuration));
697
363
 
698
364
  switch (name) {
699
- case "workspace_mcp_discover": {
700
- requireThat(workspaceFeatures(configuration).mcp, `工作区统一 MCP 功能已在 ${configuration.path} 中停用(features.mcp: false)。`);
701
- const server = asString(rawArgs, "server");
702
- return this.#bridge.discover(root, server);
703
- }
365
+ case "workspace_mcp_discover":
704
366
  case "workspace_mcp_call": {
367
+ requireThat(!this.#nativeWorkspaceMcp, "当前宿主已原生挂载工作区 .pbot/mcp.json 服务,请直接调用对应原生 MCP 工具,勿重复经由 workspace_mcp_* 桥接。");
705
368
  requireThat(workspaceFeatures(configuration).mcp, `工作区统一 MCP 功能已在 ${configuration.path} 中停用(features.mcp: false)。`);
369
+ if (name === "workspace_mcp_discover") return this.#bridge.discover(root, asString(rawArgs, "server"));
706
370
  const server = asString(rawArgs, "server", true)!;
707
371
  const tool = asString(rawArgs, "tool", true)!;
708
372
  const toolArgs = rawArgs.arguments === undefined ? {} : rawArgs.arguments;
709
373
  requireThat(object(toolArgs), "参数 arguments 必须是 JSON 对象。");
710
374
  return this.#bridge.call(root, server, tool, toolArgs);
711
375
  }
376
+ case "history_search": {
377
+ requireThat(!this.#nativeHistory, "当前宿主已提供原生 pbot_history 工具,请直接调用 pbot_history。");
378
+ requireThat(workspaceFeatures(configuration).history, `工作区历史功能已在 ${configuration.path} 中停用(features.history: false)。`);
379
+ const hostFilter = asString(rawArgs, "host");
380
+ if (hostFilter !== undefined) requireThat(isHistoryIdentifier(hostFilter), "无效的 host 来源:" + hostFilter);
381
+ const dimension = asString(rawArgs, "dimension");
382
+ if (dimension !== undefined) requireThat(isHistoryIdentifier(dimension), "无效的 dimension:" + dimension);
383
+ const query = asString(rawArgs, "query");
384
+ const sessionId = asString(rawArgs, "sessionId");
385
+ const from = asString(rawArgs, "from");
386
+ const to = asString(rawArgs, "to");
387
+ const offset = asInt(rawArgs, "offset", 0, 10_000_000) ?? 0;
388
+ const limit = asInt(rawArgs, "limit", 1, historyPageLimits.search.max) ?? historyPageLimits.search.default;
389
+ return searchWorkspaceHistory(root, {
390
+ ...(hostFilter ? { host: hostFilter } : {}),
391
+ ...(dimension ? { dimension } : {}),
392
+ ...(query ? { query } : {}),
393
+ ...(sessionId ? { sessionId } : {}),
394
+ ...(from ? { from } : {}),
395
+ ...(to ? { to } : {}),
396
+ offset,
397
+ limit,
398
+ });
399
+ }
400
+ case "history_read": {
401
+ requireThat(!this.#nativeHistory, "当前宿主已提供原生 pbot_history 工具,请直接调用 pbot_history。");
402
+ requireThat(workspaceFeatures(configuration).history, `工作区历史功能已在 ${configuration.path} 中停用(features.history: false)。`);
403
+ const id = asString(rawArgs, "id", true)!;
404
+ const hostFilter = asString(rawArgs, "host");
405
+ if (hostFilter !== undefined) requireThat(isHistoryIdentifier(hostFilter), "无效的 host 来源:" + hostFilter);
406
+ const offset = asInt(rawArgs, "offset", 0, 10_000_000) ?? 0;
407
+ const limit = asInt(rawArgs, "limit", 1, historyPageLimits.read.max) ?? historyPageLimits.read.default;
408
+ const childrenOffset = asInt(rawArgs, "childrenOffset", 0, 10_000_000) ?? 0;
409
+ return { node: readWorkspaceHistory(root, id, offset, limit, childrenOffset, hostFilter) };
410
+ }
411
+ }
412
+
413
+ const { host, service, owner } = this.workerService(root, configuration.acp);
414
+ switch (name) {
712
415
  case "worker_create": {
713
416
  const backend = this.resolveBackend(rawArgs, configuration.acp, false);
714
417
  const model = asString(rawArgs, "model");
@@ -753,10 +456,9 @@ export class McpWorkerRuntime {
753
456
  }
754
457
  case "worker_response": {
755
458
  const workerId = asString(rawArgs, "workerId", true)!;
756
- const rawAction = asString(rawArgs, "action", true)!;
757
- requireThat((responseActions as readonly string[]).includes(rawAction),
758
- `参数 action 无效:${rawAction}(可用:${responseActions.join(", ")})。`);
759
- const action = rawAction as AcpElicitationAction;
459
+ const action = asString(rawArgs, "action", true)!;
460
+ requireThat(isOneOf(action, acpElicitationActions),
461
+ `参数 action 无效:${action}(可用:${acpElicitationActions.join(", ")})。`);
760
462
  const requestId = asString(rawArgs, "requestId");
761
463
  const optionId = asString(rawArgs, "optionId");
762
464
  const content = asContent(rawArgs, "content");
@@ -778,9 +480,9 @@ export class McpWorkerRuntime {
778
480
  }
779
481
  case "worker_discover": {
780
482
  const rawTarget = asString(rawArgs, "target") ?? "overview";
781
- requireThat((discoverTargets as readonly string[]).includes(rawTarget),
483
+ requireThat(isOneOf(rawTarget, discoverTargets),
782
484
  `参数 target 无效:${rawTarget}(可用:${discoverTargets.join(", ")})。`);
783
- const target = rawTarget as DiscoverTarget;
485
+ const target = rawTarget;
784
486
  const workerId = asString(rawArgs, "workerId");
785
487
  const backendRaw = asString(rawArgs, "backend");
786
488
  const model = asString(rawArgs, "model");
@@ -815,17 +517,18 @@ export class McpWorkerRuntime {
815
517
  };
816
518
  }
817
519
  }
520
+ throw new Error(`未知工具:${name satisfies never}`);
818
521
  }
819
522
 
820
- async close(preserve = false): Promise<void> {
821
- if (this.#closed) return;
822
- this.#closed = true;
523
+ close(preserve = false): Promise<void> {
524
+ if (this.#closing) return this.#closing;
823
525
  const entries = [...this.#services.values()];
824
526
  this.#services.clear();
825
- await Promise.allSettled([
527
+ this.#closing = Promise.allSettled([
826
528
  this.#bridge.close(),
827
529
  ...entries.map(({ service, owner }) => service.close(owner, preserve)),
828
- ]);
530
+ ]).then(() => {});
531
+ return this.#closing;
829
532
  }
830
533
  }
831
534
 
@@ -853,7 +556,7 @@ export async function handleMcpRequest(
853
556
  protocolVersion: requested || protocolVersion,
854
557
  capabilities: { tools: {} },
855
558
  serverInfo: { name: "personal-bot", version: packageVersion },
856
- instructions: mcpInstructions,
559
+ instructions: runtime.nativeWorkspaceMcp ? mcpWorkerOnlyInstructions : mcpInstructions,
857
560
  },
858
561
  };
859
562
  }