@rudderhq/server 0.2.5-canary.9 → 0.2.5

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 (309) hide show
  1. package/dist/bootstrap/plugin-host-runtime.d.ts +39 -39
  2. package/dist/bundled-plugins/plugin-linear/dist/worker.js +101 -147
  3. package/dist/bundled-plugins/plugin-linear/dist/worker.js.map +2 -2
  4. package/dist/bundled-plugins/plugin-linear/package.json +1 -1
  5. package/dist/routes/access-onboarding.helpers.d.ts +142 -0
  6. package/dist/routes/access-onboarding.helpers.d.ts.map +1 -0
  7. package/dist/routes/access-onboarding.helpers.js +762 -0
  8. package/dist/routes/access-onboarding.helpers.js.map +1 -0
  9. package/dist/routes/access.d.ts +2 -48
  10. package/dist/routes/access.d.ts.map +1 -1
  11. package/dist/routes/access.helpers.d.ts +109 -0
  12. package/dist/routes/access.helpers.d.ts.map +1 -0
  13. package/dist/routes/access.helpers.js +460 -0
  14. package/dist/routes/access.helpers.js.map +1 -0
  15. package/dist/routes/access.js +6 -1218
  16. package/dist/routes/access.js.map +1 -1
  17. package/dist/routes/agents.d.ts.map +1 -1
  18. package/dist/routes/agents.js +55 -1057
  19. package/dist/routes/agents.js.map +1 -1
  20. package/dist/routes/agents.management-routes.d.ts +12 -0
  21. package/dist/routes/agents.management-routes.d.ts.map +1 -0
  22. package/dist/routes/agents.management-routes.js +1067 -0
  23. package/dist/routes/agents.management-routes.js.map +1 -0
  24. package/dist/routes/chats.d.ts.map +1 -1
  25. package/dist/routes/chats.js +42 -652
  26. package/dist/routes/chats.js.map +1 -1
  27. package/dist/routes/chats.stream-routes.d.ts +12 -0
  28. package/dist/routes/chats.stream-routes.d.ts.map +1 -0
  29. package/dist/routes/chats.stream-routes.js +666 -0
  30. package/dist/routes/chats.stream-routes.js.map +1 -0
  31. package/dist/routes/issues.comments-attachments.d.ts +12 -0
  32. package/dist/routes/issues.comments-attachments.d.ts.map +1 -0
  33. package/dist/routes/issues.comments-attachments.js +511 -0
  34. package/dist/routes/issues.comments-attachments.js.map +1 -0
  35. package/dist/routes/issues.d.ts.map +1 -1
  36. package/dist/routes/issues.js +43 -1128
  37. package/dist/routes/issues.js.map +1 -1
  38. package/dist/routes/issues.mutations.d.ts +12 -0
  39. package/dist/routes/issues.mutations.d.ts.map +1 -0
  40. package/dist/routes/issues.mutations.js +635 -0
  41. package/dist/routes/issues.mutations.js.map +1 -0
  42. package/dist/routes/plugins.d.ts.map +1 -1
  43. package/dist/routes/plugins.js +14 -694
  44. package/dist/routes/plugins.js.map +1 -1
  45. package/dist/routes/plugins.operations-routes.d.ts +28 -0
  46. package/dist/routes/plugins.operations-routes.d.ts.map +1 -0
  47. package/dist/routes/plugins.operations-routes.js +720 -0
  48. package/dist/routes/plugins.operations-routes.js.map +1 -0
  49. package/dist/services/access.d.ts +21 -21
  50. package/dist/services/activity.d.ts +19 -19
  51. package/dist/services/agents.d.ts +158 -158
  52. package/dist/services/approvals.d.ts +29 -29
  53. package/dist/services/assets.d.ts +8 -8
  54. package/dist/services/automations.d.ts +41 -27
  55. package/dist/services/automations.d.ts.map +1 -1
  56. package/dist/services/automations.js +287 -110
  57. package/dist/services/automations.js.map +1 -1
  58. package/dist/services/automations.scheduler.d.ts +9 -0
  59. package/dist/services/automations.scheduler.d.ts.map +1 -0
  60. package/dist/services/automations.scheduler.js +101 -0
  61. package/dist/services/automations.scheduler.js.map +1 -0
  62. package/dist/services/board-auth.d.ts +32 -32
  63. package/dist/services/calendar.d.ts +26 -26
  64. package/dist/services/chat-assistant.d.ts +3 -47
  65. package/dist/services/chat-assistant.d.ts.map +1 -1
  66. package/dist/services/chat-assistant.helpers.d.ts +156 -0
  67. package/dist/services/chat-assistant.helpers.d.ts.map +1 -0
  68. package/dist/services/chat-assistant.helpers.js +862 -0
  69. package/dist/services/chat-assistant.helpers.js.map +1 -0
  70. package/dist/services/chat-assistant.js +2 -861
  71. package/dist/services/chat-assistant.js.map +1 -1
  72. package/dist/services/chats.d.ts +149 -247
  73. package/dist/services/chats.d.ts.map +1 -1
  74. package/dist/services/chats.helpers.d.ts +117 -0
  75. package/dist/services/chats.helpers.d.ts.map +1 -0
  76. package/dist/services/chats.helpers.js +285 -0
  77. package/dist/services/chats.helpers.js.map +1 -0
  78. package/dist/services/chats.js +6 -286
  79. package/dist/services/chats.js.map +1 -1
  80. package/dist/services/costs.d.ts +8 -8
  81. package/dist/services/finance.d.ts +18 -18
  82. package/dist/services/goals.d.ts +30 -30
  83. package/dist/services/heartbeat.d.ts +3 -1
  84. package/dist/services/heartbeat.d.ts.map +1 -1
  85. package/dist/services/heartbeat.js +3 -1
  86. package/dist/services/heartbeat.js.map +1 -1
  87. package/dist/services/issue-approvals.d.ts +4 -4
  88. package/dist/services/issue-review-wakeup.d.ts +3 -3
  89. package/dist/services/issues.comments-attachments.d.ts +141 -0
  90. package/dist/services/issues.comments-attachments.d.ts.map +1 -0
  91. package/dist/services/issues.comments-attachments.js +313 -0
  92. package/dist/services/issues.comments-attachments.js.map +1 -0
  93. package/dist/services/issues.d.ts +205 -256
  94. package/dist/services/issues.d.ts.map +1 -1
  95. package/dist/services/issues.helpers.d.ts +87 -0
  96. package/dist/services/issues.helpers.d.ts.map +1 -0
  97. package/dist/services/issues.helpers.js +270 -0
  98. package/dist/services/issues.helpers.js.map +1 -0
  99. package/dist/services/issues.js +5 -569
  100. package/dist/services/issues.js.map +1 -1
  101. package/dist/services/knowledge-portability/organization-portability.core.d.ts +210 -0
  102. package/dist/services/knowledge-portability/organization-portability.core.d.ts.map +1 -0
  103. package/dist/services/knowledge-portability/organization-portability.core.js +997 -0
  104. package/dist/services/knowledge-portability/organization-portability.core.js.map +1 -0
  105. package/dist/services/knowledge-portability/organization-portability.d.ts +6 -28
  106. package/dist/services/knowledge-portability/organization-portability.d.ts.map +1 -1
  107. package/dist/services/knowledge-portability/organization-portability.export.d.ts +24 -0
  108. package/dist/services/knowledge-portability/organization-portability.export.d.ts.map +1 -0
  109. package/dist/services/knowledge-portability/organization-portability.export.js +607 -0
  110. package/dist/services/knowledge-portability/organization-portability.export.js.map +1 -0
  111. package/dist/services/knowledge-portability/organization-portability.files.d.ts +69 -0
  112. package/dist/services/knowledge-portability/organization-portability.files.d.ts.map +1 -0
  113. package/dist/services/knowledge-portability/organization-portability.files.js +597 -0
  114. package/dist/services/knowledge-portability/organization-portability.files.js.map +1 -0
  115. package/dist/services/knowledge-portability/organization-portability.import.d.ts +31 -0
  116. package/dist/services/knowledge-portability/organization-portability.import.d.ts.map +1 -0
  117. package/dist/services/knowledge-portability/organization-portability.import.js +575 -0
  118. package/dist/services/knowledge-portability/organization-portability.import.js.map +1 -0
  119. package/dist/services/knowledge-portability/organization-portability.js +37 -3848
  120. package/dist/services/knowledge-portability/organization-portability.js.map +1 -1
  121. package/dist/services/knowledge-portability/organization-portability.package.d.ts +72 -0
  122. package/dist/services/knowledge-portability/organization-portability.package.d.ts.map +1 -0
  123. package/dist/services/knowledge-portability/organization-portability.package.js +749 -0
  124. package/dist/services/knowledge-portability/organization-portability.package.js.map +1 -0
  125. package/dist/services/knowledge-portability/organization-portability.preview.d.ts +18 -0
  126. package/dist/services/knowledge-portability/organization-portability.preview.d.ts.map +1 -0
  127. package/dist/services/knowledge-portability/organization-portability.preview.js +333 -0
  128. package/dist/services/knowledge-portability/organization-portability.preview.js.map +1 -0
  129. package/dist/services/knowledge-portability/organization-portability.resolve-source.d.ts +4 -0
  130. package/dist/services/knowledge-portability/organization-portability.resolve-source.d.ts.map +1 -0
  131. package/dist/services/knowledge-portability/organization-portability.resolve-source.js +86 -0
  132. package/dist/services/knowledge-portability/organization-portability.resolve-source.js.map +1 -0
  133. package/dist/services/knowledge-portability/organization-skills.catalog.d.ts +221 -0
  134. package/dist/services/knowledge-portability/organization-skills.catalog.d.ts.map +1 -0
  135. package/dist/services/knowledge-portability/organization-skills.catalog.js +999 -0
  136. package/dist/services/knowledge-portability/organization-skills.catalog.js.map +1 -0
  137. package/dist/services/knowledge-portability/organization-skills.d.ts +4 -75
  138. package/dist/services/knowledge-portability/organization-skills.d.ts.map +1 -1
  139. package/dist/services/knowledge-portability/organization-skills.js +11 -2008
  140. package/dist/services/knowledge-portability/organization-skills.js.map +1 -1
  141. package/dist/services/knowledge-portability/organization-skills.scans.d.ts +16 -0
  142. package/dist/services/knowledge-portability/organization-skills.scans.d.ts.map +1 -0
  143. package/dist/services/knowledge-portability/organization-skills.scans.js +300 -0
  144. package/dist/services/knowledge-portability/organization-skills.scans.js.map +1 -0
  145. package/dist/services/knowledge-portability/organization-skills.sources.d.ts +68 -0
  146. package/dist/services/knowledge-portability/organization-skills.sources.d.ts.map +1 -0
  147. package/dist/services/knowledge-portability/organization-skills.sources.js +728 -0
  148. package/dist/services/knowledge-portability/organization-skills.sources.js.map +1 -0
  149. package/dist/services/messenger.d.ts +2 -2
  150. package/dist/services/messenger.js +2 -2
  151. package/dist/services/messenger.js.map +1 -1
  152. package/dist/services/organization-skills.d.ts +3 -1
  153. package/dist/services/organization-skills.d.ts.map +1 -1
  154. package/dist/services/organization-skills.js +3 -1
  155. package/dist/services/organization-skills.js.map +1 -1
  156. package/dist/services/orgs.d.ts +9 -9
  157. package/dist/services/plugin-loader.core.d.ts +14 -0
  158. package/dist/services/plugin-loader.core.d.ts.map +1 -0
  159. package/dist/services/plugin-loader.core.js +905 -0
  160. package/dist/services/plugin-loader.core.js.map +1 -0
  161. package/dist/services/plugin-loader.d.ts +3 -440
  162. package/dist/services/plugin-loader.d.ts.map +1 -1
  163. package/dist/services/plugin-loader.helpers.d.ts +468 -0
  164. package/dist/services/plugin-loader.helpers.d.ts.map +1 -0
  165. package/dist/services/plugin-loader.helpers.js +263 -0
  166. package/dist/services/plugin-loader.helpers.js.map +1 -0
  167. package/dist/services/plugin-loader.js +3 -1191
  168. package/dist/services/plugin-loader.js.map +1 -1
  169. package/dist/services/plugin-loader.worker-paths.d.ts +7 -0
  170. package/dist/services/plugin-loader.worker-paths.d.ts.map +1 -0
  171. package/dist/services/plugin-loader.worker-paths.js +85 -0
  172. package/dist/services/plugin-loader.worker-paths.js.map +1 -0
  173. package/dist/services/plugin-registry.d.ts +123 -123
  174. package/dist/services/projects.d.ts +8 -8
  175. package/dist/services/runtime-kernel/heartbeat.core.d.ts +725 -0
  176. package/dist/services/runtime-kernel/heartbeat.core.d.ts.map +1 -0
  177. package/dist/services/runtime-kernel/heartbeat.core.js +525 -0
  178. package/dist/services/runtime-kernel/heartbeat.core.js.map +1 -0
  179. package/dist/services/runtime-kernel/heartbeat.d.ts +38 -259
  180. package/dist/services/runtime-kernel/heartbeat.d.ts.map +1 -1
  181. package/dist/services/runtime-kernel/heartbeat.execute.d.ts +5 -0
  182. package/dist/services/runtime-kernel/heartbeat.execute.d.ts.map +1 -0
  183. package/dist/services/runtime-kernel/heartbeat.execute.js +1052 -0
  184. package/dist/services/runtime-kernel/heartbeat.execute.js.map +1 -0
  185. package/dist/services/runtime-kernel/heartbeat.js +50 -4142
  186. package/dist/services/runtime-kernel/heartbeat.js.map +1 -1
  187. package/dist/services/runtime-kernel/heartbeat.misc.d.ts +30 -0
  188. package/dist/services/runtime-kernel/heartbeat.misc.d.ts.map +1 -0
  189. package/dist/services/runtime-kernel/heartbeat.misc.js +483 -0
  190. package/dist/services/runtime-kernel/heartbeat.misc.js.map +1 -0
  191. package/dist/services/runtime-kernel/heartbeat.recovery.d.ts +38 -0
  192. package/dist/services/runtime-kernel/heartbeat.recovery.d.ts.map +1 -0
  193. package/dist/services/runtime-kernel/heartbeat.recovery.js +605 -0
  194. package/dist/services/runtime-kernel/heartbeat.recovery.js.map +1 -0
  195. package/dist/services/runtime-kernel/heartbeat.release.d.ts +6 -0
  196. package/dist/services/runtime-kernel/heartbeat.release.d.ts.map +1 -0
  197. package/dist/services/runtime-kernel/heartbeat.release.js +398 -0
  198. package/dist/services/runtime-kernel/heartbeat.release.js.map +1 -0
  199. package/dist/services/runtime-kernel/heartbeat.sessions.d.ts +229 -0
  200. package/dist/services/runtime-kernel/heartbeat.sessions.d.ts.map +1 -0
  201. package/dist/services/runtime-kernel/heartbeat.sessions.js +708 -0
  202. package/dist/services/runtime-kernel/heartbeat.sessions.js.map +1 -0
  203. package/dist/services/runtime-kernel/heartbeat.wakeup.d.ts +5 -0
  204. package/dist/services/runtime-kernel/heartbeat.wakeup.d.ts.map +1 -0
  205. package/dist/services/runtime-kernel/heartbeat.wakeup.js +552 -0
  206. package/dist/services/runtime-kernel/heartbeat.wakeup.js.map +1 -0
  207. package/dist/services/secrets.d.ts +25 -25
  208. package/dist/services/sidebar-badges.js +1 -1
  209. package/dist/services/sidebar-badges.js.map +1 -1
  210. package/dist/services/workspace-runtime.comments.d.ts +6 -0
  211. package/dist/services/workspace-runtime.comments.d.ts.map +1 -0
  212. package/dist/services/workspace-runtime.comments.js +17 -0
  213. package/dist/services/workspace-runtime.comments.js.map +1 -0
  214. package/dist/services/workspace-runtime.d.ts +4 -163
  215. package/dist/services/workspace-runtime.d.ts.map +1 -1
  216. package/dist/services/workspace-runtime.helpers.d.ts +163 -0
  217. package/dist/services/workspace-runtime.helpers.d.ts.map +1 -0
  218. package/dist/services/workspace-runtime.helpers.js +360 -0
  219. package/dist/services/workspace-runtime.helpers.js.map +1 -0
  220. package/dist/services/workspace-runtime.js +4 -1236
  221. package/dist/services/workspace-runtime.js.map +1 -1
  222. package/dist/services/workspace-runtime.lifecycle.d.ts +35 -0
  223. package/dist/services/workspace-runtime.lifecycle.d.ts.map +1 -0
  224. package/dist/services/workspace-runtime.lifecycle.js +266 -0
  225. package/dist/services/workspace-runtime.lifecycle.js.map +1 -0
  226. package/dist/services/workspace-runtime.services.d.ts +140 -0
  227. package/dist/services/workspace-runtime.services.d.ts.map +1 -0
  228. package/dist/services/workspace-runtime.services.js +606 -0
  229. package/dist/services/workspace-runtime.services.js.map +1 -0
  230. package/package.json +21 -15
  231. package/ui-dist/assets/{_basePickBy-B5mJzzqZ.js → _basePickBy-N8I9ml5Y.js} +1 -1
  232. package/ui-dist/assets/{_baseUniq-B10Ec09o.js → _baseUniq-BuSlpRSQ.js} +1 -1
  233. package/ui-dist/assets/{arc-Bw7wimOa.js → arc-qX-dPyA1.js} +1 -1
  234. package/ui-dist/assets/{architectureDiagram-2XIMDMQ5-DZr0XEvv.js → architectureDiagram-2XIMDMQ5-DhjkbXsp.js} +1 -1
  235. package/ui-dist/assets/{blockDiagram-WCTKOSBZ-D0jl0LgB.js → blockDiagram-WCTKOSBZ-JS-tTu3J.js} +1 -1
  236. package/ui-dist/assets/{c4Diagram-IC4MRINW-BEFxBnEm.js → c4Diagram-IC4MRINW-4DqwCWIx.js} +1 -1
  237. package/ui-dist/assets/channel-CccCW5_a.js +1 -0
  238. package/ui-dist/assets/{chunk-4BX2VUAB-Cbul1GoA.js → chunk-4BX2VUAB-T37SqBpp.js} +1 -1
  239. package/ui-dist/assets/{chunk-55IACEB6-DuouC3bT.js → chunk-55IACEB6-BSj9hdqK.js} +1 -1
  240. package/ui-dist/assets/{chunk-FMBD7UC4-bN1jF9xw.js → chunk-FMBD7UC4-Dkrlh0Wk.js} +1 -1
  241. package/ui-dist/assets/{chunk-JSJVCQXG-B0-Ij6ZF.js → chunk-JSJVCQXG-C0ZE3QdB.js} +1 -1
  242. package/ui-dist/assets/{chunk-KX2RTZJC-BjI3IEjI.js → chunk-KX2RTZJC-DOZQM9gW.js} +1 -1
  243. package/ui-dist/assets/{chunk-NQ4KR5QH-MUoGr46n.js → chunk-NQ4KR5QH-5Yr3U2k8.js} +1 -1
  244. package/ui-dist/assets/{chunk-QZHKN3VN-CQoI9Ouy.js → chunk-QZHKN3VN-CvKTufwF.js} +1 -1
  245. package/ui-dist/assets/{chunk-WL4C6EOR-DSJh3iDp.js → chunk-WL4C6EOR-IoEM0jyx.js} +1 -1
  246. package/ui-dist/assets/classDiagram-VBA2DB6C-JKk4tCW2.js +1 -0
  247. package/ui-dist/assets/classDiagram-v2-RAHNMMFH-JKk4tCW2.js +1 -0
  248. package/ui-dist/assets/clone-Onaweg8D.js +1 -0
  249. package/ui-dist/assets/{cose-bilkent-S5V4N54A-BPepglgB.js → cose-bilkent-S5V4N54A-CTvr1OFj.js} +1 -1
  250. package/ui-dist/assets/{dagre-KLK3FWXG-DhnHVZkt.js → dagre-KLK3FWXG-UZ-SNjVK.js} +1 -1
  251. package/ui-dist/assets/{diagram-E7M64L7V-DNvXtoOO.js → diagram-E7M64L7V-D7RAN0Hr.js} +1 -1
  252. package/ui-dist/assets/{diagram-IFDJBPK2-DhGlDTgn.js → diagram-IFDJBPK2-B4LViaFR.js} +1 -1
  253. package/ui-dist/assets/{diagram-P4PSJMXO-BmXEloWS.js → diagram-P4PSJMXO-CY1be7ak.js} +1 -1
  254. package/ui-dist/assets/{erDiagram-INFDFZHY-BTYVzaLM.js → erDiagram-INFDFZHY-Dca0KkvJ.js} +1 -1
  255. package/ui-dist/assets/{flowDiagram-PKNHOUZH-CqMNQUVv.js → flowDiagram-PKNHOUZH-i-qMvfwg.js} +1 -1
  256. package/ui-dist/assets/{ganttDiagram-A5KZAMGK-B2le_64a.js → ganttDiagram-A5KZAMGK-Wxq2lhbh.js} +1 -1
  257. package/ui-dist/assets/{gitGraphDiagram-K3NZZRJ6-BtxOBq5A.js → gitGraphDiagram-K3NZZRJ6-DwzgPlAY.js} +1 -1
  258. package/ui-dist/assets/{graph-C5E6qFfm.js → graph-BAqf89Tz.js} +1 -1
  259. package/ui-dist/assets/{index-Piq-IPXt.js → index-4eCzaLuY.js} +1 -1
  260. package/ui-dist/assets/{index-DT6UN2ec.js → index-8uu-nKqK.js} +1 -1
  261. package/ui-dist/assets/{index-T5NVZ3nR.js → index-B-1NEcI_.js} +1 -1
  262. package/ui-dist/assets/{index-D-MoarxG.js → index-B0b_3Eu5.js} +1 -1
  263. package/ui-dist/assets/{index-CZiP3FBQ.js → index-B8v0eZjP.js} +1 -1
  264. package/ui-dist/assets/{index-C1Ga66FM.js → index-BN7Moj3u.js} +1 -1
  265. package/ui-dist/assets/{index-xBUfBdQn.js → index-BSpxh3cY.js} +1 -1
  266. package/ui-dist/assets/{index-CQcMWp51.js → index-BY44RIi9.js} +1 -1
  267. package/ui-dist/assets/{index-3a93sZNI.js → index-BhyQJhdZ.js} +1 -1
  268. package/ui-dist/assets/{index-BsVDit5y.js → index-BkPL_iGU.js} +1 -1
  269. package/ui-dist/assets/{index-88lBSTsW.js → index-BsPfoHXS.js} +1 -1
  270. package/ui-dist/assets/{index-CyJtcUF0.js → index-BstW7nmv.js} +1 -1
  271. package/ui-dist/assets/{index-BvZ0Ptfl.js → index-BwB67Zyz.js} +1 -1
  272. package/ui-dist/assets/index-C2peSkmT.css +1 -0
  273. package/ui-dist/assets/{index-vkCrQLeX.js → index-C3ktOsS_.js} +1 -1
  274. package/ui-dist/assets/{index-D2hZpQJT.js → index-CMyABlS-.js} +1 -1
  275. package/ui-dist/assets/{index-C4WCPEY4.js → index-CyBJ8ujC.js} +1 -1
  276. package/ui-dist/assets/{index-Bf7NB_lK.js → index-DAxM2W3O.js} +1 -1
  277. package/ui-dist/assets/{index-Dq7H6-Lm.js → index-DVZXPmhk.js} +1 -1
  278. package/ui-dist/assets/{index-CskDu6A3.js → index-Dc19uAyw.js} +1 -1
  279. package/ui-dist/assets/index-DzHrwZu1.js +1511 -0
  280. package/ui-dist/assets/{index-B20JneLK.js → index-LJuf53Ye.js} +1 -1
  281. package/ui-dist/assets/{index-D6McTDMQ.js → index-Ugw5VWWz.js} +1 -1
  282. package/ui-dist/assets/{index-CcVGS6HJ.js → index-YGraEFR7.js} +1 -1
  283. package/ui-dist/assets/{infoDiagram-LFFYTUFH-BiCCZcIW.js → infoDiagram-LFFYTUFH-jLmDtFVR.js} +1 -1
  284. package/ui-dist/assets/{ishikawaDiagram-PHBUUO56-BiwBemM5.js → ishikawaDiagram-PHBUUO56-6OGMyLT8.js} +1 -1
  285. package/ui-dist/assets/{journeyDiagram-4ABVD52K-D8RGr2xl.js → journeyDiagram-4ABVD52K-yQjl6E0t.js} +1 -1
  286. package/ui-dist/assets/{kanban-definition-K7BYSVSG-C733Fj-E.js → kanban-definition-K7BYSVSG-DkdCeQlS.js} +1 -1
  287. package/ui-dist/assets/{layout-CM4c3NA_.js → layout-CqSYvZ_w.js} +1 -1
  288. package/ui-dist/assets/{linear-DzH21Xsf.js → linear-B8xGZaoi.js} +1 -1
  289. package/ui-dist/assets/{mermaid.core-Z2rpoVP2.js → mermaid.core-AKL_cdyk.js} +4 -4
  290. package/ui-dist/assets/{mindmap-definition-YRQLILUH-DylLLj9w.js → mindmap-definition-YRQLILUH-Zr-dXC0x.js} +1 -1
  291. package/ui-dist/assets/{pieDiagram-SKSYHLDU-617wI_rr.js → pieDiagram-SKSYHLDU-BvDAU-Nk.js} +1 -1
  292. package/ui-dist/assets/{quadrantDiagram-337W2JSQ-lxoCPJIL.js → quadrantDiagram-337W2JSQ-Dn9kM62o.js} +1 -1
  293. package/ui-dist/assets/{requirementDiagram-Z7DCOOCP-C5XydQ9-.js → requirementDiagram-Z7DCOOCP-GIsIh7Sd.js} +1 -1
  294. package/ui-dist/assets/{sankeyDiagram-WA2Y5GQK--grmq-Q8.js → sankeyDiagram-WA2Y5GQK-CUCuBkuf.js} +1 -1
  295. package/ui-dist/assets/{sequenceDiagram-2WXFIKYE-BS2PeYH-.js → sequenceDiagram-2WXFIKYE-MDpUY2HM.js} +1 -1
  296. package/ui-dist/assets/{stateDiagram-RAJIS63D-CeuZtj2z.js → stateDiagram-RAJIS63D-BymMpuUU.js} +1 -1
  297. package/ui-dist/assets/stateDiagram-v2-FVOUBMTO-Bi2oCU6d.js +1 -0
  298. package/ui-dist/assets/{timeline-definition-YZTLITO2-DxHdMpRr.js → timeline-definition-YZTLITO2-B6ofPhhy.js} +1 -1
  299. package/ui-dist/assets/{treemap-KZPCXAKY-Bv1ZlC5h.js → treemap-KZPCXAKY-DnLO6w1l.js} +1 -1
  300. package/ui-dist/assets/{vennDiagram-LZ73GAT5-DvpZSXY2.js → vennDiagram-LZ73GAT5-D0MyZIDl.js} +1 -1
  301. package/ui-dist/assets/{xychartDiagram-JWTSCODW-DttOu1GC.js → xychartDiagram-JWTSCODW-rADY1iUG.js} +1 -1
  302. package/ui-dist/index.html +2 -2
  303. package/ui-dist/assets/channel-DGUh6rEi.js +0 -1
  304. package/ui-dist/assets/classDiagram-VBA2DB6C-1ntk2IOV.js +0 -1
  305. package/ui-dist/assets/classDiagram-v2-RAHNMMFH-1ntk2IOV.js +0 -1
  306. package/ui-dist/assets/clone-BpddY88c.js +0 -1
  307. package/ui-dist/assets/index-C8AD6s7S.js +0 -1510
  308. package/ui-dist/assets/index-Ded0dPwB.css +0 -1
  309. package/ui-dist/assets/stateDiagram-v2-FVOUBMTO-DXq0yC5C.js +0 -1
