personal-bot 0.2.20 → 0.3.1

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 (343) hide show
  1. package/.claude-plugin/marketplace.json +3 -3
  2. package/.claude-plugin/plugin.json +2 -5
  3. package/.mcp.json +11 -0
  4. package/CONTEXT.md +17 -73
  5. package/README.md +41 -120
  6. package/README.zh-CN.md +41 -120
  7. package/docs/README.md +31 -23
  8. package/docs/architecture/design.md +74 -0
  9. package/docs/architecture/extensibility.md +78 -0
  10. package/docs/architecture/model-context.md +31 -0
  11. package/docs/architecture/model-instruction-guidelines.md +34 -0
  12. package/docs/architecture/principles.md +33 -0
  13. package/docs/guides/capabilities.md +36 -0
  14. package/docs/guides/cross-harness-workers.md +83 -0
  15. package/docs/guides/history.md +25 -0
  16. package/docs/guides/workspace-configuration.md +102 -0
  17. package/docs/hosts/antigravity.md +52 -0
  18. package/docs/hosts/claude-code.md +47 -0
  19. package/docs/hosts/dsh.md +67 -0
  20. package/docs/hosts/pi.md +49 -0
  21. package/docs/maintainers/release.md +59 -0
  22. package/hooks/hooks.json +0 -3
  23. package/lib/antigravity-plugin/hooks.json +23 -0
  24. package/lib/antigravity-plugin/lib/claude.d.ts +1 -0
  25. package/lib/antigravity-plugin/lib/claude.js +13 -0
  26. package/lib/antigravity-plugin/lib/common/json.d.ts +6 -0
  27. package/lib/antigravity-plugin/lib/common/json.js +16 -0
  28. package/lib/antigravity-plugin/lib/common/paths.d.ts +1 -0
  29. package/lib/antigravity-plugin/lib/common/paths.js +2 -0
  30. package/lib/antigravity-plugin/lib/common/validation.d.ts +3 -0
  31. package/lib/antigravity-plugin/lib/common/validation.js +8 -0
  32. package/lib/antigravity-plugin/lib/common/version.d.ts +3 -0
  33. package/lib/antigravity-plugin/lib/common/version.js +13 -0
  34. package/lib/antigravity-plugin/lib/extension/acp-worker.js +11597 -0
  35. package/lib/antigravity-plugin/lib/extension/mcp.js +2715 -0
  36. package/lib/antigravity-plugin/lib/extension/plugin-runtime.d.ts +10 -0
  37. package/lib/antigravity-plugin/lib/extension/plugin-runtime.js +67 -0
  38. package/lib/antigravity-plugin/lib/integrations/agent-resources.d.ts +16 -0
  39. package/lib/antigravity-plugin/lib/integrations/agent-resources.js +56 -0
  40. package/lib/antigravity-plugin/lib/integrations/hosts/antigravity.d.ts +4 -0
  41. package/lib/antigravity-plugin/lib/integrations/hosts/antigravity.js +79 -0
  42. package/lib/antigravity-plugin/lib/integrations/hosts/claude.d.ts +3 -0
  43. package/lib/antigravity-plugin/lib/integrations/hosts/claude.js +60 -0
  44. package/lib/antigravity-plugin/lib/integrations/hosts/registry.d.ts +15 -0
  45. package/lib/antigravity-plugin/lib/integrations/hosts/registry.js +34 -0
  46. package/lib/antigravity-plugin/lib/model/acp.d.ts +164 -0
  47. package/lib/antigravity-plugin/lib/model/acp.js +12 -0
  48. package/lib/antigravity-plugin/lib/model/plugin-host.d.ts +48 -0
  49. package/lib/antigravity-plugin/lib/model/workspace-config.d.ts +24 -0
  50. package/lib/antigravity-plugin/lib/model/workspace-config.js +1 -0
  51. package/lib/antigravity-plugin/lib/model/workspace-mcp.d.ts +51 -0
  52. package/lib/antigravity-plugin/lib/model/workspace-mcp.js +4 -0
  53. package/lib/antigravity-plugin/lib/plugin.d.ts +1 -0
  54. package/lib/antigravity-plugin/lib/plugin.js +17 -0
  55. package/lib/antigravity-plugin/lib/services/workspace/workspace-config.d.ts +8 -0
  56. package/lib/antigravity-plugin/lib/services/workspace/workspace-config.js +95 -0
  57. package/lib/antigravity-plugin/lib/services/workspace/workspace-preparation.d.ts +3 -0
  58. package/lib/antigravity-plugin/lib/services/workspace/workspace-preparation.js +26 -0
  59. package/lib/antigravity-plugin/lib/services/workspace/workspace-skills.d.ts +8 -0
  60. package/lib/antigravity-plugin/lib/services/workspace/workspace-skills.js +91 -0
  61. package/lib/antigravity-plugin/lib/storage/atomic-json.d.ts +11 -0
  62. package/lib/antigravity-plugin/lib/storage/atomic-json.js +101 -0
  63. package/lib/antigravity-plugin/mcp_config.json +13 -0
  64. package/lib/antigravity-plugin/package.json +6 -0
  65. package/lib/antigravity-plugin/plugin.json +7 -0
  66. package/lib/antigravity-plugin/resources/agents/coordinator.md +11 -0
  67. package/{resources/claude → lib/antigravity-plugin/resources}/agents/general-purpose.md +0 -5
  68. package/lib/antigravity-plugin/resources/prompts/plugin-coordinator.md +1 -0
  69. package/lib/antigravity-plugin/resources/prompts/workspace.md +31 -0
  70. package/lib/antigravity-plugin/resources/references/compute-finance.md +22 -0
  71. package/lib/antigravity-plugin/resources/references/compute.md +16 -0
  72. package/lib/antigravity-plugin/resources/references/task-conductor.md +25 -0
  73. package/lib/antigravity-plugin/resources/templates/workspace-agents.md +21 -0
  74. package/lib/antigravity-plugin/skills/pbot/SKILL.md +16 -0
  75. package/lib/antigravity-plugin/skills/project-maintenance/SKILL.md +35 -0
  76. package/lib/antigravity-plugin/skills/provider-connections/SKILL.md +42 -0
  77. package/lib/claude.js +4 -11
  78. package/lib/client.js +14 -531
  79. package/lib/common/markdown.js +2 -3
  80. package/lib/common/validation.d.ts +2 -0
  81. package/lib/common/validation.js +4 -0
  82. package/lib/extension/acp-member.d.ts +2 -0
  83. package/lib/extension/acp-member.js +9 -8
  84. package/lib/extension/acp-worker.js +11578 -121
  85. package/lib/extension/dsh/acp-member.js +26 -2
  86. package/lib/extension/dsh/command.js +19 -57
  87. package/lib/extension/dsh/history.js +2 -4
  88. package/lib/extension/dsh/management.d.ts +0 -2
  89. package/lib/extension/dsh/management.js +27 -126
  90. package/lib/extension/dsh/workspace.d.ts +5 -47
  91. package/lib/extension/dsh/workspace.js +76 -108
  92. package/lib/extension/mcp-bridge.d.ts +41 -0
  93. package/lib/extension/mcp-bridge.js +412 -0
  94. package/lib/extension/mcp-workers.d.ts +980 -0
  95. package/lib/extension/mcp-workers.js +882 -0
  96. package/lib/extension/mcp.js +2715 -0
  97. package/lib/extension/plugin-runtime.d.ts +10 -0
  98. package/lib/extension/plugin-runtime.js +67 -0
  99. package/lib/extension/setup-cli.js +215 -2
  100. package/lib/integrations/acp/agents.d.ts +10 -11
  101. package/lib/integrations/acp/agents.js +65 -33
  102. package/lib/integrations/acp/claude.d.ts +2 -2
  103. package/lib/integrations/acp/claude.js +5 -3
  104. package/lib/integrations/acp/connection.d.ts +17 -4
  105. package/lib/integrations/acp/connection.js +53 -27
  106. package/lib/integrations/acp/executable.d.ts +3 -0
  107. package/lib/integrations/acp/executable.js +42 -0
  108. package/lib/integrations/acp/harnesses/claude.d.ts +2 -0
  109. package/lib/integrations/acp/harnesses/claude.js +49 -0
  110. package/lib/integrations/acp/harnesses/dsh.d.ts +2 -0
  111. package/lib/integrations/acp/harnesses/dsh.js +35 -0
  112. package/lib/integrations/acp/harnesses/generic.d.ts +13 -0
  113. package/lib/integrations/acp/harnesses/generic.js +37 -0
  114. package/lib/integrations/acp/harnesses/pi.d.ts +2 -0
  115. package/lib/integrations/acp/harnesses/pi.js +34 -0
  116. package/lib/integrations/acp/harnesses/presets.d.ts +3 -0
  117. package/lib/integrations/acp/harnesses/presets.js +20 -0
  118. package/lib/integrations/acp/launch.d.ts +33 -4
  119. package/lib/integrations/acp/launch.js +60 -48
  120. package/lib/integrations/acp/mcp.d.ts +6 -0
  121. package/lib/integrations/acp/mcp.js +40 -0
  122. package/lib/integrations/acp/model-selection.d.ts +9 -2
  123. package/lib/integrations/acp/model-selection.js +73 -27
  124. package/lib/integrations/acp/registry.d.ts +18 -0
  125. package/lib/integrations/acp/registry.js +50 -0
  126. package/lib/integrations/agent-resources.d.ts +16 -1
  127. package/lib/integrations/agent-resources.js +45 -9
  128. package/lib/integrations/dsh/mcp.d.ts +4 -0
  129. package/lib/integrations/dsh/mcp.js +28 -0
  130. package/lib/integrations/dsh/resources.d.ts +3 -3
  131. package/lib/integrations/dsh/resources.js +21 -12
  132. package/lib/integrations/dsh/skills.d.ts +5 -1
  133. package/lib/integrations/dsh/skills.js +10 -6
  134. package/lib/integrations/hosts/antigravity.d.ts +4 -0
  135. package/lib/integrations/hosts/antigravity.js +79 -0
  136. package/lib/integrations/hosts/claude.d.ts +3 -0
  137. package/lib/integrations/hosts/claude.js +60 -0
  138. package/lib/integrations/hosts/registry.d.ts +15 -0
  139. package/lib/integrations/hosts/registry.js +34 -0
  140. package/lib/model/acp.d.ts +107 -2
  141. package/lib/model/acp.js +12 -1
  142. package/lib/model/agent.d.ts +35 -33
  143. package/lib/model/plugin-host.d.ts +48 -0
  144. package/lib/model/plugin-host.js +1 -0
  145. package/lib/model/workspace-config.d.ts +12 -0
  146. package/lib/model/workspace-mcp.d.ts +51 -0
  147. package/lib/model/workspace-mcp.js +4 -0
  148. package/lib/plugin.d.ts +1 -0
  149. package/lib/plugin.js +17 -0
  150. package/lib/services/agents/acp-run.d.ts +13 -1
  151. package/lib/services/agents/acp-run.js +30 -2
  152. package/lib/services/agents/agent-service.d.ts +35 -120
  153. package/lib/services/agents/agent-service.js +156 -160
  154. package/lib/services/installation/setup-service.js +17 -1
  155. package/lib/services/workspace/workspace-config.d.ts +2 -1
  156. package/lib/services/workspace/workspace-config.js +43 -9
  157. package/lib/services/workspace/workspace-mcp.d.ts +14 -0
  158. package/lib/services/workspace/workspace-mcp.js +200 -0
  159. package/lib/services/workspace/workspace-skills.d.ts +8 -0
  160. package/lib/services/workspace/workspace-skills.js +91 -0
  161. package/lib/storage/acp-files.d.ts +3 -1
  162. package/lib/storage/acp-files.js +32 -2
  163. package/lib/storage/acp-history.d.ts +3 -2
  164. package/lib/storage/acp-history.js +19 -7
  165. package/lib/storage/agent-files.d.ts +8 -8
  166. package/lib/storage/agent-files.js +27 -47
  167. package/lib/tools/history/contract.d.ts +1 -1
  168. package/lib/tools/history/contract.js +17 -11
  169. package/lib/ui/dsh/index.js +8 -3
  170. package/lib/ui/dsh/management.d.ts +1 -1
  171. package/lib/ui/dsh/management.js +24 -456
  172. package/lib/ui/dsh/remote.d.ts +0 -2
  173. package/lib/ui/dsh/remote.js +1 -1
  174. package/package.json +12 -7
  175. package/resources/agents/coordinator.md +2 -2
  176. package/resources/antigravity/skills/pbot/SKILL.md +16 -0
  177. package/resources/claude/skills/pbot/SKILL.md +1 -1
  178. package/resources/prompts/history-coordinator.md +1 -0
  179. package/resources/prompts/plugin-coordinator.md +1 -0
  180. package/resources/prompts/workspace.md +9 -8
  181. package/resources/references/compute.md +9 -11
  182. package/resources/references/task-conductor.md +12 -26
  183. package/resources/skills/project-maintenance/SKILL.md +16 -21
  184. package/resources/skills/provider-connections/SKILL.md +24 -40
  185. package/resources/templates/workspace-agents.md +4 -0
  186. package/scripts/README.md +17 -34
  187. package/src/claude.ts +4 -8
  188. package/src/common/markdown.ts +2 -3
  189. package/src/common/validation.ts +6 -0
  190. package/src/extension/acp-member.ts +9 -8
  191. package/src/extension/acp-worker.ts +239 -97
  192. package/src/extension/command.ts +38 -36
  193. package/src/extension/dsh/acp-member.ts +21 -2
  194. package/src/extension/dsh/command.ts +21 -51
  195. package/src/extension/dsh/files.ts +1 -0
  196. package/src/extension/dsh/history.ts +9 -6
  197. package/src/extension/dsh/management.ts +27 -58
  198. package/src/extension/dsh/workspace.ts +88 -99
  199. package/src/extension/events.ts +13 -10
  200. package/src/extension/history.ts +2 -50
  201. package/src/extension/lifecycle.ts +37 -22
  202. package/src/extension/mcp-bridge.ts +412 -0
  203. package/src/extension/mcp-workers.ts +941 -0
  204. package/src/extension/pi-acp-member.ts +29 -5
  205. package/src/extension/plugin-runtime.ts +63 -0
  206. package/src/extension/setup-cli.ts +186 -2
  207. package/src/integrations/acp/agents.ts +70 -24
  208. package/src/integrations/acp/claude.ts +11 -4
  209. package/src/integrations/acp/connection.ts +63 -25
  210. package/src/integrations/acp/executable.ts +41 -0
  211. package/src/integrations/acp/harnesses/claude.ts +50 -0
  212. package/src/integrations/acp/harnesses/dsh.ts +40 -0
  213. package/src/integrations/acp/harnesses/generic.ts +52 -0
  214. package/src/integrations/acp/harnesses/pi.ts +35 -0
  215. package/src/integrations/acp/harnesses/presets.ts +22 -0
  216. package/src/integrations/acp/launch.ts +69 -47
  217. package/src/integrations/acp/mcp.ts +43 -0
  218. package/src/integrations/acp/model-selection.ts +68 -25
  219. package/src/integrations/acp/registry.ts +60 -0
  220. package/src/integrations/agent-resources.ts +70 -6
  221. package/src/integrations/dsh/mcp.ts +30 -0
  222. package/src/integrations/dsh/resources.ts +28 -13
  223. package/src/integrations/dsh/skills.ts +16 -6
  224. package/src/integrations/hosts/antigravity.ts +83 -0
  225. package/src/integrations/hosts/claude.ts +62 -0
  226. package/src/integrations/hosts/registry.ts +42 -0
  227. package/src/integrations/pi/mcp.ts +26 -0
  228. package/src/mcp.ts +14 -0
  229. package/src/model/acp.ts +113 -3
  230. package/src/model/agent.ts +18 -14
  231. package/src/model/plugin-host.ts +39 -0
  232. package/src/model/workspace-config.ts +14 -0
  233. package/src/model/workspace-mcp.ts +64 -0
  234. package/src/pbot.ts +69 -20
  235. package/src/plugin.ts +19 -0
  236. package/src/services/agents/acp-run.ts +35 -3
  237. package/src/services/agents/agent-service.ts +180 -160
  238. package/src/services/installation/setup-service.ts +17 -2
  239. package/src/services/workspace/workspace-config.ts +46 -8
  240. package/src/services/workspace/workspace-mcp.ts +242 -0
  241. package/src/services/workspace/workspace-skills.ts +78 -0
  242. package/src/storage/acp-files.ts +32 -3
  243. package/src/storage/acp-history.ts +18 -7
  244. package/src/storage/agent-files.ts +27 -41
  245. package/src/tools/history/contract.ts +17 -11
  246. package/src/tools/register.ts +4 -8
  247. package/src/ui/dsh/index.ts +8 -3
  248. package/src/ui/dsh/management.ts +40 -282
  249. package/src/ui/dsh/remote.ts +2 -2
  250. package/docs/adr/0001-claude-skill-discovery.md +0 -3
  251. package/docs/adr/0002-claude-native-collaboration.md +0 -3
  252. package/docs/agent-collaboration.md +0 -190
  253. package/docs/architecture-guidelines.md +0 -37
  254. package/docs/capability-design.md +0 -55
  255. package/docs/claude-code-design.md +0 -44
  256. package/docs/claude-code.md +0 -57
  257. package/docs/dsh.md +0 -337
  258. package/docs/file-storage.md +0 -97
  259. package/docs/history.md +0 -54
  260. package/docs/installation-design.md +0 -86
  261. package/docs/interaction-design.md +0 -21
  262. package/docs/model-context.md +0 -76
  263. package/docs/model-instruction-guidelines.md +0 -51
  264. package/docs/release.md +0 -108
  265. package/docs/technical-design.md +0 -163
  266. package/docs/workspace-configuration.md +0 -79
  267. package/lib/extension/claude-hooks.d.ts +0 -9
  268. package/lib/extension/claude-hooks.js +0 -78
  269. package/lib/extension/dsh/agent-events.d.ts +0 -24
  270. package/lib/extension/dsh/agent-events.js +0 -242
  271. package/lib/extension/dsh/agent-runtime.d.ts +0 -49
  272. package/lib/extension/dsh/agent-runtime.js +0 -351
  273. package/lib/integrations/dsh/dsh-agents.d.ts +0 -30
  274. package/lib/integrations/dsh/dsh-agents.js +0 -104
  275. package/lib/integrations/dsh/input.d.ts +0 -21
  276. package/lib/integrations/dsh/input.js +0 -62
  277. package/lib/integrations/dsh/notifications.d.ts +0 -8
  278. package/lib/integrations/dsh/notifications.js +0 -55
  279. package/lib/integrations/dsh/session.d.ts +0 -14
  280. package/lib/integrations/dsh/session.js +0 -60
  281. package/lib/integrations/team-context.d.ts +0 -18
  282. package/lib/integrations/team-context.js +0 -61
  283. package/lib/model/team.d.ts +0 -85
  284. package/lib/services/agents/agent-notices.d.ts +0 -13
  285. package/lib/services/agents/agent-notices.js +0 -25
  286. package/lib/services/agents/start-options.d.ts +0 -4
  287. package/lib/services/agents/start-options.js +0 -20
  288. package/lib/services/agents/team-service.d.ts +0 -168
  289. package/lib/services/agents/team-service.js +0 -345
  290. package/lib/storage/team-files.d.ts +0 -16
  291. package/lib/storage/team-files.js +0 -111
  292. package/lib/tools/agents/actions.d.ts +0 -62
  293. package/lib/tools/agents/actions.js +0 -62
  294. package/lib/tools/agents/contract.d.ts +0 -181
  295. package/lib/tools/agents/contract.js +0 -84
  296. package/lib/tools/agents/dsh-tool.d.ts +0 -5
  297. package/lib/tools/agents/dsh-tool.js +0 -34
  298. package/lib/tools/result.d.ts +0 -18
  299. package/lib/tools/result.js +0 -10
  300. package/lib/tools/teams/actions.d.ts +0 -23
  301. package/lib/tools/teams/actions.js +0 -40
  302. package/lib/tools/teams/contract.d.ts +0 -201
  303. package/lib/tools/teams/contract.js +0 -91
  304. package/lib/tools/teams/dsh-tool.d.ts +0 -8
  305. package/lib/tools/teams/dsh-tool.js +0 -39
  306. package/lib/ui/dsh/attachments.d.ts +0 -5
  307. package/lib/ui/dsh/attachments.js +0 -39
  308. package/resources/prompts/claude-coordinator.md +0 -1
  309. package/resources/prompts/native-coordinator.md +0 -1
  310. package/resources/prompts/team-member.md +0 -7
  311. package/src/extension/agent-events.ts +0 -210
  312. package/src/extension/agents-command.ts +0 -89
  313. package/src/extension/claude-hooks.ts +0 -74
  314. package/src/extension/dsh/agent-events.ts +0 -148
  315. package/src/extension/dsh/agent-runtime.ts +0 -252
  316. package/src/extension/subagent-entry.ts +0 -270
  317. package/src/extension/teams-command.ts +0 -67
  318. package/src/integrations/dsh/dsh-agents.ts +0 -97
  319. package/src/integrations/dsh/input.ts +0 -66
  320. package/src/integrations/dsh/notifications.ts +0 -46
  321. package/src/integrations/pi/agent-context.ts +0 -18
  322. package/src/integrations/pi/agent-input.ts +0 -19
  323. package/src/integrations/pi/pi-agents.ts +0 -84
  324. package/src/integrations/pi/team-context.ts +0 -26
  325. package/src/integrations/team-context.ts +0 -64
  326. package/src/model/team.ts +0 -29
  327. package/src/services/agents/agent-notices.ts +0 -28
  328. package/src/services/agents/start-options.ts +0 -19
  329. package/src/services/agents/team-service.ts +0 -275
  330. package/src/storage/team-files.ts +0 -93
  331. package/src/tools/agents/actions.ts +0 -57
  332. package/src/tools/agents/contract.ts +0 -101
  333. package/src/tools/agents/dsh-tool.ts +0 -37
  334. package/src/tools/agents/tool.ts +0 -20
  335. package/src/tools/teams/actions.ts +0 -34
  336. package/src/tools/teams/contract.ts +0 -109
  337. package/src/tools/teams/dsh-tool.ts +0 -45
  338. package/src/tools/teams/tool.ts +0 -29
  339. package/src/ui/agent-display.ts +0 -14
  340. package/src/ui/dsh/attachments.ts +0 -42
  341. package/src/ui/pi/menu.ts +0 -37
  342. package/src/ui/pi/reader.ts +0 -46
  343. /package/lib/{model/team.js → antigravity-plugin/lib/model/plugin-host.js} +0 -0
