personal-bot 0.2.11 → 0.2.13
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 +18 -0
- package/.claude-plugin/plugin.json +15 -0
- package/CONTEXT.md +11 -5
- package/README.md +45 -14
- package/README.zh-CN.md +45 -14
- package/bin/pbot-pi-acp.mjs +20 -0
- package/docs/README.md +6 -4
- package/docs/adr/0001-claude-skill-discovery.md +3 -0
- package/docs/adr/0002-claude-native-collaboration.md +3 -0
- package/docs/agent-collaboration.md +54 -6
- package/docs/architecture-guidelines.md +1 -1
- package/docs/capability-design.md +15 -3
- package/docs/claude-code-design.md +45 -0
- package/docs/claude-code.md +64 -0
- package/docs/dsh.md +12 -11
- package/docs/file-storage.md +26 -9
- package/docs/history.md +17 -9
- package/docs/interaction-design.md +11 -3
- package/docs/model-context.md +43 -12
- package/docs/model-instruction-guidelines.md +3 -3
- package/docs/release.md +13 -5
- package/docs/technical-design.md +59 -19
- package/docs/workspace-configuration.md +50 -23
- package/hooks/hooks.json +19 -0
- package/lib/claude.d.ts +1 -0
- package/lib/claude.js +20 -0
- package/lib/client.js +41 -8
- package/lib/dsh.js +2 -0
- package/lib/extension/acp-member.d.ts +16 -0
- package/lib/extension/acp-member.js +45 -0
- package/lib/extension/acp-worker.d.ts +1 -0
- package/lib/extension/acp-worker.js +159 -0
- package/lib/extension/claude-hooks.d.ts +15 -0
- package/lib/extension/claude-hooks.js +104 -0
- package/lib/extension/dsh/acp-member.d.ts +4 -0
- package/lib/extension/dsh/acp-member.js +48 -0
- package/lib/extension/dsh/command.js +11 -1
- package/lib/extension/dsh/history.js +1 -1
- package/lib/extension/dsh/management.js +3 -1
- package/lib/extension/dsh/workspace.d.ts +35 -1
- package/lib/extension/dsh/workspace.js +21 -3
- package/lib/integrations/acp/agents.d.ts +24 -0
- package/lib/integrations/acp/agents.js +168 -0
- package/lib/integrations/acp/claude.d.ts +18 -0
- package/lib/integrations/acp/claude.js +33 -0
- package/lib/integrations/acp/connection.d.ts +27 -0
- package/lib/integrations/acp/connection.js +167 -0
- package/lib/integrations/acp/input.d.ts +4 -0
- package/lib/integrations/acp/input.js +45 -0
- package/lib/integrations/acp/launch.d.ts +4 -0
- package/lib/integrations/acp/launch.js +52 -0
- package/lib/integrations/acp/model-selection.d.ts +12 -0
- package/lib/integrations/acp/model-selection.js +65 -0
- package/lib/integrations/agent-resources.d.ts +1 -1
- package/lib/integrations/agent-resources.js +3 -1
- package/lib/integrations/dsh/dsh-agents.d.ts +2 -1
- package/lib/integrations/dsh/dsh-agents.js +4 -0
- package/lib/integrations/dsh/history-summary.js +5 -9
- package/lib/integrations/dsh/history.js +13 -5
- package/lib/integrations/history-summary.d.ts +2 -0
- package/lib/integrations/history-summary.js +21 -10
- package/lib/model/acp.d.ts +59 -0
- package/lib/model/acp.js +1 -0
- package/lib/model/agent.d.ts +15 -1
- package/lib/model/history.d.ts +11 -4
- package/lib/model/workspace-config.d.ts +3 -0
- package/lib/services/agents/acp-run.d.ts +42 -0
- package/lib/services/agents/acp-run.js +149 -0
- package/lib/services/agents/agent-service.d.ts +114 -6
- package/lib/services/agents/agent-service.js +81 -10
- package/lib/services/agents/team-service.js +4 -2
- package/lib/services/history/history-service.d.ts +8 -6
- package/lib/services/history/history-service.js +90 -48
- package/lib/services/workspace/python-environment-service.d.ts +6 -0
- package/lib/services/workspace/python-environment-service.js +25 -9
- package/lib/services/workspace/workspace-config.js +12 -1
- package/lib/storage/acp-files.d.ts +9 -0
- package/lib/storage/acp-files.js +50 -0
- package/lib/storage/agent-files.d.ts +5 -4
- package/lib/storage/agent-files.js +14 -2
- package/lib/storage/history-files.d.ts +2 -1
- package/lib/storage/history-files.js +26 -15
- package/lib/tools/agents/actions.d.ts +16 -2
- package/lib/tools/agents/actions.js +3 -1
- package/lib/tools/agents/contract.d.ts +48 -3
- package/lib/tools/agents/contract.js +15 -9
- package/lib/tools/agents/dsh-contract.d.ts +8 -15
- package/lib/tools/agents/dsh-contract.js +12 -8
- package/lib/tools/history/contract.d.ts +7 -7
- package/lib/tools/history/contract.js +2 -2
- package/lib/ui/dsh/management.js +37 -9
- package/npm-shrinkwrap.json +975 -51
- package/package.json +40 -29
- package/python/README.md +17 -14
- package/resources/agents/coordinator.md +1 -1
- package/resources/claude/agents/general-purpose.md +12 -0
- package/resources/claude/skills/pbot/SKILL.md +17 -0
- package/resources/prompts/claude-coordinator.md +1 -0
- package/resources/prompts/native-coordinator.md +1 -0
- package/resources/prompts/workspace.md +2 -2
- package/resources/references/compute.md +2 -2
- package/resources/references/task-conductor.md +3 -2
- package/resources/skills/.claude-plugin/plugin.json +4 -0
- package/resources/skills/provider-connections/SKILL.md +17 -1
- package/scripts/README.md +29 -5
- package/src/claude.ts +19 -0
- package/src/dsh.ts +1 -0
- package/src/extension/acp-member.ts +44 -0
- package/src/extension/acp-worker.ts +124 -0
- package/src/extension/agent-events.ts +28 -3
- package/src/extension/agents-command.ts +33 -5
- package/src/extension/claude-hooks.ts +94 -0
- package/src/extension/dsh/acp-member.ts +44 -0
- package/src/extension/dsh/command.ts +10 -1
- package/src/extension/dsh/history.ts +1 -1
- package/src/extension/dsh/management.ts +2 -1
- package/src/extension/dsh/workspace.ts +21 -3
- package/src/extension/lifecycle.ts +2 -2
- package/src/extension/pi-acp-member.ts +64 -0
- package/src/integrations/acp/agents.ts +118 -0
- package/src/integrations/acp/claude.ts +40 -0
- package/src/integrations/acp/connection.ts +152 -0
- package/src/integrations/acp/input.ts +39 -0
- package/src/integrations/acp/launch.ts +50 -0
- package/src/integrations/acp/model-selection.ts +66 -0
- package/src/integrations/agent-resources.ts +2 -1
- package/src/integrations/dsh/dsh-agents.ts +4 -1
- package/src/integrations/dsh/history-summary.ts +5 -9
- package/src/integrations/dsh/history.ts +12 -6
- package/src/integrations/history-summary.ts +18 -8
- package/src/integrations/pi/history.ts +16 -15
- package/src/integrations/pi/pi-agents.ts +4 -1
- package/src/model/acp.ts +26 -0
- package/src/model/agent.ts +7 -1
- package/src/model/history.ts +12 -4
- package/src/model/workspace-config.ts +4 -0
- package/src/pbot.ts +5 -4
- package/src/services/agents/acp-run.ts +123 -0
- package/src/services/agents/agent-service.ts +85 -12
- package/src/services/agents/team-service.ts +3 -2
- package/src/services/history/history-service.ts +82 -41
- package/src/services/workspace/python-environment-service.ts +26 -9
- package/src/services/workspace/workspace-config.ts +10 -1
- package/src/storage/acp-files.ts +50 -0
- package/src/storage/agent-files.ts +15 -4
- package/src/storage/history-files.ts +20 -11
- package/src/tools/agents/actions.ts +4 -2
- package/src/tools/agents/contract.ts +16 -9
- package/src/tools/agents/dsh-contract.ts +12 -8
- package/src/tools/history/contract.ts +2 -2
- package/src/ui/dsh/management.ts +32 -9
package/docs/technical-design.md
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
# 技术设计
|
|
2
2
|
|
|
3
|
-
Personal Bot 提供按工作区加载的 Pi
|
|
3
|
+
Personal Bot 提供按工作区加载的 Pi 扩展、原生 dsh Host/Web 接入及 Claude Code 标准插件。模型负责分析、协调和工具使用;Pi/dsh 提供专家协作与历史归档,Claude 通过标准 hooks、技能和原生专家复用资料与共享 Python。安装与命令见[项目 README](../README.md)及 [Claude 使用指南](claude-code.md)。
|
|
4
4
|
|
|
5
5
|
## 模块与依赖
|
|
6
6
|
|
|
7
7
|
```text
|
|
8
8
|
Pi / dsh 命令、工具、事件与原生 Remote
|
|
9
|
+
Claude command hooks / Node 命令
|
|
9
10
|
↓
|
|
10
11
|
tools / extension / ui
|
|
11
12
|
↓
|
|
@@ -16,34 +17,46 @@ Pi / dsh 命令、工具、事件与原生 Remote
|
|
|
16
17
|
integrations
|
|
17
18
|
```
|
|
18
19
|
|
|
19
|
-
src/pbot.ts 装配 Pi
|
|
20
|
+
src/pbot.ts 装配 Pi,src/dsh.ts 装配 dsh Host,src/ui/dsh/index.ts 装配 Web 客户端。src/claude.ts 是 Claude 标准 command hook 与 Node 命令入口,src/extension/claude-hooks.ts 调用共用工作区和 Python 服务。Claude 静态发现 Markdown 技能与专家,不装配 pbot 历史、ACP 或面板。各宿主共享资料与适用的业务服务。
|
|
21
|
+
|
|
22
|
+
src/extension/setup-cli.ts 装配独立 Pi 安装命令;`pbot setup` 通过原生 npm/Pi 准备工作区,再启动 Pi 执行 `/pbot init`。Claude 使用原生插件 marketplace。安装器顺序、来源保留与失败恢复由 services/installation 管理,详见[安装与升级](installation-design.md)。
|
|
20
23
|
|
|
21
24
|
| 目录 | 责任 |
|
|
22
25
|
| --- | --- |
|
|
23
26
|
| src/tools/ | 输入、输出、schema、执行适配和工具列表 |
|
|
24
27
|
| src/services/ | 业务规则、状态变更和操作顺序,按 agents、workspace、history、installation 聚合 |
|
|
25
28
|
| src/model/ | 业务数据类型与窄能力约定,不包含业务实现或宿主 SDK 类型 |
|
|
26
|
-
| src/integrations/ | Pi/dsh 原生会话、Python
|
|
27
|
-
| src/storage/ | 原子 JSON
|
|
29
|
+
| src/integrations/ | Pi/dsh 原生会话、ACP 连接与进程、Python 环境激活 |
|
|
30
|
+
| src/storage/ | 原子 JSON、子会话、pbot 团队和历史文件 |
|
|
28
31
|
| src/extension/ | 命令、事件和资源生命周期 |
|
|
29
32
|
| src/ui/ | 确认队列、对话框和专家展示 |
|
|
30
33
|
| src/common/ | JSON、校验、文件、包路径和版本辅助逻辑 |
|
|
31
34
|
| resources/ | 角色、技能、提示词、模板和参考资料 |
|
|
32
35
|
|
|
33
|
-
|
|
36
|
+
服务不依赖宿主 SDK、工具或 UI。共享进程执行可直接使用,其他宿主能力通过窄接口传入。接入层可引用服务类型;命令和工具通过服务执行状态变更。模型层用 interface/type 描述普通数据和窄能力契约;数据以普通对象进入 JSON、存储和工具结果。
|
|
37
|
+
|
|
38
|
+
Claude command hook 是独立 Node 进程,只使用 Node 内置模块和共用资料/Python 服务。hook 的 stdout 输出标准 JSON,诊断写 stderr;不加载宿主 SDK、mod API 或内部 MCP。
|
|
34
39
|
|
|
35
40
|
| 主体 | 管理内容 |
|
|
36
41
|
| --- | --- |
|
|
37
42
|
| initializeWorkspace / prepareWorkspace | 初始化依次准备资料并写入共用启用配置;资料准备补建目录与根 AGENTS.md |
|
|
38
43
|
| PythonEnvironmentService | venv 准备、依赖检查、状态与取消等待 |
|
|
39
|
-
| AgentService / AgentRun |
|
|
40
|
-
| TeamService |
|
|
41
|
-
| HistoryService |
|
|
42
|
-
| WorkspaceInstance / DshWorkspaces |
|
|
44
|
+
| AgentService / AgentRun / AcpAgentRun | 专家实例、启动预约、代次、inbox、领取/进入/消费/完成与交付资格;ACP prompt 收尾、固定报告与确认关联;拒绝向被团队占用的成员发送私人任务 |
|
|
45
|
+
| TeamService | Pi/dsh 的固定成员、公共消息、有限轮次、团队占用与暂停规则 |
|
|
46
|
+
| HistoryService | 三来源问答索引、四叉摘要、查询、来源写锁与精确输入提交核验 |
|
|
47
|
+
| WorkspaceInstance / DshWorkspaces | Pi/dsh 工作区生命周期;dsh 按父会话装配,按工作区共享历史整理 |
|
|
48
|
+
|
|
49
|
+
## Claude 标准插件入口
|
|
50
|
+
|
|
51
|
+
`hooks/hooks.json` 声明 SessionStart、UserPromptSubmit、SubagentStart、PreToolUse/Skill 和 UserPromptExpansion 的 command handlers,使用独立 `command` 与 `args`,不经 shell 拼接路径。stdin 只消费公开事件字段,stdout 返回标准 hook JSON。固定根目录取 `CLAUDE_PROJECT_DIR`,普通 Node 命令无该变量时使用 cwd。
|
|
52
|
+
|
|
53
|
+
SessionStart 检查并按需准备共享 Python。UserPromptSubmit 重读共用配置、公共约定、角色、根 AGENTS 与工作区职责补充,连同环境状态加入上下文;宿主提供子代理身份时使用专家职责。SubagentStart 只为插件的原生专家添加资料。未启用时不准备环境或加入业务资料,PreToolUse/Skill 与 UserPromptExpansion 分别检查模型调用和用户直接展开的 pbot 方法,拦截时返回初始化入口,管理技能仍可调用。
|
|
54
|
+
|
|
55
|
+
`node <插件>/lib/claude.js init|status|python setup` 调用共用初始化与 Python 服务;`/personal-bot:pbot` 是执行同一入口的原生技能,会调用模型。原生专家 Markdown 由共用职责生成。Claude 不读取内部 transcript、团队配置、启动参数或消息收据,不注册 pbot 模型工具或管理面板。
|
|
43
56
|
|
|
44
57
|
## 加载与关闭
|
|
45
58
|
|
|
46
|
-
宿主原生配置决定插件加载范围,工作区根目录下的 `.pbot/config.json` 决定业务实例是否启动。`services/workspace/workspace-config`
|
|
59
|
+
宿主原生配置决定插件加载范围,工作区根目录下的 `.pbot/config.json` 决定业务实例是否启动。`services/workspace/workspace-config` 为三种宿主读取同一 JSON;缺失、false 或无效配置保持未启用,错误由状态入口报告,不向父目录继承。规则与修改生效方式见[工作区配置](workspace-configuration.md)。
|
|
47
60
|
|
|
48
61
|
Pi 的 session_start 读取启动目录配置,仅在 enabled 为 true 时创建实例、注册工具和准备 Python。未启用时保留状态和初始化入口,不注册包内技能,也不注入 pbot 提示词;状态栏显示未启用或已启动。加载本身不开展模型任务。
|
|
49
62
|
|
|
@@ -51,18 +64,21 @@ Pi 的 `/pbot` 打开原生菜单,状态与长记录使用只读阅读页;ds
|
|
|
51
64
|
|
|
52
65
|
`/pbot init` 先准备资料,再将共用配置中的 enabled 设为 true,保留其他字段;无效配置在写入前报错。Pi 从未启用状态初始化后调用原生 ctx.reload,让实例、工具、技能和新建根 AGENTS 一起生效;已启动会话仅补建资料,新建 AGENTS 经 `/reload` 加载。`/pbot status` 展示运行状态、路径、版本和完整 Python 状态;模型环境只保留工作区、资源根目录及 Python 状态与就绪目录。实际 cwd 由宿主提供,准备错误日志保留在状态入口。
|
|
53
66
|
|
|
54
|
-
主 reload 在配置仍启用时保留子进程并重新关联,但暂停团队,不继续安排旧批次;配置关闭或损坏时停止所属专家;退出或切换会话时清理子进程、取消环境准备并恢复本实例持有的环境变量。关闭操作幂等。子会话的分支归属、通知和恢复规则见[专家协作](agent-collaboration.md)。
|
|
67
|
+
Pi 主 reload 在配置仍启用时保留子进程并重新关联,但暂停团队,不继续安排旧批次;配置关闭或损坏时停止所属专家;退出或切换会话时清理子进程、取消环境准备并恢复本实例持有的环境变量。关闭操作幂等。子会话的分支归属、通知和恢复规则见[专家协作](agent-collaboration.md)。
|
|
55
68
|
|
|
56
69
|
dsh 为原生 registry 中的每个根 Agent 读取其原始 cwd 下的配置,仅对已启用根目录建立协调者工作区。关闭的工作区保留只读状态和初始化入口,其余业务命令与 Remote 查询拒绝进入;init 写入配置后重新打开同一根目录下尚未启用的主会话,按目录合并并发初始化;首个已启用工作区触发共享 Python 准备。专家使用同进程独立 Agent/Session;组件或所属父 Agent 关闭时取消预约、暂停安排并等待自己拥有的执行资源释放。打开页面、轮询、重连不恢复专家或启动模型,已接纳工作不归浏览器生命周期所有。原生存在但由其他实例持有的专家不能替换或假称已释放。
|
|
57
70
|
|
|
71
|
+
Claude 在每次用户提交和适用 hook 中读取固定根目录的配置。hook 没有常驻实例、租约、心跳或后台摘要;配置停用后不再加入业务资料或准备 Python。宿主关闭与原生会话恢复由 Claude 自己管理。Python 用完整解释器路径,不修改宿主环境,插件停用无需恢复 PATH。实现边界见[Claude 接入](claude-code-design.md)。
|
|
72
|
+
|
|
58
73
|
## 资源加载
|
|
59
74
|
|
|
60
75
|
| 资源 | 用途与加载方式 |
|
|
61
76
|
| --- | --- |
|
|
62
77
|
| resources/prompts/workspace.md | 主会话与专家的公共操作约定、目录用途与异常重试说明 |
|
|
63
78
|
| resources/agents/、工作区 agents/ | coordinator、general-purpose 职责及同名工作区补充 |
|
|
64
|
-
| resources/prompts/
|
|
65
|
-
| resources/prompts/
|
|
79
|
+
| resources/prompts/native-coordinator.md、claude-coordinator.md | 在共有 coordinator 职责后组合相应宿主的操作导航 |
|
|
80
|
+
| resources/prompts/team-member.md | 仅在 Pi/dsh 专家处理 pbot 团队任务时随目标与职责加载 |
|
|
81
|
+
| resources/prompts/history-summary.md | Pi/dsh 的独立历史摘要调用,不带主/专家上下文 |
|
|
66
82
|
| resources/skills/ | 原生技能目录只展示元数据,正文按需读取 |
|
|
67
83
|
| resources/references/ | 按任务读取;普通计算与指标/回测分开 |
|
|
68
84
|
| resources/templates/workspace-agents.md | 补建根资料入口的模板,不覆盖现有文件 |
|
|
@@ -71,15 +87,17 @@ Pi 包清单关闭包内技能的静态发现,已启用主会话通过 resourc
|
|
|
71
87
|
|
|
72
88
|
dsh 专家通过原生 composeFrom 应用父会话 preset,再限制其工具。包内技能 provider 仅在已启用主会话和受管专家的 scope 注册,原生文件系统 provider 负责读取和监听;作用域适配保留继承的项目/用户同名方法优先级;公共约定和角色在 system-prompt/assemble 当次刷新,遵守宿主 complete persona 覆盖。团队简报随首个已接纳团队上下文提供,不放在先于 pre-step 求值的动态 system section。
|
|
73
89
|
|
|
90
|
+
Claude 根插件静态声明共用 skills、管理技能与 Markdown 原生专家。工作区资料由 command hooks 按当前文件读取;CLAUDE.md 和用户规则仍由 Claude 原生加载。自有原生专家由 SubagentStart 加载工作区补充,团队职责与通信使用 Claude 自己的能力。
|
|
91
|
+
|
|
74
92
|
同一会话中不变的 section 由宿主沿用,有效系统内容随后续请求传递。团队公共消息按结构化来源与序号去重,压缩后需要的原文通过 read 续取。目录用途常驻,维护方法、接入、计算和调度细节按需读取。具体加载方式见[模型上下文](model-context.md)。
|
|
75
93
|
|
|
76
94
|
公共约定说明工作方式与资料位置,角色说明分工与交付,技能提供专业方法与必要的本地操作约定,工具定义参数与结果语义。委派包含文件修改时说明范围和责任;不重复加入通用授权、证据或验收要求。工具按 action 校验必填与允许字段,返回具体参数错误;status 不读取报告正文。Pi 附件组装保留绝对来源及原生读取结果;dsh 使用原生文件存储与图片准入,Web 通用文件走原生 Session 上传凭证,命令图片使用原生编码图片输入。资料保存由模型按公共约定与维护技能处理,沉淀方法、口径与结论,可再次查询的数据按需获取。布局见[文件存储](file-storage.md)。
|
|
77
95
|
|
|
78
96
|
## 历史查询
|
|
79
97
|
|
|
80
|
-
Pi
|
|
98
|
+
Pi、dsh 共用 `.pbot/history/`,查询已有归档,各自只收录和整理本宿主来源。HistoryService 接收一个写来源及显式只读来源集合。顶层保存 `host`、`id`、`sessionId`、`name` 和 `nodes`;host 保留 pi、dsh、claude 数据兼容。Pi/dsh 分别使用 `.write-pi`、`.write-dsh` 短写锁,已有 Claude 归档可继续读取,Claude 插件不生成新归档。
|
|
81
99
|
|
|
82
|
-
|
|
100
|
+
扫描与模型调用在短写锁外,提交时重读,拒绝过期原文或摘要覆盖。organize 在本次调用内保留节点与子节点的精确输入,提交前比较结构化数据并检查取消信号。查询不调用模型;正常主交互结束后在空闲阶段整理,新人工输入优先取消。来源消失或部分扫描不会删除已归档分支。有不可读归档时不为未识别会话重复分配根 ID,其他可读归档继续查询。实现与限制见[历史对话](history.md)。
|
|
83
101
|
|
|
84
102
|
## 原生子会话存储
|
|
85
103
|
|
|
@@ -93,9 +111,29 @@ PiAgents 使用 `--session-id <agentId>` 启动新的原生会话,让 Pi 按
|
|
|
93
111
|
|
|
94
112
|
dsh 的 `native-session.json` 只保存原生 Session ID,不把它写入 Pi 路径字段。先持久化父会话,再创建并持久化空专家;冷读、恢复校验和固定 `dsh:<turn/end seq>` 报告均使用公开 Session API。恢复保留原生模型选择,清除旧 inbox,只接纳新代次的新请求。双方不接管对方的会话。
|
|
95
113
|
|
|
114
|
+
## ACP 执行
|
|
115
|
+
|
|
116
|
+
Pi/dsh 的 AgentBackends 在原生策略与 pi、dsh、claude 三个 ACP 目标间显式选择,默认保持当前宿主原生策略。工具 start 的 backend 单独进入启动流程,不写入既有 descriptor.options。WorkspaceConfiguration 提供 acp 命令覆盖,创建时固定解析后的路径和参数,恢复使用保存的入口。backend 参数声明目标程序前提;找不到可执行入口时,由共享接入层返回该目标的安装命令、原生认证提示与路径配置示例,各宿主沿用原生错误展示。
|
|
117
|
+
|
|
118
|
+
integrations/acp/connection 使用官方 TypeScript SDK 的稳定 ACP v1,处理初始化、能力协商、配置选择、会话建立/恢复、进度、权限与关闭。主宿主仍持有自己的原生会话和通知收据。ACP 不继承父侧模型默认值;省略 model 或 thinking 时保留目标的原生默认配置。model-selection 将 Pi 的 provider/model、dsh 的编码模型值和 Claude 别名匹配到目标公开的选择;同名模型优先使用当前提供方,无法消歧时要求显式 provider。先选择模型,再按更新后的选项选择思考等级。首次配置全部成功后才固定原生会话引用,配置失败后的恢复继续应用原参数。worker 将配置选择与有效思考等级保存到独立 acp-model.json;服务只公开当前 generation 的 selection。Claude 从适配器入口或 node 启动脚本定位目标安装中的 SDK,通过 resolveSettings 读取原生配置,将环境变量决定的默认等级传入 SDK effort;显式 thinking 同时通过当前调用的 settings.env 覆盖原生环境等级,保留用户配置文件。只订阅 _claude/sdkMessage 的 system/init,将原生模型 ID 保存为 resolvedModel,与 model 配置别名分开。
|
|
119
|
+
|
|
120
|
+
每位 ACP 成员拥有一个独立 worker。AgentService 继续写原 inbox,AcpAgentRun 逐条领取并通过关联的 prompt 结束判定结果;传输失败保存 interrupted/failed,不补发旧输入。Pi/dsh 的成员入口只装配角色、技能、工具范围和最终答复提取,不运行第二个 inbox pump。Claude 通过 systemPrompt append 加载 pbot 内容,claudeOptions 经原生 SDK 的 plugins 选项注册 resources/skills;该目录的 .claude-plugin/plugin.json 只声明技能,由 Claude 提供目录和按需加载。原生递归委派工具仍受成员工具范围限制。
|
|
121
|
+
|
|
122
|
+
Pi 通过 pi-acp 桥接 RPC;bin/pbot-pi-acp.mjs 增加受管成员入口及原生资源开关。dsh 在目标 acp profile 上叠加受管成员 patch,恢复时清除旧原生 inbox,校验进程禁止进入模型步骤。Claude 使用 claude-agent-acp。适配器和目标宿主由用户安装,pbot 仅声明 ACP SDK 运行依赖。
|
|
123
|
+
|
|
124
|
+
报告先原子保存到 reports,再发布带 acp 位置引用的原 completion。Pi/dsh 使用关联当前 requestId 的原生最终答复快照,Claude 按消息边界及 prompt 结束提取正文;thought、工具状态和适配器提示只作进度。空闲状态与工作成功分别记录。
|
|
125
|
+
|
|
126
|
+
worker 及其子进程属于同一进程组,进程记录绑定 generation,并在操作前核对启动身份。Pi reload 保留 worker,新的父实例从控制记录重新关联。stop 只为在途 prompt 发送取消并等待宽限,空闲成员直接关闭;工作或进程提前结束时清除宽限计时器。随后关闭支持的原生会话,再按宽限释放整个进程组;退出和 dsh 父生命周期沿用原清理规则。恢复校验在更换 generation 和接纳新输入前执行。
|
|
127
|
+
|
|
128
|
+
权限请求与答复分开存储并绑定 generation。Pi 扫描器送入已有 Confirmations 队列;dsh 工作台通过 snapshot 展示请求,人工 approval 命令写回选项。dsh 原生 approval.request 要求处于原生 turn,ACP 请求可能在父会话空闲时发生,因此不借用父 turn 写入审批事件。
|
|
129
|
+
|
|
130
|
+
首批 capabilities 明确关闭 ACP 的运行中 steer、团队通信和完整原生记录。人工页面提供任务与报告分页,模型 read 的通知领取语义保持不变。
|
|
131
|
+
|
|
96
132
|
## 团队接入
|
|
97
133
|
|
|
98
|
-
|
|
134
|
+
Claude 使用原生 Agent、团队、成员通信、任务与恢复,不创建 TeamService、pbot_team 或 pbot_team_message。实验团队开关与 teammate 模式由用户管理;原生恢复能力以当前宿主为准,见[专家协作](agent-collaboration.md#claude-原生专家与团队)。
|
|
135
|
+
|
|
136
|
+
Pi/dsh 的 pbot 团队采用独立 team.json,不改动旧 AgentMessage、AgentCycle 等持久结构。TeamService 接收普通成员状态与完成记录,安排 roundRobin 或 parallel 轮次;AgentService 再校验并写入原 inbox。父侧原扫描器收集固定叶节点报告并公开原文,不调用主模型转述,不另建执行器或事件总线。
|
|
99
137
|
|
|
100
138
|
团队关联先保存,再发布输入。跨文件窗口采用保守恢复:不自动重发旧请求,只补交付可核对的完成记录。主/子工具显式注册,子入口只有公共 read/post。Pi 的上下文注入和通知边界分别位于 subagent-entry、agent-events 与 integrations/pi/team-context,服务不持有宿主 ctx。dsh 在原生 pre-step 安全边界注入团队上下文,以持久事件区分领取、进入、消费与正常最终答复;团队投递先取得原生 maintenance 准入,不能把公开 idle 当作独占许可。
|
|
101
139
|
|
|
@@ -113,7 +151,7 @@ Web 拥有草稿、上传和查询;接纳后的命令归服务端。命令不
|
|
|
113
151
|
|
|
114
152
|
共享锁串行化跨进程 setup,同一服务合并重叠请求。失败或取消时保留环境并报告状态,其他扩展功能继续可用;可通过 `/pbot python setup` 重试。共享 venv 的解释器无法运行时(基础解释器被移除或升级),在锁内重建该 venv;非 venv 数据、符号链接和其他环境仍拒绝覆盖。
|
|
115
153
|
|
|
116
|
-
|
|
154
|
+
Pi/dsh 在当前宿主进程激活 PATH、VIRTUAL_ENV 和 Python 路径变量,供随后启动的 Bash 继承;同一 dsh 进程内工作区共用激活生命周期。恢复只修改仍由本实例持有的变量。Claude hooks 检查共享环境并给出 `python.executable` 完整路径,由 Bash 显式使用,不修改父宿主环境。环境更新会影响其他工作区,更新前应停止相关脚本。
|
|
117
155
|
|
|
118
156
|
计算通过原生 Bash 和第三方库 API 执行,使用项目自身的目录、输入和输出约定。路径、安装条件与许可见 [Python 说明](../python/README.md)。
|
|
119
157
|
|
|
@@ -121,8 +159,10 @@ Web 拥有草稿、上传和查询;接纳后的命令归服务端。命令不
|
|
|
121
159
|
|
|
122
160
|
Pi 将工具纳入 pbot namespace,codemode 按契约组合;dsh 注册原生工具,并在宿主可表达的 schema 之外继续校验完整领域契约。原生 CLI/MCP 与可选 Task Conductor 的接入和授权见[工具与执行](capability-design.md)。
|
|
123
161
|
|
|
124
|
-
Pi 入口指向 src,由宿主加载 TypeScript 源码;独立 CLI
|
|
162
|
+
Pi 入口指向 src,由宿主加载 TypeScript 源码;独立 CLI、dsh Host/Web、Claude Node hooks 编译到 lib,dist 供测试使用。Claude 的 hooks/hooks.json 指向 lib/claude.js;根 manifest 声明技能与原生专家,marketplace 指向同版本 npm 包。
|
|
163
|
+
|
|
164
|
+
宿主 SDK 使用 optional peer,dsh SDK 范围为 "*",最低宿主版本由 engines.dsh 声明;开发依赖和锁文件保留精确版本。TypeBox 同样为 optional peer:Pi 通过宿主加载器提供,dsh 构建携带库及许可证。Claude 插件使用 Node 命令与共用服务,不加载宿主 SDK;Claude SDK 可选依赖仅供 Pi/dsh 的 Claude ACP 目标使用。
|
|
125
165
|
|
|
126
|
-
Pi
|
|
166
|
+
Pi、CLI 与 Claude hooks 支持 Node.js 22.19+,Claude 原生 CLI 最低与当前验证基线为 2.1.325;dsh 与 Linux 完整开发使用 Node.js 24.9+。安装检查发现真实宿主后,在子进程中使用其 SDK。包内组件共用 package.json 发布版本,build:claude 同步插件与 marketplace 版本并生成原生专家文件。构建顺序为 dist → build:cli → build:dsh → build:claude;build:cli 会清理 lib。子会话兼容线在 1.0 前按次版本、之后按主版本判断。
|
|
127
167
|
|
|
128
168
|
构建与安装包检查见[维护脚本](../scripts/README.md),分发流程见[npm 发布](release.md)。
|
|
@@ -1,19 +1,28 @@
|
|
|
1
1
|
# 工作区配置
|
|
2
2
|
|
|
3
|
-
Pi 和
|
|
3
|
+
Pi、dsh 和 Claude Code 共用工作区根目录下的 `.pbot/config.json`。宿主原生配置负责安装和加载插件,此文件决定 Personal Bot 是否在当前工作区启用,也作为后续工作区功能配置的统一入口。
|
|
4
4
|
|
|
5
5
|
## 初始化与状态
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
从目标工作区打开宿主,使用相应入口:
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
9
|
+
| 宿主 | 初始化 | 状态 |
|
|
10
|
+
| --- | --- | --- |
|
|
11
|
+
| Pi | `/pbot init` | `/pbot status` |
|
|
12
|
+
| dsh | `/pbot init` 或工作区页初始化按钮 | `/pbot status` 或工作区页 |
|
|
13
|
+
| Claude | 原生技能 `/personal-bot:pbot init` | 原生技能 `/personal-bot:pbot status` |
|
|
14
|
+
|
|
15
|
+
`init` 先补建资料目录和缺失的根 `AGENTS.md`,再将配置中的 `enabled` 设为 true。已有资料、`CLAUDE.md` 和其他配置字段保留;无效配置在写入前报错。
|
|
13
16
|
|
|
14
|
-
|
|
17
|
+
Pi 首次启用时自动重载;已运行时补建的根 AGENTS 经 `/reload` 加载。dsh 立即启用此目录下已打开的主会话。Claude 的技能由模型通过 Bash 执行同一 Node CLI;确定性执行可直接运行:
|
|
18
|
+
|
|
19
|
+
```sh
|
|
20
|
+
node /absolute/path/to/plugin/lib/claude.js init
|
|
21
|
+
node /absolute/path/to/plugin/lib/claude.js status
|
|
22
|
+
node /absolute/path/to/plugin/lib/claude.js python setup
|
|
23
|
+
```
|
|
15
24
|
|
|
16
|
-
|
|
25
|
+
Claude CLI 从 `CLAUDE_PROJECT_DIR` 读取固定工作区根;在普通 shell 中未提供该变量时使用当前目录。需要显式指定工作区时,将它设为目标工作区的绝对路径。状态显示工作区、配置与 Python 信息;Claude 没有独立的 `/pbot` 原生命令或管理面板。操作见[Claude 使用指南](claude-code.md)。
|
|
17
26
|
|
|
18
27
|
## 启用与停用
|
|
19
28
|
|
|
@@ -25,31 +34,49 @@ Pi 状态栏显示“PBot 未启用”或“PBot 已启动”。dsh 的 Personal
|
|
|
25
34
|
}
|
|
26
35
|
```
|
|
27
36
|
|
|
28
|
-
例如,ONEBASE 使用 `~/onebase/.pbot/config.json`。同一 dsh profile 可以同时打开开启和关闭的工作区。
|
|
29
|
-
|
|
30
37
|
| 配置情况 | 行为 |
|
|
31
38
|
| --- | --- |
|
|
32
|
-
| `enabled: true` |
|
|
33
|
-
| 文件不存在、缺少 enabled 或 `enabled: false` |
|
|
34
|
-
| JSON 损坏、字段类型错误或文件不可读取 |
|
|
39
|
+
| `enabled: true` | Pi/dsh 启动业务实例;Claude hooks 加载上下文并准备共享 Python |
|
|
40
|
+
| 文件不存在、缺少 enabled 或 `enabled: false` | 保持未启用,提供状态与初始化入口;宿主原生功能继续使用 |
|
|
41
|
+
| JSON 损坏、字段类型错误或文件不可读取 | 保持未启用,报告具体错误;修复文件后再执行 `init` |
|
|
42
|
+
|
|
43
|
+
Pi/dsh 未启用时不注册包内技能,也不注入 pbot 提示词。Claude 静态技能名称、简介与原生 agent 仍可被宿主发现;PreToolUse 对 Skill 拦截 pbot 工作方法,保留 `personal-bot:pbot` 初始化技能可用。公共约定、角色和 Python 准备受配置控制。用户自己的指令、技能与其他插件沿用宿主加载规则;已经进入聊天的内容作为历史保留。
|
|
44
|
+
|
|
45
|
+
只读取绑定工作区根目录,不向父目录查找。例如在 `~/workspace/projects/example` 单独建立会话时,该目录需要自己的配置。修改 Bash cwd 不改变绑定根目录;Claude 使用 `CLAUDE_PROJECT_DIR` 固定此根。Pi/dsh 受管专家沿用所属工作区的启用决定,其执行目录可以不同。
|
|
46
|
+
|
|
47
|
+
配置使用普通 JSON,支持可选的布尔值 enabled 和供 Pi/dsh 使用的 ACP 启动配置 acp。其他字段原样保留。此文件是唯一业务启用入口;不自动导入旧配置,不从历史或其他资料推断启用,也不增加工作区格式版本。
|
|
35
48
|
|
|
36
|
-
|
|
49
|
+
## ACP 启动配置
|
|
37
50
|
|
|
38
|
-
|
|
51
|
+
Pi/dsh 主会话可委派 Pi、dsh 或 Claude ACP 成员。先按[ACP 专家程序安装说明](../README.zh-CN.md#可选安装-acp-专家程序)准备目标。成员从主宿主进程的 PATH 查找 pi-acp、dsh 和 claude-agent-acp;在启动主宿主的同一终端运行 `command -v` 可检查安装路径。桌面宿主或服务的 PATH 与终端可能不同,需要固定入口或选择已有 dsh profile 时,在同一配置中覆盖对应目标:
|
|
39
52
|
|
|
40
|
-
|
|
53
|
+
```json
|
|
54
|
+
{
|
|
55
|
+
"enabled": true,
|
|
56
|
+
"acp": {
|
|
57
|
+
"pi": { "command": "/absolute/path/to/pi-acp", "args": [] },
|
|
58
|
+
"dsh": { "command": "/absolute/path/to/dsh", "args": ["--profile", "acp"] },
|
|
59
|
+
"claude": { "command": "/absolute/path/to/claude-agent-acp", "args": [] }
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
每项包含 command 和 args 字符串数组,只填写要覆盖的目标。使用普通可执行文件和标准 stdio ACP 入口;dsh 入口须接受原生 `--patch` 叠加成员配置。命令不经过 shell 展开,参数中的相对路径按成员 cwd 解析。模型、认证、MCP 和工具在目标宿主配置,凭据值不写入此文件。
|
|
65
|
+
|
|
66
|
+
创建成员时保存解析后的实际可执行路径和参数。配置生效后的新成员使用新入口;已有成员恢复继续使用保存的入口和会话引用。acp 字段无效时,按工作区配置错误处理。Claude 标准插件不管理 ACP 委派。成员操作见[专家协作](agent-collaboration.md#acp-成员)。
|
|
41
67
|
|
|
42
68
|
## 应用手工修改
|
|
43
69
|
|
|
44
|
-
|
|
45
|
-
|
|
70
|
+
| 宿主 | 应用方式 |
|
|
71
|
+
| --- | --- |
|
|
72
|
+
| Pi | 执行原生 `/reload`,或重新启动 Pi |
|
|
73
|
+
| dsh | 重启对应服务或桌面宿主 |
|
|
74
|
+
| Claude | 后续 SessionStart、UserPromptSubmit、SubagentStart、Skill 调用与技能展开检查及 CLI 操作读取当前配置 |
|
|
46
75
|
|
|
47
|
-
|
|
76
|
+
Pi/dsh 在重载前保持原配置。停用生效后撤下后续业务工具与职责,释放所属执行和历史整理,并暂停团队调度。Claude 停止后续 pbot 上下文注入、工作方法技能与 Python 自动准备;原生会话和团队继续由 Claude 管理。资料、历史与备份保留。重新启用可使用各宿主的 init 入口。
|
|
48
77
|
|
|
49
|
-
所有已启用工作区共用用户级 Python venv。dsh
|
|
78
|
+
所有已启用工作区共用用户级 Python venv。Pi/dsh 激活所在进程环境,dsh 的激活由整个 Host 组件持有。Claude 通过 Bash 使用 `python.executable` 完整路径,不修改 Claude PATH 或环境变量,禁用或卸载无需恢复环境。路径与排障见 [Python 指南](../python/README.md)。
|
|
50
79
|
|
|
51
80
|
## 安装与更新
|
|
52
81
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
从此前“加载即启动”的版本更新后,同样通过 `init` 启用目标工作区,保留现有安装配置、资料和历史数据。
|
|
82
|
+
插件安装和工作区启用分别由宿主插件管理与此配置控制。`pbot setup` 可安装 Pi 并启动 `/pbot init`;Claude 使用原生 marketplace 安装。更新保留现有启用配置、资料与历史,新工作区通过相应 init 入口启用。
|
package/hooks/hooks.json
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{
|
|
2
|
+
"hooks": {
|
|
3
|
+
"SessionStart": [
|
|
4
|
+
{ "hooks": [{ "type": "command", "command": "node", "args": ["${CLAUDE_PLUGIN_ROOT}/lib/claude.js", "hook"], "timeout": 900 }] }
|
|
5
|
+
],
|
|
6
|
+
"UserPromptSubmit": [
|
|
7
|
+
{ "hooks": [{ "type": "command", "command": "node", "args": ["${CLAUDE_PLUGIN_ROOT}/lib/claude.js", "hook"], "timeout": 900 }] }
|
|
8
|
+
],
|
|
9
|
+
"SubagentStart": [
|
|
10
|
+
{ "hooks": [{ "type": "command", "command": "node", "args": ["${CLAUDE_PLUGIN_ROOT}/lib/claude.js", "hook"], "timeout": 30 }] }
|
|
11
|
+
],
|
|
12
|
+
"PreToolUse": [
|
|
13
|
+
{ "matcher": "Skill", "hooks": [{ "type": "command", "command": "node", "args": ["${CLAUDE_PLUGIN_ROOT}/lib/claude.js", "hook"], "timeout": 10 }] }
|
|
14
|
+
],
|
|
15
|
+
"UserPromptExpansion": [
|
|
16
|
+
{ "matcher": "personal-bot:.*", "hooks": [{ "type": "command", "command": "node", "args": ["${CLAUDE_PLUGIN_ROOT}/lib/claude.js", "hook"], "timeout": 10 }] }
|
|
17
|
+
]
|
|
18
|
+
}
|
|
19
|
+
}
|
package/lib/claude.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function main(args: readonly string[]): Promise<void>;
|
package/lib/claude.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { realpathSync } from "node:fs";
|
|
2
|
+
import { pathToFileURL } from "node:url";
|
|
3
|
+
import { claudeCommand, claudeHook } from "./extension/claude-hooks.js";
|
|
4
|
+
export async function main(args) {
|
|
5
|
+
if (args[0] === "hook") {
|
|
6
|
+
let input = "";
|
|
7
|
+
process.stdin.setEncoding("utf8");
|
|
8
|
+
for await (const chunk of process.stdin)
|
|
9
|
+
input += String(chunk);
|
|
10
|
+
process.stdout.write(JSON.stringify(await claudeHook(JSON.parse(input))) + "\n");
|
|
11
|
+
}
|
|
12
|
+
else
|
|
13
|
+
process.stdout.write(JSON.stringify(await claudeCommand(args, process.cwd()), null, 2) + "\n");
|
|
14
|
+
}
|
|
15
|
+
if (process.argv[1] && import.meta.url === pathToFileURL(realpathSync(process.argv[1])).href) {
|
|
16
|
+
void main(process.argv.slice(2)).catch(error => {
|
|
17
|
+
process.stderr.write("Personal Bot: " + (error instanceof Error ? error.message : String(error)) + "\n");
|
|
18
|
+
process.exitCode = 1;
|
|
19
|
+
});
|
|
20
|
+
}
|
package/lib/client.js
CHANGED
|
@@ -498,13 +498,17 @@ function showManagement(ctx, parentSessionId) {
|
|
|
498
498
|
const diagnostic = details(status, "\u73AF\u5883\u8BE6\u60C5"), statusBody = block("");
|
|
499
499
|
statusBody.classList.add("pbot-raw");
|
|
500
500
|
diagnostic.append(statusBody);
|
|
501
|
+
const permissions = group(status, "pbot-setting");
|
|
502
|
+
permissions.hidden = true;
|
|
503
|
+
let permissionKey = "";
|
|
501
504
|
const experts = section("experts", "\u4E13\u5BB6");
|
|
502
505
|
pageTitle(experts, "\u4E13\u5BB6", "");
|
|
503
506
|
const create = details(experts, "\u521B\u5EFA\u4E13\u5BB6"), createForm = form(create), newName = field(createForm, "\u540D\u79F0"), initial = field(createForm, "\u4EFB\u52A1\uFF08\u53EF\u9009\uFF09", true);
|
|
504
507
|
newName.placeholder = "\u4F8B\u5982\uFF1A\u7814\u7A76\u5458";
|
|
505
508
|
initial.placeholder = "\u4EFB\u52A1\u76EE\u6807\u4E0E\u4EA4\u4ED8\u8981\u6C42";
|
|
509
|
+
const backend = select(createForm, "\u8FD0\u884C\u5BBF\u4E3B", [["", "\u5F53\u524D\u5BBF\u4E3B"], ["pi", "Pi"], ["dsh", "dsh"], ["claude", "Claude Code"]]);
|
|
506
510
|
const options = details(createForm, "\u6A21\u578B\u4E0E\u9009\u9879"), modelFields = group(options, "pbot-grid");
|
|
507
|
-
options.querySelector("summary").after(note("\u7559\u7A7A\u6CBF\u7528\
|
|
511
|
+
options.querySelector("summary").after(note("\u5F53\u524D\u5BBF\u4E3B\u7559\u7A7A\u6CBF\u7528\u4E3B\u4F1A\u8BDD\uFF1B\u5176\u4ED6\u5BBF\u4E3B\u7559\u7A7A\u4F7F\u7528\u76EE\u6807\u914D\u7F6E\u3002"));
|
|
508
512
|
const provider = field(modelFields, "Provider"), model = field(modelFields, "\u6A21\u578B");
|
|
509
513
|
const effort = field(options, "Reasoning effort"), cwd = field(options, "\u5DE5\u4F5C\u76EE\u5F55");
|
|
510
514
|
const files = field(options, "\u6587\u4EF6\u8DEF\u5F84\uFF08\u6BCF\u884C\u4E00\u4E2A\uFF09", true);
|
|
@@ -513,6 +517,7 @@ function showManagement(ctx, parentSessionId) {
|
|
|
513
517
|
const args = {
|
|
514
518
|
...objectInput(advanced.value),
|
|
515
519
|
action: "start",
|
|
520
|
+
...backend.value ? { backend: backend.value } : {},
|
|
516
521
|
...newName.value ? { name: newName.value } : {},
|
|
517
522
|
...initial.value ? { message: initial.value } : {},
|
|
518
523
|
...provider.value ? { provider: provider.value } : {},
|
|
@@ -641,8 +646,18 @@ function showManagement(ctx, parentSessionId) {
|
|
|
641
646
|
expertBadge.replaceChildren(badge(agent.state));
|
|
642
647
|
expertPanel.hidden = false;
|
|
643
648
|
expertEmpty.hidden = true;
|
|
644
|
-
const config = object(agent.options) ? agent.options : {};
|
|
645
|
-
|
|
649
|
+
const config = object(agent.options) ? agent.options : {}, selected = record(agent.selection);
|
|
650
|
+
const configuredModel = [selected.provider ?? config.provider, selected.model ?? config.model].filter(Boolean).join("/");
|
|
651
|
+
const chosenModel = selected.resolvedModel && selected.resolvedModel !== configuredModel ? `${configuredModel} \u2192 ${text(selected.resolvedModel)}` : configuredModel;
|
|
652
|
+
expertInfo.replaceChildren(note(text(agent.activity) || "\u7B49\u5F85\u65B0\u7684\u4EFB\u52A1\u3002"), facts([
|
|
653
|
+
["\u5BBF\u4E3B", agent.backend || "\u5F53\u524D\u5BBF\u4E3B"],
|
|
654
|
+
["\u6A21\u578B", chosenModel || (agent.transport === "acp" ? "\u76EE\u6807\u5BBF\u4E3B\u914D\u7F6E" : "\u7EE7\u627F\u7236\u4F1A\u8BDD")],
|
|
655
|
+
["\u601D\u8003\u7B49\u7EA7", selected.thinking || config.thinking || "\u5BBF\u4E3B\u9ED8\u8BA4"],
|
|
656
|
+
["\u5DE5\u4F5C\u76EE\u5F55", agent.cwd]
|
|
657
|
+
]));
|
|
658
|
+
const steering = delivery.querySelector('option[value="steer"]');
|
|
659
|
+
steering.disabled = agent.transport === "acp";
|
|
660
|
+
if (steering.disabled && delivery.value === "steer") delivery.value = "followUp";
|
|
646
661
|
expertState.textContent = JSON.stringify(agent, null, 2);
|
|
647
662
|
expertError.textContent = text(agent.error);
|
|
648
663
|
expertError.hidden = !agent.error;
|
|
@@ -660,7 +675,7 @@ function showManagement(ctx, parentSessionId) {
|
|
|
660
675
|
eventBody.textContent = text(data.text);
|
|
661
676
|
eventBody.classList.toggle("pbot-raw", format === "json");
|
|
662
677
|
eventPaging.replaceChildren(element("span", `\u8BB0\u5F55 ${seq} \xB7 ${offset + 1}\u2013${offset + text(data.text).length} / ${data.totalLength}`));
|
|
663
|
-
button(eventPaging, format === "text" ? "\u67E5\u770B\u539F\u59CB\u4E8B\u4EF6" : "\u67E5\u770B\u6B63\u6587", () => loadRecord(seq, 0, format === "text" ? "json" : "text"));
|
|
678
|
+
button(eventPaging, format === "text" ? data.kind === "acp" ? "\u67E5\u770B\u8BB0\u5F55\u8BE6\u60C5" : "\u67E5\u770B\u539F\u59CB\u4E8B\u4EF6" : "\u67E5\u770B\u6B63\u6587", () => loadRecord(seq, 0, format === "text" ? "json" : "text"));
|
|
664
679
|
if (offset) button(eventPaging, "\u4ECE\u5934\u8BFB\u53D6", () => loadRecord(seq, 0, format));
|
|
665
680
|
if (typeof data.nextOffset === "number") button(eventPaging, "\u7EE7\u7EED\u8BFB\u53D6", () => loadRecord(seq, data.nextOffset, format));
|
|
666
681
|
}
|
|
@@ -689,8 +704,9 @@ function showManagement(ctx, parentSessionId) {
|
|
|
689
704
|
const expanded = new Set(Array.from(rawEventList.querySelectorAll("details[open]")).map((item) => item.dataset.seq));
|
|
690
705
|
eventList.replaceChildren();
|
|
691
706
|
rawEventList.replaceChildren();
|
|
692
|
-
|
|
693
|
-
|
|
707
|
+
rawEvents.querySelector("summary").textContent = data.kind === "acp" ? "\u5168\u90E8\u4EFB\u52A1\u4E0E\u62A5\u544A" : "\u5168\u90E8\u539F\u751F\u4E8B\u4EF6";
|
|
708
|
+
const labels = { "user/message": "\u8F93\u5165", "assistant/message": "\u4E13\u5BB6\u56DE\u590D", "tool/result": "\u5DE5\u5177\u7ED3\u679C", "turn/end": "\u672C\u8F6E\u7ED3\u675F", "acp/input": "\u4EFB\u52A1", "acp/report": "\u4E13\u5BB6\u62A5\u544A" };
|
|
709
|
+
for (const event of rows(data.kind === "acp" ? data.records : data.events)) {
|
|
694
710
|
const seq = Number(event.seq), label = event.type === "user/message" ? event.source === "user" ? "\u8F93\u5165" : event.source === "pbot-input" ? "\u4EFB\u52A1" : void 0 : labels[text(event.type)];
|
|
695
711
|
if (label && text(event.preview)) {
|
|
696
712
|
const item2 = element("article", "", "pbot-event"), meta = group(item2, "pbot-row");
|
|
@@ -853,7 +869,7 @@ function showManagement(ctx, parentSessionId) {
|
|
|
853
869
|
pageTitle(history, "\u5386\u53F2", "");
|
|
854
870
|
const searchForm = form(history);
|
|
855
871
|
searchForm.className = "pbot-search";
|
|
856
|
-
const historyQuery = field(searchForm, "\u5173\u952E\u8BCD"), host = select(searchForm, "\u6765\u6E90", [["", "\u5168\u90E8"], ["pi", "Pi"], ["dsh", "dsh"]]);
|
|
872
|
+
const historyQuery = field(searchForm, "\u5173\u952E\u8BCD"), host = select(searchForm, "\u6765\u6E90", [["", "\u5168\u90E8"], ["pi", "Pi"], ["dsh", "dsh"], ["claude", "Claude Code"]]);
|
|
857
873
|
historyQuery.placeholder = "\u7559\u7A7A\u67E5\u770B\u6700\u8FD1\u4F1A\u8BDD";
|
|
858
874
|
submit(searchForm, "\u67E5\u8BE2", () => searchHistory());
|
|
859
875
|
const dateFilters = details(history, "\u65F6\u95F4\u8303\u56F4"), dateGrid = group(dateFilters, "pbot-grid");
|
|
@@ -1004,9 +1020,26 @@ function showManagement(ctx, parentSessionId) {
|
|
|
1004
1020
|
enabled(pythonButton, python.state !== "preparing");
|
|
1005
1021
|
const { agents: _agents, teams: _teams, ...summary } = snapshot;
|
|
1006
1022
|
statusBody.textContent = JSON.stringify(summary, null, 2);
|
|
1023
|
+
const pending = rows(snapshot.permissions), nextPermissionKey = pending.map((request) => text(request.agentId) + ":" + text(request.requestId)).join(",");
|
|
1024
|
+
permissions.hidden = !pending.length;
|
|
1025
|
+
if (nextPermissionKey !== permissionKey) {
|
|
1026
|
+
permissionKey = nextPermissionKey;
|
|
1027
|
+
permissions.replaceChildren(element("h3", "\u4E13\u5BB6\u8BF7\u6C42\u786E\u8BA4"));
|
|
1028
|
+
for (const request of pending) {
|
|
1029
|
+
const card = group(permissions, "pbot-card");
|
|
1030
|
+
card.append(element("h4", text(request.name)), block(request.description));
|
|
1031
|
+
const choices = group(card, "pbot-row");
|
|
1032
|
+
for (const option of rows(request.options)) button(choices, text(option.name), async () => {
|
|
1033
|
+
await command("approval", { agentId: request.agentId, requestId: request.requestId, optionId: option.optionId }, "\u786E\u8BA4\u7B54\u590D\u5DF2\u63D0\u4EA4\u3002");
|
|
1034
|
+
});
|
|
1035
|
+
button(choices, "\u53D6\u6D88", async () => {
|
|
1036
|
+
await command("approval", { agentId: request.agentId, requestId: request.requestId, optionId: null }, "\u5DF2\u53D6\u6D88\u8BE5\u8BF7\u6C42\u3002");
|
|
1037
|
+
});
|
|
1038
|
+
}
|
|
1039
|
+
}
|
|
1007
1040
|
if (snapshot.controlError) inform(text(snapshot.controlError), "error");
|
|
1008
1041
|
renderLists();
|
|
1009
|
-
const owned = agents.filter((value2) => value2.owned), ids = new Set(owned.map((agent) => text(agent.agentId)));
|
|
1042
|
+
const owned = agents.filter((value2) => value2.owned && record(value2.capabilities).team !== false), ids = new Set(owned.map((agent) => text(agent.agentId)));
|
|
1010
1043
|
for (const input of memberFields.querySelectorAll("input[data-agent-id]")) if (!ids.has(input.dataset.agentId)) input.parentElement?.remove();
|
|
1011
1044
|
memberFields.querySelector(":scope > p")?.remove();
|
|
1012
1045
|
for (const agent of owned) {
|
package/lib/dsh.js
CHANGED
|
@@ -5,6 +5,8 @@ import { requireThat } from "./common/validation.js";
|
|
|
5
5
|
export const name = "personal-bot";
|
|
6
6
|
export const inject = ["commands", "typert", ...dshDependencies];
|
|
7
7
|
export async function apply(ctx) {
|
|
8
|
+
if (process.env.PBOT_SUBAGENT_RUN_ID)
|
|
9
|
+
return;
|
|
8
10
|
const [major, minor] = process.versions.node.split(".").map(Number);
|
|
9
11
|
requireThat(major > 24 || (major === 24 && minor >= 9), "dsh 接入需要 Node.js 24.9.0 或更新版本。");
|
|
10
12
|
const workspaces = new DshWorkspaces(ctx);
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { AgentFiles } from "../storage/agent-files.js";
|
|
2
|
+
import type { AcpInput, AcpAnswer } from "../model/acp.js";
|
|
3
|
+
export declare function acpMember(): Promise<{
|
|
4
|
+
files: AgentFiles;
|
|
5
|
+
d: import("../model/agent.js").AgentDescriptor;
|
|
6
|
+
id: string;
|
|
7
|
+
generation: string;
|
|
8
|
+
check: () => void;
|
|
9
|
+
context: () => Promise<{
|
|
10
|
+
workspace: string;
|
|
11
|
+
role: string;
|
|
12
|
+
environment: string;
|
|
13
|
+
}>;
|
|
14
|
+
input(): AcpInput;
|
|
15
|
+
answer(input: AcpInput, state: AcpAnswer["state"], answer: string, error?: string): void;
|
|
16
|
+
}>;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { dirname, join } from "node:path";
|
|
2
|
+
import { realpathSync } from "node:fs";
|
|
3
|
+
import { readFile } from "node:fs/promises";
|
|
4
|
+
import { AgentFiles, descriptor, launch } from "../storage/agent-files.js";
|
|
5
|
+
import { acpInput, acpAnswer } from "../storage/acp-files.js";
|
|
6
|
+
import { requireThat } from "../common/validation.js";
|
|
7
|
+
import { resourceRoot } from "../common/paths.js";
|
|
8
|
+
import { packageVersion, releaseLine } from "../common/version.js";
|
|
9
|
+
import { agentText } from "../integrations/agent-resources.js";
|
|
10
|
+
import { readWorkspaceConfig, workspaceDisabledMessage } from "../services/workspace/workspace-config.js";
|
|
11
|
+
export async function acpMember() {
|
|
12
|
+
const id = process.env.PBOT_SUBAGENT_RUN_ID, directory = process.env.PBOT_SUBAGENT_DIR, generation = process.env.PBOT_SUBAGENT_GENERATION;
|
|
13
|
+
requireThat(id && directory && generation, "缺少 ACP 成员启动身份。");
|
|
14
|
+
const files = new AgentFiles(dirname(realpathSync(directory)));
|
|
15
|
+
requireThat(files.directory(id) === realpathSync(directory), "ACP 成员目录不匹配。");
|
|
16
|
+
const d = files.read(id, "descriptor.json", descriptor);
|
|
17
|
+
requireThat(d.agentId === id && releaseLine(d.release) === releaseLine(packageVersion), "ACP 成员身份或版本无效。");
|
|
18
|
+
const configuration = await readWorkspaceConfig(d.workspace);
|
|
19
|
+
requireThat(configuration.enabled, workspaceDisabledMessage(configuration));
|
|
20
|
+
const check = () => {
|
|
21
|
+
files.check();
|
|
22
|
+
const run = files.read(id, "launch.json", launch);
|
|
23
|
+
requireThat(run.generation === generation && (!run.stop || process.env.PBOT_ACP_VALIDATE === "1"), "ACP 成员已停止或启动代次变化。");
|
|
24
|
+
};
|
|
25
|
+
const context = async () => {
|
|
26
|
+
const [workspace, role] = await Promise.all([readFile(join(resourceRoot, "prompts/workspace.md"), "utf8"), agentText("general-purpose", d.workspace)]);
|
|
27
|
+
const state = process.env.PBOT_ACP_PYTHON_STATE ?? "unavailable";
|
|
28
|
+
const python = state === "ready" && process.env.VIRTUAL_ENV ? { state, directory: process.env.VIRTUAL_ENV } : { state };
|
|
29
|
+
return { workspace, role, environment: JSON.stringify({ workspaceRoot: d.workspace, resourceRoot, python }) };
|
|
30
|
+
};
|
|
31
|
+
return { files, d, id, generation, check, context,
|
|
32
|
+
input() {
|
|
33
|
+
check();
|
|
34
|
+
const input = files.read(id, "acp-input.json", acpInput);
|
|
35
|
+
requireThat(input.generation === generation, "ACP 输入代次无效。");
|
|
36
|
+
return input;
|
|
37
|
+
},
|
|
38
|
+
answer(input, state, answer, error) {
|
|
39
|
+
// A stop can race the native terminal event. The current generation may still seal its result.
|
|
40
|
+
if (files.read(id, "launch.json", launch).generation !== generation)
|
|
41
|
+
return;
|
|
42
|
+
files.write(id, "acp-answer.json", { ...input, state, answer, ...(error ? { error } : {}) }, acpAnswer);
|
|
43
|
+
},
|
|
44
|
+
};
|
|
45
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|