@rulemetric/cli 0.7.3 → 0.7.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/base-command.js +1 -14
- package/dist/chunk-2TC6WCUT.js +34 -0
- package/dist/chunk-2UC3ULIG.js +1 -0
- package/dist/chunk-3AV3GTMP.js +1 -0
- package/dist/chunk-4Z5ECCJE.js +1 -0
- package/dist/chunk-5RBLIVBF.js +1 -0
- package/dist/chunk-67QCYUJU.js +1 -0
- package/dist/chunk-6QKI756T.js +2 -0
- package/dist/chunk-6V4WM73L.js +1 -0
- package/dist/chunk-6XEC6474.js +1 -0
- package/dist/chunk-72XLQE3X.js +2 -0
- package/dist/chunk-7DFNBRLY.js +61 -0
- package/dist/chunk-7XQ4VPLC.js +2 -0
- package/dist/chunk-AHRHCERJ.js +1 -0
- package/dist/chunk-ARNZQBMX.js +1 -0
- package/dist/chunk-CADKBP3D.js +58 -0
- package/dist/chunk-CDI5CCHU.js +1 -0
- package/dist/chunk-CNQ5DTNC.js +1 -0
- package/dist/chunk-CRAKDQ4H.js +1 -0
- package/dist/chunk-DNF4HDI6.js +14 -0
- package/dist/chunk-DSO2U4Y6.js +56 -0
- package/dist/chunk-DT4GKEP5.js +5 -0
- package/dist/chunk-DVN7GFJG.js +1 -0
- package/dist/chunk-E4SFUPYR.js +15 -0
- package/dist/chunk-EUHNCVJQ.js +33 -0
- package/dist/chunk-F2VP4B4J.js +1 -0
- package/dist/chunk-FEHM5OKW.js +1 -0
- package/dist/chunk-FHVBTDBM.js +69 -0
- package/dist/chunk-GBMF3TP6.js +1 -0
- package/dist/chunk-GY5IJ4RS.js +1 -0
- package/dist/chunk-HOHD5HY2.js +5 -0
- package/dist/chunk-HP2BUPGS.js +24 -0
- package/dist/{chunk-OQBBVTDG.js → chunk-I2DZGJRR.js} +6 -71
- package/dist/chunk-I4YJ7NTX.js +1 -0
- package/dist/chunk-IY5NXR3N.js +1 -0
- package/dist/chunk-IZTIYR5Q.js +2 -0
- package/dist/chunk-KKDHD4XA.js +2 -0
- package/dist/chunk-LQRYQE6Q.js +4 -0
- package/dist/chunk-M6AJDVCL.js +5 -0
- package/dist/chunk-MGHFDHHM.js +1 -0
- package/dist/chunk-ML36XQW7.js +1 -0
- package/dist/chunk-MODXEGCU.js +1 -0
- package/dist/chunk-MVM6OGAF.js +4 -0
- package/dist/chunk-N7ODX6PO.js +1 -0
- package/dist/chunk-NBTC5FNV.js +1 -0
- package/dist/chunk-NJ5UED3H.js +1 -0
- package/dist/chunk-NVKX36YN.js +3 -0
- package/dist/chunk-NVOTOQBA.js +1 -0
- package/dist/chunk-O7ZMHCMG.js +31 -0
- package/dist/chunk-OMXUK4M6.js +1 -0
- package/dist/chunk-PZS2KOU7.js +1 -0
- package/dist/chunk-RSKQRVPJ.js +1 -0
- package/dist/chunk-RTEATXTP.js +1 -0
- package/dist/chunk-RTWRHIKY.js +7 -0
- package/dist/chunk-RVO4HV3M.js +1 -0
- package/dist/chunk-SBILN45P.js +1 -0
- package/dist/chunk-SZ62CP55.js +1 -0
- package/dist/chunk-T3W5N3BP.js +2 -0
- package/dist/chunk-TDD7IOV2.js +1 -0
- package/dist/chunk-TIQ7DQ3M.js +1 -0
- package/dist/chunk-TU2AR6XO.js +1 -0
- package/dist/chunk-UF6US7VU.js +1 -0
- package/dist/chunk-V5QFOF4F.js +9 -0
- package/dist/chunk-V5U3E4BZ.js +1 -0
- package/dist/chunk-VAFAH6QL.js +1 -0
- package/dist/chunk-VMWY7KHH.js +1 -0
- package/dist/chunk-VUGRXM7R.js +1 -0
- package/dist/{chunk-XZXS2W24.js → chunk-VWEXKDWG.js} +10 -56
- package/dist/chunk-W2MV25SB.js +1 -0
- package/dist/chunk-WJ3H73G6.js +1 -0
- package/dist/chunk-WJUQBMTF.js +9 -0
- package/dist/chunk-WLVQJH4E.js +1 -0
- package/dist/chunk-WPJ2BND4.js +1 -0
- package/dist/chunk-WSCK4WNK.js +1 -0
- package/dist/chunk-Y65CSJFF.js +3 -0
- package/dist/chunk-ZL4MZMUK.js +34 -0
- package/dist/chunk-ZLLER3HP.js +1 -0
- package/dist/chunk-ZXF5NE54.js +1 -0
- package/dist/commands/antigravity/backfill.js +2 -136
- package/dist/commands/auth/create-key.js +1 -52
- package/dist/commands/auth/login.js +1 -85
- package/dist/commands/auth/logout.js +1 -29
- package/dist/commands/auth/revoke-key.js +1 -33
- package/dist/commands/auth/signup.js +1 -89
- package/dist/commands/auth/status.js +1 -42
- package/dist/commands/catalog/index.js +2 -52
- package/dist/commands/catalog/recommend.js +3 -43
- package/dist/commands/convert.js +1 -75
- package/dist/commands/converters.js +1 -54
- package/dist/commands/crons/list.js +1 -41
- package/dist/commands/crons/run.js +2 -76
- package/dist/commands/dashboard.js +1 -46
- package/dist/commands/diagnostics.js +1 -117
- package/dist/commands/eval-targets/create.js +1 -53
- package/dist/commands/eval-targets/list.js +1 -54
- package/dist/commands/evals/agent.js +3 -310
- package/dist/commands/evals/benchmark.js +6 -73
- package/dist/commands/evals/compare.js +13 -96
- package/dist/commands/evals/create.js +1 -67
- package/dist/commands/evals/optimize-description.js +25 -239
- package/dist/commands/evals/optimize.js +5 -211
- package/dist/commands/evals/run.js +3 -183
- package/dist/commands/gateway/ensure.js +1 -104
- package/dist/commands/hooks/emit-instructions.js +1 -25
- package/dist/commands/hooks/install.js +1 -442
- package/dist/commands/hooks/run.js +3 -81
- package/dist/commands/hooks/uninstall.js +2 -156
- package/dist/commands/import.js +1 -66
- package/dist/commands/instructions/create.js +1 -74
- package/dist/commands/instructions/delete.js +1 -55
- package/dist/commands/instructions/fork.js +1 -34
- package/dist/commands/instructions/get.js +1 -68
- package/dist/commands/instructions/list.js +1 -65
- package/dist/commands/instructions/promote.js +1 -42
- package/dist/commands/instructions/pull.js +1 -39
- package/dist/commands/instructions/upstream.js +1 -38
- package/dist/commands/instructions/versions.js +1 -53
- package/dist/commands/launcher.js +1 -40
- package/dist/commands/org/current.js +1 -77
- package/dist/commands/org/list.js +1 -52
- package/dist/commands/org/switch.js +1 -71
- package/dist/commands/packs/add-instruction.js +1 -37
- package/dist/commands/packs/apply.js +1 -39
- package/dist/commands/packs/create.js +1 -50
- package/dist/commands/packs/fork.js +1 -34
- package/dist/commands/packs/get.js +3 -56
- package/dist/commands/packs/list.js +1 -66
- package/dist/commands/packs/remove-instruction.js +1 -35
- package/dist/commands/proxy/env.js +3 -131
- package/dist/commands/proxy/logs.js +3 -85
- package/dist/commands/proxy/restart.js +1 -35
- package/dist/commands/proxy/setup.js +15 -454
- package/dist/commands/proxy/start.js +10 -333
- package/dist/commands/proxy/status.js +1 -78
- package/dist/commands/proxy/stop.js +1 -94
- package/dist/commands/research/backfill.js +1 -59
- package/dist/commands/research/tail-transcript.js +1 -70
- package/dist/commands/service/install.js +57 -796
- package/dist/commands/service/status.js +1 -180
- package/dist/commands/service/uninstall.js +1 -119
- package/dist/commands/sessions/analyze.js +3 -48
- package/dist/commands/sessions/end.js +2 -85
- package/dist/commands/sessions/import.js +1 -46
- package/dist/commands/sessions/list.js +1 -48
- package/dist/commands/sessions/start.js +3 -90
- package/dist/commands/setup.js +3 -150
- package/dist/commands/skills/export-approved.js +1 -46
- package/dist/commands/skills/install.js +4 -107
- package/dist/commands/skills/list.js +4 -65
- package/dist/commands/skills/publish.js +2 -98
- package/dist/commands/skills/search.js +3 -72
- package/dist/commands/skills/update.js +3 -55
- package/dist/commands/suggestions/accept.js +8 -84
- package/dist/commands/suggestions/dismiss.js +1 -45
- package/dist/commands/suggestions/list.js +1 -61
- package/dist/commands/suggestions/refresh.js +1 -27
- package/dist/cursor-T7AMCMKS.js +13 -0
- package/dist/dashboard/Dashboard.js +1 -243
- package/dist/dashboard/data.js +1 -15
- package/dist/dashboard/launcher/ActiveJobsList.js +1 -10
- package/dist/dashboard/launcher/LauncherOverlay.js +1 -16
- package/dist/dashboard/launcher/NewLaunchForm.js +1 -10
- package/dist/dashboard/launcher/api.js +1 -16
- package/dist/dashboard/launcher/tool-labels.js +1 -10
- package/dist/dashboard/launcher/types.js +0 -1
- package/dist/dashboard/launcher/useLaunchJobs.js +1 -11
- package/dist/dashboard/panels/friction.js +1 -10
- package/dist/dashboard/panels/insights.js +1 -10
- package/dist/dashboard/panels/instructions.js +1 -10
- package/dist/dashboard/panels/outcomes.js +1 -10
- package/dist/dashboard/panels/overview.js +1 -10
- package/dist/dashboard/panels/shared.js +1 -19
- package/dist/dashboard/types.js +1 -24
- package/dist/dist-FAVALJ5C.js +1 -0
- package/dist/index.js +1 -8
- package/dist/lib/active-org-refresh.js +1 -15
- package/dist/lib/active-org.js +1 -16
- package/dist/lib/agent-loop.js +1 -47
- package/dist/lib/antigravity-transcript.js +1 -22
- package/dist/lib/api-client.js +1 -23
- package/dist/lib/auth.js +1 -30
- package/dist/lib/capture-hosts.js +1 -8
- package/dist/lib/detect-languages.js +1 -8
- package/dist/lib/detect-tmux.js +1 -9
- package/dist/lib/diagnostics.js +1 -12
- package/dist/lib/editor-proxy-pins.js +1 -14
- package/dist/lib/ensure-api-key.js +1 -11
- package/dist/lib/eval-analyzer.js +1 -9
- package/dist/lib/eval-benchmark.js +1 -12
- package/dist/lib/eval-conversation-handler.js +1 -13
- package/dist/lib/eval-executor.js +1 -8
- package/dist/lib/eval-grader.js +1 -9
- package/dist/lib/eval-meta-judge.js +1 -9
- package/dist/lib/eval-trigger-tester.js +1 -11
- package/dist/lib/eval-worktree.js +1 -8
- package/dist/lib/gateway-entry.js +1 -61
- package/dist/lib/gateway-identity.js +1 -16
- package/dist/lib/gateway-lifecycle.js +1 -32
- package/dist/lib/gateway.js +1 -14
- package/dist/lib/handlers/cron-refresh-pricing.js +1 -0
- package/dist/lib/handlers/cron-refresh-skills.js +1 -8
- package/dist/lib/handlers/cron-suggest-instructions.js +1 -16
- package/dist/lib/handlers/process-announcement.js +1 -11
- package/dist/lib/handlers/process-changelog.js +1 -11
- package/dist/lib/handlers/process-conversation.js +1 -14
- package/dist/lib/handlers/process-eval.js +1 -15
- package/dist/lib/handlers/process-insights.js +1 -15
- package/dist/lib/handlers/process-launch.js +1 -16
- package/dist/lib/handlers/process-run-cleanup.js +1 -13
- package/dist/lib/handlers/process-send-message.js +1 -10
- package/dist/lib/handlers/process-session-goal.js +1 -12
- package/dist/lib/hooks-config.js +1 -81
- package/dist/lib/insights-prompts.js +1 -12
- package/dist/lib/instruction-snapshot.js +1 -8
- package/dist/lib/job-helpers.js +0 -1
- package/dist/lib/llm-client.js +1 -20
- package/dist/lib/manual-tasks-meta.js +1 -8
- package/dist/lib/manual-tasks.js +1 -80
- package/dist/lib/output.js +1 -12
- package/dist/lib/permanent-job-error.js +1 -10
- package/dist/lib/pid-identity.js +1 -14
- package/dist/lib/proxy-respawn.js +1 -12
- package/dist/lib/research-client.js +1 -12
- package/dist/lib/setup-steps.js +1 -33
- package/dist/lib/skills-loader.js +1 -8
- package/dist/lib/statusline-shim.js +1 -20
- package/dist/lib/telemetry.js +1 -16
- package/dist/lib/terminal-target-heartbeat.js +1 -15
- package/dist/lib/tmux.js +1 -16
- package/dist/lib/transcript-rate-limit-watcher.js +1 -22
- package/dist/lib/types.js +1 -8
- package/dist/lib/version-check.js +1 -12
- package/dist/lib/which.js +1 -8
- package/dist/lib/worktree.js +1 -17
- package/dist/opencode-QRJ3BH23.js +1 -0
- package/oclif.manifest.json +135 -135
- package/package.json +9 -8
- package/dist/base-command.js.map +0 -7
- package/dist/chunk-2HK7RGZB.js +0 -82
- package/dist/chunk-2HK7RGZB.js.map +0 -7
- package/dist/chunk-2ORJWTNZ.js +0 -307
- package/dist/chunk-2ORJWTNZ.js.map +0 -7
- package/dist/chunk-37LN5O7M.js +0 -59
- package/dist/chunk-37LN5O7M.js.map +0 -7
- package/dist/chunk-3S7223UR.js +0 -81
- package/dist/chunk-3S7223UR.js.map +0 -7
- package/dist/chunk-3TIMQ3O6.js +0 -96
- package/dist/chunk-3TIMQ3O6.js.map +0 -7
- package/dist/chunk-42GFSAJP.js +0 -32
- package/dist/chunk-42GFSAJP.js.map +0 -7
- package/dist/chunk-4BHDHHKL.js +0 -48
- package/dist/chunk-4BHDHHKL.js.map +0 -7
- package/dist/chunk-4D537GXE.js +0 -99
- package/dist/chunk-4D537GXE.js.map +0 -7
- package/dist/chunk-4LYCDS2N.js +0 -139
- package/dist/chunk-4LYCDS2N.js.map +0 -7
- package/dist/chunk-4SCZK7AL.js +0 -129
- package/dist/chunk-4SCZK7AL.js.map +0 -7
- package/dist/chunk-4XAWK6S2.js +0 -161
- package/dist/chunk-4XAWK6S2.js.map +0 -7
- package/dist/chunk-52WIYRZH.js +0 -73
- package/dist/chunk-52WIYRZH.js.map +0 -7
- package/dist/chunk-5BAOGNUH.js +0 -79
- package/dist/chunk-5BAOGNUH.js.map +0 -7
- package/dist/chunk-5EDMGK3W.js +0 -39
- package/dist/chunk-5EDMGK3W.js.map +0 -7
- package/dist/chunk-6NBS5XFS.js +0 -99
- package/dist/chunk-6NBS5XFS.js.map +0 -7
- package/dist/chunk-7LVVKQMZ.js +0 -98
- package/dist/chunk-7LVVKQMZ.js.map +0 -7
- package/dist/chunk-7NNFYWKK.js +0 -243
- package/dist/chunk-7NNFYWKK.js.map +0 -7
- package/dist/chunk-7NYKWN7U.js +0 -12
- package/dist/chunk-7NYKWN7U.js.map +0 -7
- package/dist/chunk-BO76WKJR.js +0 -42
- package/dist/chunk-BO76WKJR.js.map +0 -7
- package/dist/chunk-BRD5RUGM.js +0 -53
- package/dist/chunk-BRD5RUGM.js.map +0 -7
- package/dist/chunk-BT6Z6545.js +0 -43
- package/dist/chunk-BT6Z6545.js.map +0 -7
- package/dist/chunk-BZDKEQKU.js +0 -39
- package/dist/chunk-BZDKEQKU.js.map +0 -7
- package/dist/chunk-DGHWRQXL.js +0 -17
- package/dist/chunk-DGHWRQXL.js.map +0 -7
- package/dist/chunk-DIQUV5FR.js +0 -257
- package/dist/chunk-DIQUV5FR.js.map +0 -7
- package/dist/chunk-DMX5YOTM.js +0 -167
- package/dist/chunk-DMX5YOTM.js.map +0 -7
- package/dist/chunk-DNKSVWMD.js +0 -108
- package/dist/chunk-DNKSVWMD.js.map +0 -7
- package/dist/chunk-DQ3KELXD.js +0 -74
- package/dist/chunk-DQ3KELXD.js.map +0 -7
- package/dist/chunk-DUJSRBLP.js +0 -122
- package/dist/chunk-DUJSRBLP.js.map +0 -7
- package/dist/chunk-E3BIT53W.js +0 -154
- package/dist/chunk-E3BIT53W.js.map +0 -7
- package/dist/chunk-EARWG4EV.js +0 -22
- package/dist/chunk-EARWG4EV.js.map +0 -7
- package/dist/chunk-EI5BHWXA.js +0 -1662
- package/dist/chunk-EI5BHWXA.js.map +0 -7
- package/dist/chunk-EJ3YAFDP.js +0 -37
- package/dist/chunk-EJ3YAFDP.js.map +0 -7
- package/dist/chunk-EKJ2CABV.js +0 -76
- package/dist/chunk-EKJ2CABV.js.map +0 -7
- package/dist/chunk-EKP32DLN.js +0 -16
- package/dist/chunk-EKP32DLN.js.map +0 -7
- package/dist/chunk-EYPAAGN5.js +0 -51
- package/dist/chunk-EYPAAGN5.js.map +0 -7
- package/dist/chunk-F5N6CLJJ.js +0 -1995
- package/dist/chunk-F5N6CLJJ.js.map +0 -7
- package/dist/chunk-GIUBARWS.js +0 -99
- package/dist/chunk-GIUBARWS.js.map +0 -7
- package/dist/chunk-GQNJO2P2.js +0 -102
- package/dist/chunk-GQNJO2P2.js.map +0 -7
- package/dist/chunk-IJGF2ETG.js +0 -68
- package/dist/chunk-IJGF2ETG.js.map +0 -7
- package/dist/chunk-ILYDELUE.js +0 -46
- package/dist/chunk-ILYDELUE.js.map +0 -7
- package/dist/chunk-J6QFW4LD.js +0 -55
- package/dist/chunk-J6QFW4LD.js.map +0 -7
- package/dist/chunk-J7N3DLH6.js +0 -117
- package/dist/chunk-J7N3DLH6.js.map +0 -7
- package/dist/chunk-JFDWKLQC.js +0 -23
- package/dist/chunk-JFDWKLQC.js.map +0 -7
- package/dist/chunk-JULOLTZS.js +0 -61
- package/dist/chunk-JULOLTZS.js.map +0 -7
- package/dist/chunk-KJKBDQ4D.js +0 -220
- package/dist/chunk-KJKBDQ4D.js.map +0 -7
- package/dist/chunk-KRBQLMOP.js +0 -41
- package/dist/chunk-KRBQLMOP.js.map +0 -7
- package/dist/chunk-LXKPNATC.js +0 -624
- package/dist/chunk-LXKPNATC.js.map +0 -7
- package/dist/chunk-NSBPE2FW.js +0 -17
- package/dist/chunk-NSBPE2FW.js.map +0 -7
- package/dist/chunk-OCKHW72U.js +0 -55
- package/dist/chunk-OCKHW72U.js.map +0 -7
- package/dist/chunk-OKWCKCPE.js +0 -414
- package/dist/chunk-OKWCKCPE.js.map +0 -7
- package/dist/chunk-OO7JDFS4.js +0 -157
- package/dist/chunk-OO7JDFS4.js.map +0 -7
- package/dist/chunk-OQBBVTDG.js.map +0 -7
- package/dist/chunk-OQSQC7VB.js +0 -77
- package/dist/chunk-OQSQC7VB.js.map +0 -7
- package/dist/chunk-PED7L5GX.js +0 -92
- package/dist/chunk-PED7L5GX.js.map +0 -7
- package/dist/chunk-QJQS6TUN.js +0 -44
- package/dist/chunk-QJQS6TUN.js.map +0 -7
- package/dist/chunk-QN34TGD3.js +0 -83
- package/dist/chunk-QN34TGD3.js.map +0 -7
- package/dist/chunk-QSN77T7C.js +0 -250
- package/dist/chunk-QSN77T7C.js.map +0 -7
- package/dist/chunk-R56PH7YE.js +0 -78
- package/dist/chunk-R56PH7YE.js.map +0 -7
- package/dist/chunk-RAXRZYOB.js +0 -299
- package/dist/chunk-RAXRZYOB.js.map +0 -7
- package/dist/chunk-RH7NHVSK.js +0 -16
- package/dist/chunk-RH7NHVSK.js.map +0 -7
- package/dist/chunk-RMTT4KDY.js +0 -191
- package/dist/chunk-RMTT4KDY.js.map +0 -7
- package/dist/chunk-RQ2TMLKG.js +0 -142
- package/dist/chunk-RQ2TMLKG.js.map +0 -7
- package/dist/chunk-SO3T35U7.js +0 -80
- package/dist/chunk-SO3T35U7.js.map +0 -7
- package/dist/chunk-UKMLICWS.js +0 -51
- package/dist/chunk-UKMLICWS.js.map +0 -7
- package/dist/chunk-VA5FFOS7.js +0 -243
- package/dist/chunk-VA5FFOS7.js.map +0 -7
- package/dist/chunk-W2YERO7E.js +0 -170
- package/dist/chunk-W2YERO7E.js.map +0 -7
- package/dist/chunk-W53GKIZQ.js +0 -50
- package/dist/chunk-W53GKIZQ.js.map +0 -7
- package/dist/chunk-WA4MWYRW.js +0 -254
- package/dist/chunk-WA4MWYRW.js.map +0 -7
- package/dist/chunk-XC6M4CSW.js +0 -44
- package/dist/chunk-XC6M4CSW.js.map +0 -7
- package/dist/chunk-XK42ZBDE.js +0 -23
- package/dist/chunk-XK42ZBDE.js.map +0 -7
- package/dist/chunk-XUV6DDBF.js +0 -124
- package/dist/chunk-XUV6DDBF.js.map +0 -7
- package/dist/chunk-XZXS2W24.js.map +0 -7
- package/dist/chunk-Y3WD5CSW.js +0 -49
- package/dist/chunk-Y3WD5CSW.js.map +0 -7
- package/dist/chunk-Y4BJXXYV.js +0 -148
- package/dist/chunk-Y4BJXXYV.js.map +0 -7
- package/dist/chunk-YNIH3KMU.js +0 -121
- package/dist/chunk-YNIH3KMU.js.map +0 -7
- package/dist/chunk-ZUJBM6HE.js +0 -125
- package/dist/chunk-ZUJBM6HE.js.map +0 -7
- package/dist/commands/antigravity/backfill.js.map +0 -7
- package/dist/commands/auth/create-key.js.map +0 -7
- package/dist/commands/auth/login.js.map +0 -7
- package/dist/commands/auth/logout.js.map +0 -7
- package/dist/commands/auth/revoke-key.js.map +0 -7
- package/dist/commands/auth/signup.js.map +0 -7
- package/dist/commands/auth/status.js.map +0 -7
- package/dist/commands/catalog/index.js.map +0 -7
- package/dist/commands/catalog/recommend.js.map +0 -7
- package/dist/commands/convert.js.map +0 -7
- package/dist/commands/converters.js.map +0 -7
- package/dist/commands/crons/list.js.map +0 -7
- package/dist/commands/crons/run.js.map +0 -7
- package/dist/commands/dashboard.js.map +0 -7
- package/dist/commands/diagnostics.js.map +0 -7
- package/dist/commands/eval-targets/create.js.map +0 -7
- package/dist/commands/eval-targets/list.js.map +0 -7
- package/dist/commands/evals/agent.js.map +0 -7
- package/dist/commands/evals/benchmark.js.map +0 -7
- package/dist/commands/evals/compare.js.map +0 -7
- package/dist/commands/evals/create.js.map +0 -7
- package/dist/commands/evals/optimize-description.js.map +0 -7
- package/dist/commands/evals/optimize.js.map +0 -7
- package/dist/commands/evals/run.js.map +0 -7
- package/dist/commands/gateway/ensure.js.map +0 -7
- package/dist/commands/hooks/emit-instructions.js.map +0 -7
- package/dist/commands/hooks/install.js.map +0 -7
- package/dist/commands/hooks/run.js.map +0 -7
- package/dist/commands/hooks/uninstall.js.map +0 -7
- package/dist/commands/import.js.map +0 -7
- package/dist/commands/instructions/create.js.map +0 -7
- package/dist/commands/instructions/delete.js.map +0 -7
- package/dist/commands/instructions/fork.js.map +0 -7
- package/dist/commands/instructions/get.js.map +0 -7
- package/dist/commands/instructions/list.js.map +0 -7
- package/dist/commands/instructions/promote.js.map +0 -7
- package/dist/commands/instructions/pull.js.map +0 -7
- package/dist/commands/instructions/upstream.js.map +0 -7
- package/dist/commands/instructions/versions.js.map +0 -7
- package/dist/commands/launcher.js.map +0 -7
- package/dist/commands/org/current.js.map +0 -7
- package/dist/commands/org/list.js.map +0 -7
- package/dist/commands/org/switch.js.map +0 -7
- package/dist/commands/packs/add-instruction.js.map +0 -7
- package/dist/commands/packs/apply.js.map +0 -7
- package/dist/commands/packs/create.js.map +0 -7
- package/dist/commands/packs/fork.js.map +0 -7
- package/dist/commands/packs/get.js.map +0 -7
- package/dist/commands/packs/list.js.map +0 -7
- package/dist/commands/packs/remove-instruction.js.map +0 -7
- package/dist/commands/proxy/env.js.map +0 -7
- package/dist/commands/proxy/logs.js.map +0 -7
- package/dist/commands/proxy/restart.js.map +0 -7
- package/dist/commands/proxy/setup.js.map +0 -7
- package/dist/commands/proxy/start.js.map +0 -7
- package/dist/commands/proxy/status.js.map +0 -7
- package/dist/commands/proxy/stop.js.map +0 -7
- package/dist/commands/research/backfill.js.map +0 -7
- package/dist/commands/research/tail-transcript.js.map +0 -7
- package/dist/commands/service/install.js.map +0 -7
- package/dist/commands/service/status.js.map +0 -7
- package/dist/commands/service/uninstall.js.map +0 -7
- package/dist/commands/sessions/analyze.js.map +0 -7
- package/dist/commands/sessions/end.js.map +0 -7
- package/dist/commands/sessions/import.js.map +0 -7
- package/dist/commands/sessions/list.js.map +0 -7
- package/dist/commands/sessions/start.js.map +0 -7
- package/dist/commands/setup.js.map +0 -7
- package/dist/commands/skills/export-approved.js.map +0 -7
- package/dist/commands/skills/install.js.map +0 -7
- package/dist/commands/skills/list.js.map +0 -7
- package/dist/commands/skills/publish.js.map +0 -7
- package/dist/commands/skills/search.js.map +0 -7
- package/dist/commands/skills/update.js.map +0 -7
- package/dist/commands/suggestions/accept.js.map +0 -7
- package/dist/commands/suggestions/dismiss.js.map +0 -7
- package/dist/commands/suggestions/list.js.map +0 -7
- package/dist/commands/suggestions/refresh.js.map +0 -7
- package/dist/cursor-BGQJ4CWI.js +0 -134
- package/dist/cursor-BGQJ4CWI.js.map +0 -7
- package/dist/dashboard/Dashboard.js.map +0 -7
- package/dist/dashboard/data.js.map +0 -7
- package/dist/dashboard/launcher/ActiveJobsList.js.map +0 -7
- package/dist/dashboard/launcher/LauncherOverlay.js.map +0 -7
- package/dist/dashboard/launcher/NewLaunchForm.js.map +0 -7
- package/dist/dashboard/launcher/api.js.map +0 -7
- package/dist/dashboard/launcher/tool-labels.js.map +0 -7
- package/dist/dashboard/launcher/types.js.map +0 -7
- package/dist/dashboard/launcher/useLaunchJobs.js.map +0 -7
- package/dist/dashboard/panels/friction.js.map +0 -7
- package/dist/dashboard/panels/insights.js.map +0 -7
- package/dist/dashboard/panels/instructions.js.map +0 -7
- package/dist/dashboard/panels/outcomes.js.map +0 -7
- package/dist/dashboard/panels/overview.js.map +0 -7
- package/dist/dashboard/panels/shared.js.map +0 -7
- package/dist/dashboard/types.js.map +0 -7
- package/dist/dist-UNYP5PJR.js +0 -56
- package/dist/dist-UNYP5PJR.js.map +0 -7
- package/dist/index.js.map +0 -7
- package/dist/lib/active-org-refresh.js.map +0 -7
- package/dist/lib/active-org.js.map +0 -7
- package/dist/lib/agent-loop.js.map +0 -7
- package/dist/lib/antigravity-transcript.js.map +0 -7
- package/dist/lib/api-client.js.map +0 -7
- package/dist/lib/auth.js.map +0 -7
- package/dist/lib/capture-hosts.js.map +0 -7
- package/dist/lib/detect-languages.js.map +0 -7
- package/dist/lib/detect-tmux.js.map +0 -7
- package/dist/lib/diagnostics.js.map +0 -7
- package/dist/lib/editor-proxy-pins.js.map +0 -7
- package/dist/lib/ensure-api-key.js.map +0 -7
- package/dist/lib/eval-analyzer.js.map +0 -7
- package/dist/lib/eval-benchmark.js.map +0 -7
- package/dist/lib/eval-conversation-handler.js.map +0 -7
- package/dist/lib/eval-executor.js.map +0 -7
- package/dist/lib/eval-grader.js.map +0 -7
- package/dist/lib/eval-meta-judge.js.map +0 -7
- package/dist/lib/eval-trigger-tester.js.map +0 -7
- package/dist/lib/eval-worktree.js.map +0 -7
- package/dist/lib/gateway-entry.js.map +0 -7
- package/dist/lib/gateway-identity.js.map +0 -7
- package/dist/lib/gateway-lifecycle.js.map +0 -7
- package/dist/lib/gateway.js.map +0 -7
- package/dist/lib/handlers/cron-refresh-skills.js.map +0 -7
- package/dist/lib/handlers/cron-suggest-instructions.js.map +0 -7
- package/dist/lib/handlers/process-announcement.js.map +0 -7
- package/dist/lib/handlers/process-changelog.js.map +0 -7
- package/dist/lib/handlers/process-conversation.js.map +0 -7
- package/dist/lib/handlers/process-eval.js.map +0 -7
- package/dist/lib/handlers/process-insights.js.map +0 -7
- package/dist/lib/handlers/process-launch.js.map +0 -7
- package/dist/lib/handlers/process-run-cleanup.js.map +0 -7
- package/dist/lib/handlers/process-send-message.js.map +0 -7
- package/dist/lib/handlers/process-session-goal.js.map +0 -7
- package/dist/lib/hooks-config.js.map +0 -7
- package/dist/lib/insights-prompts.js.map +0 -7
- package/dist/lib/instruction-snapshot.js.map +0 -7
- package/dist/lib/job-helpers.js.map +0 -7
- package/dist/lib/llm-client.js.map +0 -7
- package/dist/lib/manual-tasks-meta.js.map +0 -7
- package/dist/lib/manual-tasks.js.map +0 -7
- package/dist/lib/output.js.map +0 -7
- package/dist/lib/permanent-job-error.js.map +0 -7
- package/dist/lib/pid-identity.js.map +0 -7
- package/dist/lib/proxy-respawn.js.map +0 -7
- package/dist/lib/research-client.js.map +0 -7
- package/dist/lib/setup-steps.js.map +0 -7
- package/dist/lib/skills-loader.js.map +0 -7
- package/dist/lib/statusline-shim.js.map +0 -7
- package/dist/lib/telemetry.js.map +0 -7
- package/dist/lib/terminal-target-heartbeat.js.map +0 -7
- package/dist/lib/tmux.js.map +0 -7
- package/dist/lib/transcript-rate-limit-watcher.js.map +0 -7
- package/dist/lib/types.js.map +0 -7
- package/dist/lib/version-check.js.map +0 -7
- package/dist/lib/which.js.map +0 -7
- package/dist/lib/worktree.js.map +0 -7
- package/dist/opencode-IQ7X5YMJ.js +0 -190
- package/dist/opencode-IQ7X5YMJ.js.map +0 -7
package/dist/chunk-2ORJWTNZ.js
DELETED
|
@@ -1,307 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
ApiError,
|
|
3
|
-
api
|
|
4
|
-
} from "./chunk-ZUJBM6HE.js";
|
|
5
|
-
|
|
6
|
-
// src/lib/antigravity-transcript.ts
|
|
7
|
-
import { existsSync, mkdirSync, readFileSync, renameSync, rmdirSync, writeFileSync } from "node:fs";
|
|
8
|
-
import { homedir, tmpdir } from "node:os";
|
|
9
|
-
import { join } from "node:path";
|
|
10
|
-
var MAX_RECORDS_PER_FIRE = 100;
|
|
11
|
-
var TOOL_CALL_TYPES = /* @__PURE__ */ new Set([
|
|
12
|
-
"RUN_COMMAND",
|
|
13
|
-
"VIEW_FILE",
|
|
14
|
-
"LIST_DIRECTORY",
|
|
15
|
-
"CODE_ACTION",
|
|
16
|
-
"GREP_SEARCH",
|
|
17
|
-
"SEARCH_WEB"
|
|
18
|
-
]);
|
|
19
|
-
var SKIP_TYPES = /* @__PURE__ */ new Set([
|
|
20
|
-
"CONVERSATION_HISTORY",
|
|
21
|
-
"KNOWLEDGE_ARTIFACTS",
|
|
22
|
-
"CHECKPOINT"
|
|
23
|
-
]);
|
|
24
|
-
function configDir() {
|
|
25
|
-
return process.env.RULEMETRIC_CONFIG_DIR ?? join(homedir(), ".config", "rulemetric");
|
|
26
|
-
}
|
|
27
|
-
function stateDir() {
|
|
28
|
-
return join(configDir(), "antigravity-state");
|
|
29
|
-
}
|
|
30
|
-
function stateFile(conversationId) {
|
|
31
|
-
return join(stateDir(), `${conversationId}.json`);
|
|
32
|
-
}
|
|
33
|
-
function loadEnvFile() {
|
|
34
|
-
const envPath = join(configDir(), "env");
|
|
35
|
-
if (!existsSync(envPath)) return;
|
|
36
|
-
try {
|
|
37
|
-
const text = readFileSync(envPath, "utf-8");
|
|
38
|
-
for (const line of text.split(/\r?\n/)) {
|
|
39
|
-
const m = line.match(/^([A-Z_][A-Z0-9_]*)=(.*)$/);
|
|
40
|
-
if (!m) continue;
|
|
41
|
-
const key = m[1];
|
|
42
|
-
if (process.env[key] !== void 0) continue;
|
|
43
|
-
let value = m[2];
|
|
44
|
-
if (value.startsWith('"') && value.endsWith('"') || value.startsWith("'") && value.endsWith("'")) {
|
|
45
|
-
value = value.slice(1, -1);
|
|
46
|
-
}
|
|
47
|
-
process.env[key] = value;
|
|
48
|
-
}
|
|
49
|
-
} catch {
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
function loadState(conversationId) {
|
|
53
|
-
try {
|
|
54
|
-
const text = readFileSync(stateFile(conversationId), "utf-8");
|
|
55
|
-
const parsed = JSON.parse(text);
|
|
56
|
-
if (parsed && typeof parsed === "object" && "lastStepIdx" in parsed) {
|
|
57
|
-
const v = parsed.lastStepIdx;
|
|
58
|
-
if (typeof v === "number" && Number.isFinite(v)) {
|
|
59
|
-
return { lastStepIdx: v };
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
} catch {
|
|
63
|
-
}
|
|
64
|
-
return null;
|
|
65
|
-
}
|
|
66
|
-
function saveState(conversationId, state) {
|
|
67
|
-
mkdirSync(stateDir(), { recursive: true });
|
|
68
|
-
const target = stateFile(conversationId);
|
|
69
|
-
const tmpPath = `${target}.tmp`;
|
|
70
|
-
writeFileSync(tmpPath, JSON.stringify(state), { mode: 384 });
|
|
71
|
-
try {
|
|
72
|
-
renameSync(tmpPath, target);
|
|
73
|
-
} catch {
|
|
74
|
-
writeFileSync(target, JSON.stringify(state), { mode: 384 });
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
function resolveRwSessionId(externalSessionId) {
|
|
78
|
-
const tempDir = process.env.TMPDIR ?? tmpdir();
|
|
79
|
-
const rulemetricTempDir = join(tempDir, "rulemetric");
|
|
80
|
-
const path = join(rulemetricTempDir, externalSessionId);
|
|
81
|
-
try {
|
|
82
|
-
const id = readFileSync(path, "utf-8").trim();
|
|
83
|
-
return id || null;
|
|
84
|
-
} catch {
|
|
85
|
-
return null;
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
function nextSequence(externalSessionId) {
|
|
89
|
-
const tempDir = process.env.TMPDIR ?? tmpdir();
|
|
90
|
-
const rulemetricTempDir = join(tempDir, "rulemetric");
|
|
91
|
-
const seqPath = join(rulemetricTempDir, `${externalSessionId}.seq`);
|
|
92
|
-
const lockDir = join(rulemetricTempDir, `${externalSessionId}.seqlock`);
|
|
93
|
-
const deadline = Date.now() + 5e3;
|
|
94
|
-
while (Date.now() < deadline) {
|
|
95
|
-
try {
|
|
96
|
-
mkdirSync(lockDir);
|
|
97
|
-
break;
|
|
98
|
-
} catch {
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
let seq = 1;
|
|
102
|
-
try {
|
|
103
|
-
seq = parseInt(readFileSync(seqPath, "utf-8").trim(), 10) + 1;
|
|
104
|
-
if (!Number.isFinite(seq) || seq < 1) seq = 1;
|
|
105
|
-
} catch {
|
|
106
|
-
seq = 1;
|
|
107
|
-
}
|
|
108
|
-
try {
|
|
109
|
-
writeFileSync(seqPath, String(seq));
|
|
110
|
-
} catch {
|
|
111
|
-
}
|
|
112
|
-
try {
|
|
113
|
-
rmdirSync(lockDir);
|
|
114
|
-
} catch {
|
|
115
|
-
}
|
|
116
|
-
return seq;
|
|
117
|
-
}
|
|
118
|
-
function readNewRecords(transcriptPath, afterStepIdx) {
|
|
119
|
-
let text;
|
|
120
|
-
try {
|
|
121
|
-
text = readFileSync(transcriptPath, "utf-8");
|
|
122
|
-
} catch {
|
|
123
|
-
return [];
|
|
124
|
-
}
|
|
125
|
-
const out = [];
|
|
126
|
-
for (const line of text.split(/\r?\n/)) {
|
|
127
|
-
if (!line.trim()) continue;
|
|
128
|
-
try {
|
|
129
|
-
const r = JSON.parse(line);
|
|
130
|
-
if (typeof r.step_index === "number" && r.step_index > afterStepIdx) {
|
|
131
|
-
out.push(r);
|
|
132
|
-
}
|
|
133
|
-
} catch {
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
out.sort((a, b) => a.step_index - b.step_index);
|
|
137
|
-
return out;
|
|
138
|
-
}
|
|
139
|
-
function findMaxStepIndex(transcriptPath) {
|
|
140
|
-
let text;
|
|
141
|
-
try {
|
|
142
|
-
text = readFileSync(transcriptPath, "utf-8");
|
|
143
|
-
} catch {
|
|
144
|
-
return -1;
|
|
145
|
-
}
|
|
146
|
-
let max = -1;
|
|
147
|
-
for (const line of text.split(/\r?\n/)) {
|
|
148
|
-
if (!line.trim()) continue;
|
|
149
|
-
try {
|
|
150
|
-
const r = JSON.parse(line);
|
|
151
|
-
if (typeof r.step_index === "number" && r.step_index > max) max = r.step_index;
|
|
152
|
-
} catch {
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
return max;
|
|
156
|
-
}
|
|
157
|
-
function extractUserPrompt(raw) {
|
|
158
|
-
const m = raw.match(/<USER_REQUEST>\s*([\s\S]*?)\s*<\/USER_REQUEST>/);
|
|
159
|
-
return m ? m[1].trim() : raw.trim();
|
|
160
|
-
}
|
|
161
|
-
function classifyRecord(record, sequence) {
|
|
162
|
-
const timestamp = record.created_at ?? (/* @__PURE__ */ new Date()).toISOString();
|
|
163
|
-
const metadata = {
|
|
164
|
-
antigravityStepIndex: record.step_index,
|
|
165
|
-
antigravitySource: record.source,
|
|
166
|
-
antigravityType: record.type
|
|
167
|
-
};
|
|
168
|
-
if (SKIP_TYPES.has(record.type)) return null;
|
|
169
|
-
if (TOOL_CALL_TYPES.has(record.type)) return null;
|
|
170
|
-
if (record.source === "USER_EXPLICIT" && record.type === "USER_INPUT") {
|
|
171
|
-
return {
|
|
172
|
-
sequence,
|
|
173
|
-
// The events API accepts `user_message` (Claude Code's convention) but
|
|
174
|
-
// rejects `user_prompt`. Stay aligned with the existing vocabulary so
|
|
175
|
-
// the same downstream readers (insights, dashboard) light up for
|
|
176
|
-
// Antigravity sessions without API changes.
|
|
177
|
-
eventType: "user_message",
|
|
178
|
-
content: extractUserPrompt(record.content ?? ""),
|
|
179
|
-
timestamp,
|
|
180
|
-
metadata
|
|
181
|
-
};
|
|
182
|
-
}
|
|
183
|
-
if (record.source === "MODEL" && record.type === "PLANNER_RESPONSE") {
|
|
184
|
-
const parts = [];
|
|
185
|
-
if (record.thinking && record.thinking.trim()) {
|
|
186
|
-
parts.push(`[thinking]
|
|
187
|
-
${record.thinking.trim()}`);
|
|
188
|
-
}
|
|
189
|
-
if (record.content && record.content.trim()) {
|
|
190
|
-
parts.push(record.content.trim());
|
|
191
|
-
}
|
|
192
|
-
if (record.tool_calls && record.tool_calls.length > 0) {
|
|
193
|
-
metadata.antigravityToolCalls = record.tool_calls.map((tc) => tc.name).filter(Boolean);
|
|
194
|
-
}
|
|
195
|
-
return {
|
|
196
|
-
sequence,
|
|
197
|
-
eventType: "assistant_response",
|
|
198
|
-
content: parts.join("\n\n") || null,
|
|
199
|
-
timestamp,
|
|
200
|
-
metadata
|
|
201
|
-
};
|
|
202
|
-
}
|
|
203
|
-
if (record.source === "MODEL" && record.type === "GENERIC") {
|
|
204
|
-
return {
|
|
205
|
-
sequence,
|
|
206
|
-
eventType: "tool_result",
|
|
207
|
-
content: record.content ?? null,
|
|
208
|
-
timestamp,
|
|
209
|
-
metadata
|
|
210
|
-
};
|
|
211
|
-
}
|
|
212
|
-
if (record.source === "SYSTEM" && (record.type === "SYSTEM_MESSAGE" || record.type === "ERROR_MESSAGE")) {
|
|
213
|
-
return null;
|
|
214
|
-
}
|
|
215
|
-
return {
|
|
216
|
-
sequence,
|
|
217
|
-
eventType: `antigravity_${record.type.toLowerCase()}`,
|
|
218
|
-
content: record.content ?? null,
|
|
219
|
-
timestamp,
|
|
220
|
-
metadata
|
|
221
|
-
};
|
|
222
|
-
}
|
|
223
|
-
function parseHookPayload(stdin) {
|
|
224
|
-
try {
|
|
225
|
-
const parsed = JSON.parse(stdin);
|
|
226
|
-
return parsed && typeof parsed === "object" ? parsed : null;
|
|
227
|
-
} catch {
|
|
228
|
-
return null;
|
|
229
|
-
}
|
|
230
|
-
}
|
|
231
|
-
async function emitRecordsAsEvents(records, rwSessionId, conversationId, initialHighestStepIdx, options = {}) {
|
|
232
|
-
const sink = options.errorSink ?? ((line) => process.stderr.write(line));
|
|
233
|
-
let attempted = 0;
|
|
234
|
-
let emitted = 0;
|
|
235
|
-
let failed = 0;
|
|
236
|
-
let skipped = 0;
|
|
237
|
-
let highest = initialHighestStepIdx;
|
|
238
|
-
for (const record of records) {
|
|
239
|
-
attempted++;
|
|
240
|
-
options.onProgress?.({ attempted, total: records.length, record });
|
|
241
|
-
const sequence = nextSequence(conversationId);
|
|
242
|
-
const event = classifyRecord(record, sequence);
|
|
243
|
-
if (!event) {
|
|
244
|
-
skipped++;
|
|
245
|
-
} else {
|
|
246
|
-
try {
|
|
247
|
-
await api(`/api/sessions/${rwSessionId}/events`, {
|
|
248
|
-
method: "POST",
|
|
249
|
-
body: event
|
|
250
|
-
});
|
|
251
|
-
emitted++;
|
|
252
|
-
} catch (err) {
|
|
253
|
-
failed++;
|
|
254
|
-
const code = err instanceof ApiError ? err.statusCode : "unknown";
|
|
255
|
-
sink(
|
|
256
|
-
`[antigravity-tailer] failed step=${record.step_index} type=${record.type} status=${code}
|
|
257
|
-
`
|
|
258
|
-
);
|
|
259
|
-
}
|
|
260
|
-
}
|
|
261
|
-
if (record.step_index > highest) highest = record.step_index;
|
|
262
|
-
}
|
|
263
|
-
return { attempted, emitted, failed, skipped, highestStepIdx: highest };
|
|
264
|
-
}
|
|
265
|
-
async function tailAntigravityTranscript(stdin) {
|
|
266
|
-
const payload = parseHookPayload(stdin);
|
|
267
|
-
if (!payload?.conversationId || !payload?.transcriptPath) return;
|
|
268
|
-
loadEnvFile();
|
|
269
|
-
if (!process.env.RULEMETRIC_API_URL) return;
|
|
270
|
-
const rwSessionId = resolveRwSessionId(payload.conversationId);
|
|
271
|
-
if (!rwSessionId) return;
|
|
272
|
-
const existingState = loadState(payload.conversationId);
|
|
273
|
-
if (existingState === null) {
|
|
274
|
-
const primed = findMaxStepIndex(payload.transcriptPath);
|
|
275
|
-
saveState(payload.conversationId, { lastStepIdx: primed });
|
|
276
|
-
return;
|
|
277
|
-
}
|
|
278
|
-
let records = readNewRecords(payload.transcriptPath, existingState.lastStepIdx);
|
|
279
|
-
if (records.length === 0) return;
|
|
280
|
-
if (records.length > MAX_RECORDS_PER_FIRE) {
|
|
281
|
-
records = records.slice(0, MAX_RECORDS_PER_FIRE);
|
|
282
|
-
}
|
|
283
|
-
const result = await emitRecordsAsEvents(
|
|
284
|
-
records,
|
|
285
|
-
rwSessionId,
|
|
286
|
-
payload.conversationId,
|
|
287
|
-
existingState.lastStepIdx
|
|
288
|
-
);
|
|
289
|
-
saveState(payload.conversationId, { lastStepIdx: result.highestStepIdx });
|
|
290
|
-
}
|
|
291
|
-
var stateApi = {
|
|
292
|
-
load: loadState,
|
|
293
|
-
save: saveState,
|
|
294
|
-
resolveRwSessionId,
|
|
295
|
-
loadEnvFile
|
|
296
|
-
};
|
|
297
|
-
|
|
298
|
-
export {
|
|
299
|
-
readNewRecords,
|
|
300
|
-
findMaxStepIndex,
|
|
301
|
-
extractUserPrompt,
|
|
302
|
-
classifyRecord,
|
|
303
|
-
emitRecordsAsEvents,
|
|
304
|
-
tailAntigravityTranscript,
|
|
305
|
-
stateApi
|
|
306
|
-
};
|
|
307
|
-
//# sourceMappingURL=chunk-2ORJWTNZ.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../src/lib/antigravity-transcript.ts"],
|
|
4
|
-
"sourcesContent": ["// Antigravity transcript tailer.\n//\n// Antigravity fires PreToolUse/PostToolUse hooks but no UserPromptSubmit /\n// Stop hooks, and the Gemini streaming traffic bypasses the proxy entirely\n// (the language_server binary opens direct sockets to\n// generativelanguage.googleapis.com). However, every hook payload includes\n// a `transcriptPath` pointing at a JSONL file that contains the full\n// conversation: user inputs, planner responses (with thinking), tool calls,\n// and tool results \u2014 all step-indexed.\n//\n// On each post-tool-use fire we tail that file forward from the last\n// step_index we processed and emit RuleMetric events for the new records.\n\nimport { existsSync, mkdirSync, readFileSync, renameSync, rmdirSync, writeFileSync } from 'node:fs';\nimport { homedir, tmpdir } from 'node:os';\nimport { join } from 'node:path';\nimport { api, ApiError } from './api-client.js';\n\ninterface HookPayload {\n conversationId?: string;\n transcriptPath?: string;\n}\n\ninterface TranscriptRecord {\n step_index: number;\n source: 'USER_EXPLICIT' | 'SYSTEM' | 'MODEL' | string;\n type: string;\n status?: string;\n created_at?: string;\n content?: string;\n thinking?: string;\n tool_calls?: Array<{ name?: string; args?: Record<string, unknown> }>;\n error?: string;\n}\n\ninterface State {\n lastStepIdx: number;\n}\n\n// Antigravity caps hook execution at 30s. Each emitted event is one HTTP\n// POST; at ~50ms/POST a fresh session with thousands of records would blow\n// the timeout. On first fire we therefore SKIP the backlog and prime\n// state to the current transcript end \u2014 only forward-going events get\n// captured. Subsequent fires process the new tail. We also hard-cap any\n// single fire to keep the latency bounded after a pause.\nconst MAX_RECORDS_PER_FIRE = 100;\n\ninterface OutgoingEvent {\n sequence: number;\n eventType: string;\n content: string | null;\n toolName?: string | null;\n toolInput?: Record<string, unknown> | null;\n toolOutput?: Record<string, unknown> | null;\n timestamp: string;\n metadata?: Record<string, unknown>;\n}\n\n// Tool call types are already captured by the PostToolUse hook itself.\n// We skip them in the transcript pass to avoid duplicate events.\nconst TOOL_CALL_TYPES = new Set([\n 'RUN_COMMAND',\n 'VIEW_FILE',\n 'LIST_DIRECTORY',\n 'CODE_ACTION',\n 'GREP_SEARCH',\n 'SEARCH_WEB',\n]);\n\n// Housekeeping records with no user-visible content.\nconst SKIP_TYPES = new Set([\n 'CONVERSATION_HISTORY',\n 'KNOWLEDGE_ARTIFACTS',\n 'CHECKPOINT',\n]);\n\nfunction configDir(): string {\n return process.env.RULEMETRIC_CONFIG_DIR ?? join(homedir(), '.config', 'rulemetric');\n}\n\nfunction stateDir(): string {\n return join(configDir(), 'antigravity-state');\n}\n\nfunction stateFile(conversationId: string): string {\n return join(stateDir(), `${conversationId}.json`);\n}\n\nfunction loadEnvFile(): void {\n // Mirror the bash _config.sh fallback: if RULEMETRIC_API_URL / _API_KEY are\n // unset in process.env (because launchd-inherited env didn't carry them),\n // read them from ~/.config/rulemetric/env.\n const envPath = join(configDir(), 'env');\n if (!existsSync(envPath)) return;\n try {\n const text = readFileSync(envPath, 'utf-8');\n for (const line of text.split(/\\r?\\n/)) {\n const m = line.match(/^([A-Z_][A-Z0-9_]*)=(.*)$/);\n if (!m) continue;\n const key = m[1];\n // Don't override an existing value \u2014 env wins over file.\n if (process.env[key] !== undefined) continue;\n let value = m[2];\n // Strip surrounding quotes if present.\n if (\n (value.startsWith('\"') && value.endsWith('\"')) ||\n (value.startsWith(\"'\") && value.endsWith(\"'\"))\n ) {\n value = value.slice(1, -1);\n }\n process.env[key] = value;\n }\n } catch {\n // Best effort.\n }\n}\n\nfunction loadState(conversationId: string): State | null {\n try {\n const text = readFileSync(stateFile(conversationId), 'utf-8');\n const parsed = JSON.parse(text) as unknown;\n if (parsed && typeof parsed === 'object' && 'lastStepIdx' in parsed) {\n const v = (parsed as { lastStepIdx: unknown }).lastStepIdx;\n if (typeof v === 'number' && Number.isFinite(v)) {\n return { lastStepIdx: v };\n }\n }\n } catch {\n // First fire for this conversation \u2014 return null so caller can prime.\n }\n return null;\n}\n\nfunction saveState(conversationId: string, state: State): void {\n mkdirSync(stateDir(), { recursive: true });\n const target = stateFile(conversationId);\n const tmpPath = `${target}.tmp`;\n writeFileSync(tmpPath, JSON.stringify(state), { mode: 0o600 });\n try {\n renameSync(tmpPath, target);\n } catch {\n writeFileSync(target, JSON.stringify(state), { mode: 0o600 });\n }\n}\n\nfunction resolveRwSessionId(externalSessionId: string): string | null {\n // The bash hook writes the RW session UUID to $TMPDIR/rulemetric/<id>.\n const tempDir = process.env.TMPDIR ?? tmpdir();\n const rulemetricTempDir = join(tempDir, 'rulemetric');\n const path = join(rulemetricTempDir, externalSessionId);\n try {\n const id = readFileSync(path, 'utf-8').trim();\n return id || null;\n } catch {\n return null;\n }\n}\n\nfunction nextSequence(externalSessionId: string): number {\n const tempDir = process.env.TMPDIR ?? tmpdir();\n const rulemetricTempDir = join(tempDir, 'rulemetric');\n const seqPath = join(rulemetricTempDir, `${externalSessionId}.seq`);\n const lockDir = join(rulemetricTempDir, `${externalSessionId}.seqlock`);\n\n // Acquire the same mkdir-based lock the bash script uses, so seq numbers\n // remain strictly monotonic when the tailer and bash script interleave.\n const deadline = Date.now() + 5_000;\n while (Date.now() < deadline) {\n try {\n mkdirSync(lockDir);\n break;\n } catch {\n // Spin.\n }\n }\n\n let seq = 1;\n try {\n seq = parseInt(readFileSync(seqPath, 'utf-8').trim(), 10) + 1;\n if (!Number.isFinite(seq) || seq < 1) seq = 1;\n } catch {\n seq = 1;\n }\n try {\n writeFileSync(seqPath, String(seq));\n } catch {\n // ignore\n }\n try {\n rmdirSync(lockDir);\n } catch {\n // ignore\n }\n return seq;\n}\n\n/**\n * Read transcript.jsonl, parse each line as a TranscriptRecord, return only\n * records whose step_index is strictly greater than `afterStepIdx`.\n * Records with malformed JSON are silently dropped.\n */\nexport function readNewRecords(\n transcriptPath: string,\n afterStepIdx: number,\n): TranscriptRecord[] {\n let text: string;\n try {\n text = readFileSync(transcriptPath, 'utf-8');\n } catch {\n return [];\n }\n const out: TranscriptRecord[] = [];\n for (const line of text.split(/\\r?\\n/)) {\n if (!line.trim()) continue;\n try {\n const r = JSON.parse(line) as TranscriptRecord;\n if (typeof r.step_index === 'number' && r.step_index > afterStepIdx) {\n out.push(r);\n }\n } catch {\n // skip malformed lines\n }\n }\n // Defensive: keep monotonic order (transcript already is, but don't trust).\n out.sort((a, b) => a.step_index - b.step_index);\n return out;\n}\n\n/** Highest step_index present in the transcript, or -1 if empty/unreadable. */\nexport function findMaxStepIndex(transcriptPath: string): number {\n let text: string;\n try {\n text = readFileSync(transcriptPath, 'utf-8');\n } catch {\n return -1;\n }\n let max = -1;\n for (const line of text.split(/\\r?\\n/)) {\n if (!line.trim()) continue;\n try {\n const r = JSON.parse(line) as { step_index?: unknown };\n if (typeof r.step_index === 'number' && r.step_index > max) max = r.step_index;\n } catch {\n // skip\n }\n }\n return max;\n}\n\n/**\n * Strip Antigravity's <USER_REQUEST>...</USER_REQUEST> wrapper from a\n * USER_INPUT record's content. Returns the original string if no wrapper\n * is present. Some user inputs have additional non-request fragments after\n * the request block (e.g. <ADDITIONAL_CONTEXT>...) \u2014 we keep only the\n * request body since that's the actual prompt text.\n */\nexport function extractUserPrompt(raw: string): string {\n const m = raw.match(/<USER_REQUEST>\\s*([\\s\\S]*?)\\s*<\\/USER_REQUEST>/);\n return m ? m[1].trim() : raw.trim();\n}\n\n/**\n * Classify a transcript record into an outgoing RuleMetric event, or null\n * if the record should be skipped.\n */\nexport function classifyRecord(\n record: TranscriptRecord,\n sequence: number,\n): OutgoingEvent | null {\n const timestamp = record.created_at ?? new Date().toISOString();\n const metadata: Record<string, unknown> = {\n antigravityStepIndex: record.step_index,\n antigravitySource: record.source,\n antigravityType: record.type,\n };\n\n if (SKIP_TYPES.has(record.type)) return null;\n // Tool-call types are owned by the PostToolUse hook regardless of who\n // initiated them (MODEL agent calls + USER_EXPLICIT file-opens both fall\n // here). Skip in the transcript pass to avoid duplicates and fallback\n // event types the API doesn't accept.\n if (TOOL_CALL_TYPES.has(record.type)) return null;\n\n if (record.source === 'USER_EXPLICIT' && record.type === 'USER_INPUT') {\n return {\n sequence,\n // The events API accepts `user_message` (Claude Code's convention) but\n // rejects `user_prompt`. Stay aligned with the existing vocabulary so\n // the same downstream readers (insights, dashboard) light up for\n // Antigravity sessions without API changes.\n eventType: 'user_message',\n content: extractUserPrompt(record.content ?? ''),\n timestamp,\n metadata,\n };\n }\n\n if (record.source === 'MODEL' && record.type === 'PLANNER_RESPONSE') {\n const parts: string[] = [];\n if (record.thinking && record.thinking.trim()) {\n parts.push(`[thinking]\\n${record.thinking.trim()}`);\n }\n if (record.content && record.content.trim()) {\n parts.push(record.content.trim());\n }\n if (record.tool_calls && record.tool_calls.length > 0) {\n metadata.antigravityToolCalls = record.tool_calls.map((tc) => tc.name).filter(Boolean);\n }\n return {\n sequence,\n eventType: 'assistant_response',\n content: parts.join('\\n\\n') || null,\n timestamp,\n metadata,\n };\n }\n\n if (record.source === 'MODEL' && record.type === 'GENERIC') {\n return {\n sequence,\n eventType: 'tool_result',\n content: record.content ?? null,\n timestamp,\n metadata,\n };\n }\n\n if (record.source === 'SYSTEM' && (record.type === 'SYSTEM_MESSAGE' || record.type === 'ERROR_MESSAGE')) {\n // The events API doesn't currently accept a `system_message` eventType.\n // Skip rather than fabricate \u2014 these are housekeeping/error records and\n // losing them doesn't break the user-facing capture story. Revisit if\n // SYSTEM records ever carry user-relevant content.\n return null;\n }\n\n // Unknown (source, type) \u2014 keep with a generic eventType so we don't\n // lose data and can extend the classifier later from real samples.\n return {\n sequence,\n eventType: `antigravity_${record.type.toLowerCase()}`,\n content: record.content ?? null,\n timestamp,\n metadata,\n };\n}\n\nfunction parseHookPayload(stdin: string): HookPayload | null {\n try {\n const parsed = JSON.parse(stdin) as HookPayload;\n return parsed && typeof parsed === 'object' ? parsed : null;\n } catch {\n return null;\n }\n}\n\ninterface EmitResult {\n attempted: number;\n emitted: number;\n failed: number;\n skipped: number;\n highestStepIdx: number;\n}\n\ninterface EmitOptions {\n /** Called once per record processed; useful for CLI progress. */\n onProgress?: (info: { attempted: number; total: number; record: TranscriptRecord }) => void;\n /** Where to write per-failure diagnostic lines. Defaults to process.stderr. */\n errorSink?: (line: string) => void;\n}\n\n/**\n * POST a sequence of transcript records as RuleMetric events on `rwSessionId`.\n * Returns counters describing what happened. Never throws \u2014 individual POST\n * failures are reported via `errorSink` and counted as `failed`.\n *\n * The sequence number for each event is drawn from the shared per-conversation\n * counter at `$TMPDIR/rulemetric/<conversationId>.seq` (the bash hook reads\n * and writes the same file). The caller is responsible for persisting state\n * after this returns.\n */\nexport async function emitRecordsAsEvents(\n records: TranscriptRecord[],\n rwSessionId: string,\n conversationId: string,\n initialHighestStepIdx: number,\n options: EmitOptions = {},\n): Promise<EmitResult> {\n const sink = options.errorSink ?? ((line) => process.stderr.write(line));\n let attempted = 0;\n let emitted = 0;\n let failed = 0;\n let skipped = 0;\n let highest = initialHighestStepIdx;\n\n for (const record of records) {\n attempted++;\n options.onProgress?.({ attempted, total: records.length, record });\n const sequence = nextSequence(conversationId);\n const event = classifyRecord(record, sequence);\n if (!event) {\n skipped++;\n } else {\n try {\n await api(`/api/sessions/${rwSessionId}/events`, {\n method: 'POST',\n body: event,\n });\n emitted++;\n } catch (err) {\n failed++;\n const code = err instanceof ApiError ? err.statusCode : 'unknown';\n sink(\n `[antigravity-tailer] failed step=${record.step_index} type=${record.type} status=${code}\\n`,\n );\n }\n }\n if (record.step_index > highest) highest = record.step_index;\n }\n\n return { attempted, emitted, failed, skipped, highestStepIdx: highest };\n}\n\n/**\n * Tail the Antigravity transcript described by the hook payload, POSTing\n * any new events to the RuleMetric API. Never throws \u2014 best-effort, errors\n * land on stderr.\n */\nexport async function tailAntigravityTranscript(stdin: string): Promise<void> {\n const payload = parseHookPayload(stdin);\n if (!payload?.conversationId || !payload?.transcriptPath) return;\n\n loadEnvFile();\n if (!process.env.RULEMETRIC_API_URL) return;\n\n const rwSessionId = resolveRwSessionId(payload.conversationId);\n if (!rwSessionId) return;\n\n const existingState = loadState(payload.conversationId);\n if (existingState === null) {\n // First fire for this conversation. Prime state to the current end of\n // the transcript instead of replaying history through 800+ HTTP POSTs \u2014\n // that would blow Antigravity's 30s hook timeout. Capture is\n // forward-only from the moment hooks are installed for a conversation.\n // Use `rulemetric antigravity backfill` to seed historical events.\n const primed = findMaxStepIndex(payload.transcriptPath);\n saveState(payload.conversationId, { lastStepIdx: primed });\n return;\n }\n\n let records = readNewRecords(payload.transcriptPath, existingState.lastStepIdx);\n if (records.length === 0) return;\n if (records.length > MAX_RECORDS_PER_FIRE) {\n records = records.slice(0, MAX_RECORDS_PER_FIRE);\n }\n\n const result = await emitRecordsAsEvents(\n records,\n rwSessionId,\n payload.conversationId,\n existingState.lastStepIdx,\n );\n saveState(payload.conversationId, { lastStepIdx: result.highestStepIdx });\n}\n\n/**\n * Helpers exposed for the backfill command. Re-exporting from one place so\n * the command surface stays decoupled from filesystem layout.\n */\nexport const stateApi = {\n load: loadState,\n save: saveState,\n resolveRwSessionId,\n loadEnvFile,\n};\n"],
|
|
5
|
-
"mappings": ";;;;;;AAaA,SAAS,YAAY,WAAW,cAAc,YAAY,WAAW,qBAAqB;AAC1F,SAAS,SAAS,cAAc;AAChC,SAAS,YAAY;AA8BrB,IAAM,uBAAuB;AAe7B,IAAM,kBAAkB,oBAAI,IAAI;AAAA,EAC9B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,CAAC;AAGD,IAAM,aAAa,oBAAI,IAAI;AAAA,EACzB;AAAA,EACA;AAAA,EACA;AACF,CAAC;AA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AAI,mBAAoB;AAErC,QAAM,cAAc,mBAAmB,QAAQ,cAAc;AAC7D,MAAI,CAAC,YAAa;AAElB,QAAM,gBAAgB,UAAU,QAAQ,cAAc;AACtD,MAAI,kBAAkB,MAAM;AAM1B,UAAM,SAAS,iBAAiB,QAAQ,cAAc;AACtD,cAAU,QAAQ,gBAAgB,EAAE,aAAa,OAAO,CAAC;AACzD;AAAA,EACF;AAEA,MAAI,UAAU,eAAe,QAAQ,gBAAgB,cAAc,WAAW;AAC9E,MAAI,QAAQ,WAAW,EAAG;AAC1B,MAAI,QAAQ,SAAS,sBAAsB;AACzC,cAAU,QAAQ,MAAM,GAAG,oBAAoB;AAAA,EACjD;AAEA,QAAM,SAAS,MAAM;AAAA,IACnB;AAAA,IACA;AAAA,IACA,QAAQ;AAAA,IACR,cAAc;AAAA,EAChB;AACA,YAAU,QAAQ,gBAAgB,EAAE,aAAa,OAAO,eAAe,CAAC;AAC1E;AAMO,IAAM,WAAW;AAAA,EACtB,MAAM;AAAA,EACN,MAAM;AAAA,EACN;AAAA,EACA;AACF;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
package/dist/chunk-37LN5O7M.js
DELETED
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
clearActiveOrg,
|
|
3
|
-
isStale,
|
|
4
|
-
readActiveOrg,
|
|
5
|
-
writeActiveOrg
|
|
6
|
-
} from "./chunk-EKJ2CABV.js";
|
|
7
|
-
import {
|
|
8
|
-
apiGet
|
|
9
|
-
} from "./chunk-ZUJBM6HE.js";
|
|
10
|
-
|
|
11
|
-
// src/lib/active-org-refresh.ts
|
|
12
|
-
var attempted = false;
|
|
13
|
-
async function syncActiveOrgFromServer() {
|
|
14
|
-
if (process.env.RULEMETRIC_ORG_ID) return;
|
|
15
|
-
const cached = readActiveOrg();
|
|
16
|
-
if (cached && !isStale(cached)) return;
|
|
17
|
-
try {
|
|
18
|
-
const profile = await apiGet("/api/profile");
|
|
19
|
-
if (!profile.activeOrgId) {
|
|
20
|
-
clearActiveOrg();
|
|
21
|
-
return;
|
|
22
|
-
}
|
|
23
|
-
if (cached && profile.activeOrgId === cached.orgId) {
|
|
24
|
-
writeActiveOrg({
|
|
25
|
-
orgId: cached.orgId,
|
|
26
|
-
orgSlug: cached.orgSlug,
|
|
27
|
-
syncedAt: Date.now()
|
|
28
|
-
});
|
|
29
|
-
return;
|
|
30
|
-
}
|
|
31
|
-
const orgs = await apiGet("/api/orgs");
|
|
32
|
-
const match = orgs.find((o) => o.id === profile.activeOrgId);
|
|
33
|
-
writeActiveOrg({
|
|
34
|
-
orgId: profile.activeOrgId,
|
|
35
|
-
orgSlug: match?.slug,
|
|
36
|
-
syncedAt: Date.now()
|
|
37
|
-
});
|
|
38
|
-
} catch {
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
async function maybeRefreshActiveOrg() {
|
|
42
|
-
if (attempted) return;
|
|
43
|
-
attempted = true;
|
|
44
|
-
await syncActiveOrgFromServer();
|
|
45
|
-
}
|
|
46
|
-
async function bootstrapActiveOrg() {
|
|
47
|
-
attempted = true;
|
|
48
|
-
await syncActiveOrgFromServer();
|
|
49
|
-
}
|
|
50
|
-
function _resetRefreshAttempt() {
|
|
51
|
-
attempted = false;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
export {
|
|
55
|
-
maybeRefreshActiveOrg,
|
|
56
|
-
bootstrapActiveOrg,
|
|
57
|
-
_resetRefreshAttempt
|
|
58
|
-
};
|
|
59
|
-
//# sourceMappingURL=chunk-37LN5O7M.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../src/lib/active-org-refresh.ts"],
|
|
4
|
-
"sourcesContent": ["import { apiGet } from './api-client.js';\nimport {\n readActiveOrg,\n writeActiveOrg,\n clearActiveOrg,\n isStale,\n} from './active-org.js';\n\ninterface ProfileResponse {\n id: string;\n email: string | null;\n displayName: string | null;\n activeOrgId: string | null;\n}\n\ninterface OrgListItem {\n id: string;\n name: string;\n slug: string;\n role: string;\n}\n\n/**\n * Module-level guard so we only refresh once per CLI invocation, even if\n * `BaseCommand.init` runs multiple times across nested commands or tests.\n */\nlet attempted = false;\n\n/**\n * Opportunistically reconcile the local active-org cache with the server.\n *\n * Runs in three cases:\n * 1. Cache file is ABSENT (bootstrap) \u2014 populate from `/api/profile`. This\n * branch is load-bearing: without it, a user who never explicitly ran\n * `rulemetric org switch` would have hook captures with `org_id=NULL`\n * forever, even when the server already has `profiles.active_org_id`\n * set (e.g. switched via the web UI, or auto-set by the handle_new_user\n * trigger from migration 00067). Caught 2026-05-25 after an audit found\n * 244 hook sessions over 14 days all missing org_id.\n * 2. Cache file exists but is stale (>5min) \u2014 re-sync from the server.\n * 3. Env override is set OR cache is fresh \u2014 no-op, zero network.\n *\n * Failures are intentionally swallowed: this is a background nicety, not a\n * gating step. The next API call the user actually invoked will surface\n * any auth/network errors with clearer messaging than a refresh failure\n * could. Capture-time fallback to `profiles.active_org_id` at\n * `apps/api/src/routes/sessions.ts:48` is the final safety net.\n */\n/**\n * Internal: fetch profile + (if needed) orgs, then write/clear the cache.\n * Shared body for both `maybeRefreshActiveOrg` (guarded, used by every CLI\n * command via BaseCommand) and `bootstrapActiveOrg` (unguarded, used by\n * lifecycle commands that just wrote auth/install state and want the cache\n * to reflect it before they exit).\n */\nasync function syncActiveOrgFromServer(): Promise<void> {\n // Env override: caller has explicitly chosen the org. Don't write the\n // file \u2014 env should be ephemeral.\n if (process.env.RULEMETRIC_ORG_ID) return;\n\n const cached = readActiveOrg();\n // Only skip when we have a fresh cache. Missing cache (cached === null)\n // and stale cache both fall through to the refresh path below.\n if (cached && !isStale(cached)) return;\n\n try {\n const profile = await apiGet<ProfileResponse>('/api/profile');\n\n if (!profile.activeOrgId) {\n // Server has no active org \u2014 drop the local cache (if any).\n clearActiveOrg();\n return;\n }\n\n if (cached && profile.activeOrgId === cached.orgId) {\n // Same id \u2014 just bump syncedAt so we don't re-fetch every command.\n writeActiveOrg({\n orgId: cached.orgId,\n orgSlug: cached.orgSlug,\n syncedAt: Date.now(),\n });\n return;\n }\n\n // Either bootstrapping fresh (no cache) OR the server changed the active\n // org out from under us (e.g. via web UI). Look up the slug for the id\n // and (re)write the cache.\n const orgs = await apiGet<OrgListItem[]>('/api/orgs');\n const match = orgs.find((o) => o.id === profile.activeOrgId);\n writeActiveOrg({\n orgId: profile.activeOrgId,\n orgSlug: match?.slug,\n syncedAt: Date.now(),\n });\n } catch {\n // Swallow \u2014 leave the old cache intact. The user's actual command will\n // surface the real error if any.\n }\n}\n\nexport async function maybeRefreshActiveOrg(): Promise<void> {\n if (attempted) return;\n attempted = true;\n await syncActiveOrgFromServer();\n}\n\n/**\n * Explicit, guard-bypassing version of the refresh. Use ONLY from commands\n * where the user just took an action that changes auth/install state and we\n * want the cache to reflect it before the command exits:\n *\n * - After `auth login`: BaseCommand.init fired the guarded refresh BEFORE\n * credentials existed and got a 401; we need to retry post-login.\n * - After `hooks install` / `service install`: belt-and-suspenders so the\n * first Claude Code session after install has a populated cache, even\n * if BaseCommand's earlier refresh hit a transient error.\n *\n * Marks `attempted = true` after running so a redundant `maybeRefreshActiveOrg`\n * call later in the same process is a no-op.\n */\nexport async function bootstrapActiveOrg(): Promise<void> {\n attempted = true;\n await syncActiveOrgFromServer();\n}\n\n/**\n * Test hook \u2014 reset the once-per-process guard so each test can exercise\n * the refresh logic.\n */\nexport function _resetRefreshAttempt(): void {\n attempted = false;\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;AA0BA,IAAI,YAAY;AA6BhB,eAAe,0BAAyC;AAGtD,MAAI,QAAQ,IAAI,kBAAmB;AAEnC,QAAM,SAAS,cAAc;AAG7B,MAAI,UAAU,CAAC,QAAQ,MAAM,EAAG;AAEhC,MAAI;AACF,UAAM,UAAU,MAAM,OAAwB,cAAc;AAE5D,QAAI,CAAC,QAAQ,aAAa;AAExB,qBAAe;AACf;AAAA,IACF;AAEA,QAAI,UAAU,QAAQ,gBAAgB,OAAO,OAAO;AAElD,qBAAe;AAAA,QACb,OAAO,OAAO;AAAA,QACd,SAAS,OAAO;AAAA,QAChB,UAAU,KAAK,IAAI;AAAA,MACrB,CAAC;AACD;AAAA,IACF;AAKA,UAAM,OAAO,MAAM,OAAsB,WAAW;AACpD,UAAM,QAAQ,KAAK,KAAK,CAAC,MAAM,EAAE,OAAO,QAAQ,WAAW;AAC3D,mBAAe;AAAA,MACb,OAAO,QAAQ;AAAA,MACf,SAAS,OAAO;AAAA,MAChB,UAAU,KAAK,IAAI;AAAA,IACrB,CAAC;AAAA,EACH,QAAQ;AAAA,EAGR;AACF;AAEA,eAAsB,wBAAuC;AAC3D,MAAI,UAAW;AACf,cAAY;AACZ,QAAM,wBAAwB;AAChC;AAgBA,eAAsB,qBAAoC;AACxD,cAAY;AACZ,QAAM,wBAAwB;AAChC;AAMO,SAAS,uBAA6B;AAC3C,cAAY;AACd;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
package/dist/chunk-3S7223UR.js
DELETED
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
getCursorUserSettingsPath,
|
|
3
|
-
getVSCodeUserSettingsPath
|
|
4
|
-
} from "./chunk-LXKPNATC.js";
|
|
5
|
-
|
|
6
|
-
// src/lib/editor-proxy-pins.ts
|
|
7
|
-
import { existsSync, readFileSync, unlinkSync, writeFileSync } from "node:fs";
|
|
8
|
-
import { homedir } from "node:os";
|
|
9
|
-
import { join } from "node:path";
|
|
10
|
-
function defaultEditorPinPaths() {
|
|
11
|
-
return {
|
|
12
|
-
vscode: getVSCodeUserSettingsPath(),
|
|
13
|
-
cursor: getCursorUserSettingsPath(),
|
|
14
|
-
marker: join(homedir(), ".config", "rulemetric", "editor-proxy-unpinned.json")
|
|
15
|
-
};
|
|
16
|
-
}
|
|
17
|
-
function isOurProxyValue(value, gatewayPort) {
|
|
18
|
-
return value === `http://localhost:${gatewayPort}` || value === `http://127.0.0.1:${gatewayPort}`;
|
|
19
|
-
}
|
|
20
|
-
function readSettings(path) {
|
|
21
|
-
if (!existsSync(path)) return null;
|
|
22
|
-
try {
|
|
23
|
-
return JSON.parse(readFileSync(path, "utf-8"));
|
|
24
|
-
} catch {
|
|
25
|
-
return null;
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
function unpinEditorProxies(gatewayPort, paths = defaultEditorPinPaths()) {
|
|
29
|
-
const unpinned = [];
|
|
30
|
-
for (const editor of ["vscode", "cursor"]) {
|
|
31
|
-
const path = paths[editor];
|
|
32
|
-
const settings = readSettings(path);
|
|
33
|
-
if (!settings || !isOurProxyValue(settings["http.proxy"], gatewayPort)) continue;
|
|
34
|
-
delete settings["http.proxy"];
|
|
35
|
-
if (settings["http.proxyStrictSSL"] === false) {
|
|
36
|
-
delete settings["http.proxyStrictSSL"];
|
|
37
|
-
}
|
|
38
|
-
try {
|
|
39
|
-
writeFileSync(path, JSON.stringify(settings, null, 2) + "\n");
|
|
40
|
-
unpinned.push(editor);
|
|
41
|
-
} catch {
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
if (unpinned.length > 0) {
|
|
45
|
-
const prior = readSettings(paths.marker);
|
|
46
|
-
const editors = [.../* @__PURE__ */ new Set([...prior?.editors ?? [], ...unpinned])];
|
|
47
|
-
try {
|
|
48
|
-
writeFileSync(
|
|
49
|
-
paths.marker,
|
|
50
|
-
JSON.stringify({ editors, gatewayPort, unpinnedAt: (/* @__PURE__ */ new Date()).toISOString() }, null, 2) + "\n"
|
|
51
|
-
);
|
|
52
|
-
} catch {
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
return unpinned;
|
|
56
|
-
}
|
|
57
|
-
function repinEditorProxies(writePin, paths = defaultEditorPinPaths()) {
|
|
58
|
-
const marker = readSettings(paths.marker);
|
|
59
|
-
if (!marker || !Array.isArray(marker.editors)) return [];
|
|
60
|
-
const repinned = [];
|
|
61
|
-
for (const editor of marker.editors) {
|
|
62
|
-
if (editor !== "vscode" && editor !== "cursor") continue;
|
|
63
|
-
try {
|
|
64
|
-
writePin(editor);
|
|
65
|
-
repinned.push(editor);
|
|
66
|
-
} catch {
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
try {
|
|
70
|
-
unlinkSync(paths.marker);
|
|
71
|
-
} catch {
|
|
72
|
-
}
|
|
73
|
-
return repinned;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
export {
|
|
77
|
-
defaultEditorPinPaths,
|
|
78
|
-
unpinEditorProxies,
|
|
79
|
-
repinEditorProxies
|
|
80
|
-
};
|
|
81
|
-
//# sourceMappingURL=chunk-3S7223UR.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../src/lib/editor-proxy-pins.ts"],
|
|
4
|
-
"sourcesContent": ["import { existsSync, readFileSync, unlinkSync, writeFileSync } from 'node:fs';\nimport { homedir } from 'node:os';\nimport { join } from 'node:path';\nimport { getVSCodeUserSettingsPath, getCursorUserSettingsPath } from './hooks-config.js';\n\n/**\n * Editor proxy pin lifecycle for a DEAD/unownable gateway.\n *\n * `hooks install` pins `http.proxy` (+ `http.proxyStrictSSL: false`) into\n * VS Code and Cursor USER-level settings so Copilot/Cursor traffic routes\n * through the capture gateway. Those pins outlive the gateway: after a crash\n * that can't self-heal \u2014 most importantly a FOREIGN process owning :8787 \u2014\n * the editors keep routing HTTP at a port we don't control, with strictSSL\n * off. `gateway ensure` (run on every session start) calls `unpin` in that\n * state and `repin` once the gateway is verifiably ours again.\n *\n * Ownership predicate is strict: `http.proxy` is only ever removed when it\n * points at OUR gateway port on localhost \u2014 a user-owned corporate proxy is\n * never touched (same discipline as removeRulemetricProxyEnv). What was\n * unpinned is recorded in a marker file so repin restores exactly that set,\n * and never manufactures a pin the user removed themselves.\n */\n\nexport interface EditorPinPaths {\n vscode: string;\n cursor: string;\n marker: string;\n}\n\nexport function defaultEditorPinPaths(): EditorPinPaths {\n return {\n vscode: getVSCodeUserSettingsPath(),\n cursor: getCursorUserSettingsPath(),\n marker: join(homedir(), '.config', 'rulemetric', 'editor-proxy-unpinned.json'),\n };\n}\n\nfunction isOurProxyValue(value: unknown, gatewayPort: number): boolean {\n return (\n value === `http://localhost:${gatewayPort}` ||\n value === `http://127.0.0.1:${gatewayPort}`\n );\n}\n\nfunction readSettings(path: string): Record<string, unknown> | null {\n if (!existsSync(path)) return null;\n try {\n return JSON.parse(readFileSync(path, 'utf-8')) as Record<string, unknown>;\n } catch {\n return null; // JSONC/corrupt \u2014 never risk clobbering a user's editor config\n }\n}\n\n/**\n * Remove our gateway pin from each editor's user settings. Returns the list\n * of editors actually unpinned and records them in the marker (merging with\n * a prior marker so repeated unpins don't lose state).\n */\nexport function unpinEditorProxies(\n gatewayPort: number,\n paths: EditorPinPaths = defaultEditorPinPaths(),\n): Array<'vscode' | 'cursor'> {\n const unpinned: Array<'vscode' | 'cursor'> = [];\n for (const editor of ['vscode', 'cursor'] as const) {\n const path = paths[editor];\n const settings = readSettings(path);\n if (!settings || !isOurProxyValue(settings['http.proxy'], gatewayPort)) continue;\n delete settings['http.proxy'];\n // strictSSL rides along with our pin; only strip it when the pin was ours\n // (checked above) AND it holds the value we wrote.\n if (settings['http.proxyStrictSSL'] === false) {\n delete settings['http.proxyStrictSSL'];\n }\n try {\n writeFileSync(path, JSON.stringify(settings, null, 2) + '\\n');\n unpinned.push(editor);\n } catch {\n /* editor settings not writable \u2014 leave as-is */\n }\n }\n if (unpinned.length > 0) {\n const prior = readSettings(paths.marker) as { editors?: string[] } | null;\n const editors = [...new Set([...(prior?.editors ?? []), ...unpinned])];\n try {\n writeFileSync(\n paths.marker,\n JSON.stringify({ editors, gatewayPort, unpinnedAt: new Date().toISOString() }, null, 2) + '\\n',\n );\n } catch {\n /* marker write failure only costs a future auto-repin */\n }\n }\n return unpinned;\n}\n\n/**\n * Restore pins for exactly the editors a previous unpin removed (per the\n * marker), then clear the marker. `writePin` is injected by the caller\n * (writeVSCodeUserProxyConfig / writeCursorUserProxyConfig) \u2014 those writers\n * already refuse to overwrite a user-owned non-localhost proxy.\n */\nexport function repinEditorProxies(\n writePin: (editor: 'vscode' | 'cursor') => void,\n paths: EditorPinPaths = defaultEditorPinPaths(),\n): Array<'vscode' | 'cursor'> {\n const marker = readSettings(paths.marker) as { editors?: unknown } | null;\n if (!marker || !Array.isArray(marker.editors)) return [];\n const repinned: Array<'vscode' | 'cursor'> = [];\n for (const editor of marker.editors) {\n if (editor !== 'vscode' && editor !== 'cursor') continue;\n try {\n writePin(editor);\n repinned.push(editor);\n } catch {\n /* best-effort \u2014 a failed repin keeps the marker below */\n }\n }\n try {\n unlinkSync(paths.marker);\n } catch {\n /* already gone */\n }\n return repinned;\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;AAAA,SAAS,YAAY,cAAc,YAAY,qBAAqB;AACpE,SAAS,eAAe;AACxB,SAAS,YAAY;AA2Bd,SAAS,wBAAwC;AACtD,SAAO;AAAA,IACL,QAAQ,0BAA0B;AAAA,IAClC,QAAQ,0BAA0B;AAAA,IAClC,QAAQ,KAAK,QAAQ,GAAG,WAAW,cAAc,4BAA4B;AAAA,EAC/E;AACF;AAEA,SAAS,gBAAgB,OAAgB,aAA8B;AACrE,SACE,UAAU,oBAAoB,WAAW,MACzC,UAAU,oBAAoB,WAAW;AAE7C;AAEA,SAAS,aAAa,MAA8C;AAClE,MAAI,CAAC,WAAW,IAAI,EAAG,QAAO;AAC9B,MAAI;AACF,WAAO,KAAK,MAAM,aAAa,MAAM,OAAO,CAAC;AAAA,EAC/C,QAAQ;AACN,WAAO;AAAA,EACT;AACF;AAOO,SAAS,mBACd,aACA,QAAwB,sBAAsB,GAClB;AAC5B,QAAM,WAAuC,CAAC;AAC9C,aAAW,UAAU,CAAC,UAAU,QAAQ,GAAY;AAClD,UAAM,OAAO,MAAM,MAAM;AACzB,UAAM,WAAW,aAAa,IAAI;AAClC,QAAI,CAAC,YAAY,CAAC,gBAAg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|
4
|
-
|
|
5
|
-
// src/lib/eval-analyzer.ts
|
|
6
|
-
var ANALYZER_SYSTEM_PROMPT = `You are an expert at improving AI coding instructions, skills, and prompts. You receive eval results showing how well the current content performs, and your job is to propose specific improvements.
|
|
7
|
-
|
|
8
|
-
You will receive:
|
|
9
|
-
1. The current content of the eval target
|
|
10
|
-
2. Eval results: for each eval, the prompt, expectations, pass/fail results, and grader feedback
|
|
11
|
-
3. The pass rate and areas of weakness
|
|
12
|
-
|
|
13
|
-
Analyze the failures and propose concrete edits to improve the content. Focus on:
|
|
14
|
-
- Expectations that consistently fail \u2014 what's missing from the content?
|
|
15
|
-
- Grader feedback suggesting new assertions \u2014 what outcomes aren't being tested?
|
|
16
|
-
- Patterns across failures \u2014 is there a systemic gap?
|
|
17
|
-
|
|
18
|
-
Your proposed content should be a complete replacement, not a diff. Keep what works, fix what doesn't.
|
|
19
|
-
|
|
20
|
-
You MUST respond with ONLY a valid JSON object:
|
|
21
|
-
|
|
22
|
-
{
|
|
23
|
-
"suggestions": [
|
|
24
|
-
{
|
|
25
|
-
"section": "which part of the content",
|
|
26
|
-
"current": "brief quote of current text",
|
|
27
|
-
"proposed": "what it should say instead",
|
|
28
|
-
"reasoning": "why this change helps"
|
|
29
|
-
}
|
|
30
|
-
],
|
|
31
|
-
"overallAssessment": "brief summary of what's working and what's not",
|
|
32
|
-
"proposedContent": "the full improved content"
|
|
33
|
-
}`;
|
|
34
|
-
async function analyzeEvalResults(options) {
|
|
35
|
-
const { content, evalResults, model, timeout = 12e4, userFeedback } = options;
|
|
36
|
-
const resultsText = evalResults.map((r) => {
|
|
37
|
-
const grading = r.grading;
|
|
38
|
-
const expectations = grading?.expectations ?? [];
|
|
39
|
-
const passRate = grading?.summary?.pass_rate ?? "N/A";
|
|
40
|
-
const feedback = grading?.eval_feedback?.overall ?? "";
|
|
41
|
-
return `## Eval: ${r.evalName}
|
|
42
|
-
Prompt: ${r.prompt}
|
|
43
|
-
Pass rate: ${typeof passRate === "number" ? (passRate * 100).toFixed(0) + "%" : passRate}
|
|
44
|
-
|
|
45
|
-
Expectations:
|
|
46
|
-
${expectations.map((e) => ` ${e.passed ? "PASS" : "FAIL"} \u2014 ${e.text}: ${e.evidence}`).join("\n")}
|
|
47
|
-
|
|
48
|
-
Feedback: ${feedback}`;
|
|
49
|
-
}).join("\n\n---\n\n");
|
|
50
|
-
const feedbackSection = userFeedback ? `
|
|
51
|
-
|
|
52
|
-
## User Feedback
|
|
53
|
-
|
|
54
|
-
${userFeedback}` : "\n\n## User Feedback\n\nNo specific feedback provided.";
|
|
55
|
-
const analyzerPrompt = `## Current Content
|
|
56
|
-
|
|
57
|
-
${content}
|
|
58
|
-
|
|
59
|
-
## Eval Results
|
|
60
|
-
|
|
61
|
-
${resultsText}${feedbackSection}
|
|
62
|
-
|
|
63
|
-
Analyze the results and propose improvements. Respond with ONLY valid JSON.`;
|
|
64
|
-
const result = await executeEval({
|
|
65
|
-
prompt: analyzerPrompt,
|
|
66
|
-
targetContent: ANALYZER_SYSTEM_PROMPT,
|
|
67
|
-
timeout,
|
|
68
|
-
model
|
|
69
|
-
});
|
|
70
|
-
if (result.error) {
|
|
71
|
-
return {
|
|
72
|
-
suggestions: [],
|
|
73
|
-
overallAssessment: `Analysis failed: ${result.error}`,
|
|
74
|
-
proposedContent: content
|
|
75
|
-
};
|
|
76
|
-
}
|
|
77
|
-
try {
|
|
78
|
-
let jsonStr = result.output.trim();
|
|
79
|
-
const jsonMatch = jsonStr.match(/```(?:json)?\s*([\s\S]*?)```/);
|
|
80
|
-
if (jsonMatch) jsonStr = jsonMatch[1].trim();
|
|
81
|
-
const objMatch = jsonStr.match(/\{[\s\S]*\}/);
|
|
82
|
-
if (objMatch) jsonStr = objMatch[0];
|
|
83
|
-
return JSON.parse(jsonStr);
|
|
84
|
-
} catch {
|
|
85
|
-
return {
|
|
86
|
-
suggestions: [],
|
|
87
|
-
overallAssessment: `Analysis returned unparseable output: ${result.output.slice(0, 200)}`,
|
|
88
|
-
proposedContent: content
|
|
89
|
-
};
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
export {
|
|
94
|
-
analyzeEvalResults
|
|
95
|
-
};
|
|
96
|
-
//# sourceMappingURL=chunk-3TIMQ3O6.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../src/lib/eval-analyzer.ts"],
|
|
4
|
-
"sourcesContent": ["import { executeEval } from './eval-executor.js';\n\nexport interface AnalysisResult {\n suggestions: Array<{\n section: string;\n current: string;\n proposed: string;\n reasoning: string;\n }>;\n overallAssessment: string;\n proposedContent: string;\n}\n\nconst ANALYZER_SYSTEM_PROMPT = `You are an expert at improving AI coding instructions, skills, and prompts. You receive eval results showing how well the current content performs, and your job is to propose specific improvements.\n\nYou will receive:\n1. The current content of the eval target\n2. Eval results: for each eval, the prompt, expectations, pass/fail results, and grader feedback\n3. The pass rate and areas of weakness\n\nAnalyze the failures and propose concrete edits to improve the content. Focus on:\n- Expectations that consistently fail \u2014 what's missing from the content?\n- Grader feedback suggesting new assertions \u2014 what outcomes aren't being tested?\n- Patterns across failures \u2014 is there a systemic gap?\n\nYour proposed content should be a complete replacement, not a diff. Keep what works, fix what doesn't.\n\nYou MUST respond with ONLY a valid JSON object:\n\n{\n \"suggestions\": [\n {\n \"section\": \"which part of the content\",\n \"current\": \"brief quote of current text\",\n \"proposed\": \"what it should say instead\",\n \"reasoning\": \"why this change helps\"\n }\n ],\n \"overallAssessment\": \"brief summary of what's working and what's not\",\n \"proposedContent\": \"the full improved content\"\n}`;\n\nexport async function analyzeEvalResults(options: {\n content: string;\n evalResults: Array<{\n evalName: string;\n prompt: string;\n expectations: string[];\n grading: Record<string, unknown>;\n }>;\n model?: string;\n timeout?: number;\n userFeedback?: string;\n}): Promise<AnalysisResult> {\n const { content, evalResults, model, timeout = 120_000, userFeedback } = options;\n\n const resultsText = evalResults.map((r) => {\n const grading = r.grading as any;\n const expectations = grading?.expectations ?? [];\n const passRate = grading?.summary?.pass_rate ?? 'N/A';\n const feedback = grading?.eval_feedback?.overall ?? '';\n\n return `## Eval: ${r.evalName}\nPrompt: ${r.prompt}\nPass rate: ${typeof passRate === 'number' ? (passRate * 100).toFixed(0) + '%' : passRate}\n\nExpectations:\n${expectations.map((e: any) => ` ${e.passed ? 'PASS' : 'FAIL'} \u2014 ${e.text}: ${e.evidence}`).join('\\n')}\n\nFeedback: ${feedback}`;\n }).join('\\n\\n---\\n\\n');\n\n const feedbackSection = userFeedback\n ? `\\n\\n## User Feedback\\n\\n${userFeedback}`\n : '\\n\\n## User Feedback\\n\\nNo specific feedback provided.';\n\n const analyzerPrompt = `## Current Content\n\n${content}\n\n## Eval Results\n\n${resultsText}${feedbackSection}\n\nAnalyze the results and propose improvements. Respond with ONLY valid JSON.`;\n\n const result = await executeEval({\n prompt: analyzerPrompt,\n targetContent: ANALYZER_SYSTEM_PROMPT,\n timeout,\n model,\n });\n\n if (result.error) {\n return {\n suggestions: [],\n overallAssessment: `Analysis failed: ${result.error}`,\n proposedContent: content,\n };\n }\n\n try {\n let jsonStr = result.output.trim();\n const jsonMatch = jsonStr.match(/```(?:json)?\\s*([\\s\\S]*?)```/);\n if (jsonMatch) jsonStr = jsonMatch[1].trim();\n const objMatch = jsonStr.match(/\\{[\\s\\S]*\\}/);\n if (objMatch) jsonStr = objMatch[0];\n\n return JSON.parse(jsonStr) as AnalysisResult;\n } catch {\n return {\n suggestions: [],\n overallAssessment: `Analysis returned unparseable output: ${result.output.slice(0, 200)}`,\n proposedContent: content,\n };\n }\n}\n"],
|
|
5
|
-
"mappings": ";;;;;AAaA,IAAM,yBAAyB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA6B/B,eAAsB,mBAAmB,SAW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