@caupulican/pi-adaptative 0.90.0 → 0.90.4

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 (172) hide show
  1. package/CHANGELOG.md +43 -0
  2. package/dist/core/agent-session-contracts.d.ts +2 -0
  3. package/dist/core/agent-session-contracts.d.ts.map +1 -1
  4. package/dist/core/agent-session-contracts.js.map +1 -1
  5. package/dist/core/agent-session.d.ts.map +1 -1
  6. package/dist/core/agent-session.js +5 -1
  7. package/dist/core/agent-session.js.map +1 -1
  8. package/dist/core/autonomy/bounded-completion.d.ts +10 -1
  9. package/dist/core/autonomy/bounded-completion.d.ts.map +1 -1
  10. package/dist/core/autonomy/bounded-completion.js +24 -2
  11. package/dist/core/autonomy/bounded-completion.js.map +1 -1
  12. package/dist/core/autonomy/lane-tracker.d.ts +1 -1
  13. package/dist/core/autonomy/lane-tracker.d.ts.map +1 -1
  14. package/dist/core/autonomy/lane-tracker.js +9 -1
  15. package/dist/core/autonomy/lane-tracker.js.map +1 -1
  16. package/dist/core/background-lane-controller.d.ts +1 -3
  17. package/dist/core/background-lane-controller.d.ts.map +1 -1
  18. package/dist/core/background-lane-controller.js.map +1 -1
  19. package/dist/core/compaction-controller.d.ts.map +1 -1
  20. package/dist/core/compaction-controller.js +0 -1
  21. package/dist/core/compaction-controller.js.map +1 -1
  22. package/dist/core/delegation/managed-lane-controller.d.ts.map +1 -1
  23. package/dist/core/delegation/managed-lane-controller.js +5 -1
  24. package/dist/core/delegation/managed-lane-controller.js.map +1 -1
  25. package/dist/core/delegation/worker-agent-control-coordinator.d.ts +8 -1
  26. package/dist/core/delegation/worker-agent-control-coordinator.d.ts.map +1 -1
  27. package/dist/core/delegation/worker-agent-control-coordinator.js +94 -36
  28. package/dist/core/delegation/worker-agent-control-coordinator.js.map +1 -1
  29. package/dist/core/delegation/worker-agent-control.d.ts +1 -0
  30. package/dist/core/delegation/worker-agent-control.d.ts.map +1 -1
  31. package/dist/core/delegation/worker-agent-control.js.map +1 -1
  32. package/dist/core/delegation/worker-attempt-executor.d.ts.map +1 -1
  33. package/dist/core/delegation/worker-attempt-executor.js +7 -2
  34. package/dist/core/delegation/worker-attempt-executor.js.map +1 -1
  35. package/dist/core/delegation/worker-authority-resolver.d.ts.map +1 -1
  36. package/dist/core/delegation/worker-authority-resolver.js +26 -3
  37. package/dist/core/delegation/worker-authority-resolver.js.map +1 -1
  38. package/dist/core/delegation/worker-delegation-controller.d.ts +7 -4
  39. package/dist/core/delegation/worker-delegation-controller.d.ts.map +1 -1
  40. package/dist/core/delegation/worker-delegation-controller.js +110 -27
  41. package/dist/core/delegation/worker-delegation-controller.js.map +1 -1
  42. package/dist/core/delegation/worker-fleet-limits.d.ts +9 -2
  43. package/dist/core/delegation/worker-fleet-limits.d.ts.map +1 -1
  44. package/dist/core/delegation/worker-fleet-limits.js +39 -3
  45. package/dist/core/delegation/worker-fleet-limits.js.map +1 -1
  46. package/dist/core/delegation/worker-lane-projection.d.ts.map +1 -1
  47. package/dist/core/delegation/worker-lane-projection.js +4 -0
  48. package/dist/core/delegation/worker-lane-projection.js.map +1 -1
  49. package/dist/core/delegation/worker-lease-heartbeat.d.ts +16 -0
  50. package/dist/core/delegation/worker-lease-heartbeat.d.ts.map +1 -0
  51. package/dist/core/delegation/worker-lease-heartbeat.js +37 -0
  52. package/dist/core/delegation/worker-lease-heartbeat.js.map +1 -0
  53. package/dist/core/delegation/worker-lifecycle.d.ts +1 -0
  54. package/dist/core/delegation/worker-lifecycle.d.ts.map +1 -1
  55. package/dist/core/delegation/worker-lifecycle.js +6 -0
  56. package/dist/core/delegation/worker-lifecycle.js.map +1 -1
  57. package/dist/core/delegation/worker-notification-coordinator.d.ts.map +1 -1
  58. package/dist/core/delegation/worker-notification-coordinator.js +2 -1
  59. package/dist/core/delegation/worker-notification-coordinator.js.map +1 -1
  60. package/dist/core/delegation/worker-runner.js +2 -2
  61. package/dist/core/delegation/worker-runner.js.map +1 -1
  62. package/dist/core/delegation/worker-terminal-handoff-coordinator.d.ts +1 -0
  63. package/dist/core/delegation/worker-terminal-handoff-coordinator.d.ts.map +1 -1
  64. package/dist/core/delegation/worker-terminal-handoff-coordinator.js +1 -0
  65. package/dist/core/delegation/worker-terminal-handoff-coordinator.js.map +1 -1
  66. package/dist/core/delegation/worker-tree-budget-coordinator.d.ts +4 -2
  67. package/dist/core/delegation/worker-tree-budget-coordinator.d.ts.map +1 -1
  68. package/dist/core/delegation/worker-tree-budget-coordinator.js +10 -2
  69. package/dist/core/delegation/worker-tree-budget-coordinator.js.map +1 -1
  70. package/dist/core/delegation/worker-write-reservation-coordinator.d.ts +14 -0
  71. package/dist/core/delegation/worker-write-reservation-coordinator.d.ts.map +1 -1
  72. package/dist/core/delegation/worker-write-reservation-coordinator.js +121 -33
  73. package/dist/core/delegation/worker-write-reservation-coordinator.js.map +1 -1
  74. package/dist/core/foreground-terminal-handoff-controller.d.ts +5 -0
  75. package/dist/core/foreground-terminal-handoff-controller.d.ts.map +1 -1
  76. package/dist/core/foreground-terminal-handoff-controller.js +28 -12
  77. package/dist/core/foreground-terminal-handoff-controller.js.map +1 -1
  78. package/dist/core/goals/goal-session-controller.d.ts +6 -0
  79. package/dist/core/goals/goal-session-controller.d.ts.map +1 -1
  80. package/dist/core/goals/goal-session-controller.js +16 -13
  81. package/dist/core/goals/goal-session-controller.js.map +1 -1
  82. package/dist/core/orchestration/capability-gateway.d.ts +2 -1
  83. package/dist/core/orchestration/capability-gateway.d.ts.map +1 -1
  84. package/dist/core/orchestration/capability-gateway.js +9 -2
  85. package/dist/core/orchestration/capability-gateway.js.map +1 -1
  86. package/dist/core/orchestration/contracts.d.ts +16 -1
  87. package/dist/core/orchestration/contracts.d.ts.map +1 -1
  88. package/dist/core/orchestration/contracts.js +5 -0
  89. package/dist/core/orchestration/contracts.js.map +1 -1
  90. package/dist/core/orchestration/profile-registry.d.ts.map +1 -1
  91. package/dist/core/orchestration/profile-registry.js +38 -1
  92. package/dist/core/orchestration/profile-registry.js.map +1 -1
  93. package/dist/core/orchestration/risk-budget.d.ts +10 -0
  94. package/dist/core/orchestration/risk-budget.d.ts.map +1 -1
  95. package/dist/core/orchestration/risk-budget.js +14 -0
  96. package/dist/core/orchestration/risk-budget.js.map +1 -1
  97. package/dist/core/orchestration/task-runtime-reducer.d.ts +1 -0
  98. package/dist/core/orchestration/task-runtime-reducer.d.ts.map +1 -1
  99. package/dist/core/orchestration/task-runtime-reducer.js +34 -0
  100. package/dist/core/orchestration/task-runtime-reducer.js.map +1 -1
  101. package/dist/core/orchestration/task-runtime.d.ts +1 -0
  102. package/dist/core/orchestration/task-runtime.d.ts.map +1 -1
  103. package/dist/core/orchestration/task-runtime.js +24 -1
  104. package/dist/core/orchestration/task-runtime.js.map +1 -1
  105. package/dist/core/provider-prompt-contracts.d.ts.map +1 -1
  106. package/dist/core/provider-prompt-contracts.js +2 -1
  107. package/dist/core/provider-prompt-contracts.js.map +1 -1
  108. package/dist/core/reflection-controller.d.ts.map +1 -1
  109. package/dist/core/reflection-controller.js +8 -1
  110. package/dist/core/reflection-controller.js.map +1 -1
  111. package/dist/core/settings-manager.d.ts +2 -2
  112. package/dist/core/settings-manager.d.ts.map +1 -1
  113. package/dist/core/settings-manager.js +2 -2
  114. package/dist/core/settings-manager.js.map +1 -1
  115. package/dist/core/tools/bash.d.ts +3 -0
  116. package/dist/core/tools/bash.d.ts.map +1 -1
  117. package/dist/core/tools/bash.js +13 -2
  118. package/dist/core/tools/bash.js.map +1 -1
  119. package/dist/core/tools/delegate-status.d.ts +1 -0
  120. package/dist/core/tools/delegate-status.d.ts.map +1 -1
  121. package/dist/core/tools/delegate-status.js +19 -1
  122. package/dist/core/tools/delegate-status.js.map +1 -1
  123. package/dist/core/tools/delegate.d.ts +9 -1
  124. package/dist/core/tools/delegate.d.ts.map +1 -1
  125. package/dist/core/tools/delegate.js +198 -64
  126. package/dist/core/tools/delegate.js.map +1 -1
  127. package/dist/core/tools/edit.d.ts.map +1 -1
  128. package/dist/core/tools/edit.js +14 -1
  129. package/dist/core/tools/edit.js.map +1 -1
  130. package/dist/core/tools/file-failure-recovery.d.ts +3 -0
  131. package/dist/core/tools/file-failure-recovery.d.ts.map +1 -1
  132. package/dist/core/tools/file-failure-recovery.js +11 -0
  133. package/dist/core/tools/file-failure-recovery.js.map +1 -1
  134. package/dist/core/tools/orchestration-panel.d.ts +1 -1
  135. package/dist/core/tools/orchestration-panel.d.ts.map +1 -1
  136. package/dist/core/tools/orchestration-panel.js +1 -0
  137. package/dist/core/tools/orchestration-panel.js.map +1 -1
  138. package/dist/core/tools/profile-writer.d.ts.map +1 -1
  139. package/dist/core/tools/profile-writer.js +2 -8
  140. package/dist/core/tools/profile-writer.js.map +1 -1
  141. package/dist/core/tools/search-command-guard.d.ts.map +1 -1
  142. package/dist/core/tools/search-command-guard.js +10 -3
  143. package/dist/core/tools/search-command-guard.js.map +1 -1
  144. package/dist/core/tools/tool-task.d.ts.map +1 -1
  145. package/dist/core/tools/tool-task.js +4 -0
  146. package/dist/core/tools/tool-task.js.map +1 -1
  147. package/dist/core/tools/write.d.ts.map +1 -1
  148. package/dist/core/tools/write.js +10 -1
  149. package/dist/core/tools/write.js.map +1 -1
  150. package/dist/modes/interactive/components/activity-lane.d.ts +1 -1
  151. package/dist/modes/interactive/components/activity-lane.d.ts.map +1 -1
  152. package/dist/modes/interactive/components/activity-lane.js +11 -2
  153. package/dist/modes/interactive/components/activity-lane.js.map +1 -1
  154. package/dist/modes/interactive/components/settings-selector.js +1 -1
  155. package/dist/modes/interactive/components/settings-selector.js.map +1 -1
  156. package/dist/utils/shell.d.ts +2 -0
  157. package/dist/utils/shell.d.ts.map +1 -1
  158. package/dist/utils/shell.js +3 -1
  159. package/dist/utils/shell.js.map +1 -1
  160. package/docs/harness-architecture.md +6 -3
  161. package/docs/settings.md +8 -6
  162. package/docs/tool-repair.md +1 -1
  163. package/docs/worker-profiles.md +2 -2
  164. package/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
  165. package/examples/extensions/custom-provider-anthropic/package.json +1 -1
  166. package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
  167. package/examples/extensions/sandbox/package-lock.json +2 -2
  168. package/examples/extensions/sandbox/package.json +1 -1
  169. package/examples/extensions/with-deps/package-lock.json +2 -2
  170. package/examples/extensions/with-deps/package.json +1 -1
  171. package/npm-shrinkwrap.json +12 -12
  172. package/package.json +4 -4
@@ -8,7 +8,16 @@ export interface BoundedCompletion {
8
8
  costUsd: number;
9
9
  stopReason: string;
10
10
  }