package/src/model/acp.ts CHANGED
@@ -1,13 +1,50 @@
1
- export type AcpBackend = "pi" | "dsh" | "claude";
2
- export interface AcpCommand { command: string; args: string[] }
3
- export type AcpCommands = Partial<Record<AcpBackend, AcpCommand>>;
1
+ export const mcpWorkerToolNames = [
2
+ "worker_create",
3
+ "worker_close",
4
+ "worker_request",
5
+ "worker_response",
6
+ "worker_output",
7
+ "worker_discover",
8
+ ] as const;
9
+ export type McpWorkerToolName = typeof mcpWorkerToolNames[number];
10
+ export function isMcpWorkerTool(name: string): boolean {
11
+ const bare = name.startsWith("mcp__pbot__") ? name.slice("mcp__pbot__".length) : name;
12
+ return bare === "pbot_worker" || (mcpWorkerToolNames as readonly string[]).includes(bare);
13
+ }
14
+
15
+ export type AcpBackend = string;
16
+ export interface AcpCommand {
17
+ command: string;
18
+ args: string[];
19
+ env?: Record<string, string>;
20
+ }
21
+ /** ask: forward target permission requests to the parent session; allow/deny: answer them automatically. */
22
+ export type AcpPermissionPolicy = "ask" | "allow" | "deny";
23
+ /** Workspace `acp.<name>` entry; omitting `command` keeps a registered harness's default command. */
24
+ export interface AcpHarnessConfig {
25
+ command?: string;
26
+ args?: string[];
27
+ env?: Record<string, string>;
28
+ permission?: AcpPermissionPolicy;
29
+ }
30
+ export type AcpCommands = Record<string, AcpHarnessConfig>;
4
31
  export interface AcpSessionReference extends AcpCommand {
5
32
  host: "acp";
6
33
  backend: AcpBackend;
7
34
  sessionId: string | null;
35
+ permission?: AcpPermissionPolicy;
8
36
  capabilities?: { resume: boolean; load: boolean; close: boolean };
9
37
  }
