personal-bot 0.2.6 → 0.2.8
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 +47 -13
- package/README.zh-CN.md +46 -12
- package/docs/README.md +4 -2
- package/docs/agent-collaboration.md +4 -4
- package/docs/capability-design.md +12 -6
- package/docs/dsh-implementation-plan.md +9 -7
- package/docs/dsh-support-proposal.md +6 -22
- package/docs/dsh.en.md +333 -0
- package/docs/dsh.md +346 -48
- package/docs/file-storage.md +1 -1
- package/docs/history.md +2 -0
- package/docs/installation-design.md +7 -4
- package/docs/model-context.md +60 -0
- package/docs/model-instruction-guidelines.md +51 -0
- package/docs/release.md +10 -6
- package/docs/subagent-upgrade-proposal.md +1 -1
- package/docs/technical-design.md +21 -15
- package/docs/validation.md +64 -7
- package/lib/dsh.js +4 -0
- package/lib/extension/dsh/agent-events.js +1 -1
- package/lib/extension/dsh/agent-runtime.js +8 -5
- package/lib/integrations/dsh/resources.d.ts +1 -1
- package/lib/integrations/dsh/resources.js +14 -14
- package/lib/integrations/dsh/session.js +1 -0
- package/lib/integrations/installation/pi-bridge.js +9 -9
- package/lib/integrations/team-context.js +7 -3
- package/lib/services/agents/agent-notices.js +2 -2
- package/lib/services/agents/team-service.js +1 -1
- package/lib/tools/agents/contract.d.ts +1 -1
- package/lib/tools/agents/contract.js +7 -7
- package/lib/tools/agents/dsh-contract.js +4 -4
- package/lib/tools/history/contract.d.ts +1 -1
- package/lib/tools/history/contract.js +2 -2
- package/lib/tools/teams/contract.d.ts +2 -2
- package/lib/tools/teams/contract.js +11 -11
- package/npm-shrinkwrap.json +30 -25
- package/package.json +28 -25
- package/python/README.md +1 -1
- package/resources/agents/coordinator.md +5 -33
- package/resources/agents/general-purpose.md +3 -15
- package/resources/prompts/history-summary.md +1 -1
- package/resources/prompts/team-member.md +7 -0
- package/resources/prompts/workspace.md +13 -24
- package/resources/references/compute-finance.md +22 -0
- package/resources/references/compute.md +11 -88
- package/resources/references/task-conductor.md +20 -15
- package/resources/skills/project-maintenance/SKILL.md +9 -11
- package/resources/skills/provider-connections/SKILL.md +7 -7
- package/scripts/README.md +1 -1
- package/src/dsh.ts +4 -0
- package/src/extension/agent-events.ts +17 -4
- package/src/extension/command.ts +1 -1
- package/src/extension/dsh/agent-events.ts +1 -1
- package/src/extension/dsh/agent-runtime.ts +7 -6
- package/src/extension/events.ts +14 -9
- package/src/extension/subagent-entry.ts +24 -16
- package/src/integrations/dsh/resources.ts +17 -14
- package/src/integrations/dsh/session.ts +2 -0
- package/src/integrations/installation/pi-bridge.ts +9 -7
- package/src/integrations/pi/agent-context.ts +1 -1
- package/src/integrations/team-context.ts +7 -3
- package/src/services/agents/agent-notices.ts +2 -2
- package/src/services/agents/team-service.ts +1 -1
- package/src/tools/agents/contract.ts +7 -7
- package/src/tools/agents/dsh-contract.ts +4 -4
- package/src/tools/history/contract.ts +2 -2
- package/src/tools/register.ts +1 -7
- package/src/tools/teams/contract.ts +11 -11
- package/resources/prompts/tool-guidelines.md +0 -3
|
@@ -1,5 +1,8 @@
|
|
|
1
|
+
import { readFileSync } from "node:fs";
|
|
2
|
+
import { join } from "node:path";
|
|
1
3
|
import type { TeamLink, TeamMessage } from "../model/team.js";
|
|
2
4
|
import { markdownBlock } from "../common/markdown.js";
|
|
5
|
+
import { resourceRoot } from "../common/paths.js";
|
|
3
6
|
|
|
4
7
|
type MessagePage = Pick<TeamMessage, "seq" | "author" | "text" | "replyTo" | "runId" | "source"> & {
|
|
5
8
|
offset: number; totalLength: number; nextOffset: number | null;
|
|
@@ -22,7 +25,7 @@ function messageMarkdown(message: MessagePage): string {
|
|
|
22
25
|
export function teamMessagesMarkdown(page: { teamId: string; messages: MessagePage[]; lastSeq: number; nextAfterSeq: number | null }): string {
|
|
23
26
|
return ["# 团队公共消息", "", "- `teamId`: `" + page.teamId + "`", "- `lastSeq`: `" + page.lastSeq + "`",
|
|
24
27
|
"- `nextAfterSeq`: `" + page.nextAfterSeq + "`", "",
|
|
25
|
-
"
|
|
28
|
+
"nextOffset 非空时先续读该条正文,再读取后续消息。", "",
|
|
26
29
|
page.messages.map(messageMarkdown).join("\n\n")].join("\n");
|
|
27
30
|
}
|
|
28
31
|
|
|
@@ -30,7 +33,8 @@ export function teamBrief(link: TeamLink): string {
|
|
|
30
33
|
return ["# 团队协作", "", "- 团队:" + link.team.name, "- `teamId`: `" + link.team.teamId + "`",
|
|
31
34
|
"- 当前成员 `agentId`: `" + link.request.agentId + "`", "- `runId`: `" + link.run.runId + "`",
|
|
32
35
|
"- 轮次:" + link.request.round + " / " + link.run.rounds, "", "## 共同目标", "", link.team.brief,
|
|
33
|
-
"", "## 成员职责", "", ...link.team.members.flatMap(member => ["### " + member.agentId, "", member.role, ""])
|
|
36
|
+
"", "## 成员职责", "", ...link.team.members.flatMap(member => ["### " + member.agentId, "", member.role, ""]),
|
|
37
|
+
readFileSync(join(resourceRoot, "prompts/team-member.md"), "utf8").trim()].join("\n");
|
|
34
38
|
}
|
|
35
39
|
|
|
36
40
|
export function createTeamContext(link: TeamLink, seen: ReadonlySet<number>, throughSeq = link.team.messages.length) {
|
|
@@ -54,7 +58,7 @@ export function createTeamContext(link: TeamLink, seen: ReadonlySet<number>, thr
|
|
|
54
58
|
const seqs = messages.map(m => m.seq);
|
|
55
59
|
return { content: ["# 团队公共上下文", "", "- `teamId`: `" + link.team.teamId + "`", "- `throughSeq`: `" + throughSeq + "`",
|
|
56
60
|
"- `remainingFromSeq`: `" + (pending[messages.length]?.seq ?? null) + "`", "",
|
|
57
|
-
"
|
|
61
|
+
"未包含或被截断的正文用 pbot_team_message read 读取。remainingFromSeq 非空时,用 afterSeq: remainingFromSeq - 1 读取未包含的消息。", "",
|
|
58
62
|
messages.map(messageMarkdown).join("\n\n")].join("\n"),
|
|
59
63
|
seqs };
|
|
60
64
|
}
|
|
@@ -8,7 +8,7 @@ export function teamNotice(values: ReturnType<TeamService["notifications"]>, kno
|
|
|
8
8
|
const notes = values.filter(value => !known.has(value.key)).slice(0, 8);
|
|
9
9
|
if (!notes.length) return;
|
|
10
10
|
return { kind: "teams" as const, keys: notes.map(value => value.key), content: ["# 团队批次状态", "",
|
|
11
|
-
"
|
|
11
|
+
"团队批次状态已变化,用 pbot_team status/read 查看状态和结果。暂停时可能仍有在途工作,重跑前先查看原请求结果。", "",
|
|
12
12
|
notes.map(value => ["## " + value.name, "", "- `teamId`: `" + value.teamId + "`", "- `runId`: `" + value.runId + "`",
|
|
13
13
|
"- 状态:" + value.state, "- 在途工作:" + value.activeCount, ...(value.reason ? ["", "### 原因", "", value.reason] : [])].join("\n")).join("\n\n")].join("\n") };
|
|
14
14
|
}
|
|
@@ -20,7 +20,7 @@ export function agentNotice(values: AgentCompletion[], links: ReadonlyMap<string
|
|
|
20
20
|
if (!batch.length) return;
|
|
21
21
|
return { kind: "agents" as const, keys: batch.map(value => value.agentId + ":" + value.cycle.cycleId),
|
|
22
22
|
content: "# 子会话工作结果\n\n子会话工作已结束。完整报告用 pbot_agent read 读取,指定对应 agentId 和 cycle.cycleId;nextOffset 非空时沿用该 cycleId 续读。\n\n" +
|
|
23
|
-
(batch.some(value => value.cycle.source !== "parent") ? "
|
|
23
|
+
(batch.some(value => value.cycle.source !== "parent") ? "部分结果包含人工子会话输入,来源见 cycle.source。\n\n" : "") +
|
|
24
24
|
batch.map(value => "## " + value.name + "\n\n" + markdownFields(json({ agentId: value.agentId,
|
|
25
25
|
cycle: { cycleId: value.cycle.cycleId, state: value.cycle.state, source: value.cycle.source, requestIds: value.cycle.requestIds,
|
|
26
26
|
...(value.cycle.error === undefined ? {} : { error: value.cycle.error }) },
|
|
@@ -249,7 +249,7 @@ export class TeamService {
|
|
|
249
249
|
const q = { requestId: randomUUID(), agentId: m.agentId, generation: run.generations[m.agentId]!, round: nextRound, throughSeq: team.messages.length };
|
|
250
250
|
run.issued.push(q); slots--; changed = true;
|
|
251
251
|
inputs.push({ ...q, teamId: team.teamId, runId: run.runId,
|
|
252
|
-
message: ["# 团队发言任务", "", "
|
|
252
|
+
message: ["# 团队发言任务", "", "执行本次团队发言安排。最终答复将公开给全体成员。", "",
|
|
253
253
|
"- `teamId`: `" + team.teamId + "`", "- `runId`: `" + run.runId + "`", "- 轮次:" + q.round,
|
|
254
254
|
"", "## 本批次要求", "", run.instruction].join("\n") });
|
|
255
255
|
}
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import { Type } from "typebox";
|
|
2
2
|
|
|
3
|
-
export const agentDescription = "
|
|
3
|
+
export const agentDescription = "委派专家并继续对话。start 启动后即返回,完成自动通知,无需轮询;省略初始输入时待命。send 继续对话,团队占用期间不可私人 send。status 查看状态,read 读取报告;读取已结束周期即领取其通知,包括部分读取。续读固定 cycle.cycleId 并使用 nextOffset。state 表示执行状态,cycle.state 表示工作结果,queued 只表示入队。stop 保留历史,resume 携新 message 继续。每个父会话最多 50 个存活专家,空闲也计入。";
|
|
4
4
|
|
|
5
5
|
const id = Type.String({ minLength: 1, maxLength: 128 });
|
|
6
|
-
const message = Type.String({ minLength: 1, maxLength: 24000, description: "
|
|
6
|
+
const message = Type.String({ minLength: 1, maxLength: 24000, description: "本次目标、相关资料、约束和交付要求。" });
|
|
7
7
|
const name = Type.String({ minLength: 1, maxLength: 64, pattern: "^[^\\r\\n\\x00-\\x1f]+$" });
|
|
8
8
|
export const agentStartOptions = {
|
|
9
9
|
name: Type.Optional(name), message: Type.Optional(message),
|
|
10
10
|
files: Type.Optional(Type.Array(Type.String({ minLength: 1 }), { maxItems: 32, description: "随初始消息读取的文件;相对路径基于原工作区根目录。" })),
|
|
11
|
-
prompts: Type.Optional(Type.Array(message, { maxItems: 32, description: "与 message
|
|
11
|
+
prompts: Type.Optional(Type.Array(message, { maxItems: 32, description: "与 message 按顺序合并为同一初始消息。" })),
|
|
12
12
|
provider: Type.Optional(Type.String({ ...id, description: "Pi 模型提供方,默认继承主会话。" })),
|
|
13
|
-
model: Type.Optional(Type.String({ ...id, description: "
|
|
13
|
+
model: Type.Optional(Type.String({ ...id, description: "Pi 模型 ID,默认继承主会话。" })),
|
|
14
14
|
thinking: Type.Optional(Type.Union([Type.Literal("off"), Type.Literal("minimal"), Type.Literal("low"), Type.Literal("medium"), Type.Literal("high"), Type.Literal("xhigh"), Type.Literal("max")], { description: "默认继承主会话思考级别。" })),
|
|
15
15
|
cwd: Type.Optional(Type.String({ minLength: 1, description: "执行目录,相对原工作区根目录;省略时使用工作区根目录。" })),
|
|
16
|
-
tools: Type.Optional(Type.Array(id, { minItems: 1, description: "按 Pi
|
|
16
|
+
tools: Type.Optional(Type.Array(id, { minItems: 1, description: "按 Pi 规则选择工具,省略时使用默认工具;MCP 工具按当前配置提供。" })),
|
|
17
17
|
noExtensions: Type.Optional(Type.Boolean({ description: "默认 true,不发现其他扩展。" })),
|
|
18
18
|
noSkills: Type.Optional(Type.Boolean({ description: "关闭技能发现,默认 false。" })),
|
|
19
19
|
noPromptTemplates: Type.Optional(Type.Boolean({ description: "关闭提示模板发现,默认 false。" })),
|
|
@@ -42,7 +42,7 @@ export const agentActionSchema = Type.Union([
|
|
|
42
42
|
]);
|
|
43
43
|
|
|
44
44
|
const cycle = Type.Object({ cycleId: Type.String(), startedAt: Type.Number(), finishedAt: Type.Optional(Type.Number()),
|
|
45
|
-
state: Type.Union([Type.Literal("running"), Type.Literal("completed"), Type.Literal("failed"), Type.Literal("cancelled"), Type.Literal("interrupted")], { description: "
|
|
45
|
+
state: Type.Union([Type.Literal("running"), Type.Literal("completed"), Type.Literal("failed"), Type.Literal("cancelled"), Type.Literal("interrupted")], { description: "本周期的工作结果,正文用 read 读取。" }),
|
|
46
46
|
requestIds: Type.Array(Type.String()),
|
|
47
47
|
source: Type.Union([Type.Literal("parent"), Type.Literal("interactive"), Type.Literal("mixed")]), error: Type.Optional(Type.String()),
|
|
48
48
|
}, { additionalProperties: false });
|
|
@@ -52,7 +52,7 @@ export const agentViewSchema = Type.Object({ agentId: Type.String(), name: Type.
|
|
|
52
52
|
activity: Type.String(), cycle: Type.Optional(cycle), error: Type.Optional(Type.String()),
|
|
53
53
|
requestId: Type.Optional(Type.String()), messageStatus: Type.Optional(Type.Literal("queued", { description: "消息已入队,不代表模型已阅读或完成。" })),
|
|
54
54
|
cycles: Type.Optional(Type.Array(Type.Object({ cycleId: Type.String(), state: Type.String() }), { description: "仅 read 返回:可读取的周期索引。" })),
|
|
55
|
-
report: Type.Optional(Type.String({ description: "仅 read
|
|
55
|
+
report: Type.Optional(Type.String({ description: "仅 read 返回:选定周期的报告正文片段。" })),
|
|
56
56
|
totalLength: Type.Optional(Type.Integer({ description: "仅 read 返回:完整报告的 UTF-16 字符数。" })),
|
|
57
57
|
nextOffset: Type.Optional(Type.Union([Type.Integer(), Type.Null()], { description: "仅 read 返回:null 表示本报告已读完;否则以相同 agentId、cycle.cycleId 和此 offset 继续。" })),
|
|
58
58
|
}, { additionalProperties: false });
|
|
@@ -5,10 +5,10 @@ const options = Type.Omit(Type.Object(agentStartOptions), ["provider", "model",
|
|
|
5
5
|
const native = {
|
|
6
6
|
provider: Type.Optional(Type.String({ minLength: 1, maxLength: 128, description: "dsh 原生 provider route,默认继承父会话。" })),
|
|
7
7
|
model: Type.Optional(Type.String({ minLength: 1, maxLength: 128, description: "该 dsh provider 的模型 ID,默认继承父会话。" })),
|
|
8
|
-
thinking: Type.Optional(Type.String({ minLength: 1, maxLength: 128, description: "该 dsh
|
|
9
|
-
files: Type.Optional(Type.Array(Type.String({ minLength: 1 }), { maxItems: 32, description: "
|
|
10
|
-
tools: Type.Optional(Type.Array(Type.String({ minLength: 1 }), { minItems: 1, description: "
|
|
11
|
-
noSkills: Type.Optional(Type.Boolean({ description: "
|
|
8
|
+
thinking: Type.Optional(Type.String({ minLength: 1, maxLength: 128, description: "该 dsh 模型的 reasoning effort ID,默认继承父会话。" })),
|
|
9
|
+
files: Type.Optional(Type.Array(Type.String({ minLength: 1 }), { maxItems: 32, description: "附给专家的文件;相对原工作区根目录。图片大小与格式遵循 dsh 限制。" })),
|
|
10
|
+
tools: Type.Optional(Type.Array(Type.String({ minLength: 1 }), { minItems: 1, description: "能力工具名,不填写 run_code;省略时使用原生工具和 pbot_team_message。" })),
|
|
11
|
+
noSkills: Type.Optional(Type.Boolean({ description: "关闭该专家的技能目录和 skill 工具。" })),
|
|
12
12
|
};
|
|
13
13
|
const omitted = ["noExtensions", "noPromptTemplates", "noContextFiles", "provider", "model", "thinking", "files", "tools", "noSkills"] as const;
|
|
14
14
|
export const dshAgentParametersSchema = Type.Object({ ...Type.Omit(agentParametersSchema, omitted).properties, ...native }, { additionalProperties: false });
|
|
@@ -10,10 +10,10 @@ export const historyResultSchema = Type.Object({
|
|
|
10
10
|
total: Type.Optional(Type.Integer()), nextOffset: Type.Optional(nullableOffset),
|
|
11
11
|
node: Type.Optional(Type.Object({ ...node.properties, text: Type.String(), totalLength: Type.Integer(), nextOffset: nullableOffset,
|
|
12
12
|
parents: Type.Array(node), children: Type.Array(node), nextChildrenOffset: nullableOffset,
|
|
13
|
-
source: Type.Object({ host, sessionId: Type.String({ description: "原始宿主会话 ID
|
|
13
|
+
source: Type.Object({ host, sessionId: Type.String({ description: "原始宿主会话 ID。" }), entryIds: Type.Array(Type.String()) }), warnings: Type.Array(Type.String()) })),
|
|
14
14
|
warnings: Type.Array(Type.String()),
|
|
15
15
|
});
|
|
16
|
-
export const historyDescription = "查询当前工作区的 Pi
|
|
16
|
+
export const historyDescription = "查询当前工作区的 Pi/dsh 问答归档,host 可筛选来源。search 按不区分大小写的连续文本匹配原文和摘要;无匹配时换词,省略 query 列会话。read 按 parents/children 的 id 展开,nextOffset 续读正文,nextChildrenOffset 续读子节点。需要对话细节时读取 exchange 原文;需要工具日志时查所属宿主的原始会话。";
|
|
17
17
|
export const historyParameters = Type.Object({ action: Type.Union([Type.Literal("search"), Type.Literal("read")]),
|
|
18
18
|
host: Type.Optional(host), query: Type.Optional(Type.String()), sessionId: Type.Optional(Type.String()),
|
|
19
19
|
from: Type.Optional(Type.String({ description: "search:ISO 日期或时间,下界。" })),
|
package/src/tools/register.ts
CHANGED
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
import { readFileSync } from "node:fs";
|
|
2
|
-
import { join } from "node:path";
|
|
3
1
|
import type { ExtensionAPI, ToolDefinition } from "@earendil-works/pi-coding-agent";
|
|
4
|
-
import { resourceRoot } from "../common/paths.js";
|
|
5
2
|
import type { AgentService } from "../services/agents/agent-service.js";
|
|
6
3
|
import type { CallAccess } from "./access.js";
|
|
7
4
|
import { agentTool } from "./agents/tool.js";
|
|
@@ -18,11 +15,8 @@ export class ToolRegistry {
|
|
|
18
15
|
readonly #registered = new Map<string, ToolDefinition>();
|
|
19
16
|
constructor(private readonly pi: ExtensionAPI) {}
|
|
20
17
|
register(tools: ToolDefinition[]) {
|
|
21
|
-
const promptGuidelines = readFileSync(join(resourceRoot, "prompts/tool-guidelines.md"), "utf8")
|
|
22
|
-
.trim().split(/\r?\n\s*\r?\n/);
|
|
23
18
|
for (const definition of tools) {
|
|
24
|
-
const tool = { ...definition, namespace: { name: "pbot", description: "
|
|
25
|
-
promptGuidelines };
|
|
19
|
+
const tool = { ...definition, namespace: { name: "pbot", description: "历史查询、专家与团队协作。" } };
|
|
26
20
|
this.#registered.set(tool.name, tool); this.pi.registerTool(tool);
|
|
27
21
|
}
|
|
28
22
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Type } from "typebox";
|
|
2
2
|
|
|
3
|
-
export const teamDescription = "
|
|
4
|
-
export const teamMessageDescription = "
|
|
3
|
+
export const teamDescription = "组织固定成员协作。create 建立团队,run 开始一批讨论。运行时占用成员;pause 停止新安排,允许在途工作收尾,之后可私人 send;中止成员用 pbot_agent stop。close 保留成员和历史;换成员须关闭旧团队再创建。继续讨论用 run 提交新要求。成员最终答复向团队公开。";
|
|
4
|
+
export const teamMessageDescription = "读写团队公共原文。post 向全体成员发布信息,需要安排回答时由主会话调用 pbot_team run;成员只能在自己的团队工作中 post。read 用 afterSeq 翻页,长正文按 seq/offset 续读,先补完 nextOffset 非空的消息。";
|
|
5
5
|
|
|
6
6
|
import type { TSchema } from "typebox";
|
|
7
7
|
|
|
@@ -10,13 +10,13 @@ const text = Type.String({ minLength: 1, maxLength: 24000 });
|
|
|
10
10
|
const name = Type.String({ minLength: 1, maxLength: 64, pattern: "^[^\\r\\n\\x00-\\x1f]+$" });
|
|
11
11
|
const mode = Type.Union([Type.Literal("roundRobin"), Type.Literal("parallel")], { description: "run 必填:roundRobin 按成员顺序轮流发言;parallel 在并发上限内发言,全员本轮完成后才进入下一轮。" });
|
|
12
12
|
const members = Type.Array(Type.Object({ agentId: id, role: Type.String({ minLength: 1, maxLength: 4000 }) }, { additionalProperties: false }), {
|
|
13
|
-
minItems: 1, maxItems: 50, description: "仅 create
|
|
13
|
+
minItems: 1, maxItems: 50, description: "仅 create,必填:当前分支中的固定成员及职责;成员须版本兼容且未加入其他未关闭团队。",
|
|
14
14
|
});
|
|
15
15
|
const run = {
|
|
16
|
-
instruction: Type.String({ ...text, description: "仅 run
|
|
16
|
+
instruction: Type.String({ ...text, description: "仅 run,必填:本批次的任务、约束与交付要求。" }), mode,
|
|
17
17
|
rounds: Type.Optional(Type.Integer({ minimum: 1, maximum: 10, description: "仅 run:每位成员的轮数,默认 2。" })),
|
|
18
|
-
maxConcurrent: Type.Optional(Type.Integer({ minimum: 1, maximum: 50, description: "仅 run:roundRobin 默认且只允许 1;parallel 默认 min(2, 成员数)
|
|
19
|
-
timeoutSeconds: Type.Optional(Type.Integer({ minimum: 1, maximum: 86400, description: "仅 run:整批期限,默认 900
|
|
18
|
+
maxConcurrent: Type.Optional(Type.Integer({ minimum: 1, maximum: 50, description: "仅 run:roundRobin 默认且只允许 1;parallel 默认 min(2, 成员数)。不得超过成员数;待处理和执行中的发言都计入上限。" })),
|
|
19
|
+
timeoutSeconds: Type.Optional(Type.Integer({ minimum: 1, maximum: 86400, description: "仅 run:整批期限,默认 900 秒,包含所有轮次和等待。到期停止安排并尝试中止尚未人工接管的工作,之后仍须核对实际状态;pause 则允许在途工作收尾。" })),
|
|
20
20
|
};
|
|
21
21
|
const page = {
|
|
22
22
|
afterSeq: Type.Optional(Type.Integer({ minimum: 0, description: "仅 read:读取序号大于此值的消息,默认 0,不得超过 lastSeq。返回 nextAfterSeq 用于继续消息列表;单条续读使用 seq/offset,省略 afterSeq。先补完被截断的正文,再继续列表。" })),
|
|
@@ -27,7 +27,7 @@ const page = {
|
|
|
27
27
|
const object = <T extends Record<string, TSchema>>(fields: T) => Type.Object(fields, { additionalProperties: false });
|
|
28
28
|
export const teamParametersSchema = object({
|
|
29
29
|
action: Type.Union(["create", "list", "status", "read", "run", "pause", "close"].map(v => Type.Literal(v)), {
|
|
30
|
-
description: "create
|
|
30
|
+
description: "create 必填 name/brief/members;list 只接受 action;status/pause/close 必填 teamId;read 必填 teamId,可选 afterSeq/seq/offset/limit;run 必填 teamId/instruction/mode,可选 rounds/maxConcurrent/timeoutSeconds。只传对应 action 的字段。run 前须确认所有成员存活、idle、可参与团队且无待处理私人输入,团队未关闭,也无运行批次或在途工作。close 前先暂停并等待在途工作结束。",
|
|
31
31
|
}),
|
|
32
32
|
teamId: Type.Optional(id), name: Type.Optional(name), brief: Type.Optional(text), members: Type.Optional(members),
|
|
33
33
|
instruction: Type.Optional(run.instruction), mode: Type.Optional(mode), rounds: run.rounds, maxConcurrent: run.maxConcurrent, timeoutSeconds: run.timeoutSeconds, ...page,
|
|
@@ -42,7 +42,7 @@ export const teamActionSchema = Type.Union([
|
|
|
42
42
|
export const teamMessageParametersSchema = object({
|
|
43
43
|
action: Type.Union([Type.Literal("read"), Type.Literal("post")], {
|
|
44
44
|
description: "read 必填 teamId,只可选 afterSeq/seq/offset/limit,禁止 text/replyTo;post 必填 teamId/text,只可选 replyTo,禁止所有分页字段。",
|
|
45
|
-
}), teamId: id, text: Type.Optional(Type.String({ ...text, description: "仅 post
|
|
45
|
+
}), teamId: id, text: Type.Optional(Type.String({ ...text, description: "仅 post,必填:向全体成员公开的原文。" })),
|
|
46
46
|
replyTo: Type.Optional(Type.Integer({ minimum: 1, description: "仅 post:回复已有消息的 seq。" })), ...page,
|
|
47
47
|
});
|
|
48
48
|
export const teamMessageActionSchema = Type.Union([
|
|
@@ -59,10 +59,10 @@ export const teamPageSchema = object({ teamId: id, messages: Type.Array(message)
|
|
|
59
59
|
nextAfterSeq: Type.Union([Type.Integer(), Type.Null()], { description: "后续消息列表的 afterSeq;null 只表示列表已到末尾,仍须检查每条消息的 nextOffset。指定 seq 时始终为 null。" }) });
|
|
60
60
|
const ownedView = object({ teamId: id, name: Type.String(), brief: Type.String(), closed: Type.Boolean(), owned: Type.Literal(true),
|
|
61
61
|
members: Type.Array(object({ agentId: id, role: Type.String(), name: Type.String(), state: Type.String() })),
|
|
62
|
-
lastSeq: Type.Integer(), activeCount: Type.Integer({ description: "
|
|
62
|
+
lastSeq: Type.Integer(), activeCount: Type.Integer({ description: "各批次仍在途的请求数;paused 时也可能大于 0。" }),
|
|
63
63
|
unresolved: Type.Array(object({ requestId: id, agentId: id, runId: id, round: Type.Integer(), active: Type.Boolean(),
|
|
64
|
-
state: Type.String({ description: "queued
|
|
65
|
-
description: "
|
|
64
|
+
state: Type.String({ description: "queued=待处理;accepted=在途;uncertain=结果未确认;cancelled=未执行或已取消;unpublished=已完成但结果尚未公开;mixed/interactive=含人工或私人工作,不自动公开;failed/interrupted=失败或中断。" }), cycleId: Type.Optional(id) }), {
|
|
65
|
+
description: "各批次尚未确认完成且公开的请求。先核对原请求和实际结果,再决定后续操作,避免重复执行。",
|
|
66
66
|
}),
|
|
67
67
|
run: Type.Optional(object({ runId: id, instruction: Type.String(), mode, state: Type.Union([Type.Literal("running"), Type.Literal("paused"), Type.Literal("finished")]),
|
|
68
68
|
rounds: Type.Integer(), maxConcurrent: Type.Integer(), deadlineAt: Type.Number(), scheduled: Type.Integer(), published: Type.Integer(), reason: Type.Optional(Type.String()) })) });
|