@oyasmi/pipiclaw 0.7.7 → 0.8.0

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 (37) hide show
  1. package/README.md +9 -2
  2. package/dist/agent/channel-runner.d.ts +3 -0
  3. package/dist/agent/channel-runner.js +7 -1
  4. package/dist/agent/commands.js +7 -2
  5. package/dist/agent/prompt-builder.js +46 -0
  6. package/dist/agent/types.d.ts +2 -0
  7. package/dist/memory/task-digest.js +17 -0
  8. package/dist/runtime/bootstrap.d.ts +5 -0
  9. package/dist/runtime/bootstrap.js +57 -2
  10. package/dist/runtime/dingtalk.d.ts +2 -0
  11. package/dist/runtime/durable-dispatch.d.ts +28 -0
  12. package/dist/runtime/durable-dispatch.js +144 -0
  13. package/dist/runtime/events.d.ts +4 -2
  14. package/dist/runtime/events.js +12 -8
  15. package/dist/runtime/task-commands.d.ts +6 -0
  16. package/dist/runtime/task-commands.js +284 -3
  17. package/dist/runtime/task-driver.d.ts +32 -0
  18. package/dist/runtime/task-driver.js +270 -0
  19. package/dist/settings.d.ts +12 -0
  20. package/dist/settings.js +30 -0
  21. package/dist/shared/task-ledger.d.ts +27 -0
  22. package/dist/shared/task-ledger.js +209 -9
  23. package/dist/subagents/tool.d.ts +13 -0
  24. package/dist/subagents/tool.js +203 -11
  25. package/dist/tasks/artifact-subject.d.ts +6 -0
  26. package/dist/tasks/artifact-subject.js +29 -0
  27. package/dist/tasks/control.d.ts +83 -0
  28. package/dist/tasks/control.js +292 -0
  29. package/dist/tasks/store.d.ts +32 -0
  30. package/dist/tasks/store.js +142 -0
  31. package/dist/tasks/verification.d.ts +23 -0
  32. package/dist/tasks/verification.js +68 -0
  33. package/dist/tools/registry.d.ts +1 -1
  34. package/dist/tools/registry.js +6 -5
  35. package/dist/tools/task-manage.d.ts +37 -3
  36. package/dist/tools/task-manage.js +385 -28
  37. package/package.json +1 -1
@@ -65,6 +65,16 @@ export interface PipiclawTaskDigestSettings {
65
65
  maxTasks: number;
66
66
  maxChars: number;
67
67
  }