@@ -1,1237 +1,5 @@
1
- import { spawn } from "node:child_process";
2
- import fs from "node:fs/promises";
3
- import net from "node:net";
4
- import { createHash, randomUUID } from "node:crypto";
5
- import path from "node:path";
6
- import { setTimeout as delay } from "node:timers/promises";
7
- import { ensureGitRepositoryIdentityConfig } from "@rudderhq/agent-runtime-utils/git-identity";
8
- import { workspaceRuntimeServices } from "@rudderhq/db";
9
- import { and, desc, eq, inArray } from "drizzle-orm";
10
- import { asNumber, asString, parseObject, renderTemplate } from "../agent-runtimes/utils.js";
11
- import { resolveHomeAwarePath } from "../home-paths.js";
12
- const runtimeServicesById = new Map();
13
- const runtimeServicesByReuseKey = new Map();
14
- const runtimeServiceLeasesByRun = new Map();
15
- function stableStringify(value) {
16
- if (Array.isArray(value)) {
17
- return `[${value.map((entry) => stableStringify(entry)).join(",")}]`;
18
- }
19
- if (value && typeof value === "object") {
20
- const rec = value;
21
- return `{${Object.keys(rec).sort().map((key) => `${JSON.stringify(key)}:${stableStringify(rec[key])}`).join(",")}}`;
22
- }
23
- return JSON.stringify(value);
24
- }
25
- export function sanitizeRuntimeServiceBaseEnv(baseEnv) {
26
- const env = { ...baseEnv };
27
- for (const key of Object.keys(env)) {
28
- if (key.startsWith("RUDDER_")) {
29
- delete env[key];
30
- }
31
- }
32
- delete env.DATABASE_URL;
33
- return env;
34
- }
35
- function stableRuntimeServiceId(input) {
36
- if (input.reportId)
37
- return input.reportId;
38
- const digest = createHash("sha256")
39
- .update(stableStringify({
40
- agentRuntimeType: input.agentRuntimeType,
41
- runId: input.runId,
42
- scopeType: input.scopeType,
43
- scopeId: input.scopeId,
44
- serviceName: input.serviceName,
45
- providerRef: input.providerRef,
46
- reuseKey: input.reuseKey,
47
- }))
48
- .digest("hex")
49
- .slice(0, 32);
50
- return `${input.agentRuntimeType}-${digest}`;
51
- }
52
- function toRuntimeServiceRef(record, overrides) {
53
- return {
54
- id: record.id,
55
- orgId: record.orgId,
56
- projectId: record.projectId,
57
- projectWorkspaceId: record.projectWorkspaceId,
58
- executionWorkspaceId: record.executionWorkspaceId,
59
- issueId: record.issueId,
60
- serviceName: record.serviceName,
61
- status: record.status,
62
- lifecycle: record.lifecycle,
63
- scopeType: record.scopeType,
64
- scopeId: record.scopeId,
65
- reuseKey: record.reuseKey,
66
- command: record.command,
67
- cwd: record.cwd,
68
- port: record.port,
69
- url: record.url,
70
- provider: record.provider,
71
- providerRef: record.providerRef,
72
- ownerAgentId: record.ownerAgentId,
73
- startedByRunId: record.startedByRunId,
74
- lastUsedAt: record.lastUsedAt,
75
- startedAt: record.startedAt,
76
- stoppedAt: record.stoppedAt,
77
- stopPolicy: record.stopPolicy,
78
- healthStatus: record.healthStatus,
79
- reused: record.reused,
80
- ...overrides,
81
- };
82
- }
83
- function sanitizeSlugPart(value, fallback) {
84
- const raw = (value ?? "").trim().toLowerCase();
85
- const normalized = raw
86
- .replace(/[^a-z0-9/_-]+/g, "-")
87
- .replace(/-+/g, "-")
88
- .replace(/^[-/]+|[-/]+$/g, "");
89
- return normalized.length > 0 ? normalized : fallback;
90
- }
91
- function renderWorkspaceTemplate(template, input) {
92
- const issueIdentifier = input.issue?.identifier ?? input.issue?.id ?? "issue";
93
- const slug = sanitizeSlugPart(input.issue?.title, sanitizeSlugPart(issueIdentifier, "issue"));
94
- return renderTemplate(template, {
95
- issue: {
96
- id: input.issue?.id ?? "",
97
- identifier: input.issue?.identifier ?? "",
98
- title: input.issue?.title ?? "",
99
- },
100
- agent: {
101
- id: input.agent.id,
102
- name: input.agent.name,
103
- },
104
- project: {
105
- id: input.projectId ?? "",
106
- },
107
- workspace: {
108
- repoRef: input.repoRef ?? "",
109
- },
110
- slug,
111
- });
112
- }
113
- function sanitizeBranchName(value) {
114
- return value
115
- .trim()
116
- .replace(/[^A-Za-z0-9._/-]+/g, "-")
117
- .replace(/-+/g, "-")
118
- .replace(/^[-/.]+|[-/.]+$/g, "")
119
- .slice(0, 120) || "rudder-work";
120
- }
121
- function isAbsolutePath(value) {
122
- return path.isAbsolute(value) || value.startsWith("~");
123
- }
124
- function resolveConfiguredPath(value, baseDir) {
125
- if (isAbsolutePath(value)) {
126
- return resolveHomeAwarePath(value);
127
- }
128
- return path.resolve(baseDir, value);
129
- }
130
- function formatCommandForDisplay(command, args) {
131
- return [command, ...args]
132
- .map((part) => (/^[A-Za-z0-9_./:-]+$/.test(part) ? part : JSON.stringify(part)))
133
- .join(" ");
134
- }
135
- async function executeProcess(input) {
136
- const proc = await new Promise((resolve, reject) => {
137
- const child = spawn(input.command, input.args, {
138
- cwd: input.cwd,
139
- stdio: ["ignore", "pipe", "pipe"],
140
- env: input.env ?? process.env,
141
- });
142
- let stdout = "";
143
- let stderr = "";
144
- child.stdout?.on("data", (chunk) => {
145
- stdout += String(chunk);
146
- });
147
- child.stderr?.on("data", (chunk) => {
148
- stderr += String(chunk);
149
- });
150
- child.on("error", reject);
151
- child.on("close", (code) => resolve({ stdout, stderr, code }));
152
- });
153
- return proc;
154
- }
155
- async function runGit(args, cwd) {
156
- const proc = await executeProcess({
157
- command: "git",
158
- args,
159
- cwd,
160
- });
161
- if (proc.code !== 0) {
162
- throw new Error(proc.stderr.trim() || proc.stdout.trim() || `git ${args.join(" ")} failed`);
163
- }
164
- return proc.stdout.trim();
165
- }
166
- function gitErrorIncludes(error, needle) {
167
- const message = error instanceof Error ? error.message : String(error);
168
- return message.toLowerCase().includes(needle.toLowerCase());
169
- }
170
- async function directoryExists(value) {
171
- return fs.stat(value).then((stats) => stats.isDirectory()).catch(() => false);
172
- }
173
- function terminateChildProcess(child) {
174
- if (!child.pid)
175
- return;
176
- if (process.platform !== "win32") {
177
- try {
178
- process.kill(-child.pid, "SIGTERM");
179
- return;
180
- }
181
- catch {
182
- // Fall through to the direct child kill.
183
- }
184
- }
185
- if (!child.killed) {
186
- child.kill("SIGTERM");
187
- }
188
- }
189
- function buildWorkspaceCommandEnv(input) {
190
- const env = { ...process.env };
191
- env.RUDDER_WORKSPACE_CWD = input.worktreePath;
192
- env.RUDDER_WORKSPACE_PATH = input.worktreePath;
193
- env.RUDDER_WORKSPACE_WORKTREE_PATH = input.worktreePath;
194
- env.RUDDER_WORKSPACE_BRANCH = input.branchName;
195
- env.RUDDER_WORKSPACE_BASE_CWD = input.base.baseCwd;
196
- env.RUDDER_WORKSPACE_REPO_ROOT = input.repoRoot;
197
- env.RUDDER_WORKSPACE_SOURCE = input.base.source;
198
- env.RUDDER_WORKSPACE_REPO_REF = input.base.repoRef ?? "";
199
- env.RUDDER_WORKSPACE_REPO_URL = input.base.repoUrl ?? "";
200
- env.RUDDER_WORKSPACE_CREATED = input.created ? "true" : "false";
201
- env.RUDDER_PROJECT_ID = input.base.projectId ?? "";
202
- env.RUDDER_PROJECT_WORKSPACE_ID = input.base.workspaceId ?? "";
203
- env.RUDDER_AGENT_ID = input.agent.id;
204
- env.RUDDER_AGENT_NAME = input.agent.name;
205
- env.RUDDER_ORG_ID = input.agent.orgId;
206
- env.RUDDER_ISSUE_ID = input.issue?.id ?? "";
207
- env.RUDDER_ISSUE_IDENTIFIER = input.issue?.identifier ?? "";
208
- env.RUDDER_ISSUE_TITLE = input.issue?.title ?? "";
209
- return env;
210
- }
211
- async function runWorkspaceCommand(input) {
212
- const shell = process.env.SHELL?.trim() || "/bin/sh";
213
- const proc = await executeProcess({
214
- command: shell,
215
- args: ["-c", input.command],
216
- cwd: input.cwd,
217
- env: input.env,
218
- });
219
- if (proc.code === 0)
220
- return;
221
- const details = [proc.stderr.trim(), proc.stdout.trim()].filter(Boolean).join("\n");
222
- throw new Error(details.length > 0
223
- ? `${input.label} failed: ${details}`
224
- : `${input.label} failed with exit code ${proc.code ?? -1}`);
225
- }
226
- async function recordGitOperation(recorder, input) {
227
- if (!recorder) {
228
- return runGit(input.args, input.cwd);
229
- }
230
- let stdout = "";
231
- let stderr = "";
232
- let code = null;
233
- await recorder.recordOperation({
234
- phase: input.phase,
235
- command: formatCommandForDisplay("git", input.args),
236
- cwd: input.cwd,
237
- metadata: input.metadata ?? null,
238
- run: async () => {
239
- const result = await executeProcess({
240
- command: "git",
241
- args: input.args,
242
- cwd: input.cwd,
243
- });
244
- stdout = result.stdout;
245
- stderr = result.stderr;
246
- code = result.code;
247
- return {
248
- status: result.code === 0 ? "succeeded" : "failed",
249
- exitCode: result.code,
250
- stdout: result.stdout,
251
- stderr: result.stderr,
252
- system: result.code === 0 ? input.successMessage ?? null : null,
253
- };
254
- },
255
- });
256
- if (code !== 0) {
257
- const details = [stderr.trim(), stdout.trim()].filter(Boolean).join("\n");
258
- throw new Error(details.length > 0
259
- ? `${input.failureLabel ?? `git ${input.args.join(" ")}`} failed: ${details}`
260
- : `${input.failureLabel ?? `git ${input.args.join(" ")}`} failed with exit code ${code ?? -1}`);
261
- }
262
- return stdout.trim();
263
- }
264
- async function recordWorkspaceCommandOperation(recorder, input) {
265
- if (!recorder) {
266
- await runWorkspaceCommand(input);
267
- return;
268
- }
269
- let stdout = "";
270
- let stderr = "";
271
- let code = null;
272
- await recorder.recordOperation({
273
- phase: input.phase,
274
- command: input.command,
275
- cwd: input.cwd,
276
- metadata: input.metadata ?? null,
277
- run: async () => {
278
- const shell = process.env.SHELL?.trim() || "/bin/sh";
279
- const result = await executeProcess({
280
- command: shell,
281
- args: ["-c", input.command],
282
- cwd: input.cwd,
283
- env: input.env,
284
- });
285
- stdout = result.stdout;
286
- stderr = result.stderr;
287
- code = result.code;
288
- return {
289
- status: result.code === 0 ? "succeeded" : "failed",
290
- exitCode: result.code,
291
- stdout: result.stdout,
292
- stderr: result.stderr,
293
- system: result.code === 0 ? input.successMessage ?? null : null,
294
- };
295
- },
296
- });
297
- if (code === 0)
298
- return;
299
- const details = [stderr.trim(), stdout.trim()].filter(Boolean).join("\n");
300
- throw new Error(details.length > 0
301
- ? `${input.label} failed: ${details}`
302
- : `${input.label} failed with exit code ${code ?? -1}`);
303
- }
304
- async function provisionExecutionWorktree(input) {
305
- await ensureGitRepositoryIdentityConfig({ cwd: input.worktreePath });
306
- const provisionCommand = asString(input.strategy.provisionCommand, "").trim();
307
- if (!provisionCommand)
308
- return;
309
- await recordWorkspaceCommandOperation(input.recorder, {
310
- phase: "workspace_provision",
311
- command: provisionCommand,
312
- cwd: input.worktreePath,
313
- env: buildWorkspaceCommandEnv({
314
- base: input.base,
315
- repoRoot: input.repoRoot,
316
- worktreePath: input.worktreePath,
317
- branchName: input.branchName,
318
- issue: input.issue,
319
- agent: input.agent,
320
- created: input.created,
321
- }),
322
- label: `Execution workspace provision command "${provisionCommand}"`,
323
- metadata: {
324
- repoRoot: input.repoRoot,
325
- worktreePath: input.worktreePath,
326
- branchName: input.branchName,
327
- created: input.created,
328
- },
329
- successMessage: `Provisioned workspace at ${input.worktreePath}\n`,
330
- });
331
- }
332
- function buildExecutionWorkspaceCleanupEnv(input) {
333
- const env = sanitizeRuntimeServiceBaseEnv(process.env);
334
- env.RUDDER_WORKSPACE_CWD = input.workspace.cwd ?? "";
335
- env.RUDDER_WORKSPACE_PATH = input.workspace.cwd ?? "";
336
- env.RUDDER_WORKSPACE_WORKTREE_PATH =
337
- input.workspace.providerRef ?? input.workspace.cwd ?? "";
338
- env.RUDDER_WORKSPACE_BRANCH = input.workspace.branchName ?? "";
339
- env.RUDDER_WORKSPACE_BASE_CWD = input.projectWorkspaceCwd ?? "";
340
- env.RUDDER_WORKSPACE_REPO_ROOT = input.projectWorkspaceCwd ?? "";
341
- env.RUDDER_WORKSPACE_REPO_URL = input.workspace.repoUrl ?? "";
342
- env.RUDDER_WORKSPACE_REPO_REF = input.workspace.baseRef ?? "";
343
- env.RUDDER_PROJECT_ID = input.workspace.projectId ?? "";
344
- env.RUDDER_PROJECT_WORKSPACE_ID = input.workspace.projectWorkspaceId ?? "";
345
- env.RUDDER_ISSUE_ID = input.workspace.sourceIssueId ?? "";
346
- return env;
347
- }
348
- async function resolveGitRepoRootForWorkspaceCleanup(worktreePath, projectWorkspaceCwd) {
349
- if (projectWorkspaceCwd) {
350
- const resolvedProjectWorkspaceCwd = path.resolve(projectWorkspaceCwd);
351
- const gitDir = await runGit(["rev-parse", "--git-common-dir"], resolvedProjectWorkspaceCwd)
352
- .catch(() => null);
353
- if (gitDir) {
354
- const resolvedGitDir = path.resolve(resolvedProjectWorkspaceCwd, gitDir);
355
- return path.dirname(resolvedGitDir);
356
- }
357
- }
358
- const gitDir = await runGit(["rev-parse", "--git-common-dir"], worktreePath).catch(() => null);
359
- if (!gitDir)
360
- return null;
361
- const resolvedGitDir = path.resolve(worktreePath, gitDir);
362
- return path.dirname(resolvedGitDir);
363
- }
364
- export async function realizeExecutionWorkspace(input) {
365
- const rawStrategy = parseObject(input.config.workspaceStrategy);
366
- const strategyType = asString(rawStrategy.type, "project_primary");
367
- if (strategyType !== "git_worktree") {
368
- return {
369
- ...input.base,
370
- strategy: "project_primary",
371
- cwd: input.base.baseCwd,
372
- branchName: null,
373
- worktreePath: null,
374
- warnings: [],
375
- created: false,
376
- };
377
- }
378
- const repoRoot = await runGit(["rev-parse", "--show-toplevel"], input.base.baseCwd);
379
- const branchTemplate = asString(rawStrategy.branchTemplate, "{{issue.identifier}}-{{slug}}");
380
- const renderedBranch = renderWorkspaceTemplate(branchTemplate, {
381
- issue: input.issue,
382
- agent: input.agent,
383
- projectId: input.base.projectId,
384
- repoRef: input.base.repoRef,
385
- });
386
- const branchName = sanitizeBranchName(renderedBranch);
387
- const configuredParentDir = asString(rawStrategy.worktreeParentDir, "");
388
- const worktreeParentDir = configuredParentDir
389
- ? resolveConfiguredPath(configuredParentDir, repoRoot)
390
- : path.join(repoRoot, ".rudder", "worktrees");
391
- const worktreePath = path.join(worktreeParentDir, branchName);
392
- const baseRef = asString(rawStrategy.baseRef, input.base.repoRef ?? "HEAD");
393
- await fs.mkdir(worktreeParentDir, { recursive: true });
394
- const existingWorktree = await directoryExists(worktreePath);
395
- if (existingWorktree) {
396
- const existingGitDir = await runGit(["rev-parse", "--git-dir"], worktreePath).catch(() => null);
397
- if (existingGitDir) {
398
- if (input.recorder) {
399
- await input.recorder.recordOperation({
400
- phase: "worktree_prepare",
401
- cwd: repoRoot,
402
- metadata: {
403
- repoRoot,
404
- worktreePath,
405
- branchName,
406
- baseRef,
407
- created: false,
408
- reused: true,
409
- },
410
- run: async () => ({
411
- status: "succeeded",
412
- exitCode: 0,
413
- system: `Reused existing git worktree at ${worktreePath}\n`,
414
- }),
415
- });
416
- }
417
- await provisionExecutionWorktree({
418
- strategy: rawStrategy,
419
- base: input.base,
420
- repoRoot,
421
- worktreePath,
422
- branchName,
423
- issue: input.issue,
424
- agent: input.agent,
425
- created: false,
426
- recorder: input.recorder ?? null,
427
- });
428
- return {
429
- ...input.base,
430
- strategy: "git_worktree",
431
- cwd: worktreePath,
432
- branchName,
433
- worktreePath,
434
- warnings: [],
435
- created: false,
436
- };
437
- }
438
- throw new Error(`Configured worktree path "${worktreePath}" already exists and is not a git worktree.`);
439
- }
440
- try {
441
- await recordGitOperation(input.recorder, {
442
- phase: "worktree_prepare",
443
- args: ["worktree", "add", "-b", branchName, worktreePath, baseRef],
444
- cwd: repoRoot,
445
- metadata: {
446
- repoRoot,
447
- worktreePath,
448
- branchName,
449
- baseRef,
450
- created: true,
451
- },
452
- successMessage: `Created git worktree at ${worktreePath}\n`,
453
- failureLabel: `git worktree add ${worktreePath}`,
454
- });
455
- }
456
- catch (error) {
457
- if (!gitErrorIncludes(error, "already exists")) {
458
- throw error;
459
- }
460
- await recordGitOperation(input.recorder, {
461
- phase: "worktree_prepare",
462
- args: ["worktree", "add", worktreePath, branchName],
463
- cwd: repoRoot,
464
- metadata: {
465
- repoRoot,
466
- worktreePath,
467
- branchName,
468
- baseRef,
469
- created: false,
470
- reusedExistingBranch: true,
471
- },
472
- successMessage: `Attached existing branch ${branchName} at ${worktreePath}\n`,
473
- failureLabel: `git worktree add ${worktreePath}`,
474
- });
475
- }
476
- await provisionExecutionWorktree({
477
- strategy: rawStrategy,
478
- base: input.base,
479
- repoRoot,
480
- worktreePath,
481
- branchName,
482
- issue: input.issue,
483
- agent: input.agent,
484
- created: true,
485
- recorder: input.recorder ?? null,
486
- });
487
- return {
488
- ...input.base,
489
- strategy: "git_worktree",
490
- cwd: worktreePath,
491
- branchName,
492
- worktreePath,
493
- warnings: [],
494
- created: true,
495
- };
496
- }
497
- export async function cleanupExecutionWorkspaceArtifacts(input) {
498
- const warnings = [];
499
- const workspacePath = input.workspace.providerRef ?? input.workspace.cwd;
500
- const cleanupEnv = buildExecutionWorkspaceCleanupEnv({
501
- workspace: input.workspace,
502
- projectWorkspaceCwd: input.projectWorkspace?.cwd ?? null,
503
- });
504
- const createdByRuntime = input.workspace.metadata?.createdByRuntime === true;
505
- const cleanupCommands = [
506
- input.projectWorkspace?.cleanupCommand ?? null,
507
- input.teardownCommand ?? null,
508
- ]
509
- .map((value) => asString(value, "").trim())
510
- .filter(Boolean);
511
- for (const command of cleanupCommands) {
512
- try {
513
- await recordWorkspaceCommandOperation(input.recorder, {
514
- phase: "workspace_teardown",
515
- command,
516
- cwd: workspacePath ?? input.projectWorkspace?.cwd ?? process.cwd(),
517
- env: cleanupEnv,
518
- label: `Execution workspace cleanup command "${command}"`,
519
- metadata: {
520
- workspaceId: input.workspace.id,
521
- workspacePath,
522
- branchName: input.workspace.branchName,
523
- providerType: input.workspace.providerType,
524
- },
525
- successMessage: `Completed cleanup command "${command}"\n`,
526
- });
527
- }
528
- catch (err) {
529
- warnings.push(err instanceof Error ? err.message : String(err));
530
- }
531
- }
532
- if (input.workspace.providerType === "git_worktree" && workspacePath) {
533
- const repoRoot = await resolveGitRepoRootForWorkspaceCleanup(workspacePath, input.projectWorkspace?.cwd ?? null);
534
- const worktreeExists = await directoryExists(workspacePath);
535
- if (worktreeExists) {
536
- if (!repoRoot) {
537
- warnings.push(`Could not resolve git repo root for "${workspacePath}".`);
538
- }
539
- else {
540
- try {
541
- await recordGitOperation(input.recorder, {
542
- phase: "worktree_cleanup",
543
- args: ["worktree", "remove", "--force", workspacePath],
544
- cwd: repoRoot,
545
- metadata: {
546
- workspaceId: input.workspace.id,
547
- workspacePath,
548
- branchName: input.workspace.branchName,
549
- cleanupAction: "worktree_remove",
550
- },
551
- successMessage: `Removed git worktree ${workspacePath}\n`,
552
- failureLabel: `git worktree remove ${workspacePath}`,
553
- });
554
- }
555
- catch (err) {
556
- warnings.push(err instanceof Error ? err.message : String(err));
557
- }
558
- }
559
- }
560
- if (createdByRuntime && input.workspace.branchName) {
561
- if (!repoRoot) {
562
- warnings.push(`Could not resolve git repo root to delete branch "${input.workspace.branchName}".`);
563
- }
564
- else {
565
- try {
566
- await recordGitOperation(input.recorder, {
567
- phase: "worktree_cleanup",
568
- args: ["branch", "-d", input.workspace.branchName],
569
- cwd: repoRoot,
570
- metadata: {
571
- workspaceId: input.workspace.id,
572
- workspacePath,
573
- branchName: input.workspace.branchName,
574
- cleanupAction: "branch_delete",
575
- },
576
- successMessage: `Deleted branch ${input.workspace.branchName}\n`,
577
- failureLabel: `git branch -d ${input.workspace.branchName}`,
578
- });
579
- }
580
- catch (err) {
581
- const message = err instanceof Error ? err.message : String(err);
582
- warnings.push(`Skipped deleting branch "${input.workspace.branchName}": ${message}`);
583
- }
584
- }
585
- }
586
- }
587
- else if (input.workspace.providerType === "local_fs" && createdByRuntime && workspacePath) {
588
- const projectWorkspaceCwd = input.projectWorkspace?.cwd ? path.resolve(input.projectWorkspace.cwd) : null;
589
- const resolvedWorkspacePath = path.resolve(workspacePath);
590
- const containsProjectWorkspace = projectWorkspaceCwd
591
- ? (resolvedWorkspacePath === projectWorkspaceCwd ||
592
- projectWorkspaceCwd.startsWith(`${resolvedWorkspacePath}${path.sep}`))
593
- : false;
594
- if (containsProjectWorkspace) {
595
- warnings.push(`Refusing to remove path "${workspacePath}" because it contains the project workspace.`);
596
- }
597
- else {
598
- await fs.rm(resolvedWorkspacePath, { recursive: true, force: true });
599
- if (input.recorder) {
600
- await input.recorder.recordOperation({
601
- phase: "workspace_teardown",
602
- cwd: projectWorkspaceCwd ?? process.cwd(),
603
- metadata: {
604
- workspaceId: input.workspace.id,
605
- workspacePath: resolvedWorkspacePath,
606
- cleanupAction: "remove_local_fs",
607
- },
608
- run: async () => ({
609
- status: "succeeded",
610
- exitCode: 0,
611
- system: `Removed local workspace directory ${resolvedWorkspacePath}\n`,
612
- }),
613
- });
614
- }
615
- }
616
- }
617
- const cleaned = !workspacePath ||
618
- !(await directoryExists(workspacePath));
619
- return {
620
- cleanedPath: workspacePath,
621
- cleaned,
622
- warnings,
623
- };
624
- }
625
- async function allocatePort() {
626
- return await new Promise((resolve, reject) => {
627
- const server = net.createServer();
628
- server.listen(0, "127.0.0.1", () => {
629
- const address = server.address();
630
- server.close((err) => {
631
- if (err) {
632
- reject(err);
633
- return;
634
- }
635
- if (!address || typeof address === "string") {
636
- reject(new Error("Failed to allocate port"));
637
- return;
638
- }
639
- resolve(address.port);
640
- });
641
- });
642
- server.on("error", reject);
643
- });
644
- }
645
- function buildTemplateData(input) {
646
- return {
647
- workspace: {
648
- cwd: input.workspace.cwd,
649
- branchName: input.workspace.branchName ?? "",
650
- worktreePath: input.workspace.worktreePath ?? "",
651
- repoUrl: input.workspace.repoUrl ?? "",
652
- repoRef: input.workspace.repoRef ?? "",
653
- env: input.adapterEnv,
654
- },
655
- issue: {
656
- id: input.issue?.id ?? "",
657
- identifier: input.issue?.identifier ?? "",
658
- title: input.issue?.title ?? "",
659
- },
660
- agent: {
661
- id: input.agent.id,
662
- name: input.agent.name,
663
- },
664
- port: input.port ?? "",
665
- };
666
- }
667
- function resolveServiceScopeId(input) {
668
- const scopeTypeRaw = asString(input.service.reuseScope, input.service.lifecycle === "shared" ? "project_workspace" : "run");
669
- const scopeType = scopeTypeRaw === "project_workspace" ||
670
- scopeTypeRaw === "execution_workspace" ||
671
- scopeTypeRaw === "agent"
672
- ? scopeTypeRaw
673
- : "run";
674
- if (scopeType === "project_workspace")
675
- return { scopeType, scopeId: input.workspace.workspaceId ?? input.workspace.projectId };
676
- if (scopeType === "execution_workspace") {
677
- return { scopeType, scopeId: input.executionWorkspaceId ?? input.workspace.cwd };
678
- }
679
- if (scopeType === "agent")
680
- return { scopeType, scopeId: input.agent.id };
681
- return { scopeType: "run", scopeId: input.runId };
682
- }
683
- async function waitForReadiness(input) {
684
- const readiness = parseObject(input.service.readiness);
685
- const readinessType = asString(readiness.type, "");
686
- if (readinessType !== "http" || !input.url)
687
- return;
688
- const timeoutSec = Math.max(1, asNumber(readiness.timeoutSec, 30));
689
- const intervalMs = Math.max(100, asNumber(readiness.intervalMs, 500));
690
- const deadline = Date.now() + timeoutSec * 1000;
691
- let lastError = "service did not become ready";
692
- while (Date.now() < deadline) {
693
- try {
694
- const response = await fetch(input.url);
695
- if (response.ok)
696
- return;
697
- lastError = `received HTTP ${response.status}`;
698
- }
699
- catch (err) {
700
- lastError = err instanceof Error ? err.message : String(err);
701
- }
702
- await delay(intervalMs);
703
- }
704
- throw new Error(`Readiness check failed for ${input.url}: ${lastError}`);
705
- }
706
- function toPersistedWorkspaceRuntimeService(record) {
707
- return {
708
- id: record.id,
709
- orgId: record.orgId,
710
- projectId: record.projectId,
711
- projectWorkspaceId: record.projectWorkspaceId,
712
- executionWorkspaceId: record.executionWorkspaceId,
713
- issueId: record.issueId,
714
- scopeType: record.scopeType,
715
- scopeId: record.scopeId,
716
- serviceName: record.serviceName,
717
- status: record.status,
718
- lifecycle: record.lifecycle,
719
- reuseKey: record.reuseKey,
720
- command: record.command,
721
- cwd: record.cwd,
722
- port: record.port,
723
- url: record.url,
724
- provider: record.provider,
725
- providerRef: record.providerRef,
726
- ownerAgentId: record.ownerAgentId,
727
- startedByRunId: record.startedByRunId,
728
- lastUsedAt: new Date(record.lastUsedAt),
729
- startedAt: new Date(record.startedAt),
730
- stoppedAt: record.stoppedAt ? new Date(record.stoppedAt) : null,
731
- stopPolicy: record.stopPolicy,
732
- healthStatus: record.healthStatus,
733
- updatedAt: new Date(),
734
- };
735
- }
736
- async function persistRuntimeServiceRecord(db, record) {
737
- if (!db)
738
- return;
739
- const values = toPersistedWorkspaceRuntimeService(record);
740
- await db
741
- .insert(workspaceRuntimeServices)
742
- .values(values)
743
- .onConflictDoUpdate({
744
- target: workspaceRuntimeServices.id,
745
- set: {
746
- projectId: values.projectId,
747
- projectWorkspaceId: values.projectWorkspaceId,
748
- executionWorkspaceId: values.executionWorkspaceId,
749
- issueId: values.issueId,
750
- scopeType: values.scopeType,
751
- scopeId: values.scopeId,
752
- serviceName: values.serviceName,
753
- status: values.status,
754
- lifecycle: values.lifecycle,
755
- reuseKey: values.reuseKey,
756
- command: values.command,
757
- cwd: values.cwd,
758
- port: values.port,
759
- url: values.url,
760
- provider: values.provider,
761
- providerRef: values.providerRef,
762
- ownerAgentId: values.ownerAgentId,
763
- startedByRunId: values.startedByRunId,
764
- lastUsedAt: values.lastUsedAt,
765
- startedAt: values.startedAt,
766
- stoppedAt: values.stoppedAt,
767
- stopPolicy: values.stopPolicy,
768
- healthStatus: values.healthStatus,
769
- updatedAt: values.updatedAt,
770
- },
771
- });
772
- }
773
- function clearIdleTimer(record) {
774
- if (!record.idleTimer)
775
- return;
776
- clearTimeout(record.idleTimer);
777
- record.idleTimer = null;
778
- }
779
- export function normalizeAdapterManagedRuntimeServices(input) {
780
- const nowIso = (input.now ?? new Date()).toISOString();
781
- return input.reports.map((report) => {
782
- const scopeType = report.scopeType ?? "run";
783
- const scopeId = report.scopeId ??
784
- (scopeType === "project_workspace"
785
- ? input.workspace.workspaceId
786
- : scopeType === "execution_workspace"
787
- ? input.executionWorkspaceId ?? input.workspace.cwd
788
- : scopeType === "agent"
789
- ? input.agent.id
790
- : input.runId) ??
791
- null;
792
- const serviceName = asString(report.serviceName, "").trim() || "service";
793
- const status = report.status ?? "running";
794
- const lifecycle = report.lifecycle ?? "ephemeral";
795
- const healthStatus = report.healthStatus ??
796
- (status === "running" ? "healthy" : status === "failed" ? "unhealthy" : "unknown");
797
- return {
798
- id: stableRuntimeServiceId({
799
- agentRuntimeType: input.agentRuntimeType,
800
- runId: input.runId,
801
- scopeType,
802
- scopeId,
803
- serviceName,
804
- reportId: report.id ?? null,
805
- providerRef: report.providerRef ?? null,
806
- reuseKey: report.reuseKey ?? null,
807
- }),
808
- orgId: input.agent.orgId,
809
- projectId: report.projectId ?? input.workspace.projectId,
810
- projectWorkspaceId: report.projectWorkspaceId ?? input.workspace.workspaceId,
811
- executionWorkspaceId: input.executionWorkspaceId ?? null,
812
- issueId: report.issueId ?? input.issue?.id ?? null,
813
- serviceName,
814
- status,
815
- lifecycle,
816
- scopeType,
817
- scopeId,
818
- reuseKey: report.reuseKey ?? null,
819
- command: report.command ?? null,
820
- cwd: report.cwd ?? null,
821
- port: report.port ?? null,
822
- url: report.url ?? null,
823
- provider: "adapter_managed",
824
- providerRef: report.providerRef ?? null,
825
- ownerAgentId: report.ownerAgentId ?? input.agent.id,
826
- startedByRunId: input.runId,
827
- lastUsedAt: nowIso,
828
- startedAt: nowIso,
829
- stoppedAt: status === "running" || status === "starting" ? null : nowIso,
830
- stopPolicy: report.stopPolicy ?? null,
831
- healthStatus,
832
- reused: false,
833
- };
834
- });
835
- }
836
- async function startLocalRuntimeService(input) {
837
- const serviceName = asString(input.service.name, "service");
838
- const lifecycle = asString(input.service.lifecycle, "shared") === "ephemeral" ? "ephemeral" : "shared";
839
- const command = asString(input.service.command, "");
840
- if (!command)
841
- throw new Error(`Runtime service "${serviceName}" is missing command`);
842
- const serviceCwdTemplate = asString(input.service.cwd, ".");
843
- const portConfig = parseObject(input.service.port);
844
- const port = asString(portConfig.type, "") === "auto" ? await allocatePort() : null;
845
- const envConfig = parseObject(input.service.env);
846
- const templateData = buildTemplateData({
847
- workspace: input.workspace,
848
- agent: input.agent,
849
- issue: input.issue,
850
- adapterEnv: input.adapterEnv,
851
- port,
852
- });
853
- const serviceCwd = resolveConfiguredPath(renderTemplate(serviceCwdTemplate, templateData), input.workspace.cwd);
854
- const env = {
855
- ...sanitizeRuntimeServiceBaseEnv(process.env),
856
- ...input.adapterEnv,
857
- };
858
- for (const [key, value] of Object.entries(envConfig)) {
859
- if (typeof value === "string") {
860
- env[key] = renderTemplate(value, templateData);
861
- }
862
- }
863
- if (port) {
864
- const portEnvKey = asString(portConfig.envKey, "PORT");
865
- env[portEnvKey] = String(port);
866
- }
867
- const shell = process.env.SHELL?.trim() || "/bin/sh";
868
- const child = spawn(shell, ["-lc", command], {
869
- cwd: serviceCwd,
870
- env,
871
- detached: process.platform !== "win32",
872
- stdio: ["ignore", "pipe", "pipe"],
873
- });
874
- let stderrExcerpt = "";
875
- let stdoutExcerpt = "";
876
- child.stdout?.on("data", async (chunk) => {
877
- const text = String(chunk);
878
- stdoutExcerpt = (stdoutExcerpt + text).slice(-4096);
879
- if (input.onLog)
880
- await input.onLog("stdout", `[service:${serviceName}] ${text}`);
881
- });
882
- child.stderr?.on("data", async (chunk) => {
883
- const text = String(chunk);
884
- stderrExcerpt = (stderrExcerpt + text).slice(-4096);
885
- if (input.onLog)
886
- await input.onLog("stderr", `[service:${serviceName}] ${text}`);
887
- });
888
- const expose = parseObject(input.service.expose);
889
- const readiness = parseObject(input.service.readiness);
890
- const urlTemplate = asString(expose.urlTemplate, "") ||
891
- asString(readiness.urlTemplate, "");
892
- const url = urlTemplate ? renderTemplate(urlTemplate, templateData) : null;
893
- try {
894
- await waitForReadiness({ service: input.service, url });
895
- }
896
- catch (err) {
897
- terminateChildProcess(child);
898
- throw new Error(`Failed to start runtime service "${serviceName}": ${err instanceof Error ? err.message : String(err)}${stderrExcerpt ? ` | stderr: ${stderrExcerpt.trim()}` : ""}`);
899
- }
900
- const envFingerprint = createHash("sha256").update(stableStringify(envConfig)).digest("hex");
901
- return {
902
- id: randomUUID(),
903
- orgId: input.agent.orgId,
904
- projectId: input.workspace.projectId,
905
- projectWorkspaceId: input.workspace.workspaceId,
906
- executionWorkspaceId: input.executionWorkspaceId ?? null,
907
- issueId: input.issue?.id ?? null,
908
- serviceName,
909
- status: "running",
910
- lifecycle,
911
- scopeType: input.scopeType,
912
- scopeId: input.scopeId,
913
- reuseKey: input.reuseKey,
914
- command,
915
- cwd: serviceCwd,
916
- port,
917
- url,
918
- provider: "local_process",
919
- providerRef: child.pid ? String(child.pid) : null,
920
- ownerAgentId: input.agent.id,
921
- startedByRunId: input.runId,
922
- lastUsedAt: new Date().toISOString(),
923
- startedAt: new Date().toISOString(),
924
- stoppedAt: null,
925
- stopPolicy: parseObject(input.service.stopPolicy),
926
- healthStatus: "healthy",
927
- reused: false,
928
- db: input.db,
929
- child,
930
- leaseRunIds: new Set([input.runId]),
931
- idleTimer: null,
932
- envFingerprint,
933
- };
934
- }
935
- function scheduleIdleStop(record) {
936
- clearIdleTimer(record);
937
- const stopType = asString(record.stopPolicy?.type, "manual");
938
- if (stopType !== "idle_timeout")
939
- return;
940
- const idleSeconds = Math.max(1, asNumber(record.stopPolicy?.idleSeconds, 1800));
941
- record.idleTimer = setTimeout(() => {
942
- stopRuntimeService(record.id).catch(() => undefined);
943
- }, idleSeconds * 1000);
944
- }
945
- async function stopRuntimeService(serviceId) {
946
- const record = runtimeServicesById.get(serviceId);
947
- if (!record)
948
- return;
949
- clearIdleTimer(record);
950
- record.status = "stopped";
951
- record.lastUsedAt = new Date().toISOString();
952
- record.stoppedAt = new Date().toISOString();
953
- if (record.child && record.child.pid) {
954
- terminateChildProcess(record.child);
955
- }
956
- runtimeServicesById.delete(serviceId);
957
- if (record.reuseKey) {
958
- runtimeServicesByReuseKey.delete(record.reuseKey);
959
- }
960
- await persistRuntimeServiceRecord(record.db, record);
961
- }
962
- async function markPersistedRuntimeServicesStoppedForExecutionWorkspace(input) {
963
- const now = new Date();
964
- await input.db
965
- .update(workspaceRuntimeServices)
966
- .set({
967
- status: "stopped",
968
- healthStatus: "unknown",
969
- stoppedAt: now,
970
- lastUsedAt: now,
971
- updatedAt: now,
972
- })
973
- .where(and(eq(workspaceRuntimeServices.executionWorkspaceId, input.executionWorkspaceId), inArray(workspaceRuntimeServices.status, ["starting", "running"])));
974
- }
975
- function registerRuntimeService(db, record) {
976
- record.db = db;
977
- runtimeServicesById.set(record.id, record);
978
- if (record.reuseKey) {
979
- runtimeServicesByReuseKey.set(record.reuseKey, record.id);
980
- }
981
- record.child?.on("exit", (code, signal) => {
982
- const current = runtimeServicesById.get(record.id);
983
- if (!current)
984
- return;
985
- clearIdleTimer(current);
986
- current.status = code === 0 || signal === "SIGTERM" ? "stopped" : "failed";
987
- current.healthStatus = current.status === "failed" ? "unhealthy" : "unknown";
988
- current.lastUsedAt = new Date().toISOString();
989
- current.stoppedAt = new Date().toISOString();
990
- runtimeServicesById.delete(current.id);
991
- if (current.reuseKey && runtimeServicesByReuseKey.get(current.reuseKey) === current.id) {
992
- runtimeServicesByReuseKey.delete(current.reuseKey);
993
- }
994
- void persistRuntimeServiceRecord(db, current);
995
- });
996
- }
997
- export async function ensureRuntimeServicesForRun(input) {
998
- const runtime = parseObject(input.config.workspaceRuntime);
999
- const rawServices = Array.isArray(runtime.services)
1000
- ? runtime.services.filter((entry) => typeof entry === "object" && entry !== null)
1001
- : [];
1002
- const acquiredServiceIds = [];
1003
- const refs = [];
1004
- runtimeServiceLeasesByRun.set(input.runId, acquiredServiceIds);
1005
- try {
1006
- for (const service of rawServices) {
1007
- const lifecycle = asString(service.lifecycle, "shared") === "ephemeral" ? "ephemeral" : "shared";
1008
- const { scopeType, scopeId } = resolveServiceScopeId({
1009
- service,
1010
- workspace: input.workspace,
1011
- executionWorkspaceId: input.executionWorkspaceId,
1012
- issue: input.issue,
1013
- runId: input.runId,
1014
- agent: input.agent,
1015
- });
1016
- const envConfig = parseObject(service.env);
1017
- const envFingerprint = createHash("sha256").update(stableStringify(envConfig)).digest("hex");
1018
- const serviceName = asString(service.name, "service");
1019
- const reuseKey = lifecycle === "shared"
1020
- ? [scopeType, scopeId ?? "", serviceName, envFingerprint].join(":")
1021
- : null;
1022
- if (reuseKey) {
1023
- const existingId = runtimeServicesByReuseKey.get(reuseKey);
1024
- const existing = existingId ? runtimeServicesById.get(existingId) : null;
1025
- if (existing && existing.status === "running") {
1026
- existing.leaseRunIds.add(input.runId);
1027
- existing.lastUsedAt = new Date().toISOString();
1028
- existing.stoppedAt = null;
1029
- clearIdleTimer(existing);
1030
- await persistRuntimeServiceRecord(input.db, existing);
1031
- acquiredServiceIds.push(existing.id);
1032
- refs.push(toRuntimeServiceRef(existing, { reused: true }));
1033
- continue;
1034
- }
1035
- }
1036
- const record = await startLocalRuntimeService({
1037
- db: input.db,
1038
- runId: input.runId,
1039
- agent: input.agent,
1040
- issue: input.issue,
1041
- workspace: input.workspace,
1042
- executionWorkspaceId: input.executionWorkspaceId,
1043
- adapterEnv: input.adapterEnv,
1044
- service,
1045
- onLog: input.onLog,
1046
- reuseKey,
1047
- scopeType,
1048
- scopeId,
1049
- });
1050
- registerRuntimeService(input.db, record);
1051
- await persistRuntimeServiceRecord(input.db, record);
1052
- acquiredServiceIds.push(record.id);
1053
- refs.push(toRuntimeServiceRef(record));
1054
- }
1055
- }
1056
- catch (err) {
1057
- await releaseRuntimeServicesForRun(input.runId);
1058
- throw err;
1059
- }
1060
- return refs;
1061
- }
1062
- export async function releaseRuntimeServicesForRun(runId) {
1063
- const acquired = runtimeServiceLeasesByRun.get(runId) ?? [];
1064
- runtimeServiceLeasesByRun.delete(runId);
1065
- for (const serviceId of acquired) {
1066
- const record = runtimeServicesById.get(serviceId);
1067
- if (!record)
1068
- continue;
1069
- record.leaseRunIds.delete(runId);
1070
- record.lastUsedAt = new Date().toISOString();
1071
- const stopType = asString(record.stopPolicy?.type, record.lifecycle === "ephemeral" ? "on_run_finish" : "manual");
1072
- await persistRuntimeServiceRecord(record.db, record);
1073
- if (record.leaseRunIds.size === 0) {
1074
- if (record.lifecycle === "ephemeral" || stopType === "on_run_finish") {
1075
- await stopRuntimeService(serviceId);
1076
- continue;
1077
- }
1078
- scheduleIdleStop(record);
1079
- }
1080
- }
1081
- }
1082
- export async function stopRuntimeServicesForExecutionWorkspace(input) {
1083
- const normalizedWorkspaceCwd = input.workspaceCwd ? path.resolve(input.workspaceCwd) : null;
1084
- const matchingServiceIds = Array.from(runtimeServicesById.values())
1085
- .filter((record) => {
1086
- if (record.executionWorkspaceId === input.executionWorkspaceId)
1087
- return true;
1088
- if (!normalizedWorkspaceCwd || !record.cwd)
1089
- return false;
1090
- const resolvedCwd = path.resolve(record.cwd);
1091
- return (resolvedCwd === normalizedWorkspaceCwd ||
1092
- resolvedCwd.startsWith(`${normalizedWorkspaceCwd}${path.sep}`));
1093
- })
1094
- .map((record) => record.id);
1095
- for (const serviceId of matchingServiceIds) {
1096
- await stopRuntimeService(serviceId);
1097
- }
1098
- if (input.db) {
1099
- await markPersistedRuntimeServicesStoppedForExecutionWorkspace({
1100
- db: input.db,
1101
- executionWorkspaceId: input.executionWorkspaceId,
1102
- });
1103
- }
1104
- }
1105
- export async function listWorkspaceRuntimeServicesForProjectWorkspaces(db, orgId, projectWorkspaceIds) {
1106
- if (projectWorkspaceIds.length === 0)
1107
- return new Map();
1108
- const rows = await db
1109
- .select()
1110
- .from(workspaceRuntimeServices)
1111
- .where(and(eq(workspaceRuntimeServices.orgId, orgId), inArray(workspaceRuntimeServices.projectWorkspaceId, projectWorkspaceIds)))
1112
- .orderBy(desc(workspaceRuntimeServices.updatedAt), desc(workspaceRuntimeServices.createdAt));
1113
- const grouped = new Map();
1114
- for (const row of rows) {
1115
- if (!row.projectWorkspaceId)
1116
- continue;
1117
- const existing = grouped.get(row.projectWorkspaceId);
1118
- if (existing)
1119
- existing.push(row);
1120
- else
1121
- grouped.set(row.projectWorkspaceId, [row]);
1122
- }
1123
- return grouped;
1124
- }
1125
- export async function reconcilePersistedRuntimeServicesOnStartup(db) {
1126
- const staleRows = await db
1127
- .select({ id: workspaceRuntimeServices.id })
1128
- .from(workspaceRuntimeServices)
1129
- .where(and(eq(workspaceRuntimeServices.provider, "local_process"), inArray(workspaceRuntimeServices.status, ["starting", "running"])));
1130
- if (staleRows.length === 0)
1131
- return { reconciled: 0 };
1132
- const now = new Date();
1133
- await db
1134
- .update(workspaceRuntimeServices)
1135
- .set({
1136
- status: "stopped",
1137
- healthStatus: "unknown",
1138
- stoppedAt: now,
1139
- lastUsedAt: now,
1140
- updatedAt: now,
1141
- })
1142
- .where(and(eq(workspaceRuntimeServices.provider, "local_process"), inArray(workspaceRuntimeServices.status, ["starting", "running"])));
1143
- return { reconciled: staleRows.length };
1144
- }
1145
- export async function persistAdapterManagedRuntimeServices(input) {
1146
- const refs = normalizeAdapterManagedRuntimeServices(input);
1147
- if (refs.length === 0)
1148
- return refs;
1149
- const existingRows = await input.db
1150
- .select()
1151
- .from(workspaceRuntimeServices)
1152
- .where(inArray(workspaceRuntimeServices.id, refs.map((ref) => ref.id)));
1153
- const existingById = new Map(existingRows.map((row) => [row.id, row]));
1154
- for (const ref of refs) {
1155
- const existing = existingById.get(ref.id);
1156
- const startedAt = existing?.startedAt ?? new Date(ref.startedAt);
1157
- const createdAt = existing?.createdAt ?? new Date();
1158
- await input.db
1159
- .insert(workspaceRuntimeServices)
1160
- .values({
1161
- id: ref.id,
1162
- orgId: ref.orgId,
1163
- projectId: ref.projectId,
1164
- projectWorkspaceId: ref.projectWorkspaceId,
1165
- executionWorkspaceId: ref.executionWorkspaceId,
1166
- issueId: ref.issueId,
1167
- scopeType: ref.scopeType,
1168
- scopeId: ref.scopeId,
1169
- serviceName: ref.serviceName,
1170
- status: ref.status,
1171
- lifecycle: ref.lifecycle,
1172
- reuseKey: ref.reuseKey,
1173
- command: ref.command,
1174
- cwd: ref.cwd,
1175
- port: ref.port,
1176
- url: ref.url,
1177
- provider: ref.provider,
1178
- providerRef: ref.providerRef,
1179
- ownerAgentId: ref.ownerAgentId,
1180
- startedByRunId: ref.startedByRunId,
1181
- lastUsedAt: new Date(ref.lastUsedAt),
1182
- startedAt,
1183
- stoppedAt: ref.stoppedAt ? new Date(ref.stoppedAt) : null,
1184
- stopPolicy: ref.stopPolicy,
1185
- healthStatus: ref.healthStatus,
1186
- createdAt,
1187
- updatedAt: new Date(),
1188
- })
1189
- .onConflictDoUpdate({
1190
- target: workspaceRuntimeServices.id,
1191
- set: {
1192
- projectId: ref.projectId,
1193
- projectWorkspaceId: ref.projectWorkspaceId,
1194
- executionWorkspaceId: ref.executionWorkspaceId,
1195
- issueId: ref.issueId,
1196
- scopeType: ref.scopeType,
1197
- scopeId: ref.scopeId,
1198
- serviceName: ref.serviceName,
1199
- status: ref.status,
1200
- lifecycle: ref.lifecycle,
1201
- reuseKey: ref.reuseKey,
1202
- command: ref.command,
1203
- cwd: ref.cwd,
1204
- port: ref.port,
1205
- url: ref.url,
1206
- provider: ref.provider,
1207
- providerRef: ref.providerRef,
1208
- ownerAgentId: ref.ownerAgentId,
1209
- startedByRunId: ref.startedByRunId,
1210
- lastUsedAt: new Date(ref.lastUsedAt),
1211
- startedAt,
1212
- stoppedAt: ref.stoppedAt ? new Date(ref.stoppedAt) : null,
1213
- stopPolicy: ref.stopPolicy,
1214
- healthStatus: ref.healthStatus,
1215
- updatedAt: new Date(),
1216
- },
1217
- });
1218
- }
1219
- return refs;
1220
- }
1221
- export function buildWorkspaceReadyComment(input) {
1222
- const lines = ["## Workspace Ready", ""];
1223
- lines.push(`- Strategy: \`${input.workspace.strategy}\``);
1224
- if (input.workspace.branchName)
1225
- lines.push(`- Branch: \`${input.workspace.branchName}\``);
1226
- lines.push(`- CWD: \`${input.workspace.cwd}\``);
1227
- if (input.workspace.worktreePath && input.workspace.worktreePath !== input.workspace.cwd) {
1228
- lines.push(`- Worktree: \`${input.workspace.worktreePath}\``);
1229
- }
1230
- for (const service of input.runtimeServices) {
1231
- const detail = service.url ? `${service.serviceName}: ${service.url}` : `${service.serviceName}: running`;
1232
- const suffix = service.reused ? " (reused)" : "";
1233
- lines.push(`- Service: ${detail}${suffix}`);
1234
- }
1235
- return lines.join("\n");
1236
- }
1
+ export * from "./workspace-runtime.helpers.js";
2
+ export * from "./workspace-runtime.lifecycle.js";
3
+ export * from "./workspace-runtime.services.js";
4
+ export * from "./workspace-runtime.comments.js";
1237
5
  //# sourceMappingURL=workspace-runtime.js.map