@oyasmi/pipiclaw 0.9.2 → 0.9.3-beta.2

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.
Files changed (178) hide show
  1. package/README.en.md +250 -0
  2. package/README.md +3 -1
  3. package/dist/agent/channel-runner.d.ts +59 -2
  4. package/dist/agent/channel-runner.js +177 -76
  5. package/dist/agent/job-manager.d.ts +76 -21
  6. package/dist/agent/job-manager.js +447 -63
  7. package/dist/agent/maintenance-context.js +4 -5
  8. package/dist/agent/prompt/manifest.d.ts +0 -2
  9. package/dist/agent/prompt/manifest.js +2 -3
  10. package/dist/agent/prompt/sections.js +3 -3
  11. package/dist/agent/session-events.js +4 -8
  12. package/dist/agent/turn-prompt.d.ts +7 -7
  13. package/dist/agent/turn-prompt.js +6 -9
  14. package/dist/agent/types.d.ts +12 -0
  15. package/dist/agent/types.js +1 -0
  16. package/dist/channel/channel-context.d.ts +13 -0
  17. package/dist/channel/channel-context.js +21 -1
  18. package/dist/commands/catalog.js +47 -20
  19. package/dist/memory/commands.d.ts +8 -0
  20. package/dist/memory/commands.js +113 -148
  21. package/dist/memory/index-budget.d.ts +27 -0
  22. package/dist/memory/index-budget.js +99 -0
  23. package/dist/memory/journal.d.ts +20 -0
  24. package/dist/memory/journal.js +78 -0
  25. package/dist/memory/lifecycle.d.ts +9 -15
  26. package/dist/memory/lifecycle.js +55 -145
  27. package/dist/memory/maintenance-gates.d.ts +13 -47
  28. package/dist/memory/maintenance-gates.js +13 -92
  29. package/dist/memory/maintenance-state.d.ts +10 -16
  30. package/dist/memory/maintenance-state.js +12 -59
  31. package/dist/memory/maintenance-tuning.d.ts +7 -27
  32. package/dist/memory/maintenance-tuning.js +11 -28
  33. package/dist/memory/migrate.d.ts +15 -0
  34. package/dist/memory/migrate.js +364 -0
  35. package/dist/memory/reflect-job.d.ts +43 -0
  36. package/dist/memory/reflect-job.js +117 -0
  37. package/dist/memory/reflect.d.ts +52 -0
  38. package/dist/memory/reflect.js +313 -0
  39. package/dist/memory/render.d.ts +19 -0
  40. package/dist/memory/render.js +35 -0
  41. package/dist/memory/review-log.d.ts +2 -1
  42. package/dist/memory/scheduler.d.ts +2 -3
  43. package/dist/memory/scheduler.js +14 -49
  44. package/dist/memory/search.d.ts +35 -0
  45. package/dist/memory/search.js +297 -0
  46. package/dist/memory/session-search.js +1 -1
  47. package/dist/memory/store.d.ts +108 -0
  48. package/dist/memory/store.js +418 -0
  49. package/dist/memory/task-digest.d.ts +2 -2
  50. package/dist/memory/task-digest.js +29 -36
  51. package/dist/memory/tombstones.d.ts +0 -11
  52. package/dist/memory/tombstones.js +6 -37
  53. package/dist/memory/transcript.js +12 -5
  54. package/dist/playbooks/agent-delegation.md +37 -9
  55. package/dist/playbooks/background-jobs.md +1 -1
  56. package/dist/playbooks/event-scheduling.md +6 -2
  57. package/dist/playbooks/memory-and-learning.md +36 -12
  58. package/dist/playbooks/outbound-media.md +1 -1
  59. package/dist/playbooks/runtime-orientation.md +9 -8
  60. package/dist/playbooks/task-loop.md +110 -0
  61. package/dist/runtime/bootstrap.d.ts +3 -3
  62. package/dist/runtime/bootstrap.js +66 -41
  63. package/dist/runtime/events.d.ts +9 -0
  64. package/dist/runtime/events.js +43 -4
  65. package/dist/runtime/task-commands.d.ts +14 -15
  66. package/dist/runtime/task-commands.js +249 -485
  67. package/dist/runtime/task-driver.d.ts +41 -29
  68. package/dist/runtime/task-driver.js +170 -317
  69. package/dist/runtime/task-migration.d.ts +34 -30
  70. package/dist/runtime/task-migration.js +229 -183
  71. package/dist/runtime/task-wake.d.ts +6 -3
  72. package/dist/runtime/task-wake.js +26 -19
  73. package/dist/settings.d.ts +0 -29
  74. package/dist/settings.js +12 -35
  75. package/dist/shared/markdown-sections.d.ts +0 -1
  76. package/dist/shared/markdown-sections.js +0 -3
  77. package/dist/subagents/discovery.d.ts +2 -2
  78. package/dist/subagents/discovery.js +21 -10
  79. package/dist/subagents/external/progress-tail.js +6 -1
  80. package/dist/subagents/external/run.js +1 -0
  81. package/dist/subagents/runs.d.ts +19 -2
  82. package/dist/subagents/runs.js +73 -4
  83. package/dist/subagents/tool.d.ts +10 -8
  84. package/dist/subagents/tool.js +55 -94
  85. package/dist/tasks/brief.d.ts +17 -0
  86. package/dist/tasks/brief.js +57 -0
  87. package/dist/tasks/budget.d.ts +26 -0
  88. package/dist/tasks/budget.js +59 -0
  89. package/dist/tasks/cycle.d.ts +48 -0
  90. package/dist/tasks/cycle.js +94 -0
  91. package/dist/tasks/frontmatter.d.ts +73 -0
  92. package/dist/tasks/frontmatter.js +175 -0
  93. package/dist/tasks/ledger.d.ts +66 -106
  94. package/dist/tasks/ledger.js +90 -546
  95. package/dist/tasks/log.d.ts +88 -0
  96. package/dist/tasks/log.js +97 -0
  97. package/dist/tasks/rounds.d.ts +41 -0
  98. package/dist/tasks/rounds.js +53 -0
  99. package/dist/tasks/session-path.d.ts +9 -0
  100. package/dist/tasks/session-path.js +16 -0
  101. package/dist/tasks/steer.d.ts +8 -0
  102. package/dist/tasks/steer.js +79 -0
  103. package/dist/tasks/store.d.ts +60 -35
  104. package/dist/tasks/store.js +166 -107
  105. package/dist/tasks/ticket.d.ts +102 -0
  106. package/dist/tasks/ticket.js +209 -0
  107. package/dist/tasks/verification.d.ts +47 -0
  108. package/dist/tasks/verification.js +60 -1
  109. package/dist/tools/index.d.ts +13 -4
  110. package/dist/tools/index.js +5 -10
  111. package/dist/tools/memory-manage.d.ts +6 -16
  112. package/dist/tools/memory-manage.js +108 -129
  113. package/dist/tools/presentation.js +2 -1
  114. package/dist/tools/registry.d.ts +11 -2
  115. package/dist/tools/registry.js +17 -6
  116. package/dist/tools/subagent-manage.d.ts +0 -9
  117. package/dist/tools/subagent-manage.js +8 -17
  118. package/dist/tools/task-manage/create.js +2 -2
  119. package/dist/tools/task-manage/lifecycle.d.ts +9 -4
  120. package/dist/tools/task-manage/lifecycle.js +136 -188
  121. package/dist/tools/task-manage/log-view.d.ts +8 -0
  122. package/dist/tools/task-manage/log-view.js +24 -0
  123. package/dist/tools/task-manage/schema.d.ts +38 -14
  124. package/dist/tools/task-manage/schema.js +46 -27
  125. package/dist/tools/task-manage/shared.d.ts +35 -31
  126. package/dist/tools/task-manage/shared.js +130 -141
  127. package/dist/tools/task-manage/step-end.d.ts +11 -0
  128. package/dist/tools/task-manage/step-end.js +134 -0
  129. package/dist/tools/task-manage/types.d.ts +23 -32
  130. package/dist/tools/task-manage.d.ts +4 -3
  131. package/dist/tools/task-manage.js +30 -15
  132. package/dist/tools/tool-details.d.ts +1 -1
  133. package/dist/tui/app.js +0 -2
  134. package/examples/sub-agents/README.md +54 -38
  135. package/examples/sub-agents/builder-hard.md +21 -12
  136. package/examples/sub-agents/builder.md +24 -16
  137. package/examples/sub-agents/explorer.md +17 -15
  138. package/examples/sub-agents/git-committer.md +8 -6
  139. package/examples/sub-agents/planner.md +17 -16
  140. package/examples/sub-agents/reviewer.md +11 -9
  141. package/examples/sub-agents/verifier.md +22 -16
  142. package/examples/sub-agents/worker.md +22 -6
  143. package/package.json +1 -1
  144. package/dist/agent/effect-ledger.d.ts +0 -32
  145. package/dist/agent/effect-ledger.js +0 -89
  146. package/dist/memory/bootstrap.d.ts +0 -17
  147. package/dist/memory/bootstrap.js +0 -120
  148. package/dist/memory/candidates.d.ts +0 -26
  149. package/dist/memory/candidates.js +0 -202
  150. package/dist/memory/consolidation.d.ts +0 -54
  151. package/dist/memory/consolidation.js +0 -292
  152. package/dist/memory/extraction.d.ts +0 -54
  153. package/dist/memory/extraction.js +0 -240
  154. package/dist/memory/files.d.ts +0 -71
  155. package/dist/memory/files.js +0 -419
  156. package/dist/memory/maintenance-jobs.d.ts +0 -41
  157. package/dist/memory/maintenance-jobs.js +0 -265
  158. package/dist/memory/metadata.d.ts +0 -57
  159. package/dist/memory/metadata.js +0 -142
  160. package/dist/memory/probation.d.ts +0 -17
  161. package/dist/memory/probation.js +0 -44
  162. package/dist/memory/promotion.d.ts +0 -38
  163. package/dist/memory/promotion.js +0 -36
  164. package/dist/memory/recall.d.ts +0 -59
  165. package/dist/memory/recall.js +0 -746
  166. package/dist/memory/session.d.ts +0 -24
  167. package/dist/memory/session.js +0 -273
  168. package/dist/playbooks/task-driving.md +0 -92
  169. package/dist/playbooks/task-planning.md +0 -58
  170. package/dist/tasks/control.d.ts +0 -56
  171. package/dist/tasks/control.js +0 -169
  172. package/dist/tasks/transitions.d.ts +0 -16
  173. package/dist/tasks/transitions.js +0 -48
  174. package/dist/tools/task-manage/verification.d.ts +0 -19
  175. package/dist/tools/task-manage/verification.js +0 -91
  176. package/examples/sub-agents/documenter.md +0 -50
  177. package/examples/sub-agents/log-sifter.md +0 -47
  178. package/examples/sub-agents/scout.md +0 -34
