pulseed 0.4.0 → 0.4.2

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 (335) hide show
  1. package/dist/base/state/state-manager-goal-write.d.ts +22 -0
  2. package/dist/base/state/state-manager-goal-write.d.ts.map +1 -0
  3. package/dist/base/state/state-manager-goal-write.js +74 -0
  4. package/dist/base/state/state-manager-goal-write.js.map +1 -0
  5. package/dist/base/state/state-manager-wal.d.ts +11 -0
  6. package/dist/base/state/state-manager-wal.d.ts.map +1 -0
  7. package/dist/base/state/state-manager-wal.js +89 -0
  8. package/dist/base/state/state-manager-wal.js.map +1 -0
  9. package/dist/base/state/state-manager.d.ts +1 -4
  10. package/dist/base/state/state-manager.d.ts.map +1 -1
  11. package/dist/base/state/state-manager.js +18 -127
  12. package/dist/base/state/state-manager.js.map +1 -1
  13. package/dist/interface/chat/chat-runner.d.ts +1 -1
  14. package/dist/interface/chat/event-subscriber.d.ts +4 -0
  15. package/dist/interface/chat/event-subscriber.d.ts.map +1 -1
  16. package/dist/interface/chat/event-subscriber.js +49 -2
  17. package/dist/interface/chat/event-subscriber.js.map +1 -1
  18. package/dist/interface/chat/tend-command.d.ts +1 -1
  19. package/dist/interface/cli/cli-command-registry.js +1 -1
  20. package/dist/interface/cli/cli-command-registry.js.map +1 -1
  21. package/dist/interface/cli/commands/chat.js +2 -2
  22. package/dist/interface/cli/commands/daemon.d.ts.map +1 -1
  23. package/dist/interface/cli/commands/daemon.js +87 -44
  24. package/dist/interface/cli/commands/daemon.js.map +1 -1
  25. package/dist/interface/cli/commands/schedule.js +2 -2
  26. package/dist/interface/cli/commands/setup/steps-runtime.js +1 -1
  27. package/dist/interface/cli/ensure-api-key.d.ts +4 -1
  28. package/dist/interface/cli/ensure-api-key.d.ts.map +1 -1
  29. package/dist/interface/cli/ensure-api-key.js +52 -15
  30. package/dist/interface/cli/ensure-api-key.js.map +1 -1
  31. package/dist/interface/tui/app.d.ts +1 -1
  32. package/dist/interface/tui/chat/scroll.d.ts +14 -0
  33. package/dist/interface/tui/chat/scroll.d.ts.map +1 -0
  34. package/dist/interface/tui/chat/scroll.js +46 -0
  35. package/dist/interface/tui/chat/scroll.js.map +1 -0
  36. package/dist/interface/tui/chat/suggestions.d.ts +8 -0
  37. package/dist/interface/tui/chat/suggestions.d.ts.map +1 -0
  38. package/dist/interface/tui/chat/suggestions.js +112 -0
  39. package/dist/interface/tui/chat/suggestions.js.map +1 -0
  40. package/dist/interface/tui/chat/types.d.ts +31 -0
  41. package/dist/interface/tui/chat/types.d.ts.map +1 -0
  42. package/dist/interface/tui/chat/types.js +2 -0
  43. package/dist/interface/tui/chat/types.js.map +1 -0
  44. package/dist/interface/tui/chat/viewport.d.ts +3 -0
  45. package/dist/interface/tui/chat/viewport.d.ts.map +1 -0
  46. package/dist/interface/tui/chat/viewport.js +78 -0
  47. package/dist/interface/tui/chat/viewport.js.map +1 -0
  48. package/dist/interface/tui/chat.d.ts +5 -49
  49. package/dist/interface/tui/chat.d.ts.map +1 -1
  50. package/dist/interface/tui/chat.js +7 -236
  51. package/dist/interface/tui/chat.js.map +1 -1
  52. package/dist/interface/tui/entry.js +3 -3
  53. package/dist/interface/tui/use-loop.d.ts +1 -1
  54. package/dist/orchestrator/execution/task/task-lifecycle.d.ts +3 -0
  55. package/dist/orchestrator/execution/task/task-lifecycle.d.ts.map +1 -1
  56. package/dist/orchestrator/execution/task/task-lifecycle.js +3 -0
  57. package/dist/orchestrator/execution/task/task-lifecycle.js.map +1 -1
  58. package/dist/orchestrator/execution/task/task-verifier-rules.d.ts.map +1 -1
  59. package/dist/orchestrator/execution/task/task-verifier-rules.js +34 -2
  60. package/dist/orchestrator/execution/task/task-verifier-rules.js.map +1 -1
  61. package/dist/orchestrator/execution/task/task-verifier-types.d.ts +2 -0
  62. package/dist/orchestrator/execution/task/task-verifier-types.d.ts.map +1 -1
  63. package/dist/orchestrator/loop/checkpoint-manager-loop.d.ts +1 -1
  64. package/dist/orchestrator/loop/checkpoint-manager-loop.d.ts.map +1 -1
  65. package/dist/orchestrator/loop/core-loop/capability.d.ts +22 -0
  66. package/dist/orchestrator/loop/core-loop/capability.d.ts.map +1 -0
  67. package/dist/orchestrator/loop/core-loop/capability.js +151 -0
  68. package/dist/orchestrator/loop/core-loop/capability.js.map +1 -0
  69. package/dist/orchestrator/loop/core-loop/contracts.d.ts +245 -0
  70. package/dist/orchestrator/loop/core-loop/contracts.d.ts.map +1 -0
  71. package/dist/orchestrator/loop/core-loop/contracts.js +40 -0
  72. package/dist/orchestrator/loop/core-loop/contracts.js.map +1 -0
  73. package/dist/orchestrator/loop/core-loop/control.d.ts +27 -0
  74. package/dist/orchestrator/loop/core-loop/control.d.ts.map +1 -0
  75. package/dist/orchestrator/loop/core-loop/control.js +72 -0
  76. package/dist/orchestrator/loop/core-loop/control.js.map +1 -0
  77. package/dist/orchestrator/loop/core-loop/learning.d.ts +31 -0
  78. package/dist/orchestrator/loop/core-loop/learning.d.ts.map +1 -0
  79. package/dist/orchestrator/loop/core-loop/learning.js +92 -0
  80. package/dist/orchestrator/loop/core-loop/learning.js.map +1 -0
  81. package/dist/orchestrator/loop/core-loop/preparation.d.ts +63 -0
  82. package/dist/orchestrator/loop/core-loop/preparation.d.ts.map +1 -0
  83. package/dist/orchestrator/loop/core-loop/preparation.js +362 -0
  84. package/dist/orchestrator/loop/core-loop/preparation.js.map +1 -0
  85. package/dist/orchestrator/loop/core-loop/task-cycle.d.ts +29 -0
  86. package/dist/orchestrator/loop/core-loop/task-cycle.d.ts.map +1 -0
  87. package/dist/orchestrator/loop/core-loop/task-cycle.js +674 -0
  88. package/dist/orchestrator/loop/core-loop/task-cycle.js.map +1 -0
  89. package/dist/orchestrator/loop/core-loop-capability.d.ts +1 -24
  90. package/dist/orchestrator/loop/core-loop-capability.d.ts.map +1 -1
  91. package/dist/orchestrator/loop/core-loop-capability.js +1 -153
  92. package/dist/orchestrator/loop/core-loop-capability.js.map +1 -1
  93. package/dist/orchestrator/loop/core-loop-learning.d.ts +1 -34
  94. package/dist/orchestrator/loop/core-loop-learning.d.ts.map +1 -1
  95. package/dist/orchestrator/loop/core-loop-learning.js +1 -95
  96. package/dist/orchestrator/loop/core-loop-learning.js.map +1 -1
  97. package/dist/orchestrator/loop/core-loop-phases-b.d.ts +1 -31
  98. package/dist/orchestrator/loop/core-loop-phases-b.d.ts.map +1 -1
  99. package/dist/orchestrator/loop/core-loop-phases-b.js +1 -669
  100. package/dist/orchestrator/loop/core-loop-phases-b.js.map +1 -1
  101. package/dist/orchestrator/loop/core-loop-phases-c.d.ts +1 -26
  102. package/dist/orchestrator/loop/core-loop-phases-c.d.ts.map +1 -1
  103. package/dist/orchestrator/loop/core-loop-phases-c.js +1 -71
  104. package/dist/orchestrator/loop/core-loop-phases-c.js.map +1 -1
  105. package/dist/orchestrator/loop/core-loop-phases.d.ts +1 -68
  106. package/dist/orchestrator/loop/core-loop-phases.d.ts.map +1 -1
  107. package/dist/orchestrator/loop/core-loop-phases.js +1 -367
  108. package/dist/orchestrator/loop/core-loop-phases.js.map +1 -1
  109. package/dist/orchestrator/loop/core-loop-types.d.ts +1 -244
  110. package/dist/orchestrator/loop/core-loop-types.d.ts.map +1 -1
  111. package/dist/orchestrator/loop/core-loop-types.js +1 -39
  112. package/dist/orchestrator/loop/core-loop-types.js.map +1 -1
  113. package/dist/orchestrator/loop/core-loop.d.ts +3 -3
  114. package/dist/orchestrator/loop/core-loop.d.ts.map +1 -1
  115. package/dist/orchestrator/loop/core-loop.js +6 -6
  116. package/dist/orchestrator/loop/core-loop.js.map +1 -1
  117. package/dist/orchestrator/loop/loop-report-helper.d.ts +1 -1
  118. package/dist/orchestrator/loop/loop-report-helper.d.ts.map +1 -1
  119. package/dist/orchestrator/loop/parallel-dispatch.d.ts +2 -2
  120. package/dist/orchestrator/loop/parallel-dispatch.d.ts.map +1 -1
  121. package/dist/orchestrator/loop/post-loop-hooks.d.ts +1 -1
  122. package/dist/orchestrator/loop/post-loop-hooks.d.ts.map +1 -1
  123. package/dist/orchestrator/loop/tree-loop-runner.d.ts +1 -1
  124. package/dist/orchestrator/loop/tree-loop-runner.d.ts.map +1 -1
  125. package/dist/orchestrator/loop/tree-loop-runner.js +1 -1
  126. package/dist/orchestrator/loop/tree-loop-runner.js.map +1 -1
  127. package/dist/platform/dream/dream-schedule-suggestions.d.ts +1 -1
  128. package/dist/platform/drive/drive-system.d.ts +8 -0
  129. package/dist/platform/drive/drive-system.d.ts.map +1 -1
  130. package/dist/platform/drive/drive-system.js +39 -22
  131. package/dist/platform/drive/drive-system.js.map +1 -1
  132. package/dist/platform/observation/engine/observe-context.d.ts +4 -0
  133. package/dist/platform/observation/engine/observe-context.d.ts.map +1 -0
  134. package/dist/platform/observation/engine/observe-context.js +26 -0
  135. package/dist/platform/observation/engine/observe-context.js.map +1 -0
  136. package/dist/platform/observation/engine/observe-datasource-stage.d.ts +33 -0
  137. package/dist/platform/observation/engine/observe-datasource-stage.d.ts.map +1 -0
  138. package/dist/platform/observation/engine/observe-datasource-stage.js +66 -0
  139. package/dist/platform/observation/engine/observe-datasource-stage.js.map +1 -0
  140. package/dist/platform/observation/engine/observe-llm-stage.d.ts +25 -0
  141. package/dist/platform/observation/engine/observe-llm-stage.d.ts.map +1 -0
  142. package/dist/platform/observation/engine/observe-llm-stage.js +79 -0
  143. package/dist/platform/observation/engine/observe-llm-stage.js.map +1 -0
  144. package/dist/platform/observation/engine/observe-precheck.d.ts +21 -0
  145. package/dist/platform/observation/engine/observe-precheck.d.ts.map +1 -0
  146. package/dist/platform/observation/engine/observe-precheck.js +51 -0
  147. package/dist/platform/observation/engine/observe-precheck.js.map +1 -0
  148. package/dist/platform/observation/engine/observe-self-report.d.ts +18 -0
  149. package/dist/platform/observation/engine/observe-self-report.d.ts.map +1 -0
  150. package/dist/platform/observation/engine/observe-self-report.js +26 -0
  151. package/dist/platform/observation/engine/observe-self-report.js.map +1 -0
  152. package/dist/platform/observation/engine/observe-tool-stage.d.ts +21 -0
  153. package/dist/platform/observation/engine/observe-tool-stage.d.ts.map +1 -0
  154. package/dist/platform/observation/engine/observe-tool-stage.js +49 -0
  155. package/dist/platform/observation/engine/observe-tool-stage.js.map +1 -0
  156. package/dist/platform/observation/observation-engine.d.ts.map +1 -1
  157. package/dist/platform/observation/observation-engine.js +67 -246
  158. package/dist/platform/observation/observation-engine.js.map +1 -1
  159. package/dist/prompt/context-assembler.d.ts +61 -13
  160. package/dist/prompt/context-assembler.d.ts.map +1 -1
  161. package/dist/prompt/context-assembler.js +18 -3
  162. package/dist/prompt/context-assembler.js.map +1 -1
  163. package/dist/runtime/approval-broker.d.ts.map +1 -1
  164. package/dist/runtime/approval-broker.js +1 -0
  165. package/dist/runtime/approval-broker.js.map +1 -1
  166. package/dist/runtime/command-dispatcher.d.ts +35 -0
  167. package/dist/runtime/command-dispatcher.d.ts.map +1 -0
  168. package/dist/runtime/command-dispatcher.js +145 -0
  169. package/dist/runtime/command-dispatcher.js.map +1 -0
  170. package/dist/runtime/daemon/client.d.ts +67 -0
  171. package/dist/runtime/daemon/client.d.ts.map +1 -0
  172. package/dist/runtime/daemon/client.js +330 -0
  173. package/dist/runtime/daemon/client.js.map +1 -0
  174. package/dist/runtime/daemon/health.d.ts +31 -0
  175. package/dist/runtime/daemon/health.d.ts.map +1 -0
  176. package/dist/runtime/daemon/health.js +113 -0
  177. package/dist/runtime/daemon/health.js.map +1 -0
  178. package/dist/runtime/daemon/index.d.ts +9 -0
  179. package/dist/runtime/daemon/index.d.ts.map +1 -0
  180. package/dist/runtime/daemon/index.js +8 -0
  181. package/dist/runtime/daemon/index.js.map +1 -0
  182. package/dist/runtime/daemon/maintenance.d.ts +47 -0
  183. package/dist/runtime/daemon/maintenance.d.ts.map +1 -0
  184. package/dist/runtime/daemon/maintenance.js +230 -0
  185. package/dist/runtime/daemon/maintenance.js.map +1 -0
  186. package/dist/runtime/daemon/persistence.d.ts +20 -0
  187. package/dist/runtime/daemon/persistence.d.ts.map +1 -0
  188. package/dist/runtime/daemon/persistence.js +112 -0
  189. package/dist/runtime/daemon/persistence.js.map +1 -0
  190. package/dist/runtime/daemon/runner-lifecycle.d.ts +29 -0
  191. package/dist/runtime/daemon/runner-lifecycle.d.ts.map +1 -0
  192. package/dist/runtime/daemon/runner-lifecycle.js +56 -0
  193. package/dist/runtime/daemon/runner-lifecycle.js.map +1 -0
  194. package/dist/runtime/daemon/runner.d.ts +229 -0
  195. package/dist/runtime/daemon/runner.d.ts.map +1 -0
  196. package/dist/runtime/daemon/runner.js +875 -0
  197. package/dist/runtime/daemon/runner.js.map +1 -0
  198. package/dist/runtime/daemon/runtime-ownership.d.ts +30 -0
  199. package/dist/runtime/daemon/runtime-ownership.d.ts.map +1 -0
  200. package/dist/runtime/daemon/runtime-ownership.js +132 -0
  201. package/dist/runtime/daemon/runtime-ownership.js.map +1 -0
  202. package/dist/runtime/daemon/signals.d.ts +17 -0
  203. package/dist/runtime/daemon/signals.d.ts.map +1 -0
  204. package/dist/runtime/daemon/signals.js +31 -0
  205. package/dist/runtime/daemon/signals.js.map +1 -0
  206. package/dist/runtime/daemon/types.d.ts +8 -0
  207. package/dist/runtime/daemon/types.d.ts.map +1 -0
  208. package/dist/runtime/daemon/types.js +2 -0
  209. package/dist/runtime/daemon/types.js.map +1 -0
  210. package/dist/runtime/daemon-client.d.ts +1 -55
  211. package/dist/runtime/daemon-client.d.ts.map +1 -1
  212. package/dist/runtime/daemon-client.js +1 -297
  213. package/dist/runtime/daemon-client.js.map +1 -1
  214. package/dist/runtime/daemon-health.d.ts +1 -30
  215. package/dist/runtime/daemon-health.d.ts.map +1 -1
  216. package/dist/runtime/daemon-health.js +1 -112
  217. package/dist/runtime/daemon-health.js.map +1 -1
  218. package/dist/runtime/daemon-runner-lifecycle.d.ts +2 -0
  219. package/dist/runtime/daemon-runner-lifecycle.d.ts.map +1 -0
  220. package/dist/runtime/daemon-runner-lifecycle.js +2 -0
  221. package/dist/runtime/daemon-runner-lifecycle.js.map +1 -0
  222. package/dist/runtime/daemon-runner.d.ts +1 -231
  223. package/dist/runtime/daemon-runner.d.ts.map +1 -1
  224. package/dist/runtime/daemon-runner.js +1 -1042
  225. package/dist/runtime/daemon-runner.js.map +1 -1
  226. package/dist/runtime/daemon-runtime-ownership.d.ts +2 -0
  227. package/dist/runtime/daemon-runtime-ownership.d.ts.map +1 -0
  228. package/dist/runtime/daemon-runtime-ownership.js +2 -0
  229. package/dist/runtime/daemon-runtime-ownership.js.map +1 -0
  230. package/dist/runtime/daemon-signals.d.ts +1 -16
  231. package/dist/runtime/daemon-signals.d.ts.map +1 -1
  232. package/dist/runtime/daemon-signals.js +1 -30
  233. package/dist/runtime/daemon-signals.js.map +1 -1
  234. package/dist/runtime/event/dispatcher.d.ts +34 -0
  235. package/dist/runtime/event/dispatcher.d.ts.map +1 -0
  236. package/dist/runtime/event/dispatcher.js +124 -0
  237. package/dist/runtime/event/dispatcher.js.map +1 -0
  238. package/dist/runtime/event/index.d.ts +5 -0
  239. package/dist/runtime/event/index.d.ts.map +1 -0
  240. package/dist/runtime/event/index.js +5 -0
  241. package/dist/runtime/event/index.js.map +1 -0
  242. package/dist/runtime/event/server-snapshot-reader.d.ts +31 -0
  243. package/dist/runtime/event/server-snapshot-reader.d.ts.map +1 -0
  244. package/dist/runtime/event/server-snapshot-reader.js +94 -0
  245. package/dist/runtime/event/server-snapshot-reader.js.map +1 -0
  246. package/dist/runtime/event/server-sse.d.ts +25 -0
  247. package/dist/runtime/event/server-sse.d.ts.map +1 -0
  248. package/dist/runtime/event/server-sse.js +149 -0
  249. package/dist/runtime/event/server-sse.js.map +1 -0
  250. package/dist/runtime/event/server.d.ts +114 -0
  251. package/dist/runtime/event/server.d.ts.map +1 -0
  252. package/dist/runtime/event/server.js +651 -0
  253. package/dist/runtime/event/server.js.map +1 -0
  254. package/dist/runtime/event-dispatcher.d.ts +2 -0
  255. package/dist/runtime/event-dispatcher.d.ts.map +1 -0
  256. package/dist/runtime/event-dispatcher.js +2 -0
  257. package/dist/runtime/event-dispatcher.js.map +1 -0
  258. package/dist/runtime/event-server-snapshot-reader.d.ts +2 -0
  259. package/dist/runtime/event-server-snapshot-reader.d.ts.map +1 -0
  260. package/dist/runtime/event-server-snapshot-reader.js +2 -0
  261. package/dist/runtime/event-server-snapshot-reader.js.map +1 -0
  262. package/dist/runtime/event-server-sse.d.ts +2 -0
  263. package/dist/runtime/event-server-sse.d.ts.map +1 -0
  264. package/dist/runtime/event-server-sse.js +2 -0
  265. package/dist/runtime/event-server-sse.js.map +1 -0
  266. package/dist/runtime/event-server.d.ts +1 -91
  267. package/dist/runtime/event-server.d.ts.map +1 -1
  268. package/dist/runtime/event-server.js +1 -698
  269. package/dist/runtime/event-server.js.map +1 -1
  270. package/dist/runtime/executor/loop-supervisor.d.ts +9 -5
  271. package/dist/runtime/executor/loop-supervisor.d.ts.map +1 -1
  272. package/dist/runtime/executor/loop-supervisor.js +59 -76
  273. package/dist/runtime/executor/loop-supervisor.js.map +1 -1
  274. package/dist/runtime/gateway/http-channel-adapter.d.ts +1 -1
  275. package/dist/runtime/plugin-loader.d.ts +1 -1
  276. package/dist/runtime/queue/index.d.ts +0 -4
  277. package/dist/runtime/queue/index.d.ts.map +1 -1
  278. package/dist/runtime/queue/index.js +0 -2
  279. package/dist/runtime/queue/index.js.map +1 -1
  280. package/dist/runtime/queue/journal-backed-queue.d.ts.map +1 -1
  281. package/dist/runtime/queue/journal-backed-queue.js +2 -0
  282. package/dist/runtime/queue/journal-backed-queue.js.map +1 -1
  283. package/dist/runtime/schedule/engine-layers.d.ts +44 -0
  284. package/dist/runtime/schedule/engine-layers.d.ts.map +1 -0
  285. package/dist/runtime/schedule/engine-layers.js +433 -0
  286. package/dist/runtime/schedule/engine-layers.js.map +1 -0
  287. package/dist/runtime/schedule/engine.d.ts +82 -0
  288. package/dist/runtime/schedule/engine.d.ts.map +1 -0
  289. package/dist/runtime/schedule/engine.js +480 -0
  290. package/dist/runtime/schedule/engine.js.map +1 -0
  291. package/dist/runtime/schedule/index.d.ts +5 -0
  292. package/dist/runtime/schedule/index.d.ts.map +1 -0
  293. package/dist/runtime/schedule/index.js +5 -0
  294. package/dist/runtime/schedule/index.js.map +1 -0
  295. package/dist/runtime/schedule/presets.d.ts +536 -0
  296. package/dist/runtime/schedule/presets.d.ts.map +1 -0
  297. package/dist/runtime/schedule/presets.js +166 -0
  298. package/dist/runtime/schedule/presets.js.map +1 -0
  299. package/dist/runtime/schedule/source.d.ts +65 -0
  300. package/dist/runtime/schedule/source.d.ts.map +1 -0
  301. package/dist/runtime/schedule/source.js +16 -0
  302. package/dist/runtime/schedule/source.js.map +1 -0
  303. package/dist/runtime/schedule-engine-layers.d.ts +1 -43
  304. package/dist/runtime/schedule-engine-layers.d.ts.map +1 -1
  305. package/dist/runtime/schedule-engine-layers.js +1 -432
  306. package/dist/runtime/schedule-engine-layers.js.map +1 -1
  307. package/dist/runtime/schedule-engine.d.ts +1 -81
  308. package/dist/runtime/schedule-engine.d.ts.map +1 -1
  309. package/dist/runtime/schedule-engine.js +1 -479
  310. package/dist/runtime/schedule-engine.js.map +1 -1
  311. package/dist/runtime/schedule-presets.d.ts +1 -535
  312. package/dist/runtime/schedule-presets.d.ts.map +1 -1
  313. package/dist/runtime/schedule-presets.js +1 -165
  314. package/dist/runtime/schedule-presets.js.map +1 -1
  315. package/dist/runtime/schedule-source.d.ts +1 -64
  316. package/dist/runtime/schedule-source.d.ts.map +1 -1
  317. package/dist/runtime/schedule-source.js +1 -15
  318. package/dist/runtime/schedule-source.js.map +1 -1
  319. package/dist/runtime/types/daemon.d.ts.map +1 -1
  320. package/dist/runtime/types/daemon.js +2 -1
  321. package/dist/runtime/types/daemon.js.map +1 -1
  322. package/dist/runtime/watchdog.d.ts +44 -0
  323. package/dist/runtime/watchdog.d.ts.map +1 -0
  324. package/dist/runtime/watchdog.js +185 -0
  325. package/dist/runtime/watchdog.js.map +1 -0
  326. package/dist/tools/builtin/index.d.ts +1 -1
  327. package/dist/tools/schedule/CreateScheduleTool/CreateScheduleTool.d.ts +1 -1
  328. package/dist/tools/schedule/CreateScheduleTool/CreateScheduleTool.js +1 -1
  329. package/dist/tools/schedule/GetScheduleTool/GetScheduleTool.d.ts +1 -1
  330. package/dist/tools/schedule/ListSchedulesTool/ListSchedulesTool.d.ts +1 -1
  331. package/dist/tools/schedule/PauseScheduleTool/PauseScheduleTool.d.ts +1 -1
  332. package/dist/tools/schedule/RemoveScheduleTool/RemoveScheduleTool.d.ts +1 -1
  333. package/dist/tools/schedule/ResumeScheduleTool/ResumeScheduleTool.d.ts +1 -1
  334. package/dist/tools/schedule/UpdateScheduleTool/UpdateScheduleTool.d.ts +1 -1
  335. package/package.json +1 -1
