personal-bot 0.3.0 → 0.3.2

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 (256) hide show
  1. package/.claude-plugin/marketplace.json +2 -2
  2. package/.claude-plugin/plugin.json +1 -1
  3. package/README.md +1 -1
  4. package/README.zh-CN.md +1 -1
  5. package/bin/pbot-pi-acp.mjs +27 -11
  6. package/bin/pbot.mjs +1 -1
  7. package/docs/README.md +1 -1
  8. package/docs/architecture/design.md +23 -10
  9. package/docs/architecture/extensibility.md +20 -18
  10. package/docs/architecture/model-context.md +2 -2
  11. package/docs/architecture/principles.md +4 -3
  12. package/docs/guides/capabilities.md +3 -3
  13. package/docs/guides/history.md +50 -16
  14. package/docs/guides/workspace-configuration.md +31 -6
  15. package/docs/hosts/antigravity.md +2 -0
  16. package/docs/hosts/claude-code.md +1 -1
  17. package/docs/hosts/dsh.md +1 -1
  18. package/docs/hosts/pi.md +1 -1
  19. package/hooks/hooks.json +3 -0
  20. package/lib/antigravity-plugin/hooks.json +7 -0
  21. package/lib/antigravity-plugin/lib/claude.js +2 -2
  22. package/lib/antigravity-plugin/lib/extension/acp-worker.js +156 -11
  23. package/lib/antigravity-plugin/lib/extension/{plugin-runtime.d.ts → hosts/plugin-runtime.d.ts} +2 -2
  24. package/lib/antigravity-plugin/lib/extension/{plugin-runtime.js → hosts/plugin-runtime.js} +34 -8
  25. package/lib/antigravity-plugin/lib/extension/mcp.js +1113 -78
  26. package/lib/antigravity-plugin/lib/integrations/agent-resources.d.ts +1 -0
  27. package/lib/antigravity-plugin/lib/integrations/agent-resources.js +5 -1
  28. package/lib/antigravity-plugin/lib/integrations/hosts/antigravity/adapter.d.ts +6 -0
  29. package/lib/antigravity-plugin/lib/integrations/hosts/antigravity/adapter.js +171 -0
  30. package/lib/antigravity-plugin/lib/integrations/hosts/{claude.d.ts → claude/adapter.d.ts} +1 -1
  31. package/lib/antigravity-plugin/lib/integrations/hosts/{claude.js → claude/adapter.js} +32 -4
  32. package/lib/antigravity-plugin/lib/integrations/hosts/{registry.js → plugin-registry.js} +2 -2
  33. package/lib/antigravity-plugin/lib/model/history.d.ts +169 -0
  34. package/lib/antigravity-plugin/lib/model/plugin-host.d.ts +26 -0
  35. package/lib/antigravity-plugin/lib/model/workspace-config.d.ts +25 -0
  36. package/lib/antigravity-plugin/lib/plugin.js +2 -2
  37. package/lib/antigravity-plugin/lib/services/history/history-capture.d.ts +4 -0
  38. package/lib/antigravity-plugin/lib/services/history/history-capture.js +86 -0
  39. package/lib/antigravity-plugin/lib/services/history/history-index.d.ts +17 -0
  40. package/lib/antigravity-plugin/lib/services/history/history-index.js +112 -0
  41. package/lib/antigravity-plugin/lib/services/history/history-migrate.d.ts +12 -0
  42. package/lib/antigravity-plugin/lib/services/history/history-migrate.js +88 -0
  43. package/lib/antigravity-plugin/lib/services/history/summary-dimensions/monthly.d.ts +7 -0
  44. package/lib/antigravity-plugin/lib/services/history/summary-dimensions/monthly.js +121 -0
  45. package/lib/antigravity-plugin/lib/services/history/summary-dimensions/session.d.ts +7 -0
  46. package/lib/antigravity-plugin/lib/services/history/summary-dimensions/session.js +124 -0
  47. package/lib/antigravity-plugin/lib/services/history/summary-registry.d.ts +7 -0
  48. package/lib/antigravity-plugin/lib/services/history/summary-registry.js +36 -0
  49. package/lib/antigravity-plugin/lib/services/history/summary-runner.d.ts +37 -0
  50. package/lib/antigravity-plugin/lib/services/history/summary-runner.js +301 -0
  51. package/lib/antigravity-plugin/lib/services/workspace/workspace-config.d.ts +5 -1
  52. package/lib/antigravity-plugin/lib/services/workspace/workspace-config.js +75 -4
  53. package/lib/antigravity-plugin/lib/storage/file-access.d.ts +2 -0
  54. package/lib/antigravity-plugin/lib/storage/file-access.js +26 -0
  55. package/lib/antigravity-plugin/lib/storage/history-files.d.ts +54 -0
  56. package/lib/antigravity-plugin/lib/storage/history-files.js +467 -0
  57. package/lib/antigravity-plugin/lib/storage/history-format.d.ts +6 -0
  58. package/lib/antigravity-plugin/lib/storage/history-format.js +62 -0
  59. package/lib/antigravity-plugin/package.json +1 -1
  60. package/lib/antigravity-plugin/plugin.json +1 -1
  61. package/lib/antigravity-plugin/skills/provider-connections/SKILL.md +22 -12
  62. package/lib/claude.js +2 -2
  63. package/lib/client.js +21 -11
  64. package/lib/dsh.js +4 -4
  65. package/lib/extension/{acp-member.d.ts → acp/member.d.ts} +5 -5
  66. package/lib/extension/{acp-member.js → acp/member.js} +6 -6
  67. package/lib/extension/acp/worker.d.ts +1 -0
  68. package/lib/extension/acp/worker.js +384 -0
  69. package/lib/extension/acp-worker.js +156 -11
  70. package/lib/extension/{dsh → hosts/dsh}/acp-member.js +8 -8
  71. package/lib/extension/hosts/dsh/command.js +92 -0
  72. package/lib/extension/{dsh → hosts/dsh}/files.js +3 -3
  73. package/lib/extension/hosts/dsh/history.d.ts +4 -0
  74. package/lib/extension/hosts/dsh/history.js +62 -0
  75. package/lib/extension/{dsh → hosts/dsh}/management.d.ts +1 -1
  76. package/lib/extension/{dsh → hosts/dsh}/management.js +12 -10
  77. package/lib/extension/{dsh → hosts/dsh}/workspace.d.ts +3 -9
  78. package/lib/extension/{dsh → hosts/dsh}/workspace.js +32 -70
  79. package/lib/extension/{plugin-runtime.d.ts → hosts/plugin-runtime.d.ts} +2 -2
  80. package/lib/extension/{plugin-runtime.js → hosts/plugin-runtime.js} +34 -8
  81. package/lib/extension/{mcp-bridge.d.ts → mcp/bridge.d.ts} +1 -1
  82. package/lib/extension/{mcp-bridge.js → mcp/bridge.js} +4 -4
  83. package/lib/extension/{mcp-workers.d.ts → mcp/workers.d.ts} +222 -2
  84. package/lib/extension/{mcp-workers.js → mcp/workers.js} +229 -63
  85. package/lib/extension/mcp.js +1113 -78
  86. package/lib/extension/{setup-cli.js → setup/cli.js} +9 -9
  87. package/lib/integrations/acp/connection.d.ts +11 -10
  88. package/lib/integrations/acp/connection.js +6 -0
  89. package/lib/integrations/acp/harnesses/claude.js +1 -1
  90. package/lib/integrations/acp/harnesses/dsh.js +1 -1
  91. package/lib/integrations/acp/history-summary.d.ts +17 -0
  92. package/lib/integrations/acp/history-summary.js +100 -0
  93. package/lib/integrations/agent-resources.d.ts +1 -0
  94. package/lib/integrations/agent-resources.js +5 -1
  95. package/lib/integrations/hosts/antigravity/adapter.d.ts +6 -0
  96. package/lib/integrations/hosts/antigravity/adapter.js +171 -0
  97. package/lib/integrations/hosts/{claude.d.ts → claude/adapter.d.ts} +1 -1
  98. package/lib/integrations/hosts/{claude.js → claude/adapter.js} +32 -4
  99. package/lib/integrations/{dsh → hosts/dsh}/mcp.d.ts +1 -1
  100. package/lib/integrations/{dsh → hosts/dsh}/resources.d.ts +1 -1
  101. package/lib/integrations/{dsh → hosts/dsh}/resources.js +4 -4
  102. package/lib/integrations/{dsh → hosts/dsh}/schema.js +1 -1
  103. package/lib/integrations/{dsh → hosts/dsh}/skills.js +1 -1
  104. package/lib/integrations/hosts/{registry.js → plugin-registry.js} +2 -2
  105. package/lib/integrations/installation/pi-setup.js +1 -1
  106. package/lib/model/history.d.ts +133 -34
  107. package/lib/model/plugin-host.d.ts +26 -0
  108. package/lib/model/workspace-config.d.ts +25 -0
  109. package/lib/plugin.js +2 -2
  110. package/lib/services/agents/agent-run.d.ts +1 -1
  111. package/lib/services/history/history-capture.d.ts +4 -0
  112. package/lib/services/history/history-capture.js +86 -0
  113. package/lib/services/history/history-index.d.ts +16 -7
  114. package/lib/services/history/history-index.js +48 -70
  115. package/lib/services/history/history-migrate.d.ts +12 -0
  116. package/lib/services/history/history-migrate.js +88 -0
  117. package/lib/services/history/history-query.d.ts +51 -0
  118. package/lib/services/history/history-query.js +371 -0
  119. package/lib/services/history/summary-command.d.ts +20 -0
  120. package/lib/services/history/summary-command.js +68 -0
  121. package/lib/services/history/summary-dimensions/monthly.d.ts +7 -0
  122. package/lib/services/history/summary-dimensions/monthly.js +121 -0
  123. package/lib/services/history/summary-dimensions/session.d.ts +7 -0
  124. package/lib/services/history/summary-dimensions/session.js +124 -0
  125. package/lib/services/history/summary-registry.d.ts +7 -0
  126. package/lib/services/history/summary-registry.js +36 -0
  127. package/lib/services/history/summary-runner.d.ts +37 -0
  128. package/lib/services/history/summary-runner.js +301 -0
  129. package/lib/services/workspace/workspace-config.d.ts +5 -1
  130. package/lib/services/workspace/workspace-config.js +75 -4
  131. package/lib/storage/history-files.d.ts +45 -9
  132. package/lib/storage/history-files.js +373 -247
  133. package/lib/storage/history-format.d.ts +3 -12
  134. package/lib/storage/history-format.js +26 -50
  135. package/lib/tools/history/actions.d.ts +3 -68
  136. package/lib/tools/history/actions.js +7 -5
  137. package/lib/tools/history/contract.d.ts +14 -7
  138. package/lib/tools/history/contract.js +58 -18
  139. package/lib/tools/history/dsh-tool.d.ts +1 -2
  140. package/lib/tools/history/dsh-tool.js +11 -5
  141. package/lib/ui/dsh/management.js +18 -5
  142. package/package.json +1 -1
  143. package/resources/prompts/history-coordinator.md +1 -1
  144. package/resources/prompts/history-monthly-summary.md +13 -0
  145. package/resources/prompts/history-summary.md +10 -4
  146. package/resources/skills/provider-connections/SKILL.md +22 -12
  147. package/src/claude.ts +2 -2
  148. package/src/dsh.ts +4 -4
  149. package/src/extension/{acp-member.ts → acp/member.ts} +7 -7
  150. package/src/extension/{acp-worker.ts → acp/worker.ts} +131 -17
  151. package/src/extension/{dsh → hosts/dsh}/acp-member.ts +9 -9
  152. package/src/extension/hosts/dsh/command.ts +92 -0
  153. package/src/extension/{dsh → hosts/dsh}/files.ts +3 -3
  154. package/src/extension/hosts/dsh/history.ts +67 -0
  155. package/src/extension/{dsh → hosts/dsh}/management.ts +11 -9
  156. package/src/extension/{dsh → hosts/dsh}/workspace.ts +31 -50
  157. package/src/extension/{pi-acp-member.ts → hosts/pi/acp-member.ts} +9 -9
  158. package/src/extension/hosts/pi/command.ts +158 -0
  159. package/src/extension/{events.ts → hosts/pi/events.ts} +14 -4
  160. package/src/extension/hosts/pi/history.ts +45 -0
  161. package/src/extension/{lifecycle.ts → hosts/pi/lifecycle.ts} +7 -11
  162. package/src/extension/{plugin-runtime.ts → hosts/plugin-runtime.ts} +29 -9
  163. package/src/extension/{mcp-bridge.ts → mcp/bridge.ts} +5 -5
  164. package/src/extension/{mcp-workers.ts → mcp/workers.ts} +237 -64
  165. package/src/extension/{setup-cli.ts → setup/cli.ts} +11 -11
  166. package/src/integrations/acp/connection.ts +6 -0
  167. package/src/integrations/acp/harnesses/claude.ts +1 -1
  168. package/src/integrations/acp/harnesses/dsh.ts +1 -1
  169. package/src/integrations/acp/history-summary.ts +108 -0
  170. package/src/integrations/agent-resources.ts +6 -0
  171. package/src/integrations/hosts/antigravity/adapter.ts +161 -0
  172. package/src/integrations/hosts/{claude.ts → claude/adapter.ts} +28 -5
  173. package/src/integrations/{dsh → hosts/dsh}/mcp.ts +1 -1
  174. package/src/integrations/{dsh → hosts/dsh}/resources.ts +5 -5
  175. package/src/integrations/{dsh → hosts/dsh}/schema.ts +1 -1
  176. package/src/integrations/{dsh → hosts/dsh}/session.ts +2 -2
  177. package/src/integrations/{dsh → hosts/dsh}/skills.ts +1 -1
  178. package/src/integrations/{pi → hosts/pi}/mcp.ts +1 -1
  179. package/src/integrations/{pi → hosts/pi}/skills.ts +1 -1
  180. package/src/integrations/hosts/{registry.ts → plugin-registry.ts} +2 -2
  181. package/src/integrations/installation/pi-setup.ts +1 -1
  182. package/src/mcp.ts +1 -1
  183. package/src/model/history.ts +151 -26
  184. package/src/model/plugin-host.ts +26 -2
  185. package/src/model/workspace-config.ts +30 -0
  186. package/src/pbot.ts +13 -22
  187. package/src/plugin.ts +2 -2
  188. package/src/services/history/history-capture.ts +83 -0
  189. package/src/services/history/history-index.ts +48 -62
  190. package/src/services/history/history-migrate.ts +89 -0
  191. package/src/services/history/history-query.ts +415 -0
  192. package/src/services/history/summary-command.ts +69 -0
  193. package/src/services/history/summary-dimensions/monthly.ts +139 -0
  194. package/src/services/history/summary-dimensions/session.ts +149 -0
  195. package/src/services/history/summary-registry.ts +44 -0
  196. package/src/services/history/summary-runner.ts +352 -0
  197. package/src/services/workspace/workspace-config.ts +93 -5
  198. package/src/storage/history-files.ts +408 -188
  199. package/src/storage/history-format.ts +46 -60
  200. package/src/tools/history/actions.ts +8 -6
  201. package/src/tools/history/contract.ts +65 -20
  202. package/src/tools/history/dsh-tool.ts +17 -8
  203. package/src/tools/history/pi-tool.ts +21 -0
  204. package/src/tools/register.ts +3 -4
  205. package/src/ui/dsh/management.ts +27 -11
  206. package/src/ui/{confirmation.ts → pi/confirmation.ts} +1 -1
  207. package/lib/antigravity-plugin/lib/integrations/hosts/antigravity.d.ts +0 -4
  208. package/lib/antigravity-plugin/lib/integrations/hosts/antigravity.js +0 -79
  209. package/lib/extension/dsh/command.js +0 -50
  210. package/lib/extension/dsh/history.d.ts +0 -15
  211. package/lib/extension/dsh/history.js +0 -87
  212. package/lib/integrations/dsh/history-summary.d.ts +0 -11
  213. package/lib/integrations/dsh/history-summary.js +0 -36
  214. package/lib/integrations/dsh/history.d.ts +0 -16
  215. package/lib/integrations/dsh/history.js +0 -167
  216. package/lib/integrations/history-summary.d.ts +0 -4
  217. package/lib/integrations/history-summary.js +0 -32
  218. package/lib/integrations/hosts/antigravity.d.ts +0 -4
  219. package/lib/integrations/hosts/antigravity.js +0 -79
  220. package/lib/services/history/history-service.d.ts +0 -106
  221. package/lib/services/history/history-service.js +0 -242
  222. package/lib/storage/acp-history.d.ts +0 -10
  223. package/lib/storage/acp-history.js +0 -57
  224. package/src/extension/command.ts +0 -76
  225. package/src/extension/dsh/command.ts +0 -54
  226. package/src/extension/dsh/history.ts +0 -74
  227. package/src/extension/history.ts +0 -26
  228. package/src/integrations/dsh/history-summary.ts +0 -39
  229. package/src/integrations/dsh/history.ts +0 -84
  230. package/src/integrations/history-summary.ts +0 -30
  231. package/src/integrations/hosts/antigravity.ts +0 -83
  232. package/src/integrations/pi/history.ts +0 -99
  233. package/src/services/history/history-service.ts +0 -195
  234. package/src/storage/acp-history.ts +0 -49
  235. package/src/tools/history/tool.ts +0 -19
  236. /package/lib/antigravity-plugin/lib/integrations/hosts/{registry.d.ts → plugin-registry.d.ts} +0 -0
  237. /package/lib/{extension/acp-worker.d.ts → antigravity-plugin/lib/model/history.js} +0 -0
  238. /package/lib/extension/{dsh → hosts/dsh}/acp-member.d.ts +0 -0
  239. /package/lib/extension/{dsh → hosts/dsh}/command.d.ts +0 -0
  240. /package/lib/extension/{dsh → hosts/dsh}/files.d.ts +0 -0
  241. /package/lib/extension/{setup-guard.js → setup/guard.js} +0 -0
  242. /package/lib/integrations/acp/{claude.d.ts → claude-settings.d.ts} +0 -0
  243. /package/lib/integrations/acp/{claude.js → claude-settings.js} +0 -0
  244. /package/lib/integrations/{dsh → hosts/dsh}/mcp.js +0 -0
  245. /package/lib/integrations/{dsh → hosts/dsh}/messages.d.ts +0 -0
  246. /package/lib/integrations/{dsh → hosts/dsh}/messages.js +0 -0
  247. /package/lib/integrations/{dsh → hosts/dsh}/root-agents.d.ts +0 -0
  248. /package/lib/integrations/{dsh → hosts/dsh}/root-agents.js +0 -0
  249. /package/lib/integrations/{dsh → hosts/dsh}/schema.d.ts +0 -0
  250. /package/lib/integrations/{dsh → hosts/dsh}/skills.d.ts +0 -0
  251. /package/lib/integrations/hosts/{registry.d.ts → plugin-registry.d.ts} +0 -0
  252. /package/src/extension/{setup-guard.ts → setup/guard.ts} +0 -0
  253. /package/src/integrations/acp/{claude.ts → claude-settings.ts} +0 -0
  254. /package/src/integrations/{dsh → hosts/dsh}/messages.ts +0 -0
  255. /package/src/integrations/{dsh → hosts/dsh}/root-agents.ts +0 -0
  256. /package/src/integrations/{pi → hosts/pi}/agent-tools.ts +0 -0
