personal-bot 0.3.6 → 0.4.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 +2 -2
- package/.claude-plugin/plugin.json +1 -1
- package/README.md +5 -8
- package/README.zh-CN.md +5 -8
- package/bin/pbot-pi-acp.mjs +1 -1
- package/docs/README.md +1 -1
- package/docs/architecture/design.md +2 -2
- package/docs/architecture/extensibility.md +1 -1
- package/docs/architecture/model-context.md +1 -2
- package/docs/guides/capabilities.md +4 -8
- package/docs/guides/cross-harness-workers.md +4 -4
- package/docs/guides/history.md +1 -3
- package/docs/guides/workspace-configuration.md +4 -4
- package/docs/hosts/claude-code.md +2 -2
- package/docs/hosts/codex-qoder.md +1 -1
- 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 +348 -203
- package/lib/antigravity-plugin/lib/extension/cli.js +574 -549
- 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 +0 -11
- package/lib/antigravity-plugin/lib/extension/mcp.js +462 -326
- package/lib/antigravity-plugin/lib/integrations/agent-resources.js +2 -2
- 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/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/package.json +1 -1
- package/lib/antigravity-plugin/plugin.json +1 -1
- package/lib/antigravity-plugin/resources/agents/coordinator.md +3 -7
- package/lib/antigravity-plugin/resources/agents/general-purpose.md +3 -3
- package/lib/antigravity-plugin/resources/prompts/plugin-coordinator.md +1 -2
- package/lib/antigravity-plugin/resources/prompts/workspace.md +12 -16
- package/lib/antigravity-plugin/resources/skills/provider-connections/SKILL.md +7 -6
- package/lib/antigravity-plugin/resources/templates/workspace-agents.md +0 -4
- package/lib/antigravity-plugin/skills/pbot/SKILL.md +14 -6
- package/lib/antigravity-plugin/skills/provider-connections/SKILL.md +7 -6
- package/lib/codex-marketplace/plugins/personal-bot/.codex-plugin/plugin.json +1 -1
- 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 +2 -2
- 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 +348 -203
- package/lib/extension/cli.js +574 -549
- package/lib/extension/hosts/dsh/acp-member.js +1 -1
- package/lib/extension/hosts/dsh/command.js +1 -1
- package/lib/extension/hosts/dsh/workspace.js +1 -3
- package/lib/extension/hosts/pi/acp-member.js +3 -4
- package/lib/extension/hosts/plugin-runtime.js +0 -11
- package/lib/extension/mcp/tool-contract.d.ts +8 -50
- package/lib/extension/mcp/tool-contract.js +48 -62
- package/lib/extension/mcp/workers.d.ts +13 -27
- package/lib/extension/mcp/workers.js +60 -25
- package/lib/extension/mcp.js +462 -326
- 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.js +2 -2
- 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 +1 -1
- package/lib/qoder-plugin/hooks/hooks.json +3 -3
- package/lib/qoder-plugin/skills/pbot/SKILL.md +2 -2
- 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 +180 -126
- 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/tools/history/contract.js +12 -12
- package/package.json +1 -1
- package/resources/agents/coordinator.md +3 -7
- package/resources/agents/general-purpose.md +3 -3
- package/resources/antigravity/skills/pbot/SKILL.md +14 -6
- package/resources/claude/skills/pbot/SKILL.md +14 -6
- package/resources/plugin/skills/pbot/SKILL.md +2 -2
- package/resources/prompts/history-coordinator.md +1 -2
- package/resources/prompts/plugin-coordinator.md +1 -2
- package/resources/prompts/workspace.md +12 -16
- package/resources/skills/provider-connections/SKILL.md +7 -6
- package/resources/templates/workspace-agents.md +0 -4
- package/src/extension/acp/member.ts +14 -11
- package/src/extension/acp/worker.ts +31 -28
- 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 +1 -1
- package/src/extension/hosts/dsh/workspace.ts +1 -3
- package/src/extension/hosts/pi/acp-member.ts +3 -4
- package/src/extension/hosts/pi/command.ts +1 -1
- package/src/extension/hosts/pi/lifecycle.ts +0 -2
- package/src/extension/hosts/plugin-runtime.ts +0 -10
- package/src/extension/mcp/tool-contract.ts +48 -62
- package/src/extension/mcp/workers.ts +66 -27
- package/src/integrations/acp/agents.ts +28 -27
- package/src/integrations/acp/harnesses/claude.ts +1 -1
- package/src/integrations/agent-resources.ts +2 -2
- package/src/integrations/hosts/dsh/session.ts +2 -2
- 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 +2 -2
- 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 +204 -133
- 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/tools/history/contract.ts +12 -12
- 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/antigravity-plugin/resources/references/compute-finance.md +0 -22
- package/lib/antigravity-plugin/resources/references/compute.md +0 -16
- package/lib/antigravity-plugin/resources/references/task-conductor.md +0 -25
- package/lib/services/workspace/plugin-releases.d.ts +0 -15
- package/lib/services/workspace/plugin-releases.js +0 -126
- package/resources/references/compute-finance.md +0 -22
- package/resources/references/compute.md +0 -16
- package/resources/references/task-conductor.md +0 -25
- package/src/services/workspace/plugin-releases.ts +0 -121
|
@@ -1,22 +1,21 @@
|
|
|
1
|
-
import { existsSync, mkdirSync, readdirSync, rmSync } from "node:fs";
|
|
1
|
+
import { existsSync, mkdirSync, readdirSync, rmdirSync, rmSync, unlinkSync } from "node:fs";
|
|
2
2
|
import { join } from "node:path";
|
|
3
3
|
import { randomUUID } from "node:crypto";
|
|
4
4
|
import { canonical, object } from "../common/json.js";
|
|
5
5
|
import { isOneOf, requireThat } from "../common/validation.js";
|
|
6
6
|
import { readJsonFile, writeJsonFile } from "./atomic-json.js";
|
|
7
7
|
import { fileId, privateDirectory } from "./file-access.js";
|
|
8
|
-
import { agentStates,
|
|
9
|
-
import {
|
|
8
|
+
import { agentStates, cycleStates, messageDeliveries } from "../model/agent.js";
|
|
9
|
+
import { acpConfig, acpInteraction, acpReference } from "./acp-files.js";
|
|
10
10
|
const text = (v) => typeof v === "string" && v.length > 0;
|
|
11
11
|
const number = (v) => typeof v === "number" && Number.isFinite(v);
|
|
12
|
-
export function
|
|
13
|
-
requireThat(object(v) && text(v.agentId) && text(v.release) && text(v.workspace) && text(v.
|
|
14
|
-
(v.
|
|
12
|
+
export function workerRecord(v) {
|
|
13
|
+
requireThat(object(v) && text(v.agentId) && text(v.release) && text(v.workspace) && text(v.parentSessionId) &&
|
|
14
|
+
text(v.generation) && Number.isSafeInteger(v.sequence) && typeof v.stop === "boolean" && number(v.startedAt) &&
|
|
15
|
+
(v.pid === undefined || (Number.isSafeInteger(v.pid) && Number(v.pid) > 1)) &&
|
|
16
|
+
(v.options === undefined || object(v.options)), "worker 控制记录无效。");
|
|
15
17
|
fileId(v.agentId);
|
|
16
|
-
|
|
17
|
-
}
|
|
18
|
-
export function launch(v) {
|
|
19
|
-
requireThat(object(v) && text(v.generation) && text(v.name) && Number.isSafeInteger(v.sequence) && typeof v.stop === "boolean" && number(v.startedAt), "子会话启动状态无效。");
|
|
18
|
+
acpConfig(v.acp);
|
|
20
19
|
return v;
|
|
21
20
|
}
|
|
22
21
|
export function message(v) {
|
|
@@ -26,18 +25,72 @@ export function message(v) {
|
|
|
26
25
|
}
|
|
27
26
|
export function cycle(v) {
|
|
28
27
|
requireThat(object(v) && text(v.cycleId) && text(v.generation) && number(v.startedAt) &&
|
|
29
|
-
isOneOf(v.state, cycleStates) &&
|
|
30
|
-
(v.
|
|
31
|
-
|
|
28
|
+
isOneOf(v.state, cycleStates) && Array.isArray(v.requestIds) && v.requestIds.every(text) &&
|
|
29
|
+
(v.finishedAt === undefined || number(v.finishedAt)) &&
|
|
30
|
+
(v.error === undefined || typeof v.error === "string"), "子会话周期无效。");
|
|
32
31
|
return v;
|
|
33
32
|
}
|
|
34
33
|
export function status(v) {
|
|
35
34
|
requireThat(object(v) && text(v.generation) && isOneOf(v.state, agentStates) &&
|
|
36
35
|
typeof v.activity === "string" && number(v.updatedAt), "子会话状态无效。");
|
|
37
|
-
if (v.
|
|
36
|
+
if (v.sessionId !== undefined)
|
|
37
|
+
requireThat(v.sessionId === null || text(v.sessionId), "ACP 会话 ID 无效。");
|
|
38
|
+
if (v.capabilities !== undefined) {
|
|
39
|
+
requireThat(object(v.capabilities) &&
|
|
40
|
+
["resume", "load", "close"].every(key => typeof v.capabilities[key] === "boolean"), "ACP 会话能力无效。");
|
|
41
|
+
}
|
|
42
|
+
if (v.selection !== undefined) {
|
|
43
|
+
requireThat(object(v.selection) &&
|
|
44
|
+
["provider", "model", "resolvedModel", "thinking"].every(key => v.selection[key] === undefined || text(v.selection[key])), "ACP 模型选择无效。");
|
|
45
|
+
}
|
|
46
|
+
if (v.activeRequestId !== undefined) {
|
|
47
|
+
requireThat(text(v.activeRequestId), "ACP 输入关联无效。");
|
|
48
|
+
fileId(v.activeRequestId);
|
|
49
|
+
}
|
|
50
|
+
if (v.accepted !== undefined)
|
|
51
|
+
requireThat(Array.isArray(v.accepted) && v.accepted.every(text), "已领取请求列表无效。");
|
|
52
|
+
if (v.cycle !== undefined)
|
|
38
53
|
cycle(v.cycle);
|
|
54
|
+
if (v.error !== undefined)
|
|
55
|
+
requireThat(typeof v.error === "string", "子会话错误信息无效。");
|
|
56
|
+
return v;
|
|
57
|
+
}
|
|
58
|
+
export function outputRecord(v) {
|
|
59
|
+
requireThat(object(v) && text(v.cycleId) && text(v.generation) && number(v.startedAt) && number(v.finishedAt) &&
|
|
60
|
+
isOneOf(v.state, ["completed", "failed", "cancelled", "interrupted"]) &&
|
|
61
|
+
Array.isArray(v.requestIds) && v.requestIds.every(text) &&
|
|
62
|
+
typeof v.text === "string" && (v.error === undefined || typeof v.error === "string"), "子会话输出记录无效。");
|
|
63
|
+
fileId(v.cycleId);
|
|
39
64
|
return v;
|
|
40
65
|
}
|
|
66
|
+
export function toDescriptor(record) {
|
|
67
|
+
return {
|
|
68
|
+
agentId: record.agentId,
|
|
69
|
+
release: record.release,
|
|
70
|
+
workspace: record.workspace,
|
|
71
|
+
parentSessionId: record.parentSessionId,
|
|
72
|
+
options: record.options ?? {},
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
function tryUnlink(path) {
|
|
76
|
+
try {
|
|
77
|
+
unlinkSync(path);
|
|
78
|
+
}
|
|
79
|
+
catch (error) {
|
|
80
|
+
if (error.code !== "ENOENT")
|
|
81
|
+
throw error;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
function tryRmdir(path) {
|
|
85
|
+
try {
|
|
86
|
+
rmdirSync(path);
|
|
87
|
+
}
|
|
88
|
+
catch (error) {
|
|
89
|
+
const code = error.code;
|
|
90
|
+
if (code !== "ENOENT" && code !== "ENOTEMPTY" && code !== "EEXIST")
|
|
91
|
+
throw error;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
41
94
|
export class AgentFiles {
|
|
42
95
|
root;
|
|
43
96
|
#failure;
|
|
@@ -72,56 +125,105 @@ export class AgentFiles {
|
|
|
72
125
|
}
|
|
73
126
|
requireThat(published, "子会话文件已存在。");
|
|
74
127
|
}
|
|
128
|
+
remove(id, path) {
|
|
129
|
+
tryUnlink(join(this.directory(id), path));
|
|
130
|
+
}
|
|
75
131
|
create(value, run, acp) {
|
|
76
132
|
this.check();
|
|
77
133
|
acpReference(acp);
|
|
78
134
|
mkdirSync(this.root, { recursive: true, mode: 0o700 });
|
|
79
135
|
mkdirSync(this.directory(value.agentId), { mode: 0o700 });
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
136
|
+
const hasOptions = Object.keys(value.options).length > 0;
|
|
137
|
+
const record = {
|
|
138
|
+
agentId: value.agentId,
|
|
139
|
+
release: value.release,
|
|
140
|
+
workspace: value.workspace,
|
|
141
|
+
parentSessionId: value.parentSessionId,
|
|
142
|
+
generation: run.generation,
|
|
143
|
+
sequence: run.sequence,
|
|
144
|
+
stop: run.stop,
|
|
145
|
+
startedAt: run.startedAt,
|
|
146
|
+
acp: {
|
|
147
|
+
backend: acp.backend,
|
|
148
|
+
command: acp.command,
|
|
149
|
+
args: acp.args,
|
|
150
|
+
...(acp.env ? { env: acp.env } : {}),
|
|
151
|
+
...(acp.permission ? { permission: acp.permission } : {}),
|
|
152
|
+
},
|
|
153
|
+
...(hasOptions ? { options: value.options } : {}),
|
|
154
|
+
};
|
|
155
|
+
this.write(value.agentId, "worker.json", record, workerRecord, true);
|
|
156
|
+
}
|
|
157
|
+
worker(id) {
|
|
158
|
+
return this.read(id, "worker.json", workerRecord);
|
|
85
159
|
}
|
|
86
160
|
list() {
|
|
87
161
|
if (!existsSync(this.root))
|
|
88
162
|
return [];
|
|
89
163
|
return readdirSync(this.root, { withFileTypes: true }).filter(e => e.isDirectory() && !e.name.startsWith(".")).flatMap(e => {
|
|
90
|
-
const
|
|
91
|
-
return
|
|
164
|
+
const record = this.optional(e.name, "worker.json", workerRecord);
|
|
165
|
+
return record ? [record] : [];
|
|
92
166
|
});
|
|
93
167
|
}
|
|
94
168
|
messages(id) {
|
|
95
|
-
|
|
169
|
+
const dir = join(this.directory(id), "inbox");
|
|
170
|
+
if (!existsSync(dir))
|
|
171
|
+
return [];
|
|
172
|
+
return readdirSync(dir).filter(n => n.endsWith(".json"))
|
|
96
173
|
.map(n => this.read(id, "inbox/" + n, message)).sort((a, b) => a.sequence - b.sequence);
|
|
97
174
|
}
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
175
|
+
removeMessage(id, requestId) {
|
|
176
|
+
fileId(requestId);
|
|
177
|
+
const dir = join(this.directory(id), "inbox");
|
|
178
|
+
tryUnlink(join(dir, requestId + ".json"));
|
|
179
|
+
tryRmdir(dir);
|
|
101
180
|
}
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
const dir = join(this.directory(id), "permissions");
|
|
105
|
-
if (!existsSync(dir))
|
|
106
|
-
return [];
|
|
107
|
-
const names = readdirSync(dir);
|
|
108
|
-
return names.filter(n => n.endsWith(".json") && !n.endsWith("-reply.json") && !names.includes(n.slice(0, -5) + "-reply.json"))
|
|
109
|
-
.map(n => this.read(id, "permissions/" + n, acpPermission)).filter(item => item.generation === generation);
|
|
181
|
+
output(id) {
|
|
182
|
+
return this.optional(id, "output.json", outputRecord);
|
|
110
183
|
}
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
const dir = join(this.directory(id), "elicitations");
|
|
184
|
+
pendingInteractions(id, generation) {
|
|
185
|
+
const dir = join(this.directory(id), "interactions");
|
|
114
186
|
if (!existsSync(dir))
|
|
115
187
|
return [];
|
|
116
188
|
const names = readdirSync(dir);
|
|
117
189
|
return names.filter(n => n.endsWith(".json") && !n.endsWith("-reply.json") && !names.includes(n.slice(0, -5) + "-reply.json"))
|
|
118
|
-
.map(n => this.read(id, "
|
|
190
|
+
.map(n => this.read(id, "interactions/" + n, acpInteraction)).filter(item => item.generation === generation);
|
|
191
|
+
}
|
|
192
|
+
removeInteraction(id, requestId) {
|
|
193
|
+
fileId(requestId);
|
|
194
|
+
const dir = join(this.directory(id), "interactions");
|
|
195
|
+
tryUnlink(join(dir, requestId + ".json"));
|
|
196
|
+
tryUnlink(join(dir, requestId + "-reply.json"));
|
|
197
|
+
tryRmdir(dir);
|
|
198
|
+
}
|
|
199
|
+
clearTransient(id) {
|
|
200
|
+
const base = this.directory(id);
|
|
201
|
+
if (!existsSync(base))
|
|
202
|
+
return;
|
|
203
|
+
rmSync(join(base, "inbox"), { recursive: true, force: true });
|
|
204
|
+
rmSync(join(base, "interactions"), { recursive: true, force: true });
|
|
205
|
+
tryUnlink(join(base, "acp-answer.json"));
|
|
206
|
+
}
|
|
207
|
+
removeWorker(id) {
|
|
208
|
+
rmSync(this.directory(id), { recursive: true, force: true });
|
|
209
|
+
tryRmdir(this.root);
|
|
119
210
|
}
|
|
120
211
|
ensureSubdirectory(id, name) {
|
|
121
212
|
privateDirectory(this.directory(id), name);
|
|
122
213
|
}
|
|
123
214
|
reference(id) {
|
|
124
|
-
|
|
215
|
+
const w = this.worker(id);
|
|
216
|
+
const saved = this.optional(id, "state.json", status);
|
|
217
|
+
return {
|
|
218
|
+
host: "acp",
|
|
219
|
+
backend: w.acp.backend,
|
|
220
|
+
command: w.acp.command,
|
|
221
|
+
args: w.acp.args,
|
|
222
|
+
...(w.acp.env ? { env: w.acp.env } : {}),
|
|
223
|
+
...(w.acp.permission ? { permission: w.acp.permission } : {}),
|
|
224
|
+
sessionId: saved?.sessionId ?? null,
|
|
225
|
+
...(saved?.capabilities ? { capabilities: saved.capabilities } : {}),
|
|
226
|
+
};
|
|
125
227
|
}
|
|
126
228
|
/** Short controller edits are serialized; an abandoned lock fails closed. */
|
|
127
229
|
control(work) {
|
|
@@ -145,14 +247,16 @@ export class AgentFiles {
|
|
|
145
247
|
}
|
|
146
248
|
enqueue(id, text, delivery, files = [], requestId = randomUUID()) {
|
|
147
249
|
fileId(requestId);
|
|
148
|
-
const
|
|
250
|
+
const w = this.worker(id);
|
|
251
|
+
const previous = this.optional(id, "inbox/" + requestId + ".json", message);
|
|
149
252
|
if (previous) {
|
|
150
|
-
requireThat(previous.generation ===
|
|
253
|
+
requireThat(previous.generation === w.generation && previous.message === text && previous.delivery === delivery && canonical(previous.files) === canonical(files), "请求 ID 已被不同输入使用。");
|
|
151
254
|
return previous;
|
|
152
255
|
}
|
|
153
|
-
|
|
154
|
-
this.write(id, "
|
|
155
|
-
|
|
256
|
+
w.sequence++;
|
|
257
|
+
this.write(id, "worker.json", w, workerRecord);
|
|
258
|
+
this.ensureSubdirectory(id, "inbox");
|
|
259
|
+
const value = { requestId, generation: w.generation, sequence: w.sequence, message: text, delivery, files };
|
|
156
260
|
this.write(id, "inbox/" + value.requestId + ".json", value, message, true);
|
|
157
261
|
return value;
|
|
158
262
|
}
|
|
@@ -1,11 +1,7 @@
|
|
|
1
1
|
# 协调者
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
委派专家时写明目标、相关资料、约束和交付要求;涉及文件修改时明确修改范围,多人并行写入时划分文件责任。
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
由你汇总专家结果、整合正式资料并处理口径差异。需要独立复核时,另开专家会话并提供待查内容与具体问题。
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
需要独立复核时,另开专家会话,提供待检查内容、相关资料和具体问题。
|
|
10
|
-
|
|
11
|
-
失败或中断后说明已完成部分、剩余工作和阻碍。需要用户决定的事项由你汇总说明。
|
|
7
|
+
失败或中断后说明已完成部分、剩余工作与阻碍;需要用户决定的事项由你汇总提出。
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# 通用专家
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
完成本次委派,使用相关资料和技能,交回结果、问题说明及产物路径;独立复核时自行核查并指出问题与不确定之处。
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
默认交回报告,由主会话整合正式资料;委派包含文件修改时直接修改并说明变更。
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
可自主排查工具和环境问题;受阻且需要主会话或用户协助时,交回已有结果与具体阻碍。不递归委派其他助手;需要额外协作者时向主会话建议。
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
用户要求更新工作区历史摘要时,运行 `pbot history summary --workspace "<workspaceRoot>"`。需要按当前版本调用时,读取 `resourceRoot/../package.json` 的 `version`,用 `npx --yes personal-bot@<version>` 替换命令中的 `pbot`。
|
|
1
|
+
未指定其他程序时,默认直接处理或使用当前宿主原生子代理;需要委派其他程序(或按工作区 `AGENTS.md`、`agents/coordinator.md` 分工约定)时,使用 `pbot` MCP 的 `worker_*` 工具。调用 `.pbot/mcp.json` 中的工作区 MCP 用 `workspace_mcp_discover` / `workspace_mcp_call`,回溯旧讨论用 `history_search` / `history_read`;更新历史摘要运行 `pbot history summary --workspace "<workspaceRoot>"`(未安装全局 `pbot` 时用 `node "<resourceRoot>/../lib/extension/cli.js"` 替换 `pbot`)。
|
|
@@ -1,31 +1,27 @@
|
|
|
1
1
|
# Personal Bot
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
按用户请求和已有约定推进工作,常规选择自行决定;只有缺失信息会改变目标或关键结果时才提问。超时、取消或断连后,先查状态再决定是否重试,避免重复执行。
|
|
4
4
|
|
|
5
|
-
##
|
|
5
|
+
## 资料与工作区
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
- 操作后查看结果。超时、取消或断连后,先查状态再决定是否重试,避免重复执行。
|
|
9
|
-
- 优先复用工作区已接入的 CLI/MCP:工作区共享 MCP 定义在 `.pbot/mcp.json`(可通过宿主原生工具或 `pbot` MCP 的 `workspace_mcp_discover` / `workspace_mcp_call` 调用),也可同时使用宿主原生 MCP。接入或排障使用 `provider-connections` 技能;需要数据口径或使用限制时读取 `providers/<id>/GUIDE.md`。认证使用原生登录或环境变量引用,资料中不保存凭据值。
|
|
10
|
-
|
|
11
|
-
## 资料与环境
|
|
12
|
-
|
|
13
|
-
沿用已有工作区约定;新资料按下列用途组织,正文维护一份,其他位置用引用连接。
|
|
7
|
+
回查或续做项目时,按用户称呼从根 `AGENTS.md` 找到项目入口,必要时按主题或交付物名称搜索。已有工作区布局与约定优先;新资料按下列用途组织,同主题正文维护一份,其他位置用引用连接:
|
|
14
8
|
|
|
15
9
|
| 路径 | 用途 |
|
|
16
10
|
| --- | --- |
|
|
17
11
|
| `AGENTS.md` | 资料导航与已确认的工作区约定 |
|
|
18
12
|
| `areas/<领域>/` | 长期目标、约束、决策与复盘 |
|
|
19
|
-
| `projects/<名称>/` |
|
|
13
|
+
| `projects/<名称>/` | 任务定义、结论、交付物与源码 |
|
|
20
14
|
| `knowledge/<主题>/` | 可跨任务复用的概念、方法与口径 |
|
|
21
|
-
| `providers
|
|
22
|
-
| `scratch/` |
|
|
15
|
+
| `providers/` | `AGENTS.md`(能力导航)与 `<id>/GUIDE.md`(使用手册) |
|
|
16
|
+
| `scratch/` | 临时脚本、中间数据、下载与运行环境 |
|
|
23
17
|
| `agents/` | `coordinator.md`、`general-purpose.md` 的职责补充 |
|
|
24
|
-
| `.agents/skills/<名称>/SKILL.md` |
|
|
25
|
-
| `.pbot/mcp.json` | 工作区共享 MCP
|
|
18
|
+
| `.agents/skills/<名称>/SKILL.md` | 工作区自有技能(跨宿主通用) |
|
|
19
|
+
| `.pbot/mcp.json` | 工作区共享 MCP 服务清单 |
|
|
26
20
|
|
|
27
21
|
保存有后续用途的结论、方法、决策和产物,普通问答不逐轮存档;更新、归集或整理资料时使用 `project-maintenance` 技能。保留用户资料、历史记录和备份。
|
|
28
22
|
|
|
29
|
-
|
|
23
|
+
## 工具与环境
|
|
24
|
+
|
|
25
|
+
优先复用工作区已接入的 CLI 与 MCP;接入或排障使用 `provider-connections` 技能,查数据口径或限制读 `providers/<id>/GUIDE.md`。资料与配置不保存明文凭据,使用环境变量引用或原生登录。计算、构建和测试遵循项目声明的环境。
|
|
30
26
|
|
|
31
|
-
|
|
27
|
+
环境上下文给出 `host`、`workspaceRoot`(资料工作区根目录)和 `resourceRoot`(包内资料根目录);资料路径相对 `workspaceRoot`,命令与文件工具按实际 cwd 解析。答复先给结论与产物路径,关键未知、前提和风险说清一次,数值注明对象、期间、单位与口径。
|
|
@@ -15,7 +15,7 @@ description: 接入或修复工作区共享 MCP 与原生 CLI/MCP,核对认证
|
|
|
15
15
|
|
|
16
16
|
接入新 MCP 前先判断归属;边界不明确或用户未说明作用域时,写入前先向用户确认放工作区共享还是当前宿主原生:
|
|
17
17
|
|
|
18
|
-
- **工作区共享 MCP(`.pbot/mcp.json`)**:归属当前工作区业务、需要跨宿主(Pi、dsh、Claude Code、Antigravity、Codex 及 ACP worker)共用,使用 stdio 或 Streamable HTTP + 环境变量/本地凭据,纯 `tools/list` + `tools/call` 请求-响应且可并发连接的服务。
|
|
18
|
+
- **工作区共享 MCP(`.pbot/mcp.json`)**:归属当前工作区业务、需要跨宿主(Pi、dsh、Claude Code、Antigravity、Codex、Qoder CLI 及 ACP worker)共用,使用 stdio 或 Streamable HTTP + 环境变量/本地凭据,纯 `tools/list` + `tools/call` 请求-响应且可并发连接的服务。
|
|
19
19
|
- **宿主原生 MCP(全局或项目级)**:满足以下任一条件时走当前宿主原生入口,不写入 `.pbot/mcp.json`:
|
|
20
20
|
1. 跨项目通用的本机全局基础设施或开发工具(如浏览器调试、全局调度);
|
|
21
21
|
2. 依赖宿主浏览器交互式 OAuth 登录;
|
|
@@ -27,14 +27,14 @@ description: 接入或修复工作区共享 MCP 与原生 CLI/MCP,核对认证
|
|
|
27
27
|
|
|
28
28
|
不保存明文凭据,使用 `${ENV_VAR}` 引用,保留无关项,不能使用保留名 `pbot`:
|
|
29
29
|
|
|
30
|
-
- **查看**:`pbot mcp list --workspace <workspaceRoot
|
|
31
|
-
- **新增 / 更新 stdio**:`pbot mcp add <name> --workspace <workspaceRoot> [--env K
|
|
32
|
-
- **新增 / 更新 HTTP**:`pbot mcp add <name> --workspace <workspaceRoot> --url https://... [--header Authorization=
|
|
33
|
-
- **删除**:`pbot mcp remove <name> --workspace <workspaceRoot
|
|
30
|
+
- **查看**:`pbot mcp list --workspace "<workspaceRoot>"`(若当前环境提供 `workspace_mcp_discover` 也可直接查询)
|
|
31
|
+
- **新增 / 更新 stdio**:`pbot mcp add <name> --workspace "<workspaceRoot>" [--env 'K=${VAR}'] [--cwd .] [--description "..."] -- <command> [args...]`
|
|
32
|
+
- **新增 / 更新 HTTP**:`pbot mcp add <name> --workspace "<workspaceRoot>" --url https://... [--header 'Authorization=Bearer ${TOKEN}'] [--description "..."]`
|
|
33
|
+
- **删除**:`pbot mcp remove <name> --workspace "<workspaceRoot>"`
|
|
34
34
|
|
|
35
35
|
生效方式(原生挂载与桥接二选一,不重复暴露):
|
|
36
36
|
- Pi 执行 `/reload`、dsh 重启会话后由宿主直接原生挂载(不暴露 `workspace_mcp_*`);
|
|
37
|
-
-
|
|
37
|
+
- 通过 `workspace_mcp_discover` / `workspace_mcp_call` 桥接的宿主即改即生效,无需重启;
|
|
38
38
|
- ACP worker 在下次新建或恢复会话时自动加载最新 `.pbot/mcp.json`。
|
|
39
39
|
|
|
40
40
|
## 宿主原生 MCP
|
|
@@ -43,6 +43,7 @@ description: 接入或修复工作区共享 MCP 与原生 CLI/MCP,核对认证
|
|
|
43
43
|
- **`host = dsh`**:通过原生界面或 profile 配置管理(注意同一 profile 可能被多工作区共用)。
|
|
44
44
|
- **`host = claude`**:`claude mcp add --scope project --transport http <server> <url>`(写入 `.mcp.json`),改完后请用户在会话中用 `/mcp` 核对认证与工具。
|
|
45
45
|
- **`host = antigravity`**:全局使用 `agy mcp add <name> <commandOrUrl> [args...]` / `agy mcp remove <name>`(管理 `~/.gemini/config/mcp_config.json`),通过 `agy mcp list` 或 UI 面板核对。
|
|
46
|
+
- **其他宿主(如 `codex`、`qoder`)**:使用该宿主自身的原生 MCP 命令或配置入口管理。
|
|
46
47
|
|
|
47
48
|
## 验证与手册
|
|
48
49
|
|
|
@@ -6,21 +6,29 @@ disable-model-invocation: true
|
|
|
6
6
|
|
|
7
7
|
# Personal Bot 工作区
|
|
8
8
|
|
|
9
|
-
从当前 Antigravity 工作区根目录,通过 `run_command` 执行对应命令。`<plugin-root>` 为本 `SKILL.md`
|
|
9
|
+
从当前 Antigravity 工作区根目录,通过 `run_command` 执行对应命令。`<plugin-root>` 为本 `SKILL.md` 路径向上两级目录(去掉尾部 `/skills/pbot/SKILL.md`)。
|
|
10
|
+
|
|
11
|
+
## 初始化与状态
|
|
10
12
|
|
|
11
13
|
```sh
|
|
12
14
|
node "<plugin-root>/lib/plugin.js" antigravity init
|
|
13
15
|
node "<plugin-root>/lib/plugin.js" antigravity status
|
|
14
16
|
```
|
|
15
17
|
|
|
16
|
-
|
|
18
|
+
`init` 补建资料目录与根 `AGENTS.md` 并启用工作区,`status` 查看工作区及配置状态;省略参数时执行 `status`。
|
|
19
|
+
|
|
20
|
+
## 历史管理与检索
|
|
21
|
+
|
|
22
|
+
`--workspace` 传入当前会话的 `workspaceRoot`(工作区未启用时使用当前工作区根目录)。支持 `history status|list|summary|migrate|search|read`,保留用户指定参数(迁移预览加 `--dry-run`):
|
|
17
23
|
|
|
18
|
-
|
|
24
|
+
```sh
|
|
25
|
+
pbot history summary --workspace "<workspaceRoot>"
|
|
26
|
+
```
|
|
19
27
|
|
|
20
|
-
|
|
28
|
+
未安装全局 `pbot` 或版本不匹配时,直接运行随插件打包的 CLI:
|
|
21
29
|
|
|
22
30
|
```sh
|
|
23
|
-
node "<plugin-root>/lib/extension/
|
|
31
|
+
node "<plugin-root>/lib/extension/cli.js" history summary --workspace "<workspaceRoot>"
|
|
24
32
|
```
|
|
25
33
|
|
|
26
|
-
|
|
34
|
+
返回命令的实际结果和需要处理的错误。
|
|
@@ -15,7 +15,7 @@ description: 接入或修复工作区共享 MCP 与原生 CLI/MCP,核对认证
|
|
|
15
15
|
|
|
16
16
|
接入新 MCP 前先判断归属;边界不明确或用户未说明作用域时,写入前先向用户确认放工作区共享还是当前宿主原生:
|
|
17
17
|
|
|
18
|
-
- **工作区共享 MCP(`.pbot/mcp.json`)**:归属当前工作区业务、需要跨宿主(Pi、dsh、Claude Code、Antigravity、Codex 及 ACP worker)共用,使用 stdio 或 Streamable HTTP + 环境变量/本地凭据,纯 `tools/list` + `tools/call` 请求-响应且可并发连接的服务。
|
|
18
|
+
- **工作区共享 MCP(`.pbot/mcp.json`)**:归属当前工作区业务、需要跨宿主(Pi、dsh、Claude Code、Antigravity、Codex、Qoder CLI 及 ACP worker)共用,使用 stdio 或 Streamable HTTP + 环境变量/本地凭据,纯 `tools/list` + `tools/call` 请求-响应且可并发连接的服务。
|
|
19
19
|
- **宿主原生 MCP(全局或项目级)**:满足以下任一条件时走当前宿主原生入口,不写入 `.pbot/mcp.json`:
|
|
20
20
|
1. 跨项目通用的本机全局基础设施或开发工具(如浏览器调试、全局调度);
|
|
21
21
|
2. 依赖宿主浏览器交互式 OAuth 登录;
|
|
@@ -27,14 +27,14 @@ description: 接入或修复工作区共享 MCP 与原生 CLI/MCP,核对认证
|
|
|
27
27
|
|
|
28
28
|
不保存明文凭据,使用 `${ENV_VAR}` 引用,保留无关项,不能使用保留名 `pbot`:
|
|
29
29
|
|
|
30
|
-
- **查看**:`pbot mcp list --workspace <workspaceRoot
|
|
31
|
-
- **新增 / 更新 stdio**:`pbot mcp add <name> --workspace <workspaceRoot> [--env K
|
|
32
|
-
- **新增 / 更新 HTTP**:`pbot mcp add <name> --workspace <workspaceRoot> --url https://... [--header Authorization=
|
|
33
|
-
- **删除**:`pbot mcp remove <name> --workspace <workspaceRoot
|
|
30
|
+
- **查看**:`pbot mcp list --workspace "<workspaceRoot>"`(若当前环境提供 `workspace_mcp_discover` 也可直接查询)
|
|
31
|
+
- **新增 / 更新 stdio**:`pbot mcp add <name> --workspace "<workspaceRoot>" [--env 'K=${VAR}'] [--cwd .] [--description "..."] -- <command> [args...]`
|
|
32
|
+
- **新增 / 更新 HTTP**:`pbot mcp add <name> --workspace "<workspaceRoot>" --url https://... [--header 'Authorization=Bearer ${TOKEN}'] [--description "..."]`
|
|
33
|
+
- **删除**:`pbot mcp remove <name> --workspace "<workspaceRoot>"`
|
|
34
34
|
|
|
35
35
|
生效方式(原生挂载与桥接二选一,不重复暴露):
|
|
36
36
|
- Pi 执行 `/reload`、dsh 重启会话后由宿主直接原生挂载(不暴露 `workspace_mcp_*`);
|
|
37
|
-
-
|
|
37
|
+
- 通过 `workspace_mcp_discover` / `workspace_mcp_call` 桥接的宿主即改即生效,无需重启;
|
|
38
38
|
- ACP worker 在下次新建或恢复会话时自动加载最新 `.pbot/mcp.json`。
|
|
39
39
|
|
|
40
40
|
## 宿主原生 MCP
|
|
@@ -43,6 +43,7 @@ description: 接入或修复工作区共享 MCP 与原生 CLI/MCP,核对认证
|
|
|
43
43
|
- **`host = dsh`**:通过原生界面或 profile 配置管理(注意同一 profile 可能被多工作区共用)。
|
|
44
44
|
- **`host = claude`**:`claude mcp add --scope project --transport http <server> <url>`(写入 `.mcp.json`),改完后请用户在会话中用 `/mcp` 核对认证与工具。
|
|
45
45
|
- **`host = antigravity`**:全局使用 `agy mcp add <name> <commandOrUrl> [args...]` / `agy mcp remove <name>`(管理 `~/.gemini/config/mcp_config.json`),通过 `agy mcp list` 或 UI 面板核对。
|
|
46
|
+
- **其他宿主(如 `codex`、`qoder`)**:使用该宿主自身的原生 MCP 命令或配置入口管理。
|
|
46
47
|
|
|
47
48
|
## 验证与手册
|
|
48
49
|
|
|
@@ -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.0 \"$@\"",
|
|
8
8
|
"pbot",
|
|
9
9
|
"mcp"
|
|
10
10
|
],
|
|
11
11
|
"env": {
|
|
12
12
|
"PBOT_HOST": "codex",
|
|
13
|
-
"PBOT_PLUGIN_VERSION": "0.
|
|
13
|
+
"PBOT_PLUGIN_VERSION": "0.4.0"
|
|
14
14
|
}
|
|
15
15
|
}
|
|
16
16
|
}
|
|
@@ -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.0 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.0 \"$@\"' pbot plugin codex 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.0 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.0 \"$@\"' pbot plugin codex 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.0 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.0 \"$@\"' pbot plugin codex hook",
|
|
31
31
|
"timeout": 120
|
|
32
32
|
}
|
|
33
33
|
]
|
|
@@ -4,6 +4,6 @@ description: 初始化 Personal Bot 工作区、查看状态、搜索归档或
|
|
|
4
4
|
disable-model-invocation: true
|
|
5
5
|
---
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
`--workspace` 传入当前会话的 `workspaceRoot`(工作区未启用时使用当前工作区根目录)。省略子命令时使用 `status`。可执行 `init`、`status`、`history status|list|summary|migrate|search|read`,保留用户指定的维度、模型和筛选参数。
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
若 `pbot --at-least 0.4.0` 返回 0,运行 `pbot <子命令> --workspace "<workspaceRoot>"`;否则运行 `npx --yes personal-bot@0.4.0 <子命令> --workspace "<workspaceRoot>"`。返回实际结果。
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AgentFiles } from "../../storage/agent-files.js";
|
|
2
|
-
import type {
|
|
2
|
+
import type { AcpAnswer, AcpInput } from "../../model/acp.js";
|
|
3
3
|
export declare function acpMember(): Promise<{
|
|
4
4
|
files: AgentFiles;
|
|
5
5
|
d: import("../../model/agent.js").AgentDescriptor;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { dirname } from "node:path";
|
|
2
2
|
import { realpathSync } from "node:fs";
|
|
3
|
-
import { AgentFiles,
|
|
4
|
-
import {
|
|
3
|
+
import { AgentFiles, status, toDescriptor } from "../../storage/agent-files.js";
|
|
4
|
+
import { acpAnswer } from "../../storage/acp-files.js";
|
|
5
5
|
import { requireThat } from "../../common/validation.js";
|
|
6
6
|
import { packageVersion, releaseLine } from "../../common/version.js";
|
|
7
7
|
import { loadWorkspaceContext } from "../../integrations/agent-resources.js";
|
|
@@ -11,15 +11,15 @@ export async function acpMember() {
|
|
|
11
11
|
requireThat(id && directory && generation, "缺少 ACP 成员启动身份。");
|
|
12
12
|
const files = new AgentFiles(dirname(realpathSync(directory)));
|
|
13
13
|
requireThat(files.directory(id) === realpathSync(directory), "ACP 成员目录不匹配。");
|
|
14
|
-
const d = files.
|
|
14
|
+
const d = toDescriptor(files.worker(id));
|
|
15
15
|
requireThat(d.agentId === id && releaseLine(d.release) === releaseLine(packageVersion), "ACP 成员身份或版本无效。");
|
|
16
16
|
const configuration = await readWorkspaceConfig(d.workspace);
|
|
17
17
|
requireThat(configuration.enabled, workspaceDisabledMessage(configuration));
|
|
18
18
|
const features = workspaceFeatures(configuration);
|
|
19
19
|
const check = () => {
|
|
20
20
|
files.check();
|
|
21
|
-
const
|
|
22
|
-
requireThat(
|
|
21
|
+
const w = files.worker(id);
|
|
22
|
+
requireThat(w.generation === generation && (!w.stop || process.env.PBOT_ACP_VALIDATE === "1"), "ACP 成员已停止或启动代次变化。");
|
|
23
23
|
};
|
|
24
24
|
const context = async () => {
|
|
25
25
|
const reference = files.reference(id);
|
|
@@ -27,16 +27,17 @@ export async function acpMember() {
|
|
|
27
27
|
const loaded = await loadWorkspaceContext({ host, root: d.workspace, role: "general-purpose" });
|
|
28
28
|
return { workspace: loaded.workspace, role: loaded.role, environment: JSON.stringify(loaded.environment) };
|
|
29
29
|
};
|
|
30
|
-
return {
|
|
30
|
+
return {
|
|
31
|
+
files, d, id, generation, configuration, features, check, context,
|
|
31
32
|
input() {
|
|
32
33
|
check();
|
|
33
|
-
const
|
|
34
|
-
requireThat(
|
|
35
|
-
return
|
|
34
|
+
const saved = files.read(id, "state.json", status);
|
|
35
|
+
requireThat(saved.generation === generation && typeof saved.activeRequestId === "string" && saved.activeRequestId.length > 0, "ACP 输入代次无效。");
|
|
36
|
+
return { generation, requestId: saved.activeRequestId };
|
|
36
37
|
},
|
|
37
38
|
answer(input, state, answer, error) {
|
|
38
39
|
// A stop can race the native terminal event. The current generation may still seal its result.
|
|
39
|
-
if (files.
|
|
40
|
+
if (files.worker(id).generation !== generation)
|
|
40
41
|
return;
|
|
41
42
|
files.write(id, "acp-answer.json", { ...input, state, answer, ...(error ? { error } : {}) }, acpAnswer);
|
|
42
43
|
},
|