personal-bot 0.3.1 → 0.3.2
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 +1 -1
- package/README.md +1 -1
- package/README.zh-CN.md +1 -1
- package/bin/pbot-pi-acp.mjs +27 -11
- package/bin/pbot.mjs +1 -1
- package/docs/README.md +1 -1
- package/docs/architecture/design.md +23 -10
- package/docs/architecture/extensibility.md +20 -18
- package/docs/architecture/model-context.md +2 -2
- package/docs/architecture/principles.md +4 -3
- package/docs/guides/capabilities.md +3 -3
- package/docs/guides/history.md +50 -16
- package/docs/guides/workspace-configuration.md +31 -6
- package/docs/hosts/antigravity.md +2 -0
- package/docs/hosts/claude-code.md +1 -1
- package/docs/hosts/dsh.md +1 -1
- package/docs/hosts/pi.md +1 -1
- package/hooks/hooks.json +3 -0
- package/lib/antigravity-plugin/hooks.json +7 -0
- package/lib/antigravity-plugin/lib/claude.js +2 -2
- package/lib/antigravity-plugin/lib/extension/acp-worker.js +156 -11
- package/lib/antigravity-plugin/lib/extension/{plugin-runtime.d.ts → hosts/plugin-runtime.d.ts} +2 -2
- package/lib/antigravity-plugin/lib/extension/{plugin-runtime.js → hosts/plugin-runtime.js} +34 -8
- package/lib/antigravity-plugin/lib/extension/mcp.js +1113 -78
- package/lib/antigravity-plugin/lib/integrations/agent-resources.d.ts +1 -0
- package/lib/antigravity-plugin/lib/integrations/agent-resources.js +5 -1
- 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.js → claude/adapter.js} +32 -4
- package/lib/antigravity-plugin/lib/integrations/hosts/{registry.js → plugin-registry.js} +2 -2
- package/lib/antigravity-plugin/lib/model/history.d.ts +169 -0
- package/lib/antigravity-plugin/lib/model/plugin-host.d.ts +26 -0
- package/lib/antigravity-plugin/lib/model/workspace-config.d.ts +25 -0
- package/lib/antigravity-plugin/lib/plugin.js +2 -2
- package/lib/antigravity-plugin/lib/services/history/history-capture.d.ts +4 -0
- package/lib/antigravity-plugin/lib/services/history/history-capture.js +86 -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/history-migrate.d.ts +12 -0
- package/lib/antigravity-plugin/lib/services/history/history-migrate.js +88 -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 +36 -0
- package/lib/antigravity-plugin/lib/services/history/summary-runner.d.ts +37 -0
- package/lib/antigravity-plugin/lib/services/history/summary-runner.js +301 -0
- package/lib/antigravity-plugin/lib/services/workspace/workspace-config.d.ts +5 -1
- package/lib/antigravity-plugin/lib/services/workspace/workspace-config.js +73 -4
- 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 +54 -0
- package/lib/antigravity-plugin/lib/storage/history-files.js +467 -0
- package/lib/antigravity-plugin/lib/storage/history-format.d.ts +6 -0
- package/lib/antigravity-plugin/lib/storage/history-format.js +62 -0
- package/lib/antigravity-plugin/package.json +1 -1
- package/lib/antigravity-plugin/plugin.json +1 -1
- package/lib/antigravity-plugin/skills/provider-connections/SKILL.md +22 -12
- package/lib/claude.js +2 -2
- package/lib/client.js +21 -11
- package/lib/dsh.js +4 -4
- package/lib/extension/{acp-member.d.ts → acp/member.d.ts} +5 -5
- package/lib/extension/{acp-member.js → acp/member.js} +6 -6
- package/lib/extension/acp/worker.d.ts +1 -0
- package/lib/extension/acp/worker.js +384 -0
- package/lib/extension/acp-worker.js +156 -11
- package/lib/extension/{dsh → hosts/dsh}/acp-member.js +8 -8
- package/lib/extension/hosts/dsh/command.js +92 -0
- package/lib/extension/{dsh → hosts/dsh}/files.js +3 -3
- 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 +32 -70
- package/lib/extension/{plugin-runtime.d.ts → hosts/plugin-runtime.d.ts} +2 -2
- package/lib/extension/{plugin-runtime.js → hosts/plugin-runtime.js} +34 -8
- package/lib/extension/{mcp-bridge.d.ts → mcp/bridge.d.ts} +1 -1
- package/lib/extension/{mcp-bridge.js → mcp/bridge.js} +4 -4
- package/lib/extension/{mcp-workers.d.ts → mcp/workers.d.ts} +222 -2
- package/lib/extension/{mcp-workers.js → mcp/workers.js} +229 -63
- package/lib/extension/mcp.js +1113 -78
- package/lib/extension/{setup-cli.js → setup/cli.js} +9 -9
- 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/history-summary.d.ts +17 -0
- package/lib/integrations/acp/history-summary.js +100 -0
- package/lib/integrations/agent-resources.d.ts +1 -0
- package/lib/integrations/agent-resources.js +5 -1
- 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.js → claude/adapter.js} +32 -4
- package/lib/integrations/{dsh → hosts/dsh}/mcp.d.ts +1 -1
- package/lib/integrations/{dsh → hosts/dsh}/resources.d.ts +1 -1
- package/lib/integrations/{dsh → hosts/dsh}/resources.js +4 -4
- package/lib/integrations/{dsh → hosts/dsh}/schema.js +1 -1
- package/lib/integrations/{dsh → hosts/dsh}/skills.js +1 -1
- package/lib/integrations/hosts/{registry.js → plugin-registry.js} +2 -2
- package/lib/integrations/installation/pi-setup.js +1 -1
- package/lib/model/history.d.ts +133 -34
- package/lib/model/plugin-host.d.ts +26 -0
- package/lib/model/workspace-config.d.ts +25 -0
- package/lib/plugin.js +2 -2
- package/lib/services/agents/agent-run.d.ts +1 -1
- package/lib/services/history/history-capture.d.ts +4 -0
- package/lib/services/history/history-capture.js +86 -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 +88 -0
- package/lib/services/history/history-query.d.ts +51 -0
- package/lib/services/history/history-query.js +371 -0
- package/lib/services/history/summary-command.d.ts +20 -0
- package/lib/services/history/summary-command.js +68 -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 +36 -0
- package/lib/services/history/summary-runner.d.ts +37 -0
- package/lib/services/history/summary-runner.js +301 -0
- package/lib/services/workspace/workspace-config.d.ts +5 -1
- package/lib/services/workspace/workspace-config.js +73 -4
- package/lib/storage/history-files.d.ts +45 -9
- package/lib/storage/history-files.js +373 -247
- package/lib/storage/history-format.d.ts +3 -12
- package/lib/storage/history-format.js +26 -50
- package/lib/tools/history/actions.d.ts +3 -68
- package/lib/tools/history/actions.js +7 -5
- package/lib/tools/history/contract.d.ts +14 -7
- package/lib/tools/history/contract.js +58 -18
- package/lib/tools/history/dsh-tool.d.ts +1 -2
- package/lib/tools/history/dsh-tool.js +11 -5
- package/lib/ui/dsh/management.js +18 -5
- package/package.json +1 -1
- package/resources/prompts/history-coordinator.md +1 -1
- package/resources/prompts/history-monthly-summary.md +13 -0
- package/resources/prompts/history-summary.md +10 -4
- package/resources/skills/provider-connections/SKILL.md +22 -12
- package/src/claude.ts +2 -2
- package/src/dsh.ts +4 -4
- 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/{dsh → hosts/dsh}/acp-member.ts +9 -9
- package/src/extension/hosts/dsh/command.ts +92 -0
- 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 -50
- package/src/extension/{pi-acp-member.ts → hosts/pi/acp-member.ts} +9 -9
- package/src/extension/hosts/pi/command.ts +158 -0
- package/src/extension/{events.ts → hosts/pi/events.ts} +14 -4
- package/src/extension/hosts/pi/history.ts +45 -0
- package/src/extension/{lifecycle.ts → hosts/pi/lifecycle.ts} +7 -11
- package/src/extension/{plugin-runtime.ts → hosts/plugin-runtime.ts} +29 -9
- package/src/extension/{mcp-bridge.ts → mcp/bridge.ts} +5 -5
- package/src/extension/{mcp-workers.ts → mcp/workers.ts} +237 -64
- package/src/extension/{setup-cli.ts → setup/cli.ts} +11 -11
- 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/history-summary.ts +108 -0
- package/src/integrations/agent-resources.ts +6 -0
- package/src/integrations/hosts/antigravity/adapter.ts +161 -0
- package/src/integrations/hosts/{claude.ts → claude/adapter.ts} +28 -5
- 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} +2 -2
- package/src/integrations/installation/pi-setup.ts +1 -1
- package/src/mcp.ts +1 -1
- package/src/model/history.ts +151 -26
- package/src/model/plugin-host.ts +26 -2
- package/src/model/workspace-config.ts +30 -0
- package/src/pbot.ts +13 -22
- package/src/plugin.ts +2 -2
- package/src/services/history/history-capture.ts +83 -0
- package/src/services/history/history-index.ts +48 -62
- package/src/services/history/history-migrate.ts +89 -0
- package/src/services/history/history-query.ts +415 -0
- package/src/services/history/summary-command.ts +69 -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 +44 -0
- package/src/services/history/summary-runner.ts +352 -0
- package/src/services/workspace/workspace-config.ts +91 -5
- package/src/storage/history-files.ts +408 -188
- package/src/storage/history-format.ts +46 -60
- package/src/tools/history/actions.ts +8 -6
- package/src/tools/history/contract.ts +65 -20
- package/src/tools/history/dsh-tool.ts +17 -8
- package/src/tools/history/pi-tool.ts +21 -0
- package/src/tools/register.ts +3 -4
- package/src/ui/dsh/management.ts +27 -11
- package/src/ui/{confirmation.ts → pi/confirmation.ts} +1 -1
- 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/extension/dsh/command.js +0 -50
- package/lib/extension/dsh/history.d.ts +0 -15
- package/lib/extension/dsh/history.js +0 -87
- 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/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/src/extension/command.ts +0 -76
- package/src/extension/dsh/command.ts +0 -54
- package/src/extension/dsh/history.ts +0 -74
- package/src/extension/history.ts +0 -26
- 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/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/history/tool.ts +0 -19
- /package/lib/antigravity-plugin/lib/integrations/hosts/{registry.d.ts → plugin-registry.d.ts} +0 -0
- /package/lib/{extension/acp-worker.d.ts → antigravity-plugin/lib/model/history.js} +0 -0
- /package/lib/extension/{dsh → hosts/dsh}/acp-member.d.ts +0 -0
- /package/lib/extension/{dsh → hosts/dsh}/command.d.ts +0 -0
- /package/lib/extension/{dsh → hosts/dsh}/files.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}/mcp.js +0 -0
- /package/lib/integrations/{dsh → hosts/dsh}/messages.d.ts +0 -0
- /package/lib/integrations/{dsh → hosts/dsh}/messages.js +0 -0
- /package/lib/integrations/{dsh → hosts/dsh}/root-agents.d.ts +0 -0
- /package/lib/integrations/{dsh → hosts/dsh}/root-agents.js +0 -0
- /package/lib/integrations/{dsh → hosts/dsh}/schema.d.ts +0 -0
- /package/lib/integrations/{dsh → hosts/dsh}/skills.d.ts +0 -0
- /package/lib/integrations/hosts/{registry.d.ts → plugin-registry.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
|
@@ -4,14 +4,14 @@ import { mkdir, readFile, realpath } from "node:fs/promises";
|
|
|
4
4
|
import { homedir } from "node:os";
|
|
5
5
|
import { join } from "node:path";
|
|
6
6
|
import { fileURLToPath } from "node:url";
|
|
7
|
-
import { executeSetup, packageChoices, parseCatalog, parseSetupArgs } from "
|
|
8
|
-
import { npmName, ordinaryNpm } from "
|
|
9
|
-
import { PiBootstrapRequired, PiSetup, piPackageName } from "
|
|
10
|
-
import { findExecutable, inspectSystem, SetupProcesses } from "
|
|
11
|
-
import { resolveWorkspace } from "
|
|
12
|
-
import { readWorkspaceMcpConfig, removeWorkspaceMcpServer, upsertWorkspaceMcpServer, } from "
|
|
13
|
-
import { SetupUI } from "
|
|
14
|
-
const root = new URL("
|
|
7
|
+
import { executeSetup, packageChoices, parseCatalog, parseSetupArgs } from "../../services/installation/setup-service.js";
|
|
8
|
+
import { npmName, ordinaryNpm } from "../../common/package-source.js";
|
|
9
|
+
import { PiBootstrapRequired, PiSetup, piPackageName } from "../../integrations/installation/pi-setup.js";
|
|
10
|
+
import { findExecutable, inspectSystem, SetupProcesses } from "../../integrations/installation/processes.js";
|
|
11
|
+
import { resolveWorkspace } from "../../integrations/installation/workspace.js";
|
|
12
|
+
import { readWorkspaceMcpConfig, removeWorkspaceMcpServer, upsertWorkspaceMcpServer, } from "../../services/workspace/workspace-mcp.js";
|
|
13
|
+
import { SetupUI } from "../../ui/setup.js";
|
|
14
|
+
const root = new URL("../../../", import.meta.url);
|
|
15
15
|
const quote = (value) => "'" + value.replaceAll("'", "'\\''") + "'";
|
|
16
16
|
const mcpManageUsage = "用法:\n" +
|
|
17
17
|
" pbot mcp list [--workspace <目录>]\n" +
|
|
@@ -334,7 +334,7 @@ export async function main(args) {
|
|
|
334
334
|
}
|
|
335
335
|
else {
|
|
336
336
|
ui.text("稍后执行:\ncd " + quote(workspace) + "\n" + quote(result.pi.command) + " --extension " +
|
|
337
|
-
quote(fileURLToPath(new URL("extension/setup
|
|
337
|
+
quote(fileURLToPath(new URL("extension/setup/guard.js", new URL("../../", import.meta.url)))) + " '/pbot init'");
|
|
338
338
|
}
|
|
339
339
|
return failed ? 1 : 0;
|
|
340
340
|
}
|
|
@@ -17,16 +17,6 @@ export interface OpenAcpOptions {
|
|
|
17
17
|
}
|
|
18
18
|
/** One ACP v1 connection. The worker owns its process group and business state; harness hooks stay in AcpHarnessAdapter. */
|
|
19
19
|
export declare function openAcp(reference: AcpSessionReference, cwd: string, env: NodeJS.ProcessEnv, callbacks: AcpCallbacks, signal: AbortSignal, openOptions?: OpenAcpOptions): Promise<{
|
|
20
|
-
sessionId: string;
|
|
21
|
-
capabilities: {
|
|
22
|
-
resume: boolean;
|
|
23
|
-
load: boolean;
|
|
24
|
-
close: boolean;
|
|
25
|
-
};
|
|
26
|
-
signal: AbortSignal;
|
|
27
|
-
close: () => Promise<void>;
|
|
28
|
-
images: boolean;
|
|
29
|
-
systemPrompt: boolean;
|
|
30
20
|
selection: () => AcpModelSelection;
|
|
31
21
|
choices: () => {
|
|
32
22
|
currentThinking?: string;
|
|
@@ -37,4 +27,15 @@ export declare function openAcp(reference: AcpSessionReference, cwd: string, env
|
|
|
37
27
|
configure(requested: AgentOptions): Promise<AcpModelSelection>;
|
|
38
28
|
prompt(content: acp.ContentBlock[]): Promise<acp.PromptResponse>;
|
|
39
29
|
cancel(): Promise<void>;
|
|
30
|
+
startupInfo?: string;
|
|
31
|
+
sessionId: string;
|
|
32
|
+
capabilities: {
|
|
33
|
+
resume: boolean;
|
|
34
|
+
load: boolean;
|
|
35
|
+
close: boolean;
|
|
36
|
+
};
|
|
37
|
+
signal: AbortSignal;
|
|
38
|
+
close: () => Promise<void>;
|
|
39
|
+
images: boolean;
|
|
40
|
+
systemPrompt: boolean;
|
|
40
41
|
}>;
|
|
@@ -2,6 +2,7 @@ import { spawn } from "node:child_process";
|
|
|
2
2
|
import { Readable, Writable } from "node:stream";
|
|
3
3
|
import { setTimeout as delay } from "node:timers/promises";
|
|
4
4
|
import * as acp from "@agentclientprotocol/sdk";
|
|
5
|
+
import { object } from "../../common/json.js";
|
|
5
6
|
import { requireThat } from "../../common/validation.js";
|
|
6
7
|
import { packageVersion } from "../../common/version.js";
|
|
7
8
|
import { acpChoices, acpModelSelection, acpModelValue, acpThinkingValue } from "./model-selection.js";
|
|
@@ -133,10 +134,14 @@ export async function openAcp(reference, cwd, env, callbacks, signal, openOption
|
|
|
133
134
|
systemPrompt: { mode: "append", content: [{ type: "text", text: openOptions.systemPrompt }] },
|
|
134
135
|
} : {}),
|
|
135
136
|
};
|
|
137
|
+
let startupInfo;
|
|
136
138
|
if (reference.sessionId === null) {
|
|
137
139
|
const created = await connection.agent.request(acp.methods.agent.session.new, setup, { cancellationSignal: AbortSignal.any([cancel, AbortSignal.timeout(30_000)]), stopWaitingOnCancel: true });
|
|
138
140
|
sessionId = created.sessionId;
|
|
139
141
|
options = created.configOptions ?? [];
|
|
142
|
+
if (object(created._meta) && object(created._meta.piAcp) && typeof created._meta.piAcp.startupInfo === "string") {
|
|
143
|
+
startupInfo = created._meta.piAcp.startupInfo;
|
|
144
|
+
}
|
|
140
145
|
}
|
|
141
146
|
else {
|
|
142
147
|
requireThat(capabilities.resume || capabilities.load, "目标 ACP 后端不支持恢复已有会话,请新建 worker。");
|
|
@@ -151,6 +156,7 @@ export async function openAcp(reference, cwd, env, callbacks, signal, openOption
|
|
|
151
156
|
return {
|
|
152
157
|
sessionId: activeId, capabilities, signal: connected, close, images: advertised?.promptCapabilities?.image === true,
|
|
153
158
|
systemPrompt: Boolean(advertised?.sessionCapabilities?.systemPrompt),
|
|
159
|
+
...(startupInfo ? { startupInfo } : {}),
|
|
154
160
|
selection,
|
|
155
161
|
choices: () => acpChoices(options),
|
|
156
162
|
async configure(requested) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { object } from "../../../common/json.js";
|
|
2
2
|
import { requireThat } from "../../../common/validation.js";
|
|
3
|
-
import { claudeOptions } from "../claude.js";
|
|
3
|
+
import { claudeOptions } from "../claude-settings.js";
|
|
4
4
|
import { defaultPrepareLaunch, filterStandardAcpOptions, validateStandardAcpOptions } from "./generic.js";
|
|
5
5
|
export const claudeAcpHarness = {
|
|
6
6
|
id: "claude",
|
|
@@ -16,7 +16,7 @@ export const dshAcpHarness = {
|
|
|
16
16
|
async prepareLaunch(context) {
|
|
17
17
|
const base = defaultPrepareLaunch(context);
|
|
18
18
|
const patch = join(context.directory, "acp-dsh-patch.json");
|
|
19
|
-
await writeFile(patch, JSON.stringify([{ insert: [{ id: "pbot-acp-member", name: join(context.packageRoot, "lib/extension/dsh/acp-member.js") }] }]) + "\n", { mode: 0o600 });
|
|
19
|
+
await writeFile(patch, JSON.stringify([{ insert: [{ id: "pbot-acp-member", name: join(context.packageRoot, "lib/extension/hosts/dsh/acp-member.js") }] }]) + "\n", { mode: 0o600 });
|
|
20
20
|
return {
|
|
21
21
|
...base,
|
|
22
22
|
command: { ...base.command, args: [...base.command.args, "--patch", patch] },
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { AcpBackend, AcpCommands } from "../../model/acp.js";
|
|
2
|
+
import type { HistorySummarizer } from "../../model/history.js";
|
|
3
|
+
export interface AcpHistorySummarizerOptions {
|
|
4
|
+
cwd: string;
|
|
5
|
+
backend?: AcpBackend;
|
|
6
|
+
commands?: AcpCommands;
|
|
7
|
+
model?: string;
|
|
8
|
+
thinking?: string;
|
|
9
|
+
timeoutMs?: number;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Spawns one isolated, ephemeral ACP worker process per summary task (default backend: "pi").
|
|
13
|
+
* Each worker runs with PBOT_SUBAGENT_RUN_ID set (so no host records raw history),
|
|
14
|
+
* denies all write/tool permissions, uses the target harness's default model unless overridden,
|
|
15
|
+
* and exits immediately after returning the summary text.
|
|
16
|
+
*/
|
|
17
|
+
export declare function createAcpHistorySummarizer(options: AcpHistorySummarizerOptions): HistorySummarizer;
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { fork } from "node:child_process";
|
|
2
|
+
import { existsSync } from "node:fs";
|
|
3
|
+
import { resolve } from "node:path";
|
|
4
|
+
import { resourceRoot } from "../../common/paths.js";
|
|
5
|
+
import { requireThat } from "../../common/validation.js";
|
|
6
|
+
import { acpLaunch, canonicalAcpBackend } from "./launch.js";
|
|
7
|
+
const defaultTimeoutMs = 180_000;
|
|
8
|
+
/**
|
|
9
|
+
* Spawns one isolated, ephemeral ACP worker process per summary task (default backend: "pi").
|
|
10
|
+
* Each worker runs with PBOT_SUBAGENT_RUN_ID set (so no host records raw history),
|
|
11
|
+
* denies all write/tool permissions, uses the target harness's default model unless overridden,
|
|
12
|
+
* and exits immediately after returning the summary text.
|
|
13
|
+
*/
|
|
14
|
+
export function createAcpHistorySummarizer(options) {
|
|
15
|
+
const workerPath = resolve(resourceRoot, "../lib/extension/acp-worker.js");
|
|
16
|
+
requireThat(process.platform === "linux" || process.platform === "darwin", "ACP 摘要 worker 当前支持 Linux 和 macOS。");
|
|
17
|
+
requireThat(existsSync(workerPath), "缺少 ACP worker 构建产物;请先运行 npm run build。");
|
|
18
|
+
const commands = options.commands ?? {};
|
|
19
|
+
const backend = canonicalAcpBackend(options.backend ?? "pi", commands);
|
|
20
|
+
const reference = acpLaunch(backend, commands, {});
|
|
21
|
+
const timeoutMs = options.timeoutMs ?? defaultTimeoutMs;
|
|
22
|
+
return async (request, signal) => {
|
|
23
|
+
signal.throwIfAborted();
|
|
24
|
+
return await new Promise((resolveAnswer, reject) => {
|
|
25
|
+
const child = fork(workerPath, ["--prompt"], {
|
|
26
|
+
cwd: options.cwd,
|
|
27
|
+
env: { ...process.env },
|
|
28
|
+
detached: true,
|
|
29
|
+
stdio: ["ignore", "ignore", "ignore", "ipc"],
|
|
30
|
+
execArgv: [],
|
|
31
|
+
});
|
|
32
|
+
let answer;
|
|
33
|
+
let failure;
|
|
34
|
+
let settled = false;
|
|
35
|
+
const killGroup = () => {
|
|
36
|
+
if (!child.pid)
|
|
37
|
+
return;
|
|
38
|
+
try {
|
|
39
|
+
process.kill(-child.pid, "SIGKILL");
|
|
40
|
+
}
|
|
41
|
+
catch { /* Process group already exited. */ }
|
|
42
|
+
};
|
|
43
|
+
const onAbort = () => {
|
|
44
|
+
const abortError = signal.reason instanceof Error
|
|
45
|
+
? signal.reason
|
|
46
|
+
: Object.assign(new Error("历史摘要已取消。"), { name: "AbortError" });
|
|
47
|
+
failure = abortError;
|
|
48
|
+
killGroup();
|
|
49
|
+
};
|
|
50
|
+
signal.addEventListener("abort", onAbort, { once: true });
|
|
51
|
+
const timer = setTimeout(() => {
|
|
52
|
+
failure = new Error(`ACP 摘要 worker(${backend})执行超时。`);
|
|
53
|
+
killGroup();
|
|
54
|
+
}, timeoutMs);
|
|
55
|
+
const finish = (err, value) => {
|
|
56
|
+
if (settled)
|
|
57
|
+
return;
|
|
58
|
+
settled = true;
|
|
59
|
+
clearTimeout(timer);
|
|
60
|
+
signal.removeEventListener("abort", onAbort);
|
|
61
|
+
if (err)
|
|
62
|
+
reject(err);
|
|
63
|
+
else
|
|
64
|
+
resolveAnswer(value);
|
|
65
|
+
};
|
|
66
|
+
child.on("message", (message) => {
|
|
67
|
+
if (message.type === "answer" && typeof message.text === "string")
|
|
68
|
+
answer = message.text;
|
|
69
|
+
if (message.type === "error")
|
|
70
|
+
failure = new Error(message.error ?? `ACP 摘要 worker(${backend})失败。`);
|
|
71
|
+
});
|
|
72
|
+
child.once("error", error => { failure = error; });
|
|
73
|
+
child.once("spawn", () => {
|
|
74
|
+
if (signal.aborted) {
|
|
75
|
+
onAbort();
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
child.send({
|
|
79
|
+
reference,
|
|
80
|
+
cwd: options.cwd,
|
|
81
|
+
system: request.system,
|
|
82
|
+
prompt: request.prompt,
|
|
83
|
+
...(options.model ? { model: options.model } : {}),
|
|
84
|
+
...(options.thinking ? { thinking: options.thinking } : {}),
|
|
85
|
+
});
|
|
86
|
+
});
|
|
87
|
+
child.once("close", code => {
|
|
88
|
+
if (signal.aborted) {
|
|
89
|
+
finish(failure ?? Object.assign(new Error("历史摘要已取消。"), { name: "AbortError" }));
|
|
90
|
+
}
|
|
91
|
+
else if (answer && code === 0 && !failure) {
|
|
92
|
+
finish(undefined, answer);
|
|
93
|
+
}
|
|
94
|
+
else {
|
|
95
|
+
finish(failure ?? new Error(`ACP 摘要 worker(${backend})异常退出(code=${String(code)})。`));
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
});
|
|
99
|
+
};
|
|
100
|
+
}
|
|
@@ -35,7 +35,7 @@ export function formatWorkspaceSkills(skills) {
|
|
|
35
35
|
return "## 工作区技能\n\n以下为工作区自有专业方法(位于 `.agents/skills/`),匹配任务时按需读取对应 `SKILL.md` 正文:\n" + lines.join("\n");
|
|
36
36
|
}
|
|
37
37
|
export async function loadWorkspaceContext(options) {
|
|
38
|
-
const { host, root, role, coordinatorPrompt, includePrompts = true, includeRootAgents = false, localRoleOnly = false, workspaceSkills = [], } = options;
|
|
38
|
+
const { host, root, role, coordinatorPrompt, includePrompts = true, includeRootAgents = false, localRoleOnly = false, workspaceSkills = [], notices = [], } = options;
|
|
39
39
|
const [workspace, roleText, rootAgents] = includePrompts
|
|
40
40
|
? await Promise.all([
|
|
41
41
|
readFile(join(resourceRoot, "prompts/workspace.md"), "utf8"),
|
|
@@ -44,12 +44,16 @@ export async function loadWorkspaceContext(options) {
|
|
|
44
44
|
])
|
|
45
45
|
: ["", "", ""];
|
|
46
46
|
const skillsSection = formatWorkspaceSkills(workspaceSkills);
|
|
47
|
+
const noticesSection = notices.length
|
|
48
|
+
? "## 启动提示\n\n" + notices.map(item => `- ${item}`).join("\n")
|
|
49
|
+
: "";
|
|
47
50
|
const environment = { host, workspaceRoot: root, resourceRoot };
|
|
48
51
|
const text = [
|
|
49
52
|
workspace,
|
|
50
53
|
roleText,
|
|
51
54
|
rootAgents,
|
|
52
55
|
skillsSection,
|
|
56
|
+
noticesSection,
|
|
53
57
|
"## 环境\n\n" + JSON.stringify(environment),
|
|
54
58
|
].filter(Boolean).join("\n\n");
|
|
55
59
|
return { workspace, role: roleText, rootAgents, workspaceSkills: [...workspaceSkills], environment, text };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { HistorySession } from "../../../model/history.js";
|
|
2
|
+
import type { PluginHostAdapter } from "../../../model/plugin-host.js";
|
|
3
|
+
export declare function projectAntigravityTranscript(sessionId: string, content: string, terminationReason?: string): HistorySession;
|
|
4
|
+
export declare function antigravityWorkspaceRoot(cwd: string, payload?: unknown): Promise<string>;
|
|
5
|
+
export declare const antigravityAdapter: PluginHostAdapter;
|
|
6
|
+
export declare const antigravitySkillPath: (pluginRoot: string, skill: string) => string;
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
import { readFile, realpath, stat } from "node:fs/promises";
|
|
2
|
+
import { dirname, 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", "Stop"];
|
|
7
|
+
function cleanUserRequest(content) {
|
|
8
|
+
const match = content.match(/<USER_REQUEST>\s*([\s\S]*?)\s*<\/USER_REQUEST>/);
|
|
9
|
+
return (match ? match[1] : content).trim();
|
|
10
|
+
}
|
|
11
|
+
export function projectAntigravityTranscript(sessionId, content, terminationReason) {
|
|
12
|
+
const exchanges = [];
|
|
13
|
+
const lines = content.split(/\r?\n/);
|
|
14
|
+
let users = [];
|
|
15
|
+
let answer;
|
|
16
|
+
const finish = (completed) => {
|
|
17
|
+
if (!users.length)
|
|
18
|
+
return;
|
|
19
|
+
const entryIds = [...users.map(u => u.id), ...(answer ? [answer.id] : [])];
|
|
20
|
+
const from = users[0].time;
|
|
21
|
+
const to = answer?.time ?? users.at(-1).time;
|
|
22
|
+
const text = users.map(u => "用户:\n" + u.text).join("\n\n") +
|
|
23
|
+
(answer ? "\n\n助手:\n" + answer.text : "");
|
|
24
|
+
exchanges.push({ entryIds, from, to, completed, text });
|
|
25
|
+
users = [];
|
|
26
|
+
answer = undefined;
|
|
27
|
+
};
|
|
28
|
+
for (const line of lines) {
|
|
29
|
+
const trimmed = line.trim();
|
|
30
|
+
if (!trimmed)
|
|
31
|
+
continue;
|
|
32
|
+
let entry;
|
|
33
|
+
try {
|
|
34
|
+
entry = JSON.parse(trimmed);
|
|
35
|
+
}
|
|
36
|
+
catch {
|
|
37
|
+
continue;
|
|
38
|
+
}
|
|
39
|
+
if (!object(entry) || typeof entry.type !== "string")
|
|
40
|
+
continue;
|
|
41
|
+
const stepIndex = typeof entry.step_index === "number" ? entry.step_index : exchanges.length;
|
|
42
|
+
const time = typeof entry.created_at === "string" && entry.created_at ? entry.created_at : new Date().toISOString();
|
|
43
|
+
if (entry.type === "USER_INPUT" && typeof entry.content === "string") {
|
|
44
|
+
if (answer)
|
|
45
|
+
finish(true);
|
|
46
|
+
const cleaned = cleanUserRequest(entry.content);
|
|
47
|
+
if (cleaned)
|
|
48
|
+
users.push({ id: `agy:${stepIndex}`, text: cleaned, time });
|
|
49
|
+
}
|
|
50
|
+
else if (entry.type === "PLANNER_RESPONSE" && users.length) {
|
|
51
|
+
const hasToolCalls = Array.isArray(entry.tool_calls) && entry.tool_calls.length > 0;
|
|
52
|
+
const text = typeof entry.content === "string" ? entry.content.trim() : "";
|
|
53
|
+
if (!hasToolCalls && text) {
|
|
54
|
+
answer = { id: `agy:${stepIndex}`, text, time };
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
const completed = Boolean(answer) && (!terminationReason || terminationReason === "NO_TOOL_CALL");
|
|
59
|
+
finish(completed);
|
|
60
|
+
return { sessionId, name: "", branches: exchanges.length ? [exchanges] : [] };
|
|
61
|
+
}
|
|
62
|
+
async function readAntigravityTranscript(transcriptPath) {
|
|
63
|
+
const fullPath = join(dirname(transcriptPath), "transcript_full.jsonl");
|
|
64
|
+
for (const path of [fullPath, transcriptPath]) {
|
|
65
|
+
try {
|
|
66
|
+
return await readFile(path, "utf8");
|
|
67
|
+
}
|
|
68
|
+
catch (error) {
|
|
69
|
+
if (error.code !== "ENOENT")
|
|
70
|
+
throw error;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
return undefined;
|
|
74
|
+
}
|
|
75
|
+
function workspaceFromPayload(cwd, payload) {
|
|
76
|
+
if (object(payload) && Array.isArray(payload.workspacePaths)) {
|
|
77
|
+
const first = payload.workspacePaths.find(value => typeof value === "string" && value.length > 0);
|
|
78
|
+
if (typeof first === "string")
|
|
79
|
+
return first;
|
|
80
|
+
}
|
|
81
|
+
return cwd;
|
|
82
|
+
}
|
|
83
|
+
function skillFromReadPath(targetPath, pluginRoot = process.env.PLUGIN_ROOT || resolve(resourceRoot, "..")) {
|
|
84
|
+
const skillsRoot = resolve(pluginRoot, "skills");
|
|
85
|
+
const rel = relative(skillsRoot, resolve(targetPath));
|
|
86
|
+
if (!rel || rel.startsWith("..") || isAbsolute(rel))
|
|
87
|
+
return undefined;
|
|
88
|
+
const skill = rel.split(sep)[0];
|
|
89
|
+
if (!skill || skill === "pbot")
|
|
90
|
+
return undefined;
|
|
91
|
+
return skill;
|
|
92
|
+
}
|
|
93
|
+
function isPreToolUse(payload) {
|
|
94
|
+
return object(payload) && payload.hookEventName === "PreToolUse";
|
|
95
|
+
}
|
|
96
|
+
export async function antigravityWorkspaceRoot(cwd, payload) {
|
|
97
|
+
const directory = workspaceFromPayload(cwd, payload);
|
|
98
|
+
requireThat(isAbsolute(directory), "Antigravity 工作区需要绝对路径。");
|
|
99
|
+
const root = await realpath(directory);
|
|
100
|
+
requireThat((await stat(root)).isDirectory(), "Antigravity 工作区需要目录。");
|
|
101
|
+
return root;
|
|
102
|
+
}
|
|
103
|
+
export const antigravityAdapter = {
|
|
104
|
+
host: "antigravity",
|
|
105
|
+
nativeRootAgents: true,
|
|
106
|
+
nativeWorkspaceSkills: true,
|
|
107
|
+
coordinatorPrompt: "plugin-coordinator.md",
|
|
108
|
+
initCommandHint: "/pbot init",
|
|
109
|
+
usage: "用法:node <插件目录>/lib/plugin.js antigravity init|status",
|
|
110
|
+
resolveRoot(cwd, rawPayload) {
|
|
111
|
+
return antigravityWorkspaceRoot(cwd, rawPayload);
|
|
112
|
+
},
|
|
113
|
+
parseEvent(value) {
|
|
114
|
+
requireThat(object(value) && typeof value.hookEventName === "string", "Antigravity hook 输入无效。");
|
|
115
|
+
const event = value.hookEventName;
|
|
116
|
+
requireThat(supportedEvents.includes(event), "Antigravity hook 事件未支持。");
|
|
117
|
+
const cwd = typeof value.cwd === "string" && value.cwd ? value.cwd : workspaceFromPayload("", value);
|
|
118
|
+
requireThat(cwd, "Antigravity hook 缺少工作目录。");
|
|
119
|
+
if (event === "SessionStart") {
|
|
120
|
+
return { kind: "inject-context", role: "coordinator", isSessionStart: true, cwd, raw: value };
|
|
121
|
+
}
|
|
122
|
+
if (event === "Stop") {
|
|
123
|
+
return { kind: "record-history", cwd, raw: value };
|
|
124
|
+
}
|
|
125
|
+
if (!object(value.toolCall) || typeof value.toolCall.name !== "string" || !object(value.toolCall.args)) {
|
|
126
|
+
return { kind: "ignore" };
|
|
127
|
+
}
|
|
128
|
+
const { name, args } = value.toolCall;
|
|
129
|
+
if (name === "read_file" && typeof args.Path === "string") {
|
|
130
|
+
const skill = skillFromReadPath(args.Path);
|
|
131
|
+
if (skill)
|
|
132
|
+
return { kind: "check-skill", skill, cwd, raw: value };
|
|
133
|
+
}
|
|
134
|
+
return { kind: "ignore" };
|
|
135
|
+
},
|
|
136
|
+
async extractHistory(event) {
|
|
137
|
+
if (event.kind !== "record-history" || !object(event.raw))
|
|
138
|
+
return undefined;
|
|
139
|
+
const sessionId = typeof event.raw.conversationId === "string" ? event.raw.conversationId.trim() : "";
|
|
140
|
+
if (!sessionId)
|
|
141
|
+
return undefined;
|
|
142
|
+
const terminationReason = typeof event.raw.terminationReason === "string" ? event.raw.terminationReason : undefined;
|
|
143
|
+
const transcriptPath = typeof event.raw.transcriptPath === "string" ? event.raw.transcriptPath.trim() : "";
|
|
144
|
+
if (transcriptPath) {
|
|
145
|
+
const content = await readAntigravityTranscript(transcriptPath);
|
|
146
|
+
if (content) {
|
|
147
|
+
const session = projectAntigravityTranscript(sessionId, content, terminationReason);
|
|
148
|
+
if (session.branches.length)
|
|
149
|
+
return { kind: "session", session };
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
const lastUserInput = typeof event.raw.lastUserInput === "string" ? event.raw.lastUserInput.trim() : "";
|
|
153
|
+
if (lastUserInput)
|
|
154
|
+
return { kind: "input", sessionId, text: lastUserInput };
|
|
155
|
+
return undefined;
|
|
156
|
+
},
|
|
157
|
+
formatPass(payload) {
|
|
158
|
+
return isPreToolUse(payload) ? { decision: "allow" } : {};
|
|
159
|
+
},
|
|
160
|
+
formatContext(_event, context) {
|
|
161
|
+
return {
|
|
162
|
+
injectSteps: [
|
|
163
|
+
{ systemMessage: { systemMessage: context.text } },
|
|
164
|
+
],
|
|
165
|
+
};
|
|
166
|
+
},
|
|
167
|
+
formatDeny(_event, reason) {
|
|
168
|
+
return { decision: "deny", reason };
|
|
169
|
+
},
|
|
170
|
+
};
|
|
171
|
+
export const antigravitySkillPath = (pluginRoot, skill) => join(pluginRoot, "skills", skill, "SKILL.md");
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type { PluginHostAdapter } from "
|
|
1
|
+
import type { PluginHostAdapter } from "../../../model/plugin-host.js";
|
|
2
2
|
export declare function claudeWorkspaceRoot(cwd: string, projectDirectory?: string | undefined): Promise<string>;
|
|
3
3
|
export declare const claudeAdapter: PluginHostAdapter;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { realpath, stat } from "node:fs/promises";
|
|
2
2
|
import { isAbsolute } from "node:path";
|
|
3
|
-
import { object } from "
|
|
4
|
-
import { requireThat } from "
|
|
5
|
-
const supportedEvents = ["UserPromptSubmit", "PreToolUse", "UserPromptExpansion"];
|
|
3
|
+
import { object } from "../../../common/json.js";
|
|
4
|
+
import { requireThat } from "../../../common/validation.js";
|
|
5
|
+
const supportedEvents = ["UserPromptSubmit", "PreToolUse", "UserPromptExpansion", "Stop"];
|
|
6
6
|
export async function claudeWorkspaceRoot(cwd, projectDirectory = process.env.CLAUDE_PROJECT_DIR) {
|
|
7
7
|
const directory = projectDirectory || cwd;
|
|
8
8
|
requireThat(isAbsolute(directory), "Claude 工作区需要绝对路径。");
|
|
@@ -33,12 +33,40 @@ export const claudeAdapter = {
|
|
|
33
33
|
requireThat(typeof value.cwd === "string", "Claude hook 缺少工作目录。");
|
|
34
34
|
return { kind: "check-skill", skill, cwd: value.cwd, raw: value };
|
|
35
35
|
}
|
|
36
|
-
// Leave Claude's native subagents untouched; only inject coordinator context
|
|
36
|
+
// Leave Claude's native subagents untouched; only inject coordinator context or record history in main sessions.
|
|
37
37
|
if (typeof value.agent_id === "string")
|
|
38
38
|
return { kind: "ignore" };
|
|
39
39
|
requireThat(typeof value.cwd === "string", "Claude hook 缺少工作目录。");
|
|
40
|
+
if (event === "Stop")
|
|
41
|
+
return { kind: "record-history", cwd: value.cwd, raw: value };
|
|
40
42
|
return { kind: "inject-context", role: "coordinator", cwd: value.cwd, raw: value };
|
|
41
43
|
},
|
|
44
|
+
async extractHistory(event) {
|
|
45
|
+
if (!object(event.raw))
|
|
46
|
+
return undefined;
|
|
47
|
+
const sessionId = typeof event.raw.session_id === "string" ? event.raw.session_id.trim() : "";
|
|
48
|
+
if (!sessionId)
|
|
49
|
+
return undefined;
|
|
50
|
+
if (event.raw.hook_event_name === "UserPromptSubmit") {
|
|
51
|
+
const text = typeof event.raw.prompt === "string" ? event.raw.prompt.trim() : "";
|
|
52
|
+
if (!text)
|
|
53
|
+
return undefined;
|
|
54
|
+
return { kind: "input", sessionId, text };
|
|
55
|
+
}
|
|
56
|
+
if (event.raw.hook_event_name === "Stop") {
|
|
57
|
+
const assistantText = typeof event.raw.last_assistant_message === "string" ? event.raw.last_assistant_message.trim() : "";
|
|
58
|
+
if (!assistantText)
|
|
59
|
+
return undefined;
|
|
60
|
+
return {
|
|
61
|
+
kind: "answer",
|
|
62
|
+
sessionId,
|
|
63
|
+
assistantText,
|
|
64
|
+
completed: true,
|
|
65
|
+
...(event.raw.stop_hook_active === true ? { isContinuation: true } : {}),
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
return undefined;
|
|
69
|
+
},
|
|
42
70
|
formatPass() {
|
|
43
71
|
return {};
|
|
44
72
|
},
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import * as McpClient from "@deepseek-ai/dsh-mcp-client";
|
|
2
|
-
import type { ResolvedWorkspaceMcpServer } from "
|
|
2
|
+
import type { ResolvedWorkspaceMcpServer } from "../../../model/workspace-mcp.js";
|
|
3
3
|
/** Translate a resolved workspace MCP entry into dsh's native `@deepseek-ai/dsh-mcp-client` config. */
|
|
4
4
|
export declare function toDshMcpConfig(server: ResolvedWorkspaceMcpServer): McpClient.Config;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Context } from "@deepseek-ai/cordis";
|
|
2
2
|
import type { Agent } from "@deepseek-ai/dsh-agent";
|
|
3
|
-
import type { AgentOptions } from "
|
|
3
|
+
import type { AgentOptions } from "../../../model/agent.js";
|
|
4
4
|
export declare function dshResources(ctx: Context, _agent: Agent, root: string, role: "coordinator" | "general-purpose", check: () => void, coordinatorPrompt?: string): Promise<void>;
|
|
5
5
|
/** Map an ACP dsh worker's native loadout without interfering with coordinator sessions. */
|
|
6
6
|
export declare function dshExpertTools(ctx: Context, agent: Agent, options: AgentOptions): void;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { readFile } from "node:fs/promises";
|
|
2
2
|
import { join } from "node:path";
|
|
3
|
-
import { agentText } from "
|
|
4
|
-
import { resourceRoot } from "
|
|
5
|
-
import { requireThat } from "
|
|
6
|
-
import { isMcpWorkerTool } from "
|
|
3
|
+
import { agentText } from "../../agent-resources.js";
|
|
4
|
+
import { resourceRoot } from "../../../common/paths.js";
|
|
5
|
+
import { requireThat } from "../../../common/validation.js";
|
|
6
|
+
import { isMcpWorkerTool } from "../../../model/acp.js";
|
|
7
7
|
export async function dshResources(ctx, _agent, root, role, check, coordinatorPrompt = "history-coordinator.md") {
|
|
8
8
|
const read = () => Promise.all([agentText(role, root, coordinatorPrompt), readFile(join(resourceRoot, "prompts/workspace.md"), "utf8")]);
|
|
9
9
|
const [text, workspace] = await read();
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { requireThat } from "
|
|
1
|
+
import { requireThat } from "../../../common/validation.js";
|
|
2
2
|
/** Remove TypeBox's non-JSON metadata before passing a schema to the native host. */
|
|
3
3
|
export function dshParameters(value) {
|
|
4
4
|
return JSON.parse(JSON.stringify(value));
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { join } from "node:path";
|
|
2
2
|
import { scopeParentOf } from "@deepseek-ai/dsh-scope";
|
|
3
3
|
import { FileSystemSkillProvider } from "@deepseek-ai/dsh-skill-filesystem";
|
|
4
|
-
import { resourceRoot } from "
|
|
4
|
+
import { resourceRoot } from "../../../common/paths.js";
|
|
5
5
|
/** Keep bundled methods local to this Agent without overriding its native project/user methods. */
|
|
6
6
|
export function registerDshSkills(ctx, agent, options = {}) {
|
|
7
7
|
const customSkillDirs = options.workspaceRoot ? [join(options.workspaceRoot, ".agents", "skills")] : undefined;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { requireThat } from "../../common/validation.js";
|
|
2
|
-
import { antigravityAdapter } from "./antigravity.js";
|
|
3
|
-
import { claudeAdapter } from "./claude.js";
|
|
2
|
+
import { antigravityAdapter } from "./antigravity/adapter.js";
|
|
3
|
+
import { claudeAdapter } from "./claude/adapter.js";
|
|
4
4
|
/** Extensible registry of hook-based plugin host adapters; runtime never branches on host IDs. */
|
|
5
5
|
export class PluginHostRegistry {
|
|
6
6
|
#adapters = new Map();
|
|
@@ -9,7 +9,7 @@ export const piPackageName = "@earendil-works/pi-coding-agent";
|
|
|
9
9
|
export class PiBootstrapRequired extends Error {
|
|
10
10
|
}
|
|
11
11
|
const bridge = fileURLToPath(new URL("./pi-bridge.js", import.meta.url));
|
|
12
|
-
const guard = fileURLToPath(new URL("../../extension/setup
|
|
12
|
+
const guard = fileURLToPath(new URL("../../extension/setup/guard.js", import.meta.url));
|
|
13
13
|
async function packageRoot(command, version, env) {
|
|
14
14
|
const resolved = await realpath(command);
|
|
15
15
|
let directory = dirname(resolved);
|