@rulemetric/cli 0.2.1 → 0.2.3
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.
- package/dist/base-command.js +13 -52
- package/dist/base-command.js.map +7 -1
- package/dist/chunk-2AM54TUK.js +59 -0
- package/dist/chunk-2AM54TUK.js.map +7 -0
- package/dist/chunk-3TIMQ3O6.js +96 -0
- package/dist/chunk-3TIMQ3O6.js.map +7 -0
- package/dist/chunk-4BHDHHKL.js +48 -0
- package/dist/chunk-4BHDHHKL.js.map +7 -0
- package/dist/chunk-4D537GXE.js +99 -0
- package/dist/chunk-4D537GXE.js.map +7 -0
- package/dist/chunk-4SCZK7AL.js +129 -0
- package/dist/chunk-4SCZK7AL.js.map +7 -0
- package/dist/chunk-4WFE4PFP.js +61 -0
- package/dist/chunk-4WFE4PFP.js.map +7 -0
- package/dist/chunk-52WIYRZH.js +73 -0
- package/dist/chunk-52WIYRZH.js.map +7 -0
- package/dist/chunk-7FAA3YNB.js +1549 -0
- package/dist/chunk-7FAA3YNB.js.map +7 -0
- package/dist/chunk-7NYKWN7U.js +12 -0
- package/dist/chunk-7NYKWN7U.js.map +7 -0
- package/dist/chunk-AULP2OWH.js +99 -0
- package/dist/chunk-AULP2OWH.js.map +7 -0
- package/dist/chunk-B5KNTGMJ.js +1788 -0
- package/dist/chunk-B5KNTGMJ.js.map +7 -0
- package/dist/chunk-BD7CY42U.js +23 -0
- package/dist/chunk-BD7CY42U.js.map +7 -0
- package/dist/chunk-BO76WKJR.js +42 -0
- package/dist/chunk-BO76WKJR.js.map +7 -0
- package/dist/chunk-BRD5RUGM.js +53 -0
- package/dist/chunk-BRD5RUGM.js.map +7 -0
- package/dist/chunk-BT6Z6545.js +43 -0
- package/dist/chunk-BT6Z6545.js.map +7 -0
- package/dist/chunk-BZDKEQKU.js +39 -0
- package/dist/chunk-BZDKEQKU.js.map +7 -0
- package/dist/chunk-CROYS75W.js +161 -0
- package/dist/chunk-CROYS75W.js.map +7 -0
- package/dist/chunk-DGHWRQXL.js +17 -0
- package/dist/chunk-DGHWRQXL.js.map +7 -0
- package/dist/chunk-DQ3KELXD.js +74 -0
- package/dist/chunk-DQ3KELXD.js.map +7 -0
- package/dist/chunk-DTFXCHHI.js +108 -0
- package/dist/chunk-DTFXCHHI.js.map +7 -0
- package/dist/chunk-DU73QUS3.js +75 -0
- package/dist/chunk-DU73QUS3.js.map +7 -0
- package/dist/chunk-EHZJ6OXD.js +307 -0
- package/dist/chunk-EHZJ6OXD.js.map +7 -0
- package/dist/chunk-EJOI2ZGU.js +109 -0
- package/dist/chunk-EJOI2ZGU.js.map +7 -0
- package/dist/chunk-EKJ2CABV.js +76 -0
- package/dist/chunk-EKJ2CABV.js.map +7 -0
- package/dist/chunk-EKP32DLN.js +16 -0
- package/dist/chunk-EKP32DLN.js.map +7 -0
- package/dist/chunk-EOOP6WTC.js +148 -0
- package/dist/chunk-EOOP6WTC.js.map +7 -0
- package/dist/chunk-ERPMDAO3.js +20 -0
- package/dist/chunk-ERPMDAO3.js.map +7 -0
- package/dist/chunk-FTJRMUID.js +96 -0
- package/dist/chunk-FTJRMUID.js.map +7 -0
- package/dist/chunk-FZKLLNDS.js +228 -0
- package/dist/chunk-FZKLLNDS.js.map +7 -0
- package/dist/chunk-GQCISMAH.js +157 -0
- package/dist/chunk-GQCISMAH.js.map +7 -0
- package/dist/chunk-IGXX624H.js +55 -0
- package/dist/chunk-IGXX624H.js.map +7 -0
- package/dist/chunk-IJGF2ETG.js +68 -0
- package/dist/chunk-IJGF2ETG.js.map +7 -0
- package/dist/chunk-IWYCRLEK.js +220 -0
- package/dist/chunk-IWYCRLEK.js.map +7 -0
- package/dist/chunk-J7N3DLH6.js +117 -0
- package/dist/chunk-J7N3DLH6.js.map +7 -0
- package/dist/chunk-JX5UI6RW.js +99 -0
- package/dist/chunk-JX5UI6RW.js.map +7 -0
- package/dist/chunk-K3BFZ7KG.js +154 -0
- package/dist/chunk-K3BFZ7KG.js.map +7 -0
- package/dist/chunk-KHJUQFIK.js +51 -0
- package/dist/chunk-KHJUQFIK.js.map +7 -0
- package/dist/chunk-KRBQLMOP.js +41 -0
- package/dist/chunk-KRBQLMOP.js.map +7 -0
- package/dist/chunk-KZRFUXGF.js +145 -0
- package/dist/chunk-KZRFUXGF.js.map +7 -0
- package/dist/chunk-L674RNKQ.js +492 -0
- package/dist/chunk-L674RNKQ.js.map +7 -0
- package/dist/chunk-N52AHNBH.js +47 -0
- package/dist/chunk-N52AHNBH.js.map +7 -0
- package/dist/chunk-NIDLJO6F.js +228 -0
- package/dist/chunk-NIDLJO6F.js.map +7 -0
- package/dist/chunk-NSBPE2FW.js +17 -0
- package/dist/chunk-NSBPE2FW.js.map +7 -0
- package/dist/chunk-OGVORIFM.js +70 -0
- package/dist/chunk-OGVORIFM.js.map +7 -0
- package/dist/chunk-OQSQC7VB.js +77 -0
- package/dist/chunk-OQSQC7VB.js.map +7 -0
- package/dist/chunk-PHLMIZKM.js +153 -0
- package/dist/chunk-PHLMIZKM.js.map +7 -0
- package/dist/chunk-PQU7GZ7A.js +92 -0
- package/dist/chunk-PQU7GZ7A.js.map +7 -0
- package/dist/chunk-PXVQLD7S.js +196 -0
- package/dist/chunk-PXVQLD7S.js.map +7 -0
- package/dist/chunk-QD6X4L4L.js +79 -0
- package/dist/chunk-QD6X4L4L.js.map +7 -0
- package/dist/chunk-QJQS6TUN.js +44 -0
- package/dist/chunk-QJQS6TUN.js.map +7 -0
- package/dist/chunk-QJXAULRC.js +191 -0
- package/dist/chunk-QJXAULRC.js.map +7 -0
- package/dist/chunk-QN34TGD3.js +83 -0
- package/dist/chunk-QN34TGD3.js.map +7 -0
- package/dist/chunk-R5MFHGHR.js +122 -0
- package/dist/chunk-R5MFHGHR.js.map +7 -0
- package/dist/chunk-RH7NHVSK.js +16 -0
- package/dist/chunk-RH7NHVSK.js.map +7 -0
- package/dist/chunk-RJ7BHDLM.js +121 -0
- package/dist/chunk-RJ7BHDLM.js.map +7 -0
- package/dist/chunk-RQ2TMLKG.js +142 -0
- package/dist/chunk-RQ2TMLKG.js.map +7 -0
- package/dist/chunk-S56LOTGQ.js +63 -0
- package/dist/chunk-S56LOTGQ.js.map +7 -0
- package/dist/chunk-UF73WX2J.js +49 -0
- package/dist/chunk-UF73WX2J.js.map +7 -0
- package/dist/chunk-W53GKIZQ.js +50 -0
- package/dist/chunk-W53GKIZQ.js.map +7 -0
- package/dist/chunk-WA4MWYRW.js +254 -0
- package/dist/chunk-WA4MWYRW.js.map +7 -0
- package/dist/chunk-WFULKPEQ.js +269 -0
- package/dist/chunk-WFULKPEQ.js.map +7 -0
- package/dist/chunk-XC6M4CSW.js +44 -0
- package/dist/chunk-XC6M4CSW.js.map +7 -0
- package/dist/chunk-XPUEGHXN.js +243 -0
- package/dist/chunk-XPUEGHXN.js.map +7 -0
- package/dist/chunk-XZXS2W24.js +148 -0
- package/dist/chunk-XZXS2W24.js.map +7 -0
- package/dist/chunk-YBNW7ARH.js +167 -0
- package/dist/chunk-YBNW7ARH.js.map +7 -0
- package/dist/chunk-YNIH3KMU.js +121 -0
- package/dist/chunk-YNIH3KMU.js.map +7 -0
- package/dist/commands/antigravity/backfill.js +135 -0
- package/dist/commands/antigravity/backfill.js.map +7 -0
- package/dist/commands/auth/create-key.js +48 -33
- package/dist/commands/auth/create-key.js.map +7 -1
- package/dist/commands/auth/login.js +58 -46
- package/dist/commands/auth/login.js.map +7 -1
- package/dist/commands/auth/logout.js +28 -13
- package/dist/commands/auth/logout.js.map +7 -1
- package/dist/commands/auth/revoke-key.js +32 -18
- package/dist/commands/auth/revoke-key.js.map +7 -1
- package/dist/commands/auth/status.js +40 -22
- package/dist/commands/auth/status.js.map +7 -1
- package/dist/commands/catalog/index.js +50 -34
- package/dist/commands/catalog/index.js.map +7 -1
- package/dist/commands/catalog/recommend.js +41 -26
- package/dist/commands/catalog/recommend.js.map +7 -1
- package/dist/commands/convert.js +72 -54
- package/dist/commands/convert.js.map +7 -1
- package/dist/commands/converters.js +52 -38
- package/dist/commands/converters.js.map +7 -1
- package/dist/commands/crons/list.js +50 -24
- package/dist/commands/crons/list.js.map +7 -1
- package/dist/commands/crons/run.js +72 -47
- package/dist/commands/crons/run.js.map +7 -1
- package/dist/commands/dashboard.js +45 -24
- package/dist/commands/dashboard.js.map +7 -1
- package/dist/commands/eval-targets/create.js +51 -39
- package/dist/commands/eval-targets/create.js.map +7 -1
- package/dist/commands/eval-targets/list.js +52 -35
- package/dist/commands/eval-targets/list.js.map +7 -1
- package/dist/commands/evals/agent.js +292 -0
- package/dist/commands/evals/agent.js.map +7 -0
- package/dist/commands/evals/benchmark.js +70 -51
- package/dist/commands/evals/benchmark.js.map +7 -1
- package/dist/commands/evals/compare.js +90 -78
- package/dist/commands/evals/compare.js.map +7 -1
- package/dist/commands/evals/create.js +64 -50
- package/dist/commands/evals/create.js.map +7 -1
- package/dist/commands/evals/optimize-description.js +225 -222
- package/dist/commands/evals/optimize-description.js.map +7 -1
- package/dist/commands/evals/optimize.js +206 -196
- package/dist/commands/evals/optimize.js.map +7 -1
- package/dist/commands/evals/run.js +178 -164
- package/dist/commands/evals/run.js.map +7 -1
- package/dist/commands/gateway/ensure.js +33 -19
- package/dist/commands/gateway/ensure.js.map +7 -1
- package/dist/commands/hooks/install.js +335 -275
- package/dist/commands/hooks/install.js.map +7 -1
- package/dist/commands/hooks/run.js +72 -53
- package/dist/commands/hooks/run.js.map +7 -1
- package/dist/commands/hooks/uninstall.js +117 -94
- package/dist/commands/hooks/uninstall.js.map +7 -1
- package/dist/commands/import.js +63 -53
- package/dist/commands/import.js.map +7 -1
- package/dist/commands/instructions/create.js +71 -58
- package/dist/commands/instructions/create.js.map +7 -1
- package/dist/commands/instructions/delete.js +53 -36
- package/dist/commands/instructions/delete.js.map +7 -1
- package/dist/commands/instructions/fork.js +33 -19
- package/dist/commands/instructions/fork.js.map +7 -1
- package/dist/commands/instructions/get.js +66 -49
- package/dist/commands/instructions/get.js.map +7 -1
- package/dist/commands/instructions/list.js +63 -46
- package/dist/commands/instructions/list.js.map +7 -1
- package/dist/commands/instructions/promote.js +41 -27
- package/dist/commands/instructions/promote.js.map +7 -1
- package/dist/commands/instructions/pull.js +37 -21
- package/dist/commands/instructions/pull.js.map +7 -1
- package/dist/commands/instructions/upstream.js +36 -21
- package/dist/commands/instructions/upstream.js.map +7 -1
- package/dist/commands/instructions/versions.js +51 -33
- package/dist/commands/instructions/versions.js.map +7 -1
- package/dist/commands/launcher.js +39 -0
- package/dist/commands/launcher.js.map +7 -0
- package/dist/commands/org/current.js +74 -68
- package/dist/commands/org/current.js.map +7 -1
- package/dist/commands/org/list.js +50 -36
- package/dist/commands/org/list.js.map +7 -1
- package/dist/commands/org/switch.js +69 -51
- package/dist/commands/org/switch.js.map +7 -1
- package/dist/commands/packs/add-instruction.js +36 -22
- package/dist/commands/packs/add-instruction.js.map +7 -1
- package/dist/commands/packs/apply.js +38 -24
- package/dist/commands/packs/apply.js.map +7 -1
- package/dist/commands/packs/create.js +47 -33
- package/dist/commands/packs/create.js.map +7 -1
- package/dist/commands/packs/fork.js +33 -19
- package/dist/commands/packs/fork.js.map +7 -1
- package/dist/commands/packs/get.js +54 -35
- package/dist/commands/packs/get.js.map +7 -1
- package/dist/commands/packs/list.js +64 -47
- package/dist/commands/packs/list.js.map +7 -1
- package/dist/commands/packs/remove-instruction.js +34 -20
- package/dist/commands/packs/remove-instruction.js.map +7 -1
- package/dist/commands/proxy/env.js +126 -116
- package/dist/commands/proxy/env.js.map +7 -1
- package/dist/commands/proxy/logs.js +83 -74
- package/dist/commands/proxy/logs.js.map +7 -1
- package/dist/commands/proxy/restart.js +34 -36
- package/dist/commands/proxy/restart.js.map +7 -1
- package/dist/commands/proxy/setup.js +432 -375
- package/dist/commands/proxy/setup.js.map +7 -1
- package/dist/commands/proxy/start.js +289 -289
- package/dist/commands/proxy/start.js.map +7 -1
- package/dist/commands/proxy/status.js +74 -64
- package/dist/commands/proxy/status.js.map +7 -1
- package/dist/commands/proxy/stop.js +81 -75
- package/dist/commands/proxy/stop.js.map +7 -1
- package/dist/commands/research/backfill.js +58 -0
- package/dist/commands/research/backfill.js.map +7 -0
- package/dist/commands/research/tail-transcript.js +69 -0
- package/dist/commands/research/tail-transcript.js.map +7 -0
- package/dist/commands/service/install.js +639 -405
- package/dist/commands/service/install.js.map +7 -1
- package/dist/commands/service/status.js +178 -111
- package/dist/commands/service/status.js.map +7 -1
- package/dist/commands/service/uninstall.js +85 -110
- package/dist/commands/service/uninstall.js.map +7 -1
- package/dist/commands/sessions/analyze.js +46 -25
- package/dist/commands/sessions/analyze.js.map +7 -1
- package/dist/commands/sessions/end.js +81 -79
- package/dist/commands/sessions/end.js.map +7 -1
- package/dist/commands/sessions/import.js +44 -27
- package/dist/commands/sessions/import.js.map +7 -1
- package/dist/commands/sessions/list.js +46 -33
- package/dist/commands/sessions/list.js.map +7 -1
- package/dist/commands/sessions/start.js +88 -87
- package/dist/commands/sessions/start.js.map +7 -1
- package/dist/commands/signals/report.js +42 -34
- package/dist/commands/signals/report.js.map +7 -1
- package/dist/commands/skills/export-approved.js +44 -30
- package/dist/commands/skills/export-approved.js.map +7 -1
- package/dist/commands/skills/install.js +99 -84
- package/dist/commands/skills/install.js.map +7 -1
- package/dist/commands/skills/list.js +59 -42
- package/dist/commands/skills/list.js.map +7 -1
- package/dist/commands/skills/publish.js +95 -78
- package/dist/commands/skills/publish.js.map +7 -1
- package/dist/commands/skills/search.js +68 -53
- package/dist/commands/skills/search.js.map +7 -1
- package/dist/commands/skills/update.js +52 -39
- package/dist/commands/skills/update.js.map +7 -1
- package/dist/commands/suggestions/accept.js +82 -59
- package/dist/commands/suggestions/accept.js.map +7 -1
- package/dist/commands/suggestions/dismiss.js +44 -26
- package/dist/commands/suggestions/dismiss.js.map +7 -1
- package/dist/commands/suggestions/list.js +59 -39
- package/dist/commands/suggestions/list.js.map +7 -1
- package/dist/commands/suggestions/refresh.js +26 -11
- package/dist/commands/suggestions/refresh.js.map +7 -1
- package/dist/cursor-BGQJ4CWI.js +134 -0
- package/dist/cursor-BGQJ4CWI.js.map +7 -0
- package/dist/dashboard/Dashboard.js +229 -126
- package/dist/dashboard/Dashboard.js.map +7 -1
- package/dist/dashboard/data.js +13 -137
- package/dist/dashboard/data.js.map +7 -1
- package/dist/dashboard/launcher/ActiveJobsList.js +10 -0
- package/dist/dashboard/launcher/ActiveJobsList.js.map +7 -0
- package/dist/dashboard/launcher/LauncherOverlay.js +14 -0
- package/dist/dashboard/launcher/LauncherOverlay.js.map +7 -0
- package/dist/dashboard/launcher/NewLaunchForm.js +10 -0
- package/dist/dashboard/launcher/NewLaunchForm.js.map +7 -0
- package/dist/dashboard/launcher/api.js +14 -0
- package/dist/dashboard/launcher/api.js.map +7 -0
- package/dist/dashboard/launcher/tool-labels.js +10 -0
- package/dist/dashboard/launcher/tool-labels.js.map +7 -0
- package/dist/dashboard/launcher/types.js +1 -0
- package/dist/dashboard/launcher/types.js.map +7 -0
- package/dist/dashboard/launcher/useLaunchJobs.js +9 -0
- package/dist/dashboard/launcher/useLaunchJobs.js.map +7 -0
- package/dist/dashboard/panels/friction.js +10 -22
- package/dist/dashboard/panels/friction.js.map +7 -1
- package/dist/dashboard/panels/insights.js +10 -109
- package/dist/dashboard/panels/insights.js.map +7 -1
- package/dist/dashboard/panels/instructions.js +10 -17
- package/dist/dashboard/panels/instructions.js.map +7 -1
- package/dist/dashboard/panels/outcomes.js +9 -28
- package/dist/dashboard/panels/outcomes.js.map +7 -1
- package/dist/dashboard/panels/overview.js +10 -20
- package/dist/dashboard/panels/overview.js.map +7 -1
- package/dist/dashboard/panels/shared.js +18 -61
- package/dist/dashboard/panels/shared.js.map +7 -1
- package/dist/dashboard/types.js +23 -26
- package/dist/dashboard/types.js.map +7 -1
- package/dist/dist-CSUYFYKI.js +52 -0
- package/dist/dist-CSUYFYKI.js.map +7 -0
- package/dist/index.js +8 -2
- package/dist/index.js.map +7 -1
- package/dist/lib/active-org-refresh.js +15 -108
- package/dist/lib/active-org-refresh.js.map +7 -1
- package/dist/lib/active-org.js +15 -95
- package/dist/lib/active-org.js.map +7 -1
- package/dist/lib/agent-loop.js +44 -0
- package/dist/lib/agent-loop.js.map +7 -0
- package/dist/lib/antigravity-transcript.js +22 -0
- package/dist/lib/antigravity-transcript.js.map +7 -0
- package/dist/lib/api-client.js +21 -92
- package/dist/lib/api-client.js.map +7 -1
- package/dist/lib/auth.js +26 -137
- package/dist/lib/auth.js.map +7 -1
- package/dist/lib/detect-languages.js +8 -113
- package/dist/lib/detect-languages.js.map +7 -1
- package/dist/lib/detect-tmux.js +9 -0
- package/dist/lib/detect-tmux.js.map +7 -0
- package/dist/lib/eval-analyzer.js +9 -89
- package/dist/lib/eval-analyzer.js.map +7 -1
- package/dist/lib/eval-benchmark.js +12 -92
- package/dist/lib/eval-benchmark.js.map +7 -1
- package/dist/lib/eval-conversation-handler.js +13 -200
- package/dist/lib/eval-conversation-handler.js.map +7 -1
- package/dist/lib/eval-executor.js +8 -83
- package/dist/lib/eval-executor.js.map +7 -1
- package/dist/lib/eval-grader.js +9 -123
- package/dist/lib/eval-grader.js.map +7 -1
- package/dist/lib/eval-meta-judge.js +9 -116
- package/dist/lib/eval-meta-judge.js.map +7 -1
- package/dist/lib/eval-trigger-tester.js +11 -96
- package/dist/lib/eval-trigger-tester.js.map +7 -1
- package/dist/lib/eval-worktree.js +8 -87
- package/dist/lib/eval-worktree.js.map +7 -1
- package/dist/lib/gateway-entry.js +20 -18
- package/dist/lib/gateway-entry.js.map +7 -1
- package/dist/lib/gateway-lifecycle.js +22 -97
- package/dist/lib/gateway-lifecycle.js.map +7 -1
- package/dist/lib/gateway.js +12 -216
- package/dist/lib/gateway.js.map +7 -1
- package/dist/lib/handlers/cron-close-stale-sessions.js +18 -7
- package/dist/lib/handlers/cron-close-stale-sessions.js.map +7 -1
- package/dist/lib/handlers/cron-data-integrity-audit.js +21 -15
- package/dist/lib/handlers/cron-data-integrity-audit.js.map +7 -1
- package/dist/lib/handlers/cron-refresh-skills.js +7 -90
- package/dist/lib/handlers/cron-refresh-skills.js.map +7 -1
- package/dist/lib/handlers/cron-suggest-instructions.js +14 -158
- package/dist/lib/handlers/cron-suggest-instructions.js.map +7 -1
- package/dist/lib/handlers/process-announcement.js +11 -0
- package/dist/lib/handlers/process-announcement.js.map +7 -0
- package/dist/lib/handlers/process-changelog.js +11 -0
- package/dist/lib/handlers/process-changelog.js.map +7 -0
- package/dist/lib/handlers/process-conversation.js +14 -35
- package/dist/lib/handlers/process-conversation.js.map +7 -1
- package/dist/lib/handlers/process-eval.js +15 -207
- package/dist/lib/handlers/process-eval.js.map +7 -1
- package/dist/lib/handlers/process-insights.js +14 -300
- package/dist/lib/handlers/process-insights.js.map +7 -1
- package/dist/lib/handlers/process-launch.js +16 -41
- package/dist/lib/handlers/process-launch.js.map +7 -1
- package/dist/lib/handlers/process-run-cleanup.js +13 -0
- package/dist/lib/handlers/process-run-cleanup.js.map +7 -0
- package/dist/lib/handlers/process-send-message.js +10 -0
- package/dist/lib/handlers/process-send-message.js.map +7 -0
- package/dist/lib/handlers/process-session-goal.js +11 -74
- package/dist/lib/handlers/process-session-goal.js.map +7 -1
- package/dist/lib/hooks-config.js +52 -544
- package/dist/lib/hooks-config.js.map +7 -1
- package/dist/lib/insights-prompts.js +12 -145
- package/dist/lib/insights-prompts.js.map +7 -1
- package/dist/lib/job-helpers.js +1 -0
- package/dist/lib/job-helpers.js.map +7 -0
- package/dist/lib/llm-client.js +16 -274
- package/dist/lib/llm-client.js.map +7 -1
- package/dist/lib/manual-tasks.js +22 -0
- package/dist/lib/manual-tasks.js.map +7 -0
- package/dist/lib/output.js +12 -36
- package/dist/lib/output.js.map +7 -1
- package/dist/lib/permanent-job-error.js +10 -23
- package/dist/lib/permanent-job-error.js.map +7 -1
- package/dist/lib/provider-aggregator.js +57 -55
- package/dist/lib/provider-aggregator.js.map +7 -1
- package/dist/lib/research-client.js +12 -0
- package/dist/lib/research-client.js.map +7 -0
- package/dist/lib/skills-loader.js +8 -51
- package/dist/lib/skills-loader.js.map +7 -1
- package/dist/lib/statusline-shim.js +16 -0
- package/dist/lib/statusline-shim.js.map +7 -0
- package/dist/lib/terminal-target-heartbeat.js +15 -0
- package/dist/lib/terminal-target-heartbeat.js.map +7 -0
- package/dist/lib/tmux.js +16 -0
- package/dist/lib/tmux.js.map +7 -0
- package/dist/lib/transcript-rate-limit-watcher.js +22 -0
- package/dist/lib/transcript-rate-limit-watcher.js.map +7 -0
- package/dist/lib/types.js +8 -7
- package/dist/lib/types.js.map +7 -1
- package/dist/lib/version-check.js +10 -106
- package/dist/lib/version-check.js.map +7 -1
- package/dist/lib/which.js +8 -0
- package/dist/lib/which.js.map +7 -0
- package/dist/lib/worktree.js +17 -0
- package/dist/lib/worktree.js.map +7 -0
- package/dist/opencode-IQ7X5YMJ.js +190 -0
- package/dist/opencode-IQ7X5YMJ.js.map +7 -0
- package/oclif.manifest.json +299 -66
- package/package.json +26 -10
- package/dist/base-command.d.ts +0 -12
- package/dist/base-command.d.ts.map +0 -1
- package/dist/commands/auth/create-key.d.ts +0 -11
- package/dist/commands/auth/create-key.d.ts.map +0 -1
- package/dist/commands/auth/login.d.ts +0 -11
- package/dist/commands/auth/login.d.ts.map +0 -1
- package/dist/commands/auth/logout.d.ts +0 -7
- package/dist/commands/auth/logout.d.ts.map +0 -1
- package/dist/commands/auth/revoke-key.d.ts +0 -10
- package/dist/commands/auth/revoke-key.d.ts.map +0 -1
- package/dist/commands/auth/status.d.ts +0 -7
- package/dist/commands/auth/status.d.ts.map +0 -1
- package/dist/commands/catalog/index.d.ts +0 -11
- package/dist/commands/catalog/index.d.ts.map +0 -1
- package/dist/commands/catalog/recommend.d.ts +0 -9
- package/dist/commands/catalog/recommend.d.ts.map +0 -1
- package/dist/commands/convert.d.ts +0 -15
- package/dist/commands/convert.d.ts.map +0 -1
- package/dist/commands/converters.d.ts +0 -12
- package/dist/commands/converters.d.ts.map +0 -1
- package/dist/commands/crons/list.d.ts +0 -7
- package/dist/commands/crons/list.d.ts.map +0 -1
- package/dist/commands/crons/run.d.ts +0 -13
- package/dist/commands/crons/run.d.ts.map +0 -1
- package/dist/commands/dashboard.d.ts +0 -10
- package/dist/commands/dashboard.d.ts.map +0 -1
- package/dist/commands/eval-targets/create.d.ts +0 -14
- package/dist/commands/eval-targets/create.d.ts.map +0 -1
- package/dist/commands/eval-targets/list.d.ts +0 -10
- package/dist/commands/eval-targets/list.d.ts.map +0 -1
- package/dist/commands/evals/benchmark.d.ts +0 -13
- package/dist/commands/evals/benchmark.d.ts.map +0 -1
- package/dist/commands/evals/compare.d.ts +0 -15
- package/dist/commands/evals/compare.d.ts.map +0 -1
- package/dist/commands/evals/create.d.ts +0 -17
- package/dist/commands/evals/create.d.ts.map +0 -1
- package/dist/commands/evals/listen.d.ts +0 -37
- package/dist/commands/evals/listen.d.ts.map +0 -1
- package/dist/commands/evals/listen.js +0 -188
- package/dist/commands/evals/listen.js.map +0 -1
- package/dist/commands/evals/listen.test.d.ts +0 -2
- package/dist/commands/evals/listen.test.d.ts.map +0 -1
- package/dist/commands/evals/listen.test.js +0 -48
- package/dist/commands/evals/listen.test.js.map +0 -1
- package/dist/commands/evals/optimize-description.d.ts +0 -22
- package/dist/commands/evals/optimize-description.d.ts.map +0 -1
- package/dist/commands/evals/optimize.d.ts +0 -22
- package/dist/commands/evals/optimize.d.ts.map +0 -1
- package/dist/commands/evals/run.d.ts +0 -21
- package/dist/commands/evals/run.d.ts.map +0 -1
- package/dist/commands/gateway/ensure.d.ts +0 -7
- package/dist/commands/gateway/ensure.d.ts.map +0 -1
- package/dist/commands/hooks/install.d.ts +0 -16
- package/dist/commands/hooks/install.d.ts.map +0 -1
- package/dist/commands/hooks/run.d.ts +0 -11
- package/dist/commands/hooks/run.d.ts.map +0 -1
- package/dist/commands/hooks/uninstall.d.ts +0 -7
- package/dist/commands/hooks/uninstall.d.ts.map +0 -1
- package/dist/commands/import.d.ts +0 -17
- package/dist/commands/import.d.ts.map +0 -1
- package/dist/commands/instructions/create.d.ts +0 -17
- package/dist/commands/instructions/create.d.ts.map +0 -1
- package/dist/commands/instructions/delete.d.ts +0 -13
- package/dist/commands/instructions/delete.d.ts.map +0 -1
- package/dist/commands/instructions/fork.d.ts +0 -10
- package/dist/commands/instructions/fork.d.ts.map +0 -1
- package/dist/commands/instructions/get.d.ts +0 -15
- package/dist/commands/instructions/get.d.ts.map +0 -1
- package/dist/commands/instructions/list.d.ts +0 -12
- package/dist/commands/instructions/list.d.ts.map +0 -1
- package/dist/commands/instructions/promote.d.ts +0 -14
- package/dist/commands/instructions/promote.d.ts.map +0 -1
- package/dist/commands/instructions/pull.d.ts +0 -9
- package/dist/commands/instructions/pull.d.ts.map +0 -1
- package/dist/commands/instructions/upstream.d.ts +0 -9
- package/dist/commands/instructions/upstream.d.ts.map +0 -1
- package/dist/commands/instructions/versions.d.ts +0 -12
- package/dist/commands/instructions/versions.d.ts.map +0 -1
- package/dist/commands/org/current.d.ts +0 -7
- package/dist/commands/org/current.d.ts.map +0 -1
- package/dist/commands/org/list.d.ts +0 -7
- package/dist/commands/org/list.d.ts.map +0 -1
- package/dist/commands/org/switch.d.ts +0 -13
- package/dist/commands/org/switch.d.ts.map +0 -1
- package/dist/commands/packs/add-instruction.d.ts +0 -11
- package/dist/commands/packs/add-instruction.d.ts.map +0 -1
- package/dist/commands/packs/apply.d.ts +0 -13
- package/dist/commands/packs/apply.d.ts.map +0 -1
- package/dist/commands/packs/create.d.ts +0 -13
- package/dist/commands/packs/create.d.ts.map +0 -1
- package/dist/commands/packs/fork.d.ts +0 -10
- package/dist/commands/packs/fork.d.ts.map +0 -1
- package/dist/commands/packs/get.d.ts +0 -10
- package/dist/commands/packs/get.d.ts.map +0 -1
- package/dist/commands/packs/list.d.ts +0 -22
- package/dist/commands/packs/list.d.ts.map +0 -1
- package/dist/commands/packs/remove-instruction.d.ts +0 -11
- package/dist/commands/packs/remove-instruction.d.ts.map +0 -1
- package/dist/commands/proxy/env.d.ts +0 -14
- package/dist/commands/proxy/env.d.ts.map +0 -1
- package/dist/commands/proxy/logs.d.ts +0 -11
- package/dist/commands/proxy/logs.d.ts.map +0 -1
- package/dist/commands/proxy/restart.d.ts +0 -11
- package/dist/commands/proxy/restart.d.ts.map +0 -1
- package/dist/commands/proxy/setup.d.ts +0 -23
- package/dist/commands/proxy/setup.d.ts.map +0 -1
- package/dist/commands/proxy/start.d.ts +0 -17
- package/dist/commands/proxy/start.d.ts.map +0 -1
- package/dist/commands/proxy/status.d.ts +0 -7
- package/dist/commands/proxy/status.d.ts.map +0 -1
- package/dist/commands/proxy/stop.d.ts +0 -8
- package/dist/commands/proxy/stop.d.ts.map +0 -1
- package/dist/commands/service/install.d.ts +0 -33
- package/dist/commands/service/install.d.ts.map +0 -1
- package/dist/commands/service/install.test.d.ts +0 -2
- package/dist/commands/service/install.test.d.ts.map +0 -1
- package/dist/commands/service/install.test.js +0 -345
- package/dist/commands/service/install.test.js.map +0 -1
- package/dist/commands/service/status.d.ts +0 -6
- package/dist/commands/service/status.d.ts.map +0 -1
- package/dist/commands/service/uninstall.d.ts +0 -6
- package/dist/commands/service/uninstall.d.ts.map +0 -1
- package/dist/commands/sessions/analyze.d.ts +0 -10
- package/dist/commands/sessions/analyze.d.ts.map +0 -1
- package/dist/commands/sessions/end.d.ts +0 -9
- package/dist/commands/sessions/end.d.ts.map +0 -1
- package/dist/commands/sessions/import.d.ts +0 -13
- package/dist/commands/sessions/import.d.ts.map +0 -1
- package/dist/commands/sessions/list.d.ts +0 -11
- package/dist/commands/sessions/list.d.ts.map +0 -1
- package/dist/commands/sessions/start.d.ts +0 -11
- package/dist/commands/sessions/start.d.ts.map +0 -1
- package/dist/commands/signals/report.d.ts +0 -10
- package/dist/commands/signals/report.d.ts.map +0 -1
- package/dist/commands/signals/report.test.d.ts +0 -2
- package/dist/commands/signals/report.test.d.ts.map +0 -1
- package/dist/commands/signals/report.test.js +0 -65
- package/dist/commands/signals/report.test.js.map +0 -1
- package/dist/commands/skills/export-approved.d.ts +0 -10
- package/dist/commands/skills/export-approved.d.ts.map +0 -1
- package/dist/commands/skills/install.d.ts +0 -15
- package/dist/commands/skills/install.d.ts.map +0 -1
- package/dist/commands/skills/list.d.ts +0 -11
- package/dist/commands/skills/list.d.ts.map +0 -1
- package/dist/commands/skills/publish.d.ts +0 -17
- package/dist/commands/skills/publish.d.ts.map +0 -1
- package/dist/commands/skills/search.d.ts +0 -17
- package/dist/commands/skills/search.d.ts.map +0 -1
- package/dist/commands/skills/update.d.ts +0 -10
- package/dist/commands/skills/update.d.ts.map +0 -1
- package/dist/commands/suggestions/accept.d.ts +0 -16
- package/dist/commands/suggestions/accept.d.ts.map +0 -1
- package/dist/commands/suggestions/accept.test.d.ts +0 -2
- package/dist/commands/suggestions/accept.test.d.ts.map +0 -1
- package/dist/commands/suggestions/accept.test.js +0 -52
- package/dist/commands/suggestions/accept.test.js.map +0 -1
- package/dist/commands/suggestions/dismiss.d.ts +0 -10
- package/dist/commands/suggestions/dismiss.d.ts.map +0 -1
- package/dist/commands/suggestions/list.d.ts +0 -10
- package/dist/commands/suggestions/list.d.ts.map +0 -1
- package/dist/commands/suggestions/refresh.d.ts +0 -7
- package/dist/commands/suggestions/refresh.d.ts.map +0 -1
- package/dist/dashboard/Dashboard.d.ts +0 -3
- package/dist/dashboard/Dashboard.d.ts.map +0 -1
- package/dist/dashboard/data.d.ts +0 -11
- package/dist/dashboard/data.d.ts.map +0 -1
- package/dist/dashboard/panels/friction.d.ts +0 -7
- package/dist/dashboard/panels/friction.d.ts.map +0 -1
- package/dist/dashboard/panels/insights.d.ts +0 -8
- package/dist/dashboard/panels/insights.d.ts.map +0 -1
- package/dist/dashboard/panels/instructions.d.ts +0 -9
- package/dist/dashboard/panels/instructions.d.ts.map +0 -1
- package/dist/dashboard/panels/outcomes.d.ts +0 -7
- package/dist/dashboard/panels/outcomes.d.ts.map +0 -1
- package/dist/dashboard/panels/overview.d.ts +0 -8
- package/dist/dashboard/panels/overview.d.ts.map +0 -1
- package/dist/dashboard/panels/shared.d.ts +0 -17
- package/dist/dashboard/panels/shared.d.ts.map +0 -1
- package/dist/dashboard/types.d.ts +0 -80
- package/dist/dashboard/types.d.ts.map +0 -1
- package/dist/index.d.ts +0 -2
- package/dist/index.d.ts.map +0 -1
- package/dist/lib/active-org-refresh.d.ts +0 -22
- package/dist/lib/active-org-refresh.d.ts.map +0 -1
- package/dist/lib/active-org-refresh.test.d.ts +0 -2
- package/dist/lib/active-org-refresh.test.d.ts.map +0 -1
- package/dist/lib/active-org-refresh.test.js +0 -190
- package/dist/lib/active-org-refresh.test.js.map +0 -1
- package/dist/lib/active-org.d.ts +0 -43
- package/dist/lib/active-org.d.ts.map +0 -1
- package/dist/lib/active-org.test.d.ts +0 -2
- package/dist/lib/active-org.test.d.ts.map +0 -1
- package/dist/lib/active-org.test.js +0 -147
- package/dist/lib/active-org.test.js.map +0 -1
- package/dist/lib/api-client.d.ts +0 -17
- package/dist/lib/api-client.d.ts.map +0 -1
- package/dist/lib/api-client.test.d.ts +0 -2
- package/dist/lib/api-client.test.d.ts.map +0 -1
- package/dist/lib/api-client.test.js +0 -161
- package/dist/lib/api-client.test.js.map +0 -1
- package/dist/lib/auth.d.ts +0 -27
- package/dist/lib/auth.d.ts.map +0 -1
- package/dist/lib/auth.test.d.ts +0 -2
- package/dist/lib/auth.test.d.ts.map +0 -1
- package/dist/lib/auth.test.js +0 -110
- package/dist/lib/auth.test.js.map +0 -1
- package/dist/lib/cron-registry.d.ts +0 -47
- package/dist/lib/cron-registry.d.ts.map +0 -1
- package/dist/lib/cron-registry.js +0 -102
- package/dist/lib/cron-registry.js.map +0 -1
- package/dist/lib/cron-registry.test.d.ts +0 -2
- package/dist/lib/cron-registry.test.d.ts.map +0 -1
- package/dist/lib/cron-registry.test.js +0 -136
- package/dist/lib/cron-registry.test.js.map +0 -1
- package/dist/lib/cron-runner.d.ts +0 -16
- package/dist/lib/cron-runner.d.ts.map +0 -1
- package/dist/lib/cron-runner.js +0 -68
- package/dist/lib/cron-runner.js.map +0 -1
- package/dist/lib/detect-languages.d.ts +0 -7
- package/dist/lib/detect-languages.d.ts.map +0 -1
- package/dist/lib/detect-languages.test.d.ts +0 -2
- package/dist/lib/detect-languages.test.d.ts.map +0 -1
- package/dist/lib/detect-languages.test.js +0 -29
- package/dist/lib/detect-languages.test.js.map +0 -1
- package/dist/lib/eval-analyzer.d.ts +0 -23
- package/dist/lib/eval-analyzer.d.ts.map +0 -1
- package/dist/lib/eval-benchmark.d.ts +0 -17
- package/dist/lib/eval-benchmark.d.ts.map +0 -1
- package/dist/lib/eval-conversation-handler.d.ts +0 -9
- package/dist/lib/eval-conversation-handler.d.ts.map +0 -1
- package/dist/lib/eval-executor.d.ts +0 -21
- package/dist/lib/eval-executor.d.ts.map +0 -1
- package/dist/lib/eval-executor.test.d.ts +0 -2
- package/dist/lib/eval-executor.test.d.ts.map +0 -1
- package/dist/lib/eval-executor.test.js +0 -8
- package/dist/lib/eval-executor.test.js.map +0 -1
- package/dist/lib/eval-grader.d.ts +0 -38
- package/dist/lib/eval-grader.d.ts.map +0 -1
- package/dist/lib/eval-grader.test.d.ts +0 -2
- package/dist/lib/eval-grader.test.d.ts.map +0 -1
- package/dist/lib/eval-grader.test.js +0 -8
- package/dist/lib/eval-grader.test.js.map +0 -1
- package/dist/lib/eval-meta-judge.d.ts +0 -28
- package/dist/lib/eval-meta-judge.d.ts.map +0 -1
- package/dist/lib/eval-trigger-tester.d.ts +0 -19
- package/dist/lib/eval-trigger-tester.d.ts.map +0 -1
- package/dist/lib/eval-worktree.d.ts +0 -11
- package/dist/lib/eval-worktree.d.ts.map +0 -1
- package/dist/lib/eval-worktree.test.d.ts +0 -2
- package/dist/lib/eval-worktree.test.d.ts.map +0 -1
- package/dist/lib/eval-worktree.test.js +0 -68
- package/dist/lib/eval-worktree.test.js.map +0 -1
- package/dist/lib/gateway-entry.d.ts +0 -3
- package/dist/lib/gateway-entry.d.ts.map +0 -1
- package/dist/lib/gateway-lifecycle.d.ts +0 -9
- package/dist/lib/gateway-lifecycle.d.ts.map +0 -1
- package/dist/lib/gateway.d.ts +0 -11
- package/dist/lib/gateway.d.ts.map +0 -1
- package/dist/lib/graphile-worker-runner.d.ts +0 -124
- package/dist/lib/graphile-worker-runner.d.ts.map +0 -1
- package/dist/lib/graphile-worker-runner.js +0 -530
- package/dist/lib/graphile-worker-runner.js.map +0 -1
- package/dist/lib/graphile-worker-runner.test.d.ts +0 -2
- package/dist/lib/graphile-worker-runner.test.d.ts.map +0 -1
- package/dist/lib/graphile-worker-runner.test.js +0 -153
- package/dist/lib/graphile-worker-runner.test.js.map +0 -1
- package/dist/lib/handlers/cron-close-stale-sessions.d.ts +0 -3
- package/dist/lib/handlers/cron-close-stale-sessions.d.ts.map +0 -1
- package/dist/lib/handlers/cron-data-integrity-audit.d.ts +0 -3
- package/dist/lib/handlers/cron-data-integrity-audit.d.ts.map +0 -1
- package/dist/lib/handlers/cron-refresh-skills.d.ts +0 -3
- package/dist/lib/handlers/cron-refresh-skills.d.ts.map +0 -1
- package/dist/lib/handlers/cron-refresh-skills.test.d.ts +0 -2
- package/dist/lib/handlers/cron-refresh-skills.test.d.ts.map +0 -1
- package/dist/lib/handlers/cron-refresh-skills.test.js +0 -114
- package/dist/lib/handlers/cron-refresh-skills.test.js.map +0 -1
- package/dist/lib/handlers/cron-regenerate-insights.d.ts +0 -3
- package/dist/lib/handlers/cron-regenerate-insights.d.ts.map +0 -1
- package/dist/lib/handlers/cron-regenerate-insights.js +0 -6
- package/dist/lib/handlers/cron-regenerate-insights.js.map +0 -1
- package/dist/lib/handlers/cron-suggest-instructions.d.ts +0 -3
- package/dist/lib/handlers/cron-suggest-instructions.d.ts.map +0 -1
- package/dist/lib/handlers/cron-suggest-instructions.test.d.ts +0 -2
- package/dist/lib/handlers/cron-suggest-instructions.test.d.ts.map +0 -1
- package/dist/lib/handlers/cron-suggest-instructions.test.js +0 -80
- package/dist/lib/handlers/cron-suggest-instructions.test.js.map +0 -1
- package/dist/lib/handlers/process-conversation.d.ts +0 -35
- package/dist/lib/handlers/process-conversation.d.ts.map +0 -1
- package/dist/lib/handlers/process-eval.d.ts +0 -32
- package/dist/lib/handlers/process-eval.d.ts.map +0 -1
- package/dist/lib/handlers/process-insights.d.ts +0 -39
- package/dist/lib/handlers/process-insights.d.ts.map +0 -1
- package/dist/lib/handlers/process-launch.d.ts +0 -29
- package/dist/lib/handlers/process-launch.d.ts.map +0 -1
- package/dist/lib/handlers/process-session-goal.d.ts +0 -29
- package/dist/lib/handlers/process-session-goal.d.ts.map +0 -1
- package/dist/lib/handlers/process-session-goal.test.d.ts +0 -2
- package/dist/lib/handlers/process-session-goal.test.d.ts.map +0 -1
- package/dist/lib/handlers/process-session-goal.test.js +0 -134
- package/dist/lib/handlers/process-session-goal.test.js.map +0 -1
- package/dist/lib/hooks-config.d.ts +0 -119
- package/dist/lib/hooks-config.d.ts.map +0 -1
- package/dist/lib/hooks-config.test.d.ts +0 -2
- package/dist/lib/hooks-config.test.d.ts.map +0 -1
- package/dist/lib/hooks-config.test.js +0 -231
- package/dist/lib/hooks-config.test.js.map +0 -1
- package/dist/lib/insights-prompts.d.ts +0 -13
- package/dist/lib/insights-prompts.d.ts.map +0 -1
- package/dist/lib/llm-client.d.ts +0 -26
- package/dist/lib/llm-client.d.ts.map +0 -1
- package/dist/lib/llm-client.test.d.ts +0 -2
- package/dist/lib/llm-client.test.d.ts.map +0 -1
- package/dist/lib/llm-client.test.js +0 -62
- package/dist/lib/llm-client.test.js.map +0 -1
- package/dist/lib/mirror-writer-db.d.ts +0 -12
- package/dist/lib/mirror-writer-db.d.ts.map +0 -1
- package/dist/lib/mirror-writer-db.js +0 -51
- package/dist/lib/mirror-writer-db.js.map +0 -1
- package/dist/lib/mirror-writer.d.ts +0 -35
- package/dist/lib/mirror-writer.d.ts.map +0 -1
- package/dist/lib/mirror-writer.js +0 -27
- package/dist/lib/mirror-writer.js.map +0 -1
- package/dist/lib/mirror-writer.test.d.ts +0 -2
- package/dist/lib/mirror-writer.test.d.ts.map +0 -1
- package/dist/lib/mirror-writer.test.js +0 -47
- package/dist/lib/mirror-writer.test.js.map +0 -1
- package/dist/lib/output.d.ts +0 -4
- package/dist/lib/output.d.ts.map +0 -1
- package/dist/lib/output.test.d.ts +0 -2
- package/dist/lib/output.test.d.ts.map +0 -1
- package/dist/lib/output.test.js +0 -71
- package/dist/lib/output.test.js.map +0 -1
- package/dist/lib/permanent-job-error.d.ts +0 -17
- package/dist/lib/permanent-job-error.d.ts.map +0 -1
- package/dist/lib/permanent-job-error.test.d.ts +0 -2
- package/dist/lib/permanent-job-error.test.d.ts.map +0 -1
- package/dist/lib/permanent-job-error.test.js +0 -29
- package/dist/lib/permanent-job-error.test.js.map +0 -1
- package/dist/lib/provider-aggregator.d.ts +0 -24
- package/dist/lib/provider-aggregator.d.ts.map +0 -1
- package/dist/lib/provider-aggregator.test.d.ts +0 -2
- package/dist/lib/provider-aggregator.test.d.ts.map +0 -1
- package/dist/lib/provider-aggregator.test.js +0 -103
- package/dist/lib/provider-aggregator.test.js.map +0 -1
- package/dist/lib/skills-loader.d.ts +0 -6
- package/dist/lib/skills-loader.d.ts.map +0 -1
- package/dist/lib/types.d.ts +0 -48
- package/dist/lib/types.d.ts.map +0 -1
- package/dist/lib/version-check.d.ts +0 -11
- package/dist/lib/version-check.d.ts.map +0 -1
- package/dist/test-helpers.d.ts +0 -58
- package/dist/test-helpers.d.ts.map +0 -1
- package/dist/test-helpers.js +0 -58
- package/dist/test-helpers.js.map +0 -1
|
@@ -1,305 +1,485 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
1
|
+
import {
|
|
2
|
+
detectTmux
|
|
3
|
+
} from "../../chunk-BO76WKJR.js";
|
|
4
|
+
import "../../chunk-KRBQLMOP.js";
|
|
5
|
+
import {
|
|
6
|
+
BaseCommand
|
|
7
|
+
} from "../../chunk-S56LOTGQ.js";
|
|
8
|
+
import "../../chunk-OGVORIFM.js";
|
|
9
|
+
import {
|
|
10
|
+
bootstrapActiveOrg
|
|
11
|
+
} from "../../chunk-2AM54TUK.js";
|
|
12
|
+
import "../../chunk-EJOI2ZGU.js";
|
|
13
|
+
import "../../chunk-KZRFUXGF.js";
|
|
14
|
+
import "../../chunk-EKJ2CABV.js";
|
|
15
|
+
import "../../chunk-NSBPE2FW.js";
|
|
16
|
+
|
|
17
|
+
// src/commands/service/install.ts
|
|
18
|
+
import { Flags } from "@oclif/core";
|
|
19
|
+
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
20
|
+
import { execSync, execFileSync, spawnSync } from "node:child_process";
|
|
21
|
+
import { homedir } from "node:os";
|
|
22
|
+
import { dirname, join } from "node:path";
|
|
23
|
+
var ALLOWED_ENV_VARS = /* @__PURE__ */ new Set([
|
|
24
|
+
"SUPABASE_URL",
|
|
25
|
+
"SUPABASE_ANON_KEY",
|
|
26
|
+
"SUPABASE_SERVICE_ROLE_KEY",
|
|
27
|
+
// Enables local HS256 JWT verification in the API's authMiddleware —
|
|
28
|
+
// without it every authed request pays a /auth/v1/user network round-trip
|
|
29
|
+
// (measured p50 ~244ms) to Supabase.
|
|
30
|
+
"SUPABASE_JWT_SECRET",
|
|
31
|
+
"DATABASE_URL",
|
|
32
|
+
"RULEMETRIC_API_URL",
|
|
33
|
+
"RULEMETRIC_API_KEY",
|
|
34
|
+
"RULEMETRIC_ACCESS_TOKEN",
|
|
35
|
+
// Recipient for the weekly cron_data_integrity_audit notification.
|
|
36
|
+
// Without one of these, the audit cron runs but nobody is notified —
|
|
37
|
+
// see cron-data-integrity-audit.ts (defaults: NOTIFY_USER_ID then USER_ID).
|
|
38
|
+
"RULEMETRIC_AUDIT_NOTIFY_USER_ID",
|
|
39
|
+
"RULEMETRIC_USER_ID",
|
|
40
|
+
// cron_refresh_skills needs an authenticated GitHub API budget (5000
|
|
41
|
+
// req/hr) — without it the handler skips and the skills registry goes
|
|
42
|
+
// stale, which makes cron_suggest_instructions mark every suggestion
|
|
43
|
+
// stale on each nightly run.
|
|
44
|
+
"GITHUB_TOKEN",
|
|
45
|
+
// Pool-tuning overrides so the plist generators (buildPlist / buildWorkerPlist)
|
|
46
|
+
// actually honor a user-set value instead of always falling back to the pinned
|
|
47
|
+
// default — without these in the allow-list the `envVars.PG_* ?? '<default>'`
|
|
48
|
+
// escape hatch was silently dead. Pool-exhaustion RCA 2026-06-21.
|
|
49
|
+
"PG_POOL_MAX",
|
|
50
|
+
"PG_IDLE_TIMEOUT",
|
|
51
|
+
"PG_STATEMENT_TIMEOUT_MS"
|
|
22
52
|
]);
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
53
|
+
var PLIST_LABEL = "com.rulemetric.api";
|
|
54
|
+
var PLIST_PATH = join(homedir(), "Library", "LaunchAgents", `${PLIST_LABEL}.plist`);
|
|
55
|
+
var WORKER_PLIST_LABEL = "com.rulemetric.worker";
|
|
56
|
+
var WORKER_PLIST_PATH = join(homedir(), "Library", "LaunchAgents", `${WORKER_PLIST_LABEL}.plist`);
|
|
57
|
+
var GATEWAY_PLIST_LABEL = "com.rulemetric.gateway";
|
|
58
|
+
var GATEWAY_PLIST_PATH = join(homedir(), "Library", "LaunchAgents", `${GATEWAY_PLIST_LABEL}.plist`);
|
|
59
|
+
var PROXY_PLIST_LABEL = "com.rulemetric.proxy";
|
|
60
|
+
var PROXY_PLIST_PATH = join(homedir(), "Library", "LaunchAgents", `${PROXY_PLIST_LABEL}.plist`);
|
|
61
|
+
var WORKER_RESTART_PLIST_LABEL = "com.rulemetric.worker.restart";
|
|
62
|
+
var WORKER_RESTART_PLIST_PATH = join(homedir(), "Library", "LaunchAgents", `${WORKER_RESTART_PLIST_LABEL}.plist`);
|
|
63
|
+
var CONFIG_DIR = join(homedir(), ".config", "rulemetric");
|
|
64
|
+
var LOG_DIR = join(CONFIG_DIR, "logs");
|
|
65
|
+
var GATEWAY_PORT = 8787;
|
|
66
|
+
var PROXY_PORT = 8788;
|
|
67
|
+
var ServiceInstall = class _ServiceInstall extends BaseCommand {
|
|
68
|
+
static description = "Install RuleMetric API, worker, gateway, and capture proxy as persistent macOS launchd services";
|
|
69
|
+
static examples = [
|
|
70
|
+
"<%= config.bin %> service install",
|
|
71
|
+
"<%= config.bin %> service install --port 3000",
|
|
72
|
+
"<%= config.bin %> service install --skip-build",
|
|
73
|
+
"<%= config.bin %> service install --no-proxy"
|
|
74
|
+
];
|
|
75
|
+
static flags = {
|
|
76
|
+
port: Flags.integer({
|
|
77
|
+
char: "p",
|
|
78
|
+
default: 3e3,
|
|
79
|
+
description: "API server port"
|
|
80
|
+
}),
|
|
81
|
+
force: Flags.boolean({
|
|
82
|
+
char: "f",
|
|
83
|
+
default: false,
|
|
84
|
+
description: "Overwrite existing service configuration and reclaim conflicting ports"
|
|
85
|
+
}),
|
|
86
|
+
"skip-build": Flags.boolean({
|
|
87
|
+
default: false,
|
|
88
|
+
description: "Skip the pre-install workspace build (API/web/cli dist must already exist)"
|
|
89
|
+
}),
|
|
90
|
+
"no-proxy": Flags.boolean({
|
|
91
|
+
default: false,
|
|
92
|
+
description: "Skip gateway + mitmproxy plists (just install API + worker)"
|
|
93
|
+
})
|
|
94
|
+
};
|
|
95
|
+
async run() {
|
|
96
|
+
const { flags } = await this.parse(_ServiceInstall);
|
|
97
|
+
const port = flags.port;
|
|
98
|
+
const skipBuild = flags["skip-build"];
|
|
99
|
+
const noProxy = flags["no-proxy"];
|
|
100
|
+
if (process.platform !== "darwin") {
|
|
101
|
+
this.error("Service install is currently macOS-only (launchd). For Linux, use systemd manually.");
|
|
102
|
+
}
|
|
103
|
+
if (existsSync(PLIST_PATH) && !flags.force) {
|
|
104
|
+
this.log(`Service already installed at ${PLIST_PATH}`);
|
|
105
|
+
this.log("Use --force to overwrite, or run: rulemetric service status");
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
try {
|
|
109
|
+
const res = await fetch(`http://localhost:${port}/health`);
|
|
110
|
+
if (res.ok && !flags.force) {
|
|
111
|
+
this.warn(`Port ${port} is already in use (API may be running via start.sh or in another terminal).`);
|
|
112
|
+
this.warn("Stop it first with scripts/stop.sh, or use --force to take over the port.");
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
} catch {
|
|
116
|
+
}
|
|
117
|
+
const projectRoot = this.findProjectRoot();
|
|
118
|
+
if (!projectRoot) {
|
|
119
|
+
this.error(
|
|
120
|
+
"Could not find RuleMetric project root. Run this command from within the momento-mori repo, or set RULEMETRIC_PROJECT_ROOT."
|
|
121
|
+
);
|
|
122
|
+
}
|
|
123
|
+
const envLocal = join(projectRoot, ".env.local");
|
|
124
|
+
if (!existsSync(envLocal)) {
|
|
125
|
+
this.error(`.env.local not found at ${envLocal}. The API needs Supabase credentials to start.`);
|
|
126
|
+
}
|
|
127
|
+
const envVars = this.guardAlwaysOnDatabaseUrl(this.loadEnvVars(projectRoot));
|
|
128
|
+
const nodePath = this.findBinary("node");
|
|
129
|
+
const pnpmPath = this.findBinary("pnpm");
|
|
130
|
+
if (!nodePath || !pnpmPath) {
|
|
131
|
+
this.error("Could not find node or pnpm. Ensure they are in your PATH.");
|
|
132
|
+
}
|
|
133
|
+
let mitmdumpPath = null;
|
|
134
|
+
if (!noProxy) {
|
|
135
|
+
mitmdumpPath = this.findBinary("mitmdump");
|
|
136
|
+
if (!mitmdumpPath) {
|
|
137
|
+
this.error(
|
|
138
|
+
"mitmdump not found in PATH. Install with: pipx install mitmproxy (or brew install mitmproxy), then re-run.\nOr skip the capture proxy with --no-proxy."
|
|
139
|
+
);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
if (!skipBuild) {
|
|
143
|
+
this.log("[..] Building workspace artifacts (api, web, cli) via turbo...");
|
|
144
|
+
const buildFilters = [
|
|
145
|
+
"--filter",
|
|
146
|
+
"@rulemetric/api...",
|
|
147
|
+
"--filter",
|
|
148
|
+
"@rulemetric/web...",
|
|
149
|
+
"--filter",
|
|
150
|
+
"@rulemetric/cli"
|
|
151
|
+
];
|
|
152
|
+
const build = spawnSync(pnpmPath, ["exec", "turbo", "run", "build", ...buildFilters], {
|
|
153
|
+
cwd: projectRoot,
|
|
154
|
+
stdio: "inherit"
|
|
155
|
+
});
|
|
156
|
+
if (build.status !== 0) {
|
|
157
|
+
this.error(
|
|
158
|
+
`Workspace build failed (exit ${build.status}). Fix the build first, or use --skip-build if dist/ already exists.`
|
|
159
|
+
);
|
|
160
|
+
}
|
|
161
|
+
this.log("[OK] Build complete");
|
|
162
|
+
} else {
|
|
163
|
+
this.log("[..] Skipping pre-install build (--skip-build)");
|
|
164
|
+
}
|
|
165
|
+
const apiEntry = join(projectRoot, "apps", "api", "dist", "index.js");
|
|
166
|
+
if (!existsSync(apiEntry)) {
|
|
167
|
+
this.error(`API entry not found at ${apiEntry}. Re-run without --skip-build, or: pnpm --filter @rulemetric/api... build`);
|
|
168
|
+
}
|
|
169
|
+
const webIndex = join(projectRoot, "apps", "web", "dist", "index.html");
|
|
170
|
+
if (!existsSync(webIndex)) {
|
|
171
|
+
this.warn(`Web bundle not found at ${webIndex}. Dashboard at :${port} will 404 until you build apps/web.`);
|
|
172
|
+
}
|
|
173
|
+
if (!noProxy) {
|
|
174
|
+
const gatewayEntry = join(projectRoot, "apps", "cli", "dist", "lib", "gateway-entry.js");
|
|
175
|
+
if (!existsSync(gatewayEntry)) {
|
|
176
|
+
this.error(`Gateway entry not found at ${gatewayEntry}. Re-run without --skip-build, or: pnpm --filter @rulemetric/cli build`);
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
if (flags.force) {
|
|
180
|
+
this.killStaleProcess(port, null, "API on :" + port);
|
|
181
|
+
}
|
|
182
|
+
if (!noProxy) {
|
|
183
|
+
this.killStaleProcess(GATEWAY_PORT, join(CONFIG_DIR, "gateway.pid"), "gateway");
|
|
184
|
+
this.killStaleProcess(PROXY_PORT, join(CONFIG_DIR, "proxy.pid"), "mitmproxy");
|
|
185
|
+
}
|
|
186
|
+
mkdirSync(join(homedir(), "Library", "LaunchAgents"), { recursive: true });
|
|
187
|
+
mkdirSync(LOG_DIR, { recursive: true });
|
|
188
|
+
const uid = execSync("id -u", { encoding: "utf-8" }).trim();
|
|
189
|
+
const apiPlist = this.buildPlist({ port, projectRoot, nodePath, pnpmPath, envVars });
|
|
190
|
+
this.bootoutAndWrite(uid, PLIST_PATH, apiPlist, "API");
|
|
191
|
+
this.bootstrapPlist(uid, PLIST_PATH, "API");
|
|
192
|
+
this.log(`[..] Waiting for API on :${port}...`);
|
|
193
|
+
const apiStarted = await this.waitForApi(port, 15);
|
|
194
|
+
if (apiStarted) {
|
|
195
|
+
this.log(`[OK] RuleMetric API running on :${port}`);
|
|
196
|
+
if (existsSync(webIndex)) {
|
|
197
|
+
this.log(`[OK] Dashboard available at http://localhost:${port}`);
|
|
198
|
+
}
|
|
199
|
+
} else {
|
|
200
|
+
this.warn("API did not respond within 15s. Check logs:");
|
|
201
|
+
this.log(` tail -f ${LOG_DIR}/api-stdout.log`);
|
|
202
|
+
this.log(` tail -f ${LOG_DIR}/api-stderr.log`);
|
|
203
|
+
}
|
|
204
|
+
this.log("");
|
|
205
|
+
this.log("Installing worker service...");
|
|
206
|
+
this.killStaleAgents();
|
|
207
|
+
const workerPlist = this.buildWorkerPlist({ projectRoot, nodePath, pnpmPath, envVars });
|
|
208
|
+
this.bootoutAndWrite(uid, WORKER_PLIST_PATH, workerPlist, "Worker");
|
|
209
|
+
this.bootstrapPlist(uid, WORKER_PLIST_PATH, "Worker");
|
|
210
|
+
if (!noProxy) {
|
|
211
|
+
this.log("");
|
|
212
|
+
this.log("Installing gateway + capture proxy services...");
|
|
213
|
+
const gatewayPlist = this.buildGatewayPlist({ projectRoot, nodePath });
|
|
214
|
+
this.bootoutAndWrite(uid, GATEWAY_PLIST_PATH, gatewayPlist, "Gateway");
|
|
215
|
+
this.bootstrapPlist(uid, GATEWAY_PLIST_PATH, "Gateway");
|
|
216
|
+
const proxyPlist = this.buildProxyPlist({
|
|
217
|
+
projectRoot,
|
|
218
|
+
mitmdumpPath,
|
|
219
|
+
envVars
|
|
220
|
+
});
|
|
221
|
+
this.bootoutAndWrite(uid, PROXY_PLIST_PATH, proxyPlist, "Proxy");
|
|
222
|
+
this.bootstrapPlist(uid, PROXY_PLIST_PATH, "Proxy");
|
|
223
|
+
}
|
|
224
|
+
if (existsSync(WORKER_RESTART_PLIST_PATH)) {
|
|
225
|
+
try {
|
|
226
|
+
execFileSync("launchctl", ["bootout", `gui/${uid}`, WORKER_RESTART_PLIST_PATH], { encoding: "utf-8" });
|
|
227
|
+
} catch {
|
|
228
|
+
}
|
|
229
|
+
try {
|
|
230
|
+
execFileSync("rm", ["-f", WORKER_RESTART_PLIST_PATH]);
|
|
231
|
+
this.log("[OK] Removed stale daily worker-restart agent (no longer needed on agent path)");
|
|
232
|
+
} catch {
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
this.log("");
|
|
236
|
+
if (noProxy) {
|
|
237
|
+
this.log("Installed: API + worker. Gateway/proxy skipped (--no-proxy).");
|
|
238
|
+
} else {
|
|
239
|
+
this.log("Installed: API + worker + gateway + capture proxy.");
|
|
240
|
+
}
|
|
241
|
+
this.log("All services start at login, restart on crash, and pick up rebuilds via WatchPaths.");
|
|
242
|
+
this.log("");
|
|
243
|
+
this.log("NOTE: Env vars are baked in at install time. If you change");
|
|
244
|
+
this.log(".env.local or credentials, re-run: rulemetric service install --force");
|
|
245
|
+
this.log("");
|
|
246
|
+
this.log("Manage with:");
|
|
247
|
+
this.log(" rulemetric service status \u2014 check if running");
|
|
248
|
+
this.log(" rulemetric service uninstall \u2014 remove all services");
|
|
249
|
+
await bootstrapActiveOrg();
|
|
250
|
+
const tmux = await detectTmux();
|
|
251
|
+
this.log("");
|
|
252
|
+
if (tmux.available) {
|
|
253
|
+
this.log(`[OK] tmux found${tmux.version ? ` (v${tmux.version})` : ""} \u2014 live send enabled`);
|
|
254
|
+
} else {
|
|
255
|
+
this.log("[!!] tmux not found \u2014 live send will fall back to opening Terminal. Install with: brew install tmux");
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
findProjectRoot() {
|
|
259
|
+
if (process.env.RULEMETRIC_PROJECT_ROOT) {
|
|
260
|
+
return process.env.RULEMETRIC_PROJECT_ROOT;
|
|
261
|
+
}
|
|
262
|
+
let dir = process.cwd();
|
|
263
|
+
for (let i = 0; i < 10; i++) {
|
|
264
|
+
if (existsSync(join(dir, "apps", "api", "package.json"))) {
|
|
265
|
+
return dir;
|
|
266
|
+
}
|
|
267
|
+
const parent = join(dir, "..");
|
|
268
|
+
if (parent === dir) break;
|
|
269
|
+
dir = parent;
|
|
270
|
+
}
|
|
271
|
+
return null;
|
|
272
|
+
}
|
|
273
|
+
findBinary(name) {
|
|
274
|
+
try {
|
|
275
|
+
return execFileSync("which", [name], { encoding: "utf-8", stdio: ["pipe", "pipe", "ignore"] }).trim() || null;
|
|
276
|
+
} catch {
|
|
277
|
+
return null;
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
loadEnvVars(projectRoot) {
|
|
281
|
+
const vars = {};
|
|
282
|
+
const envLocal = join(projectRoot, ".env.local");
|
|
283
|
+
if (existsSync(envLocal)) {
|
|
284
|
+
for (const line of readFileSync(envLocal, "utf-8").split("\n")) {
|
|
285
|
+
const trimmed = line.trim();
|
|
286
|
+
if (!trimmed || trimmed.startsWith("#")) continue;
|
|
287
|
+
const eqIdx = trimmed.indexOf("=");
|
|
288
|
+
if (eqIdx > 0) {
|
|
289
|
+
vars[trimmed.slice(0, eqIdx)] = trimmed.slice(eqIdx + 1);
|
|
236
290
|
}
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
const globalEnv = join(CONFIG_DIR, "env");
|
|
294
|
+
if (existsSync(globalEnv)) {
|
|
295
|
+
for (const line of readFileSync(globalEnv, "utf-8").split("\n")) {
|
|
296
|
+
const trimmed = line.trim();
|
|
297
|
+
if (!trimmed || trimmed.startsWith("#")) continue;
|
|
298
|
+
const eqIdx = trimmed.indexOf("=");
|
|
299
|
+
if (eqIdx > 0) {
|
|
300
|
+
vars[trimmed.slice(0, eqIdx)] = trimmed.slice(eqIdx + 1);
|
|
247
301
|
}
|
|
248
|
-
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
return Object.fromEntries(
|
|
305
|
+
Object.entries(vars).filter(([k]) => ALLOWED_ENV_VARS.has(k))
|
|
306
|
+
);
|
|
307
|
+
}
|
|
308
|
+
// Guard: the always-on API + worker MUST use the TRANSACTION-mode pooler
|
|
309
|
+
// (port 6543). A SESSION-mode URL (:5432, 15-slot cap) baked into these
|
|
310
|
+
// services was the trigger of the recurring pool saturation — a pool-cascade
|
|
311
|
+
// debugging override leaked into the plists through this very installer. Auto-
|
|
312
|
+
// correct the obvious session→transaction port and warn loudly; warn (but do
|
|
313
|
+
// not block) on a direct, non-pooler URL. Pool-exhaustion RCA 2026-06-21.
|
|
314
|
+
guardAlwaysOnDatabaseUrl(envVars) {
|
|
315
|
+
const url = envVars.DATABASE_URL;
|
|
316
|
+
if (!url) return envVars;
|
|
317
|
+
if (url.includes("pooler.supabase.com:5432")) {
|
|
318
|
+
this.warn(
|
|
319
|
+
"DATABASE_URL points at the SESSION-mode pooler (:5432, 15-slot cap). The always-on API/worker must use TRANSACTION mode (:6543) \u2014 auto-correcting for the installed services. Fix .env.local to silence this warning."
|
|
320
|
+
);
|
|
321
|
+
return { ...envVars, DATABASE_URL: url.replace("pooler.supabase.com:5432", "pooler.supabase.com:6543") };
|
|
322
|
+
}
|
|
323
|
+
if (/@db\.[a-z0-9]+\.supabase\.co[:/]/.test(url)) {
|
|
324
|
+
this.warn(
|
|
325
|
+
"DATABASE_URL is a DIRECT database connection (db.<ref>.supabase.co), not the pooler. Always-on services should use the transaction pooler (aws-*.pooler.supabase.com:6543) to avoid exhausting Postgres connections."
|
|
326
|
+
);
|
|
249
327
|
}
|
|
250
|
-
|
|
328
|
+
return envVars;
|
|
329
|
+
}
|
|
330
|
+
// Reap orphaned, unsupervised `evals agent` worker processes before
|
|
331
|
+
// (re)bootstrapping the launchd worker. The worker holds no listening port,
|
|
332
|
+
// so killStaleProcess (port/pidfile based) cannot find detached agents — a
|
|
333
|
+
// fleet of 4 ran 3+ days and helped saturate the pool (RCA 2026-06-21). pgrep
|
|
334
|
+
// the command line and SIGTERM every match except ourselves; the agent's own
|
|
335
|
+
// single-instance lock then keeps a fresh fleet from forming.
|
|
336
|
+
killStaleAgents() {
|
|
337
|
+
try {
|
|
338
|
+
const out = execFileSync("pgrep", ["-f", "bin/run.js evals agent"], {
|
|
339
|
+
encoding: "utf-8",
|
|
340
|
+
stdio: ["ignore", "pipe", "ignore"]
|
|
341
|
+
});
|
|
342
|
+
const pids = out.trim().split("\n").filter(Boolean).map((s) => parseInt(s, 10)).filter((p) => !isNaN(p) && p !== process.pid);
|
|
343
|
+
for (const pid of pids) {
|
|
251
344
|
try {
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
catch {
|
|
255
|
-
return null;
|
|
345
|
+
process.kill(pid, "SIGTERM");
|
|
346
|
+
this.log(`[OK] Reaped orphan evals agent (PID ${pid})`);
|
|
347
|
+
} catch {
|
|
256
348
|
}
|
|
349
|
+
}
|
|
350
|
+
if (pids.length) spawnSync("sleep", ["1"], { stdio: "ignore" });
|
|
351
|
+
} catch {
|
|
257
352
|
}
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
353
|
+
}
|
|
354
|
+
// Best-effort cleanup of a process that would conflict with an
|
|
355
|
+
// about-to-bootstrap launchd plist. Tries two routes:
|
|
356
|
+
// (a) the PID file written by the legacy spawn path
|
|
357
|
+
// (gateway-lifecycle / proxy start), if pidFile is non-null
|
|
358
|
+
// (b) anything actively listening on the expected port
|
|
359
|
+
// Either way: SIGTERM + small grace + SIGKILL fallback. Stale PID file
|
|
360
|
+
// gets unlinked.
|
|
361
|
+
killStaleProcess(port, pidFile, name) {
|
|
362
|
+
let killedAny = false;
|
|
363
|
+
if (pidFile && existsSync(pidFile)) {
|
|
364
|
+
try {
|
|
365
|
+
const pidStr = readFileSync(pidFile, "utf-8").trim();
|
|
366
|
+
const pid = parseInt(pidStr, 10);
|
|
367
|
+
if (!isNaN(pid)) {
|
|
368
|
+
try {
|
|
369
|
+
process.kill(pid, "SIGTERM");
|
|
370
|
+
killedAny = true;
|
|
371
|
+
this.log(`[OK] Stopped existing ${name} (PID ${pid} from ${pidFile})`);
|
|
372
|
+
} catch {
|
|
373
|
+
}
|
|
272
374
|
}
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
375
|
+
} catch {
|
|
376
|
+
}
|
|
377
|
+
try {
|
|
378
|
+
execFileSync("rm", ["-f", pidFile]);
|
|
379
|
+
} catch {
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
try {
|
|
383
|
+
const result = execFileSync("lsof", ["-ti", `:${port}`, "-sTCP:LISTEN"], {
|
|
384
|
+
encoding: "utf-8",
|
|
385
|
+
stdio: ["ignore", "pipe", "ignore"]
|
|
386
|
+
});
|
|
387
|
+
const pids = result.trim().split("\n").filter(Boolean);
|
|
388
|
+
for (const pidStr of pids) {
|
|
389
|
+
const pid = parseInt(pidStr, 10);
|
|
390
|
+
if (!isNaN(pid)) {
|
|
391
|
+
try {
|
|
392
|
+
process.kill(pid, "SIGTERM");
|
|
393
|
+
killedAny = true;
|
|
394
|
+
this.log(`[OK] Stopped orphan on :${port} (PID ${pid})`);
|
|
395
|
+
} catch {
|
|
396
|
+
}
|
|
285
397
|
}
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
398
|
+
}
|
|
399
|
+
} catch {
|
|
400
|
+
}
|
|
401
|
+
if (killedAny) {
|
|
402
|
+
spawnSync("sleep", ["1"], { stdio: "ignore" });
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
bootoutAndWrite(uid, plistPath, content, name) {
|
|
406
|
+
const benignBootoutPatterns = [
|
|
407
|
+
"Could not find specified service",
|
|
408
|
+
"No such process",
|
|
409
|
+
"3: No such process",
|
|
410
|
+
"5: Input/output error"
|
|
411
|
+
];
|
|
412
|
+
try {
|
|
413
|
+
execFileSync("launchctl", ["bootout", `gui/${uid}`, plistPath], {
|
|
414
|
+
encoding: "utf-8",
|
|
415
|
+
// Capture stderr instead of letting it print to the user's terminal.
|
|
416
|
+
// The plist was either already-loaded (we unload it cleanly) or not
|
|
417
|
+
// loaded (we want to swallow the error) — the user shouldn't see
|
|
418
|
+
// launchctl's raw output either way.
|
|
419
|
+
stdio: ["ignore", "pipe", "pipe"]
|
|
420
|
+
});
|
|
421
|
+
this.log(`[OK] Unloaded existing ${name} service`);
|
|
422
|
+
} catch (err) {
|
|
423
|
+
const msg = err.message || "";
|
|
424
|
+
const stderr = (err.stderr ?? "").toString();
|
|
425
|
+
const combined = `${msg}
|
|
426
|
+
${stderr}`;
|
|
427
|
+
if (!benignBootoutPatterns.some((p) => combined.includes(p))) {
|
|
428
|
+
this.warn(`Could not unload existing ${name} service: ${msg.trim()}`);
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
writeFileSync(plistPath, content, { mode: 384 });
|
|
432
|
+
this.log(`[OK] ${name} plist written to ${plistPath}`);
|
|
433
|
+
}
|
|
434
|
+
bootstrapPlist(uid, plistPath, name) {
|
|
435
|
+
try {
|
|
436
|
+
execFileSync("launchctl", ["bootstrap", `gui/${uid}`, plistPath]);
|
|
437
|
+
this.log(`[OK] ${name} service loaded into launchd`);
|
|
438
|
+
} catch (bootstrapErr) {
|
|
439
|
+
try {
|
|
440
|
+
execFileSync("launchctl", ["load", plistPath]);
|
|
441
|
+
this.log(`[OK] ${name} service loaded into launchd (legacy)`);
|
|
442
|
+
} catch (loadErr) {
|
|
443
|
+
this.warn(
|
|
444
|
+
`Could not load ${name} service.
|
|
445
|
+
bootstrap: ${bootstrapErr.message.trim()}
|
|
446
|
+
load: ${loadErr.message.trim()}`
|
|
447
|
+
);
|
|
448
|
+
}
|
|
449
|
+
}
|
|
450
|
+
}
|
|
451
|
+
buildPlist(opts) {
|
|
452
|
+
const { port, projectRoot, nodePath, pnpmPath, envVars } = opts;
|
|
453
|
+
const pathDirs = [.../* @__PURE__ */ new Set([dirname(nodePath), dirname(pnpmPath), "/usr/local/bin", "/usr/bin", "/bin"])];
|
|
454
|
+
const envEntries = Object.entries({
|
|
455
|
+
...envVars,
|
|
456
|
+
PORT: String(port),
|
|
457
|
+
NODE_ENV: "production",
|
|
458
|
+
PATH: pathDirs.join(":"),
|
|
459
|
+
// Pool resilience for the always-on API (NOT the worker, which runs
|
|
460
|
+
// legitimately long analytics queries). A wedged Supavisor socket with
|
|
461
|
+
// the default max=3 pool and no query timeout hangs every authenticated
|
|
462
|
+
// request — the 2026-06-09 login-hang. statement_timeout lets Postgres
|
|
463
|
+
// cancel a stuck query so the connection returns to the pool (verified
|
|
464
|
+
// honored through the transaction pooler); the larger pool adds headroom.
|
|
465
|
+
// Both env-overridable. See packages/db/src/client.ts.
|
|
466
|
+
PG_POOL_MAX: envVars.PG_POOL_MAX ?? "10",
|
|
467
|
+
PG_STATEMENT_TIMEOUT_MS: envVars.PG_STATEMENT_TIMEOUT_MS ?? "10000",
|
|
468
|
+
// Keep the pool warm so the API stops reconnecting (and re-resolving the
|
|
469
|
+
// rotating pooler ELB) on nearly every request — the churn that exposed
|
|
470
|
+
// it to intermittent CONNECT_TIMEOUT/ENOTFOUND. Worker/tests keep the
|
|
471
|
+
// conservative 5s default. See packages/db/src/client.ts (2026-06-09).
|
|
472
|
+
PG_IDLE_TIMEOUT: envVars.PG_IDLE_TIMEOUT ?? "30",
|
|
473
|
+
// Silence per-span stdout dumps on the local API — it has no OTLP
|
|
474
|
+
// endpoint and a fixed (now rotated) log file; the ConsoleSpanExporter
|
|
475
|
+
// grew api-stdout to 370MB / ~400k spans. Fly leaves this unset so its
|
|
476
|
+
// console spans stay grep-able in the managed log stream.
|
|
477
|
+
OTEL_SPAN_EXPORT: envVars.OTEL_SPAN_EXPORT ?? "none"
|
|
478
|
+
}).map(([k, v]) => ` <key>${escapeXml(k)}</key>
|
|
479
|
+
<string>${escapeXml(v)}</string>`).join("\n");
|
|
480
|
+
const apiEntry = join(projectRoot, "apps", "api", "dist", "index.js");
|
|
481
|
+
const apiDist = join(projectRoot, "apps", "api", "dist");
|
|
482
|
+
return `<?xml version="1.0" encoding="UTF-8"?>
|
|
303
483
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
304
484
|
<plist version="1.0">
|
|
305
485
|
<dict>
|
|
@@ -308,10 +488,8 @@ export default class ServiceInstall extends BaseCommand {
|
|
|
308
488
|
|
|
309
489
|
<key>ProgramArguments</key>
|
|
310
490
|
<array>
|
|
311
|
-
<string>${escapeXml(
|
|
312
|
-
<string
|
|
313
|
-
<string>@rulemetric/api</string>
|
|
314
|
-
<string>dev</string>
|
|
491
|
+
<string>${escapeXml(nodePath)}</string>
|
|
492
|
+
<string>${escapeXml(apiEntry)}</string>
|
|
315
493
|
</array>
|
|
316
494
|
|
|
317
495
|
<key>WorkingDirectory</key>
|
|
@@ -334,40 +512,42 @@ ${envEntries}
|
|
|
334
512
|
<key>ThrottleInterval</key>
|
|
335
513
|
<integer>10</integer>
|
|
336
514
|
|
|
515
|
+
<key>WatchPaths</key>
|
|
516
|
+
<array>
|
|
517
|
+
<string>${escapeXml(apiDist)}</string>
|
|
518
|
+
</array>
|
|
519
|
+
|
|
337
520
|
<key>StandardOutPath</key>
|
|
338
|
-
<string>${escapeXml(join(LOG_DIR,
|
|
521
|
+
<string>${escapeXml(join(LOG_DIR, "api-stdout.log"))}</string>
|
|
339
522
|
|
|
340
523
|
<key>StandardErrorPath</key>
|
|
341
|
-
<string>${escapeXml(join(LOG_DIR,
|
|
524
|
+
<string>${escapeXml(join(LOG_DIR, "api-stderr.log"))}</string>
|
|
342
525
|
|
|
343
526
|
<key>ProcessType</key>
|
|
344
527
|
<string>Background</string>
|
|
345
528
|
</dict>
|
|
346
529
|
</plist>
|
|
347
530
|
`;
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
// kickstart. WatchPaths fires on any change beneath the directory.
|
|
369
|
-
const cliDist = join(projectRoot, 'apps', 'cli', 'dist');
|
|
370
|
-
return `<?xml version="1.0" encoding="UTF-8"?>
|
|
531
|
+
}
|
|
532
|
+
buildWorkerPlist(opts) {
|
|
533
|
+
const { projectRoot, nodePath, pnpmPath, envVars } = opts;
|
|
534
|
+
const pathDirs = [.../* @__PURE__ */ new Set([dirname(nodePath), dirname(pnpmPath), "/usr/local/bin", "/usr/bin", "/bin"])];
|
|
535
|
+
const envEntries = Object.entries({
|
|
536
|
+
...envVars,
|
|
537
|
+
NODE_ENV: "development",
|
|
538
|
+
PATH: pathDirs.join(":"),
|
|
539
|
+
// Bound the worker's pooler footprint. The worker is mostly idle (HTTP
|
|
540
|
+
// long-poll); an UNPINNED pool plus the previously-missing single-instance
|
|
541
|
+
// guard let an orphaned fleet of agents each hold a pool and saturate
|
|
542
|
+
// Supavisor's 200-client cap. A small pool + short idle timeout releases
|
|
543
|
+
// sessions promptly. Pool-exhaustion RCA 2026-06-21.
|
|
544
|
+
PG_POOL_MAX: envVars.PG_POOL_MAX ?? "3",
|
|
545
|
+
PG_IDLE_TIMEOUT: envVars.PG_IDLE_TIMEOUT ?? "10"
|
|
546
|
+
}).map(([k, v]) => ` <key>${escapeXml(k)}</key>
|
|
547
|
+
<string>${escapeXml(v)}</string>`).join("\n");
|
|
548
|
+
const cliBin = join(projectRoot, "apps", "cli", "bin", "run.js");
|
|
549
|
+
const cliDist = join(projectRoot, "apps", "cli", "dist");
|
|
550
|
+
return `<?xml version="1.0" encoding="UTF-8"?>
|
|
371
551
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
372
552
|
<plist version="1.0">
|
|
373
553
|
<dict>
|
|
@@ -379,7 +559,7 @@ ${envEntries}
|
|
|
379
559
|
<string>${escapeXml(nodePath)}</string>
|
|
380
560
|
<string>${escapeXml(cliBin)}</string>
|
|
381
561
|
<string>evals</string>
|
|
382
|
-
<string>
|
|
562
|
+
<string>agent</string>
|
|
383
563
|
</array>
|
|
384
564
|
|
|
385
565
|
<key>WorkingDirectory</key>
|
|
@@ -408,115 +588,169 @@ ${envEntries}
|
|
|
408
588
|
</array>
|
|
409
589
|
|
|
410
590
|
<key>StandardOutPath</key>
|
|
411
|
-
<string>${escapeXml(join(LOG_DIR,
|
|
591
|
+
<string>${escapeXml(join(LOG_DIR, "worker-stdout.log"))}</string>
|
|
412
592
|
|
|
413
593
|
<key>StandardErrorPath</key>
|
|
414
|
-
<string>${escapeXml(join(LOG_DIR,
|
|
594
|
+
<string>${escapeXml(join(LOG_DIR, "worker-stderr.log"))}</string>
|
|
415
595
|
|
|
416
596
|
<key>ProcessType</key>
|
|
417
597
|
<string>Background</string>
|
|
418
598
|
</dict>
|
|
419
599
|
</plist>
|
|
420
600
|
`;
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
601
|
+
}
|
|
602
|
+
// CONNECT-proxy router that fronts mitmproxy on :8787. Always-on so
|
|
603
|
+
// .claude/settings.json's HTTPS_PROXY pointer never resolves to a dead
|
|
604
|
+
// socket (which would break Claude Code entirely — see CLAUDE.md).
|
|
605
|
+
// NOT watched on rebuild: bouncing the gateway mid-request would drop
|
|
606
|
+
// in-flight streaming responses. Gateway code changes rarely; on
|
|
607
|
+
// upgrade, the user can `launchctl kickstart gui/<uid>/com.rulemetric.gateway`.
|
|
608
|
+
buildGatewayPlist(opts) {
|
|
609
|
+
const { projectRoot, nodePath } = opts;
|
|
610
|
+
const gatewayEntry = join(projectRoot, "apps", "cli", "dist", "lib", "gateway-entry.js");
|
|
611
|
+
const cliBin = join(projectRoot, "apps", "cli", "bin", "run.js");
|
|
612
|
+
const pathDirs = [.../* @__PURE__ */ new Set([dirname(nodePath), "/usr/local/bin", "/usr/bin", "/bin"])];
|
|
613
|
+
const env = {
|
|
614
|
+
RULEMETRIC_CLI_VERSION: this.config.version,
|
|
615
|
+
RULEMETRIC_CLI_ENTRY: cliBin,
|
|
616
|
+
PATH: pathDirs.join(":")
|
|
617
|
+
};
|
|
618
|
+
const envEntries = Object.entries(env).map(([k, v]) => ` <key>${escapeXml(k)}</key>
|
|
619
|
+
<string>${escapeXml(v)}</string>`).join("\n");
|
|
620
|
+
return `<?xml version="1.0" encoding="UTF-8"?>
|
|
440
621
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
441
622
|
<plist version="1.0">
|
|
442
623
|
<dict>
|
|
443
624
|
<key>Label</key>
|
|
444
|
-
<string>${
|
|
625
|
+
<string>${GATEWAY_PLIST_LABEL}</string>
|
|
445
626
|
|
|
446
627
|
<key>ProgramArguments</key>
|
|
447
628
|
<array>
|
|
448
|
-
<string
|
|
449
|
-
<string
|
|
450
|
-
<string>-k</string>
|
|
451
|
-
<string>gui/${escapeXml(uid)}/${WORKER_PLIST_LABEL}</string>
|
|
629
|
+
<string>${escapeXml(nodePath)}</string>
|
|
630
|
+
<string>${escapeXml(gatewayEntry)}</string>
|
|
452
631
|
</array>
|
|
453
632
|
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
633
|
+
<key>WorkingDirectory</key>
|
|
634
|
+
<string>${escapeXml(projectRoot)}</string>
|
|
635
|
+
|
|
636
|
+
<key>EnvironmentVariables</key>
|
|
637
|
+
<dict>
|
|
638
|
+
${envEntries}
|
|
639
|
+
</dict>
|
|
640
|
+
|
|
641
|
+
<key>RunAtLoad</key>
|
|
642
|
+
<true/>
|
|
643
|
+
|
|
644
|
+
<key>KeepAlive</key>
|
|
645
|
+
<dict>
|
|
646
|
+
<key>SuccessfulExit</key>
|
|
647
|
+
<false/>
|
|
648
|
+
</dict>
|
|
649
|
+
|
|
650
|
+
<key>ThrottleInterval</key>
|
|
651
|
+
<integer>10</integer>
|
|
652
|
+
|
|
653
|
+
<key>StandardOutPath</key>
|
|
654
|
+
<string>${escapeXml(join(LOG_DIR, "gateway-stdout.log"))}</string>
|
|
655
|
+
|
|
656
|
+
<key>StandardErrorPath</key>
|
|
657
|
+
<string>${escapeXml(join(LOG_DIR, "gateway-stderr.log"))}</string>
|
|
658
|
+
|
|
659
|
+
<key>ProcessType</key>
|
|
660
|
+
<string>Background</string>
|
|
661
|
+
</dict>
|
|
662
|
+
</plist>
|
|
663
|
+
`;
|
|
664
|
+
}
|
|
665
|
+
// mitmproxy with the RuleMetric capture addon. Same invocation as
|
|
666
|
+
// `rulemetric proxy start` (see commands/proxy/start.ts:308) so the
|
|
667
|
+
// launchd path and the CLI path are interchangeable. We don't WatchPath
|
|
668
|
+
// the Python addon — mitmdump has its own addon reload that handles
|
|
669
|
+
// edits without a full process restart.
|
|
670
|
+
buildProxyPlist(opts) {
|
|
671
|
+
const { projectRoot, mitmdumpPath, envVars } = opts;
|
|
672
|
+
const addonPath = join(projectRoot, "packages", "proxy", "addon", "rulemetric_addon.py");
|
|
673
|
+
const pathDirs = [.../* @__PURE__ */ new Set([dirname(mitmdumpPath), "/usr/local/bin", "/usr/bin", "/bin"])];
|
|
674
|
+
const env = {
|
|
675
|
+
...envVars,
|
|
676
|
+
RULEMETRIC_PROJECT_PATH: projectRoot,
|
|
677
|
+
RULEMETRIC_CLI_VERSION: this.config.version,
|
|
678
|
+
PATH: pathDirs.join(":")
|
|
679
|
+
};
|
|
680
|
+
const envEntries = Object.entries(env).map(([k, v]) => ` <key>${escapeXml(k)}</key>
|
|
681
|
+
<string>${escapeXml(v)}</string>`).join("\n");
|
|
682
|
+
return `<?xml version="1.0" encoding="UTF-8"?>
|
|
683
|
+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
684
|
+
<plist version="1.0">
|
|
685
|
+
<dict>
|
|
686
|
+
<key>Label</key>
|
|
687
|
+
<string>${PROXY_PLIST_LABEL}</string>
|
|
688
|
+
|
|
689
|
+
<key>ProgramArguments</key>
|
|
461
690
|
<array>
|
|
462
|
-
<
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
</
|
|
468
|
-
<
|
|
469
|
-
<key>Hour</key>
|
|
470
|
-
<integer>6</integer>
|
|
471
|
-
<key>Minute</key>
|
|
472
|
-
<integer>0</integer>
|
|
473
|
-
</dict>
|
|
474
|
-
<dict>
|
|
475
|
-
<key>Hour</key>
|
|
476
|
-
<integer>12</integer>
|
|
477
|
-
<key>Minute</key>
|
|
478
|
-
<integer>0</integer>
|
|
479
|
-
</dict>
|
|
480
|
-
<dict>
|
|
481
|
-
<key>Hour</key>
|
|
482
|
-
<integer>18</integer>
|
|
483
|
-
<key>Minute</key>
|
|
484
|
-
<integer>0</integer>
|
|
485
|
-
</dict>
|
|
691
|
+
<string>${escapeXml(mitmdumpPath)}</string>
|
|
692
|
+
<string>--listen-port</string>
|
|
693
|
+
<string>${PROXY_PORT}</string>
|
|
694
|
+
<string>-s</string>
|
|
695
|
+
<string>${escapeXml(addonPath)}</string>
|
|
696
|
+
<string>--set</string>
|
|
697
|
+
<string>console_eventlog_verbosity=info</string>
|
|
486
698
|
</array>
|
|
487
699
|
|
|
700
|
+
<key>WorkingDirectory</key>
|
|
701
|
+
<string>${escapeXml(projectRoot)}</string>
|
|
702
|
+
|
|
703
|
+
<key>EnvironmentVariables</key>
|
|
704
|
+
<dict>
|
|
705
|
+
${envEntries}
|
|
706
|
+
</dict>
|
|
707
|
+
|
|
488
708
|
<key>RunAtLoad</key>
|
|
489
|
-
<
|
|
709
|
+
<true/>
|
|
710
|
+
|
|
711
|
+
<key>KeepAlive</key>
|
|
712
|
+
<dict>
|
|
713
|
+
<key>SuccessfulExit</key>
|
|
714
|
+
<false/>
|
|
715
|
+
</dict>
|
|
716
|
+
|
|
717
|
+
<key>ThrottleInterval</key>
|
|
718
|
+
<integer>15</integer>
|
|
490
719
|
|
|
491
|
-
<key>StandardErrorPath</key>
|
|
492
|
-
<string>${escapeXml(join(LOG_DIR, 'worker-restart.log'))}</string>
|
|
493
720
|
<key>StandardOutPath</key>
|
|
494
|
-
<string>${escapeXml(join(LOG_DIR,
|
|
721
|
+
<string>${escapeXml(join(LOG_DIR, "proxy-stdout.log"))}</string>
|
|
722
|
+
|
|
723
|
+
<key>StandardErrorPath</key>
|
|
724
|
+
<string>${escapeXml(join(LOG_DIR, "proxy-stderr.log"))}</string>
|
|
725
|
+
|
|
726
|
+
<key>ProcessType</key>
|
|
727
|
+
<string>Background</string>
|
|
495
728
|
</dict>
|
|
496
729
|
</plist>
|
|
497
730
|
`;
|
|
731
|
+
}
|
|
732
|
+
async waitForApi(port, timeoutSecs) {
|
|
733
|
+
let lastError = null;
|
|
734
|
+
for (let i = 0; i < timeoutSecs; i++) {
|
|
735
|
+
try {
|
|
736
|
+
const res = await fetch(`http://localhost:${port}/health`);
|
|
737
|
+
if (res.ok) return true;
|
|
738
|
+
lastError = `health check returned ${res.status}`;
|
|
739
|
+
} catch (err) {
|
|
740
|
+
lastError = err.message;
|
|
741
|
+
}
|
|
742
|
+
await new Promise((r) => setTimeout(r, 1e3));
|
|
498
743
|
}
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
for (let i = 0; i < timeoutSecs; i++) {
|
|
502
|
-
try {
|
|
503
|
-
const res = await fetch(`http://localhost:${port}/health`);
|
|
504
|
-
if (res.ok)
|
|
505
|
-
return true;
|
|
506
|
-
lastError = `health check returned ${res.status}`;
|
|
507
|
-
}
|
|
508
|
-
catch (err) {
|
|
509
|
-
lastError = err.message;
|
|
510
|
-
}
|
|
511
|
-
await new Promise(r => setTimeout(r, 1000));
|
|
512
|
-
}
|
|
513
|
-
if (lastError) {
|
|
514
|
-
this.warn(`Last health check error: ${lastError}`);
|
|
515
|
-
}
|
|
516
|
-
return false;
|
|
744
|
+
if (lastError) {
|
|
745
|
+
this.warn(`Last health check error: ${lastError}`);
|
|
517
746
|
}
|
|
518
|
-
|
|
747
|
+
return false;
|
|
748
|
+
}
|
|
749
|
+
};
|
|
519
750
|
function escapeXml(s) {
|
|
520
|
-
|
|
751
|
+
return s.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
521
752
|
}
|
|
522
|
-
|
|
753
|
+
export {
|
|
754
|
+
ServiceInstall as default
|
|
755
|
+
};
|
|
756
|
+
//# sourceMappingURL=install.js.map
|