@cortexkit/opencode-antigravity-auth 2.2.1 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +95 -89
- package/dist/cli.js +18469 -810
- package/dist/cli.js.map +4 -4
- package/dist/cli.meta.json +4079 -0
- package/dist/index.js +40914 -16441
- package/dist/index.js.map +4 -4
- package/dist/index.meta.json +6949 -0
- package/dist/server.js +50948 -0
- package/dist/server.js.map +7 -0
- package/dist/server.meta.json +7284 -0
- package/dist/src/cli.d.ts +46 -1
- package/dist/src/cli.d.ts.map +1 -1
- package/dist/src/cli.js +207 -2
- package/dist/src/cli.js.map +1 -1
- package/dist/src/common-auth-embedded/NOTICE.txt +21 -0
- package/dist/src/common-auth-embedded/auth-menu/accounts.d.ts +97 -0
- package/dist/src/common-auth-embedded/auth-menu/accounts.js +387 -0
- package/dist/src/common-auth-embedded/auth-menu/ansi.d.ts +26 -0
- package/dist/src/common-auth-embedded/auth-menu/ansi.js +98 -0
- package/dist/src/common-auth-embedded/auth-menu/confirm.d.ts +7 -0
- package/dist/src/common-auth-embedded/auth-menu/confirm.js +21 -0
- package/dist/src/common-auth-embedded/auth-menu/doctor.d.ts +52 -0
- package/dist/src/common-auth-embedded/auth-menu/doctor.js +81 -0
- package/dist/src/common-auth-embedded/auth-menu/index.d.ts +17 -0
- package/dist/src/common-auth-embedded/auth-menu/index.js +12 -0
- package/dist/src/common-auth-embedded/auth-menu/login.d.ts +55 -0
- package/dist/src/common-auth-embedded/auth-menu/login.js +83 -0
- package/dist/src/common-auth-embedded/auth-menu/menu.d.ts +59 -0
- package/dist/src/common-auth-embedded/auth-menu/menu.js +73 -0
- package/dist/src/common-auth-embedded/auth-menu/opencode-v1.d.ts +49 -0
- package/dist/src/common-auth-embedded/auth-menu/opencode-v1.js +47 -0
- package/dist/src/common-auth-embedded/auth-menu/select.d.ts +21 -0
- package/dist/src/common-auth-embedded/auth-menu/select.js +159 -0
- package/dist/src/common-auth-embedded/auth-menu/terminal.d.ts +43 -0
- package/dist/src/common-auth-embedded/auth-menu/terminal.js +19 -0
- package/dist/src/common-auth-embedded/claustrum/consumer.d.ts +102 -0
- package/dist/src/common-auth-embedded/claustrum/consumer.js +298 -0
- package/dist/src/common-auth-embedded/claustrum/custody.d.ts +175 -0
- package/dist/src/common-auth-embedded/claustrum/custody.js +354 -0
- package/dist/src/common-auth-embedded/claustrum/enrollment.d.ts +158 -0
- package/dist/src/common-auth-embedded/claustrum/enrollment.js +759 -0
- package/dist/src/common-auth-embedded/claustrum/errors.d.ts +16 -0
- package/dist/src/common-auth-embedded/claustrum/errors.js +8 -0
- package/dist/src/common-auth-embedded/claustrum/host-slot.d.ts +39 -0
- package/dist/src/common-auth-embedded/claustrum/host-slot.js +72 -0
- package/dist/src/common-auth-embedded/claustrum/index.d.ts +18 -0
- package/dist/src/common-auth-embedded/claustrum/index.js +22 -0
- package/dist/src/common-auth-embedded/claustrum/interlock.d.ts +27 -0
- package/dist/src/common-auth-embedded/claustrum/interlock.js +29 -0
- package/dist/src/common-auth-embedded/claustrum/roster.d.ts +208 -0
- package/dist/src/common-auth-embedded/claustrum/roster.js +536 -0
- package/dist/src/common-auth-embedded/commands/builtins.d.ts +71 -0
- package/dist/src/common-auth-embedded/commands/builtins.js +534 -0
- package/dist/src/common-auth-embedded/commands/index.d.ts +10 -0
- package/dist/src/common-auth-embedded/commands/index.js +5 -0
- package/dist/src/common-auth-embedded/commands/menu.d.ts +61 -0
- package/dist/src/common-auth-embedded/commands/menu.js +300 -0
- package/dist/src/common-auth-embedded/commands/model.d.ts +238 -0
- package/dist/src/common-auth-embedded/commands/model.js +16 -0
- package/dist/src/common-auth-embedded/commands/pi.d.ts +23 -0
- package/dist/src/common-auth-embedded/commands/pi.js +206 -0
- package/dist/src/common-auth-embedded/commands/seam.d.ts +72 -0
- package/dist/src/common-auth-embedded/commands/seam.js +301 -0
- package/dist/src/common-auth-embedded/fs/atomic-write.d.ts +20 -0
- package/dist/src/common-auth-embedded/fs/atomic-write.js +80 -0
- package/dist/src/common-auth-embedded/fs/index.d.ts +7 -0
- package/dist/src/common-auth-embedded/fs/index.js +6 -0
- package/dist/src/common-auth-embedded/fs/lock-constants.d.ts +14 -0
- package/dist/src/common-auth-embedded/fs/lock-constants.js +14 -0
- package/dist/src/common-auth-embedded/fs/refresh-file-lock.d.ts +33 -0
- package/dist/src/common-auth-embedded/fs/refresh-file-lock.js +501 -0
- package/dist/src/common-auth-embedded/fs/with-lock.d.ts +33 -0
- package/dist/src/common-auth-embedded/fs/with-lock.js +48 -0
- package/dist/src/common-auth-embedded/logger/capture-sink.d.ts +14 -0
- package/dist/src/common-auth-embedded/logger/capture-sink.js +13 -0
- package/dist/src/common-auth-embedded/logger/engine.d.ts +100 -0
- package/dist/src/common-auth-embedded/logger/engine.js +246 -0
- package/dist/src/common-auth-embedded/logger/index.d.ts +6 -0
- package/dist/src/common-auth-embedded/logger/index.js +3 -0
- package/dist/src/common-auth-embedded/logger/redact.d.ts +11 -0
- package/dist/src/common-auth-embedded/logger/redact.js +83 -0
- package/dist/src/common-auth-embedded/opencode2/errors.d.ts +25 -0
- package/dist/src/common-auth-embedded/opencode2/errors.js +15 -0
- package/dist/src/common-auth-embedded/opencode2/index.d.ts +8 -0
- package/dist/src/common-auth-embedded/opencode2/index.js +4 -0
- package/dist/src/common-auth-embedded/opencode2/install.d.ts +55 -0
- package/dist/src/common-auth-embedded/opencode2/install.js +886 -0
- package/dist/src/common-auth-embedded/opencode2/integration.d.ts +112 -0
- package/dist/src/common-auth-embedded/opencode2/integration.js +143 -0
- package/dist/src/common-auth-embedded/opencode2/sse.d.ts +12 -0
- package/dist/src/common-auth-embedded/opencode2/sse.js +60 -0
- package/dist/src/common-auth-embedded/opencode2/types.d.ts +413 -0
- package/dist/src/common-auth-embedded/pi-slot/index.d.ts +3 -0
- package/dist/src/common-auth-embedded/pi-slot/index.js +2 -0
- package/dist/src/common-auth-embedded/pi-slot/lock.js +212 -0
- package/dist/src/common-auth-embedded/pi-slot/slot.d.ts +49 -0
- package/dist/src/common-auth-embedded/pi-slot/slot.js +383 -0
- package/dist/src/common-auth-embedded/quota/codec.d.ts +11 -0
- package/dist/src/common-auth-embedded/quota/codec.js +12 -0
- package/dist/src/common-auth-embedded/quota/format.d.ts +46 -0
- package/dist/src/common-auth-embedded/quota/format.js +138 -0
- package/dist/src/common-auth-embedded/quota/index.d.ts +10 -0
- package/dist/src/common-auth-embedded/quota/index.js +5 -0
- package/dist/src/common-auth-embedded/quota/map.d.ts +63 -0
- package/dist/src/common-auth-embedded/quota/map.js +105 -0
- package/dist/src/common-auth-embedded/quota/merge.d.ts +48 -0
- package/dist/src/common-auth-embedded/quota/merge.js +162 -0
- package/dist/src/common-auth-embedded/quota/projection.d.ts +64 -0
- package/dist/src/common-auth-embedded/quota/projection.js +134 -0
- package/dist/src/common-auth-embedded/routing/admission.d.ts +93 -0
- package/dist/src/common-auth-embedded/routing/admission.js +142 -0
- package/dist/src/common-auth-embedded/routing/index.d.ts +8 -0
- package/dist/src/common-auth-embedded/routing/index.js +4 -0
- package/dist/src/common-auth-embedded/routing/ordered.d.ts +47 -0
- package/dist/src/common-auth-embedded/routing/ordered.js +58 -0
- package/dist/src/common-auth-embedded/routing/pins.d.ts +22 -0
- package/dist/src/common-auth-embedded/routing/pins.js +34 -0
- package/dist/src/common-auth-embedded/routing/sticky.d.ts +158 -0
- package/dist/src/common-auth-embedded/routing/sticky.js +339 -0
- package/dist/src/common-auth-embedded/rpc/client.d.ts +3 -0
- package/dist/src/common-auth-embedded/rpc/client.js +2 -0
- package/dist/src/common-auth-embedded/rpc/index.d.ts +10 -0
- package/dist/src/common-auth-embedded/rpc/index.js +5 -0
- package/dist/src/common-auth-embedded/rpc/notifications.d.ts +73 -0
- package/dist/src/common-auth-embedded/rpc/notifications.js +100 -0
- package/dist/src/common-auth-embedded/rpc/port-file.d.ts +33 -0
- package/dist/src/common-auth-embedded/rpc/port-file.js +217 -0
- package/dist/src/common-auth-embedded/rpc/rpc-client.d.ts +30 -0
- package/dist/src/common-auth-embedded/rpc/rpc-client.js +253 -0
- package/dist/src/common-auth-embedded/rpc/rpc-server.d.ts +58 -0
- package/dist/src/common-auth-embedded/rpc/rpc-server.js +311 -0
- package/dist/src/common-auth-embedded/rpc/server-registry.d.ts +11 -0
- package/dist/src/common-auth-embedded/rpc/server-registry.js +47 -0
- package/dist/src/common-auth-embedded/source-output.json +1326 -0
- package/dist/src/common-auth-embedded/store/attribution.d.ts +28 -0
- package/dist/src/common-auth-embedded/store/attribution.js +60 -0
- package/dist/src/common-auth-embedded/store/errors.d.ts +55 -0
- package/dist/src/common-auth-embedded/store/errors.js +38 -0
- package/dist/src/common-auth-embedded/store/hooks.d.ts +12 -0
- package/dist/src/common-auth-embedded/store/hooks.js +34 -0
- package/dist/src/common-auth-embedded/store/identity.d.ts +39 -0
- package/dist/src/common-auth-embedded/store/identity.js +79 -0
- package/dist/src/common-auth-embedded/store/index.d.ts +21 -0
- package/dist/src/common-auth-embedded/store/index.js +7 -0
- package/dist/src/common-auth-embedded/store/mutate.d.ts +189 -0
- package/dist/src/common-auth-embedded/store/mutate.js +500 -0
- package/dist/src/common-auth-embedded/store/pool.d.ts +196 -0
- package/dist/src/common-auth-embedded/store/pool.js +120 -0
- package/dist/src/common-auth-embedded/store/provider-state.d.ts +131 -0
- package/dist/src/common-auth-embedded/store/provider-state.js +226 -0
- package/dist/src/common-auth-embedded/store/publication.d.ts +47 -0
- package/dist/src/common-auth-embedded/store/publication.js +304 -0
- package/dist/src/common-auth-embedded/store/pull.d.ts +36 -0
- package/dist/src/common-auth-embedded/store/pull.js +143 -0
- package/dist/src/common-auth-embedded/store/refresh-lock.d.ts +63 -0
- package/dist/src/common-auth-embedded/store/refresh-lock.js +136 -0
- package/dist/src/common-auth-embedded/store/refresh.d.ts +72 -0
- package/dist/src/common-auth-embedded/store/refresh.js +225 -0
- package/dist/src/common-auth-embedded/store/reserved.js +13 -0
- package/dist/src/common-auth-embedded/store/rows.d.ts +313 -0
- package/dist/src/common-auth-embedded/store/rows.js +1258 -0
- package/dist/src/common-auth-embedded/store/runtime.d.ts +36 -0
- package/dist/src/common-auth-embedded/store/runtime.js +68 -0
- package/dist/src/common-auth-embedded/store/schema.d.ts +443 -0
- package/dist/src/common-auth-embedded/store/schema.js +754 -0
- package/dist/src/common-auth-embedded/store/settings.d.ts +63 -0
- package/dist/src/common-auth-embedded/store/settings.js +120 -0
- package/dist/src/common-auth-embedded/store/torn.d.ts +78 -0
- package/dist/src/common-auth-embedded/store/torn.js +294 -0
- package/dist/src/common-auth-embedded/tui/index.d.ts +8 -0
- package/dist/src/common-auth-embedded/tui/index.js +21 -0
- package/dist/src/common-auth-embedded/util/any-signal.js +42 -0
- package/dist/src/constants.d.ts +1 -0
- package/dist/src/constants.d.ts.map +1 -1
- package/dist/src/constants.js +4 -0
- package/dist/src/constants.js.map +1 -1
- package/dist/src/ga/proxy-guard.d.ts +120 -0
- package/dist/src/ga/proxy-guard.d.ts.map +1 -0
- package/dist/src/ga/proxy-guard.js +269 -0
- package/dist/src/ga/proxy-guard.js.map +1 -0
- package/dist/src/ga/rpc/protocol.d.ts +504 -0
- package/dist/src/ga/rpc/protocol.d.ts.map +1 -0
- package/dist/src/ga/rpc/protocol.js +1278 -0
- package/dist/src/ga/rpc/protocol.js.map +1 -0
- package/dist/src/ga/server/auth.d.ts +9 -0
- package/dist/src/ga/server/auth.d.ts.map +1 -0
- package/dist/src/ga/server/auth.js +37 -0
- package/dist/src/ga/server/auth.js.map +1 -0
- package/dist/src/ga/server/index.d.ts +576 -0
- package/dist/src/ga/server/index.d.ts.map +1 -0
- package/dist/src/ga/server/index.js +1012 -0
- package/dist/src/ga/server/index.js.map +1 -0
- package/dist/src/ga/tui/host-ga.d.ts +350 -0
- package/dist/src/ga/tui/host-ga.d.ts.map +1 -0
- package/dist/src/ga/tui/host-ga.js +1242 -0
- package/dist/src/ga/tui/host-ga.js.map +1 -0
- package/dist/src/logging/provider-key-policy.d.ts +9 -0
- package/dist/src/logging/provider-key-policy.d.ts.map +1 -0
- package/dist/src/logging/provider-key-policy.js +11 -0
- package/dist/src/logging/provider-key-policy.js.map +1 -0
- package/dist/src/plugin/account-access.d.ts +130 -15
- package/dist/src/plugin/account-access.d.ts.map +1 -1
- package/dist/src/plugin/account-access.js +331 -129
- package/dist/src/plugin/account-access.js.map +1 -1
- package/dist/src/plugin/account-blocks.d.ts +102 -0
- package/dist/src/plugin/account-blocks.d.ts.map +1 -0
- package/dist/src/plugin/account-blocks.js +196 -0
- package/dist/src/plugin/account-blocks.js.map +1 -0
- package/dist/src/plugin/accounts.d.ts +85 -1
- package/dist/src/plugin/accounts.d.ts.map +1 -1
- package/dist/src/plugin/accounts.js +127 -3
- package/dist/src/plugin/accounts.js.map +1 -1
- package/dist/src/plugin/auth-loader.d.ts +69 -5
- package/dist/src/plugin/auth-loader.d.ts.map +1 -1
- package/dist/src/plugin/auth-loader.js +355 -52
- package/dist/src/plugin/auth-loader.js.map +1 -1
- package/dist/src/plugin/background-quota-refresh.d.ts +54 -8
- package/dist/src/plugin/background-quota-refresh.d.ts.map +1 -1
- package/dist/src/plugin/background-quota-refresh.js +81 -24
- package/dist/src/plugin/background-quota-refresh.js.map +1 -1
- package/dist/src/plugin/cache/index.d.ts +1 -1
- package/dist/src/plugin/cache/index.d.ts.map +1 -1
- package/dist/src/plugin/cache/index.js +1 -1
- package/dist/src/plugin/cache/index.js.map +1 -1
- package/dist/src/plugin/cache/signature-cache.d.ts +55 -10
- package/dist/src/plugin/cache/signature-cache.d.ts.map +1 -1
- package/dist/src/plugin/cache/signature-cache.js +100 -41
- package/dist/src/plugin/cache/signature-cache.js.map +1 -1
- package/dist/src/plugin/cache.d.ts +80 -16
- package/dist/src/plugin/cache.d.ts.map +1 -1
- package/dist/src/plugin/cache.js +339 -200
- package/dist/src/plugin/cache.js.map +1 -1
- package/dist/src/plugin/catalog.d.ts +4 -18
- package/dist/src/plugin/catalog.d.ts.map +1 -1
- package/dist/src/plugin/catalog.js +11 -41
- package/dist/src/plugin/catalog.js.map +1 -1
- package/dist/src/plugin/command-apply.d.ts +58 -0
- package/dist/src/plugin/command-apply.d.ts.map +1 -0
- package/dist/src/plugin/command-apply.js +168 -0
- package/dist/src/plugin/command-apply.js.map +1 -0
- package/dist/src/plugin/command-data.d.ts +1 -0
- package/dist/src/plugin/command-data.d.ts.map +1 -1
- package/dist/src/plugin/command-data.js +2 -0
- package/dist/src/plugin/command-data.js.map +1 -1
- package/dist/src/plugin/commands.d.ts +142 -132
- package/dist/src/plugin/commands.d.ts.map +1 -1
- package/dist/src/plugin/commands.js +214 -686
- package/dist/src/plugin/commands.js.map +1 -1
- package/dist/src/plugin/config/index.d.ts +1 -1
- package/dist/src/plugin/config/index.d.ts.map +1 -1
- package/dist/src/plugin/config/index.js +1 -1
- package/dist/src/plugin/config/index.js.map +1 -1
- package/dist/src/plugin/config/loader.d.ts +37 -1
- package/dist/src/plugin/config/loader.d.ts.map +1 -1
- package/dist/src/plugin/config/loader.js +64 -9
- package/dist/src/plugin/config/loader.js.map +1 -1
- package/dist/src/plugin/config/operator-settings-schema.d.ts +2 -2
- package/dist/src/plugin/config/schema.d.ts +2 -2
- package/dist/src/plugin/config/writer.d.ts +7 -0
- package/dist/src/plugin/config/writer.d.ts.map +1 -1
- package/dist/src/plugin/config/writer.js +10 -1
- package/dist/src/plugin/config/writer.js.map +1 -1
- package/dist/src/plugin/debug.d.ts +72 -29
- package/dist/src/plugin/debug.d.ts.map +1 -1
- package/dist/src/plugin/debug.js +353 -239
- package/dist/src/plugin/debug.js.map +1 -1
- package/dist/src/plugin/fetch/retry-state.d.ts +1 -1
- package/dist/src/plugin/fetch/retry-state.d.ts.map +1 -1
- package/dist/src/plugin/fetch/retry-state.js.map +1 -1
- package/dist/src/plugin/fetch-interceptor.d.ts +66 -11
- package/dist/src/plugin/fetch-interceptor.d.ts.map +1 -1
- package/dist/src/plugin/fetch-interceptor.js +228 -1352
- package/dist/src/plugin/fetch-interceptor.js.map +1 -1
- package/dist/src/plugin/fetch-routing.d.ts +7 -2
- package/dist/src/plugin/fetch-routing.d.ts.map +1 -1
- package/dist/src/plugin/fetch-routing.js +7 -4
- package/dist/src/plugin/fetch-routing.js.map +1 -1
- package/dist/src/plugin/ga-location-services.d.ts +389 -0
- package/dist/src/plugin/ga-location-services.d.ts.map +1 -0
- package/dist/src/plugin/ga-location-services.js +1838 -0
- package/dist/src/plugin/ga-location-services.js.map +1 -0
- package/dist/src/plugin/gemini-dump.d.ts +37 -12
- package/dist/src/plugin/gemini-dump.d.ts.map +1 -1
- package/dist/src/plugin/gemini-dump.js +42 -21
- package/dist/src/plugin/gemini-dump.js.map +1 -1
- package/dist/src/plugin/google-search-tool.d.ts +2 -1
- package/dist/src/plugin/google-search-tool.d.ts.map +1 -1
- package/dist/src/plugin/google-search-tool.js +4 -1
- package/dist/src/plugin/google-search-tool.js.map +1 -1
- package/dist/src/plugin/index.d.ts.map +1 -1
- package/dist/src/plugin/index.js +505 -141
- package/dist/src/plugin/index.js.map +1 -1
- package/dist/src/plugin/killswitch.d.ts +1 -2
- package/dist/src/plugin/killswitch.d.ts.map +1 -1
- package/dist/src/plugin/lifecycle.d.ts +24 -1
- package/dist/src/plugin/lifecycle.d.ts.map +1 -1
- package/dist/src/plugin/lifecycle.js +95 -8
- package/dist/src/plugin/lifecycle.js.map +1 -1
- package/dist/src/plugin/logger.d.ts +61 -10
- package/dist/src/plugin/logger.d.ts.map +1 -1
- package/dist/src/plugin/logger.js +134 -63
- package/dist/src/plugin/logger.js.map +1 -1
- package/dist/src/plugin/neutral-types.d.ts +42 -0
- package/dist/src/plugin/neutral-types.d.ts.map +1 -0
- package/dist/src/plugin/neutral-types.js +12 -0
- package/dist/src/plugin/neutral-types.js.map +1 -0
- package/dist/src/plugin/oauth-methods.d.ts +2 -1
- package/dist/src/plugin/oauth-methods.d.ts.map +1 -1
- package/dist/src/plugin/oauth-methods.js +173 -88
- package/dist/src/plugin/oauth-methods.js.map +1 -1
- package/dist/src/plugin/operator-settings.d.ts +34 -0
- package/dist/src/plugin/operator-settings.d.ts.map +1 -1
- package/dist/src/plugin/operator-settings.js +105 -2
- package/dist/src/plugin/operator-settings.js.map +1 -1
- package/dist/src/plugin/persist-account-pool.d.ts +63 -2
- package/dist/src/plugin/persist-account-pool.d.ts.map +1 -1
- package/dist/src/plugin/persist-account-pool.js +125 -2
- package/dist/src/plugin/persist-account-pool.js.map +1 -1
- package/dist/src/plugin/quota.d.ts +335 -35
- package/dist/src/plugin/quota.d.ts.map +1 -1
- package/dist/src/plugin/quota.js +825 -95
- package/dist/src/plugin/quota.js.map +1 -1
- package/dist/src/plugin/refresh-queue.d.ts +35 -5
- package/dist/src/plugin/refresh-queue.d.ts.map +1 -1
- package/dist/src/plugin/refresh-queue.js +50 -16
- package/dist/src/plugin/refresh-queue.js.map +1 -1
- package/dist/src/plugin/request-helpers.d.ts +30 -5
- package/dist/src/plugin/request-helpers.d.ts.map +1 -1
- package/dist/src/plugin/request-helpers.js +82 -17
- package/dist/src/plugin/request-helpers.js.map +1 -1
- package/dist/src/plugin/request.d.ts +63 -15
- package/dist/src/plugin/request.d.ts.map +1 -1
- package/dist/src/plugin/request.js +190 -60
- package/dist/src/plugin/request.js.map +1 -1
- package/dist/src/plugin/session-context.d.ts.map +1 -1
- package/dist/src/plugin/session-context.js +5 -2
- package/dist/src/plugin/session-context.js.map +1 -1
- package/dist/src/plugin/shared/local-grant.d.ts +26 -0
- package/dist/src/plugin/shared/local-grant.d.ts.map +1 -0
- package/dist/src/plugin/shared/local-grant.js +19 -0
- package/dist/src/plugin/shared/local-grant.js.map +1 -0
- package/dist/src/plugin/shared/request-cancellation.d.ts +12 -0
- package/dist/src/plugin/shared/request-cancellation.d.ts.map +1 -0
- package/dist/src/plugin/shared/request-cancellation.js +118 -0
- package/dist/src/plugin/shared/request-cancellation.js.map +1 -0
- package/dist/src/plugin/shared/request-services.d.ts +375 -0
- package/dist/src/plugin/shared/request-services.d.ts.map +1 -0
- package/dist/src/plugin/shared/request-services.js +1743 -0
- package/dist/src/plugin/shared/request-services.js.map +1 -0
- package/dist/src/plugin/shared/runtime.d.ts +217 -0
- package/dist/src/plugin/shared/runtime.d.ts.map +1 -0
- package/dist/src/plugin/shared/runtime.js +345 -0
- package/dist/src/plugin/shared/runtime.js.map +1 -0
- package/dist/src/plugin/shared/source-sidebar.d.ts +15 -0
- package/dist/src/plugin/shared/source-sidebar.d.ts.map +1 -0
- package/dist/src/plugin/shared/source-sidebar.js +41 -0
- package/dist/src/plugin/shared/source-sidebar.js.map +1 -0
- package/dist/src/plugin/shared/vault-menu.d.ts +5 -0
- package/dist/src/plugin/shared/vault-menu.d.ts.map +1 -0
- package/dist/src/plugin/shared/vault-menu.js +49 -0
- package/dist/src/plugin/shared/vault-menu.js.map +1 -0
- package/dist/src/plugin/shared/vault-request-credentials.d.ts +168 -0
- package/dist/src/plugin/shared/vault-request-credentials.d.ts.map +1 -0
- package/dist/src/plugin/shared/vault-request-credentials.js +485 -0
- package/dist/src/plugin/shared/vault-request-credentials.js.map +1 -0
- package/dist/src/plugin/storage.d.ts +127 -1
- package/dist/src/plugin/storage.d.ts.map +1 -1
- package/dist/src/plugin/storage.js +188 -3
- package/dist/src/plugin/storage.js.map +1 -1
- package/dist/src/plugin/token.d.ts +23 -1
- package/dist/src/plugin/token.d.ts.map +1 -1
- package/dist/src/plugin/token.js +117 -58
- package/dist/src/plugin/token.js.map +1 -1
- package/dist/src/plugin/ui/quota-status.d.ts +1 -10
- package/dist/src/plugin/ui/quota-status.d.ts.map +1 -1
- package/dist/src/plugin/ui/quota-status.js +6 -42
- package/dist/src/plugin/ui/quota-status.js.map +1 -1
- package/dist/src/plugin/vault-activation.d.ts +11 -0
- package/dist/src/plugin/vault-activation.d.ts.map +1 -0
- package/dist/src/plugin/vault-activation.js +53 -0
- package/dist/src/plugin/vault-activation.js.map +1 -0
- package/dist/src/plugin/vault-custody.d.ts +131 -0
- package/dist/src/plugin/vault-custody.d.ts.map +1 -0
- package/dist/src/plugin/vault-custody.js +381 -0
- package/dist/src/plugin/vault-custody.js.map +1 -0
- package/dist/src/quota-presentation.d.ts +18 -0
- package/dist/src/quota-presentation.d.ts.map +1 -0
- package/dist/src/quota-presentation.js +58 -0
- package/dist/src/quota-presentation.js.map +1 -0
- package/dist/src/rpc/notifications.d.ts +2 -2
- package/dist/src/rpc/notifications.d.ts.map +1 -1
- package/dist/src/rpc/notifications.js +1 -1
- package/dist/src/rpc/notifications.js.map +1 -1
- package/dist/src/rpc/port-file.d.ts +2 -12
- package/dist/src/rpc/port-file.d.ts.map +1 -1
- package/dist/src/rpc/port-file.js +5 -107
- package/dist/src/rpc/port-file.js.map +1 -1
- package/dist/src/rpc/protocol.d.ts +47 -16
- package/dist/src/rpc/protocol.d.ts.map +1 -1
- package/dist/src/rpc/rpc-client.d.ts +27 -3
- package/dist/src/rpc/rpc-client.d.ts.map +1 -1
- package/dist/src/rpc/rpc-client.js +55 -45
- package/dist/src/rpc/rpc-client.js.map +1 -1
- package/dist/src/rpc/rpc-server.d.ts +13 -2
- package/dist/src/rpc/rpc-server.d.ts.map +1 -1
- package/dist/src/rpc/rpc-server.js +38 -212
- package/dist/src/rpc/rpc-server.js.map +1 -1
- package/dist/src/server.d.ts +30 -0
- package/dist/src/server.d.ts.map +1 -0
- package/dist/src/server.js +29 -0
- package/dist/src/server.js.map +1 -0
- package/dist/src/sidebar-projection.d.ts +102 -0
- package/dist/src/sidebar-projection.d.ts.map +1 -0
- package/dist/src/sidebar-projection.js +146 -0
- package/dist/src/sidebar-projection.js.map +1 -0
- package/dist/src/sidebar-state.d.ts +13 -5
- package/dist/src/sidebar-state.d.ts.map +1 -1
- package/dist/src/sidebar-state.js +49 -16
- package/dist/src/sidebar-state.js.map +1 -1
- package/dist/src/tui/command-dialogs.d.ts +58 -52
- package/dist/src/tui/command-dialogs.d.ts.map +1 -1
- package/dist/src/tui/command-dialogs.js +379 -571
- package/dist/src/tui/command-dialogs.js.map +1 -1
- package/dist/src/tui/file-logger.d.ts +2 -3
- package/dist/src/tui/file-logger.d.ts.map +1 -1
- package/dist/src/tui/file-logger.js +21 -7
- package/dist/src/tui/file-logger.js.map +1 -1
- package/dist/src/tui/host-api.d.ts +196 -0
- package/dist/src/tui/host-api.d.ts.map +1 -0
- package/dist/src/tui/host-api.js +357 -0
- package/dist/src/tui/host-api.js.map +1 -0
- package/dist/src/tui/host-v1.d.ts +60 -0
- package/dist/src/tui/host-v1.d.ts.map +1 -0
- package/dist/src/tui/host-v1.js +147 -0
- package/dist/src/tui/host-v1.js.map +1 -0
- package/dist/src/tui/vault-setup.d.ts +98 -0
- package/dist/src/tui/vault-setup.d.ts.map +1 -0
- package/dist/src/tui/vault-setup.js +198 -0
- package/dist/src/tui/vault-setup.js.map +1 -0
- package/dist/src/tui.d.ts +4 -11
- package/dist/src/tui.d.ts.map +1 -1
- package/dist/src/tui.js +33 -75
- package/dist/src/tui.js.map +1 -1
- package/dist/tui-build-map.json +380 -0
- package/dist/tui-ga-build-map.json +187 -0
- package/dist/types/src/antigravity/oauth.d.ts +2 -0
- package/dist/types/src/antigravity/oauth.d.ts.map +1 -0
- package/dist/types/src/cli.d.ts +66 -0
- package/dist/types/src/cli.d.ts.map +1 -0
- package/dist/types/src/common-auth-embedded/commands/builtins.d.ts +71 -0
- package/dist/types/src/common-auth-embedded/commands/index.d.ts +10 -0
- package/dist/types/src/common-auth-embedded/commands/menu.d.ts +61 -0
- package/dist/types/src/common-auth-embedded/commands/model.d.ts +238 -0
- package/dist/types/src/common-auth-embedded/commands/pi.d.ts +23 -0
- package/dist/types/src/common-auth-embedded/commands/seam.d.ts +72 -0
- package/dist/types/src/common-auth-embedded/fs/refresh-file-lock.d.ts +33 -0
- package/dist/types/src/common-auth-embedded/logger/capture-sink.d.ts +14 -0
- package/dist/types/src/common-auth-embedded/logger/engine.d.ts +100 -0
- package/dist/types/src/common-auth-embedded/logger/index.d.ts +6 -0
- package/dist/types/src/common-auth-embedded/logger/redact.d.ts +11 -0
- package/dist/types/src/common-auth-embedded/quota/codec.d.ts +11 -0
- package/dist/types/src/common-auth-embedded/quota/format.d.ts +46 -0
- package/dist/types/src/common-auth-embedded/quota/index.d.ts +10 -0
- package/dist/types/src/common-auth-embedded/quota/map.d.ts +63 -0
- package/dist/types/src/common-auth-embedded/quota/merge.d.ts +48 -0
- package/dist/types/src/common-auth-embedded/quota/projection.d.ts +64 -0
- package/dist/types/src/common-auth-embedded/store/attribution.d.ts +28 -0
- package/dist/types/src/common-auth-embedded/store/errors.d.ts +55 -0
- package/dist/types/src/common-auth-embedded/store/hooks.d.ts +12 -0
- package/dist/types/src/common-auth-embedded/store/identity.d.ts +39 -0
- package/dist/types/src/common-auth-embedded/store/index.d.ts +21 -0
- package/dist/types/src/common-auth-embedded/store/mutate.d.ts +189 -0
- package/dist/types/src/common-auth-embedded/store/pool.d.ts +196 -0
- package/dist/types/src/common-auth-embedded/store/provider-state.d.ts +131 -0
- package/dist/types/src/common-auth-embedded/store/publication.d.ts +47 -0
- package/dist/types/src/common-auth-embedded/store/pull.d.ts +36 -0
- package/dist/types/src/common-auth-embedded/store/refresh-lock.d.ts +63 -0
- package/dist/types/src/common-auth-embedded/store/refresh.d.ts +72 -0
- package/dist/types/src/common-auth-embedded/store/rows.d.ts +313 -0
- package/dist/types/src/common-auth-embedded/store/runtime.d.ts +36 -0
- package/dist/types/src/common-auth-embedded/store/schema.d.ts +443 -0
- package/dist/types/src/common-auth-embedded/store/settings.d.ts +63 -0
- package/dist/types/src/common-auth-embedded/store/torn.d.ts +78 -0
- package/dist/types/src/constants.d.ts +3 -0
- package/dist/types/src/constants.d.ts.map +1 -0
- package/dist/types/src/ga/proxy-guard.d.ts +120 -0
- package/dist/types/src/ga/proxy-guard.d.ts.map +1 -0
- package/dist/types/src/ga/rpc/protocol.d.ts +504 -0
- package/dist/types/src/ga/rpc/protocol.d.ts.map +1 -0
- package/dist/types/src/ga/server/auth.d.ts +9 -0
- package/dist/types/src/ga/server/auth.d.ts.map +1 -0
- package/dist/types/src/ga/server/index.d.ts +576 -0
- package/dist/types/src/ga/server/index.d.ts.map +1 -0
- package/dist/types/src/hooks/auto-update-checker/cache.d.ts +3 -0
- package/dist/types/src/hooks/auto-update-checker/cache.d.ts.map +1 -0
- package/dist/types/src/hooks/auto-update-checker/checker.d.ts +16 -0
- package/dist/types/src/hooks/auto-update-checker/checker.d.ts.map +1 -0
- package/dist/types/src/hooks/auto-update-checker/constants.d.ts +9 -0
- package/dist/types/src/hooks/auto-update-checker/constants.d.ts.map +1 -0
- package/dist/types/src/hooks/auto-update-checker/index.d.ts +34 -0
- package/dist/types/src/hooks/auto-update-checker/index.d.ts.map +1 -0
- package/dist/types/src/hooks/auto-update-checker/logging.d.ts +3 -0
- package/dist/types/src/hooks/auto-update-checker/logging.d.ts.map +1 -0
- package/dist/types/src/hooks/auto-update-checker/types.d.ts +25 -0
- package/dist/types/src/hooks/auto-update-checker/types.d.ts.map +1 -0
- package/dist/types/src/logging/provider-key-policy.d.ts +9 -0
- package/dist/types/src/logging/provider-key-policy.d.ts.map +1 -0
- package/dist/types/src/plugin/account-access.d.ts +214 -0
- package/dist/types/src/plugin/account-access.d.ts.map +1 -0
- package/dist/types/src/plugin/account-blocks.d.ts +102 -0
- package/dist/types/src/plugin/account-blocks.d.ts.map +1 -0
- package/dist/types/src/plugin/account-command-oauth.d.ts +34 -0
- package/dist/types/src/plugin/account-command-oauth.d.ts.map +1 -0
- package/dist/types/src/plugin/accounts.d.ts +94 -0
- package/dist/types/src/plugin/accounts.d.ts.map +1 -0
- package/dist/types/src/plugin/agy-request-metadata.d.ts +2 -0
- package/dist/types/src/plugin/agy-request-metadata.d.ts.map +1 -0
- package/dist/types/src/plugin/agy-transport.d.ts +2 -0
- package/dist/types/src/plugin/agy-transport.d.ts.map +1 -0
- package/dist/types/src/plugin/auth-doctor.d.ts +30 -0
- package/dist/types/src/plugin/auth-doctor.d.ts.map +1 -0
- package/dist/types/src/plugin/auth-drift.d.ts +13 -0
- package/dist/types/src/plugin/auth-drift.d.ts.map +1 -0
- package/dist/types/src/plugin/auth-loader.d.ts +114 -0
- package/dist/types/src/plugin/auth-loader.d.ts.map +1 -0
- package/dist/types/src/plugin/auth.d.ts +2 -0
- package/dist/types/src/plugin/auth.d.ts.map +1 -0
- package/dist/types/src/plugin/background-quota-refresh.d.ts +192 -0
- package/dist/types/src/plugin/background-quota-refresh.d.ts.map +1 -0
- package/dist/types/src/plugin/cache/signature-cache.d.ts +156 -0
- package/dist/types/src/plugin/cache/signature-cache.d.ts.map +1 -0
- package/dist/types/src/plugin/cache.d.ts +109 -0
- package/dist/types/src/plugin/cache.d.ts.map +1 -0
- package/dist/types/src/plugin/catalog.d.ts +9 -0
- package/dist/types/src/plugin/catalog.d.ts.map +1 -0
- package/dist/types/src/plugin/cli.d.ts +44 -0
- package/dist/types/src/plugin/cli.d.ts.map +1 -0
- package/dist/types/src/plugin/command-apply.d.ts +58 -0
- package/dist/types/src/plugin/command-apply.d.ts.map +1 -0
- package/dist/types/src/plugin/command-data.d.ts +330 -0
- package/dist/types/src/plugin/command-data.d.ts.map +1 -0
- package/dist/types/src/plugin/commands.d.ts +164 -0
- package/dist/types/src/plugin/commands.d.ts.map +1 -0
- package/dist/types/src/plugin/config/index.d.ts +16 -0
- package/dist/types/src/plugin/config/index.d.ts.map +1 -0
- package/dist/types/src/plugin/config/loader.d.ts +72 -0
- package/dist/types/src/plugin/config/loader.d.ts.map +1 -0
- package/dist/types/src/plugin/config/models.d.ts +3 -0
- package/dist/types/src/plugin/config/models.d.ts.map +1 -0
- package/dist/types/src/plugin/config/operator-settings-schema.d.ts +29 -0
- package/dist/types/src/plugin/config/operator-settings-schema.d.ts.map +1 -0
- package/dist/types/src/plugin/config/schema.d.ts +162 -0
- package/dist/types/src/plugin/config/schema.d.ts.map +1 -0
- package/dist/types/src/plugin/config/updater.d.ts +55 -0
- package/dist/types/src/plugin/config/updater.d.ts.map +1 -0
- package/dist/types/src/plugin/config/writer.d.ts +41 -0
- package/dist/types/src/plugin/config/writer.d.ts.map +1 -0
- package/dist/types/src/plugin/core/streaming/index.d.ts +3 -0
- package/dist/types/src/plugin/core/streaming/index.d.ts.map +1 -0
- package/dist/types/src/plugin/core/streaming/transformer.d.ts +12 -0
- package/dist/types/src/plugin/core/streaming/transformer.d.ts.map +1 -0
- package/dist/types/src/plugin/core/streaming/types.d.ts +34 -0
- package/dist/types/src/plugin/core/streaming/types.d.ts.map +1 -0
- package/dist/types/src/plugin/debug.d.ts +144 -0
- package/dist/types/src/plugin/debug.d.ts.map +1 -0
- package/dist/types/src/plugin/dependencies.d.ts +129 -0
- package/dist/types/src/plugin/dependencies.d.ts.map +1 -0
- package/dist/types/src/plugin/errors.d.ts +55 -0
- package/dist/types/src/plugin/errors.d.ts.map +1 -0
- package/dist/types/src/plugin/event-handler.d.ts +53 -0
- package/dist/types/src/plugin/event-handler.d.ts.map +1 -0
- package/dist/types/src/plugin/fetch/retry-state.d.ts +61 -0
- package/dist/types/src/plugin/fetch/retry-state.d.ts.map +1 -0
- package/dist/types/src/plugin/fetch/warmup.d.ts +30 -0
- package/dist/types/src/plugin/fetch/warmup.d.ts.map +1 -0
- package/dist/types/src/plugin/fetch-interceptor.d.ts +114 -0
- package/dist/types/src/plugin/fetch-interceptor.d.ts.map +1 -0
- package/dist/types/src/plugin/fetch-routing.d.ts +31 -0
- package/dist/types/src/plugin/fetch-routing.d.ts.map +1 -0
- package/dist/types/src/plugin/fingerprint.d.ts +2 -0
- package/dist/types/src/plugin/fingerprint.d.ts.map +1 -0
- package/dist/types/src/plugin/ga-location-services.d.ts +389 -0
- package/dist/types/src/plugin/ga-location-services.d.ts.map +1 -0
- package/dist/types/src/plugin/gemini-dump.d.ts +72 -0
- package/dist/types/src/plugin/gemini-dump.d.ts.map +1 -0
- package/dist/types/src/plugin/google-search-tool.d.ts +10 -0
- package/dist/types/src/plugin/google-search-tool.d.ts.map +1 -0
- package/dist/types/src/plugin/image-saver.d.ts +6 -0
- package/dist/types/src/plugin/image-saver.d.ts.map +1 -0
- package/dist/types/src/plugin/index.d.ts +30 -0
- package/dist/types/src/plugin/index.d.ts.map +1 -0
- package/dist/types/src/plugin/killswitch.d.ts +93 -0
- package/dist/types/src/plugin/killswitch.d.ts.map +1 -0
- package/dist/types/src/plugin/lifecycle.d.ts +63 -0
- package/dist/types/src/plugin/lifecycle.d.ts.map +1 -0
- package/dist/types/src/plugin/logger.d.ts +83 -0
- package/dist/types/src/plugin/logger.d.ts.map +1 -0
- package/dist/types/src/plugin/logging-utils.d.ts +57 -0
- package/dist/types/src/plugin/logging-utils.d.ts.map +1 -0
- package/dist/types/src/plugin/model-registry.d.ts +2 -0
- package/dist/types/src/plugin/model-registry.d.ts.map +1 -0
- package/dist/types/src/plugin/neutral-types.d.ts +42 -0
- package/dist/types/src/plugin/neutral-types.d.ts.map +1 -0
- package/dist/types/src/plugin/oauth-login.d.ts +22 -0
- package/dist/types/src/plugin/oauth-login.d.ts.map +1 -0
- package/dist/types/src/plugin/oauth-methods.d.ts +43 -0
- package/dist/types/src/plugin/oauth-methods.d.ts.map +1 -0
- package/dist/types/src/plugin/operator-settings.d.ts +74 -0
- package/dist/types/src/plugin/operator-settings.d.ts.map +1 -0
- package/dist/types/src/plugin/persist-account-pool.d.ts +98 -0
- package/dist/types/src/plugin/persist-account-pool.d.ts.map +1 -0
- package/dist/types/src/plugin/project.d.ts +2 -0
- package/dist/types/src/plugin/project.d.ts.map +1 -0
- package/dist/types/src/plugin/prompt-context.d.ts +18 -0
- package/dist/types/src/plugin/prompt-context.d.ts.map +1 -0
- package/dist/types/src/plugin/quota.d.ts +441 -0
- package/dist/types/src/plugin/quota.d.ts.map +1 -0
- package/dist/types/src/plugin/recovery/constants.d.ts +22 -0
- package/dist/types/src/plugin/recovery/constants.d.ts.map +1 -0
- package/dist/types/src/plugin/recovery/storage.d.ts +24 -0
- package/dist/types/src/plugin/recovery/storage.d.ts.map +1 -0
- package/dist/types/src/plugin/recovery/types.d.ts +116 -0
- package/dist/types/src/plugin/recovery/types.d.ts.map +1 -0
- package/dist/types/src/plugin/recovery.d.ts +61 -0
- package/dist/types/src/plugin/recovery.d.ts.map +1 -0
- package/dist/types/src/plugin/refresh-queue.d.ts +133 -0
- package/dist/types/src/plugin/refresh-queue.d.ts.map +1 -0
- package/dist/types/src/plugin/request-helpers.d.ts +304 -0
- package/dist/types/src/plugin/request-helpers.d.ts.map +1 -0
- package/dist/types/src/plugin/request.d.ts +161 -0
- package/dist/types/src/plugin/request.d.ts.map +1 -0
- package/dist/types/src/plugin/rotation.d.ts +2 -0
- package/dist/types/src/plugin/rotation.d.ts.map +1 -0
- package/dist/types/src/plugin/search.d.ts +25 -0
- package/dist/types/src/plugin/search.d.ts.map +1 -0
- package/dist/types/src/plugin/server.d.ts +23 -0
- package/dist/types/src/plugin/server.d.ts.map +1 -0
- package/dist/types/src/plugin/session-context.d.ts +22 -0
- package/dist/types/src/plugin/session-context.d.ts.map +1 -0
- package/dist/types/src/plugin/shared/local-grant.d.ts +26 -0
- package/dist/types/src/plugin/shared/local-grant.d.ts.map +1 -0
- package/dist/types/src/plugin/shared/request-cancellation.d.ts +12 -0
- package/dist/types/src/plugin/shared/request-cancellation.d.ts.map +1 -0
- package/dist/types/src/plugin/shared/request-services.d.ts +375 -0
- package/dist/types/src/plugin/shared/request-services.d.ts.map +1 -0
- package/dist/types/src/plugin/shared/runtime.d.ts +217 -0
- package/dist/types/src/plugin/shared/runtime.d.ts.map +1 -0
- package/dist/types/src/plugin/shared/source-sidebar.d.ts +15 -0
- package/dist/types/src/plugin/shared/source-sidebar.d.ts.map +1 -0
- package/dist/types/src/plugin/shared/vault-menu.d.ts +5 -0
- package/dist/types/src/plugin/shared/vault-menu.d.ts.map +1 -0
- package/dist/types/src/plugin/shared/vault-request-credentials.d.ts +168 -0
- package/dist/types/src/plugin/shared/vault-request-credentials.d.ts.map +1 -0
- package/dist/types/src/plugin/storage.d.ts +221 -0
- package/dist/types/src/plugin/storage.d.ts.map +1 -0
- package/dist/types/src/plugin/stores/signature-store.d.ts +5 -0
- package/dist/types/src/plugin/stores/signature-store.d.ts.map +1 -0
- package/dist/types/src/plugin/thinking-recovery.d.ts +90 -0
- package/dist/types/src/plugin/thinking-recovery.d.ts.map +1 -0
- package/dist/types/src/plugin/token.d.ts +41 -0
- package/dist/types/src/plugin/token.d.ts.map +1 -0
- package/dist/types/src/plugin/transform/cross-model-sanitizer.d.ts +2 -0
- package/dist/types/src/plugin/transform/cross-model-sanitizer.d.ts.map +1 -0
- package/dist/types/src/plugin/transform/index.d.ts +2 -0
- package/dist/types/src/plugin/transform/index.d.ts.map +1 -0
- package/dist/types/src/plugin/transform/model-resolver.d.ts +2 -0
- package/dist/types/src/plugin/transform/model-resolver.d.ts.map +1 -0
- package/dist/types/src/plugin/transform/types.d.ts +2 -0
- package/dist/types/src/plugin/transform/types.d.ts.map +1 -0
- package/dist/types/src/plugin/types.d.ts +36 -0
- package/dist/types/src/plugin/types.d.ts.map +1 -0
- package/dist/types/src/plugin/ui/ansi.d.ts +32 -0
- package/dist/types/src/plugin/ui/ansi.d.ts.map +1 -0
- package/dist/types/src/plugin/ui/auth-menu.d.ts +59 -0
- package/dist/types/src/plugin/ui/auth-menu.d.ts.map +1 -0
- package/dist/types/src/plugin/ui/confirm.d.ts +2 -0
- package/dist/types/src/plugin/ui/confirm.d.ts.map +1 -0
- package/dist/types/src/plugin/ui/quota-status.d.ts +73 -0
- package/dist/types/src/plugin/ui/quota-status.d.ts.map +1 -0
- package/dist/types/src/plugin/ui/select.d.ts +23 -0
- package/dist/types/src/plugin/ui/select.d.ts.map +1 -0
- package/dist/types/src/plugin/vault-activation.d.ts +11 -0
- package/dist/types/src/plugin/vault-activation.d.ts.map +1 -0
- package/dist/types/src/plugin/vault-custody.d.ts +131 -0
- package/dist/types/src/plugin/vault-custody.d.ts.map +1 -0
- package/dist/types/src/plugin/version.d.ts +2 -0
- package/dist/types/src/plugin/version.d.ts.map +1 -0
- package/dist/types/src/quota-presentation.d.ts +18 -0
- package/dist/types/src/quota-presentation.d.ts.map +1 -0
- package/dist/types/src/rpc/notifications.d.ts +6 -0
- package/dist/types/src/rpc/notifications.d.ts.map +1 -0
- package/dist/types/src/rpc/protocol.d.ts +53 -0
- package/dist/types/src/rpc/protocol.d.ts.map +1 -0
- package/dist/types/src/rpc/rpc-dir.d.ts +4 -0
- package/dist/types/src/rpc/rpc-dir.d.ts.map +1 -0
- package/dist/types/src/rpc/rpc-server.d.ts +24 -0
- package/dist/types/src/rpc/rpc-server.d.ts.map +1 -0
- package/dist/types/src/server.d.ts +30 -0
- package/dist/types/src/server.d.ts.map +1 -0
- package/dist/types/src/sidebar-state.d.ts +365 -0
- package/dist/types/src/sidebar-state.d.ts.map +1 -0
- package/dist/types/src/tui/host-api.d.ts +196 -0
- package/dist/types/src/tui/host-api.d.ts.map +1 -0
- package/package.json +45 -18
- package/server.js +6 -0
- package/src/common-auth-embedded/NOTICE.txt +21 -0
- package/src/common-auth-embedded/auth-menu/accounts.d.ts +97 -0
- package/src/common-auth-embedded/auth-menu/accounts.js +387 -0
- package/src/common-auth-embedded/auth-menu/ansi.d.ts +26 -0
- package/src/common-auth-embedded/auth-menu/ansi.js +98 -0
- package/src/common-auth-embedded/auth-menu/confirm.d.ts +7 -0
- package/src/common-auth-embedded/auth-menu/confirm.js +21 -0
- package/src/common-auth-embedded/auth-menu/doctor.d.ts +52 -0
- package/src/common-auth-embedded/auth-menu/doctor.js +81 -0
- package/src/common-auth-embedded/auth-menu/index.d.ts +17 -0
- package/src/common-auth-embedded/auth-menu/index.js +12 -0
- package/src/common-auth-embedded/auth-menu/login.d.ts +55 -0
- package/src/common-auth-embedded/auth-menu/login.js +83 -0
- package/src/common-auth-embedded/auth-menu/menu.d.ts +59 -0
- package/src/common-auth-embedded/auth-menu/menu.js +73 -0
- package/src/common-auth-embedded/auth-menu/opencode-v1.d.ts +49 -0
- package/src/common-auth-embedded/auth-menu/opencode-v1.js +47 -0
- package/src/common-auth-embedded/auth-menu/select.d.ts +21 -0
- package/src/common-auth-embedded/auth-menu/select.js +159 -0
- package/src/common-auth-embedded/auth-menu/terminal.d.ts +43 -0
- package/src/common-auth-embedded/auth-menu/terminal.js +19 -0
- package/src/common-auth-embedded/claustrum/consumer.d.ts +102 -0
- package/src/common-auth-embedded/claustrum/consumer.js +298 -0
- package/src/common-auth-embedded/claustrum/custody.d.ts +175 -0
- package/src/common-auth-embedded/claustrum/custody.js +354 -0
- package/src/common-auth-embedded/claustrum/enrollment.d.ts +158 -0
- package/src/common-auth-embedded/claustrum/enrollment.js +759 -0
- package/src/common-auth-embedded/claustrum/errors.d.ts +16 -0
- package/src/common-auth-embedded/claustrum/errors.js +8 -0
- package/src/common-auth-embedded/claustrum/host-slot.d.ts +39 -0
- package/src/common-auth-embedded/claustrum/host-slot.js +72 -0
- package/src/common-auth-embedded/claustrum/index.d.ts +18 -0
- package/src/common-auth-embedded/claustrum/index.js +22 -0
- package/src/common-auth-embedded/claustrum/interlock.d.ts +27 -0
- package/src/common-auth-embedded/claustrum/interlock.js +29 -0
- package/src/common-auth-embedded/claustrum/roster.d.ts +208 -0
- package/src/common-auth-embedded/claustrum/roster.js +536 -0
- package/src/common-auth-embedded/commands/builtins.d.ts +71 -0
- package/src/common-auth-embedded/commands/builtins.js +534 -0
- package/src/common-auth-embedded/commands/index.d.ts +10 -0
- package/src/common-auth-embedded/commands/index.js +5 -0
- package/src/common-auth-embedded/commands/menu.d.ts +61 -0
- package/src/common-auth-embedded/commands/menu.js +300 -0
- package/src/common-auth-embedded/commands/model.d.ts +238 -0
- package/src/common-auth-embedded/commands/model.js +16 -0
- package/src/common-auth-embedded/commands/pi.d.ts +23 -0
- package/src/common-auth-embedded/commands/pi.js +206 -0
- package/src/common-auth-embedded/commands/seam.d.ts +72 -0
- package/src/common-auth-embedded/commands/seam.js +301 -0
- package/src/common-auth-embedded/fs/atomic-write.d.ts +20 -0
- package/src/common-auth-embedded/fs/atomic-write.js +80 -0
- package/src/common-auth-embedded/fs/index.d.ts +7 -0
- package/src/common-auth-embedded/fs/index.js +6 -0
- package/src/common-auth-embedded/fs/lock-constants.d.ts +14 -0
- package/src/common-auth-embedded/fs/lock-constants.js +14 -0
- package/src/common-auth-embedded/fs/refresh-file-lock.d.ts +33 -0
- package/src/common-auth-embedded/fs/refresh-file-lock.js +501 -0
- package/src/common-auth-embedded/fs/with-lock.d.ts +33 -0
- package/src/common-auth-embedded/fs/with-lock.js +48 -0
- package/src/common-auth-embedded/logger/capture-sink.d.ts +14 -0
- package/src/common-auth-embedded/logger/capture-sink.js +13 -0
- package/src/common-auth-embedded/logger/engine.d.ts +100 -0
- package/src/common-auth-embedded/logger/engine.js +246 -0
- package/src/common-auth-embedded/logger/index.d.ts +6 -0
- package/src/common-auth-embedded/logger/index.js +3 -0
- package/src/common-auth-embedded/logger/redact.d.ts +11 -0
- package/src/common-auth-embedded/logger/redact.js +83 -0
- package/src/common-auth-embedded/opencode2/errors.d.ts +25 -0
- package/src/common-auth-embedded/opencode2/errors.js +15 -0
- package/src/common-auth-embedded/opencode2/index.d.ts +8 -0
- package/src/common-auth-embedded/opencode2/index.js +4 -0
- package/src/common-auth-embedded/opencode2/install.d.ts +55 -0
- package/src/common-auth-embedded/opencode2/install.js +886 -0
- package/src/common-auth-embedded/opencode2/integration.d.ts +112 -0
- package/src/common-auth-embedded/opencode2/integration.js +143 -0
- package/src/common-auth-embedded/opencode2/sse.d.ts +12 -0
- package/src/common-auth-embedded/opencode2/sse.js +60 -0
- package/src/common-auth-embedded/opencode2/types.d.ts +413 -0
- package/src/common-auth-embedded/pi-slot/index.d.ts +3 -0
- package/src/common-auth-embedded/pi-slot/index.js +2 -0
- package/src/common-auth-embedded/pi-slot/lock.js +212 -0
- package/src/common-auth-embedded/pi-slot/slot.d.ts +49 -0
- package/src/common-auth-embedded/pi-slot/slot.js +383 -0
- package/src/common-auth-embedded/quota/codec.d.ts +11 -0
- package/src/common-auth-embedded/quota/codec.js +12 -0
- package/src/common-auth-embedded/quota/format.d.ts +46 -0
- package/src/common-auth-embedded/quota/format.js +138 -0
- package/src/common-auth-embedded/quota/index.d.ts +10 -0
- package/src/common-auth-embedded/quota/index.js +5 -0
- package/src/common-auth-embedded/quota/map.d.ts +63 -0
- package/src/common-auth-embedded/quota/map.js +105 -0
- package/src/common-auth-embedded/quota/merge.d.ts +48 -0
- package/src/common-auth-embedded/quota/merge.js +162 -0
- package/src/common-auth-embedded/quota/projection.d.ts +64 -0
- package/src/common-auth-embedded/quota/projection.js +134 -0
- package/src/common-auth-embedded/routing/admission.d.ts +93 -0
- package/src/common-auth-embedded/routing/admission.js +142 -0
- package/src/common-auth-embedded/routing/index.d.ts +8 -0
- package/src/common-auth-embedded/routing/index.js +4 -0
- package/src/common-auth-embedded/routing/ordered.d.ts +47 -0
- package/src/common-auth-embedded/routing/ordered.js +58 -0
- package/src/common-auth-embedded/routing/pins.d.ts +22 -0
- package/src/common-auth-embedded/routing/pins.js +34 -0
- package/src/common-auth-embedded/routing/sticky.d.ts +158 -0
- package/src/common-auth-embedded/routing/sticky.js +339 -0
- package/src/common-auth-embedded/rpc/client.d.ts +3 -0
- package/src/common-auth-embedded/rpc/client.js +2 -0
- package/src/common-auth-embedded/rpc/index.d.ts +10 -0
- package/src/common-auth-embedded/rpc/index.js +5 -0
- package/src/common-auth-embedded/rpc/notifications.d.ts +73 -0
- package/src/common-auth-embedded/rpc/notifications.js +100 -0
- package/src/common-auth-embedded/rpc/port-file.d.ts +33 -0
- package/src/common-auth-embedded/rpc/port-file.js +217 -0
- package/src/common-auth-embedded/rpc/rpc-client.d.ts +30 -0
- package/src/common-auth-embedded/rpc/rpc-client.js +253 -0
- package/src/common-auth-embedded/rpc/rpc-server.d.ts +58 -0
- package/src/common-auth-embedded/rpc/rpc-server.js +311 -0
- package/src/common-auth-embedded/rpc/server-registry.d.ts +11 -0
- package/src/common-auth-embedded/rpc/server-registry.js +47 -0
- package/src/common-auth-embedded/source-output.json +1326 -0
- package/src/common-auth-embedded/store/attribution.d.ts +28 -0
- package/src/common-auth-embedded/store/attribution.js +60 -0
- package/src/common-auth-embedded/store/errors.d.ts +55 -0
- package/src/common-auth-embedded/store/errors.js +38 -0
- package/src/common-auth-embedded/store/hooks.d.ts +12 -0
- package/src/common-auth-embedded/store/hooks.js +34 -0
- package/src/common-auth-embedded/store/identity.d.ts +39 -0
- package/src/common-auth-embedded/store/identity.js +79 -0
- package/src/common-auth-embedded/store/index.d.ts +21 -0
- package/src/common-auth-embedded/store/index.js +7 -0
- package/src/common-auth-embedded/store/mutate.d.ts +189 -0
- package/src/common-auth-embedded/store/mutate.js +500 -0
- package/src/common-auth-embedded/store/pool.d.ts +196 -0
- package/src/common-auth-embedded/store/pool.js +120 -0
- package/src/common-auth-embedded/store/provider-state.d.ts +131 -0
- package/src/common-auth-embedded/store/provider-state.js +226 -0
- package/src/common-auth-embedded/store/publication.d.ts +47 -0
- package/src/common-auth-embedded/store/publication.js +304 -0
- package/src/common-auth-embedded/store/pull.d.ts +36 -0
- package/src/common-auth-embedded/store/pull.js +143 -0
- package/src/common-auth-embedded/store/refresh-lock.d.ts +63 -0
- package/src/common-auth-embedded/store/refresh-lock.js +136 -0
- package/src/common-auth-embedded/store/refresh.d.ts +72 -0
- package/src/common-auth-embedded/store/refresh.js +225 -0
- package/src/common-auth-embedded/store/reserved.js +13 -0
- package/src/common-auth-embedded/store/rows.d.ts +313 -0
- package/src/common-auth-embedded/store/rows.js +1258 -0
- package/src/common-auth-embedded/store/runtime.d.ts +36 -0
- package/src/common-auth-embedded/store/runtime.js +68 -0
- package/src/common-auth-embedded/store/schema.d.ts +443 -0
- package/src/common-auth-embedded/store/schema.js +754 -0
- package/src/common-auth-embedded/store/settings.d.ts +63 -0
- package/src/common-auth-embedded/store/settings.js +120 -0
- package/src/common-auth-embedded/store/torn.d.ts +78 -0
- package/src/common-auth-embedded/store/torn.js +294 -0
- package/src/common-auth-embedded/tui/index.d.ts +8 -0
- package/src/common-auth-embedded/tui/index.js +21 -0
- package/src/common-auth-embedded/util/any-signal.js +42 -0
- package/src/plugin/command-data.ts +3 -0
- package/src/rpc/port-file.ts +6 -140
- package/src/rpc/protocol.ts +59 -24
- package/src/rpc/rpc-client.ts +101 -71
- package/src/sidebar-state.ts +82 -24
- package/src/tui/command-dialogs.tsx +412 -776
- package/src/tui/entry.d.mts +17 -0
- package/src/tui/entry.mjs +34 -66
- package/src/tui/file-logger.ts +22 -7
- package/src/tui-compiled/common-auth-embedded/logger/capture-sink.js +13 -0
- package/src/tui-compiled/common-auth-embedded/logger/engine.js +246 -0
- package/src/tui-compiled/common-auth-embedded/logger/index.js +3 -0
- package/src/tui-compiled/common-auth-embedded/logger/redact.js +83 -0
- package/src/tui-compiled/common-auth-embedded/quota/codec.js +12 -0
- package/src/tui-compiled/common-auth-embedded/quota/format.js +138 -0
- package/src/tui-compiled/common-auth-embedded/quota/index.js +5 -0
- package/src/tui-compiled/common-auth-embedded/quota/map.js +105 -0
- package/src/tui-compiled/common-auth-embedded/quota/merge.js +162 -0
- package/src/tui-compiled/common-auth-embedded/quota/projection.js +134 -0
- package/src/tui-compiled/common-auth-embedded/rpc/client.js +2 -0
- package/src/tui-compiled/common-auth-embedded/rpc/port-file.js +217 -0
- package/src/tui-compiled/common-auth-embedded/rpc/rpc-client.js +253 -0
- package/src/tui-compiled/logging/provider-key-policy.js +3 -0
- package/src/tui-compiled/quota-presentation.js +42 -0
- package/src/tui-compiled/rpc/rpc-client.js +35 -0
- package/src/tui-compiled/rpc/rpc-dir.js +13 -0
- package/src/tui-compiled/selector.js +21 -0
- package/src/tui-compiled/sidebar-state.js +401 -0
- package/src/tui-compiled/tui/command-dialogs.js +424 -0
- package/src/tui-compiled/tui/file-logger.js +73 -0
- package/src/tui-compiled/tui/host-api.js +269 -0
- package/src/tui-compiled/tui/host-v1.js +228 -0
- package/src/tui-compiled/tui-preferences.js +230 -0
- package/src/tui-compiled/{tui.tsx → tui.js} +140 -231
- package/src/tui-ga-compiled/host-ga.js +1304 -0
- package/src/tui-ga-compiled/selector.js +21 -0
- package/src/tui-ga-compiled/shared/07365a7d2ccade4c-host-api.js +269 -0
- package/src/tui-ga-compiled/shared/0e19a88ff3535906-command-dialogs.js +424 -0
- package/src/tui-ga-compiled/shared/1ff34afa7c42d196-projection.js +134 -0
- package/src/tui-ga-compiled/shared/77138df80c7ae006-map.js +105 -0
- package/src/tui-ga-compiled/shared/8ae1927e5910ea81-sidebar-projection.js +112 -0
- package/src/tui-ga-compiled/shared/98cc0c186c46c42d-quota-presentation.js +42 -0
- package/src/tui-ga-compiled/shared/aef2402f8fc342f0-format.js +138 -0
- package/src/tui-ga-compiled/shared/bf17cbee28e58197-index.js +5 -0
- package/src/tui-ga-compiled/shared/ca21dc417b36dc5d-codec.js +12 -0
- package/src/tui-ga-compiled/shared/ecc214300932dfb6-merge.js +162 -0
- package/src/tui-ga-raw/host-ga.tsx +1740 -0
- package/src/tui-ga-raw/selector.js +21 -0
- package/src/tui-ga-raw/shared/07365a7d2ccade4c-host-api.js +269 -0
- package/src/tui-ga-raw/shared/0e19a88ff3535906-command-dialogs.tsx +468 -0
- package/src/tui-ga-raw/shared/1ff34afa7c42d196-projection.js +134 -0
- package/src/tui-ga-raw/shared/77138df80c7ae006-map.js +105 -0
- package/src/tui-ga-raw/shared/8ae1927e5910ea81-sidebar-projection.js +112 -0
- package/src/tui-ga-raw/shared/98cc0c186c46c42d-quota-presentation.js +42 -0
- package/src/tui-ga-raw/shared/aef2402f8fc342f0-format.js +138 -0
- package/src/tui-ga-raw/shared/bf17cbee28e58197-index.js +5 -0
- package/src/tui-ga-raw/shared/ca21dc417b36dc5d-codec.js +12 -0
- package/src/tui-ga-raw/shared/ecc214300932dfb6-merge.js +162 -0
- package/src/tui-raw/common-auth-embedded/logger/capture-sink.js +13 -0
- package/src/tui-raw/common-auth-embedded/logger/engine.js +246 -0
- package/src/tui-raw/common-auth-embedded/logger/index.js +3 -0
- package/src/tui-raw/common-auth-embedded/logger/redact.js +83 -0
- package/src/tui-raw/common-auth-embedded/quota/codec.js +12 -0
- package/src/tui-raw/common-auth-embedded/quota/format.js +138 -0
- package/src/tui-raw/common-auth-embedded/quota/index.js +5 -0
- package/src/tui-raw/common-auth-embedded/quota/map.js +105 -0
- package/src/tui-raw/common-auth-embedded/quota/merge.js +162 -0
- package/src/tui-raw/common-auth-embedded/quota/projection.js +134 -0
- package/src/tui-raw/common-auth-embedded/rpc/client.js +2 -0
- package/src/tui-raw/common-auth-embedded/rpc/port-file.js +217 -0
- package/src/tui-raw/common-auth-embedded/rpc/rpc-client.js +253 -0
- package/src/tui-raw/logging/provider-key-policy.js +3 -0
- package/src/tui-raw/quota-presentation.js +42 -0
- package/src/tui-raw/rpc/rpc-client.js +35 -0
- package/src/tui-raw/rpc/rpc-dir.js +13 -0
- package/src/tui-raw/selector.js +21 -0
- package/src/tui-raw/sidebar-state.js +401 -0
- package/src/tui-raw/tui/command-dialogs.tsx +468 -0
- package/src/tui-raw/tui/file-logger.js +73 -0
- package/src/tui-raw/tui/host-api.js +269 -0
- package/src/tui-raw/tui/host-v1.tsx +249 -0
- package/src/tui-raw/tui-preferences.js +230 -0
- package/src/tui-raw/tui.tsx +1088 -0
- package/src/tui.tsx +58 -141
- package/tui.js +6 -0
- package/src/tui-compiled/plugin/command-data.ts +0 -931
- package/src/tui-compiled/rpc/port-file.ts +0 -143
- package/src/tui-compiled/rpc/protocol.ts +0 -31
- package/src/tui-compiled/rpc/rpc-client.ts +0 -102
- package/src/tui-compiled/rpc/rpc-dir.ts +0 -24
- package/src/tui-compiled/sidebar-state.ts +0 -991
- package/src/tui-compiled/tui/command-dialogs.tsx +0 -779
- package/src/tui-compiled/tui/file-logger.ts +0 -145
- package/src/tui-compiled/tui-preferences.ts +0 -416
|
@@ -0,0 +1,1838 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The OpenCode 2 (GA host) location services: account state for the
|
|
3
|
+
* `antigravity-auth` RPC `state` method, the shared `/antigravity` menu
|
|
4
|
+
* behind `apply`, and `createGaLocationServicesFactory`, which builds a
|
|
5
|
+
* location's services from the bound account repository and the shared
|
|
6
|
+
* request pipeline.
|
|
7
|
+
*
|
|
8
|
+
* Accounts come from the location's account repository, read once per
|
|
9
|
+
* `state` call. Each account in a state answer carries an opaque selector: a
|
|
10
|
+
* random string issued for one exact credential (row id, credential epoch
|
|
11
|
+
* and recorded identity), kept across reads and reorders and retired when
|
|
12
|
+
* that credential is replaced, re-identified or removed. Account actions run
|
|
13
|
+
* through the shared menu, whose own opaque item ids are bound the same way;
|
|
14
|
+
* an account position is never accepted as a target.
|
|
15
|
+
*
|
|
16
|
+
* Everything a location needs (repository, settings controller, dump switch,
|
|
17
|
+
* logger) arrives explicitly; nothing here reads a process-global binding.
|
|
18
|
+
* The GA server module is imported for types only, so it can import this
|
|
19
|
+
* module's factory without a cycle.
|
|
20
|
+
*/
|
|
21
|
+
import { randomBytes } from 'node:crypto';
|
|
22
|
+
import { ANTIGRAVITY_MENU_COMMAND, antigravitySettingsSections, authorizeAntigravity, createAccountRepositoryFactory, createAntigravityCommandMenu, ensureProjectContext, exchangeAntigravity, fetchWithAgyCliTransport, formatRefreshParts, loadCommonAuthCommands, loadCommonAuthStoreModules, parseRefreshParts, readAccountStoreAdmission, readAccountStoreBinding, refreshAntigravityToken, rowRefKey, sameRowRef, VAULT_ACCOUNT_REMEDY, } from '@cortexkit/antigravity-auth-core';
|
|
23
|
+
import { createRepositoryAccountAccessService, extractAccountAccessErrorDetails, } from "./account-access.js";
|
|
24
|
+
import { createLocalAccountCredentials, loadAccountManagerFromRepository, } from "./accounts.js";
|
|
25
|
+
import { createStoreAccountLimits, diagnosticsMenuSection, operatorMenuSettings, } from "./command-apply.js";
|
|
26
|
+
import { createAuthorizedFetchAccountQuota, createStoreQuotaService, } from "./quota.js";
|
|
27
|
+
import { buildThinkingWarmupBody, getImageModelLocalTitle, getLastCacheStats, prepareAntigravityRequest, transformAntigravityResponse, } from "./request.js";
|
|
28
|
+
import { startOAuthListener } from "./server.js";
|
|
29
|
+
import { AgySessionRegistry } from "./session-context.js";
|
|
30
|
+
import { createLocalQuotaRefresh, createRequestExecutor, } from "./shared/request-services.js";
|
|
31
|
+
import { createMemoryQuotaSnapshots, } from "./shared/runtime.js";
|
|
32
|
+
import { createVaultAccountMenuSections } from './shared/vault-menu';
|
|
33
|
+
import { checkVaultQuota, createVaultAccountPool, vaultAccountRowKey, } from "./shared/vault-request-credentials.js";
|
|
34
|
+
import { getStoragePath } from './storage';
|
|
35
|
+
import { createOpenCodeVaultCustody, } from "./vault-custody.js";
|
|
36
|
+
/** Accounts one `state` answer may carry (`ANTIGRAVITY_RPC_LIMITS.accounts`). */
|
|
37
|
+
const ACCOUNT_LIMIT = 64;
|
|
38
|
+
/**
|
|
39
|
+
* How many retired selectors are remembered so a late action on one is
|
|
40
|
+
* answered `stale-target` rather than `unknown-target`. Older ones are
|
|
41
|
+
* forgotten and then answered `unknown-target`; neither outcome writes.
|
|
42
|
+
*/
|
|
43
|
+
const RETIRED_SELECTOR_MEMORY = 256;
|
|
44
|
+
/**
|
|
45
|
+
* 192 random bits as `sel-` plus 32 URL-safe characters, the selector shape
|
|
46
|
+
* the RPC contract accepts; carries no account data.
|
|
47
|
+
*/
|
|
48
|
+
function defaultSelector() {
|
|
49
|
+
return `sel-${randomBytes(24).toString('base64url')}`;
|
|
50
|
+
}
|
|
51
|
+
export function createGaSelectorRegistry(createSelector = defaultSelector) {
|
|
52
|
+
/** Live selectors by exact ref key, and the ref each selector names. */
|
|
53
|
+
const live = new Map();
|
|
54
|
+
const liveRefs = new Map();
|
|
55
|
+
/** Retired selectors in retirement order (oldest first). */
|
|
56
|
+
const retired = new Map();
|
|
57
|
+
const issued = new Set();
|
|
58
|
+
const fresh = () => {
|
|
59
|
+
for (;;) {
|
|
60
|
+
const selector = createSelector();
|
|
61
|
+
if (!issued.has(selector))
|
|
62
|
+
return selector;
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
return {
|
|
66
|
+
plan(refs) {
|
|
67
|
+
const additions = new Map();
|
|
68
|
+
const selectors = refs.map((ref) => {
|
|
69
|
+
const key = rowRefKey(ref);
|
|
70
|
+
const existing = live.get(key) ?? additions.get(key)?.selector;
|
|
71
|
+
if (existing !== undefined)
|
|
72
|
+
return existing;
|
|
73
|
+
const selector = fresh();
|
|
74
|
+
additions.set(key, { selector, ref });
|
|
75
|
+
return selector;
|
|
76
|
+
});
|
|
77
|
+
const keep = new Set(refs.map((ref) => rowRefKey(ref)));
|
|
78
|
+
let committed = false;
|
|
79
|
+
return {
|
|
80
|
+
selectors,
|
|
81
|
+
commit() {
|
|
82
|
+
if (committed)
|
|
83
|
+
return [];
|
|
84
|
+
committed = true;
|
|
85
|
+
const retiredNow = [];
|
|
86
|
+
for (const [key, selector] of live) {
|
|
87
|
+
if (keep.has(key))
|
|
88
|
+
continue;
|
|
89
|
+
const ref = liveRefs.get(selector);
|
|
90
|
+
live.delete(key);
|
|
91
|
+
liveRefs.delete(selector);
|
|
92
|
+
if (ref !== undefined)
|
|
93
|
+
retired.set(selector, ref);
|
|
94
|
+
retiredNow.push(selector);
|
|
95
|
+
}
|
|
96
|
+
for (const [key, entry] of additions) {
|
|
97
|
+
if (live.has(key))
|
|
98
|
+
continue;
|
|
99
|
+
issued.add(entry.selector);
|
|
100
|
+
live.set(key, entry.selector);
|
|
101
|
+
liveRefs.set(entry.selector, entry.ref);
|
|
102
|
+
}
|
|
103
|
+
while (retired.size > RETIRED_SELECTOR_MEMORY) {
|
|
104
|
+
const oldest = retired.keys().next().value;
|
|
105
|
+
if (oldest === undefined)
|
|
106
|
+
break;
|
|
107
|
+
retired.delete(oldest);
|
|
108
|
+
}
|
|
109
|
+
return retiredNow;
|
|
110
|
+
},
|
|
111
|
+
};
|
|
112
|
+
},
|
|
113
|
+
resolve(selector) {
|
|
114
|
+
const ref = liveRefs.get(selector);
|
|
115
|
+
if (ref !== undefined)
|
|
116
|
+
return { kind: 'live', ref };
|
|
117
|
+
const old = retired.get(selector);
|
|
118
|
+
if (old !== undefined)
|
|
119
|
+
return { kind: 'retired', ref: old };
|
|
120
|
+
return { kind: 'unknown' };
|
|
121
|
+
},
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
function routingSlotsOf(read, ref) {
|
|
125
|
+
const routing = read.routing;
|
|
126
|
+
if (routing === undefined)
|
|
127
|
+
return [];
|
|
128
|
+
const slots = [];
|
|
129
|
+
if (routing.activeRow && sameRowRef(routing.activeRow, ref))
|
|
130
|
+
slots.push('active');
|
|
131
|
+
const byFamily = routing.activeRowByFamily;
|
|
132
|
+
if (byFamily?.claude && sameRowRef(byFamily.claude, ref))
|
|
133
|
+
slots.push('claude');
|
|
134
|
+
if (byFamily?.gemini && sameRowRef(byFamily.gemini, ref))
|
|
135
|
+
slots.push('gemini');
|
|
136
|
+
return slots;
|
|
137
|
+
}
|
|
138
|
+
function metadataStatusOf(row) {
|
|
139
|
+
const view = row.metadata;
|
|
140
|
+
if (view.status === 'present')
|
|
141
|
+
return 'present';
|
|
142
|
+
if (view.status === 'absent')
|
|
143
|
+
return 'absent';
|
|
144
|
+
return view.reason === 'uncovered' ? 'dropped-uncovered' : 'dropped-invalid';
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* The access block the row's metadata records. Absent or dropped metadata
|
|
148
|
+
* cannot rule a block out, so it is `unknown`, never `none`.
|
|
149
|
+
*/
|
|
150
|
+
export function accessBlockOf(row) {
|
|
151
|
+
if (row.metadata.status !== 'present')
|
|
152
|
+
return { kind: 'unknown' };
|
|
153
|
+
const metadata = row.metadata.metadata;
|
|
154
|
+
const verification = metadata.verificationRequired;
|
|
155
|
+
const ineligible = metadata.accountIneligible;
|
|
156
|
+
const flag = (value) => value === undefined || value === null || typeof value === 'boolean';
|
|
157
|
+
if (!flag(verification) || !flag(ineligible))
|
|
158
|
+
return { kind: 'invalid' };
|
|
159
|
+
if (verification === true && ineligible === true)
|
|
160
|
+
return { kind: 'invalid' };
|
|
161
|
+
if (verification === true) {
|
|
162
|
+
const reason = metadata.verificationRequiredReason;
|
|
163
|
+
return {
|
|
164
|
+
kind: 'verification-required',
|
|
165
|
+
reason: reason === undefined || reason === null
|
|
166
|
+
? 'unrecorded'
|
|
167
|
+
: reason === 'validation-required'
|
|
168
|
+
? 'validation-required'
|
|
169
|
+
: 'other',
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
if (ineligible === true) {
|
|
173
|
+
const reason = metadata.accountIneligibleReason;
|
|
174
|
+
return {
|
|
175
|
+
kind: 'ineligible',
|
|
176
|
+
reason: reason === undefined || reason === null
|
|
177
|
+
? 'unrecorded'
|
|
178
|
+
: reason === 'account-ineligible'
|
|
179
|
+
? 'account-ineligible'
|
|
180
|
+
: 'other',
|
|
181
|
+
};
|
|
182
|
+
}
|
|
183
|
+
return { kind: 'none' };
|
|
184
|
+
}
|
|
185
|
+
function cooldownOf(row) {
|
|
186
|
+
if (row.metadata.status !== 'present')
|
|
187
|
+
return null;
|
|
188
|
+
const until = row.metadata.metadata.coolingDownUntil;
|
|
189
|
+
return typeof until === 'number' ? until : null;
|
|
190
|
+
}
|
|
191
|
+
function quotaOf(row) {
|
|
192
|
+
if (row.quota.status !== 'present')
|
|
193
|
+
return undefined;
|
|
194
|
+
const groups = row.quota.quota.cachedQuota;
|
|
195
|
+
if (!groups)
|
|
196
|
+
return undefined;
|
|
197
|
+
const out = {};
|
|
198
|
+
for (const [key, group] of Object.entries(groups)) {
|
|
199
|
+
out[key] = {
|
|
200
|
+
...(typeof group.remainingFraction === 'number'
|
|
201
|
+
? { remainingFraction: group.remainingFraction }
|
|
202
|
+
: {}),
|
|
203
|
+
...(typeof group.resetTime === 'string'
|
|
204
|
+
? { resetTime: group.resetTime }
|
|
205
|
+
: {}),
|
|
206
|
+
modelCount: group.modelCount,
|
|
207
|
+
...(group.windows
|
|
208
|
+
? {
|
|
209
|
+
windows: group.windows.map((window) => ({
|
|
210
|
+
window: window.window,
|
|
211
|
+
remainingFraction: window.remainingFraction,
|
|
212
|
+
resetTime: window.resetTime,
|
|
213
|
+
})),
|
|
214
|
+
}
|
|
215
|
+
: {}),
|
|
216
|
+
};
|
|
217
|
+
}
|
|
218
|
+
return out;
|
|
219
|
+
}
|
|
220
|
+
function tierOf(row) {
|
|
221
|
+
if (row.metadata.status !== 'present')
|
|
222
|
+
return undefined;
|
|
223
|
+
const metadata = row.metadata.metadata;
|
|
224
|
+
if (typeof metadata.capturedTierId !== 'string' ||
|
|
225
|
+
typeof metadata.capturedTierAt !== 'number')
|
|
226
|
+
return undefined;
|
|
227
|
+
return {
|
|
228
|
+
id: metadata.capturedTierId,
|
|
229
|
+
...(typeof metadata.capturedPaidTierId === 'string'
|
|
230
|
+
? { paidId: metadata.capturedPaidTierId }
|
|
231
|
+
: {}),
|
|
232
|
+
capturedAt: metadata.capturedTierAt,
|
|
233
|
+
};
|
|
234
|
+
}
|
|
235
|
+
/**
|
|
236
|
+
* The redaction input for one row: position, flags, cooldown, quota and
|
|
237
|
+
* tier. It carries no email, label, token, project, identity or row id.
|
|
238
|
+
*/
|
|
239
|
+
function redactionInputOf(row, position, current, health) {
|
|
240
|
+
const cooldown = cooldownOf(row);
|
|
241
|
+
const quota = quotaOf(row);
|
|
242
|
+
const tier = tierOf(row);
|
|
243
|
+
const score = health(row);
|
|
244
|
+
return {
|
|
245
|
+
index: position,
|
|
246
|
+
enabled: row.enabled,
|
|
247
|
+
current,
|
|
248
|
+
...(cooldown !== null ? { coolingDownUntil: cooldown } : {}),
|
|
249
|
+
...(score !== undefined ? { healthScore: score } : {}),
|
|
250
|
+
...(quota !== undefined ? { cachedQuota: quota } : {}),
|
|
251
|
+
...(row.quota.status === 'present' &&
|
|
252
|
+
typeof row.quota.quota.cachedQuotaUpdatedAt === 'number'
|
|
253
|
+
? { cachedQuotaUpdatedAt: row.quota.quota.cachedQuotaUpdatedAt }
|
|
254
|
+
: {}),
|
|
255
|
+
...(tier !== undefined ? { tier } : {}),
|
|
256
|
+
};
|
|
257
|
+
}
|
|
258
|
+
// ---------------------------------------------------------------------------
|
|
259
|
+
// Settings
|
|
260
|
+
// ---------------------------------------------------------------------------
|
|
261
|
+
/**
|
|
262
|
+
* The settings DTO from the location's live controller and dump switch. It
|
|
263
|
+
* only reads; per-account killswitch overrides stay out because their keys
|
|
264
|
+
* derive from refresh tokens.
|
|
265
|
+
*/
|
|
266
|
+
export function gaSettingsOf(settings, dump) {
|
|
267
|
+
return {
|
|
268
|
+
routing: {
|
|
269
|
+
cliFirst: settings.routing.cli_first,
|
|
270
|
+
quotaStyleFallback: settings.routing.quota_style_fallback,
|
|
271
|
+
},
|
|
272
|
+
killswitch: {
|
|
273
|
+
enabled: settings.killswitch.enabled,
|
|
274
|
+
minimumRemainingPercent: settings.killswitch.minimum_remaining_percent,
|
|
275
|
+
},
|
|
276
|
+
logLevel: settings.log_level,
|
|
277
|
+
dump: { enabled: dump.isEnabled() },
|
|
278
|
+
};
|
|
279
|
+
}
|
|
280
|
+
function project(read, registry, health) {
|
|
281
|
+
if (read.status !== 'ready') {
|
|
282
|
+
return { read, rows: [], overLimit: null, plan: null };
|
|
283
|
+
}
|
|
284
|
+
if (read.rows.length > ACCOUNT_LIMIT) {
|
|
285
|
+
return { read, rows: [], overLimit: read.rows.length, plan: null };
|
|
286
|
+
}
|
|
287
|
+
const plan = registry.plan(read.rows.map((row) => row.ref));
|
|
288
|
+
const rows = read.rows.map((row, position) => {
|
|
289
|
+
const slots = routingSlotsOf(read, row.ref);
|
|
290
|
+
return {
|
|
291
|
+
selector: plan.selectors[position] ?? '',
|
|
292
|
+
row: redactionInputOf(row, position, slots.includes('active'), health),
|
|
293
|
+
source: row,
|
|
294
|
+
slots,
|
|
295
|
+
};
|
|
296
|
+
});
|
|
297
|
+
return { read, rows, overLimit: null, plan };
|
|
298
|
+
}
|
|
299
|
+
function abortError(signal) {
|
|
300
|
+
return signal.reason instanceof Error
|
|
301
|
+
? signal.reason
|
|
302
|
+
: new Error('The state read was aborted');
|
|
303
|
+
}
|
|
304
|
+
/**
|
|
305
|
+
* Builds the `state` source. Reads run one at a time, so `readSeq` follows
|
|
306
|
+
* the order answers are built in; an aborted read leaves the selector
|
|
307
|
+
* registry unchanged. The diagnostic observer, when present, is called
|
|
308
|
+
* synchronously with a view of the same read.
|
|
309
|
+
*/
|
|
310
|
+
export function createGaAccountStateSource(options) {
|
|
311
|
+
let readSeq = 0;
|
|
312
|
+
let queue = Promise.resolve();
|
|
313
|
+
const health = options.health ?? (() => undefined);
|
|
314
|
+
const readOnce = async (input) => {
|
|
315
|
+
if (input.signal.aborted)
|
|
316
|
+
throw abortError(input.signal);
|
|
317
|
+
const read = await options.repository.read();
|
|
318
|
+
if (input.signal.aborted)
|
|
319
|
+
throw abortError(input.signal);
|
|
320
|
+
const projected = project(read, options.registry, health);
|
|
321
|
+
const settings = options.settings();
|
|
322
|
+
const status = options.status();
|
|
323
|
+
const route = options.route(input.scope);
|
|
324
|
+
if (input.signal.aborted)
|
|
325
|
+
throw abortError(input.signal);
|
|
326
|
+
const retiredSelectors = projected.plan?.commit() ?? [];
|
|
327
|
+
readSeq = options.nextReadSeq?.() ?? readSeq + 1;
|
|
328
|
+
const answer = {
|
|
329
|
+
readSeq,
|
|
330
|
+
accounts: projected.overLimit !== null
|
|
331
|
+
? { kind: 'over-limit', count: projected.overLimit }
|
|
332
|
+
: {
|
|
333
|
+
kind: 'complete',
|
|
334
|
+
rows: projected.rows.map(({ selector, row }) => ({
|
|
335
|
+
selector,
|
|
336
|
+
row,
|
|
337
|
+
})),
|
|
338
|
+
},
|
|
339
|
+
route,
|
|
340
|
+
status,
|
|
341
|
+
settings,
|
|
342
|
+
};
|
|
343
|
+
if (options.observe) {
|
|
344
|
+
const accounts = projected.rows.map(({ selector, source, slots }, position) => ({
|
|
345
|
+
selector,
|
|
346
|
+
position,
|
|
347
|
+
enabled: source.enabled,
|
|
348
|
+
usable: source.usable,
|
|
349
|
+
metadataStatus: metadataStatusOf(source),
|
|
350
|
+
accessBlock: accessBlockOf(source),
|
|
351
|
+
currentFor: slots,
|
|
352
|
+
cooldownUntil: cooldownOf(source),
|
|
353
|
+
}));
|
|
354
|
+
try {
|
|
355
|
+
options.observe({
|
|
356
|
+
generation: options.generation,
|
|
357
|
+
readSeq,
|
|
358
|
+
status: read.status,
|
|
359
|
+
accountsStatus: projected.overLimit !== null ? 'over-limit' : 'complete',
|
|
360
|
+
accounts,
|
|
361
|
+
retiredSelectors,
|
|
362
|
+
});
|
|
363
|
+
}
|
|
364
|
+
catch {
|
|
365
|
+
// A diagnostic observer cannot change the answer.
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
return answer;
|
|
369
|
+
};
|
|
370
|
+
return {
|
|
371
|
+
read(input) {
|
|
372
|
+
const next = queue.then(() => readOnce(input), () => readOnce(input));
|
|
373
|
+
queue = next.catch(() => undefined);
|
|
374
|
+
return next;
|
|
375
|
+
},
|
|
376
|
+
};
|
|
377
|
+
}
|
|
378
|
+
/**
|
|
379
|
+
* The location's `/antigravity` menu: the shared core menu in repository
|
|
380
|
+
* mode over this activation's repository and runtime. Accounts are acted on
|
|
381
|
+
* by the menu's own opaque item ids, each bound to one exact credential;
|
|
382
|
+
* Routing, Limits and Diagnostics read and write this location's settings
|
|
383
|
+
* controller and dump switch. `commands` must be the module whose
|
|
384
|
+
* `parseApplyRequest` the RPC activation uses.
|
|
385
|
+
*/
|
|
386
|
+
export function createGaLocationMenu(input) {
|
|
387
|
+
const runtime = input.runtime;
|
|
388
|
+
return createAntigravityCommandMenu({
|
|
389
|
+
source: 'repository',
|
|
390
|
+
commands: input.commands,
|
|
391
|
+
accounts: input.repository,
|
|
392
|
+
settings: operatorMenuSettings(runtime.operatorSettings),
|
|
393
|
+
diagnostics: diagnosticsMenuSection({
|
|
394
|
+
settings: runtime.operatorSettings,
|
|
395
|
+
dump: runtime.dump,
|
|
396
|
+
applyLogLevel: () => runtime.applyOperatorSettings(),
|
|
397
|
+
}),
|
|
398
|
+
accountLimits: createStoreAccountLimits({
|
|
399
|
+
repository: input.repository,
|
|
400
|
+
settings: runtime.operatorSettings,
|
|
401
|
+
}),
|
|
402
|
+
...(input.refreshQuota ? { refreshQuota: input.refreshQuota } : {}),
|
|
403
|
+
...(input.reauthorize ? { reauthorize: input.reauthorize } : {}),
|
|
404
|
+
...(input.vault ? { extras: [input.vault] } : {}),
|
|
405
|
+
});
|
|
406
|
+
}
|
|
407
|
+
/** The menu invocation for one RPC scope; its notices are queued there. */
|
|
408
|
+
function scopeInvocation(scope, notify) {
|
|
409
|
+
return {
|
|
410
|
+
...(scope.kind === 'session' ? { sessionId: scope.sessionID } : {}),
|
|
411
|
+
notify(message, kind) {
|
|
412
|
+
notify(scope, {
|
|
413
|
+
command: ANTIGRAVITY_MENU_COMMAND,
|
|
414
|
+
notify: { message, kind: kind ?? 'info' },
|
|
415
|
+
});
|
|
416
|
+
},
|
|
417
|
+
};
|
|
418
|
+
}
|
|
419
|
+
/**
|
|
420
|
+
* The menu service over the location's menu. Each request (already accepted
|
|
421
|
+
* by the library's own parser) runs through the menu with an invocation for
|
|
422
|
+
* its scope, whose notices are queued for that scope; once the activation's
|
|
423
|
+
* signal aborts, no new action starts. After every apply, `afterApply`
|
|
424
|
+
* brings the routing state up to date with what the action wrote; its
|
|
425
|
+
* failure is reported to the scope but does not change the menu's answer.
|
|
426
|
+
*/
|
|
427
|
+
export function createGaMenuCommandService(input) {
|
|
428
|
+
return {
|
|
429
|
+
async apply({ request, scope, signal }) {
|
|
430
|
+
if (signal.aborted)
|
|
431
|
+
throw abortError(signal);
|
|
432
|
+
const result = await input.menu.apply(request, scopeInvocation(scope, input.notify));
|
|
433
|
+
if (input.afterApply) {
|
|
434
|
+
try {
|
|
435
|
+
await input.afterApply();
|
|
436
|
+
}
|
|
437
|
+
catch {
|
|
438
|
+
input.notify(scope, {
|
|
439
|
+
command: ANTIGRAVITY_MENU_COMMAND,
|
|
440
|
+
notify: {
|
|
441
|
+
message: 'The change was saved, but routing has not picked it up yet.',
|
|
442
|
+
kind: 'warning',
|
|
443
|
+
},
|
|
444
|
+
});
|
|
445
|
+
}
|
|
446
|
+
}
|
|
447
|
+
return result;
|
|
448
|
+
},
|
|
449
|
+
async open({ scope, signal }) {
|
|
450
|
+
if (signal.aborted)
|
|
451
|
+
throw abortError(signal);
|
|
452
|
+
const payload = await input.menu.open(scopeInvocation(scope, input.notify));
|
|
453
|
+
if (signal.aborted)
|
|
454
|
+
throw abortError(signal);
|
|
455
|
+
input.notify(scope, payload);
|
|
456
|
+
},
|
|
457
|
+
};
|
|
458
|
+
}
|
|
459
|
+
/**
|
|
460
|
+
* The account items' Reauthorize action for a GA location: a browser
|
|
461
|
+
* sign-in whose result replaces exactly the credential the item was opened
|
|
462
|
+
* for (through the account adapters' repository access service, which also
|
|
463
|
+
* refuses a sign-in to a different Google account and clears the row's
|
|
464
|
+
* access blocks). The action answers once the sign-in has started and the
|
|
465
|
+
* callback listener is waiting; the rest finishes in the background and is
|
|
466
|
+
* reported to the invoking session. `afterChange` brings routing up to date
|
|
467
|
+
* with the new credential.
|
|
468
|
+
*
|
|
469
|
+
* Without an override, the redirect is received by this package's own
|
|
470
|
+
* callback listener on the registered redirect address, which accepts only
|
|
471
|
+
* the state of the sign-in it was started for.
|
|
472
|
+
*/
|
|
473
|
+
export function createGaReauthorize(input) {
|
|
474
|
+
const authorize = input.overrides.oauth?.authorize ?? authorizeAntigravity;
|
|
475
|
+
const exchange = input.overrides.oauth?.exchange ?? exchangeAntigravity;
|
|
476
|
+
const waitForCode = input.overrides.oauth?.waitForCode;
|
|
477
|
+
const access = createRepositoryAccountAccessService({
|
|
478
|
+
repository: input.repository,
|
|
479
|
+
// A GA location has no terminal: it opens no browser itself and asks
|
|
480
|
+
// no account question; the sign-in link is shown in the menu instead.
|
|
481
|
+
openBrowser: async () => false,
|
|
482
|
+
prompt: {
|
|
483
|
+
selectAccount: async () => undefined,
|
|
484
|
+
confirmOpenVerificationUrl: async () => false,
|
|
485
|
+
},
|
|
486
|
+
});
|
|
487
|
+
const listeners = new Set();
|
|
488
|
+
const continuations = new Set();
|
|
489
|
+
const shutdown = new AbortController();
|
|
490
|
+
let disposed = false;
|
|
491
|
+
const waitForRedirect = (code) => new Promise((resolve, reject) => {
|
|
492
|
+
const detach = () => shutdown.signal.removeEventListener('abort', abort);
|
|
493
|
+
const abort = () => {
|
|
494
|
+
detach();
|
|
495
|
+
reject(shutdown.signal.reason);
|
|
496
|
+
};
|
|
497
|
+
if (shutdown.signal.aborted)
|
|
498
|
+
reject(shutdown.signal.reason);
|
|
499
|
+
else
|
|
500
|
+
shutdown.signal.addEventListener('abort', abort, { once: true });
|
|
501
|
+
void code.then((value) => {
|
|
502
|
+
detach();
|
|
503
|
+
resolve(value);
|
|
504
|
+
}, (error) => {
|
|
505
|
+
detach();
|
|
506
|
+
reject(error);
|
|
507
|
+
});
|
|
508
|
+
});
|
|
509
|
+
/** Return the callback promise inside an object so setup can finish before the browser login. */
|
|
510
|
+
const startWaiting = async (expectedState) => {
|
|
511
|
+
if (waitForCode)
|
|
512
|
+
return { code: waitForCode(expectedState) };
|
|
513
|
+
const listener = await startOAuthListener();
|
|
514
|
+
if (disposed) {
|
|
515
|
+
await listener.close();
|
|
516
|
+
throw shutdown.signal.reason;
|
|
517
|
+
}
|
|
518
|
+
listeners.add(listener);
|
|
519
|
+
const code = (async () => {
|
|
520
|
+
try {
|
|
521
|
+
const url = await listener.waitForCallback();
|
|
522
|
+
if (url.searchParams.get('state') !== expectedState)
|
|
523
|
+
throw new Error('The sign-in answered for a different request');
|
|
524
|
+
const code = url.searchParams.get('code');
|
|
525
|
+
if (!code)
|
|
526
|
+
throw new Error('The sign-in returned no code');
|
|
527
|
+
return code;
|
|
528
|
+
}
|
|
529
|
+
finally {
|
|
530
|
+
listeners.delete(listener);
|
|
531
|
+
await listener.close();
|
|
532
|
+
}
|
|
533
|
+
})();
|
|
534
|
+
return { code };
|
|
535
|
+
};
|
|
536
|
+
return {
|
|
537
|
+
async run(ref, invocation) {
|
|
538
|
+
if (disposed)
|
|
539
|
+
return {
|
|
540
|
+
ok: false,
|
|
541
|
+
text: 'The location is shutting down.',
|
|
542
|
+
code: 'refused',
|
|
543
|
+
};
|
|
544
|
+
await input.assertAdmission?.();
|
|
545
|
+
const authorization = await authorize();
|
|
546
|
+
if (disposed)
|
|
547
|
+
throw shutdown.signal.reason;
|
|
548
|
+
const state = new URL(authorization.url).searchParams.get('state');
|
|
549
|
+
if (!state)
|
|
550
|
+
return {
|
|
551
|
+
ok: false,
|
|
552
|
+
text: 'The sign-in could not be started.',
|
|
553
|
+
code: 'action-failed',
|
|
554
|
+
};
|
|
555
|
+
const waiting = await startWaiting(state);
|
|
556
|
+
const continuation = (async () => {
|
|
557
|
+
try {
|
|
558
|
+
const code = await waitForRedirect(waiting.code);
|
|
559
|
+
await input.assertAdmission?.();
|
|
560
|
+
if (disposed)
|
|
561
|
+
throw shutdown.signal.reason;
|
|
562
|
+
const result = await exchange(code, state);
|
|
563
|
+
if (result.type !== 'success') {
|
|
564
|
+
invocation.notify('The sign-in was not completed.', 'error');
|
|
565
|
+
return;
|
|
566
|
+
}
|
|
567
|
+
await access.reauthorizeAccount(ref, result);
|
|
568
|
+
await input.afterChange();
|
|
569
|
+
invocation.notify('Account reauthorized.', 'info');
|
|
570
|
+
}
|
|
571
|
+
catch {
|
|
572
|
+
if (!disposed)
|
|
573
|
+
invocation.notify('The account could not be reauthorized.', 'error');
|
|
574
|
+
}
|
|
575
|
+
})();
|
|
576
|
+
continuations.add(continuation);
|
|
577
|
+
void continuation.then(() => continuations.delete(continuation), () => continuations.delete(continuation));
|
|
578
|
+
return `Sign in with the browser to reauthorize this account:\n${authorization.url}\nWaiting for the browser…`;
|
|
579
|
+
},
|
|
580
|
+
async dispose() {
|
|
581
|
+
disposed = true;
|
|
582
|
+
shutdown.abort(new Error('The location is shutting down.'));
|
|
583
|
+
const open = [...listeners];
|
|
584
|
+
listeners.clear();
|
|
585
|
+
const results = await Promise.allSettled(open.map((listener) => listener.close()));
|
|
586
|
+
while (continuations.size > 0)
|
|
587
|
+
await Promise.allSettled([...continuations]);
|
|
588
|
+
const failure = results.find((result) => result.status === 'rejected');
|
|
589
|
+
if (failure?.status === 'rejected')
|
|
590
|
+
throw failure.reason;
|
|
591
|
+
},
|
|
592
|
+
};
|
|
593
|
+
}
|
|
594
|
+
/**
|
|
595
|
+
* Reads the OpenCode 2 host's own sign-in for `integrationID` in the shape
|
|
596
|
+
* the vault library classifies: an OAuth credential as
|
|
597
|
+
* `{ type: 'oauth', refresh, access, expires }`, a key credential as
|
|
598
|
+
* `{ type: 'api', key }`, and no active connection as `undefined` (empty).
|
|
599
|
+
* An active connection whose credential cannot be resolved, or a credential
|
|
600
|
+
* of another shape, rejects: custody is then refused, never decided on a
|
|
601
|
+
* slot read as empty by mistake.
|
|
602
|
+
*/
|
|
603
|
+
export function createGaHostSlotReader(connections, integrationID) {
|
|
604
|
+
return async () => {
|
|
605
|
+
const connection = await connections.active(integrationID);
|
|
606
|
+
if (connection === undefined)
|
|
607
|
+
return undefined;
|
|
608
|
+
const credential = await connections.resolve(connection);
|
|
609
|
+
if (typeof credential !== 'object' || credential === null)
|
|
610
|
+
throw new Error('The host sign-in could not be resolved');
|
|
611
|
+
if ('type' in credential &&
|
|
612
|
+
credential.type === 'oauth' &&
|
|
613
|
+
'refresh' in credential &&
|
|
614
|
+
typeof credential.refresh === 'string' &&
|
|
615
|
+
'access' in credential &&
|
|
616
|
+
typeof credential.access === 'string' &&
|
|
617
|
+
'expires' in credential &&
|
|
618
|
+
typeof credential.expires === 'number')
|
|
619
|
+
return {
|
|
620
|
+
type: 'oauth',
|
|
621
|
+
refresh: credential.refresh,
|
|
622
|
+
access: credential.access,
|
|
623
|
+
expires: credential.expires,
|
|
624
|
+
};
|
|
625
|
+
if ('type' in credential &&
|
|
626
|
+
credential.type === 'key' &&
|
|
627
|
+
'key' in credential &&
|
|
628
|
+
typeof credential.key === 'string')
|
|
629
|
+
return { type: 'api', key: credential.key };
|
|
630
|
+
throw new Error('The host sign-in has an unknown shape');
|
|
631
|
+
};
|
|
632
|
+
}
|
|
633
|
+
// ---------------------------------------------------------------------------
|
|
634
|
+
// Location services factory
|
|
635
|
+
// ---------------------------------------------------------------------------
|
|
636
|
+
/** The legacy account file name inside a location directory. */
|
|
637
|
+
export const GA_ACCOUNTS_FILE = 'antigravity-accounts.json';
|
|
638
|
+
/**
|
|
639
|
+
* The repository's token exchange: the core OAuth refresh, or the test
|
|
640
|
+
* override. It returns the bare tokens; the repository stores them.
|
|
641
|
+
*/
|
|
642
|
+
function tokenExchange(overrides) {
|
|
643
|
+
const refresh = overrides.refreshAccessToken ?? refreshAntigravityToken;
|
|
644
|
+
return async ({ refreshToken }) => {
|
|
645
|
+
const result = await refresh(refreshToken);
|
|
646
|
+
return {
|
|
647
|
+
accessToken: result.access,
|
|
648
|
+
refreshToken: result.refresh,
|
|
649
|
+
expiresAt: result.expires,
|
|
650
|
+
};
|
|
651
|
+
};
|
|
652
|
+
}
|
|
653
|
+
function storeRefusal(status) {
|
|
654
|
+
return new Error(status.status === 'initialization-required'
|
|
655
|
+
? 'The Antigravity account store is not initialized; initialize it with the antigravity-auth CLI.'
|
|
656
|
+
: status.status === 'error'
|
|
657
|
+
? `The Antigravity account store cannot be opened: ${status.reason}`
|
|
658
|
+
: `The Antigravity account store is ${status.status}; finish its migration or rollback with \`antigravity-auth migrate --offline\` or \`antigravity-auth rollback --offline\`.`);
|
|
659
|
+
}
|
|
660
|
+
/**
|
|
661
|
+
* Opens the location's account repository on the migration's canonical
|
|
662
|
+
* binding: a completed generation the repository may open, including to
|
|
663
|
+
* resume its own pending clear or replace work. Binding is not permission
|
|
664
|
+
* to route; `assertServingAdmission` checks that before any credential is
|
|
665
|
+
* used. Initialization and migration are offline CLI operations, never a
|
|
666
|
+
* side effect of activation.
|
|
667
|
+
*/
|
|
668
|
+
async function openLocationRepository(directory, bindings, overrides) {
|
|
669
|
+
const legacyPath = bindings.resolveAccountFile(directory);
|
|
670
|
+
const modules = await bindings.loadStoreModules();
|
|
671
|
+
const binding = await readAccountStoreBinding(legacyPath, modules, bindings.now);
|
|
672
|
+
if (binding.status !== 'bound')
|
|
673
|
+
throw storeRefusal(binding);
|
|
674
|
+
return {
|
|
675
|
+
repository: createAccountRepositoryFactory(modules)({
|
|
676
|
+
paths: binding.paths,
|
|
677
|
+
now: bindings.now,
|
|
678
|
+
exchange: tokenExchange(overrides),
|
|
679
|
+
}),
|
|
680
|
+
legacyPath,
|
|
681
|
+
generation: binding.receipt.id,
|
|
682
|
+
modules,
|
|
683
|
+
};
|
|
684
|
+
}
|
|
685
|
+
/**
|
|
686
|
+
* Serving needs the full admission of the same generation the repository
|
|
687
|
+
* was bound to: healthy current rows and no pending management work.
|
|
688
|
+
*/
|
|
689
|
+
async function assertServingAdmission(location, now) {
|
|
690
|
+
const admission = await readAccountStoreAdmission(location.legacyPath, location.modules, now, location.generation);
|
|
691
|
+
if (admission.status === 'active')
|
|
692
|
+
return;
|
|
693
|
+
if (admission.status === 'pending' && admission.phase === 'activate')
|
|
694
|
+
throw new Error('An Antigravity account operation is still finishing; reopen the session once it completes.');
|
|
695
|
+
throw storeRefusal(admission);
|
|
696
|
+
}
|
|
697
|
+
// ---------------------------------------------------------------------------
|
|
698
|
+
// Request pipeline (local account repository)
|
|
699
|
+
// ---------------------------------------------------------------------------
|
|
700
|
+
/**
|
|
701
|
+
* How long a response body may stall before the transport destroys the
|
|
702
|
+
* socket; the GA raw sender (`GA_RAW_IDLE_TIMEOUT_MS`) uses the same five
|
|
703
|
+
* minutes. Declared here because the GA server module is imported for types
|
|
704
|
+
* only.
|
|
705
|
+
*/
|
|
706
|
+
const GA_TRANSPORT_IDLE_TIMEOUT_MS = 300_000;
|
|
707
|
+
/**
|
|
708
|
+
* Local credentials for a repository-backed GA location, in the shared
|
|
709
|
+
* engine's `local` domain. A refresh is of the selected account itself:
|
|
710
|
+
* `refreshAccount` uses the ref the account was loaded with, so the
|
|
711
|
+
* repository stores a successor token only for that exact credential and
|
|
712
|
+
* refuses one whose row has since changed. Rows are never found again by
|
|
713
|
+
* token.
|
|
714
|
+
*/
|
|
715
|
+
export function createGaLocalCredentials(manager, options) {
|
|
716
|
+
const local = createLocalAccountCredentials(manager, {
|
|
717
|
+
repository: options.repository,
|
|
718
|
+
...(options.overrides.ensureProjectContext
|
|
719
|
+
? { ensureProject: options.overrides.ensureProjectContext }
|
|
720
|
+
: {}),
|
|
721
|
+
});
|
|
722
|
+
return {
|
|
723
|
+
domain: 'local',
|
|
724
|
+
toAuthDetails: (account) => manager.toAuthDetails(account),
|
|
725
|
+
updateFromAuth: (account, auth) => manager.updateFromAuth(account, auth),
|
|
726
|
+
removeAccount: (account) => manager.removeAccount(account),
|
|
727
|
+
saveToDisk: () => manager.saveToDisk(),
|
|
728
|
+
saveToDiskReplace: () => manager.saveToDiskReplace(),
|
|
729
|
+
refresh: (account) => local.refresh(account),
|
|
730
|
+
// Checking and resolution use the captured row ID, epoch and identity,
|
|
731
|
+
// never whichever replacement the account object might later refer to.
|
|
732
|
+
captureGrant: (grant) => local.captureGrant(grant),
|
|
733
|
+
ensureProject: (auth) => local.ensureProject(auth),
|
|
734
|
+
isInvalidGrant: (error) => local.isInvalidGrant(error),
|
|
735
|
+
// The GA host keeps no OAuth credential of its own for this provider;
|
|
736
|
+
// accounts live only in the repository, so there is nothing to clear.
|
|
737
|
+
clearStoredAuth: async () => undefined,
|
|
738
|
+
...(options.refreshQuotaAfterSuccess
|
|
739
|
+
? { refreshQuotaAfterSuccess: options.refreshQuotaAfterSuccess }
|
|
740
|
+
: {}),
|
|
741
|
+
};
|
|
742
|
+
}
|
|
743
|
+
/** How close to expiry a stored access token is still used as is. */
|
|
744
|
+
const QUOTA_TOKEN_SKEW_MS = 60_000;
|
|
745
|
+
/**
|
|
746
|
+
* Resolves the bearer for one quota check from the repository, by the
|
|
747
|
+
* target's captured ref only. A row that no longer holds that exact
|
|
748
|
+
* credential (replaced, re-identified or removed) is refused rather than
|
|
749
|
+
* checked on its successor. An expired token is refreshed through the
|
|
750
|
+
* repository's attributed refresh, never locally.
|
|
751
|
+
*/
|
|
752
|
+
export async function authorizeGaQuotaCheck(repository, target, now) {
|
|
753
|
+
const ref = target.rowRef;
|
|
754
|
+
if (ref === undefined)
|
|
755
|
+
return { status: 'refused', reason: 'unattributed' };
|
|
756
|
+
const read = await repository.read();
|
|
757
|
+
if (read.status !== 'ready')
|
|
758
|
+
return { status: 'refused', reason: 'not-ready' };
|
|
759
|
+
const row = read.rows.find((candidate) => sameRowRef(candidate.ref, ref));
|
|
760
|
+
if (row === undefined ||
|
|
761
|
+
row.credential === undefined ||
|
|
762
|
+
!row.enabled ||
|
|
763
|
+
!row.usable ||
|
|
764
|
+
row.metadata.status !== 'present')
|
|
765
|
+
return { status: 'refused', reason: 'stale' };
|
|
766
|
+
const metadata = row.metadata.status === 'present' ? row.metadata.metadata : undefined;
|
|
767
|
+
const projects = {
|
|
768
|
+
...(metadata?.projectId ? { projectId: metadata.projectId } : {}),
|
|
769
|
+
...(metadata?.managedProjectId
|
|
770
|
+
? { managedProjectId: metadata.managedProjectId }
|
|
771
|
+
: {}),
|
|
772
|
+
};
|
|
773
|
+
const stored = row.credential;
|
|
774
|
+
if (stored.accessToken !== undefined &&
|
|
775
|
+
stored.expiresAt !== undefined &&
|
|
776
|
+
stored.expiresAt - QUOTA_TOKEN_SKEW_MS > now()) {
|
|
777
|
+
return {
|
|
778
|
+
status: 'authorized',
|
|
779
|
+
ref,
|
|
780
|
+
auth: {
|
|
781
|
+
type: 'oauth',
|
|
782
|
+
refresh: formatRefreshParts({
|
|
783
|
+
refreshToken: stored.refreshToken,
|
|
784
|
+
...projects,
|
|
785
|
+
}),
|
|
786
|
+
access: stored.accessToken,
|
|
787
|
+
expires: stored.expiresAt,
|
|
788
|
+
},
|
|
789
|
+
};
|
|
790
|
+
}
|
|
791
|
+
const outcome = await repository.refresh(ref);
|
|
792
|
+
if (outcome.status !== 'rotated')
|
|
793
|
+
return { status: 'refused', reason: 'refresh-refused' };
|
|
794
|
+
const after = await repository.read();
|
|
795
|
+
const successor = after.status === 'ready'
|
|
796
|
+
? after.rows.find((candidate) => sameRowRef(candidate.ref, outcome.ref))
|
|
797
|
+
: undefined;
|
|
798
|
+
if (successor?.credential === undefined ||
|
|
799
|
+
!successor.enabled ||
|
|
800
|
+
!successor.usable ||
|
|
801
|
+
successor.metadata.status !== 'present')
|
|
802
|
+
return { status: 'refused', reason: 'stale' };
|
|
803
|
+
return {
|
|
804
|
+
status: 'authorized',
|
|
805
|
+
ref: outcome.ref,
|
|
806
|
+
auth: {
|
|
807
|
+
type: 'oauth',
|
|
808
|
+
refresh: formatRefreshParts({
|
|
809
|
+
refreshToken: successor.credential.refreshToken,
|
|
810
|
+
...(successor.metadata.metadata.projectId
|
|
811
|
+
? { projectId: successor.metadata.metadata.projectId }
|
|
812
|
+
: {}),
|
|
813
|
+
...(successor.metadata.metadata.managedProjectId
|
|
814
|
+
? { managedProjectId: successor.metadata.metadata.managedProjectId }
|
|
815
|
+
: {}),
|
|
816
|
+
}),
|
|
817
|
+
access: outcome.accessToken,
|
|
818
|
+
expires: outcome.expiresAt,
|
|
819
|
+
},
|
|
820
|
+
};
|
|
821
|
+
}
|
|
822
|
+
function isRowRef(value) {
|
|
823
|
+
return (typeof value === 'object' &&
|
|
824
|
+
value !== null &&
|
|
825
|
+
'id' in value &&
|
|
826
|
+
typeof value.id === 'string' &&
|
|
827
|
+
'credentialEpoch' in value &&
|
|
828
|
+
typeof value.credentialEpoch === 'number' &&
|
|
829
|
+
(!('identity' in value) ||
|
|
830
|
+
value.identity === undefined ||
|
|
831
|
+
typeof value.identity === 'string'));
|
|
832
|
+
}
|
|
833
|
+
/** The captured ref a quota target carries, when it carries a valid one. */
|
|
834
|
+
function rowRefOfTarget(account) {
|
|
835
|
+
if (!('rowRef' in account))
|
|
836
|
+
return undefined;
|
|
837
|
+
return isRowRef(account.rowRef) ? account.rowRef : undefined;
|
|
838
|
+
}
|
|
839
|
+
/**
|
|
840
|
+
* The GA location's quota fetcher. Each check is attributed to the target's
|
|
841
|
+
* captured repository ref: the bearer comes from `authorizeGaQuotaCheck`
|
|
842
|
+
* (stored token, or the repository's attributed refresh), and a target
|
|
843
|
+
* without a ref, or whose credential has since changed, is answered with an
|
|
844
|
+
* error result instead of being checked on another credential.
|
|
845
|
+
*/
|
|
846
|
+
export function createGaFetchAccountQuota(options) {
|
|
847
|
+
const ensureProject = options.overrides.ensureProjectContext ?? ensureProjectContext;
|
|
848
|
+
const quotaFetch = options.overrides.quotaFetch;
|
|
849
|
+
return createAuthorizedFetchAccountQuota({
|
|
850
|
+
logger: options.logger,
|
|
851
|
+
...(quotaFetch ? { transport: () => quotaFetch } : {}),
|
|
852
|
+
async authorize(account) {
|
|
853
|
+
// Captured before any await: the ref of exactly this target.
|
|
854
|
+
const rowRef = rowRefOfTarget(account);
|
|
855
|
+
await options.assertAdmission?.();
|
|
856
|
+
const authorization = await authorizeGaQuotaCheck(options.repository, { rowRef }, options.now);
|
|
857
|
+
if (authorization.status !== 'authorized')
|
|
858
|
+
return { status: 'refused', reason: authorization.reason };
|
|
859
|
+
const ref = authorization.ref;
|
|
860
|
+
const accessToken = authorization.auth.access ?? '';
|
|
861
|
+
await options.assertAdmission?.();
|
|
862
|
+
const project = await ensureProject(authorization.auth);
|
|
863
|
+
await options.assertAdmission?.();
|
|
864
|
+
const managedProjectId = parseRefreshParts(project.auth.refresh).managedProjectId;
|
|
865
|
+
return {
|
|
866
|
+
status: 'authorized',
|
|
867
|
+
domain: 'local',
|
|
868
|
+
accessToken,
|
|
869
|
+
projectId: project.effectiveProjectId,
|
|
870
|
+
...(managedProjectId ? { managedProjectId } : {}),
|
|
871
|
+
// Before every request: the row must still hold exactly this
|
|
872
|
+
// credential and this access token.
|
|
873
|
+
confirmSend: async () => {
|
|
874
|
+
await options.assertAdmission?.();
|
|
875
|
+
const read = await options.repository.read();
|
|
876
|
+
const row = read.status === 'ready'
|
|
877
|
+
? read.rows.find((candidate) => sameRowRef(candidate.ref, ref))
|
|
878
|
+
: undefined;
|
|
879
|
+
if (row === undefined ||
|
|
880
|
+
!row.enabled ||
|
|
881
|
+
!row.usable ||
|
|
882
|
+
row.metadata.status !== 'present')
|
|
883
|
+
return { status: 'stale', reason: 'credential changed' };
|
|
884
|
+
if (row.credential?.accessToken !== accessToken)
|
|
885
|
+
return { status: 'stale', reason: 'access token changed' };
|
|
886
|
+
await options.assertAdmission?.();
|
|
887
|
+
return { status: 'current' };
|
|
888
|
+
},
|
|
889
|
+
};
|
|
890
|
+
},
|
|
891
|
+
});
|
|
892
|
+
}
|
|
893
|
+
export function createGaRouteBook(limit = 256) {
|
|
894
|
+
const routes = new Map();
|
|
895
|
+
return {
|
|
896
|
+
record(sessionId, entry) {
|
|
897
|
+
routes.delete(sessionId);
|
|
898
|
+
routes.set(sessionId, {
|
|
899
|
+
accountId: entry.accountId,
|
|
900
|
+
modelFamily: entry.modelFamily,
|
|
901
|
+
headerStyle: entry.headerStyle,
|
|
902
|
+
...(entry.strategy ? { strategy: entry.strategy } : {}),
|
|
903
|
+
updatedAt: entry.updatedAt,
|
|
904
|
+
});
|
|
905
|
+
while (routes.size > limit) {
|
|
906
|
+
const oldest = routes.keys().next().value;
|
|
907
|
+
if (oldest === undefined)
|
|
908
|
+
break;
|
|
909
|
+
routes.delete(oldest);
|
|
910
|
+
}
|
|
911
|
+
},
|
|
912
|
+
route(scope) {
|
|
913
|
+
return scope.kind === 'session'
|
|
914
|
+
? (routes.get(scope.sessionID) ?? null)
|
|
915
|
+
: null;
|
|
916
|
+
},
|
|
917
|
+
};
|
|
918
|
+
}
|
|
919
|
+
/** Runs one bridged job through the shared request engine. */
|
|
920
|
+
export function createGaJobExecutor(executor) {
|
|
921
|
+
return (job, context) => executor.execute(job.url, {
|
|
922
|
+
method: 'POST',
|
|
923
|
+
headers: { 'content-type': 'application/json' },
|
|
924
|
+
body: job.body,
|
|
925
|
+
signal: context.signal,
|
|
926
|
+
}, {
|
|
927
|
+
session: {
|
|
928
|
+
sessionId: job.sessionID,
|
|
929
|
+
parentSessionId: job.parentSessionID,
|
|
930
|
+
},
|
|
931
|
+
});
|
|
932
|
+
}
|
|
933
|
+
/**
|
|
934
|
+
* The shared request engine's collaborators that do not depend on where the
|
|
935
|
+
* accounts' credentials live: this location's config, session registry,
|
|
936
|
+
* operator settings, wire, debug log, dump switch and route book, and the
|
|
937
|
+
* AGY transport with the GA raw sender's idle timeout and signal observer.
|
|
938
|
+
*/
|
|
939
|
+
function gaEngineCollaborators(input) {
|
|
940
|
+
const runtime = input.runtime;
|
|
941
|
+
const observe = input.overrides.observeRawSenderSignal;
|
|
942
|
+
return {
|
|
943
|
+
config: runtime.config.config,
|
|
944
|
+
sessions: new AgySessionRegistry(runtime.directory),
|
|
945
|
+
operatorSettings: runtime.operatorSettings,
|
|
946
|
+
transport: (url, init, options) => {
|
|
947
|
+
const transportOptions = {
|
|
948
|
+
...options,
|
|
949
|
+
idleTimeoutMs: options?.idleTimeoutMs ?? GA_TRANSPORT_IDLE_TIMEOUT_MS,
|
|
950
|
+
};
|
|
951
|
+
if (observe && transportOptions.signal) {
|
|
952
|
+
try {
|
|
953
|
+
observe(transportOptions.signal);
|
|
954
|
+
}
|
|
955
|
+
catch {
|
|
956
|
+
// A diagnostic failure must not change or delay the dispatch.
|
|
957
|
+
}
|
|
958
|
+
}
|
|
959
|
+
return fetchWithAgyCliTransport(url, init, transportOptions);
|
|
960
|
+
},
|
|
961
|
+
fetchImpl: (request, init) => fetch(request, init),
|
|
962
|
+
wire: {
|
|
963
|
+
prepare: prepareAntigravityRequest,
|
|
964
|
+
transformResponse: transformAntigravityResponse,
|
|
965
|
+
buildThinkingWarmupBody,
|
|
966
|
+
getImageModelLocalTitle,
|
|
967
|
+
getLastCacheStats,
|
|
968
|
+
},
|
|
969
|
+
debug: runtime.debug,
|
|
970
|
+
dump: runtime.dump,
|
|
971
|
+
logger: input.logger,
|
|
972
|
+
classifyAccessError: extractAccountAccessErrorDetails,
|
|
973
|
+
onRouting: (sessionId, entry) => input.routes.record(sessionId, entry),
|
|
974
|
+
};
|
|
975
|
+
}
|
|
976
|
+
/**
|
|
977
|
+
* The shared request engine over a repository-backed account manager. The
|
|
978
|
+
* engine is the same one OpenCode 1 uses; only its collaborators are this
|
|
979
|
+
* location's.
|
|
980
|
+
*/
|
|
981
|
+
export async function createGaLocalRequestPipeline(input) {
|
|
982
|
+
const runtime = input.runtime;
|
|
983
|
+
await input.assertAdmission?.();
|
|
984
|
+
const manager = await loadAccountManagerFromRepository(input.repository);
|
|
985
|
+
input.accounts.current = manager;
|
|
986
|
+
input.accounts.quotaLogger = runtime.logger.createLogger('quota');
|
|
987
|
+
await runtime.replaceAccounts(manager);
|
|
988
|
+
const logger = runtime.logger.createLogger('request');
|
|
989
|
+
const executor = createRequestExecutor({
|
|
990
|
+
...gaEngineCollaborators({
|
|
991
|
+
runtime,
|
|
992
|
+
overrides: input.overrides,
|
|
993
|
+
routes: input.routes,
|
|
994
|
+
logger,
|
|
995
|
+
}),
|
|
996
|
+
accounts: manager,
|
|
997
|
+
...(input.assertAdmission
|
|
998
|
+
? { assertAdmission: input.assertAdmission }
|
|
999
|
+
: {}),
|
|
1000
|
+
credentials: createGaLocalCredentials(manager, {
|
|
1001
|
+
repository: input.repository,
|
|
1002
|
+
overrides: input.overrides,
|
|
1003
|
+
refreshQuotaAfterSuccess: createLocalQuotaRefresh(manager, runtime.quotaManager, logger),
|
|
1004
|
+
}),
|
|
1005
|
+
// The trackers the manager selects with, so recorded outcomes steer
|
|
1006
|
+
// the next selection.
|
|
1007
|
+
trackers: {
|
|
1008
|
+
health: manager.healthTracker,
|
|
1009
|
+
token: manager.tokenTracker,
|
|
1010
|
+
},
|
|
1011
|
+
});
|
|
1012
|
+
// Local custody: the same store quota service the OpenCode 1 menu uses,
|
|
1013
|
+
// over this activation's manager and repository.
|
|
1014
|
+
const quotaFetch = input.overrides.quotaFetch;
|
|
1015
|
+
const storeQuota = createStoreQuotaService({
|
|
1016
|
+
manager,
|
|
1017
|
+
repository: input.repository,
|
|
1018
|
+
...(input.assertAdmission
|
|
1019
|
+
? {
|
|
1020
|
+
mayRun: async () => {
|
|
1021
|
+
await input.assertAdmission?.();
|
|
1022
|
+
return true;
|
|
1023
|
+
},
|
|
1024
|
+
}
|
|
1025
|
+
: {}),
|
|
1026
|
+
logger: runtime.logger.createLogger('store-quota'),
|
|
1027
|
+
...(quotaFetch ? { transport: () => quotaFetch } : {}),
|
|
1028
|
+
});
|
|
1029
|
+
return {
|
|
1030
|
+
execute: createGaJobExecutor(executor),
|
|
1031
|
+
refreshQuota: (refs) => storeQuota.checkStoreQuota(refs),
|
|
1032
|
+
refreshAccounts: () => manager.refreshFromRepository(),
|
|
1033
|
+
async dispose() {
|
|
1034
|
+
await executor.dispose();
|
|
1035
|
+
await storeQuota.dispose();
|
|
1036
|
+
if (input.accounts.current === manager) {
|
|
1037
|
+
input.accounts.current = null;
|
|
1038
|
+
input.accounts.quotaLogger = null;
|
|
1039
|
+
}
|
|
1040
|
+
await runtime.replaceAccounts(null);
|
|
1041
|
+
await manager.dispose();
|
|
1042
|
+
},
|
|
1043
|
+
};
|
|
1044
|
+
}
|
|
1045
|
+
/**
|
|
1046
|
+
* The shared request engine for a location whose accounts are held by the
|
|
1047
|
+
* vault. Selection runs on the shared `AccountSelector` over the vault's
|
|
1048
|
+
* selectable routes (metadata rows, no credential); every physical send
|
|
1049
|
+
* takes a fresh receipt for the selected route through
|
|
1050
|
+
* `createVaultRequestCredentials`. Nothing is refreshed or cached locally.
|
|
1051
|
+
* `refreshAccounts` re-reads the vault roster and keeps each route's
|
|
1052
|
+
* selection state while its route, credential and asserted account stay
|
|
1053
|
+
* the same. With `state`, a route's selection state is restored from and
|
|
1054
|
+
* saved to the vault's provider-state file, attributed to the receipt that
|
|
1055
|
+
* last served it.
|
|
1056
|
+
*/
|
|
1057
|
+
export async function createGaVaultRequestPipeline(input) {
|
|
1058
|
+
const { pool } = input;
|
|
1059
|
+
await input.assertAdmission?.();
|
|
1060
|
+
await pool.sync();
|
|
1061
|
+
const logger = input.runtime.logger.createLogger('request');
|
|
1062
|
+
const executor = createRequestExecutor({
|
|
1063
|
+
...gaEngineCollaborators({
|
|
1064
|
+
runtime: input.runtime,
|
|
1065
|
+
overrides: input.overrides,
|
|
1066
|
+
routes: input.routes,
|
|
1067
|
+
logger,
|
|
1068
|
+
}),
|
|
1069
|
+
accounts: pool.selector,
|
|
1070
|
+
...(input.assertAdmission
|
|
1071
|
+
? { assertAdmission: input.assertAdmission }
|
|
1072
|
+
: {}),
|
|
1073
|
+
credentials: pool.credentials,
|
|
1074
|
+
trackers: {
|
|
1075
|
+
health: pool.selector.healthTracker,
|
|
1076
|
+
token: pool.selector.tokenTracker,
|
|
1077
|
+
},
|
|
1078
|
+
});
|
|
1079
|
+
return {
|
|
1080
|
+
execute: async (job, context) => {
|
|
1081
|
+
await input.assertAdmission?.();
|
|
1082
|
+
await pool.sync();
|
|
1083
|
+
return createGaJobExecutor(executor)(job, context);
|
|
1084
|
+
},
|
|
1085
|
+
rows: () => pool.selector.rows,
|
|
1086
|
+
refreshAccounts: async () => {
|
|
1087
|
+
await input.assertAdmission?.();
|
|
1088
|
+
await pool.refresh();
|
|
1089
|
+
},
|
|
1090
|
+
async dispose() {
|
|
1091
|
+
await executor.dispose();
|
|
1092
|
+
await pool.flush();
|
|
1093
|
+
},
|
|
1094
|
+
};
|
|
1095
|
+
}
|
|
1096
|
+
// ---------------------------------------------------------------------------
|
|
1097
|
+
// Vault custody location
|
|
1098
|
+
// ---------------------------------------------------------------------------
|
|
1099
|
+
/**
|
|
1100
|
+
* Opaque item and state selectors for vault routes, one per route,
|
|
1101
|
+
* credential and asserted account for the life of the activation.
|
|
1102
|
+
*/
|
|
1103
|
+
function vaultSelectors(createSelector) {
|
|
1104
|
+
const byKey = new Map();
|
|
1105
|
+
return (row) => {
|
|
1106
|
+
const key = vaultAccountRowKey(row);
|
|
1107
|
+
let selector = byKey.get(key);
|
|
1108
|
+
if (selector === undefined) {
|
|
1109
|
+
selector = createSelector();
|
|
1110
|
+
byKey.set(key, selector);
|
|
1111
|
+
}
|
|
1112
|
+
return selector;
|
|
1113
|
+
};
|
|
1114
|
+
}
|
|
1115
|
+
/**
|
|
1116
|
+
* The `state` source of a vault custody location: the vault's selectable
|
|
1117
|
+
* accounts as redaction rows with opaque selectors, read one at a time.
|
|
1118
|
+
* Vault rows carry no metadata or access blocks of this plugin's own.
|
|
1119
|
+
*/
|
|
1120
|
+
function createGaVaultStateSource(input) {
|
|
1121
|
+
let readSeq = 0;
|
|
1122
|
+
let queue = Promise.resolve();
|
|
1123
|
+
const readOnce = async (scope, signal) => {
|
|
1124
|
+
if (signal.aborted)
|
|
1125
|
+
throw abortError(signal);
|
|
1126
|
+
const rows = input.rows();
|
|
1127
|
+
const settings = input.settings();
|
|
1128
|
+
const route = input.route(scope);
|
|
1129
|
+
if (signal.aborted)
|
|
1130
|
+
throw abortError(signal);
|
|
1131
|
+
readSeq = input.nextReadSeq?.() ?? readSeq + 1;
|
|
1132
|
+
const overLimit = rows.length > ACCOUNT_LIMIT;
|
|
1133
|
+
const answer = {
|
|
1134
|
+
readSeq,
|
|
1135
|
+
accounts: overLimit
|
|
1136
|
+
? { kind: 'over-limit', count: rows.length }
|
|
1137
|
+
: {
|
|
1138
|
+
kind: 'complete',
|
|
1139
|
+
rows: rows.map((row, position) => ({
|
|
1140
|
+
selector: input.selectorOf(row),
|
|
1141
|
+
row: {
|
|
1142
|
+
index: position,
|
|
1143
|
+
enabled: row.enabled,
|
|
1144
|
+
current: false,
|
|
1145
|
+
...(row.coolingDownUntil !== undefined
|
|
1146
|
+
? { coolingDownUntil: row.coolingDownUntil }
|
|
1147
|
+
: {}),
|
|
1148
|
+
...(row.cachedQuota !== undefined
|
|
1149
|
+
? { cachedQuota: row.cachedQuota }
|
|
1150
|
+
: {}),
|
|
1151
|
+
},
|
|
1152
|
+
})),
|
|
1153
|
+
},
|
|
1154
|
+
route,
|
|
1155
|
+
status: {
|
|
1156
|
+
checkedAt: null,
|
|
1157
|
+
quotaBackoffUntil: null,
|
|
1158
|
+
routingAuthoritative: true,
|
|
1159
|
+
},
|
|
1160
|
+
settings,
|
|
1161
|
+
};
|
|
1162
|
+
if (input.observe) {
|
|
1163
|
+
try {
|
|
1164
|
+
input.observe({
|
|
1165
|
+
generation: input.generation,
|
|
1166
|
+
readSeq,
|
|
1167
|
+
status: 'ready',
|
|
1168
|
+
accountsStatus: overLimit ? 'over-limit' : 'complete',
|
|
1169
|
+
accounts: overLimit
|
|
1170
|
+
? []
|
|
1171
|
+
: rows.map((row, position) => ({
|
|
1172
|
+
selector: input.selectorOf(row),
|
|
1173
|
+
position,
|
|
1174
|
+
enabled: row.enabled,
|
|
1175
|
+
usable: row.enabled,
|
|
1176
|
+
metadataStatus: 'absent',
|
|
1177
|
+
accessBlock: { kind: 'unknown' },
|
|
1178
|
+
currentFor: [],
|
|
1179
|
+
cooldownUntil: row.coolingDownUntil ?? null,
|
|
1180
|
+
})),
|
|
1181
|
+
retiredSelectors: [],
|
|
1182
|
+
});
|
|
1183
|
+
}
|
|
1184
|
+
catch {
|
|
1185
|
+
// A diagnostic observer cannot change the answer.
|
|
1186
|
+
}
|
|
1187
|
+
}
|
|
1188
|
+
return answer;
|
|
1189
|
+
};
|
|
1190
|
+
return {
|
|
1191
|
+
read({ scope, signal }) {
|
|
1192
|
+
const next = queue.then(() => readOnce(scope, signal), () => readOnce(scope, signal));
|
|
1193
|
+
queue = next.catch(() => undefined);
|
|
1194
|
+
return next;
|
|
1195
|
+
},
|
|
1196
|
+
};
|
|
1197
|
+
}
|
|
1198
|
+
/**
|
|
1199
|
+
* A GA location whose accounts are held by the vault. No local account
|
|
1200
|
+
* store is opened. Saved Google logins stay dormant on disk. The vault
|
|
1201
|
+
* source is taken from custody, and requests go through
|
|
1202
|
+
* `createGaVaultRequestPipeline`, and the menu shows the vault's accounts,
|
|
1203
|
+
* this location's settings and the Vault section. The runtime keeps quota
|
|
1204
|
+
* snapshots in memory; it gets no account view, so its quota poller and
|
|
1205
|
+
* token refresh queue do not run for vault accounts.
|
|
1206
|
+
*/
|
|
1207
|
+
async function createGaVaultLocationServices(input) {
|
|
1208
|
+
const { custody, overrides } = input;
|
|
1209
|
+
await input.assertAdmission?.();
|
|
1210
|
+
const source = await custody.custodySource();
|
|
1211
|
+
const selectorOf = vaultSelectors(input.bindings.createSelector ?? defaultSelector);
|
|
1212
|
+
let pipeline = null;
|
|
1213
|
+
let disposed = null;
|
|
1214
|
+
return {
|
|
1215
|
+
runtime: {
|
|
1216
|
+
quotaSnapshots: createMemoryQuotaSnapshots(),
|
|
1217
|
+
// Never called: the runtime is given no account view for vault rows,
|
|
1218
|
+
// so neither its quota poller nor its refresh queue runs.
|
|
1219
|
+
fetchAccountQuota: async (account) => ({
|
|
1220
|
+
index: 0,
|
|
1221
|
+
email: account.email,
|
|
1222
|
+
status: 'error',
|
|
1223
|
+
disabled: false,
|
|
1224
|
+
error: 'vault accounts are not checked by this location',
|
|
1225
|
+
}),
|
|
1226
|
+
refreshToken: async () => undefined,
|
|
1227
|
+
},
|
|
1228
|
+
async start(start) {
|
|
1229
|
+
if (disposed)
|
|
1230
|
+
throw new Error('The location services are disposed');
|
|
1231
|
+
const location = start.runtime;
|
|
1232
|
+
const routes = createGaRouteBook();
|
|
1233
|
+
const vaultLogger = location.logger.createLogger('vault-state');
|
|
1234
|
+
const pool = createVaultAccountPool({
|
|
1235
|
+
source,
|
|
1236
|
+
durable: {
|
|
1237
|
+
source,
|
|
1238
|
+
readState: () => custody.readState(),
|
|
1239
|
+
onError: (error) => vaultLogger.debug('vault-state-write-dropped', {
|
|
1240
|
+
error: error instanceof Error ? error.name : 'unknown',
|
|
1241
|
+
}),
|
|
1242
|
+
},
|
|
1243
|
+
});
|
|
1244
|
+
pipeline = await createGaVaultRequestPipeline({
|
|
1245
|
+
...(input.assertAdmission
|
|
1246
|
+
? { assertAdmission: input.assertAdmission }
|
|
1247
|
+
: {}),
|
|
1248
|
+
pool,
|
|
1249
|
+
runtime: location,
|
|
1250
|
+
overrides,
|
|
1251
|
+
routes,
|
|
1252
|
+
});
|
|
1253
|
+
const fetchVaultQuota = input.bindings.fetchVaultQuota;
|
|
1254
|
+
const quotaLogger = location.logger.createLogger('vault-quota');
|
|
1255
|
+
const checkQuota = fetchVaultQuota
|
|
1256
|
+
? (signal) => checkVaultQuota({
|
|
1257
|
+
pool,
|
|
1258
|
+
fetchReading: async (ref, check) => {
|
|
1259
|
+
await input.assertAdmission?.();
|
|
1260
|
+
return fetchVaultQuota({
|
|
1261
|
+
source,
|
|
1262
|
+
ref,
|
|
1263
|
+
signal: check,
|
|
1264
|
+
logger: quotaLogger,
|
|
1265
|
+
...(overrides.quotaFetch
|
|
1266
|
+
? { transport: overrides.quotaFetch }
|
|
1267
|
+
: {}),
|
|
1268
|
+
});
|
|
1269
|
+
},
|
|
1270
|
+
signal,
|
|
1271
|
+
onError: (error) => quotaLogger.debug('vault-quota-not-recorded', {
|
|
1272
|
+
error: error instanceof Error ? error.name : 'unknown',
|
|
1273
|
+
}),
|
|
1274
|
+
})
|
|
1275
|
+
: undefined;
|
|
1276
|
+
const started = pipeline;
|
|
1277
|
+
const settings = operatorMenuSettings(location.operatorSettings);
|
|
1278
|
+
const menu = createAntigravityCommandMenu({
|
|
1279
|
+
source: 'sections',
|
|
1280
|
+
commands: await loadCommonAuthCommands(),
|
|
1281
|
+
sections: {
|
|
1282
|
+
...createVaultAccountMenuSections(pool, selectorOf, checkQuota),
|
|
1283
|
+
...antigravitySettingsSections(settings),
|
|
1284
|
+
},
|
|
1285
|
+
diagnostics: diagnosticsMenuSection({
|
|
1286
|
+
settings: location.operatorSettings,
|
|
1287
|
+
dump: location.dump,
|
|
1288
|
+
applyLogLevel: () => location.applyOperatorSettings(),
|
|
1289
|
+
}),
|
|
1290
|
+
extras: [custody.menuSection()],
|
|
1291
|
+
});
|
|
1292
|
+
input.bindRefresh?.(() => started.refreshAccounts());
|
|
1293
|
+
return {
|
|
1294
|
+
execute: started.execute,
|
|
1295
|
+
state: createGaVaultStateSource({
|
|
1296
|
+
rows: () => started.rows(),
|
|
1297
|
+
selectorOf,
|
|
1298
|
+
...(input.nextReadSeq ? { nextReadSeq: input.nextReadSeq } : {}),
|
|
1299
|
+
generation: start.generation,
|
|
1300
|
+
settings: () => gaSettingsOf(location.operatorSettings.get(), location.dump),
|
|
1301
|
+
route: (scope) => routes.route(scope),
|
|
1302
|
+
...(overrides.observeAccountSnapshot
|
|
1303
|
+
? { observe: overrides.observeAccountSnapshot }
|
|
1304
|
+
: {}),
|
|
1305
|
+
}),
|
|
1306
|
+
commands: createGaMenuCommandService({
|
|
1307
|
+
menu,
|
|
1308
|
+
notify: start.notify,
|
|
1309
|
+
afterApply: () => input.afterApply ? input.afterApply() : started.refreshAccounts(),
|
|
1310
|
+
}),
|
|
1311
|
+
};
|
|
1312
|
+
},
|
|
1313
|
+
dispose() {
|
|
1314
|
+
disposed ??= (async () => {
|
|
1315
|
+
const active = pipeline;
|
|
1316
|
+
pipeline = null;
|
|
1317
|
+
input.bindRefresh?.(undefined);
|
|
1318
|
+
if (active)
|
|
1319
|
+
await active.dispose();
|
|
1320
|
+
})();
|
|
1321
|
+
return disposed;
|
|
1322
|
+
},
|
|
1323
|
+
};
|
|
1324
|
+
}
|
|
1325
|
+
export function createGaLocationServicesFactory(bindings) {
|
|
1326
|
+
return async ({ directory, overrides }) => {
|
|
1327
|
+
const custody = bindings.custody?.({
|
|
1328
|
+
accountFile: bindings.resolveAccountFile(directory),
|
|
1329
|
+
overrides,
|
|
1330
|
+
});
|
|
1331
|
+
let closing = false;
|
|
1332
|
+
let started = false;
|
|
1333
|
+
let disposal;
|
|
1334
|
+
// Enrollment selects a binding, not its lifetime. Local files stay unopened
|
|
1335
|
+
// until a locally authorized operation needs them, and failures can retry.
|
|
1336
|
+
let repositoryPromise;
|
|
1337
|
+
let servingRepository;
|
|
1338
|
+
let localPromise;
|
|
1339
|
+
let vaultPromise;
|
|
1340
|
+
let vaultServices;
|
|
1341
|
+
let localPipeline;
|
|
1342
|
+
let reauthorize;
|
|
1343
|
+
let readSeq = 0;
|
|
1344
|
+
const inFlight = new Set();
|
|
1345
|
+
const run = (work) => {
|
|
1346
|
+
if (closing)
|
|
1347
|
+
return Promise.reject(new Error('The location services are disposed'));
|
|
1348
|
+
const pending = Promise.resolve().then(work);
|
|
1349
|
+
inFlight.add(pending);
|
|
1350
|
+
void pending.then(() => inFlight.delete(pending), () => inFlight.delete(pending));
|
|
1351
|
+
return pending;
|
|
1352
|
+
};
|
|
1353
|
+
const nextReadSeq = () => ++readSeq;
|
|
1354
|
+
const registry = createGaSelectorRegistry(bindings.createSelector);
|
|
1355
|
+
const authority = async () => {
|
|
1356
|
+
if (!custody)
|
|
1357
|
+
return 'local';
|
|
1358
|
+
const mode = await custody.readMode();
|
|
1359
|
+
return mode.ok
|
|
1360
|
+
? mode.record.mode === 'custody'
|
|
1361
|
+
? 'vault'
|
|
1362
|
+
: 'local'
|
|
1363
|
+
: 'unreadable';
|
|
1364
|
+
};
|
|
1365
|
+
const assertLocal = async () => {
|
|
1366
|
+
if (closing)
|
|
1367
|
+
throw new Error('The location services are disposed');
|
|
1368
|
+
const selected = await authority();
|
|
1369
|
+
if (closing)
|
|
1370
|
+
throw new Error('The location services are disposed');
|
|
1371
|
+
if (selected !== 'local')
|
|
1372
|
+
throw new Error(VAULT_ACCOUNT_REMEDY);
|
|
1373
|
+
};
|
|
1374
|
+
let refreshVaultBinding;
|
|
1375
|
+
const refreshSelectedSource = async () => {
|
|
1376
|
+
const selected = await authority();
|
|
1377
|
+
if (closing)
|
|
1378
|
+
throw new Error('The location services are disposed');
|
|
1379
|
+
if (selected === 'unreadable')
|
|
1380
|
+
throw new Error(VAULT_ACCOUNT_REMEDY);
|
|
1381
|
+
// A menu action may change sources. Refresh only the newly selected
|
|
1382
|
+
// account view, keeping both runtime bindings and their generation intact.
|
|
1383
|
+
if (selected === 'local') {
|
|
1384
|
+
await assertLocal();
|
|
1385
|
+
await localPipeline?.refreshAccounts();
|
|
1386
|
+
}
|
|
1387
|
+
else {
|
|
1388
|
+
if (vaultPromise)
|
|
1389
|
+
await vaultPromise;
|
|
1390
|
+
await refreshVaultBinding?.();
|
|
1391
|
+
}
|
|
1392
|
+
};
|
|
1393
|
+
const getRepository = async () => {
|
|
1394
|
+
await assertLocal();
|
|
1395
|
+
repositoryPromise ??= openLocationRepository(directory, bindings, overrides).catch((error) => {
|
|
1396
|
+
repositoryPromise = undefined;
|
|
1397
|
+
throw error;
|
|
1398
|
+
});
|
|
1399
|
+
const repository = (await repositoryPromise).repository;
|
|
1400
|
+
if (!servingRepository) {
|
|
1401
|
+
const methods = new Map();
|
|
1402
|
+
const pendingAdmissions = new Set();
|
|
1403
|
+
const refusedWrites = [];
|
|
1404
|
+
servingRepository = new Proxy(repository, {
|
|
1405
|
+
get(target, key) {
|
|
1406
|
+
const value = Reflect.get(target, key, target);
|
|
1407
|
+
if (typeof value !== 'function')
|
|
1408
|
+
return value;
|
|
1409
|
+
if (!methods.has(key)) {
|
|
1410
|
+
methods.set(key, (...args) => {
|
|
1411
|
+
if (key === 'flush' || key === 'settled' || key === 'dispose') {
|
|
1412
|
+
return (async () => {
|
|
1413
|
+
// Calls still awaiting the local-source check have not entered
|
|
1414
|
+
// the repository's queue. Wait for them before flushing it.
|
|
1415
|
+
await Promise.allSettled([...pendingAdmissions]);
|
|
1416
|
+
const result = await Reflect.apply(value, target, args);
|
|
1417
|
+
if (key !== 'settled' && refusedWrites.length > 0) {
|
|
1418
|
+
const failures = refusedWrites.splice(0);
|
|
1419
|
+
throw new AggregateError(failures, 'Local writes were refused by source authority');
|
|
1420
|
+
}
|
|
1421
|
+
return result;
|
|
1422
|
+
})();
|
|
1423
|
+
}
|
|
1424
|
+
const pending = (async () => {
|
|
1425
|
+
// A refresh that passed the local-source check saves its new
|
|
1426
|
+
// credentials inside this call. Later operations check again.
|
|
1427
|
+
try {
|
|
1428
|
+
await assertLocal();
|
|
1429
|
+
}
|
|
1430
|
+
catch (error) {
|
|
1431
|
+
if (key !== 'read')
|
|
1432
|
+
refusedWrites.push(error);
|
|
1433
|
+
throw error;
|
|
1434
|
+
}
|
|
1435
|
+
return Reflect.apply(value, target, args);
|
|
1436
|
+
})();
|
|
1437
|
+
pendingAdmissions.add(pending);
|
|
1438
|
+
void pending.then(() => pendingAdmissions.delete(pending), () => pendingAdmissions.delete(pending));
|
|
1439
|
+
return pending;
|
|
1440
|
+
});
|
|
1441
|
+
}
|
|
1442
|
+
return methods.get(key);
|
|
1443
|
+
},
|
|
1444
|
+
});
|
|
1445
|
+
}
|
|
1446
|
+
return servingRepository;
|
|
1447
|
+
};
|
|
1448
|
+
let runtime;
|
|
1449
|
+
try {
|
|
1450
|
+
const collaborators = bindings.runtime({
|
|
1451
|
+
directory,
|
|
1452
|
+
getRepository,
|
|
1453
|
+
assertAdmission: assertLocal,
|
|
1454
|
+
overrides,
|
|
1455
|
+
});
|
|
1456
|
+
const previousMayRun = collaborators.mayRun;
|
|
1457
|
+
runtime = {
|
|
1458
|
+
...collaborators,
|
|
1459
|
+
mayRun: async () => !closing &&
|
|
1460
|
+
(await authority()) === 'local' &&
|
|
1461
|
+
(!previousMayRun || (await previousMayRun())),
|
|
1462
|
+
};
|
|
1463
|
+
}
|
|
1464
|
+
catch (error) {
|
|
1465
|
+
await custody?.dispose().catch(() => { });
|
|
1466
|
+
throw error;
|
|
1467
|
+
}
|
|
1468
|
+
return {
|
|
1469
|
+
runtime,
|
|
1470
|
+
async start(input) {
|
|
1471
|
+
if (closing)
|
|
1472
|
+
throw new Error('The location services are disposed');
|
|
1473
|
+
if (started)
|
|
1474
|
+
throw new Error('The location services already started');
|
|
1475
|
+
started = true;
|
|
1476
|
+
const location = input.runtime;
|
|
1477
|
+
const settings = operatorMenuSettings(location.operatorSettings);
|
|
1478
|
+
const recoveryMenu = createAntigravityCommandMenu({
|
|
1479
|
+
source: 'sections',
|
|
1480
|
+
commands: await loadCommonAuthCommands(),
|
|
1481
|
+
sections: {
|
|
1482
|
+
accounts: {
|
|
1483
|
+
title: 'Accounts',
|
|
1484
|
+
build: async () => ({
|
|
1485
|
+
lines: [
|
|
1486
|
+
'Account access is unavailable. Open Vault to inspect or recover enrollment.',
|
|
1487
|
+
],
|
|
1488
|
+
items: [],
|
|
1489
|
+
actions: [],
|
|
1490
|
+
}),
|
|
1491
|
+
},
|
|
1492
|
+
quota: {
|
|
1493
|
+
title: 'Quota',
|
|
1494
|
+
build: async () => ({
|
|
1495
|
+
lines: ['No quota reading is available.'],
|
|
1496
|
+
items: [],
|
|
1497
|
+
actions: [],
|
|
1498
|
+
}),
|
|
1499
|
+
},
|
|
1500
|
+
...antigravitySettingsSections(settings),
|
|
1501
|
+
},
|
|
1502
|
+
diagnostics: diagnosticsMenuSection({
|
|
1503
|
+
settings: location.operatorSettings,
|
|
1504
|
+
dump: location.dump,
|
|
1505
|
+
applyLogLevel: () => location.applyOperatorSettings(),
|
|
1506
|
+
}),
|
|
1507
|
+
...(custody ? { extras: [custody.menuSection()] } : {}),
|
|
1508
|
+
});
|
|
1509
|
+
const recovery = {
|
|
1510
|
+
execute: async () => {
|
|
1511
|
+
throw new Error(VAULT_ACCOUNT_REMEDY);
|
|
1512
|
+
},
|
|
1513
|
+
state: {
|
|
1514
|
+
read: async ({ signal }) => {
|
|
1515
|
+
if (signal.aborted)
|
|
1516
|
+
throw abortError(signal);
|
|
1517
|
+
return {
|
|
1518
|
+
readSeq: nextReadSeq(),
|
|
1519
|
+
accounts: { kind: 'complete', rows: [] },
|
|
1520
|
+
route: null,
|
|
1521
|
+
status: {
|
|
1522
|
+
checkedAt: null,
|
|
1523
|
+
quotaBackoffUntil: null,
|
|
1524
|
+
routingAuthoritative: false,
|
|
1525
|
+
},
|
|
1526
|
+
settings: gaSettingsOf(location.operatorSettings.get(), location.dump),
|
|
1527
|
+
};
|
|
1528
|
+
},
|
|
1529
|
+
},
|
|
1530
|
+
commands: createGaMenuCommandService({
|
|
1531
|
+
menu: recoveryMenu,
|
|
1532
|
+
notify: input.notify,
|
|
1533
|
+
}),
|
|
1534
|
+
};
|
|
1535
|
+
const local = () => {
|
|
1536
|
+
localPromise ??= (async () => {
|
|
1537
|
+
const repository = await getRepository();
|
|
1538
|
+
const opened = await repositoryPromise;
|
|
1539
|
+
if (!opened)
|
|
1540
|
+
throw new Error('The local repository was not constructed');
|
|
1541
|
+
await assertServingAdmission(opened, bindings.now);
|
|
1542
|
+
await assertLocal();
|
|
1543
|
+
let pipeline;
|
|
1544
|
+
let pendingReauthorization;
|
|
1545
|
+
try {
|
|
1546
|
+
const routes = createGaRouteBook();
|
|
1547
|
+
pipeline = await bindings.createPipeline({
|
|
1548
|
+
repository,
|
|
1549
|
+
runtime: location,
|
|
1550
|
+
send: input.send,
|
|
1551
|
+
generation: input.generation,
|
|
1552
|
+
overrides,
|
|
1553
|
+
routes,
|
|
1554
|
+
assertAdmission: assertLocal,
|
|
1555
|
+
});
|
|
1556
|
+
const started = pipeline;
|
|
1557
|
+
const refreshAccounts = async () => {
|
|
1558
|
+
await assertLocal();
|
|
1559
|
+
await started.refreshAccounts();
|
|
1560
|
+
};
|
|
1561
|
+
pendingReauthorization = createGaReauthorize({
|
|
1562
|
+
repository,
|
|
1563
|
+
assertAdmission: assertLocal,
|
|
1564
|
+
overrides,
|
|
1565
|
+
afterChange: refreshAccounts,
|
|
1566
|
+
});
|
|
1567
|
+
const checkQuota = started.refreshQuota;
|
|
1568
|
+
const menu = createGaLocationMenu({
|
|
1569
|
+
commands: await loadCommonAuthCommands(),
|
|
1570
|
+
repository,
|
|
1571
|
+
runtime: location,
|
|
1572
|
+
reauthorize: pendingReauthorization,
|
|
1573
|
+
...(custody ? { vault: custody.menuSection() } : {}),
|
|
1574
|
+
...(checkQuota
|
|
1575
|
+
? {
|
|
1576
|
+
refreshQuota: async (refs) => {
|
|
1577
|
+
await assertLocal();
|
|
1578
|
+
return checkQuota(refs);
|
|
1579
|
+
},
|
|
1580
|
+
}
|
|
1581
|
+
: {}),
|
|
1582
|
+
});
|
|
1583
|
+
localPipeline = started;
|
|
1584
|
+
reauthorize = pendingReauthorization;
|
|
1585
|
+
return {
|
|
1586
|
+
state: createGaAccountStateSource({
|
|
1587
|
+
repository,
|
|
1588
|
+
registry,
|
|
1589
|
+
generation: input.generation,
|
|
1590
|
+
nextReadSeq,
|
|
1591
|
+
settings: () => gaSettingsOf(location.operatorSettings.get(), location.dump),
|
|
1592
|
+
status: () => ({
|
|
1593
|
+
checkedAt: null,
|
|
1594
|
+
quotaBackoffUntil: null,
|
|
1595
|
+
routingAuthoritative: true,
|
|
1596
|
+
}),
|
|
1597
|
+
route: (scope) => routes.route(scope),
|
|
1598
|
+
...(overrides.observeAccountSnapshot
|
|
1599
|
+
? { observe: overrides.observeAccountSnapshot }
|
|
1600
|
+
: {}),
|
|
1601
|
+
}),
|
|
1602
|
+
commands: createGaMenuCommandService({
|
|
1603
|
+
menu,
|
|
1604
|
+
notify: input.notify,
|
|
1605
|
+
afterApply: () => refreshSelectedSource(),
|
|
1606
|
+
}),
|
|
1607
|
+
execute: started.execute,
|
|
1608
|
+
};
|
|
1609
|
+
}
|
|
1610
|
+
catch (error) {
|
|
1611
|
+
await pendingReauthorization?.dispose().catch(() => { });
|
|
1612
|
+
await pipeline?.dispose().catch(() => { });
|
|
1613
|
+
await location.replaceAccounts(null).catch(() => { });
|
|
1614
|
+
throw error;
|
|
1615
|
+
}
|
|
1616
|
+
})().catch((error) => {
|
|
1617
|
+
localPromise = undefined;
|
|
1618
|
+
throw error;
|
|
1619
|
+
});
|
|
1620
|
+
return localPromise;
|
|
1621
|
+
};
|
|
1622
|
+
const vault = () => {
|
|
1623
|
+
if (!custody)
|
|
1624
|
+
return Promise.reject(new Error('Vault custody is unavailable'));
|
|
1625
|
+
vaultPromise ??= (async () => {
|
|
1626
|
+
const created = await createGaVaultLocationServices({
|
|
1627
|
+
custody,
|
|
1628
|
+
overrides,
|
|
1629
|
+
bindings,
|
|
1630
|
+
nextReadSeq,
|
|
1631
|
+
afterApply: refreshSelectedSource,
|
|
1632
|
+
bindRefresh: (refresh) => {
|
|
1633
|
+
refreshVaultBinding = refresh;
|
|
1634
|
+
},
|
|
1635
|
+
assertAdmission: async () => {
|
|
1636
|
+
const selected = await authority();
|
|
1637
|
+
if (closing || selected !== 'vault')
|
|
1638
|
+
throw new Error(VAULT_ACCOUNT_REMEDY);
|
|
1639
|
+
},
|
|
1640
|
+
});
|
|
1641
|
+
try {
|
|
1642
|
+
const serving = await created.start(input);
|
|
1643
|
+
vaultServices = created;
|
|
1644
|
+
return serving;
|
|
1645
|
+
}
|
|
1646
|
+
catch (error) {
|
|
1647
|
+
await created.dispose().catch(() => { });
|
|
1648
|
+
throw error;
|
|
1649
|
+
}
|
|
1650
|
+
})().catch((error) => {
|
|
1651
|
+
vaultPromise = undefined;
|
|
1652
|
+
throw error;
|
|
1653
|
+
});
|
|
1654
|
+
return vaultPromise;
|
|
1655
|
+
};
|
|
1656
|
+
const choose = async (purpose) => {
|
|
1657
|
+
if (closing)
|
|
1658
|
+
throw new Error('The location services are disposed');
|
|
1659
|
+
const selected = await authority();
|
|
1660
|
+
if (closing)
|
|
1661
|
+
throw new Error('The location services are disposed');
|
|
1662
|
+
if (selected === 'local')
|
|
1663
|
+
return local();
|
|
1664
|
+
if (selected === 'unreadable') {
|
|
1665
|
+
if (purpose === 'execute')
|
|
1666
|
+
throw new Error(VAULT_ACCOUNT_REMEDY);
|
|
1667
|
+
return recovery;
|
|
1668
|
+
}
|
|
1669
|
+
try {
|
|
1670
|
+
return await vault();
|
|
1671
|
+
}
|
|
1672
|
+
catch (error) {
|
|
1673
|
+
if (purpose === 'execute')
|
|
1674
|
+
throw error;
|
|
1675
|
+
return recovery;
|
|
1676
|
+
}
|
|
1677
|
+
};
|
|
1678
|
+
let reads = Promise.resolve();
|
|
1679
|
+
return {
|
|
1680
|
+
execute: (job, context) => run(async () => {
|
|
1681
|
+
if (context.signal.aborted)
|
|
1682
|
+
throw context.signal.reason;
|
|
1683
|
+
return (await choose('execute')).execute(job, context);
|
|
1684
|
+
}),
|
|
1685
|
+
commands: {
|
|
1686
|
+
apply: (request) => run(async () => {
|
|
1687
|
+
if (request.signal.aborted)
|
|
1688
|
+
throw request.signal.reason;
|
|
1689
|
+
return (await choose('view')).commands.apply(request);
|
|
1690
|
+
}),
|
|
1691
|
+
open: (request) => run(async () => {
|
|
1692
|
+
if (request.signal.aborted)
|
|
1693
|
+
throw request.signal.reason;
|
|
1694
|
+
return (await choose('view')).commands.open(request);
|
|
1695
|
+
}),
|
|
1696
|
+
},
|
|
1697
|
+
state: {
|
|
1698
|
+
read(request) {
|
|
1699
|
+
return run(() => {
|
|
1700
|
+
const pending = reads.then(async () => {
|
|
1701
|
+
if (closing)
|
|
1702
|
+
throw new Error('The location services are disposed');
|
|
1703
|
+
if (request.signal.aborted)
|
|
1704
|
+
throw request.signal.reason;
|
|
1705
|
+
for (let attempt = 0; attempt < 2; attempt++) {
|
|
1706
|
+
const before = await authority();
|
|
1707
|
+
const answer = await (await choose('view')).state.read(request);
|
|
1708
|
+
if (before === (await authority()))
|
|
1709
|
+
return answer;
|
|
1710
|
+
}
|
|
1711
|
+
throw new Error('Account authority changed while reading state');
|
|
1712
|
+
});
|
|
1713
|
+
reads = pending.catch(() => undefined);
|
|
1714
|
+
return pending;
|
|
1715
|
+
});
|
|
1716
|
+
},
|
|
1717
|
+
},
|
|
1718
|
+
};
|
|
1719
|
+
},
|
|
1720
|
+
dispose() {
|
|
1721
|
+
closing = true;
|
|
1722
|
+
disposal ??= (async () => {
|
|
1723
|
+
await Promise.allSettled([
|
|
1724
|
+
localPromise,
|
|
1725
|
+
vaultPromise,
|
|
1726
|
+
repositoryPromise,
|
|
1727
|
+
]);
|
|
1728
|
+
try {
|
|
1729
|
+
const resources = Promise.allSettled([
|
|
1730
|
+
reauthorize?.dispose(),
|
|
1731
|
+
localPipeline?.dispose(),
|
|
1732
|
+
vaultServices?.dispose(),
|
|
1733
|
+
]);
|
|
1734
|
+
await Promise.allSettled([...inFlight]);
|
|
1735
|
+
const results = await resources;
|
|
1736
|
+
while (inFlight.size > 0)
|
|
1737
|
+
await Promise.allSettled([...inFlight]);
|
|
1738
|
+
const failure = results.find((result) => result.status === 'rejected');
|
|
1739
|
+
if (failure?.status === 'rejected')
|
|
1740
|
+
throw failure.reason;
|
|
1741
|
+
}
|
|
1742
|
+
finally {
|
|
1743
|
+
try {
|
|
1744
|
+
await custody?.dispose();
|
|
1745
|
+
}
|
|
1746
|
+
finally {
|
|
1747
|
+
const opened = await repositoryPromise?.catch(() => undefined);
|
|
1748
|
+
await opened?.repository.dispose();
|
|
1749
|
+
}
|
|
1750
|
+
}
|
|
1751
|
+
})();
|
|
1752
|
+
return disposal;
|
|
1753
|
+
},
|
|
1754
|
+
};
|
|
1755
|
+
};
|
|
1756
|
+
}
|
|
1757
|
+
/**
|
|
1758
|
+
* The runtime collaborators of a repository-backed GA location: quota
|
|
1759
|
+
* snapshots kept in memory (a GA location writes no sidebar file), the
|
|
1760
|
+
* ref-attributed quota fetcher, and a token refresher that refreshes the
|
|
1761
|
+
* account it is handed through this activation's manager.
|
|
1762
|
+
*/
|
|
1763
|
+
export function createGaRuntimeCollaborators(input) {
|
|
1764
|
+
return {
|
|
1765
|
+
quotaSnapshots: createMemoryQuotaSnapshots(),
|
|
1766
|
+
fetchAccountQuota: async (account, signal) => {
|
|
1767
|
+
const repository = await input.getRepository();
|
|
1768
|
+
return createGaFetchAccountQuota({
|
|
1769
|
+
repository,
|
|
1770
|
+
...(input.assertAdmission
|
|
1771
|
+
? { assertAdmission: input.assertAdmission }
|
|
1772
|
+
: {}),
|
|
1773
|
+
now: input.now,
|
|
1774
|
+
overrides: input.overrides,
|
|
1775
|
+
logger: {
|
|
1776
|
+
debug: (...args) => input.accounts.quotaLogger?.debug(...args),
|
|
1777
|
+
},
|
|
1778
|
+
})(account, signal);
|
|
1779
|
+
},
|
|
1780
|
+
refreshToken: async (_auth, account) => {
|
|
1781
|
+
const manager = input.accounts.current;
|
|
1782
|
+
if (manager === null || !manager.getAccounts().includes(account))
|
|
1783
|
+
return undefined;
|
|
1784
|
+
const outcome = await manager.refreshAccount(account);
|
|
1785
|
+
return outcome.status === 'rotated'
|
|
1786
|
+
? manager.toAuthDetails(account)
|
|
1787
|
+
: undefined;
|
|
1788
|
+
},
|
|
1789
|
+
};
|
|
1790
|
+
}
|
|
1791
|
+
/**
|
|
1792
|
+
* The production GA location services: the embedded common-auth store,
|
|
1793
|
+
* the system clock, the repository-backed request pipeline and the
|
|
1794
|
+
* collaborators above. Every activation gets its own repository, account
|
|
1795
|
+
* slot and pipeline. With `vault`, a location can also serve the vault's
|
|
1796
|
+
* accounts: its mode file decides, and the menu's Vault section switches.
|
|
1797
|
+
*/
|
|
1798
|
+
export function createGaLocationServicesForHost(vault) {
|
|
1799
|
+
return (input) => {
|
|
1800
|
+
const accounts = { current: null, quotaLogger: null };
|
|
1801
|
+
return createGaLocationServicesFactory({
|
|
1802
|
+
loadStoreModules: loadCommonAuthStoreModules,
|
|
1803
|
+
resolveAccountFile: getStoragePath,
|
|
1804
|
+
now: Date.now,
|
|
1805
|
+
runtime: ({ getRepository, assertAdmission, overrides }) => createGaRuntimeCollaborators({
|
|
1806
|
+
getRepository,
|
|
1807
|
+
assertAdmission,
|
|
1808
|
+
overrides,
|
|
1809
|
+
accounts,
|
|
1810
|
+
now: Date.now,
|
|
1811
|
+
}),
|
|
1812
|
+
createPipeline: (pipeline) => createGaLocalRequestPipeline({ ...pipeline, accounts }),
|
|
1813
|
+
...(vault
|
|
1814
|
+
? {
|
|
1815
|
+
custody: ({ accountFile }) => createOpenCodeVaultCustody({
|
|
1816
|
+
accountFile,
|
|
1817
|
+
readHostSlot: vault.readHostSlot,
|
|
1818
|
+
...(vault.connectionFile
|
|
1819
|
+
? { connectionFile: vault.connectionFile }
|
|
1820
|
+
: {}),
|
|
1821
|
+
// The engine reads each send's HTTP status itself.
|
|
1822
|
+
reporterSource: 'direct',
|
|
1823
|
+
}),
|
|
1824
|
+
}
|
|
1825
|
+
: {}),
|
|
1826
|
+
})(input);
|
|
1827
|
+
};
|
|
1828
|
+
}
|
|
1829
|
+
/** The connection API belongs to this setup context, not a module-wide host. */
|
|
1830
|
+
export const createGaLocationServices = (input) => {
|
|
1831
|
+
const readHostSlot = input.connections
|
|
1832
|
+
? createGaHostSlotReader(input.connections, 'google')
|
|
1833
|
+
: async () => {
|
|
1834
|
+
throw new Error('The host integration connection API is unavailable');
|
|
1835
|
+
};
|
|
1836
|
+
return createGaLocationServicesForHost({ readHostSlot })(input);
|
|
1837
|
+
};
|
|
1838
|
+
//# sourceMappingURL=ga-location-services.js.map
|