@ordewell/core 0.5.4 → 0.5.6

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 (56) hide show
  1. package/dist/IFileSystem-BkPX7mLD.d.mts +76 -0
  2. package/dist/IFileSystem-C0l-4MGT.d.ts +76 -0
  3. package/dist/{ModeResolver-Dkig8ghQ.d.ts → ModeResolver--16lh7dS.d.mts} +1 -1
  4. package/dist/{ModeResolver-DVJ7HV3k.d.mts → ModeResolver-CjpG5Wli.d.ts} +1 -1
  5. package/dist/Task-Dyxp67s2.d.mts +2086 -0
  6. package/dist/Task-Dyxp67s2.d.ts +2086 -0
  7. package/dist/{chunk-T2S5O36I.mjs → chunk-C44UWIAD.mjs} +6 -6
  8. package/dist/chunk-C44UWIAD.mjs.map +1 -0
  9. package/dist/{chunk-JVMDEHRQ.mjs → chunk-EDGUFCIR.mjs} +77 -37
  10. package/dist/chunk-EDGUFCIR.mjs.map +1 -0
  11. package/dist/{chunk-XWOUIA6A.mjs → chunk-JBEFAJ2W.mjs} +2 -2
  12. package/dist/chunk-ROVYWEBI.mjs +2115 -0
  13. package/dist/chunk-ROVYWEBI.mjs.map +1 -0
  14. package/dist/index.d.mts +1647 -758
  15. package/dist/index.d.ts +1647 -758
  16. package/dist/index.js +9301 -4857
  17. package/dist/index.js.map +1 -1
  18. package/dist/index.mjs +6222 -2968
  19. package/dist/index.mjs.map +1 -1
  20. package/dist/order-labels.d.mts +3 -1
  21. package/dist/order-labels.d.ts +3 -1
  22. package/dist/{parsing-DRp4dPC0.d.mts → parsing-DPEpAszP.d.mts} +11 -3
  23. package/dist/{parsing-CF_grC29.d.ts → parsing-EcmCsF1y.d.ts} +11 -3
  24. package/dist/parsing.d.mts +5 -3
  25. package/dist/parsing.d.ts +5 -3
  26. package/dist/parsing.js.map +1 -1
  27. package/dist/parsing.mjs +2 -2
  28. package/dist/plan-utils-BAvW3hvl.d.mts +877 -0
  29. package/dist/plan-utils-BMyEiDKv.d.ts +877 -0
  30. package/dist/plan-utils.d.mts +5 -4
  31. package/dist/plan-utils.d.ts +5 -4
  32. package/dist/plan-utils.js +956 -8
  33. package/dist/plan-utils.js.map +1 -1
  34. package/dist/plan-utils.mjs +47 -7
  35. package/dist/testing.d.mts +57 -5
  36. package/dist/testing.d.ts +57 -5
  37. package/dist/testing.js +96 -2
  38. package/dist/testing.js.map +1 -1
  39. package/dist/testing.mjs +94 -2
  40. package/dist/testing.mjs.map +1 -1
  41. package/package.json +2 -1
  42. package/skills/grilling/SKILL.md +6 -16
  43. package/skills/improve-codebase-architecture/SKILL.md +1 -1
  44. package/dist/ApprovalPolicy-BVhGdECT.d.mts +0 -79
  45. package/dist/ApprovalPolicy-BVhGdECT.d.ts +0 -79
  46. package/dist/ITerminalRunner-Bd-vAJnw.d.ts +0 -561
  47. package/dist/ITerminalRunner-ByeoLF57.d.mts +0 -561
  48. package/dist/Task-BxQkPlXO.d.mts +0 -664
  49. package/dist/Task-BxQkPlXO.d.ts +0 -664
  50. package/dist/chunk-GWPIYDQW.mjs +0 -945
  51. package/dist/chunk-GWPIYDQW.mjs.map +0 -1
  52. package/dist/chunk-JVMDEHRQ.mjs.map +0 -1
  53. package/dist/chunk-T2S5O36I.mjs.map +0 -1
  54. package/dist/plan-utils-CkNbqAmS.d.ts +0 -329
  55. package/dist/plan-utils-CtB3_Ovf.d.mts +0 -329
  56. /package/dist/{chunk-XWOUIA6A.mjs.map → chunk-JBEFAJ2W.mjs.map} +0 -0
