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,15 +1,5 @@
1
- import type { HistoryHost, HistoryIdentity, HistoryRecord, HistorySummary, RawHistory } from "../model/history.js";
2
- export declare const isHistoryHost: (value: unknown) => value is HistoryHost;
1
+ import type { HistoryIdentity, RawHistory, SummaryArtifact } from "../model/history.js";
2
+ export { isHistoryIdentifier as isHistoryHost, isHistoryIdentifier as isSummaryDimension } from "../common/validation.js";
3
3
  export declare function matchIdentity(value: HistoryIdentity, expected: HistoryIdentity): void;
4
4
  export declare function rawHistory(value: unknown): RawHistory;
5
- export interface HierarchicalHistory extends HistoryIdentity {
6
- summaries: HistorySummary[];
7
- }
8
- export declare function hierarchicalHistory(value: unknown, raw: RawHistory): HierarchicalHistory;
9
- /** Old private directories carried the host in their path. Shared records must declare it. */
10
- export declare function legacyHistory(value: unknown, host?: HistoryHost): HistoryRecord;
11
- export declare function summaryData(item: HistorySummary): HistorySummary;
12
- export declare function splitLegacy(record: HistoryRecord): {
13
- raw: RawHistory;
14
- summaries: HistorySummary[];
15
- };
5
+ export declare function summaryArtifact(value: unknown, expectedDimension?: string): SummaryArtifact;
@@ -1,15 +1,15 @@
1
1
  import { object } from "../common/json.js";
2
- import { requireThat } from "../common/validation.js";
2
+ import { isHistoryIdentifier, requireThat } from "../common/validation.js";
3
3
  import { fileId } from "./file-access.js";
4
4
  const strings = (value) => Array.isArray(value) && value.every(item => typeof item === "string");
5
5
  const fields = (value, names) => Object.keys(value).every(key => names.includes(key));
6
6
  const rawFields = ["host", "id", "sessionId", "name", "exchanges", "branches"];
7
- const hierarchyFields = ["host", "id", "sessionId", "summaries"];
8
7
  const exchangeFields = ["id", "entryIds", "text", "from", "to", "completed"];
