@rulemetric/cli 0.7.3 → 0.7.4

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 (547) hide show
  1. package/dist/base-command.js +1 -14
  2. package/dist/chunk-2TC6WCUT.js +34 -0
  3. package/dist/chunk-2UC3ULIG.js +1 -0
  4. package/dist/chunk-3AV3GTMP.js +1 -0
  5. package/dist/chunk-4Z5ECCJE.js +1 -0
  6. package/dist/chunk-5RBLIVBF.js +1 -0
  7. package/dist/chunk-67QCYUJU.js +1 -0
  8. package/dist/chunk-6QKI756T.js +2 -0
  9. package/dist/chunk-6V4WM73L.js +1 -0
  10. package/dist/chunk-6XEC6474.js +1 -0
  11. package/dist/chunk-72XLQE3X.js +2 -0
  12. package/dist/chunk-7DFNBRLY.js +61 -0
  13. package/dist/chunk-7XQ4VPLC.js +2 -0
  14. package/dist/chunk-AHRHCERJ.js +1 -0
  15. package/dist/chunk-ARNZQBMX.js +1 -0
  16. package/dist/chunk-CADKBP3D.js +58 -0
  17. package/dist/chunk-CDI5CCHU.js +1 -0
  18. package/dist/chunk-CNQ5DTNC.js +1 -0
  19. package/dist/chunk-CRAKDQ4H.js +1 -0
  20. package/dist/chunk-DNF4HDI6.js +14 -0
  21. package/dist/chunk-DSO2U4Y6.js +56 -0
  22. package/dist/chunk-DT4GKEP5.js +5 -0
  23. package/dist/chunk-DVN7GFJG.js +1 -0
  24. package/dist/chunk-E4SFUPYR.js +15 -0
  25. package/dist/chunk-EUHNCVJQ.js +33 -0
  26. package/dist/chunk-F2VP4B4J.js +1 -0
  27. package/dist/chunk-FEHM5OKW.js +1 -0
  28. package/dist/chunk-FHVBTDBM.js +69 -0
  29. package/dist/chunk-GBMF3TP6.js +1 -0
  30. package/dist/chunk-GY5IJ4RS.js +1 -0
  31. package/dist/chunk-HOHD5HY2.js +5 -0
  32. package/dist/chunk-HP2BUPGS.js +24 -0
  33. package/dist/{chunk-OQBBVTDG.js → chunk-I2DZGJRR.js} +6 -71
  34. package/dist/chunk-I4YJ7NTX.js +1 -0
  35. package/dist/chunk-IY5NXR3N.js +1 -0
  36. package/dist/chunk-IZTIYR5Q.js +2 -0
  37. package/dist/chunk-KKDHD4XA.js +2 -0
  38. package/dist/chunk-LQRYQE6Q.js +4 -0
  39. package/dist/chunk-M6AJDVCL.js +5 -0
  40. package/dist/chunk-MGHFDHHM.js +1 -0
  41. package/dist/chunk-ML36XQW7.js +1 -0
  42. package/dist/chunk-MODXEGCU.js +1 -0
  43. package/dist/chunk-MVM6OGAF.js +4 -0
  44. package/dist/chunk-N7ODX6PO.js +1 -0
  45. package/dist/chunk-NBTC5FNV.js +1 -0
  46. package/dist/chunk-NJ5UED3H.js +1 -0
  47. package/dist/chunk-NVKX36YN.js +3 -0
  48. package/dist/chunk-NVOTOQBA.js +1 -0
  49. package/dist/chunk-O7ZMHCMG.js +31 -0
  50. package/dist/chunk-OMXUK4M6.js +1 -0
  51. package/dist/chunk-PZS2KOU7.js +1 -0
  52. package/dist/chunk-RSKQRVPJ.js +1 -0
  53. package/dist/chunk-RTEATXTP.js +1 -0
  54. package/dist/chunk-RTWRHIKY.js +7 -0
  55. package/dist/chunk-RVO4HV3M.js +1 -0
  56. package/dist/chunk-SBILN45P.js +1 -0
  57. package/dist/chunk-SZ62CP55.js +1 -0
  58. package/dist/chunk-T3W5N3BP.js +2 -0
  59. package/dist/chunk-TDD7IOV2.js +1 -0
  60. package/dist/chunk-TIQ7DQ3M.js +1 -0
  61. package/dist/chunk-TU2AR6XO.js +1 -0
  62. package/dist/chunk-UF6US7VU.js +1 -0
  63. package/dist/chunk-V5QFOF4F.js +9 -0
  64. package/dist/chunk-V5U3E4BZ.js +1 -0
  65. package/dist/chunk-VAFAH6QL.js +1 -0
  66. package/dist/chunk-VMWY7KHH.js +1 -0
  67. package/dist/chunk-VUGRXM7R.js +1 -0
  68. package/dist/{chunk-XZXS2W24.js → chunk-VWEXKDWG.js} +10 -56
  69. package/dist/chunk-W2MV25SB.js +1 -0
  70. package/dist/chunk-WJ3H73G6.js +1 -0
  71. package/dist/chunk-WJUQBMTF.js +9 -0
  72. package/dist/chunk-WLVQJH4E.js +1 -0
  73. package/dist/chunk-WPJ2BND4.js +1 -0
  74. package/dist/chunk-WSCK4WNK.js +1 -0
  75. package/dist/chunk-Y65CSJFF.js +3 -0
  76. package/dist/chunk-ZL4MZMUK.js +34 -0
  77. package/dist/chunk-ZLLER3HP.js +1 -0
  78. package/dist/chunk-ZXF5NE54.js +1 -0
  79. package/dist/commands/antigravity/backfill.js +2 -136
  80. package/dist/commands/auth/create-key.js +1 -52
  81. package/dist/commands/auth/login.js +1 -85
  82. package/dist/commands/auth/logout.js +1 -29
  83. package/dist/commands/auth/revoke-key.js +1 -33
  84. package/dist/commands/auth/signup.js +1 -89
  85. package/dist/commands/auth/status.js +1 -42
  86. package/dist/commands/catalog/index.js +2 -52
  87. package/dist/commands/catalog/recommend.js +3 -43
  88. package/dist/commands/convert.js +1 -75
  89. package/dist/commands/converters.js +1 -54
  90. package/dist/commands/crons/list.js +1 -41
  91. package/dist/commands/crons/run.js +2 -76
  92. package/dist/commands/dashboard.js +1 -46
  93. package/dist/commands/diagnostics.js +1 -117
  94. package/dist/commands/eval-targets/create.js +1 -53
  95. package/dist/commands/eval-targets/list.js +1 -54
  96. package/dist/commands/evals/agent.js +3 -310
  97. package/dist/commands/evals/benchmark.js +6 -73
  98. package/dist/commands/evals/compare.js +13 -96
  99. package/dist/commands/evals/create.js +1 -67
  100. package/dist/commands/evals/optimize-description.js +25 -239
  101. package/dist/commands/evals/optimize.js +5 -211
  102. package/dist/commands/evals/run.js +3 -183
  103. package/dist/commands/gateway/ensure.js +1 -104
  104. package/dist/commands/hooks/emit-instructions.js +1 -25
  105. package/dist/commands/hooks/install.js +1 -442
  106. package/dist/commands/hooks/run.js +3 -81
  107. package/dist/commands/hooks/uninstall.js +2 -156
  108. package/dist/commands/import.js +1 -66
  109. package/dist/commands/instructions/create.js +1 -74
  110. package/dist/commands/instructions/delete.js +1 -55
  111. package/dist/commands/instructions/fork.js +1 -34
  112. package/dist/commands/instructions/get.js +1 -68
  113. package/dist/commands/instructions/list.js +1 -65
  114. package/dist/commands/instructions/promote.js +1 -42
  115. package/dist/commands/instructions/pull.js +1 -39
  116. package/dist/commands/instructions/upstream.js +1 -38
  117. package/dist/commands/instructions/versions.js +1 -53
  118. package/dist/commands/launcher.js +1 -40
  119. package/dist/commands/org/current.js +1 -77
  120. package/dist/commands/org/list.js +1 -52
  121. package/dist/commands/org/switch.js +1 -71
  122. package/dist/commands/packs/add-instruction.js +1 -37
  123. package/dist/commands/packs/apply.js +1 -39
  124. package/dist/commands/packs/create.js +1 -50
  125. package/dist/commands/packs/fork.js +1 -34
  126. package/dist/commands/packs/get.js +3 -56
  127. package/dist/commands/packs/list.js +1 -66
  128. package/dist/commands/packs/remove-instruction.js +1 -35
  129. package/dist/commands/proxy/env.js +3 -131
  130. package/dist/commands/proxy/logs.js +3 -85
  131. package/dist/commands/proxy/restart.js +1 -35
  132. package/dist/commands/proxy/setup.js +15 -454
  133. package/dist/commands/proxy/start.js +10 -333
  134. package/dist/commands/proxy/status.js +1 -78
  135. package/dist/commands/proxy/stop.js +1 -94
  136. package/dist/commands/research/backfill.js +1 -59
  137. package/dist/commands/research/tail-transcript.js +1 -70
  138. package/dist/commands/service/install.js +57 -796
  139. package/dist/commands/service/status.js +1 -180
  140. package/dist/commands/service/uninstall.js +1 -119
  141. package/dist/commands/sessions/analyze.js +3 -48
  142. package/dist/commands/sessions/end.js +2 -85
  143. package/dist/commands/sessions/import.js +1 -46
  144. package/dist/commands/sessions/list.js +1 -48
  145. package/dist/commands/sessions/start.js +3 -90
  146. package/dist/commands/setup.js +3 -150
  147. package/dist/commands/skills/export-approved.js +1 -46
  148. package/dist/commands/skills/install.js +4 -107
  149. package/dist/commands/skills/list.js +4 -65
  150. package/dist/commands/skills/publish.js +2 -98
  151. package/dist/commands/skills/search.js +3 -72
  152. package/dist/commands/skills/update.js +3 -55
  153. package/dist/commands/suggestions/accept.js +8 -84
  154. package/dist/commands/suggestions/dismiss.js +1 -45
  155. package/dist/commands/suggestions/list.js +1 -61
  156. package/dist/commands/suggestions/refresh.js +1 -27
  157. package/dist/cursor-T7AMCMKS.js +13 -0
  158. package/dist/dashboard/Dashboard.js +1 -243
  159. package/dist/dashboard/data.js +1 -15
  160. package/dist/dashboard/launcher/ActiveJobsList.js +1 -10
  161. package/dist/dashboard/launcher/LauncherOverlay.js +1 -16
  162. package/dist/dashboard/launcher/NewLaunchForm.js +1 -10
  163. package/dist/dashboard/launcher/api.js +1 -16
  164. package/dist/dashboard/launcher/tool-labels.js +1 -10
  165. package/dist/dashboard/launcher/types.js +0 -1
  166. package/dist/dashboard/launcher/useLaunchJobs.js +1 -11
  167. package/dist/dashboard/panels/friction.js +1 -10
  168. package/dist/dashboard/panels/insights.js +1 -10
  169. package/dist/dashboard/panels/instructions.js +1 -10
  170. package/dist/dashboard/panels/outcomes.js +1 -10
  171. package/dist/dashboard/panels/overview.js +1 -10
  172. package/dist/dashboard/panels/shared.js +1 -19
  173. package/dist/dashboard/types.js +1 -24
  174. package/dist/dist-FAVALJ5C.js +1 -0
  175. package/dist/index.js +1 -8
  176. package/dist/lib/active-org-refresh.js +1 -15
  177. package/dist/lib/active-org.js +1 -16
  178. package/dist/lib/agent-loop.js +1 -47
  179. package/dist/lib/antigravity-transcript.js +1 -22
  180. package/dist/lib/api-client.js +1 -23
  181. package/dist/lib/auth.js +1 -30
  182. package/dist/lib/capture-hosts.js +1 -8
  183. package/dist/lib/detect-languages.js +1 -8
  184. package/dist/lib/detect-tmux.js +1 -9
  185. package/dist/lib/diagnostics.js +1 -12
  186. package/dist/lib/editor-proxy-pins.js +1 -14
  187. package/dist/lib/ensure-api-key.js +1 -11
  188. package/dist/lib/eval-analyzer.js +1 -9
  189. package/dist/lib/eval-benchmark.js +1 -12
  190. package/dist/lib/eval-conversation-handler.js +1 -13
  191. package/dist/lib/eval-executor.js +1 -8
  192. package/dist/lib/eval-grader.js +1 -9
  193. package/dist/lib/eval-meta-judge.js +1 -9
  194. package/dist/lib/eval-trigger-tester.js +1 -11
  195. package/dist/lib/eval-worktree.js +1 -8
  196. package/dist/lib/gateway-entry.js +1 -61
  197. package/dist/lib/gateway-identity.js +1 -16
  198. package/dist/lib/gateway-lifecycle.js +1 -32
  199. package/dist/lib/gateway.js +1 -14
  200. package/dist/lib/handlers/cron-refresh-pricing.js +1 -0
  201. package/dist/lib/handlers/cron-refresh-skills.js +1 -8
  202. package/dist/lib/handlers/cron-suggest-instructions.js +1 -16
  203. package/dist/lib/handlers/process-announcement.js +1 -11
  204. package/dist/lib/handlers/process-changelog.js +1 -11
  205. package/dist/lib/handlers/process-conversation.js +1 -14
  206. package/dist/lib/handlers/process-eval.js +1 -15
  207. package/dist/lib/handlers/process-insights.js +1 -15
  208. package/dist/lib/handlers/process-launch.js +1 -16
  209. package/dist/lib/handlers/process-run-cleanup.js +1 -13
  210. package/dist/lib/handlers/process-send-message.js +1 -10
  211. package/dist/lib/handlers/process-session-goal.js +1 -12
  212. package/dist/lib/hooks-config.js +1 -81
  213. package/dist/lib/insights-prompts.js +1 -12
  214. package/dist/lib/instruction-snapshot.js +1 -8
  215. package/dist/lib/job-helpers.js +0 -1
  216. package/dist/lib/llm-client.js +1 -20
  217. package/dist/lib/manual-tasks-meta.js +1 -8
  218. package/dist/lib/manual-tasks.js +1 -80
  219. package/dist/lib/output.js +1 -12
  220. package/dist/lib/permanent-job-error.js +1 -10
  221. package/dist/lib/pid-identity.js +1 -14
  222. package/dist/lib/proxy-respawn.js +1 -12
  223. package/dist/lib/research-client.js +1 -12
  224. package/dist/lib/setup-steps.js +1 -33
  225. package/dist/lib/skills-loader.js +1 -8
  226. package/dist/lib/statusline-shim.js +1 -20
  227. package/dist/lib/telemetry.js +1 -16
  228. package/dist/lib/terminal-target-heartbeat.js +1 -15
  229. package/dist/lib/tmux.js +1 -16
  230. package/dist/lib/transcript-rate-limit-watcher.js +1 -22
  231. package/dist/lib/types.js +1 -8
  232. package/dist/lib/version-check.js +1 -12
  233. package/dist/lib/which.js +1 -8
  234. package/dist/lib/worktree.js +1 -17
  235. package/dist/opencode-QRJ3BH23.js +1 -0
  236. package/oclif.manifest.json +135 -135
  237. package/package.json +9 -8
  238. package/dist/base-command.js.map +0 -7
  239. package/dist/chunk-2HK7RGZB.js +0 -82
  240. package/dist/chunk-2HK7RGZB.js.map +0 -7
  241. package/dist/chunk-2ORJWTNZ.js +0 -307
  242. package/dist/chunk-2ORJWTNZ.js.map +0 -7
  243. package/dist/chunk-37LN5O7M.js +0 -59
  244. package/dist/chunk-37LN5O7M.js.map +0 -7
  245. package/dist/chunk-3S7223UR.js +0 -81
  246. package/dist/chunk-3S7223UR.js.map +0 -7
  247. package/dist/chunk-3TIMQ3O6.js +0 -96
  248. package/dist/chunk-3TIMQ3O6.js.map +0 -7
  249. package/dist/chunk-42GFSAJP.js +0 -32
  250. package/dist/chunk-42GFSAJP.js.map +0 -7
  251. package/dist/chunk-4BHDHHKL.js +0 -48
  252. package/dist/chunk-4BHDHHKL.js.map +0 -7
  253. package/dist/chunk-4D537GXE.js +0 -99
  254. package/dist/chunk-4D537GXE.js.map +0 -7
  255. package/dist/chunk-4LYCDS2N.js +0 -139
  256. package/dist/chunk-4LYCDS2N.js.map +0 -7
  257. package/dist/chunk-4SCZK7AL.js +0 -129
  258. package/dist/chunk-4SCZK7AL.js.map +0 -7
  259. package/dist/chunk-4XAWK6S2.js +0 -161
  260. package/dist/chunk-4XAWK6S2.js.map +0 -7
  261. package/dist/chunk-52WIYRZH.js +0 -73
  262. package/dist/chunk-52WIYRZH.js.map +0 -7
  263. package/dist/chunk-5BAOGNUH.js +0 -79
  264. package/dist/chunk-5BAOGNUH.js.map +0 -7
  265. package/dist/chunk-5EDMGK3W.js +0 -39
  266. package/dist/chunk-5EDMGK3W.js.map +0 -7
  267. package/dist/chunk-6NBS5XFS.js +0 -99
  268. package/dist/chunk-6NBS5XFS.js.map +0 -7
  269. package/dist/chunk-7LVVKQMZ.js +0 -98
  270. package/dist/chunk-7LVVKQMZ.js.map +0 -7
  271. package/dist/chunk-7NNFYWKK.js +0 -243
  272. package/dist/chunk-7NNFYWKK.js.map +0 -7
  273. package/dist/chunk-7NYKWN7U.js +0 -12
  274. package/dist/chunk-7NYKWN7U.js.map +0 -7
  275. package/dist/chunk-BO76WKJR.js +0 -42
  276. package/dist/chunk-BO76WKJR.js.map +0 -7
  277. package/dist/chunk-BRD5RUGM.js +0 -53
  278. package/dist/chunk-BRD5RUGM.js.map +0 -7
  279. package/dist/chunk-BT6Z6545.js +0 -43
  280. package/dist/chunk-BT6Z6545.js.map +0 -7
  281. package/dist/chunk-BZDKEQKU.js +0 -39
  282. package/dist/chunk-BZDKEQKU.js.map +0 -7
  283. package/dist/chunk-DGHWRQXL.js +0 -17
  284. package/dist/chunk-DGHWRQXL.js.map +0 -7
  285. package/dist/chunk-DIQUV5FR.js +0 -257
  286. package/dist/chunk-DIQUV5FR.js.map +0 -7
  287. package/dist/chunk-DMX5YOTM.js +0 -167
  288. package/dist/chunk-DMX5YOTM.js.map +0 -7
  289. package/dist/chunk-DNKSVWMD.js +0 -108
  290. package/dist/chunk-DNKSVWMD.js.map +0 -7
  291. package/dist/chunk-DQ3KELXD.js +0 -74
  292. package/dist/chunk-DQ3KELXD.js.map +0 -7
  293. package/dist/chunk-DUJSRBLP.js +0 -122
  294. package/dist/chunk-DUJSRBLP.js.map +0 -7
  295. package/dist/chunk-E3BIT53W.js +0 -154
  296. package/dist/chunk-E3BIT53W.js.map +0 -7
  297. package/dist/chunk-EARWG4EV.js +0 -22
  298. package/dist/chunk-EARWG4EV.js.map +0 -7
  299. package/dist/chunk-EI5BHWXA.js +0 -1662
  300. package/dist/chunk-EI5BHWXA.js.map +0 -7
  301. package/dist/chunk-EJ3YAFDP.js +0 -37
  302. package/dist/chunk-EJ3YAFDP.js.map +0 -7
  303. package/dist/chunk-EKJ2CABV.js +0 -76
  304. package/dist/chunk-EKJ2CABV.js.map +0 -7
  305. package/dist/chunk-EKP32DLN.js +0 -16
  306. package/dist/chunk-EKP32DLN.js.map +0 -7
  307. package/dist/chunk-EYPAAGN5.js +0 -51
  308. package/dist/chunk-EYPAAGN5.js.map +0 -7
  309. package/dist/chunk-F5N6CLJJ.js +0 -1995
  310. package/dist/chunk-F5N6CLJJ.js.map +0 -7
  311. package/dist/chunk-GIUBARWS.js +0 -99
  312. package/dist/chunk-GIUBARWS.js.map +0 -7
  313. package/dist/chunk-GQNJO2P2.js +0 -102
  314. package/dist/chunk-GQNJO2P2.js.map +0 -7
  315. package/dist/chunk-IJGF2ETG.js +0 -68
  316. package/dist/chunk-IJGF2ETG.js.map +0 -7
  317. package/dist/chunk-ILYDELUE.js +0 -46
  318. package/dist/chunk-ILYDELUE.js.map +0 -7
  319. package/dist/chunk-J6QFW4LD.js +0 -55
  320. package/dist/chunk-J6QFW4LD.js.map +0 -7
  321. package/dist/chunk-J7N3DLH6.js +0 -117
  322. package/dist/chunk-J7N3DLH6.js.map +0 -7
  323. package/dist/chunk-JFDWKLQC.js +0 -23
  324. package/dist/chunk-JFDWKLQC.js.map +0 -7
  325. package/dist/chunk-JULOLTZS.js +0 -61
  326. package/dist/chunk-JULOLTZS.js.map +0 -7
  327. package/dist/chunk-KJKBDQ4D.js +0 -220
  328. package/dist/chunk-KJKBDQ4D.js.map +0 -7
  329. package/dist/chunk-KRBQLMOP.js +0 -41
  330. package/dist/chunk-KRBQLMOP.js.map +0 -7
  331. package/dist/chunk-LXKPNATC.js +0 -624
  332. package/dist/chunk-LXKPNATC.js.map +0 -7
  333. package/dist/chunk-NSBPE2FW.js +0 -17
  334. package/dist/chunk-NSBPE2FW.js.map +0 -7
  335. package/dist/chunk-OCKHW72U.js +0 -55
  336. package/dist/chunk-OCKHW72U.js.map +0 -7
  337. package/dist/chunk-OKWCKCPE.js +0 -414
  338. package/dist/chunk-OKWCKCPE.js.map +0 -7
  339. package/dist/chunk-OO7JDFS4.js +0 -157
  340. package/dist/chunk-OO7JDFS4.js.map +0 -7
  341. package/dist/chunk-OQBBVTDG.js.map +0 -7
  342. package/dist/chunk-OQSQC7VB.js +0 -77
  343. package/dist/chunk-OQSQC7VB.js.map +0 -7
  344. package/dist/chunk-PED7L5GX.js +0 -92
  345. package/dist/chunk-PED7L5GX.js.map +0 -7
  346. package/dist/chunk-QJQS6TUN.js +0 -44
  347. package/dist/chunk-QJQS6TUN.js.map +0 -7
  348. package/dist/chunk-QN34TGD3.js +0 -83
  349. package/dist/chunk-QN34TGD3.js.map +0 -7
  350. package/dist/chunk-QSN77T7C.js +0 -250
  351. package/dist/chunk-QSN77T7C.js.map +0 -7
  352. package/dist/chunk-R56PH7YE.js +0 -78
  353. package/dist/chunk-R56PH7YE.js.map +0 -7
  354. package/dist/chunk-RAXRZYOB.js +0 -299
  355. package/dist/chunk-RAXRZYOB.js.map +0 -7
  356. package/dist/chunk-RH7NHVSK.js +0 -16
  357. package/dist/chunk-RH7NHVSK.js.map +0 -7
  358. package/dist/chunk-RMTT4KDY.js +0 -191
  359. package/dist/chunk-RMTT4KDY.js.map +0 -7
  360. package/dist/chunk-RQ2TMLKG.js +0 -142
  361. package/dist/chunk-RQ2TMLKG.js.map +0 -7
  362. package/dist/chunk-SO3T35U7.js +0 -80
  363. package/dist/chunk-SO3T35U7.js.map +0 -7
  364. package/dist/chunk-UKMLICWS.js +0 -51
  365. package/dist/chunk-UKMLICWS.js.map +0 -7
  366. package/dist/chunk-VA5FFOS7.js +0 -243
  367. package/dist/chunk-VA5FFOS7.js.map +0 -7
  368. package/dist/chunk-W2YERO7E.js +0 -170
  369. package/dist/chunk-W2YERO7E.js.map +0 -7
  370. package/dist/chunk-W53GKIZQ.js +0 -50
  371. package/dist/chunk-W53GKIZQ.js.map +0 -7
  372. package/dist/chunk-WA4MWYRW.js +0 -254
  373. package/dist/chunk-WA4MWYRW.js.map +0 -7
  374. package/dist/chunk-XC6M4CSW.js +0 -44
  375. package/dist/chunk-XC6M4CSW.js.map +0 -7
  376. package/dist/chunk-XK42ZBDE.js +0 -23
  377. package/dist/chunk-XK42ZBDE.js.map +0 -7
  378. package/dist/chunk-XUV6DDBF.js +0 -124
  379. package/dist/chunk-XUV6DDBF.js.map +0 -7
  380. package/dist/chunk-XZXS2W24.js.map +0 -7
  381. package/dist/chunk-Y3WD5CSW.js +0 -49
  382. package/dist/chunk-Y3WD5CSW.js.map +0 -7
  383. package/dist/chunk-Y4BJXXYV.js +0 -148
  384. package/dist/chunk-Y4BJXXYV.js.map +0 -7
  385. package/dist/chunk-YNIH3KMU.js +0 -121
  386. package/dist/chunk-YNIH3KMU.js.map +0 -7
  387. package/dist/chunk-ZUJBM6HE.js +0 -125
  388. package/dist/chunk-ZUJBM6HE.js.map +0 -7
  389. package/dist/commands/antigravity/backfill.js.map +0 -7
  390. package/dist/commands/auth/create-key.js.map +0 -7
  391. package/dist/commands/auth/login.js.map +0 -7
  392. package/dist/commands/auth/logout.js.map +0 -7
  393. package/dist/commands/auth/revoke-key.js.map +0 -7
  394. package/dist/commands/auth/signup.js.map +0 -7
  395. package/dist/commands/auth/status.js.map +0 -7
  396. package/dist/commands/catalog/index.js.map +0 -7
  397. package/dist/commands/catalog/recommend.js.map +0 -7
  398. package/dist/commands/convert.js.map +0 -7
  399. package/dist/commands/converters.js.map +0 -7
  400. package/dist/commands/crons/list.js.map +0 -7
  401. package/dist/commands/crons/run.js.map +0 -7
  402. package/dist/commands/dashboard.js.map +0 -7
  403. package/dist/commands/diagnostics.js.map +0 -7
  404. package/dist/commands/eval-targets/create.js.map +0 -7
  405. package/dist/commands/eval-targets/list.js.map +0 -7
  406. package/dist/commands/evals/agent.js.map +0 -7
  407. package/dist/commands/evals/benchmark.js.map +0 -7
  408. package/dist/commands/evals/compare.js.map +0 -7
  409. package/dist/commands/evals/create.js.map +0 -7
  410. package/dist/commands/evals/optimize-description.js.map +0 -7
  411. package/dist/commands/evals/optimize.js.map +0 -7
  412. package/dist/commands/evals/run.js.map +0 -7
  413. package/dist/commands/gateway/ensure.js.map +0 -7
  414. package/dist/commands/hooks/emit-instructions.js.map +0 -7
  415. package/dist/commands/hooks/install.js.map +0 -7
  416. package/dist/commands/hooks/run.js.map +0 -7
  417. package/dist/commands/hooks/uninstall.js.map +0 -7
  418. package/dist/commands/import.js.map +0 -7
  419. package/dist/commands/instructions/create.js.map +0 -7
  420. package/dist/commands/instructions/delete.js.map +0 -7
  421. package/dist/commands/instructions/fork.js.map +0 -7
  422. package/dist/commands/instructions/get.js.map +0 -7
  423. package/dist/commands/instructions/list.js.map +0 -7
  424. package/dist/commands/instructions/promote.js.map +0 -7
  425. package/dist/commands/instructions/pull.js.map +0 -7
  426. package/dist/commands/instructions/upstream.js.map +0 -7
  427. package/dist/commands/instructions/versions.js.map +0 -7
  428. package/dist/commands/launcher.js.map +0 -7
  429. package/dist/commands/org/current.js.map +0 -7
  430. package/dist/commands/org/list.js.map +0 -7
  431. package/dist/commands/org/switch.js.map +0 -7
  432. package/dist/commands/packs/add-instruction.js.map +0 -7
  433. package/dist/commands/packs/apply.js.map +0 -7
  434. package/dist/commands/packs/create.js.map +0 -7
  435. package/dist/commands/packs/fork.js.map +0 -7
  436. package/dist/commands/packs/get.js.map +0 -7
  437. package/dist/commands/packs/list.js.map +0 -7
  438. package/dist/commands/packs/remove-instruction.js.map +0 -7
  439. package/dist/commands/proxy/env.js.map +0 -7
  440. package/dist/commands/proxy/logs.js.map +0 -7
  441. package/dist/commands/proxy/restart.js.map +0 -7
  442. package/dist/commands/proxy/setup.js.map +0 -7
  443. package/dist/commands/proxy/start.js.map +0 -7
  444. package/dist/commands/proxy/status.js.map +0 -7
  445. package/dist/commands/proxy/stop.js.map +0 -7
  446. package/dist/commands/research/backfill.js.map +0 -7
  447. package/dist/commands/research/tail-transcript.js.map +0 -7
  448. package/dist/commands/service/install.js.map +0 -7
  449. package/dist/commands/service/status.js.map +0 -7
  450. package/dist/commands/service/uninstall.js.map +0 -7
  451. package/dist/commands/sessions/analyze.js.map +0 -7
  452. package/dist/commands/sessions/end.js.map +0 -7
  453. package/dist/commands/sessions/import.js.map +0 -7
  454. package/dist/commands/sessions/list.js.map +0 -7
  455. package/dist/commands/sessions/start.js.map +0 -7
  456. package/dist/commands/setup.js.map +0 -7
  457. package/dist/commands/skills/export-approved.js.map +0 -7
  458. package/dist/commands/skills/install.js.map +0 -7
  459. package/dist/commands/skills/list.js.map +0 -7
  460. package/dist/commands/skills/publish.js.map +0 -7
  461. package/dist/commands/skills/search.js.map +0 -7
  462. package/dist/commands/skills/update.js.map +0 -7
  463. package/dist/commands/suggestions/accept.js.map +0 -7
  464. package/dist/commands/suggestions/dismiss.js.map +0 -7
  465. package/dist/commands/suggestions/list.js.map +0 -7
  466. package/dist/commands/suggestions/refresh.js.map +0 -7
  467. package/dist/cursor-BGQJ4CWI.js +0 -134
  468. package/dist/cursor-BGQJ4CWI.js.map +0 -7
  469. package/dist/dashboard/Dashboard.js.map +0 -7
  470. package/dist/dashboard/data.js.map +0 -7
  471. package/dist/dashboard/launcher/ActiveJobsList.js.map +0 -7
  472. package/dist/dashboard/launcher/LauncherOverlay.js.map +0 -7
  473. package/dist/dashboard/launcher/NewLaunchForm.js.map +0 -7
  474. package/dist/dashboard/launcher/api.js.map +0 -7
  475. package/dist/dashboard/launcher/tool-labels.js.map +0 -7
  476. package/dist/dashboard/launcher/types.js.map +0 -7
  477. package/dist/dashboard/launcher/useLaunchJobs.js.map +0 -7
  478. package/dist/dashboard/panels/friction.js.map +0 -7
  479. package/dist/dashboard/panels/insights.js.map +0 -7
  480. package/dist/dashboard/panels/instructions.js.map +0 -7
  481. package/dist/dashboard/panels/outcomes.js.map +0 -7
  482. package/dist/dashboard/panels/overview.js.map +0 -7
  483. package/dist/dashboard/panels/shared.js.map +0 -7
  484. package/dist/dashboard/types.js.map +0 -7
  485. package/dist/dist-UNYP5PJR.js +0 -56
  486. package/dist/dist-UNYP5PJR.js.map +0 -7
  487. package/dist/index.js.map +0 -7
  488. package/dist/lib/active-org-refresh.js.map +0 -7
  489. package/dist/lib/active-org.js.map +0 -7
  490. package/dist/lib/agent-loop.js.map +0 -7
  491. package/dist/lib/antigravity-transcript.js.map +0 -7
  492. package/dist/lib/api-client.js.map +0 -7
  493. package/dist/lib/auth.js.map +0 -7
  494. package/dist/lib/capture-hosts.js.map +0 -7
  495. package/dist/lib/detect-languages.js.map +0 -7
  496. package/dist/lib/detect-tmux.js.map +0 -7
  497. package/dist/lib/diagnostics.js.map +0 -7
  498. package/dist/lib/editor-proxy-pins.js.map +0 -7
  499. package/dist/lib/ensure-api-key.js.map +0 -7
  500. package/dist/lib/eval-analyzer.js.map +0 -7
  501. package/dist/lib/eval-benchmark.js.map +0 -7
  502. package/dist/lib/eval-conversation-handler.js.map +0 -7
  503. package/dist/lib/eval-executor.js.map +0 -7
  504. package/dist/lib/eval-grader.js.map +0 -7
  505. package/dist/lib/eval-meta-judge.js.map +0 -7
  506. package/dist/lib/eval-trigger-tester.js.map +0 -7
  507. package/dist/lib/eval-worktree.js.map +0 -7
  508. package/dist/lib/gateway-entry.js.map +0 -7
  509. package/dist/lib/gateway-identity.js.map +0 -7
  510. package/dist/lib/gateway-lifecycle.js.map +0 -7
  511. package/dist/lib/gateway.js.map +0 -7
  512. package/dist/lib/handlers/cron-refresh-skills.js.map +0 -7
  513. package/dist/lib/handlers/cron-suggest-instructions.js.map +0 -7
  514. package/dist/lib/handlers/process-announcement.js.map +0 -7
  515. package/dist/lib/handlers/process-changelog.js.map +0 -7
  516. package/dist/lib/handlers/process-conversation.js.map +0 -7
  517. package/dist/lib/handlers/process-eval.js.map +0 -7
  518. package/dist/lib/handlers/process-insights.js.map +0 -7
  519. package/dist/lib/handlers/process-launch.js.map +0 -7
  520. package/dist/lib/handlers/process-run-cleanup.js.map +0 -7
  521. package/dist/lib/handlers/process-send-message.js.map +0 -7
  522. package/dist/lib/handlers/process-session-goal.js.map +0 -7
  523. package/dist/lib/hooks-config.js.map +0 -7
  524. package/dist/lib/insights-prompts.js.map +0 -7
  525. package/dist/lib/instruction-snapshot.js.map +0 -7
  526. package/dist/lib/job-helpers.js.map +0 -7
  527. package/dist/lib/llm-client.js.map +0 -7
  528. package/dist/lib/manual-tasks-meta.js.map +0 -7
  529. package/dist/lib/manual-tasks.js.map +0 -7
  530. package/dist/lib/output.js.map +0 -7
  531. package/dist/lib/permanent-job-error.js.map +0 -7
  532. package/dist/lib/pid-identity.js.map +0 -7
  533. package/dist/lib/proxy-respawn.js.map +0 -7
  534. package/dist/lib/research-client.js.map +0 -7
  535. package/dist/lib/setup-steps.js.map +0 -7
  536. package/dist/lib/skills-loader.js.map +0 -7
  537. package/dist/lib/statusline-shim.js.map +0 -7
  538. package/dist/lib/telemetry.js.map +0 -7
  539. package/dist/lib/terminal-target-heartbeat.js.map +0 -7
  540. package/dist/lib/tmux.js.map +0 -7
  541. package/dist/lib/transcript-rate-limit-watcher.js.map +0 -7
  542. package/dist/lib/types.js.map +0 -7
  543. package/dist/lib/version-check.js.map +0 -7
  544. package/dist/lib/which.js.map +0 -7
  545. package/dist/lib/worktree.js.map +0 -7
  546. package/dist/opencode-IQ7X5YMJ.js +0 -190
  547. package/dist/opencode-IQ7X5YMJ.js.map +0 -7
