@rulemetric/cli 0.7.3 → 0.7.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (550) hide show
  1. package/README.md +10 -8
  2. package/dist/base-command.js +1 -14
  3. package/dist/chunk-2JRDG4LJ.js +31 -0
  4. package/dist/chunk-2TC6WCUT.js +34 -0
  5. package/dist/chunk-2WLVDSAP.js +2 -0
  6. package/dist/chunk-32EEBARV.js +1 -0
  7. package/dist/chunk-3AV3GTMP.js +1 -0
  8. package/dist/chunk-43YBXX7R.js +1 -0
  9. package/dist/chunk-4Z5ECCJE.js +1 -0
  10. package/dist/chunk-5RBLIVBF.js +1 -0
  11. package/dist/chunk-67QCYUJU.js +1 -0
  12. package/dist/chunk-6QKI756T.js +2 -0
  13. package/dist/chunk-6V4WM73L.js +1 -0
  14. package/dist/chunk-6XEC6474.js +1 -0
  15. package/dist/chunk-7DFNBRLY.js +61 -0
  16. package/dist/chunk-ARNZQBMX.js +1 -0
  17. package/dist/chunk-AYUJY37O.js +5 -0
  18. package/dist/chunk-CADKBP3D.js +58 -0
  19. package/dist/chunk-CDI5CCHU.js +1 -0
  20. package/dist/chunk-CNQ5DTNC.js +1 -0
  21. package/dist/chunk-DCLWFGEA.js +1 -0
  22. package/dist/chunk-DNF4HDI6.js +14 -0
  23. package/dist/chunk-DPFNJZUO.js +1 -0
  24. package/dist/chunk-DSO2U4Y6.js +56 -0
  25. package/dist/chunk-DVN7GFJG.js +1 -0
  26. package/dist/chunk-G63KMH6U.js +1 -0
  27. package/dist/chunk-G6XGDHGC.js +2 -0
  28. package/dist/chunk-GBMF3TP6.js +1 -0
  29. package/dist/chunk-GY5IJ4RS.js +1 -0
  30. package/dist/chunk-H2ORWIEY.js +1 -0
  31. package/dist/chunk-H4SV7FN4.js +1 -0
  32. package/dist/chunk-HS7X43XE.js +24 -0
  33. package/dist/{chunk-OQBBVTDG.js → chunk-I2DZGJRR.js} +6 -71
  34. package/dist/chunk-IZTIYR5Q.js +2 -0
  35. package/dist/chunk-JAPCCEKF.js +3 -0
  36. package/dist/chunk-JQTGQXUX.js +1 -0
  37. package/dist/chunk-KAF3CYRW.js +9 -0
  38. package/dist/chunk-KKDHD4XA.js +2 -0
  39. package/dist/chunk-KV325CXF.js +33 -0
  40. package/dist/chunk-MGHFDHHM.js +1 -0
  41. package/dist/chunk-MODXEGCU.js +1 -0
  42. package/dist/chunk-MVM6OGAF.js +4 -0
  43. package/dist/chunk-N7ODX6PO.js +1 -0
  44. package/dist/chunk-N7TGRFVZ.js +70 -0
  45. package/dist/chunk-NBTC5FNV.js +1 -0
  46. package/dist/chunk-NEACEHQD.js +1 -0
  47. package/dist/chunk-NJ5UED3H.js +1 -0
  48. package/dist/chunk-NVKX36YN.js +3 -0
  49. package/dist/chunk-O2SDD2WW.js +1 -0
  50. package/dist/chunk-O6C2UGBY.js +7 -0
  51. package/dist/chunk-OMXUK4M6.js +1 -0
  52. package/dist/chunk-PPKPCXJD.js +4 -0
  53. package/dist/{chunk-XZXS2W24.js → chunk-QFVGUZDO.js} +11 -57
  54. package/dist/chunk-RDET7CKR.js +1 -0
  55. package/dist/chunk-RQ424GI6.js +5 -0
  56. package/dist/chunk-RSKQRVPJ.js +1 -0
  57. package/dist/chunk-RTWRHIKY.js +7 -0
  58. package/dist/chunk-SZ62CP55.js +1 -0
  59. package/dist/chunk-TDD7IOV2.js +1 -0
  60. package/dist/chunk-TIOKY2IA.js +1 -0
  61. package/dist/chunk-TQMG647B.js +15 -0
  62. package/dist/chunk-TU2AR6XO.js +1 -0
  63. package/dist/chunk-U6ABMRT3.js +9 -0
  64. package/dist/chunk-U6XEU573.js +1 -0
  65. package/dist/chunk-UF6US7VU.js +1 -0
  66. package/dist/chunk-V44SRRYR.js +1 -0
  67. package/dist/chunk-V5U3E4BZ.js +1 -0
  68. package/dist/chunk-VAXRCSSH.js +2 -0
  69. package/dist/chunk-VLOX6KOM.js +1 -0
  70. package/dist/chunk-VUGRXM7R.js +1 -0
  71. package/dist/chunk-W2MOTOQE.js +1 -0
  72. package/dist/chunk-W2MV25SB.js +1 -0
  73. package/dist/chunk-WLVQJH4E.js +1 -0
  74. package/dist/chunk-WSCK4WNK.js +1 -0
  75. package/dist/chunk-XICLXXRH.js +1 -0
  76. package/dist/chunk-XXDZJ6YI.js +1 -0
  77. package/dist/chunk-ZL4MZMUK.js +34 -0
  78. package/dist/chunk-ZLLER3HP.js +1 -0
  79. package/dist/chunk-ZR3MUNLS.js +1 -0
  80. package/dist/chunk-ZXF5NE54.js +1 -0
  81. package/dist/commands/antigravity/backfill.js +2 -136
  82. package/dist/commands/auth/create-key.js +1 -52
  83. package/dist/commands/auth/login.js +1 -85
  84. package/dist/commands/auth/logout.js +1 -29
  85. package/dist/commands/auth/revoke-key.js +4 -33
  86. package/dist/commands/auth/signup.js +1 -89
  87. package/dist/commands/auth/status.js +1 -42
  88. package/dist/commands/catalog/index.js +2 -52
  89. package/dist/commands/catalog/recommend.js +3 -43
  90. package/dist/commands/convert.js +1 -75
  91. package/dist/commands/converters.js +1 -54
  92. package/dist/commands/crons/list.js +1 -41
  93. package/dist/commands/crons/run.js +2 -76
  94. package/dist/commands/dashboard.js +1 -46
  95. package/dist/commands/diagnostics.js +1 -117
  96. package/dist/commands/eval-targets/create.js +1 -53
  97. package/dist/commands/eval-targets/list.js +1 -54
  98. package/dist/commands/evals/agent.js +3 -310
  99. package/dist/commands/evals/benchmark.js +6 -73
  100. package/dist/commands/evals/compare.js +13 -96
  101. package/dist/commands/evals/create.js +1 -67
  102. package/dist/commands/evals/optimize-description.js +25 -239
  103. package/dist/commands/evals/optimize.js +5 -211
  104. package/dist/commands/evals/run.js +3 -183
  105. package/dist/commands/gateway/ensure.js +1 -104
  106. package/dist/commands/hooks/emit-instructions.js +1 -25
  107. package/dist/commands/hooks/install.js +1 -442
  108. package/dist/commands/hooks/run.js +3 -81
  109. package/dist/commands/hooks/uninstall.js +2 -156
  110. package/dist/commands/import.js +1 -66
  111. package/dist/commands/instructions/create.js +1 -74
  112. package/dist/commands/instructions/delete.js +1 -55
  113. package/dist/commands/instructions/fork.js +1 -34
  114. package/dist/commands/instructions/get.js +1 -68
  115. package/dist/commands/instructions/list.js +1 -65
  116. package/dist/commands/instructions/promote.js +1 -42
  117. package/dist/commands/instructions/pull.js +1 -39
  118. package/dist/commands/instructions/upstream.js +1 -38
  119. package/dist/commands/instructions/versions.js +1 -53
  120. package/dist/commands/launcher.js +1 -40
  121. package/dist/commands/org/current.js +1 -77
  122. package/dist/commands/org/list.js +1 -52
  123. package/dist/commands/org/switch.js +1 -71
  124. package/dist/commands/packs/add-instruction.js +1 -37
  125. package/dist/commands/packs/apply.js +1 -39
  126. package/dist/commands/packs/create.js +1 -50
  127. package/dist/commands/packs/fork.js +1 -34
  128. package/dist/commands/packs/get.js +3 -56
  129. package/dist/commands/packs/list.js +1 -66
  130. package/dist/commands/packs/remove-instruction.js +1 -35
  131. package/dist/commands/proxy/env.js +3 -131
  132. package/dist/commands/proxy/logs.js +3 -85
  133. package/dist/commands/proxy/restart.js +1 -35
  134. package/dist/commands/proxy/setup.js +17 -454
  135. package/dist/commands/proxy/start.js +10 -333
  136. package/dist/commands/proxy/status.js +1 -78
  137. package/dist/commands/proxy/stop.js +1 -94
  138. package/dist/commands/research/backfill.js +1 -59
  139. package/dist/commands/research/tail-transcript.js +1 -70
  140. package/dist/commands/service/install.js +57 -796
  141. package/dist/commands/service/status.js +1 -180
  142. package/dist/commands/service/uninstall.js +1 -119
  143. package/dist/commands/sessions/analyze.js +1 -48
  144. package/dist/commands/sessions/end.js +2 -85
  145. package/dist/commands/sessions/import.js +1 -46
  146. package/dist/commands/sessions/list.js +1 -48
  147. package/dist/commands/sessions/start.js +3 -90
  148. package/dist/commands/setup.js +3 -150
  149. package/dist/commands/skills/export-approved.js +1 -46
  150. package/dist/commands/skills/install.js +4 -107
  151. package/dist/commands/skills/list.js +4 -65
  152. package/dist/commands/skills/publish.js +2 -98
  153. package/dist/commands/skills/search.js +3 -72
  154. package/dist/commands/skills/update.js +3 -55
  155. package/dist/commands/suggestions/accept.js +8 -84
  156. package/dist/commands/suggestions/dismiss.js +1 -45
  157. package/dist/commands/suggestions/list.js +2 -61
  158. package/dist/commands/suggestions/refresh.js +1 -27
  159. package/dist/cursor-T7AMCMKS.js +13 -0
  160. package/dist/dashboard/Dashboard.js +1 -243
  161. package/dist/dashboard/data.js +1 -15
  162. package/dist/dashboard/launcher/ActiveJobsList.js +1 -10
  163. package/dist/dashboard/launcher/LauncherOverlay.js +1 -16
  164. package/dist/dashboard/launcher/NewLaunchForm.js +1 -10
  165. package/dist/dashboard/launcher/api.js +1 -16
  166. package/dist/dashboard/launcher/tool-labels.js +1 -10
  167. package/dist/dashboard/launcher/types.js +0 -1
  168. package/dist/dashboard/launcher/useLaunchJobs.js +1 -11
  169. package/dist/dashboard/panels/friction.js +1 -10
  170. package/dist/dashboard/panels/insights.js +1 -10
  171. package/dist/dashboard/panels/instructions.js +1 -10
  172. package/dist/dashboard/panels/outcomes.js +1 -10
  173. package/dist/dashboard/panels/overview.js +1 -10
  174. package/dist/dashboard/panels/shared.js +1 -19
  175. package/dist/dashboard/types.js +1 -24
  176. package/dist/dist-FAVALJ5C.js +1 -0
  177. package/dist/index.js +1 -8
  178. package/dist/lib/active-org-refresh.js +1 -15
  179. package/dist/lib/active-org.js +1 -16
  180. package/dist/lib/agent-loop.js +1 -47
  181. package/dist/lib/antigravity-transcript.js +1 -22
  182. package/dist/lib/api-client.js +1 -23
  183. package/dist/lib/auth.js +1 -30
  184. package/dist/lib/capture-hosts.js +1 -8
  185. package/dist/lib/detect-languages.js +1 -8
  186. package/dist/lib/detect-tmux.js +1 -9
  187. package/dist/lib/diagnostics.js +1 -12
  188. package/dist/lib/editor-proxy-pins.js +1 -14
  189. package/dist/lib/ensure-api-key.js +1 -11
  190. package/dist/lib/ensure-fresh-token.js +1 -0
  191. package/dist/lib/eval-analyzer.js +1 -9
  192. package/dist/lib/eval-benchmark.js +1 -12
  193. package/dist/lib/eval-conversation-handler.js +1 -13
  194. package/dist/lib/eval-executor.js +1 -8
  195. package/dist/lib/eval-grader.js +1 -9
  196. package/dist/lib/eval-meta-judge.js +1 -9
  197. package/dist/lib/eval-trigger-tester.js +1 -11
  198. package/dist/lib/eval-worktree.js +1 -8
  199. package/dist/lib/gateway-entry.js +1 -61
  200. package/dist/lib/gateway-identity.js +1 -16
  201. package/dist/lib/gateway-lifecycle.js +1 -32
  202. package/dist/lib/gateway.js +1 -14
  203. package/dist/lib/handlers/cron-refresh-pricing.js +1 -0
  204. package/dist/lib/handlers/cron-refresh-skills.js +1 -8
  205. package/dist/lib/handlers/cron-suggest-instructions.js +1 -16
  206. package/dist/lib/handlers/process-announcement.js +1 -11
  207. package/dist/lib/handlers/process-changelog.js +1 -11
  208. package/dist/lib/handlers/process-conversation.js +1 -14
  209. package/dist/lib/handlers/process-eval.js +1 -15
  210. package/dist/lib/handlers/process-insights.js +1 -15
  211. package/dist/lib/handlers/process-launch.js +1 -16
  212. package/dist/lib/handlers/process-run-cleanup.js +1 -13
  213. package/dist/lib/handlers/process-send-message.js +1 -10
  214. package/dist/lib/handlers/process-session-goal.js +1 -12
  215. package/dist/lib/hooks-config.js +1 -81
  216. package/dist/lib/insights-prompts.js +1 -12
  217. package/dist/lib/instruction-snapshot.js +1 -8
  218. package/dist/lib/job-helpers.js +0 -1
  219. package/dist/lib/llm-client.js +1 -20
  220. package/dist/lib/manual-tasks-meta.js +1 -8
  221. package/dist/lib/manual-tasks.js +1 -80
  222. package/dist/lib/output.js +1 -12
  223. package/dist/lib/permanent-job-error.js +1 -10
  224. package/dist/lib/pid-identity.js +1 -14
  225. package/dist/lib/proxy-respawn.js +1 -12
  226. package/dist/lib/research-client.js +1 -12
  227. package/dist/lib/setup-steps.js +1 -33
  228. package/dist/lib/skills-loader.js +1 -8
  229. package/dist/lib/statusline-shim.js +1 -20
  230. package/dist/lib/telemetry.js +1 -16
  231. package/dist/lib/terminal-target-heartbeat.js +1 -15
  232. package/dist/lib/tmux.js +1 -16
  233. package/dist/lib/transcript-rate-limit-watcher.js +1 -22
  234. package/dist/lib/types.js +1 -8
  235. package/dist/lib/version-check.js +1 -12
  236. package/dist/lib/which.js +1 -8
  237. package/dist/lib/worktree.js +1 -17
  238. package/dist/opencode-QRJ3BH23.js +1 -0
  239. package/oclif.manifest.json +12 -34
  240. package/package.json +9 -8
  241. package/dist/base-command.js.map +0 -7
  242. package/dist/chunk-2HK7RGZB.js +0 -82
  243. package/dist/chunk-2HK7RGZB.js.map +0 -7
  244. package/dist/chunk-2ORJWTNZ.js +0 -307
  245. package/dist/chunk-2ORJWTNZ.js.map +0 -7
  246. package/dist/chunk-37LN5O7M.js +0 -59
  247. package/dist/chunk-37LN5O7M.js.map +0 -7
  248. package/dist/chunk-3S7223UR.js +0 -81
  249. package/dist/chunk-3S7223UR.js.map +0 -7
  250. package/dist/chunk-3TIMQ3O6.js +0 -96
  251. package/dist/chunk-3TIMQ3O6.js.map +0 -7
  252. package/dist/chunk-42GFSAJP.js +0 -32
  253. package/dist/chunk-42GFSAJP.js.map +0 -7
  254. package/dist/chunk-4BHDHHKL.js +0 -48
  255. package/dist/chunk-4BHDHHKL.js.map +0 -7
  256. package/dist/chunk-4D537GXE.js +0 -99
  257. package/dist/chunk-4D537GXE.js.map +0 -7
  258. package/dist/chunk-4LYCDS2N.js +0 -139
  259. package/dist/chunk-4LYCDS2N.js.map +0 -7
  260. package/dist/chunk-4SCZK7AL.js +0 -129
  261. package/dist/chunk-4SCZK7AL.js.map +0 -7
  262. package/dist/chunk-4XAWK6S2.js +0 -161
  263. package/dist/chunk-4XAWK6S2.js.map +0 -7
  264. package/dist/chunk-52WIYRZH.js +0 -73
  265. package/dist/chunk-52WIYRZH.js.map +0 -7
  266. package/dist/chunk-5BAOGNUH.js +0 -79
  267. package/dist/chunk-5BAOGNUH.js.map +0 -7
  268. package/dist/chunk-5EDMGK3W.js +0 -39
  269. package/dist/chunk-5EDMGK3W.js.map +0 -7
  270. package/dist/chunk-6NBS5XFS.js +0 -99
  271. package/dist/chunk-6NBS5XFS.js.map +0 -7
  272. package/dist/chunk-7LVVKQMZ.js +0 -98
  273. package/dist/chunk-7LVVKQMZ.js.map +0 -7
  274. package/dist/chunk-7NNFYWKK.js +0 -243
  275. package/dist/chunk-7NNFYWKK.js.map +0 -7
  276. package/dist/chunk-7NYKWN7U.js +0 -12
  277. package/dist/chunk-7NYKWN7U.js.map +0 -7
  278. package/dist/chunk-BO76WKJR.js +0 -42
  279. package/dist/chunk-BO76WKJR.js.map +0 -7
  280. package/dist/chunk-BRD5RUGM.js +0 -53
  281. package/dist/chunk-BRD5RUGM.js.map +0 -7
  282. package/dist/chunk-BT6Z6545.js +0 -43
  283. package/dist/chunk-BT6Z6545.js.map +0 -7
  284. package/dist/chunk-BZDKEQKU.js +0 -39
  285. package/dist/chunk-BZDKEQKU.js.map +0 -7
  286. package/dist/chunk-DGHWRQXL.js +0 -17
  287. package/dist/chunk-DGHWRQXL.js.map +0 -7
  288. package/dist/chunk-DIQUV5FR.js +0 -257
  289. package/dist/chunk-DIQUV5FR.js.map +0 -7
  290. package/dist/chunk-DMX5YOTM.js +0 -167
  291. package/dist/chunk-DMX5YOTM.js.map +0 -7
  292. package/dist/chunk-DNKSVWMD.js +0 -108
  293. package/dist/chunk-DNKSVWMD.js.map +0 -7
  294. package/dist/chunk-DQ3KELXD.js +0 -74
  295. package/dist/chunk-DQ3KELXD.js.map +0 -7
  296. package/dist/chunk-DUJSRBLP.js +0 -122
  297. package/dist/chunk-DUJSRBLP.js.map +0 -7
  298. package/dist/chunk-E3BIT53W.js +0 -154
  299. package/dist/chunk-E3BIT53W.js.map +0 -7
  300. package/dist/chunk-EARWG4EV.js +0 -22
  301. package/dist/chunk-EARWG4EV.js.map +0 -7
  302. package/dist/chunk-EI5BHWXA.js +0 -1662
  303. package/dist/chunk-EI5BHWXA.js.map +0 -7
  304. package/dist/chunk-EJ3YAFDP.js +0 -37
  305. package/dist/chunk-EJ3YAFDP.js.map +0 -7
  306. package/dist/chunk-EKJ2CABV.js +0 -76
  307. package/dist/chunk-EKJ2CABV.js.map +0 -7
  308. package/dist/chunk-EKP32DLN.js +0 -16
  309. package/dist/chunk-EKP32DLN.js.map +0 -7
  310. package/dist/chunk-EYPAAGN5.js +0 -51
  311. package/dist/chunk-EYPAAGN5.js.map +0 -7
  312. package/dist/chunk-F5N6CLJJ.js +0 -1995
  313. package/dist/chunk-F5N6CLJJ.js.map +0 -7
  314. package/dist/chunk-GIUBARWS.js +0 -99
  315. package/dist/chunk-GIUBARWS.js.map +0 -7
  316. package/dist/chunk-GQNJO2P2.js +0 -102
  317. package/dist/chunk-GQNJO2P2.js.map +0 -7
  318. package/dist/chunk-IJGF2ETG.js +0 -68
  319. package/dist/chunk-IJGF2ETG.js.map +0 -7
  320. package/dist/chunk-ILYDELUE.js +0 -46
  321. package/dist/chunk-ILYDELUE.js.map +0 -7
  322. package/dist/chunk-J6QFW4LD.js +0 -55
  323. package/dist/chunk-J6QFW4LD.js.map +0 -7
  324. package/dist/chunk-J7N3DLH6.js +0 -117
  325. package/dist/chunk-J7N3DLH6.js.map +0 -7
  326. package/dist/chunk-JFDWKLQC.js +0 -23
  327. package/dist/chunk-JFDWKLQC.js.map +0 -7
  328. package/dist/chunk-JULOLTZS.js +0 -61
  329. package/dist/chunk-JULOLTZS.js.map +0 -7
  330. package/dist/chunk-KJKBDQ4D.js +0 -220
  331. package/dist/chunk-KJKBDQ4D.js.map +0 -7
  332. package/dist/chunk-KRBQLMOP.js +0 -41
  333. package/dist/chunk-KRBQLMOP.js.map +0 -7
  334. package/dist/chunk-LXKPNATC.js +0 -624
  335. package/dist/chunk-LXKPNATC.js.map +0 -7
  336. package/dist/chunk-NSBPE2FW.js +0 -17
  337. package/dist/chunk-NSBPE2FW.js.map +0 -7
  338. package/dist/chunk-OCKHW72U.js +0 -55
  339. package/dist/chunk-OCKHW72U.js.map +0 -7
  340. package/dist/chunk-OKWCKCPE.js +0 -414
  341. package/dist/chunk-OKWCKCPE.js.map +0 -7
  342. package/dist/chunk-OO7JDFS4.js +0 -157
  343. package/dist/chunk-OO7JDFS4.js.map +0 -7
  344. package/dist/chunk-OQBBVTDG.js.map +0 -7
  345. package/dist/chunk-OQSQC7VB.js +0 -77
  346. package/dist/chunk-OQSQC7VB.js.map +0 -7
  347. package/dist/chunk-PED7L5GX.js +0 -92
  348. package/dist/chunk-PED7L5GX.js.map +0 -7
  349. package/dist/chunk-QJQS6TUN.js +0 -44
  350. package/dist/chunk-QJQS6TUN.js.map +0 -7
  351. package/dist/chunk-QN34TGD3.js +0 -83
  352. package/dist/chunk-QN34TGD3.js.map +0 -7
  353. package/dist/chunk-QSN77T7C.js +0 -250
  354. package/dist/chunk-QSN77T7C.js.map +0 -7
  355. package/dist/chunk-R56PH7YE.js +0 -78
  356. package/dist/chunk-R56PH7YE.js.map +0 -7
  357. package/dist/chunk-RAXRZYOB.js +0 -299
  358. package/dist/chunk-RAXRZYOB.js.map +0 -7
  359. package/dist/chunk-RH7NHVSK.js +0 -16
  360. package/dist/chunk-RH7NHVSK.js.map +0 -7
  361. package/dist/chunk-RMTT4KDY.js +0 -191
  362. package/dist/chunk-RMTT4KDY.js.map +0 -7
  363. package/dist/chunk-RQ2TMLKG.js +0 -142
  364. package/dist/chunk-RQ2TMLKG.js.map +0 -7
  365. package/dist/chunk-SO3T35U7.js +0 -80
  366. package/dist/chunk-SO3T35U7.js.map +0 -7
  367. package/dist/chunk-UKMLICWS.js +0 -51
  368. package/dist/chunk-UKMLICWS.js.map +0 -7
  369. package/dist/chunk-VA5FFOS7.js +0 -243
  370. package/dist/chunk-VA5FFOS7.js.map +0 -7
  371. package/dist/chunk-W2YERO7E.js +0 -170
  372. package/dist/chunk-W2YERO7E.js.map +0 -7
  373. package/dist/chunk-W53GKIZQ.js +0 -50
  374. package/dist/chunk-W53GKIZQ.js.map +0 -7
  375. package/dist/chunk-WA4MWYRW.js +0 -254
  376. package/dist/chunk-WA4MWYRW.js.map +0 -7
  377. package/dist/chunk-XC6M4CSW.js +0 -44
  378. package/dist/chunk-XC6M4CSW.js.map +0 -7
  379. package/dist/chunk-XK42ZBDE.js +0 -23
  380. package/dist/chunk-XK42ZBDE.js.map +0 -7
  381. package/dist/chunk-XUV6DDBF.js +0 -124
  382. package/dist/chunk-XUV6DDBF.js.map +0 -7
  383. package/dist/chunk-XZXS2W24.js.map +0 -7
  384. package/dist/chunk-Y3WD5CSW.js +0 -49
  385. package/dist/chunk-Y3WD5CSW.js.map +0 -7
  386. package/dist/chunk-Y4BJXXYV.js +0 -148
  387. package/dist/chunk-Y4BJXXYV.js.map +0 -7
  388. package/dist/chunk-YNIH3KMU.js +0 -121
  389. package/dist/chunk-YNIH3KMU.js.map +0 -7
  390. package/dist/chunk-ZUJBM6HE.js +0 -125
  391. package/dist/chunk-ZUJBM6HE.js.map +0 -7
  392. package/dist/commands/antigravity/backfill.js.map +0 -7
  393. package/dist/commands/auth/create-key.js.map +0 -7
  394. package/dist/commands/auth/login.js.map +0 -7
  395. package/dist/commands/auth/logout.js.map +0 -7
  396. package/dist/commands/auth/revoke-key.js.map +0 -7
  397. package/dist/commands/auth/signup.js.map +0 -7
  398. package/dist/commands/auth/status.js.map +0 -7
  399. package/dist/commands/catalog/index.js.map +0 -7
  400. package/dist/commands/catalog/recommend.js.map +0 -7
  401. package/dist/commands/convert.js.map +0 -7
  402. package/dist/commands/converters.js.map +0 -7
  403. package/dist/commands/crons/list.js.map +0 -7
  404. package/dist/commands/crons/run.js.map +0 -7
  405. package/dist/commands/dashboard.js.map +0 -7
  406. package/dist/commands/diagnostics.js.map +0 -7
  407. package/dist/commands/eval-targets/create.js.map +0 -7
  408. package/dist/commands/eval-targets/list.js.map +0 -7
  409. package/dist/commands/evals/agent.js.map +0 -7
  410. package/dist/commands/evals/benchmark.js.map +0 -7
  411. package/dist/commands/evals/compare.js.map +0 -7
  412. package/dist/commands/evals/create.js.map +0 -7
  413. package/dist/commands/evals/optimize-description.js.map +0 -7
  414. package/dist/commands/evals/optimize.js.map +0 -7
  415. package/dist/commands/evals/run.js.map +0 -7
  416. package/dist/commands/gateway/ensure.js.map +0 -7
  417. package/dist/commands/hooks/emit-instructions.js.map +0 -7
  418. package/dist/commands/hooks/install.js.map +0 -7
  419. package/dist/commands/hooks/run.js.map +0 -7
  420. package/dist/commands/hooks/uninstall.js.map +0 -7
  421. package/dist/commands/import.js.map +0 -7
  422. package/dist/commands/instructions/create.js.map +0 -7
  423. package/dist/commands/instructions/delete.js.map +0 -7
  424. package/dist/commands/instructions/fork.js.map +0 -7
  425. package/dist/commands/instructions/get.js.map +0 -7
  426. package/dist/commands/instructions/list.js.map +0 -7
  427. package/dist/commands/instructions/promote.js.map +0 -7
  428. package/dist/commands/instructions/pull.js.map +0 -7
  429. package/dist/commands/instructions/upstream.js.map +0 -7
  430. package/dist/commands/instructions/versions.js.map +0 -7
  431. package/dist/commands/launcher.js.map +0 -7
  432. package/dist/commands/org/current.js.map +0 -7
  433. package/dist/commands/org/list.js.map +0 -7
  434. package/dist/commands/org/switch.js.map +0 -7
  435. package/dist/commands/packs/add-instruction.js.map +0 -7
  436. package/dist/commands/packs/apply.js.map +0 -7
  437. package/dist/commands/packs/create.js.map +0 -7
  438. package/dist/commands/packs/fork.js.map +0 -7
  439. package/dist/commands/packs/get.js.map +0 -7
  440. package/dist/commands/packs/list.js.map +0 -7
  441. package/dist/commands/packs/remove-instruction.js.map +0 -7
  442. package/dist/commands/proxy/env.js.map +0 -7
  443. package/dist/commands/proxy/logs.js.map +0 -7
  444. package/dist/commands/proxy/restart.js.map +0 -7
  445. package/dist/commands/proxy/setup.js.map +0 -7
  446. package/dist/commands/proxy/start.js.map +0 -7
  447. package/dist/commands/proxy/status.js.map +0 -7
  448. package/dist/commands/proxy/stop.js.map +0 -7
  449. package/dist/commands/research/backfill.js.map +0 -7
  450. package/dist/commands/research/tail-transcript.js.map +0 -7
  451. package/dist/commands/service/install.js.map +0 -7
  452. package/dist/commands/service/status.js.map +0 -7
  453. package/dist/commands/service/uninstall.js.map +0 -7
  454. package/dist/commands/sessions/analyze.js.map +0 -7
  455. package/dist/commands/sessions/end.js.map +0 -7
  456. package/dist/commands/sessions/import.js.map +0 -7
  457. package/dist/commands/sessions/list.js.map +0 -7
  458. package/dist/commands/sessions/start.js.map +0 -7
  459. package/dist/commands/setup.js.map +0 -7
  460. package/dist/commands/skills/export-approved.js.map +0 -7
  461. package/dist/commands/skills/install.js.map +0 -7
  462. package/dist/commands/skills/list.js.map +0 -7
  463. package/dist/commands/skills/publish.js.map +0 -7
  464. package/dist/commands/skills/search.js.map +0 -7
  465. package/dist/commands/skills/update.js.map +0 -7
  466. package/dist/commands/suggestions/accept.js.map +0 -7
  467. package/dist/commands/suggestions/dismiss.js.map +0 -7
  468. package/dist/commands/suggestions/list.js.map +0 -7
  469. package/dist/commands/suggestions/refresh.js.map +0 -7
  470. package/dist/cursor-BGQJ4CWI.js +0 -134
  471. package/dist/cursor-BGQJ4CWI.js.map +0 -7
  472. package/dist/dashboard/Dashboard.js.map +0 -7
  473. package/dist/dashboard/data.js.map +0 -7
  474. package/dist/dashboard/launcher/ActiveJobsList.js.map +0 -7
  475. package/dist/dashboard/launcher/LauncherOverlay.js.map +0 -7
  476. package/dist/dashboard/launcher/NewLaunchForm.js.map +0 -7
  477. package/dist/dashboard/launcher/api.js.map +0 -7
  478. package/dist/dashboard/launcher/tool-labels.js.map +0 -7
  479. package/dist/dashboard/launcher/types.js.map +0 -7
  480. package/dist/dashboard/launcher/useLaunchJobs.js.map +0 -7
  481. package/dist/dashboard/panels/friction.js.map +0 -7
  482. package/dist/dashboard/panels/insights.js.map +0 -7
  483. package/dist/dashboard/panels/instructions.js.map +0 -7
  484. package/dist/dashboard/panels/outcomes.js.map +0 -7
  485. package/dist/dashboard/panels/overview.js.map +0 -7
  486. package/dist/dashboard/panels/shared.js.map +0 -7
  487. package/dist/dashboard/types.js.map +0 -7
  488. package/dist/dist-UNYP5PJR.js +0 -56
  489. package/dist/dist-UNYP5PJR.js.map +0 -7
  490. package/dist/index.js.map +0 -7
  491. package/dist/lib/active-org-refresh.js.map +0 -7
  492. package/dist/lib/active-org.js.map +0 -7
  493. package/dist/lib/agent-loop.js.map +0 -7
  494. package/dist/lib/antigravity-transcript.js.map +0 -7
  495. package/dist/lib/api-client.js.map +0 -7
  496. package/dist/lib/auth.js.map +0 -7
  497. package/dist/lib/capture-hosts.js.map +0 -7
  498. package/dist/lib/detect-languages.js.map +0 -7
  499. package/dist/lib/detect-tmux.js.map +0 -7
  500. package/dist/lib/diagnostics.js.map +0 -7
  501. package/dist/lib/editor-proxy-pins.js.map +0 -7
  502. package/dist/lib/ensure-api-key.js.map +0 -7
  503. package/dist/lib/eval-analyzer.js.map +0 -7
  504. package/dist/lib/eval-benchmark.js.map +0 -7
  505. package/dist/lib/eval-conversation-handler.js.map +0 -7
  506. package/dist/lib/eval-executor.js.map +0 -7
  507. package/dist/lib/eval-grader.js.map +0 -7
  508. package/dist/lib/eval-meta-judge.js.map +0 -7
  509. package/dist/lib/eval-trigger-tester.js.map +0 -7
  510. package/dist/lib/eval-worktree.js.map +0 -7
  511. package/dist/lib/gateway-entry.js.map +0 -7
  512. package/dist/lib/gateway-identity.js.map +0 -7
  513. package/dist/lib/gateway-lifecycle.js.map +0 -7
  514. package/dist/lib/gateway.js.map +0 -7
  515. package/dist/lib/handlers/cron-refresh-skills.js.map +0 -7
  516. package/dist/lib/handlers/cron-suggest-instructions.js.map +0 -7
  517. package/dist/lib/handlers/process-announcement.js.map +0 -7
  518. package/dist/lib/handlers/process-changelog.js.map +0 -7
  519. package/dist/lib/handlers/process-conversation.js.map +0 -7
  520. package/dist/lib/handlers/process-eval.js.map +0 -7
  521. package/dist/lib/handlers/process-insights.js.map +0 -7
  522. package/dist/lib/handlers/process-launch.js.map +0 -7
  523. package/dist/lib/handlers/process-run-cleanup.js.map +0 -7
  524. package/dist/lib/handlers/process-send-message.js.map +0 -7
  525. package/dist/lib/handlers/process-session-goal.js.map +0 -7
  526. package/dist/lib/hooks-config.js.map +0 -7
  527. package/dist/lib/insights-prompts.js.map +0 -7
  528. package/dist/lib/instruction-snapshot.js.map +0 -7
  529. package/dist/lib/job-helpers.js.map +0 -7
  530. package/dist/lib/llm-client.js.map +0 -7
  531. package/dist/lib/manual-tasks-meta.js.map +0 -7
  532. package/dist/lib/manual-tasks.js.map +0 -7
  533. package/dist/lib/output.js.map +0 -7
  534. package/dist/lib/permanent-job-error.js.map +0 -7
  535. package/dist/lib/pid-identity.js.map +0 -7
  536. package/dist/lib/proxy-respawn.js.map +0 -7
  537. package/dist/lib/research-client.js.map +0 -7
  538. package/dist/lib/setup-steps.js.map +0 -7
  539. package/dist/lib/skills-loader.js.map +0 -7
  540. package/dist/lib/statusline-shim.js.map +0 -7
  541. package/dist/lib/telemetry.js.map +0 -7
  542. package/dist/lib/terminal-target-heartbeat.js.map +0 -7
  543. package/dist/lib/tmux.js.map +0 -7
  544. package/dist/lib/transcript-rate-limit-watcher.js.map +0 -7
  545. package/dist/lib/types.js.map +0 -7
  546. package/dist/lib/version-check.js.map +0 -7
  547. package/dist/lib/which.js.map +0 -7
  548. package/dist/lib/worktree.js.map +0 -7
  549. package/dist/opencode-IQ7X5YMJ.js +0 -190
  550. package/dist/opencode-IQ7X5YMJ.js.map +0 -7
