personal-bot 0.3.6 → 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.
- package/.claude-plugin/marketplace.json +2 -2
- package/.claude-plugin/plugin.json +1 -1
- package/docs/README.md +1 -1
- package/docs/architecture/model-context.md +1 -2
- package/docs/guides/capabilities.md +4 -8
- package/lib/antigravity-plugin/lib/extension/acp-worker.js +2 -2
- package/lib/antigravity-plugin/lib/extension/cli.js +11 -11
- package/lib/antigravity-plugin/lib/extension/mcp.js +66 -49
- package/lib/antigravity-plugin/lib/integrations/agent-resources.js +2 -2
- 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-worker.js +2 -2
- package/lib/extension/cli.js +11 -11
- package/lib/extension/mcp/tool-contract.js +49 -55
- package/lib/extension/mcp/workers.d.ts +6 -0
- package/lib/extension/mcp/workers.js +25 -8
- package/lib/extension/mcp.js +66 -49
- package/lib/integrations/agent-resources.js +2 -2
- 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/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/mcp/tool-contract.ts +49 -55
- package/src/extension/mcp/workers.ts +32 -10
- package/src/integrations/agent-resources.ts +2 -2
- package/src/pbot.ts +1 -1
- package/src/tools/history/contract.ts +12 -12
- 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/resources/references/compute-finance.md +0 -22
- package/resources/references/compute.md +0 -16
- package/resources/references/task-conductor.md +0 -25
|
@@ -6,21 +6,29 @@ disable-model-invocation: true
|
|
|
6
6
|
|
|
7
7
|
# Personal Bot 工作区
|
|
8
8
|
|
|
9
|
-
从当前 Claude 工作区根目录,通过 Bash 执行对应命令。`${CLAUDE_SKILL_DIR}`
|
|
9
|
+
从当前 Claude 工作区根目录,通过 Bash 执行对应命令。`${CLAUDE_SKILL_DIR}` 为本技能目录(位于插件内)。
|
|
10
|
+
|
|
11
|
+
## 初始化与状态
|
|
10
12
|
|
|
11
13
|
```sh
|
|
12
14
|
node "${CLAUDE_SKILL_DIR}/../../../../lib/claude.js" init
|
|
13
15
|
node "${CLAUDE_SKILL_DIR}/../../../../lib/claude.js" status
|
|
14
16
|
```
|
|
15
17
|
|
|
16
|
-
|
|
18
|
+
`init` 补建资料目录与根 `AGENTS.md` 并启用工作区,`status` 查看工作区及配置状态;省略参数时执行 `status`。
|
|
19
|
+
|
|
20
|
+
## 历史管理与检索
|
|
21
|
+
|
|
22
|
+
`--workspace` 传入当前会话的 `workspaceRoot`(工作区未启用时使用当前工作区根目录)。支持 `history status|list|summary|migrate|search|read`,保留用户指定参数(迁移预览加 `--dry-run`):
|
|
17
23
|
|
|
18
|
-
|
|
24
|
+
```sh
|
|
25
|
+
pbot history summary --workspace "<workspaceRoot>"
|
|
26
|
+
```
|
|
19
27
|
|
|
20
|
-
|
|
28
|
+
未安装全局 `pbot` 或版本不匹配时,直接运行随插件打包的 CLI:
|
|
21
29
|
|
|
22
30
|
```sh
|
|
23
|
-
node "${CLAUDE_SKILL_DIR}/../../../../lib/extension/
|
|
31
|
+
node "${CLAUDE_SKILL_DIR}/../../../../lib/extension/cli.js" history summary --workspace "<workspaceRoot>"
|
|
24
32
|
```
|
|
25
33
|
|
|
26
|
-
|
|
34
|
+
返回命令的实际结果和需要处理的错误。
|
|
@@ -4,6 +4,6 @@ description: 初始化 Personal Bot 工作区、查看状态、搜索归档或
|
|
|
4
4
|
disable-model-invocation: true
|
|
5
5
|
---
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
`--workspace` 传入当前会话的 `workspaceRoot`(工作区未启用时使用当前工作区根目录)。省略子命令时使用 `status`。可执行 `init`、`status`、`history status|list|summary|migrate|search|read`,保留用户指定的维度、模型和筛选参数。
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
若 `pbot --at-least <release>` 返回 0,运行 `pbot <子命令> --workspace "<workspaceRoot>"`;否则运行 `npx --yes personal-bot@<release> <子命令> --workspace "<workspaceRoot>"`。返回实际结果。
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
用户要求更新工作区历史摘要时,运行 `pbot history summary --workspace "<workspaceRoot>"`。需要按当前版本调用时,读取 `resourceRoot/../package.json` 的 `version`,用 `npx --yes personal-bot@<version>` 替换命令中的 `pbot`。
|
|
1
|
+
未指定其他程序时,默认直接处理或使用当前宿主原生子代理;需要委派其他程序(或按工作区 `AGENTS.md`、`agents/coordinator.md` 分工约定)时,使用 `pbot` MCP 的 `worker_*` 工具。工作区 `.pbot/mcp.json` 注册的 MCP 由宿主原生挂载,直接调用对应原生工具。回溯旧讨论用 `pbot_history`;更新历史摘要运行 `pbot history summary --workspace "<workspaceRoot>"`(未安装全局 `pbot` 时用 `node "<resourceRoot>/../lib/extension/cli.js"` 替换 `pbot`,也可请用户执行 `/pbot history summary`)。
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
用户要求更新工作区历史摘要时,运行 `pbot history summary --workspace "<workspaceRoot>"`。需要按当前版本调用时,读取 `resourceRoot/../package.json` 的 `version`,用 `npx --yes personal-bot@<version>` 替换命令中的 `pbot`。
|
|
1
|
+
未指定其他程序时,默认直接处理或使用当前宿主原生子代理;需要委派其他程序(或按工作区 `AGENTS.md`、`agents/coordinator.md` 分工约定)时,使用 `pbot` MCP 的 `worker_*` 工具。调用 `.pbot/mcp.json` 中的工作区 MCP 用 `workspace_mcp_discover` / `workspace_mcp_call`,回溯旧讨论用 `history_search` / `history_read`;更新历史摘要运行 `pbot history summary --workspace "<workspaceRoot>"`(未安装全局 `pbot` 时用 `node "<resourceRoot>/../lib/extension/cli.js"` 替换 `pbot`)。
|
|
@@ -1,31 +1,27 @@
|
|
|
1
1
|
# Personal Bot
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
按用户请求和已有约定推进工作,常规选择自行决定;只有缺失信息会改变目标或关键结果时才提问。超时、取消或断连后,先查状态再决定是否重试,避免重复执行。
|
|
4
4
|
|
|
5
|
-
##
|
|
5
|
+
## 资料与工作区
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
- 操作后查看结果。超时、取消或断连后,先查状态再决定是否重试,避免重复执行。
|
|
9
|
-
- 优先复用工作区已接入的 CLI/MCP:工作区共享 MCP 定义在 `.pbot/mcp.json`(可通过宿主原生工具或 `pbot` MCP 的 `workspace_mcp_discover` / `workspace_mcp_call` 调用),也可同时使用宿主原生 MCP。接入或排障使用 `provider-connections` 技能;需要数据口径或使用限制时读取 `providers/<id>/GUIDE.md`。认证使用原生登录或环境变量引用,资料中不保存凭据值。
|
|
10
|
-
|
|
11
|
-
## 资料与环境
|
|
12
|
-
|
|
13
|
-
沿用已有工作区约定;新资料按下列用途组织,正文维护一份,其他位置用引用连接。
|
|
7
|
+
回查或续做项目时,按用户称呼从根 `AGENTS.md` 找到项目入口,必要时按主题或交付物名称搜索。已有工作区布局与约定优先;新资料按下列用途组织,同主题正文维护一份,其他位置用引用连接:
|
|
14
8
|
|
|
15
9
|
| 路径 | 用途 |
|
|
16
10
|
| --- | --- |
|
|
17
11
|
| `AGENTS.md` | 资料导航与已确认的工作区约定 |
|
|
18
12
|
| `areas/<领域>/` | 长期目标、约束、决策与复盘 |
|
|
19
|
-
| `projects/<名称>/` |
|
|
13
|
+
| `projects/<名称>/` | 任务定义、结论、交付物与源码 |
|
|
20
14
|
| `knowledge/<主题>/` | 可跨任务复用的概念、方法与口径 |
|
|
21
|
-
| `providers
|
|
22
|
-
| `scratch/` |
|
|
15
|
+
| `providers/` | `AGENTS.md`(能力导航)与 `<id>/GUIDE.md`(使用手册) |
|
|
16
|
+
| `scratch/` | 临时脚本、中间数据、下载与运行环境 |
|
|
23
17
|
| `agents/` | `coordinator.md`、`general-purpose.md` 的职责补充 |
|
|
24
|
-
| `.agents/skills/<名称>/SKILL.md` |
|
|
25
|
-
| `.pbot/mcp.json` | 工作区共享 MCP
|
|
18
|
+
| `.agents/skills/<名称>/SKILL.md` | 工作区自有技能(跨宿主通用) |
|
|
19
|
+
| `.pbot/mcp.json` | 工作区共享 MCP 服务清单 |
|
|
26
20
|
|
|
27
21
|
保存有后续用途的结论、方法、决策和产物,普通问答不逐轮存档;更新、归集或整理资料时使用 `project-maintenance` 技能。保留用户资料、历史记录和备份。
|
|
28
22
|
|
|
29
|
-
|
|
23
|
+
## 工具与环境
|
|
24
|
+
|
|
25
|
+
优先复用工作区已接入的 CLI 与 MCP;接入或排障使用 `provider-connections` 技能,查数据口径或限制读 `providers/<id>/GUIDE.md`。资料与配置不保存明文凭据,使用环境变量引用或原生登录。计算、构建和测试遵循项目声明的环境。
|
|
30
26
|
|
|
31
|
-
|
|
27
|
+
环境上下文给出 `host`、`workspaceRoot`(资料工作区根目录)和 `resourceRoot`(包内资料根目录);资料路径相对 `workspaceRoot`,命令与文件工具按实际 cwd 解析。答复先给结论与产物路径,关键未知、前提和风险说清一次,数值注明对象、期间、单位与口径。
|
|
@@ -15,7 +15,7 @@ description: 接入或修复工作区共享 MCP 与原生 CLI/MCP,核对认证
|
|
|
15
15
|
|
|
16
16
|
接入新 MCP 前先判断归属;边界不明确或用户未说明作用域时,写入前先向用户确认放工作区共享还是当前宿主原生:
|
|
17
17
|
|
|
18
|
-
- **工作区共享 MCP(`.pbot/mcp.json`)**:归属当前工作区业务、需要跨宿主(Pi、dsh、Claude Code、Antigravity、Codex 及 ACP worker)共用,使用 stdio 或 Streamable HTTP + 环境变量/本地凭据,纯 `tools/list` + `tools/call` 请求-响应且可并发连接的服务。
|
|
18
|
+
- **工作区共享 MCP(`.pbot/mcp.json`)**:归属当前工作区业务、需要跨宿主(Pi、dsh、Claude Code、Antigravity、Codex、Qoder CLI 及 ACP worker)共用,使用 stdio 或 Streamable HTTP + 环境变量/本地凭据,纯 `tools/list` + `tools/call` 请求-响应且可并发连接的服务。
|
|
19
19
|
- **宿主原生 MCP(全局或项目级)**:满足以下任一条件时走当前宿主原生入口,不写入 `.pbot/mcp.json`:
|
|
20
20
|
1. 跨项目通用的本机全局基础设施或开发工具(如浏览器调试、全局调度);
|
|
21
21
|
2. 依赖宿主浏览器交互式 OAuth 登录;
|
|
@@ -27,14 +27,14 @@ description: 接入或修复工作区共享 MCP 与原生 CLI/MCP,核对认证
|
|
|
27
27
|
|
|
28
28
|
不保存明文凭据,使用 `${ENV_VAR}` 引用,保留无关项,不能使用保留名 `pbot`:
|
|
29
29
|
|
|
30
|
-
- **查看**:`pbot mcp list --workspace <workspaceRoot
|
|
31
|
-
- **新增 / 更新 stdio**:`pbot mcp add <name> --workspace <workspaceRoot> [--env K
|
|
32
|
-
- **新增 / 更新 HTTP**:`pbot mcp add <name> --workspace <workspaceRoot> --url https://... [--header Authorization=
|
|
33
|
-
- **删除**:`pbot mcp remove <name> --workspace <workspaceRoot
|
|
30
|
+
- **查看**:`pbot mcp list --workspace "<workspaceRoot>"`(若当前环境提供 `workspace_mcp_discover` 也可直接查询)
|
|
31
|
+
- **新增 / 更新 stdio**:`pbot mcp add <name> --workspace "<workspaceRoot>" [--env 'K=${VAR}'] [--cwd .] [--description "..."] -- <command> [args...]`
|
|
32
|
+
- **新增 / 更新 HTTP**:`pbot mcp add <name> --workspace "<workspaceRoot>" --url https://... [--header 'Authorization=Bearer ${TOKEN}'] [--description "..."]`
|
|
33
|
+
- **删除**:`pbot mcp remove <name> --workspace "<workspaceRoot>"`
|
|
34
34
|
|
|
35
35
|
生效方式(原生挂载与桥接二选一,不重复暴露):
|
|
36
36
|
- Pi 执行 `/reload`、dsh 重启会话后由宿主直接原生挂载(不暴露 `workspace_mcp_*`);
|
|
37
|
-
-
|
|
37
|
+
- 通过 `workspace_mcp_discover` / `workspace_mcp_call` 桥接的宿主即改即生效,无需重启;
|
|
38
38
|
- ACP worker 在下次新建或恢复会话时自动加载最新 `.pbot/mcp.json`。
|
|
39
39
|
|
|
40
40
|
## 宿主原生 MCP
|
|
@@ -43,6 +43,7 @@ description: 接入或修复工作区共享 MCP 与原生 CLI/MCP,核对认证
|
|
|
43
43
|
- **`host = dsh`**:通过原生界面或 profile 配置管理(注意同一 profile 可能被多工作区共用)。
|
|
44
44
|
- **`host = claude`**:`claude mcp add --scope project --transport http <server> <url>`(写入 `.mcp.json`),改完后请用户在会话中用 `/mcp` 核对认证与工具。
|
|
45
45
|
- **`host = antigravity`**:全局使用 `agy mcp add <name> <commandOrUrl> [args...]` / `agy mcp remove <name>`(管理 `~/.gemini/config/mcp_config.json`),通过 `agy mcp list` 或 UI 面板核对。
|
|
46
|
+
- **其他宿主(如 `codex`、`qoder`)**:使用该宿主自身的原生 MCP 命令或配置入口管理。
|
|
46
47
|
|
|
47
48
|
## 验证与手册
|
|
48
49
|
|
|
@@ -11,7 +11,7 @@ export const discoverTargets = ["overview", "workers", "backends", "models"] as
|
|
|
11
11
|
function formatBackendItem(entry: ReturnType<typeof inspectAcpBackends>[number], defaultBackend?: string): string {
|
|
12
12
|
const tags: string[] = [];
|
|
13
13
|
if (entry.label) tags.push(entry.label);
|
|
14
|
-
if (entry.backend === defaultBackend) tags.push("
|
|
14
|
+
if (entry.backend === defaultBackend) tags.push("当前宿主");
|
|
15
15
|
return tags.length ? `${entry.backend}(${tags.join(",")})` : entry.backend;
|
|
16
16
|
}
|
|
17
17
|
|
|
@@ -34,8 +34,8 @@ function workspaceProperty(workspaceBound: boolean) {
|
|
|
34
34
|
return {
|
|
35
35
|
type: "string",
|
|
36
36
|
description: workspaceBound
|
|
37
|
-
? "
|
|
38
|
-
: "
|
|
37
|
+
? "工作区根目录绝对路径;默认当前工作区,通常省略。"
|
|
38
|
+
: "目标工作区根目录绝对路径;请传入环境中的 workspaceRoot。",
|
|
39
39
|
};
|
|
40
40
|
}
|
|
41
41
|
|
|
@@ -50,8 +50,7 @@ export function buildPbotWorkerTools(commands: AcpCommands = {}, defaultBackend?
|
|
|
50
50
|
{
|
|
51
51
|
name: "worker_create" as const,
|
|
52
52
|
description:
|
|
53
|
-
"
|
|
54
|
-
"本工具仅建立会话并返回 workerId,随后通过 worker_request 发送具体任务。不需要借助其他助手时,优先自行完成或使用当前内置子代理。\n" +
|
|
53
|
+
"启动独立的外部助手会话并返回 workerId(不发送任务,随后用 worker_request 派发)。未指定其他助手或特定模型时,优先自行完成或使用当前内置子代理。\n" +
|
|
55
54
|
overview,
|
|
56
55
|
annotations: {
|
|
57
56
|
title: "Create Worker",
|
|
@@ -67,19 +66,19 @@ export function buildPbotWorkerTools(commands: AcpCommands = {}, defaultBackend?
|
|
|
67
66
|
properties: {
|
|
68
67
|
backend: {
|
|
69
68
|
type: "string",
|
|
70
|
-
description: "
|
|
69
|
+
description: "目标外部助手标识(不区分大小写,支持常见别名如 claude-code、agy)。",
|
|
71
70
|
},
|
|
72
71
|
model: {
|
|
73
72
|
type: "string",
|
|
74
|
-
description: "
|
|
73
|
+
description: "目标模型(模型 ID、显示名或 provider/model,不区分大小写);未明确指定时省略以用默认模型,不确定可选值时先查 worker_discover(target=\"models\")。",
|
|
75
74
|
},
|
|
76
75
|
thinking: {
|
|
77
76
|
type: "string",
|
|
78
|
-
description: "
|
|
77
|
+
description: "思考深度(如 low / medium / high / xhigh / max,不区分大小写);未明确指定时省略以用默认设置。",
|
|
79
78
|
},
|
|
80
79
|
cwd: {
|
|
81
80
|
type: "string",
|
|
82
|
-
description: "
|
|
81
|
+
description: "执行目录(绝对路径或相对工作区路径),默认工作区根目录。",
|
|
83
82
|
},
|
|
84
83
|
workspace,
|
|
85
84
|
},
|
|
@@ -88,7 +87,7 @@ export function buildPbotWorkerTools(commands: AcpCommands = {}, defaultBackend?
|
|
|
88
87
|
{
|
|
89
88
|
name: "worker_close" as const,
|
|
90
89
|
description:
|
|
91
|
-
"
|
|
90
|
+
"结束外部助手会话并释放进程。若该会话支持恢复(capabilities.resume),后续仍可直接用 worker_request 续接。",
|
|
92
91
|
annotations: {
|
|
93
92
|
title: "Close Worker",
|
|
94
93
|
readOnlyHint: false,
|
|
@@ -103,7 +102,7 @@ export function buildPbotWorkerTools(commands: AcpCommands = {}, defaultBackend?
|
|
|
103
102
|
properties: {
|
|
104
103
|
workerId: {
|
|
105
104
|
type: "string",
|
|
106
|
-
description: "
|
|
105
|
+
description: "助手会话 ID(来自 worker_create 或 worker_discover)。",
|
|
107
106
|
},
|
|
108
107
|
workspace,
|
|
109
108
|
},
|
|
@@ -112,9 +111,8 @@ export function buildPbotWorkerTools(commands: AcpCommands = {}, defaultBackend?
|
|
|
112
111
|
{
|
|
113
112
|
name: "worker_request" as const,
|
|
114
113
|
description:
|
|
115
|
-
"
|
|
116
|
-
`默认最多等待 ${defaultWaitMs / 1000}
|
|
117
|
-
"若返回 timedOut 或结果含 nextOffset,用 worker_output 继续等待或翻页;若返回 needsResponse,先向用户确认再用 worker_response 回复。",
|
|
114
|
+
"向外部助手派发任务或在同一上下文中追问(已关闭且支持恢复的会话会自动续接)。" +
|
|
115
|
+
`默认最多等待 ${defaultWaitMs / 1000} 秒(waitMs 设为 0 可立即转后台并行);返回 timedOut 或 nextOffset 用 worker_output,返回 needsResponse 先向用户确认再用 worker_response。`,
|
|
118
116
|
annotations: {
|
|
119
117
|
title: "Send Request to Worker",
|
|
120
118
|
readOnlyHint: false,
|
|
@@ -129,17 +127,17 @@ export function buildPbotWorkerTools(commands: AcpCommands = {}, defaultBackend?
|
|
|
129
127
|
properties: {
|
|
130
128
|
workerId: {
|
|
131
129
|
type: "string",
|
|
132
|
-
description: "
|
|
130
|
+
description: "助手会话 ID(来自 worker_create 或 worker_discover)。",
|
|
133
131
|
},
|
|
134
132
|
message: {
|
|
135
133
|
type: "string",
|
|
136
|
-
description: "
|
|
134
|
+
description: "任务说明或追问内容。外部助手看不到当前会话历史,首次派发需写清背景、目标、相关文件路径、约束和期望产出。",
|
|
137
135
|
},
|
|
138
136
|
waitMs: {
|
|
139
137
|
type: "integer",
|
|
140
138
|
minimum: 0,
|
|
141
139
|
maximum: maxWaitMs,
|
|
142
|
-
description:
|
|
140
|
+
description: `最多等待毫秒数(默认 ${defaultWaitMs});0 表示立即返回转后台执行。`,
|
|
143
141
|
},
|
|
144
142
|
workspace,
|
|
145
143
|
},
|
|
@@ -148,9 +146,8 @@ export function buildPbotWorkerTools(commands: AcpCommands = {}, defaultBackend?
|
|
|
148
146
|
{
|
|
149
147
|
name: "worker_response" as const,
|
|
150
148
|
description:
|
|
151
|
-
"
|
|
152
|
-
|
|
153
|
-
`提交前先向用户确认;提交后默认最多等待 ${defaultWaitMs / 1000} 秒返回后续结果(waitMs 设为 0 立即返回)。`,
|
|
149
|
+
"回复外部助手暂停时发出的待处理请求(needsResponse: true),支持操作授权、表单问答与链接确认。" +
|
|
150
|
+
`提交前先向用户确认;提交后默认等待最多 ${defaultWaitMs / 1000} 秒返回后续结果。`,
|
|
154
151
|
annotations: {
|
|
155
152
|
title: "Respond to Worker Request",
|
|
156
153
|
readOnlyHint: false,
|
|
@@ -170,26 +167,26 @@ export function buildPbotWorkerTools(commands: AcpCommands = {}, defaultBackend?
|
|
|
170
167
|
action: {
|
|
171
168
|
type: "string",
|
|
172
169
|
enum: [...acpElicitationActions],
|
|
173
|
-
description: "
|
|
170
|
+
description: "accept 同意/提交表单/确认链接;decline 拒绝;cancel 取消请求。",
|
|
174
171
|
},
|
|
175
172
|
requestId: {
|
|
176
173
|
type: "string",
|
|
177
|
-
description: "
|
|
174
|
+
description: "请求 ID(pendingRequests[].requestId);仅一条待处理请求时可省略,多条时必填。",
|
|
178
175
|
},
|
|
179
176
|
optionId: {
|
|
180
177
|
type: "string",
|
|
181
|
-
description: "
|
|
178
|
+
description: "仅 permission 请求且 action≠cancel 时可用:指定 pendingRequests[].options[].optionId,省略则按 action 单次允许或拒绝。",
|
|
182
179
|
},
|
|
183
180
|
content: {
|
|
184
181
|
type: "object",
|
|
185
182
|
additionalProperties: true,
|
|
186
|
-
description: "
|
|
183
|
+
description: "仅 form 请求且 action=\"accept\" 时可用:按 pendingRequests[].schema.properties 填写回答对象(值为字符串、数字、布尔值或字符串数组)。",
|
|
187
184
|
},
|
|
188
185
|
waitMs: {
|
|
189
186
|
type: "integer",
|
|
190
187
|
minimum: 0,
|
|
191
188
|
maximum: maxWaitMs,
|
|
192
|
-
description:
|
|
189
|
+
description: `提交后最多等待毫秒数(默认 ${defaultWaitMs});0 表示立即返回。`,
|
|
193
190
|
},
|
|
194
191
|
workspace,
|
|
195
192
|
},
|
|
@@ -198,8 +195,7 @@ export function buildPbotWorkerTools(commands: AcpCommands = {}, defaultBackend?
|
|
|
198
195
|
{
|
|
199
196
|
name: "worker_output" as const,
|
|
200
197
|
description:
|
|
201
|
-
"
|
|
202
|
-
"任务仍在运行时会等待其完成(也可能返回 timedOut 或 needsResponse),已结束则立即返回。",
|
|
198
|
+
"获取或等待外部助手的最新结果,用于收取后台产出、timedOut 后继续等待,或按 nextOffset 分页续读。任务已结束时立即返回,运行中最多等待 waitMs。",
|
|
203
199
|
annotations: {
|
|
204
200
|
title: "Get Worker Output",
|
|
205
201
|
readOnlyHint: true,
|
|
@@ -214,18 +210,18 @@ export function buildPbotWorkerTools(commands: AcpCommands = {}, defaultBackend?
|
|
|
214
210
|
properties: {
|
|
215
211
|
workerId: {
|
|
216
212
|
type: "string",
|
|
217
|
-
description: "
|
|
213
|
+
description: "助手会话 ID。",
|
|
218
214
|
},
|
|
219
215
|
offset: {
|
|
220
216
|
type: "integer",
|
|
221
217
|
minimum: 0,
|
|
222
|
-
description: "
|
|
218
|
+
description: "读取起始位置(默认 0);翻页续读时传上次返回的 nextOffset。",
|
|
223
219
|
},
|
|
224
220
|
waitMs: {
|
|
225
221
|
type: "integer",
|
|
226
222
|
minimum: 0,
|
|
227
223
|
maximum: maxWaitMs,
|
|
228
|
-
description:
|
|
224
|
+
description: `运行中最多等待毫秒数(默认 ${defaultWaitMs});已结束或翻页时立即返回。`,
|
|
229
225
|
},
|
|
230
226
|
workspace,
|
|
231
227
|
},
|
|
@@ -234,8 +230,7 @@ export function buildPbotWorkerTools(commands: AcpCommands = {}, defaultBackend?
|
|
|
234
230
|
{
|
|
235
231
|
name: "worker_discover" as const,
|
|
236
232
|
description:
|
|
237
|
-
"
|
|
238
|
-
"默认(target=\"overview\")同时返回可用助手与已有会话;仅在需要核对模型或思考深度可选值时再查 target=\"models\"(耗时较长)。",
|
|
233
|
+
"查询可用外部助手、已有会话状态,或某个助手支持的模型与思考深度。默认(overview)返回可用助手与已有会话;仅需核对模型或思考深度可选值时再查 models(需启动探测,耗时较长)。",
|
|
239
234
|
annotations: {
|
|
240
235
|
title: "Discover Workers, Backends & Models",
|
|
241
236
|
readOnlyHint: true,
|
|
@@ -251,21 +246,21 @@ export function buildPbotWorkerTools(commands: AcpCommands = {}, defaultBackend?
|
|
|
251
246
|
target: {
|
|
252
247
|
type: "string",
|
|
253
248
|
enum: [...discoverTargets],
|
|
254
|
-
description: "
|
|
249
|
+
description: "overview(默认,可用助手与已有会话)、workers(全部或单个会话状态)、backends(可用助手)、models(指定助手的模型与思考深度)。",
|
|
255
250
|
},
|
|
256
251
|
workerId: {
|
|
257
252
|
type: "string",
|
|
258
|
-
description: "仅 target=\"workers\"
|
|
253
|
+
description: "仅 target=\"workers\" 可用:指定单个会话 ID,省略列全部。",
|
|
259
254
|
},
|
|
260
255
|
backend: {
|
|
261
256
|
type: "string",
|
|
262
257
|
description: availableIds
|
|
263
|
-
? `仅 target="models" 可用(${modelsBackendHint}
|
|
264
|
-
: `仅 target="models" 可用(${modelsBackendHint}
|
|
258
|
+
? `仅 target="models" 可用(${modelsBackendHint}):目标助手标识,支持别名;当前可用:${availableIds}。`
|
|
259
|
+
: `仅 target="models" 可用(${modelsBackendHint}):目标助手标识,支持别名。`,
|
|
265
260
|
},
|
|
266
261
|
model: {
|
|
267
262
|
type: "string",
|
|
268
|
-
description: "仅 target=\"models\"
|
|
263
|
+
description: "仅 target=\"models\" 可用:指定模型以查看其支持的思考深度选项。",
|
|
269
264
|
},
|
|
270
265
|
workspace,
|
|
271
266
|
},
|
|
@@ -280,7 +275,7 @@ export function buildWorkspaceMcpTools(workspaceBound = false) {
|
|
|
280
275
|
{
|
|
281
276
|
name: "workspace_mcp_discover" as const,
|
|
282
277
|
description:
|
|
283
|
-
"
|
|
278
|
+
"查询当前工作区共享 MCP 服务(.pbot/mcp.json)。省略 server 列出服务;传入 server 返回其工具列表与参数说明。",
|
|
284
279
|
annotations: {
|
|
285
280
|
title: "Discover Workspace MCP Servers & Tools",
|
|
286
281
|
readOnlyHint: true,
|
|
@@ -295,7 +290,7 @@ export function buildWorkspaceMcpTools(workspaceBound = false) {
|
|
|
295
290
|
properties: {
|
|
296
291
|
server: {
|
|
297
292
|
type: "string",
|
|
298
|
-
description: "
|
|
293
|
+
description: "服务名称;省略列出工作区全部已配置服务。",
|
|
299
294
|
},
|
|
300
295
|
workspace,
|
|
301
296
|
},
|
|
@@ -304,8 +299,7 @@ export function buildWorkspaceMcpTools(workspaceBound = false) {
|
|
|
304
299
|
{
|
|
305
300
|
name: "workspace_mcp_call" as const,
|
|
306
301
|
description:
|
|
307
|
-
"
|
|
308
|
-
"不确定工具名或参数格式时,先用 workspace_mcp_discover(server) 查询。",
|
|
302
|
+
"调用工作区共享 MCP 服务中的指定工具。不确定工具名或参数时先用 workspace_mcp_discover(server) 查询。",
|
|
309
303
|
annotations: {
|
|
310
304
|
title: "Call Workspace MCP Tool",
|
|
311
305
|
readOnlyHint: false,
|
|
@@ -320,16 +314,16 @@ export function buildWorkspaceMcpTools(workspaceBound = false) {
|
|
|
320
314
|
properties: {
|
|
321
315
|
server: {
|
|
322
316
|
type: "string",
|
|
323
|
-
description: "
|
|
317
|
+
description: "服务名称(来自 workspace_mcp_discover)。",
|
|
324
318
|
},
|
|
325
319
|
tool: {
|
|
326
320
|
type: "string",
|
|
327
|
-
description: "
|
|
321
|
+
description: "工具名称。",
|
|
328
322
|
},
|
|
329
323
|
arguments: {
|
|
330
324
|
type: "object",
|
|
331
325
|
additionalProperties: true,
|
|
332
|
-
description: "
|
|
326
|
+
description: "传给目标工具的参数对象,默认空对象。",
|
|
333
327
|
},
|
|
334
328
|
workspace,
|
|
335
329
|
},
|
|
@@ -344,7 +338,7 @@ export function buildHistoryMcpTools(workspaceBound = false) {
|
|
|
344
338
|
{
|
|
345
339
|
name: "history_search" as const,
|
|
346
340
|
description:
|
|
347
|
-
"
|
|
341
|
+
"搜索当前工作区跨宿主历史问答与摘要归档(不含工具调用日志)。省略 query 列出各会话或指定维度摘要;传入 query 按不区分大小写的连续关键词匹配。",
|
|
348
342
|
annotations: {
|
|
349
343
|
title: "Search Workspace History",
|
|
350
344
|
readOnlyHint: true,
|
|
@@ -359,15 +353,15 @@ export function buildHistoryMcpTools(workspaceBound = false) {
|
|
|
359
353
|
properties: {
|
|
360
354
|
host: {
|
|
361
355
|
type: "string",
|
|
362
|
-
description: "
|
|
356
|
+
description: "来源宿主筛选(如 pi、dsh、claude、antigravity、codex、qoder);省略查全部。",
|
|
363
357
|
},
|
|
364
358
|
dimension: {
|
|
365
359
|
type: "string",
|
|
366
|
-
description: "
|
|
360
|
+
description: "范围筛选:raw 仅原文,或指定摘要维度(如 monthly、session);省略查全部。",
|
|
367
361
|
},
|
|
368
362
|
query: {
|
|
369
363
|
type: "string",
|
|
370
|
-
description: "
|
|
364
|
+
description: "连续关键词(不区分大小写);省略列会话或指定维度摘要。",
|
|
371
365
|
},
|
|
372
366
|
sessionId: {
|
|
373
367
|
type: "string",
|
|
@@ -384,13 +378,13 @@ export function buildHistoryMcpTools(workspaceBound = false) {
|
|
|
384
378
|
offset: {
|
|
385
379
|
type: "integer",
|
|
386
380
|
minimum: 0,
|
|
387
|
-
description: "
|
|
381
|
+
description: "结果偏移,默认 0。",
|
|
388
382
|
},
|
|
389
383
|
limit: {
|
|
390
384
|
type: "integer",
|
|
391
385
|
minimum: 1,
|
|
392
386
|
maximum: historyPageLimits.search.max,
|
|
393
|
-
description:
|
|
387
|
+
description: `返回条数(1–${historyPageLimits.search.max}),默认 ${historyPageLimits.search.default}。`,
|
|
394
388
|
},
|
|
395
389
|
workspace,
|
|
396
390
|
},
|
|
@@ -399,7 +393,7 @@ export function buildHistoryMcpTools(workspaceBound = false) {
|
|
|
399
393
|
{
|
|
400
394
|
name: "history_read" as const,
|
|
401
395
|
description:
|
|
402
|
-
"按节点 id
|
|
396
|
+
"按节点 id 读取历史正文与上下级(可从 monthly 汇总下钻至 session 摘要和 exchange 原文)。正文分页传 nextOffset,子节点分页传 nextChildrenOffset。",
|
|
403
397
|
annotations: {
|
|
404
398
|
title: "Read Workspace History Node",
|
|
405
399
|
readOnlyHint: true,
|
|
@@ -414,16 +408,16 @@ export function buildHistoryMcpTools(workspaceBound = false) {
|
|
|
414
408
|
properties: {
|
|
415
409
|
id: {
|
|
416
410
|
type: "string",
|
|
417
|
-
description: "history_search
|
|
411
|
+
description: "节点 id(来自 history_search 或上下级)。",
|
|
418
412
|
},
|
|
419
413
|
host: {
|
|
420
414
|
type: "string",
|
|
421
|
-
description: "
|
|
415
|
+
description: "跨宿主 id 冲突时指定来源宿主。",
|
|
422
416
|
},
|
|
423
417
|
offset: {
|
|
424
418
|
type: "integer",
|
|
425
419
|
minimum: 0,
|
|
426
|
-
description: "正文字符偏移,默认 0。",
|
|
420
|
+
description: "正文字符偏移,默认 0;续读传上次 nextOffset。",
|
|
427
421
|
},
|
|
428
422
|
limit: {
|
|
429
423
|
type: "integer",
|
|
@@ -434,7 +428,7 @@ export function buildHistoryMcpTools(workspaceBound = false) {
|
|
|
434
428
|
childrenOffset: {
|
|
435
429
|
type: "integer",
|
|
436
430
|
minimum: 0,
|
|
437
|
-
description: "
|
|
431
|
+
description: "子节点偏移,默认 0;续读传上次 nextChildrenOffset。",
|
|
438
432
|
},
|
|
439
433
|
workspace,
|
|
440
434
|
},
|
|
@@ -40,15 +40,27 @@ const progressIntervalMs = 5_000;
|
|
|
40
40
|
|
|
41
41
|
export type ProgressReporter = (message: string) => void;
|
|
42
42
|
|
|
43
|
-
|
|
44
|
-
"
|
|
45
|
-
"
|
|
43
|
+
const workerCapabilityInstruction =
|
|
44
|
+
"跨助手委派(worker_*):启动并调度其他外部助手在当前工作区独立执行任务;无需外部助手时优先自行完成或使用内置子代理。" +
|
|
45
|
+
"流程:worker_create 启动(或 worker_discover 复用)→ worker_request 派发/追问 → 完成后 worker_close;" +
|
|
46
|
+
"后台取结果、超时续等(timedOut)或翻页(nextOffset)用 worker_output;返回 needsResponse 时先向用户确认,再用 worker_response 回复。";
|
|
47
|
+
|
|
48
|
+
const workspaceMcpCapabilityInstruction =
|
|
49
|
+
"工作区共享 MCP(workspace_mcp_*):先用 workspace_mcp_discover 查 .pbot/mcp.json 中的服务与工具,再用 workspace_mcp_call 调用。";
|
|
50
|
+
|
|
51
|
+
const historyCapabilityInstruction =
|
|
52
|
+
"跨宿主历史(history_search / history_read):只读检索当前工作区跨宿主记录的历史问答与摘要归档。";
|
|
53
|
+
|
|
54
|
+
export function buildMcpInstructions(options: { workspaceMcp: boolean; history: boolean }): string {
|
|
55
|
+
const parts = [workerCapabilityInstruction];
|
|
56
|
+
if (options.workspaceMcp) parts.push(workspaceMcpCapabilityInstruction);
|
|
57
|
+
if (options.history) parts.push(historyCapabilityInstruction);
|
|
58
|
+
return parts.length === 1 ? parts[0]! : parts.map((text, index) => `${index + 1}. ${text}`).join("\n");
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export const mcpWorkerOnlyInstructions = buildMcpInstructions({ workspaceMcp: false, history: false });
|
|
46
62
|
|
|
47
|
-
export const mcpInstructions =
|
|
48
|
-
"提供三类能力:\n" +
|
|
49
|
-
"1. 跨助手协作(worker_*):启动并调度其他外部 AI 助手在当前工作区中独立执行任务,适用于用户指定其他助手、需要特定模型或思考深度、获取独立审查/第二意见,或并行处理子任务。不需要借助其他助手时,优先自行完成或使用当前内置子代理。使用流程:worker_create 启动助手(或 worker_discover 复用已有会话)→ worker_request 派发任务或追问 → 完成后 worker_close 结束;后台等待、超时续等(timedOut)或长结果翻页(nextOffset)用 worker_output;返回 needsResponse 时先向用户确认,再用 worker_response 回复。\n" +
|
|
50
|
-
"2. 工作区共享外部工具(workspace_mcp_*):发现并调用当前工作区接入的外部工具服务与数据源(可与当前环境原生工具同时使用)。先用 workspace_mcp_discover 查看可用服务与工具说明,再用 workspace_mcp_call 调用。\n" +
|
|
51
|
-
"3. 跨宿主历史查询(history_search / history_read):只读检索当前工作区在 Pi、dsh、Claude Code、Antigravity 等宿主中记录的历史问答与摘要归档。";
|
|
63
|
+
export const mcpInstructions = buildMcpInstructions({ workspaceMcp: true, history: true });
|
|
52
64
|
|
|
53
65
|
export function defaultWorkerDirectory(): string {
|
|
54
66
|
if (process.env.PBOT_MCP_AGENT_DIR) return process.env.PBOT_MCP_AGENT_DIR;
|
|
@@ -252,7 +264,7 @@ export class McpWorkerRuntime {
|
|
|
252
264
|
return entry;
|
|
253
265
|
}
|
|
254
266
|
|
|
255
|
-
async
|
|
267
|
+
private async resolveToolContext() {
|
|
256
268
|
let commands: AcpCommands | undefined;
|
|
257
269
|
let includeWorkspaceMcp = !this.#nativeWorkspaceMcp;
|
|
258
270
|
let includeHistory = !this.#nativeHistory;
|
|
@@ -266,6 +278,16 @@ export class McpWorkerRuntime {
|
|
|
266
278
|
includeHistory = !this.#nativeHistory && features.history;
|
|
267
279
|
}
|
|
268
280
|
} catch { /* Fall back to registered built-in harnesses when cwd is outside an enabled workspace. */ }
|
|
281
|
+
return { commands, includeWorkspaceMcp, includeHistory };
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
async serverInstructions(): Promise<string> {
|
|
285
|
+
const { includeWorkspaceMcp, includeHistory } = await this.resolveToolContext();
|
|
286
|
+
return buildMcpInstructions({ workspaceMcp: includeWorkspaceMcp, history: includeHistory });
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
async toolDefinitions() {
|
|
290
|
+
const { commands, includeWorkspaceMcp, includeHistory } = await this.resolveToolContext();
|
|
269
291
|
const defaultBackend = this.#defaultBackend ? canonicalAcpBackend(this.#defaultBackend, commands) : undefined;
|
|
270
292
|
const workspaceBound = Boolean(pluginMcpWorkspaceRoot());
|
|
271
293
|
return [
|
|
@@ -556,7 +578,7 @@ export async function handleMcpRequest(
|
|
|
556
578
|
protocolVersion: requested || protocolVersion,
|
|
557
579
|
capabilities: { tools: {} },
|
|
558
580
|
serverInfo: { name: "personal-bot", version: packageVersion },
|
|
559
|
-
instructions: runtime.
|
|
581
|
+
instructions: await runtime.serverInstructions(),
|
|
560
582
|
},
|
|
561
583
|
};
|
|
562
584
|
}
|
|
@@ -37,7 +37,7 @@ export async function agentText(
|
|
|
37
37
|
export function formatWorkspaceSkills(skills: readonly WorkspaceSkillMeta[]): string {
|
|
38
38
|
if (!skills.length) return "";
|
|
39
39
|
const lines = skills.map(skill => `- **${skill.name}**(\`${skill.path}\`):${skill.description}`);
|
|
40
|
-
return "##
|
|
40
|
+
return "## 可用技能\n\n任务匹配时按需读取对应 `SKILL.md` 正文:\n" + lines.join("\n");
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
export async function loadWorkspaceContext(options: {
|
|
@@ -71,7 +71,7 @@ export async function loadWorkspaceContext(options: {
|
|
|
71
71
|
: ["", "", ""];
|
|
72
72
|
const skillsSection = formatWorkspaceSkills(workspaceSkills);
|
|
73
73
|
const noticesSection = notices.length
|
|
74
|
-
? "## 启动提示\n\n" + notices.map(item => `- ${item}`).join("\n")
|
|
74
|
+
? "## 启动提示\n\n以下为工作区维护提醒,适时顺带告知用户即可,勿未经用户要求自行执行:\n" + notices.map(item => `- ${item}`).join("\n")
|
|
75
75
|
: "";
|
|
76
76
|
const environment = { host, workspaceRoot: root, resourceRoot };
|
|
77
77
|
const text = [
|