personal-bot 0.2.15 → 0.2.16
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 +1 -1
- package/README.zh-CN.md +1 -1
- package/docs/agent-collaboration.md +5 -6
- package/docs/dsh.md +11 -11
- package/lib/common/schema.d.ts +2 -0
- package/lib/common/schema.js +9 -0
- package/lib/extension/dsh/command.js +13 -18
- package/lib/extension/dsh/workspace.js +0 -2
- package/lib/integrations/dsh/dsh-agents.d.ts +1 -2
- package/lib/integrations/dsh/dsh-agents.js +0 -4
- package/lib/model/agent.d.ts +0 -1
- package/lib/services/agents/agent-notices.js +1 -1
- package/lib/services/agents/agent-service.js +3 -2
- package/lib/services/agents/start-options.d.ts +4 -0
- package/lib/services/agents/start-options.js +20 -0
- package/lib/tools/agents/actions.d.ts +1 -5
- package/lib/tools/agents/actions.js +12 -1
- package/lib/tools/agents/contract.d.ts +50 -77
- package/lib/tools/agents/contract.js +54 -32
- package/lib/tools/agents/dsh-tool.js +6 -11
- package/lib/tools/history/contract.d.ts +28 -11
- package/lib/tools/history/contract.js +18 -12
- package/lib/tools/input.d.ts +11 -0
- package/lib/tools/input.js +23 -0
- package/lib/tools/teams/actions.d.ts +3 -4
- package/lib/tools/teams/actions.js +7 -5
- package/lib/tools/teams/contract.d.ts +56 -87
- package/lib/tools/teams/contract.js +55 -31
- package/lib/tools/teams/dsh-tool.js +7 -18
- package/package.json +1 -1
- package/resources/prompts/native-coordinator.md +1 -1
- package/src/common/schema.ts +10 -0
- package/src/extension/agent-events.ts +1 -1
- package/src/extension/dsh/command.ts +14 -19
- package/src/extension/dsh/workspace.ts +0 -1
- package/src/integrations/dsh/dsh-agents.ts +1 -4
- package/src/model/agent.ts +1 -1
- package/src/services/agents/agent-notices.ts +1 -1
- package/src/services/agents/agent-service.ts +4 -2
- package/src/services/agents/start-options.ts +19 -0
- package/src/tools/agents/actions.ts +18 -10
- package/src/tools/agents/contract.ts +68 -33
- package/src/tools/agents/dsh-tool.ts +7 -12
- package/src/tools/agents/tool.ts +2 -8
- package/src/tools/history/actions.ts +1 -1
- package/src/tools/history/contract.ts +27 -14
- package/src/tools/input.ts +29 -0
- package/src/tools/teams/actions.ts +10 -14
- package/src/tools/teams/contract.ts +71 -33
- package/src/tools/teams/dsh-tool.ts +7 -18
- package/src/tools/teams/tool.ts +3 -13
- package/lib/tools/agents/dsh-contract.d.ts +0 -45
- package/lib/tools/agents/dsh-contract.js +0 -19
- package/src/tools/agents/dsh-contract.ts +0 -20
|
@@ -6,12 +6,12 @@
|
|
|
6
6
|
"plugins": [
|
|
7
7
|
{
|
|
8
8
|
"name": "personal-bot",
|
|
9
|
-
"version": "0.2.
|
|
9
|
+
"version": "0.2.16",
|
|
10
10
|
"description": "Workspace materials, skills, and native experts.",
|
|
11
11
|
"source": {
|
|
12
12
|
"source": "npm",
|
|
13
13
|
"package": "personal-bot",
|
|
14
|
-
"version": "0.2.
|
|
14
|
+
"version": "0.2.16"
|
|
15
15
|
}
|
|
16
16
|
}
|
|
17
17
|
]
|
package/README.md
CHANGED
|
@@ -165,7 +165,7 @@ Existing layouts and agreements take precedence. Fetch queryable data when neede
|
|
|
165
165
|
|
|
166
166
|
## Updates and operating scope
|
|
167
167
|
|
|
168
|
-
Current release: **0.2.
|
|
168
|
+
Current release: **0.2.16**. Update through the host's native package manager. For a local Pi source, update the checkout, run `npm ci --ignore-scripts` when dependencies change, then reload or restart. Stop active specialists before changing versions. Recreate specialists across compatibility lines; existing materials, history, and backups are preserved.
|
|
169
169
|
|
|
170
170
|
Operations follow the user's request, existing agreements, and required confirmations. Bash, Python, MCP, and extensions use the actual account and credential permissions. Enforce hard limits through read-only credentials, service controls, or restricted environments. Trades, transfers, and ledger changes require authorization for those operations. After cancellation, timeout, or disconnection, query native status before retrying to avoid duplicate execution.
|
|
171
171
|
|
package/README.zh-CN.md
CHANGED
|
@@ -165,7 +165,7 @@ Pi 主会话恢复用 `pi --resume` 明确选择;`pi --continue` 可能选中
|
|
|
165
165
|
|
|
166
166
|
## 更新与操作范围
|
|
167
167
|
|
|
168
|
-
当前版本为 **0.2.
|
|
168
|
+
当前版本为 **0.2.16**。通过宿主原生包管理更新;本地 Pi 来源更新源码,依赖变化后运行 `npm ci --ignore-scripts`,再重载或重启。更换版本前停止活动专家;不同兼容线的专家需重新创建,旧资料、历史和备份保留。
|
|
169
169
|
|
|
170
170
|
操作按用户请求、已有约定和必要确认执行。Bash、Python、MCP 和扩展使用实际账户与凭据权限;硬限制应由只读凭据、服务端控制或受限环境提供。交易、转账和账本修改需要相应授权。取消、超时或断连后,先查原生状态再决定是否重试,避免重复执行。
|
|
171
171
|
|
|
@@ -8,7 +8,7 @@ Personal Bot 保留独立工作和团队工作。Pi 原生专家由 tmux 和独
|
|
|
8
8
|
|
|
9
9
|
| pbot_agent action | 行为 |
|
|
10
10
|
| --- | --- |
|
|
11
|
-
| start | 新建上下文,可指定 name/provider/model/thinking/cwd/tools;有 message/
|
|
11
|
+
| start | 新建上下文,可指定 name/provider/model/thinking/cwd/tools;有 message/files 时执行初始工作,否则只启动待命进程 |
|
|
12
12
|
| send | 向 agentId 发送 message;delivery 默认为 steer,followUp 排到当前工作之后 |
|
|
13
13
|
| rename | 修改名称,agentId 保持不变 |
|
|
14
14
|
| status/list | 查询状态或当前父会话的子会话;status 不读取报告正文,报告通过 read 获取 |
|
|
@@ -20,13 +20,13 @@ Personal Bot 保留独立工作和团队工作。Pi 原生专家由 tmux 和独
|
|
|
20
20
|
|
|
21
21
|
Pi 的 start 支持 noExtensions、noSkills、noPromptTemplates 和 noContextFiles。noExtensions 默认 true,显式保留子入口及 Pi 内置 MCP、codemode、工具搜索;设为 false 时按 Pi 规则发现其他扩展。tools 遵循 Pi 原生选择。子入口只增加 pbot_team_message,不提供 pbot_agent 或 pbot_team 管理能力。
|
|
22
22
|
|
|
23
|
-
以下附件、进程模型与 TUI 说明面向 Pi;dsh 的差异见下一节。初始 files 相对工作区根目录解析。子入口在每份附件前标出绝对来源路径,保留 Pi 原生 read 的文本、图像及截断提示;未读完的附件由成员沿该路径续读。message
|
|
23
|
+
以下附件、进程模型与 TUI 说明面向 Pi;dsh 的差异见下一节。初始 files 相对工作区根目录解析。子入口在每份附件前标出绝对来源路径,保留 Pi 原生 read 的文本、图像及截断提示;未读完的附件由成员沿该路径续读。message 是唯一初始文字输入,不继承父聊天历史。
|
|
24
24
|
|
|
25
25
|
初始模型与思考级别默认继承主会话;恢复时交由 Pi 使用保存的原生模型配置,不重新传入初始模型选项。模型不可用或缺少认证时仍遵循 Pi 的原生回退与错误行为。子会话从自己的 cwd 和 Pi agent dir 取得原生配置与认证,不继承父进程临时注册的模型或 MCP。Pi 专家在启动与恢复时继承当前父进程的环境变量,终端身份由新 tmux pane 设置;父进程已删除的变量不会从 tmux server 的缓存中重新传入。环境与授权规则见[工具与执行](capability-design.md)。
|
|
26
26
|
|
|
27
27
|
## dsh 专家
|
|
28
28
|
|
|
29
|
-
dsh 使用原生 provider/model/reasoning effort
|
|
29
|
+
dsh 使用原生 provider/model/reasoning effort,忽略 Pi 专属扩展、提示模板和上下文文件开关。创建与恢复时通过原生 composeFrom 应用父 preset,保留其文件工具、AGENTS 和技能发现;tools 使用原生能力名,专家排除协调管理及递归委派工具。noSkills 关闭模型技能目录和 skill 工具,用户显式技能手势仍按宿主处理。只在模型选择仍与父一致时继承父 effort。恢复保留原生选择,不用新父默认值覆盖旧会话。
|
|
30
30
|
|
|
31
31
|
服务器文件由原生附件存储保留内容,图片使用原生准入;Web 人工对话还接受本机文件与图片。人工对话先成功暂停所属团队,再进入原生 inbox;队列接纳、实际进入、模型消费和完成分别记录,未来排队输入不提前改变此前回答的归因。
|
|
32
32
|
|
|
@@ -107,7 +107,6 @@ ACP 工作由独立 worker 持有。Pi reload 保留仍启用工作区的 worker
|
|
|
107
107
|
| --- | --- |
|
|
108
108
|
| create | name、brief、members[{agentId, role}];仅建团队,不启动模型 |
|
|
109
109
|
| list/status | 查看归属、成员、当前批次、activeCount 及 unresolved 请求 |
|
|
110
|
-
| read | afterSeq/limit 读取公共记录;单条长消息用 seq/offset/limit |
|
|
111
110
|
| run | teamId、instruction、mode,可选 rounds/maxConcurrent/timeoutSeconds;开展新批次 |
|
|
112
111
|
| pause | 停止新增安排和领取,已领取请求继续收尾 |
|
|
113
112
|
| close | 已暂停或结束且没有在途工作时关闭,保留历史;不阻塞等待 |
|
|
@@ -122,7 +121,7 @@ run 要求全部成员空闲、无未消费的私人输入,并已加载可用
|
|
|
122
121
|
2. 用 pbot_team create 指定成员、职责与共同目标。
|
|
123
122
|
3. 确认成员就绪,再 run,例如:
|
|
124
123
|
`{ action: "run", teamId: "...", instruction: "分别核对证据,下一轮回应分歧", mode: "parallel", rounds: 2, maxConcurrent: 2 }`。
|
|
125
|
-
4. 主会话不逐条转发消息。批次结束或暂停后,用 read 核对成员原文及实际产物。
|
|
124
|
+
4. 主会话不逐条转发消息。批次结束或暂停后,用 pbot_team_message read 核对成员原文及实际产物。
|
|
126
125
|
5. 继续讨论须显式 run 新批次。需要私人工作时,先 pause 并等待 activeCount 为 0;必要时 stop 成员,再 send/resume。
|
|
127
126
|
|
|
128
127
|
运行中的团队占用全部成员,已领取但尚未收尾的请求也占用对应成员。私人 steer/followUp 均返回 TEAM_BUSY,不另建私人等待队列。其他未被占用的 agent 可以同时独立工作。
|
|
@@ -186,6 +185,6 @@ dsh 的管理界面与命令见[dsh 使用说明](dsh.md),Claude 的原生专
|
|
|
186
185
|
|
|
187
186
|
当前父会话没有团队记录时,团队恢复、暂停和调度直接返回,不申请 `.control` 锁。后台扫描遇到短暂的 `.control` 锁竞争时,在下一次扫描重试;连续至少 5 秒仍无法取得锁,包括主会话中断后暂停团队仍被锁阻塞的情况,会保留 UI 错误并通知模型。暂停未成功时,通知明确说明暂停尚未确认。报告或控制记录读取失败也会通知模型。同一持续故障在当前分支去重;恢复要求升级时补发一次通知。主会话中断期间延后投递,恢复输入后再通知。
|
|
188
187
|
|
|
189
|
-
通知按实际服务状态说明恢复方式:锁释放后自动恢复扫描;可恢复的读取错误先排障,修复后由后台重试;团队服务或协作存储已停用时,修复文件仍不能恢复当前实例,须请用户在当前 Pi 会话执行 `/reload`。重载前不反复调用 pbot_team,可通过 pbot_agent list/status/read 核对仍可读取的成员状态与报告;重载后再用 pbot_team status
|
|
188
|
+
通知按实际服务状态说明恢复方式:锁释放后自动恢复扫描;可恢复的读取错误先排障,修复后由后台重试;团队服务或协作存储已停用时,修复文件仍不能恢复当前实例,须请用户在当前 Pi 会话执行 `/reload`。重载前不反复调用 pbot_team,可通过 pbot_agent list/status/read 核对仍可读取的成员状态与报告;重载后再用 pbot_team status 与 pbot_team_message read 核对团队。完整扫描成功且待暂停、待入队操作不再受阻后清除故障状态。当前实例中已恢复的故障若曾在当前分支通知,会补发一次关联的恢复消息;中断期间延后投递,成员结果优先交付。未投递的故障不补发恢复消息,重载不追认旧实例的恢复。通知不重发任务、不删除锁,命令和工具的错误仍直接返回。
|
|
190
189
|
|
|
191
190
|
进入成员前提示返回快捷键,团队成员使用相同入口。默认 tmux 绑定下,普通终端按 Ctrl+B 后按 d 脱离;主会话已在 tmux 中时,按 Ctrl+B 后按小写 l 切回。自定义绑定以自己的配置为准。返回不停止成员,不要用 /exit 代替。
|
package/docs/dsh.md
CHANGED
|
@@ -185,19 +185,20 @@ task-conductor setup
|
|
|
185
185
|
| `/pbot chat {"agentId":"AGENT_ID","text":"补充要求"}` | 人工对话,可附文件;自动先暂停所属团队 |
|
|
186
186
|
| `/pbot records {"agentId":"AGENT_ID"}` | 读取原生专家事件,或 ACP 专家的任务与报告 |
|
|
187
187
|
| `/pbot approval {"agentId":"AGENT_ID","requestId":"REQUEST_ID","optionId":"OPTION_ID"}` | 回答工作区页列出的专家确认请求;optionId 为 null 时取消 |
|
|
188
|
-
| `/pbot team {"action":"list"}` |
|
|
188
|
+
| `/pbot team {"action":"list"}` | 团队管理与批次状态 |
|
|
189
|
+
| `/pbot messages {"teamId":"TEAM_ID","afterSeq":0}` | 读取团队公共原文 |
|
|
189
190
|
| `/pbot post {"teamId":"TEAM_ID","text":"公开信息"}` | 以人工用户身份发布公共消息,不唤醒模型 |
|
|
190
191
|
| `/pbot history {"action":"search"}` | 查询历史归档;也支持 read |
|
|
191
192
|
|
|
192
|
-
`chat`、`post`、`records`、`approval` 不带 `action`。dsh 没有 `/pbot help`、`/pbot agents` 或 `/pbot teams` 子命令;后两个复数入口属于 Pi。
|
|
193
|
+
`chat`、`messages`、`post`、`records`、`approval` 不带 `action`。dsh 没有 `/pbot help`、`/pbot agents` 或 `/pbot teams` 子命令;后两个复数入口属于 Pi。
|
|
193
194
|
|
|
194
195
|
## 专家命令
|
|
195
196
|
|
|
196
|
-
`/pbot agent` 与模型工具 `pbot_agent`
|
|
197
|
+
`/pbot agent` 与模型工具 `pbot_agent` 使用相同输入契约:只读取对应 action 的字段;未知字段拒绝,其他已声明字段忽略。
|
|
197
198
|
|
|
198
199
|
| action | 除 action 外必填字段 | 可选字段 | 用途 |
|
|
199
200
|
| --- | --- | --- | --- |
|
|
200
|
-
| `start` | 无 | `backend`, `name`, `message`, `
|
|
201
|
+
| `start` | 无 | `backend`, `name`, `message`, `files`, `provider`, `model`, `thinking`, `cwd`, `tools`, `noSkills`, `noExtensions`, `noPromptTemplates`, `noContextFiles` | 创建专家,接纳后返回,不等待完成 |
|
|
201
202
|
| `list` | 无 | 无 | 列出当前父会话的专家 |
|
|
202
203
|
| `status` | `agentId` | 无 | 查看执行与最近周期状态,不读报告正文 |
|
|
203
204
|
| `send` | `agentId`, `message` | `delivery` | 向存活专家追加委派任务 |
|
|
@@ -211,7 +212,7 @@ task-conductor setup
|
|
|
211
212
|
| 启动参数 | 说明 |
|
|
212
213
|
| --- | --- |
|
|
213
214
|
| `name` | 1–64 字符的单行名称,省略使用 ID 前 8 位 |
|
|
214
|
-
| `message
|
|
215
|
+
| `message` | 1–24000 字符的初始文字;省略时只创建待命专家 |
|
|
215
216
|
| `files` | 最多 32 个服务器文件路径,相对原工作区根目录;可只带文件启动任务 |
|
|
216
217
|
| `cwd` | 默认原工作区根目录;相对路径也以该根目录解析 |
|
|
217
218
|
| `provider`, `model` | dsh 原生 provider route 与模型 ID,各 1–128 字符,默认继承父会话选择 |
|
|
@@ -221,7 +222,7 @@ task-conductor setup
|
|
|
221
222
|
|
|
222
223
|
专家创建和恢复时应用父会话的原生 preset,保留其文件工具、AGENTS 和技能发现,再应用专家工具限制。显式 complete persona 由宿主按其完整配置提供行为要求。
|
|
223
224
|
|
|
224
|
-
Pi 专属的 noExtensions、noPromptTemplates、noContextFiles 仅对 backend 为 pi 的 ACP
|
|
225
|
+
Pi 专属的 noExtensions、noPromptTemplates、noContextFiles 仅对 Pi 原生专家或 backend 为 pi 的 ACP 成员生效;其他目标忽略。`send.delivery` 为 `steer`(默认,补充当前工作)或 `followUp`(当前工作之后)。`send/resume` 不支持 files 或模型切换参数。成员被团队占用时私人 send 被拒绝,应先 pause 并等在途工作结束。
|
|
225
226
|
|
|
226
227
|
```text
|
|
227
228
|
/pbot agent {"action":"start","name":"证据核对"}
|
|
@@ -266,14 +267,13 @@ Pi 专属的 noExtensions、noPromptTemplates、noContextFiles 仅对 backend
|
|
|
266
267
|
|
|
267
268
|
## 团队与公共消息
|
|
268
269
|
|
|
269
|
-
`/pbot team` 与模型工具 `pbot_team` 的 action
|
|
270
|
+
`/pbot team` 与模型工具 `pbot_team` 的 action 相同;公共原文由 `/pbot messages` 与 `pbot_team_message read` 读取:
|
|
270
271
|
|
|
271
272
|
| action | 除 action 外必填字段 | 可选字段 | 用途 |
|
|
272
273
|
| --- | --- | --- | --- |
|
|
273
274
|
| `create` | `name`, `brief`, `members` | 无 | 创建固定成员团队,不调用模型 |
|
|
274
275
|
| `list` | 无 | 无 | 列出团队 |
|
|
275
276
|
| `status` | `teamId` | 无 | 查看批次、占用和未确认结果 |
|
|
276
|
-
| `read` | `teamId` | `afterSeq`, `seq`, `offset`, `limit` | 读取公共原文 |
|
|
277
277
|
| `run` | `teamId`, `instruction`, `mode` | `rounds`, `maxConcurrent`, `timeoutSeconds` | 开始新批次 |
|
|
278
278
|
| `pause` | `teamId` | 无 | 停止新安排,允许在途收尾 |
|
|
279
279
|
| `close` | `teamId` | 无 | 无运行批次及在途请求时关闭,保留成员和历史 |
|
|
@@ -289,7 +289,7 @@ run 的 instruction 为非空文字,最多 24000 字符。mode 必填:`round
|
|
|
289
289
|
/pbot post {"teamId":"TEAM_ID","text":"只使用提供的资料,明确列出证据缺口。"}
|
|
290
290
|
/pbot team {"action":"run","teamId":"TEAM_ID","instruction":"各自给出发现与未决问题。","mode":"parallel","rounds":1,"maxConcurrent":2,"timeoutSeconds":900}
|
|
291
291
|
/pbot team {"action":"status","teamId":"TEAM_ID"}
|
|
292
|
-
/pbot
|
|
292
|
+
/pbot messages {"teamId":"TEAM_ID","afterSeq":0,"limit":4000}
|
|
293
293
|
/pbot team {"action":"pause","teamId":"TEAM_ID"}
|
|
294
294
|
```
|
|
295
295
|
|
|
@@ -330,8 +330,8 @@ Pi/dsh 使用 `.pbot/history/`,查询已有各来源归档,只更新和整
|
|
|
330
330
|
| 工具 | 操作 |
|
|
331
331
|
| --- | --- |
|
|
332
332
|
| `pbot_agent` | start、send、rename、status、list、read、stop、resume |
|
|
333
|
-
| `pbot_team` | create、list、status、
|
|
334
|
-
| `pbot_team_message` | read、post;read
|
|
333
|
+
| `pbot_team` | create、list、status、run、pause、close |
|
|
334
|
+
| `pbot_team_message` | read、post;read 用 afterSeq/seq/offset/limit 分页,post 使用 teamId/text/可选 replyTo |
|
|
335
335
|
| `pbot_history` | search、read |
|
|
336
336
|
|
|
337
337
|
模型使用实际工具 schema;人工使用上面的命令或管理页。chat、records 是人工管理入口,没有同名模型工具。
|
package/lib/common/schema.d.ts
CHANGED
package/lib/common/schema.js
CHANGED
|
@@ -8,3 +8,12 @@ export function schema(value) {
|
|
|
8
8
|
addFormats.default(ajv);
|
|
9
9
|
return ajv.compile(value);
|
|
10
10
|
}
|
|
11
|
+
/** Name the concrete shape violation so the caller can correct the same field. */
|
|
12
|
+
export function schemaDetail(validate) {
|
|
13
|
+
return (validate.errors ?? []).map(error => {
|
|
14
|
+
const params = error.params;
|
|
15
|
+
const field = typeof params.additionalProperty === "string" ? params.additionalProperty
|
|
16
|
+
: error.instancePath ? error.instancePath.slice(1).replaceAll("/", ".") : "参数";
|
|
17
|
+
return field + " " + (error.message ?? "不符合 schema");
|
|
18
|
+
}).join(";") || "不符合 schema";
|
|
19
|
+
}
|
|
@@ -3,11 +3,10 @@ import { object, json } from "../../common/json.js";
|
|
|
3
3
|
import { requireThat } from "../../common/validation.js";
|
|
4
4
|
import { schema } from "../../common/schema.js";
|
|
5
5
|
import { executeAgent } from "../../tools/agents/actions.js";
|
|
6
|
-
import {
|
|
6
|
+
import { agentInput } from "../../tools/agents/contract.js";
|
|
7
7
|
import { executeTeam, executeTeamMessage } from "../../tools/teams/actions.js";
|
|
8
|
-
import {
|
|
8
|
+
import { teamInput, teamMessageInput } from "../../tools/teams/contract.js";
|
|
9
9
|
import { dshWorkspaceStatus } from "./management.js";
|
|
10
|
-
const validAgent = schema(dshAgentActionSchema), validTeam = schema(teamActionSchema), validMessage = schema(teamMessageActionSchema);
|
|
11
10
|
const chatSchema = Type.Object({ agentId: Type.String({ minLength: 1 }), text: Type.Optional(Type.String({ maxLength: 24000 })),
|
|
12
11
|
delivery: Type.Optional(Type.Union([Type.Literal("steer"), Type.Literal("followUp")])),
|
|
13
12
|
files: Type.Optional(Type.Array(Type.String({ minLength: 1 }), { maxItems: 32 })) }, { additionalProperties: false });
|
|
@@ -15,10 +14,10 @@ const validChat = schema(chatSchema);
|
|
|
15
14
|
const approvalSchema = Type.Object({ agentId: Type.String({ minLength: 1 }), requestId: Type.String({ minLength: 1 }),
|
|
16
15
|
optionId: Type.Union([Type.String({ minLength: 1 }), Type.Null()]) }, { additionalProperties: false });
|
|
17
16
|
const validApproval = schema(approvalSchema);
|
|
18
|
-
const usage = '用法:/pbot status | init | agent {"action":…} | chat {"agentId":…,"text":…} | team {"action":…} | post {"teamId":…,"text":…} | history {"action":…} | records {"agentId":…}';
|
|
17
|
+
const usage = '用法:/pbot status | init | agent {"action":…} | chat {"agentId":…,"text":…} | team {"action":…} | messages {"teamId":…} | post {"teamId":…,"text":…} | history {"action":…} | records {"agentId":…}';
|
|
19
18
|
export function registerDshCommand(ctx, workspaces, management) {
|
|
20
19
|
ctx.commands.register({ name: "pbot", description: "Personal Bot 工作区与协作管理", recordInput: false,
|
|
21
|
-
input: { hint: "status | init | agent/chat/team/post/history/records JSON", attachments: true },
|
|
20
|
+
input: { hint: "status | init | agent/chat/team/messages/post/history/records JSON", attachments: true },
|
|
22
21
|
async handler({ agent, rawInput, signal, attachments, commandId }) {
|
|
23
22
|
signal.throwIfAborted();
|
|
24
23
|
const command = rawInput.trim(), split = command.search(/\s/);
|
|
@@ -44,12 +43,10 @@ export function registerDshCommand(ctx, workspaces, management) {
|
|
|
44
43
|
let result;
|
|
45
44
|
switch (verb) {
|
|
46
45
|
case "agent": {
|
|
47
|
-
requireThat(validAgent(input), "dsh 专家参数无效或包含不支持的宿主选项。");
|
|
48
46
|
const selection = agent.model.current();
|
|
49
|
-
const output = await executeAgent(workspace.agents, input, workspace.owner, selection ? {
|
|
47
|
+
const output = await executeAgent(workspace.agents, agentInput(input), workspace.owner, selection ? {
|
|
50
48
|
provider: selection.provider, model: selection.model,
|
|
51
|
-
...(selection.reasoningEffort
|
|
52
|
-
? { thinking: selection.reasoningEffort } : {}),
|
|
49
|
+
...(selection.reasoningEffort ? { thinking: selection.reasoningEffort } : {}),
|
|
53
50
|
} : {});
|
|
54
51
|
result = output.structuredContent;
|
|
55
52
|
break;
|
|
@@ -67,17 +64,15 @@ export function registerDshCommand(ctx, workspaces, management) {
|
|
|
67
64
|
result = { answered: true };
|
|
68
65
|
break;
|
|
69
66
|
}
|
|
70
|
-
case "team":
|
|
71
|
-
|
|
72
|
-
result = executeTeam(workspace.teams, workspace.agents, input, workspace.owner).structuredContent;
|
|
67
|
+
case "team":
|
|
68
|
+
result = executeTeam(workspace.teams, workspace.agents, teamInput(input), workspace.owner).structuredContent;
|
|
73
69
|
break;
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
result = executeTeamMessage(workspace.teams,
|
|
70
|
+
case "messages":
|
|
71
|
+
result = executeTeamMessage(workspace.teams, teamMessageInput({ ...input, action: "read" }), { kind: "coordinator", owner: workspace.owner }, commandId).structuredContent;
|
|
72
|
+
break;
|
|
73
|
+
case "post":
|
|
74
|
+
result = executeTeamMessage(workspace.teams, teamMessageInput({ ...input, action: "post" }), { kind: "user", owner: workspace.owner }, commandId).structuredContent;
|
|
79
75
|
break;
|
|
80
|
-
}
|
|
81
76
|
case "history":
|
|
82
77
|
result = await management.history({ parentSessionId: agent.id, input: json(input) }, signal);
|
|
83
78
|
break;
|
|
@@ -45,8 +45,6 @@ export class DshWorkspace {
|
|
|
45
45
|
this.owner = { sessionId: agent.id, leaf: null, branch: [] };
|
|
46
46
|
this.host = new DshAgents(ctx, agent, {
|
|
47
47
|
setup: (d, _directory, generation) => async (agentCtx, child) => {
|
|
48
|
-
for (const key of ["noExtensions", "noPromptTemplates", "noContextFiles"])
|
|
49
|
-
requireThat(d.options[key] === undefined, "dsh 不支持宿主选项:" + key);
|
|
50
48
|
await agentCtx.plugin({ name: "pbot-expert", inject: dshDependencies, apply: async (scope) => {
|
|
51
49
|
const runtime = new DshAgentRuntime(scope, child, d, generation, this.agents.files, this.teams, { check: this.check, release: () => this.host.release(d.agentId, generation) });
|
|
52
50
|
this.#experts.set(d.agentId, runtime);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Context } from "@deepseek-ai/cordis";
|
|
2
2
|
import type { Agent, AgentSetup } from "@deepseek-ai/dsh-agent";
|
|
3
|
-
import type { AgentDescriptor,
|
|
3
|
+
import type { AgentDescriptor, AgentSessionReference } from "../../model/agent.js";
|
|
4
4
|
import type { AgentHost } from "../../services/agents/agent-service.js";
|
|
5
5
|
/** Native handles belong to the execution component, independently of browser observers. */
|
|
6
6
|
export declare class DshAgents implements AgentHost {
|
|
@@ -19,7 +19,6 @@ export declare class DshAgents implements AgentHost {
|
|
|
19
19
|
ready(agent: Agent, generation: string): void;
|
|
20
20
|
stopping(agent: Agent, generation: string): Promise<void>;
|
|
21
21
|
}, lifetime: AbortSignal);
|
|
22
|
-
validateOptions(options: AgentOptions): void;
|
|
23
22
|
available(): void;
|
|
24
23
|
alive(id: string): boolean;
|
|
25
24
|
private reference;
|
|
@@ -16,10 +16,6 @@ export class DshAgents {
|
|
|
16
16
|
this.composition = composition;
|
|
17
17
|
this.lifetime = lifetime;
|
|
18
18
|
}
|
|
19
|
-
validateOptions(options) {
|
|
20
|
-
for (const key of ["noExtensions", "noPromptTemplates", "noContextFiles"])
|
|
21
|
-
requireThat(options[key] === undefined, "dsh 不支持宿主选项:" + key);
|
|
22
|
-
}
|
|
23
19
|
available() {
|
|
24
20
|
this.lifetime.throwIfAborted();
|
|
25
21
|
requireThat(!this.#closed && this.ctx.agents.get(this.parent.id) === this.parent, "dsh 父会话或执行组件已关闭。");
|
package/lib/model/agent.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ export function teamNotice(values, known) {
|
|
|
5
5
|
if (!notes.length)
|
|
6
6
|
return;
|
|
7
7
|
return { kind: "teams", keys: notes.map(value => value.key), content: ["# 团队批次状态", "",
|
|
8
|
-
"团队批次状态已变化,用 pbot_team status
|
|
8
|
+
"团队批次状态已变化,用 pbot_team status 与 pbot_team_message read 查看状态和结果。暂停时可能仍有在途工作,重跑前先查看原请求结果。", "",
|
|
9
9
|
notes.map(value => ["## " + value.name, "", "- `teamId`: `" + value.teamId + "`", "- `runId`: `" + value.runId + "`",
|
|
10
10
|
"- 状态:" + value.state, "- 在途工作:" + value.activeCount, ...(value.reason ? ["", "### 原因", "", value.reason] : [])].join("\n")).join("\n\n")].join("\n") };
|
|
11
11
|
}
|
|
@@ -6,6 +6,7 @@ import { requireThat } from "../../common/validation.js";
|
|
|
6
6
|
import { AgentFiles, descriptor, launch, status, cycle } from "../../storage/agent-files.js";
|
|
7
7
|
import { TeamFiles } from "../../storage/team-files.js";
|
|
8
8
|
import { acpModelState, acpPermission, acpPermissionReply, acpReference } from "../../storage/acp-files.js";
|
|
9
|
+
import { applicableStartOptions } from "./start-options.js";
|
|
9
10
|
export class AgentService {
|
|
10
11
|
root;
|
|
11
12
|
host;
|
|
@@ -64,7 +65,7 @@ export class AgentService {
|
|
|
64
65
|
this.check();
|
|
65
66
|
const { backend, ...supplied } = input;
|
|
66
67
|
this.host.available(backend);
|
|
67
|
-
const options = Object.fromEntries(Object.entries(supplied).filter(([, v]) => v !== undefined));
|
|
68
|
+
const options = applicableStartOptions(this.host.kind, backend, Object.fromEntries(Object.entries(supplied).filter(([, v]) => v !== undefined)));
|
|
68
69
|
this.host.validateOptions?.(options, backend);
|
|
69
70
|
requireThat(backend || options.provider && options.model, "请选择可在专家会话使用的模型。");
|
|
70
71
|
const reference = backend ? this.host.prepare?.(backend, options) : undefined;
|
|
@@ -78,7 +79,7 @@ export class AgentService {
|
|
|
78
79
|
parentSessionId: owner.sessionId, parentLeaf: owner.leaf, createdAt: Date.now(), options: { ...options, files, cwd } };
|
|
79
80
|
const run = { generation: randomUUID(), name: options.name ?? agentId.slice(0, 8), sequence: 0, stop: false, startedAt: Date.now() };
|
|
80
81
|
this.files.create(d, run, reference);
|
|
81
|
-
const initial =
|
|
82
|
+
const initial = options.message ?? "";
|
|
82
83
|
const request = initial || files.length ? this.files.enqueue(agentId, initial, "steer", files) : undefined;
|
|
83
84
|
this.#starting.set(agentId, { generation: run.generation, controller: new AbortController(), stage: "launch" });
|
|
84
85
|
return { d, run, request };
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { AcpBackend } from "../../model/acp.js";
|
|
2
|
+
import type { AgentOptions, NativeAgentHost } from "../../model/agent.js";
|
|
3
|
+
/** Keep only options the effective target can use; declared-but-inapplicable fields are inert. */
|
|
4
|
+
export declare function applicableStartOptions(kind: NativeAgentHost, backend: AcpBackend | undefined, options: AgentOptions): AgentOptions;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
const piOnly = ["noExtensions", "noPromptTemplates", "noContextFiles"];
|
|
2
|
+
/** Keep only options the effective target can use; declared-but-inapplicable fields are inert. */
|
|
3
|
+
export function applicableStartOptions(kind, backend, options) {
|
|
4
|
+
const result = { ...options };
|
|
5
|
+
if (backend) {
|
|
6
|
+
if (backend !== "pi") {
|
|
7
|
+
for (const key of piOnly)
|
|
8
|
+
delete result[key];
|
|
9
|
+
delete result.noSkills;
|
|
10
|
+
delete result.tools;
|
|
11
|
+
}
|
|
12
|
+
if (backend === "claude")
|
|
13
|
+
delete result.provider;
|
|
14
|
+
}
|
|
15
|
+
else if (kind !== "pi") {
|
|
16
|
+
for (const key of piOnly)
|
|
17
|
+
delete result[key];
|
|
18
|
+
}
|
|
19
|
+
return result;
|
|
20
|
+
}
|
|
@@ -1,10 +1,6 @@
|
|
|
1
|
-
import type { Static } from "typebox";
|
|
2
1
|
import type { AgentService } from "../../services/agents/agent-service.js";
|
|
3
2
|
import type { AgentOptions, AgentOwner } from "../../model/agent.js";
|
|
4
|
-
import type {
|
|
5
|
-
export type AgentInput = Omit<Static<typeof agentParametersSchema>, "thinking"> & {
|
|
6
|
-
thinking?: string;
|
|
7
|
-
};
|
|
3
|
+
import type { AgentInput } from "./contract.js";
|
|
8
4
|
export declare function executeAgent(service: AgentService, input: AgentInput, owner: AgentOwner, defaults?: AgentOptions): Promise<{
|
|
9
5
|
isError?: boolean;
|
|
10
6
|
content: {
|
|
@@ -17,12 +17,23 @@ function agentOutput(view) {
|
|
|
17
17
|
...(view.nextOffset === undefined ? {} : { nextOffset: view.nextOffset }),
|
|
18
18
|
};
|
|
19
19
|
}
|
|
20
|
+
/** Parent selection is inherited only for a native expert; a chosen model drops the thinking default. */
|
|
21
|
+
function inherited(input, defaults) {
|
|
22
|
+
if (input.action !== "start" || input.backend)
|
|
23
|
+
return {};
|
|
24
|
+
const changed = Boolean(input.provider && defaults.provider && input.provider !== defaults.provider) ||
|
|
25
|
+
Boolean(input.model && defaults.model && input.model !== defaults.model);
|
|
26
|
+
const options = { ...defaults };
|
|
27
|
+
if (changed)
|
|
28
|
+
delete options.thinking;
|
|
29
|
+
return options;
|
|
30
|
+
}
|
|
20
31
|
export async function executeAgent(service, input, owner, defaults = {}) {
|
|
21
32
|
let value;
|
|
22
33
|
switch (input.action) {
|
|
23
34
|
case "start": {
|
|
24
35
|
const { action: _action, ...supplied } = input;
|
|
25
|
-
value = await service.start({ ...(
|
|
36
|
+
value = await service.start({ ...inherited(input, defaults), ...supplied }, owner);
|
|
26
37
|
break;
|
|
27
38
|
}
|
|
28
39
|
case "list": return markdownResult({ agents: service.list(owner).map(agentOutput) }, "子会话列表");
|
|
@@ -1,84 +1,57 @@
|
|
|
1
1
|
import { Type } from "typebox";
|
|
2
|
-
|
|
3
|
-
export declare const
|
|
4
|
-
backend: Type.TOptional<Type.TUnion<[Type.TLiteral<"pi">, Type.TLiteral<"dsh">, Type.TLiteral<"claude">]>>;
|
|
5
|
-
name: Type.TOptional<Type.TString>;
|
|
6
|
-
message: Type.TOptional<Type.TString>;
|
|
7
|
-
files: Type.TOptional<Type.TArray<Type.TString>>;
|
|
8
|
-
prompts: Type.TOptional<Type.TArray<Type.TString>>;
|
|
9
|
-
provider: Type.TOptional<Type.TString>;
|
|
10
|
-
model: Type.TOptional<Type.TString>;
|
|
11
|
-
thinking: Type.TOptional<Type.TString>;
|
|
12
|
-
cwd: Type.TOptional<Type.TString>;
|
|
13
|
-
tools: Type.TOptional<Type.TArray<Type.TString>>;
|
|
14
|
-
noExtensions: Type.TOptional<Type.TBoolean>;
|
|
15
|
-
noSkills: Type.TOptional<Type.TBoolean>;
|
|
16
|
-
noPromptTemplates: Type.TOptional<Type.TBoolean>;
|
|
17
|
-
noContextFiles: Type.TOptional<Type.TBoolean>;
|
|
18
|
-
};
|
|
2
|
+
import type { AgentStartOptions } from "../../model/agent.js";
|
|
3
|
+
export declare const agentDescription = "\u59D4\u6D3E\u4E13\u5BB6\u5E76\u7EE7\u7EED\u5BF9\u8BDD\u3002start \u542F\u52A8\u540E\u5373\u8FD4\u56DE\uFF0C\u5B8C\u6210\u81EA\u52A8\u901A\u77E5\uFF0C\u65E0\u9700\u8F6E\u8BE2\uFF1B\u7701\u7565\u521D\u59CB\u8F93\u5165\u65F6\u5F85\u547D\u3002send \u7EE7\u7EED\u5BF9\u8BDD\uFF0C\u56E2\u961F\u5360\u7528\u671F\u95F4\u4E0D\u53EF\u79C1\u4EBA send\u3002status \u67E5\u770B\u72B6\u6001\uFF0Cread \u8BFB\u53D6\u62A5\u544A\uFF1B\u8BFB\u53D6\u5DF2\u7ED3\u675F\u5468\u671F\u5373\u9886\u53D6\u5176\u901A\u77E5\uFF0C\u5305\u62EC\u90E8\u5206\u8BFB\u53D6\u3002\u7EED\u8BFB\u56FA\u5B9A cycle.cycleId \u5E76\u4F7F\u7528 nextOffset\u3002state \u8868\u793A\u6267\u884C\u72B6\u6001\uFF0Ccycle.state \u8868\u793A\u5DE5\u4F5C\u7ED3\u679C\uFF0Cqueued \u53EA\u8868\u793A\u5165\u961F\u3002stop \u4FDD\u7559\u5386\u53F2\uFF0Cresume \u643A\u65B0 message \u7EE7\u7EED\u3002\u6BCF\u4E2A\u7236\u4F1A\u8BDD\u6700\u591A 50 \u4E2A\u5B58\u6D3B\u4E13\u5BB6\uFF0C\u7A7A\u95F2\u4E5F\u8BA1\u5165\u3002\u52A8\u4F5C\u53EA\u8BFB\u53D6\u81EA\u5DF1\u7684\u5B57\u6BB5\uFF1B\u5176\u4ED6\u5DF2\u58F0\u660E\u5B57\u6BB5\u5FFD\u7565\u3002";
|
|
19
4
|
export declare const agentParametersSchema: Type.TObject<{
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
backend: Type.TOptional<Type.TUnion<[Type.TLiteral<"pi">, Type.TLiteral<"dsh">, Type.TLiteral<"claude">]>>;
|
|
25
|
-
name: Type.TOptional<Type.TString
|
|
26
|
-
message: Type.TOptional<Type.TString
|
|
27
|
-
files: Type.TOptional<Type.TArray<Type.TString>>;
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
noContextFiles: Type.TOptional<Type.TBoolean>;
|
|
5
|
+
cycleId: Type.TOptional<Type.TUnion<[Type.TString, Type.TNull]>>;
|
|
6
|
+
offset: Type.TOptional<Type.TUnion<[Type.TInteger, Type.TNull]>>;
|
|
7
|
+
limit: Type.TOptional<Type.TUnion<[Type.TInteger, Type.TNull]>>;
|
|
8
|
+
delivery: Type.TOptional<Type.TUnion<[Type.TUnion<[Type.TLiteral<"steer">, Type.TLiteral<"followUp">]>, Type.TNull]>>;
|
|
9
|
+
backend: Type.TOptional<Type.TUnion<[Type.TUnion<[Type.TLiteral<"pi">, Type.TLiteral<"dsh">, Type.TLiteral<"claude">]>, Type.TNull]>>;
|
|
10
|
+
name: Type.TOptional<Type.TUnion<[Type.TString, Type.TNull]>>;
|
|
11
|
+
message: Type.TOptional<Type.TUnion<[Type.TString, Type.TNull]>>;
|
|
12
|
+
files: Type.TOptional<Type.TUnion<[Type.TArray<Type.TString>, Type.TNull]>>;
|
|
13
|
+
provider: Type.TOptional<Type.TUnion<[Type.TString, Type.TNull]>>;
|
|
14
|
+
model: Type.TOptional<Type.TUnion<[Type.TString, Type.TNull]>>;
|
|
15
|
+
thinking: Type.TOptional<Type.TUnion<[Type.TString, Type.TNull]>>;
|
|
16
|
+
cwd: Type.TOptional<Type.TUnion<[Type.TString, Type.TNull]>>;
|
|
17
|
+
tools: Type.TOptional<Type.TUnion<[Type.TArray<Type.TString>, Type.TNull]>>;
|
|
18
|
+
noExtensions: Type.TOptional<Type.TUnion<[Type.TBoolean, Type.TNull]>>;
|
|
19
|
+
noSkills: Type.TOptional<Type.TUnion<[Type.TBoolean, Type.TNull]>>;
|
|
20
|
+
noPromptTemplates: Type.TOptional<Type.TUnion<[Type.TBoolean, Type.TNull]>>;
|
|
21
|
+
noContextFiles: Type.TOptional<Type.TUnion<[Type.TBoolean, Type.TNull]>>;
|
|
38
22
|
action: Type.TUnion<[Type.TLiteral<"start">, Type.TLiteral<"send">, Type.TLiteral<"rename">, Type.TLiteral<"status">, Type.TLiteral<"list">, Type.TLiteral<"read">, Type.TLiteral<"stop">, Type.TLiteral<"resume">]>;
|
|
39
|
-
agentId: Type.TOptional<Type.TString
|
|
23
|
+
agentId: Type.TOptional<Type.TUnion<[Type.TString, Type.TNull]>>;
|
|
40
24
|
}>;
|
|
41
|
-
export
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
}
|
|
58
|
-
action:
|
|
59
|
-
agentId:
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
}
|
|
63
|
-
action:
|
|
64
|
-
agentId:
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
action: Type.TLiteral<"list">;
|
|
72
|
-
}>, ...Type.TObject<{
|
|
73
|
-
action: Type.TLiteral<string>;
|
|
74
|
-
agentId: Type.TString;
|
|
75
|
-
}>[], Type.TObject<{
|
|
76
|
-
cycleId: Type.TOptional<Type.TString>;
|
|
77
|
-
offset: Type.TOptional<Type.TInteger>;
|
|
78
|
-
limit: Type.TOptional<Type.TInteger>;
|
|
79
|
-
action: Type.TLiteral<"read">;
|
|
80
|
-
agentId: Type.TString;
|
|
81
|
-
}>]>;
|
|
25
|
+
export type AgentAction = "start" | "send" | "rename" | "status" | "list" | "read" | "stop" | "resume";
|
|
26
|
+
export type AgentInput = ({
|
|
27
|
+
action: "start";
|
|
28
|
+
} & AgentStartOptions) | {
|
|
29
|
+
action: "send";
|
|
30
|
+
agentId: string;
|
|
31
|
+
message: string;
|
|
32
|
+
delivery?: "steer" | "followUp";
|
|
33
|
+
} | {
|
|
34
|
+
action: "resume";
|
|
35
|
+
agentId: string;
|
|
36
|
+
message: string;
|
|
37
|
+
} | {
|
|
38
|
+
action: "rename";
|
|
39
|
+
agentId: string;
|
|
40
|
+
name: string;
|
|
41
|
+
} | {
|
|
42
|
+
action: "stop" | "status";
|
|
43
|
+
agentId: string;
|
|
44
|
+
} | {
|
|
45
|
+
action: "list";
|
|
46
|
+
} | {
|
|
47
|
+
action: "read";
|
|
48
|
+
agentId: string;
|
|
49
|
+
cycleId?: string;
|
|
50
|
+
offset?: number;
|
|
51
|
+
limit?: number;
|
|
52
|
+
};
|
|
53
|
+
/** One flat record, one interpreter. Fields outside the selected action are inert. */
|
|
54
|
+
export declare function agentInput(value: unknown): AgentInput;
|
|
82
55
|
export declare const agentViewSchema: Type.TObject<{
|
|
83
56
|
agentId: Type.TString;
|
|
84
57
|
name: Type.TString;
|