@caupulican/pi-adaptative 0.81.39 → 0.81.41

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 (884) hide show
  1. package/CHANGELOG.md +77 -0
  2. package/README.md +2 -0
  3. package/dist/bundled-resources/extensions/tmux-agent-manager/dispatch-grant.d.ts +2 -0
  4. package/dist/bundled-resources/extensions/tmux-agent-manager/dispatch-grant.d.ts.map +1 -1
  5. package/dist/bundled-resources/extensions/tmux-agent-manager/dispatch-grant.js +3 -0
  6. package/dist/bundled-resources/extensions/tmux-agent-manager/dispatch-grant.js.map +1 -1
  7. package/dist/bundled-resources/extensions/tmux-agent-manager/dispatch-grant.ts +4 -0
  8. package/dist/bundled-resources/extensions/tmux-agent-manager/index.d.ts +9 -0
  9. package/dist/bundled-resources/extensions/tmux-agent-manager/index.d.ts.map +1 -1
  10. package/dist/bundled-resources/extensions/tmux-agent-manager/index.js +290 -107
  11. package/dist/bundled-resources/extensions/tmux-agent-manager/index.js.map +1 -1
  12. package/dist/bundled-resources/extensions/tmux-agent-manager/index.ts +357 -122
  13. package/dist/bundled-resources/skills/tool-call-repair/references/repair-catalogue.md +2 -2
  14. package/dist/cli/args.d.ts +4 -0
  15. package/dist/cli/args.d.ts.map +1 -1
  16. package/dist/cli/args.js +31 -1
  17. package/dist/cli/args.js.map +1 -1
  18. package/dist/core/agent-directory-layout.d.ts +15 -0
  19. package/dist/core/agent-directory-layout.d.ts.map +1 -0
  20. package/dist/core/agent-directory-layout.js +72 -0
  21. package/dist/core/agent-directory-layout.js.map +1 -0
  22. package/dist/core/agent-paths.d.ts +25 -2
  23. package/dist/core/agent-paths.d.ts.map +1 -1
  24. package/dist/core/agent-paths.js +79 -4
  25. package/dist/core/agent-paths.js.map +1 -1
  26. package/dist/core/agent-session-contracts.d.ts +293 -0
  27. package/dist/core/agent-session-contracts.d.ts.map +1 -0
  28. package/dist/core/agent-session-contracts.js +26 -0
  29. package/dist/core/agent-session-contracts.js.map +1 -0
  30. package/dist/core/agent-session-runtime.d.ts +52 -8
  31. package/dist/core/agent-session-runtime.d.ts.map +1 -1
  32. package/dist/core/agent-session-runtime.js +400 -79
  33. package/dist/core/agent-session-runtime.js.map +1 -1
  34. package/dist/core/agent-session-services.d.ts +1 -0
  35. package/dist/core/agent-session-services.d.ts.map +1 -1
  36. package/dist/core/agent-session-services.js +1 -0
  37. package/dist/core/agent-session-services.js.map +1 -1
  38. package/dist/core/agent-session.d.ts +74 -518
  39. package/dist/core/agent-session.d.ts.map +1 -1
  40. package/dist/core/agent-session.js +370 -1432
  41. package/dist/core/agent-session.js.map +1 -1
  42. package/dist/core/auth-storage.d.ts.map +1 -1
  43. package/dist/core/auth-storage.js +3 -1
  44. package/dist/core/auth-storage.js.map +1 -1
  45. package/dist/core/autonomy/approval-gate.d.ts +3 -2
  46. package/dist/core/autonomy/approval-gate.d.ts.map +1 -1
  47. package/dist/core/autonomy/approval-gate.js +6 -28
  48. package/dist/core/autonomy/approval-gate.js.map +1 -1
  49. package/dist/core/autonomy/bounded-completion.d.ts +1 -1
  50. package/dist/core/autonomy/bounded-completion.d.ts.map +1 -1
  51. package/dist/core/autonomy/bounded-completion.js +1 -1
  52. package/dist/core/autonomy/bounded-completion.js.map +1 -1
  53. package/dist/core/autonomy/contracts.d.ts +20 -12
  54. package/dist/core/autonomy/contracts.d.ts.map +1 -1
  55. package/dist/core/autonomy/contracts.js.map +1 -1
  56. package/dist/core/autonomy/foreground-envelope.d.ts +8 -2
  57. package/dist/core/autonomy/foreground-envelope.d.ts.map +1 -1
  58. package/dist/core/autonomy/foreground-envelope.js +8 -25
  59. package/dist/core/autonomy/foreground-envelope.js.map +1 -1
  60. package/dist/core/autonomy/gates.d.ts.map +1 -1
  61. package/dist/core/autonomy/gates.js +8 -10
  62. package/dist/core/autonomy/gates.js.map +1 -1
  63. package/dist/core/autonomy/lane-private-paths.d.ts +2 -0
  64. package/dist/core/autonomy/lane-private-paths.d.ts.map +1 -0
  65. package/dist/core/autonomy/lane-private-paths.js +16 -0
  66. package/dist/core/autonomy/lane-private-paths.js.map +1 -0
  67. package/dist/core/autonomy/lane-tool-surface.d.ts +10 -0
  68. package/dist/core/autonomy/lane-tool-surface.d.ts.map +1 -1
  69. package/dist/core/autonomy/lane-tool-surface.js +48 -9
  70. package/dist/core/autonomy/lane-tool-surface.js.map +1 -1
  71. package/dist/core/autonomy/lane-tracker.d.ts +14 -0
  72. package/dist/core/autonomy/lane-tracker.d.ts.map +1 -1
  73. package/dist/core/autonomy/lane-tracker.js +38 -0
  74. package/dist/core/autonomy/lane-tracker.js.map +1 -1
  75. package/dist/core/autonomy/risk-assessment.d.ts +1 -2
  76. package/dist/core/autonomy/risk-assessment.d.ts.map +1 -1
  77. package/dist/core/autonomy/risk-assessment.js +1 -123
  78. package/dist/core/autonomy/risk-assessment.js.map +1 -1
  79. package/dist/core/autonomy/session-lane-record.d.ts +4 -4
  80. package/dist/core/autonomy/session-lane-record.d.ts.map +1 -1
  81. package/dist/core/autonomy/session-lane-record.js +16 -29
  82. package/dist/core/autonomy/session-lane-record.js.map +1 -1
  83. package/dist/core/autonomy/telemetry-events.d.ts +1 -1
  84. package/dist/core/autonomy/telemetry-events.d.ts.map +1 -1
  85. package/dist/core/autonomy/telemetry-events.js +1 -1
  86. package/dist/core/autonomy/telemetry-events.js.map +1 -1
  87. package/dist/core/autonomy-telemetry.d.ts +7 -7
  88. package/dist/core/autonomy-telemetry.d.ts.map +1 -1
  89. package/dist/core/autonomy-telemetry.js +9 -9
  90. package/dist/core/autonomy-telemetry.js.map +1 -1
  91. package/dist/core/background-lane-controller.d.ts +56 -236
  92. package/dist/core/background-lane-controller.d.ts.map +1 -1
  93. package/dist/core/background-lane-controller.js +141 -1273
  94. package/dist/core/background-lane-controller.js.map +1 -1
  95. package/dist/core/bedrock-sso-login.d.ts +16 -0
  96. package/dist/core/bedrock-sso-login.d.ts.map +1 -0
  97. package/dist/core/bedrock-sso-login.js +98 -0
  98. package/dist/core/bedrock-sso-login.js.map +1 -0
  99. package/dist/core/capability-contract.d.ts +4 -0
  100. package/dist/core/capability-contract.d.ts.map +1 -0
  101. package/dist/core/capability-contract.js +28 -0
  102. package/dist/core/capability-contract.js.map +1 -0
  103. package/dist/core/compaction-controller.d.ts +90 -0
  104. package/dist/core/compaction-controller.d.ts.map +1 -0
  105. package/dist/core/compaction-controller.js +452 -0
  106. package/dist/core/compaction-controller.js.map +1 -0
  107. package/dist/core/compaction-support.d.ts +13 -17
  108. package/dist/core/compaction-support.d.ts.map +1 -1
  109. package/dist/core/compaction-support.js +3 -3
  110. package/dist/core/compaction-support.js.map +1 -1
  111. package/dist/core/context/context-artifacts.d.ts +6 -2
  112. package/dist/core/context/context-artifacts.d.ts.map +1 -1
  113. package/dist/core/context/context-artifacts.js +34 -2
  114. package/dist/core/context/context-artifacts.js.map +1 -1
  115. package/dist/core/context/context-store-retention.d.ts +8 -2
  116. package/dist/core/context/context-store-retention.d.ts.map +1 -1
  117. package/dist/core/context/context-store-retention.js +158 -35
  118. package/dist/core/context/context-store-retention.js.map +1 -1
  119. package/dist/core/context/okf-memory.d.ts.map +1 -1
  120. package/dist/core/context/okf-memory.js +9 -11
  121. package/dist/core/context/okf-memory.js.map +1 -1
  122. package/dist/core/context/sqlite-runtime-index.d.ts.map +1 -1
  123. package/dist/core/context/sqlite-runtime-index.js +6 -8
  124. package/dist/core/context/sqlite-runtime-index.js.map +1 -1
  125. package/dist/core/context-gc.d.ts +3 -0
  126. package/dist/core/context-gc.d.ts.map +1 -1
  127. package/dist/core/context-gc.js +10 -5
  128. package/dist/core/context-gc.js.map +1 -1
  129. package/dist/core/context-pipeline.d.ts +1 -1
  130. package/dist/core/context-pipeline.d.ts.map +1 -1
  131. package/dist/core/context-pipeline.js +16 -37
  132. package/dist/core/context-pipeline.js.map +1 -1
  133. package/dist/core/cost/cost-summary.d.ts.map +1 -1
  134. package/dist/core/cost/cost-summary.js +5 -3
  135. package/dist/core/cost/cost-summary.js.map +1 -1
  136. package/dist/core/cost/daily-usage.d.ts.map +1 -1
  137. package/dist/core/cost/daily-usage.js +4 -5
  138. package/dist/core/cost/daily-usage.js.map +1 -1
  139. package/dist/core/default-tool-surface.d.ts.map +1 -1
  140. package/dist/core/default-tool-surface.js +2 -0
  141. package/dist/core/default-tool-surface.js.map +1 -1
  142. package/dist/core/delegation/managed-lane-controller.d.ts +34 -0
  143. package/dist/core/delegation/managed-lane-controller.d.ts.map +1 -0
  144. package/dist/core/delegation/managed-lane-controller.js +217 -0
  145. package/dist/core/delegation/managed-lane-controller.js.map +1 -0
  146. package/dist/core/delegation/session-worker-claim.d.ts +44 -0
  147. package/dist/core/delegation/session-worker-claim.d.ts.map +1 -0
  148. package/dist/core/delegation/session-worker-claim.js +98 -0
  149. package/dist/core/delegation/session-worker-claim.js.map +1 -0
  150. package/dist/core/delegation/worker-actions.d.ts +7 -5
  151. package/dist/core/delegation/worker-actions.d.ts.map +1 -1
  152. package/dist/core/delegation/worker-actions.js +20 -4
  153. package/dist/core/delegation/worker-actions.js.map +1 -1
  154. package/dist/core/delegation/{worker-result.d.ts → worker-claim.d.ts} +13 -13
  155. package/dist/core/delegation/worker-claim.d.ts.map +1 -0
  156. package/dist/core/delegation/{worker-result.js → worker-claim.js} +61 -51
  157. package/dist/core/delegation/worker-claim.js.map +1 -0
  158. package/dist/core/delegation/worker-delegation-controller.d.ts +110 -0
  159. package/dist/core/delegation/worker-delegation-controller.d.ts.map +1 -0
  160. package/dist/core/delegation/worker-delegation-controller.js +861 -0
  161. package/dist/core/delegation/worker-delegation-controller.js.map +1 -0
  162. package/dist/core/delegation/worker-delegation-request.d.ts +11 -0
  163. package/dist/core/delegation/worker-delegation-request.d.ts.map +1 -0
  164. package/dist/core/delegation/worker-delegation-request.js +2 -0
  165. package/dist/core/delegation/worker-delegation-request.js.map +1 -0
  166. package/dist/core/delegation/worker-dispatch-scheduler.d.ts +40 -0
  167. package/dist/core/delegation/worker-dispatch-scheduler.d.ts.map +1 -0
  168. package/dist/core/delegation/worker-dispatch-scheduler.js +93 -0
  169. package/dist/core/delegation/worker-dispatch-scheduler.js.map +1 -0
  170. package/dist/core/delegation/worker-execution-policy.d.ts +62 -0
  171. package/dist/core/delegation/worker-execution-policy.d.ts.map +1 -0
  172. package/dist/core/delegation/worker-execution-policy.js +160 -0
  173. package/dist/core/delegation/worker-execution-policy.js.map +1 -0
  174. package/dist/core/delegation/worker-lane-projection.d.ts +14 -0
  175. package/dist/core/delegation/worker-lane-projection.d.ts.map +1 -0
  176. package/dist/core/delegation/worker-lane-projection.js +100 -0
  177. package/dist/core/delegation/worker-lane-projection.js.map +1 -0
  178. package/dist/core/delegation/worker-lifecycle.d.ts +97 -0
  179. package/dist/core/delegation/worker-lifecycle.d.ts.map +1 -0
  180. package/dist/core/delegation/worker-lifecycle.js +339 -0
  181. package/dist/core/delegation/worker-lifecycle.js.map +1 -0
  182. package/dist/core/delegation/worker-notification-coordinator.d.ts +36 -0
  183. package/dist/core/delegation/worker-notification-coordinator.d.ts.map +1 -0
  184. package/dist/core/delegation/worker-notification-coordinator.js +90 -0
  185. package/dist/core/delegation/worker-notification-coordinator.js.map +1 -0
  186. package/dist/core/delegation/worker-profile-resolver.d.ts +55 -0
  187. package/dist/core/delegation/worker-profile-resolver.d.ts.map +1 -0
  188. package/dist/core/delegation/worker-profile-resolver.js +113 -0
  189. package/dist/core/delegation/worker-profile-resolver.js.map +1 -0
  190. package/dist/core/delegation/worker-runner.d.ts +25 -14
  191. package/dist/core/delegation/worker-runner.d.ts.map +1 -1
  192. package/dist/core/delegation/worker-runner.js +122 -53
  193. package/dist/core/delegation/worker-runner.js.map +1 -1
  194. package/dist/core/delegation/worker-task-label.d.ts +3 -0
  195. package/dist/core/delegation/worker-task-label.d.ts.map +1 -0
  196. package/dist/core/delegation/worker-task-label.js +11 -0
  197. package/dist/core/delegation/worker-task-label.js.map +1 -0
  198. package/dist/core/doctor.d.ts +8 -0
  199. package/dist/core/doctor.d.ts.map +1 -1
  200. package/dist/core/doctor.js +32 -1
  201. package/dist/core/doctor.js.map +1 -1
  202. package/dist/core/extension-import-authority.d.ts +6 -0
  203. package/dist/core/extension-import-authority.d.ts.map +1 -0
  204. package/dist/core/extension-import-authority.js +10 -0
  205. package/dist/core/extension-import-authority.js.map +1 -0
  206. package/dist/core/extensions/index.d.ts +1 -1
  207. package/dist/core/extensions/index.d.ts.map +1 -1
  208. package/dist/core/extensions/index.js.map +1 -1
  209. package/dist/core/extensions/loader.d.ts +5 -1
  210. package/dist/core/extensions/loader.d.ts.map +1 -1
  211. package/dist/core/extensions/loader.js +52 -18
  212. package/dist/core/extensions/loader.js.map +1 -1
  213. package/dist/core/extensions/runner.d.ts +3 -0
  214. package/dist/core/extensions/runner.d.ts.map +1 -1
  215. package/dist/core/extensions/runner.js +20 -5
  216. package/dist/core/extensions/runner.js.map +1 -1
  217. package/dist/core/extensions/stale-context.d.ts +2 -0
  218. package/dist/core/extensions/stale-context.d.ts.map +1 -0
  219. package/dist/core/extensions/stale-context.js +2 -0
  220. package/dist/core/extensions/stale-context.js.map +1 -0
  221. package/dist/core/extensions/storage.d.ts +8 -0
  222. package/dist/core/extensions/storage.d.ts.map +1 -0
  223. package/dist/core/extensions/storage.js +28 -0
  224. package/dist/core/extensions/storage.js.map +1 -0
  225. package/dist/core/extensions/types.d.ts +78 -21
  226. package/dist/core/extensions/types.d.ts.map +1 -1
  227. package/dist/core/extensions/types.js.map +1 -1
  228. package/dist/core/failure-corpus.d.ts +1 -15
  229. package/dist/core/failure-corpus.d.ts.map +1 -1
  230. package/dist/core/failure-corpus.js +9 -37
  231. package/dist/core/failure-corpus.js.map +1 -1
  232. package/dist/core/foreground-recovery-controller.d.ts +53 -0
  233. package/dist/core/foreground-recovery-controller.d.ts.map +1 -0
  234. package/dist/core/foreground-recovery-controller.js +111 -0
  235. package/dist/core/foreground-recovery-controller.js.map +1 -0
  236. package/dist/core/gateways/channel-provider.d.ts +3 -0
  237. package/dist/core/gateways/channel-provider.d.ts.map +1 -1
  238. package/dist/core/gateways/channel-provider.js +31 -6
  239. package/dist/core/gateways/channel-provider.js.map +1 -1
  240. package/dist/core/goal-loop-controller.d.ts +14 -9
  241. package/dist/core/goal-loop-controller.d.ts.map +1 -1
  242. package/dist/core/goal-loop-controller.js +47 -75
  243. package/dist/core/goal-loop-controller.js.map +1 -1
  244. package/dist/core/goals/compact-goal-context.d.ts +11 -0
  245. package/dist/core/goals/compact-goal-context.d.ts.map +1 -0
  246. package/dist/core/goals/compact-goal-context.js +59 -0
  247. package/dist/core/goals/compact-goal-context.js.map +1 -0
  248. package/dist/core/goals/goal-acceptance.d.ts +11 -0
  249. package/dist/core/goals/goal-acceptance.d.ts.map +1 -0
  250. package/dist/core/goals/goal-acceptance.js +27 -0
  251. package/dist/core/goals/goal-acceptance.js.map +1 -0
  252. package/dist/core/goals/goal-auto-continue-controller.d.ts +28 -0
  253. package/dist/core/goals/goal-auto-continue-controller.d.ts.map +1 -0
  254. package/dist/core/goals/goal-auto-continue-controller.js +90 -0
  255. package/dist/core/goals/goal-auto-continue-controller.js.map +1 -0
  256. package/dist/core/goals/goal-continuation-controller.d.ts +2 -2
  257. package/dist/core/goals/goal-continuation-controller.d.ts.map +1 -1
  258. package/dist/core/goals/goal-continuation-controller.js +52 -11
  259. package/dist/core/goals/goal-continuation-controller.js.map +1 -1
  260. package/dist/core/goals/goal-continuation-defaults.d.ts +4 -29
  261. package/dist/core/goals/goal-continuation-defaults.d.ts.map +1 -1
  262. package/dist/core/goals/goal-continuation-defaults.js +4 -32
  263. package/dist/core/goals/goal-continuation-defaults.js.map +1 -1
  264. package/dist/core/goals/goal-continuation-prompt.d.ts +8 -18
  265. package/dist/core/goals/goal-continuation-prompt.d.ts.map +1 -1
  266. package/dist/core/goals/goal-continuation-prompt.js +9 -179
  267. package/dist/core/goals/goal-continuation-prompt.js.map +1 -1
  268. package/dist/core/goals/goal-lifecycle.d.ts +43 -0
  269. package/dist/core/goals/goal-lifecycle.d.ts.map +1 -0
  270. package/dist/core/goals/goal-lifecycle.js +102 -0
  271. package/dist/core/goals/goal-lifecycle.js.map +1 -0
  272. package/dist/core/goals/goal-record.d.ts +17 -0
  273. package/dist/core/goals/goal-record.d.ts.map +1 -0
  274. package/dist/core/goals/goal-record.js +31 -0
  275. package/dist/core/goals/goal-record.js.map +1 -0
  276. package/dist/core/goals/goal-runtime-snapshot.d.ts +11 -9
  277. package/dist/core/goals/goal-runtime-snapshot.d.ts.map +1 -1
  278. package/dist/core/goals/goal-runtime-snapshot.js +10 -8
  279. package/dist/core/goals/goal-runtime-snapshot.js.map +1 -1
  280. package/dist/core/goals/goal-session-controller.d.ts +42 -0
  281. package/dist/core/goals/goal-session-controller.d.ts.map +1 -0
  282. package/dist/core/goals/goal-session-controller.js +128 -0
  283. package/dist/core/goals/goal-session-controller.js.map +1 -0
  284. package/dist/core/goals/goal-state.d.ts +46 -25
  285. package/dist/core/goals/goal-state.d.ts.map +1 -1
  286. package/dist/core/goals/goal-state.js +91 -24
  287. package/dist/core/goals/goal-state.js.map +1 -1
  288. package/dist/core/goals/goal-tool-core.d.ts +9 -10
  289. package/dist/core/goals/goal-tool-core.d.ts.map +1 -1
  290. package/dist/core/goals/goal-tool-core.js +60 -75
  291. package/dist/core/goals/goal-tool-core.js.map +1 -1
  292. package/dist/core/goals/session-goal-state.d.ts +20 -12
  293. package/dist/core/goals/session-goal-state.d.ts.map +1 -1
  294. package/dist/core/goals/session-goal-state.js +133 -33
  295. package/dist/core/goals/session-goal-state.js.map +1 -1
  296. package/dist/core/human-input-controller.d.ts +47 -0
  297. package/dist/core/human-input-controller.d.ts.map +1 -0
  298. package/dist/core/human-input-controller.js +181 -0
  299. package/dist/core/human-input-controller.js.map +1 -0
  300. package/dist/core/human-input.d.ts +100 -0
  301. package/dist/core/human-input.d.ts.map +1 -0
  302. package/dist/core/human-input.js +362 -0
  303. package/dist/core/human-input.js.map +1 -0
  304. package/dist/core/index.d.ts +9 -1
  305. package/dist/core/index.d.ts.map +1 -1
  306. package/dist/core/index.js +9 -1
  307. package/dist/core/index.js.map +1 -1
  308. package/dist/core/{telemetry.d.ts → install-telemetry.d.ts} +1 -1
  309. package/dist/core/install-telemetry.d.ts.map +1 -0
  310. package/dist/core/{telemetry.js → install-telemetry.js} +1 -1
  311. package/dist/core/install-telemetry.js.map +1 -0
  312. package/dist/core/keybindings.d.ts +17 -1
  313. package/dist/core/keybindings.d.ts.map +1 -1
  314. package/dist/core/keybindings.js +24 -6
  315. package/dist/core/keybindings.js.map +1 -1
  316. package/dist/core/learning/learning-audit.d.ts +2 -4
  317. package/dist/core/learning/learning-audit.d.ts.map +1 -1
  318. package/dist/core/learning/learning-audit.js +9 -29
  319. package/dist/core/learning/learning-audit.js.map +1 -1
  320. package/dist/core/learning/learning-gate.d.ts.map +1 -1
  321. package/dist/core/learning/learning-gate.js +1 -6
  322. package/dist/core/learning/learning-gate.js.map +1 -1
  323. package/dist/core/learning/session-learning-decision.d.ts +2 -4
  324. package/dist/core/learning/session-learning-decision.d.ts.map +1 -1
  325. package/dist/core/learning/session-learning-decision.js +9 -29
  326. package/dist/core/learning/session-learning-decision.js.map +1 -1
  327. package/dist/core/local-runtime-controller.d.ts +1 -1
  328. package/dist/core/local-runtime-controller.d.ts.map +1 -1
  329. package/dist/core/local-runtime-controller.js.map +1 -1
  330. package/dist/core/memory-controller.d.ts.map +1 -1
  331. package/dist/core/memory-controller.js +4 -4
  332. package/dist/core/memory-controller.js.map +1 -1
  333. package/dist/core/model-capability.d.ts +0 -19
  334. package/dist/core/model-capability.d.ts.map +1 -1
  335. package/dist/core/model-capability.js +1 -19
  336. package/dist/core/model-capability.js.map +1 -1
  337. package/dist/core/model-registry.d.ts +6 -1
  338. package/dist/core/model-registry.d.ts.map +1 -1
  339. package/dist/core/model-registry.js +13 -5
  340. package/dist/core/model-registry.js.map +1 -1
  341. package/dist/core/model-resolver.d.ts +17 -2
  342. package/dist/core/model-resolver.d.ts.map +1 -1
  343. package/dist/core/model-resolver.js +38 -25
  344. package/dist/core/model-resolver.js.map +1 -1
  345. package/dist/core/model-router/intent-classifier.d.ts +1 -4
  346. package/dist/core/model-router/intent-classifier.d.ts.map +1 -1
  347. package/dist/core/model-router/intent-classifier.js +1 -156
  348. package/dist/core/model-router/intent-classifier.js.map +1 -1
  349. package/dist/core/model-router-controller.d.ts +1 -1
  350. package/dist/core/model-router-controller.d.ts.map +1 -1
  351. package/dist/core/model-router-controller.js +2 -2
  352. package/dist/core/model-router-controller.js.map +1 -1
  353. package/dist/core/model-selection-controller.d.ts +5 -5
  354. package/dist/core/model-selection-controller.d.ts.map +1 -1
  355. package/dist/core/model-selection-controller.js.map +1 -1
  356. package/dist/core/model-tool-protocol.d.ts +23 -0
  357. package/dist/core/model-tool-protocol.d.ts.map +1 -0
  358. package/dist/core/model-tool-protocol.js +43 -0
  359. package/dist/core/model-tool-protocol.js.map +1 -0
  360. package/dist/core/models/adaptation-store.d.ts +4 -6
  361. package/dist/core/models/adaptation-store.d.ts.map +1 -1
  362. package/dist/core/models/adaptation-store.js +95 -83
  363. package/dist/core/models/adaptation-store.js.map +1 -1
  364. package/dist/core/models/fitness-store.d.ts +2 -12
  365. package/dist/core/models/fitness-store.d.ts.map +1 -1
  366. package/dist/core/models/fitness-store.js +84 -57
  367. package/dist/core/models/fitness-store.js.map +1 -1
  368. package/dist/core/models/host-state-store.d.ts +34 -0
  369. package/dist/core/models/host-state-store.d.ts.map +1 -0
  370. package/dist/core/models/host-state-store.js +86 -0
  371. package/dist/core/models/host-state-store.js.map +1 -0
  372. package/dist/core/orchestration/agent-resume.d.ts +24 -0
  373. package/dist/core/orchestration/agent-resume.d.ts.map +1 -0
  374. package/dist/core/orchestration/agent-resume.js +90 -0
  375. package/dist/core/orchestration/agent-resume.js.map +1 -0
  376. package/dist/core/orchestration/capability-gateway.d.ts +61 -0
  377. package/dist/core/orchestration/capability-gateway.d.ts.map +1 -0
  378. package/dist/core/orchestration/capability-gateway.js +152 -0
  379. package/dist/core/orchestration/capability-gateway.js.map +1 -0
  380. package/dist/core/orchestration/contracts.d.ts +343 -0
  381. package/dist/core/orchestration/contracts.d.ts.map +1 -0
  382. package/dist/core/orchestration/contracts.js +135 -0
  383. package/dist/core/orchestration/contracts.js.map +1 -0
  384. package/dist/core/orchestration/delegation-ledger.d.ts +56 -0
  385. package/dist/core/orchestration/delegation-ledger.d.ts.map +1 -0
  386. package/dist/core/orchestration/delegation-ledger.js +200 -0
  387. package/dist/core/orchestration/delegation-ledger.js.map +1 -0
  388. package/dist/core/orchestration/event-store.d.ts +83 -0
  389. package/dist/core/orchestration/event-store.d.ts.map +1 -0
  390. package/dist/core/orchestration/event-store.js +560 -0
  391. package/dist/core/orchestration/event-store.js.map +1 -0
  392. package/dist/core/orchestration/lane-tool-manifests.d.ts +9 -0
  393. package/dist/core/orchestration/lane-tool-manifests.d.ts.map +1 -0
  394. package/dist/core/orchestration/lane-tool-manifests.js +37 -0
  395. package/dist/core/orchestration/lane-tool-manifests.js.map +1 -0
  396. package/dist/core/orchestration/model-binding.d.ts +15 -0
  397. package/dist/core/orchestration/model-binding.d.ts.map +1 -0
  398. package/dist/core/orchestration/model-binding.js +29 -0
  399. package/dist/core/orchestration/model-binding.js.map +1 -0
  400. package/dist/core/orchestration/policy-compiler.d.ts +49 -0
  401. package/dist/core/orchestration/policy-compiler.d.ts.map +1 -0
  402. package/dist/core/orchestration/policy-compiler.js +191 -0
  403. package/dist/core/orchestration/policy-compiler.js.map +1 -0
  404. package/dist/core/orchestration/policy-gate.d.ts +18 -0
  405. package/dist/core/orchestration/policy-gate.d.ts.map +1 -0
  406. package/dist/core/orchestration/policy-gate.js +24 -0
  407. package/dist/core/orchestration/policy-gate.js.map +1 -0
  408. package/dist/core/orchestration/profile-registry.d.ts +51 -0
  409. package/dist/core/orchestration/profile-registry.d.ts.map +1 -0
  410. package/dist/core/orchestration/profile-registry.js +393 -0
  411. package/dist/core/orchestration/profile-registry.js.map +1 -0
  412. package/dist/core/orchestration/profile-store.d.ts +31 -0
  413. package/dist/core/orchestration/profile-store.d.ts.map +1 -0
  414. package/dist/core/orchestration/profile-store.js +136 -0
  415. package/dist/core/orchestration/profile-store.js.map +1 -0
  416. package/dist/core/orchestration/risk-budget.d.ts +9 -0
  417. package/dist/core/orchestration/risk-budget.d.ts.map +1 -0
  418. package/dist/core/orchestration/risk-budget.js +48 -0
  419. package/dist/core/orchestration/risk-budget.js.map +1 -0
  420. package/dist/core/orchestration/task-runtime.d.ts +168 -0
  421. package/dist/core/orchestration/task-runtime.d.ts.map +1 -0
  422. package/dist/core/orchestration/task-runtime.js +1600 -0
  423. package/dist/core/orchestration/task-runtime.js.map +1 -0
  424. package/dist/core/orchestration/work-state-projection.d.ts +32 -0
  425. package/dist/core/orchestration/work-state-projection.d.ts.map +1 -0
  426. package/dist/core/orchestration/work-state-projection.js +116 -0
  427. package/dist/core/orchestration/work-state-projection.js.map +1 -0
  428. package/dist/core/orchestration/worker-execution-contract.d.ts +21 -0
  429. package/dist/core/orchestration/worker-execution-contract.d.ts.map +1 -0
  430. package/dist/core/orchestration/worker-execution-contract.js +179 -0
  431. package/dist/core/orchestration/worker-execution-contract.js.map +1 -0
  432. package/dist/core/orchestration/worker-result-adapter.d.ts +21 -0
  433. package/dist/core/orchestration/worker-result-adapter.d.ts.map +1 -0
  434. package/dist/core/orchestration/worker-result-adapter.js +109 -0
  435. package/dist/core/orchestration/worker-result-adapter.js.map +1 -0
  436. package/dist/core/package-manager.d.ts.map +1 -1
  437. package/dist/core/package-manager.js +20 -3
  438. package/dist/core/package-manager.js.map +1 -1
  439. package/dist/core/process-identity.d.ts +11 -0
  440. package/dist/core/process-identity.d.ts.map +1 -0
  441. package/dist/core/process-identity.js +26 -0
  442. package/dist/core/process-identity.js.map +1 -0
  443. package/dist/core/process-matrix/codes.d.ts +14 -3
  444. package/dist/core/process-matrix/codes.d.ts.map +1 -1
  445. package/dist/core/process-matrix/codes.js.map +1 -1
  446. package/dist/core/process-matrix/resume-launcher.d.ts +26 -0
  447. package/dist/core/process-matrix/resume-launcher.d.ts.map +1 -0
  448. package/dist/core/process-matrix/resume-launcher.js +62 -0
  449. package/dist/core/process-matrix/resume-launcher.js.map +1 -0
  450. package/dist/core/process-matrix/runtime.d.ts +37 -22
  451. package/dist/core/process-matrix/runtime.d.ts.map +1 -1
  452. package/dist/core/process-matrix/runtime.js +399 -76
  453. package/dist/core/process-matrix/runtime.js.map +1 -1
  454. package/dist/core/process-matrix/store.d.ts +5 -2
  455. package/dist/core/process-matrix/store.d.ts.map +1 -1
  456. package/dist/core/process-matrix/store.js +123 -14
  457. package/dist/core/process-matrix/store.js.map +1 -1
  458. package/dist/core/process-matrix/supervisor.d.ts +10 -7
  459. package/dist/core/process-matrix/supervisor.d.ts.map +1 -1
  460. package/dist/core/process-matrix/supervisor.js +45 -14
  461. package/dist/core/process-matrix/supervisor.js.map +1 -1
  462. package/dist/core/profile-filter-controller.d.ts +8 -1
  463. package/dist/core/profile-filter-controller.d.ts.map +1 -1
  464. package/dist/core/profile-filter-controller.js +23 -5
  465. package/dist/core/profile-filter-controller.js.map +1 -1
  466. package/dist/core/profile-registry.d.ts.map +1 -1
  467. package/dist/core/profile-registry.js +6 -8
  468. package/dist/core/profile-registry.js.map +1 -1
  469. package/dist/core/prompt-templates.d.ts +1 -0
  470. package/dist/core/prompt-templates.d.ts.map +1 -1
  471. package/dist/core/prompt-templates.js +18 -29
  472. package/dist/core/prompt-templates.js.map +1 -1
  473. package/dist/core/reflection-controller.d.ts +5 -5
  474. package/dist/core/reflection-controller.d.ts.map +1 -1
  475. package/dist/core/reflection-controller.js +5 -2
  476. package/dist/core/reflection-controller.js.map +1 -1
  477. package/dist/core/reload-blockers.d.ts.map +1 -1
  478. package/dist/core/reload-blockers.js +6 -8
  479. package/dist/core/reload-blockers.js.map +1 -1
  480. package/dist/core/request-auth.d.ts +7 -0
  481. package/dist/core/request-auth.d.ts.map +1 -0
  482. package/dist/core/request-auth.js +8 -0
  483. package/dist/core/request-auth.js.map +1 -0
  484. package/dist/core/research/evidence-bundle.d.ts.map +1 -1
  485. package/dist/core/research/evidence-bundle.js +1 -6
  486. package/dist/core/research/evidence-bundle.js.map +1 -1
  487. package/dist/core/research/lane-model-resolver.d.ts +33 -0
  488. package/dist/core/research/lane-model-resolver.d.ts.map +1 -0
  489. package/dist/core/research/lane-model-resolver.js +65 -0
  490. package/dist/core/research/lane-model-resolver.js.map +1 -0
  491. package/dist/core/research/model-fitness-controller.d.ts +38 -0
  492. package/dist/core/research/model-fitness-controller.d.ts.map +1 -0
  493. package/dist/core/research/model-fitness-controller.js +106 -0
  494. package/dist/core/research/model-fitness-controller.js.map +1 -0
  495. package/dist/core/research/model-fitness.d.ts +1 -1
  496. package/dist/core/research/model-fitness.d.ts.map +1 -1
  497. package/dist/core/research/model-fitness.js +4 -4
  498. package/dist/core/research/model-fitness.js.map +1 -1
  499. package/dist/core/research/research-gate.d.ts.map +1 -1
  500. package/dist/core/research/research-gate.js +7 -7
  501. package/dist/core/research/research-gate.js.map +1 -1
  502. package/dist/core/research/research-lane-controller.d.ts +62 -0
  503. package/dist/core/research/research-lane-controller.d.ts.map +1 -0
  504. package/dist/core/research/research-lane-controller.js +292 -0
  505. package/dist/core/research/research-lane-controller.js.map +1 -0
  506. package/dist/core/research/session-evidence-bundle.d.ts +2 -4
  507. package/dist/core/research/session-evidence-bundle.d.ts.map +1 -1
  508. package/dist/core/research/session-evidence-bundle.js +10 -46
  509. package/dist/core/research/session-evidence-bundle.js.map +1 -1
  510. package/dist/core/resource-loader.d.ts.map +1 -1
  511. package/dist/core/resource-loader.js +23 -8
  512. package/dist/core/resource-loader.js.map +1 -1
  513. package/dist/core/risk-classifier.d.ts +6 -0
  514. package/dist/core/risk-classifier.d.ts.map +1 -0
  515. package/dist/core/risk-classifier.js +233 -0
  516. package/dist/core/risk-classifier.js.map +1 -0
  517. package/dist/core/runtime-builder.d.ts +41 -23
  518. package/dist/core/runtime-builder.d.ts.map +1 -1
  519. package/dist/core/runtime-builder.js +365 -253
  520. package/dist/core/runtime-builder.js.map +1 -1
  521. package/dist/core/sdk.d.ts +6 -3
  522. package/dist/core/sdk.d.ts.map +1 -1
  523. package/dist/core/sdk.js +68 -25
  524. package/dist/core/sdk.js.map +1 -1
  525. package/dist/core/secrets/credential-exposure-guard.d.ts +9 -0
  526. package/dist/core/secrets/credential-exposure-guard.d.ts.map +1 -0
  527. package/dist/core/secrets/credential-exposure-guard.js +241 -0
  528. package/dist/core/secrets/credential-exposure-guard.js.map +1 -0
  529. package/dist/core/secrets/secret-dotenv.d.ts +27 -0
  530. package/dist/core/secrets/secret-dotenv.d.ts.map +1 -0
  531. package/dist/core/secrets/secret-dotenv.js +183 -0
  532. package/dist/core/secrets/secret-dotenv.js.map +1 -0
  533. package/dist/core/secrets/secret-vault-format.d.ts +112 -0
  534. package/dist/core/secrets/secret-vault-format.d.ts.map +1 -0
  535. package/dist/core/secrets/secret-vault-format.js +397 -0
  536. package/dist/core/secrets/secret-vault-format.js.map +1 -0
  537. package/dist/core/secrets/secret-vault.d.ts +72 -0
  538. package/dist/core/secrets/secret-vault.d.ts.map +1 -0
  539. package/dist/core/secrets/secret-vault.js +671 -0
  540. package/dist/core/secrets/secret-vault.js.map +1 -0
  541. package/dist/core/session-analytics.d.ts +4 -23
  542. package/dist/core/session-analytics.d.ts.map +1 -1
  543. package/dist/core/session-analytics.js +67 -70
  544. package/dist/core/session-analytics.js.map +1 -1
  545. package/dist/core/session-image-store.d.ts +33 -0
  546. package/dist/core/session-image-store.d.ts.map +1 -0
  547. package/dist/core/session-image-store.js +283 -0
  548. package/dist/core/session-image-store.js.map +1 -0
  549. package/dist/core/session-role.d.ts +11 -4
  550. package/dist/core/session-role.d.ts.map +1 -1
  551. package/dist/core/session-role.js +24 -5
  552. package/dist/core/session-role.js.map +1 -1
  553. package/dist/core/session-snapshot.d.ts +34 -0
  554. package/dist/core/session-snapshot.d.ts.map +1 -0
  555. package/dist/core/session-snapshot.js +68 -0
  556. package/dist/core/session-snapshot.js.map +1 -0
  557. package/dist/core/session-supervision-runtime.d.ts +31 -0
  558. package/dist/core/session-supervision-runtime.d.ts.map +1 -0
  559. package/dist/core/session-supervision-runtime.js +97 -0
  560. package/dist/core/session-supervision-runtime.js.map +1 -0
  561. package/dist/core/session-tree-navigator.d.ts +4 -6
  562. package/dist/core/session-tree-navigator.d.ts.map +1 -1
  563. package/dist/core/session-tree-navigator.js +4 -1
  564. package/dist/core/session-tree-navigator.js.map +1 -1
  565. package/dist/core/settings-manager.d.ts +10 -5
  566. package/dist/core/settings-manager.d.ts.map +1 -1
  567. package/dist/core/settings-manager.js +81 -29
  568. package/dist/core/settings-manager.js.map +1 -1
  569. package/dist/core/slash-commands.d.ts.map +1 -1
  570. package/dist/core/slash-commands.js +2 -2
  571. package/dist/core/slash-commands.js.map +1 -1
  572. package/dist/core/tasks/session-task-state.d.ts +2 -4
  573. package/dist/core/tasks/session-task-state.d.ts.map +1 -1
  574. package/dist/core/tasks/session-task-state.js +10 -28
  575. package/dist/core/tasks/session-task-state.js.map +1 -1
  576. package/dist/core/tasks/task-projection.d.ts +20 -0
  577. package/dist/core/tasks/task-projection.d.ts.map +1 -0
  578. package/dist/core/tasks/task-projection.js +47 -0
  579. package/dist/core/tasks/task-projection.js.map +1 -0
  580. package/dist/core/tasks/task-state.d.ts +4 -0
  581. package/dist/core/tasks/task-state.d.ts.map +1 -1
  582. package/dist/core/tasks/task-state.js +28 -11
  583. package/dist/core/tasks/task-state.js.map +1 -1
  584. package/dist/core/tool-capability-policy.d.ts +13 -0
  585. package/dist/core/tool-capability-policy.d.ts.map +1 -0
  586. package/dist/core/tool-capability-policy.js +86 -0
  587. package/dist/core/tool-capability-policy.js.map +1 -0
  588. package/dist/core/tool-gate-controller.d.ts.map +1 -1
  589. package/dist/core/tool-gate-controller.js +8 -2
  590. package/dist/core/tool-gate-controller.js.map +1 -1
  591. package/dist/core/tool-protocol-controller.d.ts +89 -0
  592. package/dist/core/tool-protocol-controller.d.ts.map +1 -0
  593. package/dist/core/tool-protocol-controller.js +512 -0
  594. package/dist/core/tool-protocol-controller.js.map +1 -0
  595. package/dist/core/tool-recovery-log-records.d.ts +2 -3
  596. package/dist/core/tool-recovery-log-records.d.ts.map +1 -1
  597. package/dist/core/tool-recovery-log-records.js +9 -35
  598. package/dist/core/tool-recovery-log-records.js.map +1 -1
  599. package/dist/core/tool-recovery-stats.d.ts +21 -1
  600. package/dist/core/tool-recovery-stats.d.ts.map +1 -1
  601. package/dist/core/tool-recovery-stats.js.map +1 -1
  602. package/dist/core/tool-selection/tool-performance-store.d.ts +3 -7
  603. package/dist/core/tool-selection/tool-performance-store.d.ts.map +1 -1
  604. package/dist/core/tool-selection/tool-performance-store.js +97 -138
  605. package/dist/core/tool-selection/tool-performance-store.js.map +1 -1
  606. package/dist/core/tools/ask-question.d.ts +124 -0
  607. package/dist/core/tools/ask-question.d.ts.map +1 -0
  608. package/dist/core/tools/ask-question.js +693 -0
  609. package/dist/core/tools/ask-question.js.map +1 -0
  610. package/dist/core/tools/bash.d.ts +5 -0
  611. package/dist/core/tools/bash.d.ts.map +1 -1
  612. package/dist/core/tools/bash.js +59 -5
  613. package/dist/core/tools/bash.js.map +1 -1
  614. package/dist/core/tools/delegate-status.d.ts +31 -3
  615. package/dist/core/tools/delegate-status.d.ts.map +1 -1
  616. package/dist/core/tools/delegate-status.js +148 -29
  617. package/dist/core/tools/delegate-status.js.map +1 -1
  618. package/dist/core/tools/delegate.d.ts +15 -13
  619. package/dist/core/tools/delegate.d.ts.map +1 -1
  620. package/dist/core/tools/delegate.js +106 -23
  621. package/dist/core/tools/delegate.js.map +1 -1
  622. package/dist/core/tools/extensionify.d.ts.map +1 -1
  623. package/dist/core/tools/extensionify.js +1 -0
  624. package/dist/core/tools/extensionify.js.map +1 -1
  625. package/dist/core/tools/git-filter.d.ts +1 -8
  626. package/dist/core/tools/git-filter.d.ts.map +1 -1
  627. package/dist/core/tools/git-filter.js +2 -63
  628. package/dist/core/tools/git-filter.js.map +1 -1
  629. package/dist/core/tools/goal.d.ts +10 -8
  630. package/dist/core/tools/goal.d.ts.map +1 -1
  631. package/dist/core/tools/goal.js +106 -28
  632. package/dist/core/tools/goal.js.map +1 -1
  633. package/dist/core/tools/index.d.ts +1 -0
  634. package/dist/core/tools/index.d.ts.map +1 -1
  635. package/dist/core/tools/index.js +1 -0
  636. package/dist/core/tools/index.js.map +1 -1
  637. package/dist/core/tools/model-fitness.d.ts.map +1 -1
  638. package/dist/core/tools/model-fitness.js +2 -2
  639. package/dist/core/tools/model-fitness.js.map +1 -1
  640. package/dist/core/tools/orchestration-panel.d.ts +40 -0
  641. package/dist/core/tools/orchestration-panel.d.ts.map +1 -0
  642. package/dist/core/tools/orchestration-panel.js +124 -0
  643. package/dist/core/tools/orchestration-panel.js.map +1 -0
  644. package/dist/core/tools/output-accumulator.d.ts +11 -0
  645. package/dist/core/tools/output-accumulator.d.ts.map +1 -1
  646. package/dist/core/tools/output-accumulator.js +36 -3
  647. package/dist/core/tools/output-accumulator.js.map +1 -1
  648. package/dist/core/tools/python.d.ts +2 -0
  649. package/dist/core/tools/python.d.ts.map +1 -1
  650. package/dist/core/tools/python.js +3 -1
  651. package/dist/core/tools/python.js.map +1 -1
  652. package/dist/core/tools/read.d.ts.map +1 -1
  653. package/dist/core/tools/read.js +1 -1
  654. package/dist/core/tools/read.js.map +1 -1
  655. package/dist/core/tools/run-process.d.ts +26 -0
  656. package/dist/core/tools/run-process.d.ts.map +1 -0
  657. package/dist/core/tools/run-process.js +138 -0
  658. package/dist/core/tools/run-process.js.map +1 -0
  659. package/dist/core/tools/search-command-guard.d.ts +14 -0
  660. package/dist/core/tools/search-command-guard.d.ts.map +1 -0
  661. package/dist/core/tools/search-command-guard.js +333 -0
  662. package/dist/core/tools/search-command-guard.js.map +1 -0
  663. package/dist/core/tools/secret-store.d.ts +38 -0
  664. package/dist/core/tools/secret-store.d.ts.map +1 -0
  665. package/dist/core/tools/secret-store.js +412 -0
  666. package/dist/core/tools/secret-store.js.map +1 -0
  667. package/dist/core/tools/shell-command-parser.d.ts +16 -0
  668. package/dist/core/tools/shell-command-parser.d.ts.map +1 -0
  669. package/dist/core/tools/shell-command-parser.js +113 -0
  670. package/dist/core/tools/shell-command-parser.js.map +1 -0
  671. package/dist/core/tools/task-steps.d.ts +2 -0
  672. package/dist/core/tools/task-steps.d.ts.map +1 -1
  673. package/dist/core/tools/task-steps.js +99 -0
  674. package/dist/core/tools/task-steps.js.map +1 -1
  675. package/dist/core/tools/tmux-dispatch.d.ts +3 -5
  676. package/dist/core/tools/tmux-dispatch.d.ts.map +1 -1
  677. package/dist/core/tools/tmux-dispatch.js +4 -4
  678. package/dist/core/tools/tmux-dispatch.js.map +1 -1
  679. package/dist/core/tools/windows-shell-engine.d.ts.map +1 -1
  680. package/dist/core/tools/windows-shell-engine.js +4 -6
  681. package/dist/core/tools/windows-shell-engine.js.map +1 -1
  682. package/dist/core/util/atomic-file.d.ts +6 -2
  683. package/dist/core/util/atomic-file.d.ts.map +1 -1
  684. package/dist/core/util/atomic-file.js +4 -4
  685. package/dist/core/util/atomic-file.js.map +1 -1
  686. package/dist/core/util/bounded-jsonl.d.ts +10 -0
  687. package/dist/core/util/bounded-jsonl.d.ts.map +1 -0
  688. package/dist/core/util/bounded-jsonl.js +75 -0
  689. package/dist/core/util/bounded-jsonl.js.map +1 -0
  690. package/dist/core/util/value-guards.d.ts +5 -0
  691. package/dist/core/util/value-guards.d.ts.map +1 -0
  692. package/dist/core/util/value-guards.js +12 -0
  693. package/dist/core/util/value-guards.js.map +1 -0
  694. package/dist/core/worktree-sync/store.d.ts +3 -3
  695. package/dist/core/worktree-sync/store.d.ts.map +1 -1
  696. package/dist/core/worktree-sync/store.js +10 -5
  697. package/dist/core/worktree-sync/store.js.map +1 -1
  698. package/dist/index.d.ts +15 -4
  699. package/dist/index.d.ts.map +1 -1
  700. package/dist/index.js +14 -3
  701. package/dist/index.js.map +1 -1
  702. package/dist/main.d.ts.map +1 -1
  703. package/dist/main.js +149 -51
  704. package/dist/main.js.map +1 -1
  705. package/dist/migrations.d.ts +4 -6
  706. package/dist/migrations.d.ts.map +1 -1
  707. package/dist/migrations.js +186 -28
  708. package/dist/migrations.js.map +1 -1
  709. package/dist/modes/interactive/auth-dialogs-controller.d.ts +4 -0
  710. package/dist/modes/interactive/auth-dialogs-controller.d.ts.map +1 -1
  711. package/dist/modes/interactive/auth-dialogs-controller.js +60 -1
  712. package/dist/modes/interactive/auth-dialogs-controller.js.map +1 -1
  713. package/dist/modes/interactive/clipboard-input.d.ts +7 -1
  714. package/dist/modes/interactive/clipboard-input.d.ts.map +1 -1
  715. package/dist/modes/interactive/clipboard-input.js +44 -6
  716. package/dist/modes/interactive/clipboard-input.js.map +1 -1
  717. package/dist/modes/interactive/components/activity-lane.d.ts +55 -0
  718. package/dist/modes/interactive/components/activity-lane.d.ts.map +1 -0
  719. package/dist/modes/interactive/components/activity-lane.js +304 -0
  720. package/dist/modes/interactive/components/activity-lane.js.map +1 -0
  721. package/dist/modes/interactive/components/assistant-message.d.ts.map +1 -1
  722. package/dist/modes/interactive/components/assistant-message.js +19 -10
  723. package/dist/modes/interactive/components/assistant-message.js.map +1 -1
  724. package/dist/modes/interactive/components/expandable-text.d.ts +12 -0
  725. package/dist/modes/interactive/components/expandable-text.d.ts.map +1 -0
  726. package/dist/modes/interactive/components/expandable-text.js +17 -0
  727. package/dist/modes/interactive/components/expandable-text.js.map +1 -0
  728. package/dist/modes/interactive/components/extension-editor.d.ts +15 -1
  729. package/dist/modes/interactive/components/extension-editor.d.ts.map +1 -1
  730. package/dist/modes/interactive/components/extension-editor.js +30 -21
  731. package/dist/modes/interactive/components/extension-editor.js.map +1 -1
  732. package/dist/modes/interactive/components/extension-input.d.ts +1 -0
  733. package/dist/modes/interactive/components/extension-input.d.ts.map +1 -1
  734. package/dist/modes/interactive/components/extension-input.js +6 -1
  735. package/dist/modes/interactive/components/extension-input.js.map +1 -1
  736. package/dist/modes/interactive/components/scoped-models-selector.d.ts +2 -2
  737. package/dist/modes/interactive/components/scoped-models-selector.d.ts.map +1 -1
  738. package/dist/modes/interactive/components/scoped-models-selector.js +23 -14
  739. package/dist/modes/interactive/components/scoped-models-selector.js.map +1 -1
  740. package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -1
  741. package/dist/modes/interactive/components/settings-selector.js +6 -6
  742. package/dist/modes/interactive/components/settings-selector.js.map +1 -1
  743. package/dist/modes/interactive/components/tool-execution.d.ts +19 -11
  744. package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
  745. package/dist/modes/interactive/components/tool-execution.js +53 -20
  746. package/dist/modes/interactive/components/tool-execution.js.map +1 -1
  747. package/dist/modes/interactive/components/tool-group.d.ts.map +1 -1
  748. package/dist/modes/interactive/components/tool-group.js +3 -0
  749. package/dist/modes/interactive/components/tool-group.js.map +1 -1
  750. package/dist/modes/interactive/components/usage-action-selector.d.ts +16 -0
  751. package/dist/modes/interactive/components/usage-action-selector.d.ts.map +1 -0
  752. package/dist/modes/interactive/components/usage-action-selector.js +46 -0
  753. package/dist/modes/interactive/components/usage-action-selector.js.map +1 -0
  754. package/dist/modes/interactive/config-backup.d.ts.map +1 -1
  755. package/dist/modes/interactive/config-backup.js +5 -4
  756. package/dist/modes/interactive/config-backup.js.map +1 -1
  757. package/dist/modes/interactive/extension-ui-host.d.ts +14 -0
  758. package/dist/modes/interactive/extension-ui-host.d.ts.map +1 -1
  759. package/dist/modes/interactive/extension-ui-host.js +77 -15
  760. package/dist/modes/interactive/extension-ui-host.js.map +1 -1
  761. package/dist/modes/interactive/external-editor.d.ts +15 -0
  762. package/dist/modes/interactive/external-editor.d.ts.map +1 -1
  763. package/dist/modes/interactive/external-editor.js +27 -19
  764. package/dist/modes/interactive/external-editor.js.map +1 -1
  765. package/dist/modes/interactive/history-reload-math.d.ts +6 -2
  766. package/dist/modes/interactive/history-reload-math.d.ts.map +1 -1
  767. package/dist/modes/interactive/history-reload-math.js +10 -5
  768. package/dist/modes/interactive/history-reload-math.js.map +1 -1
  769. package/dist/modes/interactive/interactive-event-controller.d.ts +74 -0
  770. package/dist/modes/interactive/interactive-event-controller.d.ts.map +1 -0
  771. package/dist/modes/interactive/interactive-event-controller.js +328 -0
  772. package/dist/modes/interactive/interactive-event-controller.js.map +1 -0
  773. package/dist/modes/interactive/interactive-mode.d.ts +22 -24
  774. package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
  775. package/dist/modes/interactive/interactive-mode.js +245 -595
  776. package/dist/modes/interactive/interactive-mode.js.map +1 -1
  777. package/dist/modes/interactive/key-handlers.d.ts.map +1 -1
  778. package/dist/modes/interactive/key-handlers.js +1 -1
  779. package/dist/modes/interactive/key-handlers.js.map +1 -1
  780. package/dist/modes/interactive/loaded-resources-view.d.ts +20 -0
  781. package/dist/modes/interactive/loaded-resources-view.d.ts.map +1 -0
  782. package/dist/modes/interactive/loaded-resources-view.js +147 -0
  783. package/dist/modes/interactive/loaded-resources-view.js.map +1 -0
  784. package/dist/modes/interactive/profile-menu-controller.d.ts.map +1 -1
  785. package/dist/modes/interactive/profile-menu-controller.js +7 -7
  786. package/dist/modes/interactive/profile-menu-controller.js.map +1 -1
  787. package/dist/modes/interactive/report-commands.d.ts.map +1 -1
  788. package/dist/modes/interactive/report-commands.js +21 -0
  789. package/dist/modes/interactive/report-commands.js.map +1 -1
  790. package/dist/modes/interactive/resource-display.d.ts.map +1 -1
  791. package/dist/modes/interactive/resource-display.js +8 -2
  792. package/dist/modes/interactive/resource-display.js.map +1 -1
  793. package/dist/modes/interactive/resource-shell-commands.d.ts +1 -5
  794. package/dist/modes/interactive/resource-shell-commands.d.ts.map +1 -1
  795. package/dist/modes/interactive/resource-shell-commands.js +0 -5
  796. package/dist/modes/interactive/resource-shell-commands.js.map +1 -1
  797. package/dist/modes/interactive/session-flow-commands.d.ts +27 -8
  798. package/dist/modes/interactive/session-flow-commands.d.ts.map +1 -1
  799. package/dist/modes/interactive/session-flow-commands.js +150 -64
  800. package/dist/modes/interactive/session-flow-commands.js.map +1 -1
  801. package/dist/modes/interactive/session-io-commands.d.ts.map +1 -1
  802. package/dist/modes/interactive/session-io-commands.js +16 -6
  803. package/dist/modes/interactive/session-io-commands.js.map +1 -1
  804. package/dist/modes/interactive/session-replacement-errors.d.ts +7 -0
  805. package/dist/modes/interactive/session-replacement-errors.d.ts.map +1 -0
  806. package/dist/modes/interactive/session-replacement-errors.js +15 -0
  807. package/dist/modes/interactive/session-replacement-errors.js.map +1 -0
  808. package/dist/modes/interactive/startup-checks.d.ts.map +1 -1
  809. package/dist/modes/interactive/startup-checks.js +1 -1
  810. package/dist/modes/interactive/startup-checks.js.map +1 -1
  811. package/dist/modes/interactive/usage-commands.d.ts +34 -0
  812. package/dist/modes/interactive/usage-commands.d.ts.map +1 -0
  813. package/dist/modes/interactive/usage-commands.js +225 -0
  814. package/dist/modes/interactive/usage-commands.js.map +1 -0
  815. package/dist/modes/rpc/rpc-mode.d.ts.map +1 -1
  816. package/dist/modes/rpc/rpc-mode.js +82 -23
  817. package/dist/modes/rpc/rpc-mode.js.map +1 -1
  818. package/dist/modes/rpc/rpc-types.d.ts +15 -0
  819. package/dist/modes/rpc/rpc-types.d.ts.map +1 -1
  820. package/dist/modes/rpc/rpc-types.js +138 -1
  821. package/dist/modes/rpc/rpc-types.js.map +1 -1
  822. package/dist/utils/clipboard-image.d.ts.map +1 -1
  823. package/dist/utils/clipboard-image.js +2 -13
  824. package/dist/utils/clipboard-image.js.map +1 -1
  825. package/dist/utils/clipboard-native.d.ts +1 -0
  826. package/dist/utils/clipboard-native.d.ts.map +1 -1
  827. package/dist/utils/clipboard-native.js.map +1 -1
  828. package/dist/utils/clipboard.d.ts +1 -0
  829. package/dist/utils/clipboard.d.ts.map +1 -1
  830. package/dist/utils/clipboard.js +52 -1
  831. package/dist/utils/clipboard.js.map +1 -1
  832. package/dist/utils/platform.d.ts +3 -0
  833. package/dist/utils/platform.d.ts.map +1 -0
  834. package/dist/utils/platform.js +8 -0
  835. package/dist/utils/platform.js.map +1 -0
  836. package/dist/utils/shell.d.ts.map +1 -1
  837. package/dist/utils/shell.js +5 -3
  838. package/dist/utils/shell.js.map +1 -1
  839. package/dist/utils/version-check.d.ts.map +1 -1
  840. package/dist/utils/version-check.js +3 -1
  841. package/dist/utils/version-check.js.map +1 -1
  842. package/dist/utils/work-directory.d.ts +11 -0
  843. package/dist/utils/work-directory.d.ts.map +1 -1
  844. package/dist/utils/work-directory.js +30 -9
  845. package/dist/utils/work-directory.js.map +1 -1
  846. package/docs/UI_POLISH_ORCHESTRATION.md +38 -0
  847. package/docs/UI_QUALITY_ORCHESTRATION.md +28 -0
  848. package/docs/docs.json +4 -0
  849. package/docs/extensions.md +62 -2
  850. package/docs/harness-architecture.md +156 -0
  851. package/docs/keybindings.md +11 -1
  852. package/docs/process-matrix.md +59 -26
  853. package/docs/providers.md +9 -1
  854. package/docs/rpc.md +45 -2
  855. package/docs/sessions.md +15 -0
  856. package/docs/settings.md +125 -11
  857. package/docs/task-steps.md +8 -0
  858. package/docs/telemetry.md +19 -0
  859. package/docs/tmux-agent-manager.md +10 -3
  860. package/docs/ui-reference/README.md +9 -0
  861. package/docs/ui-reference/orchestration-after.txt +14 -0
  862. package/docs/ui-reference/orchestration-before.txt +13 -0
  863. package/docs/ui-reference/orchestration-reference.txt +16 -0
  864. package/docs/usage.md +22 -2
  865. package/docs/work-directory.md +19 -8
  866. package/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
  867. package/examples/extensions/custom-provider-anthropic/package.json +1 -1
  868. package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
  869. package/examples/extensions/question.ts +34 -245
  870. package/examples/extensions/questionnaire.ts +41 -407
  871. package/examples/extensions/sandbox/package-lock.json +2 -2
  872. package/examples/extensions/sandbox/package.json +1 -1
  873. package/examples/extensions/with-deps/package-lock.json +2 -2
  874. package/examples/extensions/with-deps/package.json +1 -1
  875. package/npm-shrinkwrap.json +13 -13
  876. package/package.json +4 -4
  877. package/dist/core/delegation/session-worker-result.d.ts +0 -46
  878. package/dist/core/delegation/session-worker-result.d.ts.map +0 -1
  879. package/dist/core/delegation/session-worker-result.js +0 -113
  880. package/dist/core/delegation/session-worker-result.js.map +0 -1
  881. package/dist/core/delegation/worker-result.d.ts.map +0 -1
  882. package/dist/core/delegation/worker-result.js.map +0 -1
  883. package/dist/core/telemetry.d.ts.map +0 -1
  884. package/dist/core/telemetry.js.map +0 -1
