@oyasmi/pipiclaw 0.9.1-beta.2 → 0.9.2-beta.1
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/dist/agent/channel-runner.d.ts +9 -1
- package/dist/agent/channel-runner.js +51 -18
- package/dist/agent/command-extension.js +24 -27
- package/dist/agent/commands.d.ts +51 -7
- package/dist/agent/commands.js +199 -59
- package/dist/agent/effect-ledger.js +9 -2
- package/dist/agent/job-manager.d.ts +4 -0
- package/dist/agent/job-manager.js +17 -2
- package/dist/agent/prompt/manifest.d.ts +1 -1
- package/dist/agent/prompt/manifest.js +6 -7
- package/dist/agent/prompt/sections.js +9 -5
- package/dist/agent/reply-limits.d.ts +16 -0
- package/dist/agent/reply-limits.js +17 -0
- package/dist/agent/session-events.d.ts +2 -0
- package/dist/agent/session-events.js +29 -14
- package/dist/agent/status-render.js +12 -12
- package/dist/agent/turn-recovery.js +2 -2
- package/dist/agent/type-guards.js +5 -1
- package/dist/agent/workspace-resources.d.ts +2 -2
- package/dist/agent/workspace-resources.js +41 -3
- package/dist/executor.d.ts +28 -0
- package/dist/executor.js +120 -18
- package/dist/file-store.d.ts +96 -0
- package/dist/file-store.js +189 -0
- package/dist/main.js +3 -4
- package/dist/memory/commands.js +79 -38
- package/dist/memory/consolidation.d.ts +5 -1
- package/dist/memory/consolidation.js +35 -38
- package/dist/memory/extraction.d.ts +8 -1
- package/dist/memory/extraction.js +47 -4
- package/dist/memory/files.d.ts +0 -1
- package/dist/memory/files.js +31 -12
- package/dist/memory/lifecycle.js +9 -2
- package/dist/memory/maintenance-jobs.js +16 -38
- package/dist/memory/maintenance-state.js +2 -1
- package/dist/memory/metadata.d.ts +3 -0
- package/dist/memory/metadata.js +7 -0
- package/dist/memory/recall.d.ts +19 -0
- package/dist/memory/recall.js +116 -24
- package/dist/memory/review-log.d.ts +0 -2
- package/dist/memory/review-log.js +0 -0
- package/dist/memory/session-corpus.js +5 -0
- package/dist/memory/session-search.js +15 -22
- package/dist/memory/sidecar-worker.js +4 -0
- package/dist/memory/source-window.d.ts +0 -1
- package/dist/memory/source-window.js +0 -5
- package/dist/memory/transcript.d.ts +10 -0
- package/dist/memory/transcript.js +39 -0
- package/dist/playbooks/agent-delegation.md +34 -25
- package/dist/playbooks/background-jobs.md +8 -16
- package/dist/playbooks/catalog.d.ts +1 -1
- package/dist/playbooks/catalog.js +1 -1
- package/dist/playbooks/event-scheduling.md +15 -15
- package/dist/playbooks/memory-and-learning.md +30 -23
- package/dist/playbooks/outbound-media.md +15 -8
- package/dist/playbooks/runtime-orientation.md +40 -37
- package/dist/playbooks/task-driving.md +36 -38
- package/dist/playbooks/task-planning.md +21 -21
- package/dist/runtime/app-home.d.ts +6 -0
- package/dist/runtime/app-home.js +16 -7
- package/dist/runtime/bootstrap.js +54 -13
- package/dist/runtime/channel-context.d.ts +2 -1
- package/dist/runtime/delivery.js +3 -3
- package/dist/runtime/dingtalk.d.ts +9 -1
- package/dist/runtime/dingtalk.js +30 -15
- package/dist/runtime/durable-dispatch.d.ts +26 -1
- package/dist/runtime/durable-dispatch.js +51 -5
- package/dist/runtime/event-commands.d.ts +15 -0
- package/dist/runtime/event-commands.js +55 -56
- package/dist/runtime/events.d.ts +4 -2
- package/dist/runtime/events.js +15 -20
- package/dist/runtime/project-commands.d.ts +16 -0
- package/dist/runtime/project-commands.js +13 -17
- package/dist/runtime/subagent-commands.d.ts +20 -0
- package/dist/runtime/subagent-commands.js +61 -58
- package/dist/runtime/task-commands.d.ts +37 -0
- package/dist/runtime/task-commands.js +108 -66
- package/dist/runtime/task-driver.js +2 -2
- package/dist/security/block-message.d.ts +11 -0
- package/dist/security/block-message.js +12 -0
- package/dist/security/path-guard-check.d.ts +13 -0
- package/dist/security/path-guard-check.js +39 -0
- package/dist/security/path-guard.js +61 -12
- package/dist/security/types.d.ts +9 -0
- package/dist/settings.js +3 -2
- package/dist/shared/atomic-file.d.ts +17 -1
- package/dist/shared/atomic-file.js +50 -3
- package/dist/shared/duration.d.ts +2 -0
- package/dist/shared/duration.js +7 -0
- package/dist/shared/safe-id.d.ts +19 -0
- package/dist/shared/safe-id.js +24 -0
- package/dist/shared/text-utils.d.ts +1 -1
- package/dist/shared/text-utils.js +3 -8
- package/dist/shared/type-guards.d.ts +2 -0
- package/dist/shared/type-guards.js +4 -0
- package/dist/subagents/discovery.d.ts +51 -19
- package/dist/subagents/discovery.js +93 -98
- package/dist/subagents/external/claude-code.js +40 -2
- package/dist/subagents/external/harness.d.ts +1 -1
- package/dist/subagents/external/run.js +61 -8
- package/dist/subagents/format.d.ts +3 -2
- package/dist/subagents/format.js +3 -7
- package/dist/subagents/runs.d.ts +1 -1
- package/dist/subagents/runs.js +10 -9
- package/dist/subagents/tool.d.ts +31 -18
- package/dist/subagents/tool.js +592 -562
- package/dist/subagents/workspace-lease.js +1 -1
- package/dist/tasks/control.js +7 -9
- package/dist/tasks/ledger.d.ts +2 -2
- package/dist/tasks/ledger.js +3 -7
- package/dist/tasks/transitions.d.ts +5 -1
- package/dist/tasks/transitions.js +2 -2
- package/dist/tasks/verification.d.ts +7 -5
- package/dist/tools/bash.d.ts +1 -2
- package/dist/tools/bash.js +99 -76
- package/dist/tools/config.d.ts +6 -1
- package/dist/tools/config.js +9 -0
- package/dist/tools/edit.d.ts +2 -3
- package/dist/tools/edit.js +276 -75
- package/dist/tools/event-manage.d.ts +13 -7
- package/dist/tools/event-manage.js +52 -14
- package/dist/tools/glob-match.d.ts +11 -0
- package/dist/tools/glob-match.js +75 -0
- package/dist/tools/glob.d.ts +15 -0
- package/dist/tools/glob.js +113 -0
- package/dist/tools/grep.d.ts +0 -1
- package/dist/tools/grep.js +60 -44
- package/dist/tools/ignore-dirs.d.ts +6 -0
- package/dist/tools/ignore-dirs.js +15 -0
- package/dist/tools/index.d.ts +3 -0
- package/dist/tools/index.js +54 -40
- package/dist/tools/job.d.ts +0 -1
- package/dist/tools/job.js +3 -9
- package/dist/tools/line-index.d.ts +16 -0
- package/dist/tools/line-index.js +76 -0
- package/dist/tools/memory-manage.d.ts +21 -8
- package/dist/tools/memory-manage.js +114 -103
- package/dist/tools/presentation.d.ts +2 -0
- package/dist/tools/presentation.js +109 -0
- package/dist/tools/read.d.ts +2 -2
- package/dist/tools/read.js +100 -120
- package/dist/tools/registry.d.ts +4 -1
- package/dist/tools/registry.js +89 -22
- package/dist/tools/send-media.d.ts +6 -6
- package/dist/tools/send-media.js +21 -43
- package/dist/tools/session-search.d.ts +0 -1
- package/dist/tools/session-search.js +0 -1
- package/dist/tools/skill-security.d.ts +0 -2
- package/dist/tools/skill-security.js +1 -25
- package/dist/tools/skill.d.ts +31 -0
- package/dist/tools/skill.js +153 -0
- package/dist/tools/subagent-manage.d.ts +6 -5
- package/dist/tools/subagent-manage.js +47 -47
- package/dist/tools/task-manage/create.d.ts +2 -2
- package/dist/tools/task-manage/create.js +1 -3
- package/dist/tools/task-manage/lifecycle.d.ts +9 -6
- package/dist/tools/task-manage/lifecycle.js +49 -56
- package/dist/tools/task-manage/schema.d.ts +27 -15
- package/dist/tools/task-manage/schema.js +58 -74
- package/dist/tools/task-manage/shared.d.ts +11 -6
- package/dist/tools/task-manage/shared.js +30 -21
- package/dist/tools/task-manage/types.d.ts +14 -15
- package/dist/tools/task-manage/verification.d.ts +4 -4
- package/dist/tools/task-manage/verification.js +6 -8
- package/dist/tools/task-manage.d.ts +8 -11
- package/dist/tools/task-manage.js +63 -50
- package/dist/tools/tool-details.d.ts +17 -1
- package/dist/tools/tool-details.js +24 -0
- package/dist/tools/truncate.d.ts +8 -0
- package/dist/tools/truncate.js +8 -0
- package/dist/tools/web-fetch.d.ts +0 -1
- package/dist/tools/web-fetch.js +9 -2
- package/dist/tools/web-search.d.ts +0 -1
- package/dist/tools/web-search.js +0 -1
- package/dist/tools/write-content.d.ts +3 -3
- package/dist/tools/write-content.js +12 -41
- package/dist/tools/write.d.ts +2 -3
- package/dist/tools/write.js +3 -4
- package/dist/tui/app.js +1 -1
- package/dist/tui/commands.d.ts +1 -1
- package/dist/tui/commands.js +1 -1
- package/dist/tui/turn-controller.d.ts +1 -1
- package/dist/tui/turn-controller.js +14 -4
- package/dist/usage/ledger.js +7 -4
- package/dist/usage/render.js +10 -8
- package/examples/sub-agents/README.md +2 -0
- package/package.json +3 -2
- package/dist/tools/skill-manage.d.ts +0 -41
- package/dist/tools/skill-manage.js +0 -231
|
@@ -1,17 +1,13 @@
|
|
|
1
|
+
import { renderSubcommandUsage } from "../agent/commands.js";
|
|
1
2
|
import { loadSecurityConfigWithDiagnostics } from "../security/config.js";
|
|
2
3
|
import { currentProjectSandboxStatus, isWithinAllowedRoots, resolveExistingDirectory, resolveProjectAccessPolicy, } from "../security/project-scope.js";
|
|
3
4
|
import { errorMessage } from "../shared/text-utils.js";
|
|
4
5
|
import { commitProjectSelection, readProjectSelection } from "./project-scope-store.js";
|
|
5
6
|
function usage() {
|
|
6
|
-
return
|
|
7
|
-
|
|
8
|
-
用法:
|
|
9
|
-
|
|
10
|
-
- \`/project\` — 查看当前频道的项目目录与访问边界
|
|
11
|
-
- \`/project set <absolute-path>\` — 切换项目目录(需频道空闲,且目录在允许的可选根内)
|
|
12
|
-
- \`/project reset\` — 切回 app 默认项目目录`;
|
|
7
|
+
return renderSubcommandUsage("project");
|
|
13
8
|
}
|
|
14
|
-
|
|
9
|
+
/** Exported so `test/commands-subcommands.test.ts` can feed every broadcast example back through it. */
|
|
10
|
+
export function parseProjectCommand(args) {
|
|
15
11
|
const trimmed = args.trim();
|
|
16
12
|
if (!trimmed)
|
|
17
13
|
return { action: "show" };
|
|
@@ -33,26 +29,26 @@ function formatShow(options) {
|
|
|
33
29
|
const resolution = resolveProjectAccessPolicy(securityLoad.config, process.cwd());
|
|
34
30
|
const sandbox = currentProjectSandboxStatus();
|
|
35
31
|
const selection = readProjectSelection(options.channelDir);
|
|
36
|
-
const lines = ["
|
|
32
|
+
const lines = ["**项目作用域**"];
|
|
37
33
|
if (!selection) {
|
|
38
|
-
lines.push(
|
|
34
|
+
lines.push(`- 项目目录:\`${resolution.policy.defaultRoot}\`(尚未选择过,将在下次准入时采用 app 默认值)`);
|
|
39
35
|
}
|
|
40
36
|
else {
|
|
41
|
-
lines.push(
|
|
37
|
+
lines.push(`- 项目目录:\`${selection.projectRoot}\`(${selection.updatedBy},更新于 ${selection.updatedAt})`);
|
|
42
38
|
}
|
|
43
|
-
lines.push(
|
|
44
|
-
lines.push(
|
|
39
|
+
lines.push(`- 边界:${resolution.configured ? "project(文件工具被约束在此目录内)" : "unbounded(沿用旧的全局文件权限)"}`);
|
|
40
|
+
lines.push(`- Enforcement:${sandbox.level}(${sandbox.summary})`);
|
|
45
41
|
if (!resolution.configured) {
|
|
46
|
-
lines.push(
|
|
42
|
+
lines.push(`- 未配置 projectAccess:\`/project set\` 不可用。在 \`security.json\` 写入 projectAccess 段后即可使用。`);
|
|
47
43
|
}
|
|
48
44
|
else if (!resolution.mutable) {
|
|
49
|
-
lines.push("
|
|
45
|
+
lines.push("- projectAccess.defaultRoot 配置有误,项目切换已被禁用,见启动诊断。");
|
|
50
46
|
}
|
|
51
47
|
else {
|
|
52
|
-
lines.push(
|
|
48
|
+
lines.push(`- 可选根:${resolution.policy.allowedRoots.map((root) => `\`${root}\``).join("、")}`);
|
|
53
49
|
}
|
|
54
50
|
for (const diagnostic of resolution.diagnostics) {
|
|
55
|
-
lines.push(
|
|
51
|
+
lines.push(`- ⚠ ${diagnostic.message}`);
|
|
56
52
|
}
|
|
57
53
|
return lines.join("\n");
|
|
58
54
|
}
|
|
@@ -14,4 +14,24 @@ export interface HandleSubagentsCommandOptions {
|
|
|
14
14
|
* a live `ChannelRunner` (spec 041). Lazy — never called unless a `roles` view is actually rendered. */
|
|
15
15
|
getDetachedDiscovery?: () => Promise<SubAgentDiscoveryResult>;
|
|
16
16
|
}
|
|
17
|
+
type ListFilter = "default" | "running" | "failed" | "all";
|
|
18
|
+
type SubagentsCommand = {
|
|
19
|
+
action: "list";
|
|
20
|
+
filter: ListFilter;
|
|
21
|
+
} | {
|
|
22
|
+
action: "show";
|
|
23
|
+
ref: string;
|
|
24
|
+
} | {
|
|
25
|
+
action: "output";
|
|
26
|
+
ref: string;
|
|
27
|
+
} | {
|
|
28
|
+
action: "cancel";
|
|
29
|
+
ref: string;
|
|
30
|
+
} | {
|
|
31
|
+
action: "roles";
|
|
32
|
+
name?: string;
|
|
33
|
+
};
|
|
34
|
+
/** Exported so `test/commands-subcommands.test.ts` can feed every broadcast example back through it. */
|
|
35
|
+
export declare function parseSubagentsCommand(args: string): SubagentsCommand;
|
|
17
36
|
export declare function handleSubagentsCommand(options: HandleSubagentsCommandOptions): Promise<string>;
|
|
37
|
+
export {};
|
|
@@ -1,23 +1,14 @@
|
|
|
1
1
|
import { readFile } from "node:fs/promises";
|
|
2
2
|
import { join } from "node:path";
|
|
3
|
+
import { renderSubcommandUsage } from "../agent/commands.js";
|
|
3
4
|
import { errorMessage } from "../shared/text-utils.js";
|
|
4
5
|
import { formatCost, formatRunDuration, harnessLabel } from "../subagents/format.js";
|
|
5
6
|
import { getSubAgentRunManager } from "../subagents/runs.js";
|
|
6
7
|
function usage() {
|
|
7
|
-
return
|
|
8
|
-
|
|
9
|
-
用法:
|
|
10
|
-
|
|
11
|
-
- \`/subagents\` — 运行中的 run + 最近完成的几条 + 角色目录摘要
|
|
12
|
-
- \`/subagents list [running|failed|all]\` — 按状态筛选
|
|
13
|
-
- \`/subagents show <runId>\` — 单个 run 的完整详情(含实际 argv、stderr 尾部)
|
|
14
|
-
- \`/subagents output <runId>\` — 该 run 的文本产出(output.md 尾部)
|
|
15
|
-
- \`/subagents cancel <runId|all>\` — 直接终止,不经过模型
|
|
16
|
-
- \`/subagents roles [name]\` — 角色目录;带 name 时查看单个角色的详情
|
|
17
|
-
|
|
18
|
-
\`runId\` 支持不带 \`run_\` 前缀的简写,只要能唯一匹配即可,例如 \`show a1b2c3\`。`;
|
|
8
|
+
return `${renderSubcommandUsage("subagents")}\n\n\`runId\` 支持不带 \`run_\` 前缀的简写,只要能唯一匹配即可,例如 \`show a1b2c3\`。`;
|
|
19
9
|
}
|
|
20
|
-
|
|
10
|
+
/** Exported so `test/commands-subcommands.test.ts` can feed every broadcast example back through it. */
|
|
11
|
+
export function parseSubagentsCommand(args) {
|
|
21
12
|
const parts = args.trim().split(/\s+/).filter(Boolean);
|
|
22
13
|
const action = parts[0];
|
|
23
14
|
if (!action || action === "list") {
|
|
@@ -79,7 +70,7 @@ function formatRunLine(record) {
|
|
|
79
70
|
bits.push(cost);
|
|
80
71
|
const header = `- \`${record.runId}\` ${record.agent} (${bits.join(", ")}) — ${statusLabel(record.status)} — "${record.label}"`;
|
|
81
72
|
if (record.status === "failed" && record.failureReason) {
|
|
82
|
-
return `${header}
|
|
73
|
+
return `${header}(失败原因:${record.failureReason})`;
|
|
83
74
|
}
|
|
84
75
|
return header;
|
|
85
76
|
}
|
|
@@ -123,7 +114,7 @@ function capListForDisplay(records) {
|
|
|
123
114
|
async function listRuns(options, filter) {
|
|
124
115
|
const records = getSubAgentRunManager(options.channelId).list();
|
|
125
116
|
if (records.length === 0)
|
|
126
|
-
return "
|
|
117
|
+
return "**委派 Run**\n\n没有委派记录。";
|
|
127
118
|
const running = records.filter((record) => record.status === "running").sort((a, b) => b.startedAt - a.startedAt);
|
|
128
119
|
const terminal = records
|
|
129
120
|
.filter((record) => record.status !== "running")
|
|
@@ -134,30 +125,30 @@ async function listRuns(options, filter) {
|
|
|
134
125
|
sections.push(shown.length === 0 ? "没有正在运行的 run。" : shown.map(formatRunLine).join("\n"));
|
|
135
126
|
if (truncatedNote)
|
|
136
127
|
sections.push(truncatedNote);
|
|
137
|
-
return
|
|
128
|
+
return `**委派 Run** · 运行中\n\n${sections.join("\n\n")}`;
|
|
138
129
|
}
|
|
139
130
|
if (filter === "failed") {
|
|
140
131
|
const { shown, truncatedNote } = capListForDisplay(terminal.filter((record) => record.status === "failed"));
|
|
141
132
|
sections.push(shown.length === 0 ? "没有失败的 run。" : shown.map(formatRunLine).join("\n"));
|
|
142
133
|
if (truncatedNote)
|
|
143
134
|
sections.push(truncatedNote);
|
|
144
|
-
return
|
|
135
|
+
return `**委派 Run** · 失败\n\n${sections.join("\n\n")}`;
|
|
145
136
|
}
|
|
146
137
|
if (filter === "all") {
|
|
147
138
|
const { shown, truncatedNote } = capListForDisplay([...running, ...terminal]);
|
|
148
139
|
sections.push(shown.map(formatRunLine).join("\n"));
|
|
149
140
|
if (truncatedNote)
|
|
150
141
|
sections.push(truncatedNote);
|
|
151
|
-
return
|
|
142
|
+
return `**委派 Run** · 全部(${records.length})\n\n${sections.join("\n\n")}`;
|
|
152
143
|
}
|
|
153
144
|
// default: an overview — every running run, plus a capped tail of recent completions.
|
|
154
145
|
if (running.length > 0) {
|
|
155
|
-
sections.push(
|
|
146
|
+
sections.push(`**运行中**(${running.length})\n${running.map(formatRunLine).join("\n")}`);
|
|
156
147
|
}
|
|
157
148
|
const shown = terminal.slice(0, DEFAULT_LIST_COMPLETED_LIMIT);
|
|
158
149
|
if (shown.length > 0) {
|
|
159
150
|
const countNote = terminal.length > shown.length ? `显示 ${shown.length} / 共 ${terminal.length}` : `${shown.length}`;
|
|
160
|
-
sections.push(
|
|
151
|
+
sections.push(`**最近完成**(${countNote})\n${shown.map(formatRunLine).join("\n")}`);
|
|
161
152
|
}
|
|
162
153
|
if (sections.length === 0)
|
|
163
154
|
sections.push("没有委派记录。");
|
|
@@ -165,7 +156,7 @@ async function listRuns(options, filter) {
|
|
|
165
156
|
if (discovery)
|
|
166
157
|
sections.push(formatRolesTail(discovery));
|
|
167
158
|
sections.push("用 `/subagents show <runId>` 看详情,`/subagents output <runId>` 看产出。");
|
|
168
|
-
return
|
|
159
|
+
return `**委派 Run**\n\n${sections.join("\n\n")}`;
|
|
169
160
|
}
|
|
170
161
|
const STDERR_TAIL_CHARS = 2_000;
|
|
171
162
|
const OUTPUT_TAIL_CHARS = 4_000;
|
|
@@ -185,29 +176,28 @@ async function showRun(channelId, ref) {
|
|
|
185
176
|
return error ?? `未找到 run:\`${ref}\``;
|
|
186
177
|
const record = resolution.record;
|
|
187
178
|
const lines = [
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
`状态:${statusLabel(record.status)}(耗时 ${formatRunDuration(record)})`,
|
|
179
|
+
`**Run \`${record.runId}\`**`,
|
|
180
|
+
`- 角色:${record.agent} (${harnessLabel(record)}, ${record.source})`,
|
|
181
|
+
`- 标签:${record.label}`,
|
|
182
|
+
`- 状态:${statusLabel(record.status)}(耗时 ${formatRunDuration(record)})`,
|
|
193
183
|
];
|
|
194
184
|
if (record.failureReason)
|
|
195
|
-
lines.push(
|
|
185
|
+
lines.push(`- 失败原因:${record.failureReason}`);
|
|
196
186
|
if (record.verificationVerdict) {
|
|
197
|
-
lines.push(
|
|
187
|
+
lines.push(`- 验收结论:${record.verificationVerdict === "pass" ? "PASS" : "FAIL"}${record.verificationStrength === "advisory" ? "(advisory)" : ""}`);
|
|
198
188
|
}
|
|
199
|
-
lines.push(
|
|
189
|
+
lines.push(`- 开始:${new Date(record.startedAt).toLocaleString()}`);
|
|
200
190
|
if (record.finishedAt)
|
|
201
|
-
lines.push(
|
|
202
|
-
lines.push(
|
|
191
|
+
lines.push(`- 结束:${new Date(record.finishedAt).toLocaleString()}`);
|
|
192
|
+
lines.push(`- purpose:${record.purpose}`, `- 工作目录:\`${record.workingDirectory}\``, `- 产物目录:\`${record.artifactDir}\``);
|
|
203
193
|
if (record.taskId)
|
|
204
|
-
lines.push(
|
|
194
|
+
lines.push(`- 所属任务:${record.taskId}`);
|
|
205
195
|
if (record.leaseKey)
|
|
206
|
-
lines.push("持有写锁:是");
|
|
196
|
+
lines.push("- 持有写锁:是");
|
|
207
197
|
if (record.model)
|
|
208
|
-
lines.push(
|
|
198
|
+
lines.push(`- 模型:${record.model}`);
|
|
209
199
|
const cost = formatCost(record);
|
|
210
|
-
lines.push(
|
|
200
|
+
lines.push(`- usage:input=${record.usage.input} output=${record.usage.output}${cost ? ` cost=${cost}` : record.costKnown ? "" : "(cost 未知)"}`);
|
|
211
201
|
if (record.argv)
|
|
212
202
|
lines.push("", "实际 argv:", "```", JSON.stringify(record.argv), "```");
|
|
213
203
|
if (record.parserVersion !== undefined || record.cliVersion) {
|
|
@@ -217,19 +207,19 @@ async function showRun(channelId, ref) {
|
|
|
217
207
|
if (record.parserVersion !== undefined)
|
|
218
208
|
parts.push(`parserVersion=${record.parserVersion}`);
|
|
219
209
|
parts.push(`cliVersion=${record.cliVersion ?? "(未知)"}`);
|
|
220
|
-
lines.push(
|
|
210
|
+
lines.push(`- 适配器/CLI:${parts.join(",")}`);
|
|
221
211
|
}
|
|
222
212
|
if (record.invocationWarnings?.length) {
|
|
223
213
|
lines.push("", "⚠ 派发时的警告:", ...record.invocationWarnings.map((warning) => `- ${warning}`));
|
|
224
214
|
}
|
|
225
215
|
if (record.sessionId)
|
|
226
|
-
lines.push(
|
|
216
|
+
lines.push(`- sessionId:\`${record.sessionId}\`(可用于 subagent_run op=follow_up)`);
|
|
227
217
|
if (record.runtime === "external") {
|
|
228
218
|
const stderrTail = await readFile(join(record.artifactDir, "stderr.log"), "utf-8")
|
|
229
219
|
.then((text) => text.slice(-STDERR_TAIL_CHARS))
|
|
230
220
|
.catch(() => undefined);
|
|
231
221
|
if (stderrTail?.trim()) {
|
|
232
|
-
lines.push("", "
|
|
222
|
+
lines.push("", "**stderr(尾部)**", "```", stderrTail, "```");
|
|
233
223
|
}
|
|
234
224
|
}
|
|
235
225
|
return lines.join("\n");
|
|
@@ -243,11 +233,11 @@ async function showOutput(channelId, ref) {
|
|
|
243
233
|
const outputText = await readFile(join(record.artifactDir, "output.md"), "utf-8").catch(() => undefined);
|
|
244
234
|
if (!outputText?.trim()) {
|
|
245
235
|
const runningNote = record.status === "running" ? "该 run 仍在运行,可能还没有产出。" : "该 run 没有文本产出。";
|
|
246
|
-
return
|
|
236
|
+
return `**Run \`${record.runId}\` 的产出**\n\n${runningNote}产物目录:\`${record.artifactDir}\``;
|
|
247
237
|
}
|
|
248
238
|
const tail = outputText.slice(-OUTPUT_TAIL_CHARS);
|
|
249
239
|
const truncatedNote = outputText.length > tail.length ? `(只显示末尾 ${OUTPUT_TAIL_CHARS} 字符,完整内容见上方产物目录)\n\n` : "";
|
|
250
|
-
return
|
|
240
|
+
return `**Run \`${record.runId}\` 的产出**\n\n${truncatedNote}\`\`\`\n${tail}\n\`\`\``;
|
|
251
241
|
}
|
|
252
242
|
async function cancelRun(channelId, ref) {
|
|
253
243
|
const manager = getSubAgentRunManager(channelId);
|
|
@@ -259,7 +249,7 @@ async function cancelRun(channelId, ref) {
|
|
|
259
249
|
const status = await manager.cancel(record.runId);
|
|
260
250
|
return `- \`${record.runId}\` (${record.agent}):${status}`;
|
|
261
251
|
}));
|
|
262
|
-
return
|
|
252
|
+
return `**已请求终止 ${running.length} 个 run**\n\n${results.join("\n")}`;
|
|
263
253
|
}
|
|
264
254
|
const resolution = manager.resolveRef(ref);
|
|
265
255
|
const error = formatRunResolution(resolution, ref);
|
|
@@ -277,34 +267,47 @@ function formatRoleSummaryLine(agent) {
|
|
|
277
267
|
function formatRoleDetail(agent) {
|
|
278
268
|
const kind = agent.runtime === "external" ? `外部/${agent.harness}` : "内置";
|
|
279
269
|
const lines = [
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
`说明:${agent.description}`,
|
|
270
|
+
`**角色 \`${agent.name}\`**`,
|
|
271
|
+
`- runtime:${kind}`,
|
|
272
|
+
`- 来源:${agent.source} (${agent.filePath ?? "inline"})`,
|
|
273
|
+
`- 说明:${agent.description}`,
|
|
285
274
|
];
|
|
286
275
|
if (agent.unavailable)
|
|
287
|
-
lines.push(
|
|
288
|
-
lines.push(
|
|
276
|
+
lines.push(`- ⚠ 不可用:${agent.unavailable}`);
|
|
277
|
+
lines.push(`- mutates:${agent.mutates ?? "(未声明,由 tools 推断)"}`);
|
|
289
278
|
if (agent.runtime === "internal") {
|
|
290
|
-
lines.push(
|
|
279
|
+
lines.push(`- 模型:${agent.modelRef ?? "(默认)"}`, `- tools:${agent.tools.join(", ") || "(none)"}`, `- 预算:maxTurns=${agent.maxTurns} maxToolCalls=${agent.maxToolCalls} maxWallTimeSec=${agent.maxWallTimeSec} bashTimeoutSec=${agent.bashTimeoutSec}`, `- contextMode:${agent.contextMode},memory:${agent.memory}`);
|
|
291
280
|
}
|
|
292
281
|
else {
|
|
293
|
-
lines.push(
|
|
282
|
+
lines.push(`- command:\`${agent.command ?? ""}\`${agent.shell ? "(通过 shell 执行)" : ""}`, `- maxWallTimeSec:${agent.maxWallTimeSec}`);
|
|
294
283
|
if (agent.externalModelRef)
|
|
295
|
-
lines.push(
|
|
284
|
+
lines.push(`- 模型:${agent.externalModelRef}`);
|
|
296
285
|
// spec 042 D4: contextMode/memory are effective for external roles too (memory 默认 none,
|
|
297
286
|
// 显式声明 session/relevant 才会把频道会话状态发给外部进程) — 显示出来而不是只在内置分支里说明。
|
|
298
|
-
lines.push(
|
|
287
|
+
lines.push(`- contextMode:${agent.contextMode},memory:${agent.memory}`);
|
|
299
288
|
if (agent.memory !== "none") {
|
|
300
|
-
lines.push(
|
|
289
|
+
lines.push(`- ⚠ 该角色会把频道会话状态/记忆片段发送给外部进程(memory: ${agent.memory})`);
|
|
301
290
|
}
|
|
302
291
|
}
|
|
303
292
|
if (agent.paths.length > 0)
|
|
304
|
-
lines.push(
|
|
305
|
-
|
|
293
|
+
lines.push(`- paths:${agent.paths.join(", ")}`);
|
|
294
|
+
// A full system prompt can be several KB; a role backed by a file is shown as a head snippet
|
|
295
|
+
// with a pointer to that file instead (review 2026-08-24 §2.4/§3.2). Inline roles have no file
|
|
296
|
+
// to point to, so they get a plain truncation note instead.
|
|
297
|
+
lines.push("", "system prompt:", renderCappedPromptBlock(agent));
|
|
306
298
|
return lines.join("\n");
|
|
307
299
|
}
|
|
300
|
+
const SYSTEM_PROMPT_SHOW_MAX_CHARS = 4_000;
|
|
301
|
+
function renderCappedPromptBlock(agent) {
|
|
302
|
+
const prompt = agent.systemPrompt;
|
|
303
|
+
if (prompt.length <= SYSTEM_PROMPT_SHOW_MAX_CHARS) {
|
|
304
|
+
return `\`\`\`\n${prompt}\n\`\`\``;
|
|
305
|
+
}
|
|
306
|
+
const lastNewline = prompt.lastIndexOf("\n", SYSTEM_PROMPT_SHOW_MAX_CHARS);
|
|
307
|
+
const head = prompt.slice(0, lastNewline > 0 ? lastNewline : SYSTEM_PROMPT_SHOW_MAX_CHARS).trimEnd();
|
|
308
|
+
const nextStep = agent.filePath ? `完整内容见 \`${agent.filePath}\`` : "该角色内联定义,无文件可查看完整内容";
|
|
309
|
+
return `\`\`\`\n${head}\n\`\`\`\n\n(内容过长已截断;${nextStep})`;
|
|
310
|
+
}
|
|
308
311
|
async function showRoles(options, name) {
|
|
309
312
|
const discovery = await resolveDiscovery(options);
|
|
310
313
|
if (!discovery) {
|
|
@@ -320,11 +323,11 @@ async function showRoles(options, name) {
|
|
|
320
323
|
}
|
|
321
324
|
const internal = discovery.agents.filter((agent) => agent.runtime === "internal");
|
|
322
325
|
const external = discovery.agents.filter((agent) => agent.runtime === "external");
|
|
323
|
-
const sections = [
|
|
326
|
+
const sections = [`**角色目录**\n\n目录:\`${discovery.directory}\``];
|
|
324
327
|
if (external.length > 0)
|
|
325
|
-
sections.push(
|
|
328
|
+
sections.push(`**外部**\n${external.map(formatRoleSummaryLine).join("\n")}`);
|
|
326
329
|
if (internal.length > 0)
|
|
327
|
-
sections.push(
|
|
330
|
+
sections.push(`**内置**\n${internal.map(formatRoleSummaryLine).join("\n")}`);
|
|
328
331
|
if (discovery.agents.length === 0)
|
|
329
332
|
sections.push("目录为空。");
|
|
330
333
|
for (const warning of discovery.warnings)
|
|
@@ -8,6 +8,43 @@ export interface HandleTasksCommandOptions {
|
|
|
8
8
|
/** Optional immediate task wake, available in the long-lived DingTalk runtime. */
|
|
9
9
|
dispatchTask?: (id: string) => Promise<boolean>;
|
|
10
10
|
}
|
|
11
|
+
/**
|
|
12
|
+
* Fields `/tasks set` can edit directly.
|
|
13
|
+
*
|
|
14
|
+
* Deliberately a small, flat set: the ones a user already knows they want to change (when it
|
|
15
|
+
* should wake, what it should do next, how much rope it has). Everything structural — status
|
|
16
|
+
* transitions and verification — stays with `task_update`/`task_close`/`task_verify`, whose state
|
|
17
|
+
* machine those fields belong to. The value is the rest of the line, so it may contain spaces.
|
|
18
|
+
*/
|
|
19
|
+
declare const SETTABLE_TASK_FIELDS: readonly ["wake", "next", "deadline"];
|
|
20
|
+
type SettableTaskField = (typeof SETTABLE_TASK_FIELDS)[number];
|
|
21
|
+
type TasksCommand = {
|
|
22
|
+
action: "list";
|
|
23
|
+
} | {
|
|
24
|
+
action: "show";
|
|
25
|
+
id: string;
|
|
26
|
+
} | {
|
|
27
|
+
action: "archive";
|
|
28
|
+
} | {
|
|
29
|
+
action: "doctor";
|
|
30
|
+
} | {
|
|
31
|
+
action: "pause";
|
|
32
|
+
id: string;
|
|
33
|
+
} | {
|
|
34
|
+
action: "resume";
|
|
35
|
+
id: string;
|
|
36
|
+
} | {
|
|
37
|
+
action: "run";
|
|
38
|
+
id: string;
|
|
39
|
+
} | {
|
|
40
|
+
action: "set";
|
|
41
|
+
id: string;
|
|
42
|
+
field: SettableTaskField;
|
|
43
|
+
value: string;
|
|
44
|
+
};
|
|
45
|
+
/** Exported so `test/commands-subcommands.test.ts` can feed every broadcast example back through it. */
|
|
46
|
+
export declare function parseTasksCommand(args: string): TasksCommand;
|
|
11
47
|
export declare function pauseTask(options: HandleTasksCommandOptions, idInput: string): Promise<string>;
|
|
12
48
|
export declare function resumeTask(options: HandleTasksCommandOptions, idInput: string): Promise<string>;
|
|
13
49
|
export declare function handleTasksCommand(options: HandleTasksCommandOptions): Promise<string>;
|
|
50
|
+
export {};
|