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
|
@@ -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) {
|
|
@@ -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;
|
|
@@ -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
|
}
|
|
@@ -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"];
|
|
@@ -45,7 +45,7 @@ function formatSessionSummaries(summaries) {
|
|
|
45
45
|
export const monthlySummaryDimension = {
|
|
46
46
|
id: "monthly",
|
|
47
47
|
title: "月度历史汇总",
|
|
48
|
-
description: "
|
|
48
|
+
description: "按会话开始的 UTC 月份汇总会话摘要,可从月度结果查回各会话。",
|
|
49
49
|
requiresMonthlyLayout: true,
|
|
50
50
|
plan(_raws, existing, options = {}) {
|
|
51
51
|
const force = Boolean(options.force);
|
|
@@ -32,7 +32,7 @@ function isStrictUnchangedPrefix(existing, ordered) {
|
|
|
32
32
|
export const sessionSummaryDimension = {
|
|
33
33
|
id: "session",
|
|
34
34
|
title: "会话任务摘要",
|
|
35
|
-
description: "
|
|
35
|
+
description: "汇总单次会话的目标、决定、结果和未决事项。",
|
|
36
36
|
plan(raws, existing, options = {}) {
|
|
37
37
|
const force = Boolean(options.force);
|
|
38
38
|
const tasks = [];
|
|
@@ -95,9 +95,12 @@ export const sessionSummaryDimension = {
|
|
|
95
95
|
...heading,
|
|
96
96
|
`【已有摘要(${task.existing.from} — ${task.existing.to})】\n${task.existing.text}`,
|
|
97
97
|
`【新增对话】\n${formatExchanges(task.addedExchanges)}`,
|
|
98
|
-
"在已有摘要基础上合并新增对话,输出更新后的完整摘要:保留仍有效的事实,用新决定覆盖旧决定,去重并保持简洁。",
|
|
99
98
|
].join("\n\n");
|
|
100
|
-
return {
|
|
99
|
+
return {
|
|
100
|
+
system: system + "\n合并已有摘要与新增对话,输出完整摘要。保留仍有效的事实,用后续明确的决定更新相应结论。",
|
|
101
|
+
prompt,
|
|
102
|
+
maxTokens: 2048,
|
|
103
|
+
};
|
|
101
104
|
}
|
|
102
105
|
const prompt = [
|
|
103
106
|
...heading,
|
|
@@ -67,9 +67,9 @@ function evaluateSummaryReminder(raws, allSummaries, pendingCount, options = {})
|
|
|
67
67
|
return undefined;
|
|
68
68
|
const rawAgeDays = Math.floor((nowMs - oldestRawMs) / dayMs);
|
|
69
69
|
const daysSinceLastSummary = latestSummaryMs === undefined ? undefined : Math.floor((nowMs - latestSummaryMs) / dayMs);
|
|
70
|
-
const
|
|
71
|
-
|
|
72
|
-
|
|
70
|
+
const lastUpdate = daysSinceLastSummary === undefined ? "尚无摘要" : `上次更新摘要在 ${daysSinceLastSummary} 天前`;
|
|
71
|
+
const message = `工作区已积累 ${rawAgeDays} 天的历史,${lastUpdate},${pendingCount} 项待摘要。` +
|
|
72
|
+
"可在工作区根目录运行 pbot history summary,或在 Pi、dsh 会话中输入 /pbot history summary。";
|
|
73
73
|
return {
|
|
74
74
|
rawCount: raws.length,
|
|
75
75
|
pendingCount,
|
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
import type { AcpAnswer,
|
|
1
|
+
import type { AcpAnswer, AcpInput, AcpInteraction, AcpInteractionReply, AcpSessionReference } from "../model/acp.js";
|
|
2
|
+
import type { AgentAcpConfig } from "../model/agent.js";
|
|
3
|
+
export declare function acpConfig(value: unknown): AgentAcpConfig;
|
|
2
4
|
export declare function acpReference(value: unknown): AcpSessionReference;
|
|
3
|
-
export declare function acpModelState(value: unknown): AcpModelState;
|
|
4
|
-
export declare function acpProcess(value: unknown): AcpProcess;
|
|
5
5
|
export declare function acpInput(value: unknown): AcpInput;
|
|
6
6
|
export declare function acpAnswer(value: unknown): AcpAnswer;
|
|
7
|
-
export declare function
|
|
8
|
-
export declare function
|
|
9
|
-
export declare function acpPermissionReply(value: unknown): AcpPermissionReply;
|
|
10
|
-
export declare function acpElicitation(value: unknown): AcpElicitation;
|
|
11
|
-
export declare function acpElicitationReply(value: unknown): AcpElicitationReply;
|
|
7
|
+
export declare function acpInteraction(value: unknown): AcpInteraction;
|
|
8
|
+
export declare function acpInteractionReply(value: unknown): AcpInteractionReply;
|
|
@@ -4,27 +4,24 @@ import { isAcpBackend, isOneOf, requireThat } from "../common/validation.js";
|
|
|
4
4
|
import { fileId } from "./file-access.js";
|
|
5
5
|
import { acpAnswerStates, acpElicitationActions, acpPermissionPolicies, isAcpElicitationValue } from "../model/acp.js";
|
|
6
6
|
const text = (value) => typeof value === "string" && value.length > 0 && !value.includes("\0");
|
|
7
|
-
export function
|
|
8
|
-
requireThat(object(value) &&
|
|
9
|
-
text(value.command) && isAbsolute(value.command) &&
|
|
10
|
-
(value.
|
|
7
|
+
export function acpConfig(value) {
|
|
8
|
+
requireThat(object(value) && isAcpBackend(value.backend) &&
|
|
9
|
+
text(value.command) && isAbsolute(value.command) &&
|
|
10
|
+
Array.isArray(value.args) && value.args.every(arg => typeof arg === "string" && !arg.includes("\0")), "ACP 启动配置无效。");
|
|
11
11
|
if (value.env !== undefined) {
|
|
12
12
|
requireThat(object(value.env) && Object.entries(value.env).every(([k, v]) => text(k) && typeof v === "string" && !v.includes("\0")), "ACP 环境变量配置无效。");
|
|
13
13
|
}
|
|
14
14
|
requireThat(value.permission === undefined || isOneOf(value.permission, acpPermissionPolicies), "ACP 权限策略无效。");
|
|
15
|
+
return value;
|
|
16
|
+
}
|
|
17
|
+
export function acpReference(value) {
|
|
18
|
+
requireThat(object(value) && value.host === "acp" && (value.sessionId === null || text(value.sessionId)), "ACP 会话引用无效。");
|
|
19
|
+
acpConfig(value);
|
|
15
20
|
const capabilities = value.capabilities;
|
|
16
|
-
if (capabilities !== undefined)
|
|
21
|
+
if (capabilities !== undefined) {
|
|
17
22
|
requireThat(object(capabilities) &&
|
|
18
23
|
["resume", "load", "close"].every(key => typeof capabilities[key] === "boolean"), "ACP 会话能力无效。");
|
|
19
|
-
|
|
20
|
-
}
|
|
21
|
-
export function acpModelState(value) {
|
|
22
|
-
requireThat(object(value) && text(value.generation) && ["provider", "model", "resolvedModel", "thinking"].every(key => value[key] === undefined || text(value[key])), "ACP 模型选择无效。");
|
|
23
|
-
return value;
|
|
24
|
-
}
|
|
25
|
-
export function acpProcess(value) {
|
|
26
|
-
requireThat(object(value) && text(value.generation) && Number.isSafeInteger(value.pid) && Number(value.pid) > 1 &&
|
|
27
|
-
typeof value.startedAt === "number" && Number.isFinite(value.startedAt), "ACP 进程记录无效。");
|
|
24
|
+
}
|
|
28
25
|
return value;
|
|
29
26
|
}
|
|
30
27
|
export function acpInput(value) {
|
|
@@ -38,38 +35,35 @@ export function acpAnswer(value) {
|
|
|
38
35
|
(value.error === undefined || typeof value.error === "string"), "ACP 最终回答无效。");
|
|
39
36
|
return value;
|
|
40
37
|
}
|
|
41
|
-
export function
|
|
42
|
-
requireThat(object(value) && text(value.generation) && text(value.cycleId) && typeof value.text === "string", "ACP 周期报告无效。");
|
|
43
|
-
fileId(value.cycleId);
|
|
44
|
-
return value;
|
|
45
|
-
}
|
|
46
|
-
export function acpPermission(value) {
|
|
47
|
-
acpInput(value);
|
|
48
|
-
requireThat(object(value) && typeof value.description === "string" && Array.isArray(value.options) && value.options.every(option => object(option) && text(option.optionId) && text(option.name) && isOneOf(option.kind, ["allow_once", "allow_always", "reject_once", "reject_always"])), "ACP 确认请求无效。");
|
|
49
|
-
return value;
|
|
50
|
-
}
|
|
51
|
-
export function acpPermissionReply(value) {
|
|
38
|
+
export function acpInteraction(value) {
|
|
52
39
|
acpInput(value);
|
|
53
|
-
requireThat(object(value)
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
acpInput(value);
|
|
58
|
-
requireThat(object(value) && (value.mode === "form" || value.mode === "url") && typeof value.message === "string", "ACP 交互请求无效。");
|
|
59
|
-
if (value.mode === "form") {
|
|
60
|
-
requireThat(object(value.schema) && value.url === undefined, "ACP 表单交互请求缺少有效 schema。");
|
|
40
|
+
requireThat(object(value), "ACP 交互请求无效。");
|
|
41
|
+
if (value.kind === "permission") {
|
|
42
|
+
requireThat(typeof value.description === "string" && Array.isArray(value.options) && value.options.every(option => object(option) && text(option.optionId) && text(option.name) && isOneOf(option.kind, ["allow_once", "allow_always", "reject_once", "reject_always"])), "ACP 确认请求无效。");
|
|
43
|
+
return value;
|
|
61
44
|
}
|
|
62
|
-
|
|
63
|
-
requireThat(
|
|
45
|
+
if (value.kind === "form") {
|
|
46
|
+
requireThat(typeof value.message === "string" && object(value.schema), "ACP 表单交互请求缺少有效 schema。");
|
|
47
|
+
return value;
|
|
64
48
|
}
|
|
49
|
+
requireThat(value.kind === "url" && typeof value.message === "string" && text(value.url), "ACP URL 交互请求无效。");
|
|
65
50
|
return value;
|
|
66
51
|
}
|
|
67
|
-
export function
|
|
52
|
+
export function acpInteractionReply(value) {
|
|
68
53
|
acpInput(value);
|
|
69
|
-
requireThat(object(value)
|
|
70
|
-
if (value.
|
|
71
|
-
requireThat(value.
|
|
72
|
-
|
|
54
|
+
requireThat(object(value), "ACP 交互答复无效。");
|
|
55
|
+
if (value.kind === "permission") {
|
|
56
|
+
requireThat(value.optionId === null || text(value.optionId), "ACP 确认答复无效。");
|
|
57
|
+
return value;
|
|
58
|
+
}
|
|
59
|
+
if (value.kind === "form") {
|
|
60
|
+
requireThat(isOneOf(value.action, acpElicitationActions), "ACP 表单答复 action 无效。");
|
|
61
|
+
if (value.content !== undefined) {
|
|
62
|
+
requireThat(value.action === "accept" && object(value.content) &&
|
|
63
|
+
Object.values(value.content).every(isAcpElicitationValue), "ACP 表单答复 content 无效。");
|
|
64
|
+
}
|
|
65
|
+
return value;
|
|
73
66
|
}
|
|
67
|
+
requireThat(value.kind === "url" && isOneOf(value.action, acpElicitationActions), "ACP URL 交互答复无效。");
|
|
74
68
|
return value;
|
|
75
69
|
}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { AgentCycle, AgentDescriptor, AgentMessage, AgentOutput, AgentSessionReference, AgentStatus, AgentWorkerRecord } from "../model/agent.js";
|
|
2
2
|
import type { AcpSessionReference } from "../model/acp.js";
|
|
3
|
-
export declare function
|
|
4
|
-
export declare function launch(v: unknown): AgentLaunch;
|
|
3
|
+
export declare function workerRecord(v: unknown): AgentWorkerRecord;
|
|
5
4
|
export declare function message(v: unknown): AgentMessage;
|
|
6
5
|
export declare function cycle(v: unknown): AgentCycle;
|
|
7
6
|
export declare function status(v: unknown): AgentStatus;
|
|
7
|
+
export declare function outputRecord(v: unknown): AgentOutput;
|
|
8
|
+
export declare function toDescriptor(record: AgentWorkerRecord): AgentDescriptor;
|
|
8
9
|
export declare class AgentFiles {
|
|
9
10
|
#private;
|
|
10
11
|
readonly root: string;
|
|
@@ -15,14 +16,22 @@ export declare class AgentFiles {
|
|
|
15
16
|
read<T>(id: string, path: string, parse: (v: unknown) => T): T;
|
|
16
17
|
optional<T>(id: string, path: string, parse: (v: unknown) => T): T | undefined;
|
|
17
18
|
write<T>(id: string, path: string, value: T, parse: (v: unknown) => T, create?: boolean): void;
|
|
18
|
-
|
|
19
|
-
|
|
19
|
+
remove(id: string, path: string): void;
|
|
20
|
+
create(value: AgentDescriptor, run: {
|
|
21
|
+
generation: string;
|
|
22
|
+
sequence: number;
|
|
23
|
+
stop: boolean;
|
|
24
|
+
startedAt: number;
|
|
25
|
+
}, acp: AcpSessionReference): void;
|
|
26
|
+
worker(id: string): AgentWorkerRecord;
|
|
27
|
+
list(): AgentWorkerRecord[];
|
|
20
28
|
messages(id: string): AgentMessage[];
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
29
|
+
removeMessage(id: string, requestId: string): void;
|
|
30
|
+
output(id: string): AgentOutput | undefined;
|
|
31
|
+
pendingInteractions(id: string, generation: string): import("../model/acp.js").AcpInteraction[];
|
|
32
|
+
removeInteraction(id: string, requestId: string): void;
|
|
33
|
+
clearTransient(id: string): void;
|
|
34
|
+
removeWorker(id: string): void;
|
|
26
35
|
ensureSubdirectory(id: string, name: string): void;
|
|
27
36
|
reference(id: string): AgentSessionReference;
|
|
28
37
|
/** Short controller edits are serialized; an abandoned lock fails closed. */
|