@cortexkit/opencode-antigravity-auth 1.1.0 → 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +225 -569
- package/dist/cli.js +4017 -0
- package/dist/cli.js.map +7 -0
- package/dist/index.d.ts +1 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +20742 -14586
- package/dist/index.js.map +4 -4
- package/dist/src/antigravity/oauth.d.ts +1 -1
- package/dist/src/antigravity/oauth.js +1 -1
- package/dist/src/cli.d.ts +21 -0
- package/dist/src/cli.d.ts.map +1 -0
- package/dist/src/cli.js +237 -0
- package/dist/src/cli.js.map +1 -0
- package/dist/src/constants.d.ts +1 -1
- package/dist/src/constants.js +1 -1
- package/dist/src/hooks/auto-update-checker/cache.d.ts.map +1 -1
- package/dist/src/hooks/auto-update-checker/cache.js +13 -13
- package/dist/src/hooks/auto-update-checker/cache.js.map +1 -1
- package/dist/src/hooks/auto-update-checker/checker.d.ts +1 -1
- package/dist/src/hooks/auto-update-checker/checker.d.ts.map +1 -1
- package/dist/src/hooks/auto-update-checker/checker.js +75 -51
- package/dist/src/hooks/auto-update-checker/checker.js.map +1 -1
- package/dist/src/hooks/auto-update-checker/constants.d.ts.map +1 -1
- package/dist/src/hooks/auto-update-checker/constants.js +12 -12
- package/dist/src/hooks/auto-update-checker/constants.js.map +1 -1
- package/dist/src/hooks/auto-update-checker/index.d.ts +6 -6
- package/dist/src/hooks/auto-update-checker/index.d.ts.map +1 -1
- package/dist/src/hooks/auto-update-checker/index.js +17 -17
- package/dist/src/hooks/auto-update-checker/index.js.map +1 -1
- package/dist/src/hooks/auto-update-checker/logging.js +2 -2
- package/dist/src/hooks/auto-update-checker/logging.js.map +1 -1
- package/dist/src/hooks/auto-update-checker/types.d.ts.map +1 -1
- package/dist/src/plugin/account-access.d.ts +99 -0
- package/dist/src/plugin/account-access.d.ts.map +1 -0
- package/dist/src/plugin/account-access.js +480 -0
- package/dist/src/plugin/account-access.js.map +1 -0
- package/dist/src/plugin/account-command-oauth.d.ts +34 -0
- package/dist/src/plugin/account-command-oauth.d.ts.map +1 -0
- package/dist/src/plugin/account-command-oauth.js +156 -0
- package/dist/src/plugin/account-command-oauth.js.map +1 -0
- package/dist/src/plugin/accounts.d.ts +7 -256
- package/dist/src/plugin/accounts.d.ts.map +1 -1
- package/dist/src/plugin/accounts.js +31 -1367
- package/dist/src/plugin/accounts.js.map +1 -1
- package/dist/src/plugin/agy-request-metadata.d.ts +1 -1
- package/dist/src/plugin/agy-request-metadata.js +1 -1
- package/dist/src/plugin/agy-transport.d.ts +1 -1
- package/dist/src/plugin/agy-transport.js +1 -1
- package/dist/src/plugin/auth-doctor.d.ts +6 -6
- package/dist/src/plugin/auth-doctor.d.ts.map +1 -1
- package/dist/src/plugin/auth-doctor.js +74 -66
- package/dist/src/plugin/auth-doctor.js.map +1 -1
- package/dist/src/plugin/auth-drift.d.ts +4 -4
- package/dist/src/plugin/auth-drift.d.ts.map +1 -1
- package/dist/src/plugin/auth-drift.js +15 -15
- package/dist/src/plugin/auth-drift.js.map +1 -1
- package/dist/src/plugin/auth-loader.d.ts +50 -0
- package/dist/src/plugin/auth-loader.d.ts.map +1 -0
- package/dist/src/plugin/auth-loader.js +225 -0
- package/dist/src/plugin/auth-loader.js.map +1 -0
- package/dist/src/plugin/auth.d.ts +1 -1
- package/dist/src/plugin/auth.js +1 -1
- package/dist/src/plugin/background-quota-refresh.d.ts +146 -0
- package/dist/src/plugin/background-quota-refresh.d.ts.map +1 -0
- package/dist/src/plugin/background-quota-refresh.js +347 -0
- package/dist/src/plugin/background-quota-refresh.js.map +1 -0
- 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 +1 -1
- package/dist/src/plugin/cache/signature-cache.d.ts.map +1 -1
- package/dist/src/plugin/cache/signature-cache.js +23 -24
- package/dist/src/plugin/cache/signature-cache.js.map +1 -1
- package/dist/src/plugin/cache.d.ts +6 -5
- package/dist/src/plugin/cache.d.ts.map +1 -1
- package/dist/src/plugin/cache.js +21 -7
- package/dist/src/plugin/cache.js.map +1 -1
- package/dist/src/plugin/catalog.d.ts +23 -0
- package/dist/src/plugin/catalog.d.ts.map +1 -0
- package/dist/src/plugin/catalog.js +60 -0
- package/dist/src/plugin/catalog.js.map +1 -0
- package/dist/src/plugin/cli.d.ts +7 -7
- package/dist/src/plugin/cli.d.ts.map +1 -1
- package/dist/src/plugin/cli.js +62 -55
- package/dist/src/plugin/cli.js.map +1 -1
- package/dist/src/plugin/command-data.d.ts +329 -0
- package/dist/src/plugin/command-data.d.ts.map +1 -0
- package/dist/src/plugin/command-data.js +517 -0
- package/dist/src/plugin/command-data.js.map +1 -0
- package/dist/src/plugin/commands.d.ts +154 -0
- package/dist/src/plugin/commands.d.ts.map +1 -0
- package/dist/src/plugin/commands.js +746 -0
- package/dist/src/plugin/commands.js.map +1 -0
- package/dist/src/plugin/config/index.d.ts +2 -2
- package/dist/src/plugin/config/index.d.ts.map +1 -1
- package/dist/src/plugin/config/index.js +2 -2
- package/dist/src/plugin/config/index.js.map +1 -1
- package/dist/src/plugin/config/loader.d.ts +1 -1
- package/dist/src/plugin/config/loader.d.ts.map +1 -1
- package/dist/src/plugin/config/loader.js +18 -16
- package/dist/src/plugin/config/loader.js.map +1 -1
- package/dist/src/plugin/config/models.d.ts +2 -2
- package/dist/src/plugin/config/models.d.ts.map +1 -1
- package/dist/src/plugin/config/models.js +1 -1
- package/dist/src/plugin/config/models.js.map +1 -1
- package/dist/src/plugin/config/operator-settings-schema.d.ts +29 -0
- package/dist/src/plugin/config/operator-settings-schema.d.ts.map +1 -0
- package/dist/src/plugin/config/operator-settings-schema.js +28 -0
- package/dist/src/plugin/config/operator-settings-schema.js.map +1 -0
- package/dist/src/plugin/config/schema.d.ts +23 -2
- package/dist/src/plugin/config/schema.d.ts.map +1 -1
- package/dist/src/plugin/config/schema.js +109 -25
- package/dist/src/plugin/config/schema.js.map +1 -1
- package/dist/src/plugin/config/updater.d.ts.map +1 -1
- package/dist/src/plugin/config/updater.js +15 -15
- package/dist/src/plugin/config/updater.js.map +1 -1
- package/dist/src/plugin/config/writer.d.ts +34 -0
- package/dist/src/plugin/config/writer.d.ts.map +1 -0
- package/dist/src/plugin/config/writer.js +81 -0
- package/dist/src/plugin/config/writer.js.map +1 -0
- package/dist/src/plugin/core/streaming/index.d.ts +1 -1
- package/dist/src/plugin/core/streaming/index.d.ts.map +1 -1
- package/dist/src/plugin/core/streaming/index.js +1 -1
- package/dist/src/plugin/core/streaming/index.js.map +1 -1
- package/dist/src/plugin/core/streaming/transformer.d.ts.map +1 -1
- package/dist/src/plugin/core/streaming/transformer.js +85 -44
- package/dist/src/plugin/core/streaming/transformer.js.map +1 -1
- package/dist/src/plugin/core/streaming/types.d.ts.map +1 -1
- package/dist/src/plugin/debug.d.ts +10 -3
- package/dist/src/plugin/debug.d.ts.map +1 -1
- package/dist/src/plugin/debug.js +110 -47
- package/dist/src/plugin/debug.js.map +1 -1
- package/dist/src/plugin/dependencies.d.ts +129 -0
- package/dist/src/plugin/dependencies.d.ts.map +1 -0
- package/dist/src/plugin/dependencies.js +107 -0
- package/dist/src/plugin/dependencies.js.map +1 -0
- package/dist/src/plugin/errors.d.ts +27 -0
- package/dist/src/plugin/errors.d.ts.map +1 -1
- package/dist/src/plugin/errors.js +29 -3
- package/dist/src/plugin/errors.js.map +1 -1
- package/dist/src/plugin/event-handler.d.ts +53 -0
- package/dist/src/plugin/event-handler.d.ts.map +1 -0
- package/dist/src/plugin/event-handler.js +101 -0
- package/dist/src/plugin/event-handler.js.map +1 -0
- package/dist/src/plugin/fetch/retry-state.d.ts +61 -0
- package/dist/src/plugin/fetch/retry-state.d.ts.map +1 -0
- package/dist/src/plugin/fetch/retry-state.js +248 -0
- package/dist/src/plugin/fetch/retry-state.js.map +1 -0
- package/dist/src/plugin/fetch/warmup.d.ts +30 -0
- package/dist/src/plugin/fetch/warmup.d.ts.map +1 -0
- package/dist/src/plugin/fetch/warmup.js +76 -0
- package/dist/src/plugin/fetch/warmup.js.map +1 -0
- package/dist/src/plugin/fetch-interceptor.d.ts +59 -0
- package/dist/src/plugin/fetch-interceptor.d.ts.map +1 -0
- package/dist/src/plugin/fetch-interceptor.js +1399 -0
- package/dist/src/plugin/fetch-interceptor.js.map +1 -0
- package/dist/src/plugin/fetch-routing.d.ts +26 -0
- package/dist/src/plugin/fetch-routing.d.ts.map +1 -0
- package/dist/src/plugin/fetch-routing.js +99 -0
- package/dist/src/plugin/fetch-routing.js.map +1 -0
- package/dist/src/plugin/fingerprint.d.ts +1 -1
- package/dist/src/plugin/fingerprint.js +1 -1
- package/dist/src/plugin/gemini-dump.d.ts +5 -5
- package/dist/src/plugin/gemini-dump.d.ts.map +1 -1
- package/dist/src/plugin/gemini-dump.js +109 -55
- package/dist/src/plugin/gemini-dump.js.map +1 -1
- package/dist/src/plugin/google-search-tool.d.ts +9 -0
- package/dist/src/plugin/google-search-tool.d.ts.map +1 -0
- package/dist/src/plugin/google-search-tool.js +56 -0
- package/dist/src/plugin/google-search-tool.js.map +1 -0
- package/dist/src/plugin/image-saver.d.ts.map +1 -1
- package/dist/src/plugin/image-saver.js +16 -16
- package/dist/src/plugin/image-saver.js.map +1 -1
- package/dist/src/plugin/index.d.ts +30 -0
- package/dist/src/plugin/index.d.ts.map +1 -0
- package/dist/src/plugin/index.js +411 -0
- package/dist/src/plugin/index.js.map +1 -0
- package/dist/src/plugin/killswitch.d.ts +94 -0
- package/dist/src/plugin/killswitch.d.ts.map +1 -0
- package/dist/src/plugin/killswitch.js +197 -0
- package/dist/src/plugin/killswitch.js.map +1 -0
- package/dist/src/plugin/lifecycle.d.ts +40 -0
- package/dist/src/plugin/lifecycle.d.ts.map +1 -0
- package/dist/src/plugin/lifecycle.js +73 -0
- package/dist/src/plugin/lifecycle.js.map +1 -0
- package/dist/src/plugin/logger.d.ts +10 -1
- package/dist/src/plugin/logger.d.ts.map +1 -1
- package/dist/src/plugin/logger.js +38 -12
- package/dist/src/plugin/logger.js.map +1 -1
- package/dist/src/plugin/logging-utils.d.ts +35 -1
- package/dist/src/plugin/logging-utils.d.ts.map +1 -1
- package/dist/src/plugin/logging-utils.js +98 -15
- package/dist/src/plugin/logging-utils.js.map +1 -1
- package/dist/src/plugin/model-registry.d.ts +1 -1
- package/dist/src/plugin/model-registry.js +1 -1
- package/dist/src/plugin/oauth-login.d.ts +22 -0
- package/dist/src/plugin/oauth-login.d.ts.map +1 -0
- package/dist/src/plugin/oauth-login.js +37 -0
- package/dist/src/plugin/oauth-login.js.map +1 -0
- package/dist/src/plugin/oauth-methods.d.ts +42 -0
- package/dist/src/plugin/oauth-methods.d.ts.map +1 -0
- package/dist/src/plugin/oauth-methods.js +1276 -0
- package/dist/src/plugin/oauth-methods.js.map +1 -0
- package/dist/src/plugin/operator-settings.d.ts +40 -0
- package/dist/src/plugin/operator-settings.d.ts.map +1 -0
- package/dist/src/plugin/operator-settings.js +148 -0
- package/dist/src/plugin/operator-settings.js.map +1 -0
- package/dist/src/plugin/persist-account-pool.d.ts +37 -0
- package/dist/src/plugin/persist-account-pool.d.ts.map +1 -0
- package/dist/src/plugin/persist-account-pool.js +142 -0
- package/dist/src/plugin/persist-account-pool.js.map +1 -0
- package/dist/src/plugin/project.d.ts +1 -1
- package/dist/src/plugin/project.js +1 -1
- package/dist/src/plugin/prompt-context.d.ts.map +1 -1
- package/dist/src/plugin/prompt-context.js +11 -11
- package/dist/src/plugin/prompt-context.js.map +1 -1
- package/dist/src/plugin/quota.d.ts +138 -41
- package/dist/src/plugin/quota.d.ts.map +1 -1
- package/dist/src/plugin/quota.js +417 -285
- package/dist/src/plugin/quota.js.map +1 -1
- package/dist/src/plugin/recovery/constants.d.ts.map +1 -1
- package/dist/src/plugin/recovery/constants.js +24 -15
- package/dist/src/plugin/recovery/constants.js.map +1 -1
- package/dist/src/plugin/recovery/index.d.ts +3 -3
- package/dist/src/plugin/recovery/index.d.ts.map +1 -1
- package/dist/src/plugin/recovery/index.js +3 -3
- package/dist/src/plugin/recovery/index.js.map +1 -1
- package/dist/src/plugin/recovery/storage.d.ts +1 -1
- package/dist/src/plugin/recovery/storage.d.ts.map +1 -1
- package/dist/src/plugin/recovery/storage.js +31 -39
- package/dist/src/plugin/recovery/storage.js.map +1 -1
- package/dist/src/plugin/recovery/types.d.ts +12 -12
- package/dist/src/plugin/recovery/types.d.ts.map +1 -1
- package/dist/src/plugin/recovery.d.ts +3 -3
- package/dist/src/plugin/recovery.d.ts.map +1 -1
- package/dist/src/plugin/recovery.js +62 -58
- package/dist/src/plugin/recovery.js.map +1 -1
- package/dist/src/plugin/refresh-queue.d.ts +5 -2
- package/dist/src/plugin/refresh-queue.d.ts.map +1 -1
- package/dist/src/plugin/refresh-queue.js +37 -15
- package/dist/src/plugin/refresh-queue.js.map +1 -1
- package/dist/src/plugin/request-helpers.d.ts +1 -1
- package/dist/src/plugin/request-helpers.d.ts.map +1 -1
- package/dist/src/plugin/request-helpers.js +451 -352
- package/dist/src/plugin/request-helpers.js.map +1 -1
- package/dist/src/plugin/request.d.ts +7 -7
- package/dist/src/plugin/request.d.ts.map +1 -1
- package/dist/src/plugin/request.js +622 -384
- package/dist/src/plugin/request.js.map +1 -1
- package/dist/src/plugin/rotation.d.ts +1 -168
- package/dist/src/plugin/rotation.d.ts.map +1 -1
- package/dist/src/plugin/rotation.js +1 -327
- package/dist/src/plugin/rotation.js.map +1 -1
- package/dist/src/plugin/search.d.ts.map +1 -1
- package/dist/src/plugin/search.js +39 -35
- package/dist/src/plugin/search.js.map +1 -1
- package/dist/src/plugin/server.d.ts +1 -1
- package/dist/src/plugin/server.d.ts.map +1 -1
- package/dist/src/plugin/server.js +42 -37
- package/dist/src/plugin/server.js.map +1 -1
- package/dist/src/plugin/session-context.d.ts +2 -1
- package/dist/src/plugin/session-context.d.ts.map +1 -1
- package/dist/src/plugin/session-context.js +11 -7
- package/dist/src/plugin/session-context.js.map +1 -1
- package/dist/src/plugin/storage.d.ts +59 -120
- package/dist/src/plugin/storage.d.ts.map +1 -1
- package/dist/src/plugin/storage.js +140 -485
- package/dist/src/plugin/storage.js.map +1 -1
- package/dist/src/plugin/stores/signature-store.d.ts.map +1 -1
- package/dist/src/plugin/stores/signature-store.js.map +1 -1
- package/dist/src/plugin/thinking-recovery.d.ts.map +1 -1
- package/dist/src/plugin/thinking-recovery.js +35 -33
- package/dist/src/plugin/thinking-recovery.js.map +1 -1
- package/dist/src/plugin/token.d.ts +2 -2
- package/dist/src/plugin/token.d.ts.map +1 -1
- package/dist/src/plugin/token.js +30 -21
- package/dist/src/plugin/token.js.map +1 -1
- package/dist/src/plugin/transform/cross-model-sanitizer.d.ts +1 -1
- package/dist/src/plugin/transform/cross-model-sanitizer.js +1 -1
- package/dist/src/plugin/transform/index.d.ts +1 -1
- package/dist/src/plugin/transform/index.js +1 -1
- package/dist/src/plugin/transform/model-resolver.d.ts +1 -1
- package/dist/src/plugin/transform/model-resolver.js +1 -1
- package/dist/src/plugin/transform/types.d.ts +1 -1
- package/dist/src/plugin/transform/types.js +1 -1
- package/dist/src/plugin/types.d.ts +25 -69
- package/dist/src/plugin/types.d.ts.map +1 -1
- package/dist/src/plugin/ui/ansi.d.ts.map +1 -1
- package/dist/src/plugin/ui/ansi.js.map +1 -1
- package/dist/src/plugin/ui/auth-menu.d.ts +1 -1
- package/dist/src/plugin/ui/auth-menu.d.ts.map +1 -1
- package/dist/src/plugin/ui/auth-menu.js +84 -35
- package/dist/src/plugin/ui/auth-menu.js.map +1 -1
- package/dist/src/plugin/ui/confirm.d.ts.map +1 -1
- package/dist/src/plugin/ui/confirm.js.map +1 -1
- package/dist/src/plugin/ui/model-status.d.ts +3 -3
- package/dist/src/plugin/ui/model-status.d.ts.map +1 -1
- package/dist/src/plugin/ui/model-status.js +3 -3
- package/dist/src/plugin/ui/model-status.js.map +1 -1
- package/dist/src/plugin/ui/quota-status.d.ts +4 -4
- package/dist/src/plugin/ui/quota-status.d.ts.map +1 -1
- package/dist/src/plugin/ui/quota-status.js +49 -49
- package/dist/src/plugin/ui/quota-status.js.map +1 -1
- package/dist/src/plugin/ui/select.d.ts.map +1 -1
- package/dist/src/plugin/ui/select.js +22 -12
- package/dist/src/plugin/ui/select.js.map +1 -1
- package/dist/src/plugin/version.d.ts +1 -1
- package/dist/src/plugin/version.js +1 -1
- package/dist/src/rpc/notifications.d.ts +6 -0
- package/dist/src/rpc/notifications.d.ts.map +1 -0
- package/dist/src/rpc/notifications.js +46 -0
- package/dist/src/rpc/notifications.js.map +1 -0
- package/dist/src/rpc/port-file.d.ts +13 -0
- package/dist/src/rpc/port-file.d.ts.map +1 -0
- package/dist/src/rpc/port-file.js +109 -0
- package/dist/src/rpc/port-file.js.map +1 -0
- package/dist/src/rpc/protocol.d.ts +22 -0
- package/dist/src/rpc/protocol.d.ts.map +1 -0
- package/dist/src/rpc/protocol.js +1 -0
- package/dist/src/rpc/protocol.js.map +1 -0
- package/dist/src/rpc/rpc-client.d.ts +10 -0
- package/dist/src/rpc/rpc-client.d.ts.map +1 -0
- package/dist/src/rpc/rpc-client.js +58 -0
- package/dist/src/rpc/rpc-client.js.map +1 -0
- package/dist/src/rpc/rpc-dir.d.ts +4 -0
- package/dist/src/rpc/rpc-dir.d.ts.map +1 -0
- package/dist/src/rpc/rpc-dir.js +19 -0
- package/dist/src/rpc/rpc-dir.js.map +1 -0
- package/dist/src/rpc/rpc-server.d.ts +13 -0
- package/dist/src/rpc/rpc-server.d.ts.map +1 -0
- package/dist/src/rpc/rpc-server.js +231 -0
- package/dist/src/rpc/rpc-server.js.map +1 -0
- package/dist/src/sidebar-state.d.ts +357 -0
- package/dist/src/sidebar-state.d.ts.map +1 -0
- package/dist/src/sidebar-state.js +680 -0
- package/dist/src/sidebar-state.js.map +1 -0
- package/dist/src/tui/command-dialogs.d.ts +61 -0
- package/dist/src/tui/command-dialogs.d.ts.map +1 -0
- package/dist/src/tui/command-dialogs.js +595 -0
- package/dist/src/tui/command-dialogs.js.map +1 -0
- package/dist/src/tui/file-logger.d.ts +41 -0
- package/dist/src/tui/file-logger.d.ts.map +1 -0
- package/dist/src/tui/file-logger.js +114 -0
- package/dist/src/tui/file-logger.js.map +1 -0
- package/dist/src/tui-preferences.d.ts +40 -0
- package/dist/src/tui-preferences.d.ts.map +1 -0
- package/dist/src/tui-preferences.js +328 -0
- package/dist/src/tui-preferences.js.map +1 -0
- package/dist/src/tui.d.ts +68 -0
- package/dist/src/tui.d.ts.map +1 -0
- package/dist/src/tui.js +697 -0
- package/dist/src/tui.js.map +1 -0
- package/package.json +46 -22
- package/src/plugin/command-data.ts +931 -0
- package/src/rpc/port-file.ts +143 -0
- package/src/rpc/protocol.ts +31 -0
- package/src/rpc/rpc-client.ts +102 -0
- package/src/rpc/rpc-dir.ts +24 -0
- package/src/sidebar-state.ts +991 -0
- package/src/tui/command-dialogs.tsx +832 -0
- package/src/tui/entry.mjs +74 -0
- package/src/tui/file-logger.ts +145 -0
- package/src/tui-compiled/plugin/command-data.ts +931 -0
- package/src/tui-compiled/rpc/port-file.ts +143 -0
- package/src/tui-compiled/rpc/protocol.ts +31 -0
- package/src/tui-compiled/rpc/rpc-client.ts +102 -0
- package/src/tui-compiled/rpc/rpc-dir.ts +24 -0
- package/src/tui-compiled/sidebar-state.ts +991 -0
- package/src/tui-compiled/tui/command-dialogs.tsx +779 -0
- package/src/tui-compiled/tui/file-logger.ts +145 -0
- package/src/tui-compiled/tui-preferences.ts +416 -0
- package/src/tui-compiled/tui.tsx +1193 -0
- package/src/tui-preferences.ts +416 -0
- package/src/tui.tsx +1171 -0
- package/dist/src/plugin.d.ts +0 -48
- package/dist/src/plugin.d.ts.map +0 -1
- package/dist/src/plugin.js +0 -3311
- package/dist/src/plugin.js.map +0 -1
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Per-interceptor state that was previously module-global.
|
|
3
|
+
*
|
|
4
|
+
* The legacy plugin kept rate-limit cooldowns, account-failure counters, toast
|
|
5
|
+
* dedup flags, and empty-response attempt counters at module scope. That kept
|
|
6
|
+
* state alive across `dispose()`, which leaked warmup/rate-limit telemetry
|
|
7
|
+
* across unrelated plugin lifetimes. This class owns the same bookkeeping but
|
|
8
|
+
* scopes it to a single fetch interceptor instance.
|
|
9
|
+
*
|
|
10
|
+
* Every internal map is bounded by `MAX_MAP_ENTRIES`; once full, the oldest
|
|
11
|
+
* insertion is evicted before the new entry is recorded. This matches the
|
|
12
|
+
* warmup-state eviction policy and keeps long-lived interceptors from
|
|
13
|
+
* accumulating telemetry past the cap.
|
|
14
|
+
*
|
|
15
|
+
* `dispose()` is terminal: every mutating method becomes a no-op (or returns
|
|
16
|
+
* a documented identity value) once `disposed` flips to `true`. The plugin
|
|
17
|
+
* tear-down order may race with an in-flight fetch, so guards must return
|
|
18
|
+
* safe defaults rather than throw.
|
|
19
|
+
*/
|
|
20
|
+
const MAX_CONSECUTIVE_FAILURES = 5;
|
|
21
|
+
const FAILURE_COOLDOWN_MS = 30_000;
|
|
22
|
+
const FAILURE_STATE_RESET_MS = 120_000;
|
|
23
|
+
const RATE_LIMIT_DEDUP_WINDOW_MS = 2_000;
|
|
24
|
+
const RATE_LIMIT_STATE_RESET_MS = 120_000;
|
|
25
|
+
const RATE_LIMIT_TOAST_COOLDOWN_MS = 5_000;
|
|
26
|
+
const MAX_MAP_ENTRIES = 100;
|
|
27
|
+
/** Identity values returned by mutating methods once `disposed` flips. */
|
|
28
|
+
const DISPOSED_BACKOFF = {
|
|
29
|
+
attempt: 1,
|
|
30
|
+
delayMs: 1000,
|
|
31
|
+
isDuplicate: false,
|
|
32
|
+
};
|
|
33
|
+
const DISPOSED_FAILURE = {
|
|
34
|
+
failures: 0,
|
|
35
|
+
shouldCooldown: false,
|
|
36
|
+
cooldownMs: 0,
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* Evicts the oldest entry from `map` if it is at the cap. Maps preserve
|
|
40
|
+
* insertion order, so the first key from the iterator is the oldest. Returns
|
|
41
|
+
* the number of evicted entries (0 or 1).
|
|
42
|
+
*/
|
|
43
|
+
function evictOldestIfFull(map, key) {
|
|
44
|
+
if (map.has(key) || map.size < MAX_MAP_ENTRIES)
|
|
45
|
+
return 0;
|
|
46
|
+
const oldest = map.keys().next().value;
|
|
47
|
+
if (oldest === undefined)
|
|
48
|
+
return 0;
|
|
49
|
+
map.delete(oldest);
|
|
50
|
+
return 1;
|
|
51
|
+
}
|
|
52
|
+
export function createRetryState() {
|
|
53
|
+
const rateLimitStateByAccountQuota = new Map();
|
|
54
|
+
const accountFailureState = new Map();
|
|
55
|
+
const rateLimitToastCooldowns = new Map();
|
|
56
|
+
const emptyResponseAttempts = new Map();
|
|
57
|
+
let softQuotaToastShownFlag = false;
|
|
58
|
+
let rateLimitToastShownFlag = false;
|
|
59
|
+
let disposed = false;
|
|
60
|
+
function isDisposed() {
|
|
61
|
+
return disposed;
|
|
62
|
+
}
|
|
63
|
+
function cleanupToastCooldowns() {
|
|
64
|
+
if (rateLimitToastCooldowns.size <= MAX_MAP_ENTRIES)
|
|
65
|
+
return;
|
|
66
|
+
const now = Date.now();
|
|
67
|
+
for (const [key, time] of rateLimitToastCooldowns) {
|
|
68
|
+
if (now - time > RATE_LIMIT_TOAST_COOLDOWN_MS * 2) {
|
|
69
|
+
rateLimitToastCooldowns.delete(key);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
function getRateLimitBackoff(accountIndex, quotaKey, serverRetryAfterMs, maxBackoffMs = 60_000) {
|
|
74
|
+
if (isDisposed())
|
|
75
|
+
return DISPOSED_BACKOFF;
|
|
76
|
+
const now = Date.now();
|
|
77
|
+
const stateKey = `${accountIndex}:${quotaKey}`;
|
|
78
|
+
const previous = rateLimitStateByAccountQuota.get(stateKey);
|
|
79
|
+
if (previous && now - previous.lastAt < RATE_LIMIT_DEDUP_WINDOW_MS) {
|
|
80
|
+
const baseDelay = serverRetryAfterMs ?? 1000;
|
|
81
|
+
const backoffDelay = Math.min(baseDelay * 2 ** (previous.consecutive429 - 1), maxBackoffMs);
|
|
82
|
+
return {
|
|
83
|
+
attempt: previous.consecutive429,
|
|
84
|
+
delayMs: Math.max(baseDelay, backoffDelay),
|
|
85
|
+
isDuplicate: true,
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
const attempt = previous && now - previous.lastAt < RATE_LIMIT_STATE_RESET_MS
|
|
89
|
+
? previous.consecutive429 + 1
|
|
90
|
+
: 1;
|
|
91
|
+
evictOldestIfFull(rateLimitStateByAccountQuota, stateKey);
|
|
92
|
+
rateLimitStateByAccountQuota.set(stateKey, {
|
|
93
|
+
consecutive429: attempt,
|
|
94
|
+
lastAt: now,
|
|
95
|
+
quotaKey,
|
|
96
|
+
});
|
|
97
|
+
const baseDelay = serverRetryAfterMs ?? 1000;
|
|
98
|
+
const backoffDelay = Math.min(baseDelay * 2 ** (attempt - 1), maxBackoffMs);
|
|
99
|
+
return {
|
|
100
|
+
attempt,
|
|
101
|
+
delayMs: Math.max(baseDelay, backoffDelay),
|
|
102
|
+
isDuplicate: false,
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
function resetRateLimitState(accountIndex, quotaKey) {
|
|
106
|
+
if (isDisposed())
|
|
107
|
+
return;
|
|
108
|
+
const stateKey = `${accountIndex}:${quotaKey}`;
|
|
109
|
+
rateLimitStateByAccountQuota.delete(stateKey);
|
|
110
|
+
}
|
|
111
|
+
function resetAllRateLimitStateForAccount(accountIndex) {
|
|
112
|
+
if (isDisposed())
|
|
113
|
+
return;
|
|
114
|
+
for (const key of rateLimitStateByAccountQuota.keys()) {
|
|
115
|
+
if (key.startsWith(`${accountIndex}:`)) {
|
|
116
|
+
rateLimitStateByAccountQuota.delete(key);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
function headerStyleToQuotaKey(headerStyle, family) {
|
|
121
|
+
if (family === 'claude')
|
|
122
|
+
return 'claude';
|
|
123
|
+
return headerStyle === 'antigravity' ? 'gemini-antigravity' : 'gemini-cli';
|
|
124
|
+
}
|
|
125
|
+
function trackAccountFailure(accountIndex) {
|
|
126
|
+
if (isDisposed())
|
|
127
|
+
return DISPOSED_FAILURE;
|
|
128
|
+
const now = Date.now();
|
|
129
|
+
const previous = accountFailureState.get(accountIndex);
|
|
130
|
+
const failures = previous && now - previous.lastFailureAt < FAILURE_STATE_RESET_MS
|
|
131
|
+
? previous.consecutiveFailures + 1
|
|
132
|
+
: 1;
|
|
133
|
+
evictOldestIfFull(accountFailureState, accountIndex);
|
|
134
|
+
accountFailureState.set(accountIndex, {
|
|
135
|
+
consecutiveFailures: failures,
|
|
136
|
+
lastFailureAt: now,
|
|
137
|
+
});
|
|
138
|
+
const shouldCooldown = failures >= MAX_CONSECUTIVE_FAILURES;
|
|
139
|
+
const cooldownMs = shouldCooldown ? FAILURE_COOLDOWN_MS : 0;
|
|
140
|
+
return { failures, shouldCooldown, cooldownMs };
|
|
141
|
+
}
|
|
142
|
+
function resetAccountFailureState(accountIndex) {
|
|
143
|
+
if (isDisposed())
|
|
144
|
+
return;
|
|
145
|
+
accountFailureState.delete(accountIndex);
|
|
146
|
+
}
|
|
147
|
+
function shouldShowRateLimitToast(message) {
|
|
148
|
+
if (isDisposed())
|
|
149
|
+
return false;
|
|
150
|
+
cleanupToastCooldowns();
|
|
151
|
+
const toastKey = message.replace(/\d+/g, 'X');
|
|
152
|
+
const lastShown = rateLimitToastCooldowns.get(toastKey) ?? 0;
|
|
153
|
+
const now = Date.now();
|
|
154
|
+
if (now - lastShown < RATE_LIMIT_TOAST_COOLDOWN_MS) {
|
|
155
|
+
return false;
|
|
156
|
+
}
|
|
157
|
+
evictOldestIfFull(rateLimitToastCooldowns, toastKey);
|
|
158
|
+
rateLimitToastCooldowns.set(toastKey, now);
|
|
159
|
+
return true;
|
|
160
|
+
}
|
|
161
|
+
function markSoftQuotaToastShown() {
|
|
162
|
+
if (isDisposed())
|
|
163
|
+
return;
|
|
164
|
+
softQuotaToastShownFlag = true;
|
|
165
|
+
}
|
|
166
|
+
function markRateLimitToastShown() {
|
|
167
|
+
if (isDisposed())
|
|
168
|
+
return;
|
|
169
|
+
rateLimitToastShownFlag = true;
|
|
170
|
+
}
|
|
171
|
+
function softQuotaToastShown() {
|
|
172
|
+
return !isDisposed() && softQuotaToastShownFlag;
|
|
173
|
+
}
|
|
174
|
+
function rateLimitToastShown() {
|
|
175
|
+
return !isDisposed() && rateLimitToastShownFlag;
|
|
176
|
+
}
|
|
177
|
+
function resetAllAccountsBlockedToasts() {
|
|
178
|
+
if (isDisposed())
|
|
179
|
+
return;
|
|
180
|
+
softQuotaToastShownFlag = false;
|
|
181
|
+
rateLimitToastShownFlag = false;
|
|
182
|
+
}
|
|
183
|
+
function recordEmptyResponseAttempt(key) {
|
|
184
|
+
if (isDisposed())
|
|
185
|
+
return 0;
|
|
186
|
+
const next = (emptyResponseAttempts.get(key) ?? 0) + 1;
|
|
187
|
+
evictOldestIfFull(emptyResponseAttempts, key);
|
|
188
|
+
emptyResponseAttempts.set(key, next);
|
|
189
|
+
return next;
|
|
190
|
+
}
|
|
191
|
+
function clearEmptyResponseAttempts() {
|
|
192
|
+
if (isDisposed())
|
|
193
|
+
return;
|
|
194
|
+
emptyResponseAttempts.clear();
|
|
195
|
+
}
|
|
196
|
+
function clear() {
|
|
197
|
+
if (isDisposed())
|
|
198
|
+
return;
|
|
199
|
+
rateLimitStateByAccountQuota.clear();
|
|
200
|
+
accountFailureState.clear();
|
|
201
|
+
rateLimitToastCooldowns.clear();
|
|
202
|
+
emptyResponseAttempts.clear();
|
|
203
|
+
softQuotaToastShownFlag = false;
|
|
204
|
+
rateLimitToastShownFlag = false;
|
|
205
|
+
}
|
|
206
|
+
function dispose() {
|
|
207
|
+
if (disposed)
|
|
208
|
+
return;
|
|
209
|
+
rateLimitStateByAccountQuota.clear();
|
|
210
|
+
accountFailureState.clear();
|
|
211
|
+
rateLimitToastCooldowns.clear();
|
|
212
|
+
emptyResponseAttempts.clear();
|
|
213
|
+
softQuotaToastShownFlag = false;
|
|
214
|
+
rateLimitToastShownFlag = false;
|
|
215
|
+
disposed = true;
|
|
216
|
+
}
|
|
217
|
+
function sizes() {
|
|
218
|
+
return {
|
|
219
|
+
rateLimitState: rateLimitStateByAccountQuota.size,
|
|
220
|
+
accountFailure: accountFailureState.size,
|
|
221
|
+
rateLimitToast: rateLimitToastCooldowns.size,
|
|
222
|
+
emptyResponse: emptyResponseAttempts.size,
|
|
223
|
+
};
|
|
224
|
+
}
|
|
225
|
+
return {
|
|
226
|
+
get disposed() {
|
|
227
|
+
return disposed;
|
|
228
|
+
},
|
|
229
|
+
getRateLimitBackoff,
|
|
230
|
+
resetRateLimitState,
|
|
231
|
+
resetAllRateLimitStateForAccount,
|
|
232
|
+
headerStyleToQuotaKey,
|
|
233
|
+
trackAccountFailure,
|
|
234
|
+
resetAccountFailureState,
|
|
235
|
+
shouldShowRateLimitToast,
|
|
236
|
+
markSoftQuotaToastShown,
|
|
237
|
+
markRateLimitToastShown,
|
|
238
|
+
softQuotaToastShown,
|
|
239
|
+
rateLimitToastShown,
|
|
240
|
+
resetAllAccountsBlockedToasts,
|
|
241
|
+
recordEmptyResponseAttempt,
|
|
242
|
+
clearEmptyResponseAttempts,
|
|
243
|
+
clear,
|
|
244
|
+
dispose,
|
|
245
|
+
sizes,
|
|
246
|
+
};
|
|
247
|
+
}
|
|
248
|
+
//# sourceMappingURL=retry-state.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"retry-state.js","sourceRoot":"","sources":["../../../../src/plugin/fetch/retry-state.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,MAAM,wBAAwB,GAAG,CAAC,CAAA;AAClC,MAAM,mBAAmB,GAAG,MAAM,CAAA;AAClC,MAAM,sBAAsB,GAAG,OAAO,CAAA;A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AAE,CAAA;QACpC,mBAAmB,CAAC,KAAK,EAAE,CAAA;QAC3B,uBAAuB,CAAC,KAAK,EAAE,CAAA;QAC/B,qBAAqB,CAAC,KAAK,EAAE,CAAA;QAC7B,uBAAuB,GAAG,KAAK,CAAA;QAC/B,uBAAuB,GAAG,KAAK,CAAA;IACjC,CAAC;IAED,SAAS,OAAO;QACd,IAAI,QAAQ;YAAE,OAAM;QACpB,4BAA4B,CAAC,KAAK,EAAE,CAAA;QACpC,mBAAmB,CAAC,KAAK,EAAE,CAAA;QAC3B,uBAAuB,CAAC,KAAK,EAAE,CAAA;QAC/B,qBAAqB,CAAC,KAAK,EAAE,CAAA;QAC7B,uBAAuB,GAAG,KAAK,CAAA;QAC/B,uBAAuB,GAAG,KAAK,CAAA;QAC/B,QAAQ,GAAG,IAAI,CAAA;IACjB,CAAC;IAED,SAAS,KAAK;QACZ,OAAO;YACL,cAAc,EAAE,4BAA4B,CAAC,IAAI;YACjD,cAAc,EAAE,mBAAmB,CAAC,IAAI;YACxC,cAAc,EAAE,uBAAuB,CAAC,IAAI;YAC5C,aAAa,EAAE,qBAAqB,CAAC,IAAI;SAC1C,CAAA;IACH,CAAC;IAED,OAAO;QACL,IAAI,QAAQ;YACV,OAAO,QAAQ,CAAA;QACjB,CAAC;QACD,mBAAmB;QACnB,mBAAmB;QACnB,gCAAgC;QAChC,qBAAqB;QACrB,mBAAmB;QACnB,wBAAwB;QACxB,wBAAwB;QACxB,uBAAuB;QACvB,uBAAuB;QACvB,mBAAmB;QACnB,mBAAmB;QACnB,6BAA6B;QAC7B,0BAA0B;QAC1B,0BAA0B;QAC1B,KAAK;QACL,OAAO;QACP,KAAK;KACN,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Per-interceptor warmup attempt + success bookkeeping.
|
|
3
|
+
*
|
|
4
|
+
* The plugin used to keep two module-level sets: one for sessions that already
|
|
5
|
+
* attempted a thinking warmup and another for sessions that succeeded. They
|
|
6
|
+
* leaked across plugin lifetimes and across concurrent interceptors. This
|
|
7
|
+
* factory scopes the same sets to a single interceptor; `dispose()` evicts
|
|
8
|
+
* everything so the next interceptor starts clean.
|
|
9
|
+
*/
|
|
10
|
+
export interface WarmupState {
|
|
11
|
+
readonly disposed: boolean;
|
|
12
|
+
/**
|
|
13
|
+
* Records an attempt for the given session id. Returns false when the
|
|
14
|
+
* session already succeeded (no further attempts permitted) or when the
|
|
15
|
+
* retry budget is exhausted.
|
|
16
|
+
*/
|
|
17
|
+
trackAttempt(sessionId: string): boolean;
|
|
18
|
+
/** Returns the number of tracked attempts for the session. */
|
|
19
|
+
getAttemptCount(sessionId: string): number;
|
|
20
|
+
/** Marks the session as warmed-up; subsequent attempts are rejected. */
|
|
21
|
+
markSuccess(sessionId: string): void;
|
|
22
|
+
/** Drops a single session's attempt counter (used on warmup failure). */
|
|
23
|
+
clearWarmupAttempt(sessionId: string): void;
|
|
24
|
+
/** Drops every session entry. */
|
|
25
|
+
clear(): void;
|
|
26
|
+
/** Marks the instance as torn down; subsequent mutations are no-ops. */
|
|
27
|
+
dispose(): void;
|
|
28
|
+
}
|
|
29
|
+
export declare function createWarmupState(): WarmupState;
|
|
30
|
+
//# sourceMappingURL=warmup.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"warmup.d.ts","sourceRoot":"","sources":["../../../../src/plugin/fetch/warmup.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAKH,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAA;IAC1B;;;;OAIG;IACH,YAAY,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAA;IACxC,8DAA8D;IAC9D,eAAe,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAAA;IAC1C,wEAAwE;IACxE,WAAW,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAA;IACpC,yEAAyE;IACzE,kBAAkB,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAA;IAC3C,iCAAiC;IACjC,KAAK,IAAI,IAAI,CAAA;IACb,wEAAwE;IACxE,OAAO,IAAI,IAAI,CAAA;CAChB;AAED,wBAAgB,iBAAiB,IAAI,WAAW,CAiE/C"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Per-interceptor warmup attempt + success bookkeeping.
|
|
3
|
+
*
|
|
4
|
+
* The plugin used to keep two module-level sets: one for sessions that already
|
|
5
|
+
* attempted a thinking warmup and another for sessions that succeeded. They
|
|
6
|
+
* leaked across plugin lifetimes and across concurrent interceptors. This
|
|
7
|
+
* factory scopes the same sets to a single interceptor; `dispose()` evicts
|
|
8
|
+
* everything so the next interceptor starts clean.
|
|
9
|
+
*/
|
|
10
|
+
const MAX_WARMUP_SESSIONS = 1000;
|
|
11
|
+
const MAX_WARMUP_RETRIES = 2;
|
|
12
|
+
export function createWarmupState() {
|
|
13
|
+
const warmupAttemptedSessionIds = new Set();
|
|
14
|
+
const warmupSucceededSessionIds = new Set();
|
|
15
|
+
let disposed = false;
|
|
16
|
+
function trackAttempt(sessionId) {
|
|
17
|
+
if (disposed)
|
|
18
|
+
return false;
|
|
19
|
+
if (warmupSucceededSessionIds.has(sessionId)) {
|
|
20
|
+
return false;
|
|
21
|
+
}
|
|
22
|
+
if (warmupAttemptedSessionIds.size >= MAX_WARMUP_SESSIONS) {
|
|
23
|
+
const first = warmupAttemptedSessionIds.values().next().value;
|
|
24
|
+
if (first) {
|
|
25
|
+
warmupAttemptedSessionIds.delete(first);
|
|
26
|
+
warmupSucceededSessionIds.delete(first);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
const attempts = getAttemptCount(sessionId);
|
|
30
|
+
if (attempts >= MAX_WARMUP_RETRIES) {
|
|
31
|
+
return false;
|
|
32
|
+
}
|
|
33
|
+
warmupAttemptedSessionIds.add(sessionId);
|
|
34
|
+
return true;
|
|
35
|
+
}
|
|
36
|
+
function getAttemptCount(sessionId) {
|
|
37
|
+
return warmupAttemptedSessionIds.has(sessionId) ? 1 : 0;
|
|
38
|
+
}
|
|
39
|
+
function markSuccess(sessionId) {
|
|
40
|
+
if (disposed)
|
|
41
|
+
return;
|
|
42
|
+
warmupSucceededSessionIds.add(sessionId);
|
|
43
|
+
if (warmupSucceededSessionIds.size >= MAX_WARMUP_SESSIONS) {
|
|
44
|
+
const first = warmupSucceededSessionIds.values().next().value;
|
|
45
|
+
if (first)
|
|
46
|
+
warmupSucceededSessionIds.delete(first);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
function clearWarmupAttempt(sessionId) {
|
|
50
|
+
if (disposed)
|
|
51
|
+
return;
|
|
52
|
+
warmupAttemptedSessionIds.delete(sessionId);
|
|
53
|
+
}
|
|
54
|
+
function clear() {
|
|
55
|
+
warmupAttemptedSessionIds.clear();
|
|
56
|
+
warmupSucceededSessionIds.clear();
|
|
57
|
+
}
|
|
58
|
+
function dispose() {
|
|
59
|
+
if (disposed)
|
|
60
|
+
return;
|
|
61
|
+
clear();
|
|
62
|
+
disposed = true;
|
|
63
|
+
}
|
|
64
|
+
return {
|
|
65
|
+
get disposed() {
|
|
66
|
+
return disposed;
|
|
67
|
+
},
|
|
68
|
+
trackAttempt,
|
|
69
|
+
getAttemptCount,
|
|
70
|
+
markSuccess,
|
|
71
|
+
clearWarmupAttempt,
|
|
72
|
+
clear,
|
|
73
|
+
dispose,
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
//# sourceMappingURL=warmup.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"warmup.js","sourceRoot":"","sources":["../../../../src/plugin/fetch/warmup.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,MAAM,mBAAmB,GAAG,IAAI,CAAA;AAChC,MAAM,kBAAkB,GAAG,CAAC,CAAA;AAsB5B,MAAM,UAAU,iBAAiB;IAC/B,MAAM,yBAAyB,GAAG,IA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gBAAE,yBAAyB,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;QACpD,CAAC;IACH,CAAC;IAED,SAAS,kBAAkB,CAAC,SAAiB;QAC3C,IAAI,QAAQ;YAAE,OAAM;QACpB,yBAAyB,CAAC,MAAM,CAAC,SAAS,CAAC,CAAA;IAC7C,CAAC;IAED,SAAS,KAAK;QACZ,yBAAyB,CAAC,KAAK,EAAE,CAAA;QACjC,yBAAyB,CAAC,KAAK,EAAE,CAAA;IACnC,CAAC;IAED,SAAS,OAAO;QACd,IAAI,QAAQ;YAAE,OAAM;QACpB,KAAK,EAAE,CAAA;QACP,QAAQ,GAAG,IAAI,CAAA;IACjB,CAAC;IAED,OAAO;QACL,IAAI,QAAQ;YACV,OAAO,QAAQ,CAAA;QACjB,CAAC;QACD,YAAY;QACZ,eAAe;QACf,WAAW;QACX,kBAAkB;QAClB,KAAK;QACL,OAAO;KACR,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import type { AccountManager } from './accounts';
|
|
2
|
+
import type { GetAuth } from './auth';
|
|
3
|
+
import type { AntigravityConfig } from './config';
|
|
4
|
+
import type { AgyTransport, FetchImpl } from './dependencies';
|
|
5
|
+
import type { OperatorSettingsController } from './operator-settings';
|
|
6
|
+
import type { QuotaManager } from './quota';
|
|
7
|
+
import { type AgySessionRegistry } from './session-context';
|
|
8
|
+
import type { PluginClient } from './types';
|
|
9
|
+
/**
|
|
10
|
+
* Inputs the fetch interceptor needs from the plugin bootstrap. Everything
|
|
11
|
+
* the original closure captured from `plugin.ts` now flows through this
|
|
12
|
+
* record so a fresh interceptor can be built per plugin instance without
|
|
13
|
+
* sharing state with siblings.
|
|
14
|
+
*/
|
|
15
|
+
export interface FetchInterceptorContext {
|
|
16
|
+
readonly client: PluginClient;
|
|
17
|
+
readonly directory: string;
|
|
18
|
+
readonly providerId: string;
|
|
19
|
+
readonly config: AntigravityConfig;
|
|
20
|
+
readonly accountManager: AccountManager;
|
|
21
|
+
readonly quotaManager: QuotaManager;
|
|
22
|
+
readonly getAuth: GetAuth;
|
|
23
|
+
readonly agySessionRegistry: AgySessionRegistry;
|
|
24
|
+
/**
|
|
25
|
+
* Live operator settings controller. Optional for backward
|
|
26
|
+
* compatibility — when present, the interceptor reads routing
|
|
27
|
+
* overrides and killswitch thresholds per request.
|
|
28
|
+
*/
|
|
29
|
+
readonly operatorSettings?: OperatorSettingsController;
|
|
30
|
+
/**
|
|
31
|
+
* Transport adapter used for Antigravity HTTPS requests. Defaults to
|
|
32
|
+
* the production `fetchWithAgyCliTransport` when omitted; tests inject
|
|
33
|
+
* a deterministic stub so the e2e workspace can route calls at a mock
|
|
34
|
+
* server bound to 127.0.0.1.
|
|
35
|
+
*/
|
|
36
|
+
readonly agyTransport?: AgyTransport;
|
|
37
|
+
/**
|
|
38
|
+
* HTTP primitive used for non-Antigravity URLs. Defaults to
|
|
39
|
+
* `globalThis.fetch`; tests inject a guarded stub that refuses any
|
|
40
|
+
* non-loopback target so a regression cannot silently leak a real
|
|
41
|
+
* network call.
|
|
42
|
+
*/
|
|
43
|
+
readonly fetchImpl?: FetchImpl;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Public surface exposed to the auth-loader plumbing. `fetch` mirrors the
|
|
47
|
+
* host signature so it can be slotted into `LoaderResult` unchanged.
|
|
48
|
+
*/
|
|
49
|
+
export interface FetchInterceptor {
|
|
50
|
+
fetch(input: RequestInfo | URL, init?: RequestInit): Promise<Response>;
|
|
51
|
+
dispose(): void;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Wraps the upstream fetch with the full account-rotation, rate-limit, and
|
|
55
|
+
* quota-fallback pipeline. Each interceptor owns its retry/warmup bookkeeping
|
|
56
|
+
* so disposing the plugin releases every counter.
|
|
57
|
+
*/
|
|
58
|
+
export declare function createFetchInterceptor(context: FetchInterceptorContext): FetchInterceptor;
|
|
59
|
+
//# sourceMappingURL=fetch-interceptor.d.ts.map
|
|
@@ -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