9
- const summaryFields = [...exchangeFields, "level", "children", "ready"];
10
- export const isHistoryHost = (value) => value === "pi" || value === "dsh" || value === "claude";
8
+ const summaryArtifactFields = ["id", "dimension", "host", "sessionId", "title", "text", "from", "to", "updatedAt", "source"];
9
+ const summarySourceFields = ["rawIds", "exchangeIds", "fingerprint"];
10
+ export { isHistoryIdentifier as isHistoryHost, isHistoryIdentifier as isSummaryDimension } from "../common/validation.js";
11
11
  function identity(value) {
12
- requireThat(object(value) && isHistoryHost(value.host) && typeof value.id === "string" &&
12
+ requireThat(object(value) && isHistoryIdentifier(value.host) && typeof value.id === "string" &&
13
13
  typeof value.sessionId === "string" && value.sessionId.length > 0, "历史归档身份无效。");
14
14
  fileId(value.id);
15
15
  }
@@ -32,55 +32,29 @@ export function rawHistory(value) {
32
32
  requireThat(item.id !== value.id && !ids.has(item.id), "历史问答 ID 重复:" + item.id);
33
33
  ids.add(item.id);
34
34
  }
35
- for (const branch of value.branches)
35
+ for (const branch of value.branches) {
36
36
  requireThat(strings(branch) && new Set(branch).size === branch.length && branch.every(id => ids.has(id)), "历史分支包含重复或未知的问答 ID。");
37
- return value;
38
- }
39
- export function hierarchicalHistory(value, raw) {
40
- identity(value);
41
- matchIdentity(value, raw);
42
- requireThat(object(value) && fields(value, hierarchyFields) && Array.isArray(value.summaries), "历史摘要归档无效。");
43
- const levels = new Map(raw.exchanges.map(item => [item.id, 0]));
44
- for (const item of value.summaries) {
45
- requireThat(object(item) && exchange(item) && fields(item, summaryFields) && item.entryIds.length > 0 &&
46
- typeof item.level === "number" && Number.isSafeInteger(item.level) && item.level > 0 && strings(item.children) && typeof item.ready === "boolean", "历史摘要节点无效。");
47
- requireThat(item.id !== raw.id && !levels.has(item.id), "历史摘要 ID 重复:" + item.id);
48
- levels.set(item.id, item.level);
49
37
  }
50
- const result = value;
51
- for (const item of result.summaries)
52
- requireThat(item.children.length > 0 && new Set(item.children).size === item.children.length &&
53
- item.children.every(id => levels.get(id) === item.level - 1), "历史摘要子节点缺失、重复或层级不匹配:" + item.id);
54
- return result;
38
+ return value;
55
39
  }
56
- /** Old private directories carried the host in their path. Shared records must declare it. */
57
- export function legacyHistory(value, host) {
58
- if (host !== undefined) {
59
- requireThat(object(value) && (value.host === undefined || value.host === host), "旧历史归档与来源目录不匹配。");
60
- value = { ...value, host };
40
+ export function summaryArtifact(value, expectedDimension) {
41
+ requireThat(object(value) && fields(value, summaryArtifactFields), "历史摘要产物格式无效。");
42
+ requireThat(typeof value.id === "string" && value.id.length > 0, "历史摘要 ID 无效。");
43
+ fileId(value.id);
44
+ requireThat(isHistoryIdentifier(value.dimension), "历史摘要维度无效。");
45
+ if (expectedDimension !== undefined) {
46
+ requireThat(value.dimension === expectedDimension, `历史摘要维度不匹配,预期 ${expectedDimension},实际 ${value.dimension}。`);
61
47
  }
62
- identity(value);
63
- requireThat(object(value) && typeof value.name === "string" && Array.isArray(value.nodes) &&
64
- !("exchanges" in value) && !("branches" in value) && !("summaries" in value), "旧历史归档无效。");
65
- for (const node of value.nodes)
66
- requireThat(object(node) && exchange(node) &&
67
- (node.kind === "session" || node.kind === "exchange" || node.kind === "summary") && Number.isInteger(node.level) &&
68
- strings(node.parents) && strings(node.children) && typeof node.ready === "boolean", "旧历史节点无效。");
69
- const result = value, ids = new Set(result.nodes.map(node => node.id));
70
- const roots = result.nodes.filter(node => node.kind === "session");
71
- requireThat(ids.size === result.nodes.length && roots.length === 1 && roots[0].id === result.id &&
72
- result.nodes.every(node => [...node.parents, ...node.children].every(id => ids.has(id))), "旧历史节点关系无效。");
73
- return result;
74
- }
75
- function exchangeData({ id, entryIds, text, from, to, completed }) {
76
- return { id, entryIds, text, from, to, completed };
77
- }
78
- export function summaryData(item) {
79
- return { ...exchangeData(item), level: item.level, children: item.children, ready: item.ready };
80
- }
81
- export function splitLegacy(record) {
82
- const { host, id, sessionId, name } = record;
83
- const raw = rawHistory({ host, id, sessionId, name, exchanges: record.nodes.filter(node => node.kind === "exchange").map(exchangeData), branches: [] });
84
- const summaries = record.nodes.filter(node => node.kind === "summary").map(summaryData);
85
- return { raw, summaries: hierarchicalHistory({ host, id, sessionId, summaries }, raw).summaries };
48
+ if (value.host !== undefined)
49
+ requireThat(isHistoryIdentifier(value.host), "历史摘要来源 host 无效。");
50
+ if (value.sessionId !== undefined)
51
+ requireThat(typeof value.sessionId === "string" && value.sessionId.length > 0, "历史摘要 sessionId 无效。");
52
+ requireThat(typeof value.title === "string" && typeof value.text === "string" && value.text.trim().length > 0 &&
53
+ typeof value.from === "string" && typeof value.to === "string" && typeof value.updatedAt === "string", "历史摘要正文或时间字段无效。");
54
+ const source = value.source;
55
+ requireThat(object(source) && fields(source, summarySourceFields) &&
56
+ strings(source.rawIds) && source.rawIds.length > 0 &&
57
+ strings(source.exchangeIds) &&
58
+ typeof source.fingerprint === "string" && source.fingerprint.length > 0, "历史摘要来源指纹无效。");
59
+ return value;
86
60
  }
@@ -1,70 +1,5 @@
1
- import type { HistoryLocation } from "../../model/history.js";
2
- import type { HistoryService } from "../../services/history/history-service.js";
3
1
  import type { HistoryInput } from "./contract.js";
4
- export declare function executeHistory(service: HistoryService, args: HistoryInput, location: HistoryLocation, signal?: AbortSignal): Promise<{
5
- matches: {
6
- parents: string[];
7
- snippet: string;
8
- host: import("../../model/history.js").HistoryHost;
9
- id: string;
10
- kind: "session" | "exchange" | "summary";
11
- sessionId: string;
12
- name: string;
13
- preview: string;
14
- from: string;
15
- to: string;
16
- ready: boolean;
17
- completed: boolean;
18
- }[];
19
- total: number;
20
- nextOffset: number | null;
2
+ export declare function executeHistory(root: string, args: HistoryInput, signal?: AbortSignal): import("../../services/history/history-query.js").HistorySearchResult | {
3
+ node: import("../../services/history/history-query.js").HistoryReadNode;
21
4
  warnings: string[];
22
- } | {
23
- node: {
24
- text: string;
25
- totalLength: number;
26
- nextOffset: number | null;
27
- parents: {
28
- host: import("../../model/history.js").HistoryHost;
29
- id: string;
30
- kind: "session" | "exchange" | "summary";
31
- sessionId: string;
32
- name: string;
33
- preview: string;
34
- from: string;
35
- to: string;
36
- ready: boolean;
37
- completed: boolean;
38
- }[];
39
- children: {
40
- host: import("../../model/history.js").HistoryHost;
41
- id: string;
42
- kind: "session" | "exchange" | "summary";
43
- sessionId: string;
44
- name: string;
45
- preview: string;
46
- from: string;
47
- to: string;
48
- ready: boolean;
49
- completed: boolean;
50
- }[];
51
- nextChildrenOffset: number | null;
52
- source: {
53
- host: import("../../model/history.js").HistoryHost;
54
- sessionId: string;
55
- entryIds: string[];
56
- };
57
- warnings: string[];
58
- host: import("../../model/history.js").HistoryHost;
59
- id: string;
60
- kind: "session" | "exchange" | "summary";
61
- sessionId: string;
62
- name: string;
63
- preview: string;
64
- from: string;
65
- to: string;
66
- ready: boolean;
67
- completed: boolean;
68
- };
69
- warnings: string[];
70
- }>;
5
+ };
@@ -1,7 +1,9 @@
1
- export async function executeHistory(service, args, location, signal) {
1
+ import { readWorkspaceHistory, searchWorkspaceHistory } from "../../services/history/history-query.js";
2
+ export function executeHistory(root, args, signal) {
2
3
  signal?.throwIfAborted();
3
- await service.refresh(location, signal);
4
- signal?.throwIfAborted();
5
- return args.action === "search" ? service.search(args) :
6
- { node: service.read(args.id, args.offset, args.limit, args.childrenOffset, args.host), warnings: service.warnings };
4
+ if (args.action === "search") {
5
+ return searchWorkspaceHistory(root, args);
6
+ }
7
+ const node = readWorkspaceHistory(root, args.id, args.offset, args.limit, args.childrenOffset, args.host);
8
+ return { node, warnings: node.warnings };
7
9
  }
@@ -1,12 +1,13 @@
1
1
  import { Type } from "typebox";
2
- import type { HistoryHost } from "../../model/history.js";
2
+ import { type HistoryHost, type HistoryQuery } from "../../model/history.js";
3
3
  export declare const historyResultSchema: Type.TObject<{
4
4
  matches: Type.TOptional<Type.TArray<Type.TObject<{
5
5
  snippet: Type.TString;
6
6
  parents: Type.TArray<Type.TString>;
7
- host: Type.TUnion<[Type.TLiteral<"pi">, Type.TLiteral<"dsh">, Type.TLiteral<"claude">]>;
7
+ host: Type.TString;
8
8
  id: Type.TString;
9
9
  kind: Type.TUnion<[Type.TLiteral<"session">, Type.TLiteral<"exchange">, Type.TLiteral<"summary">]>;
10
+ dimension: Type.TOptional<Type.TString>;
10
11
  sessionId: Type.TString;
11
12
  name: Type.TString;
12
13
  preview: Type.TString;
@@ -22,9 +23,10 @@ export declare const historyResultSchema: Type.TObject<{
22
23
  totalLength: Type.TInteger;
23
24
  nextOffset: Type.TUnion<[Type.TInteger, Type.TNull]>;
24
25
  parents: Type.TArray<Type.TObject<{
25
- host: Type.TUnion<[Type.TLiteral<"pi">, Type.TLiteral<"dsh">, Type.TLiteral<"claude">]>;
26
+ host: Type.TString;
26
27
  id: Type.TString;
27
28
  kind: Type.TUnion<[Type.TLiteral<"session">, Type.TLiteral<"exchange">, Type.TLiteral<"summary">]>;
29
+ dimension: Type.TOptional<Type.TString>;
28
30
  sessionId: Type.TString;
29
31
  name: Type.TString;
30
32
  preview: Type.TString;
@@ -34,9 +36,10 @@ export declare const historyResultSchema: Type.TObject<{
34
36
  completed: Type.TBoolean;
35
37
  }>>;
36
38
  children: Type.TArray<Type.TObject<{
37
- host: Type.TUnion<[Type.TLiteral<"pi">, Type.TLiteral<"dsh">, Type.TLiteral<"claude">]>;
39
+ host: Type.TString;
38
40
  id: Type.TString;
39
41
  kind: Type.TUnion<[Type.TLiteral<"session">, Type.TLiteral<"exchange">, Type.TLiteral<"summary">]>;
42
+ dimension: Type.TOptional<Type.TString>;
40
43
  sessionId: Type.TString;
41
44
  name: Type.TString;
42
45
  preview: Type.TString;
@@ -47,14 +50,16 @@ export declare const historyResultSchema: Type.TObject<{
47
50
  }>>;
48
51
  nextChildrenOffset: Type.TUnion<[Type.TInteger, Type.TNull]>;
49
52
  source: Type.TObject<{
50
- host: Type.TUnion<[Type.TLiteral<"pi">, Type.TLiteral<"dsh">, Type.TLiteral<"claude">]>;
53
+ host: Type.TString;
51
54
  sessionId: Type.TString;
52
55
  entryIds: Type.TArray<Type.TString>;
56
+ dimension: Type.TOptional<Type.TString>;
53
57
  }>;
54
58
  warnings: Type.TArray<Type.TString>;
55
- host: Type.TUnion<[Type.TLiteral<"pi">, Type.TLiteral<"dsh">, Type.TLiteral<"claude">]>;
59
+ host: Type.TString;
56
60
  id: Type.TString;
57
61
  kind: Type.TUnion<[Type.TLiteral<"session">, Type.TLiteral<"exchange">, Type.TLiteral<"summary">]>;
62
+ dimension: Type.TOptional<Type.TString>;
58
63
  sessionId: Type.TString;
59
64
  name: Type.TString;
60
65
  preview: Type.TString;
@@ -65,10 +70,11 @@ export declare const historyResultSchema: Type.TObject<{
65
70
  }>>;
66
71
  warnings: Type.TArray<Type.TString>;
67
72
  }>;
68
- export declare const historyDescription = "\u67E5\u8BE2\u5F53\u524D\u5DE5\u4F5C\u533A\u7684\u5386\u53F2\u95EE\u7B54\u4E0E\u5F52\u6863\uFF0Chost \u53EF\u7B5B\u9009\u6765\u6E90\uFF08pi/dsh/claude\uFF09\u3002search \u6309\u4E0D\u533A\u5206\u5927\u5C0F\u5199\u7684\u8FDE\u7EED\u5173\u952E\u8BCD\u5339\u914D\u539F\u6587\u548C\u6458\u8981\uFF0C\u7701\u7565 query \u5217\u51FA\u5404\u4F1A\u8BDD\uFF1B\u65E0\u5339\u914D\u65F6\u6362\u8BCD\u3002read \u6309\u8282\u70B9 id \u5C55\u5F00\u6B63\u6587\u4E0E\u4E0A\u4E0B\u7EA7\uFF0CnextOffset \u7EED\u8BFB\u6B63\u6587\uFF0CnextChildrenOffset \u7EED\u8BFB\u5B50\u8282\u70B9\uFF1B\u9700\u8981\u7EC6\u8282\u65F6\u8BFB\u53D6 exchange \u539F\u6587\u3002\u5F52\u6863\u4E0D\u542B\u5DE5\u5177\u8C03\u7528\u65E5\u5FD7\u3002";
73
+ export declare const historyDescription: string;
69
74
  export declare const historyParameters: Type.TObject<{
70
75
  action: Type.TUnion<[Type.TLiteral<"search">, Type.TLiteral<"read">]>;
71
- host: Type.TOptional<Type.TUnion<[Type.TUnion<[Type.TLiteral<"pi">, Type.TLiteral<"dsh">, Type.TLiteral<"claude">]>, Type.TNull]>>;
76
+ host: Type.TOptional<Type.TUnion<[Type.TString, Type.TNull]>>;
77
+ dimension: Type.TOptional<Type.TUnion<[Type.TString, Type.TNull]>>;
72
78
  query: Type.TOptional<Type.TUnion<[Type.TString, Type.TNull]>>;
73
79
  sessionId: Type.TOptional<Type.TUnion<[Type.TString, Type.TNull]>>;
74
80
  from: Type.TOptional<Type.TUnion<[Type.TString, Type.TNull]>>;
@@ -78,16 +84,9 @@ export declare const historyParameters: Type.TObject<{
78
84
  limit: Type.TOptional<Type.TUnion<[Type.TInteger, Type.TNull]>>;
79
85
  childrenOffset: Type.TOptional<Type.TUnion<[Type.TInteger, Type.TNull]>>;
80
86
  }>;
81
- export type HistoryInput = {
87
+ export type HistoryInput = ({
82
88
  action: "search";
83
- host?: HistoryHost;
84
- query?: string;
85
- sessionId?: string;
86
- from?: string;
87
- to?: string;
88
- offset?: number;
89
- limit?: number;
90
- } | {
89
+ } & HistoryQuery) | {
91
90
  action: "read";
92
91
  id: string;
93
92
  host?: HistoryHost;
@@ -1,45 +1,86 @@
1
1
  import { Type } from "../../common/typebox.js";
2
- import { requireThat } from "../../common/validation.js";
2
+ import { historyPageLimits } from "../../model/history.js";
3
+ import { historyIdentifierPattern, requireThat } from "../../common/validation.js";
3
4
  import { schema } from "../../common/schema.js";
4
5
  import { inputObject, need, nullable, pick } from "../input.js";
5
- const host = Type.Union([Type.Literal("pi"), Type.Literal("dsh"), Type.Literal("claude")]);
6
+ const identifier = Type.String({ pattern: historyIdentifierPattern.source });
6
7
  const nullableOffset = Type.Union([Type.Integer(), Type.Null()]);
7
- const node = Type.Object({ host, id: Type.String(),
8
- kind: Type.Union([Type.Literal("session"), Type.Literal("exchange"), Type.Literal("summary")], { description: "session=会话根;summary=摘要;exchange=单轮问答原文。" }),
9
- sessionId: Type.String(), name: Type.String(), preview: Type.String(), from: Type.String(), to: Type.String(),
8
+ const node = Type.Object({
9
+ host: identifier,
10
+ id: Type.String(),
11
+ kind: Type.Union([Type.Literal("session"), Type.Literal("exchange"), Type.Literal("summary")], {
12
+ description: "session=会话根;summary=维度摘要;exchange=单轮问答原文。",
13
+ }),
14
+ dimension: Type.Optional(identifier),
15
+ sessionId: Type.String(),
16
+ name: Type.String(),
17
+ preview: Type.String(),
18
+ from: Type.String(),
19
+ to: Type.String(),
10
20
  ready: Type.Boolean({ description: "正文或摘要是否已生成。" }),
11
- completed: Type.Boolean({ description: "该对话或问答是否正常结束(false 表示中断或未完)。" }) });
21
+ completed: Type.Boolean({ description: "该对话或问答是否正常结束(false 表示中断或未完)。" }),
22
+ });
12
23
  export const historyResultSchema = Type.Object({
13
- matches: Type.Optional(Type.Array(Type.Object({ ...node.properties, snippet: Type.String(), parents: Type.Array(Type.String()) }))),
14
- total: Type.Optional(Type.Integer()), nextOffset: Type.Optional(nullableOffset),
15
- node: Type.Optional(Type.Object({ ...node.properties, text: Type.String(), totalLength: Type.Integer(), nextOffset: nullableOffset,
16
- parents: Type.Array(node), children: Type.Array(node), nextChildrenOffset: nullableOffset,
17
- source: Type.Object({ host, sessionId: Type.String({ description: "原始宿主会话 ID。" }), entryIds: Type.Array(Type.String()) }), warnings: Type.Array(Type.String()) })),
24
+ matches: Type.Optional(Type.Array(Type.Object({
25
+ ...node.properties,
26
+ snippet: Type.String(),
27
+ parents: Type.Array(Type.String()),
28
+ }))),
29
+ total: Type.Optional(Type.Integer()),
30
+ nextOffset: Type.Optional(nullableOffset),
31
+ node: Type.Optional(Type.Object({
32
+ ...node.properties,
33
+ text: Type.String(),
34
+ totalLength: Type.Integer(),
35
+ nextOffset: nullableOffset,
36
+ parents: Type.Array(node),
37
+ children: Type.Array(node),
38
+ nextChildrenOffset: nullableOffset,
39
+ source: Type.Object({
40
+ host: identifier,
41
+ sessionId: Type.String({ description: "原始宿主会话 ID。" }),
42
+ entryIds: Type.Array(Type.String()),
43
+ dimension: Type.Optional(identifier),
44
+ }),
45
+ warnings: Type.Array(Type.String()),
46
+ })),
18
47
  warnings: Type.Array(Type.String()),
19
48
  });
20
- export const historyDescription = "查询当前工作区的历史问答与归档,host 可筛选来源(pi/dsh/claude)。search 按不区分大小写的连续关键词匹配原文和摘要,省略 query 列出各会话;无匹配时换词。read 按节点 id 展开正文与上下级,nextOffset 续读正文,nextChildrenOffset 续读子节点;需要细节时读取 exchange 原文。归档不含工具调用日志。";
49
+ export const historyDescription = "查询当前工作区的历史问答与各维度摘要,host 可筛选来源(如 pi、dsh、claude、antigravity),dimension 可筛选 raw 原文或特定摘要维度(如 monthly 月度汇总、session 会话摘要)。" +
50
+ "search 按不区分大小写的连续关键词匹配原文和摘要,省略 query 列出各会话或指定维度摘要;无匹配时换词。" +
51
+ "read 按节点 id 展开正文与上下级(可从 monthly 下钻至 session 摘要,再下钻至 exchange 原文),nextOffset 续读正文,nextChildrenOffset 续读子节点。归档不含工具调用日志。";
21
52
  export const historyParameters = Type.Object({
22
- action: Type.Union([Type.Literal("search"), Type.Literal("read")], { description: "search 搜索或列会话;read 读取指定节点正文与上下级。各动作仅读取自身字段,其余字段忽略。" }),
23
- host: nullable(Type.Union([Type.Literal("pi"), Type.Literal("dsh"), Type.Literal("claude")], { description: "可选来源筛选:pi、dsh 或 claude。" })),
24
- query: nullable(Type.String({ description: "仅 search:不区分大小写的连续关键词;省略时列出各会话。" })),
53
+ action: Type.Union([Type.Literal("search"), Type.Literal("read")], {
54
+ description: "search 搜索或列会话;read 读取指定节点正文与上下级。各动作仅读取自身字段,其余字段忽略。",
55
+ }),
56
+ host: nullable(Type.String({ pattern: historyIdentifierPattern.source, description: "可选来源筛选(如 pi、dsh、claude、antigravity)。" })),
57
+ dimension: nullable(Type.String({ pattern: historyIdentifierPattern.source, description: "仅 search:可选范围筛选(raw 表示仅原文,或指定摘要维度如 monthly、session;省略查全部)。" })),
58
+ query: nullable(Type.String({ description: "仅 search:不区分大小写的连续关键词;省略时列出各会话(或指定维度摘要)。" })),
25
59
  sessionId: nullable(Type.String({ description: "仅 search:限定在指定会话 ID 内搜索。" })),
26
60
  from: nullable(Type.String({ description: "仅 search:ISO 日期或时间下界。" })),
27
61
  to: nullable(Type.String({ description: "仅 search:ISO 日期或时间上界。" })),
28
62
  id: nullable(Type.String({ description: "仅 read,必填:search 或上下级返回的节点 id。" })),
29
63
  offset: nullable(Type.Integer({ minimum: 0, description: "search:匹配结果偏移;read:正文字符偏移。默认 0。" })),
30
- limit: nullable(Type.Integer({ minimum: 1, maximum: 24000, description: "search:最多返回条数(默认 20,上限 50);read:正文字符数(默认 12000)。" })),
64
+ limit: nullable(Type.Integer({ minimum: 1, maximum: historyPageLimits.read.max, description: `search:最多返回条数(默认 ${historyPageLimits.search.default},上限 ${historyPageLimits.search.max});read:正文字符数(默认 ${historyPageLimits.read.default})。` })),
31
65
  childrenOffset: nullable(Type.Integer({ minimum: 0, description: "仅 read:子节点列表偏移,默认 0;续读传上页 nextChildrenOffset。" })),
32
66
  }, { additionalProperties: false });
33
67
  const valid = schema(historyParameters);
34
68
  export function historyInput(value) {
35
69
  const args = inputObject(value, valid, "历史参数格式无效");
36
70
  if (args.action === "search") {
37
- const limit = args.limit === undefined ? 20 : args.limit;
38
- requireThat(limit <= 50, "search 的 limit 最多 50。");
39
- return { action: "search", ...pick(args, ["host", "query", "sessionId", "from", "to", "offset", "limit"]) };
71
+ const limit = args.limit === undefined ? historyPageLimits.search.default : args.limit;
72
+ requireThat(limit <= historyPageLimits.search.max, `search 的 limit 最多 ${historyPageLimits.search.max}。`);
73
+ return {
74
+ action: "search",
75
+ ...pick(args, ["host", "dimension", "query", "sessionId", "from", "to", "offset", "limit"]),
76
+ };
77
+ }
78
+ if (args.action === "read") {
79
+ return {
80
+ action: "read",
81
+ id: need("read", args, "id"),
82
+ ...pick(args, ["host", "offset", "limit", "childrenOffset"]),
83
+ };
40
84
  }
41
- if (args.action === "read")
42
- return { action: "read", id: need("read", args, "id"),
43
- ...pick(args, ["host", "offset", "limit", "childrenOffset"]) };
44
85
  throw new Error("未知的历史 action。");
45
86
  }
@@ -1,4 +1,3 @@
1
1
  import type { Context } from "@deepseek-ai/cordis";
2
2
  import type { Agent } from "@deepseek-ai/dsh-agent";
3
- import type { HistoryService } from "../../services/history/history-service.js";
4
- export declare function registerDshHistoryTool(ctx: Context, agent: Agent, service: HistoryService, lifetime: AbortSignal, check: () => void): void;
3
+ export declare function registerDshHistoryTool(ctx: Context, agent: Agent, root: string, lifetime: AbortSignal, check: () => void): void;
@@ -1,19 +1,25 @@
1
- import { dshParameters, dshOutputSchema } from "../../integrations/dsh/schema.js";
1
+ import { dshParameters, dshOutputSchema } from "../../integrations/hosts/dsh/schema.js";
2
2
  import { requireThat } from "../../common/validation.js";
3
3
  import { schema } from "../../common/schema.js";
4
4
  import { json } from "../../common/json.js";
5
5
  import { markdownFields } from "../../common/markdown.js";
6
6
  import { historyDescription, historyInput, historyParameters, historyResultSchema } from "./contract.js";
7
7
  import { executeHistory } from "./actions.js";
8
- export function registerDshHistoryTool(ctx, agent, service, lifetime, check) {
8
+ export function registerDshHistoryTool(ctx, agent, root, lifetime, check) {
9
9
  const valid = schema(historyResultSchema);
10
- ctx.tools.register({ name: "pbot_history", description: historyDescription, parameters: dshParameters(historyParameters),
11
- output: { schema: dshOutputSchema(historyResultSchema), render: (_args, value) => [{ type: "text", text: "# 历史\n\n" + markdownFields(value) }] },
10
+ ctx.tools.register({
11
+ name: "pbot_history",
12
+ description: historyDescription,
13
+ parameters: dshParameters(historyParameters),
14
+ output: {
15
+ schema: dshOutputSchema(historyResultSchema),
16
+ render: (_args, value) => [{ type: "text", text: "# 历史\n\n" + markdownFields(value) }],
17
+ },
12
18
  async execute(value, exec) {
13
19
  check();
14
20
  requireThat(exec.agent === agent, "历史工具不属于当前会话。");
15
21
  const signal = AbortSignal.any([exec.signal, lifetime]);
16
- const result = await executeHistory(service, historyInput(value), { host: "dsh", sessionId: agent.id }, signal);
22
+ const result = executeHistory(root, historyInput(value), signal);
17
23
  check();
18
24
  signal.throwIfAborted();
19
25
  requireThat(valid(result), "历史输出不符合契约。");
@@ -1,17 +1,14 @@
1
1
  export declare const record: (value: unknown) => Record<string, unknown>;
2
2
  export declare const rows: (value: unknown) => Record<string, unknown>[];
3
3
  export declare const text: (value: unknown) => string;
4
- export declare const objectInput: (value: string) => Record<string, unknown>;
5
- export declare const lines: (value: string) => string[];
6
4
  export declare function element<K extends keyof HTMLElementTagNameMap>(tag: K, content?: string, className?: string): HTMLElementTagNameMap[K];
7
5
  export declare function block(value: unknown): HTMLPreElement;
8
6
  export declare function note(value: string): HTMLParagraphElement;
9
7
  export declare function group(parent: HTMLElement, className?: string): HTMLDivElement;
10
8
  export declare function details(parent: HTMLElement, title: string): HTMLDetailsElement;
11
- export declare function field(parent: HTMLElement, label: string, multiline?: boolean, value?: string): HTMLInputElement | HTMLTextAreaElement;
9
+ export declare function field(parent: HTMLElement, label: string): HTMLInputElement;
12
10
  export declare function select(parent: HTMLElement, label: string, values: [string, string][]): HTMLSelectElement;
13
- export declare function badge(state: unknown): HTMLSpanElement;
14
11
  export declare function facts(values: [string, unknown][]): HTMLDListElement;
15
12
  export declare function empty(title: string, description: string): HTMLDivElement;
16
- export declare function pageTitle(parent: HTMLElement, title: string, description: string): HTMLElement;
13
+ export declare function pageTitle(parent: HTMLElement, title: string): HTMLElement;
17
14
  export declare function time(value: unknown): string;
@@ -1,11 +1,8 @@
1
1
  import { object } from "../../common/json.js";
2
- import { stateLabel } from "../presentation.js";
3
2
  export const record = (value) => { if (!object(value))
4
3
  throw new Error("管理数据无效。"); return value; };
5
4
  export const rows = (value) => Array.isArray(value) ? value.map(record) : [];
6
5
  export const text = (value) => value === null || value === undefined ? "" : String(value);
7
- export const objectInput = (value) => record(JSON.parse(value || "{}"));
8
- export const lines = (value) => value.split(/\r?\n/).map(item => item.trim()).filter(Boolean);
9
6
  export function element(tag, content = "", className = "") {
10
7
  const node = document.createElement(tag);
11
8
  node.textContent = content;
@@ -25,13 +22,10 @@ export function details(parent, title) {
25
22
  parent.append(node);
26
23
  return node;
27
24
  }
28
- export function field(parent, label, multiline = false, value = "") {
29
- const wrapper = element("label", "", "pbot-field"), input = multiline ? element("textarea") : element("input");
25
+ export function field(parent, label) {
26
+ const wrapper = element("label", "", "pbot-field"), input = element("input");
30
27
  wrapper.append(element("span", label));
31
- input.value = value;
32
28
  input.setAttribute("aria-label", label);
33
- if (input instanceof HTMLTextAreaElement)
34
- input.rows = 3;
35
29
  wrapper.append(input);
36
30
  parent.append(wrapper);
37
31
  return input;
@@ -49,11 +43,6 @@ export function select(parent, label, values) {
49
43
  parent.append(wrapper);
50
44
  return input;
51
45
  }
52
- export function badge(state) {
53
- const node = element("span", stateLabel(state), "pbot-badge");
54
- node.dataset.state = text(state);
55
- return node;
56
- }
57
46
  export function facts(values) {
58
47
  const node = element("dl", "", "pbot-facts");
59
48
  for (const [label, value] of values)
@@ -65,11 +54,9 @@ export function empty(title, description) {
65
54
  node.append(element("h3", title), note(description));
66
55
  return node;
67
56
  }
68
- export function pageTitle(parent, title, description) {
57
+ export function pageTitle(parent, title) {
69
58
  const node = element("header", "", "pbot-page-title");
70
59
  node.append(element("h2", title));
71
- if (description)
72
- node.append(note(description));
73
60
  parent.append(node);
74
61
  return node;
75
62
  }