personal-bot 0.4.0 → 0.4.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.
- package/.claude-plugin/marketplace.json +3 -3
- package/.claude-plugin/plugin.json +2 -2
- package/README.md +4 -1
- package/README.zh-CN.md +4 -1
- package/docs/README.md +2 -3
- package/docs/architecture/design.md +41 -2
- package/docs/architecture/extensibility.md +3 -3
- package/docs/architecture/model-context.md +10 -4
- package/docs/architecture/principles.md +2 -2
- package/docs/guides/cross-harness-workers.md +27 -2
- package/docs/guides/workspace-configuration.md +3 -1
- package/docs/hosts/claude-code.md +1 -1
- package/docs/hosts/codex-qoder.md +3 -1
- package/hooks/hooks.json +3 -0
- package/lib/antigravity-plugin/lib/extension/acp-worker.js +22 -6
- package/lib/antigravity-plugin/lib/extension/cli.js +169 -95
- package/lib/antigravity-plugin/lib/extension/hosts/plugin-runtime.js +3 -1
- package/lib/antigravity-plugin/lib/extension/mcp.js +163 -119
- package/lib/antigravity-plugin/lib/integrations/agent-resources.d.ts +4 -2
- package/lib/antigravity-plugin/lib/integrations/agent-resources.js +23 -5
- 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 +2 -1
- package/lib/antigravity-plugin/lib/integrations/hosts/dsh/resources.js +12 -13
- package/lib/antigravity-plugin/lib/integrations/hosts/prompt-hooks.js +4 -7
- package/lib/antigravity-plugin/lib/model/worker-template.d.ts +21 -0
- package/lib/antigravity-plugin/lib/model/worker-template.js +1 -0
- 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/services/workspace/worker-templates.d.ts +17 -0
- package/lib/antigravity-plugin/lib/services/workspace/worker-templates.js +88 -0
- 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-worker.js +22 -6
- package/lib/extension/cli.js +169 -95
- package/lib/extension/hosts/dsh/command.js +1 -1
- package/lib/extension/hosts/dsh/workspace.js +5 -2
- package/lib/extension/hosts/plugin-runtime.js +3 -1
- package/lib/extension/mcp/tool-contract.d.ts +3 -3
- package/lib/extension/mcp/tool-contract.js +63 -101
- package/lib/extension/mcp/workers.d.ts +1 -1
- package/lib/extension/mcp/workers.js +19 -13
- package/lib/extension/mcp.js +163 -119
- package/lib/integrations/agent-resources.d.ts +4 -2
- package/lib/integrations/agent-resources.js +23 -5
- 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 +2 -1
- package/lib/integrations/hosts/dsh/resources.js +12 -13
- package/lib/integrations/hosts/prompt-hooks.js +4 -7
- package/lib/model/worker-template.d.ts +21 -0
- package/lib/model/worker-template.js +1 -0
- 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/agent-service.js +2 -2
- 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/services/workspace/worker-templates.d.ts +17 -0
- package/lib/services/workspace/worker-templates.js +88 -0
- 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/cli/commands/mcp.ts +1 -1
- package/src/extension/hosts/dsh/command.ts +1 -1
- package/src/extension/hosts/dsh/workspace.ts +5 -1
- package/src/extension/hosts/pi/command.ts +1 -1
- package/src/extension/hosts/pi/events.ts +3 -1
- package/src/extension/hosts/plugin-runtime.ts +3 -1
- package/src/extension/mcp/tool-contract.ts +63 -103
- package/src/extension/mcp/workers.ts +21 -14
- package/src/integrations/agent-resources.ts +27 -7
- 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 +14 -13
- package/src/integrations/hosts/prompt-hooks.ts +3 -6
- package/src/model/worker-template.ts +24 -0
- package/src/pbot.ts +2 -2
- package/src/services/agents/agent-service.ts +2 -2
- 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/workspace/worker-templates.ts +80 -0
- package/src/storage/history-files.ts +3 -2
- package/src/tools/history/contract.ts +14 -16
- package/docs/architecture/model-instruction-guidelines.md +0 -34
package/lib/extension/mcp.js
CHANGED
|
@@ -6,7 +6,7 @@ import { pathToFileURL as pathToFileURL2 } from "node:url";
|
|
|
6
6
|
import { randomUUID as randomUUID4 } from "node:crypto";
|
|
7
7
|
import { existsSync as existsSync3 } from "node:fs";
|
|
8
8
|
import { realpath as realpath3, stat as stat3 } from "node:fs/promises";
|
|
9
|
-
import { isAbsolute as isAbsolute5, join as
|
|
9
|
+
import { isAbsolute as isAbsolute5, join as join13 } from "node:path";
|
|
10
10
|
import { setTimeout as delay3 } from "node:timers/promises";
|
|
11
11
|
|
|
12
12
|
// src/common/json.ts
|
|
@@ -1117,7 +1117,6 @@ var antigravityAdapter = {
|
|
|
1117
1117
|
host: "antigravity",
|
|
1118
1118
|
nativeRootAgents: true,
|
|
1119
1119
|
nativeWorkspaceSkills: true,
|
|
1120
|
-
coordinatorPrompt: "plugin-coordinator.md",
|
|
1121
1120
|
initCommandHint: "/pbot init",
|
|
1122
1121
|
usage: "\u7528\u6CD5\uFF1Anode <\u63D2\u4EF6\u76EE\u5F55>/lib/plugin.js antigravity init|status",
|
|
1123
1122
|
resolveRoot(cwd, rawPayload) {
|
|
@@ -1192,12 +1191,9 @@ function parsePromptEvent(value) {
|
|
|
1192
1191
|
if (name !== "Stop" && name !== "UserPromptSubmit" && name !== "SessionStart") return { kind: "ignore" };
|
|
1193
1192
|
if (typeof value.agent_id === "string") return { kind: "ignore" };
|
|
1194
1193
|
requireThat(typeof value.cwd === "string", "\u63D2\u4EF6 hook \u7F3A\u5C11\u5DE5\u4F5C\u76EE\u5F55\u3002");
|
|
1195
|
-
if (name
|
|
1196
|
-
if (
|
|
1197
|
-
|
|
1198
|
-
return { kind: "inject-context", role: "coordinator", isSessionStart: true, noticesOnly: true, cwd: value.cwd, raw: value };
|
|
1199
|
-
}
|
|
1200
|
-
return { kind: "inject-context", role: "coordinator", cwd: value.cwd, raw: value };
|
|
1194
|
+
if (name !== "SessionStart") return { kind: "record-history", cwd: value.cwd, raw: value };
|
|
1195
|
+
if (value.source === "resume" || value.source === "compact") return { kind: "ignore" };
|
|
1196
|
+
return { kind: "inject-context", role: "coordinator", isSessionStart: true, cwd: value.cwd, raw: value };
|
|
1201
1197
|
}
|
|
1202
1198
|
var promptHooks = {
|
|
1203
1199
|
async extractHistory(event) {
|
|
@@ -1243,7 +1239,7 @@ var promptHooks = {
|
|
|
1243
1239
|
};
|
|
1244
1240
|
|
|
1245
1241
|
// src/integrations/hosts/claude/adapter.ts
|
|
1246
|
-
var supportedEvents2 = ["UserPromptSubmit", "PreToolUse", "UserPromptExpansion", "Stop"];
|
|
1242
|
+
var supportedEvents2 = ["SessionStart", "UserPromptSubmit", "PreToolUse", "UserPromptExpansion", "Stop"];
|
|
1247
1243
|
var boundWorkspaceRoot = () => process.env.CLAUDE_PROJECT_DIR;
|
|
1248
1244
|
async function claudeWorkspaceRoot(cwd, projectDirectory = boundWorkspaceRoot()) {
|
|
1249
1245
|
return pluginWorkspaceRoot(projectDirectory || cwd);
|
|
@@ -1252,7 +1248,6 @@ var claudeAdapter = {
|
|
|
1252
1248
|
host: "claude",
|
|
1253
1249
|
nativeRootAgents: false,
|
|
1254
1250
|
nativeWorkspaceSkills: false,
|
|
1255
|
-
coordinatorPrompt: "plugin-coordinator.md",
|
|
1256
1251
|
initCommandHint: "/personal-bot:pbot init",
|
|
1257
1252
|
usage: "\u7528\u6CD5\uFF1Anode <\u63D2\u4EF6\u76EE\u5F55>/lib/claude.js init|status",
|
|
1258
1253
|
boundWorkspaceRoot,
|
|
@@ -1347,37 +1342,34 @@ var historyPageLimits = {
|
|
|
1347
1342
|
// src/extension/mcp/tool-contract.ts
|
|
1348
1343
|
var defaultWaitMs = 5e4;
|
|
1349
1344
|
var maxWaitMs = 6e5;
|
|
1350
|
-
var discoverTargets = ["overview", "workers", "backends", "models"];
|
|
1345
|
+
var discoverTargets = ["overview", "workers", "backends", "models", "templates"];
|
|
1351
1346
|
function formatBackendItem(entry, defaultBackend) {
|
|
1352
1347
|
const tags = [];
|
|
1353
1348
|
if (entry.label) tags.push(entry.label);
|
|
1354
1349
|
if (entry.backend === defaultBackend) tags.push("\u5F53\u524D\u5BBF\u4E3B");
|
|
1355
1350
|
return tags.length ? `${entry.backend}\uFF08${tags.join("\uFF0C")}\uFF09` : entry.backend;
|
|
1356
1351
|
}
|
|
1357
|
-
function summarizeBackends(commands = {}, defaultBackend) {
|
|
1358
|
-
const entries = inspectAcpBackends(commands);
|
|
1359
|
-
const available = entries.filter((item) => item.available);
|
|
1360
|
-
const unavailable = entries.filter((item) => !item.available);
|
|
1361
|
-
const availableText = available.map((item) => formatBackendItem(item, defaultBackend)).join("\u3001");
|
|
1362
|
-
const unavailableText = unavailable.map((item) => formatBackendItem(item, defaultBackend)).join("\u3001");
|
|
1363
|
-
const overview = available.length ? unavailable.length ? `\u5F53\u524D\u53EF\u7528\u52A9\u624B\uFF1A${availableText}\uFF1B\u6682\u4E0D\u53EF\u7528\uFF1A${unavailableText}\u3002` : `\u5F53\u524D\u53EF\u7528\u52A9\u624B\uFF1A${availableText}\u3002` : `\u5F53\u524D\u65E0\u53EF\u7528\u5916\u90E8\u52A9\u624B\uFF08\u6682\u4E0D\u53EF\u7528\uFF1A${unavailableText}\uFF09\u3002`;
|
|
1364
|
-
const availableIds = available.map((item) => item.backend).join("\u3001");
|
|
1365
|
-
return { overview, availableIds };
|
|
1366
|
-
}
|
|
1367
1352
|
function workspaceProperty(workspaceBound) {
|
|
1368
1353
|
return {
|
|
1369
1354
|
type: "string",
|
|
1370
|
-
description: workspaceBound ? "\u5DE5\u4F5C\u533A\u6839\u76EE\u5F55\u7EDD\u5BF9\u8DEF\u5F84\
|
|
1355
|
+
description: workspaceBound ? "\u5DE5\u4F5C\u533A\u6839\u76EE\u5F55\u7684\u7EDD\u5BF9\u8DEF\u5F84\uFF0C\u9ED8\u8BA4\u5F53\u524D\u7ED1\u5B9A\u7684\u5DE5\u4F5C\u533A\u3002" : "\u4F20\u76EE\u6807\u5DE5\u4F5C\u533A\u7684\u7EDD\u5BF9\u8DEF\u5F84\uFF08workspaceRoot\uFF09\u3002\u7701\u7565\u65F6\u4F7F\u7528\u670D\u52A1\u7684\u5F53\u524D\u76EE\u5F55\u3002"
|
|
1371
1356
|
};
|
|
1372
1357
|
}
|
|
1373
1358
|
function buildPbotWorkerTools(commands = {}, defaultBackend, workspaceBound = false) {
|
|
1374
|
-
const
|
|
1375
|
-
const
|
|
1359
|
+
const available = inspectAcpBackends(commands).filter((item) => item.available);
|
|
1360
|
+
const overview = available.length ? "\u53EF\u7528\u52A9\u624B\uFF1A" + available.map((item) => formatBackendItem(item, defaultBackend)).join("\u3001") + "\u3002" : "\u5F53\u524D\u6CA1\u6709\u53EF\u7528\u52A9\u624B\u3002\u7528 worker_discover \u7684 backends \u67E5\u770B\u63A5\u5165\u72B6\u6001\u3002";
|
|
1376
1361
|
const workspace = workspaceProperty(workspaceBound);
|
|
1362
|
+
const workerId = { type: "string", description: "\u52A9\u624B\u4F1A\u8BDD ID\u3002" };
|
|
1363
|
+
const waitMs = {
|
|
1364
|
+
type: "integer",
|
|
1365
|
+
minimum: 0,
|
|
1366
|
+
maximum: maxWaitMs,
|
|
1367
|
+
description: `\u7B49\u5F85\u672C\u8F6E\u7ED3\u679C\u7684\u6BEB\u79D2\u6570\uFF0C\u9ED8\u8BA4 ${defaultWaitMs}\u30020 \u8868\u793A\u4E0D\u7B49\u5F85\u7ED3\u679C\u3002`
|
|
1368
|
+
};
|
|
1377
1369
|
return [
|
|
1378
1370
|
{
|
|
1379
1371
|
name: "worker_create",
|
|
1380
|
-
description: "\
|
|
1372
|
+
description: "\u65B0\u5EFA\u72EC\u7ACB\u52A9\u624B\u4F1A\u8BDD\uFF0C\u8FD4\u56DE workerId\u3002\u7528 worker_request \u53D1\u9001\u9996\u4E2A\u4EFB\u52A1\u3002\n" + overview,
|
|
1381
1373
|
annotations: {
|
|
1382
1374
|
title: "Create Worker",
|
|
1383
1375
|
readOnlyHint: false,
|
|
@@ -1392,15 +1384,15 @@ function buildPbotWorkerTools(commands = {}, defaultBackend, workspaceBound = fa
|
|
|
1392
1384
|
properties: {
|
|
1393
1385
|
backend: {
|
|
1394
1386
|
type: "string",
|
|
1395
|
-
description: "\
|
|
1387
|
+
description: "\u52A9\u624B\u6807\u8BC6\u6216\u522B\u540D\uFF0C\u5982 claude-code\u3001agy\u3002"
|
|
1396
1388
|
},
|
|
1397
1389
|
model: {
|
|
1398
1390
|
type: "string",
|
|
1399
|
-
description:
|
|
1391
|
+
description: "\u6A21\u578B ID\u3001\u663E\u793A\u540D\u6216 provider/model\u3002\u672A\u6307\u5B9A\u6A21\u578B\u65F6\u7701\u7565\uFF0C\u4F7F\u7528\u52A9\u624B\u9ED8\u8BA4\u6A21\u578B\u3002"
|
|
1400
1392
|
},
|
|
1401
1393
|
thinking: {
|
|
1402
1394
|
type: "string",
|
|
1403
|
-
description: "\u601D\u8003\u6DF1\u5EA6\
|
|
1395
|
+
description: "\u601D\u8003\u6DF1\u5EA6\uFF0C\u5982 high\u3002\u672A\u6307\u5B9A\u65F6\u7701\u7565\uFF0C\u4F7F\u7528\u52A9\u624B\u9ED8\u8BA4\u8BBE\u7F6E\u3002"
|
|
1404
1396
|
},
|
|
1405
1397
|
workspace
|
|
1406
1398
|
}
|
|
@@ -1408,7 +1400,7 @@ function buildPbotWorkerTools(commands = {}, defaultBackend, workspaceBound = fa
|
|
|
1408
1400
|
},
|
|
1409
1401
|
{
|
|
1410
1402
|
name: "worker_close",
|
|
1411
|
-
description: "\u7ED3\u675F\
|
|
1403
|
+
description: "\u4EFB\u52A1\u7ED3\u675F\u540E\u5173\u95ED\u52A9\u624B\u3002\u63D0\u524D\u5173\u95ED\u4F1A\u4E2D\u65AD\u6267\u884C\u3002\u521B\u5EFA\u7ED3\u679C\u4E2D resume \u4E3A true \u65F6\uFF0C\u53EF\u7528\u539F workerId \u7EED\u63A5\u3002",
|
|
1412
1404
|
annotations: {
|
|
1413
1405
|
title: "Close Worker",
|
|
1414
1406
|
readOnlyHint: false,
|
|
@@ -1421,16 +1413,13 @@ function buildPbotWorkerTools(commands = {}, defaultBackend, workspaceBound = fa
|
|
|
1421
1413
|
additionalProperties: false,
|
|
1422
1414
|
required: ["workerId"],
|
|
1423
1415
|
properties: {
|
|
1424
|
-
workerId
|
|
1425
|
-
type: "string",
|
|
1426
|
-
description: "\u52A9\u624B\u4F1A\u8BDD ID\uFF08\u6765\u81EA worker_create \u6216 worker_discover\uFF09\u3002"
|
|
1427
|
-
}
|
|
1416
|
+
workerId
|
|
1428
1417
|
}
|
|
1429
1418
|
}
|
|
1430
1419
|
},
|
|
1431
1420
|
{
|
|
1432
1421
|
name: "worker_request",
|
|
1433
|
-
description:
|
|
1422
|
+
description: "\u5411\u52A9\u624B\u6D3E\u53D1\u4EFB\u52A1\u6216\u5728\u540C\u4E00\u4F1A\u8BDD\u8FFD\u95EE\u3002\u540E\u53F0\u7ED3\u679C\u7528 worker_output \u6536\u53D6\u3002",
|
|
1434
1423
|
annotations: {
|
|
1435
1424
|
title: "Send Request to Worker",
|
|
1436
1425
|
readOnlyHint: false,
|
|
@@ -1443,26 +1432,18 @@ function buildPbotWorkerTools(commands = {}, defaultBackend, workspaceBound = fa
|
|
|
1443
1432
|
additionalProperties: false,
|
|
1444
1433
|
required: ["workerId", "message"],
|
|
1445
1434
|
properties: {
|
|
1446
|
-
workerId
|
|
1447
|
-
type: "string",
|
|
1448
|
-
description: "\u52A9\u624B\u4F1A\u8BDD ID\uFF08\u6765\u81EA worker_create \u6216 worker_discover\uFF09\u3002"
|
|
1449
|
-
},
|
|
1435
|
+
workerId,
|
|
1450
1436
|
message: {
|
|
1451
1437
|
type: "string",
|
|
1452
|
-
description: "\u4EFB\u52A1\
|
|
1438
|
+
description: "\u4EFB\u52A1\u6216\u8FFD\u95EE\u3002\u52A9\u624B\u770B\u4E0D\u5230\u4E3B\u4F1A\u8BDD\u5386\u53F2\uFF0C\u9996\u6B21\u6D3E\u53D1\u65F6\u5199\u660E\u80CC\u666F\u3001\u76EE\u6807\u3001\u6587\u4EF6\u8DEF\u5F84\u3001\u7EA6\u675F\u548C\u4EA4\u4ED8\u8981\u6C42\u3002"
|
|
1453
1439
|
},
|
|
1454
|
-
waitMs
|
|
1455
|
-
type: "integer",
|
|
1456
|
-
minimum: 0,
|
|
1457
|
-
maximum: maxWaitMs,
|
|
1458
|
-
description: `\u6700\u591A\u7B49\u5F85\u6BEB\u79D2\u6570\uFF08\u9ED8\u8BA4 ${defaultWaitMs}\uFF09\uFF1B0 \u8868\u793A\u7ACB\u5373\u8FD4\u56DE\u8F6C\u540E\u53F0\u6267\u884C\u3002`
|
|
1459
|
-
}
|
|
1440
|
+
waitMs
|
|
1460
1441
|
}
|
|
1461
1442
|
}
|
|
1462
1443
|
},
|
|
1463
1444
|
{
|
|
1464
1445
|
name: "worker_response",
|
|
1465
|
-
description:
|
|
1446
|
+
description: "\u6536\u5230 needsResponse \u65F6\uFF0C\u5C06\u6743\u9650\u9009\u9879\u3001\u8868\u5355\u95EE\u9898\u6216\u94FE\u63A5\u4EA4\u7ED9\u7528\u6237\u786E\u8BA4\uFF0C\u518D\u63D0\u4EA4\u7528\u6237\u7684\u51B3\u5B9A\u3002",
|
|
1466
1447
|
annotations: {
|
|
1467
1448
|
title: "Respond to Worker Request",
|
|
1468
1449
|
readOnlyHint: false,
|
|
@@ -1475,40 +1456,32 @@ function buildPbotWorkerTools(commands = {}, defaultBackend, workspaceBound = fa
|
|
|
1475
1456
|
additionalProperties: false,
|
|
1476
1457
|
required: ["workerId", "action"],
|
|
1477
1458
|
properties: {
|
|
1478
|
-
workerId
|
|
1479
|
-
type: "string",
|
|
1480
|
-
description: "\u7B49\u5F85\u56DE\u590D\u7684\u52A9\u624B\u4F1A\u8BDD ID\u3002"
|
|
1481
|
-
},
|
|
1459
|
+
workerId,
|
|
1482
1460
|
action: {
|
|
1483
1461
|
type: "string",
|
|
1484
1462
|
enum: [...acpElicitationActions],
|
|
1485
|
-
description: "accept \u540C\u610F
|
|
1463
|
+
description: "accept \u540C\u610F\u6216\u63D0\u4EA4\u7B54\u6848\uFF0Cdecline \u62D2\u7EDD\uFF0Ccancel \u53D6\u6D88\u8BF7\u6C42\u3002"
|
|
1486
1464
|
},
|
|
1487
1465
|
requestId: {
|
|
1488
1466
|
type: "string",
|
|
1489
|
-
description: "\u8BF7\u6C42 ID\
|
|
1467
|
+
description: "\u5F85\u56DE\u590D\u7684\u8BF7\u6C42 ID\u3002\u4EC5\u6709\u4E00\u6761\u5F85\u5904\u7406\u8BF7\u6C42\u65F6\u53EF\u7701\u7565\u3002"
|
|
1490
1468
|
},
|
|
1491
1469
|
optionId: {
|
|
1492
1470
|
type: "string",
|
|
1493
|
-
description: "\
|
|
1471
|
+
description: "\u5141\u8BB8\u6216\u62D2\u7EDD\u64CD\u4F5C\u65F6\u586B\u7528\u6237\u6240\u9009\u6743\u9650\u7684 ID\u3002\u7701\u7565\u65F6\u4F18\u5148\u5355\u6B21\uFF0C\u7F3A\u5C11\u5355\u6B21\u9009\u9879\u65F6\u53EF\u80FD\u91C7\u7528\u957F\u671F\u9009\u9879\u3002"
|
|
1494
1472
|
},
|
|
1495
1473
|
content: {
|
|
1496
1474
|
type: "object",
|
|
1497
1475
|
additionalProperties: true,
|
|
1498
|
-
description:
|
|
1476
|
+
description: "\u63A5\u53D7\u8868\u5355\u65F6\uFF0C\u6309\u8868\u5355\u5B57\u6BB5\u586B\u5199\u7B54\u6848\u3002\u503C\u53EF\u4E3A\u5B57\u7B26\u4E32\u3001\u6570\u5B57\u3001\u5E03\u5C14\u503C\u6216\u5B57\u7B26\u4E32\u6570\u7EC4\u3002"
|
|
1499
1477
|
},
|
|
1500
|
-
waitMs
|
|
1501
|
-
type: "integer",
|
|
1502
|
-
minimum: 0,
|
|
1503
|
-
maximum: maxWaitMs,
|
|
1504
|
-
description: `\u63D0\u4EA4\u540E\u6700\u591A\u7B49\u5F85\u6BEB\u79D2\u6570\uFF08\u9ED8\u8BA4 ${defaultWaitMs}\uFF09\uFF1B0 \u8868\u793A\u7ACB\u5373\u8FD4\u56DE\u3002`
|
|
1505
|
-
}
|
|
1478
|
+
waitMs
|
|
1506
1479
|
}
|
|
1507
1480
|
}
|
|
1508
1481
|
},
|
|
1509
1482
|
{
|
|
1510
1483
|
name: "worker_output",
|
|
1511
|
-
description: "\
|
|
1484
|
+
description: "\u8BFB\u53D6\u52A9\u624B\u6700\u8FD1\u4E00\u8F6E\u7684\u7ED3\u679C\u3002\u540E\u53F0\u6267\u884C\u6216\u8FD4\u56DE timedOut \u65F6\uFF0C\u7528\u539F workerId \u7EE7\u7EED\u7B49\u5F85\u3002",
|
|
1512
1485
|
annotations: {
|
|
1513
1486
|
title: "Get Worker Output",
|
|
1514
1487
|
readOnlyHint: true,
|
|
@@ -1521,29 +1494,21 @@ function buildPbotWorkerTools(commands = {}, defaultBackend, workspaceBound = fa
|
|
|
1521
1494
|
additionalProperties: false,
|
|
1522
1495
|
required: ["workerId"],
|
|
1523
1496
|
properties: {
|
|
1524
|
-
workerId
|
|
1525
|
-
type: "string",
|
|
1526
|
-
description: "\u52A9\u624B\u4F1A\u8BDD ID\u3002"
|
|
1527
|
-
},
|
|
1497
|
+
workerId,
|
|
1528
1498
|
offset: {
|
|
1529
1499
|
type: "integer",
|
|
1530
1500
|
minimum: 0,
|
|
1531
|
-
description: "\u8BFB\
|
|
1501
|
+
description: "\u7EED\u8BFB\u4F20\u4E0A\u9875\u7684 nextOffset\uFF0C\u9ED8\u8BA4\u4ECE 0 \u5F00\u59CB\u3002"
|
|
1532
1502
|
},
|
|
1533
|
-
waitMs
|
|
1534
|
-
type: "integer",
|
|
1535
|
-
minimum: 0,
|
|
1536
|
-
maximum: maxWaitMs,
|
|
1537
|
-
description: `\u8FD0\u884C\u4E2D\u6700\u591A\u7B49\u5F85\u6BEB\u79D2\u6570\uFF08\u9ED8\u8BA4 ${defaultWaitMs}\uFF09\uFF1B\u5DF2\u7ED3\u675F\u6216\u7FFB\u9875\u65F6\u7ACB\u5373\u8FD4\u56DE\u3002`
|
|
1538
|
-
}
|
|
1503
|
+
waitMs
|
|
1539
1504
|
}
|
|
1540
1505
|
}
|
|
1541
1506
|
},
|
|
1542
1507
|
{
|
|
1543
1508
|
name: "worker_discover",
|
|
1544
|
-
description: "\u67E5\
|
|
1509
|
+
description: "\u67E5\u627E\u53EF\u7528\u52A9\u624B\u3001\u6A21\u677F\u6216\u5DF2\u6709\u4F1A\u8BDD\u3002\u67E5\u8BE2\u6A21\u578B\u4F1A\u4E34\u65F6\u542F\u52A8\u6240\u9009\u52A9\u624B\u3002",
|
|
1545
1510
|
annotations: {
|
|
1546
|
-
title: "Discover Workers, Backends & Models",
|
|
1511
|
+
title: "Discover Workers, Templates, Backends & Models",
|
|
1547
1512
|
readOnlyHint: true,
|
|
1548
1513
|
destructiveHint: false,
|
|
1549
1514
|
idempotentHint: true,
|
|
@@ -1557,19 +1522,19 @@ function buildPbotWorkerTools(commands = {}, defaultBackend, workspaceBound = fa
|
|
|
1557
1522
|
target: {
|
|
1558
1523
|
type: "string",
|
|
1559
1524
|
enum: [...discoverTargets],
|
|
1560
|
-
description: "overview\uFF08\u9ED8\u8BA4\
|
|
1525
|
+
description: "overview\uFF08\u9ED8\u8BA4\uFF09\u5217\u52A9\u624B\u548C\u672C\u4F1A\u8BDD\u7684 worker\uFF0Cworkers \u67E5\u4F1A\u8BDD\u72B6\u6001\uFF0Cbackends \u67E5\u53EF\u7528\u52A9\u624B\uFF0Cmodels \u67E5\u6A21\u578B\u4E0E\u601D\u8003\u6DF1\u5EA6\u3002templates \u5217\u51FA\u5DE5\u4F5C\u533A\u7684\u52A9\u624B\u6A21\u677F\uFF0C\u9009\u4E2D\u6A21\u677F\u7684 create \u53EF\u76F4\u63A5\u4F20\u7ED9 worker_create\u3002"
|
|
1561
1526
|
},
|
|
1562
1527
|
workerId: {
|
|
1563
1528
|
type: "string",
|
|
1564
|
-
description:
|
|
1529
|
+
description: "\u67E5 workers \u65F6\u53EF\u6307\u5B9A\u5355\u4E2A\u4F1A\u8BDD\uFF0C\u7701\u7565\u5217\u51FA\u5168\u90E8\u6240\u5C5E\u4F1A\u8BDD\u3002"
|
|
1565
1530
|
},
|
|
1566
1531
|
backend: {
|
|
1567
1532
|
type: "string",
|
|
1568
|
-
description:
|
|
1533
|
+
description: defaultBackend ? `\u67E5 models \u65F6\u9009\u62E9\u52A9\u624B\uFF0C\u9ED8\u8BA4 ${defaultBackend}\u3002` : "\u67E5 models \u65F6\u5FC5\u586B\u52A9\u624B\u6807\u8BC6\u3002"
|
|
1569
1534
|
},
|
|
1570
1535
|
model: {
|
|
1571
1536
|
type: "string",
|
|
1572
|
-
description:
|
|
1537
|
+
description: "\u67E5 models \u65F6\u53EF\u6307\u5B9A\u6A21\u578B\u4EE5\u67E5\u770B\u5B83\u652F\u6301\u7684\u601D\u8003\u6DF1\u5EA6\u3002"
|
|
1573
1538
|
},
|
|
1574
1539
|
workspace
|
|
1575
1540
|
}
|
|
@@ -1582,7 +1547,7 @@ function buildWorkspaceMcpTools(workspaceBound = false) {
|
|
|
1582
1547
|
return [
|
|
1583
1548
|
{
|
|
1584
1549
|
name: "workspace_mcp_discover",
|
|
1585
|
-
description: "\u67E5\
|
|
1550
|
+
description: "\u67E5\u627E\u5DE5\u4F5C\u533A\u5171\u4EAB\u7684 MCP \u670D\u52A1\uFF0C\u4EE5\u53CA\u670D\u52A1\u63D0\u4F9B\u7684\u5DE5\u5177\u548C\u53C2\u6570\u3002",
|
|
1586
1551
|
annotations: {
|
|
1587
1552
|
title: "Discover Workspace MCP Servers & Tools",
|
|
1588
1553
|
readOnlyHint: true,
|
|
@@ -1597,7 +1562,7 @@ function buildWorkspaceMcpTools(workspaceBound = false) {
|
|
|
1597
1562
|
properties: {
|
|
1598
1563
|
server: {
|
|
1599
1564
|
type: "string",
|
|
1600
|
-
description: "\u670D\u52A1\u540D\
|
|
1565
|
+
description: "\u586B\u670D\u52A1\u540D\u5217\u51FA\u5176\u5DE5\u5177\uFF0C\u7701\u7565\u5219\u5217\u51FA\u5DF2\u914D\u7F6E\u7684\u670D\u52A1\u3002"
|
|
1601
1566
|
},
|
|
1602
1567
|
workspace
|
|
1603
1568
|
}
|
|
@@ -1605,11 +1570,11 @@ function buildWorkspaceMcpTools(workspaceBound = false) {
|
|
|
1605
1570
|
},
|
|
1606
1571
|
{
|
|
1607
1572
|
name: "workspace_mcp_call",
|
|
1608
|
-
description: "\
|
|
1573
|
+
description: "\u6267\u884C\u5DE5\u4F5C\u533A\u5171\u4EAB MCP \u670D\u52A1\u7684\u5DE5\u5177\uFF0C\u8BFB\u5199\u6548\u679C\u53D6\u51B3\u4E8E\u6240\u9009\u5DE5\u5177\u3002\u5DE5\u5177\u540D\u548C\u53C2\u6570\u53EF\u7528 workspace_mcp_discover \u67E5\u8BE2\u3002",
|
|
1609
1574
|
annotations: {
|
|
1610
1575
|
title: "Call Workspace MCP Tool",
|
|
1611
1576
|
readOnlyHint: false,
|
|
1612
|
-
destructiveHint:
|
|
1577
|
+
destructiveHint: true,
|
|
1613
1578
|
idempotentHint: false,
|
|
1614
1579
|
openWorldHint: true
|
|
1615
1580
|
},
|
|
@@ -1620,16 +1585,16 @@ function buildWorkspaceMcpTools(workspaceBound = false) {
|
|
|
1620
1585
|
properties: {
|
|
1621
1586
|
server: {
|
|
1622
1587
|
type: "string",
|
|
1623
|
-
description: "\
|
|
1588
|
+
description: "\u5DE5\u4F5C\u533A\u4E2D\u767B\u8BB0\u7684\u670D\u52A1\u540D\u3002"
|
|
1624
1589
|
},
|
|
1625
1590
|
tool: {
|
|
1626
1591
|
type: "string",
|
|
1627
|
-
description: "\u5DE5\u5177\u540D\
|
|
1592
|
+
description: "\u8BE5\u670D\u52A1\u63D0\u4F9B\u7684\u5DE5\u5177\u540D\u3002"
|
|
1628
1593
|
},
|
|
1629
1594
|
arguments: {
|
|
1630
1595
|
type: "object",
|
|
1631
1596
|
additionalProperties: true,
|
|
1632
|
-
description: "\
|
|
1597
|
+
description: "\u6309\u6240\u9009\u5DE5\u5177\u7684\u53C2\u6570\u5B9A\u4E49\u586B\u5199\uFF0C\u9ED8\u8BA4 {}\u3002"
|
|
1633
1598
|
},
|
|
1634
1599
|
workspace
|
|
1635
1600
|
}
|
|
@@ -1642,7 +1607,7 @@ function buildHistoryMcpTools(workspaceBound = false) {
|
|
|
1642
1607
|
return [
|
|
1643
1608
|
{
|
|
1644
1609
|
name: "history_search",
|
|
1645
|
-
description: "\
|
|
1610
|
+
description: "\u67E5\u627E\u5DE5\u4F5C\u533A\u5404\u5BBF\u4E3B\u5F52\u6863\u7684\u95EE\u7B54\u6216\u6458\u8981\u3002\u7528\u547D\u4E2D\u9879\u7684 id \u8C03\u7528 history_read \u53EF\u8BFB\u5168\u6587\u3002",
|
|
1646
1611
|
annotations: {
|
|
1647
1612
|
title: "Search Workspace History",
|
|
1648
1613
|
readOnlyHint: true,
|
|
@@ -1657,38 +1622,38 @@ function buildHistoryMcpTools(workspaceBound = false) {
|
|
|
1657
1622
|
properties: {
|
|
1658
1623
|
host: {
|
|
1659
1624
|
type: "string",
|
|
1660
|
-
description: "\u6765\u6E90\u5BBF\u4E3B\u7B5B\u9009\
|
|
1625
|
+
description: "\u6309\u6765\u6E90\u5BBF\u4E3B\u7B5B\u9009\uFF0C\u5982 pi \u6216 claude\u3002\u9ED8\u8BA4\u67E5\u5168\u90E8\u6765\u6E90\u3002"
|
|
1661
1626
|
},
|
|
1662
1627
|
dimension: {
|
|
1663
1628
|
type: "string",
|
|
1664
|
-
description: "\
|
|
1629
|
+
description: "raw \u4E3A\u539F\u59CB\u95EE\u7B54\uFF0Csession\u3001monthly \u7B49\u4E3A\u6458\u8981\u7EF4\u5EA6\u3002\u5173\u952E\u8BCD\u641C\u7D22\u9ED8\u8BA4\u67E5\u5168\u90E8\u3002"
|
|
1665
1630
|
},
|
|
1666
1631
|
query: {
|
|
1667
1632
|
type: "string",
|
|
1668
|
-
description: "\u8FDE\u7EED\
|
|
1633
|
+
description: "\u5339\u914D\u8FDE\u7EED\u6587\u672C\uFF0C\u5FFD\u7565\u5927\u5C0F\u5199\u3002\u7701\u7565\u65F6\u5217\u4F1A\u8BDD\uFF0C\u6307\u5B9A\u6458\u8981\u7EF4\u5EA6\u5219\u5217\u8BE5\u7EF4\u5EA6\u7684\u6458\u8981\u3002"
|
|
1669
1634
|
},
|
|
1670
1635
|
sessionId: {
|
|
1671
1636
|
type: "string",
|
|
1672
|
-
description: "\
|
|
1637
|
+
description: "\u6309\u539F\u59CB\u4F1A\u8BDD ID \u7B5B\u9009\u3002"
|
|
1673
1638
|
},
|
|
1674
1639
|
from: {
|
|
1675
1640
|
type: "string",
|
|
1676
|
-
description: "ISO \u65E5\u671F\u6216\u65F6\u95F4\
|
|
1641
|
+
description: "\u65F6\u95F4\u533A\u95F4\u8D77\u70B9\uFF08\u542B\uFF09\uFF0C\u7528 ISO \u65E5\u671F\u6216\u65F6\u95F4\u3002"
|
|
1677
1642
|
},
|
|
1678
1643
|
to: {
|
|
1679
1644
|
type: "string",
|
|
1680
|
-
description: "ISO \u65E5\u671F\
|
|
1645
|
+
description: "\u65F6\u95F4\u533A\u95F4\u7EC8\u70B9\uFF08\u542B\uFF09\uFF0C\u4EC5\u586B ISO \u65E5\u671F\u8868\u793A\u8BE5\u65E5 UTC \u96F6\u70B9\u3002"
|
|
1681
1646
|
},
|
|
1682
1647
|
offset: {
|
|
1683
1648
|
type: "integer",
|
|
1684
1649
|
minimum: 0,
|
|
1685
|
-
description: "\u7ED3\u679C\
|
|
1650
|
+
description: "\u7ED3\u679C\u8D77\u70B9\uFF0C\u9ED8\u8BA4 0\u3002\u7FFB\u9875\u4F20\u4E0A\u9875\u7684 nextOffset\u3002"
|
|
1686
1651
|
},
|
|
1687
1652
|
limit: {
|
|
1688
1653
|
type: "integer",
|
|
1689
1654
|
minimum: 1,
|
|
1690
1655
|
maximum: historyPageLimits.search.max,
|
|
1691
|
-
description: `\
|
|
1656
|
+
description: `\u6BCF\u9875\u6761\u6570\uFF0C\u9ED8\u8BA4 ${historyPageLimits.search.default}\u3002`
|
|
1692
1657
|
},
|
|
1693
1658
|
workspace
|
|
1694
1659
|
}
|
|
@@ -1696,7 +1661,7 @@ function buildHistoryMcpTools(workspaceBound = false) {
|
|
|
1696
1661
|
},
|
|
1697
1662
|
{
|
|
1698
1663
|
name: "history_read",
|
|
1699
|
-
description: "\
|
|
1664
|
+
description: "\u8BFB\u53D6\u5386\u53F2\u8282\u70B9\u7684\u6B63\u6587\u548C\u4E0A\u4E0B\u7EA7\u3002\u6CBF\u5B50\u8282\u70B9\u53EF\u4ECE\u6708\u5EA6\u6C47\u603B\u627E\u5230\u4F1A\u8BDD\u6458\u8981\u548C\u539F\u59CB\u95EE\u7B54\u3002",
|
|
1700
1665
|
annotations: {
|
|
1701
1666
|
title: "Read Workspace History Node",
|
|
1702
1667
|
readOnlyHint: true,
|
|
@@ -1711,27 +1676,27 @@ function buildHistoryMcpTools(workspaceBound = false) {
|
|
|
1711
1676
|
properties: {
|
|
1712
1677
|
id: {
|
|
1713
1678
|
type: "string",
|
|
1714
|
-
description: "\
|
|
1679
|
+
description: "\u641C\u7D22\u7ED3\u679C\u3001\u7236\u8282\u70B9\u6216\u5B50\u8282\u70B9\u7684 id\u3002"
|
|
1715
1680
|
},
|
|
1716
1681
|
host: {
|
|
1717
1682
|
type: "string",
|
|
1718
|
-
description: "\
|
|
1683
|
+
description: "\u8282\u70B9 id \u91CD\u540D\u65F6\u586B\u6765\u6E90\u5BBF\u4E3B\u3002"
|
|
1719
1684
|
},
|
|
1720
1685
|
offset: {
|
|
1721
1686
|
type: "integer",
|
|
1722
1687
|
minimum: 0,
|
|
1723
|
-
description: "\u6B63\u6587\u5B57\u7B26\u504F\u79FB\uFF0C\u9ED8\u8BA4 0\
|
|
1688
|
+
description: "\u6B63\u6587\u5B57\u7B26\u504F\u79FB\uFF0C\u9ED8\u8BA4 0\u3002\u7EED\u8BFB\u4F20\u4E0A\u9875\u7684 nextOffset\u3002"
|
|
1724
1689
|
},
|
|
1725
1690
|
limit: {
|
|
1726
1691
|
type: "integer",
|
|
1727
1692
|
minimum: 1,
|
|
1728
1693
|
maximum: historyPageLimits.read.max,
|
|
1729
|
-
description: `\u6B63\u6587\u5B57\u7B26\u6570\
|
|
1694
|
+
description: `\u6BCF\u9875\u6B63\u6587\u5B57\u7B26\u6570\uFF0C\u9ED8\u8BA4 ${historyPageLimits.read.default}\u3002`
|
|
1730
1695
|
},
|
|
1731
1696
|
childrenOffset: {
|
|
1732
1697
|
type: "integer",
|
|
1733
1698
|
minimum: 0,
|
|
1734
|
-
description: "\u5B50\u8282\u70B9\
|
|
1699
|
+
description: "\u5B50\u8282\u70B9\u8D77\u70B9\uFF0C\u9ED8\u8BA4 0\u3002\u7FFB\u9875\u4F20\u4E0A\u9875\u7684 nextChildrenOffset\u3002"
|
|
1735
1700
|
},
|
|
1736
1701
|
workspace
|
|
1737
1702
|
}
|
|
@@ -1832,10 +1797,10 @@ var AgentService = class {
|
|
|
1832
1797
|
throw new Error("\u5B58\u5728\u591A\u6761\u5F85\u56DE\u590D\u8BF7\u6C42\uFF0C\u8BF7\u6307\u5B9A requestId\uFF1A" + pending.map((item) => item.requestId).join(", "));
|
|
1833
1798
|
}
|
|
1834
1799
|
const target = input.requestId ? pending.find((item) => item.requestId === input.requestId) : pending[0];
|
|
1835
|
-
requireThat(target, input.requestId ?
|
|
1800
|
+
requireThat(target, input.requestId ? `\u6CA1\u6709\u5F85\u56DE\u590D\u7684\u8BF7\u6C42 ${input.requestId}\u3002\u7528 worker_discover \u67E5\u8BE2 target="workers"\u3001workerId="${id}" \u7684\u5F53\u524D\u8BF7\u6C42\u3002` : "\u5F53\u524D\u6CA1\u6709\u5F85\u56DE\u590D\u7684\u8BF7\u6C42\u3002");
|
|
1836
1801
|
this.files.ensureSubdirectory(id, "interactions");
|
|
1837
1802
|
if (target.kind === "permission") {
|
|
1838
|
-
requireThat(input.content === void 0, "\u6743\u9650\u8BF7\u6C42\
|
|
1803
|
+
requireThat(input.content === void 0, "\u8BF7\u79FB\u9664 content\u3002\u6743\u9650\u8BF7\u6C42\u7528 action \u56DE\u590D\uFF0C\u9009\u62E9\u5177\u4F53\u6743\u9650\u8303\u56F4\u65F6\u52A0\u4E0A optionId\u3002");
|
|
1839
1804
|
let resolved = null;
|
|
1840
1805
|
if (input.action === "cancel") {
|
|
1841
1806
|
requireThat(input.optionId === void 0, "action \u4E3A cancel \u65F6\u4E0D\u80FD\u540C\u65F6\u6307\u5B9A optionId\u3002");
|
|
@@ -2511,7 +2476,7 @@ var HistoryFiles = class {
|
|
|
2511
2476
|
rawCount,
|
|
2512
2477
|
summaryCount,
|
|
2513
2478
|
total,
|
|
2514
|
-
message: `\
|
|
2479
|
+
message: `\u5F53\u524D\u6309\u5E74\u6708\u8BFB\u53D6\u5386\u53F2\uFF0C\u5E73\u94FA\u76EE\u5F55\u4E2D\u7684 ${rawCount} \u4EFD\u539F\u6587\u548C ${summaryCount} \u4EFD\u6458\u8981\u5C1A\u672A\u7EB3\u5165\u68C0\u7D22\u3002\u53EF\u5728\u5DE5\u4F5C\u533A\u6839\u76EE\u5F55\u7528 pbot history migrate --dry-run \u9884\u89C8\uFF0C\u7528 pbot history migrate \u6267\u884C\uFF08Pi\u3001dsh \u53EF\u7528 /pbot history migrate\uFF09\u3002\u8981\u7EE7\u7EED\u4F7F\u7528\u5E73\u94FA\u76EE\u5F55\uFF0C\u53EF\u5728 .pbot/config.json \u4E2D\u8BBE\u7F6E "history": { "layout": "flat" }\u3002`
|
|
2515
2480
|
};
|
|
2516
2481
|
}
|
|
2517
2482
|
listFlatRawFiles() {
|
|
@@ -3128,13 +3093,87 @@ ${sessionSummaryText}` : sessionSummaryText : title;
|
|
|
3128
3093
|
};
|
|
3129
3094
|
}
|
|
3130
3095
|
|
|
3096
|
+
// src/services/workspace/worker-templates.ts
|
|
3097
|
+
import { constants as constants3 } from "node:fs";
|
|
3098
|
+
import { open } from "node:fs/promises";
|
|
3099
|
+
import { homedir } from "node:os";
|
|
3100
|
+
import { join as join11, resolve as resolve8 } from "node:path";
|
|
3101
|
+
var templateIdPattern = /^[a-z0-9][a-z0-9-]{0,63}$/;
|
|
3102
|
+
var templateFields = ["name", "description", "create"];
|
|
3103
|
+
var createFields = ["backend", "workspace", "model", "thinking"];
|
|
3104
|
+
function validString(value) {
|
|
3105
|
+
return typeof value === "string" && value.trim().length > 0 && !value.includes("\0");
|
|
3106
|
+
}
|
|
3107
|
+
function parseTemplate(id, entry) {
|
|
3108
|
+
if (!templateIdPattern.test(id)) return { id, message: "\u6A21\u677F\u6807\u8BC6\u65E0\u6548\u3002" };
|
|
3109
|
+
if (!object(entry) || Object.keys(entry).some((key) => !templateFields.includes(key))) {
|
|
3110
|
+
return { id, message: "\u6A21\u677F\u8BBE\u7F6E\u65E0\u6548\u3002" };
|
|
3111
|
+
}
|
|
3112
|
+
const { name = id, description, create } = entry;
|
|
3113
|
+
if (!validString(name)) return { id, message: "\u6A21\u677F\u540D\u79F0\u65E0\u6548\u3002" };
|
|
3114
|
+
if (!validString(description)) return { id, message: "\u6A21\u677F\u7F3A\u5C11\u6709\u6548\u7684\u804C\u8D23\u8BF4\u660E\u3002" };
|
|
3115
|
+
if (!object(create) || Object.keys(create).some((key) => !createFields.includes(key))) {
|
|
3116
|
+
return { id, message: "\u52A9\u624B\u7684\u542F\u52A8\u8BBE\u7F6E\u65E0\u6548\u3002" };
|
|
3117
|
+
}
|
|
3118
|
+
if (!validString(create.backend)) return { id, message: "\u6A21\u677F\u7F3A\u5C11\u6709\u6548\u7684\u52A9\u624B\u6807\u8BC6\u3002" };
|
|
3119
|
+
const options = { backend: create.backend, workspace: "." };
|
|
3120
|
+
for (const key of ["workspace", "model", "thinking"]) {
|
|
3121
|
+
const value = create[key];
|
|
3122
|
+
if (value === void 0) continue;
|
|
3123
|
+
if (!validString(value)) return { id, message: "\u52A9\u624B\u7684\u542F\u52A8\u8BBE\u7F6E\u65E0\u6548\u3002" };
|
|
3124
|
+
options[key] = value;
|
|
3125
|
+
}
|
|
3126
|
+
return { id, name, description, create: options };
|
|
3127
|
+
}
|
|
3128
|
+
async function readWorkerTemplates(root) {
|
|
3129
|
+
const path = join11(root, ".pbot", "worker", "templates.json");
|
|
3130
|
+
const catalog = { templates: [], errors: [] };
|
|
3131
|
+
const unavailable = { ...catalog, error: "\u5F53\u524D\u5DE5\u4F5C\u533A\u7684\u52A9\u624B\u6A21\u677F\u4E0D\u53EF\u7528\u3002" };
|
|
3132
|
+
let entries;
|
|
3133
|
+
try {
|
|
3134
|
+
const file = await open(path, constants3.O_RDONLY | constants3.O_NONBLOCK);
|
|
3135
|
+
try {
|
|
3136
|
+
if (!(await file.stat()).isFile()) return unavailable;
|
|
3137
|
+
entries = JSON.parse(await file.readFile("utf8"));
|
|
3138
|
+
} finally {
|
|
3139
|
+
await file.close();
|
|
3140
|
+
}
|
|
3141
|
+
} catch (error) {
|
|
3142
|
+
if (error.code === "ENOENT") return catalog;
|
|
3143
|
+
return unavailable;
|
|
3144
|
+
}
|
|
3145
|
+
if (!object(entries)) return unavailable;
|
|
3146
|
+
for (const id of Object.keys(entries).sort()) {
|
|
3147
|
+
const result = parseTemplate(id, entries[id]);
|
|
3148
|
+
if ("message" in result) catalog.errors.push(result);
|
|
3149
|
+
else catalog.templates.push(result);
|
|
3150
|
+
}
|
|
3151
|
+
return catalog;
|
|
3152
|
+
}
|
|
3153
|
+
function resolveTemplateWorkspace(root, workspace) {
|
|
3154
|
+
if (workspace === "~" || workspace.startsWith("~/")) return join11(homedir(), workspace.slice(2));
|
|
3155
|
+
return resolve8(root, workspace);
|
|
3156
|
+
}
|
|
3157
|
+
async function discoverWorkerTemplates(root) {
|
|
3158
|
+
const { templates, errors, error } = await readWorkerTemplates(root);
|
|
3159
|
+
if (error) throw new Error(error);
|
|
3160
|
+
return {
|
|
3161
|
+
target: "templates",
|
|
3162
|
+
templates: templates.map((template) => ({
|
|
3163
|
+
...template,
|
|
3164
|
+
create: { ...template.create, workspace: resolveTemplateWorkspace(root, template.create.workspace) }
|
|
3165
|
+
})),
|
|
3166
|
+
...errors.length ? { errors } : {}
|
|
3167
|
+
};
|
|
3168
|
+
}
|
|
3169
|
+
|
|
3131
3170
|
// src/extension/mcp/bridge.ts
|
|
3132
3171
|
import { spawn } from "node:child_process";
|
|
3133
3172
|
import { setTimeout as delay2 } from "node:timers/promises";
|
|
3134
3173
|
|
|
3135
3174
|
// src/services/workspace/workspace-mcp.ts
|
|
3136
3175
|
import { mkdir as mkdir2, readFile as readFile3 } from "node:fs/promises";
|
|
3137
|
-
import { dirname as dirname5, join as
|
|
3176
|
+
import { dirname as dirname5, join as join12, resolve as resolve9 } from "node:path";
|
|
3138
3177
|
var serverNamePattern = /^[A-Za-z0-9][A-Za-z0-9_-]{0,31}$/;
|
|
3139
3178
|
var reservedServerNames = /* @__PURE__ */ new Set(["pbot"]);
|
|
3140
3179
|
var stdioKeys = /* @__PURE__ */ new Set(["command", "args", "env", "cwd", "description", "timeout", "enabled"]);
|
|
@@ -3244,7 +3283,7 @@ function validateMcpFile(value) {
|
|
|
3244
3283
|
return { ...value, mcpServers: servers };
|
|
3245
3284
|
}
|
|
3246
3285
|
function workspaceMcpPath(root) {
|
|
3247
|
-
return
|
|
3286
|
+
return join12(root, ".pbot", "mcp.json");
|
|
3248
3287
|
}
|
|
3249
3288
|
async function readWorkspaceMcpConfig(root) {
|
|
3250
3289
|
const path = workspaceMcpPath(root);
|
|
@@ -3288,7 +3327,7 @@ function resolveWorkspaceMcpServer(root, name, server, env = process.env) {
|
|
|
3288
3327
|
}
|
|
3289
3328
|
const command = expandEnvTemplate(server.command, env, `MCP \u670D\u52A1 "${name}" \u7684 command`);
|
|
3290
3329
|
const args = (server.args ?? []).map((arg, index) => expandEnvTemplate(arg, env, `MCP \u670D\u52A1 "${name}" \u7684 args[${index}]`));
|
|
3291
|
-
const cwd = server.cwd ?
|
|
3330
|
+
const cwd = server.cwd ? resolve9(root, expandEnvTemplate(server.cwd, env, `MCP \u670D\u52A1 "${name}" \u7684 cwd`)) : root;
|
|
3292
3331
|
return {
|
|
3293
3332
|
transport: "stdio",
|
|
3294
3333
|
name,
|
|
@@ -3662,20 +3701,20 @@ var protocolVersion2 = "2025-03-26";
|
|
|
3662
3701
|
var readyTimeoutMs = 45e3;
|
|
3663
3702
|
var reportPageSize = 16e3;
|
|
3664
3703
|
var progressIntervalMs = 5e3;
|
|
3665
|
-
var workerCapabilityInstruction = "\
|
|
3666
|
-
var workspaceMcpCapabilityInstruction = "\
|
|
3667
|
-
var historyCapabilityInstruction = "\
|
|
3704
|
+
var workerCapabilityInstruction = "\u53EF\u67E5\u8BE2\u5DE5\u4F5C\u533A\u7684\u52A9\u624B\u6A21\u677F\uFF0C\u4E5F\u53EF\u6309\u7528\u6237\u8981\u6C42\u6216\u5DE5\u4F5C\u533A\u5206\u5DE5\u59D4\u6D3E\u7ED9\u6307\u5B9A\u52A9\u624B\u6216\u6A21\u578B\u3002\u5E38\u89C4\u4EFB\u52A1\u4F18\u5148\u81EA\u884C\u5904\u7406\u6216\u4F7F\u7528\u5BBF\u4E3B\u5185\u7F6E\u5B50\u4EE3\u7406\u3002";
|
|
3705
|
+
var workspaceMcpCapabilityInstruction = "\u53EF\u8C03\u7528\u672C\u5DE5\u4F5C\u533A .pbot/mcp.json \u4E2D\u767B\u8BB0\u7684 MCP \u5DE5\u5177\u3002";
|
|
3706
|
+
var historyCapabilityInstruction = "\u53EF\u68C0\u7D22\u672C\u5DE5\u4F5C\u533A\u5404\u5BBF\u4E3B\u5F52\u6863\u7684\u95EE\u7B54\u548C\u6458\u8981\u3002";
|
|
3668
3707
|
function buildMcpInstructions(options) {
|
|
3669
3708
|
const parts = [workerCapabilityInstruction];
|
|
3670
3709
|
if (options.workspaceMcp) parts.push(workspaceMcpCapabilityInstruction);
|
|
3671
3710
|
if (options.history) parts.push(historyCapabilityInstruction);
|
|
3672
|
-
return parts.
|
|
3711
|
+
return parts.join("\n");
|
|
3673
3712
|
}
|
|
3674
3713
|
var mcpWorkerOnlyInstructions = buildMcpInstructions({ workspaceMcp: false, history: false });
|
|
3675
3714
|
var mcpInstructions = buildMcpInstructions({ workspaceMcp: true, history: true });
|
|
3676
3715
|
function defaultWorkerDirectory(workspaceRoot) {
|
|
3677
3716
|
if (process.env.PBOT_MCP_AGENT_DIR) return process.env.PBOT_MCP_AGENT_DIR;
|
|
3678
|
-
return
|
|
3717
|
+
return join13(workspaceRoot, ".pbot", "worker", "runtime");
|
|
3679
3718
|
}
|
|
3680
3719
|
function asString(args, key, required = false) {
|
|
3681
3720
|
const value = args[key];
|
|
@@ -3751,7 +3790,7 @@ var McpWorkerRuntime = class {
|
|
|
3751
3790
|
}
|
|
3752
3791
|
/** Mount the stdio sibling with the same worker ownership as the native host command. */
|
|
3753
3792
|
nativeServer(root) {
|
|
3754
|
-
const entry =
|
|
3793
|
+
const entry = join13(resourceRoot, "../lib/extension/mcp.js");
|
|
3755
3794
|
if (!existsSync3(entry)) return void 0;
|
|
3756
3795
|
requireThat(this.#defaultBackend, "\u539F\u751F MCP \u6302\u8F7D\u9700\u8981\u5BBF\u4E3B\u540D\u79F0\u3002");
|
|
3757
3796
|
return {
|
|
@@ -3911,14 +3950,15 @@ var McpWorkerRuntime = class {
|
|
|
3911
3950
|
const { name, args: rawArgs } = parseMcpToolCall(toolName, input);
|
|
3912
3951
|
requireThat(!this.#closing, "Personal Bot MCP \u670D\u52A1\u5DF2\u5173\u95ED\u3002");
|
|
3913
3952
|
const isWorkerScoped = name === "worker_close" || name === "worker_request" || name === "worker_response" || name === "worker_output";
|
|
3914
|
-
const
|
|
3953
|
+
const isTemplateQuery = name === "worker_discover" && rawArgs.target === "templates";
|
|
3954
|
+
const root = isWorkerScoped ? await this.resolveWorkerWorkspace(asString(rawArgs, "workerId", true), defaultWorkspace) : await this.resolveWorkspace(asString(rawArgs, "workspace", isTemplateQuery && rawArgs.workspace !== void 0) ?? defaultWorkspace);
|
|
3915
3955
|
const configuration = await readWorkspaceConfig(root);
|
|
3916
3956
|
requireThat(!this.#closing, "Personal Bot MCP \u670D\u52A1\u5DF2\u5173\u95ED\u3002");
|
|
3917
|
-
requireThat(configuration.enabled, workspaceDisabledMessage(configuration));
|
|
3957
|
+
requireThat(configuration.enabled, isTemplateQuery ? `\u65E0\u6CD5\u5728\u5DE5\u4F5C\u533A ${root} \u67E5\u8BE2\u52A9\u624B\u6A21\u677F\u3002` : workspaceDisabledMessage(configuration));
|
|
3918
3958
|
switch (name) {
|
|
3919
3959
|
case "workspace_mcp_discover":
|
|
3920
3960
|
case "workspace_mcp_call": {
|
|
3921
|
-
requireThat(!this.#nativeWorkspaceMcp, "\u5F53\u524D\u5BBF\u4E3B\u5DF2\u539F\u751F\u6302\u8F7D\u5DE5\u4F5C\u533A
|
|
3961
|
+
requireThat(!this.#nativeWorkspaceMcp, "\u5F53\u524D\u5BBF\u4E3B\u5DF2\u539F\u751F\u6302\u8F7D\u5DE5\u4F5C\u533A MCP \u670D\u52A1\uFF0C\u8BF7\u76F4\u63A5\u8C03\u7528\u5BF9\u5E94\u5DE5\u5177\u3002");
|
|
3922
3962
|
requireThat(workspaceFeatures(configuration).mcp, `\u5DE5\u4F5C\u533A\u7EDF\u4E00 MCP \u529F\u80FD\u5DF2\u5728 ${configuration.path} \u4E2D\u505C\u7528\uFF08features.mcp: false\uFF09\u3002`);
|
|
3923
3963
|
if (name === "workspace_mcp_discover") return this.#bridge.discover(root, asString(rawArgs, "server"));
|
|
3924
3964
|
const server = asString(rawArgs, "server", true);
|
|
@@ -3963,6 +4003,11 @@ var McpWorkerRuntime = class {
|
|
|
3963
4003
|
return { node: readWorkspaceHistory(root, id, offset, limit, childrenOffset, hostFilter) };
|
|
3964
4004
|
}
|
|
3965
4005
|
}
|
|
4006
|
+
if (isTemplateQuery) {
|
|
4007
|
+
const extra = Object.keys(rawArgs).find((key) => key !== "target" && key !== "workspace");
|
|
4008
|
+
requireThat(extra === void 0, `\u67E5\u8BE2\u6A21\u677F\u53EA\u63A5\u53D7 target \u548C workspace\uFF0C\u6536\u5230\u53C2\u6570 ${extra}\u3002`);
|
|
4009
|
+
return discoverWorkerTemplates(root);
|
|
4010
|
+
}
|
|
3966
4011
|
const { host, service, owner } = this.workerService(root, configuration.acp);
|
|
3967
4012
|
switch (name) {
|
|
3968
4013
|
case "worker_create": {
|
|
@@ -4033,12 +4078,11 @@ var McpWorkerRuntime = class {
|
|
|
4033
4078
|
return this.waitFor(service, owner, workerId, void 0, waitMs, offset, progress);
|
|
4034
4079
|
}
|
|
4035
4080
|
case "worker_discover": {
|
|
4036
|
-
const
|
|
4081
|
+
const target = asString(rawArgs, "target") ?? "overview";
|
|
4037
4082
|
requireThat(
|
|
4038
|
-
isOneOf(
|
|
4039
|
-
`\u53C2\u6570 target \u65E0\u6548\uFF1A${
|
|
4083
|
+
isOneOf(target, discoverTargets),
|
|
4084
|
+
`\u53C2\u6570 target \u65E0\u6548\uFF1A${target}\uFF08\u53EF\u7528\uFF1A${discoverTargets.join(", ")}\uFF09\u3002`
|
|
4040
4085
|
);
|
|
4041
|
-
const target = rawTarget;
|
|
4042
4086
|
const workerId = asString(rawArgs, "workerId");
|
|
4043
4087
|
const backendRaw = asString(rawArgs, "backend");
|
|
4044
4088
|
const model = asString(rawArgs, "model");
|