10
38
  export interface AcpModelSelection { provider?: string; model?: string; resolvedModel?: string; thinking?: string }
39
+ export interface AcpChoice { value: string; name: string; description?: string }
40
+ export interface AcpModelsResult {
41
+ backend: AcpBackend;
42
+ models: AcpChoice[];
43
+ thinking: AcpChoice[];
44
+ currentModel?: string;
45
+ currentThinking?: string;
46
+ selection: AcpModelSelection;
47
+ }
11
48
  export interface AcpModelState extends AcpModelSelection { generation: string }
12
49
  export interface AcpProcess { generation: string; pid: number; startedAt: number }
13
50
  export interface AcpInput { generation: string; requestId: string }
@@ -24,3 +61,76 @@ export interface AcpPermission {
24
61
  options: { optionId: string; name: string; kind: string }[];
25
62
  }
26
63
  export interface AcpPermissionReply { generation: string; requestId: string; optionId: string | null }
64
+ export type AcpElicitationAction = "accept" | "decline" | "cancel";
65
+ export type AcpElicitationValue = string | number | boolean | string[];
66
+ export type AcpElicitationContent = Record<string, AcpElicitationValue>;
67
+ export interface AcpElicitation {
68
+ generation: string;
69
+ requestId: string;
70
+ mode: "form" | "url";
71
+ message: string;
72
+ schema?: Record<string, unknown>;
73
+ url?: string;
74
+ }
75
+ export interface AcpElicitationReply {
76
+ generation: string;
77
+ requestId: string;
78
+ action: AcpElicitationAction;
79
+ content?: AcpElicitationContent;
80
+ }
81
+
82
+ export interface AcpStartOptions {
83
+ name?: string;
84
+ message?: string;
85
+ files?: string[];
86
+ provider?: string;
87
+ model?: string;
88
+ thinking?: string;
89
+ cwd?: string;
90
+ tools?: string[];
91
+ noExtensions?: boolean;
92
+ noSkills?: boolean;
93
+ noPromptTemplates?: boolean;
94
+ noContextFiles?: boolean;
95
+ }
96
+
97
+ export interface AcpLaunchContext {
98
+ readonly reference: AcpSessionReference;
99
+ readonly cwd: string;
100
+ readonly directory: string;
101
+ readonly packageRoot: string;
102
+ readonly options: AcpStartOptions;
103
+ readonly env: NodeJS.ProcessEnv;
104
+ readonly features?: { readonly prompts: boolean; readonly skills: boolean; readonly mcp: boolean };
105
+ }
106
+
107
+ export interface AcpPreparedLaunch {
108
+ readonly command: AcpSessionReference;
109
+ readonly env: NodeJS.ProcessEnv;
110
+ readonly sessionMeta?: Record<string, unknown>;
111
+ readonly defaultThinking?: string;
112
+ }
113
+
114
+ /** Narrow adapter isolating harness-specific ACP conventions from the generic runtime. */
115
+ export interface AcpHarnessAdapter {
116
+ readonly id: AcpBackend;
117
+ /** Product name users say in conversation, e.g. "Claude Code". */
118
+ readonly label?: string;
119
+ /** Alternative backend names accepted from callers; configured custom names take precedence. */
120
+ readonly aliases?: readonly string[];
121
+ readonly defaultCommand?: AcpCommand;
122
+ readonly installHint?: string;
123
+ readonly configureHint?: string;
124
+ readonly exactAnswer?: boolean;
125
+ readonly eagerSessionId?: boolean;
126
+ readonly requireSystemPrompt?: boolean;
127
+ readonly nativeWorkspaceSkills?: boolean;
128
+ readonly nativeWorkspaceMcp?: boolean;
129
+ readonly customNotificationMethod?: string;
130
+ filterStartOptions?(options: AcpStartOptions): AcpStartOptions;
131
+ validateStartOptions?(options: AcpStartOptions): void;
132
+ prepareLaunch?(context: AcpLaunchContext): Promise<AcpPreparedLaunch> | AcpPreparedLaunch;
133
+ parseModelValue?(value: string): { provider?: string; model: string };
134
+ formatModelQuery?(model: string, provider?: string): string | undefined;
135
+ parseCustomNotification?(params: unknown, sessionId: string): { resolvedModel?: string } | undefined;
136
+ }
@@ -1,21 +1,13 @@
1
- import type { AcpBackend, AcpModelSelection, AcpSessionReference } from "./acp.js";
1
+ import type { AcpBackend, AcpElicitationAction, AcpElicitationContent, AcpModelSelection, AcpSessionReference, AcpStartOptions } from "./acp.js";
2
2
 