@@ -2,42 +2,38 @@ import { existsSync } from "node:fs";
2
2
  import { realpath } from "node:fs/promises";
3
3
  import { resolve } from "node:path";
4
4
  import * as McpClient from "@deepseek-ai/dsh-mcp-client";
5
- import { rootAgents } from "../../integrations/dsh/root-agents.js";
6
- import { dshResources } from "../../integrations/dsh/resources.js";
5
+ import { rootAgents } from "../../../integrations/hosts/dsh/root-agents.js";
6
+ import { dshResources } from "../../../integrations/hosts/dsh/resources.js";
7
7
  import { registerDshFileEvents } from "./files.js";
8
- import { DshHistoryWork, registerDshHistoryEvents } from "./history.js";
9
- import { registerDshHistoryTool } from "../../tools/history/dsh-tool.js";
10
- import { resourceRoot } from "../../common/paths.js";
11
- import { requireThat } from "../../common/validation.js";
12
- import { toDshMcpConfig } from "../../integrations/dsh/mcp.js";
13
- import { registerDshSkills } from "../../integrations/dsh/skills.js";
14
- import { readWorkspaceConfig, workspaceDisabledMessage, workspaceFeatures } from "../../services/workspace/workspace-config.js";
15
- import { readWorkspaceMcpConfig, resolveWorkspaceMcpServer } from "../../services/workspace/workspace-mcp.js";
16
- import { initializeWorkspace } from "../../services/workspace/workspace-preparation.js";
17
- import { McpWorkerRuntime, defaultWorkerDirectory } from "../mcp-workers.js";
8
+ import { registerDshHistoryEvents } from "./history.js";
9
+ import { registerDshHistoryTool } from "../../../tools/history/dsh-tool.js";
10
+ import { resourceRoot } from "../../../common/paths.js";
11
+ import { requireThat } from "../../../common/validation.js";
12
+ import { toDshMcpConfig } from "../../../integrations/hosts/dsh/mcp.js";
13
+ import { registerDshSkills } from "../../../integrations/hosts/dsh/skills.js";
14
+ import { readWorkspaceConfig, workspaceDisabledMessage, workspaceFeatures } from "../../../services/workspace/workspace-config.js";
15
+ import { readWorkspaceMcpConfig, resolveWorkspaceMcpServer } from "../../../services/workspace/workspace-mcp.js";
16
+ import { initializeWorkspace } from "../../../services/workspace/workspace-preparation.js";
17
+ import { checkHistoryMigrationNotice } from "../../../services/history/history-migrate.js";
18
+ import { checkHistorySummaryReminder } from "../../../services/history/summary-runner.js";
19
+ import { McpWorkerRuntime, defaultWorkerDirectory } from "../../mcp/workers.js";
18
20
  export const dshDependencies = ["agents", "sessions", "sessionPersistence", "sessionQuery", "llm", "tools", "systemPrompt", "skills", "fs", "workingDirectory", "approval"];
