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
package/src/model/history.ts
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
import type { HistoryLayout } from "./workspace-config.js";
|
|
2
|
+
|
|
3
|
+
export type { HistoryLayout };
|
|
4
|
+
export type HistoryHost = string;
|
|
5
|
+
|
|
1
6
|
export interface HistoryExchange {
|
|
2
7
|
entryIds: string[];
|
|
3
8
|
text: string;
|
|
@@ -5,6 +10,7 @@ export interface HistoryExchange {
|
|
|
5
10
|
to: string;
|
|
6
11
|
completed: boolean;
|
|
7
12
|
}
|
|
13
|
+
|
|
8
14
|
export interface HistorySession {
|
|
9
15
|
sessionId: string;
|
|
10
16
|
name: string;
|
|
@@ -12,48 +18,172 @@ export interface HistorySession {
|
|
|
12
18
|
/** Earlier partial observations replaced along the same native branch or turn; never persisted. */
|
|
13
19
|
supersededEntryIds?: string[];
|
|
14
20
|
}
|
|
21
|
+
|
|
15
22
|
export interface HistoryIdentity {
|
|
16
23
|
host: HistoryHost;
|
|
17
24
|
id: string;
|
|
18
25
|
sessionId: string;
|
|
19
26
|
}
|
|
27
|
+
|
|
20
28
|
export interface RawHistory extends HistoryIdentity {
|
|
21
29
|
name: string;
|
|
22
30
|
/** One entry per archived exchange; array order does not describe a conversation. */
|
|
23
31
|
exchanges: (HistoryExchange & { id: string })[];
|
|
24
|
-
/** Ordered paths observed in the native source.
|
|
32
|
+
/** Ordered paths observed in the native source. */
|
|
25
33
|
branches: string[][];
|
|
26
34
|
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
}
|
|
33
|
-
export interface HistoryArchive {
|
|
34
|
-
raw: RawHistory;
|
|
35
|
-
/** Empty if absent; null if the derived file is unreadable. */
|
|
36
|
-
summaries: HistorySummary[] | null;
|
|
37
|
-
}
|
|
38
|
-
export interface HistoryNode extends HistorySummary {
|
|
39
|
-
kind: "session" | "exchange" | "summary";
|
|
40
|
-
parents: string[];
|
|
41
|
-
}
|
|
42
|
-
/** Query view and legacy on-disk format. New writers persist raw exchanges and summaries separately. */
|
|
43
|
-
export interface HistoryRecord extends HistoryIdentity {
|
|
44
|
-
name: string;
|
|
45
|
-
nodes: HistoryNode[];
|
|
35
|
+
|
|
36
|
+
export interface SummarySource {
|
|
37
|
+
rawIds: string[];
|
|
38
|
+
exchangeIds: string[];
|
|
39
|
+
fingerprint: string;
|
|
46
40
|
}
|
|
47
|
-
|
|
48
|
-
export
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
41
|
+
|
|
42
|
+
export interface SummaryArtifact {
|
|
43
|
+
id: string;
|
|
44
|
+
dimension: string;
|
|
45
|
+
host?: HistoryHost;
|
|
46
|
+
sessionId?: string;
|
|
47
|
+
title: string;
|
|
48
|
+
text: string;
|
|
49
|
+
from: string;
|
|
50
|
+
to: string;
|
|
51
|
+
updatedAt: string;
|
|
52
|
+
source: SummarySource;
|
|
53
53
|
}
|
|
54
|
+
|
|
54
55
|
export interface HistorySummaryRequest {
|
|
55
56
|
system: string;
|
|
56
57
|
prompt: string;
|
|
57
58
|
maxTokens: number;
|
|
58
59
|
}
|
|
60
|
+
|
|
59
61
|
export type HistorySummarizer = (request: HistorySummaryRequest, signal: AbortSignal) => Promise<string>;
|
|
62
|
+
|
|
63
|
+
export type SummaryTaskMode = "create" | "incremental" | "rebuild";
|
|
64
|
+
|
|
65
|
+
export interface SummaryTask {
|
|
66
|
+
id: string;
|
|
67
|
+
dimension: string;
|
|
68
|
+
mode: SummaryTaskMode;
|
|
69
|
+
title: string;
|
|
70
|
+
host?: HistoryHost;
|
|
71
|
+
sessionId?: string;
|
|
72
|
+
from: string;
|
|
73
|
+
to: string;
|
|
74
|
+
source: SummarySource;
|
|
75
|
+
exchanges: readonly (HistoryExchange & { id: string })[];
|
|
76
|
+
existing?: SummaryArtifact;
|
|
77
|
+
addedExchanges?: readonly (HistoryExchange & { id: string })[];
|
|
78
|
+
sourceSummaries?: readonly SummaryArtifact[];
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export interface SummaryPlanOptions {
|
|
82
|
+
force?: boolean;
|
|
83
|
+
summariesByDimension?: ReadonlyMap<string, ReadonlyMap<string, SummaryArtifact>>;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export interface SummaryPlanResult {
|
|
87
|
+
tasks: SummaryTask[];
|
|
88
|
+
skipped: number;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
export interface SummaryDimension {
|
|
92
|
+
readonly id: string;
|
|
93
|
+
readonly title: string;
|
|
94
|
+
readonly description: string;
|
|
95
|
+
readonly requiresMonthlyLayout?: boolean;
|
|
96
|
+
plan(
|
|
97
|
+
raws: readonly RawHistory[],
|
|
98
|
+
existing: ReadonlyMap<string, SummaryArtifact>,
|
|
99
|
+
options?: SummaryPlanOptions,
|
|
100
|
+
): SummaryPlanResult;
|
|
101
|
+
buildRequest(task: SummaryTask): HistorySummaryRequest;
|
|
102
|
+
finalize(task: SummaryTask, output: string, now: string): SummaryArtifact;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
export interface HistoryMigrationItem {
|
|
106
|
+
kind: "raw" | "summary";
|
|
107
|
+
dimension?: string;
|
|
108
|
+
id: string;
|
|
109
|
+
from: string;
|
|
110
|
+
to: string;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
export interface HistoryMigrationConflict {
|
|
114
|
+
kind: "raw" | "summary";
|
|
115
|
+
dimension?: string;
|
|
116
|
+
from: string;
|
|
117
|
+
to: string;
|
|
118
|
+
reason: string;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
export interface HistoryMigrationReport {
|
|
122
|
+
layout: HistoryLayout;
|
|
123
|
+
dryRun: boolean;
|
|
124
|
+
moved: HistoryMigrationItem[];
|
|
125
|
+
skipped: HistoryMigrationConflict[];
|
|
126
|
+
errors: { path: string; error: string }[];
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
export interface SummaryDimensionStatus {
|
|
130
|
+
dimension: string;
|
|
131
|
+
title: string;
|
|
132
|
+
description: string;
|
|
133
|
+
total: number;
|
|
134
|
+
ready: number;
|
|
135
|
+
pendingCreate: number;
|
|
136
|
+
pendingIncremental: number;
|
|
137
|
+
pendingRebuild: number;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
export interface HistorySummaryReminder {
|
|
141
|
+
rawCount: number;
|
|
142
|
+
pendingCount: number;
|
|
143
|
+
oldestRawAt: string;
|
|
144
|
+
latestSummaryAt?: string;
|
|
145
|
+
rawAgeDays: number;
|
|
146
|
+
daysSinceLastSummary?: number;
|
|
147
|
+
thresholdDays: number;
|
|
148
|
+
message: string;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
export interface SummaryRunProgress {
|
|
152
|
+
dimension: string;
|
|
153
|
+
completed: number;
|
|
154
|
+
total: number;
|
|
155
|
+
currentId: string;
|
|
156
|
+
mode: SummaryTaskMode;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
export interface SummaryDimensionReport {
|
|
160
|
+
dimension: string;
|
|
161
|
+
scanned: number;
|
|
162
|
+
skipped: number;
|
|
163
|
+
created: number;
|
|
164
|
+
incremental: number;
|
|
165
|
+
rebuilt: number;
|
|
166
|
+
failed: { id: string; error: string }[];
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
export interface SummaryRunReport {
|
|
170
|
+
dimensions: SummaryDimensionReport[];
|
|
171
|
+
durationMs: number;
|
|
172
|
+
warnings: string[];
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
export const historyPageLimits = {
|
|
176
|
+
search: { default: 20, max: 50 },
|
|
177
|
+
read: { default: 12_000, max: 24_000 },
|
|
178
|
+
} as const;
|
|
179
|
+
|
|
180
|
+
export interface HistoryQuery {
|
|
181
|
+
host?: HistoryHost;
|
|
182
|
+
query?: string;
|
|
183
|
+
sessionId?: string;
|
|
184
|
+
dimension?: string;
|
|
185
|
+
from?: string;
|
|
186
|
+
to?: string;
|
|
187
|
+
offset?: number;
|
|
188
|
+
limit?: number;
|
|
189
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
export interface PluginSpec {
|
|
2
|
+
id: string;
|
|
3
|
+
label: string;
|
|
4
|
+
description: string;
|
|
5
|
+
source: string;
|
|
6
|
+
defaultSelected: boolean;
|
|
7
|
+
}
|
|
8
|
+
export interface InstalledPackage {
|
|
9
|
+
source: string;
|
|
10
|
+
scope: "user" | "project";
|
|
11
|
+
name?: string;
|
|
12
|
+
version?: string;
|
|
13
|
+
installedPath?: string;
|
|
14
|
+
filtered: boolean;
|
|
15
|
+
entry: unknown;
|
|
16
|
+
}
|
|
17
|
+
export interface PackageChoice {
|
|
18
|
+
plugin: PluginSpec;
|
|
19
|
+
required: boolean;
|
|
20
|
+
existing: InstalledPackage[];
|
|
21
|
+
selected: boolean;
|
|
22
|
+
keep: boolean;
|
|
23
|
+
target?: string;
|
|
24
|
+
error?: string;
|
|
25
|
+
}
|
|
26
|
+
export interface PiInstallation { command: string; root: string; version: string }
|
|
27
|
+
export interface SystemCommand { command: string; args: string[] }
|
|
28
|
+
export interface SetupPlan {
|
|
29
|
+
workspace: string;
|
|
30
|
+
pi?: PiInstallation;
|
|
31
|
+
piVersion: string;
|
|
32
|
+
tmux?: SystemCommand;
|
|
33
|
+
packages: PackageChoice[];
|
|
34
|
+
}
|
|
35
|
+
export interface SetupResult { name: string; state: "done" | "kept" | "skipped" | "failed"; detail: string }
|
|
36
|
+
export interface SetupOperations {
|
|
37
|
+
installTmux(command: SystemCommand): Promise<void>;
|
|
38
|
+
ensurePi(existing: PiInstallation | undefined, version: string): Promise<PiInstallation>;
|
|
39
|
+
installPackage(pi: PiInstallation, workspace: string, choice: PackageChoice): Promise<string>;
|
|
40
|
+
verifyKeptPackage(pi: PiInstallation, workspace: string, choice: PackageChoice): Promise<string>;
|
|
41
|
+
}
|
package/src/model/plugin-host.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { HistorySession } from "./history.js";
|
|
1
2
|
import type { WorkspaceSkillMeta } from "./workspace-mcp.js";
|
|
2
3
|
|
|
3
4
|
export type HostId = string;
|
|
@@ -19,20 +20,47 @@ export interface WorkspaceContext {
|
|
|
19
20
|
text: string;
|
|
20
21
|
}
|
|
21
22
|
|
|
23
|
+
export type HistoryCapture =
|
|
24
|
+
| {
|
|
25
|
+
kind: "input";
|
|
26
|
+
sessionId: string;
|
|
27
|
+
turnId?: string;
|
|
28
|
+
text: string;
|
|
29
|
+
timestamp?: string;
|
|
30
|
+
}
|
|
31
|
+
| {
|
|
32
|
+
kind: "answer";
|
|
33
|
+
sessionId: string;
|
|
34
|
+
turnId?: string;
|
|
35
|
+
userText?: string;
|
|
36
|
+
assistantText: string;
|
|
37
|
+
completed: boolean;
|
|
38
|
+
isContinuation?: boolean;
|
|
39
|
+
timestamp?: string;
|
|
40
|
+
}
|
|
41
|
+
| {
|
|
42
|
+
kind: "session";
|
|
43
|
+
session: HistorySession;
|
|
44
|
+
};
|
|
45
|
+
|
|
22
46
|
export type HostEvent =
|
|
23
47
|
| { kind: "ignore" }
|
|
24
|
-
| { kind: "inject-context"; role: WorkspaceRole; localRoleOnly?: boolean; cwd: string; raw: unknown }
|
|
25
|
-
| { kind: "check-skill"; skill: string; cwd: string; raw: unknown }
|
|
48
|
+
| { kind: "inject-context"; role: WorkspaceRole; localRoleOnly?: boolean; isSessionStart?: boolean; noticesOnly?: boolean; cwd: string; raw: unknown }
|
|
49
|
+
| { kind: "check-skill"; skill: string; cwd: string; raw: unknown }
|
|
50
|
+
| { kind: "record-history"; cwd: string; raw: unknown };
|
|
26
51
|
|
|
27
52
|
export interface PluginHostAdapter {
|
|
28
53
|
readonly host: PluginHostId;
|
|
29
54
|
readonly nativeRootAgents: boolean;
|
|
55
|
+
readonly indexBundledSkills?: boolean;
|
|
30
56
|
readonly nativeWorkspaceSkills?: boolean;
|
|
31
57
|
readonly coordinatorPrompt?: string;
|
|
32
58
|
readonly initCommandHint: string;
|
|
33
59
|
readonly usage: string;
|
|
60
|
+
boundWorkspaceRoot?(): string | undefined;
|
|
34
61
|
resolveRoot(cwd: string, rawPayload?: unknown): Promise<string>;
|
|
35
62
|
parseEvent(payload: unknown): HostEvent;
|
|
63
|
+
extractHistory?(event: Extract<HostEvent, { kind: "inject-context" | "record-history" }>): Promise<HistoryCapture | undefined>;
|
|
36
64
|
formatPass(payload: unknown): Record<string, unknown>;
|
|
37
65
|
formatContext(event: Extract<HostEvent, { kind: "inject-context" }>, context: WorkspaceContext): Record<string, unknown>;
|
|
38
66
|
formatDeny(event: Extract<HostEvent, { kind: "check-skill" }>, reason: string): Record<string, unknown>;
|
|
@@ -4,25 +4,49 @@ export interface WorkspaceFeatures {
|
|
|
4
4
|
prompts?: boolean;
|
|
5
5
|
skills?: boolean;
|
|
6
6
|
mcp?: boolean;
|
|
7
|
+
history?: boolean;
|
|
7
8
|
}
|
|
8
9
|
|
|
9
|
-
export
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
export type ResolvedWorkspaceFeatures = Readonly<Required<WorkspaceFeatures>>;
|
|
11
|
+
|
|
12
|
+
export const summaryConcurrency = { default: 3, max: 8 } as const;
|
|
13
|
+
|
|
14
|
+
export interface WorkspaceSummaryConfig {
|
|
15
|
+
backend?: string;
|
|
16
|
+
model?: string;
|
|
17
|
+
thinking?: string;
|
|
18
|
+
concurrency?: number;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export interface ResolvedWorkspaceSummaryConfig {
|
|
22
|
+
readonly backend: string;
|
|
23
|
+
readonly model?: string;
|
|
24
|
+
readonly thinking?: string;
|
|
25
|
+
readonly concurrency: number;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export const historyLayouts = ["monthly", "flat"] as const;
|
|
29
|
+
export type HistoryLayout = typeof historyLayouts[number];
|
|
30
|
+
|
|
31
|
+
export interface WorkspaceHistoryConfig {
|
|
32
|
+
layout?: HistoryLayout;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export interface ResolvedWorkspaceHistoryConfig {
|
|
36
|
+
readonly layout: HistoryLayout;
|
|
13
37
|
}
|
|
14
38
|
|
|
15
39
|
export interface WorkspaceConfig {
|
|
16
40
|
enabled?: boolean;
|
|
17
41
|
features?: WorkspaceFeatures;
|
|
18
42
|
acp?: AcpCommands;
|
|
43
|
+
summary?: WorkspaceSummaryConfig;
|
|
44
|
+
history?: WorkspaceHistoryConfig;
|
|
19
45
|
}
|
|
20
46
|
|
|
21
|
-
export interface WorkspaceConfiguration {
|
|
47
|
+
export interface WorkspaceConfiguration extends WorkspaceConfig {
|
|
22
48
|
path: string;
|
|
23
49
|
present: boolean;
|
|
24
50
|
enabled: boolean;
|
|
25
51
|
error?: string;
|
|
26
|
-
features?: WorkspaceFeatures;
|
|
27
|
-
acp?: AcpCommands;
|
|
28
52
|
}
|
package/src/pbot.ts
CHANGED
|
@@ -1,21 +1,14 @@
|
|
|
1
|
-
import { existsSync } from "node:fs";
|
|
2
|
-
import { join, resolve } from "node:path";
|
|
3
1
|
import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import { McpWorkerRuntime, defaultWorkerDirectory } from "./extension/mcp-workers.js";
|
|
12
|
-
import { HistoryService } from "./services/history/history-service.js";
|
|
2
|
+
import { Confirmations } from "./ui/pi/confirmation.js";
|
|
3
|
+
import { registerPiHistoryTool } from "./tools/history/pi-tool.js";
|
|
4
|
+
import { Lifecycle, WorkspaceInstance } from "./extension/hosts/pi/lifecycle.js";
|
|
5
|
+
import { registerCommand } from "./extension/hosts/pi/command.js";
|
|
6
|
+
import { registerEvents } from "./extension/hosts/pi/events.js";
|
|
7
|
+
import { registerHistoryEvents } from "./extension/hosts/pi/history.js";
|
|
8
|
+
import { McpWorkerRuntime, defaultWorkerDirectory } from "./extension/mcp/workers.js";
|
|
13
9
|
import { workspaceFeatures } from "./services/workspace/workspace-config.js";
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import { PiHistory } from "./integrations/pi/history.js";
|
|
17
|
-
import { toPiMcpConfig } from "./integrations/pi/mcp.js";
|
|
18
|
-
import { acpHistorySessions } from "./storage/acp-history.js";
|
|
10
|
+
import { loadNativeWorkspaceServers } from "./extension/hosts/workspace-mcp.js";
|
|
11
|
+
import { toPiMcpConfig } from "./integrations/hosts/pi/mcp.js";
|
|
19
12
|
|
|
20
13
|
const mcpServerName = "pbot";
|
|
21
14
|
|
|
@@ -23,59 +16,38 @@ export default function pbot(pi: ExtensionAPI) {
|
|
|
23
16
|
// The explicitly loaded child entry owns the child; normal discovery never grants main privileges.
|
|
24
17
|
if (process.env.PBOT_SUBAGENT_RUN_ID) return;
|
|
25
18
|
const confirmations = new Confirmations();
|
|
26
|
-
|
|
27
|
-
const mcpEntry = resolve(resourceRoot, "../lib/extension/mcp.js");
|
|
19
|
+
let hideHistory: (() => void) | undefined;
|
|
28
20
|
const registeredMcpServers: string[] = [];
|
|
29
21
|
|
|
30
22
|
const lifecycle = new Lifecycle(
|
|
31
23
|
(root, sessionId, configuration) => {
|
|
32
24
|
const workerDir = defaultWorkerDirectory();
|
|
33
25
|
const workers = new McpWorkerRuntime(workerDir, sessionId, "pi");
|
|
34
|
-
|
|
35
|
-
root,
|
|
36
|
-
new HistoryFiles(join(root, ".pbot/history"), "pi"),
|
|
37
|
-
new PiHistory(root),
|
|
38
|
-
[new HistoryFiles(join(root, ".pbot/history"), "dsh"), new HistoryFiles(join(root, ".pbot/history"), "claude")],
|
|
39
|
-
() => acpHistorySessions({ mcp: workerDir }),
|
|
40
|
-
);
|
|
41
|
-
return new WorkspaceInstance(root, sessionId, history, workers, workspaceFeatures(configuration));
|
|
26
|
+
return new WorkspaceInstance(root, sessionId, workers, workspaceFeatures(configuration));
|
|
42
27
|
},
|
|
43
28
|
async instance => {
|
|
44
|
-
|
|
45
|
-
|
|
29
|
+
if (instance.features.history) hideHistory = registerPiHistoryTool(pi, instance.root, instance);
|
|
30
|
+
const server = instance.workers.nativeServer(instance.root);
|
|
31
|
+
if (server) {
|
|
46
32
|
pi.registerMcpServer(mcpServerName, {
|
|
47
33
|
type: "stdio",
|
|
48
|
-
|
|
49
|
-
args: [mcpEntry],
|
|
50
|
-
env: {
|
|
51
|
-
PBOT_HOST: "pi",
|
|
52
|
-
PBOT_WORKSPACE_ROOT: instance.root,
|
|
53
|
-
PBOT_MCP_AGENT_DIR: defaultWorkerDirectory(),
|
|
54
|
-
PBOT_MCP_SESSION_ID: instance.sessionId,
|
|
55
|
-
},
|
|
34
|
+
...server,
|
|
56
35
|
exposure: "direct",
|
|
57
36
|
timeout: 600,
|
|
58
|
-
description: "跨代理程序委派(worker_
|
|
37
|
+
description: "跨代理程序委派(worker_*)",
|
|
59
38
|
});
|
|
60
39
|
registeredMcpServers.push(mcpServerName);
|
|
61
40
|
}
|
|
62
41
|
if (instance.features.mcp) {
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
if (server.enabled === false) continue;
|
|
68
|
-
try {
|
|
69
|
-
const resolved = resolveWorkspaceMcpServer(instance.root, name, server);
|
|
70
|
-
pi.registerMcpServer(resolved.name, toPiMcpConfig(resolved));
|
|
71
|
-
registeredMcpServers.push(resolved.name);
|
|
72
|
-
} catch { /* Keep the workspace active even if one external MCP env var is unset. */ }
|
|
73
|
-
}
|
|
74
|
-
}
|
|
42
|
+
await loadNativeWorkspaceServers(instance.root, server => {
|
|
43
|
+
pi.registerMcpServer(server.name, toPiMcpConfig(server));
|
|
44
|
+
registeredMcpServers.push(server.name);
|
|
45
|
+
}, { check: () => instance.check() });
|
|
75
46
|
}
|
|
76
47
|
},
|
|
77
48
|
() => {
|
|
78
|
-
|
|
49
|
+
hideHistory?.();
|
|
50
|
+
hideHistory = undefined;
|
|
79
51
|
for (const name of registeredMcpServers.splice(0)) {
|
|
80
52
|
pi.unregisterMcpServer(name);
|
|
81
53
|
}
|
package/src/plugin.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { realpathSync } from "node:fs";
|
|
2
2
|
import { pathToFileURL } from "node:url";
|
|
3
3
|
import { requireThat } from "./common/validation.js";
|
|
4
|
-
import { runPluginHost } from "./extension/plugin-runtime.js";
|
|
5
|
-
import { listPluginHosts, pluginHosts } from "./integrations/hosts/registry.js";
|
|
4
|
+
import { runPluginHost, type ReplayPluginHook } from "./extension/hosts/plugin-runtime.js";
|
|
5
|
+
import { listPluginHosts, pluginHosts } from "./integrations/hosts/plugin-registry.js";
|
|
6
6
|
|
|
7
|
-
export async function main(args: readonly string[]): Promise<void> {
|
|
7
|
+
export async function main(args: readonly string[], replayHook?: ReplayPluginHook): Promise<void> {
|
|
8
8
|
const [host, ...rest] = args;
|
|
9
9
|
const adapter = host ? pluginHosts.get(host) : undefined;
|
|
10
10
|
requireThat(adapter, `用法:node <插件目录>/lib/plugin.js <${listPluginHosts().join("|")}> hook|init|status`);
|
|
11
|
-
await runPluginHost(adapter, rest);
|
|
11
|
+
await runPluginHost(adapter, rest, replayHook);
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
if (process.argv[1] && import.meta.url === pathToFileURL(realpathSync(process.argv[1])).href) {
|
|
@@ -5,24 +5,14 @@ import { object } from "../../common/json.js";
|
|
|
5
5
|
import { packageVersion, releaseLine } from "../../common/version.js";
|
|
6
6
|
import { requireThat } from "../../common/validation.js";
|
|
7
7
|
import { AgentFiles, descriptor, launch, status, cycle } from "../../storage/agent-files.js";
|
|
8
|
-
import type { AgentOwner, AgentOptions, AgentPendingRequest, AgentResponseInput, AgentStartOptions, AgentDescriptor, AgentCycle,
|
|
9
|
-
import type { AcpBackend, AcpSessionReference } from "../../model/acp.js";
|
|
8
|
+
import type { AgentOwner, AgentOptions, AgentMessage, AgentPendingRequest, AgentResponseInput, AgentStartOptions, AgentDescriptor, AgentCycle, AgentHost, AgentView } from "../../model/agent.js";
|
|
10
9
|
import { acpElicitationReply, acpModelState, acpPermissionReply, acpReference } from "../../storage/acp-files.js";
|
|
11
10
|
|
|
12
|
-
export
|
|
13
|
-
available(backend: AcpBackend): void;
|
|
14
|
-
filterOptions?(backend: AcpBackend, options: AgentOptions): AgentOptions;
|
|
15
|
-
prepare(backend: AcpBackend, options: AgentOptions): AcpSessionReference;
|
|
16
|
-
alive(id: string): boolean;
|
|
17
|
-
validateSession(value: AgentDescriptor, reference: AgentSessionReference): void | Promise<void>;
|
|
18
|
-
launch(value: AgentDescriptor, directory: string, generation: string, reference: AgentSessionReference, resume: boolean, signal: AbortSignal): void | Promise<void>;
|
|
19
|
-
release(id: string, generation: string): void | Promise<void>;
|
|
20
|
-
report(value: AgentDescriptor, reference: AgentSessionReference, leaf: string): string | Promise<string>;
|
|
21
|
-
}
|
|
11
|
+
export type { AgentHost } from "../../model/agent.js";
|
|
22
12
|
|
|
23
13
|
/** Host-neutral lifecycle manager for cross-harness ACP workers. */
|
|
24
14
|
export class AgentService {
|
|
25
|
-
readonly files: AgentFiles;
|
|
15
|
+
private readonly files: AgentFiles;
|
|
26
16
|
#closed = false;
|
|
27
17
|
#preserve = false;
|
|
28
18
|
readonly #starting = new Map<string, { generation: string; controller: AbortController; stage: "validate" | "launch" }>();
|
|
@@ -218,7 +208,7 @@ export class AgentService {
|
|
|
218
208
|
try { await operation; } finally { this.#launches.delete(operation); }
|
|
219
209
|
}
|
|
220
210
|
|
|
221
|
-
send(id: string, text: string, delivery: "
|
|
211
|
+
send(id: string, text: string, delivery: AgentMessage["delivery"], owner: AgentOwner, attachments: readonly string[] = []) {
|
|
222
212
|
const d = this.get(id, owner);
|
|
223
213
|
return this.files.control(() => {
|
|
224
214
|
requireThat(this.alive(id) && this.#starting.get(id)?.stage !== "validate" && !this.files.read(id, "launch.json", launch).stop, "worker 已停止或仍在恢复校验,请等待显式恢复完成。");
|
|
@@ -298,7 +288,12 @@ export class AgentService {
|
|
|
298
288
|
}
|
|
299
289
|
|
|
300
290
|
cycles(id: string, owner: AgentOwner): AgentCycle[] {
|
|
301
|
-
|
|
291
|
+
return this.cyclesFor(this.view(this.get(id, owner), owner));
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
private cyclesFor(view: AgentView): AgentCycle[] {
|
|
295
|
+
const id = view.agentId;
|
|
296
|
+
const values = this.files.completions(id);
|
|
302
297
|
if (view.cycle && !values.some(c => c.cycleId === view.cycle!.cycleId)) {
|
|
303
298
|
values.push(view.state === "stopped" || view.state === "error" ? { ...view.cycle, state: "interrupted", finishedAt: view.cycle.finishedAt ?? Date.now() } : view.cycle);
|
|
304
299
|
}
|
|
@@ -321,9 +316,26 @@ export class AgentService {
|
|
|
321
316
|
return values;
|
|
322
317
|
}
|
|
323
318
|
|
|
319
|
+
private snapshot(id: string, owner: AgentOwner) {
|
|
320
|
+
const view = this.view(this.get(id, owner), owner);
|
|
321
|
+
const cycles = this.cyclesFor(view);
|
|
322
|
+
const latest = cycles.at(-1);
|
|
323
|
+
return { current: latest ? { ...view, cycle: latest } : view, cycles };
|
|
324
|
+
}
|
|
325
|
+
|
|
324
326
|
status(id: string, owner: AgentOwner) {
|
|
325
|
-
|
|
326
|
-
|
|
327
|
+
return this.snapshot(id, owner).current;
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
outputStatus(id: string, owner: AgentOwner, requestId?: string) {
|
|
331
|
+
const { current, cycles } = this.snapshot(id, owner);
|
|
332
|
+
const request = requestId ?? this.files.messages(id).findLast(item => item.generation === current.generation)?.requestId;
|
|
333
|
+
const cycle = request
|
|
334
|
+
? cycles.find(item => item.generation === current.generation && item.requestIds.includes(request))
|
|
335
|
+
: current.cycle;
|
|
336
|
+
const stopped = current.state === "stopped" || current.state === "error";
|
|
337
|
+
const terminal = request ? stopped && !cycle : stopped || (current.state === "idle" && !cycle);
|
|
338
|
+
return { current, cycle, terminal };
|
|
327
339
|
}
|
|
328
340
|
|
|
329
341
|
async read(id: string, owner: AgentOwner, cycleId?: string, offset = 0, limit = 16000) {
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { randomUUID } from "node:crypto";
|
|
2
|
+
import { isDeepStrictEqual } from "node:util";
|
|
3
|
+
import type { HistoryExchange, HistoryHost, HistorySession, RawHistory } from "../../model/history.js";
|
|
4
|
+
import type { HistoryCapture } from "../../model/plugin-host.js";
|
|
5
|
+
import { workspaceHistoryFiles } from "./workspace-history.js";
|
|
6
|
+
import { indexHistory, orderedRawExchanges } from "./history-index.js";
|
|
7
|
+
|
|
8
|
+
function orderedExchanges(raw?: RawHistory): HistoryExchange[] {
|
|
9
|
+
if (!raw) return [];
|
|
10
|
+
return orderedRawExchanges(raw).map(({ entryIds, text, from, to, completed }) => ({
|
|
11
|
+
entryIds: [...entryIds],
|
|
12
|
+
text,
|
|
13
|
+
from,
|
|
14
|
+
to,
|
|
15
|
+
completed,
|
|
16
|
+
}));
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function replaceAssistantSuffix(text: string, assistantText: string): string {
|
|
20
|
+
const marker = "\n\n助手:\n";
|
|
21
|
+
const section = `助手:\n${assistantText}`;
|
|
22
|
+
if (text === section || text.endsWith("\n\n" + section)) return text;
|
|
23
|
+
if (!text || text.startsWith("助手:\n")) return section;
|
|
24
|
+
const index = text.lastIndexOf(marker);
|
|
25
|
+
if (index >= 0) return text.slice(0, index) + marker + assistantText;
|
|
26
|
+
return text + marker + assistantText;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function buildSession(host: HistoryHost, capture: HistoryCapture, previous?: RawHistory): HistorySession | undefined {
|
|
30
|
+
if (capture.kind === "session") {
|
|
31
|
+
return capture.session.branches.length ? capture.session : undefined;
|
|
32
|
+
}
|
|
33
|
+
const timestamp = capture.timestamp ?? new Date().toISOString();
|
|
34
|
+
const branch = orderedExchanges(previous);
|
|
35
|
+
// entryIds already identify native observations on disk. A turn keeps its ID
|
|
36
|
+
// across steering, attachment-only inputs and Stop hooks arriving out of order.
|
|
37
|
+
const turnEntry = capture.turnId ? `${host}:turn:${capture.turnId}` : undefined;
|
|
38
|
+
const turn = turnEntry ? branch.find(item => item.entryIds.includes(turnEntry)) : undefined;
|
|
39
|
+
const entryId = () => turnEntry ?? `${host}:${Date.now()}:${randomUUID().slice(0, 8)}`;
|
|
40
|
+
if (capture.kind === "input") {
|
|
41
|
+
const text = capture.text.trim();
|
|
42
|
+
if (!text && !turnEntry) return undefined;
|
|
43
|
+
const input = "用户:\n" + (text || "(无文本输入)");
|
|
44
|
+
if (turn) {
|
|
45
|
+
turn.text += "\n\n" + input;
|
|
46
|
+
turn.to = timestamp;
|
|
47
|
+
turn.completed = false;
|
|
48
|
+
} else {
|
|
49
|
+
branch.push({ entryIds: [entryId()], text: input, from: timestamp, to: timestamp, completed: false });
|
|
50
|
+
}
|
|
51
|
+
return { sessionId: capture.sessionId, name: previous?.name ?? "", branches: [branch] };
|
|
52
|
+
}
|
|
53
|
+
const assistantText = capture.assistantText.trim();
|
|
54
|
+
if (!assistantText) return undefined;
|
|
55
|
+
const target = turnEntry ? turn : branch.at(-1);
|
|
56
|
+
if (target && (turnEntry || !target.completed || capture.isContinuation)) {
|
|
57
|
+
const updated = turnEntry && !target.completed
|
|
58
|
+
? target.text + "\n\n助手:\n" + assistantText
|
|
59
|
+
: replaceAssistantSuffix(target.text, assistantText);
|
|
60
|
+
if (target.text === updated && target.completed === capture.completed) return undefined;
|
|
61
|
+
target.text = updated;
|
|
62
|
+
target.to = timestamp;
|
|
63
|
+
target.completed = capture.completed;
|
|
64
|
+
} else {
|
|
65
|
+
const userText = capture.userText?.trim();
|
|
66
|
+
branch.push({
|
|
67
|
+
entryIds: [entryId()],
|
|
68
|
+
text: userText ? `用户:\n${userText}\n\n助手:\n${assistantText}` : `助手:\n${assistantText}`,
|
|
69
|
+
from: timestamp,
|
|
70
|
+
to: timestamp,
|
|
71
|
+
completed: capture.completed,
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
return { sessionId: capture.sessionId, name: previous?.name ?? "", branches: [branch] };
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/** Persist a host raw history observation atomically into .pbot/history/raw/. */
|
|
78
|
+
export function recordHistoryCapture(root: string, host: HistoryHost, capture: HistoryCapture): void {
|
|
79
|
+
const sessionId = capture.kind === "session" ? capture.session.sessionId : capture.sessionId;
|
|
80
|
+
if (!sessionId) return;
|
|
81
|
+
const files = workspaceHistoryFiles(root, host);
|
|
82
|
+
files.control(() => {
|
|
83
|
+
const previous = files.listRaw(host).find(raw => raw.sessionId === sessionId);
|
|
84
|
+
if (!previous && files.rawWarnings.length) return;
|
|
85
|
+
const session = buildSession(host, capture, previous);
|
|
86
|
+
if (!session || !session.branches.length) return;
|
|
87
|
+
const raw = indexHistory(session, previous, host);
|
|
88
|
+
if (isDeepStrictEqual(raw, previous)) return;
|
|
89
|
+
files.saveRaw(raw);
|
|
90
|
+
});
|
|
91
|
+
}
|