68
+ export interface PipiclawTaskDriverSettings {
69
+ /** Native runtime wake-up for actionable task-ledger entries. */
70
+ enabled: boolean;
71
+ /** Earliest continuation after a task changed during its previous run. */
72
+ continuationDelayMinutes: number;
73
+ /** Retry delay when a dispatched task made no observable ledger progress. */
74
+ stalledRetryMinutes: number;
75
+ /** Global enqueue cap per scan, with round-robin fairness across channels. */
76
+ maxDispatchesPerTick: number;
77
+ }
68
78
  export interface PipiclawSessionMemorySettings {
69
79
  enabled: boolean;
70
80
  minTurnsBetweenUpdate: number;
@@ -124,6 +134,7 @@ export interface PipiclawSettings {
124
134
  retry?: Partial<PipiclawRetrySettings>;
125
135
  memoryRecall?: Partial<PipiclawMemoryRecallSettings>;
126
136
  taskDigest?: Partial<PipiclawTaskDigestSettings>;
137
+ taskDriver?: Partial<PipiclawTaskDriverSettings>;
127
138
  sessionMemory?: Partial<PipiclawSessionMemorySettings>;
128
139
  memoryGrowth?: Partial<PipiclawMemoryGrowthSettings>;
129
140
  memoryMaintenance?: Partial<PipiclawMemoryMaintenanceSettings>;
@@ -163,6 +174,7 @@ export declare class PipiclawSettingsManager {
163
174
  getRetrySettings(): PipiclawRetrySettings;
164
175
  getMemoryRecallSettings(): PipiclawMemoryRecallSettings;
165
176
  getTaskDigestSettings(): PipiclawTaskDigestSettings;
177
+ getTaskDriverSettings(): PipiclawTaskDriverSettings;
166
178
  getSessionMemorySettings(): PipiclawSessionMemorySettings;
167
179
  getMemoryGrowthSettings(): PipiclawMemoryGrowthSettings;
168
180
  getMemoryMaintenanceSettings(): PipiclawMemoryMaintenanceSettings;
package/dist/settings.js CHANGED
@@ -36,6 +36,15 @@ const DEFAULT_TASK_DIGEST = {
36
36
  maxTasks: 8,
37
37
  maxChars: 1000,
38
38
  };
39
+ // The driver makes `wake` an executable task property rather than a convention
40
+ // that requires users to install a heartbeat event and sensor script. A changed
41
+ // task can continue promptly; an unchanged task backs off to avoid token loops.
42
+ const DEFAULT_TASK_DRIVER = {
43
+ enabled: true,
44
+ continuationDelayMinutes: 5,
45
+ stalledRetryMinutes: 60,
46
+ maxDispatchesPerTick: 4,
47
+ };
39
48
  const DEFAULT_SESSION_MEMORY = {
40
49
  enabled: true,
41
50
  minTurnsBetweenUpdate: 2,
@@ -180,6 +189,27 @@ export class PipiclawSettingsManager {
180
189
  ...this.settings.taskDigest,
181
190
  };
182
191
  }
192
+ getTaskDriverSettings() {
193
+ const configured = {
194
+ ...DEFAULT_TASK_DRIVER,
195
+ ...this.settings.taskDriver,
196
+ };
197
+ const continuationDelayMinutes = Number.isFinite(configured.continuationDelayMinutes)
198
+ ? Math.min(60, Math.max(1, Math.floor(configured.continuationDelayMinutes)))
199
+ : DEFAULT_TASK_DRIVER.continuationDelayMinutes;
200
+ const stalledRetryMinutes = Number.isFinite(configured.stalledRetryMinutes)
201
+ ? Math.min(24 * 60, Math.max(continuationDelayMinutes, Math.floor(configured.stalledRetryMinutes)))
202
+ : DEFAULT_TASK_DRIVER.stalledRetryMinutes;
203
+ const maxDispatchesPerTick = Number.isFinite(configured.maxDispatchesPerTick)
204
+ ? Math.min(20, Math.max(1, Math.floor(configured.maxDispatchesPerTick)))
205
+ : DEFAULT_TASK_DRIVER.maxDispatchesPerTick;
206
+ return {
207
+ enabled: configured.enabled !== false,
208
+ continuationDelayMinutes,
209
+ stalledRetryMinutes,
210
+ maxDispatchesPerTick,
211
+ };
212
+ }
183
213
  getSessionMemorySettings() {
184
214
  return {
185
215
  ...DEFAULT_SESSION_MEMORY,
@@ -1,3 +1,4 @@
1
+ import { type TaskControl, type TaskVerificationMode } from "../tasks/control.js";
1
2
  /**
2
3
  * Shared reader for the task ledger (`workspace/<channelId>/tasks/*.md`).
3
4
  *
@@ -14,6 +15,9 @@ export interface TaskFrontmatter {
14
15
  status?: string;
15
16
  wake?: string;
16
17
  recurrence?: string;
18
+ control?: TaskControl;
19
+ /** false only when a control field exists but cannot be parsed/validated. */
20
+ controlReadable?: boolean;
17
21
  }
18
22
  export interface TaskLedgerEntry {
19
23
  /** Filename without `.md`; the task id. */
@@ -33,6 +37,8 @@ export interface TaskSkeletonInput {
33
37
  goal: string;
34
38
  dod: string;
35
39
  manual?: string;
40
+ verificationPlan?: string;
41
+ verificationMode?: TaskVerificationMode;
36
42
  }
37
43
  export declare const DEFAULT_TASK_MANUAL = "- Follow the DoD, keep the current cycle log updated, and schedule check-ins when waiting.";
38
44
  export declare const STANDARD_TASK_SECTIONS: readonly [{
@@ -44,6 +50,9 @@ export declare const STANDARD_TASK_SECTIONS: readonly [{
44
50
  }, {
45
51
  readonly label: "Manual";
46
52
  readonly names: readonly ["Manual", "手册"];
53
+ }, {
54
+ readonly label: "Verification";
55
+ readonly names: readonly ["Verification", "验收"];
47
56
  }, {
48
57
  readonly label: "Current Cycle";
49
58
  readonly names: readonly ["Current Cycle", "当前周期"];
@@ -67,7 +76,25 @@ export declare function isTaskActionable(frontmatter: TaskFrontmatter, now: numb
67
76
  export declare function extractTaskTitle(content: string, fallbackId: string): string;
68
77
  export declare function hasTaskHeading(content: string, names: readonly string[]): boolean;
69
78
  export declare function missingStandardTaskSections(content: string): string[];
79
+ /** Unchecked Markdown acceptance boxes under DoD or Verification sections. */
80
+ export declare function uncheckedTaskAcceptanceItems(content: string): string[];
70
81
  export declare function renderStandardTaskBody(input: TaskSkeletonInput): string;
82
+ export interface TaskDocumentFields {
83
+ status: string;
84
+ wake?: string;
85
+ recurrence?: string;
86
+ control?: TaskControl;
87
+ }
88
+ export declare function renderTaskDocument(fields: TaskDocumentFields, body: string): string;
89
+ /** Append one progress bullet to the standard Current Cycle section. */
90
+ export declare function appendCurrentCycleNote(content: string, note: string): string;
91
+ /**
92
+ * Close the visible current-cycle notes into History and open a fresh cycle.
93
+ * Periodic task cycles deliberately use this small, deterministic transformation
94
+ * instead of asking the model to hand-edit headings and risk appending future
95
+ * checkpoints to the previous cycle.
96
+ */
97
+ export declare function startTaskCycle(content: string, cycleId: string): string;
71
98
  /** Actionable first; then earliest wake first (unset wake sorts as "ready now"); then id. */
72
99
  export declare function compareTaskEntries(a: TaskLedgerEntry, b: TaskLedgerEntry): number;
73
100
  /**
@@ -1,12 +1,14 @@
1
1
  import { readdir, readFile } from "node:fs/promises";
2
2
  import { join } from "node:path";
3
- const FRONTMATTER_FIELDS = ["status", "wake", "recurrence"];
3
+ import { parseTaskControl, taskPriorityRank } from "../tasks/control.js";
4
+ const FRONTMATTER_FIELDS = ["status", "wake", "recurrence", "control"];
4
5
  const TASK_ID_PATTERN = /^[A-Za-z0-9._-]+$/;
5
6
  export const DEFAULT_TASK_MANUAL = "- Follow the DoD, keep the current cycle log updated, and schedule check-ins when waiting.";
6
7
  export const STANDARD_TASK_SECTIONS = [
7
8
  { label: "Goal", names: ["Goal", "目标"] },
8
9
  { label: "DoD", names: ["DoD"] },
9
10
  { label: "Manual", names: ["Manual", "手册"] },
11
+ { label: "Verification", names: ["Verification", "验收"] },
10
12
  { label: "Current Cycle", names: ["Current Cycle", "当前周期"] },
11
13
  { label: "History", names: ["History", "历史"] },
12
14
  ];
@@ -45,7 +47,23 @@ export function parseTaskFrontmatter(content) {
45
47
  const key = line.slice(0, idx).trim();
46
48
  if (FRONTMATTER_FIELDS.includes(key)) {
47
49
  const value = line.slice(idx + 1).trim();
48
- frontmatter[key] = value || undefined;
50
+ if (key === "control") {
51
+ if (!value) {
52
+ frontmatter.controlReadable = false;
53
+ }
54
+ else {
55
+ try {
56
+ frontmatter.control = parseTaskControl(value);
57
+ frontmatter.controlReadable = true;
58
+ }
59
+ catch {
60
+ frontmatter.controlReadable = false;
61
+ }
62
+ }
63
+ }
64
+ else {
65
+ frontmatter[key] = value || undefined;
66
+ }
49
67
  }
50
68
  }
51
69
  return frontmatter;
@@ -58,8 +76,14 @@ export function parseTaskFrontmatter(content) {
58
76
  export function isTaskActionable(frontmatter, now) {
59
77
  if (!frontmatter.readable)
60
78
  return true;
61
- if (frontmatter.status === "done")
79
+ if (frontmatter.controlReadable === false)
80
+ return true;
81
+ if (frontmatter.status === "done" ||
82
+ frontmatter.status === "cancelled" ||
83
+ frontmatter.status === "escalated" ||
84
+ frontmatter.status === "paused") {
62
85
  return false;
86
+ }
63
87
  if (frontmatter.wake) {
64
88
  const wakeAt = new Date(frontmatter.wake).getTime();
65
89
  if (Number.isFinite(wakeAt) && wakeAt > now)
@@ -76,17 +100,60 @@ export function extractTaskTitle(content, fallbackId) {
76
100
  }
77
101
  return fallbackId;
78
102
  }
103
+ function matchesTaskSectionTitle(title, names) {
104
+ const normalized = title.trim().toLowerCase();
105
+ return names.some((name) => {
106
+ const expected = name.toLowerCase();
107
+ return (normalized === expected ||
108
+ normalized.startsWith(`${expected} `) ||
109
+ normalized.startsWith(`${expected}(`) ||
110
+ normalized.startsWith(`${expected}(`));
111
+ });
112
+ }
79
113
  export function hasTaskHeading(content, names) {
80
114
  return content.split("\n").some((line) => {
81
115
  const match = /^#{1,6}\s+(.+?)\s*$/.exec(line);
82
- return match ? names.some((name) => match[1].trim().toLowerCase() === name.toLowerCase()) : false;
116
+ return match ? matchesTaskSectionTitle(match[1] ?? "", names) : false;
83
117
  });
84
118
  }
85
119
  export function missingStandardTaskSections(content) {
86
120
  return STANDARD_TASK_SECTIONS.filter((section) => !hasTaskHeading(content, section.names)).map((section) => section.label);
87
121
  }
122
+ /** Unchecked Markdown acceptance boxes under DoD or Verification sections. */
123
+ export function uncheckedTaskAcceptanceItems(content) {
124
+ const unchecked = [];
125
+ let section;
126
+ let sectionLevel = 0;
127
+ for (const line of content.split("\n")) {
128
+ const heading = /^(#{1,6})\s+(.+?)\s*$/.exec(line);
129
+ if (heading) {
130
+ const level = heading[1]?.length ?? 7;
131
+ if (matchesTaskSectionTitle(heading[2] ?? "", ["DoD"])) {
132
+ section = "DoD";
133
+ sectionLevel = level;
134
+ }
135
+ else if (matchesTaskSectionTitle(heading[2] ?? "", ["Verification", "验收"])) {
136
+ section = "Verification";
137
+ sectionLevel = level;
138
+ }
139
+ else if (section && level <= sectionLevel) {
140
+ section = undefined;
141
+ }
142
+ continue;
143
+ }
144
+ if (!section)
145
+ continue;
146
+ const item = /^\s*[-*]\s+\[\s\]\s*(.+?)\s*$/.exec(line)?.[1];
147
+ if (item)
148
+ unchecked.push(`${section}: ${item}`);
149
+ }
150
+ return unchecked;
151
+ }
88
152
  export function renderStandardTaskBody(input) {
89
153
  const manual = input.manual?.trim() || DEFAULT_TASK_MANUAL;
154
+ const verificationPlan = input.verificationPlan?.trim() ||
155
+ "- Check every DoD item against concrete evidence.\n- Run the relevant deterministic checks before declaring PASS.";
156
+ const verificationMode = input.verificationMode ?? "independent";
90
157
  return [
91
158
  `# ${input.title}`,
92
159
  "",
@@ -99,6 +166,10 @@ export function renderStandardTaskBody(input) {
99
166
  "## Manual",
100
167
  manual,
101
168
  "",
169
+ "## Verification",
170
+ `Mode: ${verificationMode}`,
171
+ verificationPlan,
172
+ "",
102
173
  "## Current Cycle",
103
174
  "- Created; next step: start work and append progress here before ending each turn.",
104
175
  "",
@@ -106,22 +177,137 @@ export function renderStandardTaskBody(input) {
106
177
  "",
107
178
  ].join("\n");
108
179
  }
109
- /** First non-empty bullet/line under a "当前周期"/"current cycle" heading. */
180
+ export function renderTaskDocument(fields, body) {
181
+ const lines = ["---", `status: ${fields.status}`];
182
+ if (fields.wake)
183
+ lines.push(`wake: ${fields.wake}`);
184
+ if (fields.recurrence)
185
+ lines.push(`recurrence: ${fields.recurrence}`);
186
+ if (fields.control)
187
+ lines.push(`control: ${JSON.stringify(fields.control)}`);
188
+ lines.push("---");
189
+ return `${lines.join("\n")}\n${body}`;
190
+ }
191
+ /** Append one progress bullet to the standard Current Cycle section. */
192
+ export function appendCurrentCycleNote(content, note) {
193
+ const trimmedNote = note.trim().replace(/\s+/g, " ");
194
+ if (!trimmedNote) {
195
+ throw new Error("Current Cycle note must not be empty.");
196
+ }
197
+ const lines = content.split("\n");
198
+ let sectionStart = -1;
199
+ let sectionLevel = 0;
200
+ for (let index = 0; index < lines.length; index++) {
201
+ const match = /^(#{1,6})\s+(.+?)\s*$/.exec(lines[index] ?? "");
202
+ if (!match || !matchesTaskSectionTitle(match[2] ?? "", ["Current Cycle", "当前周期"]))
203
+ continue;
204
+ sectionStart = index;
205
+ sectionLevel = match[1]?.length ?? 0;
206
+ }
207
+ if (sectionStart === -1) {
208
+ throw new Error('Task body has no "Current Cycle" section; normalize the task skeleton first.');
209
+ }
210
+ let insertAt = lines.length;
211
+ for (let index = sectionStart + 1; index < lines.length; index++) {
212
+ const match = /^(#{1,6})\s+/.exec(lines[index] ?? "");
213
+ if (match && (match[1]?.length ?? 7) <= sectionLevel) {
214
+ insertAt = index;
215
+ break;
216
+ }
217
+ }
218
+ while (insertAt > sectionStart + 1 && (lines[insertAt - 1] ?? "").trim() === "") {
219
+ insertAt--;
220
+ }
221
+ lines.splice(insertAt, 0, `- ${trimmedNote}`);
222
+ return lines.join("\n");
223
+ }
224
+ /**
225
+ * Close the visible current-cycle notes into History and open a fresh cycle.
226
+ * Periodic task cycles deliberately use this small, deterministic transformation
227
+ * instead of asking the model to hand-edit headings and risk appending future
228
+ * checkpoints to the previous cycle.
229
+ */
230
+ export function startTaskCycle(content, cycleId) {
231
+ const normalizedCycleId = cycleId.trim();
232
+ if (!normalizedCycleId)
233
+ throw new Error("Cycle id must not be empty.");
234
+ const lines = content.split("\n");
235
+ let currentStart = -1;
236
+ let currentLevel = 0;
237
+ let historyStart = -1;
238
+ let historyLevel = 0;
239
+ for (let index = 0; index < lines.length; index++) {
240
+ const match = /^(#{1,6})\s+(.+?)\s*$/.exec(lines[index] ?? "");
241
+ if (!match)
242
+ continue;
243
+ const level = match[1]?.length ?? 0;
244
+ if (matchesTaskSectionTitle(match[2] ?? "", ["Current Cycle", "当前周期"])) {
245
+ currentStart = index;
246
+ currentLevel = level;
247
+ }
248
+ if (matchesTaskSectionTitle(match[2] ?? "", ["History", "历史"])) {
249
+ historyStart = index;
250
+ historyLevel = level;
251
+ break;
252
+ }
253
+ }
254
+ if (currentStart === -1 || historyStart === -1 || historyStart <= currentStart) {
255
+ throw new Error('Task body needs ordered "Current Cycle" and "History" sections before starting a new cycle.');
256
+ }
257
+ let currentEnd = historyStart;
258
+ for (let index = currentStart + 1; index < historyStart; index++) {
259
+ const match = /^(#{1,6})\s+/.exec(lines[index] ?? "");
260
+ if (match && (match[1]?.length ?? 7) <= currentLevel) {
261
+ currentEnd = index;
262
+ break;
263
+ }
264
+ }
265
+ const previous = lines
266
+ .slice(currentStart + 1, currentEnd)
267
+ .join("\n")
268
+ .trim();
269
+ const previousHeading = (lines[currentStart] ?? "## Current Cycle").replace(/^#+\s*/, "").trim();
270
+ const replacement = [
271
+ `${"#".repeat(currentLevel)} Current Cycle (${normalizedCycleId})`,
272
+ "- Cycle started; next step: follow the Manual and checkpoint concrete progress.",
273
+ ];
274
+ lines.splice(currentStart, currentEnd - currentStart, ...replacement);
275
+ const shiftedHistoryStart = historyStart + replacement.length - (currentEnd - currentStart);
276
+ const historyEntry = [
277
+ `### ${previousHeading} — closed`,
278
+ ...(previous ? [previous] : ["- No checkpoint was recorded in the previous cycle."]),
279
+ "",
280
+ ];
281
+ // A nested history heading would be unusual; inserting directly after the
282
+ // canonical History heading remains predictable and preserves all older notes.
283
+ void historyLevel;
284
+ lines.splice(shiftedHistoryStart + 1, 0, ...historyEntry);
285
+ return lines.join("\n");
286
+ }
287
+ /** Last non-empty bullet/line under a "当前周期"/"current cycle" heading. */
110
288
  function extractLatestNote(content) {
111
289
  const lines = content.split("\n");
112
290
  let inSection = false;
291
+ let sectionLevel = 0;
292
+ let latest;
113
293
  for (const line of lines) {
114
- if (/^#{1,6}\s/.test(line)) {
115
- inSection = /当前周期|current cycle/i.test(line);
294
+ const heading = /^(#{1,6})\s+(.+?)\s*$/.exec(line);
295
+ if (heading) {
296
+ if (inSection && (heading[1]?.length ?? 7) <= sectionLevel)
297
+ break;
298
+ if (!inSection && matchesTaskSectionTitle(heading[2] ?? "", ["Current Cycle", "当前周期"])) {
299
+ inSection = true;
300
+ sectionLevel = heading[1]?.length ?? 0;
301
+ }
116
302
  continue;
117
303
  }
118
304
  if (!inSection)
119
305
  continue;
120
306
  const trimmed = line.replace(/^\s*[-*]\s+/, "").trim();
121
307
  if (trimmed)
122
- return trimmed;
308
+ latest = trimmed;
123
309
  }
124
- return undefined;
310
+ return latest;
125
311
  }
126
312
  function wakeMsOf(frontmatter) {
127
313
  if (!frontmatter.wake)
@@ -133,6 +319,20 @@ function wakeMsOf(frontmatter) {
133
319
  export function compareTaskEntries(a, b) {
134
320
  if (a.actionable !== b.actionable)
135
321
  return a.actionable ? -1 : 1;
322
+ if (a.actionable && b.actionable) {
323
+ const ap = taskPriorityRank(a.frontmatter.control?.priority ?? "normal");
324
+ const bp = taskPriorityRank(b.frontmatter.control?.priority ?? "normal");
325
+ if (ap !== bp)
326
+ return ap - bp;
327
+ const ad = a.frontmatter.control?.deadline
328
+ ? new Date(a.frontmatter.control.deadline).getTime()
329
+ : Number.POSITIVE_INFINITY;
330
+ const bd = b.frontmatter.control?.deadline
331
+ ? new Date(b.frontmatter.control.deadline).getTime()
332
+ : Number.POSITIVE_INFINITY;
333
+ if (ad !== bd)
334
+ return ad - bd;
335
+ }
136
336
  const aw = a.wakeMs ?? Number.NEGATIVE_INFINITY;
137
337
  const bw = b.wakeMs ?? Number.NEGATIVE_INFINITY;
138
338
  if (aw !== bw)
@@ -23,6 +23,10 @@ declare const subagentSchema: Type.TObject<{
23
23
  contextMode: Type.TOptional<Type.TUnion<[Type.TLiteral<"isolated">, Type.TLiteral<"contextual">]>>;
24
24
  memory: Type.TOptional<Type.TUnion<[Type.TLiteral<"none">, Type.TLiteral<"session">, Type.TLiteral<"relevant">]>>;
25
25
  paths: Type.TOptional<Type.TArray<Type.TString>>;
26
+ purpose: Type.TOptional<Type.TUnion<[Type.TLiteral<"work">, Type.TLiteral<"verify">]>>;
27
+ taskId: Type.TOptional<Type.TString>;
28
+ isolation: Type.TOptional<Type.TUnion<[Type.TLiteral<"shared">, Type.TLiteral<"worktree">]>>;
29
+ worktreePath: Type.TOptional<Type.TString>;
26
30
  }>;
27
31
  export interface SubAgentToolDetails {
28
32
  kind: "subagent";
@@ -36,9 +40,18 @@ export interface SubAgentToolDetails {
36
40
  failed: boolean;
37
41
  failureReason?: string;
38
42
  usage: UsageTotals;
43
+ runId: string;
44
+ purpose: "work" | "verify";
45
+ taskId?: string;
46
+ isolation: "shared" | "worktree";
47
+ worktreePath?: string;
48
+ worktreeBranch?: string;
49
+ verificationVerdict?: "pass" | "fail";
39
50
  }
40
51
  export interface SubAgentToolOptions {
41
52
  executor: Executor;
53
+ /** Host checkout used as the shared cwd and worktree source. Defaults to process.cwd(). */
54
+ workingDirectory?: string;
42
55
  getCurrentModel: () => Model<Api>;
43
56
  getAvailableModels: () => Model<Api>[];
44
57
  resolveApiKey: (model: Model<Api>) => Promise<string>;