@rulemetric/cli 0.7.3 → 0.7.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (550) hide show
  1. package/README.md +10 -8
  2. package/dist/base-command.js +1 -14
  3. package/dist/chunk-2JRDG4LJ.js +31 -0
  4. package/dist/chunk-2TC6WCUT.js +34 -0
  5. package/dist/chunk-2WLVDSAP.js +2 -0
  6. package/dist/chunk-32EEBARV.js +1 -0
  7. package/dist/chunk-3AV3GTMP.js +1 -0
  8. package/dist/chunk-43YBXX7R.js +1 -0
  9. package/dist/chunk-4Z5ECCJE.js +1 -0
  10. package/dist/chunk-5RBLIVBF.js +1 -0
  11. package/dist/chunk-67QCYUJU.js +1 -0
  12. package/dist/chunk-6QKI756T.js +2 -0
  13. package/dist/chunk-6V4WM73L.js +1 -0
  14. package/dist/chunk-6XEC6474.js +1 -0
  15. package/dist/chunk-7DFNBRLY.js +61 -0
  16. package/dist/chunk-ARNZQBMX.js +1 -0
  17. package/dist/chunk-AYUJY37O.js +5 -0
  18. package/dist/chunk-CADKBP3D.js +58 -0
  19. package/dist/chunk-CDI5CCHU.js +1 -0
  20. package/dist/chunk-CNQ5DTNC.js +1 -0
  21. package/dist/chunk-DCLWFGEA.js +1 -0
  22. package/dist/chunk-DNF4HDI6.js +14 -0
  23. package/dist/chunk-DPFNJZUO.js +1 -0
  24. package/dist/chunk-DSO2U4Y6.js +56 -0
  25. package/dist/chunk-DVN7GFJG.js +1 -0
  26. package/dist/chunk-G63KMH6U.js +1 -0
  27. package/dist/chunk-G6XGDHGC.js +2 -0
  28. package/dist/chunk-GBMF3TP6.js +1 -0
  29. package/dist/chunk-GY5IJ4RS.js +1 -0
  30. package/dist/chunk-H2ORWIEY.js +1 -0
  31. package/dist/chunk-H4SV7FN4.js +1 -0
  32. package/dist/chunk-HS7X43XE.js +24 -0
  33. package/dist/{chunk-OQBBVTDG.js → chunk-I2DZGJRR.js} +6 -71
  34. package/dist/chunk-IZTIYR5Q.js +2 -0
  35. package/dist/chunk-JAPCCEKF.js +3 -0
  36. package/dist/chunk-JQTGQXUX.js +1 -0
  37. package/dist/chunk-KAF3CYRW.js +9 -0
  38. package/dist/chunk-KKDHD4XA.js +2 -0
  39. package/dist/chunk-KV325CXF.js +33 -0
  40. package/dist/chunk-MGHFDHHM.js +1 -0
  41. package/dist/chunk-MODXEGCU.js +1 -0
  42. package/dist/chunk-MVM6OGAF.js +4 -0
  43. package/dist/chunk-N7ODX6PO.js +1 -0
  44. package/dist/chunk-N7TGRFVZ.js +70 -0
  45. package/dist/chunk-NBTC5FNV.js +1 -0
  46. package/dist/chunk-NEACEHQD.js +1 -0
  47. package/dist/chunk-NJ5UED3H.js +1 -0
  48. package/dist/chunk-NVKX36YN.js +3 -0
  49. package/dist/chunk-O2SDD2WW.js +1 -0
  50. package/dist/chunk-O6C2UGBY.js +7 -0
  51. package/dist/chunk-OMXUK4M6.js +1 -0
  52. package/dist/chunk-PPKPCXJD.js +4 -0
  53. package/dist/{chunk-XZXS2W24.js → chunk-QFVGUZDO.js} +11 -57
  54. package/dist/chunk-RDET7CKR.js +1 -0
  55. package/dist/chunk-RQ424GI6.js +5 -0
  56. package/dist/chunk-RSKQRVPJ.js +1 -0
  57. package/dist/chunk-RTWRHIKY.js +7 -0
  58. package/dist/chunk-SZ62CP55.js +1 -0
  59. package/dist/chunk-TDD7IOV2.js +1 -0
  60. package/dist/chunk-TIOKY2IA.js +1 -0
  61. package/dist/chunk-TQMG647B.js +15 -0
  62. package/dist/chunk-TU2AR6XO.js +1 -0
  63. package/dist/chunk-U6ABMRT3.js +9 -0
  64. package/dist/chunk-U6XEU573.js +1 -0
  65. package/dist/chunk-UF6US7VU.js +1 -0
  66. package/dist/chunk-V44SRRYR.js +1 -0
  67. package/dist/chunk-V5U3E4BZ.js +1 -0
  68. package/dist/chunk-VAXRCSSH.js +2 -0
  69. package/dist/chunk-VLOX6KOM.js +1 -0
  70. package/dist/chunk-VUGRXM7R.js +1 -0
  71. package/dist/chunk-W2MOTOQE.js +1 -0
  72. package/dist/chunk-W2MV25SB.js +1 -0
  73. package/dist/chunk-WLVQJH4E.js +1 -0
  74. package/dist/chunk-WSCK4WNK.js +1 -0
  75. package/dist/chunk-XICLXXRH.js +1 -0
  76. package/dist/chunk-XXDZJ6YI.js +1 -0
  77. package/dist/chunk-ZL4MZMUK.js +34 -0
  78. package/dist/chunk-ZLLER3HP.js +1 -0
  79. package/dist/chunk-ZR3MUNLS.js +1 -0
  80. package/dist/chunk-ZXF5NE54.js +1 -0
  81. package/dist/commands/antigravity/backfill.js +2 -136
  82. package/dist/commands/auth/create-key.js +1 -52
  83. package/dist/commands/auth/login.js +1 -85
  84. package/dist/commands/auth/logout.js +1 -29
  85. package/dist/commands/auth/revoke-key.js +4 -33
  86. package/dist/commands/auth/signup.js +1 -89
  87. package/dist/commands/auth/status.js +1 -42
  88. package/dist/commands/catalog/index.js +2 -52
  89. package/dist/commands/catalog/recommend.js +3 -43
  90. package/dist/commands/convert.js +1 -75
  91. package/dist/commands/converters.js +1 -54
  92. package/dist/commands/crons/list.js +1 -41
  93. package/dist/commands/crons/run.js +2 -76
  94. package/dist/commands/dashboard.js +1 -46
  95. package/dist/commands/diagnostics.js +1 -117
  96. package/dist/commands/eval-targets/create.js +1 -53
  97. package/dist/commands/eval-targets/list.js +1 -54
  98. package/dist/commands/evals/agent.js +3 -310
  99. package/dist/commands/evals/benchmark.js +6 -73
  100. package/dist/commands/evals/compare.js +13 -96
  101. package/dist/commands/evals/create.js +1 -67
  102. package/dist/commands/evals/optimize-description.js +25 -239
  103. package/dist/commands/evals/optimize.js +5 -211
  104. package/dist/commands/evals/run.js +3 -183
  105. package/dist/commands/gateway/ensure.js +1 -104
  106. package/dist/commands/hooks/emit-instructions.js +1 -25
  107. package/dist/commands/hooks/install.js +1 -442
  108. package/dist/commands/hooks/run.js +3 -81
  109. package/dist/commands/hooks/uninstall.js +2 -156
  110. package/dist/commands/import.js +1 -66
  111. package/dist/commands/instructions/create.js +1 -74
  112. package/dist/commands/instructions/delete.js +1 -55
  113. package/dist/commands/instructions/fork.js +1 -34
  114. package/dist/commands/instructions/get.js +1 -68
  115. package/dist/commands/instructions/list.js +1 -65
  116. package/dist/commands/instructions/promote.js +1 -42
  117. package/dist/commands/instructions/pull.js +1 -39
  118. package/dist/commands/instructions/upstream.js +1 -38
  119. package/dist/commands/instructions/versions.js +1 -53
  120. package/dist/commands/launcher.js +1 -40
  121. package/dist/commands/org/current.js +1 -77
  122. package/dist/commands/org/list.js +1 -52
  123. package/dist/commands/org/switch.js +1 -71
  124. package/dist/commands/packs/add-instruction.js +1 -37
  125. package/dist/commands/packs/apply.js +1 -39
  126. package/dist/commands/packs/create.js +1 -50
  127. package/dist/commands/packs/fork.js +1 -34
  128. package/dist/commands/packs/get.js +3 -56
  129. package/dist/commands/packs/list.js +1 -66
  130. package/dist/commands/packs/remove-instruction.js +1 -35
  131. package/dist/commands/proxy/env.js +3 -131
  132. package/dist/commands/proxy/logs.js +3 -85
  133. package/dist/commands/proxy/restart.js +1 -35
  134. package/dist/commands/proxy/setup.js +17 -454
  135. package/dist/commands/proxy/start.js +10 -333
  136. package/dist/commands/proxy/status.js +1 -78
  137. package/dist/commands/proxy/stop.js +1 -94
  138. package/dist/commands/research/backfill.js +1 -59
  139. package/dist/commands/research/tail-transcript.js +1 -70
  140. package/dist/commands/service/install.js +57 -796
  141. package/dist/commands/service/status.js +1 -180
  142. package/dist/commands/service/uninstall.js +1 -119
  143. package/dist/commands/sessions/analyze.js +1 -48
  144. package/dist/commands/sessions/end.js +2 -85
  145. package/dist/commands/sessions/import.js +1 -46
  146. package/dist/commands/sessions/list.js +1 -48
  147. package/dist/commands/sessions/start.js +3 -90
  148. package/dist/commands/setup.js +3 -150
  149. package/dist/commands/skills/export-approved.js +1 -46
  150. package/dist/commands/skills/install.js +4 -107
  151. package/dist/commands/skills/list.js +4 -65
  152. package/dist/commands/skills/publish.js +2 -98
  153. package/dist/commands/skills/search.js +3 -72
  154. package/dist/commands/skills/update.js +3 -55
  155. package/dist/commands/suggestions/accept.js +8 -84
  156. package/dist/commands/suggestions/dismiss.js +1 -45
  157. package/dist/commands/suggestions/list.js +2 -61
  158. package/dist/commands/suggestions/refresh.js +1 -27
  159. package/dist/cursor-T7AMCMKS.js +13 -0
  160. package/dist/dashboard/Dashboard.js +1 -243
  161. package/dist/dashboard/data.js +1 -15
  162. package/dist/dashboard/launcher/ActiveJobsList.js +1 -10
  163. package/dist/dashboard/launcher/LauncherOverlay.js +1 -16
  164. package/dist/dashboard/launcher/NewLaunchForm.js +1 -10
  165. package/dist/dashboard/launcher/api.js +1 -16
  166. package/dist/dashboard/launcher/tool-labels.js +1 -10
  167. package/dist/dashboard/launcher/types.js +0 -1
  168. package/dist/dashboard/launcher/useLaunchJobs.js +1 -11
  169. package/dist/dashboard/panels/friction.js +1 -10
  170. package/dist/dashboard/panels/insights.js +1 -10
  171. package/dist/dashboard/panels/instructions.js +1 -10
  172. package/dist/dashboard/panels/outcomes.js +1 -10
  173. package/dist/dashboard/panels/overview.js +1 -10
  174. package/dist/dashboard/panels/shared.js +1 -19
  175. package/dist/dashboard/types.js +1 -24
  176. package/dist/dist-FAVALJ5C.js +1 -0
  177. package/dist/index.js +1 -8
  178. package/dist/lib/active-org-refresh.js +1 -15
  179. package/dist/lib/active-org.js +1 -16
  180. package/dist/lib/agent-loop.js +1 -47
  181. package/dist/lib/antigravity-transcript.js +1 -22
  182. package/dist/lib/api-client.js +1 -23
  183. package/dist/lib/auth.js +1 -30
  184. package/dist/lib/capture-hosts.js +1 -8
  185. package/dist/lib/detect-languages.js +1 -8
  186. package/dist/lib/detect-tmux.js +1 -9
  187. package/dist/lib/diagnostics.js +1 -12
  188. package/dist/lib/editor-proxy-pins.js +1 -14
  189. package/dist/lib/ensure-api-key.js +1 -11
  190. package/dist/lib/ensure-fresh-token.js +1 -0
  191. package/dist/lib/eval-analyzer.js +1 -9
  192. package/dist/lib/eval-benchmark.js +1 -12
  193. package/dist/lib/eval-conversation-handler.js +1 -13
  194. package/dist/lib/eval-executor.js +1 -8
  195. package/dist/lib/eval-grader.js +1 -9
  196. package/dist/lib/eval-meta-judge.js +1 -9
  197. package/dist/lib/eval-trigger-tester.js +1 -11
  198. package/dist/lib/eval-worktree.js +1 -8
  199. package/dist/lib/gateway-entry.js +1 -61
  200. package/dist/lib/gateway-identity.js +1 -16
  201. package/dist/lib/gateway-lifecycle.js +1 -32
  202. package/dist/lib/gateway.js +1 -14
  203. package/dist/lib/handlers/cron-refresh-pricing.js +1 -0
  204. package/dist/lib/handlers/cron-refresh-skills.js +1 -8
  205. package/dist/lib/handlers/cron-suggest-instructions.js +1 -16
  206. package/dist/lib/handlers/process-announcement.js +1 -11
  207. package/dist/lib/handlers/process-changelog.js +1 -11
  208. package/dist/lib/handlers/process-conversation.js +1 -14
  209. package/dist/lib/handlers/process-eval.js +1 -15
  210. package/dist/lib/handlers/process-insights.js +1 -15
  211. package/dist/lib/handlers/process-launch.js +1 -16
  212. package/dist/lib/handlers/process-run-cleanup.js +1 -13
  213. package/dist/lib/handlers/process-send-message.js +1 -10
  214. package/dist/lib/handlers/process-session-goal.js +1 -12
  215. package/dist/lib/hooks-config.js +1 -81
  216. package/dist/lib/insights-prompts.js +1 -12
  217. package/dist/lib/instruction-snapshot.js +1 -8
  218. package/dist/lib/job-helpers.js +0 -1
  219. package/dist/lib/llm-client.js +1 -20
  220. package/dist/lib/manual-tasks-meta.js +1 -8
  221. package/dist/lib/manual-tasks.js +1 -80
  222. package/dist/lib/output.js +1 -12
  223. package/dist/lib/permanent-job-error.js +1 -10
  224. package/dist/lib/pid-identity.js +1 -14
  225. package/dist/lib/proxy-respawn.js +1 -12
  226. package/dist/lib/research-client.js +1 -12
  227. package/dist/lib/setup-steps.js +1 -33
  228. package/dist/lib/skills-loader.js +1 -8
  229. package/dist/lib/statusline-shim.js +1 -20
  230. package/dist/lib/telemetry.js +1 -16
  231. package/dist/lib/terminal-target-heartbeat.js +1 -15
  232. package/dist/lib/tmux.js +1 -16
  233. package/dist/lib/transcript-rate-limit-watcher.js +1 -22
  234. package/dist/lib/types.js +1 -8
  235. package/dist/lib/version-check.js +1 -12
  236. package/dist/lib/which.js +1 -8
  237. package/dist/lib/worktree.js +1 -17
  238. package/dist/opencode-QRJ3BH23.js +1 -0
  239. package/oclif.manifest.json +12 -34
  240. package/package.json +9 -8
  241. package/dist/base-command.js.map +0 -7
  242. package/dist/chunk-2HK7RGZB.js +0 -82
  243. package/dist/chunk-2HK7RGZB.js.map +0 -7
  244. package/dist/chunk-2ORJWTNZ.js +0 -307
  245. package/dist/chunk-2ORJWTNZ.js.map +0 -7
  246. package/dist/chunk-37LN5O7M.js +0 -59
  247. package/dist/chunk-37LN5O7M.js.map +0 -7
  248. package/dist/chunk-3S7223UR.js +0 -81
  249. package/dist/chunk-3S7223UR.js.map +0 -7
  250. package/dist/chunk-3TIMQ3O6.js +0 -96
  251. package/dist/chunk-3TIMQ3O6.js.map +0 -7
  252. package/dist/chunk-42GFSAJP.js +0 -32
  253. package/dist/chunk-42GFSAJP.js.map +0 -7
  254. package/dist/chunk-4BHDHHKL.js +0 -48
  255. package/dist/chunk-4BHDHHKL.js.map +0 -7
  256. package/dist/chunk-4D537GXE.js +0 -99
  257. package/dist/chunk-4D537GXE.js.map +0 -7
  258. package/dist/chunk-4LYCDS2N.js +0 -139
  259. package/dist/chunk-4LYCDS2N.js.map +0 -7
  260. package/dist/chunk-4SCZK7AL.js +0 -129
  261. package/dist/chunk-4SCZK7AL.js.map +0 -7
  262. package/dist/chunk-4XAWK6S2.js +0 -161
  263. package/dist/chunk-4XAWK6S2.js.map +0 -7
  264. package/dist/chunk-52WIYRZH.js +0 -73
  265. package/dist/chunk-52WIYRZH.js.map +0 -7
  266. package/dist/chunk-5BAOGNUH.js +0 -79
  267. package/dist/chunk-5BAOGNUH.js.map +0 -7
  268. package/dist/chunk-5EDMGK3W.js +0 -39
  269. package/dist/chunk-5EDMGK3W.js.map +0 -7
  270. package/dist/chunk-6NBS5XFS.js +0 -99
  271. package/dist/chunk-6NBS5XFS.js.map +0 -7
  272. package/dist/chunk-7LVVKQMZ.js +0 -98
  273. package/dist/chunk-7LVVKQMZ.js.map +0 -7
  274. package/dist/chunk-7NNFYWKK.js +0 -243
  275. package/dist/chunk-7NNFYWKK.js.map +0 -7
  276. package/dist/chunk-7NYKWN7U.js +0 -12
  277. package/dist/chunk-7NYKWN7U.js.map +0 -7
  278. package/dist/chunk-BO76WKJR.js +0 -42
  279. package/dist/chunk-BO76WKJR.js.map +0 -7
  280. package/dist/chunk-BRD5RUGM.js +0 -53
  281. package/dist/chunk-BRD5RUGM.js.map +0 -7
  282. package/dist/chunk-BT6Z6545.js +0 -43
  283. package/dist/chunk-BT6Z6545.js.map +0 -7
  284. package/dist/chunk-BZDKEQKU.js +0 -39
  285. package/dist/chunk-BZDKEQKU.js.map +0 -7
  286. package/dist/chunk-DGHWRQXL.js +0 -17
  287. package/dist/chunk-DGHWRQXL.js.map +0 -7
  288. package/dist/chunk-DIQUV5FR.js +0 -257
  289. package/dist/chunk-DIQUV5FR.js.map +0 -7
  290. package/dist/chunk-DMX5YOTM.js +0 -167
  291. package/dist/chunk-DMX5YOTM.js.map +0 -7
  292. package/dist/chunk-DNKSVWMD.js +0 -108
  293. package/dist/chunk-DNKSVWMD.js.map +0 -7
  294. package/dist/chunk-DQ3KELXD.js +0 -74
  295. package/dist/chunk-DQ3KELXD.js.map +0 -7
  296. package/dist/chunk-DUJSRBLP.js +0 -122
  297. package/dist/chunk-DUJSRBLP.js.map +0 -7
  298. package/dist/chunk-E3BIT53W.js +0 -154
  299. package/dist/chunk-E3BIT53W.js.map +0 -7
  300. package/dist/chunk-EARWG4EV.js +0 -22
  301. package/dist/chunk-EARWG4EV.js.map +0 -7
  302. package/dist/chunk-EI5BHWXA.js +0 -1662
  303. package/dist/chunk-EI5BHWXA.js.map +0 -7
  304. package/dist/chunk-EJ3YAFDP.js +0 -37
  305. package/dist/chunk-EJ3YAFDP.js.map +0 -7
  306. package/dist/chunk-EKJ2CABV.js +0 -76
  307. package/dist/chunk-EKJ2CABV.js.map +0 -7
  308. package/dist/chunk-EKP32DLN.js +0 -16
  309. package/dist/chunk-EKP32DLN.js.map +0 -7
  310. package/dist/chunk-EYPAAGN5.js +0 -51
  311. package/dist/chunk-EYPAAGN5.js.map +0 -7
  312. package/dist/chunk-F5N6CLJJ.js +0 -1995
  313. package/dist/chunk-F5N6CLJJ.js.map +0 -7
  314. package/dist/chunk-GIUBARWS.js +0 -99
  315. package/dist/chunk-GIUBARWS.js.map +0 -7
  316. package/dist/chunk-GQNJO2P2.js +0 -102
  317. package/dist/chunk-GQNJO2P2.js.map +0 -7
  318. package/dist/chunk-IJGF2ETG.js +0 -68
  319. package/dist/chunk-IJGF2ETG.js.map +0 -7
  320. package/dist/chunk-ILYDELUE.js +0 -46
  321. package/dist/chunk-ILYDELUE.js.map +0 -7
  322. package/dist/chunk-J6QFW4LD.js +0 -55
  323. package/dist/chunk-J6QFW4LD.js.map +0 -7
  324. package/dist/chunk-J7N3DLH6.js +0 -117
  325. package/dist/chunk-J7N3DLH6.js.map +0 -7
  326. package/dist/chunk-JFDWKLQC.js +0 -23
  327. package/dist/chunk-JFDWKLQC.js.map +0 -7
  328. package/dist/chunk-JULOLTZS.js +0 -61
  329. package/dist/chunk-JULOLTZS.js.map +0 -7
  330. package/dist/chunk-KJKBDQ4D.js +0 -220
  331. package/dist/chunk-KJKBDQ4D.js.map +0 -7
  332. package/dist/chunk-KRBQLMOP.js +0 -41
  333. package/dist/chunk-KRBQLMOP.js.map +0 -7
  334. package/dist/chunk-LXKPNATC.js +0 -624
  335. package/dist/chunk-LXKPNATC.js.map +0 -7
  336. package/dist/chunk-NSBPE2FW.js +0 -17
  337. package/dist/chunk-NSBPE2FW.js.map +0 -7
  338. package/dist/chunk-OCKHW72U.js +0 -55
  339. package/dist/chunk-OCKHW72U.js.map +0 -7
  340. package/dist/chunk-OKWCKCPE.js +0 -414
  341. package/dist/chunk-OKWCKCPE.js.map +0 -7
  342. package/dist/chunk-OO7JDFS4.js +0 -157
  343. package/dist/chunk-OO7JDFS4.js.map +0 -7
  344. package/dist/chunk-OQBBVTDG.js.map +0 -7
  345. package/dist/chunk-OQSQC7VB.js +0 -77
  346. package/dist/chunk-OQSQC7VB.js.map +0 -7
  347. package/dist/chunk-PED7L5GX.js +0 -92
  348. package/dist/chunk-PED7L5GX.js.map +0 -7
  349. package/dist/chunk-QJQS6TUN.js +0 -44
  350. package/dist/chunk-QJQS6TUN.js.map +0 -7
  351. package/dist/chunk-QN34TGD3.js +0 -83
  352. package/dist/chunk-QN34TGD3.js.map +0 -7
  353. package/dist/chunk-QSN77T7C.js +0 -250
  354. package/dist/chunk-QSN77T7C.js.map +0 -7
  355. package/dist/chunk-R56PH7YE.js +0 -78
  356. package/dist/chunk-R56PH7YE.js.map +0 -7
  357. package/dist/chunk-RAXRZYOB.js +0 -299
  358. package/dist/chunk-RAXRZYOB.js.map +0 -7
  359. package/dist/chunk-RH7NHVSK.js +0 -16
  360. package/dist/chunk-RH7NHVSK.js.map +0 -7
  361. package/dist/chunk-RMTT4KDY.js +0 -191
  362. package/dist/chunk-RMTT4KDY.js.map +0 -7
  363. package/dist/chunk-RQ2TMLKG.js +0 -142
  364. package/dist/chunk-RQ2TMLKG.js.map +0 -7
  365. package/dist/chunk-SO3T35U7.js +0 -80
  366. package/dist/chunk-SO3T35U7.js.map +0 -7
  367. package/dist/chunk-UKMLICWS.js +0 -51
  368. package/dist/chunk-UKMLICWS.js.map +0 -7
  369. package/dist/chunk-VA5FFOS7.js +0 -243
  370. package/dist/chunk-VA5FFOS7.js.map +0 -7
  371. package/dist/chunk-W2YERO7E.js +0 -170
  372. package/dist/chunk-W2YERO7E.js.map +0 -7
  373. package/dist/chunk-W53GKIZQ.js +0 -50
  374. package/dist/chunk-W53GKIZQ.js.map +0 -7
  375. package/dist/chunk-WA4MWYRW.js +0 -254
  376. package/dist/chunk-WA4MWYRW.js.map +0 -7
  377. package/dist/chunk-XC6M4CSW.js +0 -44
  378. package/dist/chunk-XC6M4CSW.js.map +0 -7
  379. package/dist/chunk-XK42ZBDE.js +0 -23
  380. package/dist/chunk-XK42ZBDE.js.map +0 -7
  381. package/dist/chunk-XUV6DDBF.js +0 -124
  382. package/dist/chunk-XUV6DDBF.js.map +0 -7
  383. package/dist/chunk-XZXS2W24.js.map +0 -7
  384. package/dist/chunk-Y3WD5CSW.js +0 -49
  385. package/dist/chunk-Y3WD5CSW.js.map +0 -7
  386. package/dist/chunk-Y4BJXXYV.js +0 -148
  387. package/dist/chunk-Y4BJXXYV.js.map +0 -7
  388. package/dist/chunk-YNIH3KMU.js +0 -121
  389. package/dist/chunk-YNIH3KMU.js.map +0 -7
  390. package/dist/chunk-ZUJBM6HE.js +0 -125
  391. package/dist/chunk-ZUJBM6HE.js.map +0 -7
  392. package/dist/commands/antigravity/backfill.js.map +0 -7
  393. package/dist/commands/auth/create-key.js.map +0 -7
  394. package/dist/commands/auth/login.js.map +0 -7
  395. package/dist/commands/auth/logout.js.map +0 -7
  396. package/dist/commands/auth/revoke-key.js.map +0 -7
  397. package/dist/commands/auth/signup.js.map +0 -7
  398. package/dist/commands/auth/status.js.map +0 -7
  399. package/dist/commands/catalog/index.js.map +0 -7
  400. package/dist/commands/catalog/recommend.js.map +0 -7
  401. package/dist/commands/convert.js.map +0 -7
  402. package/dist/commands/converters.js.map +0 -7
  403. package/dist/commands/crons/list.js.map +0 -7
  404. package/dist/commands/crons/run.js.map +0 -7
  405. package/dist/commands/dashboard.js.map +0 -7
  406. package/dist/commands/diagnostics.js.map +0 -7
  407. package/dist/commands/eval-targets/create.js.map +0 -7
  408. package/dist/commands/eval-targets/list.js.map +0 -7
  409. package/dist/commands/evals/agent.js.map +0 -7
  410. package/dist/commands/evals/benchmark.js.map +0 -7
  411. package/dist/commands/evals/compare.js.map +0 -7
  412. package/dist/commands/evals/create.js.map +0 -7
  413. package/dist/commands/evals/optimize-description.js.map +0 -7
  414. package/dist/commands/evals/optimize.js.map +0 -7
  415. package/dist/commands/evals/run.js.map +0 -7
  416. package/dist/commands/gateway/ensure.js.map +0 -7
  417. package/dist/commands/hooks/emit-instructions.js.map +0 -7
  418. package/dist/commands/hooks/install.js.map +0 -7
  419. package/dist/commands/hooks/run.js.map +0 -7
  420. package/dist/commands/hooks/uninstall.js.map +0 -7
  421. package/dist/commands/import.js.map +0 -7
  422. package/dist/commands/instructions/create.js.map +0 -7
  423. package/dist/commands/instructions/delete.js.map +0 -7
  424. package/dist/commands/instructions/fork.js.map +0 -7
  425. package/dist/commands/instructions/get.js.map +0 -7
  426. package/dist/commands/instructions/list.js.map +0 -7
  427. package/dist/commands/instructions/promote.js.map +0 -7
  428. package/dist/commands/instructions/pull.js.map +0 -7
  429. package/dist/commands/instructions/upstream.js.map +0 -7
  430. package/dist/commands/instructions/versions.js.map +0 -7
  431. package/dist/commands/launcher.js.map +0 -7
  432. package/dist/commands/org/current.js.map +0 -7
  433. package/dist/commands/org/list.js.map +0 -7
  434. package/dist/commands/org/switch.js.map +0 -7
  435. package/dist/commands/packs/add-instruction.js.map +0 -7
  436. package/dist/commands/packs/apply.js.map +0 -7
  437. package/dist/commands/packs/create.js.map +0 -7
  438. package/dist/commands/packs/fork.js.map +0 -7
  439. package/dist/commands/packs/get.js.map +0 -7
  440. package/dist/commands/packs/list.js.map +0 -7
  441. package/dist/commands/packs/remove-instruction.js.map +0 -7
  442. package/dist/commands/proxy/env.js.map +0 -7
  443. package/dist/commands/proxy/logs.js.map +0 -7
  444. package/dist/commands/proxy/restart.js.map +0 -7
  445. package/dist/commands/proxy/setup.js.map +0 -7
  446. package/dist/commands/proxy/start.js.map +0 -7
  447. package/dist/commands/proxy/status.js.map +0 -7
  448. package/dist/commands/proxy/stop.js.map +0 -7
  449. package/dist/commands/research/backfill.js.map +0 -7
  450. package/dist/commands/research/tail-transcript.js.map +0 -7
  451. package/dist/commands/service/install.js.map +0 -7
  452. package/dist/commands/service/status.js.map +0 -7
  453. package/dist/commands/service/uninstall.js.map +0 -7
  454. package/dist/commands/sessions/analyze.js.map +0 -7
  455. package/dist/commands/sessions/end.js.map +0 -7
  456. package/dist/commands/sessions/import.js.map +0 -7
  457. package/dist/commands/sessions/list.js.map +0 -7
  458. package/dist/commands/sessions/start.js.map +0 -7
  459. package/dist/commands/setup.js.map +0 -7
  460. package/dist/commands/skills/export-approved.js.map +0 -7
  461. package/dist/commands/skills/install.js.map +0 -7
  462. package/dist/commands/skills/list.js.map +0 -7
  463. package/dist/commands/skills/publish.js.map +0 -7
  464. package/dist/commands/skills/search.js.map +0 -7
  465. package/dist/commands/skills/update.js.map +0 -7
  466. package/dist/commands/suggestions/accept.js.map +0 -7
  467. package/dist/commands/suggestions/dismiss.js.map +0 -7
  468. package/dist/commands/suggestions/list.js.map +0 -7
  469. package/dist/commands/suggestions/refresh.js.map +0 -7
  470. package/dist/cursor-BGQJ4CWI.js +0 -134
  471. package/dist/cursor-BGQJ4CWI.js.map +0 -7
  472. package/dist/dashboard/Dashboard.js.map +0 -7
  473. package/dist/dashboard/data.js.map +0 -7
  474. package/dist/dashboard/launcher/ActiveJobsList.js.map +0 -7
  475. package/dist/dashboard/launcher/LauncherOverlay.js.map +0 -7
  476. package/dist/dashboard/launcher/NewLaunchForm.js.map +0 -7
  477. package/dist/dashboard/launcher/api.js.map +0 -7
  478. package/dist/dashboard/launcher/tool-labels.js.map +0 -7
  479. package/dist/dashboard/launcher/types.js.map +0 -7
  480. package/dist/dashboard/launcher/useLaunchJobs.js.map +0 -7
  481. package/dist/dashboard/panels/friction.js.map +0 -7
  482. package/dist/dashboard/panels/insights.js.map +0 -7
  483. package/dist/dashboard/panels/instructions.js.map +0 -7
  484. package/dist/dashboard/panels/outcomes.js.map +0 -7
  485. package/dist/dashboard/panels/overview.js.map +0 -7
  486. package/dist/dashboard/panels/shared.js.map +0 -7
  487. package/dist/dashboard/types.js.map +0 -7
  488. package/dist/dist-UNYP5PJR.js +0 -56
  489. package/dist/dist-UNYP5PJR.js.map +0 -7
  490. package/dist/index.js.map +0 -7
  491. package/dist/lib/active-org-refresh.js.map +0 -7
  492. package/dist/lib/active-org.js.map +0 -7
  493. package/dist/lib/agent-loop.js.map +0 -7
  494. package/dist/lib/antigravity-transcript.js.map +0 -7
  495. package/dist/lib/api-client.js.map +0 -7
  496. package/dist/lib/auth.js.map +0 -7
  497. package/dist/lib/capture-hosts.js.map +0 -7
  498. package/dist/lib/detect-languages.js.map +0 -7
  499. package/dist/lib/detect-tmux.js.map +0 -7
  500. package/dist/lib/diagnostics.js.map +0 -7
  501. package/dist/lib/editor-proxy-pins.js.map +0 -7
  502. package/dist/lib/ensure-api-key.js.map +0 -7
  503. package/dist/lib/eval-analyzer.js.map +0 -7
  504. package/dist/lib/eval-benchmark.js.map +0 -7
  505. package/dist/lib/eval-conversation-handler.js.map +0 -7
  506. package/dist/lib/eval-executor.js.map +0 -7
  507. package/dist/lib/eval-grader.js.map +0 -7
  508. package/dist/lib/eval-meta-judge.js.map +0 -7
  509. package/dist/lib/eval-trigger-tester.js.map +0 -7
  510. package/dist/lib/eval-worktree.js.map +0 -7
  511. package/dist/lib/gateway-entry.js.map +0 -7
  512. package/dist/lib/gateway-identity.js.map +0 -7
  513. package/dist/lib/gateway-lifecycle.js.map +0 -7
  514. package/dist/lib/gateway.js.map +0 -7
  515. package/dist/lib/handlers/cron-refresh-skills.js.map +0 -7
  516. package/dist/lib/handlers/cron-suggest-instructions.js.map +0 -7
  517. package/dist/lib/handlers/process-announcement.js.map +0 -7
  518. package/dist/lib/handlers/process-changelog.js.map +0 -7
  519. package/dist/lib/handlers/process-conversation.js.map +0 -7
  520. package/dist/lib/handlers/process-eval.js.map +0 -7
  521. package/dist/lib/handlers/process-insights.js.map +0 -7
  522. package/dist/lib/handlers/process-launch.js.map +0 -7
  523. package/dist/lib/handlers/process-run-cleanup.js.map +0 -7
  524. package/dist/lib/handlers/process-send-message.js.map +0 -7
  525. package/dist/lib/handlers/process-session-goal.js.map +0 -7
  526. package/dist/lib/hooks-config.js.map +0 -7
  527. package/dist/lib/insights-prompts.js.map +0 -7
  528. package/dist/lib/instruction-snapshot.js.map +0 -7
  529. package/dist/lib/job-helpers.js.map +0 -7
  530. package/dist/lib/llm-client.js.map +0 -7
  531. package/dist/lib/manual-tasks-meta.js.map +0 -7
  532. package/dist/lib/manual-tasks.js.map +0 -7
  533. package/dist/lib/output.js.map +0 -7
  534. package/dist/lib/permanent-job-error.js.map +0 -7
  535. package/dist/lib/pid-identity.js.map +0 -7
  536. package/dist/lib/proxy-respawn.js.map +0 -7
  537. package/dist/lib/research-client.js.map +0 -7
  538. package/dist/lib/setup-steps.js.map +0 -7
  539. package/dist/lib/skills-loader.js.map +0 -7
  540. package/dist/lib/statusline-shim.js.map +0 -7
  541. package/dist/lib/telemetry.js.map +0 -7
  542. package/dist/lib/terminal-target-heartbeat.js.map +0 -7
  543. package/dist/lib/tmux.js.map +0 -7
  544. package/dist/lib/transcript-rate-limit-watcher.js.map +0 -7
  545. package/dist/lib/types.js.map +0 -7
  546. package/dist/lib/version-check.js.map +0 -7
  547. package/dist/lib/which.js.map +0 -7
  548. package/dist/lib/worktree.js.map +0 -7
  549. package/dist/opencode-IQ7X5YMJ.js +0 -190
  550. package/dist/opencode-IQ7X5YMJ.js.map +0 -7
