@hoknie/aip 0.0.0-stage → 0.1.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 (1081) hide show
  1. package/.claude-plugin/marketplace.json +13 -0
  2. package/README.md +74 -2
  3. package/dist/app/agents.js +18 -0
  4. package/dist/app/agents.js.map +1 -0
  5. package/dist/app/application.js +173 -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 +30 -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 +23 -0
  16. package/dist/app/timings.js.map +1 -0
  17. package/dist/app/wiring.js +57 -0
  18. package/dist/app/wiring.js.map +1 -0
  19. package/dist/cli/clean.js +71 -0
  20. package/dist/cli/clean.js.map +1 -0
  21. package/dist/cli/commands.js +963 -0
  22. package/dist/cli/commands.js.map +1 -0
  23. package/dist/cli/config-check.js +173 -0
  24. package/dist/cli/config-check.js.map +1 -0
  25. package/dist/cli/daemon.js +199 -0
  26. package/dist/cli/daemon.js.map +1 -0
  27. package/dist/cli/help.js +50 -0
  28. package/dist/cli/help.js.map +1 -0
  29. package/dist/cli/init.js +43 -0
  30. package/dist/cli/init.js.map +1 -0
  31. package/dist/cli/io.js +13 -0
  32. package/dist/cli/io.js.map +1 -0
  33. package/dist/cli/main.js +31 -0
  34. package/dist/cli/main.js.map +1 -0
  35. package/dist/cli/probe.js +12 -0
  36. package/dist/cli/probe.js.map +1 -0
  37. package/dist/cli/program.js +48 -0
  38. package/dist/cli/program.js.map +1 -0
  39. package/dist/cli/setup.js +406 -0
  40. package/dist/cli/setup.js.map +1 -0
  41. package/dist/cli/version.js +6 -0
  42. package/dist/cli/version.js.map +1 -0
  43. package/dist/cli/watch.js +24 -0
  44. package/dist/cli/watch.js.map +1 -0
  45. package/dist/cli/web/daemon-panel.js +185 -0
  46. package/dist/cli/web/daemon-panel.js.map +1 -0
  47. package/dist/cli/web/default-repository.js +12 -0
  48. package/dist/cli/web/default-repository.js.map +1 -0
  49. package/dist/cli/web/errors.js +60 -0
  50. package/dist/cli/web/errors.js.map +1 -0
  51. package/dist/cli/web/open.js +12 -0
  52. package/dist/cli/web/open.js.map +1 -0
  53. package/dist/cli/web/page.js +465 -0
  54. package/dist/cli/web/page.js.map +1 -0
  55. package/dist/cli/web/server.js +1191 -0
  56. package/dist/cli/web/server.js.map +1 -0
  57. package/dist/cli/web/standby.js +119 -0
  58. package/dist/cli/web/standby.js.map +1 -0
  59. package/dist/cli/web/state.js +69 -0
  60. package/dist/cli/web/state.js.map +1 -0
  61. package/dist/cli/web/system.js +66 -0
  62. package/dist/cli/web/system.js.map +1 -0
  63. package/dist/cli/web-control.js +173 -0
  64. package/dist/cli/web-control.js.map +1 -0
  65. package/dist/config/discover.js +25 -0
  66. package/dist/config/discover.js.map +1 -0
  67. package/dist/config/duration.js +17 -0
  68. package/dist/config/duration.js.map +1 -0
  69. package/dist/config/edit.js +966 -0
  70. package/dist/config/edit.js.map +1 -0
  71. package/dist/config/errors.js +29 -0
  72. package/dist/config/errors.js.map +1 -0
  73. package/dist/config/index.js +14 -0
  74. package/dist/config/index.js.map +1 -0
  75. package/dist/config/load.js +412 -0
  76. package/dist/config/load.js.map +1 -0
  77. package/dist/config/merge.js +45 -0
  78. package/dist/config/merge.js.map +1 -0
  79. package/dist/config/model.js +171 -0
  80. package/dist/config/model.js.map +1 -0
  81. package/dist/config/paths.js +31 -0
  82. package/dist/config/paths.js.map +1 -0
  83. package/dist/config/prompt.js +33 -0
  84. package/dist/config/prompt.js.map +1 -0
  85. package/dist/config/shared-pipelines.js +71 -0
  86. package/dist/config/shared-pipelines.js.map +1 -0
  87. package/dist/config/shared-specialists.js +68 -0
  88. package/dist/config/shared-specialists.js.map +1 -0
  89. package/dist/config/shared-workflows.js +71 -0
  90. package/dist/config/shared-workflows.js.map +1 -0
  91. package/dist/config/specialist-tags.js +214 -0
  92. package/dist/config/specialist-tags.js.map +1 -0
  93. package/dist/config/tag-names.js +43 -0
  94. package/dist/config/tag-names.js.map +1 -0
  95. package/dist/config/validate.js +872 -0
  96. package/dist/config/validate.js.map +1 -0
  97. package/dist/core/artifacts.js +37 -0
  98. package/dist/core/artifacts.js.map +1 -0
  99. package/dist/core/create.js +75 -0
  100. package/dist/core/create.js.map +1 -0
  101. package/dist/core/delivery.js +366 -0
  102. package/dist/core/delivery.js.map +1 -0
  103. package/dist/core/errors.js +7 -0
  104. package/dist/core/errors.js.map +1 -0
  105. package/dist/core/ids.js +99 -0
  106. package/dist/core/ids.js.map +1 -0
  107. package/dist/core/index.js +21 -0
  108. package/dist/core/index.js.map +1 -0
  109. package/dist/core/input.js +45 -0
  110. package/dist/core/input.js.map +1 -0
  111. package/dist/core/machine.js +1021 -0
  112. package/dist/core/machine.js.map +1 -0
  113. package/dist/core/model.js +460 -0
  114. package/dist/core/model.js.map +1 -0
  115. package/dist/core/observer.js +193 -0
  116. package/dist/core/observer.js.map +1 -0
  117. package/dist/core/occupancy.js +63 -0
  118. package/dist/core/occupancy.js.map +1 -0
  119. package/dist/core/permissions.js +222 -0
  120. package/dist/core/permissions.js.map +1 -0
  121. package/dist/core/plan.js +99 -0
  122. package/dist/core/plan.js.map +1 -0
  123. package/dist/core/progress.js +43 -0
  124. package/dist/core/progress.js.map +1 -0
  125. package/dist/core/questions.js +19 -0
  126. package/dist/core/questions.js.map +1 -0
  127. package/dist/core/queue.js +859 -0
  128. package/dist/core/queue.js.map +1 -0
  129. package/dist/core/retryable.js +8 -0
  130. package/dist/core/retryable.js.map +1 -0
  131. package/dist/core/scheduler.js +160 -0
  132. package/dist/core/scheduler.js.map +1 -0
  133. package/dist/core/skip.js +109 -0
  134. package/dist/core/skip.js.map +1 -0
  135. package/dist/core/stages.js +304 -0
  136. package/dist/core/stages.js.map +1 -0
  137. package/dist/core/summary.js +35 -0
  138. package/dist/core/summary.js.map +1 -0
  139. package/dist/core/tags.js +184 -0
  140. package/dist/core/tags.js.map +1 -0
  141. package/dist/core/topology.js +162 -0
  142. package/dist/core/topology.js.map +1 -0
  143. package/dist/daemon/artifacts.js +84 -0
  144. package/dist/daemon/artifacts.js.map +1 -0
  145. package/dist/daemon/daemon.js +1442 -0
  146. package/dist/daemon/daemon.js.map +1 -0
  147. package/dist/daemon/executor.js +749 -0
  148. package/dist/daemon/executor.js.map +1 -0
  149. package/dist/daemon/helpers.js +38 -0
  150. package/dist/daemon/helpers.js.map +1 -0
  151. package/dist/daemon/index.js +4 -0
  152. package/dist/daemon/index.js.map +1 -0
  153. package/dist/daemon/logs.js +69 -0
  154. package/dist/daemon/logs.js.map +1 -0
  155. package/dist/daemon/observers.js +93 -0
  156. package/dist/daemon/observers.js.map +1 -0
  157. package/dist/daemon/patches.js +76 -0
  158. package/dist/daemon/patches.js.map +1 -0
  159. package/dist/daemon/ports.js +2 -0
  160. package/dist/daemon/ports.js.map +1 -0
  161. package/dist/daemon/processes.js +98 -0
  162. package/dist/daemon/processes.js.map +1 -0
  163. package/dist/daemon/repositories.js +2 -0
  164. package/dist/daemon/repositories.js.map +1 -0
  165. package/dist/daemon/server.js +164 -0
  166. package/dist/daemon/server.js.map +1 -0
  167. package/dist/daemon/supervisor.js +140 -0
  168. package/dist/daemon/supervisor.js.map +1 -0
  169. package/dist/daemon/timings.js +23 -0
  170. package/dist/daemon/timings.js.map +1 -0
  171. package/dist/feature/agents/clients/agy/events.js +36 -0
  172. package/dist/feature/agents/clients/agy/events.js.map +1 -0
  173. package/dist/feature/agents/clients/agy/guard-commands.js +29 -0
  174. package/dist/feature/agents/clients/agy/guard-commands.js.map +1 -0
  175. package/dist/feature/agents/clients/agy/guard-paths.js +36 -0
  176. package/dist/feature/agents/clients/agy/guard-paths.js.map +1 -0
  177. package/dist/feature/agents/clients/agy/guard.js +77 -0
  178. package/dist/feature/agents/clients/agy/guard.js.map +1 -0
  179. package/dist/feature/agents/clients/agy/hooks.js +46 -0
  180. package/dist/feature/agents/clients/agy/hooks.js.map +1 -0
  181. package/dist/feature/agents/clients/agy/index.js +5 -0
  182. package/dist/feature/agents/clients/agy/index.js.map +1 -0
  183. package/dist/feature/agents/clients/agy/parser.js +63 -0
  184. package/dist/feature/agents/clients/agy/parser.js.map +1 -0
  185. package/dist/feature/agents/clients/agy/permissions.js +40 -0
  186. package/dist/feature/agents/clients/agy/permissions.js.map +1 -0
  187. package/dist/feature/agents/clients/agy/runtime.js +114 -0
  188. package/dist/feature/agents/clients/agy/runtime.js.map +1 -0
  189. package/dist/feature/agents/clients/agy/transcript.js +65 -0
  190. package/dist/feature/agents/clients/agy/transcript.js.map +1 -0
  191. package/dist/feature/agents/clients/claude/index.js +5 -0
  192. package/dist/feature/agents/clients/claude/index.js.map +1 -0
  193. package/dist/feature/agents/clients/claude/parser.js +221 -0
  194. package/dist/feature/agents/clients/claude/parser.js.map +1 -0
  195. package/dist/feature/agents/clients/claude/permissions.js +70 -0
  196. package/dist/feature/agents/clients/claude/permissions.js.map +1 -0
  197. package/dist/feature/agents/clients/claude/runtime.js +116 -0
  198. package/dist/feature/agents/clients/claude/runtime.js.map +1 -0
  199. package/dist/feature/agents/clients/claude/transcript.js +105 -0
  200. package/dist/feature/agents/clients/claude/transcript.js.map +1 -0
  201. package/dist/feature/agents/clients/naming/index.js +2 -0
  202. package/dist/feature/agents/clients/naming/index.js.map +1 -0
  203. package/dist/feature/agents/clients/naming/naming.js +15 -0
  204. package/dist/feature/agents/clients/naming/naming.js.map +1 -0
  205. package/dist/feature/agents/clients/opencode/index.js +4 -0
  206. package/dist/feature/agents/clients/opencode/index.js.map +1 -0
  207. package/dist/feature/agents/clients/opencode/parser.js +84 -0
  208. package/dist/feature/agents/clients/opencode/parser.js.map +1 -0
  209. package/dist/feature/agents/clients/opencode/runtime.js +129 -0
  210. package/dist/feature/agents/clients/opencode/runtime.js.map +1 -0
  211. package/dist/feature/agents/clients/opencode/transcript.js +77 -0
  212. package/dist/feature/agents/clients/opencode/transcript.js.map +1 -0
  213. package/dist/feature/agents/ports/index.js +2 -0
  214. package/dist/feature/agents/ports/index.js.map +1 -0
  215. package/dist/feature/agents/ports/naming.js +2 -0
  216. package/dist/feature/agents/ports/naming.js.map +1 -0
  217. package/dist/feature/agents/ports/runtime-factory.js +2 -0
  218. package/dist/feature/agents/ports/runtime-factory.js.map +1 -0
  219. package/dist/feature/agents/services/agents.js +38 -0
  220. package/dist/feature/agents/services/agents.js.map +1 -0
  221. package/dist/feature/agents/services/catalog.js +117 -0
  222. package/dist/feature/agents/services/catalog.js.map +1 -0
  223. package/dist/feature/agents/services/create.js +5 -0
  224. package/dist/feature/agents/services/create.js.map +1 -0
  225. package/dist/feature/agents/services/index.js +7 -0
  226. package/dist/feature/agents/services/index.js.map +1 -0
  227. package/dist/feature/agents/services/logs.js +69 -0
  228. package/dist/feature/agents/services/logs.js.map +1 -0
  229. package/dist/feature/agents/services/skills.js +17 -0
  230. package/dist/feature/agents/services/skills.js.map +1 -0
  231. package/dist/feature/agents/services/supervisor.js +160 -0
  232. package/dist/feature/agents/services/supervisor.js.map +1 -0
  233. package/dist/feature/agents/types/catalog.js +2 -0
  234. package/dist/feature/agents/types/catalog.js.map +1 -0
  235. package/dist/feature/agents/types/index.js +12 -0
  236. package/dist/feature/agents/types/index.js.map +1 -0
  237. package/dist/feature/agents/types/message.js +48 -0
  238. package/dist/feature/agents/types/message.js.map +1 -0
  239. package/dist/feature/agents/types/naming.js +4 -0
  240. package/dist/feature/agents/types/naming.js.map +1 -0
  241. package/dist/feature/agents/types/permissions.js +235 -0
  242. package/dist/feature/agents/types/permissions.js.map +1 -0
  243. package/dist/feature/agents/types/run-naming.js +66 -0
  244. package/dist/feature/agents/types/run-naming.js.map +1 -0
  245. package/dist/feature/agents/types/runtime.js +18 -0
  246. package/dist/feature/agents/types/runtime.js.map +1 -0
  247. package/dist/feature/agents/types/step-input.js +2 -0
  248. package/dist/feature/agents/types/step-input.js.map +1 -0
  249. package/dist/feature/agents/types/transcript-parts.js +62 -0
  250. package/dist/feature/agents/types/transcript-parts.js.map +1 -0
  251. package/dist/feature/agents/types/transcript.js +8 -0
  252. package/dist/feature/agents/types/transcript.js.map +1 -0
  253. package/dist/feature/agents/types/usage.js +14 -0
  254. package/dist/feature/agents/types/usage.js.map +1 -0
  255. package/dist/feature/agents/types/worker-tools.js +20 -0
  256. package/dist/feature/agents/types/worker-tools.js.map +1 -0
  257. package/dist/feature/artifacts/ports/index.js +2 -0
  258. package/dist/feature/artifacts/ports/index.js.map +1 -0
  259. package/dist/feature/artifacts/ports/publish.js +2 -0
  260. package/dist/feature/artifacts/ports/publish.js.map +1 -0
  261. package/dist/feature/artifacts/repositories/artifact-storage.js +84 -0
  262. package/dist/feature/artifacts/repositories/artifact-storage.js.map +1 -0
  263. package/dist/feature/artifacts/repositories/artifacts.js +85 -0
  264. package/dist/feature/artifacts/repositories/artifacts.js.map +1 -0
  265. package/dist/feature/artifacts/repositories/index.js +3 -0
  266. package/dist/feature/artifacts/repositories/index.js.map +1 -0
  267. package/dist/feature/artifacts/services/artifacts.js +105 -0
  268. package/dist/feature/artifacts/services/artifacts.js.map +1 -0
  269. package/dist/feature/artifacts/services/create.js +14 -0
  270. package/dist/feature/artifacts/services/create.js.map +1 -0
  271. package/dist/feature/artifacts/services/files.js +42 -0
  272. package/dist/feature/artifacts/services/files.js.map +1 -0
  273. package/dist/feature/artifacts/services/index.js +3 -0
  274. package/dist/feature/artifacts/services/index.js.map +1 -0
  275. package/dist/feature/artifacts/types/artifacts.js +36 -0
  276. package/dist/feature/artifacts/types/artifacts.js.map +1 -0
  277. package/dist/feature/artifacts/types/index.js +2 -0
  278. package/dist/feature/artifacts/types/index.js.map +1 -0
  279. package/dist/feature/artifacts/types/views.js +2 -0
  280. package/dist/feature/artifacts/types/views.js.map +1 -0
  281. package/dist/feature/compose/services/create.js +11 -0
  282. package/dist/feature/compose/services/create.js.map +1 -0
  283. package/dist/feature/compose/services/index.js +5 -0
  284. package/dist/feature/compose/services/index.js.map +1 -0
  285. package/dist/feature/compose/services/repository-edit.js +20 -0
  286. package/dist/feature/compose/services/repository-edit.js.map +1 -0
  287. package/dist/feature/compose/services/repository-move.js +35 -0
  288. package/dist/feature/compose/services/repository-move.js.map +1 -0
  289. package/dist/feature/compose/services/repository-removal.js +38 -0
  290. package/dist/feature/compose/services/repository-removal.js.map +1 -0
  291. package/dist/feature/delivery/ports/index.js +2 -0
  292. package/dist/feature/delivery/ports/index.js.map +1 -0
  293. package/dist/feature/delivery/ports/publish.js +2 -0
  294. package/dist/feature/delivery/ports/publish.js.map +1 -0
  295. package/dist/feature/delivery/repositories/index.js +3 -0
  296. package/dist/feature/delivery/repositories/index.js.map +1 -0
  297. package/dist/feature/delivery/repositories/patch-storage.js +76 -0
  298. package/dist/feature/delivery/repositories/patch-storage.js.map +1 -0
  299. package/dist/feature/delivery/repositories/patches.js +28 -0
  300. package/dist/feature/delivery/repositories/patches.js.map +1 -0
  301. package/dist/feature/delivery/services/create.js +21 -0
  302. package/dist/feature/delivery/services/create.js.map +1 -0
  303. package/dist/feature/delivery/services/deliver.js +67 -0
  304. package/dist/feature/delivery/services/deliver.js.map +1 -0
  305. package/dist/feature/delivery/services/diffs.js +153 -0
  306. package/dist/feature/delivery/services/diffs.js.map +1 -0
  307. package/dist/feature/delivery/services/index.js +5 -0
  308. package/dist/feature/delivery/services/index.js.map +1 -0
  309. package/dist/feature/delivery/services/patches.js +96 -0
  310. package/dist/feature/delivery/services/patches.js.map +1 -0
  311. package/dist/feature/delivery/types/index.js +3 -0
  312. package/dist/feature/delivery/types/index.js.map +1 -0
  313. package/dist/feature/delivery/types/outcomes.js +2 -0
  314. package/dist/feature/delivery/types/outcomes.js.map +1 -0
  315. package/dist/feature/delivery/types/spec-change.js +18 -0
  316. package/dist/feature/delivery/types/spec-change.js.map +1 -0
  317. package/dist/feature/observers/ports/index.js +2 -0
  318. package/dist/feature/observers/ports/index.js.map +1 -0
  319. package/dist/feature/observers/ports/publish.js +2 -0
  320. package/dist/feature/observers/ports/publish.js.map +1 -0
  321. package/dist/feature/observers/repositories/index.js +2 -0
  322. package/dist/feature/observers/repositories/index.js.map +1 -0
  323. package/dist/feature/observers/repositories/observers.js +28 -0
  324. package/dist/feature/observers/repositories/observers.js.map +1 -0
  325. package/dist/feature/observers/services/create.js +11 -0
  326. package/dist/feature/observers/services/create.js.map +1 -0
  327. package/dist/feature/observers/services/history.js +76 -0
  328. package/dist/feature/observers/services/history.js.map +1 -0
  329. package/dist/feature/observers/services/index.js +5 -0
  330. package/dist/feature/observers/services/index.js.map +1 -0
  331. package/dist/feature/observers/services/observers.js +178 -0
  332. package/dist/feature/observers/services/observers.js.map +1 -0
  333. package/dist/feature/observers/services/settings-check.js +93 -0
  334. package/dist/feature/observers/services/settings-check.js.map +1 -0
  335. package/dist/feature/observers/types/actions.js +2 -0
  336. package/dist/feature/observers/types/actions.js.map +1 -0
  337. package/dist/feature/observers/types/index.js +4 -0
  338. package/dist/feature/observers/types/index.js.map +1 -0
  339. package/dist/feature/observers/types/plan-repairs.js +109 -0
  340. package/dist/feature/observers/types/plan-repairs.js.map +1 -0
  341. package/dist/feature/observers/types/settings.js +13 -0
  342. package/dist/feature/observers/types/settings.js.map +1 -0
  343. package/dist/feature/processes/ports/index.js +2 -0
  344. package/dist/feature/processes/ports/index.js.map +1 -0
  345. package/dist/feature/processes/ports/publish.js +2 -0
  346. package/dist/feature/processes/ports/publish.js.map +1 -0
  347. package/dist/feature/processes/services/create.js +5 -0
  348. package/dist/feature/processes/services/create.js.map +1 -0
  349. package/dist/feature/processes/services/index.js +4 -0
  350. package/dist/feature/processes/services/index.js.map +1 -0
  351. package/dist/feature/processes/services/processes.js +131 -0
  352. package/dist/feature/processes/services/processes.js.map +1 -0
  353. package/dist/feature/processes/services/tree.js +98 -0
  354. package/dist/feature/processes/services/tree.js.map +1 -0
  355. package/dist/feature/processes/types/background.js +2 -0
  356. package/dist/feature/processes/types/background.js.map +1 -0
  357. package/dist/feature/processes/types/index.js +2 -0
  358. package/dist/feature/processes/types/index.js.map +1 -0
  359. package/dist/feature/queue/ports/index.js +2 -0
  360. package/dist/feature/queue/ports/index.js.map +1 -0
  361. package/dist/feature/queue/ports/observe.js +2 -0
  362. package/dist/feature/queue/ports/observe.js.map +1 -0
  363. package/dist/feature/queue/ports/publish.js +2 -0
  364. package/dist/feature/queue/ports/publish.js.map +1 -0
  365. package/dist/feature/queue/ports/repair-policy.js +2 -0
  366. package/dist/feature/queue/ports/repair-policy.js.map +1 -0
  367. package/dist/feature/queue/repositories/index.js +2 -0
  368. package/dist/feature/queue/repositories/index.js.map +1 -0
  369. package/dist/feature/queue/repositories/queues.js +100 -0
  370. package/dist/feature/queue/repositories/queues.js.map +1 -0
  371. package/dist/feature/queue/services/advance.js +214 -0
  372. package/dist/feature/queue/services/advance.js.map +1 -0
  373. package/dist/feature/queue/services/control.js +153 -0
  374. package/dist/feature/queue/services/control.js.map +1 -0
  375. package/dist/feature/queue/services/create.js +26 -0
  376. package/dist/feature/queue/services/create.js.map +1 -0
  377. package/dist/feature/queue/services/edit.js +126 -0
  378. package/dist/feature/queue/services/edit.js.map +1 -0
  379. package/dist/feature/queue/services/index.js +8 -0
  380. package/dist/feature/queue/services/index.js.map +1 -0
  381. package/dist/feature/queue/services/items.js +173 -0
  382. package/dist/feature/queue/services/items.js.map +1 -0
  383. package/dist/feature/queue/services/store.js +61 -0
  384. package/dist/feature/queue/services/store.js.map +1 -0
  385. package/dist/feature/queue/services/task-tags.js +103 -0
  386. package/dist/feature/queue/services/task-tags.js.map +1 -0
  387. package/dist/feature/queue/types/advance.js +183 -0
  388. package/dist/feature/queue/types/advance.js.map +1 -0
  389. package/dist/feature/queue/types/dependencies.js +98 -0
  390. package/dist/feature/queue/types/dependencies.js.map +1 -0
  391. package/dist/feature/queue/types/edit.js +180 -0
  392. package/dist/feature/queue/types/edit.js.map +1 -0
  393. package/dist/feature/queue/types/ids.js +7 -0
  394. package/dist/feature/queue/types/ids.js.map +1 -0
  395. package/dist/feature/queue/types/index.js +10 -0
  396. package/dist/feature/queue/types/index.js.map +1 -0
  397. package/dist/feature/queue/types/items.js +46 -0
  398. package/dist/feature/queue/types/items.js.map +1 -0
  399. package/dist/feature/queue/types/limit-hits.js +50 -0
  400. package/dist/feature/queue/types/limit-hits.js.map +1 -0
  401. package/dist/feature/queue/types/requests.js +2 -0
  402. package/dist/feature/queue/types/requests.js.map +1 -0
  403. package/dist/feature/queue/types/returns.js +182 -0
  404. package/dist/feature/queue/types/returns.js.map +1 -0
  405. package/dist/feature/queue/types/settings.js +117 -0
  406. package/dist/feature/queue/types/settings.js.map +1 -0
  407. package/dist/feature/repos/ports/index.js +2 -0
  408. package/dist/feature/repos/ports/index.js.map +1 -0
  409. package/dist/feature/repos/ports/publish.js +2 -0
  410. package/dist/feature/repos/ports/publish.js.map +1 -0
  411. package/dist/feature/repos/repositories/index.js +2 -0
  412. package/dist/feature/repos/repositories/index.js.map +1 -0
  413. package/dist/feature/repos/repositories/known.js +41 -0
  414. package/dist/feature/repos/repositories/known.js.map +1 -0
  415. package/dist/feature/repos/services/create.js +13 -0
  416. package/dist/feature/repos/services/create.js.map +1 -0
  417. package/dist/feature/repos/services/index.js +4 -0
  418. package/dist/feature/repos/services/index.js.map +1 -0
  419. package/dist/feature/repos/services/projects.js +50 -0
  420. package/dist/feature/repos/services/projects.js.map +1 -0
  421. package/dist/feature/repos/services/registry.js +138 -0
  422. package/dist/feature/repos/services/registry.js.map +1 -0
  423. package/dist/feature/repos/types/index.js +2 -0
  424. package/dist/feature/repos/types/index.js.map +1 -0
  425. package/dist/feature/repos/types/project.js +80 -0
  426. package/dist/feature/repos/types/project.js.map +1 -0
  427. package/dist/feature/repos/types/registry.js +2 -0
  428. package/dist/feature/repos/types/registry.js.map +1 -0
  429. package/dist/feature/runs/machine/answers.js +112 -0
  430. package/dist/feature/runs/machine/answers.js.map +1 -0
  431. package/dist/feature/runs/machine/delivery-checks.js +91 -0
  432. package/dist/feature/runs/machine/delivery-checks.js.map +1 -0
  433. package/dist/feature/runs/machine/delivery-flow.js +211 -0
  434. package/dist/feature/runs/machine/delivery-flow.js.map +1 -0
  435. package/dist/feature/runs/machine/events.js +2 -0
  436. package/dist/feature/runs/machine/events.js.map +1 -0
  437. package/dist/feature/runs/machine/exits.js +207 -0
  438. package/dist/feature/runs/machine/exits.js.map +1 -0
  439. package/dist/feature/runs/machine/index.js +7 -0
  440. package/dist/feature/runs/machine/index.js.map +1 -0
  441. package/dist/feature/runs/machine/plan.js +111 -0
  442. package/dist/feature/runs/machine/plan.js.map +1 -0
  443. package/dist/feature/runs/machine/repair.js +155 -0
  444. package/dist/feature/runs/machine/repair.js.map +1 -0
  445. package/dist/feature/runs/machine/run-control.js +276 -0
  446. package/dist/feature/runs/machine/run-control.js.map +1 -0
  447. package/dist/feature/runs/machine/scheduler.js +119 -0
  448. package/dist/feature/runs/machine/scheduler.js.map +1 -0
  449. package/dist/feature/runs/machine/steps.js +275 -0
  450. package/dist/feature/runs/machine/steps.js.map +1 -0
  451. package/dist/feature/runs/machine/texts.js +69 -0
  452. package/dist/feature/runs/machine/texts.js.map +1 -0
  453. package/dist/feature/runs/machine/transition.js +113 -0
  454. package/dist/feature/runs/machine/transition.js.map +1 -0
  455. package/dist/feature/runs/ports/agent-exit.js +2 -0
  456. package/dist/feature/runs/ports/agent-exit.js.map +1 -0
  457. package/dist/feature/runs/ports/diff.js +2 -0
  458. package/dist/feature/runs/ports/diff.js.map +1 -0
  459. package/dist/feature/runs/ports/index.js +2 -0
  460. package/dist/feature/runs/ports/index.js.map +1 -0
  461. package/dist/feature/runs/ports/observe.js +2 -0
  462. package/dist/feature/runs/ports/observe.js.map +1 -0
  463. package/dist/feature/runs/ports/publish.js +2 -0
  464. package/dist/feature/runs/ports/publish.js.map +1 -0
  465. package/dist/feature/runs/ports/queue-advance.js +2 -0
  466. package/dist/feature/runs/ports/queue-advance.js.map +1 -0
  467. package/dist/feature/runs/repositories/attempt-history.js +116 -0
  468. package/dist/feature/runs/repositories/attempt-history.js.map +1 -0
  469. package/dist/feature/runs/repositories/finished-runs.js +42 -0
  470. package/dist/feature/runs/repositories/finished-runs.js.map +1 -0
  471. package/dist/feature/runs/repositories/index.js +4 -0
  472. package/dist/feature/runs/repositories/index.js.map +1 -0
  473. package/dist/feature/runs/repositories/rows.js +110 -0
  474. package/dist/feature/runs/repositories/rows.js.map +1 -0
  475. package/dist/feature/runs/repositories/runs.js +76 -0
  476. package/dist/feature/runs/repositories/runs.js.map +1 -0
  477. package/dist/feature/runs/repositories/write.js +31 -0
  478. package/dist/feature/runs/repositories/write.js.map +1 -0
  479. package/dist/feature/runs/services/archive.js +17 -0
  480. package/dist/feature/runs/services/archive.js.map +1 -0
  481. package/dist/feature/runs/services/attempt-history.js +11 -0
  482. package/dist/feature/runs/services/attempt-history.js.map +1 -0
  483. package/dist/feature/runs/services/create.js +43 -0
  484. package/dist/feature/runs/services/create.js.map +1 -0
  485. package/dist/feature/runs/services/effects/actions.js +150 -0
  486. package/dist/feature/runs/services/effects/actions.js.map +1 -0
  487. package/dist/feature/runs/services/effects/attempts.js +179 -0
  488. package/dist/feature/runs/services/effects/attempts.js.map +1 -0
  489. package/dist/feature/runs/services/effects/context.js +7 -0
  490. package/dist/feature/runs/services/effects/context.js.map +1 -0
  491. package/dist/feature/runs/services/effects/effects.js +82 -0
  492. package/dist/feature/runs/services/effects/effects.js.map +1 -0
  493. package/dist/feature/runs/services/effects/git.js +168 -0
  494. package/dist/feature/runs/services/effects/git.js.map +1 -0
  495. package/dist/feature/runs/services/effects/naming.js +62 -0
  496. package/dist/feature/runs/services/effects/naming.js.map +1 -0
  497. package/dist/feature/runs/services/effects/outside.js +83 -0
  498. package/dist/feature/runs/services/effects/outside.js.map +1 -0
  499. package/dist/feature/runs/services/effects/running.js +76 -0
  500. package/dist/feature/runs/services/effects/running.js.map +1 -0
  501. package/dist/feature/runs/services/effects/usage.js +61 -0
  502. package/dist/feature/runs/services/effects/usage.js.map +1 -0
  503. package/dist/feature/runs/services/effects/worktrees.js +49 -0
  504. package/dist/feature/runs/services/effects/worktrees.js.map +1 -0
  505. package/dist/feature/runs/services/engine.js +163 -0
  506. package/dist/feature/runs/services/engine.js.map +1 -0
  507. package/dist/feature/runs/services/index.js +15 -0
  508. package/dist/feature/runs/services/index.js.map +1 -0
  509. package/dist/feature/runs/services/occupancy.js +62 -0
  510. package/dist/feature/runs/services/occupancy.js.map +1 -0
  511. package/dist/feature/runs/services/progress.js +42 -0
  512. package/dist/feature/runs/services/progress.js.map +1 -0
  513. package/dist/feature/runs/services/reads.js +54 -0
  514. package/dist/feature/runs/services/reads.js.map +1 -0
  515. package/dist/feature/runs/services/recovery.js +17 -0
  516. package/dist/feature/runs/services/recovery.js.map +1 -0
  517. package/dist/feature/runs/services/refresh.js +29 -0
  518. package/dist/feature/runs/services/refresh.js.map +1 -0
  519. package/dist/feature/runs/services/requests.js +88 -0
  520. package/dist/feature/runs/services/requests.js.map +1 -0
  521. package/dist/feature/runs/services/states.js +112 -0
  522. package/dist/feature/runs/services/states.js.map +1 -0
  523. package/dist/feature/runs/services/summary.js +38 -0
  524. package/dist/feature/runs/services/summary.js.map +1 -0
  525. package/dist/feature/runs/types/attempt.js +102 -0
  526. package/dist/feature/runs/types/attempt.js.map +1 -0
  527. package/dist/feature/runs/types/constants.js +45 -0
  528. package/dist/feature/runs/types/constants.js.map +1 -0
  529. package/dist/feature/runs/types/create.js +177 -0
  530. package/dist/feature/runs/types/create.js.map +1 -0
  531. package/dist/feature/runs/types/group.js +152 -0
  532. package/dist/feature/runs/types/group.js.map +1 -0
  533. package/dist/feature/runs/types/history/attempt-history.js +16 -0
  534. package/dist/feature/runs/types/history/attempt-history.js.map +1 -0
  535. package/dist/feature/runs/types/index.js +15 -0
  536. package/dist/feature/runs/types/index.js.map +1 -0
  537. package/dist/feature/runs/types/input.js +57 -0
  538. package/dist/feature/runs/types/input.js.map +1 -0
  539. package/dist/feature/runs/types/limits.js +151 -0
  540. package/dist/feature/runs/types/limits.js.map +1 -0
  541. package/dist/feature/runs/types/problems.js +74 -0
  542. package/dist/feature/runs/types/problems.js.map +1 -0
  543. package/dist/feature/runs/types/run.js +162 -0
  544. package/dist/feature/runs/types/run.js.map +1 -0
  545. package/dist/feature/runs/types/skip.js +110 -0
  546. package/dist/feature/runs/types/skip.js.map +1 -0
  547. package/dist/feature/runs/types/stage-status.js +156 -0
  548. package/dist/feature/runs/types/stage-status.js.map +1 -0
  549. package/dist/feature/runs/types/stages.js +158 -0
  550. package/dist/feature/runs/types/stages.js.map +1 -0
  551. package/dist/feature/runs/types/topology.js +165 -0
  552. package/dist/feature/runs/types/topology.js.map +1 -0
  553. package/dist/feature/swarm-config/repositories/config-files.js +141 -0
  554. package/dist/feature/swarm-config/repositories/config-files.js.map +1 -0
  555. package/dist/feature/swarm-config/services/assemble.js +212 -0
  556. package/dist/feature/swarm-config/services/assemble.js.map +1 -0
  557. package/dist/feature/swarm-config/services/create.js +5 -0
  558. package/dist/feature/swarm-config/services/create.js.map +1 -0
  559. package/dist/feature/swarm-config/services/discover.js +19 -0
  560. package/dist/feature/swarm-config/services/discover.js.map +1 -0
  561. package/dist/feature/swarm-config/services/index.js +9 -0
  562. package/dist/feature/swarm-config/services/index.js.map +1 -0
  563. package/dist/feature/swarm-config/services/load.js +86 -0
  564. package/dist/feature/swarm-config/services/load.js.map +1 -0
  565. package/dist/feature/swarm-config/services/settings.js +50 -0
  566. package/dist/feature/swarm-config/services/settings.js.map +1 -0
  567. package/dist/feature/swarm-config/services/validate-actions.js +117 -0
  568. package/dist/feature/swarm-config/services/validate-actions.js.map +1 -0
  569. package/dist/feature/swarm-config/services/validate-context.js +91 -0
  570. package/dist/feature/swarm-config/services/validate-context.js.map +1 -0
  571. package/dist/feature/swarm-config/services/validate-pipelines.js +170 -0
  572. package/dist/feature/swarm-config/services/validate-pipelines.js.map +1 -0
  573. package/dist/feature/swarm-config/services/validate-runtimes.js +212 -0
  574. package/dist/feature/swarm-config/services/validate-runtimes.js.map +1 -0
  575. package/dist/feature/swarm-config/services/validate-settings.js +177 -0
  576. package/dist/feature/swarm-config/services/validate-settings.js.map +1 -0
  577. package/dist/feature/swarm-config/services/validate-specialists.js +152 -0
  578. package/dist/feature/swarm-config/services/validate-specialists.js.map +1 -0
  579. package/dist/feature/swarm-config/services/validate.js +174 -0
  580. package/dist/feature/swarm-config/services/validate.js.map +1 -0
  581. package/dist/feature/swarm-config/types/action.js +11 -0
  582. package/dist/feature/swarm-config/types/action.js.map +1 -0
  583. package/dist/feature/swarm-config/types/chain.js +2 -0
  584. package/dist/feature/swarm-config/types/chain.js.map +1 -0
  585. package/dist/feature/swarm-config/types/duration.js +17 -0
  586. package/dist/feature/swarm-config/types/duration.js.map +1 -0
  587. package/dist/feature/swarm-config/types/errors.js +57 -0
  588. package/dist/feature/swarm-config/types/errors.js.map +1 -0
  589. package/dist/feature/swarm-config/types/index.js +13 -0
  590. package/dist/feature/swarm-config/types/index.js.map +1 -0
  591. package/dist/feature/swarm-config/types/levels.js +16 -0
  592. package/dist/feature/swarm-config/types/levels.js.map +1 -0
  593. package/dist/feature/swarm-config/types/lookups.js +53 -0
  594. package/dist/feature/swarm-config/types/lookups.js.map +1 -0
  595. package/dist/feature/swarm-config/types/merge.js +46 -0
  596. package/dist/feature/swarm-config/types/merge.js.map +1 -0
  597. package/dist/feature/swarm-config/types/pipeline.js +5 -0
  598. package/dist/feature/swarm-config/types/pipeline.js.map +1 -0
  599. package/dist/feature/swarm-config/types/prompt.js +33 -0
  600. package/dist/feature/swarm-config/types/prompt.js.map +1 -0
  601. package/dist/feature/swarm-config/types/settings.js +116 -0
  602. package/dist/feature/swarm-config/types/settings.js.map +1 -0
  603. package/dist/feature/swarm-config/types/specialist.js +38 -0
  604. package/dist/feature/swarm-config/types/specialist.js.map +1 -0
  605. package/dist/feature/swarm-config/types/tag-names.js +43 -0
  606. package/dist/feature/swarm-config/types/tag-names.js.map +1 -0
  607. package/dist/feature/swarm-edit/ports/config-changed.js +2 -0
  608. package/dist/feature/swarm-edit/ports/config-changed.js.map +1 -0
  609. package/dist/feature/swarm-edit/ports/index.js +2 -0
  610. package/dist/feature/swarm-edit/ports/index.js.map +1 -0
  611. package/dist/feature/swarm-edit/repositories/documents.js +144 -0
  612. package/dist/feature/swarm-edit/repositories/documents.js.map +1 -0
  613. package/dist/feature/swarm-edit/services/config-edits.js +116 -0
  614. package/dist/feature/swarm-edit/services/config-edits.js.map +1 -0
  615. package/dist/feature/swarm-edit/services/create.js +7 -0
  616. package/dist/feature/swarm-edit/services/create.js.map +1 -0
  617. package/dist/feature/swarm-edit/services/editor-settings.js +143 -0
  618. package/dist/feature/swarm-edit/services/editor-settings.js.map +1 -0
  619. package/dist/feature/swarm-edit/services/editor-view.js +144 -0
  620. package/dist/feature/swarm-edit/services/editor-view.js.map +1 -0
  621. package/dist/feature/swarm-edit/services/index.js +12 -0
  622. package/dist/feature/swarm-edit/services/index.js.map +1 -0
  623. package/dist/feature/swarm-edit/services/levels.js +30 -0
  624. package/dist/feature/swarm-edit/services/levels.js.map +1 -0
  625. package/dist/feature/swarm-edit/services/plan-edit.js +217 -0
  626. package/dist/feature/swarm-edit/services/plan-edit.js.map +1 -0
  627. package/dist/feature/swarm-edit/services/plan-settings.js +198 -0
  628. package/dist/feature/swarm-edit/services/plan-settings.js.map +1 -0
  629. package/dist/feature/swarm-edit/services/references.js +85 -0
  630. package/dist/feature/swarm-edit/services/references.js.map +1 -0
  631. package/dist/feature/swarm-edit/services/shared-config.js +128 -0
  632. package/dist/feature/swarm-edit/services/shared-config.js.map +1 -0
  633. package/dist/feature/swarm-edit/services/shared-pipelines.js +72 -0
  634. package/dist/feature/swarm-edit/services/shared-pipelines.js.map +1 -0
  635. package/dist/feature/swarm-edit/services/shared-specialists.js +70 -0
  636. package/dist/feature/swarm-edit/services/shared-specialists.js.map +1 -0
  637. package/dist/feature/swarm-edit/services/specialist-tags.js +215 -0
  638. package/dist/feature/swarm-edit/services/specialist-tags.js.map +1 -0
  639. package/dist/feature/swarm-edit/types/editor.js +27 -0
  640. package/dist/feature/swarm-edit/types/editor.js.map +1 -0
  641. package/dist/feature/swarm-edit/types/index.js +7 -0
  642. package/dist/feature/swarm-edit/types/index.js.map +1 -0
  643. package/dist/feature/swarm-edit/types/setting-fields.js +64 -0
  644. package/dist/feature/swarm-edit/types/setting-fields.js.map +1 -0
  645. package/dist/feature/swarm-edit/types/shared.js +2 -0
  646. package/dist/feature/swarm-edit/types/shared.js.map +1 -0
  647. package/dist/feature/swarm-edit/types/stages.js +69 -0
  648. package/dist/feature/swarm-edit/types/stages.js.map +1 -0
  649. package/dist/feature/swarm-edit/types/tag-folders.js +2 -0
  650. package/dist/feature/swarm-edit/types/tag-folders.js.map +1 -0
  651. package/dist/feature/swarm-edit/types/views.js +2 -0
  652. package/dist/feature/swarm-edit/types/views.js.map +1 -0
  653. package/dist/feature/tags/ports/index.js +2 -0
  654. package/dist/feature/tags/ports/index.js.map +1 -0
  655. package/dist/feature/tags/ports/publish.js +2 -0
  656. package/dist/feature/tags/ports/publish.js.map +1 -0
  657. package/dist/feature/tags/repositories/index.js +2 -0
  658. package/dist/feature/tags/repositories/index.js.map +1 -0
  659. package/dist/feature/tags/repositories/tags.js +36 -0
  660. package/dist/feature/tags/repositories/tags.js.map +1 -0
  661. package/dist/feature/tags/services/catalog.js +73 -0
  662. package/dist/feature/tags/services/catalog.js.map +1 -0
  663. package/dist/feature/tags/services/create.js +7 -0
  664. package/dist/feature/tags/services/create.js.map +1 -0
  665. package/dist/feature/tags/services/index.js +3 -0
  666. package/dist/feature/tags/services/index.js.map +1 -0
  667. package/dist/feature/tags/types/ids.js +7 -0
  668. package/dist/feature/tags/types/ids.js.map +1 -0
  669. package/dist/feature/tags/types/index.js +3 -0
  670. package/dist/feature/tags/types/index.js.map +1 -0
  671. package/dist/feature/tags/types/tags.js +184 -0
  672. package/dist/feature/tags/types/tags.js.map +1 -0
  673. package/dist/git/delivery.js +284 -0
  674. package/dist/git/delivery.js.map +1 -0
  675. package/dist/git/index.js +4 -0
  676. package/dist/git/index.js.map +1 -0
  677. package/dist/git/runner.js +60 -0
  678. package/dist/git/runner.js.map +1 -0
  679. package/dist/git/workspace.js +366 -0
  680. package/dist/git/workspace.js.map +1 -0
  681. package/dist/mcp/host.js +401 -0
  682. package/dist/mcp/host.js.map +1 -0
  683. package/dist/mcp/index.js +3 -0
  684. package/dist/mcp/index.js.map +1 -0
  685. package/dist/mcp/tools.js +19 -0
  686. package/dist/mcp/tools.js.map +1 -0
  687. package/dist/mcp/version.js +5 -0
  688. package/dist/mcp/version.js.map +1 -0
  689. package/dist/mcp/worker.js +230 -0
  690. package/dist/mcp/worker.js.map +1 -0
  691. package/dist/platform/build/fingerprint.js +36 -0
  692. package/dist/platform/build/fingerprint.js.map +1 -0
  693. package/dist/platform/build/index.js +3 -0
  694. package/dist/platform/build/index.js.map +1 -0
  695. package/dist/platform/build/locations.js +16 -0
  696. package/dist/platform/build/locations.js.map +1 -0
  697. package/dist/platform/errors/app-error.js +39 -0
  698. package/dist/platform/errors/app-error.js.map +1 -0
  699. package/dist/platform/errors/index.js +2 -0
  700. package/dist/platform/errors/index.js.map +1 -0
  701. package/dist/platform/git/delivery.js +284 -0
  702. package/dist/platform/git/delivery.js.map +1 -0
  703. package/dist/platform/git/index.js +4 -0
  704. package/dist/platform/git/index.js.map +1 -0
  705. package/dist/platform/git/runner.js +65 -0
  706. package/dist/platform/git/runner.js.map +1 -0
  707. package/dist/platform/git/workspace.js +366 -0
  708. package/dist/platform/git/workspace.js.map +1 -0
  709. package/dist/platform/paths/index.js +2 -0
  710. package/dist/platform/paths/index.js.map +1 -0
  711. package/dist/platform/paths/paths.js +39 -0
  712. package/dist/platform/paths/paths.js.map +1 -0
  713. package/dist/platform/process/index.js +3 -0
  714. package/dist/platform/process/index.js.map +1 -0
  715. package/dist/platform/process/ps.js +42 -0
  716. package/dist/platform/process/ps.js.map +1 -0
  717. package/dist/platform/process/which.js +21 -0
  718. package/dist/platform/process/which.js.map +1 -0
  719. package/dist/platform/sqlite/database.js +36 -0
  720. package/dist/platform/sqlite/database.js.map +1 -0
  721. package/dist/platform/sqlite/index.js +4 -0
  722. package/dist/platform/sqlite/index.js.map +1 -0
  723. package/dist/platform/sqlite/migrations.js +297 -0
  724. package/dist/platform/sqlite/migrations.js.map +1 -0
  725. package/dist/platform/sqlite/rows.js +13 -0
  726. package/dist/platform/sqlite/rows.js.map +1 -0
  727. package/dist/presentation/cli/commands/daemon.js +216 -0
  728. package/dist/presentation/cli/commands/daemon.js.map +1 -0
  729. package/dist/presentation/cli/commands/group.js +88 -0
  730. package/dist/presentation/cli/commands/group.js.map +1 -0
  731. package/dist/presentation/cli/commands/mcp.js +44 -0
  732. package/dist/presentation/cli/commands/mcp.js.map +1 -0
  733. package/dist/presentation/cli/commands/queue-edit.js +155 -0
  734. package/dist/presentation/cli/commands/queue-edit.js.map +1 -0
  735. package/dist/presentation/cli/commands/queue.js +222 -0
  736. package/dist/presentation/cli/commands/queue.js.map +1 -0
  737. package/dist/presentation/cli/commands/repositories.js +129 -0
  738. package/dist/presentation/cli/commands/repositories.js.map +1 -0
  739. package/dist/presentation/cli/commands/run-delivery.js +116 -0
  740. package/dist/presentation/cli/commands/run-delivery.js.map +1 -0
  741. package/dist/presentation/cli/commands/run.js +156 -0
  742. package/dist/presentation/cli/commands/run.js.map +1 -0
  743. package/dist/presentation/cli/commands/setup.js +97 -0
  744. package/dist/presentation/cli/commands/setup.js.map +1 -0
  745. package/dist/presentation/cli/commands/tag.js +92 -0
  746. package/dist/presentation/cli/commands/tag.js.map +1 -0
  747. package/dist/presentation/cli/commands/web.js +100 -0
  748. package/dist/presentation/cli/commands/web.js.map +1 -0
  749. package/dist/presentation/cli/context.js +49 -0
  750. package/dist/presentation/cli/context.js.map +1 -0
  751. package/dist/presentation/cli/help.js +49 -0
  752. package/dist/presentation/cli/help.js.map +1 -0
  753. package/dist/presentation/cli/io.js +13 -0
  754. package/dist/presentation/cli/io.js.map +1 -0
  755. package/dist/presentation/cli/local/clean.js +72 -0
  756. package/dist/presentation/cli/local/clean.js.map +1 -0
  757. package/dist/presentation/cli/local/config-check.js +207 -0
  758. package/dist/presentation/cli/local/config-check.js.map +1 -0
  759. package/dist/presentation/cli/local/init.js +44 -0
  760. package/dist/presentation/cli/local/init.js.map +1 -0
  761. package/dist/presentation/cli/options.js +34 -0
  762. package/dist/presentation/cli/options.js.map +1 -0
  763. package/dist/presentation/cli/probe.js +12 -0
  764. package/dist/presentation/cli/probe.js.map +1 -0
  765. package/dist/presentation/cli/program.js +76 -0
  766. package/dist/presentation/cli/program.js.map +1 -0
  767. package/dist/presentation/cli/setup/actions.js +206 -0
  768. package/dist/presentation/cli/setup/actions.js.map +1 -0
  769. package/dist/presentation/cli/setup/command.js +80 -0
  770. package/dist/presentation/cli/setup/command.js.map +1 -0
  771. package/dist/presentation/cli/setup/host.js +20 -0
  772. package/dist/presentation/cli/setup/host.js.map +1 -0
  773. package/dist/presentation/cli/setup/index.js +5 -0
  774. package/dist/presentation/cli/setup/index.js.map +1 -0
  775. package/dist/presentation/cli/setup/run.js +63 -0
  776. package/dist/presentation/cli/setup/run.js.map +1 -0
  777. package/dist/presentation/cli/setup/system.js +53 -0
  778. package/dist/presentation/cli/setup/system.js.map +1 -0
  779. package/dist/presentation/cli/setup/types.js +3 -0
  780. package/dist/presentation/cli/setup/types.js.map +1 -0
  781. package/dist/presentation/cli/watch.js +24 -0
  782. package/dist/presentation/cli/watch.js.map +1 -0
  783. package/dist/presentation/cli/web-control.js +172 -0
  784. package/dist/presentation/cli/web-control.js.map +1 -0
  785. package/dist/presentation/format/groups.js +99 -0
  786. package/dist/presentation/format/groups.js.map +1 -0
  787. package/dist/presentation/format/index.js +7 -0
  788. package/dist/presentation/format/index.js.map +1 -0
  789. package/dist/presentation/format/queue.js +109 -0
  790. package/dist/presentation/format/queue.js.map +1 -0
  791. package/dist/presentation/format/runs.js +202 -0
  792. package/dist/presentation/format/runs.js.map +1 -0
  793. package/dist/presentation/format/style.js +81 -0
  794. package/dist/presentation/format/style.js.map +1 -0
  795. package/dist/presentation/format/table.js +62 -0
  796. package/dist/presentation/format/table.js.map +1 -0
  797. package/dist/presentation/format/tags.js +26 -0
  798. package/dist/presentation/format/tags.js.map +1 -0
  799. package/dist/presentation/ipc/client/autostart.js +171 -0
  800. package/dist/presentation/ipc/client/autostart.js.map +1 -0
  801. package/dist/presentation/ipc/client/client.js +83 -0
  802. package/dist/presentation/ipc/client/client.js.map +1 -0
  803. package/dist/presentation/ipc/client/index.js +4 -0
  804. package/dist/presentation/ipc/client/index.js.map +1 -0
  805. package/dist/presentation/ipc/client/repository-argument.js +13 -0
  806. package/dist/presentation/ipc/client/repository-argument.js.map +1 -0
  807. package/dist/presentation/ipc/contract/agents.js +79 -0
  808. package/dist/presentation/ipc/contract/agents.js.map +1 -0
  809. package/dist/presentation/ipc/contract/artifacts.js +27 -0
  810. package/dist/presentation/ipc/contract/artifacts.js.map +1 -0
  811. package/dist/presentation/ipc/contract/config.js +141 -0
  812. package/dist/presentation/ipc/contract/config.js.map +1 -0
  813. package/dist/presentation/ipc/contract/envelope.js +97 -0
  814. package/dist/presentation/ipc/contract/envelope.js.map +1 -0
  815. package/dist/presentation/ipc/contract/groups.js +48 -0
  816. package/dist/presentation/ipc/contract/groups.js.map +1 -0
  817. package/dist/presentation/ipc/contract/index.js +14 -0
  818. package/dist/presentation/ipc/contract/index.js.map +1 -0
  819. package/dist/presentation/ipc/contract/observers/history.js +26 -0
  820. package/dist/presentation/ipc/contract/observers/history.js.map +1 -0
  821. package/dist/presentation/ipc/contract/observers.js +16 -0
  822. package/dist/presentation/ipc/contract/observers.js.map +1 -0
  823. package/dist/presentation/ipc/contract/panel.js +53 -0
  824. package/dist/presentation/ipc/contract/panel.js.map +1 -0
  825. package/dist/presentation/ipc/contract/processes.js +9 -0
  826. package/dist/presentation/ipc/contract/processes.js.map +1 -0
  827. package/dist/presentation/ipc/contract/queue.js +115 -0
  828. package/dist/presentation/ipc/contract/queue.js.map +1 -0
  829. package/dist/presentation/ipc/contract/repositories.js +33 -0
  830. package/dist/presentation/ipc/contract/repositories.js.map +1 -0
  831. package/dist/presentation/ipc/contract/responses/artifacts.js +2 -0
  832. package/dist/presentation/ipc/contract/responses/artifacts.js.map +1 -0
  833. package/dist/presentation/ipc/contract/responses/config.js +2 -0
  834. package/dist/presentation/ipc/contract/responses/config.js.map +1 -0
  835. package/dist/presentation/ipc/contract/responses/groups.js +2 -0
  836. package/dist/presentation/ipc/contract/responses/groups.js.map +1 -0
  837. package/dist/presentation/ipc/contract/responses/index.js +11 -0
  838. package/dist/presentation/ipc/contract/responses/index.js.map +1 -0
  839. package/dist/presentation/ipc/contract/responses/observer-history.js +2 -0
  840. package/dist/presentation/ipc/contract/responses/observer-history.js.map +1 -0
  841. package/dist/presentation/ipc/contract/responses/observers.js +2 -0
  842. package/dist/presentation/ipc/contract/responses/observers.js.map +1 -0
  843. package/dist/presentation/ipc/contract/responses/processes.js +2 -0
  844. package/dist/presentation/ipc/contract/responses/processes.js.map +1 -0
  845. package/dist/presentation/ipc/contract/responses/queue.js +2 -0
  846. package/dist/presentation/ipc/contract/responses/queue.js.map +1 -0
  847. package/dist/presentation/ipc/contract/responses/repositories.js +2 -0
  848. package/dist/presentation/ipc/contract/responses/repositories.js.map +1 -0
  849. package/dist/presentation/ipc/contract/responses/runs.js +2 -0
  850. package/dist/presentation/ipc/contract/responses/runs.js.map +1 -0
  851. package/dist/presentation/ipc/contract/responses/tags.js +2 -0
  852. package/dist/presentation/ipc/contract/responses/tags.js.map +1 -0
  853. package/dist/presentation/ipc/contract/runs.js +112 -0
  854. package/dist/presentation/ipc/contract/runs.js.map +1 -0
  855. package/dist/presentation/ipc/contract/tags.js +40 -0
  856. package/dist/presentation/ipc/contract/tags.js.map +1 -0
  857. package/dist/presentation/ipc/handlers/config.js +38 -0
  858. package/dist/presentation/ipc/handlers/config.js.map +1 -0
  859. package/dist/presentation/ipc/handlers/groups.js +14 -0
  860. package/dist/presentation/ipc/handlers/groups.js.map +1 -0
  861. package/dist/presentation/ipc/handlers/index.js +2 -0
  862. package/dist/presentation/ipc/handlers/index.js.map +1 -0
  863. package/dist/presentation/ipc/handlers/observers.js +14 -0
  864. package/dist/presentation/ipc/handlers/observers.js.map +1 -0
  865. package/dist/presentation/ipc/handlers/queue.js +36 -0
  866. package/dist/presentation/ipc/handlers/queue.js.map +1 -0
  867. package/dist/presentation/ipc/handlers/repositories.js +26 -0
  868. package/dist/presentation/ipc/handlers/repositories.js.map +1 -0
  869. package/dist/presentation/ipc/handlers/runs.js +55 -0
  870. package/dist/presentation/ipc/handlers/runs.js.map +1 -0
  871. package/dist/presentation/ipc/handlers/system.js +38 -0
  872. package/dist/presentation/ipc/handlers/system.js.map +1 -0
  873. package/dist/presentation/ipc/handlers/table.js +23 -0
  874. package/dist/presentation/ipc/handlers/table.js.map +1 -0
  875. package/dist/presentation/ipc/handlers/types.js +2 -0
  876. package/dist/presentation/ipc/handlers/types.js.map +1 -0
  877. package/dist/presentation/ipc/publisher.js +175 -0
  878. package/dist/presentation/ipc/publisher.js.map +1 -0
  879. package/dist/presentation/ipc/server.js +164 -0
  880. package/dist/presentation/ipc/server.js.map +1 -0
  881. package/dist/presentation/ipc/services.js +2 -0
  882. package/dist/presentation/ipc/services.js.map +1 -0
  883. package/dist/presentation/ipc/snapshots.js +60 -0
  884. package/dist/presentation/ipc/snapshots.js.map +1 -0
  885. package/dist/presentation/ipc/views/catalog.js +9 -0
  886. package/dist/presentation/ipc/views/catalog.js.map +1 -0
  887. package/dist/presentation/ipc/views/groups.js +112 -0
  888. package/dist/presentation/ipc/views/groups.js.map +1 -0
  889. package/dist/presentation/ipc/views/index.js +10 -0
  890. package/dist/presentation/ipc/views/index.js.map +1 -0
  891. package/dist/presentation/ipc/views/observer-history.js +26 -0
  892. package/dist/presentation/ipc/views/observer-history.js.map +1 -0
  893. package/dist/presentation/ipc/views/observers.js +16 -0
  894. package/dist/presentation/ipc/views/observers.js.map +1 -0
  895. package/dist/presentation/ipc/views/queue.js +151 -0
  896. package/dist/presentation/ipc/views/queue.js.map +1 -0
  897. package/dist/presentation/ipc/views/repositories.js +34 -0
  898. package/dist/presentation/ipc/views/repositories.js.map +1 -0
  899. package/dist/presentation/ipc/views/rows.js +117 -0
  900. package/dist/presentation/ipc/views/rows.js.map +1 -0
  901. package/dist/presentation/ipc/views/run-stages.js +66 -0
  902. package/dist/presentation/ipc/views/run-stages.js.map +1 -0
  903. package/dist/presentation/ipc/views/runs.js +201 -0
  904. package/dist/presentation/ipc/views/runs.js.map +1 -0
  905. package/dist/presentation/ipc/views/tags.js +19 -0
  906. package/dist/presentation/ipc/views/tags.js.map +1 -0
  907. package/dist/presentation/mcp/host-kit.js +67 -0
  908. package/dist/presentation/mcp/host-kit.js.map +1 -0
  909. package/dist/presentation/mcp/host-queue-control.js +135 -0
  910. package/dist/presentation/mcp/host-queue-control.js.map +1 -0
  911. package/dist/presentation/mcp/host-queue.js +124 -0
  912. package/dist/presentation/mcp/host-queue.js.map +1 -0
  913. package/dist/presentation/mcp/host-runs.js +173 -0
  914. package/dist/presentation/mcp/host-runs.js.map +1 -0
  915. package/dist/presentation/mcp/host.js +34 -0
  916. package/dist/presentation/mcp/host.js.map +1 -0
  917. package/dist/presentation/mcp/index.js +3 -0
  918. package/dist/presentation/mcp/index.js.map +1 -0
  919. package/dist/presentation/mcp/tools.js +19 -0
  920. package/dist/presentation/mcp/tools.js.map +1 -0
  921. package/dist/presentation/mcp/worker-extra.js +144 -0
  922. package/dist/presentation/mcp/worker-extra.js.map +1 -0
  923. package/dist/presentation/mcp/worker-tools.js +107 -0
  924. package/dist/presentation/mcp/worker-tools.js.map +1 -0
  925. package/dist/presentation/mcp/worker.js +12 -0
  926. package/dist/presentation/mcp/worker.js.map +1 -0
  927. package/dist/presentation/web/errors.js +60 -0
  928. package/dist/presentation/web/errors.js.map +1 -0
  929. package/dist/presentation/web/http.js +130 -0
  930. package/dist/presentation/web/http.js.map +1 -0
  931. package/dist/presentation/web/hub.js +164 -0
  932. package/dist/presentation/web/hub.js.map +1 -0
  933. package/dist/presentation/web/index.js +7 -0
  934. package/dist/presentation/web/index.js.map +1 -0
  935. package/dist/presentation/web/options.js +7 -0
  936. package/dist/presentation/web/options.js.map +1 -0
  937. package/dist/presentation/web/pages.js +44 -0
  938. package/dist/presentation/web/pages.js.map +1 -0
  939. package/dist/presentation/web/panel/daemon-panel.js +207 -0
  940. package/dist/presentation/web/panel/daemon-panel.js.map +1 -0
  941. package/dist/presentation/web/panel/default-repository.js +14 -0
  942. package/dist/presentation/web/panel/default-repository.js.map +1 -0
  943. package/dist/presentation/web/panel/directories.js +48 -0
  944. package/dist/presentation/web/panel/directories.js.map +1 -0
  945. package/dist/presentation/web/panel/open.js +12 -0
  946. package/dist/presentation/web/panel/open.js.map +1 -0
  947. package/dist/presentation/web/panel/standby.js +119 -0
  948. package/dist/presentation/web/panel/standby.js.map +1 -0
  949. package/dist/presentation/web/panel/state.js +69 -0
  950. package/dist/presentation/web/panel/state.js.map +1 -0
  951. package/dist/presentation/web/panel/system.js +66 -0
  952. package/dist/presentation/web/panel/system.js.map +1 -0
  953. package/dist/presentation/web/request.js +123 -0
  954. package/dist/presentation/web/request.js.map +1 -0
  955. package/dist/presentation/web/routes/config.js +166 -0
  956. package/dist/presentation/web/routes/config.js.map +1 -0
  957. package/dist/presentation/web/routes/directories.js +60 -0
  958. package/dist/presentation/web/routes/directories.js.map +1 -0
  959. package/dist/presentation/web/routes/downloads.js +65 -0
  960. package/dist/presentation/web/routes/downloads.js.map +1 -0
  961. package/dist/presentation/web/routes/groups.js +85 -0
  962. package/dist/presentation/web/routes/groups.js.map +1 -0
  963. package/dist/presentation/web/routes/observers/history.js +19 -0
  964. package/dist/presentation/web/routes/observers/history.js.map +1 -0
  965. package/dist/presentation/web/routes/processes.js +21 -0
  966. package/dist/presentation/web/routes/processes.js.map +1 -0
  967. package/dist/presentation/web/routes/queue.js +80 -0
  968. package/dist/presentation/web/routes/queue.js.map +1 -0
  969. package/dist/presentation/web/routes/repositories.js +66 -0
  970. package/dist/presentation/web/routes/repositories.js.map +1 -0
  971. package/dist/presentation/web/routes/runs.js +76 -0
  972. package/dist/presentation/web/routes/runs.js.map +1 -0
  973. package/dist/presentation/web/routes/settings.js +74 -0
  974. package/dist/presentation/web/routes/settings.js.map +1 -0
  975. package/dist/presentation/web/routes/specialists.js +74 -0
  976. package/dist/presentation/web/routes/specialists.js.map +1 -0
  977. package/dist/presentation/web/routes/system.js +96 -0
  978. package/dist/presentation/web/routes/system.js.map +1 -0
  979. package/dist/presentation/web/routes/tags.js +46 -0
  980. package/dist/presentation/web/routes/tags.js.map +1 -0
  981. package/dist/presentation/web/routes/types.js +2 -0
  982. package/dist/presentation/web/routes/types.js.map +1 -0
  983. package/dist/presentation/web/server.js +185 -0
  984. package/dist/presentation/web/server.js.map +1 -0
  985. package/dist/protocol/autostart.js +171 -0
  986. package/dist/protocol/autostart.js.map +1 -0
  987. package/dist/protocol/build.js +38 -0
  988. package/dist/protocol/build.js.map +1 -0
  989. package/dist/protocol/catalog.js +18 -0
  990. package/dist/protocol/catalog.js.map +1 -0
  991. package/dist/protocol/client.js +83 -0
  992. package/dist/protocol/client.js.map +1 -0
  993. package/dist/protocol/format.js +477 -0
  994. package/dist/protocol/format.js.map +1 -0
  995. package/dist/protocol/index.js +11 -0
  996. package/dist/protocol/index.js.map +1 -0
  997. package/dist/protocol/messages.js +598 -0
  998. package/dist/protocol/messages.js.map +1 -0
  999. package/dist/protocol/style.js +81 -0
  1000. package/dist/protocol/style.js.map +1 -0
  1001. package/dist/protocol/transcript.js +49 -0
  1002. package/dist/protocol/transcript.js.map +1 -0
  1003. package/dist/protocol/views.js +696 -0
  1004. package/dist/protocol/views.js.map +1 -0
  1005. package/dist/runtime/catalog.js +117 -0
  1006. package/dist/runtime/catalog.js.map +1 -0
  1007. package/dist/runtime/claude.js +399 -0
  1008. package/dist/runtime/claude.js.map +1 -0
  1009. package/dist/runtime/index.js +34 -0
  1010. package/dist/runtime/index.js.map +1 -0
  1011. package/dist/runtime/message.js +48 -0
  1012. package/dist/runtime/message.js.map +1 -0
  1013. package/dist/runtime/naming.js +69 -0
  1014. package/dist/runtime/naming.js.map +1 -0
  1015. package/dist/runtime/opencode.js +189 -0
  1016. package/dist/runtime/opencode.js.map +1 -0
  1017. package/dist/runtime/skills.js +17 -0
  1018. package/dist/runtime/skills.js.map +1 -0
  1019. package/dist/runtime/transcript.js +227 -0
  1020. package/dist/runtime/transcript.js.map +1 -0
  1021. package/dist/runtime/types.js +12 -0
  1022. package/dist/runtime/types.js.map +1 -0
  1023. package/dist/runtime/which.js +21 -0
  1024. package/dist/runtime/which.js.map +1 -0
  1025. package/dist/store/index.js +3 -0
  1026. package/dist/store/index.js.map +1 -0
  1027. package/dist/store/schema.js +286 -0
  1028. package/dist/store/schema.js.map +1 -0
  1029. package/dist/store/store.js +491 -0
  1030. package/dist/store/store.js.map +1 -0
  1031. package/dist/web/assets/EntryList-CnfGgjEY.js +1 -0
  1032. package/dist/web/assets/FilePath-C0X8-keS.js +1 -0
  1033. package/dist/web/assets/SettingsForm-BcyBWJbn.js +1 -0
  1034. package/dist/web/assets/SharedPipelinesGroup-a368-IQ0.js +1 -0
  1035. package/dist/web/assets/card-DkikoTxR.js +1 -0
  1036. package/dist/web/assets/deliveryModes-funlvXVC.js +1 -0
  1037. package/dist/web/assets/index-B-oJ93zH.js +22 -0
  1038. package/dist/web/assets/index-BZE36gYR.css +2 -0
  1039. package/dist/web/assets/inter-cyrillic-ext-wght-normal-BOeWTOD4.woff2 +0 -0
  1040. package/dist/web/assets/inter-cyrillic-wght-normal-DqGufNeO.woff2 +0 -0
  1041. package/dist/web/assets/inter-greek-ext-wght-normal-DlzME5K_.woff2 +0 -0
  1042. package/dist/web/assets/inter-greek-wght-normal-CkhJZR-_.woff2 +0 -0
  1043. package/dist/web/assets/inter-latin-ext-wght-normal-DO1Apj_S.woff2 +0 -0
  1044. package/dist/web/assets/inter-latin-wght-normal-Dx4kXJAl.woff2 +0 -0
  1045. package/dist/web/assets/inter-vietnamese-wght-normal-CBcvBZtf.woff2 +0 -0
  1046. package/dist/web/assets/locales-DtRrxYzg.js +1 -0
  1047. package/dist/web/assets/pipelines-D48ggDNe.js +1 -0
  1048. package/dist/web/assets/queue-D8_RY4IY.js +16 -0
  1049. package/dist/web/assets/rolldown-runtime-XKyaHtl9.js +1 -0
  1050. package/dist/web/assets/select-J4oIrmYh.js +1 -0
  1051. package/dist/web/assets/settings-B0-0Vaia.js +2 -0
  1052. package/dist/web/assets/skeleton-CCKCQF5n.js +1 -0
  1053. package/dist/web/assets/specialists-DH8tyluO.js +1 -0
  1054. package/dist/web/assets/switch-CWFAgxG1.js +41 -0
  1055. package/dist/web/assets/topology-CNQ28AB2.js +7 -0
  1056. package/dist/web/assets/topology-DLioOiRN.css +1 -0
  1057. package/dist/web/assets/vendor-markdown-DwXfjc7L.js +32 -0
  1058. package/dist/web/assets/vendor-react-C1iE8mnY.js +9 -0
  1059. package/dist/web/index.html +21 -0
  1060. package/integrations/claude-code/.claude-plugin/plugin.json +19 -0
  1061. package/integrations/claude-code/commands/apply.md +6 -0
  1062. package/integrations/claude-code/commands/panel.md +6 -0
  1063. package/integrations/claude-code/commands/run.md +6 -0
  1064. package/integrations/claude-code/commands/status.md +6 -0
  1065. package/integrations/claude-code/commands/web.md +6 -0
  1066. package/integrations/claude-code/hooks/aip.ts +365 -0
  1067. package/integrations/claude-code/hooks/feed.ts +923 -0
  1068. package/integrations/claude-code/hooks/hooks.json +1 -0
  1069. package/integrations/claude-code/hooks/pane.ts +396 -0
  1070. package/integrations/claude-code/hooks/register.tsx +156 -0
  1071. package/integrations/claude-code/hooks/theme.ts +59 -0
  1072. package/integrations/claude-code/hooks/transcript.tsx +44 -0
  1073. package/integrations/claude-code/hooks/view.tsx +378 -0
  1074. package/integrations/claude-code/hooks/web.ts +162 -0
  1075. package/integrations/claude-code/tsconfig.json +18 -0
  1076. package/integrations/claude-code/types/index.d.ts +89 -0
  1077. package/package.json +70 -4
  1078. package/templates/aip/pipelines/feature.yaml +4 -0
  1079. package/templates/aip/settings.yaml +10 -0
  1080. package/templates/aip/specialists/coder.yaml +4 -0
  1081. package/templates/aip/specialists/reviewer.yaml +5 -0
