@hoknie/aip 0.1.0 → 0.2.1

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 (587) hide show
  1. package/dist/app/agents.js +2 -0
  2. package/dist/app/agents.js.map +1 -1
  3. package/dist/app/application.js +41 -3
  4. package/dist/app/application.js.map +1 -1
  5. package/dist/app/lifecycle.js +5 -1
  6. package/dist/app/lifecycle.js.map +1 -1
  7. package/dist/app/timings.js +1 -0
  8. package/dist/app/timings.js.map +1 -1
  9. package/dist/app/wiring.js +1 -0
  10. package/dist/app/wiring.js.map +1 -1
  11. package/dist/cli/main.js +0 -0
  12. package/dist/feature/agents/clients/agy/guard.js +26 -8
  13. package/dist/feature/agents/clients/agy/guard.js.map +1 -1
  14. package/dist/feature/agents/clients/agy/permissions.js +9 -1
  15. package/dist/feature/agents/clients/agy/permissions.js.map +1 -1
  16. package/dist/feature/agents/clients/agy/runtime.js +8 -1
  17. package/dist/feature/agents/clients/agy/runtime.js.map +1 -1
  18. package/dist/feature/agents/clients/claude/index.js +1 -0
  19. package/dist/feature/agents/clients/claude/index.js.map +1 -1
  20. package/dist/feature/agents/clients/claude/models.js +8 -0
  21. package/dist/feature/agents/clients/claude/models.js.map +1 -0
  22. package/dist/feature/agents/clients/claude/parser.js +8 -0
  23. package/dist/feature/agents/clients/claude/parser.js.map +1 -1
  24. package/dist/feature/agents/clients/claude/runtime.js +2 -0
  25. package/dist/feature/agents/clients/claude/runtime.js.map +1 -1
  26. package/dist/feature/agents/clients/opencode/index.js +1 -0
  27. package/dist/feature/agents/clients/opencode/index.js.map +1 -1
  28. package/dist/feature/agents/clients/opencode/models.js +38 -0
  29. package/dist/feature/agents/clients/opencode/models.js.map +1 -0
  30. package/dist/feature/agents/clients/opencode/runtime.js +14 -1
  31. package/dist/feature/agents/clients/opencode/runtime.js.map +1 -1
  32. package/dist/feature/agents/ports/command.js +2 -0
  33. package/dist/feature/agents/ports/command.js.map +1 -0
  34. package/dist/feature/agents/services/agents.js +42 -1
  35. package/dist/feature/agents/services/agents.js.map +1 -1
  36. package/dist/feature/agents/services/catalog.js +1 -1
  37. package/dist/feature/agents/services/catalog.js.map +1 -1
  38. package/dist/feature/agents/types/index.js +2 -0
  39. package/dist/feature/agents/types/index.js.map +1 -1
  40. package/dist/feature/agents/types/mcp/env.js +54 -0
  41. package/dist/feature/agents/types/mcp/env.js.map +1 -0
  42. package/dist/feature/agents/types/message.js +1 -0
  43. package/dist/feature/agents/types/message.js.map +1 -1
  44. package/dist/feature/agents/types/models.js +2 -0
  45. package/dist/feature/agents/types/models.js.map +1 -0
  46. package/dist/feature/agents/types/runtime.js.map +1 -1
  47. package/dist/feature/agents/types/worker-tools.js +2 -0
  48. package/dist/feature/agents/types/worker-tools.js.map +1 -1
  49. package/dist/feature/network/ports/changed.js +2 -0
  50. package/dist/feature/network/ports/changed.js.map +1 -0
  51. package/dist/feature/network/ports/index.js +2 -0
  52. package/dist/feature/network/ports/index.js.map +1 -0
  53. package/dist/feature/network/services/create.js +5 -0
  54. package/dist/feature/network/services/create.js.map +1 -0
  55. package/dist/feature/network/services/index.js +3 -0
  56. package/dist/feature/network/services/index.js.map +1 -0
  57. package/dist/feature/network/services/monitor.js +140 -0
  58. package/dist/feature/network/services/monitor.js.map +1 -0
  59. package/dist/feature/network/types/index.js +4 -0
  60. package/dist/feature/network/types/index.js.map +1 -0
  61. package/dist/feature/network/types/network.js +8 -0
  62. package/dist/feature/network/types/network.js.map +1 -0
  63. package/dist/feature/network/types/proxy.js +95 -0
  64. package/dist/feature/network/types/proxy.js.map +1 -0
  65. package/dist/feature/network/types/state.js +36 -0
  66. package/dist/feature/network/types/state.js.map +1 -0
  67. package/dist/feature/observers/repositories/observers.js +7 -1
  68. package/dist/feature/observers/repositories/observers.js.map +1 -1
  69. package/dist/feature/observers/services/observers.js +33 -5
  70. package/dist/feature/observers/services/observers.js.map +1 -1
  71. package/dist/feature/observers/services/settings-check.js +1 -7
  72. package/dist/feature/observers/services/settings-check.js.map +1 -1
  73. package/dist/feature/observers/types/plan-repairs.js +48 -16
  74. package/dist/feature/observers/types/plan-repairs.js.map +1 -1
  75. package/dist/feature/observers/types/settings.js +0 -1
  76. package/dist/feature/observers/types/settings.js.map +1 -1
  77. package/dist/feature/queue/repositories/queues.js +28 -4
  78. package/dist/feature/queue/repositories/queues.js.map +1 -1
  79. package/dist/feature/queue/services/control.js +46 -8
  80. package/dist/feature/queue/services/control.js.map +1 -1
  81. package/dist/feature/queue/services/store.js +4 -0
  82. package/dist/feature/queue/services/store.js.map +1 -1
  83. package/dist/feature/queue/services/task-tags.js +4 -1
  84. package/dist/feature/queue/services/task-tags.js.map +1 -1
  85. package/dist/feature/queue/types/advance.js +29 -12
  86. package/dist/feature/queue/types/advance.js.map +1 -1
  87. package/dist/feature/queue/types/filter.js +36 -0
  88. package/dist/feature/queue/types/filter.js.map +1 -0
  89. package/dist/feature/queue/types/index.js +1 -0
  90. package/dist/feature/queue/types/index.js.map +1 -1
  91. package/dist/feature/queue/types/items.js +1 -0
  92. package/dist/feature/queue/types/items.js.map +1 -1
  93. package/dist/feature/queue/types/returns.js +18 -3
  94. package/dist/feature/queue/types/returns.js.map +1 -1
  95. package/dist/feature/queue/types/settings.js +14 -3
  96. package/dist/feature/queue/types/settings.js.map +1 -1
  97. package/dist/feature/runs/machine/exits.js +23 -1
  98. package/dist/feature/runs/machine/exits.js.map +1 -1
  99. package/dist/feature/runs/machine/plan.js +38 -16
  100. package/dist/feature/runs/machine/plan.js.map +1 -1
  101. package/dist/feature/runs/machine/repair.js +10 -3
  102. package/dist/feature/runs/machine/repair.js.map +1 -1
  103. package/dist/feature/runs/machine/scheduler.js +10 -3
  104. package/dist/feature/runs/machine/scheduler.js.map +1 -1
  105. package/dist/feature/runs/machine/steps.js +11 -11
  106. package/dist/feature/runs/machine/steps.js.map +1 -1
  107. package/dist/feature/runs/machine/transition.js +16 -2
  108. package/dist/feature/runs/machine/transition.js.map +1 -1
  109. package/dist/feature/runs/repositories/finished-runs.js +14 -10
  110. package/dist/feature/runs/repositories/finished-runs.js.map +1 -1
  111. package/dist/feature/runs/repositories/write.js +1 -1
  112. package/dist/feature/runs/repositories/write.js.map +1 -1
  113. package/dist/feature/runs/services/create.js +1 -0
  114. package/dist/feature/runs/services/create.js.map +1 -1
  115. package/dist/feature/runs/services/effects/actions.js +3 -2
  116. package/dist/feature/runs/services/effects/actions.js.map +1 -1
  117. package/dist/feature/runs/services/effects/attempts.js +61 -13
  118. package/dist/feature/runs/services/effects/attempts.js.map +1 -1
  119. package/dist/feature/runs/services/effects/context.js.map +1 -1
  120. package/dist/feature/runs/services/effects/effects.js +5 -0
  121. package/dist/feature/runs/services/effects/effects.js.map +1 -1
  122. package/dist/feature/runs/services/effects/naming.js +4 -1
  123. package/dist/feature/runs/services/effects/naming.js.map +1 -1
  124. package/dist/feature/runs/services/effects/proxy.js +5 -0
  125. package/dist/feature/runs/services/effects/proxy.js.map +1 -0
  126. package/dist/feature/runs/services/effects/runtime-check.js +20 -0
  127. package/dist/feature/runs/services/effects/runtime-check.js.map +1 -0
  128. package/dist/feature/runs/services/engine.js +14 -5
  129. package/dist/feature/runs/services/engine.js.map +1 -1
  130. package/dist/feature/runs/services/index.js.map +1 -1
  131. package/dist/feature/runs/services/reads.js +40 -1
  132. package/dist/feature/runs/services/reads.js.map +1 -1
  133. package/dist/feature/runs/services/requests.js +7 -1
  134. package/dist/feature/runs/services/requests.js.map +1 -1
  135. package/dist/feature/runs/services/states.js +2 -2
  136. package/dist/feature/runs/services/states.js.map +1 -1
  137. package/dist/feature/runs/types/attempt.js +8 -0
  138. package/dist/feature/runs/types/attempt.js.map +1 -1
  139. package/dist/feature/runs/types/group.js.map +1 -1
  140. package/dist/feature/runs/types/input.js +33 -0
  141. package/dist/feature/runs/types/input.js.map +1 -1
  142. package/dist/feature/runs/types/limits.js +13 -1
  143. package/dist/feature/runs/types/limits.js.map +1 -1
  144. package/dist/feature/stats/repositories/index.js +4 -0
  145. package/dist/feature/stats/repositories/index.js.map +1 -0
  146. package/dist/feature/stats/repositories/meta.js +19 -0
  147. package/dist/feature/stats/repositories/meta.js.map +1 -0
  148. package/dist/feature/stats/repositories/records.js +46 -0
  149. package/dist/feature/stats/repositories/records.js.map +1 -0
  150. package/dist/feature/stats/repositories/report.js +105 -0
  151. package/dist/feature/stats/repositories/report.js.map +1 -0
  152. package/dist/feature/stats/services/create.js +44 -0
  153. package/dist/feature/stats/services/create.js.map +1 -0
  154. package/dist/feature/stats/services/index.js +4 -0
  155. package/dist/feature/stats/services/index.js.map +1 -0
  156. package/dist/feature/stats/services/ledger.js +137 -0
  157. package/dist/feature/stats/services/ledger.js.map +1 -0
  158. package/dist/feature/stats/services/report.js +56 -0
  159. package/dist/feature/stats/services/report.js.map +1 -0
  160. package/dist/feature/stats/types/aggregate.js +179 -0
  161. package/dist/feature/stats/types/aggregate.js.map +1 -0
  162. package/dist/feature/stats/types/capture.js +79 -0
  163. package/dist/feature/stats/types/capture.js.map +1 -0
  164. package/dist/feature/stats/types/index.js +6 -0
  165. package/dist/feature/stats/types/index.js.map +1 -0
  166. package/dist/feature/stats/types/records.js +5 -0
  167. package/dist/feature/stats/types/records.js.map +1 -0
  168. package/dist/feature/stats/types/report.js +25 -0
  169. package/dist/feature/stats/types/report.js.map +1 -0
  170. package/dist/feature/stats/types/settings.js +2 -0
  171. package/dist/feature/stats/types/settings.js.map +1 -0
  172. package/dist/feature/swarm-config/services/assemble.js +1 -1
  173. package/dist/feature/swarm-config/services/assemble.js.map +1 -1
  174. package/dist/feature/swarm-config/services/index.js +4 -2
  175. package/dist/feature/swarm-config/services/index.js.map +1 -1
  176. package/dist/feature/swarm-config/services/load.js +17 -2
  177. package/dist/feature/swarm-config/services/load.js.map +1 -1
  178. package/dist/feature/swarm-config/services/sections/mcp-servers.js +128 -0
  179. package/dist/feature/swarm-config/services/sections/mcp-servers.js.map +1 -0
  180. package/dist/feature/swarm-config/services/sections/stats.js +28 -0
  181. package/dist/feature/swarm-config/services/sections/stats.js.map +1 -0
  182. package/dist/feature/swarm-config/services/settings.js +23 -1
  183. package/dist/feature/swarm-config/services/settings.js.map +1 -1
  184. package/dist/feature/swarm-config/services/validate-actions.js +9 -1
  185. package/dist/feature/swarm-config/services/validate-actions.js.map +1 -1
  186. package/dist/feature/swarm-config/services/validate-runtimes.js +3 -51
  187. package/dist/feature/swarm-config/services/validate-runtimes.js.map +1 -1
  188. package/dist/feature/swarm-config/services/validate-settings.js +65 -0
  189. package/dist/feature/swarm-config/services/validate-settings.js.map +1 -1
  190. package/dist/feature/swarm-config/services/validate-specialists.js +5 -4
  191. package/dist/feature/swarm-config/services/validate-specialists.js.map +1 -1
  192. package/dist/feature/swarm-config/services/validate.js +24 -8
  193. package/dist/feature/swarm-config/services/validate.js.map +1 -1
  194. package/dist/feature/swarm-config/types/action.js +9 -0
  195. package/dist/feature/swarm-config/types/action.js.map +1 -1
  196. package/dist/feature/swarm-config/types/index.js +1 -0
  197. package/dist/feature/swarm-config/types/index.js.map +1 -1
  198. package/dist/feature/swarm-config/types/mcp/reference.js +40 -0
  199. package/dist/feature/swarm-config/types/mcp/reference.js.map +1 -0
  200. package/dist/feature/swarm-config/types/merge.js +1 -0
  201. package/dist/feature/swarm-config/types/merge.js.map +1 -1
  202. package/dist/feature/swarm-config/types/settings.js +37 -5
  203. package/dist/feature/swarm-config/types/settings.js.map +1 -1
  204. package/dist/feature/swarm-config/types/specialist.js.map +1 -1
  205. package/dist/feature/swarm-edit/services/config-edits.js +26 -1
  206. package/dist/feature/swarm-edit/services/config-edits.js.map +1 -1
  207. package/dist/feature/swarm-edit/services/editor-settings.js +36 -7
  208. package/dist/feature/swarm-edit/services/editor-settings.js.map +1 -1
  209. package/dist/feature/swarm-edit/services/editor-view.js +2 -0
  210. package/dist/feature/swarm-edit/services/editor-view.js.map +1 -1
  211. package/dist/feature/swarm-edit/services/index.js +1 -0
  212. package/dist/feature/swarm-edit/services/index.js.map +1 -1
  213. package/dist/feature/swarm-edit/services/mcp/editor-mcp.js +51 -0
  214. package/dist/feature/swarm-edit/services/mcp/editor-mcp.js.map +1 -0
  215. package/dist/feature/swarm-edit/services/mcp/plan-mcp-server.js +93 -0
  216. package/dist/feature/swarm-edit/services/mcp/plan-mcp-server.js.map +1 -0
  217. package/dist/feature/swarm-edit/services/plan-settings.js +3 -1
  218. package/dist/feature/swarm-edit/services/plan-settings.js.map +1 -1
  219. package/dist/feature/swarm-edit/types/editor.js.map +1 -1
  220. package/dist/feature/swarm-edit/types/setting-fields.js +12 -0
  221. package/dist/feature/swarm-edit/types/setting-fields.js.map +1 -1
  222. package/dist/platform/git/delivery.js +1 -1
  223. package/dist/platform/git/delivery.js.map +1 -1
  224. package/dist/platform/network/index.js +4 -0
  225. package/dist/platform/network/index.js.map +1 -0
  226. package/dist/platform/network/interfaces.js +7 -0
  227. package/dist/platform/network/interfaces.js.map +1 -0
  228. package/dist/platform/network/probe.js +128 -0
  229. package/dist/platform/network/probe.js.map +1 -0
  230. package/dist/platform/network/tunnel.js +87 -0
  231. package/dist/platform/network/tunnel.js.map +1 -0
  232. package/dist/platform/process/command.js +23 -0
  233. package/dist/platform/process/command.js.map +1 -0
  234. package/dist/platform/process/index.js +1 -0
  235. package/dist/platform/process/index.js.map +1 -1
  236. package/dist/platform/sqlite/migrations.js +3 -0
  237. package/dist/platform/sqlite/migrations.js.map +1 -1
  238. package/dist/platform/sqlite/stats-migration.js +42 -0
  239. package/dist/platform/sqlite/stats-migration.js.map +1 -0
  240. package/dist/presentation/cli/commands/queue-edit.js +23 -1
  241. package/dist/presentation/cli/commands/queue-edit.js.map +1 -1
  242. package/dist/presentation/cli/commands/stats.js +41 -0
  243. package/dist/presentation/cli/commands/stats.js.map +1 -0
  244. package/dist/presentation/cli/help.js +1 -1
  245. package/dist/presentation/cli/help.js.map +1 -1
  246. package/dist/presentation/cli/local/config-check.js +23 -5
  247. package/dist/presentation/cli/local/config-check.js.map +1 -1
  248. package/dist/presentation/cli/program.js +2 -0
  249. package/dist/presentation/cli/program.js.map +1 -1
  250. package/dist/presentation/format/index.js +1 -0
  251. package/dist/presentation/format/index.js.map +1 -1
  252. package/dist/presentation/format/queue.js +15 -2
  253. package/dist/presentation/format/queue.js.map +1 -1
  254. package/dist/presentation/format/runs.js +8 -1
  255. package/dist/presentation/format/runs.js.map +1 -1
  256. package/dist/presentation/format/stats.js +79 -0
  257. package/dist/presentation/format/stats.js.map +1 -0
  258. package/dist/presentation/ipc/contract/agents.js +18 -0
  259. package/dist/presentation/ipc/contract/agents.js.map +1 -1
  260. package/dist/presentation/ipc/contract/config.js +26 -0
  261. package/dist/presentation/ipc/contract/config.js.map +1 -1
  262. package/dist/presentation/ipc/contract/envelope.js +4 -1
  263. package/dist/presentation/ipc/contract/envelope.js.map +1 -1
  264. package/dist/presentation/ipc/contract/groups.js +9 -0
  265. package/dist/presentation/ipc/contract/groups.js.map +1 -1
  266. package/dist/presentation/ipc/contract/index.js +1 -0
  267. package/dist/presentation/ipc/contract/index.js.map +1 -1
  268. package/dist/presentation/ipc/contract/panel.js +11 -0
  269. package/dist/presentation/ipc/contract/panel.js.map +1 -1
  270. package/dist/presentation/ipc/contract/queue.js +11 -1
  271. package/dist/presentation/ipc/contract/queue.js.map +1 -1
  272. package/dist/presentation/ipc/contract/responses/index.js +1 -0
  273. package/dist/presentation/ipc/contract/responses/index.js.map +1 -1
  274. package/dist/presentation/ipc/contract/responses/stats.js +67 -0
  275. package/dist/presentation/ipc/contract/responses/stats.js.map +1 -0
  276. package/dist/presentation/ipc/contract/runs.js +10 -0
  277. package/dist/presentation/ipc/contract/runs.js.map +1 -1
  278. package/dist/presentation/ipc/contract/stats/stats.js +20 -0
  279. package/dist/presentation/ipc/contract/stats/stats.js.map +1 -0
  280. package/dist/presentation/ipc/handlers/config.js +7 -0
  281. package/dist/presentation/ipc/handlers/config.js.map +1 -1
  282. package/dist/presentation/ipc/handlers/groups.js +8 -0
  283. package/dist/presentation/ipc/handlers/groups.js.map +1 -1
  284. package/dist/presentation/ipc/handlers/runs.js +2 -1
  285. package/dist/presentation/ipc/handlers/runs.js.map +1 -1
  286. package/dist/presentation/ipc/handlers/stats.js +17 -0
  287. package/dist/presentation/ipc/handlers/stats.js.map +1 -0
  288. package/dist/presentation/ipc/handlers/system.js +2 -0
  289. package/dist/presentation/ipc/handlers/system.js.map +1 -1
  290. package/dist/presentation/ipc/handlers/table.js +2 -0
  291. package/dist/presentation/ipc/handlers/table.js.map +1 -1
  292. package/dist/presentation/ipc/publisher.js +1 -0
  293. package/dist/presentation/ipc/publisher.js.map +1 -1
  294. package/dist/presentation/ipc/snapshots.js +2 -2
  295. package/dist/presentation/ipc/snapshots.js.map +1 -1
  296. package/dist/presentation/ipc/views/catalog.js +3 -3
  297. package/dist/presentation/ipc/views/catalog.js.map +1 -1
  298. package/dist/presentation/ipc/views/index.js +1 -0
  299. package/dist/presentation/ipc/views/index.js.map +1 -1
  300. package/dist/presentation/ipc/views/observers.js +2 -2
  301. package/dist/presentation/ipc/views/observers.js.map +1 -1
  302. package/dist/presentation/ipc/views/queue.js +9 -2
  303. package/dist/presentation/ipc/views/queue.js.map +1 -1
  304. package/dist/presentation/ipc/views/runs.js +3 -4
  305. package/dist/presentation/ipc/views/runs.js.map +1 -1
  306. package/dist/presentation/ipc/views/stats.js +5 -0
  307. package/dist/presentation/ipc/views/stats.js.map +1 -0
  308. package/dist/presentation/mcp/host-queue-control.js +11 -2
  309. package/dist/presentation/mcp/host-queue-control.js.map +1 -1
  310. package/dist/presentation/mcp/worker-extra.js +2 -2
  311. package/dist/presentation/mcp/worker-extra.js.map +1 -1
  312. package/dist/presentation/mcp/worker-read.js +45 -0
  313. package/dist/presentation/mcp/worker-read.js.map +1 -0
  314. package/dist/presentation/mcp/worker.js +2 -0
  315. package/dist/presentation/mcp/worker.js.map +1 -1
  316. package/dist/presentation/web/hub.js +4 -0
  317. package/dist/presentation/web/hub.js.map +1 -1
  318. package/dist/presentation/web/panel/directories.js +1 -1
  319. package/dist/presentation/web/panel/directories.js.map +1 -1
  320. package/dist/presentation/web/panel/system.js +1 -0
  321. package/dist/presentation/web/panel/system.js.map +1 -1
  322. package/dist/presentation/web/request.js +28 -1
  323. package/dist/presentation/web/request.js.map +1 -1
  324. package/dist/presentation/web/routes/catalog/mcp-servers.js +50 -0
  325. package/dist/presentation/web/routes/catalog/mcp-servers.js.map +1 -0
  326. package/dist/presentation/web/routes/config.js +5 -0
  327. package/dist/presentation/web/routes/config.js.map +1 -1
  328. package/dist/presentation/web/routes/runs.js +5 -0
  329. package/dist/presentation/web/routes/runs.js.map +1 -1
  330. package/dist/presentation/web/routes/stats/stats.js +22 -0
  331. package/dist/presentation/web/routes/stats/stats.js.map +1 -0
  332. package/dist/presentation/web/server.js +5 -1
  333. package/dist/presentation/web/server.js.map +1 -1
  334. package/dist/web/assets/FilterColumn-BrQWIM5F.js +1 -0
  335. package/dist/web/assets/SharedPipelinesGroup-WFngQrqI.js +1 -0
  336. package/dist/web/assets/badge-B_khFsd6.js +1 -0
  337. package/dist/web/assets/{card-DkikoTxR.js → card-COXjnc-y.js} +1 -1
  338. package/dist/web/assets/empty-Eb-EZDPX.js +41 -0
  339. package/dist/web/assets/index-DEXoIe2a.js +21 -0
  340. package/dist/web/assets/index-DMlIe0VD.css +2 -0
  341. package/dist/web/assets/locales-BlBJo1PR.js +1 -0
  342. package/dist/web/assets/pipelines-B3cdeex_.js +10 -0
  343. package/dist/web/assets/queue-HMUImu0E.js +16 -0
  344. package/dist/web/assets/select-MHus_Unr.js +1 -0
  345. package/dist/web/assets/settingFields-DVg9TQK2.js +1 -0
  346. package/dist/web/assets/settings-CpeEsUXX.js +6 -0
  347. package/dist/web/assets/skeleton-CWY1nRvW.js +1 -0
  348. package/dist/web/assets/specialists-BkLXuqUd.js +1 -0
  349. package/dist/web/assets/stats-DRg_5vll.js +1 -0
  350. package/dist/web/assets/topology-DGTNdDHf.js +1 -0
  351. package/dist/web/assets/trash-CFJeuRuc.js +1 -0
  352. package/dist/web/assets/useListDrag-B7Wlt2u9.js +1 -0
  353. package/dist/web/index.html +7 -6
  354. package/integrations/claude-code/.claude-plugin/plugin.json +1 -1
  355. package/package.json +1 -1
  356. package/dist/cli/clean.js +0 -71
  357. package/dist/cli/clean.js.map +0 -1
  358. package/dist/cli/commands.js +0 -963
  359. package/dist/cli/commands.js.map +0 -1
  360. package/dist/cli/config-check.js +0 -173
  361. package/dist/cli/config-check.js.map +0 -1
  362. package/dist/cli/daemon.js +0 -199
  363. package/dist/cli/daemon.js.map +0 -1
  364. package/dist/cli/help.js +0 -50
  365. package/dist/cli/help.js.map +0 -1
  366. package/dist/cli/init.js +0 -43
  367. package/dist/cli/init.js.map +0 -1
  368. package/dist/cli/io.js +0 -13
  369. package/dist/cli/io.js.map +0 -1
  370. package/dist/cli/probe.js +0 -12
  371. package/dist/cli/probe.js.map +0 -1
  372. package/dist/cli/program.js +0 -48
  373. package/dist/cli/program.js.map +0 -1
  374. package/dist/cli/setup.js +0 -406
  375. package/dist/cli/setup.js.map +0 -1
  376. package/dist/cli/version.js +0 -6
  377. package/dist/cli/version.js.map +0 -1
  378. package/dist/cli/watch.js +0 -24
  379. package/dist/cli/watch.js.map +0 -1
  380. package/dist/cli/web/daemon-panel.js +0 -185
  381. package/dist/cli/web/daemon-panel.js.map +0 -1
  382. package/dist/cli/web/default-repository.js +0 -12
  383. package/dist/cli/web/default-repository.js.map +0 -1
  384. package/dist/cli/web/errors.js +0 -60
  385. package/dist/cli/web/errors.js.map +0 -1
  386. package/dist/cli/web/open.js +0 -12
  387. package/dist/cli/web/open.js.map +0 -1
  388. package/dist/cli/web/page.js +0 -465
  389. package/dist/cli/web/page.js.map +0 -1
  390. package/dist/cli/web/server.js +0 -1191
  391. package/dist/cli/web/server.js.map +0 -1
  392. package/dist/cli/web/standby.js +0 -119
  393. package/dist/cli/web/standby.js.map +0 -1
  394. package/dist/cli/web/state.js +0 -69
  395. package/dist/cli/web/state.js.map +0 -1
  396. package/dist/cli/web/system.js +0 -66
  397. package/dist/cli/web/system.js.map +0 -1
  398. package/dist/cli/web-control.js +0 -173
  399. package/dist/cli/web-control.js.map +0 -1
  400. package/dist/config/discover.js +0 -25
  401. package/dist/config/discover.js.map +0 -1
  402. package/dist/config/duration.js +0 -17
  403. package/dist/config/duration.js.map +0 -1
  404. package/dist/config/edit.js +0 -966
  405. package/dist/config/edit.js.map +0 -1
  406. package/dist/config/errors.js +0 -29
  407. package/dist/config/errors.js.map +0 -1
  408. package/dist/config/index.js +0 -14
  409. package/dist/config/index.js.map +0 -1
  410. package/dist/config/load.js +0 -412
  411. package/dist/config/load.js.map +0 -1
  412. package/dist/config/merge.js +0 -45
  413. package/dist/config/merge.js.map +0 -1
  414. package/dist/config/model.js +0 -171
  415. package/dist/config/model.js.map +0 -1
  416. package/dist/config/paths.js +0 -31
  417. package/dist/config/paths.js.map +0 -1
  418. package/dist/config/prompt.js +0 -33
  419. package/dist/config/prompt.js.map +0 -1
  420. package/dist/config/shared-pipelines.js +0 -71
  421. package/dist/config/shared-pipelines.js.map +0 -1
  422. package/dist/config/shared-specialists.js +0 -68
  423. package/dist/config/shared-specialists.js.map +0 -1
  424. package/dist/config/shared-workflows.js +0 -71
  425. package/dist/config/shared-workflows.js.map +0 -1
  426. package/dist/config/specialist-tags.js +0 -214
  427. package/dist/config/specialist-tags.js.map +0 -1
  428. package/dist/config/tag-names.js +0 -43
  429. package/dist/config/tag-names.js.map +0 -1
  430. package/dist/config/validate.js +0 -872
  431. package/dist/config/validate.js.map +0 -1
  432. package/dist/core/artifacts.js +0 -37
  433. package/dist/core/artifacts.js.map +0 -1
  434. package/dist/core/create.js +0 -75
  435. package/dist/core/create.js.map +0 -1
  436. package/dist/core/delivery.js +0 -366
  437. package/dist/core/delivery.js.map +0 -1
  438. package/dist/core/errors.js +0 -7
  439. package/dist/core/errors.js.map +0 -1
  440. package/dist/core/ids.js +0 -99
  441. package/dist/core/ids.js.map +0 -1
  442. package/dist/core/index.js +0 -21
  443. package/dist/core/index.js.map +0 -1
  444. package/dist/core/input.js +0 -45
  445. package/dist/core/input.js.map +0 -1
  446. package/dist/core/machine.js +0 -1021
  447. package/dist/core/machine.js.map +0 -1
  448. package/dist/core/model.js +0 -460
  449. package/dist/core/model.js.map +0 -1
  450. package/dist/core/observer.js +0 -193
  451. package/dist/core/observer.js.map +0 -1
  452. package/dist/core/occupancy.js +0 -63
  453. package/dist/core/occupancy.js.map +0 -1
  454. package/dist/core/permissions.js +0 -222
  455. package/dist/core/permissions.js.map +0 -1
  456. package/dist/core/plan.js +0 -99
  457. package/dist/core/plan.js.map +0 -1
  458. package/dist/core/progress.js +0 -43
  459. package/dist/core/progress.js.map +0 -1
  460. package/dist/core/questions.js +0 -19
  461. package/dist/core/questions.js.map +0 -1
  462. package/dist/core/queue.js +0 -859
  463. package/dist/core/queue.js.map +0 -1
  464. package/dist/core/retryable.js +0 -8
  465. package/dist/core/retryable.js.map +0 -1
  466. package/dist/core/scheduler.js +0 -160
  467. package/dist/core/scheduler.js.map +0 -1
  468. package/dist/core/skip.js +0 -109
  469. package/dist/core/skip.js.map +0 -1
  470. package/dist/core/stages.js +0 -304
  471. package/dist/core/stages.js.map +0 -1
  472. package/dist/core/summary.js +0 -35
  473. package/dist/core/summary.js.map +0 -1
  474. package/dist/core/tags.js +0 -184
  475. package/dist/core/tags.js.map +0 -1
  476. package/dist/core/topology.js +0 -162
  477. package/dist/core/topology.js.map +0 -1
  478. package/dist/daemon/artifacts.js +0 -84
  479. package/dist/daemon/artifacts.js.map +0 -1
  480. package/dist/daemon/daemon.js +0 -1442
  481. package/dist/daemon/daemon.js.map +0 -1
  482. package/dist/daemon/executor.js +0 -749
  483. package/dist/daemon/executor.js.map +0 -1
  484. package/dist/daemon/helpers.js +0 -38
  485. package/dist/daemon/helpers.js.map +0 -1
  486. package/dist/daemon/index.js +0 -4
  487. package/dist/daemon/index.js.map +0 -1
  488. package/dist/daemon/logs.js +0 -69
  489. package/dist/daemon/logs.js.map +0 -1
  490. package/dist/daemon/observers.js +0 -93
  491. package/dist/daemon/observers.js.map +0 -1
  492. package/dist/daemon/patches.js +0 -76
  493. package/dist/daemon/patches.js.map +0 -1
  494. package/dist/daemon/ports.js +0 -2
  495. package/dist/daemon/ports.js.map +0 -1
  496. package/dist/daemon/processes.js +0 -98
  497. package/dist/daemon/processes.js.map +0 -1
  498. package/dist/daemon/repositories.js +0 -2
  499. package/dist/daemon/repositories.js.map +0 -1
  500. package/dist/daemon/server.js +0 -164
  501. package/dist/daemon/server.js.map +0 -1
  502. package/dist/daemon/supervisor.js +0 -140
  503. package/dist/daemon/supervisor.js.map +0 -1
  504. package/dist/daemon/timings.js +0 -23
  505. package/dist/daemon/timings.js.map +0 -1
  506. package/dist/git/delivery.js +0 -284
  507. package/dist/git/delivery.js.map +0 -1
  508. package/dist/git/index.js +0 -4
  509. package/dist/git/index.js.map +0 -1
  510. package/dist/git/runner.js +0 -60
  511. package/dist/git/runner.js.map +0 -1
  512. package/dist/git/workspace.js +0 -366
  513. package/dist/git/workspace.js.map +0 -1
  514. package/dist/mcp/host.js +0 -401
  515. package/dist/mcp/host.js.map +0 -1
  516. package/dist/mcp/index.js +0 -3
  517. package/dist/mcp/index.js.map +0 -1
  518. package/dist/mcp/tools.js +0 -19
  519. package/dist/mcp/tools.js.map +0 -1
  520. package/dist/mcp/version.js +0 -5
  521. package/dist/mcp/version.js.map +0 -1
  522. package/dist/mcp/worker.js +0 -230
  523. package/dist/mcp/worker.js.map +0 -1
  524. package/dist/presentation/web/routes/directories.js +0 -60
  525. package/dist/presentation/web/routes/directories.js.map +0 -1
  526. package/dist/protocol/autostart.js +0 -171
  527. package/dist/protocol/autostart.js.map +0 -1
  528. package/dist/protocol/build.js +0 -38
  529. package/dist/protocol/build.js.map +0 -1
  530. package/dist/protocol/catalog.js +0 -18
  531. package/dist/protocol/catalog.js.map +0 -1
  532. package/dist/protocol/client.js +0 -83
  533. package/dist/protocol/client.js.map +0 -1
  534. package/dist/protocol/format.js +0 -477
  535. package/dist/protocol/format.js.map +0 -1
  536. package/dist/protocol/index.js +0 -11
  537. package/dist/protocol/index.js.map +0 -1
  538. package/dist/protocol/messages.js +0 -598
  539. package/dist/protocol/messages.js.map +0 -1
  540. package/dist/protocol/style.js +0 -81
  541. package/dist/protocol/style.js.map +0 -1
  542. package/dist/protocol/transcript.js +0 -49
  543. package/dist/protocol/transcript.js.map +0 -1
  544. package/dist/protocol/views.js +0 -696
  545. package/dist/protocol/views.js.map +0 -1
  546. package/dist/runtime/catalog.js +0 -117
  547. package/dist/runtime/catalog.js.map +0 -1
  548. package/dist/runtime/claude.js +0 -399
  549. package/dist/runtime/claude.js.map +0 -1
  550. package/dist/runtime/index.js +0 -34
  551. package/dist/runtime/index.js.map +0 -1
  552. package/dist/runtime/message.js +0 -48
  553. package/dist/runtime/message.js.map +0 -1
  554. package/dist/runtime/naming.js +0 -69
  555. package/dist/runtime/naming.js.map +0 -1
  556. package/dist/runtime/opencode.js +0 -189
  557. package/dist/runtime/opencode.js.map +0 -1
  558. package/dist/runtime/skills.js +0 -17
  559. package/dist/runtime/skills.js.map +0 -1
  560. package/dist/runtime/transcript.js +0 -227
  561. package/dist/runtime/transcript.js.map +0 -1
  562. package/dist/runtime/types.js +0 -12
  563. package/dist/runtime/types.js.map +0 -1
  564. package/dist/runtime/which.js +0 -21
  565. package/dist/runtime/which.js.map +0 -1
  566. package/dist/store/index.js +0 -3
  567. package/dist/store/index.js.map +0 -1
  568. package/dist/store/schema.js +0 -286
  569. package/dist/store/schema.js.map +0 -1
  570. package/dist/store/store.js +0 -491
  571. package/dist/store/store.js.map +0 -1
  572. package/dist/web/assets/EntryList-CnfGgjEY.js +0 -1
  573. package/dist/web/assets/FilePath-C0X8-keS.js +0 -1
  574. package/dist/web/assets/SettingsForm-BcyBWJbn.js +0 -1
  575. package/dist/web/assets/SharedPipelinesGroup-a368-IQ0.js +0 -1
  576. package/dist/web/assets/index-B-oJ93zH.js +0 -22
  577. package/dist/web/assets/index-BZE36gYR.css +0 -2
  578. package/dist/web/assets/locales-DtRrxYzg.js +0 -1
  579. package/dist/web/assets/pipelines-D48ggDNe.js +0 -1
  580. package/dist/web/assets/queue-D8_RY4IY.js +0 -16
  581. package/dist/web/assets/select-J4oIrmYh.js +0 -1
  582. package/dist/web/assets/settings-B0-0Vaia.js +0 -2
  583. package/dist/web/assets/skeleton-CCKCQF5n.js +0 -1
  584. package/dist/web/assets/specialists-DH8tyluO.js +0 -1
  585. package/dist/web/assets/switch-CWFAgxG1.js +0 -41
  586. package/dist/web/assets/topology-CNQ28AB2.js +0 -7
  587. /package/dist/web/assets/{topology-DLioOiRN.css → pipelines-DLioOiRN.css} +0 -0
