personal-bot 0.3.2 → 0.3.4
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 +2 -1
- package/DISCLAIMER.md +17 -0
- package/LICENSE +21 -0
- package/README.md +15 -5
- package/README.zh-CN.md +15 -5
- package/bin/pbot-pi-acp.mjs +1 -1
- package/bin/pbot.mjs +22 -2
- package/docs/README.md +2 -0
- package/docs/architecture/design.md +16 -16
- package/docs/architecture/extensibility.md +29 -2
- package/docs/architecture/model-context.md +3 -2
- package/docs/architecture/principles.md +2 -2
- package/docs/guides/capabilities.md +1 -1
- package/docs/guides/cross-harness-workers.md +3 -1
- package/docs/guides/history.md +30 -7
- package/docs/guides/workspace-configuration.md +20 -3
- package/docs/hosts/antigravity.md +1 -1
- package/docs/hosts/claude-code.md +1 -1
- package/docs/hosts/codex-qoder.md +63 -0
- package/docs/maintainers/architecture-governance.md +78 -0
- package/lib/antigravity-plugin/DISCLAIMER.md +17 -0
- package/lib/antigravity-plugin/LICENSE +21 -0
- package/lib/antigravity-plugin/bin/pbot-pi-acp.mjs +36 -0
- package/lib/antigravity-plugin/lib/common/files.d.ts +2 -0
- package/lib/antigravity-plugin/lib/common/files.js +44 -0
- package/lib/antigravity-plugin/lib/common/validation.d.ts +4 -0
- package/lib/antigravity-plugin/lib/common/validation.js +8 -0
- package/lib/antigravity-plugin/lib/extension/acp/member.d.ts +18 -0
- package/lib/antigravity-plugin/lib/extension/acp/member.js +44 -0
- package/lib/antigravity-plugin/lib/extension/acp-worker.js +71 -45
- package/lib/antigravity-plugin/lib/extension/hosts/dsh/acp-entry.d.ts +1 -0
- package/lib/antigravity-plugin/lib/extension/hosts/dsh/acp-entry.js +22 -0
- package/lib/antigravity-plugin/lib/extension/hosts/dsh/acp-member.d.ts +4 -0
- package/lib/antigravity-plugin/lib/extension/hosts/dsh/acp-member.js +58 -0
- package/lib/antigravity-plugin/lib/extension/hosts/dsh/files.d.ts +5 -0
- package/lib/antigravity-plugin/lib/extension/hosts/dsh/files.js +67 -0
- package/lib/antigravity-plugin/lib/extension/hosts/pi/acp-member.d.ts +3 -0
- package/lib/antigravity-plugin/lib/extension/hosts/pi/acp-member.js +100 -0
- package/lib/antigravity-plugin/lib/extension/hosts/plugin-runtime.d.ts +3 -1
- package/lib/antigravity-plugin/lib/extension/hosts/plugin-runtime.js +37 -22
- package/lib/antigravity-plugin/lib/extension/hosts/workspace-mcp.d.ts +6 -0
- package/lib/antigravity-plugin/lib/extension/hosts/workspace-mcp.js +21 -0
- package/lib/antigravity-plugin/lib/extension/mcp.js +2577 -2255
- package/lib/antigravity-plugin/lib/extension/workspace-cli.js +20171 -0
- package/lib/antigravity-plugin/lib/integrations/agent-resources.js +1 -1
- package/lib/antigravity-plugin/lib/integrations/hosts/claude/adapter.js +7 -59
- package/lib/antigravity-plugin/lib/integrations/hosts/codex/adapter.d.ts +2 -0
- package/lib/antigravity-plugin/lib/integrations/hosts/codex/adapter.js +14 -0
- package/lib/antigravity-plugin/lib/integrations/hosts/dsh/mcp.d.ts +4 -0
- package/lib/antigravity-plugin/lib/integrations/hosts/dsh/mcp.js +28 -0
- package/lib/antigravity-plugin/lib/integrations/hosts/dsh/messages.d.ts +36 -0
- package/lib/antigravity-plugin/lib/integrations/hosts/dsh/messages.js +11 -0
- package/lib/antigravity-plugin/lib/integrations/hosts/dsh/resources.d.ts +6 -0
- package/lib/antigravity-plugin/lib/integrations/hosts/dsh/resources.js +47 -0
- package/lib/antigravity-plugin/lib/integrations/hosts/dsh/root-agents.d.ts +4 -0
- package/lib/antigravity-plugin/lib/integrations/hosts/dsh/root-agents.js +3 -0
- package/lib/antigravity-plugin/lib/integrations/hosts/dsh/skills.d.ts +8 -0
- package/lib/antigravity-plugin/lib/integrations/hosts/dsh/skills.js +31 -0
- package/lib/antigravity-plugin/lib/integrations/hosts/pi/agent-tools.d.ts +3 -0
- package/lib/antigravity-plugin/lib/integrations/hosts/pi/agent-tools.js +32 -0
- package/lib/antigravity-plugin/lib/integrations/hosts/pi/mcp.d.ts +4 -0
- package/lib/antigravity-plugin/lib/integrations/hosts/pi/mcp.js +23 -0
- package/lib/antigravity-plugin/lib/integrations/hosts/plugin-registry.d.ts +1 -0
- package/lib/antigravity-plugin/lib/integrations/hosts/plugin-registry.js +8 -1
- package/lib/antigravity-plugin/lib/integrations/hosts/prompt-hooks.d.ts +76 -0
- package/lib/antigravity-plugin/lib/integrations/hosts/prompt-hooks.js +76 -0
- package/lib/antigravity-plugin/lib/integrations/hosts/qoder/adapter.d.ts +2 -0
- package/lib/antigravity-plugin/lib/integrations/hosts/qoder/adapter.js +16 -0
- package/lib/antigravity-plugin/lib/model/acp.d.ts +7 -3
- package/lib/antigravity-plugin/lib/model/acp.js +8 -0
- package/lib/antigravity-plugin/lib/model/agent.d.ts +121 -0
- package/lib/antigravity-plugin/lib/model/agent.js +4 -0
- package/lib/antigravity-plugin/lib/model/history.d.ts +10 -0
- package/lib/antigravity-plugin/lib/model/history.js +4 -1
- package/lib/antigravity-plugin/lib/model/plugin-host.d.ts +5 -0
- package/lib/antigravity-plugin/lib/model/workspace-config.d.ts +8 -12
- package/lib/antigravity-plugin/lib/model/workspace-config.js +2 -1
- package/lib/antigravity-plugin/lib/plugin.d.ts +2 -1
- package/lib/antigravity-plugin/lib/plugin.js +2 -2
- package/lib/antigravity-plugin/lib/services/history/history-capture.js +34 -22
- package/lib/antigravity-plugin/lib/services/history/summary-registry.js +2 -3
- package/lib/antigravity-plugin/lib/services/history/summary-runner.d.ts +2 -5
- package/lib/antigravity-plugin/lib/services/history/summary-runner.js +72 -74
- package/lib/antigravity-plugin/lib/services/history/workspace-history.d.ts +3 -0
- package/lib/antigravity-plugin/lib/services/history/workspace-history.js +6 -0
- package/lib/antigravity-plugin/lib/services/workspace/plugin-releases.d.ts +15 -0
- package/lib/antigravity-plugin/lib/services/workspace/plugin-releases.js +126 -0
- package/lib/antigravity-plugin/lib/services/workspace/workspace-config.js +9 -8
- package/lib/antigravity-plugin/lib/services/workspace/workspace-files.d.ts +2 -0
- package/lib/antigravity-plugin/lib/services/workspace/workspace-files.js +17 -0
- package/lib/antigravity-plugin/lib/services/workspace/workspace-mcp.d.ts +14 -0
- package/lib/antigravity-plugin/lib/services/workspace/workspace-mcp.js +193 -0
- package/lib/antigravity-plugin/lib/services/workspace/workspace-skills.d.ts +1 -0
- package/lib/antigravity-plugin/lib/services/workspace/workspace-skills.js +4 -2
- package/lib/antigravity-plugin/lib/storage/acp-files.d.ts +11 -0
- package/lib/antigravity-plugin/lib/storage/acp-files.js +75 -0
- package/lib/antigravity-plugin/lib/storage/agent-files.d.ts +31 -0
- package/lib/antigravity-plugin/lib/storage/agent-files.js +159 -0
- package/lib/antigravity-plugin/lib/storage/atomic-json.d.ts +3 -1
- package/lib/antigravity-plugin/lib/storage/atomic-json.js +43 -3
- package/lib/antigravity-plugin/lib/storage/history-files.d.ts +2 -1
- package/lib/antigravity-plugin/lib/storage/history-files.js +21 -15
- package/lib/antigravity-plugin/lib/storage/history-format.d.ts +2 -3
- package/lib/antigravity-plugin/lib/storage/history-format.js +5 -7
- package/lib/antigravity-plugin/package.json +1 -1
- package/lib/antigravity-plugin/plugin.json +1 -1
- package/lib/antigravity-plugin/resources/prompts/history-monthly-summary.md +13 -0
- package/lib/antigravity-plugin/resources/prompts/history-summary.md +13 -0
- package/lib/antigravity-plugin/resources/prompts/plugin-coordinator.md +1 -0
- package/lib/antigravity-plugin/resources/skills/.claude-plugin/plugin.json +4 -0
- package/lib/antigravity-plugin/resources/skills/project-maintenance/SKILL.md +35 -0
- package/lib/antigravity-plugin/resources/skills/provider-connections/SKILL.md +52 -0
- package/lib/antigravity-plugin/skills/pbot/SKILL.md +11 -1
- package/lib/client.js +22 -50
- package/lib/codex-marketplace/.agents/plugins/marketplace.json +17 -0
- package/lib/codex-marketplace/plugins/personal-bot/.codex-plugin/plugin.json +7 -0
- package/lib/codex-marketplace/plugins/personal-bot/.mcp.json +17 -0
- package/lib/codex-marketplace/plugins/personal-bot/DISCLAIMER.md +17 -0
- package/lib/codex-marketplace/plugins/personal-bot/LICENSE +21 -0
- package/lib/codex-marketplace/plugins/personal-bot/hooks/hooks.json +37 -0
- package/lib/codex-marketplace/plugins/personal-bot/skills/pbot/SKILL.md +9 -0
- package/lib/codex-marketplace/plugins/personal-bot/skills/pbot/agents/openai.yaml +2 -0
- package/lib/common/validation.d.ts +4 -0
- package/lib/common/validation.js +8 -0
- package/lib/dsh.js +2 -2
- package/lib/extension/acp/member.d.ts +1 -1
- package/lib/extension/acp-worker.js +71 -45
- package/lib/extension/history/command.d.ts +37 -0
- package/lib/extension/history/command.js +57 -0
- package/lib/extension/hosts/dsh/acp-entry.d.ts +1 -0
- package/lib/extension/hosts/dsh/acp-entry.js +22 -0
- package/lib/extension/hosts/dsh/acp-member.js +4 -18
- package/lib/extension/hosts/dsh/command.d.ts +1 -2
- package/lib/extension/hosts/dsh/command.js +5 -49
- package/lib/extension/hosts/dsh/workspace.js +13 -44
- package/lib/extension/hosts/pi/acp-member.d.ts +3 -0
- package/lib/extension/hosts/pi/acp-member.js +100 -0
- package/lib/extension/hosts/plugin-runtime.d.ts +3 -1
- package/lib/extension/hosts/plugin-runtime.js +37 -22
- package/lib/extension/hosts/workspace-mcp.d.ts +6 -0
- package/lib/extension/hosts/workspace-mcp.js +21 -0
- package/lib/extension/mcp/bridge.d.ts +6 -8
- package/lib/extension/mcp/bridge.js +66 -84
- package/lib/extension/mcp/tool-contract.d.ts +735 -0
- package/lib/extension/mcp/tool-contract.js +441 -0
- package/lib/extension/mcp/workers.d.ts +29 -742
- package/lib/extension/mcp/workers.js +75 -525
- package/lib/extension/mcp.js +2577 -2255
- package/lib/extension/setup/cli.js +15 -0
- package/lib/extension/setup/upgrade.js +153 -0
- package/lib/extension/workspace-cli.js +20171 -0
- package/lib/integrations/acp/agents.d.ts +2 -3
- package/lib/integrations/acp/harnesses/dsh.js +1 -1
- package/lib/integrations/acp/harnesses/presets.js +8 -0
- package/lib/integrations/acp/history-summary.js +2 -1
- package/lib/integrations/acp/launch.d.ts +2 -2
- package/lib/integrations/agent-resources.js +1 -1
- package/lib/integrations/hosts/claude/adapter.js +7 -59
- package/lib/integrations/hosts/codex/adapter.d.ts +2 -0
- package/lib/integrations/hosts/codex/adapter.js +14 -0
- package/lib/integrations/hosts/pi/agent-tools.d.ts +3 -0
- package/lib/integrations/hosts/pi/agent-tools.js +32 -0
- package/lib/integrations/hosts/pi/mcp.d.ts +4 -0
- package/lib/integrations/hosts/pi/mcp.js +23 -0
- package/lib/integrations/hosts/plugin-registry.d.ts +1 -0
- package/lib/integrations/hosts/plugin-registry.js +8 -1
- package/lib/integrations/hosts/prompt-hooks.d.ts +76 -0
- package/lib/integrations/hosts/prompt-hooks.js +76 -0
- package/lib/integrations/hosts/qoder/adapter.d.ts +2 -0
- package/lib/integrations/hosts/qoder/adapter.js +16 -0
- package/lib/integrations/installation/cli-update.js +146 -0
- package/lib/integrations/installation/upgraders/antigravity.js +67 -0
- package/lib/integrations/installation/upgraders/claude.js +123 -0
- package/lib/integrations/installation/upgraders/codex.js +73 -0
- package/lib/integrations/installation/upgraders/dsh.js +62 -0
- package/lib/integrations/installation/upgraders/pi.js +90 -0
- package/lib/integrations/installation/upgraders/qoder.js +67 -0
- package/lib/integrations/installation/upgraders/registry.js +40 -0
- package/lib/model/acp.d.ts +7 -3
- package/lib/model/acp.js +8 -0
- package/lib/model/agent.d.ts +18 -4
- package/lib/model/agent.js +4 -1
- package/lib/model/history.d.ts +10 -0
- package/lib/model/history.js +4 -1
- package/lib/model/installation.js +1 -0
- package/lib/model/plugin-host.d.ts +5 -0
- package/lib/model/workspace-config.d.ts +8 -12
- package/lib/model/workspace-config.js +2 -1
- package/lib/plugin.d.ts +2 -1
- package/lib/plugin.js +2 -2
- package/lib/qoder-plugin/.mcp.json +17 -0
- package/lib/qoder-plugin/.qoder-plugin/plugin.json +7 -0
- package/lib/qoder-plugin/DISCLAIMER.md +17 -0
- package/lib/qoder-plugin/LICENSE +21 -0
- package/lib/qoder-plugin/hooks/hooks.json +37 -0
- package/lib/qoder-plugin/skills/pbot/SKILL.md +9 -0
- package/lib/services/agents/agent-service.d.ts +15 -45
- package/lib/services/agents/agent-service.js +22 -3
- package/lib/services/history/history-capture.js +34 -22
- package/lib/services/history/history-migrate.js +26 -60
- package/lib/services/history/history-query.js +38 -57
- package/lib/services/history/summary-command.d.ts +1 -1
- package/lib/services/history/summary-command.js +8 -7
- package/lib/services/history/summary-registry.js +2 -3
- package/lib/services/history/summary-runner.d.ts +2 -5
- package/lib/services/history/summary-runner.js +72 -74
- package/lib/services/history/workspace-history.d.ts +3 -0
- package/lib/services/history/workspace-history.js +6 -0
- package/lib/services/installation/setup-service.js +4 -1
- package/lib/services/installation/upgrade-service.js +95 -0
- package/lib/services/workspace/plugin-releases.d.ts +15 -0
- package/lib/services/workspace/plugin-releases.js +126 -0
- package/lib/services/workspace/workspace-config.js +9 -8
- package/lib/services/workspace/workspace-mcp.js +22 -29
- package/lib/services/workspace/workspace-skills.d.ts +1 -0
- package/lib/services/workspace/workspace-skills.js +4 -2
- package/lib/storage/acp-files.js +7 -12
- package/lib/storage/agent-files.js +6 -5
- package/lib/storage/atomic-json.d.ts +3 -1
- package/lib/storage/atomic-json.js +43 -3
- package/lib/storage/history-files.d.ts +2 -1
- package/lib/storage/history-files.js +21 -15
- package/lib/storage/history-format.d.ts +2 -3
- package/lib/storage/history-format.js +5 -7
- package/lib/tools/history/contract.d.ts +3 -11
- package/lib/tools/history/contract.js +8 -7
- package/lib/ui/dsh/elements.d.ts +2 -5
- package/lib/ui/dsh/elements.js +3 -16
- package/lib/ui/dsh/management.js +9 -9
- package/lib/ui/dsh/styles.d.ts +1 -1
- package/lib/ui/dsh/styles.js +5 -33
- package/package.json +4 -1
- package/resources/antigravity/skills/pbot/SKILL.md +11 -1
- package/resources/claude/skills/pbot/SKILL.md +11 -1
- package/resources/plugin/skills/pbot/SKILL.md +9 -0
- package/resources/prompts/history-coordinator.md +1 -0
- package/resources/prompts/plugin-coordinator.md +1 -0
- package/scripts/README.md +3 -2
- package/src/common/validation.ts +10 -0
- package/src/dsh.ts +2 -2
- package/src/extension/history/command.ts +68 -0
- package/src/extension/hosts/dsh/acp-entry.ts +21 -0
- package/src/extension/hosts/dsh/acp-member.ts +4 -15
- package/src/extension/hosts/dsh/command.ts +6 -46
- package/src/extension/hosts/dsh/workspace.ts +12 -38
- package/src/extension/hosts/pi/acp-member.ts +4 -10
- package/src/extension/hosts/pi/command.ts +14 -63
- package/src/extension/hosts/pi/events.ts +2 -8
- package/src/extension/hosts/pi/lifecycle.ts +3 -2
- package/src/extension/hosts/plugin-runtime.ts +39 -19
- package/src/extension/hosts/workspace-mcp.ts +25 -0
- package/src/extension/mcp/bridge.ts +80 -80
- package/src/extension/mcp/tool-contract.ts +462 -0
- package/src/extension/mcp/workers.ts +81 -551
- package/src/extension/setup/cli.ts +11 -1
- package/src/extension/setup/upgrade.ts +158 -0
- package/src/extension/setup/workspace-cli.ts +167 -0
- package/src/integrations/acp/agents.ts +2 -3
- package/src/integrations/acp/harnesses/dsh.ts +1 -1
- package/src/integrations/acp/harnesses/presets.ts +8 -0
- package/src/integrations/acp/history-summary.ts +2 -1
- package/src/integrations/agent-resources.ts +1 -1
- package/src/integrations/hosts/claude/adapter.ts +7 -53
- package/src/integrations/hosts/codex/adapter.ts +16 -0
- package/src/integrations/hosts/plugin-registry.ts +9 -1
- package/src/integrations/hosts/prompt-hooks.ts +72 -0
- package/src/integrations/hosts/qoder/adapter.ts +19 -0
- package/src/integrations/installation/cli-update.ts +144 -0
- package/src/integrations/installation/pi-bridge.ts +1 -1
- package/src/integrations/installation/pi-setup.ts +1 -1
- package/src/integrations/installation/processes.ts +1 -1
- package/src/integrations/installation/upgraders/antigravity.ts +68 -0
- package/src/integrations/installation/upgraders/claude.ts +123 -0
- package/src/integrations/installation/upgraders/codex.ts +73 -0
- package/src/integrations/installation/upgraders/dsh.ts +63 -0
- package/src/integrations/installation/upgraders/pi.ts +87 -0
- package/src/integrations/installation/upgraders/qoder.ts +68 -0
- package/src/integrations/installation/upgraders/registry.ts +48 -0
- package/src/model/acp.ts +11 -3
- package/src/model/agent.ts +20 -4
- package/src/model/history.ts +5 -0
- package/src/model/installation.ts +86 -0
- package/src/model/plugin-host.ts +5 -1
- package/src/model/workspace-config.ts +6 -12
- package/src/pbot.ts +13 -32
- package/src/plugin.ts +3 -3
- package/src/services/agents/agent-service.ts +29 -17
- package/src/services/history/history-capture.ts +30 -22
- package/src/services/history/history-migrate.ts +23 -50
- package/src/services/history/history-query.ts +34 -48
- package/src/services/history/summary-command.ts +9 -8
- package/src/services/history/summary-registry.ts +2 -3
- package/src/services/history/summary-runner.ts +72 -81
- package/src/services/history/workspace-history.ts +8 -0
- package/src/services/installation/setup-service.ts +9 -43
- package/src/services/installation/upgrade-service.ts +127 -0
- package/src/services/workspace/plugin-releases.ts +121 -0
- package/src/services/workspace/workspace-config.ts +9 -8
- package/src/services/workspace/workspace-mcp.ts +23 -28
- package/src/services/workspace/workspace-skills.ts +5 -2
- package/src/storage/acp-files.ts +7 -12
- package/src/storage/agent-files.ts +6 -5
- package/src/storage/atomic-json.ts +31 -4
- package/src/storage/history-files.ts +22 -15
- package/src/storage/history-format.ts +6 -8
- package/src/tools/history/contract.ts +9 -9
- package/src/tools/history/pi-tool.ts +6 -4
- package/src/ui/dsh/elements.ts +5 -12
- package/src/ui/dsh/management.ts +10 -10
- package/src/ui/dsh/styles.ts +5 -33
- package/lib/antigravity-plugin/lib/services/history/history-migrate.d.ts +0 -12
- package/lib/antigravity-plugin/lib/services/history/history-migrate.js +0 -88
- package/lib/ui/presentation.d.ts +0 -3
- package/lib/ui/presentation.js +0 -12
- package/src/tools/access.ts +0 -7
- package/src/tools/register.ts +0 -21
- package/src/ui/presentation.ts +0 -12
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
# Codex 与 Qoder CLI
|
|
2
|
+
|
|
3
|
+
两个原生插件共用 npm 包提供的 `pbot` 命令。宿主启动环境需要 Node.js 22.19+ 和 npm。PATH 中有 0.3.3 或更新的 CLI 时,插件交由 CLI 检查目标工作区是否启用,再决定是否升级。缺少此启动器时,插件通过 npx 安装或复用自身指定的版本。下面的安装流程适用于 Linux 和 macOS,已用 Codex CLI 0.172.0 和 Qoder CLI 1.1.100 校验。
|
|
4
|
+
|
|
5
|
+
## 安装
|
|
6
|
+
|
|
7
|
+
在本仓库使用 Node.js 24.9+ 构建并安装当前工作树的包。
|
|
8
|
+
|
|
9
|
+
```sh
|
|
10
|
+
npm ci --ignore-scripts
|
|
11
|
+
npm install --global "$(npm pack --silent | tail -1)"
|
|
12
|
+
pbot --version
|
|
13
|
+
pbot_lib="$(npm root --global)/personal-bot/lib"
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
按使用的宿主执行对应命令。Codex 通过本地 marketplace 安装。安装后在 Codex 的 `/hooks` 中检查并信任 Personal Bot 的 `SessionStart`、`UserPromptSubmit` 和 `Stop` 命令,再开始会话。更新后若 hook 定义变化,需要重新检查。详见 [Codex 插件 hook 说明](https://developers.openai.com/plugins/build/plugins)。
|
|
17
|
+
|
|
18
|
+
```sh
|
|
19
|
+
codex plugin marketplace add "$pbot_lib/codex-marketplace"
|
|
20
|
+
codex plugin add personal-bot@pbot-local
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
Qoder CLI 支持直接从本地插件目录安装。清单和组件目录格式见 [Qoder 插件参考](https://docs.qoder.com/cli/plugins-reference)。
|
|
24
|
+
|
|
25
|
+
```sh
|
|
26
|
+
qodercli plugin install "$pbot_lib/qoder-plugin"
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## 工作区与工具
|
|
30
|
+
|
|
31
|
+
在目标工作区根目录执行下列命令,或在宿主中调用插件的 `pbot` 管理技能,传入 `init`、`status` 或 `history` 子命令。
|
|
32
|
+
|
|
33
|
+
```sh
|
|
34
|
+
pbot plugin codex init
|
|
35
|
+
pbot plugin codex status
|
|
36
|
+
# Qoder CLI
|
|
37
|
+
pbot plugin qoder init
|
|
38
|
+
pbot plugin qoder status
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
两个宿主共用一份 `.pbot/config.json`,同一目录初始化一次即可。Codex hook 使用事件的 `cwd`。Qoder 的 hook、管理命令和 MCP 共用 `QODER_PROJECT_DIR`,缺失时依次使用 `PBOT_WORKSPACE_ROOT` 与工作目录。
|
|
42
|
+
|
|
43
|
+
启用历史后,新会话的 `SessionStart` 会提示旧布局或待更新的摘要。需要处理提醒时,在当前工作区执行 `pbot history migrate --dry-run` 预览迁移,或用 `pbot history summary` 生成摘要。提交提示时按配置注入协调者上下文和包内方法技能索引,`Stop` 配合提交事件记录主会话问答。Codex 按会话和回合 ID 关联追加输入及回复。原始记录的来源分别为 `codex` 和 `qoder`。
|
|
44
|
+
|
|
45
|
+
宿主原生发现根 `AGENTS.md` 与 `.agents/skills/`。包内方法按 `features.skills` 提供,管理技能可由用户显式调用。
|
|
46
|
+
|
|
47
|
+
插件的 `.mcp.json` 启动 `pbot mcp`。在启用的工作区可通过 `worker_discover` 查询后端、使用 `worker_create` 指定目标,并通过 `worker_request` 派发任务。调用时使用上下文给出的 `workspaceRoot` 作为 `workspace`。原生子代理由宿主管理。
|
|
48
|
+
|
|
49
|
+
作为 ACP 目标使用时,`codex` 需要单独安装 `@agentclientprotocol/codex-acp`,`qoder` 使用 `qodercli --acp`(也接受 `qodercli` 和 `qoder-cli` 后端别名)。模型调用沿用目标程序的登录配置。安装原生宿主插件和配置 ACP 后端可以分别进行。
|
|
50
|
+
|
|
51
|
+
## Codex 转发工作区 MCP 所需的环境变量
|
|
52
|
+
|
|
53
|
+
如果 `.pbot/mcp.json` 使用 `${INTERNAL_MCP_TOKEN}` 等变量,先在启动 Codex 的环境中设置值,再在 Codex 的用户配置或受信任项目的 `.codex/config.toml` 中按名称转发。以下同名服务配置覆盖插件的默认启动配置。
|
|
54
|
+
|
|
55
|
+
```toml
|
|
56
|
+
[mcp_servers.pbot]
|
|
57
|
+
command = "pbot"
|
|
58
|
+
args = ["mcp"]
|
|
59
|
+
env = { PBOT_HOST = "codex" }
|
|
60
|
+
env_vars = ["INTERNAL_MCP_TOKEN"]
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
将示例变量名替换为工作区实际引用的名称,值留在宿主环境中。重启 Codex 后,可用 `codex mcp list --json` 核对 `pbot.transport.env_vars`,并用 `workspace_mcp_discover` 指定服务名验证连接。同一环境也供 ACP worker 解析共享 MCP 配置。详见 [Codex MCP 配置](https://developers.openai.com/codex/mcp)。
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
# 架构治理工作台
|
|
2
|
+
|
|
3
|
+
## 范围与验证入口
|
|
4
|
+
|
|
5
|
+
依赖图按当前 checkout 生成。运行 `npm exec -- depcruise --include-only '^src/' --config .dependency-cruiser.cjs -T dot src > dependencies.dot` 生成逐模块依赖图,使用 `npm run check` 检查环、解析失败与越层依赖。源码权责见[技术设计](../architecture/design.md),工作区、控制记录及历史文件的路径以该文的存储表为准。
|
|
6
|
+
|
|
7
|
+
| 概念 | 状态所有者与流向 | 变更或验证入口 |
|
|
8
|
+
| --- | --- | --- |
|
|
9
|
+
| 宿主装配与上下文 | Pi Lifecycle、dsh DshWorkspaces 随会话持有实例;无状态 hook 每次解析绑定根和配置 | hosts 适配器、plugin-registry、各宿主集成测试 |
|
|
10
|
+
| Web 与 TUI | dsh 管理页持有显示状态,经 Typert 调用宿主;Pi 原生通知和确认队列绑定当前实例 | ui/dsh、ui/pi、tests/dsh、tests/ui |
|
|
11
|
+
| 工具与协议 | 模型工具输入经适配器校验,服务实施查询和控制;MCP stdio 负责请求、响应与进度通知 | tools/history、extension/mcp、tests/tools、tests/mcp |
|
|
12
|
+
| 工作区配置 | workspace-config 校验 opt-in、功能、摘要和 ACP 配置;workspace-mcp 校验、展开并写共享服务定义 | tests/workspace/config、tests/integration/workspace-config |
|
|
13
|
+
| 原始历史与派生状态 | 宿主采集 → history-capture → HistoryFiles;维度规划、锁、指纹与摘要执行由 summary-runner 协调 | tests/history、tests/storage、tests/dsh/history |
|
|
14
|
+
| Worker 与交互 | AgentService 管理 owner、生命周期和请求;AgentFiles 管理 generation 与队列;ACP 子进程交换模型选择、权限、表单及输出 | services/agents、integrations/acp、extension/acp、tests/agents |
|
|
15
|
+
| 连接与缓存 | 每个 MCP runtime 持有工作区服务实例与下游连接;退出时释放。原生挂载由宿主 SDK 释放 | extension/mcp/bridge、Pi、dsh、tests/mcp/workspace-bridge |
|
|
16
|
+
| 权限与凭据 | 工作区外写入交宿主确认,worker 的权限和 elicitation 由 ACP 会话处理,环境与认证由接入方提供 | workspace-files、ui/pi/confirmation、integrations/acp/input |
|
|
17
|
+
| 异常、重试与观测 | 存储写锁返回可辨识的 busy 错误;协议边界把异常转成相应传输结果;宿主负责日志、进度与取消 | storage、services/history、extension/mcp、各宿主边界 |
|
|
18
|
+
| 安装与分发 | package.json 管理发布版本;锁文件固定依赖;CLI、dsh、插件构建按序生成消费者产物 | scripts、smoke、CI 的 npm 包消费者检查 |
|
|
19
|
+
|
|
20
|
+
## 当前任务池
|
|
21
|
+
|
|
22
|
+
| 状态 | 证据与行动 |
|
|
23
|
+
| --- | --- |
|
|
24
|
+
| 已治理 | Pi、dsh 和独立 CLI 共用 `src/extension/history/command.ts` 执行历史命令。dsh 聊天命令直接使用已验证的工作区,Web 继续通过 Typert。宿主持有取消信号和进度展示。 |
|
|
25
|
+
| 已治理 | MCP 调用字段从 tool-contract 的公开 schema 提取,十份手写字段表已删除。工具名联合类型使执行分派具备编译期穷尽检查。 |
|
|
26
|
+
| 已治理 | bridge 以同一记录持有握手与就绪连接。新配置立即建立连接;旧配置的调用完成后释放旧会话。双 HTTP 端点测试在握手期间切换配置并验证各自的身份与清理。 |
|
|
27
|
+
| 已治理 | runtime.nativeServer 从已创建实例取得 worker 控制目录与会话 ID,生成 Pi/dsh 的挂载参数;两个宿主各自管理 SDK 注册、超时单位与环境继承。 |
|
|
28
|
+
| 已治理 | 工作区 MCP 配置写入在文件锁内读取最新值并原子发布,仅更新 mcpServers,保留用户顶层扩展字段和未展开的模板。CLI 并发新增与删除均由真实进程覆盖。 |
|
|
29
|
+
| 已治理 | AgentHost 与安装器能力类型在 model 定义。服务与适配器都依赖这些类型,dependency-cruiser 同时检查类型边和运行时边,限制 Pi/dsh SDK 的直接导入位置。 |
|
|
30
|
+
| 已治理 | historyPageLimits 与历史标识语法供服务、原生工具、MCP 和 Web 使用。MCP 编排无需再从存储模块导入标识校验。 |
|
|
31
|
+
| 已治理 | 历史列表、全文检索和节点回读使用同一摘要身份,Web 可使用返回的 host 打开跨宿主月度摘要。 |
|
|
32
|
+
| 已治理 | 工作区历史访问统一解析布局。状态与启动提醒共用只读维度规划,提醒继续在历史较新时提前返回;三个宿主入口共用启动通知。 |
|
|
33
|
+
| 已治理 | 历史迁移对两类文件使用同一条路径生成和报告流程。存储检查预览与实际目的路径,在删除原文件前同步目标目录。 |
|
|
34
|
+
| 已治理 | dsh Web 的历史与工作区两页保留正在使用的输入、来源标记与布局;已移除旧 worker 面板的状态映射、控件和样式。 |
|
|
35
|
+
| 已治理 | Pi 只暴露一个原生历史工具。其注册函数随实例返回隐藏操作,已删除通用工具注册表及历史工具用不到的文件写入权限接口。 |
|
|
36
|
+
| 已治理 | 工作区权限、历史布局、worker 状态和回复动作由数据契约声明可选值;配置和控制记录按实际 JSON 类型校验。摘要默认并发数与上限由模型常量提供。 |
|
|
37
|
+
| 已治理 | MCP 完成配置读取后再次检查运行时是否关闭。历史与外部服务请求独立执行,只有 worker 调用建立 AgentService。同一实例的重复关闭共用清理结果。 |
|
|
38
|
+
| 已治理 | Pi/dsh 主会话与 ACP 成员共用原生 MCP 加载流程,个别服务失败只影响该项;ACP 协议透传继续严格校验整份配置。 |
|
|
39
|
+
| 已治理 | build:plugins 编译一次独立运行时,再将同一份文件放入 npm 与 Antigravity 包。三个构建入口共用锁定的 TypeScript 编译器。 |
|
|
40
|
+
| 已治理 | 摘要在锁外生成,锁内核对规划时的产物。并发任务使用相同来源时复用已发布结果,来源冲突进入该项失败报告;下游月度任务读取已发布的会话摘要。 |
|
|
41
|
+
| 已治理 | worker 命令直接解析公开工具名和短名。AgentService 在一次状态读取中匹配代次、请求与周期;MCP 轮询只负责等待和呈现,私有字段阻止其再访问消息存储。 |
|
|
42
|
+
| 已验收 | 全库扫描覆盖 115 个源码模块、415 条内部依赖。当前任务池中可安全独立实施的项目均已提交,余项见下方验收边界。 |
|
|
43
|
+
|
|
44
|
+
## 决策记录
|
|
45
|
+
|
|
46
|
+
| 主题 | 采用的方案与取舍 | 防回归入口 |
|
|
47
|
+
| --- | --- | --- |
|
|
48
|
+
| 历史命令 | 共用编排函数解析和执行。Pi 与 dsh 各自保留会话校验、取消及结果展示。将 SDK 调用下沉到服务会引入宿主依赖,各宿主独立执行则需要同步修改业务分支。 | 宿主集成测试、services 依赖规则 |
|
|
49
|
+
| 工具契约 | 工具定义提供字段名和公开描述,执行层检查具体值、授权与功能开关。服务端可以独立分发。原生工具的 TypeBox 与 MCP 的 JSON Schema 各自满足其宿主加载约定。 | 工具契约与 stdio 测试、TypeScript 穷尽检查、安装包检查 |
|
|
50
|
+
| 下游连接 | 一个运行时管理握手、已就绪连接和仍被请求使用的旧连接。切换配置时为新调用建立新连接,完成旧请求后释放。全局串行会让一个慢服务阻塞其他请求。 | 双 HTTP 端点测试、关闭时仍在读取配置的请求测试 |
|
|
51
|
+
| 配置发布 | 进程在短目录锁内重读并原子替换 JSON。原子替换单独只能保证文件完整,无法保留并发编辑。锁超时提示操作者核实持有进程。 | 12 个独立 CLI 进程增删、用户元数据回读、原子文件测试 |
|
|
52
|
+
| 摘要发布 | 模型工作在锁外进行,发布时核对同一产物的规划基线。相同来源复用先发布的结果,来源冲突保留当前文件并报告任务失败。长时间持锁会阻塞同维度的无关摘要。 | 两次相互交叠的真实文件写入、增量和强制重建测试 |
|
|
53
|
+
| 原生挂载 | 共享工作区服务的解析和逐项加载,Pi 与 dsh 各自持有 SDK 注册和释放。ACP 透传以整份会话配置为单位校验。三种接口的超时单位、错误范围和生命周期仍由各自契约规定。 | 原生 Pi/dsh 工具发现、ACP 成员与传输测试 |
|
|
54
|
+
| 分发 | 在独立临时目录编译一次插件运行时,再分别组装 npm 与 Antigravity 产物。从整个 lib 复制会把同目录的 dsh 和 CLI 专用产物带入插件。 | 包内真实宿主加载、解包后独立执行、原生清单校验 |
|
|
55
|
+
|
|
56
|
+
## 技术方案与保留边界
|
|
57
|
+
|
|
58
|
+
- Pi 原生扩展、dsh Cordis 与 Typert、无 SDK 的轻插件 hook 分别对应三类宿主加载契约。Pi 使用原生 TUI,dsh Web 使用宿主组件与样式。新增轻插件通过 PluginHostRegistry 扩展。
|
|
59
|
+
- 跨宿主调度采用 stdio MCP 与 ACP v1。下游 MCP 同时支持 stdio 和 Streamable HTTP,各自负责进程或 HTTP 会话。模型选择、环境变量及身份凭据由接入方提供。
|
|
60
|
+
- JSON 文件承担工作区与进程间的持久化。原始历史是摘要输入,摘要按来源指纹派生。原始记录、worker 控制代次、跨宿主历史标识、平铺读取和显式迁移分别有现行消费者。
|
|
61
|
+
- 开发与发布使用锁定的 TypeScript、esbuild、Node 测试与原生插件校验器。维护脚本说明运行版本、命令和独立安装检查。详见[维护脚本](../../scripts/README.md)。
|
|
62
|
+
|
|
63
|
+
## 待确认与验收边界
|
|
64
|
+
|
|
65
|
+
| 事项 | 当前行为与再次开启的条件 |
|
|
66
|
+
| --- | --- |
|
|
67
|
+
| 写入进程异常退出后的遗留锁 | 超时后报告锁路径,由操作者核实。跨进程自动接管需要先确定如何可靠识别仍存活的持有者。 |
|
|
68
|
+
| 真实模型端到端验收 | 普通回归使用本地文件、协议进程和宿主 SDK。模型账号下的行为按仓库约定在获准的专用环境单独验收。 |
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
## 本批验收
|
|
72
|
+
|
|
73
|
+
| 验收面 | 结果 |
|
|
74
|
+
| --- | --- |
|
|
75
|
+
| 依赖方向 | TypeScript 和 dependency-cruiser 通过。依赖图包含 115 个源码模块,检测到 0 个环、0 项规则违规。临时违规导入验证了 services 类型依赖与 Pi、dsh SDK 所有权规则。 |
|
|
76
|
+
| 公开协议 | 从基线提交 `9d4fcc2` 独立构建 stdio MCP,在工作区绑定、功能开关、原生挂载的四组配置下对比初始化和工具发现,全部响应内容一致。 |
|
|
77
|
+
| 本地回归 | Node 24.22.2 上全量构建,134 项测试通过。覆盖真实文件、隔离进程、并发写入、跨宿主历史与原生加载。 |
|
|
78
|
+
| 分发与宿主 | 同一 npm 包在 Node 22.19.0 通过 Pi 和 Claude 消费者检查,在 Node 24.22.2 通过 dsh 消费者检查。Claude、Antigravity、Qoder 原生校验均通过。Claude 提示缺少作者、图标;Antigravity 提示使用通用图标。 |
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# Disclaimer / 免责声明
|
|
2
|
+
|
|
3
|
+
## English
|
|
4
|
+
|
|
5
|
+
AI models can produce incorrect answers, commands, and code. Verify information before relying on it. Review proposed changes before applying them to important files or systems.
|
|
6
|
+
|
|
7
|
+
Workers and MCP tools may read or change files, run commands, or send workspace data to services you configure. Check which data and credentials a worker or service can access when granting permissions. Third-party providers may charge for requests and process data under their own terms and privacy policies.
|
|
8
|
+
|
|
9
|
+
Personal Bot is provided “as is”. Its warranty disclaimer and limitation of liability are set out in the project license. Third-party software is subject to its own licenses. [MIT License](LICENSE)
|
|
10
|
+
|
|
11
|
+
## 中文
|
|
12
|
+
|
|
13
|
+
AI 模型生成的回答、命令和代码可能有误。请在据此作出决定前核实关键信息,在将更改应用到重要文件或系统前审查具体内容。
|
|
14
|
+
|
|
15
|
+
Worker 和 MCP 工具可能读取或修改文件、执行命令,或将工作区数据发送给你配置的服务。授予权限时,请确认对方能够访问哪些数据和凭据。第三方服务可能按请求收费,并按各自的条款和隐私政策处理数据。
|
|
16
|
+
|
|
17
|
+
Personal Bot 按现状提供,担保免责和责任限制条款见项目许可证。第三方软件适用其各自的许可证。[MIT 许可证全文](LICENSE)
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Personal Bot contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { spawn } from "node:child_process";
|
|
3
|
+
import { readFileSync } from "node:fs";
|
|
4
|
+
import { fileURLToPath } from "node:url";
|
|
5
|
+
import { join } from "node:path";
|
|
6
|
+
|
|
7
|
+
if (!process.env.PBOT_ACP_PI_COMMAND) throw new Error("Missing Personal Bot Pi ACP launch context");
|
|
8
|
+
|
|
9
|
+
let args;
|
|
10
|
+
if (process.env.PBOT_SUMMARY_WORKER === "1") {
|
|
11
|
+
// Minimal pure-text Pi runtime for history summarization: no tools, extensions, skills, templates, or AGENTS.md.
|
|
12
|
+
args = [
|
|
13
|
+
...process.argv.slice(2),
|
|
14
|
+
"--no-tools",
|
|
15
|
+
"--no-extensions",
|
|
16
|
+
"--no-skills",
|
|
17
|
+
"--no-prompt-templates",
|
|
18
|
+
"--no-context-files",
|
|
19
|
+
];
|
|
20
|
+
} else {
|
|
21
|
+
// pi-acp supplies RPC arguments. Add the managed member's native resource options.
|
|
22
|
+
const directory = process.env.PBOT_SUBAGENT_DIR;
|
|
23
|
+
if (!directory) throw new Error("Missing Personal Bot Pi ACP launch context");
|
|
24
|
+
const { options } = JSON.parse(readFileSync(join(directory, "descriptor.json"), "utf8"));
|
|
25
|
+
args = [...process.argv.slice(2), "--extension", fileURLToPath(new URL("../lib/extension/hosts/pi/acp-member.js", import.meta.url))];
|
|
26
|
+
if (options.noExtensions !== false) args.push("--no-extensions", "--extension", "builtin:mcp", "--extension", "builtin:codemode", "--extension", "builtin:tool-search");
|
|
27
|
+
if (options.noSkills) args.push("--no-skills");
|
|
28
|
+
if (options.noPromptTemplates) args.push("--no-prompt-templates");
|
|
29
|
+
if (options.noContextFiles) args.push("--no-context-files");
|
|
30
|
+
if (options.tools) args.push("--tools", options.tools.join(","));
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const child = spawn(process.env.PBOT_ACP_PI_COMMAND, args, { stdio: "inherit", env: process.env });
|
|
34
|
+
child.on("error", error => { console.error(error.message); process.exitCode = 1; });
|
|
35
|
+
for (const termination of ["SIGINT", "SIGTERM"]) process.on(termination, () => child.kill(termination));
|
|
36
|
+
child.on("exit", (code, termination) => { process.exitCode = termination ? 1 : code ?? 1; });
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { open, realpath, rename, unlink, link } from "node:fs/promises";
|
|
2
|
+
import { join, dirname, basename } from "node:path";
|
|
3
|
+
import { randomUUID } from "node:crypto";
|
|
4
|
+
import { requireThat } from "./validation.js";
|
|
5
|
+
export async function atomicFile(path, content, exclusive = false) {
|
|
6
|
+
const temp = path + "." + randomUUID();
|
|
7
|
+
const handle = await open(temp, "wx", 0o600);
|
|
8
|
+
try {
|
|
9
|
+
await handle.writeFile(content);
|
|
10
|
+
await handle.sync();
|
|
11
|
+
}
|
|
12
|
+
finally {
|
|
13
|
+
await handle.close();
|
|
14
|
+
}
|
|
15
|
+
try {
|
|
16
|
+
if (exclusive)
|
|
17
|
+
await link(temp, path);
|
|
18
|
+
else
|
|
19
|
+
await rename(temp, path);
|
|
20
|
+
const directory = await open(dirname(path), "r");
|
|
21
|
+
try {
|
|
22
|
+
await directory.sync();
|
|
23
|
+
}
|
|
24
|
+
finally {
|
|
25
|
+
await directory.close();
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
finally {
|
|
29
|
+
await unlink(temp).catch(error => { if (error.code !== "ENOENT")
|
|
30
|
+
throw error; });
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
export async function mutationTarget(path) {
|
|
34
|
+
try {
|
|
35
|
+
return await realpath(path);
|
|
36
|
+
}
|
|
37
|
+
catch (error) {
|
|
38
|
+
if (error.code !== "ENOENT")
|
|
39
|
+
throw error;
|
|
40
|
+
const parent = dirname(path);
|
|
41
|
+
requireThat(parent !== path, "无法定位目标路径。");
|
|
42
|
+
return join(await mutationTarget(parent), basename(path));
|
|
43
|
+
}
|
|
44
|
+
}
|
|
@@ -1,3 +1,7 @@
|
|
|
1
1
|
export declare const acpBackendPattern: RegExp;
|
|
2
2
|
export declare function isAcpBackend(value: unknown): value is string;
|
|
3
3
|
export declare function requireThat(condition: unknown, message: string): asserts condition;
|
|
4
|
+
/** Shared grammar for host and dimension identifiers in history archives and queries. */
|
|
5
|
+
export declare const historyIdentifierPattern: RegExp;
|
|
6
|
+
export declare function isHistoryIdentifier(value: unknown): value is string;
|
|
7
|
+
export declare function isOneOf<T extends string>(value: unknown, choices: readonly T[]): value is T;
|
|
@@ -6,3 +6,11 @@ export function requireThat(condition, message) {
|
|
|
6
6
|
if (!condition)
|
|
7
7
|
throw new Error(message);
|
|
8
8
|
}
|
|
9
|
+
/** Shared grammar for host and dimension identifiers in history archives and queries. */
|
|
10
|
+
export const historyIdentifierPattern = /^[a-z0-9][a-z0-9-]{0,63}$/;
|
|
11
|
+
export function isHistoryIdentifier(value) {
|
|
12
|
+
return typeof value === "string" && historyIdentifierPattern.test(value);
|
|
13
|
+
}
|
|
14
|
+
export function isOneOf(value, choices) {
|
|
15
|
+
return typeof value === "string" && choices.includes(value);
|
|
16
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
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
|
+
configuration: import("../../model/workspace-config.js").WorkspaceConfiguration;
|
|
9
|
+
features: Readonly<Required<import("../../model/workspace-config.js").WorkspaceFeatures>>;
|
|
10
|
+
check: () => void;
|
|
11
|
+
context: () => Promise<{
|
|
12
|
+
workspace: string;
|
|
13
|
+
role: string;
|
|
14
|
+
environment: string;
|
|
15
|
+
}>;
|
|
16
|
+
input(): AcpInput;
|
|
17
|
+
answer(input: AcpInput, state: AcpAnswer["state"], answer: string, error?: string): void;
|
|
18
|
+
}>;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { dirname } from "node:path";
|
|
2
|
+
import { realpathSync } from "node:fs";
|
|
3
|
+
import { AgentFiles, descriptor, launch } from "../../storage/agent-files.js";
|
|
4
|
+
import { acpInput, acpAnswer } from "../../storage/acp-files.js";
|
|
5
|
+
import { requireThat } from "../../common/validation.js";
|
|
6
|
+
import { packageVersion, releaseLine } from "../../common/version.js";
|
|
7
|
+
import { loadWorkspaceContext } from "../../integrations/agent-resources.js";
|
|
8
|
+
import { readWorkspaceConfig, workspaceDisabledMessage, workspaceFeatures } from "../../services/workspace/workspace-config.js";
|
|
9
|
+
export async function acpMember() {
|
|
10
|
+
const id = process.env.PBOT_SUBAGENT_RUN_ID, directory = process.env.PBOT_SUBAGENT_DIR, generation = process.env.PBOT_SUBAGENT_GENERATION;
|
|
11
|
+
requireThat(id && directory && generation, "缺少 ACP 成员启动身份。");
|
|
12
|
+
const files = new AgentFiles(dirname(realpathSync(directory)));
|
|
13
|
+
requireThat(files.directory(id) === realpathSync(directory), "ACP 成员目录不匹配。");
|
|
14
|
+
const d = files.read(id, "descriptor.json", descriptor);
|
|
15
|
+
requireThat(d.agentId === id && releaseLine(d.release) === releaseLine(packageVersion), "ACP 成员身份或版本无效。");
|
|
16
|
+
const configuration = await readWorkspaceConfig(d.workspace);
|
|
17
|
+
requireThat(configuration.enabled, workspaceDisabledMessage(configuration));
|
|
18
|
+
const features = workspaceFeatures(configuration);
|
|
19
|
+
const check = () => {
|
|
20
|
+
files.check();
|
|
21
|
+
const run = files.read(id, "launch.json", launch);
|
|
22
|
+
requireThat(run.generation === generation && (!run.stop || process.env.PBOT_ACP_VALIDATE === "1"), "ACP 成员已停止或启动代次变化。");
|
|
23
|
+
};
|
|
24
|
+
const context = async () => {
|
|
25
|
+
const reference = files.reference(id);
|
|
26
|
+
const host = reference.host === "acp" ? reference.backend : "pi";
|
|
27
|
+
const loaded = await loadWorkspaceContext({ host, root: d.workspace, role: "general-purpose" });
|
|
28
|
+
return { workspace: loaded.workspace, role: loaded.role, environment: JSON.stringify(loaded.environment) };
|
|
29
|
+
};
|
|
30
|
+
return { files, d, id, generation, configuration, features, check, context,
|
|
31
|
+
input() {
|
|
32
|
+
check();
|
|
33
|
+
const input = files.read(id, "acp-input.json", acpInput);
|
|
34
|
+
requireThat(input.generation === generation, "ACP 输入代次无效。");
|
|
35
|
+
return input;
|
|
36
|
+
},
|
|
37
|
+
answer(input, state, answer, error) {
|
|
38
|
+
// A stop can race the native terminal event. The current generation may still seal its result.
|
|
39
|
+
if (files.read(id, "launch.json", launch).generation !== generation)
|
|
40
|
+
return;
|
|
41
|
+
files.write(id, "acp-answer.json", { ...input, state, answer, ...(error ? { error } : {}) }, acpAnswer);
|
|
42
|
+
},
|
|
43
|
+
};
|
|
44
|
+
}
|