personal-bot 0.3.5 → 0.3.7

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 (86) hide show
  1. package/.claude-plugin/marketplace.json +2 -2
  2. package/.claude-plugin/plugin.json +1 -1
  3. package/README.md +191 -65
  4. package/README.zh-CN.md +189 -63
  5. package/docs/README.md +2 -2
  6. package/docs/architecture/design.md +3 -4
  7. package/docs/architecture/model-context.md +1 -2
  8. package/docs/guides/capabilities.md +4 -8
  9. package/docs/hosts/antigravity.md +4 -2
  10. package/docs/hosts/pi.md +4 -15
  11. package/docs/maintainers/release.md +2 -2
  12. package/lib/antigravity-plugin/lib/extension/acp-worker.js +2 -2
  13. package/lib/antigravity-plugin/lib/extension/cli.js +1403 -1504
  14. package/lib/antigravity-plugin/lib/extension/mcp.js +66 -49
  15. package/lib/antigravity-plugin/lib/integrations/agent-resources.js +2 -2
  16. package/lib/antigravity-plugin/package.json +1 -1
  17. package/lib/antigravity-plugin/plugin.json +1 -1
  18. package/lib/antigravity-plugin/resources/agents/coordinator.md +3 -7
  19. package/lib/antigravity-plugin/resources/agents/general-purpose.md +3 -3
  20. package/lib/antigravity-plugin/resources/prompts/plugin-coordinator.md +1 -2
  21. package/lib/antigravity-plugin/resources/prompts/workspace.md +12 -16
  22. package/lib/antigravity-plugin/resources/skills/provider-connections/SKILL.md +7 -6
  23. package/lib/antigravity-plugin/resources/templates/workspace-agents.md +0 -4
  24. package/lib/antigravity-plugin/skills/pbot/SKILL.md +14 -6
  25. package/lib/antigravity-plugin/skills/provider-connections/SKILL.md +7 -6
  26. package/lib/codex-marketplace/plugins/personal-bot/.codex-plugin/plugin.json +1 -1
  27. package/lib/codex-marketplace/plugins/personal-bot/.mcp.json +2 -2
  28. package/lib/codex-marketplace/plugins/personal-bot/hooks/hooks.json +3 -3
  29. package/lib/codex-marketplace/plugins/personal-bot/skills/pbot/SKILL.md +2 -2
  30. package/lib/extension/acp-worker.js +2 -2
  31. package/lib/extension/cli.js +1403 -1504
  32. package/lib/extension/mcp/tool-contract.js +49 -55
  33. package/lib/extension/mcp/workers.d.ts +6 -0
  34. package/lib/extension/mcp/workers.js +25 -8
  35. package/lib/extension/mcp.js +66 -49
  36. package/lib/integrations/agent-resources.js +2 -2
  37. package/lib/qoder-plugin/.mcp.json +2 -2
  38. package/lib/qoder-plugin/.qoder-plugin/plugin.json +1 -1
  39. package/lib/qoder-plugin/hooks/hooks.json +3 -3
  40. package/lib/qoder-plugin/skills/pbot/SKILL.md +2 -2
  41. package/lib/tools/history/contract.js +12 -12
  42. package/package.json +1 -1
  43. package/resources/agents/coordinator.md +3 -7
  44. package/resources/agents/general-purpose.md +3 -3
  45. package/resources/antigravity/skills/pbot/SKILL.md +14 -6
  46. package/resources/claude/skills/pbot/SKILL.md +14 -6
  47. package/resources/plugin/skills/pbot/SKILL.md +2 -2
  48. package/resources/prompts/history-coordinator.md +1 -2
  49. package/resources/prompts/plugin-coordinator.md +1 -2
  50. package/resources/prompts/workspace.md +12 -16
  51. package/resources/skills/provider-connections/SKILL.md +7 -6
  52. package/resources/templates/workspace-agents.md +0 -4
  53. package/src/extension/cli/commands/install.ts +77 -0
  54. package/src/extension/cli/index.ts +3 -4
  55. package/src/extension/mcp/tool-contract.ts +49 -55
  56. package/src/extension/mcp/workers.ts +32 -10
  57. package/src/integrations/agent-resources.ts +2 -2
  58. package/src/integrations/installation/installers/antigravity.ts +49 -0
  59. package/src/integrations/installation/installers/claude.ts +30 -0
  60. package/src/integrations/installation/installers/codex.ts +56 -0
  61. package/src/integrations/installation/installers/dsh.ts +25 -0
  62. package/src/integrations/installation/installers/pi.ts +26 -0
  63. package/src/integrations/installation/installers/qoder.ts +49 -0
  64. package/src/integrations/installation/installers/registry.ts +48 -0
  65. package/src/integrations/installation/processes.ts +2 -41
  66. package/src/model/installation.ts +28 -36
  67. package/src/pbot.ts +1 -1
  68. package/src/services/installation/install-service.ts +107 -0
  69. package/src/tools/history/contract.ts +12 -12
  70. package/lib/antigravity-plugin/resources/references/compute-finance.md +0 -22
  71. package/lib/antigravity-plugin/resources/references/compute.md +0 -16
  72. package/lib/antigravity-plugin/resources/references/task-conductor.md +0 -25
  73. package/lib/common/package-source.js +0 -16
  74. package/lib/extension/setup/guard.js +0 -11
  75. package/lib/integrations/installation/pi-bridge.js +0 -131
  76. package/lib/model/installation.js +0 -1
  77. package/resources/installer/plugins.json +0 -16
  78. package/resources/references/compute-finance.md +0 -22
  79. package/resources/references/compute.md +0 -16
  80. package/resources/references/task-conductor.md +0 -25
  81. package/src/extension/cli/commands/setup.ts +0 -159
  82. package/src/extension/setup/guard.ts +0 -12
  83. package/src/integrations/installation/pi-bridge.ts +0 -109
  84. package/src/integrations/installation/pi-setup.ts +0 -165
  85. package/src/services/installation/setup-service.ts +0 -91
  86. package/src/ui/setup.ts +0 -40