@@ -0,0 +1,69 @@
1
+ import{a as o}from"./chunk-ZLLER3HP.js";var R="#5b6cff",l="#1a1a1a",d="#666666",w="#f5f5f7",z="#ffffff",v="#e5e5e9",C=["Added","Changed","Fixed","Removed","Deprecated","Security"];function k(e){let t=["January","February","March","April","May","June","July","August","September","October","November","December"],[r,n,i]=e.split("-").map(p=>parseInt(p,10));return!r||!n||!i||n<1||n>12?e:`${t[n-1]} ${i}, ${r}`}o(k,"formatIsoDate");function s(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}o(s,"escapeHtml");function N(e){let t=[];for(let r of C){let n=e[r];n&&n.length>0&&t.push({name:r,items:n})}return t}o(N,"orderedSections");function U(e){let{version:t,date:r,sections:n,unsubscribeUrl:i,productUrl:p,recipientName:a}=e,f=k(r),y=`What's new in RuleMetric \u2014 ${f}`,$=a?`Hi ${a},`:"Hi there,",b=N(n),E=new Date().getUTCFullYear(),T=b.map(({name:g,items:h})=>{let m=h.map(D=>` <li style="margin:0 0 6px 0;font-size:15px;line-height:1.5;color:${l};">${s(D)}</li>`).join(`
2
+ `);return` <h3 style="margin:24px 0 8px 0;font-size:16px;line-height:1.3;font-weight:600;color:${l};">${g}</h3>
3
+ <ul style="margin:0 0 8px 0;padding-left:20px;">
4
+ ${m}
5
+ </ul>`}).join(`
6
+ `),I=`<!doctype html>
7
+ <html lang="en">
8
+ <head>
9
+ <meta charset="utf-8" />
10
+ <meta name="viewport" content="width=device-width, initial-scale=1" />
11
+ <title>${s(y)}</title>
12
+ </head>
13
+ <body style="margin:0;padding:0;background:${w};font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,Helvetica,Arial,sans-serif;color:${l};">
14
+ <table role="presentation" width="100%" cellspacing="0" cellpadding="0" border="0" style="background:${w};padding:32px 16px;">
15
+ <tr>
16
+ <td align="center">
17
+ <table role="presentation" width="560" cellspacing="0" cellpadding="0" border="0" style="max-width:560px;background:${z};border:1px solid ${v};border-radius:8px;overflow:hidden;">
18
+ <tr>
19
+ <td style="padding:24px 32px 8px 32px;">
20
+ <a href="${s(p)}" style="text-decoration:none;color:${R};font-size:14px;font-weight:600;">RuleMetric</a>
21
+ </td>
22
+ </tr>
23
+ <tr>
24
+ <td style="padding:8px 32px 8px 32px;">
25
+ <h1 style="margin:0 0 8px 0;font-size:22px;line-height:1.3;font-weight:600;color:${l};">
26
+ What's new \u2014 ${s(f)}
27
+ </h1>
28
+ <p style="margin:0 0 8px 0;font-size:13px;line-height:1.5;color:${d};">
29
+ Release ${s(t)}
30
+ </p>
31
+ <p style="margin:16px 0 0 0;font-size:15px;line-height:1.5;color:${l};">
32
+ ${s($)}
33
+ </p>
34
+ <p style="margin:8px 0 0 0;font-size:15px;line-height:1.5;color:${l};">
35
+ Here's what shipped in the latest RuleMetric release.
36
+ </p>
37
+ </td>
38
+ </tr>
39
+ <tr>
40
+ <td style="padding:0 32px 16px 32px;">
41
+ ${T}
42
+ </td>
43
+ </tr>
44
+ <tr>
45
+ <td style="padding:16px 32px 24px 32px;border-top:1px solid ${v};">
46
+ <p style="margin:0 0 8px 0;font-size:12px;line-height:1.5;color:${d};">
47
+ You're receiving this because you signed up for RuleMetric product updates. If you'd rather not hear about new releases, you can unsubscribe at any time.
48
+ </p>
49
+ <p style="margin:0 0 4px 0;font-size:12px;line-height:1.5;">
50
+ <a href="${s(i)}" style="color:${R};text-decoration:underline;">Unsubscribe</a>
51
+ </p>
52
+ <p style="margin:0 0 12px 0;font-size:12px;line-height:1.5;color:${d};word-break:break-all;">
53
+ ${s(i)}
54
+ </p>
55
+ <p style="margin:0;font-size:11px;line-height:1.5;color:${d};">
56
+ RuleMetric \u2022 ${E}
57
+ </p>
58
+ </td>
59
+ </tr>
60
+ </table>
61
+ </td>
62
+ </tr>
63
+ </table>
64
+ </body>
65
+ </html>`,c=[`What's new in RuleMetric \u2014 ${f}`,`Release ${t}`,"",$,"","Here's what shipped in the latest RuleMetric release.",""];for(let{name:g,items:h}of b){c.push(`${g}:`);for(let m of h)c.push(` - ${m}`);c.push("")}c.push("--","You're receiving this because you signed up for RuleMetric product updates.",`Unsubscribe: ${i}`,"",`RuleMetric \u2022 ${E}`);let S=c.join(`
66
+ `);return{subject:y,html:I,text:S}}o(U,"renderChangelogAnnouncement");import{randomBytes as O}from"node:crypto";async function x(e){let t=e.idempotencyKey?` idempotencyKey=${e.idempotencyKey}`:"";return process.stderr.write(`[email:noop] would send to=${e.to} subject=${JSON.stringify(e.subject)}${t}
67
+ `),{id:`noop-${O(8).toString("hex")}`,provider:"noop"}}o(x,"sendNoopEmail");var u=null;async function j(){if(u)return u;let e=process.env.RESEND_API_KEY;if(!e)throw new Error("RESEND_API_KEY is not set");let{Resend:t}=await import("resend");return u=new t(e),u}o(j,"getClient");async function M(e){let t=e.fromName??"RuleMetric",r=process.env.RESEND_FROM_EMAIL??"onboarding@resend.dev",n=`${t} <${r}>`,i=await j(),p=e.idempotencyKey?{idempotencyKey:e.idempotencyKey}:void 0,a=await i.emails.send({from:n,to:e.to,subject:e.subject,html:e.html,text:e.text},p);if(a.error)throw new Error(`Resend send failed: ${a.error.message}`);if(!a.data)throw new Error("Resend send returned no data and no error");return{id:a.data.id,provider:"resend"}}o(M,"sendResendEmail");async function A(e){throw new Error("SMTP provider not implemented. Set RESEND_API_KEY to use Resend, or unset RULEMETRIC_EMAIL_PROVIDER to fall back to noop.")}o(A,"sendSmtpEmail");function Y(){let e=process.env.RULEMETRIC_EMAIL_PROVIDER;return e==="resend"||e==="smtp"||e==="noop"?e:process.env.RESEND_API_KEY?"resend":"noop"}o(Y,"selectEmailProvider");var H=new Set(["test","example","invalid","localhost"]),K=/^example\.(com|net|org)$/;function L(e){let t=e.trim().toLowerCase(),r=t.lastIndexOf("@");if(r<0)return!1;let n=t.slice(r+1);if(!n)return!1;let i=n.slice(n.lastIndexOf(".")+1);return!!(H.has(i)||K.test(n))}o(L,"isUndeliverableRecipient");var _=!1;async function re(e){let t=Y();switch(_||(_=!0,process.stderr.write(`[email] active provider: ${t}
68
+ `)),t){case"resend":return L(e.to)?(process.stderr.write(`[email] skipping real send to reserved/undeliverable address ${e.to} (RFC 2606/6761) \u2014 routed to noop to protect sender reputation
69
+ `),x(e)):M(e);case"smtp":return A(e);case"noop":return x(e)}}o(re,"sendEmail");export{U as a,re as b};
@@ -0,0 +1 @@
1
+ import{a as s,b as p,c as f}from"./chunk-ARNZQBMX.js";import{e as u,i}from"./chunk-NJ5UED3H.js";import{a as c}from"./chunk-ZLLER3HP.js";import{Text as t}from"ink";import{jsx as n,jsxs as l}from"react/jsx-runtime";function P({instructions:o,width:r,barWidth:a}){if(!o)return n(s,{title:"Active Instructions",color:i,width:r,children:n(t,{dimColor:!0,children:"API offline \u2014 no instruction data"})});if(o.length===0)return n(s,{title:"Active Instructions",color:i,width:r,children:n(t,{dimColor:!0,children:"No instructions linked to sessions yet"})});let m=[...o].sort((e,S)=>S.linkedSessions-e.linkedSessions).slice(0,10),x=m[0].linkedSessions,d=Math.max(8,r-a-15);return l(s,{title:`Active Instructions (${o.length})`,color:i,width:r,children:[l(t,{dimColor:!0,wrap:"truncate-end",children:["".padEnd(a+1+d),"sessions".padStart(9)]}),m.map(e=>l(t,{wrap:"truncate-end",children:[n(p,{value:e.linkedSessions,max:x,width:a}),l(t,{color:u,children:[" ",f(e.name,d)]}),n(t,{children:String(e.linkedSessions).padStart(9)})]},e.name))]})}c(P,"InstructionsPanel");export{P as a};
@@ -0,0 +1 @@
1
+ var e=[{name:"cron_check_changelog",description:"Parse CHANGELOG.md and create draft announcement rows for new versions.",scheduledBy:"manual only \u2014 announcement drafts are reminder-driven, never scheduled"},{name:"cron_suggest_instructions",description:"Precompute per-project instruction suggestions for the SessionStart hook.",scheduledBy:"Supabase pg_cron daily 04:30 UTC \u2192 agent_jobs \u2192 agent loop (migration 00083)"},{name:"cron_refresh_skills",description:"Refresh the skills registry from GitHub sources (disk JSON + public instructions sync). Requires GITHUB_TOKEN.",scheduledBy:"Supabase pg_cron daily 03:30 UTC \u2192 agent_jobs \u2192 agent loop (migration 00086)"}];export{e as a};
@@ -0,0 +1,5 @@
1
+ import{c as e,d as o,h as y}from"./chunk-NVOTOQBA.js";import{f as d}from"./chunk-RTWRHIKY.js";import{a as g}from"./chunk-ZLLER3HP.js";import{eq as c,asc as P,sql as R}from"drizzle-orm";var T=1800*1e3,I=300*1e3,h=10,D=`Given these messages from an AI coding session, write a 1-2 sentence summary of what the user is trying to accomplish. Focus on the goal, not the steps. No preamble.
2
+
3
+ Return strict JSON in the form: {"goalSummary": "..."}`;async function b(t,a={}){let n=a.db??y(),f=a.llm??d,r=a.now??Date.now,[i]=await n.select().from(e).where(c(e.id,t.sessionId)).limit(1);if(!i)return{skipped:"not_found"};let w=(await n.execute(R`SELECT MAX(timestamp) AS last_at FROM session_events WHERE session_id = ${t.sessionId}`))?.[0]?.last_at??i.startedAt,_=new Date(w).getTime();if(r()-_>T)return{skipped:"stale"};let m=i.analysis??{},p=m.goalSummaryAt?new Date(m.goalSummaryAt).getTime():0;if(p&&r()-p<I)return{skipped:"recent"};let u=(await n.select().from(o).where(c(o.sessionId,t.sessionId)).orderBy(P(o.timestamp)).limit(h*2)).filter(s=>s.content&&(s.eventType==="user_message"||s.eventType==="assistant_response")).map(s=>`${s.eventType==="user_message"?"USER":"ASSISTANT"}: ${s.content}`).join(`
4
+
5
+ `);if(!u)return{skipped:"no_content"};let S=await f(D,u,200),l=typeof S?.goalSummary=="string"?S.goalSummary.trim():"";if(!l)return{skipped:"llm_empty"};let A=new Date(r()).toISOString();return await n.update(e).set({analysis:{...m,goalSummary:l,goalSummaryAt:A}}).where(c(e.id,t.sessionId)),{goalSummary:l}}g(b,"processSessionGoal");export{b as a};
@@ -0,0 +1,24 @@
1
+ import{a as x}from"./chunk-DSO2U4Y6.js";import{a as w}from"./chunk-CADKBP3D.js";import{a as y}from"./chunk-MGHFDHHM.js";import{d as h,e as f}from"./chunk-TIQ7DQ3M.js";import{a as v}from"./chunk-ZLLER3HP.js";async function P(t,i,p){let{conversationId:s,messageId:l,messageContent:c}=t,n=await h(`/api/eval-targets/${i}`),a=await h(`/api/eval-targets/${i}/evals`),e=await h(`/api/eval-conversations/${s}/messages`),r=e.findIndex(d=>d.id===l);if(r>=0&&e.slice(r+1).some(g=>g.role==="assistant"&&(g.type==="results"||g.type==="proposal"||g.type==="generated"||g.type==="text"))){p(`Message ${l} already processed \u2014 skipping (idempotency guard)`);return}let o=v(async(d,g,m)=>{await f(`/api/eval-conversations/${s}/messages/assistant`,{content:d,type:g,data:m})},"postMessage"),u=await $(n,a,e,c,p);switch(p(`Action: ${u.action}`),u.action){case"run_evals":await _(n,a,s,o,p);break;case"generate_cases":await C(n,i,s,o,p);break;case"analyze_results":case"propose_changes":await k(n,a,e,c,s,o,p);break;case"respond":await o(u.response,"text");break}}v(P,"processConversationJob");async function $(t,i,p,s,l){let c=p.slice(-10).map(e=>`${e.role}: ${e.content.slice(0,200)}`).join(`
2
+ `),n=`You are an eval assistant. Decide what action to take based on the user's message.
3
+
4
+ ## Current State
5
+ - Eval target: "${t.name}" v${t.version} (${t.type})
6
+ - Eval cases: ${i.length} defined${i.length>0?` (${i.map(e=>e.name).join(", ")})`:""}
7
+ - Content length: ${t.content.length} chars
8
+
9
+ ## Recent Conversation
10
+ ${c}
11
+
12
+ ## User's Latest Message
13
+ ${s}
14
+
15
+ ## Available Actions
16
+ - run_evals: Run all eval cases against current version (with + without target). Choose this when the user wants to test, evaluate, or see how the instruction performs.
17
+ - generate_cases: Auto-generate eval test cases from the instruction content. Choose this when there are no eval cases (${i.length} currently) or user asks to create/generate tests.
18
+ - analyze_results: Analyze recent eval failures and propose improvements based on user feedback. Choose this when user gives qualitative feedback like "this is wrong", "missing X", etc.
19
+ - propose_changes: Propose specific content edits based on conversation. Choose this when user asks for improvements or changes.
20
+ - respond: Just answer a question without running any evals. Choose this for informational questions.
21
+
22
+ Respond with ONLY valid JSON:
23
+ {"action": "run_evals", "response": "What you want to say to the user", "params": {}}`,a=await y({prompt:n,timeout:3e4});try{let e=a.output.trim(),r=e.match(/\{[\s\S]*\}/);return r&&(e=r[0]),JSON.parse(e)}catch{l("Failed to parse action decision, defaulting to respond");let e=s.toLowerCase();return e.includes("run")||e.includes("test")||e.includes("eval")?{action:"run_evals",response:"Running evals now..."}:e.includes("generate")||e.includes("create")||i.length===0&&e.includes("start")?{action:"generate_cases",response:"Generating test cases..."}:{action:"respond",response:"I can help you run evals, generate test cases, or analyze results. What would you like to do?"}}}v($,"decideAction");async function _(t,i,p,s,l){if(i.length===0){await s("No eval cases exist yet. Would you like me to generate some from the instruction content?","text");return}await s(`Running ${i.length} evals against "${t.name}" v${t.version}...`,"status");let c=[];for(let e of i){l(`Running: ${e.name} (with_target)`);let r=await y({prompt:e.prompt,targetContent:t.content,timeout:12e4}),o=!1,u="";if(!r.error&&e.expectations.length>0){let d=await w({prompt:e.prompt,output:r.output,expectations:e.expectations,timeout:12e4});o=d?.summary?.pass_rate>=1,u=d?.expectations?.map(m=>`${m.passed?"PASS":"FAIL"}: ${m.text} \u2014 ${m.evidence}`).join(`
24
+ `)??""}c.push({evalName:e.name,passed:o,output:r.error??r.output.slice(0,2e3),expectations:e.expectations,evidence:u,configuration:"with_target"})}let n=c.filter(e=>e.passed).length,a=c.length;await s(`${n} of ${a} evals passed (${Math.round(n/a*100)}%)`,"results",{summary:{passed:n,failed:a-n,total:a,passRate:n/a},results:c.map(e=>({evalName:e.evalName,passed:e.passed,output:e.output,expectations:e.expectations,evidence:e.evidence}))})}v(_,"handleRunEvals");async function C(t,i,p,s,l){await s("Generating eval cases from instruction content...","status"),l("Calling eval-from-context endpoint");let n=(await f("/api/eval-from-context",{contentHash:"",name:t.name,type:t.type,content:t.content,config:{skipBaseline:!1,skipGrading:!1}})).evals??[];await s(`Generated ${n.length} eval cases. Review them below:`,"generated",{cases:n.map(a=>({id:a.id,name:a.name,prompt:a.prompt,expectations:a.expectations}))})}v(C,"handleGenerateCases");async function k(t,i,p,s,l,c,n){await c("Analyzing results and preparing improvements...","status");let e=[...p].reverse().find(o=>o.type==="results")?.data?.results?.map(o=>({evalName:o.evalName,prompt:"",expectations:o.expectations??[],grading:{summary:{pass_rate:o.passed?1:0},expectations:o.expectations?.map(u=>({text:u,passed:o.passed,evidence:o.evidence??""}))}}))??[];n(`Analyzing ${e.length} eval results with user feedback`);let r=await x({content:t.content,evalResults:e,model:void 0,timeout:12e4,userFeedback:s});await c(r.overallAssessment,"proposal",{suggestions:r.suggestions,proposedContent:r.proposedContent,fromVersion:t.version})}v(k,"handleAnalyzeAndPropose");export{P as a};
@@ -1,13 +1,6 @@
1
- // src/lib/statusline-shim.ts
2
- import { writeFileSync, chmodSync } from "node:fs";
3
- import { homedir } from "node:os";
4
- import { join } from "node:path";
5
- var STATUSLINE_SHIM_PATH = join(homedir(), ".claude", "statusline-rulemetric.sh");
6
- function writeStatuslineShim(prevCommand) {
7
- const chainBlock = prevCommand ? `
1
+ import{a as i}from"./chunk-ZLLER3HP.js";import{writeFileSync as s,chmodSync as o}from"node:fs";import{homedir as u}from"node:os";import{join as a}from"node:path";var r=a(u(),".claude","statusline-rulemetric.sh");function h(t){let e=t?`
8
2
  # Chain to the original statusLine command so the user's prompt is preserved.
9
- echo "$STDIN_PAYLOAD" | ${prevCommand}` : "";
10
- const script = `#!/usr/bin/env bash
3
+ echo "$STDIN_PAYLOAD" | ${t}`:"",n=`#!/usr/bin/env bash
11
4
  # RuleMetric statusline shim \u2014 auto-generated by \`rulemetric hooks install --statusline-usage\`
12
5
  # Captures Claude Code rate_limits from statusline stdin and forwards to the research pipeline.
13
6
  # DO NOT EDIT \u2014 re-run \`rulemetric hooks install --statusline-usage\` to regenerate.
@@ -29,14 +22,14 @@ AUTH_TOKEN="\${RULEMETRIC_ACCESS_TOKEN:-\${RULEMETRIC_API_KEY:-}}"
29
22
 
30
23
  if [ -z "$AUTH_TOKEN" ]; then
31
24
  # No auth \u2014 still chain so the user's statusline works.
32
- ${chainBlock}
25
+ ${e}
33
26
  exit 0
34
27
  fi
35
28
 
36
29
  # \u2500\u2500 Extract + POST rate_limit windows \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500
37
30
  if ! command -v jq &>/dev/null; then
38
31
  # jq missing \u2014 chain and bail; don't break the user's statusline.
39
- ${chainBlock}
32
+ ${e}
40
33
  exit 0
41
34
  fi
42
35
 
@@ -131,64 +124,6 @@ for WIRE_KEY in five_hour seven_day seven_day_opus; do
131
124
  --data "$PAYLOAD" >/dev/null 2>&1 &
132
125
  done
133
126
 
134
- ${chainBlock}
127
+ ${e}
135
128
  exit 0
136
- `;
137
- writeFileSync(STATUSLINE_SHIM_PATH, script, { encoding: "utf-8" });
138
- chmodSync(STATUSLINE_SHIM_PATH, 493);
139
- return STATUSLINE_SHIM_PATH;
140
- }
141
- var STATUSLINE_SETTINGS_VALUE = {
142
- type: "command",
143
- command: STATUSLINE_SHIM_PATH,
144
- refreshInterval: 30
145
- };
146
- function readCurrentStatusLine(settings) {
147
- const current = settings.statusLine;
148
- if (!current) return void 0;
149
- if (typeof current === "string") {
150
- if (current === STATUSLINE_SHIM_PATH) return void 0;
151
- return current;
152
- }
153
- if (typeof current === "object" && current !== null) {
154
- const cmd = current.command;
155
- if (typeof cmd !== "string") return void 0;
156
- if (cmd === STATUSLINE_SHIM_PATH) return void 0;
157
- return cmd;
158
- }
159
- return void 0;
160
- }
161
- function removeStatuslineShim(settings) {
162
- if (!isStatuslineShimInstalled(settings)) return false;
163
- delete settings.statusLine;
164
- return true;
165
- }
166
- var STATUSLINE_SHIM_SUFFIX = "/.claude/statusline-rulemetric.sh";
167
- function removeStatuslineShimAnyHome(settings) {
168
- const current = settings.statusLine;
169
- const cmd = typeof current === "string" ? current : typeof current === "object" && current !== null ? current.command : void 0;
170
- const isShim = typeof cmd === "string" && (cmd === STATUSLINE_SHIM_PATH || cmd.endsWith(STATUSLINE_SHIM_SUFFIX));
171
- if (!isShim) return false;
172
- delete settings.statusLine;
173
- return true;
174
- }
175
- function isStatuslineShimInstalled(settings) {
176
- const current = settings.statusLine;
177
- if (!current) return false;
178
- if (typeof current === "string") return current === STATUSLINE_SHIM_PATH;
179
- if (typeof current === "object" && current !== null) {
180
- return current.command === STATUSLINE_SHIM_PATH;
181
- }
182
- return false;
183
- }
184
-
185
- export {
186
- STATUSLINE_SHIM_PATH,
187
- writeStatuslineShim,
188
- STATUSLINE_SETTINGS_VALUE,
189
- readCurrentStatusLine,
190
- removeStatuslineShim,
191
- removeStatuslineShimAnyHome,
192
- isStatuslineShimInstalled
193
- };
194
- //# sourceMappingURL=chunk-OQBBVTDG.js.map
129
+ `;return s(r,n,{encoding:"utf-8"}),o(r,493),r}i(h,"writeStatuslineShim");var S={type:"command",command:r,refreshInterval:30};function m(t){let e=t.statusLine;if(e){if(typeof e=="string")return e===r?void 0:e;if(typeof e=="object"&&e!==null){let n=e.command;return typeof n!="string"||n===r?void 0:n}}}i(m,"readCurrentStatusLine");function $(t){return c(t)?(delete t.statusLine,!0):!1}i($,"removeStatuslineShim");var l="/.claude/statusline-rulemetric.sh";function C(t){let e=t.statusLine,n=typeof e=="string"?e:typeof e=="object"&&e!==null?e.command:void 0;return typeof n=="string"&&(n===r||n.endsWith(l))?(delete t.statusLine,!0):!1}i(C,"removeStatuslineShimAnyHome");function c(t){let e=t.statusLine;return e?typeof e=="string"?e===r:typeof e=="object"&&e!==null?e.command===r:!1:!1}i(c,"isStatuslineShimInstalled");export{r as a,h as b,S as c,m as d,$ as e,C as f,c as g};
@@ -0,0 +1 @@
1
+ import{a as i}from"./chunk-HP2BUPGS.js";import{g as s}from"./chunk-TIQ7DQ3M.js";import{a as n}from"./chunk-ZLLER3HP.js";async function l(a,c){let{mirrorId:g,evalTargetId:p,config:r}=a,e=n(o=>c.logger.info(o),"log");await i(r,p,e);let t={type:"conversation",conversationId:r.conversationId};return await s(`/api/eval-jobs/${g}/state`,{result:t}).catch(o=>{e(`result persist failed: ${o instanceof Error?o.message:String(o)}`)}),t}n(l,"processConversation");export{l as a};
@@ -0,0 +1 @@
1
+ import{d as j,f as y}from"./chunk-RTWRHIKY.js";import{b as R}from"./chunk-ZL4MZMUK.js";import{a as S}from"./chunk-TDD7IOV2.js";import{a as p}from"./chunk-MODXEGCU.js";import{d as i,e as l}from"./chunk-TIQ7DQ3M.js";import{a as g}from"./chunk-ZLLER3HP.js";import{readFileSync as b}from"node:fs";import E from"node:path";import $ from"node:os";var N=5,L=Number(process.env.RULEMETRIC_MAX_SUGGESTION_PROJECTS??10),T=48,M=.5,k=400;async function O(){let d=E.join($.homedir(),".config","rulemetric","skills-registry.json");try{let o=b(d,"utf-8"),s=JSON.parse(o);return Date.now()-new Date(s.generatedAt).getTime()>T*60*60*1e3}catch{return!0}}g(O,"checkSkillsRegistryStale");var X=g(async(d,o)=>{let s=j();if(s==="none"){o.logger.warn("No LLM backend available (claude CLI missing and ANTHROPIC_API_KEY unset); skipping suggestion compute");return}o.logger.info(`Scoring backend: ${s}`);let r;try{r=(await i("/api/sessions/project-paths?limit="+L)).projectPaths}catch(e){o.logger.warn(`Failed to fetch project paths: ${e instanceof Error?e.message:String(e)}`);return}if(r.length===0){o.logger.info("No recent project paths; nothing to score");return}let m=new Map;try{let e=await i("/api/projects?limit=200");for(let t of e.projects??[])t.primaryCheckoutPath&&m.set(p(t.primaryCheckoutPath),t.id)}catch(e){o.logger.warn(`Failed to fetch projects for id resolution: ${e instanceof Error?e.message:String(e)}`)}let a=new Map;try{let e=await i("/api/catalog?limit=200");for(let t of e)a.set(t.id,{id:t.id,name:t.name,description:t.description??"",tags:t.tags??[],contentPreview:(t.content??"").slice(0,k)})}catch(e){o.logger.warn(`Failed to fetch catalog: ${e instanceof Error?e.message:String(e)}`)}try{let e=await i("/api/instructions?limit=100");for(let t of e.instructions??[])a.has(t.id)||a.set(t.id,{id:t.id,name:t.name,description:t.description??"",tags:t.tags??[],contentPreview:(t.content??"").slice(0,k)})}catch(e){o.logger.warn(`Failed to fetch personal instructions: ${e instanceof Error?e.message:String(e)}`)}let c=[...a.values()];if(c.length===0){o.logger.info("No candidate instructions; nothing to score");return}o.logger.info(`Scoring ${c.length} candidates across ${r.length} project(s)`);let u=0;for(let e of r)try{let t=p(e),f=S(t);if(f.length===0){o.logger.info(`Skipping ${t}: insufficient language signals`);continue}let C={name:E.basename(t),description:null,languages:f,topics:[],dependencies:[]},I=R(C,c),w=await y(I,"",4096);if(!w){o.logger.warn(`LLM returned null for ${t} (backend ${s})`);continue}let P=(w.recommendations??[]).filter(n=>typeof n.instructionId=="string"&&typeof n.score=="number"&&typeof n.reason=="string").map(n=>({instructionId:n.instructionId,score:n.score,reason:n.reason})).filter(n=>n.score>=M).sort((n,_)=>_.score-n.score).slice(0,N);if(P.length===0){o.logger.info(`No suggestions over threshold for ${t}`);continue}let h=m.get(t);await l("/api/instruction-suggestions/batch-upsert",{projectPath:t,...h?{projectId:h}:{},suggestions:P.map(n=>({instructionId:n.instructionId,score:n.score,reason:n.reason}))}),u++}catch(t){o.logger.warn(`Failed to score ${e}: ${t instanceof Error?t.message:String(t)}`)}if(await O())try{await l("/api/instruction-suggestions/mark-stale",{}),o.logger.warn("Skills registry is stale (>48h); marked all suggestions stale")}catch{}o.logger.info(`Done: scored ${u}/${r.length} projects`)},"cronSuggestInstructions");export{X as a};
@@ -0,0 +1,2 @@
1
+ import{a as n}from"./chunk-ZLLER3HP.js";import{mkdirSync as g,readFileSync as m,writeFileSync as d}from"node:fs";import{homedir as y}from"node:os";import{join as l}from"node:path";var u=l(y(),".config","rulemetric"),f=l(u,"version-check.json"),C=3600*1e3;function h(){try{let t=JSON.parse(m(f,"utf-8"));return typeof t.latest=="string"&&typeof t.fetchedAtMs=="number"?t:null}catch{return null}}n(h,"readCache");function b(t){try{g(u,{recursive:!0}),d(f,JSON.stringify(t))}catch{}}n(b,"writeCache");function v(t,e){let i=n(r=>r.split(".").map(s=>Number.parseInt(s,10)||0),"parse"),o=i(t),c=i(e),p=Math.max(o.length,c.length);for(let r=0;r<p;r++){let s=o[r]??0,a=c[r]??0;if(s<a)return-1;if(s>a)return 1}return 0}n(v,"compareVersions");function w(){let t=process.env.RULEMETRIC_API_URL;return t?t.replace(/\/$/,""):"https://rulemetric.com"}n(w,"getApiUrl");function k(){let t=h();if(t&&Date.now()-t.fetchedAtMs<C)return;let e=new AbortController,i=setTimeout(()=>e.abort(),3e3);globalThis.fetch(`${w()}/api/cli/latest-version`,{signal:e.signal}).then(async o=>{if(clearTimeout(i),!o.ok)return;let c=await o.json();typeof c.latest=="string"&&b({latest:c.latest,fetchedAtMs:Date.now()})}).catch(()=>{clearTimeout(i)})}n(k,"refreshVersionCacheInBackground");function A(t,e){return v(e,t)<=0?null:[`RuleMetric ${e} available (you're on ${t}).`," Upgrade: npm i -g @rulemetric/cli@latest"," Then: rulemetric hooks install (re-applies capture hooks for the new version)"].join(`
2
+ `)}n(A,"formatUpgradeBanner");function I(t){let e=h();return e?A(t,e.latest):null}n(I,"getUpgradeBanner");export{k as a,A as b,I as c};
@@ -0,0 +1,2 @@
1
+ import{a}from"./chunk-ZLLER3HP.js";import{execFileSync as c}from"node:child_process";import*as l from"node:http";var f="/__rulemetric_gateway__",p="rulemetric-gateway",m=4096;function y(o,s=1500){return new Promise(u=>{let d=!1,t=a(e=>{d||(d=!0,u(e))},"finish"),n=l.get({host:"127.0.0.1",port:o,path:f,timeout:s},e=>{let r="";e.setEncoding("utf-8"),e.on("data",i=>{r+=i,r.length>m&&(n.destroy(),t({status:"foreign",detail:"oversized identity response"}))}),e.on("end",()=>{if(e.statusCode===200)try{let i=JSON.parse(r);if(i?.service===p){t({status:"ours-live",version:typeof i.version=="string"?i.version:null,pid:typeof i.pid=="number"?i.pid:null});return}}catch{}t({status:"foreign",detail:`HTTP ${e.statusCode??"?"} without identity marker`})}),e.on("error",()=>t({status:"foreign",detail:"response stream error"}))});n.on("timeout",()=>{n.destroy(),t({status:"foreign",detail:"accepted TCP but no identity response (timeout)"})}),n.on("error",e=>{let r=e.code;t(r==="ECONNREFUSED"?{status:"dead"}:{status:"foreign",detail:`socket error ${r??e.message}`})})})}a(y,"probeGatewayIdentity");async function T(o,{timeoutMs:s=3e3,intervalMs:u=150}={}){let d=Date.now()+s;for(;;){let t=await y(o,Math.min(1500,s));if(t.status!=="dead"||Date.now()>=d)return t;await new Promise(n=>setTimeout(n,u))}}a(T,"waitForGatewayIdentity");function w(o){try{return c("lsof",["-nP",`-iTCP:${o}`,"-sTCP:LISTEN"],{encoding:"utf-8",stdio:["ignore","pipe","ignore"]})}catch{return null}}a(w,"runLsofDefault");function b(o,s={}){let u=(s.runLsof??w)(o);if(!u)return null;let t=u.split(`
2
+ `).filter(r=>r.trim().length>0).find(r=>!/^COMMAND\s/.test(r));if(!t)return null;let[n,e]=t.trim().split(/\s+/);return n?e?`${n} (PID ${e})`:n:null}a(b,"describePortOwner");export{f as a,p as b,y as c,T as d,b as e};
@@ -0,0 +1,4 @@
1
+ import{a,c}from"./chunk-IZTIYR5Q.js";import{d}from"./chunk-CRAKDQ4H.js";import{a as n}from"./chunk-WPJ2BND4.js";import{b as i}from"./chunk-TIQ7DQ3M.js";import{g as r}from"./chunk-M6AJDVCL.js";import{a as s}from"./chunk-ZLLER3HP.js";import{Command as m,Flags as f}from"@oclif/core";function h(t){return t instanceof i?t.statusCode>=500||t.statusCode===408||t.statusCode===0:/fetch failed|ECONNREFUSED|ECONNRESET|ETIMEDOUT|EAI_AGAIN|bad gateway|timed out/i.test(t.message??"")}s(h,"isAvailabilityError");var u=class extends m{static{s(this,"BaseCommand")}static baseFlags={"api-url":f.string({description:"Override API base URL",env:"RULEMETRIC_API_URL",hidden:!0})};async init(){await super.init();let{flags:e}=await this.parse(this.constructor);e["api-url"]&&(process.env.RULEMETRIC_API_URL=e["api-url"]);let o=c(this.config.version);o&&!this.argv.includes("--quiet")&&!process.env.RULEMETRIC_QUIET&&process.stderr.write(`
2
+ ${o}
3
+
4
+ `),a()}requireAuth(){r()||this.error("Not logged in. Run `rulemetric auth login` to authenticate."),n()}async catch(e){throw h(e)&&await d({command:this.id,statusCode:e instanceof i?e.statusCode:void 0,message:e.message,cliVersion:this.config.version}),e instanceof i&&(e.statusCode===401&&this.error("Session expired. Run `rulemetric auth login` to re-authenticate."),this.error(e.message)),(e.message?.includes("fetch failed")||e.message?.includes("ECONNREFUSED"))&&this.error("Could not connect to the API server. Is it running?"),e}};export{u as a};
@@ -0,0 +1,5 @@
1
+ import{a as e}from"./chunk-ZLLER3HP.js";import*as t from"node:fs";import*as u from"node:path";import*as g from"node:os";function d(){return process.env.RULEMETRIC_CONFIG_DIR||u.join(g.homedir(),".config","rulemetric")}e(d,"getConfigDir");var c;function x(){if(c!==void 0)return c;try{let n=u.join(d(),"env");if(!t.existsSync(n))return c={};let r=t.readFileSync(n,"utf-8"),l=e(p=>r.match(new RegExp(`^${p}=(.+)$`,"m"))?.[1]?.trim(),"read");return c={apiKey:l("RULEMETRIC_API_KEY"),accessToken:l("RULEMETRIC_ACCESS_TOKEN"),apiUrl:l("RULEMETRIC_API_URL")},c}catch{return c={}}}e(x,"loadEnvFileAuth");function S(){c=void 0}e(S,"__resetEnvFileAuthCache");function I(n=d()){let r=u.join(n,"auth.json");function l(o){t.mkdirSync(n,{recursive:!0,mode:448}),t.writeFileSync(r,JSON.stringify(o,null,2),{encoding:"utf-8",mode:384})}e(l,"saveToken");function p(){try{let o=t.readFileSync(r,"utf-8"),i=JSON.parse(o);return i&&typeof i=="object"&&"accessToken"in i&&"expiresAt"in i&&"email"in i&&typeof i.accessToken=="string"&&typeof i.expiresAt=="string"?i:null}catch{return null}}e(p,"loadToken");function k(){try{t.unlinkSync(r)}catch{}}e(k,"clearToken");function _(){let o=p();if(!o)return!1;let i=new Date(o.expiresAt).getTime();return Number.isNaN(i)?!1:Date.now()<i}e(_,"isAuthenticated");function m(o,i){t.mkdirSync(n,{recursive:!0,mode:448});let E=u.join(n,"env"),s="";try{let h=t.readFileSync(E,"utf-8").match(/^RULEMETRIC_API_KEY=(.+)$/m);h&&(s=h[1])}catch{}let f=[`RULEMETRIC_ACCESS_TOKEN=${o}`];s&&f.push(`RULEMETRIC_API_KEY=${s}`),i&&f.push(`RULEMETRIC_API_URL=${i}`),t.writeFileSync(E,f.join(`
2
+ `)+`
3
+ `,{encoding:"utf-8",mode:384})}e(m,"saveEnvFile");function y(o,i){t.mkdirSync(n,{recursive:!0,mode:448});let E=u.join(n,"env"),s="",f="";try{let T=t.readFileSync(E,"utf-8"),A=T.match(/^RULEMETRIC_ACCESS_TOKEN=(.+)$/m);A&&(s=A[1]);let R=T.match(/^RULEMETRIC_API_URL=(.+)$/m);R&&(f=R[1])}catch{}let v=[`RULEMETRIC_API_KEY=${o}`];s&&v.push(`RULEMETRIC_ACCESS_TOKEN=${s}`);let h=i??f;h&&v.push(`RULEMETRIC_API_URL=${h}`),t.writeFileSync(E,v.join(`
4
+ `)+`
5
+ `,{encoding:"utf-8",mode:384})}e(y,"saveApiKeyToEnv");function C(){let o=u.join(n,"env");try{t.unlinkSync(o)}catch{}}return e(C,"clearEnvFile"),{saveToken:l,loadToken:p,clearToken:k,isAuthenticated:_,saveEnvFile:m,saveApiKeyToEnv:y,clearEnvFile:C,configDir:n,authFile:r}}e(I,"createAuthStore");function a(){return I()}e(a,"getStore");function F(n){a().saveToken(n)}e(F,"saveToken");function U(){return a().loadToken()}e(U,"loadToken");function L(){a().clearToken()}e(L,"clearToken");function K(){if(process.env.RULEMETRIC_API_KEY||a().isAuthenticated())return!0;let n=x();return!!(n.apiKey||n.accessToken)}e(K,"isAuthenticated");function M(n,r){a().saveEnvFile(n,r)}e(M,"saveEnvFile");function P(n,r){a().saveApiKeyToEnv(n,r)}e(P,"saveApiKey");function N(){a().clearEnvFile()}e(N,"clearEnvFile");function $(){return d()}e($,"getDefaultConfigDir");var j=d();export{x as a,S as b,I as c,F as d,U as e,L as f,K as g,M as h,P as i,N as j,$ as k,j as l};
@@ -0,0 +1 @@
1
+ import{a as E}from"./chunk-ZLLER3HP.js";import{spawn as D}from"node:child_process";async function v(x){let{prompt:f,targetContent:T,systemPrompt:w,workDir:k=process.cwd(),timeout:i=12e4,model:l}=x,n=["-p",f,"--output-format","json"],p=T??w;p&&n.push("--system-prompt",p),l&&n.push("--model",l);let s=Date.now();return new Promise(u=>{let a={...process.env};delete a.CLAUDECODE,delete a.HTTPS_PROXY;let e=D("claude",n,{cwd:k,env:a,stdio:["ignore","pipe","pipe"]}),o="",c="";e.stdout.on("data",t=>{o+=t.toString()}),e.stderr.on("data",t=>{c+=t.toString()});let m=setTimeout(()=>{e.kill("SIGTERM"),u({output:o,exitCode:null,durationMs:Date.now()-s,totalTokens:0,error:`Timed out after ${i}ms`})},i);e.on("close",t=>{clearTimeout(m);let C=Date.now()-s,d=0,g=o;try{let r=JSON.parse(o);g=r.result??r.content??o,d=r.usage?.total_tokens??(r.usage?.input_tokens??0)+(r.usage?.output_tokens??0)}catch{}u({output:g,exitCode:t,durationMs:C,totalTokens:d,error:t!==0?c||`Exit code ${t}`:void 0})}),e.on("error",t=>{clearTimeout(m),u({output:"",exitCode:null,durationMs:Date.now()-s,totalTokens:0,error:`Failed to spawn claude: ${t.message}`})})})}E(v,"executeEval");export{v as a};
@@ -0,0 +1 @@
1
+ import{c as H}from"./chunk-PZS2KOU7.js";import{b as h}from"./chunk-RTEATXTP.js";import{a as R}from"./chunk-7XQ4VPLC.js";import{a as E}from"./chunk-RSKQRVPJ.js";import{a as S}from"./chunk-HOHD5HY2.js";import{a as T}from"./chunk-V5QFOF4F.js";import{a as _}from"./chunk-UF6US7VU.js";import{a as k}from"./chunk-IY5NXR3N.js";import{a as A}from"./chunk-72XLQE3X.js";import{a as I}from"./chunk-I4YJ7NTX.js";import{a as w}from"./chunk-F2VP4B4J.js";import{a as b}from"./chunk-E4SFUPYR.js";import{b as v}from"./chunk-5RBLIVBF.js";import{b as g,d as f,e as m}from"./chunk-TIQ7DQ3M.js";import{a as o}from"./chunk-ZLLER3HP.js";var P={process_eval:w,process_insights:b,process_launch:h,process_send_message:E,process_conversation:I,process_session_goal:S,process_announcement:A,process_run_cleanup:R,cron_suggest_instructions:k,cron_refresh_skills:_,cron_refresh_pricing:T},y=Object.keys(P),C=new Set(["process_session_goal","process_announcement","process_run_cleanup"]);function V(e=process.env){return e.DATABASE_URL?y:y.filter(n=>!C.has(n))}o(V,"availableCapabilities");var x=3e4,O=3e4,W=3e4,M=250,L=5e3,$=`thin-agent-${process.pid}`;function B(e,n,r,l){let s=o(t=>{m("/api/workers/heartbeat",{workerType:"cli-worker",clientName:$,clientVersion:l,workerVersion:"0.1.0",currentJobId:null,inFlightCount:0,lastError:null,status:t,metadata:{capabilities:e,mode:"thin-agent"}}).catch(d=>{i(r,{event:"presence_heartbeat_error",error:d instanceof Error?d.message:String(d)})})},"send");s("alive");let c=setInterval(()=>s("alive"),W);n.addEventListener("abort",()=>{clearInterval(c),s("shutting_down")},{once:!0})}o(B,"startPresenceHeartbeat");function i(e,n){try{e(JSON.stringify({ts:new Date().toISOString(),...n}))}catch{e(`[agent-loop] log_error event=${n.event}`)}}o(i,"structuredLog");function N(e,n){return n.aborted?Promise.resolve(!1):e<=0?Promise.resolve(!0):new Promise(r=>{let l=setTimeout(()=>{n.removeEventListener("abort",s),r(!0)},e),s=o(()=>{clearTimeout(l),n.removeEventListener("abort",s),r(!1)},"onAbort");n.addEventListener("abort",s,{once:!0})})}o(N,"abortableSleep");async function F(e,n){let r=`capabilities=${encodeURIComponent(e.join(","))}&waitMs=${n}`,l=await f(`/api/work/next?${r}`);return l==null||typeof l=="string"?null:l}o(F,"pollForWork");function J(e,n){return{logger:{info:o(r=>n(r),"info"),warn:o(r=>n(r),"warn"),error:o(r=>n(r),"error")},job:{attempts:e}}}o(J,"makeHelpers");async function U(e,n,r){let l=P[e.kind],s=Date.now();if(i(r,{event:"claim",jobId:e.id,kind:e.kind,attempts:e.attempts}),!l){let t=`unknown kind: ${e.kind}`;i(r,{event:"fail",jobId:e.id,kind:e.kind,terminal:!0,error:t}),await m(`/api/work/${e.id}/fail`,{leaseToken:e.leaseToken,error:t,terminal:!0}).catch(()=>{});return}let c=setInterval(()=>{i(r,{event:"heartbeat",jobId:e.id}),m(`/api/work/${e.id}/heartbeat`,{leaseToken:e.leaseToken}).catch(t=>{i(r,{event:"heartbeat_error",jobId:e.id,error:t instanceof Error?t.message:String(t)})})},n);try{let t=J(e.attempts,r),d=await l(e.payload,t)??{};clearInterval(c),i(r,{event:"complete",jobId:e.id,kind:e.kind,durationMs:Date.now()-s}),await m(`/api/work/${e.id}/complete`,{leaseToken:e.leaseToken,result:d})}catch(t){clearInterval(c);let d=v(t),p=t instanceof Error?t.message:String(t);i(r,{event:"fail",jobId:e.id,kind:e.kind,durationMs:Date.now()-s,terminal:d,error:p}),await m(`/api/work/${e.id}/fail`,{leaseToken:e.leaseToken,error:p,terminal:d}).catch(a=>{i(r,{event:"fail_post_error",jobId:e.id,error:a instanceof Error?a.message:String(a)})})}}o(U,"runOne");async function ae(e){let n=e.log??(()=>{}),r=e.pollWaitMs??x,l=e.heartbeatIntervalMs??O,s=e.capabilities??V(),c=M;i(n,{event:"agent_start",capabilities:s,pollWaitMs:r,heartbeatIntervalMs:l}),B(s,e.signal,n,e.version),H({signal:e.signal,log:n}).catch(a=>{i(n,{event:"tt_heartbeat_fatal",error:a instanceof Error?a.message:String(a)})});let t=5*6e4,d=0,p=o(()=>{if(!e.readInstalledVersion||!e.version)return!1;let a=Date.now();if(a-d<t)return!1;d=a;let u=e.readInstalledVersion();return!!(u&&u!==e.version)},"versionDrifted");for(;!e.signal.aborted;){if(p()){i(n,{event:"agent_version_drift",bootVersion:e.version,installedVersion:e.readInstalledVersion?.()??null}),e.onVersionDrift?.();break}let a=null;try{a=await F(s,r)}catch(u){let D=u instanceof g?u.statusCode:void 0;if(i(n,{event:"poll_error",status:D,error:u instanceof Error?u.message:String(u)}),!await N(c,e.signal))break;c=Math.min(c*2,L);continue}if(!a){if(i(n,{event:"poll_204"}),!await N(c,e.signal))break;c=Math.min(c*2,L);continue}c=M,await U(a,l,n)}i(n,{event:"agent_stop"})}o(ae,"runAgentLoop");export{P as a,y as b,V as c,F as d,ae as e};
@@ -0,0 +1 @@
1
+ import{a as t}from"./chunk-ZLLER3HP.js";import{realpathSync as e}from"node:fs";import a from"node:path";function m(o){let r=a.resolve(o);try{return e(r)}catch{return r}}t(m,"normalizeProjectPath");export{m as a};
@@ -0,0 +1,4 @@
1
+ import{c as d,d as w}from"./chunk-KKDHD4XA.js";import{a as y,d as p}from"./chunk-SZ62CP55.js";import{a as r}from"./chunk-ZLLER3HP.js";import{spawn as G}from"node:child_process";import{createConnection as b}from"node:net";import{existsSync as I,mkdirSync as E,openSync as P,readFileSync as R,unlinkSync as T,writeFileSync as h}from"node:fs";import{homedir as _}from"node:os";import{dirname as x,join as m,resolve as a}from"node:path";import{fileURLToPath as L}from"node:url";var s=x(L(import.meta.url)),l=m(_(),".config","rulemetric"),c=m(l,"gateway.pid"),M=m(l,"gateway.log"),u=8787,U=8788;function A(e=u,t=1500){return new Promise(i=>{let n=b({host:"127.0.0.1",port:e}),o=r(g=>{n.destroy(),i(g)},"finish");n.setTimeout(t),n.once("connect",()=>o(!0)),n.once("timeout",()=>o(!1)),n.once("error",()=>o(!1))})}r(A,"isGatewayListening");async function W(e=u,{timeoutMs:t=3e3,intervalMs:i=150}={}){let n=Date.now()+t;for(;;){if(await A(e,Math.min(1500,t)))return!0;if(Date.now()>=n)return!1;await new Promise(o=>setTimeout(o,i))}}r(W,"waitForGatewayListening");function V(e=u,t=1500){return d(e,t)}r(V,"isRulemetricGatewayListening");function X(e=u,t={}){return w(e,t)}r(X,"waitForRulemetricGateway");function O(e={}){let t=f();return t===null?!1:p(t,y,e)}r(O,"isGatewayRunning");function f(){if(!I(c))return null;let e=R(c,"utf-8").trim(),t=parseInt(e,10);return isNaN(t)?null:t}r(f,"getGatewayPid");function F(){let e=[a(s,"./gateway-entry.js"),a(s,"./lib/gateway-entry.js"),a(s,"../lib/gateway-entry.js"),a(s,"../../lib/gateway-entry.js")];for(let t of e)if(I(t))return t;throw new Error(`Could not find gateway-entry.js. Is the CLI built?
2
+ Searched:
3
+ `+e.map(t=>` ${t}`).join(`
4
+ `))}r(F,"findGatewayEntry");function $(e){if(O()){let o=f();if(o)return o}E(l,{recursive:!0});let t=F(),i=P(M,"a"),n=G(process.execPath,[t],{detached:!0,stdio:["ignore",i,i],env:{...process.env,RULEMETRIC_CLI_VERSION:e??"unknown",RULEMETRIC_CLI_ENTRY:process.argv[1]??""}});if(n.unref(),!n.pid)throw new Error("Failed to spawn gateway process");return h(c,String(n.pid)),n.pid}r($,"spawnGateway");function q(e={}){let t=f();if(t===null)return!1;if(p(t,y,e))try{process.kill(t,"SIGTERM")}catch{}try{T(c)}catch{}return!0}r(q,"stopGateway");export{c as a,M as b,u as c,U as d,A as e,W as f,V as g,X as h,O as i,f as j,$ as k,q as l};
@@ -0,0 +1 @@
1
+ import{a as t}from"./chunk-ZLLER3HP.js";import{spawn as i}from"node:child_process";function u(){let n=["/opt/homebrew/bin","/usr/local/bin"],r=(process.env.PATH??"").split(":").filter(Boolean),e=n.filter(o=>!r.includes(o));return e.length===0?process.env:{...process.env,PATH:[...r,...e].join(":")}}t(u,"tmuxSpawnEnv");function l(n){return new Promise(r=>{let e=i("tmux",n,{stdio:["ignore","ignore","pipe"],env:u()}),o="";e.stderr.on("data",s=>{o+=s.toString()}),e.on("close",s=>r({code:s,stderr:o})),e.on("error",s=>r({code:null,stderr:s.message}))})}t(l,"runTmux");function g(n){return["has-session","-t",n]}t(g,"buildTmuxHasSessionArgs");function p(n,r){return["send-keys","-t",n,"-l","--",r]}t(p,"buildTmuxSendLiteralArgs");function d(n){return["send-keys","-t",n,"Enter"]}t(d,"buildTmuxSendEnterArgs");export{u as a,l as b,g as c,p as d,d as e};
@@ -0,0 +1 @@
1
+ import{d as i,e as n,g,h as m}from"./chunk-NJ5UED3H.js";import{b as f}from"./chunk-ZXF5NE54.js";import{a as s}from"./chunk-ZLLER3HP.js";import{Box as u,Text as t}from"ink";import{jsx as l,jsxs as e}from"react/jsx-runtime";var y={pending:{glyph:"\u25CC",color:n},queued:{glyph:"\u25CC",color:n},running:{glyph:"\u25CF",color:i},completed:{glyph:"\u2713",color:g},failed:{glyph:"\u2717",color:m},cancelled:{glyph:"\u2298",color:n}};function b(c){let p=Date.now()-new Date(c).getTime(),r=Math.floor(p/6e4);if(r<1)return"now";if(r<60)return`${r}m`;let o=Math.floor(r/60);return o<24?`${o}h`:`${Math.floor(o/24)}d`}s(b,"ago");function w({jobs:c,selectedIndex:p,focused:r}){return c.length===0?e(u,{flexDirection:"column",paddingX:1,children:[l(t,{bold:!0,color:i,children:"\u25BC Active jobs"}),l(t,{dimColor:!0,children:" (no jobs yet \u2014 press tab to focus the form below)"})]}):e(u,{flexDirection:"column",paddingX:1,children:[e(t,{bold:!0,color:i,children:["\u25BC Active jobs (last ",c.length,")"]}),c.map((o,h)=>{let d=r&&h===p,a=y[o.status]??{glyph:"?",color:n},x=o.config?.projectPath??"",T=(o.config?.prompt??"").slice(0,30);return e(t,{wrap:"truncate-end",children:[l(t,{color:d?i:n,children:d?"\u25B6 ":" "}),e(t,{color:a.color,children:[a.glyph," "]}),l(t,{dimColor:!0,children:o.status.padEnd(10)}),l(t,{children:f(o.tool).padEnd(14)}),l(t,{dimColor:!0,children:x.padEnd(28)}),e(t,{children:['"',T,'"']}),e(t,{dimColor:!0,children:[" ",b(o.createdAt)]})]},o.id)})]})}s(w,"ActiveJobsList");export{w as a};
@@ -0,0 +1 @@
1
+ import{a as r}from"./chunk-ZLLER3HP.js";var o=["today","week","30days","month","all"],s={today:"Today",week:"7 Days","30days":"30 Days",month:"This Month",all:"All Time"};function a(n){let t=new Date,e=new Date(t.getFullYear(),t.getMonth(),t.getDate(),23,59,59,999);switch(n){case"today":return{start:new Date(t.getFullYear(),t.getMonth(),t.getDate()),end:e};case"week":return{start:new Date(t.getFullYear(),t.getMonth(),t.getDate()-7),end:e};case"30days":return{start:new Date(t.getFullYear(),t.getMonth(),t.getDate()-30),end:e};case"month":return{start:new Date(t.getFullYear(),t.getMonth(),1),end:e};case"all":return{start:new Date(0),end:e}}}r(a,"getDateRange");var i="#FF8C42",u="#555555",g="#FFD700",l="#5BF58C",c="#F55B5B",m="#5B9EF5";export{o as a,s as b,a as c,i as d,u as e,g as f,l as g,c as h,m as i};
@@ -0,0 +1,3 @@
1
+ import{a}from"./chunk-ZLLER3HP.js";import{promises as d}from"node:fs";import b from"node:path";import h from"node:os";var _=new Set(["America/Phoenix","America/Los_Angeles","America/Denver","America/Chicago","America/New_York","America/Anchorage","America/Toronto","America/Vancouver","America/Mexico_City","America/Sao_Paulo","Europe/London","Europe/Berlin","Europe/Paris","Europe/Madrid","Europe/Amsterdam","Europe/Zurich","Europe/Stockholm","Europe/Athens","Asia/Tokyo","Asia/Shanghai","Asia/Hong_Kong","Asia/Singapore","Asia/Kolkata","Asia/Dubai","Asia/Jerusalem","Australia/Sydney","Australia/Melbourne","Pacific/Auckland","Pacific/Honolulu","UTC"]);function N(r,t){try{let e=new Intl.DateTimeFormat("en-US",{timeZone:t,hour12:!1,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"}).formatToParts(r),s=a(g=>e.find(p=>p.type===g)?.value,"get"),c=Number(s("year")),l=Number(s("month")),u=Number(s("day")),o=Number(s("hour")),i=Number(s("minute")),f=Number(s("second"));o===24&&(o=0);let m=Date.UTC(c,l-1,u,o,i,f);return Math.round((m-r.getTime())/6e4)}catch{return null}}a(N,"getTimezoneOffsetMinutes");function E(r,t){let n=r.match(/reset(?:s|\s+at)?\s+(?:at\s+)?(\d{1,2})(?::(\d{2}))?\s*(am|pm)?\s*(?:\(([^)]+)\))?/i);if(!n)return null;let e=parseInt(n[1],10),s=n[2]?parseInt(n[2],10):0,c=n[3]?.toLowerCase(),l=n[4]?.trim();if(c==="pm"&&e<12&&(e+=12),c==="am"&&e===12&&(e=0),Number.isNaN(e)||Number.isNaN(s)||e>23||s>59)return null;let u=l&&_.has(l)?l:"UTC",o=N(t,u);if(o==null)return null;let i;try{let m=new Intl.DateTimeFormat("en-CA",{timeZone:u,year:"numeric",month:"2-digit",day:"2-digit"}).formatToParts(t),g=Number(m.find(y=>y.type==="year")?.value),p=Number(m.find(y=>y.type==="month")?.value),A=Number(m.find(y=>y.type==="day")?.value),T=Date.UTC(g,p-1,A,e,s,0)-o*6e4;i=new Date(T)}catch{return null}return i.getTime()<=t.getTime()&&(i=new Date(i.getTime()+1440*60*1e3)),i}a(E,"parseResetsAtFromMessage");function x(r,t){if(!t)return"five_hour_percent";let n=t.getTime()-r.getTime(),e=5.5*60*60*1e3;return n<=e?"five_hour_percent":"seven_day_percent"}a(x,"pickLimitType");function D(r){let t=[];r.content&&t.push(r.content),r.message?.content&&t.push(r.message.content);for(let n of t){if(typeof n=="string")return n;if(Array.isArray(n)){for(let e of n)if(e&&typeof e=="object"&&"text"in e){let s=e.text;if(typeof s=="string")return s}}}return""}a(D,"extractText");function O(r,t){let n=r.trim();if(!n)return null;let e;try{e=JSON.parse(n)}catch{return null}if(!(e.apiErrorStatus===429||e.error==="rate_limit"||e.isApiErrorMessage===!0))return null;let c=D(e);if(!(e.apiErrorStatus===429||e.error==="rate_limit"||/rate.?limit|usage limit|out of (?:extra )?usage|resets?/i.test(c)))return null;let u=e.timestamp?new Date(e.timestamp):new Date,o=isNaN(u.getTime())?new Date:u,i=c?E(c,o):null;return{provider:"anthropic",plan:"unknown",limitType:x(o,i),value:100,unit:"percentage",comparator:"=",resetsAt:i,sourceType:"self_observed_429",sourceUrl:t??null,sourceEvidence:{line:n,sessionId:e.sessionId??null,transcriptPath:t??null},confidence:.9,observedAt:o}}a(O,"lineToObservation");async function k(r,t){let n;try{n=await d.stat(r)}catch{return{observations:[],newOffset:t}}let e=t;if(n.size<t&&(e=0),n.size===e)return{observations:[],newOffset:e};let s;try{s=await d.open(r,"r")}catch{return{observations:[],newOffset:t}}try{let c=n.size-e,l=Buffer.alloc(c);await s.read(l,0,c,e);let u=l.toString("utf-8"),o=u.lastIndexOf(`
2
+ `),i,f;if(o===-1)return{observations:[],newOffset:e};i=u.slice(0,o+1),f=e+Buffer.byteLength(i,"utf-8");let m=[];for(let g of i.split(`
3
+ `)){let p=O(g,r);p&&m.push(p)}return{observations:m,newOffset:f}}finally{await s.close()}}a(k,"tailJsonl");async function*v(r){let t;try{t=await d.readdir(r,{withFileTypes:!0})}catch{return}for(let n of t){let e=b.join(r,n.name);n.isDirectory()?yield*v(e):n.isFile()&&n.name.endsWith(".jsonl")&&(yield e)}}a(v,"walkJsonl");async function j(r=b.join(h.homedir(),".claude")){let t=b.join(r,"projects"),n=[];for await(let e of v(t)){let{observations:s}=await k(e,0);n.push(...s)}return n}a(j,"scanAllTranscripts");function w(){return b.join(h.homedir(),".config","rulemetric","transcript-offsets.json")}a(w,"offsetCachePath");async function I(){try{let r=await d.readFile(w(),"utf-8"),t=JSON.parse(r);return t&&typeof t=="object"?t:{}}catch{return{}}}a(I,"loadOffsets");async function C(r){let t=w();await d.mkdir(b.dirname(t),{recursive:!0}),await d.writeFile(t,JSON.stringify(r,null,2),"utf-8")}a(C,"saveOffsets");export{E as a,x as b,O as c,k as d,j as e,w as f,I as g,C as h};
@@ -0,0 +1 @@
1
+ import{a as p,c as Zn}from"./chunk-ZLLER3HP.js";import{boolean as co,pgTable as er,text as ye,timestamp as yt,uuid as po}from"drizzle-orm/pg-core";import{pgTable as Ge,text as W,timestamp as he,jsonb as uo,uuid as B,primaryKey as lo}from"drizzle-orm/pg-core";var a=Ge("organizations",{id:B("id").primaryKey().defaultRandom(),name:W("name").unique().notNull(),slug:W("slug").unique().notNull(),metadata:uo("metadata"),createdAt:he("created_at",{withTimezone:!0}).defaultNow(),updatedAt:he("updated_at",{withTimezone:!0}).defaultNow()}),x=Ge("teams",{id:B("id").primaryKey().defaultRandom(),orgId:B("org_id").references(()=>a.id,{onDelete:"cascade"}),name:W("name").notNull(),slug:W("slug").notNull(),metadata:uo("metadata"),createdAt:he("created_at",{withTimezone:!0}).defaultNow()}),X=Ge("user_organizations",{userId:B("user_id").notNull(),orgId:B("org_id").references(()=>a.id,{onDelete:"cascade"}).notNull(),role:W("role").notNull().default("member"),createdAt:he("created_at",{withTimezone:!0}).defaultNow()},e=>[lo({columns:[e.userId,e.orgId]})]),$=Ge("user_teams",{userId:B("user_id").notNull(),teamId:B("team_id").references(()=>x.id,{onDelete:"cascade"}).notNull(),role:W("role").notNull().default("member"),createdAt:he("created_at",{withTimezone:!0}).defaultNow()},e=>[lo({columns:[e.userId,e.teamId]})]);var s=er("profiles",{id:po("id").primaryKey(),email:ye("email"),displayName:ye("display_name"),avatarUrl:ye("avatar_url"),activeOrgId:po("active_org_id").references(()=>a.id,{onDelete:"set null"}),isSuperadmin:co("is_superadmin").notNull().default(!1),claudeCodePlan:ye("claude_code_plan"),planSource:ye("plan_source").notNull().default("detected"),setupCompletedAt:yt("setup_completed_at",{withTimezone:!0}),liveSendSkipped:co("live_send_skipped").notNull().default(!1),createdAt:yt("created_at",{withTimezone:!0}).defaultNow(),updatedAt:yt("updated_at",{withTimezone:!0}).defaultNow()});import{pgTable as sr,text as ee,timestamp as At,jsonb as go,uuid as Ye,integer as ir,boolean as ar,index as bt}from"drizzle-orm/pg-core";import{boolean as or,jsonb as nr,pgTable as wt,primaryKey as fo,text as U,timestamp as Te,uniqueIndex as Tt,uuid as H}from"drizzle-orm/pg-core";import{sql as rr}from"drizzle-orm";import{pgTable as _o,text as f,timestamp as Ie,jsonb as Ve,uuid as j,integer as It,boolean as tr,uniqueIndex as mo,index as Je}from"drizzle-orm/pg-core";var o=_o("instructions",{id:j("id").primaryKey().defaultRandom(),name:f("name").notNull(),description:f("description").notNull(),type:f("type").notNull().default("instruction"),scope:f("scope").notNull(),scopeRef:j("scope_ref"),version:f("version").notNull(),content:f("content").notNull(),frontmatter:Ve("frontmatter").notNull(),slots:Ve("slots"),tags:f("tags").array(),compatibility:f("compatibility").array(),createdBy:j("created_by"),createdAt:Ie("created_at",{withTimezone:!0}).defaultNow(),updatedAt:Ie("updated_at",{withTimezone:!0}).defaultNow(),archived:tr("archived").default(!1),archivedAt:Ie("archived_at",{withTimezone:!0}),archivedBy:j("archived_by"),forkedFromId:j("forked_from_id").references(()=>o.id,{onDelete:"set null"}),upstreamVersion:f("upstream_version"),badge:f("badge"),contentHash:f("content_hash"),contextIdentity:f("context_identity"),scanScore:It("scan_score"),scanFindings:Ve("scan_findings"),popularityScore:It("popularity_score"),sourceUpdatedAt:Ie("source_updated_at",{withTimezone:!0})},e=>[mo("instructions_name_scope_ref_idx").on(e.name,e.scope,e.scopeRef),Je("idx_instructions_scope").on(e.scope,e.scopeRef),Je("idx_instructions_created_by").on(e.createdBy),Je("idx_instructions_context_identity").on(e.createdBy,e.contextIdentity),Je("idx_instructions_public_recency").on(e.scope,e.sourceUpdatedAt.desc())]),Z=_o("instruction_versions",{id:j("id").primaryKey().defaultRandom(),instructionId:j("instruction_id").references(()=>o.id,{onDelete:"cascade"}),versionNumber:It("version_number").notNull(),content:f("content").notNull(),frontmatter:Ve("frontmatter").notNull(),changeSummary:f("change_summary"),createdBy:j("created_by"),createdAt:Ie("created_at",{withTimezone:!0}).defaultNow()},e=>[mo("instruction_versions_instruction_version_idx").on(e.instructionId,e.versionNumber)]);var l=wt("projects",{id:H("id").primaryKey().defaultRandom(),orgId:H("org_id").references(()=>a.id,{onDelete:"cascade"}),name:U("name").notNull(),description:U("description"),githubRepo:U("github_repo"),gitRemoteUrl:U("git_remote_url"),gitRootCommit:U("git_root_commit"),gitRemoteAliases:U("git_remote_aliases").array().notNull().default([]),metadata:nr("metadata"),createdBy:H("created_by"),createdAt:Te("created_at",{withTimezone:!0}).defaultNow(),updatedAt:Te("updated_at",{withTimezone:!0}).defaultNow()},e=>[Tt("projects_org_name_idx").on(e.orgId,e.name),Tt("projects_git_remote_url_unique").on(e.gitRemoteUrl).where(rr`${e.gitRemoteUrl} IS NOT NULL`)]),E=wt("project_instructions",{projectId:H("project_id").references(()=>l.id,{onDelete:"cascade"}).notNull(),instructionId:H("instruction_id").references(()=>o.id,{onDelete:"cascade"}).notNull(),addedAt:Te("added_at",{withTimezone:!0}).defaultNow(),addedBy:H("added_by")},e=>[fo({columns:[e.projectId,e.instructionId]})]),xo=wt("project_checkouts",{projectId:H("project_id").references(()=>l.id,{onDelete:"cascade"}).notNull(),path:U("path").notNull(),isWorktree:or("is_worktree").notNull().default(!1),firstSeen:Te("first_seen",{withTimezone:!0}).notNull().defaultNow(),lastSeen:Te("last_seen",{withTimezone:!0}).notNull().defaultNow()},e=>[fo({columns:[e.projectId,e.path]}),Tt("project_checkouts_path_unique").on(e.path)]);var m=sr("agent_runs",{id:Ye("id").primaryKey().defaultRandom(),userId:Ye("user_id").notNull().references(()=>s.id,{onDelete:"cascade"}),orgId:Ye("org_id").references(()=>a.id,{onDelete:"set null"}),projectId:Ye("project_id").references(()=>l.id,{onDelete:"set null"}),projectPath:ee("project_path"),gitRemote:ee("git_remote"),baseBranch:ee("base_branch"),title:ee("title"),prompt:ee("prompt"),toolSpec:go("tool_spec").notNull().default([]),autoWorktree:ar("auto_worktree").notNull().default(!0),status:ee("status").notNull().default("pending"),sessionCount:ir("session_count").notNull().default(0),metadata:go("metadata").notNull().default({}),createdAt:At("created_at",{withTimezone:!0}).notNull().defaultNow(),updatedAt:At("updated_at",{withTimezone:!0}).notNull().defaultNow(),completedAt:At("completed_at",{withTimezone:!0})},e=>[bt("idx_agent_runs_user").on(e.userId),bt("idx_agent_runs_org_created").on(e.orgId,e.createdAt),bt("idx_agent_runs_project").on(e.projectId)]);import{pgTable as zt,text as y,timestamp as we,jsonb as F,uuid as w,integer as Qe,uniqueIndex as No,index as h}from"drizzle-orm/pg-core";var u=zt("sessions",{id:w("id").primaryKey().defaultRandom(),userId:w("user_id").notNull().references(()=>s.id,{onDelete:"cascade"}),externalSessionId:y("external_session_id"),projectId:w("project_id").references(()=>l.id,{onDelete:"set null"}),orgId:w("org_id").references(()=>a.id,{onDelete:"set null"}),tool:y("tool").notNull(),projectPath:y("project_path"),gitBranch:y("git_branch"),startedAt:we("started_at",{withTimezone:!0}).notNull(),endedAt:we("ended_at",{withTimezone:!0}),eventCount:Qe("event_count").default(0),tokenUsage:F("token_usage"),analysis:F("analysis"),analyzedAt:we("analyzed_at",{withTimezone:!0}),analyzedEventCount:Qe("analyzed_event_count"),analyzedTurnCount:Qe("analyzed_turn_count"),metadata:F("metadata").default({}),origin:y("origin").notNull().default("unknown"),runId:w("run_id").references(()=>m.id,{onDelete:"set null"}),createdAt:we("created_at",{withTimezone:!0}).defaultNow()},e=>[h("idx_sessions_user").on(e.userId),h("idx_sessions_tool").on(e.tool),h("idx_sessions_started_at").on(e.startedAt),h("idx_sessions_project").on(e.projectId),h("idx_sessions_org_started_at").on(e.orgId,e.startedAt),h("idx_sessions_run").on(e.runId),No("idx_sessions_user_external").on(e.userId,e.externalSessionId)]),te=zt("session_events",{id:w("id").primaryKey().defaultRandom(),sessionId:w("session_id").notNull().references(()=>u.id,{onDelete:"cascade"}),sequence:Qe("sequence").notNull(),eventType:y("event_type").notNull(),content:y("content"),toolName:y("tool_name"),toolInput:F("tool_input"),toolOutput:F("tool_output"),tokenUsage:F("token_usage"),model:y("model"),timestamp:we("timestamp",{withTimezone:!0}).notNull(),metadata:F("metadata").default({})},e=>[No("session_events_session_sequence_idx").on(e.sessionId,e.sequence),h("idx_session_events_session_id").on(e.sessionId),h("idx_session_events_event_type").on(e.eventType),h("idx_session_events_model").on(e.model)]),S=zt("session_instructions",{sessionId:w("session_id").notNull().references(()=>u.id,{onDelete:"cascade"}),instructionId:w("instruction_id").notNull().references(()=>o.id,{onDelete:"cascade"}),linkMethod:y("link_method").notNull()},e=>[h("idx_session_instructions_instruction_id").on(e.instructionId)]);import{boolean as dr,date as ur,index as kt,integer as lr,jsonb as cr,pgTable as Rt,text as N,timestamp as P,uniqueIndex as pr,uuid as oe}from"drizzle-orm/pg-core";var vo=Rt("announcements",{id:oe("id").primaryKey().defaultRandom(),version:N("version").notNull().unique(),releaseDate:ur("release_date").notNull(),subject:N("subject").notNull(),htmlBody:N("html_body").notNull(),textBody:N("text_body").notNull(),sections:cr("sections").notNull().default({}),status:N("status").notNull().default("draft"),recipientCount:lr("recipient_count"),sentAt:P("sent_at",{withTimezone:!0}),sentBy:oe("sent_by"),error:N("error"),createdAt:P("created_at",{withTimezone:!0}).notNull().defaultNow(),updatedAt:P("updated_at",{withTimezone:!0}).notNull().defaultNow()},e=>[kt("idx_announcements_status").on(e.status),kt("idx_announcements_created").on(e.createdAt)]),ho=Rt("announcement_deliveries",{id:oe("id").primaryKey().defaultRandom(),announcementId:oe("announcement_id").notNull(),userId:oe("user_id").notNull(),email:N("email").notNull(),status:N("status").notNull().default("pending"),providerId:N("provider_id"),error:N("error"),sentAt:P("sent_at",{withTimezone:!0}),createdAt:P("created_at",{withTimezone:!0}).notNull().defaultNow()},e=>[pr("uniq_announcement_deliveries_announcement_user").on(e.announcementId,e.userId),kt("idx_announcement_deliveries_user").on(e.userId,e.createdAt)]),yo=Rt("notification_preferences",{userId:oe("user_id").primaryKey(),productAnnouncements:dr("product_announcements").notNull().default(!0),unsubscribeToken:N("unsubscribe_token").notNull().unique(),unsubscribedAt:P("unsubscribed_at",{withTimezone:!0}),createdAt:P("created_at",{withTimezone:!0}).notNull().defaultNow(),updatedAt:P("updated_at",{withTimezone:!0}).notNull().defaultNow()});import{pgTable as _r,text as Dt,timestamp as We,uuid as Xe,index as Io}from"drizzle-orm/pg-core";var A=_r("org_invitations",{id:Xe("id").primaryKey().defaultRandom(),orgId:Xe("org_id").notNull().references(()=>a.id,{onDelete:"cascade"}),email:Dt("email").notNull(),role:Dt("role").notNull().default("member"),teamId:Xe("team_id").references(()=>x.id,{onDelete:"set null"}),invitedBy:Xe("invited_by").notNull().references(()=>s.id),token:Dt("token").notNull().unique(),expiresAt:We("expires_at",{withTimezone:!0}).notNull(),acceptedAt:We("accepted_at",{withTimezone:!0}),revokedAt:We("revoked_at",{withTimezone:!0}),createdAt:We("created_at",{withTimezone:!0}).notNull().defaultNow()},e=>[Io("idx_org_invitations_token").on(e.token),Io("idx_org_invitations_org").on(e.orgId)]);import{pgTable as mr,text as fr,timestamp as xr,jsonb as gr,uuid as jt,index as To}from"drizzle-orm/pg-core";var ne=mr("instruction_events",{id:jt("id").primaryKey().defaultRandom(),instructionId:jt("instruction_id").notNull().references(()=>o.id,{onDelete:"cascade"}),eventType:fr("event_type").notNull(),actorId:jt("actor_id").notNull(),metadata:gr("metadata"),createdAt:xr("created_at",{withTimezone:!0}).defaultNow()},e=>[To("idx_instruction_events_instruction").on(e.instructionId),To("idx_instruction_events_type").on(e.eventType)]);import{pgTable as Nr,text as re,timestamp as Et,uuid as St,jsonb as vr,uniqueIndex as hr,index as wo}from"drizzle-orm/pg-core";var $e=Nr("session_terminal_targets",{id:St("id").primaryKey().defaultRandom(),userId:St("user_id").notNull().references(()=>s.id,{onDelete:"cascade"}),sessionId:St("session_id").references(()=>u.id,{onDelete:"set null"}),externalSessionId:re("external_session_id"),kind:re("kind").notNull(),target:re("target").notNull(),status:re("status").notNull().default("active"),attachCommand:re("attach_command").notNull(),projectPath:re("project_path"),metadata:vr("metadata").notNull().default({}),lastSeenAt:Et("last_seen_at",{withTimezone:!0}).defaultNow(),createdAt:Et("created_at",{withTimezone:!0}).defaultNow(),updatedAt:Et("updated_at",{withTimezone:!0}).defaultNow()},e=>[hr("idx_session_terminal_targets_user_target").on(e.userId,e.target),wo("idx_session_terminal_targets_session").on(e.sessionId),wo("idx_session_terminal_targets_user_status").on(e.userId,e.status)]);import{boolean as yr,bigint as Ir,index as Ze,jsonb as Ao,pgTable as Tr,text as G,timestamp as Ae,uuid as et,integer as wr}from"drizzle-orm/pg-core";var bo=Tr("session_send_jobs",{id:et("id").primaryKey().defaultRandom(),userId:et("user_id").notNull(),sessionId:et("session_id").notNull().references(()=>u.id,{onDelete:"cascade"}),terminalTargetId:et("terminal_target_id").references(()=>$e.id,{onDelete:"set null"}),target:G("target").notNull(),message:G("message").notNull(),submit:yr("submit").notNull().default(!0),delivery:G("delivery").notNull().default("live"),status:G("status").notNull().default("pending"),result:Ao("result"),error:G("error"),attempts:wr("attempts").notNull().default(0),graphileJobId:Ir("graphile_job_id",{mode:"number"}),taskKind:G("task_kind"),payload:Ao("payload"),claimedBy:G("claimed_by"),claimedAt:Ae("claimed_at",{withTimezone:!0}),leaseExpiresAt:Ae("lease_expires_at",{withTimezone:!0}),createdAt:Ae("created_at",{withTimezone:!0}).defaultNow(),updatedAt:Ae("updated_at",{withTimezone:!0}).defaultNow(),completedAt:Ae("completed_at",{withTimezone:!0})},e=>[Ze("idx_session_send_jobs_user").on(e.userId),Ze("idx_session_send_jobs_session").on(e.sessionId),Ze("idx_session_send_jobs_status").on(e.status),Ze("idx_session_send_jobs_pending").on(e.userId,e.status)]);import{pgTable as ko,text as J,timestamp as tt,jsonb as Ro,uuid as K,integer as Ar,boolean as br,uniqueIndex as zr,index as zo,primaryKey as kr}from"drizzle-orm/pg-core";var v=ko("packs",{id:K("id").primaryKey().defaultRandom(),name:J("name").notNull(),description:J("description").notNull(),scope:J("scope").notNull(),scopeRef:K("scope_ref"),version:J("version").notNull().default("1.0.0"),tags:J("tags").array(),badge:J("badge"),metadata:Ro("metadata"),createdBy:K("created_by"),createdAt:tt("created_at",{withTimezone:!0}).defaultNow(),updatedAt:tt("updated_at",{withTimezone:!0}).defaultNow(),archived:br("archived").default(!1),archivedAt:tt("archived_at",{withTimezone:!0}),archivedBy:K("archived_by"),forkedFromId:K("forked_from_id").references(()=>v.id,{onDelete:"set null"}),upstreamVersion:J("upstream_version")},e=>[zr("packs_name_scope_ref_idx").on(e.name,e.scope,e.scopeRef),zo("idx_packs_scope").on(e.scope,e.scopeRef),zo("idx_packs_created_by").on(e.createdBy)]),O=ko("pack_instructions",{packId:K("pack_id").references(()=>v.id,{onDelete:"cascade"}).notNull(),instructionId:K("instruction_id").references(()=>o.id,{onDelete:"cascade"}).notNull(),position:Ar("position").notNull().default(0),slotOverrides:Ro("slot_overrides"),addedAt:tt("added_at",{withTimezone:!0}).defaultNow(),addedBy:K("added_by")},e=>[kr({columns:[e.packId,e.instructionId]})]);import{pgTable as Rr,text as Pt,timestamp as Dr,jsonb as jr,uuid as Kt,index as se}from"drizzle-orm/pg-core";var ie=Rr("instruction_usage_events",{id:Kt("id").primaryKey().defaultRandom(),instructionId:Kt("instruction_id").references(()=>o.id,{onDelete:"set null"}),userId:Kt("user_id").notNull(),surface:Pt("surface").notNull(),action:Pt("action").notNull(),metadata:jr("metadata"),traceId:Pt("trace_id"),createdAt:Dr("created_at",{withTimezone:!0}).defaultNow()},e=>[se("idx_usage_events_instruction").on(e.instructionId),se("idx_usage_events_user").on(e.userId),se("idx_usage_events_surface").on(e.surface),se("idx_usage_events_action").on(e.action),se("idx_usage_events_created_at").on(e.createdAt),se("idx_usage_events_user_created").on(e.userId,e.createdAt)]);import{pgTable as Er,text as ot,timestamp as Do,jsonb as Sr,uuid as jo,index as Ot}from"drizzle-orm/pg-core";var Eo=Er("worker_connections",{id:jo("id").primaryKey().defaultRandom(),userId:jo("user_id").notNull(),workerType:ot("worker_type").notNull().default("mcp"),clientName:ot("client_name").notNull(),clientVersion:ot("client_version"),workerVersion:ot("worker_version"),lastHeartbeat:Do("last_heartbeat",{withTimezone:!0}).notNull().defaultNow(),connectedAt:Do("connected_at",{withTimezone:!0}).notNull().defaultNow(),metadata:Sr("metadata")},e=>[Ot("idx_worker_connections_user").on(e.userId),Ot("idx_worker_connections_heartbeat").on(e.userId,e.lastHeartbeat),Ot("idx_worker_connections_type").on(e.userId,e.workerType)]);import{pgTable as Pr,text as nt,timestamp as Kr,jsonb as Or,uuid as So,index as Po}from"drizzle-orm/pg-core";var Ko=Pr("cli_setup_events",{id:So("id").primaryKey().defaultRandom(),userId:So("user_id").notNull(),deviceId:nt("device_id").notNull(),event:nt("event").notNull(),cliVersion:nt("cli_version"),os:nt("os"),props:Or("props").notNull().default({}),createdAt:Kr("created_at",{withTimezone:!0}).notNull().defaultNow()},e=>[Po("idx_cli_setup_events_user").on(e.userId,e.createdAt),Po("idx_cli_setup_events_device").on(e.deviceId,e.createdAt)]);import{pgTable as Cr,text as V,integer as qr,boolean as Mr,timestamp as Lr,jsonb as Br,uuid as Ur,index as Oo}from"drizzle-orm/pg-core";var Co=Cr("cli_error_events",{id:Ur("id").primaryKey().defaultRandom(),deviceId:V("device_id"),event:V("event").notNull(),command:V("command"),statusCode:qr("status_code"),message:V("message"),cliVersion:V("cli_version"),os:V("os"),nodeVersion:V("node_version"),proxied:Mr("proxied"),props:Br("props").notNull().default({}),createdAt:Lr("created_at",{withTimezone:!0}).notNull().defaultNow()},e=>[Oo("idx_cli_error_events_created").on(e.createdAt),Oo("idx_cli_error_events_device").on(e.deviceId,e.createdAt)]);import{pgTable as rt,text as b,timestamp as ae,jsonb as I,uuid as T,integer as be,index as z}from"drizzle-orm/pg-core";var n=rt("eval_targets",{id:T("id").primaryKey().defaultRandom(),userId:T("user_id").notNull(),name:b("name").notNull(),type:b("type").notNull(),content:b("content").notNull(),description:b("description").notNull().default(""),metadata:I("metadata").notNull().default({}),version:be("version").notNull().default(1),parentId:T("parent_id").references(()=>n.id,{onDelete:"set null"}),createdAt:ae("created_at",{withTimezone:!0}).defaultNow(),updatedAt:ae("updated_at",{withTimezone:!0}).defaultNow()},e=>[z("eval_targets_name_user_idx").on(e.name,e.userId),z("idx_eval_targets_user").on(e.userId),z("idx_eval_targets_type").on(e.type),z("idx_eval_targets_parent").on(e.parentId)]),k=rt("evals",{id:T("id").primaryKey().defaultRandom(),evalTargetId:T("eval_target_id").notNull().references(()=>n.id,{onDelete:"cascade"}),name:b("name").notNull(),prompt:b("prompt").notNull(),expectedOutput:b("expected_output").notNull().default(""),files:I("files").notNull().default([]),expectations:I("expectations").notNull().default([]),createdAt:ae("created_at",{withTimezone:!0}).defaultNow(),updatedAt:ae("updated_at",{withTimezone:!0}).defaultNow()},e=>[z("idx_evals_target").on(e.evalTargetId)]),C=rt("eval_runs",{id:T("id").primaryKey().defaultRandom(),evalId:T("eval_id").notNull().references(()=>k.id,{onDelete:"cascade"}),evalTargetId:T("eval_target_id").notNull().references(()=>n.id,{onDelete:"cascade"}),evalTargetVersion:be("eval_target_version").notNull(),configuration:b("configuration").notNull(),runNumber:be("run_number").notNull().default(1),iteration:be("iteration").notNull().default(1),status:b("status").notNull().default("completed"),outputs:I("outputs").notNull().default({}),timing:I("timing").notNull().default({}),grading:I("grading").notNull().default({}),comparison:I("comparison"),createdAt:ae("created_at",{withTimezone:!0}).defaultNow()},e=>[z("idx_eval_runs_eval").on(e.evalId),z("idx_eval_runs_target").on(e.evalTargetId),z("idx_eval_runs_iteration").on(e.evalTargetId,e.iteration)]),de=rt("benchmarks",{id:T("id").primaryKey().defaultRandom(),evalTargetId:T("eval_target_id").notNull().references(()=>n.id,{onDelete:"cascade"}),iteration:be("iteration").notNull().default(1),runSummary:I("run_summary").notNull().default({}),notes:I("notes").notNull().default([]),feedback:I("feedback"),createdAt:ae("created_at",{withTimezone:!0}).defaultNow()},e=>[z("idx_benchmarks_target").on(e.evalTargetId)]);import{pgTable as Mo,text as Ct,timestamp as qt,jsonb as Lo,uuid as ue,integer as ze,index as st,real as qo}from"drizzle-orm/pg-core";var le=Mo("trigger_evals",{id:ue("id").primaryKey().defaultRandom(),evalTargetId:ue("eval_target_id").notNull().references(()=>n.id,{onDelete:"cascade"}),userId:ue("user_id").notNull(),queries:Lo("queries").notNull().default([]),status:Ct("status").notNull().default("pending_review"),trainIndices:ze("train_indices").array().default([]),testIndices:ze("test_indices").array().default([]),createdAt:qt("created_at",{withTimezone:!0}).defaultNow(),updatedAt:qt("updated_at",{withTimezone:!0}).defaultNow()},e=>[st("idx_trigger_evals_target").on(e.evalTargetId),st("idx_trigger_evals_user").on(e.userId)]),ce=Mo("optimization_runs",{id:ue("id").primaryKey().defaultRandom(),evalTargetId:ue("eval_target_id").notNull().references(()=>n.id,{onDelete:"cascade"}),userId:ue("user_id").notNull(),type:Ct("type").notNull(),iteration:ze("iteration").notNull(),inputVersion:ze("input_version").notNull(),outputVersion:ze("output_version"),trainScore:qo("train_score"),testScore:qo("test_score"),analysis:Lo("analysis").notNull().default({}),status:Ct("status").notNull().default("running"),createdAt:qt("created_at",{withTimezone:!0}).defaultNow()},e=>[st("idx_optimization_runs_target").on(e.evalTargetId),st("idx_optimization_runs_user").on(e.userId)]);import{pgTable as Hr,text as q,timestamp as Fr,jsonb as ke,uuid as Mt,integer as Lt,real as Gr,index as Re,uniqueIndex as Bo}from"drizzle-orm/pg-core";var M=Hr("context_snapshots",{id:Mt("id").primaryKey().defaultRandom(),sessionId:Mt("session_id").references(()=>u.id,{onDelete:"cascade"}),userId:Mt("user_id").notNull().references(()=>s.id,{onDelete:"cascade"}),sequence:Lt("sequence").notNull().default(0),provider:q("provider").notNull(),model:q("model").notNull(),systemPrompt:q("system_prompt").notNull(),injectedInstructions:ke("injected_instructions").notNull().default([]),messagesSummary:ke("messages_summary").notNull(),tools:ke("tools").notNull().default([]),systemHash:q("system_hash").notNull(),requestHash:q("request_hash").notNull().default(""),toolsHash:q("tools_hash"),injectedHash:q("injected_hash"),messagesDelta:ke("messages_delta").default([]),messagesDeltaRef:q("messages_delta_ref"),maxTokens:Lt("max_tokens"),temperature:Gr("temperature"),estimatedTokens:Lt("estimated_tokens"),capturedAt:Fr("captured_at",{withTimezone:!0}).notNull().defaultNow(),metadata:ke("metadata").default({})},e=>[Re("idx_context_snapshots_session").on(e.sessionId),Re("idx_context_snapshots_user").on(e.userId),Re("idx_context_snapshots_hash").on(e.systemHash),Re("idx_context_snapshots_request_hash").on(e.requestHash),Bo("idx_snapshots_session_request").on(e.sessionId,e.requestHash),Bo("idx_snapshots_session_sequence").on(e.sessionId,e.sequence),Re("idx_context_snapshots_user_session_captured").on(e.userId,e.sessionId,e.capturedAt.desc())]);import{pgTable as Jr,text as Uo,timestamp as Vr,jsonb as Yr,integer as Qr,index as Wr}from"drizzle-orm/pg-core";var Ho=Jr("content_blobs",{hash:Uo("hash").primaryKey(),contentType:Uo("content_type").notNull(),content:Yr("content").notNull(),sizeBytes:Qr("size_bytes").notNull().default(0),createdAt:Vr("created_at",{withTimezone:!0}).defaultNow()},e=>[Wr("idx_content_blobs_type").on(e.contentType)]);import{pgTable as Xr,text as it,timestamp as De,jsonb as at,uuid as Bt,index as dt,integer as $r,bigint as Zr}from"drizzle-orm/pg-core";var pe=Xr("eval_jobs",{id:Bt("id").primaryKey().defaultRandom(),userId:Bt("user_id").notNull(),evalTargetId:Bt("eval_target_id").notNull().references(()=>n.id,{onDelete:"cascade"}),status:it("status").notNull().default("pending"),config:at("config").notNull().default({}),progress:at("progress").notNull().default({}),result:at("result"),error:it("error"),attempts:$r("attempts").notNull().default(0),graphileJobId:Zr("graphile_job_id",{mode:"number"}),taskKind:it("task_kind"),payload:at("payload"),claimedBy:it("claimed_by"),claimedAt:De("claimed_at",{withTimezone:!0}),leaseExpiresAt:De("lease_expires_at",{withTimezone:!0}),createdAt:De("created_at",{withTimezone:!0}).defaultNow(),updatedAt:De("updated_at",{withTimezone:!0}).defaultNow(),completedAt:De("completed_at",{withTimezone:!0})},e=>[dt("idx_eval_jobs_user").on(e.userId),dt("idx_eval_jobs_target").on(e.evalTargetId),dt("idx_eval_jobs_status").on(e.status),dt("idx_eval_jobs_pending").on(e.userId,e.status)]);import{pgTable as es,text as je,timestamp as Ee,jsonb as Fo,uuid as Go,integer as ts,index as Jo}from"drizzle-orm/pg-core";var Vo=es("agent_jobs",{id:Go("id").primaryKey().defaultRandom(),userId:Go("user_id").notNull(),taskKind:je("task_kind").notNull(),status:je("status").notNull().default("pending"),payload:Fo("payload").notNull(),dedupeKey:je("dedupe_key"),result:Fo("result"),error:je("error"),attempts:ts("attempts").notNull().default(0),claimedBy:je("claimed_by"),claimedAt:Ee("claimed_at",{withTimezone:!0}),leaseExpiresAt:Ee("lease_expires_at",{withTimezone:!0}),createdAt:Ee("created_at",{withTimezone:!0}).notNull().defaultNow(),updatedAt:Ee("updated_at",{withTimezone:!0}).notNull().defaultNow(),completedAt:Ee("completed_at",{withTimezone:!0})},e=>[Jo("idx_agent_jobs_claim").on(e.userId,e.status,e.taskKind,e.createdAt),Jo("idx_agent_jobs_dedupe").on(e.userId,e.taskKind,e.dedupeKey)]);import{pgTable as Yo,text as Y,timestamp as _e,jsonb as Se,uuid as Pe,index as me,uniqueIndex as os,integer as ns,bigint as rs}from"drizzle-orm/pg-core";var Qo=Yo("insights_jobs",{id:Pe("id").primaryKey().defaultRandom(),userId:Pe("user_id").notNull(),status:Y("status").notNull().default("pending"),projectPath:Y("project_path"),projectId:Pe("project_id").references(()=>l.id,{onDelete:"set null"}),config:Se("config").notNull().default({}),progress:Se("progress").notNull().default({}),result:Se("result"),error:Y("error"),attempts:ns("attempts").notNull().default(0),graphileJobId:rs("graphile_job_id",{mode:"number"}),taskKind:Y("task_kind"),payload:Se("payload"),claimedBy:Y("claimed_by"),claimedAt:_e("claimed_at",{withTimezone:!0}),leaseExpiresAt:_e("lease_expires_at",{withTimezone:!0}),createdAt:_e("created_at",{withTimezone:!0}).defaultNow(),updatedAt:_e("updated_at",{withTimezone:!0}).defaultNow(),completedAt:_e("completed_at",{withTimezone:!0})},e=>[me("idx_insights_jobs_user").on(e.userId),me("idx_insights_jobs_status").on(e.status),me("idx_insights_jobs_pending").on(e.userId,e.status),me("idx_insights_jobs_project").on(e.projectId)]),Wo=Yo("insights_reports",{id:Pe("id").primaryKey().defaultRandom(),userId:Pe("user_id").notNull(),projectPath:Y("project_path"),data:Se("data").notNull(),reportHtml:Y("report_html"),createdAt:_e("created_at",{withTimezone:!0}).defaultNow()},e=>[me("idx_insights_user").on(e.userId),me("idx_insights_created").on(e.createdAt),os("idx_insights_user_project").on(e.userId,e.projectPath)]);import{pgTable as ss,text as Ut,timestamp as ut,uuid as Xo,index as is,uniqueIndex as as}from"drizzle-orm/pg-core";var fe=ss("api_keys",{id:Xo("id").primaryKey().defaultRandom(),userId:Xo("user_id").notNull().references(()=>s.id,{onDelete:"cascade"}),name:Ut("name").notNull(),keyHash:Ut("key_hash").notNull(),keyPrefix:Ut("key_prefix").notNull(),lastUsedAt:ut("last_used_at",{withTimezone:!0}),expiresAt:ut("expires_at",{withTimezone:!0}),revokedAt:ut("revoked_at",{withTimezone:!0}),createdAt:ut("created_at",{withTimezone:!0}).defaultNow()},e=>[is("idx_api_keys_user").on(e.userId),as("idx_api_keys_hash").on(e.keyHash)]);import{pgTable as ds,text as Ht,timestamp as $o,uuid as us,index as ls}from"drizzle-orm/pg-core";var Zo=ds("extension_auth_codes",{code:Ht("code").primaryKey(),userId:us("user_id").notNull().references(()=>s.id,{onDelete:"cascade"}),editor:Ht("editor"),email:Ht("email"),expiresAt:$o("expires_at",{withTimezone:!0}).notNull(),createdAt:$o("created_at",{withTimezone:!0}).defaultNow()},e=>[ls("idx_ext_auth_codes_expiry").on(e.expiresAt)]);import{pgTable as cs,text as ps,timestamp as en,jsonb as _s,uuid as Ft,index as tn}from"drizzle-orm/pg-core";var xe=cs("eval_conversations",{id:Ft("id").primaryKey().defaultRandom(),evalTargetId:Ft("eval_target_id").notNull().references(()=>n.id,{onDelete:"cascade"}),userId:Ft("user_id").notNull(),messages:_s("messages").notNull().default([]),status:ps("status").notNull().default("active"),createdAt:en("created_at",{withTimezone:!0}).defaultNow(),updatedAt:en("updated_at",{withTimezone:!0}).defaultNow()},e=>[tn("idx_eval_conversations_target").on(e.evalTargetId),tn("idx_eval_conversations_user").on(e.userId)]);import{pgTable as ms,uuid as Gt,text as Ke,jsonb as fs,timestamp as xs,index as Oe}from"drizzle-orm/pg-core";var on=ms("security_events",{id:Gt("id").primaryKey().defaultRandom(),eventType:Ke("event_type").notNull(),severity:Ke("severity").notNull(),category:Ke("category").notNull(),source:Ke("source").notNull(),entityType:Ke("entity_type"),entityId:Gt("entity_id"),userId:Gt("user_id"),details:fs("details").notNull().default({}),createdAt:xs("created_at",{withTimezone:!0}).notNull().defaultNow()},e=>[Oe("idx_security_events_type").on(e.eventType),Oe("idx_security_events_user").on(e.userId),Oe("idx_security_events_created").on(e.createdAt),Oe("idx_security_events_severity").on(e.severity),Oe("idx_security_events_source").on(e.source)]);import{pgTable as gs,text as Jt,timestamp as nn,uuid as rn,index as sn}from"drizzle-orm/pg-core";var an=gs("tasks",{id:rn("id").primaryKey().defaultRandom(),title:Jt("title").notNull(),description:Jt("description"),status:Jt("status").notNull().default("pending"),createdBy:rn("created_by"),createdAt:nn("created_at",{withTimezone:!0}).defaultNow(),updatedAt:nn("updated_at",{withTimezone:!0}).defaultNow()},e=>[sn("tasks_created_by_idx").on(e.createdBy),sn("tasks_status_idx").on(e.status)]);import{pgTable as Ns,text as R,timestamp as dn,jsonb as vs,uuid as Vt}from"drizzle-orm/pg-core";var un=Ns("skill_submissions",{id:Vt("id").primaryKey().defaultRandom(),skillId:R("skill_id").notNull(),name:R("name").notNull(),description:R("description").notNull(),category:R("category").notNull(),tools:R("tools").array().notNull(),tags:R("tags").array().default([]),content:R("content").notNull(),status:R("status").notNull().default("pending"),submittedBy:Vt("submitted_by").notNull(),reviewedBy:Vt("reviewed_by"),reviewNote:R("review_note"),metadata:vs("metadata"),createdAt:dn("created_at",{withTimezone:!0}).defaultNow(),updatedAt:dn("updated_at",{withTimezone:!0}).defaultNow()});import{pgTable as hs,text as Ce,timestamp as ln,jsonb as ys,uuid as Is,uniqueIndex as Ts,index as cn}from"drizzle-orm/pg-core";var pn=hs("harness_releases",{id:Is("id").primaryKey().defaultRandom(),harness:Ce("harness").notNull(),version:Ce("version").notNull(),publishedAt:ln("published_at",{withTimezone:!0}).notNull(),title:Ce("title"),body:Ce("body"),categories:ys("categories").default({}),url:Ce("url"),createdAt:ln("created_at",{withTimezone:!0}).defaultNow()},e=>[Ts("idx_harness_releases_unique").on(e.harness,e.version),cn("idx_harness_releases_harness").on(e.harness),cn("idx_harness_releases_published").on(e.publishedAt)]);import{pgTable as ws,text as ge,timestamp as _n,jsonb as As,uuid as mn,index as fn,uniqueIndex as bs}from"drizzle-orm/pg-core";var Yt=ws("notifications",{id:mn("id").primaryKey().defaultRandom(),userId:mn("user_id").notNull(),type:ge("type").notNull(),title:ge("title").notNull(),body:ge("body"),url:ge("url"),sourceTable:ge("source_table"),sourceId:ge("source_id"),metadata:As("metadata").notNull().default({}),readAt:_n("read_at",{withTimezone:!0}),createdAt:_n("created_at",{withTimezone:!0}).notNull().defaultNow()},e=>[fn("idx_notifications_user_created").on(e.userId,e.createdAt),fn("idx_notifications_user_unread").on(e.userId),bs("idx_notifications_source_dedup").on(e.userId,e.sourceTable,e.sourceId)]);import{pgTable as zs,text as qe,timestamp as Me,jsonb as Qt,uuid as Wt,index as lt,integer as ks,bigint as Rs}from"drizzle-orm/pg-core";var Ne=zs("launch_jobs",{id:Wt("id").primaryKey().defaultRandom(),userId:Wt("user_id").notNull(),tool:qe("tool").notNull(),status:qe("status").notNull().default("pending"),config:Qt("config").notNull().default({}),result:Qt("result"),error:qe("error"),attempts:ks("attempts").notNull().default(0),graphileJobId:Rs("graphile_job_id",{mode:"number"}),taskKind:qe("task_kind"),payload:Qt("payload"),claimedBy:qe("claimed_by"),claimedAt:Me("claimed_at",{withTimezone:!0}),leaseExpiresAt:Me("lease_expires_at",{withTimezone:!0}),createdAt:Me("created_at",{withTimezone:!0}).defaultNow(),updatedAt:Me("updated_at",{withTimezone:!0}).defaultNow(),completedAt:Me("completed_at",{withTimezone:!0}),runId:Wt("run_id").references(()=>m.id,{onDelete:"set null"})},e=>[lt("idx_launch_jobs_user").on(e.userId),lt("idx_launch_jobs_status").on(e.status),lt("idx_launch_jobs_pending").on(e.userId,e.status),lt("idx_launch_jobs_run").on(e.runId)]);import{pgTable as xn,uuid as D,text as Le,real as Ds,timestamp as ct,boolean as js,uniqueIndex as Es,index as Be}from"drizzle-orm/pg-core";var Xt=xn("instruction_suggestions",{id:D("id").primaryKey().defaultRandom(),userId:D("user_id").notNull().references(()=>s.id,{onDelete:"cascade"}),instructionId:D("instruction_id").notNull().references(()=>o.id,{onDelete:"cascade"}),projectPath:Le("project_path").notNull(),projectId:D("project_id").references(()=>l.id,{onDelete:"set null"}),score:Ds("score").notNull(),reason:Le("reason").notNull(),generatedAt:ct("generated_at",{withTimezone:!0}).notNull().defaultNow(),isStale:js("is_stale").notNull().default(!1),dismissedAt:ct("dismissed_at",{withTimezone:!0}),acceptedAt:ct("accepted_at",{withTimezone:!0}),promotedToInstructionId:D("promoted_to_instruction_id").references(()=>o.id,{onDelete:"set null"})},e=>[Es("idx_instruction_suggestions_user_project_instruction").on(e.userId,e.projectPath,e.instructionId),Be("idx_instruction_suggestions_user_project").on(e.userId,e.projectPath),Be("idx_instruction_suggestions_user_proj_id").on(e.userId,e.projectId),Be("idx_instruction_suggestions_generated_at").on(e.generatedAt)]),gn=xn("instruction_suggestion_events",{id:D("id").primaryKey().defaultRandom(),suggestionId:D("suggestion_id").notNull().references(()=>Xt.id,{onDelete:"cascade"}),userId:D("user_id").notNull().references(()=>s.id,{onDelete:"cascade"}),eventType:Le("event_type").notNull(),tool:Le("tool"),sessionId:D("session_id"),projectPath:Le("project_path").notNull(),createdAt:ct("created_at",{withTimezone:!0}).notNull().defaultNow()},e=>[Be("idx_instruction_suggestion_events_suggestion_id").on(e.suggestionId),Be("idx_instruction_suggestion_events_user_id").on(e.userId)]);import{pgTable as Ss,text as $t,integer as Ps,numeric as Ue,timestamp as Zt,index as Ks,primaryKey as Os}from"drizzle-orm/pg-core";var Nn=Ss("model_pricing",{provider:$t("provider").notNull(),modelId:$t("model_id").notNull(),inputPerM:Ue("input_per_m").notNull(),outputPerM:Ue("output_per_m").notNull(),cacheReadPerM:Ue("cache_read_per_m").notNull(),cacheWrite5mPerM:Ue("cache_write_5m_per_m").notNull(),cacheWrite1hPerM:Ue("cache_write_1h_per_m").notNull(),contextWindow:Ps("context_window"),effectiveFrom:Zt("effective_from",{withTimezone:!0}).notNull(),effectiveUntil:Zt("effective_until",{withTimezone:!0}),source:$t("source").notNull(),verifiedAt:Zt("verified_at",{withTimezone:!0})},e=>[Os({columns:[e.provider,e.modelId,e.effectiveFrom]}),Ks("idx_model_pricing_active").on(e.provider,e.modelId,e.effectiveFrom.desc())]);import{pgTable as Cs,text as Q,numeric as vn,timestamp as hn,uuid as yn,jsonb as qs,index as In}from"drizzle-orm/pg-core";var Tn=Cs("limit_observations",{id:yn("id").primaryKey().defaultRandom(),observedAt:hn("observed_at",{withTimezone:!0}).notNull().defaultNow(),provider:Q("provider").notNull(),plan:Q("plan").notNull(),limitType:Q("limit_type").notNull(),value:vn("value").notNull(),unit:Q("unit").notNull(),comparator:Q("comparator").notNull().default("="),resetsAt:hn("resets_at",{withTimezone:!0}),sourceType:Q("source_type").notNull(),sourceUrl:Q("source_url"),sourceEvidence:qs("source_evidence"),confidence:vn("confidence").notNull(),userId:yn("user_id")},e=>[In("idx_limit_obs_lookup").on(e.provider,e.plan,e.limitType,e.observedAt.desc()),In("idx_limit_obs_user").on(e.userId,e.observedAt.desc())]);import{pgTable as Ms,text as pt,timestamp as Ls,uuid as Bs,jsonb as Us,boolean as Hs,uniqueIndex as Fs}from"drizzle-orm/pg-core";var wn=Ms("provider_docs_snapshots",{id:Bs("id").primaryKey().defaultRandom(),fetchedAt:Ls("fetched_at",{withTimezone:!0}).notNull().defaultNow(),provider:pt("provider").notNull(),docUrl:pt("doc_url").notNull(),contentHash:pt("content_hash").notNull(),content:pt("content").notNull(),parseSuccess:Hs("parse_success").notNull(),parseErrors:Us("parse_errors")},e=>[Fs("idx_docs_dedup").on(e.provider,e.docUrl,e.contentHash)]);import{pgTable as Gs,text as _t,numeric as An,timestamp as bn,uuid as Js,primaryKey as Vs,index as Ys}from"drizzle-orm/pg-core";var zn=Gs("plan_limits_active",{provider:_t("provider").notNull(),plan:_t("plan").notNull(),limitType:_t("limit_type").notNull(),value:An("value").notNull(),unit:_t("unit").notNull(),effectiveFrom:bn("effective_from",{withTimezone:!0}).notNull(),effectiveUntil:bn("effective_until",{withTimezone:!0}),confidence:An("confidence").notNull(),sourceObservationIds:Js("source_observation_ids").array().notNull()},e=>[Vs({columns:[e.provider,e.plan,e.limitType,e.effectiveFrom]}),Ys("idx_plan_limits_lookup").on(e.provider,e.plan,e.limitType,e.effectiveFrom.desc())]);import{pgTable as Qs,text as eo,timestamp as Ws,uuid as kn,jsonb as Xs,index as $s}from"drizzle-orm/pg-core";var Rn=Qs("alert_dispatches",{id:kn("id").primaryKey().defaultRandom(),userId:kn("user_id").notNull(),alertKey:eo("alert_key").notNull(),severity:eo("severity").notNull(),lastDispatchedAt:Ws("last_dispatched_at",{withTimezone:!0}).notNull().defaultNow(),lastState:Xs("last_state").notNull(),channel:eo("channel").notNull()},e=>[$s("idx_alert_user_key").on(e.userId,e.alertKey,e.lastDispatchedAt.desc())]);import{drizzle as Pn}from"drizzle-orm/postgres-js";import Kn from"postgres";var mt={};Zn(mt,{agentJobs:()=>Vo,agentRuns:()=>m,agentRunsRelations:()=>pi,alertDispatches:()=>Rn,announcementDeliveries:()=>ho,announcements:()=>vo,apiKeys:()=>fe,apiKeysRelations:()=>ei,benchmarks:()=>de,benchmarksRelations:()=>Ii,cliErrorEvents:()=>Co,cliSetupEvents:()=>Ko,contentBlobs:()=>Ho,contextSnapshots:()=>M,contextSnapshotsRelations:()=>zi,evalConversations:()=>xe,evalConversationsRelations:()=>bi,evalJobs:()=>pe,evalJobsRelations:()=>Ai,evalRuns:()=>C,evalRunsRelations:()=>yi,evalTargets:()=>n,evalTargetsRelations:()=>vi,evals:()=>k,evalsRelations:()=>hi,extensionAuthCodes:()=>Zo,harnessReleases:()=>pn,insightsJobs:()=>Qo,insightsReports:()=>Wo,instructionEvents:()=>ne,instructionEventsRelations:()=>ai,instructionSuggestionEvents:()=>gn,instructionSuggestions:()=>Xt,instructionUsageEvents:()=>ie,instructionUsageEventsRelations:()=>Ni,instructionVersions:()=>Z,instructionVersionsRelations:()=>di,instructions:()=>o,instructionsRelations:()=>ii,launchJobs:()=>Ne,launchJobsRelations:()=>_i,limitObservations:()=>Tn,modelPricing:()=>Nn,notificationPreferences:()=>yo,notifications:()=>Yt,optimizationRuns:()=>ce,optimizationRunsRelations:()=>wi,orgInvitations:()=>A,orgInvitationsRelations:()=>ni,organizations:()=>a,organizationsRelations:()=>ti,packInstructions:()=>O,packInstructionsRelations:()=>gi,packs:()=>v,packsRelations:()=>xi,planLimitsActive:()=>zn,profiles:()=>s,profilesRelations:()=>Zs,projectCheckouts:()=>xo,projectInstructions:()=>E,projectInstructionsRelations:()=>li,projects:()=>l,projectsRelations:()=>ui,providerDocsSnapshots:()=>wn,securityEvents:()=>on,sessionEvents:()=>te,sessionEventsRelations:()=>mi,sessionInstructions:()=>S,sessionInstructionsRelations:()=>fi,sessionSendJobs:()=>bo,sessionTerminalTargets:()=>$e,sessions:()=>u,sessionsRelations:()=>ci,skillSubmissions:()=>un,tasks:()=>an,teams:()=>x,teamsRelations:()=>oi,triggerEvals:()=>le,triggerEvalsRelations:()=>Ti,userOrganizations:()=>X,userOrganizationsRelations:()=>ri,userTeams:()=>$,userTeamsRelations:()=>si,workerConnections:()=>Eo});import{relations as i}from"drizzle-orm";var Zs=i(s,({many:e})=>({sessions:e(u),contextSnapshots:e(M),apiKeys:e(fe)})),ei=i(fe,({one:e})=>({profile:e(s,{fields:[fe.userId],references:[s.id]})})),ti=i(a,({many:e})=>({teams:e(x),userOrganizations:e(X),projects:e(l),invitations:e(A)})),oi=i(x,({one:e,many:t})=>({organization:e(a,{fields:[x.orgId],references:[a.id]}),userTeams:t($),invitations:t(A)})),ni=i(A,({one:e})=>({organization:e(a,{fields:[A.orgId],references:[a.id]}),team:e(x,{fields:[A.teamId],references:[x.id]}),inviter:e(s,{fields:[A.invitedBy],references:[s.id]})})),ri=i(X,({one:e})=>({organization:e(a,{fields:[X.orgId],references:[a.id]})})),si=i($,({one:e})=>({team:e(x,{fields:[$.teamId],references:[x.id]})})),ii=i(o,({one:e,many:t})=>({versions:t(Z),projectInstructions:t(E),events:t(ne),usageEvents:t(ie),sessionInstructions:t(S),packInstructions:t(O),forkedFrom:e(o,{fields:[o.forkedFromId],references:[o.id]})})),ai=i(ne,({one:e})=>({instruction:e(o,{fields:[ne.instructionId],references:[o.id]})})),di=i(Z,({one:e})=>({instruction:e(o,{fields:[Z.instructionId],references:[o.id]})})),ui=i(l,({one:e,many:t})=>({organization:e(a,{fields:[l.orgId],references:[a.id]}),projectInstructions:t(E),sessions:t(u)})),li=i(E,({one:e})=>({project:e(l,{fields:[E.projectId],references:[l.id]}),instruction:e(o,{fields:[E.instructionId],references:[o.id]})})),ci=i(u,({one:e,many:t})=>({profile:e(s,{fields:[u.userId],references:[s.id]}),project:e(l,{fields:[u.projectId],references:[l.id]}),run:e(m,{fields:[u.runId],references:[m.id]}),events:t(te),sessionInstructions:t(S),contextSnapshots:t(M)})),pi=i(m,({one:e,many:t})=>({profile:e(s,{fields:[m.userId],references:[s.id]}),organization:e(a,{fields:[m.orgId],references:[a.id]}),project:e(l,{fields:[m.projectId],references:[l.id]}),sessions:t(u),launchJobs:t(Ne)})),_i=i(Ne,({one:e})=>({run:e(m,{fields:[Ne.runId],references:[m.id]})})),mi=i(te,({one:e})=>({session:e(u,{fields:[te.sessionId],references:[u.id]})})),fi=i(S,({one:e})=>({session:e(u,{fields:[S.sessionId],references:[u.id]}),instruction:e(o,{fields:[S.instructionId],references:[o.id]})})),xi=i(v,({one:e,many:t})=>({packInstructions:t(O),forkedFrom:e(v,{fields:[v.forkedFromId],references:[v.id]})})),gi=i(O,({one:e})=>({pack:e(v,{fields:[O.packId],references:[v.id]}),instruction:e(o,{fields:[O.instructionId],references:[o.id]})})),Ni=i(ie,({one:e})=>({instruction:e(o,{fields:[ie.instructionId],references:[o.id]})})),vi=i(n,({one:e,many:t})=>({parent:e(n,{fields:[n.parentId],references:[n.id]}),evals:t(k),evalRuns:t(C),benchmarks:t(de),triggerEvals:t(le),optimizationRuns:t(ce),evalJobs:t(pe),evalConversations:t(xe)})),hi=i(k,({one:e,many:t})=>({evalTarget:e(n,{fields:[k.evalTargetId],references:[n.id]}),runs:t(C)})),yi=i(C,({one:e})=>({eval:e(k,{fields:[C.evalId],references:[k.id]}),evalTarget:e(n,{fields:[C.evalTargetId],references:[n.id]})})),Ii=i(de,({one:e})=>({evalTarget:e(n,{fields:[de.evalTargetId],references:[n.id]})})),Ti=i(le,({one:e})=>({evalTarget:e(n,{fields:[le.evalTargetId],references:[n.id]})})),wi=i(ce,({one:e})=>({evalTarget:e(n,{fields:[ce.evalTargetId],references:[n.id]})})),Ai=i(pe,({one:e})=>({evalTarget:e(n,{fields:[pe.evalTargetId],references:[n.id]})})),bi=i(xe,({one:e})=>({evalTarget:e(n,{fields:[xe.evalTargetId],references:[n.id]})})),zi=i(M,({one:e})=>({session:e(u,{fields:[M.sessionId],references:[u.id]}),profile:e(s,{fields:[M.userId],references:[s.id]})}));var He=0,Dn=0,Fe=0,jn=0;var ki=0;function to(){He++,He>Dn&&(Dn=He)}p(to,"trackDbOpStart");function oo(){He>0&&He--}p(oo,"trackDbOpEnd");function no(){Fe++,Fe>jn&&(jn=Fe)}p(no,"trackHeavyDbOpStart");function ro(){Fe>0&&Fe--}p(ro,"trackHeavyDbOpEnd");function En(){ki++}p(En,"recordQueryDeadline");var xt,Nt,so=!1,ft;var Sn,vt,gt;function On(e){let t=process.env[e];if(!t)throw new Error(`Missing required env var: ${e}`);return t}p(On,"getEnv");function Cn(){if(so)throw new Error("getDb() called after closeDb(): the connection pool is closed for shutdown. Stop issuing queries (timers/requests) before draining the pool.");if(!xt){let e=process.env.PG_APPLICATION_NAME||"rulemetric",t=Number(process.env.PG_POOL_MAX)||3,r=Number(process.env.PG_CONNECT_TIMEOUT_S)||10,d=Number(process.env.PG_STATEMENT_TIMEOUT_MS)||0,c=Number(process.env.PG_IDLE_TIMEOUT)||5,_=Number(process.env.PG_KEEP_ALIVE_S)||60;Nt=Kn(On("DATABASE_URL"),{prepare:!1,max:t,connect_timeout:r,idle_timeout:c,keep_alive:_,max_lifetime:300,connection:{application_name:e,...d>0?{statement_timeout:d}:{}}}),xt=Pn(Nt,{schema:mt})}return xt}p(Cn,"getDb");function qn(){if(so)throw new Error("getHeavyDb() called after closeDb(): the connection pool is closed for shutdown. Stop issuing queries (timers/requests) before draining the pool.");if(!gt){let e=(process.env.PG_APPLICATION_NAME||"rulemetric")+":heavy",t=Number(process.env.PG_HEAVY_POOL_MAX)||2;vt=Kn(On("DATABASE_URL"),{prepare:!1,max:t,connect_timeout:Number(process.env.PG_CONNECT_TIMEOUT_S)||10,idle_timeout:Number(process.env.PG_IDLE_TIMEOUT)||5,keep_alive:Number(process.env.PG_KEEP_ALIVE_S)||60,max_lifetime:300,connection:{application_name:e}}),gt=Pn(vt,{schema:mt})}return gt}p(qn,"getHeavyDb");async function Ri(){if(ft)return ft;so=!0;let e=Nt,t=Sn,r=vt;return Nt=void 0,xt=void 0,Sn=void 0,vt=void 0,gt=void 0,ft=Promise.allSettled([e?e.end({timeout:5}):Promise.resolve(),t?t.end({timeout:5}):Promise.resolve(),r?r.end({timeout:5}):Promise.resolve()]).then(()=>{}),ft}p(Ri,"closeDb");var Di=new Set(["CONNECT_TIMEOUT","ETIMEDOUT","ENOTFOUND","ECONNREFUSED","EAI_AGAIN"]);function Mn(e){let t=e,r=t?.code??t?.cause?.code??t?.errno;return r!==void 0&&Di.has(r)}p(Mn,"isRetryableConnectError");var ji=new Set(["CONNECTION_CLOSED","ECONNRESET","EPIPE"]);function Ln(e){let t=e,r=t?.code??t?.cause?.code??t?.errno;return r!==void 0&&ji.has(r)}p(Ln,"isRetryableResetError");async function Bn(e,t={}){let r=t.attempts??3,d=t.baseMs??100,c;for(let _=0;_<r;_++)try{return await e()}catch(g){c=g;let ve=Mn(g)||t.retryResets===!0&&Ln(g);if(_===r-1||!ve)throw g;await new Promise(L=>setTimeout(L,d*2**_))}throw c}p(Bn,"withDbRetry");var ht=class extends Error{static{p(this,"QueryDeadlineError")}code="QUERY_DEADLINE";constructor(t){super(`Query exceeded the client-side deadline of ${t}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.`),this.name="QueryDeadlineError"}};function Un(){let e=Number(process.env.PG_QUERY_DEADLINE_MS);return Number.isFinite(e)&&e>=0?e:2e4}p(Un,"queryDeadlineMs");function Ei(e,t){let r,d=new Promise((c,_)=>{r=setTimeout(()=>{En(),_(new ht(t))},t);let g=r;typeof g.unref=="function"&&g.unref()});return Promise.race([e,d]).finally(()=>clearTimeout(r))}p(Ei,"raceWithDeadline");var Hn=new Set(["select","selectDistinct","selectDistinctOn","insert","update","delete","execute","with","$count","refreshMaterializedView"]),Fn=new Set(["select","selectDistinct","selectDistinctOn","$count"]);function io(e,t=!1,r=0,d=!1){return e===null||typeof e!="object"&&typeof e!="function"?e:new Proxy(e,{get(c,_,g){if(_==="then"){let L=Reflect.get(c,_,g);return typeof L!="function"?L:(Vn,Yn)=>{let Qn=d?no:to,Wn=d?ro:oo;Qn();let ao=Bn(()=>new Promise((Xn,$n)=>L.call(c,Xn,$n)),{retryResets:t});return(r>0?Ei(ao,r):ao).finally(Wn).then(Vn,Yn)}}let ve=Reflect.get(c,_,g);return typeof ve=="function"?(...L)=>io(ve.apply(c,L),t,r,d):ve}})}p(io,"wrapBuilder");function Gn(e,t=!1){let r=t?no:to,d=t?ro:oo;r();try{return Promise.resolve(e()).finally(d)}catch(c){throw d(),c}}p(Gn,"gaugeTransaction");var Jn=new Proxy({},{get(e,t){let r=Cn(),d=r[t];if(typeof t=="string"&&Hn.has(t)&&typeof d=="function"){let c=Fn.has(t),_=Un();return(...g)=>io(d.apply(r,g),c,_)}return t==="transaction"&&typeof d=="function"?(...c)=>Gn(()=>d.apply(r,c)):d}}),Si=new Proxy({},{get(e,t){let r=qn(),d=r[t];if(typeof t=="string"&&Hn.has(t)&&typeof d=="function"){let c=Fn.has(t);return(..._)=>io(d.apply(r,_),c,0,!0)}return t==="transaction"&&typeof d=="function"?(...c)=>Gn(()=>d.apply(r,c),!0):d}});export{s as a,m as b,u as c,te as d,vo as e,ho as f,yo as g,Cn as h,Ri as i};
@@ -0,0 +1,31 @@
1
+ import{f as x}from"./chunk-I2DZGJRR.js";import{a as r}from"./chunk-ZLLER3HP.js";import{execSync as h}from"node:child_process";import{existsSync as c,mkdirSync as y,readFileSync as d,writeFileSync as a,unlinkSync as v,copyFileSync as _}from"node:fs";import{homedir as f}from"node:os";import{join as i,dirname as $}from"node:path";function q(e){let t=["claude_code"];return c(i(e,".cursor"))&&t.push("cursor"),c(i(e,".github"))&&t.push("copilot_agent"),c(i(e,".agents"))&&t.push("antigravity"),t}r(q,"detectInstalledTools");function N(e){let t=e?`PATH="${e}:$PATH" `:"",o=r(n=>({command:`${t}rulemetric hooks run ${n}`}),"cmd");return{version:1,hooks:{sessionStart:[o("session-start")],beforeSubmitPrompt:[o("user-prompt")],afterFileEdit:[o("post-tool-use")],beforeShellExecution:[o("post-tool-use")],afterShellExecution:[o("post-tool-use")],beforeMCPExecution:[o("post-tool-use")],afterMCPExecution:[o("post-tool-use")],afterAgentResponse:[o("assistant-response")],stop:[o("post-tool-use")],sessionEnd:[o("session-end")]}}}r(N,"generateCursorHooksConfig");function L(e){let t=e?`PATH="${e}:$PATH" `:"",o=r(n=>({type:"command",bash:`${t}rulemetric hooks run ${n}`}),"cmd");return{version:1,hooks:{sessionStart:[o("session-start")],userPromptSubmitted:[o("user-prompt")],postToolUse:[o("post-tool-use")],sessionEnd:[o("session-end")]}}}r(L,"generateCopilotHooksConfig");function B(e){let t=e?`PATH="${e}:$PATH" `:"",o=r(n=>({type:"command",command:`${t}rulemetric hooks run ${n}`}),"mk");return{SessionStart:[{hooks:[o("session-start")]}],UserPromptSubmit:[{hooks:[o("user-prompt")]}],PostToolUse:[{matcher:".*",hooks:[o("post-tool-use")]}],Stop:[{hooks:[o("assistant-response")]}],SessionEnd:[{hooks:[o("session-end")]}]}}r(B,"generateClaudeCodeHooksConfig");function J(e){if(!c(e))return{settings:{},recoveredBackup:null};let t=d(e,"utf-8");try{return{settings:JSON.parse(t),recoveredBackup:null}}catch{let o=`${e}.corrupt.bak`;return a(o,t),{settings:{},recoveredBackup:o}}}r(J,"readClaudeSettings");function b(e,t){y($(e),{recursive:!0});let o=null;return c(e)&&(o=`${e}.bak`,_(e,o)),a(e,JSON.stringify(t,null,2)+`
2
+ `),{backupPath:o}}r(b,"writeClaudeSettingsWithBackup");function k(e){if(!c(e))return{};let t=d(e,"utf-8");try{return JSON.parse(t)}catch{try{a(`${e}.corrupt.bak`,t)}catch{}return null}}r(k,"readMergeableJson");function Q(e,t){let o=B(t),n=e.hooks??{};for(let[s,u]of Object.entries(o)){let l=n[s]??[];l.some(m=>m?.hooks?.some(p=>typeof p?.command=="string"&&p.command.includes("rulemetric")))||(n[s]=[...l,...u])}e.hooks=n}r(Q,"mergeClaudeCodeHooks");function Z(e){if(!e.hooks||typeof e.hooks!="object")return!1;let t=e.hooks;return Object.values(t).some(o=>Array.isArray(o)&&o.some(n=>n?.hooks?.some(s=>typeof s?.command=="string"&&s.command.includes("rulemetric"))))}r(Z,"hasRulemetricClaudeHooks");function D(e){if(!e.hooks||typeof e.hooks!="object")return!1;let t=e.hooks,o=0;for(let n of Object.keys(t)){let s=t[n];if(!Array.isArray(s))continue;let u=s.filter(l=>{let g=l?.hooks?.some(m=>typeof m?.command=="string"&&m.command.includes("rulemetric"));return g&&(o+=1),!g});u.length===0?delete t[n]:t[n]=u}return Object.keys(t).length===0&&delete e.hooks,o>0}r(D,"removeClaudeCodeHooks");var X="localhost,127.0.0.1,*.supabase.co,*.supabase.in";function tt(e,t){return i(e,t?"settings.json":"settings.local.json")}r(tt,"claudeSettingsInstallPath");function M(e,t){let o=e.env;if(!o||typeof o!="object")return!1;let n=!1,s=o.HTTPS_PROXY;(s===`http://localhost:${t}`||s===`http://127.0.0.1:${t}`)&&(delete o.HTTPS_PROXY,n=!0),o.NO_PROXY===X&&(delete o.NO_PROXY,n=!0);let u=o.NODE_EXTRA_CA_CERTS;return typeof u=="string"&&u.includes(".mitmproxy")&&u.endsWith("mitmproxy-ca-cert.pem")&&(delete o.NODE_EXTRA_CA_CERTS,n=!0),n&&Object.keys(o).length===0&&delete e.env,n}r(M,"removeRulemetricProxyEnv");function C(e,t){let o=D(e),n=M(e,t),s=x(e);return{removedHooks:o,removedProxyEnv:n,removedStatusline:s,removed:o||n||s}}r(C,"removeRulemetricMachineState");function et(e,t){let o={migrated:!1,backupPath:null,removedHooks:!1,removedProxyEnv:!1,removedStatusline:!1,removed:!1};if(!c(e))return o;let n;try{n=JSON.parse(d(e,"utf-8"))}catch{return o}let s=C(n,t);if(!s.removed)return o;let{backupPath:u}=b(e,n);return{...s,migrated:!0,backupPath:u}}r(et,"migrateSharedClaudeSettings");function ot(e,t){let o=[];for(let n of["settings.json","settings.local.json"]){let s=i(e,n);if(!c(s))continue;let{settings:u,recoveredBackup:l}=J(s),g=C(u,t);g.removed&&b(s,u),o.push({...g,configPath:s,fileName:n,recoveredBackup:l,changed:g.removed})}return o}r(ot,"cleanClaudeSettingsFiles");function R(e,t){if(!c(e))return null;let o=i(e,"hooks.json"),n=N(t),s=k(o);if(s===null)return null;let u=s,l={...u.hooks??{}},g=r(p=>typeof p=="object"&&p!==null&&"command"in p&&typeof p.command=="string"&&p.command.includes("rulemetric"),"isRulemetricHook");for(let[p,w]of Object.entries(n.hooks)){let j=(l[p]??[]).filter(U=>!g(U));l[p]=[...j,...w]}let m={version:u.version??n.version,hooks:l};return a(o,JSON.stringify(m,null,2)+`
3
+ `),o}r(R,"writeCursorHooksToDir");function nt(e,t){return R(i(e,".cursor"),t)}r(nt,"writeCursorHooks");function rt(e,t=f()){let o=i(t,".cursor");return c(o)?R(o,e):null}r(rt,"writeCursorUserHooks");function st(e,t){let o=i(e,".github");if(!c(o))return null;let n=i(o,"hooks");y(n,{recursive:!0});let s=i(n,"rulemetric.json"),u=L(t);return a(s,JSON.stringify(u,null,2)+`
4
+ `),s}r(st,"writeCopilotHooks");function A(e){if(!c(e))return!1;let t;try{t=JSON.parse(d(e,"utf-8"))}catch{return!1}if(!t.hooks)return!1;let o=!1;for(let[n,s]of Object.entries(t.hooks)){let u=s.filter(l=>{if(typeof l!="object"||l===null||!("command"in l))return!0;let g=l.command;return typeof g=="string"&&g.includes("rulemetric")?(o=!0,!1):!0});u.length===0?delete t.hooks[n]:t.hooks[n]=u}return o&&a(e,JSON.stringify(t,null,2)+`
5
+ `),o}r(A,"removeCursorHooksFromFile");function it(e){return A(i(e,".cursor","hooks.json"))}r(it,"removeCursorHooks");function ut(){return A(i(f(),".cursor","hooks.json"))}r(ut,"removeCursorUserHooks");function ct(e,t,o){let n=i(e,".cursor");if(!c(n))return!1;let s=i(n,"settings.json"),u=k(s);return u===null?!1:(u["http.proxy"]=`http://localhost:${t}`,u["http.proxyStrictSSL"]=c(o),a(s,JSON.stringify(u,null,2)+`
6
+ `),!0)}r(ct,"writeCursorProxyConfig");function lt(e,t,o){let n=i(e,".vscode");if(!c(n))return!1;let s=i(n,"settings.json"),u=k(s);if(u===null)return!1;u["http.proxy"]=`http://localhost:${t}`,u["http.proxyStrictSSL"]=c(o);let l=u["github.copilot.advanced"]??{};return l["debug.overrideProxyUrl"]=`http://localhost:${t}`,u["github.copilot.advanced"]=l,a(s,JSON.stringify(u,null,2)+`
7
+ `),!0}r(lt,"writeVSCodeProxyConfig");function at(e){let t=i(e,".vscode","settings.json");if(!c(t))return!1;let o;try{o=JSON.parse(d(t,"utf-8"))}catch{return!1}let n=!1;o["http.proxy"]&&(delete o["http.proxy"],delete o["http.proxyStrictSSL"],n=!0);let s=o["github.copilot.advanced"];return s?.["debug.overrideProxyUrl"]&&(delete s["debug.overrideProxyUrl"],Object.keys(s).length===0&&delete o["github.copilot.advanced"],n=!0),n&&a(t,JSON.stringify(o,null,2)+`
8
+ `),n}r(at,"removeVSCodeProxyConfig");function gt(e){let t=i(e,".github","hooks","rulemetric.json");return c(t)?(v(t),!0):!1}r(gt,"removeCopilotHooks");var H="com.rulemetric.env";function P(){return i(f(),"Library","LaunchAgents",`${H}.plist`)}r(P,"getLaunchAgentPath");function pt(e,t){if(process.platform!=="darwin")return!1;let o=`http://localhost:${e}`;try{h(`launchctl setenv HTTPS_PROXY ${o}`,{stdio:"pipe"}),c(t)&&h(`launchctl setenv NODE_EXTRA_CA_CERTS ${t}`,{stdio:"pipe"})}catch{return!1}let n=P(),s=i(f(),"Library","LaunchAgents");y(s,{recursive:!0});let u=c(t)?`launchctl setenv NODE_EXTRA_CA_CERTS ${t};`:"",l=`if nc -z -w 1 127.0.0.1 ${e} 2>/dev/null; then launchctl setenv HTTPS_PROXY ${o};${u} else launchctl unsetenv HTTPS_PROXY; launchctl unsetenv NODE_EXTRA_CA_CERTS; fi`,g=`<?xml version="1.0" encoding="UTF-8"?>
9
+ <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN"
10
+ "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
11
+ <plist version="1.0">
12
+ <dict>
13
+ <key>Label</key>
14
+ <string>${H}</string>
15
+ <key>ProgramArguments</key>
16
+ <array>
17
+ <string>/bin/sh</string>
18
+ <string>-c</string>
19
+ <string>${l}</string>
20
+ </array>
21
+ <key>RunAtLoad</key>
22
+ <true/>
23
+ </dict>
24
+ </plist>
25
+ `;return a(n,g),!0}r(pt,"installMacOSProxyEnv");function ft(){if(process.platform!=="darwin")return!1;let e=!1;try{h("launchctl unsetenv HTTPS_PROXY",{stdio:"pipe"}),h("launchctl unsetenv NODE_EXTRA_CA_CERTS",{stdio:"pipe"})}catch{}let t=P();return c(t)&&(v(t),e=!0),e}r(ft,"uninstallMacOSProxyEnv");function O(){return process.platform==="darwin"?i(f(),"Library","Application Support","Code","User","settings.json"):process.platform==="win32"?i(process.env.APPDATA??"","Code","User","settings.json"):i(f(),".config","Code","User","settings.json")}r(O,"getVSCodeUserSettingsPath");function dt(e){let t=O();if(!c(i(t,"..")))return!1;let o=k(t);return o===null||o["http.proxy"]&&!o["http.proxy"].includes("localhost")?!1:(o["http.proxy"]=`http://localhost:${e}`,o["http.proxyStrictSSL"]=!1,a(t,JSON.stringify(o,null,2)+`
26
+ `),!0)}r(dt,"writeVSCodeUserProxyConfig");function mt(){let e=O();if(!c(e))return!1;let t;try{t=JSON.parse(d(e,"utf-8"))}catch{return!1}return t["http.proxy"]?.includes("localhost")?(delete t["http.proxy"],delete t["http.proxyStrictSSL"],a(e,JSON.stringify(t,null,2)+`
27
+ `),!0):!1}r(mt,"removeVSCodeUserProxyConfig");function T(){return process.platform==="darwin"?i(f(),"Library","Application Support","Cursor","User","settings.json"):process.platform==="win32"?i(process.env.APPDATA??"","Cursor","User","settings.json"):i(f(),".config","Cursor","User","settings.json")}r(T,"getCursorUserSettingsPath");function kt(e){let t=T();if(!c(i(t,"..")))return!1;let o=k(t);return o===null||o["http.proxy"]&&!o["http.proxy"].includes("localhost")?!1:(o["http.proxy"]=`http://localhost:${e}`,o["http.proxyStrictSSL"]=!1,a(t,JSON.stringify(o,null,2)+`
28
+ `),!0)}r(kt,"writeCursorUserProxyConfig");function ht(){let e=T();if(!c(e))return!1;let t;try{t=JSON.parse(d(e,"utf-8"))}catch{return!1}return t["http.proxy"]?.includes("localhost")?(delete t["http.proxy"],delete t["http.proxyStrictSSL"],a(e,JSON.stringify(t,null,2)+`
29
+ `),!0):!1}r(ht,"removeCursorUserProxyConfig");function F(){let e=process.execPath,t=process.argv[1];return t&&t.endsWith("run.js")?`${e} ${t}`:"rulemetric"}r(F,"getRulemetricCommand");function Y(){let e=F(),t=r(o=>({type:"command",command:`RULEMETRIC_HOOK_TOOL=antigravity ${e} hooks run ${o}`,timeout:30}),"mk");return{rulemetric:{enabled:!0,SessionStart:[{hooks:[t("session-start")]}],UserPromptSubmit:[{hooks:[t("user-prompt")]}],PreToolUse:[{matcher:".*",hooks:[t("post-tool-use")]}],PostToolUse:[{matcher:".*",hooks:[t("post-tool-use")]}],Stop:[{hooks:[t("assistant-response")]}],SessionEnd:[{hooks:[t("session-end")]}]}}}r(Y,"generateAntigravityHooksConfig");function E(e){let t=i(e,"hooks.json"),o=k(t);if(o===null)return null;let n=Y(),s={...o,rulemetric:n.rulemetric};return y(e,{recursive:!0}),a(t,JSON.stringify(s,null,2)+`
30
+ `),t}r(E,"writeAntigravityHooksToDir");function yt(e){return E(i(e,".agents"))}r(yt,"writeAntigravityHooks");function St(e=f()){let t=i(e,".gemini");return c(t)?E(i(t,"config")):null}r(St,"writeAntigravityUserHooks");function S(e){if(!c(e))return!1;let t;try{t=JSON.parse(d(e,"utf-8"))}catch{return!1}if(!("rulemetric"in t))return!1;if(delete t.rulemetric,Object.keys(t).length===0)try{v(e)}catch{}else a(e,JSON.stringify(t,null,2)+`
31
+ `);return!0}r(S,"removeAntigravityHooksFromFile");function vt(e){return S(i(e,".agents","hooks.json"))}r(vt,"removeAntigravityHooks");function xt(){let e=S(i(f(),".gemini","config","hooks.json")),t=S(i(f(),".gemini","hooks.json"));return e||t}r(xt,"removeAntigravityUserHooks");export{q as a,N as b,L as c,B as d,J as e,b as f,Q as g,Z as h,D as i,X as j,tt as k,M as l,C as m,et as n,ot as o,nt as p,rt as q,st as r,it as s,ut as t,ct as u,lt as v,at as w,gt as x,pt as y,ft as z,O as A,dt as B,mt as C,T as D,kt as E,ht as F,Y as G,yt as H,St as I,vt as J,xt as K};
@@ -0,0 +1 @@
1
+ import{a as s}from"./chunk-ZLLER3HP.js";import{readFileSync as i}from"node:fs";import{join as a}from"node:path";function u(e,n=process.env){if(n.RULEMETRIC_PROXY_ALL_HOSTS==="1")return[];let t;try{t=JSON.parse(i(a(e,"allow_hosts.json"),"utf-8")).allow}catch{return[]}if(!Array.isArray(t)||t.length===0)return[];let o=t.filter(r=>typeof r=="string"&&r.length>0);if(o.length===0)return[];let l=(n.RULEMETRIC_PROXY_EXTRA_HOSTS??"").split(",").map(r=>r.trim()).filter(Boolean);return[...o,...l].flatMap(r=>["--allow-hosts",r])}s(u,"buildAllowHostsArgs");export{u as a};
@@ -0,0 +1 @@
1
+ import{b as g,c as m}from"./chunk-N7ODX6PO.js";import{d as s,g as c}from"./chunk-TIQ7DQ3M.js";import{a as i}from"./chunk-ZLLER3HP.js";var u=6e4;function o(t,e){try{t(JSON.stringify({ts:new Date().toISOString(),...e}))}catch{t(`[tt-heartbeat] log_error event=${e.event}`)}}i(o,"structuredLog");function d(t,e){return e.aborted?Promise.resolve(!1):t<=0?Promise.resolve(!0):new Promise(r=>{let a=setTimeout(()=>{e.removeEventListener("abort",n),r(!0)},t),n=i(()=>{clearTimeout(a),e.removeEventListener("abort",n),r(!1)},"onAbort");e.addEventListener("abort",n,{once:!0})})}i(d,"abortableSleep");async function l(t,e){if(t.kind!=="tmux")return;let a=(await g(m(t.target))).code===0?"active":"missing";try{await c(`/api/terminal-targets/${t.id}/status`,{status:a,lastSeenAt:new Date().toISOString()}),o(e,{event:"tt_heartbeat",targetId:t.id,target:t.target,status:a})}catch(n){o(e,{event:"tt_heartbeat_error",targetId:t.id,target:t.target,error:n instanceof Error?n.message:String(n)})}}i(l,"probeAndReport");async function b(t){let e;try{e=await s("/api/terminal-targets?status=active")}catch(r){o(t,{event:"tt_heartbeat_list_error",error:r instanceof Error?r.message:String(r)});return}for(let r of e.targets??[])try{await l(r,t)}catch(a){o(t,{event:"tt_heartbeat_probe_error",targetId:r.id,error:a instanceof Error?a.message:String(a)})}}i(b,"runOneHeartbeatCycle");async function p(t){let e=t.log??(()=>{}),r=t.intervalMs??u;for(o(e,{event:"tt_heartbeat_start",intervalMs:r});!t.signal.aborted&&(await b(e),!!await d(r,t.signal)););o(e,{event:"tt_heartbeat_stop"})}i(p,"startTerminalTargetHeartbeat");export{l as a,b,p as c};
@@ -0,0 +1 @@
1
+ import{a as n}from"./chunk-5RBLIVBF.js";import{b as s,c as d,d as l,e as f}from"./chunk-N7ODX6PO.js";import{a as i}from"./chunk-ZLLER3HP.js";var c=2e3;function o(e){return(e.stderr.trim()||"no stderr").slice(0,c)}i(o,"errorDetail");async function S(e,w){let t=typeof e.target=="string"?e.target:null,u=typeof e.message=="string"?e.message:null,a=e.submit!==!1;if(!t)throw new n("tmux target is required");if(!u)throw new n("message is required");w.logger.info(`Sending message to tmux target ${t}...`);let r=await s(d(t));if(r.code===null)throw new n(`tmux not available: ${o(r)}`);if(r.code!==0)throw new n(`tmux target not found: ${t}: ${o(r)}`);let m=await s(l(t,u));if(m.code!==0)throw new Error(`tmux send-keys failed: ${o(m)}`);if(a){let g=await s(f(t));if(g.code!==0)throw new Error(`tmux send Enter failed: ${o(g)}`)}return{target:t,sentAt:new Date().toISOString(),submitted:a}}i(S,"processSendMessage");export{S as a};
@@ -0,0 +1 @@
1
+ import{b as l}from"./chunk-6QKI756T.js";import{a as p}from"./chunk-5RBLIVBF.js";import{g as h}from"./chunk-TIQ7DQ3M.js";import{a as c}from"./chunk-ZLLER3HP.js";async function g(t){if(!t.worktree?.create)return t;let{branch:e,baseRef:s}=t.worktree,n=await l({repoRoot:t.projectPath,branch:e,baseRef:s});return{...t,projectPath:n.path,gitBranch:n.branch}}c(g,"resolveWorktreeForLaunch");async function L(t,e){let{mirrorId:s,tool:n}=t,{config:r}=t,a=c(o=>e.logger.info(o),"log");if(e.job.attempts>1)throw new p(`process_launch is not safe to retry (attempt ${e.job.attempts}). Re-launch manually.`);r=await g(r),r.worktree?.create&&a(`Worktree resolved: ${r.projectPath} (branch ${r.gitBranch})`),a(`Launching ${n}...`);let{getLauncher:f}=await import("./dist-FAVALJ5C.js"),i=await f(n).launch(r);a(`Launch completed: sessionId=${i.sessionId}`);let u={...i,worktreePath:r.worktree?.create?r.projectPath:void 0,runId:r.runId};return await h(`/api/launch-jobs/${s}/state`,{result:u}).catch(o=>{a(`result persist failed: ${o instanceof Error?o.message:String(o)}`)}),u}c(L,"processLaunch");export{g as a,L as b};