personal-bot 0.3.1 → 0.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude-plugin/marketplace.json +2 -2
- package/.claude-plugin/plugin.json +2 -1
- package/DISCLAIMER.md +17 -0
- package/LICENSE +21 -0
- package/README.md +15 -5
- package/README.zh-CN.md +15 -5
- package/bin/pbot-pi-acp.mjs +27 -11
- package/bin/pbot.mjs +22 -2
- package/docs/README.md +3 -1
- package/docs/architecture/design.md +37 -24
- package/docs/architecture/extensibility.md +27 -19
- package/docs/architecture/model-context.md +4 -3
- package/docs/architecture/principles.md +5 -4
- package/docs/guides/capabilities.md +4 -4
- package/docs/guides/cross-harness-workers.md +3 -1
- package/docs/guides/history.md +73 -16
- package/docs/guides/workspace-configuration.md +35 -6
- package/docs/hosts/antigravity.md +2 -0
- package/docs/hosts/claude-code.md +1 -1
- package/docs/hosts/codex-qoder.md +63 -0
- package/docs/hosts/dsh.md +1 -1
- package/docs/hosts/pi.md +1 -1
- package/docs/maintainers/architecture-governance.md +78 -0
- package/hooks/hooks.json +3 -0
- package/lib/antigravity-plugin/DISCLAIMER.md +17 -0
- package/lib/antigravity-plugin/LICENSE +21 -0
- package/lib/antigravity-plugin/bin/pbot-pi-acp.mjs +36 -0
- package/lib/antigravity-plugin/hooks.json +7 -0
- package/lib/antigravity-plugin/lib/claude.js +2 -2
- package/lib/antigravity-plugin/lib/common/files.d.ts +2 -0
- package/lib/antigravity-plugin/lib/common/files.js +44 -0
- package/lib/antigravity-plugin/lib/common/validation.d.ts +4 -0
- package/lib/antigravity-plugin/lib/common/validation.js +8 -0
- package/lib/{extension/acp-member.d.ts → antigravity-plugin/lib/extension/acp/member.d.ts} +5 -5
- package/lib/{extension/acp-member.js → antigravity-plugin/lib/extension/acp/member.js} +6 -6
- package/lib/antigravity-plugin/lib/extension/acp-worker.js +222 -51
- package/lib/antigravity-plugin/lib/extension/hosts/dsh/acp-entry.d.ts +1 -0
- package/lib/antigravity-plugin/lib/extension/hosts/dsh/acp-entry.js +22 -0
- package/lib/{extension → antigravity-plugin/lib/extension/hosts}/dsh/acp-member.js +11 -25
- package/lib/{extension → antigravity-plugin/lib/extension/hosts}/dsh/files.js +3 -3
- package/lib/antigravity-plugin/lib/extension/hosts/pi/acp-member.d.ts +3 -0
- package/lib/antigravity-plugin/lib/extension/hosts/pi/acp-member.js +100 -0
- package/lib/antigravity-plugin/lib/extension/hosts/plugin-runtime.d.ts +12 -0
- package/lib/antigravity-plugin/lib/extension/hosts/plugin-runtime.js +101 -0
- package/lib/antigravity-plugin/lib/extension/hosts/workspace-mcp.d.ts +6 -0
- package/lib/antigravity-plugin/lib/extension/hosts/workspace-mcp.js +21 -0
- package/lib/antigravity-plugin/lib/extension/mcp.js +2705 -1348
- package/lib/antigravity-plugin/lib/extension/workspace-cli.js +20127 -0
- package/lib/antigravity-plugin/lib/integrations/agent-resources.d.ts +1 -0
- package/lib/antigravity-plugin/lib/integrations/agent-resources.js +6 -2
- package/lib/antigravity-plugin/lib/integrations/hosts/antigravity/adapter.d.ts +6 -0
- package/lib/antigravity-plugin/lib/integrations/hosts/antigravity/adapter.js +171 -0
- package/lib/antigravity-plugin/lib/integrations/hosts/{claude.d.ts → claude/adapter.d.ts} +1 -1
- package/lib/antigravity-plugin/lib/integrations/hosts/claude/adapter.js +36 -0
- package/lib/antigravity-plugin/lib/integrations/hosts/codex/adapter.d.ts +2 -0
- package/lib/antigravity-plugin/lib/integrations/hosts/codex/adapter.js +14 -0
- package/lib/{integrations → antigravity-plugin/lib/integrations/hosts}/dsh/mcp.d.ts +1 -1
- package/lib/{integrations → antigravity-plugin/lib/integrations/hosts}/dsh/resources.d.ts +1 -1
- package/lib/{integrations → antigravity-plugin/lib/integrations/hosts}/dsh/resources.js +4 -4
- package/lib/{integrations → antigravity-plugin/lib/integrations/hosts}/dsh/skills.js +1 -1
- package/lib/antigravity-plugin/lib/integrations/hosts/pi/agent-tools.d.ts +3 -0
- package/lib/antigravity-plugin/lib/integrations/hosts/pi/agent-tools.js +32 -0
- package/lib/antigravity-plugin/lib/integrations/hosts/pi/mcp.d.ts +4 -0
- package/lib/antigravity-plugin/lib/integrations/hosts/pi/mcp.js +23 -0
- package/lib/antigravity-plugin/lib/integrations/hosts/{registry.d.ts → plugin-registry.d.ts} +1 -0
- package/lib/{integrations/hosts/registry.js → antigravity-plugin/lib/integrations/hosts/plugin-registry.js} +10 -3
- package/lib/antigravity-plugin/lib/integrations/hosts/prompt-hooks.d.ts +76 -0
- package/lib/antigravity-plugin/lib/integrations/hosts/prompt-hooks.js +76 -0
- package/lib/antigravity-plugin/lib/integrations/hosts/qoder/adapter.d.ts +2 -0
- package/lib/antigravity-plugin/lib/integrations/hosts/qoder/adapter.js +16 -0
- package/lib/antigravity-plugin/lib/model/acp.d.ts +7 -3
- package/lib/antigravity-plugin/lib/model/acp.js +8 -0
- package/lib/antigravity-plugin/lib/model/agent.d.ts +121 -0
- package/lib/antigravity-plugin/lib/model/agent.js +4 -0
- package/lib/antigravity-plugin/lib/model/history.d.ts +179 -0
- package/lib/antigravity-plugin/lib/model/history.js +4 -0
- package/lib/antigravity-plugin/lib/model/plugin-host.d.ts +31 -0
- package/lib/antigravity-plugin/lib/model/workspace-config.d.ts +28 -7
- package/lib/antigravity-plugin/lib/model/workspace-config.js +2 -1
- package/lib/antigravity-plugin/lib/plugin.d.ts +2 -1
- package/lib/antigravity-plugin/lib/plugin.js +4 -4
- package/lib/antigravity-plugin/lib/services/history/history-capture.d.ts +4 -0
- package/lib/antigravity-plugin/lib/services/history/history-capture.js +98 -0
- package/lib/antigravity-plugin/lib/services/history/history-index.d.ts +17 -0
- package/lib/antigravity-plugin/lib/services/history/history-index.js +112 -0
- package/lib/antigravity-plugin/lib/services/history/summary-dimensions/monthly.d.ts +7 -0
- package/lib/antigravity-plugin/lib/services/history/summary-dimensions/monthly.js +121 -0
- package/lib/antigravity-plugin/lib/services/history/summary-dimensions/session.d.ts +7 -0
- package/lib/antigravity-plugin/lib/services/history/summary-dimensions/session.js +124 -0
- package/lib/antigravity-plugin/lib/services/history/summary-registry.d.ts +7 -0
- package/lib/antigravity-plugin/lib/services/history/summary-registry.js +35 -0
- package/lib/antigravity-plugin/lib/services/history/summary-runner.d.ts +34 -0
- package/lib/antigravity-plugin/lib/services/history/summary-runner.js +299 -0
- package/lib/antigravity-plugin/lib/services/history/workspace-history.d.ts +3 -0
- package/lib/antigravity-plugin/lib/services/history/workspace-history.js +6 -0
- package/lib/antigravity-plugin/lib/services/workspace/plugin-releases.d.ts +3 -0
- package/lib/antigravity-plugin/lib/services/workspace/plugin-releases.js +78 -0
- package/lib/antigravity-plugin/lib/services/workspace/workspace-config.d.ts +5 -1
- package/lib/antigravity-plugin/lib/services/workspace/workspace-config.js +77 -7
- package/lib/antigravity-plugin/lib/services/workspace/workspace-files.d.ts +2 -0
- package/lib/antigravity-plugin/lib/services/workspace/workspace-files.js +17 -0
- package/lib/antigravity-plugin/lib/services/workspace/workspace-mcp.d.ts +14 -0
- package/lib/antigravity-plugin/lib/services/workspace/workspace-mcp.js +193 -0
- package/lib/antigravity-plugin/lib/services/workspace/workspace-skills.d.ts +1 -0
- package/lib/antigravity-plugin/lib/services/workspace/workspace-skills.js +4 -2
- package/lib/antigravity-plugin/lib/storage/acp-files.d.ts +11 -0
- package/lib/antigravity-plugin/lib/storage/acp-files.js +75 -0
- package/lib/antigravity-plugin/lib/storage/agent-files.d.ts +31 -0
- package/lib/antigravity-plugin/lib/storage/agent-files.js +159 -0
- package/lib/antigravity-plugin/lib/storage/atomic-json.d.ts +3 -1
- package/lib/antigravity-plugin/lib/storage/atomic-json.js +43 -3
- package/lib/antigravity-plugin/lib/storage/file-access.d.ts +2 -0
- package/lib/antigravity-plugin/lib/storage/file-access.js +26 -0
- package/lib/antigravity-plugin/lib/storage/history-files.d.ts +55 -0
- package/lib/antigravity-plugin/lib/storage/history-files.js +473 -0
- package/lib/antigravity-plugin/lib/storage/history-format.d.ts +5 -0
- package/lib/antigravity-plugin/lib/storage/history-format.js +60 -0
- package/lib/antigravity-plugin/package.json +1 -1
- package/lib/antigravity-plugin/plugin.json +1 -1
- package/lib/antigravity-plugin/resources/prompts/history-monthly-summary.md +13 -0
- package/lib/antigravity-plugin/resources/prompts/history-summary.md +13 -0
- package/lib/antigravity-plugin/resources/prompts/plugin-coordinator.md +1 -0
- package/lib/antigravity-plugin/resources/skills/.claude-plugin/plugin.json +4 -0
- package/lib/antigravity-plugin/resources/skills/project-maintenance/SKILL.md +35 -0
- package/lib/antigravity-plugin/resources/skills/provider-connections/SKILL.md +52 -0
- package/lib/antigravity-plugin/skills/pbot/SKILL.md +11 -1
- package/lib/antigravity-plugin/skills/provider-connections/SKILL.md +22 -12
- package/lib/claude.js +2 -2
- package/lib/client.js +42 -60
- package/lib/codex-marketplace/.agents/plugins/marketplace.json +17 -0
- package/lib/codex-marketplace/plugins/personal-bot/.codex-plugin/plugin.json +7 -0
- package/lib/codex-marketplace/plugins/personal-bot/.mcp.json +17 -0
- package/lib/codex-marketplace/plugins/personal-bot/DISCLAIMER.md +17 -0
- package/lib/codex-marketplace/plugins/personal-bot/LICENSE +21 -0
- package/lib/codex-marketplace/plugins/personal-bot/hooks/hooks.json +37 -0
- package/lib/codex-marketplace/plugins/personal-bot/skills/pbot/SKILL.md +9 -0
- package/lib/codex-marketplace/plugins/personal-bot/skills/pbot/agents/openai.yaml +2 -0
- package/lib/common/validation.d.ts +4 -0
- package/lib/common/validation.js +8 -0
- package/lib/dsh.js +6 -6
- package/lib/extension/acp/member.d.ts +18 -0
- package/lib/extension/acp/member.js +44 -0
- package/lib/extension/acp/worker.js +384 -0
- package/lib/extension/acp-worker.js +222 -51
- package/lib/extension/history/command.d.ts +37 -0
- package/lib/extension/history/command.js +57 -0
- package/lib/extension/hosts/dsh/acp-entry.d.ts +1 -0
- package/lib/extension/hosts/dsh/acp-entry.js +22 -0
- package/lib/extension/hosts/dsh/acp-member.d.ts +4 -0
- package/lib/extension/hosts/dsh/acp-member.js +58 -0
- package/lib/extension/{dsh → hosts/dsh}/command.d.ts +1 -2
- package/lib/extension/{dsh → hosts/dsh}/command.js +9 -11
- package/lib/extension/hosts/dsh/files.d.ts +5 -0
- package/lib/extension/hosts/dsh/files.js +67 -0
- package/lib/extension/hosts/dsh/history.d.ts +4 -0
- package/lib/extension/hosts/dsh/history.js +62 -0
- package/lib/extension/{dsh → hosts/dsh}/management.d.ts +1 -1
- package/lib/extension/{dsh → hosts/dsh}/management.js +12 -10
- package/lib/extension/{dsh → hosts/dsh}/workspace.d.ts +3 -9
- package/lib/extension/{dsh → hosts/dsh}/workspace.js +30 -99
- package/lib/extension/hosts/pi/acp-member.d.ts +3 -0
- package/lib/extension/hosts/pi/acp-member.js +100 -0
- package/lib/extension/hosts/plugin-runtime.d.ts +12 -0
- package/lib/extension/hosts/plugin-runtime.js +101 -0
- package/lib/extension/hosts/workspace-mcp.d.ts +6 -0
- package/lib/extension/hosts/workspace-mcp.js +21 -0
- package/lib/extension/{mcp-bridge.d.ts → mcp/bridge.d.ts} +7 -9
- package/lib/extension/{mcp-bridge.js → mcp/bridge.js} +70 -88
- package/lib/extension/{mcp-workers.d.ts → mcp/tool-contract.d.ts} +129 -374
- package/lib/extension/mcp/tool-contract.js +441 -0
- package/lib/extension/mcp/workers.d.ts +487 -0
- package/lib/extension/mcp/workers.js +598 -0
- package/lib/extension/mcp.js +2705 -1348
- package/lib/extension/{setup-cli.js → setup/cli.js} +12 -9
- package/lib/extension/workspace-cli.js +20127 -0
- package/lib/integrations/acp/agents.d.ts +2 -3
- package/lib/integrations/acp/connection.d.ts +11 -10
- package/lib/integrations/acp/connection.js +6 -0
- package/lib/integrations/acp/harnesses/claude.js +1 -1
- package/lib/integrations/acp/harnesses/dsh.js +1 -1
- package/lib/integrations/acp/harnesses/presets.js +8 -0
- package/lib/integrations/acp/history-summary.d.ts +17 -0
- package/lib/integrations/acp/history-summary.js +101 -0
- package/lib/integrations/acp/launch.d.ts +2 -2
- package/lib/integrations/agent-resources.d.ts +1 -0
- package/lib/integrations/agent-resources.js +6 -2
- package/lib/integrations/hosts/antigravity/adapter.d.ts +6 -0
- package/lib/integrations/hosts/antigravity/adapter.js +171 -0
- package/lib/integrations/hosts/{claude.d.ts → claude/adapter.d.ts} +1 -1
- package/lib/integrations/hosts/claude/adapter.js +36 -0
- package/lib/integrations/hosts/codex/adapter.d.ts +2 -0
- package/lib/integrations/hosts/codex/adapter.js +14 -0
- package/lib/integrations/hosts/dsh/mcp.d.ts +4 -0
- package/lib/integrations/hosts/dsh/mcp.js +28 -0
- package/lib/integrations/hosts/dsh/messages.d.ts +36 -0
- package/lib/integrations/hosts/dsh/messages.js +11 -0
- package/lib/integrations/hosts/dsh/resources.d.ts +6 -0
- package/lib/integrations/hosts/dsh/resources.js +47 -0
- package/lib/integrations/hosts/dsh/root-agents.d.ts +4 -0
- package/lib/integrations/hosts/dsh/root-agents.js +3 -0
- package/lib/integrations/{dsh → hosts/dsh}/schema.js +1 -1
- package/lib/integrations/hosts/dsh/skills.d.ts +8 -0
- package/lib/integrations/hosts/dsh/skills.js +31 -0
- package/lib/integrations/hosts/pi/agent-tools.d.ts +3 -0
- package/lib/integrations/hosts/pi/agent-tools.js +32 -0
- package/lib/integrations/hosts/pi/mcp.d.ts +4 -0
- package/lib/integrations/hosts/pi/mcp.js +23 -0
- package/lib/integrations/hosts/{registry.d.ts → plugin-registry.d.ts} +1 -0
- package/lib/{antigravity-plugin/lib/integrations/hosts/registry.js → integrations/hosts/plugin-registry.js} +10 -3
- package/lib/integrations/hosts/prompt-hooks.d.ts +76 -0
- package/lib/integrations/hosts/prompt-hooks.js +76 -0
- package/lib/integrations/hosts/qoder/adapter.d.ts +2 -0
- package/lib/integrations/hosts/qoder/adapter.js +16 -0
- package/lib/integrations/installation/pi-setup.js +1 -1
- package/lib/model/acp.d.ts +7 -3
- package/lib/model/acp.js +8 -0
- package/lib/model/agent.d.ts +18 -4
- package/lib/model/agent.js +4 -1
- package/lib/model/history.d.ts +143 -34
- package/lib/model/history.js +4 -1
- package/lib/model/installation.js +1 -0
- package/lib/model/plugin-host.d.ts +31 -0
- package/lib/model/workspace-config.d.ts +28 -7
- package/lib/model/workspace-config.js +2 -1
- package/lib/plugin.d.ts +2 -1
- package/lib/plugin.js +4 -4
- package/lib/qoder-plugin/.mcp.json +17 -0
- package/lib/qoder-plugin/.qoder-plugin/plugin.json +7 -0
- package/lib/qoder-plugin/DISCLAIMER.md +17 -0
- package/lib/qoder-plugin/LICENSE +21 -0
- package/lib/qoder-plugin/hooks/hooks.json +37 -0
- package/lib/qoder-plugin/skills/pbot/SKILL.md +9 -0
- package/lib/services/agents/agent-run.d.ts +1 -1
- package/lib/services/agents/agent-service.d.ts +15 -45
- package/lib/services/agents/agent-service.js +22 -3
- package/lib/services/history/history-capture.d.ts +4 -0
- package/lib/services/history/history-capture.js +98 -0
- package/lib/services/history/history-index.d.ts +16 -7
- package/lib/services/history/history-index.js +48 -70
- package/lib/services/history/history-migrate.d.ts +12 -0
- package/lib/services/history/history-migrate.js +54 -0
- package/lib/services/history/history-query.d.ts +51 -0
- package/lib/services/history/history-query.js +352 -0
- package/lib/services/history/summary-command.d.ts +20 -0
- package/lib/services/history/summary-command.js +69 -0
- package/lib/services/history/summary-dimensions/monthly.d.ts +7 -0
- package/lib/services/history/summary-dimensions/monthly.js +121 -0
- package/lib/services/history/summary-dimensions/session.d.ts +7 -0
- package/lib/services/history/summary-dimensions/session.js +124 -0
- package/lib/services/history/summary-registry.d.ts +7 -0
- package/lib/services/history/summary-registry.js +35 -0
- package/lib/services/history/summary-runner.d.ts +34 -0
- package/lib/services/history/summary-runner.js +299 -0
- package/lib/services/history/workspace-history.d.ts +3 -0
- package/lib/services/history/workspace-history.js +6 -0
- package/lib/services/workspace/plugin-releases.d.ts +3 -0
- package/lib/services/workspace/plugin-releases.js +78 -0
- package/lib/services/workspace/workspace-config.d.ts +5 -1
- package/lib/services/workspace/workspace-config.js +77 -7
- package/lib/services/workspace/workspace-mcp.js +22 -29
- package/lib/services/workspace/workspace-skills.d.ts +1 -0
- package/lib/services/workspace/workspace-skills.js +4 -2
- package/lib/storage/acp-files.js +7 -12
- package/lib/storage/agent-files.js +6 -5
- package/lib/storage/atomic-json.d.ts +3 -1
- package/lib/storage/atomic-json.js +43 -3
- package/lib/storage/history-files.d.ts +46 -9
- package/lib/storage/history-files.js +382 -250
- package/lib/storage/history-format.d.ts +3 -13
- package/lib/storage/history-format.js +26 -52
- package/lib/tools/history/actions.d.ts +3 -68
- package/lib/tools/history/actions.js +7 -5
- package/lib/tools/history/contract.d.ts +16 -17
- package/lib/tools/history/contract.js +63 -22
- package/lib/tools/history/dsh-tool.d.ts +1 -2
- package/lib/tools/history/dsh-tool.js +11 -5
- package/lib/ui/dsh/elements.d.ts +2 -5
- package/lib/ui/dsh/elements.js +3 -16
- package/lib/ui/dsh/management.js +26 -13
- package/lib/ui/dsh/styles.d.ts +1 -1
- package/lib/ui/dsh/styles.js +5 -33
- package/package.json +4 -1
- package/resources/antigravity/skills/pbot/SKILL.md +11 -1
- package/resources/claude/skills/pbot/SKILL.md +11 -1
- package/resources/plugin/skills/pbot/SKILL.md +9 -0
- package/resources/prompts/history-coordinator.md +2 -1
- package/resources/prompts/history-monthly-summary.md +13 -0
- package/resources/prompts/history-summary.md +10 -4
- package/resources/prompts/plugin-coordinator.md +1 -0
- package/resources/skills/provider-connections/SKILL.md +22 -12
- package/scripts/README.md +3 -2
- package/src/claude.ts +2 -2
- package/src/common/validation.ts +10 -0
- package/src/dsh.ts +6 -6
- package/src/extension/{acp-member.ts → acp/member.ts} +7 -7
- package/src/extension/{acp-worker.ts → acp/worker.ts} +131 -17
- package/src/extension/history/command.ts +68 -0
- package/src/extension/hosts/dsh/acp-entry.ts +21 -0
- package/src/extension/{dsh → hosts/dsh}/acp-member.ts +12 -23
- package/src/extension/{dsh → hosts/dsh}/command.ts +10 -12
- package/src/extension/{dsh → hosts/dsh}/files.ts +3 -3
- package/src/extension/hosts/dsh/history.ts +67 -0
- package/src/extension/{dsh → hosts/dsh}/management.ts +11 -9
- package/src/extension/{dsh → hosts/dsh}/workspace.ts +31 -76
- package/src/extension/{pi-acp-member.ts → hosts/pi/acp-member.ts} +12 -18
- package/src/extension/{command.ts → hosts/pi/command.ts} +44 -11
- package/src/extension/{events.ts → hosts/pi/events.ts} +8 -4
- package/src/extension/hosts/pi/history.ts +45 -0
- package/src/extension/{lifecycle.ts → hosts/pi/lifecycle.ts} +9 -12
- package/src/extension/hosts/plugin-runtime.ts +96 -0
- package/src/extension/hosts/workspace-mcp.ts +25 -0
- package/src/extension/{mcp-bridge.ts → mcp/bridge.ts} +85 -85
- package/src/extension/mcp/tool-contract.ts +462 -0
- package/src/extension/{mcp-workers.ts → mcp/workers.ts} +151 -448
- package/src/extension/{setup-cli.ts → setup/cli.ts} +14 -11
- package/src/extension/setup/workspace-cli.ts +159 -0
- package/src/integrations/acp/agents.ts +2 -3
- package/src/integrations/acp/connection.ts +6 -0
- package/src/integrations/acp/harnesses/claude.ts +1 -1
- package/src/integrations/acp/harnesses/dsh.ts +1 -1
- package/src/integrations/acp/harnesses/presets.ts +8 -0
- package/src/integrations/acp/history-summary.ts +109 -0
- package/src/integrations/agent-resources.ts +7 -1
- package/src/integrations/hosts/antigravity/adapter.ts +161 -0
- package/src/integrations/hosts/claude/adapter.ts +39 -0
- package/src/integrations/hosts/codex/adapter.ts +16 -0
- package/src/integrations/{dsh → hosts/dsh}/mcp.ts +1 -1
- package/src/integrations/{dsh → hosts/dsh}/resources.ts +5 -5
- package/src/integrations/{dsh → hosts/dsh}/schema.ts +1 -1
- package/src/integrations/{dsh → hosts/dsh}/session.ts +2 -2
- package/src/integrations/{dsh → hosts/dsh}/skills.ts +1 -1
- package/src/integrations/{pi → hosts/pi}/mcp.ts +1 -1
- package/src/integrations/{pi → hosts/pi}/skills.ts +1 -1
- package/src/integrations/hosts/{registry.ts → plugin-registry.ts} +11 -3
- package/src/integrations/hosts/prompt-hooks.ts +72 -0
- package/src/integrations/hosts/qoder/adapter.ts +19 -0
- package/src/integrations/installation/cli-update.ts +116 -0
- package/src/integrations/installation/pi-bridge.ts +1 -1
- package/src/integrations/installation/pi-setup.ts +2 -2
- package/src/integrations/installation/processes.ts +1 -1
- package/src/mcp.ts +1 -1
- package/src/model/acp.ts +11 -3
- package/src/model/agent.ts +20 -4
- package/src/model/history.ts +156 -26
- package/src/model/installation.ts +41 -0
- package/src/model/plugin-host.ts +30 -2
- package/src/model/workspace-config.ts +31 -7
- package/src/pbot.ts +22 -50
- package/src/plugin.ts +4 -4
- package/src/services/agents/agent-service.ts +29 -17
- package/src/services/history/history-capture.ts +91 -0
- package/src/services/history/history-index.ts +48 -62
- package/src/services/history/history-migrate.ts +62 -0
- package/src/services/history/history-query.ts +401 -0
- package/src/services/history/summary-command.ts +70 -0
- package/src/services/history/summary-dimensions/monthly.ts +139 -0
- package/src/services/history/summary-dimensions/session.ts +149 -0
- package/src/services/history/summary-registry.ts +43 -0
- package/src/services/history/summary-runner.ts +343 -0
- package/src/services/history/workspace-history.ts +8 -0
- package/src/services/installation/setup-service.ts +2 -41
- package/src/services/workspace/plugin-releases.ts +68 -0
- package/src/services/workspace/workspace-config.ts +95 -8
- package/src/services/workspace/workspace-mcp.ts +23 -28
- package/src/services/workspace/workspace-skills.ts +5 -2
- package/src/storage/acp-files.ts +7 -12
- package/src/storage/agent-files.ts +6 -5
- package/src/storage/atomic-json.ts +31 -4
- package/src/storage/history-files.ts +416 -189
- package/src/storage/history-format.ts +45 -61
- package/src/tools/history/actions.ts +8 -6
- package/src/tools/history/contract.ts +70 -25
- package/src/tools/history/dsh-tool.ts +17 -8
- package/src/tools/history/pi-tool.ts +23 -0
- package/src/ui/dsh/elements.ts +5 -12
- package/src/ui/dsh/management.ts +36 -20
- package/src/ui/dsh/styles.ts +5 -33
- package/src/ui/{confirmation.ts → pi/confirmation.ts} +1 -1
- package/lib/antigravity-plugin/lib/extension/plugin-runtime.d.ts +0 -10
- package/lib/antigravity-plugin/lib/extension/plugin-runtime.js +0 -67
- package/lib/antigravity-plugin/lib/integrations/hosts/antigravity.d.ts +0 -4
- package/lib/antigravity-plugin/lib/integrations/hosts/antigravity.js +0 -79
- package/lib/antigravity-plugin/lib/integrations/hosts/claude.js +0 -60
- package/lib/extension/dsh/history.d.ts +0 -15
- package/lib/extension/dsh/history.js +0 -87
- package/lib/extension/mcp-workers.js +0 -882
- package/lib/extension/plugin-runtime.d.ts +0 -10
- package/lib/extension/plugin-runtime.js +0 -67
- package/lib/integrations/dsh/history-summary.d.ts +0 -11
- package/lib/integrations/dsh/history-summary.js +0 -36
- package/lib/integrations/dsh/history.d.ts +0 -16
- package/lib/integrations/dsh/history.js +0 -167
- package/lib/integrations/history-summary.d.ts +0 -4
- package/lib/integrations/history-summary.js +0 -32
- package/lib/integrations/hosts/antigravity.d.ts +0 -4
- package/lib/integrations/hosts/antigravity.js +0 -79
- package/lib/integrations/hosts/claude.js +0 -60
- package/lib/services/history/history-service.d.ts +0 -106
- package/lib/services/history/history-service.js +0 -242
- package/lib/storage/acp-history.d.ts +0 -10
- package/lib/storage/acp-history.js +0 -57
- package/lib/ui/presentation.d.ts +0 -3
- package/lib/ui/presentation.js +0 -12
- package/src/extension/dsh/history.ts +0 -74
- package/src/extension/history.ts +0 -26
- package/src/extension/plugin-runtime.ts +0 -63
- package/src/integrations/dsh/history-summary.ts +0 -39
- package/src/integrations/dsh/history.ts +0 -84
- package/src/integrations/history-summary.ts +0 -30
- package/src/integrations/hosts/antigravity.ts +0 -83
- package/src/integrations/hosts/claude.ts +0 -62
- package/src/integrations/pi/history.ts +0 -99
- package/src/services/history/history-service.ts +0 -195
- package/src/storage/acp-history.ts +0 -49
- package/src/tools/access.ts +0 -7
- package/src/tools/history/tool.ts +0 -19
- package/src/tools/register.ts +0 -22
- package/src/ui/presentation.ts +0 -12
- /package/lib/{extension → antigravity-plugin/lib/extension/hosts}/dsh/acp-member.d.ts +0 -0
- /package/lib/{extension → antigravity-plugin/lib/extension/hosts}/dsh/files.d.ts +0 -0
- /package/lib/{integrations → antigravity-plugin/lib/integrations/hosts}/dsh/mcp.js +0 -0
- /package/lib/{integrations → antigravity-plugin/lib/integrations/hosts}/dsh/messages.d.ts +0 -0
- /package/lib/{integrations → antigravity-plugin/lib/integrations/hosts}/dsh/messages.js +0 -0
- /package/lib/{integrations → antigravity-plugin/lib/integrations/hosts}/dsh/root-agents.d.ts +0 -0
- /package/lib/{integrations → antigravity-plugin/lib/integrations/hosts}/dsh/root-agents.js +0 -0
- /package/lib/{integrations → antigravity-plugin/lib/integrations/hosts}/dsh/skills.d.ts +0 -0
- /package/lib/extension/{acp-worker.d.ts → acp/worker.d.ts} +0 -0
- /package/lib/extension/{setup-guard.js → setup/guard.js} +0 -0
- /package/lib/integrations/acp/{claude.d.ts → claude-settings.d.ts} +0 -0
- /package/lib/integrations/acp/{claude.js → claude-settings.js} +0 -0
- /package/lib/integrations/{dsh → hosts/dsh}/schema.d.ts +0 -0
- /package/src/extension/{setup-guard.ts → setup/guard.ts} +0 -0
- /package/src/integrations/acp/{claude.ts → claude-settings.ts} +0 -0
- /package/src/integrations/{dsh → hosts/dsh}/messages.ts +0 -0
- /package/src/integrations/{dsh → hosts/dsh}/root-agents.ts +0 -0
- /package/src/integrations/{pi → hosts/pi}/agent-tools.ts +0 -0
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { PluginHostAdapter } from "../model/plugin-host.js";
|
|
2
|
-
export declare function pluginCommand(adapter: PluginHostAdapter, args: readonly string[], cwd: string): Promise<{
|
|
3
|
-
version: string;
|
|
4
|
-
workspaceRoot: string;
|
|
5
|
-
resourceRoot: string;
|
|
6
|
-
configuration: import("../model/workspace-config.js").WorkspaceConfiguration;
|
|
7
|
-
}>;
|
|
8
|
-
export declare function runPluginHost(adapter: PluginHostAdapter, args: readonly string[]): Promise<void>;
|
|
9
|
-
/** Shared hook execution engine; host-specific protocols stay in PluginHostAdapter implementations. */
|
|
10
|
-
export declare function pluginHook(adapter: PluginHostAdapter, payload: unknown): Promise<Record<string, unknown>>;
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import { resourceRoot } from "../common/paths.js";
|
|
2
|
-
import { packageVersion } from "../common/version.js";
|
|
3
|
-
import { requireThat } from "../common/validation.js";
|
|
4
|
-
import { loadWorkspaceContext } from "../integrations/agent-resources.js";
|
|
5
|
-
import { readWorkspaceConfig, workspaceFeatures } from "../services/workspace/workspace-config.js";
|
|
6
|
-
import { initializeWorkspace } from "../services/workspace/workspace-preparation.js";
|
|
7
|
-
import { discoverWorkspaceSkills } from "../services/workspace/workspace-skills.js";
|
|
8
|
-
function disabledMessage(adapter, configuration) {
|
|
9
|
-
return configuration.error ?? `Personal Bot 未在此工作区启用。运行 ${adapter.initCommandHint};配置文件:${configuration.path}`;
|
|
10
|
-
}
|
|
11
|
-
export async function pluginCommand(adapter, args, cwd) {
|
|
12
|
-
const root = await adapter.resolveRoot(cwd);
|
|
13
|
-
const action = args.join(" ");
|
|
14
|
-
requireThat(["init", "status"].includes(action), adapter.usage);
|
|
15
|
-
if (action === "init")
|
|
16
|
-
await initializeWorkspace(root);
|
|
17
|
-
const configuration = await readWorkspaceConfig(root);
|
|
18
|
-
return { version: packageVersion, workspaceRoot: root, resourceRoot, configuration };
|
|
19
|
-
}
|
|
20
|
-
export async function runPluginHost(adapter, args) {
|
|
21
|
-
if (args[0] === "hook") {
|
|
22
|
-
let input = "";
|
|
23
|
-
process.stdin.setEncoding("utf8");
|
|
24
|
-
for await (const chunk of process.stdin)
|
|
25
|
-
input += String(chunk);
|
|
26
|
-
process.stdout.write(JSON.stringify(await pluginHook(adapter, JSON.parse(input))) + "\n");
|
|
27
|
-
}
|
|
28
|
-
else {
|
|
29
|
-
process.stdout.write(JSON.stringify(await pluginCommand(adapter, args, process.cwd()), null, 2) + "\n");
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
/** Shared hook execution engine; host-specific protocols stay in PluginHostAdapter implementations. */
|
|
33
|
-
export async function pluginHook(adapter, payload) {
|
|
34
|
-
if (process.env.PBOT_SUBAGENT_RUN_ID)
|
|
35
|
-
return adapter.formatPass(payload);
|
|
36
|
-
const event = adapter.parseEvent(payload);
|
|
37
|
-
if (event.kind === "ignore")
|
|
38
|
-
return adapter.formatPass(payload);
|
|
39
|
-
const root = await adapter.resolveRoot(event.cwd, event.raw);
|
|
40
|
-
const configuration = await readWorkspaceConfig(root);
|
|
41
|
-
const features = workspaceFeatures(configuration);
|
|
42
|
-
if (event.kind === "check-skill") {
|
|
43
|
-
if (!configuration.enabled)
|
|
44
|
-
return adapter.formatDeny(event, disabledMessage(adapter, configuration));
|
|
45
|
-
if (!features.skills)
|
|
46
|
-
return adapter.formatDeny(event, `Personal Bot 工作区技能已在 ${configuration.path} 中停用(features.skills: false)。`);
|
|
47
|
-
return adapter.formatPass(payload);
|
|
48
|
-
}
|
|
49
|
-
if (!configuration.enabled)
|
|
50
|
-
return adapter.formatPass(payload);
|
|
51
|
-
const workspaceSkills = features.skills && !adapter.nativeWorkspaceSkills
|
|
52
|
-
? await discoverWorkspaceSkills(root)
|
|
53
|
-
: [];
|
|
54
|
-
if (!features.prompts && !workspaceSkills.length)
|
|
55
|
-
return adapter.formatPass(payload);
|
|
56
|
-
const context = await loadWorkspaceContext({
|
|
57
|
-
host: adapter.host,
|
|
58
|
-
root,
|
|
59
|
-
role: event.role,
|
|
60
|
-
...(adapter.coordinatorPrompt ? { coordinatorPrompt: adapter.coordinatorPrompt } : {}),
|
|
61
|
-
includePrompts: features.prompts,
|
|
62
|
-
includeRootAgents: features.prompts && !adapter.nativeRootAgents,
|
|
63
|
-
...(event.localRoleOnly ? { localRoleOnly: true } : {}),
|
|
64
|
-
workspaceSkills,
|
|
65
|
-
});
|
|
66
|
-
return adapter.formatContext(event, context);
|
|
67
|
-
}
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import type { PluginHostAdapter } from "../../model/plugin-host.js";
|
|
2
|
-
export declare function antigravityWorkspaceRoot(cwd: string, payload?: unknown): Promise<string>;
|
|
3
|
-
export declare const antigravityAdapter: PluginHostAdapter;
|
|
4
|
-
export declare const antigravitySkillPath: (pluginRoot: string, skill: string) => string;
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
import { realpath, stat } from "node:fs/promises";
|
|
2
|
-
import { isAbsolute, join, relative, resolve, sep } from "node:path";
|
|
3
|
-
import { object } from "../../common/json.js";
|
|
4
|
-
import { resourceRoot } from "../../common/paths.js";
|
|
5
|
-
import { requireThat } from "../../common/validation.js";
|
|
6
|
-
const supportedEvents = ["SessionStart", "PreToolUse"];
|
|
7
|
-
function workspaceFromPayload(cwd, payload) {
|
|
8
|
-
if (object(payload) && Array.isArray(payload.workspacePaths)) {
|
|
9
|
-
const first = payload.workspacePaths.find(value => typeof value === "string" && value.length > 0);
|
|
10
|
-
if (typeof first === "string")
|
|
11
|
-
return first;
|
|
12
|
-
}
|
|
13
|
-
return cwd;
|
|
14
|
-
}
|
|
15
|
-
function skillFromReadPath(targetPath, pluginRoot = process.env.PLUGIN_ROOT || resolve(resourceRoot, "..")) {
|
|
16
|
-
const skillsRoot = resolve(pluginRoot, "skills");
|
|
17
|
-
const rel = relative(skillsRoot, resolve(targetPath));
|
|
18
|
-
if (!rel || rel.startsWith("..") || isAbsolute(rel))
|
|
19
|
-
return undefined;
|
|
20
|
-
const skill = rel.split(sep)[0];
|
|
21
|
-
if (!skill || skill === "pbot")
|
|
22
|
-
return undefined;
|
|
23
|
-
return skill;
|
|
24
|
-
}
|
|
25
|
-
function isPreToolUse(payload) {
|
|
26
|
-
return object(payload) && payload.hookEventName === "PreToolUse";
|
|
27
|
-
}
|
|
28
|
-
export async function antigravityWorkspaceRoot(cwd, payload) {
|
|
29
|
-
const directory = workspaceFromPayload(cwd, payload);
|
|
30
|
-
requireThat(isAbsolute(directory), "Antigravity 工作区需要绝对路径。");
|
|
31
|
-
const root = await realpath(directory);
|
|
32
|
-
requireThat((await stat(root)).isDirectory(), "Antigravity 工作区需要目录。");
|
|
33
|
-
return root;
|
|
34
|
-
}
|
|
35
|
-
export const antigravityAdapter = {
|
|
36
|
-
host: "antigravity",
|
|
37
|
-
nativeRootAgents: true,
|
|
38
|
-
nativeWorkspaceSkills: true,
|
|
39
|
-
coordinatorPrompt: "plugin-coordinator.md",
|
|
40
|
-
initCommandHint: "/pbot init",
|
|
41
|
-
usage: "用法:node <插件目录>/lib/plugin.js antigravity init|status",
|
|
42
|
-
resolveRoot(cwd, rawPayload) {
|
|
43
|
-
return antigravityWorkspaceRoot(cwd, rawPayload);
|
|
44
|
-
},
|
|
45
|
-
parseEvent(value) {
|
|
46
|
-
requireThat(object(value) && typeof value.hookEventName === "string", "Antigravity hook 输入无效。");
|
|
47
|
-
const event = value.hookEventName;
|
|
48
|
-
requireThat(supportedEvents.includes(event), "Antigravity hook 事件未支持。");
|
|
49
|
-
const cwd = typeof value.cwd === "string" && value.cwd ? value.cwd : workspaceFromPayload("", value);
|
|
50
|
-
requireThat(cwd, "Antigravity hook 缺少工作目录。");
|
|
51
|
-
if (event === "SessionStart") {
|
|
52
|
-
return { kind: "inject-context", role: "coordinator", cwd, raw: value };
|
|
53
|
-
}
|
|
54
|
-
if (!object(value.toolCall) || typeof value.toolCall.name !== "string" || !object(value.toolCall.args)) {
|
|
55
|
-
return { kind: "ignore" };
|
|
56
|
-
}
|
|
57
|
-
const { name, args } = value.toolCall;
|
|
58
|
-
if (name === "read_file" && typeof args.Path === "string") {
|
|
59
|
-
const skill = skillFromReadPath(args.Path);
|
|
60
|
-
if (skill)
|
|
61
|
-
return { kind: "check-skill", skill, cwd, raw: value };
|
|
62
|
-
}
|
|
63
|
-
return { kind: "ignore" };
|
|
64
|
-
},
|
|
65
|
-
formatPass(payload) {
|
|
66
|
-
return isPreToolUse(payload) ? { decision: "allow" } : {};
|
|
67
|
-
},
|
|
68
|
-
formatContext(_event, context) {
|
|
69
|
-
return {
|
|
70
|
-
injectSteps: [
|
|
71
|
-
{ systemMessage: { systemMessage: context.text } },
|
|
72
|
-
],
|
|
73
|
-
};
|
|
74
|
-
},
|
|
75
|
-
formatDeny(_event, reason) {
|
|
76
|
-
return { decision: "deny", reason };
|
|
77
|
-
},
|
|
78
|
-
};
|
|
79
|
-
export const antigravitySkillPath = (pluginRoot, skill) => join(pluginRoot, "skills", skill, "SKILL.md");
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import { realpath, stat } from "node:fs/promises";
|
|
2
|
-
import { isAbsolute } from "node:path";
|
|
3
|
-
import { object } from "../../common/json.js";
|
|
4
|
-
import { requireThat } from "../../common/validation.js";
|
|
5
|
-
const supportedEvents = ["UserPromptSubmit", "PreToolUse", "UserPromptExpansion"];
|
|
6
|
-
export async function claudeWorkspaceRoot(cwd, projectDirectory = process.env.CLAUDE_PROJECT_DIR) {
|
|
7
|
-
const directory = projectDirectory || cwd;
|
|
8
|
-
requireThat(isAbsolute(directory), "Claude 工作区需要绝对路径。");
|
|
9
|
-
const root = await realpath(directory);
|
|
10
|
-
requireThat((await stat(root)).isDirectory(), "Claude 工作区需要目录。");
|
|
11
|
-
return root;
|
|
12
|
-
}
|
|
13
|
-
export const claudeAdapter = {
|
|
14
|
-
host: "claude",
|
|
15
|
-
nativeRootAgents: false,
|
|
16
|
-
nativeWorkspaceSkills: false,
|
|
17
|
-
coordinatorPrompt: "plugin-coordinator.md",
|
|
18
|
-
initCommandHint: "/personal-bot:pbot init",
|
|
19
|
-
usage: "用法:node <插件目录>/lib/claude.js init|status",
|
|
20
|
-
resolveRoot(cwd) {
|
|
21
|
-
return claudeWorkspaceRoot(cwd);
|
|
22
|
-
},
|
|
23
|
-
parseEvent(value) {
|
|
24
|
-
requireThat(object(value) && typeof value.hook_event_name === "string", "Claude hook 输入无效。");
|
|
25
|
-
const event = value.hook_event_name;
|
|
26
|
-
requireThat(supportedEvents.includes(event), "Claude hook 事件未支持。");
|
|
27
|
-
if (event === "PreToolUse" || event === "UserPromptExpansion") {
|
|
28
|
-
const skill = event === "UserPromptExpansion"
|
|
29
|
-
? value.expansion_type === "slash_command" ? value.command_name : undefined
|
|
30
|
-
: value.tool_name === "Skill" && object(value.tool_input) ? value.tool_input.skill : undefined;
|
|
31
|
-
if (typeof skill !== "string" || !skill.startsWith("personal-bot:") || skill === "personal-bot:pbot")
|
|
32
|
-
return { kind: "ignore" };
|
|
33
|
-
requireThat(typeof value.cwd === "string", "Claude hook 缺少工作目录。");
|
|
34
|
-
return { kind: "check-skill", skill, cwd: value.cwd, raw: value };
|
|
35
|
-
}
|
|
36
|
-
// Leave Claude's native subagents untouched; only inject coordinator context into main sessions.
|
|
37
|
-
if (typeof value.agent_id === "string")
|
|
38
|
-
return { kind: "ignore" };
|
|
39
|
-
requireThat(typeof value.cwd === "string", "Claude hook 缺少工作目录。");
|
|
40
|
-
return { kind: "inject-context", role: "coordinator", cwd: value.cwd, raw: value };
|
|
41
|
-
},
|
|
42
|
-
formatPass() {
|
|
43
|
-
return {};
|
|
44
|
-
},
|
|
45
|
-
formatContext(event, context) {
|
|
46
|
-
const raw = event.raw;
|
|
47
|
-
return {
|
|
48
|
-
hookSpecificOutput: {
|
|
49
|
-
hookEventName: raw.hook_event_name,
|
|
50
|
-
additionalContext: context.text,
|
|
51
|
-
},
|
|
52
|
-
};
|
|
53
|
-
},
|
|
54
|
-
formatDeny(event, reason) {
|
|
55
|
-
const raw = event.raw;
|
|
56
|
-
return raw.hook_event_name === "UserPromptExpansion"
|
|
57
|
-
? { decision: "block", reason }
|
|
58
|
-
: { hookSpecificOutput: { hookEventName: raw.hook_event_name, permissionDecision: "deny", permissionDecisionReason: reason } };
|
|
59
|
-
},
|
|
60
|
-
};
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import type { Context } from "@deepseek-ai/cordis";
|
|
2
|
-
import type { Agent } from "@deepseek-ai/dsh-agent";
|
|
3
|
-
import { HistoryService } from "../../services/history/history-service.js";
|
|
4
|
-
/** One server-owned organizer per workspace, shared by its parent Sessions. */
|
|
5
|
-
export declare class DshHistoryWork {
|
|
6
|
-
#private;
|
|
7
|
-
private readonly ctx;
|
|
8
|
-
readonly service: HistoryService;
|
|
9
|
-
constructor(ctx: Context, root: string);
|
|
10
|
-
attach(agent: Agent): () => void;
|
|
11
|
-
cancel(): void;
|
|
12
|
-
schedule(agent: Agent): void;
|
|
13
|
-
close(): Promise<void>;
|
|
14
|
-
}
|
|
15
|
-
export declare function registerDshHistoryEvents(ctx: Context, agent: Agent, work: DshHistoryWork, check: () => void): void;
|
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
import { join } from "node:path";
|
|
2
|
-
import { acpHistorySessions } from "../../storage/acp-history.js";
|
|
3
|
-
import { HistoryFiles } from "../../storage/history-files.js";
|
|
4
|
-
import { HistoryService } from "../../services/history/history-service.js";
|
|
5
|
-
import { DshHistory } from "../../integrations/dsh/history.js";
|
|
6
|
-
import { dshHistorySummarizer } from "../../integrations/dsh/history-summary.js";
|
|
7
|
-
import { finalDshAnswer } from "../../integrations/dsh/messages.js";
|
|
8
|
-
import { defaultWorkerDirectory } from "../mcp-workers.js";
|
|
9
|
-
/** One server-owned organizer per workspace, shared by its parent Sessions. */
|
|
10
|
-
export class DshHistoryWork {
|
|
11
|
-
ctx;
|
|
12
|
-
service;
|
|
13
|
-
#parents = new Set();
|
|
14
|
-
#controller;
|
|
15
|
-
#work;
|
|
16
|
-
#closing;
|
|
17
|
-
constructor(ctx, root) {
|
|
18
|
-
this.ctx = ctx;
|
|
19
|
-
this.service = new HistoryService(root, new HistoryFiles(join(root, ".pbot/history"), "dsh"), new DshHistory(ctx, root), [new HistoryFiles(join(root, ".pbot/history"), "pi"), new HistoryFiles(join(root, ".pbot/history"), "claude")], () => acpHistorySessions({ mcp: defaultWorkerDirectory() }));
|
|
20
|
-
}
|
|
21
|
-
attach(agent) { this.#parents.add(agent); return () => { this.#parents.delete(agent); }; }
|
|
22
|
-
cancel() { this.#controller?.abort(); }
|
|
23
|
-
schedule(agent) {
|
|
24
|
-
if (this.#closing || [...this.#parents].some(parent => parent.status !== "idle" || parent.inbox.nextTurn.length || parent.inbox.nextStep.length))
|
|
25
|
-
return;
|
|
26
|
-
this.cancel();
|
|
27
|
-
const controller = new AbortController(), selection = agent.model.current(), sessionId = agent.id;
|
|
28
|
-
this.#controller = controller;
|
|
29
|
-
const signal = controller.signal;
|
|
30
|
-
const work = (this.#work ?? Promise.resolve()).catch(() => { }).then(async () => {
|
|
31
|
-
signal.throwIfAborted();
|
|
32
|
-
await this.service.refresh({ host: "dsh", sessionId }, signal);
|
|
33
|
-
signal.throwIfAborted();
|
|
34
|
-
await this.service.organize(dshHistorySummarizer(this.ctx, selection, sessionId), signal);
|
|
35
|
-
}).catch(error => { if (!signal.aborted)
|
|
36
|
-
this.ctx.logger.warn("pbot 历史整理未完成:" + String(error)); });
|
|
37
|
-
this.#work = work;
|
|
38
|
-
void work.finally(() => { if (this.#work === work) {
|
|
39
|
-
this.#work = undefined;
|
|
40
|
-
this.#controller = undefined;
|
|
41
|
-
} });
|
|
42
|
-
}
|
|
43
|
-
close() {
|
|
44
|
-
if (this.#closing)
|
|
45
|
-
return this.#closing;
|
|
46
|
-
this.cancel();
|
|
47
|
-
this.#closing = (async () => { await this.#work; await this.service.close(); this.#parents.clear(); })();
|
|
48
|
-
return this.#closing;
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
export function registerDshHistoryEvents(ctx, agent, work, check) {
|
|
52
|
-
let normal = false, final = false;
|
|
53
|
-
ctx.effect(() => work.attach(agent));
|
|
54
|
-
ctx.on("session/event", (session, event) => {
|
|
55
|
-
if (session !== agent.session)
|
|
56
|
-
return;
|
|
57
|
-
if (event.type === "turn/start") {
|
|
58
|
-
normal = false;
|
|
59
|
-
final = false;
|
|
60
|
-
}
|
|
61
|
-
if (event.type === "assistant/message")
|
|
62
|
-
final = Boolean(finalDshAnswer(event).trim());
|
|
63
|
-
if (event.type === "agent/inbox/spliced" && event.data.inserted.some(message => message.source.kind === "user")) {
|
|
64
|
-
normal = false;
|
|
65
|
-
work.cancel();
|
|
66
|
-
}
|
|
67
|
-
if (event.type === "turn/end")
|
|
68
|
-
normal = event.data.reason.kind === "completed" && final;
|
|
69
|
-
});
|
|
70
|
-
ctx.on("agent/pre-step", async (_payload, next) => { work.cancel(); check(); return next(); });
|
|
71
|
-
ctx.on("agent/status", ({ agent: changed, status }) => {
|
|
72
|
-
if (changed !== agent || status !== "idle" || !normal)
|
|
73
|
-
return;
|
|
74
|
-
normal = false;
|
|
75
|
-
if (!agent.inbox.nextTurn.length && !agent.inbox.nextStep.length) {
|
|
76
|
-
try {
|
|
77
|
-
check();
|
|
78
|
-
}
|
|
79
|
-
catch (error) {
|
|
80
|
-
if (error.name === "AbortError")
|
|
81
|
-
return;
|
|
82
|
-
throw error;
|
|
83
|
-
}
|
|
84
|
-
work.schedule(agent);
|
|
85
|
-
}
|
|
86
|
-
});
|
|
87
|
-
}
|