@@ -0,0 +1,1191 @@
1
+ import { randomBytes, timingSafeEqual } from 'node:crypto';
2
+ import { existsSync, readFileSync } from 'node:fs';
3
+ import { createServer } from 'node:http';
4
+ import { extname, isAbsolute, join, normalize, sep } from 'node:path';
5
+ import { fileURLToPath } from 'node:url';
6
+ import { z } from 'zod';
7
+ import { settingFieldOf } from '../../feature/swarm-edit/types/index.js';
8
+ import { SLUG_PATTERN_TEXT, isValidSlug } from '../../feature/swarm-config/types/index.js';
9
+ import { checkDaemon, currentBuild, MESSAGE_TEXT_LIMIT, pingDaemon, request, settingValueSchema, streamEventSchema, subscribe, } from '../../protocol/index.js';
10
+ import { artifactPreview } from '../../feature/artifacts/types/index.js';
11
+ import { RUN_TITLE_LIMIT } from '../../feature/agents/types/index.js';
12
+ import { TOKEN_HINT, configError, panel, renderPanelError } from './errors.js';
13
+ import { systemView } from './system.js';
14
+ /** How often a daemon older than the panel is checked again, so it is replaced once idle. */
15
+ export const RECHECK_MS = 30_000;
16
+ /** dist/web of the package, both from the sources (src/cli/web) and the build (dist/cli/web). */
17
+ export const DEFAULT_ASSETS = fileURLToPath(new URL('../../../dist/web/', import.meta.url));
18
+ const TYPES = {
19
+ '.js': 'text/javascript',
20
+ '.css': 'text/css',
21
+ '.svg': 'image/svg+xml',
22
+ '.png': 'image/png',
23
+ '.ico': 'image/x-icon',
24
+ '.woff2': 'font/woff2',
25
+ '.map': 'application/json',
26
+ };
27
+ const PAGE_POLICY = "default-src 'none'; script-src 'self'; style-src 'self' 'unsafe-inline'; connect-src 'self'; img-src 'self' data:; font-src 'self'; base-uri 'none'; form-action 'none'; frame-ancestors 'none'";
28
+ const MISSING_BUILD = `<!doctype html><html lang="en"><head><meta charset="utf-8"><title>aip</title></head><body><h1>aip web</h1><p>The panel is not built. Run <code>npm run build</code> in the aip repository and reload this page.</p></body></html>`;
29
+ const COOKIE = 'aip_token';
30
+ const BODY_LIMIT = 64 * 1024;
31
+ const skipBody = z.object({ step: z.string().trim().min(1), skip: z.boolean() });
32
+ const answerBody = z.object({ answer: z.string().trim().min(1) });
33
+ const messageBody = z.object({
34
+ seq: z.number().int().positive(),
35
+ text: z.string().trim().min(1).max(MESSAGE_TEXT_LIMIT),
36
+ });
37
+ const retryBody = z.object({ refreshConfig: z.boolean().optional() });
38
+ const applyBody = z.object({
39
+ groups: z.array(z.string().min(1)).optional(),
40
+ force: z.boolean().optional(),
41
+ });
42
+ const markDeliveredBody = z.object({ groups: z.array(z.string().min(1)).optional() });
43
+ const tagName = z.string().trim().min(1);
44
+ const tagAddBody = z.object({ name: tagName, color: z.string().optional() });
45
+ const tagEditBody = z
46
+ .object({ tag: tagName, name: tagName.optional(), color: z.string().optional() })
47
+ .refine((body) => body.name !== undefined || body.color !== undefined, {
48
+ message: 'pass a new name or a new color',
49
+ });
50
+ const tagRemoveBody = z.object({ tag: tagName });
51
+ const runTagsBody = z
52
+ .object({ add: z.array(tagName).max(20).optional(), remove: z.array(tagName).max(20).optional() })
53
+ .refine((body) => (body.add?.length ?? 0) + (body.remove?.length ?? 0) > 0, {
54
+ message: 'pass tags to add or remove',
55
+ });
56
+ const runTitleBody = z.object({ title: z.string().trim().min(1).max(RUN_TITLE_LIMIT) });
57
+ const levelParam = z.enum(['project', 'global']);
58
+ const previewBody = z.object({
59
+ value: z.record(z.string(), z.unknown()),
60
+ level: levelParam.optional(),
61
+ });
62
+ const writeBody = z.object({
63
+ value: z.record(z.string(), z.unknown()),
64
+ revision: z.string().min(1).nullable(),
65
+ level: levelParam.optional(),
66
+ });
67
+ /** Repository of the project level; null is the shared level. */
68
+ const levelRepository = z
69
+ .string()
70
+ .nullable()
71
+ .refine((value) => value === null || isAbsolute(value), {
72
+ message: 'repository must be an absolute path',
73
+ });
74
+ const tagsSetBody = z.object({
75
+ repository: levelRepository,
76
+ tags: z.array(z.string()),
77
+ revision: z.string().min(1).nullable(),
78
+ });
79
+ const tagRenameBody = z.object({
80
+ repository: levelRepository,
81
+ from: z.string().min(1),
82
+ to: z.string().min(1),
83
+ });
84
+ const specialistTagRemoveBody = z.object({ repository: levelRepository, tag: z.string().min(1) });
85
+ const importBody = z.object({
86
+ source: z.string().refine((value) => isAbsolute(value), {
87
+ message: 'source must be an absolute path',
88
+ }),
89
+ slugs: z.array(z.string().min(1)).min(1),
90
+ });
91
+ const pipelineImportBody = z.object({
92
+ source: z.string().refine((value) => isAbsolute(value), {
93
+ message: 'source must be an absolute path',
94
+ }),
95
+ ids: z.array(z.string().min(1)).min(1),
96
+ });
97
+ const forceBody = z.object({ force: z.boolean().optional() });
98
+ const SYSTEM_ACTIONS = {
99
+ '/api/system/web/restart': 'web_restart',
100
+ '/api/system/daemon/restart': 'daemon_restart',
101
+ '/api/system/daemon/stop': 'daemon_stop',
102
+ '/api/system/daemon/start': 'daemon_start',
103
+ };
104
+ const settingBody = z.object({
105
+ value: settingValueSchema,
106
+ revision: z.string().min(1).nullable(),
107
+ level: levelParam.optional(),
108
+ });
109
+ const settingsBody = z.object({
110
+ values: z.record(z.string(), settingValueSchema),
111
+ revision: z.string().min(1).nullable(),
112
+ level: levelParam.optional(),
113
+ });
114
+ /** A handler result with its own status code. */
115
+ class Reply {
116
+ status;
117
+ value;
118
+ constructor(status, value) {
119
+ this.status = status;
120
+ this.value = value;
121
+ }
122
+ }
123
+ /** Maps the outcome of a configuration edit onto HTTP: 200, 422 for errors, 409 for a conflict. */
124
+ function editReply(result) {
125
+ if (result.ok)
126
+ return new Reply(200, result);
127
+ if (result.reason === 'conflict')
128
+ return new Reply(409, { error: result.message });
129
+ return new Reply(422, { errors: result.errors, references: result.references ?? [] });
130
+ }
131
+ /** Reply of a tag edit or an import: 200 with the outcome, 422 for errors, 409 for a conflict. */
132
+ function tagReply(result) {
133
+ if (result.ok)
134
+ return new Reply(200, result);
135
+ if (result.reason === 'conflict') {
136
+ return new Reply(409, { error: result.message, slugs: result.slugs ?? [] });
137
+ }
138
+ return new Reply(422, { errors: result.errors, references: [] });
139
+ }
140
+ function entryId(value) {
141
+ const id = value ?? '';
142
+ if (!isValidSlug(id))
143
+ throw panel('invalid', `id must match ${SLUG_PATTERN_TEXT}`);
144
+ return id;
145
+ }
146
+ function sameToken(given, expected) {
147
+ if (given === undefined)
148
+ return false;
149
+ const a = Buffer.from(given);
150
+ const b = Buffer.from(expected);
151
+ return a.length === b.length && timingSafeEqual(a, b);
152
+ }
153
+ function cookieToken(header) {
154
+ for (const part of (header ?? '').split(';')) {
155
+ const [name, ...value] = part.trim().split('=');
156
+ if (name === COOKIE)
157
+ return value.join('=');
158
+ }
159
+ return undefined;
160
+ }
161
+ function send(response, status, body, type, headers = {}) {
162
+ response.writeHead(status, {
163
+ 'content-type': `${type}; charset=utf-8`,
164
+ 'cache-control': 'no-store',
165
+ 'x-content-type-options': 'nosniff',
166
+ 'referrer-policy': 'no-referrer',
167
+ ...headers,
168
+ });
169
+ response.end(body);
170
+ }
171
+ function json(response, status, value) {
172
+ send(response, status, JSON.stringify(value), 'application/json');
173
+ }
174
+ async function readJson(incoming) {
175
+ if (!(incoming.headers['content-type'] ?? '').startsWith('application/json'))
176
+ throw panel('unsupported', 'content-type must be application/json');
177
+ let size = 0;
178
+ const chunks = [];
179
+ for await (const chunk of incoming) {
180
+ size += chunk.length;
181
+ if (size > BODY_LIMIT)
182
+ throw panel('too_large', 'request body is too large');
183
+ chunks.push(chunk);
184
+ }
185
+ if (size === 0)
186
+ return {};
187
+ try {
188
+ return JSON.parse(Buffer.concat(chunks).toString('utf8'));
189
+ }
190
+ catch {
191
+ throw panel('invalid', 'invalid JSON');
192
+ }
193
+ }
194
+ const runObserverBody = z.object({ enabled: z.boolean() });
195
+ function parseBody(schema, value) {
196
+ const parsed = schema.safeParse(value);
197
+ if (!parsed.success)
198
+ throw panel('invalid', z.prettifyError(parsed.error));
199
+ return parsed.data;
200
+ }
201
+ /** Fan-out of the daemon event stream; keeps the latest state of every run. */
202
+ class Hub {
203
+ socket;
204
+ runs = new Map();
205
+ queues = new Map();
206
+ repositories = [];
207
+ tags = [];
208
+ /** The last `processes` event of the daemon, without `seq`; null until it sends one. */
209
+ processes = null;
210
+ seq = 0;
211
+ ready = false;
212
+ stopped = false;
213
+ abort = new AbortController();
214
+ clients = new Set();
215
+ ensure;
216
+ /** Build mismatch with the daemon, as the panel shows it; null when the builds match. */
217
+ daemon = null;
218
+ checking = null;
219
+ recheck;
220
+ constructor(socket, ensure) {
221
+ this.socket = socket;
222
+ this.ensure = ensure;
223
+ this.recheck = setInterval(() => {
224
+ if (this.daemon?.outdated === 'daemon')
225
+ void this.check();
226
+ }, RECHECK_MS);
227
+ this.recheck.unref();
228
+ void this.connect();
229
+ }
230
+ check() {
231
+ this.checking ??= this.ensure()
232
+ .then((result) => {
233
+ if (JSON.stringify(result.mismatch) === JSON.stringify(this.daemon))
234
+ return;
235
+ this.daemon = result.mismatch;
236
+ this.broadcast({ event: 'daemon', daemon: this.daemon });
237
+ }, () => undefined)
238
+ .finally(() => {
239
+ this.checking = null;
240
+ });
241
+ return this.checking;
242
+ }
243
+ async connect() {
244
+ while (!this.stopped) {
245
+ await this.check();
246
+ if (this.stopped)
247
+ break;
248
+ try {
249
+ await subscribe(this.socket, (line) => this.onLine(line), this.abort.signal);
250
+ }
251
+ catch {
252
+ // the daemon is not reachable yet; retry below
253
+ }
254
+ this.ready = false;
255
+ if (!this.stopped)
256
+ await new Promise((resolve) => {
257
+ const timer = setTimeout(resolve, 1000);
258
+ this.abort.signal.addEventListener('abort', () => {
259
+ clearTimeout(timer);
260
+ resolve(undefined);
261
+ }, { once: true });
262
+ });
263
+ }
264
+ }
265
+ onLine(line) {
266
+ let event;
267
+ try {
268
+ event = streamEventSchema.parse(JSON.parse(line));
269
+ }
270
+ catch {
271
+ return;
272
+ }
273
+ if (event.event === 'snapshot') {
274
+ this.tags = event.tags ?? [];
275
+ this.runs = new Map(event.runs.map((run) => [run.id, run]));
276
+ this.queues = new Map((event.queues ?? []).map((queue) => [queue.repository, queue]));
277
+ this.repositories = event.repositories ?? [];
278
+ this.processes = null;
279
+ this.ready = true;
280
+ this.seq = event.seq;
281
+ this.broadcast(this.snapshot());
282
+ }
283
+ else if (event.event === 'run') {
284
+ this.runs.set(event.run.id, event.run);
285
+ this.seq = event.seq;
286
+ this.broadcast(event);
287
+ }
288
+ else if (event.event === 'repositories') {
289
+ this.repositories = event.repositories;
290
+ this.seq = event.seq;
291
+ this.broadcast(event);
292
+ }
293
+ else if (event.event === 'queue') {
294
+ this.queues.set(event.queue.repository, event.queue);
295
+ this.seq = event.seq;
296
+ this.broadcast(event);
297
+ }
298
+ else if (event.event === 'tags') {
299
+ this.tags = event.tags;
300
+ this.seq = event.seq;
301
+ this.broadcast(event);
302
+ }
303
+ else if (event.event === 'observers') {
304
+ // Not kept: the snapshot has no observers, a new tab reads GET /api/observers.
305
+ this.seq = event.seq;
306
+ this.broadcast(event);
307
+ }
308
+ else if (event.event === 'processes') {
309
+ const { seq, ...rest } = event;
310
+ this.processes = rest;
311
+ this.seq = seq;
312
+ this.broadcast(event);
313
+ }
314
+ }
315
+ snapshot() {
316
+ return {
317
+ event: 'snapshot',
318
+ seq: this.seq,
319
+ runs: [...this.runs.values()],
320
+ queues: [...this.queues.values()],
321
+ repositories: this.repositories,
322
+ tags: this.tags,
323
+ daemon: this.daemon,
324
+ };
325
+ }
326
+ broadcast(event) {
327
+ const frame = `data: ${JSON.stringify(event)}\n\n`;
328
+ for (const client of this.clients)
329
+ client.write(frame);
330
+ }
331
+ attach(incoming, response) {
332
+ response.writeHead(200, {
333
+ 'content-type': 'text/event-stream; charset=utf-8',
334
+ 'cache-control': 'no-store',
335
+ connection: 'keep-alive',
336
+ 'x-accel-buffering': 'no',
337
+ });
338
+ response.write('retry: 2000\n\n');
339
+ this.clients.add(response);
340
+ if (this.ready) {
341
+ response.write(`data: ${JSON.stringify(this.snapshot())}\n\n`);
342
+ if (this.processes) {
343
+ response.write(`data: ${JSON.stringify({ ...this.processes, seq: this.seq })}\n\n`);
344
+ }
345
+ }
346
+ const beat = setInterval(() => response.write(': ping\n\n'), 15_000);
347
+ incoming.on('close', () => {
348
+ clearInterval(beat);
349
+ this.clients.delete(response);
350
+ });
351
+ }
352
+ stop() {
353
+ this.stopped = true;
354
+ clearInterval(this.recheck);
355
+ this.abort.abort();
356
+ for (const client of this.clients)
357
+ client.end();
358
+ this.clients.clear();
359
+ }
360
+ }
361
+ function transcriptQuery(search) {
362
+ const query = {};
363
+ for (const [key, low] of [
364
+ ['seq', 1],
365
+ ['after', 0],
366
+ ]) {
367
+ const value = search.get(key);
368
+ if (value === null)
369
+ continue;
370
+ const number = Number(value);
371
+ if (!Number.isInteger(number) || number < low)
372
+ throw panel('invalid', `${key} must be an integer from ${low}`);
373
+ query[key] = number;
374
+ }
375
+ return query;
376
+ }
377
+ export function assertLoopbackHost(host) {
378
+ if (!['127.0.0.1', 'localhost', '::1'].includes(host))
379
+ throw configError('the web panel only listens on loopback: use 127.0.0.1, localhost or ::1');
380
+ }
381
+ const TOKEN_PATTERN = /^[A-Za-z0-9_-]{16,128}$/;
382
+ /** The fixed access token from `AIP_WEB_TOKEN`, or undefined when the variable is not set. */
383
+ export function webTokenFromEnv(env) {
384
+ const value = env.AIP_WEB_TOKEN;
385
+ if (value === undefined || value === '')
386
+ return undefined;
387
+ if (!TOKEN_PATTERN.test(value))
388
+ throw configError('AIP_WEB_TOKEN must be 16-128 characters of A-Z, a-z, 0-9, - and _');
389
+ return value;
390
+ }
391
+ export async function startWebServer(options) {
392
+ const open = options.auth === 'none';
393
+ const token = open ? null : (options.token ?? randomBytes(24).toString('base64url'));
394
+ const host = options.host ?? '127.0.0.1';
395
+ assertLoopbackHost(host);
396
+ const hub = new Hub(options.socket, options.ensureDaemon ?? (() => checkDaemon(options.socket)));
397
+ const assets = normalize(options.assets ?? DEFAULT_ASSETS);
398
+ const call = (method, params) => request(options.socket, method, params);
399
+ let port = options.port ?? 0;
400
+ const segment = '([^/]+)';
401
+ /** The repository of a request: `?repository=` (absolute path) or the one of the panel. */
402
+ const requestRepository = async (searchParams) => {
403
+ const chosen = searchParams.get('repository');
404
+ if (chosen === null || chosen === '') {
405
+ if (options.repository !== undefined)
406
+ return options.repository;
407
+ const found = (await options.defaultRepository?.()) ?? null;
408
+ if (found === null)
409
+ throw panel('conflict', 'no repository yet: add one in the panel');
410
+ return found;
411
+ }
412
+ if (!isAbsolute(chosen))
413
+ throw panel('invalid', 'repository must be an absolute path');
414
+ return chosen;
415
+ };
416
+ /** Fields of a queue request body; the repository comes from the query string, never the body. */
417
+ const queueBody = (body) => parseBody(z.record(z.string(), z.unknown()), body);
418
+ const routes = [
419
+ { method: 'GET', pattern: /^\/api\/runs$/, handle: () => call('status', {}) },
420
+ {
421
+ method: 'GET',
422
+ pattern: /^\/api\/finished-runs$/,
423
+ handle: (_match, body) => call('finished_runs', body),
424
+ },
425
+ {
426
+ method: 'GET',
427
+ pattern: new RegExp(`^/api/runs/${segment}$`),
428
+ handle: ([runId]) => call('status', { runId: runId ?? '' }),
429
+ },
430
+ {
431
+ method: 'GET',
432
+ pattern: new RegExp(`^/api/runs/${segment}/groups/${segment}$`),
433
+ handle: ([runId, group], body) => call('group', {
434
+ runId: runId ?? '',
435
+ group: group ?? '',
436
+ tailLines: body.tail,
437
+ }),
438
+ },
439
+ {
440
+ method: 'GET',
441
+ pattern: new RegExp(`^/api/runs/${segment}/groups/${segment}/spec$`),
442
+ handle: ([runId, group]) => call('group_spec', { runId: runId ?? '', group: group ?? '' }),
443
+ },
444
+ {
445
+ method: 'GET',
446
+ pattern: new RegExp(`^/api/runs/${segment}/groups/${segment}/artifacts$`),
447
+ handle: async ([runId, group]) => ({
448
+ artifacts: await call('group_artifacts', { runId: runId ?? '', group: group ?? '' }),
449
+ }),
450
+ },
451
+ {
452
+ method: 'GET',
453
+ pattern: new RegExp(`^/api/runs/${segment}/groups/${segment}/transcript$`),
454
+ handle: ([runId, group], body) => call('transcript', {
455
+ runId: runId ?? '',
456
+ group: group ?? '',
457
+ ...body,
458
+ }),
459
+ },
460
+ {
461
+ method: 'GET',
462
+ pattern: new RegExp(`^/api/runs/${segment}/groups/${segment}/diff$`),
463
+ handle: ([runId, group], body) => call('group_file_diff', {
464
+ runId: runId ?? '',
465
+ group: group ?? '',
466
+ path: body.path,
467
+ }),
468
+ },
469
+ {
470
+ method: 'GET',
471
+ pattern: /^\/api\/pipelines$/,
472
+ handle: (_match, _body, repository) => call('pipelines', { repository }),
473
+ },
474
+ {
475
+ method: 'GET',
476
+ pattern: /^\/api\/system-stages$/,
477
+ handle: (_match, _body, repository) => call('system_stages', { repository }),
478
+ },
479
+ {
480
+ method: 'GET',
481
+ pattern: /^\/api\/queue$/,
482
+ handle: (_match, _body, repository) => call('queue', { repository }),
483
+ },
484
+ {
485
+ method: 'POST',
486
+ pattern: /^\/api\/queue\/items$/,
487
+ handle: async (_, body, repository) => call('queue_add', {
488
+ ...queueBody(body),
489
+ repository,
490
+ }),
491
+ },
492
+ {
493
+ method: 'POST',
494
+ pattern: new RegExp(`^/api/queue/items/${segment}$`),
495
+ handle: async ([item], body, repository) => call('queue_edit', {
496
+ ...queueBody(body),
497
+ item: item ?? '',
498
+ repository,
499
+ }),
500
+ },
501
+ {
502
+ method: 'POST',
503
+ pattern: new RegExp(`^/api/queue/items/${segment}/remove$`),
504
+ handle: ([item], _body, repository) => call('queue_remove', { item: item ?? '', repository }),
505
+ },
506
+ {
507
+ method: 'POST',
508
+ pattern: new RegExp(`^/api/queue/items/${segment}/run$`),
509
+ handle: ([item], _body, repository) => call('queue_run_now', { item: item ?? '', repository }),
510
+ },
511
+ {
512
+ method: 'POST',
513
+ pattern: /^\/api\/queue\/start$/,
514
+ handle: async (_, body, repository) => call('queue_start', {
515
+ ...queueBody(body),
516
+ repository,
517
+ }),
518
+ },
519
+ {
520
+ method: 'POST',
521
+ pattern: /^\/api\/queue\/pause$/,
522
+ handle: (_match, _body, repository) => call('queue_pause', { repository }),
523
+ },
524
+ {
525
+ method: 'POST',
526
+ pattern: /^\/api\/queue\/return$/,
527
+ handle: async (_, body, repository) => {
528
+ const { run } = parseBody(z.object({ run: z.string().min(1) }), body);
529
+ return call('queue_return', { runId: run, ...(repository ? { repository } : {}) });
530
+ },
531
+ },
532
+ {
533
+ method: 'POST',
534
+ pattern: /^\/api\/queue\/dismiss$/,
535
+ handle: async (_, body, repository) => {
536
+ const { run } = parseBody(z.object({ run: z.string().min(1) }), body);
537
+ return call('queue_dismiss', { runId: run, ...(repository ? { repository } : {}) });
538
+ },
539
+ },
540
+ {
541
+ method: 'POST',
542
+ pattern: /^\/api\/queue\/settings$/,
543
+ handle: async (_, body, repository) => call('queue_settings', {
544
+ ...queueBody(body),
545
+ repository,
546
+ }),
547
+ },
548
+ {
549
+ method: 'GET',
550
+ pattern: /^\/api\/config$/,
551
+ handle: (_match, _body, repository) => call('config', { repository }),
552
+ },
553
+ {
554
+ method: 'GET',
555
+ pattern: /^\/api\/config\/catalog$/,
556
+ handle: (_match, _body, repository) => call('config_catalog', { repository }),
557
+ },
558
+ {
559
+ method: 'PUT',
560
+ pattern: new RegExp(`^/api/config/specialists/${segment}$`),
561
+ handle: async ([id], body, repository) => {
562
+ const { value, revision, level } = parseBody(writeBody, body);
563
+ return editReply((await call('config_write', {
564
+ repository,
565
+ kind: 'specialist',
566
+ id: entryId(id),
567
+ value,
568
+ revision,
569
+ level,
570
+ })));
571
+ },
572
+ },
573
+ {
574
+ method: 'GET',
575
+ pattern: /^\/api\/shared-pipelines$/,
576
+ handle: () => call('shared_pipelines', {}),
577
+ },
578
+ {
579
+ method: 'POST',
580
+ pattern: /^\/api\/config\/pipelines\/import$/,
581
+ handle: async (_match, body, repository) => {
582
+ const result = (await call('pipelines_import', {
583
+ repository,
584
+ ...parseBody(pipelineImportBody, body),
585
+ }));
586
+ if (result.ok)
587
+ return new Reply(200, result);
588
+ if (result.reason === 'conflict') {
589
+ return new Reply(409, { error: result.message, ids: result.ids ?? [] });
590
+ }
591
+ return new Reply(422, { errors: result.errors, references: [] });
592
+ },
593
+ },
594
+ {
595
+ method: 'GET',
596
+ pattern: /^\/api\/shared-specialists$/,
597
+ handle: () => call('shared_specialists', {}),
598
+ },
599
+ {
600
+ method: 'GET',
601
+ pattern: /^\/api\/observers$/,
602
+ handle: () => call('observers', {}),
603
+ },
604
+ {
605
+ method: 'PUT',
606
+ pattern: /^\/api\/observers$/,
607
+ handle: async (_match, body) => {
608
+ const settings = parseBody(z.record(z.string(), z.unknown()), body);
609
+ const result = (await call('observers_set', { settings }));
610
+ if (result.ok)
611
+ return new Reply(200, result.view);
612
+ return new Reply(422, { errors: result.errors });
613
+ },
614
+ },
615
+ {
616
+ method: 'POST',
617
+ pattern: new RegExp(`^/api/runs/${segment}/observer$`),
618
+ handle: async ([runId], body) => call('run_observer', { runId: runId ?? '', ...parseBody(runObserverBody, body) }),
619
+ },
620
+ {
621
+ method: 'GET',
622
+ pattern: /^\/api\/specialist-tags$/,
623
+ handle: () => call('specialist_tags', {}),
624
+ },
625
+ {
626
+ method: 'PUT',
627
+ pattern: new RegExp(`^/api/specialist-tags/specialists/${segment}$`),
628
+ handle: async ([slug], body) => tagReply((await call('specialist_tags_set', {
629
+ ...parseBody(tagsSetBody, body),
630
+ slug: entryId(slug),
631
+ }))),
632
+ },
633
+ {
634
+ method: 'POST',
635
+ pattern: /^\/api\/specialist-tags\/rename$/,
636
+ handle: async (_match, body) => tagReply((await call('specialist_tag_rename', parseBody(tagRenameBody, body)))),
637
+ },
638
+ {
639
+ method: 'POST',
640
+ pattern: /^\/api\/specialist-tags\/remove$/,
641
+ handle: async (_match, body) => tagReply((await call('specialist_tag_remove', parseBody(specialistTagRemoveBody, body)))),
642
+ },
643
+ {
644
+ method: 'POST',
645
+ pattern: /^\/api\/config\/specialists\/import$/,
646
+ handle: async (_match, body, repository) => tagReply((await call('specialists_import', {
647
+ repository,
648
+ ...parseBody(importBody, body),
649
+ }))),
650
+ },
651
+ {
652
+ method: 'PUT',
653
+ pattern: /^\/api\/config\/settings$/,
654
+ handle: async (_match, body, repository) => {
655
+ const { values, revision, level } = parseBody(settingsBody, body);
656
+ const unknown = Object.keys(values).filter((path) => settingFieldOf(path) === undefined);
657
+ if (unknown.length > 0) {
658
+ throw panel('not_found', `setting \`${unknown.join('`, `')}\` cannot be written`);
659
+ }
660
+ if (Object.keys(values).length === 0)
661
+ throw panel('invalid', 'values must not be empty');
662
+ return editReply((await call('config_settings', {
663
+ repository,
664
+ values,
665
+ revision,
666
+ level: level ?? 'global',
667
+ })));
668
+ },
669
+ },
670
+ {
671
+ method: 'PUT',
672
+ pattern: new RegExp(`^/api/config/settings/${segment}$`),
673
+ handle: async ([path], body, repository) => {
674
+ const known = path !== undefined && settingFieldOf(path) !== undefined ? path : undefined;
675
+ if (known === undefined) {
676
+ throw panel('not_found', `setting \`${path ?? ''}\` cannot be written`);
677
+ }
678
+ const { value, revision, level } = parseBody(settingBody, body);
679
+ return editReply((await call('config_setting', {
680
+ repository,
681
+ path: known,
682
+ value,
683
+ revision,
684
+ level: level ?? 'global',
685
+ })));
686
+ },
687
+ },
688
+ {
689
+ method: 'DELETE',
690
+ pattern: new RegExp(`^/api/config/(specialists|pipelines|actions)/${segment}$`),
691
+ handle: async ([section, id], body, repository) => {
692
+ const { revision, level } = body;
693
+ if (!revision)
694
+ throw panel('invalid', 'revision is required');
695
+ return editReply((await call('config_delete', {
696
+ repository,
697
+ kind: section === 'pipelines'
698
+ ? 'pipeline'
699
+ : section === 'actions'
700
+ ? 'action'
701
+ : 'specialist',
702
+ id: entryId(id),
703
+ revision,
704
+ level,
705
+ })));
706
+ },
707
+ },
708
+ {
709
+ method: 'PUT',
710
+ pattern: new RegExp(`^/api/config/pipelines/${segment}$`),
711
+ handle: async ([id], body, repository) => {
712
+ const { value, revision, level } = parseBody(writeBody, body);
713
+ return editReply((await call('config_write', {
714
+ repository,
715
+ kind: 'pipeline',
716
+ id: entryId(id),
717
+ value,
718
+ revision,
719
+ level,
720
+ })));
721
+ },
722
+ },
723
+ {
724
+ method: 'PUT',
725
+ pattern: new RegExp(`^/api/config/actions/${segment}$`),
726
+ handle: async ([id], body, repository) => {
727
+ const { value, revision, level } = parseBody(writeBody, body);
728
+ return editReply((await call('config_write', {
729
+ repository,
730
+ kind: 'action',
731
+ id: entryId(id),
732
+ value,
733
+ revision,
734
+ level,
735
+ })));
736
+ },
737
+ },
738
+ {
739
+ method: 'POST',
740
+ pattern: new RegExp(`^/api/config/pipelines/${segment}/preview$`),
741
+ handle: async ([id], body, repository) => call('config_preview', {
742
+ repository,
743
+ kind: 'pipeline',
744
+ id: entryId(id),
745
+ value: parseBody(previewBody, body).value,
746
+ level: parseBody(previewBody, body).level,
747
+ }),
748
+ },
749
+ {
750
+ method: 'GET',
751
+ pattern: /^\/api\/tags$/,
752
+ handle: (_match, _body, repository) => call('tags', { repository }),
753
+ },
754
+ {
755
+ method: 'POST',
756
+ pattern: /^\/api\/tags$/,
757
+ handle: async (_, body, repository) => call('tag_add', { repository, ...parseBody(tagAddBody, body) }),
758
+ },
759
+ {
760
+ method: 'POST',
761
+ pattern: /^\/api\/tags\/edit$/,
762
+ handle: async (_, body, repository) => call('tag_edit', { repository, ...parseBody(tagEditBody, body) }),
763
+ },
764
+ {
765
+ method: 'POST',
766
+ pattern: /^\/api\/tags\/remove$/,
767
+ handle: async (_, body, repository) => call('tag_remove', { repository, ...parseBody(tagRemoveBody, body) }),
768
+ },
769
+ {
770
+ method: 'POST',
771
+ pattern: new RegExp(`^/api/runs/${segment}/tags$`),
772
+ handle: async ([runId], body) => call('run_tags', { runId: runId ?? '', ...parseBody(runTagsBody, body) }),
773
+ },
774
+ {
775
+ method: 'POST',
776
+ pattern: new RegExp(`^/api/runs/${segment}/title$`),
777
+ handle: async ([runId], body) => call('run_title', { runId: runId ?? '', ...parseBody(runTitleBody, body) }),
778
+ },
779
+ {
780
+ method: 'GET',
781
+ pattern: /^\/api\/processes$/,
782
+ handle: () => call('processes', {}),
783
+ },
784
+ {
785
+ method: 'POST',
786
+ pattern: /^\/api\/processes\/([^/]+)\/kill$/,
787
+ handle: ([pid]) => {
788
+ if (!/^\d+$/.test(pid ?? ''))
789
+ throw panel('invalid', 'pid must be a positive integer');
790
+ return call('process_kill', { pid: Number(pid) });
791
+ },
792
+ },
793
+ {
794
+ method: 'POST',
795
+ pattern: new RegExp(`^/api/runs/${segment}/cancel$`),
796
+ handle: ([runId]) => call('cancel', { runId: runId ?? '' }),
797
+ },
798
+ {
799
+ method: 'POST',
800
+ pattern: new RegExp(`^/api/runs/${segment}/pause$`),
801
+ handle: ([runId]) => call('run_pause', { runId: runId ?? '' }),
802
+ },
803
+ {
804
+ method: 'POST',
805
+ pattern: new RegExp(`^/api/runs/${segment}/skip$`),
806
+ handle: async ([runId], body) => {
807
+ const { step, skip } = parseBody(skipBody, body);
808
+ return call('run_skip', { runId: runId ?? '', step, skip });
809
+ },
810
+ },
811
+ {
812
+ method: 'POST',
813
+ pattern: new RegExp(`^/api/runs/${segment}/apply$`),
814
+ handle: async ([runId], body) => {
815
+ const { groups, force } = parseBody(applyBody, body);
816
+ return call('apply', {
817
+ runId: runId ?? '',
818
+ ...(groups ? { groups } : {}),
819
+ ...(force ? { force: true } : {}),
820
+ });
821
+ },
822
+ },
823
+ {
824
+ method: 'POST',
825
+ pattern: new RegExp(`^/api/runs/${segment}/delivered$`),
826
+ handle: async ([runId], body) => {
827
+ const { groups } = parseBody(markDeliveredBody, body);
828
+ return call('run_mark_delivered', { runId: runId ?? '', ...(groups ? { groups } : {}) });
829
+ },
830
+ },
831
+ {
832
+ method: 'POST',
833
+ pattern: new RegExp(`^/api/runs/${segment}/groups/${segment}/(cancel|retry)$`),
834
+ handle: ([runId, group, action], body) => {
835
+ if (action !== 'retry')
836
+ return call('cancel', { runId: runId ?? '', group: group ?? '' });
837
+ const { refreshConfig } = parseBody(retryBody, body);
838
+ return call('retry', {
839
+ runId: runId ?? '',
840
+ group: group ?? '',
841
+ ...(refreshConfig ? { refreshConfig: true } : {}),
842
+ });
843
+ },
844
+ },
845
+ {
846
+ method: 'POST',
847
+ pattern: new RegExp(`^/api/runs/${segment}/groups/${segment}/answer$`),
848
+ handle: async ([runId, group], body) => call('answer', {
849
+ runId: runId ?? '',
850
+ group: group ?? '',
851
+ answer: parseBody(answerBody, body).answer,
852
+ }),
853
+ },
854
+ {
855
+ method: 'POST',
856
+ pattern: new RegExp(`^/api/runs/${segment}/groups/${segment}/message$`),
857
+ handle: async ([runId, group], body) => {
858
+ const { seq, text } = parseBody(messageBody, body);
859
+ return call('message', { runId: runId ?? '', group: group ?? '', seq, text });
860
+ },
861
+ },
862
+ ];
863
+ function hostAllowed(incoming) {
864
+ const given = incoming.headers.host?.toLowerCase();
865
+ if (given === undefined)
866
+ return false;
867
+ const allowed = new Set([`127.0.0.1:${port}`, `localhost:${port}`, `[::1]:${port}`]);
868
+ if (!allowed.has(given))
869
+ return false;
870
+ const origin = incoming.headers.origin;
871
+ if (origin === undefined)
872
+ return true;
873
+ try {
874
+ return new URL(origin).host.toLowerCase() === given;
875
+ }
876
+ catch {
877
+ return false;
878
+ }
879
+ }
880
+ /** Runs `action` once the response is on its way: the restart closes this very server. */
881
+ function afterResponse(response, label, action) {
882
+ response.once('finish', () => {
883
+ setImmediate(() => {
884
+ action().catch((error) => {
885
+ options.log?.(`aip web: ${label} failed: ${error.message}`);
886
+ });
887
+ });
888
+ });
889
+ }
890
+ async function handleSystem(incoming, response, path, verb) {
891
+ const hooks = options.system;
892
+ if (path === '/api/system') {
893
+ if (verb !== 'GET')
894
+ throw panel('method_not_allowed', 'method not allowed');
895
+ const ping = await pingDaemon(options.socket).catch(() => null);
896
+ const check = ping === null
897
+ ? null
898
+ : await (options.ensureDaemon ?? (() => checkDaemon(options.socket)))().catch(() => null);
899
+ return json(response, 200, systemView({
900
+ ping,
901
+ check,
902
+ panelBuild: currentBuild(),
903
+ servedBy: hooks === undefined ? 'standalone' : (hooks.servedBy ?? 'daemon'),
904
+ panel: { pid: process.pid, host, port, auth: open ? 'none' : 'token' },
905
+ logPath: hooks?.logPath ?? null,
906
+ }));
907
+ }
908
+ const action = SYSTEM_ACTIONS[path];
909
+ if (action === undefined)
910
+ throw panel('not_found', 'not found');
911
+ if (verb !== 'POST')
912
+ throw panel('method_not_allowed', 'method not allowed');
913
+ const body = parseBody(action === 'web_restart' ? z.object({}) : forceBody, await readJson(incoming));
914
+ const force = body.force === true;
915
+ if (hooks === undefined) {
916
+ throw panel('conflict', 'this panel was started by `aip web`: control the daemon in the terminal', 'web_standalone');
917
+ }
918
+ const hook = action === 'web_restart'
919
+ ? hooks.restartWeb
920
+ : action === 'daemon_restart'
921
+ ? hooks.restartDaemon
922
+ : action === 'daemon_stop'
923
+ ? hooks.stopDaemon
924
+ : hooks.startDaemon;
925
+ if (hook === undefined) {
926
+ if (action === 'daemon_start')
927
+ throw panel('conflict', 'the daemon is already running', 'daemon_running');
928
+ throw panel('conflict', 'the daemon is stopped: start it first', 'daemon_stopped');
929
+ }
930
+ if ((action === 'daemon_restart' || action === 'daemon_stop') && !force) {
931
+ const ping = await pingDaemon(options.socket).catch(() => null);
932
+ if (ping?.busy === true)
933
+ throw panel('conflict', `agents are running: ${action === 'daemon_stop' ? 'stop' : 'restart'} anyway to stop them`, 'daemon_busy');
934
+ }
935
+ afterResponse(response, action.replace('_', ' '), () => hook(force));
936
+ json(response, 202, {
937
+ state: action === 'daemon_stop'
938
+ ? 'stopping'
939
+ : action === 'daemon_start'
940
+ ? 'starting'
941
+ : 'restarting',
942
+ });
943
+ }
944
+ async function handle(incoming, response) {
945
+ if (!hostAllowed(incoming))
946
+ throw panel('forbidden', 'forbidden host or origin');
947
+ const url = new URL(incoming.url ?? '/', `http://${incoming.headers.host}`);
948
+ const verb = incoming.method ?? 'GET';
949
+ if (url.pathname === '/' || url.pathname === '/index.html') {
950
+ if (verb !== 'GET')
951
+ throw panel('method_not_allowed', 'method not allowed');
952
+ const fromQuery = url.searchParams.get('token') ?? undefined;
953
+ if (token !== null &&
954
+ !sameToken(fromQuery, token) &&
955
+ !sameToken(cookieToken(incoming.headers.cookie), token))
956
+ throw panel('unauthorized', TOKEN_HINT);
957
+ const index = join(assets, 'index.html');
958
+ const page = existsSync(index) ? readFileSync(index, 'utf8') : MISSING_BUILD;
959
+ send(response, 200, page, 'text/html', {
960
+ ...(token === null
961
+ ? {}
962
+ : { 'set-cookie': `${COOKIE}=${token}; Path=/; HttpOnly; SameSite=Strict` }),
963
+ 'content-security-policy': PAGE_POLICY,
964
+ 'cache-control': 'no-cache',
965
+ });
966
+ return;
967
+ }
968
+ if (url.pathname.startsWith('/assets/')) {
969
+ if (verb !== 'GET')
970
+ throw panel('method_not_allowed', 'method not allowed');
971
+ const file = normalize(join(assets, decodeURIComponent(url.pathname)));
972
+ if (!file.startsWith(assets.endsWith(sep) ? assets : `${assets}${sep}`) || !existsSync(file))
973
+ throw panel('not_found', 'not found');
974
+ const type = TYPES[extname(file)] ?? 'application/octet-stream';
975
+ response.writeHead(200, {
976
+ 'content-type': type.startsWith('text/') ? `${type}; charset=utf-8` : type,
977
+ // Vite names assets by their content hash, so they never change.
978
+ 'cache-control': 'public, max-age=31536000, immutable',
979
+ 'x-content-type-options': 'nosniff',
980
+ });
981
+ response.end(readFileSync(file));
982
+ return;
983
+ }
984
+ if (!url.pathname.startsWith('/api/'))
985
+ throw panel('not_found', 'not found');
986
+ if (token !== null) {
987
+ const given = incoming.headers['x-aip-token'] ??
988
+ cookieToken(incoming.headers.cookie);
989
+ if (!sameToken(given, token))
990
+ throw panel('unauthorized', 'missing or invalid token');
991
+ }
992
+ if (url.pathname === '/api/events') {
993
+ if (verb !== 'GET')
994
+ throw panel('method_not_allowed', 'method not allowed');
995
+ hub.attach(incoming, response);
996
+ return;
997
+ }
998
+ if (url.pathname === '/api/repositories') {
999
+ if (verb === 'GET')
1000
+ return json(response, 200, await call('repositories', {}));
1001
+ if (verb === 'POST') {
1002
+ const { path } = parseBody(z.object({ path: z.string().min(1) }), await readJson(incoming));
1003
+ if (!isAbsolute(path))
1004
+ throw panel('invalid', 'path must be an absolute path');
1005
+ return json(response, 200, await call('repository_add', { path }));
1006
+ }
1007
+ if (verb === 'DELETE') {
1008
+ const path = url.searchParams.get('repository');
1009
+ if (path === null || !isAbsolute(path)) {
1010
+ throw panel('invalid', 'repository must be an absolute path');
1011
+ }
1012
+ return json(response, 200, await call('repository_remove', { path }));
1013
+ }
1014
+ throw panel('method_not_allowed', 'method not allowed');
1015
+ }
1016
+ if (url.pathname === '/api/system' || url.pathname.startsWith('/api/system/')) {
1017
+ await handleSystem(incoming, response, url.pathname, verb);
1018
+ return;
1019
+ }
1020
+ const patchMatch = new RegExp(`^/api/runs/${segment}/patch$`).exec(url.pathname);
1021
+ if (patchMatch) {
1022
+ if (verb !== 'GET')
1023
+ throw panel('method_not_allowed', 'method not allowed');
1024
+ let runId;
1025
+ try {
1026
+ runId = decodeURIComponent(patchMatch[1] ?? '');
1027
+ }
1028
+ catch {
1029
+ throw panel('invalid', 'malformed percent-encoding in path');
1030
+ }
1031
+ const patch = (await call('run_patch', { runId }));
1032
+ const bytes = Buffer.from(patch.base64, 'base64');
1033
+ response.writeHead(200, {
1034
+ 'Content-Type': 'text/x-diff; charset=binary',
1035
+ 'Content-Disposition': `attachment; filename="${patch.fileName.replace(/[^A-Za-z0-9._-]/g, '_')}"`,
1036
+ 'Content-Length': bytes.length,
1037
+ 'Cache-Control': 'no-store',
1038
+ });
1039
+ response.end(bytes);
1040
+ return;
1041
+ }
1042
+ const artifactMatch = new RegExp(`^/api/runs/${segment}/groups/${segment}/artifacts/${segment}$`).exec(url.pathname);
1043
+ if (artifactMatch) {
1044
+ if (verb !== 'GET')
1045
+ throw panel('method_not_allowed', 'method not allowed');
1046
+ let parts;
1047
+ try {
1048
+ parts = artifactMatch.slice(1).map((part) => decodeURIComponent(part));
1049
+ }
1050
+ catch {
1051
+ throw panel('invalid', 'malformed percent-encoding in path');
1052
+ }
1053
+ const [runId = '', group = '', id = ''] = parts;
1054
+ const inline = url.searchParams.get('inline') === '1';
1055
+ const artifact = (await call('artifact', { runId, group, id }));
1056
+ const preview = artifactPreview(artifact.fileName);
1057
+ if (inline && preview === null) {
1058
+ throw panel('invalid', 'only .md and .log artifacts can be shown inline');
1059
+ }
1060
+ const bytes = Buffer.from(artifact.base64, 'base64');
1061
+ const headers = {
1062
+ 'Content-Length': bytes.length,
1063
+ 'X-Content-Type-Options': 'nosniff',
1064
+ 'Cache-Control': 'no-store',
1065
+ };
1066
+ if (inline) {
1067
+ headers['Content-Type'] = 'text/plain; charset=utf-8';
1068
+ }
1069
+ else {
1070
+ headers['Content-Type'] =
1071
+ preview === 'markdown'
1072
+ ? 'text/markdown; charset=utf-8'
1073
+ : preview === 'log'
1074
+ ? 'text/plain; charset=utf-8'
1075
+ : 'application/octet-stream';
1076
+ const ascii = artifact.fileName.replace(/[^A-Za-z0-9._-]/g, '_');
1077
+ headers['Content-Disposition'] =
1078
+ `attachment; filename="${ascii}"; filename*=UTF-8''${encodeURIComponent(artifact.fileName).replace(/['()*]/g, (c) => `%${c.charCodeAt(0).toString(16).toUpperCase()}`)}`;
1079
+ }
1080
+ response.writeHead(200, headers);
1081
+ response.end(bytes);
1082
+ return;
1083
+ }
1084
+ let wrongMethod = false;
1085
+ for (const route of routes) {
1086
+ const match = route.pattern.exec(url.pathname);
1087
+ if (!match)
1088
+ continue;
1089
+ if (route.method !== verb) {
1090
+ wrongMethod = true;
1091
+ continue;
1092
+ }
1093
+ let parts;
1094
+ try {
1095
+ parts = match.slice(1).map((part) => decodeURIComponent(part));
1096
+ }
1097
+ catch {
1098
+ throw panel('invalid', 'malformed percent-encoding in path');
1099
+ }
1100
+ let body = {};
1101
+ if (verb === 'POST' || verb === 'PUT')
1102
+ body = await readJson(incoming);
1103
+ else if (verb === 'DELETE') {
1104
+ const revision = url.searchParams.get('revision');
1105
+ const level = url.searchParams.get('level');
1106
+ if (level !== null && level !== 'project' && level !== 'global') {
1107
+ throw panel('invalid', 'level must be project or global');
1108
+ }
1109
+ body = { ...(revision ? { revision } : {}), ...(level ? { level } : {}) };
1110
+ }
1111
+ else if (/\/groups\/[^/]+$/.test(url.pathname)) {
1112
+ const tail = Number(url.searchParams.get('tail') ?? 40);
1113
+ if (!Number.isInteger(tail) || tail < 1 || tail > 500)
1114
+ throw panel('invalid', 'tail must be an integer from 1 to 500');
1115
+ body = { tail };
1116
+ }
1117
+ else if (url.pathname === '/api/finished-runs') {
1118
+ const limit = Number(url.searchParams.get('limit') ?? 15);
1119
+ if (!Number.isInteger(limit) || limit < 1 || limit > 100)
1120
+ throw panel('invalid', 'limit must be an integer from 1 to 100');
1121
+ const before = url.searchParams.get('before');
1122
+ body = { limit, ...(before ? { before } : {}) };
1123
+ }
1124
+ else if (url.pathname.endsWith('/transcript')) {
1125
+ body = transcriptQuery(url.searchParams);
1126
+ }
1127
+ else if (url.pathname.endsWith('/diff')) {
1128
+ const path = url.searchParams.get('path');
1129
+ if (path === null || path === '')
1130
+ throw panel('invalid', 'path is required');
1131
+ body = { path };
1132
+ }
1133
+ // Runs belong to the daemon, not to a repository: they work without one.
1134
+ // A returned run belongs to its own repository unless the request names one.
1135
+ const ownRepository = (url.pathname === '/api/queue/return' || url.pathname === '/api/queue/dismiss') &&
1136
+ !url.searchParams.get('repository');
1137
+ const repository = url.pathname.startsWith('/api/runs') ||
1138
+ url.pathname === '/api/finished-runs' ||
1139
+ url.pathname.startsWith('/api/processes') ||
1140
+ url.pathname.startsWith('/api/specialist-tags') ||
1141
+ url.pathname === '/api/observers' ||
1142
+ ownRepository
1143
+ ? ''
1144
+ : await requestRepository(url.searchParams);
1145
+ const result = await route.handle(parts, body, repository);
1146
+ if (result instanceof Reply)
1147
+ json(response, result.status, result.value);
1148
+ else
1149
+ json(response, 200, result);
1150
+ return;
1151
+ }
1152
+ if (wrongMethod)
1153
+ throw panel('method_not_allowed', 'method not allowed');
1154
+ throw panel('not_found', 'not found');
1155
+ }
1156
+ const server = createServer((incoming, response) => {
1157
+ handle(incoming, response).catch((error) => {
1158
+ if (response.headersSent) {
1159
+ response.end();
1160
+ return;
1161
+ }
1162
+ const rendered = renderPanelError(error);
1163
+ json(response, rendered.status, rendered.body);
1164
+ });
1165
+ });
1166
+ try {
1167
+ await new Promise((resolve, reject) => {
1168
+ server.once('error', reject);
1169
+ server.listen(port, host, () => resolve());
1170
+ });
1171
+ }
1172
+ catch (error) {
1173
+ hub.stop();
1174
+ throw error;
1175
+ }
1176
+ port = server.address().port;
1177
+ const shown = host.includes(':') ? `[${host}]` : host;
1178
+ return {
1179
+ server,
1180
+ token,
1181
+ host,
1182
+ port,
1183
+ url: `http://${shown}:${port}/${token === null ? '' : `?token=${token}`}`,
1184
+ close: () => new Promise((resolve) => {
1185
+ hub.stop();
1186
+ server.close(() => resolve());
1187
+ server.closeAllConnections();
1188
+ }),
1189
+ };
1190
+ }
1191
+ //# sourceMappingURL=server.js.map