@@ -1,1021 +0,0 @@
1
- import { groupPipeline } from '../config/index.js';
2
- import { advanceChecks, afterDeliveryDone, cancelDelivery, finishDelivery, finishMessage, renderCommitMessage, cleanupIfDelivered, markDelivered, requestDelivery, resolvePrepared, resolverDone, } from './delivery.js';
3
- import { Rejection } from './errors.js';
4
- import { closeRepair, openRepairGroup, repairTask } from './observer.js';
5
- import { checkSkip, lastUnskipped, nextUnskipped, stepStates } from './skip.js';
6
- import { refreshPermissions, refreshSpecialists, } from './permissions.js';
7
- import { groupSlugs } from './ids.js';
8
- import { retryableGroups } from './retryable.js';
9
- import { enterPoint } from './stages.js';
10
- import { attemptStepLabel } from './topology.js';
11
- import { questionsText, reviewQuestion } from './questions.js';
12
- import { addUsage, allGroups, attemptVerdict, describeFailReason, findGroup, isMessageGroup, isRepairGroup, isResolveGroup, isServiceGroup, isSplitGroup, newGroup, stepsOf, freshPending, isActionGroup, REPAIR_GROUP, actionGroupsOf, deliveryCheckActive, actionPointOf, pointClosed, pointStalled, isRunFinished, isTerminal, runPipeline, validateReport, } from './model.js';
13
- export { Rejection };
14
- function wrongStatus(group, action, expected) {
15
- return new Rejection(`group \`${group.slug}\` is ${group.status}; ${action} needs ${expected}`);
16
- }
17
- function updateFinished(state, now) {
18
- if (!isRunFinished(state))
19
- state.run.finishedAt = null;
20
- else if (state.run.finishedAt === null)
21
- state.run.finishedAt = now;
22
- }
23
- export function transition(state, event, now) {
24
- const machine = new Machine(state, now);
25
- const wasFinished = state.run.finishedAt !== null;
26
- const wasDone = afterDeliveryDone(state);
27
- const heldBefore = state.run.hold !== null;
28
- machine.apply(event);
29
- machine.pipeline(wasDone);
30
- machine.skipAhead();
31
- machine.startNextMerge();
32
- updateFinished(state, now);
33
- // A pause cancelled the repair of a task with nothing to retry (a delivery incident): the pause
34
- // stays, or the incident would be taken again at once. A finished task that was held before the
35
- // event is such a task.
36
- const keepHold = machine.pausedRepair || (wasFinished && heldBefore);
37
- if (state.run.finishedAt !== null && retryableGroups(state).length === 0 && !keepHold) {
38
- state.run.hold = null;
39
- }
40
- if (!wasFinished && state.run.finishedAt !== null && state.run.config.delivery.auto) {
41
- machine.autoDeliver();
42
- updateFinished(state, now);
43
- }
44
- if (state.run.finishedAt !== null && retryableGroups(state).length === 0 && !keepHold) {
45
- state.run.hold = null;
46
- }
47
- return machine.effects;
48
- }
49
- class Machine {
50
- effects = [];
51
- /** The whole run was cancelled while its delivery waited for the checks: no automatic delivery follows. */
52
- checksCancelled = false;
53
- /** A pause ended the repair that went on. */
54
- pausedRepair = false;
55
- state;
56
- now;
57
- constructor(state, now) {
58
- this.state = state;
59
- this.now = now;
60
- }
61
- group(slug) {
62
- const group = findGroup(this.state, slug);
63
- if (!group)
64
- throw new Rejection(`unknown group \`${slug}\``);
65
- return group;
66
- }
67
- running(group, seq) {
68
- return group.attempts.find((attempt) => attempt.seq === seq && attempt.status === 'running');
69
- }
70
- apply(event) {
71
- switch (event.kind) {
72
- case 'report':
73
- return this.report(event.group, event.seq, event.report);
74
- case 'split_proposed':
75
- return this.proposeSplit(event.seq, event.groups);
76
- case 'attempt_exited':
77
- return this.exited(event.group, event.seq, event.exit);
78
- case 'attempt_usage':
79
- for (const update of event.updates) {
80
- const group = findGroup(this.state, update.group);
81
- const attempt = group ? this.running(group, update.seq) : undefined;
82
- if (attempt)
83
- attempt.usage = update.usage;
84
- }
85
- return;
86
- case 'timed_out':
87
- return this.timedOut(event.group, event.seq);
88
- case 'action_finished':
89
- return this.actionFinished(event.group, event.seq, event.outcome);
90
- case 'message':
91
- return this.message(event.group, event.seq, event.text);
92
- case 'cancel':
93
- return this.cancel(event.group, event.reason);
94
- case 'retry':
95
- return this.retry(event.group, event.permissions, event.specialists);
96
- case 'answer':
97
- return this.answer(event.group, event.answer, event.by ?? 'human', event.permissions);
98
- case 'merge_finished':
99
- return this.mergeFinished(event.group, event.outcome);
100
- case 'delivered_marked':
101
- this.effects.push(...markDelivered(this.state, event.groups, this.now));
102
- return;
103
- case 'deliver_requested':
104
- this.effects.push(...requestDelivery(this.state, {
105
- groups: event.groups,
106
- force: event.force,
107
- files: event.files,
108
- auto: false,
109
- }));
110
- return;
111
- case 'delivery_finished':
112
- this.effects.push(...finishDelivery(this.state, event.result, this.now));
113
- return;
114
- case 'run_named':
115
- if (this.state.run.title === null && event.title !== null) {
116
- this.state.run.title = event.title;
117
- this.state.run.name = event.name;
118
- }
119
- this.state.run.namingUsage = addUsage(this.state.run.namingUsage, event.usage);
120
- return;
121
- case 'title_set':
122
- this.state.run.title = event.title;
123
- return;
124
- case 'tags_set':
125
- this.state.run.tags = [...event.tags];
126
- return;
127
- case 'step_skip':
128
- return this.stepSkip(event.step, event.skip);
129
- case 'resolve_prepared':
130
- this.effects.push(...resolvePrepared(this.state, event.conflicts));
131
- return;
132
- case 'commit_failed':
133
- return this.commitFailed(this.group(event.group), event.message);
134
- case 'hold':
135
- return this.hold(event.hold);
136
- case 'interrupted':
137
- return this.interrupted();
138
- case 'repair_start':
139
- return this.repairStart(event.incident, event.specialist);
140
- case 'repair_allowed':
141
- return this.repairAllowed(event.allowed);
142
- }
143
- }
144
- /** The commit of a step failed. The group of an action is merged by then: it fails, and the pipeline waits. */
145
- commitFailed(group, message) {
146
- if (!isActionGroup(group)) {
147
- this.failGroup(group, { kind: 'git', message });
148
- return;
149
- }
150
- group.status = 'failed';
151
- group.reason = describeFailReason({ kind: 'git', message });
152
- group.pending = freshPending(0);
153
- }
154
- hold(hold) {
155
- if (hold !== null && this.state.run.finishedAt !== null && this.state.run.hold === null) {
156
- throw new Rejection('a finished run cannot be held');
157
- }
158
- const pausing = hold === 'paused' && this.state.run.hold !== 'paused';
159
- this.state.run.hold = hold;
160
- if (!pausing)
161
- return;
162
- // A pause stops the running agents; their steps go on in the same session after it.
163
- const groups = [
164
- ...actionGroupsOf(this.state, 'before_split'),
165
- ...(this.state.split ? [this.state.split] : []),
166
- ...actionGroupsOf(this.state, 'after_split'),
167
- ...this.state.groups,
168
- ];
169
- for (const group of groups) {
170
- for (const attempt of group.attempts) {
171
- if (attempt.status !== 'running' || attempt.report !== null || attempt.reason !== null) {
172
- continue;
173
- }
174
- // A command cannot continue after a pause; it runs to its end.
175
- if (attempt.runtime === 'command')
176
- continue;
177
- attempt.reason = { kind: 'paused', at: this.now };
178
- this.effects.push({
179
- kind: 'stop_attempt',
180
- run: this.state.run.id,
181
- group: group.slug,
182
- seq: attempt.seq,
183
- });
184
- }
185
- }
186
- // A repair does not continue after a pause: its incident is taken again, and it is not counted.
187
- this.stopRepair({ reason: 'paused', refund: true });
188
- }
189
- report(slug, seq, report) {
190
- const attempt = this.running(this.group(slug), seq);
191
- if (!attempt)
192
- throw new Rejection(`attempt ${seq} is not running`);
193
- if (attempt.reason?.kind === 'message') {
194
- throw new Rejection(`attempt ${seq} was interrupted by a message`);
195
- }
196
- const problem = validateReport(report);
197
- if (problem !== null)
198
- throw new Rejection(`invalid report: ${problem}`);
199
- attempt.report = {
200
- verdict: report.verdict,
201
- summary: report.summary,
202
- feedback: report.feedback?.trim()
203
- ? report.feedback
204
- : report.questions
205
- ? questionsText(report.questions)
206
- : null,
207
- ...(report.questions ? { questions: report.questions } : {}),
208
- ...(report.humanOnly ? { humanOnly: true } : {}),
209
- };
210
- }
211
- proposeSplit(seq, groups) {
212
- const split = this.state.split;
213
- const attempt = split ? this.running(split, seq) : undefined;
214
- if (!split || !attempt)
215
- throw new Rejection(`attempt ${seq} is not a running split step`);
216
- const maxGroups = runPipeline(this.state.run).split?.maxGroups ?? 1;
217
- if (groups.length < 1 || groups.length > maxGroups) {
218
- throw new Rejection(`propose from 1 to ${maxGroups} groups, got ${groups.length}`);
219
- }
220
- const empty = groups.findIndex((group) => group.title.trim() === '' || group.task.trim() === '');
221
- if (empty !== -1)
222
- throw new Rejection(`group ${empty + 1} needs a non-empty title and task`);
223
- attempt.proposal = groups.map((group) => ({ title: group.title.trim(), task: group.task }));
224
- }
225
- exited(slug, seq, exit) {
226
- const group = this.group(slug);
227
- const attempt = this.running(group, seq);
228
- if (!attempt) {
229
- // Cancelled or timed out before the process ended: only the usage is still unknown.
230
- const stopped = group.attempts.find((item) => item.seq === seq);
231
- if (stopped && exit.usage !== null && stopped.finishedAt !== null)
232
- stopped.usage = exit.usage;
233
- return;
234
- }
235
- attempt.finishedAt = this.now;
236
- if (exit.sessionId !== null)
237
- attempt.sessionId = exit.sessionId;
238
- attempt.usage = exit.usage ?? attempt.usage;
239
- attempt.denials = exit.denials ?? [];
240
- attempt.outsideChanges = [...exit.outsideChanges];
241
- if (attempt.reason?.kind === 'message') {
242
- this.continueAfterMessage(group, attempt, attempt.reason);
243
- return;
244
- }
245
- if (attempt.reason?.kind === 'paused') {
246
- if (attempt.report === null) {
247
- this.continueAfterPause(group, attempt);
248
- return;
249
- }
250
- // The report came before the stop: the exit failure is the stop itself.
251
- attempt.reason = null;
252
- exit = { ...exit, failure: null };
253
- }
254
- // A report sent before the limit ran out counts as usual.
255
- const limited = exit.failure?.kind === 'usage_limit' && attempt.report !== null;
256
- const failure = limited
257
- ? null
258
- : (exit.failure ?? (attempt.report === null ? { kind: 'no_report' } : null));
259
- if (failure !== null) {
260
- attempt.status = 'failed';
261
- attempt.reason = failure;
262
- if (failure.kind === 'usage_limit' &&
263
- (exit.onLimit ?? 'wait') === 'wait' &&
264
- !isRepairGroup(group)) {
265
- this.waitForLimit(group, attempt);
266
- return;
267
- }
268
- this.failGroup(group, failure);
269
- return;
270
- }
271
- attempt.status = 'finished';
272
- const report = attempt.report;
273
- const point = actionPointOf(group);
274
- const commitsToRun = point === 'before_split' || point === 'after_split';
275
- if (report.verdict === 'done' && commitsToRun) {
276
- this.effects.push({
277
- kind: 'commit',
278
- run: this.state.run.id,
279
- group: slug,
280
- stepId: attempt.stepId,
281
- summary: report.summary,
282
- });
283
- }
284
- if (report.verdict !== 'needs_human' && !isServiceGroup(group)) {
285
- this.effects.push({
286
- kind: 'commit',
287
- run: this.state.run.id,
288
- group: slug,
289
- stepId: attempt.stepId,
290
- summary: report.summary,
291
- });
292
- }
293
- if (exit.outsideChanges.length > 0 &&
294
- this.state.run.config.outsideChanges === 'stop' &&
295
- !isRepairGroup(group)) {
296
- const files = exit.outsideChanges.join(', ');
297
- this.askHuman(group, attempt.stepIndex, `Files in your working copy changed while step ${attemptStepLabel(this.state, group, attempt)} ran: ${files}. The specialist, you or another program may have changed them; aip deliveries are not counted. Check your working copy and answer to continue.`, null);
298
- return;
299
- }
300
- if (isRepairGroup(group))
301
- this.finishRepair(group, report);
302
- else if (isResolveGroup(group))
303
- this.finishResolve(group, report);
304
- else if (isActionGroup(group))
305
- this.finishAction(group, attempt, report);
306
- else if (report.verdict === 'done' && isMessageGroup(group))
307
- this.finishMessage(group, report.summary);
308
- else if (report.verdict === 'done' && isSplitGroup(group))
309
- this.finishSplit(group, attempt);
310
- else if (report.verdict === 'done')
311
- this.finishStep(group, attempt, report);
312
- else if (report.verdict === 'rejected')
313
- this.rejected(group, attempt, report.feedback ?? '');
314
- else {
315
- this.askHuman(group, attempt.stepIndex, report.feedback ?? '', report.questions ?? null, report.humanOnly ? 'request' : null);
316
- }
317
- }
318
- /** `done` of an ordinary step: on to the next one, or first to a review by a person. */
319
- finishStep(group, attempt, report) {
320
- const step = stepsOf(this.state.run, group)[attempt.stepIndex];
321
- if (step?.humanReview && !attempt.input.reviewed) {
322
- this.askHuman(group, attempt.stepIndex, reviewQuestion(attemptStepLabel(this.state, group, attempt), report.summary), null, 'review');
323
- return;
324
- }
325
- this.advance(group, attempt.stepIndex);
326
- }
327
- finishSplit(split, attempt) {
328
- const proposal = attempt.proposal;
329
- if (!proposal || proposal.length === 0) {
330
- attempt.status = 'failed';
331
- attempt.reason = { kind: 'no_groups' };
332
- this.failGroup(split, { kind: 'no_groups' });
333
- return;
334
- }
335
- const slugs = groupSlugs(proposal.map((group) => group.title));
336
- this.state.groups = proposal.map((group, index) => newGroup(slugs[index] ?? `group-${index + 1}`, group.title, group.task, index));
337
- split.status = 'merged';
338
- split.pending = null;
339
- // The groups wait in `queued` for the actions after the split.
340
- enterPoint(this.state, 'after_split');
341
- }
342
- /** A specialist reported on its pipeline action. */
343
- finishAction(group, attempt, report) {
344
- if (report.verdict === 'done') {
345
- group.status = 'merged';
346
- group.pending = null;
347
- group.reason = null;
348
- return;
349
- }
350
- if (report.verdict === 'rejected') {
351
- const detail = (report.feedback ?? report.summary).trim();
352
- this.restorePending(group);
353
- group.status = 'failed';
354
- group.reason = `reported rejected${detail ? `: ${detail.split('\n')[0]}` : ''}`;
355
- return;
356
- }
357
- this.askHuman(group, attempt.stepIndex, report.feedback ?? '', report.questions ?? null, report.humanOnly ? 'request' : null);
358
- }
359
- /** A command action ended; the daemon says how. */
360
- actionFinished(slug, seq, outcome) {
361
- const group = this.group(slug);
362
- const attempt = this.running(group, seq);
363
- if (!attempt)
364
- return;
365
- attempt.finishedAt = this.now;
366
- if (outcome.kind === 'exit' && outcome.code === 0) {
367
- attempt.status = 'finished';
368
- attempt.report = { verdict: 'done', summary: 'exit code 0', feedback: null };
369
- group.status = 'merged';
370
- group.pending = null;
371
- group.reason = null;
372
- const point = actionPointOf(group);
373
- if (point === 'before_split' || point === 'after_split') {
374
- this.effects.push({
375
- kind: 'commit',
376
- run: this.state.run.id,
377
- group: slug,
378
- stepId: attempt.stepId,
379
- summary: `action ${attempt.stepId}`,
380
- });
381
- }
382
- return;
383
- }
384
- const reason = outcome.kind === 'exit'
385
- ? { kind: 'exit_code', code: outcome.code }
386
- : outcome.kind === 'timeout'
387
- ? { kind: 'timeout' }
388
- : { kind: 'spawn', message: outcome.message };
389
- attempt.status = 'failed';
390
- attempt.reason = reason;
391
- this.failGroup(group, reason);
392
- }
393
- finishResolve(group, report) {
394
- group.pending = null;
395
- if (report.verdict === 'done') {
396
- group.status = 'merged';
397
- this.effects.push(...resolverDone(this.state));
398
- return;
399
- }
400
- const detail = (report.feedback ?? report.summary).trim();
401
- group.status = 'failed';
402
- group.reason = `resolver reported ${report.verdict}`;
403
- this.effects.push(...finishDelivery(this.state, {
404
- kind: 'failed',
405
- message: `the resolver reported ${report.verdict}${detail ? `: ${detail}` : ''}`,
406
- }, this.now));
407
- }
408
- /** The observer reported. A delivery repair is closed by the delivery that follows `done`. */
409
- finishRepair(group, report) {
410
- group.pending = null;
411
- const incident = this.state.run.repair.incident;
412
- const taken = incident ? [incident.key] : [];
413
- if (report.verdict === 'done') {
414
- group.status = 'merged';
415
- group.reason = null;
416
- if (this.state.run.pendingDelivery?.repair) {
417
- this.effects.push(...resolverDone(this.state));
418
- return;
419
- }
420
- closeRepair(this.state, { taken, refund: false });
421
- return;
422
- }
423
- const detail = (report.feedback ?? report.summary).trim();
424
- group.status = 'failed';
425
- group.reason = `observer reported ${report.verdict}${detail ? `: ${detail.split('\n')[0]}` : ''}`;
426
- if (this.state.run.pendingDelivery?.repair) {
427
- this.effects.push(...finishDelivery(this.state, {
428
- kind: 'failed',
429
- message: `the observer reported ${report.verdict}${detail ? `: ${detail}` : ''}`,
430
- }, this.now));
431
- return;
432
- }
433
- closeRepair(this.state, { taken, refund: false });
434
- }
435
- repairStart(incident, specialist) {
436
- const { run } = this.state;
437
- if (run.repair.incident !== null)
438
- throw new Rejection('a repair of this run is already going');
439
- if (run.hold !== null)
440
- throw new Rejection(`run is ${run.hold}; observers do not take it`);
441
- if (incident.kind === 'delivery') {
442
- if (run.pendingDelivery !== null) {
443
- throw new Rejection(`a delivery of run ${run.id} is already in progress`);
444
- }
445
- const groups = this.state.groups.filter((group) => group.status === 'merged' && group.delivery.state === 'apply_failed');
446
- if (groups.length === 0)
447
- throw new Rejection('no delivery to repair');
448
- run.repair.incident = incident;
449
- run.repair.specialist = specialist;
450
- run.repair.repairs += 1;
451
- run.pendingDelivery = {
452
- groups: groups.map((group) => group.slug),
453
- force: false,
454
- auto: false,
455
- round: 1,
456
- repair: true,
457
- message: renderCommitMessage(run.config.delivery.commitMessage, this.state, groups),
458
- };
459
- this.effects.push({
460
- kind: 'prepare_resolve',
461
- run: run.id,
462
- groups: run.pendingDelivery.groups,
463
- round: 1,
464
- });
465
- return;
466
- }
467
- run.repair.incident = incident;
468
- run.repair.specialist = specialist;
469
- run.repair.repairs += 1;
470
- openRepairGroup(this.state, repairTask(this.state, incident));
471
- }
472
- repairAllowed(allowed) {
473
- const { repair } = this.state.run;
474
- if (allowed === repair.allowed)
475
- return;
476
- repair.allowed = allowed;
477
- if (!allowed) {
478
- this.stopRepair({ reason: null, refund: false });
479
- return;
480
- }
481
- // Returning the task to observers starts its count again.
482
- repair.repairs = 0;
483
- repair.taken = [];
484
- }
485
- /**
486
- * Ends the repair that goes on: the agent stops, the group is cancelled with `reason` and the
487
- * incident is released. Nothing happens when no repair goes on.
488
- */
489
- stopRepair(options) {
490
- if (this.state.run.repair.incident === null)
491
- return;
492
- if (options.reason === 'paused')
493
- this.pausedRepair = true;
494
- const group = this.state.repair;
495
- if (group && !isTerminal(group.status)) {
496
- group.status = 'cancelled';
497
- group.pending = null;
498
- if (options.reason !== null)
499
- group.reason = options.reason;
500
- for (const attempt of group.attempts) {
501
- if (attempt.status !== 'running')
502
- continue;
503
- attempt.status = 'cancelled';
504
- attempt.finishedAt = this.now;
505
- this.effects.push({
506
- kind: 'stop_attempt',
507
- run: this.state.run.id,
508
- group: group.slug,
509
- seq: attempt.seq,
510
- });
511
- }
512
- }
513
- closeRepair(this.state, { taken: [], refund: options.refund });
514
- }
515
- finishMessage(group, summary) {
516
- if (summary !== null) {
517
- group.status = 'merged';
518
- group.pending = null;
519
- }
520
- this.effects.push(...finishMessage(this.state, summary));
521
- }
522
- /**
523
- * Moves the pipeline after an event: a delivery waits for the actions before it, and the run is
524
- * cleaned up once the actions after delivery are done.
525
- */
526
- pipeline(wasDone) {
527
- this.effects.push(...advanceChecks(this.state));
528
- if (!wasDone && afterDeliveryDone(this.state) && !this.state.run.config.delivery.keep) {
529
- this.effects.push({ kind: 'cleanup', run: this.state.run.id });
530
- }
531
- }
532
- autoDeliver() {
533
- // A check that failed or was cancelled stops the pipeline: only an explicit request starts it again.
534
- if (this.checksCancelled || pointStalled(this.state, 'before_delivery'))
535
- return;
536
- if (!this.state.groups.some((group) => group.status === 'merged' && group.delivery.state === 'pending')) {
537
- return;
538
- }
539
- try {
540
- this.effects.push(...requestDelivery(this.state, { groups: null, force: false, files: [], auto: true }));
541
- }
542
- catch (error) {
543
- if (!(error instanceof Rejection))
544
- throw error;
545
- }
546
- }
547
- advance(group, current) {
548
- const next = current + 1;
549
- if (next < stepsOf(this.state.run, group).length) {
550
- group.status = 'queued';
551
- group.pending = freshPending(next);
552
- }
553
- else {
554
- this.enqueueMerge(group, false);
555
- }
556
- }
557
- rejected(group, attempt, feedback) {
558
- const steps = stepsOf(this.state.run, group);
559
- const onReject = steps[attempt.stepIndex]?.onReject ?? null;
560
- if (onReject === null) {
561
- this.askHuman(group, attempt.stepIndex, feedback, null);
562
- return;
563
- }
564
- const rounds = (group.rejections[attempt.stepId] ?? 0) + 1;
565
- if (rounds > onReject.maxRounds) {
566
- this.askHuman(group, attempt.stepIndex, `Step \`${attemptStepLabel(this.state, group, attempt)}\` rejected the work ${rounds} times (limit ${onReject.maxRounds}). Last feedback:\n${feedback}`, null);
567
- return;
568
- }
569
- group.rejections[attempt.stepId] = rounds;
570
- group.status = 'queued';
571
- group.pending = {
572
- stepIndex: steps.findIndex((step) => step.id === onReject.goto),
573
- feedback,
574
- humanAnswer: null,
575
- resume: false,
576
- };
577
- }
578
- askHuman(group, step, question, questions, humanOnly = null) {
579
- group.status = 'needs_human';
580
- group.question = question;
581
- group.questions = questions;
582
- group.humanOnly = humanOnly;
583
- group.pending = { stepIndex: step, feedback: null, humanAnswer: null, resume: true };
584
- }
585
- restorePending(group) {
586
- const last = group.attempts.at(-1);
587
- if (group.pending === null && last) {
588
- group.pending = {
589
- stepIndex: last.stepIndex,
590
- feedback: last.input.feedback,
591
- humanAnswer: last.input.humanAnswer,
592
- resume: false,
593
- ...(last.input.reviewed ? { reviewed: true } : {}),
594
- };
595
- }
596
- }
597
- /** The group waits in `queued` for the same step; the scheduler holds it until the limit resets. */
598
- waitForLimit(group, attempt) {
599
- if (isTerminal(group.status))
600
- return;
601
- group.pending = {
602
- stepIndex: attempt.stepIndex,
603
- feedback: attempt.input.feedback,
604
- humanAnswer: attempt.input.humanAnswer,
605
- resume: attempt.sessionId !== null,
606
- ...(attempt.input.reviewed ? { reviewed: true } : {}),
607
- };
608
- group.status = 'queued';
609
- group.reason = null;
610
- }
611
- failGroup(group, reason) {
612
- if (isTerminal(group.status))
613
- return;
614
- this.restorePending(group);
615
- group.status = 'failed';
616
- group.reason = describeFailReason(reason);
617
- if (isMessageGroup(group))
618
- this.finishMessage(group, null);
619
- if (isRepairGroup(group)) {
620
- // A crash, a timeout or an interruption: the incident is taken again; a usage limit gives
621
- // the repair back and does not wait.
622
- group.pending = null;
623
- closeRepair(this.state, { taken: [], refund: reason.kind === 'usage_limit' });
624
- }
625
- if (isResolveGroup(group)) {
626
- group.pending = null;
627
- this.effects.push(...finishDelivery(this.state, {
628
- kind: 'failed',
629
- message: `the resolver failed: ${describeFailReason(reason)}`,
630
- }, this.now));
631
- }
632
- }
633
- timedOut(slug, seq) {
634
- const group = this.group(slug);
635
- const attempt = this.running(group, seq);
636
- if (!attempt || attempt.reason?.kind === 'message' || attempt.reason?.kind === 'paused') {
637
- return;
638
- }
639
- attempt.status = 'failed';
640
- attempt.reason = { kind: 'timeout' };
641
- attempt.finishedAt = this.now;
642
- this.effects.push({ kind: 'stop_attempt', run: this.state.run.id, group: slug, seq });
643
- this.failGroup(group, { kind: 'timeout' });
644
- }
645
- message(slug, seq, text) {
646
- const group = this.group(slug);
647
- const attempt = this.running(group, seq);
648
- if (!attempt)
649
- throw new Rejection(`attempt ${seq} is not running`);
650
- if (attempt.runtime === 'command') {
651
- throw new Rejection(`attempt ${seq} is a command; it takes no messages`);
652
- }
653
- if (attempt.report !== null)
654
- throw new Rejection(`attempt ${seq} already reported`);
655
- if (attempt.reason !== null) {
656
- throw new Rejection(`attempt ${seq} is already being interrupted`);
657
- }
658
- attempt.reason = { kind: 'message', text, at: this.now };
659
- this.effects.push({ kind: 'stop_attempt', run: this.state.run.id, group: slug, seq });
660
- }
661
- /** The attempt stopped because of a human message: the step goes on in the same session. */
662
- continueAfterMessage(group, attempt, reason) {
663
- attempt.status = 'cancelled';
664
- attempt.finishedAt ??= this.now;
665
- group.pending = {
666
- ...freshPending(attempt.stepIndex),
667
- resume: true,
668
- message: { text: reason.text, at: reason.at },
669
- ...(attempt.input.reviewed ? { reviewed: true } : {}),
670
- };
671
- group.status = 'queued';
672
- }
673
- /** The attempt stopped because of a pause: the step goes on in the same session. */
674
- continueAfterPause(group, attempt) {
675
- attempt.status = 'cancelled';
676
- attempt.finishedAt ??= this.now;
677
- this.waitForLimit(group, attempt);
678
- }
679
- cancel(only, reason) {
680
- if (only === REPAIR_GROUP && this.state.repair === null) {
681
- // The tree of a delivery repair is still being prepared: there is no group to cancel yet.
682
- this.stopRepair({ reason: null, refund: false });
683
- return;
684
- }
685
- const groups = only === null ? allGroups(this.state) : [this.group(only)];
686
- for (const group of groups) {
687
- // A failed action can be cancelled by name: that releases the pipeline held by it.
688
- const failedAction = only !== null && isActionGroup(group) && group.status === 'failed';
689
- if (isTerminal(group.status) && !failedAction)
690
- continue;
691
- group.status = 'cancelled';
692
- if (reason !== undefined)
693
- group.reason = reason;
694
- group.mergeInFlight = false;
695
- if (isMessageGroup(group) || isResolveGroup(group))
696
- cancelDelivery(this.state);
697
- for (const attempt of group.attempts) {
698
- if (attempt.status !== 'running')
699
- continue;
700
- attempt.status = 'cancelled';
701
- attempt.finishedAt = this.now;
702
- this.effects.push({
703
- kind: 'stop_attempt',
704
- run: this.state.run.id,
705
- group: group.slug,
706
- seq: attempt.seq,
707
- });
708
- }
709
- }
710
- if (only === null || only === REPAIR_GROUP) {
711
- if (only === null && reason !== undefined)
712
- this.state.run.repair.cancelReason = reason;
713
- this.stopRepair({ reason: null, refund: false });
714
- }
715
- // Cancelling the whole run also cancels a delivery that waits for the checks, even when the
716
- // cancelled checks do not stop the pipeline.
717
- if (only === null && this.state.run.pendingDelivery?.checks) {
718
- cancelDelivery(this.state);
719
- this.checksCancelled = true;
720
- }
721
- }
722
- stepSkip(step, skip) {
723
- const { run } = this.state;
724
- const steps = groupPipeline(run.config, runPipeline(run)).steps;
725
- const index = steps.findIndex((candidate) => candidate.id === step);
726
- if (index === -1) {
727
- throw new Rejection(`unknown step \`${step}\`; steps: ${steps.map((candidate) => candidate.id).join(', ')}`);
728
- }
729
- if (stepStates(this.state)[index]?.state === 'done') {
730
- throw new Rejection(`step \`${step}\` is already passed by every group`);
731
- }
732
- const current = run.skippedSteps.includes(step);
733
- if (skip === current)
734
- return;
735
- const wanted = skip
736
- ? [...run.skippedSteps, step]
737
- : run.skippedSteps.filter((item) => item !== step);
738
- if (skip) {
739
- const error = checkSkip(run.config, run.pipeline, wanted);
740
- if (error !== null)
741
- throw new Rejection(error);
742
- }
743
- run.skippedSteps = steps.map((item) => item.id).filter((id) => wanted.includes(id));
744
- if (!skip)
745
- return;
746
- for (const group of this.state.groups) {
747
- const running = group.attempts.find((attempt) => attempt.status === 'running' && attempt.stepIndex === index);
748
- if (running) {
749
- running.status = 'cancelled';
750
- running.reason = { kind: 'skipped' };
751
- running.finishedAt = this.now;
752
- this.effects.push({
753
- kind: 'stop_attempt',
754
- run: run.id,
755
- group: group.slug,
756
- seq: running.seq,
757
- });
758
- group.status = 'queued';
759
- group.pending = {
760
- stepIndex: index,
761
- feedback: running.input.feedback,
762
- humanAnswer: null,
763
- resume: false,
764
- };
765
- }
766
- else if (group.status === 'needs_human' && group.pending?.stepIndex === index) {
767
- group.status = 'queued';
768
- group.question = null;
769
- group.questions = null;
770
- group.humanOnly = null;
771
- group.pending = { ...group.pending, humanAnswer: null, resume: false };
772
- }
773
- }
774
- }
775
- /** A queued group never waits on a skipped step: it moves on, or goes to the merge. */
776
- skipAhead() {
777
- const { run } = this.state;
778
- if (run.skippedSteps.length === 0)
779
- return;
780
- for (const group of this.state.groups) {
781
- if (group.status !== 'queued' || group.pending === null)
782
- continue;
783
- const step = stepsOf(run, group)[group.pending.stepIndex];
784
- if (!step || !run.skippedSteps.includes(step.id))
785
- continue;
786
- const next = nextUnskipped(run, group, group.pending.stepIndex + 1);
787
- if (next === null) {
788
- this.enqueueMerge(group, false);
789
- }
790
- else {
791
- group.pending = {
792
- stepIndex: next,
793
- feedback: group.pending.feedback,
794
- humanAnswer: null,
795
- resume: false,
796
- };
797
- }
798
- }
799
- }
800
- retry(slug, permissions, specialists) {
801
- const group = this.group(slug);
802
- if (group.status === 'failed' || group.status === 'cancelled')
803
- this.rejectDeliveryRetry(group);
804
- if (group.status === 'failed') {
805
- group.status = 'queued';
806
- group.reason = null;
807
- }
808
- else if (group.status === 'conflict') {
809
- this.enqueueMerge(group, true);
810
- }
811
- else if (group.status === 'cancelled') {
812
- this.retryCancelled(group);
813
- }
814
- else {
815
- throw wrongStatus(group, 'retry', 'failed, cancelled or conflict');
816
- }
817
- // After every check: a refused retry leaves the snapshot as it was.
818
- if (specialists) {
819
- const changes = refreshSpecialists(this.state.run.config, specialists);
820
- group.warnings.push(`config refreshed: ${changes.length > 0 ? changes.join('; ') : 'no changes'}`);
821
- }
822
- else {
823
- this.refresh(group, permissions);
824
- }
825
- }
826
- rejectDeliveryRetry(group) {
827
- if (isMessageGroup(group) || isResolveGroup(group)) {
828
- throw new Rejection(`group ${group.slug} is ${group.status}; delivery is retried with \`aip run apply\``);
829
- }
830
- if (isRepairGroup(group)) {
831
- throw new Rejection(`group ${group.slug} is ${group.status}; observers take a repair again`);
832
- }
833
- }
834
- retryCancelled(group) {
835
- group.reason = null;
836
- if (group.question !== null) {
837
- group.status = 'needs_human';
838
- return;
839
- }
840
- const last = group.attempts.at(-1);
841
- if (group.pending === null &&
842
- last &&
843
- !isServiceGroup(group) &&
844
- attemptVerdict(last) === 'done' &&
845
- last.stepIndex + 1 >= stepsOf(this.state.run, group).length) {
846
- this.enqueueMerge(group, false);
847
- return;
848
- }
849
- this.restorePending(group);
850
- group.status = 'queued';
851
- }
852
- /** Takes the permissions of the current configuration into the snapshot of the run. */
853
- refresh(group, permissions) {
854
- if (!permissions)
855
- return;
856
- const error = refreshPermissions(this.state.run.config, permissions);
857
- if (error !== null)
858
- group.warnings.push(`permissions not refreshed: ${error}`);
859
- }
860
- answer(slug, answer, by, permissions) {
861
- if (answer.trim() === '')
862
- throw new Rejection('answer must not be empty');
863
- const group = this.group(slug);
864
- if (group.status !== 'needs_human')
865
- throw wrongStatus(group, 'answer', 'needs_human');
866
- this.refresh(group, permissions);
867
- const last = group.attempts.at(-1);
868
- const asking = last && last.stepIndex === group.pending?.stepIndex ? last : undefined;
869
- const stepId = asking?.stepId ??
870
- group.attempts.find((candidate) => candidate.stepIndex === group.pending?.stepIndex)
871
- ?.stepId ??
872
- last?.stepId ??
873
- '';
874
- group.decisions.push({
875
- stepId,
876
- question: group.question ?? '',
877
- answer,
878
- by,
879
- ...(asking ? { attemptSeq: asking.seq } : {}),
880
- });
881
- group.status = 'queued';
882
- group.question = null;
883
- group.questions = null;
884
- if (group.pending) {
885
- group.pending.humanAnswer = answer;
886
- if (group.humanOnly === 'review')
887
- group.pending.reviewed = true;
888
- }
889
- group.humanOnly = null;
890
- }
891
- enqueueMerge(group, updateOnConflict) {
892
- group.status = 'merging';
893
- group.pending = null;
894
- group.mergeSeq = this.state.run.nextMergeSeq;
895
- this.state.run.nextMergeSeq += 1;
896
- group.mergeInFlight = false;
897
- group.updateOnConflict = updateOnConflict;
898
- }
899
- mergeFinished(slug, outcome) {
900
- const group = this.group(slug);
901
- if (group.status !== 'merging' || !group.mergeInFlight)
902
- return;
903
- group.mergeInFlight = false;
904
- group.updateOnConflict = false;
905
- switch (outcome.kind) {
906
- case 'merged':
907
- group.status = 'merged';
908
- group.mergeCommit = outcome.commit;
909
- group.conflictFiles = [];
910
- group.reason = null;
911
- break;
912
- case 'conflict':
913
- group.status = 'conflict';
914
- group.conflictFiles = outcome.files;
915
- group.reason = `merge conflict in ${outcome.files.join(', ')}`;
916
- break;
917
- case 'conflict_updated':
918
- group.status = 'queued';
919
- group.conflictFiles = outcome.files;
920
- group.reason = null;
921
- group.pending = {
922
- stepIndex: lastUnskipped(this.state.run, group),
923
- feedback: `The branch of this group was updated from the run branch and has merge conflicts in: ${outcome.files.join(', ')}. Resolve every conflict, keep the intent of both sides, and report done.`,
924
- humanAnswer: null,
925
- resume: false,
926
- };
927
- break;
928
- case 'failed':
929
- this.failGroup(group, { kind: 'git', message: outcome.message });
930
- break;
931
- }
932
- }
933
- startNextMerge() {
934
- if (this.state.groups.some((group) => group.mergeInFlight))
935
- return;
936
- if (deliveryCheckActive(this.state))
937
- return;
938
- const next = this.state.groups
939
- .filter((group) => group.status === 'merging')
940
- .sort((left, right) => (left.mergeSeq ?? 0) - (right.mergeSeq ?? 0))[0];
941
- if (!next)
942
- return;
943
- next.mergeInFlight = true;
944
- this.effects.push({
945
- kind: 'merge',
946
- run: this.state.run.id,
947
- group: next.slug,
948
- updateOnConflict: next.updateOnConflict,
949
- });
950
- }
951
- interrupted() {
952
- // Whatever the delivery was doing (git work, the message writer, the resolver) died with
953
- // the old daemon; drop it before failing its service groups, then start it again.
954
- const delivery = this.state.run.pendingDelivery;
955
- this.state.run.pendingDelivery = null;
956
- for (const group of allGroups(this.state)) {
957
- let wasRunning = false;
958
- for (const attempt of group.attempts) {
959
- if (attempt.status !== 'running')
960
- continue;
961
- if (attempt.reason?.kind === 'message') {
962
- this.continueAfterMessage(group, attempt, attempt.reason);
963
- continue;
964
- }
965
- if (attempt.reason?.kind === 'paused') {
966
- this.continueAfterPause(group, attempt);
967
- continue;
968
- }
969
- attempt.status = 'failed';
970
- attempt.reason = { kind: 'interrupted' };
971
- attempt.finishedAt = this.now;
972
- wasRunning = true;
973
- }
974
- group.mergeInFlight = false;
975
- if (wasRunning)
976
- this.failGroup(group, { kind: 'interrupted' });
977
- }
978
- if (delivery?.repair) {
979
- // A repair delivery is not resumed: the incident is taken again.
980
- const group = this.state.repair;
981
- if (group && !isTerminal(group.status)) {
982
- group.status = 'failed';
983
- group.reason = 'interrupted';
984
- group.pending = null;
985
- }
986
- closeRepair(this.state, { taken: [], refund: false });
987
- return;
988
- }
989
- if (delivery?.checks) {
990
- if (pointStalled(this.state, 'before_delivery')) {
991
- for (const group of actionGroupsOf(this.state, 'before_delivery')) {
992
- if (group.status !== 'queued')
993
- continue;
994
- group.status = 'cancelled';
995
- group.reason = 'delivery interrupted';
996
- }
997
- }
998
- else {
999
- // The interrupted check may fail without stopping the pipeline: the delivery goes on
1000
- // after the remaining checks, without entering the point (and running the command) again.
1001
- this.state.run.pendingDelivery = delivery;
1002
- }
1003
- }
1004
- // An interrupted action before delivery is not started again: the delivery waits for a new request.
1005
- if (delivery && !delivery.checks && pointClosed(this.state, 'before_delivery')) {
1006
- try {
1007
- this.effects.push(...requestDelivery(this.state, {
1008
- groups: delivery.groups,
1009
- force: delivery.force,
1010
- files: delivery.files ?? [],
1011
- auto: delivery.auto,
1012
- }, { resume: true }));
1013
- }
1014
- catch (error) {
1015
- if (!(error instanceof Rejection))
1016
- throw error;
1017
- }
1018
- }
1019
- }
1020
- }
1021
- //# sourceMappingURL=machine.js.map