11
- export type BoundedCompletionFailureStatus = "canceled" | "timeout" | "failed";
11
+ export type BoundedCompletionFailureStatus = "canceled" | "timeout" | "failed" | "budget_exhausted";
12
+ /**
13
+ * Typed failure crossing the executor boundary. Policy owners use this instead of forcing the
14
+ * completion envelope to infer a bounded denial from human-readable error text.
15
+ */
16
+ export declare class BoundedCompletionFailureError extends Error {
17
+ readonly status: BoundedCompletionFailureStatus;
18
+ readonly reasonCode: string;
19
+ constructor(status: BoundedCompletionFailureStatus, reasonCode: string, message: string);
20
+ }
12
21
  export interface BoundedCompletionOutcome {
13
22
  /** Present when the executor settled; may coexist with `failure` when an abort raced the result. */
14
23
  completion?: BoundedCompletion;
@@ -1 +1 @@
1
- {"version":3,"file":"bounded-completion.d.ts","sourceRoot":"","sources":["../../../src/core/autonomy/bounded-completion.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AAEH,MAAM,WAAW,iBAAiB;IACjC,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,MAAM,8BAA8B,GAAG,UAAU,GAAG,SAAS,GAAG,QAAQ,CAAC;AAE/E,MAAM,WAAW,wBAAwB;IACxC,oGAAoG;IACpG,UAAU,CAAC,EAAE,iBAAiB,CAAC;IAC/B,OAAO,CAAC,EAAE;QAAE,MAAM,EAAE,8BAA8B,CAAC;QAAC,UAAU,EAAE,MAAM,CAAC;QA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,GAAG,MAAM,GAAG,SAAS,CAIvE;AA2BD,wBAAsB,oBAAoB,CAAC,IAAI,EAAE;IAChD,qDAAqD;IACrD,cAAc,EAAE,MAAM,CAAC;IACvB,qDAAqD;IACrD,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,OAAO,EAAE,CAAC,MAAM,EAAE,WAAW,KAAK,OAAO,CAAC,iBAAiB,CAAC,CAAC;CAC7D,GAAG,OAAO,CAAC,wBAAwB,CAAC,CAmFpC"}
@@ -1,4 +1,16 @@
1
1
  import { boundedRedactedDiagnosticText } from "../security/secret-text.js";
2
+ /**
3
+ * Typed failure crossing the executor boundary. Policy owners use this instead of forcing the
4
+ * completion envelope to infer a bounded denial from human-readable error text.
5
+ */
6
+ export class BoundedCompletionFailureError extends Error {
7
+ constructor(status, reasonCode, message) {
8
+ super(message);
9
+ this.name = "BoundedCompletionFailureError";
10
+ this.status = status;
11
+ this.reasonCode = reasonCode;
12
+ }
13
+ }
2
14
  /**
3
15
  * Preserve the executor's actual error alongside the stable reason code. A bare
4
16
  * `completion_error` is undiagnosable from lane records alone (field lesson: workers dying
@@ -18,6 +30,17 @@ function abortFailure(args) {
18
30
  return { status: "timeout", reasonCode: "wall_clock_exceeded" };
19
31
  return { status: "failed", reasonCode: "completion_error" };
20
32
  }
33
+ function executorFailure(error) {
34
+ const detail = boundedFailureDetail(error);
35
+ if (error instanceof BoundedCompletionFailureError) {
36
+ return {
37
+ status: error.status,
38
+ reasonCode: error.reasonCode,
39
+ ...(detail ? { detail } : {}),
40
+ };
41
+ }
42
+ return { status: "failed", reasonCode: "completion_error", ...(detail ? { detail } : {}) };
43
+ }
21
44
  export async function runBoundedCompletion(args) {
22
45
  const timeoutController = new AbortController();
23
46
  let resolveAbort;
@@ -78,11 +101,10 @@ export async function runBoundedCompletion(args) {
78
101
  };
79
102
  }
80
103
  if (winner.kind === "error") {
81
- const detail = boundedFailureDetail(winner.error);
82
104
  return {
83
105
  failure: args.signal?.aborted || timeoutController.signal.aborted
84
106
  ? abortFailure({ externalSignal: args.signal, timeoutSignal: timeoutController.signal })
85
- : { status: "failed", reasonCode: "completion_error", ...(detail ? { detail } : {}) },
107
+ : executorFailure(winner.error),
86
108
  };
87
109
  }
88
110
  const completion = winner.completion;
@@ -1 +1 @@
1
- {"version":3,"file":"bounded-completion.js","sourceRoot":"","sources":["../../../src/core/autonomy/bounded-completion.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,6BAA6B,EAAE,MAAM,4BAA4B,CAAC;AAsB3E;;;;GAIG;AACH,MAAM,UAAU,oBAAoB,CAAC,KAAc;IAClD,MAAM,OAAO,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC;IACvG,IAAI,CAAC,OAAO;QAAE,OAAO,SAAS,CAAC;IAC/B,OAAO,6BAA6B,CAAC,OAAO,CAAC,CAAC;AAC/C,CAAC;AAID,MAAM,uBAAuB,GAAG,aAAa,CAAC;AAE9C,SAAS,YAAY,CAAC,IAGrB;IACA,IAAI,IAAI,CAAC,cAAc,EAAE,OAAO;QAAE,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,UAAU,EAAE,gBAAgB,EAAE,CAAC;IAC9F,IAAI,IAAI,CAAC,aAAa,CAAC,OAAO;QAAE,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,UAAU,EAAE,qBAAqB,EAAE,CAAC;IAChG,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,UAAU,EAAE,kBAAkB,EAAE,CAAC;AAC7D,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,oBAAoB,CAAC,IAM1C;IACA,MAAM,iBAAiB,GAAG,IAAI,eAAe,EAAE,CAAC;IAChD,IAAI,YAAyB,CAAC;IAC9B,MAAM,YAAY,GAAG,IAAI,OAAO,CAAoB,CAAC,OAAO,EAAE,EAAE;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AI,KAAK,OAAO,EAAE,CAAC;YAC7B,MAAM,MAAM,GAAG,oBAAoB,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;YAClD,OAAO;gBACN,OAAO,EACN,IAAI,CAAC,MAAM,EAAE,OAAO,IAAI,iBAAiB,CAAC,MAAM,CAAC,OAAO;oBACvD,CAAC,CAAC,YAAY,CAAC,EAAE,cAAc,EAAE,IAAI,CAAC,MAAM,EAAE,aAAa,EAAE,iBAAiB,CAAC,MAAM,EAAE,CAAC;oBACxF,CAAC,CAAC,EAAE,MAAM,EAAE,QAAQ,EAAE,UAAU,EAAE,kBAAkB,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE;aACvF,CAAC;QACH,CAAC;QAED,MAAM,UAAU,GAAG,MAAM,CAAC,UAAU,CAAC;QACrC,IAAI,IAAI,CAAC,MAAM,EAAE,OAAO,IAAI,iBAAiB,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;YAC9D,OAAO;gBACN,UAAU;gBACV,OAAO,EAAE,YAAY,CAAC,EAAE,cAAc,EAAE,IAAI,CAAC,MAAM,EAAE,aAAa,EAAE,iBAAiB,CAAC,MAAM,EAAE,CAAC;aAC/F,CAAC;QACH,CAAC;QACD,OAAO,EAAE,UAAU,EAAE,CAAC;IACvB,CAAC;YAAS,CAAC;QACV,IAAI,YAAY,KAAK,SAAS;YAAE,YAAY,CAAC,YAAY,CAAC,CAAC;QAC3D,IAAI,CAAC,MAAM,EAAE,mBAAmB,CAAC,OAAO,EAAE,eAAe,CAAC,CAAC;IAC5D,CAAC;AACF,CAAC","sourcesContent":["import { boundedRedactedDiagnosticText } from \"../security/secret-text.ts\";\n\n/**\n * Shared wall-clock/cancellation envelope for one-shot lane completions (research and delegated workers).\n * Composes an optional external abort signal with an internal wall-clock timeout, executes the\n * injected completion, and maps every failure to a stable status/reasonCode pair. Never throws.\n */\n\nexport interface BoundedCompletion {\n\ttext: string;\n\tcostUsd: number;\n\tstopReason: string;\n}\n\nexport type BoundedCompletionFailureStatus = \"canceled\" | \"timeout\" | \"failed\";\n\nexport interface BoundedCompletionOutcome {\n\t/** Present when the executor settled; may coexist with `failure` when an abort raced the result. */\n\tcompletion?: BoundedCompletion;\n\tfailure?: { status: BoundedCompletionFailureStatus; reasonCode: string; detail?: string };\n}\n\n/**\n * Preserve the executor's actual error alongside the stable reason code. A bare\n * `completion_error` is undiagnosable from lane records alone (field lesson: workers dying\n * on provider socket drops and budget denials all flattened to the same code).\n */\nexport function boundedFailureDetail(error: unknown): string | undefined {\n\tconst message = error instanceof Error ? error.message : typeof error === \"string\" ? error : undefined;\n\tif (!message) return undefined;\n\treturn boundedRedactedDiagnosticText(message);\n}\n\ntype ExecutorSettlement = { kind: \"completion\"; completion: BoundedCompletion } | { kind: \"error\"; error: unknown };\n\nconst MAX_HOST_TIMER_DELAY_MS = 2_147_483_647;\n\nfunction abortFailure(args: {\n\texternalSignal?: AbortSignal;\n\ttimeoutSignal: AbortSignal;\n}): BoundedCompletionOutcome[\"failure\"] {\n\tif (args.externalSignal?.aborted) return { status: \"canceled\", reasonCode: \"external_abort\" };\n\tif (args.timeoutSignal.aborted) return { status: \"timeout\", reasonCode: \"wall_clock_exceeded\" };\n\treturn { status: \"failed\", reasonCode: \"completion_error\" };\n}\n\nexport async function runBoundedCompletion(args: {\n\t/** Wall-clock budget in milliseconds; 0 disables. */\n\tmaxWallClockMs: number;\n\t/** External cancellation (e.g. session disposal). */\n\tsignal?: AbortSignal;\n\texecute: (signal: AbortSignal) => Promise<BoundedCompletion>;\n}): Promise<BoundedCompletionOutcome> {\n\tconst timeoutController = new AbortController();\n\tlet resolveAbort!: () => void;\n\tconst abortPromise = new Promise<{ kind: \"abort\" }>((resolve) => {\n\t\tresolveAbort = () => resolve({ kind: \"abort\" });\n\t});\n\tconst onExternalAbort = (): void => resolveAbort();\n\targs.signal?.addEventListener(\"abort\", onExternalAbort, { once: true });\n\tlet timeoutTimer: ReturnType<typeof setTimeout> | undefined;\n\tlet remainingWallClockMs = args.maxWallClockMs;\n\tconst armTimeout = (): void => {\n\t\tconst delayMs = Math.min(remainingWallClockMs, MAX_HOST_TIMER_DELAY_MS);\n\t\ttimeoutTimer = setTimeout(() => {\n\t\t\tremainingWallClockMs -= delayMs;\n\t\t\tif (remainingWallClockMs > 0) {\n\t\t\t\tarmTimeout();\n\t\t\t\treturn;\n\t\t\t}\n\t\t\ttimeoutController.abort();\n\t\t\tresolveAbort();\n\t\t}, delayMs);\n\t\tif (typeof timeoutTimer === \"object\" && \"unref\" in timeoutTimer) {\n\t\t\tconst { unref } = timeoutTimer as { unref?: () => void };\n\t\t\tunref?.call(timeoutTimer);\n\t\t}\n\t};\n\tif (args.maxWallClockMs > 0) armTimeout();\n\tconst signals: AbortSignal[] = [timeoutController.signal];\n\tif (args.signal) signals.push(args.signal);\n\tconst signal = AbortSignal.any(signals);\n\n\tlet settled: ExecutorSettlement | undefined;\n\tconst execution = Promise.resolve()\n\t\t.then(() => args.execute(signal))\n\t\t.then<ExecutorSettlement, ExecutorSettlement>(\n\t\t\t(completion) => {\n\t\t\t\tsettled = { kind: \"completion\", completion };\n\t\t\t\treturn settled;\n\t\t\t},\n\t\t\t(error: unknown) => {\n\t\t\t\tsettled = { kind: \"error\", error };\n\t\t\t\treturn settled;\n\t\t\t},\n\t\t);\n\tif (args.signal?.aborted) resolveAbort();\n\n\ttry {\n\t\tconst winner = await Promise.race([execution, abortPromise]);\n\t\tif (winner.kind === \"abort\") {\n\t\t\t// An abort and a completion can settle in the same microtask turn. Give the already-queued\n\t\t\t// executor handlers one chance to retain that completion (and its visible spend) without\n\t\t\t// ever waiting for a non-cooperative executor. Later settlement remains observed by\n\t\t\t// `execution`'s rejection handler, preventing an unhandled rejection after this returns.\n\t\t\tfor (let flush = 0; flush < 4 && settled === undefined; flush++) {\n\t\t\t\tawait Promise.resolve();\n\t\t\t}\n\t\t\treturn {\n\t\t\t\t...(settled?.kind === \"completion\" ? { completion: settled.completion } : {}),\n\t\t\t\tfailure: abortFailure({ externalSignal: args.signal, timeoutSignal: timeoutController.signal }),\n\t\t\t};\n\t\t}\n\n\t\tif (winner.kind === \"error\") {\n\t\t\tconst detail = boundedFailureDetail(winner.error);\n\t\t\treturn {\n\t\t\t\tfailure:\n\t\t\t\t\targs.signal?.aborted || timeoutController.signal.aborted\n\t\t\t\t\t\t? abortFailure({ externalSignal: args.signal, timeoutSignal: timeoutController.signal })\n\t\t\t\t\t\t: { status: \"failed\", reasonCode: \"completion_error\", ...(detail ? { detail } : {}) },\n\t\t\t};\n\t\t}\n\n\t\tconst completion = winner.completion;\n\t\tif (args.signal?.aborted || timeoutController.signal.aborted) {\n\t\t\treturn {\n\t\t\t\tcompletion,\n\t\t\t\tfailure: abortFailure({ externalSignal: args.signal, timeoutSignal: timeoutController.signal }),\n\t\t\t};\n\t\t}\n\t\treturn { completion };\n\t} finally {\n\t\tif (timeoutTimer !== undefined) clearTimeout(timeoutTimer);\n\t\targs.signal?.removeEventListener(\"abort\", onExternalAbort);\n\t}\n}\n"]}
1
+ {"version":3,"file":"bounded-completion.js","sourceRoot":"","sources":["../../../src/core/autonomy/bounded-completion.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,6BAA6B,EAAE,MAAM,4BAA4B,CAAC;AAgB3E;;;GAGG;AACH,MAAM,OAAO,6BAA8B,SAAQ,KAAK;IAIvD,YAAY,MAAsC,EAAE,UAAkB,EAAE,OAAe;QACtF,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,+BAA+B,CAAC;QAC5C,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;IAC9B,CAAC;CACD;AAQD;;;;GAIG;AACH,MAAM,UAAU,oBAAoB,CAAC,KAAc;IAClD,MAAM,OAAO,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,O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AC,MAAM,EAAE,CAAC;aAC/F,CAAC;QACH,CAAC;QAED,IAAI,MAAM,CAAC,IAAI,KAAK,OAAO,EAAE,CAAC;YAC7B,OAAO;gBACN,OAAO,EACN,IAAI,CAAC,MAAM,EAAE,OAAO,IAAI,iBAAiB,CAAC,MAAM,CAAC,OAAO;oBACvD,CAAC,CAAC,YAAY,CAAC,EAAE,cAAc,EAAE,IAAI,CAAC,MAAM,EAAE,aAAa,EAAE,iBAAiB,CAAC,MAAM,EAAE,CAAC;oBACxF,CAAC,CAAC,eAAe,CAAC,MAAM,CAAC,KAAK,CAAC;aACjC,CAAC;QACH,CAAC;QAED,MAAM,UAAU,GAAG,MAAM,CAAC,UAAU,CAAC;QACrC,IAAI,IAAI,CAAC,MAAM,EAAE,OAAO,IAAI,iBAAiB,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;YAC9D,OAAO;gBACN,UAAU;gBACV,OAAO,EAAE,YAAY,CAAC,EAAE,cAAc,EAAE,IAAI,CAAC,MAAM,EAAE,aAAa,EAAE,iBAAiB,CAAC,MAAM,EAAE,CAAC;aAC/F,CAAC;QACH,CAAC;QACD,OAAO,EAAE,UAAU,EAAE,CAAC;IACvB,CAAC;YAAS,CAAC;QACV,IAAI,YAAY,KAAK,SAAS;YAAE,YAAY,CAAC,YAAY,CAAC,CAAC;QAC3D,IAAI,CAAC,MAAM,EAAE,mBAAmB,CAAC,OAAO,EAAE,eAAe,CAAC,CAAC;IAC5D,CAAC;AACF,CAAC","sourcesContent":["import { boundedRedactedDiagnosticText } from \"../security/secret-text.ts\";\n\n/**\n * Shared wall-clock/cancellation envelope for one-shot lane completions (research and delegated workers).\n * Composes an optional external abort signal with an internal wall-clock timeout, executes the\n * injected completion, and maps every failure to a stable status/reasonCode pair. Never throws.\n */\n\nexport interface BoundedCompletion {\n\ttext: string;\n\tcostUsd: number;\n\tstopReason: string;\n}\n\nexport type BoundedCompletionFailureStatus = \"canceled\" | \"timeout\" | \"failed\" | \"budget_exhausted\";\n\n/**\n * Typed failure crossing the executor boundary. Policy owners use this instead of forcing the\n * completion envelope to infer a bounded denial from human-readable error text.\n */\nexport class BoundedCompletionFailureError extends Error {\n\treadonly status: BoundedCompletionFailureStatus;\n\treadonly reasonCode: string;\n\n\tconstructor(status: BoundedCompletionFailureStatus, reasonCode: string, message: string) {\n\t\tsuper(message);\n\t\tthis.name = \"BoundedCompletionFailureError\";\n\t\tthis.status = status;\n\t\tthis.reasonCode = reasonCode;\n\t}\n}\n\nexport interface BoundedCompletionOutcome {\n\t/** Present when the executor settled; may coexist with `failure` when an abort raced the result. */\n\tcompletion?: BoundedCompletion;\n\tfailure?: { status: BoundedCompletionFailureStatus; reasonCode: string; detail?: string };\n}\n\n/**\n * Preserve the executor's actual error alongside the stable reason code. A bare\n * `completion_error` is undiagnosable from lane records alone (field lesson: workers dying\n * on provider socket drops and budget denials all flattened to the same code).\n */\nexport function boundedFailureDetail(error: unknown): string | undefined {\n\tconst message = error instanceof Error ? error.message : typeof error === \"string\" ? error : undefined;\n\tif (!message) return undefined;\n\treturn boundedRedactedDiagnosticText(message);\n}\n\ntype ExecutorSettlement = { kind: \"completion\"; completion: BoundedCompletion } | { kind: \"error\"; error: unknown };\n\nconst MAX_HOST_TIMER_DELAY_MS = 2_147_483_647;\n\nfunction abortFailure(args: {\n\texternalSignal?: AbortSignal;\n\ttimeoutSignal: AbortSignal;\n}): BoundedCompletionOutcome[\"failure\"] {\n\tif (args.externalSignal?.aborted) return { status: \"canceled\", reasonCode: \"external_abort\" };\n\tif (args.timeoutSignal.aborted) return { status: \"timeout\", reasonCode: \"wall_clock_exceeded\" };\n\treturn { status: \"failed\", reasonCode: \"completion_error\" };\n}\n\nfunction executorFailure(error: unknown): BoundedCompletionOutcome[\"failure\"] {\n\tconst detail = boundedFailureDetail(error);\n\tif (error instanceof BoundedCompletionFailureError) {\n\t\treturn {\n\t\t\tstatus: error.status,\n\t\t\treasonCode: error.reasonCode,\n\t\t\t...(detail ? { detail } : {}),\n\t\t};\n\t}\n\treturn { status: \"failed\", reasonCode: \"completion_error\", ...(detail ? { detail } : {}) };\n}\n\nexport async function runBoundedCompletion(args: {\n\t/** Wall-clock budget in milliseconds; 0 disables. */\n\tmaxWallClockMs: number;\n\t/** External cancellation (e.g. session disposal). */\n\tsignal?: AbortSignal;\n\texecute: (signal: AbortSignal) => Promise<BoundedCompletion>;\n}): Promise<BoundedCompletionOutcome> {\n\tconst timeoutController = new AbortController();\n\tlet resolveAbort!: () => void;\n\tconst abortPromise = new Promise<{ kind: \"abort\" }>((resolve) => {\n\t\tresolveAbort = () => resolve({ kind: \"abort\" });\n\t});\n\tconst onExternalAbort = (): void => resolveAbort();\n\targs.signal?.addEventListener(\"abort\", onExternalAbort, { once: true });\n\tlet timeoutTimer: ReturnType<typeof setTimeout> | undefined;\n\tlet remainingWallClockMs = args.maxWallClockMs;\n\tconst armTimeout = (): void => {\n\t\tconst delayMs = Math.min(remainingWallClockMs, MAX_HOST_TIMER_DELAY_MS);\n\t\ttimeoutTimer = setTimeout(() => {\n\t\t\tremainingWallClockMs -= delayMs;\n\t\t\tif (remainingWallClockMs > 0) {\n\t\t\t\tarmTimeout();\n\t\t\t\treturn;\n\t\t\t}\n\t\t\ttimeoutController.abort();\n\t\t\tresolveAbort();\n\t\t}, delayMs);\n\t\tif (typeof timeoutTimer === \"object\" && \"unref\" in timeoutTimer) {\n\t\t\tconst { unref } = timeoutTimer as { unref?: () => void };\n\t\t\tunref?.call(timeoutTimer);\n\t\t}\n\t};\n\tif (args.maxWallClockMs > 0) armTimeout();\n\tconst signals: AbortSignal[] = [timeoutController.signal];\n\tif (args.signal) signals.push(args.signal);\n\tconst signal = AbortSignal.any(signals);\n\n\tlet settled: ExecutorSettlement | undefined;\n\tconst execution = Promise.resolve()\n\t\t.then(() => args.execute(signal))\n\t\t.then<ExecutorSettlement, ExecutorSettlement>(\n\t\t\t(completion) => {\n\t\t\t\tsettled = { kind: \"completion\", completion };\n\t\t\t\treturn settled;\n\t\t\t},\n\t\t\t(error: unknown) => {\n\t\t\t\tsettled = { kind: \"error\", error };\n\t\t\t\treturn settled;\n\t\t\t},\n\t\t);\n\tif (args.signal?.aborted) resolveAbort();\n\n\ttry {\n\t\tconst winner = await Promise.race([execution, abortPromise]);\n\t\tif (winner.kind === \"abort\") {\n\t\t\t// An abort and a completion can settle in the same microtask turn. Give the already-queued\n\t\t\t// executor handlers one chance to retain that completion (and its visible spend) without\n\t\t\t// ever waiting for a non-cooperative executor. Later settlement remains observed by\n\t\t\t// `execution`'s rejection handler, preventing an unhandled rejection after this returns.\n\t\t\tfor (let flush = 0; flush < 4 && settled === undefined; flush++) {\n\t\t\t\tawait Promise.resolve();\n\t\t\t}\n\t\t\treturn {\n\t\t\t\t...(settled?.kind === \"completion\" ? { completion: settled.completion } : {}),\n\t\t\t\tfailure: abortFailure({ externalSignal: args.signal, timeoutSignal: timeoutController.signal }),\n\t\t\t};\n\t\t}\n\n\t\tif (winner.kind === \"error\") {\n\t\t\treturn {\n\t\t\t\tfailure:\n\t\t\t\t\targs.signal?.aborted || timeoutController.signal.aborted\n\t\t\t\t\t\t? abortFailure({ externalSignal: args.signal, timeoutSignal: timeoutController.signal })\n\t\t\t\t\t\t: executorFailure(winner.error),\n\t\t\t};\n\t\t}\n\n\t\tconst completion = winner.completion;\n\t\tif (args.signal?.aborted || timeoutController.signal.aborted) {\n\t\t\treturn {\n\t\t\t\tcompletion,\n\t\t\t\tfailure: abortFailure({ externalSignal: args.signal, timeoutSignal: timeoutController.signal }),\n\t\t\t};\n\t\t}\n\t\treturn { completion };\n\t} finally {\n\t\tif (timeoutTimer !== undefined) clearTimeout(timeoutTimer);\n\t\targs.signal?.removeEventListener(\"abort\", onExternalAbort);\n\t}\n}\n"]}
@@ -6,7 +6,7 @@
6
6
  * snapshots. Terminal lane records are persisted separately via `session-lane-record.ts`.
7
7
  */
8
8
  export type LaneType = "research" | "worker" | "learning" | "tmux-worker";
9
- export type LaneTerminalStatus = "succeeded" | "failed" | "canceled" | "timeout" | "budget_exhausted";
9
+ export type LaneTerminalStatus = "succeeded" | "partial" | "blocked" | "failed" | "canceled" | "timeout" | "budget_exhausted";
10
10
  export type LaneStatus = "queued" | "running" | LaneTerminalStatus;
11
11
  export interface LaneRecord {
12
12
  laneId: string;
@@ -1 +1 @@
1
- {"version":3,"file":"lane-tracker.d.ts","sourceRoot":"","sources":["../../../src/core/autonomy/lane-tracker.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,MAAM,MAAM,QAAQ,GAAG,UAAU,GAAG,QAAQ,GAAG,UAAU,GAAG,aAAa,CAAC;AAE1E,MAAM,MAAM,kBAAkB,GAAG,WAAW,GAAG,QAAQ,GAAG,UAAU,GAAG,SAAS,GAAG,kBAAkB,CAAC;AAEtG,MAAM,MAAM,UAAU,GAAG,QAAQ,GAAG,SAAS,GAAG,kBAAkB,CAAC;AAEnE,MAAM,WAAW,UAAU;IAC1B,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,QAAQ,CAAC;IACf,MAAM,EAAE,UAAU,CAAC;IACnB,wEAAwE;IACxE,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,yFAAyF;IACzF,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB;;;;;OAKG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;CACzB;AAMD,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,kBAAkB,CAEhF;AAMD,wBAAgB,YAAY,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,UAAU,CAkBhE;AAED,wBAAgB,yBAAyB,CAAC,MAAM,EAAE,UAA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,EAAE,MAAM,CAAA;KAAE,GACnG,UAAU,GAAG,SAAS,CAcxB;IAED,cAAc,CAAC,IAAI,CAAC,EAAE,QAAQ,GAAG,MAAM,CAQtC;IAED,eAAe,CAAC,IAAI,CAAC,EAAE,QAAQ,GAAG,MAAM,CAQvC;IAED,UAAU,IAAI,UAAU,EAAE,CAEzB;IAED,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,UAAU,GAAG,SAAS,CAGhD;CACD"}
@@ -6,7 +6,15 @@
6
6
  * snapshots. Terminal lane records are persisted separately via `session-lane-record.ts`.
7
7
  */
8
8
  const LANE_TYPES = ["research", "worker", "learning", "tmux-worker"];
9
- const TERMINAL_STATUSES = ["succeeded", "failed", "canceled", "timeout", "budget_exhausted"];
9
+ const TERMINAL_STATUSES = [
10
+ "succeeded",
11
+ "partial",
12
+ "blocked",
13
+ "failed",
14
+ "canceled",
15
+ "timeout",
16
+ "budget_exhausted",
17
+ ];
10
18
  const LANE_STATUSES = ["queued", "running", ...TERMINAL_STATUSES];
11
19
  export function isLaneTerminalStatus(value) {
12
20
  return typeof value === "string" && TERMINAL_STATUSES.includes(value);
@@ -1 +1 @@
1
- {"version":3,"file":"lane-tracker.js","sourceRoot":"","sources":["../../../src/core/autonomy/lane-tracker.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AA+BH,MAAM,UAAU,GAAsB,CAAC,UAAU,EAAE,QAAQ,EAAE,UAAU,EAAE,aAAa,CAAC,CAAC;AACxF,MAAM,iBAAiB,GAAsB,CAAC,WAAW,EAAE,QAAQ,EAAE,UAAU,EAAE,SAAS,EAAE,kBAAkB,CAAC,CAAC;AAChH,MAAM,aAAa,GAAsB,CAAC,QAAQ,EAAE,SAAS,EAAE,GAAG,iBAAiB,CAAC,CAAC;AAErF,MAAM,UAAU,oBAAoB,CAAC,KAAc;IAClD,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,iBAAiB,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;AACvE,CAAC;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,MAAM,IAAI,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,EAAE,CAAC;YAC3C,IAAI,oBAAoB,CAAC,MAAM,CAAC,MAAM,CAAC;gBAAE,SAAS;YAClD,IAAI,IAAI,KAAK,SAAS,IAAI,MAAM,CAAC,IAAI,KAAK,IAAI;gBAAE,SAAS;YACzD,KAAK,EAAE,CAAC;QACT,CAAC;QACD,OAAO,KAAK,CAAC;IACd,CAAC;IAED,eAAe,CAAC,IAAe;QAC9B,IAAI,KAAK,GAAG,CAAC,CAAC;QACd,KAAK,MAAM,MAAM,IAAI,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,EAAE,CAAC;YAC3C,IAAI,MAAM,CAAC,MAAM,KAAK,SAAS;gBAAE,SAAS;YAC1C,IAAI,IAAI,KAAK,SAAS,IAAI,MAAM,CAAC,IAAI,KAAK,IAAI;gBAAE,SAAS;YACzD,KAAK,EAAE,CAAC;QACT,CAAC;QACD,OAAO,KAAK,CAAC;IACd,CAAC;IAED,UAAU;QACT,OAAO,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,MAAM,EAAE,CAAC,CAAC,CAAC;IACnE,CAAC;IAED,SAAS,CAAC,MAAc;QACvB,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;QACvC,OAAO,MAAM,CAAC,CAAC,CAAC,EAAE,GAAG,MAAM,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;IAC3C,CAAC;CACD","sourcesContent":["/**\n * Live lane registry for autonomous background work (research/worker/learning lanes).\n *\n * This is the first real concurrency tracker behind `AutonomyStatusSnapshot.activeLaneCount`:\n * counts reflect lanes actually running in THIS process, never inferred/faked from historical\n * snapshots. Terminal lane records are persisted separately via `session-lane-record.ts`.\n */\n\nexport type LaneType = \"research\" | \"worker\" | \"learning\" | \"tmux-worker\";\n\nexport type LaneTerminalStatus = \"succeeded\" | \"failed\" | \"canceled\" | \"timeout\" | \"budget_exhausted\";\n\nexport type LaneStatus = \"queued\" | \"running\" | LaneTerminalStatus;\n\nexport interface LaneRecord {\n\tlaneId: string;\n\ttype: LaneType;\n\tstatus: LaneStatus;\n\t/** Bounded human-readable work label retained across session resume. */\n\tlabel?: string;\n\t/** Owner-authored profile that fixed the worker's model, thinking, tools, and budget. */\n\tprofileId?: string;\n\treasonCode?: string;\n\tstartedAt?: string;\n\tcompletedAt?: string;\n\tcostUsd?: number;\n\tgoalId?: string;\n\tevidenceEntryId?: string;\n\t/**\n\t * Worktree-sync lane key this lane record was correlated to at dispatch (set only for a\n\t * tmux-worker lane whose fire_task carried a `worktreeLane` -- see `tmux-dispatch.ts`'s\n\t * `createLaneWorktree`). Optional so every pre-existing record/caller keeps compiling and\n\t * behaving unchanged; `undefined` for a lane never bound to a worktree-sync lane.\n\t */\n\tworktreeLaneKey?: string;\n}\n\nconst LANE_TYPES: readonly string[] = [\"research\", \"worker\", \"learning\", \"tmux-worker\"];\nconst TERMINAL_STATUSES: readonly string[] = [\"succeeded\", \"failed\", \"canceled\", \"timeout\", \"budget_exhausted\"];\nconst LANE_STATUSES: readonly string[] = [\"queued\", \"running\", ...TERMINAL_STATUSES];\n\nexport function isLaneTerminalStatus(value: unknown): value is LaneTerminalStatus {\n\treturn typeof value === \"string\" && TERMINAL_STATUSES.includes(value);\n}\n\nfunction isOptionalString(value: unknown): boolean {\n\treturn value === undefined || typeof value === \"string\";\n}\n\nexport function isLaneRecord(value: unknown): value is LaneRecord {\n\tif (!value || typeof value !== \"object\" || Array.isArray(value)) return false;\n\tconst record = value as Record<string, unknown>;\n\tif (typeof record.laneId !== \"string\" || record.laneId.length === 0) return false;\n\tif (typeof record.type !== \"string\" || !LANE_TYPES.includes(record.type)) return false;\n\tif (typeof record.status !== \"string\" || !LANE_STATUSES.includes(record.status)) return false;\n\tif (!isOptionalString(record.label)) return false;\n\tif (!isOptionalString(record.profileId)) return false;\n\tif (!isOptionalString(record.reasonCode)) return false;\n\tif (!isOptionalString(record.startedAt)) return false;\n\tif (!isOptionalString(record.completedAt)) return false;\n\tif (record.costUsd !== undefined && (typeof record.costUsd !== \"number\" || !Number.isFinite(record.costUsd))) {\n\t\treturn false;\n\t}\n\tif (!isOptionalString(record.goalId)) return false;\n\tif (!isOptionalString(record.evidenceEntryId)) return false;\n\tif (!isOptionalString(record.worktreeLaneKey)) return false;\n\treturn true;\n}\n\nexport function cloneLaneRecordForStorage(record: LaneRecord): LaneRecord {\n\treturn { ...record };\n}\n\n/** Terminal records kept in memory for diagnostics; older ones are evicted (the session log holds history). */\nconst MAX_TERMINAL_LANES_IN_MEMORY = 100;\n\nexport class LaneTracker {\n\tprivate readonly _lanes = new Map<string, LaneRecord>();\n\tprivate _nextLaneNumber = 1;\n\tprivate readonly _now: () => string;\n\n\tconstructor(options?: { now?: () => string }) {\n\t\tthis._now = options?.now ?? (() => new Date().toISOString());\n\t}\n\n\t/** Seed the id counter (e.g. from persisted lane records) so resumed sessions don't reuse ids. */\n\tensureCounterAtLeast(next: number): void {\n\t\tif (Number.isFinite(next) && next > this._nextLaneNumber) {\n\t\t\tthis._nextLaneNumber = Math.floor(next);\n\t\t}\n\t}\n\n\tprivate _evictOldTerminal(): void {\n\t\tlet terminal = 0;\n\t\tfor (const record of this._lanes.values()) {\n\t\t\tif (isLaneTerminalStatus(record.status)) terminal++;\n\t\t}\n\t\tif (terminal <= MAX_TERMINAL_LANES_IN_MEMORY) return;\n\t\t// Map iteration is insertion-ordered: drop oldest terminal records first.\n\t\tfor (const [laneId, record] of this._lanes) {\n\t\t\tif (terminal <= MAX_TERMINAL_LANES_IN_MEMORY) break;\n\t\t\tif (isLaneTerminalStatus(record.status)) {\n\t\t\t\tthis._lanes.delete(laneId);\n\t\t\t\tterminal--;\n\t\t\t}\n\t\t}\n\t}\n\n\tenqueue(args: { type: LaneType; goalId?: string; worktreeLaneKey?: string }): LaneRecord {\n\t\tconst laneId = `${args.type}-${this._nextLaneNumber++}`;\n\t\tconst record: LaneRecord = {\n\t\t\tlaneId,\n\t\t\ttype: args.type,\n\t\t\tstatus: \"queued\",\n\t\t};\n\t\tif (args.goalId !== undefined) record.goalId = args.goalId;\n\t\tif (args.worktreeLaneKey !== undefined) record.worktreeLaneKey = args.worktreeLaneKey;\n\t\tthis._lanes.set(laneId, record);\n\t\treturn { ...record };\n\t}\n\n\t/** Restore an exact durable projection without minting a replacement logical id or timestamp. */\n\trestore(record: LaneRecord): LaneRecord {\n\t\tconst restored = { ...record };\n\t\tthis._lanes.set(restored.laneId, restored);\n\t\tconst suffix = /-(\\d+)$/.exec(restored.laneId)?.[1];\n\t\tif (suffix) this.ensureCounterAtLeast(Number(suffix) + 1);\n\t\tthis._evictOldTerminal();\n\t\treturn { ...restored };\n\t}\n\n\t/** Start or restart a caller-named lane. The supplied id is its durable logical identity. */\n\tstartNamed(args: { laneId: string; type: LaneType; goalId?: string; worktreeLaneKey?: string }): LaneRecord {\n\t\tif (!args.laneId) throw new TypeError(\"A named lane requires a non-empty laneId.\");\n\t\tconst record: LaneRecord = {\n\t\t\tlaneId: args.laneId,\n\t\t\ttype: args.type,\n\t\t\tstatus: \"running\",\n\t\t\tstartedAt: this._now(),\n\t\t};\n\t\tif (args.goalId !== undefined) record.goalId = args.goalId;\n\t\tif (args.worktreeLaneKey !== undefined) record.worktreeLaneKey = args.worktreeLaneKey;\n\t\tthis._lanes.set(record.laneId, record);\n\t\tconst suffix = /-(\\d+)$/.exec(record.laneId)?.[1];\n\t\tif (suffix) this.ensureCounterAtLeast(Number(suffix) + 1);\n\t\treturn { ...record };\n\t}\n\n\tmarkRunning(laneId: string): LaneRecord | undefined {\n\t\tconst record = this._lanes.get(laneId);\n\t\tif (!record || record.status !== \"queued\") return undefined;\n\t\tconst next = { ...record, status: \"running\" as const, startedAt: this._now() };\n\t\tthis._lanes.set(laneId, next);\n\t\treturn { ...next };\n\t}\n\n\tstart(args: { type: LaneType; goalId?: string; worktreeLaneKey?: string }): LaneRecord {\n\t\tconst record = this.enqueue(args);\n\t\treturn this.markRunning(record.laneId) as LaneRecord;\n\t}\n\n\tcomplete(\n\t\tlaneId: string,\n\t\targs: { status: LaneTerminalStatus; reasonCode?: string; costUsd?: number; evidenceEntryId?: string },\n\t): LaneRecord | undefined {\n\t\tconst record = this._lanes.get(laneId);\n\t\tif (!record || isLaneTerminalStatus(record.status)) return undefined;\n\t\tconst next: LaneRecord = {\n\t\t\t...record,\n\t\t\tstatus: args.status,\n\t\t\tcompletedAt: this._now(),\n\t\t};\n\t\tif (args.reasonCode !== undefined) next.reasonCode = args.reasonCode;\n\t\tif (args.costUsd !== undefined) next.costUsd = args.costUsd;\n\t\tif (args.evidenceEntryId !== undefined) next.evidenceEntryId = args.evidenceEntryId;\n\t\tthis._lanes.set(laneId, next);\n\t\tthis._evictOldTerminal();\n\t\treturn { ...next };\n\t}\n\n\tgetActiveCount(type?: LaneType): number {\n\t\tlet count = 0;\n\t\tfor (const record of this._lanes.values()) {\n\t\t\tif (isLaneTerminalStatus(record.status)) continue;\n\t\t\tif (type !== undefined && record.type !== type) continue;\n\t\t\tcount++;\n\t\t}\n\t\treturn count;\n\t}\n\n\tgetRunningCount(type?: LaneType): number {\n\t\tlet count = 0;\n\t\tfor (const record of this._lanes.values()) {\n\t\t\tif (record.status !== \"running\") continue;\n\t\t\tif (type !== undefined && record.type !== type) continue;\n\t\t\tcount++;\n\t\t}\n\t\treturn count;\n\t}\n\n\tgetRecords(): LaneRecord[] {\n\t\treturn [...this._lanes.values()].map((record) => ({ ...record }));\n\t}\n\n\tgetRecord(laneId: string): LaneRecord | undefined {\n\t\tconst record = this._lanes.get(laneId);\n\t\treturn record ? { ...record } : undefined;\n\t}\n}\n"]}
1
+ {"version":3,"file":"lane-tracker.js","sourceRoot":"","sources":["../../../src/core/autonomy/lane-tracker.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAsCH,MAAM,UAAU,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Ac;QACvB,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;QACvC,OAAO,MAAM,CAAC,CAAC,CAAC,EAAE,GAAG,MAAM,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;IAC3C,CAAC;CACD","sourcesContent":["/**\n * Live lane registry for autonomous background work (research/worker/learning lanes).\n *\n * This is the first real concurrency tracker behind `AutonomyStatusSnapshot.activeLaneCount`:\n * counts reflect lanes actually running in THIS process, never inferred/faked from historical\n * snapshots. Terminal lane records are persisted separately via `session-lane-record.ts`.\n */\n\nexport type LaneType = \"research\" | \"worker\" | \"learning\" | \"tmux-worker\";\n\nexport type LaneTerminalStatus =\n\t| \"succeeded\"\n\t| \"partial\"\n\t| \"blocked\"\n\t| \"failed\"\n\t| \"canceled\"\n\t| \"timeout\"\n\t| \"budget_exhausted\";\n\nexport type LaneStatus = \"queued\" | \"running\" | LaneTerminalStatus;\n\nexport interface LaneRecord {\n\tlaneId: string;\n\ttype: LaneType;\n\tstatus: LaneStatus;\n\t/** Bounded human-readable work label retained across session resume. */\n\tlabel?: string;\n\t/** Owner-authored profile that fixed the worker's model, thinking, tools, and budget. */\n\tprofileId?: string;\n\treasonCode?: string;\n\tstartedAt?: string;\n\tcompletedAt?: string;\n\tcostUsd?: number;\n\tgoalId?: string;\n\tevidenceEntryId?: string;\n\t/**\n\t * Worktree-sync lane key this lane record was correlated to at dispatch (set only for a\n\t * tmux-worker lane whose fire_task carried a `worktreeLane` -- see `tmux-dispatch.ts`'s\n\t * `createLaneWorktree`). Optional so every pre-existing record/caller keeps compiling and\n\t * behaving unchanged; `undefined` for a lane never bound to a worktree-sync lane.\n\t */\n\tworktreeLaneKey?: string;\n}\n\nconst LANE_TYPES: readonly string[] = [\"research\", \"worker\", \"learning\", \"tmux-worker\"];\nconst TERMINAL_STATUSES: readonly string[] = [\n\t\"succeeded\",\n\t\"partial\",\n\t\"blocked\",\n\t\"failed\",\n\t\"canceled\",\n\t\"timeout\",\n\t\"budget_exhausted\",\n];\nconst LANE_STATUSES: readonly string[] = [\"queued\", \"running\", ...TERMINAL_STATUSES];\n\nexport function isLaneTerminalStatus(value: unknown): value is LaneTerminalStatus {\n\treturn typeof value === \"string\" && TERMINAL_STATUSES.includes(value);\n}\n\nfunction isOptionalString(value: unknown): boolean {\n\treturn value === undefined || typeof value === \"string\";\n}\n\nexport function isLaneRecord(value: unknown): value is LaneRecord {\n\tif (!value || typeof value !== \"object\" || Array.isArray(value)) return false;\n\tconst record = value as Record<string, unknown>;\n\tif (typeof record.laneId !== \"string\" || record.laneId.length === 0) return false;\n\tif (typeof record.type !== \"string\" || !LANE_TYPES.includes(record.type)) return false;\n\tif (typeof record.status !== \"string\" || !LANE_STATUSES.includes(record.status)) return false;\n\tif (!isOptionalString(record.label)) return false;\n\tif (!isOptionalString(record.profileId)) return false;\n\tif (!isOptionalString(record.reasonCode)) return false;\n\tif (!isOptionalString(record.startedAt)) return false;\n\tif (!isOptionalString(record.completedAt)) return false;\n\tif (record.costUsd !== undefined && (typeof record.costUsd !== \"number\" || !Number.isFinite(record.costUsd))) {\n\t\treturn false;\n\t}\n\tif (!isOptionalString(record.goalId)) return false;\n\tif (!isOptionalString(record.evidenceEntryId)) return false;\n\tif (!isOptionalString(record.worktreeLaneKey)) return false;\n\treturn true;\n}\n\nexport function cloneLaneRecordForStorage(record: LaneRecord): LaneRecord {\n\treturn { ...record };\n}\n\n/** Terminal records kept in memory for diagnostics; older ones are evicted (the session log holds history). */\nconst MAX_TERMINAL_LANES_IN_MEMORY = 100;\n\nexport class LaneTracker {\n\tprivate readonly _lanes = new Map<string, LaneRecord>();\n\tprivate _nextLaneNumber = 1;\n\tprivate readonly _now: () => string;\n\n\tconstructor(options?: { now?: () => string }) {\n\t\tthis._now = options?.now ?? (() => new Date().toISOString());\n\t}\n\n\t/** Seed the id counter (e.g. from persisted lane records) so resumed sessions don't reuse ids. */\n\tensureCounterAtLeast(next: number): void {\n\t\tif (Number.isFinite(next) && next > this._nextLaneNumber) {\n\t\t\tthis._nextLaneNumber = Math.floor(next);\n\t\t}\n\t}\n\n\tprivate _evictOldTerminal(): void {\n\t\tlet terminal = 0;\n\t\tfor (const record of this._lanes.values()) {\n\t\t\tif (isLaneTerminalStatus(record.status)) terminal++;\n\t\t}\n\t\tif (terminal <= MAX_TERMINAL_LANES_IN_MEMORY) return;\n\t\t// Map iteration is insertion-ordered: drop oldest terminal records first.\n\t\tfor (const [laneId, record] of this._lanes) {\n\t\t\tif (terminal <= MAX_TERMINAL_LANES_IN_MEMORY) break;\n\t\t\tif (isLaneTerminalStatus(record.status)) {\n\t\t\t\tthis._lanes.delete(laneId);\n\t\t\t\tterminal--;\n\t\t\t}\n\t\t}\n\t}\n\n\tenqueue(args: { type: LaneType; goalId?: string; worktreeLaneKey?: string }): LaneRecord {\n\t\tconst laneId = `${args.type}-${this._nextLaneNumber++}`;\n\t\tconst record: LaneRecord = {\n\t\t\tlaneId,\n\t\t\ttype: args.type,\n\t\t\tstatus: \"queued\",\n\t\t};\n\t\tif (args.goalId !== undefined) record.goalId = args.goalId;\n\t\tif (args.worktreeLaneKey !== undefined) record.worktreeLaneKey = args.worktreeLaneKey;\n\t\tthis._lanes.set(laneId, record);\n\t\treturn { ...record };\n\t}\n\n\t/** Restore an exact durable projection without minting a replacement logical id or timestamp. */\n\trestore(record: LaneRecord): LaneRecord {\n\t\tconst restored = { ...record };\n\t\tthis._lanes.set(restored.laneId, restored);\n\t\tconst suffix = /-(\\d+)$/.exec(restored.laneId)?.[1];\n\t\tif (suffix) this.ensureCounterAtLeast(Number(suffix) + 1);\n\t\tthis._evictOldTerminal();\n\t\treturn { ...restored };\n\t}\n\n\t/** Start or restart a caller-named lane. The supplied id is its durable logical identity. */\n\tstartNamed(args: { laneId: string; type: LaneType; goalId?: string; worktreeLaneKey?: string }): LaneRecord {\n\t\tif (!args.laneId) throw new TypeError(\"A named lane requires a non-empty laneId.\");\n\t\tconst record: LaneRecord = {\n\t\t\tlaneId: args.laneId,\n\t\t\ttype: args.type,\n\t\t\tstatus: \"running\",\n\t\t\tstartedAt: this._now(),\n\t\t};\n\t\tif (args.goalId !== undefined) record.goalId = args.goalId;\n\t\tif (args.worktreeLaneKey !== undefined) record.worktreeLaneKey = args.worktreeLaneKey;\n\t\tthis._lanes.set(record.laneId, record);\n\t\tconst suffix = /-(\\d+)$/.exec(record.laneId)?.[1];\n\t\tif (suffix) this.ensureCounterAtLeast(Number(suffix) + 1);\n\t\treturn { ...record };\n\t}\n\n\tmarkRunning(laneId: string): LaneRecord | undefined {\n\t\tconst record = this._lanes.get(laneId);\n\t\tif (!record || record.status !== \"queued\") return undefined;\n\t\tconst next = { ...record, status: \"running\" as const, startedAt: this._now() };\n\t\tthis._lanes.set(laneId, next);\n\t\treturn { ...next };\n\t}\n\n\tstart(args: { type: LaneType; goalId?: string; worktreeLaneKey?: string }): LaneRecord {\n\t\tconst record = this.enqueue(args);\n\t\treturn this.markRunning(record.laneId) as LaneRecord;\n\t}\n\n\tcomplete(\n\t\tlaneId: string,\n\t\targs: { status: LaneTerminalStatus; reasonCode?: string; costUsd?: number; evidenceEntryId?: string },\n\t): LaneRecord | undefined {\n\t\tconst record = this._lanes.get(laneId);\n\t\tif (!record || isLaneTerminalStatus(record.status)) return undefined;\n\t\tconst next: LaneRecord = {\n\t\t\t...record,\n\t\t\tstatus: args.status,\n\t\t\tcompletedAt: this._now(),\n\t\t};\n\t\tif (args.reasonCode !== undefined) next.reasonCode = args.reasonCode;\n\t\tif (args.costUsd !== undefined) next.costUsd = args.costUsd;\n\t\tif (args.evidenceEntryId !== undefined) next.evidenceEntryId = args.evidenceEntryId;\n\t\tthis._lanes.set(laneId, next);\n\t\tthis._evictOldTerminal();\n\t\treturn { ...next };\n\t}\n\n\tgetActiveCount(type?: LaneType): number {\n\t\tlet count = 0;\n\t\tfor (const record of this._lanes.values()) {\n\t\t\tif (isLaneTerminalStatus(record.status)) continue;\n\t\t\tif (type !== undefined && record.type !== type) continue;\n\t\t\tcount++;\n\t\t}\n\t\treturn count;\n\t}\n\n\tgetRunningCount(type?: LaneType): number {\n\t\tlet count = 0;\n\t\tfor (const record of this._lanes.values()) {\n\t\t\tif (record.status !== \"running\") continue;\n\t\t\tif (type !== undefined && record.type !== type) continue;\n\t\t\tcount++;\n\t\t}\n\t\treturn count;\n\t}\n\n\tgetRecords(): LaneRecord[] {\n\t\treturn [...this._lanes.values()].map((record) => ({ ...record }));\n\t}\n\n\tgetRecord(laneId: string): LaneRecord | undefined {\n\t\tconst record = this._lanes.get(laneId);\n\t\treturn record ? { ...record } : undefined;\n\t}\n}\n"]}
@@ -194,9 +194,7 @@ export declare class BackgroundLaneController implements WorkerAgentControlPort
194
194
  };
195
195
  cancelWorkerAgent(agentId: string, reasonCode?: string, scope?: WorkerAgentControlScope): LaneRecord | undefined;
196
196
  retireWorkerAgent(agentId: string, scope?: WorkerAgentControlScope): WorkerAgentRetireResult;
197
- waitForWorkerAgent(agentId: string, timeoutMs?: number, scope?: WorkerAgentControlScope): Promise<{
198
- status: WorkerAgentActivity;
199
- }>;
197
+ waitForWorkerAgent(agentId: string, timeoutMs?: number, scope?: WorkerAgentControlScope): ReturnType<WorkerAgentControlPort["waitForWorkerAgent"]>;
200
198
  waitForWorkerAgents(agentIds: readonly string[], mode: WorkerAgentWaitMode, timeoutMs?: number, scope?: WorkerAgentControlScope): Promise<WorkerAgentWaitResult>;
201
199
  broadcastWorkerAgentMessage(agentIds: readonly string[], message: string, options: WorkerAgentBroadcastOptions): WorkerAgentBroadcastResult;
202
200
  /** Run one worker immediately; used by focused integrations and tests. */
@@ -1 +1 @@
1
- {"version":3,"file":"background-lane-controller.d.ts","sourceRoot":"","sources":["../../src/core/background-lane-controller.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,KAAK,EACX,2BAA2B,EAC3B,0B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,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,6FAA6F;QAC7F,UAAU,CAAC,EAAE,MAAM,CAAC;KACpB,GAAG,OAAO,CAAC;QAAE,OAAO,EAAE,IAAI,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,kBAAkB,CAAA;KAAE,GAAG;QAAE,OAAO,EAAE,KAAK,CAAC;QAAC,UAAU,EAAE,MAAM,CAAA;KAAE,CAAC,CAEjH;IAED,mGAAmG;IACnG,4BAA4B,IAAI,IAAI,CAEnC;IAED,mGAAmG;IACnG,uBAAuB,IAAI,mBAAmB,EAAE,CAE/C;CACD"}
1
+ {"version":3,"file":"background-lane-controller.d.ts","sourceRoot":"","sources":["../../src/core/background-lane-controller.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,KAAK,EACX,2BAA2B,EAC3B,0BAA0B,EAC1B,aAAa,EACb,sBAAsB,EACtB,0BAA0B,EAC1B,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,KAAK,UAAU,EAAe,MAAM,4BAA4B,CAAC;AAG1E,OAAO,KAAK,EACX,gBAAgB,EAChB,qBAAqB,EACrB,2BAA2B,EAC3B,0BAA0B,EAC1B,MAAM,sCAAsC,CAAC;AAC9C,OAAO,KAAK,EACX,oCAAoC,EACpC,mBAAmB,EACnB,2BAA2B,EAC3B,0BAA0B,EAC1B,sBAAsB,EACtB,uBAAuB,EACvB,yBAAyB,EACzB,sBAAsB,EACtB,uBAAuB,EACvB,2BAA2B,EAC3B,4BAA4B,EAC5B,mBAAmB,EACnB,qBAAqB,EACrB,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EAEN,KAAK,8BAA8B,EACnC,MAAM,8CAA8C,CAAC;AACtD,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,2CAA2C,CAAC;AAGzF,OAAO,KAAK,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sBAAsB,CAAC,oBAAoB,CAAC,CAAC,CAI1D;IAED,mBAAmB,CAClB,QAAQ,EAAE,SAAS,MAAM,EAAE,EAC3B,IAAI,EAAE,mBAAmB,EACzB,SAAS,CAAC,EAAE,MAAM,EAClB,KAAK,CAAC,EAAE,uBAAuB,GAC7B,OAAO,CAAC,qBAAqB,CAAC,CAIhC;IAED,2BAA2B,CAC1B,QAAQ,EAAE,SAAS,MAAM,EAAE,EAC3B,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,2BAA2B,GAClC,0BAA0B,CAI5B;IAED,0EAA0E;IACpE,uBAAuB,CAC5B,OAAO,EAAE,uBAAuB,EAChC,SAAS,CAAC,EAAE,CAAC,MAAM,EAAE,UAAU,KAAK,IAAI,EACxC,cAAc,CAAC,EAAE,UAAU,GACzB,OAAO,CAAC,0BAA0B,CAAC,CAErC;IACD;;;;;OAKG;IACG,eAAe,CAAC,IAAI,EAAE;QAC3B,KAAK,EAAE,MAAM,CAAC;QACd,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,6FAA6F;QAC7F,UAAU,CAAC,EAAE,MAAM,CAAC;KACpB,GAAG,OAAO,CAAC;QAAE,OAAO,EAAE,IAAI,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,kBAAkB,CAAA;KAAE,GAAG;QAAE,OAAO,EAAE,KAAK,CAAC;QAAC,UAAU,EAAE,MAAM,CAAA;KAAE,CAAC,CAEjH;IAED,mGAAmG;IACnG,4BAA4B,IAAI,IAAI,CAEnC;IAED,mGAAmG;IACnG,uBAAuB,IAAI,mBAAmB,EAAE,CAE/C;CACD"}
@@ -1 +1 @@
1
- {"version":3,"file":"background-lane-controller.js","sourceRoot":"","sources":["../../src/core/background-lane-controller.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAUH,OAAO,EAAmB,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAC1E,OAAO,EAAE,wBAAwB,EAAE,4BAA4B,EAAE,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2B,EAC3B,OAAe,EACf,OAAoC;QAEpC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,oBAAoB,EAAE;YACpC,MAAM,IAAI,KAAK,CAAC,+DAA+D,CAAC,CAAC;QAClF,OAAO,IAAI,CAAC,oBAAoB,EAAE,CAAC,eAAe,EAAE,CAAC,2BAA2B,CAAC,QAAQ,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;IAC9G,CAAC;IAED,0EAA0E;IAC1E,KAAK,CAAC,uBAAuB,CAC5B,OAAgC,EAChC,SAAwC,EACxC,cAA2B;QAE3B,OAAO,IAAI,CAAC,oBAAoB,EAAE,CAAC,OAAO,CAAC,OAAO,EAAE,SAAS,EAAE,cAAc,CAAC,CAAC;IAChF,CAAC;IACD;;;;;OAKG;IACH,KAAK,CAAC,eAAe,CAAC,IAKrB;QACA,OAAO,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IAChC,CAAC;IAED,mGAAmG;IACnG,4BAA4B;QAC3B,IAAI,IAAI,CAAC,IAAI,CAAC,oBAAoB,EAAE,EAAE;YAAE,IAAI,CAAC,oBAAoB,EAAE,CAAC,KAAK,EAAE,CAAC;IAC7E,CAAC;IAED,mGAAmG;IACnG,uBAAuB;QACtB,OAAO,IAAI,CAAC,QAAQ,CAAC,gBAAgB,EAAE,CAAC;IACzC,CAAC;CACD","sourcesContent":["/**\n * Execution-plane coordinator for goal continuation, research, managed lanes, worker delegation,\n * and model fitness.\n *\n * Coordination state is owned by focused controllers. This coordinator retains one AgentSession\n * composition seam and a shared lane read model. Everything it needs\n * — the session manager, settings, model registry, live model, capability envelope, the goal\n * continuation LOOP, the isolated-completion primitive, spawned-usage accounting, and the telemetry\n * sink — is reached through narrow deps accessors rather than the whole AgentSession.\n *\n * Drive-loop boundary (deliberate): the idle triggers ({@link scheduleGoalAutoContinueFromIdle},\n * {@link scheduleResearchLaneFromIdle}) are invoked from the session's prompt tail as one-line\n * delegations; goal auto-continue itself only ever asks the session to `continueGoalLoop`, so this\n * controller never touches `prompt()`, the last-assistant-message, retry, or streaming state.\n */\n\nimport type { Api, Model } from \"@caupulican/pi-ai\";\nimport type {\n\tGoalContinuationLoopOptions,\n\tGoalContinuationLoopResult,\n\tPromptOptions,\n\tResearchLaneRunOutcome,\n\tWorkerDelegationRunOutcome,\n} from \"./agent-session-contracts.ts\";\nimport { type LaneRecord, LaneTracker } from \"./autonomy/lane-tracker.ts\";\nimport { appendLaneRecordSnapshot, getLatestLaneRecordSnapshots } from \"./autonomy/session-lane-record.ts\";\nimport { ManagedLaneController } from \"./delegation/managed-lane-controller.ts\";\nimport type {\n\tSessionRootReply,\n\tSessionRootReplyQuery,\n\tSessionRootReplyWaitOptions,\n\tSessionRootReplyWaitResult,\n} from \"./delegation/session-root-mailbox.ts\";\nimport type {\n\tSessionRootWorkerAgentMessageOptions,\n\tWorkerAgentActivity,\n\tWorkerAgentBroadcastOptions,\n\tWorkerAgentBroadcastResult,\n\tWorkerAgentControlPort,\n\tWorkerAgentControlScope,\n\tWorkerAgentMessageOptions,\n\tWorkerAgentReplyResult,\n\tWorkerAgentRetireResult,\n\tWorkerAgentTaskStartOptions,\n\tWorkerAgentTranscriptOptions,\n\tWorkerAgentWaitMode,\n\tWorkerAgentWaitResult,\n} from \"./delegation/worker-agent-control.ts\";\nimport {\n\tWorkerDelegationController,\n\ttype WorkerDelegationControllerDeps,\n} from \"./delegation/worker-delegation-controller.ts\";\nimport type { WorkerDelegationRequest } from \"./delegation/worker-delegation-request.ts\";\nimport { WorkerLifecycle } from \"./delegation/worker-lifecycle.ts\";\nimport { WorkerNotificationCoordinator } from \"./delegation/worker-notification-coordinator.ts\";\nimport type { ManagedLaneEvent } from \"./extensions/types.ts\";\nimport { GoalAutoContinueController } from \"./goals/goal-auto-continue-controller.ts\";\nimport type { GoalRuntimeSnapshot, GoalRuntimeSnapshotSettings } from \"./goals/goal-runtime-snapshot.ts\";\nimport type { GoalState } from \"./goals/goal-state.ts\";\nimport type { ModelCapabilityProfile } from \"./model-capability.ts\";\nimport type { StoredFitnessReport } from \"./models/fitness-store.ts\";\nimport type {\n\tTaskProfileCreateInput,\n\tTaskProfileCreateResult,\n\tTaskProfileInspection,\n} from \"./orchestration/task-profile-writer.ts\";\nimport type { TaskRuntimeProjection } from \"./orchestration/task-runtime.ts\";\nimport { LaneModelResolver, type LaneModelResolverDeps } from \"./research/lane-model-resolver.ts\";\nimport type { ModelFitnessReport } from \"./research/model-fitness.ts\";\nimport { ModelFitnessController, type ModelFitnessControllerDeps } from \"./research/model-fitness-controller.ts\";\nimport { ResearchLaneController, type ResearchLaneControllerDeps } from \"./research/research-lane-controller.ts\";\nimport { getActiveSessionBranchEntries } from \"./session-snapshot.ts\";\n\nexport { isLocalExecutionModel } from \"./delegation/worker-delegation-controller.ts\";\nexport { clampLaneMaxUsd } from \"./research/lane-model-resolver.ts\";\n\nexport interface BackgroundLaneControllerDeps\n\textends WorkerDelegationControllerDeps,\n\t\tResearchLaneControllerDeps,\n\t\tModelFitnessControllerDeps,\n\t\tLaneModelResolverDeps {\n\t/** True iff the `goal` tool is in the session's ACTIVE surface -- the capability-adaptive gate\n\t * for every goal-continuation loop (see `continueGoalLoopExclusive`): a surface without the\n\t * goal tool (lean capability blocklist, worker role ceiling, --tools/profile exclusion) must\n\t * never be driven with continuation prompts it cannot execute. */\n\tisGoalToolActive(): boolean;\n\t/** Capability profile of the SESSION model (gates background lanes, scales continuation budgets). */\n\tgetModelCapabilityProfile(): ModelCapabilityProfile;\n\t/** Continuation gate + goal state for the idle autosteer scheduler. */\n\tgetGoalRuntimeSnapshot(settings: GoalRuntimeSnapshotSettings): GoalRuntimeSnapshot;\n\t/** Drive-loop boundary: the session's bounded goal-continuation loop (owns `prompt()`, not us). */\n\tcontinueGoalLoop(options: GoalContinuationLoopOptions): Promise<GoalContinuationLoopResult>;\n\t/** True while the session owns a foreground prompt/retry/follow-up run. */\n\tisForegroundBusy(): boolean;\n\t/** Resolve only after the complete foreground retry/follow-up run releases the session. */\n\twaitForForegroundIdle(): Promise<void>;\n\t/** Persist an explicit stopped state when the selected surface cannot drive the active goal. */\n\tmarkGoalToolUnavailable(): void;\n}\n\nexport class BackgroundLaneController implements WorkerAgentControlPort {\n\t/** Live lane registry — the real source for AutonomyStatusSnapshot.activeLaneCount. */\n\tprivate readonly _laneTracker = new LaneTracker();\n\tprivate readonly _laneModels: LaneModelResolver;\n\tprivate readonly _goalAutoContinue: GoalAutoContinueController;\n\tprivate readonly _research: ResearchLaneController;\n\tprivate readonly _fitness: ModelFitnessController;\n\t/** Lazily materialized only when managed-lane state is queried or reported. */\n\tprivate _managedLanes: ManagedLaneController | undefined;\n\t/** Lazily materialized so a UAC surface without `delegate` allocates no worker runtime state. */\n\tprivate _workers: WorkerDelegationController | undefined;\n\t/** One durable lifecycle shared by every worker execution adapter. */\n\tprivate _workerLifecycle: WorkerLifecycle | undefined;\n\t/** Shared terminal outbox for managed and in-process workers; lazy under UAC omission. */\n\tprivate _workerNotifications: WorkerNotificationCoordinator | undefined;\n\tprivate readonly deps: BackgroundLaneControllerDeps;\n\n\t/** Emit a warning without ever throwing — used from disposal-adjacent persistence where a\n\t * listener failure (or a bare test double missing `emit`) must never block or crash cleanup. */\n\tprivate _safeWarn(message: string): void {\n\t\ttry {\n\t\t\tthis.deps.emit({ type: \"warning\", message });\n\t\t} catch {\n\t\t\t// Dispose must never throw.\n\t\t}\n\t}\n\n\tprivate _recordWorkerTerminal(record: LaneRecord, durableNotificationId: string): void {\n\t\tthis._getWorkerNotificationCoordinator().recordTerminal(record, durableNotificationId);\n\t}\n\n\tconstructor(deps: BackgroundLaneControllerDeps) {\n\t\tthis.deps = deps;\n\t\tthis._laneModels = new LaneModelResolver(deps);\n\t\tthis._research = new ResearchLaneController(deps, this._laneTracker, this._laneModels);\n\t\tthis._fitness = new ModelFitnessController(deps, this._laneModels);\n\t\tthis._goalAutoContinue = new GoalAutoContinueController({\n\t\t\tisDisposed: deps.isDisposed,\n\t\t\tisGoalToolActive: deps.isGoalToolActive,\n\t\t\tgetSettingsManager: deps.getSettingsManager,\n\t\t\tgetModelCapabilityProfile: deps.getModelCapabilityProfile,\n\t\t\tgetGoalRuntimeSnapshot: deps.getGoalRuntimeSnapshot,\n\t\t\thasInFlightLaneForGoal: (goalId) => this._hasInFlightLaneForGoal(goalId),\n\t\t\tcontinueGoalLoop: deps.continueGoalLoop,\n\t\t\tisForegroundBusy: deps.isForegroundBusy,\n\t\t\twaitForForegroundIdle: deps.waitForForegroundIdle,\n\t\t\tmarkGoalToolUnavailable: deps.markGoalToolUnavailable,\n\t\t\temit: deps.emit,\n\t\t});\n\t}\n\n\tprivate _getWorkerController(): WorkerDelegationController {\n\t\tthis._workers ??= new WorkerDelegationController(\n\t\t\tthis.deps,\n\t\t\tthis._getWorkerNotificationCoordinator(),\n\t\t\tthis._getWorkerLifecycle(),\n\t\t);\n\t\treturn this._workers;\n\t}\n\n\tprivate _getWorkerLifecycle(): WorkerLifecycle {\n\t\tif (this._workerLifecycle) return this._workerLifecycle;\n\t\tconst lifecycle = new WorkerLifecycle({\n\t\t\tagentDir: this.deps.getAgentDir(),\n\t\t\tsessionId: this.deps.getSessionId(),\n\t\t});\n\t\tthis._workerLifecycle = lifecycle;\n\t\tfor (const notification of lifecycle.getPendingTerminalNotifications()) {\n\t\t\tthis._getWorkerNotificationCoordinator().recordTerminal(notification.record, notification.notificationId);\n\t\t}\n\t\treturn lifecycle;\n\t}\n\n\tprivate _getWorkerNotificationCoordinator(): WorkerNotificationCoordinator {\n\t\tthis._workerNotifications ??= new WorkerNotificationCoordinator({\n\t\t\tgetWorkerRecords: () => this._workerLifecycle?.getAllRecords() ?? [],\n\t\t\temitStatus: (status) => {\n\t\t\t\ttry {\n\t\t\t\t\tthis.deps.emit({\n\t\t\t\t\t\ttype: \"delegate_workers\",\n\t\t\t\t\t\t...status,\n\t\t\t\t\t\tterminalSinceFlush: [...status.terminalSinceFlush],\n\t\t\t\t\t});\n\t\t\t\t} catch {\n\t\t\t\t\t// A partial integration must not crash the event-driven terminal outbox.\n\t\t\t\t}\n\t\t\t},\n\t\t\tnotify: (records) => this.deps.notifyWorkerTerminalHandoff(records),\n\t\t\twarn: (message) => this._safeWarn(message),\n\t\t\tmarkDurableDelivered: (notificationIds) => this._workerLifecycle?.markNotificationsDelivered(notificationIds),\n\t\t});\n\t\treturn this._workerNotifications;\n\t}\n\n\tprivate _getManagedLaneController(): ManagedLaneController {\n\t\tthis._managedLanes ??= new ManagedLaneController(\n\t\t\tthis.deps,\n\t\t\tthis._getWorkerLifecycle(),\n\t\t\t(record, notificationId) => this._recordWorkerTerminal(record, notificationId),\n\t\t\t(message) => this._safeWarn(message),\n\t\t);\n\t\treturn this._managedLanes;\n\t}\n\n\tprivate _hydrateManagedLanes(): void {\n\t\tif (this._managedLanes) {\n\t\t\tthis._managedLanes.ensureHydrated();\n\t\t\treturn;\n\t\t}\n\t\tconst hasPersistedActiveManagedLane = getLatestLaneRecordSnapshots(\n\t\t\tgetActiveSessionBranchEntries(this.deps.getSessionManager()),\n\t\t).some((record) => record.type === \"tmux-worker\" && (record.status === \"queued\" || record.status === \"running\"));\n\t\tif (hasPersistedActiveManagedLane) this._getManagedLaneController().ensureHydrated();\n\t}\n\n\t/** Live lane records tracked by this process (running and terminal). */\n\tgetLaneRecords(): LaneRecord[] {\n\t\tthis._hydrateManagedLanes();\n\t\tconst workerRecords =\n\t\t\tthis._workers?.getRecords() ??\n\t\t\t(this.deps.isDelegateToolActive?.() ? this._getWorkerController().getRecords() : []);\n\t\treturn [\n\t\t\t...this._laneTracker.getRecords(),\n\t\t\t...workerRecords,\n\t\t\t...(this._workerLifecycle?.getManagedRecords() ?? []),\n\t\t];\n\t}\n\n\t/** Does not materialize the worker controller when UAC omitted delegation. */\n\tgetTaskRuntimeSnapshot(): TaskRuntimeProjection | undefined {\n\t\treturn this._workerLifecycle?.getTaskRuntimeSnapshot();\n\t}\n\n\t/** Reconcile only when delegation has already been materialized; UAC omission stays zero-load. */\n\tsynchronizeGoalState(goal: GoalState): void {\n\t\tthis._workers?.synchronizeGoalState(goal);\n\t}\n\n\t/**\n\t * Resolve a tracked managed-lane dispatch. The caller's stable id is also the canonical durable\n\t * lane id, so this is an existence check rather than an id translation.\n\t */\n\tresolveManagedLaneId(callerLaneId: string): string | undefined {\n\t\treturn this._getManagedLaneController().resolve(callerLaneId);\n\t}\n\n\t/** Live count of active lanes — the real source for AutonomyStatusSnapshot.activeLaneCount. */\n\tgetActiveLaneCount(): number {\n\t\treturn this.getLaneRecords().filter((record) => record.status === \"queued\" || record.status === \"running\").length;\n\t}\n\n\t/** Belt-and-braces guard: whether ANY queued/running lane is tagged with this goalId. */\n\tprivate _hasInFlightLaneForGoal(goalId: string): boolean {\n\t\treturn this.getLaneRecords().some(\n\t\t\t(record) => record.goalId === goalId && (record.status === \"queued\" || record.status === \"running\"),\n\t\t);\n\t}\n\n\t/** Delegate the out-of-process dispatch/terminal claim to its single lifecycle owner. */\n\trecordManagedLane(event: ManagedLaneEvent): LaneRecord | undefined {\n\t\treturn this._getManagedLaneController().record(event);\n\t}\n\n\t/** Why the last idle research-lane evaluation skipped, for /autonomy diagnostics. */\n\tgetLastResearchLaneSkipReason(): string | undefined {\n\t\treturn this._research.getLastSkipReason();\n\t}\n\n\t/**\n\t * Abort in-flight research and delegate worker disposal to its single owning controller.\n\t *\n\t * This synchronous body is the LAST provably-safe write window for canceled/in-flight work.\n\t * `dispose()` (agent-session.ts) has already set the session's own disposed flag but has not yet\n\t * returned — no successor session (e.g. a `/reload` adoption) can exist yet, so an append here\n\t * cannot interleave with one; a post-await continuation resuming AFTER this method returns must\n\t * not append (see the disposed branch in `runWorkerDelegationOnce`). Persist FIRST, then\n\t * complete-in-memory, so a throw from one lane's persist cannot skip another's; each persist gets\n\t * its own try/catch — dispose must never throw.\n\t */\n\tabortInFlightLanes(): void {\n\t\tthis._goalAutoContinue.clearTimer();\n\t\tthis._research.abort();\n\t\tthis._fitness.abort();\n\t\tfor (const record of this._laneTracker.getRecords()) {\n\t\t\tif (record.status !== \"queued\" && record.status !== \"running\") continue;\n\t\t\tif (record.type === \"tmux-worker\") continue;\n\t\t\tconst canceled = this._laneTracker.complete(record.laneId, {\n\t\t\t\tstatus: \"canceled\",\n\t\t\t\treasonCode: \"session_disposed\",\n\t\t\t});\n\t\t\tif (!canceled) continue;\n\t\t\ttry {\n\t\t\t\tappendLaneRecordSnapshot(this.deps.getSessionManager(), canceled);\n\t\t\t} catch (error) {\n\t\t\t\tthis._safeWarn(\n\t\t\t\t\t`Failed to persist canceled lane record ${canceled.laneId}: ${error instanceof Error ? error.message : String(error)}`,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t\tthis._managedLanes?.release();\n\n\t\tthis._workers?.abort();\n\t\tthis._workerNotifications?.dispose();\n\t}\n\n\tclearGoalAutoContinueTimer(): void {\n\t\tthis._goalAutoContinue.clearTimer();\n\t}\n\n\tscheduleGoalAutoContinueFromIdle(options?: PromptOptions): void {\n\t\tthis._goalAutoContinue.scheduleFromIdle(options);\n\t}\n\n\t/**\n\t * Single-flight entry point for EVERY goal-continuation loop invocation — idle autosteer\n\t * ({@link _runScheduledGoalAutoContinue}) AND the manual `/goal start` / `/goal-continue`\n\t * commands (reached through `AgentSession.continueGoalLoop`). Both paths ultimately submit\n\t * continuation prompts through the session's single `prompt()` path, so two loops racing throws\n\t * \"Agent is already processing\" from whichever submits second. `_isGoalAutoContinuing` is the\n\t * ONE owner of that mutex; `deps.continueGoalLoop` (the raw {@link GoalLoopController} loop)\n\t * must never be called directly outside this method, or the guard is bypassed.\n\t */\n\tasync continueGoalLoopExclusive(options: GoalContinuationLoopOptions): Promise<GoalContinuationLoopResult> {\n\t\treturn this._goalAutoContinue.continueExclusive(options);\n\t}\n\n\tclearResearchLaneTimer(): void {\n\t\tthis._research.clearTimer();\n\t}\n\n\tscheduleResearchLaneFromIdle(): void {\n\t\tthis._research.scheduleFromIdle();\n\t}\n\n\tresolveLaneModel(configuredPattern: string | undefined): Model<Api> | undefined {\n\t\treturn this._laneModels.resolveModel(configuredPattern);\n\t}\n\n\tgetOrchestrationProfileCatalog(): Array<{ profileId: string; role: string; description: string }> {\n\t\treturn this._getWorkerController().getProfileCatalog();\n\t}\n\n\tinspectTaskProfileOptions(): TaskProfileInspection {\n\t\treturn this._getWorkerController().inspectTaskProfileOptions();\n\t}\n\n\tcreateTaskProfile(input: TaskProfileCreateInput): TaskProfileCreateResult {\n\t\treturn this._getWorkerController().createTaskProfile(input);\n\t}\n\n\t/**\n\t * Run one bounded, read-only research pass and persist its results: evidence bundle snapshot,\n\t * terminal lane record, and spawned-usage cost report (single-hop invariant, idempotent on the\n\t * lane's reportId). Explicit calls (e.g. `/autonomy research`) express user intent and bypass the\n\t * enabled/mode/dedupe gates the idle scheduler enforces; budget and capability gates always apply.\n\t */\n\tasync runResearchLaneOnce(request?: {\n\t\tquery?: string;\n\t\tcontext?: string;\n\t\tgoalId?: string;\n\t}): Promise<ResearchLaneRunOutcome> {\n\t\treturn this._research.runOnce(request);\n\t}\n\t/** Start a durable recursive agent with inherited, preset, or model-selected authority. */\n\tstartWorkerDelegation(\n\t\trequest: WorkerDelegationRequest,\n\t): { started: false; skipReason: string } | { started: true; record: LaneRecord } {\n\t\treturn this._getWorkerController().start(request);\n\t}\n\n\t/** Durable logical-worker controls. Each checks UAC before materializing worker state. */\n\tlistWorkerAgents(scope?: WorkerAgentControlScope): ReturnType<WorkerAgentControlPort[\"listWorkerAgents\"]> {\n\t\tif (!this.deps.isDelegateToolActive())\n\t\t\tthrow new Error(\"Worker delegation control is unavailable in this UAC surface.\");\n\t\treturn this._getWorkerController().getAgentControl().listWorkerAgents(scope);\n\t}\n\n\tgetWorkerTaskSessionView(): ReturnType<WorkerAgentControlPort[\"getWorkerTaskSessionView\"]> {\n\t\tif (!this.deps.isDelegateToolActive())\n\t\t\tthrow new Error(\"Worker delegation control is unavailable in this UAC surface.\");\n\t\treturn this._getWorkerController().getAgentControl().getWorkerTaskSessionView();\n\t}\n\n\tgetWorkerAgentActivity(agentId: string, scope?: WorkerAgentControlScope): WorkerAgentActivity {\n\t\tif (!this.deps.isDelegateToolActive())\n\t\t\tthrow new Error(\"Worker delegation control is unavailable in this UAC surface.\");\n\t\treturn this._getWorkerController().getAgentControl().getWorkerAgentActivity(agentId, scope);\n\t}\n\n\treadWorkerAgentTranscript(\n\t\tagentId: string,\n\t\toptions?: WorkerAgentTranscriptOptions,\n\t): ReturnType<WorkerAgentControlPort[\"readWorkerAgentTranscript\"]> {\n\t\tif (!this.deps.isDelegateToolActive())\n\t\t\tthrow new Error(\"Worker delegation control is unavailable in this UAC surface.\");\n\t\treturn this._getWorkerController().getAgentControl().readWorkerAgentTranscript(agentId, options);\n\t}\n\n\tsendWorkerAgentMessage(\n\t\tagentId: string,\n\t\tmessage: string,\n\t\toptions?: WorkerAgentMessageOptions,\n\t): { messageId: string; queued: true } {\n\t\tif (!this.deps.isDelegateToolActive())\n\t\t\tthrow new Error(\"Worker delegation control is unavailable in this UAC surface.\");\n\t\treturn this._getWorkerController().getAgentControl().sendWorkerAgentMessage(agentId, message, options);\n\t}\n\n\tfollowUpWorkerAgent(\n\t\tagentId: string,\n\t\tmessage: string,\n\t\toptions?: WorkerAgentMessageOptions,\n\t): { started: boolean; steering: boolean; messageId: string; record?: LaneRecord; skipReason?: string } {\n\t\tif (!this.deps.isDelegateToolActive())\n\t\t\tthrow new Error(\"Worker delegation control is unavailable in this UAC surface.\");\n\t\treturn this._getWorkerController().getAgentControl().followUpWorkerAgent(agentId, message, options);\n\t}\n\n\tsendSessionRootWorkerAgentMessage(\n\t\tagentId: string,\n\t\tmessage: string,\n\t\toptions?: SessionRootWorkerAgentMessageOptions,\n\t): { messageId: string; queued: true } {\n\t\tif (!this.deps.isDelegateToolActive())\n\t\t\tthrow new Error(\"Worker delegation control is unavailable in this UAC surface.\");\n\t\treturn this._getWorkerController().getAgentControl().sendSessionRootWorkerAgentMessage(agentId, message, options);\n\t}\n\n\tfollowUpSessionRootWorkerAgent(\n\t\tagentId: string,\n\t\tmessage: string,\n\t\toptions?: SessionRootWorkerAgentMessageOptions,\n\t): { started: boolean; steering: boolean; messageId: string; record?: LaneRecord; skipReason?: string } {\n\t\tif (!this.deps.isDelegateToolActive())\n\t\t\tthrow new Error(\"Worker delegation control is unavailable in this UAC surface.\");\n\t\treturn this._getWorkerController().getAgentControl().followUpSessionRootWorkerAgent(agentId, message, options);\n\t}\n\n\treplyToWorkerAgentMessage(sourceAgentId: string, message: string, replyToMessageId: string): WorkerAgentReplyResult {\n\t\tif (!this.deps.isDelegateToolActive())\n\t\t\tthrow new Error(\"Worker delegation control is unavailable in this UAC surface.\");\n\t\treturn this._getWorkerController()\n\t\t\t.getAgentControl()\n\t\t\t.replyToWorkerAgentMessage(sourceAgentId, message, replyToMessageId);\n\t}\n\n\tlistSessionRootReplies(query?: SessionRootReplyQuery): SessionRootReply[] {\n\t\tif (!this.deps.isDelegateToolActive())\n\t\t\tthrow new Error(\"Worker delegation control is unavailable in this UAC surface.\");\n\t\treturn this._getWorkerController().getAgentControl().listSessionRootReplies(query);\n\t}\n\n\twaitForSessionRootReplies(options?: SessionRootReplyWaitOptions): Promise<SessionRootReplyWaitResult> {\n\t\tif (!this.deps.isDelegateToolActive())\n\t\t\tthrow new Error(\"Worker delegation control is unavailable in this UAC surface.\");\n\t\treturn this._getWorkerController().getAgentControl().waitForSessionRootReplies(options);\n\t}\n\n\tacknowledgeSessionRootReply(messageId: string, ackToken: string): boolean {\n\t\tif (!this.deps.isDelegateToolActive())\n\t\t\tthrow new Error(\"Worker delegation control is unavailable in this UAC surface.\");\n\t\treturn this._getWorkerController().getAgentControl().acknowledgeSessionRootReply(messageId, ackToken);\n\t}\n\n\treconcileSessionRootReplies(): void {\n\t\tif (!this.deps.isDelegateToolActive())\n\t\t\tthrow new Error(\"Worker delegation control is unavailable in this UAC surface.\");\n\t\tthis._getWorkerController().getAgentControl().reconcileSessionRootReplies();\n\t}\n\n\tstartWorkerAgentTask(\n\t\tagentId: string,\n\t\tmessage: string,\n\t\toptions?: WorkerAgentTaskStartOptions,\n\t): ReturnType<WorkerAgentControlPort[\"startWorkerAgentTask\"]> {\n\t\tif (!this.deps.isDelegateToolActive())\n\t\t\tthrow new Error(\"Worker delegation control is unavailable in this UAC surface.\");\n\t\treturn this._getWorkerController().getAgentControl().startWorkerAgentTask(agentId, message, options);\n\t}\n\n\tinterruptWorkerAgent(agentId: string, scope?: WorkerAgentControlScope): { interrupted: boolean; reason?: string } {\n\t\tif (!this.deps.isDelegateToolActive())\n\t\t\tthrow new Error(\"Worker delegation control is unavailable in this UAC surface.\");\n\t\treturn this._getWorkerController().getAgentControl().interruptWorkerAgent(agentId, scope);\n\t}\n\n\tresumeWorkerAgent(\n\t\tagentId: string,\n\t\tscope?: WorkerAgentControlScope,\n\t): { started: boolean; record?: LaneRecord; skipReason?: string } {\n\t\tif (!this.deps.isDelegateToolActive())\n\t\t\tthrow new Error(\"Worker delegation control is unavailable in this UAC surface.\");\n\t\treturn this._getWorkerController().getAgentControl().resumeWorkerAgent(agentId, scope);\n\t}\n\n\tcancelWorkerAgent(agentId: string, reasonCode?: string, scope?: WorkerAgentControlScope): LaneRecord | undefined {\n\t\tif (!this.deps.isDelegateToolActive())\n\t\t\tthrow new Error(\"Worker delegation control is unavailable in this UAC surface.\");\n\t\treturn this._getWorkerController().getAgentControl().cancelWorkerAgent(agentId, reasonCode, scope);\n\t}\n\n\tretireWorkerAgent(agentId: string, scope?: WorkerAgentControlScope): WorkerAgentRetireResult {\n\t\tif (!this.deps.isDelegateToolActive())\n\t\t\tthrow new Error(\"Worker delegation control is unavailable in this UAC surface.\");\n\t\treturn this._getWorkerController().getAgentControl().retireWorkerAgent(agentId, scope);\n\t}\n\n\twaitForWorkerAgent(\n\t\tagentId: string,\n\t\ttimeoutMs?: number,\n\t\tscope?: WorkerAgentControlScope,\n\t): Promise<{ status: WorkerAgentActivity }> {\n\t\tif (!this.deps.isDelegateToolActive())\n\t\t\tthrow new Error(\"Worker delegation control is unavailable in this UAC surface.\");\n\t\treturn this._getWorkerController().getAgentControl().waitForWorkerAgent(agentId, timeoutMs, scope);\n\t}\n\n\twaitForWorkerAgents(\n\t\tagentIds: readonly string[],\n\t\tmode: WorkerAgentWaitMode,\n\t\ttimeoutMs?: number,\n\t\tscope?: WorkerAgentControlScope,\n\t): Promise<WorkerAgentWaitResult> {\n\t\tif (!this.deps.isDelegateToolActive())\n\t\t\tthrow new Error(\"Worker delegation control is unavailable in this UAC surface.\");\n\t\treturn this._getWorkerController().getAgentControl().waitForWorkerAgents(agentIds, mode, timeoutMs, scope);\n\t}\n\n\tbroadcastWorkerAgentMessage(\n\t\tagentIds: readonly string[],\n\t\tmessage: string,\n\t\toptions: WorkerAgentBroadcastOptions,\n\t): WorkerAgentBroadcastResult {\n\t\tif (!this.deps.isDelegateToolActive())\n\t\t\tthrow new Error(\"Worker delegation control is unavailable in this UAC surface.\");\n\t\treturn this._getWorkerController().getAgentControl().broadcastWorkerAgentMessage(agentIds, message, options);\n\t}\n\n\t/** Run one worker immediately; used by focused integrations and tests. */\n\tasync runWorkerDelegationOnce(\n\t\trequest: WorkerDelegationRequest,\n\t\tonStarted?: (record: LaneRecord) => void,\n\t\texistingRecord?: LaneRecord,\n\t): Promise<WorkerDelegationRunOutcome> {\n\t\treturn this._getWorkerController().runOnce(request, onStarted, existingRecord);\n\t}\n\t/**\n\t * Probe a candidate model against the subagent contracts (research/worker/judge/search/\n\t * tool-call surfaces) via {@link runModelFitnessProbe}. The model must resolve and\n\t * authenticate; every probe call runs as an isolated completion on that model, and probe\n\t * spend is reported through spawned-usage accounting.\n\t */\n\tasync runModelFitness(args: {\n\t\tmodel: string;\n\t\ttrials?: number;\n\t\t/** LLM tool-call id, present only via the model_fitness tool path — see model-fitness.ts. */\n\t\ttoolCallId?: string;\n\t}): Promise<{ started: true; model: string; report: ModelFitnessReport } | { started: false; skipReason: string }> {\n\t\treturn this._fitness.run(args);\n\t}\n\n\t/** Start every capacity-eligible queued worker at the owner session's foreground-idle boundary. */\n\tdrainQueuedWorkerDelegations(): void {\n\t\tif (this.deps.isDelegateToolActive?.()) this._getWorkerController().drain();\n\t}\n\n\t/** Fitness reports persisted for THIS host (measured evidence for architect/profile decisions). */\n\tgetStoredFitnessReports(): StoredFitnessReport[] {\n\t\treturn this._fitness.getStoredReports();\n\t}\n}\n"]}
1
+ {"version":3,"file":"background-lane-controller.js","sourceRoot":"","sources":["../../src/core/background-lane-controller.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAUH,OAAO,EAAmB,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAC1E,OAAO,EAAE,wBAAwB,EAAE,4BAA4B,EAAE,MAAM,mCAAmC,CAAC;AAC3G,OAAO,EAAE,qBAAqB,EAAE,MAAM,yCAAyC,CAAC;AAsBhF,OAAO,EACN,0BAA0B,GAE1B,MAAM,8CAA8C,CAAC;AAEtD,OAAO,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;AACnE,OAAO,EAAE,6BAA6B,EAAE,MAAM,iDAAiD,CAAC;AAEhG,OAAO,EAAE,0BAA0B,EAAE,MAAM,0CAA0C,CAAC;AAWtF,OAAO,EAAE,iBAAiB,EAA8B,MAAM,mCAAmC,CAAC;AAElG,OAAO,EAAE,sBAAsB,EAAmC,MAAM,wCAAwC,CAAC;AACjH,OAAO,EAAE,sBAAsB,EAAmC,MAAM,wCAAwC,CAAC;AACjH,OAAO,EAAE,6BAA6B,EAAE,MAAM,uBAAuB,CAAC;AAEtE,OAAO,EAAE,qBAAqB,EAAE,MAAM,8CAA8C,CAAC;AACrF,OAAO,EAAE,eAAe,EAAE,MAAM,mCAAmC,CAAC;AA0BpE,MAAM,OAAO,wBAAwB;IAiBpC;oGACgG;IACxF,SAAS,CAAC,OAAe;QAChC,IAAI,CAAC;YACJ,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,CAAC,CAAC;Q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,CAAC,QAAQ,CAAC,gBAAgB,EAAE,CAAC;IACzC,CAAC;CACD","sourcesContent":["/**\n * Execution-plane coordinator for goal continuation, research, managed lanes, worker delegation,\n * and model fitness.\n *\n * Coordination state is owned by focused controllers. This coordinator retains one AgentSession\n * composition seam and a shared lane read model. Everything it needs\n * — the session manager, settings, model registry, live model, capability envelope, the goal\n * continuation LOOP, the isolated-completion primitive, spawned-usage accounting, and the telemetry\n * sink — is reached through narrow deps accessors rather than the whole AgentSession.\n *\n * Drive-loop boundary (deliberate): the idle triggers ({@link scheduleGoalAutoContinueFromIdle},\n * {@link scheduleResearchLaneFromIdle}) are invoked from the session's prompt tail as one-line\n * delegations; goal auto-continue itself only ever asks the session to `continueGoalLoop`, so this\n * controller never touches `prompt()`, the last-assistant-message, retry, or streaming state.\n */\n\nimport type { Api, Model } from \"@caupulican/pi-ai\";\nimport type {\n\tGoalContinuationLoopOptions,\n\tGoalContinuationLoopResult,\n\tPromptOptions,\n\tResearchLaneRunOutcome,\n\tWorkerDelegationRunOutcome,\n} from \"./agent-session-contracts.ts\";\nimport { type LaneRecord, LaneTracker } from \"./autonomy/lane-tracker.ts\";\nimport { appendLaneRecordSnapshot, getLatestLaneRecordSnapshots } from \"./autonomy/session-lane-record.ts\";\nimport { ManagedLaneController } from \"./delegation/managed-lane-controller.ts\";\nimport type {\n\tSessionRootReply,\n\tSessionRootReplyQuery,\n\tSessionRootReplyWaitOptions,\n\tSessionRootReplyWaitResult,\n} from \"./delegation/session-root-mailbox.ts\";\nimport type {\n\tSessionRootWorkerAgentMessageOptions,\n\tWorkerAgentActivity,\n\tWorkerAgentBroadcastOptions,\n\tWorkerAgentBroadcastResult,\n\tWorkerAgentControlPort,\n\tWorkerAgentControlScope,\n\tWorkerAgentMessageOptions,\n\tWorkerAgentReplyResult,\n\tWorkerAgentRetireResult,\n\tWorkerAgentTaskStartOptions,\n\tWorkerAgentTranscriptOptions,\n\tWorkerAgentWaitMode,\n\tWorkerAgentWaitResult,\n} from \"./delegation/worker-agent-control.ts\";\nimport {\n\tWorkerDelegationController,\n\ttype WorkerDelegationControllerDeps,\n} from \"./delegation/worker-delegation-controller.ts\";\nimport type { WorkerDelegationRequest } from \"./delegation/worker-delegation-request.ts\";\nimport { WorkerLifecycle } from \"./delegation/worker-lifecycle.ts\";\nimport { WorkerNotificationCoordinator } from \"./delegation/worker-notification-coordinator.ts\";\nimport type { ManagedLaneEvent } from \"./extensions/types.ts\";\nimport { GoalAutoContinueController } from \"./goals/goal-auto-continue-controller.ts\";\nimport type { GoalRuntimeSnapshot, GoalRuntimeSnapshotSettings } from \"./goals/goal-runtime-snapshot.ts\";\nimport type { GoalState } from \"./goals/goal-state.ts\";\nimport type { ModelCapabilityProfile } from \"./model-capability.ts\";\nimport type { StoredFitnessReport } from \"./models/fitness-store.ts\";\nimport type {\n\tTaskProfileCreateInput,\n\tTaskProfileCreateResult,\n\tTaskProfileInspection,\n} from \"./orchestration/task-profile-writer.ts\";\nimport type { TaskRuntimeProjection } from \"./orchestration/task-runtime.ts\";\nimport { LaneModelResolver, type LaneModelResolverDeps } from \"./research/lane-model-resolver.ts\";\nimport type { ModelFitnessReport } from \"./research/model-fitness.ts\";\nimport { ModelFitnessController, type ModelFitnessControllerDeps } from \"./research/model-fitness-controller.ts\";\nimport { ResearchLaneController, type ResearchLaneControllerDeps } from \"./research/research-lane-controller.ts\";\nimport { getActiveSessionBranchEntries } from \"./session-snapshot.ts\";\n\nexport { isLocalExecutionModel } from \"./delegation/worker-delegation-controller.ts\";\nexport { clampLaneMaxUsd } from \"./research/lane-model-resolver.ts\";\n\nexport interface BackgroundLaneControllerDeps\n\textends WorkerDelegationControllerDeps,\n\t\tResearchLaneControllerDeps,\n\t\tModelFitnessControllerDeps,\n\t\tLaneModelResolverDeps {\n\t/** True iff the `goal` tool is in the session's ACTIVE surface -- the capability-adaptive gate\n\t * for every goal-continuation loop (see `continueGoalLoopExclusive`): a surface without the\n\t * goal tool (lean capability blocklist, worker role ceiling, --tools/profile exclusion) must\n\t * never be driven with continuation prompts it cannot execute. */\n\tisGoalToolActive(): boolean;\n\t/** Capability profile of the SESSION model (gates background lanes, scales continuation budgets). */\n\tgetModelCapabilityProfile(): ModelCapabilityProfile;\n\t/** Continuation gate + goal state for the idle autosteer scheduler. */\n\tgetGoalRuntimeSnapshot(settings: GoalRuntimeSnapshotSettings): GoalRuntimeSnapshot;\n\t/** Drive-loop boundary: the session's bounded goal-continuation loop (owns `prompt()`, not us). */\n\tcontinueGoalLoop(options: GoalContinuationLoopOptions): Promise<GoalContinuationLoopResult>;\n\t/** True while the session owns a foreground prompt/retry/follow-up run. */\n\tisForegroundBusy(): boolean;\n\t/** Resolve only after the complete foreground retry/follow-up run releases the session. */\n\twaitForForegroundIdle(): Promise<void>;\n\t/** Persist an explicit stopped state when the selected surface cannot drive the active goal. */\n\tmarkGoalToolUnavailable(): void;\n}\n\nexport class BackgroundLaneController implements WorkerAgentControlPort {\n\t/** Live lane registry — the real source for AutonomyStatusSnapshot.activeLaneCount. */\n\tprivate readonly _laneTracker = new LaneTracker();\n\tprivate readonly _laneModels: LaneModelResolver;\n\tprivate readonly _goalAutoContinue: GoalAutoContinueController;\n\tprivate readonly _research: ResearchLaneController;\n\tprivate readonly _fitness: ModelFitnessController;\n\t/** Lazily materialized only when managed-lane state is queried or reported. */\n\tprivate _managedLanes: ManagedLaneController | undefined;\n\t/** Lazily materialized so a UAC surface without `delegate` allocates no worker runtime state. */\n\tprivate _workers: WorkerDelegationController | undefined;\n\t/** One durable lifecycle shared by every worker execution adapter. */\n\tprivate _workerLifecycle: WorkerLifecycle | undefined;\n\t/** Shared terminal outbox for managed and in-process workers; lazy under UAC omission. */\n\tprivate _workerNotifications: WorkerNotificationCoordinator | undefined;\n\tprivate readonly deps: BackgroundLaneControllerDeps;\n\n\t/** Emit a warning without ever throwing — used from disposal-adjacent persistence where a\n\t * listener failure (or a bare test double missing `emit`) must never block or crash cleanup. */\n\tprivate _safeWarn(message: string): void {\n\t\ttry {\n\t\t\tthis.deps.emit({ type: \"warning\", message });\n\t\t} catch {\n\t\t\t// Dispose must never throw.\n\t\t}\n\t}\n\n\tprivate _recordWorkerTerminal(record: LaneRecord, durableNotificationId: string): void {\n\t\tthis._getWorkerNotificationCoordinator().recordTerminal(record, durableNotificationId);\n\t}\n\n\tconstructor(deps: BackgroundLaneControllerDeps) {\n\t\tthis.deps = deps;\n\t\tthis._laneModels = new LaneModelResolver(deps);\n\t\tthis._research = new ResearchLaneController(deps, this._laneTracker, this._laneModels);\n\t\tthis._fitness = new ModelFitnessController(deps, this._laneModels);\n\t\tthis._goalAutoContinue = new GoalAutoContinueController({\n\t\t\tisDisposed: deps.isDisposed,\n\t\t\tisGoalToolActive: deps.isGoalToolActive,\n\t\t\tgetSettingsManager: deps.getSettingsManager,\n\t\t\tgetModelCapabilityProfile: deps.getModelCapabilityProfile,\n\t\t\tgetGoalRuntimeSnapshot: deps.getGoalRuntimeSnapshot,\n\t\t\thasInFlightLaneForGoal: (goalId) => this._hasInFlightLaneForGoal(goalId),\n\t\t\tcontinueGoalLoop: deps.continueGoalLoop,\n\t\t\tisForegroundBusy: deps.isForegroundBusy,\n\t\t\twaitForForegroundIdle: deps.waitForForegroundIdle,\n\t\t\tmarkGoalToolUnavailable: deps.markGoalToolUnavailable,\n\t\t\temit: deps.emit,\n\t\t});\n\t}\n\n\tprivate _getWorkerController(): WorkerDelegationController {\n\t\tthis._workers ??= new WorkerDelegationController(\n\t\t\tthis.deps,\n\t\t\tthis._getWorkerNotificationCoordinator(),\n\t\t\tthis._getWorkerLifecycle(),\n\t\t);\n\t\treturn this._workers;\n\t}\n\n\tprivate _getWorkerLifecycle(): WorkerLifecycle {\n\t\tif (this._workerLifecycle) return this._workerLifecycle;\n\t\tconst lifecycle = new WorkerLifecycle({\n\t\t\tagentDir: this.deps.getAgentDir(),\n\t\t\tsessionId: this.deps.getSessionId(),\n\t\t});\n\t\tthis._workerLifecycle = lifecycle;\n\t\tfor (const notification of lifecycle.getPendingTerminalNotifications()) {\n\t\t\tthis._getWorkerNotificationCoordinator().recordTerminal(notification.record, notification.notificationId);\n\t\t}\n\t\treturn lifecycle;\n\t}\n\n\tprivate _getWorkerNotificationCoordinator(): WorkerNotificationCoordinator {\n\t\tthis._workerNotifications ??= new WorkerNotificationCoordinator({\n\t\t\tgetWorkerRecords: () => this._workerLifecycle?.getAllRecords() ?? [],\n\t\t\temitStatus: (status) => {\n\t\t\t\ttry {\n\t\t\t\t\tthis.deps.emit({\n\t\t\t\t\t\ttype: \"delegate_workers\",\n\t\t\t\t\t\t...status,\n\t\t\t\t\t\tterminalSinceFlush: [...status.terminalSinceFlush],\n\t\t\t\t\t});\n\t\t\t\t} catch {\n\t\t\t\t\t// A partial integration must not crash the event-driven terminal outbox.\n\t\t\t\t}\n\t\t\t},\n\t\t\tnotify: (records) => this.deps.notifyWorkerTerminalHandoff(records),\n\t\t\twarn: (message) => this._safeWarn(message),\n\t\t\tmarkDurableDelivered: (notificationIds) => this._workerLifecycle?.markNotificationsDelivered(notificationIds),\n\t\t});\n\t\treturn this._workerNotifications;\n\t}\n\n\tprivate _getManagedLaneController(): ManagedLaneController {\n\t\tthis._managedLanes ??= new ManagedLaneController(\n\t\t\tthis.deps,\n\t\t\tthis._getWorkerLifecycle(),\n\t\t\t(record, notificationId) => this._recordWorkerTerminal(record, notificationId),\n\t\t\t(message) => this._safeWarn(message),\n\t\t);\n\t\treturn this._managedLanes;\n\t}\n\n\tprivate _hydrateManagedLanes(): void {\n\t\tif (this._managedLanes) {\n\t\t\tthis._managedLanes.ensureHydrated();\n\t\t\treturn;\n\t\t}\n\t\tconst hasPersistedActiveManagedLane = getLatestLaneRecordSnapshots(\n\t\t\tgetActiveSessionBranchEntries(this.deps.getSessionManager()),\n\t\t).some((record) => record.type === \"tmux-worker\" && (record.status === \"queued\" || record.status === \"running\"));\n\t\tif (hasPersistedActiveManagedLane) this._getManagedLaneController().ensureHydrated();\n\t}\n\n\t/** Live lane records tracked by this process (running and terminal). */\n\tgetLaneRecords(): LaneRecord[] {\n\t\tthis._hydrateManagedLanes();\n\t\tconst workerRecords =\n\t\t\tthis._workers?.getRecords() ??\n\t\t\t(this.deps.isDelegateToolActive?.() ? this._getWorkerController().getRecords() : []);\n\t\treturn [\n\t\t\t...this._laneTracker.getRecords(),\n\t\t\t...workerRecords,\n\t\t\t...(this._workerLifecycle?.getManagedRecords() ?? []),\n\t\t];\n\t}\n\n\t/** Does not materialize the worker controller when UAC omitted delegation. */\n\tgetTaskRuntimeSnapshot(): TaskRuntimeProjection | undefined {\n\t\treturn this._workerLifecycle?.getTaskRuntimeSnapshot();\n\t}\n\n\t/** Reconcile only when delegation has already been materialized; UAC omission stays zero-load. */\n\tsynchronizeGoalState(goal: GoalState): void {\n\t\tthis._workers?.synchronizeGoalState(goal);\n\t}\n\n\t/**\n\t * Resolve a tracked managed-lane dispatch. The caller's stable id is also the canonical durable\n\t * lane id, so this is an existence check rather than an id translation.\n\t */\n\tresolveManagedLaneId(callerLaneId: string): string | undefined {\n\t\treturn this._getManagedLaneController().resolve(callerLaneId);\n\t}\n\n\t/** Live count of active lanes — the real source for AutonomyStatusSnapshot.activeLaneCount. */\n\tgetActiveLaneCount(): number {\n\t\treturn this.getLaneRecords().filter((record) => record.status === \"queued\" || record.status === \"running\").length;\n\t}\n\n\t/** Belt-and-braces guard: whether ANY queued/running lane is tagged with this goalId. */\n\tprivate _hasInFlightLaneForGoal(goalId: string): boolean {\n\t\treturn this.getLaneRecords().some(\n\t\t\t(record) => record.goalId === goalId && (record.status === \"queued\" || record.status === \"running\"),\n\t\t);\n\t}\n\n\t/** Delegate the out-of-process dispatch/terminal claim to its single lifecycle owner. */\n\trecordManagedLane(event: ManagedLaneEvent): LaneRecord | undefined {\n\t\treturn this._getManagedLaneController().record(event);\n\t}\n\n\t/** Why the last idle research-lane evaluation skipped, for /autonomy diagnostics. */\n\tgetLastResearchLaneSkipReason(): string | undefined {\n\t\treturn this._research.getLastSkipReason();\n\t}\n\n\t/**\n\t * Abort in-flight research and delegate worker disposal to its single owning controller.\n\t *\n\t * This synchronous body is the LAST provably-safe write window for canceled/in-flight work.\n\t * `dispose()` (agent-session.ts) has already set the session's own disposed flag but has not yet\n\t * returned — no successor session (e.g. a `/reload` adoption) can exist yet, so an append here\n\t * cannot interleave with one; a post-await continuation resuming AFTER this method returns must\n\t * not append (see the disposed branch in `runWorkerDelegationOnce`). Persist FIRST, then\n\t * complete-in-memory, so a throw from one lane's persist cannot skip another's; each persist gets\n\t * its own try/catch — dispose must never throw.\n\t */\n\tabortInFlightLanes(): void {\n\t\tthis._goalAutoContinue.clearTimer();\n\t\tthis._research.abort();\n\t\tthis._fitness.abort();\n\t\tfor (const record of this._laneTracker.getRecords()) {\n\t\t\tif (record.status !== \"queued\" && record.status !== \"running\") continue;\n\t\t\tif (record.type === \"tmux-worker\") continue;\n\t\t\tconst canceled = this._laneTracker.complete(record.laneId, {\n\t\t\t\tstatus: \"canceled\",\n\t\t\t\treasonCode: \"session_disposed\",\n\t\t\t});\n\t\t\tif (!canceled) continue;\n\t\t\ttry {\n\t\t\t\tappendLaneRecordSnapshot(this.deps.getSessionManager(), canceled);\n\t\t\t} catch (error) {\n\t\t\t\tthis._safeWarn(\n\t\t\t\t\t`Failed to persist canceled lane record ${canceled.laneId}: ${error instanceof Error ? error.message : String(error)}`,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t\tthis._managedLanes?.release();\n\n\t\tthis._workers?.abort();\n\t\tthis._workerNotifications?.dispose();\n\t}\n\n\tclearGoalAutoContinueTimer(): void {\n\t\tthis._goalAutoContinue.clearTimer();\n\t}\n\n\tscheduleGoalAutoContinueFromIdle(options?: PromptOptions): void {\n\t\tthis._goalAutoContinue.scheduleFromIdle(options);\n\t}\n\n\t/**\n\t * Single-flight entry point for EVERY goal-continuation loop invocation — idle autosteer\n\t * ({@link _runScheduledGoalAutoContinue}) AND the manual `/goal start` / `/goal-continue`\n\t * commands (reached through `AgentSession.continueGoalLoop`). Both paths ultimately submit\n\t * continuation prompts through the session's single `prompt()` path, so two loops racing throws\n\t * \"Agent is already processing\" from whichever submits second. `_isGoalAutoContinuing` is the\n\t * ONE owner of that mutex; `deps.continueGoalLoop` (the raw {@link GoalLoopController} loop)\n\t * must never be called directly outside this method, or the guard is bypassed.\n\t */\n\tasync continueGoalLoopExclusive(options: GoalContinuationLoopOptions): Promise<GoalContinuationLoopResult> {\n\t\treturn this._goalAutoContinue.continueExclusive(options);\n\t}\n\n\tclearResearchLaneTimer(): void {\n\t\tthis._research.clearTimer();\n\t}\n\n\tscheduleResearchLaneFromIdle(): void {\n\t\tthis._research.scheduleFromIdle();\n\t}\n\n\tresolveLaneModel(configuredPattern: string | undefined): Model<Api> | undefined {\n\t\treturn this._laneModels.resolveModel(configuredPattern);\n\t}\n\n\tgetOrchestrationProfileCatalog(): Array<{ profileId: string; role: string; description: string }> {\n\t\treturn this._getWorkerController().getProfileCatalog();\n\t}\n\n\tinspectTaskProfileOptions(): TaskProfileInspection {\n\t\treturn this._getWorkerController().inspectTaskProfileOptions();\n\t}\n\n\tcreateTaskProfile(input: TaskProfileCreateInput): TaskProfileCreateResult {\n\t\treturn this._getWorkerController().createTaskProfile(input);\n\t}\n\n\t/**\n\t * Run one bounded, read-only research pass and persist its results: evidence bundle snapshot,\n\t * terminal lane record, and spawned-usage cost report (single-hop invariant, idempotent on the\n\t * lane's reportId). Explicit calls (e.g. `/autonomy research`) express user intent and bypass the\n\t * enabled/mode/dedupe gates the idle scheduler enforces; budget and capability gates always apply.\n\t */\n\tasync runResearchLaneOnce(request?: {\n\t\tquery?: string;\n\t\tcontext?: string;\n\t\tgoalId?: string;\n\t}): Promise<ResearchLaneRunOutcome> {\n\t\treturn this._research.runOnce(request);\n\t}\n\t/** Start a durable recursive agent with inherited, preset, or model-selected authority. */\n\tstartWorkerDelegation(\n\t\trequest: WorkerDelegationRequest,\n\t): { started: false; skipReason: string } | { started: true; record: LaneRecord } {\n\t\treturn this._getWorkerController().start(request);\n\t}\n\n\t/** Durable logical-worker controls. Each checks UAC before materializing worker state. */\n\tlistWorkerAgents(scope?: WorkerAgentControlScope): ReturnType<WorkerAgentControlPort[\"listWorkerAgents\"]> {\n\t\tif (!this.deps.isDelegateToolActive())\n\t\t\tthrow new Error(\"Worker delegation control is unavailable in this UAC surface.\");\n\t\treturn this._getWorkerController().getAgentControl().listWorkerAgents(scope);\n\t}\n\n\tgetWorkerTaskSessionView(): ReturnType<WorkerAgentControlPort[\"getWorkerTaskSessionView\"]> {\n\t\tif (!this.deps.isDelegateToolActive())\n\t\t\tthrow new Error(\"Worker delegation control is unavailable in this UAC surface.\");\n\t\treturn this._getWorkerController().getAgentControl().getWorkerTaskSessionView();\n\t}\n\n\tgetWorkerAgentActivity(agentId: string, scope?: WorkerAgentControlScope): WorkerAgentActivity {\n\t\tif (!this.deps.isDelegateToolActive())\n\t\t\tthrow new Error(\"Worker delegation control is unavailable in this UAC surface.\");\n\t\treturn this._getWorkerController().getAgentControl().getWorkerAgentActivity(agentId, scope);\n\t}\n\n\treadWorkerAgentTranscript(\n\t\tagentId: string,\n\t\toptions?: WorkerAgentTranscriptOptions,\n\t): ReturnType<WorkerAgentControlPort[\"readWorkerAgentTranscript\"]> {\n\t\tif (!this.deps.isDelegateToolActive())\n\t\t\tthrow new Error(\"Worker delegation control is unavailable in this UAC surface.\");\n\t\treturn this._getWorkerController().getAgentControl().readWorkerAgentTranscript(agentId, options);\n\t}\n\n\tsendWorkerAgentMessage(\n\t\tagentId: string,\n\t\tmessage: string,\n\t\toptions?: WorkerAgentMessageOptions,\n\t): { messageId: string; queued: true } {\n\t\tif (!this.deps.isDelegateToolActive())\n\t\t\tthrow new Error(\"Worker delegation control is unavailable in this UAC surface.\");\n\t\treturn this._getWorkerController().getAgentControl().sendWorkerAgentMessage(agentId, message, options);\n\t}\n\n\tfollowUpWorkerAgent(\n\t\tagentId: string,\n\t\tmessage: string,\n\t\toptions?: WorkerAgentMessageOptions,\n\t): { started: boolean; steering: boolean; messageId: string; record?: LaneRecord; skipReason?: string } {\n\t\tif (!this.deps.isDelegateToolActive())\n\t\t\tthrow new Error(\"Worker delegation control is unavailable in this UAC surface.\");\n\t\treturn this._getWorkerController().getAgentControl().followUpWorkerAgent(agentId, message, options);\n\t}\n\n\tsendSessionRootWorkerAgentMessage(\n\t\tagentId: string,\n\t\tmessage: string,\n\t\toptions?: SessionRootWorkerAgentMessageOptions,\n\t): { messageId: string; queued: true } {\n\t\tif (!this.deps.isDelegateToolActive())\n\t\t\tthrow new Error(\"Worker delegation control is unavailable in this UAC surface.\");\n\t\treturn this._getWorkerController().getAgentControl().sendSessionRootWorkerAgentMessage(agentId, message, options);\n\t}\n\n\tfollowUpSessionRootWorkerAgent(\n\t\tagentId: string,\n\t\tmessage: string,\n\t\toptions?: SessionRootWorkerAgentMessageOptions,\n\t): { started: boolean; steering: boolean; messageId: string; record?: LaneRecord; skipReason?: string } {\n\t\tif (!this.deps.isDelegateToolActive())\n\t\t\tthrow new Error(\"Worker delegation control is unavailable in this UAC surface.\");\n\t\treturn this._getWorkerController().getAgentControl().followUpSessionRootWorkerAgent(agentId, message, options);\n\t}\n\n\treplyToWorkerAgentMessage(sourceAgentId: string, message: string, replyToMessageId: string): WorkerAgentReplyResult {\n\t\tif (!this.deps.isDelegateToolActive())\n\t\t\tthrow new Error(\"Worker delegation control is unavailable in this UAC surface.\");\n\t\treturn this._getWorkerController()\n\t\t\t.getAgentControl()\n\t\t\t.replyToWorkerAgentMessage(sourceAgentId, message, replyToMessageId);\n\t}\n\n\tlistSessionRootReplies(query?: SessionRootReplyQuery): SessionRootReply[] {\n\t\tif (!this.deps.isDelegateToolActive())\n\t\t\tthrow new Error(\"Worker delegation control is unavailable in this UAC surface.\");\n\t\treturn this._getWorkerController().getAgentControl().listSessionRootReplies(query);\n\t}\n\n\twaitForSessionRootReplies(options?: SessionRootReplyWaitOptions): Promise<SessionRootReplyWaitResult> {\n\t\tif (!this.deps.isDelegateToolActive())\n\t\t\tthrow new Error(\"Worker delegation control is unavailable in this UAC surface.\");\n\t\treturn this._getWorkerController().getAgentControl().waitForSessionRootReplies(options);\n\t}\n\n\tacknowledgeSessionRootReply(messageId: string, ackToken: string): boolean {\n\t\tif (!this.deps.isDelegateToolActive())\n\t\t\tthrow new Error(\"Worker delegation control is unavailable in this UAC surface.\");\n\t\treturn this._getWorkerController().getAgentControl().acknowledgeSessionRootReply(messageId, ackToken);\n\t}\n\n\treconcileSessionRootReplies(): void {\n\t\tif (!this.deps.isDelegateToolActive())\n\t\t\tthrow new Error(\"Worker delegation control is unavailable in this UAC surface.\");\n\t\tthis._getWorkerController().getAgentControl().reconcileSessionRootReplies();\n\t}\n\n\tstartWorkerAgentTask(\n\t\tagentId: string,\n\t\tmessage: string,\n\t\toptions?: WorkerAgentTaskStartOptions,\n\t): ReturnType<WorkerAgentControlPort[\"startWorkerAgentTask\"]> {\n\t\tif (!this.deps.isDelegateToolActive())\n\t\t\tthrow new Error(\"Worker delegation control is unavailable in this UAC surface.\");\n\t\treturn this._getWorkerController().getAgentControl().startWorkerAgentTask(agentId, message, options);\n\t}\n\n\tinterruptWorkerAgent(agentId: string, scope?: WorkerAgentControlScope): { interrupted: boolean; reason?: string } {\n\t\tif (!this.deps.isDelegateToolActive())\n\t\t\tthrow new Error(\"Worker delegation control is unavailable in this UAC surface.\");\n\t\treturn this._getWorkerController().getAgentControl().interruptWorkerAgent(agentId, scope);\n\t}\n\n\tresumeWorkerAgent(\n\t\tagentId: string,\n\t\tscope?: WorkerAgentControlScope,\n\t): { started: boolean; record?: LaneRecord; skipReason?: string } {\n\t\tif (!this.deps.isDelegateToolActive())\n\t\t\tthrow new Error(\"Worker delegation control is unavailable in this UAC surface.\");\n\t\treturn this._getWorkerController().getAgentControl().resumeWorkerAgent(agentId, scope);\n\t}\n\n\tcancelWorkerAgent(agentId: string, reasonCode?: string, scope?: WorkerAgentControlScope): LaneRecord | undefined {\n\t\tif (!this.deps.isDelegateToolActive())\n\t\t\tthrow new Error(\"Worker delegation control is unavailable in this UAC surface.\");\n\t\treturn this._getWorkerController().getAgentControl().cancelWorkerAgent(agentId, reasonCode, scope);\n\t}\n\n\tretireWorkerAgent(agentId: string, scope?: WorkerAgentControlScope): WorkerAgentRetireResult {\n\t\tif (!this.deps.isDelegateToolActive())\n\t\t\tthrow new Error(\"Worker delegation control is unavailable in this UAC surface.\");\n\t\treturn this._getWorkerController().getAgentControl().retireWorkerAgent(agentId, scope);\n\t}\n\n\twaitForWorkerAgent(\n\t\tagentId: string,\n\t\ttimeoutMs?: number,\n\t\tscope?: WorkerAgentControlScope,\n\t): ReturnType<WorkerAgentControlPort[\"waitForWorkerAgent\"]> {\n\t\tif (!this.deps.isDelegateToolActive())\n\t\t\tthrow new Error(\"Worker delegation control is unavailable in this UAC surface.\");\n\t\treturn this._getWorkerController().getAgentControl().waitForWorkerAgent(agentId, timeoutMs, scope);\n\t}\n\n\twaitForWorkerAgents(\n\t\tagentIds: readonly string[],\n\t\tmode: WorkerAgentWaitMode,\n\t\ttimeoutMs?: number,\n\t\tscope?: WorkerAgentControlScope,\n\t): Promise<WorkerAgentWaitResult> {\n\t\tif (!this.deps.isDelegateToolActive())\n\t\t\tthrow new Error(\"Worker delegation control is unavailable in this UAC surface.\");\n\t\treturn this._getWorkerController().getAgentControl().waitForWorkerAgents(agentIds, mode, timeoutMs, scope);\n\t}\n\n\tbroadcastWorkerAgentMessage(\n\t\tagentIds: readonly string[],\n\t\tmessage: string,\n\t\toptions: WorkerAgentBroadcastOptions,\n\t): WorkerAgentBroadcastResult {\n\t\tif (!this.deps.isDelegateToolActive())\n\t\t\tthrow new Error(\"Worker delegation control is unavailable in this UAC surface.\");\n\t\treturn this._getWorkerController().getAgentControl().broadcastWorkerAgentMessage(agentIds, message, options);\n\t}\n\n\t/** Run one worker immediately; used by focused integrations and tests. */\n\tasync runWorkerDelegationOnce(\n\t\trequest: WorkerDelegationRequest,\n\t\tonStarted?: (record: LaneRecord) => void,\n\t\texistingRecord?: LaneRecord,\n\t): Promise<WorkerDelegationRunOutcome> {\n\t\treturn this._getWorkerController().runOnce(request, onStarted, existingRecord);\n\t}\n\t/**\n\t * Probe a candidate model against the subagent contracts (research/worker/judge/search/\n\t * tool-call surfaces) via {@link runModelFitnessProbe}. The model must resolve and\n\t * authenticate; every probe call runs as an isolated completion on that model, and probe\n\t * spend is reported through spawned-usage accounting.\n\t */\n\tasync runModelFitness(args: {\n\t\tmodel: string;\n\t\ttrials?: number;\n\t\t/** LLM tool-call id, present only via the model_fitness tool path — see model-fitness.ts. */\n\t\ttoolCallId?: string;\n\t}): Promise<{ started: true; model: string; report: ModelFitnessReport } | { started: false; skipReason: string }> {\n\t\treturn this._fitness.run(args);\n\t}\n\n\t/** Start every capacity-eligible queued worker at the owner session's foreground-idle boundary. */\n\tdrainQueuedWorkerDelegations(): void {\n\t\tif (this.deps.isDelegateToolActive?.()) this._getWorkerController().drain();\n\t}\n\n\t/** Fitness reports persisted for THIS host (measured evidence for architect/profile decisions). */\n\tgetStoredFitnessReports(): StoredFitnessReport[] {\n\t\treturn this._fitness.getStoredReports();\n\t}\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"compaction-controller.d.ts","sourceRoot":"","sources":["../../src/core/compaction-controller.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,iCAAiC,CAAC;AAC7D,OAAO,EAGN,KAAK,gBAAgB,EACrB,KAAK,kBAAkB,EAOvB,MAAM,iDAAiD,CAAC;AASzD,OAAO,EAAkD,KAAK,cAAc,EAAE,MAAM,mCAAmC,CAAC;AACxH,OAAO,KAAK,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AACnF,OAAO,KAAK,EAAE,GAAG,EAAE,gBAAgB,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAItE,OAAO,KAAK,EAAE,eAAe,EAA8B,MAAM,uBAAuB,CAAC;AACzF,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,qBA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okens !== settings.keepRecentTokens ||
504
504
  frontier.triggerPercent !== settings.triggerPercent ||
505
- contextTokens < frontier.tokensAfter ||
506
505
  contextTokens >= frontier.retryAtTokens) {
507
506
  this.ineffectiveThresholdFrontier = undefined;
508
507
  return false;