19
21
  export class DshWorkspace {
20
22
  ctx;
21
23
  root;
22
24
  agent;
23
25
  component;
24
- historyWork;
25
- releaseHistory;
26
26
  features;
27
27
  lifetime = new AbortController();
28
- history;
29
28
  workers;
30
29
  #scope;
31
30
  #closing;
32
- constructor(ctx, root, agent, component, historyWork, releaseHistory, features = workspaceFeatures()) {
31
+ constructor(ctx, root, agent, component, features = workspaceFeatures()) {
33
32
  this.ctx = ctx;
34
33
  this.root = root;
35
34
  this.agent = agent;
36
35
  this.component = component;
37
- this.historyWork = historyWork;
38
- this.releaseHistory = releaseHistory;
39
36
  this.features = features;
40
- this.history = historyWork.service;
41
37
  this.workers = new McpWorkerRuntime(defaultWorkerDirectory(), agent.id, "dsh");
42
38
  }
43
39
  check = () => { this.component.throwIfAborted(); this.lifetime.signal.throwIfAborted(); };
@@ -54,8 +50,19 @@ export class DshWorkspace {
54
50
  if (this.features.prompts)
55
51
  await dshResources(ctx, this.agent, this.root, "coordinator", this.check, "history-coordinator.md");
56
52
  registerDshFileEvents(ctx, this.agent, this.root, false, this.check);
57
- registerDshHistoryTool(ctx, this.agent, this.history, this.lifetime.signal, this.check);
58
- registerDshHistoryEvents(ctx, this.agent, this.historyWork, this.check);
53
+ if (this.features.history) {
54
+ registerDshHistoryTool(ctx, this.agent, this.root, this.lifetime.signal, this.check);
55
+ registerDshHistoryEvents(ctx, this.agent, this.root);
56
+ try {
57
+ const migrationNotice = checkHistoryMigrationNotice(this.root);
58
+ if (migrationNotice)
59
+ this.ctx.logger.info(migrationNotice);
60
+ const reminder = checkHistorySummaryReminder(this.root);
61
+ if (reminder)
62
+ this.ctx.logger.info(reminder.message);
63
+ }
64
+ catch { /* Never block workspace startup if history reminder probe fails. */ }
65
+ }
59
66
  if (existsSync(mcpEntry)) {
60
67
  await ctx.plugin(McpClient, McpClient.Config({
61
68
  transport: "stdio",
@@ -70,6 +77,8 @@ export class DshWorkspace {
70
77
  PBOT_WORKSPACE_ROOT: this.root,
71
78
  PBOT_MCP_AGENT_DIR: workerDir,
72
79
  PBOT_MCP_SESSION_ID: this.agent.id,
80
+ PBOT_NATIVE_WORKSPACE_MCP: "1",
81
+ PBOT_NATIVE_HISTORY: "1",
73
82
  },
74
83
  cwd: this.root,
75
84
  toolCallTimeoutMs: 600_000,
@@ -118,12 +127,6 @@ export class DshWorkspace {
118
127
  catch (error) {
119
128
  errors.push(error);
120
129
  }
121
- try {
122
- await this.releaseHistory();
123
- }
124
- catch (error) {
125
- errors.push(error);
126
- }
127
130
  if (errors.length)
128
131
  throw new AggregateError(errors, "dsh 工作区关闭失败;请核对执行资源。");
129
132
  })();
@@ -136,47 +139,11 @@ export class DshWorkspaces {
136
139
  #initializing = new Map();
137
140
  #configurations = new Map();
138
141
  #parentEffects = new Map();
139
- #histories = new Map();
140
142
  #lifetime = new AbortController();
141
143
  #closing;
142
144
  constructor(ctx) {
143
145
  this.ctx = ctx;
144
146
  }
145
- async history(root) {
146
- this.#lifetime.signal.throwIfAborted();
147
- let entry = this.#histories.get(root);
148
- if (entry && entry.users === 0) {
149
- await entry.work.close();
150
- this.#lifetime.signal.throwIfAborted();
151
- if (this.#histories.get(root) === entry)
152
- this.#histories.delete(root);
153
- return this.history(root);
154
- }
155
- if (!entry) {
156
- entry = { work: new DshHistoryWork(this.ctx, root), users: 0 };
157
- this.#histories.set(root, entry);
158
- }
159
- const owned = entry;
160
- owned.users++;
161
- let released = false;
162
- return {
163
- work: owned.work,
164
- release: async () => {
165
- if (released)
166
- return;
167
- released = true;
168
- if (--owned.users === 0) {
169
- try {
170
- await owned.work.close();
171
- }
172
- finally {
173
- if (this.#histories.get(root) === owned)
174
- this.#histories.delete(root);
175
- }
176
- }
177
- },
178
- };
179
- }
180
147
  async open(agent) {
181
148
  this.#lifetime.signal.throwIfAborted();
182
149
  requireThat(rootAgents(this.ctx.agents).includes(agent), "子会话不拥有协调者管理入口。");
@@ -200,10 +167,9 @@ export class DshWorkspaces {
200
167
  this.#parentEffects.set(agent, dispose);
201
168
  return undefined;
202
169
  }
203
- const history = await this.history(root);
204
170
  let workspace;
205
171
  try {
206
- workspace = new DshWorkspace(this.ctx, root, agent, this.#lifetime.signal, history.work, history.release, workspaceFeatures(configuration));
172
+ workspace = new DshWorkspace(this.ctx, root, agent, this.#lifetime.signal, workspaceFeatures(configuration));
207
173
  const owned = workspace;
208
174
  const dispose = agent.ctx.effect(() => async () => {
209
175
  this.#parents.delete(agent);
@@ -223,8 +189,6 @@ export class DshWorkspaces {
223
189
  await dispose();
224
190
  else if (workspace)
225
191
  await workspace.close();
226
- else
227
- await history.release();
228
192
  }
229
193
  catch (cleanup) {
230
194
  throw new AggregateError([error, cleanup], "dsh 工作区装配与清理均未完成。");
@@ -300,8 +264,7 @@ export class DshWorkspaces {
300
264
  const opened = await Promise.allSettled(this.#parents.values());
301
265
  const closed = await Promise.allSettled(opened.flatMap(value => value.status === "fulfilled" && value.value ? [value.value.close()] : []));
302
266
  const effects = await Promise.allSettled([...this.#parentEffects.values()].map(dispose => dispose()));
303
- const histories = await Promise.allSettled([...this.#histories.values()].map(value => value.work.close()));
304
- const errors = [...new Set([...closed, ...effects, ...histories].flatMap(value => value.status === "rejected" ? [value.reason] : []))];
267
+ const errors = [...new Set([...closed, ...effects].flatMap(value => value.status === "rejected" ? [value.reason] : []))];
305
268
  if (errors.length)
306
269
  throw new AggregateError(errors, "部分 dsh 工作区未能完成关闭。");
307
270
  }
@@ -309,7 +272,6 @@ export class DshWorkspaces {
309
272
  this.#parents.clear();
310
273
  this.#configurations.clear();
311
274
  this.#parentEffects.clear();
312
- this.#histories.clear();
313
275
  }
314
276
  })();
315
277
  return this.#closing;
@@ -1,9 +1,9 @@
1
- import type { PluginHostAdapter } from "../model/plugin-host.js";
1
+ import type { PluginHostAdapter } from "../../model/plugin-host.js";
2
2
  export declare function pluginCommand(adapter: PluginHostAdapter, args: readonly string[], cwd: string): Promise<{
3
3
  version: string;
4
4
  workspaceRoot: string;
5
5
  resourceRoot: string;
6
- configuration: import("../model/workspace-config.js").WorkspaceConfiguration;
6
+ configuration: import("../../model/workspace-config.js").WorkspaceConfiguration;
7
7
  }>;
8
8
  export declare function runPluginHost(adapter: PluginHostAdapter, args: readonly string[]): Promise<void>;
9
9
  /** Shared hook execution engine; host-specific protocols stay in PluginHostAdapter implementations. */
@@ -1,10 +1,13 @@
1
- import { resourceRoot } from "../common/paths.js";
2
- import { packageVersion } from "../common/version.js";
3
- import { requireThat } from "../common/validation.js";
4
- import { loadWorkspaceContext } from "../integrations/agent-resources.js";
5
- import { readWorkspaceConfig, workspaceFeatures } from "../services/workspace/workspace-config.js";
6
- import { initializeWorkspace } from "../services/workspace/workspace-preparation.js";
7
- import { discoverWorkspaceSkills } from "../services/workspace/workspace-skills.js";
1
+ import { resourceRoot } from "../../common/paths.js";
2
+ import { packageVersion } from "../../common/version.js";
3
+ import { requireThat } from "../../common/validation.js";
4
+ import { loadWorkspaceContext } from "../../integrations/agent-resources.js";
5
+ import { recordHistoryCapture } from "../../services/history/history-capture.js";
6
+ import { checkHistoryMigrationNotice } from "../../services/history/history-migrate.js";
7
+ import { checkHistorySummaryReminder } from "../../services/history/summary-runner.js";
8
+ import { readWorkspaceConfig, workspaceFeatures } from "../../services/workspace/workspace-config.js";
9
+ import { initializeWorkspace } from "../../services/workspace/workspace-preparation.js";
10
+ import { discoverWorkspaceSkills } from "../../services/workspace/workspace-skills.js";
8
11
  function disabledMessage(adapter, configuration) {
9
12
  return configuration.error ?? `Personal Bot 未在此工作区启用。运行 ${adapter.initCommandHint};配置文件:${configuration.path}`;
10
13
  }
@@ -48,10 +51,32 @@ export async function pluginHook(adapter, payload) {
48
51
  }
49
52
  if (!configuration.enabled)
50
53
  return adapter.formatPass(payload);
54
+ if (features.history && adapter.extractHistory) {
55
+ try {
56
+ const capture = await adapter.extractHistory(event);
57
+ if (capture)
58
+ recordHistoryCapture(root, adapter.host, capture);
59
+ }
60
+ catch { /* Never block a host turn if history persistence encounters a transient error or busy lock. */ }
61
+ }
62
+ if (event.kind === "record-history")
63
+ return adapter.formatPass(payload);
51
64
  const workspaceSkills = features.skills && !adapter.nativeWorkspaceSkills
52
65
  ? await discoverWorkspaceSkills(root)
53
66
  : [];
54
- if (!features.prompts && !workspaceSkills.length)
67
+ const notices = [];
68
+ if (event.isSessionStart && features.history) {
69
+ try {
70
+ const migrationNotice = checkHistoryMigrationNotice(root);
71
+ if (migrationNotice)
72
+ notices.push(migrationNotice);
73
+ const reminder = checkHistorySummaryReminder(root);
74
+ if (reminder)
75
+ notices.push(reminder.message);
76
+ }
77
+ catch { /* Never block session start if history reminder probe fails. */ }
78
+ }
79
+ if (!features.prompts && !workspaceSkills.length && !notices.length)
55
80
  return adapter.formatPass(payload);
56
81
  const context = await loadWorkspaceContext({
57
82
  host: adapter.host,
@@ -62,6 +87,7 @@ export async function pluginHook(adapter, payload) {
62
87
  includeRootAgents: features.prompts && !adapter.nativeRootAgents,
63
88
  ...(event.localRoleOnly ? { localRoleOnly: true } : {}),
64
89
  workspaceSkills,
90
+ notices,
65
91
  });
66
92
  return adapter.formatContext(event, context);
67
93
  }
@@ -1,4 +1,4 @@
1
- import { resolveWorkspaceMcpServers } from "../services/workspace/workspace-mcp.js";
1
+ import { resolveWorkspaceMcpServers } from "../../services/workspace/workspace-mcp.js";
2
2
  export declare class WorkspaceMcpBridge {
3
3
  #private;
4
4
  discover(root: string, serverName?: string): Promise<{
@@ -1,9 +1,9 @@
1
1
  import { spawn } from "node:child_process";
2
2
  import { setTimeout as delay } from "node:timers/promises";
3
- import { object } from "../common/json.js";
4
- import { requireThat } from "../common/validation.js";
5
- import { packageVersion } from "../common/version.js";
6
- import { readWorkspaceMcpConfig, resolveWorkspaceMcpServer, resolveWorkspaceMcpServers, } from "../services/workspace/workspace-mcp.js";
3
+ import { object } from "../../common/json.js";
4
+ import { requireThat } from "../../common/validation.js";
5
+ import { packageVersion } from "../../common/version.js";
6
+ import { readWorkspaceMcpConfig, resolveWorkspaceMcpServer, resolveWorkspaceMcpServers, } from "../../services/workspace/workspace-mcp.js";
7
7
  const protocolVersion = "2025-03-26";
8
8
  const maxStderrBytes = 4096;
9
9
  function rpcError(server, method, error) {
@@ -1,5 +1,6 @@
1
- import { type AcpCommands, type McpWorkerToolName } from "../model/acp.js";
1
+ import { type AcpCommands, type McpWorkerToolName } from "../../model/acp.js";
2
2
  export type ProgressReporter = (message: string) => void;
3
+ export declare const mcpWorkerOnlyInstructions: string;
3
4
  export declare const mcpInstructions: string;
4
5
  export declare function buildPbotWorkerTools(commands?: AcpCommands, defaultBackend?: string, workspaceBound?: boolean): ({
5
6
  name: string;
@@ -341,6 +342,115 @@ export declare function buildWorkspaceMcpTools(workspaceBound?: boolean): ({
341
342
  };
342
343
  };
343
344
  })[];
345
+ export declare function buildHistoryMcpTools(workspaceBound?: boolean): ({
346
+ name: string;
347
+ description: string;
348
+ annotations: {
349
+ title: string;
350
+ readOnlyHint: boolean;
351
+ destructiveHint: boolean;
352
+ idempotentHint: boolean;
353
+ openWorldHint: boolean;
354
+ };
355
+ inputSchema: {
356
+ type: string;
357
+ additionalProperties: boolean;
358
+ required: never[];
359
+ properties: {
360
+ host: {
361
+ type: string;
362
+ description: string;
363
+ };
364
+ dimension: {
365
+ type: string;
366
+ description: string;
367
+ };
368
+ query: {
369
+ type: string;
370
+ description: string;
371
+ };
372
+ sessionId: {
373
+ type: string;
374
+ description: string;
375
+ };
376
+ from: {
377
+ type: string;
378
+ description: string;
379
+ };
380
+ to: {
381
+ type: string;
382
+ description: string;
383
+ };
384
+ offset: {
385
+ type: string;
386
+ minimum: number;
387
+ description: string;
388
+ };
389
+ limit: {
390
+ type: string;
391
+ minimum: number;
392
+ maximum: number;
393
+ description: string;
394
+ };
395
+ workspace: {
396
+ type: string;
397
+ description: string;
398
+ };
399
+ id?: never;
400
+ childrenOffset?: never;
401
+ };
402
+ };
403
+ } | {
404
+ name: string;
405
+ description: string;
406
+ annotations: {
407
+ title: string;
408
+ readOnlyHint: boolean;
409
+ destructiveHint: boolean;
410
+ idempotentHint: boolean;
411
+ openWorldHint: boolean;
412
+ };
413
+ inputSchema: {
414
+ type: string;
415
+ additionalProperties: boolean;
416
+ required: string[];
417
+ properties: {
418
+ id: {
419
+ type: string;
420
+ description: string;
421
+ };
422
+ host: {
423
+ type: string;
424
+ description: string;
425
+ };
426
+ offset: {
427
+ type: string;
428
+ minimum: number;
429
+ description: string;
430
+ };
431
+ limit: {
432
+ type: string;
433
+ minimum: number;
434
+ maximum: number;
435
+ description: string;
436
+ };
437
+ childrenOffset: {
438
+ type: string;
439
+ minimum: number;
440
+ description: string;
441
+ };
442
+ workspace: {
443
+ type: string;
444
+ description: string;
445
+ };
446
+ dimension?: never;
447
+ query?: never;
448
+ sessionId?: never;
449
+ from?: never;
450
+ to?: never;
451
+ };
452
+ };
453
+ })[];
344
454
  export declare const pbotWorkerTools: ({
345
455
  name: string;
346
456
  description: string;
@@ -627,7 +737,9 @@ export declare function parseWorkerCommand(raw: string): {
627
737
  };
628
738
  export declare class McpWorkerRuntime {
629
739
  #private;
630
- constructor(directory?: string, sessionId?: string, defaultBackend?: string | undefined);
740
+ constructor(directory?: string, sessionId?: string, defaultBackend?: string | undefined, nativeWorkspaceMcp?: boolean, nativeHistory?: boolean);
741
+ get nativeWorkspaceMcp(): boolean;
742
+ get nativeHistory(): boolean;
631
743
  private resolveBackend;
632
744
  private resolveWorkspace;
633
745
  private workspace;
@@ -969,6 +1081,114 @@ export declare class McpWorkerRuntime {
969
1081
  };
970
1082
  };
971
1083
  };
1084
+ } | {
1085
+ name: string;
1086
+ description: string;
1087
+ annotations: {
1088
+ title: string;
1089
+ readOnlyHint: boolean;
1090
+ destructiveHint: boolean;
1091
+ idempotentHint: boolean;
1092
+ openWorldHint: boolean;
1093
+ };
1094
+ inputSchema: {
1095
+ type: string;
1096
+ additionalProperties: boolean;
1097
+ required: never[];
1098
+ properties: {
1099
+ host: {
1100
+ type: string;
1101
+ description: string;
1102
+ };
1103
+ dimension: {
1104
+ type: string;
1105
+ description: string;
1106
+ };
1107
+ query: {
1108
+ type: string;
1109
+ description: string;
1110
+ };
1111
+ sessionId: {
1112
+ type: string;
1113
+ description: string;
1114
+ };
1115
+ from: {
1116
+ type: string;
1117
+ description: string;
1118
+ };
1119
+ to: {
1120
+ type: string;
1121
+ description: string;
1122
+ };
1123
+ offset: {
1124
+ type: string;
1125
+ minimum: number;
1126
+ description: string;
1127
+ };
1128
+ limit: {
1129
+ type: string;
1130
+ minimum: number;
1131
+ maximum: number;
1132
+ description: string;
1133
+ };
1134
+ workspace: {
1135
+ type: string;
1136
+ description: string;
1137
+ };
1138
+ id?: never;
1139
+ childrenOffset?: never;
1140
+ };
1141
+ };
1142
+ } | {
1143
+ name: string;
1144
+ description: string;
1145
+ annotations: {
1146
+ title: string;
1147
+ readOnlyHint: boolean;
1148
+ destructiveHint: boolean;
1149
+ idempotentHint: boolean;
1150
+ openWorldHint: boolean;
1151
+ };
1152
+ inputSchema: {
1153
+ type: string;
1154
+ additionalProperties: boolean;
1155
+ required: string[];
1156
+ properties: {
1157
+ id: {
1158
+ type: string;
1159
+ description: string;
1160
+ };
1161
+ host: {
1162
+ type: string;
1163
+ description: string;
1164
+ };
1165
+ offset: {
1166
+ type: string;
1167
+ minimum: number;
1168
+ description: string;
1169
+ };
1170
+ limit: {
1171
+ type: string;
1172
+ minimum: number;
1173
+ maximum: number;
1174
+ description: string;
1175
+ };
1176
+ childrenOffset: {
1177
+ type: string;
1178
+ minimum: number;
1179
+ description: string;
1180
+ };
1181
+ workspace: {
1182
+ type: string;
1183
+ description: string;
1184
+ };
1185
+ dimension?: never;
1186
+ query?: never;
1187
+ sessionId?: never;
1188
+ from?: never;
1189
+ to?: never;
1190
+ };
1191
+ };
972
1192
  })[]>;
973
1193
  /** Wait until ACP handshake and model/thinking configuration finish so invalid options fail synchronously on create/resume. */
974
1194
  private waitReady;