3
- export interface AgentStartOptions extends AgentOptions { backend?: AcpBackend }
4
- export interface AgentOptions {
5
- name?: string; message?: string; files?: string[];
6
- provider?: string; model?: string; thinking?: string; cwd?: string; tools?: string[];
7
- noExtensions?: boolean; noSkills?: boolean; noPromptTemplates?: boolean; noContextFiles?: boolean;
8
- }
3
+ export type AgentOptions = AcpStartOptions;
4
+ export interface AgentStartOptions extends AgentOptions { backend: AcpBackend }
9
5
  export interface AgentOwner { sessionId: string; leaf: string | null; branch: string[] }
10
6
  export interface AgentDescriptor {
11
7
  agentId: string; release: string; workspace: string; cwd: string; parentSessionId: string;
12
8
  parentLeaf: string | null; createdAt: number; options: AgentOptions;
13
9
  }
14
- /** null means no conversation input has been handed to Pi yet. */
15
- export interface AgentSessionRef { file: string | null }
16
- export type NativeAgentHost = "pi" | "dsh";
17
- /** Native references are interpreted only by their owning host adapter. */
18
- export type AgentSessionReference = { host: "pi"; file: string | null } | { host: "dsh"; sessionId: string } | AcpSessionReference;
10
+ export type AgentSessionReference = AcpSessionReference;
19
11
  export interface AgentLaunch { generation: string; name: string; sequence: number; stop: boolean; startedAt: number }
