@ordewell/core 0.10.4 → 0.10.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 (49) hide show
  1. package/dist/{IRunner-D_UkkMbJ.d.ts → IFileSystem-C4_mpfze.d.ts} +159 -15
  2. package/dist/{IRunner-NtTHQgLR.d.mts → IFileSystem-DUgeWWQN.d.mts} +159 -15
  3. package/dist/{ModeResolver-wnTFsDnF.d.mts → ModeResolver-4qNjxcDs.d.mts} +1 -1
  4. package/dist/{ModeResolver-Dy3Ef6p-.d.ts → ModeResolver-DGK2rWHE.d.ts} +1 -1
  5. package/dist/{Task-DZs9eKgg.d.mts → Task-C0o4i3Nn.d.mts} +114 -13
  6. package/dist/{Task-DZs9eKgg.d.ts → Task-C0o4i3Nn.d.ts} +114 -13
  7. package/dist/{chunk-FH6M5QZG.mjs → chunk-DMG4ISUG.mjs} +1008 -49
  8. package/dist/chunk-DMG4ISUG.mjs.map +1 -0
  9. package/dist/{chunk-SM6BV6XS.mjs → chunk-EEE2GBLG.mjs} +116 -27
  10. package/dist/chunk-EEE2GBLG.mjs.map +1 -0
  11. package/dist/chunk-H7QX32BH.mjs +647 -0
  12. package/dist/chunk-H7QX32BH.mjs.map +1 -0
  13. package/dist/{chunk-645FALZX.mjs → chunk-LTHKFBKM.mjs} +4 -4
  14. package/dist/chunk-LTHKFBKM.mjs.map +1 -0
  15. package/dist/{chunk-OYUSADFM.mjs → chunk-NJGID6BG.mjs} +3 -1
  16. package/dist/chunk-NJGID6BG.mjs.map +1 -0
  17. package/dist/index.d.mts +498 -1689
  18. package/dist/index.d.ts +498 -1689
  19. package/dist/index.js +4108 -2082
  20. package/dist/index.js.map +1 -1
  21. package/dist/index.mjs +3380 -1639
  22. package/dist/index.mjs.map +1 -1
  23. package/dist/parsing.d.mts +2 -2
  24. package/dist/parsing.d.ts +2 -2
  25. package/dist/parsing.js +231 -75
  26. package/dist/parsing.js.map +1 -1
  27. package/dist/parsing.mjs +3 -3
  28. package/dist/plan-utils.d.mts +20 -4
  29. package/dist/plan-utils.d.ts +20 -4
  30. package/dist/plan-utils.js +335 -88
  31. package/dist/plan-utils.js.map +1 -1
  32. package/dist/plan-utils.mjs +43 -19
  33. package/dist/{plan-utils-CtKceSsQ.d.mts → runSettingsText-BgOmLxdw.d.mts} +2242 -224
  34. package/dist/{plan-utils-POIz5d8z.d.ts → runSettingsText-BgXvajj2.d.ts} +2242 -224
  35. package/dist/testing.d.mts +5 -3
  36. package/dist/testing.d.ts +5 -3
  37. package/dist/testing.js +7 -0
  38. package/dist/testing.js.map +1 -1
  39. package/dist/testing.mjs +7 -2
  40. package/dist/testing.mjs.map +1 -1
  41. package/package.json +1 -1
  42. package/dist/IFileSystem-_effm8-b.d.ts +0 -78
  43. package/dist/IFileSystem-vyqMdL-x.d.mts +0 -78
  44. package/dist/chunk-645FALZX.mjs.map +0 -1
  45. package/dist/chunk-A57ITQE7.mjs +0 -1378
  46. package/dist/chunk-A57ITQE7.mjs.map +0 -1
  47. package/dist/chunk-FH6M5QZG.mjs.map +0 -1
  48. package/dist/chunk-OYUSADFM.mjs.map +0 -1
  49. package/dist/chunk-SM6BV6XS.mjs.map +0 -1
@@ -155,8 +155,10 @@ interface IsolationRepo {
155
155
  root: string;
156
156
  /** The commit checked out at run start. Switching branches mid-run does not retarget it. */
157
157
  baseRef: string;
158
- /** Branch name checked out at run start; absent on a detached HEAD. */
158
+ /** Branch name checked out at run start; absent on a detached HEAD, and on a record saved before this was noted. */
159
159
  baseBranch?: string;
160
+ /** Set when the run started on a detached HEAD, so that is told from a record that never noted its branch. */
161
+ startedDetached?: true;
160
162
  integrationBranch: string;
161
163
  }
162
164
  /**
@@ -237,6 +239,10 @@ interface IsolationHandoffRepo {
237
239
  path: string;
238
240
  integrationBranch: string;
239
241
  baseRef: string;
242
+ /** The branch the run started on in this repo; absent when it started on a detached HEAD or the record never noted one. */
243
+ baseBranch?: string;
244
+ /** Set when the run started on a detached HEAD. */
245
+ startedDetached?: true;
240
246
  /** Tasks whose work landed in this repo, in plan order. */
241
247
  landed: IsolationLandedTask[];
242
248
  }
