@hoknie/aip 0.1.0 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (587) hide show
  1. package/dist/app/agents.js +2 -0
  2. package/dist/app/agents.js.map +1 -1
  3. package/dist/app/application.js +41 -3
  4. package/dist/app/application.js.map +1 -1
  5. package/dist/app/lifecycle.js +5 -1
  6. package/dist/app/lifecycle.js.map +1 -1
  7. package/dist/app/timings.js +1 -0
  8. package/dist/app/timings.js.map +1 -1
  9. package/dist/app/wiring.js +1 -0
  10. package/dist/app/wiring.js.map +1 -1
  11. package/dist/cli/main.js +0 -0
  12. package/dist/feature/agents/clients/agy/guard.js +26 -8
  13. package/dist/feature/agents/clients/agy/guard.js.map +1 -1
  14. package/dist/feature/agents/clients/agy/permissions.js +9 -1
  15. package/dist/feature/agents/clients/agy/permissions.js.map +1 -1
  16. package/dist/feature/agents/clients/agy/runtime.js +8 -1
  17. package/dist/feature/agents/clients/agy/runtime.js.map +1 -1
  18. package/dist/feature/agents/clients/claude/index.js +1 -0
  19. package/dist/feature/agents/clients/claude/index.js.map +1 -1
  20. package/dist/feature/agents/clients/claude/models.js +8 -0
  21. package/dist/feature/agents/clients/claude/models.js.map +1 -0
  22. package/dist/feature/agents/clients/claude/parser.js +8 -0
  23. package/dist/feature/agents/clients/claude/parser.js.map +1 -1
  24. package/dist/feature/agents/clients/claude/runtime.js +2 -0
  25. package/dist/feature/agents/clients/claude/runtime.js.map +1 -1
  26. package/dist/feature/agents/clients/opencode/index.js +1 -0
  27. package/dist/feature/agents/clients/opencode/index.js.map +1 -1
  28. package/dist/feature/agents/clients/opencode/models.js +38 -0
  29. package/dist/feature/agents/clients/opencode/models.js.map +1 -0
  30. package/dist/feature/agents/clients/opencode/runtime.js +14 -1
  31. package/dist/feature/agents/clients/opencode/runtime.js.map +1 -1
  32. package/dist/feature/agents/ports/command.js +2 -0
  33. package/dist/feature/agents/ports/command.js.map +1 -0
  34. package/dist/feature/agents/services/agents.js +42 -1
  35. package/dist/feature/agents/services/agents.js.map +1 -1
  36. package/dist/feature/agents/services/catalog.js +1 -1
  37. package/dist/feature/agents/services/catalog.js.map +1 -1
  38. package/dist/feature/agents/types/index.js +2 -0
  39. package/dist/feature/agents/types/index.js.map +1 -1
  40. package/dist/feature/agents/types/mcp/env.js +54 -0
  41. package/dist/feature/agents/types/mcp/env.js.map +1 -0
  42. package/dist/feature/agents/types/message.js +1 -0
  43. package/dist/feature/agents/types/message.js.map +1 -1
  44. package/dist/feature/agents/types/models.js +2 -0
  45. package/dist/feature/agents/types/models.js.map +1 -0
  46. package/dist/feature/agents/types/runtime.js.map +1 -1
  47. package/dist/feature/agents/types/worker-tools.js +2 -0
  48. package/dist/feature/agents/types/worker-tools.js.map +1 -1
  49. package/dist/feature/network/ports/changed.js +2 -0
  50. package/dist/feature/network/ports/changed.js.map +1 -0
  51. package/dist/feature/network/ports/index.js +2 -0
  52. package/dist/feature/network/ports/index.js.map +1 -0
  53. package/dist/feature/network/services/create.js +5 -0
  54. package/dist/feature/network/services/create.js.map +1 -0
  55. package/dist/feature/network/services/index.js +3 -0
  56. package/dist/feature/network/services/index.js.map +1 -0
  57. package/dist/feature/network/services/monitor.js +140 -0
  58. package/dist/feature/network/services/monitor.js.map +1 -0
  59. package/dist/feature/network/types/index.js +4 -0
  60. package/dist/feature/network/types/index.js.map +1 -0
  61. package/dist/feature/network/types/network.js +8 -0
  62. package/dist/feature/network/types/network.js.map +1 -0
  63. package/dist/feature/network/types/proxy.js +95 -0
  64. package/dist/feature/network/types/proxy.js.map +1 -0
  65. package/dist/feature/network/types/state.js +36 -0
  66. package/dist/feature/network/types/state.js.map +1 -0
  67. package/dist/feature/observers/repositories/observers.js +7 -1
  68. package/dist/feature/observers/repositories/observers.js.map +1 -1
  69. package/dist/feature/observers/services/observers.js +33 -5
  70. package/dist/feature/observers/services/observers.js.map +1 -1
  71. package/dist/feature/observers/services/settings-check.js +1 -7
  72. package/dist/feature/observers/services/settings-check.js.map +1 -1
  73. package/dist/feature/observers/types/plan-repairs.js +48 -16
  74. package/dist/feature/observers/types/plan-repairs.js.map +1 -1
  75. package/dist/feature/observers/types/settings.js +0 -1
  76. package/dist/feature/observers/types/settings.js.map +1 -1
  77. package/dist/feature/queue/repositories/queues.js +28 -4
  78. package/dist/feature/queue/repositories/queues.js.map +1 -1
  79. package/dist/feature/queue/services/control.js +46 -8
  80. package/dist/feature/queue/services/control.js.map +1 -1
  81. package/dist/feature/queue/services/store.js +4 -0
  82. package/dist/feature/queue/services/store.js.map +1 -1
  83. package/dist/feature/queue/services/task-tags.js +4 -1
  84. package/dist/feature/queue/services/task-tags.js.map +1 -1
  85. package/dist/feature/queue/types/advance.js +29 -12
  86. package/dist/feature/queue/types/advance.js.map +1 -1
  87. package/dist/feature/queue/types/filter.js +36 -0
  88. package/dist/feature/queue/types/filter.js.map +1 -0
  89. package/dist/feature/queue/types/index.js +1 -0
  90. package/dist/feature/queue/types/index.js.map +1 -1
  91. package/dist/feature/queue/types/items.js +1 -0
  92. package/dist/feature/queue/types/items.js.map +1 -1
  93. package/dist/feature/queue/types/returns.js +18 -3
  94. package/dist/feature/queue/types/returns.js.map +1 -1
  95. package/dist/feature/queue/types/settings.js +14 -3
  96. package/dist/feature/queue/types/settings.js.map +1 -1
  97. package/dist/feature/runs/machine/exits.js +23 -1
  98. package/dist/feature/runs/machine/exits.js.map +1 -1
  99. package/dist/feature/runs/machine/plan.js +38 -16
  100. package/dist/feature/runs/machine/plan.js.map +1 -1
  101. package/dist/feature/runs/machine/repair.js +10 -3
  102. package/dist/feature/runs/machine/repair.js.map +1 -1
  103. package/dist/feature/runs/machine/scheduler.js +10 -3
  104. package/dist/feature/runs/machine/scheduler.js.map +1 -1
  105. package/dist/feature/runs/machine/steps.js +11 -11
  106. package/dist/feature/runs/machine/steps.js.map +1 -1
  107. package/dist/feature/runs/machine/transition.js +16 -2
  108. package/dist/feature/runs/machine/transition.js.map +1 -1
  109. package/dist/feature/runs/repositories/finished-runs.js +14 -10
  110. package/dist/feature/runs/repositories/finished-runs.js.map +1 -1
  111. package/dist/feature/runs/repositories/write.js +1 -1
  112. package/dist/feature/runs/repositories/write.js.map +1 -1
  113. package/dist/feature/runs/services/create.js +1 -0
  114. package/dist/feature/runs/services/create.js.map +1 -1
  115. package/dist/feature/runs/services/effects/actions.js +3 -2
  116. package/dist/feature/runs/services/effects/actions.js.map +1 -1
  117. package/dist/feature/runs/services/effects/attempts.js +61 -13
  118. package/dist/feature/runs/services/effects/attempts.js.map +1 -1
  119. package/dist/feature/runs/services/effects/context.js.map +1 -1
  120. package/dist/feature/runs/services/effects/effects.js +5 -0
  121. package/dist/feature/runs/services/effects/effects.js.map +1 -1
  122. package/dist/feature/runs/services/effects/naming.js +4 -1
  123. package/dist/feature/runs/services/effects/naming.js.map +1 -1
  124. package/dist/feature/runs/services/effects/proxy.js +5 -0
  125. package/dist/feature/runs/services/effects/proxy.js.map +1 -0
  126. package/dist/feature/runs/services/effects/runtime-check.js +20 -0
  127. package/dist/feature/runs/services/effects/runtime-check.js.map +1 -0
  128. package/dist/feature/runs/services/engine.js +14 -5
  129. package/dist/feature/runs/services/engine.js.map +1 -1
  130. package/dist/feature/runs/services/index.js.map +1 -1
  131. package/dist/feature/runs/services/reads.js +40 -1
  132. package/dist/feature/runs/services/reads.js.map +1 -1
  133. package/dist/feature/runs/services/requests.js +7 -1
  134. package/dist/feature/runs/services/requests.js.map +1 -1
  135. package/dist/feature/runs/services/states.js +2 -2
  136. package/dist/feature/runs/services/states.js.map +1 -1
  137. package/dist/feature/runs/types/attempt.js +8 -0
  138. package/dist/feature/runs/types/attempt.js.map +1 -1
  139. package/dist/feature/runs/types/group.js.map +1 -1
  140. package/dist/feature/runs/types/input.js +33 -0
  141. package/dist/feature/runs/types/input.js.map +1 -1
  142. package/dist/feature/runs/types/limits.js +13 -1
  143. package/dist/feature/runs/types/limits.js.map +1 -1
  144. package/dist/feature/stats/repositories/index.js +4 -0
  145. package/dist/feature/stats/repositories/index.js.map +1 -0
  146. package/dist/feature/stats/repositories/meta.js +19 -0
  147. package/dist/feature/stats/repositories/meta.js.map +1 -0
  148. package/dist/feature/stats/repositories/records.js +46 -0
  149. package/dist/feature/stats/repositories/records.js.map +1 -0
  150. package/dist/feature/stats/repositories/report.js +105 -0
  151. package/dist/feature/stats/repositories/report.js.map +1 -0
  152. package/dist/feature/stats/services/create.js +44 -0
  153. package/dist/feature/stats/services/create.js.map +1 -0
  154. package/dist/feature/stats/services/index.js +4 -0
  155. package/dist/feature/stats/services/index.js.map +1 -0
  156. package/dist/feature/stats/services/ledger.js +137 -0
  157. package/dist/feature/stats/services/ledger.js.map +1 -0
  158. package/dist/feature/stats/services/report.js +56 -0
  159. package/dist/feature/stats/services/report.js.map +1 -0
  160. package/dist/feature/stats/types/aggregate.js +179 -0
  161. package/dist/feature/stats/types/aggregate.js.map +1 -0
  162. package/dist/feature/stats/types/capture.js +79 -0
  163. package/dist/feature/stats/types/capture.js.map +1 -0
  164. package/dist/feature/stats/types/index.js +6 -0
  165. package/dist/feature/stats/types/index.js.map +1 -0
  166. package/dist/feature/stats/types/records.js +5 -0
  167. package/dist/feature/stats/types/records.js.map +1 -0
  168. package/dist/feature/stats/types/report.js +25 -0
  169. package/dist/feature/stats/types/report.js.map +1 -0
  170. package/dist/feature/stats/types/settings.js +2 -0
  171. package/dist/feature/stats/types/settings.js.map +1 -0
  172. package/dist/feature/swarm-config/services/assemble.js +1 -1
  173. package/dist/feature/swarm-config/services/assemble.js.map +1 -1
  174. package/dist/feature/swarm-config/services/index.js +4 -2
  175. package/dist/feature/swarm-config/services/index.js.map +1 -1
  176. package/dist/feature/swarm-config/services/load.js +17 -2
  177. package/dist/feature/swarm-config/services/load.js.map +1 -1
  178. package/dist/feature/swarm-config/services/sections/mcp-servers.js +128 -0
  179. package/dist/feature/swarm-config/services/sections/mcp-servers.js.map +1 -0
  180. package/dist/feature/swarm-config/services/sections/stats.js +28 -0
  181. package/dist/feature/swarm-config/services/sections/stats.js.map +1 -0
  182. package/dist/feature/swarm-config/services/settings.js +23 -1
  183. package/dist/feature/swarm-config/services/settings.js.map +1 -1
  184. package/dist/feature/swarm-config/services/validate-actions.js +9 -1
  185. package/dist/feature/swarm-config/services/validate-actions.js.map +1 -1
  186. package/dist/feature/swarm-config/services/validate-runtimes.js +3 -51
  187. package/dist/feature/swarm-config/services/validate-runtimes.js.map +1 -1
  188. package/dist/feature/swarm-config/services/validate-settings.js +65 -0
  189. package/dist/feature/swarm-config/services/validate-settings.js.map +1 -1
  190. package/dist/feature/swarm-config/services/validate-specialists.js +5 -4
  191. package/dist/feature/swarm-config/services/validate-specialists.js.map +1 -1
  192. package/dist/feature/swarm-config/services/validate.js +24 -8
  193. package/dist/feature/swarm-config/services/validate.js.map +1 -1
  194. package/dist/feature/swarm-config/types/action.js +9 -0
  195. package/dist/feature/swarm-config/types/action.js.map +1 -1
  196. package/dist/feature/swarm-config/types/index.js +1 -0
  197. package/dist/feature/swarm-config/types/index.js.map +1 -1
  198. package/dist/feature/swarm-config/types/mcp/reference.js +40 -0
  199. package/dist/feature/swarm-config/types/mcp/reference.js.map +1 -0
  200. package/dist/feature/swarm-config/types/merge.js +1 -0
  201. package/dist/feature/swarm-config/types/merge.js.map +1 -1
  202. package/dist/feature/swarm-config/types/settings.js +37 -5
  203. package/dist/feature/swarm-config/types/settings.js.map +1 -1
  204. package/dist/feature/swarm-config/types/specialist.js.map +1 -1
  205. package/dist/feature/swarm-edit/services/config-edits.js +26 -1
  206. package/dist/feature/swarm-edit/services/config-edits.js.map +1 -1
  207. package/dist/feature/swarm-edit/services/editor-settings.js +36 -7
  208. package/dist/feature/swarm-edit/services/editor-settings.js.map +1 -1
  209. package/dist/feature/swarm-edit/services/editor-view.js +2 -0
  210. package/dist/feature/swarm-edit/services/editor-view.js.map +1 -1
  211. package/dist/feature/swarm-edit/services/index.js +1 -0
  212. package/dist/feature/swarm-edit/services/index.js.map +1 -1
  213. package/dist/feature/swarm-edit/services/mcp/editor-mcp.js +51 -0
  214. package/dist/feature/swarm-edit/services/mcp/editor-mcp.js.map +1 -0
  215. package/dist/feature/swarm-edit/services/mcp/plan-mcp-server.js +93 -0
  216. package/dist/feature/swarm-edit/services/mcp/plan-mcp-server.js.map +1 -0
  217. package/dist/feature/swarm-edit/services/plan-settings.js +3 -1
  218. package/dist/feature/swarm-edit/services/plan-settings.js.map +1 -1
  219. package/dist/feature/swarm-edit/types/editor.js.map +1 -1
  220. package/dist/feature/swarm-edit/types/setting-fields.js +12 -0
  221. package/dist/feature/swarm-edit/types/setting-fields.js.map +1 -1
  222. package/dist/platform/git/delivery.js +1 -1
  223. package/dist/platform/git/delivery.js.map +1 -1
  224. package/dist/platform/network/index.js +4 -0
  225. package/dist/platform/network/index.js.map +1 -0
  226. package/dist/platform/network/interfaces.js +7 -0
  227. package/dist/platform/network/interfaces.js.map +1 -0
  228. package/dist/platform/network/probe.js +128 -0
  229. package/dist/platform/network/probe.js.map +1 -0
  230. package/dist/platform/network/tunnel.js +87 -0
  231. package/dist/platform/network/tunnel.js.map +1 -0
  232. package/dist/platform/process/command.js +23 -0
  233. package/dist/platform/process/command.js.map +1 -0
  234. package/dist/platform/process/index.js +1 -0
  235. package/dist/platform/process/index.js.map +1 -1
  236. package/dist/platform/sqlite/migrations.js +3 -0
  237. package/dist/platform/sqlite/migrations.js.map +1 -1
  238. package/dist/platform/sqlite/stats-migration.js +42 -0
  239. package/dist/platform/sqlite/stats-migration.js.map +1 -0
  240. package/dist/presentation/cli/commands/queue-edit.js +23 -1
  241. package/dist/presentation/cli/commands/queue-edit.js.map +1 -1
  242. package/dist/presentation/cli/commands/stats.js +41 -0
  243. package/dist/presentation/cli/commands/stats.js.map +1 -0
  244. package/dist/presentation/cli/help.js +1 -1
  245. package/dist/presentation/cli/help.js.map +1 -1
  246. package/dist/presentation/cli/local/config-check.js +23 -5
  247. package/dist/presentation/cli/local/config-check.js.map +1 -1
  248. package/dist/presentation/cli/program.js +2 -0
  249. package/dist/presentation/cli/program.js.map +1 -1
  250. package/dist/presentation/format/index.js +1 -0
  251. package/dist/presentation/format/index.js.map +1 -1
  252. package/dist/presentation/format/queue.js +15 -2
  253. package/dist/presentation/format/queue.js.map +1 -1
  254. package/dist/presentation/format/runs.js +8 -1
  255. package/dist/presentation/format/runs.js.map +1 -1
  256. package/dist/presentation/format/stats.js +79 -0
  257. package/dist/presentation/format/stats.js.map +1 -0
  258. package/dist/presentation/ipc/contract/agents.js +18 -0
  259. package/dist/presentation/ipc/contract/agents.js.map +1 -1
  260. package/dist/presentation/ipc/contract/config.js +26 -0
  261. package/dist/presentation/ipc/contract/config.js.map +1 -1
  262. package/dist/presentation/ipc/contract/envelope.js +4 -1
  263. package/dist/presentation/ipc/contract/envelope.js.map +1 -1
  264. package/dist/presentation/ipc/contract/groups.js +9 -0
  265. package/dist/presentation/ipc/contract/groups.js.map +1 -1
  266. package/dist/presentation/ipc/contract/index.js +1 -0
  267. package/dist/presentation/ipc/contract/index.js.map +1 -1
  268. package/dist/presentation/ipc/contract/panel.js +11 -0
  269. package/dist/presentation/ipc/contract/panel.js.map +1 -1
  270. package/dist/presentation/ipc/contract/queue.js +11 -1
  271. package/dist/presentation/ipc/contract/queue.js.map +1 -1
  272. package/dist/presentation/ipc/contract/responses/index.js +1 -0
  273. package/dist/presentation/ipc/contract/responses/index.js.map +1 -1
  274. package/dist/presentation/ipc/contract/responses/stats.js +67 -0
  275. package/dist/presentation/ipc/contract/responses/stats.js.map +1 -0
  276. package/dist/presentation/ipc/contract/runs.js +10 -0
  277. package/dist/presentation/ipc/contract/runs.js.map +1 -1
  278. package/dist/presentation/ipc/contract/stats/stats.js +20 -0
  279. package/dist/presentation/ipc/contract/stats/stats.js.map +1 -0
  280. package/dist/presentation/ipc/handlers/config.js +7 -0
  281. package/dist/presentation/ipc/handlers/config.js.map +1 -1
  282. package/dist/presentation/ipc/handlers/groups.js +8 -0
  283. package/dist/presentation/ipc/handlers/groups.js.map +1 -1
  284. package/dist/presentation/ipc/handlers/runs.js +2 -1
  285. package/dist/presentation/ipc/handlers/runs.js.map +1 -1
  286. package/dist/presentation/ipc/handlers/stats.js +17 -0
  287. package/dist/presentation/ipc/handlers/stats.js.map +1 -0
  288. package/dist/presentation/ipc/handlers/system.js +2 -0
  289. package/dist/presentation/ipc/handlers/system.js.map +1 -1
  290. package/dist/presentation/ipc/handlers/table.js +2 -0
  291. package/dist/presentation/ipc/handlers/table.js.map +1 -1
  292. package/dist/presentation/ipc/publisher.js +1 -0
  293. package/dist/presentation/ipc/publisher.js.map +1 -1
  294. package/dist/presentation/ipc/snapshots.js +2 -2
  295. package/dist/presentation/ipc/snapshots.js.map +1 -1
  296. package/dist/presentation/ipc/views/catalog.js +3 -3
  297. package/dist/presentation/ipc/views/catalog.js.map +1 -1
  298. package/dist/presentation/ipc/views/index.js +1 -0
  299. package/dist/presentation/ipc/views/index.js.map +1 -1
  300. package/dist/presentation/ipc/views/observers.js +2 -2
  301. package/dist/presentation/ipc/views/observers.js.map +1 -1
  302. package/dist/presentation/ipc/views/queue.js +9 -2
  303. package/dist/presentation/ipc/views/queue.js.map +1 -1
  304. package/dist/presentation/ipc/views/runs.js +3 -4
  305. package/dist/presentation/ipc/views/runs.js.map +1 -1
  306. package/dist/presentation/ipc/views/stats.js +5 -0
  307. package/dist/presentation/ipc/views/stats.js.map +1 -0
  308. package/dist/presentation/mcp/host-queue-control.js +11 -2
  309. package/dist/presentation/mcp/host-queue-control.js.map +1 -1
  310. package/dist/presentation/mcp/worker-extra.js +2 -2
  311. package/dist/presentation/mcp/worker-extra.js.map +1 -1
  312. package/dist/presentation/mcp/worker-read.js +45 -0
  313. package/dist/presentation/mcp/worker-read.js.map +1 -0
  314. package/dist/presentation/mcp/worker.js +2 -0
  315. package/dist/presentation/mcp/worker.js.map +1 -1
  316. package/dist/presentation/web/hub.js +4 -0
  317. package/dist/presentation/web/hub.js.map +1 -1
  318. package/dist/presentation/web/panel/directories.js +1 -1
  319. package/dist/presentation/web/panel/directories.js.map +1 -1
  320. package/dist/presentation/web/panel/system.js +1 -0
  321. package/dist/presentation/web/panel/system.js.map +1 -1
  322. package/dist/presentation/web/request.js +28 -1
  323. package/dist/presentation/web/request.js.map +1 -1
  324. package/dist/presentation/web/routes/catalog/mcp-servers.js +50 -0
  325. package/dist/presentation/web/routes/catalog/mcp-servers.js.map +1 -0
  326. package/dist/presentation/web/routes/config.js +5 -0
  327. package/dist/presentation/web/routes/config.js.map +1 -1
  328. package/dist/presentation/web/routes/runs.js +5 -0
  329. package/dist/presentation/web/routes/runs.js.map +1 -1
  330. package/dist/presentation/web/routes/stats/stats.js +22 -0
  331. package/dist/presentation/web/routes/stats/stats.js.map +1 -0
  332. package/dist/presentation/web/server.js +5 -1
  333. package/dist/presentation/web/server.js.map +1 -1
  334. package/dist/web/assets/FilterColumn-BrQWIM5F.js +1 -0
  335. package/dist/web/assets/SharedPipelinesGroup-WFngQrqI.js +1 -0
  336. package/dist/web/assets/badge-B_khFsd6.js +1 -0
  337. package/dist/web/assets/{card-DkikoTxR.js → card-COXjnc-y.js} +1 -1
  338. package/dist/web/assets/empty-Eb-EZDPX.js +41 -0
  339. package/dist/web/assets/index-DEXoIe2a.js +21 -0
  340. package/dist/web/assets/index-DMlIe0VD.css +2 -0
  341. package/dist/web/assets/locales-BlBJo1PR.js +1 -0
  342. package/dist/web/assets/pipelines-B3cdeex_.js +10 -0
  343. package/dist/web/assets/queue-HMUImu0E.js +16 -0
  344. package/dist/web/assets/select-MHus_Unr.js +1 -0
  345. package/dist/web/assets/settingFields-DVg9TQK2.js +1 -0
  346. package/dist/web/assets/settings-CpeEsUXX.js +6 -0
  347. package/dist/web/assets/skeleton-CWY1nRvW.js +1 -0
  348. package/dist/web/assets/specialists-BkLXuqUd.js +1 -0
  349. package/dist/web/assets/stats-DRg_5vll.js +1 -0
  350. package/dist/web/assets/topology-DGTNdDHf.js +1 -0
  351. package/dist/web/assets/trash-CFJeuRuc.js +1 -0
  352. package/dist/web/assets/useListDrag-B7Wlt2u9.js +1 -0
  353. package/dist/web/index.html +7 -6
  354. package/integrations/claude-code/.claude-plugin/plugin.json +1 -1
  355. package/package.json +1 -1
  356. package/dist/cli/clean.js +0 -71
  357. package/dist/cli/clean.js.map +0 -1
  358. package/dist/cli/commands.js +0 -963
  359. package/dist/cli/commands.js.map +0 -1
  360. package/dist/cli/config-check.js +0 -173
  361. package/dist/cli/config-check.js.map +0 -1
  362. package/dist/cli/daemon.js +0 -199
  363. package/dist/cli/daemon.js.map +0 -1
  364. package/dist/cli/help.js +0 -50
  365. package/dist/cli/help.js.map +0 -1
  366. package/dist/cli/init.js +0 -43
  367. package/dist/cli/init.js.map +0 -1
  368. package/dist/cli/io.js +0 -13
  369. package/dist/cli/io.js.map +0 -1
  370. package/dist/cli/probe.js +0 -12
  371. package/dist/cli/probe.js.map +0 -1
  372. package/dist/cli/program.js +0 -48
  373. package/dist/cli/program.js.map +0 -1
  374. package/dist/cli/setup.js +0 -406
  375. package/dist/cli/setup.js.map +0 -1
  376. package/dist/cli/version.js +0 -6
  377. package/dist/cli/version.js.map +0 -1
  378. package/dist/cli/watch.js +0 -24
  379. package/dist/cli/watch.js.map +0 -1
  380. package/dist/cli/web/daemon-panel.js +0 -185
  381. package/dist/cli/web/daemon-panel.js.map +0 -1
  382. package/dist/cli/web/default-repository.js +0 -12
  383. package/dist/cli/web/default-repository.js.map +0 -1
  384. package/dist/cli/web/errors.js +0 -60
  385. package/dist/cli/web/errors.js.map +0 -1
  386. package/dist/cli/web/open.js +0 -12
  387. package/dist/cli/web/open.js.map +0 -1
  388. package/dist/cli/web/page.js +0 -465
  389. package/dist/cli/web/page.js.map +0 -1
  390. package/dist/cli/web/server.js +0 -1191
  391. package/dist/cli/web/server.js.map +0 -1
  392. package/dist/cli/web/standby.js +0 -119
  393. package/dist/cli/web/standby.js.map +0 -1
  394. package/dist/cli/web/state.js +0 -69
  395. package/dist/cli/web/state.js.map +0 -1
  396. package/dist/cli/web/system.js +0 -66
  397. package/dist/cli/web/system.js.map +0 -1
  398. package/dist/cli/web-control.js +0 -173
  399. package/dist/cli/web-control.js.map +0 -1
  400. package/dist/config/discover.js +0 -25
  401. package/dist/config/discover.js.map +0 -1
  402. package/dist/config/duration.js +0 -17
  403. package/dist/config/duration.js.map +0 -1
  404. package/dist/config/edit.js +0 -966
  405. package/dist/config/edit.js.map +0 -1
  406. package/dist/config/errors.js +0 -29
  407. package/dist/config/errors.js.map +0 -1
  408. package/dist/config/index.js +0 -14
  409. package/dist/config/index.js.map +0 -1
  410. package/dist/config/load.js +0 -412
  411. package/dist/config/load.js.map +0 -1
  412. package/dist/config/merge.js +0 -45
  413. package/dist/config/merge.js.map +0 -1
  414. package/dist/config/model.js +0 -171
  415. package/dist/config/model.js.map +0 -1
  416. package/dist/config/paths.js +0 -31
  417. package/dist/config/paths.js.map +0 -1
  418. package/dist/config/prompt.js +0 -33
  419. package/dist/config/prompt.js.map +0 -1
  420. package/dist/config/shared-pipelines.js +0 -71
  421. package/dist/config/shared-pipelines.js.map +0 -1
  422. package/dist/config/shared-specialists.js +0 -68
  423. package/dist/config/shared-specialists.js.map +0 -1
  424. package/dist/config/shared-workflows.js +0 -71
  425. package/dist/config/shared-workflows.js.map +0 -1
  426. package/dist/config/specialist-tags.js +0 -214
  427. package/dist/config/specialist-tags.js.map +0 -1
  428. package/dist/config/tag-names.js +0 -43
  429. package/dist/config/tag-names.js.map +0 -1
  430. package/dist/config/validate.js +0 -872
  431. package/dist/config/validate.js.map +0 -1
  432. package/dist/core/artifacts.js +0 -37
  433. package/dist/core/artifacts.js.map +0 -1
  434. package/dist/core/create.js +0 -75
  435. package/dist/core/create.js.map +0 -1
  436. package/dist/core/delivery.js +0 -366
  437. package/dist/core/delivery.js.map +0 -1
  438. package/dist/core/errors.js +0 -7
  439. package/dist/core/errors.js.map +0 -1
  440. package/dist/core/ids.js +0 -99
  441. package/dist/core/ids.js.map +0 -1
  442. package/dist/core/index.js +0 -21
  443. package/dist/core/index.js.map +0 -1
  444. package/dist/core/input.js +0 -45
  445. package/dist/core/input.js.map +0 -1
  446. package/dist/core/machine.js +0 -1021
  447. package/dist/core/machine.js.map +0 -1
  448. package/dist/core/model.js +0 -460
  449. package/dist/core/model.js.map +0 -1
  450. package/dist/core/observer.js +0 -193
  451. package/dist/core/observer.js.map +0 -1
  452. package/dist/core/occupancy.js +0 -63
  453. package/dist/core/occupancy.js.map +0 -1
  454. package/dist/core/permissions.js +0 -222
  455. package/dist/core/permissions.js.map +0 -1
  456. package/dist/core/plan.js +0 -99
  457. package/dist/core/plan.js.map +0 -1
  458. package/dist/core/progress.js +0 -43
  459. package/dist/core/progress.js.map +0 -1
  460. package/dist/core/questions.js +0 -19
  461. package/dist/core/questions.js.map +0 -1
  462. package/dist/core/queue.js +0 -859
  463. package/dist/core/queue.js.map +0 -1
  464. package/dist/core/retryable.js +0 -8
  465. package/dist/core/retryable.js.map +0 -1
  466. package/dist/core/scheduler.js +0 -160
  467. package/dist/core/scheduler.js.map +0 -1
  468. package/dist/core/skip.js +0 -109
  469. package/dist/core/skip.js.map +0 -1
  470. package/dist/core/stages.js +0 -304
  471. package/dist/core/stages.js.map +0 -1
  472. package/dist/core/summary.js +0 -35
  473. package/dist/core/summary.js.map +0 -1
  474. package/dist/core/tags.js +0 -184
  475. package/dist/core/tags.js.map +0 -1
  476. package/dist/core/topology.js +0 -162
  477. package/dist/core/topology.js.map +0 -1
  478. package/dist/daemon/artifacts.js +0 -84
  479. package/dist/daemon/artifacts.js.map +0 -1
  480. package/dist/daemon/daemon.js +0 -1442
  481. package/dist/daemon/daemon.js.map +0 -1
  482. package/dist/daemon/executor.js +0 -749
  483. package/dist/daemon/executor.js.map +0 -1
  484. package/dist/daemon/helpers.js +0 -38
  485. package/dist/daemon/helpers.js.map +0 -1
  486. package/dist/daemon/index.js +0 -4
  487. package/dist/daemon/index.js.map +0 -1
  488. package/dist/daemon/logs.js +0 -69
  489. package/dist/daemon/logs.js.map +0 -1
  490. package/dist/daemon/observers.js +0 -93
  491. package/dist/daemon/observers.js.map +0 -1
  492. package/dist/daemon/patches.js +0 -76
  493. package/dist/daemon/patches.js.map +0 -1
  494. package/dist/daemon/ports.js +0 -2
  495. package/dist/daemon/ports.js.map +0 -1
  496. package/dist/daemon/processes.js +0 -98
  497. package/dist/daemon/processes.js.map +0 -1
  498. package/dist/daemon/repositories.js +0 -2
  499. package/dist/daemon/repositories.js.map +0 -1
  500. package/dist/daemon/server.js +0 -164
  501. package/dist/daemon/server.js.map +0 -1
  502. package/dist/daemon/supervisor.js +0 -140
  503. package/dist/daemon/supervisor.js.map +0 -1
  504. package/dist/daemon/timings.js +0 -23
  505. package/dist/daemon/timings.js.map +0 -1
  506. package/dist/git/delivery.js +0 -284
  507. package/dist/git/delivery.js.map +0 -1
  508. package/dist/git/index.js +0 -4
  509. package/dist/git/index.js.map +0 -1
  510. package/dist/git/runner.js +0 -60
  511. package/dist/git/runner.js.map +0 -1
  512. package/dist/git/workspace.js +0 -366
  513. package/dist/git/workspace.js.map +0 -1
  514. package/dist/mcp/host.js +0 -401
  515. package/dist/mcp/host.js.map +0 -1
  516. package/dist/mcp/index.js +0 -3
  517. package/dist/mcp/index.js.map +0 -1
  518. package/dist/mcp/tools.js +0 -19
  519. package/dist/mcp/tools.js.map +0 -1
  520. package/dist/mcp/version.js +0 -5
  521. package/dist/mcp/version.js.map +0 -1
  522. package/dist/mcp/worker.js +0 -230
  523. package/dist/mcp/worker.js.map +0 -1
  524. package/dist/presentation/web/routes/directories.js +0 -60
  525. package/dist/presentation/web/routes/directories.js.map +0 -1
  526. package/dist/protocol/autostart.js +0 -171
  527. package/dist/protocol/autostart.js.map +0 -1
  528. package/dist/protocol/build.js +0 -38
  529. package/dist/protocol/build.js.map +0 -1
  530. package/dist/protocol/catalog.js +0 -18
  531. package/dist/protocol/catalog.js.map +0 -1
  532. package/dist/protocol/client.js +0 -83
  533. package/dist/protocol/client.js.map +0 -1
  534. package/dist/protocol/format.js +0 -477
  535. package/dist/protocol/format.js.map +0 -1
  536. package/dist/protocol/index.js +0 -11
  537. package/dist/protocol/index.js.map +0 -1
  538. package/dist/protocol/messages.js +0 -598
  539. package/dist/protocol/messages.js.map +0 -1
  540. package/dist/protocol/style.js +0 -81
  541. package/dist/protocol/style.js.map +0 -1
  542. package/dist/protocol/transcript.js +0 -49
  543. package/dist/protocol/transcript.js.map +0 -1
  544. package/dist/protocol/views.js +0 -696
  545. package/dist/protocol/views.js.map +0 -1
  546. package/dist/runtime/catalog.js +0 -117
  547. package/dist/runtime/catalog.js.map +0 -1
  548. package/dist/runtime/claude.js +0 -399
  549. package/dist/runtime/claude.js.map +0 -1
  550. package/dist/runtime/index.js +0 -34
  551. package/dist/runtime/index.js.map +0 -1
  552. package/dist/runtime/message.js +0 -48
  553. package/dist/runtime/message.js.map +0 -1
  554. package/dist/runtime/naming.js +0 -69
  555. package/dist/runtime/naming.js.map +0 -1
  556. package/dist/runtime/opencode.js +0 -189
  557. package/dist/runtime/opencode.js.map +0 -1
  558. package/dist/runtime/skills.js +0 -17
  559. package/dist/runtime/skills.js.map +0 -1
  560. package/dist/runtime/transcript.js +0 -227
  561. package/dist/runtime/transcript.js.map +0 -1
  562. package/dist/runtime/types.js +0 -12
  563. package/dist/runtime/types.js.map +0 -1
  564. package/dist/runtime/which.js +0 -21
  565. package/dist/runtime/which.js.map +0 -1
  566. package/dist/store/index.js +0 -3
  567. package/dist/store/index.js.map +0 -1
  568. package/dist/store/schema.js +0 -286
  569. package/dist/store/schema.js.map +0 -1
  570. package/dist/store/store.js +0 -491
  571. package/dist/store/store.js.map +0 -1
  572. package/dist/web/assets/EntryList-CnfGgjEY.js +0 -1
  573. package/dist/web/assets/FilePath-C0X8-keS.js +0 -1
  574. package/dist/web/assets/SettingsForm-BcyBWJbn.js +0 -1
  575. package/dist/web/assets/SharedPipelinesGroup-a368-IQ0.js +0 -1
  576. package/dist/web/assets/index-B-oJ93zH.js +0 -22
  577. package/dist/web/assets/index-BZE36gYR.css +0 -2
  578. package/dist/web/assets/locales-DtRrxYzg.js +0 -1
  579. package/dist/web/assets/pipelines-D48ggDNe.js +0 -1
  580. package/dist/web/assets/queue-D8_RY4IY.js +0 -16
  581. package/dist/web/assets/select-J4oIrmYh.js +0 -1
  582. package/dist/web/assets/settings-B0-0Vaia.js +0 -2
  583. package/dist/web/assets/skeleton-CCKCQF5n.js +0 -1
  584. package/dist/web/assets/specialists-DH8tyluO.js +0 -1
  585. package/dist/web/assets/switch-CWFAgxG1.js +0 -41
  586. package/dist/web/assets/topology-CNQ28AB2.js +0 -7
  587. /package/dist/web/assets/{topology-DLioOiRN.css → pipelines-DLioOiRN.css} +0 -0
