personal-bot 0.2.11 → 0.2.12
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/README.md +17 -3
- package/README.zh-CN.md +17 -3
- package/bin/pbot-pi-acp.mjs +20 -0
- package/docs/agent-collaboration.md +38 -2
- package/docs/capability-design.md +6 -0
- package/docs/dsh.md +9 -8
- package/docs/file-storage.md +9 -1
- package/docs/interaction-design.md +2 -2
- package/docs/model-context.md +10 -2
- package/docs/technical-design.md +20 -2
- package/docs/workspace-configuration.md +20 -1
- package/lib/client.js +40 -7
- package/lib/dsh.js +2 -0
- package/lib/extension/acp-member.d.ts +16 -0
- package/lib/extension/acp-member.js +45 -0
- package/lib/extension/acp-worker.d.ts +1 -0
- package/lib/extension/acp-worker.js +156 -0
- package/lib/extension/dsh/acp-member.d.ts +4 -0
- package/lib/extension/dsh/acp-member.js +48 -0
- package/lib/extension/dsh/command.js +11 -1
- package/lib/extension/dsh/management.js +3 -1
- package/lib/extension/dsh/workspace.d.ts +35 -1
- package/lib/extension/dsh/workspace.js +21 -3
- package/lib/integrations/acp/agents.d.ts +24 -0
- package/lib/integrations/acp/agents.js +168 -0
- package/lib/integrations/acp/claude.d.ts +18 -0
- package/lib/integrations/acp/claude.js +33 -0
- package/lib/integrations/acp/connection.d.ts +27 -0
- package/lib/integrations/acp/connection.js +167 -0
- package/lib/integrations/acp/input.d.ts +4 -0
- package/lib/integrations/acp/input.js +45 -0
- package/lib/integrations/acp/launch.d.ts +4 -0
- package/lib/integrations/acp/launch.js +52 -0
- package/lib/integrations/acp/model-selection.d.ts +12 -0
- package/lib/integrations/acp/model-selection.js +65 -0
- package/lib/integrations/dsh/dsh-agents.d.ts +2 -1
- package/lib/integrations/dsh/dsh-agents.js +4 -0
- package/lib/model/acp.d.ts +59 -0
- package/lib/model/acp.js +1 -0
- package/lib/model/agent.d.ts +15 -1
- package/lib/model/workspace-config.d.ts +3 -0
- package/lib/services/agents/acp-run.d.ts +42 -0
- package/lib/services/agents/acp-run.js +149 -0
- package/lib/services/agents/agent-service.d.ts +114 -6
- package/lib/services/agents/agent-service.js +81 -10
- package/lib/services/agents/team-service.js +4 -2
- package/lib/services/workspace/workspace-config.js +12 -1
- package/lib/storage/acp-files.d.ts +9 -0
- package/lib/storage/acp-files.js +50 -0
- package/lib/storage/agent-files.d.ts +5 -4
- package/lib/storage/agent-files.js +11 -2
- package/lib/tools/agents/actions.d.ts +16 -2
- package/lib/tools/agents/actions.js +3 -1
- package/lib/tools/agents/contract.d.ts +48 -3
- package/lib/tools/agents/contract.js +15 -9
- package/lib/tools/agents/dsh-contract.d.ts +8 -15
- package/lib/tools/agents/dsh-contract.js +12 -8
- package/lib/ui/dsh/management.js +36 -8
- package/npm-shrinkwrap.json +953 -12
- package/package.json +8 -1
- package/resources/skills/.claude-plugin/plugin.json +4 -0
- package/scripts/README.md +6 -0
- package/src/dsh.ts +1 -0
- package/src/extension/acp-member.ts +44 -0
- package/src/extension/acp-worker.ts +124 -0
- package/src/extension/agent-events.ts +28 -3
- package/src/extension/agents-command.ts +33 -5
- package/src/extension/dsh/acp-member.ts +44 -0
- package/src/extension/dsh/command.ts +10 -1
- package/src/extension/dsh/management.ts +2 -1
- package/src/extension/dsh/workspace.ts +21 -3
- package/src/extension/lifecycle.ts +2 -2
- package/src/extension/pi-acp-member.ts +64 -0
- package/src/integrations/acp/agents.ts +118 -0
- package/src/integrations/acp/claude.ts +40 -0
- package/src/integrations/acp/connection.ts +152 -0
- package/src/integrations/acp/input.ts +39 -0
- package/src/integrations/acp/launch.ts +50 -0
- package/src/integrations/acp/model-selection.ts +66 -0
- package/src/integrations/dsh/dsh-agents.ts +4 -1
- package/src/integrations/pi/pi-agents.ts +4 -1
- package/src/model/acp.ts +26 -0
- package/src/model/agent.ts +7 -1
- package/src/model/workspace-config.ts +4 -0
- package/src/pbot.ts +3 -2
- package/src/services/agents/acp-run.ts +123 -0
- package/src/services/agents/agent-service.ts +85 -12
- package/src/services/agents/team-service.ts +3 -2
- package/src/services/workspace/workspace-config.ts +10 -1
- package/src/storage/acp-files.ts +50 -0
- package/src/storage/agent-files.ts +12 -4
- package/src/tools/agents/actions.ts +4 -2
- package/src/tools/agents/contract.ts +16 -9
- package/src/tools/agents/dsh-contract.ts +12 -8
- package/src/ui/dsh/management.ts +31 -8
|
@@ -5,6 +5,7 @@ import { canonical, object } from "../common/json.js";
|
|
|
5
5
|
import { 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 { acpReference } from "./acp-files.js";
|
|
8
9
|
const text = (v) => typeof v === "string" && v.length > 0;
|
|
9
10
|
const number = (v) => typeof v === "number" && Number.isFinite(v);
|
|
10
11
|
export function descriptor(v) {
|
|
@@ -81,7 +82,7 @@ export class AgentFiles {
|
|
|
81
82
|
}
|
|
82
83
|
requireThat(published, "子会话文件已存在。");
|
|
83
84
|
}
|
|
84
|
-
create(value, run) {
|
|
85
|
+
create(value, run, acp) {
|
|
85
86
|
this.check();
|
|
86
87
|
mkdirSync(this.root, { recursive: true, mode: 0o700 });
|
|
87
88
|
mkdirSync(this.directory(value.agentId), { mode: 0o700 });
|
|
@@ -89,7 +90,12 @@ export class AgentFiles {
|
|
|
89
90
|
privateDirectory(this.directory(value.agentId), dir);
|
|
90
91
|
this.write(value.agentId, "descriptor.json", value, descriptor, true);
|
|
91
92
|
this.write(value.agentId, "launch.json", run, launch, true);
|
|
92
|
-
if (
|
|
93
|
+
if (acp) {
|
|
94
|
+
for (const dir of ["reports", "permissions"])
|
|
95
|
+
privateDirectory(this.directory(value.agentId), dir);
|
|
96
|
+
this.write(value.agentId, "acp-session.json", acp, acpReference, true);
|
|
97
|
+
}
|
|
98
|
+
else if (this.host === "pi")
|
|
93
99
|
this.write(value.agentId, "session-ref.json", { file: null }, sessionRef, true);
|
|
94
100
|
else
|
|
95
101
|
this.write(value.agentId, "native-session.json", { host: "dsh", sessionId: value.agentId }, dshSessionRef, true);
|
|
@@ -111,6 +117,9 @@ export class AgentFiles {
|
|
|
111
117
|
.map(n => this.read(id, "completions/" + n, cycle)).sort((a, b) => (a.finishedAt ?? 0) - (b.finishedAt ?? 0));
|
|
112
118
|
}
|
|
113
119
|
reference(id) {
|
|
120
|
+
const acp = this.optional(id, "acp-session.json", acpReference);
|
|
121
|
+
if (acp)
|
|
122
|
+
return acp;
|
|
114
123
|
if (this.host === "pi")
|
|
115
124
|
return { host: "pi", file: this.session(id) };
|
|
116
125
|
const ref = this.read(id, "native-session.json", dshSessionRef);
|
|
@@ -16,18 +16,32 @@ export declare function executeAgent(service: AgentService, input: AgentInput, o
|
|
|
16
16
|
} | {
|
|
17
17
|
details: {
|
|
18
18
|
agentReadKeys?: string[];
|
|
19
|
+
backend?: "pi" | "dsh" | "claude";
|
|
19
20
|
error?: string;
|
|
21
|
+
capabilities?: {
|
|
22
|
+
steer: boolean;
|
|
23
|
+
resume: boolean;
|
|
24
|
+
team: boolean;
|
|
25
|
+
transcript: boolean;
|
|
26
|
+
};
|
|
20
27
|
requestId?: string;
|
|
21
28
|
cycle?: {
|
|
22
29
|
error?: string;
|
|
23
30
|
finishedAt?: number;
|
|
24
|
-
state: "
|
|
31
|
+
state: "completed" | "failed" | "cancelled" | "running" | "interrupted";
|
|
25
32
|
startedAt: number;
|
|
26
33
|
cycleId: string;
|
|
27
34
|
requestIds: string[];
|
|
28
35
|
source: "parent" | "interactive" | "mixed";
|
|
29
36
|
};
|
|
37
|
+
selection?: {
|
|
38
|
+
provider?: string;
|
|
39
|
+
model?: string;
|
|
40
|
+
resolvedModel?: string;
|
|
41
|
+
thinking?: string;
|
|
42
|
+
};
|
|
30
43
|
report?: string;
|
|
44
|
+
transport?: "acp" | "native";
|
|
31
45
|
messageStatus?: "queued";
|
|
32
46
|
cycles?: {
|
|
33
47
|
state: string;
|
|
@@ -36,10 +50,10 @@ export declare function executeAgent(service: AgentService, input: AgentInput, o
|
|
|
36
50
|
totalLength?: number;
|
|
37
51
|
nextOffset?: number | null;
|
|
38
52
|
state: "starting" | "busy" | "idle" | "stopping" | "stopped" | "error";
|
|
53
|
+
name: string;
|
|
39
54
|
agentId: string;
|
|
40
55
|
cwd: string;
|
|
41
56
|
createdAt: number;
|
|
42
|
-
name: string;
|
|
43
57
|
activity: string;
|
|
44
58
|
owned: boolean;
|
|
45
59
|
};
|
|
@@ -4,6 +4,8 @@ function agentOutput(view) {
|
|
|
4
4
|
return {
|
|
5
5
|
agentId: view.agentId, name: view.name, cwd: view.cwd, createdAt: view.createdAt,
|
|
6
6
|
owned: view.owned, state: view.state, activity: view.activity,
|
|
7
|
+
...(view.backend ? { backend: view.backend, transport: view.transport, capabilities: view.capabilities } : {}),
|
|
8
|
+
...(view.selection ? { selection: view.selection } : {}),
|
|
7
9
|
...(c ? { cycle: { cycleId: c.cycleId, startedAt: c.startedAt, state: c.state, requestIds: c.requestIds, source: c.source,
|
|
8
10
|
...(c.finishedAt === undefined ? {} : { finishedAt: c.finishedAt }), ...(c.error === undefined ? {} : { error: c.error }) } } : {}),
|
|
9
11
|
...(view.error === undefined ? {} : { error: view.error }),
|
|
@@ -20,7 +22,7 @@ export async function executeAgent(service, input, owner, defaults = {}) {
|
|
|
20
22
|
switch (input.action) {
|
|
21
23
|
case "start": {
|
|
22
24
|
const { action: _action, ...supplied } = input;
|
|
23
|
-
value = await service.start({ ...defaults, ...supplied }, owner);
|
|
25
|
+
value = await service.start({ ...(supplied.backend ? {} : defaults), ...supplied }, owner);
|
|
24
26
|
break;
|
|
25
27
|
}
|
|
26
28
|
case "list": return markdownResult({ agents: service.list(owner).map(agentOutput) }, "子会话列表");
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { Type } from "typebox";
|
|
2
2
|
export declare const agentDescription = "\u59D4\u6D3E\u4E13\u5BB6\u5E76\u7EE7\u7EED\u5BF9\u8BDD\u3002start \u542F\u52A8\u540E\u5373\u8FD4\u56DE\uFF0C\u5B8C\u6210\u81EA\u52A8\u901A\u77E5\uFF0C\u65E0\u9700\u8F6E\u8BE2\uFF1B\u7701\u7565\u521D\u59CB\u8F93\u5165\u65F6\u5F85\u547D\u3002send \u7EE7\u7EED\u5BF9\u8BDD\uFF0C\u56E2\u961F\u5360\u7528\u671F\u95F4\u4E0D\u53EF\u79C1\u4EBA send\u3002status \u67E5\u770B\u72B6\u6001\uFF0Cread \u8BFB\u53D6\u62A5\u544A\uFF1B\u8BFB\u53D6\u5DF2\u7ED3\u675F\u5468\u671F\u5373\u9886\u53D6\u5176\u901A\u77E5\uFF0C\u5305\u62EC\u90E8\u5206\u8BFB\u53D6\u3002\u7EED\u8BFB\u56FA\u5B9A cycle.cycleId \u5E76\u4F7F\u7528 nextOffset\u3002state \u8868\u793A\u6267\u884C\u72B6\u6001\uFF0Ccycle.state \u8868\u793A\u5DE5\u4F5C\u7ED3\u679C\uFF0Cqueued \u53EA\u8868\u793A\u5165\u961F\u3002stop \u4FDD\u7559\u5386\u53F2\uFF0Cresume \u643A\u65B0 message \u7EE7\u7EED\u3002\u6BCF\u4E2A\u7236\u4F1A\u8BDD\u6700\u591A 50 \u4E2A\u5B58\u6D3B\u4E13\u5BB6\uFF0C\u7A7A\u95F2\u4E5F\u8BA1\u5165\u3002";
|
|
3
3
|
export declare const agentStartOptions: {
|
|
4
|
+
backend: Type.TOptional<Type.TUnion<[Type.TLiteral<"pi">, Type.TLiteral<"dsh">, Type.TLiteral<"claude">]>>;
|
|
4
5
|
name: Type.TOptional<Type.TString>;
|
|
5
6
|
message: Type.TOptional<Type.TString>;
|
|
6
7
|
files: Type.TOptional<Type.TArray<Type.TString>>;
|
|
7
8
|
prompts: Type.TOptional<Type.TArray<Type.TString>>;
|
|
8
9
|
provider: Type.TOptional<Type.TString>;
|
|
9
10
|
model: Type.TOptional<Type.TString>;
|
|
10
|
-
thinking: Type.TOptional<Type.
|
|
11
|
+
thinking: Type.TOptional<Type.TString>;
|
|
11
12
|
cwd: Type.TOptional<Type.TString>;
|
|
12
13
|
tools: Type.TOptional<Type.TArray<Type.TString>>;
|
|
13
14
|
noExtensions: Type.TOptional<Type.TBoolean>;
|
|
@@ -20,13 +21,14 @@ export declare const agentParametersSchema: Type.TObject<{
|
|
|
20
21
|
cycleId: Type.TOptional<Type.TString>;
|
|
21
22
|
offset: Type.TOptional<Type.TInteger>;
|
|
22
23
|
limit: Type.TOptional<Type.TInteger>;
|
|
24
|
+
backend: Type.TOptional<Type.TUnion<[Type.TLiteral<"pi">, Type.TLiteral<"dsh">, Type.TLiteral<"claude">]>>;
|
|
23
25
|
name: Type.TOptional<Type.TString>;
|
|
24
26
|
message: Type.TOptional<Type.TString>;
|
|
25
27
|
files: Type.TOptional<Type.TArray<Type.TString>>;
|
|
26
28
|
prompts: Type.TOptional<Type.TArray<Type.TString>>;
|
|
27
29
|
provider: Type.TOptional<Type.TString>;
|
|
28
30
|
model: Type.TOptional<Type.TString>;
|
|
29
|
-
thinking: Type.TOptional<Type.
|
|
31
|
+
thinking: Type.TOptional<Type.TString>;
|
|
30
32
|
cwd: Type.TOptional<Type.TString>;
|
|
31
33
|
tools: Type.TOptional<Type.TArray<Type.TString>>;
|
|
32
34
|
noExtensions: Type.TOptional<Type.TBoolean>;
|
|
@@ -37,13 +39,14 @@ export declare const agentParametersSchema: Type.TObject<{
|
|
|
37
39
|
agentId: Type.TOptional<Type.TString>;
|
|
38
40
|
}>;
|
|
39
41
|
export declare const agentActionSchema: Type.TUnion<[Type.TObject<{
|
|
42
|
+
backend: Type.TOptional<Type.TUnion<[Type.TLiteral<"pi">, Type.TLiteral<"dsh">, Type.TLiteral<"claude">]>>;
|
|
40
43
|
name: Type.TOptional<Type.TString>;
|
|
41
44
|
message: Type.TOptional<Type.TString>;
|
|
42
45
|
files: Type.TOptional<Type.TArray<Type.TString>>;
|
|
43
46
|
prompts: Type.TOptional<Type.TArray<Type.TString>>;
|
|
44
47
|
provider: Type.TOptional<Type.TString>;
|
|
45
48
|
model: Type.TOptional<Type.TString>;
|
|
46
|
-
thinking: Type.TOptional<Type.
|
|
49
|
+
thinking: Type.TOptional<Type.TString>;
|
|
47
50
|
cwd: Type.TOptional<Type.TString>;
|
|
48
51
|
tools: Type.TOptional<Type.TArray<Type.TString>>;
|
|
49
52
|
noExtensions: Type.TOptional<Type.TBoolean>;
|
|
@@ -81,6 +84,20 @@ export declare const agentViewSchema: Type.TObject<{
|
|
|
81
84
|
name: Type.TString;
|
|
82
85
|
cwd: Type.TString;
|
|
83
86
|
createdAt: Type.TNumber;
|
|
87
|
+
backend: Type.TOptional<Type.TUnion<[Type.TLiteral<"pi">, Type.TLiteral<"dsh">, Type.TLiteral<"claude">]>>;
|
|
88
|
+
transport: Type.TOptional<Type.TUnion<[Type.TLiteral<"native">, Type.TLiteral<"acp">]>>;
|
|
89
|
+
selection: Type.TOptional<Type.TObject<{
|
|
90
|
+
provider: Type.TOptional<Type.TString>;
|
|
91
|
+
model: Type.TOptional<Type.TString>;
|
|
92
|
+
resolvedModel: Type.TOptional<Type.TString>;
|
|
93
|
+
thinking: Type.TOptional<Type.TString>;
|
|
94
|
+
}>>;
|
|
95
|
+
capabilities: Type.TOptional<Type.TObject<{
|
|
96
|
+
steer: Type.TBoolean;
|
|
97
|
+
resume: Type.TBoolean;
|
|
98
|
+
team: Type.TBoolean;
|
|
99
|
+
transcript: Type.TBoolean;
|
|
100
|
+
}>>;
|
|
84
101
|
owned: Type.TBoolean;
|
|
85
102
|
state: Type.TUnion<[Type.TLiteral<"starting">, Type.TLiteral<"busy">, Type.TLiteral<"idle">, Type.TLiteral<"stopping">, Type.TLiteral<"stopped">, Type.TLiteral<"error">]>;
|
|
86
103
|
activity: Type.TString;
|
|
@@ -109,6 +126,20 @@ export declare const agentResultSchema: Type.TUnion<[Type.TObject<{
|
|
|
109
126
|
name: Type.TString;
|
|
110
127
|
cwd: Type.TString;
|
|
111
128
|
createdAt: Type.TNumber;
|
|
129
|
+
backend: Type.TOptional<Type.TUnion<[Type.TLiteral<"pi">, Type.TLiteral<"dsh">, Type.TLiteral<"claude">]>>;
|
|
130
|
+
transport: Type.TOptional<Type.TUnion<[Type.TLiteral<"native">, Type.TLiteral<"acp">]>>;
|
|
131
|
+
selection: Type.TOptional<Type.TObject<{
|
|
132
|
+
provider: Type.TOptional<Type.TString>;
|
|
133
|
+
model: Type.TOptional<Type.TString>;
|
|
134
|
+
resolvedModel: Type.TOptional<Type.TString>;
|
|
135
|
+
thinking: Type.TOptional<Type.TString>;
|
|
136
|
+
}>>;
|
|
137
|
+
capabilities: Type.TOptional<Type.TObject<{
|
|
138
|
+
steer: Type.TBoolean;
|
|
139
|
+
resume: Type.TBoolean;
|
|
140
|
+
team: Type.TBoolean;
|
|
141
|
+
transcript: Type.TBoolean;
|
|
142
|
+
}>>;
|
|
112
143
|
owned: Type.TBoolean;
|
|
113
144
|
state: Type.TUnion<[Type.TLiteral<"starting">, Type.TLiteral<"busy">, Type.TLiteral<"idle">, Type.TLiteral<"stopping">, Type.TLiteral<"stopped">, Type.TLiteral<"error">]>;
|
|
114
145
|
activity: Type.TString;
|
|
@@ -137,6 +168,20 @@ export declare const agentResultSchema: Type.TUnion<[Type.TObject<{
|
|
|
137
168
|
name: Type.TString;
|
|
138
169
|
cwd: Type.TString;
|
|
139
170
|
createdAt: Type.TNumber;
|
|
171
|
+
backend: Type.TOptional<Type.TUnion<[Type.TLiteral<"pi">, Type.TLiteral<"dsh">, Type.TLiteral<"claude">]>>;
|
|
172
|
+
transport: Type.TOptional<Type.TUnion<[Type.TLiteral<"native">, Type.TLiteral<"acp">]>>;
|
|
173
|
+
selection: Type.TOptional<Type.TObject<{
|
|
174
|
+
provider: Type.TOptional<Type.TString>;
|
|
175
|
+
model: Type.TOptional<Type.TString>;
|
|
176
|
+
resolvedModel: Type.TOptional<Type.TString>;
|
|
177
|
+
thinking: Type.TOptional<Type.TString>;
|
|
178
|
+
}>>;
|
|
179
|
+
capabilities: Type.TOptional<Type.TObject<{
|
|
180
|
+
steer: Type.TBoolean;
|
|
181
|
+
resume: Type.TBoolean;
|
|
182
|
+
team: Type.TBoolean;
|
|
183
|
+
transcript: Type.TBoolean;
|
|
184
|
+
}>>;
|
|
140
185
|
owned: Type.TBoolean;
|
|
141
186
|
state: Type.TUnion<[Type.TLiteral<"starting">, Type.TLiteral<"busy">, Type.TLiteral<"idle">, Type.TLiteral<"stopping">, Type.TLiteral<"stopped">, Type.TLiteral<"error">]>;
|
|
142
187
|
activity: Type.TString;
|
|
@@ -4,25 +4,26 @@ const id = Type.String({ minLength: 1, maxLength: 128 });
|
|
|
4
4
|
const message = Type.String({ minLength: 1, maxLength: 24000, description: "本次目标、相关资料、约束和交付要求。" });
|
|
5
5
|
const name = Type.String({ minLength: 1, maxLength: 64, pattern: "^[^\\r\\n\\x00-\\x1f]+$" });
|
|
6
6
|
export const agentStartOptions = {
|
|
7
|
+
backend: Type.Optional(Type.Union([Type.Literal("pi"), Type.Literal("dsh"), Type.Literal("claude")], { description: "选择已安装并配置的子代理程序:pi、dsh 或 claude(Claude Code)。省略时使用当前宿主的原生专家;显式选择时使用目标程序自己的配置。团队成员须省略 backend。" })),
|
|
7
8
|
name: Type.Optional(name), message: Type.Optional(message),
|
|
8
9
|
files: Type.Optional(Type.Array(Type.String({ minLength: 1 }), { maxItems: 32, description: "随初始消息读取的文件;相对路径基于原工作区根目录。" })),
|
|
9
10
|
prompts: Type.Optional(Type.Array(message, { maxItems: 32, description: "与 message 按顺序合并为同一初始消息。" })),
|
|
10
|
-
provider: Type.Optional(Type.String({ ...id, description: "
|
|
11
|
-
model: Type.Optional(Type.String({ ...id, description: "Pi
|
|
12
|
-
thinking: Type.Optional(Type.
|
|
11
|
+
provider: Type.Optional(Type.String({ ...id, description: "模型提供方。省略 backend 时默认继承主会话;指定 backend 时,此参数须与 model 一起提供。Claude 子代理省略此参数。" })),
|
|
12
|
+
model: Type.Optional(Type.String({ ...id, description: "模型 ID;指定 backend 时也可使用目标公开的完整模型值。默认值:省略 backend 时继承主会话,指定时使用目标配置。Pi/dsh 同名模型可用 provider 区分。" })),
|
|
13
|
+
thinking: Type.Optional(Type.String({ minLength: 1, maxLength: 128, description: "思考等级 ID,可单独指定。默认值:省略 backend 时继承主会话,指定时使用目标配置。Pi 使用 off/minimal/low/medium/high/xhigh/max,其他程序使用其原生等级 ID。" })),
|
|
13
14
|
cwd: Type.Optional(Type.String({ minLength: 1, description: "执行目录,相对原工作区根目录;省略时使用工作区根目录。" })),
|
|
14
|
-
tools: Type.Optional(Type.Array(id, { minItems: 1, description: "
|
|
15
|
-
noExtensions: Type.Optional(Type.Boolean({ description: "
|
|
16
|
-
noSkills: Type.Optional(Type.Boolean({ description: "
|
|
17
|
-
noPromptTemplates: Type.Optional(Type.Boolean({ description: "
|
|
18
|
-
noContextFiles: Type.Optional(Type.Boolean({ description: "
|
|
15
|
+
tools: Type.Optional(Type.Array(id, { minItems: 1, description: "Pi/dsh 子代理的工具名;省略时使用所选程序默认工具。Claude 子代理省略此参数并沿用原生配置。" })),
|
|
16
|
+
noExtensions: Type.Optional(Type.Boolean({ description: "仅用于 Pi 子代理:关闭其他扩展的自动发现,默认 true。" })),
|
|
17
|
+
noSkills: Type.Optional(Type.Boolean({ description: "Pi/dsh 子代理关闭技能发现,默认 false;Claude 子代理省略此参数并沿用原生配置。" })),
|
|
18
|
+
noPromptTemplates: Type.Optional(Type.Boolean({ description: "仅用于 Pi 子代理:关闭提示模板发现,默认 false。" })),
|
|
19
|
+
noContextFiles: Type.Optional(Type.Boolean({ description: "仅用于 Pi 子代理:关闭原生上下文文件加载,默认 false。" })),
|
|
19
20
|
};
|
|
20
21
|
const page = {
|
|
21
22
|
cycleId: Type.Optional(Type.String({ ...id, description: "仅 read:省略时读取最近周期;按 nextOffset 续读时须固定为上页返回的 cycle.cycleId,避免切换到新周期。" })),
|
|
22
23
|
offset: Type.Optional(Type.Integer({ minimum: 0, description: "仅 read:报告正文的 UTF-16 字符偏移,默认 0;续读使用上页 nextOffset。" })),
|
|
23
24
|
limit: Type.Optional(Type.Integer({ minimum: 1, maximum: 16000, description: "仅 read:最多返回的正文 UTF-16 字符数,默认 16000,不是消息数或 token 数。" })),
|
|
24
25
|
};
|
|
25
|
-
const delivery = Type.Optional(Type.Union([Type.Literal("steer"), Type.Literal("followUp")], { description: "send 默认 steer 补充当前工作;followUp 排到当前工作之后。" }));
|
|
26
|
+
const delivery = Type.Optional(Type.Union([Type.Literal("steer"), Type.Literal("followUp")], { description: "send 默认 steer 补充当前工作;followUp 排到当前工作之后。capabilities.steer 为 false 的成员运行中使用 followUp。" }));
|
|
26
27
|
export const agentParametersSchema = Type.Object({
|
|
27
28
|
action: Type.Union([Type.Literal("start"), Type.Literal("send"), Type.Literal("rename"), Type.Literal("status"), Type.Literal("list"), Type.Literal("read"), Type.Literal("stop"), Type.Literal("resume")], {
|
|
28
29
|
description: "start 仅接受启动选项,可省略 message/prompts/files 创建待命会话,禁止 agentId/delivery/分页字段;list 只接受 action;status/stop 只接受并必填 agentId;send 必填 agentId/message,仅可选 delivery;resume 必填 agentId/message;rename 必填 agentId/name;read 必填 agentId,仅可选 cycleId/offset/limit。禁止携带其他 action 的字段。",
|
|
@@ -44,6 +45,11 @@ const cycle = Type.Object({ cycleId: Type.String(), startedAt: Type.Number(), fi
|
|
|
44
45
|
source: Type.Union([Type.Literal("parent"), Type.Literal("interactive"), Type.Literal("mixed")]), error: Type.Optional(Type.String()),
|
|
45
46
|
}, { additionalProperties: false });
|
|
46
47
|
export const agentViewSchema = Type.Object({ agentId: Type.String(), name: Type.String(), cwd: Type.String(), createdAt: Type.Number(),
|
|
48
|
+
backend: Type.Optional(Type.Union([Type.Literal("pi"), Type.Literal("dsh"), Type.Literal("claude")])),
|
|
49
|
+
transport: Type.Optional(Type.Union([Type.Literal("native"), Type.Literal("acp")])),
|
|
50
|
+
selection: Type.Optional(Type.Object({ provider: Type.Optional(Type.String()), model: Type.Optional(Type.String()),
|
|
51
|
+
resolvedModel: Type.Optional(Type.String({ description: "目标原生会话报告的模型 ID,可用于识别配置别名。" })), thinking: Type.Optional(Type.String()) }, { additionalProperties: false, description: "子代理实际模型配置与有效思考等级,包含默认值。" })),
|
|
52
|
+
capabilities: Type.Optional(Type.Object({ steer: Type.Boolean(), resume: Type.Boolean(), team: Type.Boolean(), transcript: Type.Boolean() }, { additionalProperties: false })),
|
|
47
53
|
owned: Type.Boolean({ description: "是否属于当前父会话分支;false 时须回到所属分支操作。" }),
|
|
48
54
|
state: Type.Union([Type.Literal("starting"), Type.Literal("busy"), Type.Literal("idle"), Type.Literal("stopping"), Type.Literal("stopped"), Type.Literal("error")], { description: "执行状态;idle 不代表上轮工作成功,结果见 cycle.state。" }),
|
|
49
55
|
activity: Type.String(), cycle: Type.Optional(cycle), error: Type.Optional(Type.String()),
|
|
@@ -1,30 +1,35 @@
|
|
|
1
1
|
import { Type } from "typebox";
|
|
2
2
|
export declare const dshAgentParametersSchema: Type.TObject<{
|
|
3
|
+
noExtensions: Type.TOptional<Type.TBoolean>;
|
|
4
|
+
noPromptTemplates: Type.TOptional<Type.TBoolean>;
|
|
5
|
+
noContextFiles: Type.TOptional<Type.TBoolean>;
|
|
3
6
|
provider: Type.TOptional<Type.TString>;
|
|
4
7
|
model: Type.TOptional<Type.TString>;
|
|
5
8
|
thinking: Type.TOptional<Type.TString>;
|
|
6
9
|
files: Type.TOptional<Type.TArray<Type.TString>>;
|
|
7
10
|
tools: Type.TOptional<Type.TArray<Type.TString>>;
|
|
8
11
|
noSkills: Type.TOptional<Type.TBoolean>;
|
|
12
|
+
backend: Type.TOptional<Type.TUnion<[Type.TLiteral<"pi">, Type.TLiteral<"dsh">, Type.TLiteral<"claude">]>>;
|
|
13
|
+
cycleId: Type.TOptional<Type.TString>;
|
|
14
|
+
name: Type.TOptional<Type.TString>;
|
|
9
15
|
agentId: Type.TOptional<Type.TString>;
|
|
10
16
|
cwd: Type.TOptional<Type.TString>;
|
|
11
|
-
name: Type.TOptional<Type.TString>;
|
|
12
17
|
message: Type.TOptional<Type.TString>;
|
|
13
18
|
delivery: Type.TOptional<Type.TUnion<[Type.TLiteral<"steer">, Type.TLiteral<"followUp">]>>;
|
|
14
|
-
cycleId: Type.TOptional<Type.TString>;
|
|
15
19
|
prompts: Type.TOptional<Type.TArray<Type.TString>>;
|
|
16
20
|
action: Type.TUnion<[Type.TLiteral<"start">, Type.TLiteral<"send">, Type.TLiteral<"rename">, Type.TLiteral<"status">, Type.TLiteral<"list">, Type.TLiteral<"read">, Type.TLiteral<"stop">, Type.TLiteral<"resume">]>;
|
|
17
21
|
offset: Type.TOptional<Type.TInteger>;
|
|
18
22
|
limit: Type.TOptional<Type.TInteger>;
|
|
19
23
|
}>;
|
|
20
24
|
export declare const dshAgentActionSchema: Type.TUnion<(Type.TObject<{
|
|
25
|
+
backend: Type.TOptional<Type.TUnion<[Type.TLiteral<"pi">, Type.TLiteral<"dsh">, Type.TLiteral<"claude">]>>;
|
|
21
26
|
name: Type.TOptional<Type.TString>;
|
|
22
27
|
message: Type.TOptional<Type.TString>;
|
|
23
28
|
files: Type.TOptional<Type.TArray<Type.TString>>;
|
|
24
29
|
prompts: Type.TOptional<Type.TArray<Type.TString>>;
|
|
25
30
|
provider: Type.TOptional<Type.TString>;
|
|
26
31
|
model: Type.TOptional<Type.TString>;
|
|
27
|
-
thinking: Type.TOptional<Type.
|
|
32
|
+
thinking: Type.TOptional<Type.TString>;
|
|
28
33
|
cwd: Type.TOptional<Type.TString>;
|
|
29
34
|
tools: Type.TOptional<Type.TArray<Type.TString>>;
|
|
30
35
|
noExtensions: Type.TOptional<Type.TBoolean>;
|
|
@@ -37,16 +42,4 @@ export declare const dshAgentActionSchema: Type.TUnion<(Type.TObject<{
|
|
|
37
42
|
}> | Type.TObject<{
|
|
38
43
|
action: Type.TLiteral<string>;
|
|
39
44
|
agentId: Type.TString;
|
|
40
|
-
}> | Type.TObject<{
|
|
41
|
-
provider: Type.TOptional<Type.TString>;
|
|
42
|
-
model: Type.TOptional<Type.TString>;
|
|
43
|
-
thinking: Type.TOptional<Type.TString>;
|
|
44
|
-
files: Type.TOptional<Type.TArray<Type.TString>>;
|
|
45
|
-
tools: Type.TOptional<Type.TArray<Type.TString>>;
|
|
46
|
-
noSkills: Type.TOptional<Type.TBoolean>;
|
|
47
|
-
cwd: Type.TOptional<Type.TString>;
|
|
48
|
-
name: Type.TOptional<Type.TString>;
|
|
49
|
-
message: Type.TOptional<Type.TString>;
|
|
50
|
-
prompts: Type.TOptional<Type.TArray<Type.TString>>;
|
|
51
|
-
action: Type.TLiteral<"start">;
|
|
52
45
|
}>)[]>;
|
|
@@ -2,14 +2,18 @@ import { Type } from "../../common/typebox.js";
|
|
|
2
2
|
import { agentActionSchema, agentParametersSchema, agentStartOptions } from "./contract.js";
|
|
3
3
|
const options = Type.Omit(Type.Object(agentStartOptions), ["provider", "model", "thinking", "files", "tools", "noExtensions", "noPromptTemplates", "noContextFiles", "noSkills"]).properties;
|
|
4
4
|
const native = {
|
|
5
|
-
provider: Type.Optional(Type.String({ minLength: 1, maxLength: 128, description: "dsh
|
|
6
|
-
model: Type.Optional(Type.String({ minLength: 1, maxLength: 128, description: "
|
|
7
|
-
thinking: Type.Optional(Type.String({ minLength: 1, maxLength: 128, description: "
|
|
8
|
-
files: Type.Optional(Type.Array(Type.String({ minLength: 1 }), { maxItems: 32, description: "
|
|
9
|
-
tools: Type.Optional(Type.Array(Type.String({ minLength: 1 }), { minItems: 1, description: "
|
|
10
|
-
noSkills: Type.Optional(Type.Boolean({ description: "
|
|
5
|
+
provider: Type.Optional(Type.String({ minLength: 1, maxLength: 128, description: "模型提供方,dsh 使用原生 provider route。省略 backend 时默认继承主会话;指定 backend 时,此参数须与 model 一起提供。Claude 子代理省略此参数。" })),
|
|
6
|
+
model: Type.Optional(Type.String({ minLength: 1, maxLength: 128, description: "模型 ID;指定 backend 时也可使用目标公开的完整模型值。默认值:省略 backend 时继承主会话,指定时使用目标配置。" })),
|
|
7
|
+
thinking: Type.Optional(Type.String({ minLength: 1, maxLength: 128, description: "思考等级 ID,dsh 使用原生 reasoning effort,可单独指定。默认值:省略 backend 时继承主会话,指定时使用目标配置。" })),
|
|
8
|
+
files: Type.Optional(Type.Array(Type.String({ minLength: 1 }), { maxItems: 32, description: "附给子代理的文件;相对原工作区根目录。图片格式与大小遵循所选程序的支持范围。" })),
|
|
9
|
+
tools: Type.Optional(Type.Array(Type.String({ minLength: 1 }), { minItems: 1, description: "dsh 子代理填 run_code 内的能力工具名,Pi 子代理填 Pi 工具名。省略时使用所选程序默认工具;未指定 backend 的专家另有 pbot_team_message。Claude 子代理省略此参数并沿用原生配置。" })),
|
|
10
|
+
noSkills: Type.Optional(Type.Boolean({ description: "Pi/dsh 子代理关闭技能发现,默认 false;dsh 同时关闭 skill 工具。Claude 子代理省略此参数并沿用原生配置。" })),
|
|
11
11
|
};
|
|
12
12
|
const omitted = ["noExtensions", "noPromptTemplates", "noContextFiles", "provider", "model", "thinking", "files", "tools", "noSkills"];
|
|
13
|
-
export const dshAgentParametersSchema = Type.Object({ ...Type.Omit(agentParametersSchema, omitted).properties, ...native
|
|
13
|
+
export const dshAgentParametersSchema = Type.Object({ ...Type.Omit(agentParametersSchema, omitted).properties, ...native,
|
|
14
|
+
noExtensions: agentStartOptions.noExtensions, noPromptTemplates: agentStartOptions.noPromptTemplates, noContextFiles: agentStartOptions.noContextFiles,
|
|
15
|
+
}, { additionalProperties: false });
|
|
14
16
|
export const dshAgentActionSchema = Type.Union(agentActionSchema.anyOf.map(row => row.properties.action.const === "start"
|
|
15
|
-
? Type.Object({ action: Type.Literal("start"), ...options, ...native
|
|
17
|
+
? Type.Object({ action: Type.Literal("start"), ...options, ...native,
|
|
18
|
+
noExtensions: agentStartOptions.noExtensions, noPromptTemplates: agentStartOptions.noPromptTemplates, noContextFiles: agentStartOptions.noContextFiles,
|
|
19
|
+
}, { additionalProperties: false }) : row));
|
package/lib/ui/dsh/management.js
CHANGED
|
@@ -165,19 +165,23 @@ export function showManagement(ctx, parentSessionId) {
|
|
|
165
165
|
const diagnostic = details(status, "环境详情"), statusBody = block("");
|
|
166
166
|
statusBody.classList.add("pbot-raw");
|
|
167
167
|
diagnostic.append(statusBody);
|
|
168
|
+
const permissions = group(status, "pbot-setting");
|
|
169
|
+
permissions.hidden = true;
|
|
170
|
+
let permissionKey = "";
|
|
168
171
|
const experts = section("experts", "专家");
|
|
169
172
|
pageTitle(experts, "专家", "");
|
|
170
173
|
const create = details(experts, "创建专家"), createForm = form(create), newName = field(createForm, "名称"), initial = field(createForm, "任务(可选)", true);
|
|
171
174
|
newName.placeholder = "例如:研究员";
|
|
172
175
|
initial.placeholder = "任务目标与交付要求";
|
|
176
|
+
const backend = select(createForm, "运行宿主", [["", "当前宿主"], ["pi", "Pi"], ["dsh", "dsh"], ["claude", "Claude Code"]]);
|
|
173
177
|
const options = details(createForm, "模型与选项"), modelFields = group(options, "pbot-grid");
|
|
174
|
-
options.querySelector("summary").after(note("
|
|
178
|
+
options.querySelector("summary").after(note("当前宿主留空沿用主会话;其他宿主留空使用目标配置。"));
|
|
175
179
|
const provider = field(modelFields, "Provider"), model = field(modelFields, "模型");
|
|
176
180
|
const effort = field(options, "Reasoning effort"), cwd = field(options, "工作目录");
|
|
177
181
|
const files = field(options, "文件路径(每行一个)", true);
|
|
178
182
|
const advanced = field(details(options, "其他选项"), "JSON", true, "{}");
|
|
179
183
|
submit(createForm, "创建", async () => {
|
|
180
|
-
const args = { ...objectInput(advanced.value), action: "start", ...(newName.value ? { name: newName.value } : {}),
|
|
184
|
+
const args = { ...objectInput(advanced.value), action: "start", ...(backend.value ? { backend: backend.value } : {}), ...(newName.value ? { name: newName.value } : {}),
|
|
181
185
|
...(initial.value ? { message: initial.value } : {}), ...(provider.value ? { provider: provider.value } : {}),
|
|
182
186
|
...(model.value ? { model: model.value } : {}), ...(effort.value ? { thinking: effort.value } : {}),
|
|
183
187
|
...(cwd.value ? { cwd: cwd.value } : {}), ...(lines(files.value).length ? { files: lines(files.value) } : {}) };
|
|
@@ -304,8 +308,15 @@ export function showManagement(ctx, parentSessionId) {
|
|
|
304
308
|
expertBadge.replaceChildren(badge(agent.state));
|
|
305
309
|
expertPanel.hidden = false;
|
|
306
310
|
expertEmpty.hidden = true;
|
|
307
|
-
const config = object(agent.options) ? agent.options : {};
|
|
308
|
-
|
|
311
|
+
const config = object(agent.options) ? agent.options : {}, selected = record(agent.selection);
|
|
312
|
+
const configuredModel = [selected.provider ?? config.provider, selected.model ?? config.model].filter(Boolean).join("/");
|
|
313
|
+
const chosenModel = selected.resolvedModel && selected.resolvedModel !== configuredModel ? `${configuredModel} → ${text(selected.resolvedModel)}` : configuredModel;
|
|
314
|
+
expertInfo.replaceChildren(note(text(agent.activity) || "等待新的任务。"), facts([["宿主", agent.backend || "当前宿主"], ["模型", chosenModel || (agent.transport === "acp" ? "目标宿主配置" : "继承父会话")],
|
|
315
|
+
["思考等级", selected.thinking || config.thinking || "宿主默认"], ["工作目录", agent.cwd]]));
|
|
316
|
+
const steering = delivery.querySelector('option[value="steer"]');
|
|
317
|
+
steering.disabled = agent.transport === "acp";
|
|
318
|
+
if (steering.disabled && delivery.value === "steer")
|
|
319
|
+
delivery.value = "followUp";
|
|
309
320
|
expertState.textContent = JSON.stringify(agent, null, 2);
|
|
310
321
|
expertError.textContent = text(agent.error);
|
|
311
322
|
expertError.hidden = !agent.error;
|
|
@@ -324,7 +335,7 @@ export function showManagement(ctx, parentSessionId) {
|
|
|
324
335
|
eventBody.textContent = text(data.text);
|
|
325
336
|
eventBody.classList.toggle("pbot-raw", format === "json");
|
|
326
337
|
eventPaging.replaceChildren(element("span", `记录 ${seq} · ${offset + 1}–${offset + text(data.text).length} / ${data.totalLength}`));
|
|
327
|
-
button(eventPaging, format === "text" ? "查看原始事件" : "查看正文", () => loadRecord(seq, 0, format === "text" ? "json" : "text"));
|
|
338
|
+
button(eventPaging, format === "text" ? data.kind === "acp" ? "查看记录详情" : "查看原始事件" : "查看正文", () => loadRecord(seq, 0, format === "text" ? "json" : "text"));
|
|
328
339
|
if (offset)
|
|
329
340
|
button(eventPaging, "从头读取", () => loadRecord(seq, 0, format));
|
|
330
341
|
if (typeof data.nextOffset === "number")
|
|
@@ -351,8 +362,9 @@ export function showManagement(ctx, parentSessionId) {
|
|
|
351
362
|
const expanded = new Set(Array.from(rawEventList.querySelectorAll("details[open]")).map(item => item.dataset.seq));
|
|
352
363
|
eventList.replaceChildren();
|
|
353
364
|
rawEventList.replaceChildren();
|
|
354
|
-
|
|
355
|
-
|
|
365
|
+
rawEvents.querySelector("summary").textContent = data.kind === "acp" ? "全部任务与报告" : "全部原生事件";
|
|
366
|
+
const labels = { "user/message": "输入", "assistant/message": "专家回复", "tool/result": "工具结果", "turn/end": "本轮结束", "acp/input": "任务", "acp/report": "专家报告" };
|
|
367
|
+
for (const event of rows(data.kind === "acp" ? data.records : data.events)) {
|
|
356
368
|
const seq = Number(event.seq), label = event.type === "user/message"
|
|
357
369
|
? event.source === "user" ? "输入" : event.source === "pbot-input" ? "任务" : undefined : labels[text(event.type)];
|
|
358
370
|
if (label && text(event.preview)) {
|
|
@@ -663,10 +675,26 @@ export function showManagement(ctx, parentSessionId) {
|
|
|
663
675
|
enabled(pythonButton, python.state !== "preparing");
|
|
664
676
|
const { agents: _agents, teams: _teams, ...summary } = snapshot;
|
|
665
677
|
statusBody.textContent = JSON.stringify(summary, null, 2);
|
|
678
|
+
const pending = rows(snapshot.permissions), nextPermissionKey = pending.map(request => text(request.agentId) + ":" + text(request.requestId)).join(",");
|
|
679
|
+
permissions.hidden = !pending.length;
|
|
680
|
+
if (nextPermissionKey !== permissionKey) {
|
|
681
|
+
permissionKey = nextPermissionKey;
|
|
682
|
+
permissions.replaceChildren(element("h3", "专家请求确认"));
|
|
683
|
+
for (const request of pending) {
|
|
684
|
+
const card = group(permissions, "pbot-card");
|
|
685
|
+
card.append(element("h4", text(request.name)), block(request.description));
|
|
686
|
+
const choices = group(card, "pbot-row");
|
|
687
|
+
for (const option of rows(request.options))
|
|
688
|
+
button(choices, text(option.name), async () => {
|
|
689
|
+
await command("approval", { agentId: request.agentId, requestId: request.requestId, optionId: option.optionId }, "确认答复已提交。");
|
|
690
|
+
});
|
|
691
|
+
button(choices, "取消", async () => { await command("approval", { agentId: request.agentId, requestId: request.requestId, optionId: null }, "已取消该请求。"); });
|
|
692
|
+
}
|
|
693
|
+
}
|
|
666
694
|
if (snapshot.controlError)
|
|
667
695
|
inform(text(snapshot.controlError), "error");
|
|
668
696
|
renderLists();
|
|
669
|
-
const owned = agents.filter(value => value.owned), ids = new Set(owned.map(agent => text(agent.agentId)));
|
|
697
|
+
const owned = agents.filter(value => value.owned && record(value.capabilities).team !== false), ids = new Set(owned.map(agent => text(agent.agentId)));
|
|
670
698
|
for (const input of memberFields.querySelectorAll("input[data-agent-id]"))
|
|
671
699
|
if (!ids.has(input.dataset.agentId))
|
|
672
700
|
input.parentElement?.remove();
|