20
12
  export interface AgentMessage { requestId: string; generation: string; sequence: number; message: string; delivery: "steer" | "followUp"; files: string[] }
21
13
  export interface AgentCycle {
@@ -30,8 +22,20 @@ export interface AgentStatus {
30
22
  }
31
23
  export interface AgentView extends AgentDescriptor {
32
24
  name: string; generation: string; state: AgentStatus["state"]; activity: string;
33
- backend?: AcpBackend; transport?: "native" | "acp"; selection?: AcpModelSelection;
34
- capabilities?: { steer: boolean; resume: boolean; team: boolean; transcript: boolean };
25
+ alive: boolean;
26
+ backend: AcpBackend; transport: "acp"; selection?: AcpModelSelection;
27
+ capabilities: { steer: boolean; resume: boolean; transcript: boolean };
35
28
  cycle?: AgentCycle; error?: string; owned: boolean;
29
+ pendingRequests?: AgentPendingRequest[];
30
+ }
31
+ export type AgentPendingRequest =
32
+ | { requestId: string; kind: "permission"; description: string; options: { optionId: string; name: string; kind: string }[] }
33
+ | { requestId: string; kind: "form"; message: string; schema: Record<string, unknown> }
34
+ | { requestId: string; kind: "url"; message: string; url: string };
35
+ export interface AgentResponseInput {
36
+ requestId?: string;
37
+ action: AcpElicitationAction;
38
+ optionId?: string;
39
+ content?: AcpElicitationContent;
36
40
  }
37
41
  export interface AgentCompletion { agentId: string; name: string; cycle: AgentCycle; report: string }
@@ -0,0 +1,39 @@
1
+ import type { WorkspaceSkillMeta } from "./workspace-mcp.js";
2
+
3
+ export type HostId = string;
4
+ export type PluginHostId = string;
5
+ export type WorkspaceRole = "coordinator" | "general-purpose";
6
+
7
+ export interface WorkspaceEnvironment {
8
+ host: HostId;
9
+ workspaceRoot: string;
10
+ resourceRoot: string;
11
+ }
12
+
13
+ export interface WorkspaceContext {
14
+ workspace: string;
15
+ role: string;
16
+ rootAgents: string;
17
+ workspaceSkills: WorkspaceSkillMeta[];
18
+ environment: WorkspaceEnvironment;
19
+ text: string;
20
+ }
21
+
22
+ export type HostEvent =
23
+ | { kind: "ignore" }
24
+ | { kind: "inject-context"; role: WorkspaceRole; localRoleOnly?: boolean; cwd: string; raw: unknown }
25
+ | { kind: "check-skill"; skill: string; cwd: string; raw: unknown };
26
+
27
+ export interface PluginHostAdapter {
28
+ readonly host: PluginHostId;
29
+ readonly nativeRootAgents: boolean;
30
+ readonly nativeWorkspaceSkills?: boolean;
31
+ readonly coordinatorPrompt?: string;
32
+ readonly initCommandHint: string;
33
+ readonly usage: string;
34
+ resolveRoot(cwd: string, rawPayload?: unknown): Promise<string>;
35
+ parseEvent(payload: unknown): HostEvent;
36
+ formatPass(payload: unknown): Record<string, unknown>;
37
+ formatContext(event: Extract<HostEvent, { kind: "inject-context" }>, context: WorkspaceContext): Record<string, unknown>;
38
+ formatDeny(event: Extract<HostEvent, { kind: "check-skill" }>, reason: string): Record<string, unknown>;
39
+ }
@@ -1,7 +1,20 @@
1
1
  import type { AcpCommands } from "./acp.js";
2
2
 
3
+ export interface WorkspaceFeatures {
4
+ prompts?: boolean;
5
+ skills?: boolean;
6
+ mcp?: boolean;
7
+ }
8
+
9
+ export interface ResolvedWorkspaceFeatures {
10
+ readonly prompts: boolean;
11
+ readonly skills: boolean;
12
+ readonly mcp: boolean;
13
+ }
14
+
3
15
  export interface WorkspaceConfig {
4
16
  enabled?: boolean;
17
+ features?: WorkspaceFeatures;
5
18
  acp?: AcpCommands;
6
19
  }
7
20
 
@@ -10,5 +23,6 @@ export interface WorkspaceConfiguration {
10
23
  present: boolean;
11
24
  enabled: boolean;
12
25
  error?: string;
26
+ features?: WorkspaceFeatures;
13
27
  acp?: AcpCommands;
14
28
  }
@@ -0,0 +1,64 @@
1
+ export const workspaceMcpToolNames = [
2
+ "workspace_mcp_discover",
3
+ "workspace_mcp_call",
4
+ ] as const;
5
+ export type WorkspaceMcpToolName = typeof workspaceMcpToolNames[number];
6
+
7
+ export interface WorkspaceMcpServerBase {
8
+ description?: string;
9
+ timeout?: number;
10
+ enabled?: boolean;
11
+ }
12
+
13
+ export interface WorkspaceMcpStdioServer extends WorkspaceMcpServerBase {
14
+ command: string;
15
+ args?: string[];
16
+ env?: Record<string, string>;
17
+ cwd?: string;
18
+ }
19
+
20
+ export interface WorkspaceMcpHttpServer extends WorkspaceMcpServerBase {
21
+ url: string;
22
+ headers?: Record<string, string>;
23
+ }
24
+
25
+ export type WorkspaceMcpServer = WorkspaceMcpStdioServer | WorkspaceMcpHttpServer;
26
+
27
+ export interface WorkspaceMcpConfig {
28
+ mcpServers: Record<string, WorkspaceMcpServer>;
29
+ }
30
+
31
+ export interface WorkspaceMcpConfiguration {
32
+ path: string;
33
+ present: boolean;
34
+ servers: Record<string, WorkspaceMcpServer>;
35
+ error?: string;
36
+ }
37
+
38
+ export interface ResolvedWorkspaceMcpStdioServer {
39
+ readonly transport: "stdio";
40
+ readonly name: string;
41
+ readonly command: string;
42
+ readonly args: string[];
43
+ readonly env: Record<string, string>;
44
+ readonly cwd: string;
45
+ readonly description?: string;
46
+ readonly timeout: number;
47
+ }
48
+
49
+ export interface ResolvedWorkspaceMcpHttpServer {
50
+ readonly transport: "http";
51
+ readonly name: string;
52
+ readonly url: string;
53
+ readonly headers: Record<string, string>;
54
+ readonly description?: string;
55
+ readonly timeout: number;
56
+ }
57
+
58
+ export type ResolvedWorkspaceMcpServer = ResolvedWorkspaceMcpStdioServer | ResolvedWorkspaceMcpHttpServer;
59
+
60
+ export interface WorkspaceSkillMeta {
61
+ readonly name: string;
62
+ readonly description: string;
63
+ readonly path: string;
64
+ }
package/src/pbot.ts CHANGED
@@ -1,38 +1,87 @@
1
+ import { existsSync } from "node:fs";
2
+ import { join, resolve } from "node:path";
1
3
  import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
2
- import { PiAgents, agentDirectory } from "./integrations/pi/pi-agents.js";
3
- import { AgentBackends } from "./integrations/acp/agents.js";
4
- import { AgentService } from "./services/agents/agent-service.js";
5
- import { TeamService } from "./services/agents/team-service.js";
4
+ import { resourceRoot } from "./common/paths.js";
6
5
  import { Confirmations } from "./ui/confirmation.js";
7
6
  import { ToolRegistry, mainTools } from "./tools/register.js";
8
7
  import { Lifecycle, WorkspaceInstance } from "./extension/lifecycle.js";
9
8
  import { registerCommand } from "./extension/command.js";
10
9
  import { registerEvents } from "./extension/events.js";
11
- import { registerAgentEvents } from "./extension/agent-events.js";
10
+ import { registerHistoryEvents } from "./extension/history.js";
11
+ import { McpWorkerRuntime, defaultWorkerDirectory } from "./extension/mcp-workers.js";
12
12
  import { HistoryService } from "./services/history/history-service.js";
13
+ import { workspaceFeatures } from "./services/workspace/workspace-config.js";
14
+ import { readWorkspaceMcpConfig, resolveWorkspaceMcpServer } from "./services/workspace/workspace-mcp.js";
13
15
  import { HistoryFiles } from "./storage/history-files.js";
14
16
  import { PiHistory } from "./integrations/pi/history.js";
15
- import { sessionRef } from "./storage/agent-files.js";
17
+ import { toPiMcpConfig } from "./integrations/pi/mcp.js";
16
18
  import { acpHistorySessions } from "./storage/acp-history.js";
17
- import { join } from "node:path";
18
- import { registerHistoryEvents } from "./extension/history.js";
19
+
20
+ const mcpServerName = "pbot";
19
21
 
20
22
  export default function pbot(pi: ExtensionAPI) {
21
23
  // The explicitly loaded child entry owns the child; normal discovery never grants main privileges.
22
24
  if (process.env.PBOT_SUBAGENT_RUN_ID) return;
23
- const confirmations = new Confirmations(), registry = new ToolRegistry(pi);
24
- const lifecycle = new Lifecycle((root, configuration) => {
25
- const agents = new AgentService(root, agentDirectory(), new AgentBackends(new PiAgents(), agentDirectory(), configuration.acp));
26
- const history = new HistoryService(root, new HistoryFiles(join(root, ".pbot/history"), "pi"), new PiHistory(root, () =>
27
- agents.files.list().filter(agent => agent.workspace === root).flatMap(agent => {
28
- const file = agents.files.optional(agent.agentId, "session-ref.json", sessionRef)?.file;
29
- return file ? [file] : [];
30
- })), [new HistoryFiles(join(root, ".pbot/history"), "dsh"), new HistoryFiles(join(root, ".pbot/history"), "claude")],
31
- () => acpHistorySessions({ pi: agents.files.root }));
32
- return new WorkspaceInstance(root, agents, new TeamService(root, agents.files, agents.teamFiles), history);
33
- }, instance => registry.register(mainTools(instance.agents, instance.teams, instance.history, instance)), () => registry.hide());
25
+ const confirmations = new Confirmations();
26
+ const registry = new ToolRegistry(pi);
27
+ const mcpEntry = resolve(resourceRoot, "../lib/extension/mcp.js");
28
+ const registeredMcpServers: string[] = [];
29
+
30
+ const lifecycle = new Lifecycle(
31
+ (root, sessionId, configuration) => {
32
+ const workerDir = defaultWorkerDirectory();
33
+ const workers = new McpWorkerRuntime(workerDir, sessionId, "pi");
34
+ const history = new HistoryService(
35
+ root,
36
+ new HistoryFiles(join(root, ".pbot/history"), "pi"),
37
+ new PiHistory(root),
38
+ [new HistoryFiles(join(root, ".pbot/history"), "dsh"), new HistoryFiles(join(root, ".pbot/history"), "claude")],
39
+ () => acpHistorySessions({ mcp: workerDir }),
40
+ );
41
+ return new WorkspaceInstance(root, sessionId, history, workers, workspaceFeatures(configuration));
42
+ },
43
+ async instance => {
44
+ registry.register(mainTools(instance.history, instance));
45
+ if (existsSync(mcpEntry)) {
46
+ pi.registerMcpServer(mcpServerName, {
47
+ type: "stdio",
48
+ command: process.execPath,
49
+ args: [mcpEntry],
50
+ env: {
51
+ PBOT_HOST: "pi",
52
+ PBOT_WORKSPACE_ROOT: instance.root,
53
+ PBOT_MCP_AGENT_DIR: defaultWorkerDirectory(),
54
+ PBOT_MCP_SESSION_ID: instance.sessionId,
55
+ },
56
+ exposure: "direct",
57
+ timeout: 600,
58
+ description: "跨代理程序委派(worker_*)与工作区统一 MCP 桥接(workspace_mcp_*)",
59
+ });
60
+ registeredMcpServers.push(mcpServerName);
61
+ }
62
+ if (instance.features.mcp) {
63
+ const mcpConfig = await readWorkspaceMcpConfig(instance.root);
64
+ instance.check();
65
+ if (!mcpConfig.error) {
66
+ for (const [name, server] of Object.entries(mcpConfig.servers)) {
67
+ if (server.enabled === false) continue;
68
+ try {
69
+ const resolved = resolveWorkspaceMcpServer(instance.root, name, server);
70
+ pi.registerMcpServer(resolved.name, toPiMcpConfig(resolved));
71
+ registeredMcpServers.push(resolved.name);
72
+ } catch { /* Keep the workspace active even if one external MCP env var is unset. */ }
73
+ }
74
+ }
75
+ }
76
+ },
77
+ () => {
78
+ registry.hide();
79
+ for (const name of registeredMcpServers.splice(0)) {
80
+ pi.unregisterMcpServer(name);
81
+ }
82
+ },
83
+ );
34
84
  registerCommand(pi, lifecycle, confirmations);
35
85
  registerEvents(pi, lifecycle, confirmations);
36
- registerAgentEvents(pi, lifecycle, confirmations);
37
86
  registerHistoryEvents(pi, lifecycle);
38
87
  }
package/src/plugin.ts ADDED
@@ -0,0 +1,19 @@
1
+ import { realpathSync } from "node:fs";
2
+ import { pathToFileURL } from "node:url";
3
+ import { requireThat } from "./common/validation.js";
4
+ import { runPluginHost } from "./extension/plugin-runtime.js";
5
+ import { listPluginHosts, pluginHosts } from "./integrations/hosts/registry.js";
6
+
7
+ export async function main(args: readonly string[]): Promise<void> {
8
+ const [host, ...rest] = args;
9
+ const adapter = host ? pluginHosts.get(host) : undefined;
10
+ requireThat(adapter, `用法:node <插件目录>/lib/plugin.js <${listPluginHosts().join("|")}> hook|init|status`);
11
+ await runPluginHost(adapter, rest);
12
+ }
13
+
14
+ if (process.argv[1] && import.meta.url === pathToFileURL(realpathSync(process.argv[1])).href) {
15
+ void main(process.argv.slice(2)).catch(error => {
16
+ process.stderr.write("Personal Bot: " + (error instanceof Error ? error.message : String(error)) + "\n");
17
+ process.exitCode = 1;
18
+ });
19
+ }
@@ -1,9 +1,9 @@
1
1
  import { randomUUID } from "node:crypto";
2
2
  import { setTimeout as delay } from "node:timers/promises";
3
3
  import type { AgentDescriptor, AgentMessage } from "../../model/agent.js";
4
- import type { AcpAnswer, AcpPermission } from "../../model/acp.js";
4
+ import type { AcpAnswer, AcpElicitationAction, AcpElicitationContent, AcpPermission } from "../../model/acp.js";
5
5
  import { AgentFiles, launch } from "../../storage/agent-files.js";
6
- import { acpAnswer, acpInput, acpPermission, acpPermissionReply, acpReport } from "../../storage/acp-files.js";
6
+ import { acpAnswer, acpElicitation, acpElicitationReply, acpInput, acpPermission, acpPermissionReply, acpReport } from "../../storage/acp-files.js";
7
7
  import { AgentRun } from "./agent-run.js";
8
8
 
9
9
  export interface AcpProgress { kind: "text" | "thought" | "tool" | "activity"; text?: string; messageId?: string; activity?: string }
@@ -50,15 +50,47 @@ export class AcpAgentRun {
50
50
  }
51
51
  async permission(description: string, options: AcpPermission["options"], signal: AbortSignal): Promise<string | null> {
52
52
  const requestId = randomUUID(), request = { generation: this.generation, requestId, description, options };
53
+ this.files.ensureSubdirectory(this.id, "permissions");
53
54
  this.files.write(this.id, "permissions/" + requestId + ".json", request, acpPermission, true);
54
55
  this.execution.save({ state: "busy", activity: "等待确认" });
55
56
  while (!signal.aborted && !this.#stopping && this.current() && !this.files.read(this.id, "launch.json", launch).stop) {
56
57
  const reply = this.files.optional(this.id, "permissions/" + requestId + "-reply.json", acpPermissionReply);
57
- if (reply?.generation === this.generation) return reply.optionId;
58
+ if (reply?.generation === this.generation) {
59
+ this.execution.save({ state: this.#stopping ? "stopping" : "busy", activity: reply.optionId ? "已获确认" : "确认被拒绝" });
60
+ return reply.optionId;
61
+ }
58
62
  await delay(100);
59
63
  }
64
+ // Close the request so it no longer shows as pending once the turn or worker has ended.
65
+ if (this.current()) this.files.write(this.id, "permissions/" + requestId + "-reply.json", { generation: this.generation, requestId, optionId: null }, acpPermissionReply, true);
60
66
  return null;
61
67
  }
68
+ async elicitation(
69
+ input: { mode: "form"; message: string; schema: Record<string, unknown> } | { mode: "url"; message: string; url: string },
70
+ signal: AbortSignal,
71
+ ): Promise<{ action: AcpElicitationAction; content?: AcpElicitationContent }> {
72
+ const requestId = randomUUID();
73
+ const request = input.mode === "form"
74
+ ? { generation: this.generation, requestId, mode: "form" as const, message: input.message, schema: input.schema }
75
+ : { generation: this.generation, requestId, mode: "url" as const, message: input.message, url: input.url };
76
+ this.files.ensureSubdirectory(this.id, "elicitations");
77
+ this.files.write(this.id, "elicitations/" + requestId + ".json", request, acpElicitation, true);
78
+ this.execution.save({ state: "busy", activity: "等待回复" });
79
+ while (!signal.aborted && !this.#stopping && this.current() && !this.files.read(this.id, "launch.json", launch).stop) {
80
+ const reply = this.files.optional(this.id, "elicitations/" + requestId + "-reply.json", acpElicitationReply);
81
+ if (reply?.generation === this.generation) {
82
+ const label = reply.action === "accept" ? "已收到回复" : reply.action === "decline" ? "回复已拒绝" : "回复已取消";
83
+ this.execution.save({ state: this.#stopping ? "stopping" : "busy", activity: label });
84
+ return { action: reply.action, ...(reply.content ? { content: reply.content } : {}) };
85
+ }
86
+ await delay(100);
87
+ }
88
+ if (this.current()) {
89
+ this.files.write(this.id, "elicitations/" + requestId + "-reply.json",
90
+ { generation: this.generation, requestId, action: "cancel" }, acpElicitationReply, true);
91
+ }
92
+ return { action: "cancel" };
93
+ }
62
94
  async run() {
63
95
  this.execution.recover(); this.execution.save({ state: "idle", activity: "空闲" });
64
96
  while (!this.#stopping && this.current() && !this.work.signal.aborted) {