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,7 +1,7 @@
|
|
|
1
1
|
import type { Context } from "@deepseek-ai/cordis";
|
|
2
2
|
import type { Agent, AgentHandle, AgentSetup } from "@deepseek-ai/dsh-agent";
|
|
3
3
|
import { SessionId } from "@deepseek-ai/dsh-session";
|
|
4
|
-
import type { AgentDescriptor,
|
|
4
|
+
import type { AgentDescriptor, AgentSessionReference } from "../../model/agent.js";
|
|
5
5
|
import type { AgentHost } from "../../services/agents/agent-service.js";
|
|
6
6
|
import { requireThat } from "../../common/validation.js";
|
|
7
7
|
import { openDshAgent, readDshAgentSession, readDshReport } from "./session.js";
|
|
@@ -25,9 +25,6 @@ export class DshAgents implements AgentHost {
|
|
|
25
25
|
ready(agent: Agent, generation: string): void;
|
|
26
26
|
stopping(agent: Agent, generation: string): Promise<void>;
|
|
27
27
|
}, readonly lifetime: AbortSignal) {}
|
|
28
|
-
validateOptions(options: AgentOptions) {
|
|
29
|
-
for (const key of ["noExtensions", "noPromptTemplates", "noContextFiles"] as const) requireThat(options[key] === undefined, "dsh 不支持宿主选项:" + key);
|
|
30
|
-
}
|
|
31
28
|
available() {
|
|
32
29
|
this.lifetime.throwIfAborted();
|
|
33
30
|
requireThat(!this.#closed && this.ctx.agents.get(this.parent.id) === this.parent, "dsh 父会话或执行组件已关闭。");
|
|
@@ -11,17 +11,14 @@ import { requireThat } from "../../common/validation.js";
|
|
|
11
11
|
import type { AgentOptions } from "../../model/agent.js";
|
|
12
12
|
|
|
13
13
|
export async function dshResources(ctx: Context, _agent: Agent, root: string,
|
|
14
|
-
role: "coordinator" | "general-purpose",
|
|
14
|
+
role: "coordinator" | "general-purpose", check: () => void) {
|
|
15
15
|
const read = () => Promise.all([agentText(role, root), readFile(join(resourceRoot, "prompts/workspace.md"), "utf8")]);
|
|
16
16
|
const [text, workspace] = await read();
|
|
17
17
|
check();
|
|
18
18
|
ctx.systemPrompt.section({ name: "pbot:role", order: 1, text, interpolate: false });
|
|
19
19
|
ctx.systemPrompt.section({ name: "pbot:workspace", order: 2, text: workspace, interpolate: false });
|
|
20
20
|
ctx.systemPrompt.context({ name: "pbot:environment", order: 300, required: true, interpolate: false,
|
|
21
|
-
text: ()
|
|
22
|
-
const { state, directory } = python();
|
|
23
|
-
return JSON.stringify({ workspaceRoot: root, resourceRoot, python: { state, ...(directory ? { directory } : {}) } });
|
|
24
|
-
} });
|
|
21
|
+
text: JSON.stringify({ workspaceRoot: root, resourceRoot }) });
|
|
25
22
|
ctx.on("system-prompt/assemble", async (_assembly, _context, next) => {
|
|
26
23
|
check();
|
|
27
24
|
const [roleText, workspaceText] = await read();
|
|
@@ -100,19 +100,6 @@ export async function inspectSystem(processes: SetupProcesses, cwd: string): Pro
|
|
|
100
100
|
if (major < 22 || major === 22 && minor < 19) throw new Error("需要 Node.js 22.19 或更高版本。");
|
|
101
101
|
const npm = await findExecutable("npm", processes.env);
|
|
102
102
|
if (!npm) throw new Error("未找到 npm。请先安装 Node.js/npm。");
|
|
103
|
-
const python = await findExecutable("python3", processes.env) ?? await findExecutable("python", processes.env);
|
|
104
|
-
if (!python) throw new Error("需要 Python 3.11+ 和 venv/ensurepip。请先安装后重试。");
|
|
105
|
-
try {
|
|
106
|
-
await processes.run(python, ["-I", "-B", "-c", [
|
|
107
|
-
"import sys, tempfile, venv, ensurepip",
|
|
108
|
-
"assert sys.version_info >= (3, 11), 'Python 3.11+ required'",
|
|
109
|
-
"with tempfile.TemporaryDirectory(prefix='pbot-python-check-') as path:",
|
|
110
|
-
" venv.EnvBuilder(with_pip=True).create(path)",
|
|
111
|
-
].join("\n")], cwd);
|
|
112
|
-
} catch (error) {
|
|
113
|
-
processes.signal.throwIfAborted();
|
|
114
|
-
throw new Error("基础 Python 检查失败。需要 Python 3.11+ 和 venv/ensurepip;Debian/Ubuntu 还需 python3-venv。\n" + String(error));
|
|
115
|
-
}
|
|
116
103
|
const tmux = await findExecutable("tmux", processes.env);
|
|
117
104
|
if (tmux) { await processes.run(tmux, ["-V"], cwd); return { npm }; }
|
|
118
105
|
const names = process.platform === "darwin" ? ["brew"] : ["apt-get", "dnf", "pacman", "zypper", "apk", "sudo"];
|
|
@@ -58,11 +58,18 @@ export class PiAgents implements AgentHost {
|
|
|
58
58
|
if (o.thinking) args.push("--thinking", o.thinking);
|
|
59
59
|
}
|
|
60
60
|
if (o.tools) args.push("--tools", o.tools.join(","));
|
|
61
|
-
const
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
61
|
+
const environment: NodeJS.ProcessEnv = { ...process.env, PWD: d.cwd,
|
|
62
|
+
PBOT_SUBAGENT_RUN_ID: d.agentId, PBOT_SUBAGENT_DIR: directory, PBOT_SUBAGENT_GENERATION: generation,
|
|
63
|
+
PI_CODING_AGENT_DIR: getAgentDir() };
|
|
64
|
+
const terminalKeys = ["TERM", "TMUX", "TMUX_PANE", "TERM_PROGRAM", "TERM_PROGRAM_VERSION"];
|
|
65
|
+
for (const key of terminalKeys) delete environment[key];
|
|
66
|
+
const cached = spawnSync("tmux", ["show-environment", "-g"], { encoding: "utf8" }).stdout ?? "";
|
|
67
|
+
const removed = cached.split("\n").map(line => line.replace(/^-/, "").split("=", 1)[0]!)
|
|
68
|
+
.filter(key => key && environment[key] === undefined && !terminalKeys.includes(key));
|
|
69
|
+
// Session environment values stay out of the pane command; clear values cached only by the server.
|
|
70
|
+
const result = spawnSync("tmux", ["new-session", "-d", "-s", tmuxName(d.agentId), "-x", "120", "-y", "40", "-c", d.cwd,
|
|
71
|
+
...Object.entries(environment).flatMap(([key, value]) => value === undefined ? [] : ["-e", `${key}=${value}`]), "--",
|
|
72
|
+
"/usr/bin/env", ...removed.flatMap(key => ["-u", key]), process.execPath, join(getPackageDir(), "dist/cli.js"), ...args], { encoding: "utf8" });
|
|
66
73
|
requireThat(result.status === 0, result.stderr || "子会话启动失败。");
|
|
67
74
|
}
|
|
68
75
|
report(d: AgentDescriptor, reference: AgentSessionReference, leaf: string) {
|
package/src/model/agent.ts
CHANGED
|
@@ -2,7 +2,7 @@ import type { AcpBackend, AcpModelSelection, AcpSessionReference } from "./acp.j
|
|
|
2
2
|
|
|
3
3
|
export interface AgentStartOptions extends AgentOptions { backend?: AcpBackend }
|
|
4
4
|
export interface AgentOptions {
|
|
5
|
-
name?: string; message?: string; files?: string[];
|
|
5
|
+
name?: string; message?: string; files?: string[];
|
|
6
6
|
provider?: string; model?: string; thinking?: string; cwd?: string; tools?: string[];
|
|
7
7
|
noExtensions?: boolean; noSkills?: boolean; noPromptTemplates?: boolean; noContextFiles?: boolean;
|
|
8
8
|
}
|
package/src/pbot.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
|
|
2
2
|
import { PiAgents, agentDirectory } from "./integrations/pi/pi-agents.js";
|
|
3
3
|
import { AgentBackends } from "./integrations/acp/agents.js";
|
|
4
|
-
import { PythonEnvironmentService } from "./services/workspace/python-environment-service.js";
|
|
5
4
|
import { AgentService } from "./services/agents/agent-service.js";
|
|
6
5
|
import { TeamService } from "./services/agents/team-service.js";
|
|
7
6
|
import { Confirmations } from "./ui/confirmation.js";
|
|
@@ -28,7 +27,7 @@ export default function pbot(pi: ExtensionAPI) {
|
|
|
28
27
|
const file = agents.files.optional(agent.agentId, "session-ref.json", sessionRef)?.file;
|
|
29
28
|
return file ? [file] : [];
|
|
30
29
|
})), [new HistoryFiles(join(root, ".pbot/history"), "dsh"), new HistoryFiles(join(root, ".pbot/history"), "claude")]);
|
|
31
|
-
return new WorkspaceInstance(root,
|
|
30
|
+
return new WorkspaceInstance(root, agents, new TeamService(root, agents.files, agents.teamFiles), history);
|
|
32
31
|
}, instance => registry.register(mainTools(instance.agents, instance.teams, instance.history, instance)), () => registry.hide());
|
|
33
32
|
registerCommand(pi, lifecycle, confirmations);
|
|
34
33
|
registerEvents(pi, lifecycle, confirmations);
|
|
@@ -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
|
-
"团队批次状态已变化,用 pbot_team status
|
|
11
|
+
"团队批次状态已变化,用 pbot_team status 与 pbot_team_message 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
|
}
|
|
@@ -9,6 +9,7 @@ import type { TeamAgent, TeamInput } from "../../model/team.js";
|
|
|
9
9
|
import type { AgentOwner, AgentOptions, AgentStartOptions, AgentDescriptor, AgentCycle, AgentCompletion, AgentSessionReference, NativeAgentHost } from "../../model/agent.js";
|
|
10
10
|
import type { AcpBackend, AcpSessionReference } from "../../model/acp.js";
|
|
11
11
|
import { acpModelState, acpPermission, acpPermissionReply, acpReference } from "../../storage/acp-files.js";
|
|
12
|
+
import { applicableStartOptions } from "./start-options.js";
|
|
12
13
|
|
|
13
14
|
export interface AgentHost {
|
|
14
15
|
readonly kind: NativeAgentHost;
|
|
@@ -72,7 +73,8 @@ export class AgentService {
|
|
|
72
73
|
this.check();
|
|
73
74
|
const { backend, ...supplied } = input;
|
|
74
75
|
this.host.available(backend);
|
|
75
|
-
const options: AgentOptions =
|
|
76
|
+
const options: AgentOptions = applicableStartOptions(this.host.kind, backend,
|
|
77
|
+
Object.fromEntries(Object.entries(supplied).filter(([, v]) => v !== undefined)));
|
|
76
78
|
this.host.validateOptions?.(options, backend);
|
|
77
79
|
requireThat(backend || options.provider && options.model, "请选择可在专家会话使用的模型。");
|
|
78
80
|
const reference = backend ? this.host.prepare?.(backend, options) : undefined;
|
|
@@ -86,7 +88,7 @@ export class AgentService {
|
|
|
86
88
|
parentSessionId: owner.sessionId, parentLeaf: owner.leaf, createdAt: Date.now(), options: { ...options, files, cwd } };
|
|
87
89
|
const run = { generation: randomUUID(), name: options.name ?? agentId.slice(0, 8), sequence: 0, stop: false, startedAt: Date.now() };
|
|
88
90
|
this.files.create(d, run, reference);
|
|
89
|
-
const initial =
|
|
91
|
+
const initial = options.message ?? "";
|
|
90
92
|
const request = initial || files.length ? this.files.enqueue(agentId, initial, "steer", files) : undefined;
|
|
91
93
|
this.#starting.set(agentId, { generation: run.generation, controller: new AbortController(), stage: "launch" });
|
|
92
94
|
return { d, run, request };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { AcpBackend } from "../../model/acp.js";
|
|
2
|
+
import type { AgentOptions, NativeAgentHost } from "../../model/agent.js";
|
|
3
|
+
|
|
4
|
+
const piOnly = ["noExtensions", "noPromptTemplates", "noContextFiles"] as const;
|
|
5
|
+
|
|
6
|
+
/** Keep only options the effective target can use; declared-but-inapplicable fields are inert. */
|
|
7
|
+
export function applicableStartOptions(kind: NativeAgentHost, backend: AcpBackend | undefined, options: AgentOptions): AgentOptions {
|
|
8
|
+
const result = { ...options };
|
|
9
|
+
if (backend) {
|
|
10
|
+
if (backend !== "pi") {
|
|
11
|
+
for (const key of piOnly) delete result[key];
|
|
12
|
+
delete result.noSkills; delete result.tools;
|
|
13
|
+
}
|
|
14
|
+
if (backend === "claude") delete result.provider;
|
|
15
|
+
} else if (kind !== "pi") {
|
|
16
|
+
for (const key of piOnly) delete result[key];
|
|
17
|
+
}
|
|
18
|
+
return result;
|
|
19
|
+
}
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import type { Static } from "typebox";
|
|
2
2
|
import type { AgentService } from "../../services/agents/agent-service.js";
|
|
3
|
-
import type { AgentOptions,
|
|
3
|
+
import type { AgentOptions, AgentOwner, AgentView } from "../../model/agent.js";
|
|
4
4
|
import { markdownResult } from "../result.js";
|
|
5
|
-
import type {
|
|
5
|
+
import type { AgentInput, agentViewSchema } from "./contract.js";
|
|
6
6
|
|
|
7
|
-
export type AgentInput = Omit<Static<typeof agentParametersSchema>, "thinking"> & { thinking?: string };
|
|
8
7
|
type AgentOutput = Static<typeof agentViewSchema>;
|
|
9
8
|
function agentOutput(view: AgentView & Partial<AgentOutput>): AgentOutput {
|
|
10
9
|
const c = view.cycle;
|
|
@@ -25,22 +24,31 @@ function agentOutput(view: AgentView & Partial<AgentOutput>): AgentOutput {
|
|
|
25
24
|
};
|
|
26
25
|
}
|
|
27
26
|
|
|
27
|
+
/** Parent selection is inherited only for a native expert; a chosen model drops the thinking default. */
|
|
28
|
+
function inherited(input: AgentInput, defaults: AgentOptions) {
|
|
29
|
+
if (input.action !== "start" || input.backend) return {};
|
|
30
|
+
const changed = Boolean(input.provider && defaults.provider && input.provider !== defaults.provider) ||
|
|
31
|
+
Boolean(input.model && defaults.model && input.model !== defaults.model);
|
|
32
|
+
const options = { ...defaults };
|
|
33
|
+
if (changed) delete options.thinking;
|
|
34
|
+
return options;
|
|
35
|
+
}
|
|
28
36
|
|
|
29
37
|
export async function executeAgent(service: AgentService, input: AgentInput, owner: AgentOwner, defaults: AgentOptions = {}) {
|
|
30
38
|
let value: AgentView & Partial<AgentOutput>;
|
|
31
39
|
switch (input.action) {
|
|
32
40
|
case "start": {
|
|
33
41
|
const { action: _action, ...supplied } = input;
|
|
34
|
-
value = await service.start({ ...(
|
|
42
|
+
value = await service.start({ ...inherited(input, defaults), ...supplied }, owner); break;
|
|
35
43
|
}
|
|
36
44
|
case "list": return markdownResult({ agents: service.list(owner).map(agentOutput) }, "子会话列表");
|
|
37
|
-
case "send": value = service.send(input.agentId
|
|
38
|
-
case "rename": value = service.rename(input.agentId
|
|
39
|
-
case "resume": value = await service.resume(input.agentId
|
|
40
|
-
case "stop": value = service.stop(input.agentId
|
|
41
|
-
case "status": value = service.status(input.agentId
|
|
45
|
+
case "send": value = service.send(input.agentId, input.message, input.delivery ?? "steer", owner); break;
|
|
46
|
+
case "rename": value = service.rename(input.agentId, input.name, owner); break;
|
|
47
|
+
case "resume": value = await service.resume(input.agentId, input.message, owner); break;
|
|
48
|
+
case "stop": value = service.stop(input.agentId, owner); break;
|
|
49
|
+
case "status": value = service.status(input.agentId, owner); break;
|
|
42
50
|
case "read": {
|
|
43
|
-
const page = await service.read(input.agentId
|
|
51
|
+
const page = await service.read(input.agentId, owner, input.cycleId, input.offset, input.limit);
|
|
44
52
|
const data = agentOutput(page), output = markdownResult(data, "子会话报告");
|
|
45
53
|
return { ...output, details: { ...data, ...(page.cycle && page.cycle.state !== "running" ? { agentReadKeys: [page.agentId + ":" + page.cycle.cycleId] } : {}) } };
|
|
46
54
|
}
|
|
@@ -1,46 +1,81 @@
|
|
|
1
1
|
import { Type } from "typebox";
|
|
2
|
+
import type { AgentStartOptions } from "../../model/agent.js";
|
|
3
|
+
import { requireThat } from "../../common/validation.js";
|
|
4
|
+
import { schema } from "../../common/schema.js";
|
|
5
|
+
import { inputObject, need, nullable, pick } from "../input.js";
|
|
2
6
|
|
|
3
|
-
export const agentDescription = "委派专家并继续对话。start 启动后即返回,完成自动通知,无需轮询;省略初始输入时待命。send 继续对话,团队占用期间不可私人 send。status 查看状态,read 读取报告;读取已结束周期即领取其通知,包括部分读取。续读固定 cycle.cycleId 并使用 nextOffset。state 表示执行状态,cycle.state 表示工作结果,queued 只表示入队。stop 保留历史,resume 携新 message 继续。每个父会话最多 50
|
|
7
|
+
export const agentDescription = "委派专家并继续对话。start 启动后即返回,完成自动通知,无需轮询;省略初始输入时待命。send 继续对话,团队占用期间不可私人 send。status 查看状态,read 读取报告;读取已结束周期即领取其通知,包括部分读取。续读固定 cycle.cycleId 并使用 nextOffset。state 表示执行状态,cycle.state 表示工作结果,queued 只表示入队。stop 保留历史,resume 携新 message 继续。每个父会话最多 50 个存活专家,空闲也计入。动作只读取自己的字段;其他已声明字段忽略。";
|
|
4
8
|
|
|
5
9
|
const id = Type.String({ minLength: 1, maxLength: 128 });
|
|
6
10
|
const message = Type.String({ minLength: 1, maxLength: 24000, description: "本次目标、相关资料、约束和交付要求。" });
|
|
7
11
|
const name = Type.String({ minLength: 1, maxLength: 64, pattern: "^[^\\r\\n\\x00-\\x1f]+$" });
|
|
8
|
-
|
|
9
|
-
backend:
|
|
10
|
-
name:
|
|
11
|
-
files:
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
};
|
|
23
|
-
const page = {
|
|
24
|
-
cycleId: Type.Optional(Type.String({ ...id, description: "仅 read:省略时读取最近周期;按 nextOffset 续读时须固定为上页返回的 cycle.cycleId,避免切换到新周期。" })),
|
|
25
|
-
offset: Type.Optional(Type.Integer({ minimum: 0, description: "仅 read:报告正文的 UTF-16 字符偏移,默认 0;续读使用上页 nextOffset。" })),
|
|
26
|
-
limit: Type.Optional(Type.Integer({ minimum: 1, maximum: 16000, description: "仅 read:最多返回的正文 UTF-16 字符数,默认 16000,不是消息数或 token 数。" })),
|
|
27
|
-
};
|
|
28
|
-
const delivery = Type.Optional(Type.Union([Type.Literal("steer"), Type.Literal("followUp")], { description: "send 默认 steer 补充当前工作;followUp 排到当前工作之后。capabilities.steer 为 false 的成员运行中使用 followUp。" }));
|
|
12
|
+
const startFields = {
|
|
13
|
+
backend: nullable(Type.Union([Type.Literal("pi"), Type.Literal("dsh"), Type.Literal("claude")], { description: "选择 ACP 子代理程序:pi、dsh 或 claude(Claude Code)。省略时使用当前宿主的原生专家;指定时使用目标程序自己的配置。" })),
|
|
14
|
+
name: nullable(name), message: nullable(message),
|
|
15
|
+
files: nullable(Type.Array(Type.String({ minLength: 1 }), { maxItems: 32, description: "随初始消息读取的文件;相对路径基于原工作区根目录。" })),
|
|
16
|
+
provider: nullable(Type.String({ ...id, description: "模型提供方覆盖项;省略时继承主会话或使用 ACP 目标配置。指定时须同时指定 model。" })),
|
|
17
|
+
model: nullable(Type.String({ ...id, description: "模型 ID 覆盖项;省略时继承主会话或使用 ACP 目标配置。Pi/dsh 同名模型可用 provider 区分。" })),
|
|
18
|
+
thinking: nullable(Type.String({ minLength: 1, maxLength: 128, description: "思考等级覆盖项;省略时继承主会话或使用 ACP 目标配置。Pi 使用 off/minimal/low/medium/high/xhigh/max,其他程序使用其原生等级 ID。" })),
|
|
19
|
+
cwd: nullable(Type.String({ minLength: 1, description: "执行目录,相对原工作区根目录;省略时使用工作区根目录。" })),
|
|
20
|
+
tools: nullable(Type.Array(id, { minItems: 1, description: "Pi/dsh 子代理的工具名;省略时使用所选程序默认工具。Claude 子代理忽略此项并沿用原生配置。" })),
|
|
21
|
+
noExtensions: nullable(Type.Boolean({ description: "仅用于 Pi 子代理:关闭其他扩展的自动发现,默认 true。" })),
|
|
22
|
+
noSkills: nullable(Type.Boolean({ description: "Pi/dsh 子代理关闭技能发现,默认 false;Claude 子代理忽略此项并沿用原生配置。" })),
|
|
23
|
+
noPromptTemplates: nullable(Type.Boolean({ description: "仅用于 Pi 子代理:关闭提示模板发现,默认 false。" })),
|
|
24
|
+
noContextFiles: nullable(Type.Boolean({ description: "仅用于 Pi 子代理:关闭原生上下文文件加载,默认 false。" })),
|
|
25
|
+
} as const;
|
|
29
26
|
export const agentParametersSchema = Type.Object({
|
|
30
27
|
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")], {
|
|
31
|
-
description: "start
|
|
28
|
+
description: "start 创建专家;省略 message/files 即待命。send 必填 agentId/message,可选 delivery。resume 必填 agentId/message。stop/status 必填 agentId。rename 必填 agentId/name。read 必填 agentId,可选 cycleId/offset/limit。list 只需 action。动作只读取自己的字段;其他已声明字段忽略。",
|
|
32
29
|
}),
|
|
33
|
-
agentId:
|
|
30
|
+
agentId: nullable(id), ...startFields,
|
|
31
|
+
cycleId: nullable(Type.String({ ...id, description: "仅 read:省略时读取最近周期;按 nextOffset 续读时须固定为上页返回的 cycle.cycleId,避免切换到新周期。" })),
|
|
32
|
+
offset: nullable(Type.Integer({ minimum: 0, description: "仅 read:报告正文的 UTF-16 字符偏移,默认 0;续读使用上页 nextOffset。" })),
|
|
33
|
+
limit: nullable(Type.Integer({ minimum: 1, maximum: 16000, description: "仅 read:最多返回的正文 UTF-16 字符数,默认 16000,不是消息数或 token 数。" })),
|
|
34
|
+
delivery: nullable(Type.Union([Type.Literal("steer"), Type.Literal("followUp")], { description: "仅 send:默认 steer 补充当前工作;followUp 排到当前工作之后。capabilities.steer 为 false 的成员运行中使用 followUp。" })),
|
|
34
35
|
}, { additionalProperties: false });
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
36
|
+
|
|
37
|
+
export type AgentAction = "start" | "send" | "rename" | "status" | "list" | "read" | "stop" | "resume";
|
|
38
|
+
export type AgentInput =
|
|
39
|
+
| ({ action: "start" } & AgentStartOptions)
|
|
40
|
+
| { action: "send"; agentId: string; message: string; delivery?: "steer" | "followUp" }
|
|
41
|
+
| { action: "resume"; agentId: string; message: string }
|
|
42
|
+
| { action: "rename"; agentId: string; name: string }
|
|
43
|
+
| { action: "stop" | "status"; agentId: string }
|
|
44
|
+
| { action: "list" }
|
|
45
|
+
| { action: "read"; agentId: string; cycleId?: string; offset?: number; limit?: number };
|
|
46
|
+
|
|
47
|
+
const startKeys = Object.keys(startFields);
|
|
48
|
+
const valid = schema(agentParametersSchema);
|
|
49
|
+
|
|
50
|
+
/** One flat record, one interpreter. Fields outside the selected action are inert. */
|
|
51
|
+
export function agentInput(value: unknown): AgentInput {
|
|
52
|
+
const args = inputObject(value, valid, "专家参数格式无效");
|
|
53
|
+
const action = args.action as AgentAction;
|
|
54
|
+
switch (action) {
|
|
55
|
+
case "start":
|
|
56
|
+
requireThat(!args.provider || args.model !== undefined, "start 需要同时提供 provider 与 model。");
|
|
57
|
+
return { action, ...(pick(args, startKeys) as AgentStartOptions) };
|
|
58
|
+
case "send":
|
|
59
|
+
return { action, agentId: need("send", args, "agentId"), message: need("send", args, "message"),
|
|
60
|
+
...(args.delivery === undefined ? {} : { delivery: args.delivery as "steer" | "followUp" }) };
|
|
61
|
+
case "resume":
|
|
62
|
+
return { action, agentId: need("resume", args, "agentId"), message: need("resume", args, "message") };
|
|
63
|
+
case "rename":
|
|
64
|
+
return { action, agentId: need("rename", args, "agentId"), name: need("rename", args, "name") };
|
|
65
|
+
case "stop":
|
|
66
|
+
case "status":
|
|
67
|
+
return { action, agentId: need(action, args, "agentId") };
|
|
68
|
+
case "list":
|
|
69
|
+
return { action };
|
|
70
|
+
case "read":
|
|
71
|
+
return { action, agentId: need("read", args, "agentId"),
|
|
72
|
+
...(args.cycleId === undefined ? {} : { cycleId: args.cycleId as string }),
|
|
73
|
+
...(args.offset === undefined ? {} : { offset: args.offset as number }),
|
|
74
|
+
...(args.limit === undefined ? {} : { limit: args.limit as number }) };
|
|
75
|
+
default:
|
|
76
|
+
throw new Error("未知的专家 action。");
|
|
77
|
+
}
|
|
78
|
+
}
|
|
44
79
|
|
|
45
80
|
const cycle = Type.Object({ cycleId: Type.String(), startedAt: Type.Number(), finishedAt: Type.Optional(Type.Number()),
|
|
46
81
|
state: Type.Union([Type.Literal("running"), Type.Literal("completed"), Type.Literal("failed"), Type.Literal("cancelled"), Type.Literal("interrupted")], { description: "本周期的工作结果,正文用 read 读取。" }),
|
|
@@ -7,15 +7,13 @@ import { object, json } from "../../common/json.js";
|
|
|
7
7
|
import { requireThat } from "../../common/validation.js";
|
|
8
8
|
import { schema } from "../../common/schema.js";
|
|
9
9
|
import { markdownFields } from "../../common/markdown.js";
|
|
10
|
-
import { executeAgent
|
|
11
|
-
import { agentDescription, agentResultSchema } from "./contract.js";
|
|
12
|
-
import { dshAgentActionSchema, dshAgentParametersSchema } from "./dsh-contract.js";
|
|
10
|
+
import { executeAgent } from "./actions.js";
|
|
11
|
+
import { agentDescription, agentInput, agentParametersSchema, agentResultSchema } from "./contract.js";
|
|
13
12
|
|
|
14
13
|
export function registerDshAgentTool(ctx: Context, agent: Agent, service: AgentService, owner: AgentOwner, check: () => void) {
|
|
15
|
-
const validators = new Map(dshAgentActionSchema.anyOf.map(row => [row.properties.action.const, schema(row)]));
|
|
16
14
|
const validOutput = schema(agentResultSchema);
|
|
17
15
|
ctx.tools.register({ name: "pbot_agent", description: agentDescription,
|
|
18
|
-
parameters: dshParameters(
|
|
16
|
+
parameters: dshParameters(agentParametersSchema),
|
|
19
17
|
output: {
|
|
20
18
|
schema: dshOutputSchema(agentResultSchema),
|
|
21
19
|
render: (_args, value) => [{ type: "text", text: "# 专家\n\n" + markdownFields(value) }],
|
|
@@ -26,14 +24,11 @@ export function registerDshAgentTool(ctx: Context, agent: Agent, service: AgentS
|
|
|
26
24
|
},
|
|
27
25
|
async execute(args, exec) {
|
|
28
26
|
check(); exec.signal.throwIfAborted();
|
|
29
|
-
requireThat(exec.agent === agent
|
|
30
|
-
const
|
|
31
|
-
|
|
32
|
-
const selection = agent.model.current();
|
|
33
|
-
const output = await executeAgent(service, args as AgentInput, owner, selection ? {
|
|
27
|
+
requireThat(exec.agent === agent, "专家工具不属于当前会话。");
|
|
28
|
+
const input = agentInput(args), selection = agent.model.current();
|
|
29
|
+
const output = await executeAgent(service, input, owner, selection ? {
|
|
34
30
|
provider: selection.provider, model: selection.model,
|
|
35
|
-
...(selection.reasoningEffort
|
|
36
|
-
? { thinking: selection.reasoningEffort } : {}),
|
|
31
|
+
...(selection.reasoningEffort ? { thinking: selection.reasoningEffort } : {}),
|
|
37
32
|
} : {});
|
|
38
33
|
requireThat(validOutput(output.structuredContent), "专家输出不符合契约。");
|
|
39
34
|
return output.structuredContent;
|
package/src/tools/agents/tool.ts
CHANGED
|
@@ -2,22 +2,16 @@ import { defineTool } from "@earendil-works/pi-coding-agent";
|
|
|
2
2
|
import type { AgentService } from "../../services/agents/agent-service.js";
|
|
3
3
|
import { agentOwner } from "../../integrations/pi/agent-context.js";
|
|
4
4
|
import type { CallAccess } from "../access.js";
|
|
5
|
-
import { requireThat } from "../../common/validation.js";
|
|
6
|
-
import { schema } from "../../common/schema.js";
|
|
7
5
|
import { executeAgent } from "./actions.js";
|
|
8
|
-
import { agentDescription,
|
|
6
|
+
import { agentDescription, agentInput, agentParametersSchema, agentResultSchema } from "./contract.js";
|
|
9
7
|
|
|
10
8
|
export function agentTool(service: AgentService, access: CallAccess) {
|
|
11
|
-
const validators = new Map(agentActionSchema.anyOf.map(action => [action.properties.action.const, schema(action)]));
|
|
12
9
|
return defineTool({ name: "pbot_agent", label: "子会话",
|
|
13
10
|
description: agentDescription,
|
|
14
11
|
parameters: agentParametersSchema, outputSchema: agentResultSchema,
|
|
15
12
|
async execute(_id, args, signal, _update, ctx) {
|
|
16
13
|
access.check(); signal?.throwIfAborted();
|
|
17
|
-
|
|
18
|
-
requireThat(valid, "未知的子会话 action:" + args.action);
|
|
19
|
-
requireThat(valid(args), "子会话 " + args.action + " 参数无效:" + JSON.stringify(valid.errors));
|
|
20
|
-
return executeAgent(service, args, agentOwner(ctx), {
|
|
14
|
+
return executeAgent(service, agentInput(args), agentOwner(ctx), {
|
|
21
15
|
...(ctx.model ? { provider: ctx.model.provider, model: ctx.model.id } : {}),
|
|
22
16
|
...(ctx.thinkingLevel ? { thinking: ctx.thinkingLevel } : {}),
|
|
23
17
|
});
|
|
@@ -5,5 +5,5 @@ import type { HistoryInput } from "./contract.js";
|
|
|
5
5
|
export async function executeHistory(service: HistoryService, args: HistoryInput, location: HistoryLocation, signal?: AbortSignal) {
|
|
6
6
|
signal?.throwIfAborted(); await service.refresh(location, signal); signal?.throwIfAborted();
|
|
7
7
|
return args.action === "search" ? service.search(args) :
|
|
8
|
-
{ node: service.read(args.id
|
|
8
|
+
{ node: service.read(args.id, args.offset, args.limit, args.childrenOffset, args.host), warnings: service.warnings };
|
|
9
9
|
}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import { Type
|
|
1
|
+
import { Type } from "typebox";
|
|
2
|
+
import type { HistoryHost } from "../../model/history.js";
|
|
2
3
|
import { requireThat } from "../../common/validation.js";
|
|
3
4
|
import { schema } from "../../common/schema.js";
|
|
5
|
+
import { inputObject, need, nullable, pick } from "../input.js";
|
|
4
6
|
|
|
5
7
|
const host = Type.Union([Type.Literal("pi"), Type.Literal("dsh"), Type.Literal("claude")]);
|
|
6
8
|
const nullableOffset = Type.Union([Type.Integer(), Type.Null()]);
|
|
@@ -16,20 +18,31 @@ export const historyResultSchema = Type.Object({
|
|
|
16
18
|
});
|
|
17
19
|
export const historyDescription = "查询当前工作区的 Pi/dsh 问答与已有 Claude 归档,host 可筛选来源。search 按不区分大小写的连续文本匹配原文和摘要;无匹配时换词,省略 query 列会话。read 按 parents/children 的 id 展开,nextOffset 续读正文,nextChildrenOffset 续读子节点。需要对话细节时读取 exchange 原文;需要工具日志时查所属宿主的原始会话。";
|
|
18
20
|
export const historyParameters = Type.Object({ action: Type.Union([Type.Literal("search"), Type.Literal("read")]),
|
|
19
|
-
host:
|
|
20
|
-
from:
|
|
21
|
-
to:
|
|
22
|
-
id:
|
|
23
|
-
offset:
|
|
24
|
-
limit:
|
|
25
|
-
childrenOffset:
|
|
21
|
+
host: nullable(host), query: nullable(Type.String()), sessionId: nullable(Type.String()),
|
|
22
|
+
from: nullable(Type.String({ description: "search:ISO 日期或时间,下界。" })),
|
|
23
|
+
to: nullable(Type.String({ description: "search:ISO 日期或时间,上界。" })),
|
|
24
|
+
id: nullable(Type.String({ description: "read 必填:返回的节点 id。" })),
|
|
25
|
+
offset: nullable(Type.Integer({ minimum: 0, description: "search:匹配结果偏移;read:正文 UTF-16 字符偏移。默认 0。" })),
|
|
26
|
+
limit: nullable(Type.Integer({ minimum: 1, maximum: 24000, description: "search:最多返回的匹配条数,默认 20,最多 50;read:正文 UTF-16 字符数,默认 12000。" })),
|
|
27
|
+
childrenOffset: nullable(Type.Integer({ minimum: 0 })),
|
|
26
28
|
}, { additionalProperties: false });
|
|
27
|
-
|
|
29
|
+
|
|
30
|
+
export type HistoryInput =
|
|
31
|
+
| { action: "search"; host?: HistoryHost; query?: string; sessionId?: string; from?: string; to?: string; offset?: number; limit?: number }
|
|
32
|
+
| { action: "read"; id: string; host?: HistoryHost; offset?: number; limit?: number; childrenOffset?: number };
|
|
33
|
+
|
|
28
34
|
const valid = schema(historyParameters);
|
|
35
|
+
|
|
29
36
|
export function historyInput(value: unknown): HistoryInput {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
37
|
+
const args = inputObject(value, valid, "历史参数格式无效");
|
|
38
|
+
if (args.action === "search") {
|
|
39
|
+
const limit = args.limit === undefined ? 20 : args.limit as number;
|
|
40
|
+
requireThat(limit <= 50, "search 的 limit 最多 50。");
|
|
41
|
+
return { action: "search", ...(pick(args, ["host", "query", "sessionId", "from", "to", "offset", "limit"]) as
|
|
42
|
+
Omit<Extract<HistoryInput, { action: "search" }>, "action">) };
|
|
43
|
+
}
|
|
44
|
+
if (args.action === "read") return { action: "read", id: need("read", args, "id"),
|
|
45
|
+
...(pick(args, ["host", "offset", "limit", "childrenOffset"]) as
|
|
46
|
+
Omit<Extract<HistoryInput, { action: "read" }>, "action" | "id">) };
|
|
47
|
+
throw new Error("未知的历史 action。");
|
|
35
48
|
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { TSchema } from "typebox";
|
|
2
|
+
import { Type } from "typebox";
|
|
3
|
+
import type { ValidateFunction } from "ajv";
|
|
4
|
+
import { object } from "../common/json.js";
|
|
5
|
+
import { schemaDetail } from "../common/schema.js";
|
|
6
|
+
import { requireThat } from "../common/validation.js";
|
|
7
|
+
|
|
8
|
+
/** Optional tool field that also accepts null, the absence spelling of structured tool calls. */
|
|
9
|
+
export function nullable<T extends TSchema>(value: T) {
|
|
10
|
+
return Type.Optional(Type.Union([value, Type.Null()]));
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/** Validate one record shape, then treat null as absent before action-specific projection. */
|
|
14
|
+
export function inputObject(value: unknown, validate: ValidateFunction, label: string): Record<string, unknown> {
|
|
15
|
+
requireThat(validate(value) && object(value), label + ":" + schemaDetail(validate));
|
|
16
|
+
return Object.fromEntries(Object.entries(value).filter(([, item]) => item !== null));
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/** A mode names each missing input instead of reporting a generic invalid-argument error. */
|
|
20
|
+
export function need<T>(action: string, args: Record<string, unknown>, key: string): T {
|
|
21
|
+
const value = args[key];
|
|
22
|
+
requireThat(value !== undefined, action + " 需要 " + key + "。");
|
|
23
|
+
return value as T;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/** Copy only the fields a mode reads. Fields outside the projection never reach the service. */
|
|
27
|
+
export function pick(args: Record<string, unknown>, keys: readonly string[]): Record<string, unknown> {
|
|
28
|
+
return Object.fromEntries(keys.filter(key => args[key] !== undefined).map(key => [key, args[key]]));
|
|
29
|
+
}
|
|
@@ -1,38 +1,34 @@
|
|
|
1
|
-
import type { Static } from "typebox";
|
|
2
1
|
import type { TeamService } from "../../services/agents/team-service.js";
|
|
3
2
|
import type { AgentService } from "../../services/agents/agent-service.js";
|
|
4
3
|
import type { TeamActor } from "../../model/team.js";
|
|
5
4
|
import type { AgentOwner } from "../../model/agent.js";
|
|
6
5
|
import { teamMessagesMarkdown } from "../../integrations/team-context.js";
|
|
7
6
|
import { markdownResult, result } from "../result.js";
|
|
8
|
-
import type {
|
|
7
|
+
import type { TeamInput, TeamMessageInput } from "./contract.js";
|
|
9
8
|
|
|
10
|
-
export function executeTeam(service: TeamService, agents: AgentService, input:
|
|
9
|
+
export function executeTeam(service: TeamService, agents: AgentService, input: TeamInput, owner: AgentOwner) {
|
|
11
10
|
const views = agents.list(owner);
|
|
12
11
|
service.recover(owner);
|
|
13
|
-
let id =
|
|
12
|
+
let id = "";
|
|
14
13
|
switch (input.action) {
|
|
15
|
-
case "create": id = service.create(owner, { name: input.name
|
|
14
|
+
case "create": id = service.create(owner, { name: input.name, brief: input.brief, members: input.members }, views).teamId; break;
|
|
16
15
|
case "list": return markdownResult({ teams: service.list(owner, views) }, "团队列表");
|
|
17
|
-
case "
|
|
18
|
-
const page = service.read(id, { kind: "coordinator", owner }, input);
|
|
19
|
-
return result(page, false, teamMessagesMarkdown(page));
|
|
20
|
-
}
|
|
21
|
-
case "run": service.run(id, owner, { instruction: input.instruction!, mode: input.mode!,
|
|
16
|
+
case "run": id = input.teamId; service.run(id, owner, { instruction: input.instruction, mode: input.mode,
|
|
22
17
|
...(input.rounds === undefined ? {} : { rounds: input.rounds }),
|
|
23
18
|
...(input.maxConcurrent === undefined ? {} : { maxConcurrent: input.maxConcurrent }),
|
|
24
19
|
...(input.timeoutSeconds === undefined ? {} : { timeoutSeconds: input.timeoutSeconds }) }, views); break;
|
|
25
|
-
case "pause": service.pause(id, owner); break;
|
|
26
|
-
case "close": service.close(id, owner, views); break;
|
|
20
|
+
case "pause": id = input.teamId; service.pause(id, owner); break;
|
|
21
|
+
case "close": id = input.teamId; service.close(id, owner, views); break;
|
|
22
|
+
case "status": id = input.teamId; break;
|
|
27
23
|
}
|
|
28
24
|
return markdownResult(service.status(id, owner, views), "团队状态");
|
|
29
25
|
}
|
|
30
26
|
|
|
31
|
-
export function executeTeamMessage(service: TeamService, input:
|
|
27
|
+
export function executeTeamMessage(service: TeamService, input: TeamMessageInput, actor: TeamActor, requestId: string) {
|
|
32
28
|
if (input.action === "read") {
|
|
33
29
|
const page = service.read(input.teamId, actor, input);
|
|
34
30
|
return result(page, false, teamMessagesMarkdown(page));
|
|
35
31
|
}
|
|
36
|
-
const message = service.post(input.teamId, actor, requestId, input.text
|
|
32
|
+
const message = service.post(input.teamId, actor, requestId, input.text, input.replyTo);
|
|
37
33
|
return markdownResult({ teamId: input.teamId, seq: message.seq, status: "stored" }, "团队消息已保存");
|
|
38
34
|
}
|