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,15 +1,5 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
export
|
|
1
|
+
import type { HistoryIdentity, RawHistory, SummaryArtifact } from "../model/history.js";
|
|
2
|
+
export { isHistoryIdentifier as isHistoryHost, isHistoryIdentifier as isSummaryDimension } from "../common/validation.js";
|
|
3
3
|
export declare function matchIdentity(value: HistoryIdentity, expected: HistoryIdentity): void;
|
|
4
4
|
export declare function rawHistory(value: unknown): RawHistory;
|
|
5
|
-
export
|
|
6
|
-
summaries: HistorySummary[];
|
|
7
|
-
}
|
|
8
|
-
export declare function hierarchicalHistory(value: unknown, raw: RawHistory): HierarchicalHistory;
|
|
9
|
-
/** Old private directories carried the host in their path. Shared records must declare it. */
|
|
10
|
-
export declare function legacyHistory(value: unknown, host?: HistoryHost): HistoryRecord;
|
|
11
|
-
export declare function summaryData(item: HistorySummary): HistorySummary;
|
|
12
|
-
export declare function splitLegacy(record: HistoryRecord): {
|
|
13
|
-
raw: RawHistory;
|
|
14
|
-
summaries: HistorySummary[];
|
|
15
|
-
};
|
|
5
|
+
export declare function summaryArtifact(value: unknown, expectedDimension?: string): SummaryArtifact;
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { object } from "../common/json.js";
|
|
2
|
-
import { requireThat } from "../common/validation.js";
|
|
2
|
+
import { isHistoryIdentifier, requireThat } from "../common/validation.js";
|
|
3
3
|
import { fileId } from "./file-access.js";
|
|
4
4
|
const strings = (value) => Array.isArray(value) && value.every(item => typeof item === "string");
|
|
5
5
|
const fields = (value, names) => Object.keys(value).every(key => names.includes(key));
|
|
6
6
|
const rawFields = ["host", "id", "sessionId", "name", "exchanges", "branches"];
|
|
7
|
-
const hierarchyFields = ["host", "id", "sessionId", "summaries"];
|
|
8
7
|
const exchangeFields = ["id", "entryIds", "text", "from", "to", "completed"];
|
|
9
|
-
const
|
|
10
|
-
|
|
8
|
+
const summaryArtifactFields = ["id", "dimension", "host", "sessionId", "title", "text", "from", "to", "updatedAt", "source"];
|
|
9
|
+
const summarySourceFields = ["rawIds", "exchangeIds", "fingerprint"];
|
|
10
|
+
export { isHistoryIdentifier as isHistoryHost, isHistoryIdentifier as isSummaryDimension } from "../common/validation.js";
|
|
11
11
|
function identity(value) {
|
|
12
|
-
requireThat(object(value) &&
|
|
12
|
+
requireThat(object(value) && isHistoryIdentifier(value.host) && typeof value.id === "string" &&
|
|
13
13
|
typeof value.sessionId === "string" && value.sessionId.length > 0, "历史归档身份无效。");
|
|
14
14
|
fileId(value.id);
|
|
15
15
|
}
|
|
@@ -32,55 +32,29 @@ export function rawHistory(value) {
|
|
|
32
32
|
requireThat(item.id !== value.id && !ids.has(item.id), "历史问答 ID 重复:" + item.id);
|
|
33
33
|
ids.add(item.id);
|
|
34
34
|
}
|
|
35
|
-
for (const branch of value.branches)
|
|
35
|
+
for (const branch of value.branches) {
|
|
36
36
|
requireThat(strings(branch) && new Set(branch).size === branch.length && branch.every(id => ids.has(id)), "历史分支包含重复或未知的问答 ID。");
|
|
37
|
-
return value;
|
|
38
|
-
}
|
|
39
|
-
export function hierarchicalHistory(value, raw) {
|
|
40
|
-
identity(value);
|
|
41
|
-
matchIdentity(value, raw);
|
|
42
|
-
requireThat(object(value) && fields(value, hierarchyFields) && Array.isArray(value.summaries), "历史摘要归档无效。");
|
|
43
|
-
const levels = new Map(raw.exchanges.map(item => [item.id, 0]));
|
|
44
|
-
for (const item of value.summaries) {
|
|
45
|
-
requireThat(object(item) && exchange(item) && fields(item, summaryFields) && item.entryIds.length > 0 &&
|
|
46
|
-
typeof item.level === "number" && Number.isSafeInteger(item.level) && item.level > 0 && strings(item.children) && typeof item.ready === "boolean", "历史摘要节点无效。");
|
|
47
|
-
requireThat(item.id !== raw.id && !levels.has(item.id), "历史摘要 ID 重复:" + item.id);
|
|
48
|
-
levels.set(item.id, item.level);
|
|
49
37
|
}
|
|
50
|
-
|
|
51
|
-
for (const item of result.summaries)
|
|
52
|
-
requireThat(item.children.length > 0 && new Set(item.children).size === item.children.length &&
|
|
53
|
-
item.children.every(id => levels.get(id) === item.level - 1), "历史摘要子节点缺失、重复或层级不匹配:" + item.id);
|
|
54
|
-
return result;
|
|
38
|
+
return value;
|
|
55
39
|
}
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
40
|
+
export function summaryArtifact(value, expectedDimension) {
|
|
41
|
+
requireThat(object(value) && fields(value, summaryArtifactFields), "历史摘要产物格式无效。");
|
|
42
|
+
requireThat(typeof value.id === "string" && value.id.length > 0, "历史摘要 ID 无效。");
|
|
43
|
+
fileId(value.id);
|
|
44
|
+
requireThat(isHistoryIdentifier(value.dimension), "历史摘要维度无效。");
|
|
45
|
+
if (expectedDimension !== undefined) {
|
|
46
|
+
requireThat(value.dimension === expectedDimension, `历史摘要维度不匹配,预期 ${expectedDimension},实际 ${value.dimension}。`);
|
|
61
47
|
}
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
return
|
|
74
|
-
}
|
|
75
|
-
function exchangeData({ id, entryIds, text, from, to, completed }) {
|
|
76
|
-
return { id, entryIds, text, from, to, completed };
|
|
77
|
-
}
|
|
78
|
-
export function summaryData(item) {
|
|
79
|
-
return { ...exchangeData(item), level: item.level, children: item.children, ready: item.ready };
|
|
80
|
-
}
|
|
81
|
-
export function splitLegacy(record) {
|
|
82
|
-
const { host, id, sessionId, name } = record;
|
|
83
|
-
const raw = rawHistory({ host, id, sessionId, name, exchanges: record.nodes.filter(node => node.kind === "exchange").map(exchangeData), branches: [] });
|
|
84
|
-
const summaries = record.nodes.filter(node => node.kind === "summary").map(summaryData);
|
|
85
|
-
return { raw, summaries: hierarchicalHistory({ host, id, sessionId, summaries }, raw).summaries };
|
|
48
|
+
if (value.host !== undefined)
|
|
49
|
+
requireThat(isHistoryIdentifier(value.host), "历史摘要来源 host 无效。");
|
|
50
|
+
if (value.sessionId !== undefined)
|
|
51
|
+
requireThat(typeof value.sessionId === "string" && value.sessionId.length > 0, "历史摘要 sessionId 无效。");
|
|
52
|
+
requireThat(typeof value.title === "string" && typeof value.text === "string" && value.text.trim().length > 0 &&
|
|
53
|
+
typeof value.from === "string" && typeof value.to === "string" && typeof value.updatedAt === "string", "历史摘要正文或时间字段无效。");
|
|
54
|
+
const source = value.source;
|
|
55
|
+
requireThat(object(source) && fields(source, summarySourceFields) &&
|
|
56
|
+
strings(source.rawIds) && source.rawIds.length > 0 &&
|
|
57
|
+
strings(source.exchangeIds) &&
|
|
58
|
+
typeof source.fingerprint === "string" && source.fingerprint.length > 0, "历史摘要来源指纹无效。");
|
|
59
|
+
return value;
|
|
86
60
|
}
|
|
@@ -1,70 +1,5 @@
|
|
|
1
|
-
import type { HistoryLocation } from "../../model/history.js";
|
|
2
|
-
import type { HistoryService } from "../../services/history/history-service.js";
|
|
3
1
|
import type { HistoryInput } from "./contract.js";
|
|
4
|
-
export declare function executeHistory(
|
|
5
|
-
|
|
6
|
-
parents: string[];
|
|
7
|
-
snippet: string;
|
|
8
|
-
host: import("../../model/history.js").HistoryHost;
|
|
9
|
-
id: string;
|
|
10
|
-
kind: "session" | "exchange" | "summary";
|
|
11
|
-
sessionId: string;
|
|
12
|
-
name: string;
|
|
13
|
-
preview: string;
|
|
14
|
-
from: string;
|
|
15
|
-
to: string;
|
|
16
|
-
ready: boolean;
|
|
17
|
-
completed: boolean;
|
|
18
|
-
}[];
|
|
19
|
-
total: number;
|
|
20
|
-
nextOffset: number | null;
|
|
2
|
+
export declare function executeHistory(root: string, args: HistoryInput, signal?: AbortSignal): import("../../services/history/history-query.js").HistorySearchResult | {
|
|
3
|
+
node: import("../../services/history/history-query.js").HistoryReadNode;
|
|
21
4
|
warnings: string[];
|
|
22
|
-
}
|
|
23
|
-
node: {
|
|
24
|
-
text: string;
|
|
25
|
-
totalLength: number;
|
|
26
|
-
nextOffset: number | null;
|
|
27
|
-
parents: {
|
|
28
|
-
host: import("../../model/history.js").HistoryHost;
|
|
29
|
-
id: string;
|
|
30
|
-
kind: "session" | "exchange" | "summary";
|
|
31
|
-
sessionId: string;
|
|
32
|
-
name: string;
|
|
33
|
-
preview: string;
|
|
34
|
-
from: string;
|
|
35
|
-
to: string;
|
|
36
|
-
ready: boolean;
|
|
37
|
-
completed: boolean;
|
|
38
|
-
}[];
|
|
39
|
-
children: {
|
|
40
|
-
host: import("../../model/history.js").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
|
-
nextChildrenOffset: number | null;
|
|
52
|
-
source: {
|
|
53
|
-
host: import("../../model/history.js").HistoryHost;
|
|
54
|
-
sessionId: string;
|
|
55
|
-
entryIds: string[];
|
|
56
|
-
};
|
|
57
|
-
warnings: string[];
|
|
58
|
-
host: import("../../model/history.js").HistoryHost;
|
|
59
|
-
id: string;
|
|
60
|
-
kind: "session" | "exchange" | "summary";
|
|
61
|
-
sessionId: string;
|
|
62
|
-
name: string;
|
|
63
|
-
preview: string;
|
|
64
|
-
from: string;
|
|
65
|
-
to: string;
|
|
66
|
-
ready: boolean;
|
|
67
|
-
completed: boolean;
|
|
68
|
-
};
|
|
69
|
-
warnings: string[];
|
|
70
|
-
}>;
|
|
5
|
+
};
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
import { readWorkspaceHistory, searchWorkspaceHistory } from "../../services/history/history-query.js";
|
|
2
|
+
export function executeHistory(root, args, signal) {
|
|
2
3
|
signal?.throwIfAborted();
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
if (args.action === "search") {
|
|
5
|
+
return searchWorkspaceHistory(root, args);
|
|
6
|
+
}
|
|
7
|
+
const node = readWorkspaceHistory(root, args.id, args.offset, args.limit, args.childrenOffset, args.host);
|
|
8
|
+
return { node, warnings: node.warnings };
|
|
7
9
|
}
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { Type } from "typebox";
|
|
2
|
-
import type
|
|
2
|
+
import { type HistoryHost, type HistoryQuery } from "../../model/history.js";
|
|
3
3
|
export declare const historyResultSchema: Type.TObject<{
|
|
4
4
|
matches: Type.TOptional<Type.TArray<Type.TObject<{
|
|
5
5
|
snippet: Type.TString;
|
|
6
6
|
parents: Type.TArray<Type.TString>;
|
|
7
|
-
host: Type.
|
|
7
|
+
host: Type.TString;
|
|
8
8
|
id: Type.TString;
|
|
9
9
|
kind: Type.TUnion<[Type.TLiteral<"session">, Type.TLiteral<"exchange">, Type.TLiteral<"summary">]>;
|
|
10
|
+
dimension: Type.TOptional<Type.TString>;
|
|
10
11
|
sessionId: Type.TString;
|
|
11
12
|
name: Type.TString;
|
|
12
13
|
preview: Type.TString;
|
|
@@ -22,9 +23,10 @@ export declare const historyResultSchema: Type.TObject<{
|
|
|
22
23
|
totalLength: Type.TInteger;
|
|
23
24
|
nextOffset: Type.TUnion<[Type.TInteger, Type.TNull]>;
|
|
24
25
|
parents: Type.TArray<Type.TObject<{
|
|
25
|
-
host: Type.
|
|
26
|
+
host: Type.TString;
|
|
26
27
|
id: Type.TString;
|
|
27
28
|
kind: Type.TUnion<[Type.TLiteral<"session">, Type.TLiteral<"exchange">, Type.TLiteral<"summary">]>;
|
|
29
|
+
dimension: Type.TOptional<Type.TString>;
|
|
28
30
|
sessionId: Type.TString;
|
|
29
31
|
name: Type.TString;
|
|
30
32
|
preview: Type.TString;
|
|
@@ -34,9 +36,10 @@ export declare const historyResultSchema: Type.TObject<{
|
|
|
34
36
|
completed: Type.TBoolean;
|
|
35
37
|
}>>;
|
|
36
38
|
children: Type.TArray<Type.TObject<{
|
|
37
|
-
host: Type.
|
|
39
|
+
host: Type.TString;
|
|
38
40
|
id: Type.TString;
|
|
39
41
|
kind: Type.TUnion<[Type.TLiteral<"session">, Type.TLiteral<"exchange">, Type.TLiteral<"summary">]>;
|
|
42
|
+
dimension: Type.TOptional<Type.TString>;
|
|
40
43
|
sessionId: Type.TString;
|
|
41
44
|
name: Type.TString;
|
|
42
45
|
preview: Type.TString;
|
|
@@ -47,14 +50,16 @@ export declare const historyResultSchema: Type.TObject<{
|
|
|
47
50
|
}>>;
|
|
48
51
|
nextChildrenOffset: Type.TUnion<[Type.TInteger, Type.TNull]>;
|
|
49
52
|
source: Type.TObject<{
|
|
50
|
-
host: Type.
|
|
53
|
+
host: Type.TString;
|
|
51
54
|
sessionId: Type.TString;
|
|
52
55
|
entryIds: Type.TArray<Type.TString>;
|
|
56
|
+
dimension: Type.TOptional<Type.TString>;
|
|
53
57
|
}>;
|
|
54
58
|
warnings: Type.TArray<Type.TString>;
|
|
55
|
-
host: Type.
|
|
59
|
+
host: Type.TString;
|
|
56
60
|
id: Type.TString;
|
|
57
61
|
kind: Type.TUnion<[Type.TLiteral<"session">, Type.TLiteral<"exchange">, Type.TLiteral<"summary">]>;
|
|
62
|
+
dimension: Type.TOptional<Type.TString>;
|
|
58
63
|
sessionId: Type.TString;
|
|
59
64
|
name: Type.TString;
|
|
60
65
|
preview: Type.TString;
|
|
@@ -65,10 +70,11 @@ export declare const historyResultSchema: Type.TObject<{
|
|
|
65
70
|
}>>;
|
|
66
71
|
warnings: Type.TArray<Type.TString>;
|
|
67
72
|
}>;
|
|
68
|
-
export declare const historyDescription
|
|
73
|
+
export declare const historyDescription: string;
|
|
69
74
|
export declare const historyParameters: Type.TObject<{
|
|
70
75
|
action: Type.TUnion<[Type.TLiteral<"search">, Type.TLiteral<"read">]>;
|
|
71
|
-
host: Type.TOptional<Type.TUnion<[Type.
|
|
76
|
+
host: Type.TOptional<Type.TUnion<[Type.TString, Type.TNull]>>;
|
|
77
|
+
dimension: Type.TOptional<Type.TUnion<[Type.TString, Type.TNull]>>;
|
|
72
78
|
query: Type.TOptional<Type.TUnion<[Type.TString, Type.TNull]>>;
|
|
73
79
|
sessionId: Type.TOptional<Type.TUnion<[Type.TString, Type.TNull]>>;
|
|
74
80
|
from: Type.TOptional<Type.TUnion<[Type.TString, Type.TNull]>>;
|
|
@@ -78,16 +84,9 @@ export declare const historyParameters: Type.TObject<{
|
|
|
78
84
|
limit: Type.TOptional<Type.TUnion<[Type.TInteger, Type.TNull]>>;
|
|
79
85
|
childrenOffset: Type.TOptional<Type.TUnion<[Type.TInteger, Type.TNull]>>;
|
|
80
86
|
}>;
|
|
81
|
-
export type HistoryInput = {
|
|
87
|
+
export type HistoryInput = ({
|
|
82
88
|
action: "search";
|
|
83
|
-
|
|
84
|
-
query?: string;
|
|
85
|
-
sessionId?: string;
|
|
86
|
-
from?: string;
|
|
87
|
-
to?: string;
|
|
88
|
-
offset?: number;
|
|
89
|
-
limit?: number;
|
|
90
|
-
} | {
|
|
89
|
+
} & HistoryQuery) | {
|
|
91
90
|
action: "read";
|
|
92
91
|
id: string;
|
|
93
92
|
host?: HistoryHost;
|
|
@@ -1,45 +1,86 @@
|
|
|
1
1
|
import { Type } from "../../common/typebox.js";
|
|
2
|
-
import {
|
|
2
|
+
import { historyPageLimits } from "../../model/history.js";
|
|
3
|
+
import { historyIdentifierPattern, requireThat } from "../../common/validation.js";
|
|
3
4
|
import { schema } from "../../common/schema.js";
|
|
4
5
|
import { inputObject, need, nullable, pick } from "../input.js";
|
|
5
|
-
const
|
|
6
|
+
const identifier = Type.String({ pattern: historyIdentifierPattern.source });
|
|
6
7
|
const nullableOffset = Type.Union([Type.Integer(), Type.Null()]);
|
|
7
|
-
const node = Type.Object({
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
const node = Type.Object({
|
|
9
|
+
host: identifier,
|
|
10
|
+
id: Type.String(),
|
|
11
|
+
kind: Type.Union([Type.Literal("session"), Type.Literal("exchange"), Type.Literal("summary")], {
|
|
12
|
+
description: "session=会话根;summary=维度摘要;exchange=单轮问答原文。",
|
|
13
|
+
}),
|
|
14
|
+
dimension: Type.Optional(identifier),
|
|
15
|
+
sessionId: Type.String(),
|
|
16
|
+
name: Type.String(),
|
|
17
|
+
preview: Type.String(),
|
|
18
|
+
from: Type.String(),
|
|
19
|
+
to: Type.String(),
|
|
10
20
|
ready: Type.Boolean({ description: "正文或摘要是否已生成。" }),
|
|
11
|
-
completed: Type.Boolean({ description: "该对话或问答是否正常结束(false 表示中断或未完)。" })
|
|
21
|
+
completed: Type.Boolean({ description: "该对话或问答是否正常结束(false 表示中断或未完)。" }),
|
|
22
|
+
});
|
|
12
23
|
export const historyResultSchema = Type.Object({
|
|
13
|
-
matches: Type.Optional(Type.Array(Type.Object({
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
parents: Type.Array(
|
|
17
|
-
|
|
24
|
+
matches: Type.Optional(Type.Array(Type.Object({
|
|
25
|
+
...node.properties,
|
|
26
|
+
snippet: Type.String(),
|
|
27
|
+
parents: Type.Array(Type.String()),
|
|
28
|
+
}))),
|
|
29
|
+
total: Type.Optional(Type.Integer()),
|
|
30
|
+
nextOffset: Type.Optional(nullableOffset),
|
|
31
|
+
node: Type.Optional(Type.Object({
|
|
32
|
+
...node.properties,
|
|
33
|
+
text: Type.String(),
|
|
34
|
+
totalLength: Type.Integer(),
|
|
35
|
+
nextOffset: nullableOffset,
|
|
36
|
+
parents: Type.Array(node),
|
|
37
|
+
children: Type.Array(node),
|
|
38
|
+
nextChildrenOffset: nullableOffset,
|
|
39
|
+
source: Type.Object({
|
|
40
|
+
host: identifier,
|
|
41
|
+
sessionId: Type.String({ description: "原始宿主会话 ID。" }),
|
|
42
|
+
entryIds: Type.Array(Type.String()),
|
|
43
|
+
dimension: Type.Optional(identifier),
|
|
44
|
+
}),
|
|
45
|
+
warnings: Type.Array(Type.String()),
|
|
46
|
+
})),
|
|
18
47
|
warnings: Type.Array(Type.String()),
|
|
19
48
|
});
|
|
20
|
-
export const historyDescription = "
|
|
49
|
+
export const historyDescription = "查询当前工作区的历史问答与各维度摘要,host 可筛选来源(如 pi、dsh、claude、antigravity),dimension 可筛选 raw 原文或特定摘要维度(如 monthly 月度汇总、session 会话摘要)。" +
|
|
50
|
+
"search 按不区分大小写的连续关键词匹配原文和摘要,省略 query 列出各会话或指定维度摘要;无匹配时换词。" +
|
|
51
|
+
"read 按节点 id 展开正文与上下级(可从 monthly 下钻至 session 摘要,再下钻至 exchange 原文),nextOffset 续读正文,nextChildrenOffset 续读子节点。归档不含工具调用日志。";
|
|
21
52
|
export const historyParameters = Type.Object({
|
|
22
|
-
action: Type.Union([Type.Literal("search"), Type.Literal("read")], {
|
|
23
|
-
|
|
24
|
-
|
|
53
|
+
action: Type.Union([Type.Literal("search"), Type.Literal("read")], {
|
|
54
|
+
description: "search 搜索或列会话;read 读取指定节点正文与上下级。各动作仅读取自身字段,其余字段忽略。",
|
|
55
|
+
}),
|
|
56
|
+
host: nullable(Type.String({ pattern: historyIdentifierPattern.source, description: "可选来源筛选(如 pi、dsh、claude、antigravity)。" })),
|
|
57
|
+
dimension: nullable(Type.String({ pattern: historyIdentifierPattern.source, description: "仅 search:可选范围筛选(raw 表示仅原文,或指定摘要维度如 monthly、session;省略查全部)。" })),
|
|
58
|
+
query: nullable(Type.String({ description: "仅 search:不区分大小写的连续关键词;省略时列出各会话(或指定维度摘要)。" })),
|
|
25
59
|
sessionId: nullable(Type.String({ description: "仅 search:限定在指定会话 ID 内搜索。" })),
|
|
26
60
|
from: nullable(Type.String({ description: "仅 search:ISO 日期或时间下界。" })),
|
|
27
61
|
to: nullable(Type.String({ description: "仅 search:ISO 日期或时间上界。" })),
|
|
28
62
|
id: nullable(Type.String({ description: "仅 read,必填:search 或上下级返回的节点 id。" })),
|
|
29
63
|
offset: nullable(Type.Integer({ minimum: 0, description: "search:匹配结果偏移;read:正文字符偏移。默认 0。" })),
|
|
30
|
-
limit: nullable(Type.Integer({ minimum: 1, maximum:
|
|
64
|
+
limit: nullable(Type.Integer({ minimum: 1, maximum: historyPageLimits.read.max, description: `search:最多返回条数(默认 ${historyPageLimits.search.default},上限 ${historyPageLimits.search.max});read:正文字符数(默认 ${historyPageLimits.read.default})。` })),
|
|
31
65
|
childrenOffset: nullable(Type.Integer({ minimum: 0, description: "仅 read:子节点列表偏移,默认 0;续读传上页 nextChildrenOffset。" })),
|
|
32
66
|
}, { additionalProperties: false });
|
|
33
67
|
const valid = schema(historyParameters);
|
|
34
68
|
export function historyInput(value) {
|
|
35
69
|
const args = inputObject(value, valid, "历史参数格式无效");
|
|
36
70
|
if (args.action === "search") {
|
|
37
|
-
const limit = args.limit === undefined ?
|
|
38
|
-
requireThat(limit <=
|
|
39
|
-
return {
|
|
71
|
+
const limit = args.limit === undefined ? historyPageLimits.search.default : args.limit;
|
|
72
|
+
requireThat(limit <= historyPageLimits.search.max, `search 的 limit 最多 ${historyPageLimits.search.max}。`);
|
|
73
|
+
return {
|
|
74
|
+
action: "search",
|
|
75
|
+
...pick(args, ["host", "dimension", "query", "sessionId", "from", "to", "offset", "limit"]),
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
if (args.action === "read") {
|
|
79
|
+
return {
|
|
80
|
+
action: "read",
|
|
81
|
+
id: need("read", args, "id"),
|
|
82
|
+
...pick(args, ["host", "offset", "limit", "childrenOffset"]),
|
|
83
|
+
};
|
|
40
84
|
}
|
|
41
|
-
if (args.action === "read")
|
|
42
|
-
return { action: "read", id: need("read", args, "id"),
|
|
43
|
-
...pick(args, ["host", "offset", "limit", "childrenOffset"]) };
|
|
44
85
|
throw new Error("未知的历史 action。");
|
|
45
86
|
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
1
|
import type { Context } from "@deepseek-ai/cordis";
|
|
2
2
|
import type { Agent } from "@deepseek-ai/dsh-agent";
|
|
3
|
-
|
|
4
|
-
export declare function registerDshHistoryTool(ctx: Context, agent: Agent, service: HistoryService, lifetime: AbortSignal, check: () => void): void;
|
|
3
|
+
export declare function registerDshHistoryTool(ctx: Context, agent: Agent, root: string, lifetime: AbortSignal, check: () => void): void;
|
|
@@ -1,19 +1,25 @@
|
|
|
1
|
-
import { dshParameters, dshOutputSchema } from "../../integrations/dsh/schema.js";
|
|
1
|
+
import { dshParameters, dshOutputSchema } from "../../integrations/hosts/dsh/schema.js";
|
|
2
2
|
import { requireThat } from "../../common/validation.js";
|
|
3
3
|
import { schema } from "../../common/schema.js";
|
|
4
4
|
import { json } from "../../common/json.js";
|
|
5
5
|
import { markdownFields } from "../../common/markdown.js";
|
|
6
6
|
import { historyDescription, historyInput, historyParameters, historyResultSchema } from "./contract.js";
|
|
7
7
|
import { executeHistory } from "./actions.js";
|
|
8
|
-
export function registerDshHistoryTool(ctx, agent,
|
|
8
|
+
export function registerDshHistoryTool(ctx, agent, root, lifetime, check) {
|
|
9
9
|
const valid = schema(historyResultSchema);
|
|
10
|
-
ctx.tools.register({
|
|
11
|
-
|
|
10
|
+
ctx.tools.register({
|
|
11
|
+
name: "pbot_history",
|
|
12
|
+
description: historyDescription,
|
|
13
|
+
parameters: dshParameters(historyParameters),
|
|
14
|
+
output: {
|
|
15
|
+
schema: dshOutputSchema(historyResultSchema),
|
|
16
|
+
render: (_args, value) => [{ type: "text", text: "# 历史\n\n" + markdownFields(value) }],
|
|
17
|
+
},
|
|
12
18
|
async execute(value, exec) {
|
|
13
19
|
check();
|
|
14
20
|
requireThat(exec.agent === agent, "历史工具不属于当前会话。");
|
|
15
21
|
const signal = AbortSignal.any([exec.signal, lifetime]);
|
|
16
|
-
const result =
|
|
22
|
+
const result = executeHistory(root, historyInput(value), signal);
|
|
17
23
|
check();
|
|
18
24
|
signal.throwIfAborted();
|
|
19
25
|
requireThat(valid(result), "历史输出不符合契约。");
|
package/lib/ui/dsh/elements.d.ts
CHANGED
|
@@ -1,17 +1,14 @@
|
|
|
1
1
|
export declare const record: (value: unknown) => Record<string, unknown>;
|
|
2
2
|
export declare const rows: (value: unknown) => Record<string, unknown>[];
|
|
3
3
|
export declare const text: (value: unknown) => string;
|
|
4
|
-
export declare const objectInput: (value: string) => Record<string, unknown>;
|
|
5
|
-
export declare const lines: (value: string) => string[];
|
|
6
4
|
export declare function element<K extends keyof HTMLElementTagNameMap>(tag: K, content?: string, className?: string): HTMLElementTagNameMap[K];
|
|
7
5
|
export declare function block(value: unknown): HTMLPreElement;
|
|
8
6
|
export declare function note(value: string): HTMLParagraphElement;
|
|
9
7
|
export declare function group(parent: HTMLElement, className?: string): HTMLDivElement;
|
|
10
8
|
export declare function details(parent: HTMLElement, title: string): HTMLDetailsElement;
|
|
11
|
-
export declare function field(parent: HTMLElement, label: string
|
|
9
|
+
export declare function field(parent: HTMLElement, label: string): HTMLInputElement;
|
|
12
10
|
export declare function select(parent: HTMLElement, label: string, values: [string, string][]): HTMLSelectElement;
|
|
13
|
-
export declare function badge(state: unknown): HTMLSpanElement;
|
|
14
11
|
export declare function facts(values: [string, unknown][]): HTMLDListElement;
|
|
15
12
|
export declare function empty(title: string, description: string): HTMLDivElement;
|
|
16
|
-
export declare function pageTitle(parent: HTMLElement, title: string
|
|
13
|
+
export declare function pageTitle(parent: HTMLElement, title: string): HTMLElement;
|
|
17
14
|
export declare function time(value: unknown): string;
|
package/lib/ui/dsh/elements.js
CHANGED
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
import { object } from "../../common/json.js";
|
|
2
|
-
import { stateLabel } from "../presentation.js";
|
|
3
2
|
export const record = (value) => { if (!object(value))
|
|
4
3
|
throw new Error("管理数据无效。"); return value; };
|
|
5
4
|
export const rows = (value) => Array.isArray(value) ? value.map(record) : [];
|
|
6
5
|
export const text = (value) => value === null || value === undefined ? "" : String(value);
|
|
7
|
-
export const objectInput = (value) => record(JSON.parse(value || "{}"));
|
|
8
|
-
export const lines = (value) => value.split(/\r?\n/).map(item => item.trim()).filter(Boolean);
|
|
9
6
|
export function element(tag, content = "", className = "") {
|
|
10
7
|
const node = document.createElement(tag);
|
|
11
8
|
node.textContent = content;
|
|
@@ -25,13 +22,10 @@ export function details(parent, title) {
|
|
|
25
22
|
parent.append(node);
|
|
26
23
|
return node;
|
|
27
24
|
}
|
|
28
|
-
export function field(parent, label
|
|
29
|
-
const wrapper = element("label", "", "pbot-field"), input =
|
|
25
|
+
export function field(parent, label) {
|
|
26
|
+
const wrapper = element("label", "", "pbot-field"), input = element("input");
|
|
30
27
|
wrapper.append(element("span", label));
|
|
31
|
-
input.value = value;
|
|
32
28
|
input.setAttribute("aria-label", label);
|
|
33
|
-
if (input instanceof HTMLTextAreaElement)
|
|
34
|
-
input.rows = 3;
|
|
35
29
|
wrapper.append(input);
|
|
36
30
|
parent.append(wrapper);
|
|
37
31
|
return input;
|
|
@@ -49,11 +43,6 @@ export function select(parent, label, values) {
|
|
|
49
43
|
parent.append(wrapper);
|
|
50
44
|
return input;
|
|
51
45
|
}
|
|
52
|
-
export function badge(state) {
|
|
53
|
-
const node = element("span", stateLabel(state), "pbot-badge");
|
|
54
|
-
node.dataset.state = text(state);
|
|
55
|
-
return node;
|
|
56
|
-
}
|
|
57
46
|
export function facts(values) {
|
|
58
47
|
const node = element("dl", "", "pbot-facts");
|
|
59
48
|
for (const [label, value] of values)
|
|
@@ -65,11 +54,9 @@ export function empty(title, description) {
|
|
|
65
54
|
node.append(element("h3", title), note(description));
|
|
66
55
|
return node;
|
|
67
56
|
}
|
|
68
|
-
export function pageTitle(parent, title
|
|
57
|
+
export function pageTitle(parent, title) {
|
|
69
58
|
const node = element("header", "", "pbot-page-title");
|
|
70
59
|
node.append(element("h2", title));
|
|
71
|
-
if (description)
|
|
72
|
-
node.append(note(description));
|
|
73
60
|
parent.append(node);
|
|
74
61
|
return node;
|
|
75
62
|
}
|