@hoknie/aip 0.0.0-stage → 0.2.0

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 (954) hide show
  1. package/.claude-plugin/marketplace.json +13 -0
  2. package/README.md +74 -2
  3. package/dist/app/agents.js +20 -0
  4. package/dist/app/agents.js.map +1 -0
  5. package/dist/app/application.js +205 -0
  6. package/dist/app/application.js.map +1 -0
  7. package/dist/app/daemon.js +71 -0
  8. package/dist/app/daemon.js.map +1 -0
  9. package/dist/app/index.js +5 -0
  10. package/dist/app/index.js.map +1 -0
  11. package/dist/app/lifecycle.js +34 -0
  12. package/dist/app/lifecycle.js.map +1 -0
  13. package/dist/app/maintenance.js +27 -0
  14. package/dist/app/maintenance.js.map +1 -0
  15. package/dist/app/timings.js +24 -0
  16. package/dist/app/timings.js.map +1 -0
  17. package/dist/app/wiring.js +58 -0
  18. package/dist/app/wiring.js.map +1 -0
  19. package/dist/cli/main.js +31 -0
  20. package/dist/cli/main.js.map +1 -0
  21. package/dist/feature/agents/clients/agy/events.js +36 -0
  22. package/dist/feature/agents/clients/agy/events.js.map +1 -0
  23. package/dist/feature/agents/clients/agy/guard-commands.js +29 -0
  24. package/dist/feature/agents/clients/agy/guard-commands.js.map +1 -0
  25. package/dist/feature/agents/clients/agy/guard-paths.js +36 -0
  26. package/dist/feature/agents/clients/agy/guard-paths.js.map +1 -0
  27. package/dist/feature/agents/clients/agy/guard.js +77 -0
  28. package/dist/feature/agents/clients/agy/guard.js.map +1 -0
  29. package/dist/feature/agents/clients/agy/hooks.js +46 -0
  30. package/dist/feature/agents/clients/agy/hooks.js.map +1 -0
  31. package/dist/feature/agents/clients/agy/index.js +5 -0
  32. package/dist/feature/agents/clients/agy/index.js.map +1 -0
  33. package/dist/feature/agents/clients/agy/parser.js +63 -0
  34. package/dist/feature/agents/clients/agy/parser.js.map +1 -0
  35. package/dist/feature/agents/clients/agy/permissions.js +40 -0
  36. package/dist/feature/agents/clients/agy/permissions.js.map +1 -0
  37. package/dist/feature/agents/clients/agy/runtime.js +115 -0
  38. package/dist/feature/agents/clients/agy/runtime.js.map +1 -0
  39. package/dist/feature/agents/clients/agy/transcript.js +65 -0
  40. package/dist/feature/agents/clients/agy/transcript.js.map +1 -0
  41. package/dist/feature/agents/clients/claude/index.js +6 -0
  42. package/dist/feature/agents/clients/claude/index.js.map +1 -0
  43. package/dist/feature/agents/clients/claude/models.js +8 -0
  44. package/dist/feature/agents/clients/claude/models.js.map +1 -0
  45. package/dist/feature/agents/clients/claude/parser.js +229 -0
  46. package/dist/feature/agents/clients/claude/parser.js.map +1 -0
  47. package/dist/feature/agents/clients/claude/permissions.js +70 -0
  48. package/dist/feature/agents/clients/claude/permissions.js.map +1 -0
  49. package/dist/feature/agents/clients/claude/runtime.js +118 -0
  50. package/dist/feature/agents/clients/claude/runtime.js.map +1 -0
  51. package/dist/feature/agents/clients/claude/transcript.js +105 -0
  52. package/dist/feature/agents/clients/claude/transcript.js.map +1 -0
  53. package/dist/feature/agents/clients/naming/index.js +2 -0
  54. package/dist/feature/agents/clients/naming/index.js.map +1 -0
  55. package/dist/feature/agents/clients/naming/naming.js +15 -0
  56. package/dist/feature/agents/clients/naming/naming.js.map +1 -0
  57. package/dist/feature/agents/clients/opencode/index.js +5 -0
  58. package/dist/feature/agents/clients/opencode/index.js.map +1 -0
  59. package/dist/feature/agents/clients/opencode/models.js +38 -0
  60. package/dist/feature/agents/clients/opencode/models.js.map +1 -0
  61. package/dist/feature/agents/clients/opencode/parser.js +84 -0
  62. package/dist/feature/agents/clients/opencode/parser.js.map +1 -0
  63. package/dist/feature/agents/clients/opencode/runtime.js +131 -0
  64. package/dist/feature/agents/clients/opencode/runtime.js.map +1 -0
  65. package/dist/feature/agents/clients/opencode/transcript.js +77 -0
  66. package/dist/feature/agents/clients/opencode/transcript.js.map +1 -0
  67. package/dist/feature/agents/ports/command.js +2 -0
  68. package/dist/feature/agents/ports/command.js.map +1 -0
  69. package/dist/feature/agents/ports/index.js +2 -0
  70. package/dist/feature/agents/ports/index.js.map +1 -0
  71. package/dist/feature/agents/ports/naming.js +2 -0
  72. package/dist/feature/agents/ports/naming.js.map +1 -0
  73. package/dist/feature/agents/ports/runtime-factory.js +2 -0
  74. package/dist/feature/agents/ports/runtime-factory.js.map +1 -0
  75. package/dist/feature/agents/services/agents.js +79 -0
  76. package/dist/feature/agents/services/agents.js.map +1 -0
  77. package/dist/feature/agents/services/catalog.js +117 -0
  78. package/dist/feature/agents/services/catalog.js.map +1 -0
  79. package/dist/feature/agents/services/create.js +5 -0
  80. package/dist/feature/agents/services/create.js.map +1 -0
  81. package/dist/feature/agents/services/index.js +7 -0
  82. package/dist/feature/agents/services/index.js.map +1 -0
  83. package/dist/feature/agents/services/logs.js +69 -0
  84. package/dist/feature/agents/services/logs.js.map +1 -0
  85. package/dist/feature/agents/services/skills.js +17 -0
  86. package/dist/feature/agents/services/skills.js.map +1 -0
  87. package/dist/feature/agents/services/supervisor.js +160 -0
  88. package/dist/feature/agents/services/supervisor.js.map +1 -0
  89. package/dist/feature/agents/types/catalog.js +2 -0
  90. package/dist/feature/agents/types/catalog.js.map +1 -0
  91. package/dist/feature/agents/types/index.js +13 -0
  92. package/dist/feature/agents/types/index.js.map +1 -0
  93. package/dist/feature/agents/types/message.js +49 -0
  94. package/dist/feature/agents/types/message.js.map +1 -0
  95. package/dist/feature/agents/types/models.js +2 -0
  96. package/dist/feature/agents/types/models.js.map +1 -0
  97. package/dist/feature/agents/types/naming.js +4 -0
  98. package/dist/feature/agents/types/naming.js.map +1 -0
  99. package/dist/feature/agents/types/permissions.js +235 -0
  100. package/dist/feature/agents/types/permissions.js.map +1 -0
  101. package/dist/feature/agents/types/run-naming.js +66 -0
  102. package/dist/feature/agents/types/run-naming.js.map +1 -0
  103. package/dist/feature/agents/types/runtime.js +18 -0
  104. package/dist/feature/agents/types/runtime.js.map +1 -0
  105. package/dist/feature/agents/types/step-input.js +2 -0
  106. package/dist/feature/agents/types/step-input.js.map +1 -0
  107. package/dist/feature/agents/types/transcript-parts.js +62 -0
  108. package/dist/feature/agents/types/transcript-parts.js.map +1 -0
  109. package/dist/feature/agents/types/transcript.js +8 -0
  110. package/dist/feature/agents/types/transcript.js.map +1 -0
  111. package/dist/feature/agents/types/usage.js +14 -0
  112. package/dist/feature/agents/types/usage.js.map +1 -0
  113. package/dist/feature/agents/types/worker-tools.js +22 -0
  114. package/dist/feature/agents/types/worker-tools.js.map +1 -0
  115. package/dist/feature/artifacts/ports/index.js +2 -0
  116. package/dist/feature/artifacts/ports/index.js.map +1 -0
  117. package/dist/feature/artifacts/ports/publish.js +2 -0
  118. package/dist/feature/artifacts/ports/publish.js.map +1 -0
  119. package/dist/feature/artifacts/repositories/artifact-storage.js +84 -0
  120. package/dist/feature/artifacts/repositories/artifact-storage.js.map +1 -0
  121. package/dist/feature/artifacts/repositories/artifacts.js +85 -0
  122. package/dist/feature/artifacts/repositories/artifacts.js.map +1 -0
  123. package/dist/feature/artifacts/repositories/index.js +3 -0
  124. package/dist/feature/artifacts/repositories/index.js.map +1 -0
  125. package/dist/feature/artifacts/services/artifacts.js +105 -0
  126. package/dist/feature/artifacts/services/artifacts.js.map +1 -0
  127. package/dist/feature/artifacts/services/create.js +14 -0
  128. package/dist/feature/artifacts/services/create.js.map +1 -0
  129. package/dist/feature/artifacts/services/files.js +42 -0
  130. package/dist/feature/artifacts/services/files.js.map +1 -0
  131. package/dist/feature/artifacts/services/index.js +3 -0
  132. package/dist/feature/artifacts/services/index.js.map +1 -0
  133. package/dist/feature/artifacts/types/artifacts.js +36 -0
  134. package/dist/feature/artifacts/types/artifacts.js.map +1 -0
  135. package/dist/feature/artifacts/types/index.js +2 -0
  136. package/dist/feature/artifacts/types/index.js.map +1 -0
  137. package/dist/feature/artifacts/types/views.js +2 -0
  138. package/dist/feature/artifacts/types/views.js.map +1 -0
  139. package/dist/feature/compose/services/create.js +11 -0
  140. package/dist/feature/compose/services/create.js.map +1 -0
  141. package/dist/feature/compose/services/index.js +5 -0
  142. package/dist/feature/compose/services/index.js.map +1 -0
  143. package/dist/feature/compose/services/repository-edit.js +20 -0
  144. package/dist/feature/compose/services/repository-edit.js.map +1 -0
  145. package/dist/feature/compose/services/repository-move.js +35 -0
  146. package/dist/feature/compose/services/repository-move.js.map +1 -0
  147. package/dist/feature/compose/services/repository-removal.js +38 -0
  148. package/dist/feature/compose/services/repository-removal.js.map +1 -0
  149. package/dist/feature/delivery/ports/index.js +2 -0
  150. package/dist/feature/delivery/ports/index.js.map +1 -0
  151. package/dist/feature/delivery/ports/publish.js +2 -0
  152. package/dist/feature/delivery/ports/publish.js.map +1 -0
  153. package/dist/feature/delivery/repositories/index.js +3 -0
  154. package/dist/feature/delivery/repositories/index.js.map +1 -0
  155. package/dist/feature/delivery/repositories/patch-storage.js +76 -0
  156. package/dist/feature/delivery/repositories/patch-storage.js.map +1 -0
  157. package/dist/feature/delivery/repositories/patches.js +28 -0
  158. package/dist/feature/delivery/repositories/patches.js.map +1 -0
  159. package/dist/feature/delivery/services/create.js +21 -0
  160. package/dist/feature/delivery/services/create.js.map +1 -0
  161. package/dist/feature/delivery/services/deliver.js +67 -0
  162. package/dist/feature/delivery/services/deliver.js.map +1 -0
  163. package/dist/feature/delivery/services/diffs.js +153 -0
  164. package/dist/feature/delivery/services/diffs.js.map +1 -0
  165. package/dist/feature/delivery/services/index.js +5 -0
  166. package/dist/feature/delivery/services/index.js.map +1 -0
  167. package/dist/feature/delivery/services/patches.js +96 -0
  168. package/dist/feature/delivery/services/patches.js.map +1 -0
  169. package/dist/feature/delivery/types/index.js +3 -0
  170. package/dist/feature/delivery/types/index.js.map +1 -0
  171. package/dist/feature/delivery/types/outcomes.js +2 -0
  172. package/dist/feature/delivery/types/outcomes.js.map +1 -0
  173. package/dist/feature/delivery/types/spec-change.js +18 -0
  174. package/dist/feature/delivery/types/spec-change.js.map +1 -0
  175. package/dist/feature/network/ports/changed.js +2 -0
  176. package/dist/feature/network/ports/changed.js.map +1 -0
  177. package/dist/feature/network/ports/index.js +2 -0
  178. package/dist/feature/network/ports/index.js.map +1 -0
  179. package/dist/feature/network/services/create.js +5 -0
  180. package/dist/feature/network/services/create.js.map +1 -0
  181. package/dist/feature/network/services/index.js +3 -0
  182. package/dist/feature/network/services/index.js.map +1 -0
  183. package/dist/feature/network/services/monitor.js +140 -0
  184. package/dist/feature/network/services/monitor.js.map +1 -0
  185. package/dist/feature/network/types/index.js +4 -0
  186. package/dist/feature/network/types/index.js.map +1 -0
  187. package/dist/feature/network/types/network.js +8 -0
  188. package/dist/feature/network/types/network.js.map +1 -0
  189. package/dist/feature/network/types/proxy.js +95 -0
  190. package/dist/feature/network/types/proxy.js.map +1 -0
  191. package/dist/feature/network/types/state.js +36 -0
  192. package/dist/feature/network/types/state.js.map +1 -0
  193. package/dist/feature/observers/ports/index.js +2 -0
  194. package/dist/feature/observers/ports/index.js.map +1 -0
  195. package/dist/feature/observers/ports/publish.js +2 -0
  196. package/dist/feature/observers/ports/publish.js.map +1 -0
  197. package/dist/feature/observers/repositories/index.js +2 -0
  198. package/dist/feature/observers/repositories/index.js.map +1 -0
  199. package/dist/feature/observers/repositories/observers.js +34 -0
  200. package/dist/feature/observers/repositories/observers.js.map +1 -0
  201. package/dist/feature/observers/services/create.js +11 -0
  202. package/dist/feature/observers/services/create.js.map +1 -0
  203. package/dist/feature/observers/services/history.js +76 -0
  204. package/dist/feature/observers/services/history.js.map +1 -0
  205. package/dist/feature/observers/services/index.js +5 -0
  206. package/dist/feature/observers/services/index.js.map +1 -0
  207. package/dist/feature/observers/services/observers.js +188 -0
  208. package/dist/feature/observers/services/observers.js.map +1 -0
  209. package/dist/feature/observers/services/settings-check.js +87 -0
  210. package/dist/feature/observers/services/settings-check.js.map +1 -0
  211. package/dist/feature/observers/types/actions.js +2 -0
  212. package/dist/feature/observers/types/actions.js.map +1 -0
  213. package/dist/feature/observers/types/index.js +4 -0
  214. package/dist/feature/observers/types/index.js.map +1 -0
  215. package/dist/feature/observers/types/plan-repairs.js +116 -0
  216. package/dist/feature/observers/types/plan-repairs.js.map +1 -0
  217. package/dist/feature/observers/types/settings.js +12 -0
  218. package/dist/feature/observers/types/settings.js.map +1 -0
  219. package/dist/feature/processes/ports/index.js +2 -0
  220. package/dist/feature/processes/ports/index.js.map +1 -0
  221. package/dist/feature/processes/ports/publish.js +2 -0
  222. package/dist/feature/processes/ports/publish.js.map +1 -0
  223. package/dist/feature/processes/services/create.js +5 -0
  224. package/dist/feature/processes/services/create.js.map +1 -0
  225. package/dist/feature/processes/services/index.js +4 -0
  226. package/dist/feature/processes/services/index.js.map +1 -0
  227. package/dist/feature/processes/services/processes.js +131 -0
  228. package/dist/feature/processes/services/processes.js.map +1 -0
  229. package/dist/feature/processes/services/tree.js +98 -0
  230. package/dist/feature/processes/services/tree.js.map +1 -0
  231. package/dist/feature/processes/types/background.js +2 -0
  232. package/dist/feature/processes/types/background.js.map +1 -0
  233. package/dist/feature/processes/types/index.js +2 -0
  234. package/dist/feature/processes/types/index.js.map +1 -0
  235. package/dist/feature/queue/ports/index.js +2 -0
  236. package/dist/feature/queue/ports/index.js.map +1 -0
  237. package/dist/feature/queue/ports/observe.js +2 -0
  238. package/dist/feature/queue/ports/observe.js.map +1 -0
  239. package/dist/feature/queue/ports/publish.js +2 -0
  240. package/dist/feature/queue/ports/publish.js.map +1 -0
  241. package/dist/feature/queue/ports/repair-policy.js +2 -0
  242. package/dist/feature/queue/ports/repair-policy.js.map +1 -0
  243. package/dist/feature/queue/repositories/index.js +2 -0
  244. package/dist/feature/queue/repositories/index.js.map +1 -0
  245. package/dist/feature/queue/repositories/queues.js +100 -0
  246. package/dist/feature/queue/repositories/queues.js.map +1 -0
  247. package/dist/feature/queue/services/advance.js +214 -0
  248. package/dist/feature/queue/services/advance.js.map +1 -0
  249. package/dist/feature/queue/services/control.js +169 -0
  250. package/dist/feature/queue/services/control.js.map +1 -0
  251. package/dist/feature/queue/services/create.js +26 -0
  252. package/dist/feature/queue/services/create.js.map +1 -0
  253. package/dist/feature/queue/services/edit.js +126 -0
  254. package/dist/feature/queue/services/edit.js.map +1 -0
  255. package/dist/feature/queue/services/index.js +8 -0
  256. package/dist/feature/queue/services/index.js.map +1 -0
  257. package/dist/feature/queue/services/items.js +173 -0
  258. package/dist/feature/queue/services/items.js.map +1 -0
  259. package/dist/feature/queue/services/store.js +61 -0
  260. package/dist/feature/queue/services/store.js.map +1 -0
  261. package/dist/feature/queue/services/task-tags.js +103 -0
  262. package/dist/feature/queue/services/task-tags.js.map +1 -0
  263. package/dist/feature/queue/types/advance.js +198 -0
  264. package/dist/feature/queue/types/advance.js.map +1 -0
  265. package/dist/feature/queue/types/dependencies.js +98 -0
  266. package/dist/feature/queue/types/dependencies.js.map +1 -0
  267. package/dist/feature/queue/types/edit.js +180 -0
  268. package/dist/feature/queue/types/edit.js.map +1 -0
  269. package/dist/feature/queue/types/ids.js +7 -0
  270. package/dist/feature/queue/types/ids.js.map +1 -0
  271. package/dist/feature/queue/types/index.js +10 -0
  272. package/dist/feature/queue/types/index.js.map +1 -0
  273. package/dist/feature/queue/types/items.js +46 -0
  274. package/dist/feature/queue/types/items.js.map +1 -0
  275. package/dist/feature/queue/types/limit-hits.js +50 -0
  276. package/dist/feature/queue/types/limit-hits.js.map +1 -0
  277. package/dist/feature/queue/types/requests.js +2 -0
  278. package/dist/feature/queue/types/requests.js.map +1 -0
  279. package/dist/feature/queue/types/returns.js +197 -0
  280. package/dist/feature/queue/types/returns.js.map +1 -0
  281. package/dist/feature/queue/types/settings.js +117 -0
  282. package/dist/feature/queue/types/settings.js.map +1 -0
  283. package/dist/feature/repos/ports/index.js +2 -0
  284. package/dist/feature/repos/ports/index.js.map +1 -0
  285. package/dist/feature/repos/ports/publish.js +2 -0
  286. package/dist/feature/repos/ports/publish.js.map +1 -0
  287. package/dist/feature/repos/repositories/index.js +2 -0
  288. package/dist/feature/repos/repositories/index.js.map +1 -0
  289. package/dist/feature/repos/repositories/known.js +41 -0
  290. package/dist/feature/repos/repositories/known.js.map +1 -0
  291. package/dist/feature/repos/services/create.js +13 -0
  292. package/dist/feature/repos/services/create.js.map +1 -0
  293. package/dist/feature/repos/services/index.js +4 -0
  294. package/dist/feature/repos/services/index.js.map +1 -0
  295. package/dist/feature/repos/services/projects.js +50 -0
  296. package/dist/feature/repos/services/projects.js.map +1 -0
  297. package/dist/feature/repos/services/registry.js +138 -0
  298. package/dist/feature/repos/services/registry.js.map +1 -0
  299. package/dist/feature/repos/types/index.js +2 -0
  300. package/dist/feature/repos/types/index.js.map +1 -0
  301. package/dist/feature/repos/types/project.js +80 -0
  302. package/dist/feature/repos/types/project.js.map +1 -0
  303. package/dist/feature/repos/types/registry.js +2 -0
  304. package/dist/feature/repos/types/registry.js.map +1 -0
  305. package/dist/feature/runs/machine/answers.js +112 -0
  306. package/dist/feature/runs/machine/answers.js.map +1 -0
  307. package/dist/feature/runs/machine/delivery-checks.js +91 -0
  308. package/dist/feature/runs/machine/delivery-checks.js.map +1 -0
  309. package/dist/feature/runs/machine/delivery-flow.js +211 -0
  310. package/dist/feature/runs/machine/delivery-flow.js.map +1 -0
  311. package/dist/feature/runs/machine/events.js +2 -0
  312. package/dist/feature/runs/machine/events.js.map +1 -0
  313. package/dist/feature/runs/machine/exits.js +229 -0
  314. package/dist/feature/runs/machine/exits.js.map +1 -0
  315. package/dist/feature/runs/machine/index.js +7 -0
  316. package/dist/feature/runs/machine/index.js.map +1 -0
  317. package/dist/feature/runs/machine/plan.js +133 -0
  318. package/dist/feature/runs/machine/plan.js.map +1 -0
  319. package/dist/feature/runs/machine/repair.js +158 -0
  320. package/dist/feature/runs/machine/repair.js.map +1 -0
  321. package/dist/feature/runs/machine/run-control.js +276 -0
  322. package/dist/feature/runs/machine/run-control.js.map +1 -0
  323. package/dist/feature/runs/machine/scheduler.js +126 -0
  324. package/dist/feature/runs/machine/scheduler.js.map +1 -0
  325. package/dist/feature/runs/machine/steps.js +275 -0
  326. package/dist/feature/runs/machine/steps.js.map +1 -0
  327. package/dist/feature/runs/machine/texts.js +69 -0
  328. package/dist/feature/runs/machine/texts.js.map +1 -0
  329. package/dist/feature/runs/machine/transition.js +117 -0
  330. package/dist/feature/runs/machine/transition.js.map +1 -0
  331. package/dist/feature/runs/ports/agent-exit.js +2 -0
  332. package/dist/feature/runs/ports/agent-exit.js.map +1 -0
  333. package/dist/feature/runs/ports/diff.js +2 -0
  334. package/dist/feature/runs/ports/diff.js.map +1 -0
  335. package/dist/feature/runs/ports/index.js +2 -0
  336. package/dist/feature/runs/ports/index.js.map +1 -0
  337. package/dist/feature/runs/ports/observe.js +2 -0
  338. package/dist/feature/runs/ports/observe.js.map +1 -0
  339. package/dist/feature/runs/ports/publish.js +2 -0
  340. package/dist/feature/runs/ports/publish.js.map +1 -0
  341. package/dist/feature/runs/ports/queue-advance.js +2 -0
  342. package/dist/feature/runs/ports/queue-advance.js.map +1 -0
  343. package/dist/feature/runs/repositories/attempt-history.js +116 -0
  344. package/dist/feature/runs/repositories/attempt-history.js.map +1 -0
  345. package/dist/feature/runs/repositories/finished-runs.js +46 -0
  346. package/dist/feature/runs/repositories/finished-runs.js.map +1 -0
  347. package/dist/feature/runs/repositories/index.js +4 -0
  348. package/dist/feature/runs/repositories/index.js.map +1 -0
  349. package/dist/feature/runs/repositories/rows.js +110 -0
  350. package/dist/feature/runs/repositories/rows.js.map +1 -0
  351. package/dist/feature/runs/repositories/runs.js +76 -0
  352. package/dist/feature/runs/repositories/runs.js.map +1 -0
  353. package/dist/feature/runs/repositories/write.js +31 -0
  354. package/dist/feature/runs/repositories/write.js.map +1 -0
  355. package/dist/feature/runs/services/archive.js +17 -0
  356. package/dist/feature/runs/services/archive.js.map +1 -0
  357. package/dist/feature/runs/services/attempt-history.js +11 -0
  358. package/dist/feature/runs/services/attempt-history.js.map +1 -0
  359. package/dist/feature/runs/services/create.js +44 -0
  360. package/dist/feature/runs/services/create.js.map +1 -0
  361. package/dist/feature/runs/services/effects/actions.js +151 -0
  362. package/dist/feature/runs/services/effects/actions.js.map +1 -0
  363. package/dist/feature/runs/services/effects/attempts.js +219 -0
  364. package/dist/feature/runs/services/effects/attempts.js.map +1 -0
  365. package/dist/feature/runs/services/effects/context.js +7 -0
  366. package/dist/feature/runs/services/effects/context.js.map +1 -0
  367. package/dist/feature/runs/services/effects/effects.js +82 -0
  368. package/dist/feature/runs/services/effects/effects.js.map +1 -0
  369. package/dist/feature/runs/services/effects/git.js +168 -0
  370. package/dist/feature/runs/services/effects/git.js.map +1 -0
  371. package/dist/feature/runs/services/effects/naming.js +65 -0
  372. package/dist/feature/runs/services/effects/naming.js.map +1 -0
  373. package/dist/feature/runs/services/effects/outside.js +83 -0
  374. package/dist/feature/runs/services/effects/outside.js.map +1 -0
  375. package/dist/feature/runs/services/effects/proxy.js +5 -0
  376. package/dist/feature/runs/services/effects/proxy.js.map +1 -0
  377. package/dist/feature/runs/services/effects/running.js +76 -0
  378. package/dist/feature/runs/services/effects/running.js.map +1 -0
  379. package/dist/feature/runs/services/effects/usage.js +61 -0
  380. package/dist/feature/runs/services/effects/usage.js.map +1 -0
  381. package/dist/feature/runs/services/effects/worktrees.js +49 -0
  382. package/dist/feature/runs/services/effects/worktrees.js.map +1 -0
  383. package/dist/feature/runs/services/engine.js +172 -0
  384. package/dist/feature/runs/services/engine.js.map +1 -0
  385. package/dist/feature/runs/services/index.js +15 -0
  386. package/dist/feature/runs/services/index.js.map +1 -0
  387. package/dist/feature/runs/services/occupancy.js +62 -0
  388. package/dist/feature/runs/services/occupancy.js.map +1 -0
  389. package/dist/feature/runs/services/progress.js +42 -0
  390. package/dist/feature/runs/services/progress.js.map +1 -0
  391. package/dist/feature/runs/services/reads.js +93 -0
  392. package/dist/feature/runs/services/reads.js.map +1 -0
  393. package/dist/feature/runs/services/recovery.js +17 -0
  394. package/dist/feature/runs/services/recovery.js.map +1 -0
  395. package/dist/feature/runs/services/refresh.js +29 -0
  396. package/dist/feature/runs/services/refresh.js.map +1 -0
  397. package/dist/feature/runs/services/requests.js +88 -0
  398. package/dist/feature/runs/services/requests.js.map +1 -0
  399. package/dist/feature/runs/services/states.js +112 -0
  400. package/dist/feature/runs/services/states.js.map +1 -0
  401. package/dist/feature/runs/services/summary.js +38 -0
  402. package/dist/feature/runs/services/summary.js.map +1 -0
  403. package/dist/feature/runs/types/attempt.js +106 -0
  404. package/dist/feature/runs/types/attempt.js.map +1 -0
  405. package/dist/feature/runs/types/constants.js +45 -0
  406. package/dist/feature/runs/types/constants.js.map +1 -0
  407. package/dist/feature/runs/types/create.js +177 -0
  408. package/dist/feature/runs/types/create.js.map +1 -0
  409. package/dist/feature/runs/types/group.js +152 -0
  410. package/dist/feature/runs/types/group.js.map +1 -0
  411. package/dist/feature/runs/types/history/attempt-history.js +16 -0
  412. package/dist/feature/runs/types/history/attempt-history.js.map +1 -0
  413. package/dist/feature/runs/types/index.js +15 -0
  414. package/dist/feature/runs/types/index.js.map +1 -0
  415. package/dist/feature/runs/types/input.js +90 -0
  416. package/dist/feature/runs/types/input.js.map +1 -0
  417. package/dist/feature/runs/types/limits.js +163 -0
  418. package/dist/feature/runs/types/limits.js.map +1 -0
  419. package/dist/feature/runs/types/problems.js +74 -0
  420. package/dist/feature/runs/types/problems.js.map +1 -0
  421. package/dist/feature/runs/types/run.js +162 -0
  422. package/dist/feature/runs/types/run.js.map +1 -0
  423. package/dist/feature/runs/types/skip.js +110 -0
  424. package/dist/feature/runs/types/skip.js.map +1 -0
  425. package/dist/feature/runs/types/stage-status.js +156 -0
  426. package/dist/feature/runs/types/stage-status.js.map +1 -0
  427. package/dist/feature/runs/types/stages.js +158 -0
  428. package/dist/feature/runs/types/stages.js.map +1 -0
  429. package/dist/feature/runs/types/topology.js +165 -0
  430. package/dist/feature/runs/types/topology.js.map +1 -0
  431. package/dist/feature/stats/repositories/index.js +4 -0
  432. package/dist/feature/stats/repositories/index.js.map +1 -0
  433. package/dist/feature/stats/repositories/meta.js +19 -0
  434. package/dist/feature/stats/repositories/meta.js.map +1 -0
  435. package/dist/feature/stats/repositories/records.js +46 -0
  436. package/dist/feature/stats/repositories/records.js.map +1 -0
  437. package/dist/feature/stats/repositories/report.js +105 -0
  438. package/dist/feature/stats/repositories/report.js.map +1 -0
  439. package/dist/feature/stats/services/create.js +44 -0
  440. package/dist/feature/stats/services/create.js.map +1 -0
  441. package/dist/feature/stats/services/index.js +4 -0
  442. package/dist/feature/stats/services/index.js.map +1 -0
  443. package/dist/feature/stats/services/ledger.js +137 -0
  444. package/dist/feature/stats/services/ledger.js.map +1 -0
  445. package/dist/feature/stats/services/report.js +56 -0
  446. package/dist/feature/stats/services/report.js.map +1 -0
  447. package/dist/feature/stats/types/aggregate.js +179 -0
  448. package/dist/feature/stats/types/aggregate.js.map +1 -0
  449. package/dist/feature/stats/types/capture.js +79 -0
  450. package/dist/feature/stats/types/capture.js.map +1 -0
  451. package/dist/feature/stats/types/index.js +6 -0
  452. package/dist/feature/stats/types/index.js.map +1 -0
  453. package/dist/feature/stats/types/records.js +5 -0
  454. package/dist/feature/stats/types/records.js.map +1 -0
  455. package/dist/feature/stats/types/report.js +25 -0
  456. package/dist/feature/stats/types/report.js.map +1 -0
  457. package/dist/feature/stats/types/settings.js +2 -0
  458. package/dist/feature/stats/types/settings.js.map +1 -0
  459. package/dist/feature/swarm-config/repositories/config-files.js +141 -0
  460. package/dist/feature/swarm-config/repositories/config-files.js.map +1 -0
  461. package/dist/feature/swarm-config/services/assemble.js +212 -0
  462. package/dist/feature/swarm-config/services/assemble.js.map +1 -0
  463. package/dist/feature/swarm-config/services/create.js +5 -0
  464. package/dist/feature/swarm-config/services/create.js.map +1 -0
  465. package/dist/feature/swarm-config/services/discover.js +19 -0
  466. package/dist/feature/swarm-config/services/discover.js.map +1 -0
  467. package/dist/feature/swarm-config/services/index.js +10 -0
  468. package/dist/feature/swarm-config/services/index.js.map +1 -0
  469. package/dist/feature/swarm-config/services/load.js +101 -0
  470. package/dist/feature/swarm-config/services/load.js.map +1 -0
  471. package/dist/feature/swarm-config/services/sections/stats.js +28 -0
  472. package/dist/feature/swarm-config/services/sections/stats.js.map +1 -0
  473. package/dist/feature/swarm-config/services/settings.js +72 -0
  474. package/dist/feature/swarm-config/services/settings.js.map +1 -0
  475. package/dist/feature/swarm-config/services/validate-actions.js +125 -0
  476. package/dist/feature/swarm-config/services/validate-actions.js.map +1 -0
  477. package/dist/feature/swarm-config/services/validate-context.js +91 -0
  478. package/dist/feature/swarm-config/services/validate-context.js.map +1 -0
  479. package/dist/feature/swarm-config/services/validate-pipelines.js +170 -0
  480. package/dist/feature/swarm-config/services/validate-pipelines.js.map +1 -0
  481. package/dist/feature/swarm-config/services/validate-runtimes.js +214 -0
  482. package/dist/feature/swarm-config/services/validate-runtimes.js.map +1 -0
  483. package/dist/feature/swarm-config/services/validate-settings.js +242 -0
  484. package/dist/feature/swarm-config/services/validate-settings.js.map +1 -0
  485. package/dist/feature/swarm-config/services/validate-specialists.js +152 -0
  486. package/dist/feature/swarm-config/services/validate-specialists.js.map +1 -0
  487. package/dist/feature/swarm-config/services/validate.js +189 -0
  488. package/dist/feature/swarm-config/services/validate.js.map +1 -0
  489. package/dist/feature/swarm-config/types/action.js +20 -0
  490. package/dist/feature/swarm-config/types/action.js.map +1 -0
  491. package/dist/feature/swarm-config/types/chain.js +2 -0
  492. package/dist/feature/swarm-config/types/chain.js.map +1 -0
  493. package/dist/feature/swarm-config/types/duration.js +17 -0
  494. package/dist/feature/swarm-config/types/duration.js.map +1 -0
  495. package/dist/feature/swarm-config/types/errors.js +57 -0
  496. package/dist/feature/swarm-config/types/errors.js.map +1 -0
  497. package/dist/feature/swarm-config/types/index.js +13 -0
  498. package/dist/feature/swarm-config/types/index.js.map +1 -0
  499. package/dist/feature/swarm-config/types/levels.js +16 -0
  500. package/dist/feature/swarm-config/types/levels.js.map +1 -0
  501. package/dist/feature/swarm-config/types/lookups.js +53 -0
  502. package/dist/feature/swarm-config/types/lookups.js.map +1 -0
  503. package/dist/feature/swarm-config/types/merge.js +46 -0
  504. package/dist/feature/swarm-config/types/merge.js.map +1 -0
  505. package/dist/feature/swarm-config/types/pipeline.js +5 -0
  506. package/dist/feature/swarm-config/types/pipeline.js.map +1 -0
  507. package/dist/feature/swarm-config/types/prompt.js +33 -0
  508. package/dist/feature/swarm-config/types/prompt.js.map +1 -0
  509. package/dist/feature/swarm-config/types/settings.js +146 -0
  510. package/dist/feature/swarm-config/types/settings.js.map +1 -0
  511. package/dist/feature/swarm-config/types/specialist.js +38 -0
  512. package/dist/feature/swarm-config/types/specialist.js.map +1 -0
  513. package/dist/feature/swarm-config/types/tag-names.js +43 -0
  514. package/dist/feature/swarm-config/types/tag-names.js.map +1 -0
  515. package/dist/feature/swarm-edit/ports/config-changed.js +2 -0
  516. package/dist/feature/swarm-edit/ports/config-changed.js.map +1 -0
  517. package/dist/feature/swarm-edit/ports/index.js +2 -0
  518. package/dist/feature/swarm-edit/ports/index.js.map +1 -0
  519. package/dist/feature/swarm-edit/repositories/documents.js +144 -0
  520. package/dist/feature/swarm-edit/repositories/documents.js.map +1 -0
  521. package/dist/feature/swarm-edit/services/config-edits.js +129 -0
  522. package/dist/feature/swarm-edit/services/config-edits.js.map +1 -0
  523. package/dist/feature/swarm-edit/services/create.js +7 -0
  524. package/dist/feature/swarm-edit/services/create.js.map +1 -0
  525. package/dist/feature/swarm-edit/services/editor-settings.js +172 -0
  526. package/dist/feature/swarm-edit/services/editor-settings.js.map +1 -0
  527. package/dist/feature/swarm-edit/services/editor-view.js +144 -0
  528. package/dist/feature/swarm-edit/services/editor-view.js.map +1 -0
  529. package/dist/feature/swarm-edit/services/index.js +12 -0
  530. package/dist/feature/swarm-edit/services/index.js.map +1 -0
  531. package/dist/feature/swarm-edit/services/levels.js +30 -0
  532. package/dist/feature/swarm-edit/services/levels.js.map +1 -0
  533. package/dist/feature/swarm-edit/services/plan-edit.js +217 -0
  534. package/dist/feature/swarm-edit/services/plan-edit.js.map +1 -0
  535. package/dist/feature/swarm-edit/services/plan-settings.js +200 -0
  536. package/dist/feature/swarm-edit/services/plan-settings.js.map +1 -0
  537. package/dist/feature/swarm-edit/services/references.js +85 -0
  538. package/dist/feature/swarm-edit/services/references.js.map +1 -0
  539. package/dist/feature/swarm-edit/services/shared-config.js +128 -0
  540. package/dist/feature/swarm-edit/services/shared-config.js.map +1 -0
  541. package/dist/feature/swarm-edit/services/shared-pipelines.js +72 -0
  542. package/dist/feature/swarm-edit/services/shared-pipelines.js.map +1 -0
  543. package/dist/feature/swarm-edit/services/shared-specialists.js +70 -0
  544. package/dist/feature/swarm-edit/services/shared-specialists.js.map +1 -0
  545. package/dist/feature/swarm-edit/services/specialist-tags.js +215 -0
  546. package/dist/feature/swarm-edit/services/specialist-tags.js.map +1 -0
  547. package/dist/feature/swarm-edit/types/editor.js +27 -0
  548. package/dist/feature/swarm-edit/types/editor.js.map +1 -0
  549. package/dist/feature/swarm-edit/types/index.js +7 -0
  550. package/dist/feature/swarm-edit/types/index.js.map +1 -0
  551. package/dist/feature/swarm-edit/types/setting-fields.js +76 -0
  552. package/dist/feature/swarm-edit/types/setting-fields.js.map +1 -0
  553. package/dist/feature/swarm-edit/types/shared.js +2 -0
  554. package/dist/feature/swarm-edit/types/shared.js.map +1 -0
  555. package/dist/feature/swarm-edit/types/stages.js +69 -0
  556. package/dist/feature/swarm-edit/types/stages.js.map +1 -0
  557. package/dist/feature/swarm-edit/types/tag-folders.js +2 -0
  558. package/dist/feature/swarm-edit/types/tag-folders.js.map +1 -0
  559. package/dist/feature/swarm-edit/types/views.js +2 -0
  560. package/dist/feature/swarm-edit/types/views.js.map +1 -0
  561. package/dist/feature/tags/ports/index.js +2 -0
  562. package/dist/feature/tags/ports/index.js.map +1 -0
  563. package/dist/feature/tags/ports/publish.js +2 -0
  564. package/dist/feature/tags/ports/publish.js.map +1 -0
  565. package/dist/feature/tags/repositories/index.js +2 -0
  566. package/dist/feature/tags/repositories/index.js.map +1 -0
  567. package/dist/feature/tags/repositories/tags.js +36 -0
  568. package/dist/feature/tags/repositories/tags.js.map +1 -0
  569. package/dist/feature/tags/services/catalog.js +73 -0
  570. package/dist/feature/tags/services/catalog.js.map +1 -0
  571. package/dist/feature/tags/services/create.js +7 -0
  572. package/dist/feature/tags/services/create.js.map +1 -0
  573. package/dist/feature/tags/services/index.js +3 -0
  574. package/dist/feature/tags/services/index.js.map +1 -0
  575. package/dist/feature/tags/types/ids.js +7 -0
  576. package/dist/feature/tags/types/ids.js.map +1 -0
  577. package/dist/feature/tags/types/index.js +3 -0
  578. package/dist/feature/tags/types/index.js.map +1 -0
  579. package/dist/feature/tags/types/tags.js +184 -0
  580. package/dist/feature/tags/types/tags.js.map +1 -0
  581. package/dist/platform/build/fingerprint.js +36 -0
  582. package/dist/platform/build/fingerprint.js.map +1 -0
  583. package/dist/platform/build/index.js +3 -0
  584. package/dist/platform/build/index.js.map +1 -0
  585. package/dist/platform/build/locations.js +16 -0
  586. package/dist/platform/build/locations.js.map +1 -0
  587. package/dist/platform/errors/app-error.js +39 -0
  588. package/dist/platform/errors/app-error.js.map +1 -0
  589. package/dist/platform/errors/index.js +2 -0
  590. package/dist/platform/errors/index.js.map +1 -0
  591. package/dist/platform/git/delivery.js +284 -0
  592. package/dist/platform/git/delivery.js.map +1 -0
  593. package/dist/platform/git/index.js +4 -0
  594. package/dist/platform/git/index.js.map +1 -0
  595. package/dist/platform/git/runner.js +65 -0
  596. package/dist/platform/git/runner.js.map +1 -0
  597. package/dist/platform/git/workspace.js +366 -0
  598. package/dist/platform/git/workspace.js.map +1 -0
  599. package/dist/platform/network/index.js +4 -0
  600. package/dist/platform/network/index.js.map +1 -0
  601. package/dist/platform/network/interfaces.js +7 -0
  602. package/dist/platform/network/interfaces.js.map +1 -0
  603. package/dist/platform/network/probe.js +128 -0
  604. package/dist/platform/network/probe.js.map +1 -0
  605. package/dist/platform/network/tunnel.js +87 -0
  606. package/dist/platform/network/tunnel.js.map +1 -0
  607. package/dist/platform/paths/index.js +2 -0
  608. package/dist/platform/paths/index.js.map +1 -0
  609. package/dist/platform/paths/paths.js +39 -0
  610. package/dist/platform/paths/paths.js.map +1 -0
  611. package/dist/platform/process/command.js +23 -0
  612. package/dist/platform/process/command.js.map +1 -0
  613. package/dist/platform/process/index.js +4 -0
  614. package/dist/platform/process/index.js.map +1 -0
  615. package/dist/platform/process/ps.js +42 -0
  616. package/dist/platform/process/ps.js.map +1 -0
  617. package/dist/platform/process/which.js +21 -0
  618. package/dist/platform/process/which.js.map +1 -0
  619. package/dist/platform/sqlite/database.js +36 -0
  620. package/dist/platform/sqlite/database.js.map +1 -0
  621. package/dist/platform/sqlite/index.js +4 -0
  622. package/dist/platform/sqlite/index.js.map +1 -0
  623. package/dist/platform/sqlite/migrations.js +299 -0
  624. package/dist/platform/sqlite/migrations.js.map +1 -0
  625. package/dist/platform/sqlite/rows.js +13 -0
  626. package/dist/platform/sqlite/rows.js.map +1 -0
  627. package/dist/platform/sqlite/stats-migration.js +42 -0
  628. package/dist/platform/sqlite/stats-migration.js.map +1 -0
  629. package/dist/presentation/cli/commands/daemon.js +216 -0
  630. package/dist/presentation/cli/commands/daemon.js.map +1 -0
  631. package/dist/presentation/cli/commands/group.js +88 -0
  632. package/dist/presentation/cli/commands/group.js.map +1 -0
  633. package/dist/presentation/cli/commands/mcp.js +44 -0
  634. package/dist/presentation/cli/commands/mcp.js.map +1 -0
  635. package/dist/presentation/cli/commands/queue-edit.js +155 -0
  636. package/dist/presentation/cli/commands/queue-edit.js.map +1 -0
  637. package/dist/presentation/cli/commands/queue.js +222 -0
  638. package/dist/presentation/cli/commands/queue.js.map +1 -0
  639. package/dist/presentation/cli/commands/repositories.js +129 -0
  640. package/dist/presentation/cli/commands/repositories.js.map +1 -0
  641. package/dist/presentation/cli/commands/run-delivery.js +116 -0
  642. package/dist/presentation/cli/commands/run-delivery.js.map +1 -0
  643. package/dist/presentation/cli/commands/run.js +156 -0
  644. package/dist/presentation/cli/commands/run.js.map +1 -0
  645. package/dist/presentation/cli/commands/setup.js +97 -0
  646. package/dist/presentation/cli/commands/setup.js.map +1 -0
  647. package/dist/presentation/cli/commands/stats.js +41 -0
  648. package/dist/presentation/cli/commands/stats.js.map +1 -0
  649. package/dist/presentation/cli/commands/tag.js +92 -0
  650. package/dist/presentation/cli/commands/tag.js.map +1 -0
  651. package/dist/presentation/cli/commands/web.js +100 -0
  652. package/dist/presentation/cli/commands/web.js.map +1 -0
  653. package/dist/presentation/cli/context.js +49 -0
  654. package/dist/presentation/cli/context.js.map +1 -0
  655. package/dist/presentation/cli/help.js +49 -0
  656. package/dist/presentation/cli/help.js.map +1 -0
  657. package/dist/presentation/cli/io.js +13 -0
  658. package/dist/presentation/cli/io.js.map +1 -0
  659. package/dist/presentation/cli/local/clean.js +72 -0
  660. package/dist/presentation/cli/local/clean.js.map +1 -0
  661. package/dist/presentation/cli/local/config-check.js +225 -0
  662. package/dist/presentation/cli/local/config-check.js.map +1 -0
  663. package/dist/presentation/cli/local/init.js +44 -0
  664. package/dist/presentation/cli/local/init.js.map +1 -0
  665. package/dist/presentation/cli/options.js +34 -0
  666. package/dist/presentation/cli/options.js.map +1 -0
  667. package/dist/presentation/cli/probe.js +12 -0
  668. package/dist/presentation/cli/probe.js.map +1 -0
  669. package/dist/presentation/cli/program.js +78 -0
  670. package/dist/presentation/cli/program.js.map +1 -0
  671. package/dist/presentation/cli/setup/actions.js +206 -0
  672. package/dist/presentation/cli/setup/actions.js.map +1 -0
  673. package/dist/presentation/cli/setup/command.js +80 -0
  674. package/dist/presentation/cli/setup/command.js.map +1 -0
  675. package/dist/presentation/cli/setup/host.js +20 -0
  676. package/dist/presentation/cli/setup/host.js.map +1 -0
  677. package/dist/presentation/cli/setup/index.js +5 -0
  678. package/dist/presentation/cli/setup/index.js.map +1 -0
  679. package/dist/presentation/cli/setup/run.js +63 -0
  680. package/dist/presentation/cli/setup/run.js.map +1 -0
  681. package/dist/presentation/cli/setup/system.js +53 -0
  682. package/dist/presentation/cli/setup/system.js.map +1 -0
  683. package/dist/presentation/cli/setup/types.js +3 -0
  684. package/dist/presentation/cli/setup/types.js.map +1 -0
  685. package/dist/presentation/cli/watch.js +24 -0
  686. package/dist/presentation/cli/watch.js.map +1 -0
  687. package/dist/presentation/cli/web-control.js +172 -0
  688. package/dist/presentation/cli/web-control.js.map +1 -0
  689. package/dist/presentation/format/groups.js +99 -0
  690. package/dist/presentation/format/groups.js.map +1 -0
  691. package/dist/presentation/format/index.js +8 -0
  692. package/dist/presentation/format/index.js.map +1 -0
  693. package/dist/presentation/format/queue.js +109 -0
  694. package/dist/presentation/format/queue.js.map +1 -0
  695. package/dist/presentation/format/runs.js +209 -0
  696. package/dist/presentation/format/runs.js.map +1 -0
  697. package/dist/presentation/format/stats.js +79 -0
  698. package/dist/presentation/format/stats.js.map +1 -0
  699. package/dist/presentation/format/style.js +81 -0
  700. package/dist/presentation/format/style.js.map +1 -0
  701. package/dist/presentation/format/table.js +62 -0
  702. package/dist/presentation/format/table.js.map +1 -0
  703. package/dist/presentation/format/tags.js +26 -0
  704. package/dist/presentation/format/tags.js.map +1 -0
  705. package/dist/presentation/ipc/client/autostart.js +171 -0
  706. package/dist/presentation/ipc/client/autostart.js.map +1 -0
  707. package/dist/presentation/ipc/client/client.js +83 -0
  708. package/dist/presentation/ipc/client/client.js.map +1 -0
  709. package/dist/presentation/ipc/client/index.js +4 -0
  710. package/dist/presentation/ipc/client/index.js.map +1 -0
  711. package/dist/presentation/ipc/client/repository-argument.js +13 -0
  712. package/dist/presentation/ipc/client/repository-argument.js.map +1 -0
  713. package/dist/presentation/ipc/contract/agents.js +97 -0
  714. package/dist/presentation/ipc/contract/agents.js.map +1 -0
  715. package/dist/presentation/ipc/contract/artifacts.js +27 -0
  716. package/dist/presentation/ipc/contract/artifacts.js.map +1 -0
  717. package/dist/presentation/ipc/contract/config.js +145 -0
  718. package/dist/presentation/ipc/contract/config.js.map +1 -0
  719. package/dist/presentation/ipc/contract/envelope.js +100 -0
  720. package/dist/presentation/ipc/contract/envelope.js.map +1 -0
  721. package/dist/presentation/ipc/contract/groups.js +57 -0
  722. package/dist/presentation/ipc/contract/groups.js.map +1 -0
  723. package/dist/presentation/ipc/contract/index.js +15 -0
  724. package/dist/presentation/ipc/contract/index.js.map +1 -0
  725. package/dist/presentation/ipc/contract/observers/history.js +26 -0
  726. package/dist/presentation/ipc/contract/observers/history.js.map +1 -0
  727. package/dist/presentation/ipc/contract/observers.js +16 -0
  728. package/dist/presentation/ipc/contract/observers.js.map +1 -0
  729. package/dist/presentation/ipc/contract/panel.js +64 -0
  730. package/dist/presentation/ipc/contract/panel.js.map +1 -0
  731. package/dist/presentation/ipc/contract/processes.js +9 -0
  732. package/dist/presentation/ipc/contract/processes.js.map +1 -0
  733. package/dist/presentation/ipc/contract/queue.js +115 -0
  734. package/dist/presentation/ipc/contract/queue.js.map +1 -0
  735. package/dist/presentation/ipc/contract/repositories.js +33 -0
  736. package/dist/presentation/ipc/contract/repositories.js.map +1 -0
  737. package/dist/presentation/ipc/contract/responses/artifacts.js +2 -0
  738. package/dist/presentation/ipc/contract/responses/artifacts.js.map +1 -0
  739. package/dist/presentation/ipc/contract/responses/config.js +2 -0
  740. package/dist/presentation/ipc/contract/responses/config.js.map +1 -0
  741. package/dist/presentation/ipc/contract/responses/groups.js +2 -0
  742. package/dist/presentation/ipc/contract/responses/groups.js.map +1 -0
  743. package/dist/presentation/ipc/contract/responses/index.js +12 -0
  744. package/dist/presentation/ipc/contract/responses/index.js.map +1 -0
  745. package/dist/presentation/ipc/contract/responses/observer-history.js +2 -0
  746. package/dist/presentation/ipc/contract/responses/observer-history.js.map +1 -0
  747. package/dist/presentation/ipc/contract/responses/observers.js +2 -0
  748. package/dist/presentation/ipc/contract/responses/observers.js.map +1 -0
  749. package/dist/presentation/ipc/contract/responses/processes.js +2 -0
  750. package/dist/presentation/ipc/contract/responses/processes.js.map +1 -0
  751. package/dist/presentation/ipc/contract/responses/queue.js +2 -0
  752. package/dist/presentation/ipc/contract/responses/queue.js.map +1 -0
  753. package/dist/presentation/ipc/contract/responses/repositories.js +2 -0
  754. package/dist/presentation/ipc/contract/responses/repositories.js.map +1 -0
  755. package/dist/presentation/ipc/contract/responses/runs.js +2 -0
  756. package/dist/presentation/ipc/contract/responses/runs.js.map +1 -0
  757. package/dist/presentation/ipc/contract/responses/stats.js +67 -0
  758. package/dist/presentation/ipc/contract/responses/stats.js.map +1 -0
  759. package/dist/presentation/ipc/contract/responses/tags.js +2 -0
  760. package/dist/presentation/ipc/contract/responses/tags.js.map +1 -0
  761. package/dist/presentation/ipc/contract/runs.js +118 -0
  762. package/dist/presentation/ipc/contract/runs.js.map +1 -0
  763. package/dist/presentation/ipc/contract/stats/stats.js +20 -0
  764. package/dist/presentation/ipc/contract/stats/stats.js.map +1 -0
  765. package/dist/presentation/ipc/contract/tags.js +40 -0
  766. package/dist/presentation/ipc/contract/tags.js.map +1 -0
  767. package/dist/presentation/ipc/handlers/config.js +39 -0
  768. package/dist/presentation/ipc/handlers/config.js.map +1 -0
  769. package/dist/presentation/ipc/handlers/groups.js +22 -0
  770. package/dist/presentation/ipc/handlers/groups.js.map +1 -0
  771. package/dist/presentation/ipc/handlers/index.js +2 -0
  772. package/dist/presentation/ipc/handlers/index.js.map +1 -0
  773. package/dist/presentation/ipc/handlers/observers.js +14 -0
  774. package/dist/presentation/ipc/handlers/observers.js.map +1 -0
  775. package/dist/presentation/ipc/handlers/queue.js +36 -0
  776. package/dist/presentation/ipc/handlers/queue.js.map +1 -0
  777. package/dist/presentation/ipc/handlers/repositories.js +26 -0
  778. package/dist/presentation/ipc/handlers/repositories.js.map +1 -0
  779. package/dist/presentation/ipc/handlers/runs.js +55 -0
  780. package/dist/presentation/ipc/handlers/runs.js.map +1 -0
  781. package/dist/presentation/ipc/handlers/stats.js +17 -0
  782. package/dist/presentation/ipc/handlers/stats.js.map +1 -0
  783. package/dist/presentation/ipc/handlers/system.js +40 -0
  784. package/dist/presentation/ipc/handlers/system.js.map +1 -0
  785. package/dist/presentation/ipc/handlers/table.js +25 -0
  786. package/dist/presentation/ipc/handlers/table.js.map +1 -0
  787. package/dist/presentation/ipc/handlers/types.js +2 -0
  788. package/dist/presentation/ipc/handlers/types.js.map +1 -0
  789. package/dist/presentation/ipc/publisher.js +176 -0
  790. package/dist/presentation/ipc/publisher.js.map +1 -0
  791. package/dist/presentation/ipc/server.js +164 -0
  792. package/dist/presentation/ipc/server.js.map +1 -0
  793. package/dist/presentation/ipc/services.js +2 -0
  794. package/dist/presentation/ipc/services.js.map +1 -0
  795. package/dist/presentation/ipc/snapshots.js +60 -0
  796. package/dist/presentation/ipc/snapshots.js.map +1 -0
  797. package/dist/presentation/ipc/views/catalog.js +9 -0
  798. package/dist/presentation/ipc/views/catalog.js.map +1 -0
  799. package/dist/presentation/ipc/views/groups.js +112 -0
  800. package/dist/presentation/ipc/views/groups.js.map +1 -0
  801. package/dist/presentation/ipc/views/index.js +11 -0
  802. package/dist/presentation/ipc/views/index.js.map +1 -0
  803. package/dist/presentation/ipc/views/observer-history.js +26 -0
  804. package/dist/presentation/ipc/views/observer-history.js.map +1 -0
  805. package/dist/presentation/ipc/views/observers.js +16 -0
  806. package/dist/presentation/ipc/views/observers.js.map +1 -0
  807. package/dist/presentation/ipc/views/queue.js +155 -0
  808. package/dist/presentation/ipc/views/queue.js.map +1 -0
  809. package/dist/presentation/ipc/views/repositories.js +34 -0
  810. package/dist/presentation/ipc/views/repositories.js.map +1 -0
  811. package/dist/presentation/ipc/views/rows.js +117 -0
  812. package/dist/presentation/ipc/views/rows.js.map +1 -0
  813. package/dist/presentation/ipc/views/run-stages.js +66 -0
  814. package/dist/presentation/ipc/views/run-stages.js.map +1 -0
  815. package/dist/presentation/ipc/views/runs.js +201 -0
  816. package/dist/presentation/ipc/views/runs.js.map +1 -0
  817. package/dist/presentation/ipc/views/stats.js +5 -0
  818. package/dist/presentation/ipc/views/stats.js.map +1 -0
  819. package/dist/presentation/ipc/views/tags.js +19 -0
  820. package/dist/presentation/ipc/views/tags.js.map +1 -0
  821. package/dist/presentation/mcp/host-kit.js +67 -0
  822. package/dist/presentation/mcp/host-kit.js.map +1 -0
  823. package/dist/presentation/mcp/host-queue-control.js +135 -0
  824. package/dist/presentation/mcp/host-queue-control.js.map +1 -0
  825. package/dist/presentation/mcp/host-queue.js +124 -0
  826. package/dist/presentation/mcp/host-queue.js.map +1 -0
  827. package/dist/presentation/mcp/host-runs.js +173 -0
  828. package/dist/presentation/mcp/host-runs.js.map +1 -0
  829. package/dist/presentation/mcp/host.js +34 -0
  830. package/dist/presentation/mcp/host.js.map +1 -0
  831. package/dist/presentation/mcp/index.js +3 -0
  832. package/dist/presentation/mcp/index.js.map +1 -0
  833. package/dist/presentation/mcp/tools.js +19 -0
  834. package/dist/presentation/mcp/tools.js.map +1 -0
  835. package/dist/presentation/mcp/worker-extra.js +144 -0
  836. package/dist/presentation/mcp/worker-extra.js.map +1 -0
  837. package/dist/presentation/mcp/worker-read.js +45 -0
  838. package/dist/presentation/mcp/worker-read.js.map +1 -0
  839. package/dist/presentation/mcp/worker-tools.js +107 -0
  840. package/dist/presentation/mcp/worker-tools.js.map +1 -0
  841. package/dist/presentation/mcp/worker.js +14 -0
  842. package/dist/presentation/mcp/worker.js.map +1 -0
  843. package/dist/presentation/web/errors.js +60 -0
  844. package/dist/presentation/web/errors.js.map +1 -0
  845. package/dist/presentation/web/http.js +130 -0
  846. package/dist/presentation/web/http.js.map +1 -0
  847. package/dist/presentation/web/hub.js +168 -0
  848. package/dist/presentation/web/hub.js.map +1 -0
  849. package/dist/presentation/web/index.js +7 -0
  850. package/dist/presentation/web/index.js.map +1 -0
  851. package/dist/presentation/web/options.js +7 -0
  852. package/dist/presentation/web/options.js.map +1 -0
  853. package/dist/presentation/web/pages.js +44 -0
  854. package/dist/presentation/web/pages.js.map +1 -0
  855. package/dist/presentation/web/panel/daemon-panel.js +207 -0
  856. package/dist/presentation/web/panel/daemon-panel.js.map +1 -0
  857. package/dist/presentation/web/panel/default-repository.js +14 -0
  858. package/dist/presentation/web/panel/default-repository.js.map +1 -0
  859. package/dist/presentation/web/panel/directories.js +48 -0
  860. package/dist/presentation/web/panel/directories.js.map +1 -0
  861. package/dist/presentation/web/panel/open.js +12 -0
  862. package/dist/presentation/web/panel/open.js.map +1 -0
  863. package/dist/presentation/web/panel/standby.js +119 -0
  864. package/dist/presentation/web/panel/standby.js.map +1 -0
  865. package/dist/presentation/web/panel/state.js +69 -0
  866. package/dist/presentation/web/panel/state.js.map +1 -0
  867. package/dist/presentation/web/panel/system.js +67 -0
  868. package/dist/presentation/web/panel/system.js.map +1 -0
  869. package/dist/presentation/web/request.js +150 -0
  870. package/dist/presentation/web/request.js.map +1 -0
  871. package/dist/presentation/web/routes/config.js +171 -0
  872. package/dist/presentation/web/routes/config.js.map +1 -0
  873. package/dist/presentation/web/routes/downloads.js +65 -0
  874. package/dist/presentation/web/routes/downloads.js.map +1 -0
  875. package/dist/presentation/web/routes/groups.js +85 -0
  876. package/dist/presentation/web/routes/groups.js.map +1 -0
  877. package/dist/presentation/web/routes/observers/history.js +19 -0
  878. package/dist/presentation/web/routes/observers/history.js.map +1 -0
  879. package/dist/presentation/web/routes/processes.js +21 -0
  880. package/dist/presentation/web/routes/processes.js.map +1 -0
  881. package/dist/presentation/web/routes/queue.js +80 -0
  882. package/dist/presentation/web/routes/queue.js.map +1 -0
  883. package/dist/presentation/web/routes/repositories.js +66 -0
  884. package/dist/presentation/web/routes/repositories.js.map +1 -0
  885. package/dist/presentation/web/routes/runs.js +76 -0
  886. package/dist/presentation/web/routes/runs.js.map +1 -0
  887. package/dist/presentation/web/routes/settings.js +74 -0
  888. package/dist/presentation/web/routes/settings.js.map +1 -0
  889. package/dist/presentation/web/routes/specialists.js +74 -0
  890. package/dist/presentation/web/routes/specialists.js.map +1 -0
  891. package/dist/presentation/web/routes/stats/stats.js +22 -0
  892. package/dist/presentation/web/routes/stats/stats.js.map +1 -0
  893. package/dist/presentation/web/routes/system.js +96 -0
  894. package/dist/presentation/web/routes/system.js.map +1 -0
  895. package/dist/presentation/web/routes/tags.js +46 -0
  896. package/dist/presentation/web/routes/tags.js.map +1 -0
  897. package/dist/presentation/web/routes/types.js +2 -0
  898. package/dist/presentation/web/routes/types.js.map +1 -0
  899. package/dist/presentation/web/server.js +187 -0
  900. package/dist/presentation/web/server.js.map +1 -0
  901. package/dist/web/assets/FilterColumn-BCMp-JO4.js +1 -0
  902. package/dist/web/assets/SharedPipelinesGroup-DJRGFtzx.js +1 -0
  903. package/dist/web/assets/badge-C_7kALlW.js +1 -0
  904. package/dist/web/assets/card-C9eXOVuF.js +1 -0
  905. package/dist/web/assets/deliveryModes-funlvXVC.js +1 -0
  906. package/dist/web/assets/empty-ACC2KkXk.js +41 -0
  907. package/dist/web/assets/index-CsVQUXJH.js +21 -0
  908. package/dist/web/assets/index-Ds1nt_qm.css +2 -0
  909. package/dist/web/assets/inter-cyrillic-ext-wght-normal-BOeWTOD4.woff2 +0 -0
  910. package/dist/web/assets/inter-cyrillic-wght-normal-DqGufNeO.woff2 +0 -0
  911. package/dist/web/assets/inter-greek-ext-wght-normal-DlzME5K_.woff2 +0 -0
  912. package/dist/web/assets/inter-greek-wght-normal-CkhJZR-_.woff2 +0 -0
  913. package/dist/web/assets/inter-latin-ext-wght-normal-DO1Apj_S.woff2 +0 -0
  914. package/dist/web/assets/inter-latin-wght-normal-Dx4kXJAl.woff2 +0 -0
  915. package/dist/web/assets/inter-vietnamese-wght-normal-CBcvBZtf.woff2 +0 -0
  916. package/dist/web/assets/locales-fB1w2oER.js +1 -0
  917. package/dist/web/assets/pipelines-DLioOiRN.css +1 -0
  918. package/dist/web/assets/pipelines-DQglwIkL.js +10 -0
  919. package/dist/web/assets/queue-CAuAo--6.js +16 -0
  920. package/dist/web/assets/rolldown-runtime-XKyaHtl9.js +1 -0
  921. package/dist/web/assets/select-BSqaxwh1.js +1 -0
  922. package/dist/web/assets/settingFields-DVg9TQK2.js +1 -0
  923. package/dist/web/assets/settings-6eHKYbS7.js +2 -0
  924. package/dist/web/assets/skeleton-CfLYGtNX.js +1 -0
  925. package/dist/web/assets/specialists-Durm0DgK.js +1 -0
  926. package/dist/web/assets/stats-67akPa3A.js +1 -0
  927. package/dist/web/assets/topology-DQu3su19.js +1 -0
  928. package/dist/web/assets/trash-ChYI9ms1.js +1 -0
  929. package/dist/web/assets/useListDrag-0GPS1X83.js +1 -0
  930. package/dist/web/assets/vendor-markdown-DwXfjc7L.js +32 -0
  931. package/dist/web/assets/vendor-react-C1iE8mnY.js +9 -0
  932. package/dist/web/index.html +22 -0
  933. package/integrations/claude-code/.claude-plugin/plugin.json +19 -0
  934. package/integrations/claude-code/commands/apply.md +6 -0
  935. package/integrations/claude-code/commands/panel.md +6 -0
  936. package/integrations/claude-code/commands/run.md +6 -0
  937. package/integrations/claude-code/commands/status.md +6 -0
  938. package/integrations/claude-code/commands/web.md +6 -0
  939. package/integrations/claude-code/hooks/aip.ts +365 -0
  940. package/integrations/claude-code/hooks/feed.ts +923 -0
  941. package/integrations/claude-code/hooks/hooks.json +1 -0
  942. package/integrations/claude-code/hooks/pane.ts +396 -0
  943. package/integrations/claude-code/hooks/register.tsx +156 -0
  944. package/integrations/claude-code/hooks/theme.ts +59 -0
  945. package/integrations/claude-code/hooks/transcript.tsx +44 -0
  946. package/integrations/claude-code/hooks/view.tsx +378 -0
  947. package/integrations/claude-code/hooks/web.ts +162 -0
  948. package/integrations/claude-code/tsconfig.json +18 -0
  949. package/integrations/claude-code/types/index.d.ts +89 -0
  950. package/package.json +70 -4
  951. package/templates/aip/pipelines/feature.yaml +4 -0
  952. package/templates/aip/settings.yaml +10 -0
  953. package/templates/aip/specialists/coder.yaml +4 -0
  954. package/templates/aip/specialists/reviewer.yaml +5 -0
