personal-bot 0.2.20 → 0.3.0
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 +3 -3
- package/.claude-plugin/plugin.json +2 -5
- package/.mcp.json +11 -0
- package/CONTEXT.md +17 -73
- package/README.md +41 -120
- package/README.zh-CN.md +41 -120
- package/docs/README.md +31 -23
- package/docs/architecture/design.md +74 -0
- package/docs/architecture/extensibility.md +78 -0
- package/docs/architecture/model-context.md +31 -0
- package/docs/architecture/model-instruction-guidelines.md +34 -0
- package/docs/architecture/principles.md +33 -0
- package/docs/guides/capabilities.md +36 -0
- package/docs/guides/cross-harness-workers.md +83 -0
- package/docs/guides/history.md +25 -0
- package/docs/guides/workspace-configuration.md +102 -0
- package/docs/hosts/antigravity.md +52 -0
- package/docs/hosts/claude-code.md +47 -0
- package/docs/hosts/dsh.md +67 -0
- package/docs/hosts/pi.md +49 -0
- package/docs/maintainers/release.md +59 -0
- package/hooks/hooks.json +0 -3
- package/lib/antigravity-plugin/hooks.json +23 -0
- package/lib/antigravity-plugin/lib/claude.d.ts +1 -0
- package/lib/antigravity-plugin/lib/claude.js +13 -0
- package/lib/antigravity-plugin/lib/common/json.d.ts +6 -0
- package/lib/antigravity-plugin/lib/common/json.js +16 -0
- package/lib/antigravity-plugin/lib/common/paths.d.ts +1 -0
- package/lib/antigravity-plugin/lib/common/paths.js +2 -0
- package/lib/antigravity-plugin/lib/common/validation.d.ts +3 -0
- package/lib/antigravity-plugin/lib/common/validation.js +8 -0
- package/lib/antigravity-plugin/lib/common/version.d.ts +3 -0
- package/lib/antigravity-plugin/lib/common/version.js +13 -0
- package/lib/antigravity-plugin/lib/extension/acp-worker.js +11597 -0
- package/lib/antigravity-plugin/lib/extension/mcp.js +2715 -0
- package/lib/antigravity-plugin/lib/extension/plugin-runtime.d.ts +10 -0
- package/lib/antigravity-plugin/lib/extension/plugin-runtime.js +67 -0
- package/lib/antigravity-plugin/lib/integrations/agent-resources.d.ts +16 -0
- package/lib/antigravity-plugin/lib/integrations/agent-resources.js +56 -0
- package/lib/antigravity-plugin/lib/integrations/hosts/antigravity.d.ts +4 -0
- package/lib/antigravity-plugin/lib/integrations/hosts/antigravity.js +79 -0
- package/lib/antigravity-plugin/lib/integrations/hosts/claude.d.ts +3 -0
- package/lib/antigravity-plugin/lib/integrations/hosts/claude.js +60 -0
- package/lib/antigravity-plugin/lib/integrations/hosts/registry.d.ts +15 -0
- package/lib/antigravity-plugin/lib/integrations/hosts/registry.js +34 -0
- package/lib/antigravity-plugin/lib/model/acp.d.ts +164 -0
- package/lib/antigravity-plugin/lib/model/acp.js +12 -0
- package/lib/antigravity-plugin/lib/model/plugin-host.d.ts +48 -0
- package/lib/antigravity-plugin/lib/model/workspace-config.d.ts +24 -0
- package/lib/antigravity-plugin/lib/model/workspace-config.js +1 -0
- package/lib/antigravity-plugin/lib/model/workspace-mcp.d.ts +51 -0
- package/lib/antigravity-plugin/lib/model/workspace-mcp.js +4 -0
- package/lib/antigravity-plugin/lib/plugin.d.ts +1 -0
- package/lib/antigravity-plugin/lib/plugin.js +17 -0
- package/lib/antigravity-plugin/lib/services/workspace/workspace-config.d.ts +8 -0
- package/lib/antigravity-plugin/lib/services/workspace/workspace-config.js +93 -0
- package/lib/antigravity-plugin/lib/services/workspace/workspace-preparation.d.ts +3 -0
- package/lib/antigravity-plugin/lib/services/workspace/workspace-preparation.js +26 -0
- package/lib/antigravity-plugin/lib/services/workspace/workspace-skills.d.ts +8 -0
- package/lib/antigravity-plugin/lib/services/workspace/workspace-skills.js +91 -0
- package/lib/antigravity-plugin/lib/storage/atomic-json.d.ts +11 -0
- package/lib/antigravity-plugin/lib/storage/atomic-json.js +101 -0
- package/lib/antigravity-plugin/mcp_config.json +13 -0
- package/lib/antigravity-plugin/package.json +6 -0
- package/lib/antigravity-plugin/plugin.json +7 -0
- package/lib/antigravity-plugin/resources/agents/coordinator.md +11 -0
- package/{resources/claude → lib/antigravity-plugin/resources}/agents/general-purpose.md +0 -5
- package/lib/antigravity-plugin/resources/prompts/plugin-coordinator.md +1 -0
- package/lib/antigravity-plugin/resources/prompts/workspace.md +31 -0
- package/lib/antigravity-plugin/resources/references/compute-finance.md +22 -0
- package/lib/antigravity-plugin/resources/references/compute.md +16 -0
- package/lib/antigravity-plugin/resources/references/task-conductor.md +25 -0
- package/lib/antigravity-plugin/resources/templates/workspace-agents.md +21 -0
- package/lib/antigravity-plugin/skills/pbot/SKILL.md +16 -0
- package/lib/antigravity-plugin/skills/project-maintenance/SKILL.md +35 -0
- package/lib/antigravity-plugin/skills/provider-connections/SKILL.md +42 -0
- package/lib/claude.js +4 -11
- package/lib/client.js +14 -531
- package/lib/common/markdown.js +2 -3
- package/lib/common/validation.d.ts +2 -0
- package/lib/common/validation.js +4 -0
- package/lib/extension/acp-member.d.ts +2 -0
- package/lib/extension/acp-member.js +9 -8
- package/lib/extension/acp-worker.js +11578 -121
- package/lib/extension/dsh/acp-member.js +26 -2
- package/lib/extension/dsh/command.js +19 -57
- package/lib/extension/dsh/history.js +2 -4
- package/lib/extension/dsh/management.d.ts +0 -2
- package/lib/extension/dsh/management.js +27 -126
- package/lib/extension/dsh/workspace.d.ts +5 -47
- package/lib/extension/dsh/workspace.js +76 -108
- package/lib/extension/mcp-bridge.d.ts +41 -0
- package/lib/extension/mcp-bridge.js +412 -0
- package/lib/extension/mcp-workers.d.ts +980 -0
- package/lib/extension/mcp-workers.js +882 -0
- package/lib/extension/mcp.js +2715 -0
- package/lib/extension/plugin-runtime.d.ts +10 -0
- package/lib/extension/plugin-runtime.js +67 -0
- package/lib/extension/setup-cli.js +215 -2
- package/lib/integrations/acp/agents.d.ts +10 -11
- package/lib/integrations/acp/agents.js +65 -33
- package/lib/integrations/acp/claude.d.ts +2 -2
- package/lib/integrations/acp/claude.js +5 -3
- package/lib/integrations/acp/connection.d.ts +17 -4
- package/lib/integrations/acp/connection.js +53 -27
- package/lib/integrations/acp/executable.d.ts +3 -0
- package/lib/integrations/acp/executable.js +42 -0
- package/lib/integrations/acp/harnesses/claude.d.ts +2 -0
- package/lib/integrations/acp/harnesses/claude.js +49 -0
- package/lib/integrations/acp/harnesses/dsh.d.ts +2 -0
- package/lib/integrations/acp/harnesses/dsh.js +35 -0
- package/lib/integrations/acp/harnesses/generic.d.ts +13 -0
- package/lib/integrations/acp/harnesses/generic.js +37 -0
- package/lib/integrations/acp/harnesses/pi.d.ts +2 -0
- package/lib/integrations/acp/harnesses/pi.js +34 -0
- package/lib/integrations/acp/harnesses/presets.d.ts +3 -0
- package/lib/integrations/acp/harnesses/presets.js +20 -0
- package/lib/integrations/acp/launch.d.ts +33 -4
- package/lib/integrations/acp/launch.js +60 -48
- package/lib/integrations/acp/mcp.d.ts +6 -0
- package/lib/integrations/acp/mcp.js +40 -0
- package/lib/integrations/acp/model-selection.d.ts +9 -2
- package/lib/integrations/acp/model-selection.js +73 -27
- package/lib/integrations/acp/registry.d.ts +18 -0
- package/lib/integrations/acp/registry.js +50 -0
- package/lib/integrations/agent-resources.d.ts +16 -1
- package/lib/integrations/agent-resources.js +45 -9
- package/lib/integrations/dsh/mcp.d.ts +4 -0
- package/lib/integrations/dsh/mcp.js +28 -0
- package/lib/integrations/dsh/resources.d.ts +3 -3
- package/lib/integrations/dsh/resources.js +21 -12
- package/lib/integrations/dsh/skills.d.ts +5 -1
- package/lib/integrations/dsh/skills.js +10 -6
- package/lib/integrations/hosts/antigravity.d.ts +4 -0
- package/lib/integrations/hosts/antigravity.js +79 -0
- package/lib/integrations/hosts/claude.d.ts +3 -0
- package/lib/integrations/hosts/claude.js +60 -0
- package/lib/integrations/hosts/registry.d.ts +15 -0
- package/lib/integrations/hosts/registry.js +34 -0
- package/lib/model/acp.d.ts +107 -2
- package/lib/model/acp.js +12 -1
- package/lib/model/agent.d.ts +35 -33
- package/lib/model/plugin-host.d.ts +48 -0
- package/lib/model/plugin-host.js +1 -0
- package/lib/model/workspace-config.d.ts +12 -0
- package/lib/model/workspace-mcp.d.ts +51 -0
- package/lib/model/workspace-mcp.js +4 -0
- package/lib/plugin.d.ts +1 -0
- package/lib/plugin.js +17 -0
- package/lib/services/agents/acp-run.d.ts +13 -1
- package/lib/services/agents/acp-run.js +30 -2
- package/lib/services/agents/agent-service.d.ts +35 -120
- package/lib/services/agents/agent-service.js +156 -160
- package/lib/services/installation/setup-service.js +17 -1
- package/lib/services/workspace/workspace-config.d.ts +2 -1
- package/lib/services/workspace/workspace-config.js +39 -7
- package/lib/services/workspace/workspace-mcp.d.ts +14 -0
- package/lib/services/workspace/workspace-mcp.js +200 -0
- package/lib/services/workspace/workspace-skills.d.ts +8 -0
- package/lib/services/workspace/workspace-skills.js +91 -0
- package/lib/storage/acp-files.d.ts +3 -1
- package/lib/storage/acp-files.js +32 -2
- package/lib/storage/acp-history.d.ts +3 -2
- package/lib/storage/acp-history.js +19 -7
- package/lib/storage/agent-files.d.ts +8 -8
- package/lib/storage/agent-files.js +27 -47
- package/lib/tools/history/contract.d.ts +1 -1
- package/lib/tools/history/contract.js +17 -11
- package/lib/ui/dsh/index.js +8 -3
- package/lib/ui/dsh/management.d.ts +1 -1
- package/lib/ui/dsh/management.js +24 -456
- package/lib/ui/dsh/remote.d.ts +0 -2
- package/lib/ui/dsh/remote.js +1 -1
- package/package.json +12 -7
- package/resources/agents/coordinator.md +2 -2
- package/resources/antigravity/skills/pbot/SKILL.md +16 -0
- package/resources/claude/skills/pbot/SKILL.md +1 -1
- package/resources/prompts/history-coordinator.md +1 -0
- package/resources/prompts/plugin-coordinator.md +1 -0
- package/resources/prompts/workspace.md +9 -8
- package/resources/references/compute.md +9 -11
- package/resources/references/task-conductor.md +12 -26
- package/resources/skills/project-maintenance/SKILL.md +16 -21
- package/resources/skills/provider-connections/SKILL.md +24 -40
- package/resources/templates/workspace-agents.md +4 -0
- package/scripts/README.md +17 -34
- package/src/claude.ts +4 -8
- package/src/common/markdown.ts +2 -3
- package/src/common/validation.ts +6 -0
- package/src/extension/acp-member.ts +9 -8
- package/src/extension/acp-worker.ts +239 -97
- package/src/extension/command.ts +38 -36
- package/src/extension/dsh/acp-member.ts +21 -2
- package/src/extension/dsh/command.ts +21 -51
- package/src/extension/dsh/files.ts +1 -0
- package/src/extension/dsh/history.ts +9 -6
- package/src/extension/dsh/management.ts +27 -58
- package/src/extension/dsh/workspace.ts +88 -99
- package/src/extension/events.ts +13 -10
- package/src/extension/history.ts +2 -50
- package/src/extension/lifecycle.ts +37 -22
- package/src/extension/mcp-bridge.ts +412 -0
- package/src/extension/mcp-workers.ts +941 -0
- package/src/extension/pi-acp-member.ts +29 -5
- package/src/extension/plugin-runtime.ts +63 -0
- package/src/extension/setup-cli.ts +186 -2
- package/src/integrations/acp/agents.ts +70 -24
- package/src/integrations/acp/claude.ts +11 -4
- package/src/integrations/acp/connection.ts +63 -25
- package/src/integrations/acp/executable.ts +41 -0
- package/src/integrations/acp/harnesses/claude.ts +50 -0
- package/src/integrations/acp/harnesses/dsh.ts +40 -0
- package/src/integrations/acp/harnesses/generic.ts +52 -0
- package/src/integrations/acp/harnesses/pi.ts +35 -0
- package/src/integrations/acp/harnesses/presets.ts +22 -0
- package/src/integrations/acp/launch.ts +69 -47
- package/src/integrations/acp/mcp.ts +43 -0
- package/src/integrations/acp/model-selection.ts +68 -25
- package/src/integrations/acp/registry.ts +60 -0
- package/src/integrations/agent-resources.ts +70 -6
- package/src/integrations/dsh/mcp.ts +30 -0
- package/src/integrations/dsh/resources.ts +28 -13
- package/src/integrations/dsh/skills.ts +16 -6
- package/src/integrations/hosts/antigravity.ts +83 -0
- package/src/integrations/hosts/claude.ts +62 -0
- package/src/integrations/hosts/registry.ts +42 -0
- package/src/integrations/pi/mcp.ts +26 -0
- package/src/mcp.ts +14 -0
- package/src/model/acp.ts +113 -3
- package/src/model/agent.ts +18 -14
- package/src/model/plugin-host.ts +39 -0
- package/src/model/workspace-config.ts +14 -0
- package/src/model/workspace-mcp.ts +64 -0
- package/src/pbot.ts +69 -20
- package/src/plugin.ts +19 -0
- package/src/services/agents/acp-run.ts +35 -3
- package/src/services/agents/agent-service.ts +180 -160
- package/src/services/installation/setup-service.ts +17 -2
- package/src/services/workspace/workspace-config.ts +42 -6
- package/src/services/workspace/workspace-mcp.ts +242 -0
- package/src/services/workspace/workspace-skills.ts +78 -0
- package/src/storage/acp-files.ts +32 -3
- package/src/storage/acp-history.ts +18 -7
- package/src/storage/agent-files.ts +27 -41
- package/src/tools/history/contract.ts +17 -11
- package/src/tools/register.ts +4 -8
- package/src/ui/dsh/index.ts +8 -3
- package/src/ui/dsh/management.ts +40 -282
- package/src/ui/dsh/remote.ts +2 -2
- package/docs/adr/0001-claude-skill-discovery.md +0 -3
- package/docs/adr/0002-claude-native-collaboration.md +0 -3
- package/docs/agent-collaboration.md +0 -190
- package/docs/architecture-guidelines.md +0 -37
- package/docs/capability-design.md +0 -55
- package/docs/claude-code-design.md +0 -44
- package/docs/claude-code.md +0 -57
- package/docs/dsh.md +0 -337
- package/docs/file-storage.md +0 -97
- package/docs/history.md +0 -54
- package/docs/installation-design.md +0 -86
- package/docs/interaction-design.md +0 -21
- package/docs/model-context.md +0 -76
- package/docs/model-instruction-guidelines.md +0 -51
- package/docs/release.md +0 -108
- package/docs/technical-design.md +0 -163
- package/docs/workspace-configuration.md +0 -79
- package/lib/extension/claude-hooks.d.ts +0 -9
- package/lib/extension/claude-hooks.js +0 -78
- package/lib/extension/dsh/agent-events.d.ts +0 -24
- package/lib/extension/dsh/agent-events.js +0 -242
- package/lib/extension/dsh/agent-runtime.d.ts +0 -49
- package/lib/extension/dsh/agent-runtime.js +0 -351
- package/lib/integrations/dsh/dsh-agents.d.ts +0 -30
- package/lib/integrations/dsh/dsh-agents.js +0 -104
- package/lib/integrations/dsh/input.d.ts +0 -21
- package/lib/integrations/dsh/input.js +0 -62
- package/lib/integrations/dsh/notifications.d.ts +0 -8
- package/lib/integrations/dsh/notifications.js +0 -55
- package/lib/integrations/dsh/session.d.ts +0 -14
- package/lib/integrations/dsh/session.js +0 -60
- package/lib/integrations/team-context.d.ts +0 -18
- package/lib/integrations/team-context.js +0 -61
- package/lib/model/team.d.ts +0 -85
- package/lib/services/agents/agent-notices.d.ts +0 -13
- package/lib/services/agents/agent-notices.js +0 -25
- package/lib/services/agents/start-options.d.ts +0 -4
- package/lib/services/agents/start-options.js +0 -20
- package/lib/services/agents/team-service.d.ts +0 -168
- package/lib/services/agents/team-service.js +0 -345
- package/lib/storage/team-files.d.ts +0 -16
- package/lib/storage/team-files.js +0 -111
- package/lib/tools/agents/actions.d.ts +0 -62
- package/lib/tools/agents/actions.js +0 -62
- package/lib/tools/agents/contract.d.ts +0 -181
- package/lib/tools/agents/contract.js +0 -84
- package/lib/tools/agents/dsh-tool.d.ts +0 -5
- package/lib/tools/agents/dsh-tool.js +0 -34
- package/lib/tools/result.d.ts +0 -18
- package/lib/tools/result.js +0 -10
- package/lib/tools/teams/actions.d.ts +0 -23
- package/lib/tools/teams/actions.js +0 -40
- package/lib/tools/teams/contract.d.ts +0 -201
- package/lib/tools/teams/contract.js +0 -91
- package/lib/tools/teams/dsh-tool.d.ts +0 -8
- package/lib/tools/teams/dsh-tool.js +0 -39
- package/lib/ui/dsh/attachments.d.ts +0 -5
- package/lib/ui/dsh/attachments.js +0 -39
- package/resources/prompts/claude-coordinator.md +0 -1
- package/resources/prompts/native-coordinator.md +0 -1
- package/resources/prompts/team-member.md +0 -7
- package/src/extension/agent-events.ts +0 -210
- package/src/extension/agents-command.ts +0 -89
- package/src/extension/claude-hooks.ts +0 -74
- package/src/extension/dsh/agent-events.ts +0 -148
- package/src/extension/dsh/agent-runtime.ts +0 -252
- package/src/extension/subagent-entry.ts +0 -270
- package/src/extension/teams-command.ts +0 -67
- package/src/integrations/dsh/dsh-agents.ts +0 -97
- package/src/integrations/dsh/input.ts +0 -66
- package/src/integrations/dsh/notifications.ts +0 -46
- package/src/integrations/pi/agent-context.ts +0 -18
- package/src/integrations/pi/agent-input.ts +0 -19
- package/src/integrations/pi/pi-agents.ts +0 -84
- package/src/integrations/pi/team-context.ts +0 -26
- package/src/integrations/team-context.ts +0 -64
- package/src/model/team.ts +0 -29
- package/src/services/agents/agent-notices.ts +0 -28
- package/src/services/agents/start-options.ts +0 -19
- package/src/services/agents/team-service.ts +0 -275
- package/src/storage/team-files.ts +0 -93
- package/src/tools/agents/actions.ts +0 -57
- package/src/tools/agents/contract.ts +0 -101
- package/src/tools/agents/dsh-tool.ts +0 -37
- package/src/tools/agents/tool.ts +0 -20
- package/src/tools/teams/actions.ts +0 -34
- package/src/tools/teams/contract.ts +0 -109
- package/src/tools/teams/dsh-tool.ts +0 -45
- package/src/tools/teams/tool.ts +0 -29
- package/src/ui/agent-display.ts +0 -14
- package/src/ui/dsh/attachments.ts +0 -42
- package/src/ui/pi/menu.ts +0 -37
- package/src/ui/pi/reader.ts +0 -46
- /package/lib/{model/team.js → antigravity-plugin/lib/model/plugin-host.js} +0 -0
|
@@ -1,23 +1,21 @@
|
|
|
1
|
+
import { existsSync } from "node:fs";
|
|
1
2
|
import { realpath } from "node:fs/promises";
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
3
|
+
import { resolve } from "node:path";
|
|
4
|
+
import * as McpClient from "@deepseek-ai/dsh-mcp-client";
|
|
4
5
|
import { rootAgents } from "../../integrations/dsh/root-agents.js";
|
|
5
|
-
import {
|
|
6
|
-
import { dshResources, dshExpertTools } from "../../integrations/dsh/resources.js";
|
|
7
|
-
import { AgentService } from "../../services/agents/agent-service.js";
|
|
8
|
-
import { TeamService } from "../../services/agents/team-service.js";
|
|
9
|
-
import { registerDshAgentTool } from "../../tools/agents/dsh-tool.js";
|
|
10
|
-
import { registerDshTeamTool, registerDshTeamMessageTool } from "../../tools/teams/dsh-tool.js";
|
|
11
|
-
import { DshAgentRuntime } from "./agent-runtime.js";
|
|
12
|
-
import { DshAgentEvents } from "./agent-events.js";
|
|
6
|
+
import { dshResources } from "../../integrations/dsh/resources.js";
|
|
13
7
|
import { registerDshFileEvents } from "./files.js";
|
|
14
8
|
import { DshHistoryWork, registerDshHistoryEvents } from "./history.js";
|
|
15
9
|
import { registerDshHistoryTool } from "../../tools/history/dsh-tool.js";
|
|
10
|
+
import { resourceRoot } from "../../common/paths.js";
|
|
16
11
|
import { requireThat } from "../../common/validation.js";
|
|
12
|
+
import { toDshMcpConfig } from "../../integrations/dsh/mcp.js";
|
|
17
13
|
import { registerDshSkills } from "../../integrations/dsh/skills.js";
|
|
18
|
-
import { readWorkspaceConfig, workspaceDisabledMessage } from "../../services/workspace/workspace-config.js";
|
|
14
|
+
import { readWorkspaceConfig, workspaceDisabledMessage, workspaceFeatures } from "../../services/workspace/workspace-config.js";
|
|
15
|
+
import { readWorkspaceMcpConfig, resolveWorkspaceMcpServer } from "../../services/workspace/workspace-mcp.js";
|
|
19
16
|
import { initializeWorkspace } from "../../services/workspace/workspace-preparation.js";
|
|
20
|
-
|
|
17
|
+
import { McpWorkerRuntime, defaultWorkerDirectory } from "../mcp-workers.js";
|
|
18
|
+
export const dshDependencies = ["agents", "sessions", "sessionPersistence", "sessionQuery", "llm", "tools", "systemPrompt", "skills", "fs", "workingDirectory", "approval"];
|
|
21
19
|
export class DshWorkspace {
|
|
22
20
|
ctx;
|
|
23
21
|
root;
|
|
@@ -25,96 +23,82 @@ export class DshWorkspace {
|
|
|
25
23
|
component;
|
|
26
24
|
historyWork;
|
|
27
25
|
releaseHistory;
|
|
26
|
+
features;
|
|
28
27
|
lifetime = new AbortController();
|
|
29
|
-
host;
|
|
30
|
-
agents;
|
|
31
|
-
teams;
|
|
32
28
|
history;
|
|
33
|
-
|
|
34
|
-
#experts = new Map();
|
|
29
|
+
workers;
|
|
35
30
|
#scope;
|
|
36
|
-
#events;
|
|
37
31
|
#closing;
|
|
38
|
-
constructor(ctx, root, agent, component, historyWork, releaseHistory,
|
|
32
|
+
constructor(ctx, root, agent, component, historyWork, releaseHistory, features = workspaceFeatures()) {
|
|
39
33
|
this.ctx = ctx;
|
|
40
34
|
this.root = root;
|
|
41
35
|
this.agent = agent;
|
|
42
36
|
this.component = component;
|
|
43
37
|
this.historyWork = historyWork;
|
|
44
38
|
this.releaseHistory = releaseHistory;
|
|
39
|
+
this.features = features;
|
|
45
40
|
this.history = historyWork.service;
|
|
46
|
-
this.
|
|
47
|
-
this.host = new DshAgents(ctx, agent, {
|
|
48
|
-
setup: (d, _directory, generation) => async (agentCtx, child) => {
|
|
49
|
-
await agentCtx.plugin({ name: "pbot-expert", inject: dshDependencies, apply: async (scope) => {
|
|
50
|
-
const runtime = new DshAgentRuntime(scope, child, d, generation, this.agents.files, this.teams, { check: this.check, release: () => this.host.release(d.agentId, generation) });
|
|
51
|
-
this.#experts.set(d.agentId, runtime);
|
|
52
|
-
scope.effect(() => () => { if (this.#experts.get(d.agentId) === runtime)
|
|
53
|
-
this.#experts.delete(d.agentId); });
|
|
54
|
-
registerDshSkills(scope, child);
|
|
55
|
-
await dshResources(scope, child, root, "general-purpose", runtime.check);
|
|
56
|
-
const teamTool = dshExpertTools(scope, child, d.options);
|
|
57
|
-
if (teamTool)
|
|
58
|
-
registerDshTeamMessageTool(scope, child, this.teams, runtime.actor, runtime.check);
|
|
59
|
-
registerDshFileEvents(scope, child, root, true, runtime.check);
|
|
60
|
-
runtime.initialize(teamTool);
|
|
61
|
-
} });
|
|
62
|
-
return { commit: this.check };
|
|
63
|
-
},
|
|
64
|
-
ready: (child, generation) => {
|
|
65
|
-
const runtime = this.#experts.get(child.id);
|
|
66
|
-
requireThat(runtime?.generation === generation, "专家执行组件未就绪。");
|
|
67
|
-
runtime.start();
|
|
68
|
-
},
|
|
69
|
-
stopping: async (child, generation) => { const runtime = this.#experts.get(child.id); if (runtime?.generation === generation)
|
|
70
|
-
await runtime.stop(); },
|
|
71
|
-
}, this.lifetime.signal);
|
|
72
|
-
const directory = dshHomePath("pbot", "subagents");
|
|
73
|
-
this.agents = new AgentService(root, directory, new AgentBackends(this.host, directory, acp));
|
|
74
|
-
this.teams = new TeamService(root, this.agents.files, this.agents.teamFiles);
|
|
41
|
+
this.workers = new McpWorkerRuntime(defaultWorkerDirectory(), agent.id, "dsh");
|
|
75
42
|
}
|
|
76
43
|
check = () => { this.component.throwIfAborted(); this.lifetime.signal.throwIfAborted(); };
|
|
77
|
-
get controlError() { return this.#events?.error; }
|
|
78
44
|
async open() {
|
|
79
45
|
this.check();
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
46
|
+
const mcpEntry = resolve(resourceRoot, "../lib/extension/mcp.js");
|
|
47
|
+
const workerDir = defaultWorkerDirectory();
|
|
48
|
+
this.#scope = await this.agent.ctx.plugin({
|
|
49
|
+
name: "pbot-coordinator",
|
|
50
|
+
inject: dshDependencies,
|
|
51
|
+
apply: async (ctx) => {
|
|
52
|
+
if (this.features.skills)
|
|
53
|
+
registerDshSkills(ctx, this.agent, { workspaceRoot: this.root });
|
|
54
|
+
if (this.features.prompts)
|
|
55
|
+
await dshResources(ctx, this.agent, this.root, "coordinator", this.check, "history-coordinator.md");
|
|
83
56
|
registerDshFileEvents(ctx, this.agent, this.root, false, this.check);
|
|
84
|
-
registerDshAgentTool(ctx, this.agent, this.agents, this.owner, this.check);
|
|
85
|
-
registerDshTeamTool(ctx, this.agent, this.teams, this.agents, this.owner, this.check);
|
|
86
|
-
registerDshTeamMessageTool(ctx, this.agent, this.teams, () => ({ kind: "coordinator", owner: this.owner }), this.check);
|
|
87
57
|
registerDshHistoryTool(ctx, this.agent, this.history, this.lifetime.signal, this.check);
|
|
88
58
|
registerDshHistoryEvents(ctx, this.agent, this.historyWork, this.check);
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
59
|
+
if (existsSync(mcpEntry)) {
|
|
60
|
+
await ctx.plugin(McpClient, McpClient.Config({
|
|
61
|
+
transport: "stdio",
|
|
62
|
+
serverName: "pbot",
|
|
63
|
+
command: process.execPath,
|
|
64
|
+
args: [mcpEntry],
|
|
65
|
+
env: {
|
|
66
|
+
...(process.env.PATH ? { PATH: process.env.PATH } : {}),
|
|
67
|
+
...(process.env.HOME ? { HOME: process.env.HOME } : {}),
|
|
68
|
+
...(process.env.DSH_HOME ? { DSH_HOME: process.env.DSH_HOME } : {}),
|
|
69
|
+
PBOT_HOST: "dsh",
|
|
70
|
+
PBOT_WORKSPACE_ROOT: this.root,
|
|
71
|
+
PBOT_MCP_AGENT_DIR: workerDir,
|
|
72
|
+
PBOT_MCP_SESSION_ID: this.agent.id,
|
|
73
|
+
},
|
|
74
|
+
cwd: this.root,
|
|
75
|
+
toolCallTimeoutMs: 600_000,
|
|
76
|
+
failOnStartupError: false,
|
|
77
|
+
}));
|
|
78
|
+
}
|
|
79
|
+
if (this.features.mcp) {
|
|
80
|
+
const mcpConfig = await readWorkspaceMcpConfig(this.root);
|
|
81
|
+
this.check();
|
|
82
|
+
if (mcpConfig.error) {
|
|
83
|
+
this.ctx.logger.warn(mcpConfig.error);
|
|
84
|
+
}
|
|
85
|
+
else {
|
|
86
|
+
for (const [serverName, server] of Object.entries(mcpConfig.servers)) {
|
|
87
|
+
if (server.enabled === false)
|
|
88
|
+
continue;
|
|
89
|
+
try {
|
|
90
|
+
const resolved = resolveWorkspaceMcpServer(this.root, serverName, server);
|
|
91
|
+
await ctx.plugin(McpClient, toDshMcpConfig(resolved));
|
|
92
|
+
}
|
|
93
|
+
catch (error) {
|
|
94
|
+
this.ctx.logger.warn(error instanceof Error ? error.message : String(error));
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
},
|
|
100
|
+
});
|
|
111
101
|
this.check();
|
|
112
|
-
const view = this.agents.status(id, this.owner), runtime = this.#experts.get(id);
|
|
113
|
-
requireThat(view.owned, "专家不属于当前父会话。");
|
|
114
|
-
requireThat(view.alive, "专家已停止;需要明确恢复后才能对话。");
|
|
115
|
-
requireThat(view.state !== "starting", "专家尚未就绪,请等待启动或恢复完成。");
|
|
116
|
-
requireThat(runtime?.generation === view.generation, "原生专家由其他执行实例持有;当前组件不能接管对话。");
|
|
117
|
-
return runtime;
|
|
118
102
|
}
|
|
119
103
|
close() {
|
|
120
104
|
if (this.#closing)
|
|
@@ -123,30 +107,11 @@ export class DshWorkspace {
|
|
|
123
107
|
this.#closing = (async () => {
|
|
124
108
|
const errors = [];
|
|
125
109
|
try {
|
|
126
|
-
await this
|
|
110
|
+
await this.workers.close();
|
|
127
111
|
}
|
|
128
112
|
catch (error) {
|
|
129
113
|
errors.push(error);
|
|
130
114
|
}
|
|
131
|
-
try {
|
|
132
|
-
this.teams.pauseAll(this.owner, "父会话或执行组件关闭");
|
|
133
|
-
}
|
|
134
|
-
catch (error) {
|
|
135
|
-
errors.push(error);
|
|
136
|
-
}
|
|
137
|
-
try {
|
|
138
|
-
await this.agents.close(this.owner);
|
|
139
|
-
}
|
|
140
|
-
catch (error) {
|
|
141
|
-
errors.push(error);
|
|
142
|
-
}
|
|
143
|
-
try {
|
|
144
|
-
await this.host.close();
|
|
145
|
-
}
|
|
146
|
-
catch (error) {
|
|
147
|
-
errors.push(error);
|
|
148
|
-
}
|
|
149
|
-
this.teams.dispose();
|
|
150
115
|
try {
|
|
151
116
|
await this.#scope?.dispose();
|
|
152
117
|
}
|
|
@@ -160,7 +125,7 @@ export class DshWorkspace {
|
|
|
160
125
|
errors.push(error);
|
|
161
126
|
}
|
|
162
127
|
if (errors.length)
|
|
163
|
-
throw new AggregateError(errors, "dsh
|
|
128
|
+
throw new AggregateError(errors, "dsh 工作区关闭失败;请核对执行资源。");
|
|
164
129
|
})();
|
|
165
130
|
return this.#closing;
|
|
166
131
|
}
|
|
@@ -194,7 +159,9 @@ export class DshWorkspaces {
|
|
|
194
159
|
const owned = entry;
|
|
195
160
|
owned.users++;
|
|
196
161
|
let released = false;
|
|
197
|
-
return {
|
|
162
|
+
return {
|
|
163
|
+
work: owned.work,
|
|
164
|
+
release: async () => {
|
|
198
165
|
if (released)
|
|
199
166
|
return;
|
|
200
167
|
released = true;
|
|
@@ -207,11 +174,12 @@ export class DshWorkspaces {
|
|
|
207
174
|
this.#histories.delete(root);
|
|
208
175
|
}
|
|
209
176
|
}
|
|
210
|
-
}
|
|
177
|
+
},
|
|
178
|
+
};
|
|
211
179
|
}
|
|
212
180
|
async open(agent) {
|
|
213
181
|
this.#lifetime.signal.throwIfAborted();
|
|
214
|
-
requireThat(rootAgents(this.ctx.agents).includes(agent), "
|
|
182
|
+
requireThat(rootAgents(this.ctx.agents).includes(agent), "子会话不拥有协调者管理入口。");
|
|
215
183
|
const current = this.#parents.get(agent);
|
|
216
184
|
if (current)
|
|
217
185
|
return current;
|
|
@@ -235,7 +203,7 @@ export class DshWorkspaces {
|
|
|
235
203
|
const history = await this.history(root);
|
|
236
204
|
let workspace;
|
|
237
205
|
try {
|
|
238
|
-
workspace = new DshWorkspace(this.ctx, root, agent, this.#lifetime.signal, history.work, history.release, configuration
|
|
206
|
+
workspace = new DshWorkspace(this.ctx, root, agent, this.#lifetime.signal, history.work, history.release, workspaceFeatures(configuration));
|
|
239
207
|
const owned = workspace;
|
|
240
208
|
const dispose = agent.ctx.effect(() => async () => {
|
|
241
209
|
this.#parents.delete(agent);
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { resolveWorkspaceMcpServers } from "../services/workspace/workspace-mcp.js";
|
|
2
|
+
export declare class WorkspaceMcpBridge {
|
|
3
|
+
#private;
|
|
4
|
+
discover(root: string, serverName?: string): Promise<{
|
|
5
|
+
workspace: string;
|
|
6
|
+
configPath: string;
|
|
7
|
+
servers: ({
|
|
8
|
+
url: string;
|
|
9
|
+
timeout?: number;
|
|
10
|
+
description?: string;
|
|
11
|
+
name: string;
|
|
12
|
+
transport: string;
|
|
13
|
+
enabled: boolean;
|
|
14
|
+
} | {
|
|
15
|
+
command: string;
|
|
16
|
+
args: string[];
|
|
17
|
+
timeout?: number;
|
|
18
|
+
description?: string;
|
|
19
|
+
name: string;
|
|
20
|
+
transport: string;
|
|
21
|
+
enabled: boolean;
|
|
22
|
+
})[];
|
|
23
|
+
} | {
|
|
24
|
+
tools: unknown[];
|
|
25
|
+
description?: string;
|
|
26
|
+
workspace: string;
|
|
27
|
+
server: string;
|
|
28
|
+
transport: "stdio" | "http";
|
|
29
|
+
configPath?: never;
|
|
30
|
+
servers?: never;
|
|
31
|
+
}>;
|
|
32
|
+
call(root: string, serverName: string, toolName: string, args?: Record<string, unknown>): Promise<{
|
|
33
|
+
structuredContent?: {} | null;
|
|
34
|
+
server: string;
|
|
35
|
+
tool: string;
|
|
36
|
+
isError: boolean;
|
|
37
|
+
content: any[];
|
|
38
|
+
}>;
|
|
39
|
+
close(): Promise<void>;
|
|
40
|
+
}
|
|
41
|
+
export { resolveWorkspaceMcpServers };
|