@ordewell/core 0.10.8 → 0.10.10

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 (40) hide show
  1. package/dist/{IFileSystem-C4_mpfze.d.ts → IFileSystem-1PqRCjhu.d.mts} +23 -3
  2. package/dist/{IFileSystem-DUgeWWQN.d.mts → IFileSystem-lTRL_G9Z.d.ts} +23 -3
  3. package/dist/{ModeResolver-4qNjxcDs.d.mts → ModeResolver-6TQXVsde.d.mts} +1 -1
  4. package/dist/{ModeResolver-DGK2rWHE.d.ts → ModeResolver-CoJAJD-f.d.ts} +1 -1
  5. package/dist/{Task-C0o4i3Nn.d.mts → Task-CfBM0wkV.d.mts} +100 -24
  6. package/dist/{Task-C0o4i3Nn.d.ts → Task-CfBM0wkV.d.ts} +100 -24
  7. package/dist/{chunk-H7QX32BH.mjs → chunk-24EL4Z2W.mjs} +2 -2
  8. package/dist/{chunk-DMG4ISUG.mjs → chunk-ESKK5I4F.mjs} +145 -21
  9. package/dist/chunk-ESKK5I4F.mjs.map +1 -0
  10. package/dist/{chunk-LTHKFBKM.mjs → chunk-KWS3VEER.mjs} +3 -3
  11. package/dist/{chunk-EEE2GBLG.mjs → chunk-PFH7WFIB.mjs} +1 -1
  12. package/dist/chunk-PFH7WFIB.mjs.map +1 -0
  13. package/dist/index.d.mts +145 -20
  14. package/dist/index.d.ts +145 -20
  15. package/dist/index.js +668 -112
  16. package/dist/index.js.map +1 -1
  17. package/dist/index.mjs +537 -96
  18. package/dist/index.mjs.map +1 -1
  19. package/dist/parsing.d.mts +2 -2
  20. package/dist/parsing.d.ts +2 -2
  21. package/dist/parsing.js.map +1 -1
  22. package/dist/parsing.mjs +3 -3
  23. package/dist/plan-utils.d.mts +4 -4
  24. package/dist/plan-utils.d.ts +4 -4
  25. package/dist/plan-utils.js +144 -18
  26. package/dist/plan-utils.js.map +1 -1
  27. package/dist/plan-utils.mjs +22 -4
  28. package/dist/{runSettingsText-BgOmLxdw.d.mts → runSettingsText-C1i9wBG1.d.mts} +61 -21
  29. package/dist/{runSettingsText-BgXvajj2.d.ts → runSettingsText-CWNrmF5U.d.ts} +61 -21
  30. package/dist/testing.d.mts +7 -2
  31. package/dist/testing.d.ts +7 -2
  32. package/dist/testing.js +11 -0
  33. package/dist/testing.js.map +1 -1
  34. package/dist/testing.mjs +12 -1
  35. package/dist/testing.mjs.map +1 -1
  36. package/package.json +1 -1
  37. package/dist/chunk-DMG4ISUG.mjs.map +0 -1
  38. package/dist/chunk-EEE2GBLG.mjs.map +0 -1
  39. /package/dist/{chunk-H7QX32BH.mjs.map → chunk-24EL4Z2W.mjs.map} +0 -0
  40. /package/dist/{chunk-LTHKFBKM.mjs.map → chunk-KWS3VEER.mjs.map} +0 -0