@@ -0,0 +1,877 @@
1
+ import { aR as StructuredTurnEnd, aT as SubagentOutcome, b9 as UsageRecord, k as ApprovalDecision, aP as StructuredEvent, aG as RunnerId, w as DiscoveredModel, aU as Task, a6 as LegacyPlanState, aw as QueuedMessage, ba as UsageTotals, bg as Verdict, aV as TaskIsolation, b4 as TaskTransport, r as AwaitingReason, ax as QueuedTaskMessage, Q as IsolationHandoff, X as IsolationMergeResult, aC as ResearchStep, l as ApprovalKind, q as ApprovalSource, aD as ResearchStepOutcome, u as ConversationMessage, aA as ResearchLogEntry, ai as PlannerUsage } from './Task-Dyxp67s2.js';
2
+ import { R as RunnerModeInfo } from './ModeResolver-CjpG5Wli.js';
3
+
4
+ /**
5
+ * One entry of a structured task's log (ADR-0018, P1): what a runner did,
6
+ * normalized and serializable, streamed live as `task_log` and appended to
7
+ * the attempt's `.jsonl` file. The live view and the reload fold the same
8
+ * events through `reduceTaskLog`, so the two cannot disagree.
9
+ *
10
+ * Readers skip a type they do not know, which is how later events join
11
+ * without a format version.
12
+ */
13
+ type TaskLogEvent =
14
+ /** A turn began by delivering `message`; `messageId` names it when it had been queued. */
15
+ {
16
+ type: 'turn_start';
17
+ message: string;
18
+ messageId?: string;
19
+ } | {
20
+ type: 'turn_end';
21
+ reason: StructuredTurnEnd;
22
+ } | {
23
+ type: 'text_delta';
24
+ text: string;
25
+ }
26
+ /** A complete run of the agent's reply, authoritative over the deltas streamed for it. */
27
+ | {
28
+ type: 'text';
29
+ text: string;
30
+ } | {
31
+ type: 'thinking_delta';
32
+ text: string;
33
+ subagentId?: string;
34
+ } | {
35
+ type: 'thinking';
36
+ text: string;
37
+ subagentId?: string;
38
+ }
39
+ /** `args` is the call's arguments as JSON, exactly as the runner announced them. */
40
+ | {
41
+ type: 'tool_call';
42
+ id: string;
43
+ name: string;
44
+ args: string;
45
+ subagentId?: string;
46
+ }
47
+ /** `omittedLines` is set when {@link trimToolOutput} cut the middle of `output`. */
48
+ | {
49
+ type: 'tool_result';
50
+ id: string;
51
+ output: string;
52
+ success: boolean;
53
+ omittedLines?: number;
54
+ subagentId?: string;
55
+ } | {
56
+ type: 'subagent_started';
57
+ subagentId: string;
58
+ brief: string;
59
+ model?: string;
60
+ } | {
61
+ type: 'subagent_finished';
62
+ subagentId: string;
63
+ outcome: SubagentOutcome;
64
+ digest: string;
65
+ } | {
66
+ type: 'usage';
67
+ record: UsageRecord;
68
+ } | {
69
+ type: 'message_queued';
70
+ messageId: string;
71
+ text: string;
72
+ } | {
73
+ type: 'message_removed';
74
+ messageId: string;
75
+ }
76
+ /** The agent's own words for a failed turn. */
77
+ | {
78
+ type: 'error';
79
+ message: string;
80
+ }
81
+ /**
82
+ * The runner asked to use a tool its mode does not cover (ADR-0018, A1).
83
+ * `approvalId` is what the answer is given under; `args` is the call's
84
+ * arguments as JSON; `allowForTask` says the runner offered its own
85
+ * session-scoped grant.
86
+ */
87
+ | {
88
+ type: 'approval_requested';
89
+ approvalId: string;
90
+ tool: string;
91
+ args: string;
92
+ allowForTask: boolean;
93
+ toolCallId?: string;
94
+ } | {
95
+ type: 'approval_decided';
96
+ approvalId: string;
97
+ decision: ApprovalDecision['decision'];
98
+ note?: string;
99
+ }
100
+ /** The request went unanswered: the runner withdrew it, or its process ended. */
101
+ | {
102
+ type: 'approval_withdrawn';
103
+ approvalId: string;
104
+ };
105
+ /**
106
+ * Keep a tool result's head and tail. A build log or a whole file read can
107
+ * run to megabytes, and every attempt's file keeps it for good; the ends are
108
+ * where a reader looks — the command's start, and how it finished.
109
+ */
110
+ declare function trimToolOutput(output: string): {
111
+ output: string;
112
+ omittedLines?: number;
113
+ };
114
+ /**
115
+ * The log entry for one structured event, or null for what the log does not
116
+ * keep: background-agent launches, which the subagent's own events already show.
117
+ */
118
+ declare function toTaskLogEvent(event: StructuredEvent): TaskLogEvent | null;
119
+ /**
120
+ * Merge runs of deltas into one event each. Deltas arrive a few characters at
121
+ * a time; merged, a batch is one message on the wire and one line on disk,
122
+ * and the view folds to the same blocks either way.
123
+ */
124
+ declare function coalesceTaskLog(events: readonly TaskLogEvent[]): TaskLogEvent[];
125
+
126
+ /**
127
+ * Pure, no-imports helper so a browser surface can format a conflict's files
128
+ * without pulling `isolationRecord` — and its `path` import — into a webview
129
+ * bundle. Kept out of `isolationRecord.ts` for exactly that reason.
130
+ */
131
+ declare function capConflictFiles(files: string[], max?: number): string;
132
+
133
+ /**
134
+ * The catalog a model/task-mode edit is checked against — the same discovered
135
+ * models and manifest modes the planner was shown in the per-turn catalog
136
+ * block (`PlannerConversation.catalogBlock`), so a refusal here can never name something
137
+ * as invalid that the planner was never told about, or vice versa.
138
+ */
139
+ interface EditCatalog {
140
+ modelsByRunner: Partial<Record<RunnerId, DiscoveredModel[]>>;
141
+ runnerModes: Partial<Record<RunnerId, RunnerModeInfo[]>>;
142
+ /** Raw (unfiltered) allowlist, keyed by runner — the same shape `coerceAssignments` takes. */
143
+ perRunnerAllowlist?: Partial<Record<RunnerId, string[]>>;
144
+ }
145
+
146
+ /**
147
+ * Targeted task edits emitted by the planner conversation (the 'task_ops'
148
+ * ConversationTurn). Task references accept a task id, a "#<order>" ref, or a
149
+ * bare order number — cheap models rarely echo UUIDs correctly.
150
+ */
151
+ type TaskOp = {
152
+ op: 'update';
153
+ taskId: string;
154
+ changes: Partial<Task>;
155
+ } | {
156
+ op: 'add';
157
+ task: Partial<Task>;
158
+ handle?: string;
159
+ } | {
160
+ op: 'remove';
161
+ taskId: string;
162
+ } | {
163
+ op: 'reorder';
164
+ taskIds: string[];
165
+ } | {
166
+ op: 'merge';
167
+ taskIds: string[];
168
+ merged: Partial<Task>;
169
+ handle?: string;
170
+ } | {
171
+ op: 'split';
172
+ taskId: string;
173
+ parts: Partial<Task>[];
174
+ handle?: string;
175
+ } | {
176
+ op: 'rearm';
177
+ taskId: string;
178
+ changes?: Partial<Task>;
179
+ };
180
+ declare function textHasTaskOps(text: string): boolean;
181
+ /** Parse a `{"taskOps":[...]}` reply. Throws PlanParseError when the JSON is unusable. */
182
+ declare function parseTaskOpsJson(text: string): TaskOp[];
183
+ interface ApplyTaskOpsResult {
184
+ ok: boolean;
185
+ tasks: readonly Task[];
186
+ errors: string[];
187
+ /** Human-readable summary of what changed, for the chat transcript. */
188
+ summary: string[];
189
+ }
190
+ /**
191
+ * Pre-flight check for a merge: would collapsing the selected tasks into one
192
+ * (rewiring every dependent of any selected task to the survivor) keep the
193
+ * dependency graph valid? Rejects locked tasks and merges whose rewiring would
194
+ * introduce a cycle. Display order is NOT checked here — neither
195
+ * consecutiveness (a UI concern) nor a dependency the merge pulls out of order,
196
+ * which {@link applyTaskOps} repairs; refusing on order would make this
197
+ * pre-flight stricter than the applier it stands in for.
198
+ */
199
+ declare function canMergeTasks(tasks: readonly Task[], selectedIds: string[]): {
200
+ ok: boolean;
201
+ error?: string;
202
+ };
203
+ /**
204
+ * The shape the dependency helpers below read. Structural rather than `Task`,
205
+ * because the TUI projects tasks into its own `TaskView`: a surface's
206
+ * dependency picker and the API's validation must agree on which dependencies
207
+ * are legal, and a signature only core can satisfy would have forced the TUI
208
+ * to keep a second copy of the rule.
209
+ */
210
+ interface TaskRef {
211
+ id: string;
212
+ order: number;
213
+ title: string;
214
+ dependencies: string[];
215
+ }
216
+ /** The tasks listing `taskId` as a dependency — exactly what removing it detaches. */
217
+ declare function dependentsOf<T extends Pick<TaskRef, 'id' | 'dependencies'>>(tasks: T[], taskId: string): T[];
218
+ /**
219
+ * The tasks that may become dependencies of `taskId`: those displayed before it.
220
+ *
221
+ * Offering only earlier tasks is what keeps a hand-edited graph valid without a
222
+ * cycle check — dependencies then only ever point backwards in display order,
223
+ * the same invariant `applyTaskOps` enforces. Omit `taskId` for a task that does
224
+ * not exist yet: it lands last, so every current task is a candidate.
225
+ */
226
+ declare function dependencyCandidates<T extends Pick<TaskRef, 'id' | 'order'>>(tasks: readonly T[], taskId?: string): T[];
227
+ /** Pre-flight check for a hand-edited dependency list: every id exists and comes earlier. */
228
+ declare function canSetDependencies<T extends TaskRef>(tasks: readonly T[], taskId: string, dependencies: string[]): {
229
+ ok: boolean;
230
+ error?: string;
231
+ };
232
+ /** Pre-flight check for a split: the task exists and is not locked by execution. */
233
+ declare function canSplitTask(tasks: readonly Task[], taskId: string): {
234
+ ok: boolean;
235
+ error?: string;
236
+ };
237
+ /**
238
+ * Apply task ops to a snapshot of the plan, atomically: either every op
239
+ * applies and the result validates (deps resolve, no cycles, running and
240
+ * completed tasks untouched), or nothing is returned and `errors` explains
241
+ * why. The caller commits `tasks` on ok.
242
+ */
243
+ declare function applyTaskOps(currentTasks: readonly Task[], ops: TaskOp[], runners: RunnerId[], catalog?: EditCatalog): ApplyTaskOpsResult;
244
+
245
+ type SerializedTaskStatus = {
246
+ id: string;
247
+ status: string;
248
+ verdict: {
249
+ outcome: 'pass' | 'fail';
250
+ reason: string;
251
+ checks: Verdict['checks'];
252
+ } | null;
253
+ /** Advisory silence timestamp from VerdictEngine — not part of task status semantics. */
254
+ idleSince?: string | null;
255
+ /** Absent unless the plan has an isolation run, so a shared-root plan's updates are unchanged. */
256
+ isolation?: TaskIsolation;
257
+ /** Absent unless the task's plan asked for the structured transport (ADR-0018): what it ran on, or why it fell back. */
258
+ transport?: Pick<TaskTransport, 'kind' | 'fallback'>;
259
+ /** What an `awaiting_user` task waits on, when it was saved (ADR-0018, W1). */
260
+ awaitingReason?: AwaitingReason;
261
+ /** Messages waiting for a structured task's turn to end, oldest first; absent when there are none. */
262
+ queued?: QueuedTaskMessage[];
263
+ /** Set when the task can be continued in its saved runner session (ADR-0018, K1); the id itself stays in the daemon. */
264
+ continuable?: true;
265
+ /**
266
+ * How many of a structured task's runner requests wait for an answer
267
+ * (ADR-0018, A1) — "waiting for approval", which leaves `status` alone.
268
+ * Absent when none do.
269
+ */
270
+ awaitingApproval?: number;
271
+ };
272
+ type SerializedTask = {
273
+ id: string;
274
+ order: number;
275
+ title: string;
276
+ type: string;
277
+ description: string;
278
+ dependencies: string[];
279
+ assignedRunner: RunnerId;
280
+ assignedModel: Task['assignedModel'] | null;
281
+ taskMode: string;
282
+ prompt: string | null;
283
+ subtasks: SerializedTask[];
284
+ userSteps: Task['userSteps'];
285
+ thinkingEffort: Task['thinkingEffort'];
286
+ autonomy: Task['autonomy'];
287
+ sliceType: Task['sliceType'];
288
+ userStoriesCovered: Task['userStoriesCovered'];
289
+ };
290
+ type SerializedPlan = {
291
+ tasks: SerializedTask[];
292
+ runners: RunnerId[];
293
+ generatedAt: string;
294
+ conversationHistory?: LegacyPlanState['conversationHistory'];
295
+ prdMarkdown?: string;
296
+ queuedMessages?: QueuedMessage[];
297
+ };
298
+ /** How a planner turn ended: the reply kind it settled on, a user stop, or a failure. */
299
+ type PlannerTurnOutcome = 'message' | 'plan' | 'task_ops' | 'stopped' | 'error';
300
+ /**
301
+ * Everything a session tells its surfaces, over one broadcast seam.
302
+ *
303
+ * A planner turn (#47) streams between `planner_turn_started` and
304
+ * `planner_turn_ended` with the same `turnId`; every turn-scoped message in
305
+ * between carries it. The stream is provisional and the settled messages are
306
+ * authoritative:
307
+ * - `planner_message` replaces the streamed text of the turn's final segment —
308
+ * a surface drops what it accumulated and shows the message instead.
309
+ * - A reply that is a JSON envelope (plan, taskOps, taskQuery) never arrives
310
+ * as `planner_text_delta`; it streams as `plan_token`, the "building plan"
311
+ * display.
312
+ * - A subagent's own text never appears in the reply; its activity arrives
313
+ * tagged with its `subagentId`.
314
+ */
315
+ type SessionMessage =
316
+ /**
317
+ * The plan, whole. `turnId` names the planner turn whose commit this
318
+ * broadcast carries, so the turn's building plan becomes the marker; it is
319
+ * absent on every other broadcast of the plan.
320
+ */
321
+ {
322
+ type: 'plan_generated';
323
+ plan: SerializedPlan;
324
+ goal: string;
325
+ runners: RunnerId[];
326
+ turnId?: string;
327
+ }
328
+ /**
329
+ * The settled reply of a planner turn, emitted by the session once the turn
330
+ * is classified. Authoritative over any `planner_text_delta` of its turn's
331
+ * final segment. `turnId` is absent for replies sent outside a streamed turn.
332
+ */
333
+ | {
334
+ type: 'planner_message';
335
+ content: string;
336
+ timestamp: string;
337
+ turnId?: string;
338
+ }
339
+ /**
340
+ * A planner turn began. Emitted once per turn by whoever runs the turn,
341
+ * before any other message carrying its `turnId`. `prompt` is the user's
342
+ * message when the turn answers one.
343
+ */
344
+ | {
345
+ type: 'planner_turn_started';
346
+ turnId: string;
347
+ prompt?: string;
348
+ }
349
+ /**
350
+ * A planner turn is over; nothing more carries its `turnId`. Emitted exactly
351
+ * once per `planner_turn_started`, stop and failure included, after the
352
+ * turn's `planner_message` when it has one.
353
+ */
354
+ | {
355
+ type: 'planner_turn_ended';
356
+ turnId: string;
357
+ outcome: PlannerTurnOutcome;
358
+ }
359
+ /**
360
+ * Reply prose as it streams, appended in order within its segment. A segment
361
+ * is one continuous run of model text; text before a tool call is its own
362
+ * segment, and a later segment never rewrites an earlier one. Never carries
363
+ * a JSON envelope or a subagent's text (see the union's invariants).
364
+ */
365
+ | {
366
+ type: 'planner_text_delta';
367
+ turnId: string;
368
+ segmentId: string;
369
+ text: string;
370
+ }
371
+ /**
372
+ * Exposed reasoning as it streams, from the planner or — tagged with
373
+ * `subagentId` — from one of its subagents. Never part of the reply. The one
374
+ * thinking message for every backend: `segmentId` is set only where the
375
+ * backend streams thinking in segments (the API loops; harness planners do
376
+ * not), and `turnId` is absent for thinking outside a turn (one-shot plans).
377
+ */
378
+ | {
379
+ type: 'planner_thinking_delta';
380
+ turnId?: string;
381
+ segmentId?: string;
382
+ subagentId?: string;
383
+ text: string;
384
+ }
385
+ /**
386
+ * Text streamed for an attempt the turn discarded (a corrective retry) is
387
+ * taken back: a surface removes it. With `segmentId`, only that segment;
388
+ * without, all of the turn's text not yet settled by a `planner_message`.
389
+ * A segment that streamed to the plan display (`plan_token`) takes the
390
+ * turn's building plan with it.
391
+ */
392
+ | {
393
+ type: 'planner_text_retracted';
394
+ turnId: string;
395
+ segmentId?: string;
396
+ }
397
+ /**
398
+ * The planner's running usage for the session, subagents included, emitted
399
+ * after a model call reports usage. `totals` already contains every
400
+ * `bySubagent` entry. `contextFill` is the last planner prompt against the
401
+ * model's window, omitted when the window is unknown. Cost appears only as
402
+ * reported by a provider or runner (see `UsageRecord`).
403
+ */
404
+ | {
405
+ type: 'planner_usage';
406
+ turnId?: string;
407
+ totals: UsageTotals;
408
+ bySubagent?: Record<string, UsageTotals>;
409
+ contextFill?: {
410
+ usedTokens: number;
411
+ windowTokens: number;
412
+ };
413
+ }
414
+ /**
415
+ * A subagent began work on `brief`. Emitted by the planner backend that
416
+ * spawned it (ADR-0005 research agents, or a harness planner's own), before
417
+ * any message tagged with its `subagentId`.
418
+ */
419
+ | {
420
+ type: 'subagent_started';
421
+ turnId?: string;
422
+ subagentId: string;
423
+ brief: string;
424
+ model?: string;
425
+ }
426
+ /**
427
+ * A subagent is done; nothing more is tagged with its `subagentId`. Emitted
428
+ * once per `subagent_started`. `digest` is what it handed back to the
429
+ * planner; `usage` is its own share, already counted in `planner_usage`.
430
+ */
431
+ | {
432
+ type: 'subagent_finished';
433
+ turnId?: string;
434
+ subagentId: string;
435
+ outcome: SubagentOutcome;
436
+ digest: string;
437
+ usage?: UsageTotals;
438
+ } | {
439
+ type: 'status_update';
440
+ tasks: SerializedTaskStatus[];
441
+ } | {
442
+ type: 'review_needed';
443
+ tasks: SerializedTask[];
444
+ } | {
445
+ type: 'review_approved';
446
+ } | {
447
+ type: 'checkpoint';
448
+ taskId: string;
449
+ taskTitle: string;
450
+ summary: string;
451
+ } | {
452
+ type: 'execution_complete';
453
+ summary: {
454
+ total: number;
455
+ completed: number;
456
+ failed: number;
457
+ };
458
+ } | {
459
+ type: 'execution_stopped';
460
+ } | {
461
+ type: 'queue_ready';
462
+ } | {
463
+ type: 'task_updated';
464
+ taskId: string;
465
+ changes: Record<string, unknown>;
466
+ } | {
467
+ type: 'task_started';
468
+ taskId: string;
469
+ order: number;
470
+ title: string;
471
+ runner: RunnerId;
472
+ modelId?: string;
473
+ } | {
474
+ type: 'task_output';
475
+ taskId: string;
476
+ text: string;
477
+ }
478
+ /**
479
+ * A structured task's log as it happens (ADR-0018, P1): the next events of
480
+ * the task's attempt `attempt`, in order — the same ones appended to that
481
+ * attempt's file, so a surface folding these and one replaying the file
482
+ * draw the same blocks. Terminal-transport tasks send none.
483
+ */
484
+ | {
485
+ type: 'task_log';
486
+ taskId: string;
487
+ attempt: number;
488
+ events: TaskLogEvent[];
489
+ } | {
490
+ type: 'isolation_blocked';
491
+ reason: 'dirty';
492
+ repos?: string[];
493
+ message: string;
494
+ } | {
495
+ type: 'isolation_handoff';
496
+ repos: IsolationHandoff['repos'];
497
+ landed: IsolationHandoff['landed'];
498
+ } | {
499
+ type: 'isolation_merge';
500
+ result: IsolationMergeResult;
501
+ } | {
502
+ type: 'planner_liveness';
503
+ } | {
504
+ type: 'research_step';
505
+ tool: string;
506
+ toolLabel?: string;
507
+ args: string;
508
+ subagentId?: string;
509
+ toolCallId?: string;
510
+ turnId?: string;
511
+ } | {
512
+ type: 'plan_token';
513
+ token: string;
514
+ turnId?: string;
515
+ segmentId?: string;
516
+ } | {
517
+ type: 'research_step_done';
518
+ step: ResearchStep;
519
+ subagentId?: string;
520
+ turnId?: string;
521
+ } | {
522
+ type: 'approval_request';
523
+ id: string;
524
+ kind: ApprovalKind;
525
+ subject: string;
526
+ scope: string;
527
+ detail?: string;
528
+ turnId?: string;
529
+ } | {
530
+ type: 'approval_settled';
531
+ id: string;
532
+ granted: boolean;
533
+ } | {
534
+ type: 'approval_decided';
535
+ kind: ApprovalKind;
536
+ subject: string;
537
+ scope: string;
538
+ detail?: string;
539
+ granted: boolean;
540
+ source: Exclude<ApprovalSource, 'asked'>;
541
+ };
542
+ /**
543
+ * A line a run wants the user to read — how it isolates, what it shares. Not a
544
+ * {@link SessionMessage}: hosts that show notices as toasts already do, and
545
+ * widening the union would break every exhaustive switch over it. A host with
546
+ * no toast channel (the daemon) hands these to its clients by its own means.
547
+ */
548
+ type SessionNotice = {
549
+ type: 'notice';
550
+ level: 'info' | 'warn' | 'error';
551
+ message: string;
552
+ };
553
+ type SessionBroadcaster = (msg: SessionMessage) => void;
554
+ declare function serializeTask(t: Task): SerializedTask;
555
+ declare function serializeTaskStatus(t: Task, idleSince?: string | null, isolation?: TaskIsolation | null, queued?: readonly QueuedTaskMessage[], awaitingApproval?: number): SerializedTaskStatus;
556
+ declare function serializePlan(plan: LegacyPlanState): SerializedPlan;
557
+ declare function executionSummary(tasks: readonly Task[]): {
558
+ total: number;
559
+ completed: number;
560
+ failed: number;
561
+ };
562
+ declare const CHECKPOINT_TRUNCATE_LENGTH = 120;
563
+ /** Truncate a checkpoint summary to a single line of at most CHECKPOINT_TRUNCATE_LENGTH chars. */
564
+ declare function truncateCheckpointSummary(summary: string): string;
565
+
566
+ /**
567
+ * @param toolLabel The agent's own name for the tool, when a harness planner
568
+ * produced the call (ADR-0009). It replaces the member name in the summary, so
569
+ * the timeline says `Edit` rather than the catch-all `agent_tool` — and says
570
+ * `WebFetch` rather than claiming a shell command ran.
571
+ */
572
+ declare function summarizeToolCall(tool: string, argsJson: string, toolLabel?: string): string;
573
+ /**
574
+ * Classify a tool outcome from its result text and success flag, so a surface
575
+ * can render a refused `rm` or a denied `npm test` distinctly from a
576
+ * successful run without re-deriving the refusal signatures per surface. The
577
+ * refusal/denial strings come from `commandPolicy.ts`, `BaseFileSystem.ts`,
578
+ * and the research-subagent wrapper — keeping the matching here means the
579
+ * signatures stay in one place alongside the human summary.
580
+ */
581
+ declare function classifyOutcome(success: boolean, output: string): ResearchStepOutcome;
582
+
583
+ /**
584
+ * What a surface draws for one planner conversation (#51): an ordered list of
585
+ * display blocks, built once in core from the `SessionMessage` stream and drawn
586
+ * per surface. Every block carries an `id` that stays the same for as long as
587
+ * the block exists, so a surface can key its own UI state on it — whether a
588
+ * block is expanded is that UI state, and deliberately not part of a block.
589
+ */
590
+ type DisplayBlock = MessageBlock | ThinkingDisplayBlock | ToolBlock | SubagentBlock | ApprovalBlock | PlanBlock | UsageBlock;
591
+ /** `agent` is a task runner speaking in a structured task's log (ADR-0018); the planner is `planner`. */
592
+ type MessageRole = 'user' | 'planner' | 'agent' | 'system' | 'error';
593
+ interface MessageBlock {
594
+ type: 'message';
595
+ id: string;
596
+ role: MessageRole;
597
+ text: string;
598
+ /** Deltas are still arriving. */
599
+ streaming: boolean;
600
+ turnId?: string;
601
+ /**
602
+ * Present while the text is the streamed segment of a reply rather than a
603
+ * settled message: provisional, replaced by the turn's `planner_message` when
604
+ * it is the final segment, and never saved to the transcript.
605
+ */
606
+ segmentId?: string;
607
+ }
608
+ interface ThinkingDisplayBlock {
609
+ type: 'thinking';
610
+ id: string;
611
+ text: string;
612
+ streaming: boolean;
613
+ turnId?: string;
614
+ segmentId?: string;
615
+ /** Set when a subagent thought it; the block then sits among that subagent's children. */
616
+ subagentId?: string;
617
+ }
618
+ /** The two halves of a Claude Code-style command row: `Name(keyArg)`. */
619
+ interface ToolHeadline {
620
+ name: string;
621
+ keyArg: string;
622
+ }
623
+ type ToolStatus = 'pending' | 'ok' | 'error' | 'denied' | 'interrupted';
624
+ interface ToolBlock {
625
+ type: 'tool';
626
+ id: string;
627
+ toolCallId?: string;
628
+ tool: string;
629
+ toolLabel?: string;
630
+ headline: ToolHeadline;
631
+ /** The arguments exactly as announced (JSON), for the expanded view. */
632
+ args: string;
633
+ status: ToolStatus;
634
+ /** How the call ended, finer than `status`: a refused command and a denied path both read `denied`. */
635
+ outcome?: ResearchStepOutcome;
636
+ output: string;
637
+ /** Every line of `output`, counted as {@link outputPreview} counts them. */
638
+ outputLineCount: number;
639
+ turnId?: string;
640
+ /**
641
+ * The subagent this call starts. The call becomes that subagent's block once
642
+ * the subagent announces itself, so the two never show as separate rows.
643
+ */
644
+ spawns?: string;
645
+ }
646
+ type SubagentStatus = 'running' | SubagentOutcome;
647
+ type SubagentChild = ToolBlock | ThinkingDisplayBlock | MessageBlock;
648
+ interface SubagentBlock {
649
+ type: 'subagent';
650
+ id: string;
651
+ subagentId: string;
652
+ /** The planner's call that started it, when one was announced. */
653
+ toolCallId?: string;
654
+ brief: string;
655
+ model?: string;
656
+ status: SubagentStatus;
657
+ children: readonly SubagentChild[];
658
+ /** What it handed back to the planner. */
659
+ digest: string;
660
+ /** Its own share, already counted in the usage line. */
661
+ usage?: UsageTotals;
662
+ turnId?: string;
663
+ }
664
+ /** `withdrawn`: a runner's request that went unanswered — the runner cancelled it, or its process ended. */
665
+ type ApprovalStatus = 'pending' | 'granted' | 'denied' | 'withdrawn';
666
+ interface ApprovalBlock {
667
+ type: 'approval';
668
+ id: string;
669
+ /** The request's id, which a surface answers through. Absent for a decision nobody was asked about. */
670
+ approvalId?: string;
671
+ kind: ApprovalKind;
672
+ subject: string;
673
+ scope: string;
674
+ detail?: string;
675
+ status: ApprovalStatus;
676
+ /** Absent while pending. */
677
+ decidedBy?: ApprovalSource;
678
+ turnId?: string;
679
+ /** A runner's request (`runner_tool`) that can also be allowed for the rest of its task. */
680
+ allowForTask?: boolean;
681
+ /** Granted for the rest of the task, not this call alone. */
682
+ forTask?: boolean;
683
+ /** What a denial told the agent. */
684
+ note?: string;
685
+ /** The runner's tool call the request is about. */
686
+ toolCallId?: string;
687
+ }
688
+ type PlanMarkerStatus = 'building' | 'generated' | 'updated';
689
+ interface PlanBlock {
690
+ type: 'plan';
691
+ id: string;
692
+ status: PlanMarkerStatus;
693
+ /** The plan envelope streamed so far — `parsePartialPlan` reads rows from it. Empty once settled. */
694
+ text: string;
695
+ taskCount?: number;
696
+ turnId?: string;
697
+ /** While building: the segment whose envelope is streaming, which a retraction of that segment takes back. */
698
+ segmentId?: string;
699
+ }
700
+ /** The token line. There is at most one, and it is always the last block. */
701
+ interface UsageBlock {
702
+ type: 'usage';
703
+ id: string;
704
+ totals: UsageTotals;
705
+ contextFill?: {
706
+ usedTokens: number;
707
+ windowTokens: number;
708
+ };
709
+ bySubagent?: Record<string, UsageTotals>;
710
+ }
711
+
712
+ /** What every view over display blocks holds; each view adds its own state beside it. */
713
+ interface BlockList {
714
+ readonly blocks: readonly DisplayBlock[];
715
+ readonly nextId: number;
716
+ }
717
+
718
+ /**
719
+ * A line a surface adds to the conversation itself rather than receiving from
720
+ * the session: the user's prompt as it is sent, a notice, an error.
721
+ */
722
+ interface LocalEntry {
723
+ type: 'local_entry';
724
+ role: 'user' | 'system' | 'error';
725
+ text: string;
726
+ }
727
+ type ConversationInput = SessionMessage | LocalEntry;
728
+ interface ConversationView extends BlockList {
729
+ /**
730
+ * The newest transcript entry the view accounts for. Plan markers and system
731
+ * notes reach a surface only inside the transcript a `plan_generated`
732
+ * carries, so entries after this one are what is new in it.
733
+ */
734
+ readonly transcriptAt?: string;
735
+ }
736
+ declare const EMPTY_CONVERSATION: ConversationView;
737
+ /**
738
+ * Fold one input into the view. Pure and incremental: blocks the input does
739
+ * not touch keep their identity, and an input that changes nothing returns
740
+ * `view` itself — surfaces memoize their drawing on that, and text deltas
741
+ * arrive quickly.
742
+ */
743
+ declare function reduceConversation(view: ConversationView, input: ConversationInput): ConversationView;
744
+
745
+ /**
746
+ * The view a saved session reopens with: what its transcript and research log
747
+ * kept, in the order it happened — messages, notices and the compaction
748
+ * summary, plan markers, tool calls with each subagent's calls nested under
749
+ * it, and the token line. Reasoning and streamed text were never saved, so a
750
+ * reload has none.
751
+ *
752
+ * The research log interleaves with the transcript by time. Entries older than
753
+ * a compaction's first kept message went with the turns it condensed.
754
+ */
755
+ declare function fromTranscript(conversationHistory: readonly ConversationMessage[] | undefined, researchLog: readonly ResearchLogEntry[] | undefined, plannerUsage?: PlannerUsage): ConversationView;
756
+
757
+ /**
758
+ * What a surface draws for one attempt of a structured task (ADR-0018, O1b):
759
+ * the same display blocks as the planner conversation, built from the task's
760
+ * {@link TaskLogEvent}s. No planner turn ids — a task's turns are its own,
761
+ * one at a time.
762
+ */
763
+ interface TaskLogView extends BlockList {
764
+ /** Messages waiting for the running turn to end, oldest first. */
765
+ readonly queued: readonly QueuedTaskMessage[];
766
+ /** A turn is running. */
767
+ readonly working: boolean;
768
+ /** How the last turn ended; absent before the first one does. */
769
+ readonly lastTurnEnd?: StructuredTurnEnd;
770
+ /** What the runner reported over the attempt, subagents included. */
771
+ readonly usage?: PlannerUsage;
772
+ /**
773
+ * The block each run of deltas streams into, keyed by stream, so the run's
774
+ * authoritative copy replaces it instead of repeating it below.
775
+ */
776
+ readonly streams: Readonly<Record<string, string>>;
777
+ }
778
+ declare const EMPTY_TASK_LOG: TaskLogView;
779
+ /** A runner's tool request, read the way its call's row reads: `Bash(npm test)`. */
780
+ declare function runnerToolSubject(tool: string, args: string): string;
781
+ /**
782
+ * Fold one task-log event into the view. Pure and incremental, like
783
+ * `reduceConversation`: an event that changes nothing returns `view` itself,
784
+ * and an event of a type this build does not know is skipped — a log written
785
+ * by a newer Ordewell still reads.
786
+ */
787
+ declare function reduceTaskLog(view: TaskLogView, event: TaskLogEvent): TaskLogView;
788
+ /** A whole attempt's events, folded from the start — what a reload shows. */
789
+ declare function replayTaskLog(events: readonly TaskLogEvent[], from?: TaskLogView): TaskLogView;
790
+
791
+ /**
792
+ * The one-line head of a command row, shared by every surface: the tool's name
793
+ * and the argument that says what the call is about.
794
+ *
795
+ * @param args The call's arguments as announced (JSON). Anything that is not a
796
+ * JSON object is shown as it came, on one line.
797
+ * @param toolLabel A harness planner's own name for the tool (ADR-0009).
798
+ */
799
+ declare function toolHeadline(tool: string, args: string, toolLabel?: string): ToolHeadline;
800
+ interface OutputPreview {
801
+ lines: string[];
802
+ hiddenLineCount: number;
803
+ }
804
+ /** The lines of a tool's output as a reader sees them — what {@link outputPreview} shows and counts. */
805
+ declare function outputLines(output: string): string[];
806
+ /** The head of a tool's output for a collapsed row, and how many lines it leaves out. */
807
+ declare function outputPreview(output: string, maxLines: number): OutputPreview;
808
+
809
+ /**
810
+ * Prompts the user sent while a planner turn was in flight, waiting to be the
811
+ * next turn's input. The hold is a plain immutable list, oldest first, so a
812
+ * pure reducer can keep it in state and a host can keep it in a field — and
813
+ * either can draw it as is.
814
+ */
815
+ type PromptHold = readonly string[];
816
+ declare const EMPTY_HOLD: PromptHold;
817
+ /** One prompt taken out of the hold, and what is left behind. */
818
+ interface TakenPrompt {
819
+ text: string;
820
+ rest: PromptHold;
821
+ }
822
+ declare function holdPrompt(hold: PromptHold, text: string): PromptHold;
823
+ /** The prompt a settled turn sends next: the oldest, so they go in the order typed. */
824
+ declare function drainNext(hold: PromptHold): TakenPrompt | undefined;
825
+ /**
826
+ * Takes back the newest prompt — the one the user most likely just regretted —
827
+ * while the older ones stay queued behind the turn.
828
+ */
829
+ declare function unsendLatest(hold: PromptHold): TakenPrompt | undefined;
830
+ /**
831
+ * A stopped turn takes its queue with it: the prompts were written against a
832
+ * turn that no longer exists, so they come back as one draft to edit and
833
+ * resend rather than firing off after the stop.
834
+ */
835
+ declare function unsendAll(hold: PromptHold): TakenPrompt | undefined;
836
+ /** Where an unsent prompt lands in the drafting input: above what is being typed, never replacing it. */
837
+ declare function aheadOfDraft(text: string, draft: string): string;
838
+
839
+ /**
840
+ * The planner turn a surface has open, and the one its user stopped. Kept
841
+ * beside the view rather than in it: the view is what a turn drew, this is
842
+ * whether the surface still wants to hear from it.
843
+ */
844
+ interface TurnGate {
845
+ readonly open: string | null;
846
+ readonly stopped: string | null;
847
+ }
848
+ declare const NO_TURN: TurnGate;
849
+ interface GatedConversation {
850
+ view: ConversationView;
851
+ gate: TurnGate;
852
+ }
853
+ /**
854
+ * One input into the view, the stop rule applied: a turn the user stopped is
855
+ * over on screen, and whatever it streams until the backend notices is
856
+ * dropped. An input that changes nothing hands back the same view and gate.
857
+ */
858
+ declare function followTurn(view: ConversationView, gate: TurnGate, input: ConversationInput): GatedConversation;
859
+ /**
860
+ * The user stopped the planner. The turn ends on screen now rather than when
861
+ * the backend notices the abort, so the surface is free at once and the
862
+ * turn's late output never lands. Nothing changes when no turn is open.
863
+ */
864
+ declare function stopTurn(view: ConversationView, gate: TurnGate): GatedConversation;
865
+
866
+ /**
867
+ * Whether the conversation holds anything the collapsed view hides — thinking,
868
+ * a command row's arguments and output, a subagent's children and digest. The
869
+ * detail toggle is the only expansion control (ADR-0017, X1), so a surface
870
+ * offers it only when it would do something.
871
+ */
872
+ declare function hasHiddenDetail(blocks: readonly DisplayBlock[]): boolean;
873
+
874
+ /** The conversation line for a task starting, worded the same on every surface. */
875
+ declare function taskStartedNotice(title: string, runner?: string): string;
876
+
877
+ export { hasHiddenDetail as $, type ApplyTaskOpsResult as A, aheadOfDraft as B, CHECKPOINT_TRUNCATE_LENGTH as C, type DisplayBlock as D, EMPTY_CONVERSATION as E, applyTaskOps as F, type GatedConversation as G, canMergeTasks as H, canSetDependencies as I, canSplitTask as J, capConflictFiles as K, type LocalEntry as L, type MessageBlock as M, NO_TURN as N, type OutputPreview as O, type PlanBlock as P, classifyOutcome as Q, coalesceTaskLog as R, type SerializedPlan as S, type TakenPrompt as T, type UsageBlock as U, dependencyCandidates as V, dependentsOf as W, drainNext as X, executionSummary as Y, followTurn as Z, fromTranscript as _, type ApprovalBlock as a, holdPrompt as a0, outputLines as a1, outputPreview as a2, parseTaskOpsJson as a3, reduceConversation as a4, reduceTaskLog as a5, replayTaskLog as a6, runnerToolSubject as a7, serializePlan as a8, serializeTask as a9, serializeTaskStatus as aa, stopTurn as ab, summarizeToolCall as ac, taskStartedNotice as ad, textHasTaskOps as ae, toTaskLogEvent as af, toolHeadline as ag, trimToolOutput as ah, truncateCheckpointSummary as ai, unsendAll as aj, unsendLatest as ak, type ApprovalStatus as b, type ConversationInput as c, type ConversationView as d, EMPTY_HOLD as e, EMPTY_TASK_LOG as f, type MessageRole as g, type PlanMarkerStatus as h, type PromptHold as i, type SerializedTask as j, type SerializedTaskStatus as k, type SessionBroadcaster as l, type SessionMessage as m, type SessionNotice as n, type SubagentBlock as o, type SubagentChild as p, type SubagentStatus as q, type TaskLogEvent as r, type TaskLogView as s, type TaskOp as t, type TaskRef as u, type ThinkingDisplayBlock as v, type ToolBlock as w, type ToolHeadline as x, type ToolStatus as y, type TurnGate as z };