personal-bot 0.2.14 → 0.2.16
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 +10 -11
- package/README.zh-CN.md +10 -11
- package/docs/README.md +2 -2
- package/docs/adr/0001-claude-skill-discovery.md +1 -1
- package/docs/agent-collaboration.md +8 -9
- package/docs/architecture-guidelines.md +1 -1
- package/docs/capability-design.md +2 -2
- package/docs/claude-code-design.md +10 -11
- package/docs/claude-code.md +8 -15
- package/docs/dsh.md +18 -19
- package/docs/file-storage.md +2 -3
- package/docs/installation-design.md +4 -5
- package/docs/interaction-design.md +1 -1
- package/docs/model-context.md +9 -10
- package/docs/release.md +5 -5
- package/docs/technical-design.md +16 -21
- package/docs/workspace-configuration.md +5 -8
- package/hooks/hooks.json +1 -4
- package/lib/client.js +3 -15
- package/lib/common/schema.d.ts +2 -0
- package/lib/common/schema.js +9 -0
- package/lib/extension/acp-member.js +1 -3
- package/lib/extension/acp-worker.js +3 -22
- package/lib/extension/claude-hooks.d.ts +0 -6
- package/lib/extension/claude-hooks.js +5 -31
- package/lib/extension/dsh/acp-member.js +1 -2
- package/lib/extension/dsh/command.js +13 -23
- package/lib/extension/dsh/management.d.ts +1 -1
- package/lib/extension/dsh/management.js +3 -3
- package/lib/extension/dsh/workspace.d.ts +1 -9
- package/lib/extension/dsh/workspace.js +4 -31
- package/lib/extension/setup-cli.js +4 -4
- package/lib/integrations/dsh/dsh-agents.d.ts +1 -2
- package/lib/integrations/dsh/dsh-agents.js +0 -4
- package/lib/integrations/dsh/resources.d.ts +1 -5
- package/lib/integrations/dsh/resources.js +2 -5
- package/lib/integrations/installation/processes.js +0 -15
- package/lib/model/agent.d.ts +0 -1
- package/lib/services/agents/agent-notices.js +1 -1
- package/lib/services/agents/agent-service.js +3 -2
- package/lib/services/agents/start-options.d.ts +4 -0
- package/lib/services/agents/start-options.js +20 -0
- package/lib/tools/agents/actions.d.ts +1 -5
- package/lib/tools/agents/actions.js +12 -1
- package/lib/tools/agents/contract.d.ts +50 -77
- package/lib/tools/agents/contract.js +54 -32
- package/lib/tools/agents/dsh-tool.js +6 -11
- package/lib/tools/history/contract.d.ts +28 -11
- package/lib/tools/history/contract.js +18 -12
- package/lib/tools/input.d.ts +11 -0
- package/lib/tools/input.js +23 -0
- package/lib/tools/teams/actions.d.ts +3 -4
- package/lib/tools/teams/actions.js +7 -5
- package/lib/tools/teams/contract.d.ts +56 -87
- package/lib/tools/teams/contract.js +55 -31
- package/lib/tools/teams/dsh-tool.js +7 -18
- package/lib/ui/dsh/management.js +1 -9
- package/lib/ui/dsh/styles.d.ts +1 -1
- package/lib/ui/dsh/styles.js +2 -2
- package/lib/ui/presentation.js +1 -1
- package/package.json +1 -4
- package/resources/claude/skills/pbot/SKILL.md +2 -3
- package/resources/prompts/native-coordinator.md +1 -1
- package/resources/prompts/workspace.md +1 -1
- package/resources/references/compute.md +6 -8
- package/scripts/README.md +2 -6
- package/src/common/schema.ts +10 -0
- package/src/extension/acp-member.ts +1 -3
- package/src/extension/acp-worker.ts +3 -12
- package/src/extension/agent-events.ts +1 -1
- package/src/extension/claude-hooks.ts +5 -25
- package/src/extension/command.ts +7 -16
- package/src/extension/dsh/acp-member.ts +1 -2
- package/src/extension/dsh/command.ts +14 -23
- package/src/extension/dsh/management.ts +3 -3
- package/src/extension/dsh/workspace.ts +5 -26
- package/src/extension/events.ts +2 -11
- package/src/extension/lifecycle.ts +8 -23
- package/src/extension/setup-cli.ts +4 -4
- package/src/extension/subagent-entry.ts +6 -12
- package/src/integrations/dsh/dsh-agents.ts +1 -4
- package/src/integrations/dsh/resources.ts +2 -5
- package/src/integrations/installation/processes.ts +0 -13
- package/src/integrations/pi/pi-agents.ts +12 -5
- package/src/model/agent.ts +1 -1
- package/src/pbot.ts +1 -2
- package/src/services/agents/agent-notices.ts +1 -1
- package/src/services/agents/agent-service.ts +4 -2
- package/src/services/agents/start-options.ts +19 -0
- package/src/tools/agents/actions.ts +18 -10
- package/src/tools/agents/contract.ts +68 -33
- package/src/tools/agents/dsh-tool.ts +7 -12
- package/src/tools/agents/tool.ts +2 -8
- package/src/tools/history/actions.ts +1 -1
- package/src/tools/history/contract.ts +27 -14
- package/src/tools/input.ts +29 -0
- package/src/tools/teams/actions.ts +10 -14
- package/src/tools/teams/contract.ts +71 -33
- package/src/tools/teams/dsh-tool.ts +7 -18
- package/src/tools/teams/tool.ts +3 -13
- package/src/ui/dsh/management.ts +2 -8
- package/src/ui/dsh/styles.ts +2 -2
- package/src/ui/presentation.ts +1 -1
- package/lib/integrations/process.d.ts +0 -14
- package/lib/integrations/process.js +0 -48
- package/lib/integrations/python-activation.d.ts +0 -2
- package/lib/integrations/python-activation.js +0 -29
- package/lib/services/workspace/python-environment-service.d.ts +0 -21
- package/lib/services/workspace/python-environment-service.js +0 -66
- package/lib/tools/agents/dsh-contract.d.ts +0 -45
- package/lib/tools/agents/dsh-contract.js +0 -19
- package/python/README.md +0 -72
- package/python/requirements.lock +0 -38
- package/scripts/setup-python.py +0 -170
- package/src/integrations/process.ts +0 -40
- package/src/integrations/python-activation.ts +0 -23
- package/src/services/workspace/python-environment-service.ts +0 -61
- package/src/tools/agents/dsh-contract.ts +0 -20
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { Type } from "typebox";
|
|
2
|
+
import type { TSchema } from "typebox";
|
|
3
|
+
import { schema } from "../../common/schema.js";
|
|
4
|
+
import { inputObject, need, nullable, pick } from "../input.js";
|
|
2
5
|
|
|
3
|
-
export const teamDescription = "组织固定成员协作。create 建立团队,run 开始一批讨论。运行时占用成员;pause 停止新安排,允许在途工作收尾,之后可私人 send;中止成员用 pbot_agent stop。close 保留成员和历史;换成员须关闭旧团队再创建。继续讨论用 run
|
|
6
|
+
export const teamDescription = "组织固定成员协作。create 建立团队,run 开始一批讨论。运行时占用成员;pause 停止新安排,允许在途工作收尾,之后可私人 send;中止成员用 pbot_agent stop。close 保留成员和历史;换成员须关闭旧团队再创建。继续讨论用 run 提交新要求。团队状态与批次用 status;公共原文用 pbot_team_message read/post。";
|
|
4
7
|
export const teamMessageDescription = "读写团队公共原文。post 向全体成员发布信息,需要安排回答时由主会话调用 pbot_team run;成员只能在自己的团队工作中 post。read 用 afterSeq 翻页,长正文按 seq/offset 续读,先补完 nextOffset 非空的消息。";
|
|
5
8
|
|
|
6
|
-
import type { TSchema } from "typebox";
|
|
7
|
-
|
|
8
9
|
const id = Type.String({ minLength: 1, maxLength: 128 });
|
|
9
10
|
const text = Type.String({ minLength: 1, maxLength: 24000 });
|
|
10
11
|
const name = Type.String({ minLength: 1, maxLength: 64, pattern: "^[^\\r\\n\\x00-\\x1f]+$" });
|
|
@@ -12,43 +13,80 @@ const mode = Type.Union([Type.Literal("roundRobin"), Type.Literal("parallel")],
|
|
|
12
13
|
const members = Type.Array(Type.Object({ agentId: id, role: Type.String({ minLength: 1, maxLength: 4000 }) }, { additionalProperties: false }), {
|
|
13
14
|
minItems: 1, maxItems: 50, description: "仅 create,必填:当前分支中的固定成员及职责;成员须版本兼容且未加入其他未关闭团队。",
|
|
14
15
|
});
|
|
15
|
-
const
|
|
16
|
-
instruction: Type.String({ ...text, description: "仅 run,必填:本批次的任务、约束与交付要求。" }),
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
}
|
|
21
|
-
const page = {
|
|
22
|
-
afterSeq: Type.Optional(Type.Integer({ minimum: 0, description: "仅 read:读取序号大于此值的消息,默认 0,不得超过 lastSeq。返回 nextAfterSeq 用于继续消息列表;单条续读使用 seq/offset,省略 afterSeq。先补完被截断的正文,再继续列表。" })),
|
|
23
|
-
seq: Type.Optional(Type.Integer({ minimum: 1, description: "仅 read:指定一条消息,配合该消息的 nextOffset 续读。未指定时从 afterSeq 后顺序读取。" })),
|
|
24
|
-
offset: Type.Optional(Type.Integer({ minimum: 0, description: "仅 read:指定 seq 的正文 UTF-16 字符偏移,默认 0;非零时必须同时提供 seq。" })),
|
|
25
|
-
limit: Type.Optional(Type.Integer({ minimum: 1, maximum: 16000, description: "仅 read:本页所有消息正文合计的 UTF-16 字符上限,默认 16000,不是消息条数或 token 数;不含元数据和 Markdown 格式开销。" })),
|
|
16
|
+
const runFields = {
|
|
17
|
+
instruction: nullable(Type.String({ ...text, description: "仅 run,必填:本批次的任务、约束与交付要求。" })),
|
|
18
|
+
mode: nullable(mode),
|
|
19
|
+
rounds: nullable(Type.Integer({ minimum: 1, maximum: 10, description: "仅 run:每位成员的轮数,默认 2。" })),
|
|
20
|
+
maxConcurrent: nullable(Type.Integer({ minimum: 1, maximum: 50, description: "仅 run:roundRobin 默认且只允许 1;parallel 默认 min(2, 成员数)。不得超过成员数;待处理和执行中的发言都计入上限。" })),
|
|
21
|
+
timeoutSeconds: nullable(Type.Integer({ minimum: 1, maximum: 86400, description: "仅 run:整批期限,默认 900 秒,包含所有轮次和等待。到期停止安排并尝试中止尚未人工接管的工作,之后仍须核对实际状态;pause 则允许在途工作收尾。" })),
|
|
26
22
|
};
|
|
27
23
|
const object = <T extends Record<string, TSchema>>(fields: T) => Type.Object(fields, { additionalProperties: false });
|
|
28
24
|
export const teamParametersSchema = object({
|
|
29
|
-
action: Type.Union(["create", "list", "status", "
|
|
30
|
-
description: "create 必填 name/brief/members;list
|
|
25
|
+
action: Type.Union(["create", "list", "status", "run", "pause", "close"].map(value => Type.Literal(value)), {
|
|
26
|
+
description: "create 必填 name/brief/members;list 只需 action;status/pause/close 必填 teamId;run 必填 teamId/instruction/mode,可选 rounds/maxConcurrent/timeoutSeconds。动作只读取自己的字段;其他已声明字段忽略。run 前须确认所有成员存活、idle、可参与团队且无待处理私人输入,团队未关闭,也无运行批次或在途工作。close 前先暂停并等待在途工作结束。",
|
|
31
27
|
}),
|
|
32
|
-
teamId:
|
|
33
|
-
instruction: Type.Optional(run.instruction), mode: Type.Optional(mode), rounds: run.rounds, maxConcurrent: run.maxConcurrent, timeoutSeconds: run.timeoutSeconds, ...page,
|
|
28
|
+
teamId: nullable(id), name: nullable(name), brief: nullable(text), members: nullable(members), ...runFields,
|
|
34
29
|
});
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
30
|
+
|
|
31
|
+
export type TeamMember = { agentId: string; role: string };
|
|
32
|
+
export type TeamInput =
|
|
33
|
+
| { action: "create"; name: string; brief: string; members: TeamMember[] }
|
|
34
|
+
| { action: "list" }
|
|
35
|
+
| { action: "status" | "pause" | "close"; teamId: string }
|
|
36
|
+
| { action: "run"; teamId: string; instruction: string; mode: "roundRobin" | "parallel"; rounds?: number; maxConcurrent?: number; timeoutSeconds?: number };
|
|
37
|
+
|
|
38
|
+
const validTeam = schema(teamParametersSchema);
|
|
39
|
+
|
|
40
|
+
export function teamInput(value: unknown): TeamInput {
|
|
41
|
+
const args = inputObject(value, validTeam, "团队参数格式无效");
|
|
42
|
+
const action = args.action as TeamInput["action"];
|
|
43
|
+
switch (action) {
|
|
44
|
+
case "create":
|
|
45
|
+
return { action, name: need("create", args, "name"), brief: need("create", args, "brief"), members: need("create", args, "members") };
|
|
46
|
+
case "list":
|
|
47
|
+
return { action };
|
|
48
|
+
case "status":
|
|
49
|
+
case "pause":
|
|
50
|
+
case "close":
|
|
51
|
+
return { action, teamId: need(action, args, "teamId") };
|
|
52
|
+
case "run":
|
|
53
|
+
return { action, teamId: need("run", args, "teamId"), instruction: need("run", args, "instruction"), mode: need("run", args, "mode"),
|
|
54
|
+
...(args.rounds === undefined ? {} : { rounds: args.rounds as number }),
|
|
55
|
+
...(args.maxConcurrent === undefined ? {} : { maxConcurrent: args.maxConcurrent as number }),
|
|
56
|
+
...(args.timeoutSeconds === undefined ? {} : { timeoutSeconds: args.timeoutSeconds as number }) };
|
|
57
|
+
default:
|
|
58
|
+
throw new Error("未知的团队 action。");
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
const page = {
|
|
63
|
+
afterSeq: nullable(Type.Integer({ minimum: 0, description: "仅 read:读取序号大于此值的消息,默认 0,不得超过 lastSeq。返回 nextAfterSeq 用于继续消息列表;单条续读使用 seq/offset,省略 afterSeq。先补完被截断的正文,再继续列表。" })),
|
|
64
|
+
seq: nullable(Type.Integer({ minimum: 1, description: "仅 read:指定一条消息,配合该消息的 nextOffset 续读。未指定时从 afterSeq 后顺序读取。" })),
|
|
65
|
+
offset: nullable(Type.Integer({ minimum: 0, description: "仅 read:指定 seq 的正文 UTF-16 字符偏移,默认 0;非零时必须同时提供 seq。" })),
|
|
66
|
+
limit: nullable(Type.Integer({ minimum: 1, maximum: 16000, description: "仅 read:本页所有消息正文合计的 UTF-16 字符上限,默认 16000,不是消息条数或 token 数;不含元数据和 Markdown 格式开销。" })),
|
|
67
|
+
};
|
|
42
68
|
export const teamMessageParametersSchema = object({
|
|
43
69
|
action: Type.Union([Type.Literal("read"), Type.Literal("post")], {
|
|
44
|
-
description: "read 必填 teamId
|
|
45
|
-
}), teamId: id, text:
|
|
46
|
-
replyTo:
|
|
70
|
+
description: "read 必填 teamId,可选 afterSeq/seq/offset/limit;post 必填 teamId/text,可选 replyTo。动作只读取自己的字段;其他已声明字段忽略。",
|
|
71
|
+
}), teamId: nullable(id), text: nullable(Type.String({ ...text, description: "仅 post,必填:向全体成员公开的原文。" })),
|
|
72
|
+
replyTo: nullable(Type.Integer({ minimum: 1, description: "仅 post:回复已有消息的 seq。" })), ...page,
|
|
47
73
|
});
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
74
|
+
|
|
75
|
+
export type TeamMessageInput =
|
|
76
|
+
| { action: "read"; teamId: string; afterSeq?: number; seq?: number; offset?: number; limit?: number }
|
|
77
|
+
| { action: "post"; teamId: string; text: string; replyTo?: number };
|
|
78
|
+
|
|
79
|
+
const validMessage = schema(teamMessageParametersSchema);
|
|
80
|
+
|
|
81
|
+
export function teamMessageInput(value: unknown): TeamMessageInput {
|
|
82
|
+
const args = inputObject(value, validMessage, "团队消息参数格式无效");
|
|
83
|
+
if (args.action === "read") return { action: "read", teamId: need("read", args, "teamId"),
|
|
84
|
+
...(pick(args, ["afterSeq", "seq", "offset", "limit"]) as Pick<Extract<TeamMessageInput, { action: "read" }>, "afterSeq" | "seq" | "offset" | "limit">) };
|
|
85
|
+
if (args.action === "post") return { action: "post", teamId: need("post", args, "teamId"), text: need("post", args, "text"),
|
|
86
|
+
...(args.replyTo === undefined ? {} : { replyTo: args.replyTo as number }) };
|
|
87
|
+
throw new Error("未知的团队消息 action。");
|
|
88
|
+
}
|
|
89
|
+
|
|
52
90
|
const message = object({ seq: Type.Integer(), operationId: Type.String(),
|
|
53
91
|
author: object({ kind: Type.Union([Type.Literal("user"), Type.Literal("coordinator"), Type.Literal("member")]), agentId: Type.Optional(id), name: Type.String() }),
|
|
54
92
|
text: Type.String(), replyTo: Type.Optional(Type.Integer()), runId: Type.Optional(id),
|
|
@@ -67,5 +105,5 @@ const ownedView = object({ teamId: id, name: Type.String(), brief: Type.String()
|
|
|
67
105
|
run: Type.Optional(object({ runId: id, instruction: Type.String(), mode, state: Type.Union([Type.Literal("running"), Type.Literal("paused"), Type.Literal("finished")]),
|
|
68
106
|
rounds: Type.Integer(), maxConcurrent: Type.Integer(), deadlineAt: Type.Number(), scheduled: Type.Integer(), published: Type.Integer(), reason: Type.Optional(Type.String()) })) });
|
|
69
107
|
const view = Type.Union([ownedView, object({ teamId: id, name: Type.String(), closed: Type.Boolean(), owned: Type.Literal(false) })]);
|
|
70
|
-
export const teamResultSchema = Type.Union([view, object({ teams: Type.Array(view) })
|
|
108
|
+
export const teamResultSchema = Type.Union([view, object({ teams: Type.Array(view) })]);
|
|
71
109
|
export const teamMessageResultSchema = Type.Union([teamPageSchema, object({ teamId: id, seq: Type.Integer(), status: Type.Literal("stored") })]);
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import type { Context } from "@deepseek-ai/cordis";
|
|
2
2
|
import type { Agent } from "@deepseek-ai/dsh-agent";
|
|
3
3
|
import { dshParameters, dshOutputSchema } from "../../integrations/dsh/schema.js";
|
|
4
|
-
import type { Static } from "typebox";
|
|
5
4
|
import type { TeamService } from "../../services/agents/team-service.js";
|
|
6
5
|
import type { AgentService } from "../../services/agents/agent-service.js";
|
|
7
6
|
import type { AgentOwner } from "../../model/agent.js";
|
|
@@ -12,31 +11,23 @@ import { schema } from "../../common/schema.js";
|
|
|
12
11
|
import { markdownFields } from "../../common/markdown.js";
|
|
13
12
|
import { teamMessagesMarkdown } from "../../integrations/team-context.js";
|
|
14
13
|
import { executeTeam, executeTeamMessage } from "./actions.js";
|
|
15
|
-
import { teamDescription, teamMessageDescription,
|
|
16
|
-
teamMessageParametersSchema,
|
|
14
|
+
import { teamDescription, teamMessageDescription, teamInput, teamMessageInput, teamParametersSchema, teamResultSchema,
|
|
15
|
+
teamMessageParametersSchema, teamMessageResultSchema } from "./contract.js";
|
|
17
16
|
|
|
18
17
|
export function registerDshTeamTool(ctx: Context, agent: Agent, service: TeamService, agents: AgentService, owner: AgentOwner, check: () => void) {
|
|
19
|
-
const validators = new Map(teamActionSchema.anyOf.map(row => [row.properties.action.const, schema(row)]));
|
|
20
18
|
const validOutput = schema(teamResultSchema);
|
|
21
19
|
ctx.tools.register({ name: "pbot_team", description: teamDescription, parameters: dshParameters(teamParametersSchema),
|
|
22
|
-
output: {
|
|
23
|
-
schema: dshOutputSchema(teamResultSchema),
|
|
24
|
-
render: (args, value) => [{ type: "text", text: object(args) && args.action === "read"
|
|
25
|
-
? teamMessagesMarkdown(value as unknown as ReturnType<TeamService["read"]>) : "# 团队\n\n" + markdownFields(value) }],
|
|
26
|
-
},
|
|
20
|
+
output: { schema: dshOutputSchema(teamResultSchema), render: (_args, value) => [{ type: "text", text: "# 团队\n\n" + markdownFields(value) }] },
|
|
27
21
|
async execute(args, exec) {
|
|
28
22
|
check(); exec.signal.throwIfAborted();
|
|
29
|
-
requireThat(exec.agent === agent
|
|
30
|
-
const
|
|
31
|
-
requireThat(valid && valid(args), "团队参数无效。");
|
|
32
|
-
const value = executeTeam(service, agents, args as Static<typeof teamParametersSchema>, owner).structuredContent;
|
|
23
|
+
requireThat(exec.agent === agent, "团队工具不属于当前会话。");
|
|
24
|
+
const value = executeTeam(service, agents, teamInput(args), owner).structuredContent;
|
|
33
25
|
requireThat(validOutput(value), "团队输出不符合契约。"); return value;
|
|
34
26
|
},
|
|
35
27
|
});
|
|
36
28
|
}
|
|
37
29
|
|
|
38
30
|
export function registerDshTeamMessageTool(ctx: Context, agent: Agent, service: TeamService, actor: () => TeamActor, check: () => void) {
|
|
39
|
-
const validators = new Map<string, ReturnType<typeof schema>>(teamMessageActionSchema.anyOf.map(row => [row.properties.action.const, schema(row)]));
|
|
40
31
|
const validOutput = schema(teamMessageResultSchema);
|
|
41
32
|
ctx.tools.register({ name: "pbot_team_message", description: teamMessageDescription, parameters: dshParameters(teamMessageParametersSchema),
|
|
42
33
|
output: {
|
|
@@ -46,10 +37,8 @@ export function registerDshTeamMessageTool(ctx: Context, agent: Agent, service:
|
|
|
46
37
|
},
|
|
47
38
|
async execute(args, exec) {
|
|
48
39
|
check(); exec.signal.throwIfAborted();
|
|
49
|
-
requireThat(exec.agent === agent
|
|
50
|
-
const
|
|
51
|
-
requireThat(valid && valid(args), "团队消息参数无效。");
|
|
52
|
-
const value = executeTeamMessage(service, args as Static<typeof teamMessageParametersSchema>, actor(), exec.callId).structuredContent;
|
|
40
|
+
requireThat(exec.agent === agent, "团队消息工具不属于当前会话。");
|
|
41
|
+
const value = executeTeamMessage(service, teamMessageInput(args), actor(), exec.callId).structuredContent;
|
|
53
42
|
requireThat(validOutput(value), "团队消息输出不符合契约。"); return value;
|
|
54
43
|
},
|
|
55
44
|
});
|
package/src/tools/teams/tool.ts
CHANGED
|
@@ -3,37 +3,27 @@ import type { TeamService } from "../../services/agents/team-service.js";
|
|
|
3
3
|
import type { AgentService } from "../../services/agents/agent-service.js";
|
|
4
4
|
import type { TeamActor } from "../../model/team.js";
|
|
5
5
|
import { agentOwner } from "../../integrations/pi/agent-context.js";
|
|
6
|
-
import { requireThat } from "../../common/validation.js";
|
|
7
|
-
import { schema } from "../../common/schema.js";
|
|
8
6
|
import type { CallAccess } from "../access.js";
|
|
9
7
|
import { executeTeam, executeTeamMessage } from "./actions.js";
|
|
10
|
-
import { teamDescription, teamMessageDescription,
|
|
8
|
+
import { teamDescription, teamMessageDescription, teamInput, teamMessageInput, teamParametersSchema, teamResultSchema, teamMessageParametersSchema, teamMessageResultSchema } from "./contract.js";
|
|
11
9
|
|
|
12
10
|
export function teamTool(service: TeamService, agents: AgentService, access: Pick<CallAccess, "check">) {
|
|
13
|
-
const validators = new Map(teamActionSchema.anyOf.map(action => [action.properties.action.const, schema(action)]));
|
|
14
11
|
return defineTool({ name: "pbot_team", label: "团队",
|
|
15
12
|
description: teamDescription,
|
|
16
13
|
parameters: teamParametersSchema, outputSchema: teamResultSchema,
|
|
17
14
|
async execute(_id, args, signal, _update, ctx) {
|
|
18
15
|
access.check(); signal?.throwIfAborted();
|
|
19
|
-
|
|
20
|
-
requireThat(valid, "未知的团队 action:" + args.action);
|
|
21
|
-
requireThat(valid(args), "团队 " + args.action + " 参数无效:" + JSON.stringify(valid.errors));
|
|
22
|
-
return executeTeam(service, agents, args, agentOwner(ctx));
|
|
16
|
+
return executeTeam(service, agents, teamInput(args), agentOwner(ctx));
|
|
23
17
|
},
|
|
24
18
|
});
|
|
25
19
|
}
|
|
26
20
|
export function teamMessageTool(service: TeamService, access: Pick<CallAccess, "check">, actor: (ctx: ExtensionContext) => TeamActor) {
|
|
27
|
-
const validators = new Map(teamMessageActionSchema.anyOf.map(action => [action.properties.action.const, schema(action)]));
|
|
28
21
|
return defineTool({ name: "pbot_team_message", label: "团队消息",
|
|
29
22
|
description: teamMessageDescription,
|
|
30
23
|
parameters: teamMessageParametersSchema, outputSchema: teamMessageResultSchema,
|
|
31
24
|
async execute(id, args, signal, _update, ctx) {
|
|
32
25
|
access.check(); signal?.throwIfAborted();
|
|
33
|
-
|
|
34
|
-
requireThat(valid, "未知的团队消息 action:" + args.action);
|
|
35
|
-
requireThat(valid(args), "团队消息 " + args.action + " 参数无效:" + JSON.stringify(valid.errors));
|
|
36
|
-
return executeTeamMessage(service, args, actor(ctx), id);
|
|
26
|
+
return executeTeamMessage(service, teamMessageInput(args), actor(ctx), id);
|
|
37
27
|
},
|
|
38
28
|
});
|
|
39
29
|
}
|
package/src/ui/dsh/management.ts
CHANGED
|
@@ -90,8 +90,6 @@ export function showManagement(ctx: Context, parentSessionId: SessionId) {
|
|
|
90
90
|
const counts = note(""), workspaceInfo = group(status); status.querySelector("header")!.after(counts); counts.classList.add("pbot-counts");
|
|
91
91
|
const materials = group(status, "pbot-setting"); materials.append(element("h3", "资料目录"));
|
|
92
92
|
const initializeButton = button(materials, "准备目录", async () => { await command("init", undefined, "工作区已初始化并启用。"); });
|
|
93
|
-
const pythonCard = group(status, "pbot-setting"), pythonInfo = group(pythonCard);
|
|
94
|
-
const pythonButton = button(pythonCard, "准备 Python", async () => { await command("python setup", undefined, "Python 准备完成。"); });
|
|
95
93
|
const diagnostic = details(status, "环境详情"), statusBody = block(""); statusBody.classList.add("pbot-raw"); diagnostic.append(statusBody);
|
|
96
94
|
const permissions = group(status, "pbot-setting"); permissions.hidden = true;
|
|
97
95
|
let permissionKey = "";
|
|
@@ -383,27 +381,23 @@ export function showManagement(ctx: Context, parentSessionId: SessionId) {
|
|
|
383
381
|
counts.textContent = configuration.error ? "Personal Bot 配置错误" : "Personal Bot 未启用";
|
|
384
382
|
workspaceInfo.replaceChildren(facts([["状态", configuration.error ? "配置错误" : "未启用"], ["工作区", snapshot.workspaceRoot], ["配置文件", configuration.path]]),
|
|
385
383
|
note(configuration.error ? "修复配置文件后执行 /pbot init。" : "执行 /pbot init,或点击下方按钮初始化并启用。"));
|
|
386
|
-
pythonInfo.replaceChildren(note("启用工作区后自动准备共享 Python 环境。"));
|
|
387
384
|
materials.hidden = false; initializeButton.textContent = "初始化并启用";
|
|
388
385
|
enabled(initializeButton, !configuration.error);
|
|
389
386
|
for (const [id, control] of tabs) enabled(control, id === "status");
|
|
390
|
-
|
|
387
|
+
activate("status");
|
|
391
388
|
statusBody.textContent = JSON.stringify(snapshot, null, 2);
|
|
392
389
|
if (configuration.error) inform(text(configuration.error), "error");
|
|
393
390
|
return;
|
|
394
391
|
}
|
|
395
392
|
for (const control of tabs.values()) enabled(control, true);
|
|
396
393
|
materials.hidden = false; initializeButton.textContent = "准备目录"; enabled(initializeButton, true);
|
|
397
|
-
const agents = rows(snapshot.agents), teams = rows(snapshot.teams),
|
|
394
|
+
const agents = rows(snapshot.agents), teams = rows(snapshot.teams), history = record(snapshot.history);
|
|
398
395
|
tabCounts.get("experts")!.textContent = text(agents.length); tabCounts.get("teams")!.textContent = text(teams.length);
|
|
399
396
|
const active = agents.filter(agent => ["starting", "busy", "stopping"].includes(text(agent.state))).length;
|
|
400
397
|
counts.textContent = `Personal Bot 已启动 · 专家 ${agents.length} · 执行中 ${active} · 团队 ${teams.length}`;
|
|
401
398
|
const model = object(snapshot.model) ? snapshot.model : {};
|
|
402
399
|
workspaceInfo.replaceChildren(facts([["状态", "已启动"], ["工作区", snapshot.workspaceRoot], ["配置文件", record(snapshot.configuration).path], ["模型", model.model || "尚未选择"], ["Provider", model.provider || "—"],
|
|
403
400
|
["历史", history.organizing ? "整理中" : history.pending === null ? "查询时更新索引" : `${history.pending} 项待整理`]]));
|
|
404
|
-
pythonInfo.replaceChildren(element("h3", "Python"), badge(python.state));
|
|
405
|
-
if (python.error) pythonInfo.append(element("p", text(python.error), "pbot-warning"));
|
|
406
|
-
enabled(pythonButton, python.state !== "preparing");
|
|
407
401
|
const { agents: _agents, teams: _teams, ...summary } = snapshot; statusBody.textContent = JSON.stringify(summary, null, 2);
|
|
408
402
|
const pending = rows(snapshot.permissions), nextPermissionKey = pending.map(request => text(request.agentId) + ":" + text(request.requestId)).join(",");
|
|
409
403
|
permissions.hidden = !pending.length;
|
package/src/ui/dsh/styles.ts
CHANGED
|
@@ -62,9 +62,9 @@ export const managementStyles = `
|
|
|
62
62
|
.pbot-card > :is(h3, .pbot-between) { margin-bottom: 12px; }
|
|
63
63
|
.pbot-badge { display: inline-flex; align-items: center; gap: 6px; flex-shrink: 0; color: var(--pbot-muted); background: var(--pbot-bg); padding: 3px 8px; border-radius: 6px; font-size: 12px; font-weight: 500; white-space: nowrap; }
|
|
64
64
|
.pbot-badge::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
|
|
65
|
-
.pbot-badge:is([data-state=busy],[data-state=running],[data-state=starting]
|
|
65
|
+
.pbot-badge:is([data-state=busy],[data-state=running],[data-state=starting]) { color: var(--pbot-accent); background: var(--pbot-tint); }
|
|
66
66
|
.pbot-badge:is([data-state=error],[data-state=failed]) { color: var(--pbot-danger); }
|
|
67
|
-
.pbot-badge
|
|
67
|
+
.pbot-badge[data-state=completed] { color: var(--dsw-alias-state-success-primary, #26834b); }
|
|
68
68
|
.pbot-badge:is([data-state=paused],[data-state=stopping]) { color: var(--dsw-alias-state-warn-label, #9a6500); }
|
|
69
69
|
.pbot-facts { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 7px 18px; margin: 12px 0; font-size: 13px; }
|
|
70
70
|
.pbot-facts dt { color: var(--pbot-muted); }
|
package/src/ui/presentation.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
const states: Record<string, string> = {
|
|
2
2
|
starting: "启动中", busy: "执行中", idle: "待命", stopping: "停止中", stopped: "已停止", error: "需要处理",
|
|
3
3
|
running: "进行中", paused: "已暂停", finished: "已结束", completed: "已完成", failed: "失败",
|
|
4
|
-
cancelled: "已取消", interrupted: "已中断",
|
|
4
|
+
cancelled: "已取消", interrupted: "已中断",
|
|
5
5
|
open: "待安排", closed: "已关闭",
|
|
6
6
|
};
|
|
7
7
|
export const stateLabel = (state: unknown) => states[String(state)] ?? String(state ?? "未知");
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import type { Json } from "../common/json.js";
|
|
2
|
-
interface ProcessResult {
|
|
3
|
-
success: boolean;
|
|
4
|
-
data: Json;
|
|
5
|
-
raw: Json;
|
|
6
|
-
}
|
|
7
|
-
export declare function processEnvironment(env: Record<string, string>): {
|
|
8
|
-
PATH: string;
|
|
9
|
-
LANG: string;
|
|
10
|
-
};
|
|
11
|
-
export declare function runCommand(command: string, args: string[], input: string | undefined, cwd: string, env: Record<string, string>, signal?: AbortSignal, options?: {
|
|
12
|
-
timeoutMs?: number;
|
|
13
|
-
}): Promise<ProcessResult>;
|
|
14
|
-
export {};
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import { spawn } from "node:child_process";
|
|
2
|
-
export function processEnvironment(env) {
|
|
3
|
-
return { PATH: process.env.PATH ?? "/usr/bin:/bin", LANG: "C.UTF-8", ...env };
|
|
4
|
-
}
|
|
5
|
-
export async function runCommand(command, args, input, cwd, env, signal, options = {}) {
|
|
6
|
-
signal?.throwIfAborted();
|
|
7
|
-
return new Promise(resolve => {
|
|
8
|
-
const child = spawn(command, args, { cwd, env: processEnvironment(env), shell: false,
|
|
9
|
-
detached: true, stdio: ["pipe", "pipe", "pipe"] });
|
|
10
|
-
let bytes = 0, failed = false;
|
|
11
|
-
const out = [], err = [];
|
|
12
|
-
const kill = () => { if (child.pid) {
|
|
13
|
-
try {
|
|
14
|
-
process.kill(-child.pid, "SIGKILL");
|
|
15
|
-
}
|
|
16
|
-
catch { /* Already stopped. */ }
|
|
17
|
-
} };
|
|
18
|
-
const stop = () => { failed = true; kill(); };
|
|
19
|
-
const timer = setTimeout(stop, options.timeoutMs ?? 30_000);
|
|
20
|
-
signal?.addEventListener("abort", stop, { once: true });
|
|
21
|
-
const collect = (target) => (chunk) => {
|
|
22
|
-
bytes += chunk.length;
|
|
23
|
-
if (bytes > 2 * 1024 * 1024)
|
|
24
|
-
stop();
|
|
25
|
-
else
|
|
26
|
-
target.push(chunk);
|
|
27
|
-
};
|
|
28
|
-
child.stdout.on("data", collect(out));
|
|
29
|
-
child.stderr.on("data", collect(err));
|
|
30
|
-
child.on("error", stop);
|
|
31
|
-
child.stdin.on("error", stop);
|
|
32
|
-
child.once("close", code => {
|
|
33
|
-
clearTimeout(timer);
|
|
34
|
-
signal?.removeEventListener("abort", stop);
|
|
35
|
-
kill();
|
|
36
|
-
const text = Buffer.concat(out).toString("utf8");
|
|
37
|
-
let data = { stdout: text, stderr: Buffer.concat(err).toString("utf8"), exitCode: code };
|
|
38
|
-
try {
|
|
39
|
-
data = JSON.parse(text);
|
|
40
|
-
}
|
|
41
|
-
catch { /* Preserve text and exit code. */ }
|
|
42
|
-
resolve({ success: !failed && !signal?.aborted && code === 0, data, raw: { stdout: text, stderr: Buffer.concat(err).toString("utf8"), exitCode: code, incomplete: failed || !!signal?.aborted } });
|
|
43
|
-
});
|
|
44
|
-
if (signal?.aborted)
|
|
45
|
-
stop();
|
|
46
|
-
child.stdin.end(input);
|
|
47
|
-
});
|
|
48
|
-
}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { delimiter, join } from "node:path";
|
|
2
|
-
/** Like venv activation, scoped to this Pi process; never edits shell configuration. */
|
|
3
|
-
export function activatePython(directory) {
|
|
4
|
-
const values = {
|
|
5
|
-
PATH: join(directory, "bin") + delimiter + (process.env.PATH ?? "/usr/bin:/bin"),
|
|
6
|
-
VIRTUAL_ENV: directory,
|
|
7
|
-
PYTHONHOME: undefined,
|
|
8
|
-
PYTHONPATH: undefined,
|
|
9
|
-
PYTHONNOUSERSITE: "1",
|
|
10
|
-
};
|
|
11
|
-
const previous = new Map(Object.keys(values).map(key => [key, process.env[key]]));
|
|
12
|
-
const assign = (key, value) => {
|
|
13
|
-
if (value === undefined)
|
|
14
|
-
delete process.env[key];
|
|
15
|
-
else
|
|
16
|
-
process.env[key] = value;
|
|
17
|
-
};
|
|
18
|
-
for (const [key, value] of Object.entries(values))
|
|
19
|
-
assign(key, value);
|
|
20
|
-
let restored = false;
|
|
21
|
-
return () => {
|
|
22
|
-
if (restored)
|
|
23
|
-
return;
|
|
24
|
-
restored = true;
|
|
25
|
-
for (const [key, value] of previous)
|
|
26
|
-
if (process.env[key] === values[key])
|
|
27
|
-
assign(key, value);
|
|
28
|
-
};
|
|
29
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
export declare class PythonEnvironmentService {
|
|
2
|
-
#private;
|
|
3
|
-
private readonly root;
|
|
4
|
-
constructor(root: string);
|
|
5
|
-
get status(): {
|
|
6
|
-
state: "unprepared" | "preparing" | "ready" | "error";
|
|
7
|
-
directory?: string;
|
|
8
|
-
error?: string;
|
|
9
|
-
};
|
|
10
|
-
private run;
|
|
11
|
-
inspect(signal?: AbortSignal): Promise<{
|
|
12
|
-
state: "unprepared" | "preparing" | "ready" | "error";
|
|
13
|
-
directory?: string;
|
|
14
|
-
error?: string;
|
|
15
|
-
}>;
|
|
16
|
-
setup(signal?: AbortSignal): Promise<{
|
|
17
|
-
directory: string;
|
|
18
|
-
python: string;
|
|
19
|
-
}>;
|
|
20
|
-
close(): Promise<void>;
|
|
21
|
-
}
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import { join } from "node:path";
|
|
2
|
-
import { object } from "../../common/json.js";
|
|
3
|
-
import { runCommand } from "../../integrations/process.js";
|
|
4
|
-
import { requireThat } from "../../common/validation.js";
|
|
5
|
-
import { resourceRoot } from "../../common/paths.js";
|
|
6
|
-
export class PythonEnvironmentService {
|
|
7
|
-
root;
|
|
8
|
-
#shutdown = new AbortController();
|
|
9
|
-
#pending;
|
|
10
|
-
#status = { state: "unprepared" };
|
|
11
|
-
constructor(root) {
|
|
12
|
-
this.root = root;
|
|
13
|
-
}
|
|
14
|
-
get status() { return { ...this.#status }; }
|
|
15
|
-
async run(checkOnly, signal) {
|
|
16
|
-
const environment = {};
|
|
17
|
-
for (const [key, value] of Object.entries(process.env))
|
|
18
|
-
if (value !== undefined)
|
|
19
|
-
environment[key] = value;
|
|
20
|
-
const result = await runCommand("/bin/sh", ["-c", 'exec "$(command -v python3 || command -v python)" "$@"',
|
|
21
|
-
"pbot-python", "-I", "-B", join(resourceRoot, "../scripts/setup-python.py"), ...(checkOnly ? ["--check"] : [])], undefined, this.root, environment, signal, { timeoutMs: 15 * 60_000 });
|
|
22
|
-
signal.throwIfAborted();
|
|
23
|
-
requireThat(result.success && object(result.data) && typeof result.data.directory === "string" && typeof result.data.python === "string", "共享 Python 环境未就绪;修复后执行 Python 准备入口。\n" + JSON.stringify(result.data).slice(-6000));
|
|
24
|
-
return { directory: result.data.directory, python: result.data.python, action: result.data.action };
|
|
25
|
-
}
|
|
26
|
-
async inspect(signal) {
|
|
27
|
-
const cancel = signal ? AbortSignal.any([this.#shutdown.signal, signal]) : this.#shutdown.signal;
|
|
28
|
-
try {
|
|
29
|
-
const result = await this.run(true, cancel);
|
|
30
|
-
this.#status = result.action === "verify" ? { state: "ready", directory: result.directory } : { state: "unprepared" };
|
|
31
|
-
return this.status;
|
|
32
|
-
}
|
|
33
|
-
catch (error) {
|
|
34
|
-
this.#status = { state: "error", error: error instanceof Error ? error.message : String(error) };
|
|
35
|
-
throw error;
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
setup(signal) {
|
|
39
|
-
const cancel = signal ? AbortSignal.any([this.#shutdown.signal, signal]) : this.#shutdown.signal;
|
|
40
|
-
if (cancel.aborted)
|
|
41
|
-
return Promise.reject(cancel.reason);
|
|
42
|
-
if (this.#pending)
|
|
43
|
-
return this.#pending;
|
|
44
|
-
this.#status = { state: "preparing" };
|
|
45
|
-
this.#pending = (async () => {
|
|
46
|
-
try {
|
|
47
|
-
const result = await this.run(false, cancel);
|
|
48
|
-
const ready = { directory: result.directory, python: result.python };
|
|
49
|
-
this.#status = { state: "ready", directory: ready.directory };
|
|
50
|
-
return ready;
|
|
51
|
-
}
|
|
52
|
-
catch (error) {
|
|
53
|
-
this.#status = { state: "error", error: error instanceof Error ? error.message : String(error) };
|
|
54
|
-
throw error;
|
|
55
|
-
}
|
|
56
|
-
finally {
|
|
57
|
-
this.#pending = undefined;
|
|
58
|
-
}
|
|
59
|
-
})();
|
|
60
|
-
return this.#pending;
|
|
61
|
-
}
|
|
62
|
-
async close() {
|
|
63
|
-
this.#shutdown.abort();
|
|
64
|
-
await this.#pending?.catch(() => undefined);
|
|
65
|
-
}
|
|
66
|
-
}
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import { Type } from "typebox";
|
|
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>;
|
|
6
|
-
provider: Type.TOptional<Type.TString>;
|
|
7
|
-
model: Type.TOptional<Type.TString>;
|
|
8
|
-
thinking: Type.TOptional<Type.TString>;
|
|
9
|
-
files: Type.TOptional<Type.TArray<Type.TString>>;
|
|
10
|
-
tools: Type.TOptional<Type.TArray<Type.TString>>;
|
|
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>;
|
|
15
|
-
agentId: Type.TOptional<Type.TString>;
|
|
16
|
-
cwd: Type.TOptional<Type.TString>;
|
|
17
|
-
message: Type.TOptional<Type.TString>;
|
|
18
|
-
delivery: Type.TOptional<Type.TUnion<[Type.TLiteral<"steer">, Type.TLiteral<"followUp">]>>;
|
|
19
|
-
prompts: Type.TOptional<Type.TArray<Type.TString>>;
|
|
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">]>;
|
|
21
|
-
offset: Type.TOptional<Type.TInteger>;
|
|
22
|
-
limit: Type.TOptional<Type.TInteger>;
|
|
23
|
-
}>;
|
|
24
|
-
export declare const dshAgentActionSchema: Type.TUnion<(Type.TObject<{
|
|
25
|
-
backend: Type.TOptional<Type.TUnion<[Type.TLiteral<"pi">, Type.TLiteral<"dsh">, Type.TLiteral<"claude">]>>;
|
|
26
|
-
name: Type.TOptional<Type.TString>;
|
|
27
|
-
message: Type.TOptional<Type.TString>;
|
|
28
|
-
files: Type.TOptional<Type.TArray<Type.TString>>;
|
|
29
|
-
prompts: Type.TOptional<Type.TArray<Type.TString>>;
|
|
30
|
-
provider: Type.TOptional<Type.TString>;
|
|
31
|
-
model: Type.TOptional<Type.TString>;
|
|
32
|
-
thinking: Type.TOptional<Type.TString>;
|
|
33
|
-
cwd: Type.TOptional<Type.TString>;
|
|
34
|
-
tools: Type.TOptional<Type.TArray<Type.TString>>;
|
|
35
|
-
noExtensions: Type.TOptional<Type.TBoolean>;
|
|
36
|
-
noSkills: Type.TOptional<Type.TBoolean>;
|
|
37
|
-
noPromptTemplates: Type.TOptional<Type.TBoolean>;
|
|
38
|
-
noContextFiles: Type.TOptional<Type.TBoolean>;
|
|
39
|
-
action: Type.TLiteral<"start">;
|
|
40
|
-
}> | Type.TObject<{
|
|
41
|
-
action: Type.TLiteral<"list">;
|
|
42
|
-
}> | Type.TObject<{
|
|
43
|
-
action: Type.TLiteral<string>;
|
|
44
|
-
agentId: Type.TString;
|
|
45
|
-
}>)[]>;
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { Type } from "../../common/typebox.js";
|
|
2
|
-
import { agentActionSchema, agentParametersSchema, agentStartOptions } from "./contract.js";
|
|
3
|
-
const options = Type.Omit(Type.Object(agentStartOptions), ["provider", "model", "thinking", "files", "tools", "noExtensions", "noPromptTemplates", "noContextFiles", "noSkills"]).properties;
|
|
4
|
-
const native = {
|
|
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
|
-
};
|
|
12
|
-
const omitted = ["noExtensions", "noPromptTemplates", "noContextFiles", "provider", "model", "thinking", "files", "tools", "noSkills"];
|
|
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 });
|
|
16
|
-
export const dshAgentActionSchema = Type.Union(agentActionSchema.anyOf.map(row => row.properties.action.const === "start"
|
|
17
|
-
? Type.Object({ action: Type.Literal("start"), ...options, ...native,
|
|
18
|
-
noExtensions: agentStartOptions.noExtensions, noPromptTemplates: agentStartOptions.noPromptTemplates, noContextFiles: agentStartOptions.noContextFiles,
|
|
19
|
-
}, { additionalProperties: false }) : row));
|