personal-bot 0.3.1 → 0.3.3
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 +27 -11
- package/bin/pbot.mjs +22 -2
- package/docs/README.md +3 -1
- package/docs/architecture/design.md +37 -24
- package/docs/architecture/extensibility.md +27 -19
- package/docs/architecture/model-context.md +4 -3
- package/docs/architecture/principles.md +5 -4
- package/docs/guides/capabilities.md +4 -4
- package/docs/guides/cross-harness-workers.md +3 -1
- package/docs/guides/history.md +73 -16
- package/docs/guides/workspace-configuration.md +35 -6
- package/docs/hosts/antigravity.md +2 -0
- package/docs/hosts/claude-code.md +1 -1
- package/docs/hosts/codex-qoder.md +63 -0
- package/docs/hosts/dsh.md +1 -1
- package/docs/hosts/pi.md +1 -1
- package/docs/maintainers/architecture-governance.md +78 -0
- package/hooks/hooks.json +3 -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/hooks.json +7 -0
- package/lib/antigravity-plugin/lib/claude.js +2 -2
- 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/{extension/acp-member.d.ts → antigravity-plugin/lib/extension/acp/member.d.ts} +5 -5
- package/lib/{extension/acp-member.js → antigravity-plugin/lib/extension/acp/member.js} +6 -6
- package/lib/antigravity-plugin/lib/extension/acp-worker.js +222 -51
- 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/{extension → antigravity-plugin/lib/extension/hosts}/dsh/acp-member.js +11 -25
- package/lib/{extension → antigravity-plugin/lib/extension/hosts}/dsh/files.js +3 -3
- 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 +12 -0
- package/lib/antigravity-plugin/lib/extension/hosts/plugin-runtime.js +101 -0
- 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 +2705 -1348
- package/lib/antigravity-plugin/lib/extension/workspace-cli.js +20127 -0
- package/lib/antigravity-plugin/lib/integrations/agent-resources.d.ts +1 -0
- package/lib/antigravity-plugin/lib/integrations/agent-resources.js +6 -2
- package/lib/antigravity-plugin/lib/integrations/hosts/antigravity/adapter.d.ts +6 -0
- package/lib/antigravity-plugin/lib/integrations/hosts/antigravity/adapter.js +171 -0
- package/lib/antigravity-plugin/lib/integrations/hosts/{claude.d.ts → claude/adapter.d.ts} +1 -1
- package/lib/antigravity-plugin/lib/integrations/hosts/claude/adapter.js +36 -0
- 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/{integrations → antigravity-plugin/lib/integrations/hosts}/dsh/mcp.d.ts +1 -1
- package/lib/{integrations → antigravity-plugin/lib/integrations/hosts}/dsh/resources.d.ts +1 -1
- package/lib/{integrations → antigravity-plugin/lib/integrations/hosts}/dsh/resources.js +4 -4
- package/lib/{integrations → antigravity-plugin/lib/integrations/hosts}/dsh/skills.js +1 -1
- 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/{registry.d.ts → plugin-registry.d.ts} +1 -0
- package/lib/{integrations/hosts/registry.js → antigravity-plugin/lib/integrations/hosts/plugin-registry.js} +10 -3
- 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 +179 -0
- package/lib/antigravity-plugin/lib/model/history.js +4 -0
- package/lib/antigravity-plugin/lib/model/plugin-host.d.ts +31 -0
- package/lib/antigravity-plugin/lib/model/workspace-config.d.ts +28 -7
- 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 +4 -4
- package/lib/antigravity-plugin/lib/services/history/history-capture.d.ts +4 -0
- package/lib/antigravity-plugin/lib/services/history/history-capture.js +98 -0
- package/lib/antigravity-plugin/lib/services/history/history-index.d.ts +17 -0
- package/lib/antigravity-plugin/lib/services/history/history-index.js +112 -0
- package/lib/antigravity-plugin/lib/services/history/summary-dimensions/monthly.d.ts +7 -0
- package/lib/antigravity-plugin/lib/services/history/summary-dimensions/monthly.js +121 -0
- package/lib/antigravity-plugin/lib/services/history/summary-dimensions/session.d.ts +7 -0
- package/lib/antigravity-plugin/lib/services/history/summary-dimensions/session.js +124 -0
- package/lib/antigravity-plugin/lib/services/history/summary-registry.d.ts +7 -0
- package/lib/antigravity-plugin/lib/services/history/summary-registry.js +35 -0
- package/lib/antigravity-plugin/lib/services/history/summary-runner.d.ts +34 -0
- package/lib/antigravity-plugin/lib/services/history/summary-runner.js +299 -0
- 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 +3 -0
- package/lib/antigravity-plugin/lib/services/workspace/plugin-releases.js +78 -0
- package/lib/antigravity-plugin/lib/services/workspace/workspace-config.d.ts +5 -1
- package/lib/antigravity-plugin/lib/services/workspace/workspace-config.js +77 -7
- 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/file-access.d.ts +2 -0
- package/lib/antigravity-plugin/lib/storage/file-access.js +26 -0
- package/lib/antigravity-plugin/lib/storage/history-files.d.ts +55 -0
- package/lib/antigravity-plugin/lib/storage/history-files.js +473 -0
- package/lib/antigravity-plugin/lib/storage/history-format.d.ts +5 -0
- package/lib/antigravity-plugin/lib/storage/history-format.js +60 -0
- 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/antigravity-plugin/skills/provider-connections/SKILL.md +22 -12
- package/lib/claude.js +2 -2
- package/lib/client.js +42 -60
- 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 +6 -6
- package/lib/extension/acp/member.d.ts +18 -0
- package/lib/extension/acp/member.js +44 -0
- package/lib/extension/acp/worker.js +384 -0
- package/lib/extension/acp-worker.js +222 -51
- 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.d.ts +4 -0
- package/lib/extension/hosts/dsh/acp-member.js +58 -0
- package/lib/extension/{dsh → hosts/dsh}/command.d.ts +1 -2
- package/lib/extension/{dsh → hosts/dsh}/command.js +9 -11
- package/lib/extension/hosts/dsh/files.d.ts +5 -0
- package/lib/extension/hosts/dsh/files.js +67 -0
- package/lib/extension/hosts/dsh/history.d.ts +4 -0
- package/lib/extension/hosts/dsh/history.js +62 -0
- package/lib/extension/{dsh → hosts/dsh}/management.d.ts +1 -1
- package/lib/extension/{dsh → hosts/dsh}/management.js +12 -10
- package/lib/extension/{dsh → hosts/dsh}/workspace.d.ts +3 -9
- package/lib/extension/{dsh → hosts/dsh}/workspace.js +30 -99
- 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 +12 -0
- package/lib/extension/hosts/plugin-runtime.js +101 -0
- 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 → mcp/bridge.d.ts} +7 -9
- package/lib/extension/{mcp-bridge.js → mcp/bridge.js} +70 -88
- package/lib/extension/{mcp-workers.d.ts → mcp/tool-contract.d.ts} +129 -374
- package/lib/extension/mcp/tool-contract.js +441 -0
- package/lib/extension/mcp/workers.d.ts +487 -0
- package/lib/extension/mcp/workers.js +598 -0
- package/lib/extension/mcp.js +2705 -1348
- package/lib/extension/{setup-cli.js → setup/cli.js} +12 -9
- package/lib/extension/workspace-cli.js +20127 -0
- package/lib/integrations/acp/agents.d.ts +2 -3
- package/lib/integrations/acp/connection.d.ts +11 -10
- package/lib/integrations/acp/connection.js +6 -0
- package/lib/integrations/acp/harnesses/claude.js +1 -1
- package/lib/integrations/acp/harnesses/dsh.js +1 -1
- package/lib/integrations/acp/harnesses/presets.js +8 -0
- package/lib/integrations/acp/history-summary.d.ts +17 -0
- package/lib/integrations/acp/history-summary.js +101 -0
- package/lib/integrations/acp/launch.d.ts +2 -2
- package/lib/integrations/agent-resources.d.ts +1 -0
- package/lib/integrations/agent-resources.js +6 -2
- package/lib/integrations/hosts/antigravity/adapter.d.ts +6 -0
- package/lib/integrations/hosts/antigravity/adapter.js +171 -0
- package/lib/integrations/hosts/{claude.d.ts → claude/adapter.d.ts} +1 -1
- package/lib/integrations/hosts/claude/adapter.js +36 -0
- package/lib/integrations/hosts/codex/adapter.d.ts +2 -0
- package/lib/integrations/hosts/codex/adapter.js +14 -0
- package/lib/integrations/hosts/dsh/mcp.d.ts +4 -0
- package/lib/integrations/hosts/dsh/mcp.js +28 -0
- package/lib/integrations/hosts/dsh/messages.d.ts +36 -0
- package/lib/integrations/hosts/dsh/messages.js +11 -0
- package/lib/integrations/hosts/dsh/resources.d.ts +6 -0
- package/lib/integrations/hosts/dsh/resources.js +47 -0
- package/lib/integrations/hosts/dsh/root-agents.d.ts +4 -0
- package/lib/integrations/hosts/dsh/root-agents.js +3 -0
- package/lib/integrations/{dsh → hosts/dsh}/schema.js +1 -1
- package/lib/integrations/hosts/dsh/skills.d.ts +8 -0
- package/lib/integrations/hosts/dsh/skills.js +31 -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/{registry.d.ts → plugin-registry.d.ts} +1 -0
- package/lib/{antigravity-plugin/lib/integrations/hosts/registry.js → integrations/hosts/plugin-registry.js} +10 -3
- 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/pi-setup.js +1 -1
- 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 +143 -34
- package/lib/model/history.js +4 -1
- package/lib/model/installation.js +1 -0
- package/lib/model/plugin-host.d.ts +31 -0
- package/lib/model/workspace-config.d.ts +28 -7
- package/lib/model/workspace-config.js +2 -1
- package/lib/plugin.d.ts +2 -1
- package/lib/plugin.js +4 -4
- 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-run.d.ts +1 -1
- 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.d.ts +4 -0
- package/lib/services/history/history-capture.js +98 -0
- package/lib/services/history/history-index.d.ts +16 -7
- package/lib/services/history/history-index.js +48 -70
- package/lib/services/history/history-migrate.d.ts +12 -0
- package/lib/services/history/history-migrate.js +54 -0
- package/lib/services/history/history-query.d.ts +51 -0
- package/lib/services/history/history-query.js +352 -0
- package/lib/services/history/summary-command.d.ts +20 -0
- package/lib/services/history/summary-command.js +69 -0
- package/lib/services/history/summary-dimensions/monthly.d.ts +7 -0
- package/lib/services/history/summary-dimensions/monthly.js +121 -0
- package/lib/services/history/summary-dimensions/session.d.ts +7 -0
- package/lib/services/history/summary-dimensions/session.js +124 -0
- package/lib/services/history/summary-registry.d.ts +7 -0
- package/lib/services/history/summary-registry.js +35 -0
- package/lib/services/history/summary-runner.d.ts +34 -0
- package/lib/services/history/summary-runner.js +299 -0
- package/lib/services/history/workspace-history.d.ts +3 -0
- package/lib/services/history/workspace-history.js +6 -0
- package/lib/services/workspace/plugin-releases.d.ts +3 -0
- package/lib/services/workspace/plugin-releases.js +78 -0
- package/lib/services/workspace/workspace-config.d.ts +5 -1
- package/lib/services/workspace/workspace-config.js +77 -7
- 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 +46 -9
- package/lib/storage/history-files.js +382 -250
- package/lib/storage/history-format.d.ts +3 -13
- package/lib/storage/history-format.js +26 -52
- package/lib/tools/history/actions.d.ts +3 -68
- package/lib/tools/history/actions.js +7 -5
- package/lib/tools/history/contract.d.ts +16 -17
- package/lib/tools/history/contract.js +63 -22
- package/lib/tools/history/dsh-tool.d.ts +1 -2
- package/lib/tools/history/dsh-tool.js +11 -5
- package/lib/ui/dsh/elements.d.ts +2 -5
- package/lib/ui/dsh/elements.js +3 -16
- package/lib/ui/dsh/management.js +26 -13
- 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 +2 -1
- package/resources/prompts/history-monthly-summary.md +13 -0
- package/resources/prompts/history-summary.md +10 -4
- package/resources/prompts/plugin-coordinator.md +1 -0
- package/resources/skills/provider-connections/SKILL.md +22 -12
- package/scripts/README.md +3 -2
- package/src/claude.ts +2 -2
- package/src/common/validation.ts +10 -0
- package/src/dsh.ts +6 -6
- package/src/extension/{acp-member.ts → acp/member.ts} +7 -7
- package/src/extension/{acp-worker.ts → acp/worker.ts} +131 -17
- package/src/extension/history/command.ts +68 -0
- package/src/extension/hosts/dsh/acp-entry.ts +21 -0
- package/src/extension/{dsh → hosts/dsh}/acp-member.ts +12 -23
- package/src/extension/{dsh → hosts/dsh}/command.ts +10 -12
- package/src/extension/{dsh → hosts/dsh}/files.ts +3 -3
- package/src/extension/hosts/dsh/history.ts +67 -0
- package/src/extension/{dsh → hosts/dsh}/management.ts +11 -9
- package/src/extension/{dsh → hosts/dsh}/workspace.ts +31 -76
- package/src/extension/{pi-acp-member.ts → hosts/pi/acp-member.ts} +12 -18
- package/src/extension/{command.ts → hosts/pi/command.ts} +44 -11
- package/src/extension/{events.ts → hosts/pi/events.ts} +8 -4
- package/src/extension/hosts/pi/history.ts +45 -0
- package/src/extension/{lifecycle.ts → hosts/pi/lifecycle.ts} +9 -12
- package/src/extension/hosts/plugin-runtime.ts +96 -0
- package/src/extension/hosts/workspace-mcp.ts +25 -0
- package/src/extension/{mcp-bridge.ts → mcp/bridge.ts} +85 -85
- package/src/extension/mcp/tool-contract.ts +462 -0
- package/src/extension/{mcp-workers.ts → mcp/workers.ts} +151 -448
- package/src/extension/{setup-cli.ts → setup/cli.ts} +14 -11
- package/src/extension/setup/workspace-cli.ts +159 -0
- package/src/integrations/acp/agents.ts +2 -3
- package/src/integrations/acp/connection.ts +6 -0
- package/src/integrations/acp/harnesses/claude.ts +1 -1
- 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 +109 -0
- package/src/integrations/agent-resources.ts +7 -1
- package/src/integrations/hosts/antigravity/adapter.ts +161 -0
- package/src/integrations/hosts/claude/adapter.ts +39 -0
- package/src/integrations/hosts/codex/adapter.ts +16 -0
- package/src/integrations/{dsh → hosts/dsh}/mcp.ts +1 -1
- package/src/integrations/{dsh → hosts/dsh}/resources.ts +5 -5
- package/src/integrations/{dsh → hosts/dsh}/schema.ts +1 -1
- package/src/integrations/{dsh → hosts/dsh}/session.ts +2 -2
- package/src/integrations/{dsh → hosts/dsh}/skills.ts +1 -1
- package/src/integrations/{pi → hosts/pi}/mcp.ts +1 -1
- package/src/integrations/{pi → hosts/pi}/skills.ts +1 -1
- package/src/integrations/hosts/{registry.ts → plugin-registry.ts} +11 -3
- 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 +116 -0
- package/src/integrations/installation/pi-bridge.ts +1 -1
- package/src/integrations/installation/pi-setup.ts +2 -2
- package/src/integrations/installation/processes.ts +1 -1
- package/src/mcp.ts +1 -1
- package/src/model/acp.ts +11 -3
- package/src/model/agent.ts +20 -4
- package/src/model/history.ts +156 -26
- package/src/model/installation.ts +41 -0
- package/src/model/plugin-host.ts +30 -2
- package/src/model/workspace-config.ts +31 -7
- package/src/pbot.ts +22 -50
- package/src/plugin.ts +4 -4
- package/src/services/agents/agent-service.ts +29 -17
- package/src/services/history/history-capture.ts +91 -0
- package/src/services/history/history-index.ts +48 -62
- package/src/services/history/history-migrate.ts +62 -0
- package/src/services/history/history-query.ts +401 -0
- package/src/services/history/summary-command.ts +70 -0
- package/src/services/history/summary-dimensions/monthly.ts +139 -0
- package/src/services/history/summary-dimensions/session.ts +149 -0
- package/src/services/history/summary-registry.ts +43 -0
- package/src/services/history/summary-runner.ts +343 -0
- package/src/services/history/workspace-history.ts +8 -0
- package/src/services/installation/setup-service.ts +2 -41
- package/src/services/workspace/plugin-releases.ts +68 -0
- package/src/services/workspace/workspace-config.ts +95 -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 +416 -189
- package/src/storage/history-format.ts +45 -61
- package/src/tools/history/actions.ts +8 -6
- package/src/tools/history/contract.ts +70 -25
- package/src/tools/history/dsh-tool.ts +17 -8
- package/src/tools/history/pi-tool.ts +23 -0
- package/src/ui/dsh/elements.ts +5 -12
- package/src/ui/dsh/management.ts +36 -20
- package/src/ui/dsh/styles.ts +5 -33
- package/src/ui/{confirmation.ts → pi/confirmation.ts} +1 -1
- package/lib/antigravity-plugin/lib/extension/plugin-runtime.d.ts +0 -10
- package/lib/antigravity-plugin/lib/extension/plugin-runtime.js +0 -67
- package/lib/antigravity-plugin/lib/integrations/hosts/antigravity.d.ts +0 -4
- package/lib/antigravity-plugin/lib/integrations/hosts/antigravity.js +0 -79
- package/lib/antigravity-plugin/lib/integrations/hosts/claude.js +0 -60
- package/lib/extension/dsh/history.d.ts +0 -15
- package/lib/extension/dsh/history.js +0 -87
- package/lib/extension/mcp-workers.js +0 -882
- package/lib/extension/plugin-runtime.d.ts +0 -10
- package/lib/extension/plugin-runtime.js +0 -67
- package/lib/integrations/dsh/history-summary.d.ts +0 -11
- package/lib/integrations/dsh/history-summary.js +0 -36
- package/lib/integrations/dsh/history.d.ts +0 -16
- package/lib/integrations/dsh/history.js +0 -167
- package/lib/integrations/history-summary.d.ts +0 -4
- package/lib/integrations/history-summary.js +0 -32
- package/lib/integrations/hosts/antigravity.d.ts +0 -4
- package/lib/integrations/hosts/antigravity.js +0 -79
- package/lib/integrations/hosts/claude.js +0 -60
- package/lib/services/history/history-service.d.ts +0 -106
- package/lib/services/history/history-service.js +0 -242
- package/lib/storage/acp-history.d.ts +0 -10
- package/lib/storage/acp-history.js +0 -57
- package/lib/ui/presentation.d.ts +0 -3
- package/lib/ui/presentation.js +0 -12
- package/src/extension/dsh/history.ts +0 -74
- package/src/extension/history.ts +0 -26
- package/src/extension/plugin-runtime.ts +0 -63
- package/src/integrations/dsh/history-summary.ts +0 -39
- package/src/integrations/dsh/history.ts +0 -84
- package/src/integrations/history-summary.ts +0 -30
- package/src/integrations/hosts/antigravity.ts +0 -83
- package/src/integrations/hosts/claude.ts +0 -62
- package/src/integrations/pi/history.ts +0 -99
- package/src/services/history/history-service.ts +0 -195
- package/src/storage/acp-history.ts +0 -49
- package/src/tools/access.ts +0 -7
- package/src/tools/history/tool.ts +0 -19
- package/src/tools/register.ts +0 -22
- package/src/ui/presentation.ts +0 -12
- /package/lib/{extension → antigravity-plugin/lib/extension/hosts}/dsh/acp-member.d.ts +0 -0
- /package/lib/{extension → antigravity-plugin/lib/extension/hosts}/dsh/files.d.ts +0 -0
- /package/lib/{integrations → antigravity-plugin/lib/integrations/hosts}/dsh/mcp.js +0 -0
- /package/lib/{integrations → antigravity-plugin/lib/integrations/hosts}/dsh/messages.d.ts +0 -0
- /package/lib/{integrations → antigravity-plugin/lib/integrations/hosts}/dsh/messages.js +0 -0
- /package/lib/{integrations → antigravity-plugin/lib/integrations/hosts}/dsh/root-agents.d.ts +0 -0
- /package/lib/{integrations → antigravity-plugin/lib/integrations/hosts}/dsh/root-agents.js +0 -0
- /package/lib/{integrations → antigravity-plugin/lib/integrations/hosts}/dsh/skills.d.ts +0 -0
- /package/lib/extension/{acp-worker.d.ts → acp/worker.d.ts} +0 -0
- /package/lib/extension/{setup-guard.js → setup/guard.js} +0 -0
- /package/lib/integrations/acp/{claude.d.ts → claude-settings.d.ts} +0 -0
- /package/lib/integrations/acp/{claude.js → claude-settings.js} +0 -0
- /package/lib/integrations/{dsh → hosts/dsh}/schema.d.ts +0 -0
- /package/src/extension/{setup-guard.ts → setup/guard.ts} +0 -0
- /package/src/integrations/acp/{claude.ts → claude-settings.ts} +0 -0
- /package/src/integrations/{dsh → hosts/dsh}/messages.ts +0 -0
- /package/src/integrations/{dsh → hosts/dsh}/root-agents.ts +0 -0
- /package/src/integrations/{pi → hosts/pi}/agent-tools.ts +0 -0
|
@@ -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
|
+
}
|
|
@@ -0,0 +1,384 @@
|
|
|
1
|
+
import { randomUUID } from "node:crypto";
|
|
2
|
+
import { dirname, join, resolve } from "node:path";
|
|
3
|
+
import { AgentFiles, descriptor, launch, status } from "../../storage/agent-files.js";
|
|
4
|
+
import { acpModelState, acpReference } from "../../storage/acp-files.js";
|
|
5
|
+
import { AcpAgentRun } from "../../services/agents/acp-run.js";
|
|
6
|
+
import { openAcp } from "../../integrations/acp/connection.js";
|
|
7
|
+
import { acpExecutable } from "../../integrations/acp/executable.js";
|
|
8
|
+
import { acpContent } from "../../integrations/acp/input.js";
|
|
9
|
+
import { toAcpMcpServers } from "../../integrations/acp/mcp.js";
|
|
10
|
+
import { resolveAcpHarness } from "../../integrations/acp/registry.js";
|
|
11
|
+
import { loadWorkspaceContext } from "../../integrations/agent-resources.js";
|
|
12
|
+
import { readWorkspaceConfig, workspaceFeatures } from "../../services/workspace/workspace-config.js";
|
|
13
|
+
import { readWorkspaceMcpConfig, resolveWorkspaceMcpServers } from "../../services/workspace/workspace-mcp.js";
|
|
14
|
+
import { discoverWorkspaceSkills } from "../../services/workspace/workspace-skills.js";
|
|
15
|
+
import { object } from "../../common/json.js";
|
|
16
|
+
import { resourceRoot } from "../../common/paths.js";
|
|
17
|
+
import { requireThat } from "../../common/validation.js";
|
|
18
|
+
import { packageVersion, releaseLine } from "../../common/version.js";
|
|
19
|
+
const errorMessage = (error) => error instanceof Error ? error.message : String(error);
|
|
20
|
+
function sendIpc(message) {
|
|
21
|
+
return new Promise(resolveSend => {
|
|
22
|
+
if (!process.connected || !process.send) {
|
|
23
|
+
resolveSend();
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
process.send(message, undefined, undefined, () => resolveSend());
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
function permissionDescription(request) {
|
|
30
|
+
const call = request.toolCall;
|
|
31
|
+
const detail = call.rawInput === undefined ? "" : JSON.stringify(call.rawInput);
|
|
32
|
+
return [call.title ?? "工具调用", call.kind ? "类型:" + call.kind : "", call.locations?.length ? "路径:" + call.locations.map(item => item.path).join(", ") : "",
|
|
33
|
+
detail ? "参数:" + (detail.length > 2000 ? detail.slice(0, 2000) + "…" : detail) : ""].filter(Boolean).join("\n");
|
|
34
|
+
}
|
|
35
|
+
async function runProbe() {
|
|
36
|
+
const lifetime = new AbortController();
|
|
37
|
+
const stop = () => lifetime.abort(new Error("ACP 模型探测已取消。"));
|
|
38
|
+
process.on("SIGTERM", stop);
|
|
39
|
+
process.on("SIGINT", stop);
|
|
40
|
+
try {
|
|
41
|
+
const payload = await new Promise((resolvePayload, rejectPayload) => {
|
|
42
|
+
const timer = setTimeout(() => rejectPayload(new Error("缺少 ACP 模型探测参数。")), 5000);
|
|
43
|
+
process.once("message", (value) => {
|
|
44
|
+
clearTimeout(timer);
|
|
45
|
+
if (!object(value)) {
|
|
46
|
+
rejectPayload(new Error("ACP 模型探测参数必须是对象。"));
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
resolvePayload(value);
|
|
50
|
+
});
|
|
51
|
+
process.once("disconnect", () => { clearTimeout(timer); rejectPayload(new Error("ACP 模型探测通道已断开。")); });
|
|
52
|
+
});
|
|
53
|
+
const reference = acpReference(payload.reference);
|
|
54
|
+
requireThat(typeof payload.cwd === "string" && payload.cwd.length > 0, "缺少 ACP 模型探测目录。");
|
|
55
|
+
const env = { ...process.env, ...(reference.env ?? {}) };
|
|
56
|
+
const connection = await openAcp(reference, payload.cwd, env, {
|
|
57
|
+
update() { },
|
|
58
|
+
async permission() { return { outcome: { outcome: "cancelled" } }; },
|
|
59
|
+
}, lifetime.signal);
|
|
60
|
+
try {
|
|
61
|
+
if (payload.model) {
|
|
62
|
+
await connection.configure({
|
|
63
|
+
...(payload.provider ? { provider: payload.provider } : {}),
|
|
64
|
+
model: payload.model,
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
await sendIpc({
|
|
68
|
+
type: "models",
|
|
69
|
+
result: {
|
|
70
|
+
backend: reference.backend,
|
|
71
|
+
...connection.choices(),
|
|
72
|
+
selection: connection.selection(),
|
|
73
|
+
},
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
finally {
|
|
77
|
+
await connection.close();
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
catch (error) {
|
|
81
|
+
await sendIpc({ type: "error", error: errorMessage(error) });
|
|
82
|
+
process.exitCode = 1;
|
|
83
|
+
}
|
|
84
|
+
finally {
|
|
85
|
+
lifetime.abort();
|
|
86
|
+
if (process.connected)
|
|
87
|
+
process.disconnect();
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
async function runWorker(args) {
|
|
91
|
+
const option = (name) => args[args.indexOf(name) + 1];
|
|
92
|
+
const directory = option("--directory"), id = option("--pbot-acp-agent"), generation = option("--generation");
|
|
93
|
+
requireThat(directory && id && generation, "缺少 ACP worker 启动信息。");
|
|
94
|
+
const files = new AgentFiles(dirname(directory));
|
|
95
|
+
requireThat(files.directory(id) === directory, "ACP worker 目录不匹配。");
|
|
96
|
+
const d = files.read(id, "descriptor.json", descriptor), reference = files.read(id, "acp-session.json", acpReference);
|
|
97
|
+
requireThat(d.agentId === id && releaseLine(d.release) === releaseLine(packageVersion), "ACP worker 身份或版本不匹配。");
|
|
98
|
+
const validating = args.includes("--validate"), lifetime = new AbortController();
|
|
99
|
+
let execution;
|
|
100
|
+
const stop = () => { void execution?.stop().catch(error => lifetime.abort(error)); if (!execution)
|
|
101
|
+
lifetime.abort(); };
|
|
102
|
+
process.on("SIGTERM", stop);
|
|
103
|
+
process.on("SIGINT", stop);
|
|
104
|
+
async function main() {
|
|
105
|
+
requireThat(files.read(id, "launch.json", launch).generation === generation, "ACP worker 启动代次已失效。");
|
|
106
|
+
const harness = resolveAcpHarness(reference.backend);
|
|
107
|
+
const exactAnswer = Boolean(harness.exactAnswer);
|
|
108
|
+
const packageRoot = resolve(resourceRoot, "..");
|
|
109
|
+
const configuration = await readWorkspaceConfig(d.workspace);
|
|
110
|
+
const features = workspaceFeatures(configuration);
|
|
111
|
+
const baseEnv = {
|
|
112
|
+
...process.env,
|
|
113
|
+
PBOT_SUBAGENT_RUN_ID: id,
|
|
114
|
+
PBOT_SUBAGENT_DIR: directory,
|
|
115
|
+
PBOT_SUBAGENT_GENERATION: generation,
|
|
116
|
+
...(validating ? { PBOT_ACP_VALIDATE: "1" } : {}),
|
|
117
|
+
};
|
|
118
|
+
const prepared = harness.prepareLaunch
|
|
119
|
+
? await harness.prepareLaunch({ reference, cwd: d.cwd, directory: directory, packageRoot, options: d.options, env: baseEnv, features })
|
|
120
|
+
: { command: { ...reference, args: [...reference.args] }, env: { ...baseEnv, ...(reference.env ?? {}) } };
|
|
121
|
+
let prompt;
|
|
122
|
+
if (!exactAnswer) {
|
|
123
|
+
const workspaceSkills = features.skills && !harness.nativeWorkspaceSkills && !d.options.noSkills
|
|
124
|
+
? await discoverWorkspaceSkills(d.workspace)
|
|
125
|
+
: [];
|
|
126
|
+
if (features.prompts || workspaceSkills.length > 0) {
|
|
127
|
+
prompt = (await loadWorkspaceContext({
|
|
128
|
+
host: reference.backend,
|
|
129
|
+
root: d.workspace,
|
|
130
|
+
role: "general-purpose",
|
|
131
|
+
includePrompts: features.prompts,
|
|
132
|
+
workspaceSkills,
|
|
133
|
+
})).text;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
let mcpServers;
|
|
137
|
+
if (features.mcp && !harness.nativeWorkspaceMcp && !validating) {
|
|
138
|
+
const mcpConfig = await readWorkspaceMcpConfig(d.workspace);
|
|
139
|
+
if (mcpConfig.present) {
|
|
140
|
+
const resolved = resolveWorkspaceMcpServers(d.workspace, mcpConfig, prepared.env);
|
|
141
|
+
if (resolved.length)
|
|
142
|
+
mcpServers = toAcpMcpServers(resolved);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
// Only publish acp-model.json after requested model/thinking options are applied so callers can detect startup readiness.
|
|
146
|
+
let configured = false;
|
|
147
|
+
const saveSelection = (selection) => {
|
|
148
|
+
if (validating || !configured)
|
|
149
|
+
return;
|
|
150
|
+
const run = files.read(id, "launch.json", launch);
|
|
151
|
+
if (run.generation === generation && !run.stop)
|
|
152
|
+
files.write(id, "acp-model.json", { generation, ...selection }, acpModelState);
|
|
153
|
+
};
|
|
154
|
+
const connection = await openAcp(prepared.command, d.cwd, prepared.env, {
|
|
155
|
+
selection: saveSelection,
|
|
156
|
+
update(update) {
|
|
157
|
+
if (update.sessionUpdate === "agent_message_chunk" && update.content.type === "text") {
|
|
158
|
+
execution?.update({ kind: "text", text: update.content.text, ...(update.messageId ? { messageId: update.messageId } : {}) });
|
|
159
|
+
}
|
|
160
|
+
else if (update.sessionUpdate === "agent_thought_chunk") {
|
|
161
|
+
execution?.update({ kind: "thought" });
|
|
162
|
+
}
|
|
163
|
+
else if (update.sessionUpdate === "tool_call" || update.sessionUpdate === "tool_call_update") {
|
|
164
|
+
execution?.update({ kind: update.sessionUpdate === "tool_call" ? "tool" : "activity", activity: update.name ?? update.title ?? "工具" });
|
|
165
|
+
}
|
|
166
|
+
},
|
|
167
|
+
async permission(request, signal) {
|
|
168
|
+
if (!execution)
|
|
169
|
+
return { outcome: { outcome: "cancelled" } };
|
|
170
|
+
const policy = reference.permission ?? "ask";
|
|
171
|
+
const pick = (...kinds) => kinds.map(kind => request.options.find(item => item.kind === kind)).find(Boolean)?.optionId;
|
|
172
|
+
// ask forwards the request to the parent session; allow/deny follow the workspace's explicit configuration.
|
|
173
|
+
const optionId = policy === "allow" ? pick("allow_once", "allow_always")
|
|
174
|
+
: policy === "deny" ? pick("reject_once", "reject_always")
|
|
175
|
+
: await execution.permission(permissionDescription(request), request.options.map(({ optionId, name, kind }) => ({ optionId, name, kind })), signal);
|
|
176
|
+
return optionId ? { outcome: { outcome: "selected", optionId } } : { outcome: { outcome: "cancelled" } };
|
|
177
|
+
},
|
|
178
|
+
async elicitation(request, signal) {
|
|
179
|
+
if (!execution)
|
|
180
|
+
return { action: "cancel" };
|
|
181
|
+
if (request.mode === "form") {
|
|
182
|
+
const schema = "requestedSchema" in request && object(request.requestedSchema)
|
|
183
|
+
? request.requestedSchema
|
|
184
|
+
: { type: "object", properties: {} };
|
|
185
|
+
const reply = await execution.elicitation({ mode: "form", message: request.message, schema }, signal);
|
|
186
|
+
if (reply.action === "accept")
|
|
187
|
+
return { action: "accept", content: reply.content ?? {} };
|
|
188
|
+
return reply.action === "decline" ? { action: "decline" } : { action: "cancel" };
|
|
189
|
+
}
|
|
190
|
+
if (request.mode === "url" && "url" in request && typeof request.url === "string" && request.url.length > 0) {
|
|
191
|
+
const reply = await execution.elicitation({ mode: "url", message: request.message, url: request.url }, signal);
|
|
192
|
+
if (reply.action === "accept")
|
|
193
|
+
return { action: "accept" };
|
|
194
|
+
return reply.action === "decline" ? { action: "decline" } : { action: "cancel" };
|
|
195
|
+
}
|
|
196
|
+
return { action: "decline" };
|
|
197
|
+
},
|
|
198
|
+
}, lifetime.signal, {
|
|
199
|
+
harness,
|
|
200
|
+
...(prompt ? { systemPrompt: prompt } : {}),
|
|
201
|
+
...(prepared.sessionMeta ? { sessionMeta: prepared.sessionMeta } : {}),
|
|
202
|
+
...(prepared.defaultThinking ? { defaultThinking: prepared.defaultThinking } : {}),
|
|
203
|
+
...(mcpServers ? { mcpServers } : {}),
|
|
204
|
+
});
|
|
205
|
+
try {
|
|
206
|
+
requireThat(!prompt || !harness.requireSystemPrompt || connection.systemPrompt, `${reference.backend} ACP 后端需要支持 systemPrompt,以加载专家职责与工作区资料。`);
|
|
207
|
+
if (validating) {
|
|
208
|
+
await sendIpc({ type: "validated" });
|
|
209
|
+
return;
|
|
210
|
+
}
|
|
211
|
+
if (reference.sessionId === null)
|
|
212
|
+
await connection.configure(d.options);
|
|
213
|
+
requireThat(files.read(id, "launch.json", launch).generation === generation && !files.read(id, "launch.json", launch).stop, "ACP 启动已取消。");
|
|
214
|
+
files.write(id, "acp-session.json", {
|
|
215
|
+
...reference,
|
|
216
|
+
sessionId: harness.eagerSessionId || reference.sessionId !== null ? connection.sessionId : null,
|
|
217
|
+
capabilities: connection.capabilities,
|
|
218
|
+
}, acpReference);
|
|
219
|
+
configured = true;
|
|
220
|
+
saveSelection(connection.selection());
|
|
221
|
+
let promptInjected = reference.sessionId !== null || connection.systemPrompt;
|
|
222
|
+
execution = new AcpAgentRun(files, d, generation, {
|
|
223
|
+
signal: connection.signal,
|
|
224
|
+
async prompt(request) {
|
|
225
|
+
const effective = !exactAnswer && prompt && !promptInjected
|
|
226
|
+
? { ...request, message: prompt + "\n\n---\n\n" + request.message }
|
|
227
|
+
: request;
|
|
228
|
+
promptInjected = true;
|
|
229
|
+
const content = await acpContent(effective, connection.images, connection.signal);
|
|
230
|
+
const run = files.read(id, "launch.json", launch);
|
|
231
|
+
requireThat(run.generation === generation && !run.stop, "ACP 输入已取消或启动代次变化。");
|
|
232
|
+
connection.signal.throwIfAborted();
|
|
233
|
+
const saved = files.read(id, "acp-session.json", acpReference);
|
|
234
|
+
if (saved.sessionId === null)
|
|
235
|
+
files.write(id, "acp-session.json", { ...saved, sessionId: connection.sessionId }, acpReference);
|
|
236
|
+
return connection.prompt(content);
|
|
237
|
+
},
|
|
238
|
+
cancel: () => connection.cancel(),
|
|
239
|
+
}, exactAnswer);
|
|
240
|
+
await execution.run();
|
|
241
|
+
}
|
|
242
|
+
finally {
|
|
243
|
+
try {
|
|
244
|
+
await connection.close();
|
|
245
|
+
}
|
|
246
|
+
finally {
|
|
247
|
+
await execution?.settled();
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
try {
|
|
252
|
+
await main();
|
|
253
|
+
if (!validating && files.read(id, "launch.json", launch).generation === generation) {
|
|
254
|
+
if (execution)
|
|
255
|
+
execution.execution.save({ state: "stopped", activity: "已停止" });
|
|
256
|
+
else
|
|
257
|
+
files.write(id, "status.json", { generation, state: "stopped", activity: "已停止", updatedAt: Date.now() }, status);
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
catch (error) {
|
|
261
|
+
if (validating) {
|
|
262
|
+
await sendIpc({ type: "error", error: errorMessage(error) });
|
|
263
|
+
}
|
|
264
|
+
else if (files.read(id, "launch.json", launch).generation === generation) {
|
|
265
|
+
const stopped = files.read(id, "launch.json", launch).stop;
|
|
266
|
+
const patch = { state: stopped ? "stopped" : "error", activity: stopped ? "已停止" : "ACP 执行失败", ...(stopped ? {} : { error: errorMessage(error) }) };
|
|
267
|
+
if (execution)
|
|
268
|
+
execution.execution.save(patch);
|
|
269
|
+
else
|
|
270
|
+
files.write(id, "status.json", { generation, ...patch, updatedAt: Date.now() }, status);
|
|
271
|
+
}
|
|
272
|
+
process.exitCode = 1;
|
|
273
|
+
}
|
|
274
|
+
finally {
|
|
275
|
+
lifetime.abort();
|
|
276
|
+
if (process.connected)
|
|
277
|
+
process.disconnect();
|
|
278
|
+
// Keep child processes in this worker's process group so forced release covers descendants.
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
async function runOneShotPrompt() {
|
|
282
|
+
const lifetime = new AbortController();
|
|
283
|
+
const stop = () => lifetime.abort(new Error("ACP 摘要任务已取消。"));
|
|
284
|
+
process.on("SIGTERM", stop);
|
|
285
|
+
process.on("SIGINT", stop);
|
|
286
|
+
try {
|
|
287
|
+
const payload = await new Promise((resolvePayload, rejectPayload) => {
|
|
288
|
+
const timer = setTimeout(() => rejectPayload(new Error("缺少 ACP 摘要任务参数。")), 5000);
|
|
289
|
+
process.once("message", (value) => {
|
|
290
|
+
clearTimeout(timer);
|
|
291
|
+
if (!object(value)) {
|
|
292
|
+
rejectPayload(new Error("ACP 摘要任务参数必须是对象。"));
|
|
293
|
+
return;
|
|
294
|
+
}
|
|
295
|
+
resolvePayload(value);
|
|
296
|
+
});
|
|
297
|
+
process.once("disconnect", () => { clearTimeout(timer); rejectPayload(new Error("ACP 摘要任务通道已断开。")); });
|
|
298
|
+
});
|
|
299
|
+
const reference = acpReference(payload.reference);
|
|
300
|
+
requireThat(typeof payload.cwd === "string" && payload.cwd.length > 0, "缺少 ACP 摘要工作目录。");
|
|
301
|
+
requireThat(typeof payload.prompt === "string" && payload.prompt.trim().length > 0, "缺少 ACP 摘要输入内容。");
|
|
302
|
+
const harness = resolveAcpHarness(reference.backend);
|
|
303
|
+
const packageRoot = resolve(resourceRoot, "..");
|
|
304
|
+
// Mark as managed subagent so no host (Pi, dsh, Claude, Antigravity) ever records raw history for summary runs.
|
|
305
|
+
const env = {
|
|
306
|
+
...process.env,
|
|
307
|
+
...(reference.env ?? {}),
|
|
308
|
+
PBOT_SUBAGENT_RUN_ID: "pbot-summary-" + randomUUID(),
|
|
309
|
+
...(reference.backend === "pi" ? {
|
|
310
|
+
PBOT_SUMMARY_WORKER: "1",
|
|
311
|
+
PI_OFFLINE: "1",
|
|
312
|
+
PBOT_ACP_PI_COMMAND: process.env.PI_ACP_PI_COMMAND ?? acpExecutable("pi", "pi"),
|
|
313
|
+
PI_ACP_PI_COMMAND: join(packageRoot, "bin/pbot-pi-acp.mjs"),
|
|
314
|
+
} : {}),
|
|
315
|
+
};
|
|
316
|
+
let collecting = false;
|
|
317
|
+
let text = "";
|
|
318
|
+
const connection = await openAcp(reference, payload.cwd, env, {
|
|
319
|
+
update(update) {
|
|
320
|
+
if (collecting && update.sessionUpdate === "agent_message_chunk" && update.content.type === "text") {
|
|
321
|
+
text += update.content.text;
|
|
322
|
+
}
|
|
323
|
+
},
|
|
324
|
+
async permission() {
|
|
325
|
+
return { outcome: { outcome: "cancelled" } };
|
|
326
|
+
},
|
|
327
|
+
}, lifetime.signal, {
|
|
328
|
+
harness,
|
|
329
|
+
...(payload.system ? { systemPrompt: payload.system } : {}),
|
|
330
|
+
});
|
|
331
|
+
try {
|
|
332
|
+
if (payload.model || payload.thinking) {
|
|
333
|
+
const parsedModel = payload.model
|
|
334
|
+
? (harness.parseModelValue ? harness.parseModelValue(payload.model) : { model: payload.model })
|
|
335
|
+
: undefined;
|
|
336
|
+
await connection.configure({
|
|
337
|
+
...(parsedModel?.provider ? { provider: parsedModel.provider } : {}),
|
|
338
|
+
...(parsedModel?.model ? { model: parsedModel.model } : {}),
|
|
339
|
+
...(payload.thinking ? { thinking: payload.thinking } : {}),
|
|
340
|
+
});
|
|
341
|
+
}
|
|
342
|
+
const promptText = !connection.systemPrompt && payload.system
|
|
343
|
+
? `${payload.system}\n\n---\n\n${payload.prompt}`
|
|
344
|
+
: payload.prompt;
|
|
345
|
+
collecting = true;
|
|
346
|
+
await connection.prompt([{ type: "text", text: promptText }]);
|
|
347
|
+
let cleaned = text;
|
|
348
|
+
if (connection.startupInfo) {
|
|
349
|
+
if (cleaned.startsWith(connection.startupInfo)) {
|
|
350
|
+
cleaned = cleaned.slice(connection.startupInfo.length);
|
|
351
|
+
}
|
|
352
|
+
else {
|
|
353
|
+
const trimmedInfo = connection.startupInfo.trim();
|
|
354
|
+
const trimmedText = cleaned.trimStart();
|
|
355
|
+
if (trimmedInfo && trimmedText.startsWith(trimmedInfo)) {
|
|
356
|
+
cleaned = trimmedText.slice(trimmedInfo.length);
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
const answer = cleaned.trim();
|
|
361
|
+
requireThat(answer.length > 0, "ACP 摘要返回为空。");
|
|
362
|
+
await sendIpc({ type: "answer", text: answer });
|
|
363
|
+
}
|
|
364
|
+
finally {
|
|
365
|
+
await connection.close();
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
catch (error) {
|
|
369
|
+
await sendIpc({ type: "error", error: errorMessage(error) });
|
|
370
|
+
process.exitCode = 1;
|
|
371
|
+
}
|
|
372
|
+
finally {
|
|
373
|
+
lifetime.abort();
|
|
374
|
+
if (process.connected)
|
|
375
|
+
process.disconnect();
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
const args = process.argv.slice(2);
|
|
379
|
+
if (args.includes("--probe"))
|
|
380
|
+
await runProbe();
|
|
381
|
+
else if (args.includes("--prompt"))
|
|
382
|
+
await runOneShotPrompt();
|
|
383
|
+
else
|
|
384
|
+
await runWorker(args);
|