@@ -0,0 +1,131 @@
1
+ import { rejected } from '../../../platform/errors/index.js';
2
+ import { findGroup, runTitle } from '../../runs/types/index.js';
3
+ import { selectBackground, terminateTree } from './tree.js';
4
+ /** Processes the agents left running: watched while someone listens, killed on request. */
5
+ export class ProcessService {
6
+ dependencies;
7
+ /** Agents that exited, by PID; their process group is background while it has members. */
8
+ departed = new Map();
9
+ cache = null;
10
+ timer = null;
11
+ looking = false;
12
+ /** The list (JSON) subscribers last got, or null. */
13
+ sent = null;
14
+ sentError = null;
15
+ constructor(dependencies) {
16
+ this.dependencies = dependencies;
17
+ }
18
+ /** The list subscribers last got; a new subscriber gets it at once. */
19
+ lastSent() {
20
+ return this.sent === null ? null : JSON.parse(this.sent);
21
+ }
22
+ /** Starts looking at the processes regularly while someone listens. */
23
+ watch() {
24
+ if (this.timer || this.dependencies.stopping())
25
+ return;
26
+ this.timer = setInterval(() => void this.look(), this.dependencies.intervalMs);
27
+ this.timer.unref();
28
+ void this.look();
29
+ }
30
+ /** Stops looking: the last subscriber left. */
31
+ unwatch() {
32
+ this.stop();
33
+ this.sent = null;
34
+ this.sentError = null;
35
+ }
36
+ /** Stops the timer; called when the daemon stops. */
37
+ stop() {
38
+ if (this.timer)
39
+ clearInterval(this.timer);
40
+ this.timer = null;
41
+ }
42
+ /** An agent exited; what it left in its process group is still shown as background. */
43
+ agentGone(root) {
44
+ this.departed.set(root.pid, root);
45
+ }
46
+ async list(fresh = false) {
47
+ const { found } = await this.background(fresh);
48
+ return {
49
+ processes: found.map(({ root, ...process }) => {
50
+ const state = this.dependencies.lookup(root.run) ?? null;
51
+ const group = state && root.group !== null ? findGroup(state, root.group) : null;
52
+ const attempt = group?.attempts.find((candidate) => candidate.seq === root.seq);
53
+ return {
54
+ ...process,
55
+ owner: {
56
+ runId: root.run,
57
+ runTitle: state ? runTitle(state) : root.run,
58
+ repository: state?.run.repository ?? '',
59
+ group: root.group,
60
+ groupTitle: group?.title ?? null,
61
+ step: attempt?.stepId ?? null,
62
+ },
63
+ };
64
+ }),
65
+ };
66
+ }
67
+ async kill(pid) {
68
+ const { rows, found } = await this.background(true);
69
+ if (!found.some((process) => process.pid === pid)) {
70
+ throw rejected(`not a background process: ${pid}`);
71
+ }
72
+ const look = () => void this.look(true);
73
+ setTimeout(look, this.dependencies.killLookMs).unref();
74
+ void terminateTree(pid, {
75
+ rows,
76
+ stillBackground: async () => new Set((await this.background(true)).found.map((process) => process.pid)),
77
+ graceMs: this.dependencies.killGraceMs,
78
+ })
79
+ .catch(() => undefined)
80
+ .then(look);
81
+ return { ok: true };
82
+ }
83
+ /** One look at background processes; tells subscribers when the list or the error changed. */
84
+ async look(fresh = false) {
85
+ const { publish, stopping, roots } = this.dependencies;
86
+ if (this.looking || stopping() || !publish.hasSubscribers())
87
+ return;
88
+ if (!fresh && roots().length === 0 && this.departed.size === 0 && this.sent === '[]')
89
+ return;
90
+ this.looking = true;
91
+ try {
92
+ const { processes } = await this.list(fresh);
93
+ const json = JSON.stringify(processes);
94
+ this.sentError = null;
95
+ if (json === this.sent || !publish.hasSubscribers())
96
+ return;
97
+ this.sent = json;
98
+ publish.processesChanged({ processes });
99
+ }
100
+ catch (error) {
101
+ const message = error instanceof Error ? error.message : String(error);
102
+ if (message === this.sentError || !publish.hasSubscribers())
103
+ return;
104
+ this.sentError = message;
105
+ this.sent = null;
106
+ publish.processesChanged({ error: message });
107
+ }
108
+ finally {
109
+ this.looking = false;
110
+ }
111
+ }
112
+ async rows(fresh) {
113
+ const now = Date.now();
114
+ if (!fresh && this.cache && now - this.cache.at < this.dependencies.cacheMs) {
115
+ return this.cache.rows;
116
+ }
117
+ const rows = await this.dependencies.takeProcesses();
118
+ this.cache = { at: now, rows };
119
+ return rows;
120
+ }
121
+ async background(fresh) {
122
+ const rows = await this.rows(fresh);
123
+ for (const pid of [...this.departed.keys()]) {
124
+ if (!rows.some((row) => row.pgid === pid))
125
+ this.departed.delete(pid);
126
+ }
127
+ const roots = [...this.dependencies.roots(), ...this.departed.values()];
128
+ return { rows, found: selectBackground(rows, roots) };
129
+ }
130
+ }
131
+ //# sourceMappingURL=processes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"processes.js","sourceRoot":"","sources":["../../../../src/feature/processes/services/processes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,mCAAmC,CAAC;AA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CAAC,KAAc;QAC/B,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;QACvB,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,KAAK,IAAI,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,EAAE,GAAG,IAAI,CAAC,YAAY,CAAC,OAAO,EAAE,CAAC;YAC5E,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC;QACzB,CAAC;QACD,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,YAAY,CAAC,aAAa,EAAE,CAAC;QACrD,IAAI,CAAC,KAAK,GAAG,EAAE,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE,CAAC;QAC/B,OAAO,IAAI,CAAC;IACd,CAAC;IAEO,KAAK,CAAC,UAAU,CAAC,KAAc;QACrC,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACpC,KAAK,MAAM,GAAG,IAAI,CAAC,GAAG,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC,EAAE,CAAC;YAC5C,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,IAAI,KAAK,GAAG,CAAC;gBAAE,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QACvE,CAAC;QACD,MAAM,KAAK,GAAG,CAAC,GAAG,IAAI,CAAC,YAAY,CAAC,KAAK,EAAE,EAAE,GAAG,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAC;QACxE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,gBAAgB,CAAC,IAAI,EAAE,KAAK,CAAC,EAAE,CAAC;IACxD,CAAC;CACF"}
@@ -0,0 +1,98 @@
1
+ /** Pause between SIGTERM and SIGKILL of a terminated process tree. */
2
+ export const KILL_GRACE_MS = 5_000;
3
+ /** The MCP server of a specialist: killing it breaks the report of the specialist. */
4
+ function isWorkerServer(args) {
5
+ return /(^|\s)mcp(\s|$)/.test(args) && /(^|\s)--worker(\s|=|$)/.test(args);
6
+ }
7
+ /** Executable name without the directory, from the first word of the command line. */
8
+ function nameOf(args) {
9
+ const first = args.split(/\s+/)[0] ?? '';
10
+ const name = first.slice(first.lastIndexOf('/') + 1);
11
+ return name === '' ? args : name;
12
+ }
13
+ /** Descendants (by parent) and members of the process groups of the roots, longest-running first. */
14
+ export function selectBackground(rows, roots) {
15
+ const children = new Map();
16
+ for (const row of rows) {
17
+ const list = children.get(row.ppid) ?? [];
18
+ list.push(row);
19
+ children.set(row.ppid, list);
20
+ }
21
+ const rootPids = new Set(roots.map((root) => root.pid));
22
+ const owner = new Map();
23
+ for (const root of roots) {
24
+ const pending = [...(children.get(root.pid) ?? [])];
25
+ while (pending.length > 0) {
26
+ const row = pending.pop();
27
+ if (owner.has(row.pid) || rootPids.has(row.pid))
28
+ continue;
29
+ owner.set(row.pid, root);
30
+ pending.push(...(children.get(row.pid) ?? []));
31
+ }
32
+ }
33
+ const byPid = new Map(roots.map((root) => [root.pid, root]));
34
+ for (const row of rows) {
35
+ const root = byPid.get(row.pgid);
36
+ if (root && !owner.has(row.pid) && !rootPids.has(row.pid))
37
+ owner.set(row.pid, root);
38
+ }
39
+ const found = [];
40
+ for (const row of rows) {
41
+ const root = owner.get(row.pid);
42
+ if (!root || isWorkerServer(row.args))
43
+ continue;
44
+ found.push({
45
+ pid: row.pid,
46
+ name: nameOf(row.args),
47
+ command: row.args,
48
+ uptimeSeconds: row.elapsed,
49
+ cpuPercent: row.elapsed > 0 ? (row.cpuSeconds / row.elapsed) * 100 : 0,
50
+ memoryBytes: row.rssKb * 1024,
51
+ root,
52
+ elapsed: row.elapsed,
53
+ });
54
+ }
55
+ found.sort((a, b) => b.elapsed - a.elapsed || a.pid - b.pid);
56
+ return found.map(({ elapsed: _elapsed, ...process }) => process);
57
+ }
58
+ function send(kill, pid, signal) {
59
+ try {
60
+ kill(pid, signal);
61
+ }
62
+ catch (error) {
63
+ if (error.code !== 'ESRCH')
64
+ throw error;
65
+ }
66
+ }
67
+ /**
68
+ * SIGTERM to the process and its descendants, then, after the grace period, SIGKILL to those of
69
+ * them that are still background processes (a PID may have been reused meanwhile).
70
+ */
71
+ export async function terminateTree(pid, options) {
72
+ const kill = options.kill ?? ((target, signal) => process.kill(target, signal));
73
+ const wait = options.wait ?? ((ms) => new Promise((resolve) => setTimeout(resolve, ms).unref()));
74
+ const children = new Map();
75
+ for (const row of options.rows) {
76
+ const list = children.get(row.ppid) ?? [];
77
+ list.push(row.pid);
78
+ children.set(row.ppid, list);
79
+ }
80
+ const targets = [];
81
+ const pending = [pid];
82
+ while (pending.length > 0) {
83
+ const next = pending.shift();
84
+ if (targets.includes(next))
85
+ continue;
86
+ targets.push(next);
87
+ pending.push(...(children.get(next) ?? []));
88
+ }
89
+ for (const target of targets)
90
+ send(kill, target, 'SIGTERM');
91
+ await wait(options.graceMs ?? KILL_GRACE_MS);
92
+ const alive = await options.stillBackground();
93
+ for (const target of targets)
94
+ if (alive.has(target))
95
+ send(kill, target, 'SIGKILL');
96
+ return targets;
97
+ }
98
+ //# sourceMappingURL=tree.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tree.js","sourceRoot":"","sources":["../../../../src/feature/processes/services/tree.ts"],"names":[],"mappings":"AAIA,sEAAsE;AACtE,MAAM,CAAC,MAAM,aAAa,GAAG,KAAK,CAAC;AAMnC,sFAAsF;AACtF,SAAS,cAAc,CAAC,IAAY;IAClC,OAAO,iBAAiB,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,wBAAwB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC7E,CAAC;AAED,sFAAsF;AACtF,SAAS,MAAM,CAAC,IAAY;IAC1B,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;IACzC,MAAM,IAAI,GAAG,KAAK,CAAC,KAAK,CAAC,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QAC/B,MAAM,IAAI,GAAG,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;QAC1C,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QACnB,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IAC/B,CAAC;IACD,MAAM,OAAO,GAAa,EAAE,CAAC;IAC7B,MAAM,OAAO,GAAG,CAAC,GAAG,CAAC,CAAC;IACtB,OAAO,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC1B,MAAM,IAAI,GAAG,OAAO,CAAC,KAAK,EAAG,CAAC;QAC9B,IAAI,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC;YAAE,SAAS;QACrC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACnB,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC;IAC9C,CAAC;IACD,KAAK,MAAM,MAAM,IAAI,OAAO;QAAE,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,CAAC,CAAC;IAC5D,MAAM,IAAI,CAAC,OAAO,CAAC,OAAO,IAAI,aAAa,CAAC,CAAC;IAC7C,MAAM,KAAK,GAAG,MAAM,OAAO,CAAC,eAAe,EAAE,CAAC;IAC9C,KAAK,MAAM,MAAM,IAAI,OAAO;QAAE,IAAI,KAAK,CAAC,GAAG,CAAC,MAAM,CAAC;YAAE,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,CAAC,CAAC;IACnF,OAAO,OAAO,CAAC;AACjB,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=background.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"background.js","sourceRoot":"","sources":["../../../../src/feature/processes/types/background.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/feature/processes/types/index.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/feature/queue/ports/index.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=observe.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"observe.js","sourceRoot":"","sources":["../../../../src/feature/queue/ports/observe.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=publish.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"publish.js","sourceRoot":"","sources":["../../../../src/feature/queue/ports/publish.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=repair-policy.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"repair-policy.js","sourceRoot":"","sources":["../../../../src/feature/queue/ports/repair-policy.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export { QueueRepository } from './queues.js';
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/feature/queue/repositories/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC"}
@@ -0,0 +1,100 @@
1
+ import { DELIVERY_MODES } from '../../swarm-config/types/index.js';
2
+ import { ON_LIMIT_MODES } from '../../runs/types/index.js';
3
+ import { json, nullable, parse, text } from '../../../platform/sqlite/index.js';
4
+ export class QueueRepository {
5
+ database;
6
+ constructor(database) {
7
+ this.database = database;
8
+ }
9
+ loadQueue(repository) {
10
+ const row = this.database
11
+ .prepare('SELECT * FROM queues WHERE repository = ?')
12
+ .get(repository);
13
+ return row ? this.hydrateQueue(row) : null;
14
+ }
15
+ queues() {
16
+ const rows = this.database.prepare('SELECT * FROM queues ORDER BY repository').all();
17
+ return rows.map((row) => this.hydrateQueue(row));
18
+ }
19
+ /** The largest task number among the queue items of the repository; 0 when none. */
20
+ maxItemNumber(repository) {
21
+ const row = this.database
22
+ .prepare('SELECT COALESCE(MAX(number), 0) AS max FROM queue_items WHERE repository = ?')
23
+ .get(repository);
24
+ return Number(row.max);
25
+ }
26
+ /** One statement, no transaction of its own: the scenario of removing a tag opens it. */
27
+ dropItemTag(repository, id) {
28
+ this.database
29
+ .prepare(`UPDATE queue_items SET tags_json = (SELECT json_group_array(value) FROM json_each(tags_json) WHERE value <> ?)
30
+ WHERE repository = ? AND EXISTS (SELECT 1 FROM json_each(tags_json) WHERE value = ?)`)
31
+ .run(id, repository, id);
32
+ }
33
+ /** No transaction of its own: the queue of a project that moved gets its new path. */
34
+ moveQueue(from, to) {
35
+ this.database.exec('PRAGMA defer_foreign_keys = ON');
36
+ this.database
37
+ .prepare('UPDATE queue_items SET repository = ? WHERE repository = ?')
38
+ .run(to, from);
39
+ this.database.prepare('UPDATE queues SET repository = ? WHERE repository = ?').run(to, from);
40
+ }
41
+ saveQueue(queue) {
42
+ this.database.transaction(() => {
43
+ this.database
44
+ .prepare(`INSERT INTO queues (repository, status, parallel, runs_json, acknowledged_json, stop_json, updated_at, autopilot, skip_failed, skipped_json, autopilot_answer, on_limit, next_number, priority_json, auto_answer)
45
+ VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
46
+ ON CONFLICT (repository) DO UPDATE SET status = excluded.status, parallel = excluded.parallel, runs_json = excluded.runs_json, acknowledged_json = excluded.acknowledged_json, stop_json = excluded.stop_json, updated_at = excluded.updated_at, autopilot = excluded.autopilot, skip_failed = excluded.skip_failed, skipped_json = excluded.skipped_json, autopilot_answer = excluded.autopilot_answer, on_limit = excluded.on_limit, next_number = excluded.next_number, priority_json = excluded.priority_json, auto_answer = excluded.auto_answer`)
47
+ .run(queue.repository, queue.status, queue.parallel, JSON.stringify(queue.runs), JSON.stringify(queue.acknowledged), json(queue.stop), queue.updatedAt, queue.autopilot ? 1 : 0, queue.skipFailed ? 1 : 0, JSON.stringify(queue.skipped), queue.autopilotAnswer, queue.onLimit, queue.nextNumber, JSON.stringify(queue.priority), queue.autoAnswer ? 1 : 0);
48
+ this.database.prepare('DELETE FROM queue_items WHERE repository = ?').run(queue.repository);
49
+ const insert = this.database.prepare(`INSERT INTO queue_items (id, repository, position, pipeline, task, groups_json, title, error, created_at, auto_deliver, tags_json, skip_json, after_json, delivery_mode, run_id, postponed, number)
50
+ VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`);
51
+ queue.items.forEach((item, position) => insert.run(item.id, queue.repository, position, item.pipeline, item.task, json(item.groups), item.title, item.error, item.createdAt, item.autoDeliver === null ? null : item.autoDeliver ? 1 : 0, JSON.stringify(item.tags), JSON.stringify(item.skip), JSON.stringify(item.after), item.deliveryMode, item.run, item.postponed ? 1 : 0, item.number));
52
+ });
53
+ }
54
+ hydrateQueue(row) {
55
+ const repository = String(row.repository);
56
+ const items = this.database
57
+ .prepare('SELECT * FROM queue_items WHERE repository = ? ORDER BY position')
58
+ .all(repository);
59
+ return {
60
+ repository,
61
+ status: String(row.status),
62
+ parallel: Number(row.parallel),
63
+ autopilot: Number(row.autopilot ?? 0) === 1,
64
+ autoAnswer: Number(row.auto_answer ?? 0) === 1,
65
+ skipFailed: Number(row.skip_failed ?? 0) === 1,
66
+ skipped: row.skipped_json ? parse(row.skipped_json) : [],
67
+ autopilotAnswer: text(row.autopilot_answer ?? null),
68
+ onLimit: ON_LIMIT_MODES.find((mode) => mode === row.on_limit) ?? 'wait',
69
+ nextNumber: Number(row.next_number ?? 1),
70
+ priority: row.priority_json ? parse(row.priority_json) : [],
71
+ items: items.map(hydrateItem),
72
+ runs: parse(row.runs_json ?? null),
73
+ acknowledged: parse(row.acknowledged_json ?? null),
74
+ stop: nullable(row.stop_json ?? null),
75
+ updatedAt: Number(row.updated_at),
76
+ };
77
+ }
78
+ }
79
+ function hydrateItem(item) {
80
+ return {
81
+ id: String(item.id),
82
+ number: Number(item.number),
83
+ pipeline: String(item.pipeline),
84
+ task: text(item.task ?? null),
85
+ groups: nullable(item.groups_json ?? null),
86
+ title: text(item.title ?? null),
87
+ autoDeliver: item.auto_deliver === null || item.auto_deliver === undefined
88
+ ? null
89
+ : Number(item.auto_deliver) === 1,
90
+ deliveryMode: DELIVERY_MODES.find((mode) => mode === item.delivery_mode) ?? null,
91
+ tags: item.tags_json ? parse(item.tags_json) : [],
92
+ skip: item.skip_json ? parse(item.skip_json) : [],
93
+ after: item.after_json ? parse(item.after_json) : [],
94
+ postponed: Number(item.postponed ?? 0) === 1,
95
+ createdAt: Number(item.created_at),
96
+ error: text(item.error ?? null),
97
+ run: text(item.run_id ?? null),
98
+ };
99
+ }
100
+ //# sourceMappingURL=queues.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"queues.js","sourceRoot":"","sources":["../../../../src/feature/queue/repositories/queues.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAC;AACnE,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAE3D,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,mCAAmC,CAAC;AAGhF,MAAM,OAAO,eAAe;IACT,QAAQ,CAAW;IAEpC,YAAY,QAAkB;QAC5B,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC3B,CAAC;IAED,SAAS,CAAC,UAAkB;QAC1B,MAAM,GAAG,GAAG,IAAI,CAAC,QAAQ;aACtB,OAAO,CAAC,2CAA2C,CAAC;aACpD,GAAG,CAAC,UAAU,CAAoB,CAAC;QACtC,OAAO,GAAG,CAAC,CAAC,CAAC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EAAE,CAAC,IAAI,KAAK,IAAI,CAAC,aAAa,CAAC,IAAI,IAAI;QAChF,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,EAAE;QACjD,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,EAAE;QACjD,KAAK,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,EAAE;QACpD,SAAS,EAAE,MAAM,CAAC,IAAI,CAAC,SAAS,IAAI,CAAC,CAAC,KAAK,CAAC;QAC5C,SAAS,EAAE,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC;QAClC,KAAK,EAAE,IAAI,CAAC,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC;QAC/B,GAAG,EAAE,IAAI,CAAC,IAAI,CAAC,MAAM,IAAI,IAAI,CAAC;KAC/B,CAAC;AACJ,CAAC"}
@@ -0,0 +1,214 @@
1
+ import { randomInt } from 'node:crypto';
2
+ import { isRejected, rejected } from '../../../platform/errors/index.js';
3
+ import { currentPermissions } from '../../runs/services/index.js';
4
+ import { retryableGroups, runCreated, } from '../../runs/types/index.js';
5
+ import { knownTags } from '../../tags/types/index.js';
6
+ import { acknowledgeRun, advance, autopilotAnswers, claimPlace, itemFailed, itemStarted, queueItemId, queueWakeAt, } from '../types/index.js';
7
+ /** The arguments of `run` that an item of the queue stands for. */
8
+ function itemRequest(queue, item) {
9
+ return {
10
+ repository: queue.repository,
11
+ pipeline: item.pipeline,
12
+ ...(item.task !== null ? { task: item.task } : {}),
13
+ ...(item.groups !== null ? { groups: item.groups } : {}),
14
+ ...(item.title !== null ? { title: item.title } : {}),
15
+ ...(item.autoDeliver !== null ? { autoDeliver: item.autoDeliver } : {}),
16
+ ...(item.deliveryMode !== null ? { deliveryMode: item.deliveryMode } : {}),
17
+ ...(item.skip.length > 0 ? { skip: item.skip } : {}),
18
+ };
19
+ }
20
+ /** The queue moves on: it starts items, freezes and resumes runs, answers for the autopilot. */
21
+ export class QueueAdvance {
22
+ dependencies;
23
+ requested = new Set();
24
+ constructor(dependencies) {
25
+ this.dependencies = dependencies;
26
+ }
27
+ /** A run was saved: the queue of its repository looks at it when it holds or waits for it. */
28
+ runChanged(state) {
29
+ const queue = this.dependencies.store.get(state.run.repository);
30
+ if (queue &&
31
+ (queue.runs.length > 0 ||
32
+ queue.skipped.includes(state.run.id) ||
33
+ queue.items.some((item) => item.after.includes(state.run.id)))) {
34
+ this.request(state.run.repository);
35
+ }
36
+ }
37
+ /** Looks at the queue of the repository once, however many changes arrive meanwhile. */
38
+ request(repository) {
39
+ const { engine } = this.dependencies.runs;
40
+ if (engine.stopping || this.requested.has(repository))
41
+ return;
42
+ this.requested.add(repository);
43
+ void engine
44
+ .serial(async () => {
45
+ this.requested.delete(repository);
46
+ if (!engine.stopping)
47
+ await this.advance(repository);
48
+ })
49
+ .catch(() => undefined);
50
+ }
51
+ /** A look at the queue of the repository is pending: the autopilot answers there first. */
52
+ pending(repository) {
53
+ return this.requested.has(repository);
54
+ }
55
+ /** What a usage limit does to the groups of the repository's runs: the queue's setting. */
56
+ onLimitOf(repository) {
57
+ return this.dependencies.store.of(repository).onLimit;
58
+ }
59
+ /** Moments a queue stopped by a usage limit may start again. */
60
+ wakeMoments() {
61
+ return this.dependencies.store.all().flatMap((queue) => queueWakeAt(queue) ?? []);
62
+ }
63
+ /** Starts the queues that resume after a usage limit. */
64
+ async wake() {
65
+ for (const queue of this.dependencies.store.all()) {
66
+ if (queue.stop?.kind === 'limit')
67
+ await this.advance(queue.repository);
68
+ }
69
+ }
70
+ /** At the start: the queues that run, hold runs or wait for a usage limit move on. */
71
+ async resume() {
72
+ for (const queue of this.dependencies.store.all()) {
73
+ if (queue.status === 'running' ||
74
+ queue.runs.length > 0 ||
75
+ queue.skipped.length > 0 ||
76
+ queue.stop?.kind === 'limit') {
77
+ await this.advance(queue.repository);
78
+ }
79
+ }
80
+ }
81
+ /** Moves the queue on; returns the runs created for its items, by item id. */
82
+ async advance(repository) {
83
+ const { store, runs, repair, now } = this.dependencies;
84
+ const queue = store.of(repository);
85
+ const fingerprint = () => JSON.stringify({ ...queue, updatedAt: 0 });
86
+ const before = fingerprint();
87
+ const states = queue.runs.flatMap((id) => runs.states.lookup(id) ?? []);
88
+ // An incident an observer takes does not stop the queue.
89
+ for (const state of states)
90
+ if (repair.takesIncident(state))
91
+ acknowledgeRun(queue, state);
92
+ const lookup = (id) => runs.states.lookup(id);
93
+ const { take, freeze } = advance(queue, states, lookup, now());
94
+ const changedBefore = fingerprint() !== before;
95
+ for (const id of freeze)
96
+ await this.freeze(id);
97
+ await this.answerForAutopilot(queue);
98
+ const { started, changed, failed } = await this.takeItems(queue, take);
99
+ if (changedBefore || changed)
100
+ store.save(queue);
101
+ else
102
+ store.check(queue);
103
+ if ((take.length > 0 && queue.runs.length > 0) || (failed && queue.status === 'running')) {
104
+ this.request(repository);
105
+ }
106
+ runs.engine.armWake();
107
+ // After the autopilot: the incidents it did not answer are the observers'.
108
+ this.dependencies.observe.request();
109
+ return started;
110
+ }
111
+ /** Sets `hold: frozen` on a run the queue has taken off its places for a priority run. */
112
+ async freeze(id) {
113
+ const state = this.dependencies.runs.states.lookup(id);
114
+ if (!state)
115
+ return;
116
+ try {
117
+ await this.dependencies.runs.engine.apply(state, { kind: 'hold', hold: 'frozen' });
118
+ }
119
+ catch (error) {
120
+ if (!isRejected(error))
121
+ throw error;
122
+ }
123
+ }
124
+ /** A priority action: the run takes a place, and the last run that took one may be frozen. */
125
+ async claimPlace(queue, run) {
126
+ const { runs, now } = this.dependencies;
127
+ const moment = now();
128
+ const states = queue.runs.flatMap((id) => runs.states.lookup(id) ?? []);
129
+ const frozen = claimPlace(queue, states, run, queueItemId(moment, randomInt(36 ** 3)), moment);
130
+ if (frozen !== null)
131
+ await this.freeze(frozen);
132
+ }
133
+ /**
134
+ * Takes a returned run: retries its failed and cancelled groups, and the run holds a place in
135
+ * the queue instead of the item.
136
+ */
137
+ async takeReturned(queue, item) {
138
+ const { runs, config, now } = this.dependencies;
139
+ const id = item.run;
140
+ const state = runs.states.lookup(id);
141
+ if (!state)
142
+ throw rejected(`unknown run \`${id}\``);
143
+ const held = state.run.hold !== null;
144
+ if (held)
145
+ await runs.engine.apply(state, { kind: 'hold', hold: null });
146
+ const groups = retryableGroups(state);
147
+ if (groups.length === 0 && !held)
148
+ throw rejected('run has no failed or cancelled groups');
149
+ for (const group of groups) {
150
+ const permissions = currentPermissions(config, state);
151
+ await runs.engine.apply(state, { kind: 'retry', group, permissions });
152
+ }
153
+ acknowledgeRun(queue, state);
154
+ itemStarted(queue, item.id, id, now());
155
+ return runCreated(state);
156
+ }
157
+ /** Creates the run of an item of the queue with the item's tags still in the catalog. */
158
+ createRun(queue, item) {
159
+ const tags = knownTags(this.dependencies.tags.of(queue.repository), item.tags);
160
+ return this.dependencies.runs.requests.create(itemRequest(queue, item), tags, item);
161
+ }
162
+ async answerForAutopilot(queue) {
163
+ const { runs, config } = this.dependencies;
164
+ const current = queue.runs.flatMap((id) => runs.states.lookup(id) ?? []);
165
+ for (const answer of autopilotAnswers(queue, current)) {
166
+ const state = runs.states.lookup(answer.run);
167
+ if (!state)
168
+ continue;
169
+ try {
170
+ await runs.engine.apply(state, {
171
+ kind: 'answer',
172
+ group: answer.group,
173
+ answer: answer.answer,
174
+ by: 'autopilot',
175
+ permissions: currentPermissions(config, state),
176
+ });
177
+ }
178
+ catch (error) {
179
+ if (!isRejected(error))
180
+ throw error;
181
+ }
182
+ }
183
+ }
184
+ async takeItems(queue, take) {
185
+ const { store, now } = this.dependencies;
186
+ const started = new Map();
187
+ let changed = false;
188
+ let failed = false;
189
+ for (const item of take) {
190
+ try {
191
+ if (item.run !== null) {
192
+ await this.takeReturned(queue, item);
193
+ }
194
+ else {
195
+ const created = await this.createRun(queue, item);
196
+ itemStarted(queue, item.id, created.runId, now());
197
+ started.set(item.id, created);
198
+ }
199
+ store.write(queue);
200
+ }
201
+ catch (error) {
202
+ itemFailed(queue, item.id, error.message, now());
203
+ changed = true;
204
+ if (!queue.skipFailed)
205
+ break;
206
+ failed = true;
207
+ continue;
208
+ }
209
+ changed = true;
210
+ }
211
+ return { started, changed, failed };
212
+ }
213
+ }
214
+ //# sourceMappingURL=advance.js.map