@@ -11,7 +11,7 @@ function formatBackendItem(entry, defaultBackend) {
11
11
  if (entry.label)
12
12
  tags.push(entry.label);
13
13
  if (entry.backend === defaultBackend)
14
- tags.push("当前");
14
+ tags.push("当前宿主");
15
15
  return tags.length ? `${entry.backend}(${tags.join(",")})` : entry.backend;
16
16
  }
17
17
  function summarizeBackends(commands = {}, defaultBackend) {
@@ -32,8 +32,8 @@ function workspaceProperty(workspaceBound) {
32
32
  return {
33
33
  type: "string",
34
34
  description: workspaceBound
35
- ? "目标工作区根目录的绝对路径;默认使用当前工作区,通常省略。"
36
- : "目标工作区根目录的绝对路径(如上下文中提供了 workspaceRoot 则传该路径);请显式传入。",
35
+ ? "工作区根目录绝对路径;默认当前工作区,通常省略。"
36
+ : "目标工作区根目录绝对路径;请传入环境中的 workspaceRoot。",
37
37
  };
38
38
  }
39
39
  export function buildPbotWorkerTools(commands = {}, defaultBackend, workspaceBound = false) {
@@ -45,8 +45,7 @@ export function buildPbotWorkerTools(commands = {}, defaultBackend, workspaceBou
45
45
  return [
46
46
  {
47
47
  name: "worker_create",
48
- description: "启动一个独立的外部 AI 助手会话(worker),用于将任务委派给其他助手或指定模型/思考深度来独立处理(如按用户要求切换助手、获取独立审查或第二意见、并行分担子任务)。" +
49
- "本工具仅建立会话并返回 workerId,随后通过 worker_request 发送具体任务。不需要借助其他助手时,优先自行完成或使用当前内置子代理。\n" +
48
+ description: "启动独立的外部助手会话并返回 workerId(不发送任务,随后用 worker_request 派发)。未指定其他助手或特定模型时,优先自行完成或使用当前内置子代理。\n" +
50
49
  overview,
51
50
  annotations: {
52
51
  title: "Create Worker",
@@ -62,19 +61,19 @@ export function buildPbotWorkerTools(commands = {}, defaultBackend, workspaceBou
62
61
  properties: {
63
62
  backend: {
64
63
  type: "string",
65
- description: "要启动的外部助手标识(不区分大小写,支持常见别名,如 claude-code、agy)。",
64
+ description: "目标外部助手标识(不区分大小写,支持常见别名如 claude-code、agy)。",
66
65
  },
67
66
  model: {
68
67
  type: "string",
69
- description: "仅用户明确要求特定模型时指定(支持模型 ID、显示名或 provider/model,不区分大小写);不确定可用值时先用 worker_discover(target=\"models\") 查询;不填则使用该助手默认模型。",
68
+ description: "目标模型(模型 ID、显示名或 provider/model,不区分大小写);未明确指定时省略以用默认模型,不确定可选值时先查 worker_discover(target=\"models\")。",
70
69
  },
71
70
  thinking: {
72
71
  type: "string",
73
- description: "仅用户明确要求思考深度时指定(如 low / medium / high / xhigh / max,不区分大小写);不填则使用默认设置。",
72
+ description: "思考深度(如 low / medium / high / xhigh / max,不区分大小写);未明确指定时省略以用默认设置。",
74
73
  },
75
74
  cwd: {
76
75
  type: "string",
77
- description: "助手执行任务时的工作目录(绝对路径或相对工作区的路径),默认为当前工作区根目录。",
76
+ description: "执行目录(绝对路径或相对工作区路径),默认工作区根目录。",
78
77
  },
79
78
  workspace,
80
79
  },
@@ -82,7 +81,7 @@ export function buildPbotWorkerTools(commands = {}, defaultBackend, workspaceBou
82
81
  },
83
82
  {
84
83
  name: "worker_close",
85
- description: "结束不再需要的外部助手会话并释放资源。若该助手支持会话恢复,后续仍可直接用 worker_request 在原上下文中继续对话。",
84
+ description: "结束外部助手会话并释放进程。若该会话支持恢复(capabilities.resume),后续仍可直接用 worker_request 续接。",
86
85
  annotations: {
87
86
  title: "Close Worker",
88
87
  readOnlyHint: false,
@@ -97,7 +96,7 @@ export function buildPbotWorkerTools(commands = {}, defaultBackend, workspaceBou
97
96
  properties: {
98
97
  workerId: {
99
98
  type: "string",
100
- description: "要结束的助手会话 ID(来自 worker_create 或 worker_discover)。",
99
+ description: "助手会话 ID(来自 worker_create 或 worker_discover)。",
101
100
  },
102
101
  workspace,
103
102
  },
@@ -105,9 +104,8 @@ export function buildPbotWorkerTools(commands = {}, defaultBackend, workspaceBou
105
104
  },
106
105
  {
107
106
  name: "worker_request",
108
- description: "向指定的外部助手派发任务,或在同一上下文中追问与补充要求,并获取执行结果(已关闭但支持恢复的会话会自动续接)。" +
109
- `默认最多等待 ${defaultWaitMs / 1000} 秒返回结果;将 waitMs 设为 0 可立即返回并转入后台执行,适合耗时任务或多助手并行。` +
110
- "若返回 timedOut 或结果含 nextOffset,用 worker_output 继续等待或翻页;若返回 needsResponse,先向用户确认再用 worker_response 回复。",
107
+ description: "向外部助手派发任务或在同一上下文中追问(已关闭且支持恢复的会话会自动续接)。" +
108
+ `默认最多等待 ${defaultWaitMs / 1000} 秒(waitMs 设为 0 可立即转后台并行);返回 timedOut 或 nextOffset 用 worker_output,返回 needsResponse 先向用户确认再用 worker_response。`,
111
109
  annotations: {
112
110
  title: "Send Request to Worker",
113
111
  readOnlyHint: false,
@@ -122,17 +120,17 @@ export function buildPbotWorkerTools(commands = {}, defaultBackend, workspaceBou
122
120
  properties: {
123
121
  workerId: {
124
122
  type: "string",
125
- description: "目标助手会话 ID(来自 worker_create 或 worker_discover)。",
123
+ description: "助手会话 ID(来自 worker_create 或 worker_discover)。",
126
124
  },
127
125
  message: {
128
126
  type: "string",
129
- description: "要发送的任务说明或追问内容。外部助手看不到你与用户的对话历史,首次派发时请写清背景、目标、相关文件路径、约束条件和期望产出。",
127
+ description: "任务说明或追问内容。外部助手看不到当前会话历史,首次派发需写清背景、目标、相关文件路径、约束和期望产出。",
130
128
  },
131
129
  waitMs: {
132
130
  type: "integer",
133
131
  minimum: 0,
134
132
  maximum: maxWaitMs,
135
- description: `最多等待结果的毫秒数(默认 ${defaultWaitMs});设为 0 可立即返回并在后台执行。`,
133
+ description: `最多等待毫秒数(默认 ${defaultWaitMs});0 表示立即返回转后台执行。`,
136
134
  },
137
135
  workspace,
138
136
  },
@@ -140,9 +138,8 @@ export function buildPbotWorkerTools(commands = {}, defaultBackend, workspaceBou
140
138
  },
141
139
  {
142
140
  name: "worker_response",
143
- description: "当外部助手在执行过程中暂停并请求确认或补充信息(返回 needsResponse: true)时,向其提交决定以继续执行。" +
144
- "支持三类请求:操作授权(kind=\"permission\")、问答表单(kind=\"form\")和链接确认(kind=\"url\")。" +
145
- `提交前先向用户确认;提交后默认最多等待 ${defaultWaitMs / 1000} 秒返回后续结果(waitMs 设为 0 立即返回)。`,
141
+ description: "回复外部助手暂停时发出的待处理请求(needsResponse: true),支持操作授权、表单问答与链接确认。" +
142
+ `提交前先向用户确认;提交后默认等待最多 ${defaultWaitMs / 1000} 秒返回后续结果。`,
146
143
  annotations: {
147
144
  title: "Respond to Worker Request",
148
145
  readOnlyHint: false,
@@ -162,26 +159,26 @@ export function buildPbotWorkerTools(commands = {}, defaultBackend, workspaceBou
162
159
  action: {
163
160
  type: "string",
164
161
  enum: [...acpElicitationActions],
165
- description: "处理方式:accept 表示同意授权、提交表单回答或确认链接;decline 表示拒绝;cancel 表示取消本次请求。",
162
+ description: "accept 同意/提交表单/确认链接;decline 拒绝;cancel 取消请求。",
166
163
  },
167
164
  requestId: {
168
165
  type: "string",
169
- description: "要回复的请求 ID(来自 pendingRequests[].requestId);仅一条待处理请求时可省略,多条时必填。",
166
+ description: "请求 ID(pendingRequests[].requestId);仅一条待处理请求时可省略,多条时必填。",
170
167
  },
171
168
  optionId: {
172
169
  type: "string",
173
- description: "仅授权请求(kind=\"permission\")且 action 不为 cancel 时可用:指定选项 ID(来自 pendingRequests[].options[].optionId),省略时默认单次允许或拒绝。",
170
+ description: "仅 permission 请求且 action≠cancel 时可用:指定 pendingRequests[].options[].optionId,省略则按 action 单次允许或拒绝。",
174
171
  },
175
172
  content: {
176
173
  type: "object",
177
174
  additionalProperties: true,
178
- description: "仅表单提问(kind=\"form\")且 action=\"accept\" 时可用:按 pendingRequests[].schema.properties 填写的回答对象(值为字符串、数字、布尔值或字符串数组)。",
175
+ description: "仅 form 请求且 action=\"accept\" 时可用:按 pendingRequests[].schema.properties 填写回答对象(值为字符串、数字、布尔值或字符串数组)。",
179
176
  },
180
177
  waitMs: {
181
178
  type: "integer",
182
179
  minimum: 0,
183
180
  maximum: maxWaitMs,
184
- description: `提交回复后最多等待后续结果的毫秒数(默认 ${defaultWaitMs});设为 0 立即返回。`,
181
+ description: `提交后最多等待毫秒数(默认 ${defaultWaitMs});0 表示立即返回。`,
185
182
  },
186
183
  workspace,
187
184
  },
@@ -189,8 +186,7 @@ export function buildPbotWorkerTools(commands = {}, defaultBackend, workspaceBou
189
186
  },
190
187
  {
191
188
  name: "worker_output",
192
- description: "获取或等待外部助手的最新执行结果。用于收取后台任务的产出、在等待超时(timedOut)后继续等待,或在长结果分页(含 nextOffset)时读取后续内容。" +
193
- "任务仍在运行时会等待其完成(也可能返回 timedOut 或 needsResponse),已结束则立即返回。",
189
+ description: "获取或等待外部助手的最新结果,用于收取后台产出、timedOut 后继续等待,或按 nextOffset 分页续读。任务已结束时立即返回,运行中最多等待 waitMs。",
194
190
  annotations: {
195
191
  title: "Get Worker Output",
196
192
  readOnlyHint: true,
@@ -205,18 +201,18 @@ export function buildPbotWorkerTools(commands = {}, defaultBackend, workspaceBou
205
201
  properties: {
206
202
  workerId: {
207
203
  type: "string",
208
- description: "要等待或获取结果的助手会话 ID。",
204
+ description: "助手会话 ID。",
209
205
  },
210
206
  offset: {
211
207
  type: "integer",
212
208
  minimum: 0,
213
- description: "结果读取起始位置(默认 0);翻页读取剩余内容时传入上次返回的 nextOffset。",
209
+ description: "读取起始位置(默认 0);翻页续读时传上次返回的 nextOffset。",
214
210
  },
215
211
  waitMs: {
216
212
  type: "integer",
217
213
  minimum: 0,
218
214
  maximum: maxWaitMs,
219
- description: `任务仍在运行时最多等待的毫秒数(默认 ${defaultWaitMs});任务已结束或翻页读取时会立即返回。`,
215
+ description: `运行中最多等待毫秒数(默认 ${defaultWaitMs});已结束或翻页时立即返回。`,
220
216
  },
221
217
  workspace,
222
218
  },
@@ -224,8 +220,7 @@ export function buildPbotWorkerTools(commands = {}, defaultBackend, workspaceBou
224
220
  },
225
221
  {
226
222
  name: "worker_discover",
227
- description: "了解当前可以委派哪些外部助手、查看已有助手会话的运行状态以便复用,或查询某个助手支持的模型与思考深度选项。" +
228
- "默认(target=\"overview\")同时返回可用助手与已有会话;仅在需要核对模型或思考深度可选值时再查 target=\"models\"(耗时较长)。",
223
+ description: "查询可用外部助手、已有会话状态,或某个助手支持的模型与思考深度。默认(overview)返回可用助手与已有会话;仅需核对模型或思考深度可选值时再查 models(需启动探测,耗时较长)。",
229
224
  annotations: {
230
225
  title: "Discover Workers, Backends & Models",
231
226
  readOnlyHint: true,
@@ -241,21 +236,21 @@ export function buildPbotWorkerTools(commands = {}, defaultBackend, workspaceBou
241
236
  target: {
242
237
  type: "string",
243
238
  enum: [...discoverTargets],
244
- description: "查询范围,默认 \"overview\"(同时返回可用助手与已有会话);\"workers\" 查全部或单个会话状态;\"backends\" 查可用助手列表;\"models\" 查指定助手支持的模型与思考深度。",
239
+ description: "overview(默认,可用助手与已有会话)、workers(全部或单个会话状态)、backends(可用助手)、models(指定助手的模型与思考深度)。",
245
240
  },
246
241
  workerId: {
247
242
  type: "string",
248
- description: "仅 target=\"workers\" 可用:指定单个助手会话 ID;不填则列出全部。",
243
+ description: "仅 target=\"workers\" 可用:指定单个会话 ID,省略列全部。",
249
244
  },
250
245
  backend: {
251
246
  type: "string",
252
247
  description: availableIds
253
- ? `仅 target="models" 可用(${modelsBackendHint}):目标外部助手标识,支持常见别名;当前可用:${availableIds}。`
254
- : `仅 target="models" 可用(${modelsBackendHint}):目标外部助手标识,支持常见别名。`,
248
+ ? `仅 target="models" 可用(${modelsBackendHint}):目标助手标识,支持别名;当前可用:${availableIds}。`
249
+ : `仅 target="models" 可用(${modelsBackendHint}):目标助手标识,支持别名。`,
255
250
  },
256
251
  model: {
257
252
  type: "string",
258
- description: "仅 target=\"models\" 可用:指定模型以查看该模型支持的思考深度选项。",
253
+ description: "仅 target=\"models\" 可用:指定模型以查看其支持的思考深度选项。",
259
254
  },
260
255
  workspace,
261
256
  },
@@ -268,7 +263,7 @@ export function buildWorkspaceMcpTools(workspaceBound = false) {
268
263
  return [
269
264
  {
270
265
  name: "workspace_mcp_discover",
271
- description: "发现当前工作区共享的外部工具服务(MCP)及其可用工具。不传 server 时列出可用服务;传入 server 时返回该服务提供的工具清单与参数说明。",
266
+ description: "查询当前工作区共享 MCP 服务(.pbot/mcp.json)。省略 server 列出服务;传入 server 返回其工具列表与参数说明。",
272
267
  annotations: {
273
268
  title: "Discover Workspace MCP Servers & Tools",
274
269
  readOnlyHint: true,
@@ -283,7 +278,7 @@ export function buildWorkspaceMcpTools(workspaceBound = false) {
283
278
  properties: {
284
279
  server: {
285
280
  type: "string",
286
- description: "目标工具服务名称;不填时列出工作区全部可用服务。",
281
+ description: "服务名称;省略列出工作区全部已配置服务。",
287
282
  },
288
283
  workspace,
289
284
  },
@@ -291,8 +286,7 @@ export function buildWorkspaceMcpTools(workspaceBound = false) {
291
286
  },
292
287
  {
293
288
  name: "workspace_mcp_call",
294
- description: "调用当前工作区共享的外部工具服务(MCP)中的指定工具,用于访问工作区接入的外部能力与数据源。" +
295
- "不确定工具名或参数格式时,先用 workspace_mcp_discover(server) 查询。",
289
+ description: "调用工作区共享 MCP 服务中的指定工具。不确定工具名或参数时先用 workspace_mcp_discover(server) 查询。",
296
290
  annotations: {
297
291
  title: "Call Workspace MCP Tool",
298
292
  readOnlyHint: false,
@@ -307,16 +301,16 @@ export function buildWorkspaceMcpTools(workspaceBound = false) {
307
301
  properties: {
308
302
  server: {
309
303
  type: "string",
310
- description: "目标工具服务名称(可通过 workspace_mcp_discover 获取)。",
304
+ description: "服务名称(来自 workspace_mcp_discover)。",
311
305
  },
312
306
  tool: {
313
307
  type: "string",
314
- description: "要调用的工具名称。",
308
+ description: "工具名称。",
315
309
  },
316
310
  arguments: {
317
311
  type: "object",
318
312
  additionalProperties: true,
319
- description: "传给目标工具的参数对象,不填则为空对象。",
313
+ description: "传给目标工具的参数对象,默认空对象。",
320
314
  },
321
315
  workspace,
322
316
  },
@@ -329,7 +323,7 @@ export function buildHistoryMcpTools(workspaceBound = false) {
329
323
  return [
330
324
  {
331
325
  name: "history_search",
332
- description: "搜索当前工作区跨宿主(pi、dsh、claude、antigravity 等)的历史问答与摘要归档。省略 query 时列出各会话;传入 query 按不区分大小写的连续关键词匹配原文与摘要。",
326
+ description: "搜索当前工作区跨宿主历史问答与摘要归档(不含工具调用日志)。省略 query 列出各会话或指定维度摘要;传入 query 按不区分大小写的连续关键词匹配。",
333
327
  annotations: {
334
328
  title: "Search Workspace History",
335
329
  readOnlyHint: true,
@@ -344,15 +338,15 @@ export function buildHistoryMcpTools(workspaceBound = false) {
344
338
  properties: {
345
339
  host: {
346
340
  type: "string",
347
- description: "可选来源筛选(如 pi、dsh、claude、antigravity);省略查全部宿主。",
341
+ description: "来源宿主筛选(如 pi、dsh、claude、antigravity、codex、qoder);省略查全部。",
348
342
  },
349
343
  dimension: {
350
344
  type: "string",
351
- description: "可选范围筛选:raw 表示仅搜原文,或指定摘要维度(如 monthly、session);省略查全部原文与维度摘要。",
345
+ description: "范围筛选:raw 仅原文,或指定摘要维度(如 monthly、session);省略查全部。",
352
346
  },
353
347
  query: {
354
348
  type: "string",
355
- description: "不区分大小写的连续关键词;省略时列出各会话(或指定维度摘要)。",
349
+ description: "连续关键词(不区分大小写);省略列会话或指定维度摘要。",
356
350
  },
357
351
  sessionId: {
358
352
  type: "string",
@@ -369,13 +363,13 @@ export function buildHistoryMcpTools(workspaceBound = false) {
369
363
  offset: {
370
364
  type: "integer",
371
365
  minimum: 0,
372
- description: "匹配结果偏移,默认 0。",
366
+ description: "结果偏移,默认 0。",
373
367
  },
374
368
  limit: {
375
369
  type: "integer",
376
370
  minimum: 1,
377
371
  maximum: historyPageLimits.search.max,
378
- description: `最多返回条数(1–${historyPageLimits.search.max}),默认 ${historyPageLimits.search.default}。`,
372
+ description: `返回条数(1–${historyPageLimits.search.max}),默认 ${historyPageLimits.search.default}。`,
379
373
  },
380
374
  workspace,
381
375
  },
@@ -383,7 +377,7 @@ export function buildHistoryMcpTools(workspaceBound = false) {
383
377
  },
384
378
  {
385
379
  name: "history_read",
386
- description: "按节点 id 读取当前工作区历史归档的正文与上下级节点(monthly、session、summary、exchange),支持从月度汇总下钻至单会话摘要与原始问答。正文过长时用 nextOffset 续读,子节点过多时用 nextChildrenOffset 续读。",
380
+ description: "按节点 id 读取历史正文与上下级(可从 monthly 汇总下钻至 session 摘要和 exchange 原文)。正文分页传 nextOffset,子节点分页传 nextChildrenOffset。",
387
381
  annotations: {
388
382
  title: "Read Workspace History Node",
389
383
  readOnlyHint: true,
@@ -398,16 +392,16 @@ export function buildHistoryMcpTools(workspaceBound = false) {
398
392
  properties: {
399
393
  id: {
400
394
  type: "string",
401
- description: "history_search 或上下级返回的节点 id。",
395
+ description: "节点 id(来自 history_search 或上下级)。",
402
396
  },
403
397
  host: {
404
398
  type: "string",
405
- description: "跨来源 ID 冲突时显式指定来源宿主。",
399
+ description: "跨宿主 id 冲突时指定来源宿主。",
406
400
  },
407
401
  offset: {
408
402
  type: "integer",
409
403
  minimum: 0,
410
- description: "正文字符偏移,默认 0。",
404
+ description: "正文字符偏移,默认 0;续读传上次 nextOffset。",
411
405
  },
412
406
  limit: {
413
407
  type: "integer",
@@ -418,7 +412,7 @@ export function buildHistoryMcpTools(workspaceBound = false) {
418
412
  childrenOffset: {
419
413
  type: "integer",
420
414
  minimum: 0,
421
- description: "子节点列表偏移,默认 0;续读传上页 nextChildrenOffset。",
415
+ description: "子节点偏移,默认 0;续读传上次 nextChildrenOffset。",
422
416
  },
423
417
  workspace,
424
418
  },
@@ -1,6 +1,10 @@
1
1
  import { type McpWorkerToolName } from "../../model/acp.js";
2
2
  export { buildHistoryMcpTools, buildPbotWorkerTools, buildWorkspaceMcpTools, pbotWorkerTools } from "./tool-contract.js";
3
3
  export type ProgressReporter = (message: string) => void;
4
+ export declare function buildMcpInstructions(options: {
5
+ workspaceMcp: boolean;
6
+ history: boolean;
7
+ }): string;
4
8
  export declare const mcpWorkerOnlyInstructions: string;
5
9
  export declare const mcpInstructions: string;
6
10
  export declare function defaultWorkerDirectory(): string;
@@ -30,6 +34,8 @@ export declare class McpWorkerRuntime {
30
34
  private resolveBackend;
31
35
  private resolveWorkspace;
32
36
  private workerService;
37
+ private resolveToolContext;
38
+ serverInstructions(): Promise<string>;
33
39
  toolDefinitions(): Promise<({
34
40
  name: "worker_create";
35
41
  description: string;
@@ -23,12 +23,21 @@ const protocolVersion = "2025-03-26";
23
23
  const readyTimeoutMs = 45_000;
24
24
  const reportPageSize = 16_000;
25
25
  const progressIntervalMs = 5_000;
26
- export const mcpWorkerOnlyInstructions = "提供跨助手协作能力(worker_*):可启动并调度其他外部 AI 助手在当前工作区中独立执行任务,适用于用户指定其他助手、需要特定模型或思考深度、获取独立审查/第二意见,或并行处理子任务。不需要借助其他助手时,优先自行完成或使用当前内置子代理。\n" +
27
- "使用流程:用 worker_create 启动目标助手(或用 worker_discover 复用已有会话)→ 用 worker_request 派发任务或继续追问 → 任务完成后可用 worker_close 结束会话。后台等待、超时续等(timedOut)或长结果翻页(nextOffset)用 worker_output;助手请求授权或提问(needsResponse)时,先向用户确认,再用 worker_response 回复。";
28
- export const mcpInstructions = "提供三类能力:\n" +
29
- "1. 跨助手协作(worker_*):启动并调度其他外部 AI 助手在当前工作区中独立执行任务,适用于用户指定其他助手、需要特定模型或思考深度、获取独立审查/第二意见,或并行处理子任务。不需要借助其他助手时,优先自行完成或使用当前内置子代理。使用流程:worker_create 启动助手(或 worker_discover 复用已有会话)→ worker_request 派发任务或追问 → 完成后 worker_close 结束;后台等待、超时续等(timedOut)或长结果翻页(nextOffset)用 worker_output;返回 needsResponse 时先向用户确认,再用 worker_response 回复。\n" +
30
- "2. 工作区共享外部工具(workspace_mcp_*):发现并调用当前工作区接入的外部工具服务与数据源(可与当前环境原生工具同时使用)。先用 workspace_mcp_discover 查看可用服务与工具说明,再用 workspace_mcp_call 调用。\n" +
31
- "3. 跨宿主历史查询(history_search / history_read):只读检索当前工作区在 Pi、dsh、Claude Code、Antigravity 等宿主中记录的历史问答与摘要归档。";
26
+ const workerCapabilityInstruction = "跨助手委派(worker_*):启动并调度其他外部助手在当前工作区独立执行任务;无需外部助手时优先自行完成或使用内置子代理。" +
27
+ "流程:worker_create 启动(或 worker_discover 复用)→ worker_request 派发/追问 → 完成后 worker_close;" +
28
+ "后台取结果、超时续等(timedOut)或翻页(nextOffset)用 worker_output;返回 needsResponse 时先向用户确认,再用 worker_response 回复。";
29
+ const workspaceMcpCapabilityInstruction = "工作区共享 MCP(workspace_mcp_*):先用 workspace_mcp_discover 查 .pbot/mcp.json 中的服务与工具,再用 workspace_mcp_call 调用。";
30
+ const historyCapabilityInstruction = "跨宿主历史(history_search / history_read):只读检索当前工作区跨宿主记录的历史问答与摘要归档。";
31
+ export function buildMcpInstructions(options) {
32
+ const parts = [workerCapabilityInstruction];
33
+ if (options.workspaceMcp)
34
+ parts.push(workspaceMcpCapabilityInstruction);
35
+ if (options.history)
36
+ parts.push(historyCapabilityInstruction);
37
+ return parts.length === 1 ? parts[0] : parts.map((text, index) => `${index + 1}. ${text}`).join("\n");
38
+ }
39
+ export const mcpWorkerOnlyInstructions = buildMcpInstructions({ workspaceMcp: false, history: false });
40
+ export const mcpInstructions = buildMcpInstructions({ workspaceMcp: true, history: true });
32
41
  export function defaultWorkerDirectory() {
33
42
  if (process.env.PBOT_MCP_AGENT_DIR)
34
43
  return process.env.PBOT_MCP_AGENT_DIR;
@@ -214,7 +223,7 @@ export class McpWorkerRuntime {
214
223
  }
215
224
  return entry;
216
225
  }
217
- async toolDefinitions() {
226
+ async resolveToolContext() {
218
227
  let commands;
219
228
  let includeWorkspaceMcp = !this.#nativeWorkspaceMcp;
220
229
  let includeHistory = !this.#nativeHistory;
@@ -229,6 +238,14 @@ export class McpWorkerRuntime {
229
238
  }
230
239
  }
231
240
  catch { /* Fall back to registered built-in harnesses when cwd is outside an enabled workspace. */ }
241
+ return { commands, includeWorkspaceMcp, includeHistory };
242
+ }
243
+ async serverInstructions() {
244
+ const { includeWorkspaceMcp, includeHistory } = await this.resolveToolContext();
245
+ return buildMcpInstructions({ workspaceMcp: includeWorkspaceMcp, history: includeHistory });
246
+ }
247
+ async toolDefinitions() {
248
+ const { commands, includeWorkspaceMcp, includeHistory } = await this.resolveToolContext();
232
249
  const defaultBackend = this.#defaultBackend ? canonicalAcpBackend(this.#defaultBackend, commands) : undefined;
233
250
  const workspaceBound = Boolean(pluginMcpWorkspaceRoot());
234
251
  return [
@@ -502,7 +519,7 @@ export async function handleMcpRequest(runtime, message, notify) {
502
519
  protocolVersion: requested || protocolVersion,
503
520
  capabilities: { tools: {} },
504
521
  serverInfo: { name: "personal-bot", version: packageVersion },
505
- instructions: runtime.nativeWorkspaceMcp ? mcpWorkerOnlyInstructions : mcpInstructions,
522
+ instructions: await runtime.serverInstructions(),
506
523
  },
507
524
  };
508
525
  }