@@ -259,27 +265,36 @@ interface IsolationView {
259
265
  /**
260
266
  * Why "Merge all" would not touch a repo. `partial-landing`: a task's landing
261
267
  * was interrupted and could not be rolled back there, so its integration
262
- * branch holds part of a task.
268
+ * branch holds part of a task. `wrong-branch`: the repo is not on the branch
269
+ * the run started on, and the merge would land on some other one.
263
270
  */
264
- type IsolationMergeBlockReason = 'merge-in-progress' | 'conflict' | 'uncommitted-changes' | 'partial-landing' | 'git-error';
271
+ type IsolationMergeBlockReason = 'merge-in-progress' | 'conflict' | 'uncommitted-changes' | 'partial-landing' | 'wrong-branch' | 'git-error';
265
272
  interface IsolationMergeBlock {
266
273
  repo: string;
267
274
  reason: IsolationMergeBlockReason;
268
275
  /** The files that would conflict, or the user's uncommitted ones the merge also changes; empty for the other reasons. */
269
276
  files: string[];
277
+ /** `wrong-branch` only: the branch the run started on. */
278
+ expected?: string;
279
+ /** `wrong-branch` only: the branch checked out now; absent on a detached HEAD. */
280
+ actual?: string;
281
+ /** `wrong-branch` only: the repo is in the middle of a rebase, which is what detached its HEAD. */
282
+ rebasing?: true;
270
283
  }
271
284
  /**
272
285
  * How "Merge all" went.
273
286
  * - `merged`: every repo with work on its integration branch took it.
274
- * - `blocked`: the preflight found repos that could not, so nothing was
287
+ * - `blocked`: a repo was on another branch than the run started on, or the
288
+ * preflight found repos that could not take their merge, so nothing was
275
289
  * touched anywhere; `blocked` says which and why.
276
290
  * - `conflict` / `failed`: a merge stopped in `repo` — on git older than 2.38,
277
291
  * which cannot preflight, or for a reason no preflight could foresee. That
278
292
  * merge was aborted, leaving `repo` as it was; `landed` names the repos
279
293
  * merged before it, which stay merged, and is absent when there are none.
280
294
  *
281
- * A group of one is blocked only by a partial landing; otherwise its one merge
282
- * lands or is aborted whole, so it reports as it always has.
295
+ * A group of one is blocked only by a partial landing or by being on the wrong
296
+ * branch; otherwise its one merge lands or is aborted whole, so it reports as
297
+ * it always has.
283
298
  */
284
299
  type IsolationMergeResult = {
285
300
  outcome: 'merged';
@@ -561,7 +576,11 @@ interface UsageRecord {
561
576
  amount: number;
562
577
  currency: string;
563
578
  };
564
- /** The model's context window, when the runner itself reports it. */
579
+ /**
580
+ * The model's context window: as the runner or provider reported it, or,
581
+ * when it reported none, from that runner's or provider's own model listing
582
+ * (`ContextWindowFill`). Never from a table kept in Ordewell.
583
+ */
565
584
  contextWindow?: number;
566
585
  /** Set when a subagent made the call; its usage still counts toward the total. */
567
586
  subagentId?: string;
@@ -638,16 +657,41 @@ interface ModelUsage {
638
657
  totals: UsageTotals;
639
658
  }
640
659
  declare function addModelUsage(models: readonly ModelUsage[], record: UsageRecord): ModelUsage[];
660
+ /**
661
+ * What Ordewell has counted of a runner's own session that reports its cost
662
+ * as a running total: that total and each model's share, in USD, as of its
663
+ * last report. A resume of that session counts its first report's growth
664
+ * over this; with no count kept for it, that report only sets the baseline.
665
+ */
666
+ interface RunnerSessionCost {
667
+ sessionId: string;
668
+ usd: number;
669
+ modelUsd: Record<string, number>;
670
+ }
641
671
  interface AttemptUsage extends PlannerUsage {
642
672
  attempt: number;
643
673
  runner: string;
674
+ /** The runner session this attempt ran in, as its runner reported it: what a later Continue of it resumes. */
675
+ sessionId?: string;
644
676
  startedAt: string;
645
677
  endedAt?: string;
646
678
  wallTimeMs: number;
679
+ /** What was counted of its runner session's running cost as it ended: a continue of that session counts on from it. */
680
+ runnerSessionCost?: RunnerSessionCost;
647
681
  }
648
682
  declare function startAttemptUsage(attempt: number, runner: string, startedAt: string): AttemptUsage;
649
683
  declare function addAttemptUsage(usage: AttemptUsage, record: UsageRecord, now: string): AttemptUsage;
650
- declare function endAttemptUsage(usage: AttemptUsage, now: string): AttemptUsage;
684
+ declare function endAttemptUsage(usage: AttemptUsage, now: string, runnerSessionCost?: RunnerSessionCost, sessionId?: string): AttemptUsage;
685
+ /** The count a continue of `sessionId` starts from: the one its latest attempt in that session ended with. */
686
+ declare function countedSessionCost(attempts: readonly AttemptUsage[] | undefined, sessionId: string): RunnerSessionCost | undefined;
687
+ /**
688
+ * The model a continue's session last ran on and the window it was measured
689
+ * against: the latest earlier attempt of that same runner session that
690
+ * reported one. An attempt that measured nothing is skipped — a continuation
691
+ * does not undo what its session was last measured against — and a window is
692
+ * never borrowed from another session: a fresh attempt starts one.
693
+ */
694
+ declare function resumedSessionWindow(attempts: readonly AttemptUsage[] | undefined, runner: string, attempt: number, sessionId: string): Pick<PlannerUsage, 'source' | 'model' | 'contextWindow'> | undefined;
651
695
  interface PlanUsage {
652
696
  totals: UsageTotals;
653
697
  byModel: ModelUsage[];
@@ -660,6 +704,21 @@ interface UsageTask {
660
704
  subtasks?: readonly UsageTask[];
661
705
  }
662
706
  declare function planUsage(tasks: readonly UsageTask[]): PlanUsage;
707
+ /**
708
+ * What one task spent across every attempt and every model it ran on, so a
709
+ * stop, a model change and a continue never makes the earlier spend vanish. The
710
+ * context meter is the exception: it reads the latest attempt, because only the
711
+ * current model's window says how full the next prompt is.
712
+ */
713
+ interface TaskUsageSummary {
714
+ totals: UsageTotals;
715
+ attempts: number;
716
+ contextFill?: {
717
+ usedTokens: number;
718
+ windowTokens: number;
719
+ };
720
+ }
721
+ declare function taskUsageSummary(task: Pick<UsageTask, 'attemptUsage'>): TaskUsageSummary;
663
722
 
664
723
  /**
665
724
  * How far a plan's supervisor may act in its wake-up turns (ADR-0029): a plan
@@ -685,7 +744,7 @@ type ExecutionActor = {
685
744
  | {
686
745
  kind: 'autorun';
687
746
  };
688
- type ExecutionCommandName = 'run_plan' | 'run_task' | 'stop_task' | 'stop_run' | 'retry_task' | 'message_task' | 'answer_approval' | 'merge_all' | 'skip_task';
747
+ type ExecutionCommandName = 'run_plan' | 'run_task' | 'stop_task' | 'stop_run' | 'retry_task' | 'message_task' | 'answer_approval' | 'merge_all' | 'skip_task' | 'force_start' | 'mark_complete' | 'mark_not_done' | 'interrupt_task' | 'force_send_queued' | 'remove_queued' | 'cancel_resume' | 'answer_checkpoint' | 'approve_review';
689
748
  /**
690
749
  * One call at the command seam as the timeline keeps it: what was asked, by
691
750
  * whom, about which task, and how it ended — done, refused by the seam, or
@@ -933,9 +992,11 @@ type TaskType = 'ai' | 'user';
933
992
  /**
934
993
  * `skipped` is terminal and verdict-less: the task will not be waited for, and
935
994
  * nothing it did lands. Its dependents go ahead without it once the work it
936
- * waited on is done.
995
+ * waited on is done. There is no stored `blocked`: a task is blocked when a
996
+ * failed dependency says so (ADR-0034), and a file that kept the old status
997
+ * loads as pending.
937
998
  */
938
- type TaskStatus = 'pending' | 'approved' | 'in_progress' | 'completed' | 'failed' | 'blocked' | 'awaiting_user' | 'skipped';
999
+ type TaskStatus = 'pending' | 'approved' | 'in_progress' | 'completed' | 'failed' | 'awaiting_user' | 'skipped';
939
1000
  type TaskMode = string;
940
1001
  /**
941
1002
  * Why an `awaiting_user` task waits (ADR-0018, W1): a structured turn that
@@ -993,6 +1054,13 @@ interface Task {
993
1054
  userStoriesCovered?: string[];
994
1055
  /** The runner's saved session for a later continue; cleared when a fresh attempt starts. */
995
1056
  runnerSessionId?: string;
1057
+ /**
1058
+ * The runner that session belongs to: a session cannot cross runners, so
1059
+ * Continue is offered only while the task is still assigned to it. Absent
1060
+ * on a plan saved before it was recorded; the last attempt's runner stands
1061
+ * in (see `sessionOwner`).
1062
+ */
1063
+ runnerSessionOwner?: RunnerId;
996
1064
  /** Set only while `status` is `awaiting_user`, and not always then — a pause saved by an older build has none. */
997
1065
  awaitingReason?: AwaitingReason;
998
1066
  /**
@@ -1177,10 +1245,13 @@ interface ConversationMessage {
1177
1245
  * (ADR-0029), its record in `execution`. 'wake_up' is the digest a wake-up
1178
1246
  * gave the supervisor (role 'user': the model was told it), and
1179
1247
  * 'supervisor' what the supervisor said in a wake-up turn (ADR-0029).
1248
+ * 'error' is a planner turn that ended on the planner's usage limit, drawn
1249
+ * as a failure and never replayed to the planner: it is not the planner's
1250
+ * answer, and its inputs are sent again (see {@link PlannerResendState}).
1180
1251
  * Absent for ordinary chat turns, so sessions saved before markers existed
1181
1252
  * degrade gracefully.
1182
1253
  */
1183
- kind?: 'plan_generated' | 'system' | 'compaction' | 'skill_load' | 'execution' | 'wake_up' | 'supervisor';
1254
+ kind?: 'plan_generated' | 'system' | 'compaction' | 'skill_load' | 'execution' | 'wake_up' | 'supervisor' | 'error';
1184
1255
  actor?: 'Ordewell setting';
1185
1256
  /** Present exactly when `kind` is 'skill_load'. */
1186
1257
  skill?: SkillLoad;
@@ -1188,6 +1259,23 @@ interface ConversationMessage {
1188
1259
  execution?: ExecutionRecord;
1189
1260
  /** A user's message that was force sent, stopping the turn before it (ADR-0023). */
1190
1261
  forced?: true;
1262
+ /**
1263
+ * What a reply showed, run by run, where each began (ADR-0017 A1). Beside
1264
+ * `content`, which stays the reply as the planner is told it. Absent on
1265
+ * entries saved before runs were kept, which reload as one message.
1266
+ */
1267
+ runs?: ReplyRun[];
1268
+ }
1269
+ /**
1270
+ * One run of a planner reply's text: the segment it streamed under, its
1271
+ * settled text, and when it began. A run that never streamed (a message the
1272
+ * conversation wrote in the planner's place) has a segment no stream used.
1273
+ */
1274
+ interface ReplyRun {
1275
+ segmentId: string;
1276
+ text: string;
1277
+ /** ISO timestamp. */
1278
+ startedAt: string;
1191
1279
  }
1192
1280
  /**
1193
1281
  * A skill's SKILL.md as it was when loaded into a planner conversation. A
@@ -1268,6 +1356,17 @@ interface SupervisionSnapshot {
1268
1356
  /** The events inside their debounce window and the wake-up rate's timestamps. */
1269
1357
  wake?: SupervisorSnapshot;
1270
1358
  }
1359
+ /**
1360
+ * What waits on the planner's usage limit. With `at`, the inputs no turn
1361
+ * answered are sent again then, on their own; without it — the reset could
1362
+ * not be read, the resend hit the limit again, or it was cancelled — they go
1363
+ * with the next input: the user's message, or a wake-up.
1364
+ */
1365
+ interface PlannerResendState {
1366
+ /** The runner whose account hit the limit; a planner on another one is not held by it. */
1367
+ runner?: RunnerId;
1368
+ at?: string;
1369
+ }
1271
1370
  interface LegacyPlanState {
1272
1371
  runSettings?: RunSettings;
1273
1372
  /** What supervision remembers across a daemon restart (ADR-0029); absent on plans saved before it existed. */
@@ -1295,6 +1394,8 @@ interface LegacyPlanState {
1295
1394
  isolation?: PlanIsolation;
1296
1395
  /** Kept so a reopened session shows the same token line (#49). */
1297
1396
  plannerUsage?: PlannerUsage;
1397
+ /** The planner hit its usage limit and the inputs its turn took wait to be sent again; absent otherwise. */
1398
+ plannerResend?: PlannerResendState;
1298
1399
  /**
1299
1400
  * The tasks the user approved to run: every task when they executed the
1300
1401
  * plan, and each one they started or retried themselves since. A command
@@ -1385,4 +1486,4 @@ type ApprovalRecord = Pick<LegacyPlanState, 'approved' | 'approvedTasks'>;
1385
1486
  */
1386
1487
  declare function waitsForApproval(task: Pick<Task, 'id' | 'type' | 'status'>, record: ApprovalRecord): boolean;
1387
1488
 
1388
- export { type ResearchStepOutcome as $, type ApprovalRecord as A, BUILTIN_SKILL_NAMES as B, type ConversationMessage as C, DEFAULT_RUNNERS as D, type ExecutionActor as E, type IsolationTaskStatus as F, type GuardTarget as G, type IsolationView as H, type IWorktreeIsolation as I, type PlanIsolation as J, type PlanState as K, type LegacyPlanState as L, type ModelUsage as M, type PlanStatus as N, type PlanUsage as O, type PendingPlanTurn as P, type PlannerUsage as Q, type PrepareIntent as R, type PreparedTask as S, type PreservedWork as T, type PreviousWork as U, type RefusedRemoval as V, type RepairEvidence as W, type RepoGroupLayout as X, type ResearchLogEntry as Y, type ResearchProgress as Z, type ResearchStep as _, type AttemptUsage as a, type ResearchToolType as a0, type RunSettings as a1, type RunnerId as a2, type SetupFailure as a3, type ShadowedSkill as a4, type SkillAppliesTo as a5, type SkillCatalog as a6, type SkillInfo as a7, type SkillLoad as a8, type SkillLoadNotice as a9, createEmptyPlan as aA, createSkillsService as aB, createTask as aC, endAttemptUsage as aD, flattenTasks as aE, flattenTasksWithParents as aF, isAwaitingReason as aG, isMeasured as aH, isSupervisorLevel as aI, isUserMessage as aJ, migratePlanState as aK, partedPromptUsage as aL, pausedOnLimit as aM, planUsage as aN, plannerContextFill as aO, rejoinPlanTree as aP, startAttemptUsage as aQ, usageLine as aR, waitsForApproval as aS, type SkillMetadata as aa, type SkillSource as ab, SkillsService as ac, type SubagentOutcome as ad, type SupervisorLevel as ae, type Task as af, type TaskDiffRead as ag, type TaskDiffResult as ah, type TaskIsolation as ai, type TaskIsolationState as aj, type TaskModelAssignment as ak, type TaskSkillNotice as al, type TaskSkillSnapshot as am, type TaskSnapshot as an, type TaskStatus as ao, type TreeSnapshot as ap, type UsageLine as aq, type UsageRecord as ar, type UsageTotals as as, type Verdict as at, type VerificationCheck as au, addAttemptUsage as av, addModelUsage as aw, addPlannerUsage as ax, addUsage as ay, addUsageTotals as az, type AwaitingReason as b, DEFAULT_SUPERVISOR_RETRY_LIMIT as c, type DiscoveredModel as d, type ExecutionCommandName as e, type ExecutionRecord as f, type GuardTrip as g, type IntegrationDisposal as h, type InvalidSkill as i, type IsolationAvailability as j, type IsolationHandoff as k, type IsolationHandoffRepo as l, type IsolationInactiveReason as m, type IsolationLandedTask as n, type IsolationLanding as o, type IsolationMergeBlock as p, type IsolationMergeBlockReason as q, type IsolationMergeResult as r, type IsolationOutcome as s, type IsolationPruneResult as t, type IsolationRemoval as u, type IsolationRepo as v, type IsolationRun as w, type IsolationTaskRecord as x, type IsolationTaskRef as y, type IsolationTaskRepo as z };
1489
+ export { type ResearchProgress as $, type ApprovalRecord as A, BUILTIN_SKILL_NAMES as B, type ConversationMessage as C, DEFAULT_RUNNERS as D, type ExecutionActor as E, type IsolationTaskStatus as F, type GuardTarget as G, type IsolationView as H, type IWorktreeIsolation as I, type PlanIsolation as J, type PlanState as K, type LegacyPlanState as L, type ModelUsage as M, type PlanStatus as N, type PlanUsage as O, type PendingPlanTurn as P, type PlannerResendState as Q, type PlannerUsage as R, type PrepareIntent as S, type PreparedTask as T, type PreservedWork as U, type PreviousWork as V, type RefusedRemoval as W, type RepairEvidence as X, type ReplyRun as Y, type RepoGroupLayout as Z, type ResearchLogEntry as _, type AttemptUsage as a, type ResearchStep as a0, type ResearchStepOutcome as a1, type ResearchToolType as a2, type RunSettings as a3, type RunnerId as a4, type RunnerSessionCost as a5, type SetupFailure as a6, type ShadowedSkill as a7, type SkillAppliesTo as a8, type SkillCatalog as a9, addModelUsage as aA, addPlannerUsage as aB, addUsage as aC, addUsageTotals as aD, countedSessionCost as aE, createEmptyPlan as aF, createSkillsService as aG, createTask as aH, endAttemptUsage as aI, flattenTasks as aJ, flattenTasksWithParents as aK, isAwaitingReason as aL, isMeasured as aM, isSupervisorLevel as aN, isUserMessage as aO, migratePlanState as aP, partedPromptUsage as aQ, pausedOnLimit as aR, planUsage as aS, plannerContextFill as aT, rejoinPlanTree as aU, resumedSessionWindow as aV, startAttemptUsage as aW, taskUsageSummary as aX, usageLine as aY, waitsForApproval as aZ, type SkillInfo as aa, type SkillLoad as ab, type SkillLoadNotice as ac, type SkillMetadata as ad, type SkillSource as ae, SkillsService as af, type SubagentOutcome as ag, type SupervisorLevel as ah, type Task as ai, type TaskDiffRead as aj, type TaskDiffResult as ak, type TaskIsolation as al, type TaskIsolationState as am, type TaskModelAssignment as an, type TaskSkillNotice as ao, type TaskSkillSnapshot as ap, type TaskSnapshot as aq, type TaskStatus as ar, type TaskUsageSummary as as, type TreeSnapshot as at, type UsageLine as au, type UsageRecord as av, type UsageTotals as aw, type Verdict as ax, type VerificationCheck as ay, addAttemptUsage as az, type AwaitingReason as b, DEFAULT_SUPERVISOR_RETRY_LIMIT as c, type DiscoveredModel as d, type ExecutionCommandName as e, type ExecutionRecord as f, type GuardTrip as g, type IntegrationDisposal as h, type InvalidSkill as i, type IsolationAvailability as j, type IsolationHandoff as k, type IsolationHandoffRepo as l, type IsolationInactiveReason as m, type IsolationLandedTask as n, type IsolationLanding as o, type IsolationMergeBlock as p, type IsolationMergeBlockReason as q, type IsolationMergeResult as r, type IsolationOutcome as s, type IsolationPruneResult as t, type IsolationRemoval as u, type IsolationRepo as v, type IsolationRun as w, type IsolationTaskRecord as x, type IsolationTaskRef as y, type IsolationTaskRepo as z };
@@ -155,8 +155,10 @@ interface IsolationRepo {
155
155
  root: string;
156
156
  /** The commit checked out at run start. Switching branches mid-run does not retarget it. */
157
157
  baseRef: string;
158
- /** Branch name checked out at run start; absent on a detached HEAD. */
158
+ /** Branch name checked out at run start; absent on a detached HEAD, and on a record saved before this was noted. */
159
159
  baseBranch?: string;
160
+ /** Set when the run started on a detached HEAD, so that is told from a record that never noted its branch. */
161
+ startedDetached?: true;
160
162
  integrationBranch: string;
161
163
  }
162
164
  /**
@@ -237,6 +239,10 @@ interface IsolationHandoffRepo {
237
239
  path: string;
238
240
  integrationBranch: string;
239
241
  baseRef: string;
242
+ /** The branch the run started on in this repo; absent when it started on a detached HEAD or the record never noted one. */
243
+ baseBranch?: string;
244
+ /** Set when the run started on a detached HEAD. */
245
+ startedDetached?: true;
240
246
  /** Tasks whose work landed in this repo, in plan order. */
241
247
  landed: IsolationLandedTask[];
242
248
  }
@@ -259,27 +265,36 @@ interface IsolationView {
259
265
  /**
260
266
  * Why "Merge all" would not touch a repo. `partial-landing`: a task's landing
261
267
  * was interrupted and could not be rolled back there, so its integration
262
- * branch holds part of a task.
268
+ * branch holds part of a task. `wrong-branch`: the repo is not on the branch
269
+ * the run started on, and the merge would land on some other one.
263
270
  */
264
- type IsolationMergeBlockReason = 'merge-in-progress' | 'conflict' | 'uncommitted-changes' | 'partial-landing' | 'git-error';
271
+ type IsolationMergeBlockReason = 'merge-in-progress' | 'conflict' | 'uncommitted-changes' | 'partial-landing' | 'wrong-branch' | 'git-error';
265
272
  interface IsolationMergeBlock {
266
273
  repo: string;
267
274
  reason: IsolationMergeBlockReason;
268
275
  /** The files that would conflict, or the user's uncommitted ones the merge also changes; empty for the other reasons. */
269
276
  files: string[];
277
+ /** `wrong-branch` only: the branch the run started on. */
278
+ expected?: string;
279
+ /** `wrong-branch` only: the branch checked out now; absent on a detached HEAD. */
280
+ actual?: string;
281
+ /** `wrong-branch` only: the repo is in the middle of a rebase, which is what detached its HEAD. */
282
+ rebasing?: true;
270
283
  }
271
284
  /**
272
285
  * How "Merge all" went.
273
286
  * - `merged`: every repo with work on its integration branch took it.
274
- * - `blocked`: the preflight found repos that could not, so nothing was
287
+ * - `blocked`: a repo was on another branch than the run started on, or the
288
+ * preflight found repos that could not take their merge, so nothing was
275
289
  * touched anywhere; `blocked` says which and why.
276
290
  * - `conflict` / `failed`: a merge stopped in `repo` — on git older than 2.38,
277
291
  * which cannot preflight, or for a reason no preflight could foresee. That
278
292
  * merge was aborted, leaving `repo` as it was; `landed` names the repos
279
293
  * merged before it, which stay merged, and is absent when there are none.
280
294
  *
281
- * A group of one is blocked only by a partial landing; otherwise its one merge
282
- * lands or is aborted whole, so it reports as it always has.
295
+ * A group of one is blocked only by a partial landing or by being on the wrong
296
+ * branch; otherwise its one merge lands or is aborted whole, so it reports as
297
+ * it always has.
283
298
  */
284
299
  type IsolationMergeResult = {
285
300
  outcome: 'merged';
@@ -561,7 +576,11 @@ interface UsageRecord {
561
576
  amount: number;
562
577
  currency: string;
563
578
  };
564
- /** The model's context window, when the runner itself reports it. */
579
+ /**
580
+ * The model's context window: as the runner or provider reported it, or,
581
+ * when it reported none, from that runner's or provider's own model listing
582
+ * (`ContextWindowFill`). Never from a table kept in Ordewell.
583
+ */
565
584
  contextWindow?: number;
566
585
  /** Set when a subagent made the call; its usage still counts toward the total. */
567
586
  subagentId?: string;
@@ -638,16 +657,41 @@ interface ModelUsage {
638
657
  totals: UsageTotals;
639
658
  }
640
659
  declare function addModelUsage(models: readonly ModelUsage[], record: UsageRecord): ModelUsage[];
660
+ /**
661
+ * What Ordewell has counted of a runner's own session that reports its cost
662
+ * as a running total: that total and each model's share, in USD, as of its
663
+ * last report. A resume of that session counts its first report's growth
664
+ * over this; with no count kept for it, that report only sets the baseline.
665
+ */
666
+ interface RunnerSessionCost {
667
+ sessionId: string;
668
+ usd: number;
669
+ modelUsd: Record<string, number>;
670
+ }
641
671
  interface AttemptUsage extends PlannerUsage {
642
672
  attempt: number;
643
673
  runner: string;
674
+ /** The runner session this attempt ran in, as its runner reported it: what a later Continue of it resumes. */
675
+ sessionId?: string;
644
676
  startedAt: string;
645
677
  endedAt?: string;
646
678
  wallTimeMs: number;
679
+ /** What was counted of its runner session's running cost as it ended: a continue of that session counts on from it. */
680
+ runnerSessionCost?: RunnerSessionCost;
647
681
  }
648
682
  declare function startAttemptUsage(attempt: number, runner: string, startedAt: string): AttemptUsage;
649
683
  declare function addAttemptUsage(usage: AttemptUsage, record: UsageRecord, now: string): AttemptUsage;
650
- declare function endAttemptUsage(usage: AttemptUsage, now: string): AttemptUsage;
684
+ declare function endAttemptUsage(usage: AttemptUsage, now: string, runnerSessionCost?: RunnerSessionCost, sessionId?: string): AttemptUsage;
685
+ /** The count a continue of `sessionId` starts from: the one its latest attempt in that session ended with. */
686
+ declare function countedSessionCost(attempts: readonly AttemptUsage[] | undefined, sessionId: string): RunnerSessionCost | undefined;
687
+ /**
688
+ * The model a continue's session last ran on and the window it was measured
689
+ * against: the latest earlier attempt of that same runner session that
690
+ * reported one. An attempt that measured nothing is skipped — a continuation
691
+ * does not undo what its session was last measured against — and a window is
692
+ * never borrowed from another session: a fresh attempt starts one.
693
+ */
694
+ declare function resumedSessionWindow(attempts: readonly AttemptUsage[] | undefined, runner: string, attempt: number, sessionId: string): Pick<PlannerUsage, 'source' | 'model' | 'contextWindow'> | undefined;
651
695
  interface PlanUsage {
652
696
  totals: UsageTotals;
653
697
  byModel: ModelUsage[];
@@ -660,6 +704,21 @@ interface UsageTask {
660
704
  subtasks?: readonly UsageTask[];
661
705
  }
662
706
  declare function planUsage(tasks: readonly UsageTask[]): PlanUsage;
707
+ /**
708
+ * What one task spent across every attempt and every model it ran on, so a
709
+ * stop, a model change and a continue never makes the earlier spend vanish. The
710
+ * context meter is the exception: it reads the latest attempt, because only the
711
+ * current model's window says how full the next prompt is.
712
+ */
713
+ interface TaskUsageSummary {
714
+ totals: UsageTotals;
715
+ attempts: number;
716
+ contextFill?: {
717
+ usedTokens: number;
718
+ windowTokens: number;
719
+ };
720
+ }
721
+ declare function taskUsageSummary(task: Pick<UsageTask, 'attemptUsage'>): TaskUsageSummary;
663
722
 
664
723
  /**
665
724
  * How far a plan's supervisor may act in its wake-up turns (ADR-0029): a plan
@@ -685,7 +744,7 @@ type ExecutionActor = {
685
744
  | {
686
745
  kind: 'autorun';
687
746
  };
688
- type ExecutionCommandName = 'run_plan' | 'run_task' | 'stop_task' | 'stop_run' | 'retry_task' | 'message_task' | 'answer_approval' | 'merge_all' | 'skip_task';
747
+ type ExecutionCommandName = 'run_plan' | 'run_task' | 'stop_task' | 'stop_run' | 'retry_task' | 'message_task' | 'answer_approval' | 'merge_all' | 'skip_task' | 'force_start' | 'mark_complete' | 'mark_not_done' | 'interrupt_task' | 'force_send_queued' | 'remove_queued' | 'cancel_resume' | 'answer_checkpoint' | 'approve_review';
689
748
  /**
690
749
  * One call at the command seam as the timeline keeps it: what was asked, by
691
750
  * whom, about which task, and how it ended — done, refused by the seam, or
@@ -933,9 +992,11 @@ type TaskType = 'ai' | 'user';
933
992
  /**
934
993
  * `skipped` is terminal and verdict-less: the task will not be waited for, and
935
994
  * nothing it did lands. Its dependents go ahead without it once the work it
936
- * waited on is done.
995
+ * waited on is done. There is no stored `blocked`: a task is blocked when a
996
+ * failed dependency says so (ADR-0034), and a file that kept the old status
997
+ * loads as pending.
937
998
  */
938
- type TaskStatus = 'pending' | 'approved' | 'in_progress' | 'completed' | 'failed' | 'blocked' | 'awaiting_user' | 'skipped';
999
+ type TaskStatus = 'pending' | 'approved' | 'in_progress' | 'completed' | 'failed' | 'awaiting_user' | 'skipped';
939
1000
  type TaskMode = string;
940
1001
  /**
941
1002
  * Why an `awaiting_user` task waits (ADR-0018, W1): a structured turn that
@@ -993,6 +1054,13 @@ interface Task {
993
1054
  userStoriesCovered?: string[];
994
1055
  /** The runner's saved session for a later continue; cleared when a fresh attempt starts. */
995
1056
  runnerSessionId?: string;
1057
+ /**
1058
+ * The runner that session belongs to: a session cannot cross runners, so
1059
+ * Continue is offered only while the task is still assigned to it. Absent
1060
+ * on a plan saved before it was recorded; the last attempt's runner stands
1061
+ * in (see `sessionOwner`).
1062
+ */
1063
+ runnerSessionOwner?: RunnerId;
996
1064
  /** Set only while `status` is `awaiting_user`, and not always then — a pause saved by an older build has none. */
997
1065
  awaitingReason?: AwaitingReason;
998
1066
  /**
@@ -1177,10 +1245,13 @@ interface ConversationMessage {
1177
1245
  * (ADR-0029), its record in `execution`. 'wake_up' is the digest a wake-up
1178
1246
  * gave the supervisor (role 'user': the model was told it), and
1179
1247
  * 'supervisor' what the supervisor said in a wake-up turn (ADR-0029).
1248
+ * 'error' is a planner turn that ended on the planner's usage limit, drawn
1249
+ * as a failure and never replayed to the planner: it is not the planner's
1250
+ * answer, and its inputs are sent again (see {@link PlannerResendState}).
1180
1251
  * Absent for ordinary chat turns, so sessions saved before markers existed
1181
1252
  * degrade gracefully.
1182
1253
  */
1183
- kind?: 'plan_generated' | 'system' | 'compaction' | 'skill_load' | 'execution' | 'wake_up' | 'supervisor';
1254
+ kind?: 'plan_generated' | 'system' | 'compaction' | 'skill_load' | 'execution' | 'wake_up' | 'supervisor' | 'error';
1184
1255
  actor?: 'Ordewell setting';
1185
1256
  /** Present exactly when `kind` is 'skill_load'. */
1186
1257
  skill?: SkillLoad;
@@ -1188,6 +1259,23 @@ interface ConversationMessage {
1188
1259
  execution?: ExecutionRecord;
1189
1260
  /** A user's message that was force sent, stopping the turn before it (ADR-0023). */
1190
1261
  forced?: true;
1262
+ /**
1263
+ * What a reply showed, run by run, where each began (ADR-0017 A1). Beside
1264
+ * `content`, which stays the reply as the planner is told it. Absent on
1265
+ * entries saved before runs were kept, which reload as one message.
1266
+ */
1267
+ runs?: ReplyRun[];
1268
+ }
1269
+ /**
1270
+ * One run of a planner reply's text: the segment it streamed under, its
1271
+ * settled text, and when it began. A run that never streamed (a message the
1272
+ * conversation wrote in the planner's place) has a segment no stream used.
1273
+ */
1274
+ interface ReplyRun {
1275
+ segmentId: string;
1276
+ text: string;
1277
+ /** ISO timestamp. */
1278
+ startedAt: string;
1191
1279
  }
1192
1280
  /**
1193
1281
  * A skill's SKILL.md as it was when loaded into a planner conversation. A
@@ -1268,6 +1356,17 @@ interface SupervisionSnapshot {
1268
1356
  /** The events inside their debounce window and the wake-up rate's timestamps. */
1269
1357
  wake?: SupervisorSnapshot;
1270
1358
  }
1359
+ /**
1360
+ * What waits on the planner's usage limit. With `at`, the inputs no turn
1361
+ * answered are sent again then, on their own; without it — the reset could
1362
+ * not be read, the resend hit the limit again, or it was cancelled — they go
1363
+ * with the next input: the user's message, or a wake-up.
1364
+ */
1365
+ interface PlannerResendState {
1366
+ /** The runner whose account hit the limit; a planner on another one is not held by it. */
1367
+ runner?: RunnerId;
1368
+ at?: string;
1369
+ }
1271
1370
  interface LegacyPlanState {
1272
1371
  runSettings?: RunSettings;
1273
1372
  /** What supervision remembers across a daemon restart (ADR-0029); absent on plans saved before it existed. */
@@ -1295,6 +1394,8 @@ interface LegacyPlanState {
1295
1394
  isolation?: PlanIsolation;
1296
1395
  /** Kept so a reopened session shows the same token line (#49). */
1297
1396
  plannerUsage?: PlannerUsage;
1397
+ /** The planner hit its usage limit and the inputs its turn took wait to be sent again; absent otherwise. */
1398
+ plannerResend?: PlannerResendState;
1298
1399
  /**
1299
1400
  * The tasks the user approved to run: every task when they executed the
1300
1401
  * plan, and each one they started or retried themselves since. A command
@@ -1385,4 +1486,4 @@ type ApprovalRecord = Pick<LegacyPlanState, 'approved' | 'approvedTasks'>;
1385
1486
  */
1386
1487
  declare function waitsForApproval(task: Pick<Task, 'id' | 'type' | 'status'>, record: ApprovalRecord): boolean;
1387
1488
 
1388
- export { type ResearchStepOutcome as $, type ApprovalRecord as A, BUILTIN_SKILL_NAMES as B, type ConversationMessage as C, DEFAULT_RUNNERS as D, type ExecutionActor as E, type IsolationTaskStatus as F, type GuardTarget as G, type IsolationView as H, type IWorktreeIsolation as I, type PlanIsolation as J, type PlanState as K, type LegacyPlanState as L, type ModelUsage as M, type PlanStatus as N, type PlanUsage as O, type PendingPlanTurn as P, type PlannerUsage as Q, type PrepareIntent as R, type PreparedTask as S, type PreservedWork as T, type PreviousWork as U, type RefusedRemoval as V, type RepairEvidence as W, type RepoGroupLayout as X, type ResearchLogEntry as Y, type ResearchProgress as Z, type ResearchStep as _, type AttemptUsage as a, type ResearchToolType as a0, type RunSettings as a1, type RunnerId as a2, type SetupFailure as a3, type ShadowedSkill as a4, type SkillAppliesTo as a5, type SkillCatalog as a6, type SkillInfo as a7, type SkillLoad as a8, type SkillLoadNotice as a9, createEmptyPlan as aA, createSkillsService as aB, createTask as aC, endAttemptUsage as aD, flattenTasks as aE, flattenTasksWithParents as aF, isAwaitingReason as aG, isMeasured as aH, isSupervisorLevel as aI, isUserMessage as aJ, migratePlanState as aK, partedPromptUsage as aL, pausedOnLimit as aM, planUsage as aN, plannerContextFill as aO, rejoinPlanTree as aP, startAttemptUsage as aQ, usageLine as aR, waitsForApproval as aS, type SkillMetadata as aa, type SkillSource as ab, SkillsService as ac, type SubagentOutcome as ad, type SupervisorLevel as ae, type Task as af, type TaskDiffRead as ag, type TaskDiffResult as ah, type TaskIsolation as ai, type TaskIsolationState as aj, type TaskModelAssignment as ak, type TaskSkillNotice as al, type TaskSkillSnapshot as am, type TaskSnapshot as an, type TaskStatus as ao, type TreeSnapshot as ap, type UsageLine as aq, type UsageRecord as ar, type UsageTotals as as, type Verdict as at, type VerificationCheck as au, addAttemptUsage as av, addModelUsage as aw, addPlannerUsage as ax, addUsage as ay, addUsageTotals as az, type AwaitingReason as b, DEFAULT_SUPERVISOR_RETRY_LIMIT as c, type DiscoveredModel as d, type ExecutionCommandName as e, type ExecutionRecord as f, type GuardTrip as g, type IntegrationDisposal as h, type InvalidSkill as i, type IsolationAvailability as j, type IsolationHandoff as k, type IsolationHandoffRepo as l, type IsolationInactiveReason as m, type IsolationLandedTask as n, type IsolationLanding as o, type IsolationMergeBlock as p, type IsolationMergeBlockReason as q, type IsolationMergeResult as r, type IsolationOutcome as s, type IsolationPruneResult as t, type IsolationRemoval as u, type IsolationRepo as v, type IsolationRun as w, type IsolationTaskRecord as x, type IsolationTaskRef as y, type IsolationTaskRepo as z };
1489
+ export { type ResearchProgress as $, type ApprovalRecord as A, BUILTIN_SKILL_NAMES as B, type ConversationMessage as C, DEFAULT_RUNNERS as D, type ExecutionActor as E, type IsolationTaskStatus as F, type GuardTarget as G, type IsolationView as H, type IWorktreeIsolation as I, type PlanIsolation as J, type PlanState as K, type LegacyPlanState as L, type ModelUsage as M, type PlanStatus as N, type PlanUsage as O, type PendingPlanTurn as P, type PlannerResendState as Q, type PlannerUsage as R, type PrepareIntent as S, type PreparedTask as T, type PreservedWork as U, type PreviousWork as V, type RefusedRemoval as W, type RepairEvidence as X, type ReplyRun as Y, type RepoGroupLayout as Z, type ResearchLogEntry as _, type AttemptUsage as a, type ResearchStep as a0, type ResearchStepOutcome as a1, type ResearchToolType as a2, type RunSettings as a3, type RunnerId as a4, type RunnerSessionCost as a5, type SetupFailure as a6, type ShadowedSkill as a7, type SkillAppliesTo as a8, type SkillCatalog as a9, addModelUsage as aA, addPlannerUsage as aB, addUsage as aC, addUsageTotals as aD, countedSessionCost as aE, createEmptyPlan as aF, createSkillsService as aG, createTask as aH, endAttemptUsage as aI, flattenTasks as aJ, flattenTasksWithParents as aK, isAwaitingReason as aL, isMeasured as aM, isSupervisorLevel as aN, isUserMessage as aO, migratePlanState as aP, partedPromptUsage as aQ, pausedOnLimit as aR, planUsage as aS, plannerContextFill as aT, rejoinPlanTree as aU, resumedSessionWindow as aV, startAttemptUsage as aW, taskUsageSummary as aX, usageLine as aY, waitsForApproval as aZ, type SkillInfo as aa, type SkillLoad as ab, type SkillLoadNotice as ac, type SkillMetadata as ad, type SkillSource as ae, SkillsService as af, type SubagentOutcome as ag, type SupervisorLevel as ah, type Task as ai, type TaskDiffRead as aj, type TaskDiffResult as ak, type TaskIsolation as al, type TaskIsolationState as am, type TaskModelAssignment as an, type TaskSkillNotice as ao, type TaskSkillSnapshot as ap, type TaskSnapshot as aq, type TaskStatus as ar, type TaskUsageSummary as as, type TreeSnapshot as at, type UsageLine as au, type UsageRecord as av, type UsageTotals as aw, type Verdict as ax, type VerificationCheck as ay, addAttemptUsage as az, type AwaitingReason as b, DEFAULT_SUPERVISOR_RETRY_LIMIT as c, type DiscoveredModel as d, type ExecutionCommandName as e, type ExecutionRecord as f, type GuardTrip as g, type IntegrationDisposal as h, type InvalidSkill as i, type IsolationAvailability as j, type IsolationHandoff as k, type IsolationHandoffRepo as l, type IsolationInactiveReason as m, type IsolationLandedTask as n, type IsolationLanding as o, type IsolationMergeBlock as p, type IsolationMergeBlockReason as q, type IsolationMergeResult as r, type IsolationOutcome as s, type IsolationPruneResult as t, type IsolationRemoval as u, type IsolationRepo as v, type IsolationRun as w, type IsolationTaskRecord as x, type IsolationTaskRef as y, type IsolationTaskRepo as z };