@cortexkit/opencode-antigravity-auth 1.0.1 → 2.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 +225 -553
- package/dist/cli.js +3790 -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 +18951 -13145
- 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/accounts.d.ts +7 -236
- package/dist/src/plugin/accounts.d.ts.map +1 -1
- package/dist/src/plugin/accounts.js +31 -1166
- package/dist/src/plugin/accounts.js.map +1 -1
- package/dist/src/plugin/agy-request-metadata.d.ts +2 -0
- package/dist/src/plugin/agy-request-metadata.d.ts.map +1 -0
- package/dist/src/plugin/agy-request-metadata.js +2 -0
- package/dist/src/plugin/agy-request-metadata.js.map +1 -0
- 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 +79 -62
- 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 +35 -0
- package/dist/src/plugin/auth-loader.d.ts.map +1 -0
- package/dist/src/plugin/auth-loader.js +144 -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/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 +276 -0
- package/dist/src/plugin/command-data.d.ts.map +1 -0
- package/dist/src/plugin/command-data.js +325 -0
- package/dist/src/plugin/command-data.js.map +1 -0
- package/dist/src/plugin/commands.d.ts +151 -0
- package/dist/src/plugin/commands.d.ts.map +1 -0
- package/dist/src/plugin/commands.js +639 -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 +21 -2
- package/dist/src/plugin/config/schema.d.ts.map +1 -1
- package/dist/src/plugin/config/schema.js +85 -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 +3 -3
- package/dist/src/plugin/debug.d.ts.map +1 -1
- package/dist/src/plugin/debug.js +85 -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 +1387 -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 +2 -21
- package/dist/src/plugin/image-saver.d.ts.map +1 -1
- package/dist/src/plugin/image-saver.js +22 -56
- package/dist/src/plugin/image-saver.js.map +1 -1
- package/dist/src/plugin/index.d.ts +23 -0
- package/dist/src/plugin/index.d.ts.map +1 -0
- package/dist/src/plugin/index.js +308 -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 +194 -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 +1284 -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 +97 -41
- package/dist/src/plugin/quota.d.ts.map +1 -1
- package/dist/src/plugin/quota.js +273 -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 +2 -1
- package/dist/src/plugin/request-helpers.d.ts.map +1 -1
- package/dist/src/plugin/request-helpers.js +458 -354
- package/dist/src/plugin/request-helpers.js.map +1 -1
- package/dist/src/plugin/request.d.ts +12 -6
- package/dist/src/plugin/request.d.ts.map +1 -1
- package/dist/src/plugin/request.js +801 -390
- 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 +22 -0
- package/dist/src/plugin/session-context.d.ts.map +1 -0
- package/dist/src/plugin/session-context.js +67 -0
- package/dist/src/plugin/session-context.js.map +1 -0
- package/dist/src/plugin/storage.d.ts +59 -114
- package/dist/src/plugin/storage.d.ts.map +1 -1
- package/dist/src/plugin/storage.js +140 -474
- 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 +2 -2
- package/dist/src/plugin/ui/auth-menu.d.ts.map +1 -1
- package/dist/src/plugin/ui/auth-menu.js +84 -31
- 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 +51 -48
- 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 +240 -0
- package/dist/src/sidebar-state.d.ts.map +1 -0
- package/dist/src/sidebar-state.js +520 -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 +497 -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 +662 -0
- package/dist/src/tui.js.map +1 -0
- package/package.json +46 -22
- package/src/plugin/command-data.ts +651 -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 +717 -0
- package/src/tui/command-dialogs.tsx +699 -0
- package/src/tui/entry.mjs +74 -0
- package/src/tui/file-logger.ts +145 -0
- package/src/tui-compiled/plugin/command-data.ts +651 -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 +717 -0
- package/src/tui-compiled/tui/command-dialogs.tsx +659 -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 +1150 -0
- package/src/tui-preferences.ts +416 -0
- package/src/tui.tsx +1117 -0
- package/dist/src/plugin.d.ts +0 -32
- package/dist/src/plugin.d.ts.map +0 -1
- package/dist/src/plugin.js +0 -3151
- package/dist/src/plugin.js.map +0 -1
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { ANTIGRAVITY_ACCOUNT_COMMAND_NAME, ANTIGRAVITY_DUMP_COMMAND_NAME, ANTIGRAVITY_KILLSWITCH_COMMAND_NAME, ANTIGRAVITY_LOGGING_COMMAND_NAME, ANTIGRAVITY_QUOTA_COMMAND_NAME, ANTIGRAVITY_ROUTING_COMMAND_NAME, MODAL_COMMANDS, } from './commands';
|
|
2
|
+
import { GEMINI_DUMP_COMMAND_NAME } from './gemini-dump';
|
|
3
|
+
import { getAntigravityOpencodeModelIds, OPENCODE_MODEL_DEFINITIONS, } from './model-registry';
|
|
4
|
+
export function applyAntigravityProviderCatalog(config, providerId) {
|
|
5
|
+
const mutableConfig = config;
|
|
6
|
+
mutableConfig.provider ??= {};
|
|
7
|
+
const providerConfig = mutableConfig.provider[providerId] ?? {};
|
|
8
|
+
providerConfig.models = {
|
|
9
|
+
...(providerConfig.models ?? {}),
|
|
10
|
+
...OPENCODE_MODEL_DEFINITIONS,
|
|
11
|
+
};
|
|
12
|
+
providerConfig.whitelist = getAntigravityOpencodeModelIds();
|
|
13
|
+
mutableConfig.provider[providerId] = providerConfig;
|
|
14
|
+
}
|
|
15
|
+
const COMMAND_DESCRIPTIONS = {
|
|
16
|
+
'antigravity-quota': 'Refresh Antigravity quota for the active account pool.',
|
|
17
|
+
'antigravity-account': 'Add, refresh, or remove Antigravity accounts.',
|
|
18
|
+
'antigravity-routing': 'Toggle routing overrides for Gemini / Antigravity fallback.',
|
|
19
|
+
'antigravity-killswitch': 'Configure the quota killswitch threshold and per-account overrides.',
|
|
20
|
+
'antigravity-dump': 'Show or toggle Gemini/Antigravity wire dump capture for debugging.',
|
|
21
|
+
'antigravity-logging': 'Adjust the runtime logging level.',
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* Register every modal command with the host `config.command` map.
|
|
25
|
+
*
|
|
26
|
+
* Existing entries are preserved — the host may ship its own slash
|
|
27
|
+
* commands (e.g. `init`, `undo`, …) and the merge must not blow them
|
|
28
|
+
* away. `/gemini-dump` is registered in addition to the modal
|
|
29
|
+
* `antigravity-dump` so legacy sessions keep working.
|
|
30
|
+
*
|
|
31
|
+
* This function is the FIRST of three places that must agree on the
|
|
32
|
+
* set of modal commands — see the three-wiring test in
|
|
33
|
+
* `commands.test.ts` for the invariant.
|
|
34
|
+
*/
|
|
35
|
+
export function registerAntigravityCommands(config) {
|
|
36
|
+
const mutableConfig = config;
|
|
37
|
+
const existing = mutableConfig.command ?? {};
|
|
38
|
+
const next = { ...existing };
|
|
39
|
+
for (const command of MODAL_COMMANDS) {
|
|
40
|
+
next[command] = {
|
|
41
|
+
template: command,
|
|
42
|
+
description: COMMAND_DESCRIPTIONS[command],
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
next[GEMINI_DUMP_COMMAND_NAME] = {
|
|
46
|
+
template: GEMINI_DUMP_COMMAND_NAME,
|
|
47
|
+
description: 'Show or toggle Gemini/Antigravity wire dump capture for debugging.',
|
|
48
|
+
};
|
|
49
|
+
mutableConfig.command = next;
|
|
50
|
+
}
|
|
51
|
+
// Re-export so existing callers can keep importing from catalog.
|
|
52
|
+
export const ANTIGRAVITY_COMMAND_NAMES = {
|
|
53
|
+
quota: ANTIGRAVITY_QUOTA_COMMAND_NAME,
|
|
54
|
+
account: ANTIGRAVITY_ACCOUNT_COMMAND_NAME,
|
|
55
|
+
routing: ANTIGRAVITY_ROUTING_COMMAND_NAME,
|
|
56
|
+
killswitch: ANTIGRAVITY_KILLSWITCH_COMMAND_NAME,
|
|
57
|
+
dump: ANTIGRAVITY_DUMP_COMMAND_NAME,
|
|
58
|
+
logging: ANTIGRAVITY_LOGGING_COMMAND_NAME,
|
|
59
|
+
};
|
|
60
|
+
//# sourceMappingURL=catalog.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"catalog.js","sourceRoot":"","sources":["../../../src/plugin/catalog.ts"],"names":[],"mappings":"AACA,OAAO,EACL,gCAAgC,EAChC,6BAA6B,EAC7B,mCAAmC,EACnC,gCAAgC,EAChC,8BAA8B,EAC9B,gCAAgC,EAChC,cAAc,GACf,MAAM,YAAY,CAAA;AACnB,OAAO,EAAE,wBAAwB,EAAE,MAAM,eAAe,CAAA;AACxD,OAAO,EACL,8BAA8B,EAC9B,0BAA0B,GAC3B,MAAM,kBAAkB,CAAA;AAazB,MAAM,UAAU,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AAM,CAAC,MAAM,yBAAyB,GAAG;IACvC,KAAK,EAAE,8BAA8B;IACrC,OAAO,EAAE,gCAAgC;IACzC,OAAO,EAAE,gCAAgC;IACzC,UAAU,EAAE,mCAAmC;IAC/C,IAAI,EAAE,6BAA6B;IACnC,OAAO,EAAE,gCAAgC;CACjC,CAAA"}
|
package/dist/src/plugin/cli.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import type { FingerprintVersion } from
|
|
3
|
-
import type {
|
|
4
|
-
import type
|
|
1
|
+
import type { CooldownReason } from './accounts';
|
|
2
|
+
import type { FingerprintVersion } from './fingerprint';
|
|
3
|
+
import type { QuotaGroupSummary } from './quota';
|
|
4
|
+
import { type AccountStatus } from './ui/auth-menu';
|
|
5
5
|
export declare function promptProjectId(): Promise<string>;
|
|
6
6
|
export declare function promptAddAnotherAccount(currentCount: number): Promise<boolean>;
|
|
7
|
-
export type LoginMode =
|
|
7
|
+
export type LoginMode = 'add' | 'fresh' | 'manage' | 'check' | 'doctor' | 'repair' | 'current' | 'switch-account' | 'restore-fingerprint' | 'verify' | 'verify-all' | 'cancel';
|
|
8
8
|
export interface ExistingAccountInfo {
|
|
9
9
|
email?: string;
|
|
10
10
|
index: number;
|
|
@@ -39,6 +39,6 @@ export interface LoginMenuResult {
|
|
|
39
39
|
deleteAll?: boolean;
|
|
40
40
|
}
|
|
41
41
|
export declare function promptLoginMode(existingAccounts: ExistingAccountInfo[]): Promise<LoginMenuResult>;
|
|
42
|
-
export {
|
|
43
|
-
export
|
|
42
|
+
export type { AccountStatus } from './ui/auth-menu';
|
|
43
|
+
export { isTTY } from './ui/auth-menu';
|
|
44
44
|
//# sourceMappingURL=cli.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../../../src/plugin/cli.ts"],"names":[],"mappings":"AAEA,OAAO,
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot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S,CAAC,EAAE,MAAM,CAAA;KACnB,EAAE,CAAA;IACH,kBAAkB,CAAC,EAAE,kBAAkB,EAAE,CAAA;CAC1C;AAED,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,SAAS,CAAA;IACf,kBAAkB,CAAC,EAAE,MAAM,CAAA;IAC3B,mBAAmB,CAAC,EAAE,MAAM,CAAA;IAC5B,kBAAkB,CAAC,EAAE,MAAM,CAAA;IAC3B,kBAAkB,CAAC,EAAE,MAAM,CAAA;IAC3B,kBAAkB,CAAC,EAAE,MAAM,CAAA;IAC3B,8BAA8B,CAAC,EAAE,MAAM,CAAA;IACvC,8BAA8B,CAAC,EAAE,MAAM,CAAA;IACvC,SAAS,CAAC,EAAE,OAAO,CAAA;IACnB,SAAS,CAAC,EAAE,OAAO,CAAA;CACpB;AAqDD,wBAAsB,eAAe,CACnC,gBAAgB,EAAE,mBAAmB,EAAE,GACtC,OAAO,CAAC,eAAe,CAAC,CA2G1B;AAED,YAAY,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAA;AACnD,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAA"}
|
package/dist/src/plugin/cli.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
1
|
+
import { stdin as input, stdout as output } from 'node:process';
|
|
2
|
+
import { createInterface } from 'node:readline/promises';
|
|
3
|
+
import { updateOpencodeConfig } from './config/updater';
|
|
4
|
+
import { isTTY, showAccountDetails, showAuthMenu, showFingerprintHistory, } from './ui/auth-menu';
|
|
5
5
|
export async function promptProjectId() {
|
|
6
6
|
const rl = createInterface({ input, output });
|
|
7
7
|
try {
|
|
8
|
-
const answer = await rl.question(
|
|
8
|
+
const answer = await rl.question('Project ID (leave blank to use your default project): ');
|
|
9
9
|
return answer.trim();
|
|
10
10
|
}
|
|
11
11
|
finally {
|
|
@@ -17,7 +17,7 @@ export async function promptAddAnotherAccount(currentCount) {
|
|
|
17
17
|
try {
|
|
18
18
|
const answer = await rl.question(`Add another account? (${currentCount} added) (y/n): `);
|
|
19
19
|
const normalized = answer.trim().toLowerCase();
|
|
20
|
-
return normalized ===
|
|
20
|
+
return normalized === 'y' || normalized === 'yes';
|
|
21
21
|
}
|
|
22
22
|
finally {
|
|
23
23
|
rl.close();
|
|
@@ -31,27 +31,31 @@ async function promptLoginModeFallback(existingAccounts) {
|
|
|
31
31
|
const label = acc.email || `Account ${acc.index + 1}`;
|
|
32
32
|
console.log(` ${acc.index + 1}. ${label}`);
|
|
33
33
|
}
|
|
34
|
-
console.log(
|
|
34
|
+
console.log('');
|
|
35
35
|
while (true) {
|
|
36
|
-
const answer = await rl.question(
|
|
36
|
+
const answer = await rl.question('(a)dd new, (f)resh start, (c)heck quotas, auth (d)octor, (v)erify account, (va) verify all? [a/f/c/d/v/va]: ');
|
|
37
37
|
const normalized = answer.trim().toLowerCase();
|
|
38
|
-
if (normalized ===
|
|
39
|
-
return { mode:
|
|
38
|
+
if (normalized === 'a' || normalized === 'add') {
|
|
39
|
+
return { mode: 'add' };
|
|
40
40
|
}
|
|
41
|
-
if (normalized ===
|
|
42
|
-
return { mode:
|
|
41
|
+
if (normalized === 'f' || normalized === 'fresh') {
|
|
42
|
+
return { mode: 'fresh' };
|
|
43
43
|
}
|
|
44
|
-
if (normalized ===
|
|
45
|
-
return { mode:
|
|
44
|
+
if (normalized === 'c' || normalized === 'check') {
|
|
45
|
+
return { mode: 'check' };
|
|
46
46
|
}
|
|
47
|
-
if (normalized ===
|
|
48
|
-
|
|
47
|
+
if (normalized === 'd' ||
|
|
48
|
+
normalized === 'doctor' ||
|
|
49
|
+
normalized === 'auth-doctor') {
|
|
50
|
+
return { mode: 'doctor' };
|
|
49
51
|
}
|
|
50
|
-
if (normalized ===
|
|
51
|
-
return { mode:
|
|
52
|
+
if (normalized === 'v' || normalized === 'verify') {
|
|
53
|
+
return { mode: 'verify' };
|
|
52
54
|
}
|
|
53
|
-
if (normalized ===
|
|
54
|
-
|
|
55
|
+
if (normalized === 'va' ||
|
|
56
|
+
normalized === 'verify-all' ||
|
|
57
|
+
normalized === 'all') {
|
|
58
|
+
return { mode: 'verify-all', verifyAll: true };
|
|
55
59
|
}
|
|
56
60
|
console.log("Please enter 'a', 'f', 'c', 'd', 'v', or 'va'.");
|
|
57
61
|
}
|
|
@@ -64,7 +68,7 @@ export async function promptLoginMode(existingAccounts) {
|
|
|
64
68
|
if (!isTTY()) {
|
|
65
69
|
return promptLoginModeFallback(existingAccounts);
|
|
66
70
|
}
|
|
67
|
-
const accounts = existingAccounts.map(acc => ({
|
|
71
|
+
const accounts = existingAccounts.map((acc) => ({
|
|
68
72
|
email: acc.email,
|
|
69
73
|
index: acc.index,
|
|
70
74
|
addedAt: acc.addedAt,
|
|
@@ -79,44 +83,47 @@ export async function promptLoginMode(existingAccounts) {
|
|
|
79
83
|
cachedPerModelQuota: acc.cachedPerModelQuota,
|
|
80
84
|
fingerprintHistory: acc.fingerprintHistory,
|
|
81
85
|
}));
|
|
82
|
-
console.log(
|
|
86
|
+
console.log('');
|
|
83
87
|
while (true) {
|
|
84
88
|
const action = await showAuthMenu(accounts);
|
|
85
89
|
switch (action.type) {
|
|
86
|
-
case
|
|
87
|
-
return { mode:
|
|
88
|
-
case
|
|
89
|
-
return { mode:
|
|
90
|
-
case
|
|
91
|
-
return { mode:
|
|
92
|
-
case
|
|
93
|
-
return { mode:
|
|
94
|
-
case
|
|
95
|
-
return { mode:
|
|
96
|
-
case
|
|
97
|
-
return { mode:
|
|
98
|
-
case
|
|
99
|
-
return { mode:
|
|
100
|
-
case
|
|
90
|
+
case 'add':
|
|
91
|
+
return { mode: 'add' };
|
|
92
|
+
case 'check':
|
|
93
|
+
return { mode: 'check' };
|
|
94
|
+
case 'doctor':
|
|
95
|
+
return { mode: 'doctor' };
|
|
96
|
+
case 'repair':
|
|
97
|
+
return { mode: 'repair' };
|
|
98
|
+
case 'current':
|
|
99
|
+
return { mode: 'current' };
|
|
100
|
+
case 'verify':
|
|
101
|
+
return { mode: 'verify' };
|
|
102
|
+
case 'verify-all':
|
|
103
|
+
return { mode: 'verify-all', verifyAll: true };
|
|
104
|
+
case 'select-account': {
|
|
101
105
|
const accountAction = await showAccountDetails(action.account);
|
|
102
|
-
if (accountAction ===
|
|
103
|
-
return { mode:
|
|
106
|
+
if (accountAction === 'delete') {
|
|
107
|
+
return { mode: 'add', deleteAccountIndex: action.account.index };
|
|
104
108
|
}
|
|
105
|
-
if (accountAction ===
|
|
106
|
-
return { mode:
|
|
109
|
+
if (accountAction === 'refresh') {
|
|
110
|
+
return { mode: 'add', refreshAccountIndex: action.account.index };
|
|
107
111
|
}
|
|
108
|
-
if (accountAction ===
|
|
109
|
-
return { mode:
|
|
112
|
+
if (accountAction === 'toggle') {
|
|
113
|
+
return { mode: 'manage', toggleAccountIndex: action.account.index };
|
|
110
114
|
}
|
|
111
|
-
if (accountAction ===
|
|
112
|
-
return { mode:
|
|
115
|
+
if (accountAction === 'verify') {
|
|
116
|
+
return { mode: 'verify', verifyAccountIndex: action.account.index };
|
|
113
117
|
}
|
|
114
|
-
if (accountAction ===
|
|
118
|
+
if (accountAction === 'switch-account') {
|
|
115
119
|
const accountLabel = action.account.email || `Account ${action.account.index + 1}`;
|
|
116
120
|
console.log(`\n✓ Switched to ${accountLabel}. Restart OpenCode for changes to take effect.\n`);
|
|
117
|
-
return {
|
|
121
|
+
return {
|
|
122
|
+
mode: 'switch-account',
|
|
123
|
+
switchAccountIndex: action.account.index,
|
|
124
|
+
};
|
|
118
125
|
}
|
|
119
|
-
if (accountAction ===
|
|
126
|
+
if (accountAction === 'restore-fingerprint') {
|
|
120
127
|
const history = action.account.fingerprintHistory;
|
|
121
128
|
if (!history || history.length === 0)
|
|
122
129
|
continue;
|
|
@@ -125,16 +132,16 @@ export async function promptLoginMode(existingAccounts) {
|
|
|
125
132
|
if (historyIndex === null)
|
|
126
133
|
continue;
|
|
127
134
|
return {
|
|
128
|
-
mode:
|
|
135
|
+
mode: 'restore-fingerprint',
|
|
129
136
|
restoreFingerprintAccountIndex: action.account.index,
|
|
130
137
|
restoreFingerprintHistoryIndex: historyIndex,
|
|
131
138
|
};
|
|
132
139
|
}
|
|
133
140
|
continue;
|
|
134
141
|
}
|
|
135
|
-
case
|
|
136
|
-
return { mode:
|
|
137
|
-
case
|
|
142
|
+
case 'delete-all':
|
|
143
|
+
return { mode: 'fresh', deleteAll: true };
|
|
144
|
+
case 'configure-models': {
|
|
138
145
|
const result = await updateOpencodeConfig();
|
|
139
146
|
if (result.success) {
|
|
140
147
|
console.log(`\n✓ Models configured in ${result.configPath}\n`);
|
|
@@ -144,10 +151,10 @@ export async function promptLoginMode(existingAccounts) {
|
|
|
144
151
|
}
|
|
145
152
|
continue;
|
|
146
153
|
}
|
|
147
|
-
case
|
|
148
|
-
return { mode:
|
|
154
|
+
case 'cancel':
|
|
155
|
+
return { mode: 'cancel' };
|
|
149
156
|
}
|
|
150
157
|
}
|
|
151
158
|
}
|
|
152
|
-
export { isTTY } from
|
|
159
|
+
export { isTTY } from './ui/auth-menu';
|
|
153
160
|
//# sourceMappingURL=cli.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../../../src/plugin/cli.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../../../src/plugin/cli.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,IAAI,KAAK,EAAE,MAAM,IAAI,MAAM,EAAE,MAAM,cAAc,CAAA;AAC/D,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAA;AAExD,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAA;AAGvD,OAAO,EAGL,KAAK,EACL,kBAAkB,EAClB,YAAY,EACZ,sBAAsB,GACvB,MAAM,gBAAgB,CAAA;AACvB,MAAM,CAAC,KAAK,UAAU,eAAe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B,CAAA"}
|
|
@@ -0,0 +1,276 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Privacy-safe data service for the data-first slash-command dialogs.
|
|
3
|
+
*
|
|
4
|
+
* `/antigravity-quota` (this task) and the future `/antigravity-account`
|
|
5
|
+
* dialogs (Tasks 10-11) read from a single shared service so they
|
|
6
|
+
* never touch raw account storage, never see the email PII field, and
|
|
7
|
+
* never run quota network I/O during the dialog's open path — the
|
|
8
|
+
* Refresh action is the only path that performs a live fetch.
|
|
9
|
+
*
|
|
10
|
+
* Why this is a separate module:
|
|
11
|
+
*
|
|
12
|
+
* - `commands.ts` owns the slash-command orchestration; mixing the row
|
|
13
|
+
* projection + quota refresh logic in there would balloon the surface
|
|
14
|
+
* for what is fundamentally a small read/refresh service.
|
|
15
|
+
* - The row type (`CommandAccountRow`) is the projection that crosses
|
|
16
|
+
* the PII firewall into the dialog payload. Defining it here (next
|
|
17
|
+
* to the code that constructs it) keeps the firewall reviewable.
|
|
18
|
+
* - Tests can pin the read-vs-refresh boundary, the email redaction, and
|
|
19
|
+
* the refresh-token-keyed persistence in one file rather than chasing
|
|
20
|
+
* them across the dispatcher + RPC + apply layers.
|
|
21
|
+
*
|
|
22
|
+
* Cache-only opening contract (Task 9 operator requirement):
|
|
23
|
+
*
|
|
24
|
+
* `listAccounts()` is a pure read of the live AccountManager view
|
|
25
|
+
* the auth-loader materialized at session start. It performs
|
|
26
|
+
* ZERO quota manager calls — opening the dialog must be instant even
|
|
27
|
+
* when the network is unreachable, and quota refresh must remain an
|
|
28
|
+
* explicit user-driven action so the cached percentages never quietly
|
|
29
|
+
* rewrite themselves behind the user's back.
|
|
30
|
+
*
|
|
31
|
+
* Refresh-token-keyed persistence (Task 9 plan trap):
|
|
32
|
+
*
|
|
33
|
+
* `refreshQuota()` runs the shared quota manager across every enabled
|
|
34
|
+
* account and folds the results back into the live AccountManager +
|
|
35
|
+
* storage. Concurrent OAuth can renumber the flat `accounts[]` array
|
|
36
|
+
* between read and write, so we re-read under the lock and key the
|
|
37
|
+
* update by `refreshToken` (the canonical identity) rather than the
|
|
38
|
+
* array index. This way a successful OAuth add that lands between
|
|
39
|
+
* the read and the write cannot cause the refresh to overwrite the
|
|
40
|
+
* wrong account.
|
|
41
|
+
*/
|
|
42
|
+
/**
|
|
43
|
+
* Local copies of the few core types the data service touches.
|
|
44
|
+
*
|
|
45
|
+
* The shipped TUI tree cannot depend on the `@cortexkit/antigravity-auth-core`
|
|
46
|
+
* barrel (only subpath imports like `./file-lock` are allowed) — the
|
|
47
|
+
* compiled `command-data.ts` is copied verbatim into `tui-compiled/`,
|
|
48
|
+
* and the type-import would otherwise leak the full core surface into
|
|
49
|
+
* the dialog render path. Declaring the structural shape locally keeps
|
|
50
|
+
* the compiled tree free of the barrel while preserving duck-typed
|
|
51
|
+
* compatibility with the production quota manager.
|
|
52
|
+
*/
|
|
53
|
+
type CommandDataAccountMetadata = {
|
|
54
|
+
email?: string;
|
|
55
|
+
refreshToken: string;
|
|
56
|
+
projectId?: string;
|
|
57
|
+
managedProjectId?: string;
|
|
58
|
+
addedAt: number;
|
|
59
|
+
lastUsed: number;
|
|
60
|
+
enabled?: boolean;
|
|
61
|
+
label?: string;
|
|
62
|
+
cachedQuota?: Partial<Record<CommandDataQuotaGroup, CommandDataQuotaGroupSummary>>;
|
|
63
|
+
cachedQuotaUpdatedAt?: number;
|
|
64
|
+
accountIneligible?: boolean;
|
|
65
|
+
};
|
|
66
|
+
type CommandDataQuotaGroup = 'claude' | 'gemini-pro' | 'gemini-flash' | 'gpt-oss';
|
|
67
|
+
type CommandDataQuotaGroupSummary = {
|
|
68
|
+
remainingFraction?: number;
|
|
69
|
+
resetTime?: string;
|
|
70
|
+
modelCount: number;
|
|
71
|
+
};
|
|
72
|
+
type CommandDataAccountQuotaResult = {
|
|
73
|
+
index: number;
|
|
74
|
+
status: 'ok' | 'disabled' | 'error';
|
|
75
|
+
error?: string;
|
|
76
|
+
disabled?: boolean;
|
|
77
|
+
quota?: {
|
|
78
|
+
groups: Partial<Record<CommandDataQuotaGroup, CommandDataQuotaGroupSummary>>;
|
|
79
|
+
perModel?: Array<{
|
|
80
|
+
modelId: string;
|
|
81
|
+
displayName?: string;
|
|
82
|
+
group: CommandDataQuotaGroup | null;
|
|
83
|
+
remainingFraction: number;
|
|
84
|
+
resetTime?: string;
|
|
85
|
+
}>;
|
|
86
|
+
modelCount: number;
|
|
87
|
+
error?: string;
|
|
88
|
+
};
|
|
89
|
+
updatedAccount?: CommandDataAccountMetadata;
|
|
90
|
+
};
|
|
91
|
+
type CommandDataAccountStorage = {
|
|
92
|
+
version: 4;
|
|
93
|
+
activeIndex: number;
|
|
94
|
+
activeIndexByFamily?: {
|
|
95
|
+
claude?: number;
|
|
96
|
+
gemini?: number;
|
|
97
|
+
};
|
|
98
|
+
accounts: CommandDataAccountMetadata[];
|
|
99
|
+
};
|
|
100
|
+
/**
|
|
101
|
+
* Privacy-safe per-account row shown in `/antigravity-*` data-first
|
|
102
|
+
* dialogs. Carries the cached quota percentages and the labels the
|
|
103
|
+
* dialog needs, but NEVER the email — the email stays in private
|
|
104
|
+
* account storage and is invisible to the sidebar and the dialog.
|
|
105
|
+
*
|
|
106
|
+
* `index` is the position in the live account array at the time of
|
|
107
|
+
* projection. It is informational only and is NOT a stable identity
|
|
108
|
+
* across refreshes — concurrent OAuth can renumber the array between
|
|
109
|
+
* the dialog opening and a refresh.
|
|
110
|
+
*/
|
|
111
|
+
export interface CommandAccountRow {
|
|
112
|
+
/** Stable identity for dialog keying (`acct-<index>`). */
|
|
113
|
+
id: string;
|
|
114
|
+
/** Position in the live account array at projection time. */
|
|
115
|
+
index: number;
|
|
116
|
+
/** Privacy-safe ordinal display label (for example, `Account 1`). */
|
|
117
|
+
label: string;
|
|
118
|
+
enabled: boolean;
|
|
119
|
+
/** `true` when this row matches the harness-active account. */
|
|
120
|
+
current: boolean;
|
|
121
|
+
quota: Array<{
|
|
122
|
+
key: 'claude' | 'gemini-pro' | 'gemini-flash' | 'gpt-oss';
|
|
123
|
+
label: string;
|
|
124
|
+
remainingPercent: number | null;
|
|
125
|
+
resetAt?: number;
|
|
126
|
+
}>;
|
|
127
|
+
}
|
|
128
|
+
interface LiveAccountSnapshot {
|
|
129
|
+
index: number;
|
|
130
|
+
refreshToken: string;
|
|
131
|
+
label?: string;
|
|
132
|
+
enabled: boolean;
|
|
133
|
+
active: boolean;
|
|
134
|
+
cachedQuota?: Partial<Record<CommandDataQuotaGroup, CommandDataQuotaGroupSummary>>;
|
|
135
|
+
cachedQuotaUpdatedAt?: number;
|
|
136
|
+
accountIneligible?: boolean;
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Live AccountManager view the data service needs.
|
|
140
|
+
*
|
|
141
|
+
* - `getAccounts()` returns the in-memory snapshot — used for cache-only
|
|
142
|
+
* reads during dialog open and for re-reading the post-mutation state.
|
|
143
|
+
* `getAccountsForQuotaCheck()` returns the freshest `AccountMetadataV3`
|
|
144
|
+
* (the canonical shape the quota manager expects).
|
|
145
|
+
* - `updateQuotaCache(index, groups)` + `requestSaveToDisk()` fold the
|
|
146
|
+
* refreshed quota back into the live view and persist it. The service
|
|
147
|
+
* calls them together after the network fetch resolves.
|
|
148
|
+
* - `setAccountEnabled`, `setAccountCurrent`, `removeAccountByIndex`
|
|
149
|
+
* mirror the CLI menu's mutation primitives — the dialog actions
|
|
150
|
+
* (Task 10) reuse them so the TUI never invents its own mutation
|
|
151
|
+
* logic. Each method returns `true` when the live view changed.
|
|
152
|
+
* - `getRefreshTokenAt(index)` lets the service identify the canonical
|
|
153
|
+
* account identity before it reaches the locked storage mutator; a
|
|
154
|
+
* concurrent OAuth could renumber the flat array between the dialog
|
|
155
|
+
* opening and the apply, so keying by refresh token is mandatory.
|
|
156
|
+
* - `flushSaveToDisk()` drains the AccountManager's debounced save so a
|
|
157
|
+
* dialog-triggered mutation lands on disk before the dialog's response
|
|
158
|
+
* returns. Without it, the dialog could toast "Account removed" while
|
|
159
|
+
* the file still carries the old pool.
|
|
160
|
+
* - `activeIndex()` returns the position the harness considers active;
|
|
161
|
+
* the service uses it to mark the matching row as `current: true`.
|
|
162
|
+
*/
|
|
163
|
+
export interface CommandDataAccountManagerView {
|
|
164
|
+
getAccounts(): LiveAccountSnapshot[];
|
|
165
|
+
getAccountsForQuotaCheck(): CommandDataAccountMetadata[];
|
|
166
|
+
updateQuotaCache(index: number, groups: Partial<Record<CommandDataQuotaGroup, CommandDataQuotaGroupSummary>>): void;
|
|
167
|
+
requestSaveToDisk(): void;
|
|
168
|
+
flushSaveToDisk(): Promise<void>;
|
|
169
|
+
activeIndex(): number;
|
|
170
|
+
/** Enable/disable the account at `index`. Returns true when it changed. */
|
|
171
|
+
setAccountEnabled(index: number, enabled: boolean): boolean;
|
|
172
|
+
/** Pin `index` as the active account for every family the dialog cares about. */
|
|
173
|
+
setAccountCurrent(index: number): boolean;
|
|
174
|
+
/** Remove the account at `index` from the live view. Returns true when it changed. */
|
|
175
|
+
removeAccountByIndex(index: number): boolean;
|
|
176
|
+
/** Canonical refresh token for the account at `index`, or undefined. */
|
|
177
|
+
getRefreshTokenAt(index: number): string | undefined;
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* Storage adapter the data service uses for re-read-under-lock writes.
|
|
181
|
+
* `mutate` runs the supplied callback against the latest snapshot under
|
|
182
|
+
* the file lock — the callback receives the current storage and may
|
|
183
|
+
* return a replacement; returning the input unchanged is a no-op.
|
|
184
|
+
*
|
|
185
|
+
* The promise resolves with the (possibly mutated) storage snapshot so
|
|
186
|
+
* the data service can await it. A rejected promise signals a failed
|
|
187
|
+
* write — `AccountStorageUnreadableError`, lock contention, or any
|
|
188
|
+
* other I/O failure — which the data service surfaces to the dialog
|
|
189
|
+
* as a friendly error toast.
|
|
190
|
+
*/
|
|
191
|
+
export interface CommandDataStorage {
|
|
192
|
+
mutate(mutator: (current: CommandDataAccountStorage) => CommandDataAccountStorage | undefined | Promise<CommandDataAccountStorage | undefined>): Promise<CommandDataAccountStorage | undefined> | undefined;
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* Options for `createCommandDataService`. Each field is required so
|
|
196
|
+
* production wiring is explicit — a missing dependency is a startup
|
|
197
|
+
* error, not a silent no-op at dialog-open time.
|
|
198
|
+
*/
|
|
199
|
+
export interface CommandDataServiceOptions {
|
|
200
|
+
accountManagerView: CommandDataAccountManagerView;
|
|
201
|
+
quotaManager: {
|
|
202
|
+
refreshAccounts(accounts: CommandDataAccountMetadata[], options: {
|
|
203
|
+
indexFor?: (account: CommandDataAccountMetadata) => number;
|
|
204
|
+
force?: boolean;
|
|
205
|
+
}): Promise<CommandDataAccountQuotaResult[]>;
|
|
206
|
+
};
|
|
207
|
+
/** Path to the label-only sidebar state file. */
|
|
208
|
+
sidebarStateFile: string;
|
|
209
|
+
/**
|
|
210
|
+
* Optional storage adapter. When provided, the service persists the
|
|
211
|
+
* refreshed quota to disk via the lock-held mutator (best-effort —
|
|
212
|
+
* a lock contention never breaks the dialog response). When omitted,
|
|
213
|
+
* the service still folds results into the live AccountManager view;
|
|
214
|
+
* the auth-loader is responsible for the on-disk write.
|
|
215
|
+
*/
|
|
216
|
+
storage?: CommandDataStorage;
|
|
217
|
+
/** Clock for `cachedQuotaUpdatedAt`. Tests inject a fixed clock. */
|
|
218
|
+
now?: () => number;
|
|
219
|
+
}
|
|
220
|
+
/**
|
|
221
|
+
* Public surface of the command-data service. Each method is the
|
|
222
|
+
* smallest possible projection so the dialog layer never has to know
|
|
223
|
+
* how the underlying quota manager or storage adapter is wired.
|
|
224
|
+
*/
|
|
225
|
+
export interface CommandDataService {
|
|
226
|
+
/**
|
|
227
|
+
* Cache-only snapshot. Performs zero quota manager calls — safe to
|
|
228
|
+
* call as part of the dialog's open path.
|
|
229
|
+
*/
|
|
230
|
+
listAccounts(): Promise<CommandAccountRow[]>;
|
|
231
|
+
/**
|
|
232
|
+
* Force-refresh quota through the shared quota manager, persist by
|
|
233
|
+
* refresh token, bump `cachedQuotaUpdatedAt`, and push a label-only
|
|
234
|
+
* sidebar snapshot. Returns the freshly persisted rows so the
|
|
235
|
+
* dialog can re-render in place.
|
|
236
|
+
*/
|
|
237
|
+
refreshQuota(): Promise<CommandAccountRow[]>;
|
|
238
|
+
/**
|
|
239
|
+
* Pin `index` as the active account for every family the dialog
|
|
240
|
+
* tracks (claude + gemini). Mutates the live AccountManager AND the
|
|
241
|
+
* locked storage so the new active index survives a restart. Returns
|
|
242
|
+
* the freshly projected rows so the dialog can re-render in place.
|
|
243
|
+
* Returns `null` when the index is out of range or the account has
|
|
244
|
+
* no refresh token — the dialog surfaces the null as a toast.
|
|
245
|
+
*/
|
|
246
|
+
setCurrentAccount(index: number): Promise<CommandAccountRow[] | null>;
|
|
247
|
+
/**
|
|
248
|
+
* Flip the `enabled` flag on the account at `index`. Mirrors the CLI
|
|
249
|
+
* menu's "manage" toggle so the on-disk state matches what the CLI
|
|
250
|
+
* would produce. Returns the freshly projected rows (or `null` when
|
|
251
|
+
* the index is invalid or the account is ineligible).
|
|
252
|
+
*/
|
|
253
|
+
toggleAccountEnabled(index: number): Promise<CommandAccountRow[] | null>;
|
|
254
|
+
/**
|
|
255
|
+
* Remove the account at `index` from both the live view and the
|
|
256
|
+
* locked storage. Removal renumbers the flat `accounts[]` array so
|
|
257
|
+
* the returned rows use the freshest indices; callers MUST re-key
|
|
258
|
+
* their transient dialog IDs (`acct-${index}`) by the row's `id`
|
|
259
|
+
* field after this method returns.
|
|
260
|
+
*
|
|
261
|
+
* Returns `null` when the index is out of range — the dialog
|
|
262
|
+
* surfaces the null as a toast.
|
|
263
|
+
*/
|
|
264
|
+
removeAccount(index: number): Promise<CommandAccountRow[] | null>;
|
|
265
|
+
}
|
|
266
|
+
/**
|
|
267
|
+
* Build the data service.
|
|
268
|
+
*
|
|
269
|
+
* The factory form (instead of a module-level singleton) keeps the
|
|
270
|
+
* service unit-testable: each test constructs its own dependencies
|
|
271
|
+
* (storage stub, quota manager stub, fixed clock) without touching
|
|
272
|
+
* the production quota path.
|
|
273
|
+
*/
|
|
274
|
+
export declare function createCommandDataService(options: CommandDataServiceOptions): CommandDataService;
|
|
275
|
+
export {};
|
|
276
|
+
//# sourceMappingURL=command-data.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"command-data.d.ts","sourceRoot":"","sources":["../../../src/plugin/command-data.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AAQH;;;;;;;;;;GAUG;AACH,KAAK,0BAA0B,GAAG;IAChC,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,YAAY,EAAE,MAAM,CAAA;IACpB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,gBAAgB,CAAC,EAAE,MAAM,CAAA;IACzB,OAAO,EAAE,MAAM,CAAA;IACf,QAAQ,EAAE,MAAM,CAAA;IAChB,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,WAAW,CAAC,EAAE,OAAO,CACnB,MAAM,CAAC,qBAAqB,EAAE,4BAA4B,CAAC,CAC5D,CAAA;IACD,oBAAoB,CAAC,EAAE,MAAM,CAAA;IAC7B,iBAAiB,CAAC,EAAE,OAAO,CAAA;CAC5B,CAAA;AAED,KAAK,qBAAqB,GACtB,QAAQ,GACR,YAAY,GACZ,cAAc,GACd,SAAS,CAAA;AAEb,KAAK,4BAA4B,GAAG;IAClC,iBAAiB,CAAC,EAAE,MAAM,CAAA;IAC1B,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,UAAU,EAAE,MAAM,CAAA;CACnB,CAAA;AAED,KAAK,6BAA6B,GAAG;IACnC,KAAK,EAAE,MAAM,CAAA;IACb,MAAM,EAAE,IAAI,GAAG,UAAU,GAAG,OAAO,CAAA;IACnC,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,KAAK,CAAC,EAAE;QACN,MAAM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