@@ -1,169 +0,0 @@
1
- import { formatLocalTime, parseLocalTime } from "../shared/local-time.js";
2
- import { errorMessage } from "../shared/text-utils.js";
3
- import { isPlainObject } from "../shared/type-guards.js";
4
- const WAITING_FOR = ["time", "user", "job", "external-signal"];
5
- const VERIFICATION_STATUSES = ["pending", "passed", "failed"];
6
- function optionalString(value) {
7
- if (typeof value !== "string")
8
- return undefined;
9
- const trimmed = value.trim();
10
- return trimmed || undefined;
11
- }
12
- function enumValue(value, values, fallback) {
13
- if (value === undefined)
14
- return fallback;
15
- if (typeof value !== "string" || !values.includes(value)) {
16
- throw new Error(`control enum value must be one of: ${values.join(", ")}`);
17
- }
18
- return value;
19
- }
20
- function parseStop(value) {
21
- if (value === undefined)
22
- return undefined;
23
- if (!isPlainObject(value))
24
- throw new Error("control.stop must be an object");
25
- const by = enumValue(value.by, ["user", "governor"], "user");
26
- const reason = optionalString(value.reason);
27
- const at = optionalString(value.at);
28
- if (!reason || !at || parseLocalTime(at) === undefined) {
29
- throw new Error("control.stop requires a reason and valid at timestamp");
30
- }
31
- return { by, reason, at: formatLocalTime(new Date(parseLocalTime(at))) };
32
- }
33
- export function createDefaultTaskControl(requiresVerification = false) {
34
- return {
35
- version: 3,
36
- verification: { required: requiresVerification, status: "pending" },
37
- };
38
- }
39
- /** Read the v3 control contract only. Anything else is a read-time failure — see `parseLegacyTaskControl`. */
40
- export function parseTaskControl(raw) {
41
- let value;
42
- try {
43
- value = JSON.parse(raw);
44
- }
45
- catch (error) {
46
- throw new Error(`control is not valid JSON: ${errorMessage(error)}`);
47
- }
48
- if (!isPlainObject(value) || value.version !== 3) {
49
- throw new Error("control must be a version 3 JSON object; repair it with task_update (no note).");
50
- }
51
- const verification = isPlainObject(value.verification) ? value.verification : {};
52
- const deadline = optionalString(value.deadline);
53
- if (deadline && parseLocalTime(deadline) === undefined) {
54
- throw new Error("control.deadline must be a valid local time");
55
- }
56
- const waitingFor = value.waitingFor === undefined ? undefined : enumValue(value.waitingFor, WAITING_FOR, "external-signal");
57
- return {
58
- version: 3,
59
- deadline,
60
- nextAction: optionalString(value.nextAction),
61
- waitingFor,
62
- verification: {
63
- required: typeof verification.required === "boolean" ? verification.required : false,
64
- status: enumValue(verification.status, VERIFICATION_STATUSES, "pending"),
65
- runId: optionalString(verification.runId),
66
- },
67
- cycleId: optionalString(value.cycleId),
68
- stop: parseStop(value.stop),
69
- };
70
- }
71
- /**
72
- * Migration-only reader for v1/v2 control blocks. `parseTaskControl` no longer accepts them —
73
- * this exists so `migrateLegacyTaskState` (spec 029, D6's window, closed here) can durably
74
- * upgrade an old file the one time it is encountered. Nothing else may call this.
75
- *
76
- * RETIRE AT v0.9.3 — see the header comment in `../runtime/task-migration.js`.
77
- */
78
- export function parseLegacyTaskControl(raw) {
79
- let value;
80
- try {
81
- value = JSON.parse(raw);
82
- }
83
- catch (error) {
84
- throw new Error(`control is not valid JSON: ${errorMessage(error)}`);
85
- }
86
- if (!isPlainObject(value) || (value.version !== 1 && value.version !== 2)) {
87
- throw new Error("legacy control must be a version 1 or version 2 JSON object");
88
- }
89
- const verification = isPlainObject(value.verification) ? value.verification : {};
90
- const deadline = optionalString(value.deadline);
91
- const waitingFor = value.waitingFor === undefined ? undefined : enumValue(value.waitingFor, WAITING_FOR, "external-signal");
92
- let stop = parseStop(value.stop);
93
- // v1 stored the stop dimension as a status-side `pausedBy` value. Preserve its
94
- // operational meaning while converting it to the structured record.
95
- if (!stop && value.pausedBy !== undefined) {
96
- const by = enumValue(value.pausedBy, ["user", "governor"], "user");
97
- stop = {
98
- by,
99
- reason: optionalString(value.blockedReason) ?? `Task stopped by ${by}.`,
100
- at: formatLocalTime(),
101
- };
102
- }
103
- return {
104
- version: 3,
105
- deadline: deadline && parseLocalTime(deadline) !== undefined ? deadline : undefined,
106
- nextAction: optionalString(value.nextAction),
107
- waitingFor,
108
- verification: {
109
- // v1's independent mode was the only mode that represented a real checker gate.
110
- required: typeof verification.required === "boolean" ? verification.required : verification.mode === "independent",
111
- status: enumValue(verification.status, VERIFICATION_STATUSES, "pending"),
112
- runId: optionalString(verification.runId),
113
- },
114
- cycleId: optionalString(value.cycleId),
115
- stop,
116
- };
117
- }
118
- /** Reset state that is meaningful only within one recurring task cycle. */
119
- export function resetTaskControlForCycle(control, cycleId) {
120
- const normalizedCycleId = cycleId.trim();
121
- if (!normalizedCycleId)
122
- throw new Error("cycleId must not be empty.");
123
- return {
124
- ...structuredClone(control),
125
- nextAction: undefined,
126
- waitingFor: undefined,
127
- verification: { required: control.verification.required, status: "pending" },
128
- cycleId: normalizedCycleId,
129
- stop: undefined,
130
- };
131
- }
132
- function patchOptionalString(current, value) {
133
- if (value === undefined)
134
- return current;
135
- return value.trim() || undefined;
136
- }
137
- export function applyTaskControlPatch(control, patch) {
138
- const next = structuredClone(control);
139
- let normalizedDeadlinePatch = patch.deadline;
140
- if (patch.deadline?.trim()) {
141
- const deadlineMs = parseLocalTime(patch.deadline);
142
- if (deadlineMs === undefined)
143
- throw new Error(`deadline "${patch.deadline}" is not a valid local time.`);
144
- normalizedDeadlinePatch = formatLocalTime(new Date(deadlineMs));
145
- }
146
- next.deadline = patchOptionalString(next.deadline, normalizedDeadlinePatch);
147
- next.nextAction = patchOptionalString(next.nextAction, patch.nextAction);
148
- if (patch.waitingFor !== undefined)
149
- next.waitingFor = patch.waitingFor;
150
- if (patch.verificationRequired !== undefined && patch.verificationRequired !== next.verification.required) {
151
- next.verification = { required: patch.verificationRequired, status: "pending" };
152
- }
153
- return next;
154
- }
155
- /**
156
- * Return a deterministic governance violation for a live task. Sleeping tasks have no current
157
- * work, so a deadline cannot stop them; waiting and active tasks are both subject to it — a
158
- * deadline is the user's own intent, not something a task can dodge by parking.
159
- */
160
- export function taskBudgetViolation(control, nowMs, status = "active") {
161
- if (status === "sleeping")
162
- return undefined;
163
- if (control.deadline) {
164
- const deadlineMs = parseLocalTime(control.deadline);
165
- if (deadlineMs !== undefined && deadlineMs < nowMs)
166
- return `deadline exceeded (${control.deadline})`;
167
- }
168
- return undefined;
169
- }
@@ -1,16 +0,0 @@
1
- /** The only lifecycle stages stored in an active task directory. */
2
- export declare const TASK_STATUSES: readonly ["active", "waiting", "sleeping"];
3
- export type TaskStatus = (typeof TASK_STATUSES)[number];
4
- /** Statuses a model/user may set directly; recurring sleeping is runtime-owned but repairable. */
5
- export declare const SETTABLE_TASK_STATUSES: readonly ["active", "waiting", "sleeping"];
6
- export type SettableTaskStatus = (typeof SETTABLE_TASK_STATUSES)[number];
7
- export type TaskLifecycleAction = "create"
8
- /** task_update with a `note` — a checkpoint on an open cycle. */
9
- | "checkpoint" | "verify" | "complete" | "skip" | "cancel"
10
- /** task_update with no `note` — a metadata-only edit (spec 046, D3.2). */
11
- | "metadata" | "pause" | "resume" | "run" | "governor-stop" | "wait-due" | "cycle-due";
12
- /** Canonicalize a stored status value, fail-open to `active` for anything not in the current vocabulary. */
13
- export declare function normalizeStoredStatus(raw: string | undefined): TaskStatus;
14
- export declare function isSettableTaskStatus(value: string): value is SettableTaskStatus;
15
- /** Assert an action is legal and resolve caller-supplied target status. */
16
- export declare function resolveTaskTransition(action: TaskLifecycleAction, id: string, from: TaskStatus, requestedStatus?: string): TaskStatus;
@@ -1,48 +0,0 @@
1
- import { RecoverableToolError } from "../shared/recoverable-error.js";
2
- /** The only lifecycle stages stored in an active task directory. */
3
- export const TASK_STATUSES = ["active", "waiting", "sleeping"];
4
- /** Statuses a model/user may set directly; recurring sleeping is runtime-owned but repairable. */
5
- export const SETTABLE_TASK_STATUSES = ["active", "waiting", "sleeping"];
6
- const LIVE = ["active", "waiting", "sleeping"];
7
- const WORKABLE = ["active", "waiting"];
8
- const TRANSITIONS = {
9
- create: { from: [], to: "active" },
10
- checkpoint: { from: WORKABLE, to: "caller" },
11
- // Not gated on a specific waitingFor value: the wake that reactivates a task parked for a
12
- // purpose=verify sub-agent already flips it to active before this runs (the same as any other
13
- // delegation wake), but `verify` also accepts waiting so it is not sensitive to exactly when
14
- // that reactivation lands relative to the model's own turn.
15
- verify: { from: WORKABLE, to: "active" },
16
- complete: { from: ["active"], to: "caller" },
17
- skip: { from: WORKABLE, to: "sleeping" },
18
- cancel: { from: LIVE, to: "caller" },
19
- metadata: { from: LIVE, to: "caller" },
20
- pause: { from: LIVE, to: "caller" },
21
- resume: { from: LIVE, to: "caller" },
22
- run: { from: LIVE, to: "active" },
23
- "governor-stop": { from: LIVE, to: "caller" },
24
- "wait-due": { from: ["waiting"], to: "active" },
25
- "cycle-due": { from: ["sleeping"], to: "active" },
26
- };
27
- /** Canonicalize a stored status value, fail-open to `active` for anything not in the current vocabulary. */
28
- export function normalizeStoredStatus(raw) {
29
- return raw !== undefined && TASK_STATUSES.includes(raw) ? raw : "active";
30
- }
31
- export function isSettableTaskStatus(value) {
32
- return SETTABLE_TASK_STATUSES.includes(value);
33
- }
34
- /** Assert an action is legal and resolve caller-supplied target status. */
35
- export function resolveTaskTransition(action, id, from, requestedStatus) {
36
- const rule = TRANSITIONS[action];
37
- if (!rule.from.includes(from)) {
38
- throw new RecoverableToolError(`Task ${id} is ${from}; action ${action} allows only from: ${rule.from.join(", ") || "(none)"}.`);
39
- }
40
- if (rule.to !== "caller")
41
- return rule.to;
42
- if (requestedStatus === undefined)
43
- return from;
44
- if (!isSettableTaskStatus(requestedStatus)) {
45
- throw new RecoverableToolError(`Invalid status "${requestedStatus}". Use one of ${SETTABLE_TASK_STATUSES.join(", ")}.`);
46
- }
47
- return requestedStatus;
48
- }
@@ -1,19 +0,0 @@
1
- import { type VerificationAttestation } from "../../tasks/verification.js";
2
- import type { TaskManageResult, TaskManageToolOptions, TaskVerifyRequest } from "./types.js";
3
- /**
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). `task_verify` works whether the task
7
- * is still `waiting` (e.g. called right after its completion wake reactivated it) or already
8
- * `active`.
9
- */
10
- export declare function verifyTask(options: TaskManageToolOptions, request: TaskVerifyRequest): Promise<TaskManageResult>;
11
- /**
12
- * `verify` writes control.verification from a real attestation file, but the task Markdown
13
- * itself is writable by the agent's own write/edit tools — nothing stops it from hand-crafting
14
- * a "passed" verification block that was never backed by a real verifier run. Re-check the
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.
18
- */
19
- export declare function assertVerificationAttestationMatches(channelDir: string, id: string, runId: string | undefined, currentBodyHash: string, trustedWorkingDirectory?: string): Promise<VerificationAttestation>;
@@ -1,91 +0,0 @@
1
- import { writeFileAtomically } from "../../shared/atomic-file.js";
2
- import { getSubAgentRunManager } from "../../subagents/runs.js";
3
- import { workspaceSubjectHash } from "../../tasks/artifact-subject.js";
4
- import { createDefaultTaskControl } from "../../tasks/control.js";
5
- import { normalizeTaskId } from "../../tasks/ledger.js";
6
- import { readStoredTask, taskBodyHash } from "../../tasks/store.js";
7
- import { normalizeStoredStatus, resolveTaskTransition } from "../../tasks/transitions.js";
8
- import { getVerificationSubjectHashOptions, readVerificationAttestation, } from "../../tasks/verification.js";
9
- import { RecoverableToolError } from "../tool-details.js";
10
- import { renderTaskFile } from "./shared.js";
11
- /**
12
- * Import a verifier's attestation. The task's own lifecycle status is not the authorization
13
- * check — a real, matching, on-disk attestation for this task id is (spec 040's threat model:
14
- * the task Markdown is agent-writable and proves nothing). `task_verify` works whether the task
15
- * is still `waiting` (e.g. called right after its completion wake reactivated it) or already
16
- * `active`.
17
- */
18
- export async function verifyTask(options, request) {
19
- const id = normalizeTaskId(request.id);
20
- const runId = request.verifierRunId;
21
- const task = await readStoredTask(options.channelDir, id);
22
- if (!task)
23
- throw new RecoverableToolError(`Task "${id}" does not exist; create it before verification.`);
24
- resolveTaskTransition("verify", id, normalizeStoredStatus(task.fields.status));
25
- const trustedWorkingDirectory = getSubAgentRunManager(options.channelId).get(runId)?.workingDirectory;
26
- const attestation = await readVerificationAttestation(options.channelDir, runId, {
27
- trustedWorkingDirectory,
28
- });
29
- if (attestation.taskId !== id) {
30
- throw new RecoverableToolError(`Verification run "${runId}" belongs to task "${attestation.taskId}", not "${id}".`);
31
- }
32
- if (attestation.workspaceChanged) {
33
- throw new RecoverableToolError(`Verification run "${runId}" changed protected workspace content; rerun the verifier on the current content. Test/build outputs under the documented transient artifact scope are allowed, but implementation changes are not.`);
34
- }
35
- if (attestation.bodyHash !== taskBodyHash(task.body)) {
36
- throw new RecoverableToolError(`Task "${id}" changed after verification run "${runId}"; rerun the verifier on current content.`);
37
- }
38
- if (attestation.subjectHash) {
39
- const subjectDir = attestation.subjectDir ?? trustedWorkingDirectory ?? options.workingDirectory ?? process.cwd();
40
- const currentSubject = await workspaceSubjectHash(subjectDir, getVerificationSubjectHashOptions(attestation));
41
- if (!currentSubject) {
42
- throw new RecoverableToolError(`Verification run "${runId}" is bound to a Git artifact subject, but the current checkout cannot be read. Rerun verification from the project checkout.`);
43
- }
44
- if (currentSubject !== attestation.subjectHash) {
45
- throw new RecoverableToolError(`Task "${id}" artifacts changed after verification run "${runId}"; rerun the verifier. Legacy attestations without a base commit are HEAD-sensitive and may also require re-verification after a normal Git commit.`);
46
- }
47
- }
48
- const control = task.fields.control ?? createDefaultTaskControl(true);
49
- control.verification = {
50
- required: true,
51
- status: attestation.verdict === "pass" ? "passed" : "failed",
52
- runId,
53
- };
54
- control.waitingFor = undefined;
55
- control.nextAction = undefined;
56
- task.fields.control = control;
57
- task.fields.status = "active";
58
- task.fields.wake = undefined;
59
- await writeFileAtomically(task.path, renderTaskFile(task.fields, task.body));
60
- return {
61
- action: "verify",
62
- id,
63
- path: task.path,
64
- status: "active",
65
- notice: `任务 \`${id}\` 独立验收结果:${attestation.verdict.toUpperCase()}${attestation.verificationStrength === "advisory" ? "(advisory)" : ""}(run: ${runId})。`,
66
- };
67
- }
68
- /**
69
- * `verify` writes control.verification from a real attestation file, but the task Markdown
70
- * itself is writable by the agent's own write/edit tools — nothing stops it from hand-crafting
71
- * a "passed" verification block that was never backed by a real verifier run. Re-check the
72
- * attestation file on the consuming side (complete/doctor) too, not just at import time, and
73
- * against the task's *current* body hash directly — not a mirrored value the task file could
74
- * itself have drifted.
75
- */
76
- export async function assertVerificationAttestationMatches(channelDir, id, runId, currentBodyHash, trustedWorkingDirectory) {
77
- if (!runId) {
78
- throw new RecoverableToolError(`Task "${id}" has no verification run id; rerun task_verify before task_close.`);
79
- }
80
- const attestation = await readVerificationAttestation(channelDir, runId, { trustedWorkingDirectory });
81
- if (attestation.taskId !== id) {
82
- throw new RecoverableToolError(`Verification run "${runId}" belongs to task "${attestation.taskId}", not "${id}"; rerun verification.`);
83
- }
84
- if (attestation.verdict !== "pass") {
85
- throw new RecoverableToolError(`Verification run "${runId}" recorded a FAIL, not a PASS; rerun verification.`);
86
- }
87
- if (attestation.bodyHash !== currentBodyHash) {
88
- throw new RecoverableToolError(`Task "${id}" changed since verification run "${runId}"; rerun task_verify.`);
89
- }
90
- return attestation;
91
- }
@@ -1,50 +0,0 @@
1
- ---
2
- name: documenter
3
- description: >-
4
- 文档交付:基于已稳定的实现和验证证据编写使用、设计、运维、迁移文档与变更记录。实现未定先用 builder,文档挑错用 reviewer,提交用 git-committer。
5
- runtime: external
6
- harness: codex-cli
7
- command: codex exec --sandbox workspace-write --skip-git-repo-check
8
- model: gpt-5.6-luna
9
- thinkingLevel: high
10
- workload: heavy
11
- mutates: write
12
- maxWallTimeSec: 3600
13
- ---
14
-
15
- 你是文档负责人。你依据当前实现和已验证的证据编写准确、可执行的文档与变更记录,只留可审查的工作树改动。
16
-
17
- ## 工作范围
18
-
19
- 按任务创建或修改需求、设计、使用、运维文档,以及变更记录和迁移指南;直接相关的示例和代码注释可以同步更新。需要产品决策或大范围代码修改时,说明问题并交回 planner 或 builder。默认在既有文档里做最小必要修改,不重排别人的文档结构(确需重构先说明理由),不夹带与本任务无关的改动。只留可审查的工作树改动,不 commit、push、发布或部署,提交交给 git-committer。
20
-
21
- ## 事实纪律
22
-
23
- - 事实来源优先级:当前实现与配置 → 实际运行或验证证据 → 已批准的需求与方案 → 历史文档。来源冲突时指出不一致,不把未确认内容写成事实。
24
- - 文档里出现的路径、命令、参数、字段名、默认值、返回结构和错误码,都要在当前实现或配置里核对过;核对不了的不写成事实,列入待确认。
25
- - 不编造示例输出、版本号、日期、性能数字、验证状态或不存在的选项。对运行结果和效果的说法必须来自实际验证或分析证据。
26
- - 操作性示例要能直接复制执行,用真实命令和路径;占位符用 `<尖括号>` 标出并说明取值来源。示意性的简化输出可以用,但要标明性质和省略了什么。
27
-
28
- ## 组织方式
29
-
30
- - 按读者要完成的任务组织,不按代码结构罗列:先让人跑通最小可用路径,再给完整参数、边界和排查。仓库已有结构就跟随它。
31
- - 解释意图、约束和后果,不复述代码逻辑。同一事实只在一处权威描述,别处引用它。
32
- - 变更记录只写用户或运维可观测的变化,包括兼容影响、迁移与回滚要求、已知限制;不把文件清单改写成营销文案,不宣称未被证明的改进。
33
- - 篇幅服从读者需要:不为凑长度扩写,也不为省事略过关键边界。
34
-
35
- ## 检查
36
-
37
- 改完看一遍文档 diff、链接、引用和示例;仓库有文档 lint 或生成检查就跑一次。未解决的评审问题、失败或阻塞的验证、未确认的事实,如实列进最终结果。
38
-
39
- ## 交付
40
-
41
- 最终消息是本次委派的交付物,编排方据此决策并向用户转述;完整文本另存为本次 run 的 `output.md`,但唤醒里只内联结尾一段,写成流水账会连开头的结论一起被截断丢掉。保持简短、只讲事实:
42
-
43
- ```
44
- 文档:<path — 读者可获得的新信息>
45
- 变更记录:<path 或版本条目 — 记录内容>(无需更新时写明依据)
46
- 检查:<命令或人工核对 → 结果>
47
- 状态:<已完成 / 有条件完成 / 未完成 + 未解决评审、失败或阻塞验证、未确认项与剩余风险>
48
- ```
49
-
50
- 用中文;代码、路径、命令、标识符和错误原文保持原样。
@@ -1,47 +0,0 @@
1
- ---
2
- name: log-sifter
3
- description: >-
4
- 大体量输出筛证据:在日志、构建输出或测试报告里按症状和时间窗定位关键片段,只带回结论与最小证据,避免原文淹没主会话。不做源码探索、复现或修复。
5
- runtime: internal
6
- tools:
7
- - read
8
- - grep
9
- - bash
10
- contextMode: isolated
11
- memory: none
12
- thinkingLevel: low
13
- workload: light
14
- mutates: read
15
- maxTurns: 32
16
- maxToolCalls: 64
17
- maxWallTimeSec: 900
18
- bashTimeoutSec: 300
19
- ---
20
-
21
- 你是日志筛查者。你在大量原始输出中定位与问题相关的证据,只把足以支撑结论的最小片段带回。
22
-
23
- ## 工作方式
24
-
25
- - 先摸清规模和格式(文件大小、日志格式、时间戳时区、可用时间范围),再决定怎么检索。永远不要从头顺读大文件。
26
- - 从症状关键词和时间窗收敛候选行:先用 `grep -n` / `-c` 看量级和分布,再读命中处的上下文。
27
- - 分清首次异常、重复噪声和恢复节点。重点看异常前最后一条正常记录、重启边界、退出码、OOM、信号和被截断的堆栈。
28
- - 证据定位到 `文件:行号` 或 `命令 + 时间戳`;频率和趋势结论要说明统计范围。
29
- - 任务缺问题、数据位置或时间范围时,先用已有线索做有限搜索;如果只会变成无目标全量扫描,就报告最小缺口,不硬扫。
30
-
31
- ## 边界
32
-
33
- 只读:不修改、删除或轮转日志,不重启服务、清缓存、改配置或触发复现;不用重定向写入、`sed -i`、`truncate` 以及 `--fix`、`--write` 之类的写入选项。不做源码探索、复现或修复——那是 explorer 和 builder 的事。
34
-
35
- ## 交付
36
-
37
- 最终消息是本次委派的交付物,编排方据此决策并向用户转述;完整文本另存为本次 run 的 `output.md`,但唤醒里只内联结尾一段,写成流水账会连开头的结论一起被截断丢掉。保持简短、只讲事实:
38
-
39
- ```
40
- 结论:<对任务问题的直接回答;无法确定就说无法确定>
41
- 时间线:<时间戳 — 事件>(按时间排序,只列与结论相关的关键节点)
42
- 证据:<file:line 或 命令 → 关键片段>(每条不超过 5 行原文,长堆栈只留最内层与最外层)
43
- 噪声:<已确认与本问题无关的高频错误及排除依据>
44
- 未覆盖:<未检索的范围、缺失的日志、需要写操作才能确认的假设>
45
- ```
46
-
47
- 摘要控制在 40 行以内。宁可说明未覆盖范围,也不要整段搬运原始日志。用中文;日志原文、命令、路径和错误信息保持原样。
@@ -1,34 +0,0 @@
1
- ---
2
- name: scout
3
- description: >-
4
- 单点事实查询:在大仓库里回答一个能用一条事实答完的问题,附 path:line 或命令证据。同仓库定位与调用链梳理用 explorer 更快,需要多步推理用 worker。
5
- runtime: external
6
- harness: codex-cli
7
- command: codex exec --sandbox read-only --skip-git-repo-check
8
- model: gpt-5.6-luna
9
- thinkingLevel: medium
10
- workload: heavy
11
- mutates: read
12
- maxWallTimeSec: 600
13
- ---
14
-
15
- 你是单点事实查询者。你只回答任务里的那一个问题,答案短、有出处,不做延伸分析。
16
-
17
- ## 查询原则
18
-
19
- - 只回答任务里的那一个问题。代码质量评价、改进建议、周边分析,只在任务同时要求时才做。
20
- - 答案必须来自你在当前工作目录实际读到或运行到的内容,不能用推测、通用惯例或对项目结构的印象顶替。不确定的地方标出来。
21
- - 快是这个角色的意义:先用一两轮精确检索直奔答案。两三轮还没收敛,就把已确认的部分和检索缺口带回去,不要把单点查询做成全仓库扫描。
22
- - 找不到就写「未找到」,并说明检索了什么范围(命令、路径、关键词)——这比猜一个答案有用得多。
23
- - 问题实际需要多步推理或取舍时,回答已确认的部分,并指出更合适的处理方式。
24
- - 你在只读沙箱里跑,完成查询需要的诊断命令放心用。
25
-
26
- ## 交付
27
-
28
- 最终消息是本次委派的交付物,编排方据此决策并向用户转述;完整文本另存为本次 run 的 `output.md`,但唤醒里只内联结尾一段,写成流水账会连开头的结论一起被截断丢掉。保持简短、只讲事实:
29
-
30
- - 第一行直接给答案本身(值、路径、符号、结论),不要铺垫,不要复述问题。
31
- - 随后最多三行证据:`path:line`,或你实际运行的命令及其关键输出。
32
- - 通常控制在十行以内;需要说明检索缺口时可略微展开。
33
-
34
- 用中文;代码、路径、命令、标识符和错误原文保持原样。