@@ -9,7 +9,7 @@
9
9
  */
10
10
  import type { StateManager } from "../../base/state/state-manager.js";
11
11
  import type { TrustManager } from "../../platform/traits/trust-manager.js";
12
- import type { LoopIterationResult } from "./core-loop-types.js";
12
+ import type { LoopIterationResult } from "./core-loop/contracts.js";
13
13
  import type { Logger } from "../../runtime/logger.js";
14
14
  /**
15
15
  * Save a checkpoint after a successful verify step.
@@ -1 +1 @@
1
- {"version":3,"file":"checkpoint-manager-loop.d.ts","sourceRoot":"","sources":["../../../src/orchestrator/loop/checkpoint-manager-loop.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mCAAmC,CAAC;AACtE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,wCAAwC,CAAC;AAC3E,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAChE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AAEtD;;;;GAIG;AACH,wBAAsB,kBAAkB,CACtC,YAAY,EAAE,YAAY,EAC1B,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,MAAM,EACjB,eAAe,EAAE,mBAAmB,EACpC,WAAW,EAAE,MAAM,EACnB,YAAY,EAAE,YAAY,GAAG,SAAS,EACtC,MAAM,EAAE,MAAM,GAAG,SAAS,GACzB,OAAO,CAAC,IAAI,CAAC,CAoCf;AAED;;;;;;GAMG;AACH,wBAAsB,qBAAqB,CACzC,YAAY,EAAE,YAAY,EAC1B,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,MAAM,EACnB,YAAY,EAAE,YAAY,GAAG,SAAS,GACrC,OAAO,CAAC,MAAM,CAAC,CAEjB"}
1
+ {"version":3,"file":"checkpoint-manager-loop.d.ts","sourceRoot":"","sources":["../../../src/orchestrator/loop/checkpoint-manager-loop.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mCAAmC,CAAC;AACtE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,wCAAwC,CAAC;AAC3E,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AACpE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AAEtD;;;;GAIG;AACH,wBAAsB,kBAAkB,CACtC,YAAY,EAAE,YAAY,EAC1B,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,MAAM,EACjB,eAAe,EAAE,mBAAmB,EACpC,WAAW,EAAE,MAAM,EACnB,YAAY,EAAE,YAAY,GAAG,SAAS,EACtC,MAAM,EAAE,MAAM,GAAG,SAAS,GACzB,OAAO,CAAC,IAAI,CAAC,CAoCf;AAED;;;;;;GAMG;AACH,wBAAsB,qBAAqB,CACzC,YAAY,EAAE,YAAY,EAC1B,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,MAAM,EACnB,YAAY,EAAE,YAAY,GAAG,SAAS,GACrC,OAAO,CAAC,MAAM,CAAC,CAEjB"}
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Capability acquisition helpers used from the CoreLoop task cycle.
3
+ */
4
+ import type { Logger } from "../../../runtime/logger.js";
5
+ import type { IAdapter } from "../../execution/adapter-layer.js";
6
+ import type { CapabilityDetector } from "../../../platform/observation/capability-detector.js";
7
+ import type { CapabilityAcquisitionTask } from "../../../base/types/capability.js";
8
+ export interface CapabilityAcquisitionOutcome {
9
+ capabilityName: string;
10
+ replanRequired: boolean;
11
+ recommendationSource?: string;
12
+ recommendedPlugin?: string;
13
+ }
14
+ /** Handle the "capability_acquiring" action from TaskLifecycle.
15
+ * Delegates acquisition to an adapter, verifies the result, and registers
16
+ * the capability on success. Retries up to 3 times before escalating. */
17
+ export declare function handleCapabilityAcquisition(acquisitionTask: CapabilityAcquisitionTask, goalId: string, adapter: IAdapter, capabilityDetector: CapabilityDetector | undefined, capabilityAcquisitionFailures: Map<string, number>, logger: Logger | undefined): Promise<CapabilityAcquisitionOutcome>;
18
+ /** Records a capability acquisition failure and escalates after 3 consecutive failures. */
19
+ export declare function recordCapabilityFailure(capabilityDetector: CapabilityDetector, acquisitionTask: CapabilityAcquisitionTask, goalId: string, capabilityAcquisitionFailures: Map<string, number>, logger: Logger | undefined): Promise<void>;
20
+ /** Escalates a capability acquisition failure to the user and marks status as verification_failed. */
21
+ export declare function escalateCapability(capabilityDetector: CapabilityDetector, acquisitionTask: CapabilityAcquisitionTask, goalId: string, logger: Logger | undefined): Promise<void>;
22
+ //# sourceMappingURL=capability.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"capability.d.ts","sourceRoot":"","sources":["../../../../src/orchestrator/loop/core-loop/capability.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AACzD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,kCAAkC,CAAC;AACjE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,sDAAsD,CAAC;AAC/F,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,mCAAmC,CAAC;AAEnF,MAAM,WAAW,4BAA4B;IAC3C,cAAc,EAAE,MAAM,CAAC;IACvB,cAAc,EAAE,OAAO,CAAC;IACxB,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B;AAED;;yEAEyE;AACzE,wBAAsB,2BAA2B,CAC/C,eAAe,EAAE,yBAAyB,EAC1C,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,QAAQ,EACjB,kBAAkB,EAAE,kBAAkB,GAAG,SAAS,EAClD,6BAA6B,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,EAClD,MAAM,EAAE,MAAM,GAAG,SAAS,GACzB,OAAO,CAAC,4BAA4B,CAAC,CA+HvC;AAED,2FAA2F;AAC3F,wBAAsB,uBAAuB,CAC3C,kBAAkB,EAAE,kBAAkB,EACtC,eAAe,EAAE,yBAAyB,EAC1C,MAAM,EAAE,MAAM,EACd,6BAA6B,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,EAClD,MAAM,EAAE,MAAM,GAAG,SAAS,GACzB,OAAO,CAAC,IAAI,CAAC,CAUf;AAED,sGAAsG;AACtG,wBAAsB,kBAAkB,CACtC,kBAAkB,EAAE,kBAAkB,EACtC,eAAe,EAAE,yBAAyB,EAC1C,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,GAAG,SAAS,GACzB,OAAO,CAAC,IAAI,CAAC,CAcf"}
@@ -0,0 +1,151 @@
1
+ /**
2
+ * Capability acquisition helpers used from the CoreLoop task cycle.
3
+ */
4
+ /** Handle the "capability_acquiring" action from TaskLifecycle.
5
+ * Delegates acquisition to an adapter, verifies the result, and registers
6
+ * the capability on success. Retries up to 3 times before escalating. */
7
+ export async function handleCapabilityAcquisition(acquisitionTask, goalId, adapter, capabilityDetector, capabilityAcquisitionFailures, logger) {
8
+ const capName = acquisitionTask.gap.missing_capability.name;
9
+ const capType = acquisitionTask.gap.missing_capability.type;
10
+ if (!capabilityDetector) {
11
+ logger?.warn("CoreLoop: capability_acquiring action received but no capabilityDetector configured — skipping");
12
+ return { capabilityName: capName, replanRequired: false };
13
+ }
14
+ const recommendation = capabilityDetector.recommendAcquisition(acquisitionTask.gap)[0];
15
+ try {
16
+ await capabilityDetector.setCapabilityStatus(capName, capType, "requested");
17
+ }
18
+ catch {
19
+ // Non-fatal.
20
+ }
21
+ logger?.info("CoreLoop: handling capability acquisition", { capName, capType, method: acquisitionTask.method });
22
+ const recommendationBlock = recommendation
23
+ ? `\nRecommended acquisition path:\n` +
24
+ `- Plugin: ${recommendation.pluginName}\n` +
25
+ `- Install source: ${recommendation.installSource}\n` +
26
+ `- Verification hint: ${recommendation.verificationHint}\n`
27
+ : "";
28
+ const prompt = `Capability Acquisition Task\n` +
29
+ `Method: ${acquisitionTask.method}\n` +
30
+ `Description: ${acquisitionTask.task_description}\n` +
31
+ `Success criteria: ${acquisitionTask.success_criteria.join("; ")}\n\n` +
32
+ recommendationBlock +
33
+ `Instructions: Please acquire or set up the capability "${capName}" (${capType}). ` +
34
+ `Follow the method "${acquisitionTask.method}" and ensure the success criteria are met.`;
35
+ let agentResult;
36
+ try {
37
+ await capabilityDetector.setCapabilityStatus(capName, capType, "acquiring");
38
+ agentResult = await adapter.execute({ prompt, timeout_ms: 120000, adapter_type: adapter.adapterType });
39
+ }
40
+ catch (err) {
41
+ logger?.error("CoreLoop: adapter execution failed during capability acquisition", {
42
+ capName,
43
+ error: err instanceof Error ? err.message : String(err),
44
+ });
45
+ await recordCapabilityFailure(capabilityDetector, acquisitionTask, goalId, capabilityAcquisitionFailures, logger);
46
+ return {
47
+ capabilityName: capName,
48
+ replanRequired: false,
49
+ recommendationSource: recommendation?.installSource,
50
+ recommendedPlugin: recommendation?.pluginName,
51
+ };
52
+ }
53
+ const capability = {
54
+ id: capName.toLowerCase().replace(/\s+/g, "_"),
55
+ name: capName,
56
+ description: acquisitionTask.task_description,
57
+ type: capType,
58
+ status: "acquiring",
59
+ };
60
+ let verificationResult;
61
+ try {
62
+ verificationResult = await capabilityDetector.verifyAcquiredCapability(capability, acquisitionTask, agentResult);
63
+ }
64
+ catch (err) {
65
+ logger?.error("CoreLoop: capability verification threw an error", {
66
+ capName,
67
+ error: err instanceof Error ? err.message : String(err),
68
+ });
69
+ await recordCapabilityFailure(capabilityDetector, acquisitionTask, goalId, capabilityAcquisitionFailures, logger);
70
+ return {
71
+ capabilityName: capName,
72
+ replanRequired: false,
73
+ recommendationSource: recommendation?.installSource,
74
+ recommendedPlugin: recommendation?.pluginName,
75
+ };
76
+ }
77
+ if (verificationResult === "pass") {
78
+ capabilityAcquisitionFailures.delete(capName);
79
+ try {
80
+ await capabilityDetector.registerCapability(capability, {
81
+ goal_id: goalId,
82
+ originating_task_id: acquisitionTask.gap.related_task_id,
83
+ acquired_at: new Date().toISOString(),
84
+ });
85
+ await capabilityDetector.setCapabilityStatus(capName, capType, "available");
86
+ logger?.info("CoreLoop: capability acquired and registered successfully", {
87
+ capName,
88
+ replanRequired: true,
89
+ recommendedPlugin: recommendation?.pluginName,
90
+ });
91
+ return {
92
+ capabilityName: capName,
93
+ replanRequired: true,
94
+ recommendationSource: recommendation?.installSource,
95
+ recommendedPlugin: recommendation?.pluginName,
96
+ };
97
+ }
98
+ catch (err) {
99
+ logger?.error("CoreLoop: failed to register capability after verification pass", {
100
+ capName,
101
+ error: err instanceof Error ? err.message : String(err),
102
+ });
103
+ return {
104
+ capabilityName: capName,
105
+ replanRequired: false,
106
+ recommendationSource: recommendation?.installSource,
107
+ recommendedPlugin: recommendation?.pluginName,
108
+ };
109
+ }
110
+ }
111
+ else if (verificationResult === "escalate") {
112
+ capabilityAcquisitionFailures.delete(capName);
113
+ await escalateCapability(capabilityDetector, acquisitionTask, goalId, logger);
114
+ }
115
+ else {
116
+ await recordCapabilityFailure(capabilityDetector, acquisitionTask, goalId, capabilityAcquisitionFailures, logger);
117
+ }
118
+ return {
119
+ capabilityName: capName,
120
+ replanRequired: false,
121
+ recommendationSource: recommendation?.installSource,
122
+ recommendedPlugin: recommendation?.pluginName,
123
+ };
124
+ }
125
+ /** Records a capability acquisition failure and escalates after 3 consecutive failures. */
126
+ export async function recordCapabilityFailure(capabilityDetector, acquisitionTask, goalId, capabilityAcquisitionFailures, logger) {
127
+ const capName = acquisitionTask.gap.missing_capability.name;
128
+ const currentCount = (capabilityAcquisitionFailures.get(capName) ?? 0) + 1;
129
+ capabilityAcquisitionFailures.set(capName, currentCount);
130
+ logger?.warn("CoreLoop: capability acquisition failed", { capName, failureCount: currentCount });
131
+ if (currentCount >= 3) {
132
+ await escalateCapability(capabilityDetector, acquisitionTask, goalId, logger);
133
+ }
134
+ }
135
+ /** Escalates a capability acquisition failure to the user and marks status as verification_failed. */
136
+ export async function escalateCapability(capabilityDetector, acquisitionTask, goalId, logger) {
137
+ const capName = acquisitionTask.gap.missing_capability.name;
138
+ const capType = acquisitionTask.gap.missing_capability.type;
139
+ logger?.warn("CoreLoop: escalating capability acquisition to user", { capName });
140
+ try {
141
+ await capabilityDetector.escalateToUser(acquisitionTask.gap, goalId);
142
+ await capabilityDetector.setCapabilityStatus(capName, capType, "verification_failed");
143
+ }
144
+ catch (err) {
145
+ logger?.error("CoreLoop: escalation failed", {
146
+ capName,
147
+ error: err instanceof Error ? err.message : String(err),
148
+ });
149
+ }
150
+ }
151
+ //# sourceMappingURL=capability.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"capability.js","sourceRoot":"","sources":["../../../../src/orchestrator/loop/core-loop/capability.ts"],"names":[],"mappings":"AAAA;;GAEG;AAcH;;yEAEyE;AACzE,MAAM,CAAC,KAAK,UAAU,2BAA2B,CAC/C,eAA0C,EAC1C,MAAc,EACd,OAAiB,EACjB,kBAAkD,EAClD,6BAAkD,EAClD,MAA0B;IAE1B,MAAM,OAAO,GAAG,eAAe,CAAC,GAAG,CAAC,kBAAkB,CAAC,IAAI,CAAC;IAC5D,MAAM,OAAO,GAAG,eAAe,CAAC,GAAG,CAAC,kBAAkB,CAAC,IAAI,CAAC;IAE5D,IAAI,CAAC,kBAAkB,EAAE,CAAC;QACxB,MAAM,EAAE,IAAI,CAAC,gGAAgG,CAAC,CAAC;QAC/G,OAA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OAAO,GAAG,eAAe,CAAC,GAAG,CAAC,kBAAkB,CAAC,IAAI,CAAC;IAE5D,MAAM,EAAE,IAAI,CAAC,qDAAqD,EAAE,EAAE,OAAO,EAAE,CAAC,CAAC;IACjF,IAAI,CAAC;QACH,MAAM,kBAAkB,CAAC,cAAc,CAAC,eAAe,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;QACrE,MAAM,kBAAkB,CAAC,mBAAmB,CAAC,OAAO,EAAE,OAAO,EAAE,qBAAqB,CAAC,CAAC;IACxF,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,MAAM,EAAE,KAAK,CAAC,6BAA6B,EAAE;YAC3C,OAAO;YACP,KAAK,EAAE,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC;SACxD,CAAC,CAAC;IACL,CAAC;AACH,CAAC"}
@@ -0,0 +1,245 @@
1
+ import type { CuriosityEngine } from "../../../platform/traits/curiosity-engine.js";
2
+ import type { IterationBudget } from "../iteration-budget.js";
3
+ import type { Logger } from "../../../runtime/logger.js";
4
+ import type { StrategyTemplateRegistry } from "../../strategy/strategy-template-registry.js";
5
+ import type { TrustManager } from "../../../platform/traits/trust-manager.js";
6
+ import type { KnowledgeTransfer } from "../../../platform/knowledge/transfer/knowledge-transfer.js";
7
+ import type { CrossGoalPortfolio } from "../../strategy/cross-goal-portfolio.js";
8
+ import type { GoalTreeManager } from "../../goal/goal-tree-manager.js";
9
+ import type { StateAggregator } from "../../goal/state-aggregator.js";
10
+ import type { TreeLoopOrchestrator } from "../../goal/tree-loop-orchestrator.js";
11
+ import type { StateManager } from "../../../base/state/state-manager.js";
12
+ import type { ObservationEngine } from "../../../platform/observation/observation-engine.js";
13
+ import type { TaskLifecycle } from "../../execution/task/task-lifecycle.js";
14
+ import type { SatisficingJudge } from "../../../platform/drive/satisficing-judge.js";
15
+ import type { StallDetector } from "../../../platform/drive/stall-detector.js";
16
+ import type { StrategyManager } from "../../strategy/strategy-manager.js";
17
+ import type { DriveSystem } from "../../../platform/drive/drive-system.js";
18
+ import type { AdapterRegistry } from "../../execution/adapter-layer.js";
19
+ import type { KnowledgeManager } from "../../../platform/knowledge/knowledge-manager.js";
20
+ import type { CapabilityDetector } from "../../../platform/observation/capability-detector.js";
21
+ import type { PortfolioManager } from "../../strategy/portfolio-manager.js";
22
+ import type { GoalDependencyGraph } from "../../goal/goal-dependency-graph.js";
23
+ import type { LearningPipeline } from "../../../platform/knowledge/learning/learning-pipeline.js";
24
+ import type { DriveScoreAdapter, MemoryLifecycleManager } from "../../../platform/knowledge/memory/memory-lifecycle.js";
25
+ import type { ParallelExecutor } from "../../execution/parallel-executor.js";
26
+ import type { GoalRefiner } from "../../goal/goal-refiner.js";
27
+ import type { Goal } from "../../../base/types/goal.js";
28
+ import type { GapVector } from "../../../base/types/gap.js";
29
+ import type { DriveContext, DriveScore } from "../../../base/types/drive.js";
30
+ import type { ToolExecutor } from "../../../tools/executor.js";
31
+ import type { ToolRegistry } from "../../../tools/registry.js";
32
+ export type { LoopIterationResult, LoopResult, } from "../loop-result-types.js";
33
+ export { makeEmptyIterationResult } from "../loop-result-types.js";
34
+ export interface GapCalculatorModule {
35
+ calculateGapVector: (goalId: string, dimensions: Goal["dimensions"], globalUncertaintyWeight?: number) => GapVector;
36
+ aggregateGaps: (childGaps: number[], method?: "max" | "weighted_avg" | "sum", weights?: number[]) => number;
37
+ }
38
+ export interface DriveScorerModule {
39
+ scoreAllDimensions: (gapVector: GapVector, context: DriveContext, config?: unknown) => DriveScore[];
40
+ rankDimensions: (scores: DriveScore[]) => DriveScore[];
41
+ }
42
+ export interface ExecutionSummaryParams {
43
+ goalId: string;
44
+ loopIndex: number;
45
+ observation: {
46
+ dimensionName: string;
47
+ progress: number;
48
+ confidence: number;
49
+ }[];
50
+ gapAggregate: number;
51
+ taskResult: {
52
+ taskId: string;
53
+ action: string;
54
+ dimension: string;
55
+ } | null;
56
+ stallDetected: boolean;
57
+ pivotOccurred: boolean;
58
+ elapsedMs: number;
59
+ }
60
+ export interface ReportingEngine {
61
+ generateExecutionSummary(params: ExecutionSummaryParams): unknown;
62
+ saveReport(report: unknown): void;
63
+ }
64
+ /**
65
+ * LoopConfig with all required fields resolved (except iterationBudget which remains optional).
66
+ * Used as the internal config type throughout CoreLoop and its sub-modules.
67
+ */
68
+ export type ResolvedLoopConfig = Required<Omit<LoopConfig, "iterationBudget">> & Pick<LoopConfig, "iterationBudget">;
69
+ export interface LoopConfig {
70
+ maxIterations?: number;
71
+ maxConsecutiveErrors?: number;
72
+ delayBetweenLoopsMs?: number;
73
+ adapterType?: string;
74
+ treeMode?: boolean;
75
+ multiGoalMode?: boolean;
76
+ goalIds?: string[];
77
+ /**
78
+ * Minimum number of iterations to run before the loop can exit on completion.
79
+ * Default: 1 (at least one full task cycle always runs before declaring complete).
80
+ * Setting to 2 forces two full iterations even if the goal is already satisfied after iteration 1.
81
+ */
82
+ minIterations?: number;
83
+ /**
84
+ * Whether to automatically archive a completed goal at the end of run().
85
+ * Default: false — archiving is an irreversible action and should be triggered explicitly
86
+ * (e.g. via `pulseed goal archive <id>` CLI command or by setting this flag intentionally).
87
+ */
88
+ autoArchive?: boolean;
89
+ /**
90
+ * When true, suppress loop-level persistence side effects: checkpoint writes,
91
+ * final goal status updates, and archive operations.
92
+ */
93
+ dryRun?: boolean;
94
+ /**
95
+ * Maximum number of consecutive iterations that can be skipped due to no state change
96
+ * (Pillar 2: State Diff + Loop Skip). After this many consecutive skips, the full loop
97
+ * runs regardless so stall detection can fire. Default: 5.
98
+ */
99
+ maxConsecutiveSkips?: number;
100
+ /**
101
+ * When true (default), automatically decompose an abstract goal into sub-goals
102
+ * using TreeLoopOrchestrator.ensureGoalRefined() before the first iteration.
103
+ * Set to false to disable auto-decomposition.
104
+ */
105
+ autoDecompose?: boolean;
106
+ /**
107
+ * Shared iteration budget for parent-child agent trees.
108
+ * When set, all iterations (including child node iterations in tree mode) consume
109
+ * from this budget. Prevents runaway recursion across hierarchical agent invocations.
110
+ * If not set, maxIterations acts as the sole upper bound.
111
+ */
112
+ iterationBudget?: IterationBudget;
113
+ /**
114
+ * When true (default), automatically consolidate agent memory when a goal completes
115
+ * and raw entry count exceeds consolidationRawThreshold.
116
+ */
117
+ autoConsolidateOnComplete?: boolean;
118
+ /**
119
+ * Minimum number of raw agent memory entries required to trigger auto-consolidation.
120
+ * Default: 20.
121
+ */
122
+ consolidationRawThreshold?: number;
123
+ }
124
+ /** Deps needed for observation phase */
125
+ export interface ObservationDeps {
126
+ observationEngine: ObservationEngine;
127
+ stateManager: StateManager;
128
+ }
129
+ /** Deps needed for tree iteration */
130
+ export interface TreeDeps {
131
+ stateManager: StateManager;
132
+ treeLoopOrchestrator?: TreeLoopOrchestrator;
133
+ satisficingJudge: SatisficingJudge;
134
+ goalRefiner?: GoalRefiner;
135
+ goalTreeManager?: GoalTreeManager;
136
+ stateAggregator?: StateAggregator;
137
+ }
138
+ /** Deps needed for stall detection and recovery */
139
+ export interface StallDeps {
140
+ stallDetector: StallDetector;
141
+ strategyManager: StrategyManager;
142
+ knowledgeManager?: KnowledgeManager;
143
+ learningPipeline?: LearningPipeline;
144
+ goalRefiner?: GoalRefiner;
145
+ }
146
+ /** Deps needed for task execution cycle */
147
+ export interface TaskCycleDeps {
148
+ taskLifecycle: TaskLifecycle;
149
+ adapterRegistry: AdapterRegistry;
150
+ portfolioManager?: PortfolioManager;
151
+ knowledgeManager?: KnowledgeManager;
152
+ contextProvider?: (goalId: string, dimensionName: string) => Promise<string>;
153
+ }
154
+ export interface CoreLoopDeps extends ObservationDeps, TreeDeps, StallDeps, TaskCycleDeps {
155
+ gapCalculator: GapCalculatorModule;
156
+ driveScorer: DriveScorerModule;
157
+ reportingEngine: ReportingEngine;
158
+ driveSystem: DriveSystem;
159
+ capabilityDetector?: CapabilityDetector;
160
+ curiosityEngine?: CuriosityEngine;
161
+ goalDependencyGraph?: GoalDependencyGraph;
162
+ crossGoalPortfolio?: CrossGoalPortfolio;
163
+ knowledgeTransfer?: KnowledgeTransfer;
164
+ memoryLifecycleManager?: MemoryLifecycleManager;
165
+ /**
166
+ * Optional adapter that bridges DriveScorer output to MemoryLifecycleManager.
167
+ * When provided, CoreLoop calls adapter.update(driveScores) after each drive
168
+ * scoring step so MemoryLifecycleManager can use live dissatisfaction values
169
+ * for compression delay and relevance scoring.
170
+ *
171
+ * Typical setup (in CLIRunner):
172
+ * const adapter = new DriveScoreAdapter();
173
+ * const mlm = new MemoryLifecycleManager(baseDir, llm, config, emb, vec, adapter);
174
+ * const loop = new CoreLoop({ ..., memoryLifecycleManager: mlm, driveScoreAdapter: adapter });
175
+ */
176
+ driveScoreAdapter?: DriveScoreAdapter;
177
+ /**
178
+ * Optional TrustManager for including per-adapter trust balance in reward logs.
179
+ * When provided, CoreLoop reads the balance for the configured adapterType and
180
+ * includes it in logRewardComputation calls (PULSEED_REWARD_LOG=1).
181
+ */
182
+ trustManager?: TrustManager;
183
+ /**
184
+ * Optional ParallelExecutor for TaskGroup execution (M15 Phase 2).
185
+ * When provided, tasks evaluated as "large" complexity will be decomposed
186
+ * into a TaskGroup and executed in parallel waves.
187
+ * If not provided, all tasks fall through to the normal single-task flow.
188
+ */
189
+ parallelExecutor?: ParallelExecutor;
190
+ /**
191
+ * Optional factory function to generate a TaskGroup for a large task.
192
+ * Provided as a callback so the caller owns the llmClient dependency.
193
+ * If not provided (or returns null), the normal single-task flow is used.
194
+ */
195
+ generateTaskGroupFn?: (context: {
196
+ goalDescription: string;
197
+ targetDimension: string;
198
+ currentState: string;
199
+ gap: number;
200
+ availableAdapters: string[];
201
+ contextBlock?: string;
202
+ }) => Promise<import("../../../base/types/index.js").TaskGroup | null>;
203
+ logger?: Logger;
204
+ /**
205
+ * Optional progress callback. Called at key phases during each iteration so
206
+ * callers (e.g. CLIRunner) can print user-friendly progress lines.
207
+ */
208
+ onProgress?: (event: ProgressEvent) => void;
209
+ /**
210
+ * Optional StrategyTemplateRegistry. When provided, CoreLoop wires it into
211
+ * StrategyManager so that strategies completing with effectiveness_score >= 0.5
212
+ * are automatically registered as reusable templates.
213
+ */
214
+ strategyTemplateRegistry?: StrategyTemplateRegistry;
215
+ /** Optional HookManager for lifecycle hook events. */
216
+ hookManager?: import("../../../runtime/hook-manager.js").HookManager;
217
+ /** Optional ToolExecutor for direct tool-based operations (observation, verification, knowledge). */
218
+ toolExecutor?: ToolExecutor;
219
+ /** Optional ToolRegistry for context-aware tool assembly. */
220
+ toolRegistry?: ToolRegistry;
221
+ }
222
+ export type ProgressPhase = "Observing..." | "Generating task..." | "Executing task..." | "Verifying result..." | "Skipped" | "Skipped (no state change)";
223
+ export interface ProgressEvent {
224
+ /** 1-based iteration number */
225
+ iteration: number;
226
+ /** Maximum iterations configured */
227
+ maxIterations: number;
228
+ /** Current phase label */
229
+ phase: ProgressPhase;
230
+ /** Gap aggregate from latest gap calculation (undefined before first gap calc) */
231
+ gap?: number;
232
+ /** Average confidence across gap dimensions (undefined before first gap calc) */
233
+ confidence?: number;
234
+ /** Short description of the task being executed (undefined outside execute phase) */
235
+ taskDescription?: string;
236
+ /** Reason this iteration was skipped (undefined when not skipped) */
237
+ skipReason?: string;
238
+ }
239
+ /**
240
+ * Build DriveContext from goal state.
241
+ * For each dimension, compute hours since last update.
242
+ * Deadline comes from goal.deadline if set.
243
+ */
244
+ export declare function buildDriveContext(goal: Goal): DriveContext;
245
+ //# sourceMappingURL=contracts.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"contracts.d.ts","sourceRoot":"","sources":["../../../../src/orchestrator/loop/core-loop/contracts.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,8CAA8C,CAAC;AACpF,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AACzD,OAAO,KAAK,EAAE,wBAAwB,EAAE,MA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AE,MAAM,CAAC;IACtB,0BAA0B;IAC1B,KAAK,EAAE,aAAa,CAAC;IACrB,kFAAkF;IAClF,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,iFAAiF;IACjF,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,qFAAqF;IACrF,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,qEAAqE;IACrE,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAID;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,IAAI,GAAG,YAAY,CAiC1D"}
@@ -0,0 +1,40 @@
1
+ export { makeEmptyIterationResult } from "../loop-result-types.js";
2
+ // ─── Helpers ───
3
+ /**
4
+ * Build DriveContext from goal state.
5
+ * For each dimension, compute hours since last update.
6
+ * Deadline comes from goal.deadline if set.
7
+ */
8
+ export function buildDriveContext(goal) {
9
+ const timeSinceLastAttempt = {};
10
+ const deadlines = {};
11
+ const opportunities = {};
12
+ const now = Date.now();
13
+ const deadlineTime = goal.deadline ? new Date(goal.deadline).getTime() : null;
14
+ for (const dim of goal.dimensions) {
15
+ // Calculate hours since last update
16
+ if (dim.last_updated) {
17
+ const lastUpdated = new Date(dim.last_updated).getTime();
18
+ timeSinceLastAttempt[dim.name] = (now - lastUpdated) / (1000 * 60 * 60);
19
+ }
20
+ else {
21
+ // No previous attempt — use a large number to indicate high staleness
22
+ timeSinceLastAttempt[dim.name] = 168; // 1 week default
23
+ }
24
+ // Deadline: compute hours remaining from goal.deadline
25
+ if (deadlineTime !== null) {
26
+ const hoursRemaining = (deadlineTime - now) / (1000 * 60 * 60);
27
+ deadlines[dim.name] = hoursRemaining;
28
+ }
29
+ else {
30
+ deadlines[dim.name] = null;
31
+ }
32
+ }
33
+ return {
34
+ time_since_last_attempt: timeSinceLastAttempt,
35
+ deadlines,
36
+ opportunities,
37
+ pacing: {},
38
+ };
39
+ }
40
+ //# sourceMappingURL=contracts.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"contracts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C;YACN,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;QAC7B,CAAC;IACH,CAAC;IAED,OAAO;QACL,uBAAuB,EAAE,oBAAoB;QAC7C,SAAS;QACT,aAAa;QACb,MAAM,EAAE,EAAE;KACX,CAAC;AACJ,CAAC"}
@@ -0,0 +1,27 @@
1
+ import type { Logger } from "../../../runtime/logger.js";
2
+ import type { StateDiffCalculator, IterationSnapshot } from "../state-diff.js";
3
+ import type { ResolvedLoopConfig, LoopIterationResult, CoreLoopDeps } from "./contracts.js";
4
+ import type { Goal } from "../../../base/types/goal.js";
5
+ export interface StateDiffState {
6
+ previousSnapshot: IterationSnapshot | null;
7
+ consecutiveSkips: number;
8
+ }
9
+ /**
10
+ * Runs the state diff check for a loop iteration.
11
+ *
12
+ * Returns an object indicating whether to skip the rest of the iteration.
13
+ * When `shouldSkip` is true, `result` has been fully populated with skip info
14
+ * and the caller should return it immediately.
15
+ * When `shouldSkip` is false, the loop should continue normally.
16
+ */
17
+ export declare function runStateDiffCheck(stateDiff: StateDiffCalculator, stateDiffStateMap: Map<string, StateDiffState>, goalId: string, goal: Goal, loopIndex: number, config: ResolvedLoopConfig, deps: CoreLoopDeps, result: LoopIterationResult, startTime: number, logger?: Logger): Promise<{
18
+ shouldSkip: boolean;
19
+ }>;
20
+ /**
21
+ * Attempts to run the iteration in parallel (TaskGroup mode).
22
+ *
23
+ * Returns `true` if the parallel path was taken (caller should return result),
24
+ * `false` if parallel was skipped/unavailable (fall through to normal task cycle).
25
+ */
26
+ export declare function tryParallelExecution(goalId: string, goal: Goal, gapAggregate: number, result: LoopIterationResult, startTime: number, deps: CoreLoopDeps, loopIndex: number, logger?: Logger): Promise<boolean>;
27
+ //# sourceMappingURL=control.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"control.d.ts","sourceRoot":"","sources":["../../../../src/orchestrator/loop/core-loop/control.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AACzD,OAAO,KAAK,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAG/E,OAAO,KAAK,EACV,kBAAkB,EAClB,mBAAmB,EACnB,YAAY,EACb,MAAM,gBAAgB,CAAC;AACxB,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,6BAA6B,CAAC;AAIxD,MAAM,WAAW,cAAc;IAC7B,gBAAgB,EAAE,iBAAiB,GAAG,IAAI,CAAC;IAC3C,gBAAgB,EAAE,MAAM,CAAC;CAC1B;AAED;;;;;;;GAOG;AACH,wBAAsB,iBAAiB,CACrC,SAAS,EAAE,mBAAmB,EAC9B,iBAAiB,EAAE,GAAG,CAAC,MAAM,EAAE,cAAc,CAAC,EAC9C,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,IAAI,EACV,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,kBAAkB,EAC1B,IAAI,EAAE,YAAY,EAClB,MAAM,EAAE,mBAAmB,EAC3B,SAAS,EAAE,MAAM,EACjB,MAAM,CAAC,EAAE,MAAM,GACd,OAAO,CAAC;IAAE,UAAU,EAAE,OAAO,CAAA;CAAE,CAAC,CAgDlC;AAID;;;;;GAKG;AACH,wBAAsB,oBAAoB,CACxC,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,IAAI,EACV,YAAY,EAAE,MAAM,EACpB,MAAM,EAAE,mBAAmB,EAC3B,SAAS,EAAE,MAAM,EACjB,IAAI,EAAE,YAAY,EAClB,SAAS,EAAE,MAAM,EACjB,MAAM,CAAC,EAAE,MAAM,GACd,OAAO,CAAC,OAAO,CAAC,CAclB"}
@@ -0,0 +1,72 @@
1
+ import { tryRunParallel } from "../parallel-dispatch.js";
2
+ import { generateLoopReport } from "../loop-report-helper.js";
3
+ /**
4
+ * Runs the state diff check for a loop iteration.
5
+ *
6
+ * Returns an object indicating whether to skip the rest of the iteration.
7
+ * When `shouldSkip` is true, `result` has been fully populated with skip info
8
+ * and the caller should return it immediately.
9
+ * When `shouldSkip` is false, the loop should continue normally.
10
+ */
11
+ export async function runStateDiffCheck(stateDiff, stateDiffStateMap, goalId, goal, loopIndex, config, deps, result, startTime, logger) {
12
+ const diffState = stateDiffStateMap.get(goalId) ?? { previousSnapshot: null, consecutiveSkips: 0 };
13
+ const snapshot = stateDiff.buildSnapshot(goal, loopIndex);
14
+ const diff = stateDiff.compare(diffState.previousSnapshot, snapshot);
15
+ diffState.previousSnapshot = snapshot;
16
+ if (!diff.hasChange && diffState.consecutiveSkips < config.maxConsecutiveSkips) {
17
+ diffState.consecutiveSkips++;
18
+ stateDiffStateMap.set(goalId, diffState);
19
+ logger?.info(`[CoreLoop] iteration ${loopIndex} skipped: no state change detected ` +
20
+ `(consecutiveSkips=${diffState.consecutiveSkips}/${config.maxConsecutiveSkips})`, { goalId });
21
+ result.skipped = true;
22
+ result.skipReason = "no_state_change";
23
+ deps.onProgress?.({
24
+ iteration: loopIndex + 1,
25
+ maxIterations: config.maxIterations,
26
+ phase: "Skipped",
27
+ skipReason: result.skipReason,
28
+ });
29
+ // Carry forward completion status from the already-loaded goal so a
30
+ // completed goal is not forced through 5 more iterations.
31
+ const goalState = await deps.stateManager.loadGoal(goalId);
32
+ if (goalState?.status === "completed") {
33
+ result.completionJudgment.is_complete = true;
34
+ }
35
+ deps.onProgress?.({
36
+ iteration: loopIndex + 1,
37
+ maxIterations: config.maxIterations,
38
+ phase: "Skipped (no state change)",
39
+ });
40
+ result.elapsedMs = Date.now() - startTime;
41
+ return { shouldSkip: true };
42
+ }
43
+ // Reset skip counter — full loop is running
44
+ diffState.consecutiveSkips = 0;
45
+ stateDiffStateMap.set(goalId, diffState);
46
+ if (!diff.hasChange) {
47
+ logger?.info(`[CoreLoop] max consecutive skips reached (${config.maxConsecutiveSkips}), ` +
48
+ "forcing full iteration for stall detection", { goalId });
49
+ }
50
+ return { shouldSkip: false };
51
+ }
52
+ // ─── Parallel execution check ───
53
+ /**
54
+ * Attempts to run the iteration in parallel (TaskGroup mode).
55
+ *
56
+ * Returns `true` if the parallel path was taken (caller should return result),
57
+ * `false` if parallel was skipped/unavailable (fall through to normal task cycle).
58
+ */
59
+ export async function tryParallelExecution(goalId, goal, gapAggregate, result, startTime, deps, loopIndex, logger) {
60
+ if (!deps.parallelExecutor || !deps.generateTaskGroupFn) {
61
+ return false;
62
+ }
63
+ const parallelResult = await tryRunParallel(goalId, goal, gapAggregate, result, startTime, deps, logger);
64
+ if (parallelResult !== null) {
65
+ // Parallel path completed — skip normal task cycle
66
+ await generateLoopReport(goalId, loopIndex, result, goal, deps.reportingEngine, logger);
67
+ result.elapsedMs = Date.now() - startTime;
68
+ return true;
69
+ }
70
+ return false;
71
+ }
72
+ //# sourceMappingURL=control.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"control.js","sourceRoot":"","sources":["../../../../src/orchestrator/loop/core-loop/control.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AACzD,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAe9D;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,iBAAiB,CACrC,SAA8B,EAC9B,iBAA8C,EAC9C,MAAc,EACd,IAAU,EACV,SAAiB,EACjB,MAA0B,EAC1B,IAAkB,EAClB,MAA2B,EAC3B,SAAiB,EACjB,MAAe;IAEf,MAAM,SAAS,GAAG,iBAAiB,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,EAAE,gBAAgB,EAAE,IAAI,EAAE,gBAAgB,EAAE,CAAC,EAAE,CAAC;IACnG,MAAM,QAAQ,GAAG,SAAS,CAAC,aAAa,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;IAC1D,MAAM,IAAI,GAAG,SAAS,CAAC,OAAO,CAAC,SAAS,CAAC,gBAAgB,EAAE,QAAQ,CAAC,CAAC;IACrE,SAAS,CAAC,gBAAgB,GAAG,QAAQ,CAAC;IAEtC,IAAI,CAAC,I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