@oyasmi/pipiclaw 0.9.1-beta.1 → 0.9.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 +7 -1
- package/dist/agent/channel-runner.js +42 -15
- 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/prompt/manifest.js +5 -6
- package/dist/agent/prompt/sections.js +1 -0
- package/dist/agent/reply-limits.d.ts +16 -0
- package/dist/agent/reply-limits.js +17 -0
- package/dist/agent/runner-factory.d.ts +0 -2
- package/dist/agent/session-events.js +2 -2
- package/dist/agent/status-render.js +12 -12
- package/dist/executor.d.ts +14 -0
- package/dist/executor.js +36 -6
- 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 +33 -12
- 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 +24 -5
- package/dist/memory/lifecycle.js +9 -2
- package/dist/memory/maintenance-jobs.js +14 -4
- package/dist/memory/metadata.d.ts +3 -0
- package/dist/memory/metadata.js +7 -0
- package/dist/memory/recall.d.ts +9 -0
- package/dist/memory/recall.js +101 -17
- 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 +9 -0
- 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/task-digest.js +0 -2
- package/dist/playbooks/agent-delegation.md +32 -24
- package/dist/playbooks/background-jobs.md +8 -16
- package/dist/playbooks/event-scheduling.md +13 -15
- package/dist/playbooks/memory-and-learning.md +29 -22
- package/dist/playbooks/outbound-media.md +15 -8
- package/dist/playbooks/runtime-orientation.md +40 -37
- package/dist/playbooks/task-driving.md +34 -38
- package/dist/playbooks/task-planning.md +18 -20
- package/dist/runtime/app-home.d.ts +6 -0
- package/dist/runtime/app-home.js +15 -6
- package/dist/runtime/bootstrap.d.ts +1 -1
- package/dist/runtime/bootstrap.js +57 -62
- package/dist/runtime/channel-context.d.ts +2 -1
- package/dist/runtime/channel-event.d.ts +0 -6
- package/dist/runtime/delivery.js +3 -3
- package/dist/runtime/dingtalk.d.ts +9 -1
- package/dist/runtime/dingtalk.js +27 -13
- package/dist/runtime/event-commands.d.ts +15 -0
- package/dist/runtime/event-commands.js +48 -40
- 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 +38 -1
- package/dist/runtime/task-commands.js +135 -234
- package/dist/runtime/task-driver.d.ts +1 -3
- package/dist/runtime/task-driver.js +34 -40
- package/dist/runtime/task-migration.d.ts +7 -6
- package/dist/runtime/task-migration.js +85 -19
- package/dist/runtime/task-wake.d.ts +3 -5
- package/dist/runtime/task-wake.js +7 -15
- package/dist/security/path-guard.js +33 -2
- package/dist/security/types.d.ts +9 -0
- package/dist/subagents/discovery.d.ts +7 -2
- package/dist/subagents/discovery.js +31 -7
- package/dist/subagents/external/claude-code.js +42 -2
- package/dist/subagents/external/run.js +72 -2
- package/dist/subagents/runs.js +28 -3
- package/dist/subagents/tool.d.ts +11 -0
- package/dist/subagents/tool.js +89 -55
- package/dist/subagents/verification-outcome.js +17 -10
- package/dist/tasks/control.d.ts +18 -67
- package/dist/tasks/control.js +44 -176
- package/dist/tasks/ledger.d.ts +7 -13
- package/dist/tasks/ledger.js +13 -49
- package/dist/tasks/store.d.ts +15 -48
- package/dist/tasks/store.js +22 -154
- package/dist/tasks/transitions.d.ts +3 -4
- package/dist/tasks/transitions.js +8 -27
- package/dist/tasks/verification.d.ts +7 -5
- package/dist/tools/bash.d.ts +1 -1
- package/dist/tools/bash.js +77 -59
- package/dist/tools/edit.js +17 -4
- package/dist/tools/grep.js +3 -2
- package/dist/tools/index.d.ts +0 -2
- package/dist/tools/index.js +6 -1
- package/dist/tools/job.js +2 -1
- package/dist/tools/memory-manage.d.ts +1 -0
- package/dist/tools/memory-manage.js +54 -16
- package/dist/tools/read.js +21 -5
- package/dist/tools/registry.d.ts +0 -1
- package/dist/tools/registry.js +0 -1
- package/dist/tools/send-media.js +17 -6
- package/dist/tools/skill-manage.js +12 -11
- package/dist/tools/skill-security.js +1 -1
- package/dist/tools/subagent-manage.d.ts +8 -1
- package/dist/tools/subagent-manage.js +77 -7
- package/dist/tools/task-manage/lifecycle.js +19 -17
- package/dist/tools/task-manage/schema.d.ts +2 -6
- package/dist/tools/task-manage/schema.js +4 -17
- package/dist/tools/task-manage/shared.js +1 -6
- package/dist/tools/task-manage/types.d.ts +0 -3
- package/dist/tools/task-manage/verification.d.ts +9 -6
- package/dist/tools/task-manage/verification.js +19 -71
- package/dist/tools/task-manage.d.ts +1 -1
- package/dist/tools/task-manage.js +3 -5
- package/dist/tools/truncate.d.ts +8 -0
- package/dist/tools/truncate.js +8 -0
- package/dist/tools/web-fetch.js +9 -1
- package/dist/tools/write-content.js +11 -1
- 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.d.ts +4 -0
- package/dist/usage/ledger.js +3 -0
- package/dist/usage/render.js +10 -8
- package/examples/sub-agents/README.md +2 -0
- package/package.json +3 -2
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
import { existsSync } from "node:fs";
|
|
2
2
|
import { readdir, readFile } from "node:fs/promises";
|
|
3
3
|
import { join, resolve, sep } from "node:path";
|
|
4
|
+
import { renderSubcommandUsage } from "../agent/commands.js";
|
|
4
5
|
import { channelJobTaskIds } from "../agent/job-manager.js";
|
|
6
|
+
import { capReply } from "../agent/reply-limits.js";
|
|
5
7
|
import { formatLocalTime, parseLocalTime, parseWakeInput } from "../shared/local-time.js";
|
|
6
8
|
import { errorMessage } from "../shared/text-utils.js";
|
|
7
|
-
import { isRecord } from "../shared/type-guards.js";
|
|
8
9
|
import { channelDelegationTaskIds } from "../subagents/runs.js";
|
|
9
|
-
import { applyTaskControlPatch, createDefaultTaskControl,
|
|
10
|
-
import { countTaskDodItems, extractTaskTitle,
|
|
10
|
+
import { applyTaskControlPatch, createDefaultTaskControl, taskBudgetViolation } from "../tasks/control.js";
|
|
11
|
+
import { countTaskDodItems, extractTaskTitle, missingStandardTaskSections, normalizeTaskId, readActiveTasks, recurringTaskMissedOccurrence, } from "../tasks/ledger.js";
|
|
11
12
|
import { withTaskMutation } from "../tasks/mutation-lock.js";
|
|
12
|
-
import {
|
|
13
|
+
import { openRecurringTaskCycle, readStoredTask, taskBodyHash, writeStoredTask } from "../tasks/store.js";
|
|
13
14
|
import { parseTaskEventName, taskEventPrefix } from "../tasks/task-events.js";
|
|
14
15
|
import { nextTaskWake, validateTaskSchedule } from "../tasks/task-schedule.js";
|
|
15
16
|
import { normalizeStoredStatus, resolveTaskTransition } from "../tasks/transitions.js";
|
|
@@ -23,23 +24,16 @@ import { parseScheduledEventContent } from "./events.js";
|
|
|
23
24
|
* transitions and verification — stays with `task_manage`, whose state
|
|
24
25
|
* machine those fields belong to. The value is the rest of the line, so it may contain spaces.
|
|
25
26
|
*/
|
|
26
|
-
const SETTABLE_TASK_FIELDS = ["wake", "next", "
|
|
27
|
+
const SETTABLE_TASK_FIELDS = ["wake", "next", "deadline"];
|
|
28
|
+
/** `/tasks show <id>` head-snippet cap; the full file is always readable at its own path. */
|
|
29
|
+
const TASK_SHOW_MAX_CHARS = 4_000;
|
|
30
|
+
// Broadcast (subcommand names, args, descriptions, examples) lives once in commands.ts's
|
|
31
|
+
// `BUILT_IN_COMMANDS` entry for "tasks"; this just renders it (review 2026-08-24 §3.1).
|
|
27
32
|
function usage() {
|
|
28
|
-
return
|
|
29
|
-
|
|
30
|
-
用法:
|
|
31
|
-
|
|
32
|
-
- \`/tasks\` — 列出本频道进行中的任务
|
|
33
|
-
- \`/tasks show <id>\` — 查看单个任务文件(进行中或已归档)
|
|
34
|
-
- \`/tasks archive\` — 列出已归档(已关闭)的任务
|
|
35
|
-
- \`/tasks pause <id>\` — 停止该任务的自动执行(保留当前阶段与 wake)
|
|
36
|
-
- \`/tasks resume <id>\` — 重新启用该任务,按当前阶段继续
|
|
37
|
-
- \`/tasks run <id>\` — 恢复并立即排入一次执行(需要运行时可用)
|
|
38
|
-
- \`/tasks set <id> <${SETTABLE_TASK_FIELDS.join("|")}> <值>\` — 直接改一个字段,不花一个 LLM 回合
|
|
39
|
-
- \`/tasks stats [id]\` — 查看任务级的尝试次数、token、花费与验收结果
|
|
40
|
-
- \`/tasks doctor\` — 只读检查任务/事件一致性`;
|
|
33
|
+
return renderSubcommandUsage("tasks");
|
|
41
34
|
}
|
|
42
|
-
|
|
35
|
+
/** Exported so `test/commands-subcommands.test.ts` can feed every broadcast example back through it. */
|
|
36
|
+
export function parseTasksCommand(args) {
|
|
43
37
|
const trimmed = args.trim();
|
|
44
38
|
const parts = trimmed.split(/\s+/).filter(Boolean);
|
|
45
39
|
const action = parts[0];
|
|
@@ -90,12 +84,6 @@ function parseTasksCommand(args) {
|
|
|
90
84
|
value: match[3].trim(),
|
|
91
85
|
};
|
|
92
86
|
}
|
|
93
|
-
if (action === "stats") {
|
|
94
|
-
const id = parts[1];
|
|
95
|
-
if (parts.length > 2)
|
|
96
|
-
throw new Error("用法:/tasks stats [id]");
|
|
97
|
-
return { action: "stats", id };
|
|
98
|
-
}
|
|
99
87
|
throw new Error(`未知的 /tasks 动作:${action}`);
|
|
100
88
|
}
|
|
101
89
|
function tasksDir(channelDir) {
|
|
@@ -113,14 +101,42 @@ function resolveTaskPath(dir, id, subdir) {
|
|
|
113
101
|
}
|
|
114
102
|
function relativeWake(wakeMs, now) {
|
|
115
103
|
if (wakeMs === undefined)
|
|
116
|
-
return "
|
|
104
|
+
return "无唤醒时间";
|
|
117
105
|
const local = formatLocalTime(new Date(wakeMs));
|
|
118
106
|
const diffMs = wakeMs - now;
|
|
119
107
|
if (diffMs <= 0)
|
|
120
|
-
return `${local}
|
|
108
|
+
return `${local}(已到期)`;
|
|
121
109
|
const minutes = Math.round(diffMs / 60000);
|
|
122
|
-
const rel = minutes < 60
|
|
123
|
-
|
|
110
|
+
const rel = minutes < 60
|
|
111
|
+
? `${minutes}分钟后`
|
|
112
|
+
: minutes < 1440
|
|
113
|
+
? `${Math.round(minutes / 60)}小时后`
|
|
114
|
+
: `${Math.round(minutes / 1440)}天后`;
|
|
115
|
+
return `${local}(${rel})`;
|
|
116
|
+
}
|
|
117
|
+
function taskStatusLabel(status) {
|
|
118
|
+
switch (status) {
|
|
119
|
+
case "active":
|
|
120
|
+
return "进行中";
|
|
121
|
+
case "waiting":
|
|
122
|
+
return "等待中";
|
|
123
|
+
case "sleeping":
|
|
124
|
+
return "睡眠中";
|
|
125
|
+
default:
|
|
126
|
+
return status;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
function verificationStatusLabel(status) {
|
|
130
|
+
switch (status) {
|
|
131
|
+
case "pending":
|
|
132
|
+
return "待验收";
|
|
133
|
+
case "passed":
|
|
134
|
+
return "已通过";
|
|
135
|
+
case "failed":
|
|
136
|
+
return "未通过";
|
|
137
|
+
default:
|
|
138
|
+
return status;
|
|
139
|
+
}
|
|
124
140
|
}
|
|
125
141
|
function eventDir(workspaceDir) {
|
|
126
142
|
return join(workspaceDir, "events");
|
|
@@ -165,27 +181,7 @@ function validWakeMs(entry) {
|
|
|
165
181
|
return parseLocalTime(wake);
|
|
166
182
|
}
|
|
167
183
|
function issue(problem, nextStep) {
|
|
168
|
-
return `- ${problem}
|
|
169
|
-
}
|
|
170
|
-
/**
|
|
171
|
-
* Render the ordering edges a stored task still declares, e.g. `child → parent, a → b`.
|
|
172
|
-
* Empty when the task carries no retired relation keys (spec 036, D8).
|
|
173
|
-
*/
|
|
174
|
-
function describeDroppedTaskRelations(id, rawControl) {
|
|
175
|
-
if (!isRecord(rawControl))
|
|
176
|
-
return "";
|
|
177
|
-
const edges = [];
|
|
178
|
-
const parent = rawControl.parent;
|
|
179
|
-
if (typeof parent === "string" && parent.trim())
|
|
180
|
-
edges.push(`${id} → ${parent.trim()}`);
|
|
181
|
-
const dependsOn = rawControl.dependsOn;
|
|
182
|
-
if (Array.isArray(dependsOn)) {
|
|
183
|
-
for (const dependency of dependsOn) {
|
|
184
|
-
if (typeof dependency === "string" && dependency.trim())
|
|
185
|
-
edges.push(`${id} → ${dependency.trim()}`);
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
return edges.join(", ");
|
|
184
|
+
return `- ${problem}(下一步:${nextStep})`;
|
|
189
185
|
}
|
|
190
186
|
async function readActiveTaskContent(channelDir, id) {
|
|
191
187
|
try {
|
|
@@ -200,39 +196,42 @@ async function listTasks(channelDir) {
|
|
|
200
196
|
const now = Date.now();
|
|
201
197
|
const entries = (await readActiveTasks(dir, now)).filter((entry) => !entry.frontmatter.archiveOutcome);
|
|
202
198
|
if (entries.length === 0) {
|
|
203
|
-
return "
|
|
199
|
+
return "**任务**\n\n暂无进行中的任务。用 `/tasks archive` 查看已归档任务。";
|
|
204
200
|
}
|
|
205
201
|
const blocks = entries.map((entry) => {
|
|
206
|
-
|
|
207
|
-
|
|
202
|
+
if (!entry.frontmatter.readable) {
|
|
203
|
+
return `**${entry.id}** — ${entry.title}\n- ⚠ frontmatter 无法读取,status/wake 不可信`;
|
|
204
|
+
}
|
|
205
|
+
const status = entry.frontmatter.status ?? "active";
|
|
206
|
+
const lines = [
|
|
207
|
+
`**${entry.id}** — ${entry.title}`,
|
|
208
|
+
`- 状态:${taskStatusLabel(status)} · 下次唤醒 ${relativeWake(entry.wakeMs, now)}`,
|
|
209
|
+
];
|
|
208
210
|
const control = entry.frontmatter.control;
|
|
209
211
|
if (control) {
|
|
210
|
-
detail.push(`priority: ${control.priority}`);
|
|
211
|
-
detail.push(`attempts: ${control.usage.attempts}/${control.budget.maxAttempts}`);
|
|
212
212
|
if (control.verification.required)
|
|
213
|
-
|
|
213
|
+
lines.push(`- 验收:需要验收,${verificationStatusLabel(control.verification.status)}`);
|
|
214
214
|
if (control.waitingFor)
|
|
215
|
-
|
|
215
|
+
lines.push(`- 等待:${control.waitingFor}`);
|
|
216
216
|
if (control.stop)
|
|
217
|
-
|
|
217
|
+
lines.push(`- 已停用:${control.stop.by} — ${control.stop.reason}`);
|
|
218
218
|
if (control.deadline)
|
|
219
|
-
|
|
219
|
+
lines.push(`- 截止:${control.deadline}`);
|
|
220
220
|
if (control.nextAction)
|
|
221
|
-
|
|
222
|
-
if (control.cycleId)
|
|
223
|
-
|
|
224
|
-
}
|
|
221
|
+
lines.push(`- 下一步:${control.nextAction}`);
|
|
222
|
+
if (control.cycleId)
|
|
223
|
+
lines.push(`- ${status === "sleeping" ? "上一周期" : "当前周期"}:${control.cycleId}`);
|
|
225
224
|
}
|
|
226
225
|
if (entry.frontmatter.enabled === false)
|
|
227
|
-
|
|
228
|
-
if (entry.frontmatter.recurrence)
|
|
229
|
-
detail.push(`recurrence: ${entry.frontmatter.recurrence}`);
|
|
226
|
+
lines.push("- 已停用(enabled: false)");
|
|
230
227
|
if (entry.frontmatter.schedule) {
|
|
231
|
-
|
|
228
|
+
lines.push(`- 调度时区:${Intl.DateTimeFormat().resolvedOptions().timeZone}(本机)`);
|
|
232
229
|
}
|
|
233
|
-
return
|
|
230
|
+
return lines.join("\n");
|
|
234
231
|
});
|
|
235
|
-
|
|
232
|
+
const footer = "详情 `/tasks show <id>`,体检 `/tasks doctor`";
|
|
233
|
+
const body = `**任务** · ${entries.length} 个进行中\n\n${blocks.join("\n\n")}\n\n${footer}`;
|
|
234
|
+
return capReply(body, { nextStepHint: "用 `/tasks show <id>` 查看单个任务的完整状态" }).text;
|
|
236
235
|
}
|
|
237
236
|
export async function pauseTask(options, idInput) {
|
|
238
237
|
const id = normalizeTaskId(idInput);
|
|
@@ -242,7 +241,7 @@ async function pauseTaskLocked(options, id) {
|
|
|
242
241
|
const task = await readStoredTask(options.channelDir, id);
|
|
243
242
|
if (!task)
|
|
244
243
|
return `找不到任务:${id}`;
|
|
245
|
-
const from = normalizeStoredStatus(task.fields.status
|
|
244
|
+
const from = normalizeStoredStatus(task.fields.status);
|
|
246
245
|
try {
|
|
247
246
|
resolveTaskTransition("pause", id, from);
|
|
248
247
|
}
|
|
@@ -263,7 +262,7 @@ export async function resumeTask(options, idInput) {
|
|
|
263
262
|
const task = await readStoredTask(options.channelDir, id);
|
|
264
263
|
if (!task)
|
|
265
264
|
return `找不到任务:${id}`;
|
|
266
|
-
const from = normalizeStoredStatus(task.fields.status
|
|
265
|
+
const from = normalizeStoredStatus(task.fields.status);
|
|
267
266
|
if (task.fields.enabled !== false)
|
|
268
267
|
return `任务 ${id} 已启用。`;
|
|
269
268
|
resolveTaskTransition("resume", id, from);
|
|
@@ -303,13 +302,7 @@ async function setTaskField(options, idInput, field, value) {
|
|
|
303
302
|
else {
|
|
304
303
|
const control = task.fields.control ?? createDefaultTaskControl();
|
|
305
304
|
try {
|
|
306
|
-
task.fields.control = applyTaskControlPatch(control, field === "next"
|
|
307
|
-
? { nextAction: value }
|
|
308
|
-
: field === "deadline"
|
|
309
|
-
? { deadline: value }
|
|
310
|
-
: field === "priority"
|
|
311
|
-
? { priority: parseTaskPriority(value) }
|
|
312
|
-
: { maxAttempts: parseAttempts(value) });
|
|
305
|
+
task.fields.control = applyTaskControlPatch(control, field === "next" ? { nextAction: value } : { deadline: value });
|
|
313
306
|
}
|
|
314
307
|
catch (error) {
|
|
315
308
|
return errorMessage(error);
|
|
@@ -318,19 +311,6 @@ async function setTaskField(options, idInput, field, value) {
|
|
|
318
311
|
await writeStoredTask(task);
|
|
319
312
|
return `已更新任务 ${id}:${field} = ${value || "(已清除)"}`;
|
|
320
313
|
}
|
|
321
|
-
function parseTaskPriority(value) {
|
|
322
|
-
if (!TASK_PRIORITIES.includes(value)) {
|
|
323
|
-
throw new Error(`priority 必须是 ${TASK_PRIORITIES.join(" / ")} 之一。`);
|
|
324
|
-
}
|
|
325
|
-
return value;
|
|
326
|
-
}
|
|
327
|
-
function parseAttempts(value) {
|
|
328
|
-
const parsed = Number(value);
|
|
329
|
-
if (!Number.isInteger(parsed) || parsed < 1) {
|
|
330
|
-
throw new Error("attempts 必须是不小于 1 的整数。");
|
|
331
|
-
}
|
|
332
|
-
return parsed;
|
|
333
|
-
}
|
|
334
314
|
async function runTask(options, idInput) {
|
|
335
315
|
const id = normalizeTaskId(idInput);
|
|
336
316
|
const task = await readStoredTask(options.channelDir, id);
|
|
@@ -359,77 +339,14 @@ async function runTask(options, idInput) {
|
|
|
359
339
|
if (task.fields.control) {
|
|
360
340
|
task.fields.control.stop = undefined;
|
|
361
341
|
task.fields.control.waitingFor = undefined;
|
|
362
|
-
task.fields.control.blockedReason = undefined;
|
|
363
342
|
}
|
|
364
343
|
await writeStoredTask(task);
|
|
365
344
|
}
|
|
366
|
-
const
|
|
367
|
-
const enqueued = await options.dispatchTask?.(id, claim?.generation);
|
|
368
|
-
if (!enqueued && claim)
|
|
369
|
-
await releaseTaskAttemptClaim(options.channelDir, id, claim);
|
|
345
|
+
const enqueued = await options.dispatchTask?.(id);
|
|
370
346
|
return enqueued
|
|
371
347
|
? `已把任务 ${id} 排入一次立即执行。`
|
|
372
348
|
: `任务 ${id} 已就绪。启动钉钉守护进程可自动派发,或在本会话里直接发一条普通消息推进它。`;
|
|
373
349
|
}
|
|
374
|
-
function renderUsageLine(entry) {
|
|
375
|
-
const control = entry.frontmatter.control;
|
|
376
|
-
if (!control)
|
|
377
|
-
return `- ${entry.id}:旧格式任务(没有受治理的用量记录)`;
|
|
378
|
-
const verification = control.verification;
|
|
379
|
-
const cycleCost = control.usage.costKnown ? `$${control.usage.costUsd.toFixed(4)}` : "unavailable";
|
|
380
|
-
return [
|
|
381
|
-
`- ${entry.id} — ${entry.title}`,
|
|
382
|
-
` this cycle: ${control.usage.attempts}/${control.budget.maxAttempts} attempts, ${control.usage.tokens} tokens, ${cycleCost}, ${control.usage.wallTimeMinutes.toFixed(1)}m`,
|
|
383
|
-
` last run: ${control.lastOutcome}`,
|
|
384
|
-
` verification: ${verification.required ? "required" : "not required"}/${verification.status}`,
|
|
385
|
-
].join("\n");
|
|
386
|
-
}
|
|
387
|
-
async function taskStats(options, idInput) {
|
|
388
|
-
if (idInput) {
|
|
389
|
-
const id = normalizeTaskId(idInput);
|
|
390
|
-
const task = await readStoredTask(options.channelDir, id, true, true);
|
|
391
|
-
if (!task)
|
|
392
|
-
return `找不到任务:${id}`;
|
|
393
|
-
const entry = {
|
|
394
|
-
id,
|
|
395
|
-
title: extractTaskTitle(task.body, id),
|
|
396
|
-
frontmatter: {
|
|
397
|
-
readable: true,
|
|
398
|
-
status: task.fields.status,
|
|
399
|
-
enabled: task.fields.enabled !== false,
|
|
400
|
-
wake: task.fields.wake,
|
|
401
|
-
schedule: task.fields.schedule,
|
|
402
|
-
recurrence: task.fields.recurrence,
|
|
403
|
-
control: task.fields.control,
|
|
404
|
-
},
|
|
405
|
-
actionable: false,
|
|
406
|
-
};
|
|
407
|
-
return `# 任务用量\n\n${renderUsageLine(entry)}`;
|
|
408
|
-
}
|
|
409
|
-
const entries = (await readActiveTasks(tasksDir(options.channelDir))).filter((entry) => !entry.frontmatter.archiveOutcome);
|
|
410
|
-
const governed = entries.filter((entry) => entry.frontmatter.control);
|
|
411
|
-
const totals = governed.reduce((total, entry) => {
|
|
412
|
-
const usage = entry.frontmatter.control.usage;
|
|
413
|
-
total.attempts += usage.attempts;
|
|
414
|
-
total.tokens += usage.tokens;
|
|
415
|
-
total.costUsd += usage.costUsd;
|
|
416
|
-
total.costKnown &&= usage.costKnown;
|
|
417
|
-
total.wallTimeMinutes += usage.wallTimeMinutes;
|
|
418
|
-
return total;
|
|
419
|
-
}, { attempts: 0, tokens: 0, costUsd: 0, costKnown: true, wallTimeMinutes: 0 });
|
|
420
|
-
const verified = governed.filter((entry) => entry.frontmatter.control?.verification.status === "passed").length;
|
|
421
|
-
const stalled = governed.filter((entry) => entry.frontmatter.control?.lastOutcome === "failed").length;
|
|
422
|
-
return [
|
|
423
|
-
"# 任务用量",
|
|
424
|
-
"",
|
|
425
|
-
`governed tasks: ${governed.length}/${entries.length}`,
|
|
426
|
-
`this cycle: ${totals.attempts} attempts, ${totals.tokens} tokens, ${totals.costKnown ? `$${totals.costUsd.toFixed(4)}` : "cost unavailable"}, ${totals.wallTimeMinutes.toFixed(1)}m`,
|
|
427
|
-
`verification PASS: ${verified}`,
|
|
428
|
-
`last-run failures: ${stalled}`,
|
|
429
|
-
"",
|
|
430
|
-
...governed.map(renderUsageLine),
|
|
431
|
-
].join("\n");
|
|
432
|
-
}
|
|
433
350
|
async function showTask(channelDir, id) {
|
|
434
351
|
const dir = tasksDir(channelDir);
|
|
435
352
|
const taskId = normalizeTaskId(id);
|
|
@@ -439,18 +356,27 @@ async function showTask(channelDir, id) {
|
|
|
439
356
|
if (!path) {
|
|
440
357
|
return `找不到任务:${taskId}`;
|
|
441
358
|
}
|
|
442
|
-
const location = path === archivePath ? "
|
|
359
|
+
const location = path === archivePath ? "(已归档)" : "";
|
|
360
|
+
const header = `**任务 ${taskId}**${location}`;
|
|
443
361
|
const content = await readFile(path, "utf-8");
|
|
444
|
-
|
|
362
|
+
// The file already lives on disk at `path`; a huge task file (long Plan/DoD history) is shown
|
|
363
|
+
// as a head snippet with a pointer to that existing path instead of dumping it whole (review
|
|
364
|
+
// 2026-08-24 §2.4/§3.2) — no separate copy needs to be written.
|
|
365
|
+
if (content.length <= TASK_SHOW_MAX_CHARS) {
|
|
366
|
+
return `${header}\n\n\`\`\`markdown\n${content}\n\`\`\``;
|
|
367
|
+
}
|
|
368
|
+
const lastNewline = content.lastIndexOf("\n", TASK_SHOW_MAX_CHARS);
|
|
369
|
+
const head = content.slice(0, lastNewline > 0 ? lastNewline : TASK_SHOW_MAX_CHARS).trimEnd();
|
|
370
|
+
return `${header}\n\n\`\`\`markdown\n${head}\n\`\`\`\n\n(内容过长已截断;完整内容见 \`${path}\`)`;
|
|
445
371
|
}
|
|
446
372
|
async function listArchive(channelDir) {
|
|
447
373
|
const dir = join(tasksDir(channelDir), "archive");
|
|
448
374
|
if (!existsSync(dir)) {
|
|
449
|
-
return "
|
|
375
|
+
return "**已归档任务**\n\n暂无已归档任务。";
|
|
450
376
|
}
|
|
451
377
|
const filenames = (await readdir(dir)).filter((filename) => filename.endsWith(".md")).sort();
|
|
452
378
|
if (filenames.length === 0) {
|
|
453
|
-
return "
|
|
379
|
+
return "**已归档任务**\n\n暂无已归档任务。";
|
|
454
380
|
}
|
|
455
381
|
const blocks = [];
|
|
456
382
|
for (const filename of filenames) {
|
|
@@ -463,11 +389,12 @@ async function listArchive(channelDir) {
|
|
|
463
389
|
blocks.push(`- ${id}`);
|
|
464
390
|
}
|
|
465
391
|
}
|
|
466
|
-
|
|
392
|
+
const body = `**已归档任务** · ${blocks.length} 个\n\n${blocks.join("\n")}`;
|
|
393
|
+
return capReply(body, { nextStepHint: "用 `/tasks show <id>` 查看单个已归档任务" }).text;
|
|
467
394
|
}
|
|
468
395
|
async function doctor(options) {
|
|
469
396
|
if (!options.workspaceDir || !options.channelId) {
|
|
470
|
-
return "
|
|
397
|
+
return "**任务体检**\n\n不可用:需要 workspaceDir 与 channelId。";
|
|
471
398
|
}
|
|
472
399
|
const now = Date.now();
|
|
473
400
|
const entries = await readActiveTasks(tasksDir(options.channelDir), now);
|
|
@@ -480,89 +407,74 @@ async function doctor(options) {
|
|
|
480
407
|
for (const entry of entries) {
|
|
481
408
|
const status = entry.frontmatter.status ?? "active";
|
|
482
409
|
if (!entry.frontmatter.readable) {
|
|
483
|
-
issues.push(issue(`tasks/${entry.id}.md
|
|
410
|
+
issues.push(issue(`tasks/${entry.id}.md 的 frontmatter 无法读取,wake/status 不可信`, `修复 tasks/${entry.id}.md,让它以可读的 status/wake/schedule frontmatter 开头`));
|
|
484
411
|
continue;
|
|
485
412
|
}
|
|
486
413
|
if (entry.frontmatter.controlReadable === false) {
|
|
487
|
-
issues.push(issue(`tasks/${entry.id}.md
|
|
414
|
+
issues.push(issue(`tasks/${entry.id}.md 的 control 元数据无效;治理机制 fail-open,但无法生效`, `用 task_manage set 或直接修复那一行 control JSON,然后再允许任务运行`));
|
|
488
415
|
continue;
|
|
489
416
|
}
|
|
490
417
|
const control = entry.frontmatter.control;
|
|
491
418
|
if (!control && entry.frontmatter.enabled === false) {
|
|
492
|
-
issues.push(issue(`tasks/${entry.id}.md
|
|
419
|
+
issues.push(issue(`tasks/${entry.id}.md 已停用,但完全没有 control.stop 回执`, `用 task_manage set 修复 control 元数据,确认可以继续后再 /tasks resume ${entry.id}`));
|
|
493
420
|
}
|
|
494
421
|
if (control) {
|
|
495
422
|
const storedTask = await readStoredTask(options.channelDir, entry.id);
|
|
496
423
|
const violation = taskBudgetViolation(control, now, status);
|
|
497
424
|
if (violation) {
|
|
498
|
-
issues.push(issue(`tasks/${entry.id}.md
|
|
425
|
+
issues.push(issue(`tasks/${entry.id}.md 超出了它的 control 限额:${violation}`, `检查这个任务,明确提高 budget/deadline 或取消它;否则 driver 会升级处理`));
|
|
499
426
|
}
|
|
500
|
-
if (status !== "sleeping" && control.verification.status === "passed"
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
if (!attestationOk) {
|
|
511
|
-
issues.push(issue(`tasks/${entry.id}.md records an independent PASS with no matching verifier attestation on disk.`, `Run a fresh purpose=verify sub-agent and import its attestation with task_manage verify before completion.`));
|
|
512
|
-
}
|
|
427
|
+
if (status !== "sleeping" && control.verification.status === "passed") {
|
|
428
|
+
const attestationOk = control.verification.runId
|
|
429
|
+
? await readVerificationAttestation(options.channelDir, control.verification.runId)
|
|
430
|
+
.then((attestation) => attestation.taskId === entry.id &&
|
|
431
|
+
attestation.verdict === "pass" &&
|
|
432
|
+
(!storedTask || attestation.bodyHash === taskBodyHash(storedTask.body)))
|
|
433
|
+
.catch(() => false)
|
|
434
|
+
: false;
|
|
435
|
+
if (!attestationOk) {
|
|
436
|
+
issues.push(issue(`tasks/${entry.id}.md 记录了一次独立 PASS,但磁盘上没有匹配且新鲜的验证 attestation`, `跑一次新的 purpose=verify 子代理,并用 task_manage verify 导入它的 attestation 后再完成`));
|
|
513
437
|
}
|
|
514
438
|
}
|
|
515
439
|
if (entry.frontmatter.enabled === false && !control.stop) {
|
|
516
|
-
issues.push(issue(`tasks/${entry.id}.md
|
|
440
|
+
issues.push(issue(`tasks/${entry.id}.md 已停用,但 control 里没有 stop 回执`, `先弄清是谁停用的,再 /tasks resume ${entry.id};或者用 task_manage set 写一条合法的 stop 记录`));
|
|
517
441
|
}
|
|
518
442
|
if (entry.frontmatter.enabled !== false && control.stop) {
|
|
519
|
-
issues.push(issue(`tasks/${entry.id}.md
|
|
443
|
+
issues.push(issue(`tasks/${entry.id}.md 有 stop 回执,但 enabled 是 true`, `跑 /tasks resume ${entry.id} 清掉过期的 stop 回执,或者显式停用这个任务`));
|
|
520
444
|
}
|
|
521
445
|
}
|
|
522
446
|
const recurring = Boolean(entry.frontmatter.schedule);
|
|
523
447
|
if (status === "sleeping" && !recurring) {
|
|
524
|
-
issues.push(issue(`tasks/${entry.id}.md
|
|
448
|
+
issues.push(issue(`tasks/${entry.id}.md 处于 sleeping,但没有 recurring schedule`, `一次性任务用 task_manage complete/cancel 结束;要保留 sleeping 需要先加一个合法的 schedule`));
|
|
525
449
|
}
|
|
526
450
|
if (recurring) {
|
|
527
451
|
try {
|
|
528
452
|
validateTaskSchedule(entry.frontmatter.schedule);
|
|
529
453
|
}
|
|
530
454
|
catch (error) {
|
|
531
|
-
issues.push(issue(`tasks/${entry.id}.md
|
|
455
|
+
issues.push(issue(`tasks/${entry.id}.md 的 schedule 无效:${errorMessage(error)}`, `修复或清空 ${entry.id} 的 schedule;修复前 driver 会让这个任务保持停用`));
|
|
532
456
|
}
|
|
533
457
|
if (status === "sleeping" && !entry.frontmatter.wake) {
|
|
534
|
-
issues.push(issue(`tasks/${entry.id}.md
|
|
458
|
+
issues.push(issue(`tasks/${entry.id}.md 处于 sleeping,但没有 wake`, `修复 schedule 和 wake,确认无误后 /tasks resume ${entry.id}`));
|
|
535
459
|
}
|
|
536
460
|
}
|
|
537
461
|
if (status === "active" &&
|
|
538
462
|
entry.frontmatter.wake &&
|
|
539
463
|
validWakeMs(entry) !== undefined &&
|
|
540
464
|
validWakeMs(entry) > now) {
|
|
541
|
-
issues.push(issue(`tasks/${entry.id}.md
|
|
542
|
-
}
|
|
543
|
-
if (status === "waiting" && entry.frontmatter.wake && !control?.waitingFor) {
|
|
544
|
-
issues.push(issue(`tasks/${entry.id}.md is waiting on a timed wake but has no waitingFor marker.`, `Run task_manage set with control.waitingFor=time or progress the task to normalize the wait.`));
|
|
545
|
-
}
|
|
546
|
-
if (status === "waiting" &&
|
|
547
|
-
entry.frontmatter.wake &&
|
|
548
|
-
control?.waitingFor &&
|
|
549
|
-
!["time", "external-signal"].includes(control.waitingFor)) {
|
|
550
|
-
issues.push(issue(`tasks/${entry.id}.md is waiting on a wake but waitingFor=${control.waitingFor} is not a timed source.`, `Set control.waitingFor to time, or clear wake and record the real signal source before resuming ${entry.id}.`));
|
|
551
|
-
}
|
|
552
|
-
if (status === "waiting" && !entry.frontmatter.wake && control?.waitingFor === "time") {
|
|
553
|
-
issues.push(issue(`tasks/${entry.id}.md is parked but waitingFor=time has no wake.`, `Set a valid wake or change waitingFor to the actual recovery source.`));
|
|
465
|
+
issues.push(issue(`tasks/${entry.id}.md 处于 active,但它的 wake 在未来`, `用 task_manage set/progress 把它改成 waiting 且 waitingFor=time,或者清空 wake 让它现在继续`));
|
|
554
466
|
}
|
|
555
467
|
if (recurringTaskMissedOccurrence({ status, schedule: entry.frontmatter.schedule, control }, new Date(now))) {
|
|
556
|
-
issues.push(issue(`tasks/${entry.id}.md
|
|
468
|
+
issues.push(issue(`tasks/${entry.id}.md 有一个已过下次 recurring 时点、仍处于 ${status} 的周期,且没有并行开启新周期`, `完成、跳过或取消 ${entry.id} 当前周期,之后让 driver 计算下一次时点`));
|
|
557
469
|
}
|
|
558
470
|
const content = await readActiveTaskContent(options.channelDir, entry.id);
|
|
559
471
|
if (content === undefined) {
|
|
560
|
-
issues.push(issue(`tasks/${entry.id}.md
|
|
472
|
+
issues.push(issue(`tasks/${entry.id}.md 在体检时读取失败`, `手动打开 tasks/${entry.id}.md,修复权限或文件内容`));
|
|
561
473
|
}
|
|
562
474
|
else {
|
|
563
475
|
const missing = missingStandardTaskSections(content);
|
|
564
476
|
if (missing.length > 0) {
|
|
565
|
-
issues.push(issue(`tasks/${entry.id}.md
|
|
477
|
+
issues.push(issue(`tasks/${entry.id}.md 缺少标准分节:${missing.join(", ")}`, `让 agent 把 tasks/${entry.id}.md 规范化成标准任务骨架`));
|
|
566
478
|
}
|
|
567
479
|
// spec 037, D4: two deterministic, zero-LLM-cost drift checks between a Plan and its
|
|
568
480
|
// DoD — the first real consumer of "is the plan still pointed at the goal?".
|
|
@@ -570,28 +482,30 @@ async function doctor(options) {
|
|
|
570
482
|
const dodCount = countTaskDodItems(content);
|
|
571
483
|
const invalidRefs = entry.plan.steps.flatMap((step) => step.dodRefs.filter((ref) => ref < 1 || ref > dodCount).map((ref) => `${step.id}→dod:${ref}`));
|
|
572
484
|
if (invalidRefs.length > 0) {
|
|
573
|
-
issues.push(issue(`tasks/${entry.id}.md Plan
|
|
485
|
+
issues.push(issue(`tasks/${entry.id}.md 的 Plan 引用了不存在的 DoD 项:${invalidRefs.join(", ")}`, `修正 Plan 里的 "→ dod:N" 引用;如果 DoD 列表变了就重新编号`));
|
|
574
486
|
}
|
|
575
487
|
const covered = new Set(entry.plan.steps.filter((step) => step.status !== "dropped").flatMap((step) => step.dodRefs));
|
|
576
488
|
const uncovered = Array.from({ length: dodCount }, (_, index) => index + 1).filter((dodIndex) => !covered.has(dodIndex));
|
|
577
489
|
if (dodCount > 0 && uncovered.length > 0) {
|
|
578
|
-
issues.push(issue(`tasks/${entry.id}.md
|
|
490
|
+
issues.push(issue(`tasks/${entry.id}.md 有 DoD 项没有 Plan 步骤覆盖:dod:${uncovered.join(",")}`, `给某个 Plan 步骤加上或更新 "→ dod:${uncovered[0]}" 引用,或者确认这些 DoD 项确实不需要专门的步骤`));
|
|
579
491
|
}
|
|
580
492
|
}
|
|
581
493
|
}
|
|
582
|
-
// A
|
|
583
|
-
//
|
|
584
|
-
//
|
|
585
|
-
//
|
|
586
|
-
//
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
494
|
+
// A waiting task resumes only via a real durable source: a valid wake (the driver's timed
|
|
495
|
+
// reactivation) or an actually-running background job/delegation recorded against this
|
|
496
|
+
// id — never by what `waitingFor` merely claims, which is model-written display text and
|
|
497
|
+
// no longer gates anything. With neither, resumption is entirely up to the user —
|
|
498
|
+
// legitimate when waiting on an answer, and indistinguishable, on disk, from a task
|
|
499
|
+
// everyone has forgotten. Report the fact and name every way out.
|
|
500
|
+
if (status === "waiting") {
|
|
501
|
+
const hasDurableWake = Boolean(entry.frontmatter.wake) && validWakeMs(entry) !== undefined;
|
|
502
|
+
const hasRunningSource = runningJobTaskIds.has(entry.id) || runningDelegationTaskIds.has(entry.id);
|
|
503
|
+
if (!hasDurableWake && !hasRunningSource) {
|
|
504
|
+
issues.push(issue(`tasks/${entry.id}.md 处于 waiting,且没有可靠的恢复方式(没有合法 wake,也没有记录在案的运行中 job/委派)`, `它只能靠你回复、跑 /tasks run ${entry.id},或者用 /tasks set ${entry.id} wake <本地时间或 +2h> 给它一个 wake 才能恢复;如果等待的东西已经不存在了就取消它`));
|
|
505
|
+
}
|
|
592
506
|
}
|
|
593
507
|
if (entry.frontmatter.wake && validWakeMs(entry) === undefined) {
|
|
594
|
-
issues.push(issue(`tasks/${entry.id}.md
|
|
508
|
+
issues.push(issue(`tasks/${entry.id}.md 的 wake 值无效(${entry.frontmatter.wake});原生 driver 会把它当成已到期处理`, `用 task_manage set 或 progress 把 wake 换成合法本地时间,或者清空它让任务直接继续`));
|
|
595
509
|
}
|
|
596
510
|
// A recurring task's wake should always be an occurrence of its own schedule. A wake that
|
|
597
511
|
// isn't — a stale value left over from a since-changed cron, or a hand-typed local↔UTC
|
|
@@ -603,44 +517,33 @@ async function doctor(options) {
|
|
|
603
517
|
if (wakeMs !== undefined) {
|
|
604
518
|
const priorOccurrence = nextTaskWake(schedule, new Date(wakeMs - 1));
|
|
605
519
|
if (priorOccurrence?.getTime() !== wakeMs) {
|
|
606
|
-
issues.push(issue(`tasks/${entry.id}.md wake
|
|
520
|
+
issues.push(issue(`tasks/${entry.id}.md 的 wake(${formatLocalTime(new Date(wakeMs))})不是它 schedule "${schedule}" 的一个合法时点`, `跑 task_manage set schedule="${schedule}"(不变)用 cron 重新计算 wake,或者手动明确设置 wake`));
|
|
607
521
|
}
|
|
608
522
|
}
|
|
609
523
|
}
|
|
610
524
|
}
|
|
611
|
-
// Spec 036 D8: retired control keys are ignored on read, which keeps stored tasks readable
|
|
612
|
-
// but silently discards whatever `parent`/`dependsOn` once expressed. Report the loss —
|
|
613
|
-
// naming the dropped edges, not just the key — so the user can restate any real ordering.
|
|
614
|
-
for (const entry of entries) {
|
|
615
|
-
const retired = retiredTaskControlKeys(entry.frontmatter.rawControl);
|
|
616
|
-
if (retired.length === 0)
|
|
617
|
-
continue;
|
|
618
|
-
const edges = describeDroppedTaskRelations(entry.id, entry.frontmatter.rawControl);
|
|
619
|
-
issues.push(issue(`tasks/${entry.id}.md still carries retired control keys: ${retired.join(", ")}.${edges ? ` Dropped ordering: ${edges}.` : ""}`, edges
|
|
620
|
-
? `These no longer constrain execution. Restate any real ordering in the task body or with wake, then remove the keys (any task_manage write drops them).`
|
|
621
|
-
: `They are ignored; any task_manage write drops them.`));
|
|
622
|
-
}
|
|
623
525
|
for (const event of events) {
|
|
624
526
|
if (!event.id || !event.use) {
|
|
625
|
-
issues.push(issue(`events/${event.filename}
|
|
527
|
+
issues.push(issue(`events/${event.filename} 不符合 task.<channelId>.<taskId>.<use>.json 命名`, "把这个事件改名为任务专用命名约定,或者当作普通事件管理"));
|
|
626
528
|
continue;
|
|
627
529
|
}
|
|
628
530
|
if (event.error) {
|
|
629
|
-
issues.push(issue(`events/${event.filename}
|
|
531
|
+
issues.push(issue(`events/${event.filename} 无法解析:${event.error}`, `修复或删除 events/${event.filename};无效的任务专属事件不可信`));
|
|
630
532
|
continue;
|
|
631
533
|
}
|
|
632
534
|
if (!activeIds.has(event.id) && !archivedIds.has(event.id)) {
|
|
633
|
-
issues.push(issue(`events/${event.filename}
|
|
535
|
+
issues.push(issue(`events/${event.filename} 指向了不存在的任务 ${event.id}`, `删除 events/${event.filename};如果那个任务在概念上还存在,就重新创建 tasks/${event.id}.md`));
|
|
634
536
|
continue;
|
|
635
537
|
}
|
|
636
538
|
if (archivedIds.has(event.id)) {
|
|
637
|
-
issues.push(issue(`events/${event.filename}
|
|
539
|
+
issues.push(issue(`events/${event.filename} 指向了已归档任务 ${event.id};已关闭的任务不应该还有存活的事件`, `删除 events/${event.filename};已归档任务不应该唤醒 agent`));
|
|
638
540
|
}
|
|
639
541
|
}
|
|
640
542
|
if (issues.length === 0) {
|
|
641
|
-
return "
|
|
543
|
+
return "**任务体检**\n\n未发现任务台账问题。";
|
|
642
544
|
}
|
|
643
|
-
|
|
545
|
+
const body = `**任务体检** · 发现 ${issues.length} 个问题\n\n${issues.join("\n")}`;
|
|
546
|
+
return capReply(body, { nextStepHint: "先处理靠前的问题,再重新运行 `/tasks doctor`" }).text;
|
|
644
547
|
}
|
|
645
548
|
export async function handleTasksCommand(options) {
|
|
646
549
|
let command;
|
|
@@ -652,7 +555,7 @@ export async function handleTasksCommand(options) {
|
|
|
652
555
|
return `${message}\n\n${usage()}`;
|
|
653
556
|
}
|
|
654
557
|
try {
|
|
655
|
-
if ("id" in command && command.id &&
|
|
558
|
+
if ("id" in command && command.id && command.action !== "show") {
|
|
656
559
|
return await withTaskMutation(options.channelDir, command.id, () => dispatchTasksCommand(options, command));
|
|
657
560
|
}
|
|
658
561
|
return await dispatchTasksCommand(options, command);
|
|
@@ -678,8 +581,6 @@ async function dispatchTasksCommand(options, command) {
|
|
|
678
581
|
return await runTask(options, command.id);
|
|
679
582
|
case "set":
|
|
680
583
|
return await setTaskField(options, command.id, command.field, command.value);
|
|
681
|
-
case "stats":
|
|
682
|
-
return await taskStats(options, command.id);
|
|
683
584
|
case "doctor":
|
|
684
585
|
return await doctor(options);
|
|
685
586
|
}
|
|
@@ -22,9 +22,7 @@ export interface TaskDriverOptions {
|
|
|
22
22
|
notify?: (event: ChannelEvent) => boolean | Promise<boolean>;
|
|
23
23
|
}
|
|
24
24
|
export declare function discoverTaskChannels(workspaceDir: string, knownChannelIds?: Iterable<string>): Promise<string[]>;
|
|
25
|
-
export declare function createTaskDriverEvent(channelId: string, entry: TaskLedgerEntry, nowMs: number
|
|
26
|
-
/** Durable checker wake created by request-verification; it is a normal main-agent turn. */
|
|
27
|
-
export declare function createTaskVerificationEvent(channelId: string, entry: TaskLedgerEntry, nowMs: number): ChannelEvent;
|
|
25
|
+
export declare function createTaskDriverEvent(channelId: string, entry: TaskLedgerEntry, nowMs: number): ChannelEvent;
|
|
28
26
|
export declare function taskGovernorReceipt(channelId: string, entry: TaskLedgerEntry, reason: string, nowMs: number): ChannelEvent;
|
|
29
27
|
/**
|
|
30
28
|
* Native, token-gated driver for the persistent task ledger.
|