@@ -0,0 +1,102 @@
1
+ import { applyGoalEvent, isGoalResumableStatus, isGoalUnfinishedStatus, MAX_GOAL_OBJECTIVE_LENGTH, } from "./goal-state.js";
2
+ import { applyGoalAction } from "./goal-tool-core.js";
3
+ export function getGoalStateRevision(state) {
4
+ return { goalId: state.goalId, revision: state.revision ?? 0 };
5
+ }
6
+ function missingGoal(action) {
7
+ return { ok: false, error: `No goal exists to ${action}.` };
8
+ }
9
+ function persistResult(host, current, result) {
10
+ if (!result.ok)
11
+ return result;
12
+ host.saveGoalStateSnapshot(result.state, current ? getGoalStateRevision(current) : undefined);
13
+ return result;
14
+ }
15
+ export function pauseGoal(current, now) {
16
+ if (!current)
17
+ return missingGoal("pause");
18
+ if (current.status !== "active") {
19
+ return { ok: false, error: `Goal '${current.goalId}' is ${current.status}; only active goals can be paused.` };
20
+ }
21
+ return { ok: true, state: applyGoalEvent(current, { type: "pause_goal", now }) };
22
+ }
23
+ export function resumeGoal(current, now) {
24
+ if (!current)
25
+ return missingGoal("resume");
26
+ if (!isGoalResumableStatus(current.status)) {
27
+ return {
28
+ ok: false,
29
+ error: `Goal '${current.goalId}' is ${current.status}; only paused, blocked, or usage-limited goals can be resumed.`,
30
+ };
31
+ }
32
+ return { ok: true, state: applyGoalEvent(current, { type: "resume_goal", now }) };
33
+ }
34
+ export function editGoal(current, args, now) {
35
+ if (!current)
36
+ return missingGoal("edit");
37
+ if (current.status === "cancelled") {
38
+ return { ok: false, error: `Goal '${current.goalId}' is cancelled; start a new goal instead.` };
39
+ }
40
+ const userGoal = args.userGoal.trim();
41
+ if (!userGoal)
42
+ return { ok: false, error: "Goal objective must not be empty." };
43
+ if (userGoal.length > MAX_GOAL_OBJECTIVE_LENGTH) {
44
+ return { ok: false, error: `Goal objective must be at most ${MAX_GOAL_OBJECTIVE_LENGTH} characters.` };
45
+ }
46
+ if (args.tokenBudget !== undefined && (!Number.isSafeInteger(args.tokenBudget) || args.tokenBudget <= 0)) {
47
+ return { ok: false, error: "Goal token budget must be a positive integer when provided." };
48
+ }
49
+ return {
50
+ ok: true,
51
+ state: applyGoalEvent(current, { type: "edit_goal", userGoal, tokenBudget: args.tokenBudget, now }),
52
+ };
53
+ }
54
+ export function cancelGoal(current, now) {
55
+ if (!current)
56
+ return missingGoal("cancel");
57
+ if (!isGoalUnfinishedStatus(current.status)) {
58
+ return { ok: false, error: `Goal '${current.goalId}' is already ${current.status}.` };
59
+ }
60
+ return { ok: true, state: applyGoalEvent(current, { type: "cancel_goal", now }) };
61
+ }
62
+ /** Explicit owner replacement. The old and new states cross one persistence boundary. */
63
+ export function replaceGoal(args, now) {
64
+ return applyGoalAction(undefined, { action: "start", ...args }, now);
65
+ }
66
+ export function stopGoalFromSystem(current, args, now) {
67
+ if (!current)
68
+ return missingGoal("stop");
69
+ if (current.status !== "active") {
70
+ return { ok: false, error: `Goal '${current.goalId}' is ${current.status}; no system stop is needed.` };
71
+ }
72
+ const reason = args.reason.trim();
73
+ if (!reason)
74
+ return { ok: false, error: "System goal stop requires a reason." };
75
+ return { ok: true, state: applyGoalEvent(current, { type: "system_stop_goal", ...args, reason, now }) };
76
+ }
77
+ export function pausePersistedGoal(host, now = new Date().toISOString()) {
78
+ const current = host.getGoalStateSnapshot();
79
+ return persistResult(host, current, pauseGoal(current, now));
80
+ }
81
+ export function resumePersistedGoal(host, now = new Date().toISOString()) {
82
+ const current = host.getGoalStateSnapshot();
83
+ return persistResult(host, current, resumeGoal(current, now));
84
+ }
85
+ export function editPersistedGoal(host, args, now = new Date().toISOString()) {
86
+ const current = host.getGoalStateSnapshot();
87
+ return persistResult(host, current, editGoal(current, args, now));
88
+ }
89
+ export function cancelPersistedGoal(host, now = new Date().toISOString()) {
90
+ const current = host.getGoalStateSnapshot();
91
+ return persistResult(host, current, cancelGoal(current, now));
92
+ }
93
+ export function clearPersistedGoal(host, now = new Date().toISOString()) {
94
+ const current = host.getGoalStateSnapshot();
95
+ if (!current)
96
+ return { ok: true, cleared: false };
97
+ if (!host.clearGoalStateSnapshot)
98
+ return { ok: false, error: "This session does not support clearing goals." };
99
+ host.clearGoalStateSnapshot(current, now);
100
+ return { ok: true, cleared: true };
101
+ }
102
+ //# sourceMappingURL=goal-lifecycle.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"goal-lifecycle.js","sourceRoot":"","sources":["../../../src/core/goals/goal-lifecycle.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,cAAc,EAEd,qBAAqB,EACrB,sBAAsB,EACtB,yBAAyB,GACzB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,eAAe,EAAiD,MAAM,qBAAqB,CAAC;AAOrG,MAAM,UAAU,oBAAoB,CAAC,KAAgB,EAAqB;IACzE,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,MAAM,EAAE,QAAQ,EAAE,KAAK,CAAC,QAAQ,IAAI,CAAC,EAAE,CAAC;AAAA,CAC/D;AASD,SAAS,WAAW,CAAC,MAAc,EAAqB;IACvD,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,qBAAqB,MAAM,GAAG,EAAE,CAAC;AAAA,CAC5D;AAED,SAAS,aAAa,CACrB,IAA4B,EAC5B,OAA8B,EAC9B,MAAwB,EACL;IACnB,IAAI,CAAC,MAAM,CAAC,EAAE;QAAE,OAAO,MAAM,CAAC;IAC9B,IAAI,CAAC,qBAAqB,CAAC,MAAM,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC,CAAC,oBAAoB,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;IAC9F,OAAO,MAAM,CAAC;AAAA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AO,EAAE,IAAI,EAAE,CAAC;AAAA,CACnC","sourcesContent":["import {\n\tapplyGoalEvent,\n\ttype GoalState,\n\tisGoalResumableStatus,\n\tisGoalUnfinishedStatus,\n\tMAX_GOAL_OBJECTIVE_LENGTH,\n} from \"./goal-state.ts\";\nimport { applyGoalAction, type GoalActionFailure, type GoalActionResult } from \"./goal-tool-core.ts\";\n\nexport interface GoalStateRevision {\n\tgoalId: string;\n\trevision: number;\n}\n\nexport function getGoalStateRevision(state: GoalState): GoalStateRevision {\n\treturn { goalId: state.goalId, revision: state.revision ?? 0 };\n}\n\n/** Minimal durable seam shared by CLI, tools, and in-process session restoration. */\nexport interface PersistedGoalStateHost {\n\tgetGoalStateSnapshot(): GoalState | undefined;\n\tsaveGoalStateSnapshot(state: GoalState, expected?: GoalStateRevision): string;\n\tclearGoalStateSnapshot?(state: GoalState, now: string): string;\n}\n\nfunction missingGoal(action: string): GoalActionFailure {\n\treturn { ok: false, error: `No goal exists to ${action}.` };\n}\n\nfunction persistResult(\n\thost: PersistedGoalStateHost,\n\tcurrent: GoalState | undefined,\n\tresult: GoalActionResult,\n): GoalActionResult {\n\tif (!result.ok) return result;\n\thost.saveGoalStateSnapshot(result.state, current ? getGoalStateRevision(current) : undefined);\n\treturn result;\n}\n\nexport function pauseGoal(current: GoalState | undefined, now: string): GoalActionResult {\n\tif (!current) return missingGoal(\"pause\");\n\tif (current.status !== \"active\") {\n\t\treturn { ok: false, error: `Goal '${current.goalId}' is ${current.status}; only active goals can be paused.` };\n\t}\n\treturn { ok: true, state: applyGoalEvent(current, { type: \"pause_goal\", now }) };\n}\n\nexport function resumeGoal(current: GoalState | undefined, now: string): GoalActionResult {\n\tif (!current) return missingGoal(\"resume\");\n\tif (!isGoalResumableStatus(current.status)) {\n\t\treturn {\n\t\t\tok: false,\n\t\t\terror: `Goal '${current.goalId}' is ${current.status}; only paused, blocked, or usage-limited goals can be resumed.`,\n\t\t};\n\t}\n\treturn { ok: true, state: applyGoalEvent(current, { type: \"resume_goal\", now }) };\n}\n\nexport function editGoal(\n\tcurrent: GoalState | undefined,\n\targs: { userGoal: string; tokenBudget?: number },\n\tnow: string,\n): GoalActionResult {\n\tif (!current) return missingGoal(\"edit\");\n\tif (current.status === \"cancelled\") {\n\t\treturn { ok: false, error: `Goal '${current.goalId}' is cancelled; start a new goal instead.` };\n\t}\n\tconst userGoal = args.userGoal.trim();\n\tif (!userGoal) return { ok: false, error: \"Goal objective must not be empty.\" };\n\tif (userGoal.length > MAX_GOAL_OBJECTIVE_LENGTH) {\n\t\treturn { ok: false, error: `Goal objective must be at most ${MAX_GOAL_OBJECTIVE_LENGTH} characters.` };\n\t}\n\tif (args.tokenBudget !== undefined && (!Number.isSafeInteger(args.tokenBudget) || args.tokenBudget <= 0)) {\n\t\treturn { ok: false, error: \"Goal token budget must be a positive integer when provided.\" };\n\t}\n\treturn {\n\t\tok: true,\n\t\tstate: applyGoalEvent(current, { type: \"edit_goal\", userGoal, tokenBudget: args.tokenBudget, now }),\n\t};\n}\n\nexport function cancelGoal(current: GoalState | undefined, now: string): GoalActionResult {\n\tif (!current) return missingGoal(\"cancel\");\n\tif (!isGoalUnfinishedStatus(current.status)) {\n\t\treturn { ok: false, error: `Goal '${current.goalId}' is already ${current.status}.` };\n\t}\n\treturn { ok: true, state: applyGoalEvent(current, { type: \"cancel_goal\", now }) };\n}\n\n/** Explicit owner replacement. The old and new states cross one persistence boundary. */\nexport function replaceGoal(\n\targs: { goalId: string; userGoal: string; tokenBudget?: number },\n\tnow: string,\n): GoalActionResult {\n\treturn applyGoalAction(undefined, { action: \"start\", ...args }, now);\n}\n\nexport function stopGoalFromSystem(\n\tcurrent: GoalState | undefined,\n\targs: { status: \"blocked\" | \"usage_limited\" | \"budget_limited\"; reason: string },\n\tnow: string,\n): GoalActionResult {\n\tif (!current) return missingGoal(\"stop\");\n\tif (current.status !== \"active\") {\n\t\treturn { ok: false, error: `Goal '${current.goalId}' is ${current.status}; no system stop is needed.` };\n\t}\n\tconst reason = args.reason.trim();\n\tif (!reason) return { ok: false, error: \"System goal stop requires a reason.\" };\n\treturn { ok: true, state: applyGoalEvent(current, { type: \"system_stop_goal\", ...args, reason, now }) };\n}\n\nexport function pausePersistedGoal(host: PersistedGoalStateHost, now = new Date().toISOString()): GoalActionResult {\n\tconst current = host.getGoalStateSnapshot();\n\treturn persistResult(host, current, pauseGoal(current, now));\n}\n\nexport function resumePersistedGoal(host: PersistedGoalStateHost, now = new Date().toISOString()): GoalActionResult {\n\tconst current = host.getGoalStateSnapshot();\n\treturn persistResult(host, current, resumeGoal(current, now));\n}\n\nexport function editPersistedGoal(\n\thost: PersistedGoalStateHost,\n\targs: { userGoal: string; tokenBudget?: number },\n\tnow = new Date().toISOString(),\n): GoalActionResult {\n\tconst current = host.getGoalStateSnapshot();\n\treturn persistResult(host, current, editGoal(current, args, now));\n}\n\nexport function cancelPersistedGoal(host: PersistedGoalStateHost, now = new Date().toISOString()): GoalActionResult {\n\tconst current = host.getGoalStateSnapshot();\n\treturn persistResult(host, current, cancelGoal(current, now));\n}\n\nexport type ClearPersistedGoalResult = { ok: true; cleared: boolean } | GoalActionFailure;\n\nexport function clearPersistedGoal(\n\thost: PersistedGoalStateHost,\n\tnow = new Date().toISOString(),\n): ClearPersistedGoalResult {\n\tconst current = host.getGoalStateSnapshot();\n\tif (!current) return { ok: true, cleared: false };\n\tif (!host.clearGoalStateSnapshot) return { ok: false, error: \"This session does not support clearing goals.\" };\n\thost.clearGoalStateSnapshot(current, now);\n\treturn { ok: true, cleared: true };\n}\n"]}
@@ -0,0 +1,17 @@
1
+ import type { GoalState, GoalStatus } from "./goal-state.ts";
2
+ /** Compact model/user projection. Detailed planning and evidence remain in their owning stores. */
3
+ export interface GoalRecord {
4
+ goalId: string;
5
+ objective: string;
6
+ status: GoalStatus;
7
+ tokenBudget?: number;
8
+ tokensUsed: number;
9
+ tokensRemaining?: number;
10
+ timeUsedSeconds: number;
11
+ blockedReason?: string;
12
+ createdAt: string;
13
+ updatedAt: string;
14
+ }
15
+ export declare function projectGoalRecord(state: GoalState): GoalRecord;
16
+ export declare function formatGoalRecord(record: GoalRecord): string;
17
+ //# sourceMappingURL=goal-record.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"goal-record.d.ts","sourceRoot":"","sources":["../../../src/core/goals/goal-record.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAE7D,mGAAmG;AACnG,MAAM,WAAW,UAAU;IAC1B,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,UAAU,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;IACnB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,eAAe,EAAE,MAAM,CAAC;IACxB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;CAClB;AAED,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,SAAS,GAAG,UAAU,CAkB9D;AAED,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,UAAU,GAAG,MAAM,CAW3D","sourcesContent":["import type { GoalState, GoalStatus } from \"./goal-state.ts\";\n\n/** Compact model/user projection. Detailed planning and evidence remain in their owning stores. */\nexport interface GoalRecord {\n\tgoalId: string;\n\tobjective: string;\n\tstatus: GoalStatus;\n\ttokenBudget?: number;\n\ttokensUsed: number;\n\ttokensRemaining?: number;\n\ttimeUsedSeconds: number;\n\tblockedReason?: string;\n\tcreatedAt: string;\n\tupdatedAt: string;\n}\n\nexport function projectGoalRecord(state: GoalState): GoalRecord {\n\tconst tokensUsed = Math.max(0, state.tokensUsed ?? 0);\n\treturn {\n\t\tgoalId: state.goalId,\n\t\tobjective: state.userGoal,\n\t\tstatus: state.status,\n\t\t...(state.tokenBudget === undefined\n\t\t\t? {}\n\t\t\t: {\n\t\t\t\t\ttokenBudget: state.tokenBudget,\n\t\t\t\t\ttokensRemaining: Math.max(0, state.tokenBudget - tokensUsed),\n\t\t\t\t}),\n\t\ttokensUsed,\n\t\ttimeUsedSeconds: Math.max(0, Math.ceil((state.continuationWallClockMs ?? 0) / 1000)),\n\t\tblockedReason: state.blockedReason,\n\t\tcreatedAt: state.createdAt,\n\t\tupdatedAt: state.updatedAt,\n\t};\n}\n\nexport function formatGoalRecord(record: GoalRecord): string {\n\tconst budget =\n\t\trecord.tokenBudget === undefined\n\t\t\t? `${record.tokensUsed} tokens (unbounded)`\n\t\t\t: `${record.tokensUsed}/${record.tokenBudget} tokens; ${record.tokensRemaining ?? 0} remaining`;\n\treturn [\n\t\t`Goal '${record.goalId}' (${record.status})`,\n\t\t`Objective: ${record.objective}`,\n\t\t`Usage: ${budget}; ${record.timeUsedSeconds}s active time.`,\n\t\t...(record.blockedReason ? [`Reason: ${record.blockedReason}`] : []),\n\t].join(\"\\n\");\n}\n"]}
@@ -0,0 +1,31 @@
1
+ export function projectGoalRecord(state) {
2
+ const tokensUsed = Math.max(0, state.tokensUsed ?? 0);
3
+ return {
4
+ goalId: state.goalId,
5
+ objective: state.userGoal,
6
+ status: state.status,
7
+ ...(state.tokenBudget === undefined
8
+ ? {}
9
+ : {
10
+ tokenBudget: state.tokenBudget,
11
+ tokensRemaining: Math.max(0, state.tokenBudget - tokensUsed),
12
+ }),
13
+ tokensUsed,
14
+ timeUsedSeconds: Math.max(0, Math.ceil((state.continuationWallClockMs ?? 0) / 1000)),
15
+ blockedReason: state.blockedReason,
16
+ createdAt: state.createdAt,
17
+ updatedAt: state.updatedAt,
18
+ };
19
+ }
20
+ export function formatGoalRecord(record) {
21
+ const budget = record.tokenBudget === undefined
22
+ ? `${record.tokensUsed} tokens (unbounded)`
23
+ : `${record.tokensUsed}/${record.tokenBudget} tokens; ${record.tokensRemaining ?? 0} remaining`;
24
+ return [
25
+ `Goal '${record.goalId}' (${record.status})`,
26
+ `Objective: ${record.objective}`,
27
+ `Usage: ${budget}; ${record.timeUsedSeconds}s active time.`,
28
+ ...(record.blockedReason ? [`Reason: ${record.blockedReason}`] : []),
29
+ ].join("\n");
30
+ }
31
+ //# sourceMappingURL=goal-record.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"goal-record.js","sourceRoot":"","sources":["../../../src/core/goals/goal-record.ts"],"names":[],"mappings":"AAgBA,MAAM,UAAU,iBAAiB,CAAC,KAAgB,EAAc;IAC/D,MAAM,UAAU,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,CAAC,UAAU,IAAI,CAAC,CAAC,CAAC;IACtD,OAAO;QACN,MAAM,EAAE,KAAK,CAAC,MAAM;QACpB,SAAS,EAAE,KAAK,CAAC,QAAQ;QACzB,MAAM,EAAE,KAAK,CAAC,MAAM;QACpB,GAAG,CAAC,KAAK,CAAC,WAAW,KAAK,SAAS;YAClC,CAAC,CAAC,EAAE;YACJ,CAAC,CAAC;gBACA,WAAW,EAAE,KAAK,CAAC,WAAW;gBAC9B,eAAe,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,CAAC,WAAW,GAAG,UAAU,CAAC;aAC5D,CAAC;QACJ,UAAU;QACV,eAAe,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,uBAAuB,IAAI,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC;QACpF,aAAa,EAAE,KAAK,CAAC,aAAa;QAClC,SAAS,EAAE,KAAK,CAAC,SAAS;QAC1B,SAAS,EAAE,KAAK,CAAC,SAAS;KAC1B,CAAC;AAAA,CACF;AAED,MAAM,UAAU,gBAAgB,CAAC,MAAkB,EAAU;IAC5D,MAAM,MAAM,GACX,MAAM,CAAC,WAAW,KAAK,SAAS;QAC/B,CAAC,CAAC,GAAG,MAAM,CAAC,UAAU,qBAAqB;QAC3C,CAAC,CAAC,GAAG,MAAM,CAAC,UAAU,IAAI,MAAM,CAAC,WAAW,YAAY,MAAM,CAAC,eAAe,IAAI,CAAC,YAAY,CAAC;IAClG,OAAO;QACN,SAAS,MAAM,CAAC,MAAM,MAAM,MAAM,CAAC,MAAM,GAAG;QAC5C,cAAc,MAAM,CAAC,SAAS,EAAE;QAChC,UAAU,MAAM,KAAK,MAAM,CAAC,eAAe,gBAAgB;QAC3D,GAAG,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,WAAW,MAAM,CAAC,aAAa,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;KACpE,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAAA,CACb","sourcesContent":["import type { GoalState, GoalStatus } from \"./goal-state.ts\";\n\n/** Compact model/user projection. Detailed planning and evidence remain in their owning stores. */\nexport interface GoalRecord {\n\tgoalId: string;\n\tobjective: string;\n\tstatus: GoalStatus;\n\ttokenBudget?: number;\n\ttokensUsed: number;\n\ttokensRemaining?: number;\n\ttimeUsedSeconds: number;\n\tblockedReason?: string;\n\tcreatedAt: string;\n\tupdatedAt: string;\n}\n\nexport function projectGoalRecord(state: GoalState): GoalRecord {\n\tconst tokensUsed = Math.max(0, state.tokensUsed ?? 0);\n\treturn {\n\t\tgoalId: state.goalId,\n\t\tobjective: state.userGoal,\n\t\tstatus: state.status,\n\t\t...(state.tokenBudget === undefined\n\t\t\t? {}\n\t\t\t: {\n\t\t\t\t\ttokenBudget: state.tokenBudget,\n\t\t\t\t\ttokensRemaining: Math.max(0, state.tokenBudget - tokensUsed),\n\t\t\t\t}),\n\t\ttokensUsed,\n\t\ttimeUsedSeconds: Math.max(0, Math.ceil((state.continuationWallClockMs ?? 0) / 1000)),\n\t\tblockedReason: state.blockedReason,\n\t\tcreatedAt: state.createdAt,\n\t\tupdatedAt: state.updatedAt,\n\t};\n}\n\nexport function formatGoalRecord(record: GoalRecord): string {\n\tconst budget =\n\t\trecord.tokenBudget === undefined\n\t\t\t? `${record.tokensUsed} tokens (unbounded)`\n\t\t\t: `${record.tokensUsed}/${record.tokenBudget} tokens; ${record.tokensRemaining ?? 0} remaining`;\n\treturn [\n\t\t`Goal '${record.goalId}' (${record.status})`,\n\t\t`Objective: ${record.objective}`,\n\t\t`Usage: ${budget}; ${record.timeUsedSeconds}s active time.`,\n\t\t...(record.blockedReason ? [`Reason: ${record.blockedReason}`] : []),\n\t].join(\"\\n\");\n}\n"]}
@@ -1,7 +1,9 @@
1
1
  import type { SessionManager } from "@caupulican/pi-agent-core/node";