@@ -1,1662 +0,0 @@
1
- import {
2
- __export
3
- } from "./chunk-NSBPE2FW.js";
4
-
5
- // ../../packages/db/dist/schema/tables/profiles.js
6
- import { boolean, pgTable as pgTable2, text as text2, timestamp as timestamp2, uuid as uuid2 } from "drizzle-orm/pg-core";
7
-
8
- // ../../packages/db/dist/schema/tables/organizations.js
9
- import { pgTable, text, timestamp, jsonb, uuid, primaryKey } from "drizzle-orm/pg-core";
10
- var organizations = pgTable("organizations", {
11
- id: uuid("id").primaryKey().defaultRandom(),
12
- name: text("name").unique().notNull(),
13
- slug: text("slug").unique().notNull(),
14
- metadata: jsonb("metadata"),
15
- createdAt: timestamp("created_at", { withTimezone: true }).defaultNow(),
16
- updatedAt: timestamp("updated_at", { withTimezone: true }).defaultNow()
17
- });
18
- var teams = pgTable("teams", {
19
- id: uuid("id").primaryKey().defaultRandom(),
20
- orgId: uuid("org_id").references(() => organizations.id, { onDelete: "cascade" }),
21
- name: text("name").notNull(),
22
- slug: text("slug").notNull(),
23
- metadata: jsonb("metadata"),
24
- createdAt: timestamp("created_at", { withTimezone: true }).defaultNow()
25
- });
26
- var userOrganizations = pgTable("user_organizations", {
27
- userId: uuid("user_id").notNull(),
28
- orgId: uuid("org_id").references(() => organizations.id, { onDelete: "cascade" }).notNull(),
29
- role: text("role").notNull().default("member"),
30
- createdAt: timestamp("created_at", { withTimezone: true }).defaultNow()
31
- }, (table) => [
32
- primaryKey({ columns: [table.userId, table.orgId] })
33
- ]);
34
- var userTeams = pgTable("user_teams", {
35
- userId: uuid("user_id").notNull(),
36
- teamId: uuid("team_id").references(() => teams.id, { onDelete: "cascade" }).notNull(),
37
- role: text("role").notNull().default("member"),
38
- createdAt: timestamp("created_at", { withTimezone: true }).defaultNow()
39
- }, (table) => [
40
- primaryKey({ columns: [table.userId, table.teamId] })
41
- ]);
42
-
43
- // ../../packages/db/dist/schema/tables/profiles.js
44
- var profiles = pgTable2("profiles", {
45
- id: uuid2("id").primaryKey(),
46
- email: text2("email"),
47
- displayName: text2("display_name"),
48
- avatarUrl: text2("avatar_url"),
49
- activeOrgId: uuid2("active_org_id").references(() => organizations.id, { onDelete: "set null" }),
50
- isSuperadmin: boolean("is_superadmin").notNull().default(false),
51
- claudeCodePlan: text2("claude_code_plan"),
52
- planSource: text2("plan_source").notNull().default("detected"),
53
- setupCompletedAt: timestamp2("setup_completed_at", { withTimezone: true }),
54
- liveSendSkipped: boolean("live_send_skipped").notNull().default(false),
55
- createdAt: timestamp2("created_at", { withTimezone: true }).defaultNow(),
56
- updatedAt: timestamp2("updated_at", { withTimezone: true }).defaultNow()
57
- });
58
-
59
- // ../../packages/db/dist/schema/tables/agent-runs.js
60
- import { pgTable as pgTable5, text as text5, timestamp as timestamp5, jsonb as jsonb4, uuid as uuid5, integer as integer2, boolean as boolean4, index as index2 } from "drizzle-orm/pg-core";
61
-
62
- // ../../packages/db/dist/schema/tables/projects.js
63
- import { boolean as boolean3, jsonb as jsonb3, pgTable as pgTable4, primaryKey as primaryKey2, text as text4, timestamp as timestamp4, uniqueIndex as uniqueIndex2, uuid as uuid4 } from "drizzle-orm/pg-core";
64
- import { sql } from "drizzle-orm";
65
-
66
- // ../../packages/db/dist/schema/tables/instructions.js
67
- import { pgTable as pgTable3, text as text3, timestamp as timestamp3, jsonb as jsonb2, uuid as uuid3, integer, boolean as boolean2, uniqueIndex, index } from "drizzle-orm/pg-core";
68
- var instructions = pgTable3("instructions", {
69
- id: uuid3("id").primaryKey().defaultRandom(),
70
- name: text3("name").notNull(),
71
- description: text3("description").notNull(),
72
- type: text3("type").notNull().default("instruction"),
73
- scope: text3("scope").notNull(),
74
- scopeRef: uuid3("scope_ref"),
75
- version: text3("version").notNull(),
76
- content: text3("content").notNull(),
77
- frontmatter: jsonb2("frontmatter").notNull(),
78
- slots: jsonb2("slots"),
79
- tags: text3("tags").array(),
80
- compatibility: text3("compatibility").array(),
81
- createdBy: uuid3("created_by"),
82
- createdAt: timestamp3("created_at", { withTimezone: true }).defaultNow(),
83
- updatedAt: timestamp3("updated_at", { withTimezone: true }).defaultNow(),
84
- archived: boolean2("archived").default(false),
85
- archivedAt: timestamp3("archived_at", { withTimezone: true }),
86
- archivedBy: uuid3("archived_by"),
87
- forkedFromId: uuid3("forked_from_id").references(() => instructions.id, { onDelete: "set null" }),
88
- upstreamVersion: text3("upstream_version"),
89
- badge: text3("badge"),
90
- contentHash: text3("content_hash"),
91
- contextIdentity: text3("context_identity"),
92
- scanScore: integer("scan_score"),
93
- scanFindings: jsonb2("scan_findings"),
94
- popularityScore: integer("popularity_score"),
95
- // Source file's last git-commit date (from the skills registry). Distinct
96
- // from updatedAt, which is the local row's last-sync time. Used to sort the
97
- // public catalog by genuine recency. NULL for non-registry rows and until
98
- // the next registry sync populates it.
99
- sourceUpdatedAt: timestamp3("source_updated_at", { withTimezone: true })
100
- }, (table) => [
101
- uniqueIndex("instructions_name_scope_ref_idx").on(table.name, table.scope, table.scopeRef),
102
- index("idx_instructions_scope").on(table.scope, table.scopeRef),
103
- index("idx_instructions_created_by").on(table.createdBy),
104
- index("idx_instructions_context_identity").on(table.createdBy, table.contextIdentity),
105
- // Recency sort for the public catalog: COALESCE(source_updated_at, updated_at) DESC.
106
- index("idx_instructions_public_recency").on(table.scope, table.sourceUpdatedAt.desc())
107
- ]);
108
- var instructionVersions = pgTable3("instruction_versions", {
109
- id: uuid3("id").primaryKey().defaultRandom(),
110
- instructionId: uuid3("instruction_id").references(() => instructions.id, { onDelete: "cascade" }),
111
- versionNumber: integer("version_number").notNull(),
112
- content: text3("content").notNull(),
113
- frontmatter: jsonb2("frontmatter").notNull(),
114
- changeSummary: text3("change_summary"),
115
- createdBy: uuid3("created_by"),
116
- createdAt: timestamp3("created_at", { withTimezone: true }).defaultNow()
117
- }, (table) => [
118
- uniqueIndex("instruction_versions_instruction_version_idx").on(table.instructionId, table.versionNumber)
119
- ]);
120
-
121
- // ../../packages/db/dist/schema/tables/projects.js
122
- var projects = pgTable4("projects", {
123
- id: uuid4("id").primaryKey().defaultRandom(),
124
- orgId: uuid4("org_id").references(() => organizations.id, { onDelete: "cascade" }),
125
- name: text4("name").notNull(),
126
- description: text4("description"),
127
- // Legacy display field. No longer used as a primary lookup key — see
128
- // gitRemoteUrl below. Kept for backward compat on existing UI forms.
129
- githubRepo: text4("github_repo"),
130
- // Canonicalized git remote URL (e.g. 'github.com/owner/repo'). Primary
131
- // identity for project matching, set via canonicalizeRemote() server-side.
132
- gitRemoteUrl: text4("git_remote_url"),
133
- // SHA of the repo's first commit. Stability anchor — survives URL renames
134
- // (transferred repos keep the same root commit). Used as fallback lookup
135
- // when remote URL doesn't match.
136
- gitRootCommit: text4("git_root_commit"),
137
- // Old URLs this project has been known by. Populated when a URL rename
138
- // is detected via root-commit match. Future sessions with the old URL
139
- // still resolve to this project.
140
- gitRemoteAliases: text4("git_remote_aliases").array().notNull().default([]),
141
- metadata: jsonb3("metadata"),
142
- createdBy: uuid4("created_by"),
143
- createdAt: timestamp4("created_at", { withTimezone: true }).defaultNow(),
144
- updatedAt: timestamp4("updated_at", { withTimezone: true }).defaultNow()
145
- }, (table) => [
146
- uniqueIndex2("projects_org_name_idx").on(table.orgId, table.name),
147
- // Partial unique index — NULLs are allowed (legacy projects with no
148
- // remote). See migration 00054.
149
- uniqueIndex2("projects_git_remote_url_unique").on(table.gitRemoteUrl).where(sql`${table.gitRemoteUrl} IS NOT NULL`)
150
- ]);
151
- var projectInstructions = pgTable4("project_instructions", {
152
- projectId: uuid4("project_id").references(() => projects.id, { onDelete: "cascade" }).notNull(),
153
- instructionId: uuid4("instruction_id").references(() => instructions.id, { onDelete: "cascade" }).notNull(),
154
- addedAt: timestamp4("added_at", { withTimezone: true }).defaultNow(),
155
- addedBy: uuid4("added_by")
156
- }, (table) => [
157
- primaryKey2({ columns: [table.projectId, table.instructionId] })
158
- ]);
159
- var projectCheckouts = pgTable4("project_checkouts", {
160
- projectId: uuid4("project_id").references(() => projects.id, { onDelete: "cascade" }).notNull(),
161
- path: text4("path").notNull(),
162
- isWorktree: boolean3("is_worktree").notNull().default(false),
163
- firstSeen: timestamp4("first_seen", { withTimezone: true }).notNull().defaultNow(),
164
- lastSeen: timestamp4("last_seen", { withTimezone: true }).notNull().defaultNow()
165
- }, (table) => [
166
- primaryKey2({ columns: [table.projectId, table.path] }),
167
- uniqueIndex2("project_checkouts_path_unique").on(table.path)
168
- ]);
169
-
170
- // ../../packages/db/dist/schema/tables/agent-runs.js
171
- var agentRuns = pgTable5("agent_runs", {
172
- id: uuid5("id").primaryKey().defaultRandom(),
173
- userId: uuid5("user_id").notNull().references(() => profiles.id, { onDelete: "cascade" }),
174
- orgId: uuid5("org_id").references(() => organizations.id, { onDelete: "set null" }),
175
- projectId: uuid5("project_id").references(() => projects.id, { onDelete: "set null" }),
176
- projectPath: text5("project_path"),
177
- gitRemote: text5("git_remote"),
178
- baseBranch: text5("base_branch"),
179
- title: text5("title"),
180
- prompt: text5("prompt"),
181
- // the shared task fanned out to each session
182
- toolSpec: jsonb4("tool_spec").notNull().default([]),
183
- // [{tool, model?, label?}] one entry per session
184
- autoWorktree: boolean4("auto_worktree").notNull().default(true),
185
- // 'pending' | 'running' | 'completed' | 'failed' | 'cancelled' (DB CHECK enforces)
186
- status: text5("status").notNull().default("pending"),
187
- sessionCount: integer2("session_count").notNull().default(0),
188
- metadata: jsonb4("metadata").notNull().default({}),
189
- createdAt: timestamp5("created_at", { withTimezone: true }).notNull().defaultNow(),
190
- updatedAt: timestamp5("updated_at", { withTimezone: true }).notNull().defaultNow(),
191
- completedAt: timestamp5("completed_at", { withTimezone: true })
192
- }, (table) => [
193
- index2("idx_agent_runs_user").on(table.userId),
194
- index2("idx_agent_runs_org_created").on(table.orgId, table.createdAt),
195
- index2("idx_agent_runs_project").on(table.projectId)
196
- ]);
197
-
198
- // ../../packages/db/dist/schema/tables/sessions.js
199
- import { pgTable as pgTable6, text as text6, timestamp as timestamp6, jsonb as jsonb5, uuid as uuid6, integer as integer3, uniqueIndex as uniqueIndex3, index as index3 } from "drizzle-orm/pg-core";
200
- var sessions = pgTable6("sessions", {
201
- id: uuid6("id").primaryKey().defaultRandom(),
202
- userId: uuid6("user_id").notNull().references(() => profiles.id, { onDelete: "cascade" }),
203
- externalSessionId: text6("external_session_id"),
204
- projectId: uuid6("project_id").references(() => projects.id, { onDelete: "set null" }),
205
- orgId: uuid6("org_id").references(() => organizations.id, { onDelete: "set null" }),
206
- tool: text6("tool").notNull(),
207
- projectPath: text6("project_path"),
208
- gitBranch: text6("git_branch"),
209
- startedAt: timestamp6("started_at", { withTimezone: true }).notNull(),
210
- endedAt: timestamp6("ended_at", { withTimezone: true }),
211
- eventCount: integer3("event_count").default(0),
212
- tokenUsage: jsonb5("token_usage"),
213
- analysis: jsonb5("analysis"),
214
- analyzedAt: timestamp6("analyzed_at", { withTimezone: true }),
215
- analyzedEventCount: integer3("analyzed_event_count"),
216
- analyzedTurnCount: integer3("analyzed_turn_count"),
217
- metadata: jsonb5("metadata").default({}),
218
- // 'hook' | 'mcp' | 'proxy' | 'internal_worker' | 'import' | 'unknown'
219
- // Set on insert in POST /api/sessions. GET /api/sessions defaults to
220
- // excluding 'internal_worker' so insights/eval pipeline auto-captures
221
- // never appear in the user's Sessions tab. See migration 00050.
222
- origin: text6("origin").notNull().default("unknown"),
223
- runId: uuid6("run_id").references(() => agentRuns.id, { onDelete: "set null" }),
224
- createdAt: timestamp6("created_at", { withTimezone: true }).defaultNow()
225
- }, (table) => [
226
- index3("idx_sessions_user").on(table.userId),
227
- index3("idx_sessions_tool").on(table.tool),
228
- index3("idx_sessions_started_at").on(table.startedAt),
229
- index3("idx_sessions_project").on(table.projectId),
230
- index3("idx_sessions_org_started_at").on(table.orgId, table.startedAt),
231
- index3("idx_sessions_run").on(table.runId),
232
- uniqueIndex3("idx_sessions_user_external").on(table.userId, table.externalSessionId)
233
- ]);
234
- var sessionEvents = pgTable6("session_events", {
235
- id: uuid6("id").primaryKey().defaultRandom(),
236
- sessionId: uuid6("session_id").notNull().references(() => sessions.id, { onDelete: "cascade" }),
237
- sequence: integer3("sequence").notNull(),
238
- eventType: text6("event_type").notNull(),
239
- content: text6("content"),
240
- toolName: text6("tool_name"),
241
- toolInput: jsonb5("tool_input"),
242
- toolOutput: jsonb5("tool_output"),
243
- tokenUsage: jsonb5("token_usage"),
244
- model: text6("model"),
245
- timestamp: timestamp6("timestamp", { withTimezone: true }).notNull(),
246
- metadata: jsonb5("metadata").default({})
247
- }, (table) => [
248
- uniqueIndex3("session_events_session_sequence_idx").on(table.sessionId, table.sequence),
249
- index3("idx_session_events_session_id").on(table.sessionId),
250
- index3("idx_session_events_event_type").on(table.eventType),
251
- index3("idx_session_events_model").on(table.model)
252
- ]);
253
- var sessionInstructions = pgTable6("session_instructions", {
254
- sessionId: uuid6("session_id").notNull().references(() => sessions.id, { onDelete: "cascade" }),
255
- instructionId: uuid6("instruction_id").notNull().references(() => instructions.id, { onDelete: "cascade" }),
256
- linkMethod: text6("link_method").notNull()
257
- }, (table) => [
258
- index3("idx_session_instructions_instruction_id").on(table.instructionId)
259
- ]);
260
-
261
- // ../../packages/db/dist/schema/tables/announcements.js
262
- import { boolean as boolean5, date, index as index4, integer as integer4, jsonb as jsonb6, pgTable as pgTable7, text as text7, timestamp as timestamp7, uniqueIndex as uniqueIndex4, uuid as uuid7 } from "drizzle-orm/pg-core";
263
- var announcements = pgTable7("announcements", {
264
- id: uuid7("id").primaryKey().defaultRandom(),
265
- version: text7("version").notNull().unique(),
266
- releaseDate: date("release_date").notNull(),
267
- subject: text7("subject").notNull(),
268
- htmlBody: text7("html_body").notNull(),
269
- textBody: text7("text_body").notNull(),
270
- sections: jsonb6("sections").notNull().default({}),
271
- status: text7("status").notNull().default("draft"),
272
- recipientCount: integer4("recipient_count"),
273
- sentAt: timestamp7("sent_at", { withTimezone: true }),
274
- sentBy: uuid7("sent_by"),
275
- error: text7("error"),
276
- createdAt: timestamp7("created_at", { withTimezone: true }).notNull().defaultNow(),
277
- updatedAt: timestamp7("updated_at", { withTimezone: true }).notNull().defaultNow()
278
- }, (table) => [
279
- index4("idx_announcements_status").on(table.status),
280
- index4("idx_announcements_created").on(table.createdAt)
281
- ]);
282
- var announcementDeliveries = pgTable7("announcement_deliveries", {
283
- id: uuid7("id").primaryKey().defaultRandom(),
284
- announcementId: uuid7("announcement_id").notNull(),
285
- userId: uuid7("user_id").notNull(),
286
- email: text7("email").notNull(),
287
- status: text7("status").notNull().default("pending"),
288
- providerId: text7("provider_id"),
289
- error: text7("error"),
290
- sentAt: timestamp7("sent_at", { withTimezone: true }),
291
- createdAt: timestamp7("created_at", { withTimezone: true }).notNull().defaultNow()
292
- }, (table) => [
293
- uniqueIndex4("uniq_announcement_deliveries_announcement_user").on(table.announcementId, table.userId),
294
- index4("idx_announcement_deliveries_user").on(table.userId, table.createdAt)
295
- ]);
296
- var notificationPreferences = pgTable7("notification_preferences", {
297
- userId: uuid7("user_id").primaryKey(),
298
- productAnnouncements: boolean5("product_announcements").notNull().default(true),
299
- unsubscribeToken: text7("unsubscribe_token").notNull().unique(),
300
- unsubscribedAt: timestamp7("unsubscribed_at", { withTimezone: true }),
301
- createdAt: timestamp7("created_at", { withTimezone: true }).notNull().defaultNow(),
302
- updatedAt: timestamp7("updated_at", { withTimezone: true }).notNull().defaultNow()
303
- });
304
-
305
- // ../../packages/db/dist/schema/tables/org-invitations.js
306
- import { pgTable as pgTable8, text as text8, timestamp as timestamp8, uuid as uuid8, index as index5 } from "drizzle-orm/pg-core";
307
- var orgInvitations = pgTable8("org_invitations", {
308
- id: uuid8("id").primaryKey().defaultRandom(),
309
- orgId: uuid8("org_id").notNull().references(() => organizations.id, { onDelete: "cascade" }),
310
- email: text8("email").notNull(),
311
- role: text8("role").notNull().default("member"),
312
- teamId: uuid8("team_id").references(() => teams.id, { onDelete: "set null" }),
313
- invitedBy: uuid8("invited_by").notNull().references(() => profiles.id),
314
- token: text8("token").notNull().unique(),
315
- // expires_at is generated by Postgres via `default (now() + interval '7 days')`,
316
- // so no Drizzle-side default — just notNull.
317
- expiresAt: timestamp8("expires_at", { withTimezone: true }).notNull(),
318
- acceptedAt: timestamp8("accepted_at", { withTimezone: true }),
319
- revokedAt: timestamp8("revoked_at", { withTimezone: true }),
320
- createdAt: timestamp8("created_at", { withTimezone: true }).notNull().defaultNow()
321
- }, (t) => [
322
- index5("idx_org_invitations_token").on(t.token),
323
- index5("idx_org_invitations_org").on(t.orgId)
324
- ]);
325
-
326
- // ../../packages/db/dist/schema/tables/instruction-events.js
327
- import { pgTable as pgTable9, text as text9, timestamp as timestamp9, jsonb as jsonb7, uuid as uuid9, index as index6 } from "drizzle-orm/pg-core";
328
- var instructionEvents = pgTable9("instruction_events", {
329
- id: uuid9("id").primaryKey().defaultRandom(),
330
- instructionId: uuid9("instruction_id").notNull().references(() => instructions.id, { onDelete: "cascade" }),
331
- eventType: text9("event_type").notNull(),
332
- actorId: uuid9("actor_id").notNull(),
333
- metadata: jsonb7("metadata"),
334
- createdAt: timestamp9("created_at", { withTimezone: true }).defaultNow()
335
- }, (table) => [
336
- index6("idx_instruction_events_instruction").on(table.instructionId),
337
- index6("idx_instruction_events_type").on(table.eventType)
338
- ]);
339
-
340
- // ../../packages/db/dist/schema/tables/session-terminal-targets.js
341
- import { pgTable as pgTable10, text as text10, timestamp as timestamp10, uuid as uuid10, jsonb as jsonb8, uniqueIndex as uniqueIndex5, index as index7 } from "drizzle-orm/pg-core";
342
- var sessionTerminalTargets = pgTable10("session_terminal_targets", {
343
- id: uuid10("id").primaryKey().defaultRandom(),
344
- userId: uuid10("user_id").notNull().references(() => profiles.id, { onDelete: "cascade" }),
345
- sessionId: uuid10("session_id").references(() => sessions.id, { onDelete: "set null" }),
346
- externalSessionId: text10("external_session_id"),
347
- kind: text10("kind").notNull(),
348
- target: text10("target").notNull(),
349
- status: text10("status").notNull().default("active"),
350
- attachCommand: text10("attach_command").notNull(),
351
- projectPath: text10("project_path"),
352
- metadata: jsonb8("metadata").notNull().default({}),
353
- lastSeenAt: timestamp10("last_seen_at", { withTimezone: true }).defaultNow(),
354
- createdAt: timestamp10("created_at", { withTimezone: true }).defaultNow(),
355
- updatedAt: timestamp10("updated_at", { withTimezone: true }).defaultNow()
356
- }, (table) => [
357
- uniqueIndex5("idx_session_terminal_targets_user_target").on(table.userId, table.target),
358
- index7("idx_session_terminal_targets_session").on(table.sessionId),
359
- index7("idx_session_terminal_targets_user_status").on(table.userId, table.status)
360
- ]);
361
-
362
- // ../../packages/db/dist/schema/tables/session-send-jobs.js
363
- import { boolean as boolean6, bigint, index as index8, jsonb as jsonb9, pgTable as pgTable11, text as text11, timestamp as timestamp11, uuid as uuid11, integer as integer5 } from "drizzle-orm/pg-core";
364
- var sessionSendJobs = pgTable11("session_send_jobs", {
365
- id: uuid11("id").primaryKey().defaultRandom(),
366
- userId: uuid11("user_id").notNull(),
367
- sessionId: uuid11("session_id").notNull().references(() => sessions.id, { onDelete: "cascade" }),
368
- terminalTargetId: uuid11("terminal_target_id").references(() => sessionTerminalTargets.id, { onDelete: "set null" }),
369
- target: text11("target").notNull(),
370
- message: text11("message").notNull(),
371
- submit: boolean6("submit").notNull().default(true),
372
- delivery: text11("delivery").notNull().default("live"),
373
- status: text11("status").notNull().default("pending"),
374
- result: jsonb9("result"),
375
- error: text11("error"),
376
- attempts: integer5("attempts").notNull().default(0),
377
- graphileJobId: bigint("graphile_job_id", { mode: "number" }),
378
- taskKind: text11("task_kind"),
379
- payload: jsonb9("payload"),
380
- claimedBy: text11("claimed_by"),
381
- claimedAt: timestamp11("claimed_at", { withTimezone: true }),
382
- leaseExpiresAt: timestamp11("lease_expires_at", { withTimezone: true }),
383
- createdAt: timestamp11("created_at", { withTimezone: true }).defaultNow(),
384
- updatedAt: timestamp11("updated_at", { withTimezone: true }).defaultNow(),
385
- completedAt: timestamp11("completed_at", { withTimezone: true })
386
- }, (table) => [
387
- index8("idx_session_send_jobs_user").on(table.userId),
388
- index8("idx_session_send_jobs_session").on(table.sessionId),
389
- index8("idx_session_send_jobs_status").on(table.status),
390
- index8("idx_session_send_jobs_pending").on(table.userId, table.status)
391
- ]);
392
-
393
- // ../../packages/db/dist/schema/tables/packs.js
394
- import { pgTable as pgTable12, text as text12, timestamp as timestamp12, jsonb as jsonb10, uuid as uuid12, integer as integer6, boolean as boolean7, uniqueIndex as uniqueIndex6, index as index9, primaryKey as primaryKey3 } from "drizzle-orm/pg-core";
395
- var packs = pgTable12("packs", {
396
- id: uuid12("id").primaryKey().defaultRandom(),
397
- name: text12("name").notNull(),
398
- description: text12("description").notNull(),
399
- scope: text12("scope").notNull(),
400
- scopeRef: uuid12("scope_ref"),
401
- version: text12("version").notNull().default("1.0.0"),
402
- tags: text12("tags").array(),
403
- badge: text12("badge"),
404
- metadata: jsonb10("metadata"),
405
- createdBy: uuid12("created_by"),
406
- createdAt: timestamp12("created_at", { withTimezone: true }).defaultNow(),
407
- updatedAt: timestamp12("updated_at", { withTimezone: true }).defaultNow(),
408
- archived: boolean7("archived").default(false),
409
- archivedAt: timestamp12("archived_at", { withTimezone: true }),
410
- archivedBy: uuid12("archived_by"),
411
- forkedFromId: uuid12("forked_from_id").references(() => packs.id, { onDelete: "set null" }),
412
- upstreamVersion: text12("upstream_version")
413
- }, (table) => [
414
- uniqueIndex6("packs_name_scope_ref_idx").on(table.name, table.scope, table.scopeRef),
415
- index9("idx_packs_scope").on(table.scope, table.scopeRef),
416
- index9("idx_packs_created_by").on(table.createdBy)
417
- ]);
418
- var packInstructions = pgTable12("pack_instructions", {
419
- packId: uuid12("pack_id").references(() => packs.id, { onDelete: "cascade" }).notNull(),
420
- instructionId: uuid12("instruction_id").references(() => instructions.id, { onDelete: "cascade" }).notNull(),
421
- position: integer6("position").notNull().default(0),
422
- slotOverrides: jsonb10("slot_overrides"),
423
- addedAt: timestamp12("added_at", { withTimezone: true }).defaultNow(),
424
- addedBy: uuid12("added_by")
425
- }, (table) => [
426
- primaryKey3({ columns: [table.packId, table.instructionId] })
427
- ]);
428
-
429
- // ../../packages/db/dist/schema/tables/usage-events.js
430
- import { pgTable as pgTable13, text as text13, timestamp as timestamp13, jsonb as jsonb11, uuid as uuid13, index as index10 } from "drizzle-orm/pg-core";
431
- var instructionUsageEvents = pgTable13("instruction_usage_events", {
432
- id: uuid13("id").primaryKey().defaultRandom(),
433
- instructionId: uuid13("instruction_id").references(() => instructions.id, { onDelete: "set null" }),
434
- userId: uuid13("user_id").notNull(),
435
- surface: text13("surface").notNull(),
436
- action: text13("action").notNull(),
437
- metadata: jsonb11("metadata"),
438
- traceId: text13("trace_id"),
439
- createdAt: timestamp13("created_at", { withTimezone: true }).defaultNow()
440
- }, (table) => [
441
- index10("idx_usage_events_instruction").on(table.instructionId),
442
- index10("idx_usage_events_user").on(table.userId),
443
- index10("idx_usage_events_surface").on(table.surface),
444
- index10("idx_usage_events_action").on(table.action),
445
- index10("idx_usage_events_created_at").on(table.createdAt),
446
- index10("idx_usage_events_user_created").on(table.userId, table.createdAt)
447
- ]);
448
-
449
- // ../../packages/db/dist/schema/tables/worker-connections.js
450
- import { pgTable as pgTable14, text as text14, timestamp as timestamp14, jsonb as jsonb12, uuid as uuid14, index as index11 } from "drizzle-orm/pg-core";
451
- var workerConnections = pgTable14("worker_connections", {
452
- id: uuid14("id").primaryKey().defaultRandom(),
453
- userId: uuid14("user_id").notNull(),
454
- workerType: text14("worker_type").notNull().default("mcp"),
455
- clientName: text14("client_name").notNull(),
456
- clientVersion: text14("client_version"),
457
- workerVersion: text14("worker_version"),
458
- lastHeartbeat: timestamp14("last_heartbeat", { withTimezone: true }).notNull().defaultNow(),
459
- connectedAt: timestamp14("connected_at", { withTimezone: true }).notNull().defaultNow(),
460
- metadata: jsonb12("metadata")
461
- }, (table) => [
462
- index11("idx_worker_connections_user").on(table.userId),
463
- index11("idx_worker_connections_heartbeat").on(table.userId, table.lastHeartbeat),
464
- index11("idx_worker_connections_type").on(table.userId, table.workerType)
465
- ]);
466
-
467
- // ../../packages/db/dist/schema/tables/cli-setup-events.js
468
- import { pgTable as pgTable15, text as text15, timestamp as timestamp15, jsonb as jsonb13, uuid as uuid15, index as index12 } from "drizzle-orm/pg-core";
469
- var cliSetupEvents = pgTable15("cli_setup_events", {
470
- id: uuid15("id").primaryKey().defaultRandom(),
471
- userId: uuid15("user_id").notNull(),
472
- deviceId: text15("device_id").notNull(),
473
- event: text15("event").notNull(),
474
- cliVersion: text15("cli_version"),
475
- os: text15("os"),
476
- props: jsonb13("props").notNull().default({}),
477
- createdAt: timestamp15("created_at", { withTimezone: true }).notNull().defaultNow()
478
- }, (table) => [
479
- index12("idx_cli_setup_events_user").on(table.userId, table.createdAt),
480
- index12("idx_cli_setup_events_device").on(table.deviceId, table.createdAt)
481
- ]);
482
-
483
- // ../../packages/db/dist/schema/tables/cli-error-events.js
484
- import { pgTable as pgTable16, text as text16, integer as integer7, boolean as boolean8, timestamp as timestamp16, jsonb as jsonb14, uuid as uuid16, index as index13 } from "drizzle-orm/pg-core";
485
- var cliErrorEvents = pgTable16("cli_error_events", {
486
- id: uuid16("id").primaryKey().defaultRandom(),
487
- deviceId: text16("device_id"),
488
- event: text16("event").notNull(),
489
- command: text16("command"),
490
- statusCode: integer7("status_code"),
491
- message: text16("message"),
492
- cliVersion: text16("cli_version"),
493
- os: text16("os"),
494
- nodeVersion: text16("node_version"),
495
- proxied: boolean8("proxied"),
496
- props: jsonb14("props").notNull().default({}),
497
- createdAt: timestamp16("created_at", { withTimezone: true }).notNull().defaultNow()
498
- }, (table) => [
499
- index13("idx_cli_error_events_created").on(table.createdAt),
500
- index13("idx_cli_error_events_device").on(table.deviceId, table.createdAt)
501
- ]);
502
-
503
- // ../../packages/db/dist/schema/tables/eval-targets.js
504
- import { pgTable as pgTable17, text as text17, timestamp as timestamp17, jsonb as jsonb15, uuid as uuid17, integer as integer8, index as index14 } from "drizzle-orm/pg-core";
505
- var evalTargets = pgTable17("eval_targets", {
506
- id: uuid17("id").primaryKey().defaultRandom(),
507
- userId: uuid17("user_id").notNull(),
508
- name: text17("name").notNull(),
509
- type: text17("type").notNull(),
510
- content: text17("content").notNull(),
511
- description: text17("description").notNull().default(""),
512
- metadata: jsonb15("metadata").notNull().default({}),
513
- version: integer8("version").notNull().default(1),
514
- parentId: uuid17("parent_id").references(() => evalTargets.id, { onDelete: "set null" }),
515
- createdAt: timestamp17("created_at", { withTimezone: true }).defaultNow(),
516
- updatedAt: timestamp17("updated_at", { withTimezone: true }).defaultNow()
517
- }, (table) => [
518
- index14("eval_targets_name_user_idx").on(table.name, table.userId),
519
- index14("idx_eval_targets_user").on(table.userId),
520
- index14("idx_eval_targets_type").on(table.type),
521
- index14("idx_eval_targets_parent").on(table.parentId)
522
- ]);
523
- var evals = pgTable17("evals", {
524
- id: uuid17("id").primaryKey().defaultRandom(),
525
- evalTargetId: uuid17("eval_target_id").notNull().references(() => evalTargets.id, { onDelete: "cascade" }),
526
- name: text17("name").notNull(),
527
- prompt: text17("prompt").notNull(),
528
- expectedOutput: text17("expected_output").notNull().default(""),
529
- files: jsonb15("files").notNull().default([]),
530
- expectations: jsonb15("expectations").notNull().default([]),
531
- createdAt: timestamp17("created_at", { withTimezone: true }).defaultNow(),
532
- updatedAt: timestamp17("updated_at", { withTimezone: true }).defaultNow()
533
- }, (table) => [
534
- index14("idx_evals_target").on(table.evalTargetId)
535
- ]);
536
- var evalRuns = pgTable17("eval_runs", {
537
- id: uuid17("id").primaryKey().defaultRandom(),
538
- evalId: uuid17("eval_id").notNull().references(() => evals.id, { onDelete: "cascade" }),
539
- evalTargetId: uuid17("eval_target_id").notNull().references(() => evalTargets.id, { onDelete: "cascade" }),
540
- evalTargetVersion: integer8("eval_target_version").notNull(),
541
- configuration: text17("configuration").notNull(),
542
- runNumber: integer8("run_number").notNull().default(1),
543
- iteration: integer8("iteration").notNull().default(1),
544
- status: text17("status").notNull().default("completed"),
545
- outputs: jsonb15("outputs").notNull().default({}),
546
- timing: jsonb15("timing").notNull().default({}),
547
- grading: jsonb15("grading").notNull().default({}),
548
- comparison: jsonb15("comparison"),
549
- createdAt: timestamp17("created_at", { withTimezone: true }).defaultNow()
550
- }, (table) => [
551
- index14("idx_eval_runs_eval").on(table.evalId),
552
- index14("idx_eval_runs_target").on(table.evalTargetId),
553
- index14("idx_eval_runs_iteration").on(table.evalTargetId, table.iteration)
554
- ]);
555
- var benchmarks = pgTable17("benchmarks", {
556
- id: uuid17("id").primaryKey().defaultRandom(),
557
- evalTargetId: uuid17("eval_target_id").notNull().references(() => evalTargets.id, { onDelete: "cascade" }),
558
- iteration: integer8("iteration").notNull().default(1),
559
- runSummary: jsonb15("run_summary").notNull().default({}),
560
- notes: jsonb15("notes").notNull().default([]),
561
- feedback: jsonb15("feedback"),
562
- createdAt: timestamp17("created_at", { withTimezone: true }).defaultNow()
563
- }, (table) => [
564
- index14("idx_benchmarks_target").on(table.evalTargetId)
565
- ]);
566
-
567
- // ../../packages/db/dist/schema/tables/optimization.js
568
- import { pgTable as pgTable18, text as text18, timestamp as timestamp18, jsonb as jsonb16, uuid as uuid18, integer as integer9, index as index15, real } from "drizzle-orm/pg-core";
569
- var triggerEvals = pgTable18("trigger_evals", {
570
- id: uuid18("id").primaryKey().defaultRandom(),
571
- evalTargetId: uuid18("eval_target_id").notNull().references(() => evalTargets.id, { onDelete: "cascade" }),
572
- userId: uuid18("user_id").notNull(),
573
- queries: jsonb16("queries").notNull().default([]),
574
- status: text18("status").notNull().default("pending_review"),
575
- trainIndices: integer9("train_indices").array().default([]),
576
- testIndices: integer9("test_indices").array().default([]),
577
- createdAt: timestamp18("created_at", { withTimezone: true }).defaultNow(),
578
- updatedAt: timestamp18("updated_at", { withTimezone: true }).defaultNow()
579
- }, (table) => [
580
- index15("idx_trigger_evals_target").on(table.evalTargetId),
581
- index15("idx_trigger_evals_user").on(table.userId)
582
- ]);
583
- var optimizationRuns = pgTable18("optimization_runs", {
584
- id: uuid18("id").primaryKey().defaultRandom(),
585
- evalTargetId: uuid18("eval_target_id").notNull().references(() => evalTargets.id, { onDelete: "cascade" }),
586
- userId: uuid18("user_id").notNull(),
587
- type: text18("type").notNull(),
588
- iteration: integer9("iteration").notNull(),
589
- inputVersion: integer9("input_version").notNull(),
590
- outputVersion: integer9("output_version"),
591
- trainScore: real("train_score"),
592
- testScore: real("test_score"),
593
- analysis: jsonb16("analysis").notNull().default({}),
594
- status: text18("status").notNull().default("running"),
595
- createdAt: timestamp18("created_at", { withTimezone: true }).defaultNow()
596
- }, (table) => [
597
- index15("idx_optimization_runs_target").on(table.evalTargetId),
598
- index15("idx_optimization_runs_user").on(table.userId)
599
- ]);
600
-
601
- // ../../packages/db/dist/schema/tables/context-snapshots.js
602
- import { pgTable as pgTable19, text as text19, timestamp as timestamp19, jsonb as jsonb17, uuid as uuid19, integer as integer10, real as real2, index as index16, uniqueIndex as uniqueIndex7 } from "drizzle-orm/pg-core";
603
- var contextSnapshots = pgTable19("context_snapshots", {
604
- id: uuid19("id").primaryKey().defaultRandom(),
605
- sessionId: uuid19("session_id").references(() => sessions.id, { onDelete: "cascade" }),
606
- userId: uuid19("user_id").notNull().references(() => profiles.id, { onDelete: "cascade" }),
607
- sequence: integer10("sequence").notNull().default(0),
608
- provider: text19("provider").notNull(),
609
- model: text19("model").notNull(),
610
- systemPrompt: text19("system_prompt").notNull(),
611
- injectedInstructions: jsonb17("injected_instructions").notNull().default([]),
612
- messagesSummary: jsonb17("messages_summary").notNull(),
613
- tools: jsonb17("tools").notNull().default([]),
614
- // Deprecated: use content_blobs via tools_hash
615
- systemHash: text19("system_hash").notNull(),
616
- requestHash: text19("request_hash").notNull().default(""),
617
- toolsHash: text19("tools_hash"),
618
- injectedHash: text19("injected_hash"),
619
- messagesDelta: jsonb17("messages_delta").default([]),
620
- // Storage pointer set when messages_delta is offloaded to the snapshot-deltas
621
- // bucket (Stage 1+). NULL = inline (messages_delta populated) OR pruned (both
622
- // NULL — see 00101). docs/plans/2026-06-24-messages-delta-object-storage-offload.md
623
- messagesDeltaRef: text19("messages_delta_ref"),
624
- maxTokens: integer10("max_tokens"),
625
- temperature: real2("temperature"),
626
- estimatedTokens: integer10("estimated_tokens"),
627
- capturedAt: timestamp19("captured_at", { withTimezone: true }).notNull().defaultNow(),
628
- metadata: jsonb17("metadata").default({})
629
- }, (table) => [
630
- index16("idx_context_snapshots_session").on(table.sessionId),
631
- index16("idx_context_snapshots_user").on(table.userId),
632
- index16("idx_context_snapshots_hash").on(table.systemHash),
633
- index16("idx_context_snapshots_request_hash").on(table.requestHash),
634
- uniqueIndex7("idx_snapshots_session_request").on(table.sessionId, table.requestHash),
635
- // Concurrent snapshot POSTs for one session must not reuse a sequence — stops
636
- // the live duplicate-sequence corruption. Built via migration 00095.
637
- // Pool/perf audit 2026-06-22.
638
- uniqueIndex7("idx_snapshots_session_sequence").on(table.sessionId, table.sequence),
639
- // "Latest snapshot per session for a user" read (DISTINCT ON (session_id)
640
- // WHERE user_id ORDER BY session_id, captured_at DESC). Matches the ORDER BY so
641
- // the planner drops the Incremental Sort (the ~11s-max, temp-spill-prone step);
642
- // verified 60.6ms -> 26.3ms. Built CONCURRENTLY via migration 00106.
643
- index16("idx_context_snapshots_user_session_captured").on(table.userId, table.sessionId, table.capturedAt.desc())
644
- ]);
645
-
646
- // ../../packages/db/dist/schema/tables/content-blobs.js
647
- import { pgTable as pgTable20, text as text20, timestamp as timestamp20, jsonb as jsonb18, integer as integer11, index as index17 } from "drizzle-orm/pg-core";
648
- var contentBlobs = pgTable20("content_blobs", {
649
- hash: text20("hash").primaryKey(),
650
- contentType: text20("content_type").notNull(),
651
- content: jsonb18("content").notNull(),
652
- sizeBytes: integer11("size_bytes").notNull().default(0),
653
- createdAt: timestamp20("created_at", { withTimezone: true }).defaultNow()
654
- }, (table) => [
655
- index17("idx_content_blobs_type").on(table.contentType)
656
- ]);
657
-
658
- // ../../packages/db/dist/schema/tables/eval-jobs.js
659
- import { pgTable as pgTable21, text as text21, timestamp as timestamp21, jsonb as jsonb19, uuid as uuid20, index as index18, integer as integer12, bigint as bigint2 } from "drizzle-orm/pg-core";
660
- var evalJobs = pgTable21("eval_jobs", {
661
- id: uuid20("id").primaryKey().defaultRandom(),
662
- userId: uuid20("user_id").notNull(),
663
- evalTargetId: uuid20("eval_target_id").notNull().references(() => evalTargets.id, { onDelete: "cascade" }),
664
- status: text21("status").notNull().default("pending"),
665
- config: jsonb19("config").notNull().default({}),
666
- progress: jsonb19("progress").notNull().default({}),
667
- result: jsonb19("result"),
668
- error: text21("error"),
669
- attempts: integer12("attempts").notNull().default(0),
670
- graphileJobId: bigint2("graphile_job_id", { mode: "number" }),
671
- taskKind: text21("task_kind"),
672
- payload: jsonb19("payload"),
673
- claimedBy: text21("claimed_by"),
674
- claimedAt: timestamp21("claimed_at", { withTimezone: true }),
675
- leaseExpiresAt: timestamp21("lease_expires_at", { withTimezone: true }),
676
- createdAt: timestamp21("created_at", { withTimezone: true }).defaultNow(),
677
- updatedAt: timestamp21("updated_at", { withTimezone: true }).defaultNow(),
678
- completedAt: timestamp21("completed_at", { withTimezone: true })
679
- }, (table) => [
680
- index18("idx_eval_jobs_user").on(table.userId),
681
- index18("idx_eval_jobs_target").on(table.evalTargetId),
682
- index18("idx_eval_jobs_status").on(table.status),
683
- index18("idx_eval_jobs_pending").on(table.userId, table.status)
684
- ]);
685
-
686
- // ../../packages/db/dist/schema/tables/agent-jobs.js
687
- import { pgTable as pgTable22, text as text22, timestamp as timestamp22, jsonb as jsonb20, uuid as uuid21, integer as integer13, index as index19 } from "drizzle-orm/pg-core";
688
- var agentJobs = pgTable22("agent_jobs", {
689
- id: uuid21("id").primaryKey().defaultRandom(),
690
- userId: uuid21("user_id").notNull(),
691
- taskKind: text22("task_kind").notNull(),
692
- status: text22("status").notNull().default("pending"),
693
- payload: jsonb20("payload").notNull(),
694
- dedupeKey: text22("dedupe_key"),
695
- result: jsonb20("result"),
696
- error: text22("error"),
697
- attempts: integer13("attempts").notNull().default(0),
698
- claimedBy: text22("claimed_by"),
699
- claimedAt: timestamp22("claimed_at", { withTimezone: true }),
700
- leaseExpiresAt: timestamp22("lease_expires_at", { withTimezone: true }),
701
- createdAt: timestamp22("created_at", { withTimezone: true }).notNull().defaultNow(),
702
- updatedAt: timestamp22("updated_at", { withTimezone: true }).notNull().defaultNow(),
703
- completedAt: timestamp22("completed_at", { withTimezone: true })
704
- }, (table) => [
705
- index19("idx_agent_jobs_claim").on(table.userId, table.status, table.taskKind, table.createdAt),
706
- index19("idx_agent_jobs_dedupe").on(table.userId, table.taskKind, table.dedupeKey)
707
- ]);
708
-
709
- // ../../packages/db/dist/schema/tables/insights.js
710
- import { pgTable as pgTable23, text as text23, timestamp as timestamp23, jsonb as jsonb21, uuid as uuid22, index as index20, uniqueIndex as uniqueIndex8, integer as integer14, bigint as bigint3 } from "drizzle-orm/pg-core";
711
- var insightsJobs = pgTable23("insights_jobs", {
712
- id: uuid22("id").primaryKey().defaultRandom(),
713
- userId: uuid22("user_id").notNull(),
714
- status: text23("status").notNull().default("pending"),
715
- projectPath: text23("project_path"),
716
- // Canonical project identity (project_path-keying fragments one project across
717
- // worktrees/subdirs/cwds — migration 00104). Nullable: legacy/unlinked rows fall
718
- // back to project_path. Stamped at enqueue when resolvable.
719
- projectId: uuid22("project_id").references(() => projects.id, { onDelete: "set null" }),
720
- config: jsonb21("config").notNull().default({}),
721
- progress: jsonb21("progress").notNull().default({}),
722
- result: jsonb21("result"),
723
- error: text23("error"),
724
- attempts: integer14("attempts").notNull().default(0),
725
- graphileJobId: bigint3("graphile_job_id", { mode: "number" }),
726
- taskKind: text23("task_kind"),
727
- payload: jsonb21("payload"),
728
- claimedBy: text23("claimed_by"),
729
- claimedAt: timestamp23("claimed_at", { withTimezone: true }),
730
- leaseExpiresAt: timestamp23("lease_expires_at", { withTimezone: true }),
731
- createdAt: timestamp23("created_at", { withTimezone: true }).defaultNow(),
732
- updatedAt: timestamp23("updated_at", { withTimezone: true }).defaultNow(),
733
- completedAt: timestamp23("completed_at", { withTimezone: true })
734
- }, (table) => [
735
- index20("idx_insights_jobs_user").on(table.userId),
736
- index20("idx_insights_jobs_status").on(table.status),
737
- index20("idx_insights_jobs_pending").on(table.userId, table.status),
738
- index20("idx_insights_jobs_project").on(table.projectId)
739
- ]);
740
- var insightsReports = pgTable23("insights_reports", {
741
- id: uuid22("id").primaryKey().defaultRandom(),
742
- userId: uuid22("user_id").notNull(),
743
- projectPath: text23("project_path"),
744
- data: jsonb21("data").notNull(),
745
- reportHtml: text23("report_html"),
746
- createdAt: timestamp23("created_at", { withTimezone: true }).defaultNow()
747
- }, (table) => [
748
- index20("idx_insights_user").on(table.userId),
749
- index20("idx_insights_created").on(table.createdAt),
750
- uniqueIndex8("idx_insights_user_project").on(table.userId, table.projectPath)
751
- ]);
752
-
753
- // ../../packages/db/dist/schema/tables/api-keys.js
754
- import { pgTable as pgTable24, text as text24, timestamp as timestamp24, uuid as uuid23, index as index21, uniqueIndex as uniqueIndex9 } from "drizzle-orm/pg-core";
755
- var apiKeys = pgTable24("api_keys", {
756
- id: uuid23("id").primaryKey().defaultRandom(),
757
- userId: uuid23("user_id").notNull().references(() => profiles.id, { onDelete: "cascade" }),
758
- name: text24("name").notNull(),
759
- keyHash: text24("key_hash").notNull(),
760
- keyPrefix: text24("key_prefix").notNull(),
761
- lastUsedAt: timestamp24("last_used_at", { withTimezone: true }),
762
- expiresAt: timestamp24("expires_at", { withTimezone: true }),
763
- revokedAt: timestamp24("revoked_at", { withTimezone: true }),
764
- createdAt: timestamp24("created_at", { withTimezone: true }).defaultNow()
765
- }, (table) => [
766
- index21("idx_api_keys_user").on(table.userId),
767
- uniqueIndex9("idx_api_keys_hash").on(table.keyHash)
768
- ]);
769
-
770
- // ../../packages/db/dist/schema/tables/extension-auth-codes.js
771
- import { pgTable as pgTable25, text as text25, timestamp as timestamp25, uuid as uuid24, index as index22 } from "drizzle-orm/pg-core";
772
- var extensionAuthCodes = pgTable25("extension_auth_codes", {
773
- code: text25("code").primaryKey(),
774
- userId: uuid24("user_id").notNull().references(() => profiles.id, { onDelete: "cascade" }),
775
- editor: text25("editor"),
776
- email: text25("email"),
777
- expiresAt: timestamp25("expires_at", { withTimezone: true }).notNull(),
778
- createdAt: timestamp25("created_at", { withTimezone: true }).defaultNow()
779
- }, (table) => [
780
- index22("idx_ext_auth_codes_expiry").on(table.expiresAt)
781
- ]);
782
-
783
- // ../../packages/db/dist/schema/tables/eval-conversations.js
784
- import { pgTable as pgTable26, text as text26, timestamp as timestamp26, jsonb as jsonb22, uuid as uuid25, index as index23 } from "drizzle-orm/pg-core";
785
- var evalConversations = pgTable26("eval_conversations", {
786
- id: uuid25("id").primaryKey().defaultRandom(),
787
- evalTargetId: uuid25("eval_target_id").notNull().references(() => evalTargets.id, { onDelete: "cascade" }),
788
- userId: uuid25("user_id").notNull(),
789
- messages: jsonb22("messages").notNull().default([]),
790
- status: text26("status").notNull().default("active"),
791
- createdAt: timestamp26("created_at", { withTimezone: true }).defaultNow(),
792
- updatedAt: timestamp26("updated_at", { withTimezone: true }).defaultNow()
793
- }, (table) => [
794
- index23("idx_eval_conversations_target").on(table.evalTargetId),
795
- index23("idx_eval_conversations_user").on(table.userId)
796
- ]);
797
-
798
- // ../../packages/db/dist/schema/tables/security-events.js
799
- import { pgTable as pgTable27, uuid as uuid26, text as text27, jsonb as jsonb23, timestamp as timestamp27, index as index24 } from "drizzle-orm/pg-core";
800
- var securityEvents = pgTable27("security_events", {
801
- id: uuid26("id").primaryKey().defaultRandom(),
802
- eventType: text27("event_type").notNull(),
803
- severity: text27("severity").notNull(),
804
- category: text27("category").notNull(),
805
- source: text27("source").notNull(),
806
- entityType: text27("entity_type"),
807
- entityId: uuid26("entity_id"),
808
- userId: uuid26("user_id"),
809
- details: jsonb23("details").notNull().default({}),
810
- createdAt: timestamp27("created_at", { withTimezone: true }).notNull().defaultNow()
811
- }, (table) => [
812
- index24("idx_security_events_type").on(table.eventType),
813
- index24("idx_security_events_user").on(table.userId),
814
- index24("idx_security_events_created").on(table.createdAt),
815
- index24("idx_security_events_severity").on(table.severity),
816
- index24("idx_security_events_source").on(table.source)
817
- ]);
818
-
819
- // ../../packages/db/dist/schema/tables/tasks.js
820
- import { pgTable as pgTable28, text as text28, timestamp as timestamp28, uuid as uuid27, index as index25 } from "drizzle-orm/pg-core";
821
- var tasks = pgTable28("tasks", {
822
- id: uuid27("id").primaryKey().defaultRandom(),
823
- title: text28("title").notNull(),
824
- description: text28("description"),
825
- status: text28("status").notNull().default("pending"),
826
- createdBy: uuid27("created_by"),
827
- createdAt: timestamp28("created_at", { withTimezone: true }).defaultNow(),
828
- updatedAt: timestamp28("updated_at", { withTimezone: true }).defaultNow()
829
- }, (table) => [
830
- index25("tasks_created_by_idx").on(table.createdBy),
831
- index25("tasks_status_idx").on(table.status)
832
- ]);
833
-
834
- // ../../packages/db/dist/schema/tables/skill-submissions.js
835
- import { pgTable as pgTable29, text as text29, timestamp as timestamp29, jsonb as jsonb24, uuid as uuid28 } from "drizzle-orm/pg-core";
836
- var skillSubmissions = pgTable29("skill_submissions", {
837
- id: uuid28("id").primaryKey().defaultRandom(),
838
- skillId: text29("skill_id").notNull(),
839
- name: text29("name").notNull(),
840
- description: text29("description").notNull(),
841
- category: text29("category").notNull(),
842
- tools: text29("tools").array().notNull(),
843
- tags: text29("tags").array().default([]),
844
- content: text29("content").notNull(),
845
- status: text29("status").notNull().default("pending"),
846
- // pending | approved | rejected
847
- submittedBy: uuid28("submitted_by").notNull(),
848
- reviewedBy: uuid28("reviewed_by"),
849
- reviewNote: text29("review_note"),
850
- metadata: jsonb24("metadata"),
851
- createdAt: timestamp29("created_at", { withTimezone: true }).defaultNow(),
852
- updatedAt: timestamp29("updated_at", { withTimezone: true }).defaultNow()
853
- });
854
-
855
- // ../../packages/db/dist/schema/tables/harness-releases.js
856
- import { pgTable as pgTable30, text as text30, timestamp as timestamp30, jsonb as jsonb25, uuid as uuid29, uniqueIndex as uniqueIndex10, index as index26 } from "drizzle-orm/pg-core";
857
- var harnessReleases = pgTable30("harness_releases", {
858
- id: uuid29("id").primaryKey().defaultRandom(),
859
- harness: text30("harness").notNull(),
860
- // "claude_code", "cursor", "copilot"
861
- version: text30("version").notNull(),
862
- // "v2.1.119"
863
- publishedAt: timestamp30("published_at", { withTimezone: true }).notNull(),
864
- title: text30("title"),
865
- // release name
866
- body: text30("body"),
867
- // raw markdown
868
- categories: jsonb25("categories").default({}),
869
- // { features: string[], fixes: string[], security: string[] }
870
- url: text30("url"),
871
- // link to release page
872
- createdAt: timestamp30("created_at", { withTimezone: true }).defaultNow()
873
- }, (table) => [
874
- uniqueIndex10("idx_harness_releases_unique").on(table.harness, table.version),
875
- index26("idx_harness_releases_harness").on(table.harness),
876
- index26("idx_harness_releases_published").on(table.publishedAt)
877
- ]);
878
-
879
- // ../../packages/db/dist/schema/tables/notifications.js
880
- import { pgTable as pgTable31, text as text31, timestamp as timestamp31, jsonb as jsonb26, uuid as uuid30, index as index27, uniqueIndex as uniqueIndex11 } from "drizzle-orm/pg-core";
881
- var notifications = pgTable31("notifications", {
882
- id: uuid30("id").primaryKey().defaultRandom(),
883
- userId: uuid30("user_id").notNull(),
884
- type: text31("type").notNull(),
885
- title: text31("title").notNull(),
886
- body: text31("body"),
887
- url: text31("url"),
888
- sourceTable: text31("source_table"),
889
- sourceId: text31("source_id"),
890
- metadata: jsonb26("metadata").notNull().default({}),
891
- readAt: timestamp31("read_at", { withTimezone: true }),
892
- createdAt: timestamp31("created_at", { withTimezone: true }).notNull().defaultNow()
893
- }, (table) => [
894
- index27("idx_notifications_user_created").on(table.userId, table.createdAt),
895
- index27("idx_notifications_user_unread").on(table.userId),
896
- uniqueIndex11("idx_notifications_source_dedup").on(table.userId, table.sourceTable, table.sourceId)
897
- ]);
898
-
899
- // ../../packages/db/dist/schema/tables/launch-jobs.js
900
- import { pgTable as pgTable32, text as text32, timestamp as timestamp32, jsonb as jsonb27, uuid as uuid31, index as index28, integer as integer15, bigint as bigint4 } from "drizzle-orm/pg-core";
901
- var launchJobs = pgTable32("launch_jobs", {
902
- id: uuid31("id").primaryKey().defaultRandom(),
903
- userId: uuid31("user_id").notNull(),
904
- tool: text32("tool").notNull(),
905
- status: text32("status").notNull().default("pending"),
906
- config: jsonb27("config").notNull().default({}),
907
- result: jsonb27("result"),
908
- error: text32("error"),
909
- attempts: integer15("attempts").notNull().default(0),
910
- graphileJobId: bigint4("graphile_job_id", { mode: "number" }),
911
- taskKind: text32("task_kind"),
912
- payload: jsonb27("payload"),
913
- claimedBy: text32("claimed_by"),
914
- claimedAt: timestamp32("claimed_at", { withTimezone: true }),
915
- leaseExpiresAt: timestamp32("lease_expires_at", { withTimezone: true }),
916
- createdAt: timestamp32("created_at", { withTimezone: true }).defaultNow(),
917
- updatedAt: timestamp32("updated_at", { withTimezone: true }).defaultNow(),
918
- completedAt: timestamp32("completed_at", { withTimezone: true }),
919
- runId: uuid31("run_id").references(() => agentRuns.id, { onDelete: "set null" })
920
- }, (table) => [
921
- index28("idx_launch_jobs_user").on(table.userId),
922
- index28("idx_launch_jobs_status").on(table.status),
923
- index28("idx_launch_jobs_pending").on(table.userId, table.status),
924
- index28("idx_launch_jobs_run").on(table.runId)
925
- ]);
926
-
927
- // ../../packages/db/dist/schema/tables/instruction-suggestions.js
928
- import { pgTable as pgTable33, uuid as uuid32, text as text33, real as real3, timestamp as timestamp33, boolean as boolean9, uniqueIndex as uniqueIndex12, index as index29 } from "drizzle-orm/pg-core";
929
- var instructionSuggestions = pgTable33("instruction_suggestions", {
930
- id: uuid32("id").primaryKey().defaultRandom(),
931
- userId: uuid32("user_id").notNull().references(() => profiles.id, { onDelete: "cascade" }),
932
- instructionId: uuid32("instruction_id").notNull().references(() => instructions.id, { onDelete: "cascade" }),
933
- projectPath: text33("project_path").notNull(),
934
- // Canonical project identity (migration 00104). Additive + nullable; the
935
- // unique index below stays on project_path (NOT NULL) so upserts are
936
- // unchanged. Readers prefer project_id to aggregate across path variants.
937
- projectId: uuid32("project_id").references(() => projects.id, { onDelete: "set null" }),
938
- score: real3("score").notNull(),
939
- reason: text33("reason").notNull(),
940
- generatedAt: timestamp33("generated_at", { withTimezone: true }).notNull().defaultNow(),
941
- isStale: boolean9("is_stale").notNull().default(false),
942
- dismissedAt: timestamp33("dismissed_at", { withTimezone: true }),
943
- acceptedAt: timestamp33("accepted_at", { withTimezone: true }),
944
- promotedToInstructionId: uuid32("promoted_to_instruction_id").references(() => instructions.id, { onDelete: "set null" })
945
- }, (table) => [
946
- uniqueIndex12("idx_instruction_suggestions_user_project_instruction").on(table.userId, table.projectPath, table.instructionId),
947
- index29("idx_instruction_suggestions_user_project").on(table.userId, table.projectPath),
948
- index29("idx_instruction_suggestions_user_proj_id").on(table.userId, table.projectId),
949
- index29("idx_instruction_suggestions_generated_at").on(table.generatedAt)
950
- ]);
951
- var instructionSuggestionEvents = pgTable33("instruction_suggestion_events", {
952
- id: uuid32("id").primaryKey().defaultRandom(),
953
- suggestionId: uuid32("suggestion_id").notNull().references(() => instructionSuggestions.id, { onDelete: "cascade" }),
954
- userId: uuid32("user_id").notNull().references(() => profiles.id, { onDelete: "cascade" }),
955
- eventType: text33("event_type").notNull(),
956
- tool: text33("tool"),
957
- sessionId: uuid32("session_id"),
958
- projectPath: text33("project_path").notNull(),
959
- createdAt: timestamp33("created_at", { withTimezone: true }).notNull().defaultNow()
960
- }, (table) => [
961
- index29("idx_instruction_suggestion_events_suggestion_id").on(table.suggestionId),
962
- index29("idx_instruction_suggestion_events_user_id").on(table.userId)
963
- ]);
964
-
965
- // ../../packages/db/dist/schema/tables/model-pricing.js
966
- import { pgTable as pgTable34, text as text34, integer as integer16, numeric, timestamp as timestamp34, index as index30, primaryKey as primaryKey4 } from "drizzle-orm/pg-core";
967
- var modelPricing = pgTable34("model_pricing", {
968
- provider: text34("provider").notNull(),
969
- modelId: text34("model_id").notNull(),
970
- inputPerM: numeric("input_per_m").notNull(),
971
- outputPerM: numeric("output_per_m").notNull(),
972
- cacheReadPerM: numeric("cache_read_per_m").notNull(),
973
- cacheWrite5mPerM: numeric("cache_write_5m_per_m").notNull(),
974
- cacheWrite1hPerM: numeric("cache_write_1h_per_m").notNull(),
975
- contextWindow: integer16("context_window"),
976
- effectiveFrom: timestamp34("effective_from", { withTimezone: true }).notNull(),
977
- effectiveUntil: timestamp34("effective_until", { withTimezone: true }),
978
- source: text34("source").notNull()
979
- }, (table) => [
980
- primaryKey4({ columns: [table.provider, table.modelId, table.effectiveFrom] }),
981
- index30("idx_model_pricing_active").on(table.provider, table.modelId, table.effectiveFrom.desc())
982
- ]);
983
-
984
- // ../../packages/db/dist/schema/tables/limit-observations.js
985
- import { pgTable as pgTable35, text as text35, numeric as numeric2, timestamp as timestamp35, uuid as uuid33, jsonb as jsonb28, index as index31 } from "drizzle-orm/pg-core";
986
- var limitObservations = pgTable35("limit_observations", {
987
- id: uuid33("id").primaryKey().defaultRandom(),
988
- observedAt: timestamp35("observed_at", { withTimezone: true }).notNull().defaultNow(),
989
- provider: text35("provider").notNull(),
990
- plan: text35("plan").notNull(),
991
- limitType: text35("limit_type").notNull(),
992
- value: numeric2("value").notNull(),
993
- unit: text35("unit").notNull(),
994
- comparator: text35("comparator").notNull().default("="),
995
- resetsAt: timestamp35("resets_at", { withTimezone: true }),
996
- sourceType: text35("source_type").notNull(),
997
- sourceUrl: text35("source_url"),
998
- sourceEvidence: jsonb28("source_evidence"),
999
- confidence: numeric2("confidence").notNull(),
1000
- userId: uuid33("user_id")
1001
- }, (table) => [
1002
- index31("idx_limit_obs_lookup").on(table.provider, table.plan, table.limitType, table.observedAt.desc()),
1003
- index31("idx_limit_obs_user").on(table.userId, table.observedAt.desc())
1004
- ]);
1005
-
1006
- // ../../packages/db/dist/schema/tables/provider-docs-snapshots.js
1007
- import { pgTable as pgTable36, text as text36, timestamp as timestamp36, uuid as uuid34, jsonb as jsonb29, boolean as boolean10, uniqueIndex as uniqueIndex13 } from "drizzle-orm/pg-core";
1008
- var providerDocsSnapshots = pgTable36("provider_docs_snapshots", {
1009
- id: uuid34("id").primaryKey().defaultRandom(),
1010
- fetchedAt: timestamp36("fetched_at", { withTimezone: true }).notNull().defaultNow(),
1011
- provider: text36("provider").notNull(),
1012
- docUrl: text36("doc_url").notNull(),
1013
- contentHash: text36("content_hash").notNull(),
1014
- content: text36("content").notNull(),
1015
- parseSuccess: boolean10("parse_success").notNull(),
1016
- parseErrors: jsonb29("parse_errors")
1017
- }, (table) => [
1018
- uniqueIndex13("idx_docs_dedup").on(table.provider, table.docUrl, table.contentHash)
1019
- ]);
1020
-
1021
- // ../../packages/db/dist/schema/tables/plan-limits-active.js
1022
- import { pgTable as pgTable37, text as text37, numeric as numeric3, timestamp as timestamp37, uuid as uuid35, primaryKey as primaryKey5, index as index32 } from "drizzle-orm/pg-core";
1023
- var planLimitsActive = pgTable37("plan_limits_active", {
1024
- provider: text37("provider").notNull(),
1025
- plan: text37("plan").notNull(),
1026
- limitType: text37("limit_type").notNull(),
1027
- value: numeric3("value").notNull(),
1028
- unit: text37("unit").notNull(),
1029
- effectiveFrom: timestamp37("effective_from", { withTimezone: true }).notNull(),
1030
- effectiveUntil: timestamp37("effective_until", { withTimezone: true }),
1031
- confidence: numeric3("confidence").notNull(),
1032
- sourceObservationIds: uuid35("source_observation_ids").array().notNull()
1033
- }, (table) => [
1034
- primaryKey5({ columns: [table.provider, table.plan, table.limitType, table.effectiveFrom] }),
1035
- index32("idx_plan_limits_lookup").on(table.provider, table.plan, table.limitType, table.effectiveFrom.desc())
1036
- ]);
1037
-
1038
- // ../../packages/db/dist/schema/tables/alert-dispatches.js
1039
- import { pgTable as pgTable38, text as text38, timestamp as timestamp38, uuid as uuid36, jsonb as jsonb30, index as index33 } from "drizzle-orm/pg-core";
1040
- var alertDispatches = pgTable38("alert_dispatches", {
1041
- id: uuid36("id").primaryKey().defaultRandom(),
1042
- userId: uuid36("user_id").notNull(),
1043
- alertKey: text38("alert_key").notNull(),
1044
- // 'soft' | 'approaching' | 'imminent' | 'hit'
1045
- severity: text38("severity").notNull(),
1046
- lastDispatchedAt: timestamp38("last_dispatched_at", { withTimezone: true }).notNull().defaultNow(),
1047
- // { used_percentage, resets_at, ... } — snapshot of the input that fired this alert.
1048
- lastState: jsonb30("last_state").notNull(),
1049
- // 'in_app' | 'vscode' | 'banner'
1050
- channel: text38("channel").notNull()
1051
- }, (table) => [
1052
- index33("idx_alert_user_key").on(table.userId, table.alertKey, table.lastDispatchedAt.desc())
1053
- ]);
1054
-
1055
- // ../../packages/db/dist/client.js
1056
- import { drizzle } from "drizzle-orm/postgres-js";
1057
- import postgres from "postgres";
1058
-
1059
- // ../../packages/db/dist/schema/index.js
1060
- var schema_exports = {};
1061
- __export(schema_exports, {
1062
- agentJobs: () => agentJobs,
1063
- agentRuns: () => agentRuns,
1064
- agentRunsRelations: () => agentRunsRelations,
1065
- alertDispatches: () => alertDispatches,
1066
- announcementDeliveries: () => announcementDeliveries,
1067
- announcements: () => announcements,
1068
- apiKeys: () => apiKeys,
1069
- apiKeysRelations: () => apiKeysRelations,
1070
- benchmarks: () => benchmarks,
1071
- benchmarksRelations: () => benchmarksRelations,
1072
- cliErrorEvents: () => cliErrorEvents,
1073
- cliSetupEvents: () => cliSetupEvents,
1074
- contentBlobs: () => contentBlobs,
1075
- contextSnapshots: () => contextSnapshots,
1076
- contextSnapshotsRelations: () => contextSnapshotsRelations,
1077
- evalConversations: () => evalConversations,
1078
- evalConversationsRelations: () => evalConversationsRelations,
1079
- evalJobs: () => evalJobs,
1080
- evalJobsRelations: () => evalJobsRelations,
1081
- evalRuns: () => evalRuns,
1082
- evalRunsRelations: () => evalRunsRelations,
1083
- evalTargets: () => evalTargets,
1084
- evalTargetsRelations: () => evalTargetsRelations,
1085
- evals: () => evals,
1086
- evalsRelations: () => evalsRelations,
1087
- extensionAuthCodes: () => extensionAuthCodes,
1088
- harnessReleases: () => harnessReleases,
1089
- insightsJobs: () => insightsJobs,
1090
- insightsReports: () => insightsReports,
1091
- instructionEvents: () => instructionEvents,
1092
- instructionEventsRelations: () => instructionEventsRelations,
1093
- instructionSuggestionEvents: () => instructionSuggestionEvents,
1094
- instructionSuggestions: () => instructionSuggestions,
1095
- instructionUsageEvents: () => instructionUsageEvents,
1096
- instructionUsageEventsRelations: () => instructionUsageEventsRelations,
1097
- instructionVersions: () => instructionVersions,
1098
- instructionVersionsRelations: () => instructionVersionsRelations,
1099
- instructions: () => instructions,
1100
- instructionsRelations: () => instructionsRelations,
1101
- launchJobs: () => launchJobs,
1102
- launchJobsRelations: () => launchJobsRelations,
1103
- limitObservations: () => limitObservations,
1104
- modelPricing: () => modelPricing,
1105
- notificationPreferences: () => notificationPreferences,
1106
- notifications: () => notifications,
1107
- optimizationRuns: () => optimizationRuns,
1108
- optimizationRunsRelations: () => optimizationRunsRelations,
1109
- orgInvitations: () => orgInvitations,
1110
- orgInvitationsRelations: () => orgInvitationsRelations,
1111
- organizations: () => organizations,
1112
- organizationsRelations: () => organizationsRelations,
1113
- packInstructions: () => packInstructions,
1114
- packInstructionsRelations: () => packInstructionsRelations,
1115
- packs: () => packs,
1116
- packsRelations: () => packsRelations,
1117
- planLimitsActive: () => planLimitsActive,
1118
- profiles: () => profiles,
1119
- profilesRelations: () => profilesRelations,
1120
- projectCheckouts: () => projectCheckouts,
1121
- projectInstructions: () => projectInstructions,
1122
- projectInstructionsRelations: () => projectInstructionsRelations,
1123
- projects: () => projects,
1124
- projectsRelations: () => projectsRelations,
1125
- providerDocsSnapshots: () => providerDocsSnapshots,
1126
- securityEvents: () => securityEvents,
1127
- sessionEvents: () => sessionEvents,
1128
- sessionEventsRelations: () => sessionEventsRelations,
1129
- sessionInstructions: () => sessionInstructions,
1130
- sessionInstructionsRelations: () => sessionInstructionsRelations,
1131
- sessionSendJobs: () => sessionSendJobs,
1132
- sessionTerminalTargets: () => sessionTerminalTargets,
1133
- sessions: () => sessions,
1134
- sessionsRelations: () => sessionsRelations,
1135
- skillSubmissions: () => skillSubmissions,
1136
- tasks: () => tasks,
1137
- teams: () => teams,
1138
- teamsRelations: () => teamsRelations,
1139
- triggerEvals: () => triggerEvals,
1140
- triggerEvalsRelations: () => triggerEvalsRelations,
1141
- userOrganizations: () => userOrganizations,
1142
- userOrganizationsRelations: () => userOrganizationsRelations,
1143
- userTeams: () => userTeams,
1144
- userTeamsRelations: () => userTeamsRelations,
1145
- workerConnections: () => workerConnections
1146
- });
1147
-
1148
- // ../../packages/db/dist/schema/relations.js
1149
- import { relations } from "drizzle-orm";
1150
- var profilesRelations = relations(profiles, ({ many }) => ({
1151
- sessions: many(sessions),
1152
- contextSnapshots: many(contextSnapshots),
1153
- apiKeys: many(apiKeys)
1154
- }));
1155
- var apiKeysRelations = relations(apiKeys, ({ one }) => ({
1156
- profile: one(profiles, {
1157
- fields: [apiKeys.userId],
1158
- references: [profiles.id]
1159
- })
1160
- }));
1161
- var organizationsRelations = relations(organizations, ({ many }) => ({
1162
- teams: many(teams),
1163
- userOrganizations: many(userOrganizations),
1164
- projects: many(projects),
1165
- invitations: many(orgInvitations)
1166
- }));
1167
- var teamsRelations = relations(teams, ({ one, many }) => ({
1168
- organization: one(organizations, {
1169
- fields: [teams.orgId],
1170
- references: [organizations.id]
1171
- }),
1172
- userTeams: many(userTeams),
1173
- invitations: many(orgInvitations)
1174
- }));
1175
- var orgInvitationsRelations = relations(orgInvitations, ({ one }) => ({
1176
- organization: one(organizations, {
1177
- fields: [orgInvitations.orgId],
1178
- references: [organizations.id]
1179
- }),
1180
- team: one(teams, {
1181
- fields: [orgInvitations.teamId],
1182
- references: [teams.id]
1183
- }),
1184
- inviter: one(profiles, {
1185
- fields: [orgInvitations.invitedBy],
1186
- references: [profiles.id]
1187
- })
1188
- }));
1189
- var userOrganizationsRelations = relations(userOrganizations, ({ one }) => ({
1190
- organization: one(organizations, {
1191
- fields: [userOrganizations.orgId],
1192
- references: [organizations.id]
1193
- })
1194
- }));
1195
- var userTeamsRelations = relations(userTeams, ({ one }) => ({
1196
- team: one(teams, {
1197
- fields: [userTeams.teamId],
1198
- references: [teams.id]
1199
- })
1200
- }));
1201
- var instructionsRelations = relations(instructions, ({ one, many }) => ({
1202
- versions: many(instructionVersions),
1203
- projectInstructions: many(projectInstructions),
1204
- events: many(instructionEvents),
1205
- usageEvents: many(instructionUsageEvents),
1206
- sessionInstructions: many(sessionInstructions),
1207
- packInstructions: many(packInstructions),
1208
- forkedFrom: one(instructions, {
1209
- fields: [instructions.forkedFromId],
1210
- references: [instructions.id]
1211
- })
1212
- }));
1213
- var instructionEventsRelations = relations(instructionEvents, ({ one }) => ({
1214
- instruction: one(instructions, {
1215
- fields: [instructionEvents.instructionId],
1216
- references: [instructions.id]
1217
- })
1218
- }));
1219
- var instructionVersionsRelations = relations(instructionVersions, ({ one }) => ({
1220
- instruction: one(instructions, {
1221
- fields: [instructionVersions.instructionId],
1222
- references: [instructions.id]
1223
- })
1224
- }));
1225
- var projectsRelations = relations(projects, ({ one, many }) => ({
1226
- organization: one(organizations, {
1227
- fields: [projects.orgId],
1228
- references: [organizations.id]
1229
- }),
1230
- projectInstructions: many(projectInstructions),
1231
- sessions: many(sessions)
1232
- }));
1233
- var projectInstructionsRelations = relations(projectInstructions, ({ one }) => ({
1234
- project: one(projects, {
1235
- fields: [projectInstructions.projectId],
1236
- references: [projects.id]
1237
- }),
1238
- instruction: one(instructions, {
1239
- fields: [projectInstructions.instructionId],
1240
- references: [instructions.id]
1241
- })
1242
- }));
1243
- var sessionsRelations = relations(sessions, ({ one, many }) => ({
1244
- profile: one(profiles, {
1245
- fields: [sessions.userId],
1246
- references: [profiles.id]
1247
- }),
1248
- project: one(projects, {
1249
- fields: [sessions.projectId],
1250
- references: [projects.id]
1251
- }),
1252
- run: one(agentRuns, {
1253
- fields: [sessions.runId],
1254
- references: [agentRuns.id]
1255
- }),
1256
- events: many(sessionEvents),
1257
- sessionInstructions: many(sessionInstructions),
1258
- contextSnapshots: many(contextSnapshots)
1259
- }));
1260
- var agentRunsRelations = relations(agentRuns, ({ one, many }) => ({
1261
- profile: one(profiles, {
1262
- fields: [agentRuns.userId],
1263
- references: [profiles.id]
1264
- }),
1265
- organization: one(organizations, {
1266
- fields: [agentRuns.orgId],
1267
- references: [organizations.id]
1268
- }),
1269
- project: one(projects, {
1270
- fields: [agentRuns.projectId],
1271
- references: [projects.id]
1272
- }),
1273
- sessions: many(sessions),
1274
- launchJobs: many(launchJobs)
1275
- }));
1276
- var launchJobsRelations = relations(launchJobs, ({ one }) => ({
1277
- run: one(agentRuns, {
1278
- fields: [launchJobs.runId],
1279
- references: [agentRuns.id]
1280
- })
1281
- }));
1282
- var sessionEventsRelations = relations(sessionEvents, ({ one }) => ({
1283
- session: one(sessions, {
1284
- fields: [sessionEvents.sessionId],
1285
- references: [sessions.id]
1286
- })
1287
- }));
1288
- var sessionInstructionsRelations = relations(sessionInstructions, ({ one }) => ({
1289
- session: one(sessions, {
1290
- fields: [sessionInstructions.sessionId],
1291
- references: [sessions.id]
1292
- }),
1293
- instruction: one(instructions, {
1294
- fields: [sessionInstructions.instructionId],
1295
- references: [instructions.id]
1296
- })
1297
- }));
1298
- var packsRelations = relations(packs, ({ one, many }) => ({
1299
- packInstructions: many(packInstructions),
1300
- forkedFrom: one(packs, {
1301
- fields: [packs.forkedFromId],
1302
- references: [packs.id]
1303
- })
1304
- }));
1305
- var packInstructionsRelations = relations(packInstructions, ({ one }) => ({
1306
- pack: one(packs, {
1307
- fields: [packInstructions.packId],
1308
- references: [packs.id]
1309
- }),
1310
- instruction: one(instructions, {
1311
- fields: [packInstructions.instructionId],
1312
- references: [instructions.id]
1313
- })
1314
- }));
1315
- var instructionUsageEventsRelations = relations(instructionUsageEvents, ({ one }) => ({
1316
- instruction: one(instructions, {
1317
- fields: [instructionUsageEvents.instructionId],
1318
- references: [instructions.id]
1319
- })
1320
- }));
1321
- var evalTargetsRelations = relations(evalTargets, ({ one, many }) => ({
1322
- parent: one(evalTargets, {
1323
- fields: [evalTargets.parentId],
1324
- references: [evalTargets.id]
1325
- }),
1326
- evals: many(evals),
1327
- evalRuns: many(evalRuns),
1328
- benchmarks: many(benchmarks),
1329
- triggerEvals: many(triggerEvals),
1330
- optimizationRuns: many(optimizationRuns),
1331
- evalJobs: many(evalJobs),
1332
- evalConversations: many(evalConversations)
1333
- }));
1334
- var evalsRelations = relations(evals, ({ one, many }) => ({
1335
- evalTarget: one(evalTargets, {
1336
- fields: [evals.evalTargetId],
1337
- references: [evalTargets.id]
1338
- }),
1339
- runs: many(evalRuns)
1340
- }));
1341
- var evalRunsRelations = relations(evalRuns, ({ one }) => ({
1342
- eval: one(evals, {
1343
- fields: [evalRuns.evalId],
1344
- references: [evals.id]
1345
- }),
1346
- evalTarget: one(evalTargets, {
1347
- fields: [evalRuns.evalTargetId],
1348
- references: [evalTargets.id]
1349
- })
1350
- }));
1351
- var benchmarksRelations = relations(benchmarks, ({ one }) => ({
1352
- evalTarget: one(evalTargets, {
1353
- fields: [benchmarks.evalTargetId],
1354
- references: [evalTargets.id]
1355
- })
1356
- }));
1357
- var triggerEvalsRelations = relations(triggerEvals, ({ one }) => ({
1358
- evalTarget: one(evalTargets, {
1359
- fields: [triggerEvals.evalTargetId],
1360
- references: [evalTargets.id]
1361
- })
1362
- }));
1363
- var optimizationRunsRelations = relations(optimizationRuns, ({ one }) => ({
1364
- evalTarget: one(evalTargets, {
1365
- fields: [optimizationRuns.evalTargetId],
1366
- references: [evalTargets.id]
1367
- })
1368
- }));
1369
- var evalJobsRelations = relations(evalJobs, ({ one }) => ({
1370
- evalTarget: one(evalTargets, {
1371
- fields: [evalJobs.evalTargetId],
1372
- references: [evalTargets.id]
1373
- })
1374
- }));
1375
- var evalConversationsRelations = relations(evalConversations, ({ one }) => ({
1376
- evalTarget: one(evalTargets, {
1377
- fields: [evalConversations.evalTargetId],
1378
- references: [evalTargets.id]
1379
- })
1380
- }));
1381
- var contextSnapshotsRelations = relations(contextSnapshots, ({ one }) => ({
1382
- session: one(sessions, {
1383
- fields: [contextSnapshots.sessionId],
1384
- references: [sessions.id]
1385
- }),
1386
- profile: one(profiles, {
1387
- fields: [contextSnapshots.userId],
1388
- references: [profiles.id]
1389
- })
1390
- }));
1391
-
1392
- // ../../packages/db/dist/db-load.js
1393
- var _inFlight = 0;
1394
- var _peak = 0;
1395
- var _heavyInFlight = 0;
1396
- var _heavyPeak = 0;
1397
- function trackDbOpStart() {
1398
- _inFlight++;
1399
- if (_inFlight > _peak)
1400
- _peak = _inFlight;
1401
- }
1402
- function trackDbOpEnd() {
1403
- if (_inFlight > 0)
1404
- _inFlight--;
1405
- }
1406
- function trackHeavyDbOpStart() {
1407
- _heavyInFlight++;
1408
- if (_heavyInFlight > _heavyPeak)
1409
- _heavyPeak = _heavyInFlight;
1410
- }
1411
- function trackHeavyDbOpEnd() {
1412
- if (_heavyInFlight > 0)
1413
- _heavyInFlight--;
1414
- }
1415
-
1416
- // ../../packages/db/dist/client.js
1417
- var _db;
1418
- var _client;
1419
- var _closed = false;
1420
- var _closing;
1421
- var _probeClient;
1422
- var _heavyClient;
1423
- var _heavyDb;
1424
- function getEnv(name) {
1425
- const value = process.env[name];
1426
- if (!value)
1427
- throw new Error(`Missing required env var: ${name}`);
1428
- return value;
1429
- }
1430
- function getDb() {
1431
- if (_closed) {
1432
- throw new Error("getDb() called after closeDb(): the connection pool is closed for shutdown. Stop issuing queries (timers/requests) before draining the pool.");
1433
- }
1434
- if (!_db) {
1435
- const appName = process.env.PG_APPLICATION_NAME || "rulemetric";
1436
- const max = Number(process.env.PG_POOL_MAX) || 3;
1437
- const connectTimeoutS = Number(process.env.PG_CONNECT_TIMEOUT_S) || 10;
1438
- const statementTimeoutMs = Number(process.env.PG_STATEMENT_TIMEOUT_MS) || 0;
1439
- const idleTimeoutS = Number(process.env.PG_IDLE_TIMEOUT) || 5;
1440
- const keepAliveS = Number(process.env.PG_KEEP_ALIVE_S) || 60;
1441
- _client = postgres(getEnv("DATABASE_URL"), {
1442
- prepare: false,
1443
- max,
1444
- connect_timeout: connectTimeoutS,
1445
- idle_timeout: idleTimeoutS,
1446
- keep_alive: keepAliveS,
1447
- // Hard rotation cap. Even active connections get closed and replaced
1448
- // after 5 minutes, defending against long-lived sockets that Supavisor
1449
- // marks stale for reasons unrelated to idleness (max-lifetime, server
1450
- // restart, network blip).
1451
- max_lifetime: 300,
1452
- connection: {
1453
- application_name: appName,
1454
- // postgres-js applies this as the server-side statement_timeout (ms).
1455
- ...statementTimeoutMs > 0 ? { statement_timeout: statementTimeoutMs } : {}
1456
- }
1457
- });
1458
- _db = drizzle(_client, { schema: schema_exports });
1459
- }
1460
- return _db;
1461
- }
1462
- function getHeavyDb() {
1463
- if (_closed) {
1464
- throw new Error("getHeavyDb() called after closeDb(): the connection pool is closed for shutdown. Stop issuing queries (timers/requests) before draining the pool.");
1465
- }
1466
- if (!_heavyDb) {
1467
- const appName = (process.env.PG_APPLICATION_NAME || "rulemetric") + ":heavy";
1468
- const max = Number(process.env.PG_HEAVY_POOL_MAX) || 2;
1469
- _heavyClient = postgres(getEnv("DATABASE_URL"), {
1470
- prepare: false,
1471
- max,
1472
- connect_timeout: Number(process.env.PG_CONNECT_TIMEOUT_S) || 10,
1473
- idle_timeout: Number(process.env.PG_IDLE_TIMEOUT) || 5,
1474
- keep_alive: Number(process.env.PG_KEEP_ALIVE_S) || 60,
1475
- max_lifetime: 300,
1476
- connection: {
1477
- application_name: appName
1478
- // Deliberately NO statement_timeout — these ARE the legitimately-long
1479
- // reads this pool exists to host. The DB role's 120s timeout is the
1480
- // ultimate backstop.
1481
- }
1482
- });
1483
- _heavyDb = drizzle(_heavyClient, { schema: schema_exports });
1484
- }
1485
- return _heavyDb;
1486
- }
1487
- async function closeDb() {
1488
- if (_closing)
1489
- return _closing;
1490
- _closed = true;
1491
- const c = _client;
1492
- const p = _probeClient;
1493
- const h = _heavyClient;
1494
- _client = void 0;
1495
- _db = void 0;
1496
- _probeClient = void 0;
1497
- _heavyClient = void 0;
1498
- _heavyDb = void 0;
1499
- _closing = Promise.allSettled([
1500
- c ? c.end({ timeout: 5 }) : Promise.resolve(),
1501
- p ? p.end({ timeout: 5 }) : Promise.resolve(),
1502
- h ? h.end({ timeout: 5 }) : Promise.resolve()
1503
- ]).then(() => {
1504
- });
1505
- return _closing;
1506
- }
1507
- var RETRYABLE_CONNECT_CODES = /* @__PURE__ */ new Set([
1508
- "CONNECT_TIMEOUT",
1509
- "ETIMEDOUT",
1510
- "ENOTFOUND",
1511
- "ECONNREFUSED",
1512
- "EAI_AGAIN"
1513
- ]);
1514
- function isRetryableConnectError(err) {
1515
- const e = err;
1516
- const code = e?.code ?? e?.cause?.code ?? e?.errno;
1517
- return code !== void 0 && RETRYABLE_CONNECT_CODES.has(code);
1518
- }
1519
- var RETRYABLE_RESET_CODES = /* @__PURE__ */ new Set(["CONNECTION_CLOSED", "ECONNRESET", "EPIPE"]);
1520
- function isRetryableResetError(err) {
1521
- const e = err;
1522
- const code = e?.code ?? e?.cause?.code ?? e?.errno;
1523
- return code !== void 0 && RETRYABLE_RESET_CODES.has(code);
1524
- }
1525
- async function withDbRetry(fn, opts = {}) {
1526
- const attempts = opts.attempts ?? 3;
1527
- const baseMs = opts.baseMs ?? 100;
1528
- let lastErr;
1529
- for (let i = 0; i < attempts; i++) {
1530
- try {
1531
- return await fn();
1532
- } catch (err) {
1533
- lastErr = err;
1534
- const retryable = isRetryableConnectError(err) || opts.retryResets === true && isRetryableResetError(err);
1535
- if (i === attempts - 1 || !retryable)
1536
- throw err;
1537
- await new Promise((resolve) => setTimeout(resolve, baseMs * 2 ** i));
1538
- }
1539
- }
1540
- throw lastErr;
1541
- }
1542
- var QueryDeadlineError = class extends Error {
1543
- code = "QUERY_DEADLINE";
1544
- constructor(ms) {
1545
- super(`Query exceeded the client-side deadline of ${ms}ms \u2014 the DB pool is likely saturated (acquire-wait) or holding a dead socket; failing fast to avoid pinning the caller. See client.ts.`);
1546
- this.name = "QueryDeadlineError";
1547
- }
1548
- };
1549
- function queryDeadlineMs() {
1550
- const explicit = Number(process.env.PG_QUERY_DEADLINE_MS);
1551
- if (Number.isFinite(explicit) && explicit >= 0)
1552
- return explicit;
1553
- return 2e4;
1554
- }
1555
- function raceWithDeadline(p, ms) {
1556
- let timer;
1557
- const deadline = new Promise((_, reject) => {
1558
- timer = setTimeout(() => reject(new QueryDeadlineError(ms)), ms);
1559
- const t = timer;
1560
- if (typeof t.unref === "function")
1561
- t.unref();
1562
- });
1563
- return Promise.race([p, deadline]).finally(() => clearTimeout(timer));
1564
- }
1565
- var RETRY_ENTRY_METHODS = /* @__PURE__ */ new Set([
1566
- "select",
1567
- "selectDistinct",
1568
- "selectDistinctOn",
1569
- "insert",
1570
- "update",
1571
- "delete",
1572
- "execute",
1573
- "with",
1574
- "$count",
1575
- "refreshMaterializedView"
1576
- ]);
1577
- var READ_ONLY_ENTRY_METHODS = /* @__PURE__ */ new Set([
1578
- "select",
1579
- "selectDistinct",
1580
- "selectDistinctOn",
1581
- "$count"
1582
- ]);
1583
- function wrapBuilder(value, readSafe = false, deadlineMs = 0, heavyPool = false) {
1584
- if (value === null || typeof value !== "object" && typeof value !== "function") {
1585
- return value;
1586
- }
1587
- return new Proxy(value, {
1588
- get(target, prop, receiver) {
1589
- if (prop === "then") {
1590
- const then = Reflect.get(target, prop, receiver);
1591
- if (typeof then !== "function")
1592
- return then;
1593
- return (onFulfilled, onRejected) => {
1594
- const opStart = heavyPool ? trackHeavyDbOpStart : trackDbOpStart;
1595
- const opEnd = heavyPool ? trackHeavyDbOpEnd : trackDbOpEnd;
1596
- opStart();
1597
- const exec = withDbRetry(() => new Promise((resolve, reject) => then.call(target, resolve, reject)), { retryResets: readSafe });
1598
- const guarded = deadlineMs > 0 ? raceWithDeadline(exec, deadlineMs) : exec;
1599
- return guarded.finally(opEnd).then(onFulfilled, onRejected);
1600
- };
1601
- }
1602
- const v = Reflect.get(target, prop, receiver);
1603
- if (typeof v === "function") {
1604
- return (...args) => wrapBuilder(v.apply(target, args), readSafe, deadlineMs, heavyPool);
1605
- }
1606
- return v;
1607
- }
1608
- });
1609
- }
1610
- function gaugeTransaction(run, heavyPool = false) {
1611
- const opStart = heavyPool ? trackHeavyDbOpStart : trackDbOpStart;
1612
- const opEnd = heavyPool ? trackHeavyDbOpEnd : trackDbOpEnd;
1613
- opStart();
1614
- try {
1615
- return Promise.resolve(run()).finally(opEnd);
1616
- } catch (err) {
1617
- opEnd();
1618
- throw err;
1619
- }
1620
- }
1621
- var db = new Proxy({}, {
1622
- get(_target, prop) {
1623
- const real4 = getDb();
1624
- const value = real4[prop];
1625
- if (typeof prop === "string" && RETRY_ENTRY_METHODS.has(prop) && typeof value === "function") {
1626
- const readSafe = READ_ONLY_ENTRY_METHODS.has(prop);
1627
- const deadlineMs = queryDeadlineMs();
1628
- return (...args) => wrapBuilder(value.apply(real4, args), readSafe, deadlineMs);
1629
- }
1630
- if (prop === "transaction" && typeof value === "function") {
1631
- return (...args) => gaugeTransaction(() => value.apply(real4, args));
1632
- }
1633
- return value;
1634
- }
1635
- });
1636
- var heavyDb = new Proxy({}, {
1637
- get(_target, prop) {
1638
- const real4 = getHeavyDb();
1639
- const value = real4[prop];
1640
- if (typeof prop === "string" && RETRY_ENTRY_METHODS.has(prop) && typeof value === "function") {
1641
- const readSafe = READ_ONLY_ENTRY_METHODS.has(prop);
1642
- return (...args) => wrapBuilder(value.apply(real4, args), readSafe, 0, true);
1643
- }
1644
- if (prop === "transaction" && typeof value === "function") {
1645
- return (...args) => gaugeTransaction(() => value.apply(real4, args), true);
1646
- }
1647
- return value;
1648
- }
1649
- });
1650
-
1651
- export {
1652
- profiles,
1653
- agentRuns,
1654
- sessions,
1655
- sessionEvents,
1656
- announcements,
1657
- announcementDeliveries,
1658
- notificationPreferences,
1659
- getDb,
1660
- closeDb
1661
- };
1662
- //# sourceMappingURL=chunk-EI5BHWXA.js.map