@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,859 +0,0 @@
1
- import { DELIVERY_MODES } from '../config/index.js';
2
- import { Rejection } from './errors.js';
3
- import { RUN_TITLE_LIMIT, queueItemId } from './ids.js';
4
- import { retryableGroups } from './retryable.js';
5
- import { cleanSkip } from './skip.js';
6
- import { mergeTags } from './tags.js';
7
- import { ON_LIMIT_MODES, RECOMMENDATION_LIMIT, actionClosed, allGroups, finishedApartFromRepair, isRepairGroup, runPhase, } from './model.js';
8
- import { limitResetsAt } from './scheduler.js';
9
- export { retryableGroups };
10
- export const QUEUE_PARALLEL_MAX = 20;
11
- /** The most runs the queue remembers as skipped. */
12
- export const QUEUE_SKIPPED_MAX = 10;
13
- /** The most answers in a row the autopilot gives to one group. */
14
- export const AUTOPILOT_ANSWERS_MAX = 3;
15
- /** The answer of the autopilot when the queue has no text of its own. */
16
- export const DEFAULT_AUTOPILOT_ANSWER = 'I agree with your recommendations; go ahead with them. Where you gave no recommendation, choose the option you consider best and continue without asking again.';
17
- /**
18
- * Problems that stop the queue; a question to a human does not, a usage limit stops it its own
19
- * way, and a manual cancel does not either: the user did it on purpose.
20
- */
21
- const STOPPING_REASONS = new Set([
22
- 'failed',
23
- 'conflict',
24
- 'apply_failed',
25
- ]);
26
- /** Problems that `skipFailed` takes off the places: neither a cancel nor a usage limit. */
27
- const SKIPPED_REASONS = new Set([
28
- 'failed',
29
- 'conflict',
30
- 'apply_failed',
31
- ]);
32
- /** Problems that block the tasks depending on the run. */
33
- const BLOCKING_REASONS = new Set([
34
- ...STOPPING_REASONS,
35
- 'cancelled',
36
- 'usage_limit',
37
- ]);
38
- export function emptyQueue(repository, now, nextNumber = 1) {
39
- return {
40
- repository,
41
- status: 'stopped',
42
- parallel: 1,
43
- autopilot: false,
44
- autoAnswer: false,
45
- skipFailed: false,
46
- autopilotAnswer: null,
47
- onLimit: 'wait',
48
- items: [],
49
- nextNumber,
50
- runs: [],
51
- priority: [],
52
- acknowledged: [],
53
- skipped: [],
54
- stop: null,
55
- updatedAt: now,
56
- };
57
- }
58
- function cleanTitle(title) {
59
- if (title === undefined || title === null)
60
- return null;
61
- const trimmed = title.trim();
62
- if (trimmed === '')
63
- throw new Rejection('title must not be empty');
64
- if ([...trimmed].length > RUN_TITLE_LIMIT) {
65
- throw new Rejection(`title must be at most ${RUN_TITLE_LIMIT} characters`);
66
- }
67
- return trimmed;
68
- }
69
- function cleanGroups(groups) {
70
- if (groups.length === 0)
71
- throw new Rejection('groups must not be empty');
72
- return groups.map((group) => {
73
- const title = group.title.trim();
74
- const task = group.task.trim();
75
- if (title === '')
76
- throw new Rejection('a group title must not be empty');
77
- if (task === '')
78
- throw new Rejection(`group \`${title}\` has an empty task`);
79
- return { title, task };
80
- });
81
- }
82
- /** Validates the task or the groups: exactly one of them. */
83
- function cleanBody(fields) {
84
- if ((fields.task === undefined) === (fields.groups === undefined)) {
85
- throw new Rejection('pass either task or groups');
86
- }
87
- if (fields.task !== undefined) {
88
- const task = fields.task.trim();
89
- if (task === '')
90
- throw new Rejection('task must not be empty');
91
- return { task, groups: null };
92
- }
93
- return { task: null, groups: cleanGroups(fields.groups ?? []) };
94
- }
95
- function cleanPipeline(pipeline) {
96
- if (pipeline.trim() === '')
97
- throw new Rejection('pipeline must not be empty');
98
- return pipeline;
99
- }
100
- function cleanDeliveryMode(mode) {
101
- if (mode === undefined || mode === null)
102
- return mode;
103
- if (!DELIVERY_MODES.includes(mode)) {
104
- throw new Rejection(`delivery mode must be one of: ${DELIVERY_MODES.join(', ')}`);
105
- }
106
- return mode;
107
- }
108
- /** An id for a return item made by the queue itself; free among the items. */
109
- function newItemId(queue, now) {
110
- let random = queue.items.length;
111
- let id = queueItemId(now, random);
112
- while (queue.items.some((item) => item.id === id)) {
113
- random += 1;
114
- id = queueItemId(now, random);
115
- }
116
- return id;
117
- }
118
- function find(queue, id) {
119
- const item = queue.items.find((candidate) => candidate.id === id);
120
- if (!item)
121
- throw new Rejection('unknown queue item');
122
- return item;
123
- }
124
- export function addItem(queue, fields, id, now) {
125
- const after = [...new Set(fields.after ?? [])];
126
- checkDependencies(queue, id, after);
127
- const item = {
128
- id,
129
- number: queue.nextNumber,
130
- pipeline: cleanPipeline(fields.pipeline),
131
- ...cleanBody(fields),
132
- title: cleanTitle(fields.title),
133
- autoDeliver: fields.autoDeliver ?? null,
134
- deliveryMode: cleanDeliveryMode(fields.deliveryMode) ?? null,
135
- tags: [...new Set(fields.tags ?? [])],
136
- skip: cleanSkip(fields.skip ?? []),
137
- after,
138
- postponed: fields.postponed ?? false,
139
- createdAt: now,
140
- error: null,
141
- run: null,
142
- };
143
- queue.items.push(item);
144
- queue.nextNumber += 1;
145
- queue.updatedAt = now;
146
- return item;
147
- }
148
- /** Rejects a patch of a returned run's item that changes more than its place and `after`; `skip` is allowed when `skipInRun`. */
149
- export function checkReturnedPatch(patch, skipInRun = false) {
150
- const { position: _position, after: _after, skip, ...rest } = patch;
151
- const others = skipInRun ? rest : { ...rest, skip };
152
- if (Object.values(others).some((value) => value !== undefined)) {
153
- throw new Rejection('a returned run keeps its own task');
154
- }
155
- }
156
- export function editItem(queue, id, patch, now) {
157
- const item = find(queue, id);
158
- if (item.run !== null)
159
- checkReturnedPatch(patch);
160
- if (patch.task !== undefined && patch.groups !== undefined) {
161
- throw new Rejection('pass either task or groups');
162
- }
163
- const body = patch.task !== undefined || patch.groups !== undefined
164
- ? cleanBody({ task: patch.task, groups: patch.groups })
165
- : null;
166
- const pipeline = patch.pipeline === undefined ? null : cleanPipeline(patch.pipeline);
167
- const title = patch.title === undefined ? undefined : cleanTitle(patch.title);
168
- if (patch.position !== undefined)
169
- checkPosition(queue, patch.position);
170
- const after = patch.after === undefined ? undefined : [...new Set(patch.after)];
171
- if (after !== undefined)
172
- checkDependencies(queue, id, after);
173
- const deliveryMode = cleanDeliveryMode(patch.deliveryMode);
174
- if (pipeline !== null)
175
- item.pipeline = pipeline;
176
- if (body)
177
- Object.assign(item, body);
178
- if (title !== undefined)
179
- item.title = title;
180
- if (patch.autoDeliver !== undefined)
181
- item.autoDeliver = patch.autoDeliver;
182
- if (deliveryMode !== undefined)
183
- item.deliveryMode = deliveryMode;
184
- if (patch.tags !== undefined)
185
- item.tags = [...new Set(patch.tags)];
186
- if (patch.skip !== undefined)
187
- item.skip = cleanSkip(patch.skip);
188
- if (after !== undefined)
189
- item.after = after;
190
- if (patch.postponed !== undefined)
191
- item.postponed = patch.postponed;
192
- const hadError = item.error !== null;
193
- item.error = null;
194
- if (patch.position !== undefined)
195
- placeItem(queue, item, patch.position);
196
- else if (hadError)
197
- placeItem(queue, item, 1);
198
- queue.updatedAt = now;
199
- return item;
200
- }
201
- /**
202
- * Tags of the predecessors in `after`, in the order of the references, without
203
- * repeats: the tags of a queue item, or `runTags(id)` for a run (unknown: none).
204
- */
205
- export function dependencyTags(queue, after, runTags) {
206
- return mergeTags(...after.map((ref) => queue.items.find((item) => item.id === ref)?.tags ?? runTags(ref) ?? []));
207
- }
208
- /**
209
- * Appends the tags `added` to every waiting item that depends on `source` (an
210
- * item or a run) directly or through a chain of items. Returns the ids of the
211
- * changed items; a cycle in the data does not loop.
212
- */
213
- export function spreadTags(queue, source, added, now) {
214
- if (added.length === 0)
215
- return [];
216
- const reached = new Set([source]);
217
- const changed = [];
218
- let grew = true;
219
- while (grew) {
220
- grew = false;
221
- for (const item of queue.items) {
222
- if (reached.has(item.id) || !item.after.some((ref) => reached.has(ref)))
223
- continue;
224
- reached.add(item.id);
225
- grew = true;
226
- const next = mergeTags(item.tags, added);
227
- if (next.length !== item.tags.length) {
228
- item.tags = next;
229
- changed.push(item.id);
230
- }
231
- }
232
- }
233
- if (changed.length > 0)
234
- queue.updatedAt = now;
235
- return changed;
236
- }
237
- /** The return item of a run: the queue item that retries it when taken; null when there is none. */
238
- export function returnItemOf(queue, run) {
239
- return queue.items.find((item) => item.run === run) ?? null;
240
- }
241
- export function removeItem(queue, id, now, lookup) {
242
- const item = find(queue, id);
243
- if (item.run !== null) {
244
- const state = lookup?.(item.run);
245
- if (state && state.run.hold !== null && state.run.finishedAt === null) {
246
- throw new Rejection(`a ${state.run.hold} run stays in the queue; continue or cancel it`);
247
- }
248
- }
249
- queue.items = queue.items.filter((candidate) => candidate !== item);
250
- for (const other of queue.items)
251
- other.after = other.after.filter((ref) => ref !== id);
252
- queue.updatedAt = now;
253
- }
254
- /**
255
- * Rejects a dependency list of item `id` (not in the queue yet when adding) that
256
- * points at the item itself or closes a cycle. Runs have no dependencies, so a
257
- * cycle can only pass through items.
258
- */
259
- export function checkDependencies(queue, id, after) {
260
- if (after.includes(id))
261
- throw new Rejection('a task cannot depend on itself');
262
- const refs = (item) => item === id ? after : (queue.items.find((candidate) => candidate.id === item)?.after ?? []);
263
- const walk = (current, path) => {
264
- for (const next of refs(current)) {
265
- if (next === id)
266
- return [...path, next];
267
- if (path.includes(next))
268
- continue;
269
- if (!queue.items.some((candidate) => candidate.id === next))
270
- continue;
271
- const found = walk(next, [...path, next]);
272
- if (found)
273
- return found;
274
- }
275
- return null;
276
- };
277
- const cycle = walk(id, [id]);
278
- if (cycle)
279
- throw new Rejection(`dependency cycle: ${cycle.join(' → ')}`);
280
- }
281
- /** A run is done when it is finished and every work group is merged and applied. */
282
- export function runDone(state) {
283
- return (runPhase(state) === 'finished' &&
284
- state.groups.length > 0 &&
285
- state.groups.every((group) => group.status === 'merged' && group.delivery.state === 'applied'));
286
- }
287
- export function dependencyState(queue, ref, lookup, seen = new Set()) {
288
- if (seen.has(ref))
289
- return 'waiting';
290
- const item = queue.items.find((candidate) => candidate.id === ref);
291
- if (item) {
292
- return itemReadiness(queue, item, lookup, new Set([...seen, ref])) === 'blocked'
293
- ? 'blocked'
294
- : 'waiting';
295
- }
296
- const state = lookup(ref);
297
- if (!state)
298
- return 'blocked';
299
- if (state.run.hold !== null)
300
- return 'waiting';
301
- if (runProblems(state).some((problem) => BLOCKING_REASONS.has(problem.reason)))
302
- return 'blocked';
303
- return runDone(state) ? 'done' : 'waiting';
304
- }
305
- export function itemReadiness(queue, item, lookup, seen = new Set()) {
306
- const states = item.after.map((ref) => dependencyState(queue, ref, lookup, seen));
307
- if (states.includes('blocked'))
308
- return 'blocked';
309
- return states.every((state) => state === 'done') ? 'ready' : 'waiting';
310
- }
311
- export function checkPosition(queue, position) {
312
- if (!Number.isInteger(position) || position < 1 || position > queue.items.length) {
313
- throw new Rejection(`position must be an integer from 1 to ${queue.items.length}`);
314
- }
315
- }
316
- function placeItem(queue, item, position) {
317
- queue.items = queue.items.filter((candidate) => candidate !== item);
318
- queue.items.splice(position - 1, 0, item);
319
- }
320
- export function moveItem(queue, id, position, now) {
321
- const item = find(queue, id);
322
- checkPosition(queue, position);
323
- placeItem(queue, item, position);
324
- queue.updatedAt = now;
325
- }
326
- export function setParallel(queue, parallel, now) {
327
- if (!Number.isInteger(parallel) || parallel < 1 || parallel > QUEUE_PARALLEL_MAX) {
328
- throw new Rejection(`parallel must be an integer from 1 to ${QUEUE_PARALLEL_MAX}`);
329
- }
330
- queue.parallel = parallel;
331
- queue.updatedAt = now;
332
- }
333
- function cleanAnswer(answer) {
334
- if (answer === null)
335
- return null;
336
- const trimmed = answer.trim();
337
- if (trimmed === '')
338
- throw new Rejection('autopilot answer must not be empty');
339
- if ([...trimmed].length > RECOMMENDATION_LIMIT) {
340
- throw new Rejection(`autopilot answer must be at most ${RECOMMENDATION_LIMIT} characters`);
341
- }
342
- return trimmed;
343
- }
344
- /** Changes only the passed settings; the state of the queue stays as is. */
345
- export function setQueueSettings(queue, patch, now) {
346
- if (patch.parallel === undefined &&
347
- patch.autopilot === undefined &&
348
- patch.autoAnswer === undefined &&
349
- patch.skipFailed === undefined &&
350
- patch.autopilotAnswer === undefined &&
351
- patch.onLimit === undefined) {
352
- throw new Rejection('pass parallel, autopilot, autoAnswer, autopilotAnswer, skipFailed or onLimit');
353
- }
354
- if (patch.onLimit !== undefined && !ON_LIMIT_MODES.includes(patch.onLimit)) {
355
- throw new Rejection(`onLimit must be one of: ${ON_LIMIT_MODES.join(', ')}`);
356
- }
357
- const answer = patch.autopilotAnswer === undefined ? undefined : cleanAnswer(patch.autopilotAnswer);
358
- if (patch.parallel !== undefined)
359
- setParallel(queue, patch.parallel, now);
360
- if (patch.autopilot !== undefined)
361
- queue.autopilot = patch.autopilot;
362
- if (patch.autoAnswer !== undefined)
363
- queue.autoAnswer = patch.autoAnswer;
364
- if (patch.skipFailed !== undefined)
365
- queue.skipFailed = patch.skipFailed;
366
- if (answer !== undefined)
367
- queue.autopilotAnswer = answer;
368
- if (patch.onLimit !== undefined)
369
- queue.onLimit = patch.onLimit;
370
- queue.updatedAt = now;
371
- }
372
- /** Stops the queue; a queue stopped by a usage limit no longer starts by itself. */
373
- export function pauseQueue(queue, now) {
374
- queue.status = 'stopped';
375
- if (queue.stop?.kind === 'limit')
376
- queue.stop = { ...queue.stop, autoResume: false };
377
- queue.updatedAt = now;
378
- }
379
- /** When a queue stopped by a usage limit starts by itself; null when it does not. */
380
- export function queueWakeAt(queue) {
381
- return queue.status === 'stopped' && queue.stop?.kind === 'limit' && queue.stop.autoResume
382
- ? queue.stop.resetsAt
383
- : null;
384
- }
385
- /** Attempts of a run that ran out of the usage limit, each a problem of its own. */
386
- function limitHits(state) {
387
- // A limit of the observer's agent is not a limit of the run's work.
388
- return allGroups(state)
389
- .filter((group) => !isRepairGroup(group))
390
- .flatMap((group) => group.attempts.flatMap((attempt) => {
391
- const resetsAt = limitResetsAt(attempt);
392
- return resetsAt === null
393
- ? []
394
- : [
395
- {
396
- key: `${state.run.id}/${group.slug}/usage_limit/${attempt.seq}`,
397
- run: state.run.id,
398
- group: group.slug,
399
- runtime: attempt.runtime,
400
- resetsAt,
401
- },
402
- ];
403
- }));
404
- }
405
- /** Keys of every problem and usage limit of a run now. */
406
- export function problemKeys(state) {
407
- return [
408
- ...runProblems(state).map((problem) => problem.key),
409
- ...limitHits(state).map((hit) => hit.key),
410
- ];
411
- }
412
- /**
413
- * Problems of a run. The key includes the number of attempts, so a problem that
414
- * comes back after a retry is a new one even if nobody saw the state between.
415
- */
416
- export function runProblems(state) {
417
- const id = state.run.id;
418
- const problems = [];
419
- const work = [
420
- ...(state.split ? [state.split, ...state.groups] : state.groups),
421
- // A failure that the pipeline goes on after is not a problem.
422
- ...state.actions.filter((group) => group.status === 'needs_human' || !actionClosed(state.run, group)),
423
- ];
424
- for (const group of work) {
425
- const attempts = group.attempts.length;
426
- if (group.status === 'needs_human' ||
427
- group.status === 'failed' ||
428
- group.status === 'conflict') {
429
- const reason = group.status === 'failed' && group.attempts.at(-1)?.reason?.kind === 'usage_limit'
430
- ? 'usage_limit'
431
- : group.status;
432
- problems.push({
433
- key: `${id}/${group.slug}/${reason}/${attempts}`,
434
- run: id,
435
- group: group.slug,
436
- reason,
437
- });
438
- }
439
- if (group.status === 'merged' && group.delivery.state === 'apply_failed') {
440
- problems.push({
441
- key: `${id}/${group.slug}/apply_failed/${attempts}`,
442
- run: id,
443
- group: group.slug,
444
- reason: 'apply_failed',
445
- });
446
- }
447
- }
448
- if (runPhase(state) === 'cancelled') {
449
- const total = allGroups(state)
450
- .filter((group) => !isRepairGroup(group))
451
- .reduce((sum, group) => sum + group.attempts.length, 0);
452
- problems.push({
453
- key: `${id}/run/cancelled/${total}`,
454
- run: id,
455
- group: null,
456
- reason: 'cancelled',
457
- });
458
- }
459
- return problems;
460
- }
461
- /** A run keeps its place until it is finished and, with auto delivery, delivered. */
462
- export function occupiesSlot(state) {
463
- if (state.run.hold !== null)
464
- return false;
465
- if (!finishedApartFromRepair(state))
466
- return true;
467
- if (!state.run.config.delivery.auto)
468
- return false;
469
- // The delivery a repair started is the observer's, not the place's.
470
- return ((state.run.pendingDelivery !== null && !state.run.pendingDelivery.repair) ||
471
- state.groups.some((group) => group.status === 'merged' && group.delivery.state === 'pending'));
472
- }
473
- /**
474
- * The run a priority action would freeze: the last of the places that took one, skipping a run
475
- * that waits for a human, a finished run awaiting delivery, a held run, a priority run and
476
- * `claimant` itself. `null` when there is none.
477
- */
478
- export function freezeCandidate(queue, states, claimant) {
479
- const byId = new Map([...states].map((state) => [state.run.id, state]));
480
- for (const id of [...queue.runs].reverse()) {
481
- const state = byId.get(id);
482
- if (!state || id === claimant)
483
- continue;
484
- if (queue.priority.includes(id) || state.run.hold !== null)
485
- continue;
486
- if (finishedApartFromRepair(state))
487
- continue;
488
- if (allGroups(state).some((group) => group.status === 'needs_human'))
489
- continue;
490
- return id;
491
- }
492
- return null;
493
- }
494
- /**
495
- * Gives `run` a place as a priority run. When every place is taken and a run can be frozen, that
496
- * run leaves the places and its return item `itemId` goes first in the queue; its id is returned
497
- * and the caller sets `hold: frozen` on it. Without a candidate the run takes a place over
498
- * `parallel`.
499
- */
500
- export function claimPlace(queue, states, run, itemId, now) {
501
- let frozen = null;
502
- const list = [...states];
503
- const others = queue.runs.filter((id) => id !== run).length;
504
- if (others >= queue.parallel) {
505
- const candidate = freezeCandidate(queue, list, run);
506
- const state = candidate === null ? undefined : list.find((s) => s.run.id === candidate);
507
- if (candidate !== null && state) {
508
- queue.runs = queue.runs.filter((id) => id !== candidate);
509
- queue.priority = queue.priority.filter((id) => id !== candidate);
510
- queue.acknowledged = queue.acknowledged.filter((key) => !key.startsWith(`${candidate}/`));
511
- queue.items = queue.items.filter((item) => item.run !== candidate);
512
- queue.items.unshift(returnItem(state, itemId, now));
513
- frozen = candidate;
514
- }
515
- }
516
- if (!queue.runs.includes(run))
517
- queue.runs.push(run);
518
- if (!queue.priority.includes(run))
519
- queue.priority.push(run);
520
- queue.updatedAt = now;
521
- return frozen;
522
- }
523
- function queueStates(queue, states) {
524
- const wanted = new Set(queue.runs);
525
- return [...states].filter((state) => wanted.has(state.run.id));
526
- }
527
- /** Starts the queue; the problems that exist now become known. */
528
- export function startQueue(queue, states, now) {
529
- queue.status = 'running';
530
- queue.stop = null;
531
- for (const item of queue.items)
532
- item.error = null;
533
- const known = new Set(queue.acknowledged);
534
- for (const state of queueStates(queue, states)) {
535
- for (const key of problemKeys(state))
536
- known.add(key);
537
- }
538
- queue.acknowledged = [...known];
539
- queue.updatedAt = now;
540
- }
541
- /** Makes the current problems and usage limits of a run known to the queue. */
542
- export function acknowledgeRun(queue, state) {
543
- queue.acknowledged = [...new Set([...queue.acknowledged, ...problemKeys(state)])];
544
- }
545
- /**
546
- * A run revived by a direct retry joins the places of the queue, as with "run now". Returns
547
- * false and changes nothing for a run of another repository, a run that already holds a place or
548
- * is skipped, and a run that does not occupy a place. The queue state and its stop stay as they
549
- * are; `known` (problem keys from before the retry) and the current ones do not stop the queue.
550
- */
551
- export function adoptRun(queue, state, known, now, claim) {
552
- const id = state.run.id;
553
- if (state.run.repository !== queue.repository)
554
- return null;
555
- if (queue.runs.includes(id))
556
- return null;
557
- if (!occupiesSlot(state))
558
- return null;
559
- queue.items = queue.items.filter((item) => item.run !== id);
560
- queue.skipped = queue.skipped.filter((skipped) => skipped !== id);
561
- const frozen = claim ? claimPlace(queue, claim.states, id, claim.itemId, now) : null;
562
- if (!claim)
563
- queue.runs.push(id);
564
- queue.acknowledged = [...new Set([...queue.acknowledged, ...known, ...problemKeys(state)])];
565
- queue.updatedAt = now;
566
- return { frozen };
567
- }
568
- /**
569
- * Observes the runs of the queue and returns the items to start now. Items leave
570
- * the queue only through `itemStarted`.
571
- */
572
- export function advance(queue, states, lookup, now) {
573
- let own = queueStates(queue, states);
574
- const wake = queueWakeAt(queue);
575
- if (wake !== null && now >= wake)
576
- startQueue(queue, own, now);
577
- if (queue.skipFailed) {
578
- const failed = own.filter((state) => state.run.hold === null &&
579
- runProblems(state).some((problem) => SKIPPED_REASONS.has(problem.reason)));
580
- if (failed.length > 0) {
581
- const ids = new Set(failed.map((state) => state.run.id));
582
- queue.skipped = [
583
- ...failed.map((state) => state.run.id).reverse(),
584
- ...queue.skipped.filter((id) => !ids.has(id)),
585
- ];
586
- queue.runs = queue.runs.filter((id) => !ids.has(id));
587
- queue.acknowledged = queue.acknowledged.filter((key) => ![...ids].some((id) => key.startsWith(`${id}/`)));
588
- own = own.filter((state) => !ids.has(state.run.id));
589
- }
590
- }
591
- const returned = [];
592
- queue.skipped = queue.skipped
593
- .filter((id) => {
594
- const state = lookup(id);
595
- if (state === undefined)
596
- return false;
597
- if (runProblems(state).some((problem) => BLOCKING_REASONS.has(problem.reason)))
598
- return true;
599
- if (occupiesSlot(state) && !queue.runs.includes(id))
600
- returned.push(state);
601
- return false;
602
- })
603
- .slice(0, QUEUE_SKIPPED_MAX);
604
- if (returned.length > 0) {
605
- queue.runs = [...queue.runs, ...returned.map((state) => state.run.id)];
606
- for (const state of returned) {
607
- for (const hit of limitHits(state))
608
- queue.acknowledged.push(hit.key);
609
- }
610
- own = [...own, ...returned];
611
- }
612
- const watched = own.filter((state) => state.run.hold === null);
613
- stopOnLimit(queue, watched);
614
- const known = new Set(queue.acknowledged);
615
- if (queue.stop === null) {
616
- for (const state of watched) {
617
- const fresh = runProblems(state).find((problem) => STOPPING_REASONS.has(problem.reason) && !known.has(problem.key));
618
- if (!fresh)
619
- continue;
620
- queue.status = 'stopped';
621
- queue.stop = {
622
- kind: 'problem',
623
- run: fresh.run,
624
- group: fresh.group,
625
- reason: fresh.reason,
626
- };
627
- break;
628
- }
629
- }
630
- const keep = new Set(own.filter(occupiesSlot).map((state) => state.run.id));
631
- for (const item of [...queue.items]) {
632
- if (item.run === null)
633
- continue;
634
- const state = lookup(item.run);
635
- if (state &&
636
- state.run.finishedAt !== null &&
637
- state.run.hold === null &&
638
- retryableGroups(state).length === 0) {
639
- queue.items = queue.items.filter((candidate) => candidate !== item);
640
- for (const other of queue.items) {
641
- other.after = [
642
- ...new Set(other.after.map((ref) => (ref === item.id ? item.run : ref))),
643
- ].filter((ref) => ref !== null);
644
- }
645
- }
646
- }
647
- const released = queue.runs.filter((id) => !keep.has(id));
648
- if (released.length > 0) {
649
- queue.runs = queue.runs.filter((id) => keep.has(id));
650
- queue.acknowledged = queue.acknowledged.filter((key) => !released.some((id) => key.startsWith(`${id}/`)));
651
- }
652
- const take = [];
653
- const freeze = [];
654
- // Frozen runs go first, in any state of the queue, as soon as a place is free.
655
- for (const item of queue.items) {
656
- if (item.run === null || lookup(item.run)?.run.hold !== 'frozen')
657
- continue;
658
- if (queue.runs.length + take.length >= queue.parallel)
659
- break;
660
- take.push(item);
661
- }
662
- const frozenTaken = take.length;
663
- if (queue.status === 'running') {
664
- // Returned runs without a hold take a place at once, freezing the last run that took one.
665
- const live = () => own.filter((state) => queue.runs.includes(state.run.id));
666
- for (const item of [...queue.items]) {
667
- if (item.run === null || item.postponed)
668
- continue;
669
- if (queue.skipFailed && item.error !== null)
670
- continue;
671
- const state = lookup(item.run);
672
- if (!state || state.run.hold !== null || retryableGroups(state).length === 0)
673
- continue;
674
- if (itemReadiness(queue, item, lookup) !== 'ready')
675
- continue;
676
- const frozen = claimPlace(queue, live(), item.run, newItemId(queue, now), now);
677
- if (frozen !== null)
678
- freeze.push(frozen);
679
- take.push(item);
680
- }
681
- const free = Math.max(0, queue.parallel - queue.runs.length - frozenTaken);
682
- take.push(...queue.items
683
- .filter((item) => !take.includes(item) &&
684
- !item.postponed &&
685
- !(item.run !== null && lookup(item.run)?.run.hold === 'paused') &&
686
- !(queue.skipFailed && item.error !== null) &&
687
- itemReadiness(queue, item, lookup) === 'ready')
688
- .slice(0, free));
689
- if (!queue.autopilot &&
690
- !queue.items.some((item) => !item.postponed) &&
691
- queue.runs.length === 0) {
692
- queue.status = 'stopped';
693
- }
694
- }
695
- queue.priority = queue.priority.filter((id) => queue.runs.includes(id));
696
- queue.updatedAt = now;
697
- return { take, freeze };
698
- }
699
- /** A new usage limit of a run of the queue stops it; every such attempt counts once. */
700
- function stopOnLimit(queue, own) {
701
- const known = new Set(queue.acknowledged);
702
- const fresh = own.flatMap(limitHits).filter((hit) => !known.has(hit.key));
703
- if (fresh.length === 0)
704
- return;
705
- queue.acknowledged = [...queue.acknowledged, ...fresh.map((hit) => hit.key)];
706
- const first = fresh[0];
707
- const running = queue.status === 'running';
708
- if (!running && queue.stop !== null)
709
- return;
710
- queue.status = 'stopped';
711
- queue.stop = {
712
- kind: 'limit',
713
- run: first.run,
714
- group: first.group,
715
- runtime: first.runtime,
716
- resetsAt: Math.max(...fresh.map((hit) => hit.resetsAt)),
717
- autoResume: running && queue.onLimit === 'wait',
718
- };
719
- }
720
- /** The queue item that takes `state` back: retries it, or only lifts its hold. */
721
- function returnItem(state, id, now) {
722
- return {
723
- id,
724
- number: state.run.number,
725
- pipeline: state.run.pipeline,
726
- task: null,
727
- groups: null,
728
- title: state.run.title,
729
- autoDeliver: null,
730
- deliveryMode: null,
731
- tags: [...state.run.tags],
732
- skip: [],
733
- after: [],
734
- createdAt: now,
735
- error: null,
736
- run: state.run.id,
737
- postponed: false,
738
- };
739
- }
740
- /**
741
- * Puts a run on pause (checked before the hold is set): the run leaves its place and becomes the
742
- * last item of the queue. The queue never takes the item of a paused run by itself: only an
743
- * explicit action lifts the hold. A frozen run already has its item: the item moves to the end.
744
- */
745
- export function pauseRun(queue, state, id, now) {
746
- const run = state.run.id;
747
- if (state.run.hold === 'paused')
748
- throw new Rejection('run is already paused');
749
- if (state.run.hold === 'frozen') {
750
- const item = returnItemOf(queue, run) ?? returnItem(state, id, now);
751
- queue.items = [...queue.items.filter((other) => other !== item), item];
752
- queue.updatedAt = now;
753
- return item;
754
- }
755
- if (state.run.finishedAt !== null)
756
- throw new Rejection('run has nothing to pause');
757
- if (queue.items.some((item) => item.run === run)) {
758
- throw new Rejection('run is already in the queue');
759
- }
760
- const item = returnItem(state, id, now);
761
- queue.runs = queue.runs.filter((candidate) => candidate !== run);
762
- queue.priority = queue.priority.filter((candidate) => candidate !== run);
763
- queue.skipped = queue.skipped.filter((candidate) => candidate !== run);
764
- queue.acknowledged = queue.acknowledged.filter((key) => !key.startsWith(`${run}/`));
765
- queue.items.push(item);
766
- queue.updatedAt = now;
767
- return item;
768
- }
769
- /**
770
- * Puts a run back into the queue as its first item: taking the item retries the failed and
771
- * cancelled groups of the run, which then holds a place.
772
- */
773
- export function returnRun(queue, state, id, now) {
774
- const run = state.run.id;
775
- if (retryableGroups(state).length === 0) {
776
- throw new Rejection('run has no failed or cancelled groups');
777
- }
778
- if (queue.runs.includes(run))
779
- throw new Rejection('run already holds a place in the queue');
780
- if (queue.items.some((item) => item.run === run)) {
781
- throw new Rejection('run is already in the queue');
782
- }
783
- const item = returnItem(state, id, now);
784
- queue.items.unshift(item);
785
- queue.skipped = queue.skipped.filter((skipped) => skipped !== run);
786
- queue.updatedAt = now;
787
- return item;
788
- }
789
- /** Whether `returnRun` would take the run: something to retry, and not in the queue yet. */
790
- export function canReturn(queue, state) {
791
- const id = state.run.id;
792
- return (retryableGroups(state).length > 0 &&
793
- !queue.runs.includes(id) &&
794
- !queue.items.some((item) => item.run === id));
795
- }
796
- /** Removes a skipped run from the skipped list; the run itself is not changed. */
797
- export function dismissRun(queue, state, now) {
798
- const id = state.run.id;
799
- if (!queue.skipped.includes(id))
800
- throw new Rejection('run is not in the skipped list');
801
- queue.skipped = queue.skipped.filter((skipped) => skipped !== id);
802
- queue.acknowledged = queue.acknowledged.filter((key) => !key.startsWith(`${id}/`));
803
- queue.updatedAt = now;
804
- }
805
- function autopilotStreak(decisions) {
806
- let streak = 0;
807
- for (let index = decisions.length - 1; index >= 0; index -= 1) {
808
- if (decisions[index]?.by !== 'autopilot')
809
- break;
810
- streak += 1;
811
- }
812
- return streak;
813
- }
814
- /**
815
- * Questions the queue answers now (when `autoAnswer` is on): groups of the runs that hold a place in a
816
- * running queue, waiting because the specialist reported `needs_human` (not
817
- * because of a limit or a change outside the worktree), that got fewer than
818
- * `AUTOPILOT_ANSWERS_MAX` autopilot answers in a row.
819
- */
820
- export function autopilotAnswers(queue, states) {
821
- if (queue.status !== 'running' || !queue.autoAnswer)
822
- return [];
823
- const answer = queue.autopilotAnswer ?? DEFAULT_AUTOPILOT_ANSWER;
824
- const result = [];
825
- for (const state of queueStates(queue, states)) {
826
- const work = state.split ? [state.split, ...state.groups] : state.groups;
827
- for (const group of work) {
828
- if (group.status !== 'needs_human' || group.humanOnly)
829
- continue;
830
- const last = group.attempts.at(-1);
831
- if (last?.report?.verdict !== 'needs_human' || last.outsideChanges.length > 0)
832
- continue;
833
- if (autopilotStreak(group.decisions) >= AUTOPILOT_ANSWERS_MAX)
834
- continue;
835
- result.push({ run: state.run.id, group: group.slug, answer });
836
- }
837
- }
838
- return result;
839
- }
840
- export function itemStarted(queue, id, run, now) {
841
- const item = find(queue, id);
842
- queue.items = queue.items.filter((candidate) => candidate !== item);
843
- for (const other of queue.items) {
844
- other.after = [...new Set(other.after.map((ref) => (ref === id ? run : ref)))];
845
- }
846
- if (!queue.runs.includes(run))
847
- queue.runs.push(run);
848
- queue.updatedAt = now;
849
- }
850
- export function itemFailed(queue, id, error, now) {
851
- const item = find(queue, id);
852
- item.error = error;
853
- if (!queue.skipFailed) {
854
- queue.status = 'stopped';
855
- queue.stop = { kind: 'item', item: id, error };
856
- }
857
- queue.updatedAt = now;
858
- }
859
- //# sourceMappingURL=queue.js.map