@ordewell/core 0.4.23 → 0.5.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.
Files changed (46) hide show
  1. package/dist/{ITerminalRunner-CuNYBnqK.d.mts → ITerminalRunner-DCjsa2-I.d.mts} +31 -1
  2. package/dist/{ITerminalRunner-Da1gIAFX.d.ts → ITerminalRunner-H1yT8LTy.d.ts} +31 -1
  3. package/dist/{ModeResolver-mtIWrLXn.d.mts → ModeResolver-DVJ7HV3k.d.mts} +1 -1
  4. package/dist/{ModeResolver-Ob-ihQbI.d.ts → ModeResolver-Dkig8ghQ.d.ts} +1 -1
  5. package/dist/Task-BxQkPlXO.d.mts +664 -0
  6. package/dist/Task-BxQkPlXO.d.ts +664 -0
  7. package/dist/{chunk-O2MFTRHA.mjs → chunk-GWPIYDQW.mjs} +29 -5
  8. package/dist/chunk-GWPIYDQW.mjs.map +1 -0
  9. package/dist/{chunk-T4KGVP4N.mjs → chunk-JVMDEHRQ.mjs} +1 -1
  10. package/dist/chunk-JVMDEHRQ.mjs.map +1 -0
  11. package/dist/chunk-T2S5O36I.mjs +103 -0
  12. package/dist/chunk-T2S5O36I.mjs.map +1 -0
  13. package/dist/{chunk-MKUTJDT2.mjs → chunk-XWOUIA6A.mjs} +2 -2
  14. package/dist/index.d.mts +614 -104
  15. package/dist/index.d.ts +614 -104
  16. package/dist/index.js +3780 -1209
  17. package/dist/index.js.map +1 -1
  18. package/dist/index.mjs +3747 -1291
  19. package/dist/index.mjs.map +1 -1
  20. package/dist/order-labels.d.mts +1 -1
  21. package/dist/order-labels.d.ts +1 -1
  22. package/dist/{parsing-BJoHbA-t.d.ts → parsing-CF_grC29.d.ts} +2 -2
  23. package/dist/{parsing-BWfpLch9.d.mts → parsing-DRp4dPC0.d.mts} +2 -2
  24. package/dist/parsing.d.mts +3 -3
  25. package/dist/parsing.d.ts +3 -3
  26. package/dist/parsing.js.map +1 -1
  27. package/dist/parsing.mjs +2 -2
  28. package/dist/{plan-utils-DJm2a7Zp.d.ts → plan-utils-CkNbqAmS.d.ts} +63 -5
  29. package/dist/{plan-utils-s6VL8NDF.d.mts → plan-utils-CtB3_Ovf.d.mts} +63 -5
  30. package/dist/plan-utils.d.mts +3 -3
  31. package/dist/plan-utils.d.ts +3 -3
  32. package/dist/plan-utils.js +7 -0
  33. package/dist/plan-utils.js.map +1 -1
  34. package/dist/plan-utils.mjs +6 -2
  35. package/dist/testing.d.mts +93 -3
  36. package/dist/testing.d.ts +93 -3
  37. package/dist/testing.js +200 -0
  38. package/dist/testing.js.map +1 -1
  39. package/dist/testing.mjs +179 -0
  40. package/dist/testing.mjs.map +1 -1
  41. package/package.json +1 -1
  42. package/dist/Task-4rDGr8Su.d.mts +0 -271
  43. package/dist/Task-4rDGr8Su.d.ts +0 -271
  44. package/dist/chunk-O2MFTRHA.mjs.map +0 -1
  45. package/dist/chunk-T4KGVP4N.mjs.map +0 -1
  46. /package/dist/{chunk-MKUTJDT2.mjs.map → chunk-XWOUIA6A.mjs.map} +0 -0
