@cortexkit/opencode-antigravity-auth 2.2.1 → 3.0.0
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 +95 -89
- package/dist/cli.js +18469 -810
- package/dist/cli.js.map +4 -4
- package/dist/cli.meta.json +4079 -0
- package/dist/index.js +40914 -16441
- package/dist/index.js.map +4 -4
- package/dist/index.meta.json +6949 -0
- package/dist/server.js +50948 -0
- package/dist/server.js.map +7 -0
- package/dist/server.meta.json +7284 -0
- package/dist/src/cli.d.ts +46 -1
- package/dist/src/cli.d.ts.map +1 -1
- package/dist/src/cli.js +207 -2
- package/dist/src/cli.js.map +1 -1
- package/dist/src/common-auth-embedded/NOTICE.txt +21 -0
- package/dist/src/common-auth-embedded/auth-menu/accounts.d.ts +97 -0
- package/dist/src/common-auth-embedded/auth-menu/accounts.js +387 -0
- package/dist/src/common-auth-embedded/auth-menu/ansi.d.ts +26 -0
- package/dist/src/common-auth-embedded/auth-menu/ansi.js +98 -0
- package/dist/src/common-auth-embedded/auth-menu/confirm.d.ts +7 -0
- package/dist/src/common-auth-embedded/auth-menu/confirm.js +21 -0
- package/dist/src/common-auth-embedded/auth-menu/doctor.d.ts +52 -0
- package/dist/src/common-auth-embedded/auth-menu/doctor.js +81 -0
- package/dist/src/common-auth-embedded/auth-menu/index.d.ts +17 -0
- package/dist/src/common-auth-embedded/auth-menu/index.js +12 -0
- package/dist/src/common-auth-embedded/auth-menu/login.d.ts +55 -0
- package/dist/src/common-auth-embedded/auth-menu/login.js +83 -0
- package/dist/src/common-auth-embedded/auth-menu/menu.d.ts +59 -0
- package/dist/src/common-auth-embedded/auth-menu/menu.js +73 -0
- package/dist/src/common-auth-embedded/auth-menu/opencode-v1.d.ts +49 -0
- package/dist/src/common-auth-embedded/auth-menu/opencode-v1.js +47 -0
- package/dist/src/common-auth-embedded/auth-menu/select.d.ts +21 -0
- package/dist/src/common-auth-embedded/auth-menu/select.js +159 -0
- package/dist/src/common-auth-embedded/auth-menu/terminal.d.ts +43 -0
- package/dist/src/common-auth-embedded/auth-menu/terminal.js +19 -0
- package/dist/src/common-auth-embedded/claustrum/consumer.d.ts +102 -0
- package/dist/src/common-auth-embedded/claustrum/consumer.js +298 -0
- package/dist/src/common-auth-embedded/claustrum/custody.d.ts +175 -0
- package/dist/src/common-auth-embedded/claustrum/custody.js +354 -0
- package/dist/src/common-auth-embedded/claustrum/enrollment.d.ts +158 -0
- package/dist/src/common-auth-embedded/claustrum/enrollment.js +759 -0
- package/dist/src/common-auth-embedded/claustrum/errors.d.ts +16 -0
- package/dist/src/common-auth-embedded/claustrum/errors.js +8 -0
- package/dist/src/common-auth-embedded/claustrum/host-slot.d.ts +39 -0
- package/dist/src/common-auth-embedded/claustrum/host-slot.js +72 -0
- package/dist/src/common-auth-embedded/claustrum/index.d.ts +18 -0
- package/dist/src/common-auth-embedded/claustrum/index.js +22 -0
- package/dist/src/common-auth-embedded/claustrum/interlock.d.ts +27 -0
- package/dist/src/common-auth-embedded/claustrum/interlock.js +29 -0
- package/dist/src/common-auth-embedded/claustrum/roster.d.ts +208 -0
- package/dist/src/common-auth-embedded/claustrum/roster.js +536 -0
- package/dist/src/common-auth-embedded/commands/builtins.d.ts +71 -0
- package/dist/src/common-auth-embedded/commands/builtins.js +534 -0
- package/dist/src/common-auth-embedded/commands/index.d.ts +10 -0
- package/dist/src/common-auth-embedded/commands/index.js +5 -0
- package/dist/src/common-auth-embedded/commands/menu.d.ts +61 -0
- package/dist/src/common-auth-embedded/commands/menu.js +300 -0
- package/dist/src/common-auth-embedded/commands/model.d.ts +238 -0
- package/dist/src/common-auth-embedded/commands/model.js +16 -0
- package/dist/src/common-auth-embedded/commands/pi.d.ts +23 -0
- package/dist/src/common-auth-embedded/commands/pi.js +206 -0
- package/dist/src/common-auth-embedded/commands/seam.d.ts +72 -0
- package/dist/src/common-auth-embedded/commands/seam.js +301 -0
- package/dist/src/common-auth-embedded/fs/atomic-write.d.ts +20 -0
- package/dist/src/common-auth-embedded/fs/atomic-write.js +80 -0
- package/dist/src/common-auth-embedded/fs/index.d.ts +7 -0
- package/dist/src/common-auth-embedded/fs/index.js +6 -0
- package/dist/src/common-auth-embedded/fs/lock-constants.d.ts +14 -0
- package/dist/src/common-auth-embedded/fs/lock-constants.js +14 -0
- package/dist/src/common-auth-embedded/fs/refresh-file-lock.d.ts +33 -0
- package/dist/src/common-auth-embedded/fs/refresh-file-lock.js +501 -0
- package/dist/src/common-auth-embedded/fs/with-lock.d.ts +33 -0
- package/dist/src/common-auth-embedded/fs/with-lock.js +48 -0
- package/dist/src/common-auth-embedded/logger/capture-sink.d.ts +14 -0
- package/dist/src/common-auth-embedded/logger/capture-sink.js +13 -0
- package/dist/src/common-auth-embedded/logger/engine.d.ts +100 -0
- package/dist/src/common-auth-embedded/logger/engine.js +246 -0
- package/dist/src/common-auth-embedded/logger/index.d.ts +6 -0
- package/dist/src/common-auth-embedded/logger/index.js +3 -0
- package/dist/src/common-auth-embedded/logger/redact.d.ts +11 -0
- package/dist/src/common-auth-embedded/logger/redact.js +83 -0
- package/dist/src/common-auth-embedded/opencode2/errors.d.ts +25 -0
- package/dist/src/common-auth-embedded/opencode2/errors.js +15 -0
- package/dist/src/common-auth-embedded/opencode2/index.d.ts +8 -0
- package/dist/src/common-auth-embedded/opencode2/index.js +4 -0
- package/dist/src/common-auth-embedded/opencode2/install.d.ts +55 -0
- package/dist/src/common-auth-embedded/opencode2/install.js +886 -0
- package/dist/src/common-auth-embedded/opencode2/integration.d.ts +112 -0
- package/dist/src/common-auth-embedded/opencode2/integration.js +143 -0
- package/dist/src/common-auth-embedded/opencode2/sse.d.ts +12 -0
- package/dist/src/common-auth-embedded/opencode2/sse.js +60 -0
- package/dist/src/common-auth-embedded/opencode2/types.d.ts +413 -0
- package/dist/src/common-auth-embedded/pi-slot/index.d.ts +3 -0
- package/dist/src/common-auth-embedded/pi-slot/index.js +2 -0
- package/dist/src/common-auth-embedded/pi-slot/lock.js +212 -0
- package/dist/src/common-auth-embedded/pi-slot/slot.d.ts +49 -0
- package/dist/src/common-auth-embedded/pi-slot/slot.js +383 -0
- package/dist/src/common-auth-embedded/quota/codec.d.ts +11 -0
- package/dist/src/common-auth-embedded/quota/codec.js +12 -0
- package/dist/src/common-auth-embedded/quota/format.d.ts +46 -0
- package/dist/src/common-auth-embedded/quota/format.js +138 -0
- package/dist/src/common-auth-embedded/quota/index.d.ts +10 -0
- package/dist/src/common-auth-embedded/quota/index.js +5 -0
- package/dist/src/common-auth-embedded/quota/map.d.ts +63 -0
- package/dist/src/common-auth-embedded/quota/map.js +105 -0
- package/dist/src/common-auth-embedded/quota/merge.d.ts +48 -0
- package/dist/src/common-auth-embedded/quota/merge.js +162 -0
- package/dist/src/common-auth-embedded/quota/projection.d.ts +64 -0
- package/dist/src/common-auth-embedded/quota/projection.js +134 -0
- package/dist/src/common-auth-embedded/routing/admission.d.ts +93 -0
- package/dist/src/common-auth-embedded/routing/admission.js +142 -0
- package/dist/src/common-auth-embedded/routing/index.d.ts +8 -0
- package/dist/src/common-auth-embedded/routing/index.js +4 -0
- package/dist/src/common-auth-embedded/routing/ordered.d.ts +47 -0
- package/dist/src/common-auth-embedded/routing/ordered.js +58 -0
- package/dist/src/common-auth-embedded/routing/pins.d.ts +22 -0
- package/dist/src/common-auth-embedded/routing/pins.js +34 -0
- package/dist/src/common-auth-embedded/routing/sticky.d.ts +158 -0
- package/dist/src/common-auth-embedded/routing/sticky.js +339 -0
- package/dist/src/common-auth-embedded/rpc/client.d.ts +3 -0
- package/dist/src/common-auth-embedded/rpc/client.js +2 -0
- package/dist/src/common-auth-embedded/rpc/index.d.ts +10 -0
- package/dist/src/common-auth-embedded/rpc/index.js +5 -0
- package/dist/src/common-auth-embedded/rpc/notifications.d.ts +73 -0
- package/dist/src/common-auth-embedded/rpc/notifications.js +100 -0
- package/dist/src/common-auth-embedded/rpc/port-file.d.ts +33 -0
- package/dist/src/common-auth-embedded/rpc/port-file.js +217 -0
- package/dist/src/common-auth-embedded/rpc/rpc-client.d.ts +30 -0
- package/dist/src/common-auth-embedded/rpc/rpc-client.js +253 -0
- package/dist/src/common-auth-embedded/rpc/rpc-server.d.ts +58 -0
- package/dist/src/common-auth-embedded/rpc/rpc-server.js +311 -0
- package/dist/src/common-auth-embedded/rpc/server-registry.d.ts +11 -0
- package/dist/src/common-auth-embedded/rpc/server-registry.js +47 -0
- package/dist/src/common-auth-embedded/source-output.json +1326 -0
- package/dist/src/common-auth-embedded/store/attribution.d.ts +28 -0
- package/dist/src/common-auth-embedded/store/attribution.js +60 -0
- package/dist/src/common-auth-embedded/store/errors.d.ts +55 -0
- package/dist/src/common-auth-embedded/store/errors.js +38 -0
- package/dist/src/common-auth-embedded/store/hooks.d.ts +12 -0
- package/dist/src/common-auth-embedded/store/hooks.js +34 -0
- package/dist/src/common-auth-embedded/store/identity.d.ts +39 -0
- package/dist/src/common-auth-embedded/store/identity.js +79 -0
- package/dist/src/common-auth-embedded/store/index.d.ts +21 -0
- package/dist/src/common-auth-embedded/store/index.js +7 -0
- package/dist/src/common-auth-embedded/store/mutate.d.ts +189 -0
- package/dist/src/common-auth-embedded/store/mutate.js +500 -0
- package/dist/src/common-auth-embedded/store/pool.d.ts +196 -0
- package/dist/src/common-auth-embedded/store/pool.js +120 -0
- package/dist/src/common-auth-embedded/store/provider-state.d.ts +131 -0
- package/dist/src/common-auth-embedded/store/provider-state.js +226 -0
- package/dist/src/common-auth-embedded/store/publication.d.ts +47 -0
- package/dist/src/common-auth-embedded/store/publication.js +304 -0
- package/dist/src/common-auth-embedded/store/pull.d.ts +36 -0
- package/dist/src/common-auth-embedded/store/pull.js +143 -0
- package/dist/src/common-auth-embedded/store/refresh-lock.d.ts +63 -0
- package/dist/src/common-auth-embedded/store/refresh-lock.js +136 -0
- package/dist/src/common-auth-embedded/store/refresh.d.ts +72 -0
- package/dist/src/common-auth-embedded/store/refresh.js +225 -0
- package/dist/src/common-auth-embedded/store/reserved.js +13 -0
- package/dist/src/common-auth-embedded/store/rows.d.ts +313 -0
- package/dist/src/common-auth-embedded/store/rows.js +1258 -0
- package/dist/src/common-auth-embedded/store/runtime.d.ts +36 -0
- package/dist/src/common-auth-embedded/store/runtime.js +68 -0
- package/dist/src/common-auth-embedded/store/schema.d.ts +443 -0
- package/dist/src/common-auth-embedded/store/schema.js +754 -0
- package/dist/src/common-auth-embedded/store/settings.d.ts +63 -0
- package/dist/src/common-auth-embedded/store/settings.js +120 -0
- package/dist/src/common-auth-embedded/store/torn.d.ts +78 -0
- package/dist/src/common-auth-embedded/store/torn.js +294 -0
- package/dist/src/common-auth-embedded/tui/index.d.ts +8 -0
- package/dist/src/common-auth-embedded/tui/index.js +21 -0
- package/dist/src/common-auth-embedded/util/any-signal.js +42 -0
- package/dist/src/constants.d.ts +1 -0
- package/dist/src/constants.d.ts.map +1 -1
- package/dist/src/constants.js +4 -0
- package/dist/src/constants.js.map +1 -1
- package/dist/src/ga/proxy-guard.d.ts +120 -0
- package/dist/src/ga/proxy-guard.d.ts.map +1 -0
- package/dist/src/ga/proxy-guard.js +269 -0
- package/dist/src/ga/proxy-guard.js.map +1 -0
- package/dist/src/ga/rpc/protocol.d.ts +504 -0
- package/dist/src/ga/rpc/protocol.d.ts.map +1 -0
- package/dist/src/ga/rpc/protocol.js +1278 -0
- package/dist/src/ga/rpc/protocol.js.map +1 -0
- package/dist/src/ga/server/auth.d.ts +9 -0
- package/dist/src/ga/server/auth.d.ts.map +1 -0
- package/dist/src/ga/server/auth.js +37 -0
- package/dist/src/ga/server/auth.js.map +1 -0
- package/dist/src/ga/server/index.d.ts +576 -0
- package/dist/src/ga/server/index.d.ts.map +1 -0
- package/dist/src/ga/server/index.js +1012 -0
- package/dist/src/ga/server/index.js.map +1 -0
- package/dist/src/ga/tui/host-ga.d.ts +350 -0
- package/dist/src/ga/tui/host-ga.d.ts.map +1 -0
- package/dist/src/ga/tui/host-ga.js +1242 -0
- package/dist/src/ga/tui/host-ga.js.map +1 -0
- package/dist/src/logging/provider-key-policy.d.ts +9 -0
- package/dist/src/logging/provider-key-policy.d.ts.map +1 -0
- package/dist/src/logging/provider-key-policy.js +11 -0
- package/dist/src/logging/provider-key-policy.js.map +1 -0
- package/dist/src/plugin/account-access.d.ts +130 -15
- package/dist/src/plugin/account-access.d.ts.map +1 -1
- package/dist/src/plugin/account-access.js +331 -129
- package/dist/src/plugin/account-access.js.map +1 -1
- package/dist/src/plugin/account-blocks.d.ts +102 -0
- package/dist/src/plugin/account-blocks.d.ts.map +1 -0
- package/dist/src/plugin/account-blocks.js +196 -0
- package/dist/src/plugin/account-blocks.js.map +1 -0
- package/dist/src/plugin/accounts.d.ts +85 -1
- package/dist/src/plugin/accounts.d.ts.map +1 -1
- package/dist/src/plugin/accounts.js +127 -3
- package/dist/src/plugin/accounts.js.map +1 -1
- package/dist/src/plugin/auth-loader.d.ts +69 -5
- package/dist/src/plugin/auth-loader.d.ts.map +1 -1
- package/dist/src/plugin/auth-loader.js +355 -52
- package/dist/src/plugin/auth-loader.js.map +1 -1
- package/dist/src/plugin/background-quota-refresh.d.ts +54 -8
- package/dist/src/plugin/background-quota-refresh.d.ts.map +1 -1
- package/dist/src/plugin/background-quota-refresh.js +81 -24
- package/dist/src/plugin/background-quota-refresh.js.map +1 -1
- package/dist/src/plugin/cache/index.d.ts +1 -1
- package/dist/src/plugin/cache/index.d.ts.map +1 -1
- package/dist/src/plugin/cache/index.js +1 -1
- package/dist/src/plugin/cache/index.js.map +1 -1
- package/dist/src/plugin/cache/signature-cache.d.ts +55 -10
- package/dist/src/plugin/cache/signature-cache.d.ts.map +1 -1
- package/dist/src/plugin/cache/signature-cache.js +100 -41
- package/dist/src/plugin/cache/signature-cache.js.map +1 -1
- package/dist/src/plugin/cache.d.ts +80 -16
- package/dist/src/plugin/cache.d.ts.map +1 -1
- package/dist/src/plugin/cache.js +339 -200
- package/dist/src/plugin/cache.js.map +1 -1
- package/dist/src/plugin/catalog.d.ts +4 -18
- package/dist/src/plugin/catalog.d.ts.map +1 -1
- package/dist/src/plugin/catalog.js +11 -41
- package/dist/src/plugin/catalog.js.map +1 -1
- package/dist/src/plugin/command-apply.d.ts +58 -0
- package/dist/src/plugin/command-apply.d.ts.map +1 -0
- package/dist/src/plugin/command-apply.js +168 -0
- package/dist/src/plugin/command-apply.js.map +1 -0
- package/dist/src/plugin/command-data.d.ts +1 -0
- package/dist/src/plugin/command-data.d.ts.map +1 -1
- package/dist/src/plugin/command-data.js +2 -0
- package/dist/src/plugin/command-data.js.map +1 -1
- package/dist/src/plugin/commands.d.ts +142 -132
- package/dist/src/plugin/commands.d.ts.map +1 -1
- package/dist/src/plugin/commands.js +214 -686
- package/dist/src/plugin/commands.js.map +1 -1
- package/dist/src/plugin/config/index.d.ts +1 -1
- package/dist/src/plugin/config/index.d.ts.map +1 -1
- package/dist/src/plugin/config/index.js +1 -1
- package/dist/src/plugin/config/index.js.map +1 -1
- package/dist/src/plugin/config/loader.d.ts +37 -1
- package/dist/src/plugin/config/loader.d.ts.map +1 -1
- package/dist/src/plugin/config/loader.js +64 -9
- package/dist/src/plugin/config/loader.js.map +1 -1
- package/dist/src/plugin/config/operator-settings-schema.d.ts +2 -2
- package/dist/src/plugin/config/schema.d.ts +2 -2
- package/dist/src/plugin/config/writer.d.ts +7 -0
- package/dist/src/plugin/config/writer.d.ts.map +1 -1
- package/dist/src/plugin/config/writer.js +10 -1
- package/dist/src/plugin/config/writer.js.map +1 -1
- package/dist/src/plugin/debug.d.ts +72 -29
- package/dist/src/plugin/debug.d.ts.map +1 -1
- package/dist/src/plugin/debug.js +353 -239
- package/dist/src/plugin/debug.js.map +1 -1
- package/dist/src/plugin/fetch/retry-state.d.ts +1 -1
- package/dist/src/plugin/fetch/retry-state.d.ts.map +1 -1
- package/dist/src/plugin/fetch/retry-state.js.map +1 -1
- package/dist/src/plugin/fetch-interceptor.d.ts +66 -11
- package/dist/src/plugin/fetch-interceptor.d.ts.map +1 -1
- package/dist/src/plugin/fetch-interceptor.js +228 -1352
- package/dist/src/plugin/fetch-interceptor.js.map +1 -1
- package/dist/src/plugin/fetch-routing.d.ts +7 -2
- package/dist/src/plugin/fetch-routing.d.ts.map +1 -1
- package/dist/src/plugin/fetch-routing.js +7 -4
- package/dist/src/plugin/fetch-routing.js.map +1 -1
- package/dist/src/plugin/ga-location-services.d.ts +389 -0
- package/dist/src/plugin/ga-location-services.d.ts.map +1 -0
- package/dist/src/plugin/ga-location-services.js +1838 -0
- package/dist/src/plugin/ga-location-services.js.map +1 -0
- package/dist/src/plugin/gemini-dump.d.ts +37 -12
- package/dist/src/plugin/gemini-dump.d.ts.map +1 -1
- package/dist/src/plugin/gemini-dump.js +42 -21
- package/dist/src/plugin/gemini-dump.js.map +1 -1
- package/dist/src/plugin/google-search-tool.d.ts +2 -1
- package/dist/src/plugin/google-search-tool.d.ts.map +1 -1
- package/dist/src/plugin/google-search-tool.js +4 -1
- package/dist/src/plugin/google-search-tool.js.map +1 -1
- package/dist/src/plugin/index.d.ts.map +1 -1
- package/dist/src/plugin/index.js +505 -141
- package/dist/src/plugin/index.js.map +1 -1
- package/dist/src/plugin/killswitch.d.ts +1 -2
- package/dist/src/plugin/killswitch.d.ts.map +1 -1
- package/dist/src/plugin/lifecycle.d.ts +24 -1
- package/dist/src/plugin/lifecycle.d.ts.map +1 -1
- package/dist/src/plugin/lifecycle.js +95 -8
- package/dist/src/plugin/lifecycle.js.map +1 -1
- package/dist/src/plugin/logger.d.ts +61 -10
- package/dist/src/plugin/logger.d.ts.map +1 -1
- package/dist/src/plugin/logger.js +134 -63
- package/dist/src/plugin/logger.js.map +1 -1
- package/dist/src/plugin/neutral-types.d.ts +42 -0
- package/dist/src/plugin/neutral-types.d.ts.map +1 -0
- package/dist/src/plugin/neutral-types.js +12 -0
- package/dist/src/plugin/neutral-types.js.map +1 -0
- package/dist/src/plugin/oauth-methods.d.ts +2 -1
- package/dist/src/plugin/oauth-methods.d.ts.map +1 -1
- package/dist/src/plugin/oauth-methods.js +173 -88
- package/dist/src/plugin/oauth-methods.js.map +1 -1
- package/dist/src/plugin/operator-settings.d.ts +34 -0
- package/dist/src/plugin/operator-settings.d.ts.map +1 -1
- package/dist/src/plugin/operator-settings.js +105 -2
- package/dist/src/plugin/operator-settings.js.map +1 -1
- package/dist/src/plugin/persist-account-pool.d.ts +63 -2
- package/dist/src/plugin/persist-account-pool.d.ts.map +1 -1
- package/dist/src/plugin/persist-account-pool.js +125 -2
- package/dist/src/plugin/persist-account-pool.js.map +1 -1
- package/dist/src/plugin/quota.d.ts +335 -35
- package/dist/src/plugin/quota.d.ts.map +1 -1
- package/dist/src/plugin/quota.js +825 -95
- package/dist/src/plugin/quota.js.map +1 -1
- package/dist/src/plugin/refresh-queue.d.ts +35 -5
- package/dist/src/plugin/refresh-queue.d.ts.map +1 -1
- package/dist/src/plugin/refresh-queue.js +50 -16
- package/dist/src/plugin/refresh-queue.js.map +1 -1
- package/dist/src/plugin/request-helpers.d.ts +30 -5
- package/dist/src/plugin/request-helpers.d.ts.map +1 -1
- package/dist/src/plugin/request-helpers.js +82 -17
- package/dist/src/plugin/request-helpers.js.map +1 -1
- package/dist/src/plugin/request.d.ts +63 -15
- package/dist/src/plugin/request.d.ts.map +1 -1
- package/dist/src/plugin/request.js +190 -60
- package/dist/src/plugin/request.js.map +1 -1
- package/dist/src/plugin/session-context.d.ts.map +1 -1
- package/dist/src/plugin/session-context.js +5 -2
- package/dist/src/plugin/session-context.js.map +1 -1
- package/dist/src/plugin/shared/local-grant.d.ts +26 -0
- package/dist/src/plugin/shared/local-grant.d.ts.map +1 -0
- package/dist/src/plugin/shared/local-grant.js +19 -0
- package/dist/src/plugin/shared/local-grant.js.map +1 -0
- package/dist/src/plugin/shared/request-cancellation.d.ts +12 -0
- package/dist/src/plugin/shared/request-cancellation.d.ts.map +1 -0
- package/dist/src/plugin/shared/request-cancellation.js +118 -0
- package/dist/src/plugin/shared/request-cancellation.js.map +1 -0
- package/dist/src/plugin/shared/request-services.d.ts +375 -0
- package/dist/src/plugin/shared/request-services.d.ts.map +1 -0
- package/dist/src/plugin/shared/request-services.js +1743 -0
- package/dist/src/plugin/shared/request-services.js.map +1 -0
- package/dist/src/plugin/shared/runtime.d.ts +217 -0
- package/dist/src/plugin/shared/runtime.d.ts.map +1 -0
- package/dist/src/plugin/shared/runtime.js +345 -0
- package/dist/src/plugin/shared/runtime.js.map +1 -0
- package/dist/src/plugin/shared/source-sidebar.d.ts +15 -0
- package/dist/src/plugin/shared/source-sidebar.d.ts.map +1 -0
- package/dist/src/plugin/shared/source-sidebar.js +41 -0
- package/dist/src/plugin/shared/source-sidebar.js.map +1 -0
- package/dist/src/plugin/shared/vault-menu.d.ts +5 -0
- package/dist/src/plugin/shared/vault-menu.d.ts.map +1 -0
- package/dist/src/plugin/shared/vault-menu.js +49 -0
- package/dist/src/plugin/shared/vault-menu.js.map +1 -0
- package/dist/src/plugin/shared/vault-request-credentials.d.ts +168 -0
- package/dist/src/plugin/shared/vault-request-credentials.d.ts.map +1 -0
- package/dist/src/plugin/shared/vault-request-credentials.js +485 -0
- package/dist/src/plugin/shared/vault-request-credentials.js.map +1 -0
- package/dist/src/plugin/storage.d.ts +127 -1
- package/dist/src/plugin/storage.d.ts.map +1 -1
- package/dist/src/plugin/storage.js +188 -3
- package/dist/src/plugin/storage.js.map +1 -1
- package/dist/src/plugin/token.d.ts +23 -1
- package/dist/src/plugin/token.d.ts.map +1 -1
- package/dist/src/plugin/token.js +117 -58
- package/dist/src/plugin/token.js.map +1 -1
- package/dist/src/plugin/ui/quota-status.d.ts +1 -10
- package/dist/src/plugin/ui/quota-status.d.ts.map +1 -1
- package/dist/src/plugin/ui/quota-status.js +6 -42
- package/dist/src/plugin/ui/quota-status.js.map +1 -1
- package/dist/src/plugin/vault-activation.d.ts +11 -0
- package/dist/src/plugin/vault-activation.d.ts.map +1 -0
- package/dist/src/plugin/vault-activation.js +53 -0
- package/dist/src/plugin/vault-activation.js.map +1 -0
- package/dist/src/plugin/vault-custody.d.ts +131 -0
- package/dist/src/plugin/vault-custody.d.ts.map +1 -0
- package/dist/src/plugin/vault-custody.js +381 -0
- package/dist/src/plugin/vault-custody.js.map +1 -0
- package/dist/src/quota-presentation.d.ts +18 -0
- package/dist/src/quota-presentation.d.ts.map +1 -0
- package/dist/src/quota-presentation.js +58 -0
- package/dist/src/quota-presentation.js.map +1 -0
- package/dist/src/rpc/notifications.d.ts +2 -2
- package/dist/src/rpc/notifications.d.ts.map +1 -1
- package/dist/src/rpc/notifications.js +1 -1
- package/dist/src/rpc/notifications.js.map +1 -1
- package/dist/src/rpc/port-file.d.ts +2 -12
- package/dist/src/rpc/port-file.d.ts.map +1 -1
- package/dist/src/rpc/port-file.js +5 -107
- package/dist/src/rpc/port-file.js.map +1 -1
- package/dist/src/rpc/protocol.d.ts +47 -16
- package/dist/src/rpc/protocol.d.ts.map +1 -1
- package/dist/src/rpc/rpc-client.d.ts +27 -3
- package/dist/src/rpc/rpc-client.d.ts.map +1 -1
- package/dist/src/rpc/rpc-client.js +55 -45
- package/dist/src/rpc/rpc-client.js.map +1 -1
- package/dist/src/rpc/rpc-server.d.ts +13 -2
- package/dist/src/rpc/rpc-server.d.ts.map +1 -1
- package/dist/src/rpc/rpc-server.js +38 -212
- package/dist/src/rpc/rpc-server.js.map +1 -1
- package/dist/src/server.d.ts +30 -0
- package/dist/src/server.d.ts.map +1 -0
- package/dist/src/server.js +29 -0
- package/dist/src/server.js.map +1 -0
- package/dist/src/sidebar-projection.d.ts +102 -0
- package/dist/src/sidebar-projection.d.ts.map +1 -0
- package/dist/src/sidebar-projection.js +146 -0
- package/dist/src/sidebar-projection.js.map +1 -0
- package/dist/src/sidebar-state.d.ts +13 -5
- package/dist/src/sidebar-state.d.ts.map +1 -1
- package/dist/src/sidebar-state.js +49 -16
- package/dist/src/sidebar-state.js.map +1 -1
- package/dist/src/tui/command-dialogs.d.ts +58 -52
- package/dist/src/tui/command-dialogs.d.ts.map +1 -1
- package/dist/src/tui/command-dialogs.js +379 -571
- package/dist/src/tui/command-dialogs.js.map +1 -1
- package/dist/src/tui/file-logger.d.ts +2 -3
- package/dist/src/tui/file-logger.d.ts.map +1 -1
- package/dist/src/tui/file-logger.js +21 -7
- package/dist/src/tui/file-logger.js.map +1 -1
- package/dist/src/tui/host-api.d.ts +196 -0
- package/dist/src/tui/host-api.d.ts.map +1 -0
- package/dist/src/tui/host-api.js +357 -0
- package/dist/src/tui/host-api.js.map +1 -0
- package/dist/src/tui/host-v1.d.ts +60 -0
- package/dist/src/tui/host-v1.d.ts.map +1 -0
- package/dist/src/tui/host-v1.js +147 -0
- package/dist/src/tui/host-v1.js.map +1 -0
- package/dist/src/tui/vault-setup.d.ts +98 -0
- package/dist/src/tui/vault-setup.d.ts.map +1 -0
- package/dist/src/tui/vault-setup.js +198 -0
- package/dist/src/tui/vault-setup.js.map +1 -0
- package/dist/src/tui.d.ts +4 -11
- package/dist/src/tui.d.ts.map +1 -1
- package/dist/src/tui.js +33 -75
- package/dist/src/tui.js.map +1 -1
- package/dist/tui-build-map.json +380 -0
- package/dist/tui-ga-build-map.json +187 -0
- package/dist/types/src/antigravity/oauth.d.ts +2 -0
- package/dist/types/src/antigravity/oauth.d.ts.map +1 -0
- package/dist/types/src/cli.d.ts +66 -0
- package/dist/types/src/cli.d.ts.map +1 -0
- package/dist/types/src/common-auth-embedded/commands/builtins.d.ts +71 -0
- package/dist/types/src/common-auth-embedded/commands/index.d.ts +10 -0
- package/dist/types/src/common-auth-embedded/commands/menu.d.ts +61 -0
- package/dist/types/src/common-auth-embedded/commands/model.d.ts +238 -0
- package/dist/types/src/common-auth-embedded/commands/pi.d.ts +23 -0
- package/dist/types/src/common-auth-embedded/commands/seam.d.ts +72 -0
- package/dist/types/src/common-auth-embedded/fs/refresh-file-lock.d.ts +33 -0
- package/dist/types/src/common-auth-embedded/logger/capture-sink.d.ts +14 -0
- package/dist/types/src/common-auth-embedded/logger/engine.d.ts +100 -0
- package/dist/types/src/common-auth-embedded/logger/index.d.ts +6 -0
- package/dist/types/src/common-auth-embedded/logger/redact.d.ts +11 -0
- package/dist/types/src/common-auth-embedded/quota/codec.d.ts +11 -0
- package/dist/types/src/common-auth-embedded/quota/format.d.ts +46 -0
- package/dist/types/src/common-auth-embedded/quota/index.d.ts +10 -0
- package/dist/types/src/common-auth-embedded/quota/map.d.ts +63 -0
- package/dist/types/src/common-auth-embedded/quota/merge.d.ts +48 -0
- package/dist/types/src/common-auth-embedded/quota/projection.d.ts +64 -0
- package/dist/types/src/common-auth-embedded/store/attribution.d.ts +28 -0
- package/dist/types/src/common-auth-embedded/store/errors.d.ts +55 -0
- package/dist/types/src/common-auth-embedded/store/hooks.d.ts +12 -0
- package/dist/types/src/common-auth-embedded/store/identity.d.ts +39 -0
- package/dist/types/src/common-auth-embedded/store/index.d.ts +21 -0
- package/dist/types/src/common-auth-embedded/store/mutate.d.ts +189 -0
- package/dist/types/src/common-auth-embedded/store/pool.d.ts +196 -0
- package/dist/types/src/common-auth-embedded/store/provider-state.d.ts +131 -0
- package/dist/types/src/common-auth-embedded/store/publication.d.ts +47 -0
- package/dist/types/src/common-auth-embedded/store/pull.d.ts +36 -0
- package/dist/types/src/common-auth-embedded/store/refresh-lock.d.ts +63 -0
- package/dist/types/src/common-auth-embedded/store/refresh.d.ts +72 -0
- package/dist/types/src/common-auth-embedded/store/rows.d.ts +313 -0
- package/dist/types/src/common-auth-embedded/store/runtime.d.ts +36 -0
- package/dist/types/src/common-auth-embedded/store/schema.d.ts +443 -0
- package/dist/types/src/common-auth-embedded/store/settings.d.ts +63 -0
- package/dist/types/src/common-auth-embedded/store/torn.d.ts +78 -0
- package/dist/types/src/constants.d.ts +3 -0
- package/dist/types/src/constants.d.ts.map +1 -0
- package/dist/types/src/ga/proxy-guard.d.ts +120 -0
- package/dist/types/src/ga/proxy-guard.d.ts.map +1 -0
- package/dist/types/src/ga/rpc/protocol.d.ts +504 -0
- package/dist/types/src/ga/rpc/protocol.d.ts.map +1 -0
- package/dist/types/src/ga/server/auth.d.ts +9 -0
- package/dist/types/src/ga/server/auth.d.ts.map +1 -0
- package/dist/types/src/ga/server/index.d.ts +576 -0
- package/dist/types/src/ga/server/index.d.ts.map +1 -0
- package/dist/types/src/hooks/auto-update-checker/cache.d.ts +3 -0
- package/dist/types/src/hooks/auto-update-checker/cache.d.ts.map +1 -0
- package/dist/types/src/hooks/auto-update-checker/checker.d.ts +16 -0
- package/dist/types/src/hooks/auto-update-checker/checker.d.ts.map +1 -0
- package/dist/types/src/hooks/auto-update-checker/constants.d.ts +9 -0
- package/dist/types/src/hooks/auto-update-checker/constants.d.ts.map +1 -0
- package/dist/types/src/hooks/auto-update-checker/index.d.ts +34 -0
- package/dist/types/src/hooks/auto-update-checker/index.d.ts.map +1 -0
- package/dist/types/src/hooks/auto-update-checker/logging.d.ts +3 -0
- package/dist/types/src/hooks/auto-update-checker/logging.d.ts.map +1 -0
- package/dist/types/src/hooks/auto-update-checker/types.d.ts +25 -0
- package/dist/types/src/hooks/auto-update-checker/types.d.ts.map +1 -0
- package/dist/types/src/logging/provider-key-policy.d.ts +9 -0
- package/dist/types/src/logging/provider-key-policy.d.ts.map +1 -0
- package/dist/types/src/plugin/account-access.d.ts +214 -0
- package/dist/types/src/plugin/account-access.d.ts.map +1 -0
- package/dist/types/src/plugin/account-blocks.d.ts +102 -0
- package/dist/types/src/plugin/account-blocks.d.ts.map +1 -0
- package/dist/types/src/plugin/account-command-oauth.d.ts +34 -0
- package/dist/types/src/plugin/account-command-oauth.d.ts.map +1 -0
- package/dist/types/src/plugin/accounts.d.ts +94 -0
- package/dist/types/src/plugin/accounts.d.ts.map +1 -0
- package/dist/types/src/plugin/agy-request-metadata.d.ts +2 -0
- package/dist/types/src/plugin/agy-request-metadata.d.ts.map +1 -0
- package/dist/types/src/plugin/agy-transport.d.ts +2 -0
- package/dist/types/src/plugin/agy-transport.d.ts.map +1 -0
- package/dist/types/src/plugin/auth-doctor.d.ts +30 -0
- package/dist/types/src/plugin/auth-doctor.d.ts.map +1 -0
- package/dist/types/src/plugin/auth-drift.d.ts +13 -0
- package/dist/types/src/plugin/auth-drift.d.ts.map +1 -0
- package/dist/types/src/plugin/auth-loader.d.ts +114 -0
- package/dist/types/src/plugin/auth-loader.d.ts.map +1 -0
- package/dist/types/src/plugin/auth.d.ts +2 -0
- package/dist/types/src/plugin/auth.d.ts.map +1 -0
- package/dist/types/src/plugin/background-quota-refresh.d.ts +192 -0
- package/dist/types/src/plugin/background-quota-refresh.d.ts.map +1 -0
- package/dist/types/src/plugin/cache/signature-cache.d.ts +156 -0
- package/dist/types/src/plugin/cache/signature-cache.d.ts.map +1 -0
- package/dist/types/src/plugin/cache.d.ts +109 -0
- package/dist/types/src/plugin/cache.d.ts.map +1 -0
- package/dist/types/src/plugin/catalog.d.ts +9 -0
- package/dist/types/src/plugin/catalog.d.ts.map +1 -0
- package/dist/types/src/plugin/cli.d.ts +44 -0
- package/dist/types/src/plugin/cli.d.ts.map +1 -0
- package/dist/types/src/plugin/command-apply.d.ts +58 -0
- package/dist/types/src/plugin/command-apply.d.ts.map +1 -0
- package/dist/types/src/plugin/command-data.d.ts +330 -0
- package/dist/types/src/plugin/command-data.d.ts.map +1 -0
- package/dist/types/src/plugin/commands.d.ts +164 -0
- package/dist/types/src/plugin/commands.d.ts.map +1 -0
- package/dist/types/src/plugin/config/index.d.ts +16 -0
- package/dist/types/src/plugin/config/index.d.ts.map +1 -0
- package/dist/types/src/plugin/config/loader.d.ts +72 -0
- package/dist/types/src/plugin/config/loader.d.ts.map +1 -0
- package/dist/types/src/plugin/config/models.d.ts +3 -0
- package/dist/types/src/plugin/config/models.d.ts.map +1 -0
- package/dist/types/src/plugin/config/operator-settings-schema.d.ts +29 -0
- package/dist/types/src/plugin/config/operator-settings-schema.d.ts.map +1 -0
- package/dist/types/src/plugin/config/schema.d.ts +162 -0
- package/dist/types/src/plugin/config/schema.d.ts.map +1 -0
- package/dist/types/src/plugin/config/updater.d.ts +55 -0
- package/dist/types/src/plugin/config/updater.d.ts.map +1 -0
- package/dist/types/src/plugin/config/writer.d.ts +41 -0
- package/dist/types/src/plugin/config/writer.d.ts.map +1 -0
- package/dist/types/src/plugin/core/streaming/index.d.ts +3 -0
- package/dist/types/src/plugin/core/streaming/index.d.ts.map +1 -0
- package/dist/types/src/plugin/core/streaming/transformer.d.ts +12 -0
- package/dist/types/src/plugin/core/streaming/transformer.d.ts.map +1 -0
- package/dist/types/src/plugin/core/streaming/types.d.ts +34 -0
- package/dist/types/src/plugin/core/streaming/types.d.ts.map +1 -0
- package/dist/types/src/plugin/debug.d.ts +144 -0
- package/dist/types/src/plugin/debug.d.ts.map +1 -0
- package/dist/types/src/plugin/dependencies.d.ts +129 -0
- package/dist/types/src/plugin/dependencies.d.ts.map +1 -0
- package/dist/types/src/plugin/errors.d.ts +55 -0
- package/dist/types/src/plugin/errors.d.ts.map +1 -0
- package/dist/types/src/plugin/event-handler.d.ts +53 -0
- package/dist/types/src/plugin/event-handler.d.ts.map +1 -0
- package/dist/types/src/plugin/fetch/retry-state.d.ts +61 -0
- package/dist/types/src/plugin/fetch/retry-state.d.ts.map +1 -0
- package/dist/types/src/plugin/fetch/warmup.d.ts +30 -0
- package/dist/types/src/plugin/fetch/warmup.d.ts.map +1 -0
- package/dist/types/src/plugin/fetch-interceptor.d.ts +114 -0
- package/dist/types/src/plugin/fetch-interceptor.d.ts.map +1 -0
- package/dist/types/src/plugin/fetch-routing.d.ts +31 -0
- package/dist/types/src/plugin/fetch-routing.d.ts.map +1 -0
- package/dist/types/src/plugin/fingerprint.d.ts +2 -0
- package/dist/types/src/plugin/fingerprint.d.ts.map +1 -0
- package/dist/types/src/plugin/ga-location-services.d.ts +389 -0
- package/dist/types/src/plugin/ga-location-services.d.ts.map +1 -0
- package/dist/types/src/plugin/gemini-dump.d.ts +72 -0
- package/dist/types/src/plugin/gemini-dump.d.ts.map +1 -0
- package/dist/types/src/plugin/google-search-tool.d.ts +10 -0
- package/dist/types/src/plugin/google-search-tool.d.ts.map +1 -0
- package/dist/types/src/plugin/image-saver.d.ts +6 -0
- package/dist/types/src/plugin/image-saver.d.ts.map +1 -0
- package/dist/types/src/plugin/index.d.ts +30 -0
- package/dist/types/src/plugin/index.d.ts.map +1 -0
- package/dist/types/src/plugin/killswitch.d.ts +93 -0
- package/dist/types/src/plugin/killswitch.d.ts.map +1 -0
- package/dist/types/src/plugin/lifecycle.d.ts +63 -0
- package/dist/types/src/plugin/lifecycle.d.ts.map +1 -0
- package/dist/types/src/plugin/logger.d.ts +83 -0
- package/dist/types/src/plugin/logger.d.ts.map +1 -0
- package/dist/types/src/plugin/logging-utils.d.ts +57 -0
- package/dist/types/src/plugin/logging-utils.d.ts.map +1 -0
- package/dist/types/src/plugin/model-registry.d.ts +2 -0
- package/dist/types/src/plugin/model-registry.d.ts.map +1 -0
- package/dist/types/src/plugin/neutral-types.d.ts +42 -0
- package/dist/types/src/plugin/neutral-types.d.ts.map +1 -0
- package/dist/types/src/plugin/oauth-login.d.ts +22 -0
- package/dist/types/src/plugin/oauth-login.d.ts.map +1 -0
- package/dist/types/src/plugin/oauth-methods.d.ts +43 -0
- package/dist/types/src/plugin/oauth-methods.d.ts.map +1 -0
- package/dist/types/src/plugin/operator-settings.d.ts +74 -0
- package/dist/types/src/plugin/operator-settings.d.ts.map +1 -0
- package/dist/types/src/plugin/persist-account-pool.d.ts +98 -0
- package/dist/types/src/plugin/persist-account-pool.d.ts.map +1 -0
- package/dist/types/src/plugin/project.d.ts +2 -0
- package/dist/types/src/plugin/project.d.ts.map +1 -0
- package/dist/types/src/plugin/prompt-context.d.ts +18 -0
- package/dist/types/src/plugin/prompt-context.d.ts.map +1 -0
- package/dist/types/src/plugin/quota.d.ts +441 -0
- package/dist/types/src/plugin/quota.d.ts.map +1 -0
- package/dist/types/src/plugin/recovery/constants.d.ts +22 -0
- package/dist/types/src/plugin/recovery/constants.d.ts.map +1 -0
- package/dist/types/src/plugin/recovery/storage.d.ts +24 -0
- package/dist/types/src/plugin/recovery/storage.d.ts.map +1 -0
- package/dist/types/src/plugin/recovery/types.d.ts +116 -0
- package/dist/types/src/plugin/recovery/types.d.ts.map +1 -0
- package/dist/types/src/plugin/recovery.d.ts +61 -0
- package/dist/types/src/plugin/recovery.d.ts.map +1 -0
- package/dist/types/src/plugin/refresh-queue.d.ts +133 -0
- package/dist/types/src/plugin/refresh-queue.d.ts.map +1 -0
- package/dist/types/src/plugin/request-helpers.d.ts +304 -0
- package/dist/types/src/plugin/request-helpers.d.ts.map +1 -0
- package/dist/types/src/plugin/request.d.ts +161 -0
- package/dist/types/src/plugin/request.d.ts.map +1 -0
- package/dist/types/src/plugin/rotation.d.ts +2 -0
- package/dist/types/src/plugin/rotation.d.ts.map +1 -0
- package/dist/types/src/plugin/search.d.ts +25 -0
- package/dist/types/src/plugin/search.d.ts.map +1 -0
- package/dist/types/src/plugin/server.d.ts +23 -0
- package/dist/types/src/plugin/server.d.ts.map +1 -0
- package/dist/types/src/plugin/session-context.d.ts +22 -0
- package/dist/types/src/plugin/session-context.d.ts.map +1 -0
- package/dist/types/src/plugin/shared/local-grant.d.ts +26 -0
- package/dist/types/src/plugin/shared/local-grant.d.ts.map +1 -0
- package/dist/types/src/plugin/shared/request-cancellation.d.ts +12 -0
- package/dist/types/src/plugin/shared/request-cancellation.d.ts.map +1 -0
- package/dist/types/src/plugin/shared/request-services.d.ts +375 -0
- package/dist/types/src/plugin/shared/request-services.d.ts.map +1 -0
- package/dist/types/src/plugin/shared/runtime.d.ts +217 -0
- package/dist/types/src/plugin/shared/runtime.d.ts.map +1 -0
- package/dist/types/src/plugin/shared/source-sidebar.d.ts +15 -0
- package/dist/types/src/plugin/shared/source-sidebar.d.ts.map +1 -0
- package/dist/types/src/plugin/shared/vault-menu.d.ts +5 -0
- package/dist/types/src/plugin/shared/vault-menu.d.ts.map +1 -0
- package/dist/types/src/plugin/shared/vault-request-credentials.d.ts +168 -0
- package/dist/types/src/plugin/shared/vault-request-credentials.d.ts.map +1 -0
- package/dist/types/src/plugin/storage.d.ts +221 -0
- package/dist/types/src/plugin/storage.d.ts.map +1 -0
- package/dist/types/src/plugin/stores/signature-store.d.ts +5 -0
- package/dist/types/src/plugin/stores/signature-store.d.ts.map +1 -0
- package/dist/types/src/plugin/thinking-recovery.d.ts +90 -0
- package/dist/types/src/plugin/thinking-recovery.d.ts.map +1 -0
- package/dist/types/src/plugin/token.d.ts +41 -0
- package/dist/types/src/plugin/token.d.ts.map +1 -0
- package/dist/types/src/plugin/transform/cross-model-sanitizer.d.ts +2 -0
- package/dist/types/src/plugin/transform/cross-model-sanitizer.d.ts.map +1 -0
- package/dist/types/src/plugin/transform/index.d.ts +2 -0
- package/dist/types/src/plugin/transform/index.d.ts.map +1 -0
- package/dist/types/src/plugin/transform/model-resolver.d.ts +2 -0
- package/dist/types/src/plugin/transform/model-resolver.d.ts.map +1 -0
- package/dist/types/src/plugin/transform/types.d.ts +2 -0
- package/dist/types/src/plugin/transform/types.d.ts.map +1 -0
- package/dist/types/src/plugin/types.d.ts +36 -0
- package/dist/types/src/plugin/types.d.ts.map +1 -0
- package/dist/types/src/plugin/ui/ansi.d.ts +32 -0
- package/dist/types/src/plugin/ui/ansi.d.ts.map +1 -0
- package/dist/types/src/plugin/ui/auth-menu.d.ts +59 -0
- package/dist/types/src/plugin/ui/auth-menu.d.ts.map +1 -0
- package/dist/types/src/plugin/ui/confirm.d.ts +2 -0
- package/dist/types/src/plugin/ui/confirm.d.ts.map +1 -0
- package/dist/types/src/plugin/ui/quota-status.d.ts +73 -0
- package/dist/types/src/plugin/ui/quota-status.d.ts.map +1 -0
- package/dist/types/src/plugin/ui/select.d.ts +23 -0
- package/dist/types/src/plugin/ui/select.d.ts.map +1 -0
- package/dist/types/src/plugin/vault-activation.d.ts +11 -0
- package/dist/types/src/plugin/vault-activation.d.ts.map +1 -0
- package/dist/types/src/plugin/vault-custody.d.ts +131 -0
- package/dist/types/src/plugin/vault-custody.d.ts.map +1 -0
- package/dist/types/src/plugin/version.d.ts +2 -0
- package/dist/types/src/plugin/version.d.ts.map +1 -0
- package/dist/types/src/quota-presentation.d.ts +18 -0
- package/dist/types/src/quota-presentation.d.ts.map +1 -0
- package/dist/types/src/rpc/notifications.d.ts +6 -0
- package/dist/types/src/rpc/notifications.d.ts.map +1 -0
- package/dist/types/src/rpc/protocol.d.ts +53 -0
- package/dist/types/src/rpc/protocol.d.ts.map +1 -0
- package/dist/types/src/rpc/rpc-dir.d.ts +4 -0
- package/dist/types/src/rpc/rpc-dir.d.ts.map +1 -0
- package/dist/types/src/rpc/rpc-server.d.ts +24 -0
- package/dist/types/src/rpc/rpc-server.d.ts.map +1 -0
- package/dist/types/src/server.d.ts +30 -0
- package/dist/types/src/server.d.ts.map +1 -0
- package/dist/types/src/sidebar-state.d.ts +365 -0
- package/dist/types/src/sidebar-state.d.ts.map +1 -0
- package/dist/types/src/tui/host-api.d.ts +196 -0
- package/dist/types/src/tui/host-api.d.ts.map +1 -0
- package/package.json +45 -18
- package/server.js +6 -0
- package/src/common-auth-embedded/NOTICE.txt +21 -0
- package/src/common-auth-embedded/auth-menu/accounts.d.ts +97 -0
- package/src/common-auth-embedded/auth-menu/accounts.js +387 -0
- package/src/common-auth-embedded/auth-menu/ansi.d.ts +26 -0
- package/src/common-auth-embedded/auth-menu/ansi.js +98 -0
- package/src/common-auth-embedded/auth-menu/confirm.d.ts +7 -0
- package/src/common-auth-embedded/auth-menu/confirm.js +21 -0
- package/src/common-auth-embedded/auth-menu/doctor.d.ts +52 -0
- package/src/common-auth-embedded/auth-menu/doctor.js +81 -0
- package/src/common-auth-embedded/auth-menu/index.d.ts +17 -0
- package/src/common-auth-embedded/auth-menu/index.js +12 -0
- package/src/common-auth-embedded/auth-menu/login.d.ts +55 -0
- package/src/common-auth-embedded/auth-menu/login.js +83 -0
- package/src/common-auth-embedded/auth-menu/menu.d.ts +59 -0
- package/src/common-auth-embedded/auth-menu/menu.js +73 -0
- package/src/common-auth-embedded/auth-menu/opencode-v1.d.ts +49 -0
- package/src/common-auth-embedded/auth-menu/opencode-v1.js +47 -0
- package/src/common-auth-embedded/auth-menu/select.d.ts +21 -0
- package/src/common-auth-embedded/auth-menu/select.js +159 -0
- package/src/common-auth-embedded/auth-menu/terminal.d.ts +43 -0
- package/src/common-auth-embedded/auth-menu/terminal.js +19 -0
- package/src/common-auth-embedded/claustrum/consumer.d.ts +102 -0
- package/src/common-auth-embedded/claustrum/consumer.js +298 -0
- package/src/common-auth-embedded/claustrum/custody.d.ts +175 -0
- package/src/common-auth-embedded/claustrum/custody.js +354 -0
- package/src/common-auth-embedded/claustrum/enrollment.d.ts +158 -0
- package/src/common-auth-embedded/claustrum/enrollment.js +759 -0
- package/src/common-auth-embedded/claustrum/errors.d.ts +16 -0
- package/src/common-auth-embedded/claustrum/errors.js +8 -0
- package/src/common-auth-embedded/claustrum/host-slot.d.ts +39 -0
- package/src/common-auth-embedded/claustrum/host-slot.js +72 -0
- package/src/common-auth-embedded/claustrum/index.d.ts +18 -0
- package/src/common-auth-embedded/claustrum/index.js +22 -0
- package/src/common-auth-embedded/claustrum/interlock.d.ts +27 -0
- package/src/common-auth-embedded/claustrum/interlock.js +29 -0
- package/src/common-auth-embedded/claustrum/roster.d.ts +208 -0
- package/src/common-auth-embedded/claustrum/roster.js +536 -0
- package/src/common-auth-embedded/commands/builtins.d.ts +71 -0
- package/src/common-auth-embedded/commands/builtins.js +534 -0
- package/src/common-auth-embedded/commands/index.d.ts +10 -0
- package/src/common-auth-embedded/commands/index.js +5 -0
- package/src/common-auth-embedded/commands/menu.d.ts +61 -0
- package/src/common-auth-embedded/commands/menu.js +300 -0
- package/src/common-auth-embedded/commands/model.d.ts +238 -0
- package/src/common-auth-embedded/commands/model.js +16 -0
- package/src/common-auth-embedded/commands/pi.d.ts +23 -0
- package/src/common-auth-embedded/commands/pi.js +206 -0
- package/src/common-auth-embedded/commands/seam.d.ts +72 -0
- package/src/common-auth-embedded/commands/seam.js +301 -0
- package/src/common-auth-embedded/fs/atomic-write.d.ts +20 -0
- package/src/common-auth-embedded/fs/atomic-write.js +80 -0
- package/src/common-auth-embedded/fs/index.d.ts +7 -0
- package/src/common-auth-embedded/fs/index.js +6 -0
- package/src/common-auth-embedded/fs/lock-constants.d.ts +14 -0
- package/src/common-auth-embedded/fs/lock-constants.js +14 -0
- package/src/common-auth-embedded/fs/refresh-file-lock.d.ts +33 -0
- package/src/common-auth-embedded/fs/refresh-file-lock.js +501 -0
- package/src/common-auth-embedded/fs/with-lock.d.ts +33 -0
- package/src/common-auth-embedded/fs/with-lock.js +48 -0
- package/src/common-auth-embedded/logger/capture-sink.d.ts +14 -0
- package/src/common-auth-embedded/logger/capture-sink.js +13 -0
- package/src/common-auth-embedded/logger/engine.d.ts +100 -0
- package/src/common-auth-embedded/logger/engine.js +246 -0
- package/src/common-auth-embedded/logger/index.d.ts +6 -0
- package/src/common-auth-embedded/logger/index.js +3 -0
- package/src/common-auth-embedded/logger/redact.d.ts +11 -0
- package/src/common-auth-embedded/logger/redact.js +83 -0
- package/src/common-auth-embedded/opencode2/errors.d.ts +25 -0
- package/src/common-auth-embedded/opencode2/errors.js +15 -0
- package/src/common-auth-embedded/opencode2/index.d.ts +8 -0
- package/src/common-auth-embedded/opencode2/index.js +4 -0
- package/src/common-auth-embedded/opencode2/install.d.ts +55 -0
- package/src/common-auth-embedded/opencode2/install.js +886 -0
- package/src/common-auth-embedded/opencode2/integration.d.ts +112 -0
- package/src/common-auth-embedded/opencode2/integration.js +143 -0
- package/src/common-auth-embedded/opencode2/sse.d.ts +12 -0
- package/src/common-auth-embedded/opencode2/sse.js +60 -0
- package/src/common-auth-embedded/opencode2/types.d.ts +413 -0
- package/src/common-auth-embedded/pi-slot/index.d.ts +3 -0
- package/src/common-auth-embedded/pi-slot/index.js +2 -0
- package/src/common-auth-embedded/pi-slot/lock.js +212 -0
- package/src/common-auth-embedded/pi-slot/slot.d.ts +49 -0
- package/src/common-auth-embedded/pi-slot/slot.js +383 -0
- package/src/common-auth-embedded/quota/codec.d.ts +11 -0
- package/src/common-auth-embedded/quota/codec.js +12 -0
- package/src/common-auth-embedded/quota/format.d.ts +46 -0
- package/src/common-auth-embedded/quota/format.js +138 -0
- package/src/common-auth-embedded/quota/index.d.ts +10 -0
- package/src/common-auth-embedded/quota/index.js +5 -0
- package/src/common-auth-embedded/quota/map.d.ts +63 -0
- package/src/common-auth-embedded/quota/map.js +105 -0
- package/src/common-auth-embedded/quota/merge.d.ts +48 -0
- package/src/common-auth-embedded/quota/merge.js +162 -0
- package/src/common-auth-embedded/quota/projection.d.ts +64 -0
- package/src/common-auth-embedded/quota/projection.js +134 -0
- package/src/common-auth-embedded/routing/admission.d.ts +93 -0
- package/src/common-auth-embedded/routing/admission.js +142 -0
- package/src/common-auth-embedded/routing/index.d.ts +8 -0
- package/src/common-auth-embedded/routing/index.js +4 -0
- package/src/common-auth-embedded/routing/ordered.d.ts +47 -0
- package/src/common-auth-embedded/routing/ordered.js +58 -0
- package/src/common-auth-embedded/routing/pins.d.ts +22 -0
- package/src/common-auth-embedded/routing/pins.js +34 -0
- package/src/common-auth-embedded/routing/sticky.d.ts +158 -0
- package/src/common-auth-embedded/routing/sticky.js +339 -0
- package/src/common-auth-embedded/rpc/client.d.ts +3 -0
- package/src/common-auth-embedded/rpc/client.js +2 -0
- package/src/common-auth-embedded/rpc/index.d.ts +10 -0
- package/src/common-auth-embedded/rpc/index.js +5 -0
- package/src/common-auth-embedded/rpc/notifications.d.ts +73 -0
- package/src/common-auth-embedded/rpc/notifications.js +100 -0
- package/src/common-auth-embedded/rpc/port-file.d.ts +33 -0
- package/src/common-auth-embedded/rpc/port-file.js +217 -0
- package/src/common-auth-embedded/rpc/rpc-client.d.ts +30 -0
- package/src/common-auth-embedded/rpc/rpc-client.js +253 -0
- package/src/common-auth-embedded/rpc/rpc-server.d.ts +58 -0
- package/src/common-auth-embedded/rpc/rpc-server.js +311 -0
- package/src/common-auth-embedded/rpc/server-registry.d.ts +11 -0
- package/src/common-auth-embedded/rpc/server-registry.js +47 -0
- package/src/common-auth-embedded/source-output.json +1326 -0
- package/src/common-auth-embedded/store/attribution.d.ts +28 -0
- package/src/common-auth-embedded/store/attribution.js +60 -0
- package/src/common-auth-embedded/store/errors.d.ts +55 -0
- package/src/common-auth-embedded/store/errors.js +38 -0
- package/src/common-auth-embedded/store/hooks.d.ts +12 -0
- package/src/common-auth-embedded/store/hooks.js +34 -0
- package/src/common-auth-embedded/store/identity.d.ts +39 -0
- package/src/common-auth-embedded/store/identity.js +79 -0
- package/src/common-auth-embedded/store/index.d.ts +21 -0
- package/src/common-auth-embedded/store/index.js +7 -0
- package/src/common-auth-embedded/store/mutate.d.ts +189 -0
- package/src/common-auth-embedded/store/mutate.js +500 -0
- package/src/common-auth-embedded/store/pool.d.ts +196 -0
- package/src/common-auth-embedded/store/pool.js +120 -0
- package/src/common-auth-embedded/store/provider-state.d.ts +131 -0
- package/src/common-auth-embedded/store/provider-state.js +226 -0
- package/src/common-auth-embedded/store/publication.d.ts +47 -0
- package/src/common-auth-embedded/store/publication.js +304 -0
- package/src/common-auth-embedded/store/pull.d.ts +36 -0
- package/src/common-auth-embedded/store/pull.js +143 -0
- package/src/common-auth-embedded/store/refresh-lock.d.ts +63 -0
- package/src/common-auth-embedded/store/refresh-lock.js +136 -0
- package/src/common-auth-embedded/store/refresh.d.ts +72 -0
- package/src/common-auth-embedded/store/refresh.js +225 -0
- package/src/common-auth-embedded/store/reserved.js +13 -0
- package/src/common-auth-embedded/store/rows.d.ts +313 -0
- package/src/common-auth-embedded/store/rows.js +1258 -0
- package/src/common-auth-embedded/store/runtime.d.ts +36 -0
- package/src/common-auth-embedded/store/runtime.js +68 -0
- package/src/common-auth-embedded/store/schema.d.ts +443 -0
- package/src/common-auth-embedded/store/schema.js +754 -0
- package/src/common-auth-embedded/store/settings.d.ts +63 -0
- package/src/common-auth-embedded/store/settings.js +120 -0
- package/src/common-auth-embedded/store/torn.d.ts +78 -0
- package/src/common-auth-embedded/store/torn.js +294 -0
- package/src/common-auth-embedded/tui/index.d.ts +8 -0
- package/src/common-auth-embedded/tui/index.js +21 -0
- package/src/common-auth-embedded/util/any-signal.js +42 -0
- package/src/plugin/command-data.ts +3 -0
- package/src/rpc/port-file.ts +6 -140
- package/src/rpc/protocol.ts +59 -24
- package/src/rpc/rpc-client.ts +101 -71
- package/src/sidebar-state.ts +82 -24
- package/src/tui/command-dialogs.tsx +412 -776
- package/src/tui/entry.d.mts +17 -0
- package/src/tui/entry.mjs +34 -66
- package/src/tui/file-logger.ts +22 -7
- package/src/tui-compiled/common-auth-embedded/logger/capture-sink.js +13 -0
- package/src/tui-compiled/common-auth-embedded/logger/engine.js +246 -0
- package/src/tui-compiled/common-auth-embedded/logger/index.js +3 -0
- package/src/tui-compiled/common-auth-embedded/logger/redact.js +83 -0
- package/src/tui-compiled/common-auth-embedded/quota/codec.js +12 -0
- package/src/tui-compiled/common-auth-embedded/quota/format.js +138 -0
- package/src/tui-compiled/common-auth-embedded/quota/index.js +5 -0
- package/src/tui-compiled/common-auth-embedded/quota/map.js +105 -0
- package/src/tui-compiled/common-auth-embedded/quota/merge.js +162 -0
- package/src/tui-compiled/common-auth-embedded/quota/projection.js +134 -0
- package/src/tui-compiled/common-auth-embedded/rpc/client.js +2 -0
- package/src/tui-compiled/common-auth-embedded/rpc/port-file.js +217 -0
- package/src/tui-compiled/common-auth-embedded/rpc/rpc-client.js +253 -0
- package/src/tui-compiled/logging/provider-key-policy.js +3 -0
- package/src/tui-compiled/quota-presentation.js +42 -0
- package/src/tui-compiled/rpc/rpc-client.js +35 -0
- package/src/tui-compiled/rpc/rpc-dir.js +13 -0
- package/src/tui-compiled/selector.js +21 -0
- package/src/tui-compiled/sidebar-state.js +401 -0
- package/src/tui-compiled/tui/command-dialogs.js +424 -0
- package/src/tui-compiled/tui/file-logger.js +73 -0
- package/src/tui-compiled/tui/host-api.js +269 -0
- package/src/tui-compiled/tui/host-v1.js +228 -0
- package/src/tui-compiled/tui-preferences.js +230 -0
- package/src/tui-compiled/{tui.tsx → tui.js} +140 -231
- package/src/tui-ga-compiled/host-ga.js +1304 -0
- package/src/tui-ga-compiled/selector.js +21 -0
- package/src/tui-ga-compiled/shared/07365a7d2ccade4c-host-api.js +269 -0
- package/src/tui-ga-compiled/shared/0e19a88ff3535906-command-dialogs.js +424 -0
- package/src/tui-ga-compiled/shared/1ff34afa7c42d196-projection.js +134 -0
- package/src/tui-ga-compiled/shared/77138df80c7ae006-map.js +105 -0
- package/src/tui-ga-compiled/shared/8ae1927e5910ea81-sidebar-projection.js +112 -0
- package/src/tui-ga-compiled/shared/98cc0c186c46c42d-quota-presentation.js +42 -0
- package/src/tui-ga-compiled/shared/aef2402f8fc342f0-format.js +138 -0
- package/src/tui-ga-compiled/shared/bf17cbee28e58197-index.js +5 -0
- package/src/tui-ga-compiled/shared/ca21dc417b36dc5d-codec.js +12 -0
- package/src/tui-ga-compiled/shared/ecc214300932dfb6-merge.js +162 -0
- package/src/tui-ga-raw/host-ga.tsx +1740 -0
- package/src/tui-ga-raw/selector.js +21 -0
- package/src/tui-ga-raw/shared/07365a7d2ccade4c-host-api.js +269 -0
- package/src/tui-ga-raw/shared/0e19a88ff3535906-command-dialogs.tsx +468 -0
- package/src/tui-ga-raw/shared/1ff34afa7c42d196-projection.js +134 -0
- package/src/tui-ga-raw/shared/77138df80c7ae006-map.js +105 -0
- package/src/tui-ga-raw/shared/8ae1927e5910ea81-sidebar-projection.js +112 -0
- package/src/tui-ga-raw/shared/98cc0c186c46c42d-quota-presentation.js +42 -0
- package/src/tui-ga-raw/shared/aef2402f8fc342f0-format.js +138 -0
- package/src/tui-ga-raw/shared/bf17cbee28e58197-index.js +5 -0
- package/src/tui-ga-raw/shared/ca21dc417b36dc5d-codec.js +12 -0
- package/src/tui-ga-raw/shared/ecc214300932dfb6-merge.js +162 -0
- package/src/tui-raw/common-auth-embedded/logger/capture-sink.js +13 -0
- package/src/tui-raw/common-auth-embedded/logger/engine.js +246 -0
- package/src/tui-raw/common-auth-embedded/logger/index.js +3 -0
- package/src/tui-raw/common-auth-embedded/logger/redact.js +83 -0
- package/src/tui-raw/common-auth-embedded/quota/codec.js +12 -0
- package/src/tui-raw/common-auth-embedded/quota/format.js +138 -0
- package/src/tui-raw/common-auth-embedded/quota/index.js +5 -0
- package/src/tui-raw/common-auth-embedded/quota/map.js +105 -0
- package/src/tui-raw/common-auth-embedded/quota/merge.js +162 -0
- package/src/tui-raw/common-auth-embedded/quota/projection.js +134 -0
- package/src/tui-raw/common-auth-embedded/rpc/client.js +2 -0
- package/src/tui-raw/common-auth-embedded/rpc/port-file.js +217 -0
- package/src/tui-raw/common-auth-embedded/rpc/rpc-client.js +253 -0
- package/src/tui-raw/logging/provider-key-policy.js +3 -0
- package/src/tui-raw/quota-presentation.js +42 -0
- package/src/tui-raw/rpc/rpc-client.js +35 -0
- package/src/tui-raw/rpc/rpc-dir.js +13 -0
- package/src/tui-raw/selector.js +21 -0
- package/src/tui-raw/sidebar-state.js +401 -0
- package/src/tui-raw/tui/command-dialogs.tsx +468 -0
- package/src/tui-raw/tui/file-logger.js +73 -0
- package/src/tui-raw/tui/host-api.js +269 -0
- package/src/tui-raw/tui/host-v1.tsx +249 -0
- package/src/tui-raw/tui-preferences.js +230 -0
- package/src/tui-raw/tui.tsx +1088 -0
- package/src/tui.tsx +58 -141
- package/tui.js +6 -0
- package/src/tui-compiled/plugin/command-data.ts +0 -931
- package/src/tui-compiled/rpc/port-file.ts +0 -143
- package/src/tui-compiled/rpc/protocol.ts +0 -31
- package/src/tui-compiled/rpc/rpc-client.ts +0 -102
- package/src/tui-compiled/rpc/rpc-dir.ts +0 -24
- package/src/tui-compiled/sidebar-state.ts +0 -991
- package/src/tui-compiled/tui/command-dialogs.tsx +0 -779
- package/src/tui-compiled/tui/file-logger.ts +0 -145
- package/src/tui-compiled/tui-preferences.ts +0 -416
package/dist/src/plugin/quota.js
CHANGED
|
@@ -14,9 +14,10 @@
|
|
|
14
14
|
* with `force: true` — manual quota screens must always refresh, even if
|
|
15
15
|
* the background manager has backed off.
|
|
16
16
|
*/
|
|
17
|
-
import { aggregateGeminiCliQuota, aggregateQuota, aggregateQuotaSummary, createQuotaManager, defaultKeyOf, fetchAvailableModels, fetchGeminiCliQuota, fetchQuotaSummary, getHealthTracker, } from '@cortexkit/antigravity-auth-core';
|
|
17
|
+
import { aggregateGeminiCliQuota, aggregateQuota, aggregateQuotaSummary, createQuotaManager, defaultKeyOf, fetchAvailableModels, fetchGeminiCliQuota, fetchQuotaSummary, fetchWithActiveTimeout, getHealthTracker, rowRefKey, sameRowRef, VAULT_ACCOUNT_REMEDY, } from '@cortexkit/antigravity-auth-core';
|
|
18
18
|
import { ANTIGRAVITY_ENDPOINT_FALLBACKS, ANTIGRAVITY_PROVIDER_ID, buildGeminiCliUserAgent, } from '../constants';
|
|
19
19
|
import { buildSidebarMachineStateFromAccounts, isAccountCurrent, setSidebarMachineState, } from '../sidebar-state';
|
|
20
|
+
import { createLocalAccountCredentials, } from './accounts';
|
|
20
21
|
import { accessTokenExpired, formatRefreshParts, parseRefreshParts, } from './auth';
|
|
21
22
|
import { logQuotaFetch, logQuotaStatus } from './debug';
|
|
22
23
|
import { buildAntigravityHarnessUserAgent } from './fingerprint';
|
|
@@ -41,7 +42,20 @@ export { classifyQuotaGroup, createQuotaManager, defaultKeyOf, } from '@cortexki
|
|
|
41
42
|
* no-op.
|
|
42
43
|
*/
|
|
43
44
|
export function createOpenCodeQuotaManager(client, providerId = ANTIGRAVITY_PROVIDER_ID, options = {}) {
|
|
44
|
-
const
|
|
45
|
+
const fetchPoolFileQuota = makeFetchAccountQuota(client, providerId, options.fetchVia);
|
|
46
|
+
const fetchAccountQuota = async (account, request) => {
|
|
47
|
+
const target = account;
|
|
48
|
+
const ref = target.rowRef;
|
|
49
|
+
if (options.mayRun && !(await options.mayRun()))
|
|
50
|
+
throw new Error(VAULT_ACCOUNT_REMEDY);
|
|
51
|
+
if (ref !== undefined) {
|
|
52
|
+
if (!options.fetchStoreAccountQuota)
|
|
53
|
+
throw new Error('Store quota authorization is unavailable');
|
|
54
|
+
const captured = { ...target, rowRef: ref };
|
|
55
|
+
return options.fetchStoreAccountQuota(captured, request);
|
|
56
|
+
}
|
|
57
|
+
return fetchPoolFileQuota(account, request);
|
|
58
|
+
};
|
|
45
59
|
const manager = createQuotaManager({
|
|
46
60
|
fetchAccountQuota,
|
|
47
61
|
keyOf: options.keyOf ?? defaultKeyOf,
|
|
@@ -49,16 +63,59 @@ export function createOpenCodeQuotaManager(client, providerId = ANTIGRAVITY_PROV
|
|
|
49
63
|
maxBackoffMs: options.maxBackoffMs,
|
|
50
64
|
fetchTimeoutMs: options.fetchTimeoutMs,
|
|
51
65
|
});
|
|
52
|
-
const originalRefreshAccount = manager.refreshAccount;
|
|
53
|
-
const originalRefreshAccounts = manager.refreshAccounts;
|
|
54
66
|
const getAccountsForSidebar = options.getAccountsForSidebar;
|
|
55
67
|
const getActiveIndexByFamily = options.getActiveIndexByFamily;
|
|
68
|
+
return withSidebarPushAfterRefresh(manager, options.publishSidebar ??
|
|
69
|
+
(getAccountsForSidebar
|
|
70
|
+
? (account) => pushSidebarQuotaSnapshot(getAccountsForSidebar, manager.getBackoffUntil(account), getActiveIndexByFamily)
|
|
71
|
+
: undefined));
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Build one location's quota manager. Backoff, in-flight dedupe and the
|
|
75
|
+
* per-account cache belong to the returned manager alone, so a second
|
|
76
|
+
* location never shares another location's backoff or cached results.
|
|
77
|
+
* Refreshes push a sidebar snapshot exactly like `createOpenCodeQuotaManager`
|
|
78
|
+
* does, but to the location's own state file and through its own logger.
|
|
79
|
+
*/
|
|
80
|
+
export function createLocationQuotaManager(options) {
|
|
81
|
+
if (typeof options?.logger?.debug !== 'function') {
|
|
82
|
+
throw new TypeError('createLocationQuotaManager requires a location logger');
|
|
83
|
+
}
|
|
84
|
+
if (typeof options.fetchAccountQuota !== 'function') {
|
|
85
|
+
throw new TypeError('createLocationQuotaManager requires a fetchAccountQuota function');
|
|
86
|
+
}
|
|
87
|
+
const manager = createQuotaManager({
|
|
88
|
+
fetchAccountQuota: options.fetchAccountQuota,
|
|
89
|
+
keyOf: options.keyOf ?? defaultKeyOf,
|
|
90
|
+
baseBackoffMs: options.baseBackoffMs,
|
|
91
|
+
maxBackoffMs: options.maxBackoffMs,
|
|
92
|
+
fetchTimeoutMs: options.fetchTimeoutMs,
|
|
93
|
+
});
|
|
94
|
+
const sidebar = options.sidebar;
|
|
95
|
+
const logger = options.logger;
|
|
96
|
+
return withSidebarPushAfterRefresh(manager, sidebar
|
|
97
|
+
? (account) => pushSidebarQuotaSnapshot(sidebar.getAccounts, manager.getBackoffUntil(account), sidebar.getActiveIndexByFamily, {
|
|
98
|
+
write: sidebar.write,
|
|
99
|
+
logger,
|
|
100
|
+
healthScore: sidebar.healthScore ?? null,
|
|
101
|
+
now: sidebar.now,
|
|
102
|
+
})
|
|
103
|
+
: undefined);
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Wrap a quota manager so every refresh started before disposal pushes one
|
|
107
|
+
* sidebar snapshot after it settles, and so `dispose()` waits for those
|
|
108
|
+
* pushes. A refresh that starts after disposal pushes nothing.
|
|
109
|
+
*/
|
|
110
|
+
function withSidebarPushAfterRefresh(manager, push) {
|
|
111
|
+
const originalRefreshAccount = manager.refreshAccount;
|
|
112
|
+
const originalRefreshAccounts = manager.refreshAccounts;
|
|
56
113
|
let disposed = false;
|
|
57
114
|
const inFlight = new Set();
|
|
58
115
|
const pushAfterRefresh = async (account) => {
|
|
59
|
-
if (!
|
|
116
|
+
if (!push)
|
|
60
117
|
return;
|
|
61
|
-
await
|
|
118
|
+
await push(account).catch(() => {
|
|
62
119
|
// Sidebar persistence remains best-effort when lock contention
|
|
63
120
|
// outlives its retry budget.
|
|
64
121
|
});
|
|
@@ -157,13 +214,22 @@ export async function checkAccountsQuota(accounts, client, providerId = ANTIGRAV
|
|
|
157
214
|
* On lock contention the error is logged-and-swallowed so a quota dialog
|
|
158
215
|
* never fails just because the sidebar file is busy.
|
|
159
216
|
*/
|
|
160
|
-
export async function pushSidebarQuotaSnapshot(getAccounts, backoffUntil = 0, getActiveIndexByFamily) {
|
|
217
|
+
export async function pushSidebarQuotaSnapshot(getAccounts, backoffUntil = 0, getActiveIndexByFamily, options = {}) {
|
|
161
218
|
const accounts = getAccounts();
|
|
162
219
|
if (!accounts || accounts.length === 0)
|
|
163
220
|
return;
|
|
164
221
|
const activeByFamily = getActiveIndexByFamily?.() ?? null;
|
|
222
|
+
// `undefined` keeps the process-wide health tracker the OpenCode 1 plugin
|
|
223
|
+
// uses; `null` means the caller has no health source and the sidebar shows
|
|
224
|
+
// its default.
|
|
225
|
+
const healthScore = options.healthScore === undefined
|
|
226
|
+
? (index) => getHealthTracker().getScore(index)
|
|
227
|
+
: options.healthScore;
|
|
228
|
+
const now = options.now ?? Date.now;
|
|
229
|
+
const write = options.write ??
|
|
230
|
+
((state) => setSidebarMachineState(state, options.stateFile === undefined ? {} : { stateFile: options.stateFile }));
|
|
165
231
|
try {
|
|
166
|
-
await
|
|
232
|
+
await write(buildSidebarMachineStateFromAccounts(accounts.map((entry) => ({
|
|
167
233
|
index: entry.index,
|
|
168
234
|
label: entry.label,
|
|
169
235
|
enabled: entry.enabled,
|
|
@@ -172,17 +238,21 @@ export async function pushSidebarQuotaSnapshot(getAccounts, backoffUntil = 0, ge
|
|
|
172
238
|
: false,
|
|
173
239
|
coolingDownUntil: entry.coolingDownUntil,
|
|
174
240
|
cachedQuota: entry.cachedQuota,
|
|
241
|
+
cachedQuotaUpdatedAt: entry.cachedQuotaUpdatedAt,
|
|
175
242
|
cachedQuotaAccountId: entry.cachedQuotaAccountId,
|
|
176
243
|
currentQuotaAccountId: entry.currentQuotaAccountId,
|
|
177
|
-
healthScore:
|
|
244
|
+
...(healthScore ? { healthScore: healthScore(entry.index) } : {}),
|
|
178
245
|
tier: entry.tier,
|
|
179
246
|
})), {
|
|
180
|
-
checkedAt:
|
|
247
|
+
checkedAt: now(),
|
|
181
248
|
quotaBackoffUntil: backoffUntil > 0 ? backoffUntil : undefined,
|
|
182
249
|
}));
|
|
183
250
|
}
|
|
184
251
|
catch (error) {
|
|
185
|
-
|
|
252
|
+
;
|
|
253
|
+
(options.logger ?? log).debug('sidebar-quota-write-failed', {
|
|
254
|
+
error: String(error),
|
|
255
|
+
});
|
|
186
256
|
}
|
|
187
257
|
}
|
|
188
258
|
/**
|
|
@@ -218,6 +288,428 @@ async function fetchLegacyModelsFallback(options) {
|
|
|
218
288
|
};
|
|
219
289
|
}
|
|
220
290
|
}
|
|
291
|
+
/**
|
|
292
|
+
* Fetches both quota payloads for one account with a bearer and project the
|
|
293
|
+
* caller already resolved: the windowed quota summary (with the legacy
|
|
294
|
+
* model-list fallback) and the Gemini CLI quota. Shared by the OpenCode 1
|
|
295
|
+
* fetcher and `createAuthorizedFetchAccountQuota`.
|
|
296
|
+
*/
|
|
297
|
+
async function fetchQuotaPayloads(options) {
|
|
298
|
+
const { accessToken, managedProjectId, projectId, fetchVia } = options;
|
|
299
|
+
// Two independent payload contracts: the windowed summary
|
|
300
|
+
// (with legacy fallback) and the gemini-CLI quota. They share
|
|
301
|
+
// access + project but target different endpoints, so the
|
|
302
|
+
// two 10s timeouts ran back-to-back for ~20s per account on
|
|
303
|
+
// modal open. Run them concurrently; either rejection is
|
|
304
|
+
// handled by its own branch and the result is still merged.
|
|
305
|
+
const fetchSummaryPayload = (async () => {
|
|
306
|
+
try {
|
|
307
|
+
const summaryResult = await fetchQuotaSummary({
|
|
308
|
+
accessToken,
|
|
309
|
+
managedProjectId,
|
|
310
|
+
projectId,
|
|
311
|
+
endpoints: ANTIGRAVITY_ENDPOINT_FALLBACKS,
|
|
312
|
+
userAgent: buildAntigravityHarnessUserAgent(),
|
|
313
|
+
timeoutMs: 10_000,
|
|
314
|
+
...(fetchVia ? { fetchVia } : {}),
|
|
315
|
+
});
|
|
316
|
+
return {
|
|
317
|
+
result: aggregateQuotaSummary(summaryResult.summary),
|
|
318
|
+
fellBackToLegacy: summaryResult.fellBackToLegacy ?? false,
|
|
319
|
+
};
|
|
320
|
+
}
|
|
321
|
+
catch {
|
|
322
|
+
return {
|
|
323
|
+
result: await fetchLegacyModelsFallback({
|
|
324
|
+
accessToken,
|
|
325
|
+
projectId,
|
|
326
|
+
fetchVia,
|
|
327
|
+
}),
|
|
328
|
+
fellBackToLegacy: true,
|
|
329
|
+
};
|
|
330
|
+
}
|
|
331
|
+
})();
|
|
332
|
+
// CLI fetch is independent of the summary fetch. A CLI failure must
|
|
333
|
+
// NOT kill the summary result, but it also must not be laundered into
|
|
334
|
+
// "No Gemini CLI quota available" (a permanent-looking status) when
|
|
335
|
+
// the real cause is a transient network error. Capture the error
|
|
336
|
+
// message separately so the annotated result can carry it.
|
|
337
|
+
let geminiCliFetchError;
|
|
338
|
+
const fetchGeminiCliPayload = fetchGeminiCliQuota({
|
|
339
|
+
accessToken,
|
|
340
|
+
projectId,
|
|
341
|
+
endpoints: ANTIGRAVITY_ENDPOINT_FALLBACKS,
|
|
342
|
+
userAgent: buildGeminiCliUserAgent(),
|
|
343
|
+
timeoutMs: 10_000,
|
|
344
|
+
...(fetchVia ? { fetchVia } : {}),
|
|
345
|
+
}).catch((error) => {
|
|
346
|
+
geminiCliFetchError = error instanceof Error ? error.message : String(error);
|
|
347
|
+
options.logger.debug('fetchGeminiCliQuota failed', {
|
|
348
|
+
error: geminiCliFetchError,
|
|
349
|
+
});
|
|
350
|
+
return { buckets: undefined };
|
|
351
|
+
});
|
|
352
|
+
const [summary, geminiCliResponse] = await Promise.all([
|
|
353
|
+
fetchSummaryPayload,
|
|
354
|
+
fetchGeminiCliPayload,
|
|
355
|
+
]);
|
|
356
|
+
return {
|
|
357
|
+
quota: summary.result,
|
|
358
|
+
geminiCliQuota: annotateGeminiCliQuota(geminiCliResponse, geminiCliFetchError),
|
|
359
|
+
fellBackToLegacy: summary.fellBackToLegacy,
|
|
360
|
+
};
|
|
361
|
+
}
|
|
362
|
+
/**
|
|
363
|
+
* The Gemini CLI quota summary for a `retrieveUserQuota` answer. An empty or
|
|
364
|
+
* missing answer carries an error: the fetch error when the request failed
|
|
365
|
+
* (a transient failure, not "no CLI quota configured"), else the generic
|
|
366
|
+
* "no quota" text.
|
|
367
|
+
*/
|
|
368
|
+
function annotateGeminiCliQuota(response, fetchError) {
|
|
369
|
+
const result = aggregateGeminiCliQuota(response);
|
|
370
|
+
if (response.buckets !== undefined && response.buckets.length > 0) {
|
|
371
|
+
return result;
|
|
372
|
+
}
|
|
373
|
+
return {
|
|
374
|
+
...result,
|
|
375
|
+
error: fetchError ??
|
|
376
|
+
(result.models.length === 0
|
|
377
|
+
? 'No Gemini CLI quota available'
|
|
378
|
+
: undefined),
|
|
379
|
+
};
|
|
380
|
+
}
|
|
381
|
+
/** Stops an outbound quota request after cancellation or a vault authorization refusal. */
|
|
382
|
+
class VaultQuotaCheckStoppedError extends Error {
|
|
383
|
+
name = 'VaultQuotaCheckStoppedError';
|
|
384
|
+
constructor() {
|
|
385
|
+
super('the quota check was stopped before this request was sent');
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
/** Refuses a second request using the same vault authorization. */
|
|
389
|
+
class VaultAdmissionReusedError extends Error {
|
|
390
|
+
name = 'VaultAdmissionReusedError';
|
|
391
|
+
constructor() {
|
|
392
|
+
super('a vault admission authorizes exactly one physical request');
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
/**
|
|
396
|
+
* Makes exactly one physical quota request for `ref` under a new served
|
|
397
|
+
* receipt from `source.send`. Inside the dispatch, `build` runs one of the
|
|
398
|
+
* core quota builders with that receipt's access token and project, so the
|
|
399
|
+
* Authorization header and the request project both come from the same
|
|
400
|
+
* receipt and are built after it was served.
|
|
401
|
+
*
|
|
402
|
+
* The builder reads a clone of the response; the original Response goes back
|
|
403
|
+
* to `send`. `send` needs the original to read its status: it reports a 401
|
|
404
|
+
* against that receipt's record version and may retry once, under a new
|
|
405
|
+
* receipt of the same credential and account, when the vault now serves a
|
|
406
|
+
* different record version (not necessarily a higher one; a restore can
|
|
407
|
+
* serve an older one). The retried request is built from the retry's
|
|
408
|
+
* receipt. A builder that tries a second request under one receipt is
|
|
409
|
+
* stopped before that request is sent.
|
|
410
|
+
*/
|
|
411
|
+
async function vaultQuotaAttempt(options,
|
|
412
|
+
/**
|
|
413
|
+
* True once the whole check must send nothing more (a receipt was refused
|
|
414
|
+
* elsewhere in the check, or it was aborted). Checked again right before
|
|
415
|
+
* the physical request, because serving this receipt may have taken a
|
|
416
|
+
* while.
|
|
417
|
+
*/
|
|
418
|
+
isStopped, build) {
|
|
419
|
+
const transport = options.transport ??
|
|
420
|
+
((url, init, extra) => fetchWithActiveTimeout(url, { ...init, signal: extra.signal ?? options.signal }, { timeoutMs: extra.timeoutMs }));
|
|
421
|
+
let attempt = {};
|
|
422
|
+
let dispatched = false;
|
|
423
|
+
try {
|
|
424
|
+
const response = await options.source.send(options.ref, async (admission, signal) => {
|
|
425
|
+
dispatched = true;
|
|
426
|
+
let used = false;
|
|
427
|
+
let served;
|
|
428
|
+
const fetchVia = async (url, init, extra) => {
|
|
429
|
+
// Marked before the request goes out, so a failed or still
|
|
430
|
+
// pending first request cannot let a second one use this receipt.
|
|
431
|
+
if (used)
|
|
432
|
+
throw new VaultAdmissionReusedError();
|
|
433
|
+
used = true;
|
|
434
|
+
if (isStopped())
|
|
435
|
+
throw new VaultQuotaCheckStoppedError();
|
|
436
|
+
served = await transport(url, init, {
|
|
437
|
+
...extra,
|
|
438
|
+
signal: signal ?? options.signal,
|
|
439
|
+
});
|
|
440
|
+
// The builder reads a clone; `send` gets the original Response,
|
|
441
|
+
// whose status it needs for 401 reporting.
|
|
442
|
+
return served.clone();
|
|
443
|
+
};
|
|
444
|
+
attempt = {};
|
|
445
|
+
try {
|
|
446
|
+
attempt.value = await build({
|
|
447
|
+
accessToken: admission.accessToken,
|
|
448
|
+
projectId: admission.projectId,
|
|
449
|
+
}, fetchVia);
|
|
450
|
+
}
|
|
451
|
+
catch (error) {
|
|
452
|
+
attempt.error = error;
|
|
453
|
+
}
|
|
454
|
+
if (served === undefined)
|
|
455
|
+
throw attempt.error ?? new Error('no request');
|
|
456
|
+
attempt.status = served.status;
|
|
457
|
+
if (attempt.value !== undefined) {
|
|
458
|
+
attempt.attribution = options.source.attribution(admission);
|
|
459
|
+
}
|
|
460
|
+
return served;
|
|
461
|
+
}, { site: 'quota', signal: options.signal });
|
|
462
|
+
await response.body?.cancel().catch(() => { });
|
|
463
|
+
}
|
|
464
|
+
catch (error) {
|
|
465
|
+
if (!dispatched)
|
|
466
|
+
return { error, refused: true };
|
|
467
|
+
attempt.error ??= error;
|
|
468
|
+
}
|
|
469
|
+
return attempt;
|
|
470
|
+
}
|
|
471
|
+
/**
|
|
472
|
+
* Fetches a vault account's quota: the windowed quota summary (with the
|
|
473
|
+
* legacy model-list fallback) and the Gemini CLI quota, from the same core
|
|
474
|
+
* builders and endpoint list the local check uses.
|
|
475
|
+
*
|
|
476
|
+
* Every physical request (each endpoint, each fallback, and the model
|
|
477
|
+
* list's retry without a project after a 403) is one `source.send` with a
|
|
478
|
+
* new served receipt, and that request's bearer and project come from that
|
|
479
|
+
* receipt alone. Nothing is authorized once and reused, and no local refresh
|
|
480
|
+
* token, token exchange, project cache or earlier grant is used. A refused
|
|
481
|
+
* receipt or an abort stops the check with no further request. Recording
|
|
482
|
+
* the reading (with the returned attributions and the source's
|
|
483
|
+
* `commitState`) is the caller's.
|
|
484
|
+
*/
|
|
485
|
+
export async function fetchVaultAccountQuota(options) {
|
|
486
|
+
// Shared by the summary and Gemini CLI halves, which run concurrently: a
|
|
487
|
+
// refusal in one stops requests in the other too, including one whose
|
|
488
|
+
// receipt was being served when the refusal happened.
|
|
489
|
+
const stopped = { value: false };
|
|
490
|
+
const isStopped = () => stopped.value || options.signal.aborted;
|
|
491
|
+
const attempt = async (build) => {
|
|
492
|
+
if (isStopped()) {
|
|
493
|
+
return { error: new VaultQuotaCheckStoppedError(), refused: true };
|
|
494
|
+
}
|
|
495
|
+
const result = await vaultQuotaAttempt(options, isStopped, build);
|
|
496
|
+
if (result.refused || options.signal.aborted)
|
|
497
|
+
stopped.value = true;
|
|
498
|
+
return result;
|
|
499
|
+
};
|
|
500
|
+
const fetchSummary = async () => {
|
|
501
|
+
for (const endpoint of ANTIGRAVITY_ENDPOINT_FALLBACKS) {
|
|
502
|
+
// An answer that cannot be aggregated counts as a failed request.
|
|
503
|
+
const result = await attempt(async (grant, fetchVia) => aggregateQuotaSummary((await fetchQuotaSummary({
|
|
504
|
+
accessToken: grant.accessToken,
|
|
505
|
+
projectId: grant.projectId,
|
|
506
|
+
endpoints: [endpoint],
|
|
507
|
+
userAgent: buildAntigravityHarnessUserAgent(),
|
|
508
|
+
timeoutMs: 10_000,
|
|
509
|
+
fetchVia,
|
|
510
|
+
})).summary));
|
|
511
|
+
if (result.value !== undefined) {
|
|
512
|
+
return {
|
|
513
|
+
result: result.value,
|
|
514
|
+
fellBackToLegacy: false,
|
|
515
|
+
...(result.attribution ? { attribution: result.attribution } : {}),
|
|
516
|
+
};
|
|
517
|
+
}
|
|
518
|
+
if (result.refused)
|
|
519
|
+
break;
|
|
520
|
+
}
|
|
521
|
+
// Fetch the legacy model list. After a 403, retry once without a project
|
|
522
|
+
// as a separate request with a newly authorized vault credential, rather
|
|
523
|
+
// than reusing the authorization from the rejected request.
|
|
524
|
+
for (const endpoint of ANTIGRAVITY_ENDPOINT_FALLBACKS) {
|
|
525
|
+
for (const withProject of [true, false]) {
|
|
526
|
+
const result = await attempt((grant, fetchVia) => fetchAvailableModels({
|
|
527
|
+
accessToken: grant.accessToken,
|
|
528
|
+
projectId: withProject ? grant.projectId : '',
|
|
529
|
+
endpoints: [endpoint],
|
|
530
|
+
userAgent: buildAntigravityHarnessUserAgent(),
|
|
531
|
+
timeoutMs: 10_000,
|
|
532
|
+
fetchVia,
|
|
533
|
+
}));
|
|
534
|
+
if (result.value !== undefined) {
|
|
535
|
+
return result.value.models
|
|
536
|
+
? {
|
|
537
|
+
result: aggregateQuota(result.value.models),
|
|
538
|
+
fellBackToLegacy: true,
|
|
539
|
+
...(result.attribution
|
|
540
|
+
? { attribution: result.attribution }
|
|
541
|
+
: {}),
|
|
542
|
+
}
|
|
543
|
+
: {
|
|
544
|
+
result: {
|
|
545
|
+
groups: {},
|
|
546
|
+
modelCount: 0,
|
|
547
|
+
error: 'Failed to fetch Antigravity quota (legacy fallback)',
|
|
548
|
+
},
|
|
549
|
+
fellBackToLegacy: true,
|
|
550
|
+
};
|
|
551
|
+
}
|
|
552
|
+
if (result.refused) {
|
|
553
|
+
return {
|
|
554
|
+
result: {
|
|
555
|
+
groups: {},
|
|
556
|
+
modelCount: 0,
|
|
557
|
+
error: 'Failed to fetch Antigravity quota',
|
|
558
|
+
},
|
|
559
|
+
fellBackToLegacy: true,
|
|
560
|
+
};
|
|
561
|
+
}
|
|
562
|
+
// Only a 403 for the request with a project is retried, without one.
|
|
563
|
+
if (!withProject || result.status !== 403)
|
|
564
|
+
break;
|
|
565
|
+
}
|
|
566
|
+
}
|
|
567
|
+
return {
|
|
568
|
+
result: {
|
|
569
|
+
groups: {},
|
|
570
|
+
modelCount: 0,
|
|
571
|
+
error: 'Failed to fetch Antigravity quota',
|
|
572
|
+
},
|
|
573
|
+
fellBackToLegacy: true,
|
|
574
|
+
};
|
|
575
|
+
};
|
|
576
|
+
const fetchGeminiCli = async () => {
|
|
577
|
+
const errors = [];
|
|
578
|
+
for (const endpoint of ANTIGRAVITY_ENDPOINT_FALLBACKS) {
|
|
579
|
+
const result = await attempt((grant, fetchVia) => fetchGeminiCliQuota({
|
|
580
|
+
accessToken: grant.accessToken,
|
|
581
|
+
projectId: grant.projectId,
|
|
582
|
+
endpoints: [endpoint],
|
|
583
|
+
userAgent: buildGeminiCliUserAgent(),
|
|
584
|
+
timeoutMs: 10_000,
|
|
585
|
+
fetchVia,
|
|
586
|
+
}));
|
|
587
|
+
if (result.value !== undefined) {
|
|
588
|
+
return {
|
|
589
|
+
response: result.value,
|
|
590
|
+
...(result.attribution ? { attribution: result.attribution } : {}),
|
|
591
|
+
};
|
|
592
|
+
}
|
|
593
|
+
errors.push(result.error instanceof Error
|
|
594
|
+
? result.error.message
|
|
595
|
+
: String(result.error));
|
|
596
|
+
if (result.refused)
|
|
597
|
+
break;
|
|
598
|
+
}
|
|
599
|
+
const error = errors.join('; ') || 'fetchGeminiCliQuota failed';
|
|
600
|
+
options.logger.debug('vault fetchGeminiCliQuota failed', { error });
|
|
601
|
+
return { response: { buckets: undefined }, error };
|
|
602
|
+
};
|
|
603
|
+
const [summary, cli] = await Promise.all([fetchSummary(), fetchGeminiCli()]);
|
|
604
|
+
return {
|
|
605
|
+
quota: summary.result,
|
|
606
|
+
geminiCliQuota: annotateGeminiCliQuota(cli.response, cli.error),
|
|
607
|
+
fellBackToLegacy: summary.fellBackToLegacy,
|
|
608
|
+
...(summary.attribution ? { quotaAttribution: summary.attribution } : {}),
|
|
609
|
+
...(cli.attribution ? { geminiCliAttribution: cli.attribution } : {}),
|
|
610
|
+
};
|
|
611
|
+
}
|
|
612
|
+
/** Raised inside a check when a request's local grant is no longer current. */
|
|
613
|
+
class LocalQuotaGrantStaleError extends Error {
|
|
614
|
+
name = 'LocalQuotaGrantStaleError';
|
|
615
|
+
}
|
|
616
|
+
/**
|
|
617
|
+
* A quota fetcher for LOCAL credentials whose bearer and project come from
|
|
618
|
+
* the caller's `authorize` callback instead of the account's stored refresh
|
|
619
|
+
* token. The network requests and result shape are the OpenCode 1
|
|
620
|
+
* fetcher's (`fetchQuotaPayloads`), sent through a transport that calls the
|
|
621
|
+
* authorization's `confirmSend` before every physical request.
|
|
622
|
+
*
|
|
623
|
+
* - A disabled account is answered without calling `authorize`.
|
|
624
|
+
* - A refused authorization, an authorization that is not `local`, or a
|
|
625
|
+
* throw from `authorize` is answered as an error result without any
|
|
626
|
+
* request.
|
|
627
|
+
* - Once `confirmSend` reports `stale`, no further request of the check is
|
|
628
|
+
* sent and the whole check is answered as an error, so a reading taken
|
|
629
|
+
* for a replaced or removed credential is never applied.
|
|
630
|
+
* - The result never carries `updatedAccount`: any credential or project
|
|
631
|
+
* change belongs to the `authorize` callback, which knows which stored row
|
|
632
|
+
* it may write to.
|
|
633
|
+
*/
|
|
634
|
+
export function createAuthorizedFetchAccountQuota(options) {
|
|
635
|
+
return async (account, signal) => {
|
|
636
|
+
const base = { index: 0, email: account.email };
|
|
637
|
+
if (account.enabled === false) {
|
|
638
|
+
return { ...base, status: 'disabled', disabled: true };
|
|
639
|
+
}
|
|
640
|
+
if (signal.aborted) {
|
|
641
|
+
return { ...base, status: 'error', disabled: false, error: 'aborted' };
|
|
642
|
+
}
|
|
643
|
+
let staleReason = null;
|
|
644
|
+
try {
|
|
645
|
+
// Called before the first await, so the callback sees the account as
|
|
646
|
+
// handed in; a synchronous throw lands in the catch below.
|
|
647
|
+
const authorizing = options.authorize(account, signal);
|
|
648
|
+
const authorization = await authorizing;
|
|
649
|
+
if (authorization.status !== 'authorized') {
|
|
650
|
+
return {
|
|
651
|
+
...base,
|
|
652
|
+
status: 'error',
|
|
653
|
+
disabled: false,
|
|
654
|
+
error: `quota check refused (${authorization.reason})`,
|
|
655
|
+
};
|
|
656
|
+
}
|
|
657
|
+
if (authorization.domain !== 'local') {
|
|
658
|
+
return {
|
|
659
|
+
...base,
|
|
660
|
+
status: 'error',
|
|
661
|
+
disabled: false,
|
|
662
|
+
error: 'quota check refused (unsupported credential domain)',
|
|
663
|
+
};
|
|
664
|
+
}
|
|
665
|
+
if (signal.aborted) {
|
|
666
|
+
return { ...base, status: 'error', disabled: false, error: 'aborted' };
|
|
667
|
+
}
|
|
668
|
+
const send = options.transport?.(signal) ??
|
|
669
|
+
((url, init, extra) => fetchWithActiveTimeout(url, { ...init, signal: extra.signal ?? signal }, { timeoutMs: extra.timeoutMs }));
|
|
670
|
+
const guarded = async (url, init, extra) => {
|
|
671
|
+
if (staleReason !== null)
|
|
672
|
+
throw new LocalQuotaGrantStaleError(staleReason);
|
|
673
|
+
const check = await authorization.confirmSend(signal);
|
|
674
|
+
if (check.status !== 'current') {
|
|
675
|
+
staleReason = check.reason;
|
|
676
|
+
throw new LocalQuotaGrantStaleError(check.reason);
|
|
677
|
+
}
|
|
678
|
+
// `confirmSend` (the check that the account still holds this exact
|
|
679
|
+
// credential and access token) has just finished; the request goes
|
|
680
|
+
// out at once, with this quota check's abort signal.
|
|
681
|
+
return send(url, init, { ...extra, signal });
|
|
682
|
+
};
|
|
683
|
+
const payloads = await fetchQuotaPayloads({
|
|
684
|
+
accessToken: authorization.accessToken,
|
|
685
|
+
managedProjectId: authorization.managedProjectId,
|
|
686
|
+
projectId: authorization.projectId,
|
|
687
|
+
fetchVia: guarded,
|
|
688
|
+
logger: options.logger,
|
|
689
|
+
});
|
|
690
|
+
if (staleReason !== null) {
|
|
691
|
+
return {
|
|
692
|
+
...base,
|
|
693
|
+
status: 'error',
|
|
694
|
+
disabled: false,
|
|
695
|
+
error: `quota check refused (stale grant: ${staleReason})`,
|
|
696
|
+
};
|
|
697
|
+
}
|
|
698
|
+
return {
|
|
699
|
+
...base,
|
|
700
|
+
status: 'ok',
|
|
701
|
+
disabled: false,
|
|
702
|
+
quota: payloads.quota,
|
|
703
|
+
geminiCliQuota: payloads.geminiCliQuota,
|
|
704
|
+
};
|
|
705
|
+
}
|
|
706
|
+
catch (error) {
|
|
707
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
708
|
+
options.logger.debug('authorized quota check failed', { error: message });
|
|
709
|
+
return { ...base, status: 'error', disabled: false, error: message };
|
|
710
|
+
}
|
|
711
|
+
};
|
|
712
|
+
}
|
|
221
713
|
function makeFetchAccountQuota(client, providerId, fetchVia) {
|
|
222
714
|
return async (account, signal) => {
|
|
223
715
|
const index = 0;
|
|
@@ -264,78 +756,16 @@ function makeFetchAccountQuota(client, providerId, fetchVia) {
|
|
|
264
756
|
// account record. The real managedProjectId lives on the persisted
|
|
265
757
|
// account, not in the packed refresh string.
|
|
266
758
|
const managedProjectId = authParts.managedProjectId ?? account.managedProjectId;
|
|
267
|
-
|
|
268
|
-
// (with legacy fallback) and the gemini-CLI quota. They share
|
|
269
|
-
// access + project but target different endpoints, so the
|
|
270
|
-
// two 10s timeouts ran back-to-back for ~20s per account on
|
|
271
|
-
// modal open. Run them concurrently; either rejection is
|
|
272
|
-
// handled by its own branch and the result is still merged.
|
|
273
|
-
const fetchSummaryPayload = (async () => {
|
|
274
|
-
try {
|
|
275
|
-
const summaryResult = await fetchQuotaSummary({
|
|
276
|
-
accessToken: auth.access ?? '',
|
|
277
|
-
managedProjectId,
|
|
278
|
-
projectId: projectContext.effectiveProjectId,
|
|
279
|
-
endpoints: ANTIGRAVITY_ENDPOINT_FALLBACKS,
|
|
280
|
-
userAgent: buildAntigravityHarnessUserAgent(),
|
|
281
|
-
timeoutMs: 10_000,
|
|
282
|
-
...(fetchVia ? { fetchVia } : {}),
|
|
283
|
-
});
|
|
284
|
-
return {
|
|
285
|
-
result: aggregateQuotaSummary(summaryResult.summary),
|
|
286
|
-
fellBackToLegacy: summaryResult.fellBackToLegacy ?? false,
|
|
287
|
-
};
|
|
288
|
-
}
|
|
289
|
-
catch {
|
|
290
|
-
return {
|
|
291
|
-
result: await fetchLegacyModelsFallback({
|
|
292
|
-
accessToken: auth.access ?? '',
|
|
293
|
-
projectId: projectContext.effectiveProjectId,
|
|
294
|
-
fetchVia,
|
|
295
|
-
}),
|
|
296
|
-
fellBackToLegacy: true,
|
|
297
|
-
};
|
|
298
|
-
}
|
|
299
|
-
})();
|
|
300
|
-
// CLI fetch is independent of the summary fetch. A CLI failure must
|
|
301
|
-
// NOT kill the summary result, but it also must not be laundered into
|
|
302
|
-
// "No Gemini CLI quota available" (a permanent-looking status) when
|
|
303
|
-
// the real cause is a transient network error. Capture the error
|
|
304
|
-
// message separately so the annotated result can carry it.
|
|
305
|
-
let geminiCliFetchError;
|
|
306
|
-
const fetchGeminiCliPayload = fetchGeminiCliQuota({
|
|
759
|
+
const payloads = await fetchQuotaPayloads({
|
|
307
760
|
accessToken: auth.access ?? '',
|
|
761
|
+
managedProjectId,
|
|
308
762
|
projectId: projectContext.effectiveProjectId,
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
timeoutMs: 10_000,
|
|
312
|
-
...(fetchVia ? { fetchVia } : {}),
|
|
313
|
-
}).catch((error) => {
|
|
314
|
-
geminiCliFetchError =
|
|
315
|
-
error instanceof Error ? error.message : String(error);
|
|
316
|
-
log.debug('fetchGeminiCliQuota failed', { error: geminiCliFetchError });
|
|
317
|
-
return { buckets: undefined };
|
|
763
|
+
fetchVia,
|
|
764
|
+
logger: log,
|
|
318
765
|
});
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
]);
|
|
323
|
-
quotaResult = summary.result;
|
|
324
|
-
fellBackToLegacy = summary.fellBackToLegacy;
|
|
325
|
-
const geminiCliQuotaResult = aggregateGeminiCliQuota(geminiCliResponse);
|
|
326
|
-
const annotated = geminiCliResponse.buckets === undefined ||
|
|
327
|
-
geminiCliResponse.buckets.length === 0
|
|
328
|
-
? {
|
|
329
|
-
...geminiCliQuotaResult,
|
|
330
|
-
error:
|
|
331
|
-
// A real fetch exception is a transient failure, not a
|
|
332
|
-
// "no CLI configured" scenario — propagate the actual message.
|
|
333
|
-
geminiCliFetchError ??
|
|
334
|
-
(geminiCliQuotaResult.models.length === 0
|
|
335
|
-
? 'No Gemini CLI quota available'
|
|
336
|
-
: undefined),
|
|
337
|
-
}
|
|
338
|
-
: geminiCliQuotaResult;
|
|
766
|
+
quotaResult = payloads.quota;
|
|
767
|
+
fellBackToLegacy = payloads.fellBackToLegacy;
|
|
768
|
+
const annotated = payloads.geminiCliQuota;
|
|
339
769
|
for (const [family, groupQuota] of Object.entries(quotaResult.groups)) {
|
|
340
770
|
const remainingPercent = (groupQuota.remainingFraction ?? 0) * 100;
|
|
341
771
|
logQuotaStatus(account.email, index, remainingPercent, family);
|
|
@@ -424,30 +854,55 @@ async function persistRotatedRefresh(client, providerId, auth) {
|
|
|
424
854
|
/**
|
|
425
855
|
* Build a per-account tier-loader callback for the background poller.
|
|
426
856
|
*
|
|
427
|
-
* Calls `loadManagedProject` (loadCodeAssist) directly
|
|
428
|
-
* `ensureProjectContext` cache
|
|
429
|
-
*
|
|
857
|
+
* Calls `loadManagedProject` (loadCodeAssist) directly. The
|
|
858
|
+
* `ensureProjectContext` cache answers from a known `managedProjectId`
|
|
859
|
+
* without asking Google, so for an account that already has a project it
|
|
860
|
+
* never returns a tier; the tier is only in loadCodeAssist's answer. One
|
|
861
|
+
* call per account per 24 h.
|
|
430
862
|
*
|
|
431
|
-
*
|
|
432
|
-
*
|
|
863
|
+
* An expired access token is refreshed the same way `makeFetchAccountQuota`
|
|
864
|
+
* refreshes it, so the lookup does not fail just because the token aged.
|
|
433
865
|
*
|
|
434
|
-
* `loadManagedProject`
|
|
435
|
-
*
|
|
436
|
-
* `
|
|
866
|
+
* `loadManagedProject` sends through the native TLS transport
|
|
867
|
+
* (`fetchWithAgyCliTransport`), not through a generic `fetch`, so a
|
|
868
|
+
* `fetchVia` override cannot intercept it; `ensureProjectContext` has the
|
|
869
|
+
* same limit. Tier lookup is best-effort; any failure resolves `null`.
|
|
437
870
|
*/
|
|
438
|
-
export function makeTierLoader(client, providerId) {
|
|
871
|
+
export function makeTierLoader(client, providerId, options = {}) {
|
|
439
872
|
return async (account) => {
|
|
440
873
|
try {
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
874
|
+
if (options.mayRun && !(await options.mayRun()))
|
|
875
|
+
return null;
|
|
876
|
+
let accessToken;
|
|
877
|
+
const target = account;
|
|
878
|
+
if (target.rowRef !== undefined) {
|
|
879
|
+
if (!options.authorizeStore)
|
|
445
880
|
return null;
|
|
446
|
-
|
|
881
|
+
const authorization = await options.authorizeStore(target);
|
|
882
|
+
if (authorization.status !== 'authorized' ||
|
|
883
|
+
authorization.domain !== 'local')
|
|
884
|
+
return null;
|
|
885
|
+
if (options.mayRun && !(await options.mayRun()))
|
|
886
|
+
return null;
|
|
887
|
+
if ((await authorization.confirmSend(new AbortController().signal))
|
|
888
|
+
.status !== 'current')
|
|
889
|
+
return null;
|
|
890
|
+
accessToken = authorization.accessToken;
|
|
891
|
+
}
|
|
892
|
+
else {
|
|
893
|
+
let auth = buildAuthFromAccount(account);
|
|
894
|
+
if (accessTokenExpired(auth)) {
|
|
895
|
+
const refreshed = await refreshAccessToken(auth, client, providerId);
|
|
896
|
+
if (!refreshed)
|
|
897
|
+
return null;
|
|
898
|
+
auth = refreshed;
|
|
899
|
+
}
|
|
900
|
+
accessToken = auth.access;
|
|
447
901
|
}
|
|
448
|
-
const accessToken = auth.access;
|
|
449
902
|
if (!accessToken)
|
|
450
903
|
return null;
|
|
904
|
+
if (options.mayRun && !(await options.mayRun()))
|
|
905
|
+
return null;
|
|
451
906
|
const payload = await loadManagedProject(accessToken);
|
|
452
907
|
if (!payload?.currentTier?.id)
|
|
453
908
|
return null;
|
|
@@ -465,4 +920,279 @@ export function makeTierLoader(client, providerId) {
|
|
|
465
920
|
}
|
|
466
921
|
};
|
|
467
922
|
}
|
|
923
|
+
/**
|
|
924
|
+
* The quota groups a reading carries, in one canonical text: groups by
|
|
925
|
+
* name, each with its model count, remaining fraction, reset time and
|
|
926
|
+
* windows in order; absent and null are the same. The in-memory groups a
|
|
927
|
+
* check records and the groups the store keeps for them give the same text,
|
|
928
|
+
* so the two can be compared exactly.
|
|
929
|
+
*/
|
|
930
|
+
function canonicalQuotaGroups(groups) {
|
|
931
|
+
const entries = Object.entries(groups ?? {})
|
|
932
|
+
.filter((entry) => entry[1] !== undefined)
|
|
933
|
+
.sort(([left], [right]) => (left < right ? -1 : left > right ? 1 : 0))
|
|
934
|
+
.map(([name, group]) => [
|
|
935
|
+
name,
|
|
936
|
+
group.modelCount,
|
|
937
|
+
group.remainingFraction ?? null,
|
|
938
|
+
group.resetTime ?? null,
|
|
939
|
+
group.windows?.map((window) => [
|
|
940
|
+
window.window,
|
|
941
|
+
window.remainingFraction ?? null,
|
|
942
|
+
window.resetTime ?? null,
|
|
943
|
+
]) ?? null,
|
|
944
|
+
]);
|
|
945
|
+
return JSON.stringify(entries);
|
|
946
|
+
}
|
|
947
|
+
/**
|
|
948
|
+
* The manager's account holding exactly `ref`. A RowRef names one
|
|
949
|
+
* credential version of one row (row id, credential epoch and recorded
|
|
950
|
+
* identity), so the lookup succeeds only while that row still holds that
|
|
951
|
+
* very credential.
|
|
952
|
+
*/
|
|
953
|
+
function heldAccount(manager, ref) {
|
|
954
|
+
return manager
|
|
955
|
+
.getAccounts()
|
|
956
|
+
.find((candidate) => candidate.ref !== undefined && sameRowRef(candidate.ref, ref));
|
|
957
|
+
}
|
|
958
|
+
/**
|
|
959
|
+
* Quota checks for one plugin account pool whose accounts come from the
|
|
960
|
+
* account store. One check, in order:
|
|
961
|
+
* 1. Capture the target's RowRef before any await, and take the manager's
|
|
962
|
+
* account holding exactly that ref; if none does, the check is refused.
|
|
963
|
+
* 2. If that account's access token has expired, refresh it through the
|
|
964
|
+
* repository, which commits the new token only to the row still holding
|
|
965
|
+
* that ref. Neither a token copied from an earlier read nor the host
|
|
966
|
+
* client is used.
|
|
967
|
+
* 3. Resolve the account's project from the local project cache; a newly
|
|
968
|
+
* resolved project is recorded through the manager on the account's ref.
|
|
969
|
+
* 4. Before every physical quota request, check that the manager still
|
|
970
|
+
* holds the same account object, at the same ref, enabled, with the same
|
|
971
|
+
* access token; otherwise no further request of the check is sent.
|
|
972
|
+
* 5. Hand the reading to the manager only while it still holds that exact
|
|
973
|
+
* ref; otherwise discard it. The manager's write can still be refused by
|
|
974
|
+
* the store, so `checkStoreQuota` reads the store back and counts a
|
|
975
|
+
* check only when the store holds this check's whole reading.
|
|
976
|
+
*
|
|
977
|
+
* Only accounts whose refresh token is stored locally use this service;
|
|
978
|
+
* vault-held accounts never do.
|
|
979
|
+
*/
|
|
980
|
+
export function createStoreQuotaService(options) {
|
|
981
|
+
const { manager, logger } = options;
|
|
982
|
+
const credentials = options.credentials ??
|
|
983
|
+
createLocalAccountCredentials(manager, { repository: options.repository });
|
|
984
|
+
const authorize = async (account) => {
|
|
985
|
+
const ref = account.rowRef;
|
|
986
|
+
if (ref === undefined) {
|
|
987
|
+
return { status: 'refused', reason: 'the account has no store ref' };
|
|
988
|
+
}
|
|
989
|
+
if (options.mayRun && !(await options.mayRun()))
|
|
990
|
+
return { status: 'refused', reason: VAULT_ACCOUNT_REMEDY };
|
|
991
|
+
const held = heldAccount(manager, ref);
|
|
992
|
+
if (held === undefined) {
|
|
993
|
+
return { status: 'refused', reason: 'the account changed or was removed' };
|
|
994
|
+
}
|
|
995
|
+
let auth = manager.toAuthDetails(held);
|
|
996
|
+
if (accessTokenExpired(auth)) {
|
|
997
|
+
const refreshed = await credentials.refresh(held);
|
|
998
|
+
if (refreshed === undefined) {
|
|
999
|
+
return { status: 'refused', reason: 'token refresh failed' };
|
|
1000
|
+
}
|
|
1001
|
+
auth = refreshed;
|
|
1002
|
+
}
|
|
1003
|
+
// A refresh keeps the credential epoch but can record the provider's
|
|
1004
|
+
// account identity on the ref and always brings a new access token, so
|
|
1005
|
+
// the grant is the account's ref and token as they are now, after it.
|
|
1006
|
+
const grantRef = held.ref;
|
|
1007
|
+
const accessToken = auth.access;
|
|
1008
|
+
if (grantRef === undefined || !accessToken) {
|
|
1009
|
+
return { status: 'refused', reason: 'no access token' };
|
|
1010
|
+
}
|
|
1011
|
+
if (options.mayRun && !(await options.mayRun()))
|
|
1012
|
+
return { status: 'refused', reason: VAULT_ACCOUNT_REMEDY };
|
|
1013
|
+
const project = await credentials.ensureProject(auth);
|
|
1014
|
+
if (options.mayRun && !(await options.mayRun()))
|
|
1015
|
+
return { status: 'refused', reason: VAULT_ACCOUNT_REMEDY };
|
|
1016
|
+
if (project.auth.refresh !== auth.refresh) {
|
|
1017
|
+
// The resolved project belongs to this credential: the manager records
|
|
1018
|
+
// only the project fields, fenced on this account's ref, so they can
|
|
1019
|
+
// never land on another row or a replaced credential.
|
|
1020
|
+
manager.updateFromAuth(held, { ...project.auth, access: accessToken });
|
|
1021
|
+
}
|
|
1022
|
+
const managedProjectId = parseRefreshParts(project.auth.refresh).managedProjectId ??
|
|
1023
|
+
held.managedProjectId;
|
|
1024
|
+
return {
|
|
1025
|
+
status: 'authorized',
|
|
1026
|
+
domain: 'local',
|
|
1027
|
+
accessToken,
|
|
1028
|
+
projectId: project.effectiveProjectId,
|
|
1029
|
+
...(managedProjectId !== undefined ? { managedProjectId } : {}),
|
|
1030
|
+
async confirmSend() {
|
|
1031
|
+
try {
|
|
1032
|
+
if (options.mayRun && !(await options.mayRun()))
|
|
1033
|
+
return { status: 'stale', reason: VAULT_ACCOUNT_REMEDY };
|
|
1034
|
+
if (held.ref === undefined || !sameRowRef(held.ref, grantRef)) {
|
|
1035
|
+
return { status: 'stale', reason: 'the credential changed' };
|
|
1036
|
+
}
|
|
1037
|
+
await credentials.assertGrantCurrent({
|
|
1038
|
+
account: held,
|
|
1039
|
+
accessToken,
|
|
1040
|
+
ref: grantRef,
|
|
1041
|
+
});
|
|
1042
|
+
if (options.mayRun && !(await options.mayRun()))
|
|
1043
|
+
return { status: 'stale', reason: VAULT_ACCOUNT_REMEDY };
|
|
1044
|
+
return { status: 'current' };
|
|
1045
|
+
}
|
|
1046
|
+
catch (error) {
|
|
1047
|
+
return {
|
|
1048
|
+
status: 'stale',
|
|
1049
|
+
reason: error instanceof Error ? error.message : String(error),
|
|
1050
|
+
};
|
|
1051
|
+
}
|
|
1052
|
+
},
|
|
1053
|
+
};
|
|
1054
|
+
};
|
|
1055
|
+
const fetchAccountQuota = createAuthorizedFetchAccountQuota({
|
|
1056
|
+
authorize: (account) => authorize(account),
|
|
1057
|
+
logger,
|
|
1058
|
+
transport: options.transport,
|
|
1059
|
+
});
|
|
1060
|
+
const quotaManager = createLocationQuotaManager({
|
|
1061
|
+
logger,
|
|
1062
|
+
fetchAccountQuota,
|
|
1063
|
+
// Backoff and cache are per credential: a re-authenticated row starts
|
|
1064
|
+
// fresh instead of inheriting its predecessor's state.
|
|
1065
|
+
keyOf: (account) => {
|
|
1066
|
+
const ref = account.rowRef;
|
|
1067
|
+
return ref === undefined ? defaultKeyOf(account) : rowRefKey(ref);
|
|
1068
|
+
},
|
|
1069
|
+
baseBackoffMs: options.baseBackoffMs,
|
|
1070
|
+
maxBackoffMs: options.maxBackoffMs,
|
|
1071
|
+
fetchTimeoutMs: options.fetchTimeoutMs,
|
|
1072
|
+
sidebar: options.sidebar,
|
|
1073
|
+
});
|
|
1074
|
+
const record = async (target, result) => {
|
|
1075
|
+
if (result.status !== 'ok' || result.quota === undefined) {
|
|
1076
|
+
return { status: 'failed', result };
|
|
1077
|
+
}
|
|
1078
|
+
// A completed poll does not authorize deferred local metadata writes after enrollment.
|
|
1079
|
+
if (options.mayRun && !(await options.mayRun()))
|
|
1080
|
+
return { status: 'discarded', result };
|
|
1081
|
+
const held = target.rowRef === undefined
|
|
1082
|
+
? undefined
|
|
1083
|
+
: heldAccount(manager, target.rowRef);
|
|
1084
|
+
if (held === undefined)
|
|
1085
|
+
return { status: 'discarded', result };
|
|
1086
|
+
manager.updateQuotaCache(held.index, result.quota.groups, held.parts.refreshToken);
|
|
1087
|
+
// Captured now: the account's fields may change before the store is
|
|
1088
|
+
// read back, and a later reading must not stand in for this one.
|
|
1089
|
+
return {
|
|
1090
|
+
status: 'recorded',
|
|
1091
|
+
result,
|
|
1092
|
+
reading: {
|
|
1093
|
+
cachedQuotaAccountId: held.cachedQuotaAccountId,
|
|
1094
|
+
cachedQuotaUpdatedAt: held.cachedQuotaUpdatedAt,
|
|
1095
|
+
groups: canonicalQuotaGroups(result.quota.groups),
|
|
1096
|
+
},
|
|
1097
|
+
};
|
|
1098
|
+
};
|
|
1099
|
+
const refreshAccount = async (target, refreshOptions = {}) => {
|
|
1100
|
+
const index = Math.max(0, manager
|
|
1101
|
+
.getAccountsForQuotaCheck()
|
|
1102
|
+
.findIndex((candidate) => candidate.rowRef !== undefined &&
|
|
1103
|
+
target.rowRef !== undefined &&
|
|
1104
|
+
sameRowRef(candidate.rowRef, target.rowRef)));
|
|
1105
|
+
const result = await quotaManager.refreshAccount(target, {
|
|
1106
|
+
index,
|
|
1107
|
+
force: refreshOptions.force === true,
|
|
1108
|
+
});
|
|
1109
|
+
return record(target, result);
|
|
1110
|
+
};
|
|
1111
|
+
return {
|
|
1112
|
+
quotaManager,
|
|
1113
|
+
fetchAccountQuota,
|
|
1114
|
+
authorizeLocalCheck: authorize,
|
|
1115
|
+
refreshAccount,
|
|
1116
|
+
async checkStoreQuota(refs) {
|
|
1117
|
+
// Targets are taken before any await, so each names the credential
|
|
1118
|
+
// the manager held when the action started.
|
|
1119
|
+
const targets = manager.getAccountsForQuotaCheck();
|
|
1120
|
+
const outcomes = await Promise.all(refs.map((ref) => {
|
|
1121
|
+
const target = targets.find((candidate) => candidate.rowRef !== undefined &&
|
|
1122
|
+
sameRowRef(candidate.rowRef, ref));
|
|
1123
|
+
return target === undefined
|
|
1124
|
+
? undefined
|
|
1125
|
+
: refreshAccount(target, { force: true });
|
|
1126
|
+
}));
|
|
1127
|
+
// Wait for queued quota writes before counting an account as checked.
|
|
1128
|
+
// If a failed write cannot be attributed to an account, no account's
|
|
1129
|
+
// quota reading is confirmed.
|
|
1130
|
+
let failedRows = new Set();
|
|
1131
|
+
try {
|
|
1132
|
+
await manager.saveToDisk();
|
|
1133
|
+
}
|
|
1134
|
+
catch (error) {
|
|
1135
|
+
// AccountManagerPersistError includes a flush report, but the public
|
|
1136
|
+
// core entry does not export its constructor. Identify it by name and
|
|
1137
|
+
// require at least one failed row ID. Only accounts outside the
|
|
1138
|
+
// reported failure list can still count as checked; missing or empty
|
|
1139
|
+
// failure details confirm none.
|
|
1140
|
+
const report = error instanceof Error && error.name === 'AccountManagerPersistError'
|
|
1141
|
+
? error.report
|
|
1142
|
+
: undefined;
|
|
1143
|
+
const failedIds = (report?.failures ?? []).map((failure) => failure.rowId);
|
|
1144
|
+
failedRows =
|
|
1145
|
+
report === undefined ||
|
|
1146
|
+
failedIds.length === 0 ||
|
|
1147
|
+
failedIds.some((id) => id === undefined)
|
|
1148
|
+
? 'all'
|
|
1149
|
+
: new Set(failedIds.filter((id) => id !== undefined));
|
|
1150
|
+
logger.debug('quota readings were not all persisted', {
|
|
1151
|
+
error: error instanceof Error ? error.message : String(error),
|
|
1152
|
+
});
|
|
1153
|
+
}
|
|
1154
|
+
const read = await options.repository.read();
|
|
1155
|
+
let checked = 0;
|
|
1156
|
+
refs.forEach((ref, position) => {
|
|
1157
|
+
const outcome = outcomes[position];
|
|
1158
|
+
if (outcome?.status !== 'recorded')
|
|
1159
|
+
return;
|
|
1160
|
+
if (failedRows === 'all' || failedRows.has(ref.id))
|
|
1161
|
+
return;
|
|
1162
|
+
const row = read.status === 'ready'
|
|
1163
|
+
? read.rows.find((candidate) => sameRowRef(candidate.ref, ref))
|
|
1164
|
+
: undefined;
|
|
1165
|
+
if (row?.quota.status !== 'present')
|
|
1166
|
+
return;
|
|
1167
|
+
const stored = row.quota.quota;
|
|
1168
|
+
// The store must hold exactly this check's reading: same identity
|
|
1169
|
+
// stamp, same time and the same groups. An older reading stored with
|
|
1170
|
+
// the same time, or another check's reading of the same row, does
|
|
1171
|
+
// not count.
|
|
1172
|
+
if (stored.cachedQuotaAccountId ===
|
|
1173
|
+
outcome.reading.cachedQuotaAccountId &&
|
|
1174
|
+
stored.cachedQuotaUpdatedAt ===
|
|
1175
|
+
outcome.reading.cachedQuotaUpdatedAt &&
|
|
1176
|
+
canonicalQuotaGroups(stored.cachedQuota) === outcome.reading.groups) {
|
|
1177
|
+
checked += 1;
|
|
1178
|
+
}
|
|
1179
|
+
});
|
|
1180
|
+
return { checked, notChecked: refs.length - checked };
|
|
1181
|
+
},
|
|
1182
|
+
async refreshAll(refreshOptions = {}) {
|
|
1183
|
+
const targets = manager.getAccountsForQuotaCheck();
|
|
1184
|
+
const results = await quotaManager.refreshAccounts(targets, {
|
|
1185
|
+
indexFor: (account) => targets.indexOf(account),
|
|
1186
|
+
force: refreshOptions.force === true,
|
|
1187
|
+
});
|
|
1188
|
+
return Promise.all(results.map((result, position) => {
|
|
1189
|
+
const target = targets[position];
|
|
1190
|
+
return target === undefined
|
|
1191
|
+
? { status: 'failed', result }
|
|
1192
|
+
: record(target, result);
|
|
1193
|
+
}));
|
|
1194
|
+
},
|
|
1195
|
+
dispose: () => quotaManager.dispose(),
|
|
1196
|
+
};
|
|
1197
|
+
}
|
|
468
1198
|
//# sourceMappingURL=quota.js.map
|