personal-bot 0.2.19 → 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 +17 -22
- package/resources/skills/provider-connections/SKILL.md +24 -40
- package/resources/templates/workspace-agents.md +8 -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
|
@@ -0,0 +1,10 @@
|
|
|
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>>;
|
|
@@ -0,0 +1,67 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { HostId, WorkspaceContext, WorkspaceRole } from "../model/plugin-host.js";
|
|
2
|
+
import type { WorkspaceSkillMeta } from "../model/workspace-mcp.js";
|
|
3
|
+
export declare function readOptionalFile(path: string): Promise<string>;
|
|
4
|
+
export declare function readLocalRole(agent: WorkspaceRole, root: string): Promise<string>;
|
|
5
|
+
export declare function agentText(agent: WorkspaceRole, root: string, coordinatorPrompt?: string): Promise<string>;
|
|
6
|
+
export declare function formatWorkspaceSkills(skills: readonly WorkspaceSkillMeta[]): string;
|
|
7
|
+
export declare function loadWorkspaceContext(options: {
|
|
8
|
+
host: HostId;
|
|
9
|
+
root: string;
|
|
10
|
+
role: WorkspaceRole;
|
|
11
|
+
coordinatorPrompt?: string;
|
|
12
|
+
includePrompts?: boolean;
|
|
13
|
+
includeRootAgents?: boolean;
|
|
14
|
+
localRoleOnly?: boolean;
|
|
15
|
+
workspaceSkills?: readonly WorkspaceSkillMeta[];
|
|
16
|
+
}): Promise<WorkspaceContext>;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { readFile } from "node:fs/promises";
|
|
2
|
+
import { join } from "node:path";
|
|
3
|
+
import { resourceRoot } from "../common/paths.js";
|
|
4
|
+
import { requireThat } from "../common/validation.js";
|
|
5
|
+
export async function readOptionalFile(path) {
|
|
6
|
+
try {
|
|
7
|
+
return await readFile(path, "utf8");
|
|
8
|
+
}
|
|
9
|
+
catch (error) {
|
|
10
|
+
if (error.code === "ENOENT")
|
|
11
|
+
return "";
|
|
12
|
+
throw error;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
export async function readLocalRole(agent, root) {
|
|
16
|
+
const local = await readOptionalFile(join(root, "agents", agent + ".md"));
|
|
17
|
+
return local.trim() ? "工作区职责补充:\n" + local : "";
|
|
18
|
+
}
|
|
19
|
+
export async function agentText(agent, root, coordinatorPrompt = "plugin-coordinator.md") {
|
|
20
|
+
requireThat(agent === "coordinator" || agent === "general-purpose", "未知职责。");
|
|
21
|
+
let text = await readFile(join(resourceRoot, "agents", agent + ".md"), "utf8");
|
|
22
|
+
if (agent === "coordinator") {
|
|
23
|
+
text += "\n\n" + await readFile(join(resourceRoot, "prompts", coordinatorPrompt), "utf8");
|
|
24
|
+
}
|
|
25
|
+
const local = await readLocalRole(agent, root);
|
|
26
|
+
if (local)
|
|
27
|
+
text += "\n\n" + local;
|
|
28
|
+
requireThat(text.trim(), "专家职责为空。");
|
|
29
|
+
return text;
|
|
30
|
+
}
|
|
31
|
+
export function formatWorkspaceSkills(skills) {
|
|
32
|
+
if (!skills.length)
|
|
33
|
+
return "";
|
|
34
|
+
const lines = skills.map(skill => `- **${skill.name}**(\`${skill.path}\`):${skill.description}`);
|
|
35
|
+
return "## 工作区技能\n\n以下为工作区自有专业方法(位于 `.agents/skills/`),匹配任务时按需读取对应 `SKILL.md` 正文:\n" + lines.join("\n");
|
|
36
|
+
}
|
|
37
|
+
export async function loadWorkspaceContext(options) {
|
|
38
|
+
const { host, root, role, coordinatorPrompt, includePrompts = true, includeRootAgents = false, localRoleOnly = false, workspaceSkills = [], } = options;
|
|
39
|
+
const [workspace, roleText, rootAgents] = includePrompts
|
|
40
|
+
? await Promise.all([
|
|
41
|
+
readFile(join(resourceRoot, "prompts/workspace.md"), "utf8"),
|
|
42
|
+
localRoleOnly ? readLocalRole(role, root) : agentText(role, root, coordinatorPrompt),
|
|
43
|
+
includeRootAgents ? readOptionalFile(join(root, "AGENTS.md")) : Promise.resolve(""),
|
|
44
|
+
])
|
|
45
|
+
: ["", "", ""];
|
|
46
|
+
const skillsSection = formatWorkspaceSkills(workspaceSkills);
|
|
47
|
+
const environment = { host, workspaceRoot: root, resourceRoot };
|
|
48
|
+
const text = [
|
|
49
|
+
workspace,
|
|
50
|
+
roleText,
|
|
51
|
+
rootAgents,
|
|
52
|
+
skillsSection,
|
|
53
|
+
"## 环境\n\n" + JSON.stringify(environment),
|
|
54
|
+
].filter(Boolean).join("\n\n");
|
|
55
|
+
return { workspace, role: roleText, rootAgents, workspaceSkills: [...workspaceSkills], environment, text };
|
|
56
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
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;
|
|
@@ -0,0 +1,79 @@
|
|
|
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");
|
|
@@ -0,0 +1,60 @@
|
|
|
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
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { PluginHostAdapter, PluginHostId } from "../../model/plugin-host.js";
|
|
2
|
+
/** Extensible registry of hook-based plugin host adapters; runtime never branches on host IDs. */
|
|
3
|
+
export declare class PluginHostRegistry {
|
|
4
|
+
#private;
|
|
5
|
+
constructor(initial?: readonly PluginHostAdapter[]);
|
|
6
|
+
register(adapter: PluginHostAdapter): this;
|
|
7
|
+
unregister(host: PluginHostId): boolean;
|
|
8
|
+
get(host: PluginHostId): PluginHostAdapter | undefined;
|
|
9
|
+
require(host: PluginHostId): PluginHostAdapter;
|
|
10
|
+
list(): PluginHostId[];
|
|
11
|
+
}
|
|
12
|
+
export declare const pluginHosts: PluginHostRegistry;
|
|
13
|
+
export declare const registerPluginHost: (adapter: PluginHostAdapter) => PluginHostRegistry;
|
|
14
|
+
export declare const getPluginHost: (host: PluginHostId) => PluginHostAdapter | undefined;
|
|
15
|
+
export declare const listPluginHosts: () => string[];
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { requireThat } from "../../common/validation.js";
|
|
2
|
+
import { antigravityAdapter } from "./antigravity.js";
|
|
3
|
+
import { claudeAdapter } from "./claude.js";
|
|
4
|
+
/** Extensible registry of hook-based plugin host adapters; runtime never branches on host IDs. */
|
|
5
|
+
export class PluginHostRegistry {
|
|
6
|
+
#adapters = new Map();
|
|
7
|
+
constructor(initial = []) {
|
|
8
|
+
for (const adapter of initial)
|
|
9
|
+
this.register(adapter);
|
|
10
|
+
}
|
|
11
|
+
register(adapter) {
|
|
12
|
+
requireThat(typeof adapter.host === "string" && adapter.host.length > 0, "插件宿主标识无效。");
|
|
13
|
+
this.#adapters.set(adapter.host, adapter);
|
|
14
|
+
return this;
|
|
15
|
+
}
|
|
16
|
+
unregister(host) {
|
|
17
|
+
return this.#adapters.delete(host);
|
|
18
|
+
}
|
|
19
|
+
get(host) {
|
|
20
|
+
return this.#adapters.get(host);
|
|
21
|
+
}
|
|
22
|
+
require(host) {
|
|
23
|
+
const adapter = this.#adapters.get(host);
|
|
24
|
+
requireThat(adapter, `未注册的插件宿主:${host}。可用宿主:${this.list().join(", ")}`);
|
|
25
|
+
return adapter;
|
|
26
|
+
}
|
|
27
|
+
list() {
|
|
28
|
+
return [...this.#adapters.keys()];
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
export const pluginHosts = new PluginHostRegistry([claudeAdapter, antigravityAdapter]);
|
|
32
|
+
export const registerPluginHost = (adapter) => pluginHosts.register(adapter);
|
|
33
|
+
export const getPluginHost = (host) => pluginHosts.get(host);
|
|
34
|
+
export const listPluginHosts = () => pluginHosts.list();
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
export declare const mcpWorkerToolNames: readonly ["worker_create", "worker_close", "worker_request", "worker_response", "worker_output", "worker_discover"];
|
|
2
|
+
export type McpWorkerToolName = typeof mcpWorkerToolNames[number];
|
|
3
|
+
export declare function isMcpWorkerTool(name: string): boolean;
|
|
4
|
+
export type AcpBackend = string;
|
|
5
|
+
export interface AcpCommand {
|
|
6
|
+
command: string;
|
|
7
|
+
args: string[];
|
|
8
|
+
env?: Record<string, string>;
|
|
9
|
+
}
|
|
10
|
+
/** ask: forward target permission requests to the parent session; allow/deny: answer them automatically. */
|
|
11
|
+
export type AcpPermissionPolicy = "ask" | "allow" | "deny";
|
|
12
|
+
/** Workspace `acp.<name>` entry; omitting `command` keeps a registered harness's default command. */
|
|
13
|
+
export interface AcpHarnessConfig {
|
|
14
|
+
command?: string;
|
|
15
|
+
args?: string[];
|
|
16
|
+
env?: Record<string, string>;
|
|
17
|
+
permission?: AcpPermissionPolicy;
|
|
18
|
+
}
|
|
19
|
+
export type AcpCommands = Record<string, AcpHarnessConfig>;
|
|
20
|
+
export interface AcpSessionReference extends AcpCommand {
|
|
21
|
+
host: "acp";
|
|
22
|
+
backend: AcpBackend;
|
|
23
|
+
sessionId: string | null;
|
|
24
|
+
permission?: AcpPermissionPolicy;
|
|
25
|
+
capabilities?: {
|
|
26
|
+
resume: boolean;
|
|
27
|
+
load: boolean;
|
|
28
|
+
close: boolean;
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
export interface AcpModelSelection {
|
|
32
|
+
provider?: string;
|
|
33
|
+
model?: string;
|
|
34
|
+
resolvedModel?: string;
|
|
35
|
+
thinking?: string;
|
|
36
|
+
}
|
|
37
|
+
export interface AcpChoice {
|
|
38
|
+
value: string;
|
|
39
|
+
name: string;
|
|
40
|
+
description?: string;
|
|
41
|
+
}
|
|
42
|
+
export interface AcpModelsResult {
|
|
43
|
+
backend: AcpBackend;
|
|
44
|
+
models: AcpChoice[];
|
|
45
|
+
thinking: AcpChoice[];
|
|
46
|
+
currentModel?: string;
|
|
47
|
+
currentThinking?: string;
|
|
48
|
+
selection: AcpModelSelection;
|
|
49
|
+
}
|
|
50
|
+
export interface AcpModelState extends AcpModelSelection {
|
|
51
|
+
generation: string;
|
|
52
|
+
}
|
|
53
|
+
export interface AcpProcess {
|
|
54
|
+
generation: string;
|
|
55
|
+
pid: number;
|
|
56
|
+
startedAt: number;
|
|
57
|
+
}
|
|
58
|
+
export interface AcpInput {
|
|
59
|
+
generation: string;
|
|
60
|
+
requestId: string;
|
|
61
|
+
}
|
|
62
|
+
export interface AcpAnswer extends AcpInput {
|
|
63
|
+
answer: string;
|
|
64
|
+
state: "completed" | "failed" | "cancelled";
|
|
65
|
+
error?: string;
|
|
66
|
+
}
|
|
67
|
+
export interface AcpReport {
|
|
68
|
+
generation: string;
|
|
69
|
+
cycleId: string;
|
|
70
|
+
text: string;
|
|
71
|
+
}
|
|
72
|
+
export interface AcpPermission {
|
|
73
|
+
generation: string;
|
|
74
|
+
requestId: string;
|
|
75
|
+
description: string;
|
|
76
|
+
options: {
|
|
77
|
+
optionId: string;
|
|
78
|
+
name: string;
|
|
79
|
+
kind: string;
|
|
80
|
+
}[];
|
|
81
|
+
}
|
|
82
|
+
export interface AcpPermissionReply {
|
|
83
|
+
generation: string;
|
|
84
|
+
requestId: string;
|
|
85
|
+
optionId: string | null;
|
|
86
|
+
}
|
|
87
|
+
export type AcpElicitationAction = "accept" | "decline" | "cancel";
|
|
88
|
+
export type AcpElicitationValue = string | number | boolean | string[];
|
|
89
|
+
export type AcpElicitationContent = Record<string, AcpElicitationValue>;
|
|
90
|
+
export interface AcpElicitation {
|
|
91
|
+
generation: string;
|
|
92
|
+
requestId: string;
|
|
93
|
+
mode: "form" | "url";
|
|
94
|
+
message: string;
|
|
95
|
+
schema?: Record<string, unknown>;
|
|
96
|
+
url?: string;
|
|
97
|
+
}
|
|
98
|
+
export interface AcpElicitationReply {
|
|
99
|
+
generation: string;
|
|
100
|
+
requestId: string;
|
|
101
|
+
action: AcpElicitationAction;
|
|
102
|
+
content?: AcpElicitationContent;
|
|
103
|
+
}
|
|
104
|
+
export interface AcpStartOptions {
|
|
105
|
+
name?: string;
|
|
106
|
+
message?: string;
|
|
107
|
+
files?: string[];
|
|
108
|
+
provider?: string;
|
|
109
|
+
model?: string;
|
|
110
|
+
thinking?: string;
|
|
111
|
+
cwd?: string;
|
|
112
|
+
tools?: string[];
|
|
113
|
+
noExtensions?: boolean;
|
|
114
|
+
noSkills?: boolean;
|
|
115
|
+
noPromptTemplates?: boolean;
|
|
116
|
+
noContextFiles?: boolean;
|
|
117
|
+
}
|
|
118
|
+
export interface AcpLaunchContext {
|
|
119
|
+
readonly reference: AcpSessionReference;
|
|
120
|
+
readonly cwd: string;
|
|
121
|
+
readonly directory: string;
|
|
122
|
+
readonly packageRoot: string;
|
|
123
|
+
readonly options: AcpStartOptions;
|
|
124
|
+
readonly env: NodeJS.ProcessEnv;
|
|
125
|
+
readonly features?: {
|
|
126
|
+
readonly prompts: boolean;
|
|
127
|
+
readonly skills: boolean;
|
|
128
|
+
readonly mcp: boolean;
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
export interface AcpPreparedLaunch {
|
|
132
|
+
readonly command: AcpSessionReference;
|
|
133
|
+
readonly env: NodeJS.ProcessEnv;
|
|
134
|
+
readonly sessionMeta?: Record<string, unknown>;
|
|
135
|
+
readonly defaultThinking?: string;
|
|
136
|
+
}
|
|
137
|
+
/** Narrow adapter isolating harness-specific ACP conventions from the generic runtime. */
|
|
138
|
+
export interface AcpHarnessAdapter {
|
|
139
|
+
readonly id: AcpBackend;
|
|
140
|
+
/** Product name users say in conversation, e.g. "Claude Code". */
|
|
141
|
+
readonly label?: string;
|
|
142
|
+
/** Alternative backend names accepted from callers; configured custom names take precedence. */
|
|
143
|
+
readonly aliases?: readonly string[];
|
|
144
|
+
readonly defaultCommand?: AcpCommand;
|
|
145
|
+
readonly installHint?: string;
|
|
146
|
+
readonly configureHint?: string;
|
|
147
|
+
readonly exactAnswer?: boolean;
|
|
148
|
+
readonly eagerSessionId?: boolean;
|
|
149
|
+
readonly requireSystemPrompt?: boolean;
|
|
150
|
+
readonly nativeWorkspaceSkills?: boolean;
|
|
151
|
+
readonly nativeWorkspaceMcp?: boolean;
|
|
152
|
+
readonly customNotificationMethod?: string;
|
|
153
|
+
filterStartOptions?(options: AcpStartOptions): AcpStartOptions;
|
|
154
|
+
validateStartOptions?(options: AcpStartOptions): void;
|
|
155
|
+
prepareLaunch?(context: AcpLaunchContext): Promise<AcpPreparedLaunch> | AcpPreparedLaunch;
|
|
156
|
+
parseModelValue?(value: string): {
|
|
157
|
+
provider?: string;
|
|
158
|
+
model: string;
|
|
159
|
+
};
|
|
160
|
+
formatModelQuery?(model: string, provider?: string): string | undefined;
|
|
161
|
+
parseCustomNotification?(params: unknown, sessionId: string): {
|
|
162
|
+
resolvedModel?: string;
|
|
163
|
+
} | undefined;
|
|
164
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export const mcpWorkerToolNames = [
|
|
2
|
+
"worker_create",
|
|
3
|
+
"worker_close",
|
|
4
|
+
"worker_request",
|
|
5
|
+
"worker_response",
|
|
6
|
+
"worker_output",
|
|
7
|
+
"worker_discover",
|
|
8
|
+
];
|
|
9
|
+
export function isMcpWorkerTool(name) {
|
|
10
|
+
const bare = name.startsWith("mcp__pbot__") ? name.slice("mcp__pbot__".length) : name;
|
|
11
|
+
return bare === "pbot_worker" || mcpWorkerToolNames.includes(bare);
|
|
12
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import type { WorkspaceSkillMeta } from "./workspace-mcp.js";
|
|
2
|
+
export type HostId = string;
|
|
3
|
+
export type PluginHostId = string;
|
|
4
|
+
export type WorkspaceRole = "coordinator" | "general-purpose";
|
|
5
|
+
export interface WorkspaceEnvironment {
|
|
6
|
+
host: HostId;
|
|
7
|
+
workspaceRoot: string;
|
|
8
|
+
resourceRoot: string;
|
|
9
|
+
}
|
|
10
|
+
export interface WorkspaceContext {
|
|
11
|
+
workspace: string;
|
|
12
|
+
role: string;
|
|
13
|
+
rootAgents: string;
|
|
14
|
+
workspaceSkills: WorkspaceSkillMeta[];
|
|
15
|
+
environment: WorkspaceEnvironment;
|
|
16
|
+
text: string;
|
|
17
|
+
}
|
|
18
|
+
export type HostEvent = {
|
|
19
|
+
kind: "ignore";
|
|
20
|
+
} | {
|
|
21
|
+
kind: "inject-context";
|
|
22
|
+
role: WorkspaceRole;
|
|
23
|
+
localRoleOnly?: boolean;
|
|
24
|
+
cwd: string;
|
|
25
|
+
raw: unknown;
|
|
26
|
+
} | {
|
|
27
|
+
kind: "check-skill";
|
|
28
|
+
skill: string;
|
|
29
|
+
cwd: string;
|
|
30
|
+
raw: unknown;
|
|
31
|
+
};
|
|
32
|
+
export interface PluginHostAdapter {
|
|
33
|
+
readonly host: PluginHostId;
|
|
34
|
+
readonly nativeRootAgents: boolean;
|
|
35
|
+
readonly nativeWorkspaceSkills?: boolean;
|
|
36
|
+
readonly coordinatorPrompt?: string;
|
|
37
|
+
readonly initCommandHint: string;
|
|
38
|
+
readonly usage: string;
|
|
39
|
+
resolveRoot(cwd: string, rawPayload?: unknown): Promise<string>;
|
|
40
|
+
parseEvent(payload: unknown): HostEvent;
|
|
41
|
+
formatPass(payload: unknown): Record<string, unknown>;
|
|
42
|
+
formatContext(event: Extract<HostEvent, {
|
|
43
|
+
kind: "inject-context";
|
|
44
|
+
}>, context: WorkspaceContext): Record<string, unknown>;
|
|
45
|
+
formatDeny(event: Extract<HostEvent, {
|
|
46
|
+
kind: "check-skill";
|
|
47
|
+
}>, reason: string): Record<string, unknown>;
|
|
48
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { AcpCommands } from "./acp.js";
|
|
2
|
+
export interface WorkspaceFeatures {
|
|
3
|
+
prompts?: boolean;
|
|
4
|
+
skills?: boolean;
|
|
5
|
+
mcp?: boolean;
|
|
6
|
+
}
|
|
7
|
+
export interface ResolvedWorkspaceFeatures {
|
|
8
|
+
readonly prompts: boolean;
|
|
9
|
+
readonly skills: boolean;
|
|
10
|
+
readonly mcp: boolean;
|
|
11
|
+
}
|
|
12
|
+
export interface WorkspaceConfig {
|
|
13
|
+
enabled?: boolean;
|
|
14
|
+
features?: WorkspaceFeatures;
|
|
15
|
+
acp?: AcpCommands;
|
|
16
|
+
}
|
|
17
|
+
export interface WorkspaceConfiguration {
|
|
18
|
+
path: string;
|
|
19
|
+
present: boolean;
|
|
20
|
+
enabled: boolean;
|
|
21
|
+
error?: string;
|
|
22
|
+
features?: WorkspaceFeatures;
|
|
23
|
+
acp?: AcpCommands;
|
|
24
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
export declare const workspaceMcpToolNames: readonly ["workspace_mcp_discover", "workspace_mcp_call"];
|
|
2
|
+
export type WorkspaceMcpToolName = typeof workspaceMcpToolNames[number];
|
|
3
|
+
export interface WorkspaceMcpServerBase {
|
|
4
|
+
description?: string;
|
|
5
|
+
timeout?: number;
|
|
6
|
+
enabled?: boolean;
|
|
7
|
+
}
|
|
8
|
+
export interface WorkspaceMcpStdioServer extends WorkspaceMcpServerBase {
|
|
9
|
+
command: string;
|
|
10
|
+
args?: string[];
|
|
11
|
+
env?: Record<string, string>;
|
|
12
|
+
cwd?: string;
|
|
13
|
+
}
|
|
14
|
+
export interface WorkspaceMcpHttpServer extends WorkspaceMcpServerBase {
|
|
15
|
+
url: string;
|
|
16
|
+
headers?: Record<string, string>;
|
|
17
|
+
}
|
|
18
|
+
export type WorkspaceMcpServer = WorkspaceMcpStdioServer | WorkspaceMcpHttpServer;
|
|
19
|
+
export interface WorkspaceMcpConfig {
|
|
20
|
+
mcpServers: Record<string, WorkspaceMcpServer>;
|
|
21
|
+
}
|
|
22
|
+
export interface WorkspaceMcpConfiguration {
|
|
23
|
+
path: string;
|
|
24
|
+
present: boolean;
|
|
25
|
+
servers: Record<string, WorkspaceMcpServer>;
|
|
26
|
+
error?: string;
|
|
27
|
+
}
|
|
28
|
+
export interface ResolvedWorkspaceMcpStdioServer {
|
|
29
|
+
readonly transport: "stdio";
|
|
30
|
+
readonly name: string;
|
|
31
|
+
readonly command: string;
|
|
32
|
+
readonly args: string[];
|
|
33
|
+
readonly env: Record<string, string>;
|
|
34
|
+
readonly cwd: string;
|
|
35
|
+
readonly description?: string;
|
|
36
|
+
readonly timeout: number;
|
|
37
|
+
}
|
|
38
|
+
export interface ResolvedWorkspaceMcpHttpServer {
|
|
39
|
+
readonly transport: "http";
|
|
40
|
+
readonly name: string;
|
|
41
|
+
readonly url: string;
|
|
42
|
+
readonly headers: Record<string, string>;
|
|
43
|
+
readonly description?: string;
|
|
44
|
+
readonly timeout: number;
|
|
45
|
+
}
|
|
46
|
+
export type ResolvedWorkspaceMcpServer = ResolvedWorkspaceMcpStdioServer | ResolvedWorkspaceMcpHttpServer;
|
|
47
|
+
export interface WorkspaceSkillMeta {
|
|
48
|
+
readonly name: string;
|
|
49
|
+
readonly description: string;
|
|
50
|
+
readonly path: string;
|
|
51
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function main(args: readonly string[]): Promise<void>;
|