@@ -0,0 +1,2 @@
1
+ import{c as E,o as m}from"./chunk-7DFNBRLY.js";import{a as d}from"./chunk-H2ORWIEY.js";import{a as c}from"./chunk-ZLLER3HP.js";import*as p from"node:fs";import*as u from"node:path";import*as _ from"node:os";function T(){if(process.env.RULEMETRIC_API_KEY||process.env.RULEMETRIC_ACCESS_TOKEN)return;let s=u.join(_.homedir(),".config","rulemetric","env");C(s)||C(u.join(process.cwd(),".env.local"))}c(T,"ensureEnv");function C(s){try{let t=p.readFileSync(s,"utf-8");for(let n of t.split(`
2
+ `)){let e=n.trim();if(!e||e.startsWith("#"))continue;let o=e.indexOf("=");if(o<0)continue;let r=e.slice(0,o).trim(),i=e.slice(o+1).trim();process.env[r]||(process.env[r]=i)}return!!(process.env.RULEMETRIC_API_KEY||process.env.RULEMETRIC_ACCESS_TOKEN)}catch{return!1}}c(C,"loadEnvFile");T();async function I(s){let t={totalSessions:0,totalCalls:0,totalInputTokens:0,totalOutputTokens:0,totalCacheReadTokens:0,totalCacheWriteTokens:0,totalCostUSD:0,providers:{}},n=await m(s);t.providers={};for(let a of n)t.providers[a.provider]=(t.providers[a.provider]||0)+1;let e=new E,o=n.filter(a=>a.provider==="claude");for(let a of o)try{let h=p.readdirSync(a.path).filter(f=>f.endsWith(".jsonl"));t.totalSessions+=h.length;for(let f of h){let v=p.readFileSync(u.join(a.path,f),"utf-8"),R=e.parse(v);for(let l of R.events)l.tokenUsage&&(t.totalCalls++,t.totalInputTokens+=l.tokenUsage.input,t.totalOutputTokens+=l.tokenUsage.output,t.totalCacheReadTokens+=l.tokenUsage.cacheRead??0,t.totalCacheWriteTokens+=l.tokenUsage.cacheWrite??0)}}catch{}let r=15,i=75;return t.totalCostUSD=Math.round((t.totalInputTokens/1e6*r+t.totalOutputTokens/1e6*i+t.totalCacheReadTokens/1e6*(r*.1)+t.totalCacheWriteTokens/1e6*(r*1.25))*100)/100,t}c(I,"loadLocalStats");async function U(s){let t=process.env.RULEMETRIC_API_URL??d,n=process.env.RULEMETRIC_API_KEY,e=process.env.RULEMETRIC_ACCESS_TOKEN,o=n??e;if(!o)return null;let r=new URLSearchParams;s&&r.set("projectPath",s);try{let i=await fetch(`${t}/api/insights/compute?${r}`,{headers:{Authorization:`Bearer ${o}`},signal:AbortSignal.timeout(5e3)});return i.ok?await i.json():null}catch{return null}}c(U,"loadApiInsights");async function g(s){let t=process.env.RULEMETRIC_API_URL??d,n=process.env.RULEMETRIC_API_KEY??process.env.RULEMETRIC_ACCESS_TOKEN;if(!n)return null;let e=new URLSearchParams;s&&e.set("projectPath",s);try{let o=await fetch(`${t}/api/insights/linked-instructions?${e}`,{headers:{Authorization:`Bearer ${n}`},signal:AbortSignal.timeout(5e3)});return o.ok?await o.json():null}catch{return null}}c(g,"loadLinkedInstructions");export{I as a,U as b,g as c};
@@ -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 @@
1
+ import{a as T,e as w}from"./chunk-O6C2UGBY.js";import{a as s}from"./chunk-ZLLER3HP.js";import{fileURLToPath as x}from"node:url";import{existsSync as A,readFileSync as E}from"node:fs";import{dirname as v,join as O}from"node:path";function _(){let e=v(x(import.meta.url));for(let t=0;t<8;t++){let c=O(e,"package.json");if(A(c))try{let i=JSON.parse(E(c,"utf8"));if(i.name==="@rulemetric/cli"&&i.version)return i.version}catch{}let o=v(e);if(o===e)break;e=o}return"0.0.0"}s(_,"readCliVersion");var k=_(),L="https://rulemetric.com",l=class extends Error{constructor(c,o){super(o);this.statusCode=c;this.name="ApiError"}static{s(this,"ApiError")}};function H(){let e=process.env.RULEMETRIC_API_URL??T().apiUrl??L,t=new URL(e);if(t.protocol==="http:"&&t.hostname!=="localhost"&&t.hostname!=="127.0.0.1")throw new Error(`API URL must use HTTPS for non-localhost hosts: ${e}`);return e}s(H,"getBaseUrl");async function a(e,t={}){let o=`${H()}${e}`,i={"Content-Type":"application/json","User-Agent":`rulemetric-cli/${k}`,...t.headers},m=T(),d=process.env.RULEMETRIC_API_KEY||m.apiKey||w()?.accessToken||m.accessToken;d&&(i.Authorization=`Bearer ${d}`);let h=new URL(o),f=h.hostname==="localhost"||h.hostname==="127.0.0.1",P=process.env.HTTPS_PROXY,g=process.env.HTTP_PROXY;f&&(delete process.env.HTTPS_PROXY,delete process.env.HTTP_PROXY);let p=t.timeoutMs?new AbortController:void 0,y=!1,R=p?setTimeout(()=>{y=!0,p.abort()},t.timeoutMs):void 0,r;try{r=await fetch(o,{method:t.method??"GET",headers:i,body:t.body?JSON.stringify(t.body):void 0,signal:p?.signal})}catch(u){if(y){let U=new URL(o).host,b=Math.round(t.timeoutMs/1e3);throw new l(408,`Request to ${U} timed out after ${b}s. This is usually transient or a local proxy/gateway issue \u2014 retry, and if it persists check HTTPS_PROXY / the RuleMetric gateway (:8787).`)}throw u}finally{R&&clearTimeout(R),f&&(P!==void 0&&(process.env.HTTPS_PROXY=P),g!==void 0&&(process.env.HTTP_PROXY=g))}let n;if(r.headers.get("content-type")?.includes("application/json")?n=await r.json():n=await r.text(),!r.ok){let u=n&&typeof n=="object"&&"error"in n?String(n.error):`HTTP ${r.status}`;throw new l(r.status,u)}return n}s(a,"api");var C=s(e=>a(e),"apiGet"),X=s((e,t)=>a(e,{method:"POST",body:t}),"apiPost"),I=s((e,t)=>a(e,{method:"PUT",body:t}),"apiPut"),B=s((e,t)=>a(e,{method:"PATCH",body:t}),"apiPatch"),D=s(e=>a(e,{method:"DELETE"}),"apiDelete");export{L as a,l as b,H as c,a as d,C as e,X as f,I as g,B as h,D as i};
@@ -0,0 +1 @@
1
+ import{a as p,c as Bn}from"./chunk-ZLLER3HP.js";import{boolean as io,pgTable as Hn,text as Le,timestamp as Nt,uuid as ao}from"drizzle-orm/pg-core";import{pgTable as Me,text as Q,timestamp as ge,jsonb as ro,uuid as U,primaryKey as so}from"drizzle-orm/pg-core";var a=Me("organizations",{id:U("id").primaryKey().defaultRandom(),name:Q("name").unique().notNull(),slug:Q("slug").unique().notNull(),metadata:ro("metadata"),createdAt:ge("created_at",{withTimezone:!0}).defaultNow(),updatedAt:ge("updated_at",{withTimezone:!0}).defaultNow()}),x=Me("teams",{id:U("id").primaryKey().defaultRandom(),orgId:U("org_id").references(()=>a.id,{onDelete:"cascade"}),name:Q("name").notNull(),slug:Q("slug").notNull(),metadata:ro("metadata"),createdAt:ge("created_at",{withTimezone:!0}).defaultNow()}),W=Me("user_organizations",{userId:U("user_id").notNull(),orgId:U("org_id").references(()=>a.id,{onDelete:"cascade"}).notNull(),role:Q("role").notNull().default("member"),createdAt:ge("created_at",{withTimezone:!0}).defaultNow()},e=>[so({columns:[e.userId,e.orgId]})]),X=Me("user_teams",{userId:U("user_id").notNull(),teamId:U("team_id").references(()=>x.id,{onDelete:"cascade"}).notNull(),role:Q("role").notNull().default("member"),createdAt:ge("created_at",{withTimezone:!0}).defaultNow()},e=>[so({columns:[e.userId,e.teamId]})]);var s=Hn("profiles",{id:ao("id").primaryKey(),email:Le("email"),displayName:Le("display_name"),activeOrgId:ao("active_org_id").references(()=>a.id,{onDelete:"set null"}),isSuperadmin:io("is_superadmin").notNull().default(!1),claudeCodePlan:Le("claude_code_plan"),planSource:Le("plan_source").notNull().default("detected"),setupCompletedAt:Nt("setup_completed_at",{withTimezone:!0}),liveSendSkipped:io("live_send_skipped").notNull().default(!1),createdAt:Nt("created_at",{withTimezone:!0}).defaultNow(),updatedAt:Nt("updated_at",{withTimezone:!0}).defaultNow()});import{pgTable as Yn,text as Z,timestamp as It,jsonb as _o,uuid as He,integer as Qn,boolean as Wn,index as Tt}from"drizzle-orm/pg-core";import{boolean as Gn,jsonb as Vn,pgTable as yt,primaryKey as co,text as B,timestamp as ve,uniqueIndex as ht,uuid as H}from"drizzle-orm/pg-core";import{sql as Jn}from"drizzle-orm";import{pgTable as uo,text as f,timestamp as Ne,jsonb as Be,uuid as E,integer as vt,boolean as Fn,uniqueIndex as lo,index as Ue}from"drizzle-orm/pg-core";var o=uo("instructions",{id:E("id").primaryKey().defaultRandom(),name:f("name").notNull(),description:f("description").notNull(),type:f("type").notNull().default("instruction"),scope:f("scope").notNull(),scopeRef:E("scope_ref"),version:f("version").notNull(),content:f("content").notNull(),frontmatter:Be("frontmatter").notNull(),slots:Be("slots"),tags:f("tags").array(),compatibility:f("compatibility").array(),createdBy:E("created_by"),createdAt:Ne("created_at",{withTimezone:!0}).defaultNow(),updatedAt:Ne("updated_at",{withTimezone:!0}).defaultNow(),archived:Fn("archived").default(!1),archivedAt:Ne("archived_at",{withTimezone:!0}),archivedBy:E("archived_by"),forkedFromId:E("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:vt("scan_score"),scanFindings:Be("scan_findings"),popularityScore:vt("popularity_score"),sourceUpdatedAt:Ne("source_updated_at",{withTimezone:!0})},e=>[lo("instructions_name_scope_ref_idx").on(e.name,e.scope,e.scopeRef),Ue("idx_instructions_scope").on(e.scope,e.scopeRef),Ue("idx_instructions_created_by").on(e.createdBy),Ue("idx_instructions_context_identity").on(e.createdBy,e.contextIdentity),Ue("idx_instructions_public_recency").on(e.scope,e.sourceUpdatedAt.desc())]),$=uo("instruction_versions",{id:E("id").primaryKey().defaultRandom(),instructionId:E("instruction_id").references(()=>o.id,{onDelete:"cascade"}),versionNumber:vt("version_number").notNull(),content:f("content").notNull(),frontmatter:Be("frontmatter").notNull(),changeSummary:f("change_summary"),createdBy:E("created_by"),createdAt:Ne("created_at",{withTimezone:!0}).defaultNow()},e=>[lo("instruction_versions_instruction_version_idx").on(e.instructionId,e.versionNumber)]);var l=yt("projects",{id:H("id").primaryKey().defaultRandom(),orgId:H("org_id").references(()=>a.id,{onDelete:"cascade"}),name:B("name").notNull(),description:B("description"),githubRepo:B("github_repo"),gitRemoteUrl:B("git_remote_url"),gitRootCommit:B("git_root_commit"),gitRemoteAliases:B("git_remote_aliases").array().notNull().default([]),metadata:Vn("metadata"),createdBy:H("created_by"),createdAt:ve("created_at",{withTimezone:!0}).defaultNow(),updatedAt:ve("updated_at",{withTimezone:!0}).defaultNow()},e=>[ht("projects_org_name_idx").on(e.orgId,e.name),ht("projects_git_remote_url_unique").on(e.gitRemoteUrl).where(Jn`${e.gitRemoteUrl} IS NOT NULL`)]),j=yt("project_instructions",{projectId:H("project_id").references(()=>l.id,{onDelete:"cascade"}).notNull(),instructionId:H("instruction_id").references(()=>o.id,{onDelete:"cascade"}).notNull(),addedAt:ve("added_at",{withTimezone:!0}).defaultNow(),addedBy:H("added_by")},e=>[co({columns:[e.projectId,e.instructionId]})]),po=yt("project_checkouts",{projectId:H("project_id").references(()=>l.id,{onDelete:"cascade"}).notNull(),path:B("path").notNull(),isWorktree:Gn("is_worktree").notNull().default(!1),firstSeen:ve("first_seen",{withTimezone:!0}).notNull().defaultNow(),lastSeen:ve("last_seen",{withTimezone:!0}).notNull().defaultNow()},e=>[co({columns:[e.projectId,e.path]}),ht("project_checkouts_path_unique").on(e.path)]);var m=Yn("agent_runs",{id:He("id").primaryKey().defaultRandom(),userId:He("user_id").notNull().references(()=>s.id,{onDelete:"cascade"}),orgId:He("org_id").references(()=>a.id,{onDelete:"set null"}),projectId:He("project_id").references(()=>l.id,{onDelete:"set null"}),projectPath:Z("project_path"),gitRemote:Z("git_remote"),baseBranch:Z("base_branch"),title:Z("title"),prompt:Z("prompt"),toolSpec:_o("tool_spec").notNull().default([]),autoWorktree:Wn("auto_worktree").notNull().default(!0),status:Z("status").notNull().default("pending"),sessionCount:Qn("session_count").notNull().default(0),metadata:_o("metadata").notNull().default({}),createdAt:It("created_at",{withTimezone:!0}).notNull().defaultNow(),updatedAt:It("updated_at",{withTimezone:!0}).notNull().defaultNow(),completedAt:It("completed_at",{withTimezone:!0})},e=>[Tt("idx_agent_runs_user").on(e.userId),Tt("idx_agent_runs_org_created").on(e.orgId,e.createdAt),Tt("idx_agent_runs_project").on(e.projectId)]);import{pgTable as wt,text as y,timestamp as he,jsonb as F,uuid as w,integer as Fe,uniqueIndex as mo,index as h}from"drizzle-orm/pg-core";var u=wt("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:he("started_at",{withTimezone:!0}).notNull(),endedAt:he("ended_at",{withTimezone:!0}),eventCount:Fe("event_count").default(0),tokenUsage:F("token_usage"),analysis:F("analysis"),analyzedAt:he("analyzed_at",{withTimezone:!0}),analyzedEventCount:Fe("analyzed_event_count"),analyzedTurnCount:Fe("analyzed_turn_count"),metadata:F("metadata").default({}),origin:y("origin").notNull().default("unknown"),runId:w("run_id").references(()=>m.id,{onDelete:"set null"}),createdAt:he("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),mo("idx_sessions_user_external").on(e.userId,e.externalSessionId)]),ee=wt("session_events",{id:w("id").primaryKey().defaultRandom(),sessionId:w("session_id").notNull().references(()=>u.id,{onDelete:"cascade"}),sequence:Fe("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:he("timestamp",{withTimezone:!0}).notNull(),metadata:F("metadata").default({})},e=>[mo("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=wt("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 Xn,date as $n,index as At,integer as Zn,jsonb as er,pgTable as bt,text as N,timestamp as P,uniqueIndex as tr,uuid as te}from"drizzle-orm/pg-core";var fo=bt("announcements",{id:te("id").primaryKey().defaultRandom(),version:N("version").notNull().unique(),releaseDate:$n("release_date").notNull(),subject:N("subject").notNull(),htmlBody:N("html_body").notNull(),textBody:N("text_body").notNull(),sections:er("sections").notNull().default({}),status:N("status").notNull().default("draft"),recipientCount:Zn("recipient_count"),sentAt:P("sent_at",{withTimezone:!0}),sentBy:te("sent_by"),error:N("error"),createdAt:P("created_at",{withTimezone:!0}).notNull().defaultNow(),updatedAt:P("updated_at",{withTimezone:!0}).notNull().defaultNow()},e=>[At("idx_announcements_status").on(e.status),At("idx_announcements_created").on(e.createdAt)]),xo=bt("announcement_deliveries",{id:te("id").primaryKey().defaultRandom(),announcementId:te("announcement_id").notNull(),userId:te("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=>[tr("uniq_announcement_deliveries_announcement_user").on(e.announcementId,e.userId),At("idx_announcement_deliveries_user").on(e.userId,e.createdAt)]),go=bt("notification_preferences",{userId:te("user_id").primaryKey(),productAnnouncements:Xn("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 or,text as zt,timestamp as Ge,uuid as Ve,index as No}from"drizzle-orm/pg-core";var A=or("org_invitations",{id:Ve("id").primaryKey().defaultRandom(),orgId:Ve("org_id").notNull().references(()=>a.id,{onDelete:"cascade"}),email:zt("email").notNull(),role:zt("role").notNull().default("member"),teamId:Ve("team_id").references(()=>x.id,{onDelete:"set null"}),invitedBy:Ve("invited_by").notNull().references(()=>s.id),token:zt("token").notNull().unique(),expiresAt:Ge("expires_at",{withTimezone:!0}).notNull(),acceptedAt:Ge("accepted_at",{withTimezone:!0}),revokedAt:Ge("revoked_at",{withTimezone:!0}),createdAt:Ge("created_at",{withTimezone:!0}).notNull().defaultNow()},e=>[No("idx_org_invitations_token").on(e.token),No("idx_org_invitations_org").on(e.orgId)]);import{pgTable as nr,text as rr,timestamp as sr,jsonb as ir,uuid as Dt,index as vo}from"drizzle-orm/pg-core";var oe=nr("instruction_events",{id:Dt("id").primaryKey().defaultRandom(),instructionId:Dt("instruction_id").notNull().references(()=>o.id,{onDelete:"cascade"}),eventType:rr("event_type").notNull(),actorId:Dt("actor_id").notNull(),metadata:ir("metadata"),createdAt:sr("created_at",{withTimezone:!0}).defaultNow()},e=>[vo("idx_instruction_events_instruction").on(e.instructionId),vo("idx_instruction_events_type").on(e.eventType)]);import{pgTable as ar,text as ne,timestamp as kt,uuid as Rt,jsonb as dr,uniqueIndex as ur,index as ho}from"drizzle-orm/pg-core";var Je=ar("session_terminal_targets",{id:Rt("id").primaryKey().defaultRandom(),userId:Rt("user_id").notNull().references(()=>s.id,{onDelete:"cascade"}),sessionId:Rt("session_id").references(()=>u.id,{onDelete:"set null"}),externalSessionId:ne("external_session_id"),kind:ne("kind").notNull(),target:ne("target").notNull(),status:ne("status").notNull().default("active"),attachCommand:ne("attach_command").notNull(),projectPath:ne("project_path"),metadata:dr("metadata").notNull().default({}),lastSeenAt:kt("last_seen_at",{withTimezone:!0}).defaultNow(),createdAt:kt("created_at",{withTimezone:!0}).defaultNow(),updatedAt:kt("updated_at",{withTimezone:!0}).defaultNow()},e=>[ur("idx_session_terminal_targets_user_target").on(e.userId,e.target),ho("idx_session_terminal_targets_session").on(e.sessionId),ho("idx_session_terminal_targets_user_status").on(e.userId,e.status)]);import{boolean as lr,index as Ye,jsonb as yo,pgTable as cr,text as G,timestamp as ye,uuid as Qe,integer as pr}from"drizzle-orm/pg-core";var Io=cr("session_send_jobs",{id:Qe("id").primaryKey().defaultRandom(),userId:Qe("user_id").notNull(),sessionId:Qe("session_id").notNull().references(()=>u.id,{onDelete:"cascade"}),terminalTargetId:Qe("terminal_target_id").references(()=>Je.id,{onDelete:"set null"}),target:G("target").notNull(),message:G("message").notNull(),submit:lr("submit").notNull().default(!0),delivery:G("delivery").notNull().default("live"),status:G("status").notNull().default("pending"),result:yo("result"),error:G("error"),attempts:pr("attempts").notNull().default(0),taskKind:G("task_kind"),payload:yo("payload"),claimedBy:G("claimed_by"),claimedAt:ye("claimed_at",{withTimezone:!0}),leaseExpiresAt:ye("lease_expires_at",{withTimezone:!0}),createdAt:ye("created_at",{withTimezone:!0}).defaultNow(),updatedAt:ye("updated_at",{withTimezone:!0}).defaultNow(),completedAt:ye("completed_at",{withTimezone:!0})},e=>[Ye("idx_session_send_jobs_user").on(e.userId),Ye("idx_session_send_jobs_session").on(e.sessionId),Ye("idx_session_send_jobs_status").on(e.status),Ye("idx_session_send_jobs_pending").on(e.userId,e.status)]);import{pgTable as wo,text as V,timestamp as We,jsonb as Ao,uuid as K,integer as _r,boolean as mr,uniqueIndex as fr,index as To,primaryKey as xr}from"drizzle-orm/pg-core";var v=wo("packs",{id:K("id").primaryKey().defaultRandom(),name:V("name").notNull(),description:V("description").notNull(),scope:V("scope").notNull(),scopeRef:K("scope_ref"),version:V("version").notNull().default("1.0.0"),tags:V("tags").array(),badge:V("badge"),metadata:Ao("metadata"),createdBy:K("created_by"),createdAt:We("created_at",{withTimezone:!0}).defaultNow(),updatedAt:We("updated_at",{withTimezone:!0}).defaultNow(),archived:mr("archived").default(!1),archivedAt:We("archived_at",{withTimezone:!0}),archivedBy:K("archived_by"),forkedFromId:K("forked_from_id").references(()=>v.id,{onDelete:"set null"}),upstreamVersion:V("upstream_version")},e=>[fr("packs_name_scope_ref_idx").on(e.name,e.scope,e.scopeRef),To("idx_packs_scope").on(e.scope,e.scopeRef),To("idx_packs_created_by").on(e.createdBy)]),O=wo("pack_instructions",{packId:K("pack_id").references(()=>v.id,{onDelete:"cascade"}).notNull(),instructionId:K("instruction_id").references(()=>o.id,{onDelete:"cascade"}).notNull(),position:_r("position").notNull().default(0),slotOverrides:Ao("slot_overrides"),addedAt:We("added_at",{withTimezone:!0}).defaultNow(),addedBy:K("added_by")},e=>[xr({columns:[e.packId,e.instructionId]})]);import{pgTable as gr,text as Et,timestamp as Nr,jsonb as vr,uuid as jt,index as re}from"drizzle-orm/pg-core";var se=gr("instruction_usage_events",{id:jt("id").primaryKey().defaultRandom(),instructionId:jt("instruction_id").references(()=>o.id,{onDelete:"set null"}),userId:jt("user_id").notNull(),surface:Et("surface").notNull(),action:Et("action").notNull(),metadata:vr("metadata"),traceId:Et("trace_id"),createdAt:Nr("created_at",{withTimezone:!0}).defaultNow()},e=>[re("idx_usage_events_instruction").on(e.instructionId),re("idx_usage_events_user").on(e.userId),re("idx_usage_events_surface").on(e.surface),re("idx_usage_events_action").on(e.action),re("idx_usage_events_created_at").on(e.createdAt),re("idx_usage_events_user_created").on(e.userId,e.createdAt)]);import{pgTable as hr,text as Xe,timestamp as bo,jsonb as yr,uuid as zo,index as St}from"drizzle-orm/pg-core";var Do=hr("worker_connections",{id:zo("id").primaryKey().defaultRandom(),userId:zo("user_id").notNull(),workerType:Xe("worker_type").notNull().default("mcp"),clientName:Xe("client_name").notNull(),clientVersion:Xe("client_version"),workerVersion:Xe("worker_version"),lastHeartbeat:bo("last_heartbeat",{withTimezone:!0}).notNull().defaultNow(),connectedAt:bo("connected_at",{withTimezone:!0}).notNull().defaultNow(),metadata:yr("metadata")},e=>[St("idx_worker_connections_user").on(e.userId),St("idx_worker_connections_heartbeat").on(e.userId,e.lastHeartbeat),St("idx_worker_connections_type").on(e.userId,e.workerType)]);import{pgTable as Ir,text as $e,timestamp as Tr,jsonb as wr,uuid as ko,index as Ro}from"drizzle-orm/pg-core";var Eo=Ir("cli_setup_events",{id:ko("id").primaryKey().defaultRandom(),userId:ko("user_id").notNull(),deviceId:$e("device_id").notNull(),event:$e("event").notNull(),cliVersion:$e("cli_version"),os:$e("os"),props:wr("props").notNull().default({}),createdAt:Tr("created_at",{withTimezone:!0}).notNull().defaultNow()},e=>[Ro("idx_cli_setup_events_user").on(e.userId,e.createdAt),Ro("idx_cli_setup_events_device").on(e.deviceId,e.createdAt)]);import{pgTable as Ar,text as J,integer as br,boolean as zr,timestamp as Dr,jsonb as kr,uuid as Rr,index as jo}from"drizzle-orm/pg-core";var So=Ar("cli_error_events",{id:Rr("id").primaryKey().defaultRandom(),deviceId:J("device_id"),event:J("event").notNull(),command:J("command"),statusCode:br("status_code"),message:J("message"),cliVersion:J("cli_version"),os:J("os"),nodeVersion:J("node_version"),proxied:zr("proxied"),props:kr("props").notNull().default({}),createdAt:Dr("created_at",{withTimezone:!0}).notNull().defaultNow()},e=>[jo("idx_cli_error_events_created").on(e.createdAt),jo("idx_cli_error_events_device").on(e.deviceId,e.createdAt)]);import{pgTable as Ze,text as b,timestamp as ie,jsonb as I,uuid as T,integer as Ie,index as z}from"drizzle-orm/pg-core";var n=Ze("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:Ie("version").notNull().default(1),parentId:T("parent_id").references(()=>n.id,{onDelete:"set null"}),createdAt:ie("created_at",{withTimezone:!0}).defaultNow(),updatedAt:ie("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)]),D=Ze("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:ie("created_at",{withTimezone:!0}).defaultNow(),updatedAt:ie("updated_at",{withTimezone:!0}).defaultNow()},e=>[z("idx_evals_target").on(e.evalTargetId)]),C=Ze("eval_runs",{id:T("id").primaryKey().defaultRandom(),evalId:T("eval_id").notNull().references(()=>D.id,{onDelete:"cascade"}),evalTargetId:T("eval_target_id").notNull().references(()=>n.id,{onDelete:"cascade"}),evalTargetVersion:Ie("eval_target_version").notNull(),configuration:b("configuration").notNull(),runNumber:Ie("run_number").notNull().default(1),iteration:Ie("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:ie("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)]),ae=Ze("benchmarks",{id:T("id").primaryKey().defaultRandom(),evalTargetId:T("eval_target_id").notNull().references(()=>n.id,{onDelete:"cascade"}),iteration:Ie("iteration").notNull().default(1),runSummary:I("run_summary").notNull().default({}),notes:I("notes").notNull().default([]),feedback:I("feedback"),createdAt:ie("created_at",{withTimezone:!0}).defaultNow()},e=>[z("idx_benchmarks_target").on(e.evalTargetId)]);import{pgTable as Ko,text as Pt,timestamp as Kt,jsonb as Oo,uuid as de,integer as Te,index as et,real as Po}from"drizzle-orm/pg-core";var ue=Ko("trigger_evals",{id:de("id").primaryKey().defaultRandom(),evalTargetId:de("eval_target_id").notNull().references(()=>n.id,{onDelete:"cascade"}),userId:de("user_id").notNull(),queries:Oo("queries").notNull().default([]),status:Pt("status").notNull().default("pending_review"),trainIndices:Te("train_indices").array().default([]),testIndices:Te("test_indices").array().default([]),createdAt:Kt("created_at",{withTimezone:!0}).defaultNow(),updatedAt:Kt("updated_at",{withTimezone:!0}).defaultNow()},e=>[et("idx_trigger_evals_target").on(e.evalTargetId),et("idx_trigger_evals_user").on(e.userId)]),le=Ko("optimization_runs",{id:de("id").primaryKey().defaultRandom(),evalTargetId:de("eval_target_id").notNull().references(()=>n.id,{onDelete:"cascade"}),userId:de("user_id").notNull(),type:Pt("type").notNull(),iteration:Te("iteration").notNull(),inputVersion:Te("input_version").notNull(),outputVersion:Te("output_version"),trainScore:Po("train_score"),testScore:Po("test_score"),analysis:Oo("analysis").notNull().default({}),status:Pt("status").notNull().default("running"),createdAt:Kt("created_at",{withTimezone:!0}).defaultNow()},e=>[et("idx_optimization_runs_target").on(e.evalTargetId),et("idx_optimization_runs_user").on(e.userId)]);import{pgTable as Er,text as q,timestamp as jr,jsonb as we,uuid as Ot,integer as Ct,real as Sr,index as Ae,uniqueIndex as Co}from"drizzle-orm/pg-core";var M=Er("context_snapshots",{id:Ot("id").primaryKey().defaultRandom(),sessionId:Ot("session_id").references(()=>u.id,{onDelete:"cascade"}),userId:Ot("user_id").notNull().references(()=>s.id,{onDelete:"cascade"}),sequence:Ct("sequence").notNull().default(0),provider:q("provider").notNull(),model:q("model").notNull(),systemPrompt:q("system_prompt").notNull(),injectedInstructions:we("injected_instructions").notNull().default([]),messagesSummary:we("messages_summary").notNull(),tools:we("tools").notNull().default([]),systemHash:q("system_hash").notNull(),requestHash:q("request_hash").notNull().default(""),toolsHash:q("tools_hash"),injectedHash:q("injected_hash"),messagesDelta:we("messages_delta").default([]),messagesDeltaRef:q("messages_delta_ref"),maxTokens:Ct("max_tokens"),temperature:Sr("temperature"),estimatedTokens:Ct("estimated_tokens"),capturedAt:jr("captured_at",{withTimezone:!0}).notNull().defaultNow(),metadata:we("metadata").default({})},e=>[Ae("idx_context_snapshots_session").on(e.sessionId),Ae("idx_context_snapshots_user").on(e.userId),Ae("idx_context_snapshots_hash").on(e.systemHash),Ae("idx_context_snapshots_request_hash").on(e.requestHash),Co("idx_snapshots_session_request").on(e.sessionId,e.requestHash),Co("idx_snapshots_session_sequence").on(e.sessionId,e.sequence),Ae("idx_context_snapshots_user_session_captured").on(e.userId,e.sessionId,e.capturedAt.desc())]);import{pgTable as Pr,text as qo,timestamp as Kr,jsonb as Or,integer as Cr,index as qr}from"drizzle-orm/pg-core";var Mo=Pr("content_blobs",{hash:qo("hash").primaryKey(),contentType:qo("content_type").notNull(),content:Or("content").notNull(),sizeBytes:Cr("size_bytes").notNull().default(0),createdAt:Kr("created_at",{withTimezone:!0}).defaultNow()},e=>[qr("idx_content_blobs_type").on(e.contentType)]);import{pgTable as Mr,text as tt,timestamp as be,jsonb as ot,uuid as qt,index as nt,integer as Lr}from"drizzle-orm/pg-core";var ce=Mr("eval_jobs",{id:qt("id").primaryKey().defaultRandom(),userId:qt("user_id").notNull(),evalTargetId:qt("eval_target_id").notNull().references(()=>n.id,{onDelete:"cascade"}),status:tt("status").notNull().default("pending"),config:ot("config").notNull().default({}),progress:ot("progress").notNull().default({}),result:ot("result"),error:tt("error"),attempts:Lr("attempts").notNull().default(0),taskKind:tt("task_kind"),payload:ot("payload"),claimedBy:tt("claimed_by"),claimedAt:be("claimed_at",{withTimezone:!0}),leaseExpiresAt:be("lease_expires_at",{withTimezone:!0}),createdAt:be("created_at",{withTimezone:!0}).defaultNow(),updatedAt:be("updated_at",{withTimezone:!0}).defaultNow(),completedAt:be("completed_at",{withTimezone:!0})},e=>[nt("idx_eval_jobs_user").on(e.userId),nt("idx_eval_jobs_target").on(e.evalTargetId),nt("idx_eval_jobs_status").on(e.status),nt("idx_eval_jobs_pending").on(e.userId,e.status)]);import{pgTable as Ur,text as ze,timestamp as De,jsonb as Lo,uuid as Uo,integer as Br,index as Bo}from"drizzle-orm/pg-core";var Ho=Ur("agent_jobs",{id:Uo("id").primaryKey().defaultRandom(),userId:Uo("user_id").notNull(),taskKind:ze("task_kind").notNull(),status:ze("status").notNull().default("pending"),payload:Lo("payload").notNull(),dedupeKey:ze("dedupe_key"),result:Lo("result"),error:ze("error"),attempts:Br("attempts").notNull().default(0),claimedBy:ze("claimed_by"),claimedAt:De("claimed_at",{withTimezone:!0}),leaseExpiresAt:De("lease_expires_at",{withTimezone:!0}),createdAt:De("created_at",{withTimezone:!0}).notNull().defaultNow(),updatedAt:De("updated_at",{withTimezone:!0}).notNull().defaultNow(),completedAt:De("completed_at",{withTimezone:!0})},e=>[Bo("idx_agent_jobs_claim").on(e.userId,e.status,e.taskKind,e.createdAt),Bo("idx_agent_jobs_dedupe").on(e.userId,e.taskKind,e.dedupeKey)]);import{pgTable as Hr,text as ke,timestamp as Re,jsonb as rt,uuid as Mt,index as st,integer as Fr}from"drizzle-orm/pg-core";var Fo=Hr("insights_jobs",{id:Mt("id").primaryKey().defaultRandom(),userId:Mt("user_id").notNull(),status:ke("status").notNull().default("pending"),projectPath:ke("project_path"),projectId:Mt("project_id").references(()=>l.id,{onDelete:"set null"}),config:rt("config").notNull().default({}),progress:rt("progress").notNull().default({}),result:rt("result"),error:ke("error"),attempts:Fr("attempts").notNull().default(0),taskKind:ke("task_kind"),payload:rt("payload"),claimedBy:ke("claimed_by"),claimedAt:Re("claimed_at",{withTimezone:!0}),leaseExpiresAt:Re("lease_expires_at",{withTimezone:!0}),createdAt:Re("created_at",{withTimezone:!0}).defaultNow(),updatedAt:Re("updated_at",{withTimezone:!0}).defaultNow(),completedAt:Re("completed_at",{withTimezone:!0})},e=>[st("idx_insights_jobs_user").on(e.userId),st("idx_insights_jobs_status").on(e.status),st("idx_insights_jobs_pending").on(e.userId,e.status),st("idx_insights_jobs_project").on(e.projectId)]);import{pgTable as Gr,text as Lt,timestamp as it,uuid as Go,index as Vr,uniqueIndex as Jr}from"drizzle-orm/pg-core";var pe=Gr("api_keys",{id:Go("id").primaryKey().defaultRandom(),userId:Go("user_id").notNull().references(()=>s.id,{onDelete:"cascade"}),name:Lt("name").notNull(),keyHash:Lt("key_hash").notNull(),keyPrefix:Lt("key_prefix").notNull(),lastUsedAt:it("last_used_at",{withTimezone:!0}),expiresAt:it("expires_at",{withTimezone:!0}),revokedAt:it("revoked_at",{withTimezone:!0}),createdAt:it("created_at",{withTimezone:!0}).defaultNow()},e=>[Vr("idx_api_keys_user").on(e.userId),Jr("idx_api_keys_hash").on(e.keyHash)]);import{pgTable as Yr,text as Ut,timestamp as Vo,uuid as Qr,index as Wr}from"drizzle-orm/pg-core";var Jo=Yr("extension_auth_codes",{code:Ut("code").primaryKey(),userId:Qr("user_id").notNull().references(()=>s.id,{onDelete:"cascade"}),editor:Ut("editor"),email:Ut("email"),expiresAt:Vo("expires_at",{withTimezone:!0}).notNull(),createdAt:Vo("created_at",{withTimezone:!0}).defaultNow()},e=>[Wr("idx_ext_auth_codes_expiry").on(e.expiresAt)]);import{pgTable as Xr,text as $r,timestamp as Yo,jsonb as Zr,uuid as Bt,index as Qo}from"drizzle-orm/pg-core";var _e=Xr("eval_conversations",{id:Bt("id").primaryKey().defaultRandom(),evalTargetId:Bt("eval_target_id").notNull().references(()=>n.id,{onDelete:"cascade"}),userId:Bt("user_id").notNull(),messages:Zr("messages").notNull().default([]),status:$r("status").notNull().default("active"),createdAt:Yo("created_at",{withTimezone:!0}).defaultNow(),updatedAt:Yo("updated_at",{withTimezone:!0}).defaultNow()},e=>[Qo("idx_eval_conversations_target").on(e.evalTargetId),Qo("idx_eval_conversations_user").on(e.userId)]);import{pgTable as es,text as k,timestamp as Wo,jsonb as ts,uuid as Ht}from"drizzle-orm/pg-core";var Xo=es("skill_submissions",{id:Ht("id").primaryKey().defaultRandom(),skillId:k("skill_id").notNull(),name:k("name").notNull(),description:k("description").notNull(),category:k("category").notNull(),tools:k("tools").array().notNull(),tags:k("tags").array().default([]),content:k("content").notNull(),status:k("status").notNull().default("pending"),submittedBy:Ht("submitted_by").notNull(),reviewedBy:Ht("reviewed_by"),reviewNote:k("review_note"),metadata:ts("metadata"),createdAt:Wo("created_at",{withTimezone:!0}).defaultNow(),updatedAt:Wo("updated_at",{withTimezone:!0}).defaultNow()});import{pgTable as os,text as Ee,timestamp as $o,jsonb as ns,uuid as rs,uniqueIndex as ss,index as Zo}from"drizzle-orm/pg-core";var en=os("harness_releases",{id:rs("id").primaryKey().defaultRandom(),harness:Ee("harness").notNull(),version:Ee("version").notNull(),publishedAt:$o("published_at",{withTimezone:!0}).notNull(),title:Ee("title"),body:Ee("body"),categories:ns("categories").default({}),url:Ee("url"),createdAt:$o("created_at",{withTimezone:!0}).defaultNow()},e=>[ss("idx_harness_releases_unique").on(e.harness,e.version),Zo("idx_harness_releases_harness").on(e.harness),Zo("idx_harness_releases_published").on(e.publishedAt)]);import{pgTable as is,text as me,timestamp as tn,jsonb as as,uuid as on,index as nn,uniqueIndex as ds}from"drizzle-orm/pg-core";var Ft=is("notifications",{id:on("id").primaryKey().defaultRandom(),userId:on("user_id").notNull(),type:me("type").notNull(),title:me("title").notNull(),body:me("body"),url:me("url"),sourceTable:me("source_table"),sourceId:me("source_id"),metadata:as("metadata").notNull().default({}),readAt:tn("read_at",{withTimezone:!0}),createdAt:tn("created_at",{withTimezone:!0}).notNull().defaultNow()},e=>[nn("idx_notifications_user_created").on(e.userId,e.createdAt),nn("idx_notifications_user_unread").on(e.userId),ds("idx_notifications_source_dedup").on(e.userId,e.sourceTable,e.sourceId)]);import{pgTable as us,text as je,timestamp as Se,jsonb as Gt,uuid as Vt,index as at,integer as ls}from"drizzle-orm/pg-core";var fe=us("launch_jobs",{id:Vt("id").primaryKey().defaultRandom(),userId:Vt("user_id").notNull(),tool:je("tool").notNull(),status:je("status").notNull().default("pending"),config:Gt("config").notNull().default({}),result:Gt("result"),error:je("error"),attempts:ls("attempts").notNull().default(0),taskKind:je("task_kind"),payload:Gt("payload"),claimedBy:je("claimed_by"),claimedAt:Se("claimed_at",{withTimezone:!0}),leaseExpiresAt:Se("lease_expires_at",{withTimezone:!0}),createdAt:Se("created_at",{withTimezone:!0}).defaultNow(),updatedAt:Se("updated_at",{withTimezone:!0}).defaultNow(),completedAt:Se("completed_at",{withTimezone:!0}),runId:Vt("run_id").references(()=>m.id,{onDelete:"set null"})},e=>[at("idx_launch_jobs_user").on(e.userId),at("idx_launch_jobs_status").on(e.status),at("idx_launch_jobs_pending").on(e.userId,e.status),at("idx_launch_jobs_run").on(e.runId)]);import{pgTable as rn,uuid as R,text as Pe,real as cs,timestamp as dt,boolean as ps,uniqueIndex as _s,index as Ke}from"drizzle-orm/pg-core";var Jt=rn("instruction_suggestions",{id:R("id").primaryKey().defaultRandom(),userId:R("user_id").notNull().references(()=>s.id,{onDelete:"cascade"}),instructionId:R("instruction_id").notNull().references(()=>o.id,{onDelete:"cascade"}),projectPath:Pe("project_path").notNull(),projectId:R("project_id").references(()=>l.id,{onDelete:"set null"}),score:cs("score").notNull(),reason:Pe("reason").notNull(),generatedAt:dt("generated_at",{withTimezone:!0}).notNull().defaultNow(),isStale:ps("is_stale").notNull().default(!1),dismissedAt:dt("dismissed_at",{withTimezone:!0}),acceptedAt:dt("accepted_at",{withTimezone:!0}),promotedToInstructionId:R("promoted_to_instruction_id").references(()=>o.id,{onDelete:"set null"})},e=>[_s("idx_instruction_suggestions_user_project_instruction").on(e.userId,e.projectPath,e.instructionId),Ke("idx_instruction_suggestions_user_project").on(e.userId,e.projectPath),Ke("idx_instruction_suggestions_user_proj_id").on(e.userId,e.projectId),Ke("idx_instruction_suggestions_generated_at").on(e.generatedAt)]),sn=rn("instruction_suggestion_events",{id:R("id").primaryKey().defaultRandom(),suggestionId:R("suggestion_id").notNull().references(()=>Jt.id,{onDelete:"cascade"}),userId:R("user_id").notNull().references(()=>s.id,{onDelete:"cascade"}),eventType:Pe("event_type").notNull(),tool:Pe("tool"),sessionId:R("session_id"),projectPath:Pe("project_path").notNull(),createdAt:dt("created_at",{withTimezone:!0}).notNull().defaultNow()},e=>[Ke("idx_instruction_suggestion_events_suggestion_id").on(e.suggestionId),Ke("idx_instruction_suggestion_events_user_id").on(e.userId)]);import{pgTable as ms,text as Yt,integer as fs,numeric as Oe,timestamp as Qt,index as xs,primaryKey as gs}from"drizzle-orm/pg-core";var an=ms("model_pricing",{provider:Yt("provider").notNull(),modelId:Yt("model_id").notNull(),inputPerM:Oe("input_per_m").notNull(),outputPerM:Oe("output_per_m").notNull(),cacheReadPerM:Oe("cache_read_per_m").notNull(),cacheWrite5mPerM:Oe("cache_write_5m_per_m").notNull(),cacheWrite1hPerM:Oe("cache_write_1h_per_m").notNull(),contextWindow:fs("context_window"),effectiveFrom:Qt("effective_from",{withTimezone:!0}).notNull(),effectiveUntil:Qt("effective_until",{withTimezone:!0}),source:Yt("source").notNull(),verifiedAt:Qt("verified_at",{withTimezone:!0})},e=>[gs({columns:[e.provider,e.modelId,e.effectiveFrom]}),xs("idx_model_pricing_active").on(e.provider,e.modelId,e.effectiveFrom.desc())]);import{pgTable as Ns,text as Y,numeric as dn,timestamp as un,uuid as ln,jsonb as vs,index as cn}from"drizzle-orm/pg-core";var pn=Ns("limit_observations",{id:ln("id").primaryKey().defaultRandom(),observedAt:un("observed_at",{withTimezone:!0}).notNull().defaultNow(),provider:Y("provider").notNull(),plan:Y("plan").notNull(),limitType:Y("limit_type").notNull(),value:dn("value").notNull(),unit:Y("unit").notNull(),comparator:Y("comparator").notNull().default("="),resetsAt:un("resets_at",{withTimezone:!0}),sourceType:Y("source_type").notNull(),sourceUrl:Y("source_url"),sourceEvidence:vs("source_evidence"),confidence:dn("confidence").notNull(),userId:ln("user_id")},e=>[cn("idx_limit_obs_lookup").on(e.provider,e.plan,e.limitType,e.observedAt.desc()),cn("idx_limit_obs_user").on(e.userId,e.observedAt.desc())]);import{pgTable as hs,text as ut,timestamp as ys,uuid as Is,jsonb as Ts,boolean as ws,uniqueIndex as As}from"drizzle-orm/pg-core";var _n=hs("provider_docs_snapshots",{id:Is("id").primaryKey().defaultRandom(),fetchedAt:ys("fetched_at",{withTimezone:!0}).notNull().defaultNow(),provider:ut("provider").notNull(),docUrl:ut("doc_url").notNull(),contentHash:ut("content_hash").notNull(),content:ut("content").notNull(),parseSuccess:ws("parse_success").notNull(),parseErrors:Ts("parse_errors")},e=>[As("idx_docs_dedup").on(e.provider,e.docUrl,e.contentHash)]);import{pgTable as bs,text as lt,numeric as mn,timestamp as fn,uuid as zs,primaryKey as Ds,index as ks}from"drizzle-orm/pg-core";var xn=bs("plan_limits_active",{provider:lt("provider").notNull(),plan:lt("plan").notNull(),limitType:lt("limit_type").notNull(),value:mn("value").notNull(),unit:lt("unit").notNull(),effectiveFrom:fn("effective_from",{withTimezone:!0}).notNull(),effectiveUntil:fn("effective_until",{withTimezone:!0}),confidence:mn("confidence").notNull(),sourceObservationIds:zs("source_observation_ids").array().notNull()},e=>[Ds({columns:[e.provider,e.plan,e.limitType,e.effectiveFrom]}),ks("idx_plan_limits_lookup").on(e.provider,e.plan,e.limitType,e.effectiveFrom.desc())]);import{pgTable as Rs,text as Wt,timestamp as Es,uuid as gn,jsonb as js,index as Ss}from"drizzle-orm/pg-core";var Nn=Rs("alert_dispatches",{id:gn("id").primaryKey().defaultRandom(),userId:gn("user_id").notNull(),alertKey:Wt("alert_key").notNull(),severity:Wt("severity").notNull(),lastDispatchedAt:Es("last_dispatched_at",{withTimezone:!0}).notNull().defaultNow(),lastState:js("last_state").notNull(),channel:Wt("channel").notNull()},e=>[Ss("idx_alert_user_key").on(e.userId,e.alertKey,e.lastDispatchedAt.desc())]);import{drizzle as Tn}from"drizzle-orm/postgres-js";import wn from"postgres";var ct={};Bn(ct,{agentJobs:()=>Ho,agentRuns:()=>m,agentRunsRelations:()=>Js,alertDispatches:()=>Nn,announcementDeliveries:()=>xo,announcements:()=>fo,apiKeys:()=>pe,apiKeysRelations:()=>Ks,benchmarks:()=>ae,benchmarksRelations:()=>ni,cliErrorEvents:()=>So,cliSetupEvents:()=>Eo,contentBlobs:()=>Mo,contextSnapshots:()=>M,contextSnapshotsRelations:()=>di,evalConversations:()=>_e,evalConversationsRelations:()=>ai,evalJobs:()=>ce,evalJobsRelations:()=>ii,evalRuns:()=>C,evalRunsRelations:()=>oi,evalTargets:()=>n,evalTargetsRelations:()=>ei,evals:()=>D,evalsRelations:()=>ti,extensionAuthCodes:()=>Jo,harnessReleases:()=>en,insightsJobs:()=>Fo,instructionEvents:()=>oe,instructionEventsRelations:()=>Bs,instructionSuggestionEvents:()=>sn,instructionSuggestions:()=>Jt,instructionUsageEvents:()=>se,instructionUsageEventsRelations:()=>Zs,instructionVersions:()=>$,instructionVersionsRelations:()=>Hs,instructions:()=>o,instructionsRelations:()=>Us,launchJobs:()=>fe,launchJobsRelations:()=>Ys,limitObservations:()=>pn,modelPricing:()=>an,notificationPreferences:()=>go,notifications:()=>Ft,optimizationRuns:()=>le,optimizationRunsRelations:()=>si,orgInvitations:()=>A,orgInvitationsRelations:()=>qs,organizations:()=>a,organizationsRelations:()=>Os,packInstructions:()=>O,packInstructionsRelations:()=>$s,packs:()=>v,packsRelations:()=>Xs,planLimitsActive:()=>xn,profiles:()=>s,profilesRelations:()=>Ps,projectCheckouts:()=>po,projectInstructions:()=>j,projectInstructionsRelations:()=>Gs,projects:()=>l,projectsRelations:()=>Fs,providerDocsSnapshots:()=>_n,sessionEvents:()=>ee,sessionEventsRelations:()=>Qs,sessionInstructions:()=>S,sessionInstructionsRelations:()=>Ws,sessionSendJobs:()=>Io,sessionTerminalTargets:()=>Je,sessions:()=>u,sessionsRelations:()=>Vs,skillSubmissions:()=>Xo,teams:()=>x,teamsRelations:()=>Cs,triggerEvals:()=>ue,triggerEvalsRelations:()=>ri,userOrganizations:()=>W,userOrganizationsRelations:()=>Ms,userTeams:()=>X,userTeamsRelations:()=>Ls,workerConnections:()=>Do});import{relations as i}from"drizzle-orm";var Ps=i(s,({many:e})=>({sessions:e(u),contextSnapshots:e(M),apiKeys:e(pe)})),Ks=i(pe,({one:e})=>({profile:e(s,{fields:[pe.userId],references:[s.id]})})),Os=i(a,({many:e})=>({teams:e(x),userOrganizations:e(W),projects:e(l),invitations:e(A)})),Cs=i(x,({one:e,many:t})=>({organization:e(a,{fields:[x.orgId],references:[a.id]}),userTeams:t(X),invitations:t(A)})),qs=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]})})),Ms=i(W,({one:e})=>({organization:e(a,{fields:[W.orgId],references:[a.id]})})),Ls=i(X,({one:e})=>({team:e(x,{fields:[X.teamId],references:[x.id]})})),Us=i(o,({one:e,many:t})=>({versions:t($),projectInstructions:t(j),events:t(oe),usageEvents:t(se),sessionInstructions:t(S),packInstructions:t(O),forkedFrom:e(o,{fields:[o.forkedFromId],references:[o.id]})})),Bs=i(oe,({one:e})=>({instruction:e(o,{fields:[oe.instructionId],references:[o.id]})})),Hs=i($,({one:e})=>({instruction:e(o,{fields:[$.instructionId],references:[o.id]})})),Fs=i(l,({one:e,many:t})=>({organization:e(a,{fields:[l.orgId],references:[a.id]}),projectInstructions:t(j),sessions:t(u)})),Gs=i(j,({one:e})=>({project:e(l,{fields:[j.projectId],references:[l.id]}),instruction:e(o,{fields:[j.instructionId],references:[o.id]})})),Vs=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(ee),sessionInstructions:t(S),contextSnapshots:t(M)})),Js=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(fe)})),Ys=i(fe,({one:e})=>({run:e(m,{fields:[fe.runId],references:[m.id]})})),Qs=i(ee,({one:e})=>({session:e(u,{fields:[ee.sessionId],references:[u.id]})})),Ws=i(S,({one:e})=>({session:e(u,{fields:[S.sessionId],references:[u.id]}),instruction:e(o,{fields:[S.instructionId],references:[o.id]})})),Xs=i(v,({one:e,many:t})=>({packInstructions:t(O),forkedFrom:e(v,{fields:[v.forkedFromId],references:[v.id]})})),$s=i(O,({one:e})=>({pack:e(v,{fields:[O.packId],references:[v.id]}),instruction:e(o,{fields:[O.instructionId],references:[o.id]})})),Zs=i(se,({one:e})=>({instruction:e(o,{fields:[se.instructionId],references:[o.id]})})),ei=i(n,({one:e,many:t})=>({parent:e(n,{fields:[n.parentId],references:[n.id]}),evals:t(D),evalRuns:t(C),benchmarks:t(ae),triggerEvals:t(ue),optimizationRuns:t(le),evalJobs:t(ce),evalConversations:t(_e)})),ti=i(D,({one:e,many:t})=>({evalTarget:e(n,{fields:[D.evalTargetId],references:[n.id]}),runs:t(C)})),oi=i(C,({one:e})=>({eval:e(D,{fields:[C.evalId],references:[D.id]}),evalTarget:e(n,{fields:[C.evalTargetId],references:[n.id]})})),ni=i(ae,({one:e})=>({evalTarget:e(n,{fields:[ae.evalTargetId],references:[n.id]})})),ri=i(ue,({one:e})=>({evalTarget:e(n,{fields:[ue.evalTargetId],references:[n.id]})})),si=i(le,({one:e})=>({evalTarget:e(n,{fields:[le.evalTargetId],references:[n.id]})})),ii=i(ce,({one:e})=>({evalTarget:e(n,{fields:[ce.evalTargetId],references:[n.id]})})),ai=i(_e,({one:e})=>({evalTarget:e(n,{fields:[_e.evalTargetId],references:[n.id]})})),di=i(M,({one:e})=>({session:e(u,{fields:[M.sessionId],references:[u.id]}),profile:e(s,{fields:[M.userId],references:[s.id]})}));var Ce=0,vn=0,qe=0,hn=0;var ui=0;function Xt(){Ce++,Ce>vn&&(vn=Ce)}p(Xt,"trackDbOpStart");function $t(){Ce>0&&Ce--}p($t,"trackDbOpEnd");function Zt(){qe++,qe>hn&&(hn=qe)}p(Zt,"trackHeavyDbOpStart");function eo(){qe>0&&qe--}p(eo,"trackHeavyDbOpEnd");function yn(){ui++}p(yn,"recordQueryDeadline");var _t,ft,to=!1,pt;var In,xt,mt;function An(e){let t=process.env[e];if(!t)throw new Error(`Missing required env var: ${e}`);return t}p(An,"getEnv");function bn(){if(to)throw new Error("getDb() called after closeDb(): the connection pool is closed for shutdown. Stop issuing queries (timers/requests) before draining the pool.");if(!_t){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;ft=wn(An("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}:{}}}),_t=Tn(ft,{schema:ct})}return _t}p(bn,"getDb");function zn(){if(to)throw new Error("getHeavyDb() called after closeDb(): the connection pool is closed for shutdown. Stop issuing queries (timers/requests) before draining the pool.");if(!mt){let e=(process.env.PG_APPLICATION_NAME||"rulemetric")+":heavy",t=Number(process.env.PG_HEAVY_POOL_MAX)||2;xt=wn(An("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}}),mt=Tn(xt,{schema:ct})}return mt}p(zn,"getHeavyDb");async function li(){if(pt)return pt;to=!0;let e=ft,t=In,r=xt;return ft=void 0,_t=void 0,In=void 0,xt=void 0,mt=void 0,pt=Promise.allSettled([e?e.end({timeout:5}):Promise.resolve(),t?t.end({timeout:5}):Promise.resolve(),r?r.end({timeout:5}):Promise.resolve()]).then(()=>{}),pt}p(li,"closeDb");var ci=new Set(["CONNECT_TIMEOUT","ETIMEDOUT","ENOTFOUND","ECONNREFUSED","EAI_AGAIN"]);function Dn(e){let t=e,r=t?.code??t?.cause?.code??t?.errno;return r!==void 0&&ci.has(r)}p(Dn,"isRetryableConnectError");var pi=new Set(["CONNECTION_CLOSED","ECONNRESET","EPIPE"]);function kn(e){let t=e,r=t?.code??t?.cause?.code??t?.errno;return r!==void 0&&pi.has(r)}p(kn,"isRetryableResetError");async function Rn(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 xe=Dn(g)||t.retryResets===!0&&kn(g);if(_===r-1||!xe)throw g;await new Promise(L=>setTimeout(L,d*2**_))}throw c}p(Rn,"withDbRetry");var gt=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 En(){let e=Number(process.env.PG_QUERY_DEADLINE_MS);return Number.isFinite(e)&&e>=0?e:2e4}p(En,"queryDeadlineMs");function _i(e,t){let r,d=new Promise((c,_)=>{r=setTimeout(()=>{yn(),_(new gt(t))},t);let g=r;typeof g.unref=="function"&&g.unref()});return Promise.race([e,d]).finally(()=>clearTimeout(r))}p(_i,"raceWithDeadline");var jn=new Set(["select","selectDistinct","selectDistinctOn","insert","update","delete","execute","with","$count","refreshMaterializedView"]),Sn=new Set(["select","selectDistinct","selectDistinctOn","$count"]);function oo(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:(On,Cn)=>{let qn=d?Zt:Xt,Mn=d?eo:$t;qn();let no=Rn(()=>new Promise((Ln,Un)=>L.call(c,Ln,Un)),{retryResets:t});return(r>0?_i(no,r):no).finally(Mn).then(On,Cn)}}let xe=Reflect.get(c,_,g);return typeof xe=="function"?(...L)=>oo(xe.apply(c,L),t,r,d):xe}})}p(oo,"wrapBuilder");function Pn(e,t=!1){let r=t?Zt:Xt,d=t?eo:$t;r();try{return Promise.resolve(e()).finally(d)}catch(c){throw d(),c}}p(Pn,"gaugeTransaction");var Kn=new Proxy({},{get(e,t){let r=bn(),d=r[t];if(typeof t=="string"&&jn.has(t)&&typeof d=="function"){let c=Sn.has(t),_=En();return(...g)=>oo(d.apply(r,g),c,_)}return t==="transaction"&&typeof d=="function"?(...c)=>Pn(()=>d.apply(r,c)):d}}),mi=new Proxy({},{get(e,t){let r=zn(),d=r[t];if(typeof t=="string"&&jn.has(t)&&typeof d=="function"){let c=Sn.has(t);return(..._)=>oo(d.apply(r,_),c,0,!0)}return t==="transaction"&&typeof d=="function"?(...c)=>Pn(()=>d.apply(r,c),!0):d}});export{s as a,m as b,u as c,ee as d,fo as e,xo as f,go as g,bn as h,li as i};
@@ -0,0 +1,24 @@
1
+ import{a as $}from"./chunk-DSO2U4Y6.js";import{a as y}from"./chunk-CADKBP3D.js";import{a as w}from"./chunk-MGHFDHHM.js";import{e as h,f}from"./chunk-H2ORWIEY.js";import{a as v}from"./chunk-ZLLER3HP.js";async function I(t,r,u){let{conversationId:a,messageId:d,messageContent:c}=t,n=await h(`/api/eval-targets/${r}`),o=await h(`/api/eval-targets/${r}/evals`),e=await h(`/api/eval-conversations/${a}/messages`),s=e.findIndex(l=>l.id===d);if(s>=0&&e.slice(s+1).some(p=>p.role==="assistant"&&(p.type==="results"||p.type==="proposal"||p.type==="generated"||p.type==="text"))){u(`Message ${d} already processed \u2014 skipping (idempotency guard)`);return}let i=v(async(l,p,m)=>{await f(`/api/eval-conversations/${a}/messages/assistant`,{content:l,type:p,data:m})},"postMessage"),g=await C(n,o,e,c,u);u(`Action: ${g.action}`);try{switch(g.action){case"run_evals":await x(n,o,a,i,u);break;case"generate_cases":await _(n,r,a,i,u);break;case"analyze_results":case"propose_changes":await k(n,o,e,c,a,i,u);break;case"respond":await i(g.response,"text");break}}catch(l){let p=l instanceof Error?l.message:String(l);throw await i(`Something went wrong: ${p}`,"text").catch(()=>{}),l}}v(I,"processConversationJob");async function C(t,r,u,a,d){let c=u.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: ${r.length} defined${r.length>0?` (${r.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
+ ${a}
14
+
15
+ ## Available Actions
16
+ - run_evals: Run all eval cases against the current version (target content injected; no baseline arm). 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 (${r.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": {}}`,o=await w({prompt:n,timeout:3e4});try{let e=o.output.trim(),s=e.match(/\{[\s\S]*\}/);return s&&(e=s[0]),JSON.parse(e)}catch{d("Failed to parse action decision, defaulting to respond");let e=a.toLowerCase();return e.includes("run")||e.includes("test")||e.includes("eval")?{action:"run_evals",response:"Running evals now..."}:e.includes("generate")||e.includes("create")||r.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(C,"decideAction");async function x(t,r,u,a,d){if(r.length===0){await a("No eval cases exist yet. Would you like me to generate some from the instruction content?","text");return}await a(`Running ${r.length} evals against "${t.name}" v${t.version}...`,"status");let c=[];for(let e of r){d(`Running: ${e.name} (with_target)`);let s=await w({prompt:e.prompt,targetContent:t.content,timeout:12e4}),i=!1,g="",l={};!s.error&&e.expectations.length>0&&(l=await y({prompt:e.prompt,output:s.output,expectations:e.expectations,timeout:12e4}),i=l?.summary?.pass_rate>=1,g=l?.expectations?.map(m=>`${m.passed?"PASS":"FAIL"}: ${m.text} \u2014 ${m.evidence}`).join(`
24
+ `)??"");try{await f("/api/eval-runs",{evalId:e.id,evalTargetId:t.id,evalTargetVersion:t.version,configuration:"with_target",status:s.error?"failed":"completed",outputs:s.error?{error:s.error}:{transcript:s.output},timing:{duration_ms:s.durationMs,total_tokens:s.totalTokens},grading:l})}catch(p){d(`eval-run persist failed (non-fatal): ${p instanceof Error?p.message:String(p)}`)}c.push({evalName:e.name,passed:i,output:s.error??s.output.slice(0,2e3),expectations:e.expectations,evidence:g,configuration:"with_target"})}let n=c.filter(e=>e.passed).length,o=c.length;await a(`${n} of ${o} evals passed (${Math.round(n/o*100)}%)`,"results",{summary:{passed:n,failed:o-n,total:o,passRate:n/o},results:c.map(e=>({evalName:e.evalName,passed:e.passed,output:e.output,expectations:e.expectations,evidence:e.evidence}))})}v(x,"handleRunEvals");async function _(t,r,u,a,d){await a("Generating eval cases from instruction content...","status"),d("Calling eval-from-context endpoint");let c=await f("/api/eval-from-context",{evalTargetId:t.id,name:t.name,type:t.type,content:t.content,config:{skipBaseline:!1,skipGrading:!1}}),n=await h(`/api/eval-targets/${t.id}/evals`);await a(c.evalCasesCreated>0?`Generated ${c.evalCasesCreated} eval cases. Review them below:`:`This target already has ${n.length} eval case${n.length===1?"":"s"}:`,"generated",{cases:n.map(o=>({id:o.id,name:o.name,prompt:o.prompt,expectations:o.expectations}))})}v(_,"handleGenerateCases");async function k(t,r,u,a,d,c,n){await c("Analyzing results and preparing improvements...","status");let e=[...u].reverse().find(i=>i.type==="results")?.data?.results?.map(i=>({evalName:i.evalName,prompt:"",expectations:i.expectations??[],grading:{summary:{pass_rate:i.passed?1:0},expectations:i.expectations?.map(g=>({text:g,passed:i.passed,evidence:i.evidence??""}))}}))??[];n(`Analyzing ${e.length} eval results with user feedback`);let s=await $({content:t.content,evalResults:e,model:void 0,timeout:12e4,userFeedback:a});await c(s.overallAssessment,"proposal",{suggestions:s.suggestions,proposedContent:s.proposedContent,fromVersion:t.version})}v(k,"handleAnalyzeAndPropose");export{I 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,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,3 @@
1
+ import{A as u,D as d}from"./chunk-2JRDG4LJ.js";import{a as s}from"./chunk-ZLLER3HP.js";import{existsSync as l,readFileSync as p,unlinkSync as y,writeFileSync as a}from"node:fs";import{homedir as h}from"node:os";import{join as S}from"node:path";function f(){return{vscode:u(),cursor:d(),marker:S(h(),".config","rulemetric","editor-proxy-unpinned.json")}}s(f,"defaultEditorPinPaths");function m(r,t){return r===`http://localhost:${t}`||r===`http://127.0.0.1:${t}`}s(m,"isOurProxyValue");function c(r){if(!l(r))return null;try{return JSON.parse(p(r,"utf-8"))}catch{return null}}s(c,"readSettings");function v(r,t=f()){let o=[];for(let e of["vscode","cursor"]){let n=t[e],i=c(n);if(!(!i||!m(i["http.proxy"],r))){delete i["http.proxy"],i["http.proxyStrictSSL"]===!1&&delete i["http.proxyStrictSSL"];try{a(n,JSON.stringify(i,null,2)+`
2
+ `),o.push(e)}catch{}}}if(o.length>0){let e=c(t.marker),n=[...new Set([...e?.editors??[],...o])];try{a(t.marker,JSON.stringify({editors:n,gatewayPort:r,unpinnedAt:new Date().toISOString()},null,2)+`
3
+ `)}catch{}}return o}s(v,"unpinEditorProxies");function A(r,t=f()){let o=c(t.marker);if(!o||!Array.isArray(o.editors))return[];let e=[];for(let n of o.editors)if(!(n!=="vscode"&&n!=="cursor"))try{r(n),e.push(n)}catch{}try{y(t.marker)}catch{}return e}s(A,"repinEditorProxies");export{f as a,v as b,A as c};
@@ -0,0 +1 @@
1
+ import{c as m,d as p}from"./chunk-ZL4MZMUK.js";import{a as C}from"./chunk-N7TGRFVZ.js";import{e as c,h as f}from"./chunk-H4SV7FN4.js";import{a as r}from"./chunk-ZLLER3HP.js";import*as a from"node:fs/promises";import*as g from"node:path";import{eq as b}from"drizzle-orm";async function v(e){let n=e;for(let t=0;t<50;t++){try{return await a.stat(g.join(n,"pnpm-workspace.yaml")),n}catch{}let i=g.dirname(n);if(i===n)return null;n=i}return null}r(v,"findRepoRoot");async function k(e){if(e)try{return await a.readFile(e,"utf-8")}catch{return null}let n=await v(process.cwd())??process.cwd(),t=g.join(n,"CHANGELOG.md");try{return await a.readFile(t,"utf-8")}catch{return null}}r(k,"readChangelog");var _="https://rulemetric.com";function D(e){let n=e.date??new Date().toISOString().slice(0,10),t=C({version:e.version,date:n,sections:e.sections,unsubscribeUrl:"{{unsubscribe_url}}",recipientName:"{{recipient_name}}",productUrl:_});return{version:e.version,releaseDate:n,subject:t.subject,htmlBody:t.html,textBody:t.text,sections:e.sections}}r(D,"renderRow");async function R(e={}){let n=e.db??f(),t=e.logger??{info:r(s=>console.log(s),"info"),warn:r(s=>console.warn(s),"warn")},i=await k(e.changelogPath);if(i===null)return t.info("[cron_check_changelog] CHANGELOG.md not found; nothing to do"),{createdCount:0,skippedCount:0};let y=m(i),h=p(y);if(h.length===0)return t.info("[cron_check_changelog] No announceable entries; nothing to do"),{createdCount:0,skippedCount:0};let d=0,l=0;for(let s of h){if((await n.select({id:c.id}).from(c).where(b(c.version,s.version)).limit(1)).length>0){l++;continue}let o=D(s);try{await n.insert(c).values({version:o.version,releaseDate:o.releaseDate,subject:o.subject,htmlBody:o.htmlBody,textBody:o.textBody,sections:o.sections,status:"draft"}),d++,t.info(`[cron_check_changelog] Created draft announcement for ${o.version}`)}catch(u){let w=u instanceof Error?u.message:String(u);if(/duplicate key|unique/i.test(w)){l++;continue}throw u}}return t.info(`[cron_check_changelog] Done: created ${d}, skipped ${l}`),{createdCount:d,skippedCount:l}}r(R,"processChangelog");export{R as a};
@@ -0,0 +1,9 @@
1
+ import{d as b,f as y}from"./chunk-RTWRHIKY.js";import{e as M,f as w}from"./chunk-H2ORWIEY.js";import{a as u}from"./chunk-ZLLER3HP.js";var $={anthropic:["https://platform.claude.com/docs/en/about-claude/pricing.md"],openai:["https://platform.openai.com/docs/pricing"]},R=.7,v=16e3,x=["You extract LLM API pricing from a provider pricing page.","You will be given the page text in <data> tags and, in this system prompt,","a list of model ids to find. For EACH requested model id, return its","published USD price per 1,000,000 tokens.","","Rules:","- Only report a model if you can find its rate ON THE PAGE. If it is not on"," the page, set found=false and omit the numbers \u2014 never guess from memory.","- inputPerM and outputPerM are the standard (non-batch, non-priority) rates.","- cacheReadPerM: the cached/discounted-input rate if published, else omit.","- For Anthropic models ONLY, if cache-write rates are not explicitly listed,"," compute them as cacheWrite5mPerM = inputPerM * 1.25 and"," cacheWrite1hPerM = inputPerM * 2.0. For all other providers, omit them.","- confidence is 0..1: how sure you are the numbers are correct for THIS id.","- contextWindow in tokens if stated, else omit.","","Respond with ONLY a JSON object of the form:",'{"rates":[{"modelId":"...","found":true,"confidence":0.9,"inputPerM":5,"outputPerM":25,"cacheReadPerM":0.5,"contextWindow":1000000}]}'].join(`
2
+ `);async function C(f){try{let n=await fetch(f,{headers:{accept:"text/plain, text/markdown, text/html"}});if(!n.ok)return null;let i=await n.text();return i.length>v?i.slice(0,v):i}catch{return null}}u(C,"fetchPage");var L=u(async(f,n)=>{let i=await M("/api/pricing/coverage"),I=[...i.unpriced,...i.stale],m=new Map;for(let r of I)m.set(`${r.provider}::${r.modelId}`,r);let a=[...m.values()];if(a.length===0)return n.logger.info("[cron-refresh-pricing] coverage clean \u2014 nothing unpriced or stale"),{status:"clean",checked:i.unpriced.length+i.stale.length};if(b()==="none")return n.logger.warn(`[cron-refresh-pricing] ${a.length} model(s) need pricing but no LLM backend (install the claude CLI or set ANTHROPIC_API_KEY) \u2014 skipping`),{status:"no-llm",pending:a.length};let d=new Map;for(let r of a){let o=d.get(r.provider)??[];o.push(r.modelId),d.set(r.provider,o)}let t={written:0,unchanged:0,flagged:0,rejected:0,skipped:0},c=[];for(let[r,o]of d){let h=$[r];if(!h){n.logger.warn(`[cron-refresh-pricing] no pricing source configured for provider '${r}' (${o.length} model(s)) \u2014 skipping`),t.skipped+=o.length;continue}let p="",l="";for(let e of h){let s=await C(e);s&&(p+=`
3
+
4
+ === ${e} ===
5
+ ${s}`,l||(l=e))}if(!p.trim()){n.logger.warn(`[cron-refresh-pricing] could not fetch pricing page(s) for '${r}' \u2014 skipping ${o.length} model(s)`),t.skipped+=o.length;continue}let k=`${x}
6
+
7
+ Model ids to find:
8
+ ${o.map(e=>`- ${e}`).join(`
9
+ `)}`,g=(await y(k,p,2048))?.rates??[];if(!Array.isArray(g)||g.length===0){n.logger.warn(`[cron-refresh-pricing] LLM returned no rates for '${r}' \u2014 skipping`),t.skipped+=o.length;continue}for(let e of g){if(!e.found||e.confidence<R){t.skipped+=1;continue}try{let s=await w("/api/pricing/rates",{provider:r,modelId:e.modelId,inputPerM:e.inputPerM,outputPerM:e.outputPerM,cacheReadPerM:e.cacheReadPerM,cacheWrite5mPerM:e.cacheWrite5mPerM,cacheWrite1hPerM:e.cacheWrite1hPerM,contextWindow:e.contextWindow??null,sourceUrl:l}),P=s.status;P in t&&(t[P]+=1),s.status==="flagged"&&c.push({modelId:e.modelId,reason:s.reason??""})}catch(s){t.rejected+=1,n.logger.warn(`[cron-refresh-pricing] POST rate failed for ${e.modelId}: ${String(s)}`)}}}return n.logger.info(`[cron-refresh-pricing] done \u2014 written=${t.written} unchanged=${t.unchanged} flagged=${t.flagged} rejected=${t.rejected} skipped=${t.skipped}`),c.length>0&&n.logger.warn(`[cron-refresh-pricing] ${c.length} rate(s) flagged for human review: ${c.map(r=>r.modelId).join(", ")}`),{status:"done",...t,flagged:c}},"cronRefreshPricing");export{L as a};
@@ -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,33 @@
1
+ import{a as u}from"./chunk-MGHFDHHM.js";import{a as l}from"./chunk-ZLLER3HP.js";var y='Warning: trigger "accuracy" is heuristic \u2014 the skill content is always injected during execution, so scores measure detectable influence on the output, not real description-gated triggering.',w=`You are determining whether an AI assistant's response shows evidence of using a specific skill/instruction.
2
+
3
+ You will receive:
4
+ 1. The skill name and description
5
+ 2. Key content from the skill (to know what it teaches)
6
+ 3. The user's query
7
+ 4. The AI's response
8
+
9
+ Determine if the response shows clear signs of the skill being used:
10
+ - Does the response follow patterns/approaches described in the skill?
11
+ - Does it use terminology or structures specific to the skill?
12
+ - Would the response be noticeably different without the skill?
13
+
14
+ Respond with ONLY a valid JSON object:
15
+
16
+ {
17
+ "triggered": true,
18
+ "confidence": 0.85,
19
+ "evidence": "The response follows the X pattern described in the skill..."
20
+ }`;async function v(t){let{query:r,shouldTrigger:e,skillName:m,skillDescription:T,skillContent:a,model:g,timeout:k=12e4}=t,s=await u({prompt:r,targetContent:a,timeout:k,model:g});if(s.error)return{query:r,shouldTrigger:e,didTrigger:!1,correct:!e,confidence:0,evidence:`Execution failed: ${s.error}`};let b=`## Skill
21
+ Name: ${m}
22
+ Description: ${T}
23
+
24
+ ## Key Skill Content (first 500 chars)
25
+ ${a.slice(0,500)}
26
+
27
+ ## User Query
28
+ ${r}
29
+
30
+ ## AI Response
31
+ ${s.output}
32
+
33
+ Did the AI's response show evidence of using this skill? Respond with ONLY valid JSON.`,d=await u({prompt:b,targetContent:w,timeout:6e4,model:g}),n=!1,h=0,o="";try{let i=d.output.trim(),p=i.match(/```(?:json)?\s*([\s\S]*?)```/);p&&(i=p[1].trim());let f=i.match(/\{[\s\S]*\}/);f&&(i=f[0]);let c=JSON.parse(i);n=c.triggered===!0,h=c.confidence??0,o=c.evidence??""}catch{o=`Detector returned unparseable output: ${d.output.slice(0,200)}`}return{query:r,shouldTrigger:e,didTrigger:n,correct:n===e,confidence:h,evidence:o}}l(v,"testTrigger");function D(t){return t.length===0?0:t.filter(e=>e.correct).length/t.length}l(D,"computeTriggerScore");export{y as a,v as b,D as c};
@@ -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{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,70 @@
1
+ import{a as n}from"./chunk-ZLLER3HP.js";var R="#0d9488",l="#1a1a1a",d="#666666",w="#f5f5f7",C="#ffffff",v="#e5e5e9",O=["Added","Changed","Fixed","Removed","Deprecated","Security"];function z(e){let t=["January","February","March","April","May","June","July","August","September","October","November","December"],[r,o,i]=e.split("-").map(p=>parseInt(p,10));return!r||!o||!i||o<1||o>12?e:`${t[o-1]} ${i}, ${r}`}n(z,"formatIsoDate");function s(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}n(s,"escapeHtml");function U(e){let t=[];for(let r of O){let o=e[r];o&&o.length>0&&t.push({name:r,items:o})}return t}n(U,"orderedSections");function k(e){let{version:t,date:r,sections:o,unsubscribeUrl:i,productUrl:p,recipientName:a}=e,f=z(r),y=`What's new in RuleMetric \u2014 ${f}`,$=a?`Hi ${a},`:"Hi there,",E=U(o),b=new Date().getUTCFullYear(),I=E.map(({name:h,items:m})=>{let g=m.map(S=>` <li style="margin:0 0 6px 0;font-size:15px;line-height:1.5;color:${l};">${s(S)}</li>`).join(`
2
+ `);return` <h3 style="margin:24px 0 8px 0;font-size:16px;line-height:1.3;font-weight:600;color:${l};">${h}</h3>
3
+ <ul style="margin:0 0 8px 0;padding-left:20px;">
4
+ ${g}
5
+ </ul>`}).join(`
6
+ `),T=`<!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:${C};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
+ ${I}
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 ${b}
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:h,items:m}of E){c.push(`${h}:`);for(let g of m)c.push(` - ${g}`);c.push("")}c.push("--","You're receiving this because you signed up for RuleMetric product updates.",`Unsubscribe: ${i}`,"",`RuleMetric \u2022 ${b}`);let N=c.join(`
66
+ `);return{subject:y,html:T,text:N}}n(k,"renderChangelogAnnouncement");import{randomBytes as L}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-${L(8).toString("hex")}`,provider:"noop"}}n(x,"sendNoopEmail");var u=null;async function P(){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}n(P,"getClient");var _=!1;function F(){let e=process.env.RESEND_FROM_EMAIL;if(e)return e;if(!_){_=!0;let t=process.env.NODE_ENV==="production"?"PRODUCTION":"dev";process.stderr.write(`[email:resend] ${t}: RESEND_FROM_EMAIL not set \u2014 sending from the shared sandbox sender onboarding@resend.dev, which Gmail spam-filters. Set RESEND_FROM_EMAIL to an address on a verified domain.
68
+ `)}return"onboarding@resend.dev"}n(F,"resolveFromEmail");async function M(e){let t=e.fromName??"RuleMetric",r=F(),o=`${t} <${r}>`,i=await P(),p=e.idempotencyKey?{idempotencyKey:e.idempotencyKey}:void 0,a=await i.emails.send({from:o,to:e.to,subject:e.subject,html:e.html,text:e.text,...e.headers?{headers:e.headers}:{}},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"}}n(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.")}n(A,"sendSmtpEmail");function K(){let e=process.env.RULEMETRIC_EMAIL_PROVIDER;return e==="resend"||e==="smtp"||e==="noop"?e:process.env.RESEND_API_KEY?"resend":"noop"}n(K,"selectEmailProvider");var Y=new Set(["test","example","invalid","localhost"]),j=/^example\.(com|net|org)$/;function B(e){let t=e.trim().toLowerCase(),r=t.lastIndexOf("@");if(r<0)return!1;let o=t.slice(r+1);if(!o)return!1;let i=o.slice(o.lastIndexOf(".")+1);return!!(Y.has(i)||j.test(o))}n(B,"isUndeliverableRecipient");var D=!1;async function se(e){let t=K();switch(D||(D=!0,process.stderr.write(`[email] active provider: ${t}
69
+ `)),t){case"resend":return B(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
70
+ `),x(e)):M(e);case"smtp":return A(e);case"noop":if(process.env.NODE_ENV==="production"&&process.env.RULEMETRIC_EMAIL_PROVIDER!=="noop")throw new Error("email provider unconfigured in production: RESEND_API_KEY is not set (set it, or force RULEMETRIC_EMAIL_PROVIDER=noop to intentionally disable email)");return x(e)}}n(se,"sendEmail");export{k as a,se as b};
@@ -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 i}from"./chunk-HS7X43XE.js";import{h as s}from"./chunk-H2ORWIEY.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{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 h,c as _}from"./chunk-ARNZQBMX.js";import{d as p,e as m,g as S,i as w}from"./chunk-NJ5UED3H.js";import{a as u,b as M}from"./chunk-ZLLER3HP.js";import{useState as B,useMemo as P}from"react";import{Box as g,Text as r,useInput as E}from"ink";import{jsx as o,jsxs as d}from"react/jsx-runtime";function D(n){let t=n.recommendations;if(!t)return[];let s=[];for(let e of t.suggestions?.features_to_try??[])e.example_code&&s.push({label:e.feature,description:e.why_for_you||e.one_liner,command:e.example_code});for(let e of t.suggestions?.usage_patterns??[])e.copyable_prompt&&s.push({label:e.title,description:e.suggestion,command:e.copyable_prompt});for(let e of t.on_the_horizon?.opportunities??[])e.copyable_prompt&&s.push({label:e.title,description:e.whats_possible,command:e.copyable_prompt});return s}u(D,"extractSuggestions");function R(n){let t=n.trim();return/^(claude|rulemetric|pnpm|npm|npx|git)\s/.test(t)?t:`claude -p '${t.replace(/'/g,"'\\''")}'`}u(R,"toCliCommand");function v(n){try{let{execSync:t}=M("node:child_process");return process.platform==="darwin"?t("pbcopy",{input:n,stdio:["pipe","ignore","ignore"]}):t("xclip -selection clipboard",{input:n,stdio:["pipe","ignore","ignore"]}),!0}catch{return!1}}u(v,"copyToClipboard");function q({api:n,width:t,focused:s,onSelect:e}){let[b,I]=B(0),[C,y]=B(null),a=P(()=>n?D(n):[],[n]),f=n?.recommendations?.at_a_glance;if(E((l,c)=>{if(!(!s||a.length===0)){if(c.upArrow)I(i=>Math.max(0,i-1));else if(c.downArrow)I(i=>Math.min(a.length-1,i+1));else if(c.return){let i=a[b];if(i){let x=R(i.command);v(x)&&(y(b),setTimeout(()=>y(null),2e3)),e?.(x)}}}}),!n)return o(h,{title:"Insights",color:p,width:t,children:o(r,{dimColor:!0,children:"API offline \u2014 no insights"})});if(!f&&a.length===0)return o(h,{title:"Insights",color:p,width:t,children:o(r,{dimColor:!0,children:"No recommendations yet. Ensure the worker is running: rulemetric evals agent"})});let T=Math.min(30,Math.max(...a.map(l=>l.label.length),10)),A=Math.max(10,t-T-12);return d(h,{title:s?"\u25B8 Insights & Suggestions":"Insights & Suggestions",color:s?p:m,width:t,children:[f&&Object.entries(f).length>0&&o(g,{flexDirection:"column",marginBottom:1,children:Object.entries(f).map(([l,c])=>d(g,{flexDirection:"column",children:[o(r,{color:m,bold:!0,children:l.replace(/_/g," ").toUpperCase()}),o(r,{wrap:"wrap",children:String(c).slice(0,200)})]},l))}),a.length>0&&d(g,{flexDirection:"column",children:[d(g,{marginBottom:0,children:[o(r,{color:p,bold:!0,children:"Suggestions"}),s&&o(r,{dimColor:!0,children:" \u2191\u2193 navigate \u23CE copy command"})]}),a.map((l,c)=>{let i=s&&c===b,x=c===C;return d(g,{children:[o(r,{color:i?p:m,children:i?"\u25B8 ":" "}),o(r,{color:i?p:w,bold:i,children:_(l.label,T)}),o(r,{color:m,children:" \u2502 "}),o(r,{color:i?void 0:m,wrap:"truncate-end",children:_(l.description,A)}),x&&o(r,{color:S,children:" \u2713 copied"})]},c)})]})]})}u(q,"InsightsPanel");export{q as a};
@@ -0,0 +1,7 @@
1
+ import{a as e}from"./chunk-ZLLER3HP.js";import*as i from"node:fs";import*as u from"node:path";import*as R from"node:os";function m(){return process.env.RULEMETRIC_CONFIG_DIR||u.join(R.homedir(),".config","rulemetric")}e(m,"getConfigDir");var l;function F(){if(l!==void 0)return l;try{let n=u.join(m(),"env");if(!i.existsSync(n))return l={};let s=i.readFileSync(n,"utf-8"),E=e(h=>s.match(new RegExp(`^${h}=(.+)$`,"m"))?.[1]?.trim(),"read");return l={apiKey:E("RULEMETRIC_API_KEY"),accessToken:E("RULEMETRIC_ACCESS_TOKEN"),apiUrl:E("RULEMETRIC_API_URL")},l}catch{return l={}}}e(F,"loadEnvFileAuth");function U(){l=void 0}e(U,"__resetEnvFileAuthCache");function S(n=m()){let s=u.join(n,"auth.json");function E(o){i.mkdirSync(n,{recursive:!0,mode:448}),i.writeFileSync(s,JSON.stringify(o,null,2),{encoding:"utf-8",mode:384})}e(E,"saveToken");function h(){try{let o=i.readFileSync(s,"utf-8"),t=JSON.parse(o);return t&&typeof t=="object"&&"accessToken"in t&&"expiresAt"in t&&"email"in t&&typeof t.accessToken=="string"&&typeof t.expiresAt=="string"?t:null}catch{return null}}e(h,"loadToken");function y(){try{i.unlinkSync(s)}catch{}}e(y,"clearToken");function _(){let o=h();if(!o)return!1;let t=new Date(o.expiresAt).getTime();return Number.isNaN(t)?!1:Date.now()<t}e(_,"isAuthenticated");function g(o=0){let t=h();if(!t?.refreshToken)return!1;let r=new Date(t.expiresAt).getTime();return Number.isNaN(r)?!0:Date.now()>=r-o}e(g,"isRefreshable");function k(o,t){i.mkdirSync(n,{recursive:!0,mode:448});let r=u.join(n,"env"),c="",p="";try{let d=i.readFileSync(r,"utf-8"),T=d.match(/^RULEMETRIC_API_KEY=(.+)$/m);T&&(c=T[1]);let A=d.match(/^RULEMETRIC_API_URL=(.+)$/m);A&&(p=A[1])}catch{}let f=[`RULEMETRIC_ACCESS_TOKEN=${o}`];c&&f.push(`RULEMETRIC_API_KEY=${c}`);let v=t??p;v&&f.push(`RULEMETRIC_API_URL=${v}`),i.writeFileSync(r,f.join(`
2
+ `)+`
3
+ `,{encoding:"utf-8",mode:384})}e(k,"saveEnvFile");function x(o,t){i.mkdirSync(n,{recursive:!0,mode:448});let r=u.join(n,"env"),c="",p="";try{let d=i.readFileSync(r,"utf-8"),T=d.match(/^RULEMETRIC_ACCESS_TOKEN=(.+)$/m);T&&(c=T[1]);let A=d.match(/^RULEMETRIC_API_URL=(.+)$/m);A&&(p=A[1])}catch{}let f=[`RULEMETRIC_API_KEY=${o}`];c&&f.push(`RULEMETRIC_ACCESS_TOKEN=${c}`);let v=t??p;v&&f.push(`RULEMETRIC_API_URL=${v}`),i.writeFileSync(r,f.join(`
4
+ `)+`
5
+ `,{encoding:"utf-8",mode:384})}e(x,"saveApiKeyToEnv");function I(){let o=u.join(n,"env");try{i.unlinkSync(o)}catch{}}e(I,"clearEnvFile");function C(){let o=u.join(n,"env");try{let t=i.readFileSync(o,"utf-8"),r=t.split(`
6
+ `).filter(c=>!c.startsWith("RULEMETRIC_API_KEY=")).join(`
7
+ `);r!==t&&i.writeFileSync(o,r,{encoding:"utf-8",mode:384})}catch{}}return e(C,"removeApiKeyFromEnvFile"),{saveToken:E,loadToken:h,clearToken:y,isAuthenticated:_,isRefreshable:g,saveEnvFile:k,saveApiKeyToEnv:x,clearEnvFile:I,removeApiKeyFromEnvFile:C,configDir:n,authFile:s}}e(S,"createAuthStore");function a(){return S()}e(a,"getStore");function L(n){a().saveToken(n)}e(L,"saveToken");function K(){return a().loadToken()}e(K,"loadToken");function M(){a().clearToken()}e(M,"clearToken");function P(){if(process.env.RULEMETRIC_API_KEY||a().isAuthenticated())return!0;let n=F();return!!(n.apiKey||n.accessToken)}e(P,"isAuthenticated");function N(n,s){a().saveEnvFile(n,s)}e(N,"saveEnvFile");function j(n,s){a().saveApiKeyToEnv(n,s)}e(j,"saveApiKey");function $(){a().clearEnvFile()}e($,"clearEnvFile");function w(){a().removeApiKeyFromEnvFile()}e(w,"removeApiKeyFromEnv");function O(){return m()}e(O,"getDefaultConfigDir");var b=m();export{F as a,U as b,S as c,L as d,K as e,M as f,P as g,N as h,j as i,$ as j,w as k,O as l,b as m};
@@ -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,4 @@
1
+ import{a as c,c as d}from"./chunk-IZTIYR5Q.js";import{d as u}from"./chunk-V44SRRYR.js";import{a}from"./chunk-U6XEU573.js";import{a as n}from"./chunk-VLOX6KOM.js";import{b as i}from"./chunk-H2ORWIEY.js";import{g as r}from"./chunk-O6C2UGBY.js";import{a as s}from"./chunk-ZLLER3HP.js";import{Command as f,Flags as h}from"@oclif/core";function p(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(p,"isAvailabilityError");var m=class extends f{static{s(this,"BaseCommand")}static baseFlags={"api-url":h.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=d(this.config.version);o&&!this.argv.includes("--quiet")&&!process.env.RULEMETRIC_QUIET&&process.stderr.write(`
2
+ ${o}
3
+
4
+ `),c();try{await a()}catch{}}requireAuth(){r()||this.error("Not logged in. Run `rulemetric auth login` to authenticate."),n()}async catch(e){throw p(e)&&await u({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{m as a};