@@ -1,164 +0,0 @@
1
- import { errorMessage } from '../platform/errors/index.js';
2
- import { chmodSync, existsSync, readFileSync, renameSync, rmSync, statSync, } from 'node:fs';
3
- import { createServer } from 'node:net';
4
- import { parseRequest } from '../presentation/ipc/contract/index.js';
5
- const SUBSCRIBER_BUFFER_LIMIT = 4 * 1024 * 1024;
6
- /** How often the daemon checks that its socket file and its lock are still in place. */
7
- export const SOCKET_CHECK_MS = 5_000;
8
- /** The file at `path` is the socket the daemon listens on (not removed, not replaced). */
9
- function sameFile(path, own) {
10
- try {
11
- const current = statSync(path);
12
- return current.dev === own.dev && current.ino === own.ino;
13
- }
14
- catch {
15
- return false;
16
- }
17
- }
18
- /** The lock at `path` holds the pid of this process. */
19
- function ownLock(path) {
20
- try {
21
- return readFileSync(path, 'utf8').trim() === String(process.pid);
22
- }
23
- catch {
24
- return false;
25
- }
26
- }
27
- async function answer(daemon, line) {
28
- const parsed = parseRequest(line);
29
- if ('error' in parsed)
30
- return { id: parsed.id, ok: false, error: parsed.error };
31
- try {
32
- return { id: parsed.id, ok: true, result: await daemon.handle(parsed.request) };
33
- }
34
- catch (error) {
35
- return { id: parsed.id, ok: false, error: errorMessage(error) };
36
- }
37
- }
38
- /** Sends events to a subscribed connection; a connection that falls behind is dropped. */
39
- function subscribeConnection(serving, connection) {
40
- const unsubscribe = serving.daemon.subscribe((event) => {
41
- if (connection.destroyed)
42
- return;
43
- if (connection.writableLength > SUBSCRIBER_BUFFER_LIMIT) {
44
- connection.destroy();
45
- return;
46
- }
47
- connection.write(`${event}\n`);
48
- });
49
- serving.subscriptions.add(connection);
50
- connection.once('close', () => {
51
- unsubscribe();
52
- serving.subscriptions.delete(connection);
53
- });
54
- }
55
- function handleLine(serving, connection, line, close) {
56
- const parsed = parseRequest(line);
57
- if ('request' in parsed && parsed.request.method === 'subscribe') {
58
- subscribeConnection(serving, connection);
59
- return;
60
- }
61
- void answer(serving.daemon, line).then((response) => {
62
- if (!connection.destroyed)
63
- connection.write(`${JSON.stringify(response)}\n`);
64
- if (response.ok && response.result?.stopping)
65
- close();
66
- });
67
- }
68
- function handleConnection(serving, connection, close) {
69
- connection.setEncoding('utf8');
70
- let buffer = '';
71
- connection.on('data', (chunk) => {
72
- buffer += chunk;
73
- let end = buffer.indexOf('\n');
74
- while (end !== -1) {
75
- const line = buffer.slice(0, end);
76
- buffer = buffer.slice(end + 1);
77
- handleLine(serving, connection, line, close);
78
- end = buffer.indexOf('\n');
79
- }
80
- });
81
- connection.on('error', () => undefined);
82
- }
83
- async function shutdown(serving) {
84
- const { daemon, server, lockPath, own } = serving;
85
- if (serving.socketCheck)
86
- clearInterval(serving.socketCheck);
87
- for (const connection of serving.subscriptions)
88
- connection.destroy();
89
- // Closing a listening Unix socket unlinks its path, whatever file is there now: a file put in
90
- // place of the socket by someone else is moved aside for the close and then put back.
91
- const foreign = own !== null && existsSync(daemon.socket) && !sameFile(daemon.socket, own);
92
- const aside = `${daemon.socket}.${process.pid}.keep`;
93
- if (foreign)
94
- renameSync(daemon.socket, aside);
95
- await new Promise((resolve) => server.close(() => resolve()));
96
- if (foreign)
97
- renameSync(aside, daemon.socket);
98
- await daemon.stop();
99
- if (own && sameFile(daemon.socket, own))
100
- rmSync(daemon.socket, { force: true });
101
- if (existsSync(lockPath) && readFileSync(lockPath, 'utf8').trim() === String(process.pid)) {
102
- rmSync(lockPath, { force: true });
103
- }
104
- }
105
- /**
106
- * Without its socket nobody can reach the daemon; without its lock the next client starts
107
- * another one. Either is gone when the state directory is removed (the socket may live in the
108
- * temporary directory, see `socketPath`): the daemon then stops by itself.
109
- */
110
- function watchSocket(serving, socketStat, intervalMs, close) {
111
- const { daemon, lockPath } = serving;
112
- serving.socketCheck = setInterval(() => {
113
- if (serving.closing)
114
- return;
115
- const lost = !sameFile(daemon.socket, socketStat)
116
- ? `socket ${daemon.socket}`
117
- : !ownLock(lockPath)
118
- ? `lock ${lockPath}`
119
- : null;
120
- if (lost === null)
121
- return;
122
- process.stderr.write(`aip daemon: ${lost} is gone; stopping\n`);
123
- close();
124
- }, intervalMs);
125
- serving.socketCheck.unref();
126
- }
127
- /** Listens on the socket of the daemon and starts it; the caller holds the lock. */
128
- export async function serveDaemon(daemon, options) {
129
- rmSync(daemon.socket, { force: true });
130
- let resolveClosed = () => undefined;
131
- const closed = new Promise((resolve) => {
132
- resolveClosed = resolve;
133
- });
134
- const serving = {
135
- daemon,
136
- server: createServer((connection) => handleConnection(serving, connection, () => void close())),
137
- lockPath: options.lockPath,
138
- subscriptions: new Set(),
139
- own: null,
140
- socketCheck: null,
141
- closing: null,
142
- };
143
- const close = () => {
144
- serving.closing ??= shutdown(serving).then(resolveClosed);
145
- return serving.closing;
146
- };
147
- try {
148
- await new Promise((resolve, reject) => {
149
- serving.server.once('error', reject);
150
- serving.server.listen(daemon.socket, () => resolve());
151
- });
152
- chmodSync(daemon.socket, 0o600);
153
- const socketStat = statSync(daemon.socket);
154
- serving.own = socketStat;
155
- await daemon.start();
156
- watchSocket(serving, socketStat, options.socketCheckMs ?? SOCKET_CHECK_MS, () => void close());
157
- }
158
- catch (error) {
159
- serving.server.close();
160
- throw error;
161
- }
162
- return { close, closed };
163
- }
164
- //# sourceMappingURL=server.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"server.js","sourceRoot":"","sources":["../../src/daemon/server.ts"],"names":[],"mappings":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AAE,OAAO,CAAC,QAAQ;QAC1B,aAAa,EAAE,IAAI,GAAG,EAAE;QACxB,GAAG,EAAE,IAAI;QACT,WAAW,EAAE,IAAI;QACjB,OAAO,EAAE,IAAI;KACd,CAAC;IACF,MAAM,KAAK,GAAG,GAAkB,EAAE;QAChC,OAAO,CAAC,OAAO,KAAK,QAAQ,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;QAC1D,OAAO,OAAO,CAAC,OAAO,CAAC;IACzB,CAAC,CAAC;IACF,IAAI,CAAC;QACH,MAAM,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YAC1C,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;YACrC,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,EAAE,CAAC,OAAO,EAAE,CAAC,CAAC;QACxD,CAAC,CAAC,CAAC;QACH,SAAS,CAAC,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;QAChC,MAAM,UAAU,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;QAC3C,OAAO,CAAC,GAAG,GAAG,UAAU,CAAC;QACzB,MAAM,MAAM,CAAC,KAAK,EAAE,CAAC;QACrB,WAAW,CAAC,OAAO,EAAE,UAAU,EAAE,OAAO,CAAC,aAAa,IAAI,eAAe,EAAE,GAAG,EAAE,CAAC,KAAK,KAAK,EAAE,CAAC,CAAC;IACjG,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;QACvB,MAAM,KAAK,CAAC;IACd,CAAC;IACD,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC;AAC3B,CAAC"}
@@ -1,140 +0,0 @@
1
- import { spawn } from 'node:child_process';
2
- import { appendFileSync, createWriteStream, mkdirSync, readFileSync, writeFileSync } from 'node:fs';
3
- import { dirname } from 'node:path';
4
- import { createInterface } from 'node:readline';
5
- export const STOP_GRACE_MS = 10_000;
6
- export const DRAIN_MS = 2_000;
7
- export function launchProcess(launch, options) {
8
- for (const file of launch.files) {
9
- mkdirSync(dirname(file.path), { recursive: true });
10
- writeFileSync(file.path, file.content, { mode: 0o600 });
11
- }
12
- mkdirSync(dirname(options.logPath), { recursive: true });
13
- // Lines already in the log (an executor may have added some) keep their numbers.
14
- let lineCount = 0;
15
- if (options.timesPath) {
16
- try {
17
- for (const char of readFileSync(options.logPath, 'utf8'))
18
- if (char === '\n')
19
- lineCount += 1;
20
- }
21
- catch {
22
- lineCount = 0;
23
- }
24
- }
25
- const stamp = (lines) => {
26
- if (!options.timesPath || lines <= 0)
27
- return;
28
- const now = Date.now();
29
- let text = '';
30
- for (let index = 0; index < lines; index += 1)
31
- text += `${lineCount + index}\t${now}\n`;
32
- lineCount += lines;
33
- try {
34
- appendFileSync(options.timesPath, text);
35
- }
36
- catch {
37
- // the journal works without times
38
- }
39
- };
40
- const log = createWriteStream(options.logPath, { flags: 'a' });
41
- let child;
42
- let spawnError = null;
43
- try {
44
- child = spawn(launch.command, launch.args, {
45
- cwd: options.cwd,
46
- env: { ...options.environment, ...launch.env },
47
- detached: true,
48
- stdio: ['ignore', 'pipe', 'pipe'],
49
- });
50
- }
51
- catch (error) {
52
- spawnError = error.message;
53
- stamp(1);
54
- const failure = {
55
- code: null,
56
- signal: null,
57
- outcome: options.parser.outcome(),
58
- spawnError,
59
- };
60
- return {
61
- pid: undefined,
62
- stop() { },
63
- exited: new Promise((resolve) => {
64
- log.end(`[aip] spawn failed: ${spawnError}\n`, () => resolve(failure));
65
- }),
66
- };
67
- }
68
- const stdout = createInterface({ input: child.stdout });
69
- let reported = null;
70
- stdout.on('line', (line) => {
71
- log.write(`${line}\n`);
72
- stamp(1);
73
- options.parser.push(line);
74
- if (options.onUsage) {
75
- const usage = options.parser.usage();
76
- if (usage !== null &&
77
- (reported === null ||
78
- reported.inputTokens !== usage.inputTokens ||
79
- reported.outputTokens !== usage.outputTokens ||
80
- reported.costUsd !== usage.costUsd)) {
81
- reported = usage;
82
- options.onUsage(usage);
83
- }
84
- }
85
- });
86
- child.stderr.on('data', (chunk) => {
87
- log.write(chunk);
88
- stamp(chunk.filter((byte) => byte === 10).length);
89
- });
90
- let killTimer = null;
91
- const signalGroup = (signal) => {
92
- if (child.pid === undefined)
93
- return;
94
- try {
95
- process.kill(-child.pid, signal);
96
- }
97
- catch {
98
- try {
99
- child.kill(signal);
100
- }
101
- catch {
102
- return;
103
- }
104
- }
105
- };
106
- const exited = new Promise((resolve) => {
107
- let settled = false;
108
- const finish = (code, signal) => {
109
- if (settled)
110
- return;
111
- settled = true;
112
- if (killTimer)
113
- clearTimeout(killTimer);
114
- stdout.close();
115
- stamp(1);
116
- const exit = { code, signal, outcome: options.parser.outcome(), spawnError };
117
- // Resolved once the log is on disk: a reader after the exit sees its last line.
118
- log.end(`[aip] exited code=${code} signal=${signal}${spawnError ? ` error=${spawnError}` : ''}\n`, () => resolve(exit));
119
- };
120
- child.once('error', (error) => {
121
- spawnError = error.message;
122
- finish(null, null);
123
- });
124
- child.once('exit', (code, signal) => {
125
- signalGroup('SIGTERM');
126
- setTimeout(() => finish(code, signal), options.drainMs ?? DRAIN_MS).unref();
127
- });
128
- child.once('close', finish);
129
- });
130
- return {
131
- pid: child.pid,
132
- stop() {
133
- signalGroup('SIGTERM');
134
- killTimer ??= setTimeout(() => signalGroup('SIGKILL'), options.graceMs ?? STOP_GRACE_MS);
135
- killTimer.unref();
136
- },
137
- exited,
138
- };
139
- }
140
- //# sourceMappingURL=supervisor.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"supervisor.js","sourceRoot":"","sources":["../../src/daemon/supervisor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAqB,MAAM,oBAAoB,CAAC;AAC9D,OAAO,EAAE,cAAc,EAAE,iBAAiB,EAAE,SAAS,EAAE,YAAY,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CAAC,CAAC,CAAC;QACH,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE;YAClC,WAAW,CAAC,SAAS,CAAC,CAAC;YACvB,UAAU,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,EAAE,OAAO,CAAC,OAAO,IAAI,QAAQ,CAAC,CAAC,KAAK,EAAE,CAAC;QAC9E,CAAC,CAAC,CAAC;QACH,KAAK,CAAC,IAAI,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;IAC9B,CAAC,CAAC,CAAC;IACH,OAAO;QACL,GAAG,EAAE,KAAK,CAAC,GAAG;QACd,IAAI;YACF,WAAW,CAAC,SAAS,CAAC,CAAC;YACvB,SAAS,KAAK,UAAU,CAAC,GAAG,EAAE,CAAC,WAAW,CAAC,SAAS,CAAC,EAAE,OAAO,CAAC,OAAO,IAAI,aAAa,CAAC,CAAC;YACzF,SAAS,CAAC,KAAK,EAAE,CAAC;QACpB,CAAC;QACD,MAAM;KACP,CAAC;AACJ,CAAC"}
@@ -1,23 +0,0 @@
1
- import { NAMING_TIMEOUT_MS, USAGE_INTERVAL_MS } from '../feature/runs/services/index.js';
2
- import { KILL_GRACE_MS } from '../feature/processes/services/index.js';
3
- import { DRAIN_MS, STOP_GRACE_MS } from '../feature/agents/services/index.js';
4
- /** A timer fires this long after a usage limit resets, so the reset has surely passed. */
5
- const WAKE_MARGIN_MS = 1000;
6
- /** How often the daemon looks at background processes while someone is subscribed. */
7
- const PROCESS_STREAM_MS = 2000;
8
- /** Pause between a SIGTERM and the extra look at background processes. */
9
- const PROCESS_KILL_LOOK_MS = 250;
10
- /** The durations of a daemon without overrides. */
11
- export const DEFAULT_TIMINGS = {
12
- timeoutUnitMs: 1000,
13
- drainMs: DRAIN_MS,
14
- stopGraceMs: STOP_GRACE_MS,
15
- killGraceMs: KILL_GRACE_MS,
16
- wakeMarginMs: WAKE_MARGIN_MS,
17
- usageIntervalMs: USAGE_INTERVAL_MS,
18
- namingTimeoutMs: NAMING_TIMEOUT_MS,
19
- processStreamMs: PROCESS_STREAM_MS,
20
- processKillLookMs: PROCESS_KILL_LOOK_MS,
21
- processCacheMs: 1_000,
22
- };
23
- //# sourceMappingURL=timings.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"timings.js","sourceRoot":"","sources":["../../src/daemon/timings.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AACzF,OAAO,EAAE,aAAa,EAAE,MAAM,wCAAwC,CAAC;AACvE,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,qCAAqC,CAAC;AAE9E,0FAA0F;AAC1F,MAAM,cAAc,GAAG,IAAI,CAAC;AAC5B,sFAAsF;AACtF,MAAM,iBAAiB,GAAG,IAAI,CAAC;AAC/B,0EAA0E;AAC1E,MAAM,oBAAoB,GAAG,GAAG,CAAC;AA0BjC,mDAAmD;AACnD,MAAM,CAAC,MAAM,eAAe,GAAkB;IAC5C,aAAa,EAAE,IAAI;IACnB,OAAO,EAAE,QAAQ;IACjB,WAAW,EAAE,aAAa;IAC1B,WAAW,EAAE,aAAa;IAC1B,YAAY,EAAE,cAAc;IAC5B,eAAe,EAAE,iBAAiB;IAClC,eAAe,EAAE,iBAAiB;IAClC,eAAe,EAAE,iBAAiB;IAClC,iBAAiB,EAAE,oBAAoB;IACvC,cAAc,EAAE,KAAK;CACtB,CAAC"}
@@ -1,284 +0,0 @@
1
- import { existsSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
2
- import { tmpdir } from 'node:os';
3
- import { join } from 'node:path';
4
- import { git, runGit, runGitBuffer } from './runner.js';
5
- import { commitAll, existingPaths, snapshotCommit } from './workspace.js';
6
- export const CONFLICT_REASON = 'the changes conflict with your working tree';
7
- function underInclude(file, include) {
8
- return include.some((entry) => {
9
- const path = entry.replace(/\/+$/, '');
10
- return file === path || file.startsWith(`${path}/`);
11
- });
12
- }
13
- function lines(text) {
14
- return text === '' ? [] : text.split('\n');
15
- }
16
- export async function changedFiles(repository, from, to) {
17
- const output = await git(repository, 'diff', '--name-status', '-M', '-z', from, to);
18
- const parts = output.split('\0').filter((part) => part !== '');
19
- const files = [];
20
- for (let index = 0; index < parts.length; index += 1) {
21
- const status = parts[index] ?? '';
22
- if (status.startsWith('R') || status.startsWith('C')) {
23
- files.push(parts[index + 1] ?? '', parts[index + 2] ?? '');
24
- index += 2;
25
- }
26
- else {
27
- files.push(parts[index + 1] ?? '');
28
- index += 1;
29
- }
30
- }
31
- return [...new Set(files.filter((file) => file !== ''))].sort();
32
- }
33
- export async function dirtyPaths(repository) {
34
- const output = (await runGit(repository, ['status', '--porcelain=v1', '-z', '--untracked-files=all'])).stdout;
35
- const entries = output.split('\0');
36
- const paths = [];
37
- for (let index = 0; index < entries.length; index += 1) {
38
- const entry = entries[index] ?? '';
39
- if (entry.length < 4)
40
- continue;
41
- paths.push(entry.slice(3));
42
- if (entry.startsWith('R') || entry.startsWith('C')) {
43
- paths.push(entries[index + 1] ?? '');
44
- index += 1;
45
- }
46
- }
47
- return paths.filter((path) => path !== '');
48
- }
49
- async function patchFile(repository, change, directory) {
50
- const patch = (await runGit(repository, ['diff', '--binary', '-M', change.from, change.to]))
51
- .stdout;
52
- const path = join(directory, `${change.group}.patch`);
53
- writeFileSync(path, patch);
54
- return path;
55
- }
56
- /**
57
- * One patch with the changes of every group, stacked in order on the base of the first one in a
58
- * temporary index. Applying the groups one by one to the user's tree loses every group after a
59
- * conflict: `git apply --3way` refuses a whole patch while the index holds an unmerged path.
60
- */
61
- async function combinedPatch(repository, changes, directory) {
62
- const [first] = changes;
63
- if (!first)
64
- throw new Error('no changes to combine');
65
- if (changes.length === 1)
66
- return patchFile(repository, first, directory);
67
- const environment = { GIT_INDEX_FILE: join(directory, 'combined.index') };
68
- await runGitWith(repository, ['read-tree', first.from], environment);
69
- for (const change of changes) {
70
- const patch = await patchFile(repository, change, directory);
71
- const result = await runGitWith(repository, ['apply', '--cached', '--3way', patch], environment, true);
72
- if (result.code !== 0) {
73
- throw new Error(`the changes of group ${change.group} do not apply on top of the groups before it: ${result.stderr.trim()}`);
74
- }
75
- }
76
- const tree = (await runGitWith(repository, ['write-tree'], environment)).stdout.trim();
77
- const patch = (await runGit(repository, ['diff', '--binary', '-M', first.from, tree])).stdout;
78
- const path = join(directory, 'combined.patch');
79
- writeFileSync(path, patch);
80
- return path;
81
- }
82
- async function snapshotIndex(repository, path, include) {
83
- const environment = { GIT_INDEX_FILE: path };
84
- await runGitWith(repository, ['read-tree', 'HEAD'], environment);
85
- await runGitWith(repository, ['add', '-A'], environment);
86
- const extra = existingPaths(repository, include);
87
- if (extra.length > 0)
88
- await runGitWith(repository, ['add', '-A', '-f', '--', ...extra], environment);
89
- return environment;
90
- }
91
- async function runGitWith(repository, args, env, allowFailure = false) {
92
- return runGit(repository, args, { allowFailure, env });
93
- }
94
- async function unmerged(repository, env) {
95
- const output = (await runGitWith(repository, ['ls-files', '-u'], env)).stdout.trim();
96
- return [...new Set(lines(output).map((line) => line.split('\t')[1] ?? ''))]
97
- .filter(Boolean)
98
- .sort();
99
- }
100
- export async function probe(repository, patches, directory, include = []) {
101
- const environment = await snapshotIndex(repository, join(directory, 'probe.index'), include);
102
- const conflicts = new Set();
103
- for (const patch of patches) {
104
- const result = await runGitWith(repository, ['apply', '--3way', '--cached', patch], environment, true);
105
- if (result.code !== 0) {
106
- const files = await unmerged(repository, environment);
107
- if (files.length === 0)
108
- throw new Error(`patch does not apply: ${result.stderr.trim()}`);
109
- for (const file of files)
110
- conflicts.add(file);
111
- break;
112
- }
113
- }
114
- return [...conflicts].sort();
115
- }
116
- async function applyToWorktree(repository, patches, directory, include) {
117
- const conflicts = new Set();
118
- for (const [index, patch] of patches.entries()) {
119
- const environment = await snapshotIndex(repository, join(directory, `apply-${index}.index`), include);
120
- const result = await runGitWith(repository, ['apply', '--3way', patch], environment, true);
121
- if (result.code !== 0) {
122
- const files = await unmerged(repository, environment);
123
- if (files.length === 0)
124
- throw new Error(`patch does not apply: ${result.stderr.trim()}`);
125
- for (const file of files)
126
- conflicts.add(file);
127
- }
128
- }
129
- return [...conflicts].sort();
130
- }
131
- export async function deliver(request) {
132
- const { repository } = request;
133
- const include = request.include ?? [];
134
- const changes = request.changes.filter((change) => change.from !== change.to);
135
- const files = [
136
- ...new Set((await Promise.all(changes.map((change) => changedFiles(repository, change.from, change.to)))).flat()),
137
- ].sort();
138
- if (request.mode === 'branch') {
139
- await git(repository, 'branch', '-f', request.branch, request.runRef);
140
- return { kind: 'applied', files, conflicts: [], commit: null, userEdits: [] };
141
- }
142
- if (request.mode === 'commit') {
143
- const staged = await runGit(repository, ['diff', '--cached', '--quiet'], {
144
- allowFailure: true,
145
- });
146
- if (staged.code !== 0) {
147
- return {
148
- kind: 'refused',
149
- reason: 'the index has staged changes; commit or unstage them first',
150
- files: [],
151
- };
152
- }
153
- }
154
- if (files.length === 0) {
155
- return { kind: 'applied', files, conflicts: [], commit: null, userEdits: [] };
156
- }
157
- const directory = mkdtempSync(join(tmpdir(), 'aip-deliver-'));
158
- try {
159
- const patches = [await combinedPatch(repository, changes, directory)];
160
- const committed = request.mode === 'commit' ? files.filter((file) => !underInclude(file, include)) : [];
161
- const dirty = new Set(await dirtyPaths(repository));
162
- const userEdits = committed.filter((file) => dirty.has(file));
163
- if (!request.force) {
164
- const conflicts = await probe(repository, patches, directory, include);
165
- if (conflicts.length > 0) {
166
- return { kind: 'refused', reason: CONFLICT_REASON, files: conflicts, conflict: true };
167
- }
168
- }
169
- const conflicts = await applyToWorktree(repository, patches, directory, include);
170
- let commit = null;
171
- if (request.mode === 'commit' && conflicts.length === 0 && committed.length > 0) {
172
- await git(repository, 'add', '-A', '--', ...committed);
173
- await git(repository, 'commit', '--no-verify', '-m', request.message, '--', ...committed);
174
- commit = await git(repository, 'rev-parse', 'HEAD');
175
- }
176
- return { kind: 'applied', files, conflicts, commit, userEdits };
177
- }
178
- finally {
179
- rmSync(directory, { recursive: true, force: true });
180
- }
181
- }
182
- /**
183
- * Snapshots the current working tree of the user, checks it out in the resolver worktree and
184
- * applies the changes there with a three-way merge, leaving conflict markers in place.
185
- */
186
- export async function prepareResolve(request) {
187
- const { repository, worktree } = request;
188
- const base = await snapshotCommit(repository, true, request.include);
189
- await git(repository, 'update-ref', request.baseRef, base);
190
- if (existsSync(worktree)) {
191
- await runGit(repository, ['worktree', 'remove', '--force', worktree], { allowFailure: true });
192
- rmSync(worktree, { recursive: true, force: true });
193
- await git(repository, 'worktree', 'prune');
194
- }
195
- await git(repository, 'worktree', 'add', '--detach', worktree, base);
196
- const directory = mkdtempSync(join(tmpdir(), 'aip-resolve-'));
197
- try {
198
- const changes = request.changes.filter((change) => change.from !== change.to);
199
- if (changes.length > 0) {
200
- const patch = await combinedPatch(repository, changes, directory);
201
- const result = await runGit(worktree, ['apply', '--3way', patch], { allowFailure: true });
202
- if (result.code !== 0 && (await unmergedIn(worktree)).length === 0) {
203
- throw new Error(`patch does not apply: ${result.stderr.trim()}`);
204
- }
205
- }
206
- return { base, conflicts: await unmergedIn(worktree) };
207
- }
208
- finally {
209
- rmSync(directory, { recursive: true, force: true });
210
- }
211
- }
212
- async function unmergedIn(worktree) {
213
- return lines(await git(worktree, 'diff', '--name-only', '--diff-filter=U')).sort();
214
- }
215
- const MARKER = /^(<{7}|>{7})( |$)|^={7}$/m;
216
- /** Files among `files` of the worktree that still contain conflict markers. */
217
- export function filesWithMarkers(worktree, files) {
218
- return files.filter((file) => {
219
- const path = join(worktree, file);
220
- return existsSync(path) && MARKER.test(readFileSync(path, 'utf8'));
221
- });
222
- }
223
- /** Commits what the resolver left in its worktree; returns the commit, or `base` without changes. */
224
- export async function commitResolve(worktree, base, include) {
225
- return (await commitAll(worktree, 'aip: resolve delivery conflicts', null, include)) ?? base;
226
- }
227
- /** Changed files between two commits with added and removed lines (`git diff --numstat`). */
228
- export async function diffStat(repository, from, to) {
229
- const output = (await runGit(repository, ['diff', '--numstat', '-z', '-M', from, to])).stdout;
230
- const parts = output.split('\0');
231
- const files = [];
232
- for (let index = 0; index < parts.length; index += 1) {
233
- const head = parts[index] ?? '';
234
- if (head === '')
235
- continue;
236
- const [added = '-', removed = '-', path = ''] = head.split('\t');
237
- // A rename prints an empty path followed by the old and the new path.
238
- let name = path;
239
- let previousPath;
240
- if (path === '') {
241
- previousPath = parts[index + 1] ?? '';
242
- name = parts[index + 2] ?? '';
243
- index += 2;
244
- }
245
- files.push({
246
- path: name,
247
- added: added === '-' ? null : Number(added),
248
- removed: removed === '-' ? null : Number(removed),
249
- ...(previousPath ? { previousPath } : {}),
250
- });
251
- }
252
- files.sort((left, right) => left.path.localeCompare(right.path));
253
- return {
254
- files,
255
- added: files.reduce((sum, file) => sum + (file.added ?? 0), 0),
256
- removed: files.reduce((sum, file) => sum + (file.removed ?? 0), 0),
257
- };
258
- }
259
- /** Diff of the given paths (a renamed file needs both) with `context` lines around each change. */
260
- export async function fileDiff(repository, from, to, paths, options) {
261
- const output = (await runGit(repository, [
262
- 'diff',
263
- `-U${options.context}`,
264
- '-M',
265
- '--no-color',
266
- from,
267
- to,
268
- '--',
269
- ...paths,
270
- ])).stdout;
271
- const all = lines(output.replace(/\n$/, ''));
272
- const start = all.findIndex((line) => line.startsWith('@@'));
273
- const body = start < 0 ? [] : all.slice(start);
274
- return {
275
- lines: body.slice(0, options.maxLines),
276
- totalLines: body.length,
277
- truncated: body.length > options.maxLines,
278
- };
279
- }
280
- /** Patch of `from..to` for `git apply`, binary files included, as raw bytes. */
281
- export async function rangePatch(repository, from, to) {
282
- return runGitBuffer(repository, ['diff', '--binary', '-M', from, to]);
283
- }
284
- //# sourceMappingURL=delivery.js.map