@@ -0,0 +1,664 @@
1
+ /**
2
+ * Why isolated execution is unavailable for a workspace. The orchestrator needs
3
+ * the reason, not just a boolean: `dirty` is offered a stash or an explicit
4
+ * "run without isolation", while the others fall back to the shared
5
+ * workspace root with a one-line notice.
6
+ */
7
+ type IsolationInactiveReason = 'disabled' | 'git-missing' | 'not-git' | 'no-commits' | 'dirty' | 'nested-repos';
8
+ /**
9
+ * `repos` names, relative to the workspace, the repositories behind the answer:
10
+ * when active, the ones that will isolate, with `shared` the paths every task
11
+ * will share live; otherwise the nested ones `nested-repos` refuses, the dirty
12
+ * ones of a `dirty` group, or the commitless ones of a `no-commits` group. A
13
+ * group of one names none.
14
+ */
15
+ type IsolationAvailability = {
16
+ active: true;
17
+ repos?: string[];
18
+ shared?: string[];
19
+ } | {
20
+ active: false;
21
+ reason: IsolationInactiveReason;
22
+ repos?: string[];
23
+ };
24
+ /**
25
+ * Where a run's tasks work, as the planner is told it: the repos of the group
26
+ * and the paths shared live between tasks. A lone repository is `['.']` with
27
+ * nothing shared.
28
+ */
29
+ interface RepoGroupLayout {
30
+ repos: string[];
31
+ shared: string[];
32
+ }
33
+ type IsolationOutcome = 'merged' | 'conflict' | 'failed';
34
+ /**
35
+ * `active` — worktree exists, a runner may be writing to it.
36
+ * `kept` — released with its worktree and branch preserved for inspection.
37
+ * `conflict` — integration stopped on a merge conflict; worktree and refs kept.
38
+ * `repairing` — a conflict repair (ADR-0015) is working in the kept worktree;
39
+ * one that ends without landing leaves the task `conflict` again.
40
+ * `failed` — integration hit a git error other than a conflict; refs kept.
41
+ * `merged` — landed on the integration branch; worktree and task branch removed.
42
+ */
43
+ type IsolationTaskStatus = 'active' | 'kept' | 'conflict' | 'repairing' | 'failed' | 'merged';
44
+ /** One repo's share of a task: its worktree inside the task workspace. */
45
+ interface IsolationTaskRepo {
46
+ /** Absolute path of this repo's worktree: the task workspace joined with the repo's path. */
47
+ worktree: string;
48
+ /**
49
+ * Paths bootstrapped from the real repo (symlinks, junctions, copies).
50
+ * Recorded so the commit step can leave them out — a symlink is not matched
51
+ * by a `node_modules/` ignore rule and would otherwise be committed.
52
+ */
53
+ linked: string[];
54
+ /** Whether the task brought commits to this repo; unknown until it first integrates. */
55
+ changed?: boolean;
56
+ }
57
+ interface IsolationTaskRecord {
58
+ taskId: string;
59
+ order: number;
60
+ title: string;
61
+ /** One branch name, the same in every repo, so a task is one name to look up across the group. */
62
+ branch: string;
63
+ /**
64
+ * Absolute path of the task workspace, holding one worktree per repo at the
65
+ * repo's path. The Runner's cwd is inside it when the workspace is a repo
66
+ * subdirectory; for a group of one it is the worktree.
67
+ */
68
+ workspace: string;
69
+ /** For the task as a whole: landing is atomic across the repos it changed. */
70
+ status: IsolationTaskStatus;
71
+ /** Keyed by repo path. */
72
+ repos: Record<string, IsolationTaskRepo>;
73
+ /** The repo whose merge stopped the task from landing, while `status` is `conflict` or `failed`. */
74
+ conflictRepo?: string;
75
+ /** Repo-relative paths, in `conflictRepo`, that conflicted; set only while `status` is `conflict` or `repairing`. */
76
+ conflictFiles?: string[];
77
+ /**
78
+ * Conflict repairs started for this task (ADR-0015). Counted when one starts,
79
+ * so a crash cannot hand the spent attempt back; absent reads as none.
80
+ */
81
+ repairs?: number;
82
+ /**
83
+ * Keyed by repo path: each changed repo's integration tip when the repair in
84
+ * flight started — what the task branch must contain before it may land.
85
+ * Set only while `status` is `repairing`.
86
+ */
87
+ repairBase?: Record<string, string>;
88
+ /**
89
+ * Every file a repair was started for, across all of them: as `conflictFiles`
90
+ * names it in a group of one, prefixed with its repo's path in a group.
91
+ */
92
+ repairedFiles?: string[];
93
+ }
94
+ /**
95
+ * A task's landing in flight: each changed repo's integration tip from before
96
+ * the task's merge. On the run rather than the task record because it must
97
+ * outlive that record — a retry drops and recreates it — until every repo is
98
+ * back at its tip or the task has landed.
99
+ */
100
+ interface IsolationLanding {
101
+ taskId: string;
102
+ /** Keyed by repo path. */
103
+ tips: Record<string, string>;
104
+ }
105
+ /**
106
+ * One repository of the group (ADR-0014). Every git operation on it runs in
107
+ * `root`, never in the workspace root.
108
+ */
109
+ interface IsolationRepo {
110
+ /** Relative to the workspace root; `.` when the workspace is itself the repository. */
111
+ path: string;
112
+ /**
113
+ * Absolute: the workspace root joined with `path`. For a group of one that is
114
+ * the workspace root, which may be a subdirectory of the repository.
115
+ */
116
+ root: string;
117
+ /** The commit checked out at run start. Switching branches mid-run does not retarget it. */
118
+ baseRef: string;
119
+ /** Branch name checked out at run start; absent on a detached HEAD. */
120
+ baseBranch?: string;
121
+ integrationBranch: string;
122
+ }
123
+ /**
124
+ * One Execute-Plan click or one manual task run over the workspace's repo
125
+ * group. Plain JSON on purpose: the orchestrator persists it with the plan
126
+ * state so a resumed session can find its integration branches again. The
127
+ * module mutates `tasks` in place.
128
+ */
129
+ interface IsolationRun {
130
+ id: string;
131
+ workspaceRoot: string;
132
+ repos: IsolationRepo[];
133
+ /**
134
+ * Workspace paths outside every isolated repo, linked live into each task
135
+ * workspace: loose entries of the workspace root, the entries beside a deeper
136
+ * repo, and `sharedRepos`. Empty for a group of one.
137
+ */
138
+ shared: string[];
139
+ /** Repos of the group that could not be isolated — no commits, or git refused a worktree — and are among `shared`. */
140
+ sharedRepos: string[];
141
+ /** Keyed by task id — ids are unique within one plan and a run belongs to one plan. */
142
+ tasks: Record<string, IsolationTaskRecord>;
143
+ /**
144
+ * Set before a task's first merge and cleared once it has landed or been
145
+ * rolled back. One found set — after a crash, or a rollback git refused —
146
+ * names exactly what to return each repo's integration branch to.
147
+ */
148
+ landing?: IsolationLanding;
149
+ }
150
+ /**
151
+ * What a plan persists of isolated execution (`LegacyPlanState.isolation`): its
152
+ * run, and which added tasks resolve which conflicts. Belongs to that plan and
153
+ * its branches alone, so a copy of the plan (a fork) must not carry it.
154
+ */
155
+ interface PlanIsolation {
156
+ run: IsolationRun;
157
+ /** Resolver task id → the conflicted task whose branch it merges. */
158
+ resolvers: Record<string, string>;
159
+ }
160
+ /**
161
+ * A task's isolation as a surface shows it. `kept` covers every record whose
162
+ * worktree stays for inspection — a failed verdict, an interrupted attempt, an
163
+ * integration git refused — because to the user they are one thing: work that
164
+ * did not land and can be looked at. `none` is a task with no worktree in a plan
165
+ * that has an isolation run.
166
+ */
167
+ type TaskIsolationState = 'none' | 'active' | 'integrated' | 'conflict' | 'repairing' | 'kept';
168
+ type TaskIsolation = {
169
+ state: 'none';
170
+ } | {
171
+ state: Exclude<TaskIsolationState, 'none'>;
172
+ branch: string;
173
+ /** The task workspace; for a group of one, the task's worktree. */
174
+ worktree: string;
175
+ /** Paths of the repos the task changed. */
176
+ repos: string[];
177
+ conflictRepo?: string;
178
+ /** Repo-relative paths, in `conflictRepo`, that conflicted. */
179
+ conflictFiles?: string[];
180
+ /** The conflict repair running or last run, of the most a task may have; absent before its first. */
181
+ repair?: {
182
+ attempt: number;
183
+ limit: number;
184
+ };
185
+ /** What {@link IsolationTaskRecord.repairedFiles} says. */
186
+ repairedFiles?: string[];
187
+ };
188
+ interface IsolationLandedTask {
189
+ taskId: string;
190
+ order: number;
191
+ title: string;
192
+ /** Set when the task landed only after a conflict repair (ADR-0015): the files it was started for. */
193
+ repairedFiles?: string[];
194
+ }
195
+ interface IsolationHandoffRepo {
196
+ path: string;
197
+ integrationBranch: string;
198
+ baseRef: string;
199
+ /** Tasks whose work landed in this repo, in plan order. */
200
+ landed: IsolationLandedTask[];
201
+ }
202
+ interface IsolationHandoff {
203
+ repos: IsolationHandoffRepo[];
204
+ /** Tasks that landed on the integration branches, in plan order. */
205
+ landed: IsolationLandedTask[];
206
+ }
207
+ /** A plan's isolation as a surface shows it: a mark for each task the run touched, and its handoff. */
208
+ interface IsolationView {
209
+ tasks: Record<string, TaskIsolation>;
210
+ handoff: IsolationHandoff;
211
+ }
212
+ /**
213
+ * Why "Merge all" would not touch a repo. `partial-landing`: a task's landing
214
+ * was interrupted and could not be rolled back there, so its integration
215
+ * branch holds part of a task.
216
+ */
217
+ type IsolationMergeBlockReason = 'merge-in-progress' | 'conflict' | 'uncommitted-changes' | 'partial-landing' | 'git-error';
218
+ interface IsolationMergeBlock {
219
+ repo: string;
220
+ reason: IsolationMergeBlockReason;
221
+ /** The files that would conflict, or the user's uncommitted ones the merge also changes; empty for the other reasons. */
222
+ files: string[];
223
+ }
224
+ /**
225
+ * How "Merge all" went.
226
+ * - `merged`: every repo with work on its integration branch took it.
227
+ * - `blocked`: the preflight found repos that could not, so nothing was
228
+ * touched anywhere; `blocked` says which and why.
229
+ * - `conflict` / `failed`: a merge stopped in `repo` — on git older than 2.38,
230
+ * which cannot preflight, or for a reason no preflight could foresee. That
231
+ * merge was aborted, leaving `repo` as it was; `landed` names the repos
232
+ * merged before it, which stay merged, and is absent when there are none.
233
+ *
234
+ * A group of one is blocked only by a partial landing; otherwise its one merge
235
+ * lands or is aborted whole, so it reports as it always has.
236
+ */
237
+ type IsolationMergeResult = {
238
+ outcome: 'merged';
239
+ } | {
240
+ outcome: 'blocked';
241
+ blocked: IsolationMergeBlock[];
242
+ } | {
243
+ outcome: 'conflict' | 'failed';
244
+ repo: string;
245
+ files?: string[];
246
+ landed?: string[];
247
+ };
248
+ /**
249
+ * What `discard` does with each repo's integration branch: `keep` it for review
250
+ * or merge, `delete` it, or delete it only in the repos whose checked-out HEAD
251
+ * already contains it (`delete-merged`) — the one way that can never give up
252
+ * landed work the user has not merged.
253
+ */
254
+ type IntegrationDisposal = 'keep' | 'delete' | 'delete-merged';
255
+ /**
256
+ * Whether a conflict repair's work may land. `not-merged`: the task branch in
257
+ * `repo` does not contain the tip the repair started from. `conflict-markers`:
258
+ * it adds leftover conflict markers to `files`. `failed`: git could not tell.
259
+ */
260
+ type RepairEvidence = {
261
+ ok: true;
262
+ } | {
263
+ ok: false;
264
+ reason: 'not-merged' | 'conflict-markers' | 'failed';
265
+ repo: string;
266
+ files?: string[];
267
+ };
268
+ interface PreparedTask {
269
+ cwd: string;
270
+ branch: string;
271
+ /**
272
+ * Paths, relative to the task workspace, that are copies rather than links
273
+ * because a hard link was impossible (Windows, another volume). Edits to them
274
+ * stay in the task, so the user is told.
275
+ */
276
+ copied: string[];
277
+ }
278
+ interface IWorktreeIsolation {
279
+ /**
280
+ * A repo group with at least one repo to isolate, a clean tracked tree in
281
+ * each, and the config enabled; otherwise the reason it is not.
282
+ */
283
+ isActive(workspaceRoot: string): Promise<IsolationAvailability>;
284
+ /**
285
+ * Put the tracked changes of every dirty repo of the group on its git stash,
286
+ * the user's way out of a `dirty` refusal. Untracked files stay: they never
287
+ * block isolation.
288
+ */
289
+ stash(workspaceRoot: string): Promise<void>;
290
+ /**
291
+ * Mint a run: resolve each repo's base ref to a commit now, and share the
292
+ * repos that cannot be isolated. Only meaningful after `isActive` said yes;
293
+ * throws when no repo of the group can be isolated after all.
294
+ */
295
+ startRun(workspaceRoot: string): Promise<IsolationRun>;
296
+ /**
297
+ * Create the task workspace — one worktree per isolated repo from its
298
+ * integration tip, the shared paths linked in — and return the cwd to spawn
299
+ * the Runner into. A second `prepare` for the same task is a retry: the old
300
+ * attempt is discarded and the workspace recreated from the tips, so the
301
+ * task sees everything its predecessors have integrated.
302
+ */
303
+ prepare(task: Task, run: IsolationRun): Promise<PreparedTask>;
304
+ /**
305
+ * Hand a conflicted task's kept workspace to a conflict repair (ADR-0015)
306
+ * as it is — nothing is re-cut — and return the same cwd. Records each
307
+ * changed repo's integration tip as `repairBase`, counts the repair, and
308
+ * moves the task to `repairing`. Throws for a task that is not `conflict`.
309
+ */
310
+ reopen(task: Task, run: IsolationRun): Promise<PreparedTask>;
311
+ /**
312
+ * The evidence a repair must show before it lands: its work committed, and
313
+ * in each repo of `repairBase` the task branch containing that tip
314
+ * (`git merge-base --is-ancestor`) and adding no leftover conflict markers
315
+ * (`git diff --check`; whitespace warnings do not count). Changes nothing
316
+ * else: a task that fails stays `repairing` until released.
317
+ */
318
+ verifyRepair(task: Task, run: IsolationRun): Promise<RepairEvidence>;
319
+ /**
320
+ * Land the task atomically across the repos it changed: commit each
321
+ * worktree, then `git merge --no-ff` the task branch into each changed
322
+ * repo's integration branch. If any merge conflicts or fails, it is aborted
323
+ * and the merges already made for the task are reset away, so `merged`
324
+ * always means the whole task landed. Serialized inside the module; among
325
+ * tasks waiting at once the lowest plan order goes first. On anything but
326
+ * `merged` the worktrees and refs stay, and nothing is resolved here: a
327
+ * conflict is repaired, if at all, by a new attempt of the task in its own
328
+ * worktree (ADR-0015), never inside this queue.
329
+ *
330
+ * `persist` is called once `run.landing` is set and before the first
331
+ * merge; the caller saves the run there, synchronously, which is what
332
+ * lets `pruneOrphans` finish a landing a crash interrupted.
333
+ */
334
+ integrate(task: Task, run: IsolationRun, persist?: () => void): Promise<IsolationOutcome>;
335
+ /**
336
+ * `keep: false` removes the task's worktree, branch and record (cancel, task
337
+ * removal). `keep: true` leaves the worktree and branch exactly as they are
338
+ * for inspection — a failed verdict — and only moves the task off `active`,
339
+ * so a crash-recovery prune does not sweep it away; a repair it ends leaves
340
+ * the task `conflict`, as it was before the repair. Takes the run rather than
341
+ * a bare task id: ids are only unique within one plan, and one daemon serves
342
+ * many (ADR-0007).
343
+ */
344
+ release(run: IsolationRun, taskId: string, opts: {
345
+ keep: boolean;
346
+ }): Promise<void>;
347
+ /** End of run: park the integration branch for review and report what landed. */
348
+ handoff(run: IsolationRun): Promise<IsolationHandoff>;
349
+ /**
350
+ * Drop what a crash left behind: a landing it interrupted is rolled back in
351
+ * every repo, a repair it interrupted leaves its task `conflict`, then stale
352
+ * active worktrees and directories no record owns go.
353
+ */
354
+ pruneOrphans(run: IsolationRun): Promise<void>;
355
+ /** Unified diff of each repo's integration branch against its base ref. */
356
+ reviewDiff(run: IsolationRun): Promise<string>;
357
+ /**
358
+ * "Merge all": merge each repo's integration branch into whatever the user
359
+ * has checked out there. The one irreversible step, so it only ever happens
360
+ * when a caller asks for it. Every repo with work is preflighted first — no
361
+ * merge of the user's in progress, no conflict against their HEAD, no
362
+ * uncommitted edit to a file the merge changes — and unless all pass,
363
+ * nothing is merged anywhere. Only a merge Ordewell itself just started is
364
+ * ever aborted; nothing of the user's is reset.
365
+ */
366
+ mergeIntoCheckedOut(run: IsolationRun): Promise<IsolationMergeResult>;
367
+ /**
368
+ * Remove every worktree and task branch of the run, and settle each repo's
369
+ * integration branch as `integration` says. Anything but `keep` also clears
370
+ * the run's task records.
371
+ */
372
+ discard(run: IsolationRun, opts: {
373
+ integration: IntegrationDisposal;
374
+ }): Promise<void>;
375
+ /**
376
+ * Clear what other runs left in each repo of `run`'s group: every
377
+ * `ordewell/<run-id>/…` branch the repo's checked-out HEAD already contains.
378
+ * Never a branch of `run` itself, one a worktree has checked out, or any
379
+ * branch of a run that still has a worktree — that run may be live in
380
+ * another plan. Tries every repo, then throws naming those where git failed.
381
+ */
382
+ sweep(run: IsolationRun): Promise<void>;
383
+ }
384
+
385
+ interface UserStep {
386
+ order: number;
387
+ instruction: string;
388
+ completed: boolean;
389
+ }
390
+ /** One deterministic signal gathered while verifying a completed task. */
391
+ interface VerificationCheck {
392
+ name: 'exit_code' | 'completion_marker' | 'manual';
393
+ passed: boolean;
394
+ /** A check that did not apply. Skipped checks don't affect the verdict. */
395
+ skipped: boolean;
396
+ detail: string;
397
+ }
398
+ /** Evidence-based verdict for a completed task. Single end-to-end outcome produced by verification. */
399
+ interface Verdict {
400
+ outcome: 'pass' | 'fail';
401
+ reason: string;
402
+ checks: VerificationCheck[];
403
+ decidedAt: string;
404
+ }
405
+ interface TaskOutputSummary {
406
+ reviewReason: string;
407
+ logTail: string;
408
+ capturedAt: string;
409
+ }
410
+ type TaskType = 'ai' | 'user';
411
+ type TaskStatus = 'pending' | 'approved' | 'in_progress' | 'completed' | 'failed' | 'blocked' | 'awaiting_user';
412
+ type TaskMode = string;
413
+ interface TaskModelAssignment {
414
+ modelId: string;
415
+ modelLabel: string;
416
+ thinkingEffort?: string;
417
+ /**
418
+ * All variant ids the model offered when this assignment was made. Carried
419
+ * on the assignment because runners need it at spawn time (opencode's TUI
420
+ * only honors an assigned variant when the others are config-disabled) and
421
+ * the discovery catalog isn't available there.
422
+ */
423
+ availableVariants?: string[];
424
+ }
425
+ type RunnerId = string;
426
+ interface Task {
427
+ id: string;
428
+ order: number;
429
+ title: string;
430
+ description: string;
431
+ type: TaskType;
432
+ status: TaskStatus;
433
+ dependencies: string[];
434
+ prompt?: string;
435
+ userSteps?: UserStep[];
436
+ subtasks: Task[];
437
+ verdict?: Verdict;
438
+ outputSummary?: TaskOutputSummary;
439
+ assignedModel?: TaskModelAssignment;
440
+ assignedRunner: RunnerId;
441
+ thinkingEffort?: string;
442
+ taskMode?: TaskMode;
443
+ completionMarker: string;
444
+ autonomy?: 'AFK' | 'HITL';
445
+ sliceType?: 'HITL' | 'AFK';
446
+ userStoriesCovered?: string[];
447
+ }
448
+ interface DiscoveredMode {
449
+ id: string;
450
+ label: string;
451
+ description: string;
452
+ }
453
+ type ResearchToolType = 'read_file' | 'read_files' | 'glob' | 'grep' | 'find_symbol' | 'list_dir' | 'bash' | 'fetch' | 'web_search' | 'spawn_research_agent'
454
+ /**
455
+ * A tool belonging to a harness planner's own toolbox (ADR-0009) that has no
456
+ * Ordewell equivalent — Edit, WebFetch, TodoWrite, whatever a coding agent
457
+ * ships next. The real name travels in `toolLabel` rather than being
458
+ * relabelled as a tool it is not; the union stays closed so the
459
+ * exhaustiveness checks in every surface's icon/label switch survive.
460
+ */
461
+ | 'agent_tool';
462
+ /**
463
+ * What happened when a research tool call ran, for honest per-surface
464
+ * rendering. The broadcast seam carries this on every `research_step_done` so
465
+ * surfaces do not have to pattern-match refusal text to tell a refused `rm`
466
+ * from a successful `rm` — the old render path flipped a `✓` for both.
467
+ */
468
+ type ResearchStepOutcome = 'success' | 'failure' | 'refused' | 'denied' | 'not_executed';
469
+ interface ResearchStep {
470
+ id: string;
471
+ tool: ResearchToolType;
472
+ /** The tool's own name when it came from a harness planner — always set for `agent_tool`. */
473
+ toolLabel?: string;
474
+ args: string;
475
+ result: string;
476
+ success: boolean;
477
+ outcome: ResearchStepOutcome;
478
+ /** The model's tool_call id, so a surface can match `tool_result` to the
479
+ * pending `tool_call` it announced — robust under parallel same-tool rounds. */
480
+ toolCallId?: string;
481
+ timestamp: string;
482
+ thinkingText?: string;
483
+ }
484
+ interface UserPromptEntry {
485
+ id: string;
486
+ type: 'user_prompt' | 'system';
487
+ content: string;
488
+ timestamp: string;
489
+ }
490
+ type ResearchLogEntry = ResearchStep | UserPromptEntry;
491
+ interface ResearchProgress {
492
+ type: 'thinking' | 'tool_call' | 'tool_result' | 'plan_token' | 'interrupted' | 'liveness';
493
+ text?: string;
494
+ tool?: string;
495
+ /** Harness planners (ADR-0009): the agent's own name for a tool Ordewell has no member for. */
496
+ toolLabel?: string;
497
+ toolArgs?: string;
498
+ toolResult?: string;
499
+ planToken?: string;
500
+ step?: ResearchStep;
501
+ /** The model's tool_call id, threaded on tool_call and tool_result so a
502
+ * surface can match the result to its pending call — robust under parallel
503
+ * same-tool rounds where LIFO-by-name matching mislabels summaries. */
504
+ toolCallId?: string;
505
+ /** Present when this event originates from (or reports on) one spawned research subagent (issue #34). */
506
+ subagentId?: string;
507
+ }
508
+ interface ThinkingBlock {
509
+ id: string;
510
+ text: string;
511
+ }
512
+ interface StreamThinkingEvent {
513
+ type: 'thinking';
514
+ block: ThinkingBlock;
515
+ }
516
+ interface StreamStepEvent {
517
+ type: 'step';
518
+ step: ResearchStep;
519
+ }
520
+ type StreamEvent = StreamThinkingEvent | StreamStepEvent;
521
+ interface DiscoveredModel {
522
+ modelId: string;
523
+ modelLabel: string;
524
+ runnerProvider?: string;
525
+ /**
526
+ * Human-facing provider name as the runner itself reports it (e.g.
527
+ * "OpenCode Zen" for `runnerProvider: 'opencode'`). Populated from the
528
+ * runner's own provider catalog when available; when absent the UI derives a
529
+ * label from `runnerProvider` by title-casing.
530
+ */
531
+ runnerProviderLabel?: string;
532
+ /**
533
+ * The runner whose catalog listed this model. Stamped once, at the single
534
+ * `ModelDiscovery.discover` choke point, so a flat cross-runner list can
535
+ * still say where each entry came from — `runnerProvider` alone cannot:
536
+ * OpenCode reports most of its catalog as `openrouter`, which names the
537
+ * serving backend, not the agent Ordewell would spawn.
538
+ */
539
+ runnerId?: string;
540
+ /** The runner's display name (`OpenCode`), from its manifest. */
541
+ runnerLabel?: string;
542
+ variants: {
543
+ id: string;
544
+ label: string;
545
+ }[];
546
+ }
547
+ type PlanStatus = 'draft' | 'approved' | 'rejected' | 'running' | 'completed';
548
+ /**
549
+ * One entry of the planner's persisted dialogue (ADR-0002). The single source
550
+ * of truth for both UI redisplay and conversational context. Tool-call results
551
+ * are NOT stored here — they live in the AI service's tool-use history;
552
+ * `researchLog` remains the persisted tool trace for the UI.
553
+ */
554
+ interface ConversationMessage {
555
+ role: 'user' | 'assistant';
556
+ content: string;
557
+ timestamp: string;
558
+ /**
559
+ * Timeline marker: 'plan_generated' records the point in the dialogue where
560
+ * the plan was committed (the UI anchors the plan card there on restore);
561
+ * 'system' is a host-injected notice; 'compaction' is the summary a
562
+ * user-triggered compaction left in place of the earlier messages — always
563
+ * the transcript's first entry. Absent for ordinary chat turns, so
564
+ * sessions saved before markers existed degrade gracefully.
565
+ */
566
+ kind?: 'plan_generated' | 'system' | 'compaction';
567
+ }
568
+ interface QueuedMessage {
569
+ id: string;
570
+ text: string;
571
+ timestamp: string;
572
+ }
573
+ interface PlanModificationWarnings {
574
+ deletedCompleted: string[];
575
+ changedCompleted: string[];
576
+ deletedInProgress: string[];
577
+ modifiedInProgress: string[];
578
+ brokenDependencies: string[];
579
+ }
580
+ declare function emptyWarnings(): PlanModificationWarnings;
581
+ interface LegacyPlanState {
582
+ tasks: Task[];
583
+ generatedAt: string;
584
+ status: PlanStatus;
585
+ runners: RunnerId[];
586
+ lastUpdated: string;
587
+ researchLog?: ResearchLogEntry[];
588
+ /** The planner dialogue — user messages and assistant messages, in order (ADR-0002). */
589
+ conversationHistory?: ConversationMessage[];
590
+ /** Full markdown PRD once written by the planner (PRD mode), also saved to .scratch/<slug>/PRD.md. */
591
+ prdMarkdown?: string;
592
+ /** Follow-ups queued while tasks execute — applied as plan modifications between batches. */
593
+ queuedMessages?: QueuedMessage[];
594
+ /**
595
+ * The plan's isolation run (ADR-0013), written from the orchestrator at
596
+ * persist time and read back only when a saved plan is adopted. It names
597
+ * branches and worktrees that belong to this plan alone: a fork of the plan
598
+ * must leave it behind rather than share it.
599
+ */
600
+ isolation?: PlanIsolation;
601
+ }
602
+ interface Message {
603
+ id: string;
604
+ role: 'user' | 'planner' | 'system';
605
+ content: string;
606
+ timestamp: number;
607
+ }
608
+ interface TaskSnapshot extends Task {
609
+ completedAt: number;
610
+ verdict?: Verdict;
611
+ retryCount: number;
612
+ finalized: boolean;
613
+ }
614
+ type PlanState = {
615
+ phase: 'planning';
616
+ history: Message[];
617
+ message: string;
618
+ pendingTasks: Task[];
619
+ } | {
620
+ phase: 'executing';
621
+ history: Message[];
622
+ message: string;
623
+ executionLog: TaskSnapshot[];
624
+ pendingTasks: Task[];
625
+ goal: string;
626
+ runners: string[];
627
+ status: PlanStatus;
628
+ };
629
+ declare function migratePlanState(raw: unknown): PlanState;
630
+ declare function migrateLegacyPlan(legacy: LegacyPlanState): PlanState;
631
+
632
+ declare function createTask(overrides?: Partial<Task>): Task;
633
+ declare function createEmptyPlan(): LegacyPlanState;
634
+ declare function flattenTasks(tasks: Task[]): Task[];
635
+ /** A flattened task with the parent it hangs under, null for a top-level task. */
636
+ interface TaskWithParent {
637
+ task: Task;
638
+ parent: Task | null;
639
+ }
640
+ declare function flattenTasksWithParents(tasks: Task[]): TaskWithParent[];
641
+ declare function migrateTask(task: Record<string, unknown>): Task;
642
+ declare function addTaskToPlan(tasks: Task[], partial: Partial<Task>): Task[];
643
+ declare function removeTaskFromPlan(tasks: Task[], taskId: string): Task[];
644
+ declare function updateTaskInPlan(tasks: Task[], taskId: string, changes: Partial<Task>): Task[];
645
+ declare function renumberTasks(tasks: Task[]): Task[];
646
+ declare function validateModifiedPlan(original: Task[], modified: Task[]): PlanModificationWarnings;
647
+ interface ActiveTaskSession {
648
+ id: string;
649
+ taskId: string;
650
+ }
651
+ interface ValidationResult {
652
+ valid: boolean;
653
+ errors: string[];
654
+ }
655
+ interface ValidationContext {
656
+ executionLog: TaskSnapshot[];
657
+ oldPending: Task[];
658
+ newPending: Task[];
659
+ activeSessions: Map<string, ActiveTaskSession>;
660
+ }
661
+ type ValidationCheck = (ctx: ValidationContext) => ValidationResult;
662
+ declare function warningsText(w: PlanModificationWarnings): string | null;
663
+
664
+ export { type UserStep as $, type ActiveTaskSession as A, type ResearchStepOutcome as B, type ConversationMessage as C, type DiscoveredMode as D, type ResearchToolType as E, type RunnerId as F, type StreamStepEvent as G, type StreamThinkingEvent as H, type IWorktreeIsolation as I, type TaskIsolation as J, type TaskIsolationState as K, type LegacyPlanState as L, type Message as M, type TaskMode as N, type TaskModelAssignment as O, type PlanIsolation as P, type QueuedMessage as Q, type RepairEvidence as R, type StreamEvent as S, type Task as T, type TaskOutputSummary as U, type TaskSnapshot as V, type TaskStatus as W, type TaskType as X, type TaskWithParent as Y, type ThinkingBlock as Z, type UserPromptEntry as _, type DiscoveredModel as a, type ValidationCheck as a0, type ValidationContext as a1, type ValidationResult as a2, type Verdict as a3, type VerificationCheck as a4, addTaskToPlan as a5, createEmptyPlan as a6, createTask as a7, emptyWarnings as a8, flattenTasks as a9, flattenTasksWithParents as aa, migrateLegacyPlan as ab, migratePlanState as ac, migrateTask as ad, removeTaskFromPlan as ae, renumberTasks as af, updateTaskInPlan as ag, validateModifiedPlan as ah, warningsText as ai, type IntegrationDisposal as b, type IsolationAvailability as c, type IsolationHandoff as d, type IsolationHandoffRepo as e, type IsolationInactiveReason as f, type IsolationLandedTask as g, type IsolationLanding as h, type IsolationMergeBlock as i, type IsolationMergeBlockReason as j, type IsolationMergeResult as k, type IsolationOutcome as l, type IsolationRepo as m, type IsolationRun as n, type IsolationTaskRecord as o, type IsolationTaskRepo as p, type IsolationTaskStatus as q, type IsolationView as r, type PlanModificationWarnings as s, type PlanState as t, type PlanStatus as u, type PreparedTask as v, type RepoGroupLayout as w, type ResearchLogEntry as x, type ResearchProgress as y, type ResearchStep as z };