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
|
@@ -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任务匹配时按需读取对应 `SKILL.md` 正文:\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
|
-
? "## 启动提示\n\n" + notices.map(item => `- ${item}`).join("\n")
|
|
48
|
+
? "## 启动提示\n\n以下为工作区维护提醒,适时顺带告知用户即可,勿未经用户要求自行执行:\n" + notices.map(item => `- ${item}`).join("\n")
|
|
49
49
|
: "";
|
|
50
50
|
const environment = { host, workspaceRoot: root, resourceRoot };
|
|
51
51
|
const text = [
|
|
@@ -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"];
|
|
@@ -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. */
|