@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,129 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Composition seam for the opencode Antigravity plugin.
|
|
3
|
+
*
|
|
4
|
+
* `createAntigravityPlugin` is the single host-facing factory. Its surface
|
|
5
|
+
* stayed stable for years (input → PluginResult) so production callers
|
|
6
|
+
* never needed to think about which fetch, transport, or OAuth primitive
|
|
7
|
+
* actually runs under the hood. Tests had to either reach for
|
|
8
|
+
* `mock.module('./agy-transport', …)` or stub `globalThis.fetch` — both
|
|
9
|
+
* leaks that pull on module-graph seams that should be invisible to the
|
|
10
|
+
* factory's public surface.
|
|
11
|
+
*
|
|
12
|
+
* The contract here is intentionally narrow:
|
|
13
|
+
* - Every dependency below has a default that maps to the current
|
|
14
|
+
* production function (i.e. no behavior change in production).
|
|
15
|
+
* - Tests inject deterministic doubles for fetch / transport / OAuth /
|
|
16
|
+
* filesystem roots / clock so the e2e workspace can run without
|
|
17
|
+
* hitting the public internet or a real disk root.
|
|
18
|
+
* - No dependency below is intended to leak into the public exports of
|
|
19
|
+
* `packages/opencode/index.ts`. That barrel stays at "create the
|
|
20
|
+
* plugin and give me a PluginResult" — the override shape is a test-
|
|
21
|
+
* time contract, not a stable API.
|
|
22
|
+
*
|
|
23
|
+
* Anything that already had an inline `dependencies:` injection point on
|
|
24
|
+
* a sub-factory (auth-loader, oauth-methods) is intentionally NOT re-
|
|
25
|
+
* surfaced here. Those seams already work; the goal of THIS file is to
|
|
26
|
+
* catch the seams that did NOT exist yet (fetch, transport, env-resolved
|
|
27
|
+
* filesystem roots, clock).
|
|
28
|
+
*/
|
|
29
|
+
import { type AgyTransportOptions } from '@cortexkit/antigravity-auth-core';
|
|
30
|
+
import { authorizeAntigravity, exchangeAntigravity } from '../antigravity/oauth';
|
|
31
|
+
import type { AntigravityConfig } from './config';
|
|
32
|
+
import type { GetAuth, PluginClient } from './types';
|
|
33
|
+
/**
|
|
34
|
+
* Transport adapter shape — wraps the existing `fetchWithAgyCliTransport`
|
|
35
|
+
* export from core so the interceptor never reaches across the package
|
|
36
|
+
* boundary. Keeping it in this file (rather than re-exporting core)
|
|
37
|
+
* means we can change the transport signature without rippling through
|
|
38
|
+
* plugin callers.
|
|
39
|
+
*/
|
|
40
|
+
export type AgyTransport = (url: string, init?: RequestInit, options?: AgyTransportOptions) => Promise<Response>;
|
|
41
|
+
/**
|
|
42
|
+
* Per-call HTTP shape used for non-Antigravity URLs (e.g. loopback RPC,
|
|
43
|
+
* local project probes). Tests inject a deterministic stub; production
|
|
44
|
+
* keeps `globalThis.fetch` so the interceptor transparently benefits from
|
|
45
|
+
* whatever fetch the host runtime provides.
|
|
46
|
+
*/
|
|
47
|
+
export type FetchImpl = (input: RequestInfo | URL, init?: RequestInit) => Promise<Response>;
|
|
48
|
+
export interface FilesystemRoots {
|
|
49
|
+
/** Root used for project-scoped config (`{root}/.opencode/antigravity.json`). */
|
|
50
|
+
projectRoot: string;
|
|
51
|
+
/** Root used for the user-level config (`~/.config/opencode/antigravity.json`). */
|
|
52
|
+
userConfigRoot: string;
|
|
53
|
+
/** Root used for the sidebar state file. */
|
|
54
|
+
sidebarStateRoot: string;
|
|
55
|
+
/** Root used for the RPC server port file. */
|
|
56
|
+
rpcRoot: string;
|
|
57
|
+
}
|
|
58
|
+
export interface OAuthOperations {
|
|
59
|
+
authorize: typeof authorizeAntigravity;
|
|
60
|
+
exchange: typeof exchangeAntigravity;
|
|
61
|
+
}
|
|
62
|
+
export interface ClockFunctions {
|
|
63
|
+
now(): number;
|
|
64
|
+
random(): number;
|
|
65
|
+
sleep(ms: number, signal?: AbortSignal): Promise<void>;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Fully resolved dependency bag consumed by every plugin sub-module.
|
|
69
|
+
*
|
|
70
|
+
* `resolvePluginDependencies` fills any missing slot with the production
|
|
71
|
+
* default; `createAntigravityPlugin` calls it once and threads the result
|
|
72
|
+
* into fetch-interceptor / quota / auth-loader / oauth-methods.
|
|
73
|
+
*/
|
|
74
|
+
export interface PluginDependencies {
|
|
75
|
+
fetchImpl: FetchImpl;
|
|
76
|
+
agyTransport: AgyTransport;
|
|
77
|
+
filesystemRoots: FilesystemRoots;
|
|
78
|
+
oauth: OAuthOperations;
|
|
79
|
+
clock: ClockFunctions;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* User-supplied override bag — every field is optional. Production callers
|
|
83
|
+
* omit it entirely; tests fill only the slots they care about (typically
|
|
84
|
+
* `fetchImpl`, `agyTransport`, `filesystemRoots`).
|
|
85
|
+
*/
|
|
86
|
+
export interface PluginDependencyOverrides {
|
|
87
|
+
fetchImpl?: FetchImpl;
|
|
88
|
+
agyTransport?: AgyTransport;
|
|
89
|
+
filesystemRoots?: Partial<FilesystemRoots>;
|
|
90
|
+
oauth?: Partial<OAuthOperations>;
|
|
91
|
+
clock?: Partial<ClockFunctions>;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Carry context the sub-factories need (the active client, the resolved
|
|
95
|
+
* dependencies, plus the read-only config). Passed to the fetch
|
|
96
|
+
* interceptor, quota manager, auth loader, and oauth methods so each
|
|
97
|
+
* one sees the same bag without having to resolve defaults twice.
|
|
98
|
+
*/
|
|
99
|
+
export interface ResolvedPluginContext {
|
|
100
|
+
client: PluginClient;
|
|
101
|
+
config: AntigravityConfig;
|
|
102
|
+
providerId: string;
|
|
103
|
+
directory: string;
|
|
104
|
+
dependencies: PluginDependencies;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Default filesystem roots that mirror the loader's production layout.
|
|
108
|
+
*
|
|
109
|
+
* Tests override `filesystemRoots` to point at a temp directory — the
|
|
110
|
+
* plugin will then read/write config + sidebar + port files inside the
|
|
111
|
+
* test's mkdtemp root, never touching the host's actual HOME or XDG
|
|
112
|
+
* dirs.
|
|
113
|
+
*/
|
|
114
|
+
export declare function defaultFilesystemRoots(): FilesystemRoots;
|
|
115
|
+
/**
|
|
116
|
+
* Build the default dependency bag used by production. Each default is
|
|
117
|
+
* deliberately written so the e2e tests can re-use the same functions
|
|
118
|
+
* (e.g. `fetchImpl` defaults to `globalThis.fetch` — a test that wants
|
|
119
|
+
* a stub can replace `globalThis.fetch` and the production bag picks it
|
|
120
|
+
* up on the next call).
|
|
121
|
+
*/
|
|
122
|
+
export declare function resolvePluginDependencies(overrides?: PluginDependencyOverrides): PluginDependencies;
|
|
123
|
+
/**
|
|
124
|
+
* Default `getAuth` placeholder used by sub-modules that require one
|
|
125
|
+
* (auth-loader, fetch-interceptor). The plugin entry builds the live
|
|
126
|
+
* version once auth has loaded.
|
|
127
|
+
*/
|
|
128
|
+
export declare const placeholderGetAuth: GetAuth;
|
|
129
|
+
//# sourceMappingURL=dependencies.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dependencies.d.ts","sourceRoot":"","sources":["../../../src/plugin/dependencies.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAKH,OAAO,EACL,KAAK,mBAAmB,EAEzB,MAAM,kCAAkC,CAAA;AAEzC,OAAO,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAA;AAChF,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAA;AACjD,OAAO,KAAK,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AAEpD;;;;;;GAMG;AACH,MAAM,MAAM,YAAY,GAAG,CACzB,GAAG,EAAE,MAAM,EACX,IAAI,CAAC,EAAE,WAAW,EAClB,OAAO,CAAC,EAAE,mBAAmB,KAC1B,OAAO,CAAC,QAAQ,CAAC,CAAA;AAEtB;;;;;GAKG;AACH,MAAM,MAAM,SAAS,GAAG,CACtB,KAAK,EAAE,WAAW,GAAG,GAAG,EACxB,IAAI,CAAC,EAAE,WAAW,KACf,OAAO,CAAC,QAAQ,CAAC,CAAA;AAEtB,MAAM,WAAW,eAAe;IAC9B,iFAAiF;IACjF,WAAW,EAAE,MAAM,CAAA;IACnB,mFAAmF;IACnF,cAAc,EAAE,MAAM,CAAA;IACtB,4CAA4C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G;AACH,eAAO,MAAM,kBAAkB,EAAE,OAG/B,CAAA"}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Composition seam for the opencode Antigravity plugin.
|
|
3
|
+
*
|
|
4
|
+
* `createAntigravityPlugin` is the single host-facing factory. Its surface
|
|
5
|
+
* stayed stable for years (input → PluginResult) so production callers
|
|
6
|
+
* never needed to think about which fetch, transport, or OAuth primitive
|
|
7
|
+
* actually runs under the hood. Tests had to either reach for
|
|
8
|
+
* `mock.module('./agy-transport', …)` or stub `globalThis.fetch` — both
|
|
9
|
+
* leaks that pull on module-graph seams that should be invisible to the
|
|
10
|
+
* factory's public surface.
|
|
11
|
+
*
|
|
12
|
+
* The contract here is intentionally narrow:
|
|
13
|
+
* - Every dependency below has a default that maps to the current
|
|
14
|
+
* production function (i.e. no behavior change in production).
|
|
15
|
+
* - Tests inject deterministic doubles for fetch / transport / OAuth /
|
|
16
|
+
* filesystem roots / clock so the e2e workspace can run without
|
|
17
|
+
* hitting the public internet or a real disk root.
|
|
18
|
+
* - No dependency below is intended to leak into the public exports of
|
|
19
|
+
* `packages/opencode/index.ts`. That barrel stays at "create the
|
|
20
|
+
* plugin and give me a PluginResult" — the override shape is a test-
|
|
21
|
+
* time contract, not a stable API.
|
|
22
|
+
*
|
|
23
|
+
* Anything that already had an inline `dependencies:` injection point on
|
|
24
|
+
* a sub-factory (auth-loader, oauth-methods) is intentionally NOT re-
|
|
25
|
+
* surfaced here. Those seams already work; the goal of THIS file is to
|
|
26
|
+
* catch the seams that did NOT exist yet (fetch, transport, env-resolved
|
|
27
|
+
* filesystem roots, clock).
|
|
28
|
+
*/
|
|
29
|
+
import { homedir } from 'node:os';
|
|
30
|
+
import { join } from 'node:path';
|
|
31
|
+
import { fetchWithAgyCliTransport, } from '@cortexkit/antigravity-auth-core';
|
|
32
|
+
import { authorizeAntigravity, exchangeAntigravity } from '../antigravity/oauth';
|
|
33
|
+
/**
|
|
34
|
+
* Default filesystem roots that mirror the loader's production layout.
|
|
35
|
+
*
|
|
36
|
+
* Tests override `filesystemRoots` to point at a temp directory — the
|
|
37
|
+
* plugin will then read/write config + sidebar + port files inside the
|
|
38
|
+
* test's mkdtemp root, never touching the host's actual HOME or XDG
|
|
39
|
+
* dirs.
|
|
40
|
+
*/
|
|
41
|
+
export function defaultFilesystemRoots() {
|
|
42
|
+
const xdgConfig = process.env.XDG_CONFIG_HOME ?? join(homedir(), '.config');
|
|
43
|
+
const xdgState = process.env.XDG_STATE_HOME ?? join(homedir(), '.local', 'state');
|
|
44
|
+
return {
|
|
45
|
+
projectRoot: process.cwd(),
|
|
46
|
+
userConfigRoot: join(xdgConfig, 'opencode'),
|
|
47
|
+
sidebarStateRoot: join(xdgState, 'cortexkit', 'antigravity-auth'),
|
|
48
|
+
rpcRoot: join(xdgState, 'cortexkit', 'antigravity-auth', 'rpc'),
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Build the default dependency bag used by production. Each default is
|
|
53
|
+
* deliberately written so the e2e tests can re-use the same functions
|
|
54
|
+
* (e.g. `fetchImpl` defaults to `globalThis.fetch` — a test that wants
|
|
55
|
+
* a stub can replace `globalThis.fetch` and the production bag picks it
|
|
56
|
+
* up on the next call).
|
|
57
|
+
*/
|
|
58
|
+
export function resolvePluginDependencies(overrides = {}) {
|
|
59
|
+
const fetchImpl = overrides.fetchImpl ?? ((input, init) => globalThis.fetch(input, init));
|
|
60
|
+
const agyTransport = overrides.agyTransport ?? fetchWithAgyCliTransport;
|
|
61
|
+
const roots = {
|
|
62
|
+
...defaultFilesystemRoots(),
|
|
63
|
+
...overrides.filesystemRoots,
|
|
64
|
+
};
|
|
65
|
+
const oauth = {
|
|
66
|
+
authorize: overrides.oauth?.authorize ?? authorizeAntigravity,
|
|
67
|
+
exchange: overrides.oauth?.exchange ?? exchangeAntigravity,
|
|
68
|
+
};
|
|
69
|
+
const clock = {
|
|
70
|
+
now: overrides.clock?.now ?? (() => Date.now()),
|
|
71
|
+
random: overrides.clock?.random ?? Math.random,
|
|
72
|
+
sleep: overrides.clock?.sleep ?? defaultSleep,
|
|
73
|
+
};
|
|
74
|
+
return {
|
|
75
|
+
fetchImpl,
|
|
76
|
+
agyTransport,
|
|
77
|
+
filesystemRoots: roots,
|
|
78
|
+
oauth,
|
|
79
|
+
clock,
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
async function defaultSleep(ms, signal) {
|
|
83
|
+
if (ms <= 0)
|
|
84
|
+
return;
|
|
85
|
+
await new Promise((resolve, reject) => {
|
|
86
|
+
const timer = setTimeout(() => {
|
|
87
|
+
signal?.removeEventListener('abort', onAbort);
|
|
88
|
+
resolve();
|
|
89
|
+
}, ms);
|
|
90
|
+
timer.unref?.();
|
|
91
|
+
const onAbort = () => {
|
|
92
|
+
clearTimeout(timer);
|
|
93
|
+
reject(signal?.reason instanceof Error ? signal.reason : new Error('Aborted'));
|
|
94
|
+
};
|
|
95
|
+
signal?.addEventListener('abort', onAbort, { once: true });
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Default `getAuth` placeholder used by sub-modules that require one
|
|
100
|
+
* (auth-loader, fetch-interceptor). The plugin entry builds the live
|
|
101
|
+
* version once auth has loaded.
|
|
102
|
+
*/
|
|
103
|
+
export const placeholderGetAuth = async () => ({
|
|
104
|
+
type: 'api_key',
|
|
105
|
+
key: '',
|
|
106
|
+
});
|
|
107
|
+
//# sourceMappingURL=dependencies.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dependencies.js","sourceRoot":"","sources":["../../../src/plugin/dependencies.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AACjC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAEhC,OAAO,EAEL,wBAAwB,GACzB,MAAM,kCAAkC,CAAA;AA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@@ export declare class ToolIdMismatchError extends Error {
|
|
|
25
25
|
readonly foundIds: string[];
|
|
26
26
|
constructor(expectedIds: string[], foundIds: string[], message?: string);
|
|
27
27
|
}
|
|
28
|
+
/**
|
|
29
|
+
* Thrown when the operator killswitch excludes every available account.
|
|
30
|
+
*
|
|
31
|
+
* The killswitch compares each candidate's freshest cached quota
|
|
32
|
+
* remaining-percent against an account-specific override (or the
|
|
33
|
+
* global threshold) and excludes accounts below the floor. When all
|
|
34
|
+
* accounts are excluded, the fetch interceptor throws this error
|
|
35
|
+
* with redacted summaries so the host can surface a useful message
|
|
36
|
+
* without exposing any account identifiers or tokens.
|
|
37
|
+
*/
|
|
38
|
+
export declare class AntigravityKillswitchError extends Error {
|
|
39
|
+
readonly family: string;
|
|
40
|
+
readonly model: string;
|
|
41
|
+
readonly thresholdPercent: number;
|
|
42
|
+
readonly summaries: Array<{
|
|
43
|
+
accountKey: string;
|
|
44
|
+
remainingPercent: number | null;
|
|
45
|
+
thresholdPercent: number;
|
|
46
|
+
}>;
|
|
47
|
+
constructor(input: {
|
|
48
|
+
family: string;
|
|
49
|
+
model: string;
|
|
50
|
+
thresholdPercent: number;
|
|
51
|
+
summaries: AntigravityKillswitchError['summaries'];
|
|
52
|
+
message?: string;
|
|
53
|
+
});
|
|
54
|
+
}
|
|
28
55
|
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../../src/plugin/errors.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;;;;GAOG;AACH,qBAAa,kBAAmB,SAAQ,KAAK;IAC3C,QAAQ,CAAC,QAAQ,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../../src/plugin/errors.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;;;;GAOG;AACH,qBAAa,kBAAmB,SAAQ,KAAK;IAC3C,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;IACzB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;IACtB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;gBAGvB,QAAQ,EAAE,MAAM,EAChB,KAAK,EAAE,MAAM,EACb,QAAQ,EAAE,MAAM,EAChB,OAAO,CAAC,EAAE,MAAM;CAYnB;AAED;;GAEG;AACH,qBAAa,mBAAoB,SAAQ,KAAK;IAC5C,QAAQ,CAAC,WAAW,EAAE,MAAM,EAAE,CAAA;IAC9B,QAAQ,CAAC,QAAQ,EAAE,MAAM,EAAE,CAAA;gBAEf,WAAW,EAAE,MAAM,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,OAAO,CAAC,EAAE,MAAM;CASxE;AAED;;;;;;;;;GASG;AACH,qBAAa,0BAA2B,SAAQ,KAAK;IACnD,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;IACvB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;IACtB,QAAQ,CAAC,gBAAgB,EAAE,MAAM,CAAA;IACjC,QAAQ,CAAC,SAAS,EAAE,KAAK,CAAC;QACxB,UAAU,EAAE,MAAM,CAAA;QAClB,gBAAgB,EAAE,MAAM,GAAG,IAAI,CAAA;QAC/B,gBAAgB,EAAE,MAAM,CAAA;KACzB,CAAC,CAAA;gBAEU,KAAK,EAAE;QACjB,MAAM,EAAE,MAAM,CAAA;QACd,KAAK,EAAE,MAAM,CAAA;QACb,gBAAgB,EAAE,MAAM,CAAA;QACxB,SAAS,EAAE,0BAA0B,CAAC,WAAW,CAAC,CAAA;QAClD,OAAO,CAAC,EAAE,MAAM,CAAA;KACjB;CAYF"}
|
|
@@ -19,7 +19,7 @@ export class EmptyResponseError extends Error {
|
|
|
19
19
|
super(message ??
|
|
20
20
|
`The model returned an empty response after ${attempts} attempts. ` +
|
|
21
21
|
`This may indicate a temporary service issue. Please try again.`);
|
|
22
|
-
this.name =
|
|
22
|
+
this.name = 'EmptyResponseError';
|
|
23
23
|
this.provider = provider;
|
|
24
24
|
this.model = model;
|
|
25
25
|
this.attempts = attempts;
|
|
@@ -33,10 +33,36 @@ export class ToolIdMismatchError extends Error {
|
|
|
33
33
|
foundIds;
|
|
34
34
|
constructor(expectedIds, foundIds, message) {
|
|
35
35
|
super(message ??
|
|
36
|
-
`Tool ID mismatch: expected [${expectedIds.join(
|
|
37
|
-
this.name =
|
|
36
|
+
`Tool ID mismatch: expected [${expectedIds.join(', ')}] but found [${foundIds.join(', ')}]`);
|
|
37
|
+
this.name = 'ToolIdMismatchError';
|
|
38
38
|
this.expectedIds = expectedIds;
|
|
39
39
|
this.foundIds = foundIds;
|
|
40
40
|
}
|
|
41
41
|
}
|
|
42
|
+
/**
|
|
43
|
+
* Thrown when the operator killswitch excludes every available account.
|
|
44
|
+
*
|
|
45
|
+
* The killswitch compares each candidate's freshest cached quota
|
|
46
|
+
* remaining-percent against an account-specific override (or the
|
|
47
|
+
* global threshold) and excludes accounts below the floor. When all
|
|
48
|
+
* accounts are excluded, the fetch interceptor throws this error
|
|
49
|
+
* with redacted summaries so the host can surface a useful message
|
|
50
|
+
* without exposing any account identifiers or tokens.
|
|
51
|
+
*/
|
|
52
|
+
export class AntigravityKillswitchError extends Error {
|
|
53
|
+
family;
|
|
54
|
+
model;
|
|
55
|
+
thresholdPercent;
|
|
56
|
+
summaries;
|
|
57
|
+
constructor(input) {
|
|
58
|
+
super(input.message ??
|
|
59
|
+
`Antigravity killswitch: all ${input.summaries.length} account(s) under ${input.thresholdPercent}% quota for ${input.family}. ` +
|
|
60
|
+
`Refresh quota or raise the threshold via /antigravity-killswitch.`);
|
|
61
|
+
this.name = 'AntigravityKillswitchError';
|
|
62
|
+
this.family = input.family;
|
|
63
|
+
this.model = input.model;
|
|
64
|
+
this.thresholdPercent = input.thresholdPercent;
|
|
65
|
+
this.summaries = input.summaries;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
42
68
|
//# sourceMappingURL=errors.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../../src/plugin/errors.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;;;;GAOG;AACH,MAAM,OAAO,kBAAmB,SAAQ,KAAK;IAClC,QAAQ,
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../../src/plugin/errors.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;;;;GAOG;AACH,MAAM,OAAO,kBAAmB,SAAQ,KAAK;IAClC,QAAQ,CAAQ;IAChB,KAAK,CAAQ;IACb,QAAQ,CAAQ;IAEzB,YACE,QAAgB,EAChB,KAAa,EACb,QAAgB,EAChB,OAAgB;QAEhB,KAAK,CACH,OAAO;YACL,8CAA8C,QAAQ,aAAa;gBACjE,gEAAgE,CACrE,CAAA;QACD,IAAI,CAAC,IAAI,GAAG,oBAAoB,CAAA;QAChC,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAA;QACxB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAA;QAClB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAA;IAC1B,CAAC;CACF;AAED;;GAEG;AACH,MAAM,OAAO,mBAAoB,SAAQ,KAAK;IACnC,WAAW,CAAU;IACrB,QAAQ,CAAU;IAE3B,YAAY,WAAqB,EAAE,QAAkB,EAAE,OAAgB;QACrE,KAAK,CACH,OAAO;YACL,+BAA+B,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,gBAAgB,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAC9F,CAAA;QACD,IAAI,CAAC,IAAI,GAAG,qBAAqB,CAAA;QACjC,IAAI,CAAC,WAAW,GAAG,WAAW,CAAA;QAC9B,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAA;IAC1B,CAAC;CACF;AAED;;;;;;;;;GASG;AACH,MAAM,OAAO,0BAA2B,SAAQ,KAAK;IAC1C,MAAM,CAAQ;IACd,KAAK,CAAQ;IACb,gBAAgB,CAAQ;IACxB,SAAS,CAIhB;IAEF,YAAY,KAMX;QACC,KAAK,CACH,KAAK,CAAC,OAAO;YACX,+BAA+B,KAAK,CAAC,SAAS,CAAC,MAAM,qBAAqB,KAAK,CAAC,gBAAgB,eAAe,KAAK,CAAC,MAAM,IAAI;gBAC7H,mEAAmE,CACxE,CAAA;QACD,IAAI,CAAC,IAAI,GAAG,4BAA4B,CAAA;QACxC,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC,MAAM,CAAA;QAC1B,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC,KAAK,CAAA;QACxB,IAAI,CAAC,gBAAgB,GAAG,KAAK,CAAC,gBAAgB,CAAA;QAC9C,IAAI,CAAC,SAAS,GAAG,KAAK,CAAC,SAAS,CAAA;IAClC,CAAC;CACF"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import type { AntigravityConfig } from './config';
|
|
2
|
+
import type { Logger } from './logger';
|
|
3
|
+
import type { PluginClient } from './types';
|
|
4
|
+
type EventInput = {
|
|
5
|
+
event: {
|
|
6
|
+
type: string;
|
|
7
|
+
properties?: unknown;
|
|
8
|
+
};
|
|
9
|
+
};
|
|
10
|
+
type SessionSummary = {
|
|
11
|
+
durationMinutes: number;
|
|
12
|
+
totalClaude: number;
|
|
13
|
+
totalGemini: number;
|
|
14
|
+
requestsPerHour: number;
|
|
15
|
+
accountsUsed: number;
|
|
16
|
+
};
|
|
17
|
+
type EventAccountManager = {
|
|
18
|
+
getSessionSummary(): SessionSummary;
|
|
19
|
+
deleteSessionState(sessionId: string): void;
|
|
20
|
+
};
|
|
21
|
+
type EventLifecycle = {
|
|
22
|
+
getAccountManager(): EventAccountManager | null;
|
|
23
|
+
};
|
|
24
|
+
type EventSessionRegistry = {
|
|
25
|
+
register(sessionId: string, parentSessionId: string | null): void;
|
|
26
|
+
delete(sessionId: string): void;
|
|
27
|
+
getParentSessionId(sessionId: string): string | null;
|
|
28
|
+
};
|
|
29
|
+
type EventSessionRecovery = {
|
|
30
|
+
isRecoverableError(error: unknown): boolean;
|
|
31
|
+
handleSessionRecovery(info: {
|
|
32
|
+
id?: string;
|
|
33
|
+
role: 'assistant';
|
|
34
|
+
sessionID?: string;
|
|
35
|
+
error: unknown;
|
|
36
|
+
}): Promise<boolean>;
|
|
37
|
+
};
|
|
38
|
+
type EventUpdateChecker = {
|
|
39
|
+
event(input: EventInput): void | Promise<void>;
|
|
40
|
+
};
|
|
41
|
+
export interface CreateEventHandlerOptions {
|
|
42
|
+
client: PluginClient;
|
|
43
|
+
config: Pick<AntigravityConfig, 'auto_resume' | 'resume_text' | 'toast_scope'>;
|
|
44
|
+
directory: string;
|
|
45
|
+
lifecycle: EventLifecycle;
|
|
46
|
+
sessionRegistry: EventSessionRegistry;
|
|
47
|
+
sessionRecovery: EventSessionRecovery | null;
|
|
48
|
+
updateChecker: EventUpdateChecker;
|
|
49
|
+
logger: Pick<Logger, 'debug'>;
|
|
50
|
+
}
|
|
51
|
+
export declare function createEventHandler({ client, config, directory, lifecycle, sessionRegistry, sessionRecovery, updateChecker, logger, }: CreateEventHandlerOptions): (input: EventInput) => Promise<void>;
|
|
52
|
+
export {};
|
|
53
|
+
//# sourceMappingURL=event-handler.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"event-handler.d.ts","sourceRoot":"","sources":["../../../src/plugin/event-handler.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAA;AACjD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA;AAEtC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AAE3C,KAAK,UAAU,GAAG;IAChB,KAAK,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,UAAU,CAAC,EAAE,OAAO,CAAA;KAAE,CAAA;CAC9C,CAAA;AAED,KAAK,cAAc,GAAG;IACpB,eAAe,EAAE,MAAM,CAAA;IACvB,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AE,oBAAoB,CAAA;IACrC,eAAe,EAAE,oBAAoB,GAAG,IAAI,CAAA;IAC5C,aAAa,EAAE,kBAAkB,CAAA;IACjC,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAC9B;AAED,wBAAgB,kBAAkB,CAAC,EACjC,MAAM,EACN,MAAM,EACN,SAAS,EACT,SAAS,EACT,eAAe,EACf,eAAe,EACf,aAAa,EACb,MAAM,GACP,EAAE,yBAAyB,IACZ,OAAO,UAAU,KAAG,OAAO,CAAC,IAAI,CAAC,CAqHhD"}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { removeSidebarActiveRouting } from '../sidebar-state';
|
|
2
|
+
import { getRecoverySuccessToast } from './recovery';
|
|
3
|
+
export function createEventHandler({ client, config, directory, lifecycle, sessionRegistry, sessionRecovery, updateChecker, logger, }) {
|
|
4
|
+
return async (input) => {
|
|
5
|
+
await updateChecker.event(input);
|
|
6
|
+
if (input.event.type === 'session.created') {
|
|
7
|
+
const properties = input.event.properties;
|
|
8
|
+
const sessionId = properties?.info?.id;
|
|
9
|
+
const parentSessionId = properties?.info?.parentID ?? null;
|
|
10
|
+
if (sessionId) {
|
|
11
|
+
sessionRegistry.register(sessionId, parentSessionId);
|
|
12
|
+
}
|
|
13
|
+
if (parentSessionId) {
|
|
14
|
+
logger.debug('child-session-detected', {
|
|
15
|
+
sessionId,
|
|
16
|
+
parentID: parentSessionId,
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
else {
|
|
20
|
+
const previousSummary = lifecycle
|
|
21
|
+
.getAccountManager()
|
|
22
|
+
?.getSessionSummary();
|
|
23
|
+
if (previousSummary &&
|
|
24
|
+
(previousSummary.totalClaude > 0 || previousSummary.totalGemini > 0)) {
|
|
25
|
+
logger.debug('prev-session-quota-summary', {
|
|
26
|
+
durationMinutes: previousSummary.durationMinutes,
|
|
27
|
+
totalClaude: previousSummary.totalClaude,
|
|
28
|
+
totalGemini: previousSummary.totalGemini,
|
|
29
|
+
requestsPerHour: previousSummary.requestsPerHour,
|
|
30
|
+
accountsUsed: previousSummary.accountsUsed,
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
logger.debug('root-session-detected', { sessionId });
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
if (input.event.type === 'session.deleted') {
|
|
37
|
+
const properties = input.event.properties;
|
|
38
|
+
const sessionId = properties?.sessionID ?? properties?.info?.id;
|
|
39
|
+
if (sessionId) {
|
|
40
|
+
sessionRegistry.delete(sessionId);
|
|
41
|
+
lifecycle.getAccountManager()?.deleteSessionState(sessionId);
|
|
42
|
+
// Drop the session's sidebar route so the TUI does not retain a
|
|
43
|
+
// dead route after the session ends. Fire-and-forget; the next
|
|
44
|
+
// sidebar poll will see the pruned map.
|
|
45
|
+
const eventLogger = logger;
|
|
46
|
+
void removeSidebarActiveRouting(sessionId).catch((error) => {
|
|
47
|
+
eventLogger.debug('sidebar-route-remove-failed', {
|
|
48
|
+
sessionId,
|
|
49
|
+
error: String(error),
|
|
50
|
+
});
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
if (!sessionRecovery || input.event.type !== 'session.error') {
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
const properties = input.event.properties;
|
|
58
|
+
const sessionID = properties?.sessionID;
|
|
59
|
+
const messageID = properties?.messageID;
|
|
60
|
+
const error = properties?.error;
|
|
61
|
+
if (!sessionRecovery.isRecoverableError(error)) {
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
const recovered = await sessionRecovery.handleSessionRecovery({
|
|
65
|
+
id: messageID,
|
|
66
|
+
role: 'assistant',
|
|
67
|
+
sessionID,
|
|
68
|
+
error,
|
|
69
|
+
});
|
|
70
|
+
if (!recovered || !sessionID || !config.auto_resume) {
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
await client.session
|
|
74
|
+
.prompt({
|
|
75
|
+
path: { id: sessionID },
|
|
76
|
+
body: { parts: [{ type: 'text', text: config.resume_text }] },
|
|
77
|
+
query: { directory },
|
|
78
|
+
})
|
|
79
|
+
.catch(() => { });
|
|
80
|
+
const successToast = getRecoverySuccessToast();
|
|
81
|
+
const isChildSession = sessionRegistry.getParentSessionId(sessionID) !== null;
|
|
82
|
+
logger.debug('recovery-toast', {
|
|
83
|
+
...successToast,
|
|
84
|
+
isChildSession,
|
|
85
|
+
toastScope: config.toast_scope,
|
|
86
|
+
});
|
|
87
|
+
if (config.toast_scope === 'root_only' && isChildSession) {
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
await client.tui
|
|
91
|
+
.showToast({
|
|
92
|
+
body: {
|
|
93
|
+
title: successToast.title,
|
|
94
|
+
message: successToast.message,
|
|
95
|
+
variant: 'success',
|
|
96
|
+
},
|
|
97
|
+
})
|
|
98
|
+
.catch(() => { });
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
//# sourceMappingURL=event-handler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"event-handler.js","sourceRoot":"","sources":["../../../src/plugin/event-handler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,0BAA0B,EAAE,MAAM,kBAAkB,CAAA;AAG7D,OAAO,EAAE,uBAAuB,EAAE,MAAM,YAAY,CAAA;AAuDpD,MAAM,UAAU,kBAAkB,CAAC,EACjC,MAAM,EACN,MAAM,EACN,SAAS,EACT,SAAS,EACT,eAAe,EACf,eAAe,EACf,aAAa,EACb,MAAM,GACoB;IAC1B,OAAO,KAAK,EAAE,KAAiB,EAAiB,EAAE;QAChD,MAAM,aAAa,CAAC,KAAK,CAAC,KAAK,CAAC,CAAA;QAEhC,IAAI,KAAK,CAAC,KAAK,CAAC,IAAI,KAAK,iBAAiB,EAAE,CAAC;YAC3C,MAAM,UAAU,GAAG,KAAK,CAAC,KAAK,CAAC,UAElB,CAAA;YACb,MAAM,SAAS,GAAG,UAAU,EAAE,IAAI,EAAE,EAAE,CAAA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CAAC,EAAE;YAC7D,KAAK,EAAE,EAAE,SAAS,EAAE;SACrB,CAAC;aACD,KAAK,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAA;QAElB,MAAM,YAAY,GAAG,uBAAuB,EAAE,CAAA;QAC9C,MAAM,cAAc,GAClB,eAAe,CAAC,kBAAkB,CAAC,SAAS,CAAC,KAAK,IAAI,CAAA;QACxD,MAAM,CAAC,KAAK,CAAC,gBAAgB,EAAE;YAC7B,GAAG,YAAY;YACf,cAAc;YACd,UAAU,EAAE,MAAM,CAAC,WAAW;SAC/B,CAAC,CAAA;QAEF,IAAI,MAAM,CAAC,WAAW,KAAK,WAAW,IAAI,cAAc,EAAE,CAAC;YACzD,OAAM;QACR,CAAC;QAED,MAAM,MAAM,CAAC,GAAG;aACb,SAAS,CAAC;YACT,IAAI,EAAE;gBACJ,KAAK,EAAE,YAAY,CAAC,KAAK;gBACzB,OAAO,EAAE,YAAY,CAAC,OAAO;gBAC7B,OAAO,EAAE,SAAS;aACnB;SACF,CAAC;aACD,KAAK,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAA;IACpB,CAAC,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import type { HeaderStyle, ModelFamily } from '../accounts';
|
|
2
|
+
export interface AccountFailureResult {
|
|
3
|
+
failures: number;
|
|
4
|
+
shouldCooldown: boolean;
|
|
5
|
+
cooldownMs: number;
|
|
6
|
+
}
|
|
7
|
+
export interface RateLimitBackoffResult {
|
|
8
|
+
attempt: number;
|
|
9
|
+
delayMs: number;
|
|
10
|
+
isDuplicate: boolean;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Diagnostic snapshot of the four internal maps. Exposed for tests and for
|
|
14
|
+
* future diagnostics endpoints; callers must not mutate the returned view.
|
|
15
|
+
*/
|
|
16
|
+
export interface RetryStateSizes {
|
|
17
|
+
rateLimitState: number;
|
|
18
|
+
accountFailure: number;
|
|
19
|
+
rateLimitToast: number;
|
|
20
|
+
emptyResponse: number;
|
|
21
|
+
}
|
|
22
|
+
export interface RetryState {
|
|
23
|
+
/** Marks the instance as torn down; subsequent mutations are no-ops. */
|
|
24
|
+
readonly disposed: boolean;
|
|
25
|
+
/** Returns the rate-limit backoff for the given account + quota key. */
|
|
26
|
+
getRateLimitBackoff(accountIndex: number, quotaKey: string, serverRetryAfterMs: number | null, maxBackoffMs?: number): RateLimitBackoffResult;
|
|
27
|
+
/** Resets a single account/quota pair. */
|
|
28
|
+
resetRateLimitState(accountIndex: number, quotaKey: string): void;
|
|
29
|
+
/** Resets every quota key for the given account. */
|
|
30
|
+
resetAllRateLimitStateForAccount(accountIndex: number): void;
|
|
31
|
+
/** Maps header style + family to a deduplication bucket. */
|
|
32
|
+
headerStyleToQuotaKey(headerStyle: HeaderStyle, family: ModelFamily): string;
|
|
33
|
+
/** Records a non-429 failure and returns cooldown state. */
|
|
34
|
+
trackAccountFailure(accountIndex: number): AccountFailureResult;
|
|
35
|
+
/** Clears the failure counter for one account. */
|
|
36
|
+
resetAccountFailureState(accountIndex: number): void;
|
|
37
|
+
/** Returns true when the rate-limit warning toast may be shown. */
|
|
38
|
+
shouldShowRateLimitToast(message: string): boolean;
|
|
39
|
+
/** Marks the "all accounts blocked — soft quota" toast as shown. */
|
|
40
|
+
markSoftQuotaToastShown(): void;
|
|
41
|
+
/** Marks the "all accounts blocked — rate limit" toast as shown. */
|
|
42
|
+
markRateLimitToastShown(): void;
|
|
43
|
+
/** Reads the soft-quota toast guard flag. */
|
|
44
|
+
softQuotaToastShown(): boolean;
|
|
45
|
+
/** Reads the rate-limit toast guard flag. */
|
|
46
|
+
rateLimitToastShown(): boolean;
|
|
47
|
+
/** Clears both blocked-toast guards. */
|
|
48
|
+
resetAllAccountsBlockedToasts(): void;
|
|
49
|
+
/** Increments the per-session empty-response attempt counter. */
|
|
50
|
+
recordEmptyResponseAttempt(key: string): number;
|
|
51
|
+
/** Drops all empty-response attempt counters. */
|
|
52
|
+
clearEmptyResponseAttempts(): void;
|
|
53
|
+
/** Resets every map/flag. */
|
|
54
|
+
clear(): void;
|
|
55
|
+
/** Drops all state and prevents further mutations. */
|
|
56
|
+
dispose(): void;
|
|
57
|
+
/** Diagnostic snapshot of every internal map's current size. */
|
|
58
|
+
sizes(): RetryStateSizes;
|
|
59
|
+
}
|
|
60
|
+
export declare function createRetryState(): RetryState;
|
|
61
|
+
//# sourceMappingURL=retry-state.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"retry-state.d.ts","sourceRoot":"","sources":["../../../../src/plugin/fetch/retry-state.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AA8B3D,MAAM,WAAW,oBAAoB;IACnC,QAAQ,EAAE,MAAM,CAAA;IAChB,cAAc,EAAE,OAAO,CAAA;IACvB,UAAU,EAAE,MAAM,CAAA;CACnB;AAQD,MAAM,WAAW,sBAAsB;IACrC,OAAO,EAAE,MAAM,CAAA;IACf,OAAO,EAAE,MAAM,CAAA;IACf,WAAW,EAAE,OAAO,CAAA;CACrB;AAED;;;GAGG;AACH,MAAM,WAAW,eAAe;IAC9B,cAAc,EAAE,MAAM,CAAA;IACtB,cAAc,EAAE,MAAM,CAAA;IACtB,cAAc,EAAE,MAAM,CAAA;IACtB,aAAa,EAAE,MAAM,CAAA;CACtB;AAED,MAAM,WAAW,UAAU;IACzB,wEAAwE;IACxE,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAA;IAC1B,wEAAwE;IACxE,mBAAmB,CACjB,YAAY,EAAE,MAAM,EACpB,QAAQ,EAAE,MAAM,EAChB,kBAAkB,EAAE,MAAM,GAAG,IAAI,EACjC,YAAY,CAAC,EAAE,MAAM,GACpB,sBAAsB,CAAA;IACzB,0CAA0C;IAC1C,mBAAmB,CAAC,YAAY,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAA;IACjE,o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