@@ -24,6 +24,9 @@ import {
24
24
  canMergeTasks,
25
25
  canSplitTask,
26
26
  capConflictFiles,
27
+ contextMeterText,
28
+ contextMeterTitle,
29
+ costText,
27
30
  countedSessionCost,
28
31
  dependentsNotice,
29
32
  diffRows,
@@ -33,6 +36,8 @@ import {
33
36
  endAttemptUsage,
34
37
  followTaskLog,
35
38
  followTurn,
39
+ formatCost,
40
+ formatTokenCount,
36
41
  fromTranscript,
37
42
  hasHiddenDetail,
38
43
  holdPrompt,
@@ -42,6 +47,7 @@ import {
42
47
  markRequestFor,
43
48
  markdownHtml,
44
49
  markdownTokens,
50
+ modelCostTitle,
45
51
  namedRepos,
46
52
  newTaskFields,
47
53
  opsEditable,
@@ -63,6 +69,7 @@ import {
63
69
  skippedLabel,
64
70
  startAttemptUsage,
65
71
  stopTurn,
72
+ subagentCostTitle,
66
73
  summarizeToolCall,
67
74
  takeAt,
68
75
  taskRowActions,
@@ -70,16 +77,18 @@ import {
70
77
  taskStartedNotice,
71
78
  taskStatusKind,
72
79
  taskUsageSummary,
80
+ tasksTotalText,
73
81
  titledRefs,
74
82
  toolHeadline,
75
83
  truncateCheckpointSummary,
76
84
  unsendAll,
77
85
  unsendLatest,
78
- usageLine
79
- } from "./chunk-DMG4ISUG.mjs";
86
+ usageLine,
87
+ usageText
88
+ } from "./chunk-ESKK5I4F.mjs";
80
89
  import {
81
90
  clampThinkingEffort
82
- } from "./chunk-H7QX32BH.mjs";
91
+ } from "./chunk-24EL4Z2W.mjs";
83
92
  import {
84
93
  DEFAULT_RUNNERS,
85
94
  canSetDependencies,
@@ -98,7 +107,7 @@ import {
98
107
  titledTaskRef,
99
108
  titledTaskRefOf,
100
109
  walkPlan
101
- } from "./chunk-EEE2GBLG.mjs";
110
+ } from "./chunk-PFH7WFIB.mjs";
102
111
  export {
103
112
  CHECKPOINT_TRUNCATE_LENGTH,
104
113
  DEFAULT_RUNNERS,
@@ -128,6 +137,9 @@ export {
128
137
  canSplitTask,
129
138
  capConflictFiles,
130
139
  clampThinkingEffort,
140
+ contextMeterText,
141
+ contextMeterTitle,
142
+ costText,
131
143
  countedSessionCost,
132
144
  dependencyCandidates,
133
145
  dependentsNotice,
@@ -139,6 +151,8 @@ export {
139
151
  endAttemptUsage,
140
152
  followTaskLog,
141
153
  followTurn,
154
+ formatCost,
155
+ formatTokenCount,
142
156
  fromTranscript,
143
157
  hasHiddenDetail,
144
158
  holdPrompt,
@@ -149,6 +163,7 @@ export {
149
163
  markRequestFor,
150
164
  markdownHtml,
151
165
  markdownTokens,
166
+ modelCostTitle,
152
167
  namedRepos,
153
168
  newTaskFields,
154
169
  opsEditable,
@@ -174,6 +189,7 @@ export {
174
189
  skippedLabel,
175
190
  startAttemptUsage,
176
191
  stopTurn,
192
+ subagentCostTitle,
177
193
  subtreeIds,
178
194
  summarizeToolCall,
179
195
  takeAt,
@@ -186,6 +202,7 @@ export {
186
202
  taskStartedNotice,
187
203
  taskStatusKind,
188
204
  taskUsageSummary,
205
+ tasksTotalText,
189
206
  titledRefs,
190
207
  titledTaskRef,
191
208
  titledTaskRefOf,
@@ -194,6 +211,7 @@ export {
194
211
  unsendAll,
195
212
  unsendLatest,
196
213
  usageLine,
214
+ usageText,
197
215
  walkPlan
198
216
  };
199
217
  //# sourceMappingURL=plan-utils.mjs.map
@@ -1,6 +1,6 @@
1
- import { ai as Task, a4 as RunnerId, aq as TaskSnapshot, b as AwaitingReason, av as UsageRecord, a5 as RunnerSessionCost, d as DiscoveredModel, af as SkillsService, aa as SkillInfo, Z as RepoGroupLayout, I as IWorktreeIsolation, w as IsolationRun, k as IsolationHandoff, J as PlanIsolation, x as IsolationTaskRecord, al as TaskIsolation, H as IsolationView, S as PrepareIntent, V as PreviousWork, s as IsolationOutcome, X as RepairEvidence, at as TreeSnapshot, aj as TaskDiffRead, ak as TaskDiffResult, r as IsolationMergeResult, ax as Verdict, ap as TaskSkillSnapshot, ao as TaskSkillNotice, ag as SubagentOutcome, L as LegacyPlanState, C as ConversationMessage, ac as SkillLoadNotice, P as PendingPlanTurn, a as AttemptUsage, a3 as RunSettings, O as PlanUsage, Y as ReplyRun, M as ModelUsage, aw as UsageTotals, f as ExecutionRecord, a0 as ResearchStep, K as PlanState, $ as ResearchProgress, _ as ResearchLogEntry, ab as SkillLoad, N as PlanStatus, ah as SupervisorLevel, a1 as ResearchStepOutcome, R as PlannerUsage, am as TaskIsolationState, as as TaskUsageSummary } from './Task-C0o4i3Nn.mjs';
2
- import { N as IRunnerSession, K as IConfig, aL as TaskMessageFrom, ax as RunnerModelRef, ap as RunnerCommand, au as RunnerMcpServer, aE as StructuredTurnEnd, j as ApprovalDecision, aD as StructuredEvent, ah as QueuedTaskMessage, k as ApprovalKind, q as ApprovalSource, M as IRunner, ay as RunnerRegistry, J as IApproval, aU as ToolOutcome, d as AgentProcessDeps, a as AgentAdapter, a4 as OrdewellMcpServer, L as IFileSystem, aV as UsageLimitSignal, ac as PlannerToolHandler, p as ApprovalRequest, i as ApprovalAnswer, f as AiProvider, a3 as OrchestratorOption, a9 as PlannerBackendId } from './IFileSystem-DUgeWWQN.mjs';
3
- import { R as RunnerModeInfo } from './ModeResolver-4qNjxcDs.mjs';
1
+ import { am as Task, a7 as RunnerId, au as TaskSnapshot, b as AwaitingReason, az as UsageRecord, a8 as RunnerSessionCost, f as DiscoveredModel, aj as SkillsService, ae as SkillInfo, $ as RepoGroupLayout, I as IWorktreeIsolation, y as IsolationRun, m as IsolationHandoff, N as PlanIsolation, z as IsolationTaskRecord, ap as TaskIsolation, K as IsolationView, U as PrepareIntent, X as PreviousWork, u as IsolationOutcome, Z as RepairEvidence, ax as TreeSnapshot, an as TaskDiffRead, ao as TaskDiffResult, t as IsolationMergeResult, aB as Verdict, at as TaskSkillSnapshot, as as TaskSkillNotice, ak as SubagentOutcome, L as LegacyPlanState, c as ConversationMessage, ag as SkillLoadNotice, P as PendingPlanTurn, a as AttemptUsage, a6 as RunSettings, R as PlanUsage, _ as ReplyRun, a9 as SessionBilling, M as ModelUsage, aA as UsageTotals, C as ContextFill, h as ExecutionRecord, a3 as ResearchStep, O as PlanState, a2 as ResearchProgress, a1 as ResearchLogEntry, af as SkillLoad, Q as PlanStatus, al as SupervisorLevel, a4 as ResearchStepOutcome, T as PlannerUsage, aq as TaskIsolationState, aw as TaskUsageSummary } from './Task-CfBM0wkV.mjs';
2
+ import { N as IRunnerSession, K as IConfig, aL as TaskMessageFrom, ax as RunnerModelRef, ap as RunnerCommand, au as RunnerMcpServer, aE as StructuredTurnEnd, j as ApprovalDecision, aD as StructuredEvent, ah as QueuedTaskMessage, k as ApprovalKind, q as ApprovalSource, M as IRunner, ay as RunnerRegistry, J as IApproval, aU as ToolOutcome, d as AgentProcessDeps, a as AgentAdapter, a4 as OrdewellMcpServer, L as IFileSystem, aV as UsageLimitSignal, ac as PlannerToolHandler, p as ApprovalRequest, i as ApprovalAnswer, f as AiProvider, a3 as OrchestratorOption, a9 as PlannerBackendId } from './IFileSystem-1PqRCjhu.mjs';
3
+ import { R as RunnerModeInfo } from './ModeResolver-6TQXVsde.mjs';
4
4
 
5
5
  type NotificationAction = {
6
6
  label: string;
@@ -394,6 +394,12 @@ interface PlannerModes {
394
394
  type IsolationNoticeLevel = 'info' | 'warn' | 'error';
395
395
  /** How an attempt that may run in a worktree gets one: fresh, the kept one for a repair, or restoring the previous attempt's work. */
396
396
  type AttemptIntent = 'fresh' | 'repair' | PrepareIntent;
397
+ /**
398
+ * What adopting a persisted run found: nothing to change, landed work git
399
+ * shows the user has merged since, or a settled run that had nothing left to
400
+ * hand over and was cleared up.
401
+ */
402
+ type AdoptOutcome = 'unchanged' | 'changed' | 'cleared';
397
403
  interface AttemptWorkspace {
398
404
  cwd: string;
399
405
  worktree: boolean;
@@ -451,6 +457,8 @@ declare class IsolationRunController {
451
457
  private readonly listener;
452
458
  private readonly liveTasks;
453
459
  private run;
460
+ /** An adoption stays scoped even while cleanup temporarily leaves no run record. */
461
+ private adoptions;
454
462
  /** Copied paths already reported for the current run: every task gets the same copies. */
455
463
  private reportedCopies;
456
464
  private reportedSetupFailures;
@@ -492,13 +500,20 @@ declare class IsolationRunController {
492
500
  * Take over a plan's persisted isolation, or none for a plan that has not
493
501
  * isolated yet. Whatever a crashed process left behind for the run — a
494
502
  * worktree still marked active, a directory no record owns — is pruned,
495
- * while kept, failed and conflicted worktrees stay for the user.
503
+ * while kept, failed and conflicted worktrees stay for the user. Then git is
504
+ * asked which landed work the user has merged since the record was saved:
505
+ * a settled run whose landed work is all in HEAD has nothing left to hand
506
+ * over, so it is cleared up as Merge all would have, unless it still holds
507
+ * work that never landed (ADR-0013).
496
508
  *
497
- * Deliberately not reported as a change: adopting is not a change to
498
- * persist, and a host that adopts without persisting (VS Code's restore)
499
- * would otherwise write a new session file on every reload.
500
- */
501
- adopt(state: PlanIsolation | null): Promise<void>;
509
+ * Deliberately not reported to the listener: adopting is not a change of the
510
+ * session's own, and a host that adopts without persisting (VS Code's
511
+ * restore) would otherwise write a new session file on every reload. What
512
+ * git changed is returned instead, for the caller to save where it can and
513
+ * announce. A plan loaded meanwhile supersedes this adoption, which then
514
+ * touches nothing and resolves `unchanged`.
515
+ */
516
+ adopt(state: PlanIsolation | null): Promise<AdoptOutcome>;
502
517
  /** Open a run if none is, leaving whether it isolates to its first change task. */
503
518
  open(): void;
504
519
  /**
@@ -587,6 +602,10 @@ declare class IsolationRunController {
587
602
  * with git. Resolves true when some was found.
588
603
  */
589
604
  refreshInHead(): Promise<boolean>;
605
+ /** Mark the run's landed work git finds in HEAD; true when some was found. */
606
+ private findLanded;
607
+ /** The run landed something and every landing is in the user's HEAD. */
608
+ private allMerged;
590
609
  /**
591
610
  * The tracked state of the workspace as an attempt whose tree is checked
592
611
  * starts (see `attemptKind.checksTree`), for {@link filesChangedSince}
@@ -645,6 +664,10 @@ declare class IsolationRunController {
645
664
  * than leaving that work to a deletion.
646
665
  */
647
666
  private clearMerged;
667
+ /** The records that keep a settled run from being cleared up: live, or holding work that never landed. */
668
+ private holdouts;
669
+ /** The run's worktrees and merged branches go; false, said, when git would not let them. */
670
+ private discardMerged;
648
671
  /** Say what a removal kept back instead of deleting: where the work went, or which worktree stayed. */
649
672
  private report;
650
673
  private forget;
@@ -1403,21 +1426,19 @@ type SessionMessage =
1403
1426
  /**
1404
1427
  * The planner's running usage for the session, subagents included, emitted
1405
1428
  * after a model call reports usage. `totals` already contains every
1406
- * `bySubagent` entry. `contextFill` is the last planner prompt against the
1407
- * model's window, omitted when the window is unknown. Cost appears only as
1408
- * reported by a provider or runner (see `UsageRecord`).
1429
+ * `bySubagent` entry. `contextFill` is the context the main model's last
1430
+ * call left, with its window when known; omitted before a call was measured.
1431
+ * Cost appears only as reported by a provider or runner (see `UsageRecord`).
1409
1432
  */
1410
1433
  | {
1411
1434
  type: 'planner_usage';
1435
+ sessionBilling?: SessionBilling;
1412
1436
  byModel?: ModelUsage[];
1413
1437
  model?: string;
1414
1438
  turnId?: string;
1415
1439
  totals: UsageTotals;
1416
1440
  bySubagent?: Record<string, UsageTotals>;
1417
- contextFill?: {
1418
- usedTokens: number;
1419
- windowTokens: number;
1420
- };
1441
+ contextFill?: ContextFill;
1421
1442
  }
1422
1443
  /**
1423
1444
  * A subagent began work on `brief`. Emitted by the planner backend that
@@ -1847,6 +1868,10 @@ declare class TaskOrchestrator {
1847
1868
  private store;
1848
1869
  private output;
1849
1870
  private attempts;
1871
+ /** Bumped by every plan load: an ended attempt's wind-down belongs to the scope before it. */
1872
+ private planScope;
1873
+ /** Each task's runners still winding down once stopped: a continue waits for them (ADR-0018, L1). */
1874
+ private windDowns;
1850
1875
  private verifier;
1851
1876
  /** Changed only by start, stop, a plan load, a usage-limit pause, a move off the limit, and {@link settleRun}. */
1852
1877
  private runState;
@@ -2484,6 +2509,18 @@ declare class TaskOrchestrator {
2484
2509
  * load reset the whole verifier themselves.
2485
2510
  */
2486
2511
  private endAttempt;
2512
+ /**
2513
+ * Let the attempt's runner go the way it ends a turn (ADR-0018, L1): it
2514
+ * winds down on its own time, bounded by its interrupt grace, and nothing
2515
+ * here waits on it but a continue of the same task.
2516
+ */
2517
+ private stopRunner;
2518
+ /**
2519
+ * An ended attempt's runner is gone: the count its session ended on is the
2520
+ * one a continue of that session counts from. One still current is ended
2521
+ * with that count instead.
2522
+ */
2523
+ private woundDown;
2487
2524
  /** Kept on the task once the attempt ends, so a continue can resume it after a reload (ADR-0018, K1). */
2488
2525
  private saveNativeSession;
2489
2526
  private endAllAttempts;
@@ -2788,6 +2825,12 @@ declare class CliAgentAiService implements IAiService {
2788
2825
  * `startConversation` reseeds from Ordewell's transcript, which is the same
2789
2826
  * degradation `restoreChat` already performs on every surface.
2790
2827
  *
2828
+ * A process can end while idle without Ordewell stopping it — the OS, the
2829
+ * CLI itself, a sleeping machine, a signal sent to its group — and every
2830
+ * path of ours that kills one also drops its adapter. So an adapter still
2831
+ * held whose process has ended died on its own, and is restarted here
2832
+ * rather than answering the next message with its exit code.
2833
+ *
2791
2834
  * Also restarted when the policy's decision on the runner's own search has
2792
2835
  * changed since the process was spawned: the running thread would otherwise
2793
2836
  * keep searching unasked after Full turned Guarded. Codex 0.162 applies
@@ -4515,17 +4558,14 @@ interface RunnerLoadedBlock {
4515
4558
  commands: readonly RunnerCommand[];
4516
4559
  mcpServers: readonly RunnerMcpServer[];
4517
4560
  }
4518
- /** The token line. There is at most one, and it is always the last block. */
4561
+ /** The usage line (context and cost). Token counts ride in `totals` but are not drawn. There is at most one, and it is always the last block. */
4519
4562
  interface UsageBlock {
4520
4563
  byModel?: ModelUsage[];
4521
4564
  model?: string;
4522
4565
  type: 'usage';
4523
4566
  id: string;
4524
4567
  totals: UsageTotals;
4525
- contextFill?: {
4526
- usedTokens: number;
4527
- windowTokens: number;
4528
- };
4568
+ contextFill?: ContextFill;
4529
4569
  bySubagent?: Record<string, UsageTotals>;
4530
4570
  }
4531
4571
 
@@ -1,6 +1,6 @@
1
- import { ai as Task, a4 as RunnerId, aq as TaskSnapshot, b as AwaitingReason, av as UsageRecord, a5 as RunnerSessionCost, d as DiscoveredModel, af as SkillsService, aa as SkillInfo, Z as RepoGroupLayout, I as IWorktreeIsolation, w as IsolationRun, k as IsolationHandoff, J as PlanIsolation, x as IsolationTaskRecord, al as TaskIsolation, H as IsolationView, S as PrepareIntent, V as PreviousWork, s as IsolationOutcome, X as RepairEvidence, at as TreeSnapshot, aj as TaskDiffRead, ak as TaskDiffResult, r as IsolationMergeResult, ax as Verdict, ap as TaskSkillSnapshot, ao as TaskSkillNotice, ag as SubagentOutcome, L as LegacyPlanState, C as ConversationMessage, ac as SkillLoadNotice, P as PendingPlanTurn, a as AttemptUsage, a3 as RunSettings, O as PlanUsage, Y as ReplyRun, M as ModelUsage, aw as UsageTotals, f as ExecutionRecord, a0 as ResearchStep, K as PlanState, $ as ResearchProgress, _ as ResearchLogEntry, ab as SkillLoad, N as PlanStatus, ah as SupervisorLevel, a1 as ResearchStepOutcome, R as PlannerUsage, am as TaskIsolationState, as as TaskUsageSummary } from './Task-C0o4i3Nn.js';
2
- import { N as IRunnerSession, K as IConfig, aL as TaskMessageFrom, ax as RunnerModelRef, ap as RunnerCommand, au as RunnerMcpServer, aE as StructuredTurnEnd, j as ApprovalDecision, aD as StructuredEvent, ah as QueuedTaskMessage, k as ApprovalKind, q as ApprovalSource, M as IRunner, ay as RunnerRegistry, J as IApproval, aU as ToolOutcome, d as AgentProcessDeps, a as AgentAdapter, a4 as OrdewellMcpServer, L as IFileSystem, aV as UsageLimitSignal, ac as PlannerToolHandler, p as ApprovalRequest, i as ApprovalAnswer, f as AiProvider, a3 as OrchestratorOption, a9 as PlannerBackendId } from './IFileSystem-C4_mpfze.js';
3
- import { R as RunnerModeInfo } from './ModeResolver-DGK2rWHE.js';
1
+ import { am as Task, a7 as RunnerId, au as TaskSnapshot, b as AwaitingReason, az as UsageRecord, a8 as RunnerSessionCost, f as DiscoveredModel, aj as SkillsService, ae as SkillInfo, $ as RepoGroupLayout, I as IWorktreeIsolation, y as IsolationRun, m as IsolationHandoff, N as PlanIsolation, z as IsolationTaskRecord, ap as TaskIsolation, K as IsolationView, U as PrepareIntent, X as PreviousWork, u as IsolationOutcome, Z as RepairEvidence, ax as TreeSnapshot, an as TaskDiffRead, ao as TaskDiffResult, t as IsolationMergeResult, aB as Verdict, at as TaskSkillSnapshot, as as TaskSkillNotice, ak as SubagentOutcome, L as LegacyPlanState, c as ConversationMessage, ag as SkillLoadNotice, P as PendingPlanTurn, a as AttemptUsage, a6 as RunSettings, R as PlanUsage, _ as ReplyRun, a9 as SessionBilling, M as ModelUsage, aA as UsageTotals, C as ContextFill, h as ExecutionRecord, a3 as ResearchStep, O as PlanState, a2 as ResearchProgress, a1 as ResearchLogEntry, af as SkillLoad, Q as PlanStatus, al as SupervisorLevel, a4 as ResearchStepOutcome, T as PlannerUsage, aq as TaskIsolationState, aw as TaskUsageSummary } from './Task-CfBM0wkV.js';
2
+ import { N as IRunnerSession, K as IConfig, aL as TaskMessageFrom, ax as RunnerModelRef, ap as RunnerCommand, au as RunnerMcpServer, aE as StructuredTurnEnd, j as ApprovalDecision, aD as StructuredEvent, ah as QueuedTaskMessage, k as ApprovalKind, q as ApprovalSource, M as IRunner, ay as RunnerRegistry, J as IApproval, aU as ToolOutcome, d as AgentProcessDeps, a as AgentAdapter, a4 as OrdewellMcpServer, L as IFileSystem, aV as UsageLimitSignal, ac as PlannerToolHandler, p as ApprovalRequest, i as ApprovalAnswer, f as AiProvider, a3 as OrchestratorOption, a9 as PlannerBackendId } from './IFileSystem-lTRL_G9Z.js';
3
+ import { R as RunnerModeInfo } from './ModeResolver-CoJAJD-f.js';
4
4
 
5
5
  type NotificationAction = {
6
6
  label: string;
@@ -394,6 +394,12 @@ interface PlannerModes {
394
394
  type IsolationNoticeLevel = 'info' | 'warn' | 'error';
395
395
  /** How an attempt that may run in a worktree gets one: fresh, the kept one for a repair, or restoring the previous attempt's work. */
396
396
  type AttemptIntent = 'fresh' | 'repair' | PrepareIntent;
397
+ /**
398
+ * What adopting a persisted run found: nothing to change, landed work git
399
+ * shows the user has merged since, or a settled run that had nothing left to
400
+ * hand over and was cleared up.
401
+ */
402
+ type AdoptOutcome = 'unchanged' | 'changed' | 'cleared';
397
403
  interface AttemptWorkspace {
398
404
  cwd: string;
399
405
  worktree: boolean;
@@ -451,6 +457,8 @@ declare class IsolationRunController {
451
457
  private readonly listener;
452
458
  private readonly liveTasks;
453
459
  private run;
460
+ /** An adoption stays scoped even while cleanup temporarily leaves no run record. */
461
+ private adoptions;
454
462
  /** Copied paths already reported for the current run: every task gets the same copies. */
455
463
  private reportedCopies;
456
464
  private reportedSetupFailures;
@@ -492,13 +500,20 @@ declare class IsolationRunController {
492
500
  * Take over a plan's persisted isolation, or none for a plan that has not
493
501
  * isolated yet. Whatever a crashed process left behind for the run — a
494
502
  * worktree still marked active, a directory no record owns — is pruned,
495
- * while kept, failed and conflicted worktrees stay for the user.
503
+ * while kept, failed and conflicted worktrees stay for the user. Then git is
504
+ * asked which landed work the user has merged since the record was saved:
505
+ * a settled run whose landed work is all in HEAD has nothing left to hand
506
+ * over, so it is cleared up as Merge all would have, unless it still holds
507
+ * work that never landed (ADR-0013).
496
508
  *
497
- * Deliberately not reported as a change: adopting is not a change to
498
- * persist, and a host that adopts without persisting (VS Code's restore)
499
- * would otherwise write a new session file on every reload.
500
- */
501
- adopt(state: PlanIsolation | null): Promise<void>;
509
+ * Deliberately not reported to the listener: adopting is not a change of the
510
+ * session's own, and a host that adopts without persisting (VS Code's
511
+ * restore) would otherwise write a new session file on every reload. What
512
+ * git changed is returned instead, for the caller to save where it can and
513
+ * announce. A plan loaded meanwhile supersedes this adoption, which then
514
+ * touches nothing and resolves `unchanged`.
515
+ */
516
+ adopt(state: PlanIsolation | null): Promise<AdoptOutcome>;
502
517
  /** Open a run if none is, leaving whether it isolates to its first change task. */
503
518
  open(): void;
504
519
  /**
@@ -587,6 +602,10 @@ declare class IsolationRunController {
587
602
  * with git. Resolves true when some was found.
588
603
  */
589
604
  refreshInHead(): Promise<boolean>;
605
+ /** Mark the run's landed work git finds in HEAD; true when some was found. */
606
+ private findLanded;
607
+ /** The run landed something and every landing is in the user's HEAD. */
608
+ private allMerged;
590
609
  /**
591
610
  * The tracked state of the workspace as an attempt whose tree is checked
592
611
  * starts (see `attemptKind.checksTree`), for {@link filesChangedSince}
@@ -645,6 +664,10 @@ declare class IsolationRunController {
645
664
  * than leaving that work to a deletion.
646
665
  */
647
666
  private clearMerged;
667
+ /** The records that keep a settled run from being cleared up: live, or holding work that never landed. */
668
+ private holdouts;
669
+ /** The run's worktrees and merged branches go; false, said, when git would not let them. */
670
+ private discardMerged;
648
671
  /** Say what a removal kept back instead of deleting: where the work went, or which worktree stayed. */
649
672
  private report;
650
673
  private forget;
@@ -1403,21 +1426,19 @@ type SessionMessage =
1403
1426
  /**
1404
1427
  * The planner's running usage for the session, subagents included, emitted
1405
1428
  * after a model call reports usage. `totals` already contains every
1406
- * `bySubagent` entry. `contextFill` is the last planner prompt against the
1407
- * model's window, omitted when the window is unknown. Cost appears only as
1408
- * reported by a provider or runner (see `UsageRecord`).
1429
+ * `bySubagent` entry. `contextFill` is the context the main model's last
1430
+ * call left, with its window when known; omitted before a call was measured.
1431
+ * Cost appears only as reported by a provider or runner (see `UsageRecord`).
1409
1432
  */
1410
1433
  | {
1411
1434
  type: 'planner_usage';
1435
+ sessionBilling?: SessionBilling;
1412
1436
  byModel?: ModelUsage[];
1413
1437
  model?: string;
1414
1438
  turnId?: string;
1415
1439
  totals: UsageTotals;
1416
1440
  bySubagent?: Record<string, UsageTotals>;
1417
- contextFill?: {
1418
- usedTokens: number;
1419
- windowTokens: number;
1420
- };
1441
+ contextFill?: ContextFill;
1421
1442
  }
1422
1443
  /**
1423
1444
  * A subagent began work on `brief`. Emitted by the planner backend that
@@ -1847,6 +1868,10 @@ declare class TaskOrchestrator {
1847
1868
  private store;
1848
1869
  private output;
1849
1870
  private attempts;
1871
+ /** Bumped by every plan load: an ended attempt's wind-down belongs to the scope before it. */
1872
+ private planScope;
1873
+ /** Each task's runners still winding down once stopped: a continue waits for them (ADR-0018, L1). */
1874
+ private windDowns;
1850
1875
  private verifier;
1851
1876
  /** Changed only by start, stop, a plan load, a usage-limit pause, a move off the limit, and {@link settleRun}. */
1852
1877
  private runState;
@@ -2484,6 +2509,18 @@ declare class TaskOrchestrator {
2484
2509
  * load reset the whole verifier themselves.
2485
2510
  */
2486
2511
  private endAttempt;
2512
+ /**
2513
+ * Let the attempt's runner go the way it ends a turn (ADR-0018, L1): it
2514
+ * winds down on its own time, bounded by its interrupt grace, and nothing
2515
+ * here waits on it but a continue of the same task.
2516
+ */
2517
+ private stopRunner;
2518
+ /**
2519
+ * An ended attempt's runner is gone: the count its session ended on is the
2520
+ * one a continue of that session counts from. One still current is ended
2521
+ * with that count instead.
2522
+ */
2523
+ private woundDown;
2487
2524
  /** Kept on the task once the attempt ends, so a continue can resume it after a reload (ADR-0018, K1). */
2488
2525
  private saveNativeSession;
2489
2526
  private endAllAttempts;
@@ -2788,6 +2825,12 @@ declare class CliAgentAiService implements IAiService {
2788
2825
  * `startConversation` reseeds from Ordewell's transcript, which is the same
2789
2826
  * degradation `restoreChat` already performs on every surface.
2790
2827
  *
2828
+ * A process can end while idle without Ordewell stopping it — the OS, the
2829
+ * CLI itself, a sleeping machine, a signal sent to its group — and every
2830
+ * path of ours that kills one also drops its adapter. So an adapter still
2831
+ * held whose process has ended died on its own, and is restarted here
2832
+ * rather than answering the next message with its exit code.
2833
+ *
2791
2834
  * Also restarted when the policy's decision on the runner's own search has
2792
2835
  * changed since the process was spawned: the running thread would otherwise
2793
2836
  * keep searching unasked after Full turned Guarded. Codex 0.162 applies
@@ -4515,17 +4558,14 @@ interface RunnerLoadedBlock {
4515
4558
  commands: readonly RunnerCommand[];
4516
4559
  mcpServers: readonly RunnerMcpServer[];
4517
4560
  }
4518
- /** The token line. There is at most one, and it is always the last block. */
4561
+ /** The usage line (context and cost). Token counts ride in `totals` but are not drawn. There is at most one, and it is always the last block. */
4519
4562
  interface UsageBlock {
4520
4563
  byModel?: ModelUsage[];
4521
4564
  model?: string;
4522
4565
  type: 'usage';
4523
4566
  id: string;
4524
4567
  totals: UsageTotals;
4525
- contextFill?: {
4526
- usedTokens: number;
4527
- windowTokens: number;
4528
- };
4568
+ contextFill?: ContextFill;
4529
4569
  bySubagent?: Record<string, UsageTotals>;
4530
4570
  }
4531
4571
 
@@ -1,5 +1,5 @@
1
- import { N as IRunnerSession, ah as QueuedTaskMessage, aE as StructuredTurnEnd, aD as StructuredEvent, aJ as TaskCompleteArgs, r as CheckpointAnswer, aL as TaskMessageFrom, ap as RunnerCommand, O as InvokedCommand, j as ApprovalDecision, K as IConfig, L as IFileSystem } from './IFileSystem-DUgeWWQN.mjs';
2
- import { h as IntegrationDisposal, a5 as RunnerSessionCost, I as IWorktreeIsolation, j as IsolationAvailability, r as IsolationMergeResult, at as TreeSnapshot, a6 as SetupFailure, t as IsolationPruneResult, u as IsolationRemoval, s as IsolationOutcome, X as RepairEvidence, w as IsolationRun, ai as Task, T as PreparedTask, k as IsolationHandoff } from './Task-C0o4i3Nn.mjs';
1
+ import { N as IRunnerSession, ah as QueuedTaskMessage, aE as StructuredTurnEnd, aD as StructuredEvent, aJ as TaskCompleteArgs, r as CheckpointAnswer, aL as TaskMessageFrom, ap as RunnerCommand, O as InvokedCommand, j as ApprovalDecision, K as IConfig, L as IFileSystem } from './IFileSystem-1PqRCjhu.mjs';
2
+ import { j as IntegrationDisposal, a8 as RunnerSessionCost, I as IWorktreeIsolation, l as IsolationAvailability, t as IsolationMergeResult, ax as TreeSnapshot, aa as SetupFailure, v as IsolationPruneResult, w as IsolationRemoval, u as IsolationOutcome, Z as RepairEvidence, y as IsolationRun, am as Task, V as PreparedTask, m as IsolationHandoff } from './Task-CfBM0wkV.mjs';
3
3
  import 'child_process';
4
4
  import 'zod/v4';
5
5
 
@@ -37,9 +37,14 @@ declare class FakeRunnerSession implements IRunnerSession {
37
37
  private completeCbs;
38
38
  private checkpointHandler;
39
39
  constructor(id?: string, taskId?: string, sessionId?: string | null);
40
+ /** `stop()` was asked for: the runner winds its turn down, still reporting, until {@link emitExit}. */
41
+ stopped: boolean;
42
+ private markGone;
43
+ private readonly gone;
40
44
  onOutput(cb: (text: string) => void): void;
41
45
  onExit(cb: (code: number) => void): void;
42
46
  kill(): void;
47
+ stop(): Promise<void>;
43
48
  getOutput(): string;
44
49
  emitOutput(text: string): void;
45
50
  emitExit(code: number): void;
package/dist/testing.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { N as IRunnerSession, ah as QueuedTaskMessage, aE as StructuredTurnEnd, aD as StructuredEvent, aJ as TaskCompleteArgs, r as CheckpointAnswer, aL as TaskMessageFrom, ap as RunnerCommand, O as InvokedCommand, j as ApprovalDecision, K as IConfig, L as IFileSystem } from './IFileSystem-C4_mpfze.js';
2
- import { h as IntegrationDisposal, a5 as RunnerSessionCost, I as IWorktreeIsolation, j as IsolationAvailability, r as IsolationMergeResult, at as TreeSnapshot, a6 as SetupFailure, t as IsolationPruneResult, u as IsolationRemoval, s as IsolationOutcome, X as RepairEvidence, w as IsolationRun, ai as Task, T as PreparedTask, k as IsolationHandoff } from './Task-C0o4i3Nn.js';
1
+ import { N as IRunnerSession, ah as QueuedTaskMessage, aE as StructuredTurnEnd, aD as StructuredEvent, aJ as TaskCompleteArgs, r as CheckpointAnswer, aL as TaskMessageFrom, ap as RunnerCommand, O as InvokedCommand, j as ApprovalDecision, K as IConfig, L as IFileSystem } from './IFileSystem-lTRL_G9Z.js';
2
+ import { j as IntegrationDisposal, a8 as RunnerSessionCost, I as IWorktreeIsolation, l as IsolationAvailability, t as IsolationMergeResult, ax as TreeSnapshot, aa as SetupFailure, v as IsolationPruneResult, w as IsolationRemoval, u as IsolationOutcome, Z as RepairEvidence, y as IsolationRun, am as Task, V as PreparedTask, m as IsolationHandoff } from './Task-CfBM0wkV.js';
3
3
  import 'child_process';
4
4
  import 'zod/v4';
5
5
 
@@ -37,9 +37,14 @@ declare class FakeRunnerSession implements IRunnerSession {
37
37
  private completeCbs;
38
38
  private checkpointHandler;
39
39
  constructor(id?: string, taskId?: string, sessionId?: string | null);
40
+ /** `stop()` was asked for: the runner winds its turn down, still reporting, until {@link emitExit}. */
41
+ stopped: boolean;
42
+ private markGone;
43
+ private readonly gone;
40
44
  onOutput(cb: (text: string) => void): void;
41
45
  onExit(cb: (code: number) => void): void;
42
46
  kill(): void;
47
+ stop(): Promise<void>;
43
48
  getOutput(): string;
44
49
  emitOutput(text: string): void;
45
50
  emitExit(code: number): void;
package/dist/testing.js CHANGED
@@ -154,6 +154,12 @@ var FakeRunnerSession = class {
154
154
  eventCbs = [];
155
155
  completeCbs = [];
156
156
  checkpointHandler = null;
157
+ /** `stop()` was asked for: the runner winds its turn down, still reporting, until {@link emitExit}. */
158
+ stopped = false;
159
+ markGone;
160
+ gone = new Promise((resolve) => {
161
+ this.markGone = resolve;
162
+ });
157
163
  onOutput(cb) {
158
164
  this.outputCbs.push(cb);
159
165
  }
@@ -163,6 +169,10 @@ var FakeRunnerSession = class {
163
169
  kill() {
164
170
  this.killed = true;
165
171
  }
172
+ stop() {
173
+ this.stopped = true;
174
+ return this.gone;
175
+ }
166
176
  getOutput() {
167
177
  return this.output;
168
178
  }
@@ -172,6 +182,7 @@ var FakeRunnerSession = class {
172
182
  }
173
183
  emitExit(code) {
174
184
  for (const cb of this.exitCbs) cb(code);
185
+ this.markGone();
175
186
  }
176
187
  write(text) {
177
188
  this.written.push(text);