personal-bot 0.3.7 → 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/architecture/design.md +2 -2
- package/docs/architecture/extensibility.md +1 -1
- 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 +346 -201
- package/lib/antigravity-plugin/lib/extension/cli.js +563 -538
- 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 +397 -278
- 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/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 +1 -1
- 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 +346 -201
- package/lib/extension/cli.js +563 -538
- 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 +0 -8
- package/lib/extension/mcp/workers.d.ts +7 -27
- package/lib/extension/mcp/workers.js +35 -17
- package/lib/extension/mcp.js +397 -278
- 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/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 +1 -1
- 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/package.json +1 -1
- 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 +0 -8
- package/src/extension/mcp/workers.ts +34 -17
- package/src/integrations/acp/agents.ts +28 -27
- package/src/integrations/acp/harnesses/claude.ts +1 -1
- 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 +1 -1
- 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/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
|
@@ -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
|
]
|
|
@@ -6,4 +6,4 @@ disable-model-invocation: true
|
|
|
6
6
|
|
|
7
7
|
`--workspace` 传入当前会话的 `workspaceRoot`(工作区未启用时使用当前工作区根目录)。省略子命令时使用 `status`。可执行 `init`、`status`、`history status|list|summary|migrate|search|read`,保留用户指定的维度、模型和筛选参数。
|
|
8
8
|
|
|
9
|
-
若 `pbot --at-least 0.
|
|
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
|
},
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { randomUUID } from "node:crypto";
|
|
2
2
|
import { dirname, join, resolve } from "node:path";
|
|
3
|
-
import { AgentFiles,
|
|
4
|
-
import {
|
|
3
|
+
import { AgentFiles, status, toDescriptor } from "../../storage/agent-files.js";
|
|
4
|
+
import { acpReference } from "../../storage/acp-files.js";
|
|
5
5
|
import { AcpAgentRun } from "../../services/agents/acp-run.js";
|
|
6
|
+
import { AgentRun } from "../../services/agents/agent-run.js";
|
|
6
7
|
import { openAcp } from "../../integrations/acp/connection.js";
|
|
7
8
|
import { acpExecutable } from "../../integrations/acp/executable.js";
|
|
8
9
|
import { acpContent } from "../../integrations/acp/input.js";
|
|
@@ -93,16 +94,17 @@ async function runWorker(args) {
|
|
|
93
94
|
requireThat(directory && id && generation, "缺少 ACP worker 启动信息。");
|
|
94
95
|
const files = new AgentFiles(dirname(directory));
|
|
95
96
|
requireThat(files.directory(id) === directory, "ACP worker 目录不匹配。");
|
|
96
|
-
const d = files.
|
|
97
|
+
const d = toDescriptor(files.worker(id)), reference = files.reference(id);
|
|
97
98
|
requireThat(d.agentId === id && releaseLine(d.release) === releaseLine(packageVersion), "ACP worker 身份或版本不匹配。");
|
|
98
99
|
const validating = args.includes("--validate"), lifetime = new AbortController();
|
|
100
|
+
const agentRun = validating ? undefined : new AgentRun(files, id, generation);
|
|
99
101
|
let execution;
|
|
100
102
|
const stop = () => { void execution?.stop().catch(error => lifetime.abort(error)); if (!execution)
|
|
101
103
|
lifetime.abort(); };
|
|
102
104
|
process.on("SIGTERM", stop);
|
|
103
105
|
process.on("SIGINT", stop);
|
|
104
106
|
async function main() {
|
|
105
|
-
requireThat(files.
|
|
107
|
+
requireThat(files.worker(id).generation === generation, "ACP worker 启动代次已失效。");
|
|
106
108
|
const harness = resolveAcpHarness(reference.backend);
|
|
107
109
|
const exactAnswer = Boolean(harness.exactAnswer);
|
|
108
110
|
const packageRoot = resolve(resourceRoot, "..");
|
|
@@ -116,7 +118,7 @@ async function runWorker(args) {
|
|
|
116
118
|
...(validating ? { PBOT_ACP_VALIDATE: "1" } : {}),
|
|
117
119
|
};
|
|
118
120
|
const prepared = harness.prepareLaunch
|
|
119
|
-
? await harness.prepareLaunch({ reference,
|
|
121
|
+
? await harness.prepareLaunch({ reference, workspace: d.workspace, directory: directory, packageRoot, options: d.options, env: baseEnv, features })
|
|
120
122
|
: { command: { ...reference, args: [...reference.args] }, env: { ...baseEnv, ...(reference.env ?? {}) } };
|
|
121
123
|
let prompt;
|
|
122
124
|
if (!exactAnswer) {
|
|
@@ -142,16 +144,16 @@ async function runWorker(args) {
|
|
|
142
144
|
mcpServers = toAcpMcpServers(resolved);
|
|
143
145
|
}
|
|
144
146
|
}
|
|
145
|
-
// Only publish
|
|
147
|
+
// Only publish selection after requested model/thinking options are applied so callers can detect startup readiness.
|
|
146
148
|
let configured = false;
|
|
147
149
|
const saveSelection = (selection) => {
|
|
148
|
-
if (validating || !configured)
|
|
150
|
+
if (validating || !configured || !agentRun)
|
|
149
151
|
return;
|
|
150
|
-
const
|
|
151
|
-
if (
|
|
152
|
-
|
|
152
|
+
const w = files.worker(id);
|
|
153
|
+
if (w.generation === generation && !w.stop)
|
|
154
|
+
agentRun.setSelection(selection);
|
|
153
155
|
};
|
|
154
|
-
const connection = await openAcp(prepared.command, d.
|
|
156
|
+
const connection = await openAcp(prepared.command, d.workspace, prepared.env, {
|
|
155
157
|
selection: saveSelection,
|
|
156
158
|
update(update) {
|
|
157
159
|
if (update.sessionUpdate === "agent_message_chunk" && update.content.type === "text") {
|
|
@@ -210,12 +212,10 @@ async function runWorker(args) {
|
|
|
210
212
|
}
|
|
211
213
|
if (reference.sessionId === null)
|
|
212
214
|
await connection.configure(d.options);
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
capabilities: connection.capabilities,
|
|
218
|
-
}, acpReference);
|
|
215
|
+
const currentWorker = files.worker(id);
|
|
216
|
+
requireThat(currentWorker.generation === generation && !currentWorker.stop, "ACP 启动已取消。");
|
|
217
|
+
let sessionId = harness.eagerSessionId || reference.sessionId !== null ? connection.sessionId : null;
|
|
218
|
+
agentRun.setSession(sessionId, connection.capabilities);
|
|
219
219
|
configured = true;
|
|
220
220
|
saveSelection(connection.selection());
|
|
221
221
|
let promptInjected = reference.sessionId !== null || connection.systemPrompt;
|
|
@@ -227,16 +227,17 @@ async function runWorker(args) {
|
|
|
227
227
|
: request;
|
|
228
228
|
promptInjected = true;
|
|
229
229
|
const content = await acpContent(effective, connection.images, connection.signal);
|
|
230
|
-
const
|
|
231
|
-
requireThat(
|
|
230
|
+
const w = files.worker(id);
|
|
231
|
+
requireThat(w.generation === generation && !w.stop, "ACP 输入已取消或启动代次变化。");
|
|
232
232
|
connection.signal.throwIfAborted();
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
233
|
+
if (sessionId === null) {
|
|
234
|
+
sessionId = connection.sessionId;
|
|
235
|
+
agentRun.setSession(sessionId, connection.capabilities);
|
|
236
|
+
}
|
|
236
237
|
return connection.prompt(content);
|
|
237
238
|
},
|
|
238
239
|
cancel: () => connection.cancel(),
|
|
239
|
-
}, exactAnswer);
|
|
240
|
+
}, exactAnswer, agentRun);
|
|
240
241
|
await execution.run();
|
|
241
242
|
}
|
|
242
243
|
finally {
|
|
@@ -250,24 +251,24 @@ async function runWorker(args) {
|
|
|
250
251
|
}
|
|
251
252
|
try {
|
|
252
253
|
await main();
|
|
253
|
-
if (!validating && files.
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
else
|
|
257
|
-
files.write(id, "status.json", { generation, state: "stopped", activity: "已停止", updatedAt: Date.now() }, status);
|
|
254
|
+
if (!validating && files.worker(id).generation === generation) {
|
|
255
|
+
agentRun.save({ state: "stopped", activity: "已停止" });
|
|
256
|
+
files.clearTransient(id);
|
|
258
257
|
}
|
|
259
258
|
}
|
|
260
259
|
catch (error) {
|
|
261
260
|
if (validating) {
|
|
262
261
|
await sendIpc({ type: "error", error: errorMessage(error) });
|
|
263
262
|
}
|
|
264
|
-
else if (files.
|
|
265
|
-
const stopped = files.
|
|
263
|
+
else if (files.worker(id).generation === generation) {
|
|
264
|
+
const stopped = files.worker(id).stop;
|
|
266
265
|
const patch = { state: stopped ? "stopped" : "error", activity: stopped ? "已停止" : "ACP 执行失败", ...(stopped ? {} : { error: errorMessage(error) }) };
|
|
267
|
-
if (
|
|
268
|
-
|
|
266
|
+
if (agentRun)
|
|
267
|
+
agentRun.save(patch);
|
|
269
268
|
else
|
|
270
|
-
files.write(id, "
|
|
269
|
+
files.write(id, "state.json", { generation, ...patch, updatedAt: Date.now() }, status);
|
|
270
|
+
if (stopped)
|
|
271
|
+
files.clearTransient(id);
|
|
271
272
|
}
|
|
272
273
|
process.exitCode = 1;
|
|
273
274
|
}
|