personal-bot 0.3.6 → 0.4.0
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 +2 -2
- package/.claude-plugin/plugin.json +1 -1
- package/README.md +5 -8
- package/README.zh-CN.md +5 -8
- package/bin/pbot-pi-acp.mjs +1 -1
- package/docs/README.md +1 -1
- package/docs/architecture/design.md +2 -2
- package/docs/architecture/extensibility.md +1 -1
- package/docs/architecture/model-context.md +1 -2
- package/docs/guides/capabilities.md +4 -8
- package/docs/guides/cross-harness-workers.md +4 -4
- package/docs/guides/history.md +1 -3
- package/docs/guides/workspace-configuration.md +4 -4
- package/docs/hosts/claude-code.md +2 -2
- package/docs/hosts/codex-qoder.md +1 -1
- 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 +348 -203
- package/lib/antigravity-plugin/lib/extension/cli.js +574 -549
- 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 +0 -11
- package/lib/antigravity-plugin/lib/extension/mcp.js +462 -326
- package/lib/antigravity-plugin/lib/integrations/agent-resources.js +2 -2
- 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/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/package.json +1 -1
- package/lib/antigravity-plugin/plugin.json +1 -1
- package/lib/antigravity-plugin/resources/agents/coordinator.md +3 -7
- package/lib/antigravity-plugin/resources/agents/general-purpose.md +3 -3
- package/lib/antigravity-plugin/resources/prompts/plugin-coordinator.md +1 -2
- package/lib/antigravity-plugin/resources/prompts/workspace.md +12 -16
- package/lib/antigravity-plugin/resources/skills/provider-connections/SKILL.md +7 -6
- package/lib/antigravity-plugin/resources/templates/workspace-agents.md +0 -4
- package/lib/antigravity-plugin/skills/pbot/SKILL.md +14 -6
- package/lib/antigravity-plugin/skills/provider-connections/SKILL.md +7 -6
- package/lib/codex-marketplace/plugins/personal-bot/.codex-plugin/plugin.json +1 -1
- 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 +2 -2
- 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 +348 -203
- package/lib/extension/cli.js +574 -549
- package/lib/extension/hosts/dsh/acp-member.js +1 -1
- package/lib/extension/hosts/dsh/command.js +1 -1
- package/lib/extension/hosts/dsh/workspace.js +1 -3
- package/lib/extension/hosts/pi/acp-member.js +3 -4
- package/lib/extension/hosts/plugin-runtime.js +0 -11
- package/lib/extension/mcp/tool-contract.d.ts +8 -50
- package/lib/extension/mcp/tool-contract.js +48 -62
- package/lib/extension/mcp/workers.d.ts +13 -27
- package/lib/extension/mcp/workers.js +60 -25
- package/lib/extension/mcp.js +462 -326
- 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.js +2 -2
- 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 +1 -1
- package/lib/qoder-plugin/hooks/hooks.json +3 -3
- package/lib/qoder-plugin/skills/pbot/SKILL.md +2 -2
- 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 +180 -126
- 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/tools/history/contract.js +12 -12
- package/package.json +1 -1
- package/resources/agents/coordinator.md +3 -7
- package/resources/agents/general-purpose.md +3 -3
- package/resources/antigravity/skills/pbot/SKILL.md +14 -6
- package/resources/claude/skills/pbot/SKILL.md +14 -6
- package/resources/plugin/skills/pbot/SKILL.md +2 -2
- package/resources/prompts/history-coordinator.md +1 -2
- package/resources/prompts/plugin-coordinator.md +1 -2
- package/resources/prompts/workspace.md +12 -16
- package/resources/skills/provider-connections/SKILL.md +7 -6
- package/resources/templates/workspace-agents.md +0 -4
- package/src/extension/acp/member.ts +14 -11
- package/src/extension/acp/worker.ts +31 -28
- 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 +1 -1
- package/src/extension/hosts/dsh/workspace.ts +1 -3
- package/src/extension/hosts/pi/acp-member.ts +3 -4
- package/src/extension/hosts/pi/command.ts +1 -1
- package/src/extension/hosts/pi/lifecycle.ts +0 -2
- package/src/extension/hosts/plugin-runtime.ts +0 -10
- package/src/extension/mcp/tool-contract.ts +48 -62
- package/src/extension/mcp/workers.ts +66 -27
- package/src/integrations/acp/agents.ts +28 -27
- package/src/integrations/acp/harnesses/claude.ts +1 -1
- package/src/integrations/agent-resources.ts +2 -2
- package/src/integrations/hosts/dsh/session.ts +2 -2
- 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 +2 -2
- 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 +204 -133
- 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/tools/history/contract.ts +12 -12
- 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/antigravity-plugin/resources/references/compute-finance.md +0 -22
- package/lib/antigravity-plugin/resources/references/compute.md +0 -16
- package/lib/antigravity-plugin/resources/references/task-conductor.md +0 -25
- package/lib/services/workspace/plugin-releases.d.ts +0 -15
- package/lib/services/workspace/plugin-releases.js +0 -126
- package/resources/references/compute-finance.md +0 -22
- package/resources/references/compute.md +0 -16
- package/resources/references/task-conductor.md +0 -25
- package/src/services/workspace/plugin-releases.ts +0 -121
|
@@ -1,9 +1,13 @@
|
|
|
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
|
-
export declare function defaultWorkerDirectory(): string;
|
|
10
|
+
export declare function defaultWorkerDirectory(workspaceRoot: string): string;
|
|
7
11
|
/** Parse Pi/dsh `/pbot worker ...` CLI arguments into a canonical MCP tool call. */
|
|
8
12
|
export declare function parseWorkerCommand(raw: string): {
|
|
9
13
|
tool: McpWorkerToolName;
|
|
@@ -29,7 +33,10 @@ export declare class McpWorkerRuntime {
|
|
|
29
33
|
get nativeHistory(): boolean;
|
|
30
34
|
private resolveBackend;
|
|
31
35
|
private resolveWorkspace;
|
|
36
|
+
private resolveWorkerWorkspace;
|
|
32
37
|
private workerService;
|
|
38
|
+
private resolveToolContext;
|
|
39
|
+
serverInstructions(): Promise<string>;
|
|
33
40
|
toolDefinitions(): Promise<({
|
|
34
41
|
name: "worker_create";
|
|
35
42
|
description: string;
|
|
@@ -57,10 +64,6 @@ export declare class McpWorkerRuntime {
|
|
|
57
64
|
type: string;
|
|
58
65
|
description: string;
|
|
59
66
|
};
|
|
60
|
-
cwd: {
|
|
61
|
-
type: string;
|
|
62
|
-
description: string;
|
|
63
|
-
};
|
|
64
67
|
workspace: {
|
|
65
68
|
type: string;
|
|
66
69
|
description: string;
|
|
@@ -95,14 +98,10 @@ export declare class McpWorkerRuntime {
|
|
|
95
98
|
type: string;
|
|
96
99
|
description: string;
|
|
97
100
|
};
|
|
98
|
-
workspace: {
|
|
99
|
-
type: string;
|
|
100
|
-
description: string;
|
|
101
|
-
};
|
|
102
101
|
backend?: never;
|
|
103
102
|
model?: never;
|
|
104
103
|
thinking?: never;
|
|
105
|
-
|
|
104
|
+
workspace?: never;
|
|
106
105
|
message?: never;
|
|
107
106
|
waitMs?: never;
|
|
108
107
|
action?: never;
|
|
@@ -142,14 +141,10 @@ export declare class McpWorkerRuntime {
|
|
|
142
141
|
maximum: number;
|
|
143
142
|
description: string;
|
|
144
143
|
};
|
|
145
|
-
workspace: {
|
|
146
|
-
type: string;
|
|
147
|
-
description: string;
|
|
148
|
-
};
|
|
149
144
|
backend?: never;
|
|
150
145
|
model?: never;
|
|
151
146
|
thinking?: never;
|
|
152
|
-
|
|
147
|
+
workspace?: never;
|
|
153
148
|
action?: never;
|
|
154
149
|
requestId?: never;
|
|
155
150
|
optionId?: never;
|
|
@@ -201,14 +196,10 @@ export declare class McpWorkerRuntime {
|
|
|
201
196
|
maximum: number;
|
|
202
197
|
description: string;
|
|
203
198
|
};
|
|
204
|
-
workspace: {
|
|
205
|
-
type: string;
|
|
206
|
-
description: string;
|
|
207
|
-
};
|
|
208
199
|
backend?: never;
|
|
209
200
|
model?: never;
|
|
210
201
|
thinking?: never;
|
|
211
|
-
|
|
202
|
+
workspace?: never;
|
|
212
203
|
message?: never;
|
|
213
204
|
offset?: never;
|
|
214
205
|
target?: never;
|
|
@@ -244,14 +235,10 @@ export declare class McpWorkerRuntime {
|
|
|
244
235
|
maximum: number;
|
|
245
236
|
description: string;
|
|
246
237
|
};
|
|
247
|
-
workspace: {
|
|
248
|
-
type: string;
|
|
249
|
-
description: string;
|
|
250
|
-
};
|
|
251
238
|
backend?: never;
|
|
252
239
|
model?: never;
|
|
253
240
|
thinking?: never;
|
|
254
|
-
|
|
241
|
+
workspace?: never;
|
|
255
242
|
message?: never;
|
|
256
243
|
action?: never;
|
|
257
244
|
requestId?: never;
|
|
@@ -297,7 +284,6 @@ export declare class McpWorkerRuntime {
|
|
|
297
284
|
description: string;
|
|
298
285
|
};
|
|
299
286
|
thinking?: never;
|
|
300
|
-
cwd?: never;
|
|
301
287
|
message?: never;
|
|
302
288
|
waitMs?: never;
|
|
303
289
|
action?: never;
|
|
@@ -480,7 +466,7 @@ export declare class McpWorkerRuntime {
|
|
|
480
466
|
/** Wait until ACP handshake and model/thinking configuration finish so invalid options fail synchronously on create/resume. */
|
|
481
467
|
private waitReady;
|
|
482
468
|
private waitFor;
|
|
483
|
-
callTool(toolName: string, input: unknown, progress?: ProgressReporter): Promise<unknown>;
|
|
469
|
+
callTool(toolName: string, input: unknown, progress?: ProgressReporter, defaultWorkspace?: string): Promise<unknown>;
|
|
484
470
|
close(preserve?: boolean): Promise<void>;
|
|
485
471
|
}
|
|
486
472
|
export declare function handleMcpRequest(runtime: McpWorkerRuntime, message: unknown, notify?: (notification: Record<string, unknown>) => void): Promise<Record<string, unknown> | null>;
|
|
@@ -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,18 +22,25 @@ const protocolVersion = "2025-03-26";
|
|
|
23
22
|
const readyTimeoutMs = 45_000;
|
|
24
23
|
const reportPageSize = 16_000;
|
|
25
24
|
const progressIntervalMs = 5_000;
|
|
26
|
-
|
|
27
|
-
"
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
25
|
+
const workerCapabilityInstruction = "跨助手委派(worker_*):启动并调度其他外部助手在当前工作区独立执行任务;无需外部助手时优先自行完成或使用内置子代理。" +
|
|
26
|
+
"流程:worker_create 启动(或 worker_discover 复用)→ worker_request 派发/追问 → 完成后 worker_close;" +
|
|
27
|
+
"后台取结果、超时续等(timedOut)或翻页(nextOffset)用 worker_output;返回 needsResponse 时先向用户确认,再用 worker_response 回复。";
|
|
28
|
+
const workspaceMcpCapabilityInstruction = "工作区共享 MCP(workspace_mcp_*):先用 workspace_mcp_discover 查 .pbot/mcp.json 中的服务与工具,再用 workspace_mcp_call 调用。";
|
|
29
|
+
const historyCapabilityInstruction = "跨宿主历史(history_search / history_read):只读检索当前工作区跨宿主记录的历史问答与摘要归档。";
|
|
30
|
+
export function buildMcpInstructions(options) {
|
|
31
|
+
const parts = [workerCapabilityInstruction];
|
|
32
|
+
if (options.workspaceMcp)
|
|
33
|
+
parts.push(workspaceMcpCapabilityInstruction);
|
|
34
|
+
if (options.history)
|
|
35
|
+
parts.push(historyCapabilityInstruction);
|
|
36
|
+
return parts.length === 1 ? parts[0] : parts.map((text, index) => `${index + 1}. ${text}`).join("\n");
|
|
37
|
+
}
|
|
38
|
+
export const mcpWorkerOnlyInstructions = buildMcpInstructions({ workspaceMcp: false, history: false });
|
|
39
|
+
export const mcpInstructions = buildMcpInstructions({ workspaceMcp: true, history: true });
|
|
40
|
+
export function defaultWorkerDirectory(workspaceRoot) {
|
|
33
41
|
if (process.env.PBOT_MCP_AGENT_DIR)
|
|
34
42
|
return process.env.PBOT_MCP_AGENT_DIR;
|
|
35
|
-
|
|
36
|
-
return join(process.env.PLUGIN_DATA, "subagents");
|
|
37
|
-
return join(homedir(), ".pbot/subagents");
|
|
43
|
+
return join(workspaceRoot, ".pbot", "subagents");
|
|
38
44
|
}
|
|
39
45
|
function workerCommandTool(name) {
|
|
40
46
|
const full = name.startsWith("worker_") ? name : `worker_${name}`;
|
|
@@ -145,6 +151,7 @@ function presentWorker(value) {
|
|
|
145
151
|
}
|
|
146
152
|
export class McpWorkerRuntime {
|
|
147
153
|
#services = new Map();
|
|
154
|
+
#workerWorkspaces = new Map();
|
|
148
155
|
#bridge = new WorkspaceMcpBridge();
|
|
149
156
|
#sessionId;
|
|
150
157
|
#directory;
|
|
@@ -152,7 +159,7 @@ export class McpWorkerRuntime {
|
|
|
152
159
|
#nativeWorkspaceMcp;
|
|
153
160
|
#nativeHistory;
|
|
154
161
|
#closing;
|
|
155
|
-
constructor(directory
|
|
162
|
+
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 ?? "")) {
|
|
156
163
|
this.#directory = directory;
|
|
157
164
|
this.#sessionId = sessionId;
|
|
158
165
|
this.#defaultBackend = defaultBackend?.trim() || undefined;
|
|
@@ -171,7 +178,7 @@ export class McpWorkerRuntime {
|
|
|
171
178
|
env: {
|
|
172
179
|
PBOT_HOST: this.#defaultBackend,
|
|
173
180
|
PBOT_WORKSPACE_ROOT: root,
|
|
174
|
-
PBOT_MCP_AGENT_DIR: this.#directory,
|
|
181
|
+
PBOT_MCP_AGENT_DIR: this.#directory ?? defaultWorkerDirectory(root),
|
|
175
182
|
PBOT_MCP_SESSION_ID: this.#sessionId,
|
|
176
183
|
PBOT_NATIVE_WORKSPACE_MCP: "1",
|
|
177
184
|
PBOT_NATIVE_HISTORY: "1",
|
|
@@ -198,13 +205,26 @@ export class McpWorkerRuntime {
|
|
|
198
205
|
requireThat((await stat(root)).isDirectory(), "工作区路径不是目录。");
|
|
199
206
|
return root;
|
|
200
207
|
}
|
|
208
|
+
async resolveWorkerWorkspace(workerId, defaultWorkspace) {
|
|
209
|
+
const known = this.#workerWorkspaces.get(workerId);
|
|
210
|
+
if (known)
|
|
211
|
+
return known;
|
|
212
|
+
for (const [root, entry] of this.#services) {
|
|
213
|
+
if (entry.service.has(workerId, entry.owner)) {
|
|
214
|
+
this.#workerWorkspaces.set(workerId, root);
|
|
215
|
+
return root;
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
return this.resolveWorkspace(defaultWorkspace);
|
|
219
|
+
}
|
|
201
220
|
workerService(root, commands = {}) {
|
|
202
221
|
let entry = this.#services.get(root);
|
|
203
222
|
if (!entry) {
|
|
204
|
-
const
|
|
223
|
+
const directory = this.#directory ?? defaultWorkerDirectory(root);
|
|
224
|
+
const host = new AcpWorkerHost(directory, commands);
|
|
205
225
|
entry = {
|
|
206
226
|
host,
|
|
207
|
-
service: new AgentService(root,
|
|
227
|
+
service: new AgentService(root, directory, host),
|
|
208
228
|
owner: { sessionId: this.#sessionId, leaf: null, branch: [] },
|
|
209
229
|
};
|
|
210
230
|
this.#services.set(root, entry);
|
|
@@ -214,7 +234,7 @@ export class McpWorkerRuntime {
|
|
|
214
234
|
}
|
|
215
235
|
return entry;
|
|
216
236
|
}
|
|
217
|
-
async
|
|
237
|
+
async resolveToolContext() {
|
|
218
238
|
let commands;
|
|
219
239
|
let includeWorkspaceMcp = !this.#nativeWorkspaceMcp;
|
|
220
240
|
let includeHistory = !this.#nativeHistory;
|
|
@@ -229,6 +249,14 @@ export class McpWorkerRuntime {
|
|
|
229
249
|
}
|
|
230
250
|
}
|
|
231
251
|
catch { /* Fall back to registered built-in harnesses when cwd is outside an enabled workspace. */ }
|
|
252
|
+
return { commands, includeWorkspaceMcp, includeHistory };
|
|
253
|
+
}
|
|
254
|
+
async serverInstructions() {
|
|
255
|
+
const { includeWorkspaceMcp, includeHistory } = await this.resolveToolContext();
|
|
256
|
+
return buildMcpInstructions({ workspaceMcp: includeWorkspaceMcp, history: includeHistory });
|
|
257
|
+
}
|
|
258
|
+
async toolDefinitions() {
|
|
259
|
+
const { commands, includeWorkspaceMcp, includeHistory } = await this.resolveToolContext();
|
|
232
260
|
const defaultBackend = this.#defaultBackend ? canonicalAcpBackend(this.#defaultBackend, commands) : undefined;
|
|
233
261
|
const workspaceBound = Boolean(pluginMcpWorkspaceRoot());
|
|
234
262
|
return [
|
|
@@ -302,10 +330,13 @@ export class McpWorkerRuntime {
|
|
|
302
330
|
await delay(100);
|
|
303
331
|
}
|
|
304
332
|
}
|
|
305
|
-
async callTool(toolName, input, progress) {
|
|
333
|
+
async callTool(toolName, input, progress, defaultWorkspace) {
|
|
306
334
|
const { name, args: rawArgs } = parseMcpToolCall(toolName, input);
|
|
307
335
|
requireThat(!this.#closing, "Personal Bot MCP 服务已关闭。");
|
|
308
|
-
const
|
|
336
|
+
const isWorkerScoped = name === "worker_close" || name === "worker_request" || name === "worker_response" || name === "worker_output";
|
|
337
|
+
const root = isWorkerScoped
|
|
338
|
+
? await this.resolveWorkerWorkspace(asString(rawArgs, "workerId", true), defaultWorkspace)
|
|
339
|
+
: await this.resolveWorkspace(asString(rawArgs, "workspace") ?? defaultWorkspace);
|
|
309
340
|
const configuration = await readWorkspaceConfig(root);
|
|
310
341
|
requireThat(!this.#closing, "Personal Bot MCP 服务已关闭。");
|
|
311
342
|
requireThat(configuration.enabled, workspaceDisabledMessage(configuration));
|
|
@@ -367,13 +398,12 @@ export class McpWorkerRuntime {
|
|
|
367
398
|
const backend = this.resolveBackend(rawArgs, configuration.acp, false);
|
|
368
399
|
const model = asString(rawArgs, "model");
|
|
369
400
|
const thinking = asString(rawArgs, "thinking");
|
|
370
|
-
const cwd = asString(rawArgs, "cwd");
|
|
371
401
|
const created = await service.start({
|
|
372
402
|
backend,
|
|
373
403
|
...(model ? { model } : {}),
|
|
374
404
|
...(thinking ? { thinking } : {}),
|
|
375
|
-
...(cwd ? { cwd } : {}),
|
|
376
405
|
}, owner);
|
|
406
|
+
this.#workerWorkspaces.set(created.agentId, root);
|
|
377
407
|
const ready = await this.waitReady(service, owner, created.agentId, readyTimeoutMs, progress);
|
|
378
408
|
return {
|
|
379
409
|
...presentWorker(ready),
|
|
@@ -444,21 +474,25 @@ export class McpWorkerRuntime {
|
|
|
444
474
|
requireThat(backendRaw === undefined && model === undefined, '参数 backend / model 仅在 target="models" 时可用。');
|
|
445
475
|
}
|
|
446
476
|
if (target === "overview") {
|
|
477
|
+
const workers = service.list(owner);
|
|
478
|
+
for (const item of workers)
|
|
479
|
+
this.#workerWorkspaces.set(item.agentId, root);
|
|
447
480
|
return {
|
|
448
481
|
target,
|
|
449
482
|
backends: inspectAcpBackends(configuration.acp),
|
|
450
|
-
workers:
|
|
483
|
+
workers: workers.map(presentWorker),
|
|
451
484
|
};
|
|
452
485
|
}
|
|
453
486
|
if (target === "backends") {
|
|
454
487
|
return { target, backends: inspectAcpBackends(configuration.acp) };
|
|
455
488
|
}
|
|
456
489
|
if (target === "workers") {
|
|
490
|
+
const workers = workerId ? [service.status(workerId, owner)] : service.list(owner);
|
|
491
|
+
for (const item of workers)
|
|
492
|
+
this.#workerWorkspaces.set(item.agentId, root);
|
|
457
493
|
return {
|
|
458
494
|
target,
|
|
459
|
-
workers:
|
|
460
|
-
? [presentWorker(service.status(workerId, owner))]
|
|
461
|
-
: service.list(owner).map(presentWorker),
|
|
495
|
+
workers: workers.map(presentWorker),
|
|
462
496
|
};
|
|
463
497
|
}
|
|
464
498
|
const backend = this.resolveBackend(rawArgs, configuration.acp, true);
|
|
@@ -475,6 +509,7 @@ export class McpWorkerRuntime {
|
|
|
475
509
|
return this.#closing;
|
|
476
510
|
const entries = [...this.#services.values()];
|
|
477
511
|
this.#services.clear();
|
|
512
|
+
this.#workerWorkspaces.clear();
|
|
478
513
|
this.#closing = Promise.allSettled([
|
|
479
514
|
this.#bridge.close(),
|
|
480
515
|
...entries.map(({ service, owner }) => service.close(owner, preserve)),
|
|
@@ -502,7 +537,7 @@ export async function handleMcpRequest(runtime, message, notify) {
|
|
|
502
537
|
protocolVersion: requested || protocolVersion,
|
|
503
538
|
capabilities: { tools: {} },
|
|
504
539
|
serverInfo: { name: "personal-bot", version: packageVersion },
|
|
505
|
-
instructions: runtime.
|
|
540
|
+
instructions: await runtime.serverInstructions(),
|
|
506
541
|
},
|
|
507
542
|
};
|
|
508
543
|
}
|