@kaitranntt/ccs 8.2.0 → 8.3.0-dev.1
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/README.md +12 -0
- package/config/base-claude.settings.json +1 -5
- package/dist/api/services/cliproxy-profile-bridge.d.ts.map +1 -1
- package/dist/api/services/cliproxy-profile-bridge.js +6 -0
- package/dist/api/services/cliproxy-profile-bridge.js.map +1 -1
- package/dist/api/services/profile-writer.d.ts.map +1 -1
- package/dist/api/services/profile-writer.js +18 -8
- package/dist/api/services/profile-writer.js.map +1 -1
- package/dist/auth/commands/create-command.d.ts.map +1 -1
- package/dist/auth/commands/create-command.js +11 -0
- package/dist/auth/commands/create-command.js.map +1 -1
- package/dist/cliproxy/accounts/account-safety-cross-lane.d.ts +41 -0
- package/dist/cliproxy/accounts/account-safety-cross-lane.d.ts.map +1 -0
- package/dist/cliproxy/accounts/account-safety-cross-lane.js +177 -0
- package/dist/cliproxy/accounts/account-safety-cross-lane.js.map +1 -0
- package/dist/cliproxy/accounts/account-safety.d.ts +29 -1
- package/dist/cliproxy/accounts/account-safety.d.ts.map +1 -1
- package/dist/cliproxy/accounts/account-safety.js +41 -7
- package/dist/cliproxy/accounts/account-safety.js.map +1 -1
- package/dist/cliproxy/accounts/drain-order.d.ts +277 -0
- package/dist/cliproxy/accounts/drain-order.d.ts.map +1 -0
- package/dist/cliproxy/accounts/drain-order.js +575 -0
- package/dist/cliproxy/accounts/drain-order.js.map +1 -0
- package/dist/cliproxy/accounts/pool-state.d.ts +132 -0
- package/dist/cliproxy/accounts/pool-state.d.ts.map +1 -0
- package/dist/cliproxy/accounts/pool-state.js +201 -0
- package/dist/cliproxy/accounts/pool-state.js.map +1 -0
- package/dist/cliproxy/accounts/registry.d.ts +17 -1
- package/dist/cliproxy/accounts/registry.d.ts.map +1 -1
- package/dist/cliproxy/accounts/registry.js +47 -1
- package/dist/cliproxy/accounts/registry.js.map +1 -1
- package/dist/cliproxy/accounts/types.d.ts +20 -0
- package/dist/cliproxy/accounts/types.d.ts.map +1 -1
- package/dist/cliproxy/auth/oauth-handler.d.ts.map +1 -1
- package/dist/cliproxy/auth/oauth-handler.js +29 -0
- package/dist/cliproxy/auth/oauth-handler.js.map +1 -1
- package/dist/cliproxy/binary/platform-detector.d.ts.map +1 -1
- package/dist/cliproxy/binary/platform-detector.js +34 -1
- package/dist/cliproxy/binary/platform-detector.js.map +1 -1
- package/dist/cliproxy/binary/types.d.ts +3 -0
- package/dist/cliproxy/binary/types.d.ts.map +1 -1
- package/dist/cliproxy/binary/types.js +7 -2
- package/dist/cliproxy/binary/types.js.map +1 -1
- package/dist/cliproxy/binary/version-cache.d.ts.map +1 -1
- package/dist/cliproxy/binary/version-cache.js +4 -0
- package/dist/cliproxy/binary/version-cache.js.map +1 -1
- package/dist/cliproxy/claude-shadow-warning.d.ts +39 -0
- package/dist/cliproxy/claude-shadow-warning.d.ts.map +1 -0
- package/dist/cliproxy/claude-shadow-warning.js +187 -0
- package/dist/cliproxy/claude-shadow-warning.js.map +1 -0
- package/dist/cliproxy/config/base-config-loader.d.ts +6 -5
- package/dist/cliproxy/config/base-config-loader.d.ts.map +1 -1
- package/dist/cliproxy/config/base-config-loader.js +19 -12
- package/dist/cliproxy/config/base-config-loader.js.map +1 -1
- package/dist/cliproxy/config/env-builder.d.ts +3 -0
- package/dist/cliproxy/config/env-builder.d.ts.map +1 -1
- package/dist/cliproxy/config/env-builder.js +158 -20
- package/dist/cliproxy/config/env-builder.js.map +1 -1
- package/dist/cliproxy/config/generator.d.ts +2 -1
- package/dist/cliproxy/config/generator.d.ts.map +1 -1
- package/dist/cliproxy/config/generator.js +66 -9
- package/dist/cliproxy/config/generator.js.map +1 -1
- package/dist/cliproxy/config/thinking-config.d.ts.map +1 -1
- package/dist/cliproxy/config/thinking-config.js +2 -0
- package/dist/cliproxy/config/thinking-config.js.map +1 -1
- package/dist/cliproxy/executor/account-resolution.d.ts.map +1 -1
- package/dist/cliproxy/executor/account-resolution.js +5 -0
- package/dist/cliproxy/executor/account-resolution.js.map +1 -1
- package/dist/cliproxy/executor/auth-coordinator.d.ts +4 -0
- package/dist/cliproxy/executor/auth-coordinator.d.ts.map +1 -1
- package/dist/cliproxy/executor/auth-coordinator.js +5 -1
- package/dist/cliproxy/executor/auth-coordinator.js.map +1 -1
- package/dist/cliproxy/executor/index.d.ts.map +1 -1
- package/dist/cliproxy/executor/index.js +20 -0
- package/dist/cliproxy/executor/index.js.map +1 -1
- package/dist/cliproxy/model-catalog.d.ts.map +1 -1
- package/dist/cliproxy/model-catalog.js +15 -0
- package/dist/cliproxy/model-catalog.js.map +1 -1
- package/dist/cliproxy/proxy/upstream-response-timeout.d.ts.map +1 -1
- package/dist/cliproxy/proxy/upstream-response-timeout.js +8 -1
- package/dist/cliproxy/proxy/upstream-response-timeout.js.map +1 -1
- package/dist/cliproxy/quota/quota-fetcher-claude.d.ts +9 -0
- package/dist/cliproxy/quota/quota-fetcher-claude.d.ts.map +1 -1
- package/dist/cliproxy/quota/quota-fetcher-claude.js +53 -16
- package/dist/cliproxy/quota/quota-fetcher-claude.js.map +1 -1
- package/dist/cliproxy/quota/quota-fetcher.d.ts.map +1 -1
- package/dist/cliproxy/quota/quota-fetcher.js +4 -0
- package/dist/cliproxy/quota/quota-fetcher.js.map +1 -1
- package/dist/cliproxy/quota/quota-manager.d.ts +7 -0
- package/dist/cliproxy/quota/quota-manager.d.ts.map +1 -1
- package/dist/cliproxy/quota/quota-manager.js +51 -2
- package/dist/cliproxy/quota/quota-manager.js.map +1 -1
- package/dist/cliproxy/routing/pool-onboarding-hint.d.ts +95 -0
- package/dist/cliproxy/routing/pool-onboarding-hint.d.ts.map +1 -0
- package/dist/cliproxy/routing/pool-onboarding-hint.js +172 -0
- package/dist/cliproxy/routing/pool-onboarding-hint.js.map +1 -0
- package/dist/cliproxy/routing/pool-opt-in-prompt.d.ts +50 -0
- package/dist/cliproxy/routing/pool-opt-in-prompt.d.ts.map +1 -0
- package/dist/cliproxy/routing/pool-opt-in-prompt.js +232 -0
- package/dist/cliproxy/routing/pool-opt-in-prompt.js.map +1 -0
- package/dist/cliproxy/routing/routing-strategy.d.ts +132 -0
- package/dist/cliproxy/routing/routing-strategy.d.ts.map +1 -1
- package/dist/cliproxy/routing/routing-strategy.js +342 -5
- package/dist/cliproxy/routing/routing-strategy.js.map +1 -1
- package/dist/cliproxy/services/stats-fetcher.d.ts +13 -0
- package/dist/cliproxy/services/stats-fetcher.d.ts.map +1 -1
- package/dist/cliproxy/services/stats-fetcher.js +25 -1
- package/dist/cliproxy/services/stats-fetcher.js.map +1 -1
- package/dist/commands/bar/help-subcommand.d.ts +2 -0
- package/dist/commands/bar/help-subcommand.d.ts.map +1 -0
- package/dist/commands/bar/help-subcommand.js +63 -0
- package/dist/commands/bar/help-subcommand.js.map +1 -0
- package/dist/commands/bar/index.d.ts +8 -0
- package/dist/commands/bar/index.d.ts.map +1 -0
- package/dist/commands/bar/index.js +78 -0
- package/dist/commands/bar/index.js.map +1 -0
- package/dist/commands/bar/install-subcommand.d.ts +92 -0
- package/dist/commands/bar/install-subcommand.d.ts.map +1 -0
- package/dist/commands/bar/install-subcommand.js +605 -0
- package/dist/commands/bar/install-subcommand.js.map +1 -0
- package/dist/commands/bar/launch-subcommand.d.ts +64 -0
- package/dist/commands/bar/launch-subcommand.d.ts.map +1 -0
- package/dist/commands/bar/launch-subcommand.js +236 -0
- package/dist/commands/bar/launch-subcommand.js.map +1 -0
- package/dist/commands/bar/uninstall-subcommand.d.ts +13 -0
- package/dist/commands/bar/uninstall-subcommand.d.ts.map +1 -0
- package/dist/commands/bar/uninstall-subcommand.js +78 -0
- package/dist/commands/bar/uninstall-subcommand.js.map +1 -0
- package/dist/commands/bar/version-subcommand.d.ts +8 -0
- package/dist/commands/bar/version-subcommand.d.ts.map +1 -0
- package/dist/commands/bar/version-subcommand.js +62 -0
- package/dist/commands/bar/version-subcommand.js.map +1 -0
- package/dist/commands/cliproxy/help-subcommand.d.ts.map +1 -1
- package/dist/commands/cliproxy/help-subcommand.js +20 -1
- package/dist/commands/cliproxy/help-subcommand.js.map +1 -1
- package/dist/commands/cliproxy/index.d.ts.map +1 -1
- package/dist/commands/cliproxy/index.js +20 -0
- package/dist/commands/cliproxy/index.js.map +1 -1
- package/dist/commands/cliproxy/order-subcommand.d.ts +16 -0
- package/dist/commands/cliproxy/order-subcommand.d.ts.map +1 -0
- package/dist/commands/cliproxy/order-subcommand.js +520 -0
- package/dist/commands/cliproxy/order-subcommand.js.map +1 -0
- package/dist/commands/cliproxy/pool-state-renderer.d.ts +40 -0
- package/dist/commands/cliproxy/pool-state-renderer.d.ts.map +1 -0
- package/dist/commands/cliproxy/pool-state-renderer.js +220 -0
- package/dist/commands/cliproxy/pool-state-renderer.js.map +1 -0
- package/dist/commands/cliproxy/pool-subcommand.d.ts +10 -0
- package/dist/commands/cliproxy/pool-subcommand.d.ts.map +1 -0
- package/dist/commands/cliproxy/pool-subcommand.js +112 -0
- package/dist/commands/cliproxy/pool-subcommand.js.map +1 -0
- package/dist/commands/cliproxy/quota-subcommand.d.ts.map +1 -1
- package/dist/commands/cliproxy/quota-subcommand.js +7 -0
- package/dist/commands/cliproxy/quota-subcommand.js.map +1 -1
- package/dist/commands/cliproxy/routing-subcommand.d.ts.map +1 -1
- package/dist/commands/cliproxy/routing-subcommand.js +19 -0
- package/dist/commands/cliproxy/routing-subcommand.js.map +1 -1
- package/dist/commands/command-catalog.d.ts.map +1 -1
- package/dist/commands/command-catalog.js +7 -0
- package/dist/commands/command-catalog.js.map +1 -1
- package/dist/commands/help-command.d.ts.map +1 -1
- package/dist/commands/help-command.js +6 -1
- package/dist/commands/help-command.js.map +1 -1
- package/dist/commands/root-command-router.d.ts.map +1 -1
- package/dist/commands/root-command-router.js +7 -0
- package/dist/commands/root-command-router.js.map +1 -1
- package/dist/config/loader/yaml-serializer.d.ts.map +1 -1
- package/dist/config/loader/yaml-serializer.js +13 -0
- package/dist/config/loader/yaml-serializer.js.map +1 -1
- package/dist/config/schemas/cliproxy.d.ts +37 -0
- package/dist/config/schemas/cliproxy.d.ts.map +1 -1
- package/dist/config/schemas/quota.d.ts +26 -2
- package/dist/config/schemas/quota.d.ts.map +1 -1
- package/dist/config/schemas/quota.js +20 -1
- package/dist/config/schemas/quota.js.map +1 -1
- package/dist/config/unified-config-loader.d.ts.map +1 -1
- package/dist/config/unified-config-loader.js +3 -0
- package/dist/config/unified-config-loader.js.map +1 -1
- package/dist/dispatcher/flows/account-flow.d.ts.map +1 -1
- package/dist/dispatcher/flows/account-flow.js +9 -0
- package/dist/dispatcher/flows/account-flow.js.map +1 -1
- package/dist/glmt/delta-accumulator.d.ts.map +1 -1
- package/dist/glmt/delta-accumulator.js +1 -0
- package/dist/glmt/delta-accumulator.js.map +1 -1
- package/dist/management/doctor.d.ts.map +1 -1
- package/dist/management/doctor.js +10 -0
- package/dist/management/doctor.js.map +1 -1
- package/dist/proxy/profile-router.d.ts +14 -0
- package/dist/proxy/profile-router.d.ts.map +1 -1
- package/dist/proxy/profile-router.js +1 -0
- package/dist/proxy/profile-router.js.map +1 -1
- package/dist/proxy/server/http-helpers.d.ts +5 -0
- package/dist/proxy/server/http-helpers.d.ts.map +1 -1
- package/dist/proxy/server/http-helpers.js +40 -1
- package/dist/proxy/server/http-helpers.js.map +1 -1
- package/dist/proxy/server/messages-route.d.ts.map +1 -1
- package/dist/proxy/server/messages-route.js +173 -10
- package/dist/proxy/server/messages-route.js.map +1 -1
- package/dist/proxy/upstream-url.d.ts +42 -2
- package/dist/proxy/upstream-url.d.ts.map +1 -1
- package/dist/proxy/upstream-url.js +83 -4
- package/dist/proxy/upstream-url.js.map +1 -1
- package/dist/ui/assets/{Trans-DsGR5Bhb.js → Trans-RG_sMDEu.js} +1 -1
- package/dist/ui/assets/accounts-yTXURc-q.js +1 -0
- package/dist/ui/assets/{alert-dialog-Do0XfN46.js → alert-dialog-DjvPgzFs.js} +1 -1
- package/dist/ui/assets/{api-B7OYas_V.js → api-Ck1dtNEM.js} +3 -3
- package/dist/ui/assets/{auth-section-BmTeNetL.js → auth-section-DBnY_LPz.js} +1 -1
- package/dist/ui/assets/{backups-section-COawLfTr.js → backups-section-Ci-uL4Of.js} +1 -1
- package/dist/ui/assets/{channels-C9LVYmNJ.js → channels-BeS9O5q0.js} +1 -1
- package/dist/ui/assets/{checkbox-BkFzg8C-.js → checkbox-DFeFDZBp.js} +1 -1
- package/dist/ui/assets/{claude-extension-Ch7L4lTF.js → claude-extension-DS5qN19Z.js} +1 -1
- package/dist/ui/assets/{cliproxy-B3uWt6gn.js → cliproxy-D7HJH4mZ.js} +1 -1
- package/dist/ui/assets/{cliproxy-ai-providers-Bn1_AdKD.js → cliproxy-ai-providers-oJQZXrtc.js} +1 -1
- package/dist/ui/assets/{cliproxy-control-panel-DC4pOOfY.js → cliproxy-control-panel-2mRPEcRj.js} +1 -1
- package/dist/ui/assets/codex-D0AUQ6jA.js +30 -0
- package/dist/ui/assets/{confirm-dialog-4rb-E8-R.js → confirm-dialog-B37-CVuq.js} +1 -1
- package/dist/ui/assets/{copilot-zgPXNkMw.js → copilot-KaaW-mko.js} +2 -2
- package/dist/ui/assets/{cursor-lRPpppk-.js → cursor-BKiTgYi5.js} +1 -1
- package/dist/ui/assets/{droid-koOj34SB.js → droid-DHdqGnFw.js} +2 -2
- package/dist/ui/assets/{globalenv-section-jOkPVwvN.js → globalenv-section-SfZO97nU.js} +1 -1
- package/dist/ui/assets/health-CSRS9O0D.js +1 -0
- package/dist/ui/assets/icons-DSLG1YsC.js +1 -0
- package/dist/ui/assets/{index-D7crOfea.js → index-CGgavq2X.js} +37 -37
- package/dist/ui/assets/{index-BLC5PyZn.js → index-ChTYEBCZ.js} +1 -1
- package/dist/ui/assets/index-Cu_F55_O.js +1 -0
- package/dist/ui/assets/{index-CRhKyfnS.js → index-DJ66NrBH.js} +1 -1
- package/dist/ui/assets/index-DWUuSBUe.js +1 -0
- package/dist/ui/assets/{index-BK-PSsqi.js → index-DycwEe96.js} +1 -1
- package/dist/ui/assets/index-DzFlVVV3.css +1 -0
- package/dist/ui/assets/{index-De3yNJ94.js → index-iQuEEGbH.js} +1 -1
- package/dist/ui/assets/{logs-BplpQHRb.js → logs-tiZ_51mo.js} +1 -1
- package/dist/ui/assets/{masked-input-DuLL3EwS.js → masked-input-D9FVoeMA.js} +1 -1
- package/dist/ui/assets/proxy-status-widget-2k26d8pS.js +1 -0
- package/dist/ui/assets/{raw-json-settings-editor-panel-ClPqZ6iZ.js → raw-json-settings-editor-panel-CguBh93H.js} +1 -1
- package/dist/ui/assets/{searchable-select-BH1b065u.js → searchable-select-C4wShshD.js} +1 -1
- package/dist/ui/assets/{separator-BOiJ0l4s.js → separator-mvGlDdEW.js} +1 -1
- package/dist/ui/assets/{shared-CunXigZu.js → shared-Ck0yAwbs.js} +1 -1
- package/dist/ui/assets/{table-C7ysR1Xz.js → table-DrUJOxKL.js} +1 -1
- package/dist/ui/assets/updates-BVHBFcq8.js +1 -0
- package/dist/ui/assets/{use-accounts-CwRU3ln9.js → use-accounts-DLtuaniS.js} +1 -1
- package/dist/ui/index.html +3 -3
- package/dist/utils/browser/mcp-installer.d.ts.map +1 -1
- package/dist/utils/browser/mcp-installer.js +5 -34
- package/dist/utils/browser/mcp-installer.js.map +1 -1
- package/dist/utils/claude-user-config-lock.d.ts +9 -0
- package/dist/utils/claude-user-config-lock.d.ts.map +1 -0
- package/dist/utils/claude-user-config-lock.js +96 -0
- package/dist/utils/claude-user-config-lock.js.map +1 -0
- package/dist/utils/image-analysis/mcp-installer.d.ts.map +1 -1
- package/dist/utils/image-analysis/mcp-installer.js +5 -34
- package/dist/utils/image-analysis/mcp-installer.js.map +1 -1
- package/dist/utils/websearch/mcp-installer.d.ts.map +1 -1
- package/dist/utils/websearch/mcp-installer.js +112 -78
- package/dist/utils/websearch/mcp-installer.js.map +1 -1
- package/dist/web-server/model-pricing.d.ts.map +1 -1
- package/dist/web-server/model-pricing.js +7 -0
- package/dist/web-server/model-pricing.js.map +1 -1
- package/dist/web-server/routes/account-routes.d.ts.map +1 -1
- package/dist/web-server/routes/account-routes.js +116 -0
- package/dist/web-server/routes/account-routes.js.map +1 -1
- package/dist/web-server/routes/bar-routes.d.ts +149 -0
- package/dist/web-server/routes/bar-routes.d.ts.map +1 -0
- package/dist/web-server/routes/bar-routes.js +415 -0
- package/dist/web-server/routes/bar-routes.js.map +1 -0
- package/dist/web-server/routes/index.d.ts.map +1 -1
- package/dist/web-server/routes/index.js +18 -0
- package/dist/web-server/routes/index.js.map +1 -1
- package/dist/web-server/usage/bar-analytics.d.ts +101 -0
- package/dist/web-server/usage/bar-analytics.d.ts.map +1 -0
- package/dist/web-server/usage/bar-analytics.js +315 -0
- package/dist/web-server/usage/bar-analytics.js.map +1 -0
- package/dist/web-server/usage/claude-native-credentials.d.ts +56 -0
- package/dist/web-server/usage/claude-native-credentials.d.ts.map +1 -0
- package/dist/web-server/usage/claude-native-credentials.js +140 -0
- package/dist/web-server/usage/claude-native-credentials.js.map +1 -0
- package/dist/web-server/usage/cliproxy-snapshot-reader.d.ts +24 -0
- package/dist/web-server/usage/cliproxy-snapshot-reader.d.ts.map +1 -0
- package/dist/web-server/usage/cliproxy-snapshot-reader.js +82 -0
- package/dist/web-server/usage/cliproxy-snapshot-reader.js.map +1 -0
- package/dist/web-server/usage/cliproxy-usage-syncer.d.ts +3 -2
- package/dist/web-server/usage/cliproxy-usage-syncer.d.ts.map +1 -1
- package/dist/web-server/usage/cliproxy-usage-syncer.js +14 -2
- package/dist/web-server/usage/cliproxy-usage-syncer.js.map +1 -1
- package/dist/web-server/usage/cliproxy-usage-transformer.d.ts +8 -1
- package/dist/web-server/usage/cliproxy-usage-transformer.d.ts.map +1 -1
- package/dist/web-server/usage/cliproxy-usage-transformer.js +31 -4
- package/dist/web-server/usage/cliproxy-usage-transformer.js.map +1 -1
- package/dist/web-server/usage/codex-local-quota-collector.d.ts +74 -0
- package/dist/web-server/usage/codex-local-quota-collector.d.ts.map +1 -0
- package/dist/web-server/usage/codex-local-quota-collector.js +250 -0
- package/dist/web-server/usage/codex-local-quota-collector.js.map +1 -0
- package/dist/web-server/usage/data-aggregator.d.ts +11 -0
- package/dist/web-server/usage/data-aggregator.d.ts.map +1 -1
- package/dist/web-server/usage/data-aggregator.js +29 -1
- package/dist/web-server/usage/data-aggregator.js.map +1 -1
- package/dist/web-server/usage/native-quota-collector.d.ts +44 -0
- package/dist/web-server/usage/native-quota-collector.d.ts.map +1 -0
- package/dist/web-server/usage/native-quota-collector.js +378 -0
- package/dist/web-server/usage/native-quota-collector.js.map +1 -0
- package/dist/web-server/usage/types.d.ts +2 -0
- package/dist/web-server/usage/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/scripts/run-test-bucket.js +183 -17
- package/dist/ui/assets/accounts-DHBmHeH-.js +0 -1
- package/dist/ui/assets/codex-CcODhykP.js +0 -30
- package/dist/ui/assets/health-CxHauE3Y.js +0 -1
- package/dist/ui/assets/icons-DzKUh8vG.js +0 -1
- package/dist/ui/assets/index-DOfPoKe_.css +0 -1
- package/dist/ui/assets/index-DUGnoURR.js +0 -1
- package/dist/ui/assets/index-I_ek1xyD.js +0 -1
- package/dist/ui/assets/proxy-status-widget-BruRPTSl.js +0 -1
- package/dist/ui/assets/updates-BtBCV2xk.js +0 -1
|
@@ -0,0 +1,415 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Bar Routes — /api/bar/summary aggregator
|
|
4
|
+
*
|
|
5
|
+
* One GET returns the full glance array for CCS Bar (macOS MenuBarExtra).
|
|
6
|
+
* Supports cached (instant) and ?refresh=true (live provider pull) modes.
|
|
7
|
+
*
|
|
8
|
+
* Design:
|
|
9
|
+
* - Calls data sources DIRECTLY (not via HTTP routes) so rate-limiters are irrelevant.
|
|
10
|
+
* - Force-fresh = invalidate quota-response-cache then call the fetcher server-side.
|
|
11
|
+
* - Debounce: if a fresh pull happened < 15s ago, serve cache even when refresh=true.
|
|
12
|
+
* - Per-account failure degrades THAT row (null fields + needsReauth/health:error);
|
|
13
|
+
* other rows are unaffected — the payload always returns HTTP 200.
|
|
14
|
+
* - today_cost sourced from getTodayCostByAccount() (Phase 1A output).
|
|
15
|
+
* - health derived from runHealthChecks() summary (overall, not per-account for v1).
|
|
16
|
+
*/
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.createBarRouter = exports.resetForceFreshDebounce = void 0;
|
|
19
|
+
const express_1 = require("express");
|
|
20
|
+
const bar_analytics_1 = require("../usage/bar-analytics");
|
|
21
|
+
// ============================================================================
|
|
22
|
+
// Timing budgets (module-level; the bar must NEVER block on a slow provider)
|
|
23
|
+
// ============================================================================
|
|
24
|
+
/** Debounce window: skip force-fresh if last fresh pull was < 15s ago */
|
|
25
|
+
const FORCE_FRESH_DEBOUNCE_MS = 15000;
|
|
26
|
+
/** Hard ceiling for the whole /summary response. Past this we paint from cache. */
|
|
27
|
+
const REQUEST_DEADLINE_MS = 2500;
|
|
28
|
+
/** Per-account synchronous wait before falling back to stale cache (bg fetch continues). */
|
|
29
|
+
const PER_ACCOUNT_TIMEOUT_MS = 5000;
|
|
30
|
+
/** Bound for the cost side-load so a slow snapshot read can't dominate the response. */
|
|
31
|
+
const SIDELOAD_TIMEOUT_MS = 1500;
|
|
32
|
+
/**
|
|
33
|
+
* Bound for the native-subscription side-load. A slow or failed native fetch
|
|
34
|
+
* resolves to [] so the response paints CLIProxy rows only — never errors, never
|
|
35
|
+
* blocks. Native rows have their own 10-min cache, so the common path is instant.
|
|
36
|
+
*/
|
|
37
|
+
const NATIVE_SIDELOAD_TIMEOUT_MS = 1500;
|
|
38
|
+
/** Timestamp of the last successful force-fresh pull (epoch ms, 0 = never) */
|
|
39
|
+
let lastForceFreshAt = 0;
|
|
40
|
+
/** Reset module state — called in tests to prevent cross-test pollution */
|
|
41
|
+
function resetForceFreshDebounce() {
|
|
42
|
+
lastForceFreshAt = 0;
|
|
43
|
+
}
|
|
44
|
+
exports.resetForceFreshDebounce = resetForceFreshDebounce;
|
|
45
|
+
/**
|
|
46
|
+
* Resolve a promise to its value, or to null if it doesn't settle within `ms`.
|
|
47
|
+
* The underlying promise keeps running (used to let a slow fetch warm the cache
|
|
48
|
+
* for the next open while the current response degrades gracefully).
|
|
49
|
+
*/
|
|
50
|
+
function withTimeout(p, ms) {
|
|
51
|
+
return new Promise((resolve) => {
|
|
52
|
+
let settled = false;
|
|
53
|
+
const timer = setTimeout(() => {
|
|
54
|
+
if (!settled) {
|
|
55
|
+
settled = true;
|
|
56
|
+
resolve(null);
|
|
57
|
+
}
|
|
58
|
+
}, ms);
|
|
59
|
+
p.then((v) => {
|
|
60
|
+
if (!settled) {
|
|
61
|
+
settled = true;
|
|
62
|
+
clearTimeout(timer);
|
|
63
|
+
resolve(v);
|
|
64
|
+
}
|
|
65
|
+
}, () => {
|
|
66
|
+
if (!settled) {
|
|
67
|
+
settled = true;
|
|
68
|
+
clearTimeout(timer);
|
|
69
|
+
resolve(null);
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Map a row to its wire shape. The native-only additions use snake_case parent
|
|
76
|
+
* keys ("quota_windows" / "stale_as_of") to match the existing payload's mixed
|
|
77
|
+
* casing; inner QuotaWindowDetail keys stay camelCase and pass through as-is.
|
|
78
|
+
* Rows without the native fields serialize byte-identically to before, so
|
|
79
|
+
* CLIProxy decode/encode tests are unaffected.
|
|
80
|
+
*/
|
|
81
|
+
function serializeBarRow(row) {
|
|
82
|
+
const { quotaWindows, staleAsOf, ...rest } = row;
|
|
83
|
+
const wire = { ...rest };
|
|
84
|
+
if (quotaWindows !== undefined)
|
|
85
|
+
wire.quota_windows = quotaWindows;
|
|
86
|
+
if (staleAsOf !== undefined && staleAsOf !== null)
|
|
87
|
+
wire.stale_as_of = staleAsOf;
|
|
88
|
+
return wire;
|
|
89
|
+
}
|
|
90
|
+
// ============================================================================
|
|
91
|
+
// Per-account health derivation
|
|
92
|
+
// ============================================================================
|
|
93
|
+
/**
|
|
94
|
+
* Tri-state quota availability derived from the QuotaResult.
|
|
95
|
+
*
|
|
96
|
+
* We branch ONLY on the result's stable errorCode, never on a provider
|
|
97
|
+
* registry: ghcp is listed in MANAGED_QUOTA_PROVIDERS, yet fetchAccountQuota
|
|
98
|
+
* returns unsupported for every provider !== 'agy'. The result's
|
|
99
|
+
* 'quota_not_supported' code is the only honest signal that a provider has no
|
|
100
|
+
* quota API, so we use it here.
|
|
101
|
+
*
|
|
102
|
+
* success → 'ok'
|
|
103
|
+
* errorCode 'quota_not_supported' → 'unsupported' (no quota API; healthy)
|
|
104
|
+
* anything else (null/timeout/reauth/other failure) → 'error'
|
|
105
|
+
*/
|
|
106
|
+
function deriveQuotaStatus(quota) {
|
|
107
|
+
if (quota?.success === true)
|
|
108
|
+
return 'ok';
|
|
109
|
+
if (quota && quota.errorCode === 'quota_not_supported')
|
|
110
|
+
return 'unsupported';
|
|
111
|
+
return 'error';
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Health for a single account, derived from its own quota-fetch result.
|
|
115
|
+
*
|
|
116
|
+
* The menu bar is a per-account glance, so health is per-row — NOT the global
|
|
117
|
+
* system audit. (The system audit is also unsafe here: it shells out via a
|
|
118
|
+
* synchronous execSync that would block the event loop on the request path.)
|
|
119
|
+
*
|
|
120
|
+
* A provider with no quota API (quotaStatus 'unsupported', e.g. ghcp/kiro) is
|
|
121
|
+
* healthy — it must not show a permanent warning dot. 'warning' is reserved for
|
|
122
|
+
* genuine transient fetch failures, 'error' for accounts needing reauth.
|
|
123
|
+
*
|
|
124
|
+
* needsReauth → 'error' (token expired; user action required)
|
|
125
|
+
* quota unsupported → 'ok' (no quota API is not a fault)
|
|
126
|
+
* fetch failed → 'warning' (transient/unknown; row degrades but isn't fatal)
|
|
127
|
+
* success → 'ok'
|
|
128
|
+
*/
|
|
129
|
+
function deriveHealth(quota, quotaStatus) {
|
|
130
|
+
if (quota?.needsReauth)
|
|
131
|
+
return 'error';
|
|
132
|
+
if (quotaStatus === 'unsupported')
|
|
133
|
+
return 'ok';
|
|
134
|
+
if (!quota || !quota.success)
|
|
135
|
+
return 'warning';
|
|
136
|
+
return 'ok';
|
|
137
|
+
}
|
|
138
|
+
// ============================================================================
|
|
139
|
+
// Quota → bar row mapping
|
|
140
|
+
// ============================================================================
|
|
141
|
+
/**
|
|
142
|
+
* Extract the primary quota percentage from a QuotaResult.
|
|
143
|
+
* For Antigravity accounts: use the first model's percentage.
|
|
144
|
+
* Returns null on failure or missing data.
|
|
145
|
+
*/
|
|
146
|
+
function extractQuotaPercentage(quota) {
|
|
147
|
+
if (!quota.success || quota.models.length === 0)
|
|
148
|
+
return null;
|
|
149
|
+
// Use the first model (highest weight) as the representative percentage
|
|
150
|
+
return quota.models[0].percentage ?? null;
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Extract the next reset timestamp from a QuotaResult.
|
|
154
|
+
* Returns null if not available.
|
|
155
|
+
*/
|
|
156
|
+
function extractNextReset(quota) {
|
|
157
|
+
if (!quota.success || quota.models.length === 0)
|
|
158
|
+
return null;
|
|
159
|
+
return quota.models[0].resetTime ?? null;
|
|
160
|
+
}
|
|
161
|
+
async function fetchAccountData(account, forceRefresh, deps) {
|
|
162
|
+
const provider = account.provider;
|
|
163
|
+
const accountId = account.id;
|
|
164
|
+
const now = new Date().toISOString();
|
|
165
|
+
// Read any prior cache up front so it survives as a stale fallback even when a
|
|
166
|
+
// refresh fetch is slow or fails (stale-while-revalidate).
|
|
167
|
+
const cached = deps.getCachedQuota(provider, accountId);
|
|
168
|
+
// Paused accounts: serve cache if present, otherwise degrade.
|
|
169
|
+
// Never trigger a live fetch for a user-paused account.
|
|
170
|
+
if (account.paused === true) {
|
|
171
|
+
return { quota: cached ?? null, cached: cached !== null, fetchedAt: now };
|
|
172
|
+
}
|
|
173
|
+
// Default mode serves a present cache instantly (no provider call).
|
|
174
|
+
if (!forceRefresh && cached) {
|
|
175
|
+
return { quota: cached, cached: true, fetchedAt: now };
|
|
176
|
+
}
|
|
177
|
+
// Force-fresh busts the route cache first (the stale value captured above
|
|
178
|
+
// still backs the fallback below).
|
|
179
|
+
if (forceRefresh) {
|
|
180
|
+
deps.invalidateQuotaCache(provider, accountId);
|
|
181
|
+
}
|
|
182
|
+
// Live fetch (force-refresh, or default-mode cache miss). It overwrites the
|
|
183
|
+
// cache on success and is bounded by PER_ACCOUNT_TIMEOUT_MS; if it overruns,
|
|
184
|
+
// the fetch keeps running (warming the cache for the next open) while this row
|
|
185
|
+
// degrades to the stale value so the payload never blocks.
|
|
186
|
+
const live = deps.fetchAccountQuota(provider, accountId).then((quota) => {
|
|
187
|
+
deps.setCachedQuota(provider, accountId, quota);
|
|
188
|
+
return quota;
|
|
189
|
+
});
|
|
190
|
+
const fresh = await withTimeout(live, PER_ACCOUNT_TIMEOUT_MS);
|
|
191
|
+
if (fresh)
|
|
192
|
+
return { quota: fresh, cached: false, fetchedAt: now };
|
|
193
|
+
return { quota: cached ?? null, cached: cached !== null, fetchedAt: now };
|
|
194
|
+
}
|
|
195
|
+
// ============================================================================
|
|
196
|
+
// Row builder
|
|
197
|
+
// ============================================================================
|
|
198
|
+
/**
|
|
199
|
+
* Resolve the cost-lookup key for an account.
|
|
200
|
+
*
|
|
201
|
+
* The attribution pipeline (buildAuthIndexToAccountMap) stores email as the
|
|
202
|
+
* map value, so costByAccount keys are emails. For providers where
|
|
203
|
+
* account.id == email (agy, gemini, anthropic, etc.) this is a no-op.
|
|
204
|
+
* For duplicate-email providers like codex, account.id may be "email#variant",
|
|
205
|
+
* so we prefer account.email for the lookup to ensure the keys match.
|
|
206
|
+
* Falls back to account.id when email is absent (e.g. kiro/ghcp).
|
|
207
|
+
*/
|
|
208
|
+
function resolveCostKey(account) {
|
|
209
|
+
return account.email ?? account.id;
|
|
210
|
+
}
|
|
211
|
+
function buildRow(account, fetchResult, costByAccount,
|
|
212
|
+
/** Set of cost-keys that are shared by more than one account. Cost is unknowable for these. */
|
|
213
|
+
sharedCostKeys) {
|
|
214
|
+
const { quota, cached, fetchedAt } = fetchResult;
|
|
215
|
+
const costKey = resolveCostKey(account);
|
|
216
|
+
const quotaStatus = deriveQuotaStatus(quota);
|
|
217
|
+
const health = deriveHealth(quota, quotaStatus);
|
|
218
|
+
const isDefault = account.isDefault ?? false;
|
|
219
|
+
const lastActivityAt = account.lastUsedAt ?? null;
|
|
220
|
+
// When multiple accounts share the same cost-key (e.g. two codex accounts with
|
|
221
|
+
// the same email), we cannot attribute the combined cost to either individual
|
|
222
|
+
// account, so it is null=unknowable. A missing key on a single-owner account is
|
|
223
|
+
// ALSO null=unknown (no usage record on a possibly-stale snapshot), distinct from
|
|
224
|
+
// a genuine 0 spend — the UI renders "no data" vs "$0.00" honestly.
|
|
225
|
+
const todayCost = sharedCostKeys.has(costKey) ? null : (costByAccount[costKey] ?? null);
|
|
226
|
+
if (!quota || !quota.success) {
|
|
227
|
+
// Degraded row: preserve identity fields, null out quota data
|
|
228
|
+
return {
|
|
229
|
+
account_id: account.id,
|
|
230
|
+
provider: account.provider,
|
|
231
|
+
displayName: account.nickname ?? account.id,
|
|
232
|
+
tier: account.tier ?? null,
|
|
233
|
+
paused: account.paused ?? false,
|
|
234
|
+
quota_percentage: null,
|
|
235
|
+
quotaStatus,
|
|
236
|
+
next_reset: null,
|
|
237
|
+
is_default: isDefault,
|
|
238
|
+
last_activity_at: lastActivityAt,
|
|
239
|
+
today_cost: todayCost,
|
|
240
|
+
health,
|
|
241
|
+
cached,
|
|
242
|
+
fetchedAt,
|
|
243
|
+
needsReauth: quota?.needsReauth ?? false,
|
|
244
|
+
};
|
|
245
|
+
}
|
|
246
|
+
return {
|
|
247
|
+
account_id: account.id,
|
|
248
|
+
provider: account.provider,
|
|
249
|
+
displayName: account.nickname ?? account.id,
|
|
250
|
+
tier: quota.tier ?? account.tier ?? null,
|
|
251
|
+
paused: account.paused ?? false,
|
|
252
|
+
quota_percentage: extractQuotaPercentage(quota),
|
|
253
|
+
quotaStatus,
|
|
254
|
+
next_reset: extractNextReset(quota),
|
|
255
|
+
is_default: isDefault,
|
|
256
|
+
last_activity_at: lastActivityAt,
|
|
257
|
+
today_cost: todayCost,
|
|
258
|
+
health,
|
|
259
|
+
cached,
|
|
260
|
+
fetchedAt,
|
|
261
|
+
needsReauth: quota.needsReauth ?? false,
|
|
262
|
+
};
|
|
263
|
+
}
|
|
264
|
+
// ============================================================================
|
|
265
|
+
// Router factory
|
|
266
|
+
// ============================================================================
|
|
267
|
+
/**
|
|
268
|
+
* Create the bar router with injected dependencies.
|
|
269
|
+
*
|
|
270
|
+
* Production usage: call without arguments (defaults resolve from real modules).
|
|
271
|
+
* Test usage: pass mock implementations for each dep.
|
|
272
|
+
*/
|
|
273
|
+
function createBarRouter(deps) {
|
|
274
|
+
const router = (0, express_1.Router)();
|
|
275
|
+
/**
|
|
276
|
+
* GET /summary[?refresh=true]
|
|
277
|
+
*
|
|
278
|
+
* Returns the menu-bar glance array for all CLIProxy accounts.
|
|
279
|
+
*
|
|
280
|
+
* Query params:
|
|
281
|
+
* refresh=true — force-fresh from provider (debounced to once per 15s)
|
|
282
|
+
*/
|
|
283
|
+
router.get('/summary', async (req, res) => {
|
|
284
|
+
try {
|
|
285
|
+
const wantsRefresh = req.query['refresh'] === 'true';
|
|
286
|
+
// Determine effective refresh mode after applying debounce.
|
|
287
|
+
// IMPORTANT: set lastForceFreshAt at decision time (before awaiting any
|
|
288
|
+
// fetches) to prevent a read-modify-write race where two concurrent
|
|
289
|
+
// refresh=true requests both pass the debounce check before either
|
|
290
|
+
// records the timestamp.
|
|
291
|
+
let doForceRefresh = false;
|
|
292
|
+
if (wantsRefresh) {
|
|
293
|
+
const sinceLastFresh = Date.now() - lastForceFreshAt;
|
|
294
|
+
if (sinceLastFresh >= FORCE_FRESH_DEBOUNCE_MS) {
|
|
295
|
+
doForceRefresh = true;
|
|
296
|
+
lastForceFreshAt = Date.now(); // claim the window before any async work
|
|
297
|
+
}
|
|
298
|
+
// else: debounce active — fall through to cache path
|
|
299
|
+
}
|
|
300
|
+
// Cost side-load is bounded so a slow usage-snapshot read can't stall the
|
|
301
|
+
// glance. (Health is per-account, derived from each quota result below —
|
|
302
|
+
// no blocking system audit on the request path.)
|
|
303
|
+
const details = await withTimeout(deps.loadCliproxyDetails(), SIDELOAD_TIMEOUT_MS);
|
|
304
|
+
const costByAccount = details
|
|
305
|
+
? deps.getTodayCostByAccount(details)
|
|
306
|
+
: {};
|
|
307
|
+
// Flatten all accounts across providers
|
|
308
|
+
const summary = deps.getAllAccountsSummary();
|
|
309
|
+
const allAccounts = Object.values(summary).flat();
|
|
310
|
+
// Fix #11: compute which cost-keys are shared by >1 account so buildRow can
|
|
311
|
+
// report null (unknowable) rather than the combined total for those rows.
|
|
312
|
+
const costKeyCount = new Map();
|
|
313
|
+
for (const account of allAccounts) {
|
|
314
|
+
const key = resolveCostKey(account);
|
|
315
|
+
costKeyCount.set(key, (costKeyCount.get(key) ?? 0) + 1);
|
|
316
|
+
}
|
|
317
|
+
const sharedCostKeys = new Set(Array.from(costKeyCount.entries())
|
|
318
|
+
.filter(([, count]) => count > 1)
|
|
319
|
+
.map(([key]) => key));
|
|
320
|
+
// Build every row synchronously from whatever is in cache right now. This
|
|
321
|
+
// is the instant-paint fallback and the source of truth when the deadline
|
|
322
|
+
// fires before live fetches finish.
|
|
323
|
+
const cacheRows = () => {
|
|
324
|
+
const at = new Date().toISOString();
|
|
325
|
+
return allAccounts.map((account) => {
|
|
326
|
+
const cached = deps.getCachedQuota(account.provider, account.id);
|
|
327
|
+
return buildRow(account, { quota: cached ?? null, cached: cached !== null, fetchedAt: at }, costByAccount, sharedCostKeys);
|
|
328
|
+
});
|
|
329
|
+
};
|
|
330
|
+
// Fetch quota in parallel with per-account error isolation. Each row is
|
|
331
|
+
// bounded inside fetchAccountData; the whole gather is additionally raced
|
|
332
|
+
// against REQUEST_DEADLINE_MS so the response NEVER hangs on a slow
|
|
333
|
+
// provider — past the deadline we paint from cache and let background
|
|
334
|
+
// fetches warm the next open.
|
|
335
|
+
const CONCURRENCY_CAP = 5;
|
|
336
|
+
const gather = (async () => {
|
|
337
|
+
const rows = [];
|
|
338
|
+
for (let i = 0; i < allAccounts.length; i += CONCURRENCY_CAP) {
|
|
339
|
+
const batch = allAccounts.slice(i, i + CONCURRENCY_CAP);
|
|
340
|
+
const batchRows = await Promise.all(batch.map(async (account) => {
|
|
341
|
+
const fetchResult = await fetchAccountData(account, doForceRefresh, deps);
|
|
342
|
+
return buildRow(account, fetchResult, costByAccount, sharedCostKeys);
|
|
343
|
+
}));
|
|
344
|
+
rows.push(...batchRows);
|
|
345
|
+
}
|
|
346
|
+
return rows;
|
|
347
|
+
})();
|
|
348
|
+
const deadline = new Promise((resolve) => {
|
|
349
|
+
setTimeout(() => resolve(cacheRows()), REQUEST_DEADLINE_MS);
|
|
350
|
+
});
|
|
351
|
+
const rows = await Promise.race([gather, deadline]);
|
|
352
|
+
// Native subscription rows (Claude Code + Codex) are side-loaded AFTER the
|
|
353
|
+
// CLIProxy rows resolve, bounded so a slow/failed native fetch degrades to
|
|
354
|
+
// [] rather than blocking or erroring the response.
|
|
355
|
+
const getNative = deps.getNativeAccountRows ?? (async () => []);
|
|
356
|
+
const nativeRows = (await withTimeout(getNative(), NATIVE_SIDELOAD_TIMEOUT_MS)) ?? [];
|
|
357
|
+
res.json([...rows, ...nativeRows].map(serializeBarRow));
|
|
358
|
+
}
|
|
359
|
+
catch (err) {
|
|
360
|
+
console.error('[bar-routes] /summary error:', err.message);
|
|
361
|
+
res.status(500).json({ error: 'Internal server error' });
|
|
362
|
+
}
|
|
363
|
+
});
|
|
364
|
+
/**
|
|
365
|
+
* GET /analytics
|
|
366
|
+
*
|
|
367
|
+
* Rolls up the merged, multi-source usage (Claude Code, Codex, Droid, CLIProxy)
|
|
368
|
+
* into today / 7-day / 30-day spend, a 30-day sparkline, top models, and a
|
|
369
|
+
* per-surface breakdown. Reads the dashboard's stale-while-revalidate caches so
|
|
370
|
+
* recent activity shows even when the CLIProxy snapshot is frozen by a restart.
|
|
371
|
+
* Both loads are bounded so a slow read can't stall the menu; on miss the
|
|
372
|
+
* windows degrade to empty rather than failing the payload.
|
|
373
|
+
*/
|
|
374
|
+
router.get('/analytics', async (_req, res) => {
|
|
375
|
+
try {
|
|
376
|
+
const [daily, hourly] = await Promise.all([
|
|
377
|
+
withTimeout(deps.loadDailyUsage(), SIDELOAD_TIMEOUT_MS).catch(() => []),
|
|
378
|
+
withTimeout(deps.loadHourlyUsage(), SIDELOAD_TIMEOUT_MS).catch(() => []),
|
|
379
|
+
]);
|
|
380
|
+
const analytics = (0, bar_analytics_1.computeBarAnalyticsFromDaily)(daily ?? [], hourly ?? [], new Date());
|
|
381
|
+
res.json(analytics);
|
|
382
|
+
}
|
|
383
|
+
catch (err) {
|
|
384
|
+
console.error('[bar-routes] /analytics error:', err.message);
|
|
385
|
+
res.status(500).json({ error: 'Internal server error' });
|
|
386
|
+
}
|
|
387
|
+
});
|
|
388
|
+
return router;
|
|
389
|
+
}
|
|
390
|
+
exports.createBarRouter = createBarRouter;
|
|
391
|
+
// ============================================================================
|
|
392
|
+
// Default production router (sync imports — matches all other route modules)
|
|
393
|
+
// ============================================================================
|
|
394
|
+
const query_1 = require("../../cliproxy/accounts/query");
|
|
395
|
+
const quota_response_cache_1 = require("../../cliproxy/quota/quota-response-cache");
|
|
396
|
+
const quota_fetcher_1 = require("../../cliproxy/quota/quota-fetcher");
|
|
397
|
+
const data_aggregator_1 = require("../usage/data-aggregator");
|
|
398
|
+
const cliproxy_snapshot_reader_1 = require("../usage/cliproxy-snapshot-reader");
|
|
399
|
+
const aggregator_1 = require("../usage/aggregator");
|
|
400
|
+
const native_quota_collector_1 = require("../usage/native-quota-collector");
|
|
401
|
+
/** Production bar router — wired to real dependencies */
|
|
402
|
+
const barRouter = createBarRouter({
|
|
403
|
+
getAllAccountsSummary: query_1.getAllAccountsSummary,
|
|
404
|
+
getCachedQuota: quota_response_cache_1.getCachedQuota,
|
|
405
|
+
setCachedQuota: quota_response_cache_1.setCachedQuota,
|
|
406
|
+
invalidateQuotaCache: quota_response_cache_1.invalidateQuotaCache,
|
|
407
|
+
fetchAccountQuota: quota_fetcher_1.fetchAccountQuota,
|
|
408
|
+
getTodayCostByAccount: data_aggregator_1.getTodayCostByAccount,
|
|
409
|
+
loadCliproxyDetails: cliproxy_snapshot_reader_1.loadCliproxySnapshotDetails,
|
|
410
|
+
loadDailyUsage: () => (0, aggregator_1.getCachedDailyData)(),
|
|
411
|
+
loadHourlyUsage: () => (0, aggregator_1.getCachedHourlyData)(),
|
|
412
|
+
getNativeAccountRows: () => (0, native_quota_collector_1.getNativeAccountRows)(),
|
|
413
|
+
});
|
|
414
|
+
exports.default = barRouter;
|
|
415
|
+
//# sourceMappingURL=bar-routes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bar-routes.js","sourceRoot":"","sources":["../../../src/web-server/routes/bar-routes.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEH,qCAAiC;AAOjC,0DAAsE;AAkItE,+EAA+E;AAC/E,6EAA6E;AAC7E,+EAA+E;AAE/E,yEAAyE;AACzE,MAAM,uBAAuB,GAAG,KAAM,CAAC;AAEvC,mFAAmF;AACnF,MAAM,mBAAmB,GAAG,IAAK,CAAC;AAElC,4FAA4F;AAC5F,MAAM,sBAAsB,GAAG,IAAK,CAAC;AAErC,wFAAwF;AACxF,MAAM,mBAAmB,GAAG,IAAK,CAAC;AAElC;;;;GAIG;AACH,MAAM,0BAA0B,GAAG,IAAK,CAAC;AAEzC,8EAA8E;AAC9E,IAAI,gBAAgB,GAAG,CAAC,CAAC;AAEzB,2EAA2E;AAC3E,SAAgB,uBAAuB;IACrC,gBAAgB,GAAG,CAAC,CAAC;AACvB,CAAC;AAFD,0DAEC;AAED;;;;GAIG;AACH,SAAS,WAAW,CAAI,CAAa,EAAE,EAAU;IAC/C,OAAO,IAAI,OA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A,+BAAkB,GAAE;IAC1C,eAAe,EAAE,GAAG,EAAE,CAAC,IAAA,gCAAmB,GAAE;IAC5C,oBAAoB,EAAE,GAAG,EAAE,CAAC,IAAA,6CAAoB,GAAE;CACnD,CAAC,CAAC;AAEH,kBAAe,SAAS,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/web-server/routes/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/web-server/routes/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAoCH,eAAO,MAAM,SAAS,4CAAW,CAAC"}
|
|
@@ -40,9 +40,15 @@ const persist_routes_1 = __importDefault(require("./persist-routes"));
|
|
|
40
40
|
const catalog_routes_1 = __importDefault(require("./catalog-routes"));
|
|
41
41
|
const claude_extension_routes_1 = __importDefault(require("./claude-extension-routes"));
|
|
42
42
|
const logs_routes_1 = __importDefault(require("./logs-routes"));
|
|
43
|
+
const bar_routes_1 = __importDefault(require("./bar-routes"));
|
|
43
44
|
// Create the main API router
|
|
44
45
|
exports.apiRoutes = (0, express_1.Router)();
|
|
45
46
|
const REMOTE_WRITE_ACCESS_ERROR = 'Remote dashboard writes require localhost access when dashboard auth is disabled.';
|
|
47
|
+
// CCS Bar endpoints (/api/bar/*) expose the user's native quota, tier, and cost
|
|
48
|
+
// snapshot. Unlike the rest of the read API these are sensitive even on GET, so
|
|
49
|
+
// they are gated for ALL methods (not just mutations) by the same
|
|
50
|
+
// localhost-when-auth-disabled choke point.
|
|
51
|
+
const BAR_LOCAL_ACCESS_ERROR = 'CCS Bar endpoints require localhost access when dashboard auth is disabled.';
|
|
46
52
|
function isMutationMethod(method) {
|
|
47
53
|
const normalized = method.toUpperCase();
|
|
48
54
|
return (normalized === 'POST' ||
|
|
@@ -51,6 +57,16 @@ function isMutationMethod(method) {
|
|
|
51
57
|
normalized === 'DELETE');
|
|
52
58
|
}
|
|
53
59
|
exports.apiRoutes.use((req, res, next) => {
|
|
60
|
+
// /api/bar/* leaks native quota/tier/cost data; gate it for every method.
|
|
61
|
+
// This middleware runs before the '/bar' mount below, so req.path still
|
|
62
|
+
// carries the '/bar' prefix here.
|
|
63
|
+
// Exact segment match so a future sibling like '/barbaz' isn't accidentally gated.
|
|
64
|
+
if (req.path === '/bar' || req.path.startsWith('/bar/')) {
|
|
65
|
+
if ((0, auth_middleware_1.requireLocalAccessWhenAuthDisabled)(req, res, BAR_LOCAL_ACCESS_ERROR)) {
|
|
66
|
+
next();
|
|
67
|
+
}
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
54
70
|
if (!isMutationMethod(req.method)) {
|
|
55
71
|
next();
|
|
56
72
|
return;
|
|
@@ -100,6 +116,8 @@ exports.apiRoutes.use('/droid', droid_routes_1.default);
|
|
|
100
116
|
exports.apiRoutes.use('/codex', codex_routes_1.default);
|
|
101
117
|
// ==================== CLIProxy Server Settings ====================
|
|
102
118
|
exports.apiRoutes.use('/cliproxy-server', proxy_routes_1.default);
|
|
119
|
+
// ==================== Bar (Menu Bar Glance) ====================
|
|
120
|
+
exports.apiRoutes.use('/bar', bar_routes_1.default);
|
|
103
121
|
// ==================== Misc (File API, Global Env) ====================
|
|
104
122
|
exports.apiRoutes.use('/', misc_routes_1.default);
|
|
105
123
|
exports.apiRoutes.use('/logs', logs_routes_1.default);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/web-server/routes/index.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;;;;AAEH,qCAAiC;AACjC,mEAAmF;AAEnF,wBAAwB;AACxB,sEAA6C;AAC7C,sEAA6C;AAC7C,oEAA2C;AAC3C,oEAA2C;AAC3C,wEAA+C;AAC/C,sEAA6C;AAC7C,wEAA+C;AAC/C,wEAA+C;AAC/C,0EAAiD;AACjD,oFAA0D;AAC1D,sEAA6C;AAC7C,kFAAw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qEAAqE;AACrE,iBAAS,CAAC,GAAG,CAAC,kBAAkB,EAAE,sBAAoB,CAAC,CAAC;AAExD,kEAAkE;AAClE,iBAAS,CAAC,GAAG,CAAC,MAAM,EAAE,oBAAS,CAAC,CAAC;AAEjC,wEAAwE;AACxE,iBAAS,CAAC,GAAG,CAAC,GAAG,EAAE,qBAAU,CAAC,CAAC;AAC/B,iBAAS,CAAC,GAAG,CAAC,OAAO,EAAE,qBAAU,CAAC,CAAC"}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bar Analytics Aggregator
|
|
3
|
+
*
|
|
4
|
+
* Pure functions that roll up the flat CliproxyUsageHistoryDetail array (the
|
|
5
|
+
* same snapshot the bar already loads for per-account cost) into the small,
|
|
6
|
+
* glanceable analytics the menu bar surfaces: today / 7-day / 30-day spend,
|
|
7
|
+
* a 7-day cost sparkline, and the top models by spend.
|
|
8
|
+
*
|
|
9
|
+
* Kept dependency-free and deterministic (the reference "now" is injected) so
|
|
10
|
+
* it is trivially unit-testable and cheap enough to run on every bar open.
|
|
11
|
+
*/
|
|
12
|
+
import type { CliproxyUsageHistoryDetail } from './cliproxy-usage-transformer';
|
|
13
|
+
import type { DailyUsage, HourlyUsage } from './types';
|
|
14
|
+
/** A single day's roll-up (local-day granularity). */
|
|
15
|
+
export interface BarAnalyticsDay {
|
|
16
|
+
/** Local calendar day, YYYY-MM-DD. */
|
|
17
|
+
date: string;
|
|
18
|
+
cost: number;
|
|
19
|
+
requests: number;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* One usage surface's contribution to spend over the active window.
|
|
23
|
+
* A "surface" is the tool/origin a request came from (Claude Code, Codex, the
|
|
24
|
+
* CLIProxy router, Droid, …) — the dimension the menu bar uses to answer
|
|
25
|
+
* "where is my usage actually going".
|
|
26
|
+
*/
|
|
27
|
+
export interface BarAnalyticsSurface {
|
|
28
|
+
/** Raw pipeline source key (custom-parser | codex-native | cliproxy | droid-native | …). */
|
|
29
|
+
source: string;
|
|
30
|
+
/** Human label shown in the bar (Claude Code, Codex, CLIProxy, Droid, …). */
|
|
31
|
+
surface: string;
|
|
32
|
+
cost: number;
|
|
33
|
+
requests: number;
|
|
34
|
+
}
|
|
35
|
+
/** Aggregate spend over a rolling window. */
|
|
36
|
+
export interface BarAnalyticsWindow {
|
|
37
|
+
cost: number;
|
|
38
|
+
requests: number;
|
|
39
|
+
}
|
|
40
|
+
/** One model's contribution to spend over the trailing 7 days. */
|
|
41
|
+
export interface BarAnalyticsModel {
|
|
42
|
+
model: string;
|
|
43
|
+
cost: number;
|
|
44
|
+
requests: number;
|
|
45
|
+
}
|
|
46
|
+
/** The full analytics payload returned by GET /api/bar/analytics. */
|
|
47
|
+
export interface BarAnalytics {
|
|
48
|
+
today: BarAnalyticsWindow;
|
|
49
|
+
last7d: BarAnalyticsWindow;
|
|
50
|
+
last30d: BarAnalyticsWindow;
|
|
51
|
+
/**
|
|
52
|
+
* Honest calendar month-to-date (1st of the current local month → now), NOT a
|
|
53
|
+
* rolling 30 days. A fresh month resets this toward ~0 even when `last30d`
|
|
54
|
+
* stays populated, so a monthly-cap alert measures the real billing month.
|
|
55
|
+
*/
|
|
56
|
+
monthToDate: BarAnalyticsWindow;
|
|
57
|
+
/** Lifetime totals across every record in the snapshot. */
|
|
58
|
+
allTime: BarAnalyticsWindow;
|
|
59
|
+
/** Oldest → newest, exactly 30 entries (zero-filled), for the sparkline. */
|
|
60
|
+
byDay: BarAnalyticsDay[];
|
|
61
|
+
/** Highest-spend models (descending, capped) for the window in `topModelsWindow`. */
|
|
62
|
+
topModels: BarAnalyticsModel[];
|
|
63
|
+
/** Which window `topModels` covers — the most recent one that has data. */
|
|
64
|
+
topModelsWindow: '30d' | 'all';
|
|
65
|
+
/**
|
|
66
|
+
* Spend/requests broken down by usage surface (tool/origin), for the same
|
|
67
|
+
* window as `topModels`. Descending by cost. Empty when no source is known
|
|
68
|
+
* (e.g. the legacy snapshot-only path that carries no surface dimension).
|
|
69
|
+
*/
|
|
70
|
+
bySurface: BarAnalyticsSurface[];
|
|
71
|
+
/** ISO timestamp of the most recent non-failed usage record, null if none. */
|
|
72
|
+
lastActivityAt: string | null;
|
|
73
|
+
/** Whole local-days since `lastActivityAt`, null if no usable records. */
|
|
74
|
+
daysSinceLastActivity: number | null;
|
|
75
|
+
/**
|
|
76
|
+
* True when the trailing 30 days carry any spend or requests. The UI pivots
|
|
77
|
+
* its empty/stale presentation on this without re-deriving it.
|
|
78
|
+
*/
|
|
79
|
+
hasRecentData: boolean;
|
|
80
|
+
/** ISO timestamp the payload was generated. */
|
|
81
|
+
generatedAt: string;
|
|
82
|
+
}
|
|
83
|
+
/** Local-time YYYY-MM-DD key for a Date (matches the user's calendar day). */
|
|
84
|
+
export declare function localDayKey(d: Date): string;
|
|
85
|
+
/**
|
|
86
|
+
* Roll the raw details into the bar analytics payload, relative to `now`.
|
|
87
|
+
* Failed requests are excluded from spend (they carry no real cost).
|
|
88
|
+
*/
|
|
89
|
+
export declare function computeBarAnalytics(details: CliproxyUsageHistoryDetail[], now: Date): BarAnalytics;
|
|
90
|
+
/**
|
|
91
|
+
* Roll the merged, multi-source usage aggregates into the bar analytics payload.
|
|
92
|
+
*
|
|
93
|
+
* Unlike `computeBarAnalytics` (which reads only the CLIProxy snapshot — frozen
|
|
94
|
+
* whenever the proxy restarts), this consumes the same merged daily/hourly data
|
|
95
|
+
* the dashboard uses, so recent activity from Claude Code, Codex, Droid, and the
|
|
96
|
+
* CLIProxy router all show up. `daily` carries cost+models+source; `hourly`
|
|
97
|
+
* carries the request counts (daily aggregates don't), so the two are combined:
|
|
98
|
+
* cost/models/surface-cost from daily, request counts from hourly.
|
|
99
|
+
*/
|
|
100
|
+
export declare function computeBarAnalyticsFromDaily(daily: DailyUsage[], hourly: HourlyUsage[], now: Date): BarAnalytics;
|
|
101
|
+
//# sourceMappingURL=bar-analytics.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bar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