personal-bot 0.3.7 → 0.4.1
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 -2
- package/README.md +5 -8
- package/README.zh-CN.md +5 -8
- package/bin/pbot-pi-acp.mjs +1 -1
- package/docs/architecture/design.md +2 -2
- package/docs/architecture/extensibility.md +4 -4
- package/docs/architecture/model-context.md +6 -3
- package/docs/guides/cross-harness-workers.md +5 -5
- package/docs/guides/history.md +1 -3
- package/docs/guides/workspace-configuration.md +5 -5
- package/docs/hosts/claude-code.md +3 -3
- package/docs/hosts/codex-qoder.md +4 -2
- package/hooks/hooks.json +3 -0
- package/lib/antigravity-plugin/bin/pbot-pi-acp.mjs +1 -1
- package/lib/antigravity-plugin/lib/extension/acp/member.d.ts +1 -1
- package/lib/antigravity-plugin/lib/extension/acp/member.js +11 -10
- package/lib/antigravity-plugin/lib/extension/acp-worker.js +349 -204
- package/lib/antigravity-plugin/lib/extension/cli.js +596 -572
- package/lib/antigravity-plugin/lib/extension/hosts/dsh/acp-member.js +1 -1
- package/lib/antigravity-plugin/lib/extension/hosts/pi/acp-member.js +3 -4
- package/lib/antigravity-plugin/lib/extension/hosts/plugin-runtime.js +1 -12
- package/lib/antigravity-plugin/lib/extension/mcp.js +463 -379
- package/lib/antigravity-plugin/lib/integrations/agent-resources.d.ts +2 -2
- package/lib/antigravity-plugin/lib/integrations/agent-resources.js +3 -3
- package/lib/antigravity-plugin/lib/integrations/hosts/antigravity/adapter.js +0 -1
- package/lib/antigravity-plugin/lib/integrations/hosts/claude/adapter.js +1 -2
- package/lib/antigravity-plugin/lib/integrations/hosts/dsh/resources.d.ts +1 -1
- package/lib/antigravity-plugin/lib/integrations/hosts/prompt-hooks.js +4 -7
- package/lib/antigravity-plugin/lib/model/acp.d.ts +29 -35
- package/lib/antigravity-plugin/lib/model/agent.d.ts +33 -17
- package/lib/antigravity-plugin/lib/model/agent.js +0 -1
- package/lib/antigravity-plugin/lib/services/history/summary-dimensions/monthly.js +1 -1
- package/lib/antigravity-plugin/lib/services/history/summary-dimensions/session.js +6 -3
- package/lib/antigravity-plugin/lib/services/history/summary-runner.js +3 -3
- package/lib/antigravity-plugin/lib/storage/acp-files.d.ts +5 -8
- package/lib/antigravity-plugin/lib/storage/acp-files.js +34 -40
- package/lib/antigravity-plugin/lib/storage/agent-files.d.ts +19 -10
- package/lib/antigravity-plugin/lib/storage/agent-files.js +147 -43
- package/lib/antigravity-plugin/lib/storage/history-files.js +3 -2
- package/lib/antigravity-plugin/package.json +1 -1
- package/lib/antigravity-plugin/plugin.json +2 -2
- package/lib/antigravity-plugin/resources/agents/coordinator.md +2 -4
- package/lib/antigravity-plugin/resources/agents/general-purpose.md +2 -4
- package/lib/antigravity-plugin/resources/prompts/history-monthly-summary.md +6 -11
- package/lib/antigravity-plugin/resources/prompts/history-summary.md +6 -11
- package/lib/antigravity-plugin/resources/prompts/plugin-coordinator.md +1 -1
- package/lib/antigravity-plugin/resources/prompts/workspace.md +16 -23
- package/lib/antigravity-plugin/resources/skills/project-maintenance/SKILL.md +14 -21
- package/lib/antigravity-plugin/resources/skills/provider-connections/SKILL.md +23 -36
- package/lib/antigravity-plugin/resources/templates/workspace-agents.md +5 -13
- package/lib/antigravity-plugin/skills/pbot/SKILL.md +6 -23
- package/lib/antigravity-plugin/skills/project-maintenance/SKILL.md +14 -21
- package/lib/antigravity-plugin/skills/provider-connections/SKILL.md +23 -36
- package/lib/codex-marketplace/plugins/personal-bot/.codex-plugin/plugin.json +2 -2
- package/lib/codex-marketplace/plugins/personal-bot/.mcp.json +2 -2
- package/lib/codex-marketplace/plugins/personal-bot/hooks/hooks.json +3 -3
- package/lib/codex-marketplace/plugins/personal-bot/skills/pbot/SKILL.md +11 -3
- package/lib/extension/acp/member.d.ts +1 -1
- package/lib/extension/acp/member.js +11 -10
- package/lib/extension/acp/worker.js +34 -33
- package/lib/extension/acp-worker.js +349 -204
- package/lib/extension/cli.js +596 -572
- package/lib/extension/hosts/dsh/acp-member.js +1 -1
- package/lib/extension/hosts/dsh/command.js +2 -2
- package/lib/extension/hosts/dsh/workspace.js +5 -5
- package/lib/extension/hosts/pi/acp-member.js +3 -4
- package/lib/extension/hosts/plugin-runtime.js +1 -12
- package/lib/extension/mcp/tool-contract.d.ts +8 -50
- package/lib/extension/mcp/tool-contract.js +61 -107
- package/lib/extension/mcp/workers.d.ts +7 -27
- package/lib/extension/mcp/workers.js +40 -24
- package/lib/extension/mcp.js +463 -379
- package/lib/integrations/acp/agents.d.ts +2 -3
- package/lib/integrations/acp/agents.js +22 -22
- package/lib/integrations/acp/harnesses/claude.js +1 -1
- package/lib/integrations/agent-resources.d.ts +2 -2
- package/lib/integrations/agent-resources.js +3 -3
- package/lib/integrations/hosts/antigravity/adapter.js +0 -1
- package/lib/integrations/hosts/claude/adapter.js +1 -2
- package/lib/integrations/hosts/dsh/resources.d.ts +1 -1
- package/lib/integrations/hosts/prompt-hooks.js +4 -7
- package/lib/model/acp.d.ts +29 -35
- package/lib/model/agent.d.ts +33 -17
- package/lib/model/agent.js +0 -1
- package/lib/qoder-plugin/.mcp.json +2 -2
- package/lib/qoder-plugin/.qoder-plugin/plugin.json +2 -2
- package/lib/qoder-plugin/hooks/hooks.json +3 -3
- package/lib/qoder-plugin/skills/pbot/SKILL.md +11 -3
- package/lib/services/agents/acp-run.d.ts +6 -4
- package/lib/services/agents/acp-run.js +62 -43
- package/lib/services/agents/agent-run.d.ts +10 -6
- package/lib/services/agents/agent-run.js +142 -65
- package/lib/services/agents/agent-service.d.ts +3 -21
- package/lib/services/agents/agent-service.js +182 -128
- package/lib/services/history/summary-dimensions/monthly.js +1 -1
- package/lib/services/history/summary-dimensions/session.js +6 -3
- package/lib/services/history/summary-runner.js +3 -3
- package/lib/storage/acp-files.d.ts +5 -8
- package/lib/storage/acp-files.js +34 -40
- package/lib/storage/agent-files.d.ts +19 -10
- package/lib/storage/agent-files.js +147 -43
- package/lib/storage/history-files.js +3 -2
- package/lib/tools/history/contract.d.ts +1 -1
- package/lib/tools/history/contract.js +14 -16
- package/package.json +2 -2
- package/resources/agents/coordinator.md +2 -4
- package/resources/agents/general-purpose.md +2 -4
- package/resources/antigravity/skills/pbot/SKILL.md +6 -23
- package/resources/claude/skills/pbot/SKILL.md +6 -23
- package/resources/plugin/skills/pbot/SKILL.md +11 -3
- package/resources/prompts/history-coordinator.md +1 -1
- package/resources/prompts/history-monthly-summary.md +6 -11
- package/resources/prompts/history-summary.md +6 -11
- package/resources/prompts/plugin-coordinator.md +1 -1
- package/resources/prompts/workspace.md +16 -23
- package/resources/skills/project-maintenance/SKILL.md +14 -21
- package/resources/skills/provider-connections/SKILL.md +23 -36
- package/resources/templates/workspace-agents.md +5 -13
- package/src/extension/acp/member.ts +14 -11
- package/src/extension/acp/worker.ts +31 -28
- package/src/extension/cli/commands/mcp.ts +1 -1
- package/src/extension/cli/commands/upgrade.ts +8 -36
- package/src/extension/cli/commands/workspace.ts +3 -8
- package/src/extension/cli/index.ts +1 -2
- package/src/extension/hosts/dsh/acp-member.ts +1 -1
- package/src/extension/hosts/dsh/command.ts +2 -2
- package/src/extension/hosts/dsh/workspace.ts +5 -4
- package/src/extension/hosts/pi/acp-member.ts +3 -4
- package/src/extension/hosts/pi/command.ts +2 -2
- package/src/extension/hosts/pi/events.ts +1 -1
- package/src/extension/hosts/pi/lifecycle.ts +0 -2
- package/src/extension/hosts/plugin-runtime.ts +1 -11
- package/src/extension/mcp/tool-contract.ts +61 -108
- package/src/extension/mcp/workers.ts +39 -24
- package/src/integrations/acp/agents.ts +28 -27
- package/src/integrations/acp/harnesses/claude.ts +1 -1
- package/src/integrations/agent-resources.ts +5 -5
- package/src/integrations/hosts/antigravity/adapter.ts +0 -1
- package/src/integrations/hosts/claude/adapter.ts +1 -2
- package/src/integrations/hosts/dsh/resources.ts +1 -1
- package/src/integrations/hosts/dsh/session.ts +2 -2
- package/src/integrations/hosts/prompt-hooks.ts +3 -6
- package/src/integrations/installation/cli-update.ts +2 -2
- package/src/integrations/installation/installers/claude.ts +4 -4
- package/src/integrations/installation/installers/qoder.ts +5 -5
- package/src/integrations/installation/upgraders/antigravity.ts +57 -15
- package/src/integrations/installation/upgraders/claude.ts +1 -4
- package/src/integrations/installation/upgraders/codex.ts +85 -15
- package/src/integrations/installation/upgraders/dsh.ts +46 -24
- package/src/integrations/installation/upgraders/pi.ts +18 -11
- package/src/integrations/installation/upgraders/qoder.ts +95 -20
- package/src/model/acp.ts +27 -29
- package/src/model/agent.ts +80 -16
- package/src/model/installation.ts +0 -2
- package/src/pbot.ts +3 -3
- package/src/services/agents/acp-run.ts +81 -49
- package/src/services/agents/agent-run.ts +154 -56
- package/src/services/agents/agent-service.ts +206 -135
- package/src/services/history/summary-dimensions/monthly.ts +1 -1
- package/src/services/history/summary-dimensions/session.ts +6 -3
- package/src/services/history/summary-runner.ts +3 -3
- package/src/services/installation/upgrade-service.ts +1 -5
- package/src/storage/acp-files.ts +50 -45
- package/src/storage/agent-files.ts +159 -46
- package/src/storage/history-files.ts +3 -2
- package/src/tools/history/contract.ts +14 -16
- package/lib/antigravity-plugin/lib/services/workspace/plugin-releases.d.ts +0 -15
- package/lib/antigravity-plugin/lib/services/workspace/plugin-releases.js +0 -126
- package/lib/services/workspace/plugin-releases.d.ts +0 -15
- package/lib/services/workspace/plugin-releases.js +0 -126
- package/src/services/workspace/plugin-releases.ts +0 -121
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { AgentDescriptor, AgentHost, AgentOptions, AgentSessionReference } from "../../model/agent.js";
|
|
2
2
|
import type { AcpBackend, AcpCommands, AcpModelsResult } from "../../model/acp.js";
|
|
3
3
|
import { AgentFiles } from "../../storage/agent-files.js";
|
|
4
4
|
/** Pure ACP v1 worker host; spawns isolated acp-worker child processes for any registered or custom harness. */
|
|
@@ -11,12 +11,11 @@ export declare class AcpWorkerHost implements AgentHost {
|
|
|
11
11
|
filterOptions(backend: AcpBackend, options: AgentOptions): AgentOptions;
|
|
12
12
|
prepare(backend: AcpBackend, options: AgentOptions): import("../../model/acp.js").AcpSessionReference;
|
|
13
13
|
/** Probe a backend's advertised model and thinking choices in an isolated ACP process without prompting. */
|
|
14
|
-
inspectModels(backend: AcpBackend,
|
|
14
|
+
inspectModels(backend: AcpBackend, workspace: string, options?: Pick<AgentOptions, "provider" | "model">): Promise<AcpModelsResult>;
|
|
15
15
|
private process;
|
|
16
16
|
alive(id: string): boolean;
|
|
17
17
|
validateSession(d: AgentDescriptor, reference: AgentSessionReference): Promise<void>;
|
|
18
18
|
private spawn;
|
|
19
19
|
launch(d: AgentDescriptor, _directory: string, generation: string, _reference: AgentSessionReference, _resume: boolean, signal: AbortSignal): Promise<void>;
|
|
20
20
|
release(id: string, generation: string): Promise<void>;
|
|
21
|
-
report(d: AgentDescriptor, _reference: AgentSessionReference, leaf: string): string;
|
|
22
21
|
}
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import { fork, spawnSync } from "node:child_process";
|
|
2
2
|
import { existsSync } from "node:fs";
|
|
3
|
-
import {
|
|
3
|
+
import { resolve } from "node:path";
|
|
4
4
|
import { setTimeout as delay } from "node:timers/promises";
|
|
5
|
-
import { AgentFiles,
|
|
6
|
-
import { acpInput, acpProcess, acpReport } from "../../storage/acp-files.js";
|
|
7
|
-
import { fileId } from "../../storage/file-access.js";
|
|
5
|
+
import { AgentFiles, status, workerRecord } from "../../storage/agent-files.js";
|
|
8
6
|
import { requireThat } from "../../common/validation.js";
|
|
9
7
|
import { resourceRoot } from "../../common/paths.js";
|
|
10
8
|
import { acpLaunch, filterAcpStartOptions } from "./launch.js";
|
|
@@ -29,13 +27,13 @@ export class AcpWorkerHost {
|
|
|
29
27
|
return acpLaunch(backend, this.commands, options);
|
|
30
28
|
}
|
|
31
29
|
/** Probe a backend's advertised model and thinking choices in an isolated ACP process without prompting. */
|
|
32
|
-
async inspectModels(backend,
|
|
30
|
+
async inspectModels(backend, workspace, options = {}) {
|
|
33
31
|
this.available(backend);
|
|
34
32
|
const filtered = this.filterOptions(backend, options);
|
|
35
33
|
const reference = this.prepare(backend, filtered);
|
|
36
34
|
return await new Promise((resolveResult, reject) => {
|
|
37
35
|
const child = fork(this.worker, ["--probe"], {
|
|
38
|
-
cwd, env: { ...process.env }, detached: true, stdio: ["ignore", "ignore", "ignore", "ipc"], execArgv: [],
|
|
36
|
+
cwd: workspace, env: { ...process.env }, detached: true, stdio: ["ignore", "ignore", "ignore", "ipc"], execArgv: [],
|
|
39
37
|
});
|
|
40
38
|
let result, failure;
|
|
41
39
|
const timer = setTimeout(() => {
|
|
@@ -60,7 +58,7 @@ export class AcpWorkerHost {
|
|
|
60
58
|
child.once("spawn", () => {
|
|
61
59
|
child.send({
|
|
62
60
|
reference,
|
|
63
|
-
cwd,
|
|
61
|
+
cwd: workspace,
|
|
64
62
|
...(filtered.provider ? { provider: filtered.provider } : {}),
|
|
65
63
|
...(filtered.model ? { model: filtered.model } : {}),
|
|
66
64
|
});
|
|
@@ -75,8 +73,8 @@ export class AcpWorkerHost {
|
|
|
75
73
|
});
|
|
76
74
|
}
|
|
77
75
|
process(id) {
|
|
78
|
-
const record = this.files.optional(id, "
|
|
79
|
-
if (!record
|
|
76
|
+
const record = this.files.optional(id, "worker.json", workerRecord);
|
|
77
|
+
if (!record?.pid)
|
|
80
78
|
return;
|
|
81
79
|
let denied = false;
|
|
82
80
|
try {
|
|
@@ -94,7 +92,7 @@ export class AcpWorkerHost {
|
|
|
94
92
|
// A dead leader can leave its group alive. A reused leader must match our exact launch identity.
|
|
95
93
|
if (leader.status === 0 && !leader.stdout.includes("--pbot-acp-agent " + id + " --generation " + record.generation) || denied && leader.status !== 0)
|
|
96
94
|
return;
|
|
97
|
-
return record;
|
|
95
|
+
return { generation: record.generation, pid: record.pid };
|
|
98
96
|
}
|
|
99
97
|
alive(id) {
|
|
100
98
|
return Boolean(this.process(id));
|
|
@@ -102,10 +100,11 @@ export class AcpWorkerHost {
|
|
|
102
100
|
async validateSession(d, reference) {
|
|
103
101
|
requireThat(!this.alive(d.agentId), "ACP 成员仍在运行,不能恢复。");
|
|
104
102
|
if (reference.sessionId === null) {
|
|
105
|
-
|
|
103
|
+
const saved = this.files.optional(d.agentId, "state.json", status);
|
|
104
|
+
requireThat(!saved?.activeRequestId, "ACP 输入交付状态不明;请核对原请求后新建成员。");
|
|
106
105
|
return;
|
|
107
106
|
}
|
|
108
|
-
const generation = this.files.
|
|
107
|
+
const generation = this.files.worker(d.agentId).generation;
|
|
109
108
|
await new Promise((resolveResult, reject) => {
|
|
110
109
|
const child = this.spawn(d, generation, true);
|
|
111
110
|
let validated = false, failure;
|
|
@@ -137,20 +136,27 @@ export class AcpWorkerHost {
|
|
|
137
136
|
spawn(d, generation, validate = false) {
|
|
138
137
|
return fork(this.worker, ["--pbot-acp-agent", d.agentId, "--generation", generation, "--directory", this.files.directory(d.agentId),
|
|
139
138
|
...(validate ? ["--validate"] : [])], {
|
|
140
|
-
cwd: d.
|
|
139
|
+
cwd: d.workspace, env: { ...process.env }, detached: true, stdio: ["ignore", "ignore", "ignore", "ipc"], execArgv: [],
|
|
141
140
|
});
|
|
142
141
|
}
|
|
143
142
|
async launch(d, _directory, generation, _reference, _resume, signal) {
|
|
144
143
|
signal.throwIfAborted();
|
|
145
144
|
const child = this.spawn(d, generation);
|
|
146
145
|
await new Promise((resolveResult, reject) => { child.once("spawn", resolveResult); child.once("error", reject); });
|
|
147
|
-
|
|
146
|
+
const pid = child.pid;
|
|
147
|
+
requireThat(pid, "ACP worker 没有进程身份。");
|
|
148
148
|
try {
|
|
149
|
-
this.files.
|
|
149
|
+
this.files.control(() => {
|
|
150
|
+
const w = this.files.worker(d.agentId);
|
|
151
|
+
if (w.generation === generation) {
|
|
152
|
+
w.pid = pid;
|
|
153
|
+
this.files.write(d.agentId, "worker.json", w, workerRecord);
|
|
154
|
+
}
|
|
155
|
+
});
|
|
150
156
|
}
|
|
151
157
|
catch (error) {
|
|
152
158
|
try {
|
|
153
|
-
process.kill(-
|
|
159
|
+
process.kill(-pid, "SIGKILL");
|
|
154
160
|
}
|
|
155
161
|
catch (failure) {
|
|
156
162
|
if (failure.code !== "ESRCH")
|
|
@@ -191,10 +197,4 @@ export class AcpWorkerHost {
|
|
|
191
197
|
if (current?.generation === generation && current.pid === record.pid)
|
|
192
198
|
terminate("SIGKILL");
|
|
193
199
|
}
|
|
194
|
-
report(d, _reference, leaf) {
|
|
195
|
-
requireThat(leaf.startsWith("acp:"), "ACP 报告引用无效。");
|
|
196
|
-
const cycleId = fileId(leaf.slice(4)), report = this.files.read(d.agentId, join("reports", cycleId + ".json"), acpReport);
|
|
197
|
-
requireThat(report.cycleId === cycleId, "ACP 报告周期不匹配。");
|
|
198
|
-
return report.text;
|
|
199
|
-
}
|
|
200
200
|
}
|
|
@@ -24,7 +24,7 @@ export const claudeAcpHarness = {
|
|
|
24
24
|
},
|
|
25
25
|
async prepareLaunch(context) {
|
|
26
26
|
const base = defaultPrepareLaunch(context);
|
|
27
|
-
const claude = await claudeOptions(base.command, context.
|
|
27
|
+
const claude = await claudeOptions(base.command, context.workspace, context.options.thinking, context.features?.skills !== false);
|
|
28
28
|
return {
|
|
29
29
|
...base,
|
|
30
30
|
...(claude.thinking ? { defaultThinking: claude.thinking } : {}),
|
|
@@ -2,13 +2,13 @@ import type { HostId, WorkspaceContext, WorkspaceRole } from "../model/plugin-ho
|
|
|
2
2
|
import type { WorkspaceSkillMeta } from "../model/workspace-mcp.js";
|
|
3
3
|
export declare function readOptionalFile(path: string): Promise<string>;
|
|
4
4
|
export declare function readLocalRole(agent: WorkspaceRole, root: string): Promise<string>;
|
|
5
|
-
export declare function agentText(agent: WorkspaceRole, root: string, coordinatorPrompt?: string): Promise<string>;
|
|
5
|
+
export declare function agentText(agent: WorkspaceRole, root: string, coordinatorPrompt?: string | null): Promise<string>;
|
|
6
6
|
export declare function formatWorkspaceSkills(skills: readonly WorkspaceSkillMeta[]): string;
|
|
7
7
|
export declare function loadWorkspaceContext(options: {
|
|
8
8
|
host: HostId;
|
|
9
9
|
root: string;
|
|
10
10
|
role: WorkspaceRole;
|
|
11
|
-
coordinatorPrompt?: string;
|
|
11
|
+
coordinatorPrompt?: string | null;
|
|
12
12
|
includePrompts?: boolean;
|
|
13
13
|
includeRootAgents?: boolean;
|
|
14
14
|
localRoleOnly?: boolean;
|
|
@@ -19,7 +19,7 @@ export async function readLocalRole(agent, root) {
|
|
|
19
19
|
export async function agentText(agent, root, coordinatorPrompt = "plugin-coordinator.md") {
|
|
20
20
|
requireThat(agent === "coordinator" || agent === "general-purpose", "未知职责。");
|
|
21
21
|
let text = await readFile(join(resourceRoot, "agents", agent + ".md"), "utf8");
|
|
22
|
-
if (agent === "coordinator") {
|
|
22
|
+
if (agent === "coordinator" && coordinatorPrompt) {
|
|
23
23
|
text += "\n\n" + await readFile(join(resourceRoot, "prompts", coordinatorPrompt), "utf8");
|
|
24
24
|
}
|
|
25
25
|
const local = await readLocalRole(agent, root);
|
|
@@ -32,7 +32,7 @@ export function formatWorkspaceSkills(skills) {
|
|
|
32
32
|
if (!skills.length)
|
|
33
33
|
return "";
|
|
34
34
|
const lines = skills.map(skill => `- **${skill.name}**(\`${skill.path}\`):${skill.description}`);
|
|
35
|
-
return "##
|
|
35
|
+
return "## 按需读取的技能\n\n" + lines.join("\n");
|
|
36
36
|
}
|
|
37
37
|
export async function loadWorkspaceContext(options) {
|
|
38
38
|
const { host, root, role, coordinatorPrompt, includePrompts = true, includeRootAgents = false, localRoleOnly = false, workspaceSkills = [], notices = [], } = options;
|
|
@@ -45,7 +45,7 @@ export async function loadWorkspaceContext(options) {
|
|
|
45
45
|
: ["", "", ""];
|
|
46
46
|
const skillsSection = formatWorkspaceSkills(workspaceSkills);
|
|
47
47
|
const noticesSection = notices.length
|
|
48
|
-
? "##
|
|
48
|
+
? "## 维护提醒\n\n告知用户,按用户要求执行。\n\n" + notices.map(item => `- ${item}`).join("\n")
|
|
49
49
|
: "";
|
|
50
50
|
const environment = { host, workspaceRoot: root, resourceRoot };
|
|
51
51
|
const text = [
|
|
@@ -104,7 +104,6 @@ export const antigravityAdapter = {
|
|
|
104
104
|
host: "antigravity",
|
|
105
105
|
nativeRootAgents: true,
|
|
106
106
|
nativeWorkspaceSkills: true,
|
|
107
|
-
coordinatorPrompt: "plugin-coordinator.md",
|
|
108
107
|
initCommandHint: "/pbot init",
|
|
109
108
|
usage: "用法:node <插件目录>/lib/plugin.js antigravity init|status",
|
|
110
109
|
resolveRoot(cwd, rawPayload) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { object } from "../../../common/json.js";
|
|
2
2
|
import { requireThat } from "../../../common/validation.js";
|
|
3
3
|
import { parsePromptEvent, pluginWorkspaceRoot, promptHooks } from "../prompt-hooks.js";
|
|
4
|
-
const supportedEvents = ["UserPromptSubmit", "PreToolUse", "UserPromptExpansion", "Stop"];
|
|
4
|
+
const supportedEvents = ["SessionStart", "UserPromptSubmit", "PreToolUse", "UserPromptExpansion", "Stop"];
|
|
5
5
|
const boundWorkspaceRoot = () => process.env.CLAUDE_PROJECT_DIR;
|
|
6
6
|
export async function claudeWorkspaceRoot(cwd, projectDirectory = boundWorkspaceRoot()) {
|
|
7
7
|
return pluginWorkspaceRoot(projectDirectory || cwd);
|
|
@@ -10,7 +10,6 @@ export const claudeAdapter = {
|
|
|
10
10
|
host: "claude",
|
|
11
11
|
nativeRootAgents: false,
|
|
12
12
|
nativeWorkspaceSkills: false,
|
|
13
|
-
coordinatorPrompt: "plugin-coordinator.md",
|
|
14
13
|
initCommandHint: "/personal-bot:pbot init",
|
|
15
14
|
usage: "用法:node <插件目录>/lib/claude.js init|status",
|
|
16
15
|
boundWorkspaceRoot,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Context } from "@deepseek-ai/cordis";
|
|
2
2
|
import type { Agent } from "@deepseek-ai/dsh-agent";
|
|
3
3
|
import type { AgentOptions } from "../../../model/agent.js";
|
|
4
|
-
export declare function dshResources(ctx: Context, _agent: Agent, root: string, role: "coordinator" | "general-purpose", check: () => void, coordinatorPrompt?: string): Promise<void>;
|
|
4
|
+
export declare function dshResources(ctx: Context, _agent: Agent, root: string, role: "coordinator" | "general-purpose", check: () => void, coordinatorPrompt?: string | null): 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;
|
|
@@ -17,14 +17,11 @@ export function parsePromptEvent(value) {
|
|
|
17
17
|
if (typeof value.agent_id === "string")
|
|
18
18
|
return { kind: "ignore" };
|
|
19
19
|
requireThat(typeof value.cwd === "string", "插件 hook 缺少工作目录。");
|
|
20
|
-
if (name
|
|
20
|
+
if (name !== "SessionStart")
|
|
21
21
|
return { kind: "record-history", cwd: value.cwd, raw: value };
|
|
22
|
-
if (
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
return { kind: "inject-context", role: "coordinator", isSessionStart: true, noticesOnly: true, cwd: value.cwd, raw: value };
|
|
26
|
-
}
|
|
27
|
-
return { kind: "inject-context", role: "coordinator", cwd: value.cwd, raw: value };
|
|
22
|
+
if (value.source === "resume" || value.source === "compact")
|
|
23
|
+
return { kind: "ignore" };
|
|
24
|
+
return { kind: "inject-context", role: "coordinator", isSessionStart: true, cwd: value.cwd, raw: value };
|
|
28
25
|
}
|
|
29
26
|
export const promptHooks = {
|
|
30
27
|
async extractHistory(event) {
|
package/lib/model/acp.d.ts
CHANGED
|
@@ -48,14 +48,6 @@ export interface AcpModelsResult {
|
|
|
48
48
|
currentThinking?: string;
|
|
49
49
|
selection: AcpModelSelection;
|
|
50
50
|
}
|
|
51
|
-
export interface AcpModelState extends AcpModelSelection {
|
|
52
|
-
generation: string;
|
|
53
|
-
}
|
|
54
|
-
export interface AcpProcess {
|
|
55
|
-
generation: string;
|
|
56
|
-
pid: number;
|
|
57
|
-
startedAt: number;
|
|
58
|
-
}
|
|
59
51
|
export interface AcpInput {
|
|
60
52
|
generation: string;
|
|
61
53
|
requestId: string;
|
|
@@ -66,53 +58,55 @@ export interface AcpAnswer extends AcpInput {
|
|
|
66
58
|
state: typeof acpAnswerStates[number];
|
|
67
59
|
error?: string;
|
|
68
60
|
}
|
|
69
|
-
export
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
export
|
|
61
|
+
export declare const acpElicitationActions: readonly ["accept", "decline", "cancel"];
|
|
62
|
+
export type AcpElicitationAction = typeof acpElicitationActions[number];
|
|
63
|
+
export type AcpElicitationValue = string | number | boolean | string[];
|
|
64
|
+
export declare function isAcpElicitationValue(value: unknown): value is AcpElicitationValue;
|
|
65
|
+
export type AcpElicitationContent = Record<string, AcpElicitationValue>;
|
|
66
|
+
export type AcpInteraction = {
|
|
75
67
|
generation: string;
|
|
76
68
|
requestId: string;
|
|
69
|
+
kind: "permission";
|
|
77
70
|
description: string;
|
|
78
71
|
options: {
|
|
79
72
|
optionId: string;
|
|
80
73
|
name: string;
|
|
81
74
|
kind: string;
|
|
82
75
|
}[];
|
|
83
|
-
}
|
|
84
|
-
export interface AcpPermissionReply {
|
|
76
|
+
} | {
|
|
85
77
|
generation: string;
|
|
86
78
|
requestId: string;
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
export type AcpElicitationValue = string | number | boolean | string[];
|
|
92
|
-
export declare function isAcpElicitationValue(value: unknown): value is AcpElicitationValue;
|
|
93
|
-
export type AcpElicitationContent = Record<string, AcpElicitationValue>;
|
|
94
|
-
export interface AcpElicitation {
|
|
79
|
+
kind: "form";
|
|
80
|
+
message: string;
|
|
81
|
+
schema: Record<string, unknown>;
|
|
82
|
+
} | {
|
|
95
83
|
generation: string;
|
|
96
84
|
requestId: string;
|
|
97
|
-
|
|
85
|
+
kind: "url";
|
|
98
86
|
message: string;
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
export interface AcpElicitationReply {
|
|
87
|
+
url: string;
|
|
88
|
+
};
|
|
89
|
+
export type AcpInteractionReply = {
|
|
103
90
|
generation: string;
|
|
104
91
|
requestId: string;
|
|
92
|
+
kind: "permission";
|
|
93
|
+
optionId: string | null;
|
|
94
|
+
} | {
|
|
95
|
+
generation: string;
|
|
96
|
+
requestId: string;
|
|
97
|
+
kind: "form";
|
|
105
98
|
action: AcpElicitationAction;
|
|
106
99
|
content?: AcpElicitationContent;
|
|
107
|
-
}
|
|
100
|
+
} | {
|
|
101
|
+
generation: string;
|
|
102
|
+
requestId: string;
|
|
103
|
+
kind: "url";
|
|
104
|
+
action: AcpElicitationAction;
|
|
105
|
+
};
|
|
108
106
|
export interface AcpStartOptions {
|
|
109
|
-
name?: string;
|
|
110
|
-
message?: string;
|
|
111
|
-
files?: string[];
|
|
112
107
|
provider?: string;
|
|
113
108
|
model?: string;
|
|
114
109
|
thinking?: string;
|
|
115
|
-
cwd?: string;
|
|
116
110
|
tools?: string[];
|
|
117
111
|
noExtensions?: boolean;
|
|
118
112
|
noSkills?: boolean;
|
|
@@ -121,7 +115,7 @@ export interface AcpStartOptions {
|
|
|
121
115
|
}
|
|
122
116
|
export interface AcpLaunchContext {
|
|
123
117
|
readonly reference: AcpSessionReference;
|
|
124
|
-
readonly
|
|
118
|
+
readonly workspace: string;
|
|
125
119
|
readonly directory: string;
|
|
126
120
|
readonly packageRoot: string;
|
|
127
121
|
readonly options: AcpStartOptions;
|
package/lib/model/agent.d.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import type { AcpBackend, AcpElicitationAction, AcpElicitationContent, AcpModelSelection, AcpSessionReference, AcpStartOptions } from "./acp.js";
|
|
1
|
+
import type { AcpBackend, AcpCommand, AcpElicitationAction, AcpElicitationContent, AcpModelSelection, AcpPermissionPolicy, AcpSessionReference, AcpStartOptions } from "./acp.js";
|
|
2
2
|
export type AgentOptions = AcpStartOptions;
|
|
3
3
|
export interface AgentStartOptions extends AgentOptions {
|
|
4
4
|
backend: AcpBackend;
|
|
5
|
+
message?: string;
|
|
6
|
+
files?: string[];
|
|
5
7
|
}
|
|
6
8
|
export interface AgentOwner {
|
|
7
9
|
sessionId: string;
|
|
@@ -12,23 +14,29 @@ export interface AgentDescriptor {
|
|
|
12
14
|
agentId: string;
|
|
13
15
|
release: string;
|
|
14
16
|
workspace: string;
|
|
15
|
-
cwd: string;
|
|
16
17
|
parentSessionId: string;
|
|
17
|
-
parentLeaf: string | null;
|
|
18
|
-
createdAt: number;
|
|
19
18
|
options: AgentOptions;
|
|
20
19
|
}
|
|
21
20
|
export type AgentSessionReference = AcpSessionReference;
|
|
22
|
-
export interface
|
|
21
|
+
export interface AgentAcpConfig extends AcpCommand {
|
|
22
|
+
backend: AcpBackend;
|
|
23
|
+
permission?: AcpPermissionPolicy;
|
|
24
|
+
}
|
|
25
|
+
export interface AgentWorkerRecord {
|
|
26
|
+
agentId: string;
|
|
27
|
+
release: string;
|
|
28
|
+
workspace: string;
|
|
29
|
+
parentSessionId: string;
|
|
23
30
|
generation: string;
|
|
24
|
-
name: string;
|
|
25
31
|
sequence: number;
|
|
26
32
|
stop: boolean;
|
|
27
33
|
startedAt: number;
|
|
34
|
+
pid?: number;
|
|
35
|
+
acp: AgentAcpConfig;
|
|
36
|
+
options?: AgentOptions;
|
|
28
37
|
}
|
|
29
38
|
export declare const messageDeliveries: readonly ["steer", "followUp"];
|
|
30
39
|
export declare const cycleStates: readonly ["running", "completed", "failed", "cancelled", "interrupted"];
|
|
31
|
-
export declare const cycleSources: readonly ["parent", "interactive", "mixed"];
|
|
32
40
|
export declare const agentStates: readonly ["starting", "busy", "idle", "stopping", "stopped", "error"];
|
|
33
41
|
export interface AgentMessage {
|
|
34
42
|
requestId: string;
|
|
@@ -44,9 +52,7 @@ export interface AgentCycle {
|
|
|
44
52
|
startedAt: number;
|
|
45
53
|
finishedAt?: number;
|
|
46
54
|
state: typeof cycleStates[number];
|
|
47
|
-
leaf: string | null;
|
|
48
55
|
requestIds: string[];
|
|
49
|
-
source: typeof cycleSources[number];
|
|
50
56
|
error?: string;
|
|
51
57
|
}
|
|
52
58
|
export interface AgentStatus {
|
|
@@ -54,12 +60,29 @@ export interface AgentStatus {
|
|
|
54
60
|
state: typeof agentStates[number];
|
|
55
61
|
activity: string;
|
|
56
62
|
updatedAt: number;
|
|
63
|
+
sessionId?: string | null;
|
|
64
|
+
capabilities?: {
|
|
65
|
+
resume: boolean;
|
|
66
|
+
load: boolean;
|
|
67
|
+
close: boolean;
|
|
68
|
+
};
|
|
69
|
+
selection?: AcpModelSelection;
|
|
70
|
+
activeRequestId?: string;
|
|
57
71
|
accepted?: string[];
|
|
58
72
|
cycle?: AgentCycle;
|
|
59
73
|
error?: string;
|
|
60
74
|
}
|
|
75
|
+
export interface AgentOutput {
|
|
76
|
+
cycleId: string;
|
|
77
|
+
generation: string;
|
|
78
|
+
startedAt: number;
|
|
79
|
+
finishedAt: number;
|
|
80
|
+
state: Exclude<AgentCycle["state"], "running">;
|
|
81
|
+
requestIds: string[];
|
|
82
|
+
text: string;
|
|
83
|
+
error?: string;
|
|
84
|
+
}
|
|
61
85
|
export interface AgentView extends AgentDescriptor {
|
|
62
|
-
name: string;
|
|
63
86
|
generation: string;
|
|
64
87
|
state: AgentStatus["state"];
|
|
65
88
|
activity: string;
|
|
@@ -103,12 +126,6 @@ export interface AgentResponseInput {
|
|
|
103
126
|
optionId?: string;
|
|
104
127
|
content?: AcpElicitationContent;
|
|
105
128
|
}
|
|
106
|
-
export interface AgentCompletion {
|
|
107
|
-
agentId: string;
|
|
108
|
-
name: string;
|
|
109
|
-
cycle: AgentCycle;
|
|
110
|
-
report: string;
|
|
111
|
-
}
|
|
112
129
|
export interface AgentHost {
|
|
113
130
|
available(backend: AcpBackend): void;
|
|
114
131
|
filterOptions?(backend: AcpBackend, options: AgentOptions): AgentOptions;
|
|
@@ -117,5 +134,4 @@ export interface AgentHost {
|
|
|
117
134
|
validateSession(value: AgentDescriptor, reference: AgentSessionReference): void | Promise<void>;
|
|
118
135
|
launch(value: AgentDescriptor, directory: string, generation: string, reference: AgentSessionReference, resume: boolean, signal: AbortSignal): void | Promise<void>;
|
|
119
136
|
release(id: string, generation: string): void | Promise<void>;
|
|
120
|
-
report(value: AgentDescriptor, reference: AgentSessionReference, leaf: string): string | Promise<string>;
|
|
121
137
|
}
|
package/lib/model/agent.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
1
|
export const messageDeliveries = ["steer", "followUp"];
|
|
2
2
|
export const cycleStates = ["running", "completed", "failed", "cancelled", "interrupted"];
|
|
3
|
-
export const cycleSources = ["parent", "interactive", "mixed"];
|
|
4
3
|
export const agentStates = ["starting", "busy", "idle", "stopping", "stopped", "error"];
|
|
@@ -4,13 +4,13 @@
|
|
|
4
4
|
"command": "sh",
|
|
5
5
|
"args": [
|
|
6
6
|
"-c",
|
|
7
|
-
"if pbot --at-least 0.3.3 </dev/null >/dev/null 2>&1; then exec pbot \"$@\"; fi\nexec npx --yes --ignore-scripts --prefer-offline personal-bot@0.
|
|
7
|
+
"if pbot --at-least 0.3.3 </dev/null >/dev/null 2>&1; then exec pbot \"$@\"; fi\nexec npx --yes --ignore-scripts --prefer-offline personal-bot@0.4.1 \"$@\"",
|
|
8
8
|
"pbot",
|
|
9
9
|
"mcp"
|
|
10
10
|
],
|
|
11
11
|
"env": {
|
|
12
12
|
"PBOT_HOST": "qoder",
|
|
13
|
-
"PBOT_PLUGIN_VERSION": "0.
|
|
13
|
+
"PBOT_PLUGIN_VERSION": "0.4.1"
|
|
14
14
|
}
|
|
15
15
|
}
|
|
16
16
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "personal-bot",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.4.1",
|
|
4
|
+
"description": "Organize workspace files, search past conversations, use shared MCP tools, and delegate tasks to other assistants.",
|
|
5
5
|
"skills": "./skills/",
|
|
6
6
|
"mcpServers": "./.mcp.json"
|
|
7
7
|
}
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
"hooks": [
|
|
6
6
|
{
|
|
7
7
|
"type": "command",
|
|
8
|
-
"command": "PBOT_PLUGIN_VERSION=0.
|
|
8
|
+
"command": "PBOT_PLUGIN_VERSION=0.4.1 sh -c 'if pbot --at-least 0.3.3 </dev/null >/dev/null 2>&1; then exec pbot \"$@\"; fi\nexec npx --yes --ignore-scripts --prefer-offline personal-bot@0.4.1 \"$@\"' pbot plugin qoder hook",
|
|
9
9
|
"timeout": 120
|
|
10
10
|
}
|
|
11
11
|
]
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"hooks": [
|
|
17
17
|
{
|
|
18
18
|
"type": "command",
|
|
19
|
-
"command": "PBOT_PLUGIN_VERSION=0.
|
|
19
|
+
"command": "PBOT_PLUGIN_VERSION=0.4.1 sh -c 'if pbot --at-least 0.3.3 </dev/null >/dev/null 2>&1; then exec pbot \"$@\"; fi\nexec npx --yes --ignore-scripts --prefer-offline personal-bot@0.4.1 \"$@\"' pbot plugin qoder hook",
|
|
20
20
|
"timeout": 120
|
|
21
21
|
}
|
|
22
22
|
]
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"hooks": [
|
|
28
28
|
{
|
|
29
29
|
"type": "command",
|
|
30
|
-
"command": "PBOT_PLUGIN_VERSION=0.
|
|
30
|
+
"command": "PBOT_PLUGIN_VERSION=0.4.1 sh -c 'if pbot --at-least 0.3.3 </dev/null >/dev/null 2>&1; then exec pbot \"$@\"; fi\nexec npx --yes --ignore-scripts --prefer-offline personal-bot@0.4.1 \"$@\"' pbot plugin qoder hook",
|
|
31
31
|
"timeout": 120
|
|
32
32
|
}
|
|
33
33
|
]
|
|
@@ -1,9 +1,17 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: pbot
|
|
3
|
-
description:
|
|
3
|
+
description: 初始化或检查 Personal Bot 工作区,检索、汇总或迁移历史归档。
|
|
4
4
|
disable-model-invocation: true
|
|
5
5
|
---
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
用当前会话的工作区根目录替换 `<workspaceRoot>`。无参数时执行 `status`。用户要求初始化时执行 `init`,启用工作区并补建缺失的资料目录和根 `AGENTS.md`。
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
会话给出 `resourceRoot` 时,用随包 CLI 执行所选命令。查看状态可运行
|
|
10
|
+
|
|
11
|
+
```sh
|
|
12
|
+
node "<resourceRoot>/../lib/extension/cli.js" status --workspace "<workspaceRoot>"
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
没有该路径时,若 `pbot --at-least 0.4.1` 成功,用 `pbot` 替换上例的 `node ".../cli.js"`,否则用 `npx --yes --ignore-scripts personal-bot@0.4.1`。
|
|
16
|
+
|
|
17
|
+
历史操作将 `status` 替换为 `history` 和用户指定的子命令、参数。`history summary` 更新各维度,`history summary monthly` 汇总已有会话摘要。迁移预览用 `history migrate --dry-run`,其他用法见 `history --help`。
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { AgentDescriptor, AgentMessage } from "../../model/agent.js";
|
|
2
|
-
import type { AcpElicitationAction, AcpElicitationContent,
|
|
2
|
+
import type { AcpElicitationAction, AcpElicitationContent, AcpInteraction } from "../../model/acp.js";
|
|
3
3
|
import { AgentFiles } from "../../storage/agent-files.js";
|
|
4
4
|
import { AgentRun } from "./agent-run.js";
|
|
5
5
|
export interface AcpProgress {
|
|
@@ -21,7 +21,7 @@ export interface AcpWork {
|
|
|
21
21
|
}>;
|
|
22
22
|
cancel(): Promise<void>;
|
|
23
23
|
}
|
|
24
|
-
/** ACP prompt completion is the receipt boundary;
|
|
24
|
+
/** ACP prompt completion is the receipt boundary; output publishes before state returns to idle. */
|
|
25
25
|
export declare class AcpAgentRun {
|
|
26
26
|
#private;
|
|
27
27
|
readonly files: AgentFiles;
|
|
@@ -30,11 +30,13 @@ export declare class AcpAgentRun {
|
|
|
30
30
|
readonly work: AcpWork;
|
|
31
31
|
readonly exactAnswer: boolean;
|
|
32
32
|
readonly execution: AgentRun;
|
|
33
|
-
constructor(files: AgentFiles, descriptor: AgentDescriptor, generation: string, work: AcpWork, exactAnswer: boolean);
|
|
33
|
+
constructor(files: AgentFiles, descriptor: AgentDescriptor, generation: string, work: AcpWork, exactAnswer: boolean, execution?: AgentRun);
|
|
34
34
|
private get id();
|
|
35
35
|
private current;
|
|
36
36
|
update(value: AcpProgress): void;
|
|
37
|
-
permission(description: string, options:
|
|
37
|
+
permission(description: string, options: Extract<AcpInteraction, {
|
|
38
|
+
kind: "permission";
|
|
39
|
+
}>["options"], signal: AbortSignal): Promise<string | null>;
|
|
38
40
|
elicitation(input: {
|
|
39
41
|
mode: "form";
|
|
40
42
|
message: string;
|