@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,24 +1,29 @@
|
|
|
1
|
+
import { readFile } from "node:fs/promises";
|
|
1
2
|
import { dirname, join } from "node:path";
|
|
2
3
|
import { Type } from "typebox";
|
|
3
4
|
import { DEFAULT_SECURITY_CONFIG } from "../security/config.js";
|
|
4
5
|
import { RecoverableToolError } from "../shared/recoverable-error.js";
|
|
5
|
-
import { externalRoleFingerprint } from "../subagents/discovery.js";
|
|
6
|
+
import { externalRoleFingerprint, validateSubAgentTask } from "../subagents/discovery.js";
|
|
6
7
|
import { launchExternalRun } from "../subagents/external/run.js";
|
|
7
8
|
import { formatCost, formatRunDuration, harnessLabel } from "../subagents/format.js";
|
|
8
9
|
import { getSubAgentRunManager } from "../subagents/runs.js";
|
|
9
|
-
import { assertVerifyAdmissible, buildContextualBlocks, buildSubAgentTask, } from "../subagents/tool.js";
|
|
10
|
+
import { assertVerifyAdmissible, assertWithinProjectBoundary, buildContextualBlocks, buildSubAgentTask, } from "../subagents/tool.js";
|
|
10
11
|
import { acquireWorkspaceLease, formatWorkspaceLeaseConflict, releaseWorkspaceLease, } from "../subagents/workspace-lease.js";
|
|
11
12
|
const subagentManageSchema = Type.Object({
|
|
12
13
|
label: Type.String({ description: "Brief description of what you're checking (shown to user)" }),
|
|
13
|
-
op: Type.Union([Type.Literal("list"), Type.Literal("cancel"), Type.Literal("follow_up")], {
|
|
14
|
-
description: '"list" a snapshot of this channel\'s delegation runs, "cancel" a running one by runId,
|
|
15
|
-
'"follow_up" to continue a resumable run with a new instruction (produces a new runId)
|
|
14
|
+
op: Type.Union([Type.Literal("list"), Type.Literal("cancel"), Type.Literal("follow_up"), Type.Literal("show")], {
|
|
15
|
+
description: '"list" a snapshot of this channel\'s delegation runs, "cancel" a running one by runId, ' +
|
|
16
|
+
'"follow_up" to continue a resumable run with a new instruction (produces a new runId), or ' +
|
|
17
|
+
'"show" the full detail on one run by runId (argv, dispatch warnings, stderr tail) for self-diagnosis of a failed run.',
|
|
16
18
|
}),
|
|
17
|
-
runId: Type.Optional(Type.String({ description: "Required for cancel and
|
|
19
|
+
runId: Type.Optional(Type.String({ description: "Required for cancel, follow_up, and show." })),
|
|
18
20
|
task: Type.Optional(Type.String({ description: "Follow-up instruction. Required for op=follow_up." })),
|
|
19
21
|
});
|
|
20
22
|
/** Spec 042 D9: cap on `op=list`'s output — see the call site for why running runs are exempt. */
|
|
21
23
|
const LIST_CAP = 50;
|
|
24
|
+
/** Matches `/subagents show`'s own cap (`runtime/subagent-commands.ts`) — enough to diagnose a
|
|
25
|
+
* failure without dumping an unbounded log into the model's context. */
|
|
26
|
+
const STDERR_TAIL_CHARS = 2_000;
|
|
22
27
|
function formatRunLine(record) {
|
|
23
28
|
const task = record.taskId ? `, task ${record.taskId}` : "";
|
|
24
29
|
const lease = record.leaseKey ? ", lease held" : "";
|
|
@@ -30,6 +35,53 @@ function formatRunLine(record) {
|
|
|
30
35
|
}
|
|
31
36
|
return header;
|
|
32
37
|
}
|
|
38
|
+
/**
|
|
39
|
+
* The machine-readable subset of `/subagents show` (`runtime/subagent-commands.ts`'s `showRun`):
|
|
40
|
+
* argv, dispatch-time warnings, and the adapter/CLI version pair the model previously had no way
|
|
41
|
+
* to see at all — it could only guess at a failed external run's cause or re-dispatch blindly
|
|
42
|
+
* (review 2026-08-23 §3.4).
|
|
43
|
+
*/
|
|
44
|
+
async function formatRunShow(record) {
|
|
45
|
+
const lines = [
|
|
46
|
+
`Run ${record.runId}: ${record.agent} (${harnessLabel(record)}, ${record.source}) — ${record.status} (${formatRunDuration(record)})`,
|
|
47
|
+
`purpose=${record.purpose}, workingDirectory=${record.workingDirectory}, artifactDir=${record.artifactDir}`,
|
|
48
|
+
];
|
|
49
|
+
if (record.failureReason)
|
|
50
|
+
lines.push(`failureReason: ${record.failureReason}`);
|
|
51
|
+
if (record.verificationVerdict) {
|
|
52
|
+
lines.push(`verification: ${record.verificationVerdict.toUpperCase()}${record.verificationStrength === "advisory" ? " (advisory)" : ""}`);
|
|
53
|
+
}
|
|
54
|
+
if (record.taskId)
|
|
55
|
+
lines.push(`taskId: ${record.taskId}`);
|
|
56
|
+
if (record.leaseKey)
|
|
57
|
+
lines.push("holds write lease: yes");
|
|
58
|
+
if (record.model)
|
|
59
|
+
lines.push(`model: ${record.model}`);
|
|
60
|
+
const cost = formatCost(record);
|
|
61
|
+
lines.push(`usage: input=${record.usage.input} output=${record.usage.output}${cost ? ` cost=${cost}` : ""}`);
|
|
62
|
+
if (record.argv)
|
|
63
|
+
lines.push(`argv: ${JSON.stringify(record.argv)}`);
|
|
64
|
+
if (record.parserVersion !== undefined || record.cliVersion) {
|
|
65
|
+
const parts = [];
|
|
66
|
+
if (record.parserVersion !== undefined)
|
|
67
|
+
parts.push(`parserVersion=${record.parserVersion}`);
|
|
68
|
+
parts.push(`cliVersion=${record.cliVersion ?? "(unknown)"}`);
|
|
69
|
+
lines.push(`adapter/CLI: ${parts.join(", ")}`);
|
|
70
|
+
}
|
|
71
|
+
if (record.invocationWarnings?.length) {
|
|
72
|
+
lines.push("dispatch warnings:", ...record.invocationWarnings.map((warning) => `- ${warning}`));
|
|
73
|
+
}
|
|
74
|
+
if (record.sessionId)
|
|
75
|
+
lines.push(`sessionId: ${record.sessionId} (usable with subagent_manage op=follow_up)`);
|
|
76
|
+
if (record.runtime === "external") {
|
|
77
|
+
const stderrTail = await readFile(join(record.artifactDir, "stderr.log"), "utf-8")
|
|
78
|
+
.then((text) => text.slice(-STDERR_TAIL_CHARS))
|
|
79
|
+
.catch(() => undefined);
|
|
80
|
+
if (stderrTail?.trim())
|
|
81
|
+
lines.push("", "stderr (tail):", stderrTail);
|
|
82
|
+
}
|
|
83
|
+
return lines.join("\n");
|
|
84
|
+
}
|
|
33
85
|
/** Resumable harnesses only: `claude-code`/`codex-cli`. `exec` has no session concept, and internal
|
|
34
86
|
* runs have no persisted transcript by design (spec 040, non-goals). */
|
|
35
87
|
function resumableHarnessOf(record) {
|
|
@@ -45,7 +97,8 @@ export function createSubAgentManageTool(options) {
|
|
|
45
97
|
description: "Inspect and control delegation runs (internal sub-agents and, once configured, external agents): " +
|
|
46
98
|
"op=list shows a snapshot of this channel's runs; op=cancel stops a running one by runId without " +
|
|
47
99
|
"waking the channel (that is your own decision, not a failure); op=follow_up continues a resumable " +
|
|
48
|
-
"run with a new instruction, producing a new runId
|
|
100
|
+
"run with a new instruction, producing a new runId; op=show gives full detail on one run (argv, " +
|
|
101
|
+
"dispatch warnings, stderr tail) for self-diagnosis. A run finishing wakes this channel by itself, " +
|
|
49
102
|
"so never poll here waiting for one — end the turn instead.",
|
|
50
103
|
parameters: subagentManageSchema,
|
|
51
104
|
execute: async (_toolCallId, { op, runId, task }) => {
|
|
@@ -81,6 +134,13 @@ export function createSubAgentManageTool(options) {
|
|
|
81
134
|
throw new RecoverableToolError(`Run "${runId}" was not found on this channel.`);
|
|
82
135
|
}
|
|
83
136
|
const resolvedRunId = resolution.record.runId;
|
|
137
|
+
if (op === "show") {
|
|
138
|
+
const text = await formatRunShow(resolution.record);
|
|
139
|
+
return {
|
|
140
|
+
content: [{ type: "text", text }],
|
|
141
|
+
details: { op, runId: resolvedRunId },
|
|
142
|
+
};
|
|
143
|
+
}
|
|
84
144
|
if (op === "cancel") {
|
|
85
145
|
const status = await manager().cancel(resolvedRunId);
|
|
86
146
|
return {
|
|
@@ -92,7 +152,17 @@ export function createSubAgentManageTool(options) {
|
|
|
92
152
|
if (!task || !task.trim()) {
|
|
93
153
|
throw new RecoverableToolError("follow_up requires task.");
|
|
94
154
|
}
|
|
155
|
+
const taskLengthError = validateSubAgentTask(task);
|
|
156
|
+
if (taskLengthError) {
|
|
157
|
+
throw new RecoverableToolError(taskLengthError);
|
|
158
|
+
}
|
|
95
159
|
const record = resolution.record;
|
|
160
|
+
// The initial dispatch validated `record.workingDirectory` against the project boundary
|
|
161
|
+
// in effect at the time (spec 043, D6.2); `/project` can move that boundary afterward, and
|
|
162
|
+
// this re-checks the *current* one before resuming a process there (review 2026-08-23 §3.1).
|
|
163
|
+
if (options.projectBoundary === "project" && options.workingDirectory) {
|
|
164
|
+
assertWithinProjectBoundary(record.workingDirectory, options.workingDirectory, record.workingDirectory);
|
|
165
|
+
}
|
|
96
166
|
const harness = resumableHarnessOf(record);
|
|
97
167
|
if (!harness) {
|
|
98
168
|
// Internal runs have no persisted transcript to resume — the isolated-context design
|
|
@@ -15,7 +15,7 @@ export async function setTask(options, request) {
|
|
|
15
15
|
const id = normalizeTaskId(request.id);
|
|
16
16
|
const taskPath = join(tasksDir(options), `${id}.md`);
|
|
17
17
|
const { fields, body } = await readTaskDocument(taskPath, id, request.control !== undefined);
|
|
18
|
-
const fromStatus = normalizeStoredStatus(fields.status
|
|
18
|
+
const fromStatus = normalizeStoredStatus(fields.status);
|
|
19
19
|
resolveTaskTransition("set", id, fromStatus, request.status);
|
|
20
20
|
const nextFields = applySet(fields, request);
|
|
21
21
|
if (nextFields.status === "sleeping" && !nextFields.schedule) {
|
|
@@ -37,7 +37,7 @@ export async function progressTask(options, request) {
|
|
|
37
37
|
const note = requiredField(request.note, "note", "progress");
|
|
38
38
|
const taskPath = join(tasksDir(options), `${id}.md`);
|
|
39
39
|
const { fields, body } = await readTaskDocument(taskPath, id);
|
|
40
|
-
const from = normalizeStoredStatus(fields.status
|
|
40
|
+
const from = normalizeStoredStatus(fields.status);
|
|
41
41
|
resolveTaskTransition("progress", id, from, request.status);
|
|
42
42
|
if (from === "sleeping") {
|
|
43
43
|
throw new RecoverableToolError(`Task "${id}" is sleeping; wait for its occurrence or use /tasks run ${id}.`);
|
|
@@ -49,7 +49,6 @@ export async function progressTask(options, request) {
|
|
|
49
49
|
if (nextFields.control) {
|
|
50
50
|
if (nextFields.status === "active") {
|
|
51
51
|
nextFields.control.waitingFor = undefined;
|
|
52
|
-
nextFields.control.blockedReason = undefined;
|
|
53
52
|
}
|
|
54
53
|
else if (!nextFields.control.waitingFor) {
|
|
55
54
|
nextFields.control.waitingFor = nextFields.wake ? "time" : "external-signal";
|
|
@@ -75,22 +74,20 @@ export async function completeTask(options, request) {
|
|
|
75
74
|
const dir = tasksDir(options);
|
|
76
75
|
const taskPath = join(dir, `${id}.md`);
|
|
77
76
|
const { fields, body } = await readTaskDocument(taskPath, id);
|
|
78
|
-
resolveTaskTransition("complete", id, normalizeStoredStatus(fields.status
|
|
77
|
+
resolveTaskTransition("complete", id, normalizeStoredStatus(fields.status));
|
|
79
78
|
const uncheckedAcceptance = uncheckedTaskAcceptanceItems(body);
|
|
80
79
|
if (uncheckedAcceptance.length > 0) {
|
|
81
80
|
throw new RecoverableToolError(`Task "${id}" still has unchecked acceptance items: ${uncheckedAcceptance.join("; ")}. Check them with evidence before complete.`);
|
|
82
81
|
}
|
|
82
|
+
let verificationNote = "";
|
|
83
83
|
if (fields.control?.verification.required) {
|
|
84
84
|
const verification = fields.control.verification;
|
|
85
|
-
if (verification.status !== "passed" || !verification.
|
|
86
|
-
throw new RecoverableToolError(`Task "${id}" requires an independent PASS.
|
|
85
|
+
if (verification.status !== "passed" || !verification.runId) {
|
|
86
|
+
throw new RecoverableToolError(`Task "${id}" requires an independent PASS. Dispatch a purpose=verify sub-agent, then task_manage verify with its run id.`);
|
|
87
87
|
}
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
const attestation = await assertVerificationAttestationMatches(options.channelDir, id, verification);
|
|
92
|
-
// The attestation is the durable source of the artifact subject. The mirrored control
|
|
93
|
-
// field is writable task metadata, so it must not decide whether freshness is checked.
|
|
88
|
+
// The attestation file is the sole authority — for the verdict, the body-hash freshness
|
|
89
|
+
// check, and the artifact subject. The task Markdown is agent-writable and proves nothing.
|
|
90
|
+
const attestation = await assertVerificationAttestationMatches(options.channelDir, id, verification.runId, taskBodyHash(body));
|
|
94
91
|
if (attestation.subjectHash) {
|
|
95
92
|
const subjectDir = attestation.subjectDir ?? options.workingDirectory ?? process.cwd();
|
|
96
93
|
const currentSubject = await workspaceSubjectHash(subjectDir);
|
|
@@ -101,10 +98,16 @@ export async function completeTask(options, request) {
|
|
|
101
98
|
throw new RecoverableToolError(`Task "${id}" artifacts changed after its independent PASS; request verification again.`);
|
|
102
99
|
}
|
|
103
100
|
}
|
|
101
|
+
// advisory means runtime could not structurally prove the verifier left artifacts alone
|
|
102
|
+
// (external harness, or bash left in an internal verifier's tool set) — surface it at the
|
|
103
|
+
// one moment completion is actually decided, not just in a file nobody re-reads (review
|
|
104
|
+
// 2026-08-23 §2.1).
|
|
105
|
+
if (attestation.verificationStrength === "advisory") {
|
|
106
|
+
verificationNote = " ⚠️ 验收结论为 advisory:runtime 无法证明验收者未改动产物,请自行抽查 diff 与测试结果。";
|
|
107
|
+
}
|
|
104
108
|
}
|
|
105
109
|
const bodyWithEvidence = appendCompletionEvidence(body, request);
|
|
106
110
|
if (fields.control) {
|
|
107
|
-
fields.control.blockedReason = undefined;
|
|
108
111
|
fields.control.waitingFor = undefined;
|
|
109
112
|
}
|
|
110
113
|
const recurring = Boolean(fields.schedule);
|
|
@@ -143,7 +146,7 @@ export async function completeTask(options, request) {
|
|
|
143
146
|
status: recurring ? "sleeping" : undefined,
|
|
144
147
|
archived,
|
|
145
148
|
deletedEvents: deleted,
|
|
146
|
-
notice: `任务 \`${id}\` 已完成(${archived ? "已归档" : "已进入 sleeping,等待下一 occurrence"}${cleanup}
|
|
149
|
+
notice: `任务 \`${id}\` 已完成(${archived ? "已归档" : "已进入 sleeping,等待下一 occurrence"}${cleanup})。${verificationNote}`,
|
|
147
150
|
};
|
|
148
151
|
}
|
|
149
152
|
export async function skipTask(options, request) {
|
|
@@ -153,13 +156,12 @@ export async function skipTask(options, request) {
|
|
|
153
156
|
const reason = requiredField(request.reason, "reason", "skip");
|
|
154
157
|
const taskPath = join(tasksDir(options), `${id}.md`);
|
|
155
158
|
const { fields, body } = await readTaskDocument(taskPath, id);
|
|
156
|
-
resolveTaskTransition("skip", id, normalizeStoredStatus(fields.status
|
|
159
|
+
resolveTaskTransition("skip", id, normalizeStoredStatus(fields.status));
|
|
157
160
|
if (!fields.schedule) {
|
|
158
161
|
throw new RecoverableToolError(`Task "${id}" is not recurring; use complete after satisfying its DoD or cancel it.`);
|
|
159
162
|
}
|
|
160
163
|
const skippedBody = appendCurrentCycleNote(body, `Skipped: ${reason}`);
|
|
161
164
|
if (fields.control) {
|
|
162
|
-
fields.control.blockedReason = undefined;
|
|
163
165
|
fields.control.waitingFor = undefined;
|
|
164
166
|
fields.control.verification = { required: fields.control.verification.required, status: "pending" };
|
|
165
167
|
}
|
|
@@ -183,7 +185,7 @@ export async function cancelTask(options, request) {
|
|
|
183
185
|
const dir = tasksDir(options);
|
|
184
186
|
const taskPath = join(dir, `${id}.md`);
|
|
185
187
|
const { fields, body } = await readTaskDocument(taskPath, id);
|
|
186
|
-
resolveTaskTransition("cancel", id, normalizeStoredStatus(fields.status
|
|
188
|
+
resolveTaskTransition("cancel", id, normalizeStoredStatus(fields.status));
|
|
187
189
|
const cancelledBody = `${body.replace(/\n+$/, "\n")}\n## Cancellation\n\n- Reason: ${markdownValue(reason)}\n`;
|
|
188
190
|
const archiveDir = join(dir, "archive");
|
|
189
191
|
await mkdir(archiveDir, { recursive: true });
|
|
@@ -3,7 +3,7 @@ import type { TaskManageAction } from "./types.js";
|
|
|
3
3
|
export declare const SETTABLE_STATUSES: readonly ["active", "waiting", "sleeping"];
|
|
4
4
|
export declare const taskManageSchema: Type.TObject<{
|
|
5
5
|
label: Type.TString;
|
|
6
|
-
action: Type.TUnion<[Type.TLiteral<"create">, Type.TLiteral<"progress">, Type.TLiteral<"set">, Type.TLiteral<"
|
|
6
|
+
action: Type.TUnion<[Type.TLiteral<"create">, Type.TLiteral<"progress">, Type.TLiteral<"set">, Type.TLiteral<"verify">, Type.TLiteral<"complete">, Type.TLiteral<"skip">, Type.TLiteral<"cancel">, Type.TLiteral<"list">]>;
|
|
7
7
|
id: Type.TOptional<Type.TString>;
|
|
8
8
|
title: Type.TOptional<Type.TString>;
|
|
9
9
|
goal: Type.TOptional<Type.TString>;
|
|
@@ -17,18 +17,14 @@ export declare const taskManageSchema: Type.TObject<{
|
|
|
17
17
|
text: Type.TOptional<Type.TString>;
|
|
18
18
|
}>>>;
|
|
19
19
|
control: Type.TOptional<Type.TObject<{
|
|
20
|
-
priority: Type.TOptional<Type.TUnion<[Type.TLiteral<"low">, Type.TLiteral<"normal">, Type.TLiteral<"high">, Type.TLiteral<"critical">]>>;
|
|
21
20
|
deadline: Type.TOptional<Type.TString>;
|
|
22
21
|
nextAction: Type.TOptional<Type.TString>;
|
|
23
|
-
|
|
24
|
-
waitingFor: Type.TOptional<Type.TUnion<[Type.TLiteral<"time">, Type.TLiteral<"user">, Type.TLiteral<"job">, Type.TLiteral<"verification">, Type.TLiteral<"external-signal">]>>;
|
|
25
|
-
maxAttempts: Type.TOptional<Type.TInteger>;
|
|
22
|
+
waitingFor: Type.TOptional<Type.TUnion<[Type.TLiteral<"time">, Type.TLiteral<"user">, Type.TLiteral<"job">, Type.TLiteral<"external-signal">]>>;
|
|
26
23
|
verificationRequired: Type.TOptional<Type.TBoolean>;
|
|
27
24
|
}>>;
|
|
28
25
|
status: Type.TOptional<Type.TUnion<Type.TLiteral<"active" | "waiting" | "sleeping">[]>>;
|
|
29
26
|
wake: Type.TOptional<Type.TString>;
|
|
30
27
|
schedule: Type.TOptional<Type.TString>;
|
|
31
|
-
recurrence: Type.TOptional<Type.TString>;
|
|
32
28
|
note: Type.TOptional<Type.TString>;
|
|
33
29
|
verifierRunId: Type.TOptional<Type.TString>;
|
|
34
30
|
summary: Type.TOptional<Type.TString>;
|
|
@@ -3,22 +3,12 @@ import { SETTABLE_TASK_STATUSES } from "../../tasks/transitions.js";
|
|
|
3
3
|
import { RecoverableToolError } from "../tool-details.js";
|
|
4
4
|
export const SETTABLE_STATUSES = SETTABLE_TASK_STATUSES;
|
|
5
5
|
const taskControlSchema = Type.Object({
|
|
6
|
-
priority: Type.Optional(Type.Union([Type.Literal("low"), Type.Literal("normal"), Type.Literal("high"), Type.Literal("critical")])),
|
|
7
6
|
deadline: Type.Optional(Type.String({
|
|
8
7
|
description: "Local time deadline, e.g. 2026-07-27T18:00:00+08:00 (host timezone if no offset given); empty string clears it.",
|
|
9
8
|
})),
|
|
10
9
|
nextAction: Type.Optional(Type.String({ description: "Concrete next executable step; empty string clears it." })),
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
Type.Literal("time"),
|
|
14
|
-
Type.Literal("user"),
|
|
15
|
-
Type.Literal("job"),
|
|
16
|
-
Type.Literal("verification"),
|
|
17
|
-
Type.Literal("external-signal"),
|
|
18
|
-
], { description: "Diagnostic recovery source; it does not create a new lifecycle status." })),
|
|
19
|
-
maxAttempts: Type.Optional(Type.Integer({
|
|
20
|
-
minimum: 1,
|
|
21
|
-
description: "Attempt stop-loss; the only per-task budget. Default 12, spent over the whole task (recurring: per cycle) — raise it on create for long multi-step work.",
|
|
10
|
+
waitingFor: Type.Optional(Type.Union([Type.Literal("time"), Type.Literal("user"), Type.Literal("job"), Type.Literal("external-signal")], {
|
|
11
|
+
description: "Diagnostic recovery source; it does not create a new lifecycle status.",
|
|
22
12
|
})),
|
|
23
13
|
verificationRequired: Type.Optional(Type.Boolean({
|
|
24
14
|
description: "Whether complete requires an independent verifier attestation. Default false; set true only when the task produces a checkable artifact (code, config, a runnable command) a read-only verifier sub-agent can inspect.",
|
|
@@ -30,14 +20,13 @@ export const taskManageSchema = Type.Object({
|
|
|
30
20
|
Type.Literal("create"),
|
|
31
21
|
Type.Literal("progress"),
|
|
32
22
|
Type.Literal("set"),
|
|
33
|
-
Type.Literal("request-verification"),
|
|
34
23
|
Type.Literal("verify"),
|
|
35
24
|
Type.Literal("complete"),
|
|
36
25
|
Type.Literal("skip"),
|
|
37
26
|
Type.Literal("cancel"),
|
|
38
27
|
Type.Literal("list"),
|
|
39
28
|
], {
|
|
40
|
-
description: '"create" writes a persistent task; "progress" checkpoints work
|
|
29
|
+
description: '"create" writes a persistent task; "progress" checkpoints work — to wait on an independent verifier, dispatch a purpose=verify sub-agent with taskId and park like any other delegation (status=waiting, waitingFor=external-signal); "set" repairs metadata; "verify" imports the verifier\'s attestation by run id; "complete" closes a task; "skip" closes one recurring occurrence without claiming completion; "cancel" archives abandoned work; "list" returns tasks. Recurring tasks sleep between occurrences.',
|
|
41
30
|
}),
|
|
42
31
|
id: Type.Optional(Type.String({ description: "Task id (filename without .md). Required for create/progress/set/complete." })),
|
|
43
32
|
title: Type.Optional(Type.String({ description: "Required for create: task title used as the H1 heading." })),
|
|
@@ -74,7 +63,6 @@ export const taskManageSchema = Type.Object({
|
|
|
74
63
|
"Changing this on an existing task recomputes wake to the new cadence's next occurrence unless this " +
|
|
75
64
|
"same call also sets wake explicitly. Recurring creation starts in sleeping and opens cycles at occurrences. Min every 30 minutes.",
|
|
76
65
|
})),
|
|
77
|
-
recurrence: Type.Optional(Type.String({ description: "Human annotation only (e.g. 每周一); empty string clears it." })),
|
|
78
66
|
note: Type.Optional(Type.String({
|
|
79
67
|
description: "Required for progress: concise Current Cycle entry covering what changed, evidence observed, and the next step.",
|
|
80
68
|
})),
|
|
@@ -89,7 +77,6 @@ export const taskManageSchema = Type.Object({
|
|
|
89
77
|
export function parseAction(action) {
|
|
90
78
|
if (action === "create" ||
|
|
91
79
|
action === "progress" ||
|
|
92
|
-
action === "request-verification" ||
|
|
93
80
|
action === "set" ||
|
|
94
81
|
action === "verify" ||
|
|
95
82
|
action === "complete" ||
|
|
@@ -98,5 +85,5 @@ export function parseAction(action) {
|
|
|
98
85
|
action === "list") {
|
|
99
86
|
return action;
|
|
100
87
|
}
|
|
101
|
-
throw new RecoverableToolError("Unsupported task action. Next step: use create, progress,
|
|
88
|
+
throw new RecoverableToolError("Unsupported task action. Next step: use create, progress, set, verify, complete, skip, cancel, or list.");
|
|
102
89
|
}
|
|
@@ -59,7 +59,7 @@ export function renderTaskSkeleton(request) {
|
|
|
59
59
|
const goal = requiredField(request.goal, "goal", "create");
|
|
60
60
|
const dod = requiredField(request.dod, "dod", "create");
|
|
61
61
|
// Independent verification is opt-in: it is a quality fact, not an external-action policy.
|
|
62
|
-
const control = applyTaskControlPatch(createDefaultTaskControl(request.control?.verificationRequired ?? false
|
|
62
|
+
const control = applyTaskControlPatch(createDefaultTaskControl(request.control?.verificationRequired ?? false), request.control ?? {});
|
|
63
63
|
const fields = applySet({ status: normalizeCreateStatus(request.status), enabled: true, control }, request);
|
|
64
64
|
if (!fields.schedule && fields.status === "sleeping") {
|
|
65
65
|
throw new RecoverableToolError('A one-shot task cannot use status "sleeping"; create it as active or waiting.');
|
|
@@ -108,7 +108,6 @@ export async function readTaskDocument(taskPath, id, allowControlRepair = false)
|
|
|
108
108
|
enabled: frontmatter.enabled,
|
|
109
109
|
wake: frontmatter.wake,
|
|
110
110
|
schedule: frontmatter.schedule,
|
|
111
|
-
recurrence: frontmatter.recurrence,
|
|
112
111
|
// A successful task_manage write upgrades a hand-written/v0 task to the v2
|
|
113
112
|
// control contract instead of preserving an ungoverned task indefinitely.
|
|
114
113
|
control: frontmatter.control ?? createDefaultTaskControl(),
|
|
@@ -177,10 +176,6 @@ export function applySet(fields, request) {
|
|
|
177
176
|
}
|
|
178
177
|
}
|
|
179
178
|
}
|
|
180
|
-
if (request.recurrence !== undefined) {
|
|
181
|
-
const trimmed = request.recurrence.trim();
|
|
182
|
-
next.recurrence = trimmed === "" ? undefined : trimmed;
|
|
183
|
-
}
|
|
184
179
|
if (request.control !== undefined) {
|
|
185
180
|
next.control = applyTaskControlPatch(next.control ?? createDefaultTaskControl(), request.control);
|
|
186
181
|
}
|
|
@@ -43,15 +43,12 @@ export interface TaskManageToolOptions {
|
|
|
43
43
|
channelId: string;
|
|
44
44
|
/** Project checkout whose artifact state an independent verifier binds to. */
|
|
45
45
|
workingDirectory?: string;
|
|
46
|
-
/** Durable checker dispatch supplied by the long-lived runtime. */
|
|
47
|
-
dispatchVerification?: (taskId: string) => Promise<boolean>;
|
|
48
46
|
}
|
|
49
47
|
export interface TaskFields {
|
|
50
48
|
status: string;
|
|
51
49
|
enabled?: boolean;
|
|
52
50
|
wake?: string;
|
|
53
51
|
schedule?: string;
|
|
54
|
-
recurrence?: string;
|
|
55
52
|
control?: TaskControl;
|
|
56
53
|
outcome?: "completed" | "cancelled";
|
|
57
54
|
closedAt?: string;
|
|
@@ -1,16 +1,19 @@
|
|
|
1
|
-
import { type TaskVerification } from "../../tasks/control.js";
|
|
2
1
|
import { type VerificationAttestation } from "../../tasks/verification.js";
|
|
3
2
|
import type { TaskManageRequest, TaskManageResult, TaskManageToolOptions } from "./types.js";
|
|
4
3
|
/**
|
|
5
|
-
*
|
|
6
|
-
*
|
|
4
|
+
* Import a verifier's attestation. The task's own lifecycle status is not the authorization
|
|
5
|
+
* check — a real, matching, on-disk attestation for this task id is (spec 040's threat model:
|
|
6
|
+
* the task Markdown is agent-writable and proves nothing). `verify` works whether the task is
|
|
7
|
+
* still `waiting` (e.g. called right after its completion wake reactivated it) or already
|
|
8
|
+
* `active`.
|
|
7
9
|
*/
|
|
8
|
-
export declare function requestVerificationTask(options: TaskManageToolOptions, request: TaskManageRequest): Promise<TaskManageResult>;
|
|
9
10
|
export declare function verifyTask(options: TaskManageToolOptions, request: TaskManageRequest): Promise<TaskManageResult>;
|
|
10
11
|
/**
|
|
11
12
|
* `verify` writes control.verification from a real attestation file, but the task Markdown
|
|
12
13
|
* itself is writable by the agent's own write/edit tools — nothing stops it from hand-crafting
|
|
13
14
|
* a "passed" verification block that was never backed by a real verifier run. Re-check the
|
|
14
|
-
* attestation file on the consuming side (complete/doctor) too, not just at import time
|
|
15
|
+
* attestation file on the consuming side (complete/doctor) too, not just at import time, and
|
|
16
|
+
* against the task's *current* body hash directly — not a mirrored value the task file could
|
|
17
|
+
* itself have drifted.
|
|
15
18
|
*/
|
|
16
|
-
export declare function assertVerificationAttestationMatches(channelDir: string, id: string,
|
|
19
|
+
export declare function assertVerificationAttestationMatches(channelDir: string, id: string, runId: string | undefined, currentBodyHash: string): Promise<VerificationAttestation>;
|
|
@@ -1,64 +1,19 @@
|
|
|
1
|
-
import { join } from "node:path";
|
|
2
1
|
import { writeFileAtomically } from "../../shared/atomic-file.js";
|
|
3
|
-
import { errorMessage } from "../../shared/text-utils.js";
|
|
4
2
|
import { workspaceSubjectHash } from "../../tasks/artifact-subject.js";
|
|
5
3
|
import { createDefaultTaskControl } from "../../tasks/control.js";
|
|
6
|
-
import {
|
|
4
|
+
import { normalizeTaskId } from "../../tasks/ledger.js";
|
|
7
5
|
import { readStoredTask, taskBodyHash } from "../../tasks/store.js";
|
|
8
6
|
import { normalizeStoredStatus, resolveTaskTransition } from "../../tasks/transitions.js";
|
|
9
7
|
import { readVerificationAttestation } from "../../tasks/verification.js";
|
|
10
8
|
import { RecoverableToolError } from "../tool-details.js";
|
|
11
|
-
import {
|
|
9
|
+
import { renderTaskFile, requiredField } from "./shared.js";
|
|
12
10
|
/**
|
|
13
|
-
*
|
|
14
|
-
*
|
|
11
|
+
* Import a verifier's attestation. The task's own lifecycle status is not the authorization
|
|
12
|
+
* check — a real, matching, on-disk attestation for this task id is (spec 040's threat model:
|
|
13
|
+
* the task Markdown is agent-writable and proves nothing). `verify` works whether the task is
|
|
14
|
+
* still `waiting` (e.g. called right after its completion wake reactivated it) or already
|
|
15
|
+
* `active`.
|
|
15
16
|
*/
|
|
16
|
-
export async function requestVerificationTask(options, request) {
|
|
17
|
-
if (!request.id)
|
|
18
|
-
throw new RecoverableToolError('action "request-verification" requires an id.');
|
|
19
|
-
const id = normalizeTaskId(request.id);
|
|
20
|
-
const note = requiredField(request.note, "note", "request-verification");
|
|
21
|
-
const taskPath = join(tasksDir(options), `${id}.md`);
|
|
22
|
-
const { fields, body } = await readTaskDocument(taskPath, id);
|
|
23
|
-
resolveTaskTransition("request-verification", id, normalizeStoredStatus(fields.status, Boolean(fields.schedule)));
|
|
24
|
-
const uncheckedAcceptance = uncheckedTaskAcceptanceItems(body);
|
|
25
|
-
if (uncheckedAcceptance.length > 0) {
|
|
26
|
-
throw new RecoverableToolError(`Task "${id}" still has unchecked acceptance items: ${uncheckedAcceptance.join("; ")}. Check them with evidence before requesting verification.`);
|
|
27
|
-
}
|
|
28
|
-
if (!options.dispatchVerification) {
|
|
29
|
-
throw new RecoverableToolError(`Task "${id}" cannot enter verification wait because the durable checker is unavailable. Retry request-verification when the runtime can enqueue a checker.`);
|
|
30
|
-
}
|
|
31
|
-
const originalFields = structuredClone(fields);
|
|
32
|
-
const control = fields.control ?? createDefaultTaskControl(true);
|
|
33
|
-
control.verification = { required: true, status: "pending" };
|
|
34
|
-
control.blockedReason = undefined;
|
|
35
|
-
control.waitingFor = "verification";
|
|
36
|
-
control.nextAction = "Wait for the durable checker, then import its attestation.";
|
|
37
|
-
const waitingFields = { ...fields, status: "waiting", wake: undefined, control };
|
|
38
|
-
const nextBody = appendCurrentCycleNote(body, note);
|
|
39
|
-
await writeFileAtomically(taskPath, renderTaskFile(waitingFields, nextBody));
|
|
40
|
-
let accepted;
|
|
41
|
-
try {
|
|
42
|
-
accepted = await options.dispatchVerification(id);
|
|
43
|
-
}
|
|
44
|
-
catch (error) {
|
|
45
|
-
await writeFileAtomically(taskPath, renderTaskFile(originalFields, nextBody));
|
|
46
|
-
throw new RecoverableToolError(`Could not enqueue the verification checker for task "${id}": ${errorMessage(error)}. The task was restored to active; retry request-verification.`);
|
|
47
|
-
}
|
|
48
|
-
if (!accepted) {
|
|
49
|
-
// Do not leave a signal-waiting task with no signal source. Roll back atomically to active;
|
|
50
|
-
// the caller can retry once durable dispatch is available.
|
|
51
|
-
await writeFileAtomically(taskPath, renderTaskFile(originalFields, nextBody));
|
|
52
|
-
throw new RecoverableToolError(`Could not enqueue the verification checker for task "${id}". The task was restored to active; retry request-verification.`);
|
|
53
|
-
}
|
|
54
|
-
return {
|
|
55
|
-
action: "request-verification",
|
|
56
|
-
id,
|
|
57
|
-
path: taskPath,
|
|
58
|
-
status: "waiting",
|
|
59
|
-
notice: `任务 \`${id}\` 已进入独立验收等待;checker 完成后 runtime 会恢复任务。`,
|
|
60
|
-
};
|
|
61
|
-
}
|
|
62
17
|
export async function verifyTask(options, request) {
|
|
63
18
|
if (!request.id)
|
|
64
19
|
throw new RecoverableToolError('action "verify" requires an id.');
|
|
@@ -67,10 +22,7 @@ export async function verifyTask(options, request) {
|
|
|
67
22
|
const task = await readStoredTask(options.channelDir, id);
|
|
68
23
|
if (!task)
|
|
69
24
|
throw new RecoverableToolError(`Task "${id}" does not exist; create it before verification.`);
|
|
70
|
-
resolveTaskTransition("verify", id, normalizeStoredStatus(task.fields.status
|
|
71
|
-
if (task.fields.control?.waitingFor !== "verification") {
|
|
72
|
-
throw new RecoverableToolError(`Task "${id}" is not waiting for verification. Request verification first so the checker signal is tied to this task.`);
|
|
73
|
-
}
|
|
25
|
+
resolveTaskTransition("verify", id, normalizeStoredStatus(task.fields.status));
|
|
74
26
|
const attestation = await readVerificationAttestation(options.channelDir, runId);
|
|
75
27
|
if (attestation.taskId !== id) {
|
|
76
28
|
throw new RecoverableToolError(`Verification run "${runId}" belongs to task "${attestation.taskId}", not "${id}".`);
|
|
@@ -95,13 +47,7 @@ export async function verifyTask(options, request) {
|
|
|
95
47
|
required: true,
|
|
96
48
|
status: attestation.verdict === "pass" ? "passed" : "failed",
|
|
97
49
|
runId,
|
|
98
|
-
evidence: attestation.evidence,
|
|
99
|
-
bodyHash: attestation.bodyHash,
|
|
100
|
-
subjectHash: attestation.subjectHash,
|
|
101
|
-
checkedAt: attestation.checkedAt,
|
|
102
50
|
};
|
|
103
|
-
// The verdict lives in `control.verification`; `lastOutcome` stays runtime-owned telemetry.
|
|
104
|
-
control.blockedReason = attestation.verdict === "fail" ? attestation.evidence : undefined;
|
|
105
51
|
control.waitingFor = undefined;
|
|
106
52
|
control.nextAction = undefined;
|
|
107
53
|
task.fields.control = control;
|
|
@@ -113,28 +59,30 @@ export async function verifyTask(options, request) {
|
|
|
113
59
|
id,
|
|
114
60
|
path: task.path,
|
|
115
61
|
status: "active",
|
|
116
|
-
notice: `任务 \`${id}\` 独立验收结果:${attestation.verdict.toUpperCase()}(run: ${runId})。`,
|
|
62
|
+
notice: `任务 \`${id}\` 独立验收结果:${attestation.verdict.toUpperCase()}${attestation.verificationStrength === "advisory" ? "(advisory)" : ""}(run: ${runId})。`,
|
|
117
63
|
};
|
|
118
64
|
}
|
|
119
65
|
/**
|
|
120
66
|
* `verify` writes control.verification from a real attestation file, but the task Markdown
|
|
121
67
|
* itself is writable by the agent's own write/edit tools — nothing stops it from hand-crafting
|
|
122
68
|
* a "passed" verification block that was never backed by a real verifier run. Re-check the
|
|
123
|
-
* attestation file on the consuming side (complete/doctor) too, not just at import time
|
|
69
|
+
* attestation file on the consuming side (complete/doctor) too, not just at import time, and
|
|
70
|
+
* against the task's *current* body hash directly — not a mirrored value the task file could
|
|
71
|
+
* itself have drifted.
|
|
124
72
|
*/
|
|
125
|
-
export async function assertVerificationAttestationMatches(channelDir, id,
|
|
126
|
-
if (!
|
|
73
|
+
export async function assertVerificationAttestationMatches(channelDir, id, runId, currentBodyHash) {
|
|
74
|
+
if (!runId) {
|
|
127
75
|
throw new RecoverableToolError(`Task "${id}" has no verification run id; rerun task_manage verify before complete.`);
|
|
128
76
|
}
|
|
129
|
-
const attestation = await readVerificationAttestation(channelDir,
|
|
77
|
+
const attestation = await readVerificationAttestation(channelDir, runId);
|
|
130
78
|
if (attestation.taskId !== id) {
|
|
131
|
-
throw new RecoverableToolError(`Verification run "${
|
|
79
|
+
throw new RecoverableToolError(`Verification run "${runId}" belongs to task "${attestation.taskId}", not "${id}"; rerun verification.`);
|
|
132
80
|
}
|
|
133
81
|
if (attestation.verdict !== "pass") {
|
|
134
|
-
throw new RecoverableToolError(`Verification run "${
|
|
82
|
+
throw new RecoverableToolError(`Verification run "${runId}" recorded a FAIL, not a PASS; rerun verification.`);
|
|
135
83
|
}
|
|
136
|
-
if (attestation.bodyHash !==
|
|
137
|
-
throw new RecoverableToolError(`Task "${id}"
|
|
84
|
+
if (attestation.bodyHash !== currentBodyHash) {
|
|
85
|
+
throw new RecoverableToolError(`Task "${id}" changed since verification run "${runId}"; rerun task_manage verify.`);
|
|
138
86
|
}
|
|
139
87
|
return attestation;
|
|
140
88
|
}
|
|
@@ -4,7 +4,7 @@ import type { TaskManageRequest, TaskManageResult, TaskManageToolOptions } from
|
|
|
4
4
|
export type { TaskManageAction, TaskManageRequest, TaskManageResult, TaskManageToolOptions, } from "./task-manage/types.js";
|
|
5
5
|
/**
|
|
6
6
|
* The `task_manage` dispatcher. Each action lives in a focused module — `create`,
|
|
7
|
-
* `lifecycle` (progress/set/complete/skip/cancel/list) and `verification` (
|
|
7
|
+
* `lifecycle` (progress/set/complete/skip/cancel/list) and `verification` (verify) — over a
|
|
8
8
|
* shared helper layer, with the status transition table in `src/tasks/transitions.ts` (spec
|
|
9
9
|
* 029, D7). This entry only routes and wraps the tool.
|
|
10
10
|
*/
|
|
@@ -3,10 +3,10 @@ import { withTaskMutation } from "../tasks/mutation-lock.js";
|
|
|
3
3
|
import { createTask } from "./task-manage/create.js";
|
|
4
4
|
import { cancelTask, completeTask, listTasks, progressTask, setTask, skipTask } from "./task-manage/lifecycle.js";
|
|
5
5
|
import { parseAction, taskManageSchema } from "./task-manage/schema.js";
|
|
6
|
-
import {
|
|
6
|
+
import { verifyTask } from "./task-manage/verification.js";
|
|
7
7
|
/**
|
|
8
8
|
* The `task_manage` dispatcher. Each action lives in a focused module — `create`,
|
|
9
|
-
* `lifecycle` (progress/set/complete/skip/cancel/list) and `verification` (
|
|
9
|
+
* `lifecycle` (progress/set/complete/skip/cancel/list) and `verification` (verify) — over a
|
|
10
10
|
* shared helper layer, with the status transition table in `src/tasks/transitions.ts` (spec
|
|
11
11
|
* 029, D7). This entry only routes and wraps the tool.
|
|
12
12
|
*/
|
|
@@ -24,8 +24,6 @@ function dispatchTaskMutation(options, request) {
|
|
|
24
24
|
return createTask(options, request);
|
|
25
25
|
case "progress":
|
|
26
26
|
return progressTask(options, request);
|
|
27
|
-
case "request-verification":
|
|
28
|
-
return requestVerificationTask(options, request);
|
|
29
27
|
case "set":
|
|
30
28
|
return setTask(options, request);
|
|
31
29
|
case "verify":
|
|
@@ -57,7 +55,7 @@ export function createTaskManageTool(options) {
|
|
|
57
55
|
action: parseAction(request.action),
|
|
58
56
|
});
|
|
59
57
|
return {
|
|
60
|
-
content: [{ type: "text", text: JSON.stringify(result
|
|
58
|
+
content: [{ type: "text", text: JSON.stringify(result) }],
|
|
61
59
|
details: { ...result },
|
|
62
60
|
};
|
|
63
61
|
},
|
package/dist/tools/truncate.d.ts
CHANGED
|
@@ -9,6 +9,14 @@
|
|
|
9
9
|
*/
|
|
10
10
|
export declare const DEFAULT_MAX_LINES = 2000;
|
|
11
11
|
export declare const DEFAULT_MAX_BYTES: number;
|
|
12
|
+
/**
|
|
13
|
+
* Upper bound for a file read/sent as base64 in one `sh -c` (fix plan §2.3). `base64` inflates a
|
|
14
|
+
* file to 4/3 of its size, and the executor caps captured stdout at 10MB -- above this threshold
|
|
15
|
+
* the encoded output would be silently cut mid-stream, producing a buffer that still decodes (so
|
|
16
|
+
* failure is invisible) but is corrupt. 5MB leaves headroom for the 4/3 blow-up plus protocol
|
|
17
|
+
* overhead. A code constant, not a settings.json key, per CLAUDE.md's rule for numeric thresholds.
|
|
18
|
+
*/
|
|
19
|
+
export declare const MAX_INLINE_BINARY_BYTES: number;
|
|
12
20
|
export interface TruncationResult {
|
|
13
21
|
/** The truncated content */
|
|
14
22
|
content: string;
|
package/dist/tools/truncate.js
CHANGED
|
@@ -9,6 +9,14 @@
|
|
|
9
9
|
*/
|
|
10
10
|
export const DEFAULT_MAX_LINES = 2000;
|
|
11
11
|
export const DEFAULT_MAX_BYTES = 50 * 1024; // 50KB
|
|
12
|
+
/**
|
|
13
|
+
* Upper bound for a file read/sent as base64 in one `sh -c` (fix plan §2.3). `base64` inflates a
|
|
14
|
+
* file to 4/3 of its size, and the executor caps captured stdout at 10MB -- above this threshold
|
|
15
|
+
* the encoded output would be silently cut mid-stream, producing a buffer that still decodes (so
|
|
16
|
+
* failure is invisible) but is corrupt. 5MB leaves headroom for the 4/3 blow-up plus protocol
|
|
17
|
+
* overhead. A code constant, not a settings.json key, per CLAUDE.md's rule for numeric thresholds.
|
|
18
|
+
*/
|
|
19
|
+
export const MAX_INLINE_BINARY_BYTES = 5 * 1024 * 1024;
|
|
12
20
|
/**
|
|
13
21
|
* Format bytes as human-readable size.
|
|
14
22
|
*/
|