2
- import type { EvidenceBundle, LearningDecision, WorkerResult } from "../autonomy/contracts.ts";
2
+ import type { EvidenceBundle, LearningDecision, WorkerClaim } from "../autonomy/contracts.ts";
3
3
  import type { LaneRecord } from "../autonomy/lane-tracker.ts";
4
- import type { TaskStepStatus } from "../tasks/task-state.ts";
4
+ import type { TaskRuntimeProjection } from "../orchestration/task-runtime.ts";
5
+ import { type SessionWorkStateProjection } from "../orchestration/work-state-projection.ts";
6
+ import type { OpenTaskStepProjection } from "../tasks/task-projection.ts";
5
7
  import { type GoalContinuationDecision } from "./goal-continuation-controller.ts";
6
8
  import type { GoalState } from "./goal-state.ts";
7
9
  export interface GoalRuntimeSnapshotSettings {
@@ -13,11 +15,7 @@ export interface GoalRuntimeSnapshotSettings {
13
15
  * loop never writes back to task state through this snapshot, and the task store stays the
14
16
  * single source of truth for its own steps.
15
17
  */
16
- export interface GoalRuntimeOpenTaskStep {
17
- id: string;
18
- status: TaskStepStatus;
19
- content: string;
20
- }
18
+ export type GoalRuntimeOpenTaskStep = OpenTaskStepProjection;
21
19
  /**
22
20
  * Live, per-worktree-sync-lane status for one lane bound to a dispatched worker, as the caller
23
21
  * (runtime-builder / whatever host process has live git-engine access) derives it. `boundLaneId` is
@@ -53,7 +51,7 @@ export interface GoalRuntimeRequirementWorktreeState {
53
51
  export interface GoalRuntimeSnapshot {
54
52
  goalState?: GoalState;
55
53
  latestEvidenceBundle?: EvidenceBundle;
56
- workerResults: readonly WorkerResult[];
54
+ workerClaims: readonly WorkerClaim[];
57
55
  learningDecisions: readonly LearningDecision[];
58
56
  continuation: GoalContinuationDecision;
59
57
  /**
@@ -63,6 +61,8 @@ export interface GoalRuntimeSnapshot {
63
61
  * itself always populates a concrete array (possibly empty).
64
62
  */
65
63
  openTaskSteps?: readonly GoalRuntimeOpenTaskStep[];
64
+ /** Canonical read model joining requirements, foreground steps, and delegated DAG tasks. */
65
+ workState?: SessionWorkStateProjection;
66
66
  /**
67
67
  * Per-requirement worktree-sync state, present only for requirements whose `boundLaneId` matches
68
68
  * a `worktreeLaneStatus` entry supplied to the builder. Optional (like `openTaskSteps`) so every
@@ -74,7 +74,7 @@ export interface GoalRuntimeSnapshot {
74
74
  }
75
75
  /**
76
76
  * Branch-scoped: every resolver here reads from ONE source (the active branch), so the goal
77
- * state, evidence bundle, worker results, learning decisions, and open task steps in the
77
+ * state, evidence bundle, worker claims, learning decisions, and open task steps in the
78
78
  * returned snapshot are never a mix of the current branch and a sibling branch's history.
79
79
  */
80
80
  export declare function buildGoalRuntimeSnapshot(args: {
@@ -114,5 +114,7 @@ export declare function buildGoalRuntimeSnapshot(args: {
114
114
  * changes any OTHER continuation outcome.
115
115
  */
116
116
  worktreeLaneStatus?: readonly GoalRuntimeWorktreeLaneStatus[];
117
+ /** Durable worker DAG projection, supplied only when the delegate capability has been loaded. */
118
+ taskRuntime?: TaskRuntimeProjection;
117
119
  }): GoalRuntimeSnapshot;
118
120
  //# sourceMappingURL=goal-runtime-snapshot.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"goal-runtime-snapshot.d.ts","sourceRoot":"","sources":["../../../src/core/goals/goal-runtime-snapshot.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AACrE,OAAO,KAAK,EAAE,cAAc,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAC/F,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,6B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;GAIG;AACH,wBAAgB,wBAAwB,CAAC,IAAI,EAAE;IAC9C,cAAc,EAAE,IAAI,CAAC,cAAc,EAAE,8BAA8B,GAAG,WAAW,CAAC,CAAC;IACnF,QAAQ,EAAE,2BAA2B,CAAC;IACtC;;;;;;;;OAQG;IACH,WAAW,CAAC,EAAE,SAAS,UAAU,EAAE,CAAC;IACpC;;;;;OAKG;IACH,GAAG,CAAC,EAAE,MAAM,MAAM,CAAC;IACnB;;;;OAIG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB;;;;;;;;;OASG;IACH,kBAAkB,CAAC,EAAE,SAAS,6BAA6B,EAAE,CAAC;CAC9D,GAAG,mBAAmB,CA4FtB","sourcesContent":["import type { SessionManager } from \"@caupulican/pi-agent-core/node\";\nimport type { EvidenceBundle, LearningDecision, WorkerResult } from \"../autonomy/contracts.ts\";\nimport type { LaneRecord } from \"../autonomy/lane-tracker.ts\";\nimport { getWorkerResultSnapshots } from \"../delegation/session-worker-result.ts\";\nimport { getLearningDecisionSnapshots } from \"../learning/session-learning-decision.ts\";\nimport { getLatestEvidenceBundleSnapshot } from \"../research/session-evidence-bundle.ts\";\nimport { getLatestTaskStepsStateSnapshot } from \"../tasks/session-task-state.ts\";\nimport type { TaskStepStatus } from \"../tasks/task-state.ts\";\nimport { evaluateGoalContinuation, type GoalContinuationDecision } from \"./goal-continuation-controller.ts\";\nimport { DEFAULT_GOAL_WORKER_WAIT_MS } from \"./goal-continuation-defaults.ts\";\nimport type { GoalState } from \"./goal-state.ts\";\nimport { getLatestGoalStateSnapshot } from \"./session-goal-state.ts\";\n\nexport interface GoalRuntimeSnapshotSettings {\n\tmaxStallTurns: number;\n}\n\n/**\n * A read-only projection of one OPEN (non-terminal) task_steps step, included in the goal\n * runtime snapshot purely for cross-visibility. This is NOT a shared state machine: the goal\n * loop never writes back to task state through this snapshot, and the task store stays the\n * single source of truth for its own steps.\n */\nexport interface GoalRuntimeOpenTaskStep {\n\tid: string;\n\tstatus: TaskStepStatus;\n\tcontent: string;\n}\n\n/**\n * Live, per-worktree-sync-lane status for one lane bound to a dispatched worker, as the caller\n * (runtime-builder / whatever host process has live git-engine access) derives it. `boundLaneId` is\n * the host `LaneRecord.laneId` the lane's registration was correlated to\n * (`LaneRegistration.boundLaneId`, same id-space as `Requirement.boundLaneId`) -- `undefined` for a\n * lane never bound to a dispatch. `fresh`/`stale` mirror `LaneFacts`; `syncRequired` is the\n * staleness-propagation verdict (`WorktreeSyncPolicy`-derived); `rebaseInProgress` marks a sync that\n * stopped on conflicts (a rebase left in progress) -- see `core/worktree-sync/git-engine.ts`.\n */\nexport interface GoalRuntimeWorktreeLaneStatus {\n\tlaneKey: string;\n\tboundLaneId?: string;\n\tfresh: boolean;\n\tstale: boolean;\n\tsyncRequired: boolean;\n\trebaseInProgress: boolean;\n}\n\n/**\n * Per-requirement projection of {@link GoalRuntimeWorktreeLaneStatus}, joined via\n * `requirement.boundLaneId === status.boundLaneId` -- read-only cross-visibility for snapshot\n * consumers (e.g. a future continuation-prompt render), mirroring `openTaskSteps`'s role. This is\n * NOT what feeds `evaluateGoalContinuation` (that reads the raw `boundLaneId`-keyed sets directly);\n * it exists purely so a requirement's worktree state is visible without re-deriving the join.\n */\nexport interface GoalRuntimeRequirementWorktreeState {\n\trequirementId: string;\n\tlaneKey: string;\n\tfresh: boolean;\n\tstale: boolean;\n\tsyncRequired: boolean;\n\trebaseInProgress: boolean;\n}\n\nexport interface GoalRuntimeSnapshot {\n\tgoalState?: GoalState;\n\tlatestEvidenceBundle?: EvidenceBundle;\n\tworkerResults: readonly WorkerResult[];\n\tlearningDecisions: readonly LearningDecision[];\n\tcontinuation: GoalContinuationDecision;\n\t/**\n\t * Open (non-terminal) task_steps steps on the active branch, latest-wins. Read-only.\n\t * Optional (like `goalState`/`latestEvidenceBundle`) so hand-built snapshots in existing\n\t * tests/call sites that predate this field keep compiling unchanged; `buildGoalRuntimeSnapshot`\n\t * itself always populates a concrete array (possibly empty).\n\t */\n\topenTaskSteps?: readonly GoalRuntimeOpenTaskStep[];\n\t/**\n\t * Per-requirement worktree-sync state, present only for requirements whose `boundLaneId` matches\n\t * a `worktreeLaneStatus` entry supplied to the builder. Optional (like `openTaskSteps`) so every\n\t * pre-existing caller/test keeps compiling unchanged; omitted entirely (not an empty array) when\n\t * the builder was never given `worktreeLaneStatus`, since \"no data supplied\" and \"data supplied,\n\t * nothing bound\" are genuinely different states worth distinguishing.\n\t */\n\trequirementWorktreeStates?: readonly GoalRuntimeRequirementWorktreeState[];\n}\n\n/**\n * Branch-scoped: every resolver here reads from ONE source (the active branch), so the goal\n * state, evidence bundle, worker results, learning decisions, and open task steps in the\n * returned snapshot are never a mix of the current branch and a sibling branch's history.\n */\nexport function buildGoalRuntimeSnapshot(args: {\n\tsessionManager: Pick<SessionManager, \"getLatestCustomEntryOnBranch\" | \"getBranch\">;\n\tsettings: GoalRuntimeSnapshotSettings;\n\t/**\n\t * Live lane records (queued/running/terminal), independent of branch scoping. Used ONLY to (a)\n\t * detect a worker in flight against the active goal's open requirement (\"waiting\" — see\n\t * `evaluateGoalContinuation`'s `inFlightGoalLaneIds`), and (b) surface this goal's cumulative\n\t * worker/subagent spend (advisory — see `GoalState.continuationWorkerSpendUsd`). Optional so\n\t * every pre-existing caller (hand-built snapshots, tests) that predates lane-awareness keeps\n\t * compiling and behaving byte-identically: omitting it disables both the \"waiting\" branch and the\n\t * worker-spend overlay, and never changes any OTHER continuation outcome.\n\t */\n\tlaneRecords?: readonly LaneRecord[];\n\t/**\n\t * Current time as an ISO-string factory, threaded into `evaluateGoalContinuation`'s never-hang\n\t * wait-timeout check (`now`/`maxWorkerWaitMs` — see there) alongside `maxWorkerWaitMs` below.\n\t * Defaults to the real wall clock. A factory (not a plain string) so a caller/test can inject a\n\t * fixed clock without freezing global `Date`.\n\t */\n\tnow?: () => string;\n\t/**\n\t * Maximum milliseconds a bound in-flight requirement may wait before the continuation escalates\n\t * to `worker_wait_timeout` instead of `\"waiting\"` forever (see `evaluateGoalContinuation`).\n\t * Defaults to `DEFAULT_GOAL_WORKER_WAIT_MS`.\n\t */\n\tmaxWorkerWaitMs?: number;\n\t/**\n\t * Live per-lane worktree-sync status, independent of branch scoping -- exactly like `laneRecords`,\n\t * this builder performs NO I/O of its own; the caller derives this array (e.g. from\n\t * `core/worktree-sync/git-engine.ts`'s live status) and supplies it ready-made. Used to (a) build\n\t * `requirementWorktreeStates` (per-requirement projection, matched via `boundLaneId`) and (b)\n\t * derive the `laneSyncConflictLaneKeys`/`syncRequiredLaneKeys` sets threaded into\n\t * `evaluateGoalContinuation`. Optional so every pre-existing caller (predating worktree-sync\n\t * awareness) keeps compiling and behaving byte-identically: omitting it disables both, and never\n\t * changes any OTHER continuation outcome.\n\t */\n\tworktreeLaneStatus?: readonly GoalRuntimeWorktreeLaneStatus[];\n}): GoalRuntimeSnapshot {\n\tconst branchEntries = args.sessionManager.getBranch();\n\tlet goalState = getLatestGoalStateSnapshot(args.sessionManager);\n\tconst latestEvidenceBundle = getLatestEvidenceBundleSnapshot(branchEntries);\n\tconst workerResults = getWorkerResultSnapshots(branchEntries);\n\tconst learningDecisions = getLearningDecisionSnapshots(branchEntries);\n\n\t// Reuses the SAME branch-scoped primitive as goal-state resolution (getLatestCustomEntryOnBranch),\n\t// so the task-steps summary below can never leak a sibling branch's checklist either.\n\tconst taskStepsState = getLatestTaskStepsStateSnapshot(args.sessionManager);\n\tconst openTaskSteps: GoalRuntimeOpenTaskStep[] = (taskStepsState?.steps ?? [])\n\t\t.filter((step) => step.status !== \"completed\" && step.status !== \"cancelled\")\n\t\t.map((step) => ({ id: step.id, status: step.status, content: step.activeForm || step.content }));\n\n\tlet inFlightGoalLaneIds: ReadonlySet<string> | undefined;\n\tif (goalState && args.laneRecords) {\n\t\tconst goalId = goalState.goalId;\n\t\tconst inFlight = new Set<string>();\n\t\t// Live-derived, not durably persisted: the goal-state event log has no reducer branch that\n\t\t// writes `continuationWorkerSpendUsd` (see its doc comment on `GoalState`), so every read\n\t\t// re-sums THIS goal's own lane records instead of trusting a stale/zero persisted value.\n\t\t// `costUsd` is set today for in-process worker/research lane completions (LaneTracker.complete);\n\t\t// it is NOT yet set for tmux-worker completions (`ManagedLaneEvent` carries no cost claim), so\n\t\t// this sum is accurate for in-process lanes and a documented undercount for tmux workers until\n\t\t// `reportSpawnedUsage` threads a goalId/lane correlation through. Forward-compatible: the moment\n\t\t// tmux-worker costUsd is populated, this same sum picks it up with no further change here.\n\t\tlet workerSpendUsd = 0;\n\t\tfor (const record of args.laneRecords) {\n\t\t\tif (record.goalId !== goalId) continue;\n\t\t\tif (record.status === \"queued\" || record.status === \"running\") inFlight.add(record.laneId);\n\t\t\tworkerSpendUsd += record.costUsd ?? 0;\n\t\t}\n\t\tinFlightGoalLaneIds = inFlight;\n\t\tgoalState = { ...goalState, continuationWorkerSpendUsd: workerSpendUsd };\n\t}\n\n\t// Worktree-sync surfacing: (a) a per-requirement projection (matched via `boundLaneId`, purely for\n\t// snapshot consumers -- never read by `evaluateGoalContinuation` itself), and (b) the\n\t// `boundLaneId`-keyed sets `evaluateGoalContinuation` actually matches against\n\t// `Requirement.boundLaneId`, same id-space and matching pattern as `inFlightGoalLaneIds` above.\n\t// Disjoint by construction: a lane with `rebaseInProgress` feeds the conflict set only, never both.\n\tlet requirementWorktreeStates: GoalRuntimeRequirementWorktreeState[] | undefined;\n\tconst laneSyncConflictLaneKeys = new Set<string>();\n\tconst syncRequiredLaneKeys = new Set<string>();\n\tif (args.worktreeLaneStatus) {\n\t\tfor (const status of args.worktreeLaneStatus) {\n\t\t\tif (status.boundLaneId === undefined) continue;\n\t\t\tif (status.rebaseInProgress) laneSyncConflictLaneKeys.add(status.boundLaneId);\n\t\t\telse if (status.syncRequired) syncRequiredLaneKeys.add(status.boundLaneId);\n\t\t}\n\t\tif (goalState) {\n\t\t\tconst states: GoalRuntimeRequirementWorktreeState[] = [];\n\t\t\tfor (const requirement of goalState.requirements) {\n\t\t\t\tif (requirement.boundLaneId === undefined) continue;\n\t\t\t\tconst status = args.worktreeLaneStatus.find(\n\t\t\t\t\t(candidate) => candidate.boundLaneId === requirement.boundLaneId,\n\t\t\t\t);\n\t\t\t\tif (!status) continue;\n\t\t\t\tstates.push({\n\t\t\t\t\trequirementId: requirement.id,\n\t\t\t\t\tlaneKey: status.laneKey,\n\t\t\t\t\tfresh: status.fresh,\n\t\t\t\t\tstale: status.stale,\n\t\t\t\t\tsyncRequired: status.syncRequired,\n\t\t\t\t\trebaseInProgress: status.rebaseInProgress,\n\t\t\t\t});\n\t\t\t}\n\t\t\trequirementWorktreeStates = states;\n\t\t}\n\t}\n\n\tconst now = (args.now ?? (() => new Date().toISOString()))();\n\tconst maxWorkerWaitMs = args.maxWorkerWaitMs ?? DEFAULT_GOAL_WORKER_WAIT_MS;\n\tconst continuation = evaluateGoalContinuation({\n\t\tstate: goalState,\n\t\tsettings: { maxStallTurns: args.settings.maxStallTurns },\n\t\tinFlightGoalLaneIds,\n\t\tnow,\n\t\tmaxWorkerWaitMs,\n\t\tlaneSyncConflictLaneKeys: laneSyncConflictLaneKeys.size > 0 ? laneSyncConflictLaneKeys : undefined,\n\t\tsyncRequiredLaneKeys: syncRequiredLaneKeys.size > 0 ? syncRequiredLaneKeys : undefined,\n\t});\n\n\treturn {\n\t\tgoalState,\n\t\tlatestEvidenceBundle,\n\t\tworkerResults,\n\t\tlearningDecisions,\n\t\tcontinuation,\n\t\topenTaskSteps,\n\t\t...(requirementWorktreeStates !== undefined ? { requirementWorktreeStates } : {}),\n\t};\n}\n"]}
1
+ {"version":3,"file":"goal-runtime-snapshot.d.ts","sourceRoot":"","sources":["../../../src/core/goals/goal-runtime-snapshot.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AACrE,OAAO,KAAK,EAAE,cAAc,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAC9F,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,6BA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EAAE,0BAA0B,CAAC;IACvC;;;;;;OAMG;IACH,yBAAyB,CAAC,EAAE,SAAS,mCAAmC,EAAE,CAAC;CAC3E;AAED;;;;GAIG;AACH,wBAAgB,wBAAwB,CAAC,IAAI,EAAE;IAC9C,cAAc,EAAE,IAAI,CAAC,cAAc,EAAE,8BAA8B,GAAG,WAAW,CAAC,CAAC;IACnF,QAAQ,EAAE,2BAA2B,CAAC;IACtC;;;;;;;;OAQG;IACH,WAAW,CAAC,EAAE,SAAS,UAAU,EAAE,CAAC;IACpC;;;;;OAKG;IACH,GAAG,CAAC,EAAE,MAAM,MAAM,CAAC;IACnB;;;;OAIG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB;;;;;;;;;OASG;IACH,kBAAkB,CAAC,EAAE,SAAS,6BAA6B,EAAE,CAAC;IAC9D,iGAAiG;IACjG,WAAW,CAAC,EAAE,qBAAqB,CAAC;CACpC,GAAG,mBAAmB,CA4FtB","sourcesContent":["import type { SessionManager } from \"@caupulican/pi-agent-core/node\";\nimport type { EvidenceBundle, LearningDecision, WorkerClaim } from \"../autonomy/contracts.ts\";\nimport type { LaneRecord } from \"../autonomy/lane-tracker.ts\";\nimport { getWorkerClaimSnapshots } from \"../delegation/session-worker-claim.ts\";\nimport { getLearningDecisionSnapshots } from \"../learning/session-learning-decision.ts\";\nimport type { TaskRuntimeProjection } from \"../orchestration/task-runtime.ts\";\nimport { projectSessionWorkState, type SessionWorkStateProjection } from \"../orchestration/work-state-projection.ts\";\nimport { getLatestEvidenceBundleSnapshot } from \"../research/session-evidence-bundle.ts\";\nimport { getActiveSessionBranchEntries } from \"../session-snapshot.ts\";\nimport { getLatestTaskStepsStateSnapshot } from \"../tasks/session-task-state.ts\";\nimport type { OpenTaskStepProjection } from \"../tasks/task-projection.ts\";\nimport { evaluateGoalContinuation, type GoalContinuationDecision } from \"./goal-continuation-controller.ts\";\nimport { DEFAULT_GOAL_WORKER_WAIT_MS } from \"./goal-continuation-defaults.ts\";\nimport type { GoalState } from \"./goal-state.ts\";\nimport { getLatestGoalStateSnapshot } from \"./session-goal-state.ts\";\n\nexport interface GoalRuntimeSnapshotSettings {\n\tmaxStallTurns: number;\n}\n\n/**\n * A read-only projection of one OPEN (non-terminal) task_steps step, included in the goal\n * runtime snapshot purely for cross-visibility. This is NOT a shared state machine: the goal\n * loop never writes back to task state through this snapshot, and the task store stays the\n * single source of truth for its own steps.\n */\nexport type GoalRuntimeOpenTaskStep = OpenTaskStepProjection;\n\n/**\n * Live, per-worktree-sync-lane status for one lane bound to a dispatched worker, as the caller\n * (runtime-builder / whatever host process has live git-engine access) derives it. `boundLaneId` is\n * the host `LaneRecord.laneId` the lane's registration was correlated to\n * (`LaneRegistration.boundLaneId`, same id-space as `Requirement.boundLaneId`) -- `undefined` for a\n * lane never bound to a dispatch. `fresh`/`stale` mirror `LaneFacts`; `syncRequired` is the\n * staleness-propagation verdict (`WorktreeSyncPolicy`-derived); `rebaseInProgress` marks a sync that\n * stopped on conflicts (a rebase left in progress) -- see `core/worktree-sync/git-engine.ts`.\n */\nexport interface GoalRuntimeWorktreeLaneStatus {\n\tlaneKey: string;\n\tboundLaneId?: string;\n\tfresh: boolean;\n\tstale: boolean;\n\tsyncRequired: boolean;\n\trebaseInProgress: boolean;\n}\n\n/**\n * Per-requirement projection of {@link GoalRuntimeWorktreeLaneStatus}, joined via\n * `requirement.boundLaneId === status.boundLaneId` -- read-only cross-visibility for snapshot\n * consumers (e.g. a future continuation-prompt render), mirroring `openTaskSteps`'s role. This is\n * NOT what feeds `evaluateGoalContinuation` (that reads the raw `boundLaneId`-keyed sets directly);\n * it exists purely so a requirement's worktree state is visible without re-deriving the join.\n */\nexport interface GoalRuntimeRequirementWorktreeState {\n\trequirementId: string;\n\tlaneKey: string;\n\tfresh: boolean;\n\tstale: boolean;\n\tsyncRequired: boolean;\n\trebaseInProgress: boolean;\n}\n\nexport interface GoalRuntimeSnapshot {\n\tgoalState?: GoalState;\n\tlatestEvidenceBundle?: EvidenceBundle;\n\tworkerClaims: readonly WorkerClaim[];\n\tlearningDecisions: readonly LearningDecision[];\n\tcontinuation: GoalContinuationDecision;\n\t/**\n\t * Open (non-terminal) task_steps steps on the active branch, latest-wins. Read-only.\n\t * Optional (like `goalState`/`latestEvidenceBundle`) so hand-built snapshots in existing\n\t * tests/call sites that predate this field keep compiling unchanged; `buildGoalRuntimeSnapshot`\n\t * itself always populates a concrete array (possibly empty).\n\t */\n\topenTaskSteps?: readonly GoalRuntimeOpenTaskStep[];\n\t/** Canonical read model joining requirements, foreground steps, and delegated DAG tasks. */\n\tworkState?: SessionWorkStateProjection;\n\t/**\n\t * Per-requirement worktree-sync state, present only for requirements whose `boundLaneId` matches\n\t * a `worktreeLaneStatus` entry supplied to the builder. Optional (like `openTaskSteps`) so every\n\t * pre-existing caller/test keeps compiling unchanged; omitted entirely (not an empty array) when\n\t * the builder was never given `worktreeLaneStatus`, since \"no data supplied\" and \"data supplied,\n\t * nothing bound\" are genuinely different states worth distinguishing.\n\t */\n\trequirementWorktreeStates?: readonly GoalRuntimeRequirementWorktreeState[];\n}\n\n/**\n * Branch-scoped: every resolver here reads from ONE source (the active branch), so the goal\n * state, evidence bundle, worker claims, learning decisions, and open task steps in the\n * returned snapshot are never a mix of the current branch and a sibling branch's history.\n */\nexport function buildGoalRuntimeSnapshot(args: {\n\tsessionManager: Pick<SessionManager, \"getLatestCustomEntryOnBranch\" | \"getBranch\">;\n\tsettings: GoalRuntimeSnapshotSettings;\n\t/**\n\t * Live lane records (queued/running/terminal), independent of branch scoping. Used ONLY to (a)\n\t * detect a worker in flight against the active goal's open requirement (\"waiting\" — see\n\t * `evaluateGoalContinuation`'s `inFlightGoalLaneIds`), and (b) surface this goal's cumulative\n\t * worker/subagent spend (advisory — see `GoalState.continuationWorkerSpendUsd`). Optional so\n\t * every pre-existing caller (hand-built snapshots, tests) that predates lane-awareness keeps\n\t * compiling and behaving byte-identically: omitting it disables both the \"waiting\" branch and the\n\t * worker-spend overlay, and never changes any OTHER continuation outcome.\n\t */\n\tlaneRecords?: readonly LaneRecord[];\n\t/**\n\t * Current time as an ISO-string factory, threaded into `evaluateGoalContinuation`'s never-hang\n\t * wait-timeout check (`now`/`maxWorkerWaitMs` — see there) alongside `maxWorkerWaitMs` below.\n\t * Defaults to the real wall clock. A factory (not a plain string) so a caller/test can inject a\n\t * fixed clock without freezing global `Date`.\n\t */\n\tnow?: () => string;\n\t/**\n\t * Maximum milliseconds a bound in-flight requirement may wait before the continuation escalates\n\t * to `worker_wait_timeout` instead of `\"waiting\"` forever (see `evaluateGoalContinuation`).\n\t * Defaults to `DEFAULT_GOAL_WORKER_WAIT_MS`.\n\t */\n\tmaxWorkerWaitMs?: number;\n\t/**\n\t * Live per-lane worktree-sync status, independent of branch scoping -- exactly like `laneRecords`,\n\t * this builder performs NO I/O of its own; the caller derives this array (e.g. from\n\t * `core/worktree-sync/git-engine.ts`'s live status) and supplies it ready-made. Used to (a) build\n\t * `requirementWorktreeStates` (per-requirement projection, matched via `boundLaneId`) and (b)\n\t * derive the `laneSyncConflictLaneKeys`/`syncRequiredLaneKeys` sets threaded into\n\t * `evaluateGoalContinuation`. Optional so every pre-existing caller (predating worktree-sync\n\t * awareness) keeps compiling and behaving byte-identically: omitting it disables both, and never\n\t * changes any OTHER continuation outcome.\n\t */\n\tworktreeLaneStatus?: readonly GoalRuntimeWorktreeLaneStatus[];\n\t/** Durable worker DAG projection, supplied only when the delegate capability has been loaded. */\n\ttaskRuntime?: TaskRuntimeProjection;\n}): GoalRuntimeSnapshot {\n\tconst branchEntries = getActiveSessionBranchEntries(args.sessionManager);\n\tlet goalState = getLatestGoalStateSnapshot(args.sessionManager);\n\tconst latestEvidenceBundle = getLatestEvidenceBundleSnapshot(branchEntries);\n\tconst workerClaims = getWorkerClaimSnapshots(branchEntries);\n\tconst learningDecisions = getLearningDecisionSnapshots(branchEntries);\n\n\t// Reuses the SAME branch-scoped primitive as goal-state resolution (getLatestCustomEntryOnBranch),\n\t// so the task-steps summary below can never leak a sibling branch's checklist either.\n\tconst taskStepsState = getLatestTaskStepsStateSnapshot(args.sessionManager);\n\tconst workState = projectSessionWorkState({ goalState, taskStepsState, taskRuntime: args.taskRuntime });\n\tconst openTaskSteps = workState.openTaskSteps;\n\n\tlet inFlightGoalLaneIds: ReadonlySet<string> | undefined;\n\tif (goalState && args.laneRecords) {\n\t\tconst goalId = goalState.goalId;\n\t\tconst inFlight = new Set<string>();\n\t\t// Live-derived, not durably persisted: the goal-state event log has no reducer branch that\n\t\t// writes `continuationWorkerSpendUsd` (see its doc comment on `GoalState`), so every read\n\t\t// re-sums THIS goal's own lane records instead of trusting a stale/zero persisted value.\n\t\t// `costUsd` is set today for in-process worker/research lane completions (LaneTracker.complete);\n\t\t// it is NOT yet set for tmux-worker completions (`ManagedLaneEvent` carries no cost claim), so\n\t\t// this sum is accurate for in-process lanes and a documented undercount for tmux workers until\n\t\t// `reportSpawnedUsage` threads a goalId/lane correlation through. Forward-compatible: the moment\n\t\t// tmux-worker costUsd is populated, this same sum picks it up with no further change here.\n\t\tlet workerSpendUsd = 0;\n\t\tfor (const record of args.laneRecords) {\n\t\t\tif (record.goalId !== goalId) continue;\n\t\t\tif (record.status === \"queued\" || record.status === \"running\") inFlight.add(record.laneId);\n\t\t\tworkerSpendUsd += record.costUsd ?? 0;\n\t\t}\n\t\tinFlightGoalLaneIds = inFlight;\n\t\tgoalState = { ...goalState, continuationWorkerSpendUsd: workerSpendUsd };\n\t}\n\n\t// Worktree-sync surfacing: (a) a per-requirement projection (matched via `boundLaneId`, purely for\n\t// snapshot consumers -- never read by `evaluateGoalContinuation` itself), and (b) the\n\t// `boundLaneId`-keyed sets `evaluateGoalContinuation` actually matches against\n\t// `Requirement.boundLaneId`, same id-space and matching pattern as `inFlightGoalLaneIds` above.\n\t// Disjoint by construction: a lane with `rebaseInProgress` feeds the conflict set only, never both.\n\tlet requirementWorktreeStates: GoalRuntimeRequirementWorktreeState[] | undefined;\n\tconst laneSyncConflictLaneKeys = new Set<string>();\n\tconst syncRequiredLaneKeys = new Set<string>();\n\tif (args.worktreeLaneStatus) {\n\t\tfor (const status of args.worktreeLaneStatus) {\n\t\t\tif (status.boundLaneId === undefined) continue;\n\t\t\tif (status.rebaseInProgress) laneSyncConflictLaneKeys.add(status.boundLaneId);\n\t\t\telse if (status.syncRequired) syncRequiredLaneKeys.add(status.boundLaneId);\n\t\t}\n\t\tif (goalState) {\n\t\t\tconst states: GoalRuntimeRequirementWorktreeState[] = [];\n\t\t\tfor (const requirement of goalState.requirements) {\n\t\t\t\tif (requirement.boundLaneId === undefined) continue;\n\t\t\t\tconst status = args.worktreeLaneStatus.find(\n\t\t\t\t\t(candidate) => candidate.boundLaneId === requirement.boundLaneId,\n\t\t\t\t);\n\t\t\t\tif (!status) continue;\n\t\t\t\tstates.push({\n\t\t\t\t\trequirementId: requirement.id,\n\t\t\t\t\tlaneKey: status.laneKey,\n\t\t\t\t\tfresh: status.fresh,\n\t\t\t\t\tstale: status.stale,\n\t\t\t\t\tsyncRequired: status.syncRequired,\n\t\t\t\t\trebaseInProgress: status.rebaseInProgress,\n\t\t\t\t});\n\t\t\t}\n\t\t\trequirementWorktreeStates = states;\n\t\t}\n\t}\n\n\tconst now = (args.now ?? (() => new Date().toISOString()))();\n\tconst maxWorkerWaitMs = args.maxWorkerWaitMs ?? DEFAULT_GOAL_WORKER_WAIT_MS;\n\tconst continuation = evaluateGoalContinuation({\n\t\tstate: goalState,\n\t\tsettings: { maxStallTurns: args.settings.maxStallTurns },\n\t\tinFlightGoalLaneIds,\n\t\tnow,\n\t\tmaxWorkerWaitMs,\n\t\tlaneSyncConflictLaneKeys: laneSyncConflictLaneKeys.size > 0 ? laneSyncConflictLaneKeys : undefined,\n\t\tsyncRequiredLaneKeys: syncRequiredLaneKeys.size > 0 ? syncRequiredLaneKeys : undefined,\n\t});\n\n\treturn {\n\t\tgoalState,\n\t\tlatestEvidenceBundle,\n\t\tworkerClaims,\n\t\tlearningDecisions,\n\t\tcontinuation,\n\t\topenTaskSteps,\n\t\tworkState,\n\t\t...(requirementWorktreeStates !== undefined ? { requirementWorktreeStates } : {}),\n\t};\n}\n"]}
@@ -1,27 +1,28 @@
1
- import { getWorkerResultSnapshots } from "../delegation/session-worker-result.js";
1
+ import { getWorkerClaimSnapshots } from "../delegation/session-worker-claim.js";
2
2
  import { getLearningDecisionSnapshots } from "../learning/session-learning-decision.js";
3
+ import { projectSessionWorkState } from "../orchestration/work-state-projection.js";
3
4
  import { getLatestEvidenceBundleSnapshot } from "../research/session-evidence-bundle.js";
5
+ import { getActiveSessionBranchEntries } from "../session-snapshot.js";
4
6
  import { getLatestTaskStepsStateSnapshot } from "../tasks/session-task-state.js";
5
7
  import { evaluateGoalContinuation } from "./goal-continuation-controller.js";
6
8
  import { DEFAULT_GOAL_WORKER_WAIT_MS } from "./goal-continuation-defaults.js";
7
9
  import { getLatestGoalStateSnapshot } from "./session-goal-state.js";
8
10
  /**
9
11
  * Branch-scoped: every resolver here reads from ONE source (the active branch), so the goal
10
- * state, evidence bundle, worker results, learning decisions, and open task steps in the
12
+ * state, evidence bundle, worker claims, learning decisions, and open task steps in the
11
13
  * returned snapshot are never a mix of the current branch and a sibling branch's history.
12
14
  */
13
15
  export function buildGoalRuntimeSnapshot(args) {
14
- const branchEntries = args.sessionManager.getBranch();
16
+ const branchEntries = getActiveSessionBranchEntries(args.sessionManager);
15
17
  let goalState = getLatestGoalStateSnapshot(args.sessionManager);
16
18
  const latestEvidenceBundle = getLatestEvidenceBundleSnapshot(branchEntries);
17
- const workerResults = getWorkerResultSnapshots(branchEntries);
19
+ const workerClaims = getWorkerClaimSnapshots(branchEntries);
18
20
  const learningDecisions = getLearningDecisionSnapshots(branchEntries);
19
21
  // Reuses the SAME branch-scoped primitive as goal-state resolution (getLatestCustomEntryOnBranch),
20
22
  // so the task-steps summary below can never leak a sibling branch's checklist either.
21
23
  const taskStepsState = getLatestTaskStepsStateSnapshot(args.sessionManager);
22
- const openTaskSteps = (taskStepsState?.steps ?? [])
23
- .filter((step) => step.status !== "completed" && step.status !== "cancelled")
24
- .map((step) => ({ id: step.id, status: step.status, content: step.activeForm || step.content }));
24
+ const workState = projectSessionWorkState({ goalState, taskStepsState, taskRuntime: args.taskRuntime });
25
+ const openTaskSteps = workState.openTaskSteps;
25
26
  let inFlightGoalLaneIds;
26
27
  if (goalState && args.laneRecords) {
27
28
  const goalId = goalState.goalId;
@@ -96,10 +97,11 @@ export function buildGoalRuntimeSnapshot(args) {
96
97
  return {
97
98
  goalState,
98
99
  latestEvidenceBundle,
99
- workerResults,
100
+ workerClaims,
100
101
  learningDecisions,
101
102
  continuation,
102
103
  openTaskSteps,
104
+ workState,
103
105
  ...(requirementWorktreeStates !== undefined ? { requirementWorktreeStates } : {}),
104
106
  };
105
107
  }
@@ -1 +1 @@
1
- {"version":3,"file":"goal-runtime-snapshot.js","sourceRoot":"","sources":["../../../src/core/goals/goal-runtime-snapshot.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,wBAAwB,EAAE,MAAM,wCAAwC,CAAC;AAClF,OAAO,EAAE,4BAA4B,EAAE,MAAM,0CAA0C,CAAC;AACxF,OAAO,EAAE,+BAA+B,EAAE,MAAM,wCAAwC,CAAC;AACzF,OAAO,EAAE,+BAA+B,EAAE,MAAM,gCAAgC,CAAC;AAEjF,OAAO,EAAE,wBAAwB,EAAiC,MAAM,mCAAmC,CAAC;AAC5G,OAAO,EAAE,2BAA2B,EAAE,MAAM,iCAAiC,CAAC;AAE9E,OAAO,EAAE,0BAA0B,EAAE,MAAM,yBAAyB,CAAC;AA2ErE;;;;GAIG;AACH,MAAM,UAAU,wBAAwB,CAAC,IAqCxC,EAAuB;IACvB,MAAM,aAAa,GAAG,IAAI,CAAC,cAAc,CAAC,SAAS,EAAE,CAAC;IACtD,IAAI,SAAS,GAAG,0BAA0B,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;IAChE,MAAM,oBAAoB,GAAG,+BAA+B,CAAC,aAAa,CAAC,CAAC;IAC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AM,CAAC,KAAK;oBACnB,KAAK,EAAE,MAAM,CAAC,KAAK;oBACnB,YAAY,EAAE,MAAM,CAAC,YAAY;oBACjC,gBAAgB,EAAE,MAAM,CAAC,gBAAgB;iBACzC,CAAC,CAAC;YACJ,CAAC;YACD,yBAAyB,GAAG,MAAM,CAAC;QACpC,CAAC;IACF,CAAC;IAED,MAAM,GAAG,GAAG,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC,CAAC,EAAE,CAAC;IAC7D,MAAM,eAAe,GAAG,IAAI,CAAC,eAAe,IAAI,2BAA2B,CAAC;IAC5E,MAAM,YAAY,GAAG,wBAAwB,CAAC;QAC7C,KAAK,EAAE,SAAS;QAChB,QAAQ,EAAE,EAAE,aAAa,EAAE,IAAI,CAAC,QAAQ,CAAC,aAAa,EAAE;QACxD,mBAAmB;QACnB,GAAG;QACH,eAAe;QACf,wBAAwB,EAAE,wBAAwB,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC,CAAC,wBAAwB,CAAC,CAAC,CAAC,SAAS;QAClG,oBAAoB,EAAE,oBAAoB,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC,CAAC,oBAAoB,CAAC,CAAC,CAAC,SAAS;KACtF,CAAC,CAAC;IAEH,OAAO;QACN,SAAS;QACT,oBAAoB;QACpB,aAAa;QACb,iBAAiB;QACjB,YAAY;QACZ,aAAa;QACb,GAAG,CAAC,yBAAyB,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,yBAAyB,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KACjF,CAAC;AAAA,CACF","sourcesContent":["import type { SessionManager } from \"@caupulican/pi-agent-core/node\";\nimport type { EvidenceBundle, LearningDecision, WorkerResult } from \"../autonomy/contracts.ts\";\nimport type { LaneRecord } from \"../autonomy/lane-tracker.ts\";\nimport { getWorkerResultSnapshots } from \"../delegation/session-worker-result.ts\";\nimport { getLearningDecisionSnapshots } from \"../learning/session-learning-decision.ts\";\nimport { getLatestEvidenceBundleSnapshot } from \"../research/session-evidence-bundle.ts\";\nimport { getLatestTaskStepsStateSnapshot } from \"../tasks/session-task-state.ts\";\nimport type { TaskStepStatus } from \"../tasks/task-state.ts\";\nimport { evaluateGoalContinuation, type GoalContinuationDecision } from \"./goal-continuation-controller.ts\";\nimport { DEFAULT_GOAL_WORKER_WAIT_MS } from \"./goal-continuation-defaults.ts\";\nimport type { GoalState } from \"./goal-state.ts\";\nimport { getLatestGoalStateSnapshot } from \"./session-goal-state.ts\";\n\nexport interface GoalRuntimeSnapshotSettings {\n\tmaxStallTurns: number;\n}\n\n/**\n * A read-only projection of one OPEN (non-terminal) task_steps step, included in the goal\n * runtime snapshot purely for cross-visibility. This is NOT a shared state machine: the goal\n * loop never writes back to task state through this snapshot, and the task store stays the\n * single source of truth for its own steps.\n */\nexport interface GoalRuntimeOpenTaskStep {\n\tid: string;\n\tstatus: TaskStepStatus;\n\tcontent: string;\n}\n\n/**\n * Live, per-worktree-sync-lane status for one lane bound to a dispatched worker, as the caller\n * (runtime-builder / whatever host process has live git-engine access) derives it. `boundLaneId` is\n * the host `LaneRecord.laneId` the lane's registration was correlated to\n * (`LaneRegistration.boundLaneId`, same id-space as `Requirement.boundLaneId`) -- `undefined` for a\n * lane never bound to a dispatch. `fresh`/`stale` mirror `LaneFacts`; `syncRequired` is the\n * staleness-propagation verdict (`WorktreeSyncPolicy`-derived); `rebaseInProgress` marks a sync that\n * stopped on conflicts (a rebase left in progress) -- see `core/worktree-sync/git-engine.ts`.\n */\nexport interface GoalRuntimeWorktreeLaneStatus {\n\tlaneKey: string;\n\tboundLaneId?: string;\n\tfresh: boolean;\n\tstale: boolean;\n\tsyncRequired: boolean;\n\trebaseInProgress: boolean;\n}\n\n/**\n * Per-requirement projection of {@link GoalRuntimeWorktreeLaneStatus}, joined via\n * `requirement.boundLaneId === status.boundLaneId` -- read-only cross-visibility for snapshot\n * consumers (e.g. a future continuation-prompt render), mirroring `openTaskSteps`'s role. This is\n * NOT what feeds `evaluateGoalContinuation` (that reads the raw `boundLaneId`-keyed sets directly);\n * it exists purely so a requirement's worktree state is visible without re-deriving the join.\n */\nexport interface GoalRuntimeRequirementWorktreeState {\n\trequirementId: string;\n\tlaneKey: string;\n\tfresh: boolean;\n\tstale: boolean;\n\tsyncRequired: boolean;\n\trebaseInProgress: boolean;\n}\n\nexport interface GoalRuntimeSnapshot {\n\tgoalState?: GoalState;\n\tlatestEvidenceBundle?: EvidenceBundle;\n\tworkerResults: readonly WorkerResult[];\n\tlearningDecisions: readonly LearningDecision[];\n\tcontinuation: GoalContinuationDecision;\n\t/**\n\t * Open (non-terminal) task_steps steps on the active branch, latest-wins. Read-only.\n\t * Optional (like `goalState`/`latestEvidenceBundle`) so hand-built snapshots in existing\n\t * tests/call sites that predate this field keep compiling unchanged; `buildGoalRuntimeSnapshot`\n\t * itself always populates a concrete array (possibly empty).\n\t */\n\topenTaskSteps?: readonly GoalRuntimeOpenTaskStep[];\n\t/**\n\t * Per-requirement worktree-sync state, present only for requirements whose `boundLaneId` matches\n\t * a `worktreeLaneStatus` entry supplied to the builder. Optional (like `openTaskSteps`) so every\n\t * pre-existing caller/test keeps compiling unchanged; omitted entirely (not an empty array) when\n\t * the builder was never given `worktreeLaneStatus`, since \"no data supplied\" and \"data supplied,\n\t * nothing bound\" are genuinely different states worth distinguishing.\n\t */\n\trequirementWorktreeStates?: readonly GoalRuntimeRequirementWorktreeState[];\n}\n\n/**\n * Branch-scoped: every resolver here reads from ONE source (the active branch), so the goal\n * state, evidence bundle, worker results, learning decisions, and open task steps in the\n * returned snapshot are never a mix of the current branch and a sibling branch's history.\n */\nexport function buildGoalRuntimeSnapshot(args: {\n\tsessionManager: Pick<SessionManager, \"getLatestCustomEntryOnBranch\" | \"getBranch\">;\n\tsettings: GoalRuntimeSnapshotSettings;\n\t/**\n\t * Live lane records (queued/running/terminal), independent of branch scoping. Used ONLY to (a)\n\t * detect a worker in flight against the active goal's open requirement (\"waiting\" — see\n\t * `evaluateGoalContinuation`'s `inFlightGoalLaneIds`), and (b) surface this goal's cumulative\n\t * worker/subagent spend (advisory — see `GoalState.continuationWorkerSpendUsd`). Optional so\n\t * every pre-existing caller (hand-built snapshots, tests) that predates lane-awareness keeps\n\t * compiling and behaving byte-identically: omitting it disables both the \"waiting\" branch and the\n\t * worker-spend overlay, and never changes any OTHER continuation outcome.\n\t */\n\tlaneRecords?: readonly LaneRecord[];\n\t/**\n\t * Current time as an ISO-string factory, threaded into `evaluateGoalContinuation`'s never-hang\n\t * wait-timeout check (`now`/`maxWorkerWaitMs` — see there) alongside `maxWorkerWaitMs` below.\n\t * Defaults to the real wall clock. A factory (not a plain string) so a caller/test can inject a\n\t * fixed clock without freezing global `Date`.\n\t */\n\tnow?: () => string;\n\t/**\n\t * Maximum milliseconds a bound in-flight requirement may wait before the continuation escalates\n\t * to `worker_wait_timeout` instead of `\"waiting\"` forever (see `evaluateGoalContinuation`).\n\t * Defaults to `DEFAULT_GOAL_WORKER_WAIT_MS`.\n\t */\n\tmaxWorkerWaitMs?: number;\n\t/**\n\t * Live per-lane worktree-sync status, independent of branch scoping -- exactly like `laneRecords`,\n\t * this builder performs NO I/O of its own; the caller derives this array (e.g. from\n\t * `core/worktree-sync/git-engine.ts`'s live status) and supplies it ready-made. Used to (a) build\n\t * `requirementWorktreeStates` (per-requirement projection, matched via `boundLaneId`) and (b)\n\t * derive the `laneSyncConflictLaneKeys`/`syncRequiredLaneKeys` sets threaded into\n\t * `evaluateGoalContinuation`. Optional so every pre-existing caller (predating worktree-sync\n\t * awareness) keeps compiling and behaving byte-identically: omitting it disables both, and never\n\t * changes any OTHER continuation outcome.\n\t */\n\tworktreeLaneStatus?: readonly GoalRuntimeWorktreeLaneStatus[];\n}): GoalRuntimeSnapshot {\n\tconst branchEntries = args.sessionManager.getBranch();\n\tlet goalState = getLatestGoalStateSnapshot(args.sessionManager);\n\tconst latestEvidenceBundle = getLatestEvidenceBundleSnapshot(branchEntries);\n\tconst workerResults = getWorkerResultSnapshots(branchEntries);\n\tconst learningDecisions = getLearningDecisionSnapshots(branchEntries);\n\n\t// Reuses the SAME branch-scoped primitive as goal-state resolution (getLatestCustomEntryOnBranch),\n\t// so the task-steps summary below can never leak a sibling branch's checklist either.\n\tconst taskStepsState = getLatestTaskStepsStateSnapshot(args.sessionManager);\n\tconst openTaskSteps: GoalRuntimeOpenTaskStep[] = (taskStepsState?.steps ?? [])\n\t\t.filter((step) => step.status !== \"completed\" && step.status !== \"cancelled\")\n\t\t.map((step) => ({ id: step.id, status: step.status, content: step.activeForm || step.content }));\n\n\tlet inFlightGoalLaneIds: ReadonlySet<string> | undefined;\n\tif (goalState && args.laneRecords) {\n\t\tconst goalId = goalState.goalId;\n\t\tconst inFlight = new Set<string>();\n\t\t// Live-derived, not durably persisted: the goal-state event log has no reducer branch that\n\t\t// writes `continuationWorkerSpendUsd` (see its doc comment on `GoalState`), so every read\n\t\t// re-sums THIS goal's own lane records instead of trusting a stale/zero persisted value.\n\t\t// `costUsd` is set today for in-process worker/research lane completions (LaneTracker.complete);\n\t\t// it is NOT yet set for tmux-worker completions (`ManagedLaneEvent` carries no cost claim), so\n\t\t// this sum is accurate for in-process lanes and a documented undercount for tmux workers until\n\t\t// `reportSpawnedUsage` threads a goalId/lane correlation through. Forward-compatible: the moment\n\t\t// tmux-worker costUsd is populated, this same sum picks it up with no further change here.\n\t\tlet workerSpendUsd = 0;\n\t\tfor (const record of args.laneRecords) {\n\t\t\tif (record.goalId !== goalId) continue;\n\t\t\tif (record.status === \"queued\" || record.status === \"running\") inFlight.add(record.laneId);\n\t\t\tworkerSpendUsd += record.costUsd ?? 0;\n\t\t}\n\t\tinFlightGoalLaneIds = inFlight;\n\t\tgoalState = { ...goalState, continuationWorkerSpendUsd: workerSpendUsd };\n\t}\n\n\t// Worktree-sync surfacing: (a) a per-requirement projection (matched via `boundLaneId`, purely for\n\t// snapshot consumers -- never read by `evaluateGoalContinuation` itself), and (b) the\n\t// `boundLaneId`-keyed sets `evaluateGoalContinuation` actually matches against\n\t// `Requirement.boundLaneId`, same id-space and matching pattern as `inFlightGoalLaneIds` above.\n\t// Disjoint by construction: a lane with `rebaseInProgress` feeds the conflict set only, never both.\n\tlet requirementWorktreeStates: GoalRuntimeRequirementWorktreeState[] | undefined;\n\tconst laneSyncConflictLaneKeys = new Set<string>();\n\tconst syncRequiredLaneKeys = new Set<string>();\n\tif (args.worktreeLaneStatus) {\n\t\tfor (const status of args.worktreeLaneStatus) {\n\t\t\tif (status.boundLaneId === undefined) continue;\n\t\t\tif (status.rebaseInProgress) laneSyncConflictLaneKeys.add(status.boundLaneId);\n\t\t\telse if (status.syncRequired) syncRequiredLaneKeys.add(status.boundLaneId);\n\t\t}\n\t\tif (goalState) {\n\t\t\tconst states: GoalRuntimeRequirementWorktreeState[] = [];\n\t\t\tfor (const requirement of goalState.requirements) {\n\t\t\t\tif (requirement.boundLaneId === undefined) continue;\n\t\t\t\tconst status = args.worktreeLaneStatus.find(\n\t\t\t\t\t(candidate) => candidate.boundLaneId === requirement.boundLaneId,\n\t\t\t\t);\n\t\t\t\tif (!status) continue;\n\t\t\t\tstates.push({\n\t\t\t\t\trequirementId: requirement.id,\n\t\t\t\t\tlaneKey: status.laneKey,\n\t\t\t\t\tfresh: status.fresh,\n\t\t\t\t\tstale: status.stale,\n\t\t\t\t\tsyncRequired: status.syncRequired,\n\t\t\t\t\trebaseInProgress: status.rebaseInProgress,\n\t\t\t\t});\n\t\t\t}\n\t\t\trequirementWorktreeStates = states;\n\t\t}\n\t}\n\n\tconst now = (args.now ?? (() => new Date().toISOString()))();\n\tconst maxWorkerWaitMs = args.maxWorkerWaitMs ?? DEFAULT_GOAL_WORKER_WAIT_MS;\n\tconst continuation = evaluateGoalContinuation({\n\t\tstate: goalState,\n\t\tsettings: { maxStallTurns: args.settings.maxStallTurns },\n\t\tinFlightGoalLaneIds,\n\t\tnow,\n\t\tmaxWorkerWaitMs,\n\t\tlaneSyncConflictLaneKeys: laneSyncConflictLaneKeys.size > 0 ? laneSyncConflictLaneKeys : undefined,\n\t\tsyncRequiredLaneKeys: syncRequiredLaneKeys.size > 0 ? syncRequiredLaneKeys : undefined,\n\t});\n\n\treturn {\n\t\tgoalState,\n\t\tlatestEvidenceBundle,\n\t\tworkerResults,\n\t\tlearningDecisions,\n\t\tcontinuation,\n\t\topenTaskSteps,\n\t\t...(requirementWorktreeStates !== undefined ? { requirementWorktreeStates } : {}),\n\t};\n}\n"]}
1
+ {"version":3,"file":"goal-runtime-snapshot.js","sourceRoot":"","sources":["../../../src/core/goals/goal-runtime-snapshot.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,uBAAuB,EAAE,MAAM,uCAAuC,CAAC;AAChF,OAAO,EAAE,4BAA4B,EAAE,MAAM,0CAA0C,CAAC;AAExF,OAAO,EAAE,uBAAuB,EAAmC,MAAM,2CAA2C,CAAC;AACrH,OAAO,EAAE,+BAA+B,EAAE,MAAM,wCAAwC,CAAC;AACzF,OAAO,EAAE,6BAA6B,EAAE,MAAM,wBAAwB,CAAC;AACvE,OAAO,EAAE,+BAA+B,EAAE,MAAM,gCAAgC,CAAC;AAEjF,OAAO,EAAE,wBAAwB,EAAiC,MAAM,mCAAmC,CAAC;AAC5G,OAAO,EAAE,2BAA2B,EAAE,MAAM,iCAAiC,CAAC;AAE9E,OAAO,EAAE,0BAA0B,EAAE,MAAM,yBAAyB,CAAC;AAyErE;;;;GAIG;AACH,MAAM,UAAU,wBAAwB,CAAC,IAuCxC,EAAuB;IACvB,MAAM,aAAa,GAAG,6BAA6B,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;IACzE,IAAI,SAAS,GAAG,0BAA0B,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;IAChE,MAAM,oBAAoB,GAAG,+BAA+B,CAAC,aAAa,CAAC,CAAC;IAC5E,MAAM,YAAY,GAAG,uBAAuB,CAAC,aAAa,CAAC,CAAC;IAC5D,MAAM,iBAAiB,G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,CAAC,WAAW,EAAE,CAAC,CAAC,EAAE,CAAC;IAC7D,MAAM,eAAe,GAAG,IAAI,CAAC,eAAe,IAAI,2BAA2B,CAAC;IAC5E,MAAM,YAAY,GAAG,wBAAwB,CAAC;QAC7C,KAAK,EAAE,SAAS;QAChB,QAAQ,EAAE,EAAE,aAAa,EAAE,IAAI,CAAC,QAAQ,CAAC,aAAa,EAAE;QACxD,mBAAmB;QACnB,GAAG;QACH,eAAe;QACf,wBAAwB,EAAE,wBAAwB,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC,CAAC,wBAAwB,CAAC,CAAC,CAAC,SAAS;QAClG,oBAAoB,EAAE,oBAAoB,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC,CAAC,oBAAoB,CAAC,CAAC,CAAC,SAAS;KACtF,CAAC,CAAC;IAEH,OAAO;QACN,SAAS;QACT,oBAAoB;QACpB,YAAY;QACZ,iBAAiB;QACjB,YAAY;QACZ,aAAa;QACb,SAAS;QACT,GAAG,CAAC,yBAAyB,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,yBAAyB,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KACjF,CAAC;AAAA,CACF","sourcesContent":["import type { SessionManager } from \"@caupulican/pi-agent-core/node\";\nimport type { EvidenceBundle, LearningDecision, WorkerClaim } from \"../autonomy/contracts.ts\";\nimport type { LaneRecord } from \"../autonomy/lane-tracker.ts\";\nimport { getWorkerClaimSnapshots } from \"../delegation/session-worker-claim.ts\";\nimport { getLearningDecisionSnapshots } from \"../learning/session-learning-decision.ts\";\nimport type { TaskRuntimeProjection } from \"../orchestration/task-runtime.ts\";\nimport { projectSessionWorkState, type SessionWorkStateProjection } from \"../orchestration/work-state-projection.ts\";\nimport { getLatestEvidenceBundleSnapshot } from \"../research/session-evidence-bundle.ts\";\nimport { getActiveSessionBranchEntries } from \"../session-snapshot.ts\";\nimport { getLatestTaskStepsStateSnapshot } from \"../tasks/session-task-state.ts\";\nimport type { OpenTaskStepProjection } from \"../tasks/task-projection.ts\";\nimport { evaluateGoalContinuation, type GoalContinuationDecision } from \"./goal-continuation-controller.ts\";\nimport { DEFAULT_GOAL_WORKER_WAIT_MS } from \"./goal-continuation-defaults.ts\";\nimport type { GoalState } from \"./goal-state.ts\";\nimport { getLatestGoalStateSnapshot } from \"./session-goal-state.ts\";\n\nexport interface GoalRuntimeSnapshotSettings {\n\tmaxStallTurns: number;\n}\n\n/**\n * A read-only projection of one OPEN (non-terminal) task_steps step, included in the goal\n * runtime snapshot purely for cross-visibility. This is NOT a shared state machine: the goal\n * loop never writes back to task state through this snapshot, and the task store stays the\n * single source of truth for its own steps.\n */\nexport type GoalRuntimeOpenTaskStep = OpenTaskStepProjection;\n\n/**\n * Live, per-worktree-sync-lane status for one lane bound to a dispatched worker, as the caller\n * (runtime-builder / whatever host process has live git-engine access) derives it. `boundLaneId` is\n * the host `LaneRecord.laneId` the lane's registration was correlated to\n * (`LaneRegistration.boundLaneId`, same id-space as `Requirement.boundLaneId`) -- `undefined` for a\n * lane never bound to a dispatch. `fresh`/`stale` mirror `LaneFacts`; `syncRequired` is the\n * staleness-propagation verdict (`WorktreeSyncPolicy`-derived); `rebaseInProgress` marks a sync that\n * stopped on conflicts (a rebase left in progress) -- see `core/worktree-sync/git-engine.ts`.\n */\nexport interface GoalRuntimeWorktreeLaneStatus {\n\tlaneKey: string;\n\tboundLaneId?: string;\n\tfresh: boolean;\n\tstale: boolean;\n\tsyncRequired: boolean;\n\trebaseInProgress: boolean;\n}\n\n/**\n * Per-requirement projection of {@link GoalRuntimeWorktreeLaneStatus}, joined via\n * `requirement.boundLaneId === status.boundLaneId` -- read-only cross-visibility for snapshot\n * consumers (e.g. a future continuation-prompt render), mirroring `openTaskSteps`'s role. This is\n * NOT what feeds `evaluateGoalContinuation` (that reads the raw `boundLaneId`-keyed sets directly);\n * it exists purely so a requirement's worktree state is visible without re-deriving the join.\n */\nexport interface GoalRuntimeRequirementWorktreeState {\n\trequirementId: string;\n\tlaneKey: string;\n\tfresh: boolean;\n\tstale: boolean;\n\tsyncRequired: boolean;\n\trebaseInProgress: boolean;\n}\n\nexport interface GoalRuntimeSnapshot {\n\tgoalState?: GoalState;\n\tlatestEvidenceBundle?: EvidenceBundle;\n\tworkerClaims: readonly WorkerClaim[];\n\tlearningDecisions: readonly LearningDecision[];\n\tcontinuation: GoalContinuationDecision;\n\t/**\n\t * Open (non-terminal) task_steps steps on the active branch, latest-wins. Read-only.\n\t * Optional (like `goalState`/`latestEvidenceBundle`) so hand-built snapshots in existing\n\t * tests/call sites that predate this field keep compiling unchanged; `buildGoalRuntimeSnapshot`\n\t * itself always populates a concrete array (possibly empty).\n\t */\n\topenTaskSteps?: readonly GoalRuntimeOpenTaskStep[];\n\t/** Canonical read model joining requirements, foreground steps, and delegated DAG tasks. */\n\tworkState?: SessionWorkStateProjection;\n\t/**\n\t * Per-requirement worktree-sync state, present only for requirements whose `boundLaneId` matches\n\t * a `worktreeLaneStatus` entry supplied to the builder. Optional (like `openTaskSteps`) so every\n\t * pre-existing caller/test keeps compiling unchanged; omitted entirely (not an empty array) when\n\t * the builder was never given `worktreeLaneStatus`, since \"no data supplied\" and \"data supplied,\n\t * nothing bound\" are genuinely different states worth distinguishing.\n\t */\n\trequirementWorktreeStates?: readonly GoalRuntimeRequirementWorktreeState[];\n}\n\n/**\n * Branch-scoped: every resolver here reads from ONE source (the active branch), so the goal\n * state, evidence bundle, worker claims, learning decisions, and open task steps in the\n * returned snapshot are never a mix of the current branch and a sibling branch's history.\n */\nexport function buildGoalRuntimeSnapshot(args: {\n\tsessionManager: Pick<SessionManager, \"getLatestCustomEntryOnBranch\" | \"getBranch\">;\n\tsettings: GoalRuntimeSnapshotSettings;\n\t/**\n\t * Live lane records (queued/running/terminal), independent of branch scoping. Used ONLY to (a)\n\t * detect a worker in flight against the active goal's open requirement (\"waiting\" — see\n\t * `evaluateGoalContinuation`'s `inFlightGoalLaneIds`), and (b) surface this goal's cumulative\n\t * worker/subagent spend (advisory — see `GoalState.continuationWorkerSpendUsd`). Optional so\n\t * every pre-existing caller (hand-built snapshots, tests) that predates lane-awareness keeps\n\t * compiling and behaving byte-identically: omitting it disables both the \"waiting\" branch and the\n\t * worker-spend overlay, and never changes any OTHER continuation outcome.\n\t */\n\tlaneRecords?: readonly LaneRecord[];\n\t/**\n\t * Current time as an ISO-string factory, threaded into `evaluateGoalContinuation`'s never-hang\n\t * wait-timeout check (`now`/`maxWorkerWaitMs` — see there) alongside `maxWorkerWaitMs` below.\n\t * Defaults to the real wall clock. A factory (not a plain string) so a caller/test can inject a\n\t * fixed clock without freezing global `Date`.\n\t */\n\tnow?: () => string;\n\t/**\n\t * Maximum milliseconds a bound in-flight requirement may wait before the continuation escalates\n\t * to `worker_wait_timeout` instead of `\"waiting\"` forever (see `evaluateGoalContinuation`).\n\t * Defaults to `DEFAULT_GOAL_WORKER_WAIT_MS`.\n\t */\n\tmaxWorkerWaitMs?: number;\n\t/**\n\t * Live per-lane worktree-sync status, independent of branch scoping -- exactly like `laneRecords`,\n\t * this builder performs NO I/O of its own; the caller derives this array (e.g. from\n\t * `core/worktree-sync/git-engine.ts`'s live status) and supplies it ready-made. Used to (a) build\n\t * `requirementWorktreeStates` (per-requirement projection, matched via `boundLaneId`) and (b)\n\t * derive the `laneSyncConflictLaneKeys`/`syncRequiredLaneKeys` sets threaded into\n\t * `evaluateGoalContinuation`. Optional so every pre-existing caller (predating worktree-sync\n\t * awareness) keeps compiling and behaving byte-identically: omitting it disables both, and never\n\t * changes any OTHER continuation outcome.\n\t */\n\tworktreeLaneStatus?: readonly GoalRuntimeWorktreeLaneStatus[];\n\t/** Durable worker DAG projection, supplied only when the delegate capability has been loaded. */\n\ttaskRuntime?: TaskRuntimeProjection;\n}): GoalRuntimeSnapshot {\n\tconst branchEntries = getActiveSessionBranchEntries(args.sessionManager);\n\tlet goalState = getLatestGoalStateSnapshot(args.sessionManager);\n\tconst latestEvidenceBundle = getLatestEvidenceBundleSnapshot(branchEntries);\n\tconst workerClaims = getWorkerClaimSnapshots(branchEntries);\n\tconst learningDecisions = getLearningDecisionSnapshots(branchEntries);\n\n\t// Reuses the SAME branch-scoped primitive as goal-state resolution (getLatestCustomEntryOnBranch),\n\t// so the task-steps summary below can never leak a sibling branch's checklist either.\n\tconst taskStepsState = getLatestTaskStepsStateSnapshot(args.sessionManager);\n\tconst workState = projectSessionWorkState({ goalState, taskStepsState, taskRuntime: args.taskRuntime });\n\tconst openTaskSteps = workState.openTaskSteps;\n\n\tlet inFlightGoalLaneIds: ReadonlySet<string> | undefined;\n\tif (goalState && args.laneRecords) {\n\t\tconst goalId = goalState.goalId;\n\t\tconst inFlight = new Set<string>();\n\t\t// Live-derived, not durably persisted: the goal-state event log has no reducer branch that\n\t\t// writes `continuationWorkerSpendUsd` (see its doc comment on `GoalState`), so every read\n\t\t// re-sums THIS goal's own lane records instead of trusting a stale/zero persisted value.\n\t\t// `costUsd` is set today for in-process worker/research lane completions (LaneTracker.complete);\n\t\t// it is NOT yet set for tmux-worker completions (`ManagedLaneEvent` carries no cost claim), so\n\t\t// this sum is accurate for in-process lanes and a documented undercount for tmux workers until\n\t\t// `reportSpawnedUsage` threads a goalId/lane correlation through. Forward-compatible: the moment\n\t\t// tmux-worker costUsd is populated, this same sum picks it up with no further change here.\n\t\tlet workerSpendUsd = 0;\n\t\tfor (const record of args.laneRecords) {\n\t\t\tif (record.goalId !== goalId) continue;\n\t\t\tif (record.status === \"queued\" || record.status === \"running\") inFlight.add(record.laneId);\n\t\t\tworkerSpendUsd += record.costUsd ?? 0;\n\t\t}\n\t\tinFlightGoalLaneIds = inFlight;\n\t\tgoalState = { ...goalState, continuationWorkerSpendUsd: workerSpendUsd };\n\t}\n\n\t// Worktree-sync surfacing: (a) a per-requirement projection (matched via `boundLaneId`, purely for\n\t// snapshot consumers -- never read by `evaluateGoalContinuation` itself), and (b) the\n\t// `boundLaneId`-keyed sets `evaluateGoalContinuation` actually matches against\n\t// `Requirement.boundLaneId`, same id-space and matching pattern as `inFlightGoalLaneIds` above.\n\t// Disjoint by construction: a lane with `rebaseInProgress` feeds the conflict set only, never both.\n\tlet requirementWorktreeStates: GoalRuntimeRequirementWorktreeState[] | undefined;\n\tconst laneSyncConflictLaneKeys = new Set<string>();\n\tconst syncRequiredLaneKeys = new Set<string>();\n\tif (args.worktreeLaneStatus) {\n\t\tfor (const status of args.worktreeLaneStatus) {\n\t\t\tif (status.boundLaneId === undefined) continue;\n\t\t\tif (status.rebaseInProgress) laneSyncConflictLaneKeys.add(status.boundLaneId);\n\t\t\telse if (status.syncRequired) syncRequiredLaneKeys.add(status.boundLaneId);\n\t\t}\n\t\tif (goalState) {\n\t\t\tconst states: GoalRuntimeRequirementWorktreeState[] = [];\n\t\t\tfor (const requirement of goalState.requirements) {\n\t\t\t\tif (requirement.boundLaneId === undefined) continue;\n\t\t\t\tconst status = args.worktreeLaneStatus.find(\n\t\t\t\t\t(candidate) => candidate.boundLaneId === requirement.boundLaneId,\n\t\t\t\t);\n\t\t\t\tif (!status) continue;\n\t\t\t\tstates.push({\n\t\t\t\t\trequirementId: requirement.id,\n\t\t\t\t\tlaneKey: status.laneKey,\n\t\t\t\t\tfresh: status.fresh,\n\t\t\t\t\tstale: status.stale,\n\t\t\t\t\tsyncRequired: status.syncRequired,\n\t\t\t\t\trebaseInProgress: status.rebaseInProgress,\n\t\t\t\t});\n\t\t\t}\n\t\t\trequirementWorktreeStates = states;\n\t\t}\n\t}\n\n\tconst now = (args.now ?? (() => new Date().toISOString()))();\n\tconst maxWorkerWaitMs = args.maxWorkerWaitMs ?? DEFAULT_GOAL_WORKER_WAIT_MS;\n\tconst continuation = evaluateGoalContinuation({\n\t\tstate: goalState,\n\t\tsettings: { maxStallTurns: args.settings.maxStallTurns },\n\t\tinFlightGoalLaneIds,\n\t\tnow,\n\t\tmaxWorkerWaitMs,\n\t\tlaneSyncConflictLaneKeys: laneSyncConflictLaneKeys.size > 0 ? laneSyncConflictLaneKeys : undefined,\n\t\tsyncRequiredLaneKeys: syncRequiredLaneKeys.size > 0 ? syncRequiredLaneKeys : undefined,\n\t});\n\n\treturn {\n\t\tgoalState,\n\t\tlatestEvidenceBundle,\n\t\tworkerClaims,\n\t\tlearningDecisions,\n\t\tcontinuation,\n\t\topenTaskSteps,\n\t\tworkState,\n\t\t...(requirementWorktreeStates !== undefined ? { requirementWorktreeStates } : {}),\n\t};\n}\n"]}
@@ -0,0 +1,42 @@
1
+ import type { SessionManager } from "@caupulican/pi-agent-core/node";
2
+ import type { GoalContinuationLoopOptions, GoalContinuationLoopResult, GoalContinuationOnceOptions, GoalContinuationOnceResult, PromptOptions } from "../agent-session-contracts.ts";
3
+ import type { LaneRecord } from "../autonomy/lane-tracker.ts";
4
+ import type { TaskRuntimeProjection } from "../orchestration/task-runtime.ts";
5
+ import { type GoalStateRevision } from "./goal-lifecycle.ts";
6
+ import { type GoalRuntimeSnapshot, type GoalRuntimeSnapshotSettings } from "./goal-runtime-snapshot.ts";
7
+ import { type GoalState } from "./goal-state.ts";
8
+ export interface GoalSessionControllerDeps {
9
+ getSessionManager(): SessionManager;
10
+ getModelProvider(): string | undefined;
11
+ getLaneRecords(): readonly LaneRecord[];
12
+ getTaskRuntimeSnapshot(): TaskRuntimeProjection | undefined;
13
+ synchronizeGoalState(state: GoalState): void;
14
+ scheduleGoalAutoContinueFromIdle(): void;
15
+ prompt(text: string, options?: PromptOptions): Promise<void>;
16
+ emitWarning(message: string): void;
17
+ }
18
+ /**
19
+ * Owns durable goal state, exact continuation accounting, and the raw continuation loop. The
20
+ * AgentSession facade supplies process collaborators but no longer implements goal lifecycle rules.
21
+ */
22
+ export declare class GoalSessionController {
23
+ private readonly deps;
24
+ private readonly loop;
25
+ constructor(deps: GoalSessionControllerDeps);
26
+ saveState(state: GoalState, expected?: GoalStateRevision): string;
27
+ clearState(state: GoalState, now: string): string;
28
+ getState(): GoalState | undefined;
29
+ recordContinuationPass(pass: {
30
+ turns: number;
31
+ wallClockMs: number;
32
+ usageCursor: string | null;
33
+ }): void;
34
+ markToolUnavailable(): void;
35
+ getRuntimeSnapshot(settings: GoalRuntimeSnapshotSettings): GoalRuntimeSnapshot;
36
+ continueOnce(options: GoalContinuationOnceOptions): Promise<GoalContinuationOnceResult>;
37
+ continueLoop(options: GoalContinuationLoopOptions): Promise<GoalContinuationLoopResult>;
38
+ restoreAfterResume(): void;
39
+ private recordContinuationFailure;
40
+ private markBudgetLimited;
41
+ }
42
+ //# sourceMappingURL=goal-session-controller.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"goal-session-controller.d.ts","sourceRoot":"","sources":["../../../src/core/goals/goal-session-controller.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAErE,OAAO,KAAK,EACX,2BAA2B,EAC3B,0BAA0B,EAC1B,2BAA2B,EAC3B,0BAA0B,EAC1B,aAAa,EACb,MAAM,+BAA+B,CAAC;AACvC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AAE9D,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,kCAAkC,CAAC;AAC9E,OAAO,EAAE,KAAK,iBAAiB,EAA4C,MAAM,qBAAqB,CAAC;AACvG,OAAO,EAEN,KAAK,mBAAmB,EACxB,KAAK,2BAA2B,EAChC,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAkB,KAAK,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAOjE,MAAM,WAAW,yBAAyB;IACzC,iBAAiB,IAAI,cAAc,CAAC;IACpC,gBAAgB,IAAI,MAAM,GAAG,SAAS,CAAC;IACvC,cAAc,IAAI,SAAS,UAAU,EAAE,CAAC;IACxC,sBAAsB,IAAI,qBAAqB,GAAG,SAAS,CAAC;IAC5D,oBAAoB,CAAC,KAAK,EAAE,SAAS,GAAG,IAAI,CAAC;IAC7C,gCAAgC,IAAI,IAAI,CAAC;IACzC,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC7D,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;CACnC;AAED;;;GAGG;AACH,qBAAa,qBAAqB;IACjC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAA4B;IACjD,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAqB;IAE1C,YAAY,IAAI,EAAE,yBAAyB,EAU1C;IAED,SAAS,CAAC,KAAK,EAAE,SAAS,EAAE,QAAQ,CAAC,EAAE,iBAAiB,GAAG,MAAM,CAmBhE;IAED,UAAU,CAAC,KAAK,EAAE,SAAS,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,CAUhD;IAED,QAAQ,IAAI,SAAS,GAAG,SAAS,CAEhC;IAED,sBAAsB,CAAC,IAAI,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,WAAW,EAAE,MAAM,CAAC;QAAC,WAAW,EAAE,MAAM,GAAG,IAAI,CAAA;KAAE,GAAG,IAAI,CA6BrG;IAED,mBAAmB,IAAI,IAAI,CAW1B;IAED,kBAAkB,CAAC,QAAQ,EAAE,2BAA2B,GAAG,mBAAmB,CAO7E;IAED,YAAY,CAAC,OAAO,EAAE,2BAA2B,GAAG,OAAO,CAAC,0BAA0B,CAAC,CAEtF;IAED,YAAY,CAAC,OAAO,EAAE,2BAA2B,GAAG,OAAO,CAAC,0BAA0B,CAAC,CAEtF;IAED,kBAAkB,IAAI,IAAI,CAEzB;IAED,OAAO,CAAC,yBAAyB;IAcjC,OAAO,CAAC,iBAAiB;CAKzB","sourcesContent":["import { classifyFailure } from \"@caupulican/pi-agent-core\";\nimport type { SessionManager } from \"@caupulican/pi-agent-core/node\";\nimport type { AssistantMessage } from \"@caupulican/pi-ai\";\nimport type {\n\tGoalContinuationLoopOptions,\n\tGoalContinuationLoopResult,\n\tGoalContinuationOnceOptions,\n\tGoalContinuationOnceResult,\n\tPromptOptions,\n} from \"../agent-session-contracts.ts\";\nimport type { LaneRecord } from \"../autonomy/lane-tracker.ts\";\nimport { GoalLoopController } from \"../goal-loop-controller.ts\";\nimport type { TaskRuntimeProjection } from \"../orchestration/task-runtime.ts\";\nimport { type GoalStateRevision, getGoalStateRevision, stopGoalFromSystem } from \"./goal-lifecycle.ts\";\nimport {\n\tbuildGoalRuntimeSnapshot,\n\ttype GoalRuntimeSnapshot,\n\ttype GoalRuntimeSnapshotSettings,\n} from \"./goal-runtime-snapshot.ts\";\nimport { applyGoalEvent, type GoalState } from \"./goal-state.ts\";\nimport {\n\tappendGoalClearedSnapshot,\n\tappendGoalStateSnapshot,\n\tgetLatestGoalStateSnapshot,\n} from \"./session-goal-state.ts\";\n\nexport interface GoalSessionControllerDeps {\n\tgetSessionManager(): SessionManager;\n\tgetModelProvider(): string | undefined;\n\tgetLaneRecords(): readonly LaneRecord[];\n\tgetTaskRuntimeSnapshot(): TaskRuntimeProjection | undefined;\n\tsynchronizeGoalState(state: GoalState): void;\n\tscheduleGoalAutoContinueFromIdle(): void;\n\tprompt(text: string, options?: PromptOptions): Promise<void>;\n\temitWarning(message: string): void;\n}\n\n/**\n * Owns durable goal state, exact continuation accounting, and the raw continuation loop. The\n * AgentSession facade supplies process collaborators but no longer implements goal lifecycle rules.\n */\nexport class GoalSessionController {\n\tprivate readonly deps: GoalSessionControllerDeps;\n\tprivate readonly loop: GoalLoopController;\n\n\tconstructor(deps: GoalSessionControllerDeps) {\n\t\tthis.deps = deps;\n\t\tthis.loop = new GoalLoopController({\n\t\t\tgetGoalRuntimeSnapshot: (settings) => this.getRuntimeSnapshot(settings),\n\t\t\tprompt: (text, options) => this.deps.prompt(text, options),\n\t\t\tcaptureUsageCursor: () => this.deps.getSessionManager().getLeafId(),\n\t\t\trecordGoalContinuationPass: (pass) => this.recordContinuationPass(pass),\n\t\t\trecordGoalContinuationFailure: (error) => this.recordContinuationFailure(error),\n\t\t\tmarkGoalBudgetLimited: (reason) => this.markBudgetLimited(reason),\n\t\t});\n\t}\n\n\tsaveState(state: GoalState, expected?: GoalStateRevision): string {\n\t\tconst current = this.getState();\n\t\tif (\n\t\t\texpected &&\n\t\t\t(!current || current.goalId !== expected.goalId || (current.revision ?? 0) !== expected.revision)\n\t\t) {\n\t\t\tthrow new Error(\n\t\t\t\t`Goal state changed concurrently; expected ${expected.goalId}@${expected.revision}, found ${current ? `${current.goalId}@${current.revision ?? 0}` : \"none\"}. Retry against the latest state.`,\n\t\t\t);\n\t\t}\n\t\tconst entryId = appendGoalStateSnapshot(this.deps.getSessionManager(), state, current);\n\t\ttry {\n\t\t\tthis.deps.synchronizeGoalState(state);\n\t\t} catch (error) {\n\t\t\tthis.deps.emitWarning(\n\t\t\t\t`Goal state persisted but durable worker reconciliation failed: ${error instanceof Error ? error.message : String(error)}`,\n\t\t\t);\n\t\t}\n\t\treturn entryId;\n\t}\n\n\tclearState(state: GoalState, now: string): string {\n\t\tconst current = this.getState();\n\t\tconst expected = getGoalStateRevision(state);\n\t\tif (!current || current.goalId !== expected.goalId || (current.revision ?? 0) !== expected.revision) {\n\t\t\tthrow new Error(\"Goal state changed concurrently; retry clear against the latest state.\");\n\t\t}\n\t\tif (state.status !== \"completed\" && state.status !== \"cancelled\") {\n\t\t\tthis.deps.synchronizeGoalState(applyGoalEvent(state, { type: \"cancel_goal\", now }));\n\t\t}\n\t\treturn appendGoalClearedSnapshot(this.deps.getSessionManager(), state, now);\n\t}\n\n\tgetState(): GoalState | undefined {\n\t\treturn getLatestGoalStateSnapshot(this.deps.getSessionManager());\n\t}\n\n\trecordContinuationPass(pass: { turns: number; wallClockMs: number; usageCursor: string | null }): void {\n\t\tconst state = this.getState();\n\t\tif (!state) return;\n\t\tconst branch = this.deps.getSessionManager().getBranch();\n\t\tconst cursorIndex = pass.usageCursor === null ? -1 : branch.findIndex((entry) => entry.id === pass.usageCursor);\n\t\tif (pass.usageCursor !== null && cursorIndex < 0) {\n\t\t\tthis.deps.emitWarning(\n\t\t\t\t\"Goal usage cursor is no longer on the active branch; stopping instead of guessing usage.\",\n\t\t\t);\n\t\t\tthis.recordContinuationFailure(new Error(\"goal_usage_cursor_lost\"));\n\t\t\treturn;\n\t\t}\n\t\tlet tokens = 0;\n\t\tlet spendUsd = 0;\n\t\tfor (const entry of branch.slice(cursorIndex + 1)) {\n\t\t\tif (entry.type !== \"message\" || entry.message.role !== \"assistant\") continue;\n\t\t\tconst usage = (entry.message as AssistantMessage).usage;\n\t\t\ttokens += Math.max(0, usage.input) + Math.max(0, usage.output);\n\t\t\tspendUsd += Math.max(0, usage.cost.total);\n\t\t}\n\t\tconst updated = applyGoalEvent(state, {\n\t\t\ttype: \"record_continuation_budget\",\n\t\t\tturns: pass.turns,\n\t\t\twallClockMs: pass.wallClockMs,\n\t\t\ttokens,\n\t\t\tspendUsd,\n\t\t\tnow: new Date().toISOString(),\n\t\t});\n\t\tthis.saveState(updated, getGoalStateRevision(state));\n\t}\n\n\tmarkToolUnavailable(): void {\n\t\tconst state = this.getState();\n\t\tconst stopped = stopGoalFromSystem(\n\t\t\tstate,\n\t\t\t{\n\t\t\t\tstatus: \"blocked\",\n\t\t\t\treason: \"goal_tool_unavailable: the active capability surface cannot update durable goal state\",\n\t\t\t},\n\t\t\tnew Date().toISOString(),\n\t\t);\n\t\tif (stopped.ok && state) this.saveState(stopped.state, getGoalStateRevision(state));\n\t}\n\n\tgetRuntimeSnapshot(settings: GoalRuntimeSnapshotSettings): GoalRuntimeSnapshot {\n\t\treturn buildGoalRuntimeSnapshot({\n\t\t\tsessionManager: this.deps.getSessionManager(),\n\t\t\tsettings,\n\t\t\tlaneRecords: this.deps.getLaneRecords(),\n\t\t\ttaskRuntime: this.deps.getTaskRuntimeSnapshot(),\n\t\t});\n\t}\n\n\tcontinueOnce(options: GoalContinuationOnceOptions): Promise<GoalContinuationOnceResult> {\n\t\treturn this.loop.continueGoalOnce(options);\n\t}\n\n\tcontinueLoop(options: GoalContinuationLoopOptions): Promise<GoalContinuationLoopResult> {\n\t\treturn this.loop.continueGoalLoop(options);\n\t}\n\n\trestoreAfterResume(): void {\n\t\tthis.deps.scheduleGoalAutoContinueFromIdle();\n\t}\n\n\tprivate recordContinuationFailure(error: unknown): void {\n\t\tconst state = this.getState();\n\t\tif (!state || state.status !== \"active\") return;\n\t\tconst message = error instanceof Error ? error.message : String(error);\n\t\tconst classified = classifyFailure({ message, provider: this.deps.getModelProvider() });\n\t\tconst status = classified.reason === \"billing_or_quota\" ? \"usage_limited\" : \"blocked\";\n\t\tconst stopped = stopGoalFromSystem(\n\t\t\tstate,\n\t\t\t{ status, reason: `${classified.reason}: ${message}` },\n\t\t\tnew Date().toISOString(),\n\t\t);\n\t\tif (stopped.ok) this.saveState(stopped.state, getGoalStateRevision(state));\n\t}\n\n\tprivate markBudgetLimited(reason: string): void {\n\t\tconst state = this.getState();\n\t\tconst stopped = stopGoalFromSystem(state, { status: \"budget_limited\", reason }, new Date().toISOString());\n\t\tif (stopped.ok && state) this.saveState(stopped.state, getGoalStateRevision(state));\n\t}\n}\n"]}