personal-bot 0.3.7 → 0.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude-plugin/marketplace.json +3 -3
- package/.claude-plugin/plugin.json +2 -2
- package/README.md +5 -8
- package/README.zh-CN.md +5 -8
- package/bin/pbot-pi-acp.mjs +1 -1
- package/docs/architecture/design.md +2 -2
- package/docs/architecture/extensibility.md +4 -4
- package/docs/architecture/model-context.md +6 -3
- package/docs/guides/cross-harness-workers.md +5 -5
- package/docs/guides/history.md +1 -3
- package/docs/guides/workspace-configuration.md +5 -5
- package/docs/hosts/claude-code.md +3 -3
- package/docs/hosts/codex-qoder.md +4 -2
- package/hooks/hooks.json +3 -0
- package/lib/antigravity-plugin/bin/pbot-pi-acp.mjs +1 -1
- package/lib/antigravity-plugin/lib/extension/acp/member.d.ts +1 -1
- package/lib/antigravity-plugin/lib/extension/acp/member.js +11 -10
- package/lib/antigravity-plugin/lib/extension/acp-worker.js +349 -204
- package/lib/antigravity-plugin/lib/extension/cli.js +596 -572
- package/lib/antigravity-plugin/lib/extension/hosts/dsh/acp-member.js +1 -1
- package/lib/antigravity-plugin/lib/extension/hosts/pi/acp-member.js +3 -4
- package/lib/antigravity-plugin/lib/extension/hosts/plugin-runtime.js +1 -12
- package/lib/antigravity-plugin/lib/extension/mcp.js +463 -379
- package/lib/antigravity-plugin/lib/integrations/agent-resources.d.ts +2 -2
- package/lib/antigravity-plugin/lib/integrations/agent-resources.js +3 -3
- package/lib/antigravity-plugin/lib/integrations/hosts/antigravity/adapter.js +0 -1
- package/lib/antigravity-plugin/lib/integrations/hosts/claude/adapter.js +1 -2
- package/lib/antigravity-plugin/lib/integrations/hosts/dsh/resources.d.ts +1 -1
- package/lib/antigravity-plugin/lib/integrations/hosts/prompt-hooks.js +4 -7
- package/lib/antigravity-plugin/lib/model/acp.d.ts +29 -35
- package/lib/antigravity-plugin/lib/model/agent.d.ts +33 -17
- package/lib/antigravity-plugin/lib/model/agent.js +0 -1
- package/lib/antigravity-plugin/lib/services/history/summary-dimensions/monthly.js +1 -1
- package/lib/antigravity-plugin/lib/services/history/summary-dimensions/session.js +6 -3
- package/lib/antigravity-plugin/lib/services/history/summary-runner.js +3 -3
- package/lib/antigravity-plugin/lib/storage/acp-files.d.ts +5 -8
- package/lib/antigravity-plugin/lib/storage/acp-files.js +34 -40
- package/lib/antigravity-plugin/lib/storage/agent-files.d.ts +19 -10
- package/lib/antigravity-plugin/lib/storage/agent-files.js +147 -43
- package/lib/antigravity-plugin/lib/storage/history-files.js +3 -2
- package/lib/antigravity-plugin/package.json +1 -1
- package/lib/antigravity-plugin/plugin.json +2 -2
- package/lib/antigravity-plugin/resources/agents/coordinator.md +2 -4
- package/lib/antigravity-plugin/resources/agents/general-purpose.md +2 -4
- package/lib/antigravity-plugin/resources/prompts/history-monthly-summary.md +6 -11
- package/lib/antigravity-plugin/resources/prompts/history-summary.md +6 -11
- package/lib/antigravity-plugin/resources/prompts/plugin-coordinator.md +1 -1
- package/lib/antigravity-plugin/resources/prompts/workspace.md +16 -23
- package/lib/antigravity-plugin/resources/skills/project-maintenance/SKILL.md +14 -21
- package/lib/antigravity-plugin/resources/skills/provider-connections/SKILL.md +23 -36
- package/lib/antigravity-plugin/resources/templates/workspace-agents.md +5 -13
- package/lib/antigravity-plugin/skills/pbot/SKILL.md +6 -23
- package/lib/antigravity-plugin/skills/project-maintenance/SKILL.md +14 -21
- package/lib/antigravity-plugin/skills/provider-connections/SKILL.md +23 -36
- package/lib/codex-marketplace/plugins/personal-bot/.codex-plugin/plugin.json +2 -2
- package/lib/codex-marketplace/plugins/personal-bot/.mcp.json +2 -2
- package/lib/codex-marketplace/plugins/personal-bot/hooks/hooks.json +3 -3
- package/lib/codex-marketplace/plugins/personal-bot/skills/pbot/SKILL.md +11 -3
- package/lib/extension/acp/member.d.ts +1 -1
- package/lib/extension/acp/member.js +11 -10
- package/lib/extension/acp/worker.js +34 -33
- package/lib/extension/acp-worker.js +349 -204
- package/lib/extension/cli.js +596 -572
- package/lib/extension/hosts/dsh/acp-member.js +1 -1
- package/lib/extension/hosts/dsh/command.js +2 -2
- package/lib/extension/hosts/dsh/workspace.js +5 -5
- package/lib/extension/hosts/pi/acp-member.js +3 -4
- package/lib/extension/hosts/plugin-runtime.js +1 -12
- package/lib/extension/mcp/tool-contract.d.ts +8 -50
- package/lib/extension/mcp/tool-contract.js +61 -107
- package/lib/extension/mcp/workers.d.ts +7 -27
- package/lib/extension/mcp/workers.js +40 -24
- package/lib/extension/mcp.js +463 -379
- package/lib/integrations/acp/agents.d.ts +2 -3
- package/lib/integrations/acp/agents.js +22 -22
- package/lib/integrations/acp/harnesses/claude.js +1 -1
- package/lib/integrations/agent-resources.d.ts +2 -2
- package/lib/integrations/agent-resources.js +3 -3
- package/lib/integrations/hosts/antigravity/adapter.js +0 -1
- package/lib/integrations/hosts/claude/adapter.js +1 -2
- package/lib/integrations/hosts/dsh/resources.d.ts +1 -1
- package/lib/integrations/hosts/prompt-hooks.js +4 -7
- package/lib/model/acp.d.ts +29 -35
- package/lib/model/agent.d.ts +33 -17
- package/lib/model/agent.js +0 -1
- package/lib/qoder-plugin/.mcp.json +2 -2
- package/lib/qoder-plugin/.qoder-plugin/plugin.json +2 -2
- package/lib/qoder-plugin/hooks/hooks.json +3 -3
- package/lib/qoder-plugin/skills/pbot/SKILL.md +11 -3
- package/lib/services/agents/acp-run.d.ts +6 -4
- package/lib/services/agents/acp-run.js +62 -43
- package/lib/services/agents/agent-run.d.ts +10 -6
- package/lib/services/agents/agent-run.js +142 -65
- package/lib/services/agents/agent-service.d.ts +3 -21
- package/lib/services/agents/agent-service.js +182 -128
- package/lib/services/history/summary-dimensions/monthly.js +1 -1
- package/lib/services/history/summary-dimensions/session.js +6 -3
- package/lib/services/history/summary-runner.js +3 -3
- package/lib/storage/acp-files.d.ts +5 -8
- package/lib/storage/acp-files.js +34 -40
- package/lib/storage/agent-files.d.ts +19 -10
- package/lib/storage/agent-files.js +147 -43
- package/lib/storage/history-files.js +3 -2
- package/lib/tools/history/contract.d.ts +1 -1
- package/lib/tools/history/contract.js +14 -16
- package/package.json +2 -2
- package/resources/agents/coordinator.md +2 -4
- package/resources/agents/general-purpose.md +2 -4
- package/resources/antigravity/skills/pbot/SKILL.md +6 -23
- package/resources/claude/skills/pbot/SKILL.md +6 -23
- package/resources/plugin/skills/pbot/SKILL.md +11 -3
- package/resources/prompts/history-coordinator.md +1 -1
- package/resources/prompts/history-monthly-summary.md +6 -11
- package/resources/prompts/history-summary.md +6 -11
- package/resources/prompts/plugin-coordinator.md +1 -1
- package/resources/prompts/workspace.md +16 -23
- package/resources/skills/project-maintenance/SKILL.md +14 -21
- package/resources/skills/provider-connections/SKILL.md +23 -36
- package/resources/templates/workspace-agents.md +5 -13
- package/src/extension/acp/member.ts +14 -11
- package/src/extension/acp/worker.ts +31 -28
- package/src/extension/cli/commands/mcp.ts +1 -1
- package/src/extension/cli/commands/upgrade.ts +8 -36
- package/src/extension/cli/commands/workspace.ts +3 -8
- package/src/extension/cli/index.ts +1 -2
- package/src/extension/hosts/dsh/acp-member.ts +1 -1
- package/src/extension/hosts/dsh/command.ts +2 -2
- package/src/extension/hosts/dsh/workspace.ts +5 -4
- package/src/extension/hosts/pi/acp-member.ts +3 -4
- package/src/extension/hosts/pi/command.ts +2 -2
- package/src/extension/hosts/pi/events.ts +1 -1
- package/src/extension/hosts/pi/lifecycle.ts +0 -2
- package/src/extension/hosts/plugin-runtime.ts +1 -11
- package/src/extension/mcp/tool-contract.ts +61 -108
- package/src/extension/mcp/workers.ts +39 -24
- package/src/integrations/acp/agents.ts +28 -27
- package/src/integrations/acp/harnesses/claude.ts +1 -1
- package/src/integrations/agent-resources.ts +5 -5
- package/src/integrations/hosts/antigravity/adapter.ts +0 -1
- package/src/integrations/hosts/claude/adapter.ts +1 -2
- package/src/integrations/hosts/dsh/resources.ts +1 -1
- package/src/integrations/hosts/dsh/session.ts +2 -2
- package/src/integrations/hosts/prompt-hooks.ts +3 -6
- package/src/integrations/installation/cli-update.ts +2 -2
- package/src/integrations/installation/installers/claude.ts +4 -4
- package/src/integrations/installation/installers/qoder.ts +5 -5
- package/src/integrations/installation/upgraders/antigravity.ts +57 -15
- package/src/integrations/installation/upgraders/claude.ts +1 -4
- package/src/integrations/installation/upgraders/codex.ts +85 -15
- package/src/integrations/installation/upgraders/dsh.ts +46 -24
- package/src/integrations/installation/upgraders/pi.ts +18 -11
- package/src/integrations/installation/upgraders/qoder.ts +95 -20
- package/src/model/acp.ts +27 -29
- package/src/model/agent.ts +80 -16
- package/src/model/installation.ts +0 -2
- package/src/pbot.ts +3 -3
- package/src/services/agents/acp-run.ts +81 -49
- package/src/services/agents/agent-run.ts +154 -56
- package/src/services/agents/agent-service.ts +206 -135
- package/src/services/history/summary-dimensions/monthly.ts +1 -1
- package/src/services/history/summary-dimensions/session.ts +6 -3
- package/src/services/history/summary-runner.ts +3 -3
- package/src/services/installation/upgrade-service.ts +1 -5
- package/src/storage/acp-files.ts +50 -45
- package/src/storage/agent-files.ts +159 -46
- package/src/storage/history-files.ts +3 -2
- package/src/tools/history/contract.ts +14 -16
- package/lib/antigravity-plugin/lib/services/workspace/plugin-releases.d.ts +0 -15
- package/lib/antigravity-plugin/lib/services/workspace/plugin-releases.js +0 -126
- package/lib/services/workspace/plugin-releases.d.ts +0 -15
- package/lib/services/workspace/plugin-releases.js +0 -126
- package/src/services/workspace/plugin-releases.ts +0 -121
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { randomUUID } from "node:crypto";
|
|
2
2
|
import { existsSync } from "node:fs";
|
|
3
3
|
import { realpath, stat } from "node:fs/promises";
|
|
4
|
-
import { homedir } from "node:os";
|
|
5
4
|
import { isAbsolute, join } from "node:path";
|
|
6
5
|
import { setTimeout as delay } from "node:timers/promises";
|
|
7
6
|
import { object } from "../../common/json.js";
|
|
@@ -23,27 +22,23 @@ const protocolVersion = "2025-03-26";
|
|
|
23
22
|
const readyTimeoutMs = 45_000;
|
|
24
23
|
const reportPageSize = 16_000;
|
|
25
24
|
const progressIntervalMs = 5_000;
|
|
26
|
-
const workerCapabilityInstruction = "
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
const workspaceMcpCapabilityInstruction = "工作区共享 MCP(workspace_mcp_*):先用 workspace_mcp_discover 查 .pbot/mcp.json 中的服务与工具,再用 workspace_mcp_call 调用。";
|
|
30
|
-
const historyCapabilityInstruction = "跨宿主历史(history_search / history_read):只读检索当前工作区跨宿主记录的历史问答与摘要归档。";
|
|
25
|
+
const workerCapabilityInstruction = "用户或工作区分工指定其他助手或特定模型时,可在当前工作区委派任务。常规任务优先自行处理或使用宿主内置子代理。";
|
|
26
|
+
const workspaceMcpCapabilityInstruction = "可调用本工作区 .pbot/mcp.json 中登记的 MCP 工具。";
|
|
27
|
+
const historyCapabilityInstruction = "可检索本工作区各宿主归档的问答和摘要。";
|
|
31
28
|
export function buildMcpInstructions(options) {
|
|
32
29
|
const parts = [workerCapabilityInstruction];
|
|
33
30
|
if (options.workspaceMcp)
|
|
34
31
|
parts.push(workspaceMcpCapabilityInstruction);
|
|
35
32
|
if (options.history)
|
|
36
33
|
parts.push(historyCapabilityInstruction);
|
|
37
|
-
return parts.
|
|
34
|
+
return parts.join("\n");
|
|
38
35
|
}
|
|
39
36
|
export const mcpWorkerOnlyInstructions = buildMcpInstructions({ workspaceMcp: false, history: false });
|
|
40
37
|
export const mcpInstructions = buildMcpInstructions({ workspaceMcp: true, history: true });
|
|
41
|
-
export function defaultWorkerDirectory() {
|
|
38
|
+
export function defaultWorkerDirectory(workspaceRoot) {
|
|
42
39
|
if (process.env.PBOT_MCP_AGENT_DIR)
|
|
43
40
|
return process.env.PBOT_MCP_AGENT_DIR;
|
|
44
|
-
|
|
45
|
-
return join(process.env.PLUGIN_DATA, "subagents");
|
|
46
|
-
return join(homedir(), ".pbot/subagents");
|
|
41
|
+
return join(workspaceRoot, ".pbot", "subagents");
|
|
47
42
|
}
|
|
48
43
|
function workerCommandTool(name) {
|
|
49
44
|
const full = name.startsWith("worker_") ? name : `worker_${name}`;
|
|
@@ -154,6 +149,7 @@ function presentWorker(value) {
|
|
|
154
149
|
}
|
|
155
150
|
export class McpWorkerRuntime {
|
|
156
151
|
#services = new Map();
|
|
152
|
+
#workerWorkspaces = new Map();
|
|
157
153
|
#bridge = new WorkspaceMcpBridge();
|
|
158
154
|
#sessionId;
|
|
159
155
|
#directory;
|
|
@@ -161,7 +157,7 @@ export class McpWorkerRuntime {
|
|
|
161
157
|
#nativeWorkspaceMcp;
|
|
162
158
|
#nativeHistory;
|
|
163
159
|
#closing;
|
|
164
|
-
constructor(directory
|
|
160
|
+
constructor(directory, sessionId = process.env.PBOT_MCP_SESSION_ID || ("mcp-" + randomUUID()), defaultBackend = process.env.PBOT_HOST || undefined, nativeWorkspaceMcp = /^(1|true)$/i.test(process.env.PBOT_NATIVE_WORKSPACE_MCP ?? ""), nativeHistory = /^(1|true)$/i.test(process.env.PBOT_NATIVE_HISTORY ?? "")) {
|
|
165
161
|
this.#directory = directory;
|
|
166
162
|
this.#sessionId = sessionId;
|
|
167
163
|
this.#defaultBackend = defaultBackend?.trim() || undefined;
|
|
@@ -180,7 +176,7 @@ export class McpWorkerRuntime {
|
|
|
180
176
|
env: {
|
|
181
177
|
PBOT_HOST: this.#defaultBackend,
|
|
182
178
|
PBOT_WORKSPACE_ROOT: root,
|
|
183
|
-
PBOT_MCP_AGENT_DIR: this.#directory,
|
|
179
|
+
PBOT_MCP_AGENT_DIR: this.#directory ?? defaultWorkerDirectory(root),
|
|
184
180
|
PBOT_MCP_SESSION_ID: this.#sessionId,
|
|
185
181
|
PBOT_NATIVE_WORKSPACE_MCP: "1",
|
|
186
182
|
PBOT_NATIVE_HISTORY: "1",
|
|
@@ -207,13 +203,26 @@ export class McpWorkerRuntime {
|
|
|
207
203
|
requireThat((await stat(root)).isDirectory(), "工作区路径不是目录。");
|
|
208
204
|
return root;
|
|
209
205
|
}
|
|
206
|
+
async resolveWorkerWorkspace(workerId, defaultWorkspace) {
|
|
207
|
+
const known = this.#workerWorkspaces.get(workerId);
|
|
208
|
+
if (known)
|
|
209
|
+
return known;
|
|
210
|
+
for (const [root, entry] of this.#services) {
|
|
211
|
+
if (entry.service.has(workerId, entry.owner)) {
|
|
212
|
+
this.#workerWorkspaces.set(workerId, root);
|
|
213
|
+
return root;
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
return this.resolveWorkspace(defaultWorkspace);
|
|
217
|
+
}
|
|
210
218
|
workerService(root, commands = {}) {
|
|
211
219
|
let entry = this.#services.get(root);
|
|
212
220
|
if (!entry) {
|
|
213
|
-
const
|
|
221
|
+
const directory = this.#directory ?? defaultWorkerDirectory(root);
|
|
222
|
+
const host = new AcpWorkerHost(directory, commands);
|
|
214
223
|
entry = {
|
|
215
224
|
host,
|
|
216
|
-
service: new AgentService(root,
|
|
225
|
+
service: new AgentService(root, directory, host),
|
|
217
226
|
owner: { sessionId: this.#sessionId, leaf: null, branch: [] },
|
|
218
227
|
};
|
|
219
228
|
this.#services.set(root, entry);
|
|
@@ -319,17 +328,20 @@ export class McpWorkerRuntime {
|
|
|
319
328
|
await delay(100);
|
|
320
329
|
}
|
|
321
330
|
}
|
|
322
|
-
async callTool(toolName, input, progress) {
|
|
331
|
+
async callTool(toolName, input, progress, defaultWorkspace) {
|
|
323
332
|
const { name, args: rawArgs } = parseMcpToolCall(toolName, input);
|
|
324
333
|
requireThat(!this.#closing, "Personal Bot MCP 服务已关闭。");
|
|
325
|
-
const
|
|
334
|
+
const isWorkerScoped = name === "worker_close" || name === "worker_request" || name === "worker_response" || name === "worker_output";
|
|
335
|
+
const root = isWorkerScoped
|
|
336
|
+
? await this.resolveWorkerWorkspace(asString(rawArgs, "workerId", true), defaultWorkspace)
|
|
337
|
+
: await this.resolveWorkspace(asString(rawArgs, "workspace") ?? defaultWorkspace);
|
|
326
338
|
const configuration = await readWorkspaceConfig(root);
|
|
327
339
|
requireThat(!this.#closing, "Personal Bot MCP 服务已关闭。");
|
|
328
340
|
requireThat(configuration.enabled, workspaceDisabledMessage(configuration));
|
|
329
341
|
switch (name) {
|
|
330
342
|
case "workspace_mcp_discover":
|
|
331
343
|
case "workspace_mcp_call": {
|
|
332
|
-
requireThat(!this.#nativeWorkspaceMcp, "当前宿主已原生挂载工作区
|
|
344
|
+
requireThat(!this.#nativeWorkspaceMcp, "当前宿主已原生挂载工作区 MCP 服务,请直接调用对应工具。");
|
|
333
345
|
requireThat(workspaceFeatures(configuration).mcp, `工作区统一 MCP 功能已在 ${configuration.path} 中停用(features.mcp: false)。`);
|
|
334
346
|
if (name === "workspace_mcp_discover")
|
|
335
347
|
return this.#bridge.discover(root, asString(rawArgs, "server"));
|
|
@@ -384,13 +396,12 @@ export class McpWorkerRuntime {
|
|
|
384
396
|
const backend = this.resolveBackend(rawArgs, configuration.acp, false);
|
|
385
397
|
const model = asString(rawArgs, "model");
|
|
386
398
|
const thinking = asString(rawArgs, "thinking");
|
|
387
|
-
const cwd = asString(rawArgs, "cwd");
|
|
388
399
|
const created = await service.start({
|
|
389
400
|
backend,
|
|
390
401
|
...(model ? { model } : {}),
|
|
391
402
|
...(thinking ? { thinking } : {}),
|
|
392
|
-
...(cwd ? { cwd } : {}),
|
|
393
403
|
}, owner);
|
|
404
|
+
this.#workerWorkspaces.set(created.agentId, root);
|
|
394
405
|
const ready = await this.waitReady(service, owner, created.agentId, readyTimeoutMs, progress);
|
|
395
406
|
return {
|
|
396
407
|
...presentWorker(ready),
|
|
@@ -461,21 +472,25 @@ export class McpWorkerRuntime {
|
|
|
461
472
|
requireThat(backendRaw === undefined && model === undefined, '参数 backend / model 仅在 target="models" 时可用。');
|
|
462
473
|
}
|
|
463
474
|
if (target === "overview") {
|
|
475
|
+
const workers = service.list(owner);
|
|
476
|
+
for (const item of workers)
|
|
477
|
+
this.#workerWorkspaces.set(item.agentId, root);
|
|
464
478
|
return {
|
|
465
479
|
target,
|
|
466
480
|
backends: inspectAcpBackends(configuration.acp),
|
|
467
|
-
workers:
|
|
481
|
+
workers: workers.map(presentWorker),
|
|
468
482
|
};
|
|
469
483
|
}
|
|
470
484
|
if (target === "backends") {
|
|
471
485
|
return { target, backends: inspectAcpBackends(configuration.acp) };
|
|
472
486
|
}
|
|
473
487
|
if (target === "workers") {
|
|
488
|
+
const workers = workerId ? [service.status(workerId, owner)] : service.list(owner);
|
|
489
|
+
for (const item of workers)
|
|
490
|
+
this.#workerWorkspaces.set(item.agentId, root);
|
|
474
491
|
return {
|
|
475
492
|
target,
|
|
476
|
-
workers:
|
|
477
|
-
? [presentWorker(service.status(workerId, owner))]
|
|
478
|
-
: service.list(owner).map(presentWorker),
|
|
493
|
+
workers: workers.map(presentWorker),
|
|
479
494
|
};
|
|
480
495
|
}
|
|
481
496
|
const backend = this.resolveBackend(rawArgs, configuration.acp, true);
|
|
@@ -492,6 +507,7 @@ export class McpWorkerRuntime {
|
|
|
492
507
|
return this.#closing;
|
|
493
508
|
const entries = [...this.#services.values()];
|
|
494
509
|
this.#services.clear();
|
|
510
|
+
this.#workerWorkspaces.clear();
|
|
495
511
|
this.#closing = Promise.allSettled([
|
|
496
512
|
this.#bridge.close(),
|
|
497
513
|
...entries.map(({ service, owner }) => service.close(owner, preserve)),
|