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,57 @@
|
|
|
1
|
+
import { requireThat } from "../../common/validation.js";
|
|
2
|
+
import { createAcpHistorySummarizer } from "../../integrations/acp/history-summary.js";
|
|
3
|
+
import { migrateWorkspaceHistory } from "../../services/history/history-migrate.js";
|
|
4
|
+
import { parseHistoryCommand } from "../../services/history/summary-command.js";
|
|
5
|
+
import { listSummaryDimensions } from "../../services/history/summary-registry.js";
|
|
6
|
+
import { inspectWorkspaceSummaries, runWorkspaceSummaries } from "../../services/history/summary-runner.js";
|
|
7
|
+
import { readWorkspaceConfig, readWorkspaceHistoryLayoutSync, workspaceDisabledMessage, workspaceFeatures, workspaceSummaryConfig } from "../../services/workspace/workspace-config.js";
|
|
8
|
+
import { executeHistory } from "../../tools/history/actions.js";
|
|
9
|
+
import { historyInput } from "../../tools/history/contract.js";
|
|
10
|
+
export async function runHistoryCommand(workspace, argument, signal, progress) {
|
|
11
|
+
const { root } = workspace;
|
|
12
|
+
signal.throwIfAborted();
|
|
13
|
+
requireThat(workspace.features.history, "当前工作区已停用历史功能(features.history: false)。");
|
|
14
|
+
const command = typeof argument === "string" ? parseHistoryCommand(argument) : argument;
|
|
15
|
+
switch (command.kind) {
|
|
16
|
+
case "status":
|
|
17
|
+
return inspectWorkspaceSummaries(root);
|
|
18
|
+
case "list": {
|
|
19
|
+
const layout = readWorkspaceHistoryLayoutSync(root);
|
|
20
|
+
const dimensions = listSummaryDimensions(layout).map(({ id, title, description }) => ({ id, title, description }));
|
|
21
|
+
return { layout, dimensions };
|
|
22
|
+
}
|
|
23
|
+
case "migrate":
|
|
24
|
+
return migrateWorkspaceHistory(root, { dryRun: command.dryRun });
|
|
25
|
+
case "query":
|
|
26
|
+
return executeHistory(root, historyInput(command.input), signal);
|
|
27
|
+
case "summary": {
|
|
28
|
+
const config = await readWorkspaceConfig(root);
|
|
29
|
+
requireThat(config.enabled && !config.error, workspaceDisabledMessage(config));
|
|
30
|
+
requireThat(workspaceFeatures(config).history, "当前工作区已停用历史功能(features.history: false)。");
|
|
31
|
+
const defaults = workspaceSummaryConfig(config);
|
|
32
|
+
const backend = command.backend ?? defaults.backend;
|
|
33
|
+
const model = command.model ?? defaults.model;
|
|
34
|
+
const thinking = command.thinking ?? defaults.thinking;
|
|
35
|
+
const summarizer = createAcpHistorySummarizer({
|
|
36
|
+
cwd: root, backend,
|
|
37
|
+
...(config.acp ? { commands: config.acp } : {}),
|
|
38
|
+
...(model ? { model } : {}),
|
|
39
|
+
...(thinking ? { thinking } : {}),
|
|
40
|
+
});
|
|
41
|
+
progress?.start(backend);
|
|
42
|
+
try {
|
|
43
|
+
const report = await runWorkspaceSummaries({
|
|
44
|
+
root, summarizer, signal,
|
|
45
|
+
force: command.force,
|
|
46
|
+
concurrency: defaults.concurrency,
|
|
47
|
+
...(command.dimensions ? { dimensions: command.dimensions } : {}),
|
|
48
|
+
...(progress ? { onProgress: progress.update } : {}),
|
|
49
|
+
});
|
|
50
|
+
return { backend, ...(model ? { model } : {}), ...report };
|
|
51
|
+
}
|
|
52
|
+
finally {
|
|
53
|
+
progress?.finish?.();
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const name: string, inject: string[], apply: typeof import("./acp-member.js").apply;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { realpathSync } from "node:fs";
|
|
2
|
+
import { registerHooks } from "node:module";
|
|
3
|
+
import { pathToFileURL } from "node:url";
|
|
4
|
+
// Keep normal dsh profile resolution. A standalone plugin cache has no SDK
|
|
5
|
+
// peers of its own, so resolve missing peers from the running dsh installation.
|
|
6
|
+
const memberLib = new URL("../../../", import.meta.url).href;
|
|
7
|
+
const peers = registerHooks({
|
|
8
|
+
resolve(specifier, context, nextResolve) {
|
|
9
|
+
if (specifier.startsWith("@deepseek-ai/") && context.parentURL?.startsWith(memberLib)) {
|
|
10
|
+
try {
|
|
11
|
+
return nextResolve(specifier, context);
|
|
12
|
+
}
|
|
13
|
+
catch (error) {
|
|
14
|
+
if (error.code !== "ERR_MODULE_NOT_FOUND" || !process.argv[1])
|
|
15
|
+
throw error;
|
|
16
|
+
return nextResolve(specifier, { ...context, parentURL: pathToFileURL(realpathSync(process.argv[1])).href });
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
return nextResolve(specifier, context);
|
|
20
|
+
},
|
|
21
|
+
});
|
|
22
|
+
export const { name, inject, apply } = await import("./acp-member.js").finally(() => peers.deregister());
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import * as McpClient from "@deepseek-ai/dsh-mcp-client";
|
|
2
|
+
import { acpMember } from "../../acp/member.js";
|
|
3
|
+
import { rootAgents } from "../../../integrations/hosts/dsh/root-agents.js";
|
|
4
|
+
import { dshResources, dshExpertTools } from "../../../integrations/hosts/dsh/resources.js";
|
|
5
|
+
import { registerDshSkills } from "../../../integrations/hosts/dsh/skills.js";
|
|
6
|
+
import { toDshMcpConfig } from "../../../integrations/hosts/dsh/mcp.js";
|
|
7
|
+
import { finalDshAnswer } from "../../../integrations/hosts/dsh/messages.js";
|
|
8
|
+
import { loadNativeWorkspaceServers } from "../workspace-mcp.js";
|
|
9
|
+
import { registerDshFileEvents } from "./files.js";
|
|
10
|
+
import { requireThat } from "../../../common/validation.js";
|
|
11
|
+
export const name = "pbot-acp-member";
|
|
12
|
+
export const inject = ["agents", "sessions", "llm", "tools", "systemPrompt", "skills", "fs", "workingDirectory", "approval"];
|
|
13
|
+
export async function apply(ctx) {
|
|
14
|
+
const member = await acpMember();
|
|
15
|
+
ctx.on("agent/pre-step", async (_event, next) => {
|
|
16
|
+
if (process.env.PBOT_ACP_VALIDATE === "1")
|
|
17
|
+
return { kind: "reject" };
|
|
18
|
+
member.input();
|
|
19
|
+
return next();
|
|
20
|
+
});
|
|
21
|
+
ctx.on("agent/created", async ({ agent, source }) => {
|
|
22
|
+
if (!rootAgents(ctx.agents).includes(agent))
|
|
23
|
+
return;
|
|
24
|
+
if (source === "resume")
|
|
25
|
+
agent.inbox.clear();
|
|
26
|
+
const reference = member.files.reference(member.id);
|
|
27
|
+
requireThat(reference.host === "acp" && reference.backend === "dsh" && agent.session.header.cwd === member.d.cwd &&
|
|
28
|
+
(reference.sessionId === null || reference.sessionId === agent.id), "dsh ACP 会话身份或工作目录不匹配。");
|
|
29
|
+
await agent.ctx.plugin({ name: "pbot-acp-expert", inject, apply: async (scope) => {
|
|
30
|
+
if (member.features.skills)
|
|
31
|
+
registerDshSkills(scope, agent, { workspaceRoot: member.d.workspace });
|
|
32
|
+
if (member.features.mcp && process.env.PBOT_ACP_VALIDATE !== "1") {
|
|
33
|
+
await loadNativeWorkspaceServers(member.d.workspace, async (server) => {
|
|
34
|
+
await scope.plugin(McpClient, toDshMcpConfig(server));
|
|
35
|
+
}, { warn: message => ctx.logger.warn(message) });
|
|
36
|
+
}
|
|
37
|
+
dshExpertTools(scope, agent, member.d.options);
|
|
38
|
+
if (member.features.prompts)
|
|
39
|
+
await dshResources(scope, agent, member.d.workspace, "general-purpose", member.check);
|
|
40
|
+
registerDshFileEvents(scope, agent, member.d.workspace, true, member.check);
|
|
41
|
+
let input, answer = "";
|
|
42
|
+
scope.on("session/event", (session, event) => {
|
|
43
|
+
if (session !== agent.session)
|
|
44
|
+
return;
|
|
45
|
+
if (event.type === "turn/start") {
|
|
46
|
+
input = member.input();
|
|
47
|
+
answer = "";
|
|
48
|
+
}
|
|
49
|
+
if (event.type === "assistant/message")
|
|
50
|
+
answer = finalDshAnswer(event);
|
|
51
|
+
if (event.type === "turn/end" && input) {
|
|
52
|
+
const reason = event.data.reason;
|
|
53
|
+
member.answer(input, reason.kind === "completed" && answer.trim() ? "completed" : reason.kind === "aborted" ? "cancelled" : "failed", answer, reason.kind === "error" ? reason.error.message : reason.kind === "completed" ? undefined : reason.kind);
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
} });
|
|
57
|
+
});
|
|
58
|
+
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
1
|
import type { Context } from "@deepseek-ai/cordis";
|
|
2
|
-
import { type PbotManagement } from "./management.js";
|
|
3
2
|
import type { DshWorkspaces } from "./workspace.js";
|
|
4
|
-
export declare function registerDshCommand(ctx: Context, workspaces: DshWorkspaces
|
|
3
|
+
export declare function registerDshCommand(ctx: Context, workspaces: DshWorkspaces): void;
|
|
@@ -1,14 +1,13 @@
|
|
|
1
|
-
import { object, json } from "../../common/json.js";
|
|
2
|
-
import { requireThat } from "../../common/validation.js";
|
|
3
1
|
import { dshWorkspaceStatus } from "./management.js";
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
import { runHistoryCommand } from "../../history/command.js";
|
|
3
|
+
import { parseWorkerCommand } from "../../mcp/workers.js";
|
|
4
|
+
const usage = '用法:/pbot status | init | history [summary [维度] [--force] [--backend <acp>] [--model <model>] | migrate [--dry-run] | status | list | {"action":…}] | worker [overview|status|backends|models|create|request|response|output|close] [JSON]';
|
|
5
|
+
export function registerDshCommand(ctx, workspaces) {
|
|
7
6
|
ctx.commands.register({
|
|
8
7
|
name: "pbot",
|
|
9
|
-
description: "Personal Bot
|
|
8
|
+
description: "Personal Bot 工作区、历史摘要与跨 Harness worker 管理",
|
|
10
9
|
recordInput: false,
|
|
11
|
-
input: { hint: "status | init |
|
|
10
|
+
input: { hint: "status | init | history ... | worker ...", attachments: false },
|
|
12
11
|
async handler({ agent, rawInput, signal }) {
|
|
13
12
|
signal.throwIfAborted();
|
|
14
13
|
const command = rawInput.trim(), split = command.search(/\s/);
|
|
@@ -34,10 +33,9 @@ export function registerDshCommand(ctx, workspaces, management) {
|
|
|
34
33
|
break;
|
|
35
34
|
}
|
|
36
35
|
case "history": {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
result = await management.history({ parentSessionId: agent.id, input: json(input) }, signal);
|
|
36
|
+
const active = AbortSignal.any([signal, workspace.lifetime.signal]);
|
|
37
|
+
result = await runHistoryCommand(workspace, rest, active);
|
|
38
|
+
active.throwIfAborted();
|
|
41
39
|
break;
|
|
42
40
|
}
|
|
43
41
|
default:
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { Context } from "@deepseek-ai/cordis";
|
|
2
|
+
import type { Agent } from "@deepseek-ai/dsh-agent";
|
|
3
|
+
/** Native filesystem mutations share the original workspace's confirmation rule.
|
|
4
|
+
* This does not confine Bash, Python, MCP, or other extensions. */
|
|
5
|
+
export declare function registerDshFileEvents(ctx: Context, agent: Agent, root: string, expert: boolean, check: () => void): void;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { parsePatch } from "@deepseek-ai/dsh-fs-patch";
|
|
2
|
+
import { object } from "../../../common/json.js";
|
|
3
|
+
import { requireThat } from "../../../common/validation.js";
|
|
4
|
+
import { mutationScope } from "../../../services/workspace/workspace-files.js";
|
|
5
|
+
/** Native filesystem mutations share the original workspace's confirmation rule.
|
|
6
|
+
* This does not confine Bash, Python, MCP, or other extensions. */
|
|
7
|
+
export function registerDshFileEvents(ctx, agent, root, expert, check) {
|
|
8
|
+
const lifetime = new AbortController();
|
|
9
|
+
const mutations = new Set(["write", "edit", "apply_patch"]);
|
|
10
|
+
const captured = new Map();
|
|
11
|
+
ctx.effect(() => () => { lifetime.abort(); captured.clear(); });
|
|
12
|
+
async function targets(exec) {
|
|
13
|
+
check();
|
|
14
|
+
const args = exec.arguments;
|
|
15
|
+
requireThat(exec.agent === agent && object(args), "文件操作会话或参数无效。");
|
|
16
|
+
const signal = AbortSignal.any([lifetime.signal, exec.signal]);
|
|
17
|
+
signal.throwIfAborted();
|
|
18
|
+
let paths;
|
|
19
|
+
if (exec.name === "apply_patch") {
|
|
20
|
+
requireThat(typeof args.input === "string", "补丁参数无效。");
|
|
21
|
+
paths = parsePatch(args.input).flatMap(operation => [operation.path, ...(operation.kind === "update" && operation.moveTo ? [operation.moveTo] : [])]);
|
|
22
|
+
}
|
|
23
|
+
else {
|
|
24
|
+
requireThat(typeof args.file_path === "string" && args.file_path.trim().length > 0, "文件路径无效。");
|
|
25
|
+
paths = [args.file_path];
|
|
26
|
+
}
|
|
27
|
+
const anchor = ctx.fs.processPathFromHostPath(root);
|
|
28
|
+
requireThat(anchor !== undefined, "原生文件系统未映射当前工作区。");
|
|
29
|
+
const cwd = ctx.workingDirectory.get(agent.session);
|
|
30
|
+
const resolved = await Promise.all(paths.map(path => ctx.fs.resolve(path, { cwd, signal })));
|
|
31
|
+
signal.throwIfAborted();
|
|
32
|
+
check();
|
|
33
|
+
const outside = resolved.map(target => ctx.fs.processPath(target)).filter(path => mutationScope(anchor, path) === "outside");
|
|
34
|
+
return { cwd, keys: resolved.map(target => target.targetKey), outside, signal };
|
|
35
|
+
}
|
|
36
|
+
ctx.on("tools/pre-execute", async (exec, next) => {
|
|
37
|
+
if (!mutations.has(exec.name))
|
|
38
|
+
return next();
|
|
39
|
+
const value = await targets(exec), record = { cwd: value.cwd, keys: value.keys, approved: !value.outside.length };
|
|
40
|
+
captured.set(exec.token, record);
|
|
41
|
+
if (value.outside.length && expert)
|
|
42
|
+
return { kind: "deny", reason: "专家不能修改工作区外文件。" };
|
|
43
|
+
const policy = await next();
|
|
44
|
+
value.signal.throwIfAborted();
|
|
45
|
+
check();
|
|
46
|
+
if (policy.kind === "deny" || policy.kind === "cancel" || !value.outside.length)
|
|
47
|
+
return policy;
|
|
48
|
+
const scopeReason = "Personal Bot: confirm changes outside the original workspace: " + JSON.stringify(value.outside);
|
|
49
|
+
const reason = [policy.kind === "ask" ? policy.reason : undefined, scopeReason].filter(Boolean).join("\n");
|
|
50
|
+
const outcome = await ctx.approval.request({ agent, toolName: exec.name, callId: exec.callId, signal: value.signal, reason,
|
|
51
|
+
displayReason: { en: reason, "zh-CN": "允许本次修改原工作区之外的文件:" + value.outside.join("、") + (policy.kind === "ask" && policy.reason ? "\n" + policy.reason : "") } });
|
|
52
|
+
value.signal.throwIfAborted();
|
|
53
|
+
check();
|
|
54
|
+
record.approved = outcome === "allowed-once";
|
|
55
|
+
return record.approved ? { kind: "allow" } : { kind: "deny", reason: "用户未确认文件修改。" };
|
|
56
|
+
});
|
|
57
|
+
ctx.on("tools/execute", async (exec, next) => {
|
|
58
|
+
if (!mutations.has(exec.name))
|
|
59
|
+
return next();
|
|
60
|
+
const record = captured.get(exec.token);
|
|
61
|
+
requireThat(record?.approved, "文件操作没有有效的范围检查或确认。");
|
|
62
|
+
const value = await targets(exec);
|
|
63
|
+
requireThat(record.cwd === value.cwd && record.keys.length === value.keys.length && record.keys.every((key, index) => key === value.keys[index]), "确认期间文件路径或工作目录已变化。");
|
|
64
|
+
return next();
|
|
65
|
+
});
|
|
66
|
+
ctx.on("tools/result", exec => { captured.delete(exec.token); });
|
|
67
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { Context } from "@deepseek-ai/cordis";
|
|
2
|
+
import type { Agent } from "@deepseek-ai/dsh-agent";
|
|
3
|
+
/** Capture root-session raw Q&A exchanges into .pbot/history/raw/. Summaries run on explicit trigger. */
|
|
4
|
+
export declare function registerDshHistoryEvents(ctx: Context, agent: Agent, root: string): void;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { recordHistoryCapture } from "../../../services/history/history-capture.js";
|
|
2
|
+
import { finalDshAnswer } from "../../../integrations/hosts/dsh/messages.js";
|
|
3
|
+
function userMessageText(content) {
|
|
4
|
+
return content.flatMap(block => block.type === "text" ? [block.text] :
|
|
5
|
+
block.type === "image" ? ["[图片 " + (block.attachment.name ?? block.attachment.attachmentId) + "]"] :
|
|
6
|
+
block.type === "file" ? ["[附件 " + (block.attachment.name ?? block.attachment.attachmentId) + "]"] : []).join("\n");
|
|
7
|
+
}
|
|
8
|
+
/** Capture root-session raw Q&A exchanges into .pbot/history/raw/. Summaries run on explicit trigger. */
|
|
9
|
+
export function registerDshHistoryEvents(ctx, agent, root) {
|
|
10
|
+
let final = false;
|
|
11
|
+
let lastAnswer = "";
|
|
12
|
+
let lastAnswerTime;
|
|
13
|
+
ctx.on("session/event", (session, event) => {
|
|
14
|
+
if (session !== agent.session)
|
|
15
|
+
return;
|
|
16
|
+
if (event.type === "turn/start") {
|
|
17
|
+
final = false;
|
|
18
|
+
lastAnswer = "";
|
|
19
|
+
lastAnswerTime = undefined;
|
|
20
|
+
}
|
|
21
|
+
if (event.type === "user/message" && event.data.source.kind === "user") {
|
|
22
|
+
const text = userMessageText(event.data.content).trim();
|
|
23
|
+
if (text) {
|
|
24
|
+
try {
|
|
25
|
+
recordHistoryCapture(root, "dsh", {
|
|
26
|
+
kind: "input",
|
|
27
|
+
sessionId: agent.id,
|
|
28
|
+
text,
|
|
29
|
+
timestamp: new Date(event.time).toISOString(),
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
catch { /* Never block a user turn if history persistence fails. */ }
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
if (event.type === "assistant/message") {
|
|
36
|
+
const completeText = finalDshAnswer(event).trim();
|
|
37
|
+
final = Boolean(completeText);
|
|
38
|
+
const body = completeText || event.data.message.content.filter(block => block.type === "text").map(block => block.text).join("\n").trim();
|
|
39
|
+
if (body) {
|
|
40
|
+
lastAnswer = body;
|
|
41
|
+
lastAnswerTime = new Date(event.time).toISOString();
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
if (event.type === "turn/end") {
|
|
45
|
+
const completed = event.data.reason.kind === "completed" && final;
|
|
46
|
+
if (lastAnswer) {
|
|
47
|
+
try {
|
|
48
|
+
recordHistoryCapture(root, "dsh", {
|
|
49
|
+
kind: "answer",
|
|
50
|
+
sessionId: agent.id,
|
|
51
|
+
assistantText: lastAnswer,
|
|
52
|
+
completed,
|
|
53
|
+
...(lastAnswerTime ? { timestamp: lastAnswerTime } : {}),
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
catch { /* Never block turn completion if history persistence fails. */ }
|
|
57
|
+
}
|
|
58
|
+
lastAnswer = "";
|
|
59
|
+
lastAnswerTime = undefined;
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Agent } from "@deepseek-ai/dsh-agent";
|
|
2
2
|
import type { Context } from "@deepseek-ai/cordis";
|
|
3
3
|
import { TypertRemoteService } from "@deepseek-ai/dsh-typert-protocol";
|
|
4
|
-
import { type Json } from "
|
|
4
|
+
import { type Json } from "../../../common/json.js";
|
|
5
5
|
import type { DshWorkspaces, DshWorkspace } from "./workspace.js";
|
|
6
6
|
export declare function dshStatus(workspace: DshWorkspace): Json;
|
|
7
7
|
/** Status remains available when this workspace has not opted in. */
|
|
@@ -34,14 +34,15 @@ var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn,
|
|
|
34
34
|
};
|
|
35
35
|
import { Remote, TypertRemoteService } from "@deepseek-ai/dsh-typert-protocol";
|
|
36
36
|
import { SessionId } from "@deepseek-ai/dsh-session";
|
|
37
|
-
import { Type } from "
|
|
38
|
-
import { json } from "
|
|
39
|
-
import { requireThat } from "
|
|
40
|
-
import { schema } from "
|
|
41
|
-
import { packageVersion } from "
|
|
42
|
-
import {
|
|
43
|
-
import {
|
|
44
|
-
import {
|
|
37
|
+
import { Type } from "../../../common/typebox.js";
|
|
38
|
+
import { json } from "../../../common/json.js";
|
|
39
|
+
import { requireThat } from "../../../common/validation.js";
|
|
40
|
+
import { schema } from "../../../common/schema.js";
|
|
41
|
+
import { packageVersion } from "../../../common/version.js";
|
|
42
|
+
import { inspectWorkspaceSummaries } from "../../../services/history/summary-runner.js";
|
|
43
|
+
import { historyInput } from "../../../tools/history/contract.js";
|
|
44
|
+
import { executeHistory } from "../../../tools/history/actions.js";
|
|
45
|
+
import { pbotReadRemote } from "../../../ui/dsh/remote.js";
|
|
45
46
|
const requestSchema = Type.Object({ parentSessionId: Type.String({ minLength: 1 }), input: Type.Optional(Type.Unknown()) }, { additionalProperties: false });
|
|
46
47
|
const validRequest = schema(requestSchema);
|
|
47
48
|
export function dshStatus(workspace) {
|
|
@@ -54,7 +55,7 @@ export function dshStatus(workspace) {
|
|
|
54
55
|
workspaceRoot: workspace.root,
|
|
55
56
|
sessionId: workspace.agent.id,
|
|
56
57
|
model: workspace.agent.model.current() ?? null,
|
|
57
|
-
history: workspace.history.
|
|
58
|
+
history: workspace.features.history ? inspectWorkspaceSummaries(workspace.root) : null,
|
|
58
59
|
});
|
|
59
60
|
}
|
|
60
61
|
/** Status remains available when this workspace has not opted in. */
|
|
@@ -119,7 +120,8 @@ let PbotManagement = (() => {
|
|
|
119
120
|
}
|
|
120
121
|
async history(request, signal) {
|
|
121
122
|
const current = await this.workspace(request, signal), { workspace, input } = current;
|
|
122
|
-
|
|
123
|
+
requireThat(workspace.features.history, "当前工作区已停用历史功能(features.history: false)。");
|
|
124
|
+
const result = executeHistory(workspace.root, historyInput(input), current.signal);
|
|
123
125
|
workspace.check();
|
|
124
126
|
current.signal.throwIfAborted();
|
|
125
127
|
return json(result);
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import type { Agent } from "@deepseek-ai/dsh-agent";
|
|
2
2
|
import type { Context } from "@deepseek-ai/cordis";
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
5
|
-
import type { ResolvedWorkspaceFeatures, WorkspaceConfiguration } from "../../model/workspace-config.js";
|
|
6
|
-
import { McpWorkerRuntime } from "../mcp-workers.js";
|
|
3
|
+
import type { ResolvedWorkspaceFeatures, WorkspaceConfiguration } from "../../../model/workspace-config.js";
|
|
4
|
+
import { McpWorkerRuntime } from "../../mcp/workers.js";
|
|
7
5
|
export declare const dshDependencies: string[];
|
|
8
6
|
export declare class DshWorkspace {
|
|
9
7
|
#private;
|
|
@@ -11,13 +9,10 @@ export declare class DshWorkspace {
|
|
|
11
9
|
readonly root: string;
|
|
12
10
|
readonly agent: Agent;
|
|
13
11
|
readonly component: AbortSignal;
|
|
14
|
-
private readonly historyWork;
|
|
15
|
-
private readonly releaseHistory;
|
|
16
12
|
readonly features: ResolvedWorkspaceFeatures;
|
|
17
13
|
readonly lifetime: AbortController;
|
|
18
|
-
readonly history: HistoryService;
|
|
19
14
|
readonly workers: McpWorkerRuntime;
|
|
20
|
-
constructor(ctx: Context, root: string, agent: Agent, component: AbortSignal,
|
|
15
|
+
constructor(ctx: Context, root: string, agent: Agent, component: AbortSignal, features?: ResolvedWorkspaceFeatures);
|
|
21
16
|
check: () => void;
|
|
22
17
|
open(): Promise<void>;
|
|
23
18
|
close(): Promise<void>;
|
|
@@ -26,7 +21,6 @@ export declare class DshWorkspaces {
|
|
|
26
21
|
#private;
|
|
27
22
|
readonly ctx: Context;
|
|
28
23
|
constructor(ctx: Context);
|
|
29
|
-
private history;
|
|
30
24
|
open(agent: Agent): Promise<DshWorkspace | undefined>;
|
|
31
25
|
get(agent: Agent): Promise<DshWorkspace>;
|
|
32
26
|
configuration(agent: Agent): Promise<{
|