@cortexkit/opencode-antigravity-auth 2.2.0 → 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 +40923 -16450
- 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 -1347
- 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,886 @@
|
|
|
1
|
+
import { OpenCode2AuthError } from './errors.js';
|
|
2
|
+
import { placeholderSecret } from './integration.js';
|
|
3
|
+
import { watchServerSentEvents } from './sse.js';
|
|
4
|
+
export const DEFAULT_MAX_RECORDS = 512;
|
|
5
|
+
/**
|
|
6
|
+
* The request header `model.request` sets to the attempt it started. The
|
|
7
|
+
* host builds the HTTP request and the WebSocket handshake from the headers
|
|
8
|
+
* `model.request` leaves, so `http.request` and `experimental.ws.handshake`
|
|
9
|
+
* read it to find their own attempt among several of one session and kind,
|
|
10
|
+
* and remove it: it never reaches the wire.
|
|
11
|
+
*/
|
|
12
|
+
export const ATTEMPT_HEADER = 'x-common-auth-attempt';
|
|
13
|
+
const keyOf = (sessionID, kind) => JSON.stringify([sessionID, kind]);
|
|
14
|
+
const scopeOf = (draft) => ({
|
|
15
|
+
providerID: draft.model.providerID,
|
|
16
|
+
modelID: draft.model.id,
|
|
17
|
+
sessionID: draft.sessionID,
|
|
18
|
+
agent: draft.agent,
|
|
19
|
+
kind: draft.kind,
|
|
20
|
+
});
|
|
21
|
+
// A header value is a string or null, so an object under `headers` can only
|
|
22
|
+
// be the `{headers, attempt}` form.
|
|
23
|
+
function isHeadersResult(value) {
|
|
24
|
+
const headers = value.headers;
|
|
25
|
+
return typeof headers === 'object' && headers !== null;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Forwards a response body and reports how it ended: read to the end
|
|
29
|
+
* (`undefined`), errored, or cancelled by whoever was reading it.
|
|
30
|
+
*/
|
|
31
|
+
function trackBody(source, onEnd) {
|
|
32
|
+
const reader = source.getReader();
|
|
33
|
+
return new ReadableStream({
|
|
34
|
+
async pull(controller) {
|
|
35
|
+
let chunk;
|
|
36
|
+
try {
|
|
37
|
+
chunk = await reader.read();
|
|
38
|
+
}
|
|
39
|
+
catch (error) {
|
|
40
|
+
onEnd({
|
|
41
|
+
reason: 'failed',
|
|
42
|
+
message: error instanceof Error ? error.message : String(error),
|
|
43
|
+
});
|
|
44
|
+
controller.error(error);
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
if (chunk.done) {
|
|
48
|
+
onEnd();
|
|
49
|
+
controller.close();
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
controller.enqueue(chunk.value);
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
|
+
async cancel(reason) {
|
|
56
|
+
onEnd({
|
|
57
|
+
reason: 'cancelled',
|
|
58
|
+
...(reason === undefined ? {} : { message: String(reason) }),
|
|
59
|
+
});
|
|
60
|
+
await reader.cancel(reason);
|
|
61
|
+
},
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
/** Applies edits to a plain header record, replacing every spelling of each name. */
|
|
65
|
+
export function applyHeaderEdits(target, edits) {
|
|
66
|
+
for (const [name, value] of Object.entries(edits)) {
|
|
67
|
+
const lower = name.toLowerCase();
|
|
68
|
+
for (const existing of Object.keys(target)) {
|
|
69
|
+
if (existing.toLowerCase() === lower)
|
|
70
|
+
delete target[existing];
|
|
71
|
+
}
|
|
72
|
+
if (value !== null)
|
|
73
|
+
target[name] = value;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
function applyHeaderEditsTo(target, edits) {
|
|
77
|
+
for (const [name, value] of Object.entries(edits)) {
|
|
78
|
+
if (value === null)
|
|
79
|
+
target.delete(name);
|
|
80
|
+
else
|
|
81
|
+
target.set(name, value);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Installs multi-account auth on OpenCode 2's own provider drivers. Every
|
|
86
|
+
* hook is scoped to `adapter.providerID`:
|
|
87
|
+
*
|
|
88
|
+
* - `model.request` picks the account for one model call of a session and
|
|
89
|
+
* request kind, which starts a new attempt, sets its headers and marks the
|
|
90
|
+
* request with the attempt (`ATTEMPT_HEADER`);
|
|
91
|
+
* - `http.request` and `experimental.ws.handshake` find the attempt by that
|
|
92
|
+
* mark, remove it and set the account headers again, because the host
|
|
93
|
+
* applies its own credential after `model.request`;
|
|
94
|
+
* - `experimental.ws.send` (only when the adapter rewrites frames) rewrites
|
|
95
|
+
* each outgoing frame;
|
|
96
|
+
* - `http.response` and `experimental.ws.receive` read quota, refusals,
|
|
97
|
+
* whether output has started and when the response ended, attributed to
|
|
98
|
+
* an attempt by the rules below;
|
|
99
|
+
* - `retry` asks the host to retry at once when an account was refused
|
|
100
|
+
* before any output, so `model.request` runs again and can pick another
|
|
101
|
+
* account, and refuses to retry once output has started.
|
|
102
|
+
*
|
|
103
|
+
* Attribution. A send belongs to the attempt named by the mark
|
|
104
|
+
* `model.request` left on it, so several attempts of one session and kind
|
|
105
|
+
* can be in flight at once, each on its own account. An HTTP response
|
|
106
|
+
* belongs to the attempt whose `http.request` produced its request object,
|
|
107
|
+
* and to nothing else. The host hands `http.response` the request object the
|
|
108
|
+
* `http.request` hooks left, so a different object means a later hook
|
|
109
|
+
* replaced it; nothing then proves which send the response answers, and its
|
|
110
|
+
* feedback is dropped rather than guessed by recency. A WebSocket frame
|
|
111
|
+
* names no attempt, so frames go to the newest open attempt of their session
|
|
112
|
+
* and kind that went out over WebSocket, and an older one is abandoned as
|
|
113
|
+
* soon as a newer attempt of that session and kind begins or goes out over
|
|
114
|
+
* WebSocket: the host runs one exchange at a time on a session's socket.
|
|
115
|
+
* Anything else is attributed to no attempt and reaches no adapter callback
|
|
116
|
+
* or listener.
|
|
117
|
+
*
|
|
118
|
+
* With `gateOnPlaceholder`, `model.request` is a no-op. Each transport hook
|
|
119
|
+
* compares the host-prepared secret exactly, then selects a fresh attempt only
|
|
120
|
+
* for an owned send. Request-object attribution therefore needs no attempt
|
|
121
|
+
* header. Frames are owned by the latest handshake of their session and kind;
|
|
122
|
+
* retry runs only when the session's latest transport was owned. The host's
|
|
123
|
+
* retry hook has no request identity, so concurrent mixed-ownership calls
|
|
124
|
+
* cannot be distinguished there; owned retries retain the heuristic above.
|
|
125
|
+
*/
|
|
126
|
+
export async function installOpenCode2Auth(ctx, adapter, options = {}) {
|
|
127
|
+
const { providerID } = adapter;
|
|
128
|
+
const ownership = options.gateOnPlaceholder;
|
|
129
|
+
const owns = (headers) => ownership === undefined ||
|
|
130
|
+
ownership.credential(headers) === placeholderSecret(providerID);
|
|
131
|
+
const logger = options.logger;
|
|
132
|
+
const maxRecords = Math.max(1, options.maxRecords ?? DEFAULT_MAX_RECORDS);
|
|
133
|
+
const forbidden = [
|
|
134
|
+
...(options.hostCredentials ?? [placeholderSecret(providerID)]),
|
|
135
|
+
// An owned request must replace its placeholder even if a caller customizes
|
|
136
|
+
// the list of other host credentials forbidden on the wire.
|
|
137
|
+
...(ownership ? [placeholderSecret(providerID)] : []),
|
|
138
|
+
].filter((value) => value !== '');
|
|
139
|
+
/** Every attempt still held, oldest first. */
|
|
140
|
+
const attempts = new Map();
|
|
141
|
+
const byRequest = new WeakMap();
|
|
142
|
+
/** Retries the retry hook asked for, by `sessionID:kind`. */
|
|
143
|
+
const pendingRetries = new Map();
|
|
144
|
+
// The host names only session/kind for frames and only session for retry.
|
|
145
|
+
// A transport's prepared credential, never global login state, owns these.
|
|
146
|
+
const ownedSockets = new Set();
|
|
147
|
+
const latestTransportOwned = new Map();
|
|
148
|
+
let warnedUnprovenResponse = false;
|
|
149
|
+
let warnedUnmarkedSend = false;
|
|
150
|
+
const listeners = new Map();
|
|
151
|
+
let seq = 0;
|
|
152
|
+
let disposed = false;
|
|
153
|
+
/** Only active hook calls are held; forgetting never leaves a session tombstone. */
|
|
154
|
+
const inFlight = new Map();
|
|
155
|
+
const warn = (message, data) => {
|
|
156
|
+
try {
|
|
157
|
+
logger?.warn(message, data);
|
|
158
|
+
}
|
|
159
|
+
catch { }
|
|
160
|
+
};
|
|
161
|
+
const describe = (error) => error instanceof Error ? error.message : String(error);
|
|
162
|
+
const emit = async (event, payload) => {
|
|
163
|
+
const set = listeners.get(event);
|
|
164
|
+
if (!set || set.size === 0)
|
|
165
|
+
return;
|
|
166
|
+
await Promise.all([...set].map(async (listener) => {
|
|
167
|
+
try {
|
|
168
|
+
await listener(payload);
|
|
169
|
+
}
|
|
170
|
+
catch (error) {
|
|
171
|
+
warn('opencode2 auth listener threw; the request is unaffected', {
|
|
172
|
+
event,
|
|
173
|
+
error: describe(error),
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
}));
|
|
177
|
+
};
|
|
178
|
+
const deliverEnd = async (attempt, outcome) => {
|
|
179
|
+
try {
|
|
180
|
+
await adapter.onAttemptEnd?.(attempt, outcome);
|
|
181
|
+
}
|
|
182
|
+
catch (error) {
|
|
183
|
+
warn('opencode2 auth onAttemptEnd threw; the request is unaffected', {
|
|
184
|
+
attemptId: attempt.attemptId,
|
|
185
|
+
error: describe(error),
|
|
186
|
+
});
|
|
187
|
+
}
|
|
188
|
+
};
|
|
189
|
+
/** Ends an attempt once; later calls for the same attempt do nothing. */
|
|
190
|
+
const finish = (rec, error) => {
|
|
191
|
+
if (rec.ended || !rec.attempt)
|
|
192
|
+
return;
|
|
193
|
+
const outcome = {
|
|
194
|
+
...(rec.status === undefined ? {} : { status: rec.status }),
|
|
195
|
+
outputStarted: rec.outputStarted,
|
|
196
|
+
...(rec.limit ? { limit: rec.limit.signal } : {}),
|
|
197
|
+
...(error ? { error } : {}),
|
|
198
|
+
};
|
|
199
|
+
if (error)
|
|
200
|
+
rec.endError = error;
|
|
201
|
+
rec.ended = deliverEnd(rec.attempt, outcome);
|
|
202
|
+
};
|
|
203
|
+
const abandon = (rec, message) => finish(rec, { reason: 'abandoned', message });
|
|
204
|
+
/** The attempts of one session and kind, oldest first. */
|
|
205
|
+
const attemptsOf = (key) => [...attempts.values()].filter((rec) => rec.key === key);
|
|
206
|
+
const newestOf = (key) => attemptsOf(key).at(-1);
|
|
207
|
+
/** Forgets an attempt, and its key's pending retry once nothing else holds the key. */
|
|
208
|
+
const drop = (rec) => {
|
|
209
|
+
attempts.delete(rec.id);
|
|
210
|
+
if (!attemptsOf(rec.key).length)
|
|
211
|
+
pendingRetries.delete(rec.key);
|
|
212
|
+
};
|
|
213
|
+
const remember = (rec) => {
|
|
214
|
+
attempts.set(rec.id, rec);
|
|
215
|
+
while (attempts.size > maxRecords) {
|
|
216
|
+
const oldest = attempts.values().next().value;
|
|
217
|
+
if (oldest === undefined)
|
|
218
|
+
break;
|
|
219
|
+
abandon(oldest, 'dropped to keep the record bound');
|
|
220
|
+
drop(oldest);
|
|
221
|
+
}
|
|
222
|
+
};
|
|
223
|
+
const accountOf = (rec) => rec.accountId === undefined
|
|
224
|
+
? undefined
|
|
225
|
+
: { ...rec.scope, accountId: rec.accountId };
|
|
226
|
+
const noAccount = (scope, message) => new OpenCode2AuthError({
|
|
227
|
+
kind: 'no-account',
|
|
228
|
+
providerID,
|
|
229
|
+
sessionID: scope.sessionID,
|
|
230
|
+
requestKind: scope.kind,
|
|
231
|
+
...(message === undefined ? {} : { message }),
|
|
232
|
+
});
|
|
233
|
+
const revokeSelections = (sessionID) => {
|
|
234
|
+
inFlight.get(sessionID)?.clear();
|
|
235
|
+
inFlight.delete(sessionID);
|
|
236
|
+
};
|
|
237
|
+
/**
|
|
238
|
+
* Owns selection through its transport handoff, not just the adapter calls.
|
|
239
|
+
* Deleting a session's set revokes its old calls without poisoning reuse of
|
|
240
|
+
* that id. Each await must recheck before calling the adapter or publishing.
|
|
241
|
+
*/
|
|
242
|
+
const withSelection = async (scope, run) => {
|
|
243
|
+
const revoked = () => noAccount(scope, `${providerID} ${scope.kind} request has no account: its auth selection was revoked by session forgetting or installation disposal`);
|
|
244
|
+
if (disposed)
|
|
245
|
+
throw revoked();
|
|
246
|
+
let selections = inFlight.get(scope.sessionID);
|
|
247
|
+
if (!selections) {
|
|
248
|
+
selections = new Set();
|
|
249
|
+
inFlight.set(scope.sessionID, selections);
|
|
250
|
+
}
|
|
251
|
+
const token = {};
|
|
252
|
+
selections.add(token);
|
|
253
|
+
const assertActive = () => {
|
|
254
|
+
if (!selections.has(token))
|
|
255
|
+
throw revoked();
|
|
256
|
+
};
|
|
257
|
+
try {
|
|
258
|
+
return await run(assertActive);
|
|
259
|
+
}
|
|
260
|
+
finally {
|
|
261
|
+
selections.delete(token);
|
|
262
|
+
// An old call may settle after a new call has reused the session id.
|
|
263
|
+
if (selections.size === 0 && inFlight.get(scope.sessionID) === selections)
|
|
264
|
+
inFlight.delete(scope.sessionID);
|
|
265
|
+
}
|
|
266
|
+
};
|
|
267
|
+
const guard = (scope, headers) => {
|
|
268
|
+
for (const [name, value] of headers) {
|
|
269
|
+
if (forbidden.some((secret) => value.includes(secret))) {
|
|
270
|
+
throw new OpenCode2AuthError({
|
|
271
|
+
kind: 'host-credential-on-wire',
|
|
272
|
+
providerID,
|
|
273
|
+
sessionID: scope.sessionID,
|
|
274
|
+
requestKind: scope.kind,
|
|
275
|
+
message: `${providerID} ${scope.kind} request still carries the host's placeholder credential in ${name}; the adapter's account headers must replace it`,
|
|
276
|
+
});
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
};
|
|
280
|
+
/**
|
|
281
|
+
* Retires the attempts a new attempt of the same session and kind
|
|
282
|
+
* supersedes. One that has ended is dropped. One still open stays when it
|
|
283
|
+
* may yet be sent or answered (waiting for its transport, or an HTTP send
|
|
284
|
+
* whose response will name it), since another call of the same session and
|
|
285
|
+
* kind may run beside this one. One on WebSocket is abandoned, because
|
|
286
|
+
* frames name no attempt and the host runs one exchange at a time on a
|
|
287
|
+
* session's socket; one the retry hook already judged is abandoned too,
|
|
288
|
+
* because the host has finished with that call.
|
|
289
|
+
*/
|
|
290
|
+
const supersede = (key) => {
|
|
291
|
+
for (const rec of attemptsOf(key)) {
|
|
292
|
+
if (rec.ended || !rec.attempt) {
|
|
293
|
+
drop(rec);
|
|
294
|
+
}
|
|
295
|
+
else if (rec.transport === 'ws' || rec.judged) {
|
|
296
|
+
abandon(rec, 'a newer attempt of its session and kind began');
|
|
297
|
+
drop(rec);
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
};
|
|
301
|
+
const select = async (scope, hook, assertActive, transport) => {
|
|
302
|
+
const key = keyOf(scope.sessionID, scope.kind);
|
|
303
|
+
const retried = pendingRetries.get(key);
|
|
304
|
+
pendingRetries.delete(key);
|
|
305
|
+
const previousAccountId = retried?.accountId ?? newestOf(key)?.accountId;
|
|
306
|
+
supersede(key);
|
|
307
|
+
const input = {
|
|
308
|
+
...scope,
|
|
309
|
+
...(previousAccountId === undefined ? {} : { previousAccountId }),
|
|
310
|
+
...(retried?.rerouteFrom === undefined
|
|
311
|
+
? {}
|
|
312
|
+
: { rerouteFrom: retried.rerouteFrom }),
|
|
313
|
+
};
|
|
314
|
+
const accountId = await adapter.chooseAccount(input);
|
|
315
|
+
assertActive();
|
|
316
|
+
let headers = {};
|
|
317
|
+
let data;
|
|
318
|
+
if (accountId !== undefined) {
|
|
319
|
+
const result = await adapter.accountHeaders({ ...scope, accountId });
|
|
320
|
+
assertActive();
|
|
321
|
+
if (isHeadersResult(result)) {
|
|
322
|
+
headers = result.headers;
|
|
323
|
+
data = result.attempt;
|
|
324
|
+
}
|
|
325
|
+
else {
|
|
326
|
+
headers = result;
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
const id = `attempt-${++seq}`;
|
|
330
|
+
const rec = {
|
|
331
|
+
id,
|
|
332
|
+
key,
|
|
333
|
+
scope,
|
|
334
|
+
accountId,
|
|
335
|
+
headers,
|
|
336
|
+
attempt: accountId === undefined
|
|
337
|
+
? undefined
|
|
338
|
+
: {
|
|
339
|
+
...scope,
|
|
340
|
+
accountId,
|
|
341
|
+
attemptId: id,
|
|
342
|
+
transport,
|
|
343
|
+
data,
|
|
344
|
+
},
|
|
345
|
+
...(transport === undefined ? {} : { transport }),
|
|
346
|
+
outputStarted: false,
|
|
347
|
+
};
|
|
348
|
+
remember(rec);
|
|
349
|
+
if (rec.attempt) {
|
|
350
|
+
void emit('select', {
|
|
351
|
+
...scope,
|
|
352
|
+
accountId: rec.attempt.accountId,
|
|
353
|
+
hook,
|
|
354
|
+
...(input.previousAccountId === undefined
|
|
355
|
+
? {}
|
|
356
|
+
: { previousAccountId: input.previousAccountId }),
|
|
357
|
+
...(input.rerouteFrom === undefined
|
|
358
|
+
? {}
|
|
359
|
+
: { rerouteFrom: input.rerouteFrom }),
|
|
360
|
+
handle: rec.attempt,
|
|
361
|
+
});
|
|
362
|
+
}
|
|
363
|
+
return rec;
|
|
364
|
+
};
|
|
365
|
+
// The transport hooks normally follow `model.request` and carry the mark
|
|
366
|
+
// of the attempt it started. Choosing here too keeps a request that skipped
|
|
367
|
+
// it from going out under the host credential, and a second send of the
|
|
368
|
+
// same attempt from reusing the first send's attempt.
|
|
369
|
+
const bind = async (scope, hook, transport, mark, assertActive) => {
|
|
370
|
+
const key = keyOf(scope.sessionID, scope.kind);
|
|
371
|
+
let rec = mark === undefined ? undefined : attempts.get(mark);
|
|
372
|
+
if (rec?.key !== key)
|
|
373
|
+
rec = undefined;
|
|
374
|
+
if (!rec) {
|
|
375
|
+
// No mark: the newest attempt of the session and kind is the only
|
|
376
|
+
// candidate the hook can name. Say so once when that is a guess.
|
|
377
|
+
rec = newestOf(key);
|
|
378
|
+
const waiting = attemptsOf(key).filter((other) => other.transport === undefined && !other.ended);
|
|
379
|
+
if (waiting.length > 1 && !warnedUnmarkedSend) {
|
|
380
|
+
warnedUnmarkedSend = true;
|
|
381
|
+
warn('opencode2 auth tied a send without its attempt mark to the newest of several waiting attempts', { sessionID: scope.sessionID, kind: scope.kind });
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
if (!rec || rec.transport !== undefined || rec.ended)
|
|
385
|
+
rec = await select(scope, hook, assertActive, transport);
|
|
386
|
+
else {
|
|
387
|
+
rec.transport = transport;
|
|
388
|
+
if (rec.attempt)
|
|
389
|
+
rec.attempt.transport = transport;
|
|
390
|
+
}
|
|
391
|
+
if (transport === 'ws') {
|
|
392
|
+
for (const other of attemptsOf(key)) {
|
|
393
|
+
if (other !== rec && other.transport === 'ws')
|
|
394
|
+
abandon(other, 'a newer attempt of its session and kind went out over WebSocket');
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
return rec;
|
|
398
|
+
};
|
|
399
|
+
// A transport hook that throws stops the send, so its attempt is over.
|
|
400
|
+
const failing = async (rec, run) => {
|
|
401
|
+
try {
|
|
402
|
+
return await run();
|
|
403
|
+
}
|
|
404
|
+
catch (error) {
|
|
405
|
+
finish(rec, { reason: 'failed', message: describe(error) });
|
|
406
|
+
throw error;
|
|
407
|
+
}
|
|
408
|
+
};
|
|
409
|
+
/** The attempt a frame of this session and kind belongs to, if any. */
|
|
410
|
+
const liveOnSocket = (sessionID, kind) => {
|
|
411
|
+
const rec = attemptsOf(keyOf(sessionID, kind))
|
|
412
|
+
.filter((each) => each.transport === 'ws')
|
|
413
|
+
.at(-1);
|
|
414
|
+
return rec?.attempt !== undefined && !rec.ended ? rec : undefined;
|
|
415
|
+
};
|
|
416
|
+
const noteLimit = (rec, signal, via) => {
|
|
417
|
+
const account = accountOf(rec);
|
|
418
|
+
if (!account || !rec.attempt || rec.limit)
|
|
419
|
+
return;
|
|
420
|
+
rec.limit = {
|
|
421
|
+
signal,
|
|
422
|
+
delivered: emit('limit', {
|
|
423
|
+
...account,
|
|
424
|
+
via,
|
|
425
|
+
limit: signal,
|
|
426
|
+
outputStarted: rec.outputStarted,
|
|
427
|
+
handle: rec.attempt,
|
|
428
|
+
}),
|
|
429
|
+
};
|
|
430
|
+
};
|
|
431
|
+
const noteQuota = (rec, transport, quota, status) => {
|
|
432
|
+
const account = accountOf(rec);
|
|
433
|
+
if (!account || !rec.attempt)
|
|
434
|
+
return;
|
|
435
|
+
void emit('quota', {
|
|
436
|
+
...account,
|
|
437
|
+
transport,
|
|
438
|
+
...(status === undefined ? {} : { status }),
|
|
439
|
+
quota,
|
|
440
|
+
handle: rec.attempt,
|
|
441
|
+
});
|
|
442
|
+
};
|
|
443
|
+
const inspect = (rec, transport, data, event) => {
|
|
444
|
+
const attempt = rec.attempt;
|
|
445
|
+
if (!attempt)
|
|
446
|
+
return;
|
|
447
|
+
const verdict = adapter.inspectEvent?.(event === undefined
|
|
448
|
+
? { transport, data, attempt }
|
|
449
|
+
: { transport, data, event, attempt });
|
|
450
|
+
if (!verdict)
|
|
451
|
+
return;
|
|
452
|
+
if (verdict.quota !== undefined)
|
|
453
|
+
noteQuota(rec, transport, verdict.quota);
|
|
454
|
+
if (verdict.outputStarted)
|
|
455
|
+
rec.outputStarted = true;
|
|
456
|
+
if (verdict.limit)
|
|
457
|
+
noteLimit(rec, verdict.limit, transport);
|
|
458
|
+
if (verdict.error !== undefined)
|
|
459
|
+
finish(rec, { reason: 'failed', message: verdict.error });
|
|
460
|
+
else if (verdict.done)
|
|
461
|
+
finish(rec);
|
|
462
|
+
};
|
|
463
|
+
/** Moves an attempt to the account that answered its response. */
|
|
464
|
+
const rebind = (rec, answered) => {
|
|
465
|
+
const attempt = rec.attempt;
|
|
466
|
+
if (!attempt || answered.accountId === rec.accountId)
|
|
467
|
+
return;
|
|
468
|
+
attempt.reboundFrom ??= attempt.accountId;
|
|
469
|
+
attempt.accountId = answered.accountId;
|
|
470
|
+
if ('data' in answered)
|
|
471
|
+
attempt.data = answered.data;
|
|
472
|
+
rec.accountId = answered.accountId;
|
|
473
|
+
};
|
|
474
|
+
const failedOutcome = (rec) => !rec.attempt ||
|
|
475
|
+
rec.endError !== undefined ||
|
|
476
|
+
(rec.status !== undefined && rec.status >= 400);
|
|
477
|
+
/**
|
|
478
|
+
* The attempt a retry is about. The retry hook names only the session, so:
|
|
479
|
+
* the newest refused attempt not yet rerouted; else, among the session's
|
|
480
|
+
* primary attempts (or all of them when it has none), the only one, the
|
|
481
|
+
* newest that failed and was not yet judged, the only one still open, or
|
|
482
|
+
* the newest. Two or more open with nothing else to tell them apart is
|
|
483
|
+
* `ambiguous`: deciding for one could reroute or end the other.
|
|
484
|
+
*/
|
|
485
|
+
const pickForRetry = (sessionID) => {
|
|
486
|
+
const held = [...attempts.values()].filter((rec) => rec.scope.sessionID === sessionID);
|
|
487
|
+
const refused = held.filter((rec) => rec.limit && !rec.rerouted).at(-1);
|
|
488
|
+
if (refused)
|
|
489
|
+
return refused;
|
|
490
|
+
const primary = held.filter((rec) => rec.scope.kind === 'primary');
|
|
491
|
+
const pool = primary.length > 0 ? primary : held;
|
|
492
|
+
if (pool.length <= 1)
|
|
493
|
+
return pool[0];
|
|
494
|
+
const failed = pool
|
|
495
|
+
.filter((rec) => !rec.judged && failedOutcome(rec))
|
|
496
|
+
.at(-1);
|
|
497
|
+
if (failed)
|
|
498
|
+
return failed;
|
|
499
|
+
const open = pool.filter((rec) => rec.attempt && !rec.ended);
|
|
500
|
+
if (open.length > 1)
|
|
501
|
+
return 'ambiguous';
|
|
502
|
+
return open[0] ?? pool.at(-1);
|
|
503
|
+
};
|
|
504
|
+
const scoped = { providerID };
|
|
505
|
+
const registrations = [];
|
|
506
|
+
registrations.push(await ctx.session.hook('model.request', (draft) => {
|
|
507
|
+
if (ownership)
|
|
508
|
+
return;
|
|
509
|
+
return withSelection(scopeOf(draft), async (assertActive) => {
|
|
510
|
+
const rec = await select(scopeOf(draft), 'model.request', assertActive);
|
|
511
|
+
assertActive();
|
|
512
|
+
if (rec.accountId === undefined)
|
|
513
|
+
throw noAccount(rec.scope);
|
|
514
|
+
applyHeaderEdits(draft.headers, {
|
|
515
|
+
...rec.headers,
|
|
516
|
+
[ATTEMPT_HEADER]: rec.id,
|
|
517
|
+
});
|
|
518
|
+
});
|
|
519
|
+
}, scoped));
|
|
520
|
+
registrations.push(await ctx.session.hook('http.request', (draft) => {
|
|
521
|
+
if (ownership) {
|
|
522
|
+
const owned = owns(draft.request.headers);
|
|
523
|
+
latestTransportOwned.set(draft.sessionID, owned);
|
|
524
|
+
if (!owned)
|
|
525
|
+
return;
|
|
526
|
+
}
|
|
527
|
+
return withSelection(scopeOf(draft), async (assertActive) => {
|
|
528
|
+
const mark = draft.request.headers.get(ATTEMPT_HEADER) ?? undefined;
|
|
529
|
+
// With gateOnPlaceholder, each owned transport call creates its own
|
|
530
|
+
// attempt. No ATTEMPT_HEADER is needed to link it to model.request.
|
|
531
|
+
const rec = ownership
|
|
532
|
+
? await select(scopeOf(draft), 'http.request', assertActive, 'http')
|
|
533
|
+
: await bind(scopeOf(draft), 'http.request', 'http', mark, assertActive);
|
|
534
|
+
assertActive();
|
|
535
|
+
const account = accountOf(rec);
|
|
536
|
+
const attempt = rec.attempt;
|
|
537
|
+
if (!account || !attempt)
|
|
538
|
+
throw noAccount(rec.scope);
|
|
539
|
+
await failing(rec, async () => {
|
|
540
|
+
let request = draft.request;
|
|
541
|
+
if (adapter.rewriteRequest) {
|
|
542
|
+
if (mark !== undefined) {
|
|
543
|
+
// The mark is the installer's own; the adapter's rewrite never
|
|
544
|
+
// sees it.
|
|
545
|
+
const unmarked = new Headers(request.headers);
|
|
546
|
+
unmarked.delete(ATTEMPT_HEADER);
|
|
547
|
+
request = new Request(request, { headers: unmarked });
|
|
548
|
+
}
|
|
549
|
+
request =
|
|
550
|
+
(await adapter.rewriteRequest({
|
|
551
|
+
...account,
|
|
552
|
+
request,
|
|
553
|
+
attempt,
|
|
554
|
+
})) ?? request;
|
|
555
|
+
assertActive();
|
|
556
|
+
}
|
|
557
|
+
const headers = new Headers(request.headers);
|
|
558
|
+
headers.delete(ATTEMPT_HEADER);
|
|
559
|
+
applyHeaderEditsTo(headers, rec.headers);
|
|
560
|
+
guard(rec.scope, headers.entries());
|
|
561
|
+
const final = new Request(request, { headers });
|
|
562
|
+
byRequest.set(final, rec);
|
|
563
|
+
draft.request = final;
|
|
564
|
+
});
|
|
565
|
+
});
|
|
566
|
+
}, scoped));
|
|
567
|
+
registrations.push(await ctx.session.hook('http.response', async (draft) => {
|
|
568
|
+
const rec = byRequest.get(draft.request);
|
|
569
|
+
if (!rec) {
|
|
570
|
+
if (ownership)
|
|
571
|
+
return;
|
|
572
|
+
if (!warnedUnprovenResponse) {
|
|
573
|
+
warnedUnprovenResponse = true;
|
|
574
|
+
warn('opencode2 auth dropped an http.response whose request it did not produce', { sessionID: draft.sessionID, kind: draft.kind });
|
|
575
|
+
}
|
|
576
|
+
return;
|
|
577
|
+
}
|
|
578
|
+
const original = draft.response;
|
|
579
|
+
if (adapter.answeredBy && rec.attempt) {
|
|
580
|
+
const attempt = rec.attempt;
|
|
581
|
+
const answered = await failing(rec, async () => adapter.answeredBy?.({
|
|
582
|
+
request: draft.request,
|
|
583
|
+
response: original,
|
|
584
|
+
attempt,
|
|
585
|
+
}));
|
|
586
|
+
if (answered)
|
|
587
|
+
rebind(rec, answered);
|
|
588
|
+
}
|
|
589
|
+
const account = accountOf(rec);
|
|
590
|
+
const attempt = rec.attempt;
|
|
591
|
+
if (!account || !attempt)
|
|
592
|
+
return;
|
|
593
|
+
rec.status = original.status;
|
|
594
|
+
const quota = adapter.quotaFromHeaders?.(original.headers, original.status, attempt);
|
|
595
|
+
if (quota !== undefined)
|
|
596
|
+
noteQuota(rec, 'http', quota, original.status);
|
|
597
|
+
if (!original.ok && adapter.limitFromResponse) {
|
|
598
|
+
const signal = await adapter.limitFromResponse({
|
|
599
|
+
status: original.status,
|
|
600
|
+
headers: original.headers,
|
|
601
|
+
body: () => original.clone().text(),
|
|
602
|
+
attempt,
|
|
603
|
+
});
|
|
604
|
+
if (signal)
|
|
605
|
+
noteLimit(rec, signal, 'http');
|
|
606
|
+
}
|
|
607
|
+
// An error response carries no output, so its status is the outcome;
|
|
608
|
+
// ending here keeps the end from depending on whether the host reads
|
|
609
|
+
// the error body to the end.
|
|
610
|
+
if (!original.ok || !original.body)
|
|
611
|
+
finish(rec);
|
|
612
|
+
let response = original;
|
|
613
|
+
if (original.body && (adapter.inspectEvent || adapter.onAttemptEnd)) {
|
|
614
|
+
let body = original.body;
|
|
615
|
+
if (adapter.inspectEvent) {
|
|
616
|
+
body = body.pipeThrough(watchServerSentEvents((event) => inspect(rec, 'http', event.data, event.event), (error) => warn('opencode2 auth event inspection threw', {
|
|
617
|
+
error: describe(error),
|
|
618
|
+
})));
|
|
619
|
+
}
|
|
620
|
+
response = new Response(trackBody(body, (error) => finish(rec, error)), {
|
|
621
|
+
status: original.status,
|
|
622
|
+
statusText: original.statusText,
|
|
623
|
+
headers: original.headers,
|
|
624
|
+
});
|
|
625
|
+
}
|
|
626
|
+
if (adapter.rewriteResponse) {
|
|
627
|
+
response =
|
|
628
|
+
(await adapter.rewriteResponse({
|
|
629
|
+
...account,
|
|
630
|
+
request: draft.request,
|
|
631
|
+
response,
|
|
632
|
+
attempt,
|
|
633
|
+
})) ?? response;
|
|
634
|
+
}
|
|
635
|
+
if (response !== original)
|
|
636
|
+
draft.response = response;
|
|
637
|
+
}, scoped));
|
|
638
|
+
registrations.push(await ctx.session.hook('experimental.ws.handshake', (draft) => {
|
|
639
|
+
if (ownership) {
|
|
640
|
+
const owned = owns(new Headers(draft.headers));
|
|
641
|
+
const key = keyOf(draft.sessionID, draft.kind);
|
|
642
|
+
latestTransportOwned.set(draft.sessionID, owned);
|
|
643
|
+
// Clear the previous handshake's ownership before selecting: if no
|
|
644
|
+
// account can serve, subsequent frames must not use the old attempt.
|
|
645
|
+
ownedSockets.delete(key);
|
|
646
|
+
if (!owned)
|
|
647
|
+
return;
|
|
648
|
+
}
|
|
649
|
+
return withSelection(scopeOf(draft), async (assertActive) => {
|
|
650
|
+
let mark;
|
|
651
|
+
for (const name of Object.keys(draft.headers)) {
|
|
652
|
+
if (name.toLowerCase() !== ATTEMPT_HEADER)
|
|
653
|
+
continue;
|
|
654
|
+
mark ??= draft.headers[name];
|
|
655
|
+
delete draft.headers[name];
|
|
656
|
+
}
|
|
657
|
+
const rec = ownership
|
|
658
|
+
? await select(scopeOf(draft), 'experimental.ws.handshake', assertActive, 'ws')
|
|
659
|
+
: await bind(scopeOf(draft), 'experimental.ws.handshake', 'ws', mark, assertActive);
|
|
660
|
+
assertActive();
|
|
661
|
+
const account = accountOf(rec);
|
|
662
|
+
const attempt = rec.attempt;
|
|
663
|
+
if (!account || !attempt)
|
|
664
|
+
throw noAccount(rec.scope);
|
|
665
|
+
await failing(rec, async () => {
|
|
666
|
+
applyHeaderEdits(draft.headers, rec.headers);
|
|
667
|
+
const url = adapter.rewriteHandshakeURL?.({
|
|
668
|
+
...account,
|
|
669
|
+
url: draft.url,
|
|
670
|
+
attempt,
|
|
671
|
+
});
|
|
672
|
+
if (url !== undefined)
|
|
673
|
+
draft.url = url;
|
|
674
|
+
guard(rec.scope, Object.entries(draft.headers));
|
|
675
|
+
if (ownership)
|
|
676
|
+
ownedSockets.add(rec.key);
|
|
677
|
+
});
|
|
678
|
+
});
|
|
679
|
+
}, scoped));
|
|
680
|
+
const rewriteFrame = adapter.rewriteWebSocketFrame?.bind(adapter);
|
|
681
|
+
if (rewriteFrame) {
|
|
682
|
+
registrations.push(await ctx.session.hook('experimental.ws.send', async (draft) => {
|
|
683
|
+
const scope = scopeOf(draft);
|
|
684
|
+
if (ownership &&
|
|
685
|
+
!ownedSockets.has(keyOf(scope.sessionID, scope.kind)))
|
|
686
|
+
return;
|
|
687
|
+
const rec = liveOnSocket(scope.sessionID, scope.kind);
|
|
688
|
+
const frame = await rewriteFrame({
|
|
689
|
+
...scope,
|
|
690
|
+
attempt: rec?.attempt,
|
|
691
|
+
frame: draft.frame,
|
|
692
|
+
});
|
|
693
|
+
if (frame !== undefined)
|
|
694
|
+
draft.frame = frame;
|
|
695
|
+
}, scoped));
|
|
696
|
+
}
|
|
697
|
+
registrations.push(await ctx.session.hook('experimental.ws.receive', (draft) => {
|
|
698
|
+
if (ownership && !ownedSockets.has(keyOf(draft.sessionID, draft.kind)))
|
|
699
|
+
return;
|
|
700
|
+
const rec = liveOnSocket(draft.sessionID, draft.kind);
|
|
701
|
+
if (!rec)
|
|
702
|
+
return;
|
|
703
|
+
try {
|
|
704
|
+
inspect(rec, 'ws', draft.frame);
|
|
705
|
+
}
|
|
706
|
+
catch (error) {
|
|
707
|
+
warn('opencode2 auth frame inspection threw', {
|
|
708
|
+
error: describe(error),
|
|
709
|
+
});
|
|
710
|
+
}
|
|
711
|
+
}, scoped));
|
|
712
|
+
registrations.push(await ctx.session.hook('retry', async (draft) => {
|
|
713
|
+
if (ownership && latestTransportOwned.get(draft.sessionID) !== true)
|
|
714
|
+
return;
|
|
715
|
+
const picked = pickForRetry(draft.sessionID);
|
|
716
|
+
if (!picked)
|
|
717
|
+
return;
|
|
718
|
+
const hostDecision = draft.decision;
|
|
719
|
+
if (picked === 'ambiguous') {
|
|
720
|
+
// Nothing tells which open attempt failed: keep the host's
|
|
721
|
+
// decision and leave every attempt as it is.
|
|
722
|
+
await emit('retry', {
|
|
723
|
+
sessionID: draft.sessionID,
|
|
724
|
+
attempt: draft.attempt,
|
|
725
|
+
reason: 'host-decides',
|
|
726
|
+
hostDecision,
|
|
727
|
+
decision: hostDecision,
|
|
728
|
+
});
|
|
729
|
+
return;
|
|
730
|
+
}
|
|
731
|
+
const rec = picked;
|
|
732
|
+
await withSelection(rec.scope, async (assertActive) => {
|
|
733
|
+
rec.judged = true;
|
|
734
|
+
let decision = hostDecision;
|
|
735
|
+
let reason;
|
|
736
|
+
let rerouteFrom;
|
|
737
|
+
const attempt = rec.attempt;
|
|
738
|
+
if (rec.accountId === undefined || !attempt) {
|
|
739
|
+
decision = { retry: false };
|
|
740
|
+
reason = 'no-account';
|
|
741
|
+
}
|
|
742
|
+
else if (rec.outputStarted) {
|
|
743
|
+
// The user has already seen part of this answer; a retry would
|
|
744
|
+
// send it again.
|
|
745
|
+
decision = { retry: false };
|
|
746
|
+
reason = 'output-started';
|
|
747
|
+
}
|
|
748
|
+
else {
|
|
749
|
+
if (!rec.limit) {
|
|
750
|
+
const signal = adapter.limitFromError?.(draft.error, attempt);
|
|
751
|
+
if (signal)
|
|
752
|
+
noteLimit(rec, signal, 'error');
|
|
753
|
+
}
|
|
754
|
+
// The next `chooseAccount` should see whatever the plugin learnt
|
|
755
|
+
// from how this attempt ended.
|
|
756
|
+
if (rec.ended) {
|
|
757
|
+
await rec.ended;
|
|
758
|
+
assertActive();
|
|
759
|
+
}
|
|
760
|
+
if (rec.limit) {
|
|
761
|
+
await rec.limit.delivered;
|
|
762
|
+
assertActive();
|
|
763
|
+
rec.rerouted = true;
|
|
764
|
+
rerouteFrom = {
|
|
765
|
+
accountId: rec.accountId,
|
|
766
|
+
limit: rec.limit.signal,
|
|
767
|
+
};
|
|
768
|
+
// No delay: the next attempt goes to another account, and the
|
|
769
|
+
// host would otherwise wait out the refused account's backoff,
|
|
770
|
+
// or not retry at all for errors it deems final.
|
|
771
|
+
decision = { retry: true, delay: 0 };
|
|
772
|
+
reason = 'reroute';
|
|
773
|
+
}
|
|
774
|
+
else {
|
|
775
|
+
reason = 'host-decides';
|
|
776
|
+
}
|
|
777
|
+
}
|
|
778
|
+
draft.decision = decision;
|
|
779
|
+
// The host's retry runs `model.request` again for this attempt's
|
|
780
|
+
// session and kind; that next attempt, and no other attempt of the
|
|
781
|
+
// session, is told what this one ended with.
|
|
782
|
+
if (decision.retry && rec.accountId !== undefined) {
|
|
783
|
+
pendingRetries.set(rec.key, {
|
|
784
|
+
sessionID: rec.scope.sessionID,
|
|
785
|
+
accountId: rec.accountId,
|
|
786
|
+
...(rerouteFrom === undefined ? {} : { rerouteFrom }),
|
|
787
|
+
});
|
|
788
|
+
}
|
|
789
|
+
await emit('retry', {
|
|
790
|
+
sessionID: draft.sessionID,
|
|
791
|
+
...(rec.accountId === undefined
|
|
792
|
+
? {}
|
|
793
|
+
: { accountId: rec.accountId }),
|
|
794
|
+
kind: rec.scope.kind,
|
|
795
|
+
attempt: draft.attempt,
|
|
796
|
+
reason,
|
|
797
|
+
hostDecision,
|
|
798
|
+
decision,
|
|
799
|
+
...(attempt === undefined ? {} : { handle: attempt }),
|
|
800
|
+
});
|
|
801
|
+
});
|
|
802
|
+
}, scoped));
|
|
803
|
+
const forgetSession = (sessionID) => {
|
|
804
|
+
revokeSelections(sessionID);
|
|
805
|
+
latestTransportOwned.delete(sessionID);
|
|
806
|
+
for (const key of ownedSockets) {
|
|
807
|
+
if (JSON.parse(key)[0] === sessionID)
|
|
808
|
+
ownedSockets.delete(key);
|
|
809
|
+
}
|
|
810
|
+
for (const rec of [...attempts.values()]) {
|
|
811
|
+
if (rec.scope.sessionID !== sessionID)
|
|
812
|
+
continue;
|
|
813
|
+
abandon(rec, 'its session was forgotten');
|
|
814
|
+
attempts.delete(rec.id);
|
|
815
|
+
}
|
|
816
|
+
for (const [key, pending] of pendingRetries) {
|
|
817
|
+
if (pending.sessionID === sessionID)
|
|
818
|
+
pendingRetries.delete(key);
|
|
819
|
+
}
|
|
820
|
+
};
|
|
821
|
+
const abort = new AbortController();
|
|
822
|
+
const events = ctx.event;
|
|
823
|
+
if (events) {
|
|
824
|
+
void (async () => {
|
|
825
|
+
try {
|
|
826
|
+
for await (const event of events.subscribe({ signal: abort.signal })) {
|
|
827
|
+
if (event.type === 'session.deleted')
|
|
828
|
+
forgetSession(event.data.sessionID);
|
|
829
|
+
}
|
|
830
|
+
}
|
|
831
|
+
catch (error) {
|
|
832
|
+
if (!abort.signal.aborted) {
|
|
833
|
+
warn('opencode2 auth stopped listening for session deletion', {
|
|
834
|
+
error: describe(error),
|
|
835
|
+
});
|
|
836
|
+
}
|
|
837
|
+
}
|
|
838
|
+
})();
|
|
839
|
+
}
|
|
840
|
+
return {
|
|
841
|
+
on(event, listener) {
|
|
842
|
+
let set = listeners.get(event);
|
|
843
|
+
if (!set) {
|
|
844
|
+
set = new Set();
|
|
845
|
+
listeners.set(event, set);
|
|
846
|
+
}
|
|
847
|
+
const entry = listener;
|
|
848
|
+
set.add(entry);
|
|
849
|
+
return () => {
|
|
850
|
+
set.delete(entry);
|
|
851
|
+
};
|
|
852
|
+
},
|
|
853
|
+
accountFor(sessionID, kind) {
|
|
854
|
+
return newestOf(keyOf(sessionID, kind))?.accountId;
|
|
855
|
+
},
|
|
856
|
+
forgetSession,
|
|
857
|
+
get size() {
|
|
858
|
+
return attempts.size;
|
|
859
|
+
},
|
|
860
|
+
async dispose() {
|
|
861
|
+
if (disposed)
|
|
862
|
+
return;
|
|
863
|
+
disposed = true;
|
|
864
|
+
for (const sessionID of inFlight.keys())
|
|
865
|
+
revokeSelections(sessionID);
|
|
866
|
+
abort.abort();
|
|
867
|
+
for (const rec of attempts.values())
|
|
868
|
+
abandon(rec, 'the installation was disposed');
|
|
869
|
+
attempts.clear();
|
|
870
|
+
pendingRetries.clear();
|
|
871
|
+
ownedSockets.clear();
|
|
872
|
+
latestTransportOwned.clear();
|
|
873
|
+
listeners.clear();
|
|
874
|
+
await Promise.all(registrations.map(async (registration) => {
|
|
875
|
+
try {
|
|
876
|
+
await registration.dispose();
|
|
877
|
+
}
|
|
878
|
+
catch (error) {
|
|
879
|
+
warn('opencode2 auth hook did not dispose cleanly', {
|
|
880
|
+
error: describe(error),
|
|
881
|
+
});
|
|
882
|
+
}
|
|
883
|
+
}));
|
|
884
|
+
},
|
|
885
|
+
};
|
|
886
|
+
}
|