@growthub/cli 0.3.13 → 0.3.15

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 (1699) hide show
  1. package/dist/index.js +190 -186
  2. package/dist/index.js.map +1 -1
  3. package/dist/runtime/server/dist/adapters/codex-models.d.ts +4 -0
  4. package/dist/runtime/server/dist/adapters/codex-models.d.ts.map +1 -0
  5. package/dist/runtime/server/dist/adapters/codex-models.js +98 -0
  6. package/dist/runtime/server/dist/adapters/codex-models.js.map +1 -0
  7. package/dist/runtime/server/dist/adapters/cursor-models.d.ts +13 -0
  8. package/dist/runtime/server/dist/adapters/cursor-models.d.ts.map +1 -0
  9. package/dist/runtime/server/dist/adapters/cursor-models.js +148 -0
  10. package/dist/runtime/server/dist/adapters/cursor-models.js.map +1 -0
  11. package/dist/runtime/server/dist/adapters/http/execute.d.ts +3 -0
  12. package/dist/runtime/server/dist/adapters/http/execute.d.ts.map +1 -0
  13. package/dist/runtime/server/dist/adapters/http/execute.js +39 -0
  14. package/dist/runtime/server/dist/adapters/http/execute.js.map +1 -0
  15. package/dist/runtime/server/dist/adapters/http/index.d.ts +3 -0
  16. package/dist/runtime/server/dist/adapters/http/index.d.ts.map +1 -0
  17. package/dist/runtime/server/dist/adapters/http/index.js +20 -0
  18. package/dist/runtime/server/dist/adapters/http/index.js.map +1 -0
  19. package/dist/runtime/server/dist/adapters/http/test.d.ts +3 -0
  20. package/dist/runtime/server/dist/adapters/http/test.d.ts.map +1 -0
  21. package/dist/runtime/server/dist/adapters/http/test.js +106 -0
  22. package/dist/runtime/server/dist/adapters/http/test.js.map +1 -0
  23. package/dist/runtime/server/dist/adapters/index.d.ts +4 -0
  24. package/dist/runtime/server/dist/adapters/index.d.ts.map +1 -0
  25. package/dist/runtime/server/dist/adapters/index.js +3 -0
  26. package/dist/runtime/server/dist/adapters/index.js.map +1 -0
  27. package/dist/runtime/server/dist/adapters/process/execute.d.ts +3 -0
  28. package/dist/runtime/server/dist/adapters/process/execute.d.ts.map +1 -0
  29. package/dist/runtime/server/dist/adapters/process/execute.js +63 -0
  30. package/dist/runtime/server/dist/adapters/process/execute.js.map +1 -0
  31. package/dist/runtime/server/dist/adapters/process/index.d.ts +3 -0
  32. package/dist/runtime/server/dist/adapters/process/index.d.ts.map +1 -0
  33. package/dist/runtime/server/dist/adapters/process/index.js +23 -0
  34. package/dist/runtime/server/dist/adapters/process/index.js.map +1 -0
  35. package/dist/runtime/server/dist/adapters/process/test.d.ts +3 -0
  36. package/dist/runtime/server/dist/adapters/process/test.d.ts.map +1 -0
  37. package/dist/runtime/server/dist/adapters/process/test.js +77 -0
  38. package/dist/runtime/server/dist/adapters/process/test.js.map +1 -0
  39. package/dist/runtime/server/dist/adapters/registry.d.ts +9 -0
  40. package/dist/runtime/server/dist/adapters/registry.d.ts.map +1 -0
  41. package/dist/runtime/server/dist/adapters/registry.js +142 -0
  42. package/dist/runtime/server/dist/adapters/registry.js.map +1 -0
  43. package/dist/runtime/server/dist/adapters/types.d.ts +2 -0
  44. package/dist/runtime/server/dist/adapters/types.d.ts.map +1 -0
  45. package/dist/runtime/server/dist/adapters/types.js +2 -0
  46. package/dist/runtime/server/dist/adapters/types.js.map +1 -0
  47. package/dist/runtime/server/dist/adapters/utils.d.ts +10 -0
  48. package/dist/runtime/server/dist/adapters/utils.d.ts.map +1 -0
  49. package/dist/runtime/server/dist/adapters/utils.js +14 -0
  50. package/dist/runtime/server/dist/adapters/utils.js.map +1 -0
  51. package/dist/runtime/server/dist/agent-auth-jwt.d.ts +14 -0
  52. package/dist/runtime/server/dist/agent-auth-jwt.d.ts.map +1 -0
  53. package/dist/runtime/server/dist/agent-auth-jwt.js +117 -0
  54. package/dist/runtime/server/dist/agent-auth-jwt.js.map +1 -0
  55. package/dist/runtime/server/dist/app.d.ts +26 -0
  56. package/dist/runtime/server/dist/app.d.ts.map +1 -0
  57. package/dist/runtime/server/dist/app.js +371 -0
  58. package/dist/runtime/server/dist/app.js.map +1 -0
  59. package/dist/runtime/server/dist/attachment-types.d.ts +33 -0
  60. package/dist/runtime/server/dist/attachment-types.d.ts.map +1 -0
  61. package/dist/runtime/server/dist/attachment-types.js +67 -0
  62. package/dist/runtime/server/dist/attachment-types.js.map +1 -0
  63. package/dist/runtime/server/dist/auth/better-auth.d.ts +24 -0
  64. package/dist/runtime/server/dist/auth/better-auth.d.ts.map +1 -0
  65. package/dist/runtime/server/dist/auth/better-auth.js +108 -0
  66. package/dist/runtime/server/dist/auth/better-auth.js.map +1 -0
  67. package/dist/runtime/server/dist/board-claim.d.ts +23 -0
  68. package/dist/runtime/server/dist/board-claim.d.ts.map +1 -0
  69. package/dist/runtime/server/dist/board-claim.js +115 -0
  70. package/dist/runtime/server/dist/board-claim.js.map +1 -0
  71. package/dist/runtime/server/dist/config-file.d.ts +4 -0
  72. package/dist/runtime/server/dist/config-file.d.ts.map +1 -0
  73. package/dist/runtime/server/dist/config-file.js +25 -0
  74. package/dist/runtime/server/dist/config-file.js.map +1 -0
  75. package/dist/runtime/server/dist/config.d.ts +39 -0
  76. package/dist/runtime/server/dist/config.d.ts.map +1 -0
  77. package/dist/runtime/server/dist/config.js +164 -0
  78. package/dist/runtime/server/dist/config.js.map +1 -0
  79. package/dist/runtime/server/dist/errors.d.ts +12 -0
  80. package/dist/runtime/server/dist/errors.d.ts.map +1 -0
  81. package/dist/runtime/server/dist/errors.js +28 -0
  82. package/dist/runtime/server/dist/errors.js.map +1 -0
  83. package/dist/runtime/server/dist/home-paths.d.ts +17 -0
  84. package/dist/runtime/server/dist/home-paths.d.ts.map +1 -0
  85. package/dist/runtime/server/dist/home-paths.js +75 -0
  86. package/dist/runtime/server/dist/home-paths.js.map +1 -0
  87. package/dist/runtime/server/dist/index.d.ts +10 -0
  88. package/dist/runtime/server/dist/index.d.ts.map +1 -0
  89. package/dist/runtime/server/dist/index.js +567 -0
  90. package/dist/runtime/server/dist/index.js.map +1 -0
  91. package/dist/runtime/server/dist/log-redaction.d.ts +10 -0
  92. package/dist/runtime/server/dist/log-redaction.d.ts.map +1 -0
  93. package/dist/runtime/server/dist/log-redaction.js +110 -0
  94. package/dist/runtime/server/dist/log-redaction.js.map +1 -0
  95. package/dist/runtime/server/dist/middleware/auth.d.ts +12 -0
  96. package/dist/runtime/server/dist/middleware/auth.d.ts.map +1 -0
  97. package/dist/runtime/server/dist/middleware/auth.js +124 -0
  98. package/dist/runtime/server/dist/middleware/auth.js.map +1 -0
  99. package/dist/runtime/server/dist/middleware/board-mutation-guard.d.ts +3 -0
  100. package/dist/runtime/server/dist/middleware/board-mutation-guard.d.ts.map +1 -0
  101. package/dist/runtime/server/dist/middleware/board-mutation-guard.js +60 -0
  102. package/dist/runtime/server/dist/middleware/board-mutation-guard.js.map +1 -0
  103. package/dist/runtime/server/dist/middleware/error-handler.d.ts +17 -0
  104. package/dist/runtime/server/dist/middleware/error-handler.d.ts.map +1 -0
  105. package/dist/runtime/server/dist/middleware/error-handler.js +37 -0
  106. package/dist/runtime/server/dist/middleware/error-handler.js.map +1 -0
  107. package/dist/runtime/server/dist/middleware/index.d.ts +4 -0
  108. package/dist/runtime/server/dist/middleware/index.d.ts.map +1 -0
  109. package/dist/runtime/server/dist/middleware/index.js +4 -0
  110. package/dist/runtime/server/dist/middleware/index.js.map +1 -0
  111. package/dist/runtime/server/dist/middleware/logger.d.ts +4 -0
  112. package/dist/runtime/server/dist/middleware/logger.d.ts.map +1 -0
  113. package/dist/runtime/server/dist/middleware/logger.js +87 -0
  114. package/dist/runtime/server/dist/middleware/logger.js.map +1 -0
  115. package/dist/runtime/server/dist/middleware/private-hostname-guard.d.ts +11 -0
  116. package/dist/runtime/server/dist/middleware/private-hostname-guard.d.ts.map +1 -0
  117. package/dist/runtime/server/dist/middleware/private-hostname-guard.js +78 -0
  118. package/dist/runtime/server/dist/middleware/private-hostname-guard.js.map +1 -0
  119. package/dist/runtime/server/dist/middleware/validate.d.ts +4 -0
  120. package/dist/runtime/server/dist/middleware/validate.d.ts.map +1 -0
  121. package/dist/runtime/server/dist/middleware/validate.js +7 -0
  122. package/dist/runtime/server/dist/middleware/validate.js.map +1 -0
  123. package/dist/runtime/server/dist/paths.d.ts +3 -0
  124. package/dist/runtime/server/dist/paths.d.ts.map +1 -0
  125. package/dist/runtime/server/dist/paths.js +31 -0
  126. package/dist/runtime/server/dist/paths.js.map +1 -0
  127. package/dist/runtime/server/dist/realtime/live-events-ws.d.ts +28 -0
  128. package/dist/runtime/server/dist/realtime/live-events-ws.d.ts.map +1 -0
  129. package/dist/runtime/server/dist/realtime/live-events-ws.js +187 -0
  130. package/dist/runtime/server/dist/realtime/live-events-ws.js.map +1 -0
  131. package/dist/runtime/server/dist/redaction.d.ts +4 -0
  132. package/dist/runtime/server/dist/redaction.d.ts.map +1 -0
  133. package/dist/runtime/server/dist/redaction.js +63 -0
  134. package/dist/runtime/server/dist/redaction.js.map +1 -0
  135. package/dist/runtime/server/dist/routes/access.d.ts +56 -0
  136. package/dist/runtime/server/dist/routes/access.d.ts.map +1 -0
  137. package/dist/runtime/server/dist/routes/access.js +2125 -0
  138. package/dist/runtime/server/dist/routes/access.js.map +1 -0
  139. package/dist/runtime/server/dist/routes/activity.d.ts +3 -0
  140. package/dist/runtime/server/dist/routes/activity.d.ts.map +1 -0
  141. package/dist/runtime/server/dist/routes/activity.js +78 -0
  142. package/dist/runtime/server/dist/routes/activity.js.map +1 -0
  143. package/dist/runtime/server/dist/routes/agents.d.ts +3 -0
  144. package/dist/runtime/server/dist/routes/agents.d.ts.map +1 -0
  145. package/dist/runtime/server/dist/routes/agents.js +1485 -0
  146. package/dist/runtime/server/dist/routes/agents.js.map +1 -0
  147. package/dist/runtime/server/dist/routes/approvals.d.ts +3 -0
  148. package/dist/runtime/server/dist/routes/approvals.d.ts.map +1 -0
  149. package/dist/runtime/server/dist/routes/approvals.js +275 -0
  150. package/dist/runtime/server/dist/routes/approvals.js.map +1 -0
  151. package/dist/runtime/server/dist/routes/assets.d.ts +4 -0
  152. package/dist/runtime/server/dist/routes/assets.d.ts.map +1 -0
  153. package/dist/runtime/server/dist/routes/assets.js +309 -0
  154. package/dist/runtime/server/dist/routes/assets.js.map +1 -0
  155. package/dist/runtime/server/dist/routes/authz.d.ts +15 -0
  156. package/dist/runtime/server/dist/routes/authz.d.ts.map +1 -0
  157. package/dist/runtime/server/dist/routes/authz.js +40 -0
  158. package/dist/runtime/server/dist/routes/authz.js.map +1 -0
  159. package/dist/runtime/server/dist/routes/companies.d.ts +3 -0
  160. package/dist/runtime/server/dist/routes/companies.d.ts.map +1 -0
  161. package/dist/runtime/server/dist/routes/companies.js +196 -0
  162. package/dist/runtime/server/dist/routes/companies.js.map +1 -0
  163. package/dist/runtime/server/dist/routes/costs.d.ts +3 -0
  164. package/dist/runtime/server/dist/routes/costs.d.ts.map +1 -0
  165. package/dist/runtime/server/dist/routes/costs.js +268 -0
  166. package/dist/runtime/server/dist/routes/costs.js.map +1 -0
  167. package/dist/runtime/server/dist/routes/dashboard.d.ts +3 -0
  168. package/dist/runtime/server/dist/routes/dashboard.d.ts.map +1 -0
  169. package/dist/runtime/server/dist/routes/dashboard.js +15 -0
  170. package/dist/runtime/server/dist/routes/dashboard.js.map +1 -0
  171. package/dist/runtime/server/dist/routes/execution-workspaces.d.ts +3 -0
  172. package/dist/runtime/server/dist/routes/execution-workspaces.d.ts.map +1 -0
  173. package/dist/runtime/server/dist/routes/execution-workspaces.js +165 -0
  174. package/dist/runtime/server/dist/routes/execution-workspaces.js.map +1 -0
  175. package/dist/runtime/server/dist/routes/goals.d.ts +3 -0
  176. package/dist/runtime/server/dist/routes/goals.d.ts.map +1 -0
  177. package/dist/runtime/server/dist/routes/goals.js +95 -0
  178. package/dist/runtime/server/dist/routes/goals.js.map +1 -0
  179. package/dist/runtime/server/dist/routes/gtm.d.ts +3 -0
  180. package/dist/runtime/server/dist/routes/gtm.d.ts.map +1 -0
  181. package/dist/runtime/server/dist/routes/gtm.js +555 -0
  182. package/dist/runtime/server/dist/routes/gtm.js.map +1 -0
  183. package/dist/runtime/server/dist/routes/health.d.ts +10 -0
  184. package/dist/runtime/server/dist/routes/health.d.ts.map +1 -0
  185. package/dist/runtime/server/dist/routes/health.js +53 -0
  186. package/dist/runtime/server/dist/routes/health.js.map +1 -0
  187. package/dist/runtime/server/dist/routes/index.d.ts +16 -0
  188. package/dist/runtime/server/dist/routes/index.d.ts.map +1 -0
  189. package/dist/runtime/server/dist/routes/index.js +16 -0
  190. package/dist/runtime/server/dist/routes/index.js.map +1 -0
  191. package/dist/runtime/server/dist/routes/instance-settings.d.ts +3 -0
  192. package/dist/runtime/server/dist/routes/instance-settings.d.ts.map +1 -0
  193. package/dist/runtime/server/dist/routes/instance-settings.js +46 -0
  194. package/dist/runtime/server/dist/routes/instance-settings.js.map +1 -0
  195. package/dist/runtime/server/dist/routes/issues-checkout-wakeup.d.ts +9 -0
  196. package/dist/runtime/server/dist/routes/issues-checkout-wakeup.d.ts.map +1 -0
  197. package/dist/runtime/server/dist/routes/issues-checkout-wakeup.js +12 -0
  198. package/dist/runtime/server/dist/routes/issues-checkout-wakeup.js.map +1 -0
  199. package/dist/runtime/server/dist/routes/issues.d.ts +4 -0
  200. package/dist/runtime/server/dist/routes/issues.d.ts.map +1 -0
  201. package/dist/runtime/server/dist/routes/issues.js +1454 -0
  202. package/dist/runtime/server/dist/routes/issues.js.map +1 -0
  203. package/dist/runtime/server/dist/routes/llms.d.ts +3 -0
  204. package/dist/runtime/server/dist/routes/llms.d.ts.map +1 -0
  205. package/dist/runtime/server/dist/routes/llms.js +78 -0
  206. package/dist/runtime/server/dist/routes/llms.js.map +1 -0
  207. package/dist/runtime/server/dist/routes/plugin-ui-static.d.ts +69 -0
  208. package/dist/runtime/server/dist/routes/plugin-ui-static.d.ts.map +1 -0
  209. package/dist/runtime/server/dist/routes/plugin-ui-static.js +411 -0
  210. package/dist/runtime/server/dist/routes/plugin-ui-static.js.map +1 -0
  211. package/dist/runtime/server/dist/routes/plugins.d.ts +120 -0
  212. package/dist/runtime/server/dist/routes/plugins.d.ts.map +1 -0
  213. package/dist/runtime/server/dist/routes/plugins.js +1784 -0
  214. package/dist/runtime/server/dist/routes/plugins.js.map +1 -0
  215. package/dist/runtime/server/dist/routes/projects.d.ts +3 -0
  216. package/dist/runtime/server/dist/routes/projects.d.ts.map +1 -0
  217. package/dist/runtime/server/dist/routes/projects.js +257 -0
  218. package/dist/runtime/server/dist/routes/projects.js.map +1 -0
  219. package/dist/runtime/server/dist/routes/secrets.d.ts +3 -0
  220. package/dist/runtime/server/dist/routes/secrets.d.ts.map +1 -0
  221. package/dist/runtime/server/dist/routes/secrets.js +128 -0
  222. package/dist/runtime/server/dist/routes/secrets.js.map +1 -0
  223. package/dist/runtime/server/dist/routes/sidebar-badges.d.ts +3 -0
  224. package/dist/runtime/server/dist/routes/sidebar-badges.d.ts.map +1 -0
  225. package/dist/runtime/server/dist/routes/sidebar-badges.js +45 -0
  226. package/dist/runtime/server/dist/routes/sidebar-badges.js.map +1 -0
  227. package/dist/runtime/server/dist/routes/tickets.d.ts +3 -0
  228. package/dist/runtime/server/dist/routes/tickets.d.ts.map +1 -0
  229. package/dist/runtime/server/dist/routes/tickets.js +112 -0
  230. package/dist/runtime/server/dist/routes/tickets.js.map +1 -0
  231. package/dist/runtime/server/dist/secrets/external-stub-providers.d.ts +5 -0
  232. package/dist/runtime/server/dist/secrets/external-stub-providers.d.ts.map +1 -0
  233. package/dist/runtime/server/dist/secrets/external-stub-providers.js +21 -0
  234. package/dist/runtime/server/dist/secrets/external-stub-providers.js.map +1 -0
  235. package/dist/runtime/server/dist/secrets/local-encrypted-provider.d.ts +3 -0
  236. package/dist/runtime/server/dist/secrets/local-encrypted-provider.d.ts.map +1 -0
  237. package/dist/runtime/server/dist/secrets/local-encrypted-provider.js +116 -0
  238. package/dist/runtime/server/dist/secrets/local-encrypted-provider.js.map +1 -0
  239. package/dist/runtime/server/dist/secrets/provider-registry.d.ts +5 -0
  240. package/dist/runtime/server/dist/secrets/provider-registry.d.ts.map +1 -0
  241. package/dist/runtime/server/dist/secrets/provider-registry.js +20 -0
  242. package/dist/runtime/server/dist/secrets/provider-registry.js.map +1 -0
  243. package/dist/runtime/server/dist/secrets/types.d.ts +21 -0
  244. package/dist/runtime/server/dist/secrets/types.d.ts.map +1 -0
  245. package/dist/runtime/server/dist/secrets/types.js +2 -0
  246. package/dist/runtime/server/dist/secrets/types.js.map +1 -0
  247. package/dist/runtime/server/dist/services/access.d.ts +93 -0
  248. package/dist/runtime/server/dist/services/access.d.ts.map +1 -0
  249. package/dist/runtime/server/dist/services/access.js +231 -0
  250. package/dist/runtime/server/dist/services/access.js.map +1 -0
  251. package/dist/runtime/server/dist/services/activity-log.d.ts +17 -0
  252. package/dist/runtime/server/dist/services/activity-log.d.ts.map +1 -0
  253. package/dist/runtime/server/dist/services/activity-log.js +68 -0
  254. package/dist/runtime/server/dist/services/activity-log.js.map +1 -0
  255. package/dist/runtime/server/dist/services/activity.d.ts +764 -0
  256. package/dist/runtime/server/dist/services/activity.d.ts.map +1 -0
  257. package/dist/runtime/server/dist/services/activity.js +105 -0
  258. package/dist/runtime/server/dist/services/activity.js.map +1 -0
  259. package/dist/runtime/server/dist/services/agent-permissions.d.ts +6 -0
  260. package/dist/runtime/server/dist/services/agent-permissions.d.ts.map +1 -0
  261. package/dist/runtime/server/dist/services/agent-permissions.js +18 -0
  262. package/dist/runtime/server/dist/services/agent-permissions.js.map +1 -0
  263. package/dist/runtime/server/dist/services/agents.d.ts +1670 -0
  264. package/dist/runtime/server/dist/services/agents.d.ts.map +1 -0
  265. package/dist/runtime/server/dist/services/agents.js +572 -0
  266. package/dist/runtime/server/dist/services/agents.js.map +1 -0
  267. package/dist/runtime/server/dist/services/approvals.d.ts +546 -0
  268. package/dist/runtime/server/dist/services/approvals.d.ts.map +1 -0
  269. package/dist/runtime/server/dist/services/approvals.js +206 -0
  270. package/dist/runtime/server/dist/services/approvals.js.map +1 -0
  271. package/dist/runtime/server/dist/services/assets.d.ts +33 -0
  272. package/dist/runtime/server/dist/services/assets.d.ts.map +1 -0
  273. package/dist/runtime/server/dist/services/assets.js +17 -0
  274. package/dist/runtime/server/dist/services/assets.js.map +1 -0
  275. package/dist/runtime/server/dist/services/budgets.d.ts +38 -0
  276. package/dist/runtime/server/dist/services/budgets.d.ts.map +1 -0
  277. package/dist/runtime/server/dist/services/budgets.js +784 -0
  278. package/dist/runtime/server/dist/services/budgets.js.map +1 -0
  279. package/dist/runtime/server/dist/services/companies.d.ts +124 -0
  280. package/dist/runtime/server/dist/services/companies.d.ts.map +1 -0
  281. package/dist/runtime/server/dist/services/companies.js +256 -0
  282. package/dist/runtime/server/dist/services/companies.js.map +1 -0
  283. package/dist/runtime/server/dist/services/company-portability.d.ts +8 -0
  284. package/dist/runtime/server/dist/services/company-portability.d.ts.map +1 -0
  285. package/dist/runtime/server/dist/services/company-portability.js +869 -0
  286. package/dist/runtime/server/dist/services/company-portability.js.map +1 -0
  287. package/dist/runtime/server/dist/services/costs.d.ts +114 -0
  288. package/dist/runtime/server/dist/services/costs.d.ts.map +1 -0
  289. package/dist/runtime/server/dist/services/costs.js +294 -0
  290. package/dist/runtime/server/dist/services/costs.js.map +1 -0
  291. package/dist/runtime/server/dist/services/cron.d.ts +80 -0
  292. package/dist/runtime/server/dist/services/cron.d.ts.map +1 -0
  293. package/dist/runtime/server/dist/services/cron.js +300 -0
  294. package/dist/runtime/server/dist/services/cron.js.map +1 -0
  295. package/dist/runtime/server/dist/services/dashboard.d.ts +26 -0
  296. package/dist/runtime/server/dist/services/dashboard.d.ts.map +1 -0
  297. package/dist/runtime/server/dist/services/dashboard.js +98 -0
  298. package/dist/runtime/server/dist/services/dashboard.js.map +1 -0
  299. package/dist/runtime/server/dist/services/documents.d.ts +164 -0
  300. package/dist/runtime/server/dist/services/documents.d.ts.map +1 -0
  301. package/dist/runtime/server/dist/services/documents.js +382 -0
  302. package/dist/runtime/server/dist/services/documents.js.map +1 -0
  303. package/dist/runtime/server/dist/services/execution-workspace-policy.d.ts +20 -0
  304. package/dist/runtime/server/dist/services/execution-workspace-policy.d.ts.map +1 -0
  305. package/dist/runtime/server/dist/services/execution-workspace-policy.js +165 -0
  306. package/dist/runtime/server/dist/services/execution-workspace-policy.js.map +1 -0
  307. package/dist/runtime/server/dist/services/execution-workspaces.d.ts +19 -0
  308. package/dist/runtime/server/dist/services/execution-workspaces.d.ts.map +1 -0
  309. package/dist/runtime/server/dist/services/execution-workspaces.js +87 -0
  310. package/dist/runtime/server/dist/services/execution-workspaces.js.map +1 -0
  311. package/dist/runtime/server/dist/services/finance.d.ts +93 -0
  312. package/dist/runtime/server/dist/services/finance.d.ts.map +1 -0
  313. package/dist/runtime/server/dist/services/finance.js +120 -0
  314. package/dist/runtime/server/dist/services/finance.js.map +1 -0
  315. package/dist/runtime/server/dist/services/goals.d.ts +433 -0
  316. package/dist/runtime/server/dist/services/goals.d.ts.map +1 -0
  317. package/dist/runtime/server/dist/services/goals.js +54 -0
  318. package/dist/runtime/server/dist/services/goals.js.map +1 -0
  319. package/dist/runtime/server/dist/services/gtm-state.d.ts +6 -0
  320. package/dist/runtime/server/dist/services/gtm-state.d.ts.map +1 -0
  321. package/dist/runtime/server/dist/services/gtm-state.js +88 -0
  322. package/dist/runtime/server/dist/services/gtm-state.js.map +1 -0
  323. package/dist/runtime/server/dist/services/heartbeat-run-summary.d.ts +2 -0
  324. package/dist/runtime/server/dist/services/heartbeat-run-summary.d.ts.map +1 -0
  325. package/dist/runtime/server/dist/services/heartbeat-run-summary.js +30 -0
  326. package/dist/runtime/server/dist/services/heartbeat-run-summary.js.map +1 -0
  327. package/dist/runtime/server/dist/services/heartbeat.d.ts +796 -0
  328. package/dist/runtime/server/dist/services/heartbeat.d.ts.map +1 -0
  329. package/dist/runtime/server/dist/services/heartbeat.js +3046 -0
  330. package/dist/runtime/server/dist/services/heartbeat.js.map +1 -0
  331. package/dist/runtime/server/dist/services/hire-hook.d.ts +14 -0
  332. package/dist/runtime/server/dist/services/hire-hook.d.ts.map +1 -0
  333. package/dist/runtime/server/dist/services/hire-hook.js +85 -0
  334. package/dist/runtime/server/dist/services/hire-hook.js.map +1 -0
  335. package/dist/runtime/server/dist/services/index.d.ts +30 -0
  336. package/dist/runtime/server/dist/services/index.d.ts.map +1 -0
  337. package/dist/runtime/server/dist/services/index.js +30 -0
  338. package/dist/runtime/server/dist/services/index.js.map +1 -0
  339. package/dist/runtime/server/dist/services/instance-settings.d.ts +9 -0
  340. package/dist/runtime/server/dist/services/instance-settings.d.ts.map +1 -0
  341. package/dist/runtime/server/dist/services/instance-settings.js +80 -0
  342. package/dist/runtime/server/dist/services/instance-settings.js.map +1 -0
  343. package/dist/runtime/server/dist/services/issue-approvals.d.ts +56 -0
  344. package/dist/runtime/server/dist/services/issue-approvals.d.ts.map +1 -0
  345. package/dist/runtime/server/dist/services/issue-approvals.js +153 -0
  346. package/dist/runtime/server/dist/services/issue-approvals.js.map +1 -0
  347. package/dist/runtime/server/dist/services/issue-goal-fallback.d.ts +15 -0
  348. package/dist/runtime/server/dist/services/issue-goal-fallback.d.ts.map +1 -0
  349. package/dist/runtime/server/dist/services/issue-goal-fallback.js +15 -0
  350. package/dist/runtime/server/dist/services/issue-goal-fallback.js.map +1 -0
  351. package/dist/runtime/server/dist/services/issues.d.ts +536 -0
  352. package/dist/runtime/server/dist/services/issues.d.ts.map +1 -0
  353. package/dist/runtime/server/dist/services/issues.js +1321 -0
  354. package/dist/runtime/server/dist/services/issues.js.map +1 -0
  355. package/dist/runtime/server/dist/services/live-events.d.ts +17 -0
  356. package/dist/runtime/server/dist/services/live-events.d.ts.map +1 -0
  357. package/dist/runtime/server/dist/services/live-events.js +33 -0
  358. package/dist/runtime/server/dist/services/live-events.js.map +1 -0
  359. package/dist/runtime/server/dist/services/plugin-capability-validator.d.ts +108 -0
  360. package/dist/runtime/server/dist/services/plugin-capability-validator.d.ts.map +1 -0
  361. package/dist/runtime/server/dist/services/plugin-capability-validator.js +268 -0
  362. package/dist/runtime/server/dist/services/plugin-capability-validator.js.map +1 -0
  363. package/dist/runtime/server/dist/services/plugin-config-validator.d.ts +26 -0
  364. package/dist/runtime/server/dist/services/plugin-config-validator.d.ts.map +1 -0
  365. package/dist/runtime/server/dist/services/plugin-config-validator.js +41 -0
  366. package/dist/runtime/server/dist/services/plugin-config-validator.js.map +1 -0
  367. package/dist/runtime/server/dist/services/plugin-dev-watcher.d.ts +30 -0
  368. package/dist/runtime/server/dist/services/plugin-dev-watcher.d.ts.map +1 -0
  369. package/dist/runtime/server/dist/services/plugin-dev-watcher.js +241 -0
  370. package/dist/runtime/server/dist/services/plugin-dev-watcher.js.map +1 -0
  371. package/dist/runtime/server/dist/services/plugin-event-bus.d.ts +149 -0
  372. package/dist/runtime/server/dist/services/plugin-event-bus.d.ts.map +1 -0
  373. package/dist/runtime/server/dist/services/plugin-event-bus.js +258 -0
  374. package/dist/runtime/server/dist/services/plugin-event-bus.js.map +1 -0
  375. package/dist/runtime/server/dist/services/plugin-host-service-cleanup.d.ts +14 -0
  376. package/dist/runtime/server/dist/services/plugin-host-service-cleanup.d.ts.map +1 -0
  377. package/dist/runtime/server/dist/services/plugin-host-service-cleanup.js +37 -0
  378. package/dist/runtime/server/dist/services/plugin-host-service-cleanup.js.map +1 -0
  379. package/dist/runtime/server/dist/services/plugin-host-services.d.ts +13 -0
  380. package/dist/runtime/server/dist/services/plugin-host-services.d.ts.map +1 -0
  381. package/dist/runtime/server/dist/services/plugin-host-services.js +969 -0
  382. package/dist/runtime/server/dist/services/plugin-host-services.js.map +1 -0
  383. package/dist/runtime/server/dist/services/plugin-job-coordinator.d.ts +81 -0
  384. package/dist/runtime/server/dist/services/plugin-job-coordinator.d.ts.map +1 -0
  385. package/dist/runtime/server/dist/services/plugin-job-coordinator.js +172 -0
  386. package/dist/runtime/server/dist/services/plugin-job-coordinator.js.map +1 -0
  387. package/dist/runtime/server/dist/services/plugin-job-scheduler.d.ts +163 -0
  388. package/dist/runtime/server/dist/services/plugin-job-scheduler.d.ts.map +1 -0
  389. package/dist/runtime/server/dist/services/plugin-job-scheduler.js +454 -0
  390. package/dist/runtime/server/dist/services/plugin-job-scheduler.js.map +1 -0
  391. package/dist/runtime/server/dist/services/plugin-job-store.d.ts +208 -0
  392. package/dist/runtime/server/dist/services/plugin-job-store.d.ts.map +1 -0
  393. package/dist/runtime/server/dist/services/plugin-job-store.js +350 -0
  394. package/dist/runtime/server/dist/services/plugin-job-store.js.map +1 -0
  395. package/dist/runtime/server/dist/services/plugin-lifecycle.d.ts +203 -0
  396. package/dist/runtime/server/dist/services/plugin-lifecycle.d.ts.map +1 -0
  397. package/dist/runtime/server/dist/services/plugin-lifecycle.js +476 -0
  398. package/dist/runtime/server/dist/services/plugin-lifecycle.js.map +1 -0
  399. package/dist/runtime/server/dist/services/plugin-loader.d.ts +441 -0
  400. package/dist/runtime/server/dist/services/plugin-loader.d.ts.map +1 -0
  401. package/dist/runtime/server/dist/services/plugin-loader.js +1192 -0
  402. package/dist/runtime/server/dist/services/plugin-loader.js.map +1 -0
  403. package/dist/runtime/server/dist/services/plugin-log-retention.d.ts +20 -0
  404. package/dist/runtime/server/dist/services/plugin-log-retention.d.ts.map +1 -0
  405. package/dist/runtime/server/dist/services/plugin-log-retention.js +63 -0
  406. package/dist/runtime/server/dist/services/plugin-log-retention.js.map +1 -0
  407. package/dist/runtime/server/dist/services/plugin-manifest-validator.d.ts +79 -0
  408. package/dist/runtime/server/dist/services/plugin-manifest-validator.d.ts.map +1 -0
  409. package/dist/runtime/server/dist/services/plugin-manifest-validator.js +84 -0
  410. package/dist/runtime/server/dist/services/plugin-manifest-validator.js.map +1 -0
  411. package/dist/runtime/server/dist/services/plugin-registry.d.ts +2542 -0
  412. package/dist/runtime/server/dist/services/plugin-registry.d.ts.map +1 -0
  413. package/dist/runtime/server/dist/services/plugin-registry.js +539 -0
  414. package/dist/runtime/server/dist/services/plugin-registry.js.map +1 -0
  415. package/dist/runtime/server/dist/services/plugin-runtime-sandbox.d.ts +40 -0
  416. package/dist/runtime/server/dist/services/plugin-runtime-sandbox.d.ts.map +1 -0
  417. package/dist/runtime/server/dist/services/plugin-runtime-sandbox.js +154 -0
  418. package/dist/runtime/server/dist/services/plugin-runtime-sandbox.js.map +1 -0
  419. package/dist/runtime/server/dist/services/plugin-secrets-handler.d.ts +81 -0
  420. package/dist/runtime/server/dist/services/plugin-secrets-handler.d.ts.map +1 -0
  421. package/dist/runtime/server/dist/services/plugin-secrets-handler.js +275 -0
  422. package/dist/runtime/server/dist/services/plugin-secrets-handler.js.map +1 -0
  423. package/dist/runtime/server/dist/services/plugin-state-store.d.ts +92 -0
  424. package/dist/runtime/server/dist/services/plugin-state-store.d.ts.map +1 -0
  425. package/dist/runtime/server/dist/services/plugin-state-store.js +190 -0
  426. package/dist/runtime/server/dist/services/plugin-state-store.js.map +1 -0
  427. package/dist/runtime/server/dist/services/plugin-stream-bus.d.ts +29 -0
  428. package/dist/runtime/server/dist/services/plugin-stream-bus.d.ts.map +1 -0
  429. package/dist/runtime/server/dist/services/plugin-stream-bus.js +48 -0
  430. package/dist/runtime/server/dist/services/plugin-stream-bus.js.map +1 -0
  431. package/dist/runtime/server/dist/services/plugin-tool-dispatcher.d.ts +180 -0
  432. package/dist/runtime/server/dist/services/plugin-tool-dispatcher.d.ts.map +1 -0
  433. package/dist/runtime/server/dist/services/plugin-tool-dispatcher.js +224 -0
  434. package/dist/runtime/server/dist/services/plugin-tool-dispatcher.js.map +1 -0
  435. package/dist/runtime/server/dist/services/plugin-tool-registry.d.ts +192 -0
  436. package/dist/runtime/server/dist/services/plugin-tool-registry.d.ts.map +1 -0
  437. package/dist/runtime/server/dist/services/plugin-tool-registry.js +224 -0
  438. package/dist/runtime/server/dist/services/plugin-tool-registry.js.map +1 -0
  439. package/dist/runtime/server/dist/services/plugin-worker-manager.d.ts +260 -0
  440. package/dist/runtime/server/dist/services/plugin-worker-manager.d.ts.map +1 -0
  441. package/dist/runtime/server/dist/services/plugin-worker-manager.js +835 -0
  442. package/dist/runtime/server/dist/services/plugin-worker-manager.js.map +1 -0
  443. package/dist/runtime/server/dist/services/projects.d.ts +87 -0
  444. package/dist/runtime/server/dist/services/projects.d.ts.map +1 -0
  445. package/dist/runtime/server/dist/services/projects.js +656 -0
  446. package/dist/runtime/server/dist/services/projects.js.map +1 -0
  447. package/dist/runtime/server/dist/services/quota-windows.d.ts +9 -0
  448. package/dist/runtime/server/dist/services/quota-windows.d.ts.map +1 -0
  449. package/dist/runtime/server/dist/services/quota-windows.js +56 -0
  450. package/dist/runtime/server/dist/services/quota-windows.js.map +1 -0
  451. package/dist/runtime/server/dist/services/run-log-store.d.ts +34 -0
  452. package/dist/runtime/server/dist/services/run-log-store.d.ts.map +1 -0
  453. package/dist/runtime/server/dist/services/run-log-store.js +109 -0
  454. package/dist/runtime/server/dist/services/run-log-store.js.map +1 -0
  455. package/dist/runtime/server/dist/services/secrets.d.ts +510 -0
  456. package/dist/runtime/server/dist/services/secrets.d.ts.map +1 -0
  457. package/dist/runtime/server/dist/services/secrets.js +288 -0
  458. package/dist/runtime/server/dist/services/secrets.js.map +1 -0
  459. package/dist/runtime/server/dist/services/sidebar-badges.d.ts +9 -0
  460. package/dist/runtime/server/dist/services/sidebar-badges.d.ts.map +1 -0
  461. package/dist/runtime/server/dist/services/sidebar-badges.js +33 -0
  462. package/dist/runtime/server/dist/services/sidebar-badges.js.map +1 -0
  463. package/dist/runtime/server/dist/services/tickets.d.ts +1869 -0
  464. package/dist/runtime/server/dist/services/tickets.d.ts.map +1 -0
  465. package/dist/runtime/server/dist/services/tickets.js +78 -0
  466. package/dist/runtime/server/dist/services/tickets.js.map +1 -0
  467. package/dist/runtime/server/dist/services/work-products.d.ts +14 -0
  468. package/dist/runtime/server/dist/services/work-products.d.ts.map +1 -0
  469. package/dist/runtime/server/dist/services/work-products.js +100 -0
  470. package/dist/runtime/server/dist/services/work-products.js.map +1 -0
  471. package/dist/runtime/server/dist/services/workspace-operation-log-store.d.ts +33 -0
  472. package/dist/runtime/server/dist/services/workspace-operation-log-store.d.ts.map +1 -0
  473. package/dist/runtime/server/dist/services/workspace-operation-log-store.js +110 -0
  474. package/dist/runtime/server/dist/services/workspace-operation-log-store.js.map +1 -0
  475. package/dist/runtime/server/dist/services/workspace-operations.d.ts +44 -0
  476. package/dist/runtime/server/dist/services/workspace-operations.d.ts.map +1 -0
  477. package/dist/runtime/server/dist/services/workspace-operations.js +204 -0
  478. package/dist/runtime/server/dist/services/workspace-operations.js.map +1 -0
  479. package/dist/runtime/server/dist/services/workspace-runtime.d.ts +164 -0
  480. package/dist/runtime/server/dist/services/workspace-runtime.d.ts.map +1 -0
  481. package/dist/runtime/server/dist/services/workspace-runtime.js +1235 -0
  482. package/dist/runtime/server/dist/services/workspace-runtime.js.map +1 -0
  483. package/dist/runtime/server/dist/startup-banner.d.ts +31 -0
  484. package/dist/runtime/server/dist/startup-banner.d.ts.map +1 -0
  485. package/dist/runtime/server/dist/startup-banner.js +117 -0
  486. package/dist/runtime/server/dist/startup-banner.js.map +1 -0
  487. package/dist/runtime/server/dist/storage/index.d.ts +6 -0
  488. package/dist/runtime/server/dist/storage/index.d.ts.map +1 -0
  489. package/dist/runtime/server/dist/storage/index.js +29 -0
  490. package/dist/runtime/server/dist/storage/index.js.map +1 -0
  491. package/dist/runtime/server/dist/storage/local-disk-provider.d.ts +3 -0
  492. package/dist/runtime/server/dist/storage/local-disk-provider.d.ts.map +1 -0
  493. package/dist/runtime/server/dist/storage/local-disk-provider.js +79 -0
  494. package/dist/runtime/server/dist/storage/local-disk-provider.js.map +1 -0
  495. package/dist/runtime/server/dist/storage/provider-registry.d.ts +4 -0
  496. package/dist/runtime/server/dist/storage/provider-registry.d.ts.map +1 -0
  497. package/dist/runtime/server/dist/storage/provider-registry.js +15 -0
  498. package/dist/runtime/server/dist/storage/provider-registry.js.map +1 -0
  499. package/dist/runtime/server/dist/storage/s3-provider.d.ts +11 -0
  500. package/dist/runtime/server/dist/storage/s3-provider.d.ts.map +1 -0
  501. package/dist/runtime/server/dist/storage/s3-provider.js +123 -0
  502. package/dist/runtime/server/dist/storage/s3-provider.js.map +1 -0
  503. package/dist/runtime/server/dist/storage/service.d.ts +3 -0
  504. package/dist/runtime/server/dist/storage/service.d.ts.map +1 -0
  505. package/dist/runtime/server/dist/storage/service.js +120 -0
  506. package/dist/runtime/server/dist/storage/service.js.map +1 -0
  507. package/dist/runtime/server/dist/storage/types.d.ts +55 -0
  508. package/dist/runtime/server/dist/storage/types.d.ts.map +1 -0
  509. package/dist/runtime/server/dist/storage/types.js +2 -0
  510. package/dist/runtime/server/dist/storage/types.js.map +1 -0
  511. package/dist/runtime/server/dist/ui-branding.d.ts +14 -0
  512. package/dist/runtime/server/dist/ui-branding.d.ts.map +1 -0
  513. package/dist/runtime/server/dist/ui-branding.js +189 -0
  514. package/dist/runtime/server/dist/ui-branding.js.map +1 -0
  515. package/dist/runtime/server/dist/version.d.ts +2 -0
  516. package/dist/runtime/server/dist/version.d.ts.map +1 -0
  517. package/dist/runtime/server/dist/version.js +5 -0
  518. package/dist/runtime/server/dist/version.js.map +1 -0
  519. package/dist/runtime/server/node_modules/@paperclipai/adapter-claude-local/dist/cli/format-event.d.ts +2 -0
  520. package/dist/runtime/server/node_modules/@paperclipai/adapter-claude-local/dist/cli/format-event.d.ts.map +1 -0
  521. package/dist/runtime/server/node_modules/@paperclipai/adapter-claude-local/dist/cli/format-event.js +94 -0
  522. package/dist/runtime/server/node_modules/@paperclipai/adapter-claude-local/dist/cli/format-event.js.map +1 -0
  523. package/dist/runtime/server/node_modules/@paperclipai/adapter-claude-local/dist/cli/index.d.ts +2 -0
  524. package/dist/runtime/server/node_modules/@paperclipai/adapter-claude-local/dist/cli/index.d.ts.map +1 -0
  525. package/dist/runtime/server/node_modules/@paperclipai/adapter-claude-local/dist/cli/index.js +2 -0
  526. package/dist/runtime/server/node_modules/@paperclipai/adapter-claude-local/dist/cli/index.js.map +1 -0
  527. package/dist/runtime/server/node_modules/@paperclipai/adapter-claude-local/dist/cli/quota-probe.d.ts +3 -0
  528. package/dist/runtime/server/node_modules/@paperclipai/adapter-claude-local/dist/cli/quota-probe.d.ts.map +1 -0
  529. package/dist/runtime/server/node_modules/@paperclipai/adapter-claude-local/dist/cli/quota-probe.js +106 -0
  530. package/dist/runtime/server/node_modules/@paperclipai/adapter-claude-local/dist/cli/quota-probe.js.map +1 -0
  531. package/dist/runtime/server/node_modules/@paperclipai/adapter-claude-local/dist/index.d.ts +8 -0
  532. package/dist/runtime/server/node_modules/@paperclipai/adapter-claude-local/dist/index.d.ts.map +1 -0
  533. package/dist/runtime/server/node_modules/@paperclipai/adapter-claude-local/dist/index.js +36 -0
  534. package/dist/runtime/server/node_modules/@paperclipai/adapter-claude-local/dist/index.js.map +1 -0
  535. package/dist/runtime/server/node_modules/@paperclipai/adapter-claude-local/dist/server/execute.d.ts +18 -0
  536. package/dist/runtime/server/node_modules/@paperclipai/adapter-claude-local/dist/server/execute.d.ts.map +1 -0
  537. package/dist/runtime/server/node_modules/@paperclipai/adapter-claude-local/dist/server/execute.js +453 -0
  538. package/dist/runtime/server/node_modules/@paperclipai/adapter-claude-local/dist/server/execute.js.map +1 -0
  539. package/dist/runtime/server/node_modules/@paperclipai/adapter-claude-local/dist/server/index.d.ts +7 -0
  540. package/dist/runtime/server/node_modules/@paperclipai/adapter-claude-local/dist/server/index.d.ts.map +1 -0
  541. package/dist/runtime/server/node_modules/@paperclipai/adapter-claude-local/dist/server/index.js +56 -0
  542. package/dist/runtime/server/node_modules/@paperclipai/adapter-claude-local/dist/server/index.js.map +1 -0
  543. package/dist/runtime/server/node_modules/@paperclipai/adapter-claude-local/dist/server/parse.d.ts +22 -0
  544. package/dist/runtime/server/node_modules/@paperclipai/adapter-claude-local/dist/server/parse.d.ts.map +1 -0
  545. package/dist/runtime/server/node_modules/@paperclipai/adapter-claude-local/dist/server/parse.js +158 -0
  546. package/dist/runtime/server/node_modules/@paperclipai/adapter-claude-local/dist/server/parse.js.map +1 -0
  547. package/dist/runtime/server/node_modules/@paperclipai/adapter-claude-local/dist/server/quota.d.ts +20 -0
  548. package/dist/runtime/server/node_modules/@paperclipai/adapter-claude-local/dist/server/quota.d.ts.map +1 -0
  549. package/dist/runtime/server/node_modules/@paperclipai/adapter-claude-local/dist/server/quota.js +477 -0
  550. package/dist/runtime/server/node_modules/@paperclipai/adapter-claude-local/dist/server/quota.js.map +1 -0
  551. package/dist/runtime/server/node_modules/@paperclipai/adapter-claude-local/dist/server/test.d.ts +3 -0
  552. package/dist/runtime/server/node_modules/@paperclipai/adapter-claude-local/dist/server/test.d.ts.map +1 -0
  553. package/dist/runtime/server/node_modules/@paperclipai/adapter-claude-local/dist/server/test.js +201 -0
  554. package/dist/runtime/server/node_modules/@paperclipai/adapter-claude-local/dist/server/test.js.map +1 -0
  555. package/dist/runtime/server/node_modules/@paperclipai/adapter-claude-local/dist/ui/build-config.d.ts +3 -0
  556. package/dist/runtime/server/node_modules/@paperclipai/adapter-claude-local/dist/ui/build-config.d.ts.map +1 -0
  557. package/dist/runtime/server/node_modules/@paperclipai/adapter-claude-local/dist/ui/build-config.js +115 -0
  558. package/dist/runtime/server/node_modules/@paperclipai/adapter-claude-local/dist/ui/build-config.js.map +1 -0
  559. package/dist/runtime/server/node_modules/@paperclipai/adapter-claude-local/dist/ui/index.d.ts +3 -0
  560. package/dist/runtime/server/node_modules/@paperclipai/adapter-claude-local/dist/ui/index.d.ts.map +1 -0
  561. package/dist/runtime/server/node_modules/@paperclipai/adapter-claude-local/dist/ui/index.js +3 -0
  562. package/dist/runtime/server/node_modules/@paperclipai/adapter-claude-local/dist/ui/index.js.map +1 -0
  563. package/dist/runtime/server/node_modules/@paperclipai/adapter-claude-local/dist/ui/parse-stdout.d.ts +3 -0
  564. package/dist/runtime/server/node_modules/@paperclipai/adapter-claude-local/dist/ui/parse-stdout.d.ts.map +1 -0
  565. package/dist/runtime/server/node_modules/@paperclipai/adapter-claude-local/dist/ui/parse-stdout.js +149 -0
  566. package/dist/runtime/server/node_modules/@paperclipai/adapter-claude-local/dist/ui/parse-stdout.js.map +1 -0
  567. package/dist/runtime/server/node_modules/@paperclipai/adapter-claude-local/package.json +42 -0
  568. package/dist/runtime/server/node_modules/@paperclipai/adapter-codex-local/dist/cli/format-event.d.ts +2 -0
  569. package/dist/runtime/server/node_modules/@paperclipai/adapter-codex-local/dist/cli/format-event.d.ts.map +1 -0
  570. package/dist/runtime/server/node_modules/@paperclipai/adapter-codex-local/dist/cli/format-event.js +213 -0
  571. package/dist/runtime/server/node_modules/@paperclipai/adapter-codex-local/dist/cli/format-event.js.map +1 -0
  572. package/dist/runtime/server/node_modules/@paperclipai/adapter-codex-local/dist/cli/index.d.ts +2 -0
  573. package/dist/runtime/server/node_modules/@paperclipai/adapter-codex-local/dist/cli/index.d.ts.map +1 -0
  574. package/dist/runtime/server/node_modules/@paperclipai/adapter-codex-local/dist/cli/index.js +2 -0
  575. package/dist/runtime/server/node_modules/@paperclipai/adapter-codex-local/dist/cli/index.js.map +1 -0
  576. package/dist/runtime/server/node_modules/@paperclipai/adapter-codex-local/dist/cli/quota-probe.d.ts +3 -0
  577. package/dist/runtime/server/node_modules/@paperclipai/adapter-codex-local/dist/cli/quota-probe.d.ts.map +1 -0
  578. package/dist/runtime/server/node_modules/@paperclipai/adapter-codex-local/dist/cli/quota-probe.js +97 -0
  579. package/dist/runtime/server/node_modules/@paperclipai/adapter-codex-local/dist/cli/quota-probe.js.map +1 -0
  580. package/dist/runtime/server/node_modules/@paperclipai/adapter-codex-local/dist/index.d.ts +10 -0
  581. package/dist/runtime/server/node_modules/@paperclipai/adapter-codex-local/dist/index.d.ts.map +1 -0
  582. package/dist/runtime/server/node_modules/@paperclipai/adapter-codex-local/dist/index.js +45 -0
  583. package/dist/runtime/server/node_modules/@paperclipai/adapter-codex-local/dist/index.js.map +1 -0
  584. package/dist/runtime/server/node_modules/@paperclipai/adapter-codex-local/dist/server/codex-home.d.ts +5 -0
  585. package/dist/runtime/server/node_modules/@paperclipai/adapter-codex-local/dist/server/codex-home.d.ts.map +1 -0
  586. package/dist/runtime/server/node_modules/@paperclipai/adapter-codex-local/dist/server/codex-home.js +86 -0
  587. package/dist/runtime/server/node_modules/@paperclipai/adapter-codex-local/dist/server/codex-home.js.map +1 -0
  588. package/dist/runtime/server/node_modules/@paperclipai/adapter-codex-local/dist/server/execute.d.ts +11 -0
  589. package/dist/runtime/server/node_modules/@paperclipai/adapter-codex-local/dist/server/execute.d.ts.map +1 -0
  590. package/dist/runtime/server/node_modules/@paperclipai/adapter-codex-local/dist/server/execute.js +451 -0
  591. package/dist/runtime/server/node_modules/@paperclipai/adapter-codex-local/dist/server/execute.js.map +1 -0
  592. package/dist/runtime/server/node_modules/@paperclipai/adapter-codex-local/dist/server/index.d.ts +7 -0
  593. package/dist/runtime/server/node_modules/@paperclipai/adapter-codex-local/dist/server/index.d.ts.map +1 -0
  594. package/dist/runtime/server/node_modules/@paperclipai/adapter-codex-local/dist/server/index.js +56 -0
  595. package/dist/runtime/server/node_modules/@paperclipai/adapter-codex-local/dist/server/index.js.map +1 -0
  596. package/dist/runtime/server/node_modules/@paperclipai/adapter-codex-local/dist/server/parse.d.ts +12 -0
  597. package/dist/runtime/server/node_modules/@paperclipai/adapter-codex-local/dist/server/parse.d.ts.map +1 -0
  598. package/dist/runtime/server/node_modules/@paperclipai/adapter-codex-local/dist/server/parse.js +67 -0
  599. package/dist/runtime/server/node_modules/@paperclipai/adapter-codex-local/dist/server/parse.js.map +1 -0
  600. package/dist/runtime/server/node_modules/@paperclipai/adapter-codex-local/dist/server/quota.d.ts +64 -0
  601. package/dist/runtime/server/node_modules/@paperclipai/adapter-codex-local/dist/server/quota.d.ts.map +1 -0
  602. package/dist/runtime/server/node_modules/@paperclipai/adapter-codex-local/dist/server/quota.js +425 -0
  603. package/dist/runtime/server/node_modules/@paperclipai/adapter-codex-local/dist/server/quota.js.map +1 -0
  604. package/dist/runtime/server/node_modules/@paperclipai/adapter-codex-local/dist/server/test.d.ts +3 -0
  605. package/dist/runtime/server/node_modules/@paperclipai/adapter-codex-local/dist/server/test.d.ts.map +1 -0
  606. package/dist/runtime/server/node_modules/@paperclipai/adapter-codex-local/dist/server/test.js +194 -0
  607. package/dist/runtime/server/node_modules/@paperclipai/adapter-codex-local/dist/server/test.js.map +1 -0
  608. package/dist/runtime/server/node_modules/@paperclipai/adapter-codex-local/dist/ui/build-config.d.ts +3 -0
  609. package/dist/runtime/server/node_modules/@paperclipai/adapter-codex-local/dist/ui/build-config.d.ts.map +1 -0
  610. package/dist/runtime/server/node_modules/@paperclipai/adapter-codex-local/dist/ui/build-config.js +116 -0
  611. package/dist/runtime/server/node_modules/@paperclipai/adapter-codex-local/dist/ui/build-config.js.map +1 -0
  612. package/dist/runtime/server/node_modules/@paperclipai/adapter-codex-local/dist/ui/index.d.ts +3 -0
  613. package/dist/runtime/server/node_modules/@paperclipai/adapter-codex-local/dist/ui/index.d.ts.map +1 -0
  614. package/dist/runtime/server/node_modules/@paperclipai/adapter-codex-local/dist/ui/index.js +3 -0
  615. package/dist/runtime/server/node_modules/@paperclipai/adapter-codex-local/dist/ui/index.js.map +1 -0
  616. package/dist/runtime/server/node_modules/@paperclipai/adapter-codex-local/dist/ui/parse-stdout.d.ts +3 -0
  617. package/dist/runtime/server/node_modules/@paperclipai/adapter-codex-local/dist/ui/parse-stdout.d.ts.map +1 -0
  618. package/dist/runtime/server/node_modules/@paperclipai/adapter-codex-local/dist/ui/parse-stdout.js +233 -0
  619. package/dist/runtime/server/node_modules/@paperclipai/adapter-codex-local/dist/ui/parse-stdout.js.map +1 -0
  620. package/dist/runtime/server/node_modules/@paperclipai/adapter-codex-local/package.json +42 -0
  621. package/dist/runtime/server/node_modules/@paperclipai/adapter-cursor-local/dist/cli/format-event.d.ts +2 -0
  622. package/dist/runtime/server/node_modules/@paperclipai/adapter-cursor-local/dist/cli/format-event.d.ts.map +1 -0
  623. package/dist/runtime/server/node_modules/@paperclipai/adapter-cursor-local/dist/cli/format-event.js +296 -0
  624. package/dist/runtime/server/node_modules/@paperclipai/adapter-cursor-local/dist/cli/format-event.js.map +1 -0
  625. package/dist/runtime/server/node_modules/@paperclipai/adapter-cursor-local/dist/cli/index.d.ts +2 -0
  626. package/dist/runtime/server/node_modules/@paperclipai/adapter-cursor-local/dist/cli/index.d.ts.map +1 -0
  627. package/dist/runtime/server/node_modules/@paperclipai/adapter-cursor-local/dist/cli/index.js +2 -0
  628. package/dist/runtime/server/node_modules/@paperclipai/adapter-cursor-local/dist/cli/index.js.map +1 -0
  629. package/dist/runtime/server/node_modules/@paperclipai/adapter-cursor-local/dist/index.d.ts +9 -0
  630. package/dist/runtime/server/node_modules/@paperclipai/adapter-cursor-local/dist/index.d.ts.map +1 -0
  631. package/dist/runtime/server/node_modules/@paperclipai/adapter-cursor-local/dist/index.js +81 -0
  632. package/dist/runtime/server/node_modules/@paperclipai/adapter-cursor-local/dist/index.js.map +1 -0
  633. package/dist/runtime/server/node_modules/@paperclipai/adapter-cursor-local/dist/server/execute.d.ts +14 -0
  634. package/dist/runtime/server/node_modules/@paperclipai/adapter-cursor-local/dist/server/execute.d.ts.map +1 -0
  635. package/dist/runtime/server/node_modules/@paperclipai/adapter-cursor-local/dist/server/execute.js +416 -0
  636. package/dist/runtime/server/node_modules/@paperclipai/adapter-cursor-local/dist/server/execute.js.map +1 -0
  637. package/dist/runtime/server/node_modules/@paperclipai/adapter-cursor-local/dist/server/index.d.ts +6 -0
  638. package/dist/runtime/server/node_modules/@paperclipai/adapter-cursor-local/dist/server/index.d.ts.map +1 -0
  639. package/dist/runtime/server/node_modules/@paperclipai/adapter-cursor-local/dist/server/index.js +61 -0
  640. package/dist/runtime/server/node_modules/@paperclipai/adapter-cursor-local/dist/server/index.js.map +1 -0
  641. package/dist/runtime/server/node_modules/@paperclipai/adapter-cursor-local/dist/server/parse.d.ts +13 -0
  642. package/dist/runtime/server/node_modules/@paperclipai/adapter-cursor-local/dist/server/parse.d.ts.map +1 -0
  643. package/dist/runtime/server/node_modules/@paperclipai/adapter-cursor-local/dist/server/parse.js +139 -0
  644. package/dist/runtime/server/node_modules/@paperclipai/adapter-cursor-local/dist/server/parse.js.map +1 -0
  645. package/dist/runtime/server/node_modules/@paperclipai/adapter-cursor-local/dist/server/test.d.ts +3 -0
  646. package/dist/runtime/server/node_modules/@paperclipai/adapter-cursor-local/dist/server/test.d.ts.map +1 -0
  647. package/dist/runtime/server/node_modules/@paperclipai/adapter-cursor-local/dist/server/test.js +188 -0
  648. package/dist/runtime/server/node_modules/@paperclipai/adapter-cursor-local/dist/server/test.js.map +1 -0
  649. package/dist/runtime/server/node_modules/@paperclipai/adapter-cursor-local/dist/shared/stream.d.ts +5 -0
  650. package/dist/runtime/server/node_modules/@paperclipai/adapter-cursor-local/dist/shared/stream.d.ts.map +1 -0
  651. package/dist/runtime/server/node_modules/@paperclipai/adapter-cursor-local/dist/shared/stream.js +13 -0
  652. package/dist/runtime/server/node_modules/@paperclipai/adapter-cursor-local/dist/shared/stream.js.map +1 -0
  653. package/dist/runtime/server/node_modules/@paperclipai/adapter-cursor-local/dist/shared/trust.d.ts +2 -0
  654. package/dist/runtime/server/node_modules/@paperclipai/adapter-cursor-local/dist/shared/trust.d.ts.map +1 -0
  655. package/dist/runtime/server/node_modules/@paperclipai/adapter-cursor-local/dist/shared/trust.js +7 -0
  656. package/dist/runtime/server/node_modules/@paperclipai/adapter-cursor-local/dist/shared/trust.js.map +1 -0
  657. package/dist/runtime/server/node_modules/@paperclipai/adapter-cursor-local/dist/ui/build-config.d.ts +3 -0
  658. package/dist/runtime/server/node_modules/@paperclipai/adapter-cursor-local/dist/ui/build-config.d.ts.map +1 -0
  659. package/dist/runtime/server/node_modules/@paperclipai/adapter-cursor-local/dist/ui/build-config.js +92 -0
  660. package/dist/runtime/server/node_modules/@paperclipai/adapter-cursor-local/dist/ui/build-config.js.map +1 -0
  661. package/dist/runtime/server/node_modules/@paperclipai/adapter-cursor-local/dist/ui/index.d.ts +3 -0
  662. package/dist/runtime/server/node_modules/@paperclipai/adapter-cursor-local/dist/ui/index.d.ts.map +1 -0
  663. package/dist/runtime/server/node_modules/@paperclipai/adapter-cursor-local/dist/ui/index.js +3 -0
  664. package/dist/runtime/server/node_modules/@paperclipai/adapter-cursor-local/dist/ui/index.js.map +1 -0
  665. package/dist/runtime/server/node_modules/@paperclipai/adapter-cursor-local/dist/ui/parse-stdout.d.ts +3 -0
  666. package/dist/runtime/server/node_modules/@paperclipai/adapter-cursor-local/dist/ui/parse-stdout.d.ts.map +1 -0
  667. package/dist/runtime/server/node_modules/@paperclipai/adapter-cursor-local/dist/ui/parse-stdout.js +373 -0
  668. package/dist/runtime/server/node_modules/@paperclipai/adapter-cursor-local/dist/ui/parse-stdout.js.map +1 -0
  669. package/dist/runtime/server/node_modules/@paperclipai/adapter-cursor-local/package.json +42 -0
  670. package/dist/runtime/server/node_modules/@paperclipai/adapter-gemini-local/dist/cli/format-event.d.ts +2 -0
  671. package/dist/runtime/server/node_modules/@paperclipai/adapter-gemini-local/dist/cli/format-event.d.ts.map +1 -0
  672. package/dist/runtime/server/node_modules/@paperclipai/adapter-gemini-local/dist/cli/format-event.js +198 -0
  673. package/dist/runtime/server/node_modules/@paperclipai/adapter-gemini-local/dist/cli/format-event.js.map +1 -0
  674. package/dist/runtime/server/node_modules/@paperclipai/adapter-gemini-local/dist/cli/index.d.ts +2 -0
  675. package/dist/runtime/server/node_modules/@paperclipai/adapter-gemini-local/dist/cli/index.d.ts.map +1 -0
  676. package/dist/runtime/server/node_modules/@paperclipai/adapter-gemini-local/dist/cli/index.js +2 -0
  677. package/dist/runtime/server/node_modules/@paperclipai/adapter-gemini-local/dist/cli/index.js.map +1 -0
  678. package/dist/runtime/server/node_modules/@paperclipai/adapter-gemini-local/dist/index.d.ts +9 -0
  679. package/dist/runtime/server/node_modules/@paperclipai/adapter-gemini-local/dist/index.d.ts.map +1 -0
  680. package/dist/runtime/server/node_modules/@paperclipai/adapter-gemini-local/dist/index.js +46 -0
  681. package/dist/runtime/server/node_modules/@paperclipai/adapter-gemini-local/dist/index.js.map +1 -0
  682. package/dist/runtime/server/node_modules/@paperclipai/adapter-gemini-local/dist/server/execute.d.ts +3 -0
  683. package/dist/runtime/server/node_modules/@paperclipai/adapter-gemini-local/dist/server/execute.d.ts.map +1 -0
  684. package/dist/runtime/server/node_modules/@paperclipai/adapter-gemini-local/dist/server/execute.js +364 -0
  685. package/dist/runtime/server/node_modules/@paperclipai/adapter-gemini-local/dist/server/execute.js.map +1 -0
  686. package/dist/runtime/server/node_modules/@paperclipai/adapter-gemini-local/dist/server/index.d.ts +6 -0
  687. package/dist/runtime/server/node_modules/@paperclipai/adapter-gemini-local/dist/server/index.d.ts.map +1 -0
  688. package/dist/runtime/server/node_modules/@paperclipai/adapter-gemini-local/dist/server/index.js +61 -0
  689. package/dist/runtime/server/node_modules/@paperclipai/adapter-gemini-local/dist/server/index.js.map +1 -0
  690. package/dist/runtime/server/node_modules/@paperclipai/adapter-gemini-local/dist/server/parse.d.ts +31 -0
  691. package/dist/runtime/server/node_modules/@paperclipai/adapter-gemini-local/dist/server/parse.d.ts.map +1 -0
  692. package/dist/runtime/server/node_modules/@paperclipai/adapter-gemini-local/dist/server/parse.js +227 -0
  693. package/dist/runtime/server/node_modules/@paperclipai/adapter-gemini-local/dist/server/parse.js.map +1 -0
  694. package/dist/runtime/server/node_modules/@paperclipai/adapter-gemini-local/dist/server/test.d.ts +3 -0
  695. package/dist/runtime/server/node_modules/@paperclipai/adapter-gemini-local/dist/server/test.d.ts.map +1 -0
  696. package/dist/runtime/server/node_modules/@paperclipai/adapter-gemini-local/dist/server/test.js +203 -0
  697. package/dist/runtime/server/node_modules/@paperclipai/adapter-gemini-local/dist/server/test.js.map +1 -0
  698. package/dist/runtime/server/node_modules/@paperclipai/adapter-gemini-local/dist/server/utils.d.ts +2 -0
  699. package/dist/runtime/server/node_modules/@paperclipai/adapter-gemini-local/dist/server/utils.d.ts.map +1 -0
  700. package/dist/runtime/server/node_modules/@paperclipai/adapter-gemini-local/dist/server/utils.js +7 -0
  701. package/dist/runtime/server/node_modules/@paperclipai/adapter-gemini-local/dist/server/utils.js.map +1 -0
  702. package/dist/runtime/server/node_modules/@paperclipai/adapter-gemini-local/dist/ui/build-config.d.ts +3 -0
  703. package/dist/runtime/server/node_modules/@paperclipai/adapter-gemini-local/dist/ui/build-config.d.ts.map +1 -0
  704. package/dist/runtime/server/node_modules/@paperclipai/adapter-gemini-local/dist/ui/build-config.js +84 -0
  705. package/dist/runtime/server/node_modules/@paperclipai/adapter-gemini-local/dist/ui/build-config.js.map +1 -0
  706. package/dist/runtime/server/node_modules/@paperclipai/adapter-gemini-local/dist/ui/index.d.ts +3 -0
  707. package/dist/runtime/server/node_modules/@paperclipai/adapter-gemini-local/dist/ui/index.d.ts.map +1 -0
  708. package/dist/runtime/server/node_modules/@paperclipai/adapter-gemini-local/dist/ui/index.js +3 -0
  709. package/dist/runtime/server/node_modules/@paperclipai/adapter-gemini-local/dist/ui/index.js.map +1 -0
  710. package/dist/runtime/server/node_modules/@paperclipai/adapter-gemini-local/dist/ui/parse-stdout.d.ts +3 -0
  711. package/dist/runtime/server/node_modules/@paperclipai/adapter-gemini-local/dist/ui/parse-stdout.d.ts.map +1 -0
  712. package/dist/runtime/server/node_modules/@paperclipai/adapter-gemini-local/dist/ui/parse-stdout.js +247 -0
  713. package/dist/runtime/server/node_modules/@paperclipai/adapter-gemini-local/dist/ui/parse-stdout.js.map +1 -0
  714. package/dist/runtime/server/node_modules/@paperclipai/adapter-gemini-local/package.json +42 -0
  715. package/dist/runtime/server/node_modules/@paperclipai/adapter-openclaw-gateway/dist/cli/format-event.d.ts +2 -0
  716. package/dist/runtime/server/node_modules/@paperclipai/adapter-openclaw-gateway/dist/cli/format-event.d.ts.map +1 -0
  717. package/dist/runtime/server/node_modules/@paperclipai/adapter-openclaw-gateway/dist/cli/format-event.js +20 -0
  718. package/dist/runtime/server/node_modules/@paperclipai/adapter-openclaw-gateway/dist/cli/format-event.js.map +1 -0
  719. package/dist/runtime/server/node_modules/@paperclipai/adapter-openclaw-gateway/dist/cli/index.d.ts +2 -0
  720. package/dist/runtime/server/node_modules/@paperclipai/adapter-openclaw-gateway/dist/cli/index.d.ts.map +1 -0
  721. package/dist/runtime/server/node_modules/@paperclipai/adapter-openclaw-gateway/dist/cli/index.js +2 -0
  722. package/dist/runtime/server/node_modules/@paperclipai/adapter-openclaw-gateway/dist/cli/index.js.map +1 -0
  723. package/dist/runtime/server/node_modules/@paperclipai/adapter-openclaw-gateway/dist/index.d.ts +8 -0
  724. package/dist/runtime/server/node_modules/@paperclipai/adapter-openclaw-gateway/dist/index.d.ts.map +1 -0
  725. package/dist/runtime/server/node_modules/@paperclipai/adapter-openclaw-gateway/dist/index.js +53 -0
  726. package/dist/runtime/server/node_modules/@paperclipai/adapter-openclaw-gateway/dist/index.js.map +1 -0
  727. package/dist/runtime/server/node_modules/@paperclipai/adapter-openclaw-gateway/dist/server/execute.d.ts +3 -0
  728. package/dist/runtime/server/node_modules/@paperclipai/adapter-openclaw-gateway/dist/server/execute.d.ts.map +1 -0
  729. package/dist/runtime/server/node_modules/@paperclipai/adapter-openclaw-gateway/dist/server/execute.js +1146 -0
  730. package/dist/runtime/server/node_modules/@paperclipai/adapter-openclaw-gateway/dist/server/execute.js.map +1 -0
  731. package/dist/runtime/server/node_modules/@paperclipai/adapter-openclaw-gateway/dist/server/index.d.ts +3 -0
  732. package/dist/runtime/server/node_modules/@paperclipai/adapter-openclaw-gateway/dist/server/index.d.ts.map +1 -0
  733. package/dist/runtime/server/node_modules/@paperclipai/adapter-openclaw-gateway/dist/server/index.js +3 -0
  734. package/dist/runtime/server/node_modules/@paperclipai/adapter-openclaw-gateway/dist/server/index.js.map +1 -0
  735. package/dist/runtime/server/node_modules/@paperclipai/adapter-openclaw-gateway/dist/server/test.d.ts +3 -0
  736. package/dist/runtime/server/node_modules/@paperclipai/adapter-openclaw-gateway/dist/server/test.d.ts.map +1 -0
  737. package/dist/runtime/server/node_modules/@paperclipai/adapter-openclaw-gateway/dist/server/test.js +290 -0
  738. package/dist/runtime/server/node_modules/@paperclipai/adapter-openclaw-gateway/dist/server/test.js.map +1 -0
  739. package/dist/runtime/server/node_modules/@paperclipai/adapter-openclaw-gateway/dist/shared/stream.d.ts +5 -0
  740. package/dist/runtime/server/node_modules/@paperclipai/adapter-openclaw-gateway/dist/shared/stream.d.ts.map +1 -0
  741. package/dist/runtime/server/node_modules/@paperclipai/adapter-openclaw-gateway/dist/shared/stream.js +13 -0
  742. package/dist/runtime/server/node_modules/@paperclipai/adapter-openclaw-gateway/dist/shared/stream.js.map +1 -0
  743. package/dist/runtime/server/node_modules/@paperclipai/adapter-openclaw-gateway/dist/ui/build-config.d.ts +3 -0
  744. package/dist/runtime/server/node_modules/@paperclipai/adapter-openclaw-gateway/dist/ui/build-config.d.ts.map +1 -0
  745. package/dist/runtime/server/node_modules/@paperclipai/adapter-openclaw-gateway/dist/ui/build-config.js +33 -0
  746. package/dist/runtime/server/node_modules/@paperclipai/adapter-openclaw-gateway/dist/ui/build-config.js.map +1 -0
  747. package/dist/runtime/server/node_modules/@paperclipai/adapter-openclaw-gateway/dist/ui/index.d.ts +3 -0
  748. package/dist/runtime/server/node_modules/@paperclipai/adapter-openclaw-gateway/dist/ui/index.d.ts.map +1 -0
  749. package/dist/runtime/server/node_modules/@paperclipai/adapter-openclaw-gateway/dist/ui/index.js +3 -0
  750. package/dist/runtime/server/node_modules/@paperclipai/adapter-openclaw-gateway/dist/ui/index.js.map +1 -0
  751. package/dist/runtime/server/node_modules/@paperclipai/adapter-openclaw-gateway/dist/ui/parse-stdout.d.ts +3 -0
  752. package/dist/runtime/server/node_modules/@paperclipai/adapter-openclaw-gateway/dist/ui/parse-stdout.d.ts.map +1 -0
  753. package/dist/runtime/server/node_modules/@paperclipai/adapter-openclaw-gateway/dist/ui/parse-stdout.js +64 -0
  754. package/dist/runtime/server/node_modules/@paperclipai/adapter-openclaw-gateway/dist/ui/parse-stdout.js.map +1 -0
  755. package/dist/runtime/server/node_modules/@paperclipai/adapter-openclaw-gateway/package.json +43 -0
  756. package/dist/runtime/server/node_modules/@paperclipai/adapter-opencode-local/dist/cli/format-event.d.ts +2 -0
  757. package/dist/runtime/server/node_modules/@paperclipai/adapter-opencode-local/dist/cli/format-event.d.ts.map +1 -0
  758. package/dist/runtime/server/node_modules/@paperclipai/adapter-opencode-local/dist/cli/format-event.js +115 -0
  759. package/dist/runtime/server/node_modules/@paperclipai/adapter-opencode-local/dist/cli/format-event.js.map +1 -0
  760. package/dist/runtime/server/node_modules/@paperclipai/adapter-opencode-local/dist/cli/index.d.ts +2 -0
  761. package/dist/runtime/server/node_modules/@paperclipai/adapter-opencode-local/dist/cli/index.d.ts.map +1 -0
  762. package/dist/runtime/server/node_modules/@paperclipai/adapter-opencode-local/dist/cli/index.js +2 -0
  763. package/dist/runtime/server/node_modules/@paperclipai/adapter-opencode-local/dist/cli/index.js.map +1 -0
  764. package/dist/runtime/server/node_modules/@paperclipai/adapter-opencode-local/dist/index.d.ts +8 -0
  765. package/dist/runtime/server/node_modules/@paperclipai/adapter-opencode-local/dist/index.d.ts.map +1 -0
  766. package/dist/runtime/server/node_modules/@paperclipai/adapter-opencode-local/dist/index.js +39 -0
  767. package/dist/runtime/server/node_modules/@paperclipai/adapter-opencode-local/dist/index.js.map +1 -0
  768. package/dist/runtime/server/node_modules/@paperclipai/adapter-opencode-local/dist/server/execute.d.ts +3 -0
  769. package/dist/runtime/server/node_modules/@paperclipai/adapter-opencode-local/dist/server/execute.d.ts.map +1 -0
  770. package/dist/runtime/server/node_modules/@paperclipai/adapter-opencode-local/dist/server/execute.js +337 -0
  771. package/dist/runtime/server/node_modules/@paperclipai/adapter-opencode-local/dist/server/execute.js.map +1 -0
  772. package/dist/runtime/server/node_modules/@paperclipai/adapter-opencode-local/dist/server/index.d.ts +7 -0
  773. package/dist/runtime/server/node_modules/@paperclipai/adapter-opencode-local/dist/server/index.d.ts.map +1 -0
  774. package/dist/runtime/server/node_modules/@paperclipai/adapter-opencode-local/dist/server/index.js +62 -0
  775. package/dist/runtime/server/node_modules/@paperclipai/adapter-opencode-local/dist/server/index.js.map +1 -0
  776. package/dist/runtime/server/node_modules/@paperclipai/adapter-opencode-local/dist/server/models.d.ts +20 -0
  777. package/dist/runtime/server/node_modules/@paperclipai/adapter-opencode-local/dist/server/models.d.ts.map +1 -0
  778. package/dist/runtime/server/node_modules/@paperclipai/adapter-opencode-local/dist/server/models.js +165 -0
  779. package/dist/runtime/server/node_modules/@paperclipai/adapter-opencode-local/dist/server/models.js.map +1 -0
  780. package/dist/runtime/server/node_modules/@paperclipai/adapter-opencode-local/dist/server/models.test.d.ts +2 -0
  781. package/dist/runtime/server/node_modules/@paperclipai/adapter-opencode-local/dist/server/models.test.d.ts.map +1 -0
  782. package/dist/runtime/server/node_modules/@paperclipai/adapter-opencode-local/dist/server/models.test.js +22 -0
  783. package/dist/runtime/server/node_modules/@paperclipai/adapter-opencode-local/dist/server/models.test.js.map +1 -0
  784. package/dist/runtime/server/node_modules/@paperclipai/adapter-opencode-local/dist/server/parse.d.ts +13 -0
  785. package/dist/runtime/server/node_modules/@paperclipai/adapter-opencode-local/dist/server/parse.d.ts.map +1 -0
  786. package/dist/runtime/server/node_modules/@paperclipai/adapter-opencode-local/dist/server/parse.js +97 -0
  787. package/dist/runtime/server/node_modules/@paperclipai/adapter-opencode-local/dist/server/parse.js.map +1 -0
  788. package/dist/runtime/server/node_modules/@paperclipai/adapter-opencode-local/dist/server/parse.test.d.ts +2 -0
  789. package/dist/runtime/server/node_modules/@paperclipai/adapter-opencode-local/dist/server/parse.test.d.ts.map +1 -0
  790. package/dist/runtime/server/node_modules/@paperclipai/adapter-opencode-local/dist/server/parse.test.js +48 -0
  791. package/dist/runtime/server/node_modules/@paperclipai/adapter-opencode-local/dist/server/parse.test.js.map +1 -0
  792. package/dist/runtime/server/node_modules/@paperclipai/adapter-opencode-local/dist/server/test.d.ts +3 -0
  793. package/dist/runtime/server/node_modules/@paperclipai/adapter-opencode-local/dist/server/test.d.ts.map +1 -0
  794. package/dist/runtime/server/node_modules/@paperclipai/adapter-opencode-local/dist/server/test.js +300 -0
  795. package/dist/runtime/server/node_modules/@paperclipai/adapter-opencode-local/dist/server/test.js.map +1 -0
  796. package/dist/runtime/server/node_modules/@paperclipai/adapter-opencode-local/dist/ui/build-config.d.ts +3 -0
  797. package/dist/runtime/server/node_modules/@paperclipai/adapter-opencode-local/dist/ui/build-config.d.ts.map +1 -0
  798. package/dist/runtime/server/node_modules/@paperclipai/adapter-opencode-local/dist/ui/build-config.js +87 -0
  799. package/dist/runtime/server/node_modules/@paperclipai/adapter-opencode-local/dist/ui/build-config.js.map +1 -0
  800. package/dist/runtime/server/node_modules/@paperclipai/adapter-opencode-local/dist/ui/index.d.ts +3 -0
  801. package/dist/runtime/server/node_modules/@paperclipai/adapter-opencode-local/dist/ui/index.d.ts.map +1 -0
  802. package/dist/runtime/server/node_modules/@paperclipai/adapter-opencode-local/dist/ui/index.js +3 -0
  803. package/dist/runtime/server/node_modules/@paperclipai/adapter-opencode-local/dist/ui/index.js.map +1 -0
  804. package/dist/runtime/server/node_modules/@paperclipai/adapter-opencode-local/dist/ui/parse-stdout.d.ts +3 -0
  805. package/dist/runtime/server/node_modules/@paperclipai/adapter-opencode-local/dist/ui/parse-stdout.d.ts.map +1 -0
  806. package/dist/runtime/server/node_modules/@paperclipai/adapter-opencode-local/dist/ui/parse-stdout.js +141 -0
  807. package/dist/runtime/server/node_modules/@paperclipai/adapter-opencode-local/dist/ui/parse-stdout.js.map +1 -0
  808. package/dist/runtime/server/node_modules/@paperclipai/adapter-opencode-local/package.json +42 -0
  809. package/dist/runtime/server/node_modules/@paperclipai/adapter-pi-local/dist/cli/format-event.d.ts +2 -0
  810. package/dist/runtime/server/node_modules/@paperclipai/adapter-pi-local/dist/cli/format-event.d.ts.map +1 -0
  811. package/dist/runtime/server/node_modules/@paperclipai/adapter-pi-local/dist/cli/format-event.js +99 -0
  812. package/dist/runtime/server/node_modules/@paperclipai/adapter-pi-local/dist/cli/format-event.js.map +1 -0
  813. package/dist/runtime/server/node_modules/@paperclipai/adapter-pi-local/dist/cli/index.d.ts +2 -0
  814. package/dist/runtime/server/node_modules/@paperclipai/adapter-pi-local/dist/cli/index.d.ts.map +1 -0
  815. package/dist/runtime/server/node_modules/@paperclipai/adapter-pi-local/dist/cli/index.js +2 -0
  816. package/dist/runtime/server/node_modules/@paperclipai/adapter-pi-local/dist/cli/index.js.map +1 -0
  817. package/dist/runtime/server/node_modules/@paperclipai/adapter-pi-local/dist/index.d.ts +8 -0
  818. package/dist/runtime/server/node_modules/@paperclipai/adapter-pi-local/dist/index.d.ts.map +1 -0
  819. package/dist/runtime/server/node_modules/@paperclipai/adapter-pi-local/dist/index.js +39 -0
  820. package/dist/runtime/server/node_modules/@paperclipai/adapter-pi-local/dist/index.js.map +1 -0
  821. package/dist/runtime/server/node_modules/@paperclipai/adapter-pi-local/dist/server/execute.d.ts +3 -0
  822. package/dist/runtime/server/node_modules/@paperclipai/adapter-pi-local/dist/server/execute.d.ts.map +1 -0
  823. package/dist/runtime/server/node_modules/@paperclipai/adapter-pi-local/dist/server/execute.js +405 -0
  824. package/dist/runtime/server/node_modules/@paperclipai/adapter-pi-local/dist/server/execute.js.map +1 -0
  825. package/dist/runtime/server/node_modules/@paperclipai/adapter-pi-local/dist/server/index.d.ts +7 -0
  826. package/dist/runtime/server/node_modules/@paperclipai/adapter-pi-local/dist/server/index.d.ts.map +1 -0
  827. package/dist/runtime/server/node_modules/@paperclipai/adapter-pi-local/dist/server/index.js +50 -0
  828. package/dist/runtime/server/node_modules/@paperclipai/adapter-pi-local/dist/server/index.js.map +1 -0
  829. package/dist/runtime/server/node_modules/@paperclipai/adapter-pi-local/dist/server/models.d.ts +20 -0
  830. package/dist/runtime/server/node_modules/@paperclipai/adapter-pi-local/dist/server/models.d.ts.map +1 -0
  831. package/dist/runtime/server/node_modules/@paperclipai/adapter-pi-local/dist/server/models.js +161 -0
  832. package/dist/runtime/server/node_modules/@paperclipai/adapter-pi-local/dist/server/models.js.map +1 -0
  833. package/dist/runtime/server/node_modules/@paperclipai/adapter-pi-local/dist/server/models.test.d.ts +2 -0
  834. package/dist/runtime/server/node_modules/@paperclipai/adapter-pi-local/dist/server/models.test.d.ts.map +1 -0
  835. package/dist/runtime/server/node_modules/@paperclipai/adapter-pi-local/dist/server/models.test.js +22 -0
  836. package/dist/runtime/server/node_modules/@paperclipai/adapter-pi-local/dist/server/models.test.js.map +1 -0
  837. package/dist/runtime/server/node_modules/@paperclipai/adapter-pi-local/dist/server/parse.d.ts +23 -0
  838. package/dist/runtime/server/node_modules/@paperclipai/adapter-pi-local/dist/server/parse.d.ts.map +1 -0
  839. package/dist/runtime/server/node_modules/@paperclipai/adapter-pi-local/dist/server/parse.js +180 -0
  840. package/dist/runtime/server/node_modules/@paperclipai/adapter-pi-local/dist/server/parse.js.map +1 -0
  841. package/dist/runtime/server/node_modules/@paperclipai/adapter-pi-local/dist/server/parse.test.d.ts +2 -0
  842. package/dist/runtime/server/node_modules/@paperclipai/adapter-pi-local/dist/server/parse.test.d.ts.map +1 -0
  843. package/dist/runtime/server/node_modules/@paperclipai/adapter-pi-local/dist/server/parse.test.js +206 -0
  844. package/dist/runtime/server/node_modules/@paperclipai/adapter-pi-local/dist/server/parse.test.js.map +1 -0
  845. package/dist/runtime/server/node_modules/@paperclipai/adapter-pi-local/dist/server/test.d.ts +3 -0
  846. package/dist/runtime/server/node_modules/@paperclipai/adapter-pi-local/dist/server/test.d.ts.map +1 -0
  847. package/dist/runtime/server/node_modules/@paperclipai/adapter-pi-local/dist/server/test.js +257 -0
  848. package/dist/runtime/server/node_modules/@paperclipai/adapter-pi-local/dist/server/test.js.map +1 -0
  849. package/dist/runtime/server/node_modules/@paperclipai/adapter-pi-local/dist/ui/build-config.d.ts +3 -0
  850. package/dist/runtime/server/node_modules/@paperclipai/adapter-pi-local/dist/ui/build-config.d.ts.map +1 -0
  851. package/dist/runtime/server/node_modules/@paperclipai/adapter-pi-local/dist/ui/build-config.js +82 -0
  852. package/dist/runtime/server/node_modules/@paperclipai/adapter-pi-local/dist/ui/build-config.js.map +1 -0
  853. package/dist/runtime/server/node_modules/@paperclipai/adapter-pi-local/dist/ui/index.d.ts +3 -0
  854. package/dist/runtime/server/node_modules/@paperclipai/adapter-pi-local/dist/ui/index.d.ts.map +1 -0
  855. package/dist/runtime/server/node_modules/@paperclipai/adapter-pi-local/dist/ui/index.js +3 -0
  856. package/dist/runtime/server/node_modules/@paperclipai/adapter-pi-local/dist/ui/index.js.map +1 -0
  857. package/dist/runtime/server/node_modules/@paperclipai/adapter-pi-local/dist/ui/parse-stdout.d.ts +3 -0
  858. package/dist/runtime/server/node_modules/@paperclipai/adapter-pi-local/dist/ui/parse-stdout.d.ts.map +1 -0
  859. package/dist/runtime/server/node_modules/@paperclipai/adapter-pi-local/dist/ui/parse-stdout.js +163 -0
  860. package/dist/runtime/server/node_modules/@paperclipai/adapter-pi-local/dist/ui/parse-stdout.js.map +1 -0
  861. package/dist/runtime/server/node_modules/@paperclipai/adapter-pi-local/package.json +42 -0
  862. package/dist/runtime/server/node_modules/@paperclipai/adapter-utils/dist/billing.d.ts +2 -0
  863. package/dist/runtime/server/node_modules/@paperclipai/adapter-utils/dist/billing.d.ts.map +1 -0
  864. package/dist/runtime/server/node_modules/@paperclipai/adapter-utils/dist/billing.js +16 -0
  865. package/dist/runtime/server/node_modules/@paperclipai/adapter-utils/dist/billing.js.map +1 -0
  866. package/dist/runtime/server/node_modules/@paperclipai/adapter-utils/dist/billing.test.d.ts +2 -0
  867. package/dist/runtime/server/node_modules/@paperclipai/adapter-utils/dist/billing.test.d.ts.map +1 -0
  868. package/dist/runtime/server/node_modules/@paperclipai/adapter-utils/dist/billing.test.js +14 -0
  869. package/dist/runtime/server/node_modules/@paperclipai/adapter-utils/dist/billing.test.js.map +1 -0
  870. package/dist/runtime/server/node_modules/@paperclipai/adapter-utils/dist/index.d.ts +6 -0
  871. package/dist/runtime/server/node_modules/@paperclipai/adapter-utils/dist/index.d.ts.map +1 -0
  872. package/dist/runtime/server/node_modules/@paperclipai/adapter-utils/dist/index.js +4 -0
  873. package/dist/runtime/server/node_modules/@paperclipai/adapter-utils/dist/index.js.map +1 -0
  874. package/dist/runtime/server/node_modules/@paperclipai/adapter-utils/dist/log-redaction.d.ts +6 -0
  875. package/dist/runtime/server/node_modules/@paperclipai/adapter-utils/dist/log-redaction.d.ts.map +1 -0
  876. package/dist/runtime/server/node_modules/@paperclipai/adapter-utils/dist/log-redaction.js +75 -0
  877. package/dist/runtime/server/node_modules/@paperclipai/adapter-utils/dist/log-redaction.js.map +1 -0
  878. package/dist/runtime/server/node_modules/@paperclipai/adapter-utils/dist/server-utils.d.ts +62 -0
  879. package/dist/runtime/server/node_modules/@paperclipai/adapter-utils/dist/server-utils.d.ts.map +1 -0
  880. package/dist/runtime/server/node_modules/@paperclipai/adapter-utils/dist/server-utils.js +419 -0
  881. package/dist/runtime/server/node_modules/@paperclipai/adapter-utils/dist/server-utils.js.map +1 -0
  882. package/dist/runtime/server/node_modules/@paperclipai/adapter-utils/dist/session-compaction.d.ts +25 -0
  883. package/dist/runtime/server/node_modules/@paperclipai/adapter-utils/dist/session-compaction.d.ts.map +1 -0
  884. package/dist/runtime/server/node_modules/@paperclipai/adapter-utils/dist/session-compaction.js +142 -0
  885. package/dist/runtime/server/node_modules/@paperclipai/adapter-utils/dist/session-compaction.js.map +1 -0
  886. package/dist/runtime/server/node_modules/@paperclipai/adapter-utils/dist/types.d.ts +290 -0
  887. package/dist/runtime/server/node_modules/@paperclipai/adapter-utils/dist/types.d.ts.map +1 -0
  888. package/dist/runtime/server/node_modules/@paperclipai/adapter-utils/dist/types.js +5 -0
  889. package/dist/runtime/server/node_modules/@paperclipai/adapter-utils/dist/types.js.map +1 -0
  890. package/dist/runtime/server/node_modules/@paperclipai/adapter-utils/package.json +30 -0
  891. package/dist/runtime/server/node_modules/@paperclipai/db/dist/backup-lib.d.ts +24 -0
  892. package/dist/runtime/server/node_modules/@paperclipai/db/dist/backup-lib.d.ts.map +1 -0
  893. package/dist/runtime/server/node_modules/@paperclipai/db/dist/backup-lib.js +448 -0
  894. package/dist/runtime/server/node_modules/@paperclipai/db/dist/backup-lib.js.map +1 -0
  895. package/dist/runtime/server/node_modules/@paperclipai/db/dist/backup.d.ts +2 -0
  896. package/dist/runtime/server/node_modules/@paperclipai/db/dist/backup.d.ts.map +1 -0
  897. package/dist/runtime/server/node_modules/@paperclipai/db/dist/backup.js +103 -0
  898. package/dist/runtime/server/node_modules/@paperclipai/db/dist/backup.js.map +1 -0
  899. package/dist/runtime/server/node_modules/@paperclipai/db/dist/client.d.ts +43 -0
  900. package/dist/runtime/server/node_modules/@paperclipai/db/dist/client.d.ts.map +1 -0
  901. package/dist/runtime/server/node_modules/@paperclipai/db/dist/client.js +574 -0
  902. package/dist/runtime/server/node_modules/@paperclipai/db/dist/client.js.map +1 -0
  903. package/dist/runtime/server/node_modules/@paperclipai/db/dist/client.test.d.ts +2 -0
  904. package/dist/runtime/server/node_modules/@paperclipai/db/dist/client.test.d.ts.map +1 -0
  905. package/dist/runtime/server/node_modules/@paperclipai/db/dist/client.test.js +117 -0
  906. package/dist/runtime/server/node_modules/@paperclipai/db/dist/client.test.js.map +1 -0
  907. package/dist/runtime/server/node_modules/@paperclipai/db/dist/index.d.ts +4 -0
  908. package/dist/runtime/server/node_modules/@paperclipai/db/dist/index.d.ts.map +1 -0
  909. package/dist/runtime/server/node_modules/@paperclipai/db/dist/index.js +4 -0
  910. package/dist/runtime/server/node_modules/@paperclipai/db/dist/index.js.map +1 -0
  911. package/dist/runtime/server/node_modules/@paperclipai/db/dist/migrate.d.ts +2 -0
  912. package/dist/runtime/server/node_modules/@paperclipai/db/dist/migrate.d.ts.map +1 -0
  913. package/dist/runtime/server/node_modules/@paperclipai/db/dist/migrate.js +25 -0
  914. package/dist/runtime/server/node_modules/@paperclipai/db/dist/migrate.js.map +1 -0
  915. package/dist/runtime/server/node_modules/@paperclipai/db/dist/migration-runtime.d.ts +7 -0
  916. package/dist/runtime/server/node_modules/@paperclipai/db/dist/migration-runtime.d.ts.map +1 -0
  917. package/dist/runtime/server/node_modules/@paperclipai/db/dist/migration-runtime.js +163 -0
  918. package/dist/runtime/server/node_modules/@paperclipai/db/dist/migration-runtime.js.map +1 -0
  919. package/dist/runtime/server/node_modules/@paperclipai/db/dist/migration-status.d.ts +2 -0
  920. package/dist/runtime/server/node_modules/@paperclipai/db/dist/migration-status.d.ts.map +1 -0
  921. package/dist/runtime/server/node_modules/@paperclipai/db/dist/migration-status.js +55 -0
  922. package/dist/runtime/server/node_modules/@paperclipai/db/dist/migration-status.js.map +1 -0
  923. package/dist/runtime/server/node_modules/@paperclipai/db/dist/migrations/0000_mature_masked_marvel.sql +208 -0
  924. package/dist/runtime/server/node_modules/@paperclipai/db/dist/migrations/0001_fast_northstar.sql +87 -0
  925. package/dist/runtime/server/node_modules/@paperclipai/db/dist/migrations/0002_big_zaladane.sql +1 -0
  926. package/dist/runtime/server/node_modules/@paperclipai/db/dist/migrations/0003_shallow_quentin_quire.sql +5 -0
  927. package/dist/runtime/server/node_modules/@paperclipai/db/dist/migrations/0004_issue_identifiers.sql +28 -0
  928. package/dist/runtime/server/node_modules/@paperclipai/db/dist/migrations/0005_chief_luke_cage.sql +19 -0
  929. package/dist/runtime/server/node_modules/@paperclipai/db/dist/migrations/0006_overjoyed_mister_sinister.sql +36 -0
  930. package/dist/runtime/server/node_modules/@paperclipai/db/dist/migrations/0007_new_quentin_quire.sql +20 -0
  931. package/dist/runtime/server/node_modules/@paperclipai/db/dist/migrations/0008_amused_zzzax.sql +1 -0
  932. package/dist/runtime/server/node_modules/@paperclipai/db/dist/migrations/0009_fast_jackal.sql +36 -0
  933. package/dist/runtime/server/node_modules/@paperclipai/db/dist/migrations/0010_stale_justin_hammer.sql +37 -0
  934. package/dist/runtime/server/node_modules/@paperclipai/db/dist/migrations/0011_windy_corsair.sql +18 -0
  935. package/dist/runtime/server/node_modules/@paperclipai/db/dist/migrations/0012_perpetual_ser_duncan.sql +2 -0
  936. package/dist/runtime/server/node_modules/@paperclipai/db/dist/migrations/0013_dashing_wasp.sql +4 -0
  937. package/dist/runtime/server/node_modules/@paperclipai/db/dist/migrations/0014_many_mikhail_rasputin.sql +135 -0
  938. package/dist/runtime/server/node_modules/@paperclipai/db/dist/migrations/0015_project_color_archived.sql +2 -0
  939. package/dist/runtime/server/node_modules/@paperclipai/db/dist/migrations/0016_agent_icon.sql +1 -0
  940. package/dist/runtime/server/node_modules/@paperclipai/db/dist/migrations/0017_tiresome_gabe_jones.sql +51 -0
  941. package/dist/runtime/server/node_modules/@paperclipai/db/dist/migrations/0018_flat_sleepwalker.sql +26 -0
  942. package/dist/runtime/server/node_modules/@paperclipai/db/dist/migrations/0019_public_victor_mancha.sql +18 -0
  943. package/dist/runtime/server/node_modules/@paperclipai/db/dist/migrations/0020_white_anita_blake.sql +1 -0
  944. package/dist/runtime/server/node_modules/@paperclipai/db/dist/migrations/0021_chief_vindicator.sql +1 -0
  945. package/dist/runtime/server/node_modules/@paperclipai/db/dist/migrations/0022_company_brand_color.sql +1 -0
  946. package/dist/runtime/server/node_modules/@paperclipai/db/dist/migrations/0023_fair_lethal_legion.sql +3 -0
  947. package/dist/runtime/server/node_modules/@paperclipai/db/dist/migrations/0024_far_beast.sql +2 -0
  948. package/dist/runtime/server/node_modules/@paperclipai/db/dist/migrations/0025_nasty_salo.sql +15 -0
  949. package/dist/runtime/server/node_modules/@paperclipai/db/dist/migrations/0026_lying_pete_wisdom.sql +39 -0
  950. package/dist/runtime/server/node_modules/@paperclipai/db/dist/migrations/0027_tranquil_tenebrous.sql +2 -0
  951. package/dist/runtime/server/node_modules/@paperclipai/db/dist/migrations/0028_harsh_goliath.sql +54 -0
  952. package/dist/runtime/server/node_modules/@paperclipai/db/dist/migrations/0029_plugin_tables.sql +177 -0
  953. package/dist/runtime/server/node_modules/@paperclipai/db/dist/migrations/0030_rich_magneto.sql +12 -0
  954. package/dist/runtime/server/node_modules/@paperclipai/db/dist/migrations/0031_zippy_magma.sql +51 -0
  955. package/dist/runtime/server/node_modules/@paperclipai/db/dist/migrations/0032_pretty_doctor_octopus.sql +102 -0
  956. package/dist/runtime/server/node_modules/@paperclipai/db/dist/migrations/0033_shiny_black_tarantula.sql +2 -0
  957. package/dist/runtime/server/node_modules/@paperclipai/db/dist/migrations/0034_fat_dormammu.sql +2 -0
  958. package/dist/runtime/server/node_modules/@paperclipai/db/dist/migrations/0035_marvelous_satana.sql +91 -0
  959. package/dist/runtime/server/node_modules/@paperclipai/db/dist/migrations/0036_cheerful_nitro.sql +9 -0
  960. package/dist/runtime/server/node_modules/@paperclipai/db/dist/migrations/0037_friendly_eddie_brock.sql +29 -0
  961. package/dist/runtime/server/node_modules/@paperclipai/db/dist/migrations/0038_careless_iron_monger.sql +5 -0
  962. package/dist/runtime/server/node_modules/@paperclipai/db/dist/migrations/0039_tickets.sql +25 -0
  963. package/dist/runtime/server/node_modules/@paperclipai/db/dist/migrations/0040_ticket_meta.sql +3 -0
  964. package/dist/runtime/server/node_modules/@paperclipai/db/dist/migrations/meta/0000_snapshot.json +1743 -0
  965. package/dist/runtime/server/node_modules/@paperclipai/db/dist/migrations/meta/0001_snapshot.json +2441 -0
  966. package/dist/runtime/server/node_modules/@paperclipai/db/dist/migrations/meta/0002_snapshot.json +2454 -0
  967. package/dist/runtime/server/node_modules/@paperclipai/db/dist/migrations/meta/0003_snapshot.json +2502 -0
  968. package/dist/runtime/server/node_modules/@paperclipai/db/dist/migrations/meta/0005_snapshot.json +2719 -0
  969. package/dist/runtime/server/node_modules/@paperclipai/db/dist/migrations/meta/0006_snapshot.json +3048 -0
  970. package/dist/runtime/server/node_modules/@paperclipai/db/dist/migrations/meta/0007_snapshot.json +3258 -0
  971. package/dist/runtime/server/node_modules/@paperclipai/db/dist/migrations/meta/0008_snapshot.json +3264 -0
  972. package/dist/runtime/server/node_modules/@paperclipai/db/dist/migrations/meta/0009_snapshot.json +3587 -0
  973. package/dist/runtime/server/node_modules/@paperclipai/db/dist/migrations/meta/0010_snapshot.json +3929 -0
  974. package/dist/runtime/server/node_modules/@paperclipai/db/dist/migrations/meta/0011_snapshot.json +4068 -0
  975. package/dist/runtime/server/node_modules/@paperclipai/db/dist/migrations/meta/0012_snapshot.json +4087 -0
  976. package/dist/runtime/server/node_modules/@paperclipai/db/dist/migrations/meta/0013_snapshot.json +4118 -0
  977. package/dist/runtime/server/node_modules/@paperclipai/db/dist/migrations/meta/0014_snapshot.json +5187 -0
  978. package/dist/runtime/server/node_modules/@paperclipai/db/dist/migrations/meta/0017_snapshot.json +5215 -0
  979. package/dist/runtime/server/node_modules/@paperclipai/db/dist/migrations/meta/0018_snapshot.json +5450 -0
  980. package/dist/runtime/server/node_modules/@paperclipai/db/dist/migrations/meta/0019_snapshot.json +5603 -0
  981. package/dist/runtime/server/node_modules/@paperclipai/db/dist/migrations/meta/0020_snapshot.json +5603 -0
  982. package/dist/runtime/server/node_modules/@paperclipai/db/dist/migrations/meta/0021_snapshot.json +5609 -0
  983. package/dist/runtime/server/node_modules/@paperclipai/db/dist/migrations/meta/0023_snapshot.json +5633 -0
  984. package/dist/runtime/server/node_modules/@paperclipai/db/dist/migrations/meta/0024_snapshot.json +5693 -0
  985. package/dist/runtime/server/node_modules/@paperclipai/db/dist/migrations/meta/0025_snapshot.json +5849 -0
  986. package/dist/runtime/server/node_modules/@paperclipai/db/dist/migrations/meta/0027_snapshot.json +6205 -0
  987. package/dist/runtime/server/node_modules/@paperclipai/db/dist/migrations/meta/0028_snapshot.json +6710 -0
  988. package/dist/runtime/server/node_modules/@paperclipai/db/dist/migrations/meta/0029_snapshot.json +7899 -0
  989. package/dist/runtime/server/node_modules/@paperclipai/db/dist/migrations/meta/0030_snapshot.json +8003 -0
  990. package/dist/runtime/server/node_modules/@paperclipai/db/dist/migrations/meta/0031_snapshot.json +7242 -0
  991. package/dist/runtime/server/node_modules/@paperclipai/db/dist/migrations/meta/0032_snapshot.json +7733 -0
  992. package/dist/runtime/server/node_modules/@paperclipai/db/dist/migrations/meta/0033_snapshot.json +9038 -0
  993. package/dist/runtime/server/node_modules/@paperclipai/db/dist/migrations/meta/0034_snapshot.json +9039 -0
  994. package/dist/runtime/server/node_modules/@paperclipai/db/dist/migrations/meta/0035_snapshot.json +9959 -0
  995. package/dist/runtime/server/node_modules/@paperclipai/db/dist/migrations/meta/0036_snapshot.json +10023 -0
  996. package/dist/runtime/server/node_modules/@paperclipai/db/dist/migrations/meta/0037_snapshot.json +10263 -0
  997. package/dist/runtime/server/node_modules/@paperclipai/db/dist/migrations/meta/0038_snapshot.json +10301 -0
  998. package/dist/runtime/server/node_modules/@paperclipai/db/dist/migrations/meta/_journal.json +293 -0
  999. package/dist/runtime/server/node_modules/@paperclipai/db/dist/runtime-config.d.ts +16 -0
  1000. package/dist/runtime/server/node_modules/@paperclipai/db/dist/runtime-config.d.ts.map +1 -0
  1001. package/dist/runtime/server/node_modules/@paperclipai/db/dist/runtime-config.js +197 -0
  1002. package/dist/runtime/server/node_modules/@paperclipai/db/dist/runtime-config.js.map +1 -0
  1003. package/dist/runtime/server/node_modules/@paperclipai/db/dist/runtime-config.test.d.ts +2 -0
  1004. package/dist/runtime/server/node_modules/@paperclipai/db/dist/runtime-config.test.d.ts.map +1 -0
  1005. package/dist/runtime/server/node_modules/@paperclipai/db/dist/runtime-config.test.js +93 -0
  1006. package/dist/runtime/server/node_modules/@paperclipai/db/dist/runtime-config.test.js.map +1 -0
  1007. package/dist/runtime/server/node_modules/@paperclipai/db/dist/schema/activity_log.d.ts +197 -0
  1008. package/dist/runtime/server/node_modules/@paperclipai/db/dist/schema/activity_log.d.ts.map +1 -0
  1009. package/dist/runtime/server/node_modules/@paperclipai/db/dist/schema/activity_log.js +22 -0
  1010. package/dist/runtime/server/node_modules/@paperclipai/db/dist/schema/activity_log.js.map +1 -0
  1011. package/dist/runtime/server/node_modules/@paperclipai/db/dist/schema/agent_api_keys.d.ts +144 -0
  1012. package/dist/runtime/server/node_modules/@paperclipai/db/dist/schema/agent_api_keys.d.ts.map +1 -0
  1013. package/dist/runtime/server/node_modules/@paperclipai/db/dist/schema/agent_api_keys.js +17 -0
  1014. package/dist/runtime/server/node_modules/@paperclipai/db/dist/schema/agent_api_keys.js.map +1 -0
  1015. package/dist/runtime/server/node_modules/@paperclipai/db/dist/schema/agent_config_revisions.d.ts +201 -0
  1016. package/dist/runtime/server/node_modules/@paperclipai/db/dist/schema/agent_config_revisions.d.ts.map +1 -0
  1017. package/dist/runtime/server/node_modules/@paperclipai/db/dist/schema/agent_config_revisions.js +20 -0
  1018. package/dist/runtime/server/node_modules/@paperclipai/db/dist/schema/agent_config_revisions.js.map +1 -0
  1019. package/dist/runtime/server/node_modules/@paperclipai/db/dist/schema/agent_runtime_state.d.ts +248 -0
  1020. package/dist/runtime/server/node_modules/@paperclipai/db/dist/schema/agent_runtime_state.d.ts.map +1 -0
  1021. package/dist/runtime/server/node_modules/@paperclipai/db/dist/schema/agent_runtime_state.js +23 -0
  1022. package/dist/runtime/server/node_modules/@paperclipai/db/dist/schema/agent_runtime_state.js.map +1 -0
  1023. package/dist/runtime/server/node_modules/@paperclipai/db/dist/schema/agent_task_sessions.d.ts +197 -0
  1024. package/dist/runtime/server/node_modules/@paperclipai/db/dist/schema/agent_task_sessions.d.ts.map +1 -0
  1025. package/dist/runtime/server/node_modules/@paperclipai/db/dist/schema/agent_task_sessions.js +22 -0
  1026. package/dist/runtime/server/node_modules/@paperclipai/db/dist/schema/agent_task_sessions.js.map +1 -0
  1027. package/dist/runtime/server/node_modules/@paperclipai/db/dist/schema/agent_wakeup_requests.d.ts +333 -0
  1028. package/dist/runtime/server/node_modules/@paperclipai/db/dist/schema/agent_wakeup_requests.d.ts.map +1 -0
  1029. package/dist/runtime/server/node_modules/@paperclipai/db/dist/schema/agent_wakeup_requests.js +29 -0
  1030. package/dist/runtime/server/node_modules/@paperclipai/db/dist/schema/agent_wakeup_requests.js.map +1 -0
  1031. package/dist/runtime/server/node_modules/@paperclipai/db/dist/schema/agents.d.ts +373 -0
  1032. package/dist/runtime/server/node_modules/@paperclipai/db/dist/schema/agents.d.ts.map +1 -0
  1033. package/dist/runtime/server/node_modules/@paperclipai/db/dist/schema/agents.js +29 -0
  1034. package/dist/runtime/server/node_modules/@paperclipai/db/dist/schema/agents.js.map +1 -0
  1035. package/dist/runtime/server/node_modules/@paperclipai/db/dist/schema/approval_comments.d.ts +144 -0
  1036. package/dist/runtime/server/node_modules/@paperclipai/db/dist/schema/approval_comments.d.ts.map +1 -0
  1037. package/dist/runtime/server/node_modules/@paperclipai/db/dist/schema/approval_comments.js +19 -0
  1038. package/dist/runtime/server/node_modules/@paperclipai/db/dist/schema/approval_comments.js.map +1 -0
  1039. package/dist/runtime/server/node_modules/@paperclipai/db/dist/schema/approvals.d.ts +214 -0
  1040. package/dist/runtime/server/node_modules/@paperclipai/db/dist/schema/approvals.d.ts.map +1 -0
  1041. package/dist/runtime/server/node_modules/@paperclipai/db/dist/schema/approvals.js +20 -0
  1042. package/dist/runtime/server/node_modules/@paperclipai/db/dist/schema/approvals.js.map +1 -0
  1043. package/dist/runtime/server/node_modules/@paperclipai/db/dist/schema/assets.d.ts +212 -0
  1044. package/dist/runtime/server/node_modules/@paperclipai/db/dist/schema/assets.d.ts.map +1 -0
  1045. package/dist/runtime/server/node_modules/@paperclipai/db/dist/schema/assets.js +22 -0
  1046. package/dist/runtime/server/node_modules/@paperclipai/db/dist/schema/assets.js.map +1 -0
  1047. package/dist/runtime/server/node_modules/@paperclipai/db/dist/schema/auth.d.ts +607 -0
  1048. package/dist/runtime/server/node_modules/@paperclipai/db/dist/schema/auth.d.ts.map +1 -0
  1049. package/dist/runtime/server/node_modules/@paperclipai/db/dist/schema/auth.js +44 -0
  1050. package/dist/runtime/server/node_modules/@paperclipai/db/dist/schema/auth.js.map +1 -0
  1051. package/dist/runtime/server/node_modules/@paperclipai/db/dist/schema/budget_incidents.d.ts +297 -0
  1052. package/dist/runtime/server/node_modules/@paperclipai/db/dist/schema/budget_incidents.d.ts.map +1 -0
  1053. package/dist/runtime/server/node_modules/@paperclipai/db/dist/schema/budget_incidents.js +29 -0
  1054. package/dist/runtime/server/node_modules/@paperclipai/db/dist/schema/budget_incidents.js.map +1 -0
  1055. package/dist/runtime/server/node_modules/@paperclipai/db/dist/schema/budget_policies.d.ts +263 -0
  1056. package/dist/runtime/server/node_modules/@paperclipai/db/dist/schema/budget_policies.d.ts.map +1 -0
  1057. package/dist/runtime/server/node_modules/@paperclipai/db/dist/schema/budget_policies.js +24 -0
  1058. package/dist/runtime/server/node_modules/@paperclipai/db/dist/schema/budget_policies.js.map +1 -0
  1059. package/dist/runtime/server/node_modules/@paperclipai/db/dist/schema/companies.d.ts +246 -0
  1060. package/dist/runtime/server/node_modules/@paperclipai/db/dist/schema/companies.d.ts.map +1 -0
  1061. package/dist/runtime/server/node_modules/@paperclipai/db/dist/schema/companies.js +22 -0
  1062. package/dist/runtime/server/node_modules/@paperclipai/db/dist/schema/companies.js.map +1 -0
  1063. package/dist/runtime/server/node_modules/@paperclipai/db/dist/schema/company_logos.d.ts +93 -0
  1064. package/dist/runtime/server/node_modules/@paperclipai/db/dist/schema/company_logos.d.ts.map +1 -0
  1065. package/dist/runtime/server/node_modules/@paperclipai/db/dist/schema/company_logos.js +14 -0
  1066. package/dist/runtime/server/node_modules/@paperclipai/db/dist/schema/company_logos.js.map +1 -0
  1067. package/dist/runtime/server/node_modules/@paperclipai/db/dist/schema/company_memberships.d.ts +144 -0
  1068. package/dist/runtime/server/node_modules/@paperclipai/db/dist/schema/company_memberships.d.ts.map +1 -0
  1069. package/dist/runtime/server/node_modules/@paperclipai/db/dist/schema/company_memberships.js +17 -0
  1070. package/dist/runtime/server/node_modules/@paperclipai/db/dist/schema/company_memberships.js.map +1 -0
  1071. package/dist/runtime/server/node_modules/@paperclipai/db/dist/schema/company_secret_versions.d.ts +163 -0
  1072. package/dist/runtime/server/node_modules/@paperclipai/db/dist/schema/company_secret_versions.d.ts.map +1 -0
  1073. package/dist/runtime/server/node_modules/@paperclipai/db/dist/schema/company_secret_versions.js +19 -0
  1074. package/dist/runtime/server/node_modules/@paperclipai/db/dist/schema/company_secret_versions.js.map +1 -0
  1075. package/dist/runtime/server/node_modules/@paperclipai/db/dist/schema/company_secrets.d.ts +195 -0
  1076. package/dist/runtime/server/node_modules/@paperclipai/db/dist/schema/company_secrets.d.ts.map +1 -0
  1077. package/dist/runtime/server/node_modules/@paperclipai/db/dist/schema/company_secrets.js +21 -0
  1078. package/dist/runtime/server/node_modules/@paperclipai/db/dist/schema/company_secrets.js.map +1 -0
  1079. package/dist/runtime/server/node_modules/@paperclipai/db/dist/schema/cost_events.d.ts +314 -0
  1080. package/dist/runtime/server/node_modules/@paperclipai/db/dist/schema/cost_events.d.ts.map +1 -0
  1081. package/dist/runtime/server/node_modules/@paperclipai/db/dist/schema/cost_events.js +34 -0
  1082. package/dist/runtime/server/node_modules/@paperclipai/db/dist/schema/cost_events.js.map +1 -0
  1083. package/dist/runtime/server/node_modules/@paperclipai/db/dist/schema/document_revisions.d.ts +161 -0
  1084. package/dist/runtime/server/node_modules/@paperclipai/db/dist/schema/document_revisions.d.ts.map +1 -0
  1085. package/dist/runtime/server/node_modules/@paperclipai/db/dist/schema/document_revisions.js +19 -0
  1086. package/dist/runtime/server/node_modules/@paperclipai/db/dist/schema/document_revisions.js.map +1 -0
  1087. package/dist/runtime/server/node_modules/@paperclipai/db/dist/schema/documents.d.ts +229 -0
  1088. package/dist/runtime/server/node_modules/@paperclipai/db/dist/schema/documents.d.ts.map +1 -0
  1089. package/dist/runtime/server/node_modules/@paperclipai/db/dist/schema/documents.js +22 -0
  1090. package/dist/runtime/server/node_modules/@paperclipai/db/dist/schema/documents.js.map +1 -0
  1091. package/dist/runtime/server/node_modules/@paperclipai/db/dist/schema/execution_workspaces.d.ts +418 -0
  1092. package/dist/runtime/server/node_modules/@paperclipai/db/dist/schema/execution_workspaces.d.ts.map +1 -0
  1093. package/dist/runtime/server/node_modules/@paperclipai/db/dist/schema/execution_workspaces.js +39 -0
  1094. package/dist/runtime/server/node_modules/@paperclipai/db/dist/schema/execution_workspaces.js.map +1 -0
  1095. package/dist/runtime/server/node_modules/@paperclipai/db/dist/schema/finance_events.d.ts +469 -0
  1096. package/dist/runtime/server/node_modules/@paperclipai/db/dist/schema/finance_events.d.ts.map +1 -0
  1097. package/dist/runtime/server/node_modules/@paperclipai/db/dist/schema/finance_events.js +45 -0
  1098. package/dist/runtime/server/node_modules/@paperclipai/db/dist/schema/finance_events.js.map +1 -0
  1099. package/dist/runtime/server/node_modules/@paperclipai/db/dist/schema/goals.d.ts +178 -0
  1100. package/dist/runtime/server/node_modules/@paperclipai/db/dist/schema/goals.d.ts.map +1 -0
  1101. package/dist/runtime/server/node_modules/@paperclipai/db/dist/schema/goals.js +18 -0
  1102. package/dist/runtime/server/node_modules/@paperclipai/db/dist/schema/goals.js.map +1 -0
  1103. package/dist/runtime/server/node_modules/@paperclipai/db/dist/schema/heartbeat_run_events.d.ts +214 -0
  1104. package/dist/runtime/server/node_modules/@paperclipai/db/dist/schema/heartbeat_run_events.d.ts.map +1 -0
  1105. package/dist/runtime/server/node_modules/@paperclipai/db/dist/schema/heartbeat_run_events.js +23 -0
  1106. package/dist/runtime/server/node_modules/@paperclipai/db/dist/schema/heartbeat_run_events.js.map +1 -0
  1107. package/dist/runtime/server/node_modules/@paperclipai/db/dist/schema/heartbeat_runs.d.ts +558 -0
  1108. package/dist/runtime/server/node_modules/@paperclipai/db/dist/schema/heartbeat_runs.d.ts.map +1 -0
  1109. package/dist/runtime/server/node_modules/@paperclipai/db/dist/schema/heartbeat_runs.js +43 -0
  1110. package/dist/runtime/server/node_modules/@paperclipai/db/dist/schema/heartbeat_runs.js.map +1 -0
  1111. package/dist/runtime/server/node_modules/@paperclipai/db/dist/schema/index.d.ts +55 -0
  1112. package/dist/runtime/server/node_modules/@paperclipai/db/dist/schema/index.d.ts.map +1 -0
  1113. package/dist/runtime/server/node_modules/@paperclipai/db/dist/schema/index.js +55 -0
  1114. package/dist/runtime/server/node_modules/@paperclipai/db/dist/schema/index.js.map +1 -0
  1115. package/dist/runtime/server/node_modules/@paperclipai/db/dist/schema/instance_settings.d.ts +95 -0
  1116. package/dist/runtime/server/node_modules/@paperclipai/db/dist/schema/instance_settings.d.ts.map +1 -0
  1117. package/dist/runtime/server/node_modules/@paperclipai/db/dist/schema/instance_settings.js +11 -0
  1118. package/dist/runtime/server/node_modules/@paperclipai/db/dist/schema/instance_settings.js.map +1 -0
  1119. package/dist/runtime/server/node_modules/@paperclipai/db/dist/schema/instance_user_roles.d.ts +93 -0
  1120. package/dist/runtime/server/node_modules/@paperclipai/db/dist/schema/instance_user_roles.d.ts.map +1 -0
  1121. package/dist/runtime/server/node_modules/@paperclipai/db/dist/schema/instance_user_roles.js +12 -0
  1122. package/dist/runtime/server/node_modules/@paperclipai/db/dist/schema/instance_user_roles.js.map +1 -0
  1123. package/dist/runtime/server/node_modules/@paperclipai/db/dist/schema/invites.d.ts +214 -0
  1124. package/dist/runtime/server/node_modules/@paperclipai/db/dist/schema/invites.d.ts.map +1 -0
  1125. package/dist/runtime/server/node_modules/@paperclipai/db/dist/schema/invites.js +20 -0
  1126. package/dist/runtime/server/node_modules/@paperclipai/db/dist/schema/invites.js.map +1 -0
  1127. package/dist/runtime/server/node_modules/@paperclipai/db/dist/schema/issue_approvals.d.ts +110 -0
  1128. package/dist/runtime/server/node_modules/@paperclipai/db/dist/schema/issue_approvals.d.ts.map +1 -0
  1129. package/dist/runtime/server/node_modules/@paperclipai/db/dist/schema/issue_approvals.js +19 -0
  1130. package/dist/runtime/server/node_modules/@paperclipai/db/dist/schema/issue_approvals.js.map +1 -0
  1131. package/dist/runtime/server/node_modules/@paperclipai/db/dist/schema/issue_attachments.d.ts +127 -0
  1132. package/dist/runtime/server/node_modules/@paperclipai/db/dist/schema/issue_attachments.d.ts.map +1 -0
  1133. package/dist/runtime/server/node_modules/@paperclipai/db/dist/schema/issue_attachments.js +19 -0
  1134. package/dist/runtime/server/node_modules/@paperclipai/db/dist/schema/issue_attachments.js.map +1 -0
  1135. package/dist/runtime/server/node_modules/@paperclipai/db/dist/schema/issue_comments.d.ts +144 -0
  1136. package/dist/runtime/server/node_modules/@paperclipai/db/dist/schema/issue_comments.d.ts.map +1 -0
  1137. package/dist/runtime/server/node_modules/@paperclipai/db/dist/schema/issue_comments.js +20 -0
  1138. package/dist/runtime/server/node_modules/@paperclipai/db/dist/schema/issue_comments.js.map +1 -0
  1139. package/dist/runtime/server/node_modules/@paperclipai/db/dist/schema/issue_documents.d.ts +127 -0
  1140. package/dist/runtime/server/node_modules/@paperclipai/db/dist/schema/issue_documents.d.ts.map +1 -0
  1141. package/dist/runtime/server/node_modules/@paperclipai/db/dist/schema/issue_documents.js +18 -0
  1142. package/dist/runtime/server/node_modules/@paperclipai/db/dist/schema/issue_documents.js.map +1 -0
  1143. package/dist/runtime/server/node_modules/@paperclipai/db/dist/schema/issue_labels.d.ts +76 -0
  1144. package/dist/runtime/server/node_modules/@paperclipai/db/dist/schema/issue_labels.d.ts.map +1 -0
  1145. package/dist/runtime/server/node_modules/@paperclipai/db/dist/schema/issue_labels.js +16 -0
  1146. package/dist/runtime/server/node_modules/@paperclipai/db/dist/schema/issue_labels.js.map +1 -0
  1147. package/dist/runtime/server/node_modules/@paperclipai/db/dist/schema/issue_read_states.d.ts +127 -0
  1148. package/dist/runtime/server/node_modules/@paperclipai/db/dist/schema/issue_read_states.d.ts.map +1 -0
  1149. package/dist/runtime/server/node_modules/@paperclipai/db/dist/schema/issue_read_states.js +17 -0
  1150. package/dist/runtime/server/node_modules/@paperclipai/db/dist/schema/issue_read_states.js.map +1 -0
  1151. package/dist/runtime/server/node_modules/@paperclipai/db/dist/schema/issue_work_products.d.ts +350 -0
  1152. package/dist/runtime/server/node_modules/@paperclipai/db/dist/schema/issue_work_products.d.ts.map +1 -0
  1153. package/dist/runtime/server/node_modules/@paperclipai/db/dist/schema/issue_work_products.js +37 -0
  1154. package/dist/runtime/server/node_modules/@paperclipai/db/dist/schema/issue_work_products.js.map +1 -0
  1155. package/dist/runtime/server/node_modules/@paperclipai/db/dist/schema/issues.d.ts +590 -0
  1156. package/dist/runtime/server/node_modules/@paperclipai/db/dist/schema/issues.d.ts.map +1 -0
  1157. package/dist/runtime/server/node_modules/@paperclipai/db/dist/schema/issues.js +58 -0
  1158. package/dist/runtime/server/node_modules/@paperclipai/db/dist/schema/issues.js.map +1 -0
  1159. package/dist/runtime/server/node_modules/@paperclipai/db/dist/schema/join_requests.d.ts +384 -0
  1160. package/dist/runtime/server/node_modules/@paperclipai/db/dist/schema/join_requests.d.ts.map +1 -0
  1161. package/dist/runtime/server/node_modules/@paperclipai/db/dist/schema/join_requests.js +32 -0
  1162. package/dist/runtime/server/node_modules/@paperclipai/db/dist/schema/join_requests.js.map +1 -0
  1163. package/dist/runtime/server/node_modules/@paperclipai/db/dist/schema/labels.d.ts +110 -0
  1164. package/dist/runtime/server/node_modules/@paperclipai/db/dist/schema/labels.d.ts.map +1 -0
  1165. package/dist/runtime/server/node_modules/@paperclipai/db/dist/schema/labels.js +14 -0
  1166. package/dist/runtime/server/node_modules/@paperclipai/db/dist/schema/labels.js.map +1 -0
  1167. package/dist/runtime/server/node_modules/@paperclipai/db/dist/schema/plugin_company_settings.d.ts +158 -0
  1168. package/dist/runtime/server/node_modules/@paperclipai/db/dist/schema/plugin_company_settings.d.ts.map +1 -0
  1169. package/dist/runtime/server/node_modules/@paperclipai/db/dist/schema/plugin_company_settings.js +34 -0
  1170. package/dist/runtime/server/node_modules/@paperclipai/db/dist/schema/plugin_company_settings.js.map +1 -0
  1171. package/dist/runtime/server/node_modules/@paperclipai/db/dist/schema/plugin_config.d.ts +123 -0
  1172. package/dist/runtime/server/node_modules/@paperclipai/db/dist/schema/plugin_config.d.ts.map +1 -0
  1173. package/dist/runtime/server/node_modules/@paperclipai/db/dist/schema/plugin_config.js +26 -0
  1174. package/dist/runtime/server/node_modules/@paperclipai/db/dist/schema/plugin_config.js.map +1 -0
  1175. package/dist/runtime/server/node_modules/@paperclipai/db/dist/schema/plugin_entities.d.ts +213 -0
  1176. package/dist/runtime/server/node_modules/@paperclipai/db/dist/schema/plugin_entities.d.ts.map +1 -0
  1177. package/dist/runtime/server/node_modules/@paperclipai/db/dist/schema/plugin_entities.js +37 -0
  1178. package/dist/runtime/server/node_modules/@paperclipai/db/dist/schema/plugin_entities.js.map +1 -0
  1179. package/dist/runtime/server/node_modules/@paperclipai/db/dist/schema/plugin_jobs.d.ts +392 -0
  1180. package/dist/runtime/server/node_modules/@paperclipai/db/dist/schema/plugin_jobs.d.ts.map +1 -0
  1181. package/dist/runtime/server/node_modules/@paperclipai/db/dist/schema/plugin_jobs.js +83 -0
  1182. package/dist/runtime/server/node_modules/@paperclipai/db/dist/schema/plugin_jobs.js.map +1 -0
  1183. package/dist/runtime/server/node_modules/@paperclipai/db/dist/schema/plugin_logs.d.ts +125 -0
  1184. package/dist/runtime/server/node_modules/@paperclipai/db/dist/schema/plugin_logs.d.ts.map +1 -0
  1185. package/dist/runtime/server/node_modules/@paperclipai/db/dist/schema/plugin_logs.js +29 -0
  1186. package/dist/runtime/server/node_modules/@paperclipai/db/dist/schema/plugin_logs.js.map +1 -0
  1187. package/dist/runtime/server/node_modules/@paperclipai/db/dist/schema/plugin_state.d.ts +169 -0
  1188. package/dist/runtime/server/node_modules/@paperclipai/db/dist/schema/plugin_state.d.ts.map +1 -0
  1189. package/dist/runtime/server/node_modules/@paperclipai/db/dist/schema/plugin_state.js +68 -0
  1190. package/dist/runtime/server/node_modules/@paperclipai/db/dist/schema/plugin_state.js.map +1 -0
  1191. package/dist/runtime/server/node_modules/@paperclipai/db/dist/schema/plugin_webhooks.d.ts +239 -0
  1192. package/dist/runtime/server/node_modules/@paperclipai/db/dist/schema/plugin_webhooks.d.ts.map +1 -0
  1193. package/dist/runtime/server/node_modules/@paperclipai/db/dist/schema/plugin_webhooks.js +52 -0
  1194. package/dist/runtime/server/node_modules/@paperclipai/db/dist/schema/plugin_webhooks.js.map +1 -0
  1195. package/dist/runtime/server/node_modules/@paperclipai/db/dist/schema/plugins.d.ts +246 -0
  1196. package/dist/runtime/server/node_modules/@paperclipai/db/dist/schema/plugins.d.ts.map +1 -0
  1197. package/dist/runtime/server/node_modules/@paperclipai/db/dist/schema/plugins.js +31 -0
  1198. package/dist/runtime/server/node_modules/@paperclipai/db/dist/schema/plugins.js.map +1 -0
  1199. package/dist/runtime/server/node_modules/@paperclipai/db/dist/schema/principal_permission_grants.d.ts +163 -0
  1200. package/dist/runtime/server/node_modules/@paperclipai/db/dist/schema/principal_permission_grants.d.ts.map +1 -0
  1201. package/dist/runtime/server/node_modules/@paperclipai/db/dist/schema/principal_permission_grants.js +17 -0
  1202. package/dist/runtime/server/node_modules/@paperclipai/db/dist/schema/principal_permission_grants.js.map +1 -0
  1203. package/dist/runtime/server/node_modules/@paperclipai/db/dist/schema/project_goals.d.ts +93 -0
  1204. package/dist/runtime/server/node_modules/@paperclipai/db/dist/schema/project_goals.d.ts.map +1 -0
  1205. package/dist/runtime/server/node_modules/@paperclipai/db/dist/schema/project_goals.js +17 -0
  1206. package/dist/runtime/server/node_modules/@paperclipai/db/dist/schema/project_goals.js.map +1 -0
  1207. package/dist/runtime/server/node_modules/@paperclipai/db/dist/schema/project_workspaces.d.ts +333 -0
  1208. package/dist/runtime/server/node_modules/@paperclipai/db/dist/schema/project_workspaces.d.ts.map +1 -0
  1209. package/dist/runtime/server/node_modules/@paperclipai/db/dist/schema/project_workspaces.js +32 -0
  1210. package/dist/runtime/server/node_modules/@paperclipai/db/dist/schema/project_workspaces.js.map +1 -0
  1211. package/dist/runtime/server/node_modules/@paperclipai/db/dist/schema/projects.d.ts +265 -0
  1212. package/dist/runtime/server/node_modules/@paperclipai/db/dist/schema/projects.d.ts.map +1 -0
  1213. package/dist/runtime/server/node_modules/@paperclipai/db/dist/schema/projects.js +24 -0
  1214. package/dist/runtime/server/node_modules/@paperclipai/db/dist/schema/projects.js.map +1 -0
  1215. package/dist/runtime/server/node_modules/@paperclipai/db/dist/schema/tickets.d.ts +284 -0
  1216. package/dist/runtime/server/node_modules/@paperclipai/db/dist/schema/tickets.d.ts.map +1 -0
  1217. package/dist/runtime/server/node_modules/@paperclipai/db/dist/schema/tickets.js +24 -0
  1218. package/dist/runtime/server/node_modules/@paperclipai/db/dist/schema/tickets.js.map +1 -0
  1219. package/dist/runtime/server/node_modules/@paperclipai/db/dist/schema/workspace_operations.d.ts +367 -0
  1220. package/dist/runtime/server/node_modules/@paperclipai/db/dist/schema/workspace_operations.d.ts.map +1 -0
  1221. package/dist/runtime/server/node_modules/@paperclipai/db/dist/schema/workspace_operations.js +35 -0
  1222. package/dist/runtime/server/node_modules/@paperclipai/db/dist/schema/workspace_operations.js.map +1 -0
  1223. package/dist/runtime/server/node_modules/@paperclipai/db/dist/schema/workspace_runtime_services.d.ts +469 -0
  1224. package/dist/runtime/server/node_modules/@paperclipai/db/dist/schema/workspace_runtime_services.d.ts.map +1 -0
  1225. package/dist/runtime/server/node_modules/@paperclipai/db/dist/schema/workspace_runtime_services.js +44 -0
  1226. package/dist/runtime/server/node_modules/@paperclipai/db/dist/schema/workspace_runtime_services.js.map +1 -0
  1227. package/dist/runtime/server/node_modules/@paperclipai/db/dist/seed.d.ts +2 -0
  1228. package/dist/runtime/server/node_modules/@paperclipai/db/dist/seed.d.ts.map +1 -0
  1229. package/dist/runtime/server/node_modules/@paperclipai/db/dist/seed.js +91 -0
  1230. package/dist/runtime/server/node_modules/@paperclipai/db/dist/seed.js.map +1 -0
  1231. package/dist/runtime/server/node_modules/@paperclipai/db/package.json +36 -0
  1232. package/dist/runtime/server/node_modules/@paperclipai/plugin-sdk/dist/bundlers.d.ts +57 -0
  1233. package/dist/runtime/server/node_modules/@paperclipai/plugin-sdk/dist/bundlers.d.ts.map +1 -0
  1234. package/dist/runtime/server/node_modules/@paperclipai/plugin-sdk/dist/bundlers.js +105 -0
  1235. package/dist/runtime/server/node_modules/@paperclipai/plugin-sdk/dist/bundlers.js.map +1 -0
  1236. package/dist/runtime/server/node_modules/@paperclipai/plugin-sdk/dist/define-plugin.d.ts +218 -0
  1237. package/dist/runtime/server/node_modules/@paperclipai/plugin-sdk/dist/define-plugin.d.ts.map +1 -0
  1238. package/dist/runtime/server/node_modules/@paperclipai/plugin-sdk/dist/define-plugin.js +85 -0
  1239. package/dist/runtime/server/node_modules/@paperclipai/plugin-sdk/dist/define-plugin.js.map +1 -0
  1240. package/dist/runtime/server/node_modules/@paperclipai/plugin-sdk/dist/dev-cli.d.ts +3 -0
  1241. package/dist/runtime/server/node_modules/@paperclipai/plugin-sdk/dist/dev-cli.d.ts.map +1 -0
  1242. package/dist/runtime/server/node_modules/@paperclipai/plugin-sdk/dist/dev-cli.js +49 -0
  1243. package/dist/runtime/server/node_modules/@paperclipai/plugin-sdk/dist/dev-cli.js.map +1 -0
  1244. package/dist/runtime/server/node_modules/@paperclipai/plugin-sdk/dist/dev-server.d.ts +34 -0
  1245. package/dist/runtime/server/node_modules/@paperclipai/plugin-sdk/dist/dev-server.d.ts.map +1 -0
  1246. package/dist/runtime/server/node_modules/@paperclipai/plugin-sdk/dist/dev-server.js +194 -0
  1247. package/dist/runtime/server/node_modules/@paperclipai/plugin-sdk/dist/dev-server.js.map +1 -0
  1248. package/dist/runtime/server/node_modules/@paperclipai/plugin-sdk/dist/host-client-factory.d.ts +229 -0
  1249. package/dist/runtime/server/node_modules/@paperclipai/plugin-sdk/dist/host-client-factory.d.ts.map +1 -0
  1250. package/dist/runtime/server/node_modules/@paperclipai/plugin-sdk/dist/host-client-factory.js +353 -0
  1251. package/dist/runtime/server/node_modules/@paperclipai/plugin-sdk/dist/host-client-factory.js.map +1 -0
  1252. package/dist/runtime/server/node_modules/@paperclipai/plugin-sdk/dist/index.d.ts +84 -0
  1253. package/dist/runtime/server/node_modules/@paperclipai/plugin-sdk/dist/index.d.ts.map +1 -0
  1254. package/dist/runtime/server/node_modules/@paperclipai/plugin-sdk/dist/index.js +84 -0
  1255. package/dist/runtime/server/node_modules/@paperclipai/plugin-sdk/dist/index.js.map +1 -0
  1256. package/dist/runtime/server/node_modules/@paperclipai/plugin-sdk/dist/protocol.d.ts +881 -0
  1257. package/dist/runtime/server/node_modules/@paperclipai/plugin-sdk/dist/protocol.d.ts.map +1 -0
  1258. package/dist/runtime/server/node_modules/@paperclipai/plugin-sdk/dist/protocol.js +297 -0
  1259. package/dist/runtime/server/node_modules/@paperclipai/plugin-sdk/dist/protocol.js.map +1 -0
  1260. package/dist/runtime/server/node_modules/@paperclipai/plugin-sdk/dist/testing.d.ts +63 -0
  1261. package/dist/runtime/server/node_modules/@paperclipai/plugin-sdk/dist/testing.d.ts.map +1 -0
  1262. package/dist/runtime/server/node_modules/@paperclipai/plugin-sdk/dist/testing.js +702 -0
  1263. package/dist/runtime/server/node_modules/@paperclipai/plugin-sdk/dist/testing.js.map +1 -0
  1264. package/dist/runtime/server/node_modules/@paperclipai/plugin-sdk/dist/types.d.ts +982 -0
  1265. package/dist/runtime/server/node_modules/@paperclipai/plugin-sdk/dist/types.d.ts.map +1 -0
  1266. package/dist/runtime/server/node_modules/@paperclipai/plugin-sdk/dist/types.js +12 -0
  1267. package/dist/runtime/server/node_modules/@paperclipai/plugin-sdk/dist/types.js.map +1 -0
  1268. package/dist/runtime/server/node_modules/@paperclipai/plugin-sdk/dist/ui/components.d.ts +257 -0
  1269. package/dist/runtime/server/node_modules/@paperclipai/plugin-sdk/dist/ui/components.d.ts.map +1 -0
  1270. package/dist/runtime/server/node_modules/@paperclipai/plugin-sdk/dist/ui/components.js +97 -0
  1271. package/dist/runtime/server/node_modules/@paperclipai/plugin-sdk/dist/ui/components.js.map +1 -0
  1272. package/dist/runtime/server/node_modules/@paperclipai/plugin-sdk/dist/ui/hooks.d.ts +120 -0
  1273. package/dist/runtime/server/node_modules/@paperclipai/plugin-sdk/dist/ui/hooks.d.ts.map +1 -0
  1274. package/dist/runtime/server/node_modules/@paperclipai/plugin-sdk/dist/ui/hooks.js +148 -0
  1275. package/dist/runtime/server/node_modules/@paperclipai/plugin-sdk/dist/ui/hooks.js.map +1 -0
  1276. package/dist/runtime/server/node_modules/@paperclipai/plugin-sdk/dist/ui/index.d.ts +50 -0
  1277. package/dist/runtime/server/node_modules/@paperclipai/plugin-sdk/dist/ui/index.d.ts.map +1 -0
  1278. package/dist/runtime/server/node_modules/@paperclipai/plugin-sdk/dist/ui/index.js +48 -0
  1279. package/dist/runtime/server/node_modules/@paperclipai/plugin-sdk/dist/ui/index.js.map +1 -0
  1280. package/dist/runtime/server/node_modules/@paperclipai/plugin-sdk/dist/ui/runtime.d.ts +3 -0
  1281. package/dist/runtime/server/node_modules/@paperclipai/plugin-sdk/dist/ui/runtime.d.ts.map +1 -0
  1282. package/dist/runtime/server/node_modules/@paperclipai/plugin-sdk/dist/ui/runtime.js +30 -0
  1283. package/dist/runtime/server/node_modules/@paperclipai/plugin-sdk/dist/ui/runtime.js.map +1 -0
  1284. package/dist/runtime/server/node_modules/@paperclipai/plugin-sdk/dist/ui/types.d.ts +308 -0
  1285. package/dist/runtime/server/node_modules/@paperclipai/plugin-sdk/dist/ui/types.d.ts.map +1 -0
  1286. package/dist/runtime/server/node_modules/@paperclipai/plugin-sdk/dist/ui/types.js +17 -0
  1287. package/dist/runtime/server/node_modules/@paperclipai/plugin-sdk/dist/ui/types.js.map +1 -0
  1288. package/dist/runtime/server/node_modules/@paperclipai/plugin-sdk/dist/worker-rpc-host.d.ts +127 -0
  1289. package/dist/runtime/server/node_modules/@paperclipai/plugin-sdk/dist/worker-rpc-host.d.ts.map +1 -0
  1290. package/dist/runtime/server/node_modules/@paperclipai/plugin-sdk/dist/worker-rpc-host.js +941 -0
  1291. package/dist/runtime/server/node_modules/@paperclipai/plugin-sdk/dist/worker-rpc-host.js.map +1 -0
  1292. package/dist/runtime/server/node_modules/@paperclipai/plugin-sdk/package.json +74 -0
  1293. package/dist/runtime/server/node_modules/@paperclipai/shared/dist/agent-url-key.d.ts +4 -0
  1294. package/dist/runtime/server/node_modules/@paperclipai/shared/dist/agent-url-key.d.ts.map +1 -0
  1295. package/dist/runtime/server/node_modules/@paperclipai/shared/dist/agent-url-key.js +22 -0
  1296. package/dist/runtime/server/node_modules/@paperclipai/shared/dist/agent-url-key.js.map +1 -0
  1297. package/dist/runtime/server/node_modules/@paperclipai/shared/dist/api.d.ts +20 -0
  1298. package/dist/runtime/server/node_modules/@paperclipai/shared/dist/api.d.ts.map +1 -0
  1299. package/dist/runtime/server/node_modules/@paperclipai/shared/dist/api.js +20 -0
  1300. package/dist/runtime/server/node_modules/@paperclipai/shared/dist/api.js.map +1 -0
  1301. package/dist/runtime/server/node_modules/@paperclipai/shared/dist/config-schema.d.ts +755 -0
  1302. package/dist/runtime/server/node_modules/@paperclipai/shared/dist/config-schema.d.ts.map +1 -0
  1303. package/dist/runtime/server/node_modules/@paperclipai/shared/dist/config-schema.js +154 -0
  1304. package/dist/runtime/server/node_modules/@paperclipai/shared/dist/config-schema.js.map +1 -0
  1305. package/dist/runtime/server/node_modules/@paperclipai/shared/dist/constants.d.ts +214 -0
  1306. package/dist/runtime/server/node_modules/@paperclipai/shared/dist/constants.d.ts.map +1 -0
  1307. package/dist/runtime/server/node_modules/@paperclipai/shared/dist/constants.js +553 -0
  1308. package/dist/runtime/server/node_modules/@paperclipai/shared/dist/constants.js.map +1 -0
  1309. package/dist/runtime/server/node_modules/@paperclipai/shared/dist/gtm.d.ts +116 -0
  1310. package/dist/runtime/server/node_modules/@paperclipai/shared/dist/gtm.d.ts.map +1 -0
  1311. package/dist/runtime/server/node_modules/@paperclipai/shared/dist/gtm.js +181 -0
  1312. package/dist/runtime/server/node_modules/@paperclipai/shared/dist/gtm.js.map +1 -0
  1313. package/dist/runtime/server/node_modules/@paperclipai/shared/dist/index.d.ts +12 -0
  1314. package/dist/runtime/server/node_modules/@paperclipai/shared/dist/index.d.ts.map +1 -0
  1315. package/dist/runtime/server/node_modules/@paperclipai/shared/dist/index.js +11 -0
  1316. package/dist/runtime/server/node_modules/@paperclipai/shared/dist/index.js.map +1 -0
  1317. package/dist/runtime/server/node_modules/@paperclipai/shared/dist/project-mentions.d.ts +9 -0
  1318. package/dist/runtime/server/node_modules/@paperclipai/shared/dist/project-mentions.d.ts.map +1 -0
  1319. package/dist/runtime/server/node_modules/@paperclipai/shared/dist/project-mentions.js +71 -0
  1320. package/dist/runtime/server/node_modules/@paperclipai/shared/dist/project-mentions.js.map +1 -0
  1321. package/dist/runtime/server/node_modules/@paperclipai/shared/dist/project-url-key.d.ts +3 -0
  1322. package/dist/runtime/server/node_modules/@paperclipai/shared/dist/project-url-key.d.ts.map +1 -0
  1323. package/dist/runtime/server/node_modules/@paperclipai/shared/dist/project-url-key.js +16 -0
  1324. package/dist/runtime/server/node_modules/@paperclipai/shared/dist/project-url-key.js.map +1 -0
  1325. package/dist/runtime/server/node_modules/@paperclipai/shared/dist/surface-runtime.d.ts +15 -0
  1326. package/dist/runtime/server/node_modules/@paperclipai/shared/dist/surface-runtime.d.ts.map +1 -0
  1327. package/dist/runtime/server/node_modules/@paperclipai/shared/dist/surface-runtime.js +40 -0
  1328. package/dist/runtime/server/node_modules/@paperclipai/shared/dist/surface-runtime.js.map +1 -0
  1329. package/dist/runtime/server/node_modules/@paperclipai/shared/dist/types/access.d.ts +67 -0
  1330. package/dist/runtime/server/node_modules/@paperclipai/shared/dist/types/access.d.ts.map +1 -0
  1331. package/dist/runtime/server/node_modules/@paperclipai/shared/dist/types/access.js +2 -0
  1332. package/dist/runtime/server/node_modules/@paperclipai/shared/dist/types/access.js.map +1 -0
  1333. package/dist/runtime/server/node_modules/@paperclipai/shared/dist/types/activity.d.ts +14 -0
  1334. package/dist/runtime/server/node_modules/@paperclipai/shared/dist/types/activity.d.ts.map +1 -0
  1335. package/dist/runtime/server/node_modules/@paperclipai/shared/dist/types/activity.js +2 -0
  1336. package/dist/runtime/server/node_modules/@paperclipai/shared/dist/types/activity.js.map +1 -0
  1337. package/dist/runtime/server/node_modules/@paperclipai/shared/dist/types/agent.d.ts +80 -0
  1338. package/dist/runtime/server/node_modules/@paperclipai/shared/dist/types/agent.d.ts.map +1 -0
  1339. package/dist/runtime/server/node_modules/@paperclipai/shared/dist/types/agent.js +2 -0
  1340. package/dist/runtime/server/node_modules/@paperclipai/shared/dist/types/agent.js.map +1 -0
  1341. package/dist/runtime/server/node_modules/@paperclipai/shared/dist/types/approval.d.ts +26 -0
  1342. package/dist/runtime/server/node_modules/@paperclipai/shared/dist/types/approval.d.ts.map +1 -0
  1343. package/dist/runtime/server/node_modules/@paperclipai/shared/dist/types/approval.js +2 -0
  1344. package/dist/runtime/server/node_modules/@paperclipai/shared/dist/types/approval.js.map +1 -0
  1345. package/dist/runtime/server/node_modules/@paperclipai/shared/dist/types/asset.d.ts +16 -0
  1346. package/dist/runtime/server/node_modules/@paperclipai/shared/dist/types/asset.d.ts.map +1 -0
  1347. package/dist/runtime/server/node_modules/@paperclipai/shared/dist/types/asset.js +2 -0
  1348. package/dist/runtime/server/node_modules/@paperclipai/shared/dist/types/asset.js.map +1 -0
  1349. package/dist/runtime/server/node_modules/@paperclipai/shared/dist/types/budget.d.ts +86 -0
  1350. package/dist/runtime/server/node_modules/@paperclipai/shared/dist/types/budget.d.ts.map +1 -0
  1351. package/dist/runtime/server/node_modules/@paperclipai/shared/dist/types/budget.js +2 -0
  1352. package/dist/runtime/server/node_modules/@paperclipai/shared/dist/types/budget.js.map +1 -0
  1353. package/dist/runtime/server/node_modules/@paperclipai/shared/dist/types/company-portability.d.ts +120 -0
  1354. package/dist/runtime/server/node_modules/@paperclipai/shared/dist/types/company-portability.d.ts.map +1 -0
  1355. package/dist/runtime/server/node_modules/@paperclipai/shared/dist/types/company-portability.js +2 -0
  1356. package/dist/runtime/server/node_modules/@paperclipai/shared/dist/types/company-portability.js.map +1 -0
  1357. package/dist/runtime/server/node_modules/@paperclipai/shared/dist/types/company.d.ts +20 -0
  1358. package/dist/runtime/server/node_modules/@paperclipai/shared/dist/types/company.d.ts.map +1 -0
  1359. package/dist/runtime/server/node_modules/@paperclipai/shared/dist/types/company.js +2 -0
  1360. package/dist/runtime/server/node_modules/@paperclipai/shared/dist/types/company.js.map +1 -0
  1361. package/dist/runtime/server/node_modules/@paperclipai/shared/dist/types/cost.d.ts +106 -0
  1362. package/dist/runtime/server/node_modules/@paperclipai/shared/dist/types/cost.d.ts.map +1 -0
  1363. package/dist/runtime/server/node_modules/@paperclipai/shared/dist/types/cost.js +2 -0
  1364. package/dist/runtime/server/node_modules/@paperclipai/shared/dist/types/cost.js.map +1 -0
  1365. package/dist/runtime/server/node_modules/@paperclipai/shared/dist/types/dashboard.d.ts +28 -0
  1366. package/dist/runtime/server/node_modules/@paperclipai/shared/dist/types/dashboard.d.ts.map +1 -0
  1367. package/dist/runtime/server/node_modules/@paperclipai/shared/dist/types/dashboard.js +2 -0
  1368. package/dist/runtime/server/node_modules/@paperclipai/shared/dist/types/dashboard.js.map +1 -0
  1369. package/dist/runtime/server/node_modules/@paperclipai/shared/dist/types/finance.d.ts +57 -0
  1370. package/dist/runtime/server/node_modules/@paperclipai/shared/dist/types/finance.d.ts.map +1 -0
  1371. package/dist/runtime/server/node_modules/@paperclipai/shared/dist/types/finance.js +2 -0
  1372. package/dist/runtime/server/node_modules/@paperclipai/shared/dist/types/finance.js.map +1 -0
  1373. package/dist/runtime/server/node_modules/@paperclipai/shared/dist/types/goal.d.ts +14 -0
  1374. package/dist/runtime/server/node_modules/@paperclipai/shared/dist/types/goal.d.ts.map +1 -0
  1375. package/dist/runtime/server/node_modules/@paperclipai/shared/dist/types/goal.js +2 -0
  1376. package/dist/runtime/server/node_modules/@paperclipai/shared/dist/types/goal.js.map +1 -0
  1377. package/dist/runtime/server/node_modules/@paperclipai/shared/dist/types/heartbeat.d.ts +118 -0
  1378. package/dist/runtime/server/node_modules/@paperclipai/shared/dist/types/heartbeat.d.ts.map +1 -0
  1379. package/dist/runtime/server/node_modules/@paperclipai/shared/dist/types/heartbeat.js +2 -0
  1380. package/dist/runtime/server/node_modules/@paperclipai/shared/dist/types/heartbeat.js.map +1 -0
  1381. package/dist/runtime/server/node_modules/@paperclipai/shared/dist/types/index.d.ts +26 -0
  1382. package/dist/runtime/server/node_modules/@paperclipai/shared/dist/types/index.d.ts.map +1 -0
  1383. package/dist/runtime/server/node_modules/@paperclipai/shared/dist/types/index.js +2 -0
  1384. package/dist/runtime/server/node_modules/@paperclipai/shared/dist/types/index.js.map +1 -0
  1385. package/dist/runtime/server/node_modules/@paperclipai/shared/dist/types/instance.d.ts +10 -0
  1386. package/dist/runtime/server/node_modules/@paperclipai/shared/dist/types/instance.d.ts.map +1 -0
  1387. package/dist/runtime/server/node_modules/@paperclipai/shared/dist/types/instance.js +2 -0
  1388. package/dist/runtime/server/node_modules/@paperclipai/shared/dist/types/instance.js.map +1 -0
  1389. package/dist/runtime/server/node_modules/@paperclipai/shared/dist/types/issue.d.ts +164 -0
  1390. package/dist/runtime/server/node_modules/@paperclipai/shared/dist/types/issue.d.ts.map +1 -0
  1391. package/dist/runtime/server/node_modules/@paperclipai/shared/dist/types/issue.js +2 -0
  1392. package/dist/runtime/server/node_modules/@paperclipai/shared/dist/types/issue.js.map +1 -0
  1393. package/dist/runtime/server/node_modules/@paperclipai/shared/dist/types/live.d.ts +9 -0
  1394. package/dist/runtime/server/node_modules/@paperclipai/shared/dist/types/live.d.ts.map +1 -0
  1395. package/dist/runtime/server/node_modules/@paperclipai/shared/dist/types/live.js +2 -0
  1396. package/dist/runtime/server/node_modules/@paperclipai/shared/dist/types/live.js.map +1 -0
  1397. package/dist/runtime/server/node_modules/@paperclipai/shared/dist/types/plugin.d.ts +419 -0
  1398. package/dist/runtime/server/node_modules/@paperclipai/shared/dist/types/plugin.d.ts.map +1 -0
  1399. package/dist/runtime/server/node_modules/@paperclipai/shared/dist/types/plugin.js +2 -0
  1400. package/dist/runtime/server/node_modules/@paperclipai/shared/dist/types/plugin.js.map +1 -0
  1401. package/dist/runtime/server/node_modules/@paperclipai/shared/dist/types/project.d.ts +67 -0
  1402. package/dist/runtime/server/node_modules/@paperclipai/shared/dist/types/project.d.ts.map +1 -0
  1403. package/dist/runtime/server/node_modules/@paperclipai/shared/dist/types/project.js +2 -0
  1404. package/dist/runtime/server/node_modules/@paperclipai/shared/dist/types/project.js.map +1 -0
  1405. package/dist/runtime/server/node_modules/@paperclipai/shared/dist/types/quota.d.ts +26 -0
  1406. package/dist/runtime/server/node_modules/@paperclipai/shared/dist/types/quota.d.ts.map +1 -0
  1407. package/dist/runtime/server/node_modules/@paperclipai/shared/dist/types/quota.js +2 -0
  1408. package/dist/runtime/server/node_modules/@paperclipai/shared/dist/types/quota.js.map +1 -0
  1409. package/dist/runtime/server/node_modules/@paperclipai/shared/dist/types/secrets.d.ts +32 -0
  1410. package/dist/runtime/server/node_modules/@paperclipai/shared/dist/types/secrets.d.ts.map +1 -0
  1411. package/dist/runtime/server/node_modules/@paperclipai/shared/dist/types/secrets.js +2 -0
  1412. package/dist/runtime/server/node_modules/@paperclipai/shared/dist/types/secrets.js.map +1 -0
  1413. package/dist/runtime/server/node_modules/@paperclipai/shared/dist/types/sidebar-badges.d.ts +7 -0
  1414. package/dist/runtime/server/node_modules/@paperclipai/shared/dist/types/sidebar-badges.d.ts.map +1 -0
  1415. package/dist/runtime/server/node_modules/@paperclipai/shared/dist/types/sidebar-badges.js +2 -0
  1416. package/dist/runtime/server/node_modules/@paperclipai/shared/dist/types/sidebar-badges.js.map +1 -0
  1417. package/dist/runtime/server/node_modules/@paperclipai/shared/dist/types/ticket.d.ts +26 -0
  1418. package/dist/runtime/server/node_modules/@paperclipai/shared/dist/types/ticket.d.ts.map +1 -0
  1419. package/dist/runtime/server/node_modules/@paperclipai/shared/dist/types/ticket.js +2 -0
  1420. package/dist/runtime/server/node_modules/@paperclipai/shared/dist/types/ticket.js.map +1 -0
  1421. package/dist/runtime/server/node_modules/@paperclipai/shared/dist/types/work-product.d.ts +27 -0
  1422. package/dist/runtime/server/node_modules/@paperclipai/shared/dist/types/work-product.d.ts.map +1 -0
  1423. package/dist/runtime/server/node_modules/@paperclipai/shared/dist/types/work-product.js +2 -0
  1424. package/dist/runtime/server/node_modules/@paperclipai/shared/dist/types/work-product.js.map +1 -0
  1425. package/dist/runtime/server/node_modules/@paperclipai/shared/dist/types/workspace-operation.d.ts +26 -0
  1426. package/dist/runtime/server/node_modules/@paperclipai/shared/dist/types/workspace-operation.d.ts.map +1 -0
  1427. package/dist/runtime/server/node_modules/@paperclipai/shared/dist/types/workspace-operation.js +2 -0
  1428. package/dist/runtime/server/node_modules/@paperclipai/shared/dist/types/workspace-operation.js.map +1 -0
  1429. package/dist/runtime/server/node_modules/@paperclipai/shared/dist/types/workspace-runtime.d.ts +86 -0
  1430. package/dist/runtime/server/node_modules/@paperclipai/shared/dist/types/workspace-runtime.d.ts.map +1 -0
  1431. package/dist/runtime/server/node_modules/@paperclipai/shared/dist/types/workspace-runtime.js +2 -0
  1432. package/dist/runtime/server/node_modules/@paperclipai/shared/dist/types/workspace-runtime.js.map +1 -0
  1433. package/dist/runtime/server/node_modules/@paperclipai/shared/dist/validators/access.d.ts +109 -0
  1434. package/dist/runtime/server/node_modules/@paperclipai/shared/dist/validators/access.d.ts.map +1 -0
  1435. package/dist/runtime/server/node_modules/@paperclipai/shared/dist/validators/access.js +40 -0
  1436. package/dist/runtime/server/node_modules/@paperclipai/shared/dist/validators/access.js.map +1 -0
  1437. package/dist/runtime/server/node_modules/@paperclipai/shared/dist/validators/agent.d.ts +235 -0
  1438. package/dist/runtime/server/node_modules/@paperclipai/shared/dist/validators/agent.d.ts.map +1 -0
  1439. package/dist/runtime/server/node_modules/@paperclipai/shared/dist/validators/agent.js +71 -0
  1440. package/dist/runtime/server/node_modules/@paperclipai/shared/dist/validators/agent.js.map +1 -0
  1441. package/dist/runtime/server/node_modules/@paperclipai/shared/dist/validators/approval.d.ts +57 -0
  1442. package/dist/runtime/server/node_modules/@paperclipai/shared/dist/validators/approval.d.ts.map +1 -0
  1443. package/dist/runtime/server/node_modules/@paperclipai/shared/dist/validators/approval.js +23 -0
  1444. package/dist/runtime/server/node_modules/@paperclipai/shared/dist/validators/approval.js.map +1 -0
  1445. package/dist/runtime/server/node_modules/@paperclipai/shared/dist/validators/asset.d.ts +10 -0
  1446. package/dist/runtime/server/node_modules/@paperclipai/shared/dist/validators/asset.d.ts.map +1 -0
  1447. package/dist/runtime/server/node_modules/@paperclipai/shared/dist/validators/asset.js +11 -0
  1448. package/dist/runtime/server/node_modules/@paperclipai/shared/dist/validators/asset.js.map +1 -0
  1449. package/dist/runtime/server/node_modules/@paperclipai/shared/dist/validators/budget.d.ts +56 -0
  1450. package/dist/runtime/server/node_modules/@paperclipai/shared/dist/validators/budget.d.ts.map +1 -0
  1451. package/dist/runtime/server/node_modules/@paperclipai/shared/dist/validators/budget.js +27 -0
  1452. package/dist/runtime/server/node_modules/@paperclipai/shared/dist/validators/budget.js.map +1 -0
  1453. package/dist/runtime/server/node_modules/@paperclipai/shared/dist/validators/company-portability.d.ts +1535 -0
  1454. package/dist/runtime/server/node_modules/@paperclipai/shared/dist/validators/company-portability.d.ts.map +1 -0
  1455. package/dist/runtime/server/node_modules/@paperclipai/shared/dist/validators/company-portability.js +95 -0
  1456. package/dist/runtime/server/node_modules/@paperclipai/shared/dist/validators/company-portability.js.map +1 -0
  1457. package/dist/runtime/server/node_modules/@paperclipai/shared/dist/validators/company.d.ts +64 -0
  1458. package/dist/runtime/server/node_modules/@paperclipai/shared/dist/validators/company.d.ts.map +1 -0
  1459. package/dist/runtime/server/node_modules/@paperclipai/shared/dist/validators/company.js +25 -0
  1460. package/dist/runtime/server/node_modules/@paperclipai/shared/dist/validators/company.js.map +1 -0
  1461. package/dist/runtime/server/node_modules/@paperclipai/shared/dist/validators/cost.d.ts +92 -0
  1462. package/dist/runtime/server/node_modules/@paperclipai/shared/dist/validators/cost.d.ts.map +1 -0
  1463. package/dist/runtime/server/node_modules/@paperclipai/shared/dist/validators/cost.js +26 -0
  1464. package/dist/runtime/server/node_modules/@paperclipai/shared/dist/validators/cost.js.map +1 -0
  1465. package/dist/runtime/server/node_modules/@paperclipai/shared/dist/validators/execution-workspace.d.ts +20 -0
  1466. package/dist/runtime/server/node_modules/@paperclipai/shared/dist/validators/execution-workspace.d.ts.map +1 -0
  1467. package/dist/runtime/server/node_modules/@paperclipai/shared/dist/validators/execution-workspace.js +15 -0
  1468. package/dist/runtime/server/node_modules/@paperclipai/shared/dist/validators/execution-workspace.js.map +1 -0
  1469. package/dist/runtime/server/node_modules/@paperclipai/shared/dist/validators/finance.d.ts +129 -0
  1470. package/dist/runtime/server/node_modules/@paperclipai/shared/dist/validators/finance.d.ts.map +1 -0
  1471. package/dist/runtime/server/node_modules/@paperclipai/shared/dist/validators/finance.js +32 -0
  1472. package/dist/runtime/server/node_modules/@paperclipai/shared/dist/validators/finance.js.map +1 -0
  1473. package/dist/runtime/server/node_modules/@paperclipai/shared/dist/validators/goal.d.ts +48 -0
  1474. package/dist/runtime/server/node_modules/@paperclipai/shared/dist/validators/goal.d.ts.map +1 -0
  1475. package/dist/runtime/server/node_modules/@paperclipai/shared/dist/validators/goal.js +12 -0
  1476. package/dist/runtime/server/node_modules/@paperclipai/shared/dist/validators/goal.js.map +1 -0
  1477. package/dist/runtime/server/node_modules/@paperclipai/shared/dist/validators/index.d.ts +19 -0
  1478. package/dist/runtime/server/node_modules/@paperclipai/shared/dist/validators/index.d.ts.map +1 -0
  1479. package/dist/runtime/server/node_modules/@paperclipai/shared/dist/validators/index.js +19 -0
  1480. package/dist/runtime/server/node_modules/@paperclipai/shared/dist/validators/index.js.map +1 -0
  1481. package/dist/runtime/server/node_modules/@paperclipai/shared/dist/validators/instance.d.ts +18 -0
  1482. package/dist/runtime/server/node_modules/@paperclipai/shared/dist/validators/instance.d.ts.map +1 -0
  1483. package/dist/runtime/server/node_modules/@paperclipai/shared/dist/validators/instance.js +6 -0
  1484. package/dist/runtime/server/node_modules/@paperclipai/shared/dist/validators/instance.js.map +1 -0
  1485. package/dist/runtime/server/node_modules/@paperclipai/shared/dist/validators/issue.d.ts +656 -0
  1486. package/dist/runtime/server/node_modules/@paperclipai/shared/dist/validators/issue.d.ts.map +1 -0
  1487. package/dist/runtime/server/node_modules/@paperclipai/shared/dist/validators/issue.js +95 -0
  1488. package/dist/runtime/server/node_modules/@paperclipai/shared/dist/validators/issue.js.map +1 -0
  1489. package/dist/runtime/server/node_modules/@paperclipai/shared/dist/validators/plugin.d.ts +1173 -0
  1490. package/dist/runtime/server/node_modules/@paperclipai/shared/dist/validators/plugin.d.ts.map +1 -0
  1491. package/dist/runtime/server/node_modules/@paperclipai/shared/dist/validators/plugin.js +547 -0
  1492. package/dist/runtime/server/node_modules/@paperclipai/shared/dist/validators/plugin.js.map +1 -0
  1493. package/dist/runtime/server/node_modules/@paperclipai/shared/dist/validators/project.d.ts +583 -0
  1494. package/dist/runtime/server/node_modules/@paperclipai/shared/dist/validators/project.d.ts.map +1 -0
  1495. package/dist/runtime/server/node_modules/@paperclipai/shared/dist/validators/project.js +93 -0
  1496. package/dist/runtime/server/node_modules/@paperclipai/shared/dist/validators/project.js.map +1 -0
  1497. package/dist/runtime/server/node_modules/@paperclipai/shared/dist/validators/secret.d.ts +114 -0
  1498. package/dist/runtime/server/node_modules/@paperclipai/shared/dist/validators/secret.d.ts.map +1 -0
  1499. package/dist/runtime/server/node_modules/@paperclipai/shared/dist/validators/secret.js +35 -0
  1500. package/dist/runtime/server/node_modules/@paperclipai/shared/dist/validators/secret.js.map +1 -0
  1501. package/dist/runtime/server/node_modules/@paperclipai/shared/dist/validators/ticket.d.ts +56 -0
  1502. package/dist/runtime/server/node_modules/@paperclipai/shared/dist/validators/ticket.d.ts.map +1 -0
  1503. package/dist/runtime/server/node_modules/@paperclipai/shared/dist/validators/ticket.js +22 -0
  1504. package/dist/runtime/server/node_modules/@paperclipai/shared/dist/validators/ticket.js.map +1 -0
  1505. package/dist/runtime/server/node_modules/@paperclipai/shared/dist/validators/work-product.d.ts +105 -0
  1506. package/dist/runtime/server/node_modules/@paperclipai/shared/dist/validators/work-product.d.ts.map +1 -0
  1507. package/dist/runtime/server/node_modules/@paperclipai/shared/dist/validators/work-product.js +46 -0
  1508. package/dist/runtime/server/node_modules/@paperclipai/shared/dist/validators/work-product.js.map +1 -0
  1509. package/dist/runtime/server/node_modules/@paperclipai/shared/package.json +33 -0
  1510. package/dist/runtime/server/package.json +5 -0
  1511. package/dist/runtime/server/ui-dist/android-chrome-192x192.png +0 -0
  1512. package/dist/runtime/server/ui-dist/android-chrome-512x512.png +0 -0
  1513. package/dist/runtime/server/ui-dist/apple-touch-icon.png +0 -0
  1514. package/dist/runtime/server/ui-dist/assets/OnboardingWizard-DQqBk_u-.js +839 -0
  1515. package/dist/runtime/server/ui-dist/assets/_basePickBy-CycqvnCH.js +1 -0
  1516. package/dist/runtime/server/ui-dist/assets/_baseUniq-jJI66QE5.js +1 -0
  1517. package/dist/runtime/server/ui-dist/assets/apl-B4CMkyY2.js +1 -0
  1518. package/dist/runtime/server/ui-dist/assets/arc-DAfOGkhs.js +1 -0
  1519. package/dist/runtime/server/ui-dist/assets/architectureDiagram-VXUJARFQ-Bseplhn_.js +36 -0
  1520. package/dist/runtime/server/ui-dist/assets/asciiarmor-Df11BRmG.js +1 -0
  1521. package/dist/runtime/server/ui-dist/assets/asn1-EdZsLKOL.js +1 -0
  1522. package/dist/runtime/server/ui-dist/assets/asterisk-B-8jnY81.js +1 -0
  1523. package/dist/runtime/server/ui-dist/assets/blockDiagram-VD42YOAC-CImRkHxE.js +122 -0
  1524. package/dist/runtime/server/ui-dist/assets/brainfuck-C4LP7Hcl.js +1 -0
  1525. package/dist/runtime/server/ui-dist/assets/c4Diagram-YG6GDRKO-DocRJ0-4.js +10 -0
  1526. package/dist/runtime/server/ui-dist/assets/channel-BBXTGjGr.js +1 -0
  1527. package/dist/runtime/server/ui-dist/assets/chunk-4BX2VUAB-C_QZ3yOc.js +1 -0
  1528. package/dist/runtime/server/ui-dist/assets/chunk-55IACEB6-B83lcfpC.js +1 -0
  1529. package/dist/runtime/server/ui-dist/assets/chunk-B4BG7PRW-_ZGkSCBB.js +165 -0
  1530. package/dist/runtime/server/ui-dist/assets/chunk-DI55MBZ5-D84JXXQK.js +220 -0
  1531. package/dist/runtime/server/ui-dist/assets/chunk-FMBD7UC4-MA5md7TF.js +15 -0
  1532. package/dist/runtime/server/ui-dist/assets/chunk-QN33PNHL-pBntDM8z.js +1 -0
  1533. package/dist/runtime/server/ui-dist/assets/chunk-QZHKN3VN-BaIMiSo-.js +1 -0
  1534. package/dist/runtime/server/ui-dist/assets/chunk-TZMSLE5B-CrjyhaCL.js +1 -0
  1535. package/dist/runtime/server/ui-dist/assets/classDiagram-2ON5EDUG-BNttVhse.js +1 -0
  1536. package/dist/runtime/server/ui-dist/assets/classDiagram-v2-WZHVMYZB-BNttVhse.js +1 -0
  1537. package/dist/runtime/server/ui-dist/assets/clike-B9uivgTg.js +1 -0
  1538. package/dist/runtime/server/ui-dist/assets/clojure-BMjYHr_A.js +1 -0
  1539. package/dist/runtime/server/ui-dist/assets/clone-dcpmW7Wd.js +1 -0
  1540. package/dist/runtime/server/ui-dist/assets/cmake-BQqOBYOt.js +1 -0
  1541. package/dist/runtime/server/ui-dist/assets/cobol-CWcv1MsR.js +1 -0
  1542. package/dist/runtime/server/ui-dist/assets/coffeescript-S37ZYGWr.js +1 -0
  1543. package/dist/runtime/server/ui-dist/assets/commonlisp-DBKNyK5s.js +1 -0
  1544. package/dist/runtime/server/ui-dist/assets/cose-bilkent-S5V4N54A-mNFISgZf.js +1 -0
  1545. package/dist/runtime/server/ui-dist/assets/crystal-SjHAIU92.js +1 -0
  1546. package/dist/runtime/server/ui-dist/assets/css-BnMrqG3P.js +1 -0
  1547. package/dist/runtime/server/ui-dist/assets/cypher-C_CwsFkJ.js +1 -0
  1548. package/dist/runtime/server/ui-dist/assets/cytoscape.esm-BQaXIfA_.js +331 -0
  1549. package/dist/runtime/server/ui-dist/assets/d-pRatUO7H.js +1 -0
  1550. package/dist/runtime/server/ui-dist/assets/dagre-6UL2VRFP-BW8ACip_.js +4 -0
  1551. package/dist/runtime/server/ui-dist/assets/defaultLocale-DX6XiGOO.js +1 -0
  1552. package/dist/runtime/server/ui-dist/assets/diagram-PSM6KHXK-ByQfKnwU.js +24 -0
  1553. package/dist/runtime/server/ui-dist/assets/diagram-QEK2KX5R-CVMlaNLR.js +43 -0
  1554. package/dist/runtime/server/ui-dist/assets/diagram-S2PKOQOG-CfBIwKQh.js +24 -0
  1555. package/dist/runtime/server/ui-dist/assets/diff-DbItnlRl.js +1 -0
  1556. package/dist/runtime/server/ui-dist/assets/dockerfile-BKs6k2Af.js +1 -0
  1557. package/dist/runtime/server/ui-dist/assets/dtd-DF_7sFjM.js +1 -0
  1558. package/dist/runtime/server/ui-dist/assets/dx-root-DH9to-bY.js +280 -0
  1559. package/dist/runtime/server/ui-dist/assets/dylan-DwRh75JA.js +1 -0
  1560. package/dist/runtime/server/ui-dist/assets/ebnf-CDyGwa7X.js +1 -0
  1561. package/dist/runtime/server/ui-dist/assets/ecl-Cabwm37j.js +1 -0
  1562. package/dist/runtime/server/ui-dist/assets/eiffel-CnydiIhH.js +1 -0
  1563. package/dist/runtime/server/ui-dist/assets/elm-vLlmbW-K.js +1 -0
  1564. package/dist/runtime/server/ui-dist/assets/erDiagram-Q2GNP2WA-DjZOGwrs.js +60 -0
  1565. package/dist/runtime/server/ui-dist/assets/erlang-BNw1qcRV.js +1 -0
  1566. package/dist/runtime/server/ui-dist/assets/factor-kuTfRLto.js +1 -0
  1567. package/dist/runtime/server/ui-dist/assets/fcl-Kvtd6kyn.js +1 -0
  1568. package/dist/runtime/server/ui-dist/assets/flowDiagram-NV44I4VS-BpGnGwpO.js +162 -0
  1569. package/dist/runtime/server/ui-dist/assets/forth-Ffai-XNe.js +1 -0
  1570. package/dist/runtime/server/ui-dist/assets/fortran-DYz_wnZ1.js +1 -0
  1571. package/dist/runtime/server/ui-dist/assets/ganttDiagram-JELNMOA3-CpTGtCqK.js +267 -0
  1572. package/dist/runtime/server/ui-dist/assets/gas-Bneqetm1.js +1 -0
  1573. package/dist/runtime/server/ui-dist/assets/gherkin-heZmZLOM.js +1 -0
  1574. package/dist/runtime/server/ui-dist/assets/gitGraphDiagram-V2S2FVAM-BQaWuAZj.js +65 -0
  1575. package/dist/runtime/server/ui-dist/assets/graph-DXdHsjCL.js +1 -0
  1576. package/dist/runtime/server/ui-dist/assets/groovy-D9Dt4D0W.js +1 -0
  1577. package/dist/runtime/server/ui-dist/assets/gtm-root-Bz1qVp9E.js +11 -0
  1578. package/dist/runtime/server/ui-dist/assets/haskell-Cw1EW3IL.js +1 -0
  1579. package/dist/runtime/server/ui-dist/assets/haxe-H-WmDvRZ.js +1 -0
  1580. package/dist/runtime/server/ui-dist/assets/http-DBlCnlav.js +1 -0
  1581. package/dist/runtime/server/ui-dist/assets/idl-BEugSyMb.js +1 -0
  1582. package/dist/runtime/server/ui-dist/assets/index-B8I0xKWu.js +1 -0
  1583. package/dist/runtime/server/ui-dist/assets/index-B8TKmcyb.js +6 -0
  1584. package/dist/runtime/server/ui-dist/assets/index-BMSNv6QN.js +13 -0
  1585. package/dist/runtime/server/ui-dist/assets/index-BYHJbnHR.js +1 -0
  1586. package/dist/runtime/server/ui-dist/assets/index-BgVlUrJs.js +2 -0
  1587. package/dist/runtime/server/ui-dist/assets/index-Bq-1_kyP.js +1 -0
  1588. package/dist/runtime/server/ui-dist/assets/index-BqPQYsKl.js +50 -0
  1589. package/dist/runtime/server/ui-dist/assets/index-BzMyBmxt.js +7 -0
  1590. package/dist/runtime/server/ui-dist/assets/index-CFpWwIka.js +1 -0
  1591. package/dist/runtime/server/ui-dist/assets/index-CKSID6Zp.js +1 -0
  1592. package/dist/runtime/server/ui-dist/assets/index-CQebjpNv.js +1 -0
  1593. package/dist/runtime/server/ui-dist/assets/index-CmOpk52T.css +1 -0
  1594. package/dist/runtime/server/ui-dist/assets/index-CmWaG74-.js +1 -0
  1595. package/dist/runtime/server/ui-dist/assets/index-CpAx3Tjk.js +3 -0
  1596. package/dist/runtime/server/ui-dist/assets/index-Crtq9e3P.js +1 -0
  1597. package/dist/runtime/server/ui-dist/assets/index-D5QPPm5h.js +1 -0
  1598. package/dist/runtime/server/ui-dist/assets/index-D8pJptAs.js +1 -0
  1599. package/dist/runtime/server/ui-dist/assets/index-DKPn8Zd0.js +1 -0
  1600. package/dist/runtime/server/ui-dist/assets/index-DRwidkWV.js +1 -0
  1601. package/dist/runtime/server/ui-dist/assets/index-DwTdFnM5.js +1 -0
  1602. package/dist/runtime/server/ui-dist/assets/index-KhE_p8qv.js +1 -0
  1603. package/dist/runtime/server/ui-dist/assets/index-LPZbBYTO.js +1 -0
  1604. package/dist/runtime/server/ui-dist/assets/index-mMQEcPHs.js +1 -0
  1605. package/dist/runtime/server/ui-dist/assets/index-nPSc8Rbx.js +1 -0
  1606. package/dist/runtime/server/ui-dist/assets/infoDiagram-HS3SLOUP-Du9idGhC.js +2 -0
  1607. package/dist/runtime/server/ui-dist/assets/init-Gi6I4Gst.js +1 -0
  1608. package/dist/runtime/server/ui-dist/assets/javascript-iXu5QeM3.js +1 -0
  1609. package/dist/runtime/server/ui-dist/assets/journeyDiagram-XKPGCS4Q-DQHmnv0N.js +139 -0
  1610. package/dist/runtime/server/ui-dist/assets/julia-DuME0IfC.js +1 -0
  1611. package/dist/runtime/server/ui-dist/assets/kanban-definition-3W4ZIXB7-D1us-ZVV.js +89 -0
  1612. package/dist/runtime/server/ui-dist/assets/katex-O9d3_IXG.js +261 -0
  1613. package/dist/runtime/server/ui-dist/assets/layout-CLyzF__I.js +1 -0
  1614. package/dist/runtime/server/ui-dist/assets/linear-DCEHrHNY.js +1 -0
  1615. package/dist/runtime/server/ui-dist/assets/livescript-BwQOo05w.js +1 -0
  1616. package/dist/runtime/server/ui-dist/assets/lua-BgMRiT3U.js +1 -0
  1617. package/dist/runtime/server/ui-dist/assets/mathematica-DTrFuWx2.js +1 -0
  1618. package/dist/runtime/server/ui-dist/assets/mbox-CNhZ1qSd.js +1 -0
  1619. package/dist/runtime/server/ui-dist/assets/mermaid.core-DPCeJESB.js +256 -0
  1620. package/dist/runtime/server/ui-dist/assets/mindmap-definition-VGOIOE7T-BmEem54z.js +68 -0
  1621. package/dist/runtime/server/ui-dist/assets/mirc-CjQqDB4T.js +1 -0
  1622. package/dist/runtime/server/ui-dist/assets/mllike-CXdrOF99.js +1 -0
  1623. package/dist/runtime/server/ui-dist/assets/modelica-Dc1JOy9r.js +1 -0
  1624. package/dist/runtime/server/ui-dist/assets/mscgen-BA5vi2Kp.js +1 -0
  1625. package/dist/runtime/server/ui-dist/assets/mumps-BT43cFF4.js +1 -0
  1626. package/dist/runtime/server/ui-dist/assets/nginx-DdIZxoE0.js +1 -0
  1627. package/dist/runtime/server/ui-dist/assets/nsis-LdVXkNf5.js +1 -0
  1628. package/dist/runtime/server/ui-dist/assets/ntriples-BfvgReVJ.js +1 -0
  1629. package/dist/runtime/server/ui-dist/assets/octave-Ck1zUtKM.js +1 -0
  1630. package/dist/runtime/server/ui-dist/assets/ordinal-Cboi1Yqb.js +1 -0
  1631. package/dist/runtime/server/ui-dist/assets/oz-BzwKVEFT.js +1 -0
  1632. package/dist/runtime/server/ui-dist/assets/pascal--L3eBynH.js +1 -0
  1633. package/dist/runtime/server/ui-dist/assets/perl-CdXCOZ3F.js +1 -0
  1634. package/dist/runtime/server/ui-dist/assets/pieDiagram-ADFJNKIX-DjIZtNwx.js +30 -0
  1635. package/dist/runtime/server/ui-dist/assets/pig-CevX1Tat.js +1 -0
  1636. package/dist/runtime/server/ui-dist/assets/powershell-CFHJl5sT.js +1 -0
  1637. package/dist/runtime/server/ui-dist/assets/properties-C78fOPTZ.js +1 -0
  1638. package/dist/runtime/server/ui-dist/assets/protobuf-ChK-085T.js +1 -0
  1639. package/dist/runtime/server/ui-dist/assets/pug-DeIclll2.js +1 -0
  1640. package/dist/runtime/server/ui-dist/assets/puppet-DMA9R1ak.js +1 -0
  1641. package/dist/runtime/server/ui-dist/assets/python-BuPzkPfP.js +1 -0
  1642. package/dist/runtime/server/ui-dist/assets/q-pXgVlZs6.js +1 -0
  1643. package/dist/runtime/server/ui-dist/assets/quadrantDiagram-AYHSOK5B-ba-xD4cb.js +7 -0
  1644. package/dist/runtime/server/ui-dist/assets/r-B6wPVr8A.js +1 -0
  1645. package/dist/runtime/server/ui-dist/assets/requirementDiagram-UZGBJVZJ-CB358t-a.js +64 -0
  1646. package/dist/runtime/server/ui-dist/assets/rpm-CTu-6PCP.js +1 -0
  1647. package/dist/runtime/server/ui-dist/assets/ruby-B2Rjki9n.js +1 -0
  1648. package/dist/runtime/server/ui-dist/assets/sankeyDiagram-TZEHDZUN-B0oPaNiW.js +10 -0
  1649. package/dist/runtime/server/ui-dist/assets/sas-B4kiWyti.js +1 -0
  1650. package/dist/runtime/server/ui-dist/assets/scheme-C41bIUwD.js +1 -0
  1651. package/dist/runtime/server/ui-dist/assets/sequenceDiagram-WL72ISMW-D7n_ZO5c.js +145 -0
  1652. package/dist/runtime/server/ui-dist/assets/shell-CjFT_Tl9.js +1 -0
  1653. package/dist/runtime/server/ui-dist/assets/sieve-C3Gn_uJK.js +1 -0
  1654. package/dist/runtime/server/ui-dist/assets/simple-mode-GW_nhZxv.js +1 -0
  1655. package/dist/runtime/server/ui-dist/assets/smalltalk-CnHTOXQT.js +1 -0
  1656. package/dist/runtime/server/ui-dist/assets/solr-DehyRSwq.js +1 -0
  1657. package/dist/runtime/server/ui-dist/assets/sparql-DkYu6x3z.js +1 -0
  1658. package/dist/runtime/server/ui-dist/assets/spreadsheet-BCZA_wO0.js +1 -0
  1659. package/dist/runtime/server/ui-dist/assets/sql-D0XecflT.js +1 -0
  1660. package/dist/runtime/server/ui-dist/assets/stateDiagram-FKZM4ZOC-MkMtXK-v.js +1 -0
  1661. package/dist/runtime/server/ui-dist/assets/stateDiagram-v2-4FDKWEC3-Cah7upY-.js +1 -0
  1662. package/dist/runtime/server/ui-dist/assets/stex-C3f8Ysf7.js +1 -0
  1663. package/dist/runtime/server/ui-dist/assets/stylus-B533Al4x.js +1 -0
  1664. package/dist/runtime/server/ui-dist/assets/swift-BzpIVaGY.js +1 -0
  1665. package/dist/runtime/server/ui-dist/assets/tcl-DVfN8rqt.js +1 -0
  1666. package/dist/runtime/server/ui-dist/assets/textile-CnDTJFAw.js +1 -0
  1667. package/dist/runtime/server/ui-dist/assets/tiddlywiki-DO-Gjzrf.js +1 -0
  1668. package/dist/runtime/server/ui-dist/assets/tiki-DGYXhP31.js +1 -0
  1669. package/dist/runtime/server/ui-dist/assets/timeline-definition-IT6M3QCI-CjBjKaYS.js +61 -0
  1670. package/dist/runtime/server/ui-dist/assets/toml-Bm5Em-hy.js +1 -0
  1671. package/dist/runtime/server/ui-dist/assets/treemap-GDKQZRPO-JNjc1ydw.js +162 -0
  1672. package/dist/runtime/server/ui-dist/assets/troff-wAsdV37c.js +1 -0
  1673. package/dist/runtime/server/ui-dist/assets/ttcn-CfJYG6tj.js +1 -0
  1674. package/dist/runtime/server/ui-dist/assets/ttcn-cfg-B9xdYoR4.js +1 -0
  1675. package/dist/runtime/server/ui-dist/assets/turtle-B1tBg_DP.js +1 -0
  1676. package/dist/runtime/server/ui-dist/assets/vb-CmGdzxic.js +1 -0
  1677. package/dist/runtime/server/ui-dist/assets/vbscript-BuJXcnF6.js +1 -0
  1678. package/dist/runtime/server/ui-dist/assets/velocity-D8B20fx6.js +1 -0
  1679. package/dist/runtime/server/ui-dist/assets/verilog-C6RDOZhf.js +1 -0
  1680. package/dist/runtime/server/ui-dist/assets/vhdl-lSbBsy5d.js +1 -0
  1681. package/dist/runtime/server/ui-dist/assets/webidl-ZXfAyPTL.js +1 -0
  1682. package/dist/runtime/server/ui-dist/assets/xquery-DzFWVndE.js +1 -0
  1683. package/dist/runtime/server/ui-dist/assets/xychartDiagram-PRI3JC2R-DU-mF_06.js +7 -0
  1684. package/dist/runtime/server/ui-dist/assets/yacas-BJ4BC0dw.js +1 -0
  1685. package/dist/runtime/server/ui-dist/assets/z80-Hz9HOZM7.js +1 -0
  1686. package/dist/runtime/server/ui-dist/brands/opencode-logo-dark-square.svg +18 -0
  1687. package/dist/runtime/server/ui-dist/brands/opencode-logo-light-square.svg +18 -0
  1688. package/dist/runtime/server/ui-dist/favicon-16x16.png +0 -0
  1689. package/dist/runtime/server/ui-dist/favicon-32x32.png +0 -0
  1690. package/dist/runtime/server/ui-dist/favicon.ico +0 -0
  1691. package/dist/runtime/server/ui-dist/favicon.svg +9 -0
  1692. package/dist/runtime/server/ui-dist/index.html +48 -0
  1693. package/dist/runtime/server/ui-dist/site.webmanifest +30 -0
  1694. package/dist/runtime/server/ui-dist/sw.js +42 -0
  1695. package/dist/runtime/server/ui-dist/worktree-favicon-16x16.png +0 -0
  1696. package/dist/runtime/server/ui-dist/worktree-favicon-32x32.png +0 -0
  1697. package/dist/runtime/server/ui-dist/worktree-favicon.ico +0 -0
  1698. package/dist/runtime/server/ui-dist/worktree-favicon.svg +9 -0
  1699. package/package.json +7 -4
@@ -0,0 +1,3046 @@
1
+ import fs from "node:fs/promises";
2
+ import path from "node:path";
3
+ import { execFile as execFileCallback } from "node:child_process";
4
+ import { promisify } from "node:util";
5
+ import { and, asc, desc, eq, gt, inArray, sql } from "drizzle-orm";
6
+ import { agents, agentRuntimeState, agentTaskSessions, agentWakeupRequests, heartbeatRunEvents, heartbeatRuns, issues, projects, projectWorkspaces, } from "@paperclipai/db";
7
+ import { conflict, notFound } from "../errors.js";
8
+ import { logger } from "../middleware/logger.js";
9
+ import { publishLiveEvent } from "./live-events.js";
10
+ import { getRunLogStore } from "./run-log-store.js";
11
+ import { getServerAdapter, runningProcesses } from "../adapters/index.js";
12
+ import { createLocalAgentJwt } from "../agent-auth-jwt.js";
13
+ import { parseObject, asBoolean, asNumber, appendWithCap, MAX_EXCERPT_BYTES } from "../adapters/utils.js";
14
+ import { costService } from "./costs.js";
15
+ import { budgetService } from "./budgets.js";
16
+ import { secretService } from "./secrets.js";
17
+ import { resolveDefaultAgentWorkspaceDir, resolveManagedProjectWorkspaceDir } from "../home-paths.js";
18
+ import { summarizeHeartbeatRunResultJson } from "./heartbeat-run-summary.js";
19
+ import { buildWorkspaceReadyComment, cleanupExecutionWorkspaceArtifacts, ensureRuntimeServicesForRun, persistAdapterManagedRuntimeServices, realizeExecutionWorkspace, releaseRuntimeServicesForRun, sanitizeRuntimeServiceBaseEnv, } from "./workspace-runtime.js";
20
+ import { issueService } from "./issues.js";
21
+ import { executionWorkspaceService } from "./execution-workspaces.js";
22
+ import { workspaceOperationService } from "./workspace-operations.js";
23
+ import { buildExecutionWorkspaceAdapterConfig, gateProjectExecutionWorkspacePolicy, parseIssueExecutionWorkspaceSettings, parseProjectExecutionWorkspacePolicy, resolveExecutionWorkspaceMode, } from "./execution-workspace-policy.js";
24
+ import { instanceSettingsService } from "./instance-settings.js";
25
+ import { redactCurrentUserText, redactCurrentUserValue } from "../log-redaction.js";
26
+ import { hasSessionCompactionThresholds, resolveSessionCompactionPolicy, } from "@paperclipai/adapter-utils";
27
+ const MAX_LIVE_LOG_CHUNK_BYTES = 8 * 1024;
28
+ const HEARTBEAT_MAX_CONCURRENT_RUNS_DEFAULT = 1;
29
+ const HEARTBEAT_MAX_CONCURRENT_RUNS_MAX = 10;
30
+ const DEFERRED_WAKE_CONTEXT_KEY = "_paperclipWakeContext";
31
+ const DETACHED_PROCESS_ERROR_CODE = "process_detached";
32
+ const startLocksByAgent = new Map();
33
+ const REPO_ONLY_CWD_SENTINEL = "/__paperclip_repo_only__";
34
+ const MANAGED_WORKSPACE_GIT_CLONE_TIMEOUT_MS = 10 * 60 * 1000;
35
+ const execFile = promisify(execFileCallback);
36
+ const SESSIONED_LOCAL_ADAPTERS = new Set([
37
+ "claude_local",
38
+ "codex_local",
39
+ "cursor",
40
+ "gemini_local",
41
+ "opencode_local",
42
+ "pi_local",
43
+ ]);
44
+ function deriveRepoNameFromRepoUrl(repoUrl) {
45
+ const trimmed = repoUrl?.trim() ?? "";
46
+ if (!trimmed)
47
+ return null;
48
+ try {
49
+ const parsed = new URL(trimmed);
50
+ const cleanedPath = parsed.pathname.replace(/\/+$/, "");
51
+ const repoName = cleanedPath.split("/").filter(Boolean).pop()?.replace(/\.git$/i, "") ?? "";
52
+ return repoName || null;
53
+ }
54
+ catch {
55
+ return null;
56
+ }
57
+ }
58
+ async function ensureManagedProjectWorkspace(input) {
59
+ const cwd = resolveManagedProjectWorkspaceDir({
60
+ companyId: input.companyId,
61
+ projectId: input.projectId,
62
+ repoName: deriveRepoNameFromRepoUrl(input.repoUrl),
63
+ });
64
+ await fs.mkdir(path.dirname(cwd), { recursive: true });
65
+ const stats = await fs.stat(cwd).catch(() => null);
66
+ if (!input.repoUrl) {
67
+ if (!stats) {
68
+ await fs.mkdir(cwd, { recursive: true });
69
+ }
70
+ return { cwd, warning: null };
71
+ }
72
+ const gitDirExists = await fs
73
+ .stat(path.resolve(cwd, ".git"))
74
+ .then((entry) => entry.isDirectory())
75
+ .catch(() => false);
76
+ if (gitDirExists) {
77
+ return { cwd, warning: null };
78
+ }
79
+ if (stats) {
80
+ const entries = await fs.readdir(cwd).catch(() => []);
81
+ if (entries.length > 0) {
82
+ return {
83
+ cwd,
84
+ warning: `Managed workspace path "${cwd}" already exists but is not a git checkout. Using it as-is.`,
85
+ };
86
+ }
87
+ await fs.rm(cwd, { recursive: true, force: true });
88
+ }
89
+ try {
90
+ await execFile("git", ["clone", input.repoUrl, cwd], {
91
+ env: sanitizeRuntimeServiceBaseEnv(process.env),
92
+ timeout: MANAGED_WORKSPACE_GIT_CLONE_TIMEOUT_MS,
93
+ });
94
+ return { cwd, warning: null };
95
+ }
96
+ catch (error) {
97
+ const reason = error instanceof Error ? error.message : String(error);
98
+ throw new Error(`Failed to prepare managed checkout for "${input.repoUrl}" at "${cwd}": ${reason}`);
99
+ }
100
+ }
101
+ const heartbeatRunListColumns = {
102
+ id: heartbeatRuns.id,
103
+ companyId: heartbeatRuns.companyId,
104
+ agentId: heartbeatRuns.agentId,
105
+ invocationSource: heartbeatRuns.invocationSource,
106
+ triggerDetail: heartbeatRuns.triggerDetail,
107
+ status: heartbeatRuns.status,
108
+ startedAt: heartbeatRuns.startedAt,
109
+ finishedAt: heartbeatRuns.finishedAt,
110
+ error: heartbeatRuns.error,
111
+ wakeupRequestId: heartbeatRuns.wakeupRequestId,
112
+ exitCode: heartbeatRuns.exitCode,
113
+ signal: heartbeatRuns.signal,
114
+ usageJson: heartbeatRuns.usageJson,
115
+ resultJson: heartbeatRuns.resultJson,
116
+ sessionIdBefore: heartbeatRuns.sessionIdBefore,
117
+ sessionIdAfter: heartbeatRuns.sessionIdAfter,
118
+ logStore: heartbeatRuns.logStore,
119
+ logRef: heartbeatRuns.logRef,
120
+ logBytes: heartbeatRuns.logBytes,
121
+ logSha256: heartbeatRuns.logSha256,
122
+ logCompressed: heartbeatRuns.logCompressed,
123
+ stdoutExcerpt: sql `NULL`.as("stdoutExcerpt"),
124
+ stderrExcerpt: sql `NULL`.as("stderrExcerpt"),
125
+ errorCode: heartbeatRuns.errorCode,
126
+ externalRunId: heartbeatRuns.externalRunId,
127
+ processPid: heartbeatRuns.processPid,
128
+ processStartedAt: heartbeatRuns.processStartedAt,
129
+ retryOfRunId: heartbeatRuns.retryOfRunId,
130
+ processLossRetryCount: heartbeatRuns.processLossRetryCount,
131
+ contextSnapshot: heartbeatRuns.contextSnapshot,
132
+ createdAt: heartbeatRuns.createdAt,
133
+ updatedAt: heartbeatRuns.updatedAt,
134
+ };
135
+ function appendExcerpt(prev, chunk) {
136
+ return appendWithCap(prev, chunk, MAX_EXCERPT_BYTES);
137
+ }
138
+ function normalizeMaxConcurrentRuns(value) {
139
+ const parsed = Math.floor(asNumber(value, HEARTBEAT_MAX_CONCURRENT_RUNS_DEFAULT));
140
+ if (!Number.isFinite(parsed))
141
+ return HEARTBEAT_MAX_CONCURRENT_RUNS_DEFAULT;
142
+ return Math.max(HEARTBEAT_MAX_CONCURRENT_RUNS_DEFAULT, Math.min(HEARTBEAT_MAX_CONCURRENT_RUNS_MAX, parsed));
143
+ }
144
+ async function withAgentStartLock(agentId, fn) {
145
+ const previous = startLocksByAgent.get(agentId) ?? Promise.resolve();
146
+ const run = previous.then(fn);
147
+ const marker = run.then(() => undefined, () => undefined);
148
+ startLocksByAgent.set(agentId, marker);
149
+ try {
150
+ return await run;
151
+ }
152
+ finally {
153
+ if (startLocksByAgent.get(agentId) === marker) {
154
+ startLocksByAgent.delete(agentId);
155
+ }
156
+ }
157
+ }
158
+ export function prioritizeProjectWorkspaceCandidatesForRun(rows, preferredWorkspaceId) {
159
+ if (!preferredWorkspaceId)
160
+ return rows;
161
+ const preferredIndex = rows.findIndex((row) => row.id === preferredWorkspaceId);
162
+ if (preferredIndex <= 0)
163
+ return rows;
164
+ return [rows[preferredIndex], ...rows.slice(0, preferredIndex), ...rows.slice(preferredIndex + 1)];
165
+ }
166
+ function readNonEmptyString(value) {
167
+ return typeof value === "string" && value.trim().length > 0 ? value : null;
168
+ }
169
+ function normalizeLedgerBillingType(value) {
170
+ const raw = readNonEmptyString(value);
171
+ switch (raw) {
172
+ case "api":
173
+ case "metered_api":
174
+ return "metered_api";
175
+ case "subscription":
176
+ case "subscription_included":
177
+ return "subscription_included";
178
+ case "subscription_overage":
179
+ return "subscription_overage";
180
+ case "credits":
181
+ return "credits";
182
+ case "fixed":
183
+ return "fixed";
184
+ default:
185
+ return "unknown";
186
+ }
187
+ }
188
+ function resolveLedgerBiller(result) {
189
+ return readNonEmptyString(result.biller) ?? readNonEmptyString(result.provider) ?? "unknown";
190
+ }
191
+ function normalizeBilledCostCents(costUsd, billingType) {
192
+ if (billingType === "subscription_included")
193
+ return 0;
194
+ if (typeof costUsd !== "number" || !Number.isFinite(costUsd))
195
+ return 0;
196
+ return Math.max(0, Math.round(costUsd * 100));
197
+ }
198
+ async function resolveLedgerScopeForRun(db, companyId, run) {
199
+ const context = parseObject(run.contextSnapshot);
200
+ const contextIssueId = readNonEmptyString(context.issueId);
201
+ const contextProjectId = readNonEmptyString(context.projectId);
202
+ if (!contextIssueId) {
203
+ return {
204
+ issueId: null,
205
+ projectId: contextProjectId,
206
+ };
207
+ }
208
+ const issue = await db
209
+ .select({
210
+ id: issues.id,
211
+ projectId: issues.projectId,
212
+ })
213
+ .from(issues)
214
+ .where(and(eq(issues.id, contextIssueId), eq(issues.companyId, companyId)))
215
+ .then((rows) => rows[0] ?? null);
216
+ return {
217
+ issueId: issue?.id ?? null,
218
+ projectId: issue?.projectId ?? contextProjectId,
219
+ };
220
+ }
221
+ function normalizeUsageTotals(usage) {
222
+ if (!usage)
223
+ return null;
224
+ return {
225
+ inputTokens: Math.max(0, Math.floor(asNumber(usage.inputTokens, 0))),
226
+ cachedInputTokens: Math.max(0, Math.floor(asNumber(usage.cachedInputTokens, 0))),
227
+ outputTokens: Math.max(0, Math.floor(asNumber(usage.outputTokens, 0))),
228
+ };
229
+ }
230
+ function readRawUsageTotals(usageJson) {
231
+ const parsed = parseObject(usageJson);
232
+ if (Object.keys(parsed).length === 0)
233
+ return null;
234
+ const inputTokens = Math.max(0, Math.floor(asNumber(parsed.rawInputTokens, asNumber(parsed.inputTokens, 0))));
235
+ const cachedInputTokens = Math.max(0, Math.floor(asNumber(parsed.rawCachedInputTokens, asNumber(parsed.cachedInputTokens, 0))));
236
+ const outputTokens = Math.max(0, Math.floor(asNumber(parsed.rawOutputTokens, asNumber(parsed.outputTokens, 0))));
237
+ if (inputTokens <= 0 && cachedInputTokens <= 0 && outputTokens <= 0) {
238
+ return null;
239
+ }
240
+ return {
241
+ inputTokens,
242
+ cachedInputTokens,
243
+ outputTokens,
244
+ };
245
+ }
246
+ function deriveNormalizedUsageDelta(current, previous) {
247
+ if (!current)
248
+ return null;
249
+ if (!previous)
250
+ return { ...current };
251
+ const inputTokens = current.inputTokens >= previous.inputTokens
252
+ ? current.inputTokens - previous.inputTokens
253
+ : current.inputTokens;
254
+ const cachedInputTokens = current.cachedInputTokens >= previous.cachedInputTokens
255
+ ? current.cachedInputTokens - previous.cachedInputTokens
256
+ : current.cachedInputTokens;
257
+ const outputTokens = current.outputTokens >= previous.outputTokens
258
+ ? current.outputTokens - previous.outputTokens
259
+ : current.outputTokens;
260
+ return {
261
+ inputTokens: Math.max(0, inputTokens),
262
+ cachedInputTokens: Math.max(0, cachedInputTokens),
263
+ outputTokens: Math.max(0, outputTokens),
264
+ };
265
+ }
266
+ function formatCount(value) {
267
+ if (typeof value !== "number" || !Number.isFinite(value))
268
+ return "0";
269
+ return value.toLocaleString("en-US");
270
+ }
271
+ export function parseSessionCompactionPolicy(agent) {
272
+ return resolveSessionCompactionPolicy(agent.adapterType, agent.runtimeConfig).policy;
273
+ }
274
+ export function resolveRuntimeSessionParamsForWorkspace(input) {
275
+ const { agentId, previousSessionParams, resolvedWorkspace } = input;
276
+ const previousSessionId = readNonEmptyString(previousSessionParams?.sessionId);
277
+ const previousCwd = readNonEmptyString(previousSessionParams?.cwd);
278
+ if (!previousSessionId || !previousCwd) {
279
+ return {
280
+ sessionParams: previousSessionParams,
281
+ warning: null,
282
+ };
283
+ }
284
+ if (resolvedWorkspace.source !== "project_primary") {
285
+ return {
286
+ sessionParams: previousSessionParams,
287
+ warning: null,
288
+ };
289
+ }
290
+ const projectCwd = readNonEmptyString(resolvedWorkspace.cwd);
291
+ if (!projectCwd) {
292
+ return {
293
+ sessionParams: previousSessionParams,
294
+ warning: null,
295
+ };
296
+ }
297
+ const fallbackAgentHomeCwd = resolveDefaultAgentWorkspaceDir(agentId);
298
+ if (path.resolve(previousCwd) !== path.resolve(fallbackAgentHomeCwd)) {
299
+ return {
300
+ sessionParams: previousSessionParams,
301
+ warning: null,
302
+ };
303
+ }
304
+ if (path.resolve(projectCwd) === path.resolve(previousCwd)) {
305
+ return {
306
+ sessionParams: previousSessionParams,
307
+ warning: null,
308
+ };
309
+ }
310
+ const previousWorkspaceId = readNonEmptyString(previousSessionParams?.workspaceId);
311
+ if (previousWorkspaceId &&
312
+ resolvedWorkspace.workspaceId &&
313
+ previousWorkspaceId !== resolvedWorkspace.workspaceId) {
314
+ return {
315
+ sessionParams: previousSessionParams,
316
+ warning: null,
317
+ };
318
+ }
319
+ const migratedSessionParams = {
320
+ ...(previousSessionParams ?? {}),
321
+ cwd: projectCwd,
322
+ };
323
+ if (resolvedWorkspace.workspaceId)
324
+ migratedSessionParams.workspaceId = resolvedWorkspace.workspaceId;
325
+ if (resolvedWorkspace.repoUrl)
326
+ migratedSessionParams.repoUrl = resolvedWorkspace.repoUrl;
327
+ if (resolvedWorkspace.repoRef)
328
+ migratedSessionParams.repoRef = resolvedWorkspace.repoRef;
329
+ return {
330
+ sessionParams: migratedSessionParams,
331
+ warning: `Project workspace "${projectCwd}" is now available. ` +
332
+ `Attempting to resume session "${previousSessionId}" that was previously saved in fallback workspace "${previousCwd}".`,
333
+ };
334
+ }
335
+ function parseIssueAssigneeAdapterOverrides(raw) {
336
+ const parsed = parseObject(raw);
337
+ const parsedAdapterConfig = parseObject(parsed.adapterConfig);
338
+ const adapterConfig = Object.keys(parsedAdapterConfig).length > 0 ? parsedAdapterConfig : null;
339
+ const useProjectWorkspace = typeof parsed.useProjectWorkspace === "boolean"
340
+ ? parsed.useProjectWorkspace
341
+ : null;
342
+ if (!adapterConfig && useProjectWorkspace === null)
343
+ return null;
344
+ return {
345
+ adapterConfig,
346
+ useProjectWorkspace,
347
+ };
348
+ }
349
+ function deriveTaskKey(contextSnapshot, payload) {
350
+ return (readNonEmptyString(contextSnapshot?.taskKey) ??
351
+ readNonEmptyString(contextSnapshot?.taskId) ??
352
+ readNonEmptyString(contextSnapshot?.issueId) ??
353
+ readNonEmptyString(payload?.taskKey) ??
354
+ readNonEmptyString(payload?.taskId) ??
355
+ readNonEmptyString(payload?.issueId) ??
356
+ null);
357
+ }
358
+ export function shouldResetTaskSessionForWake(contextSnapshot) {
359
+ if (contextSnapshot?.forceFreshSession === true)
360
+ return true;
361
+ const wakeReason = readNonEmptyString(contextSnapshot?.wakeReason);
362
+ if (wakeReason === "issue_assigned")
363
+ return true;
364
+ return false;
365
+ }
366
+ export function formatRuntimeWorkspaceWarningLog(warning) {
367
+ return {
368
+ stream: "stdout",
369
+ chunk: `[paperclip] ${warning}\n`,
370
+ };
371
+ }
372
+ function describeSessionResetReason(contextSnapshot) {
373
+ if (contextSnapshot?.forceFreshSession === true)
374
+ return "forceFreshSession was requested";
375
+ const wakeReason = readNonEmptyString(contextSnapshot?.wakeReason);
376
+ if (wakeReason === "issue_assigned")
377
+ return "wake reason is issue_assigned";
378
+ return null;
379
+ }
380
+ function deriveCommentId(contextSnapshot, payload) {
381
+ return (readNonEmptyString(contextSnapshot?.wakeCommentId) ??
382
+ readNonEmptyString(contextSnapshot?.commentId) ??
383
+ readNonEmptyString(payload?.commentId) ??
384
+ null);
385
+ }
386
+ function enrichWakeContextSnapshot(input) {
387
+ const { contextSnapshot, reason, source, triggerDetail, payload } = input;
388
+ const issueIdFromPayload = readNonEmptyString(payload?.["issueId"]);
389
+ const commentIdFromPayload = readNonEmptyString(payload?.["commentId"]);
390
+ const taskKey = deriveTaskKey(contextSnapshot, payload);
391
+ const wakeCommentId = deriveCommentId(contextSnapshot, payload);
392
+ if (!readNonEmptyString(contextSnapshot["wakeReason"]) && reason) {
393
+ contextSnapshot.wakeReason = reason;
394
+ }
395
+ if (!readNonEmptyString(contextSnapshot["issueId"]) && issueIdFromPayload) {
396
+ contextSnapshot.issueId = issueIdFromPayload;
397
+ }
398
+ if (!readNonEmptyString(contextSnapshot["taskId"]) && issueIdFromPayload) {
399
+ contextSnapshot.taskId = issueIdFromPayload;
400
+ }
401
+ if (!readNonEmptyString(contextSnapshot["taskKey"]) && taskKey) {
402
+ contextSnapshot.taskKey = taskKey;
403
+ }
404
+ if (!readNonEmptyString(contextSnapshot["commentId"]) && commentIdFromPayload) {
405
+ contextSnapshot.commentId = commentIdFromPayload;
406
+ }
407
+ if (!readNonEmptyString(contextSnapshot["wakeCommentId"]) && wakeCommentId) {
408
+ contextSnapshot.wakeCommentId = wakeCommentId;
409
+ }
410
+ if (!readNonEmptyString(contextSnapshot["wakeSource"]) && source) {
411
+ contextSnapshot.wakeSource = source;
412
+ }
413
+ if (!readNonEmptyString(contextSnapshot["wakeTriggerDetail"]) && triggerDetail) {
414
+ contextSnapshot.wakeTriggerDetail = triggerDetail;
415
+ }
416
+ return {
417
+ contextSnapshot,
418
+ issueIdFromPayload,
419
+ commentIdFromPayload,
420
+ taskKey,
421
+ wakeCommentId,
422
+ };
423
+ }
424
+ function mergeCoalescedContextSnapshot(existingRaw, incoming) {
425
+ const existing = parseObject(existingRaw);
426
+ const merged = {
427
+ ...existing,
428
+ ...incoming,
429
+ };
430
+ const commentId = deriveCommentId(incoming, null);
431
+ if (commentId) {
432
+ merged.commentId = commentId;
433
+ merged.wakeCommentId = commentId;
434
+ }
435
+ return merged;
436
+ }
437
+ function runTaskKey(run) {
438
+ return deriveTaskKey(run.contextSnapshot, null);
439
+ }
440
+ function isSameTaskScope(left, right) {
441
+ return (left ?? null) === (right ?? null);
442
+ }
443
+ function isTrackedLocalChildProcessAdapter(adapterType) {
444
+ return SESSIONED_LOCAL_ADAPTERS.has(adapterType);
445
+ }
446
+ // A positive liveness check means some process currently owns the PID.
447
+ // On Linux, PIDs can be recycled, so this is a best-effort signal rather
448
+ // than proof that the original child is still alive.
449
+ function isProcessAlive(pid) {
450
+ if (typeof pid !== "number" || !Number.isInteger(pid) || pid <= 0)
451
+ return false;
452
+ try {
453
+ process.kill(pid, 0);
454
+ return true;
455
+ }
456
+ catch (error) {
457
+ const code = error?.code;
458
+ if (code === "EPERM")
459
+ return true;
460
+ if (code === "ESRCH")
461
+ return false;
462
+ return false;
463
+ }
464
+ }
465
+ function truncateDisplayId(value, max = 128) {
466
+ if (!value)
467
+ return null;
468
+ return value.length > max ? value.slice(0, max) : value;
469
+ }
470
+ function normalizeAgentNameKey(value) {
471
+ if (typeof value !== "string")
472
+ return null;
473
+ const normalized = value.trim().toLowerCase();
474
+ return normalized.length > 0 ? normalized : null;
475
+ }
476
+ const defaultSessionCodec = {
477
+ deserialize(raw) {
478
+ const asObj = parseObject(raw);
479
+ if (Object.keys(asObj).length > 0)
480
+ return asObj;
481
+ const sessionId = readNonEmptyString(raw?.sessionId);
482
+ if (sessionId)
483
+ return { sessionId };
484
+ return null;
485
+ },
486
+ serialize(params) {
487
+ if (!params || Object.keys(params).length === 0)
488
+ return null;
489
+ return params;
490
+ },
491
+ getDisplayId(params) {
492
+ return readNonEmptyString(params?.sessionId);
493
+ },
494
+ };
495
+ function getAdapterSessionCodec(adapterType) {
496
+ const adapter = getServerAdapter(adapterType);
497
+ return adapter.sessionCodec ?? defaultSessionCodec;
498
+ }
499
+ function normalizeSessionParams(params) {
500
+ if (!params)
501
+ return null;
502
+ return Object.keys(params).length > 0 ? params : null;
503
+ }
504
+ function resolveNextSessionState(input) {
505
+ const { codec, adapterResult, previousParams, previousDisplayId, previousLegacySessionId } = input;
506
+ if (adapterResult.clearSession) {
507
+ return {
508
+ params: null,
509
+ displayId: null,
510
+ legacySessionId: null,
511
+ };
512
+ }
513
+ const explicitParams = adapterResult.sessionParams;
514
+ const hasExplicitParams = adapterResult.sessionParams !== undefined;
515
+ const hasExplicitSessionId = adapterResult.sessionId !== undefined;
516
+ const explicitSessionId = readNonEmptyString(adapterResult.sessionId);
517
+ const hasExplicitDisplay = adapterResult.sessionDisplayId !== undefined;
518
+ const explicitDisplayId = readNonEmptyString(adapterResult.sessionDisplayId);
519
+ const shouldUsePrevious = !hasExplicitParams && !hasExplicitSessionId && !hasExplicitDisplay;
520
+ const candidateParams = hasExplicitParams
521
+ ? explicitParams
522
+ : hasExplicitSessionId
523
+ ? (explicitSessionId ? { sessionId: explicitSessionId } : null)
524
+ : previousParams;
525
+ const serialized = normalizeSessionParams(codec.serialize(normalizeSessionParams(candidateParams) ?? null));
526
+ const deserialized = normalizeSessionParams(codec.deserialize(serialized));
527
+ const displayId = truncateDisplayId(explicitDisplayId ??
528
+ (codec.getDisplayId ? codec.getDisplayId(deserialized) : null) ??
529
+ readNonEmptyString(deserialized?.sessionId) ??
530
+ (shouldUsePrevious ? previousDisplayId : null) ??
531
+ explicitSessionId ??
532
+ (shouldUsePrevious ? previousLegacySessionId : null));
533
+ const legacySessionId = explicitSessionId ??
534
+ readNonEmptyString(deserialized?.sessionId) ??
535
+ displayId ??
536
+ (shouldUsePrevious ? previousLegacySessionId : null);
537
+ return {
538
+ params: serialized,
539
+ displayId,
540
+ legacySessionId,
541
+ };
542
+ }
543
+ export function heartbeatService(db) {
544
+ const instanceSettings = instanceSettingsService(db);
545
+ const runLogStore = getRunLogStore();
546
+ const secretsSvc = secretService(db);
547
+ const issuesSvc = issueService(db);
548
+ const executionWorkspacesSvc = executionWorkspaceService(db);
549
+ const workspaceOperationsSvc = workspaceOperationService(db);
550
+ const activeRunExecutions = new Set();
551
+ const budgetHooks = {
552
+ cancelWorkForScope: cancelBudgetScopeWork,
553
+ };
554
+ const budgets = budgetService(db, budgetHooks);
555
+ async function getAgent(agentId) {
556
+ return db
557
+ .select()
558
+ .from(agents)
559
+ .where(eq(agents.id, agentId))
560
+ .then((rows) => rows[0] ?? null);
561
+ }
562
+ async function getRun(runId) {
563
+ return db
564
+ .select()
565
+ .from(heartbeatRuns)
566
+ .where(eq(heartbeatRuns.id, runId))
567
+ .then((rows) => rows[0] ?? null);
568
+ }
569
+ async function getRuntimeState(agentId) {
570
+ return db
571
+ .select()
572
+ .from(agentRuntimeState)
573
+ .where(eq(agentRuntimeState.agentId, agentId))
574
+ .then((rows) => rows[0] ?? null);
575
+ }
576
+ async function getTaskSession(companyId, agentId, adapterType, taskKey) {
577
+ return db
578
+ .select()
579
+ .from(agentTaskSessions)
580
+ .where(and(eq(agentTaskSessions.companyId, companyId), eq(agentTaskSessions.agentId, agentId), eq(agentTaskSessions.adapterType, adapterType), eq(agentTaskSessions.taskKey, taskKey)))
581
+ .then((rows) => rows[0] ?? null);
582
+ }
583
+ async function getLatestRunForSession(agentId, sessionId, opts) {
584
+ const conditions = [
585
+ eq(heartbeatRuns.agentId, agentId),
586
+ eq(heartbeatRuns.sessionIdAfter, sessionId),
587
+ ];
588
+ if (opts?.excludeRunId) {
589
+ conditions.push(sql `${heartbeatRuns.id} <> ${opts.excludeRunId}`);
590
+ }
591
+ return db
592
+ .select()
593
+ .from(heartbeatRuns)
594
+ .where(and(...conditions))
595
+ .orderBy(desc(heartbeatRuns.createdAt))
596
+ .limit(1)
597
+ .then((rows) => rows[0] ?? null);
598
+ }
599
+ async function getOldestRunForSession(agentId, sessionId) {
600
+ return db
601
+ .select({
602
+ id: heartbeatRuns.id,
603
+ createdAt: heartbeatRuns.createdAt,
604
+ })
605
+ .from(heartbeatRuns)
606
+ .where(and(eq(heartbeatRuns.agentId, agentId), eq(heartbeatRuns.sessionIdAfter, sessionId)))
607
+ .orderBy(asc(heartbeatRuns.createdAt), asc(heartbeatRuns.id))
608
+ .limit(1)
609
+ .then((rows) => rows[0] ?? null);
610
+ }
611
+ async function resolveNormalizedUsageForSession(input) {
612
+ const { agentId, runId, sessionId, rawUsage } = input;
613
+ if (!sessionId || !rawUsage) {
614
+ return {
615
+ normalizedUsage: rawUsage,
616
+ previousRawUsage: null,
617
+ derivedFromSessionTotals: false,
618
+ };
619
+ }
620
+ const previousRun = await getLatestRunForSession(agentId, sessionId, { excludeRunId: runId });
621
+ const previousRawUsage = readRawUsageTotals(previousRun?.usageJson);
622
+ return {
623
+ normalizedUsage: deriveNormalizedUsageDelta(rawUsage, previousRawUsage),
624
+ previousRawUsage,
625
+ derivedFromSessionTotals: previousRawUsage !== null,
626
+ };
627
+ }
628
+ async function evaluateSessionCompaction(input) {
629
+ const { agent, sessionId, issueId } = input;
630
+ if (!sessionId) {
631
+ return {
632
+ rotate: false,
633
+ reason: null,
634
+ handoffMarkdown: null,
635
+ previousRunId: null,
636
+ };
637
+ }
638
+ const policy = parseSessionCompactionPolicy(agent);
639
+ if (!policy.enabled || !hasSessionCompactionThresholds(policy)) {
640
+ return {
641
+ rotate: false,
642
+ reason: null,
643
+ handoffMarkdown: null,
644
+ previousRunId: null,
645
+ };
646
+ }
647
+ const fetchLimit = Math.max(policy.maxSessionRuns > 0 ? policy.maxSessionRuns + 1 : 0, 4);
648
+ const runs = await db
649
+ .select({
650
+ id: heartbeatRuns.id,
651
+ createdAt: heartbeatRuns.createdAt,
652
+ usageJson: heartbeatRuns.usageJson,
653
+ resultJson: heartbeatRuns.resultJson,
654
+ error: heartbeatRuns.error,
655
+ })
656
+ .from(heartbeatRuns)
657
+ .where(and(eq(heartbeatRuns.agentId, agent.id), eq(heartbeatRuns.sessionIdAfter, sessionId)))
658
+ .orderBy(desc(heartbeatRuns.createdAt))
659
+ .limit(fetchLimit);
660
+ if (runs.length === 0) {
661
+ return {
662
+ rotate: false,
663
+ reason: null,
664
+ handoffMarkdown: null,
665
+ previousRunId: null,
666
+ };
667
+ }
668
+ const latestRun = runs[0] ?? null;
669
+ const oldestRun = policy.maxSessionAgeHours > 0
670
+ ? await getOldestRunForSession(agent.id, sessionId)
671
+ : runs[runs.length - 1] ?? latestRun;
672
+ const latestRawUsage = readRawUsageTotals(latestRun?.usageJson);
673
+ const sessionAgeHours = latestRun && oldestRun
674
+ ? Math.max(0, (new Date(latestRun.createdAt).getTime() - new Date(oldestRun.createdAt).getTime()) / (1000 * 60 * 60))
675
+ : 0;
676
+ let reason = null;
677
+ if (policy.maxSessionRuns > 0 && runs.length > policy.maxSessionRuns) {
678
+ reason = `session exceeded ${policy.maxSessionRuns} runs`;
679
+ }
680
+ else if (policy.maxRawInputTokens > 0 &&
681
+ latestRawUsage &&
682
+ latestRawUsage.inputTokens >= policy.maxRawInputTokens) {
683
+ reason =
684
+ `session raw input reached ${formatCount(latestRawUsage.inputTokens)} tokens ` +
685
+ `(threshold ${formatCount(policy.maxRawInputTokens)})`;
686
+ }
687
+ else if (policy.maxSessionAgeHours > 0 && sessionAgeHours >= policy.maxSessionAgeHours) {
688
+ reason = `session age reached ${Math.floor(sessionAgeHours)} hours`;
689
+ }
690
+ if (!reason || !latestRun) {
691
+ return {
692
+ rotate: false,
693
+ reason: null,
694
+ handoffMarkdown: null,
695
+ previousRunId: latestRun?.id ?? null,
696
+ };
697
+ }
698
+ const latestSummary = summarizeHeartbeatRunResultJson(latestRun.resultJson);
699
+ const latestTextSummary = readNonEmptyString(latestSummary?.summary) ??
700
+ readNonEmptyString(latestSummary?.result) ??
701
+ readNonEmptyString(latestSummary?.message) ??
702
+ readNonEmptyString(latestRun.error);
703
+ const handoffMarkdown = [
704
+ "Paperclip session handoff:",
705
+ `- Previous session: ${sessionId}`,
706
+ issueId ? `- Issue: ${issueId}` : "",
707
+ `- Rotation reason: ${reason}`,
708
+ latestTextSummary ? `- Last run summary: ${latestTextSummary}` : "",
709
+ "Continue from the current task state. Rebuild only the minimum context you need.",
710
+ ]
711
+ .filter(Boolean)
712
+ .join("\n");
713
+ return {
714
+ rotate: true,
715
+ reason,
716
+ handoffMarkdown,
717
+ previousRunId: latestRun.id,
718
+ };
719
+ }
720
+ async function resolveSessionBeforeForWakeup(agent, taskKey) {
721
+ if (taskKey) {
722
+ const codec = getAdapterSessionCodec(agent.adapterType);
723
+ const existingTaskSession = await getTaskSession(agent.companyId, agent.id, agent.adapterType, taskKey);
724
+ const parsedParams = normalizeSessionParams(codec.deserialize(existingTaskSession?.sessionParamsJson ?? null));
725
+ return truncateDisplayId(existingTaskSession?.sessionDisplayId ??
726
+ (codec.getDisplayId ? codec.getDisplayId(parsedParams) : null) ??
727
+ readNonEmptyString(parsedParams?.sessionId));
728
+ }
729
+ const runtimeForRun = await getRuntimeState(agent.id);
730
+ return runtimeForRun?.sessionId ?? null;
731
+ }
732
+ async function resolveWorkspaceForRun(agent, context, previousSessionParams, opts) {
733
+ const issueId = readNonEmptyString(context.issueId);
734
+ const contextProjectId = readNonEmptyString(context.projectId);
735
+ const contextProjectWorkspaceId = readNonEmptyString(context.projectWorkspaceId);
736
+ const issueProjectRef = issueId
737
+ ? await db
738
+ .select({
739
+ projectId: issues.projectId,
740
+ projectWorkspaceId: issues.projectWorkspaceId,
741
+ })
742
+ .from(issues)
743
+ .where(and(eq(issues.id, issueId), eq(issues.companyId, agent.companyId)))
744
+ .then((rows) => rows[0] ?? null)
745
+ : null;
746
+ const issueProjectId = issueProjectRef?.projectId ?? null;
747
+ const preferredProjectWorkspaceId = issueProjectRef?.projectWorkspaceId ?? contextProjectWorkspaceId ?? null;
748
+ const resolvedProjectId = issueProjectId ?? contextProjectId;
749
+ const useProjectWorkspace = opts?.useProjectWorkspace !== false;
750
+ const workspaceProjectId = useProjectWorkspace ? resolvedProjectId : null;
751
+ const unorderedProjectWorkspaceRows = workspaceProjectId
752
+ ? await db
753
+ .select()
754
+ .from(projectWorkspaces)
755
+ .where(and(eq(projectWorkspaces.companyId, agent.companyId), eq(projectWorkspaces.projectId, workspaceProjectId)))
756
+ .orderBy(asc(projectWorkspaces.createdAt), asc(projectWorkspaces.id))
757
+ : [];
758
+ const projectWorkspaceRows = prioritizeProjectWorkspaceCandidatesForRun(unorderedProjectWorkspaceRows, preferredProjectWorkspaceId);
759
+ const workspaceHints = projectWorkspaceRows.map((workspace) => ({
760
+ workspaceId: workspace.id,
761
+ cwd: readNonEmptyString(workspace.cwd),
762
+ repoUrl: readNonEmptyString(workspace.repoUrl),
763
+ repoRef: readNonEmptyString(workspace.repoRef),
764
+ }));
765
+ if (projectWorkspaceRows.length > 0) {
766
+ const preferredWorkspace = preferredProjectWorkspaceId
767
+ ? projectWorkspaceRows.find((workspace) => workspace.id === preferredProjectWorkspaceId) ?? null
768
+ : null;
769
+ const missingProjectCwds = [];
770
+ let hasConfiguredProjectCwd = false;
771
+ let preferredWorkspaceWarning = null;
772
+ if (preferredProjectWorkspaceId && !preferredWorkspace) {
773
+ preferredWorkspaceWarning =
774
+ `Selected project workspace "${preferredProjectWorkspaceId}" is not available on this project.`;
775
+ }
776
+ for (const workspace of projectWorkspaceRows) {
777
+ let projectCwd = readNonEmptyString(workspace.cwd);
778
+ let managedWorkspaceWarning = null;
779
+ if (!projectCwd || projectCwd === REPO_ONLY_CWD_SENTINEL) {
780
+ try {
781
+ const managedWorkspace = await ensureManagedProjectWorkspace({
782
+ companyId: agent.companyId,
783
+ projectId: workspaceProjectId ?? resolvedProjectId ?? workspace.projectId,
784
+ repoUrl: readNonEmptyString(workspace.repoUrl),
785
+ });
786
+ projectCwd = managedWorkspace.cwd;
787
+ managedWorkspaceWarning = managedWorkspace.warning;
788
+ }
789
+ catch (error) {
790
+ if (preferredWorkspace?.id === workspace.id) {
791
+ preferredWorkspaceWarning = error instanceof Error ? error.message : String(error);
792
+ }
793
+ continue;
794
+ }
795
+ }
796
+ hasConfiguredProjectCwd = true;
797
+ const projectCwdExists = await fs
798
+ .stat(projectCwd)
799
+ .then((stats) => stats.isDirectory())
800
+ .catch(() => false);
801
+ if (projectCwdExists) {
802
+ return {
803
+ cwd: projectCwd,
804
+ source: "project_primary",
805
+ projectId: resolvedProjectId,
806
+ workspaceId: workspace.id,
807
+ repoUrl: workspace.repoUrl,
808
+ repoRef: workspace.repoRef,
809
+ workspaceHints,
810
+ warnings: [preferredWorkspaceWarning, managedWorkspaceWarning].filter((value) => Boolean(value)),
811
+ };
812
+ }
813
+ if (preferredWorkspace?.id === workspace.id) {
814
+ preferredWorkspaceWarning =
815
+ `Selected project workspace path "${projectCwd}" is not available yet.`;
816
+ }
817
+ missingProjectCwds.push(projectCwd);
818
+ }
819
+ const fallbackCwd = resolveDefaultAgentWorkspaceDir(agent.id);
820
+ await fs.mkdir(fallbackCwd, { recursive: true });
821
+ const warnings = [];
822
+ if (preferredWorkspaceWarning) {
823
+ warnings.push(preferredWorkspaceWarning);
824
+ }
825
+ if (missingProjectCwds.length > 0) {
826
+ const firstMissing = missingProjectCwds[0];
827
+ const extraMissingCount = Math.max(0, missingProjectCwds.length - 1);
828
+ warnings.push(extraMissingCount > 0
829
+ ? `Project workspace path "${firstMissing}" and ${extraMissingCount} other configured path(s) are not available yet. Using fallback workspace "${fallbackCwd}" for this run.`
830
+ : `Project workspace path "${firstMissing}" is not available yet. Using fallback workspace "${fallbackCwd}" for this run.`);
831
+ }
832
+ else if (!hasConfiguredProjectCwd) {
833
+ warnings.push(`Project workspace has no local cwd configured. Using fallback workspace "${fallbackCwd}" for this run.`);
834
+ }
835
+ return {
836
+ cwd: fallbackCwd,
837
+ source: "project_primary",
838
+ projectId: resolvedProjectId,
839
+ workspaceId: projectWorkspaceRows[0]?.id ?? null,
840
+ repoUrl: projectWorkspaceRows[0]?.repoUrl ?? null,
841
+ repoRef: projectWorkspaceRows[0]?.repoRef ?? null,
842
+ workspaceHints,
843
+ warnings,
844
+ };
845
+ }
846
+ if (workspaceProjectId) {
847
+ const managedWorkspace = await ensureManagedProjectWorkspace({
848
+ companyId: agent.companyId,
849
+ projectId: workspaceProjectId,
850
+ repoUrl: null,
851
+ });
852
+ return {
853
+ cwd: managedWorkspace.cwd,
854
+ source: "project_primary",
855
+ projectId: resolvedProjectId,
856
+ workspaceId: null,
857
+ repoUrl: null,
858
+ repoRef: null,
859
+ workspaceHints,
860
+ warnings: managedWorkspace.warning ? [managedWorkspace.warning] : [],
861
+ };
862
+ }
863
+ const sessionCwd = readNonEmptyString(previousSessionParams?.cwd);
864
+ if (sessionCwd) {
865
+ const sessionCwdExists = await fs
866
+ .stat(sessionCwd)
867
+ .then((stats) => stats.isDirectory())
868
+ .catch(() => false);
869
+ if (sessionCwdExists) {
870
+ return {
871
+ cwd: sessionCwd,
872
+ source: "task_session",
873
+ projectId: resolvedProjectId,
874
+ workspaceId: readNonEmptyString(previousSessionParams?.workspaceId),
875
+ repoUrl: readNonEmptyString(previousSessionParams?.repoUrl),
876
+ repoRef: readNonEmptyString(previousSessionParams?.repoRef),
877
+ workspaceHints,
878
+ warnings: [],
879
+ };
880
+ }
881
+ }
882
+ const cwd = resolveDefaultAgentWorkspaceDir(agent.id);
883
+ await fs.mkdir(cwd, { recursive: true });
884
+ const warnings = [];
885
+ if (sessionCwd) {
886
+ warnings.push(`Saved session workspace "${sessionCwd}" is not available. Using fallback workspace "${cwd}" for this run.`);
887
+ }
888
+ else if (resolvedProjectId) {
889
+ warnings.push(`No project workspace directory is currently available for this issue. Using fallback workspace "${cwd}" for this run.`);
890
+ }
891
+ else {
892
+ warnings.push(`No project or prior session workspace was available. Using fallback workspace "${cwd}" for this run.`);
893
+ }
894
+ return {
895
+ cwd,
896
+ source: "agent_home",
897
+ projectId: resolvedProjectId,
898
+ workspaceId: null,
899
+ repoUrl: null,
900
+ repoRef: null,
901
+ workspaceHints,
902
+ warnings,
903
+ };
904
+ }
905
+ async function upsertTaskSession(input) {
906
+ const existing = await getTaskSession(input.companyId, input.agentId, input.adapterType, input.taskKey);
907
+ if (existing) {
908
+ return db
909
+ .update(agentTaskSessions)
910
+ .set({
911
+ sessionParamsJson: input.sessionParamsJson,
912
+ sessionDisplayId: input.sessionDisplayId,
913
+ lastRunId: input.lastRunId,
914
+ lastError: input.lastError,
915
+ updatedAt: new Date(),
916
+ })
917
+ .where(eq(agentTaskSessions.id, existing.id))
918
+ .returning()
919
+ .then((rows) => rows[0] ?? null);
920
+ }
921
+ return db
922
+ .insert(agentTaskSessions)
923
+ .values({
924
+ companyId: input.companyId,
925
+ agentId: input.agentId,
926
+ adapterType: input.adapterType,
927
+ taskKey: input.taskKey,
928
+ sessionParamsJson: input.sessionParamsJson,
929
+ sessionDisplayId: input.sessionDisplayId,
930
+ lastRunId: input.lastRunId,
931
+ lastError: input.lastError,
932
+ })
933
+ .returning()
934
+ .then((rows) => rows[0] ?? null);
935
+ }
936
+ async function clearTaskSessions(companyId, agentId, opts) {
937
+ const conditions = [
938
+ eq(agentTaskSessions.companyId, companyId),
939
+ eq(agentTaskSessions.agentId, agentId),
940
+ ];
941
+ if (opts?.taskKey) {
942
+ conditions.push(eq(agentTaskSessions.taskKey, opts.taskKey));
943
+ }
944
+ if (opts?.adapterType) {
945
+ conditions.push(eq(agentTaskSessions.adapterType, opts.adapterType));
946
+ }
947
+ return db
948
+ .delete(agentTaskSessions)
949
+ .where(and(...conditions))
950
+ .returning()
951
+ .then((rows) => rows.length);
952
+ }
953
+ async function ensureRuntimeState(agent) {
954
+ const existing = await getRuntimeState(agent.id);
955
+ if (existing)
956
+ return existing;
957
+ return db
958
+ .insert(agentRuntimeState)
959
+ .values({
960
+ agentId: agent.id,
961
+ companyId: agent.companyId,
962
+ adapterType: agent.adapterType,
963
+ stateJson: {},
964
+ })
965
+ .returning()
966
+ .then((rows) => rows[0]);
967
+ }
968
+ async function setRunStatus(runId, status, patch) {
969
+ const updated = await db
970
+ .update(heartbeatRuns)
971
+ .set({ status, ...patch, updatedAt: new Date() })
972
+ .where(eq(heartbeatRuns.id, runId))
973
+ .returning()
974
+ .then((rows) => rows[0] ?? null);
975
+ if (updated) {
976
+ publishLiveEvent({
977
+ companyId: updated.companyId,
978
+ type: "heartbeat.run.status",
979
+ payload: {
980
+ runId: updated.id,
981
+ agentId: updated.agentId,
982
+ status: updated.status,
983
+ invocationSource: updated.invocationSource,
984
+ triggerDetail: updated.triggerDetail,
985
+ error: updated.error ?? null,
986
+ errorCode: updated.errorCode ?? null,
987
+ startedAt: updated.startedAt ? new Date(updated.startedAt).toISOString() : null,
988
+ finishedAt: updated.finishedAt ? new Date(updated.finishedAt).toISOString() : null,
989
+ },
990
+ });
991
+ }
992
+ return updated;
993
+ }
994
+ async function setWakeupStatus(wakeupRequestId, status, patch) {
995
+ if (!wakeupRequestId)
996
+ return;
997
+ await db
998
+ .update(agentWakeupRequests)
999
+ .set({ status, ...patch, updatedAt: new Date() })
1000
+ .where(eq(agentWakeupRequests.id, wakeupRequestId));
1001
+ }
1002
+ async function appendRunEvent(run, seq, event) {
1003
+ const sanitizedMessage = event.message ? redactCurrentUserText(event.message) : event.message;
1004
+ const sanitizedPayload = event.payload ? redactCurrentUserValue(event.payload) : event.payload;
1005
+ await db.insert(heartbeatRunEvents).values({
1006
+ companyId: run.companyId,
1007
+ runId: run.id,
1008
+ agentId: run.agentId,
1009
+ seq,
1010
+ eventType: event.eventType,
1011
+ stream: event.stream,
1012
+ level: event.level,
1013
+ color: event.color,
1014
+ message: sanitizedMessage,
1015
+ payload: sanitizedPayload,
1016
+ });
1017
+ publishLiveEvent({
1018
+ companyId: run.companyId,
1019
+ type: "heartbeat.run.event",
1020
+ payload: {
1021
+ runId: run.id,
1022
+ agentId: run.agentId,
1023
+ seq,
1024
+ eventType: event.eventType,
1025
+ stream: event.stream ?? null,
1026
+ level: event.level ?? null,
1027
+ color: event.color ?? null,
1028
+ message: sanitizedMessage ?? null,
1029
+ payload: sanitizedPayload ?? null,
1030
+ },
1031
+ });
1032
+ }
1033
+ async function nextRunEventSeq(runId) {
1034
+ const [row] = await db
1035
+ .select({ maxSeq: sql `max(${heartbeatRunEvents.seq})` })
1036
+ .from(heartbeatRunEvents)
1037
+ .where(eq(heartbeatRunEvents.runId, runId));
1038
+ return Number(row?.maxSeq ?? 0) + 1;
1039
+ }
1040
+ async function persistRunProcessMetadata(runId, meta) {
1041
+ const startedAt = new Date(meta.startedAt);
1042
+ return db
1043
+ .update(heartbeatRuns)
1044
+ .set({
1045
+ processPid: meta.pid,
1046
+ processStartedAt: Number.isNaN(startedAt.getTime()) ? new Date() : startedAt,
1047
+ updatedAt: new Date(),
1048
+ })
1049
+ .where(eq(heartbeatRuns.id, runId))
1050
+ .returning()
1051
+ .then((rows) => rows[0] ?? null);
1052
+ }
1053
+ async function clearDetachedRunWarning(runId) {
1054
+ const updated = await db
1055
+ .update(heartbeatRuns)
1056
+ .set({
1057
+ error: null,
1058
+ errorCode: null,
1059
+ updatedAt: new Date(),
1060
+ })
1061
+ .where(and(eq(heartbeatRuns.id, runId), eq(heartbeatRuns.status, "running"), eq(heartbeatRuns.errorCode, DETACHED_PROCESS_ERROR_CODE)))
1062
+ .returning()
1063
+ .then((rows) => rows[0] ?? null);
1064
+ if (!updated)
1065
+ return null;
1066
+ await appendRunEvent(updated, await nextRunEventSeq(updated.id), {
1067
+ eventType: "lifecycle",
1068
+ stream: "system",
1069
+ level: "info",
1070
+ message: "Detached child process reported activity; cleared detached warning",
1071
+ });
1072
+ return updated;
1073
+ }
1074
+ async function enqueueProcessLossRetry(run, agent, now) {
1075
+ const contextSnapshot = parseObject(run.contextSnapshot);
1076
+ const issueId = readNonEmptyString(contextSnapshot.issueId);
1077
+ const taskKey = deriveTaskKey(contextSnapshot, null);
1078
+ const sessionBefore = await resolveSessionBeforeForWakeup(agent, taskKey);
1079
+ const retryContextSnapshot = {
1080
+ ...contextSnapshot,
1081
+ retryOfRunId: run.id,
1082
+ wakeReason: "process_lost_retry",
1083
+ retryReason: "process_lost",
1084
+ };
1085
+ const queued = await db.transaction(async (tx) => {
1086
+ const wakeupRequest = await tx
1087
+ .insert(agentWakeupRequests)
1088
+ .values({
1089
+ companyId: run.companyId,
1090
+ agentId: run.agentId,
1091
+ source: "automation",
1092
+ triggerDetail: "system",
1093
+ reason: "process_lost_retry",
1094
+ payload: {
1095
+ ...(issueId ? { issueId } : {}),
1096
+ retryOfRunId: run.id,
1097
+ },
1098
+ status: "queued",
1099
+ requestedByActorType: "system",
1100
+ requestedByActorId: null,
1101
+ updatedAt: now,
1102
+ })
1103
+ .returning()
1104
+ .then((rows) => rows[0]);
1105
+ const retryRun = await tx
1106
+ .insert(heartbeatRuns)
1107
+ .values({
1108
+ companyId: run.companyId,
1109
+ agentId: run.agentId,
1110
+ invocationSource: "automation",
1111
+ triggerDetail: "system",
1112
+ status: "queued",
1113
+ wakeupRequestId: wakeupRequest.id,
1114
+ contextSnapshot: retryContextSnapshot,
1115
+ sessionIdBefore: sessionBefore,
1116
+ retryOfRunId: run.id,
1117
+ processLossRetryCount: (run.processLossRetryCount ?? 0) + 1,
1118
+ updatedAt: now,
1119
+ })
1120
+ .returning()
1121
+ .then((rows) => rows[0]);
1122
+ await tx
1123
+ .update(agentWakeupRequests)
1124
+ .set({
1125
+ runId: retryRun.id,
1126
+ updatedAt: now,
1127
+ })
1128
+ .where(eq(agentWakeupRequests.id, wakeupRequest.id));
1129
+ if (issueId) {
1130
+ await tx
1131
+ .update(issues)
1132
+ .set({
1133
+ executionRunId: retryRun.id,
1134
+ executionAgentNameKey: normalizeAgentNameKey(agent.name),
1135
+ executionLockedAt: now,
1136
+ updatedAt: now,
1137
+ })
1138
+ .where(and(eq(issues.id, issueId), eq(issues.companyId, run.companyId), eq(issues.executionRunId, run.id)));
1139
+ }
1140
+ return retryRun;
1141
+ });
1142
+ publishLiveEvent({
1143
+ companyId: queued.companyId,
1144
+ type: "heartbeat.run.queued",
1145
+ payload: {
1146
+ runId: queued.id,
1147
+ agentId: queued.agentId,
1148
+ invocationSource: queued.invocationSource,
1149
+ triggerDetail: queued.triggerDetail,
1150
+ wakeupRequestId: queued.wakeupRequestId,
1151
+ },
1152
+ });
1153
+ await appendRunEvent(queued, 1, {
1154
+ eventType: "lifecycle",
1155
+ stream: "system",
1156
+ level: "warn",
1157
+ message: "Queued automatic retry after orphaned child process was confirmed dead",
1158
+ payload: {
1159
+ retryOfRunId: run.id,
1160
+ },
1161
+ });
1162
+ return queued;
1163
+ }
1164
+ function parseHeartbeatPolicy(agent) {
1165
+ const runtimeConfig = parseObject(agent.runtimeConfig);
1166
+ const heartbeat = parseObject(runtimeConfig.heartbeat);
1167
+ // globalWakeOnDemand is the legacy single flag — per-source flags take precedence.
1168
+ // Separating these means disabling on_demand wakeups won't accidentally block
1169
+ // assignment-triggered wakeups (the primary pipeline path).
1170
+ const globalWakeOnDemand = heartbeat.wakeOnDemand;
1171
+ return {
1172
+ enabled: asBoolean(heartbeat.enabled, true),
1173
+ intervalSec: Math.max(0, asNumber(heartbeat.intervalSec, 0)),
1174
+ wakeOnAssignment: asBoolean(heartbeat.wakeOnAssignment ?? globalWakeOnDemand, true),
1175
+ wakeOnAutomation: asBoolean(heartbeat.wakeOnAutomation ?? globalWakeOnDemand, true),
1176
+ wakeOnDemand: asBoolean(heartbeat.wakeOnOnDemand ?? globalWakeOnDemand, true),
1177
+ maxConcurrentRuns: normalizeMaxConcurrentRuns(heartbeat.maxConcurrentRuns),
1178
+ };
1179
+ }
1180
+ async function countRunningRunsForAgent(agentId) {
1181
+ const [{ count }] = await db
1182
+ .select({ count: sql `count(*)` })
1183
+ .from(heartbeatRuns)
1184
+ .where(and(eq(heartbeatRuns.agentId, agentId), eq(heartbeatRuns.status, "running")));
1185
+ return Number(count ?? 0);
1186
+ }
1187
+ async function claimQueuedRun(run) {
1188
+ if (run.status !== "queued")
1189
+ return run;
1190
+ const agent = await getAgent(run.agentId);
1191
+ if (!agent) {
1192
+ await cancelRunInternal(run.id, "Cancelled because the agent no longer exists");
1193
+ return null;
1194
+ }
1195
+ if (agent.status === "paused" || agent.status === "terminated" || agent.status === "pending_approval") {
1196
+ await cancelRunInternal(run.id, "Cancelled because the agent is not invokable");
1197
+ return null;
1198
+ }
1199
+ const context = parseObject(run.contextSnapshot);
1200
+ const budgetBlock = await budgets.getInvocationBlock(run.companyId, run.agentId, {
1201
+ issueId: readNonEmptyString(context.issueId),
1202
+ projectId: readNonEmptyString(context.projectId),
1203
+ });
1204
+ if (budgetBlock) {
1205
+ await cancelRunInternal(run.id, budgetBlock.reason);
1206
+ return null;
1207
+ }
1208
+ const claimedAt = new Date();
1209
+ const claimed = await db
1210
+ .update(heartbeatRuns)
1211
+ .set({
1212
+ status: "running",
1213
+ startedAt: run.startedAt ?? claimedAt,
1214
+ updatedAt: claimedAt,
1215
+ })
1216
+ .where(and(eq(heartbeatRuns.id, run.id), eq(heartbeatRuns.status, "queued")))
1217
+ .returning()
1218
+ .then((rows) => rows[0] ?? null);
1219
+ if (!claimed)
1220
+ return null;
1221
+ publishLiveEvent({
1222
+ companyId: claimed.companyId,
1223
+ type: "heartbeat.run.status",
1224
+ payload: {
1225
+ runId: claimed.id,
1226
+ agentId: claimed.agentId,
1227
+ status: claimed.status,
1228
+ invocationSource: claimed.invocationSource,
1229
+ triggerDetail: claimed.triggerDetail,
1230
+ error: claimed.error ?? null,
1231
+ errorCode: claimed.errorCode ?? null,
1232
+ startedAt: claimed.startedAt ? new Date(claimed.startedAt).toISOString() : null,
1233
+ finishedAt: claimed.finishedAt ? new Date(claimed.finishedAt).toISOString() : null,
1234
+ },
1235
+ });
1236
+ await setWakeupStatus(claimed.wakeupRequestId, "claimed", { claimedAt });
1237
+ return claimed;
1238
+ }
1239
+ async function finalizeAgentStatus(agentId, outcome) {
1240
+ const existing = await getAgent(agentId);
1241
+ if (!existing)
1242
+ return;
1243
+ if (existing.status === "paused" || existing.status === "terminated") {
1244
+ return;
1245
+ }
1246
+ const runningCount = await countRunningRunsForAgent(agentId);
1247
+ const nextStatus = runningCount > 0
1248
+ ? "running"
1249
+ : outcome === "succeeded" || outcome === "cancelled"
1250
+ ? "idle"
1251
+ : "error";
1252
+ const updated = await db
1253
+ .update(agents)
1254
+ .set({
1255
+ status: nextStatus,
1256
+ lastHeartbeatAt: new Date(),
1257
+ updatedAt: new Date(),
1258
+ })
1259
+ .where(eq(agents.id, agentId))
1260
+ .returning()
1261
+ .then((rows) => rows[0] ?? null);
1262
+ if (updated) {
1263
+ publishLiveEvent({
1264
+ companyId: updated.companyId,
1265
+ type: "agent.status",
1266
+ payload: {
1267
+ agentId: updated.id,
1268
+ status: updated.status,
1269
+ lastHeartbeatAt: updated.lastHeartbeatAt
1270
+ ? new Date(updated.lastHeartbeatAt).toISOString()
1271
+ : null,
1272
+ outcome,
1273
+ },
1274
+ });
1275
+ }
1276
+ }
1277
+ async function reapOrphanedRuns(opts) {
1278
+ const staleThresholdMs = opts?.staleThresholdMs ?? 0;
1279
+ const now = new Date();
1280
+ // Find all runs stuck in "running" state (queued runs are legitimately waiting; resumeQueuedRuns handles them)
1281
+ const activeRuns = await db
1282
+ .select({
1283
+ run: heartbeatRuns,
1284
+ adapterType: agents.adapterType,
1285
+ })
1286
+ .from(heartbeatRuns)
1287
+ .innerJoin(agents, eq(heartbeatRuns.agentId, agents.id))
1288
+ .where(eq(heartbeatRuns.status, "running"));
1289
+ const reaped = [];
1290
+ for (const { run, adapterType } of activeRuns) {
1291
+ if (runningProcesses.has(run.id) || activeRunExecutions.has(run.id))
1292
+ continue;
1293
+ // Apply staleness threshold to avoid false positives
1294
+ if (staleThresholdMs > 0) {
1295
+ const refTime = run.updatedAt ? new Date(run.updatedAt).getTime() : 0;
1296
+ if (now.getTime() - refTime < staleThresholdMs)
1297
+ continue;
1298
+ }
1299
+ const tracksLocalChild = isTrackedLocalChildProcessAdapter(adapterType);
1300
+ if (tracksLocalChild && run.processPid && isProcessAlive(run.processPid)) {
1301
+ if (run.errorCode !== DETACHED_PROCESS_ERROR_CODE) {
1302
+ const detachedMessage = `Lost in-memory process handle, but child pid ${run.processPid} is still alive`;
1303
+ const detachedRun = await setRunStatus(run.id, "running", {
1304
+ error: detachedMessage,
1305
+ errorCode: DETACHED_PROCESS_ERROR_CODE,
1306
+ });
1307
+ if (detachedRun) {
1308
+ await appendRunEvent(detachedRun, await nextRunEventSeq(detachedRun.id), {
1309
+ eventType: "lifecycle",
1310
+ stream: "system",
1311
+ level: "warn",
1312
+ message: detachedMessage,
1313
+ payload: {
1314
+ processPid: run.processPid,
1315
+ },
1316
+ });
1317
+ }
1318
+ }
1319
+ continue;
1320
+ }
1321
+ const shouldRetry = tracksLocalChild && !!run.processPid && (run.processLossRetryCount ?? 0) < 1;
1322
+ const baseMessage = run.processPid
1323
+ ? `Process lost -- child pid ${run.processPid} is no longer running`
1324
+ : "Process lost -- server may have restarted";
1325
+ let finalizedRun = await setRunStatus(run.id, "failed", {
1326
+ error: shouldRetry ? `${baseMessage}; retrying once` : baseMessage,
1327
+ errorCode: "process_lost",
1328
+ finishedAt: now,
1329
+ });
1330
+ await setWakeupStatus(run.wakeupRequestId, "failed", {
1331
+ finishedAt: now,
1332
+ error: shouldRetry ? `${baseMessage}; retrying once` : baseMessage,
1333
+ });
1334
+ if (!finalizedRun)
1335
+ finalizedRun = await getRun(run.id);
1336
+ if (!finalizedRun)
1337
+ continue;
1338
+ let retriedRun = null;
1339
+ if (shouldRetry) {
1340
+ const agent = await getAgent(run.agentId);
1341
+ if (agent) {
1342
+ retriedRun = await enqueueProcessLossRetry(finalizedRun, agent, now);
1343
+ }
1344
+ }
1345
+ else {
1346
+ await releaseIssueExecutionAndPromote(finalizedRun);
1347
+ }
1348
+ await appendRunEvent(finalizedRun, await nextRunEventSeq(finalizedRun.id), {
1349
+ eventType: "lifecycle",
1350
+ stream: "system",
1351
+ level: "error",
1352
+ message: shouldRetry
1353
+ ? `${baseMessage}; queued retry ${retriedRun?.id ?? ""}`.trim()
1354
+ : baseMessage,
1355
+ payload: {
1356
+ ...(run.processPid ? { processPid: run.processPid } : {}),
1357
+ ...(retriedRun ? { retryRunId: retriedRun.id } : {}),
1358
+ },
1359
+ });
1360
+ await finalizeAgentStatus(run.agentId, "failed");
1361
+ await startNextQueuedRunForAgent(run.agentId);
1362
+ runningProcesses.delete(run.id);
1363
+ reaped.push(run.id);
1364
+ }
1365
+ if (reaped.length > 0) {
1366
+ logger.warn({ reapedCount: reaped.length, runIds: reaped }, "reaped orphaned heartbeat runs");
1367
+ }
1368
+ return { reaped: reaped.length, runIds: reaped };
1369
+ }
1370
+ async function resumeQueuedRuns() {
1371
+ const queuedRuns = await db
1372
+ .select({ agentId: heartbeatRuns.agentId })
1373
+ .from(heartbeatRuns)
1374
+ .where(eq(heartbeatRuns.status, "queued"));
1375
+ const agentIds = [...new Set(queuedRuns.map((r) => r.agentId))];
1376
+ for (const agentId of agentIds) {
1377
+ await startNextQueuedRunForAgent(agentId);
1378
+ }
1379
+ }
1380
+ async function updateRuntimeState(agent, run, result, session, normalizedUsage) {
1381
+ await ensureRuntimeState(agent);
1382
+ const usage = normalizedUsage ?? normalizeUsageTotals(result.usage);
1383
+ const inputTokens = usage?.inputTokens ?? 0;
1384
+ const outputTokens = usage?.outputTokens ?? 0;
1385
+ const cachedInputTokens = usage?.cachedInputTokens ?? 0;
1386
+ const billingType = normalizeLedgerBillingType(result.billingType);
1387
+ const additionalCostCents = normalizeBilledCostCents(result.costUsd, billingType);
1388
+ const hasTokenUsage = inputTokens > 0 || outputTokens > 0 || cachedInputTokens > 0;
1389
+ const provider = result.provider ?? "unknown";
1390
+ const biller = resolveLedgerBiller(result);
1391
+ const ledgerScope = await resolveLedgerScopeForRun(db, agent.companyId, run);
1392
+ await db
1393
+ .update(agentRuntimeState)
1394
+ .set({
1395
+ adapterType: agent.adapterType,
1396
+ sessionId: session.legacySessionId,
1397
+ lastRunId: run.id,
1398
+ lastRunStatus: run.status,
1399
+ lastError: result.errorMessage ?? null,
1400
+ totalInputTokens: sql `${agentRuntimeState.totalInputTokens} + ${inputTokens}`,
1401
+ totalOutputTokens: sql `${agentRuntimeState.totalOutputTokens} + ${outputTokens}`,
1402
+ totalCachedInputTokens: sql `${agentRuntimeState.totalCachedInputTokens} + ${cachedInputTokens}`,
1403
+ totalCostCents: sql `${agentRuntimeState.totalCostCents} + ${additionalCostCents}`,
1404
+ updatedAt: new Date(),
1405
+ })
1406
+ .where(eq(agentRuntimeState.agentId, agent.id));
1407
+ if (additionalCostCents > 0 || hasTokenUsage) {
1408
+ const costs = costService(db, budgetHooks);
1409
+ await costs.createEvent(agent.companyId, {
1410
+ heartbeatRunId: run.id,
1411
+ agentId: agent.id,
1412
+ issueId: ledgerScope.issueId,
1413
+ projectId: ledgerScope.projectId,
1414
+ provider,
1415
+ biller,
1416
+ billingType,
1417
+ model: result.model ?? "unknown",
1418
+ inputTokens,
1419
+ cachedInputTokens,
1420
+ outputTokens,
1421
+ costCents: additionalCostCents,
1422
+ occurredAt: new Date(),
1423
+ });
1424
+ }
1425
+ }
1426
+ async function startNextQueuedRunForAgent(agentId) {
1427
+ return withAgentStartLock(agentId, async () => {
1428
+ const agent = await getAgent(agentId);
1429
+ if (!agent)
1430
+ return [];
1431
+ if (agent.status === "paused" || agent.status === "terminated" || agent.status === "pending_approval") {
1432
+ return [];
1433
+ }
1434
+ const policy = parseHeartbeatPolicy(agent);
1435
+ const runningCount = await countRunningRunsForAgent(agentId);
1436
+ const availableSlots = Math.max(0, policy.maxConcurrentRuns - runningCount);
1437
+ if (availableSlots <= 0)
1438
+ return [];
1439
+ const queuedRuns = await db
1440
+ .select()
1441
+ .from(heartbeatRuns)
1442
+ .where(and(eq(heartbeatRuns.agentId, agentId), eq(heartbeatRuns.status, "queued")))
1443
+ .orderBy(asc(heartbeatRuns.createdAt))
1444
+ .limit(availableSlots);
1445
+ if (queuedRuns.length === 0)
1446
+ return [];
1447
+ const claimedRuns = [];
1448
+ for (const queuedRun of queuedRuns) {
1449
+ const claimed = await claimQueuedRun(queuedRun);
1450
+ if (claimed)
1451
+ claimedRuns.push(claimed);
1452
+ }
1453
+ if (claimedRuns.length === 0)
1454
+ return [];
1455
+ for (const claimedRun of claimedRuns) {
1456
+ void executeRun(claimedRun.id).catch((err) => {
1457
+ logger.error({ err, runId: claimedRun.id }, "queued heartbeat execution failed");
1458
+ });
1459
+ }
1460
+ return claimedRuns;
1461
+ });
1462
+ }
1463
+ async function executeRun(runId) {
1464
+ let run = await getRun(runId);
1465
+ if (!run)
1466
+ return;
1467
+ if (run.status !== "queued" && run.status !== "running")
1468
+ return;
1469
+ if (run.status === "queued") {
1470
+ const claimed = await claimQueuedRun(run);
1471
+ if (!claimed) {
1472
+ // Another worker has already claimed or finalized this run.
1473
+ return;
1474
+ }
1475
+ run = claimed;
1476
+ }
1477
+ activeRunExecutions.add(run.id);
1478
+ try {
1479
+ const agent = await getAgent(run.agentId);
1480
+ if (!agent) {
1481
+ await setRunStatus(runId, "failed", {
1482
+ error: "Agent not found",
1483
+ errorCode: "agent_not_found",
1484
+ finishedAt: new Date(),
1485
+ });
1486
+ await setWakeupStatus(run.wakeupRequestId, "failed", {
1487
+ finishedAt: new Date(),
1488
+ error: "Agent not found",
1489
+ });
1490
+ const failedRun = await getRun(runId);
1491
+ if (failedRun)
1492
+ await releaseIssueExecutionAndPromote(failedRun);
1493
+ return;
1494
+ }
1495
+ const runtime = await ensureRuntimeState(agent);
1496
+ const context = parseObject(run.contextSnapshot);
1497
+ const taskKey = deriveTaskKey(context, null);
1498
+ const sessionCodec = getAdapterSessionCodec(agent.adapterType);
1499
+ const issueId = readNonEmptyString(context.issueId);
1500
+ const issueContext = issueId
1501
+ ? await db
1502
+ .select({
1503
+ id: issues.id,
1504
+ identifier: issues.identifier,
1505
+ title: issues.title,
1506
+ projectId: issues.projectId,
1507
+ projectWorkspaceId: issues.projectWorkspaceId,
1508
+ executionWorkspaceId: issues.executionWorkspaceId,
1509
+ executionWorkspacePreference: issues.executionWorkspacePreference,
1510
+ assigneeAgentId: issues.assigneeAgentId,
1511
+ assigneeAdapterOverrides: issues.assigneeAdapterOverrides,
1512
+ executionWorkspaceSettings: issues.executionWorkspaceSettings,
1513
+ })
1514
+ .from(issues)
1515
+ .where(and(eq(issues.id, issueId), eq(issues.companyId, agent.companyId)))
1516
+ .then((rows) => rows[0] ?? null)
1517
+ : null;
1518
+ const issueAssigneeOverrides = issueContext && issueContext.assigneeAgentId === agent.id
1519
+ ? parseIssueAssigneeAdapterOverrides(issueContext.assigneeAdapterOverrides)
1520
+ : null;
1521
+ const isolatedWorkspacesEnabled = (await instanceSettings.getExperimental()).enableIsolatedWorkspaces;
1522
+ const issueExecutionWorkspaceSettings = isolatedWorkspacesEnabled
1523
+ ? parseIssueExecutionWorkspaceSettings(issueContext?.executionWorkspaceSettings)
1524
+ : null;
1525
+ const contextProjectId = readNonEmptyString(context.projectId);
1526
+ const executionProjectId = issueContext?.projectId ?? contextProjectId;
1527
+ const projectExecutionWorkspacePolicy = executionProjectId
1528
+ ? await db
1529
+ .select({ executionWorkspacePolicy: projects.executionWorkspacePolicy })
1530
+ .from(projects)
1531
+ .where(and(eq(projects.id, executionProjectId), eq(projects.companyId, agent.companyId)))
1532
+ .then((rows) => gateProjectExecutionWorkspacePolicy(parseProjectExecutionWorkspacePolicy(rows[0]?.executionWorkspacePolicy), isolatedWorkspacesEnabled))
1533
+ : null;
1534
+ const taskSession = taskKey
1535
+ ? await getTaskSession(agent.companyId, agent.id, agent.adapterType, taskKey)
1536
+ : null;
1537
+ const resetTaskSession = shouldResetTaskSessionForWake(context);
1538
+ const sessionResetReason = describeSessionResetReason(context);
1539
+ const taskSessionForRun = resetTaskSession ? null : taskSession;
1540
+ const previousSessionParams = normalizeSessionParams(sessionCodec.deserialize(taskSessionForRun?.sessionParamsJson ?? null));
1541
+ const config = parseObject(agent.adapterConfig);
1542
+ const executionWorkspaceMode = resolveExecutionWorkspaceMode({
1543
+ projectPolicy: projectExecutionWorkspacePolicy,
1544
+ issueSettings: issueExecutionWorkspaceSettings,
1545
+ legacyUseProjectWorkspace: issueAssigneeOverrides?.useProjectWorkspace ?? null,
1546
+ });
1547
+ const resolvedWorkspace = await resolveWorkspaceForRun(agent, context, previousSessionParams, { useProjectWorkspace: executionWorkspaceMode !== "agent_default" });
1548
+ const workspaceManagedConfig = buildExecutionWorkspaceAdapterConfig({
1549
+ agentConfig: config,
1550
+ projectPolicy: projectExecutionWorkspacePolicy,
1551
+ issueSettings: issueExecutionWorkspaceSettings,
1552
+ mode: executionWorkspaceMode,
1553
+ legacyUseProjectWorkspace: issueAssigneeOverrides?.useProjectWorkspace ?? null,
1554
+ });
1555
+ const mergedConfig = issueAssigneeOverrides?.adapterConfig
1556
+ ? { ...workspaceManagedConfig, ...issueAssigneeOverrides.adapterConfig }
1557
+ : workspaceManagedConfig;
1558
+ const { config: resolvedConfig, secretKeys } = await secretsSvc.resolveAdapterConfigForRuntime(agent.companyId, mergedConfig);
1559
+ const issueRef = issueContext
1560
+ ? {
1561
+ id: issueContext.id,
1562
+ identifier: issueContext.identifier,
1563
+ title: issueContext.title,
1564
+ projectId: issueContext.projectId,
1565
+ projectWorkspaceId: issueContext.projectWorkspaceId,
1566
+ executionWorkspaceId: issueContext.executionWorkspaceId,
1567
+ executionWorkspacePreference: issueContext.executionWorkspacePreference,
1568
+ }
1569
+ : null;
1570
+ const existingExecutionWorkspace = issueRef?.executionWorkspaceId ? await executionWorkspacesSvc.getById(issueRef.executionWorkspaceId) : null;
1571
+ const workspaceOperationRecorder = workspaceOperationsSvc.createRecorder({
1572
+ companyId: agent.companyId,
1573
+ heartbeatRunId: run.id,
1574
+ executionWorkspaceId: existingExecutionWorkspace?.id ?? null,
1575
+ });
1576
+ const executionWorkspace = await realizeExecutionWorkspace({
1577
+ base: {
1578
+ baseCwd: resolvedWorkspace.cwd,
1579
+ source: resolvedWorkspace.source,
1580
+ projectId: resolvedWorkspace.projectId,
1581
+ workspaceId: resolvedWorkspace.workspaceId,
1582
+ repoUrl: resolvedWorkspace.repoUrl,
1583
+ repoRef: resolvedWorkspace.repoRef,
1584
+ },
1585
+ config: resolvedConfig,
1586
+ issue: issueRef,
1587
+ agent: {
1588
+ id: agent.id,
1589
+ name: agent.name,
1590
+ companyId: agent.companyId,
1591
+ },
1592
+ recorder: workspaceOperationRecorder,
1593
+ });
1594
+ const resolvedProjectId = executionWorkspace.projectId ?? issueRef?.projectId ?? executionProjectId ?? null;
1595
+ const resolvedProjectWorkspaceId = issueRef?.projectWorkspaceId ?? resolvedWorkspace.workspaceId ?? null;
1596
+ const shouldReuseExisting = issueRef?.executionWorkspacePreference === "reuse_existing" &&
1597
+ existingExecutionWorkspace &&
1598
+ existingExecutionWorkspace.status !== "archived";
1599
+ let persistedExecutionWorkspace = null;
1600
+ try {
1601
+ persistedExecutionWorkspace = shouldReuseExisting && existingExecutionWorkspace
1602
+ ? await executionWorkspacesSvc.update(existingExecutionWorkspace.id, {
1603
+ cwd: executionWorkspace.cwd,
1604
+ repoUrl: executionWorkspace.repoUrl,
1605
+ baseRef: executionWorkspace.repoRef,
1606
+ branchName: executionWorkspace.branchName,
1607
+ providerType: executionWorkspace.strategy === "git_worktree" ? "git_worktree" : "local_fs",
1608
+ providerRef: executionWorkspace.worktreePath,
1609
+ status: "active",
1610
+ lastUsedAt: new Date(),
1611
+ metadata: {
1612
+ ...(existingExecutionWorkspace.metadata ?? {}),
1613
+ source: executionWorkspace.source,
1614
+ createdByRuntime: executionWorkspace.created,
1615
+ },
1616
+ })
1617
+ : resolvedProjectId
1618
+ ? await executionWorkspacesSvc.create({
1619
+ companyId: agent.companyId,
1620
+ projectId: resolvedProjectId,
1621
+ projectWorkspaceId: resolvedProjectWorkspaceId,
1622
+ sourceIssueId: issueRef?.id ?? null,
1623
+ mode: executionWorkspaceMode === "isolated_workspace"
1624
+ ? "isolated_workspace"
1625
+ : executionWorkspaceMode === "operator_branch"
1626
+ ? "operator_branch"
1627
+ : executionWorkspaceMode === "agent_default"
1628
+ ? "adapter_managed"
1629
+ : "shared_workspace",
1630
+ strategyType: executionWorkspace.strategy === "git_worktree" ? "git_worktree" : "project_primary",
1631
+ name: executionWorkspace.branchName ?? issueRef?.identifier ?? `workspace-${agent.id.slice(0, 8)}`,
1632
+ status: "active",
1633
+ cwd: executionWorkspace.cwd,
1634
+ repoUrl: executionWorkspace.repoUrl,
1635
+ baseRef: executionWorkspace.repoRef,
1636
+ branchName: executionWorkspace.branchName,
1637
+ providerType: executionWorkspace.strategy === "git_worktree" ? "git_worktree" : "local_fs",
1638
+ providerRef: executionWorkspace.worktreePath,
1639
+ lastUsedAt: new Date(),
1640
+ openedAt: new Date(),
1641
+ metadata: {
1642
+ source: executionWorkspace.source,
1643
+ createdByRuntime: executionWorkspace.created,
1644
+ },
1645
+ })
1646
+ : null;
1647
+ }
1648
+ catch (error) {
1649
+ if (executionWorkspace.created) {
1650
+ try {
1651
+ await cleanupExecutionWorkspaceArtifacts({
1652
+ workspace: {
1653
+ id: existingExecutionWorkspace?.id ?? `transient-${run.id}`,
1654
+ cwd: executionWorkspace.cwd,
1655
+ providerType: executionWorkspace.strategy === "git_worktree" ? "git_worktree" : "local_fs",
1656
+ providerRef: executionWorkspace.worktreePath,
1657
+ branchName: executionWorkspace.branchName,
1658
+ repoUrl: executionWorkspace.repoUrl,
1659
+ baseRef: executionWorkspace.repoRef,
1660
+ projectId: resolvedProjectId,
1661
+ projectWorkspaceId: resolvedProjectWorkspaceId,
1662
+ sourceIssueId: issueRef?.id ?? null,
1663
+ metadata: {
1664
+ createdByRuntime: true,
1665
+ source: executionWorkspace.source,
1666
+ },
1667
+ },
1668
+ projectWorkspace: {
1669
+ cwd: resolvedWorkspace.cwd,
1670
+ cleanupCommand: null,
1671
+ },
1672
+ teardownCommand: projectExecutionWorkspacePolicy?.workspaceStrategy?.teardownCommand ?? null,
1673
+ recorder: workspaceOperationRecorder,
1674
+ });
1675
+ }
1676
+ catch (cleanupError) {
1677
+ logger.warn({
1678
+ runId: run.id,
1679
+ issueId,
1680
+ executionWorkspaceCwd: executionWorkspace.cwd,
1681
+ cleanupError: cleanupError instanceof Error ? cleanupError.message : String(cleanupError),
1682
+ }, "Failed to cleanup realized execution workspace after persistence failure");
1683
+ }
1684
+ }
1685
+ throw error;
1686
+ }
1687
+ await workspaceOperationRecorder.attachExecutionWorkspaceId(persistedExecutionWorkspace?.id ?? null);
1688
+ if (existingExecutionWorkspace &&
1689
+ persistedExecutionWorkspace &&
1690
+ existingExecutionWorkspace.id !== persistedExecutionWorkspace.id &&
1691
+ existingExecutionWorkspace.status === "active") {
1692
+ await executionWorkspacesSvc.update(existingExecutionWorkspace.id, {
1693
+ status: "idle",
1694
+ cleanupReason: null,
1695
+ });
1696
+ }
1697
+ if (issueId && persistedExecutionWorkspace && issueRef?.executionWorkspaceId !== persistedExecutionWorkspace.id) {
1698
+ await issuesSvc.update(issueId, {
1699
+ executionWorkspaceId: persistedExecutionWorkspace.id,
1700
+ ...(resolvedProjectWorkspaceId ? { projectWorkspaceId: resolvedProjectWorkspaceId } : {}),
1701
+ });
1702
+ }
1703
+ if (persistedExecutionWorkspace) {
1704
+ context.executionWorkspaceId = persistedExecutionWorkspace.id;
1705
+ await db
1706
+ .update(heartbeatRuns)
1707
+ .set({
1708
+ contextSnapshot: context,
1709
+ updatedAt: new Date(),
1710
+ })
1711
+ .where(eq(heartbeatRuns.id, run.id));
1712
+ }
1713
+ const runtimeSessionResolution = resolveRuntimeSessionParamsForWorkspace({
1714
+ agentId: agent.id,
1715
+ previousSessionParams,
1716
+ resolvedWorkspace: {
1717
+ ...resolvedWorkspace,
1718
+ cwd: executionWorkspace.cwd,
1719
+ },
1720
+ });
1721
+ const runtimeSessionParams = runtimeSessionResolution.sessionParams;
1722
+ const runtimeWorkspaceWarnings = [
1723
+ ...resolvedWorkspace.warnings,
1724
+ ...executionWorkspace.warnings,
1725
+ ...(runtimeSessionResolution.warning ? [runtimeSessionResolution.warning] : []),
1726
+ ...(resetTaskSession && sessionResetReason
1727
+ ? [
1728
+ taskKey
1729
+ ? `Skipping saved session resume for task "${taskKey}" because ${sessionResetReason}.`
1730
+ : `Skipping saved session resume because ${sessionResetReason}.`,
1731
+ ]
1732
+ : []),
1733
+ ];
1734
+ context.paperclipWorkspace = {
1735
+ cwd: executionWorkspace.cwd,
1736
+ source: executionWorkspace.source,
1737
+ mode: executionWorkspaceMode,
1738
+ strategy: executionWorkspace.strategy,
1739
+ projectId: executionWorkspace.projectId,
1740
+ workspaceId: executionWorkspace.workspaceId,
1741
+ repoUrl: executionWorkspace.repoUrl,
1742
+ repoRef: executionWorkspace.repoRef,
1743
+ branchName: executionWorkspace.branchName,
1744
+ worktreePath: executionWorkspace.worktreePath,
1745
+ agentHome: resolveDefaultAgentWorkspaceDir(agent.id),
1746
+ };
1747
+ context.paperclipWorkspaces = resolvedWorkspace.workspaceHints;
1748
+ const runtimeServiceIntents = (() => {
1749
+ const runtimeConfig = parseObject(resolvedConfig.workspaceRuntime);
1750
+ return Array.isArray(runtimeConfig.services)
1751
+ ? runtimeConfig.services.filter((value) => typeof value === "object" && value !== null)
1752
+ : [];
1753
+ })();
1754
+ if (runtimeServiceIntents.length > 0) {
1755
+ context.paperclipRuntimeServiceIntents = runtimeServiceIntents;
1756
+ }
1757
+ else {
1758
+ delete context.paperclipRuntimeServiceIntents;
1759
+ }
1760
+ if (executionWorkspace.projectId && !readNonEmptyString(context.projectId)) {
1761
+ context.projectId = executionWorkspace.projectId;
1762
+ }
1763
+ const runtimeSessionFallback = taskKey || resetTaskSession ? null : runtime.sessionId;
1764
+ let previousSessionDisplayId = truncateDisplayId(taskSessionForRun?.sessionDisplayId ??
1765
+ (sessionCodec.getDisplayId ? sessionCodec.getDisplayId(runtimeSessionParams) : null) ??
1766
+ readNonEmptyString(runtimeSessionParams?.sessionId) ??
1767
+ runtimeSessionFallback);
1768
+ let runtimeSessionIdForAdapter = readNonEmptyString(runtimeSessionParams?.sessionId) ?? runtimeSessionFallback;
1769
+ let runtimeSessionParamsForAdapter = runtimeSessionParams;
1770
+ const sessionCompaction = await evaluateSessionCompaction({
1771
+ agent,
1772
+ sessionId: previousSessionDisplayId ?? runtimeSessionIdForAdapter,
1773
+ issueId,
1774
+ });
1775
+ if (sessionCompaction.rotate) {
1776
+ context.paperclipSessionHandoffMarkdown = sessionCompaction.handoffMarkdown;
1777
+ context.paperclipSessionRotationReason = sessionCompaction.reason;
1778
+ context.paperclipPreviousSessionId = previousSessionDisplayId ?? runtimeSessionIdForAdapter;
1779
+ runtimeSessionIdForAdapter = null;
1780
+ runtimeSessionParamsForAdapter = null;
1781
+ previousSessionDisplayId = null;
1782
+ if (sessionCompaction.reason) {
1783
+ runtimeWorkspaceWarnings.push(`Starting a fresh session because ${sessionCompaction.reason}.`);
1784
+ }
1785
+ }
1786
+ else {
1787
+ delete context.paperclipSessionHandoffMarkdown;
1788
+ delete context.paperclipSessionRotationReason;
1789
+ delete context.paperclipPreviousSessionId;
1790
+ }
1791
+ const runtimeForAdapter = {
1792
+ sessionId: runtimeSessionIdForAdapter,
1793
+ sessionParams: runtimeSessionParamsForAdapter,
1794
+ sessionDisplayId: previousSessionDisplayId,
1795
+ taskKey,
1796
+ };
1797
+ let seq = 1;
1798
+ let handle = null;
1799
+ let stdoutExcerpt = "";
1800
+ let stderrExcerpt = "";
1801
+ try {
1802
+ const startedAt = run.startedAt ?? new Date();
1803
+ const runningWithSession = await db
1804
+ .update(heartbeatRuns)
1805
+ .set({
1806
+ startedAt,
1807
+ sessionIdBefore: runtimeForAdapter.sessionDisplayId ?? runtimeForAdapter.sessionId,
1808
+ contextSnapshot: context,
1809
+ updatedAt: new Date(),
1810
+ })
1811
+ .where(eq(heartbeatRuns.id, run.id))
1812
+ .returning()
1813
+ .then((rows) => rows[0] ?? null);
1814
+ if (runningWithSession)
1815
+ run = runningWithSession;
1816
+ const runningAgent = await db
1817
+ .update(agents)
1818
+ .set({ status: "running", updatedAt: new Date() })
1819
+ .where(eq(agents.id, agent.id))
1820
+ .returning()
1821
+ .then((rows) => rows[0] ?? null);
1822
+ if (runningAgent) {
1823
+ publishLiveEvent({
1824
+ companyId: runningAgent.companyId,
1825
+ type: "agent.status",
1826
+ payload: {
1827
+ agentId: runningAgent.id,
1828
+ status: runningAgent.status,
1829
+ outcome: "running",
1830
+ },
1831
+ });
1832
+ }
1833
+ const currentRun = run;
1834
+ await appendRunEvent(currentRun, seq++, {
1835
+ eventType: "lifecycle",
1836
+ stream: "system",
1837
+ level: "info",
1838
+ message: "run started",
1839
+ });
1840
+ handle = await runLogStore.begin({
1841
+ companyId: run.companyId,
1842
+ agentId: run.agentId,
1843
+ runId,
1844
+ });
1845
+ await db
1846
+ .update(heartbeatRuns)
1847
+ .set({
1848
+ logStore: handle.store,
1849
+ logRef: handle.logRef,
1850
+ updatedAt: new Date(),
1851
+ })
1852
+ .where(eq(heartbeatRuns.id, runId));
1853
+ const onLog = async (stream, chunk) => {
1854
+ const sanitizedChunk = redactCurrentUserText(chunk);
1855
+ if (stream === "stdout")
1856
+ stdoutExcerpt = appendExcerpt(stdoutExcerpt, sanitizedChunk);
1857
+ if (stream === "stderr")
1858
+ stderrExcerpt = appendExcerpt(stderrExcerpt, sanitizedChunk);
1859
+ const ts = new Date().toISOString();
1860
+ if (handle) {
1861
+ await runLogStore.append(handle, {
1862
+ stream,
1863
+ chunk: sanitizedChunk,
1864
+ ts,
1865
+ });
1866
+ }
1867
+ const payloadChunk = sanitizedChunk.length > MAX_LIVE_LOG_CHUNK_BYTES
1868
+ ? sanitizedChunk.slice(sanitizedChunk.length - MAX_LIVE_LOG_CHUNK_BYTES)
1869
+ : sanitizedChunk;
1870
+ publishLiveEvent({
1871
+ companyId: run.companyId,
1872
+ type: "heartbeat.run.log",
1873
+ payload: {
1874
+ runId: run.id,
1875
+ agentId: run.agentId,
1876
+ ts,
1877
+ stream,
1878
+ chunk: payloadChunk,
1879
+ truncated: payloadChunk.length !== sanitizedChunk.length,
1880
+ },
1881
+ });
1882
+ };
1883
+ for (const warning of runtimeWorkspaceWarnings) {
1884
+ const logEntry = formatRuntimeWorkspaceWarningLog(warning);
1885
+ await onLog(logEntry.stream, logEntry.chunk);
1886
+ }
1887
+ const adapterEnv = Object.fromEntries(Object.entries(parseObject(resolvedConfig.env)).filter((entry) => typeof entry[0] === "string" && typeof entry[1] === "string"));
1888
+ const runtimeServices = await ensureRuntimeServicesForRun({
1889
+ db,
1890
+ runId: run.id,
1891
+ agent: {
1892
+ id: agent.id,
1893
+ name: agent.name,
1894
+ companyId: agent.companyId,
1895
+ },
1896
+ issue: issueRef,
1897
+ workspace: executionWorkspace,
1898
+ executionWorkspaceId: persistedExecutionWorkspace?.id ?? issueRef?.executionWorkspaceId ?? null,
1899
+ config: resolvedConfig,
1900
+ adapterEnv,
1901
+ onLog,
1902
+ });
1903
+ if (runtimeServices.length > 0) {
1904
+ context.paperclipRuntimeServices = runtimeServices;
1905
+ context.paperclipRuntimePrimaryUrl =
1906
+ runtimeServices.find((service) => readNonEmptyString(service.url))?.url ?? null;
1907
+ await db
1908
+ .update(heartbeatRuns)
1909
+ .set({
1910
+ contextSnapshot: context,
1911
+ updatedAt: new Date(),
1912
+ })
1913
+ .where(eq(heartbeatRuns.id, run.id));
1914
+ }
1915
+ if (issueId && (executionWorkspace.created || runtimeServices.some((service) => !service.reused))) {
1916
+ try {
1917
+ await issuesSvc.addComment(issueId, buildWorkspaceReadyComment({
1918
+ workspace: executionWorkspace,
1919
+ runtimeServices,
1920
+ }), { agentId: agent.id });
1921
+ }
1922
+ catch (err) {
1923
+ await onLog("stderr", `[paperclip] Failed to post workspace-ready comment: ${err instanceof Error ? err.message : String(err)}\n`);
1924
+ }
1925
+ }
1926
+ const onAdapterMeta = async (meta) => {
1927
+ if (meta.env && secretKeys.size > 0) {
1928
+ for (const key of secretKeys) {
1929
+ if (key in meta.env)
1930
+ meta.env[key] = "***REDACTED***";
1931
+ }
1932
+ }
1933
+ await appendRunEvent(currentRun, seq++, {
1934
+ eventType: "adapter.invoke",
1935
+ stream: "system",
1936
+ level: "info",
1937
+ message: "adapter invocation",
1938
+ payload: meta,
1939
+ });
1940
+ };
1941
+ const adapter = getServerAdapter(agent.adapterType);
1942
+ const authToken = adapter.supportsLocalAgentJwt
1943
+ ? createLocalAgentJwt(agent.id, agent.companyId, agent.adapterType, run.id)
1944
+ : null;
1945
+ if (adapter.supportsLocalAgentJwt && !authToken) {
1946
+ logger.warn({
1947
+ companyId: agent.companyId,
1948
+ agentId: agent.id,
1949
+ runId: run.id,
1950
+ adapterType: agent.adapterType,
1951
+ }, "local agent jwt secret missing or invalid; running without injected PAPERCLIP_API_KEY");
1952
+ }
1953
+ const adapterResult = await adapter.execute({
1954
+ runId: run.id,
1955
+ agent,
1956
+ runtime: runtimeForAdapter,
1957
+ config: resolvedConfig,
1958
+ context,
1959
+ onLog,
1960
+ onMeta: onAdapterMeta,
1961
+ onSpawn: async (meta) => {
1962
+ await persistRunProcessMetadata(run.id, meta);
1963
+ },
1964
+ authToken: authToken ?? undefined,
1965
+ });
1966
+ const adapterManagedRuntimeServices = adapterResult.runtimeServices
1967
+ ? await persistAdapterManagedRuntimeServices({
1968
+ db,
1969
+ adapterType: agent.adapterType,
1970
+ runId: run.id,
1971
+ agent: {
1972
+ id: agent.id,
1973
+ name: agent.name,
1974
+ companyId: agent.companyId,
1975
+ },
1976
+ issue: issueRef,
1977
+ workspace: executionWorkspace,
1978
+ reports: adapterResult.runtimeServices,
1979
+ })
1980
+ : [];
1981
+ if (adapterManagedRuntimeServices.length > 0) {
1982
+ const combinedRuntimeServices = [
1983
+ ...runtimeServices,
1984
+ ...adapterManagedRuntimeServices,
1985
+ ];
1986
+ context.paperclipRuntimeServices = combinedRuntimeServices;
1987
+ context.paperclipRuntimePrimaryUrl =
1988
+ combinedRuntimeServices.find((service) => readNonEmptyString(service.url))?.url ?? null;
1989
+ await db
1990
+ .update(heartbeatRuns)
1991
+ .set({
1992
+ contextSnapshot: context,
1993
+ updatedAt: new Date(),
1994
+ })
1995
+ .where(eq(heartbeatRuns.id, run.id));
1996
+ if (issueId) {
1997
+ try {
1998
+ await issuesSvc.addComment(issueId, buildWorkspaceReadyComment({
1999
+ workspace: executionWorkspace,
2000
+ runtimeServices: adapterManagedRuntimeServices,
2001
+ }), { agentId: agent.id });
2002
+ }
2003
+ catch (err) {
2004
+ await onLog("stderr", `[paperclip] Failed to post adapter-managed runtime comment: ${err instanceof Error ? err.message : String(err)}\n`);
2005
+ }
2006
+ }
2007
+ }
2008
+ const nextSessionState = resolveNextSessionState({
2009
+ codec: sessionCodec,
2010
+ adapterResult,
2011
+ previousParams: previousSessionParams,
2012
+ previousDisplayId: runtimeForAdapter.sessionDisplayId,
2013
+ previousLegacySessionId: runtimeForAdapter.sessionId,
2014
+ });
2015
+ const rawUsage = normalizeUsageTotals(adapterResult.usage);
2016
+ const sessionUsageResolution = await resolveNormalizedUsageForSession({
2017
+ agentId: agent.id,
2018
+ runId: run.id,
2019
+ sessionId: nextSessionState.displayId ?? nextSessionState.legacySessionId,
2020
+ rawUsage,
2021
+ });
2022
+ const normalizedUsage = sessionUsageResolution.normalizedUsage;
2023
+ let outcome;
2024
+ const latestRun = await getRun(run.id);
2025
+ if (latestRun?.status === "cancelled") {
2026
+ outcome = "cancelled";
2027
+ }
2028
+ else if (adapterResult.timedOut) {
2029
+ outcome = "timed_out";
2030
+ }
2031
+ else if ((adapterResult.exitCode ?? 0) === 0 && !adapterResult.errorMessage) {
2032
+ outcome = "succeeded";
2033
+ }
2034
+ else {
2035
+ outcome = "failed";
2036
+ }
2037
+ let logSummary = null;
2038
+ if (handle) {
2039
+ logSummary = await runLogStore.finalize(handle);
2040
+ }
2041
+ const status = outcome === "succeeded"
2042
+ ? "succeeded"
2043
+ : outcome === "cancelled"
2044
+ ? "cancelled"
2045
+ : outcome === "timed_out"
2046
+ ? "timed_out"
2047
+ : "failed";
2048
+ const usageJson = normalizedUsage || adapterResult.costUsd != null
2049
+ ? {
2050
+ ...(normalizedUsage ?? {}),
2051
+ ...(rawUsage ? {
2052
+ rawInputTokens: rawUsage.inputTokens,
2053
+ rawCachedInputTokens: rawUsage.cachedInputTokens,
2054
+ rawOutputTokens: rawUsage.outputTokens,
2055
+ } : {}),
2056
+ ...(sessionUsageResolution.derivedFromSessionTotals ? { usageSource: "session_delta" } : {}),
2057
+ ...((nextSessionState.displayId ?? nextSessionState.legacySessionId)
2058
+ ? { persistedSessionId: nextSessionState.displayId ?? nextSessionState.legacySessionId }
2059
+ : {}),
2060
+ sessionReused: runtimeForAdapter.sessionId != null || runtimeForAdapter.sessionDisplayId != null,
2061
+ taskSessionReused: taskSessionForRun != null,
2062
+ freshSession: runtimeForAdapter.sessionId == null && runtimeForAdapter.sessionDisplayId == null,
2063
+ sessionRotated: sessionCompaction.rotate,
2064
+ sessionRotationReason: sessionCompaction.reason,
2065
+ provider: readNonEmptyString(adapterResult.provider) ?? "unknown",
2066
+ biller: resolveLedgerBiller(adapterResult),
2067
+ model: readNonEmptyString(adapterResult.model) ?? "unknown",
2068
+ ...(adapterResult.costUsd != null ? { costUsd: adapterResult.costUsd } : {}),
2069
+ billingType: normalizeLedgerBillingType(adapterResult.billingType),
2070
+ }
2071
+ : null;
2072
+ await setRunStatus(run.id, status, {
2073
+ finishedAt: new Date(),
2074
+ error: outcome === "succeeded"
2075
+ ? null
2076
+ : redactCurrentUserText(adapterResult.errorMessage ?? (outcome === "timed_out" ? "Timed out" : "Adapter failed")),
2077
+ errorCode: outcome === "timed_out"
2078
+ ? "timeout"
2079
+ : outcome === "cancelled"
2080
+ ? "cancelled"
2081
+ : outcome === "failed"
2082
+ ? (adapterResult.errorCode ?? "adapter_failed")
2083
+ : null,
2084
+ exitCode: adapterResult.exitCode,
2085
+ signal: adapterResult.signal,
2086
+ usageJson,
2087
+ resultJson: adapterResult.resultJson ?? null,
2088
+ sessionIdAfter: nextSessionState.displayId ?? nextSessionState.legacySessionId,
2089
+ stdoutExcerpt,
2090
+ stderrExcerpt,
2091
+ logBytes: logSummary?.bytes,
2092
+ logSha256: logSummary?.sha256,
2093
+ logCompressed: logSummary?.compressed ?? false,
2094
+ });
2095
+ await setWakeupStatus(run.wakeupRequestId, outcome === "succeeded" ? "completed" : status, {
2096
+ finishedAt: new Date(),
2097
+ error: adapterResult.errorMessage ?? null,
2098
+ });
2099
+ const finalizedRun = await getRun(run.id);
2100
+ if (finalizedRun) {
2101
+ await appendRunEvent(finalizedRun, seq++, {
2102
+ eventType: "lifecycle",
2103
+ stream: "system",
2104
+ level: outcome === "succeeded" ? "info" : "error",
2105
+ message: `run ${outcome}`,
2106
+ payload: {
2107
+ status,
2108
+ exitCode: adapterResult.exitCode,
2109
+ },
2110
+ });
2111
+ await releaseIssueExecutionAndPromote(finalizedRun);
2112
+ }
2113
+ if (finalizedRun) {
2114
+ await updateRuntimeState(agent, finalizedRun, adapterResult, {
2115
+ legacySessionId: nextSessionState.legacySessionId,
2116
+ }, normalizedUsage);
2117
+ if (taskKey) {
2118
+ if (adapterResult.clearSession || (!nextSessionState.params && !nextSessionState.displayId)) {
2119
+ await clearTaskSessions(agent.companyId, agent.id, {
2120
+ taskKey,
2121
+ adapterType: agent.adapterType,
2122
+ });
2123
+ }
2124
+ else {
2125
+ await upsertTaskSession({
2126
+ companyId: agent.companyId,
2127
+ agentId: agent.id,
2128
+ adapterType: agent.adapterType,
2129
+ taskKey,
2130
+ sessionParamsJson: nextSessionState.params,
2131
+ sessionDisplayId: nextSessionState.displayId,
2132
+ lastRunId: finalizedRun.id,
2133
+ lastError: outcome === "succeeded" ? null : (adapterResult.errorMessage ?? "run_failed"),
2134
+ });
2135
+ }
2136
+ }
2137
+ }
2138
+ await finalizeAgentStatus(agent.id, outcome);
2139
+ }
2140
+ catch (err) {
2141
+ const message = redactCurrentUserText(err instanceof Error ? err.message : "Unknown adapter failure");
2142
+ logger.error({ err, runId }, "heartbeat execution failed");
2143
+ let logSummary = null;
2144
+ if (handle) {
2145
+ try {
2146
+ logSummary = await runLogStore.finalize(handle);
2147
+ }
2148
+ catch (finalizeErr) {
2149
+ logger.warn({ err: finalizeErr, runId }, "failed to finalize run log after error");
2150
+ }
2151
+ }
2152
+ const failedRun = await setRunStatus(run.id, "failed", {
2153
+ error: message,
2154
+ errorCode: "adapter_failed",
2155
+ finishedAt: new Date(),
2156
+ stdoutExcerpt,
2157
+ stderrExcerpt,
2158
+ logBytes: logSummary?.bytes,
2159
+ logSha256: logSummary?.sha256,
2160
+ logCompressed: logSummary?.compressed ?? false,
2161
+ });
2162
+ await setWakeupStatus(run.wakeupRequestId, "failed", {
2163
+ finishedAt: new Date(),
2164
+ error: message,
2165
+ });
2166
+ if (failedRun) {
2167
+ await appendRunEvent(failedRun, seq++, {
2168
+ eventType: "error",
2169
+ stream: "system",
2170
+ level: "error",
2171
+ message,
2172
+ });
2173
+ await releaseIssueExecutionAndPromote(failedRun);
2174
+ await updateRuntimeState(agent, failedRun, {
2175
+ exitCode: null,
2176
+ signal: null,
2177
+ timedOut: false,
2178
+ errorMessage: message,
2179
+ }, {
2180
+ legacySessionId: runtimeForAdapter.sessionId,
2181
+ });
2182
+ if (taskKey && (previousSessionParams || previousSessionDisplayId || taskSession)) {
2183
+ await upsertTaskSession({
2184
+ companyId: agent.companyId,
2185
+ agentId: agent.id,
2186
+ adapterType: agent.adapterType,
2187
+ taskKey,
2188
+ sessionParamsJson: previousSessionParams,
2189
+ sessionDisplayId: previousSessionDisplayId,
2190
+ lastRunId: failedRun.id,
2191
+ lastError: message,
2192
+ });
2193
+ }
2194
+ }
2195
+ await finalizeAgentStatus(agent.id, "failed");
2196
+ }
2197
+ }
2198
+ catch (outerErr) {
2199
+ // Setup code before adapter.execute threw (e.g. ensureRuntimeState, resolveWorkspaceForRun).
2200
+ // The inner catch did not fire, so we must record the failure here.
2201
+ const message = outerErr instanceof Error ? outerErr.message : "Unknown setup failure";
2202
+ logger.error({ err: outerErr, runId }, "heartbeat execution setup failed");
2203
+ await setRunStatus(runId, "failed", {
2204
+ error: message,
2205
+ errorCode: "adapter_failed",
2206
+ finishedAt: new Date(),
2207
+ }).catch(() => undefined);
2208
+ await setWakeupStatus(run.wakeupRequestId, "failed", {
2209
+ finishedAt: new Date(),
2210
+ error: message,
2211
+ }).catch(() => undefined);
2212
+ const failedRun = await getRun(runId).catch(() => null);
2213
+ if (failedRun) {
2214
+ // Emit a run-log event so the failure is visible in the run timeline,
2215
+ // consistent with what the inner catch block does for adapter failures.
2216
+ await appendRunEvent(failedRun, 1, {
2217
+ eventType: "error",
2218
+ stream: "system",
2219
+ level: "error",
2220
+ message,
2221
+ }).catch(() => undefined);
2222
+ await releaseIssueExecutionAndPromote(failedRun).catch(() => undefined);
2223
+ }
2224
+ // Ensure the agent is not left stuck in "running" if the inner catch handler's
2225
+ // DB calls threw (e.g. a transient DB error in finalizeAgentStatus).
2226
+ await finalizeAgentStatus(run.agentId, "failed").catch(() => undefined);
2227
+ }
2228
+ finally {
2229
+ await releaseRuntimeServicesForRun(run.id).catch(() => undefined);
2230
+ activeRunExecutions.delete(run.id);
2231
+ await startNextQueuedRunForAgent(run.agentId);
2232
+ }
2233
+ }
2234
+ async function releaseIssueExecutionAndPromote(run) {
2235
+ const promotedRun = await db.transaction(async (tx) => {
2236
+ await tx.execute(sql `select id from issues where company_id = ${run.companyId} and execution_run_id = ${run.id} for update`);
2237
+ const issue = await tx
2238
+ .select({
2239
+ id: issues.id,
2240
+ companyId: issues.companyId,
2241
+ })
2242
+ .from(issues)
2243
+ .where(and(eq(issues.companyId, run.companyId), eq(issues.executionRunId, run.id)))
2244
+ .then((rows) => rows[0] ?? null);
2245
+ if (!issue)
2246
+ return;
2247
+ await tx
2248
+ .update(issues)
2249
+ .set({
2250
+ executionRunId: null,
2251
+ executionAgentNameKey: null,
2252
+ executionLockedAt: null,
2253
+ updatedAt: new Date(),
2254
+ })
2255
+ .where(eq(issues.id, issue.id));
2256
+ while (true) {
2257
+ const deferred = await tx
2258
+ .select()
2259
+ .from(agentWakeupRequests)
2260
+ .where(and(eq(agentWakeupRequests.companyId, issue.companyId), eq(agentWakeupRequests.status, "deferred_issue_execution"), sql `${agentWakeupRequests.payload} ->> 'issueId' = ${issue.id}`))
2261
+ .orderBy(asc(agentWakeupRequests.requestedAt))
2262
+ .limit(1)
2263
+ .then((rows) => rows[0] ?? null);
2264
+ if (!deferred)
2265
+ return null;
2266
+ const deferredAgent = await tx
2267
+ .select()
2268
+ .from(agents)
2269
+ .where(eq(agents.id, deferred.agentId))
2270
+ .then((rows) => rows[0] ?? null);
2271
+ if (!deferredAgent ||
2272
+ deferredAgent.companyId !== issue.companyId ||
2273
+ deferredAgent.status === "paused" ||
2274
+ deferredAgent.status === "terminated" ||
2275
+ deferredAgent.status === "pending_approval") {
2276
+ await tx
2277
+ .update(agentWakeupRequests)
2278
+ .set({
2279
+ status: "failed",
2280
+ finishedAt: new Date(),
2281
+ error: "Deferred wake could not be promoted: agent is not invokable",
2282
+ updatedAt: new Date(),
2283
+ })
2284
+ .where(eq(agentWakeupRequests.id, deferred.id));
2285
+ continue;
2286
+ }
2287
+ const deferredPayload = parseObject(deferred.payload);
2288
+ const deferredContextSeed = parseObject(deferredPayload[DEFERRED_WAKE_CONTEXT_KEY]);
2289
+ const promotedContextSeed = { ...deferredContextSeed };
2290
+ const promotedReason = readNonEmptyString(deferred.reason) ?? "issue_execution_promoted";
2291
+ const promotedSource = readNonEmptyString(deferred.source) ?? "automation";
2292
+ const promotedTriggerDetail = readNonEmptyString(deferred.triggerDetail) ?? null;
2293
+ const promotedPayload = deferredPayload;
2294
+ delete promotedPayload[DEFERRED_WAKE_CONTEXT_KEY];
2295
+ const { contextSnapshot: promotedContextSnapshot, taskKey: promotedTaskKey, } = enrichWakeContextSnapshot({
2296
+ contextSnapshot: promotedContextSeed,
2297
+ reason: promotedReason,
2298
+ source: promotedSource,
2299
+ triggerDetail: promotedTriggerDetail,
2300
+ payload: promotedPayload,
2301
+ });
2302
+ const sessionBefore = await resolveSessionBeforeForWakeup(deferredAgent, promotedTaskKey);
2303
+ const now = new Date();
2304
+ const newRun = await tx
2305
+ .insert(heartbeatRuns)
2306
+ .values({
2307
+ companyId: deferredAgent.companyId,
2308
+ agentId: deferredAgent.id,
2309
+ invocationSource: promotedSource,
2310
+ triggerDetail: promotedTriggerDetail,
2311
+ status: "queued",
2312
+ wakeupRequestId: deferred.id,
2313
+ contextSnapshot: promotedContextSnapshot,
2314
+ sessionIdBefore: sessionBefore,
2315
+ })
2316
+ .returning()
2317
+ .then((rows) => rows[0]);
2318
+ await tx
2319
+ .update(agentWakeupRequests)
2320
+ .set({
2321
+ status: "queued",
2322
+ reason: "issue_execution_promoted",
2323
+ runId: newRun.id,
2324
+ claimedAt: null,
2325
+ finishedAt: null,
2326
+ error: null,
2327
+ updatedAt: now,
2328
+ })
2329
+ .where(eq(agentWakeupRequests.id, deferred.id));
2330
+ await tx
2331
+ .update(issues)
2332
+ .set({
2333
+ executionRunId: newRun.id,
2334
+ executionAgentNameKey: normalizeAgentNameKey(deferredAgent.name),
2335
+ executionLockedAt: now,
2336
+ updatedAt: now,
2337
+ })
2338
+ .where(eq(issues.id, issue.id));
2339
+ return newRun;
2340
+ }
2341
+ });
2342
+ if (!promotedRun)
2343
+ return;
2344
+ publishLiveEvent({
2345
+ companyId: promotedRun.companyId,
2346
+ type: "heartbeat.run.queued",
2347
+ payload: {
2348
+ runId: promotedRun.id,
2349
+ agentId: promotedRun.agentId,
2350
+ invocationSource: promotedRun.invocationSource,
2351
+ triggerDetail: promotedRun.triggerDetail,
2352
+ wakeupRequestId: promotedRun.wakeupRequestId,
2353
+ },
2354
+ });
2355
+ await startNextQueuedRunForAgent(promotedRun.agentId);
2356
+ }
2357
+ async function enqueueWakeup(agentId, opts = {}) {
2358
+ const source = opts.source ?? "on_demand";
2359
+ const triggerDetail = opts.triggerDetail ?? null;
2360
+ const contextSnapshot = { ...(opts.contextSnapshot ?? {}) };
2361
+ const reason = opts.reason ?? null;
2362
+ const payload = opts.payload ?? null;
2363
+ const { contextSnapshot: enrichedContextSnapshot, issueIdFromPayload, taskKey, wakeCommentId, } = enrichWakeContextSnapshot({
2364
+ contextSnapshot,
2365
+ reason,
2366
+ source,
2367
+ triggerDetail,
2368
+ payload,
2369
+ });
2370
+ const issueId = readNonEmptyString(enrichedContextSnapshot.issueId) ?? issueIdFromPayload;
2371
+ const agent = await getAgent(agentId);
2372
+ if (!agent)
2373
+ throw notFound("Agent not found");
2374
+ const writeSkippedRequest = async (skipReason) => {
2375
+ await db.insert(agentWakeupRequests).values({
2376
+ companyId: agent.companyId,
2377
+ agentId,
2378
+ source,
2379
+ triggerDetail,
2380
+ reason: skipReason,
2381
+ payload,
2382
+ status: "skipped",
2383
+ requestedByActorType: opts.requestedByActorType ?? null,
2384
+ requestedByActorId: opts.requestedByActorId ?? null,
2385
+ idempotencyKey: opts.idempotencyKey ?? null,
2386
+ finishedAt: new Date(),
2387
+ });
2388
+ };
2389
+ let projectId = readNonEmptyString(enrichedContextSnapshot.projectId);
2390
+ if (!projectId && issueId) {
2391
+ projectId = await db
2392
+ .select({ projectId: issues.projectId })
2393
+ .from(issues)
2394
+ .where(and(eq(issues.id, issueId), eq(issues.companyId, agent.companyId)))
2395
+ .then((rows) => rows[0]?.projectId ?? null);
2396
+ }
2397
+ const budgetBlock = await budgets.getInvocationBlock(agent.companyId, agentId, {
2398
+ issueId,
2399
+ projectId,
2400
+ });
2401
+ if (budgetBlock) {
2402
+ await writeSkippedRequest("budget.blocked");
2403
+ throw conflict(budgetBlock.reason, {
2404
+ scopeType: budgetBlock.scopeType,
2405
+ scopeId: budgetBlock.scopeId,
2406
+ });
2407
+ }
2408
+ if (agent.status === "paused" ||
2409
+ agent.status === "terminated" ||
2410
+ agent.status === "pending_approval") {
2411
+ throw conflict("Agent is not invokable in its current state", { status: agent.status });
2412
+ }
2413
+ const policy = parseHeartbeatPolicy(agent);
2414
+ if (source === "timer" && !policy.enabled) {
2415
+ await writeSkippedRequest("heartbeat.disabled");
2416
+ return null;
2417
+ }
2418
+ if (source === "assignment" && !policy.wakeOnAssignment) {
2419
+ await writeSkippedRequest("heartbeat.wakeOnAssignment.disabled");
2420
+ return null;
2421
+ }
2422
+ if (source === "automation" && !policy.wakeOnAutomation) {
2423
+ await writeSkippedRequest("heartbeat.wakeOnAutomation.disabled");
2424
+ return null;
2425
+ }
2426
+ if (source === "on_demand" && !policy.wakeOnDemand) {
2427
+ await writeSkippedRequest("heartbeat.wakeOnDemand.disabled");
2428
+ return null;
2429
+ }
2430
+ const bypassIssueExecutionLock = reason === "issue_comment_mentioned" ||
2431
+ readNonEmptyString(enrichedContextSnapshot.wakeReason) === "issue_comment_mentioned";
2432
+ if (issueId && !bypassIssueExecutionLock) {
2433
+ const agentNameKey = normalizeAgentNameKey(agent.name);
2434
+ const sessionBefore = await resolveSessionBeforeForWakeup(agent, taskKey);
2435
+ const outcome = await db.transaction(async (tx) => {
2436
+ await tx.execute(sql `select id from issues where id = ${issueId} and company_id = ${agent.companyId} for update`);
2437
+ const issue = await tx
2438
+ .select({
2439
+ id: issues.id,
2440
+ companyId: issues.companyId,
2441
+ executionRunId: issues.executionRunId,
2442
+ executionAgentNameKey: issues.executionAgentNameKey,
2443
+ })
2444
+ .from(issues)
2445
+ .where(and(eq(issues.id, issueId), eq(issues.companyId, agent.companyId)))
2446
+ .then((rows) => rows[0] ?? null);
2447
+ if (!issue) {
2448
+ await tx.insert(agentWakeupRequests).values({
2449
+ companyId: agent.companyId,
2450
+ agentId,
2451
+ source,
2452
+ triggerDetail,
2453
+ reason: "issue_execution_issue_not_found",
2454
+ payload,
2455
+ status: "skipped",
2456
+ requestedByActorType: opts.requestedByActorType ?? null,
2457
+ requestedByActorId: opts.requestedByActorId ?? null,
2458
+ idempotencyKey: opts.idempotencyKey ?? null,
2459
+ finishedAt: new Date(),
2460
+ });
2461
+ return { kind: "skipped" };
2462
+ }
2463
+ let activeExecutionRun = issue.executionRunId
2464
+ ? await tx
2465
+ .select()
2466
+ .from(heartbeatRuns)
2467
+ .where(eq(heartbeatRuns.id, issue.executionRunId))
2468
+ .then((rows) => rows[0] ?? null)
2469
+ : null;
2470
+ if (activeExecutionRun && activeExecutionRun.status !== "queued" && activeExecutionRun.status !== "running") {
2471
+ activeExecutionRun = null;
2472
+ }
2473
+ if (!activeExecutionRun && issue.executionRunId) {
2474
+ await tx
2475
+ .update(issues)
2476
+ .set({
2477
+ executionRunId: null,
2478
+ executionAgentNameKey: null,
2479
+ executionLockedAt: null,
2480
+ updatedAt: new Date(),
2481
+ })
2482
+ .where(eq(issues.id, issue.id));
2483
+ }
2484
+ if (!activeExecutionRun) {
2485
+ const legacyRun = await tx
2486
+ .select()
2487
+ .from(heartbeatRuns)
2488
+ .where(and(eq(heartbeatRuns.companyId, issue.companyId), inArray(heartbeatRuns.status, ["queued", "running"]), sql `${heartbeatRuns.contextSnapshot} ->> 'issueId' = ${issue.id}`))
2489
+ .orderBy(sql `case when ${heartbeatRuns.status} = 'running' then 0 else 1 end`, asc(heartbeatRuns.createdAt))
2490
+ .limit(1)
2491
+ .then((rows) => rows[0] ?? null);
2492
+ if (legacyRun) {
2493
+ activeExecutionRun = legacyRun;
2494
+ const legacyAgent = await tx
2495
+ .select({ name: agents.name })
2496
+ .from(agents)
2497
+ .where(eq(agents.id, legacyRun.agentId))
2498
+ .then((rows) => rows[0] ?? null);
2499
+ await tx
2500
+ .update(issues)
2501
+ .set({
2502
+ executionRunId: legacyRun.id,
2503
+ executionAgentNameKey: normalizeAgentNameKey(legacyAgent?.name),
2504
+ executionLockedAt: new Date(),
2505
+ updatedAt: new Date(),
2506
+ })
2507
+ .where(eq(issues.id, issue.id));
2508
+ }
2509
+ }
2510
+ if (activeExecutionRun) {
2511
+ const executionAgent = await tx
2512
+ .select({ name: agents.name })
2513
+ .from(agents)
2514
+ .where(eq(agents.id, activeExecutionRun.agentId))
2515
+ .then((rows) => rows[0] ?? null);
2516
+ const executionAgentNameKey = normalizeAgentNameKey(issue.executionAgentNameKey) ??
2517
+ normalizeAgentNameKey(executionAgent?.name);
2518
+ const isSameExecutionAgent = Boolean(executionAgentNameKey) && executionAgentNameKey === agentNameKey;
2519
+ const shouldQueueFollowupForCommentWake = Boolean(wakeCommentId) &&
2520
+ activeExecutionRun.status === "running" &&
2521
+ isSameExecutionAgent;
2522
+ if (isSameExecutionAgent && !shouldQueueFollowupForCommentWake) {
2523
+ const mergedContextSnapshot = mergeCoalescedContextSnapshot(activeExecutionRun.contextSnapshot, enrichedContextSnapshot);
2524
+ const mergedRun = await tx
2525
+ .update(heartbeatRuns)
2526
+ .set({
2527
+ contextSnapshot: mergedContextSnapshot,
2528
+ updatedAt: new Date(),
2529
+ })
2530
+ .where(eq(heartbeatRuns.id, activeExecutionRun.id))
2531
+ .returning()
2532
+ .then((rows) => rows[0] ?? activeExecutionRun);
2533
+ await tx.insert(agentWakeupRequests).values({
2534
+ companyId: agent.companyId,
2535
+ agentId,
2536
+ source,
2537
+ triggerDetail,
2538
+ reason: "issue_execution_same_name",
2539
+ payload,
2540
+ status: "coalesced",
2541
+ coalescedCount: 1,
2542
+ requestedByActorType: opts.requestedByActorType ?? null,
2543
+ requestedByActorId: opts.requestedByActorId ?? null,
2544
+ idempotencyKey: opts.idempotencyKey ?? null,
2545
+ runId: mergedRun.id,
2546
+ finishedAt: new Date(),
2547
+ });
2548
+ return { kind: "coalesced", run: mergedRun };
2549
+ }
2550
+ const deferredPayload = {
2551
+ ...(payload ?? {}),
2552
+ issueId,
2553
+ [DEFERRED_WAKE_CONTEXT_KEY]: enrichedContextSnapshot,
2554
+ };
2555
+ const existingDeferred = await tx
2556
+ .select()
2557
+ .from(agentWakeupRequests)
2558
+ .where(and(eq(agentWakeupRequests.companyId, agent.companyId), eq(agentWakeupRequests.agentId, agentId), eq(agentWakeupRequests.status, "deferred_issue_execution"), sql `${agentWakeupRequests.payload} ->> 'issueId' = ${issue.id}`))
2559
+ .orderBy(asc(agentWakeupRequests.requestedAt))
2560
+ .limit(1)
2561
+ .then((rows) => rows[0] ?? null);
2562
+ if (existingDeferred) {
2563
+ const existingDeferredPayload = parseObject(existingDeferred.payload);
2564
+ const existingDeferredContext = parseObject(existingDeferredPayload[DEFERRED_WAKE_CONTEXT_KEY]);
2565
+ const mergedDeferredContext = mergeCoalescedContextSnapshot(existingDeferredContext, enrichedContextSnapshot);
2566
+ const mergedDeferredPayload = {
2567
+ ...existingDeferredPayload,
2568
+ ...(payload ?? {}),
2569
+ issueId,
2570
+ [DEFERRED_WAKE_CONTEXT_KEY]: mergedDeferredContext,
2571
+ };
2572
+ await tx
2573
+ .update(agentWakeupRequests)
2574
+ .set({
2575
+ payload: mergedDeferredPayload,
2576
+ coalescedCount: (existingDeferred.coalescedCount ?? 0) + 1,
2577
+ updatedAt: new Date(),
2578
+ })
2579
+ .where(eq(agentWakeupRequests.id, existingDeferred.id));
2580
+ return { kind: "deferred" };
2581
+ }
2582
+ await tx.insert(agentWakeupRequests).values({
2583
+ companyId: agent.companyId,
2584
+ agentId,
2585
+ source,
2586
+ triggerDetail,
2587
+ reason: "issue_execution_deferred",
2588
+ payload: deferredPayload,
2589
+ status: "deferred_issue_execution",
2590
+ requestedByActorType: opts.requestedByActorType ?? null,
2591
+ requestedByActorId: opts.requestedByActorId ?? null,
2592
+ idempotencyKey: opts.idempotencyKey ?? null,
2593
+ });
2594
+ return { kind: "deferred" };
2595
+ }
2596
+ const wakeupRequest = await tx
2597
+ .insert(agentWakeupRequests)
2598
+ .values({
2599
+ companyId: agent.companyId,
2600
+ agentId,
2601
+ source,
2602
+ triggerDetail,
2603
+ reason,
2604
+ payload,
2605
+ status: "queued",
2606
+ requestedByActorType: opts.requestedByActorType ?? null,
2607
+ requestedByActorId: opts.requestedByActorId ?? null,
2608
+ idempotencyKey: opts.idempotencyKey ?? null,
2609
+ })
2610
+ .returning()
2611
+ .then((rows) => rows[0]);
2612
+ const newRun = await tx
2613
+ .insert(heartbeatRuns)
2614
+ .values({
2615
+ companyId: agent.companyId,
2616
+ agentId,
2617
+ invocationSource: source,
2618
+ triggerDetail,
2619
+ status: "queued",
2620
+ wakeupRequestId: wakeupRequest.id,
2621
+ contextSnapshot: enrichedContextSnapshot,
2622
+ sessionIdBefore: sessionBefore,
2623
+ })
2624
+ .returning()
2625
+ .then((rows) => rows[0]);
2626
+ await tx
2627
+ .update(agentWakeupRequests)
2628
+ .set({
2629
+ runId: newRun.id,
2630
+ updatedAt: new Date(),
2631
+ })
2632
+ .where(eq(agentWakeupRequests.id, wakeupRequest.id));
2633
+ await tx
2634
+ .update(issues)
2635
+ .set({
2636
+ executionRunId: newRun.id,
2637
+ executionAgentNameKey: agentNameKey,
2638
+ executionLockedAt: new Date(),
2639
+ updatedAt: new Date(),
2640
+ })
2641
+ .where(eq(issues.id, issue.id));
2642
+ return { kind: "queued", run: newRun };
2643
+ });
2644
+ if (outcome.kind === "deferred" || outcome.kind === "skipped")
2645
+ return null;
2646
+ if (outcome.kind === "coalesced")
2647
+ return outcome.run;
2648
+ const newRun = outcome.run;
2649
+ publishLiveEvent({
2650
+ companyId: newRun.companyId,
2651
+ type: "heartbeat.run.queued",
2652
+ payload: {
2653
+ runId: newRun.id,
2654
+ agentId: newRun.agentId,
2655
+ invocationSource: newRun.invocationSource,
2656
+ triggerDetail: newRun.triggerDetail,
2657
+ wakeupRequestId: newRun.wakeupRequestId,
2658
+ },
2659
+ });
2660
+ await startNextQueuedRunForAgent(agent.id);
2661
+ return newRun;
2662
+ }
2663
+ const activeRuns = await db
2664
+ .select()
2665
+ .from(heartbeatRuns)
2666
+ .where(and(eq(heartbeatRuns.agentId, agentId), inArray(heartbeatRuns.status, ["queued", "running"])))
2667
+ .orderBy(desc(heartbeatRuns.createdAt));
2668
+ const sameScopeQueuedRun = activeRuns.find((candidate) => candidate.status === "queued" && isSameTaskScope(runTaskKey(candidate), taskKey));
2669
+ const sameScopeRunningRun = activeRuns.find((candidate) => candidate.status === "running" && isSameTaskScope(runTaskKey(candidate), taskKey));
2670
+ const shouldQueueFollowupForCommentWake = Boolean(wakeCommentId) && Boolean(sameScopeRunningRun) && !sameScopeQueuedRun;
2671
+ const coalescedTargetRun = sameScopeQueuedRun ??
2672
+ (shouldQueueFollowupForCommentWake ? null : sameScopeRunningRun ?? null);
2673
+ if (coalescedTargetRun) {
2674
+ const mergedContextSnapshot = mergeCoalescedContextSnapshot(coalescedTargetRun.contextSnapshot, contextSnapshot);
2675
+ const mergedRun = await db
2676
+ .update(heartbeatRuns)
2677
+ .set({
2678
+ contextSnapshot: mergedContextSnapshot,
2679
+ updatedAt: new Date(),
2680
+ })
2681
+ .where(eq(heartbeatRuns.id, coalescedTargetRun.id))
2682
+ .returning()
2683
+ .then((rows) => rows[0] ?? coalescedTargetRun);
2684
+ await db.insert(agentWakeupRequests).values({
2685
+ companyId: agent.companyId,
2686
+ agentId,
2687
+ source,
2688
+ triggerDetail,
2689
+ reason,
2690
+ payload,
2691
+ status: "coalesced",
2692
+ coalescedCount: 1,
2693
+ requestedByActorType: opts.requestedByActorType ?? null,
2694
+ requestedByActorId: opts.requestedByActorId ?? null,
2695
+ idempotencyKey: opts.idempotencyKey ?? null,
2696
+ runId: mergedRun.id,
2697
+ finishedAt: new Date(),
2698
+ });
2699
+ return mergedRun;
2700
+ }
2701
+ const wakeupRequest = await db
2702
+ .insert(agentWakeupRequests)
2703
+ .values({
2704
+ companyId: agent.companyId,
2705
+ agentId,
2706
+ source,
2707
+ triggerDetail,
2708
+ reason,
2709
+ payload,
2710
+ status: "queued",
2711
+ requestedByActorType: opts.requestedByActorType ?? null,
2712
+ requestedByActorId: opts.requestedByActorId ?? null,
2713
+ idempotencyKey: opts.idempotencyKey ?? null,
2714
+ })
2715
+ .returning()
2716
+ .then((rows) => rows[0]);
2717
+ const sessionBefore = await resolveSessionBeforeForWakeup(agent, taskKey);
2718
+ const newRun = await db
2719
+ .insert(heartbeatRuns)
2720
+ .values({
2721
+ companyId: agent.companyId,
2722
+ agentId,
2723
+ invocationSource: source,
2724
+ triggerDetail,
2725
+ status: "queued",
2726
+ wakeupRequestId: wakeupRequest.id,
2727
+ contextSnapshot: enrichedContextSnapshot,
2728
+ sessionIdBefore: sessionBefore,
2729
+ })
2730
+ .returning()
2731
+ .then((rows) => rows[0]);
2732
+ await db
2733
+ .update(agentWakeupRequests)
2734
+ .set({
2735
+ runId: newRun.id,
2736
+ updatedAt: new Date(),
2737
+ })
2738
+ .where(eq(agentWakeupRequests.id, wakeupRequest.id));
2739
+ publishLiveEvent({
2740
+ companyId: newRun.companyId,
2741
+ type: "heartbeat.run.queued",
2742
+ payload: {
2743
+ runId: newRun.id,
2744
+ agentId: newRun.agentId,
2745
+ invocationSource: newRun.invocationSource,
2746
+ triggerDetail: newRun.triggerDetail,
2747
+ wakeupRequestId: newRun.wakeupRequestId,
2748
+ },
2749
+ });
2750
+ await startNextQueuedRunForAgent(agent.id);
2751
+ return newRun;
2752
+ }
2753
+ async function listProjectScopedRunIds(companyId, projectId) {
2754
+ const runIssueId = sql `${heartbeatRuns.contextSnapshot} ->> 'issueId'`;
2755
+ const effectiveProjectId = sql `coalesce(${heartbeatRuns.contextSnapshot} ->> 'projectId', ${issues.projectId}::text)`;
2756
+ const rows = await db
2757
+ .selectDistinctOn([heartbeatRuns.id], { id: heartbeatRuns.id })
2758
+ .from(heartbeatRuns)
2759
+ .leftJoin(issues, and(eq(issues.companyId, companyId), sql `${issues.id}::text = ${runIssueId}`))
2760
+ .where(and(eq(heartbeatRuns.companyId, companyId), inArray(heartbeatRuns.status, ["queued", "running"]), sql `${effectiveProjectId} = ${projectId}`));
2761
+ return rows.map((row) => row.id);
2762
+ }
2763
+ async function listProjectScopedWakeupIds(companyId, projectId) {
2764
+ const wakeIssueId = sql `${agentWakeupRequests.payload} ->> 'issueId'`;
2765
+ const effectiveProjectId = sql `coalesce(${agentWakeupRequests.payload} ->> 'projectId', ${issues.projectId}::text)`;
2766
+ const rows = await db
2767
+ .selectDistinctOn([agentWakeupRequests.id], { id: agentWakeupRequests.id })
2768
+ .from(agentWakeupRequests)
2769
+ .leftJoin(issues, and(eq(issues.companyId, companyId), sql `${issues.id}::text = ${wakeIssueId}`))
2770
+ .where(and(eq(agentWakeupRequests.companyId, companyId), inArray(agentWakeupRequests.status, ["queued", "deferred_issue_execution"]), sql `${agentWakeupRequests.runId} is null`, sql `${effectiveProjectId} = ${projectId}`));
2771
+ return rows.map((row) => row.id);
2772
+ }
2773
+ async function cancelPendingWakeupsForBudgetScope(scope) {
2774
+ const now = new Date();
2775
+ let wakeupIds = [];
2776
+ if (scope.scopeType === "company") {
2777
+ wakeupIds = await db
2778
+ .select({ id: agentWakeupRequests.id })
2779
+ .from(agentWakeupRequests)
2780
+ .where(and(eq(agentWakeupRequests.companyId, scope.companyId), inArray(agentWakeupRequests.status, ["queued", "deferred_issue_execution"]), sql `${agentWakeupRequests.runId} is null`))
2781
+ .then((rows) => rows.map((row) => row.id));
2782
+ }
2783
+ else if (scope.scopeType === "agent") {
2784
+ wakeupIds = await db
2785
+ .select({ id: agentWakeupRequests.id })
2786
+ .from(agentWakeupRequests)
2787
+ .where(and(eq(agentWakeupRequests.companyId, scope.companyId), eq(agentWakeupRequests.agentId, scope.scopeId), inArray(agentWakeupRequests.status, ["queued", "deferred_issue_execution"]), sql `${agentWakeupRequests.runId} is null`))
2788
+ .then((rows) => rows.map((row) => row.id));
2789
+ }
2790
+ else {
2791
+ wakeupIds = await listProjectScopedWakeupIds(scope.companyId, scope.scopeId);
2792
+ }
2793
+ if (wakeupIds.length === 0)
2794
+ return 0;
2795
+ await db
2796
+ .update(agentWakeupRequests)
2797
+ .set({
2798
+ status: "cancelled",
2799
+ finishedAt: now,
2800
+ error: "Cancelled due to budget pause",
2801
+ updatedAt: now,
2802
+ })
2803
+ .where(inArray(agentWakeupRequests.id, wakeupIds));
2804
+ return wakeupIds.length;
2805
+ }
2806
+ async function cancelRunInternal(runId, reason = "Cancelled by control plane") {
2807
+ const run = await getRun(runId);
2808
+ if (!run)
2809
+ throw notFound("Heartbeat run not found");
2810
+ if (run.status !== "running" && run.status !== "queued")
2811
+ return run;
2812
+ const running = runningProcesses.get(run.id);
2813
+ if (running) {
2814
+ running.child.kill("SIGTERM");
2815
+ const graceMs = Math.max(1, running.graceSec) * 1000;
2816
+ setTimeout(() => {
2817
+ if (!running.child.killed) {
2818
+ running.child.kill("SIGKILL");
2819
+ }
2820
+ }, graceMs);
2821
+ }
2822
+ const cancelled = await setRunStatus(run.id, "cancelled", {
2823
+ finishedAt: new Date(),
2824
+ error: reason,
2825
+ errorCode: "cancelled",
2826
+ });
2827
+ await setWakeupStatus(run.wakeupRequestId, "cancelled", {
2828
+ finishedAt: new Date(),
2829
+ error: reason,
2830
+ });
2831
+ if (cancelled) {
2832
+ await appendRunEvent(cancelled, 1, {
2833
+ eventType: "lifecycle",
2834
+ stream: "system",
2835
+ level: "warn",
2836
+ message: "run cancelled",
2837
+ });
2838
+ await releaseIssueExecutionAndPromote(cancelled);
2839
+ }
2840
+ runningProcesses.delete(run.id);
2841
+ await finalizeAgentStatus(run.agentId, "cancelled");
2842
+ await startNextQueuedRunForAgent(run.agentId);
2843
+ return cancelled;
2844
+ }
2845
+ async function cancelActiveForAgentInternal(agentId, reason = "Cancelled due to agent pause") {
2846
+ const runs = await db
2847
+ .select()
2848
+ .from(heartbeatRuns)
2849
+ .where(and(eq(heartbeatRuns.agentId, agentId), inArray(heartbeatRuns.status, ["queued", "running"])));
2850
+ for (const run of runs) {
2851
+ await setRunStatus(run.id, "cancelled", {
2852
+ finishedAt: new Date(),
2853
+ error: reason,
2854
+ errorCode: "cancelled",
2855
+ });
2856
+ await setWakeupStatus(run.wakeupRequestId, "cancelled", {
2857
+ finishedAt: new Date(),
2858
+ error: reason,
2859
+ });
2860
+ const running = runningProcesses.get(run.id);
2861
+ if (running) {
2862
+ running.child.kill("SIGTERM");
2863
+ runningProcesses.delete(run.id);
2864
+ }
2865
+ await releaseIssueExecutionAndPromote(run);
2866
+ }
2867
+ return runs.length;
2868
+ }
2869
+ async function cancelBudgetScopeWork(scope) {
2870
+ if (scope.scopeType === "agent") {
2871
+ await cancelActiveForAgentInternal(scope.scopeId, "Cancelled due to budget pause");
2872
+ await cancelPendingWakeupsForBudgetScope(scope);
2873
+ return;
2874
+ }
2875
+ const runIds = scope.scopeType === "company"
2876
+ ? await db
2877
+ .select({ id: heartbeatRuns.id })
2878
+ .from(heartbeatRuns)
2879
+ .where(and(eq(heartbeatRuns.companyId, scope.companyId), inArray(heartbeatRuns.status, ["queued", "running"])))
2880
+ .then((rows) => rows.map((row) => row.id))
2881
+ : await listProjectScopedRunIds(scope.companyId, scope.scopeId);
2882
+ for (const runId of runIds) {
2883
+ await cancelRunInternal(runId, "Cancelled due to budget pause");
2884
+ }
2885
+ await cancelPendingWakeupsForBudgetScope(scope);
2886
+ }
2887
+ return {
2888
+ list: async (companyId, agentId, limit) => {
2889
+ const query = db
2890
+ .select(heartbeatRunListColumns)
2891
+ .from(heartbeatRuns)
2892
+ .where(agentId
2893
+ ? and(eq(heartbeatRuns.companyId, companyId), eq(heartbeatRuns.agentId, agentId))
2894
+ : eq(heartbeatRuns.companyId, companyId))
2895
+ .orderBy(desc(heartbeatRuns.createdAt));
2896
+ const rows = limit ? await query.limit(limit) : await query;
2897
+ return rows.map((row) => ({
2898
+ ...row,
2899
+ resultJson: summarizeHeartbeatRunResultJson(row.resultJson),
2900
+ }));
2901
+ },
2902
+ getRun,
2903
+ getRuntimeState: async (agentId) => {
2904
+ const state = await getRuntimeState(agentId);
2905
+ const agent = await getAgent(agentId);
2906
+ if (!agent)
2907
+ return null;
2908
+ const ensured = state ?? (await ensureRuntimeState(agent));
2909
+ const latestTaskSession = await db
2910
+ .select()
2911
+ .from(agentTaskSessions)
2912
+ .where(and(eq(agentTaskSessions.companyId, agent.companyId), eq(agentTaskSessions.agentId, agent.id)))
2913
+ .orderBy(desc(agentTaskSessions.updatedAt))
2914
+ .limit(1)
2915
+ .then((rows) => rows[0] ?? null);
2916
+ return {
2917
+ ...ensured,
2918
+ sessionDisplayId: latestTaskSession?.sessionDisplayId ?? ensured.sessionId,
2919
+ sessionParamsJson: latestTaskSession?.sessionParamsJson ?? null,
2920
+ };
2921
+ },
2922
+ listTaskSessions: async (agentId) => {
2923
+ const agent = await getAgent(agentId);
2924
+ if (!agent)
2925
+ throw notFound("Agent not found");
2926
+ return db
2927
+ .select()
2928
+ .from(agentTaskSessions)
2929
+ .where(and(eq(agentTaskSessions.companyId, agent.companyId), eq(agentTaskSessions.agentId, agentId)))
2930
+ .orderBy(desc(agentTaskSessions.updatedAt), desc(agentTaskSessions.createdAt));
2931
+ },
2932
+ resetRuntimeSession: async (agentId, opts) => {
2933
+ const agent = await getAgent(agentId);
2934
+ if (!agent)
2935
+ throw notFound("Agent not found");
2936
+ await ensureRuntimeState(agent);
2937
+ const taskKey = readNonEmptyString(opts?.taskKey);
2938
+ const clearedTaskSessions = await clearTaskSessions(agent.companyId, agent.id, taskKey ? { taskKey, adapterType: agent.adapterType } : undefined);
2939
+ const runtimePatch = {
2940
+ sessionId: null,
2941
+ lastError: null,
2942
+ updatedAt: new Date(),
2943
+ };
2944
+ if (!taskKey) {
2945
+ runtimePatch.stateJson = {};
2946
+ }
2947
+ const updated = await db
2948
+ .update(agentRuntimeState)
2949
+ .set(runtimePatch)
2950
+ .where(eq(agentRuntimeState.agentId, agentId))
2951
+ .returning()
2952
+ .then((rows) => rows[0] ?? null);
2953
+ if (!updated)
2954
+ return null;
2955
+ return {
2956
+ ...updated,
2957
+ sessionDisplayId: null,
2958
+ sessionParamsJson: null,
2959
+ clearedTaskSessions,
2960
+ };
2961
+ },
2962
+ listEvents: (runId, afterSeq = 0, limit = 200) => db
2963
+ .select()
2964
+ .from(heartbeatRunEvents)
2965
+ .where(and(eq(heartbeatRunEvents.runId, runId), gt(heartbeatRunEvents.seq, afterSeq)))
2966
+ .orderBy(asc(heartbeatRunEvents.seq))
2967
+ .limit(Math.max(1, Math.min(limit, 1000))),
2968
+ readLog: async (runId, opts) => {
2969
+ const run = await getRun(runId);
2970
+ if (!run)
2971
+ throw notFound("Heartbeat run not found");
2972
+ if (!run.logStore || !run.logRef)
2973
+ throw notFound("Run log not found");
2974
+ const result = await runLogStore.read({
2975
+ store: run.logStore,
2976
+ logRef: run.logRef,
2977
+ }, opts);
2978
+ return {
2979
+ runId,
2980
+ store: run.logStore,
2981
+ logRef: run.logRef,
2982
+ ...result,
2983
+ content: redactCurrentUserText(result.content),
2984
+ };
2985
+ },
2986
+ invoke: async (agentId, source = "on_demand", contextSnapshot = {}, triggerDetail = "manual", actor) => enqueueWakeup(agentId, {
2987
+ source,
2988
+ triggerDetail,
2989
+ contextSnapshot,
2990
+ requestedByActorType: actor?.actorType,
2991
+ requestedByActorId: actor?.actorId ?? null,
2992
+ }),
2993
+ wakeup: enqueueWakeup,
2994
+ reportRunActivity: clearDetachedRunWarning,
2995
+ reapOrphanedRuns,
2996
+ resumeQueuedRuns,
2997
+ tickTimers: async (now = new Date()) => {
2998
+ const allAgents = await db.select().from(agents);
2999
+ let checked = 0;
3000
+ let enqueued = 0;
3001
+ let skipped = 0;
3002
+ for (const agent of allAgents) {
3003
+ if (agent.status === "paused" || agent.status === "terminated" || agent.status === "pending_approval")
3004
+ continue;
3005
+ const policy = parseHeartbeatPolicy(agent);
3006
+ if (!policy.enabled || policy.intervalSec <= 0)
3007
+ continue;
3008
+ checked += 1;
3009
+ const baseline = new Date(agent.lastHeartbeatAt ?? agent.createdAt).getTime();
3010
+ const elapsedMs = now.getTime() - baseline;
3011
+ if (elapsedMs < policy.intervalSec * 1000)
3012
+ continue;
3013
+ const run = await enqueueWakeup(agent.id, {
3014
+ source: "timer",
3015
+ triggerDetail: "system",
3016
+ reason: "heartbeat_timer",
3017
+ requestedByActorType: "system",
3018
+ requestedByActorId: "heartbeat_scheduler",
3019
+ contextSnapshot: {
3020
+ source: "scheduler",
3021
+ reason: "interval_elapsed",
3022
+ now: now.toISOString(),
3023
+ },
3024
+ });
3025
+ if (run)
3026
+ enqueued += 1;
3027
+ else
3028
+ skipped += 1;
3029
+ }
3030
+ return { checked, enqueued, skipped };
3031
+ },
3032
+ cancelRun: (runId) => cancelRunInternal(runId),
3033
+ cancelActiveForAgent: (agentId) => cancelActiveForAgentInternal(agentId),
3034
+ cancelBudgetScopeWork,
3035
+ getActiveRunForAgent: async (agentId) => {
3036
+ const [run] = await db
3037
+ .select()
3038
+ .from(heartbeatRuns)
3039
+ .where(and(eq(heartbeatRuns.agentId, agentId), eq(heartbeatRuns.status, "running")))
3040
+ .orderBy(desc(heartbeatRuns.startedAt))
3041
+ .limit(1);
3042
+ return run ?? null;
3043
+ },
3044
+ };
3045
+ }
3046
+ //# sourceMappingURL=heartbeat.js.map