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
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { PluginHostAdapter } from "../model/plugin-host.js";
|
|
2
|
-
export declare function pluginCommand(adapter: PluginHostAdapter, args: readonly string[], cwd: string): Promise<{
|
|
3
|
-
version: string;
|
|
4
|
-
workspaceRoot: string;
|
|
5
|
-
resourceRoot: string;
|
|
6
|
-
configuration: import("../model/workspace-config.js").WorkspaceConfiguration;
|
|
7
|
-
}>;
|
|
8
|
-
export declare function runPluginHost(adapter: PluginHostAdapter, args: readonly string[]): Promise<void>;
|
|
9
|
-
/** Shared hook execution engine; host-specific protocols stay in PluginHostAdapter implementations. */
|
|
10
|
-
export declare function pluginHook(adapter: PluginHostAdapter, payload: unknown): Promise<Record<string, unknown>>;
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import { resourceRoot } from "../common/paths.js";
|
|
2
|
-
import { packageVersion } from "../common/version.js";
|
|
3
|
-
import { requireThat } from "../common/validation.js";
|
|
4
|
-
import { loadWorkspaceContext } from "../integrations/agent-resources.js";
|
|
5
|
-
import { readWorkspaceConfig, workspaceFeatures } from "../services/workspace/workspace-config.js";
|
|
6
|
-
import { initializeWorkspace } from "../services/workspace/workspace-preparation.js";
|
|
7
|
-
import { discoverWorkspaceSkills } from "../services/workspace/workspace-skills.js";
|
|
8
|
-
function disabledMessage(adapter, configuration) {
|
|
9
|
-
return configuration.error ?? `Personal Bot 未在此工作区启用。运行 ${adapter.initCommandHint};配置文件:${configuration.path}`;
|
|
10
|
-
}
|
|
11
|
-
export async function pluginCommand(adapter, args, cwd) {
|
|
12
|
-
const root = await adapter.resolveRoot(cwd);
|
|
13
|
-
const action = args.join(" ");
|
|
14
|
-
requireThat(["init", "status"].includes(action), adapter.usage);
|
|
15
|
-
if (action === "init")
|
|
16
|
-
await initializeWorkspace(root);
|
|
17
|
-
const configuration = await readWorkspaceConfig(root);
|
|
18
|
-
return { version: packageVersion, workspaceRoot: root, resourceRoot, configuration };
|
|
19
|
-
}
|
|
20
|
-
export async function runPluginHost(adapter, args) {
|
|
21
|
-
if (args[0] === "hook") {
|
|
22
|
-
let input = "";
|
|
23
|
-
process.stdin.setEncoding("utf8");
|
|
24
|
-
for await (const chunk of process.stdin)
|
|
25
|
-
input += String(chunk);
|
|
26
|
-
process.stdout.write(JSON.stringify(await pluginHook(adapter, JSON.parse(input))) + "\n");
|
|
27
|
-
}
|
|
28
|
-
else {
|
|
29
|
-
process.stdout.write(JSON.stringify(await pluginCommand(adapter, args, process.cwd()), null, 2) + "\n");
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
/** Shared hook execution engine; host-specific protocols stay in PluginHostAdapter implementations. */
|
|
33
|
-
export async function pluginHook(adapter, payload) {
|
|
34
|
-
if (process.env.PBOT_SUBAGENT_RUN_ID)
|
|
35
|
-
return adapter.formatPass(payload);
|
|
36
|
-
const event = adapter.parseEvent(payload);
|
|
37
|
-
if (event.kind === "ignore")
|
|
38
|
-
return adapter.formatPass(payload);
|
|
39
|
-
const root = await adapter.resolveRoot(event.cwd, event.raw);
|
|
40
|
-
const configuration = await readWorkspaceConfig(root);
|
|
41
|
-
const features = workspaceFeatures(configuration);
|
|
42
|
-
if (event.kind === "check-skill") {
|
|
43
|
-
if (!configuration.enabled)
|
|
44
|
-
return adapter.formatDeny(event, disabledMessage(adapter, configuration));
|
|
45
|
-
if (!features.skills)
|
|
46
|
-
return adapter.formatDeny(event, `Personal Bot 工作区技能已在 ${configuration.path} 中停用(features.skills: false)。`);
|
|
47
|
-
return adapter.formatPass(payload);
|
|
48
|
-
}
|
|
49
|
-
if (!configuration.enabled)
|
|
50
|
-
return adapter.formatPass(payload);
|
|
51
|
-
const workspaceSkills = features.skills && !adapter.nativeWorkspaceSkills
|
|
52
|
-
? await discoverWorkspaceSkills(root)
|
|
53
|
-
: [];
|
|
54
|
-
if (!features.prompts && !workspaceSkills.length)
|
|
55
|
-
return adapter.formatPass(payload);
|
|
56
|
-
const context = await loadWorkspaceContext({
|
|
57
|
-
host: adapter.host,
|
|
58
|
-
root,
|
|
59
|
-
role: event.role,
|
|
60
|
-
...(adapter.coordinatorPrompt ? { coordinatorPrompt: adapter.coordinatorPrompt } : {}),
|
|
61
|
-
includePrompts: features.prompts,
|
|
62
|
-
includeRootAgents: features.prompts && !adapter.nativeRootAgents,
|
|
63
|
-
...(event.localRoleOnly ? { localRoleOnly: true } : {}),
|
|
64
|
-
workspaceSkills,
|
|
65
|
-
});
|
|
66
|
-
return adapter.formatContext(event, context);
|
|
67
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import type { Context } from "@deepseek-ai/cordis";
|
|
2
|
-
import type { Agent } from "@deepseek-ai/dsh-agent";
|
|
3
|
-
import type { SessionId } from "@deepseek-ai/dsh-session";
|
|
4
|
-
import type { HistorySummarizer } from "../../model/history.js";
|
|
5
|
-
declare module "@deepseek-ai/dsh-llm" {
|
|
6
|
-
interface LlmRequestPurposeMap {
|
|
7
|
-
"pbot-history": true;
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
/** Independent text calls through the host's routing and authentication; no Agent or Session messages. */
|
|
11
|
-
export declare function dshHistorySummarizer(ctx: Context, selection: ReturnType<Agent["model"]["current"]>, sessionId: SessionId): HistorySummarizer;
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { BlockAssembler } from "@deepseek-ai/dsh-llm";
|
|
2
|
-
import { requireThat } from "../../common/validation.js";
|
|
3
|
-
import { reduceHistorySummary } from "../history-summary.js";
|
|
4
|
-
/** Independent text calls through the host's routing and authentication; no Agent or Session messages. */
|
|
5
|
-
export function dshHistorySummarizer(ctx, selection, sessionId) {
|
|
6
|
-
return async (request, signal) => {
|
|
7
|
-
requireThat(selection, "请先选择 dsh 模型。");
|
|
8
|
-
signal.throwIfAborted();
|
|
9
|
-
const prepare = () => ctx.llm.prepareCall({ provider: selection.provider, model: selection.model, maxTokens: request.maxTokens }, signal, (controls, model) => ({ ...controls, ...(model.reasoning?.efforts[0] ? { reasoningEffort: model.reasoning.efforts[0].id } : {}) }));
|
|
10
|
-
let first = await prepare();
|
|
11
|
-
const budget = Math.max(2000, Math.min(24000, Math.floor((first.context?.contextWindow ?? 12000) / 2)));
|
|
12
|
-
const ask = async ({ system, prompt }, signal) => {
|
|
13
|
-
signal.throwIfAborted();
|
|
14
|
-
const prepared = first ?? await prepare();
|
|
15
|
-
first = undefined;
|
|
16
|
-
const assembler = new BlockAssembler();
|
|
17
|
-
let finished = false;
|
|
18
|
-
for await (const chunk of prepared.stream({ ...prepared.config, system, sessionId, purpose: "pbot-history", signal, tools: [],
|
|
19
|
-
messages: [{ role: "user", content: [{ type: "text", text: prompt }] }] })) {
|
|
20
|
-
signal.throwIfAborted();
|
|
21
|
-
assembler.push(chunk);
|
|
22
|
-
if (chunk.type === "finish")
|
|
23
|
-
finished = true;
|
|
24
|
-
}
|
|
25
|
-
signal.throwIfAborted();
|
|
26
|
-
const reason = assembler.finish;
|
|
27
|
-
requireThat(finished && reason.kind === "stop", reason.kind === "error" || reason.kind === "aborted" ? reason.failure.message : "历史摘要未正常结束:" + reason.kind);
|
|
28
|
-
const blocks = assembler.blocks();
|
|
29
|
-
requireThat(!blocks.some(block => block.type === "tool-call"), "历史摘要不能执行工具。");
|
|
30
|
-
const answer = blocks.filter(block => block.type === "text").map(block => block.text).join("\n").trim();
|
|
31
|
-
requireThat(answer, "历史摘要为空。");
|
|
32
|
-
return answer;
|
|
33
|
-
};
|
|
34
|
-
return reduceHistorySummary(budget, ask)(request, signal);
|
|
35
|
-
};
|
|
36
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import type { Context } from "@deepseek-ai/cordis";
|
|
2
|
-
import type { SessionEvent, SessionHeader } from "@deepseek-ai/dsh-session";
|
|
3
|
-
import type { HistoryLocation, HistorySession, HistorySource } from "../../model/history.js";
|
|
4
|
-
/** Archive questions and the final/partial answer; raw tool records stay in the native log. */
|
|
5
|
-
export declare function projectDshHistory(header: SessionHeader, events: readonly SessionEvent[], name?: string): HistorySession;
|
|
6
|
-
export declare class DshHistory implements HistorySource {
|
|
7
|
-
private readonly ctx;
|
|
8
|
-
private readonly root;
|
|
9
|
-
private readonly relatedSessions;
|
|
10
|
-
readonly host = "dsh";
|
|
11
|
-
constructor(ctx: Context, root: string, relatedSessions?: () => string[]);
|
|
12
|
-
scan(location: HistoryLocation, signal?: AbortSignal, excluded?: ReadonlySet<string>): Promise<{
|
|
13
|
-
sessions: HistorySession[];
|
|
14
|
-
warnings: string[];
|
|
15
|
-
}>;
|
|
16
|
-
}
|
|
@@ -1,167 +0,0 @@
|
|
|
1
|
-
var __addDisposableResource = (this && this.__addDisposableResource) || function (env, value, async) {
|
|
2
|
-
if (value !== null && value !== void 0) {
|
|
3
|
-
if (typeof value !== "object" && typeof value !== "function") throw new TypeError("Object expected.");
|
|
4
|
-
var dispose, inner;
|
|
5
|
-
if (async) {
|
|
6
|
-
if (!Symbol.asyncDispose) throw new TypeError("Symbol.asyncDispose is not defined.");
|
|
7
|
-
dispose = value[Symbol.asyncDispose];
|
|
8
|
-
}
|
|
9
|
-
if (dispose === void 0) {
|
|
10
|
-
if (!Symbol.dispose) throw new TypeError("Symbol.dispose is not defined.");
|
|
11
|
-
dispose = value[Symbol.dispose];
|
|
12
|
-
if (async) inner = dispose;
|
|
13
|
-
}
|
|
14
|
-
if (typeof dispose !== "function") throw new TypeError("Object not disposable.");
|
|
15
|
-
if (inner) dispose = function() { try { inner.call(this); } catch (e) { return Promise.reject(e); } };
|
|
16
|
-
env.stack.push({ value: value, dispose: dispose, async: async });
|
|
17
|
-
}
|
|
18
|
-
else if (async) {
|
|
19
|
-
env.stack.push({ async: true });
|
|
20
|
-
}
|
|
21
|
-
return value;
|
|
22
|
-
};
|
|
23
|
-
var __disposeResources = (this && this.__disposeResources) || (function (SuppressedError) {
|
|
24
|
-
return function (env) {
|
|
25
|
-
function fail(e) {
|
|
26
|
-
env.error = env.hasError ? new SuppressedError(e, env.error, "An error was suppressed during disposal.") : e;
|
|
27
|
-
env.hasError = true;
|
|
28
|
-
}
|
|
29
|
-
var r, s = 0;
|
|
30
|
-
function next() {
|
|
31
|
-
while (r = env.stack.pop()) {
|
|
32
|
-
try {
|
|
33
|
-
if (!r.async && s === 1) return s = 0, env.stack.push(r), Promise.resolve().then(next);
|
|
34
|
-
if (r.dispose) {
|
|
35
|
-
var result = r.dispose.call(r.value);
|
|
36
|
-
if (r.async) return s |= 2, Promise.resolve(result).then(next, function(e) { fail(e); return next(); });
|
|
37
|
-
}
|
|
38
|
-
else s |= 1;
|
|
39
|
-
}
|
|
40
|
-
catch (e) {
|
|
41
|
-
fail(e);
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
if (s === 1) return env.hasError ? Promise.reject(env.error) : Promise.resolve();
|
|
45
|
-
if (env.hasError) throw env.error;
|
|
46
|
-
}
|
|
47
|
-
return next();
|
|
48
|
-
};
|
|
49
|
-
})(typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
50
|
-
var e = new Error(message);
|
|
51
|
-
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
52
|
-
});
|
|
53
|
-
import { realpath } from "node:fs/promises";
|
|
54
|
-
import { SessionId } from "@deepseek-ai/dsh-session";
|
|
55
|
-
import { requireThat } from "../../common/validation.js";
|
|
56
|
-
import { finalDshAnswer } from "./messages.js";
|
|
57
|
-
const text = (content) => content.flatMap(block => block.type === "text" ? [block.text] :
|
|
58
|
-
block.type === "image" ? ["[图片 " + (block.attachment.name ?? block.attachment.attachmentId) + "]"] :
|
|
59
|
-
block.type === "file" ? ["[附件 " + (block.attachment.name ?? block.attachment.attachmentId) + "]"] : []).join("\n");
|
|
60
|
-
/** Archive questions and the final/partial answer; raw tool records stay in the native log. */
|
|
61
|
-
export function projectDshHistory(header, events, name = "") {
|
|
62
|
-
const exchanges = [], supersededEntryIds = [];
|
|
63
|
-
let users = [], answer, observed = [];
|
|
64
|
-
const finish = (completed = false) => {
|
|
65
|
-
if (users.length) {
|
|
66
|
-
const entries = [...users, ...(answer ? [answer] : [])];
|
|
67
|
-
const body = answer ? answer.data.message.content.filter(block => block.type === "text").map(block => block.text).join("\n") : "";
|
|
68
|
-
exchanges.push({ entryIds: entries.map(event => "dsh:" + event.seq), from: new Date(users[0].time).toISOString(),
|
|
69
|
-
to: new Date(entries.at(-1).time).toISOString(),
|
|
70
|
-
completed: completed && Boolean(answer && finalDshAnswer(answer).trim()),
|
|
71
|
-
text: users.map(event => (event.data.source.kind === "user" ? "用户:\n" : "协调者要求:\n") + text(event.data.content)).join("\n\n") +
|
|
72
|
-
(body ? "\n\n助手:\n" + body : "") });
|
|
73
|
-
}
|
|
74
|
-
const last = (answer ?? users.at(-1))?.seq;
|
|
75
|
-
supersededEntryIds.push(...observed.filter(id => id !== "dsh:" + last));
|
|
76
|
-
users = [];
|
|
77
|
-
answer = undefined;
|
|
78
|
-
observed = [];
|
|
79
|
-
};
|
|
80
|
-
for (const event of events) {
|
|
81
|
-
if (event.type === "turn/start")
|
|
82
|
-
finish();
|
|
83
|
-
else if (event.type === "user/message" && ["user", "pbot-input"].includes(event.data.source.kind)) {
|
|
84
|
-
if (!answer)
|
|
85
|
-
observed.push("dsh:" + event.seq);
|
|
86
|
-
users.push(event);
|
|
87
|
-
}
|
|
88
|
-
else if (event.type === "assistant/message" && users.length) {
|
|
89
|
-
answer = event;
|
|
90
|
-
observed.push("dsh:" + event.seq);
|
|
91
|
-
}
|
|
92
|
-
else if (event.type === "turn/end")
|
|
93
|
-
finish(event.data.reason.kind === "completed");
|
|
94
|
-
}
|
|
95
|
-
finish();
|
|
96
|
-
return { sessionId: header.id, name, branches: exchanges.length ? [exchanges] : [], supersededEntryIds };
|
|
97
|
-
}
|
|
98
|
-
export class DshHistory {
|
|
99
|
-
ctx;
|
|
100
|
-
root;
|
|
101
|
-
relatedSessions;
|
|
102
|
-
host = "dsh";
|
|
103
|
-
constructor(ctx, root, relatedSessions = () => []) {
|
|
104
|
-
this.ctx = ctx;
|
|
105
|
-
this.root = root;
|
|
106
|
-
this.relatedSessions = relatedSessions;
|
|
107
|
-
}
|
|
108
|
-
async scan(location, signal, excluded) {
|
|
109
|
-
requireThat(location.host === "dsh", "dsh 历史只读取 dsh 原生会话。");
|
|
110
|
-
signal?.throwIfAborted();
|
|
111
|
-
const records = (await this.ctx.sessionQuery.listSessions(signal)).filter(record => !excluded?.has(record.header.id));
|
|
112
|
-
const selected = new Set(), warnings = [];
|
|
113
|
-
// Expert records also name ACP members and sessions that dsh no longer stores; only real dsh sessions are readable.
|
|
114
|
-
const stored = new Set(records.map(record => record.header.id));
|
|
115
|
-
try {
|
|
116
|
-
for (const id of this.relatedSessions())
|
|
117
|
-
if (stored.has(id))
|
|
118
|
-
selected.add(id);
|
|
119
|
-
}
|
|
120
|
-
catch (error) {
|
|
121
|
-
warnings.push("专家引用:" + String(error));
|
|
122
|
-
}
|
|
123
|
-
if (location.sessionId && !excluded?.has(location.sessionId))
|
|
124
|
-
selected.add(location.sessionId);
|
|
125
|
-
for (const record of records) {
|
|
126
|
-
signal?.throwIfAborted();
|
|
127
|
-
if ((record.header.origin !== "subagent" || !record.header.parentSession) && record.header.cwd &&
|
|
128
|
-
await realpath(record.header.cwd).catch(() => record.header.cwd) === this.root)
|
|
129
|
-
selected.add(record.header.id);
|
|
130
|
-
}
|
|
131
|
-
// Native subagents may use a different cwd while still belonging to a workspace's parent.
|
|
132
|
-
for (let changed = true; changed;) {
|
|
133
|
-
changed = false;
|
|
134
|
-
for (const record of records)
|
|
135
|
-
if (record.header.origin === "subagent" && record.header.parentSession && selected.has(record.header.parentSession) && !selected.has(record.header.id)) {
|
|
136
|
-
selected.add(record.header.id);
|
|
137
|
-
changed = true;
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
const sessions = [];
|
|
141
|
-
for (const id of selected) {
|
|
142
|
-
signal?.throwIfAborted();
|
|
143
|
-
try {
|
|
144
|
-
const env_1 = { stack: [], error: void 0, hasError: false };
|
|
145
|
-
try {
|
|
146
|
-
const observation = __addDisposableResource(env_1, await this.ctx.sessionQuery.observeSession(SessionId(id), { ...(signal ? { signal } : {}), projectionMode: "none" }), false);
|
|
147
|
-
const title = await this.ctx.sessionQuery.readTitle(SessionId(id), signal);
|
|
148
|
-
const session = projectDshHistory(observation.header, observation.events, title?.title);
|
|
149
|
-
if (session.branches.length)
|
|
150
|
-
sessions.push(session);
|
|
151
|
-
}
|
|
152
|
-
catch (e_1) {
|
|
153
|
-
env_1.error = e_1;
|
|
154
|
-
env_1.hasError = true;
|
|
155
|
-
}
|
|
156
|
-
finally {
|
|
157
|
-
__disposeResources(env_1);
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
catch (error) {
|
|
161
|
-
signal?.throwIfAborted();
|
|
162
|
-
warnings.push(id + ": " + String(error));
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
return { sessions, warnings };
|
|
166
|
-
}
|
|
167
|
-
}
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import type { HistorySummarizer } from "../model/history.js";
|
|
2
|
-
/** Split Pi/dsh summary inputs within the model's character budget. */
|
|
3
|
-
export declare function splitHistorySummary(text: string, budget: number): string[];
|
|
4
|
-
export declare function reduceHistorySummary(budget: number, ask: HistorySummarizer): HistorySummarizer;
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
/** Split Pi/dsh summary inputs within the model's character budget. */
|
|
2
|
-
export function splitHistorySummary(text, budget) {
|
|
3
|
-
if (!Number.isInteger(budget) || budget < 2)
|
|
4
|
-
throw new Error("历史摘要分段预算无效。");
|
|
5
|
-
const parts = [];
|
|
6
|
-
for (let offset = 0; offset < text.length;) {
|
|
7
|
-
let end = Math.min(text.length, offset + budget);
|
|
8
|
-
if (end < text.length && /[\uD800-\uDBFF]/.test(text[end - 1]))
|
|
9
|
-
end--;
|
|
10
|
-
parts.push(text.slice(offset, end));
|
|
11
|
-
offset = end;
|
|
12
|
-
}
|
|
13
|
-
return parts;
|
|
14
|
-
}
|
|
15
|
-
export function reduceHistorySummary(budget, ask) {
|
|
16
|
-
return async (request, signal) => {
|
|
17
|
-
let text = request.prompt;
|
|
18
|
-
while (text.length > budget) {
|
|
19
|
-
const parts = [];
|
|
20
|
-
for (const prompt of splitHistorySummary(text, budget)) {
|
|
21
|
-
signal.throwIfAborted();
|
|
22
|
-
parts.push(await ask({ ...request, prompt }, signal));
|
|
23
|
-
}
|
|
24
|
-
const smaller = parts.join("\n\n");
|
|
25
|
-
if (smaller.length >= text.length)
|
|
26
|
-
throw new Error("历史摘要未缩短,稍后重试。");
|
|
27
|
-
text = smaller;
|
|
28
|
-
}
|
|
29
|
-
signal.throwIfAborted();
|
|
30
|
-
return ask({ ...request, prompt: text }, signal);
|
|
31
|
-
};
|
|
32
|
-
}
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import type { PluginHostAdapter } from "../../model/plugin-host.js";
|
|
2
|
-
export declare function antigravityWorkspaceRoot(cwd: string, payload?: unknown): Promise<string>;
|
|
3
|
-
export declare const antigravityAdapter: PluginHostAdapter;
|
|
4
|
-
export declare const antigravitySkillPath: (pluginRoot: string, skill: string) => string;
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
import { realpath, stat } from "node:fs/promises";
|
|
2
|
-
import { isAbsolute, join, relative, resolve, sep } from "node:path";
|
|
3
|
-
import { object } from "../../common/json.js";
|
|
4
|
-
import { resourceRoot } from "../../common/paths.js";
|
|
5
|
-
import { requireThat } from "../../common/validation.js";
|
|
6
|
-
const supportedEvents = ["SessionStart", "PreToolUse"];
|
|
7
|
-
function workspaceFromPayload(cwd, payload) {
|
|
8
|
-
if (object(payload) && Array.isArray(payload.workspacePaths)) {
|
|
9
|
-
const first = payload.workspacePaths.find(value => typeof value === "string" && value.length > 0);
|
|
10
|
-
if (typeof first === "string")
|
|
11
|
-
return first;
|
|
12
|
-
}
|
|
13
|
-
return cwd;
|
|
14
|
-
}
|
|
15
|
-
function skillFromReadPath(targetPath, pluginRoot = process.env.PLUGIN_ROOT || resolve(resourceRoot, "..")) {
|
|
16
|
-
const skillsRoot = resolve(pluginRoot, "skills");
|
|
17
|
-
const rel = relative(skillsRoot, resolve(targetPath));
|
|
18
|
-
if (!rel || rel.startsWith("..") || isAbsolute(rel))
|
|
19
|
-
return undefined;
|
|
20
|
-
const skill = rel.split(sep)[0];
|
|
21
|
-
if (!skill || skill === "pbot")
|
|
22
|
-
return undefined;
|
|
23
|
-
return skill;
|
|
24
|
-
}
|
|
25
|
-
function isPreToolUse(payload) {
|
|
26
|
-
return object(payload) && payload.hookEventName === "PreToolUse";
|
|
27
|
-
}
|
|
28
|
-
export async function antigravityWorkspaceRoot(cwd, payload) {
|
|
29
|
-
const directory = workspaceFromPayload(cwd, payload);
|
|
30
|
-
requireThat(isAbsolute(directory), "Antigravity 工作区需要绝对路径。");
|
|
31
|
-
const root = await realpath(directory);
|
|
32
|
-
requireThat((await stat(root)).isDirectory(), "Antigravity 工作区需要目录。");
|
|
33
|
-
return root;
|
|
34
|
-
}
|
|
35
|
-
export const antigravityAdapter = {
|
|
36
|
-
host: "antigravity",
|
|
37
|
-
nativeRootAgents: true,
|
|
38
|
-
nativeWorkspaceSkills: true,
|
|
39
|
-
coordinatorPrompt: "plugin-coordinator.md",
|
|
40
|
-
initCommandHint: "/pbot init",
|
|
41
|
-
usage: "用法:node <插件目录>/lib/plugin.js antigravity init|status",
|
|
42
|
-
resolveRoot(cwd, rawPayload) {
|
|
43
|
-
return antigravityWorkspaceRoot(cwd, rawPayload);
|
|
44
|
-
},
|
|
45
|
-
parseEvent(value) {
|
|
46
|
-
requireThat(object(value) && typeof value.hookEventName === "string", "Antigravity hook 输入无效。");
|
|
47
|
-
const event = value.hookEventName;
|
|
48
|
-
requireThat(supportedEvents.includes(event), "Antigravity hook 事件未支持。");
|
|
49
|
-
const cwd = typeof value.cwd === "string" && value.cwd ? value.cwd : workspaceFromPayload("", value);
|
|
50
|
-
requireThat(cwd, "Antigravity hook 缺少工作目录。");
|
|
51
|
-
if (event === "SessionStart") {
|
|
52
|
-
return { kind: "inject-context", role: "coordinator", cwd, raw: value };
|
|
53
|
-
}
|
|
54
|
-
if (!object(value.toolCall) || typeof value.toolCall.name !== "string" || !object(value.toolCall.args)) {
|
|
55
|
-
return { kind: "ignore" };
|
|
56
|
-
}
|
|
57
|
-
const { name, args } = value.toolCall;
|
|
58
|
-
if (name === "read_file" && typeof args.Path === "string") {
|
|
59
|
-
const skill = skillFromReadPath(args.Path);
|
|
60
|
-
if (skill)
|
|
61
|
-
return { kind: "check-skill", skill, cwd, raw: value };
|
|
62
|
-
}
|
|
63
|
-
return { kind: "ignore" };
|
|
64
|
-
},
|
|
65
|
-
formatPass(payload) {
|
|
66
|
-
return isPreToolUse(payload) ? { decision: "allow" } : {};
|
|
67
|
-
},
|
|
68
|
-
formatContext(_event, context) {
|
|
69
|
-
return {
|
|
70
|
-
injectSteps: [
|
|
71
|
-
{ systemMessage: { systemMessage: context.text } },
|
|
72
|
-
],
|
|
73
|
-
};
|
|
74
|
-
},
|
|
75
|
-
formatDeny(_event, reason) {
|
|
76
|
-
return { decision: "deny", reason };
|
|
77
|
-
},
|
|
78
|
-
};
|
|
79
|
-
export const antigravitySkillPath = (pluginRoot, skill) => join(pluginRoot, "skills", skill, "SKILL.md");
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import { realpath, stat } from "node:fs/promises";
|
|
2
|
-
import { isAbsolute } from "node:path";
|
|
3
|
-
import { object } from "../../common/json.js";
|
|
4
|
-
import { requireThat } from "../../common/validation.js";
|
|
5
|
-
const supportedEvents = ["UserPromptSubmit", "PreToolUse", "UserPromptExpansion"];
|
|
6
|
-
export async function claudeWorkspaceRoot(cwd, projectDirectory = process.env.CLAUDE_PROJECT_DIR) {
|
|
7
|
-
const directory = projectDirectory || cwd;
|
|
8
|
-
requireThat(isAbsolute(directory), "Claude 工作区需要绝对路径。");
|
|
9
|
-
const root = await realpath(directory);
|
|
10
|
-
requireThat((await stat(root)).isDirectory(), "Claude 工作区需要目录。");
|
|
11
|
-
return root;
|
|
12
|
-
}
|
|
13
|
-
export const claudeAdapter = {
|
|
14
|
-
host: "claude",
|
|
15
|
-
nativeRootAgents: false,
|
|
16
|
-
nativeWorkspaceSkills: false,
|
|
17
|
-
coordinatorPrompt: "plugin-coordinator.md",
|
|
18
|
-
initCommandHint: "/personal-bot:pbot init",
|
|
19
|
-
usage: "用法:node <插件目录>/lib/claude.js init|status",
|
|
20
|
-
resolveRoot(cwd) {
|
|
21
|
-
return claudeWorkspaceRoot(cwd);
|
|
22
|
-
},
|
|
23
|
-
parseEvent(value) {
|
|
24
|
-
requireThat(object(value) && typeof value.hook_event_name === "string", "Claude hook 输入无效。");
|
|
25
|
-
const event = value.hook_event_name;
|
|
26
|
-
requireThat(supportedEvents.includes(event), "Claude hook 事件未支持。");
|
|
27
|
-
if (event === "PreToolUse" || event === "UserPromptExpansion") {
|
|
28
|
-
const skill = event === "UserPromptExpansion"
|
|
29
|
-
? value.expansion_type === "slash_command" ? value.command_name : undefined
|
|
30
|
-
: value.tool_name === "Skill" && object(value.tool_input) ? value.tool_input.skill : undefined;
|
|
31
|
-
if (typeof skill !== "string" || !skill.startsWith("personal-bot:") || skill === "personal-bot:pbot")
|
|
32
|
-
return { kind: "ignore" };
|
|
33
|
-
requireThat(typeof value.cwd === "string", "Claude hook 缺少工作目录。");
|
|
34
|
-
return { kind: "check-skill", skill, cwd: value.cwd, raw: value };
|
|
35
|
-
}
|
|
36
|
-
// Leave Claude's native subagents untouched; only inject coordinator context into main sessions.
|
|
37
|
-
if (typeof value.agent_id === "string")
|
|
38
|
-
return { kind: "ignore" };
|
|
39
|
-
requireThat(typeof value.cwd === "string", "Claude hook 缺少工作目录。");
|
|
40
|
-
return { kind: "inject-context", role: "coordinator", cwd: value.cwd, raw: value };
|
|
41
|
-
},
|
|
42
|
-
formatPass() {
|
|
43
|
-
return {};
|
|
44
|
-
},
|
|
45
|
-
formatContext(event, context) {
|
|
46
|
-
const raw = event.raw;
|
|
47
|
-
return {
|
|
48
|
-
hookSpecificOutput: {
|
|
49
|
-
hookEventName: raw.hook_event_name,
|
|
50
|
-
additionalContext: context.text,
|
|
51
|
-
},
|
|
52
|
-
};
|
|
53
|
-
},
|
|
54
|
-
formatDeny(event, reason) {
|
|
55
|
-
const raw = event.raw;
|
|
56
|
-
return raw.hook_event_name === "UserPromptExpansion"
|
|
57
|
-
? { decision: "block", reason }
|
|
58
|
-
: { hookSpecificOutput: { hookEventName: raw.hook_event_name, permissionDecision: "deny", permissionDecisionReason: reason } };
|
|
59
|
-
},
|
|
60
|
-
};
|
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
import type { HistoryHost, HistoryIdentity, HistoryLocation, HistoryNode, HistoryRecord, HistorySource, HistorySummarizer } from "../../model/history.js";
|
|
2
|
-
import type { HistoryFiles } from "../../storage/history-files.js";
|
|
3
|
-
export interface HistoryQuery {
|
|
4
|
-
host?: HistoryHost;
|
|
5
|
-
query?: string;
|
|
6
|
-
sessionId?: string;
|
|
7
|
-
from?: string;
|
|
8
|
-
to?: string;
|
|
9
|
-
offset?: number;
|
|
10
|
-
limit?: number;
|
|
11
|
-
}
|
|
12
|
-
type HistoryReader = Pick<HistoryFiles, "host" | "list" | "warnings">;
|
|
13
|
-
/** Validate the exact target and ordered inputs under the source lock. Only publish the derived file. */
|
|
14
|
-
export declare function commitHistorySummary(files: Pick<HistoryFiles, "control" | "list" | "saveSummaries">, identity: HistoryIdentity, expected: HistoryNode, children: readonly HistoryNode[], text: string, signal?: AbortSignal): HistoryRecord | undefined;
|
|
15
|
-
export declare class HistoryService {
|
|
16
|
-
#private;
|
|
17
|
-
readonly root: string;
|
|
18
|
-
private readonly files;
|
|
19
|
-
private readonly source;
|
|
20
|
-
private readonly otherFiles;
|
|
21
|
-
private readonly acpSessions?;
|
|
22
|
-
constructor(root: string, files: HistoryFiles, source: HistorySource, otherFiles?: readonly HistoryReader[], acpSessions?: (() => {
|
|
23
|
-
ids: Record<HistoryHost, ReadonlySet<string>>;
|
|
24
|
-
warnings: string[];
|
|
25
|
-
}) | undefined);
|
|
26
|
-
check(): void;
|
|
27
|
-
get warnings(): string[];
|
|
28
|
-
get status(): {
|
|
29
|
-
loaded: boolean;
|
|
30
|
-
organizing: boolean;
|
|
31
|
-
pending: number | null;
|
|
32
|
-
warnings: string[];
|
|
33
|
-
};
|
|
34
|
-
refresh(location: HistoryLocation, signal?: AbortSignal): Promise<void>;
|
|
35
|
-
private load;
|
|
36
|
-
search({ host, query, sessionId, from, to, offset, limit }?: HistoryQuery): {
|
|
37
|
-
matches: {
|
|
38
|
-
parents: string[];
|
|
39
|
-
snippet: string;
|
|
40
|
-
host: HistoryHost;
|
|
41
|
-
id: string;
|
|
42
|
-
kind: "session" | "exchange" | "summary";
|
|
43
|
-
sessionId: string;
|
|
44
|
-
name: string;
|
|
45
|
-
preview: string;
|
|
46
|
-
from: string;
|
|
47
|
-
to: string;
|
|
48
|
-
ready: boolean;
|
|
49
|
-
completed: boolean;
|
|
50
|
-
}[];
|
|
51
|
-
total: number;
|
|
52
|
-
nextOffset: number | null;
|
|
53
|
-
warnings: string[];
|
|
54
|
-
};
|
|
55
|
-
private find;
|
|
56
|
-
read(id: string, offset?: number, limit?: number, childrenOffset?: number, host?: HistoryHost): {
|
|
57
|
-
text: string;
|
|
58
|
-
totalLength: number;
|
|
59
|
-
nextOffset: number | null;
|
|
60
|
-
parents: {
|
|
61
|
-
host: HistoryHost;
|
|
62
|
-
id: string;
|
|
63
|
-
kind: "session" | "exchange" | "summary";
|
|
64
|
-
sessionId: string;
|
|
65
|
-
name: string;
|
|
66
|
-
preview: string;
|
|
67
|
-
from: string;
|
|
68
|
-
to: string;
|
|
69
|
-
ready: boolean;
|
|
70
|
-
completed: boolean;
|
|
71
|
-
}[];
|
|
72
|
-
children: {
|
|
73
|
-
host: HistoryHost;
|
|
74
|
-
id: string;
|
|
75
|
-
kind: "session" | "exchange" | "summary";
|
|
76
|
-
sessionId: string;
|
|
77
|
-
name: string;
|
|
78
|
-
preview: string;
|
|
79
|
-
from: string;
|
|
80
|
-
to: string;
|
|
81
|
-
ready: boolean;
|
|
82
|
-
completed: boolean;
|
|
83
|
-
}[];
|
|
84
|
-
nextChildrenOffset: number | null;
|
|
85
|
-
source: {
|
|
86
|
-
host: HistoryHost;
|
|
87
|
-
sessionId: string;
|
|
88
|
-
entryIds: string[];
|
|
89
|
-
};
|
|
90
|
-
warnings: string[];
|
|
91
|
-
host: HistoryHost;
|
|
92
|
-
id: string;
|
|
93
|
-
kind: "session" | "exchange" | "summary";
|
|
94
|
-
sessionId: string;
|
|
95
|
-
name: string;
|
|
96
|
-
preview: string;
|
|
97
|
-
from: string;
|
|
98
|
-
to: string;
|
|
99
|
-
ready: boolean;
|
|
100
|
-
completed: boolean;
|
|
101
|
-
};
|
|
102
|
-
/** Retain exact inputs only for this call; model work never holds the source write lock. */
|
|
103
|
-
organize(summarize: HistorySummarizer, signal: AbortSignal): Promise<void>;
|
|
104
|
-
close(): Promise<void>;
|
|
105
|
-
}
|
|
106
|
-
export {};
|