@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,575 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Drain Order Management
|
|
4
|
+
*
|
|
5
|
+
* Manages CLIProxy account drain order via top-level "priority" field in auth JSONs.
|
|
6
|
+
*
|
|
7
|
+
* Architecture:
|
|
8
|
+
* - Priority >= 1 always (management layer treats 0 as delete-the-attribute)
|
|
9
|
+
* - Write path is dual: management API when proxy running, direct file when stopped
|
|
10
|
+
* - Tier-aware defaults only where AccountTier metadata exists (agy/gemini)
|
|
11
|
+
* - Claude pools: tier is unknown -> stable file order + manual --set required
|
|
12
|
+
* - Selector drain order: priority bucket desc, then Auth.ID asc
|
|
13
|
+
*/
|
|
14
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
15
|
+
if (k2 === undefined) k2 = k;
|
|
16
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
17
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
18
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
19
|
+
}
|
|
20
|
+
Object.defineProperty(o, k2, desc);
|
|
21
|
+
}) : (function(o, m, k, k2) {
|
|
22
|
+
if (k2 === undefined) k2 = k;
|
|
23
|
+
o[k2] = m[k];
|
|
24
|
+
}));
|
|
25
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
26
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
27
|
+
}) : function(o, v) {
|
|
28
|
+
o["default"] = v;
|
|
29
|
+
});
|
|
30
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
31
|
+
if (mod && mod.__esModule) return mod;
|
|
32
|
+
var result = {};
|
|
33
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
34
|
+
__setModuleDefault(result, mod);
|
|
35
|
+
return result;
|
|
36
|
+
};
|
|
37
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
38
|
+
exports.fetchProxyAuthCooldowns = exports.resolveEffectiveDrainOrder = exports.tieBreakKey = exports.annotateCurrentPriorities = exports.applyDrainOrder = exports.clearDrainOrderPriorities = exports.clearAuthFilePriorityDirect = exports.clearAuthFilePriorityViaApi = exports.writeAuthFilePriorityViaApi = exports.writeAuthFilePriorityDirect = exports.readAuthFilePriority = exports.computeTierDrainOrder = exports.computeManualDrainOrder = exports.tierRank = exports.rankToPriority = exports.MIN_PRIORITY = void 0;
|
|
39
|
+
const fs = __importStar(require("fs"));
|
|
40
|
+
const path = __importStar(require("path"));
|
|
41
|
+
const config_generator_1 = require("../config/config-generator");
|
|
42
|
+
const proxy_target_resolver_1 = require("../proxy/proxy-target-resolver");
|
|
43
|
+
const registry_1 = require("./registry");
|
|
44
|
+
/** Minimum valid priority value. Management layer treats 0 as delete. */
|
|
45
|
+
exports.MIN_PRIORITY = 1;
|
|
46
|
+
/** Management API path for patching auth file fields */
|
|
47
|
+
const AUTH_FILES_FIELDS_PATH = '/v0/management/auth-files/fields';
|
|
48
|
+
/** Management API path for listing auth files (and their runtime status). */
|
|
49
|
+
const AUTH_FILES_PATH = '/v0/management/auth-files';
|
|
50
|
+
/** Timeout for management API calls in ms */
|
|
51
|
+
const MGMT_TIMEOUT_MS = 5000;
|
|
52
|
+
/**
|
|
53
|
+
* Tier rank for priority derivation.
|
|
54
|
+
* Higher rank = higher priority = drained first.
|
|
55
|
+
* ultra > pro > free, unknown = no rank (returns undefined).
|
|
56
|
+
*/
|
|
57
|
+
const TIER_RANK = {
|
|
58
|
+
ultra: 3,
|
|
59
|
+
pro: 2,
|
|
60
|
+
free: 1,
|
|
61
|
+
};
|
|
62
|
+
/**
|
|
63
|
+
* Compute 1-based priority from a 0-based rank among N accounts.
|
|
64
|
+
* Rank 0 = highest priority = assigned priority N.
|
|
65
|
+
* Rank N-1 = lowest priority = assigned priority 1.
|
|
66
|
+
*
|
|
67
|
+
* Never returns 0 (management layer treats 0 as delete).
|
|
68
|
+
*/
|
|
69
|
+
function rankToPriority(rank, total) {
|
|
70
|
+
const raw = total - rank;
|
|
71
|
+
return Math.max(exports.MIN_PRIORITY, raw);
|
|
72
|
+
}
|
|
73
|
+
exports.rankToPriority = rankToPriority;
|
|
74
|
+
/** Tier rank for a known tier, undefined for unknown. */
|
|
75
|
+
function tierRank(tier) {
|
|
76
|
+
if (!tier || tier === 'unknown')
|
|
77
|
+
return undefined;
|
|
78
|
+
return TIER_RANK[tier];
|
|
79
|
+
}
|
|
80
|
+
exports.tierRank = tierRank;
|
|
81
|
+
/**
|
|
82
|
+
* Compute drain order priorities for a list of accounts using manual ordering.
|
|
83
|
+
*
|
|
84
|
+
* @param orderedIds Account IDs in desired drain order (first = highest priority)
|
|
85
|
+
* @param allAccounts All accounts for the provider (some may not be in orderedIds)
|
|
86
|
+
* @returns DrainOrderEntry array ordered by resulting priority desc
|
|
87
|
+
*/
|
|
88
|
+
function computeManualDrainOrder(orderedIds, allAccounts) {
|
|
89
|
+
const accountMap = new Map(allAccounts.map((a) => [a.accountId, a]));
|
|
90
|
+
const result = [];
|
|
91
|
+
// Reject duplicate IDs: a repeated account in --set is ambiguous and would
|
|
92
|
+
// otherwise be assigned two different priorities.
|
|
93
|
+
const seen = new Set();
|
|
94
|
+
for (const id of orderedIds) {
|
|
95
|
+
if (seen.has(id)) {
|
|
96
|
+
throw new Error(`Duplicate account ID in order: ${id}`);
|
|
97
|
+
}
|
|
98
|
+
seen.add(id);
|
|
99
|
+
}
|
|
100
|
+
// Validate that all specified IDs exist
|
|
101
|
+
for (const id of orderedIds) {
|
|
102
|
+
if (!accountMap.has(id)) {
|
|
103
|
+
throw new Error(`Account ID not found: ${id}`);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
const specifiedSet = new Set(orderedIds);
|
|
107
|
+
// Use total + 1 so rank (N-1) maps to priority 2, keeping every specified
|
|
108
|
+
// account strictly above the MIN_PRIORITY floor assigned to unspecified ones.
|
|
109
|
+
const total = orderedIds.length + 1;
|
|
110
|
+
// Assign priorities to specified accounts (first = highest priority)
|
|
111
|
+
for (let rank = 0; rank < orderedIds.length; rank++) {
|
|
112
|
+
const id = orderedIds[rank];
|
|
113
|
+
const account = accountMap.get(id);
|
|
114
|
+
if (!account)
|
|
115
|
+
continue;
|
|
116
|
+
result.push({
|
|
117
|
+
accountId: id,
|
|
118
|
+
tokenFile: account.tokenFile,
|
|
119
|
+
priority: rankToPriority(rank, total),
|
|
120
|
+
tier: account.tier,
|
|
121
|
+
tierDerived: false,
|
|
122
|
+
currentPriority: undefined,
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
// Remaining accounts not in the specified list get priority 1 (lowest)
|
|
126
|
+
for (const account of allAccounts) {
|
|
127
|
+
if (!specifiedSet.has(account.accountId)) {
|
|
128
|
+
result.push({
|
|
129
|
+
accountId: account.accountId,
|
|
130
|
+
tokenFile: account.tokenFile,
|
|
131
|
+
priority: exports.MIN_PRIORITY,
|
|
132
|
+
tier: account.tier,
|
|
133
|
+
tierDerived: false,
|
|
134
|
+
currentPriority: undefined,
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
return result;
|
|
139
|
+
}
|
|
140
|
+
exports.computeManualDrainOrder = computeManualDrainOrder;
|
|
141
|
+
/**
|
|
142
|
+
* Compute drain order priorities for accounts using tier metadata.
|
|
143
|
+
* Only valid where tier metadata exists (agy/gemini providers).
|
|
144
|
+
*
|
|
145
|
+
* Accounts with unknown tier are sorted last (priority MIN_PRIORITY).
|
|
146
|
+
* Accounts within the same tier bucket are given equal priorities.
|
|
147
|
+
*
|
|
148
|
+
* @param accounts Accounts with optional tier metadata
|
|
149
|
+
* @returns DrainOrderEntry array
|
|
150
|
+
*/
|
|
151
|
+
function computeTierDrainOrder(accounts) {
|
|
152
|
+
// Group by tier rank
|
|
153
|
+
const withRank = accounts.map((a) => ({
|
|
154
|
+
input: a,
|
|
155
|
+
rank: tierRank(a.tier) ?? 0,
|
|
156
|
+
}));
|
|
157
|
+
// Get unique ranks descending
|
|
158
|
+
const uniqueRanks = [...new Set(withRank.map((x) => x.rank))].sort((a, b) => b - a);
|
|
159
|
+
const numRanks = uniqueRanks.length;
|
|
160
|
+
// Assign priority buckets: highest rank -> highest priority (numRanks), lowest -> MIN_PRIORITY
|
|
161
|
+
const rankToPriorityMap = new Map();
|
|
162
|
+
uniqueRanks.forEach((rank, idx) => {
|
|
163
|
+
// idx 0 = highest rank, gets highest priority
|
|
164
|
+
const priority = Math.max(exports.MIN_PRIORITY, numRanks - idx);
|
|
165
|
+
rankToPriorityMap.set(rank, priority);
|
|
166
|
+
});
|
|
167
|
+
return withRank.map(({ input, rank }) => ({
|
|
168
|
+
accountId: input.accountId,
|
|
169
|
+
tokenFile: input.tokenFile,
|
|
170
|
+
priority: rankToPriorityMap.get(rank) ?? exports.MIN_PRIORITY,
|
|
171
|
+
tier: input.tier,
|
|
172
|
+
tierDerived: rank > 0, // only true when tier contributed a real rank
|
|
173
|
+
currentPriority: undefined,
|
|
174
|
+
}));
|
|
175
|
+
}
|
|
176
|
+
exports.computeTierDrainOrder = computeTierDrainOrder;
|
|
177
|
+
/**
|
|
178
|
+
* Read the current priority from an auth JSON file.
|
|
179
|
+
* Returns undefined if file missing, unreadable, or has no priority field.
|
|
180
|
+
*/
|
|
181
|
+
function readAuthFilePriority(tokenFile) {
|
|
182
|
+
try {
|
|
183
|
+
const authDir = (0, config_generator_1.getAuthDir)();
|
|
184
|
+
const filePath = path.join(authDir, tokenFile);
|
|
185
|
+
const content = fs.readFileSync(filePath, 'utf-8');
|
|
186
|
+
const data = JSON.parse(content);
|
|
187
|
+
if (typeof data.priority === 'number' && Number.isFinite(data.priority) && data.priority >= 1) {
|
|
188
|
+
return data.priority;
|
|
189
|
+
}
|
|
190
|
+
return undefined;
|
|
191
|
+
}
|
|
192
|
+
catch {
|
|
193
|
+
return undefined;
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
exports.readAuthFilePriority = readAuthFilePriority;
|
|
197
|
+
/**
|
|
198
|
+
* Write priority directly to an auth JSON file (proxy must be stopped).
|
|
199
|
+
* Validates priority >= MIN_PRIORITY before writing.
|
|
200
|
+
* Preserves all other fields; uses atomic temp-rename.
|
|
201
|
+
*/
|
|
202
|
+
function writeAuthFilePriorityDirect(tokenFile, priority) {
|
|
203
|
+
if (priority < exports.MIN_PRIORITY) {
|
|
204
|
+
throw new Error(`Priority must be >= ${exports.MIN_PRIORITY}, got ${priority}`);
|
|
205
|
+
}
|
|
206
|
+
const authDir = (0, config_generator_1.getAuthDir)();
|
|
207
|
+
const filePath = path.join(authDir, tokenFile);
|
|
208
|
+
if (!fs.existsSync(filePath)) {
|
|
209
|
+
throw new Error(`Auth file not found: ${tokenFile}`);
|
|
210
|
+
}
|
|
211
|
+
const content = fs.readFileSync(filePath, 'utf-8');
|
|
212
|
+
const data = JSON.parse(content);
|
|
213
|
+
data.priority = priority;
|
|
214
|
+
const tempPath = `${filePath}.tmp.${process.pid}`;
|
|
215
|
+
fs.writeFileSync(tempPath, JSON.stringify(data, null, 2) + '\n', { mode: 0o600 });
|
|
216
|
+
fs.renameSync(tempPath, filePath);
|
|
217
|
+
}
|
|
218
|
+
exports.writeAuthFilePriorityDirect = writeAuthFilePriorityDirect;
|
|
219
|
+
/**
|
|
220
|
+
* Write priority via CLIProxy management API (proxy must be running).
|
|
221
|
+
* Uses PATCH /v0/management/auth-files/fields.
|
|
222
|
+
*
|
|
223
|
+
* @param tokenFile File name (basename, e.g. "antigravity-foo.json")
|
|
224
|
+
* @param priority Priority value >= MIN_PRIORITY
|
|
225
|
+
* @returns true on success, false on failure
|
|
226
|
+
*/
|
|
227
|
+
async function writeAuthFilePriorityViaApi(tokenFile, priority) {
|
|
228
|
+
if (priority < exports.MIN_PRIORITY) {
|
|
229
|
+
throw new Error(`Priority must be >= ${exports.MIN_PRIORITY}, got ${priority}`);
|
|
230
|
+
}
|
|
231
|
+
return patchAuthFilePriority(tokenFile, priority);
|
|
232
|
+
}
|
|
233
|
+
exports.writeAuthFilePriorityViaApi = writeAuthFilePriorityViaApi;
|
|
234
|
+
/**
|
|
235
|
+
* Remove the priority attribute via CLIProxy management API (proxy running).
|
|
236
|
+
* Sends PATCH /v0/management/auth-files/fields with priority:0, which the
|
|
237
|
+
* management layer treats as "delete the attribute" (verified upstream:
|
|
238
|
+
* CLIProxyAPIPlus syncAuthFilePriorityAttribute deletes the attribute when the
|
|
239
|
+
* incoming priority is 0 or absent, which then persists the auth file without a
|
|
240
|
+
* top-level priority field).
|
|
241
|
+
*
|
|
242
|
+
* Using the API path is mandatory while the proxy is running: a direct file
|
|
243
|
+
* write would be clobbered by the proxy's whole-file MarkResult persist.
|
|
244
|
+
*
|
|
245
|
+
* @param tokenFile File name (basename, e.g. "antigravity-foo.json")
|
|
246
|
+
* @returns true on success, false on failure
|
|
247
|
+
*/
|
|
248
|
+
async function clearAuthFilePriorityViaApi(tokenFile) {
|
|
249
|
+
return patchAuthFilePriority(tokenFile, 0);
|
|
250
|
+
}
|
|
251
|
+
exports.clearAuthFilePriorityViaApi = clearAuthFilePriorityViaApi;
|
|
252
|
+
/** Shared PATCH-fields call for setting (>=1) or clearing (0) a file's priority. */
|
|
253
|
+
async function patchAuthFilePriority(tokenFile, priority) {
|
|
254
|
+
const target = (0, proxy_target_resolver_1.getProxyTarget)();
|
|
255
|
+
const url = (0, proxy_target_resolver_1.buildProxyUrl)(target, AUTH_FILES_FIELDS_PATH);
|
|
256
|
+
const headers = (0, proxy_target_resolver_1.buildManagementHeaders)(target, { 'Content-Type': 'application/json' });
|
|
257
|
+
const body = JSON.stringify({ name: tokenFile, priority });
|
|
258
|
+
const controller = new AbortController();
|
|
259
|
+
const timeoutId = setTimeout(() => controller.abort(), MGMT_TIMEOUT_MS);
|
|
260
|
+
try {
|
|
261
|
+
const response = await fetch(url, {
|
|
262
|
+
method: 'PATCH',
|
|
263
|
+
headers,
|
|
264
|
+
body,
|
|
265
|
+
signal: controller.signal,
|
|
266
|
+
});
|
|
267
|
+
return response.ok;
|
|
268
|
+
}
|
|
269
|
+
catch {
|
|
270
|
+
return false;
|
|
271
|
+
}
|
|
272
|
+
finally {
|
|
273
|
+
clearTimeout(timeoutId);
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
/**
|
|
277
|
+
* Remove the priority field directly from an auth JSON file (proxy stopped).
|
|
278
|
+
* No-op (returns false) when the file has no priority field. Preserves all
|
|
279
|
+
* other fields; uses the same atomic temp-rename as writeAuthFilePriorityDirect.
|
|
280
|
+
*
|
|
281
|
+
* @returns true if a priority field was present and removed, false otherwise
|
|
282
|
+
*/
|
|
283
|
+
function clearAuthFilePriorityDirect(tokenFile) {
|
|
284
|
+
const authDir = (0, config_generator_1.getAuthDir)();
|
|
285
|
+
const filePath = path.join(authDir, tokenFile);
|
|
286
|
+
if (!fs.existsSync(filePath)) {
|
|
287
|
+
throw new Error(`Auth file not found: ${tokenFile}`);
|
|
288
|
+
}
|
|
289
|
+
const content = fs.readFileSync(filePath, 'utf-8');
|
|
290
|
+
const data = JSON.parse(content);
|
|
291
|
+
if (!('priority' in data)) {
|
|
292
|
+
return false;
|
|
293
|
+
}
|
|
294
|
+
delete data.priority;
|
|
295
|
+
const tempPath = `${filePath}.tmp.${process.pid}`;
|
|
296
|
+
fs.writeFileSync(tempPath, JSON.stringify(data, null, 2) + '\n', { mode: 0o600 });
|
|
297
|
+
fs.renameSync(tempPath, filePath);
|
|
298
|
+
return true;
|
|
299
|
+
}
|
|
300
|
+
exports.clearAuthFilePriorityDirect = clearAuthFilePriorityDirect;
|
|
301
|
+
/**
|
|
302
|
+
* Clear residual on-disk priority fields for the given auth files.
|
|
303
|
+
*
|
|
304
|
+
* Mirrors applyDrainOrder's dual write path:
|
|
305
|
+
* - Proxy running: PATCH priority:0 via the management API (the only safe path;
|
|
306
|
+
* a direct write is clobbered by the proxy's whole-file persist).
|
|
307
|
+
* - Proxy stopped: delete the field directly with an atomic temp-rename.
|
|
308
|
+
*
|
|
309
|
+
* Idempotent: files with no priority field are reported as alreadyClear, not
|
|
310
|
+
* failures. The running path always reports the file as cleared on a 200 (the
|
|
311
|
+
* API treats a missing-attribute delete as a successful no-op), so this is safe
|
|
312
|
+
* to run repeatedly.
|
|
313
|
+
*
|
|
314
|
+
* @param tokenFiles Auth file basenames to clear.
|
|
315
|
+
* @param proxyRunning Whether the proxy is currently running.
|
|
316
|
+
*/
|
|
317
|
+
async function clearDrainOrderPriorities(tokenFiles, proxyRunning) {
|
|
318
|
+
const result = {
|
|
319
|
+
cleared: [],
|
|
320
|
+
alreadyClear: [],
|
|
321
|
+
failed: [],
|
|
322
|
+
usedManagementApi: proxyRunning,
|
|
323
|
+
};
|
|
324
|
+
for (const tokenFile of tokenFiles) {
|
|
325
|
+
if (proxyRunning) {
|
|
326
|
+
// Skip the API round-trip when the file already has no priority on disk.
|
|
327
|
+
if (readAuthFilePriority(tokenFile) === undefined) {
|
|
328
|
+
result.alreadyClear.push(tokenFile);
|
|
329
|
+
continue;
|
|
330
|
+
}
|
|
331
|
+
const ok = await clearAuthFilePriorityViaApi(tokenFile);
|
|
332
|
+
if (ok) {
|
|
333
|
+
result.cleared.push(tokenFile);
|
|
334
|
+
}
|
|
335
|
+
else {
|
|
336
|
+
result.failed.push({ tokenFile, reason: 'management API PATCH failed' });
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
else {
|
|
340
|
+
try {
|
|
341
|
+
const removed = clearAuthFilePriorityDirect(tokenFile);
|
|
342
|
+
if (removed) {
|
|
343
|
+
result.cleared.push(tokenFile);
|
|
344
|
+
}
|
|
345
|
+
else {
|
|
346
|
+
result.alreadyClear.push(tokenFile);
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
catch (err) {
|
|
350
|
+
result.failed.push({ tokenFile, reason: err.message });
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
return result;
|
|
355
|
+
}
|
|
356
|
+
exports.clearDrainOrderPriorities = clearDrainOrderPriorities;
|
|
357
|
+
/**
|
|
358
|
+
* Apply drain order priorities to auth files.
|
|
359
|
+
*
|
|
360
|
+
* Write path selection:
|
|
361
|
+
* - Proxy running (HTTP health check passes): use management API
|
|
362
|
+
* - Proxy stopped: direct file write
|
|
363
|
+
*
|
|
364
|
+
* Idempotent: skips entries where priority already equals the target value.
|
|
365
|
+
*
|
|
366
|
+
* @param entries Drain order entries with target priorities
|
|
367
|
+
* @param proxyRunning Whether the proxy is currently running
|
|
368
|
+
* @returns Result summary
|
|
369
|
+
*/
|
|
370
|
+
async function applyDrainOrder(entries, proxyRunning) {
|
|
371
|
+
const result = {
|
|
372
|
+
written: [],
|
|
373
|
+
skipped: [],
|
|
374
|
+
failed: [],
|
|
375
|
+
usedManagementApi: proxyRunning,
|
|
376
|
+
};
|
|
377
|
+
for (const entry of entries) {
|
|
378
|
+
// Idempotency: read current value and skip if already set
|
|
379
|
+
const currentPriority = readAuthFilePriority(entry.tokenFile);
|
|
380
|
+
if (currentPriority === entry.priority) {
|
|
381
|
+
result.skipped.push({ ...entry, currentPriority });
|
|
382
|
+
continue;
|
|
383
|
+
}
|
|
384
|
+
if (proxyRunning) {
|
|
385
|
+
const ok = await writeAuthFilePriorityViaApi(entry.tokenFile, entry.priority);
|
|
386
|
+
if (ok) {
|
|
387
|
+
result.written.push({ ...entry, currentPriority });
|
|
388
|
+
}
|
|
389
|
+
else {
|
|
390
|
+
result.failed.push({
|
|
391
|
+
entry: { ...entry, currentPriority },
|
|
392
|
+
reason: 'management API PATCH failed',
|
|
393
|
+
});
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
else {
|
|
397
|
+
try {
|
|
398
|
+
writeAuthFilePriorityDirect(entry.tokenFile, entry.priority);
|
|
399
|
+
result.written.push({ ...entry, currentPriority });
|
|
400
|
+
}
|
|
401
|
+
catch (err) {
|
|
402
|
+
result.failed.push({
|
|
403
|
+
entry: { ...entry, currentPriority },
|
|
404
|
+
reason: err.message,
|
|
405
|
+
});
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
return result;
|
|
410
|
+
}
|
|
411
|
+
exports.applyDrainOrder = applyDrainOrder;
|
|
412
|
+
/**
|
|
413
|
+
* Read current drain order priorities for a set of accounts.
|
|
414
|
+
* Annotates each DrainOrderEntry with its current priority from disk.
|
|
415
|
+
*
|
|
416
|
+
* @param entries Entries to annotate (modifies currentPriority in-place)
|
|
417
|
+
*/
|
|
418
|
+
function annotateCurrentPriorities(entries) {
|
|
419
|
+
for (const entry of entries) {
|
|
420
|
+
entry.currentPriority = readAuthFilePriority(entry.tokenFile);
|
|
421
|
+
}
|
|
422
|
+
}
|
|
423
|
+
exports.annotateCurrentPriorities = annotateCurrentPriorities;
|
|
424
|
+
/**
|
|
425
|
+
* Tie-break key for a token file, matching the upstream Go selector.
|
|
426
|
+
* The selector breaks priority ties by Auth.ID asc. Upstream (synthesizer
|
|
427
|
+
* file.go:120-122) lowercases Auth.ID only on Windows; on other platforms it
|
|
428
|
+
* compares by raw byte order. We mirror that platform-conditional behaviour so
|
|
429
|
+
* the displayed order matches what CLIProxy actually drains.
|
|
430
|
+
*
|
|
431
|
+
* @param platform process.platform; defaults to the current platform. Exposed
|
|
432
|
+
* for tests so non-Windows byte-order behaviour can be asserted deterministically.
|
|
433
|
+
*/
|
|
434
|
+
function tieBreakKey(tokenFile, platform = process.platform) {
|
|
435
|
+
return platform === 'win32' ? tokenFile.toLowerCase() : tokenFile;
|
|
436
|
+
}
|
|
437
|
+
exports.tieBreakKey = tieBreakKey;
|
|
438
|
+
/**
|
|
439
|
+
* Resolve the effective drain order for a provider's active (non-paused)
|
|
440
|
+
* accounts, mirroring what `ccs cliproxy accounts order` shows and what the
|
|
441
|
+
* selector actually drains.
|
|
442
|
+
*
|
|
443
|
+
* Semantics (shared by the order subcommand and the quota pool section):
|
|
444
|
+
* 1. Pick the config mode (manual when stored ids still resolve, else tier when
|
|
445
|
+
* stored, else file order).
|
|
446
|
+
* 2. annotateCurrentPriorities() to read the on-disk priority for each account.
|
|
447
|
+
* 3. Sort by currentPriority desc (undefined treated as 0, matching the
|
|
448
|
+
* selector), tie-break by tieBreakKey(tokenFile) asc.
|
|
449
|
+
* 4. Flag drift when the computed config priority != on-disk priority anywhere.
|
|
450
|
+
*
|
|
451
|
+
* File mode never writes priorities, but it still honours any residual on-disk
|
|
452
|
+
* priority the selector reads (e.g. left by `order --reset`): it sorts by that
|
|
453
|
+
* priority desc then tieBreakKey asc, and flags drift when any residual is
|
|
454
|
+
* non-zero. With no residuals all priorities are 0 and it falls back to plain
|
|
455
|
+
* tieBreakKey order with no drift.
|
|
456
|
+
*
|
|
457
|
+
* @param activeAccounts Accounts in rotation (callers exclude paused accounts).
|
|
458
|
+
*/
|
|
459
|
+
function resolveEffectiveDrainOrder(provider, activeAccounts) {
|
|
460
|
+
if (activeAccounts.length === 0) {
|
|
461
|
+
return { mode: 'file', entries: [], hasDrift: false };
|
|
462
|
+
}
|
|
463
|
+
const drainCfg = (0, registry_1.loadDrainOrderConfig)(provider);
|
|
464
|
+
// Manual mode is only usable when at least one stored ID still maps to a live
|
|
465
|
+
// account. If every stored ID is stale, fall back to the file-order view.
|
|
466
|
+
let manualValidIds;
|
|
467
|
+
if (drainCfg?.mode === 'manual' && drainCfg.orderedIds && drainCfg.orderedIds.length > 0) {
|
|
468
|
+
const existingIds = new Set(activeAccounts.map((a) => a.accountId));
|
|
469
|
+
manualValidIds = drainCfg.orderedIds.filter((id) => existingIds.has(id));
|
|
470
|
+
}
|
|
471
|
+
let entries;
|
|
472
|
+
let mode;
|
|
473
|
+
if (manualValidIds && manualValidIds.length > 0) {
|
|
474
|
+
entries = computeManualDrainOrder(manualValidIds, activeAccounts);
|
|
475
|
+
mode = 'manual';
|
|
476
|
+
}
|
|
477
|
+
else if (drainCfg?.mode === 'tier') {
|
|
478
|
+
entries = computeTierDrainOrder(activeAccounts);
|
|
479
|
+
mode = 'tier';
|
|
480
|
+
}
|
|
481
|
+
else {
|
|
482
|
+
// File order: config never writes priorities, so entries carry no computed
|
|
483
|
+
// priority. The selector still reads any residual on-disk priority (e.g.
|
|
484
|
+
// left behind by `order --reset`), so annotate, sort by that priority like
|
|
485
|
+
// the other modes, and flag drift when any residual is non-zero.
|
|
486
|
+
entries = activeAccounts.map((a) => ({
|
|
487
|
+
accountId: a.accountId,
|
|
488
|
+
tokenFile: a.tokenFile,
|
|
489
|
+
priority: exports.MIN_PRIORITY,
|
|
490
|
+
tier: a.tier,
|
|
491
|
+
tierDerived: false,
|
|
492
|
+
currentPriority: undefined,
|
|
493
|
+
}));
|
|
494
|
+
annotateCurrentPriorities(entries);
|
|
495
|
+
const fileHasDrift = entries.some((e) => (e.currentPriority ?? 0) !== 0);
|
|
496
|
+
entries.sort((a, b) => (b.currentPriority ?? 0) - (a.currentPriority ?? 0) ||
|
|
497
|
+
(tieBreakKey(a.tokenFile) < tieBreakKey(b.tokenFile) ? -1 : 1));
|
|
498
|
+
return { mode: 'file', entries, hasDrift: fileHasDrift };
|
|
499
|
+
}
|
|
500
|
+
// Annotate on-disk priorities (the selector's real input) before sorting.
|
|
501
|
+
annotateCurrentPriorities(entries);
|
|
502
|
+
// Drift: computed config priority diverges from on-disk anywhere. Missing
|
|
503
|
+
// file priority (undefined) is treated as 0, matching the selector.
|
|
504
|
+
const hasDrift = entries.some((e) => (e.currentPriority ?? 0) !== e.priority);
|
|
505
|
+
// Sort by on-disk priority desc (undefined as 0), tie-break by tokenFile asc.
|
|
506
|
+
entries.sort((a, b) => (b.currentPriority ?? 0) - (a.currentPriority ?? 0) ||
|
|
507
|
+
(tieBreakKey(a.tokenFile) < tieBreakKey(b.tokenFile) ? -1 : 1));
|
|
508
|
+
return { mode, entries, hasDrift };
|
|
509
|
+
}
|
|
510
|
+
exports.resolveEffectiveDrainOrder = resolveEffectiveDrainOrder;
|
|
511
|
+
/**
|
|
512
|
+
* Fetch in-proxy cooldowns from the running CLIProxy.
|
|
513
|
+
*
|
|
514
|
+
* Pool routing turns cooling ON, so when a credential hits a 429 the proxy
|
|
515
|
+
* marks it Unavailable and rotates to a healthy one. That cooldown lives inside
|
|
516
|
+
* the proxy process (not in CCS's quota-paused.json), so the only way the quota
|
|
517
|
+
* Pool section can explain a session hop is to read it here.
|
|
518
|
+
*
|
|
519
|
+
* GET /v0/management/auth-files returns { files: [{ name, unavailable,
|
|
520
|
+
* next_retry_after, ... }] }. We classify any entry with unavailable=true as a
|
|
521
|
+
* cooling credential and parse next_retry_after (RFC3339) into epoch ms when
|
|
522
|
+
* present.
|
|
523
|
+
*
|
|
524
|
+
* Degrades silently to an empty array on any failure (proxy not running,
|
|
525
|
+
* endpoint missing on an older binary, malformed/unknown response shape,
|
|
526
|
+
* timeout): the caller falls back to its CCS-side cooldown view with no error
|
|
527
|
+
* spam in quota output. Latency is bounded by a single request and MGMT_TIMEOUT_MS.
|
|
528
|
+
*
|
|
529
|
+
* @returns One entry per auth file the proxy reports unavailable.
|
|
530
|
+
*/
|
|
531
|
+
async function fetchProxyAuthCooldowns() {
|
|
532
|
+
const target = (0, proxy_target_resolver_1.getProxyTarget)();
|
|
533
|
+
const url = (0, proxy_target_resolver_1.buildProxyUrl)(target, AUTH_FILES_PATH);
|
|
534
|
+
const headers = (0, proxy_target_resolver_1.buildManagementHeaders)(target);
|
|
535
|
+
const controller = new AbortController();
|
|
536
|
+
const timeoutId = setTimeout(() => controller.abort(), MGMT_TIMEOUT_MS);
|
|
537
|
+
try {
|
|
538
|
+
const response = await fetch(url, { method: 'GET', headers, signal: controller.signal });
|
|
539
|
+
if (!response.ok) {
|
|
540
|
+
return [];
|
|
541
|
+
}
|
|
542
|
+
const data = (await response.json());
|
|
543
|
+
if (!Array.isArray(data.files)) {
|
|
544
|
+
return [];
|
|
545
|
+
}
|
|
546
|
+
const cooldowns = [];
|
|
547
|
+
for (const raw of data.files) {
|
|
548
|
+
// Defensive parse: only entries the proxy explicitly flags unavailable.
|
|
549
|
+
if (!raw || raw.unavailable !== true) {
|
|
550
|
+
continue;
|
|
551
|
+
}
|
|
552
|
+
const name = typeof raw.name === 'string' ? raw.name : undefined;
|
|
553
|
+
if (!name) {
|
|
554
|
+
continue;
|
|
555
|
+
}
|
|
556
|
+
let cooldownUntil;
|
|
557
|
+
if (typeof raw.next_retry_after === 'string') {
|
|
558
|
+
const parsed = Date.parse(raw.next_retry_after);
|
|
559
|
+
if (Number.isFinite(parsed)) {
|
|
560
|
+
cooldownUntil = parsed;
|
|
561
|
+
}
|
|
562
|
+
}
|
|
563
|
+
cooldowns.push({ tokenFile: name, cooldownUntil });
|
|
564
|
+
}
|
|
565
|
+
return cooldowns;
|
|
566
|
+
}
|
|
567
|
+
catch {
|
|
568
|
+
return [];
|
|
569
|
+
}
|
|
570
|
+
finally {
|
|
571
|
+
clearTimeout(timeoutId);
|
|
572
|
+
}
|
|
573
|
+
}
|
|
574
|
+
exports.fetchProxyAuthCooldowns = fetchProxyAuthCooldowns;
|
|
575
|
+
//# sourceMappingURL=drain-order.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"drain-order.js","sourceRoot":"","sources":["../../../src/cliproxy/accounts/drain-order.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;GAWG;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,uCAAyB;AACzB,2CAA6B;AAC7B,iEAAwD;AACxD,0EAIwC;AACxC,yCAAkD;AAIlD,yEAAyE;AAC5D,QAAA,YAAY,GAAG,CAAC,CAAC;AAE9B,wDAAwD;AACxD,MAAM,sBAAsB,GAAG,kCAAkC,CAAC;AAElE,6EAA6E;AAC7E,MAAM,eAAe,GAAG,2BAA2B,CAAC;AAEpD,6CAA6C;AAC7C,MAAM,eAAe,GAAG,IAAI,CAAC;AAoB7B;;;;GAIG;AACH,MAAM,SAAS,GAAoD;IACjE,KAAK,EAAE,CAAC;IACR,GAAG,EAAE,CAAC;IACN,IAAI,EAAE,CAAC;CACR,CAAC;AAEF;;;;;;GAMG;AACH,SAAgB,cAAc,CAAC,IAAY,EAAE,KAAa;IACxD,MAAM,GAAG,GAAG,KAAK,GAAG,IAAI,CAAC;IACzB,OAAO,IAAI,CAAC,GAAG,CAAC,oBAAY,EAAE,GAAG,CAAC,CAAC;AACrC,CAAC;AAHD,wCAGC;AAED,yDAAyD;AACzD,SAAgB,QAAQ,CAAC,IAA6B;IACpD,IAAI,CAAC,IAAI,IAAI,IAAI,KAAK,SAAS;QAAE,OAAO,SAAS,CAAC;IAClD,OAAO,SAAS,CAAC,IAAI,CAAC,CAAC;AACzB,CAAC;AAHD,4BAGC;AA6BD;;;;;;GAMG;AACH,SAAgB,uBAAuB,CACrC,UAAoB,EACpB,W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