personal-bot 0.3.1 → 0.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude-plugin/marketplace.json +2 -2
- package/.claude-plugin/plugin.json +2 -1
- package/DISCLAIMER.md +17 -0
- package/LICENSE +21 -0
- package/README.md +15 -5
- package/README.zh-CN.md +15 -5
- package/bin/pbot-pi-acp.mjs +27 -11
- package/bin/pbot.mjs +22 -2
- package/docs/README.md +3 -1
- package/docs/architecture/design.md +37 -24
- package/docs/architecture/extensibility.md +27 -19
- package/docs/architecture/model-context.md +4 -3
- package/docs/architecture/principles.md +5 -4
- package/docs/guides/capabilities.md +4 -4
- package/docs/guides/cross-harness-workers.md +3 -1
- package/docs/guides/history.md +73 -16
- package/docs/guides/workspace-configuration.md +35 -6
- package/docs/hosts/antigravity.md +2 -0
- package/docs/hosts/claude-code.md +1 -1
- package/docs/hosts/codex-qoder.md +63 -0
- package/docs/hosts/dsh.md +1 -1
- package/docs/hosts/pi.md +1 -1
- package/docs/maintainers/architecture-governance.md +78 -0
- package/hooks/hooks.json +3 -0
- package/lib/antigravity-plugin/DISCLAIMER.md +17 -0
- package/lib/antigravity-plugin/LICENSE +21 -0
- package/lib/antigravity-plugin/bin/pbot-pi-acp.mjs +36 -0
- package/lib/antigravity-plugin/hooks.json +7 -0
- package/lib/antigravity-plugin/lib/claude.js +2 -2
- package/lib/antigravity-plugin/lib/common/files.d.ts +2 -0
- package/lib/antigravity-plugin/lib/common/files.js +44 -0
- package/lib/antigravity-plugin/lib/common/validation.d.ts +4 -0
- package/lib/antigravity-plugin/lib/common/validation.js +8 -0
- package/lib/{extension/acp-member.d.ts → antigravity-plugin/lib/extension/acp/member.d.ts} +5 -5
- package/lib/{extension/acp-member.js → antigravity-plugin/lib/extension/acp/member.js} +6 -6
- package/lib/antigravity-plugin/lib/extension/acp-worker.js +222 -51
- package/lib/antigravity-plugin/lib/extension/hosts/dsh/acp-entry.d.ts +1 -0
- package/lib/antigravity-plugin/lib/extension/hosts/dsh/acp-entry.js +22 -0
- package/lib/{extension → antigravity-plugin/lib/extension/hosts}/dsh/acp-member.js +11 -25
- package/lib/{extension → antigravity-plugin/lib/extension/hosts}/dsh/files.js +3 -3
- package/lib/antigravity-plugin/lib/extension/hosts/pi/acp-member.d.ts +3 -0
- package/lib/antigravity-plugin/lib/extension/hosts/pi/acp-member.js +100 -0
- package/lib/antigravity-plugin/lib/extension/hosts/plugin-runtime.d.ts +12 -0
- package/lib/antigravity-plugin/lib/extension/hosts/plugin-runtime.js +101 -0
- package/lib/antigravity-plugin/lib/extension/hosts/workspace-mcp.d.ts +6 -0
- package/lib/antigravity-plugin/lib/extension/hosts/workspace-mcp.js +21 -0
- package/lib/antigravity-plugin/lib/extension/mcp.js +2705 -1348
- package/lib/antigravity-plugin/lib/extension/workspace-cli.js +20127 -0
- package/lib/antigravity-plugin/lib/integrations/agent-resources.d.ts +1 -0
- package/lib/antigravity-plugin/lib/integrations/agent-resources.js +6 -2
- package/lib/antigravity-plugin/lib/integrations/hosts/antigravity/adapter.d.ts +6 -0
- package/lib/antigravity-plugin/lib/integrations/hosts/antigravity/adapter.js +171 -0
- package/lib/antigravity-plugin/lib/integrations/hosts/{claude.d.ts → claude/adapter.d.ts} +1 -1
- package/lib/antigravity-plugin/lib/integrations/hosts/claude/adapter.js +36 -0
- package/lib/antigravity-plugin/lib/integrations/hosts/codex/adapter.d.ts +2 -0
- package/lib/antigravity-plugin/lib/integrations/hosts/codex/adapter.js +14 -0
- package/lib/{integrations → antigravity-plugin/lib/integrations/hosts}/dsh/mcp.d.ts +1 -1
- package/lib/{integrations → antigravity-plugin/lib/integrations/hosts}/dsh/resources.d.ts +1 -1
- package/lib/{integrations → antigravity-plugin/lib/integrations/hosts}/dsh/resources.js +4 -4
- package/lib/{integrations → antigravity-plugin/lib/integrations/hosts}/dsh/skills.js +1 -1
- package/lib/antigravity-plugin/lib/integrations/hosts/pi/agent-tools.d.ts +3 -0
- package/lib/antigravity-plugin/lib/integrations/hosts/pi/agent-tools.js +32 -0
- package/lib/antigravity-plugin/lib/integrations/hosts/pi/mcp.d.ts +4 -0
- package/lib/antigravity-plugin/lib/integrations/hosts/pi/mcp.js +23 -0
- package/lib/antigravity-plugin/lib/integrations/hosts/{registry.d.ts → plugin-registry.d.ts} +1 -0
- package/lib/{integrations/hosts/registry.js → antigravity-plugin/lib/integrations/hosts/plugin-registry.js} +10 -3
- package/lib/antigravity-plugin/lib/integrations/hosts/prompt-hooks.d.ts +76 -0
- package/lib/antigravity-plugin/lib/integrations/hosts/prompt-hooks.js +76 -0
- package/lib/antigravity-plugin/lib/integrations/hosts/qoder/adapter.d.ts +2 -0
- package/lib/antigravity-plugin/lib/integrations/hosts/qoder/adapter.js +16 -0
- package/lib/antigravity-plugin/lib/model/acp.d.ts +7 -3
- package/lib/antigravity-plugin/lib/model/acp.js +8 -0
- package/lib/antigravity-plugin/lib/model/agent.d.ts +121 -0
- package/lib/antigravity-plugin/lib/model/agent.js +4 -0
- package/lib/antigravity-plugin/lib/model/history.d.ts +179 -0
- package/lib/antigravity-plugin/lib/model/history.js +4 -0
- package/lib/antigravity-plugin/lib/model/plugin-host.d.ts +31 -0
- package/lib/antigravity-plugin/lib/model/workspace-config.d.ts +28 -7
- package/lib/antigravity-plugin/lib/model/workspace-config.js +2 -1
- package/lib/antigravity-plugin/lib/plugin.d.ts +2 -1
- package/lib/antigravity-plugin/lib/plugin.js +4 -4
- package/lib/antigravity-plugin/lib/services/history/history-capture.d.ts +4 -0
- package/lib/antigravity-plugin/lib/services/history/history-capture.js +98 -0
- package/lib/antigravity-plugin/lib/services/history/history-index.d.ts +17 -0
- package/lib/antigravity-plugin/lib/services/history/history-index.js +112 -0
- package/lib/antigravity-plugin/lib/services/history/summary-dimensions/monthly.d.ts +7 -0
- package/lib/antigravity-plugin/lib/services/history/summary-dimensions/monthly.js +121 -0
- package/lib/antigravity-plugin/lib/services/history/summary-dimensions/session.d.ts +7 -0
- package/lib/antigravity-plugin/lib/services/history/summary-dimensions/session.js +124 -0
- package/lib/antigravity-plugin/lib/services/history/summary-registry.d.ts +7 -0
- package/lib/antigravity-plugin/lib/services/history/summary-registry.js +35 -0
- package/lib/antigravity-plugin/lib/services/history/summary-runner.d.ts +34 -0
- package/lib/antigravity-plugin/lib/services/history/summary-runner.js +299 -0
- package/lib/antigravity-plugin/lib/services/history/workspace-history.d.ts +3 -0
- package/lib/antigravity-plugin/lib/services/history/workspace-history.js +6 -0
- package/lib/antigravity-plugin/lib/services/workspace/plugin-releases.d.ts +3 -0
- package/lib/antigravity-plugin/lib/services/workspace/plugin-releases.js +78 -0
- package/lib/antigravity-plugin/lib/services/workspace/workspace-config.d.ts +5 -1
- package/lib/antigravity-plugin/lib/services/workspace/workspace-config.js +77 -7
- package/lib/antigravity-plugin/lib/services/workspace/workspace-files.d.ts +2 -0
- package/lib/antigravity-plugin/lib/services/workspace/workspace-files.js +17 -0
- package/lib/antigravity-plugin/lib/services/workspace/workspace-mcp.d.ts +14 -0
- package/lib/antigravity-plugin/lib/services/workspace/workspace-mcp.js +193 -0
- package/lib/antigravity-plugin/lib/services/workspace/workspace-skills.d.ts +1 -0
- package/lib/antigravity-plugin/lib/services/workspace/workspace-skills.js +4 -2
- package/lib/antigravity-plugin/lib/storage/acp-files.d.ts +11 -0
- package/lib/antigravity-plugin/lib/storage/acp-files.js +75 -0
- package/lib/antigravity-plugin/lib/storage/agent-files.d.ts +31 -0
- package/lib/antigravity-plugin/lib/storage/agent-files.js +159 -0
- package/lib/antigravity-plugin/lib/storage/atomic-json.d.ts +3 -1
- package/lib/antigravity-plugin/lib/storage/atomic-json.js +43 -3
- package/lib/antigravity-plugin/lib/storage/file-access.d.ts +2 -0
- package/lib/antigravity-plugin/lib/storage/file-access.js +26 -0
- package/lib/antigravity-plugin/lib/storage/history-files.d.ts +55 -0
- package/lib/antigravity-plugin/lib/storage/history-files.js +473 -0
- package/lib/antigravity-plugin/lib/storage/history-format.d.ts +5 -0
- package/lib/antigravity-plugin/lib/storage/history-format.js +60 -0
- package/lib/antigravity-plugin/package.json +1 -1
- package/lib/antigravity-plugin/plugin.json +1 -1
- package/lib/antigravity-plugin/resources/prompts/history-monthly-summary.md +13 -0
- package/lib/antigravity-plugin/resources/prompts/history-summary.md +13 -0
- package/lib/antigravity-plugin/resources/prompts/plugin-coordinator.md +1 -0
- package/lib/antigravity-plugin/resources/skills/.claude-plugin/plugin.json +4 -0
- package/lib/antigravity-plugin/resources/skills/project-maintenance/SKILL.md +35 -0
- package/lib/antigravity-plugin/resources/skills/provider-connections/SKILL.md +52 -0
- package/lib/antigravity-plugin/skills/pbot/SKILL.md +11 -1
- package/lib/antigravity-plugin/skills/provider-connections/SKILL.md +22 -12
- package/lib/claude.js +2 -2
- package/lib/client.js +42 -60
- package/lib/codex-marketplace/.agents/plugins/marketplace.json +17 -0
- package/lib/codex-marketplace/plugins/personal-bot/.codex-plugin/plugin.json +7 -0
- package/lib/codex-marketplace/plugins/personal-bot/.mcp.json +17 -0
- package/lib/codex-marketplace/plugins/personal-bot/DISCLAIMER.md +17 -0
- package/lib/codex-marketplace/plugins/personal-bot/LICENSE +21 -0
- package/lib/codex-marketplace/plugins/personal-bot/hooks/hooks.json +37 -0
- package/lib/codex-marketplace/plugins/personal-bot/skills/pbot/SKILL.md +9 -0
- package/lib/codex-marketplace/plugins/personal-bot/skills/pbot/agents/openai.yaml +2 -0
- package/lib/common/validation.d.ts +4 -0
- package/lib/common/validation.js +8 -0
- package/lib/dsh.js +6 -6
- package/lib/extension/acp/member.d.ts +18 -0
- package/lib/extension/acp/member.js +44 -0
- package/lib/extension/acp/worker.js +384 -0
- package/lib/extension/acp-worker.js +222 -51
- package/lib/extension/history/command.d.ts +37 -0
- package/lib/extension/history/command.js +57 -0
- package/lib/extension/hosts/dsh/acp-entry.d.ts +1 -0
- package/lib/extension/hosts/dsh/acp-entry.js +22 -0
- package/lib/extension/hosts/dsh/acp-member.d.ts +4 -0
- package/lib/extension/hosts/dsh/acp-member.js +58 -0
- package/lib/extension/{dsh → hosts/dsh}/command.d.ts +1 -2
- package/lib/extension/{dsh → hosts/dsh}/command.js +9 -11
- package/lib/extension/hosts/dsh/files.d.ts +5 -0
- package/lib/extension/hosts/dsh/files.js +67 -0
- package/lib/extension/hosts/dsh/history.d.ts +4 -0
- package/lib/extension/hosts/dsh/history.js +62 -0
- package/lib/extension/{dsh → hosts/dsh}/management.d.ts +1 -1
- package/lib/extension/{dsh → hosts/dsh}/management.js +12 -10
- package/lib/extension/{dsh → hosts/dsh}/workspace.d.ts +3 -9
- package/lib/extension/{dsh → hosts/dsh}/workspace.js +30 -99
- package/lib/extension/hosts/pi/acp-member.d.ts +3 -0
- package/lib/extension/hosts/pi/acp-member.js +100 -0
- package/lib/extension/hosts/plugin-runtime.d.ts +12 -0
- package/lib/extension/hosts/plugin-runtime.js +101 -0
- package/lib/extension/hosts/workspace-mcp.d.ts +6 -0
- package/lib/extension/hosts/workspace-mcp.js +21 -0
- package/lib/extension/{mcp-bridge.d.ts → mcp/bridge.d.ts} +7 -9
- package/lib/extension/{mcp-bridge.js → mcp/bridge.js} +70 -88
- package/lib/extension/{mcp-workers.d.ts → mcp/tool-contract.d.ts} +129 -374
- package/lib/extension/mcp/tool-contract.js +441 -0
- package/lib/extension/mcp/workers.d.ts +487 -0
- package/lib/extension/mcp/workers.js +598 -0
- package/lib/extension/mcp.js +2705 -1348
- package/lib/extension/{setup-cli.js → setup/cli.js} +12 -9
- package/lib/extension/workspace-cli.js +20127 -0
- package/lib/integrations/acp/agents.d.ts +2 -3
- package/lib/integrations/acp/connection.d.ts +11 -10
- package/lib/integrations/acp/connection.js +6 -0
- package/lib/integrations/acp/harnesses/claude.js +1 -1
- package/lib/integrations/acp/harnesses/dsh.js +1 -1
- package/lib/integrations/acp/harnesses/presets.js +8 -0
- package/lib/integrations/acp/history-summary.d.ts +17 -0
- package/lib/integrations/acp/history-summary.js +101 -0
- package/lib/integrations/acp/launch.d.ts +2 -2
- package/lib/integrations/agent-resources.d.ts +1 -0
- package/lib/integrations/agent-resources.js +6 -2
- package/lib/integrations/hosts/antigravity/adapter.d.ts +6 -0
- package/lib/integrations/hosts/antigravity/adapter.js +171 -0
- package/lib/integrations/hosts/{claude.d.ts → claude/adapter.d.ts} +1 -1
- package/lib/integrations/hosts/claude/adapter.js +36 -0
- package/lib/integrations/hosts/codex/adapter.d.ts +2 -0
- package/lib/integrations/hosts/codex/adapter.js +14 -0
- package/lib/integrations/hosts/dsh/mcp.d.ts +4 -0
- package/lib/integrations/hosts/dsh/mcp.js +28 -0
- package/lib/integrations/hosts/dsh/messages.d.ts +36 -0
- package/lib/integrations/hosts/dsh/messages.js +11 -0
- package/lib/integrations/hosts/dsh/resources.d.ts +6 -0
- package/lib/integrations/hosts/dsh/resources.js +47 -0
- package/lib/integrations/hosts/dsh/root-agents.d.ts +4 -0
- package/lib/integrations/hosts/dsh/root-agents.js +3 -0
- package/lib/integrations/{dsh → hosts/dsh}/schema.js +1 -1
- package/lib/integrations/hosts/dsh/skills.d.ts +8 -0
- package/lib/integrations/hosts/dsh/skills.js +31 -0
- package/lib/integrations/hosts/pi/agent-tools.d.ts +3 -0
- package/lib/integrations/hosts/pi/agent-tools.js +32 -0
- package/lib/integrations/hosts/pi/mcp.d.ts +4 -0
- package/lib/integrations/hosts/pi/mcp.js +23 -0
- package/lib/integrations/hosts/{registry.d.ts → plugin-registry.d.ts} +1 -0
- package/lib/{antigravity-plugin/lib/integrations/hosts/registry.js → integrations/hosts/plugin-registry.js} +10 -3
- package/lib/integrations/hosts/prompt-hooks.d.ts +76 -0
- package/lib/integrations/hosts/prompt-hooks.js +76 -0
- package/lib/integrations/hosts/qoder/adapter.d.ts +2 -0
- package/lib/integrations/hosts/qoder/adapter.js +16 -0
- package/lib/integrations/installation/pi-setup.js +1 -1
- package/lib/model/acp.d.ts +7 -3
- package/lib/model/acp.js +8 -0
- package/lib/model/agent.d.ts +18 -4
- package/lib/model/agent.js +4 -1
- package/lib/model/history.d.ts +143 -34
- package/lib/model/history.js +4 -1
- package/lib/model/installation.js +1 -0
- package/lib/model/plugin-host.d.ts +31 -0
- package/lib/model/workspace-config.d.ts +28 -7
- package/lib/model/workspace-config.js +2 -1
- package/lib/plugin.d.ts +2 -1
- package/lib/plugin.js +4 -4
- package/lib/qoder-plugin/.mcp.json +17 -0
- package/lib/qoder-plugin/.qoder-plugin/plugin.json +7 -0
- package/lib/qoder-plugin/DISCLAIMER.md +17 -0
- package/lib/qoder-plugin/LICENSE +21 -0
- package/lib/qoder-plugin/hooks/hooks.json +37 -0
- package/lib/qoder-plugin/skills/pbot/SKILL.md +9 -0
- package/lib/services/agents/agent-run.d.ts +1 -1
- package/lib/services/agents/agent-service.d.ts +15 -45
- package/lib/services/agents/agent-service.js +22 -3
- package/lib/services/history/history-capture.d.ts +4 -0
- package/lib/services/history/history-capture.js +98 -0
- package/lib/services/history/history-index.d.ts +16 -7
- package/lib/services/history/history-index.js +48 -70
- package/lib/services/history/history-migrate.d.ts +12 -0
- package/lib/services/history/history-migrate.js +54 -0
- package/lib/services/history/history-query.d.ts +51 -0
- package/lib/services/history/history-query.js +352 -0
- package/lib/services/history/summary-command.d.ts +20 -0
- package/lib/services/history/summary-command.js +69 -0
- package/lib/services/history/summary-dimensions/monthly.d.ts +7 -0
- package/lib/services/history/summary-dimensions/monthly.js +121 -0
- package/lib/services/history/summary-dimensions/session.d.ts +7 -0
- package/lib/services/history/summary-dimensions/session.js +124 -0
- package/lib/services/history/summary-registry.d.ts +7 -0
- package/lib/services/history/summary-registry.js +35 -0
- package/lib/services/history/summary-runner.d.ts +34 -0
- package/lib/services/history/summary-runner.js +299 -0
- package/lib/services/history/workspace-history.d.ts +3 -0
- package/lib/services/history/workspace-history.js +6 -0
- package/lib/services/workspace/plugin-releases.d.ts +3 -0
- package/lib/services/workspace/plugin-releases.js +78 -0
- package/lib/services/workspace/workspace-config.d.ts +5 -1
- package/lib/services/workspace/workspace-config.js +77 -7
- package/lib/services/workspace/workspace-mcp.js +22 -29
- package/lib/services/workspace/workspace-skills.d.ts +1 -0
- package/lib/services/workspace/workspace-skills.js +4 -2
- package/lib/storage/acp-files.js +7 -12
- package/lib/storage/agent-files.js +6 -5
- package/lib/storage/atomic-json.d.ts +3 -1
- package/lib/storage/atomic-json.js +43 -3
- package/lib/storage/history-files.d.ts +46 -9
- package/lib/storage/history-files.js +382 -250
- package/lib/storage/history-format.d.ts +3 -13
- package/lib/storage/history-format.js +26 -52
- package/lib/tools/history/actions.d.ts +3 -68
- package/lib/tools/history/actions.js +7 -5
- package/lib/tools/history/contract.d.ts +16 -17
- package/lib/tools/history/contract.js +63 -22
- package/lib/tools/history/dsh-tool.d.ts +1 -2
- package/lib/tools/history/dsh-tool.js +11 -5
- package/lib/ui/dsh/elements.d.ts +2 -5
- package/lib/ui/dsh/elements.js +3 -16
- package/lib/ui/dsh/management.js +26 -13
- package/lib/ui/dsh/styles.d.ts +1 -1
- package/lib/ui/dsh/styles.js +5 -33
- package/package.json +4 -1
- package/resources/antigravity/skills/pbot/SKILL.md +11 -1
- package/resources/claude/skills/pbot/SKILL.md +11 -1
- package/resources/plugin/skills/pbot/SKILL.md +9 -0
- package/resources/prompts/history-coordinator.md +2 -1
- package/resources/prompts/history-monthly-summary.md +13 -0
- package/resources/prompts/history-summary.md +10 -4
- package/resources/prompts/plugin-coordinator.md +1 -0
- package/resources/skills/provider-connections/SKILL.md +22 -12
- package/scripts/README.md +3 -2
- package/src/claude.ts +2 -2
- package/src/common/validation.ts +10 -0
- package/src/dsh.ts +6 -6
- package/src/extension/{acp-member.ts → acp/member.ts} +7 -7
- package/src/extension/{acp-worker.ts → acp/worker.ts} +131 -17
- package/src/extension/history/command.ts +68 -0
- package/src/extension/hosts/dsh/acp-entry.ts +21 -0
- package/src/extension/{dsh → hosts/dsh}/acp-member.ts +12 -23
- package/src/extension/{dsh → hosts/dsh}/command.ts +10 -12
- package/src/extension/{dsh → hosts/dsh}/files.ts +3 -3
- package/src/extension/hosts/dsh/history.ts +67 -0
- package/src/extension/{dsh → hosts/dsh}/management.ts +11 -9
- package/src/extension/{dsh → hosts/dsh}/workspace.ts +31 -76
- package/src/extension/{pi-acp-member.ts → hosts/pi/acp-member.ts} +12 -18
- package/src/extension/{command.ts → hosts/pi/command.ts} +44 -11
- package/src/extension/{events.ts → hosts/pi/events.ts} +8 -4
- package/src/extension/hosts/pi/history.ts +45 -0
- package/src/extension/{lifecycle.ts → hosts/pi/lifecycle.ts} +9 -12
- package/src/extension/hosts/plugin-runtime.ts +96 -0
- package/src/extension/hosts/workspace-mcp.ts +25 -0
- package/src/extension/{mcp-bridge.ts → mcp/bridge.ts} +85 -85
- package/src/extension/mcp/tool-contract.ts +462 -0
- package/src/extension/{mcp-workers.ts → mcp/workers.ts} +151 -448
- package/src/extension/{setup-cli.ts → setup/cli.ts} +14 -11
- package/src/extension/setup/workspace-cli.ts +159 -0
- package/src/integrations/acp/agents.ts +2 -3
- package/src/integrations/acp/connection.ts +6 -0
- package/src/integrations/acp/harnesses/claude.ts +1 -1
- package/src/integrations/acp/harnesses/dsh.ts +1 -1
- package/src/integrations/acp/harnesses/presets.ts +8 -0
- package/src/integrations/acp/history-summary.ts +109 -0
- package/src/integrations/agent-resources.ts +7 -1
- package/src/integrations/hosts/antigravity/adapter.ts +161 -0
- package/src/integrations/hosts/claude/adapter.ts +39 -0
- package/src/integrations/hosts/codex/adapter.ts +16 -0
- package/src/integrations/{dsh → hosts/dsh}/mcp.ts +1 -1
- package/src/integrations/{dsh → hosts/dsh}/resources.ts +5 -5
- package/src/integrations/{dsh → hosts/dsh}/schema.ts +1 -1
- package/src/integrations/{dsh → hosts/dsh}/session.ts +2 -2
- package/src/integrations/{dsh → hosts/dsh}/skills.ts +1 -1
- package/src/integrations/{pi → hosts/pi}/mcp.ts +1 -1
- package/src/integrations/{pi → hosts/pi}/skills.ts +1 -1
- package/src/integrations/hosts/{registry.ts → plugin-registry.ts} +11 -3
- package/src/integrations/hosts/prompt-hooks.ts +72 -0
- package/src/integrations/hosts/qoder/adapter.ts +19 -0
- package/src/integrations/installation/cli-update.ts +116 -0
- package/src/integrations/installation/pi-bridge.ts +1 -1
- package/src/integrations/installation/pi-setup.ts +2 -2
- package/src/integrations/installation/processes.ts +1 -1
- package/src/mcp.ts +1 -1
- package/src/model/acp.ts +11 -3
- package/src/model/agent.ts +20 -4
- package/src/model/history.ts +156 -26
- package/src/model/installation.ts +41 -0
- package/src/model/plugin-host.ts +30 -2
- package/src/model/workspace-config.ts +31 -7
- package/src/pbot.ts +22 -50
- package/src/plugin.ts +4 -4
- package/src/services/agents/agent-service.ts +29 -17
- package/src/services/history/history-capture.ts +91 -0
- package/src/services/history/history-index.ts +48 -62
- package/src/services/history/history-migrate.ts +62 -0
- package/src/services/history/history-query.ts +401 -0
- package/src/services/history/summary-command.ts +70 -0
- package/src/services/history/summary-dimensions/monthly.ts +139 -0
- package/src/services/history/summary-dimensions/session.ts +149 -0
- package/src/services/history/summary-registry.ts +43 -0
- package/src/services/history/summary-runner.ts +343 -0
- package/src/services/history/workspace-history.ts +8 -0
- package/src/services/installation/setup-service.ts +2 -41
- package/src/services/workspace/plugin-releases.ts +68 -0
- package/src/services/workspace/workspace-config.ts +95 -8
- package/src/services/workspace/workspace-mcp.ts +23 -28
- package/src/services/workspace/workspace-skills.ts +5 -2
- package/src/storage/acp-files.ts +7 -12
- package/src/storage/agent-files.ts +6 -5
- package/src/storage/atomic-json.ts +31 -4
- package/src/storage/history-files.ts +416 -189
- package/src/storage/history-format.ts +45 -61
- package/src/tools/history/actions.ts +8 -6
- package/src/tools/history/contract.ts +70 -25
- package/src/tools/history/dsh-tool.ts +17 -8
- package/src/tools/history/pi-tool.ts +23 -0
- package/src/ui/dsh/elements.ts +5 -12
- package/src/ui/dsh/management.ts +36 -20
- package/src/ui/dsh/styles.ts +5 -33
- package/src/ui/{confirmation.ts → pi/confirmation.ts} +1 -1
- package/lib/antigravity-plugin/lib/extension/plugin-runtime.d.ts +0 -10
- package/lib/antigravity-plugin/lib/extension/plugin-runtime.js +0 -67
- package/lib/antigravity-plugin/lib/integrations/hosts/antigravity.d.ts +0 -4
- package/lib/antigravity-plugin/lib/integrations/hosts/antigravity.js +0 -79
- package/lib/antigravity-plugin/lib/integrations/hosts/claude.js +0 -60
- package/lib/extension/dsh/history.d.ts +0 -15
- package/lib/extension/dsh/history.js +0 -87
- package/lib/extension/mcp-workers.js +0 -882
- package/lib/extension/plugin-runtime.d.ts +0 -10
- package/lib/extension/plugin-runtime.js +0 -67
- package/lib/integrations/dsh/history-summary.d.ts +0 -11
- package/lib/integrations/dsh/history-summary.js +0 -36
- package/lib/integrations/dsh/history.d.ts +0 -16
- package/lib/integrations/dsh/history.js +0 -167
- package/lib/integrations/history-summary.d.ts +0 -4
- package/lib/integrations/history-summary.js +0 -32
- package/lib/integrations/hosts/antigravity.d.ts +0 -4
- package/lib/integrations/hosts/antigravity.js +0 -79
- package/lib/integrations/hosts/claude.js +0 -60
- package/lib/services/history/history-service.d.ts +0 -106
- package/lib/services/history/history-service.js +0 -242
- package/lib/storage/acp-history.d.ts +0 -10
- package/lib/storage/acp-history.js +0 -57
- package/lib/ui/presentation.d.ts +0 -3
- package/lib/ui/presentation.js +0 -12
- package/src/extension/dsh/history.ts +0 -74
- package/src/extension/history.ts +0 -26
- package/src/extension/plugin-runtime.ts +0 -63
- package/src/integrations/dsh/history-summary.ts +0 -39
- package/src/integrations/dsh/history.ts +0 -84
- package/src/integrations/history-summary.ts +0 -30
- package/src/integrations/hosts/antigravity.ts +0 -83
- package/src/integrations/hosts/claude.ts +0 -62
- package/src/integrations/pi/history.ts +0 -99
- package/src/services/history/history-service.ts +0 -195
- package/src/storage/acp-history.ts +0 -49
- package/src/tools/access.ts +0 -7
- package/src/tools/history/tool.ts +0 -19
- package/src/tools/register.ts +0 -22
- package/src/ui/presentation.ts +0 -12
- /package/lib/{extension → antigravity-plugin/lib/extension/hosts}/dsh/acp-member.d.ts +0 -0
- /package/lib/{extension → antigravity-plugin/lib/extension/hosts}/dsh/files.d.ts +0 -0
- /package/lib/{integrations → antigravity-plugin/lib/integrations/hosts}/dsh/mcp.js +0 -0
- /package/lib/{integrations → antigravity-plugin/lib/integrations/hosts}/dsh/messages.d.ts +0 -0
- /package/lib/{integrations → antigravity-plugin/lib/integrations/hosts}/dsh/messages.js +0 -0
- /package/lib/{integrations → antigravity-plugin/lib/integrations/hosts}/dsh/root-agents.d.ts +0 -0
- /package/lib/{integrations → antigravity-plugin/lib/integrations/hosts}/dsh/root-agents.js +0 -0
- /package/lib/{integrations → antigravity-plugin/lib/integrations/hosts}/dsh/skills.d.ts +0 -0
- /package/lib/extension/{acp-worker.d.ts → acp/worker.d.ts} +0 -0
- /package/lib/extension/{setup-guard.js → setup/guard.js} +0 -0
- /package/lib/integrations/acp/{claude.d.ts → claude-settings.d.ts} +0 -0
- /package/lib/integrations/acp/{claude.js → claude-settings.js} +0 -0
- /package/lib/integrations/{dsh → hosts/dsh}/schema.d.ts +0 -0
- /package/src/extension/{setup-guard.ts → setup/guard.ts} +0 -0
- /package/src/integrations/acp/{claude.ts → claude-settings.ts} +0 -0
- /package/src/integrations/{dsh → hosts/dsh}/messages.ts +0 -0
- /package/src/integrations/{dsh → hosts/dsh}/root-agents.ts +0 -0
- /package/src/integrations/{pi → hosts/pi}/agent-tools.ts +0 -0
|
@@ -0,0 +1,441 @@
|
|
|
1
|
+
import { object } from "../../common/json.js";
|
|
2
|
+
import { requireThat } from "../../common/validation.js";
|
|
3
|
+
import { inspectAcpBackends } from "../../integrations/acp/launch.js";
|
|
4
|
+
import { historyPageLimits } from "../../model/history.js";
|
|
5
|
+
import { acpElicitationActions } from "../../model/acp.js";
|
|
6
|
+
export const defaultWaitMs = 50_000;
|
|
7
|
+
export const maxWaitMs = 600_000;
|
|
8
|
+
export const discoverTargets = ["overview", "workers", "backends", "models"];
|
|
9
|
+
function formatBackendItem(entry, defaultBackend) {
|
|
10
|
+
const tags = [];
|
|
11
|
+
if (entry.label)
|
|
12
|
+
tags.push(entry.label);
|
|
13
|
+
if (entry.backend === defaultBackend)
|
|
14
|
+
tags.push("当前");
|
|
15
|
+
return tags.length ? `${entry.backend}(${tags.join(",")})` : entry.backend;
|
|
16
|
+
}
|
|
17
|
+
function summarizeBackends(commands = {}, defaultBackend) {
|
|
18
|
+
const entries = inspectAcpBackends(commands);
|
|
19
|
+
const available = entries.filter(item => item.available);
|
|
20
|
+
const unavailable = entries.filter(item => !item.available);
|
|
21
|
+
const availableText = available.map(item => formatBackendItem(item, defaultBackend)).join("、");
|
|
22
|
+
const unavailableText = unavailable.map(item => formatBackendItem(item, defaultBackend)).join("、");
|
|
23
|
+
const overview = available.length
|
|
24
|
+
? unavailable.length
|
|
25
|
+
? `当前可用助手:${availableText};暂不可用:${unavailableText}。`
|
|
26
|
+
: `当前可用助手:${availableText}。`
|
|
27
|
+
: `当前无可用外部助手(暂不可用:${unavailableText})。`;
|
|
28
|
+
const availableIds = available.map(item => item.backend).join("、");
|
|
29
|
+
return { overview, availableIds };
|
|
30
|
+
}
|
|
31
|
+
function workspaceProperty(workspaceBound) {
|
|
32
|
+
return {
|
|
33
|
+
type: "string",
|
|
34
|
+
description: workspaceBound
|
|
35
|
+
? "目标工作区根目录的绝对路径;默认使用当前工作区,通常省略。"
|
|
36
|
+
: "目标工作区根目录的绝对路径(如上下文中提供了 workspaceRoot 则传该路径);请显式传入。",
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
export function buildPbotWorkerTools(commands = {}, defaultBackend, workspaceBound = false) {
|
|
40
|
+
const { overview, availableIds } = summarizeBackends(commands, defaultBackend);
|
|
41
|
+
const modelsBackendHint = defaultBackend
|
|
42
|
+
? `省略时默认查 ${defaultBackend}`
|
|
43
|
+
: "必填";
|
|
44
|
+
const workspace = workspaceProperty(workspaceBound);
|
|
45
|
+
return [
|
|
46
|
+
{
|
|
47
|
+
name: "worker_create",
|
|
48
|
+
description: "启动一个独立的外部 AI 助手会话(worker),用于将任务委派给其他助手或指定模型/思考深度来独立处理(如按用户要求切换助手、获取独立审查或第二意见、并行分担子任务)。" +
|
|
49
|
+
"本工具仅建立会话并返回 workerId,随后通过 worker_request 发送具体任务。不需要借助其他助手时,优先自行完成或使用当前内置子代理。\n" +
|
|
50
|
+
overview,
|
|
51
|
+
annotations: {
|
|
52
|
+
title: "Create Worker",
|
|
53
|
+
readOnlyHint: false,
|
|
54
|
+
destructiveHint: false,
|
|
55
|
+
idempotentHint: false,
|
|
56
|
+
openWorldHint: true,
|
|
57
|
+
},
|
|
58
|
+
inputSchema: {
|
|
59
|
+
type: "object",
|
|
60
|
+
additionalProperties: false,
|
|
61
|
+
required: ["backend"],
|
|
62
|
+
properties: {
|
|
63
|
+
backend: {
|
|
64
|
+
type: "string",
|
|
65
|
+
description: "要启动的外部助手标识(不区分大小写,支持常见别名,如 claude-code、agy)。",
|
|
66
|
+
},
|
|
67
|
+
model: {
|
|
68
|
+
type: "string",
|
|
69
|
+
description: "仅用户明确要求特定模型时指定(支持模型 ID、显示名或 provider/model,不区分大小写);不确定可用值时先用 worker_discover(target=\"models\") 查询;不填则使用该助手默认模型。",
|
|
70
|
+
},
|
|
71
|
+
thinking: {
|
|
72
|
+
type: "string",
|
|
73
|
+
description: "仅用户明确要求思考深度时指定(如 low / medium / high / xhigh / max,不区分大小写);不填则使用默认设置。",
|
|
74
|
+
},
|
|
75
|
+
cwd: {
|
|
76
|
+
type: "string",
|
|
77
|
+
description: "助手执行任务时的工作目录(绝对路径或相对工作区的路径),默认为当前工作区根目录。",
|
|
78
|
+
},
|
|
79
|
+
workspace,
|
|
80
|
+
},
|
|
81
|
+
},
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
name: "worker_close",
|
|
85
|
+
description: "结束不再需要的外部助手会话并释放资源。若该助手支持会话恢复,后续仍可直接用 worker_request 在原上下文中继续对话。",
|
|
86
|
+
annotations: {
|
|
87
|
+
title: "Close Worker",
|
|
88
|
+
readOnlyHint: false,
|
|
89
|
+
destructiveHint: true,
|
|
90
|
+
idempotentHint: true,
|
|
91
|
+
openWorldHint: false,
|
|
92
|
+
},
|
|
93
|
+
inputSchema: {
|
|
94
|
+
type: "object",
|
|
95
|
+
additionalProperties: false,
|
|
96
|
+
required: ["workerId"],
|
|
97
|
+
properties: {
|
|
98
|
+
workerId: {
|
|
99
|
+
type: "string",
|
|
100
|
+
description: "要结束的助手会话 ID(来自 worker_create 或 worker_discover)。",
|
|
101
|
+
},
|
|
102
|
+
workspace,
|
|
103
|
+
},
|
|
104
|
+
},
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
name: "worker_request",
|
|
108
|
+
description: "向指定的外部助手派发任务,或在同一上下文中追问与补充要求,并获取执行结果(已关闭但支持恢复的会话会自动续接)。" +
|
|
109
|
+
`默认最多等待 ${defaultWaitMs / 1000} 秒返回结果;将 waitMs 设为 0 可立即返回并转入后台执行,适合耗时任务或多助手并行。` +
|
|
110
|
+
"若返回 timedOut 或结果含 nextOffset,用 worker_output 继续等待或翻页;若返回 needsResponse,先向用户确认再用 worker_response 回复。",
|
|
111
|
+
annotations: {
|
|
112
|
+
title: "Send Request to Worker",
|
|
113
|
+
readOnlyHint: false,
|
|
114
|
+
destructiveHint: false,
|
|
115
|
+
idempotentHint: false,
|
|
116
|
+
openWorldHint: true,
|
|
117
|
+
},
|
|
118
|
+
inputSchema: {
|
|
119
|
+
type: "object",
|
|
120
|
+
additionalProperties: false,
|
|
121
|
+
required: ["workerId", "message"],
|
|
122
|
+
properties: {
|
|
123
|
+
workerId: {
|
|
124
|
+
type: "string",
|
|
125
|
+
description: "目标助手会话 ID(来自 worker_create 或 worker_discover)。",
|
|
126
|
+
},
|
|
127
|
+
message: {
|
|
128
|
+
type: "string",
|
|
129
|
+
description: "要发送的任务说明或追问内容。外部助手看不到你与用户的对话历史,首次派发时请写清背景、目标、相关文件路径、约束条件和期望产出。",
|
|
130
|
+
},
|
|
131
|
+
waitMs: {
|
|
132
|
+
type: "integer",
|
|
133
|
+
minimum: 0,
|
|
134
|
+
maximum: maxWaitMs,
|
|
135
|
+
description: `最多等待结果的毫秒数(默认 ${defaultWaitMs});设为 0 可立即返回并在后台执行。`,
|
|
136
|
+
},
|
|
137
|
+
workspace,
|
|
138
|
+
},
|
|
139
|
+
},
|
|
140
|
+
},
|
|
141
|
+
{
|
|
142
|
+
name: "worker_response",
|
|
143
|
+
description: "当外部助手在执行过程中暂停并请求确认或补充信息(返回 needsResponse: true)时,向其提交决定以继续执行。" +
|
|
144
|
+
"支持三类请求:操作授权(kind=\"permission\")、问答表单(kind=\"form\")和链接确认(kind=\"url\")。" +
|
|
145
|
+
`提交前先向用户确认;提交后默认最多等待 ${defaultWaitMs / 1000} 秒返回后续结果(waitMs 设为 0 立即返回)。`,
|
|
146
|
+
annotations: {
|
|
147
|
+
title: "Respond to Worker Request",
|
|
148
|
+
readOnlyHint: false,
|
|
149
|
+
destructiveHint: false,
|
|
150
|
+
idempotentHint: false,
|
|
151
|
+
openWorldHint: true,
|
|
152
|
+
},
|
|
153
|
+
inputSchema: {
|
|
154
|
+
type: "object",
|
|
155
|
+
additionalProperties: false,
|
|
156
|
+
required: ["workerId", "action"],
|
|
157
|
+
properties: {
|
|
158
|
+
workerId: {
|
|
159
|
+
type: "string",
|
|
160
|
+
description: "等待回复的助手会话 ID。",
|
|
161
|
+
},
|
|
162
|
+
action: {
|
|
163
|
+
type: "string",
|
|
164
|
+
enum: [...acpElicitationActions],
|
|
165
|
+
description: "处理方式:accept 表示同意授权、提交表单回答或确认链接;decline 表示拒绝;cancel 表示取消本次请求。",
|
|
166
|
+
},
|
|
167
|
+
requestId: {
|
|
168
|
+
type: "string",
|
|
169
|
+
description: "要回复的请求 ID(来自 pendingRequests[].requestId);仅一条待处理请求时可省略,多条时必填。",
|
|
170
|
+
},
|
|
171
|
+
optionId: {
|
|
172
|
+
type: "string",
|
|
173
|
+
description: "仅授权请求(kind=\"permission\")且 action 不为 cancel 时可用:指定选项 ID(来自 pendingRequests[].options[].optionId),省略时默认单次允许或拒绝。",
|
|
174
|
+
},
|
|
175
|
+
content: {
|
|
176
|
+
type: "object",
|
|
177
|
+
additionalProperties: true,
|
|
178
|
+
description: "仅表单提问(kind=\"form\")且 action=\"accept\" 时可用:按 pendingRequests[].schema.properties 填写的回答对象(值为字符串、数字、布尔值或字符串数组)。",
|
|
179
|
+
},
|
|
180
|
+
waitMs: {
|
|
181
|
+
type: "integer",
|
|
182
|
+
minimum: 0,
|
|
183
|
+
maximum: maxWaitMs,
|
|
184
|
+
description: `提交回复后最多等待后续结果的毫秒数(默认 ${defaultWaitMs});设为 0 立即返回。`,
|
|
185
|
+
},
|
|
186
|
+
workspace,
|
|
187
|
+
},
|
|
188
|
+
},
|
|
189
|
+
},
|
|
190
|
+
{
|
|
191
|
+
name: "worker_output",
|
|
192
|
+
description: "获取或等待外部助手的最新执行结果。用于收取后台任务的产出、在等待超时(timedOut)后继续等待,或在长结果分页(含 nextOffset)时读取后续内容。" +
|
|
193
|
+
"任务仍在运行时会等待其完成(也可能返回 timedOut 或 needsResponse),已结束则立即返回。",
|
|
194
|
+
annotations: {
|
|
195
|
+
title: "Get Worker Output",
|
|
196
|
+
readOnlyHint: true,
|
|
197
|
+
destructiveHint: false,
|
|
198
|
+
idempotentHint: true,
|
|
199
|
+
openWorldHint: false,
|
|
200
|
+
},
|
|
201
|
+
inputSchema: {
|
|
202
|
+
type: "object",
|
|
203
|
+
additionalProperties: false,
|
|
204
|
+
required: ["workerId"],
|
|
205
|
+
properties: {
|
|
206
|
+
workerId: {
|
|
207
|
+
type: "string",
|
|
208
|
+
description: "要等待或获取结果的助手会话 ID。",
|
|
209
|
+
},
|
|
210
|
+
offset: {
|
|
211
|
+
type: "integer",
|
|
212
|
+
minimum: 0,
|
|
213
|
+
description: "结果读取起始位置(默认 0);翻页读取剩余内容时传入上次返回的 nextOffset。",
|
|
214
|
+
},
|
|
215
|
+
waitMs: {
|
|
216
|
+
type: "integer",
|
|
217
|
+
minimum: 0,
|
|
218
|
+
maximum: maxWaitMs,
|
|
219
|
+
description: `任务仍在运行时最多等待的毫秒数(默认 ${defaultWaitMs});任务已结束或翻页读取时会立即返回。`,
|
|
220
|
+
},
|
|
221
|
+
workspace,
|
|
222
|
+
},
|
|
223
|
+
},
|
|
224
|
+
},
|
|
225
|
+
{
|
|
226
|
+
name: "worker_discover",
|
|
227
|
+
description: "了解当前可以委派哪些外部助手、查看已有助手会话的运行状态以便复用,或查询某个助手支持的模型与思考深度选项。" +
|
|
228
|
+
"默认(target=\"overview\")同时返回可用助手与已有会话;仅在需要核对模型或思考深度可选值时再查 target=\"models\"(耗时较长)。",
|
|
229
|
+
annotations: {
|
|
230
|
+
title: "Discover Workers, Backends & Models",
|
|
231
|
+
readOnlyHint: true,
|
|
232
|
+
destructiveHint: false,
|
|
233
|
+
idempotentHint: true,
|
|
234
|
+
openWorldHint: false,
|
|
235
|
+
},
|
|
236
|
+
inputSchema: {
|
|
237
|
+
type: "object",
|
|
238
|
+
additionalProperties: false,
|
|
239
|
+
required: [],
|
|
240
|
+
properties: {
|
|
241
|
+
target: {
|
|
242
|
+
type: "string",
|
|
243
|
+
enum: [...discoverTargets],
|
|
244
|
+
description: "查询范围,默认 \"overview\"(同时返回可用助手与已有会话);\"workers\" 查全部或单个会话状态;\"backends\" 查可用助手列表;\"models\" 查指定助手支持的模型与思考深度。",
|
|
245
|
+
},
|
|
246
|
+
workerId: {
|
|
247
|
+
type: "string",
|
|
248
|
+
description: "仅 target=\"workers\" 可用:指定单个助手会话 ID;不填则列出全部。",
|
|
249
|
+
},
|
|
250
|
+
backend: {
|
|
251
|
+
type: "string",
|
|
252
|
+
description: availableIds
|
|
253
|
+
? `仅 target="models" 可用(${modelsBackendHint}):目标外部助手标识,支持常见别名;当前可用:${availableIds}。`
|
|
254
|
+
: `仅 target="models" 可用(${modelsBackendHint}):目标外部助手标识,支持常见别名。`,
|
|
255
|
+
},
|
|
256
|
+
model: {
|
|
257
|
+
type: "string",
|
|
258
|
+
description: "仅 target=\"models\" 可用:指定模型以查看该模型支持的思考深度选项。",
|
|
259
|
+
},
|
|
260
|
+
workspace,
|
|
261
|
+
},
|
|
262
|
+
},
|
|
263
|
+
},
|
|
264
|
+
];
|
|
265
|
+
}
|
|
266
|
+
export function buildWorkspaceMcpTools(workspaceBound = false) {
|
|
267
|
+
const workspace = workspaceProperty(workspaceBound);
|
|
268
|
+
return [
|
|
269
|
+
{
|
|
270
|
+
name: "workspace_mcp_discover",
|
|
271
|
+
description: "发现当前工作区共享的外部工具服务(MCP)及其可用工具。不传 server 时列出可用服务;传入 server 时返回该服务提供的工具清单与参数说明。",
|
|
272
|
+
annotations: {
|
|
273
|
+
title: "Discover Workspace MCP Servers & Tools",
|
|
274
|
+
readOnlyHint: true,
|
|
275
|
+
destructiveHint: false,
|
|
276
|
+
idempotentHint: true,
|
|
277
|
+
openWorldHint: true,
|
|
278
|
+
},
|
|
279
|
+
inputSchema: {
|
|
280
|
+
type: "object",
|
|
281
|
+
additionalProperties: false,
|
|
282
|
+
required: [],
|
|
283
|
+
properties: {
|
|
284
|
+
server: {
|
|
285
|
+
type: "string",
|
|
286
|
+
description: "目标工具服务名称;不填时列出工作区全部可用服务。",
|
|
287
|
+
},
|
|
288
|
+
workspace,
|
|
289
|
+
},
|
|
290
|
+
},
|
|
291
|
+
},
|
|
292
|
+
{
|
|
293
|
+
name: "workspace_mcp_call",
|
|
294
|
+
description: "调用当前工作区共享的外部工具服务(MCP)中的指定工具,用于访问工作区接入的外部能力与数据源。" +
|
|
295
|
+
"不确定工具名或参数格式时,先用 workspace_mcp_discover(server) 查询。",
|
|
296
|
+
annotations: {
|
|
297
|
+
title: "Call Workspace MCP Tool",
|
|
298
|
+
readOnlyHint: false,
|
|
299
|
+
destructiveHint: false,
|
|
300
|
+
idempotentHint: false,
|
|
301
|
+
openWorldHint: true,
|
|
302
|
+
},
|
|
303
|
+
inputSchema: {
|
|
304
|
+
type: "object",
|
|
305
|
+
additionalProperties: false,
|
|
306
|
+
required: ["server", "tool"],
|
|
307
|
+
properties: {
|
|
308
|
+
server: {
|
|
309
|
+
type: "string",
|
|
310
|
+
description: "目标工具服务名称(可通过 workspace_mcp_discover 获取)。",
|
|
311
|
+
},
|
|
312
|
+
tool: {
|
|
313
|
+
type: "string",
|
|
314
|
+
description: "要调用的工具名称。",
|
|
315
|
+
},
|
|
316
|
+
arguments: {
|
|
317
|
+
type: "object",
|
|
318
|
+
additionalProperties: true,
|
|
319
|
+
description: "传给目标工具的参数对象,不填则为空对象。",
|
|
320
|
+
},
|
|
321
|
+
workspace,
|
|
322
|
+
},
|
|
323
|
+
},
|
|
324
|
+
},
|
|
325
|
+
];
|
|
326
|
+
}
|
|
327
|
+
export function buildHistoryMcpTools(workspaceBound = false) {
|
|
328
|
+
const workspace = workspaceProperty(workspaceBound);
|
|
329
|
+
return [
|
|
330
|
+
{
|
|
331
|
+
name: "history_search",
|
|
332
|
+
description: "搜索当前工作区跨宿主(pi、dsh、claude、antigravity 等)的历史问答与摘要归档。省略 query 时列出各会话;传入 query 按不区分大小写的连续关键词匹配原文与摘要。",
|
|
333
|
+
annotations: {
|
|
334
|
+
title: "Search Workspace History",
|
|
335
|
+
readOnlyHint: true,
|
|
336
|
+
destructiveHint: false,
|
|
337
|
+
idempotentHint: true,
|
|
338
|
+
openWorldHint: false,
|
|
339
|
+
},
|
|
340
|
+
inputSchema: {
|
|
341
|
+
type: "object",
|
|
342
|
+
additionalProperties: false,
|
|
343
|
+
required: [],
|
|
344
|
+
properties: {
|
|
345
|
+
host: {
|
|
346
|
+
type: "string",
|
|
347
|
+
description: "可选来源筛选(如 pi、dsh、claude、antigravity);省略查全部宿主。",
|
|
348
|
+
},
|
|
349
|
+
dimension: {
|
|
350
|
+
type: "string",
|
|
351
|
+
description: "可选范围筛选:raw 表示仅搜原文,或指定摘要维度(如 monthly、session);省略查全部原文与维度摘要。",
|
|
352
|
+
},
|
|
353
|
+
query: {
|
|
354
|
+
type: "string",
|
|
355
|
+
description: "不区分大小写的连续关键词;省略时列出各会话(或指定维度摘要)。",
|
|
356
|
+
},
|
|
357
|
+
sessionId: {
|
|
358
|
+
type: "string",
|
|
359
|
+
description: "限定在指定原始会话 ID 内搜索。",
|
|
360
|
+
},
|
|
361
|
+
from: {
|
|
362
|
+
type: "string",
|
|
363
|
+
description: "ISO 日期或时间下界。",
|
|
364
|
+
},
|
|
365
|
+
to: {
|
|
366
|
+
type: "string",
|
|
367
|
+
description: "ISO 日期或时间上界。",
|
|
368
|
+
},
|
|
369
|
+
offset: {
|
|
370
|
+
type: "integer",
|
|
371
|
+
minimum: 0,
|
|
372
|
+
description: "匹配结果偏移,默认 0。",
|
|
373
|
+
},
|
|
374
|
+
limit: {
|
|
375
|
+
type: "integer",
|
|
376
|
+
minimum: 1,
|
|
377
|
+
maximum: historyPageLimits.search.max,
|
|
378
|
+
description: `最多返回条数(1–${historyPageLimits.search.max}),默认 ${historyPageLimits.search.default}。`,
|
|
379
|
+
},
|
|
380
|
+
workspace,
|
|
381
|
+
},
|
|
382
|
+
},
|
|
383
|
+
},
|
|
384
|
+
{
|
|
385
|
+
name: "history_read",
|
|
386
|
+
description: "按节点 id 读取当前工作区历史归档的正文与上下级节点(monthly、session、summary、exchange),支持从月度汇总下钻至单会话摘要与原始问答。正文过长时用 nextOffset 续读,子节点过多时用 nextChildrenOffset 续读。",
|
|
387
|
+
annotations: {
|
|
388
|
+
title: "Read Workspace History Node",
|
|
389
|
+
readOnlyHint: true,
|
|
390
|
+
destructiveHint: false,
|
|
391
|
+
idempotentHint: true,
|
|
392
|
+
openWorldHint: false,
|
|
393
|
+
},
|
|
394
|
+
inputSchema: {
|
|
395
|
+
type: "object",
|
|
396
|
+
additionalProperties: false,
|
|
397
|
+
required: ["id"],
|
|
398
|
+
properties: {
|
|
399
|
+
id: {
|
|
400
|
+
type: "string",
|
|
401
|
+
description: "history_search 或上下级返回的节点 id。",
|
|
402
|
+
},
|
|
403
|
+
host: {
|
|
404
|
+
type: "string",
|
|
405
|
+
description: "跨来源 ID 冲突时显式指定来源宿主。",
|
|
406
|
+
},
|
|
407
|
+
offset: {
|
|
408
|
+
type: "integer",
|
|
409
|
+
minimum: 0,
|
|
410
|
+
description: "正文字符偏移,默认 0。",
|
|
411
|
+
},
|
|
412
|
+
limit: {
|
|
413
|
+
type: "integer",
|
|
414
|
+
minimum: 1,
|
|
415
|
+
maximum: historyPageLimits.read.max,
|
|
416
|
+
description: `正文字符数(1–${historyPageLimits.read.max}),默认 ${historyPageLimits.read.default}。`,
|
|
417
|
+
},
|
|
418
|
+
childrenOffset: {
|
|
419
|
+
type: "integer",
|
|
420
|
+
minimum: 0,
|
|
421
|
+
description: "子节点列表偏移,默认 0;续读传上页 nextChildrenOffset。",
|
|
422
|
+
},
|
|
423
|
+
workspace,
|
|
424
|
+
},
|
|
425
|
+
},
|
|
426
|
+
},
|
|
427
|
+
];
|
|
428
|
+
}
|
|
429
|
+
export const pbotWorkerTools = buildPbotWorkerTools();
|
|
430
|
+
const definitions = [...pbotWorkerTools, ...buildWorkspaceMcpTools(), ...buildHistoryMcpTools()];
|
|
431
|
+
const toolsByName = new Map(definitions.map(({ name, inputSchema }) => [name, { name, fields: new Set(Object.keys(inputSchema.properties)) }]));
|
|
432
|
+
export function parseMcpToolCall(name, args) {
|
|
433
|
+
const tool = toolsByName.get(name);
|
|
434
|
+
requireThat(tool, `未知工具:${name}(可用:${[...toolsByName.keys()].join(", ")})。`);
|
|
435
|
+
requireThat(object(args), "工具参数必须是对象。");
|
|
436
|
+
const unknown = Object.entries(args)
|
|
437
|
+
.filter(([key, value]) => value !== undefined && !tool.fields.has(key))
|
|
438
|
+
.map(([key]) => key);
|
|
439
|
+
requireThat(unknown.length === 0, `未知参数:${unknown.join(", ")}(${name} 可用参数:${[...tool.fields].join(", ")})。`);
|
|
440
|
+
return { name: tool.name, args };
|
|
441
|
+
}
|