@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,832 @@
|
|
|
1
|
+
/** @jsxImportSource @opentui/solid */
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Imperative command-dialog dispatcher for the /antigravity-* slash commands.
|
|
5
|
+
*
|
|
6
|
+
* Mirrors the fleet sibling layout (see `anthropic-auth-live` /
|
|
7
|
+
* `openai-auth-live` `packages/opencode/src/tui/command-dialogs.tsx`):
|
|
8
|
+
* each command's dialog opens with its data/status content rendered into the
|
|
9
|
+
* dialog BODY as a column of plain `<text>` nodes — non-selectable,
|
|
10
|
+
* non-searchable — and a separate `<DialogSelect>` below carries ONLY the
|
|
11
|
+
* real actions with proper `{title, description}` shapes the host renders
|
|
12
|
+
* on separate lines. The earlier implementation crammed the data rows into
|
|
13
|
+
* `DialogSelect`'s `placeholder` (which participates in type-ahead search)
|
|
14
|
+
* and concatenated label+description into a single highlighted option line;
|
|
15
|
+
* this rewrite separates data from actions the way the host expects.
|
|
16
|
+
*
|
|
17
|
+
* Contract:
|
|
18
|
+
* - Every main/subdialog calls `api.ui.dialog.setSize('xlarge')` before
|
|
19
|
+
* `api.ui.dialog.replace()` so the host reserves enough width for the
|
|
20
|
+
* longest line in any branch.
|
|
21
|
+
* - `apply(command, args, options?)` is the RPC apply path the dispatch
|
|
22
|
+
* site (the module-scoped poll in `tui.tsx`) supplies. The dispatcher
|
|
23
|
+
* forwards `options.timeoutMs` so a long-running apply (account add /
|
|
24
|
+
* refresh, future quota refresh) gets the right RPC timeout.
|
|
25
|
+
* - All `DialogSelect` options must remain VISIBLE — the host's
|
|
26
|
+
* `disabled: true` is a hard hide, so this file must never set it.
|
|
27
|
+
* Invalid actions stay visible with an explanatory description and are
|
|
28
|
+
* rejected in `onSelect`. The `no hide-property option scan` test in
|
|
29
|
+
* the verification gates pins this contract.
|
|
30
|
+
* - `onSelect` awaits the apply, toasts the result, then either clears
|
|
31
|
+
* the dialog or replaces it for multi-step flows. The dialog stack
|
|
32
|
+
* never sees a `clear()` between apply and re-render so the user
|
|
33
|
+
* always sees feedback (per the dispatcher contract).
|
|
34
|
+
*/
|
|
35
|
+
|
|
36
|
+
import type { TuiPluginApi } from '@opencode-ai/plugin/tui'
|
|
37
|
+
import type { CommandAccountRow } from '../plugin/command-data'
|
|
38
|
+
import type { CommandModalName, OpenDialogPayload } from '../rpc/protocol'
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Apply handler the dispatcher calls when the user selects a dialog
|
|
42
|
+
* option. Mirrors `ApplyRequest` from `rpc/protocol` plus the
|
|
43
|
+
* `RpcRequestOptions.timeoutMs` knob the RPC client already accepts —
|
|
44
|
+
* the call site in `tui.tsx` forwards these directly into
|
|
45
|
+
* `rpcClient.apply(request, options)`.
|
|
46
|
+
*/
|
|
47
|
+
export type ApplyFn = (
|
|
48
|
+
command: CommandModalName,
|
|
49
|
+
args: string,
|
|
50
|
+
options?: { timeoutMs?: number },
|
|
51
|
+
) => Promise<{ text: string; knobs: Record<string, unknown> }>
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Mount the dialog for `payload.command` on the live TUI.
|
|
55
|
+
*
|
|
56
|
+
* The dispatcher branches on `payload.command` — each branch is
|
|
57
|
+
* self-contained: render the data body, render the host DialogSelect
|
|
58
|
+
* below it with the real actions, wire `onSelect` to await `apply(...)`,
|
|
59
|
+
* then toast the result and clear (or replace for multi-step flows).
|
|
60
|
+
* Unknown commands throw so a future command registered in
|
|
61
|
+
* `MODAL_COMMANDS` without a dispatcher branch fails loudly at the first
|
|
62
|
+
* dialog open.
|
|
63
|
+
*/
|
|
64
|
+
export function openCommandDialog(
|
|
65
|
+
api: TuiPluginApi,
|
|
66
|
+
payload: OpenDialogPayload,
|
|
67
|
+
apply: ApplyFn,
|
|
68
|
+
): void {
|
|
69
|
+
if (payload.command === 'antigravity-dump') {
|
|
70
|
+
renderDumpDialog(api, payload, apply)
|
|
71
|
+
return
|
|
72
|
+
}
|
|
73
|
+
if (payload.command === 'antigravity-logging') {
|
|
74
|
+
renderLoggingDialog(api, payload, apply)
|
|
75
|
+
return
|
|
76
|
+
}
|
|
77
|
+
if (payload.command === 'antigravity-quota') {
|
|
78
|
+
throw new Error('antigravity-quota is rendered by the TUI quota panel')
|
|
79
|
+
}
|
|
80
|
+
if (payload.command === 'antigravity-account') {
|
|
81
|
+
renderAccountDialog(api, payload, apply)
|
|
82
|
+
return
|
|
83
|
+
}
|
|
84
|
+
if (payload.command === 'antigravity-routing') {
|
|
85
|
+
renderRoutingDialog(api, payload, apply)
|
|
86
|
+
return
|
|
87
|
+
}
|
|
88
|
+
if (payload.command === 'antigravity-killswitch') {
|
|
89
|
+
renderKillswitchDialog(api, payload, apply)
|
|
90
|
+
return
|
|
91
|
+
}
|
|
92
|
+
const exhaustiveCheck: never = payload.command
|
|
93
|
+
throw new Error(`Unknown command ${exhaustiveCheck as string}`)
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
// ---------------------------------------------------------------------------
|
|
97
|
+
// Fully wired branches — non-data-first dialogs.
|
|
98
|
+
// ---------------------------------------------------------------------------
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* /antigravity-dump: three actions (on / off / status). Each selection
|
|
102
|
+
* applies through the RPC, toasts the result text, and clears the
|
|
103
|
+
* dialog. Status is a read-only check that still goes through apply so
|
|
104
|
+
* the dump helper runs once and reports the current state.
|
|
105
|
+
*/
|
|
106
|
+
function renderDumpDialog(
|
|
107
|
+
api: TuiPluginApi,
|
|
108
|
+
_payload: OpenDialogPayload,
|
|
109
|
+
apply: ApplyFn,
|
|
110
|
+
): void {
|
|
111
|
+
const DialogSelect = api.ui.DialogSelect<string>
|
|
112
|
+
api.ui.dialog.setSize('xlarge')
|
|
113
|
+
api.ui.dialog.replace(() => (
|
|
114
|
+
<DialogSelect
|
|
115
|
+
title='Antigravity wire dump'
|
|
116
|
+
options={[
|
|
117
|
+
{
|
|
118
|
+
title: 'Turn dump on',
|
|
119
|
+
value: 'on',
|
|
120
|
+
description: 'Write request and response bodies to the dump dir.',
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
title: 'Turn dump off',
|
|
124
|
+
value: 'off',
|
|
125
|
+
description: 'Stop writing new dump files.',
|
|
126
|
+
},
|
|
127
|
+
{
|
|
128
|
+
title: 'Show dump status',
|
|
129
|
+
value: 'status',
|
|
130
|
+
description: 'Display whether dumps are enabled and where they go.',
|
|
131
|
+
},
|
|
132
|
+
]}
|
|
133
|
+
onSelect={(option) => {
|
|
134
|
+
void apply('antigravity-dump', String(option.value)).then((result) => {
|
|
135
|
+
api.ui.toast({ message: result.text })
|
|
136
|
+
api.ui.dialog.clear()
|
|
137
|
+
})
|
|
138
|
+
}}
|
|
139
|
+
/>
|
|
140
|
+
))
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* /antigravity-logging: every log level as an option. The dispatcher
|
|
145
|
+
* forwards the level as the apply arg; the apply path persists it
|
|
146
|
+
* through `OperatorSettingsController` and toasts the resolution text.
|
|
147
|
+
*/
|
|
148
|
+
function renderLoggingDialog(
|
|
149
|
+
api: TuiPluginApi,
|
|
150
|
+
payload: OpenDialogPayload,
|
|
151
|
+
apply: ApplyFn,
|
|
152
|
+
): void {
|
|
153
|
+
const DialogSelect = api.ui.DialogSelect<string>
|
|
154
|
+
const current = (payload.knobs.log_level as string) ?? 'info'
|
|
155
|
+
api.ui.dialog.setSize('xlarge')
|
|
156
|
+
api.ui.dialog.replace(() => (
|
|
157
|
+
<DialogSelect
|
|
158
|
+
title='Antigravity logging'
|
|
159
|
+
current={current}
|
|
160
|
+
options={[
|
|
161
|
+
{ title: 'Error', value: 'error', description: 'Errors only.' },
|
|
162
|
+
{ title: 'Warn', value: 'warn', description: 'Warnings and errors.' },
|
|
163
|
+
{
|
|
164
|
+
title: 'Info',
|
|
165
|
+
value: 'info',
|
|
166
|
+
description: 'Default. Includes informational events.',
|
|
167
|
+
},
|
|
168
|
+
{
|
|
169
|
+
title: 'Debug',
|
|
170
|
+
value: 'debug',
|
|
171
|
+
description: 'Includes debug-level events.',
|
|
172
|
+
},
|
|
173
|
+
{
|
|
174
|
+
title: 'Trace',
|
|
175
|
+
value: 'trace',
|
|
176
|
+
description: 'Most verbose — every diagnostic event.',
|
|
177
|
+
},
|
|
178
|
+
]}
|
|
179
|
+
onSelect={(option) => {
|
|
180
|
+
void apply('antigravity-logging', String(option.value)).then(
|
|
181
|
+
(result) => {
|
|
182
|
+
api.ui.toast({ message: result.text })
|
|
183
|
+
api.ui.dialog.clear()
|
|
184
|
+
},
|
|
185
|
+
)
|
|
186
|
+
}}
|
|
187
|
+
/>
|
|
188
|
+
))
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
// ---------------------------------------------------------------------------
|
|
192
|
+
// Shared helpers — render data rows as plain text in the dialog body.
|
|
193
|
+
// ---------------------------------------------------------------------------
|
|
194
|
+
|
|
195
|
+
function formatQuotaRowLine(row: CommandAccountRow): string {
|
|
196
|
+
const status = row.enabled ? '' : ' (disabled)'
|
|
197
|
+
const current = row.current ? ' *' : ''
|
|
198
|
+
if (row.quota.length === 0) {
|
|
199
|
+
return `${row.label}${status}${current}: no cached quota`
|
|
200
|
+
}
|
|
201
|
+
const parts = row.quota.map((q) => {
|
|
202
|
+
const pct = q.remainingPercent == null ? '–%' : `${q.remainingPercent}%`
|
|
203
|
+
return `${q.label} ${pct}`
|
|
204
|
+
})
|
|
205
|
+
return `${row.label}${status}${current}: ${parts.join(', ')}`
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
/**
|
|
209
|
+
* /antigravity-account data-first dialog.
|
|
210
|
+
*
|
|
211
|
+
* The body lists each account row as a plain `<text>` node (cache-only
|
|
212
|
+
* — no network I/O on open). The DialogSelect carries ONLY real
|
|
213
|
+
* actions: Add account… and one drill-in entry per row. Drill-in
|
|
214
|
+
* navigates to a row-level subdialog that exposes toggle / set-current
|
|
215
|
+
* / remove with a DialogConfirm gate for the destructive path.
|
|
216
|
+
*
|
|
217
|
+
* Each action calls `apply('antigravity-account', '<verb> <index>')`,
|
|
218
|
+
* which the apply path translates into a locked-storage mutation.
|
|
219
|
+
* The service returns fresh `CommandAccountRow[]`; the dialog mutates
|
|
220
|
+
* its closed-over payload and re-renders via `renderMain()` so the
|
|
221
|
+
* user never sees a clear-then-redraw gap.
|
|
222
|
+
*/
|
|
223
|
+
function renderAccountDialog(
|
|
224
|
+
api: TuiPluginApi,
|
|
225
|
+
initialPayload: OpenDialogPayload,
|
|
226
|
+
apply: ApplyFn,
|
|
227
|
+
): void {
|
|
228
|
+
// Closed-over payload: every render reads from the latest snapshot.
|
|
229
|
+
const payload: OpenDialogPayload = { ...initialPayload }
|
|
230
|
+
|
|
231
|
+
const rowsFromKnobs = (): CommandAccountRow[] => {
|
|
232
|
+
const raw = payload.knobs.accounts
|
|
233
|
+
return Array.isArray(raw) ? (raw as CommandAccountRow[]) : []
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
const runApply = async (
|
|
237
|
+
args: string,
|
|
238
|
+
options?: { timeoutMs?: number },
|
|
239
|
+
): Promise<CommandAccountRow[] | null> => {
|
|
240
|
+
const result = await apply('antigravity-account', args, options)
|
|
241
|
+
api.ui.toast({ message: result.text })
|
|
242
|
+
const next = result.knobs.accounts
|
|
243
|
+
if (Array.isArray(next)) {
|
|
244
|
+
payload.knobs = {
|
|
245
|
+
...payload.knobs,
|
|
246
|
+
accounts: next as CommandAccountRow[],
|
|
247
|
+
}
|
|
248
|
+
renderMain()
|
|
249
|
+
return next as CommandAccountRow[]
|
|
250
|
+
}
|
|
251
|
+
renderMain()
|
|
252
|
+
return null
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
const updateAccounts = (knobs: Record<string, unknown>): void => {
|
|
256
|
+
const accounts = knobs.accounts
|
|
257
|
+
if (!Array.isArray(accounts)) return
|
|
258
|
+
payload.knobs = {
|
|
259
|
+
...payload.knobs,
|
|
260
|
+
accounts: accounts as CommandAccountRow[],
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
const openOAuthLabelPrompt = (code: string, oauthUrl: string): void => {
|
|
265
|
+
const DialogPrompt = api.ui.DialogPrompt
|
|
266
|
+
api.ui.dialog.setSize('xlarge')
|
|
267
|
+
api.ui.dialog.replace(() => (
|
|
268
|
+
<DialogPrompt
|
|
269
|
+
title='OAuth sign-in — label'
|
|
270
|
+
description={() => (
|
|
271
|
+
<text>A short name for this account (optional).</text>
|
|
272
|
+
)}
|
|
273
|
+
placeholder='e.g. work'
|
|
274
|
+
value=''
|
|
275
|
+
onConfirm={(value: string) => {
|
|
276
|
+
const label = value.trim()
|
|
277
|
+
const args = label
|
|
278
|
+
? `add-oauth-finish ${code} --label ${label}`
|
|
279
|
+
: `add-oauth-finish ${code}`
|
|
280
|
+
void apply('antigravity-account', args, { timeoutMs: 120_000 })
|
|
281
|
+
.then((result) => {
|
|
282
|
+
api.ui.toast({ message: result.text })
|
|
283
|
+
updateAccounts(result.knobs)
|
|
284
|
+
renderMain()
|
|
285
|
+
})
|
|
286
|
+
.catch(() => {
|
|
287
|
+
api.ui.toast({ message: 'OAuth account add failed' })
|
|
288
|
+
renderMain()
|
|
289
|
+
})
|
|
290
|
+
}}
|
|
291
|
+
onCancel={() => openOAuthCodePrompt(oauthUrl)}
|
|
292
|
+
/>
|
|
293
|
+
))
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
const openOAuthCodePrompt = (oauthUrl: string): void => {
|
|
297
|
+
const DialogPrompt = api.ui.DialogPrompt
|
|
298
|
+
api.ui.dialog.setSize('xlarge')
|
|
299
|
+
api.ui.dialog.replace(() => (
|
|
300
|
+
<DialogPrompt
|
|
301
|
+
title='OAuth sign-in — enter code'
|
|
302
|
+
description={() => (
|
|
303
|
+
<text>
|
|
304
|
+
After signing in, paste the full callback URL or authorization code.
|
|
305
|
+
</text>
|
|
306
|
+
)}
|
|
307
|
+
placeholder='Paste callback URL or code here'
|
|
308
|
+
value=''
|
|
309
|
+
onConfirm={(value: string) => {
|
|
310
|
+
const code = value.trim()
|
|
311
|
+
if (!code) {
|
|
312
|
+
// Empty submit must keep the user inside the flow, not
|
|
313
|
+
// silently drop them back to the account list. Surface the
|
|
314
|
+
// validation message and reopen the same prompt so the
|
|
315
|
+
// user can paste again.
|
|
316
|
+
api.ui.toast({
|
|
317
|
+
message: 'Please paste the callback URL or authorization code.',
|
|
318
|
+
})
|
|
319
|
+
openOAuthCodePrompt(oauthUrl)
|
|
320
|
+
return
|
|
321
|
+
}
|
|
322
|
+
openOAuthLabelPrompt(code, oauthUrl)
|
|
323
|
+
}}
|
|
324
|
+
onCancel={() => openOAuthUrlScreen(oauthUrl)}
|
|
325
|
+
/>
|
|
326
|
+
))
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
const openOAuthUrlScreen = (oauthUrl: string): void => {
|
|
330
|
+
const DialogSelect = api.ui.DialogSelect<string>
|
|
331
|
+
api.ui.dialog.setSize('xlarge')
|
|
332
|
+
api.ui.dialog.replace(() => (
|
|
333
|
+
<DialogSelect
|
|
334
|
+
title='OAuth sign-in'
|
|
335
|
+
options={[
|
|
336
|
+
{
|
|
337
|
+
title: 'Copy URL to clipboard',
|
|
338
|
+
value: 'copy',
|
|
339
|
+
description: oauthUrl,
|
|
340
|
+
},
|
|
341
|
+
{
|
|
342
|
+
title: 'Enter sign-in code',
|
|
343
|
+
value: 'code',
|
|
344
|
+
description:
|
|
345
|
+
'Open the URL in your browser, sign in, then paste the callback URL or code.',
|
|
346
|
+
},
|
|
347
|
+
{ title: 'Cancel', value: 'cancel' },
|
|
348
|
+
]}
|
|
349
|
+
onSelect={(option) => {
|
|
350
|
+
if (option.value === 'cancel') {
|
|
351
|
+
renderMain()
|
|
352
|
+
return
|
|
353
|
+
}
|
|
354
|
+
if (option.value === 'copy') {
|
|
355
|
+
const copied = api.renderer.copyToClipboardOSC52(oauthUrl)
|
|
356
|
+
api.ui.toast({
|
|
357
|
+
message: copied
|
|
358
|
+
? 'URL copied to clipboard'
|
|
359
|
+
: 'Copy unavailable — select the URL text above to copy',
|
|
360
|
+
})
|
|
361
|
+
openOAuthUrlScreen(oauthUrl)
|
|
362
|
+
return
|
|
363
|
+
}
|
|
364
|
+
openOAuthCodePrompt(oauthUrl)
|
|
365
|
+
}}
|
|
366
|
+
/>
|
|
367
|
+
))
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
const openAddOAuthStart = (): void => {
|
|
371
|
+
void apply('antigravity-account', 'add-oauth-start', {
|
|
372
|
+
timeoutMs: 120_000,
|
|
373
|
+
})
|
|
374
|
+
.then((result) => {
|
|
375
|
+
updateAccounts(result.knobs)
|
|
376
|
+
const oauthUrl = result.knobs.oauthUrl
|
|
377
|
+
if (typeof oauthUrl === 'string' && oauthUrl.length > 0) {
|
|
378
|
+
openOAuthUrlScreen(oauthUrl)
|
|
379
|
+
return
|
|
380
|
+
}
|
|
381
|
+
api.ui.toast({ message: result.text })
|
|
382
|
+
renderMain()
|
|
383
|
+
})
|
|
384
|
+
.catch(() => {
|
|
385
|
+
api.ui.toast({ message: 'OAuth account add failed' })
|
|
386
|
+
renderMain()
|
|
387
|
+
})
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
const renderManageRow = (row: CommandAccountRow): void => {
|
|
391
|
+
const DialogSelect = api.ui.DialogSelect<string>
|
|
392
|
+
api.ui.dialog.setSize('xlarge')
|
|
393
|
+
api.ui.dialog.replace(() => (
|
|
394
|
+
<box flexDirection='column' padding={1} width='100%'>
|
|
395
|
+
<text>{row.label}</text>
|
|
396
|
+
<text>
|
|
397
|
+
{row.quota.length === 0
|
|
398
|
+
? 'no cached quota'
|
|
399
|
+
: row.quota
|
|
400
|
+
.map((q) =>
|
|
401
|
+
q.remainingPercent == null
|
|
402
|
+
? `${q.label} –%`
|
|
403
|
+
: `${q.label} ${q.remainingPercent}%`,
|
|
404
|
+
)
|
|
405
|
+
.join(', ')}
|
|
406
|
+
</text>
|
|
407
|
+
<box marginTop={1}>
|
|
408
|
+
<DialogSelect
|
|
409
|
+
title={`Manage ${row.label}`}
|
|
410
|
+
options={[
|
|
411
|
+
{
|
|
412
|
+
title: row.enabled ? 'Disable account' : 'Enable account',
|
|
413
|
+
value: `toggle ${row.index}`,
|
|
414
|
+
description: row.enabled
|
|
415
|
+
? 'Skip this account in rotation when its quota is low.'
|
|
416
|
+
: 'Include this account in rotation again.',
|
|
417
|
+
},
|
|
418
|
+
{
|
|
419
|
+
title: 'Set as current',
|
|
420
|
+
value: `current ${row.index}`,
|
|
421
|
+
description:
|
|
422
|
+
'Pin this account as the active Claude + Gemini choice.',
|
|
423
|
+
},
|
|
424
|
+
{
|
|
425
|
+
title: 'Remove account…',
|
|
426
|
+
value: `__remove_prompt__ ${row.index}`,
|
|
427
|
+
description:
|
|
428
|
+
'Permanently delete this account from the local pool.',
|
|
429
|
+
},
|
|
430
|
+
{
|
|
431
|
+
title: 'Back',
|
|
432
|
+
value: '__back__',
|
|
433
|
+
description: 'Return to the account list.',
|
|
434
|
+
},
|
|
435
|
+
]}
|
|
436
|
+
onSelect={(option) => {
|
|
437
|
+
const raw = String(option.value)
|
|
438
|
+
if (raw === '__back__') {
|
|
439
|
+
renderMain()
|
|
440
|
+
return
|
|
441
|
+
}
|
|
442
|
+
if (raw.startsWith('__remove_prompt__ ')) {
|
|
443
|
+
const targetIndex = Number.parseInt(raw.split(' ')[1] ?? '', 10)
|
|
444
|
+
promptRemove(targetIndex)
|
|
445
|
+
return
|
|
446
|
+
}
|
|
447
|
+
if (raw.startsWith('toggle ') || raw.startsWith('current ')) {
|
|
448
|
+
void runApply(raw, { timeoutMs: 2_000 }).catch(() => {
|
|
449
|
+
api.ui.toast({
|
|
450
|
+
message: `${row.label}: action failed`,
|
|
451
|
+
})
|
|
452
|
+
})
|
|
453
|
+
return
|
|
454
|
+
}
|
|
455
|
+
api.ui.toast({
|
|
456
|
+
message: `${row.label}: unknown action`,
|
|
457
|
+
})
|
|
458
|
+
}}
|
|
459
|
+
/>
|
|
460
|
+
</box>
|
|
461
|
+
</box>
|
|
462
|
+
))
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
const promptRemove = (index: number): void => {
|
|
466
|
+
const DialogConfirm = api.ui.DialogConfirm
|
|
467
|
+
const row = rowsFromKnobs()[index]
|
|
468
|
+
api.ui.dialog.setSize('xlarge')
|
|
469
|
+
api.ui.dialog.replace(() => (
|
|
470
|
+
<DialogConfirm
|
|
471
|
+
title='Remove account'
|
|
472
|
+
message={`Permanently remove ${row?.label ?? `account ${index + 1}`} from the local pool? This cannot be undone.`}
|
|
473
|
+
onConfirm={async () => {
|
|
474
|
+
try {
|
|
475
|
+
const next = await runApply(`remove ${index}`, {
|
|
476
|
+
timeoutMs: 2_000,
|
|
477
|
+
})
|
|
478
|
+
if (next === null) {
|
|
479
|
+
renderMain()
|
|
480
|
+
}
|
|
481
|
+
} catch {
|
|
482
|
+
api.ui.toast({ message: 'Account remove failed' })
|
|
483
|
+
renderMain()
|
|
484
|
+
}
|
|
485
|
+
}}
|
|
486
|
+
onCancel={() => {
|
|
487
|
+
renderMain()
|
|
488
|
+
}}
|
|
489
|
+
/>
|
|
490
|
+
))
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
const renderMain = (): void => {
|
|
494
|
+
const DialogSelect = api.ui.DialogSelect<string>
|
|
495
|
+
api.ui.dialog.setSize('xlarge')
|
|
496
|
+
const rows = rowsFromKnobs()
|
|
497
|
+
const bodyLines = rows.length
|
|
498
|
+
? rows.map(formatQuotaRowLine)
|
|
499
|
+
: ['No accounts configured. Add one via the menu below.']
|
|
500
|
+
api.ui.dialog.replace(() => (
|
|
501
|
+
<box flexDirection='column' padding={1} width='100%'>
|
|
502
|
+
{bodyLines.map((line) => (
|
|
503
|
+
<text>{line}</text>
|
|
504
|
+
))}
|
|
505
|
+
<box marginTop={1}>
|
|
506
|
+
<DialogSelect
|
|
507
|
+
title='Antigravity accounts'
|
|
508
|
+
options={[
|
|
509
|
+
{
|
|
510
|
+
title: 'Add account…',
|
|
511
|
+
value: 'add',
|
|
512
|
+
description:
|
|
513
|
+
'Open the OAuth flow to add a new account (120s timeout).',
|
|
514
|
+
},
|
|
515
|
+
...rows.map((row) => ({
|
|
516
|
+
title: row.label,
|
|
517
|
+
value: `__manage__ ${row.index}`,
|
|
518
|
+
description: row.enabled
|
|
519
|
+
? row.current
|
|
520
|
+
? 'Current account — toggle, remove, or back.'
|
|
521
|
+
: 'Enabled — toggle, set as current, or remove.'
|
|
522
|
+
: 'Disabled — toggle to re-enable, or remove.',
|
|
523
|
+
})),
|
|
524
|
+
{ title: 'Back', value: 'back' },
|
|
525
|
+
]}
|
|
526
|
+
onSelect={(option) => {
|
|
527
|
+
const raw = String(option.value)
|
|
528
|
+
if (raw === 'back') {
|
|
529
|
+
api.ui.dialog.clear()
|
|
530
|
+
return
|
|
531
|
+
}
|
|
532
|
+
if (raw === 'add') {
|
|
533
|
+
openAddOAuthStart()
|
|
534
|
+
return
|
|
535
|
+
}
|
|
536
|
+
if (raw.startsWith('__manage__ ')) {
|
|
537
|
+
const targetIndex = Number.parseInt(raw.split(' ')[1] ?? '', 10)
|
|
538
|
+
const target = rows[targetIndex]
|
|
539
|
+
if (target) renderManageRow(target)
|
|
540
|
+
return
|
|
541
|
+
}
|
|
542
|
+
api.ui.toast({ message: 'Unknown action' })
|
|
543
|
+
}}
|
|
544
|
+
/>
|
|
545
|
+
</box>
|
|
546
|
+
</box>
|
|
547
|
+
))
|
|
548
|
+
}
|
|
549
|
+
|
|
550
|
+
renderMain()
|
|
551
|
+
}
|
|
552
|
+
|
|
553
|
+
/**
|
|
554
|
+
* /antigravity-routing data-first dialog.
|
|
555
|
+
*
|
|
556
|
+
* The body lists the current persisted values (`cli_first`,
|
|
557
|
+
* `quota_style_fallback`) as plain `<text>` nodes so the data is
|
|
558
|
+
* visible without filtering the action list. The DialogSelect carries
|
|
559
|
+
* ONLY real toggle actions — each row flips exactly one flag, awaits
|
|
560
|
+
* apply, toasts the result, and re-renders in place from the
|
|
561
|
+
* freshly-returned state.
|
|
562
|
+
*
|
|
563
|
+
* Re-render contract mirrors the quota/account dialogs: the
|
|
564
|
+
* closed-over `payload.knobs` is mutated with the apply response and
|
|
565
|
+
* `renderMain()` is re-invoked. The dialog stack never sees a
|
|
566
|
+
* `clear()` between apply and re-render.
|
|
567
|
+
*
|
|
568
|
+
* Error path: when apply returns a `knobs.error === true` payload
|
|
569
|
+
* (lock contention, unreadable config), the dispatcher does NOT swap
|
|
570
|
+
* the closed-over payload — the dialog stays mounted on the previous
|
|
571
|
+
* state so the user can retry or back out. The error message was
|
|
572
|
+
* already toasted by `runApply`.
|
|
573
|
+
*/
|
|
574
|
+
function renderRoutingDialog(
|
|
575
|
+
api: TuiPluginApi,
|
|
576
|
+
initialPayload: OpenDialogPayload,
|
|
577
|
+
apply: ApplyFn,
|
|
578
|
+
): void {
|
|
579
|
+
// Closed-over payload: every render reads from the latest snapshot.
|
|
580
|
+
const payload: OpenDialogPayload = { ...initialPayload }
|
|
581
|
+
|
|
582
|
+
const readRouting = (): { cliFirst: boolean; quotaFallback: boolean } => ({
|
|
583
|
+
cliFirst: payload.knobs.cli_first === true,
|
|
584
|
+
quotaFallback: payload.knobs.quota_style_fallback === true,
|
|
585
|
+
})
|
|
586
|
+
|
|
587
|
+
const runApply = async (args: string): Promise<void> => {
|
|
588
|
+
const result = await apply('antigravity-routing', args, {
|
|
589
|
+
timeoutMs: 2_000,
|
|
590
|
+
})
|
|
591
|
+
api.ui.toast({ message: result.text })
|
|
592
|
+
if (result.knobs.error === true) {
|
|
593
|
+
return
|
|
594
|
+
}
|
|
595
|
+
payload.knobs = {
|
|
596
|
+
...payload.knobs,
|
|
597
|
+
cli_first: result.knobs.cli_first,
|
|
598
|
+
quota_style_fallback: result.knobs.quota_style_fallback,
|
|
599
|
+
}
|
|
600
|
+
renderMain()
|
|
601
|
+
}
|
|
602
|
+
|
|
603
|
+
const renderMain = (): void => {
|
|
604
|
+
const DialogSelect = api.ui.DialogSelect<string>
|
|
605
|
+
api.ui.dialog.setSize('xlarge')
|
|
606
|
+
const { cliFirst, quotaFallback } = readRouting()
|
|
607
|
+
const bodyLines = [
|
|
608
|
+
`cli_first: ${cliFirst ? 'on' : 'off'}`,
|
|
609
|
+
`quota_style_fallback: ${quotaFallback ? 'on' : 'off'}`,
|
|
610
|
+
]
|
|
611
|
+
api.ui.dialog.replace(() => (
|
|
612
|
+
<box flexDirection='column' padding={1} width='100%'>
|
|
613
|
+
{bodyLines.map((line) => (
|
|
614
|
+
<text>{line}</text>
|
|
615
|
+
))}
|
|
616
|
+
<box marginTop={1}>
|
|
617
|
+
<DialogSelect
|
|
618
|
+
title='Antigravity routing'
|
|
619
|
+
options={[
|
|
620
|
+
{
|
|
621
|
+
title: `${cliFirst ? '●' : '○'} cli_first: ${cliFirst}`,
|
|
622
|
+
value: `cli_first=${!cliFirst}`,
|
|
623
|
+
description: cliFirst
|
|
624
|
+
? 'CLI is preferred before Antigravity. Click to turn off.'
|
|
625
|
+
: 'Antigravity runs before CLI. Click to turn on.',
|
|
626
|
+
},
|
|
627
|
+
{
|
|
628
|
+
title: `${quotaFallback ? '●' : '○'} quota_style_fallback: ${quotaFallback}`,
|
|
629
|
+
value: `quota_style_fallback=${!quotaFallback}`,
|
|
630
|
+
description: quotaFallback
|
|
631
|
+
? 'Falls back to the alternate quota style on exhaustion. Click to turn off.'
|
|
632
|
+
: 'No quota-style fallback today. Click to turn on.',
|
|
633
|
+
},
|
|
634
|
+
{ title: 'Back', value: 'back' },
|
|
635
|
+
]}
|
|
636
|
+
onSelect={(option) => {
|
|
637
|
+
const raw = String(option.value)
|
|
638
|
+
if (raw === 'back') {
|
|
639
|
+
api.ui.dialog.clear()
|
|
640
|
+
return
|
|
641
|
+
}
|
|
642
|
+
if (
|
|
643
|
+
!raw.startsWith('cli_first=') &&
|
|
644
|
+
!raw.startsWith('quota_style_fallback=')
|
|
645
|
+
) {
|
|
646
|
+
api.ui.toast({ message: 'Unknown routing action' })
|
|
647
|
+
return
|
|
648
|
+
}
|
|
649
|
+
void runApply(raw).catch(() => {
|
|
650
|
+
api.ui.toast({ message: 'Routing update failed' })
|
|
651
|
+
renderMain()
|
|
652
|
+
})
|
|
653
|
+
}}
|
|
654
|
+
/>
|
|
655
|
+
</box>
|
|
656
|
+
</box>
|
|
657
|
+
))
|
|
658
|
+
}
|
|
659
|
+
|
|
660
|
+
renderMain()
|
|
661
|
+
}
|
|
662
|
+
|
|
663
|
+
/**
|
|
664
|
+
* /antigravity-killswitch data-first dialog.
|
|
665
|
+
*
|
|
666
|
+
* The body lists the current persisted killswitch state (`enabled`,
|
|
667
|
+
* `minimum_remaining_percent`, and the per-account override map) as
|
|
668
|
+
* plain `<text>` nodes. The DialogSelect carries ONLY real actions:
|
|
669
|
+
* the global enabled toggle, the threshold-edit prompt, and a Back
|
|
670
|
+
* affordance. The threshold edit opens a DialogPrompt for a fresh
|
|
671
|
+
* integer in `0..100`; out-of-range input stays at the prompt without
|
|
672
|
+
* applying.
|
|
673
|
+
*
|
|
674
|
+
* Re-render contract matches the routing dialog: the closed-over
|
|
675
|
+
* `payload.knobs` is swapped to the apply response on success and
|
|
676
|
+
* `renderMain()` re-runs. Errors leave the payload untouched.
|
|
677
|
+
*/
|
|
678
|
+
function renderKillswitchDialog(
|
|
679
|
+
api: TuiPluginApi,
|
|
680
|
+
initialPayload: OpenDialogPayload,
|
|
681
|
+
apply: ApplyFn,
|
|
682
|
+
): void {
|
|
683
|
+
const payload: OpenDialogPayload = { ...initialPayload }
|
|
684
|
+
|
|
685
|
+
const readKillswitch = (): {
|
|
686
|
+
enabled: boolean
|
|
687
|
+
minimum: number
|
|
688
|
+
accounts: Record<string, number>
|
|
689
|
+
} => {
|
|
690
|
+
const enabled = payload.knobs.enabled === true
|
|
691
|
+
const rawMin = payload.knobs.minimum_remaining_percent
|
|
692
|
+
const minimum =
|
|
693
|
+
typeof rawMin === 'number' && Number.isFinite(rawMin)
|
|
694
|
+
? Math.max(0, Math.min(100, Math.round(rawMin)))
|
|
695
|
+
: 0
|
|
696
|
+
const rawAccounts = payload.knobs.accounts
|
|
697
|
+
const accounts =
|
|
698
|
+
rawAccounts &&
|
|
699
|
+
typeof rawAccounts === 'object' &&
|
|
700
|
+
!Array.isArray(rawAccounts)
|
|
701
|
+
? (rawAccounts as Record<string, number>)
|
|
702
|
+
: {}
|
|
703
|
+
return { enabled, minimum, accounts }
|
|
704
|
+
}
|
|
705
|
+
|
|
706
|
+
const runApply = async (args: string): Promise<void> => {
|
|
707
|
+
const result = await apply('antigravity-killswitch', args, {
|
|
708
|
+
timeoutMs: 2_000,
|
|
709
|
+
})
|
|
710
|
+
api.ui.toast({ message: result.text })
|
|
711
|
+
if (result.knobs.error === true) {
|
|
712
|
+
return
|
|
713
|
+
}
|
|
714
|
+
payload.knobs = {
|
|
715
|
+
...payload.knobs,
|
|
716
|
+
enabled: result.knobs.enabled,
|
|
717
|
+
minimum_remaining_percent: result.knobs.minimum_remaining_percent,
|
|
718
|
+
accounts: result.knobs.accounts ?? {},
|
|
719
|
+
}
|
|
720
|
+
renderMain()
|
|
721
|
+
}
|
|
722
|
+
|
|
723
|
+
const openThresholdPrompt = (currentMinimum: number): void => {
|
|
724
|
+
const DialogPrompt = api.ui.DialogPrompt
|
|
725
|
+
api.ui.dialog.setSize('xlarge')
|
|
726
|
+
api.ui.dialog.replace(() => (
|
|
727
|
+
<DialogPrompt
|
|
728
|
+
title='Antigravity killswitch — set threshold'
|
|
729
|
+
description={() => (
|
|
730
|
+
<text>
|
|
731
|
+
Enter a new minimum_remaining_percent (0-100). Empty input cancels.
|
|
732
|
+
</text>
|
|
733
|
+
)}
|
|
734
|
+
placeholder={`${currentMinimum}`}
|
|
735
|
+
value={`${currentMinimum}`}
|
|
736
|
+
onConfirm={(value: string) => {
|
|
737
|
+
const trimmed = value.trim()
|
|
738
|
+
if (!trimmed) {
|
|
739
|
+
renderMain()
|
|
740
|
+
return
|
|
741
|
+
}
|
|
742
|
+
const parsed = Number.parseInt(trimmed, 10)
|
|
743
|
+
if (
|
|
744
|
+
!Number.isInteger(parsed) ||
|
|
745
|
+
parsed < 0 ||
|
|
746
|
+
parsed > 100 ||
|
|
747
|
+
String(parsed) !== trimmed
|
|
748
|
+
) {
|
|
749
|
+
api.ui.toast({
|
|
750
|
+
message: 'Threshold must be an integer between 0 and 100',
|
|
751
|
+
})
|
|
752
|
+
openThresholdPrompt(currentMinimum)
|
|
753
|
+
return
|
|
754
|
+
}
|
|
755
|
+
void runApply(`minimum_remaining_percent=${parsed}`).catch(() => {
|
|
756
|
+
api.ui.toast({ message: 'Killswitch update failed' })
|
|
757
|
+
renderMain()
|
|
758
|
+
})
|
|
759
|
+
}}
|
|
760
|
+
onCancel={() => {
|
|
761
|
+
renderMain()
|
|
762
|
+
}}
|
|
763
|
+
/>
|
|
764
|
+
))
|
|
765
|
+
}
|
|
766
|
+
|
|
767
|
+
const renderMain = (): void => {
|
|
768
|
+
const DialogSelect = api.ui.DialogSelect<string>
|
|
769
|
+
api.ui.dialog.setSize('xlarge')
|
|
770
|
+
const { enabled, minimum, accounts } = readKillswitch()
|
|
771
|
+
const accountKeys = Object.keys(accounts)
|
|
772
|
+
const bodyLines = [
|
|
773
|
+
`Killswitch: ${enabled ? 'enabled' : 'disabled'}`,
|
|
774
|
+
`Minimum remaining percent: ${minimum}%`,
|
|
775
|
+
...(accountKeys.length > 0
|
|
776
|
+
? [
|
|
777
|
+
'Per-account overrides:',
|
|
778
|
+
...accountKeys.map((key) => ` ${key}: ${accounts[key] ?? 0}%`),
|
|
779
|
+
]
|
|
780
|
+
: []),
|
|
781
|
+
]
|
|
782
|
+
api.ui.dialog.replace(() => (
|
|
783
|
+
<box flexDirection='column' padding={1} width='100%'>
|
|
784
|
+
{bodyLines.map((line) => (
|
|
785
|
+
<text>{line}</text>
|
|
786
|
+
))}
|
|
787
|
+
<box marginTop={1}>
|
|
788
|
+
<DialogSelect
|
|
789
|
+
title='Antigravity killswitch'
|
|
790
|
+
options={[
|
|
791
|
+
{
|
|
792
|
+
title: `${enabled ? '●' : '○'} Killswitch: ${enabled ? 'enabled' : 'disabled'}`,
|
|
793
|
+
value: `enabled=${!enabled}`,
|
|
794
|
+
description: enabled
|
|
795
|
+
? 'Drop candidates below the floor before dispatch. Click to turn off.'
|
|
796
|
+
: 'Resume candidate selection regardless of quota. Click to turn on.',
|
|
797
|
+
},
|
|
798
|
+
{
|
|
799
|
+
title: `Set minimum remaining percent (${minimum}%)`,
|
|
800
|
+
value: '__edit_threshold__',
|
|
801
|
+
description:
|
|
802
|
+
'Prompt for a new global floor (0-100). Per-account overrides are listed above.',
|
|
803
|
+
},
|
|
804
|
+
{ title: 'Back', value: 'back' },
|
|
805
|
+
]}
|
|
806
|
+
onSelect={(option) => {
|
|
807
|
+
const raw = String(option.value)
|
|
808
|
+
if (raw === 'back') {
|
|
809
|
+
api.ui.dialog.clear()
|
|
810
|
+
return
|
|
811
|
+
}
|
|
812
|
+
if (raw === '__edit_threshold__') {
|
|
813
|
+
openThresholdPrompt(minimum)
|
|
814
|
+
return
|
|
815
|
+
}
|
|
816
|
+
if (raw === 'enabled=true' || raw === 'enabled=false') {
|
|
817
|
+
void runApply(raw).catch(() => {
|
|
818
|
+
api.ui.toast({ message: 'Killswitch update failed' })
|
|
819
|
+
renderMain()
|
|
820
|
+
})
|
|
821
|
+
return
|
|
822
|
+
}
|
|
823
|
+
api.ui.toast({ message: 'Unknown killswitch action' })
|
|
824
|
+
}}
|
|
825
|
+
/>
|
|
826
|
+
</box>
|
|
827
|
+
</box>
|
|
828
|
+
))
|
|
829
|
+
}
|
|
830
|
+
|
|
831
|
+
renderMain()
|
|
832
|
+
}
|