@ashlr/hub 3.11.0 → 3.11.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/CHANGELOG.md +104 -0
- package/dist/authority-surface.json +12 -7
- package/dist/build-identity.json +2 -2
- package/dist/core/universe/builtins/preparation/manifest.json +1 -1
- package/dist/core/universe/builtins/preparation/preparation-bridge.mjs +5 -4
- package/dist/core/universe/builtins/preparation/preparation-verification-fixtures.mjs +4 -3
- package/dist/core/universe/campaign.js +9 -1
- package/dist/core/universe/campaign.js.map +1 -1
- package/dist/core/universe/runner.d.ts +3 -0
- package/dist/core/universe/runner.js +7 -3
- package/dist/core/universe/runner.js.map +1 -1
- package/dist/core/verse/compaction-point.d.ts +55 -0
- package/dist/core/verse/compaction-point.js +75 -0
- package/dist/core/verse/compaction-point.js.map +1 -0
- package/dist/core/verse/context-math.d.ts +1 -38
- package/dist/core/verse/context-math.js +5 -59
- package/dist/core/verse/context-math.js.map +1 -1
- package/dist/core/web/public/next/assets/{ActionMenu-CQvNJvHY.js → ActionMenu-FxXeRbPx.js} +2 -2
- package/dist/core/web/public/next/assets/{ActionMenu-CQvNJvHY.js.map → ActionMenu-FxXeRbPx.js.map} +1 -1
- package/dist/core/web/public/next/assets/Advanced-D_eS4472.js +2 -0
- package/dist/core/web/public/next/assets/{Advanced-DEM93sKI.js.map → Advanced-D_eS4472.js.map} +1 -1
- package/dist/core/web/public/next/assets/App-Cj4zKbG3.js +7 -0
- package/dist/core/web/public/next/assets/{App-CimXmK0L.js.map → App-Cj4zKbG3.js.map} +1 -1
- package/dist/core/web/public/next/assets/AppsSection-Ddu_RCQE.js +2 -0
- package/dist/core/web/public/next/assets/{AppsSection-D6U-dSj6.js.map → AppsSection-Ddu_RCQE.js.map} +1 -1
- package/dist/core/web/public/next/assets/{AreaTrend-LD9lCPkT.js → AreaTrend-CDxrQU4b.js} +2 -2
- package/dist/core/web/public/next/assets/{AreaTrend-LD9lCPkT.js.map → AreaTrend-CDxrQU4b.js.map} +1 -1
- package/dist/core/web/public/next/assets/AutonomySection-DuQkHGD_.js +2 -0
- package/dist/core/web/public/next/assets/{AutonomySection-3V9pUyxm.js.map → AutonomySection-DuQkHGD_.js.map} +1 -1
- package/dist/core/web/public/next/assets/BranchBar-CLsvOcyK.js +2 -0
- package/dist/core/web/public/next/assets/{BranchBar-U8UdpfEB.js.map → BranchBar-CLsvOcyK.js.map} +1 -1
- package/dist/core/web/public/next/assets/{BudgetControl-DOTlMSmW.js → BudgetControl-TL3FeZ1D.js} +2 -2
- package/dist/core/web/public/next/assets/{BudgetControl-DOTlMSmW.js.map → BudgetControl-TL3FeZ1D.js.map} +1 -1
- package/dist/core/web/public/next/assets/{BurnDown-x4PWH9JF.js → BurnDown-sFXkUGdB.js} +2 -2
- package/dist/core/web/public/next/assets/{BurnDown-x4PWH9JF.js.map → BurnDown-sFXkUGdB.js.map} +1 -1
- package/dist/core/web/public/next/assets/{Button-DYv_KKxr.js → Button-HHXgoXGr.js} +2 -2
- package/dist/core/web/public/next/assets/{Button-DYv_KKxr.js.map → Button-HHXgoXGr.js.map} +1 -1
- package/dist/core/web/public/next/assets/CapacityStrip-qReu0RaF.js +2 -0
- package/dist/core/web/public/next/assets/CapacityStrip-qReu0RaF.js.map +1 -0
- package/dist/core/web/public/next/assets/ChatSection-DZuZfTaC.js +3 -0
- package/dist/core/web/public/next/assets/ChatSection-DZuZfTaC.js.map +1 -0
- package/dist/core/web/public/next/assets/{CloudBudgetForm-DJeJvBEu.js → CloudBudgetForm-DJbiT1wi.js} +2 -2
- package/dist/core/web/public/next/assets/{CloudBudgetForm-DJeJvBEu.js.map → CloudBudgetForm-DJbiT1wi.js.map} +1 -1
- package/dist/core/web/public/next/assets/CommandPalette-zYLFZRnj.js +2 -0
- package/dist/core/web/public/next/assets/{CommandPalette-FiD4N8XD.js.map → CommandPalette-zYLFZRnj.js.map} +1 -1
- package/dist/core/web/public/next/assets/CommandSection-rIeMK5Ch.js +2 -0
- package/dist/core/web/public/next/assets/{CommandSection-DN8KwH-X.js.map → CommandSection-rIeMK5Ch.js.map} +1 -1
- package/dist/core/web/public/next/assets/ConfirmDialog-DLrLKM0c.js +2 -0
- package/dist/core/web/public/next/assets/ConfirmDialog-DLrLKM0c.js.map +1 -0
- package/dist/core/web/public/next/assets/ConfirmDialog-Dx15x0Ho.css +1 -0
- package/dist/core/web/public/next/assets/Dialog-BS9Dxi3G.js +2 -0
- package/dist/core/web/public/next/assets/Dialog-BS9Dxi3G.js.map +1 -0
- package/dist/core/web/public/next/assets/Dialog-tQ8kFulD.css +1 -0
- package/dist/core/web/public/next/assets/{DiffPane-DLJ3gGGK.js → DiffPane-TOmUf3b2.js} +2 -2
- package/dist/core/web/public/next/assets/{DiffPane-DLJ3gGGK.js.map → DiffPane-TOmUf3b2.js.map} +1 -1
- package/dist/core/web/public/next/assets/{DiffViewer-B7NWPjIO.js → DiffViewer-BpH56302.js} +2 -2
- package/dist/core/web/public/next/assets/{DiffViewer-B7NWPjIO.js.map → DiffViewer-BpH56302.js.map} +1 -1
- package/dist/core/web/public/next/assets/DockHost-DzkzR-HD.js +2 -0
- package/dist/core/web/public/next/assets/{DockHost-DvR-hPhZ.js.map → DockHost-DzkzR-HD.js.map} +1 -1
- package/dist/core/web/public/next/assets/{EmptyState-DhNgDDrF.js → EmptyState-BqR5YAmf.js} +2 -2
- package/dist/core/web/public/next/assets/{EmptyState-DhNgDDrF.js.map → EmptyState-BqR5YAmf.js.map} +1 -1
- package/dist/core/web/public/next/assets/{Epistemic-uARPnx9x.js → Epistemic-dhvDTwAZ.js} +2 -2
- package/dist/core/web/public/next/assets/{Epistemic-uARPnx9x.js.map → Epistemic-dhvDTwAZ.js.map} +1 -1
- package/dist/core/web/public/next/assets/FleetSection-ViAb549H.js +3 -0
- package/dist/core/web/public/next/assets/{FleetSection-D_zRBCub.js.map → FleetSection-ViAb549H.js.map} +1 -1
- package/dist/core/web/public/next/assets/{Funnel-CL8uHONq.js → Funnel-D2u7Wlzc.js} +2 -2
- package/dist/core/web/public/next/assets/{Funnel-CL8uHONq.js.map → Funnel-D2u7Wlzc.js.map} +1 -1
- package/dist/core/web/public/next/assets/GearTray-Cb2npoxM.js +2 -0
- package/dist/core/web/public/next/assets/{GearTray-C7k4l_BW.js.map → GearTray-Cb2npoxM.js.map} +1 -1
- package/dist/core/web/public/next/assets/{GrowthSection-DwdNSGj8.js → GrowthSection-C5aDPs8B.js} +2 -2
- package/dist/core/web/public/next/assets/{GrowthSection-DwdNSGj8.js.map → GrowthSection-C5aDPs8B.js.map} +1 -1
- package/dist/core/web/public/next/assets/HandoffDialog-BF3AYg-X.js +2 -0
- package/dist/core/web/public/next/assets/{HandoffDialog-FPVOqOMN.js.map → HandoffDialog-BF3AYg-X.js.map} +1 -1
- package/dist/core/web/public/next/assets/{Input-B9-VLcHS.js → Input-B5dmGLZx.js} +2 -2
- package/dist/core/web/public/next/assets/{Input-B9-VLcHS.js.map → Input-B5dmGLZx.js.map} +1 -1
- package/dist/core/web/public/next/assets/LeaderCard-DZrmjDbI.js +2 -0
- package/dist/core/web/public/next/assets/{LeaderCard-4R0BhDzT.js.map → LeaderCard-DZrmjDbI.js.map} +1 -1
- package/dist/core/web/public/next/assets/{MatrixHeatmap-DiuushcS.js → MatrixHeatmap-BgEUs2Eu.js} +2 -2
- package/dist/core/web/public/next/assets/{MatrixHeatmap-DiuushcS.js.map → MatrixHeatmap-BgEUs2Eu.js.map} +1 -1
- package/dist/core/web/public/next/assets/McpSection-DZkiOuoq.js +2 -0
- package/dist/core/web/public/next/assets/{McpSection-CJ__OJKl.js.map → McpSection-DZkiOuoq.js.map} +1 -1
- package/dist/core/web/public/next/assets/{MessageMarkdown-qWKyJvAQ.js → MessageMarkdown-BauY8ZTY.js} +3 -3
- package/dist/core/web/public/next/assets/{MessageMarkdown-qWKyJvAQ.js.map → MessageMarkdown-BauY8ZTY.js.map} +1 -1
- package/dist/core/web/public/next/assets/{MessageMarkdownRenderer-x05TrsrW.js → MessageMarkdownRenderer-DLBNLfsn.js} +2 -2
- package/dist/core/web/public/next/assets/{MessageMarkdownRenderer-x05TrsrW.js.map → MessageMarkdownRenderer-DLBNLfsn.js.map} +1 -1
- package/dist/core/web/public/next/assets/{Meter-D-hncpkO.js → Meter-DNeocJnD.js} +2 -2
- package/dist/core/web/public/next/assets/{Meter-D-hncpkO.js.map → Meter-DNeocJnD.js.map} +1 -1
- package/dist/core/web/public/next/assets/MindSection-BvJXFjyX.js +2 -0
- package/dist/core/web/public/next/assets/{MindSection-BjXHkQPS.js.map → MindSection-BvJXFjyX.js.map} +1 -1
- package/dist/core/web/public/next/assets/MutationTokenDialog-CrfJ0PdD.css +1 -0
- package/dist/core/web/public/next/assets/MutationTokenDialog-mxrw0Yvy.js +2 -0
- package/dist/core/web/public/next/assets/MutationTokenDialog-mxrw0Yvy.js.map +1 -0
- package/dist/core/web/public/next/assets/NeedsYouDrawer-CO-Balfp.js +2 -0
- package/dist/core/web/public/next/assets/{NeedsYouDrawer-rSd1ZHAR.js.map → NeedsYouDrawer-CO-Balfp.js.map} +1 -1
- package/dist/core/web/public/next/assets/{NeedsYouList-CG-nB1tr.js → NeedsYouList-CzDZbzRD.js} +2 -2
- package/dist/core/web/public/next/assets/{NeedsYouList-CG-nB1tr.js.map → NeedsYouList-CzDZbzRD.js.map} +1 -1
- package/dist/core/web/public/next/assets/NewChatDialog-B8eJjlFf.js +3 -0
- package/dist/core/web/public/next/assets/{NewChatDialog-BeDQ1eW3.js.map → NewChatDialog-B8eJjlFf.js.map} +1 -1
- package/dist/core/web/public/next/assets/OnboardingFlow-Cij6KWat.js +2 -0
- package/dist/core/web/public/next/assets/{OnboardingFlow-CkTZtt-m.js.map → OnboardingFlow-Cij6KWat.js.map} +1 -1
- package/dist/core/web/public/next/assets/PreviewPane-BS-CleCd.js +2 -0
- package/dist/core/web/public/next/assets/{PreviewPane-kzbbSK4u.js.map → PreviewPane-BS-CleCd.js.map} +1 -1
- package/dist/core/web/public/next/assets/ProviderLogo-C5mBg8i0.js +2 -0
- package/dist/core/web/public/next/assets/ProviderLogo-C5mBg8i0.js.map +1 -0
- package/dist/core/web/public/next/assets/{RailStatus-D-t2gPae.js → RailStatus-cPRyOmrk.js} +2 -2
- package/dist/core/web/public/next/assets/{RailStatus-D-t2gPae.js.map → RailStatus-cPRyOmrk.js.map} +1 -1
- package/dist/core/web/public/next/assets/{RefreshIndicator-BLnr9IOM.js → RefreshIndicator-CMwSCiz5.js} +2 -2
- package/dist/core/web/public/next/assets/{RefreshIndicator-BLnr9IOM.js.map → RefreshIndicator-CMwSCiz5.js.map} +1 -1
- package/dist/core/web/public/next/assets/{ResourcePoolConsoleApp-BeG0gBif.js → ResourcePoolConsoleApp-BFi1opsC.js} +5 -5
- package/dist/core/web/public/next/assets/{ResourcePoolConsoleApp-BeG0gBif.js.map → ResourcePoolConsoleApp-BFi1opsC.js.map} +1 -1
- package/dist/core/web/public/next/assets/{ResourcePoolConsoleApp-CM_8pJs6.css → ResourcePoolConsoleApp-BX9JLkT4.css} +1 -1
- package/dist/core/web/public/next/assets/ResourcesChrome-BJCauW_t.js +3 -0
- package/dist/core/web/public/next/assets/ResourcesChrome-BJCauW_t.js.map +1 -0
- package/dist/core/web/public/next/assets/ResourcesChrome-uZEqC2EM.css +1 -0
- package/dist/core/web/public/next/assets/ResourcesDrawer-BDecg6nO.js +2 -0
- package/dist/core/web/public/next/assets/ResourcesDrawer-BDecg6nO.js.map +1 -0
- package/dist/core/web/public/next/assets/RouteErrorBoundary-DYtwc2ja.js +2 -0
- package/dist/core/web/public/next/assets/RouteErrorBoundary-DYtwc2ja.js.map +1 -0
- package/dist/core/web/public/next/assets/RouteErrorBoundary-DdxhTdZ6.css +1 -0
- package/dist/core/web/public/next/assets/{RunInCloudAction-C3LBp7C4.js → RunInCloudAction-BEGEEM8O.js} +2 -2
- package/dist/core/web/public/next/assets/{RunInCloudAction-C3LBp7C4.js.map → RunInCloudAction-BEGEEM8O.js.map} +1 -1
- package/dist/core/web/public/next/assets/SeatSelector-CYHRR7Wp.js +3 -0
- package/dist/core/web/public/next/assets/{SeatSelector-DpvvbjNm.js.map → SeatSelector-CYHRR7Wp.js.map} +1 -1
- package/dist/core/web/public/next/assets/{Segmented-BL40udoO.js → Segmented-BE53BenI.js} +2 -2
- package/dist/core/web/public/next/assets/{Segmented-BL40udoO.js.map → Segmented-BE53BenI.js.map} +1 -1
- package/dist/core/web/public/next/assets/{Select-FWLnAw_j.js → Select-BwSGkHCS.js} +2 -2
- package/dist/core/web/public/next/assets/{Select-FWLnAw_j.js.map → Select-BwSGkHCS.js.map} +1 -1
- package/dist/core/web/public/next/assets/SessionGate-DvMpXNpJ.css +1 -0
- package/dist/core/web/public/next/assets/SessionGate-e0dFJm9d.js +2 -0
- package/dist/core/web/public/next/assets/SessionGate-e0dFJm9d.js.map +1 -0
- package/dist/core/web/public/next/assets/SessionInsightChip-CxlSyueJ.js +2 -0
- package/dist/core/web/public/next/assets/{SessionInsightChip-CWye87Ju.js.map → SessionInsightChip-CxlSyueJ.js.map} +1 -1
- package/dist/core/web/public/next/assets/{SessionSearch-YvCHFUuN.js → SessionSearch-_yp7S2TP.js} +2 -2
- package/dist/core/web/public/next/assets/{SessionSearch-YvCHFUuN.js.map → SessionSearch-_yp7S2TP.js.map} +1 -1
- package/dist/core/web/public/next/assets/SettingsSection-wGnpWeGW.js +2 -0
- package/dist/core/web/public/next/assets/SettingsSection-wGnpWeGW.js.map +1 -0
- package/dist/core/web/public/next/assets/Sheet-DVP2Mgy6.js +2 -0
- package/dist/core/web/public/next/assets/{Sheet-DZKcQXQg.js.map → Sheet-DVP2Mgy6.js.map} +1 -1
- package/dist/core/web/public/next/assets/ShortcutsOverlay-BcIcoClX.js +2 -0
- package/dist/core/web/public/next/assets/{ShortcutsOverlay-BpDimdPq.js.map → ShortcutsOverlay-BcIcoClX.js.map} +1 -1
- package/dist/core/web/public/next/assets/Sidebar-DjQOqPbm.js +3 -0
- package/dist/core/web/public/next/assets/{Sidebar-BoBzBEFX.js.map → Sidebar-DjQOqPbm.js.map} +1 -1
- package/dist/core/web/public/next/assets/{Slider-DUMo9HDD.js → Slider-BypUWjpH.js} +2 -2
- package/dist/core/web/public/next/assets/{Slider-DUMo9HDD.js.map → Slider-BypUWjpH.js.map} +1 -1
- package/dist/core/web/public/next/assets/{StatusBadge-BwnBNFQr.js → StatusBadge-HCZp416_.js} +2 -2
- package/dist/core/web/public/next/assets/{StatusBadge-BwnBNFQr.js.map → StatusBadge-HCZp416_.js.map} +1 -1
- package/dist/core/web/public/next/assets/{StepBand-PDXMIlRk.js → StepBand-Duz1PUes.js} +2 -2
- package/dist/core/web/public/next/assets/{StepBand-PDXMIlRk.js.map → StepBand-Duz1PUes.js.map} +1 -1
- package/dist/core/web/public/next/assets/{Surface-B3TZVoER.js → Surface-B75lVfzm.js} +2 -2
- package/dist/core/web/public/next/assets/{Surface-B3TZVoER.js.map → Surface-B75lVfzm.js.map} +1 -1
- package/dist/core/web/public/next/assets/{Swimlane-DR4OgON_.js → Swimlane-DGcIcnNA.js} +2 -2
- package/dist/core/web/public/next/assets/{Swimlane-DR4OgON_.js.map → Swimlane-DGcIcnNA.js.map} +1 -1
- package/dist/core/web/public/next/assets/{Switch-CcR5Llk5.js → Switch-iveI-8NY.js} +2 -2
- package/dist/core/web/public/next/assets/{Switch-CcR5Llk5.js.map → Switch-iveI-8NY.js.map} +1 -1
- package/dist/core/web/public/next/assets/{Tag-_-K1h7Hk.js → Tag-DH15CUJp.js} +2 -2
- package/dist/core/web/public/next/assets/{Tag-_-K1h7Hk.js.map → Tag-DH15CUJp.js.map} +1 -1
- package/dist/core/web/public/next/assets/TerminalPane-MQT-veKZ.js +7 -0
- package/dist/core/web/public/next/assets/{TerminalPane-_1aH4ndN.js.map → TerminalPane-MQT-veKZ.js.map} +1 -1
- package/dist/core/web/public/next/assets/UniverseConsoleApp-C8yQ0AaR.js +2 -0
- package/dist/core/web/public/next/assets/{UniverseConsoleApp-BUsq-inZ.js.map → UniverseConsoleApp-C8yQ0AaR.js.map} +1 -1
- package/dist/core/web/public/next/assets/{UniverseConsoleApp-Dh7A-hLD.css → UniverseConsoleApp-DfuT-wFw.css} +1 -1
- package/dist/core/web/public/next/assets/{UniverseView-Dogy_dsB.js → UniverseView-_nPURPqe.js} +4 -4
- package/dist/core/web/public/next/assets/{UniverseView-Dogy_dsB.js.map → UniverseView-_nPURPqe.js.map} +1 -1
- package/dist/core/web/public/next/assets/UsageSection-CqxRGJ40.js +2 -0
- package/dist/core/web/public/next/assets/{UsageSection-DiX_dTyo.js.map → UsageSection-CqxRGJ40.js.map} +1 -1
- package/dist/core/web/public/next/assets/VerseConsoleApp-DTjDpGCd.js +3 -0
- package/dist/core/web/public/next/assets/VerseConsoleApp-DTjDpGCd.js.map +1 -0
- package/dist/core/web/public/next/assets/Workspace-DfcFGzME.js +10 -0
- package/dist/core/web/public/next/assets/Workspace-DfcFGzME.js.map +1 -0
- package/dist/core/web/public/next/assets/Workspace-Dwri2jFJ.css +1 -0
- package/dist/core/web/public/next/assets/actions-tWevL9HV.js +2 -0
- package/dist/core/web/public/next/assets/{actions-s2lfm_5k.js.map → actions-tWevL9HV.js.map} +1 -1
- package/dist/core/web/public/next/assets/budget-queries-V3wcJVK_.js +2 -0
- package/dist/core/web/public/next/assets/{budget-queries-wUshcovN.js.map → budget-queries-V3wcJVK_.js.map} +1 -1
- package/dist/core/web/public/next/assets/{capacity-strip-model-Bj_9ztzs.js → capacity-strip-model-BDbmQ3e3.js} +2 -2
- package/dist/core/web/public/next/assets/{capacity-strip-model-Bj_9ztzs.js.map → capacity-strip-model-BDbmQ3e3.js.map} +1 -1
- package/dist/core/web/public/next/assets/{charts-CMSgAUKn.js → charts-CfAjuKMv.js} +2 -2
- package/dist/core/web/public/next/assets/{charts-CMSgAUKn.js.map → charts-CfAjuKMv.js.map} +1 -1
- package/dist/core/web/public/next/assets/cloud-queries-Br_r0UAz.js +2 -0
- package/dist/core/web/public/next/assets/{cloud-queries-CnV1yaNG.js.map → cloud-queries-Br_r0UAz.js.map} +1 -1
- package/dist/core/web/public/next/assets/{cloud.module-CiwatLj3.js → cloud.module-ascz58c3.js} +2 -2
- package/dist/core/web/public/next/assets/{cloud.module-CiwatLj3.js.map → cloud.module-ascz58c3.js.map} +1 -1
- package/dist/core/web/public/next/assets/{command-bus-DqimKCUY.js → command-bus-xYZoK9nQ.js} +2 -2
- package/dist/core/web/public/next/assets/{command-bus-DqimKCUY.js.map → command-bus-xYZoK9nQ.js.map} +1 -1
- package/dist/core/web/public/next/assets/command-catalog-Bb_PxC5w.js +2 -0
- package/dist/core/web/public/next/assets/command-catalog-Bb_PxC5w.js.map +1 -0
- package/dist/core/web/public/next/assets/compaction-point-VL9oegWS.js +2 -0
- package/dist/core/web/public/next/assets/compaction-point-VL9oegWS.js.map +1 -0
- package/dist/core/web/public/next/assets/{composer-keys-DBRymxQn.js → composer-keys-su0g1h9o.js} +2 -2
- package/dist/core/web/public/next/assets/{composer-keys-DBRymxQn.js.map → composer-keys-su0g1h9o.js.map} +1 -1
- package/dist/core/web/public/next/assets/context-model-BC-HOmPo.js +2 -0
- package/dist/core/web/public/next/assets/{context-model-Dwd49-dp.js.map → context-model-BC-HOmPo.js.map} +1 -1
- package/dist/core/web/public/next/assets/context-model-CIBmSugV.js +2 -0
- package/dist/core/web/public/next/assets/{context-model-MT17V86_.js.map → context-model-CIBmSugV.js.map} +1 -1
- package/dist/core/web/public/next/assets/context-queries-CrPcHWTz.js +2 -0
- package/dist/core/web/public/next/assets/{context-queries-xVKIeynP.js.map → context-queries-CrPcHWTz.js.map} +1 -1
- package/dist/core/web/public/next/assets/control-queries-CmgBgKV7.js +2 -0
- package/dist/core/web/public/next/assets/{control-queries-DOZR-D8G.js.map → control-queries-CmgBgKV7.js.map} +1 -1
- package/dist/core/web/public/next/assets/{dock-icons-8EtARwUm.js → dock-icons-CUh8dOxJ.js} +2 -2
- package/dist/core/web/public/next/assets/{dock-icons-8EtARwUm.js.map → dock-icons-CUh8dOxJ.js.map} +1 -1
- package/dist/core/web/public/next/assets/{dock-store-BA1cHOYA.js → dock-store-B2vlxqPu.js} +2 -2
- package/dist/core/web/public/next/assets/{dock-store-BA1cHOYA.js.map → dock-store-B2vlxqPu.js.map} +1 -1
- package/dist/core/web/public/next/assets/{fleet-model-CNe8Wh-s.js → fleet-model-7i-FbzKI.js} +2 -2
- package/dist/core/web/public/next/assets/{fleet-model-CNe8Wh-s.js.map → fleet-model-7i-FbzKI.js.map} +1 -1
- package/dist/core/web/public/next/assets/fleet-queries-DzGoqq8X.js +2 -0
- package/dist/core/web/public/next/assets/{fleet-queries-BSdRlUwJ.js.map → fleet-queries-DzGoqq8X.js.map} +1 -1
- package/dist/core/web/public/next/assets/focus-trap-HtcoXeEq.js +2 -0
- package/dist/core/web/public/next/assets/focus-trap-HtcoXeEq.js.map +1 -0
- package/dist/core/web/public/next/assets/{format-B8DAVcn2.js → format-BkWdOQDL.js} +2 -2
- package/dist/core/web/public/next/assets/{format-B8DAVcn2.js.map → format-BkWdOQDL.js.map} +1 -1
- package/dist/core/web/public/next/assets/git-model-bk_RXh3y.js +5 -0
- package/dist/core/web/public/next/assets/{git-model-CivuBY_D.js.map → git-model-bk_RXh3y.js.map} +1 -1
- package/dist/core/web/public/next/assets/global-BlI2BYa1.css +1 -0
- package/dist/core/web/public/next/assets/global-oEl9Qj8u.js +2 -0
- package/dist/core/web/public/next/assets/global-oEl9Qj8u.js.map +1 -0
- package/dist/core/web/public/next/assets/guarded-action-OzqcPjmh.js +3 -0
- package/dist/core/web/public/next/assets/guarded-action-OzqcPjmh.js.map +1 -0
- package/dist/core/web/public/next/assets/guarded-runners-LHLXmXIk.js +2 -0
- package/dist/core/web/public/next/assets/guarded-runners-LHLXmXIk.js.map +1 -0
- package/dist/core/web/public/next/assets/icon-base-DvM1eI5V.js +2 -0
- package/dist/core/web/public/next/assets/icon-base-DvM1eI5V.js.map +1 -0
- package/dist/core/web/public/next/assets/icons-DEQa2rTx.js +2 -0
- package/dist/core/web/public/next/assets/icons-DEQa2rTx.js.map +1 -0
- package/dist/core/web/public/next/assets/{index-oAAq8XJa.js → index-BVxOlseC.js} +3 -3
- package/dist/core/web/public/next/assets/{index-oAAq8XJa.js.map → index-BVxOlseC.js.map} +1 -1
- package/dist/core/web/public/next/assets/{live-model-DCw_IFRI.js → live-model-bmsJgnYD.js} +2 -2
- package/dist/core/web/public/next/assets/{live-model-DCw_IFRI.js.map → live-model-bmsJgnYD.js.map} +1 -1
- package/dist/core/web/public/next/assets/{mind.module-vnuJcwvD.js → mind.module-gTGAuJt1.js} +2 -2
- package/dist/core/web/public/next/assets/{mind.module-vnuJcwvD.js.map → mind.module-gTGAuJt1.js.map} +1 -1
- package/dist/core/web/public/next/assets/mutations-C5S7okTW.js +2 -0
- package/dist/core/web/public/next/assets/{mutations-Dpsql5t7.js.map → mutations-C5S7okTW.js.map} +1 -1
- package/dist/core/web/public/next/assets/nav-NVtnuG7A.js +2 -0
- package/dist/core/web/public/next/assets/nav-NVtnuG7A.js.map +1 -0
- package/dist/core/web/public/next/assets/overnight-queries-DGm3qL1b.js +2 -0
- package/dist/core/web/public/next/assets/{overnight-queries-X-44Gsw5.js.map → overnight-queries-DGm3qL1b.js.map} +1 -1
- package/dist/core/web/public/next/assets/preloaded-Cwf9rsnZ.js +2 -0
- package/dist/core/web/public/next/assets/preloaded-Cwf9rsnZ.js.map +1 -0
- package/dist/core/web/public/next/assets/primitives-DyCKYSBG.js +1 -0
- package/dist/core/web/public/next/assets/{queries-BA4rNGD-.js → queries-CYisSAAB.js} +2 -2
- package/dist/core/web/public/next/assets/{queries-BA4rNGD-.js.map → queries-CYisSAAB.js.map} +1 -1
- package/dist/core/web/public/next/assets/reasoning-pref-BUcFF_5G.js +2 -0
- package/dist/core/web/public/next/assets/{reasoning-pref-B9-DJUXP.js.map → reasoning-pref-BUcFF_5G.js.map} +1 -1
- package/dist/core/web/public/next/assets/reveal-anchor-D-tV8xau.js +2 -0
- package/dist/core/web/public/next/assets/reveal-anchor-D-tV8xau.js.map +1 -0
- package/dist/core/web/public/next/assets/seat-subscription-B-f9ViU2.js +2 -0
- package/dist/core/web/public/next/assets/{seat-subscription-CH6fW4fJ.js.map → seat-subscription-B-f9ViU2.js.map} +1 -1
- package/dist/core/web/public/next/assets/{section-visibility-qFqc_d4Z.js → section-visibility-Yctxu-if.js} +2 -2
- package/dist/core/web/public/next/assets/{section-visibility-qFqc_d4Z.js.map → section-visibility-Yctxu-if.js.map} +1 -1
- package/dist/core/web/public/next/assets/{sidebar-model-M1GaQU5l.js → sidebar-model-DQ-FyBHW.js} +2 -2
- package/dist/core/web/public/next/assets/{sidebar-model-M1GaQU5l.js.map → sidebar-model-DQ-FyBHW.js.map} +1 -1
- package/dist/core/web/public/next/assets/slots-BhP8b8tf.js +3 -0
- package/dist/core/web/public/next/assets/{slots-Ds9ZIqUL.js.map → slots-BhP8b8tf.js.map} +1 -1
- package/dist/core/web/public/next/assets/surface-data-DTI7LjvH.js +2 -0
- package/dist/core/web/public/next/assets/{surface-data-J52iIGMD.js.map → surface-data-DTI7LjvH.js.map} +1 -1
- package/dist/core/web/public/next/assets/surface-prefetch-CdUEBFrl.js +2 -0
- package/dist/core/web/public/next/assets/{surface-prefetch-CgZ-LEJK.js.map → surface-prefetch-CdUEBFrl.js.map} +1 -1
- package/dist/core/web/public/next/assets/{tasks-model-ent8f0jZ.js → tasks-model-BKDNqmmt.js} +2 -2
- package/dist/core/web/public/next/assets/{tasks-model-ent8f0jZ.js.map → tasks-model-BKDNqmmt.js.map} +1 -1
- package/dist/core/web/public/next/assets/{terminal-icons-DJTK7QpR.js → terminal-icons-D2xe-aM1.js} +2 -2
- package/dist/core/web/public/next/assets/{terminal-icons-DJTK7QpR.js.map → terminal-icons-D2xe-aM1.js.map} +1 -1
- package/dist/core/web/public/next/assets/{usage-queries-Bn8ccqyN.js → usage-queries-BZuAANlI.js} +2 -2
- package/dist/core/web/public/next/assets/{usage-queries-Bn8ccqyN.js.map → usage-queries-BZuAANlI.js.map} +1 -1
- package/dist/core/web/public/next/assets/use-guarded-action-Cf4MeNBa.js +2 -0
- package/dist/core/web/public/next/assets/{use-guarded-action-C2HlSzkz.js.map → use-guarded-action-Cf4MeNBa.js.map} +1 -1
- package/dist/core/web/public/next/assets/{use-ticker-BNc1H4ZC.js → use-ticker-D9yi49my.js} +2 -2
- package/dist/core/web/public/next/assets/{use-ticker-BNc1H4ZC.js.map → use-ticker-D9yi49my.js.map} +1 -1
- package/dist/core/web/public/next/assets/use-token-gate-DqrSXdX6.js +2 -0
- package/dist/core/web/public/next/assets/{use-token-gate-B3IJL6bf.js.map → use-token-gate-DqrSXdX6.js.map} +1 -1
- package/dist/core/web/public/next/assets/useChartWidth-BW6SwYIK.css +1 -0
- package/dist/core/web/public/next/assets/useChartWidth-owwodNVz.js +2 -0
- package/dist/core/web/public/next/assets/{useChartWidth-lZ9PrQn0.js.map → useChartWidth-owwodNVz.js.map} +1 -1
- package/dist/core/web/public/next/assets/{useSeatsRefresh-CG4jczeL.js → useSeatsRefresh-DgFy-Ph4.js} +2 -2
- package/dist/core/web/public/next/assets/{useSeatsRefresh-CG4jczeL.js.map → useSeatsRefresh-DgFy-Ph4.js.map} +1 -1
- package/dist/core/web/public/next/assets/useVerseTranscript-CDYrrWOO.js +2 -0
- package/dist/core/web/public/next/assets/useVerseTranscript-CDYrrWOO.js.map +1 -0
- package/dist/core/web/public/next/assets/verse-icons-F9VwX07_.js +2 -0
- package/dist/core/web/public/next/assets/verse-icons-F9VwX07_.js.map +1 -0
- package/dist/core/web/public/next/assets/verse-model-DyCwZF-M.js +2 -0
- package/dist/core/web/public/next/assets/verse-model-DyCwZF-M.js.map +1 -0
- package/dist/core/web/public/next/assets/verse-store-b_Lek_c5.js +3 -0
- package/dist/core/web/public/next/assets/verse-store-b_Lek_c5.js.map +1 -0
- package/dist/core/web/public/next/assets/verse-ui-store-62DxpVHS.js +3 -0
- package/dist/core/web/public/next/assets/{verse-ui-store-zafyzXKD.js.map → verse-ui-store-62DxpVHS.js.map} +1 -1
- package/dist/core/web/public/next/assets/{viewport-BEqGUoTA.js → viewport-nTubFCwf.js} +2 -2
- package/dist/core/web/public/next/assets/{viewport-BEqGUoTA.js.map → viewport-nTubFCwf.js.map} +1 -1
- package/dist/core/web/public/next/assets/warmup-HG5vYbsN.js +3 -0
- package/dist/core/web/public/next/assets/{warmup-BR6pxAKs.js.map → warmup-HG5vYbsN.js.map} +1 -1
- package/dist/core/web/public/next/assets/{workspace-model-D_tWD5Wt.js → workspace-model-CbhdPhei.js} +2 -2
- package/dist/core/web/public/next/assets/{workspace-model-D_tWD5Wt.js.map → workspace-model-CbhdPhei.js.map} +1 -1
- package/dist/core/web/public/next/index.html +1 -1
- package/dist/release-dependency-inventory.json +1 -1
- package/package.json +5 -2
- package/dist/cli/activation.d.ts +0 -41
- package/dist/cli/activation.js +0 -485
- package/dist/cli/activation.js.map +0 -1
- package/dist/core/fleet/generated-repair-resolution.d.ts +0 -36
- package/dist/core/fleet/generated-repair-resolution.js +0 -245
- package/dist/core/fleet/generated-repair-resolution.js.map +0 -1
- package/dist/core/local-runtime/llama/port.d.ts +0 -17
- package/dist/core/local-runtime/llama/port.js +0 -47
- package/dist/core/local-runtime/llama/port.js.map +0 -1
- package/dist/core/local-runtime/llama/proxy-host.d.ts +0 -54
- package/dist/core/local-runtime/llama/proxy-host.js +0 -159
- package/dist/core/local-runtime/llama/proxy-host.js.map +0 -1
- package/dist/core/local-runtime/llama/proxy-process.d.ts +0 -148
- package/dist/core/local-runtime/llama/proxy-process.js +0 -250
- package/dist/core/local-runtime/llama/proxy-process.js.map +0 -1
- package/dist/core/local-runtime/llama/proxy-record.d.ts +0 -40
- package/dist/core/local-runtime/llama/proxy-record.js +0 -133
- package/dist/core/local-runtime/llama/proxy-record.js.map +0 -1
- package/dist/core/local-runtime/llama/proxy-supervisor.d.ts +0 -118
- package/dist/core/local-runtime/llama/proxy-supervisor.js +0 -511
- package/dist/core/local-runtime/llama/proxy-supervisor.js.map +0 -1
- package/dist/core/web/public/next/assets/Advanced-DEM93sKI.js +0 -2
- package/dist/core/web/public/next/assets/App-CimXmK0L.js +0 -7
- package/dist/core/web/public/next/assets/AppsSection-D6U-dSj6.js +0 -2
- package/dist/core/web/public/next/assets/AutonomySection-3V9pUyxm.js +0 -2
- package/dist/core/web/public/next/assets/BranchBar-U8UdpfEB.js +0 -2
- package/dist/core/web/public/next/assets/CapacityStrip-C667yQe8.js +0 -2
- package/dist/core/web/public/next/assets/CapacityStrip-C667yQe8.js.map +0 -1
- package/dist/core/web/public/next/assets/ChatSection-CCcIPpOq.js +0 -3
- package/dist/core/web/public/next/assets/ChatSection-CCcIPpOq.js.map +0 -1
- package/dist/core/web/public/next/assets/CommandPalette-FiD4N8XD.js +0 -2
- package/dist/core/web/public/next/assets/CommandSection-DN8KwH-X.js +0 -2
- package/dist/core/web/public/next/assets/DockHost-DvR-hPhZ.js +0 -2
- package/dist/core/web/public/next/assets/FleetSection-D_zRBCub.js +0 -3
- package/dist/core/web/public/next/assets/GearTray-C7k4l_BW.js +0 -2
- package/dist/core/web/public/next/assets/HandoffDialog-FPVOqOMN.js +0 -2
- package/dist/core/web/public/next/assets/LeaderCard-4R0BhDzT.js +0 -2
- package/dist/core/web/public/next/assets/McpSection-CJ__OJKl.js +0 -2
- package/dist/core/web/public/next/assets/MindSection-BjXHkQPS.js +0 -2
- package/dist/core/web/public/next/assets/MutationTokenDialog-Cum_DqQZ.css +0 -1
- package/dist/core/web/public/next/assets/MutationTokenDialog-SkRxqV_I.js +0 -2
- package/dist/core/web/public/next/assets/MutationTokenDialog-SkRxqV_I.js.map +0 -1
- package/dist/core/web/public/next/assets/NeedsYouDrawer-rSd1ZHAR.js +0 -2
- package/dist/core/web/public/next/assets/NewChatDialog-BeDQ1eW3.js +0 -3
- package/dist/core/web/public/next/assets/OnboardingFlow-CkTZtt-m.js +0 -2
- package/dist/core/web/public/next/assets/PreviewPane-kzbbSK4u.js +0 -2
- package/dist/core/web/public/next/assets/ResourcesChrome-B3Z3O98t.css +0 -1
- package/dist/core/web/public/next/assets/ResourcesChrome-BzV6bkIa.js +0 -3
- package/dist/core/web/public/next/assets/ResourcesChrome-BzV6bkIa.js.map +0 -1
- package/dist/core/web/public/next/assets/ResourcesDrawer-o4ILHdep.js +0 -2
- package/dist/core/web/public/next/assets/ResourcesDrawer-o4ILHdep.js.map +0 -1
- package/dist/core/web/public/next/assets/RouteErrorBoundary-6RMd_aZg.css +0 -1
- package/dist/core/web/public/next/assets/RouteErrorBoundary-C5SxA2Dg.js +0 -2
- package/dist/core/web/public/next/assets/RouteErrorBoundary-C5SxA2Dg.js.map +0 -1
- package/dist/core/web/public/next/assets/SeatSelector-DpvvbjNm.js +0 -3
- package/dist/core/web/public/next/assets/SessionInsightChip-CWye87Ju.js +0 -2
- package/dist/core/web/public/next/assets/SettingsSection-Dr18upeE.js +0 -2
- package/dist/core/web/public/next/assets/SettingsSection-Dr18upeE.js.map +0 -1
- package/dist/core/web/public/next/assets/Sheet-DZKcQXQg.js +0 -2
- package/dist/core/web/public/next/assets/ShortcutsOverlay-BpDimdPq.js +0 -2
- package/dist/core/web/public/next/assets/Sidebar-BoBzBEFX.js +0 -3
- package/dist/core/web/public/next/assets/TerminalPane-_1aH4ndN.js +0 -7
- package/dist/core/web/public/next/assets/UniverseConsoleApp-BUsq-inZ.js +0 -2
- package/dist/core/web/public/next/assets/UsageSection-DiX_dTyo.js +0 -2
- package/dist/core/web/public/next/assets/VerseConsoleApp-WVeyJnW7.js +0 -3
- package/dist/core/web/public/next/assets/VerseConsoleApp-WVeyJnW7.js.map +0 -1
- package/dist/core/web/public/next/assets/Workspace-BYW9dm90.css +0 -1
- package/dist/core/web/public/next/assets/Workspace-BbxZHwQd.js +0 -10
- package/dist/core/web/public/next/assets/Workspace-BbxZHwQd.js.map +0 -1
- package/dist/core/web/public/next/assets/actions-s2lfm_5k.js +0 -2
- package/dist/core/web/public/next/assets/budget-queries-wUshcovN.js +0 -2
- package/dist/core/web/public/next/assets/cloud-queries-CnV1yaNG.js +0 -2
- package/dist/core/web/public/next/assets/command-catalog-BdtDH93o.js +0 -2
- package/dist/core/web/public/next/assets/command-catalog-BdtDH93o.js.map +0 -1
- package/dist/core/web/public/next/assets/context-model-Dwd49-dp.js +0 -2
- package/dist/core/web/public/next/assets/context-model-MT17V86_.js +0 -2
- package/dist/core/web/public/next/assets/context-queries-xVKIeynP.js +0 -2
- package/dist/core/web/public/next/assets/control-queries-DOZR-D8G.js +0 -2
- package/dist/core/web/public/next/assets/dock-panes-UKS-mXhr.js +0 -2
- package/dist/core/web/public/next/assets/dock-panes-UKS-mXhr.js.map +0 -1
- package/dist/core/web/public/next/assets/fleet-queries-BSdRlUwJ.js +0 -2
- package/dist/core/web/public/next/assets/git-model-CivuBY_D.js +0 -5
- package/dist/core/web/public/next/assets/global-Di2PUgj4.js +0 -2
- package/dist/core/web/public/next/assets/global-Di2PUgj4.js.map +0 -1
- package/dist/core/web/public/next/assets/global-_tOCFt9y.css +0 -1
- package/dist/core/web/public/next/assets/guarded-action-CvOHcqyH.js +0 -2
- package/dist/core/web/public/next/assets/guarded-action-CvOHcqyH.js.map +0 -1
- package/dist/core/web/public/next/assets/icons-B_yuAgdN.js +0 -2
- package/dist/core/web/public/next/assets/icons-B_yuAgdN.js.map +0 -1
- package/dist/core/web/public/next/assets/mutations-Dpsql5t7.js +0 -2
- package/dist/core/web/public/next/assets/overnight-queries-X-44Gsw5.js +0 -2
- package/dist/core/web/public/next/assets/primitives-BDIcUvob.js +0 -1
- package/dist/core/web/public/next/assets/reasoning-pref-B9-DJUXP.js +0 -2
- package/dist/core/web/public/next/assets/seat-subscription-CH6fW4fJ.js +0 -2
- package/dist/core/web/public/next/assets/slots-Ds9ZIqUL.js +0 -3
- package/dist/core/web/public/next/assets/surface-data-J52iIGMD.js +0 -2
- package/dist/core/web/public/next/assets/surface-prefetch-CgZ-LEJK.js +0 -2
- package/dist/core/web/public/next/assets/use-guarded-action-C2HlSzkz.js +0 -2
- package/dist/core/web/public/next/assets/use-token-gate-B3IJL6bf.js +0 -2
- package/dist/core/web/public/next/assets/useActivity-Bk3XgXjL.js +0 -2
- package/dist/core/web/public/next/assets/useActivity-Bk3XgXjL.js.map +0 -1
- package/dist/core/web/public/next/assets/useChartWidth-BAtVgn2n.css +0 -1
- package/dist/core/web/public/next/assets/useChartWidth-lZ9PrQn0.js +0 -2
- package/dist/core/web/public/next/assets/verse-model-D7NZQFAR.js +0 -2
- package/dist/core/web/public/next/assets/verse-model-D7NZQFAR.js.map +0 -1
- package/dist/core/web/public/next/assets/verse-queries-DvIJcn6Z.js +0 -2
- package/dist/core/web/public/next/assets/verse-queries-DvIJcn6Z.js.map +0 -1
- package/dist/core/web/public/next/assets/verse-store-DjBWj04q.js +0 -3
- package/dist/core/web/public/next/assets/verse-store-DjBWj04q.js.map +0 -1
- package/dist/core/web/public/next/assets/verse-ui-store-zafyzXKD.js +0 -3
- package/dist/core/web/public/next/assets/warmup-BR6pxAKs.js +0 -3
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"command-catalog-Bb_PxC5w.js","names":[],"sources":["../../../../../../src/web-ui/routes/verse/shell/command-catalog.ts"],"sourcesContent":["/**\n * routes/verse/shell/command-catalog.ts — every workbench command and its\n * keys, in ONE table (unit C0; SPEC-310C §1).\n *\n * The ⌘K palette (C1), the shortcuts overlay (⌘/), the native menu bridge\n * (C8), the drawer and every surface's key handler read this table; the key\n * test reads it too, which is how \"no two commands share a key\" and \"no key\n * the native menu already owns\" stay true as units add commands. A key that\n * is not here does not exist.\n *\n * Pure data plus pure helpers — no React, no DOM beyond reading a\n * KeyboardEvent-shaped object — so the palette can import it without pulling\n * a surface into its chunk.\n *\n * Adding a command: one entry below (a change request to C0 when another\n * unit needs it). The handler lives with the unit that owns the behaviour and\n * dispatches on the command `id`.\n */\n\n// ===========================================================================\n// Scopes — where a key is live\n// ===========================================================================\n\n/**\n * global anywhere in the workbench (except inside the palette, which\n * owns every key while open, and native text editing keys)\n * chat the Chat surface has focus (transcript, sidebar, dock)\n * composer the composer's text box has focus\n * drawer the Needs-you drawer list has focus (bare letters are safe\n * there: nothing in it takes text)\n * chart a chart card has focus\n */\nexport const COMMAND_SCOPES = ['global', 'chat', 'composer', 'drawer', 'chart'] as const;\nexport type CommandScope = (typeof COMMAND_SCOPES)[number];\n\n/**\n * The scopes live AT THE SAME TIME as each scope (itself included). A key\n * must be unique across every such set — the key test checks exactly this —\n * while two scopes that are never live together (the drawer's bare `Enter`\n * and the composer's) may reuse a key.\n */\nexport const SCOPE_LAYERS: Readonly<Record<CommandScope, readonly CommandScope[]>> = {\n global: ['global'],\n chat: ['chat', 'global'],\n composer: ['composer', 'chat', 'global'],\n drawer: ['drawer', 'global'],\n chart: ['chart', 'global'],\n};\n\n// ===========================================================================\n// Keys\n// ===========================================================================\n\n/**\n * One key chord. `key` is the UNSHIFTED US-layout name: a lowercase letter or\n * digit, a punctuation character, or one of the named keys below. `mod` is ⌘\n * on macOS and Ctrl elsewhere (\"CmdOrCtrl\"); `ctrl` is the literal ⌃ key.\n */\nexport interface KeyChord {\n key: string;\n mod?: true;\n ctrl?: true;\n shift?: true;\n alt?: true;\n}\n\nexport const NAMED_KEYS = ['enter', 'escape', 'tab', 'space', 'arrowup', 'arrowdown', 'arrowleft', 'arrowright', 'backspace'] as const;\n\n/**\n * Keys the page never binds, because macOS or the desktop shell answers them\n * first: the native menu's own accelerators live in app_menu.rs (the key test\n * parses that file), these are the system's.\n */\nexport const SYSTEM_RESERVED_CHORDS: readonly KeyChord[] = [\n { key: 'space', mod: true }, // Spotlight\n { key: 'space', ctrl: true }, // input sources\n { key: 'tab', mod: true }, // app switcher\n { key: 'tab', mod: true, shift: true },\n { key: '`', mod: true }, // cycle this app's windows\n { key: '3', mod: true, shift: true }, // screenshots\n { key: '4', mod: true, shift: true },\n { key: '5', mod: true, shift: true },\n];\n\n/**\n * How a key reaches the page when a native layer is involved.\n * menu the desktop menu owns the accelerator and forwards the\n * command (via `ashlr:desktop-command`); the page's own\n * handler only fires in a plain browser.\n * global-hotkey registered system-wide by the desktop app (C8); the page\n * never binds it — it is listed for the shortcuts overlay.\n */\nexport type NativeBinding =\n | { kind: 'menu'; desktopCommand: DesktopCommandName; accelerator: string }\n | { kind: 'global-hotkey'; accelerator: string };\n\n// ===========================================================================\n// The window event (units that are not on the command bus)\n// ===========================================================================\n\n/**\n * The window event the palette (C1) and the native menu bridge dispatch to\n * run a catalog command on a surface that listens for it instead of\n * registering on the command bus:\n * window.dispatchEvent(new CustomEvent(WORKBENCH_COMMAND_EVENT, { detail: { id } }))\n * The composer (C3) answers the `composer.*` ids it implements.\n *\n * It lives HERE, beside the ids it carries, so the shell (run-command.ts)\n * does not have to import a composer module to name its own event —\n * composer/composer-keys.ts re-exports it for its existing importers.\n */\nexport const WORKBENCH_COMMAND_EVENT = 'ashlr:command';\n\n// ===========================================================================\n// Desktop commands (C8 → page)\n// ===========================================================================\n\n/**\n * What the desktop shell may send the page (`ashlr:desktop-command`), and the\n * catalog command each one runs. C8 dispatches these from the menu bar, the\n * tray, a clicked notification (focus regained within 60 s) and the global\n * hotkey; C1 runs them. `open-session:<id>` carries a session id.\n */\nexport const DESKTOP_COMMAND_NAMES = ['open-settings', 'toggle-theme', 'open-needs-you', 'new-chat', 'focus-composer'] as const;\n// Its own literal list (not `keyof typeof DESKTOP_COMMANDS`): NativeBinding\n// names it, WORKBENCH_COMMANDS uses NativeBinding, and DESKTOP_COMMANDS is\n// typed by CommandId — deriving it from the map would make the types circular.\nexport type DesktopCommandName = (typeof DESKTOP_COMMAND_NAMES)[number];\n\nexport const DESKTOP_COMMANDS: Readonly<Record<DesktopCommandName, CommandId>> = {\n 'open-settings': 'section.settings',\n 'toggle-theme': 'appearance.toggle-theme',\n 'open-needs-you': 'needs-you.open',\n 'new-chat': 'chat.new',\n 'focus-composer': 'app.summon',\n};\n\n/** `open-session:<id>` — the notification for a finished or failed chat. */\nexport const OPEN_SESSION_COMMAND_RE = /^open-session:([A-Za-z0-9._-]{1,128})$/;\n\nexport type ParsedDesktopCommand =\n | { kind: 'command'; name: DesktopCommandName; commandId: CommandId }\n | { kind: 'open-session'; sessionId: string };\n\n/** Parse a raw desktop command string; null for anything unknown (never guessed). */\nexport function parseDesktopCommand(raw: unknown): ParsedDesktopCommand | null {\n if (typeof raw !== 'string') return null;\n if (Object.prototype.hasOwnProperty.call(DESKTOP_COMMANDS, raw)) {\n const name = raw as DesktopCommandName;\n return { kind: 'command', name, commandId: DESKTOP_COMMANDS[name] };\n }\n const session = OPEN_SESSION_COMMAND_RE.exec(raw);\n return session ? { kind: 'open-session', sessionId: session[1]! } : null;\n}\n\n// ===========================================================================\n// The palette\n// ===========================================================================\n\n/** Result groups, in the order the palette shows them (SPEC-310C §1). */\nexport const PALETTE_GROUPS = [\n { id: 'needs-you', label: 'Needs you' },\n { id: 'chats', label: 'Chats' },\n { id: 'actions', label: 'Actions' },\n { id: 'go-to', label: 'Go to' },\n { id: 'seats-apps', label: 'Seats & Apps' },\n { id: 'projects', label: 'Projects' },\n] as const;\nexport type PaletteGroupId = (typeof PALETTE_GROUPS)[number]['id'];\n\n/** A leading `>` limits results to actions; `#` to chats. */\nexport const PALETTE_PREFIXES: Readonly<Record<'>' | '#', PaletteGroupId>> = { '>': 'actions', '#': 'chats' };\n\n/** An empty query shows the last this-many actions run. */\nexport const PALETTE_RECENT_LIMIT = 5;\n\n/** The palette opens in under this (it lives in the shell chunk). */\nexport const PALETTE_OPEN_BUDGET_MS = 50;\n\n// ===========================================================================\n// Commands\n// ===========================================================================\n\nexport type CommandArgumentKind = 'seat' | 'project' | 'section' | 'session';\n\n/**\n * A guarded command asks for confirmation FIRST, then the mutation token\n * (the palette must never be a shortcut around the confirm step its regular\n * UI requires).\n */\nexport interface CommandGuard {\n confirm: { title: string; body: string; confirmLabel: string; destructive: boolean };\n token: boolean;\n}\n\n/** Sections of the shortcuts overlay (⌘/), in display order. */\nexport const SHORTCUT_SECTIONS = ['Surfaces', 'Navigation', 'Chat', 'Dock', 'Composer', 'Needs you', 'Charts', 'App'] as const;\nexport type ShortcutSection = (typeof SHORTCUT_SECTIONS)[number];\n\nexport interface WorkbenchCommand {\n id: string;\n /** Palette / overlay text: a verb phrase, operator language. */\n title: string;\n scope: CommandScope;\n /** Empty = reachable from the palette (or a button) only. */\n keys: readonly KeyChord[];\n /** Where the palette lists it; null = not a palette entry (drawer and chart keys). */\n group: 'actions' | 'go-to' | null;\n section: ShortcutSection;\n keywords?: readonly string[];\n /** Tab fills this argument (\"New chat on…\" → a seat). */\n argument?: { kind: CommandArgumentKind; prompt: string };\n guard?: CommandGuard;\n native?: NativeBinding;\n /** A qualifier the overlay prints under the title. */\n note?: string;\n}\n\nconst STOP_CHATS_GUARD: CommandGuard = {\n confirm: {\n title: 'Stop every running chat?',\n body: 'Each running turn is cancelled. Queued follow-ups are held, not sent.',\n confirmLabel: 'Stop chats',\n destructive: true,\n },\n token: true,\n};\n\nconst STOP_FLEET_GUARD: CommandGuard = {\n confirm: {\n title: 'Stop the fleet?',\n body: 'Autonomous work halts within one tick and stays stopped until you resume it. Chats keep running.',\n confirmLabel: 'Stop fleet',\n destructive: true,\n },\n token: true,\n};\n\nconst surface = (n: 1 | 2 | 3 | 4 | 5, id: string, name: string): WorkbenchCommand => ({\n id: `surface.${id}`,\n title: `Go to ${name}`,\n scope: 'global',\n keys: [{ key: String(n), mod: true }],\n group: 'go-to',\n section: 'Surfaces',\n keywords: [name.toLowerCase()],\n});\n\nexport const WORKBENCH_COMMANDS = [\n // ── Surfaces (⌘1 Command … ⌘5 Chat) and the gear tray ────────────────────\n surface(1, 'command', 'Command'),\n surface(2, 'fleet', 'Fleet'),\n surface(3, 'growth', 'Growth'),\n surface(4, 'mind', 'Mind'),\n surface(5, 'chat', 'Chat'),\n {\n id: 'section.settings',\n title: 'Open Settings',\n scope: 'global',\n keys: [{ key: ',', mod: true }],\n group: 'go-to',\n section: 'Surfaces',\n keywords: ['preferences', 'appearance'],\n native: { kind: 'menu', desktopCommand: 'open-settings', accelerator: 'CmdOrCtrl+,' },\n },\n { id: 'section.apps', title: 'Open Apps & Accounts', scope: 'global', keys: [], group: 'go-to', section: 'Surfaces', keywords: ['mcp', 'accounts', 'seats', 'integrations', 'ollama'] },\n { id: 'section.usage', title: 'Open Usage', scope: 'global', keys: [], group: 'go-to', section: 'Surfaces', keywords: ['capacity', 'spend', 'limits'] },\n\n // ── Navigation ───────────────────────────────────────────────────────────\n { id: 'palette.open', title: 'Command palette', scope: 'global', keys: [{ key: 'k', mod: true }], group: null, section: 'Navigation' },\n { id: 'needs-you.open', title: 'Open Needs you', scope: 'global', keys: [{ key: 'j', mod: true }], group: 'actions', section: 'Navigation', keywords: ['approvals', 'inbox', 'triage'] },\n { id: 'shortcuts.open', title: 'Keyboard shortcuts', scope: 'global', keys: [{ key: '/', mod: true }], group: 'actions', section: 'Navigation', keywords: ['keys', 'help'] },\n // The Resources drawer (3.11 C6): the key toggles it, the palette opens it.\n // ⌘. — not ⇧⌘R, which browsers keep for a hard reload.\n {\n id: 'resources.toggle',\n title: 'Show resources',\n scope: 'global',\n keys: [{ key: '.', mod: true }],\n group: 'actions',\n section: 'Navigation',\n keywords: ['accounts', 'seats', 'capacity', 'credits', 'cloud', 'local models'],\n },\n {\n id: 'resources.bar.toggle',\n title: 'Show or hide the resource bar',\n scope: 'global',\n keys: [],\n group: 'actions',\n section: 'Navigation',\n keywords: ['battery', 'usage bars', 'accounts', 'capacity', 'rail', 'resources'],\n },\n { id: 'history.back', title: 'Back', scope: 'global', keys: [{ key: '[', mod: true }], group: null, section: 'Navigation', note: 'through surfaces and chats' },\n { id: 'history.forward', title: 'Forward', scope: 'global', keys: [{ key: ']', mod: true }], group: null, section: 'Navigation', note: 'through surfaces and chats' },\n { id: 'chat.recent-next', title: 'Next recent chat', scope: 'global', keys: [{ key: 'tab', ctrl: true }], group: null, section: 'Navigation' },\n { id: 'chat.recent-prev', title: 'Previous recent chat', scope: 'global', keys: [{ key: 'tab', ctrl: true, shift: true }], group: null, section: 'Navigation' },\n { id: 'rail.toggle-labels', title: 'Show or hide rail labels', scope: 'global', keys: [{ key: '\\\\', mod: true, shift: true }], group: 'actions', section: 'Navigation' },\n\n // ── Chats ────────────────────────────────────────────────────────────────\n { id: 'chat.new', title: 'New chat', scope: 'global', keys: [{ key: 'n', mod: true }], group: 'actions', section: 'Chat' },\n {\n id: 'chat.new-on',\n title: 'New chat on…',\n scope: 'global',\n keys: [],\n group: 'actions',\n section: 'Chat',\n argument: { kind: 'seat', prompt: 'Seat' },\n keywords: ['seat', 'account', 'engine'],\n },\n { id: 'chat.sidebar', title: 'Show or hide the chat list', scope: 'chat', keys: [{ key: 'b', mod: true }], group: 'actions', section: 'Chat' },\n { id: 'chat.find', title: 'Find in chat', scope: 'chat', keys: [{ key: 'f', mod: true }], group: 'actions', section: 'Chat', keywords: ['search'] },\n { id: 'chat.turn-prev', title: 'Previous turn', scope: 'chat', keys: [{ key: 'arrowup', alt: true }], group: null, section: 'Chat' },\n { id: 'chat.turn-next', title: 'Next turn', scope: 'chat', keys: [{ key: 'arrowdown', alt: true }], group: null, section: 'Chat' },\n { id: 'chats.stop-all', title: 'Stop running chats…', scope: 'global', keys: [], group: 'actions', section: 'Chat', guard: STOP_CHATS_GUARD, keywords: ['cancel', 'halt'] },\n // ── Git (C5's BranchBar serves these) ─────────────────────────────────────\n // Palette-only and unguarded ON PURPOSE: each OPENS BranchBar's own dialog\n // (CreatePrDialog / MergeDialog), which carries the before-click disclosure,\n // and every write inside it still goes through the mutation-token gate —\n // so the palette is never a shortcut around a confirm step. No key: a\n // merge is never one keystroke away. Chat-scoped because the bar lives\n // above the composer; from another surface the shell switches to Chat and\n // parks the command until BranchBar registers (command-bus).\n { id: 'git.create-pr', title: 'Create pull request…', scope: 'chat', keys: [], group: 'actions', section: 'Chat', keywords: ['pr', 'github', 'git', 'open pull request'] },\n { id: 'git.merge-pr', title: 'Merge pull request…', scope: 'chat', keys: [], group: 'actions', section: 'Chat', keywords: ['pr', 'github', 'git', 'land', 'ship'] },\n\n // ── Dock (C2 container; panes from dock-catalog.ts) ───────────────────────\n { id: 'dock.toggle', title: 'Show or hide the dock', scope: 'chat', keys: [{ key: '\\\\', mod: true }], group: 'actions', section: 'Dock' },\n { id: 'dock.terminal', title: 'Terminal', scope: 'chat', keys: [{ key: '`', ctrl: true }], group: 'actions', section: 'Dock', keywords: ['shell', 'console'] },\n { id: 'dock.terminal-new', title: 'New terminal tab', scope: 'chat', keys: [{ key: '`', ctrl: true, shift: true }], group: 'actions', section: 'Dock' },\n { id: 'dock.preview', title: 'Preview', scope: 'chat', keys: [{ key: 'b', mod: true, shift: true }], group: 'actions', section: 'Dock', keywords: ['browser', 'dev server'] },\n { id: 'dock.diff', title: 'Review changes', scope: 'chat', keys: [{ key: 'd', mod: true, shift: true }], group: 'actions', section: 'Dock', keywords: ['diff', 'git'] },\n\n // ── Composer ─────────────────────────────────────────────────────────────\n { id: 'composer.permission', title: 'Permission mode…', scope: 'chat', keys: [{ key: 'm', mod: true, shift: true }], group: 'actions', section: 'Composer', keywords: ['plan', 'bypass', 'auto'] },\n { id: 'composer.model', title: 'Model…', scope: 'chat', keys: [{ key: 'i', mod: true, shift: true }], group: 'actions', section: 'Composer' },\n { id: 'composer.effort', title: 'Effort…', scope: 'chat', keys: [{ key: 'e', mod: true, shift: true }], group: 'actions', section: 'Composer', keywords: ['reasoning', 'thinking'] },\n { id: 'composer.attach', title: 'Attach files…', scope: 'chat', keys: [{ key: 'u', mod: true }], group: 'actions', section: 'Composer', keywords: ['upload', 'image'] },\n { id: 'composer.send', title: 'Send', scope: 'composer', keys: [{ key: 'enter' }], group: null, section: 'Composer', note: 'queues while a turn runs (up to 3)' },\n { id: 'composer.stop-and-send', title: 'Stop and send', scope: 'composer', keys: [{ key: 'enter', mod: true, shift: true }], group: null, section: 'Composer' },\n { id: 'composer.stop', title: 'Stop the running turn', scope: 'composer', keys: [{ key: 'escape' }], group: null, section: 'Composer', note: 'only from an empty composer with no overlay open' },\n\n // ── Needs-you drawer ─────────────────────────────────────────────────────\n { id: 'drawer.next', title: 'Next item', scope: 'drawer', keys: [{ key: 'j' }], group: null, section: 'Needs you' },\n { id: 'drawer.prev', title: 'Previous item', scope: 'drawer', keys: [{ key: 'k' }], group: null, section: 'Needs you' },\n { id: 'drawer.open', title: 'Open item', scope: 'drawer', keys: [{ key: 'enter' }], group: null, section: 'Needs you' },\n { id: 'drawer.approve', title: 'Approve', scope: 'drawer', keys: [{ key: 'a' }], group: null, section: 'Needs you', note: 'confirms, then asks for the token' },\n { id: 'drawer.reject', title: 'Reject', scope: 'drawer', keys: [{ key: 'r' }], group: null, section: 'Needs you', note: 'confirms, then asks for the token' },\n { id: 'drawer.veto', title: 'Veto', scope: 'drawer', keys: [{ key: 'v' }], group: null, section: 'Needs you', note: 'confirms, then asks for the token' },\n { id: 'drawer.done', title: 'Mark done', scope: 'drawer', keys: [{ key: 'e' }], group: null, section: 'Needs you' },\n { id: 'drawer.split-prev', title: 'Previous split', scope: 'drawer', keys: [{ key: 'h' }], group: null, section: 'Needs you' },\n { id: 'drawer.split-next', title: 'Next split', scope: 'drawer', keys: [{ key: 'l' }], group: null, section: 'Needs you' },\n\n // ── Charts ───────────────────────────────────────────────────────────────\n { id: 'chart.table', title: 'Show as a table', scope: 'chart', keys: [{ key: 't' }], group: null, section: 'Charts', note: 'when a chart card has focus' },\n\n // ── App ──────────────────────────────────────────────────────────────────\n {\n id: 'appearance.toggle-theme',\n title: 'Toggle light / dark',\n scope: 'global',\n keys: [{ key: 'l', mod: true, shift: true }],\n group: 'actions',\n section: 'App',\n keywords: ['theme', 'dark mode'],\n native: { kind: 'menu', desktopCommand: 'toggle-theme', accelerator: 'Shift+CmdOrCtrl+L' },\n },\n {\n id: 'app.summon',\n title: 'Show Verse and focus the composer',\n scope: 'global',\n keys: [{ key: 'space', ctrl: true, alt: true }],\n group: null,\n section: 'App',\n note: 'system-wide; turn on in Settings ▸ Desktop',\n native: { kind: 'global-hotkey', accelerator: 'Control+Alt+Space' },\n },\n { id: 'fleet.stop', title: 'Stop the fleet…', scope: 'global', keys: [], group: 'actions', section: 'App', guard: STOP_FLEET_GUARD, keywords: ['kill', 'halt', 'autonomy'] },\n] as const satisfies readonly WorkbenchCommand[];\n\nexport type CommandId = (typeof WORKBENCH_COMMANDS)[number]['id'];\n\nconst BY_ID: ReadonlyMap<string, WorkbenchCommand> = new Map(WORKBENCH_COMMANDS.map((c) => [c.id, c as WorkbenchCommand]));\n\nexport function findCommand(id: string): WorkbenchCommand | null {\n return BY_ID.get(id) ?? null;\n}\n\n/** Palette entries of one group, in catalog order. */\nexport function paletteCommands(group: 'actions' | 'go-to'): WorkbenchCommand[] {\n return (WORKBENCH_COMMANDS as readonly WorkbenchCommand[]).filter((c) => c.group === group);\n}\n\n/** The shortcuts overlay: every command with keys, grouped by section, in display order. */\nexport function shortcutSections(): Array<{ section: ShortcutSection; commands: WorkbenchCommand[] }> {\n const withKeys = (WORKBENCH_COMMANDS as readonly WorkbenchCommand[]).filter((c) => c.keys.length > 0);\n return SHORTCUT_SECTIONS.map((section) => ({ section, commands: withKeys.filter((c) => c.section === section) })).filter(\n (s) => s.commands.length > 0,\n );\n}\n\n// ===========================================================================\n// Matching and display\n// ===========================================================================\n\nexport type KeyPlatform = 'mac' | 'other';\n\n/** The platform the page runs on, for ⌘ vs Ctrl. */\nexport function detectKeyPlatform(): KeyPlatform {\n if (typeof navigator === 'undefined') return 'mac';\n const nav = navigator as Navigator & { userAgentData?: { platform?: string } };\n const platform = nav.userAgentData?.platform ?? nav.platform ?? '';\n return /mac|iphone|ipad|ipod/i.test(platform) ? 'mac' : 'other';\n}\n\n/** The part of a KeyboardEvent matching needs (so tests can pass plain objects). */\nexport interface KeyEventLike {\n key: string;\n code?: string;\n metaKey: boolean;\n ctrlKey: boolean;\n shiftKey: boolean;\n altKey: boolean;\n}\n\nconst CODE_CHARS: Readonly<Record<string, string>> = {\n Backslash: '\\\\',\n Backquote: '`',\n BracketLeft: '[',\n BracketRight: ']',\n Slash: '/',\n Comma: ',',\n Period: '.',\n Semicolon: ';',\n Quote: \"'\",\n Minus: '-',\n Equal: '=',\n Space: 'space',\n};\n\nconst KEY_ALIASES: Readonly<Record<string, string>> = {\n ' ': 'space',\n spacebar: 'space',\n esc: 'escape',\n return: 'enter',\n up: 'arrowup',\n down: 'arrowdown',\n left: 'arrowleft',\n right: 'arrowright',\n};\n\n/**\n * The event's key as a chord `key`. Letters come from `event.key` (so ⌘K is\n * ⌘K on any keyboard layout); digits and punctuation come from `event.code`\n * when it is known, because Shift and ⌥ change `event.key` (⇧\\ reads \"|\",\n * ⌥J reads \"∆\") while the chord names the unshifted key.\n */\nexport function eventKeyName(event: Pick<KeyEventLike, 'key' | 'code'>): string {\n const key = event.key ?? '';\n if (/^[a-z]$/i.test(key)) return key.toLowerCase();\n const code = event.code ?? '';\n if (/^Digit[0-9]$/.test(code)) return code.slice(5);\n if (CODE_CHARS[code]) return CODE_CHARS[code]!;\n if (/^Key[A-Z]$/.test(code)) return code.slice(3).toLowerCase();\n const lower = key.toLowerCase();\n return KEY_ALIASES[lower] ?? lower;\n}\n\n/**\n * Does `event` press `chord`? Modifiers must match EXACTLY (⌘K is not ⇧⌘K).\n * Off macOS, `mod` and `ctrl` are both the Ctrl key and ⌘/Win never matches.\n */\nexport function chordMatches(event: KeyEventLike, chord: KeyChord, platform: KeyPlatform = detectKeyPlatform()): boolean {\n if (platform === 'mac') {\n if (Boolean(chord.mod) !== event.metaKey) return false;\n if (Boolean(chord.ctrl) !== event.ctrlKey) return false;\n } else {\n if (event.metaKey) return false;\n if (Boolean(chord.mod || chord.ctrl) !== event.ctrlKey) return false;\n }\n if (Boolean(chord.shift) !== event.shiftKey) return false;\n if (Boolean(chord.alt) !== event.altKey) return false;\n return eventKeyName(event) === chord.key;\n}\n\n/**\n * The command a key press runs, given the scopes live right now (innermost\n * first, e.g. ['composer', 'chat', 'global']). Null when nothing is bound —\n * the caller must then leave the event alone.\n */\nexport function matchCommand(event: KeyEventLike, liveScopes: readonly CommandScope[], platform: KeyPlatform = detectKeyPlatform()): WorkbenchCommand | null {\n for (const scope of liveScopes) {\n for (const command of WORKBENCH_COMMANDS as readonly WorkbenchCommand[]) {\n if (command.scope !== scope) continue;\n // The page never handles a system-wide hotkey itself.\n if (command.native?.kind === 'global-hotkey') continue;\n if (command.keys.some((chord) => chordMatches(event, chord, platform))) return command;\n }\n }\n return null;\n}\n\n/** Stable identity for a chord (\"mod+shift+b\"), for de-duplication and tests. */\nexport function chordId(chord: KeyChord): string {\n return [chord.ctrl ? 'ctrl' : '', chord.alt ? 'alt' : '', chord.shift ? 'shift' : '', chord.mod ? 'mod' : '', chord.key].filter(Boolean).join('+');\n}\n\nconst MAC_KEY_GLYPHS: Readonly<Record<string, string>> = {\n enter: '↩',\n escape: 'Esc',\n tab: '⇥',\n space: 'Space',\n arrowup: '↑',\n arrowdown: '↓',\n arrowleft: '←',\n arrowright: '→',\n backspace: '⌫',\n};\n\nconst OTHER_KEY_NAMES: Readonly<Record<string, string>> = {\n enter: 'Enter',\n escape: 'Esc',\n tab: 'Tab',\n space: 'Space',\n arrowup: '↑',\n arrowdown: '↓',\n arrowleft: '←',\n arrowright: '→',\n backspace: 'Backspace',\n};\n\n/**\n * How a chord is printed. macOS uses Apple's modifier order (⌃ ⌥ ⇧ ⌘) with\n * no separators (\"⇧⌘B\", \"⌃`\", \"⌥↑\"); elsewhere \"Ctrl+Shift+B\".\n */\nexport function formatChord(chord: KeyChord, platform: KeyPlatform = detectKeyPlatform()): string {\n const key = chord.key.length === 1 ? chord.key.toUpperCase() : (platform === 'mac' ? MAC_KEY_GLYPHS : OTHER_KEY_NAMES)[chord.key] ?? chord.key;\n if (platform === 'mac') {\n return `${chord.ctrl ? '⌃' : ''}${chord.alt ? '⌥' : ''}${chord.shift ? '⇧' : ''}${chord.mod ? '⌘' : ''}${key}`;\n }\n const parts = [chord.mod || chord.ctrl ? 'Ctrl' : '', chord.alt ? 'Alt' : '', chord.shift ? 'Shift' : '', key].filter(Boolean);\n return parts.join('+');\n}\n\n/**\n * Tauri's accelerator string for a chord (\"Shift+CmdOrCtrl+L\") — what C8\n * writes in app_menu.rs, and what the key test compares against.\n */\nexport function chordAccelerator(chord: KeyChord): string {\n const TAURI_KEYS: Readonly<Record<string, string>> = {\n enter: 'Enter',\n escape: 'Escape',\n tab: 'Tab',\n space: 'Space',\n arrowup: 'Up',\n arrowdown: 'Down',\n arrowleft: 'Left',\n arrowright: 'Right',\n backspace: 'Backspace',\n };\n const key = TAURI_KEYS[chord.key] ?? (chord.key.length === 1 ? chord.key.toUpperCase() : chord.key);\n return [chord.shift ? 'Shift' : '', chord.ctrl ? 'Control' : '', chord.alt ? 'Alt' : '', chord.mod ? 'CmdOrCtrl' : '', key].filter(Boolean).join('+');\n}\n"],"mappings":"AA+GA,IAAa,EAA0B,gBAkB1B,EAAoE,CAC/E,gBAAiB,mBACjB,eAAgB,0BAChB,iBAAkB,iBAClB,WAAY,WACZ,iBAAkB,YACpB,EAGa,EAA0B,yCAOvC,SAAgB,EAAoB,EAA2C,CAC7E,GAAI,OAAO,GAAQ,SAAU,OAAO,KACpC,GAAI,OAAO,UAAU,eAAe,KAAK,EAAkB,CAAG,EAAG,CAC/D,IAAM,EAAO,EACb,MAAO,CAAE,KAAM,UAAW,OAAM,UAAW,EAAiB,EAAM,CACpE,CACA,IAAM,EAAU,EAAwB,KAAK,CAAG,EAChD,OAAO,EAAU,CAAE,KAAM,eAAgB,UAAW,EAAQ,EAAI,EAAI,IACtE,CAOA,IAAa,EAAiB,CAC5B,CAAE,GAAI,YAAa,MAAO,WAAY,EACtC,CAAE,GAAI,QAAS,MAAO,OAAQ,EAC9B,CAAE,GAAI,UAAW,MAAO,SAAU,EAClC,CAAE,GAAI,QAAS,MAAO,OAAQ,EAC9B,CAAE,GAAI,aAAc,MAAO,cAAe,EAC1C,CAAE,GAAI,WAAY,MAAO,UAAW,CACtC,EAIa,EAAgE,C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AAiB,EAAM,MAAQ,EAAM,IAK3I,OAJI,IAAa,MACR,GAAG,EAAM,KAAO,IAAM,KAAK,EAAM,IAAM,IAAM,KAAK,EAAM,MAAQ,IAAM,KAAK,EAAM,IAAM,IAAM,KAAK,IAE7F,CAAC,EAAM,KAAO,EAAM,KAAO,OAAS,GAAI,EAAM,IAAM,MAAQ,GAAI,EAAM,MAAQ,QAAU,GAAI,CAAG,CAAC,CAAC,OAAO,OAC/G,CAAA,CAAM,KAAK,GAAG,CACvB"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
var e=2e4,t=13e3;function n(e){return typeof e==`number`&&Number.isFinite(e)&&e>0?Math.floor(e):null}function r(r,i,a=null){let o=Math.min(r,n(a)??r),s=Math.min(n(i)??2e4,e);return Math.max(0,o-s-t)}function i(e){return Math.floor(e*.9)}function a(e){let t=n(e.runtimeWindow);if(t===null)return e.budget?.autoCompactAt??null;if(e.budget&&e.budget.contextWindow===t)return e.budget.autoCompactAt;switch(e.engine){case`claude`:case`local`:return r(t,e.maxOutputTokens??null,e.autocompactWindow??null);case`codex`:return i(Math.round(t*100/95));default:{let n=e.budget;return!n||n.autoCompactAt===null||n.contextWindow<=0?null:Math.floor(t*(n.autoCompactAt/n.contextWindow))}}}export{a as i,e as n,n as r,t};
|
|
2
|
+
//# sourceMappingURL=compaction-point-VL9oegWS.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compaction-point-VL9oegWS.js","names":[],"sources":["../../../../../../src/core/verse/compaction-point.ts"],"sourcesContent":["/**\n * Ashlr Verse — where each engine auto-compacts, including when the CLI\n * reports a different window at runtime. Part of context-math.ts, which\n * re-exports everything here; see its header for where each formula comes\n * from (docs/VERSE-CONTEXT.md is the prose authority for every constant).\n *\n * WHY A SEPARATE MODULE: the browser's session store (web-ui verse-store.ts)\n * reconciles the compaction point as context readings stream in, which puts\n * it on the chat first-paint path. Importing context-math there pulled the\n * whole module (budgets, occupancy, fit and handoff advice) into the chat\n * first-paint critical JS; importing this file pulls only these formulas.\n *\n * PURE and BROWSER-SAFE: no node imports, no I/O.\n */\n\nimport type { VerseContextBudget, VerseEngine } from './types.js';\n\n/** Claude Code reserves min(max output, this) of the window for the reply. */\nexport const CLAUDE_OUTPUT_RESERVE_CAP = 20_000;\n/** …and compacts this many tokens below the reserved window. */\nexport const CLAUDE_COMPACT_BUFFER = 13_000;\n/** Codex: default `effective_context_window_percent` in every catalog entry. */\nexport const CODEX_EFFECTIVE_WINDOW_PERCENT = 95;\n/** Codex: auto-compaction fires at this fraction of the RAW window. */\nexport const CODEX_AUTO_COMPACT_FRACTION = 0.9;\n\n/** A positive finite number, floored; null for anything else. */\nexport function positiveInt(value: unknown): number | null {\n return typeof value === 'number' && Number.isFinite(value) && value > 0 ? Math.floor(value) : null;\n}\n\n/**\n * Claude Code's auto-compaction point.\n *\n * @param modelWindow the model's context window (1_000_000, 200_000, or\n * the local num_ctx passed in CLAUDE_CODE_MAX_CONTEXT_TOKENS)\n * @param maxOutputTokens the model's default max output; null → assume the cap\n * @param autocompactWindow the `--autocompact` value in force; null → `auto`\n * (the full model window)\n */\nexport function claudeAutoCompactAt(\n modelWindow: number,\n maxOutputTokens: number | null,\n autocompactWindow: number | null = null,\n): number {\n const window = Math.min(modelWindow, positiveInt(autocompactWindow) ?? modelWindow);\n const reserve = Math.min(positiveInt(maxOutputTokens) ?? CLAUDE_OUTPUT_RESERVE_CAP, CLAUDE_OUTPUT_RESERVE_CAP);\n return Math.max(0, window - reserve - CLAUDE_COMPACT_BUFFER);\n}\n\n/** Codex: where auto-compaction fires for a given RAW window. */\nexport function codexAutoCompactAt(rawWindow: number): number {\n return Math.floor(rawWindow * CODEX_AUTO_COMPACT_FRACTION);\n}\n\n/**\n * Recompute the compaction point when the CLI reports a window at runtime\n * that differs from the catalog budget (Claude Code clamps a 1M model to 200k\n * when long-context credit runs out; grok can upgrade a window by header).\n *\n * claude/local — fixed-buffer formula over min(runtime window, --autocompact).\n * codex — the runtime figure is the EFFECTIVE window; the compaction\n * point stays 90% of the raw window it implies.\n * grok/other — keep the budget's compaction RATIO.\n */\nexport function reconcileAutoCompactAt(input: {\n engine: VerseEngine;\n runtimeWindow: number;\n budget: VerseContextBudget | null;\n /** The `--autocompact` value in force for claude/local; null = auto. */\n autocompactWindow?: number | null;\n maxOutputTokens?: number | null;\n}): number | null {\n const runtime = positiveInt(input.runtimeWindow);\n if (runtime === null) return input.budget?.autoCompactAt ?? null;\n if (input.budget && input.budget.contextWindow === runtime) return input.budget.autoCompactAt;\n switch (input.engine) {\n case 'claude':\n case 'local':\n return claudeAutoCompactAt(runtime, input.maxOutputTokens ?? null, input.autocompactWindow ?? null);\n case 'codex':\n return codexAutoCompactAt(Math.round((runtime * 100) / CODEX_EFFECTIVE_WINDOW_PERCENT));\n default: {\n const b = input.budget;\n if (!b || b.autoCompactAt === null || b.contextWindow <= 0) return null;\n return Math.floor(runtime * (b.autoCompactAt / b.contextWindow));\n }\n }\n}\n"],"mappings":"AAkBA,IAAa,EAA4B,IAE5B,EAAwB,KAOrC,SAAgB,EAAY,EAA+B,CACzD,OAAO,OAAO,GAAU,UAAY,OAAO,SAAS,CAAK,GAAK,EAAQ,EAAI,KAAK,MAAM,CAAK,EAAI,IAChG,CAWA,SAAgB,EACd,EACA,EACA,EAAmC,KAC3B,CACR,IAAM,EAAS,KAAK,IAAI,EAAa,EAAY,CAAiB,GAAK,CAAW,EAC5E,EAAU,KAAK,IAAI,EAAY,CAAe,GAAA,IAAgC,CAAyB,EAC7G,OAAO,KAAK,IAAI,EAAG,EAAS,EAAU,CAAqB,CAC7D,CAGA,SAAgB,EAAmB,EAA2B,CAC5D,OAAO,KAAK,MAAM,EAAY,EAA2B,CAC3D,CAYA,SAAgB,EAAuB,EAOrB,CAChB,IAAM,EAAU,EAAY,EAAM,aAAa,EAC/C,GAAI,IAAY,KAAM,OAAO,EAAM,QAAQ,eAAiB,KAC5D,GAAI,EAAM,QAAU,EAAM,OAAO,gBAAkB,EAAS,OAAO,EAAM,OAAO,cAChF,OAAQ,EAAM,OAAd,CACE,IAAK,SACL,IAAK,QACH,OAAO,EAAoB,EAAS,EAAM,iBAAmB,KAAM,EAAM,mBAAqB,IAAI,EACpG,IAAK,QACH,OAAO,EAAmB,KAAK,MAAO,EAAU,IAAA,EAAqC,CAAC,EACxF,QAAS,CACP,IAAM,EAAI,EAAM,OAEhB,MADI,CAAC,GAAK,EAAE,gBAAkB,MAAQ,EAAE,eAAiB,EAAU,KAC5D,KAAK,MAAM,GAAW,EAAE,cAAgB,EAAE,cAAc,CACjE,CACF,CACF"}
|
package/dist/core/web/public/next/assets/{composer-keys-DBRymxQn.js → composer-keys-su0g1h9o.js}
RENAMED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{c as e,i as t,s as n}from"./command-catalog-
|
|
2
|
-
//# sourceMappingURL=composer-keys-
|
|
1
|
+
import{c as e,i as t,s as n}from"./command-catalog-Bb_PxC5w.js";var r=[`composer.permission`,`composer.model`,`composer.effort`,`composer.attach`,`composer.send`,`composer.stop-and-send`,`composer.stop`];function i(e,r){let i=n(r);return i!==null&&i.keys.some(n=>t(e,n))}function a(t){let r=n(t)?.keys[0];return r?e(r):``}export{i as n,a as r,r as t};
|
|
2
|
+
//# sourceMappingURL=composer-keys-su0g1h9o.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"composer-keys-
|
|
1
|
+
{"version":3,"file":"composer-keys-su0g1h9o.js","names":[],"sources":["../../../../../../src/web-ui/routes/verse/composer/composer-keys.ts"],"sourcesContent":["/**\n * routes/verse/composer/composer-keys.ts — the composer's keys, read from\n * C0's command catalog (the one table the palette, the shortcuts overlay and\n * the native menu also read), never re-declared here (unit C3).\n */\nimport {\n chordMatches,\n findCommand,\n formatChord,\n type KeyEventLike,\n} from '../shell/command-catalog.js';\n\n/** The composer commands this unit implements (command-catalog ids). */\nexport const COMPOSER_COMMAND_IDS = [\n 'composer.permission',\n 'composer.model',\n 'composer.effort',\n 'composer.attach',\n 'composer.send',\n 'composer.stop-and-send',\n 'composer.stop',\n] as const;\nexport type ComposerCommandId = (typeof COMPOSER_COMMAND_IDS)[number];\n\n/**\n * The window event the palette (C1) and the native menu bridge dispatch to\n * run a catalog command on the surface that owns it. Defined in C0's\n * command-catalog.ts (beside the ids it carries); re-exported here so the\n * composer's importers keep one import site.\n */\nexport { WORKBENCH_COMMAND_EVENT } from '../shell/command-catalog.js';\n\n/** Does this key event press the catalog chord for `id`? */\nexport function pressesCommand(event: KeyEventLike, id: ComposerCommandId): boolean {\n const command = findCommand(id);\n return command !== null && command.keys.some((chord) => chordMatches(event, chord));\n}\n\n/** The chord for `id` as the platform prints it (\"⇧⌘M\" / \"Ctrl+Shift+M\"); '' when unbound. */\nexport function shortcutLabel(id: ComposerCommandId): string {\n const chord = findCommand(id)?.keys[0];\n return chord ? formatChord(chord) : '';\n}\n"],"mappings":"gEAaA,IAAa,EAAuB,CAClC,sBACA,iBACA,kBACA,kBACA,gBACA,yBACA,eACF,EAYA,SAAgB,EAAe,EAAqB,EAAgC,CAClF,IAAM,EAAU,EAAY,CAAE,EAC9B,OAAO,IAAY,MAAQ,EAAQ,KAAK,KAAM,GAAU,EAAa,EAAO,CAAK,CAAC,CACpF,CAGA,SAAgB,EAAc,EAA+B,CAC3D,IAAM,EAAQ,EAAY,CAAE,CAAC,EAAE,KAAK,GACpC,OAAO,EAAQ,EAAY,CAAK,EAAI,EACtC"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{F as e,L as t,N as n,c as r,j as i,k as a,z as o}from"./verse-model-DyCwZF-M.js";import{S as s,r as c,x as l}from"./verse-store-b_Lek_c5.js";import{g as u,t as d,v as f}from"./format-BkWdOQDL.js";var p=/\s·\spart\s(\d+)$/;function m(e){let t=e.replace(/\s+/g,` `).trim(),n=p.exec(t),r=(n?t.slice(0,n.index):t)||`Untitled chat`,i=` · part ${n?Number.parseInt(n[1],10)+1:2}`,a=120-i.length;return`${r.length>a?`${r.slice(0,a-1).trimEnd()}…`:r}${i}`}function h(e,t){if(!e)return null;let n=e.models.find(e=>e.id===t);if(n)return n;let r=i(t);return e.models.find(e=>i(e.id)===r)??null}function g(e,t,n=Date.now()){return e?e.health.state===`unavailable`?`${e.label} is unavailable: ${d(f(e.health.summary??`no reason given`,n))}.`:t?t.unavailableReason?`${t.label} cannot run on ${e.label}: ${d(f(t.unavailableReason,n))}.`:null:`Pick a model on this seat.`:`Pick a seat to continue on.`}function _(e,t){let n=e.find(e=>e.id===t.seatId);if(n&&n.health.state!==`unavailable`){let e=h(n,t.model);if(e&&!e.unavailableReason)return{seatId:n.id,model:e.id};let r=n.models.find(e=>!e.unavailableReason);if(r)return{seatId:n.id,model:r.id}}for(let t of e){if(t.health.state===`unavailable`)continue;let e=t.models.find(e=>!e.unavailableReason);if(e)return{seatId:t.id,model:e.id}}return null}function v(e){let{option:t,target:n,source:r,preferences:o}=e,s=e=>e!==void 0&&a(t,e)!==null;if(n!==null&&n.seatId===r.seatId&&i(n.model)===i(r.model)&&s(r.contextMode??`standard`))return r.contextMode??`standard`;let c=n?o?.seats[n.seatId]?.contextMode:void 0;return s(c)?c:`standard`}function y(e,t){return a(e,t)===null?void 0:t}function b(e,t){let n=a(e,t);if(!n)return null;let r=`${c(n.contextWindow)} window`;return n.autoCompactAt===null?r:`${r} · compacts ≈${c(n.autoCompactAt)}`}function x(t,r,i,s){let l=n(t),d=o(s),f=l+d,p=e(l,r,d),m=`~${c(l)} tokens of handoff + an estimated ~${c(d)} of fixed prompt`,h=a(r,`standard`),g=h?h.autoCompactAt??h.contextWindow:null,_={verdict:p,handoffTokens:l,overheadTokens:d,needTokens:f};switch(p){case`fits`:return{..._,tone:`ok`,text:`Fits: ${m} leaves most of the budget before the first compaction.`};case`tight`:return{..._,tone:`warn`,text:`Tight: ${m} is ${u(f/(g??f)*100)} of where this model compacts — the new chat will compact early.`};case`expansive`:return i===`expansive`?{..._,tone:`warn`,text:`Fits only the expansive budget: ${m}.`}:{..._,tone:`danger`,text:`Too big for the standard budget (${m}). Switch to Expansive, or trim the handoff.`};case`split`:return{..._,tone:`danger`,text:`Too big for one context on this model (${m}). Trim the handoff or pick a seat with a larger window.`};default:return{..._,verdict:null,tone:`unknown`,text:`This model’s window is not known, so there is no fit estimate.`}}}function S(e){return t(e)}function C(e,t){return e===`local`?`Runs on this machine with ${t}; it spends no subscription usage.`:`Sends one turn to ${t} and spends from its usage. The automatic preview costs nothing.`}var w=typeof TextEncoder==`function`?new TextEncoder:null;function T(e){if(w)return w.encode(e).length;let t=0;for(let n of e){let e=n.codePointAt(0)??0;t+=e<128?1:e<2048?2:e<65536?3:4}return t}var E=65536,D=s;function O(e){return T(JSON.stringify(e)??``)}function k(e){if(!Number.isFinite(e)||e<0)return`—`;if(e<1024)return`${e} B`;let t=e/1024;return`${t<10?t.toFixed(1).replace(/\.0$/,``):Math.round(t)} KB`}function A(e,t=Date.now()){if(!e)return null;let n=r(e,t);return n?n===`now`?`just now`:/^\d+[mhd]$/.test(n)?`${n} ago`:`on ${n}`:null}var j=[{label:`a private key`,re:/-----BEGIN [A-Z ]*PRIVATE KEY-----/},{label:`an Anthropic API key`,re:/\bsk-ant-[A-Za-z0-9_-]{20,}/},{label:`an OpenAI-style API key`,re:/\bsk-(?:proj-)?[A-Za-z0-9_-]{32,}/},{label:`an xAI API key`,re:/\bxai-[A-Za-z0-9]{32,}/},{label:`a GitHub token`,re:/\b(?:ghp|gho|ghu|ghs|ghr)_[A-Za-z0-9]{30,}|\bgithub_pat_[A-Za-z0-9_]{40,}/},{label:`an AWS access key`,re:/\b(?:AKIA|ASIA)[0-9A-Z]{16}\b/},{label:`a Slack token`,re:/\bxox[abprs]-[A-Za-z0-9-]{10,}/},{label:`a Google API key`,re:/\bAIza[0-9A-Za-z_-]{35}\b/},{label:`a Stripe secret key`,re:/\b(?:sk|rk)_live_[0-9A-Za-z]{20,}/}],M=l,N=`Reading and editing memory here spends nothing. On a paid seat it is not free to use: each new chat’s system prompt carries a memory block of up to ${M/1024} KB, re-sent every turn (cached after the first), and the agent reads and updates MEMORY.md as it works. Local seats spend nothing.`;function P(e){for(let{label:t,re:n}of j)if(n.test(e))return t;return null}var F=`[REDACTED]`;function I(e){return e.split(F).length-1}function L(e){let t=[];for(let n of e.toLowerCase().split(/\s+/))n&&!t.includes(n)&&t.push(n);return t}function R(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function z(e,t){let n=[...t].filter(e=>e.length>0).sort((e,t)=>t.length-e.length);if(n.length===0||e.length===0)return e?[{text:e,match:!1}]:[];let r=new RegExp(n.map(R).join(`|`),`gi`),i=[],a=0;for(let t of e.matchAll(r)){let n=t.index??0;t[0].length!==0&&(n>a&&i.push({text:e.slice(a,n),match:!1}),i.push({text:t[0],match:!0}),a=n+t[0].length)}return a<e.length&&i.push({text:e.slice(a),match:!1}),i}function B(e){let t=new Map;for(let n of e){let e=t.get(n.sessionId);if(!e){t.set(n.sessionId,{sessionId:n.sessionId,title:n.title,projectPath:n.projectPath,engine:n.engine,top:n,count:1,latestAt:n.at});continue}e.count+=1,n.at>e.latestAt&&(e.latestAt=n.at)}return[...t.values()]}export{C,g as S,I as _,F as a,L as b,_ as c,x as d,m as f,S as g,h,N as i,k as l,O as m,M as n,b as o,z as p,D as r,v as s,E as t,B as u,A as v,T as w,P as x,y};
|
|
2
|
+
//# sourceMappingURL=context-model-BC-HOmPo.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context-model-Dwd49-dp.js","names":[],"sources":["../../../../../../src/web-ui/routes/verse/context/context-model.ts"],"sourcesContent":["/**\n * routes/verse/context/context-model.ts — the pure half of the context\n * components (handoff dialog, memory panel, session search). No React, no\n * I/O, so every rule the components render is pinned by a plain unit test.\n *\n * Every number shown here comes from context-math.ts (the one module the\n * server and the browser share), so \"compacts ≈367k\" in the handoff dialog is\n * the same figure the meter and the seat picker show.\n */\nimport type { VerseEngine, VerseModelOption, VerseSeat, VerseSession } from '../../../data/api-types.js';\nimport type {\n VerseContextMode,\n VerseFitVerdict,\n VersePreferences,\n VerseSearchHit,\n} from '../../../../core/verse/types.js';\nimport { VERSE_MEMORY_BLOCK_MAX_BYTES, VERSE_MEMORY_BODY_MAX_BYTES } from '../../../../core/verse/types.js';\nimport {\n budgetFor,\n canonicalModelId,\n estimateTokensFromChars,\n fitVerdict,\n hasExpansiveMode,\n sessionOverheadTokens,\n} from '../../../../core/verse/context-math.js';\nimport { formatRelative } from '../verse-model.js';\nimport { asClause, percentText, tidyProse } from '../autonomy/format.js';\nimport { formatTokens } from '../verse-store.js';\n\n// ---------------------------------------------------------------------------\n// Handoff\n// ---------------------------------------------------------------------------\n\n// The canned \"Ask this seat to summarize first\" turn is\n// VERSE_HANDOFF_SUMMARY_REQUEST in core/verse/types.ts, not a copy here: the\n// handoff builder on the server matches that exact text to keep it OUT of the\n// new session's \"latest requests\" (otherwise the new chat is told to write\n// another handoff note). A local copy that drifted by one character would\n// silently defeat that filter.\n\n/** Mirrors session-engine's TITLE_MAX so a title we send is never cut by the server instead. */\nexport const TITLE_MAX_CHARS = 120;\n\nconst PART_SUFFIX = /\\s·\\spart\\s(\\d+)$/;\n\n/**\n * Title for the session a handoff continues in: \"Fix the login bug · part 2\".\n * A continuation of a continuation counts up rather than stacking suffixes, so\n * the sidebar reads \"part 3\", never \"part 2 · part 2\".\n */\nexport function handoffTitle(sourceTitle: string): string {\n const collapsed = sourceTitle.replace(/\\s+/g, ' ').trim();\n const match = PART_SUFFIX.exec(collapsed);\n const base = (match ? collapsed.slice(0, match.index) : collapsed) || 'Untitled chat';\n const next = match ? Number.parseInt(match[1]!, 10) + 1 : 2;\n const suffix = ` · part ${next}`;\n const room = TITLE_MAX_CHARS - suffix.length;\n const clipped = base.length > room ? `${base.slice(0, room - 1).trimEnd()}…` : base;\n return `${clipped}${suffix}`;\n}\n\n/**\n * A seat's catalog entry for a model id. Exact id first, then canonical — a\n * session created before the alias fix stores `claude-opus-5.5` while the\n * catalog now lists `claude-opus-5-5` (context-math VERSE_MODEL_ID_ALIASES).\n */\nexport function modelOption(seat: VerseSeat | null | undefined, modelId: string): VerseModelOption | null {\n if (!seat) return null;\n const exact = seat.models.find((m) => m.id === modelId);\n if (exact) return exact;\n const canonical = canonicalModelId(modelId);\n return seat.models.find((m) => canonicalModelId(m.id) === canonical) ?? null;\n}\n\n/**\n * Why a seat+model cannot take a new session right now; null when it can.\n *\n * The seat's own reason is embedded as a clause: its closing period is\n * dropped (no \"exhausted..\") and any ISO instant in it — a health summary\n * saying when usage resets — is read as the viewer's local time.\n */\nexport function targetUnavailableReason(\n seat: VerseSeat | null | undefined,\n option: VerseModelOption | null,\n now: number = Date.now(),\n): string | null {\n if (!seat) return 'Pick a seat to continue on.';\n if (seat.health.state === 'unavailable') {\n return `${seat.label} is unavailable: ${asClause(tidyProse(seat.health.summary ?? 'no reason given', now))}.`;\n }\n if (!option) return 'Pick a model on this seat.';\n if (option.unavailableReason) {\n return `${option.label} cannot run on ${seat.label}: ${asClause(tidyProse(option.unavailableReason, now))}.`;\n }\n return null;\n}\n\nexport interface HandoffTarget {\n seatId: string;\n model: string;\n}\n\n/**\n * Where a handoff lands by default: the SAME seat and model (the common case\n * is \"same agent, fresh context\"). When that model can no longer run there,\n * the seat's first runnable model; when the seat itself is gone or\n * unavailable, the first runnable model on any available seat, in the seat\n * list's own order.\n */\nexport function defaultHandoffTarget(seats: readonly VerseSeat[], source: Pick<VerseSession, 'seatId' | 'model'>): HandoffTarget | null {\n const own = seats.find((s) => s.id === source.seatId);\n if (own && own.health.state !== 'unavailable') {\n const same = modelOption(own, source.model);\n if (same && !same.unavailableReason) return { seatId: own.id, model: same.id };\n const runnable = own.models.find((m) => !m.unavailableReason);\n if (runnable) return { seatId: own.id, model: runnable.id };\n }\n for (const seat of seats) {\n if (seat.health.state === 'unavailable') continue;\n const runnable = seat.models.find((m) => !m.unavailableReason);\n if (runnable) return { seatId: seat.id, model: runnable.id };\n }\n return null;\n}\n\n/**\n * The mode a handoff starts in. Only a mode that EXISTS for the target model\n * is ever returned (a mode with no budget would be refused by the server).\n *\n * 1. Same seat and model as the source → keep the source's mode. \"Continue in\n * a fresh chat\" means the same settings with a clean context; an operator\n * who chose expansive for this work chose it for the work.\n * 2. Otherwise the target seat's standing preference (preferences.json).\n * 3. Otherwise standard.\n */\nexport function defaultHandoffMode(input: {\n option: VerseModelOption | null;\n target: HandoffTarget | null;\n source: Pick<VerseSession, 'seatId' | 'model' | 'contextMode'>;\n preferences: VersePreferences | null | undefined;\n}): VerseContextMode {\n const { option, target, source, preferences } = input;\n const valid = (mode: VerseContextMode | undefined): mode is VerseContextMode =>\n mode !== undefined && budgetFor(option, mode) !== null;\n const sameModel = target !== null && target.seatId === source.seatId\n && canonicalModelId(target.model) === canonicalModelId(source.model);\n if (sameModel && valid(source.contextMode ?? 'standard')) return source.contextMode ?? 'standard';\n const preferred = target ? preferences?.seats[target.seatId]?.contextMode : undefined;\n if (valid(preferred)) return preferred;\n return 'standard';\n}\n\n/**\n * The mode to put on the create request, or undefined to leave it to the\n * server. A mode is sent only when the model has a budget for it — which is\n * exactly the server's acceptance rule — so what the dialog shows is what is\n * created, and an unknown-window model is never refused over a mode it could\n * not have.\n */\nexport function requestMode(option: VerseModelOption | null, mode: VerseContextMode): VerseContextMode | undefined {\n return budgetFor(option, mode) !== null ? mode : undefined;\n}\n\n/** \"1M window · compacts ≈367k\" for a model in a mode; null when the budget is unknown. */\nexport function budgetLine(option: VerseModelOption | null, mode: VerseContextMode): string | null {\n const budget = budgetFor(option, mode);\n if (!budget) return null;\n const window = `${formatTokens(budget.contextWindow)} window`;\n return budget.autoCompactAt === null ? window : `${window} · compacts ≈${formatTokens(budget.autoCompactAt)}`;\n}\n\nexport interface HandoffFit {\n verdict: VerseFitVerdict | null;\n /** The handoff text's own estimate (chars / 4). */\n handoffTokens: number;\n /** The target engine's estimated fixed prompt (context-math `sessionOverheadTokens`). */\n overheadTokens: number;\n /** Handoff + that fixed prompt: what the new session holds before its first reply. */\n needTokens: number;\n /** One sentence for the dialog. */\n text: string;\n tone: 'ok' | 'warn' | 'danger' | 'unknown';\n}\n\n/**\n * Will the new session START comfortably? The handoff is small by design\n * (≤ 12k chars ≈ 3k tokens), but every fresh session also carries the CLI's\n * fixed prompt — a large share of a 64k local slot — so this is a real\n * question on small windows, and the sentence shows both halves of the sum\n * rather than a bare verdict.\n *\n * The fixed prompt is the TARGET seat's engine estimate (local ≈15k measured,\n * claude ≈25k, …), not one flat figure: a flat 30k called every handoff to a\n * 64k local seat \"too big for one context\" when the real sum was ~20k. It is\n * still an estimate — no CLI reports its base prompt before the first turn —\n * so the sentence says \"estimated\" rather than presenting it as a reading.\n * `engine` null (target seat not known yet) falls back to the largest estimate.\n */\nexport function handoffFit(\n textChars: number,\n option: VerseModelOption | null,\n mode: VerseContextMode,\n engine: VerseEngine | null,\n): HandoffFit {\n const handoffTokens = estimateTokensFromChars(textChars);\n const overheadTokens = sessionOverheadTokens(engine);\n const needTokens = handoffTokens + overheadTokens;\n const verdict = fitVerdict(handoffTokens, option, overheadTokens);\n const sum = `~${formatTokens(handoffTokens)} tokens of handoff + an estimated ~${formatTokens(overheadTokens)} of fixed prompt`;\n const standard = budgetFor(option, 'standard');\n const standardCap = standard ? standard.autoCompactAt ?? standard.contextWindow : null;\n const base = { verdict, handoffTokens, overheadTokens, needTokens };\n switch (verdict) {\n case 'fits':\n return { ...base, tone: 'ok', text: `Fits: ${sum} leaves most of the budget before the first compaction.` };\n case 'tight':\n return {\n ...base,\n tone: 'warn',\n text: `Tight: ${sum} is ${percentText((needTokens / (standardCap ?? needTokens)) * 100)} of where this model compacts — the new chat will compact early.`,\n };\n case 'expansive':\n return mode === 'expansive'\n ? { ...base, tone: 'warn', text: `Fits only the expansive budget: ${sum}.` }\n : { ...base, tone: 'danger', text: `Too big for the standard budget (${sum}). Switch to Expansive, or trim the handoff.` };\n case 'split':\n return { ...base, tone: 'danger', text: `Too big for one context on this model (${sum}). Trim the handoff or pick a seat with a larger window.` };\n default:\n return { ...base, verdict: null, tone: 'unknown', text: 'This model’s window is not known, so there is no fit estimate.' };\n }\n}\n\n/** True when the target model has a real expansive budget (context-math, re-exported for the dialog). */\nexport function offersExpansive(option: VerseModelOption | null): boolean {\n return hasExpansiveMode(option);\n}\n\n/** A local turn runs on this machine; every other engine spends subscription usage. */\nexport function turnCostSentence(engine: VerseEngine, seatLabel: string): string {\n return engine === 'local'\n ? `Runs on this machine with ${seatLabel}; it spends no subscription usage.`\n : `Sends one turn to ${seatLabel} and spends from its usage. The automatic preview costs nothing.`;\n}\n\n// ---------------------------------------------------------------------------\n// Bytes\n// ---------------------------------------------------------------------------\n\nconst encoder = typeof TextEncoder === 'function' ? new TextEncoder() : null;\n\n/** UTF-8 byte length — the unit the server's caps (64 KB memory content, 64 KB turn) are written in. */\nexport function utf8Bytes(text: string): number {\n if (encoder) return encoder.encode(text).length;\n // Fallback for an environment with no TextEncoder: count code points by width.\n let bytes = 0;\n for (const ch of text) {\n const cp = ch.codePointAt(0) ?? 0;\n bytes += cp < 0x80 ? 1 : cp < 0x800 ? 2 : cp < 0x10000 ? 3 : 4;\n }\n return bytes;\n}\n\n/**\n * The API's default request-body cap: `readBody` in src/core/web/api.ts, which\n * every /api/verse POST uses unless its route passes a larger one (only\n * POST /memory does — see MEMORY_BODY_MAX_BYTES). A write travels as JSON, so what must fit is\n * the ENCODED body — every `\\n` and `\"` escaped to two bytes — not the text\n * alone; the editors measure it so a refusal happens on screen instead of as\n * \"request body too large\".\n */\nexport const API_BODY_MAX_BYTES = 65_536;\n\n/**\n * POST /api/verse/memory's own body cap — mirrors `VERSE_MEMORY_BODY_MAX_BYTES`\n * in src/core/verse/verse-api.ts (a server module the browser cannot import):\n * room for 64 KiB of content in which EVERY byte escapes to two, plus the\n * project path and the JSON around it. The server still holds the CONTENT to\n * VERSE_MEMORY_MAX_BYTES after parsing. Guarding the memory editor with the\n * 64 KiB default instead blocked saves the server accepts — a 60–64 KB\n * MEMORY.md with ordinary line breaks could not be edited from the panel,\n * which is the exact case the server's larger cap exists for.\n */\nexport const MEMORY_BODY_MAX_BYTES = VERSE_MEMORY_BODY_MAX_BYTES;\n\n/** UTF-8 size of `body` exactly as the client will send it. */\nexport function jsonBodyBytes(body: unknown): number {\n return utf8Bytes(JSON.stringify(body) ?? '');\n}\n\nexport function formatBytes(bytes: number): string {\n if (!Number.isFinite(bytes) || bytes < 0) return '—';\n if (bytes < 1024) return `${bytes} B`;\n const kb = bytes / 1024;\n return `${kb < 10 ? kb.toFixed(1).replace(/\\.0$/, '') : Math.round(kb)} KB`;\n}\n\n/**\n * A relative time that reads as a phrase: \"just now\", \"5m ago\", \"on Sep 19\".\n * `formatRelative` (verse-model) is sized for a 5ch sidebar column and reads\n * as a bare token; prose needs the preposition.\n */\nexport function relativePhrase(iso: string | null | undefined, now: number = Date.now()): string | null {\n if (!iso) return null;\n const short = formatRelative(iso, now);\n if (!short) return null;\n if (short === 'now') return 'just now';\n // Only the relative tokens (\"5m\", \"3h\", \"2d\") take \"ago\". Anything else is a\n // DATE, whatever the locale prints: \"Sep 1\" (en-US) but \"1 Sept\" (en-GB)\n // and \"1. Sept.\" (de) start with a digit — testing for a leading digit\n // printed \"Last completed 1 Sept ago.\" outside the US.\n return /^\\d+[mhd]$/.test(short) ? `${short} ago` : `on ${short}`;\n}\n\n// ---------------------------------------------------------------------------\n// Memory\n// ---------------------------------------------------------------------------\n\n/**\n * Shapes that are almost certainly credentials. MEMORY.md is sent to every\n * seat's model on every turn, so a pasted key would travel to every provider\n * — the panel warns BEFORE the save rather than trusting the server's scrub\n * to catch it on the way out. Conservative on purpose: a false alarm on prose\n * would teach the operator to ignore the warning.\n */\nconst SECRET_PATTERNS: ReadonlyArray<{ label: string; re: RegExp }> = [\n { label: 'a private key', re: /-----BEGIN [A-Z ]*PRIVATE KEY-----/ },\n { label: 'an Anthropic API key', re: /\\bsk-ant-[A-Za-z0-9_-]{20,}/ },\n { label: 'an OpenAI-style API key', re: /\\bsk-(?:proj-)?[A-Za-z0-9_-]{32,}/ },\n { label: 'an xAI API key', re: /\\bxai-[A-Za-z0-9]{32,}/ },\n { label: 'a GitHub token', re: /\\b(?:ghp|gho|ghu|ghs|ghr)_[A-Za-z0-9]{30,}|\\bgithub_pat_[A-Za-z0-9_]{40,}/ },\n { label: 'an AWS access key', re: /\\b(?:AKIA|ASIA)[0-9A-Z]{16}\\b/ },\n { label: 'a Slack token', re: /\\bxox[abprs]-[A-Za-z0-9-]{10,}/ },\n { label: 'a Google API key', re: /\\bAIza[0-9A-Za-z_-]{35}\\b/ },\n { label: 'a Stripe secret key', re: /\\b(?:sk|rk)_live_[0-9A-Za-z]{20,}/ },\n];\n\n/**\n * Mirrors `VERSE_MEMORY_BLOCK_MAX_BYTES` in src/core/verse/project-memory.ts\n * (a node module the browser cannot import): the most memory text a chat's\n * instructions carry, however large MEMORY.md itself is.\n */\nexport const MEMORY_BLOCK_MAX_BYTES = VERSE_MEMORY_BLOCK_MAX_BYTES;\n\n/**\n * What memory costs, in the one wording the memory panel and the resources\n * panel share. Memory is ON by default and snapshotted into every new chat's\n * system prompt (claude `--append-system-prompt`, codex `developer_instructions`,\n * grok `--rules`), which re-rides every turn, and it asks writable seats to\n * read and update MEMORY.md — tool calls and output. On a paid seat that is\n * real (if small, mostly cached) usage, so \"nothing here spends\" would be\n * false for exactly the operator deciding whether to leave it on near a limit.\n * Reading and editing the file from the panel is still free.\n */\nexport const MEMORY_SPEND_NOTE =\n `Reading and editing memory here spends nothing. On a paid seat it is not free to use: each new chat’s system prompt carries a memory block of up to ${MEMORY_BLOCK_MAX_BYTES / 1024} KB, re-sent every turn (cached after the first), and the agent reads and updates MEMORY.md as it works. Local seats spend nothing.`;\n\n/** The first credential shape found, as a phrase (\"a GitHub token\"), or null. */\nexport function secretLike(text: string): string | null {\n for (const { label, re } of SECRET_PATTERNS) if (re.test(text)) return label;\n return null;\n}\n\n/**\n * The placeholder the server's scrubber (src/core/util/scrub.ts) writes over\n * secret-shaped text in every rule. In a memory view flagged\n * `contentSanitized`, each one stands for a REAL value still in MEMORY.md.\n */\nexport const REDACTION_MARKER = '[REDACTED]';\n\n/** How many redaction placeholders a text carries. */\nexport function redactionMarkers(text: string): number {\n return text.split(REDACTION_MARKER).length - 1;\n}\n\n// ---------------------------------------------------------------------------\n// Search\n// ---------------------------------------------------------------------------\n\n/** Below this many characters a keyword search over every message is noise, not recall. */\nexport const SEARCH_MIN_CHARS = 2;\n/** Keystrokes inside this window collapse into one request. */\nexport const SEARCH_DEBOUNCE_MS = 250;\n/** Hits asked for per search — enough to fill the sidebar twice over. */\nexport const SEARCH_LIMIT = 30;\n\n/** Whitespace-separated terms, lowercased and de-duplicated (the server ANDs them). */\nexport function searchTerms(query: string): string[] {\n const out: string[] = [];\n for (const raw of query.toLowerCase().split(/\\s+/)) {\n if (raw && !out.includes(raw)) out.push(raw);\n }\n return out;\n}\n\nexport interface HighlightSegment {\n text: string;\n match: boolean;\n}\n\nfunction escapeRegExp(value: string): string {\n return value.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&');\n}\n\n/**\n * Split `text` into plain and matched runs for every term, case-insensitive.\n * Longest terms first so \"migrate\" wins over \"migrat\" at the same position.\n */\nexport function highlightSegments(text: string, terms: readonly string[]): HighlightSegment[] {\n const usable = [...terms].filter((t) => t.length > 0).sort((a, b) => b.length - a.length);\n if (usable.length === 0 || text.length === 0) return text ? [{ text, match: false }] : [];\n const re = new RegExp(usable.map(escapeRegExp).join('|'), 'gi');\n const out: HighlightSegment[] = [];\n let last = 0;\n for (const m of text.matchAll(re)) {\n const start = m.index ?? 0;\n if (m[0].length === 0) continue;\n if (start > last) out.push({ text: text.slice(last, start), match: false });\n out.push({ text: m[0], match: true });\n last = start + m[0].length;\n }\n if (last < text.length) out.push({ text: text.slice(last), match: false });\n return out;\n}\n\nexport interface SessionSearchGroup {\n sessionId: string;\n title: string;\n projectPath: string;\n engine: VerseEngine;\n /** The best-scoring hit in this session (the server returns hits best-first). */\n top: VerseSearchHit;\n /** Every hit this session contributed to the response. */\n count: number;\n /** Newest hit time, for the row's relative time. */\n latestAt: string;\n}\n\n/**\n * One row per session. The server ranks MESSAGES; the sidebar lists CHATS,\n * and five rows for one chat would push every other match off screen. Order\n * is the order each session first appears, i.e. by its best hit.\n */\nexport function groupSearchHits(hits: readonly VerseSearchHit[]): SessionSearchGroup[] {\n const groups = new Map<string, SessionSearchGroup>();\n for (const hit of hits) {\n const existing = groups.get(hit.sessionId);\n if (!existing) {\n groups.set(hit.sessionId, {\n sessionId: hit.sessionId,\n title: hit.title,\n projectPath: hit.projectPath,\n engine: hit.engine,\n top: hit,\n count: 1,\n latestAt: hit.at,\n });\n continue;\n }\n existing.count += 1;\n if (hit.at > existing.latestAt) existing.latestAt = hit.at;\n }\n return [...groups.values()];\n}\n"],"mappings":"8OA2CA,IAAM,EAAc,oBAOpB,SAAgB,EAAa,EAA6B,CACxD,IAAM,EAAY,EAAY,QAAQ,OAAQ,GAAG,CAAC,CAAC,KAAK,EAClD,EAAQ,EAAY,KAAK,CAAS,EAClC,GAAQ,EAAQ,EAAU,MAAM,EAAG,EAAM,KAAK,EAAI,IAAc,gBAEhE,EAAS,WADF,EAAQ,OAAO,SAAS,EAAM,GAAK,EAAE,EAAI,EAAI,IAEpD,EAAA,IAAyB,EAAO,OAEtC,MAAO,GADS,EAAK,OAAS,EAAO,GAAG,EAAK,MAAM,EAAG,EAAO,CAAC,CAAC,CAAC,QAAQ,EAAE,GAAK,IAC3D,GACtB,CAOA,SAAgB,EAAY,EAAoC,EAA0C,CACxG,GAAI,CAAC,EAAM,OAAO,KAClB,IAAM,EAAQ,EAAK,OAAO,KAAM,GAAM,EAAE,KAAO,CAAO,EACtD,GAAI,EAAO,OAAO,EAClB,IAAM,EAAY,EAAiB,CAAO,EAC1C,OAAO,EAAK,OAAO,KAAM,GAAM,EAAiB,EAAE,EAAE,IAAM,CAAS,GAAK,IAC1E,CASA,SAAgB,EACd,EACA,EACA,EAAc,KAAK,IAAI,E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IAAK,IAAM,KAAK,EAAK,SAAS,CAAE,EAAG,CACjC,IAAM,EAAQ,EAAE,OAAS,EACrB,EAAE,EAAE,CAAC,SAAW,IAChB,EAAQ,GAAM,EAAI,KAAK,CAAE,KAAM,EAAK,MAAM,EAAM,CAAK,EAAG,MAAO,EAAM,CAAC,EAC1E,EAAI,KAAK,CAAE,KAAM,EAAE,GAAI,MAAO,EAAK,CAAC,EACpC,EAAO,EAAQ,EAAE,EAAE,CAAC,OACtB,CAEA,OADI,EAAO,EAAK,QAAQ,EAAI,KAAK,CAAE,KAAM,EAAK,MAAM,CAAI,EAAG,MAAO,EAAM,CAAC,EAClE,CACT,CAoBA,SAAgB,EAAgB,EAAuD,CACrF,IAAM,EAAS,IAAI,IACnB,IAAK,IAAM,KAAO,EAAM,CACtB,IAAM,EAAW,EAAO,IAAI,EAAI,SAAS,EACzC,GAAI,CAAC,EAAU,CACb,EAAO,IAAI,EAAI,UAAW,CACxB,UAAW,EAAI,UACf,MAAO,EAAI,MACX,YAAa,EAAI,YACjB,OAAQ,EAAI,OACZ,IAAK,EACL,MAAO,EACP,SAAU,EAAI,EAChB,CAAC,EACD,QACF,CACA,EAAS,OAAS,EACd,EAAI,GAAK,EAAS,WAAU,EAAS,SAAW,EAAI,GAC1D,CACA,MAAO,CAAC,GAAG,EAAO,OAAO,CAAC,CAC5B"}
|
|
1
|
+
{"version":3,"file":"context-model-BC-HOmPo.js","names":[],"sources":["../../../../../../src/web-ui/routes/verse/context/context-model.ts"],"sourcesContent":["/**\n * routes/verse/context/context-model.ts — the pure half of the context\n * components (handoff dialog, memory panel, session search). No React, no\n * I/O, so every rule the components render is pinned by a plain unit test.\n *\n * Every number shown here comes from context-math.ts (the one module the\n * server and the browser share), so \"compacts ≈367k\" in the handoff dialog is\n * the same figure the meter and the seat picker show.\n */\nimport type { VerseEngine, VerseModelOption, VerseSeat, VerseSession } from '../../../data/api-types.js';\nimport type {\n VerseContextMode,\n VerseFitVerdict,\n VersePreferences,\n VerseSearchHit,\n} from '../../../../core/verse/types.js';\nimport { VERSE_MEMORY_BLOCK_MAX_BYTES, VERSE_MEMORY_BODY_MAX_BYTES } from '../../../../core/verse/types.js';\nimport {\n budgetFor,\n canonicalModelId,\n estimateTokensFromChars,\n fitVerdict,\n hasExpansiveMode,\n sessionOverheadTokens,\n} from '../../../../core/verse/context-math.js';\nimport { formatRelative } from '../verse-model.js';\nimport { asClause, percentText, tidyProse } from '../autonomy/format.js';\nimport { formatTokens } from '../verse-store.js';\n\n// ---------------------------------------------------------------------------\n// Handoff\n// ---------------------------------------------------------------------------\n\n// The canned \"Ask this seat to summarize first\" turn is\n// VERSE_HANDOFF_SUMMARY_REQUEST in core/verse/types.ts, not a copy here: the\n// handoff builder on the server matches that exact text to keep it OUT of the\n// new session's \"latest requests\" (otherwise the new chat is told to write\n// another handoff note). A local copy that drifted by one character would\n// silently defeat that filter.\n\n/** Mirrors session-engine's TITLE_MAX so a title we send is never cut by the server instead. */\nexport const TITLE_MAX_CHARS = 120;\n\nconst PART_SUFFIX = /\\s·\\spart\\s(\\d+)$/;\n\n/**\n * Title for the session a handoff continues in: \"Fix the login bug · part 2\".\n * A continuation of a continuation counts up rather than stacking suffixes, so\n * the sidebar reads \"part 3\", never \"part 2 · part 2\".\n */\nexport function handoffTitle(sourceTitle: string): string {\n const collapsed = sourceTitle.replace(/\\s+/g, ' ').trim();\n const match = PART_SUFFIX.exec(collapsed);\n const base = (match ? collapsed.slice(0, match.index) : collapsed) || 'Untitled chat';\n const next = match ? Number.parseInt(match[1]!, 10) + 1 : 2;\n const suffix = ` · part ${next}`;\n const room = TITLE_MAX_CHARS - suffix.length;\n const clipped = base.length > room ? `${base.slice(0, room - 1).trimEnd()}…` : base;\n return `${clipped}${suffix}`;\n}\n\n/**\n * A seat's catalog entry for a model id. Exact id first, then canonical — a\n * session created before the alias fix stores `claude-opus-5.5` while the\n * catalog now lists `claude-opus-5-5` (context-math VERSE_MODEL_ID_ALIASES).\n */\nexport function modelOption(seat: VerseSeat | null | undefined, modelId: string): VerseModelOption | null {\n if (!seat) return null;\n const exact = seat.models.find((m) => m.id === modelId);\n if (exact) return exact;\n const canonical = canonicalModelId(modelId);\n return seat.models.find((m) => canonicalModelId(m.id) === canonical) ?? null;\n}\n\n/**\n * Why a seat+model cannot take a new session right now; null when it can.\n *\n * The seat's own reason is embedded as a clause: its closing period is\n * dropped (no \"exhausted..\") and any ISO instant in it — a health summary\n * saying when usage resets — is read as the viewer's local time.\n */\nexport function targetUnavailableReason(\n seat: VerseSeat | null | undefined,\n option: VerseModelOption | null,\n now: number = Date.now(),\n): string | null {\n if (!seat) return 'Pick a seat to continue on.';\n if (seat.health.state === 'unavailable') {\n return `${seat.label} is unavailable: ${asClause(tidyProse(seat.health.summary ?? 'no reason given', now))}.`;\n }\n if (!option) return 'Pick a model on this seat.';\n if (option.unavailableReason) {\n return `${option.label} cannot run on ${seat.label}: ${asClause(tidyProse(option.unavailableReason, now))}.`;\n }\n return null;\n}\n\nexport interface HandoffTarget {\n seatId: string;\n model: string;\n}\n\n/**\n * Where a handoff lands by default: the SAME seat and model (the common case\n * is \"same agent, fresh context\"). When that model can no longer run there,\n * the seat's first runnable model; when the seat itself is gone or\n * unavailable, the first runnable model on any available seat, in the seat\n * list's own order.\n */\nexport function defaultHandoffTarget(seats: readonly VerseSeat[], source: Pick<VerseSession, 'seatId' | 'model'>): HandoffTarget | null {\n const own = seats.find((s) => s.id === source.seatId);\n if (own && own.health.state !== 'unavailable') {\n const same = modelOption(own, source.model);\n if (same && !same.unavailableReason) return { seatId: own.id, model: same.id };\n const runnable = own.models.find((m) => !m.unavailableReason);\n if (runnable) return { seatId: own.id, model: runnable.id };\n }\n for (const seat of seats) {\n if (seat.health.state === 'unavailable') continue;\n const runnable = seat.models.find((m) => !m.unavailableReason);\n if (runnable) return { seatId: seat.id, model: runnable.id };\n }\n return null;\n}\n\n/**\n * The mode a handoff starts in. Only a mode that EXISTS for the target model\n * is ever returned (a mode with no budget would be refused by the server).\n *\n * 1. Same seat and model as the source → keep the source's mode. \"Continue in\n * a fresh chat\" means the same settings with a clean context; an operator\n * who chose expansive for this work chose it for the work.\n * 2. Otherwise the target seat's standing preference (preferences.json).\n * 3. Otherwise standard.\n */\nexport function defaultHandoffMode(input: {\n option: VerseModelOption | null;\n target: HandoffTarget | null;\n source: Pick<VerseSession, 'seatId' | 'model' | 'contextMode'>;\n preferences: VersePreferences | null | undefined;\n}): VerseContextMode {\n const { option, target, source, preferences } = input;\n const valid = (mode: VerseContextMode | undefined): mode is VerseContextMode =>\n mode !== undefined && budgetFor(option, mode) !== null;\n const sameModel = target !== null && target.seatId === source.seatId\n && canonicalModelId(target.model) === canonicalModelId(source.model);\n if (sameModel && valid(source.contextMode ?? 'standard')) return source.contextMode ?? 'standard';\n const preferred = target ? preferences?.seats[target.seatId]?.contextMode : undefined;\n if (valid(preferred)) return preferred;\n return 'standard';\n}\n\n/**\n * The mode to put on the create request, or undefined to leave it to the\n * server. A mode is sent only when the model has a budget for it — which is\n * exactly the server's acceptance rule — so what the dialog shows is what is\n * created, and an unknown-window model is never refused over a mode it could\n * not have.\n */\nexport function requestMode(option: VerseModelOption | null, mode: VerseContextMode): VerseContextMode | undefined {\n return budgetFor(option, mode) !== null ? mode : undefined;\n}\n\n/** \"1M window · compacts ≈367k\" for a model in a mode; null when the budget is unknown. */\nexport function budgetLine(option: VerseModelOption | null, mode: VerseContextMode): string | null {\n const budget = budgetFor(option, mode);\n if (!budget) return null;\n const window = `${formatTokens(budget.contextWindow)} window`;\n return budget.autoCompactAt === null ? window : `${window} · compacts ≈${formatTokens(budget.autoCompactAt)}`;\n}\n\nexport interface HandoffFit {\n verdict: VerseFitVerdict | null;\n /** The handoff text's own estimate (chars / 4). */\n handoffTokens: number;\n /** The target engine's estimated fixed prompt (context-math `sessionOverheadTokens`). */\n overheadTokens: number;\n /** Handoff + that fixed prompt: what the new session holds before its first reply. */\n needTokens: number;\n /** One sentence for the dialog. */\n text: string;\n tone: 'ok' | 'warn' | 'danger' | 'unknown';\n}\n\n/**\n * Will the new session START comfortably? The handoff is small by design\n * (≤ 12k chars ≈ 3k tokens), but every fresh session also carries the CLI's\n * fixed prompt — a large share of a 64k local slot — so this is a real\n * question on small windows, and the sentence shows both halves of the sum\n * rather than a bare verdict.\n *\n * The fixed prompt is the TARGET seat's engine estimate (local ≈15k measured,\n * claude ≈25k, …), not one flat figure: a flat 30k called every handoff to a\n * 64k local seat \"too big for one context\" when the real sum was ~20k. It is\n * still an estimate — no CLI reports its base prompt before the first turn —\n * so the sentence says \"estimated\" rather than presenting it as a reading.\n * `engine` null (target seat not known yet) falls back to the largest estimate.\n */\nexport function handoffFit(\n textChars: number,\n option: VerseModelOption | null,\n mode: VerseContextMode,\n engine: VerseEngine | null,\n): HandoffFit {\n const handoffTokens = estimateTokensFromChars(textChars);\n const overheadTokens = sessionOverheadTokens(engine);\n const needTokens = handoffTokens + overheadTokens;\n const verdict = fitVerdict(handoffTokens, option, overheadTokens);\n const sum = `~${formatTokens(handoffTokens)} tokens of handoff + an estimated ~${formatTokens(overheadTokens)} of fixed prompt`;\n const standard = budgetFor(option, 'standard');\n const standardCap = standard ? standard.autoCompactAt ?? standard.contextWindow : null;\n const base = { verdict, handoffTokens, overheadTokens, needTokens };\n switch (verdict) {\n case 'fits':\n return { ...base, tone: 'ok', text: `Fits: ${sum} leaves most of the budget before the first compaction.` };\n case 'tight':\n return {\n ...base,\n tone: 'warn',\n text: `Tight: ${sum} is ${percentText((needTokens / (standardCap ?? needTokens)) * 100)} of where this model compacts — the new chat will compact early.`,\n };\n case 'expansive':\n return mode === 'expansive'\n ? { ...base, tone: 'warn', text: `Fits only the expansive budget: ${sum}.` }\n : { ...base, tone: 'danger', text: `Too big for the standard budget (${sum}). Switch to Expansive, or trim the handoff.` };\n case 'split':\n return { ...base, tone: 'danger', text: `Too big for one context on this model (${sum}). Trim the handoff or pick a seat with a larger window.` };\n default:\n return { ...base, verdict: null, tone: 'unknown', text: 'This model’s window is not known, so there is no fit estimate.' };\n }\n}\n\n/** True when the target model has a real expansive budget (context-math, re-exported for the dialog). */\nexport function offersExpansive(option: VerseModelOption | null): boolean {\n return hasExpansiveMode(option);\n}\n\n/** A local turn runs on this machine; every other engine spends subscription usage. */\nexport function turnCostSentence(engine: VerseEngine, seatLabel: string): string {\n return engine === 'local'\n ? `Runs on this machine with ${seatLabel}; it spends no subscription usage.`\n : `Sends one turn to ${seatLabel} and spends from its usage. The automatic preview costs nothing.`;\n}\n\n// ---------------------------------------------------------------------------\n// Bytes\n// ---------------------------------------------------------------------------\n\nconst encoder = typeof TextEncoder === 'function' ? new TextEncoder() : null;\n\n/** UTF-8 byte length — the unit the server's caps (64 KB memory content, 64 KB turn) are written in. */\nexport function utf8Bytes(text: string): number {\n if (encoder) return encoder.encode(text).length;\n // Fallback for an environment with no TextEncoder: count code points by width.\n let bytes = 0;\n for (const ch of text) {\n const cp = ch.codePointAt(0) ?? 0;\n bytes += cp < 0x80 ? 1 : cp < 0x800 ? 2 : cp < 0x10000 ? 3 : 4;\n }\n return bytes;\n}\n\n/**\n * The API's default request-body cap: `readBody` in src/core/web/api.ts, which\n * every /api/verse POST uses unless its route passes a larger one (only\n * POST /memory does — see MEMORY_BODY_MAX_BYTES). A write travels as JSON, so what must fit is\n * the ENCODED body — every `\\n` and `\"` escaped to two bytes — not the text\n * alone; the editors measure it so a refusal happens on screen instead of as\n * \"request body too large\".\n */\nexport const API_BODY_MAX_BYTES = 65_536;\n\n/**\n * POST /api/verse/memory's own body cap — mirrors `VERSE_MEMORY_BODY_MAX_BYTES`\n * in src/core/verse/verse-api.ts (a server module the browser cannot import):\n * room for 64 KiB of content in which EVERY byte escapes to two, plus the\n * project path and the JSON around it. The server still holds the CONTENT to\n * VERSE_MEMORY_MAX_BYTES after parsing. Guarding the memory editor with the\n * 64 KiB default instead blocked saves the server accepts — a 60–64 KB\n * MEMORY.md with ordinary line breaks could not be edited from the panel,\n * which is the exact case the server's larger cap exists for.\n */\nexport const MEMORY_BODY_MAX_BYTES = VERSE_MEMORY_BODY_MAX_BYTES;\n\n/** UTF-8 size of `body` exactly as the client will send it. */\nexport function jsonBodyBytes(body: unknown): number {\n return utf8Bytes(JSON.stringify(body) ?? '');\n}\n\nexport function formatBytes(bytes: number): string {\n if (!Number.isFinite(bytes) || bytes < 0) return '—';\n if (bytes < 1024) return `${bytes} B`;\n const kb = bytes / 1024;\n return `${kb < 10 ? kb.toFixed(1).replace(/\\.0$/, '') : Math.round(kb)} KB`;\n}\n\n/**\n * A relative time that reads as a phrase: \"just now\", \"5m ago\", \"on Sep 19\".\n * `formatRelative` (verse-model) is sized for a 5ch sidebar column and reads\n * as a bare token; prose needs the preposition.\n */\nexport function relativePhrase(iso: string | null | undefined, now: number = Date.now()): string | null {\n if (!iso) return null;\n const short = formatRelative(iso, now);\n if (!short) return null;\n if (short === 'now') return 'just now';\n // Only the relative tokens (\"5m\", \"3h\", \"2d\") take \"ago\". Anything else is a\n // DATE, whatever the locale prints: \"Sep 1\" (en-US) but \"1 Sept\" (en-GB)\n // and \"1. Sept.\" (de) start with a digit — testing for a leading digit\n // printed \"Last completed 1 Sept ago.\" outside the US.\n return /^\\d+[mhd]$/.test(short) ? `${short} ago` : `on ${short}`;\n}\n\n// ---------------------------------------------------------------------------\n// Memory\n// ---------------------------------------------------------------------------\n\n/**\n * Shapes that are almost certainly credentials. MEMORY.md is sent to every\n * seat's model on every turn, so a pasted key would travel to every provider\n * — the panel warns BEFORE the save rather than trusting the server's scrub\n * to catch it on the way out. Conservative on purpose: a false alarm on prose\n * would teach the operator to ignore the warning.\n */\nconst SECRET_PATTERNS: ReadonlyArray<{ label: string; re: RegExp }> = [\n { label: 'a private key', re: /-----BEGIN [A-Z ]*PRIVATE KEY-----/ },\n { label: 'an Anthropic API key', re: /\\bsk-ant-[A-Za-z0-9_-]{20,}/ },\n { label: 'an OpenAI-style API key', re: /\\bsk-(?:proj-)?[A-Za-z0-9_-]{32,}/ },\n { label: 'an xAI API key', re: /\\bxai-[A-Za-z0-9]{32,}/ },\n { label: 'a GitHub token', re: /\\b(?:ghp|gho|ghu|ghs|ghr)_[A-Za-z0-9]{30,}|\\bgithub_pat_[A-Za-z0-9_]{40,}/ },\n { label: 'an AWS access key', re: /\\b(?:AKIA|ASIA)[0-9A-Z]{16}\\b/ },\n { label: 'a Slack token', re: /\\bxox[abprs]-[A-Za-z0-9-]{10,}/ },\n { label: 'a Google API key', re: /\\bAIza[0-9A-Za-z_-]{35}\\b/ },\n { label: 'a Stripe secret key', re: /\\b(?:sk|rk)_live_[0-9A-Za-z]{20,}/ },\n];\n\n/**\n * Mirrors `VERSE_MEMORY_BLOCK_MAX_BYTES` in src/core/verse/project-memory.ts\n * (a node module the browser cannot import): the most memory text a chat's\n * instructions carry, however large MEMORY.md itself is.\n */\nexport const MEMORY_BLOCK_MAX_BYTES = VERSE_MEMORY_BLOCK_MAX_BYTES;\n\n/**\n * What memory costs, in the one wording the memory panel and the resources\n * panel share. Memory is ON by default and snapshotted into every new chat's\n * system prompt (claude `--append-system-prompt`, codex `developer_instructions`,\n * grok `--rules`), which re-rides every turn, and it asks writable seats to\n * read and update MEMORY.md — tool calls and output. On a paid seat that is\n * real (if small, mostly cached) usage, so \"nothing here spends\" would be\n * false for exactly the operator deciding whether to leave it on near a limit.\n * Reading and editing the file from the panel is still free.\n */\nexport const MEMORY_SPEND_NOTE =\n `Reading and editing memory here spends nothing. On a paid seat it is not free to use: each new chat’s system prompt carries a memory block of up to ${MEMORY_BLOCK_MAX_BYTES / 1024} KB, re-sent every turn (cached after the first), and the agent reads and updates MEMORY.md as it works. Local seats spend nothing.`;\n\n/** The first credential shape found, as a phrase (\"a GitHub token\"), or null. */\nexport function secretLike(text: string): string | null {\n for (const { label, re } of SECRET_PATTERNS) if (re.test(text)) return label;\n return null;\n}\n\n/**\n * The placeholder the server's scrubber (src/core/util/scrub.ts) writes over\n * secret-shaped text in every rule. In a memory view flagged\n * `contentSanitized`, each one stands for a REAL value still in MEMORY.md.\n */\nexport const REDACTION_MARKER = '[REDACTED]';\n\n/** How many redaction placeholders a text carries. */\nexport function redactionMarkers(text: string): number {\n return text.split(REDACTION_MARKER).length - 1;\n}\n\n// ---------------------------------------------------------------------------\n// Search\n// ---------------------------------------------------------------------------\n\n/** Below this many characters a keyword search over every message is noise, not recall. */\nexport const SEARCH_MIN_CHARS = 2;\n/** Keystrokes inside this window collapse into one request. */\nexport const SEARCH_DEBOUNCE_MS = 250;\n/** Hits asked for per search — enough to fill the sidebar twice over. */\nexport const SEARCH_LIMIT = 30;\n\n/** Whitespace-separated terms, lowercased and de-duplicated (the server ANDs them). */\nexport function searchTerms(query: string): string[] {\n const out: string[] = [];\n for (const raw of query.toLowerCase().split(/\\s+/)) {\n if (raw && !out.includes(raw)) out.push(raw);\n }\n return out;\n}\n\nexport interface HighlightSegment {\n text: string;\n match: boolean;\n}\n\nfunction escapeRegExp(value: string): string {\n return value.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&');\n}\n\n/**\n * Split `text` into plain and matched runs for every term, case-insensitive.\n * Longest terms first so \"migrate\" wins over \"migrat\" at the same position.\n */\nexport function highlightSegments(text: string, terms: readonly string[]): HighlightSegment[] {\n const usable = [...terms].filter((t) => t.length > 0).sort((a, b) => b.length - a.length);\n if (usable.length === 0 || text.length === 0) return text ? [{ text, match: false }] : [];\n const re = new RegExp(usable.map(escapeRegExp).join('|'), 'gi');\n const out: HighlightSegment[] = [];\n let last = 0;\n for (const m of text.matchAll(re)) {\n const start = m.index ?? 0;\n if (m[0].length === 0) continue;\n if (start > last) out.push({ text: text.slice(last, start), match: false });\n out.push({ text: m[0], match: true });\n last = start + m[0].length;\n }\n if (last < text.length) out.push({ text: text.slice(last), match: false });\n return out;\n}\n\nexport interface SessionSearchGroup {\n sessionId: string;\n title: string;\n projectPath: string;\n engine: VerseEngine;\n /** The best-scoring hit in this session (the server returns hits best-first). */\n top: VerseSearchHit;\n /** Every hit this session contributed to the response. */\n count: number;\n /** Newest hit time, for the row's relative time. */\n latestAt: string;\n}\n\n/**\n * One row per session. The server ranks MESSAGES; the sidebar lists CHATS,\n * and five rows for one chat would push every other match off screen. Order\n * is the order each session first appears, i.e. by its best hit.\n */\nexport function groupSearchHits(hits: readonly VerseSearchHit[]): SessionSearchGroup[] {\n const groups = new Map<string, SessionSearchGroup>();\n for (const hit of hits) {\n const existing = groups.get(hit.sessionId);\n if (!existing) {\n groups.set(hit.sessionId, {\n sessionId: hit.sessionId,\n title: hit.title,\n projectPath: hit.projectPath,\n engine: hit.engine,\n top: hit,\n count: 1,\n latestAt: hit.at,\n });\n continue;\n }\n existing.count += 1;\n if (hit.at > existing.latestAt) existing.latestAt = hit.at;\n }\n return [...groups.values()];\n}\n"],"mappings":"2MA2CA,IAAM,EAAc,oBAOpB,SAAgB,EAAa,EAA6B,CACxD,IAAM,EAAY,EAAY,QAAQ,OAAQ,GAAG,CAAC,CAAC,KAAK,EAClD,EAAQ,EAAY,KAAK,CAAS,EAClC,GAAQ,EAAQ,EAAU,MAAM,EAAG,EAAM,KAAK,EAAI,IAAc,gBAEhE,EAAS,WADF,EAAQ,OAAO,SAAS,EAAM,GAAK,EAAE,EAAI,EAAI,IAEpD,EAAA,IAAyB,EAAO,OAEtC,MAAO,GADS,EAAK,OAAS,EAAO,GAAG,EAAK,MAAM,EAAG,EAAO,CAAC,CAAC,CAAC,QAAQ,EAAE,GAAK,IAC3D,GACtB,CAOA,SAAgB,EAAY,EAAoC,EAA0C,CACxG,GAAI,CAAC,EAAM,OAAO,KAClB,IAAM,EAAQ,EAAK,OAAO,KAAM,GAAM,EAAE,KAAO,CAAO,EACtD,GAAI,EAAO,OAAO,EAClB,IAAM,EAAY,EAAiB,CAAO,EAC1C,OAAO,EAAK,OAAO,KAAM,GAAM,EAAiB,EAAE,EAAE,IAAM,CAAS,GAAK,IAC1E,CASA,SAAgB,EACd,EACA,EACA,EAAc,KAAK,IAAI,EACR,CASf,OARK,EACD,EAAK,OAAO,QAAU,cACjB,GAAG,EAAK,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EAAQ,EAAE,OAAS,EACrB,EAAE,EAAE,CAAC,SAAW,IAChB,EAAQ,GAAM,EAAI,KAAK,CAAE,KAAM,EAAK,MAAM,EAAM,CAAK,EAAG,MAAO,EAAM,CAAC,EAC1E,EAAI,KAAK,CAAE,KAAM,EAAE,GAAI,MAAO,EAAK,CAAC,EACpC,EAAO,EAAQ,EAAE,EAAE,CAAC,OACtB,CAEA,OADI,EAAO,EAAK,QAAQ,EAAI,KAAK,CAAE,KAAM,EAAK,MAAM,CAAI,EAAG,MAAO,EAAM,CAAC,EAClE,CACT,CAoBA,SAAgB,EAAgB,EAAuD,CACrF,IAAM,EAAS,IAAI,IACnB,IAAK,IAAM,KAAO,EAAM,CACtB,IAAM,EAAW,EAAO,IAAI,EAAI,SAAS,EACzC,GAAI,CAAC,EAAU,CACb,EAAO,IAAI,EAAI,UAAW,CACxB,UAAW,EAAI,UACf,MAAO,EAAI,MACX,YAAa,EAAI,YACjB,OAAQ,EAAI,OACZ,IAAK,EACL,MAAO,EACP,SAAU,EAAI,EAChB,CAAC,EACD,QACF,CACA,EAAS,OAAS,EACd,EAAI,GAAK,EAAS,WAAU,EAAS,SAAW,EAAI,GAC1D,CACA,MAAO,CAAC,GAAG,EAAO,OAAO,CAAC,CAC5B"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{A as e,F as t,L as n,S as r,b as i,i as a,k as o,m as s,t as c,z as l}from"./verse-model-DyCwZF-M.js";import{r as u}from"./verse-store-b_Lek_c5.js";import{f as d}from"./format-BkWdOQDL.js";function f(e,t){return e?s([e],{seatId:e.id,model:t}):null}function p(e,t){return t!==`standard`&&o(e,t)!==null?t:`standard`}function m(e,t){return o(e,p(e,t))}function h(e,t){let n=i(e);if(n!==null)return n;let r=t.unavailableReason;return typeof r==`string`&&r.trim().length>0?r.trim():null}var g={standard:`Standard`,expansive:`Expansive`},_={claude:`Claude Code`,codex:`Codex CLI`,grok:`Grok CLI`,local:`Claude Code`};function v(e){let t=typeof e.cliVersion==`string`?e.cliVersion.trim():``;return t.length>0?`${_[e.engine]} ${t}`:null}function y(e){return(e.notes??[]).filter(e=>typeof e==`string`&&e.trim().length>0)}function b(e){return e===`fallback`}function x(e,t=`standard`){let n=p(e,t),r=o(e,n);return r?`${`${u(r.contextWindow)} ctx${b(e.windowSource)?` (est.)`:``}`}${r.autoCompactAt===null?``:` · compacts ≈${u(r.autoCompactAt)}`}${n===`expansive`?` (expansive)`:``}`:`window unknown`}function S(e){let t=o(e,`standard`),r=n(e)?o(e,`expansive`):null,i=[];if(!t)i.push(`Context window unknown for this model.`);else{let e=t.autoCompactAt===null?``:`; compacts at about ${u(t.autoCompactAt)}${r?` in Standard`:``}`;i.push(`${u(t.contextWindow)}-token window${e}.`)}return r&&i.push(`Expansive runs to about ${u(r.autoCompactAt??r.contextWindow)} before compacting.`),e.windowSource&&i.push(`Window ${a[e.windowSource]}.`),i.join(` `)}function C(e){return e===`codex`?c:null}function w(e){let t=o(e,`standard`),n=o(e,`expansive`),r=t?t.autoCompactAt??t.contextWindow:null,i=n?n.autoCompactAt??n.contextWindow:null;return r===null||i===null||r<=0?null:`A turn at ${u(i)} re-sends ${(i/r).toFixed(1)}× the tokens of one at ${u(r)}.`}function T(e,t,n){let r=o(t,`standard`),i=o(t,`expansive`),a=r?r.autoCompactAt??r.contextWindow:null,s=i?i.autoCompactAt??i.contextWindow:null;if(n===`standard`||s===null)return a===null?`The CLI compacts at its own default point for this model.`:e===`claude`?`Compacts at about ${u(a)}. Every turn re-sends the whole context, so holding it under this point keeps each turn cheaper and recall sharper.`:`Compacts at about ${u(a)} — the CLI's own default budget for this model.`;let c=w(t),l=C(e);return`Runs to about ${u(s)} before compacting — for tightly coupled, cross-cutting work that needs everything in view at once. Each turn re-sends everything held, so a long expansive chat uses noticeably more of your plan per turn.${c?` ${c}`:``}${l?` ${l}`:``}`}function E(e,t){return o(t,`standard`)?e===`grok`||e===`local`?`One budget: this CLI compacts at its own fixed point, and Verse cannot raise it per chat.`:`One budget: this model has no larger window to expand into.`:`This model’s window is unknown, so Verse cannot offer a larger budget for it.`}var D={fits:`code fits`,tight:`code fits, tight`,expansive:`code needs expansive`,split:`code too big — split`},O={fits:`Fits`,tight:`Tight fit`,expansive:`Needs expansive`,split:`Split the work`};function k(e){return e.roots.some(e=>e.truncated)}function A(e,n,r,i){if(typeof e!=`number`||!Number.isFinite(e)||e<0)return null;let a=l(i);if(p(n,r)===`expansive`&&n){let r=o(n,`expansive`);return t(e,{...n,contextWindow:r.contextWindow,autoCompactAt:r.autoCompactAt,expansive:null},a)}return t(e,n,a)}function j(e){let t=`${e.floor?`at least `:``}~${u(e.tokens)} tokens of tracked code`,r=p(e.option,e.mode)===`expansive`,i=o(e.option,`standard`),a=o(e.option,`expansive`),s=i?u(i.autoCompactAt??i.contextWindow):null,c=a?u(a.autoCompactAt??a.contextWindow):null,l=r?c:s,d=r?`Expansive budget`:`budget`;switch(e.verdict){case`fits`:return`All ${t} fits well inside this model's ${d}${l?` (compacts ≈${l})`:``}, with room left for the conversation.`;case`tight`:{let i=!r&&c!==null&&n(e.option)?` Expansive (≈${c}) would hold it with room to spare.`:``;return`${N(t)} fits under the ≈${l??`?`} compaction point${r?` of the Expansive budget`:``}, with little room for the conversation — expect it to compact if the agent reads widely.${i}`}case`expansive`:return`${N(t)} is more than the Standard budget (≈${s??`?`}) holds; only Expansive (≈${c??`?`}) takes it all. Switch to Expansive, or narrow the folders to the part you are changing.`;case`split`:return`${N(t)} is more than any single context on this model holds${c?`, even Expansive (≈${c})`:``}. Split the work: fan it out across several chats, each scoped to one folder or subsystem, or narrow this chat to the part you are changing.`}}function M(e){let t=e?` for ${_[e]}`:``;return`Estimated from the size of tracked text files (bytes ÷ 4), plus an estimated ~${u(l(e))} of fixed prompt${t} that every chat starts with. An agent rarely reads everything, so this is a ceiling, not a forecast.`}function N(e){return e.length===0?e:e.charAt(0).toUpperCase()+e.slice(1)}function P(e,t){let i=r(t,e);return{tokens:Math.floor(i.contextTokens),exact:i.exact,window:i.contextWindow,autoCompactAt:i.autoCompactAt,source:i.source,mode:i.mode,hasModes:n(i.option)}}function F(t){return t.cacheReadTokens<=0&&t.cacheCreationTokens<=0?null:e(t)}function I(e){return e===null||!Number.isFinite(e)?`—`:d(e)}function L(e){let t=new Map,n=0,r=null,i=(e,n,r)=>{if(!Number.isFinite(n)||n<0)return;let i=t.get(e)??{exact:null,bound:null};r?i.exact=Math.max(i.exact??0,n):i.bound=Math.max(i.bound??0,n),t.set(e,i)};for(let t of e)switch(t.type){case`usage`:r=t.usage,i(t.turnId,t.usage.contextTokens,t.usage.contextTokensExact!==!1);break;case`context`:t.turnId!==null&&i(t.turnId,t.contextTokens,t.exact);break;case`compaction`:n+=1}let a=0,o=null,s=!0,c=0;for(let e of t.values()){let t=e.exact??e.bound;t!==null&&(e.exact===null&&(s=!1),c+=1,a+=t,o=o===null?t:Math.max(o,t))}return{turns:c,average:c===0?null:Math.round(a/c),peak:o,exact:s,compactions:n,lastTurnCacheHit:r===null?null:F(r)}}function R(e,t,n,r){if(e.status===`running`||r===null)return null;let i=Date.parse(r);if(!Number.isFinite(i))return null;let a=n-i;return a<36e5||t<l(e.engine)?null:{idleMs:a,tokens:t,local:e.engine===`local`}}function z(e,t){return e.window!==null&&t.window!==null?e.tokens/e.window>t.tokens/t.window:e.window!==null||t.window===null&&e.tokens>t.tokens}function B(e,t){let n=new Map;for(let t of e){let e=n.get(t.seatId)??[];e.push(t),n.set(t.seatId,e)}let r=[];for(let[e,i]of n){let n=t.find(t=>t.id===e)??null,a=0,o=0,s=0,c=0,l=0,u=0,d=0,f=null;for(let e of i){a+=e.usage.inputTokens,o+=e.usage.cacheReadTokens,s+=e.usage.cacheCreationTokens,c+=e.usage.outputTokens,l+=e.turnCount,u+=e.compactionCount??0;let n=P(e,t);if(n.mode===`expansive`&&(d+=1),n.tokens<=0)continue;let r={sessionId:e.id,title:e.title,tokens:n.tokens,window:n.window,exact:n.exact};(f===null||z(r,f))&&(f=r)}r.push({seatId:e,label:n?.label??e,engine:n?.engine??i[0].engine,retired:n===null,sessions:i.length,turns:l,promptTokens:a+o+s,outputTokens:c,cacheHitRatio:F({inputTokens:a,cacheReadTokens:o,cacheCreationTokens:s}),compactions:u,expansiveSessions:d,fullest:f})}return r.sort((e,t)=>t.promptTokens-e.promptTokens||e.label.localeCompare(t.label))}export{f as C,B as S,L as T,E as _,m as a,v as b,j as c,I as d,R as f,h as g,A as h,T as i,k as l,S as m,O as n,C as o,x as p,D as r,w as s,g as t,M as u,F as v,P as w,y as x,p as y};
|
|
2
|
+
//# sourceMappingURL=context-model-CIBmSugV.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context-model-MT17V86_.js","names":[],"sources":["../../../../../../src/web-ui/routes/verse/usage/context-model.ts"],"sourcesContent":["/**\n * routes/verse/usage/context-model.ts — the ONE projection of context facts\n * for every surface that shows a seat: the seat picker's rows, the new-chat\n * dialog's context block, the resources panel's \"This chat\" efficiency block,\n * and the Usage section's per-seat efficiency table.\n *\n * WHY ONE MODULE. Before V3.9 every surface read `seat.contextWindow` (the\n * DEFAULT model's window) or the session's creation-time window, and three of\n * them rendered \"200k\" for a 1M Claude model. The arithmetic now lives in\n * core/verse/context-math.ts, shared with the server; this module is only the\n * wording and the aggregation, so the picker, the dialog and the panel cannot\n * describe one model's budget three different ways.\n *\n * HONESTY RULES this module enforces (docs/VERSE-CONTEXT.md):\n *\n * 1. UNKNOWN IS NOT A NUMBER. A model whose budget is unknown reads \"window\n * unknown\", never a default dressed as a fact. A Verse fallback window is\n * marked \"est.\", and its source says so in words.\n * 2. AN UPPER BOUND IS NOT A MEASUREMENT. Codex's turn total sums every model\n * call; until its rollout is read, occupancy is \"≤ N\", and any statistic\n * built on such a reading carries the same flag.\n * 3. NO CACHE REPORTED IS NOT A 0% HIT RATE. A provider that reported no\n * cache activity at all (Ollama; codex on its very first call) gets \"none\n * reported\", not a 0% that reads \"caching is broken\".\n * 4. NOTHING HERE SPENDS. Every figure is derived from what the server\n * already returned (seats, sessions, the open chat's event log).\n *\n * Pure: no React, no I/O.\n */\nimport {\n CACHE_IDLE_TTL_MS,\n budgetFor,\n cacheHitRatio,\n fitVerdict,\n hasExpansiveMode,\n sessionOverheadTokens,\n} from '../../../../core/verse/context-math.js';\nimport type {\n VerseContextBudget,\n VerseContextFit,\n VerseContextMode,\n VerseEngine,\n VerseEvent,\n VerseFitVerdict,\n VerseModelOption,\n VerseSeat,\n VerseSession,\n VerseUsage,\n VerseWindowSource,\n} from '../../../../core/verse/types.js';\nimport { CODEX_EXPANSIVE_METERING_NOTE, WINDOW_SOURCE_TEXT, modelOptionFor, seatUnavailableReason, sessionContextBudget } from '../verse-model.js';\nimport { formatTokens } from '../verse-store.js';\nimport { formatWholePercent } from '../autonomy/format.js';\n\n// ---------------------------------------------------------------------------\n// Models and modes\n// ---------------------------------------------------------------------------\n\n/**\n * A seat's option for a model id, matching through the alias table (a chat\n * remembered on `claude-opus-5.5` is the catalog's `claude-opus-5-5`). The\n * lookup itself is verse-model's `modelOptionFor`, the one the context meter\n * uses, so the picker and the meter can never resolve one id two ways.\n */\nexport function seatModelOption(seat: VerseSeat | null | undefined, modelId: string): VerseModelOption | null {\n return seat ? modelOptionFor([seat], { seatId: seat.id, model: modelId }) : null;\n}\n\n/** `mode` when this model has a budget for it, else `standard` — never a mode the CLI cannot be told. */\nexport function resolveContextMode(option: VerseModelOption | null | undefined, mode: VerseContextMode): VerseContextMode {\n return mode !== 'standard' && budgetFor(option, mode) !== null ? mode : 'standard';\n}\n\n/** The budget a model runs with in a mode (resolved), or null when even its standard window is unknown. */\nexport function effectiveBudget(option: VerseModelOption | null | undefined, mode: VerseContextMode): VerseContextBudget | null {\n return budgetFor(option, resolveContextMode(option, mode));\n}\n\n/** Why this model cannot be chosen on this seat, or null when it can. The seat's own outage wins. */\nexport function modelUnavailableReason(seat: VerseSeat, option: VerseModelOption): string | null {\n const seatReason = seatUnavailableReason(seat);\n if (seatReason !== null) return seatReason;\n const reason = option.unavailableReason;\n return typeof reason === 'string' && reason.trim().length > 0 ? reason.trim() : null;\n}\n\nexport const CONTEXT_MODE_LABEL: Record<VerseContextMode, string> = {\n standard: 'Standard',\n expansive: 'Expansive',\n};\n\n/** How each seat's CLI is named when its pinned version is shown. */\nexport const ENGINE_CLI_NAME: Record<VerseEngine, string> = {\n claude: 'Claude Code',\n codex: 'Codex CLI',\n grok: 'Grok CLI',\n local: 'Claude Code',\n};\n\n/** \"Claude Code 2.1.257\" — the binary this seat is pinned to; null when unknown (local seats, old servers). */\nexport function seatCliLine(seat: VerseSeat): string | null {\n const version = typeof seat.cliVersion === 'string' ? seat.cliVersion.trim() : '';\n return version.length > 0 ? `${ENGINE_CLI_NAME[seat.engine]} ${version}` : null;\n}\n\n/** The seat's own plain-language context facts (binary skew, catalog not yet fetched, …). */\nexport function seatContextNotes(seat: VerseSeat): string[] {\n return (seat.notes ?? []).filter((n): n is string => typeof n === 'string' && n.trim().length > 0);\n}\n\n// ---------------------------------------------------------------------------\n// Window provenance\n// ---------------------------------------------------------------------------\n\n// Window provenance wording is verse-model's `WINDOW_SOURCE_TEXT` — the\n// meter's tooltip, the picker and the resources panel all read that one table.\n\nexport function isEstimatedWindow(source: VerseWindowSource | null | undefined): boolean {\n return source === 'fallback';\n}\n\n// ---------------------------------------------------------------------------\n// Picker and dialog wording\n// ---------------------------------------------------------------------------\n\n/**\n * The compact per-model phrase a picker row carries: \"1M ctx · compacts ≈367k\".\n * Uses the budget for `mode` when the model has one, and names the mode only\n * when it is not the default, so an ordinary row stays short.\n */\nexport function modelContextPhrase(option: VerseModelOption, mode: VerseContextMode = 'standard'): string {\n const resolved = resolveContextMode(option, mode);\n const budget = budgetFor(option, resolved);\n if (!budget) return 'window unknown';\n const window = `${formatTokens(budget.contextWindow)} ctx${isEstimatedWindow(option.windowSource) ? ' (est.)' : ''}`;\n const compacts = budget.autoCompactAt === null ? '' : ` · compacts ≈${formatTokens(budget.autoCompactAt)}`;\n return `${window}${compacts}${resolved === 'expansive' ? ' (expansive)' : ''}`;\n}\n\n/**\n * The full sentence for a tooltip or the dialog: the window, where each mode\n * compacts, and how the window is known.\n */\nexport function modelContextSentence(option: VerseModelOption): string {\n const standard = budgetFor(option, 'standard');\n const expansive = hasExpansiveMode(option) ? budgetFor(option, 'expansive') : null;\n const parts: string[] = [];\n if (!standard) {\n parts.push('Context window unknown for this model.');\n } else {\n const where = standard.autoCompactAt === null\n ? ''\n : `; compacts at about ${formatTokens(standard.autoCompactAt)}${expansive ? ' in Standard' : ''}`;\n parts.push(`${formatTokens(standard.contextWindow)}-token window${where}.`);\n }\n if (expansive) {\n parts.push(`Expansive runs to about ${formatTokens(expansive.autoCompactAt ?? expansive.contextWindow)} before compacting.`);\n }\n if (option.windowSource) parts.push(`Window ${WINDOW_SOURCE_TEXT[option.windowSource]}.`);\n return parts.join(' ');\n}\n\n/**\n * The metering caveat an Expansive cost sentence must carry for this engine,\n * or null when there is none. The wording is verse-model's\n * CODEX_EXPANSIVE_METERING_NOTE — ONE sentence for the new-chat dialog, the\n * handoff dialog, the in-chat mode menu and the \"Expansive could help\" chip.\n * The ratio those surfaces quote (≈3.2× for a 785k vs 245k codex turn) counts\n * re-sent TOKENS only; GPT-5.6-class requests above 272k reportedly also\n * count about 2× against plan limits (docs/VERSE-CONTEXT.md §2.3, a single\n * secondary source), so the note is worded as reported, never as a measured\n * multiplier. Standard never crosses 272k; Expansive does by design.\n */\nexport function expansiveMeteringNote(engine: VerseEngine | null | undefined): string | null {\n return engine === 'codex' ? CODEX_EXPANSIVE_METERING_NOTE : null;\n}\n\n/**\n * \"A turn at 967k re-sends 2.6× the tokens of one at 367k.\" — the only ratio\n * any Expansive cost sentence quotes, and it is arithmetic on the model's own\n * budgets. Null when either compaction point is unknown. It comes BEFORE the\n * codex metering note, whose \"twice that\" refers to it.\n */\nexport function expansiveRatioSentence(option: VerseModelOption | null | undefined): string | null {\n const standard = budgetFor(option, 'standard');\n const expansive = budgetFor(option, 'expansive');\n const stdCap = standard ? standard.autoCompactAt ?? standard.contextWindow : null;\n const expCap = expansive ? expansive.autoCompactAt ?? expansive.contextWindow : null;\n if (stdCap === null || expCap === null || stdCap <= 0) return null;\n return `A turn at ${formatTokens(expCap)} re-sends ${(expCap / stdCap).toFixed(1)}× the tokens of one at ${formatTokens(stdCap)}.`;\n}\n\n/**\n * What each mode costs, in plain words, for the mode selector. Numbers come\n * from the model's own budgets; the only ratio quoted is arithmetic (every\n * turn re-sends everything held, so a turn at X re-sends X/Y of one at Y) —\n * a token ratio, not a usage multiplier, which is why codex also carries the\n * shared metering caveat.\n */\nexport function contextModeDescription(engine: VerseEngine, option: VerseModelOption, mode: VerseContextMode): string {\n const standard = budgetFor(option, 'standard');\n const expansive = budgetFor(option, 'expansive');\n const stdCap = standard ? standard.autoCompactAt ?? standard.contextWindow : null;\n const expCap = expansive ? expansive.autoCompactAt ?? expansive.contextWindow : null;\n if (mode === 'standard' || expCap === null) {\n if (stdCap === null) return 'The CLI compacts at its own default point for this model.';\n return engine === 'claude'\n ? `Compacts at about ${formatTokens(stdCap)}. Every turn re-sends the whole context, so holding it under this point keeps each turn cheaper and recall sharper.`\n : `Compacts at about ${formatTokens(stdCap)} — the CLI's own default budget for this model.`;\n }\n const ratio = expansiveRatioSentence(option);\n const metering = expansiveMeteringNote(engine);\n return `Runs to about ${formatTokens(expCap)} before compacting — for tightly coupled, cross-cutting work that needs everything in view at once. Each turn re-sends everything held, so a long expansive chat uses noticeably more of your plan per turn.${ratio ? ` ${ratio}` : ''}${metering ? ` ${metering}` : ''}`;\n}\n\n/** Why a model offers no mode choice, for the one line where the selector would be. */\nexport function noModeReason(engine: VerseEngine, option: VerseModelOption): string {\n if (!budgetFor(option, 'standard')) return 'This model’s window is unknown, so Verse cannot offer a larger budget for it.';\n if (engine === 'grok' || engine === 'local') return 'One budget: this CLI compacts at its own fixed point, and Verse cannot raise it per chat.';\n return 'One budget: this model has no larger window to expand into.';\n}\n\n// ---------------------------------------------------------------------------\n// Context fit\n// ---------------------------------------------------------------------------\n\n/** Short form for a picker row, where it sits beside the capacity words. */\nexport const FIT_SHORT: Record<VerseFitVerdict, string> = {\n fits: 'code fits',\n tight: 'code fits, tight',\n expansive: 'code needs expansive',\n split: 'code too big — split',\n};\n\n/** Badge text for the chosen model. */\nexport const FIT_LABEL: Record<VerseFitVerdict, string> = {\n fits: 'Fits',\n tight: 'Tight fit',\n expansive: 'Needs expansive',\n split: 'Split the work',\n};\n\n/** A fit reading that is a FLOOR (a root hit its file or time cap). */\nexport function fitIsFloor(fit: VerseContextFit): boolean {\n return fit.roots.some((r) => r.truncated);\n}\n\n/**\n * The verdict for a model IN THE MODE THE CHAT WOULD RUN IN, or null when its\n * budget is unknown (never guessed).\n *\n * `engine` is the seat's engine: the fixed prompt added to the code is that\n * CLI's estimate (context-math `sessionOverheadTokens` — ≈15k local, ≈25k\n * claude), not one flat figure. With a flat 30k a 64k local seat (compacts\n * ≈32.5k) called anything over ~2.5k tokens of code \"too big — split\". Null\n * falls back to the largest estimate.\n *\n * In Standard this is context-math's `fitVerdict` as is — including\n * \"expansive\", the suggestion that only the bigger budget holds the code. In\n * Expansive the bigger budget IS the budget, so the same thresholds are\n * applied to it: the code fits, fits tightly, or no single context on this\n * model holds it. Without this, a chat already set to Expansive would still be\n * told its code \"fits tightly under ≈367k\" — true of a budget it is not using.\n */\nexport function modelFit(\n tokens: number | null | undefined,\n option: VerseModelOption | null | undefined,\n mode: VerseContextMode,\n engine: VerseEngine | null,\n): VerseFitVerdict | null {\n if (typeof tokens !== 'number' || !Number.isFinite(tokens) || tokens < 0) return null;\n const overhead = sessionOverheadTokens(engine);\n if (resolveContextMode(option, mode) === 'expansive' && option) {\n const expansive = budgetFor(option, 'expansive')!;\n return fitVerdict(tokens, { ...option, contextWindow: expansive.contextWindow, autoCompactAt: expansive.autoCompactAt, expansive: null }, overhead);\n }\n return fitVerdict(tokens, option, overhead);\n}\n\n/**\n * The sentence under the fit badge, for the verdict `modelFit` gave in the\n * chat's mode. In Standard a tight fit also names the Expansive budget when\n * one exists, and \"needs expansive\" says what to do — suggestions only;\n * nothing here switches the mode.\n */\nexport function fitExplanation(input: {\n verdict: VerseFitVerdict;\n tokens: number;\n option: VerseModelOption;\n mode: VerseContextMode;\n floor?: boolean;\n}): string {\n const amount = `${input.floor ? 'at least ' : ''}~${formatTokens(input.tokens)} tokens of tracked code`;\n const inExpansive = resolveContextMode(input.option, input.mode) === 'expansive';\n const standard = budgetFor(input.option, 'standard');\n const expansive = budgetFor(input.option, 'expansive');\n const stdCap = standard ? formatTokens(standard.autoCompactAt ?? standard.contextWindow) : null;\n const expCap = expansive ? formatTokens(expansive.autoCompactAt ?? expansive.contextWindow) : null;\n const cap = inExpansive ? expCap : stdCap;\n const budget = inExpansive ? 'Expansive budget' : 'budget';\n switch (input.verdict) {\n case 'fits':\n return `All ${amount} fits well inside this model's ${budget}${cap ? ` (compacts ≈${cap})` : ''}, with room left for the conversation.`;\n case 'tight': {\n const roomier = !inExpansive && expCap !== null && hasExpansiveMode(input.option)\n ? ` Expansive (≈${expCap}) would hold it with room to spare.`\n : '';\n return `${capitalize(amount)} fits under the ≈${cap ?? '?'} compaction point${inExpansive ? ' of the Expansive budget' : ''}, with little room for the conversation — expect it to compact if the agent reads widely.${roomier}`;\n }\n case 'expansive':\n return `${capitalize(amount)} is more than the Standard budget (≈${stdCap ?? '?'}) holds; only Expansive (≈${expCap ?? '?'}) takes it all. Switch to Expansive, or narrow the folders to the part you are changing.`;\n case 'split':\n return `${capitalize(amount)} is more than any single context on this model holds${expCap ? `, even Expansive (≈${expCap})` : ''}. Split the work: fan it out across several chats, each scoped to one folder or subsystem, or narrow this chat to the part you are changing.`;\n }\n}\n\n/**\n * How the working-set figure is made — shown once, beside the badge. Names the\n * fixed-prompt figure the verdict added, and calls it an estimate: no CLI\n * reports its base prompt before a turn has run.\n */\nexport function fitMethodNote(engine: VerseEngine | null): string {\n const cli = engine ? ` for ${ENGINE_CLI_NAME[engine]}` : '';\n return `Estimated from the size of tracked text files (bytes ÷ 4), plus an estimated ~${formatTokens(sessionOverheadTokens(engine))} of fixed prompt${cli} that every chat starts with. An agent rarely reads everything, so this is a ceiling, not a forecast.`;\n}\n\nfunction capitalize(text: string): string {\n return text.length === 0 ? text : text.charAt(0).toUpperCase() + text.slice(1);\n}\n\n// ---------------------------------------------------------------------------\n// One session's context\n// ---------------------------------------------------------------------------\n\nexport interface SessionContextView {\n tokens: number;\n /** False when `tokens` is an upper bound (codex before its rollout is read). */\n exact: boolean;\n window: number | null;\n autoCompactAt: number | null;\n /** How the window is known; null when nothing says (no window, or a stored one without provenance). */\n source: VerseWindowSource | null;\n mode: VerseContextMode;\n /** The session's model has a real expansive budget on its seat. */\n hasModes: boolean;\n}\n\n/**\n * The window a session is measured against, by the precedence every surface\n * shares — runtime → the seat's CURRENT catalog budget for the model and mode\n * → what the record stored → the seat default. The precedence itself lives in\n * verse-model's `sessionContextBudget` (the context meter reads it too); this\n * only adds whether the model offers a second mode, for the panels here.\n */\nexport function sessionContext(session: VerseSession, seats: readonly VerseSeat[]): SessionContextView {\n const budget = sessionContextBudget(seats, session);\n return {\n tokens: Math.floor(budget.contextTokens),\n exact: budget.exact,\n window: budget.contextWindow,\n autoCompactAt: budget.autoCompactAt,\n source: budget.source,\n mode: budget.mode,\n hasModes: hasExpansiveMode(budget.option),\n };\n}\n\n/**\n * Cache-hit ratio, except when the provider reported no cache activity at all\n * — then null (\"none reported\"), because 0% would claim caching failed when\n * the truth is that nothing was said about it.\n */\nexport function reportedCacheHitRatio(usage: Pick<VerseUsage, 'inputTokens' | 'cacheReadTokens' | 'cacheCreationTokens'>): number | null {\n if (usage.cacheReadTokens <= 0 && usage.cacheCreationTokens <= 0) return null;\n return cacheHitRatio(usage);\n}\n\n/** A 0–1 ratio as a whole percent; a real sliver reads \"<1%\", never \"0%\". */\nexport function formatRatio(ratio: number | null): string {\n if (ratio === null || !Number.isFinite(ratio)) return '—';\n return formatWholePercent(ratio);\n}\n\nexport interface TurnContextStats {\n /** Turns with at least one context reading. */\n turns: number;\n /** Mean of each turn's context (its largest trustworthy reading); null with no turns. */\n average: number | null;\n /** Largest per-turn context seen. */\n peak: number | null;\n /** False when any counted turn had only an upper-bound reading. */\n exact: boolean;\n /** Compactions recorded in the log. */\n compactions: number;\n /** Cache-hit ratio of the most recent turn (see `reportedCacheHitRatio`). */\n lastTurnCacheHit: number | null;\n}\n\n/**\n * Context per turn from the open chat's event log.\n *\n * A turn's context is its LARGEST trustworthy reading: within one turn the\n * prompt only grows, except across a compaction, and the peak is what the\n * turn actually paid for. Exact readings (`context` events, usage frames not\n * flagged as upper bounds) win; a turn whose only reading is codex's turn\n * total contributes that total and flags the statistic as an upper bound —\n * that figure can be many times the real prompt, so it is never mixed in\n * where an exact one exists.\n */\nexport function turnContextStats(events: readonly VerseEvent[]): TurnContextStats {\n const perTurn = new Map<string, { exact: number | null; bound: number | null }>();\n let compactions = 0;\n let lastUsage: VerseUsage | null = null;\n const note = (turnId: string, tokens: number, exact: boolean): void => {\n if (!Number.isFinite(tokens) || tokens < 0) return;\n const entry = perTurn.get(turnId) ?? { exact: null, bound: null };\n if (exact) entry.exact = Math.max(entry.exact ?? 0, tokens);\n else entry.bound = Math.max(entry.bound ?? 0, tokens);\n perTurn.set(turnId, entry);\n };\n for (const event of events) {\n switch (event.type) {\n case 'usage':\n lastUsage = event.usage;\n note(event.turnId, event.usage.contextTokens, event.usage.contextTokensExact !== false);\n break;\n case 'context':\n if (event.turnId !== null) note(event.turnId, event.contextTokens, event.exact);\n break;\n case 'compaction':\n compactions += 1;\n break;\n default:\n break;\n }\n }\n let sum = 0;\n let peak: number | null = null;\n let exact = true;\n let turns = 0;\n for (const entry of perTurn.values()) {\n const value = entry.exact ?? entry.bound;\n if (value === null) continue;\n if (entry.exact === null) exact = false;\n turns += 1;\n sum += value;\n peak = peak === null ? value : Math.max(peak, value);\n }\n return {\n turns,\n average: turns === 0 ? null : Math.round(sum / turns),\n peak,\n exact,\n compactions,\n lastTurnCacheHit: lastUsage === null ? null : reportedCacheHitRatio(lastUsage),\n };\n}\n\nexport interface IdleCacheWarning {\n idleMs: number;\n tokens: number;\n /** A local model: the cost is time, not spend. */\n local: boolean;\n}\n\n/**\n * The next turn of an idle chat re-reads its whole context uncached once the\n * provider's prompt cache has expired (CACHE_IDLE_TTL_MS). Below the fixed\n * prompt every new chat on this engine pays anyway (its estimate) there is\n * nothing worth warning about.\n */\nexport function idleCacheWarning(\n session: Pick<VerseSession, 'status' | 'engine'>,\n tokens: number,\n now: number,\n /**\n * When the chat last TALKED to its provider (`lastTurnActivityAt(events)`),\n * never `session.updatedAt`: a rename or mode switch moves that without\n * warming the provider's cache. Null (no turn yet / log not loaded) → no warning.\n */\n lastActivityAt: string | null,\n): IdleCacheWarning | null {\n if (session.status === 'running' || lastActivityAt === null) return null;\n const last = Date.parse(lastActivityAt);\n if (!Number.isFinite(last)) return null;\n const idleMs = now - last;\n if (idleMs < CACHE_IDLE_TTL_MS || tokens < sessionOverheadTokens(session.engine)) return null;\n return { idleMs, tokens, local: session.engine === 'local' };\n}\n\n// ---------------------------------------------------------------------------\n// Per-seat efficiency across sessions (Usage section)\n// ---------------------------------------------------------------------------\n\nexport interface SeatEfficiencyRow {\n seatId: string;\n label: string;\n engine: VerseEngine;\n /** The seat is no longer in the roster (its sessions remain on disk). */\n retired: boolean;\n sessions: number;\n turns: number;\n /** input + cache read + cache write: every prompt token the seat was sent. */\n promptTokens: number;\n outputTokens: number;\n /** Null when the provider reported no cache activity on any of these sessions. */\n cacheHitRatio: number | null;\n compactions: number;\n expansiveSessions: number;\n /** The fullest context among these sessions right now, as a share of its window. */\n fullest: { sessionId: string; title: string; tokens: number; window: number | null; exact: boolean } | null;\n}\n\n/**\n * \"Fullest\" is a share of the window when both windows are known; a context\n * with a known window outranks one without (its fullness is a fact, the other\n * a size); two unknown windows compare by size.\n */\nfunction fuller(a: NonNullable<SeatEfficiencyRow['fullest']>, b: NonNullable<SeatEfficiencyRow['fullest']>): boolean {\n if (a.window !== null && b.window !== null) return a.tokens / a.window > b.tokens / b.window;\n if (a.window !== null) return true;\n if (b.window !== null) return false;\n return a.tokens > b.tokens;\n}\n\n/**\n * Aggregate every session by seat. Ratios are computed from SUMS, never as a\n * mean of per-session ratios — a two-turn chat must not weigh as much as a\n * two-hundred-turn one. Seats with no sessions are omitted rather than shown\n * as zeros. Sorted by prompt tokens, largest first: that is where efficiency\n * matters most.\n */\nexport function seatEfficiency(sessions: readonly VerseSession[], seats: readonly VerseSeat[]): SeatEfficiencyRow[] {\n const bySeat = new Map<string, VerseSession[]>();\n for (const s of sessions) {\n const list = bySeat.get(s.seatId) ?? [];\n list.push(s);\n bySeat.set(s.seatId, list);\n }\n const rows: SeatEfficiencyRow[] = [];\n for (const [seatId, list] of bySeat) {\n const seat = seats.find((s) => s.id === seatId) ?? null;\n let input = 0;\n let read = 0;\n let write = 0;\n let output = 0;\n let turns = 0;\n let compactions = 0;\n let expansiveSessions = 0;\n let fullest: SeatEfficiencyRow['fullest'] = null;\n for (const s of list) {\n input += s.usage.inputTokens;\n read += s.usage.cacheReadTokens;\n write += s.usage.cacheCreationTokens;\n output += s.usage.outputTokens;\n turns += s.turnCount;\n compactions += s.compactionCount ?? 0;\n // The mode as the meter resolves it (verse-model sessionContextBudget),\n // counted before the empty-reading skip: the mode is a fact about the\n // chat, not about its reading.\n const view = sessionContext(s, seats);\n if (view.mode === 'expansive') expansiveSessions += 1;\n if (view.tokens <= 0) continue;\n const candidate = { sessionId: s.id, title: s.title, tokens: view.tokens, window: view.window, exact: view.exact };\n if (fullest === null || fuller(candidate, fullest)) fullest = candidate;\n }\n rows.push({\n seatId,\n label: seat?.label ?? seatId,\n engine: seat?.engine ?? list[0]!.engine,\n retired: seat === null,\n sessions: list.length,\n turns,\n promptTokens: input + read + write,\n outputTokens: output,\n cacheHitRatio: reportedCacheHitRatio({ inputTokens: input, cacheReadTokens: read, cacheCreationTokens: write }),\n compactions,\n expansiveSessions,\n fullest,\n });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AE,iBAAmB,EAIpC,IAAM,EAAO,EAAe,EAAG,CAAK,EAEpC,GADI,EAAK,OAAS,cAAa,GAAqB,GAChD,EAAK,QAAU,EAAG,SACtB,IAAM,EAAY,CAAE,UAAW,EAAE,GAAI,MAAO,EAAE,MAAO,OAAQ,EAAK,OAAQ,OAAQ,EAAK,OAAQ,MAAO,EAAK,KAAM,GAC7G,IAAY,MAAQ,EAAO,EAAW,CAAO,KAAG,EAAU,EAChE,CACA,EAAK,KAAK,CACR,SACA,MAAO,GAAM,OAAS,EACtB,OAAQ,GAAM,QAAU,EAAK,EAAE,CAAE,OACjC,QAAS,IAAS,KAClB,SAAU,EAAK,OACf,QACA,aAAc,EAAQ,EAAO,EAC7B,aAAc,EACd,cAAe,EAAsB,CAAE,YAAa,EAAO,gBAAiB,EAAM,oBAAqB,CAAM,CAAC,EAC9G,cACA,oBACA,SACF,CAAC,CACH,CACA,OAAO,EAAK,MAAM,EAAG,IAAM,EAAE,aAAe,EAAE,cAAgB,EAAE,MAAM,cAAc,EAAE,KAAK,CAAC,CAC9F"}
|
|
1
|
+
{"version":3,"file":"context-model-CIBmSugV.js","names":[],"sources":["../../../../../../src/web-ui/routes/verse/usage/context-model.ts"],"sourcesContent":["/**\n * routes/verse/usage/context-model.ts — the ONE projection of context facts\n * for every surface that shows a seat: the seat picker's rows, the new-chat\n * dialog's context block, the resources panel's \"This chat\" efficiency block,\n * and the Usage section's per-seat efficiency table.\n *\n * WHY ONE MODULE. Before V3.9 every surface read `seat.contextWindow` (the\n * DEFAULT model's window) or the session's creation-time window, and three of\n * them rendered \"200k\" for a 1M Claude model. The arithmetic now lives in\n * core/verse/context-math.ts, shared with the server; this module is only the\n * wording and the aggregation, so the picker, the dialog and the panel cannot\n * describe one model's budget three different ways.\n *\n * HONESTY RULES this module enforces (docs/VERSE-CONTEXT.md):\n *\n * 1. UNKNOWN IS NOT A NUMBER. A model whose budget is unknown reads \"window\n * unknown\", never a default dressed as a fact. A Verse fallback window is\n * marked \"est.\", and its source says so in words.\n * 2. AN UPPER BOUND IS NOT A MEASUREMENT. Codex's turn total sums every model\n * call; until its rollout is read, occupancy is \"≤ N\", and any statistic\n * built on such a reading carries the same flag.\n * 3. NO CACHE REPORTED IS NOT A 0% HIT RATE. A provider that reported no\n * cache activity at all (Ollama; codex on its very first call) gets \"none\n * reported\", not a 0% that reads \"caching is broken\".\n * 4. NOTHING HERE SPENDS. Every figure is derived from what the server\n * already returned (seats, sessions, the open chat's event log).\n *\n * Pure: no React, no I/O.\n */\nimport {\n CACHE_IDLE_TTL_MS,\n budgetFor,\n cacheHitRatio,\n fitVerdict,\n hasExpansiveMode,\n sessionOverheadTokens,\n} from '../../../../core/verse/context-math.js';\nimport type {\n VerseContextBudget,\n VerseContextFit,\n VerseContextMode,\n VerseEngine,\n VerseEvent,\n VerseFitVerdict,\n VerseModelOption,\n VerseSeat,\n VerseSession,\n VerseUsage,\n VerseWindowSource,\n} from '../../../../core/verse/types.js';\nimport { CODEX_EXPANSIVE_METERING_NOTE, WINDOW_SOURCE_TEXT, modelOptionFor, seatUnavailableReason, sessionContextBudget } from '../verse-model.js';\nimport { formatTokens } from '../verse-store.js';\nimport { formatWholePercent } from '../autonomy/format.js';\n\n// ---------------------------------------------------------------------------\n// Models and modes\n// ---------------------------------------------------------------------------\n\n/**\n * A seat's option for a model id, matching through the alias table (a chat\n * remembered on `claude-opus-5.5` is the catalog's `claude-opus-5-5`). The\n * lookup itself is verse-model's `modelOptionFor`, the one the context meter\n * uses, so the picker and the meter can never resolve one id two ways.\n */\nexport function seatModelOption(seat: VerseSeat | null | undefined, modelId: string): VerseModelOption | null {\n return seat ? modelOptionFor([seat], { seatId: seat.id, model: modelId }) : null;\n}\n\n/** `mode` when this model has a budget for it, else `standard` — never a mode the CLI cannot be told. */\nexport function resolveContextMode(option: VerseModelOption | null | undefined, mode: VerseContextMode): VerseContextMode {\n return mode !== 'standard' && budgetFor(option, mode) !== null ? mode : 'standard';\n}\n\n/** The budget a model runs with in a mode (resolved), or null when even its standard window is unknown. */\nexport function effectiveBudget(option: VerseModelOption | null | undefined, mode: VerseContextMode): VerseContextBudget | null {\n return budgetFor(option, resolveContextMode(option, mode));\n}\n\n/** Why this model cannot be chosen on this seat, or null when it can. The seat's own outage wins. */\nexport function modelUnavailableReason(seat: VerseSeat, option: VerseModelOption): string | null {\n const seatReason = seatUnavailableReason(seat);\n if (seatReason !== null) return seatReason;\n const reason = option.unavailableReason;\n return typeof reason === 'string' && reason.trim().length > 0 ? reason.trim() : null;\n}\n\nexport const CONTEXT_MODE_LABEL: Record<VerseContextMode, string> = {\n standard: 'Standard',\n expansive: 'Expansive',\n};\n\n/** How each seat's CLI is named when its pinned version is shown. */\nexport const ENGINE_CLI_NAME: Record<VerseEngine, string> = {\n claude: 'Claude Code',\n codex: 'Codex CLI',\n grok: 'Grok CLI',\n local: 'Claude Code',\n};\n\n/** \"Claude Code 2.1.257\" — the binary this seat is pinned to; null when unknown (local seats, old servers). */\nexport function seatCliLine(seat: VerseSeat): string | null {\n const version = typeof seat.cliVersion === 'string' ? seat.cliVersion.trim() : '';\n return version.length > 0 ? `${ENGINE_CLI_NAME[seat.engine]} ${version}` : null;\n}\n\n/** The seat's own plain-language context facts (binary skew, catalog not yet fetched, …). */\nexport function seatContextNotes(seat: VerseSeat): string[] {\n return (seat.notes ?? []).filter((n): n is string => typeof n === 'string' && n.trim().length > 0);\n}\n\n// ---------------------------------------------------------------------------\n// Window provenance\n// ---------------------------------------------------------------------------\n\n// Window provenance wording is verse-model's `WINDOW_SOURCE_TEXT` — the\n// meter's tooltip, the picker and the resources panel all read that one table.\n\nexport function isEstimatedWindow(source: VerseWindowSource | null | undefined): boolean {\n return source === 'fallback';\n}\n\n// ---------------------------------------------------------------------------\n// Picker and dialog wording\n// ---------------------------------------------------------------------------\n\n/**\n * The compact per-model phrase a picker row carries: \"1M ctx · compacts ≈367k\".\n * Uses the budget for `mode` when the model has one, and names the mode only\n * when it is not the default, so an ordinary row stays short.\n */\nexport function modelContextPhrase(option: VerseModelOption, mode: VerseContextMode = 'standard'): string {\n const resolved = resolveContextMode(option, mode);\n const budget = budgetFor(option, resolved);\n if (!budget) return 'window unknown';\n const window = `${formatTokens(budget.contextWindow)} ctx${isEstimatedWindow(option.windowSource) ? ' (est.)' : ''}`;\n const compacts = budget.autoCompactAt === null ? '' : ` · compacts ≈${formatTokens(budget.autoCompactAt)}`;\n return `${window}${compacts}${resolved === 'expansive' ? ' (expansive)' : ''}`;\n}\n\n/**\n * The full sentence for a tooltip or the dialog: the window, where each mode\n * compacts, and how the window is known.\n */\nexport function modelContextSentence(option: VerseModelOption): string {\n const standard = budgetFor(option, 'standard');\n const expansive = hasExpansiveMode(option) ? budgetFor(option, 'expansive') : null;\n const parts: string[] = [];\n if (!standard) {\n parts.push('Context window unknown for this model.');\n } else {\n const where = standard.autoCompactAt === null\n ? ''\n : `; compacts at about ${formatTokens(standard.autoCompactAt)}${expansive ? ' in Standard' : ''}`;\n parts.push(`${formatTokens(standard.contextWindow)}-token window${where}.`);\n }\n if (expansive) {\n parts.push(`Expansive runs to about ${formatTokens(expansive.autoCompactAt ?? expansive.contextWindow)} before compacting.`);\n }\n if (option.windowSource) parts.push(`Window ${WINDOW_SOURCE_TEXT[option.windowSource]}.`);\n return parts.join(' ');\n}\n\n/**\n * The metering caveat an Expansive cost sentence must carry for this engine,\n * or null when there is none. The wording is verse-model's\n * CODEX_EXPANSIVE_METERING_NOTE — ONE sentence for the new-chat dialog, the\n * handoff dialog, the in-chat mode menu and the \"Expansive could help\" chip.\n * The ratio those surfaces quote (≈3.2× for a 785k vs 245k codex turn) counts\n * re-sent TOKENS only; GPT-5.6-class requests above 272k reportedly also\n * count about 2× against plan limits (docs/VERSE-CONTEXT.md §2.3, a single\n * secondary source), so the note is worded as reported, never as a measured\n * multiplier. Standard never crosses 272k; Expansive does by design.\n */\nexport function expansiveMeteringNote(engine: VerseEngine | null | undefined): string | null {\n return engine === 'codex' ? CODEX_EXPANSIVE_METERING_NOTE : null;\n}\n\n/**\n * \"A turn at 967k re-sends 2.6× the tokens of one at 367k.\" — the only ratio\n * any Expansive cost sentence quotes, and it is arithmetic on the model's own\n * budgets. Null when either compaction point is unknown. It comes BEFORE the\n * codex metering note, whose \"twice that\" refers to it.\n */\nexport function expansiveRatioSentence(option: VerseModelOption | null | undefined): string | null {\n const standard = budgetFor(option, 'standard');\n const expansive = budgetFor(option, 'expansive');\n const stdCap = standard ? standard.autoCompactAt ?? standard.contextWindow : null;\n const expCap = expansive ? expansive.autoCompactAt ?? expansive.contextWindow : null;\n if (stdCap === null || expCap === null || stdCap <= 0) return null;\n return `A turn at ${formatTokens(expCap)} re-sends ${(expCap / stdCap).toFixed(1)}× the tokens of one at ${formatTokens(stdCap)}.`;\n}\n\n/**\n * What each mode costs, in plain words, for the mode selector. Numbers come\n * from the model's own budgets; the only ratio quoted is arithmetic (every\n * turn re-sends everything held, so a turn at X re-sends X/Y of one at Y) —\n * a token ratio, not a usage multiplier, which is why codex also carries the\n * shared metering caveat.\n */\nexport function contextModeDescription(engine: VerseEngine, option: VerseModelOption, mode: VerseContextMode): string {\n const standard = budgetFor(option, 'standard');\n const expansive = budgetFor(option, 'expansive');\n const stdCap = standard ? standard.autoCompactAt ?? standard.contextWindow : null;\n const expCap = expansive ? expansive.autoCompactAt ?? expansive.contextWindow : null;\n if (mode === 'standard' || expCap === null) {\n if (stdCap === null) return 'The CLI compacts at its own default point for this model.';\n return engine === 'claude'\n ? `Compacts at about ${formatTokens(stdCap)}. Every turn re-sends the whole context, so holding it under this point keeps each turn cheaper and recall sharper.`\n : `Compacts at about ${formatTokens(stdCap)} — the CLI's own default budget for this model.`;\n }\n const ratio = expansiveRatioSentence(option);\n const metering = expansiveMeteringNote(engine);\n return `Runs to about ${formatTokens(expCap)} before compacting — for tightly coupled, cross-cutting work that needs everything in view at once. Each turn re-sends everything held, so a long expansive chat uses noticeably more of your plan per turn.${ratio ? ` ${ratio}` : ''}${metering ? ` ${metering}` : ''}`;\n}\n\n/** Why a model offers no mode choice, for the one line where the selector would be. */\nexport function noModeReason(engine: VerseEngine, option: VerseModelOption): string {\n if (!budgetFor(option, 'standard')) return 'This model’s window is unknown, so Verse cannot offer a larger budget for it.';\n if (engine === 'grok' || engine === 'local') return 'One budget: this CLI compacts at its own fixed point, and Verse cannot raise it per chat.';\n return 'One budget: this model has no larger window to expand into.';\n}\n\n// ---------------------------------------------------------------------------\n// Context fit\n// ---------------------------------------------------------------------------\n\n/** Short form for a picker row, where it sits beside the capacity words. */\nexport const FIT_SHORT: Record<VerseFitVerdict, string> = {\n fits: 'code fits',\n tight: 'code fits, tight',\n expansive: 'code needs expansive',\n split: 'code too big — split',\n};\n\n/** Badge text for the chosen model. */\nexport const FIT_LABEL: Record<VerseFitVerdict, string> = {\n fits: 'Fits',\n tight: 'Tight fit',\n expansive: 'Needs expansive',\n split: 'Split the work',\n};\n\n/** A fit reading that is a FLOOR (a root hit its file or time cap). */\nexport function fitIsFloor(fit: VerseContextFit): boolean {\n return fit.roots.some((r) => r.truncated);\n}\n\n/**\n * The verdict for a model IN THE MODE THE CHAT WOULD RUN IN, or null when its\n * budget is unknown (never guessed).\n *\n * `engine` is the seat's engine: the fixed prompt added to the code is that\n * CLI's estimate (context-math `sessionOverheadTokens` — ≈15k local, ≈25k\n * claude), not one flat figure. With a flat 30k a 64k local seat (compacts\n * ≈32.5k) called anything over ~2.5k tokens of code \"too big — split\". Null\n * falls back to the largest estimate.\n *\n * In Standard this is context-math's `fitVerdict` as is — including\n * \"expansive\", the suggestion that only the bigger budget holds the code. In\n * Expansive the bigger budget IS the budget, so the same thresholds are\n * applied to it: the code fits, fits tightly, or no single context on this\n * model holds it. Without this, a chat already set to Expansive would still be\n * told its code \"fits tightly under ≈367k\" — true of a budget it is not using.\n */\nexport function modelFit(\n tokens: number | null | undefined,\n option: VerseModelOption | null | undefined,\n mode: VerseContextMode,\n engine: VerseEngine | null,\n): VerseFitVerdict | null {\n if (typeof tokens !== 'number' || !Number.isFinite(tokens) || tokens < 0) return null;\n const overhead = sessionOverheadTokens(engine);\n if (resolveContextMode(option, mode) === 'expansive' && option) {\n const expansive = budgetFor(option, 'expansive')!;\n return fitVerdict(tokens, { ...option, contextWindow: expansive.contextWindow, autoCompactAt: expansive.autoCompactAt, expansive: null }, overhead);\n }\n return fitVerdict(tokens, option, overhead);\n}\n\n/**\n * The sentence under the fit badge, for the verdict `modelFit` gave in the\n * chat's mode. In Standard a tight fit also names the Expansive budget when\n * one exists, and \"needs expansive\" says what to do — suggestions only;\n * nothing here switches the mode.\n */\nexport function fitExplanation(input: {\n verdict: VerseFitVerdict;\n tokens: number;\n option: VerseModelOption;\n mode: VerseContextMode;\n floor?: boolean;\n}): string {\n const amount = `${input.floor ? 'at least ' : ''}~${formatTokens(input.tokens)} tokens of tracked code`;\n const inExpansive = resolveContextMode(input.option, input.mode) === 'expansive';\n const standard = budgetFor(input.option, 'standard');\n const expansive = budgetFor(input.option, 'expansive');\n const stdCap = standard ? formatTokens(standard.autoCompactAt ?? standard.contextWindow) : null;\n const expCap = expansive ? formatTokens(expansive.autoCompactAt ?? expansive.contextWindow) : null;\n const cap = inExpansive ? expCap : stdCap;\n const budget = inExpansive ? 'Expansive budget' : 'budget';\n switch (input.verdict) {\n case 'fits':\n return `All ${amount} fits well inside this model's ${budget}${cap ? ` (compacts ≈${cap})` : ''}, with room left for the conversation.`;\n case 'tight': {\n const roomier = !inExpansive && expCap !== null && hasExpansiveMode(input.option)\n ? ` Expansive (≈${expCap}) would hold it with room to spare.`\n : '';\n return `${capitalize(amount)} fits under the ≈${cap ?? '?'} compaction point${inExpansive ? ' of the Expansive budget' : ''}, with little room for the conversation — expect it to compact if the agent reads widely.${roomier}`;\n }\n case 'expansive':\n return `${capitalize(amount)} is more than the Standard budget (≈${stdCap ?? '?'}) holds; only Expansive (≈${expCap ?? '?'}) takes it all. Switch to Expansive, or narrow the folders to the part you are changing.`;\n case 'split':\n return `${capitalize(amount)} is more than any single context on this model holds${expCap ? `, even Expansive (≈${expCap})` : ''}. Split the work: fan it out across several chats, each scoped to one folder or subsystem, or narrow this chat to the part you are changing.`;\n }\n}\n\n/**\n * How the working-set figure is made — shown once, beside the badge. Names the\n * fixed-prompt figure the verdict added, and calls it an estimate: no CLI\n * reports its base prompt before a turn has run.\n */\nexport function fitMethodNote(engine: VerseEngine | null): string {\n const cli = engine ? ` for ${ENGINE_CLI_NAME[engine]}` : '';\n return `Estimated from the size of tracked text files (bytes ÷ 4), plus an estimated ~${formatTokens(sessionOverheadTokens(engine))} of fixed prompt${cli} that every chat starts with. An agent rarely reads everything, so this is a ceiling, not a forecast.`;\n}\n\nfunction capitalize(text: string): string {\n return text.length === 0 ? text : text.charAt(0).toUpperCase() + text.slice(1);\n}\n\n// ---------------------------------------------------------------------------\n// One session's context\n// ---------------------------------------------------------------------------\n\nexport interface SessionContextView {\n tokens: number;\n /** False when `tokens` is an upper bound (codex before its rollout is read). */\n exact: boolean;\n window: number | null;\n autoCompactAt: number | null;\n /** How the window is known; null when nothing says (no window, or a stored one without provenance). */\n source: VerseWindowSource | null;\n mode: VerseContextMode;\n /** The session's model has a real expansive budget on its seat. */\n hasModes: boolean;\n}\n\n/**\n * The window a session is measured against, by the precedence every surface\n * shares — runtime → the seat's CURRENT catalog budget for the model and mode\n * → what the record stored → the seat default. The precedence itself lives in\n * verse-model's `sessionContextBudget` (the context meter reads it too); this\n * only adds whether the model offers a second mode, for the panels here.\n */\nexport function sessionContext(session: VerseSession, seats: readonly VerseSeat[]): SessionContextView {\n const budget = sessionContextBudget(seats, session);\n return {\n tokens: Math.floor(budget.contextTokens),\n exact: budget.exact,\n window: budget.contextWindow,\n autoCompactAt: budget.autoCompactAt,\n source: budget.source,\n mode: budget.mode,\n hasModes: hasExpansiveMode(budget.option),\n };\n}\n\n/**\n * Cache-hit ratio, except when the provider reported no cache activity at all\n * — then null (\"none reported\"), because 0% would claim caching failed when\n * the truth is that nothing was said about it.\n */\nexport function reportedCacheHitRatio(usage: Pick<VerseUsage, 'inputTokens' | 'cacheReadTokens' | 'cacheCreationTokens'>): number | null {\n if (usage.cacheReadTokens <= 0 && usage.cacheCreationTokens <= 0) return null;\n return cacheHitRatio(usage);\n}\n\n/** A 0–1 ratio as a whole percent; a real sliver reads \"<1%\", never \"0%\". */\nexport function formatRatio(ratio: number | null): string {\n if (ratio === null || !Number.isFinite(ratio)) return '—';\n return formatWholePercent(ratio);\n}\n\nexport interface TurnContextStats {\n /** Turns with at least one context reading. */\n turns: number;\n /** Mean of each turn's context (its largest trustworthy reading); null with no turns. */\n average: number | null;\n /** Largest per-turn context seen. */\n peak: number | null;\n /** False when any counted turn had only an upper-bound reading. */\n exact: boolean;\n /** Compactions recorded in the log. */\n compactions: number;\n /** Cache-hit ratio of the most recent turn (see `reportedCacheHitRatio`). */\n lastTurnCacheHit: number | null;\n}\n\n/**\n * Context per turn from the open chat's event log.\n *\n * A turn's context is its LARGEST trustworthy reading: within one turn the\n * prompt only grows, except across a compaction, and the peak is what the\n * turn actually paid for. Exact readings (`context` events, usage frames not\n * flagged as upper bounds) win; a turn whose only reading is codex's turn\n * total contributes that total and flags the statistic as an upper bound —\n * that figure can be many times the real prompt, so it is never mixed in\n * where an exact one exists.\n */\nexport function turnContextStats(events: readonly VerseEvent[]): TurnContextStats {\n const perTurn = new Map<string, { exact: number | null; bound: number | null }>();\n let compactions = 0;\n let lastUsage: VerseUsage | null = null;\n const note = (turnId: string, tokens: number, exact: boolean): void => {\n if (!Number.isFinite(tokens) || tokens < 0) return;\n const entry = perTurn.get(turnId) ?? { exact: null, bound: null };\n if (exact) entry.exact = Math.max(entry.exact ?? 0, tokens);\n else entry.bound = Math.max(entry.bound ?? 0, tokens);\n perTurn.set(turnId, entry);\n };\n for (const event of events) {\n switch (event.type) {\n case 'usage':\n lastUsage = event.usage;\n note(event.turnId, event.usage.contextTokens, event.usage.contextTokensExact !== false);\n break;\n case 'context':\n if (event.turnId !== null) note(event.turnId, event.contextTokens, event.exact);\n break;\n case 'compaction':\n compactions += 1;\n break;\n default:\n break;\n }\n }\n let sum = 0;\n let peak: number | null = null;\n let exact = true;\n let turns = 0;\n for (const entry of perTurn.values()) {\n const value = entry.exact ?? entry.bound;\n if (value === null) continue;\n if (entry.exact === null) exact = false;\n turns += 1;\n sum += value;\n peak = peak === null ? value : Math.max(peak, value);\n }\n return {\n turns,\n average: turns === 0 ? null : Math.round(sum / turns),\n peak,\n exact,\n compactions,\n lastTurnCacheHit: lastUsage === null ? null : reportedCacheHitRatio(lastUsage),\n };\n}\n\nexport interface IdleCacheWarning {\n idleMs: number;\n tokens: number;\n /** A local model: the cost is time, not spend. */\n local: boolean;\n}\n\n/**\n * The next turn of an idle chat re-reads its whole context uncached once the\n * provider's prompt cache has expired (CACHE_IDLE_TTL_MS). Below the fixed\n * prompt every new chat on this engine pays anyway (its estimate) there is\n * nothing worth warning about.\n */\nexport function idleCacheWarning(\n session: Pick<VerseSession, 'status' | 'engine'>,\n tokens: number,\n now: number,\n /**\n * When the chat last TALKED to its provider (`lastTurnActivityAt(events)`),\n * never `session.updatedAt`: a rename or mode switch moves that without\n * warming the provider's cache. Null (no turn yet / log not loaded) → no warning.\n */\n lastActivityAt: string | null,\n): IdleCacheWarning | null {\n if (session.status === 'running' || lastActivityAt === null) return null;\n const last = Date.parse(lastActivityAt);\n if (!Number.isFinite(last)) return null;\n const idleMs = now - last;\n if (idleMs < CACHE_IDLE_TTL_MS || tokens < sessionOverheadTokens(session.engine)) return null;\n return { idleMs, tokens, local: session.engine === 'local' };\n}\n\n// ---------------------------------------------------------------------------\n// Per-seat efficiency across sessions (Usage section)\n// ---------------------------------------------------------------------------\n\nexport interface SeatEfficiencyRow {\n seatId: string;\n label: string;\n engine: VerseEngine;\n /** The seat is no longer in the roster (its sessions remain on disk). */\n retired: boolean;\n sessions: number;\n turns: number;\n /** input + cache read + cache write: every prompt token the seat was sent. */\n promptTokens: number;\n outputTokens: number;\n /** Null when the provider reported no cache activity on any of these sessions. */\n cacheHitRatio: number | null;\n compactions: number;\n expansiveSessions: number;\n /** The fullest context among these sessions right now, as a share of its window. */\n fullest: { sessionId: string; title: string; tokens: number; window: number | null; exact: boolean } | null;\n}\n\n/**\n * \"Fullest\" is a share of the window when both windows are known; a context\n * with a known window outranks one without (its fullness is a fact, the other\n * a size); two unknown windows compare by size.\n */\nfunction fuller(a: NonNullable<SeatEfficiencyRow['fullest']>, b: NonNullable<SeatEfficiencyRow['fullest']>): boolean {\n if (a.window !== null && b.window !== null) return a.tokens / a.window > b.tokens / b.window;\n if (a.window !== null) return true;\n if (b.window !== null) return false;\n return a.tokens > b.tokens;\n}\n\n/**\n * Aggregate every session by seat. Ratios are computed from SUMS, never as a\n * mean of per-session ratios — a two-turn chat must not weigh as much as a\n * two-hundred-turn one. Seats with no sessions are omitted rather than shown\n * as zeros. Sorted by prompt tokens, largest first: that is where efficiency\n * matters most.\n */\nexport function seatEfficiency(sessions: readonly VerseSession[], seats: readonly VerseSeat[]): SeatEfficiencyRow[] {\n const bySeat = new Map<string, VerseSession[]>();\n for (const s of sessions) {\n const list = bySeat.get(s.seatId) ?? [];\n list.push(s);\n bySeat.set(s.seatId, list);\n }\n const rows: SeatEfficiencyRow[] = [];\n for (const [seatId, list] of bySeat) {\n const seat = seats.find((s) => s.id === seatId) ?? null;\n let input = 0;\n let read = 0;\n let write = 0;\n let output = 0;\n let turns = 0;\n let compactions = 0;\n let expansiveSessions = 0;\n let fullest: SeatEfficiencyRow['fullest'] = null;\n for (const s of list) {\n input += s.usage.inputTokens;\n read += s.usage.cacheReadTokens;\n write += s.usage.cacheCreationTokens;\n output += s.usage.outputTokens;\n turns += s.turnCount;\n compactions += s.compactionCount ?? 0;\n // The mode as the meter resolves it (verse-model sessionContextBudget),\n // counted before the empty-reading skip: the mode is a fact about the\n // chat, not about its reading.\n const view = sessionContext(s, seats);\n if (view.mode === 'expansive') expansiveSessions += 1;\n if (view.tokens <= 0) continue;\n const candidate = { sessionId: s.id, title: s.title, tokens: view.tokens, window: view.window, exact: view.exact };\n if (fullest === null || fuller(candidate, fullest)) fullest = candidate;\n }\n rows.push({\n seatId,\n label: seat?.label ?? seatId,\n engine: seat?.engine ?? list[0]!.engine,\n retired: seat === null,\n sessions: list.length,\n turns,\n promptTokens: input + read + write,\n outputTokens: output,\n cacheHitRatio: reportedCacheHitRatio({ inputTokens: input, cacheReadTokens: read, cacheCreationTokens: write }),\n compactions,\n expansiveSessions,\n fullest,\n });\n }\n return rows.sort((a, b) => b.promptTokens - a.promptTokens || a.label.localeCompare(b.label));\n}\n"],"mappings":"oMAgEA,SAAgB,EAAgB,EAAoC,EAA0C,CAC5G,OAAO,EAAO,EAAe,CAAC,CAAI,EAAG,CAAE,OAAQ,EAAK,GAAI,MAAO,CAAQ,CAAC,EAAI,IAC9E,CAGA,SAAgB,EAAmB,EAA6C,EAA0C,CACxH,OAAO,IAAS,YAAc,EAAU,EAAQ,CAAI,IAAM,KAAO,EAAO,UAC1E,CAGA,SAAgB,EAAgB,EAA6C,EAAmD,CAC9H,OAAO,EAAU,EAAQ,EAAmB,EAAQ,CAAI,CAAC,CAC3D,CAGA,SAAgB,EAAuB,EAAiB,EAAyC,CAC/F,IAAM,EAAa,EAAsB,CAAI,EAC7C,GAAI,IAAe,KAAM,OAAO,EAChC,IAAM,EAAS,EAAO,kBACtB,OAAO,OAAO,GAAW,UAAY,EAAO,KAAK,CAAC,CAAC,OAAS,EAAI,EAAO,KAAK,EAAI,IAClF,CAEA,IAAa,EAAuD,CAClE,SAAU,WACV,UAAW,WACb,EAGa,EAA+C,CAC1D,OAAQ,cACR,MAAO,YACP,KAAM,WACN,MAAO,aACT,EAGA,SAAgB,EAAY,EAAgC,CAC1D,IAAM,EAAU,OAAO,EAAK,YAAe,SAAW,EAAK,WAAW,KAAK,EAAI,GAC/E,OAAO,EAAQ,OAAS,EAAI,GAAG,EAAgB,EAAK,QAAQ,GAAG,IAAY,IAC7E,CAGA,SAAgB,EAAiB,EAA2B,CAC1D,OAAQ,EAAK,OAAS,CAAC,E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AAK,KAC/C,EAAQ,EACR,EAAO,EACP,EAAQ,EACR,EAAS,EACT,EAAQ,EACR,EAAc,EACd,EAAoB,EACpB,EAAwC,KAC5C,IAAK,IAAM,KAAK,EAAM,CACpB,GAAS,EAAE,MAAM,YACjB,GAAQ,EAAE,MAAM,gBAChB,GAAS,EAAE,MAAM,oBACjB,GAAU,EAAE,MAAM,aAClB,GAAS,EAAE,UACX,GAAe,EAAE,iBAAmB,EAIpC,IAAM,EAAO,EAAe,EAAG,CAAK,EAEpC,GADI,EAAK,OAAS,cAAa,GAAqB,GAChD,EAAK,QAAU,EAAG,SACtB,IAAM,EAAY,CAAE,UAAW,EAAE,GAAI,MAAO,EAAE,MAAO,OAAQ,EAAK,OAAQ,OAAQ,EAAK,OAAQ,MAAO,EAAK,KAAM,GAC7G,IAAY,MAAQ,EAAO,EAAW,CAAO,KAAG,EAAU,EAChE,CACA,EAAK,KAAK,CACR,SACA,MAAO,GAAM,OAAS,EACtB,OAAQ,GAAM,QAAU,EAAK,EAAE,CAAE,OACjC,QAAS,IAAS,KAClB,SAAU,EAAK,OACf,QACA,aAAc,EAAQ,EAAO,EAC7B,aAAc,EACd,cAAe,EAAsB,CAAE,YAAa,EAAO,gBAAiB,EAAM,oBAAqB,CAAM,CAAC,EAC9G,cACA,oBACA,SACF,CAAC,CACH,CACA,OAAO,EAAK,MAAM,EAAG,IAAM,EAAE,aAAe,EAAE,cAAgB,EAAE,MAAM,cAAc,EAAE,KAAK,CAAC,CAC9F"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{D as e,F as t,M as n,O as r,U as i,W as a,l as o,o as s}from"./global-oEl9Qj8u.js";import{C as c,d as l,n as u,r as d}from"./VerseConsoleApp-DTjDpGCd.js";import{d as f}from"./verse-store-b_Lek_c5.js";import{t as p}from"./format-BkWdOQDL.js";var m=`verse-preferences`,h=`verse-memory:`;async function g(e){try{let t=await e.json();if(typeof t.error==`string`&&t.error)return t.error;if(typeof t.note==`string`&&t.note)return t.note}catch{}return null}async function _(e,t){let i=await fetch(e,{method:`GET`,credentials:`same-origin`,headers:{"x-ashlr-read-client":r()},signal:t});if(i.status===401)throw n(),new s(`Read session expired.`,401,e);if(!i.ok){let t=await g(i);throw new s(`GET ${e} failed (HTTP ${i.status})${t?`: ${p(t)}`:``}.`,i.status,e,t)}return await i.json()}async function v(n,r){let i=e();if(!i)throw new d;let a=await o(n,r,i);return t(),a}function y(e,t){let n=t.toString();return n?`${e}?${n}`:e}async function b(e,t){let n={mode:t},r=await v(c(e,`/context-mode`),n);return f(e,r),i(u),r}async function x(e,t={}){let n={};t.includeLastAssistant===!0&&(n.includeLastAssistant=!0);let r=typeof t.focus==`string`?t.focus.trim().slice(0,500):``;return r&&(n.focus=r),v(c(e,`/handoff-preview`),n)}async function S(e){let{source:t}=e,n={projectPath:t.projectPath,seatId:e.seatId,handoffFromSessionId:t.id},r=(t.extraRoots??[]).filter(e=>typeof e==`string`&&e.length>0&&e!==t.projectPath);r.length>0&&(n.extraRoots=r),e.model&&(n.model=e.model),e.contextMode&&(n.contextMode=e.contextMode);let i=e.title?.trim();i&&(n.title=i);let a=await v(`/api/verse/sessions`,n);return l(),a}function C(e){return _(`/api/verse/preferences`,e)}var w={key:m,fetch:e=>C(e)};async function T(e){let t=await v(`/api/verse/preferences`,e);return i(m),a(h),t}function E(e){let t=new URLSearchParams,n=e.workspaceId?.trim()??``,r=e.projectPath?.trim()??``,i=(e.extraRoots??[]).map(e=>e.trim()).filter(e=>e.length>0);if(n){if(r||i.length>0)throw Error(`Estimate a workspace or a folder set, not both.`);t.set(`workspaceId`,n)}else if(r){t.set(`projectPath`,r);for(let e of i)t.append(`extraRoots`,e)}else throw Error(`Pick a project or a workspace to estimate.`);return y(`/api/verse/context-fit`,t)}function D(e,t){return _(E(e),t)}function O(e,t,n){let r=new URLSearchParams({q:e});return typeof t==`number`&&Number.isFinite(t)&&r.set(`limit`,String(Math.max(1,Math.min(50,Math.floor(t))))),_(y(`/api/verse/search`,r),n)}function k(e){return`${h}${e}`}function A(e,t){return _(y(`/api/verse/memory`,new URLSearchParams({projectPath:e})),t)}function j(e){return{key:k(e),fetch:t=>A(e,t)}}async function M(e,t){let n=await v(`/api/verse/memory`,{projectPath:e,content:t});return i(k(e)),n}export{A as a,T as c,M as d,C as i,w as l,D as n,O as o,x as r,b as s,S as t,j as u};
|
|
2
|
+
//# sourceMappingURL=context-queries-CrPcHWTz.js.map
|