@cortexkit/opencode-antigravity-auth 2.2.1 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +95 -89
- package/dist/cli.js +18469 -810
- package/dist/cli.js.map +4 -4
- package/dist/cli.meta.json +4079 -0
- package/dist/index.js +40914 -16441
- package/dist/index.js.map +4 -4
- package/dist/index.meta.json +6949 -0
- package/dist/server.js +50948 -0
- package/dist/server.js.map +7 -0
- package/dist/server.meta.json +7284 -0
- package/dist/src/cli.d.ts +46 -1
- package/dist/src/cli.d.ts.map +1 -1
- package/dist/src/cli.js +207 -2
- package/dist/src/cli.js.map +1 -1
- package/dist/src/common-auth-embedded/NOTICE.txt +21 -0
- package/dist/src/common-auth-embedded/auth-menu/accounts.d.ts +97 -0
- package/dist/src/common-auth-embedded/auth-menu/accounts.js +387 -0
- package/dist/src/common-auth-embedded/auth-menu/ansi.d.ts +26 -0
- package/dist/src/common-auth-embedded/auth-menu/ansi.js +98 -0
- package/dist/src/common-auth-embedded/auth-menu/confirm.d.ts +7 -0
- package/dist/src/common-auth-embedded/auth-menu/confirm.js +21 -0
- package/dist/src/common-auth-embedded/auth-menu/doctor.d.ts +52 -0
- package/dist/src/common-auth-embedded/auth-menu/doctor.js +81 -0
- package/dist/src/common-auth-embedded/auth-menu/index.d.ts +17 -0
- package/dist/src/common-auth-embedded/auth-menu/index.js +12 -0
- package/dist/src/common-auth-embedded/auth-menu/login.d.ts +55 -0
- package/dist/src/common-auth-embedded/auth-menu/login.js +83 -0
- package/dist/src/common-auth-embedded/auth-menu/menu.d.ts +59 -0
- package/dist/src/common-auth-embedded/auth-menu/menu.js +73 -0
- package/dist/src/common-auth-embedded/auth-menu/opencode-v1.d.ts +49 -0
- package/dist/src/common-auth-embedded/auth-menu/opencode-v1.js +47 -0
- package/dist/src/common-auth-embedded/auth-menu/select.d.ts +21 -0
- package/dist/src/common-auth-embedded/auth-menu/select.js +159 -0
- package/dist/src/common-auth-embedded/auth-menu/terminal.d.ts +43 -0
- package/dist/src/common-auth-embedded/auth-menu/terminal.js +19 -0
- package/dist/src/common-auth-embedded/claustrum/consumer.d.ts +102 -0
- package/dist/src/common-auth-embedded/claustrum/consumer.js +298 -0
- package/dist/src/common-auth-embedded/claustrum/custody.d.ts +175 -0
- package/dist/src/common-auth-embedded/claustrum/custody.js +354 -0
- package/dist/src/common-auth-embedded/claustrum/enrollment.d.ts +158 -0
- package/dist/src/common-auth-embedded/claustrum/enrollment.js +759 -0
- package/dist/src/common-auth-embedded/claustrum/errors.d.ts +16 -0
- package/dist/src/common-auth-embedded/claustrum/errors.js +8 -0
- package/dist/src/common-auth-embedded/claustrum/host-slot.d.ts +39 -0
- package/dist/src/common-auth-embedded/claustrum/host-slot.js +72 -0
- package/dist/src/common-auth-embedded/claustrum/index.d.ts +18 -0
- package/dist/src/common-auth-embedded/claustrum/index.js +22 -0
- package/dist/src/common-auth-embedded/claustrum/interlock.d.ts +27 -0
- package/dist/src/common-auth-embedded/claustrum/interlock.js +29 -0
- package/dist/src/common-auth-embedded/claustrum/roster.d.ts +208 -0
- package/dist/src/common-auth-embedded/claustrum/roster.js +536 -0
- package/dist/src/common-auth-embedded/commands/builtins.d.ts +71 -0
- package/dist/src/common-auth-embedded/commands/builtins.js +534 -0
- package/dist/src/common-auth-embedded/commands/index.d.ts +10 -0
- package/dist/src/common-auth-embedded/commands/index.js +5 -0
- package/dist/src/common-auth-embedded/commands/menu.d.ts +61 -0
- package/dist/src/common-auth-embedded/commands/menu.js +300 -0
- package/dist/src/common-auth-embedded/commands/model.d.ts +238 -0
- package/dist/src/common-auth-embedded/commands/model.js +16 -0
- package/dist/src/common-auth-embedded/commands/pi.d.ts +23 -0
- package/dist/src/common-auth-embedded/commands/pi.js +206 -0
- package/dist/src/common-auth-embedded/commands/seam.d.ts +72 -0
- package/dist/src/common-auth-embedded/commands/seam.js +301 -0
- package/dist/src/common-auth-embedded/fs/atomic-write.d.ts +20 -0
- package/dist/src/common-auth-embedded/fs/atomic-write.js +80 -0
- package/dist/src/common-auth-embedded/fs/index.d.ts +7 -0
- package/dist/src/common-auth-embedded/fs/index.js +6 -0
- package/dist/src/common-auth-embedded/fs/lock-constants.d.ts +14 -0
- package/dist/src/common-auth-embedded/fs/lock-constants.js +14 -0
- package/dist/src/common-auth-embedded/fs/refresh-file-lock.d.ts +33 -0
- package/dist/src/common-auth-embedded/fs/refresh-file-lock.js +501 -0
- package/dist/src/common-auth-embedded/fs/with-lock.d.ts +33 -0
- package/dist/src/common-auth-embedded/fs/with-lock.js +48 -0
- package/dist/src/common-auth-embedded/logger/capture-sink.d.ts +14 -0
- package/dist/src/common-auth-embedded/logger/capture-sink.js +13 -0
- package/dist/src/common-auth-embedded/logger/engine.d.ts +100 -0
- package/dist/src/common-auth-embedded/logger/engine.js +246 -0
- package/dist/src/common-auth-embedded/logger/index.d.ts +6 -0
- package/dist/src/common-auth-embedded/logger/index.js +3 -0
- package/dist/src/common-auth-embedded/logger/redact.d.ts +11 -0
- package/dist/src/common-auth-embedded/logger/redact.js +83 -0
- package/dist/src/common-auth-embedded/opencode2/errors.d.ts +25 -0
- package/dist/src/common-auth-embedded/opencode2/errors.js +15 -0
- package/dist/src/common-auth-embedded/opencode2/index.d.ts +8 -0
- package/dist/src/common-auth-embedded/opencode2/index.js +4 -0
- package/dist/src/common-auth-embedded/opencode2/install.d.ts +55 -0
- package/dist/src/common-auth-embedded/opencode2/install.js +886 -0
- package/dist/src/common-auth-embedded/opencode2/integration.d.ts +112 -0
- package/dist/src/common-auth-embedded/opencode2/integration.js +143 -0
- package/dist/src/common-auth-embedded/opencode2/sse.d.ts +12 -0
- package/dist/src/common-auth-embedded/opencode2/sse.js +60 -0
- package/dist/src/common-auth-embedded/opencode2/types.d.ts +413 -0
- package/dist/src/common-auth-embedded/pi-slot/index.d.ts +3 -0
- package/dist/src/common-auth-embedded/pi-slot/index.js +2 -0
- package/dist/src/common-auth-embedded/pi-slot/lock.js +212 -0
- package/dist/src/common-auth-embedded/pi-slot/slot.d.ts +49 -0
- package/dist/src/common-auth-embedded/pi-slot/slot.js +383 -0
- package/dist/src/common-auth-embedded/quota/codec.d.ts +11 -0
- package/dist/src/common-auth-embedded/quota/codec.js +12 -0
- package/dist/src/common-auth-embedded/quota/format.d.ts +46 -0
- package/dist/src/common-auth-embedded/quota/format.js +138 -0
- package/dist/src/common-auth-embedded/quota/index.d.ts +10 -0
- package/dist/src/common-auth-embedded/quota/index.js +5 -0
- package/dist/src/common-auth-embedded/quota/map.d.ts +63 -0
- package/dist/src/common-auth-embedded/quota/map.js +105 -0
- package/dist/src/common-auth-embedded/quota/merge.d.ts +48 -0
- package/dist/src/common-auth-embedded/quota/merge.js +162 -0
- package/dist/src/common-auth-embedded/quota/projection.d.ts +64 -0
- package/dist/src/common-auth-embedded/quota/projection.js +134 -0
- package/dist/src/common-auth-embedded/routing/admission.d.ts +93 -0
- package/dist/src/common-auth-embedded/routing/admission.js +142 -0
- package/dist/src/common-auth-embedded/routing/index.d.ts +8 -0
- package/dist/src/common-auth-embedded/routing/index.js +4 -0
- package/dist/src/common-auth-embedded/routing/ordered.d.ts +47 -0
- package/dist/src/common-auth-embedded/routing/ordered.js +58 -0
- package/dist/src/common-auth-embedded/routing/pins.d.ts +22 -0
- package/dist/src/common-auth-embedded/routing/pins.js +34 -0
- package/dist/src/common-auth-embedded/routing/sticky.d.ts +158 -0
- package/dist/src/common-auth-embedded/routing/sticky.js +339 -0
- package/dist/src/common-auth-embedded/rpc/client.d.ts +3 -0
- package/dist/src/common-auth-embedded/rpc/client.js +2 -0
- package/dist/src/common-auth-embedded/rpc/index.d.ts +10 -0
- package/dist/src/common-auth-embedded/rpc/index.js +5 -0
- package/dist/src/common-auth-embedded/rpc/notifications.d.ts +73 -0
- package/dist/src/common-auth-embedded/rpc/notifications.js +100 -0
- package/dist/src/common-auth-embedded/rpc/port-file.d.ts +33 -0
- package/dist/src/common-auth-embedded/rpc/port-file.js +217 -0
- package/dist/src/common-auth-embedded/rpc/rpc-client.d.ts +30 -0
- package/dist/src/common-auth-embedded/rpc/rpc-client.js +253 -0
- package/dist/src/common-auth-embedded/rpc/rpc-server.d.ts +58 -0
- package/dist/src/common-auth-embedded/rpc/rpc-server.js +311 -0
- package/dist/src/common-auth-embedded/rpc/server-registry.d.ts +11 -0
- package/dist/src/common-auth-embedded/rpc/server-registry.js +47 -0
- package/dist/src/common-auth-embedded/source-output.json +1326 -0
- package/dist/src/common-auth-embedded/store/attribution.d.ts +28 -0
- package/dist/src/common-auth-embedded/store/attribution.js +60 -0
- package/dist/src/common-auth-embedded/store/errors.d.ts +55 -0
- package/dist/src/common-auth-embedded/store/errors.js +38 -0
- package/dist/src/common-auth-embedded/store/hooks.d.ts +12 -0
- package/dist/src/common-auth-embedded/store/hooks.js +34 -0
- package/dist/src/common-auth-embedded/store/identity.d.ts +39 -0
- package/dist/src/common-auth-embedded/store/identity.js +79 -0
- package/dist/src/common-auth-embedded/store/index.d.ts +21 -0
- package/dist/src/common-auth-embedded/store/index.js +7 -0
- package/dist/src/common-auth-embedded/store/mutate.d.ts +189 -0
- package/dist/src/common-auth-embedded/store/mutate.js +500 -0
- package/dist/src/common-auth-embedded/store/pool.d.ts +196 -0
- package/dist/src/common-auth-embedded/store/pool.js +120 -0
- package/dist/src/common-auth-embedded/store/provider-state.d.ts +131 -0
- package/dist/src/common-auth-embedded/store/provider-state.js +226 -0
- package/dist/src/common-auth-embedded/store/publication.d.ts +47 -0
- package/dist/src/common-auth-embedded/store/publication.js +304 -0
- package/dist/src/common-auth-embedded/store/pull.d.ts +36 -0
- package/dist/src/common-auth-embedded/store/pull.js +143 -0
- package/dist/src/common-auth-embedded/store/refresh-lock.d.ts +63 -0
- package/dist/src/common-auth-embedded/store/refresh-lock.js +136 -0
- package/dist/src/common-auth-embedded/store/refresh.d.ts +72 -0
- package/dist/src/common-auth-embedded/store/refresh.js +225 -0
- package/dist/src/common-auth-embedded/store/reserved.js +13 -0
- package/dist/src/common-auth-embedded/store/rows.d.ts +313 -0
- package/dist/src/common-auth-embedded/store/rows.js +1258 -0
- package/dist/src/common-auth-embedded/store/runtime.d.ts +36 -0
- package/dist/src/common-auth-embedded/store/runtime.js +68 -0
- package/dist/src/common-auth-embedded/store/schema.d.ts +443 -0
- package/dist/src/common-auth-embedded/store/schema.js +754 -0
- package/dist/src/common-auth-embedded/store/settings.d.ts +63 -0
- package/dist/src/common-auth-embedded/store/settings.js +120 -0
- package/dist/src/common-auth-embedded/store/torn.d.ts +78 -0
- package/dist/src/common-auth-embedded/store/torn.js +294 -0
- package/dist/src/common-auth-embedded/tui/index.d.ts +8 -0
- package/dist/src/common-auth-embedded/tui/index.js +21 -0
- package/dist/src/common-auth-embedded/util/any-signal.js +42 -0
- package/dist/src/constants.d.ts +1 -0
- package/dist/src/constants.d.ts.map +1 -1
- package/dist/src/constants.js +4 -0
- package/dist/src/constants.js.map +1 -1
- package/dist/src/ga/proxy-guard.d.ts +120 -0
- package/dist/src/ga/proxy-guard.d.ts.map +1 -0
- package/dist/src/ga/proxy-guard.js +269 -0
- package/dist/src/ga/proxy-guard.js.map +1 -0
- package/dist/src/ga/rpc/protocol.d.ts +504 -0
- package/dist/src/ga/rpc/protocol.d.ts.map +1 -0
- package/dist/src/ga/rpc/protocol.js +1278 -0
- package/dist/src/ga/rpc/protocol.js.map +1 -0
- package/dist/src/ga/server/auth.d.ts +9 -0
- package/dist/src/ga/server/auth.d.ts.map +1 -0
- package/dist/src/ga/server/auth.js +37 -0
- package/dist/src/ga/server/auth.js.map +1 -0
- package/dist/src/ga/server/index.d.ts +576 -0
- package/dist/src/ga/server/index.d.ts.map +1 -0
- package/dist/src/ga/server/index.js +1012 -0
- package/dist/src/ga/server/index.js.map +1 -0
- package/dist/src/ga/tui/host-ga.d.ts +350 -0
- package/dist/src/ga/tui/host-ga.d.ts.map +1 -0
- package/dist/src/ga/tui/host-ga.js +1242 -0
- package/dist/src/ga/tui/host-ga.js.map +1 -0
- package/dist/src/logging/provider-key-policy.d.ts +9 -0
- package/dist/src/logging/provider-key-policy.d.ts.map +1 -0
- package/dist/src/logging/provider-key-policy.js +11 -0
- package/dist/src/logging/provider-key-policy.js.map +1 -0
- package/dist/src/plugin/account-access.d.ts +130 -15
- package/dist/src/plugin/account-access.d.ts.map +1 -1
- package/dist/src/plugin/account-access.js +331 -129
- package/dist/src/plugin/account-access.js.map +1 -1
- package/dist/src/plugin/account-blocks.d.ts +102 -0
- package/dist/src/plugin/account-blocks.d.ts.map +1 -0
- package/dist/src/plugin/account-blocks.js +196 -0
- package/dist/src/plugin/account-blocks.js.map +1 -0
- package/dist/src/plugin/accounts.d.ts +85 -1
- package/dist/src/plugin/accounts.d.ts.map +1 -1
- package/dist/src/plugin/accounts.js +127 -3
- package/dist/src/plugin/accounts.js.map +1 -1
- package/dist/src/plugin/auth-loader.d.ts +69 -5
- package/dist/src/plugin/auth-loader.d.ts.map +1 -1
- package/dist/src/plugin/auth-loader.js +355 -52
- package/dist/src/plugin/auth-loader.js.map +1 -1
- package/dist/src/plugin/background-quota-refresh.d.ts +54 -8
- package/dist/src/plugin/background-quota-refresh.d.ts.map +1 -1
- package/dist/src/plugin/background-quota-refresh.js +81 -24
- package/dist/src/plugin/background-quota-refresh.js.map +1 -1
- package/dist/src/plugin/cache/index.d.ts +1 -1
- package/dist/src/plugin/cache/index.d.ts.map +1 -1
- package/dist/src/plugin/cache/index.js +1 -1
- package/dist/src/plugin/cache/index.js.map +1 -1
- package/dist/src/plugin/cache/signature-cache.d.ts +55 -10
- package/dist/src/plugin/cache/signature-cache.d.ts.map +1 -1
- package/dist/src/plugin/cache/signature-cache.js +100 -41
- package/dist/src/plugin/cache/signature-cache.js.map +1 -1
- package/dist/src/plugin/cache.d.ts +80 -16
- package/dist/src/plugin/cache.d.ts.map +1 -1
- package/dist/src/plugin/cache.js +339 -200
- package/dist/src/plugin/cache.js.map +1 -1
- package/dist/src/plugin/catalog.d.ts +4 -18
- package/dist/src/plugin/catalog.d.ts.map +1 -1
- package/dist/src/plugin/catalog.js +11 -41
- package/dist/src/plugin/catalog.js.map +1 -1
- package/dist/src/plugin/command-apply.d.ts +58 -0
- package/dist/src/plugin/command-apply.d.ts.map +1 -0
- package/dist/src/plugin/command-apply.js +168 -0
- package/dist/src/plugin/command-apply.js.map +1 -0
- package/dist/src/plugin/command-data.d.ts +1 -0
- package/dist/src/plugin/command-data.d.ts.map +1 -1
- package/dist/src/plugin/command-data.js +2 -0
- package/dist/src/plugin/command-data.js.map +1 -1
- package/dist/src/plugin/commands.d.ts +142 -132
- package/dist/src/plugin/commands.d.ts.map +1 -1
- package/dist/src/plugin/commands.js +214 -686
- package/dist/src/plugin/commands.js.map +1 -1
- package/dist/src/plugin/config/index.d.ts +1 -1
- package/dist/src/plugin/config/index.d.ts.map +1 -1
- package/dist/src/plugin/config/index.js +1 -1
- package/dist/src/plugin/config/index.js.map +1 -1
- package/dist/src/plugin/config/loader.d.ts +37 -1
- package/dist/src/plugin/config/loader.d.ts.map +1 -1
- package/dist/src/plugin/config/loader.js +64 -9
- package/dist/src/plugin/config/loader.js.map +1 -1
- package/dist/src/plugin/config/operator-settings-schema.d.ts +2 -2
- package/dist/src/plugin/config/schema.d.ts +2 -2
- package/dist/src/plugin/config/writer.d.ts +7 -0
- package/dist/src/plugin/config/writer.d.ts.map +1 -1
- package/dist/src/plugin/config/writer.js +10 -1
- package/dist/src/plugin/config/writer.js.map +1 -1
- package/dist/src/plugin/debug.d.ts +72 -29
- package/dist/src/plugin/debug.d.ts.map +1 -1
- package/dist/src/plugin/debug.js +353 -239
- package/dist/src/plugin/debug.js.map +1 -1
- package/dist/src/plugin/fetch/retry-state.d.ts +1 -1
- package/dist/src/plugin/fetch/retry-state.d.ts.map +1 -1
- package/dist/src/plugin/fetch/retry-state.js.map +1 -1
- package/dist/src/plugin/fetch-interceptor.d.ts +66 -11
- package/dist/src/plugin/fetch-interceptor.d.ts.map +1 -1
- package/dist/src/plugin/fetch-interceptor.js +228 -1352
- package/dist/src/plugin/fetch-interceptor.js.map +1 -1
- package/dist/src/plugin/fetch-routing.d.ts +7 -2
- package/dist/src/plugin/fetch-routing.d.ts.map +1 -1
- package/dist/src/plugin/fetch-routing.js +7 -4
- package/dist/src/plugin/fetch-routing.js.map +1 -1
- package/dist/src/plugin/ga-location-services.d.ts +389 -0
- package/dist/src/plugin/ga-location-services.d.ts.map +1 -0
- package/dist/src/plugin/ga-location-services.js +1838 -0
- package/dist/src/plugin/ga-location-services.js.map +1 -0
- package/dist/src/plugin/gemini-dump.d.ts +37 -12
- package/dist/src/plugin/gemini-dump.d.ts.map +1 -1
- package/dist/src/plugin/gemini-dump.js +42 -21
- package/dist/src/plugin/gemini-dump.js.map +1 -1
- package/dist/src/plugin/google-search-tool.d.ts +2 -1
- package/dist/src/plugin/google-search-tool.d.ts.map +1 -1
- package/dist/src/plugin/google-search-tool.js +4 -1
- package/dist/src/plugin/google-search-tool.js.map +1 -1
- package/dist/src/plugin/index.d.ts.map +1 -1
- package/dist/src/plugin/index.js +505 -141
- package/dist/src/plugin/index.js.map +1 -1
- package/dist/src/plugin/killswitch.d.ts +1 -2
- package/dist/src/plugin/killswitch.d.ts.map +1 -1
- package/dist/src/plugin/lifecycle.d.ts +24 -1
- package/dist/src/plugin/lifecycle.d.ts.map +1 -1
- package/dist/src/plugin/lifecycle.js +95 -8
- package/dist/src/plugin/lifecycle.js.map +1 -1
- package/dist/src/plugin/logger.d.ts +61 -10
- package/dist/src/plugin/logger.d.ts.map +1 -1
- package/dist/src/plugin/logger.js +134 -63
- package/dist/src/plugin/logger.js.map +1 -1
- package/dist/src/plugin/neutral-types.d.ts +42 -0
- package/dist/src/plugin/neutral-types.d.ts.map +1 -0
- package/dist/src/plugin/neutral-types.js +12 -0
- package/dist/src/plugin/neutral-types.js.map +1 -0
- package/dist/src/plugin/oauth-methods.d.ts +2 -1
- package/dist/src/plugin/oauth-methods.d.ts.map +1 -1
- package/dist/src/plugin/oauth-methods.js +173 -88
- package/dist/src/plugin/oauth-methods.js.map +1 -1
- package/dist/src/plugin/operator-settings.d.ts +34 -0
- package/dist/src/plugin/operator-settings.d.ts.map +1 -1
- package/dist/src/plugin/operator-settings.js +105 -2
- package/dist/src/plugin/operator-settings.js.map +1 -1
- package/dist/src/plugin/persist-account-pool.d.ts +63 -2
- package/dist/src/plugin/persist-account-pool.d.ts.map +1 -1
- package/dist/src/plugin/persist-account-pool.js +125 -2
- package/dist/src/plugin/persist-account-pool.js.map +1 -1
- package/dist/src/plugin/quota.d.ts +335 -35
- package/dist/src/plugin/quota.d.ts.map +1 -1
- package/dist/src/plugin/quota.js +825 -95
- package/dist/src/plugin/quota.js.map +1 -1
- package/dist/src/plugin/refresh-queue.d.ts +35 -5
- package/dist/src/plugin/refresh-queue.d.ts.map +1 -1
- package/dist/src/plugin/refresh-queue.js +50 -16
- package/dist/src/plugin/refresh-queue.js.map +1 -1
- package/dist/src/plugin/request-helpers.d.ts +30 -5
- package/dist/src/plugin/request-helpers.d.ts.map +1 -1
- package/dist/src/plugin/request-helpers.js +82 -17
- package/dist/src/plugin/request-helpers.js.map +1 -1
- package/dist/src/plugin/request.d.ts +63 -15
- package/dist/src/plugin/request.d.ts.map +1 -1
- package/dist/src/plugin/request.js +190 -60
- package/dist/src/plugin/request.js.map +1 -1
- package/dist/src/plugin/session-context.d.ts.map +1 -1
- package/dist/src/plugin/session-context.js +5 -2
- package/dist/src/plugin/session-context.js.map +1 -1
- package/dist/src/plugin/shared/local-grant.d.ts +26 -0
- package/dist/src/plugin/shared/local-grant.d.ts.map +1 -0
- package/dist/src/plugin/shared/local-grant.js +19 -0
- package/dist/src/plugin/shared/local-grant.js.map +1 -0
- package/dist/src/plugin/shared/request-cancellation.d.ts +12 -0
- package/dist/src/plugin/shared/request-cancellation.d.ts.map +1 -0
- package/dist/src/plugin/shared/request-cancellation.js +118 -0
- package/dist/src/plugin/shared/request-cancellation.js.map +1 -0
- package/dist/src/plugin/shared/request-services.d.ts +375 -0
- package/dist/src/plugin/shared/request-services.d.ts.map +1 -0
- package/dist/src/plugin/shared/request-services.js +1743 -0
- package/dist/src/plugin/shared/request-services.js.map +1 -0
- package/dist/src/plugin/shared/runtime.d.ts +217 -0
- package/dist/src/plugin/shared/runtime.d.ts.map +1 -0
- package/dist/src/plugin/shared/runtime.js +345 -0
- package/dist/src/plugin/shared/runtime.js.map +1 -0
- package/dist/src/plugin/shared/source-sidebar.d.ts +15 -0
- package/dist/src/plugin/shared/source-sidebar.d.ts.map +1 -0
- package/dist/src/plugin/shared/source-sidebar.js +41 -0
- package/dist/src/plugin/shared/source-sidebar.js.map +1 -0
- package/dist/src/plugin/shared/vault-menu.d.ts +5 -0
- package/dist/src/plugin/shared/vault-menu.d.ts.map +1 -0
- package/dist/src/plugin/shared/vault-menu.js +49 -0
- package/dist/src/plugin/shared/vault-menu.js.map +1 -0
- package/dist/src/plugin/shared/vault-request-credentials.d.ts +168 -0
- package/dist/src/plugin/shared/vault-request-credentials.d.ts.map +1 -0
- package/dist/src/plugin/shared/vault-request-credentials.js +485 -0
- package/dist/src/plugin/shared/vault-request-credentials.js.map +1 -0
- package/dist/src/plugin/storage.d.ts +127 -1
- package/dist/src/plugin/storage.d.ts.map +1 -1
- package/dist/src/plugin/storage.js +188 -3
- package/dist/src/plugin/storage.js.map +1 -1
- package/dist/src/plugin/token.d.ts +23 -1
- package/dist/src/plugin/token.d.ts.map +1 -1
- package/dist/src/plugin/token.js +117 -58
- package/dist/src/plugin/token.js.map +1 -1
- package/dist/src/plugin/ui/quota-status.d.ts +1 -10
- package/dist/src/plugin/ui/quota-status.d.ts.map +1 -1
- package/dist/src/plugin/ui/quota-status.js +6 -42
- package/dist/src/plugin/ui/quota-status.js.map +1 -1
- package/dist/src/plugin/vault-activation.d.ts +11 -0
- package/dist/src/plugin/vault-activation.d.ts.map +1 -0
- package/dist/src/plugin/vault-activation.js +53 -0
- package/dist/src/plugin/vault-activation.js.map +1 -0
- package/dist/src/plugin/vault-custody.d.ts +131 -0
- package/dist/src/plugin/vault-custody.d.ts.map +1 -0
- package/dist/src/plugin/vault-custody.js +381 -0
- package/dist/src/plugin/vault-custody.js.map +1 -0
- package/dist/src/quota-presentation.d.ts +18 -0
- package/dist/src/quota-presentation.d.ts.map +1 -0
- package/dist/src/quota-presentation.js +58 -0
- package/dist/src/quota-presentation.js.map +1 -0
- package/dist/src/rpc/notifications.d.ts +2 -2
- package/dist/src/rpc/notifications.d.ts.map +1 -1
- package/dist/src/rpc/notifications.js +1 -1
- package/dist/src/rpc/notifications.js.map +1 -1
- package/dist/src/rpc/port-file.d.ts +2 -12
- package/dist/src/rpc/port-file.d.ts.map +1 -1
- package/dist/src/rpc/port-file.js +5 -107
- package/dist/src/rpc/port-file.js.map +1 -1
- package/dist/src/rpc/protocol.d.ts +47 -16
- package/dist/src/rpc/protocol.d.ts.map +1 -1
- package/dist/src/rpc/rpc-client.d.ts +27 -3
- package/dist/src/rpc/rpc-client.d.ts.map +1 -1
- package/dist/src/rpc/rpc-client.js +55 -45
- package/dist/src/rpc/rpc-client.js.map +1 -1
- package/dist/src/rpc/rpc-server.d.ts +13 -2
- package/dist/src/rpc/rpc-server.d.ts.map +1 -1
- package/dist/src/rpc/rpc-server.js +38 -212
- package/dist/src/rpc/rpc-server.js.map +1 -1
- package/dist/src/server.d.ts +30 -0
- package/dist/src/server.d.ts.map +1 -0
- package/dist/src/server.js +29 -0
- package/dist/src/server.js.map +1 -0
- package/dist/src/sidebar-projection.d.ts +102 -0
- package/dist/src/sidebar-projection.d.ts.map +1 -0
- package/dist/src/sidebar-projection.js +146 -0
- package/dist/src/sidebar-projection.js.map +1 -0
- package/dist/src/sidebar-state.d.ts +13 -5
- package/dist/src/sidebar-state.d.ts.map +1 -1
- package/dist/src/sidebar-state.js +49 -16
- package/dist/src/sidebar-state.js.map +1 -1
- package/dist/src/tui/command-dialogs.d.ts +58 -52
- package/dist/src/tui/command-dialogs.d.ts.map +1 -1
- package/dist/src/tui/command-dialogs.js +379 -571
- package/dist/src/tui/command-dialogs.js.map +1 -1
- package/dist/src/tui/file-logger.d.ts +2 -3
- package/dist/src/tui/file-logger.d.ts.map +1 -1
- package/dist/src/tui/file-logger.js +21 -7
- package/dist/src/tui/file-logger.js.map +1 -1
- package/dist/src/tui/host-api.d.ts +196 -0
- package/dist/src/tui/host-api.d.ts.map +1 -0
- package/dist/src/tui/host-api.js +357 -0
- package/dist/src/tui/host-api.js.map +1 -0
- package/dist/src/tui/host-v1.d.ts +60 -0
- package/dist/src/tui/host-v1.d.ts.map +1 -0
- package/dist/src/tui/host-v1.js +147 -0
- package/dist/src/tui/host-v1.js.map +1 -0
- package/dist/src/tui/vault-setup.d.ts +98 -0
- package/dist/src/tui/vault-setup.d.ts.map +1 -0
- package/dist/src/tui/vault-setup.js +198 -0
- package/dist/src/tui/vault-setup.js.map +1 -0
- package/dist/src/tui.d.ts +4 -11
- package/dist/src/tui.d.ts.map +1 -1
- package/dist/src/tui.js +33 -75
- package/dist/src/tui.js.map +1 -1
- package/dist/tui-build-map.json +380 -0
- package/dist/tui-ga-build-map.json +187 -0
- package/dist/types/src/antigravity/oauth.d.ts +2 -0
- package/dist/types/src/antigravity/oauth.d.ts.map +1 -0
- package/dist/types/src/cli.d.ts +66 -0
- package/dist/types/src/cli.d.ts.map +1 -0
- package/dist/types/src/common-auth-embedded/commands/builtins.d.ts +71 -0
- package/dist/types/src/common-auth-embedded/commands/index.d.ts +10 -0
- package/dist/types/src/common-auth-embedded/commands/menu.d.ts +61 -0
- package/dist/types/src/common-auth-embedded/commands/model.d.ts +238 -0
- package/dist/types/src/common-auth-embedded/commands/pi.d.ts +23 -0
- package/dist/types/src/common-auth-embedded/commands/seam.d.ts +72 -0
- package/dist/types/src/common-auth-embedded/fs/refresh-file-lock.d.ts +33 -0
- package/dist/types/src/common-auth-embedded/logger/capture-sink.d.ts +14 -0
- package/dist/types/src/common-auth-embedded/logger/engine.d.ts +100 -0
- package/dist/types/src/common-auth-embedded/logger/index.d.ts +6 -0
- package/dist/types/src/common-auth-embedded/logger/redact.d.ts +11 -0
- package/dist/types/src/common-auth-embedded/quota/codec.d.ts +11 -0
- package/dist/types/src/common-auth-embedded/quota/format.d.ts +46 -0
- package/dist/types/src/common-auth-embedded/quota/index.d.ts +10 -0
- package/dist/types/src/common-auth-embedded/quota/map.d.ts +63 -0
- package/dist/types/src/common-auth-embedded/quota/merge.d.ts +48 -0
- package/dist/types/src/common-auth-embedded/quota/projection.d.ts +64 -0
- package/dist/types/src/common-auth-embedded/store/attribution.d.ts +28 -0
- package/dist/types/src/common-auth-embedded/store/errors.d.ts +55 -0
- package/dist/types/src/common-auth-embedded/store/hooks.d.ts +12 -0
- package/dist/types/src/common-auth-embedded/store/identity.d.ts +39 -0
- package/dist/types/src/common-auth-embedded/store/index.d.ts +21 -0
- package/dist/types/src/common-auth-embedded/store/mutate.d.ts +189 -0
- package/dist/types/src/common-auth-embedded/store/pool.d.ts +196 -0
- package/dist/types/src/common-auth-embedded/store/provider-state.d.ts +131 -0
- package/dist/types/src/common-auth-embedded/store/publication.d.ts +47 -0
- package/dist/types/src/common-auth-embedded/store/pull.d.ts +36 -0
- package/dist/types/src/common-auth-embedded/store/refresh-lock.d.ts +63 -0
- package/dist/types/src/common-auth-embedded/store/refresh.d.ts +72 -0
- package/dist/types/src/common-auth-embedded/store/rows.d.ts +313 -0
- package/dist/types/src/common-auth-embedded/store/runtime.d.ts +36 -0
- package/dist/types/src/common-auth-embedded/store/schema.d.ts +443 -0
- package/dist/types/src/common-auth-embedded/store/settings.d.ts +63 -0
- package/dist/types/src/common-auth-embedded/store/torn.d.ts +78 -0
- package/dist/types/src/constants.d.ts +3 -0
- package/dist/types/src/constants.d.ts.map +1 -0
- package/dist/types/src/ga/proxy-guard.d.ts +120 -0
- package/dist/types/src/ga/proxy-guard.d.ts.map +1 -0
- package/dist/types/src/ga/rpc/protocol.d.ts +504 -0
- package/dist/types/src/ga/rpc/protocol.d.ts.map +1 -0
- package/dist/types/src/ga/server/auth.d.ts +9 -0
- package/dist/types/src/ga/server/auth.d.ts.map +1 -0
- package/dist/types/src/ga/server/index.d.ts +576 -0
- package/dist/types/src/ga/server/index.d.ts.map +1 -0
- package/dist/types/src/hooks/auto-update-checker/cache.d.ts +3 -0
- package/dist/types/src/hooks/auto-update-checker/cache.d.ts.map +1 -0
- package/dist/types/src/hooks/auto-update-checker/checker.d.ts +16 -0
- package/dist/types/src/hooks/auto-update-checker/checker.d.ts.map +1 -0
- package/dist/types/src/hooks/auto-update-checker/constants.d.ts +9 -0
- package/dist/types/src/hooks/auto-update-checker/constants.d.ts.map +1 -0
- package/dist/types/src/hooks/auto-update-checker/index.d.ts +34 -0
- package/dist/types/src/hooks/auto-update-checker/index.d.ts.map +1 -0
- package/dist/types/src/hooks/auto-update-checker/logging.d.ts +3 -0
- package/dist/types/src/hooks/auto-update-checker/logging.d.ts.map +1 -0
- package/dist/types/src/hooks/auto-update-checker/types.d.ts +25 -0
- package/dist/types/src/hooks/auto-update-checker/types.d.ts.map +1 -0
- package/dist/types/src/logging/provider-key-policy.d.ts +9 -0
- package/dist/types/src/logging/provider-key-policy.d.ts.map +1 -0
- package/dist/types/src/plugin/account-access.d.ts +214 -0
- package/dist/types/src/plugin/account-access.d.ts.map +1 -0
- package/dist/types/src/plugin/account-blocks.d.ts +102 -0
- package/dist/types/src/plugin/account-blocks.d.ts.map +1 -0
- package/dist/types/src/plugin/account-command-oauth.d.ts +34 -0
- package/dist/types/src/plugin/account-command-oauth.d.ts.map +1 -0
- package/dist/types/src/plugin/accounts.d.ts +94 -0
- package/dist/types/src/plugin/accounts.d.ts.map +1 -0
- package/dist/types/src/plugin/agy-request-metadata.d.ts +2 -0
- package/dist/types/src/plugin/agy-request-metadata.d.ts.map +1 -0
- package/dist/types/src/plugin/agy-transport.d.ts +2 -0
- package/dist/types/src/plugin/agy-transport.d.ts.map +1 -0
- package/dist/types/src/plugin/auth-doctor.d.ts +30 -0
- package/dist/types/src/plugin/auth-doctor.d.ts.map +1 -0
- package/dist/types/src/plugin/auth-drift.d.ts +13 -0
- package/dist/types/src/plugin/auth-drift.d.ts.map +1 -0
- package/dist/types/src/plugin/auth-loader.d.ts +114 -0
- package/dist/types/src/plugin/auth-loader.d.ts.map +1 -0
- package/dist/types/src/plugin/auth.d.ts +2 -0
- package/dist/types/src/plugin/auth.d.ts.map +1 -0
- package/dist/types/src/plugin/background-quota-refresh.d.ts +192 -0
- package/dist/types/src/plugin/background-quota-refresh.d.ts.map +1 -0
- package/dist/types/src/plugin/cache/signature-cache.d.ts +156 -0
- package/dist/types/src/plugin/cache/signature-cache.d.ts.map +1 -0
- package/dist/types/src/plugin/cache.d.ts +109 -0
- package/dist/types/src/plugin/cache.d.ts.map +1 -0
- package/dist/types/src/plugin/catalog.d.ts +9 -0
- package/dist/types/src/plugin/catalog.d.ts.map +1 -0
- package/dist/types/src/plugin/cli.d.ts +44 -0
- package/dist/types/src/plugin/cli.d.ts.map +1 -0
- package/dist/types/src/plugin/command-apply.d.ts +58 -0
- package/dist/types/src/plugin/command-apply.d.ts.map +1 -0
- package/dist/types/src/plugin/command-data.d.ts +330 -0
- package/dist/types/src/plugin/command-data.d.ts.map +1 -0
- package/dist/types/src/plugin/commands.d.ts +164 -0
- package/dist/types/src/plugin/commands.d.ts.map +1 -0
- package/dist/types/src/plugin/config/index.d.ts +16 -0
- package/dist/types/src/plugin/config/index.d.ts.map +1 -0
- package/dist/types/src/plugin/config/loader.d.ts +72 -0
- package/dist/types/src/plugin/config/loader.d.ts.map +1 -0
- package/dist/types/src/plugin/config/models.d.ts +3 -0
- package/dist/types/src/plugin/config/models.d.ts.map +1 -0
- package/dist/types/src/plugin/config/operator-settings-schema.d.ts +29 -0
- package/dist/types/src/plugin/config/operator-settings-schema.d.ts.map +1 -0
- package/dist/types/src/plugin/config/schema.d.ts +162 -0
- package/dist/types/src/plugin/config/schema.d.ts.map +1 -0
- package/dist/types/src/plugin/config/updater.d.ts +55 -0
- package/dist/types/src/plugin/config/updater.d.ts.map +1 -0
- package/dist/types/src/plugin/config/writer.d.ts +41 -0
- package/dist/types/src/plugin/config/writer.d.ts.map +1 -0
- package/dist/types/src/plugin/core/streaming/index.d.ts +3 -0
- package/dist/types/src/plugin/core/streaming/index.d.ts.map +1 -0
- package/dist/types/src/plugin/core/streaming/transformer.d.ts +12 -0
- package/dist/types/src/plugin/core/streaming/transformer.d.ts.map +1 -0
- package/dist/types/src/plugin/core/streaming/types.d.ts +34 -0
- package/dist/types/src/plugin/core/streaming/types.d.ts.map +1 -0
- package/dist/types/src/plugin/debug.d.ts +144 -0
- package/dist/types/src/plugin/debug.d.ts.map +1 -0
- package/dist/types/src/plugin/dependencies.d.ts +129 -0
- package/dist/types/src/plugin/dependencies.d.ts.map +1 -0
- package/dist/types/src/plugin/errors.d.ts +55 -0
- package/dist/types/src/plugin/errors.d.ts.map +1 -0
- package/dist/types/src/plugin/event-handler.d.ts +53 -0
- package/dist/types/src/plugin/event-handler.d.ts.map +1 -0
- package/dist/types/src/plugin/fetch/retry-state.d.ts +61 -0
- package/dist/types/src/plugin/fetch/retry-state.d.ts.map +1 -0
- package/dist/types/src/plugin/fetch/warmup.d.ts +30 -0
- package/dist/types/src/plugin/fetch/warmup.d.ts.map +1 -0
- package/dist/types/src/plugin/fetch-interceptor.d.ts +114 -0
- package/dist/types/src/plugin/fetch-interceptor.d.ts.map +1 -0
- package/dist/types/src/plugin/fetch-routing.d.ts +31 -0
- package/dist/types/src/plugin/fetch-routing.d.ts.map +1 -0
- package/dist/types/src/plugin/fingerprint.d.ts +2 -0
- package/dist/types/src/plugin/fingerprint.d.ts.map +1 -0
- package/dist/types/src/plugin/ga-location-services.d.ts +389 -0
- package/dist/types/src/plugin/ga-location-services.d.ts.map +1 -0
- package/dist/types/src/plugin/gemini-dump.d.ts +72 -0
- package/dist/types/src/plugin/gemini-dump.d.ts.map +1 -0
- package/dist/types/src/plugin/google-search-tool.d.ts +10 -0
- package/dist/types/src/plugin/google-search-tool.d.ts.map +1 -0
- package/dist/types/src/plugin/image-saver.d.ts +6 -0
- package/dist/types/src/plugin/image-saver.d.ts.map +1 -0
- package/dist/types/src/plugin/index.d.ts +30 -0
- package/dist/types/src/plugin/index.d.ts.map +1 -0
- package/dist/types/src/plugin/killswitch.d.ts +93 -0
- package/dist/types/src/plugin/killswitch.d.ts.map +1 -0
- package/dist/types/src/plugin/lifecycle.d.ts +63 -0
- package/dist/types/src/plugin/lifecycle.d.ts.map +1 -0
- package/dist/types/src/plugin/logger.d.ts +83 -0
- package/dist/types/src/plugin/logger.d.ts.map +1 -0
- package/dist/types/src/plugin/logging-utils.d.ts +57 -0
- package/dist/types/src/plugin/logging-utils.d.ts.map +1 -0
- package/dist/types/src/plugin/model-registry.d.ts +2 -0
- package/dist/types/src/plugin/model-registry.d.ts.map +1 -0
- package/dist/types/src/plugin/neutral-types.d.ts +42 -0
- package/dist/types/src/plugin/neutral-types.d.ts.map +1 -0
- package/dist/types/src/plugin/oauth-login.d.ts +22 -0
- package/dist/types/src/plugin/oauth-login.d.ts.map +1 -0
- package/dist/types/src/plugin/oauth-methods.d.ts +43 -0
- package/dist/types/src/plugin/oauth-methods.d.ts.map +1 -0
- package/dist/types/src/plugin/operator-settings.d.ts +74 -0
- package/dist/types/src/plugin/operator-settings.d.ts.map +1 -0
- package/dist/types/src/plugin/persist-account-pool.d.ts +98 -0
- package/dist/types/src/plugin/persist-account-pool.d.ts.map +1 -0
- package/dist/types/src/plugin/project.d.ts +2 -0
- package/dist/types/src/plugin/project.d.ts.map +1 -0
- package/dist/types/src/plugin/prompt-context.d.ts +18 -0
- package/dist/types/src/plugin/prompt-context.d.ts.map +1 -0
- package/dist/types/src/plugin/quota.d.ts +441 -0
- package/dist/types/src/plugin/quota.d.ts.map +1 -0
- package/dist/types/src/plugin/recovery/constants.d.ts +22 -0
- package/dist/types/src/plugin/recovery/constants.d.ts.map +1 -0
- package/dist/types/src/plugin/recovery/storage.d.ts +24 -0
- package/dist/types/src/plugin/recovery/storage.d.ts.map +1 -0
- package/dist/types/src/plugin/recovery/types.d.ts +116 -0
- package/dist/types/src/plugin/recovery/types.d.ts.map +1 -0
- package/dist/types/src/plugin/recovery.d.ts +61 -0
- package/dist/types/src/plugin/recovery.d.ts.map +1 -0
- package/dist/types/src/plugin/refresh-queue.d.ts +133 -0
- package/dist/types/src/plugin/refresh-queue.d.ts.map +1 -0
- package/dist/types/src/plugin/request-helpers.d.ts +304 -0
- package/dist/types/src/plugin/request-helpers.d.ts.map +1 -0
- package/dist/types/src/plugin/request.d.ts +161 -0
- package/dist/types/src/plugin/request.d.ts.map +1 -0
- package/dist/types/src/plugin/rotation.d.ts +2 -0
- package/dist/types/src/plugin/rotation.d.ts.map +1 -0
- package/dist/types/src/plugin/search.d.ts +25 -0
- package/dist/types/src/plugin/search.d.ts.map +1 -0
- package/dist/types/src/plugin/server.d.ts +23 -0
- package/dist/types/src/plugin/server.d.ts.map +1 -0
- package/dist/types/src/plugin/session-context.d.ts +22 -0
- package/dist/types/src/plugin/session-context.d.ts.map +1 -0
- package/dist/types/src/plugin/shared/local-grant.d.ts +26 -0
- package/dist/types/src/plugin/shared/local-grant.d.ts.map +1 -0
- package/dist/types/src/plugin/shared/request-cancellation.d.ts +12 -0
- package/dist/types/src/plugin/shared/request-cancellation.d.ts.map +1 -0
- package/dist/types/src/plugin/shared/request-services.d.ts +375 -0
- package/dist/types/src/plugin/shared/request-services.d.ts.map +1 -0
- package/dist/types/src/plugin/shared/runtime.d.ts +217 -0
- package/dist/types/src/plugin/shared/runtime.d.ts.map +1 -0
- package/dist/types/src/plugin/shared/source-sidebar.d.ts +15 -0
- package/dist/types/src/plugin/shared/source-sidebar.d.ts.map +1 -0
- package/dist/types/src/plugin/shared/vault-menu.d.ts +5 -0
- package/dist/types/src/plugin/shared/vault-menu.d.ts.map +1 -0
- package/dist/types/src/plugin/shared/vault-request-credentials.d.ts +168 -0
- package/dist/types/src/plugin/shared/vault-request-credentials.d.ts.map +1 -0
- package/dist/types/src/plugin/storage.d.ts +221 -0
- package/dist/types/src/plugin/storage.d.ts.map +1 -0
- package/dist/types/src/plugin/stores/signature-store.d.ts +5 -0
- package/dist/types/src/plugin/stores/signature-store.d.ts.map +1 -0
- package/dist/types/src/plugin/thinking-recovery.d.ts +90 -0
- package/dist/types/src/plugin/thinking-recovery.d.ts.map +1 -0
- package/dist/types/src/plugin/token.d.ts +41 -0
- package/dist/types/src/plugin/token.d.ts.map +1 -0
- package/dist/types/src/plugin/transform/cross-model-sanitizer.d.ts +2 -0
- package/dist/types/src/plugin/transform/cross-model-sanitizer.d.ts.map +1 -0
- package/dist/types/src/plugin/transform/index.d.ts +2 -0
- package/dist/types/src/plugin/transform/index.d.ts.map +1 -0
- package/dist/types/src/plugin/transform/model-resolver.d.ts +2 -0
- package/dist/types/src/plugin/transform/model-resolver.d.ts.map +1 -0
- package/dist/types/src/plugin/transform/types.d.ts +2 -0
- package/dist/types/src/plugin/transform/types.d.ts.map +1 -0
- package/dist/types/src/plugin/types.d.ts +36 -0
- package/dist/types/src/plugin/types.d.ts.map +1 -0
- package/dist/types/src/plugin/ui/ansi.d.ts +32 -0
- package/dist/types/src/plugin/ui/ansi.d.ts.map +1 -0
- package/dist/types/src/plugin/ui/auth-menu.d.ts +59 -0
- package/dist/types/src/plugin/ui/auth-menu.d.ts.map +1 -0
- package/dist/types/src/plugin/ui/confirm.d.ts +2 -0
- package/dist/types/src/plugin/ui/confirm.d.ts.map +1 -0
- package/dist/types/src/plugin/ui/quota-status.d.ts +73 -0
- package/dist/types/src/plugin/ui/quota-status.d.ts.map +1 -0
- package/dist/types/src/plugin/ui/select.d.ts +23 -0
- package/dist/types/src/plugin/ui/select.d.ts.map +1 -0
- package/dist/types/src/plugin/vault-activation.d.ts +11 -0
- package/dist/types/src/plugin/vault-activation.d.ts.map +1 -0
- package/dist/types/src/plugin/vault-custody.d.ts +131 -0
- package/dist/types/src/plugin/vault-custody.d.ts.map +1 -0
- package/dist/types/src/plugin/version.d.ts +2 -0
- package/dist/types/src/plugin/version.d.ts.map +1 -0
- package/dist/types/src/quota-presentation.d.ts +18 -0
- package/dist/types/src/quota-presentation.d.ts.map +1 -0
- package/dist/types/src/rpc/notifications.d.ts +6 -0
- package/dist/types/src/rpc/notifications.d.ts.map +1 -0
- package/dist/types/src/rpc/protocol.d.ts +53 -0
- package/dist/types/src/rpc/protocol.d.ts.map +1 -0
- package/dist/types/src/rpc/rpc-dir.d.ts +4 -0
- package/dist/types/src/rpc/rpc-dir.d.ts.map +1 -0
- package/dist/types/src/rpc/rpc-server.d.ts +24 -0
- package/dist/types/src/rpc/rpc-server.d.ts.map +1 -0
- package/dist/types/src/server.d.ts +30 -0
- package/dist/types/src/server.d.ts.map +1 -0
- package/dist/types/src/sidebar-state.d.ts +365 -0
- package/dist/types/src/sidebar-state.d.ts.map +1 -0
- package/dist/types/src/tui/host-api.d.ts +196 -0
- package/dist/types/src/tui/host-api.d.ts.map +1 -0
- package/package.json +45 -18
- package/server.js +6 -0
- package/src/common-auth-embedded/NOTICE.txt +21 -0
- package/src/common-auth-embedded/auth-menu/accounts.d.ts +97 -0
- package/src/common-auth-embedded/auth-menu/accounts.js +387 -0
- package/src/common-auth-embedded/auth-menu/ansi.d.ts +26 -0
- package/src/common-auth-embedded/auth-menu/ansi.js +98 -0
- package/src/common-auth-embedded/auth-menu/confirm.d.ts +7 -0
- package/src/common-auth-embedded/auth-menu/confirm.js +21 -0
- package/src/common-auth-embedded/auth-menu/doctor.d.ts +52 -0
- package/src/common-auth-embedded/auth-menu/doctor.js +81 -0
- package/src/common-auth-embedded/auth-menu/index.d.ts +17 -0
- package/src/common-auth-embedded/auth-menu/index.js +12 -0
- package/src/common-auth-embedded/auth-menu/login.d.ts +55 -0
- package/src/common-auth-embedded/auth-menu/login.js +83 -0
- package/src/common-auth-embedded/auth-menu/menu.d.ts +59 -0
- package/src/common-auth-embedded/auth-menu/menu.js +73 -0
- package/src/common-auth-embedded/auth-menu/opencode-v1.d.ts +49 -0
- package/src/common-auth-embedded/auth-menu/opencode-v1.js +47 -0
- package/src/common-auth-embedded/auth-menu/select.d.ts +21 -0
- package/src/common-auth-embedded/auth-menu/select.js +159 -0
- package/src/common-auth-embedded/auth-menu/terminal.d.ts +43 -0
- package/src/common-auth-embedded/auth-menu/terminal.js +19 -0
- package/src/common-auth-embedded/claustrum/consumer.d.ts +102 -0
- package/src/common-auth-embedded/claustrum/consumer.js +298 -0
- package/src/common-auth-embedded/claustrum/custody.d.ts +175 -0
- package/src/common-auth-embedded/claustrum/custody.js +354 -0
- package/src/common-auth-embedded/claustrum/enrollment.d.ts +158 -0
- package/src/common-auth-embedded/claustrum/enrollment.js +759 -0
- package/src/common-auth-embedded/claustrum/errors.d.ts +16 -0
- package/src/common-auth-embedded/claustrum/errors.js +8 -0
- package/src/common-auth-embedded/claustrum/host-slot.d.ts +39 -0
- package/src/common-auth-embedded/claustrum/host-slot.js +72 -0
- package/src/common-auth-embedded/claustrum/index.d.ts +18 -0
- package/src/common-auth-embedded/claustrum/index.js +22 -0
- package/src/common-auth-embedded/claustrum/interlock.d.ts +27 -0
- package/src/common-auth-embedded/claustrum/interlock.js +29 -0
- package/src/common-auth-embedded/claustrum/roster.d.ts +208 -0
- package/src/common-auth-embedded/claustrum/roster.js +536 -0
- package/src/common-auth-embedded/commands/builtins.d.ts +71 -0
- package/src/common-auth-embedded/commands/builtins.js +534 -0
- package/src/common-auth-embedded/commands/index.d.ts +10 -0
- package/src/common-auth-embedded/commands/index.js +5 -0
- package/src/common-auth-embedded/commands/menu.d.ts +61 -0
- package/src/common-auth-embedded/commands/menu.js +300 -0
- package/src/common-auth-embedded/commands/model.d.ts +238 -0
- package/src/common-auth-embedded/commands/model.js +16 -0
- package/src/common-auth-embedded/commands/pi.d.ts +23 -0
- package/src/common-auth-embedded/commands/pi.js +206 -0
- package/src/common-auth-embedded/commands/seam.d.ts +72 -0
- package/src/common-auth-embedded/commands/seam.js +301 -0
- package/src/common-auth-embedded/fs/atomic-write.d.ts +20 -0
- package/src/common-auth-embedded/fs/atomic-write.js +80 -0
- package/src/common-auth-embedded/fs/index.d.ts +7 -0
- package/src/common-auth-embedded/fs/index.js +6 -0
- package/src/common-auth-embedded/fs/lock-constants.d.ts +14 -0
- package/src/common-auth-embedded/fs/lock-constants.js +14 -0
- package/src/common-auth-embedded/fs/refresh-file-lock.d.ts +33 -0
- package/src/common-auth-embedded/fs/refresh-file-lock.js +501 -0
- package/src/common-auth-embedded/fs/with-lock.d.ts +33 -0
- package/src/common-auth-embedded/fs/with-lock.js +48 -0
- package/src/common-auth-embedded/logger/capture-sink.d.ts +14 -0
- package/src/common-auth-embedded/logger/capture-sink.js +13 -0
- package/src/common-auth-embedded/logger/engine.d.ts +100 -0
- package/src/common-auth-embedded/logger/engine.js +246 -0
- package/src/common-auth-embedded/logger/index.d.ts +6 -0
- package/src/common-auth-embedded/logger/index.js +3 -0
- package/src/common-auth-embedded/logger/redact.d.ts +11 -0
- package/src/common-auth-embedded/logger/redact.js +83 -0
- package/src/common-auth-embedded/opencode2/errors.d.ts +25 -0
- package/src/common-auth-embedded/opencode2/errors.js +15 -0
- package/src/common-auth-embedded/opencode2/index.d.ts +8 -0
- package/src/common-auth-embedded/opencode2/index.js +4 -0
- package/src/common-auth-embedded/opencode2/install.d.ts +55 -0
- package/src/common-auth-embedded/opencode2/install.js +886 -0
- package/src/common-auth-embedded/opencode2/integration.d.ts +112 -0
- package/src/common-auth-embedded/opencode2/integration.js +143 -0
- package/src/common-auth-embedded/opencode2/sse.d.ts +12 -0
- package/src/common-auth-embedded/opencode2/sse.js +60 -0
- package/src/common-auth-embedded/opencode2/types.d.ts +413 -0
- package/src/common-auth-embedded/pi-slot/index.d.ts +3 -0
- package/src/common-auth-embedded/pi-slot/index.js +2 -0
- package/src/common-auth-embedded/pi-slot/lock.js +212 -0
- package/src/common-auth-embedded/pi-slot/slot.d.ts +49 -0
- package/src/common-auth-embedded/pi-slot/slot.js +383 -0
- package/src/common-auth-embedded/quota/codec.d.ts +11 -0
- package/src/common-auth-embedded/quota/codec.js +12 -0
- package/src/common-auth-embedded/quota/format.d.ts +46 -0
- package/src/common-auth-embedded/quota/format.js +138 -0
- package/src/common-auth-embedded/quota/index.d.ts +10 -0
- package/src/common-auth-embedded/quota/index.js +5 -0
- package/src/common-auth-embedded/quota/map.d.ts +63 -0
- package/src/common-auth-embedded/quota/map.js +105 -0
- package/src/common-auth-embedded/quota/merge.d.ts +48 -0
- package/src/common-auth-embedded/quota/merge.js +162 -0
- package/src/common-auth-embedded/quota/projection.d.ts +64 -0
- package/src/common-auth-embedded/quota/projection.js +134 -0
- package/src/common-auth-embedded/routing/admission.d.ts +93 -0
- package/src/common-auth-embedded/routing/admission.js +142 -0
- package/src/common-auth-embedded/routing/index.d.ts +8 -0
- package/src/common-auth-embedded/routing/index.js +4 -0
- package/src/common-auth-embedded/routing/ordered.d.ts +47 -0
- package/src/common-auth-embedded/routing/ordered.js +58 -0
- package/src/common-auth-embedded/routing/pins.d.ts +22 -0
- package/src/common-auth-embedded/routing/pins.js +34 -0
- package/src/common-auth-embedded/routing/sticky.d.ts +158 -0
- package/src/common-auth-embedded/routing/sticky.js +339 -0
- package/src/common-auth-embedded/rpc/client.d.ts +3 -0
- package/src/common-auth-embedded/rpc/client.js +2 -0
- package/src/common-auth-embedded/rpc/index.d.ts +10 -0
- package/src/common-auth-embedded/rpc/index.js +5 -0
- package/src/common-auth-embedded/rpc/notifications.d.ts +73 -0
- package/src/common-auth-embedded/rpc/notifications.js +100 -0
- package/src/common-auth-embedded/rpc/port-file.d.ts +33 -0
- package/src/common-auth-embedded/rpc/port-file.js +217 -0
- package/src/common-auth-embedded/rpc/rpc-client.d.ts +30 -0
- package/src/common-auth-embedded/rpc/rpc-client.js +253 -0
- package/src/common-auth-embedded/rpc/rpc-server.d.ts +58 -0
- package/src/common-auth-embedded/rpc/rpc-server.js +311 -0
- package/src/common-auth-embedded/rpc/server-registry.d.ts +11 -0
- package/src/common-auth-embedded/rpc/server-registry.js +47 -0
- package/src/common-auth-embedded/source-output.json +1326 -0
- package/src/common-auth-embedded/store/attribution.d.ts +28 -0
- package/src/common-auth-embedded/store/attribution.js +60 -0
- package/src/common-auth-embedded/store/errors.d.ts +55 -0
- package/src/common-auth-embedded/store/errors.js +38 -0
- package/src/common-auth-embedded/store/hooks.d.ts +12 -0
- package/src/common-auth-embedded/store/hooks.js +34 -0
- package/src/common-auth-embedded/store/identity.d.ts +39 -0
- package/src/common-auth-embedded/store/identity.js +79 -0
- package/src/common-auth-embedded/store/index.d.ts +21 -0
- package/src/common-auth-embedded/store/index.js +7 -0
- package/src/common-auth-embedded/store/mutate.d.ts +189 -0
- package/src/common-auth-embedded/store/mutate.js +500 -0
- package/src/common-auth-embedded/store/pool.d.ts +196 -0
- package/src/common-auth-embedded/store/pool.js +120 -0
- package/src/common-auth-embedded/store/provider-state.d.ts +131 -0
- package/src/common-auth-embedded/store/provider-state.js +226 -0
- package/src/common-auth-embedded/store/publication.d.ts +47 -0
- package/src/common-auth-embedded/store/publication.js +304 -0
- package/src/common-auth-embedded/store/pull.d.ts +36 -0
- package/src/common-auth-embedded/store/pull.js +143 -0
- package/src/common-auth-embedded/store/refresh-lock.d.ts +63 -0
- package/src/common-auth-embedded/store/refresh-lock.js +136 -0
- package/src/common-auth-embedded/store/refresh.d.ts +72 -0
- package/src/common-auth-embedded/store/refresh.js +225 -0
- package/src/common-auth-embedded/store/reserved.js +13 -0
- package/src/common-auth-embedded/store/rows.d.ts +313 -0
- package/src/common-auth-embedded/store/rows.js +1258 -0
- package/src/common-auth-embedded/store/runtime.d.ts +36 -0
- package/src/common-auth-embedded/store/runtime.js +68 -0
- package/src/common-auth-embedded/store/schema.d.ts +443 -0
- package/src/common-auth-embedded/store/schema.js +754 -0
- package/src/common-auth-embedded/store/settings.d.ts +63 -0
- package/src/common-auth-embedded/store/settings.js +120 -0
- package/src/common-auth-embedded/store/torn.d.ts +78 -0
- package/src/common-auth-embedded/store/torn.js +294 -0
- package/src/common-auth-embedded/tui/index.d.ts +8 -0
- package/src/common-auth-embedded/tui/index.js +21 -0
- package/src/common-auth-embedded/util/any-signal.js +42 -0
- package/src/plugin/command-data.ts +3 -0
- package/src/rpc/port-file.ts +6 -140
- package/src/rpc/protocol.ts +59 -24
- package/src/rpc/rpc-client.ts +101 -71
- package/src/sidebar-state.ts +82 -24
- package/src/tui/command-dialogs.tsx +412 -776
- package/src/tui/entry.d.mts +17 -0
- package/src/tui/entry.mjs +34 -66
- package/src/tui/file-logger.ts +22 -7
- package/src/tui-compiled/common-auth-embedded/logger/capture-sink.js +13 -0
- package/src/tui-compiled/common-auth-embedded/logger/engine.js +246 -0
- package/src/tui-compiled/common-auth-embedded/logger/index.js +3 -0
- package/src/tui-compiled/common-auth-embedded/logger/redact.js +83 -0
- package/src/tui-compiled/common-auth-embedded/quota/codec.js +12 -0
- package/src/tui-compiled/common-auth-embedded/quota/format.js +138 -0
- package/src/tui-compiled/common-auth-embedded/quota/index.js +5 -0
- package/src/tui-compiled/common-auth-embedded/quota/map.js +105 -0
- package/src/tui-compiled/common-auth-embedded/quota/merge.js +162 -0
- package/src/tui-compiled/common-auth-embedded/quota/projection.js +134 -0
- package/src/tui-compiled/common-auth-embedded/rpc/client.js +2 -0
- package/src/tui-compiled/common-auth-embedded/rpc/port-file.js +217 -0
- package/src/tui-compiled/common-auth-embedded/rpc/rpc-client.js +253 -0
- package/src/tui-compiled/logging/provider-key-policy.js +3 -0
- package/src/tui-compiled/quota-presentation.js +42 -0
- package/src/tui-compiled/rpc/rpc-client.js +35 -0
- package/src/tui-compiled/rpc/rpc-dir.js +13 -0
- package/src/tui-compiled/selector.js +21 -0
- package/src/tui-compiled/sidebar-state.js +401 -0
- package/src/tui-compiled/tui/command-dialogs.js +424 -0
- package/src/tui-compiled/tui/file-logger.js +73 -0
- package/src/tui-compiled/tui/host-api.js +269 -0
- package/src/tui-compiled/tui/host-v1.js +228 -0
- package/src/tui-compiled/tui-preferences.js +230 -0
- package/src/tui-compiled/{tui.tsx → tui.js} +140 -231
- package/src/tui-ga-compiled/host-ga.js +1304 -0
- package/src/tui-ga-compiled/selector.js +21 -0
- package/src/tui-ga-compiled/shared/07365a7d2ccade4c-host-api.js +269 -0
- package/src/tui-ga-compiled/shared/0e19a88ff3535906-command-dialogs.js +424 -0
- package/src/tui-ga-compiled/shared/1ff34afa7c42d196-projection.js +134 -0
- package/src/tui-ga-compiled/shared/77138df80c7ae006-map.js +105 -0
- package/src/tui-ga-compiled/shared/8ae1927e5910ea81-sidebar-projection.js +112 -0
- package/src/tui-ga-compiled/shared/98cc0c186c46c42d-quota-presentation.js +42 -0
- package/src/tui-ga-compiled/shared/aef2402f8fc342f0-format.js +138 -0
- package/src/tui-ga-compiled/shared/bf17cbee28e58197-index.js +5 -0
- package/src/tui-ga-compiled/shared/ca21dc417b36dc5d-codec.js +12 -0
- package/src/tui-ga-compiled/shared/ecc214300932dfb6-merge.js +162 -0
- package/src/tui-ga-raw/host-ga.tsx +1740 -0
- package/src/tui-ga-raw/selector.js +21 -0
- package/src/tui-ga-raw/shared/07365a7d2ccade4c-host-api.js +269 -0
- package/src/tui-ga-raw/shared/0e19a88ff3535906-command-dialogs.tsx +468 -0
- package/src/tui-ga-raw/shared/1ff34afa7c42d196-projection.js +134 -0
- package/src/tui-ga-raw/shared/77138df80c7ae006-map.js +105 -0
- package/src/tui-ga-raw/shared/8ae1927e5910ea81-sidebar-projection.js +112 -0
- package/src/tui-ga-raw/shared/98cc0c186c46c42d-quota-presentation.js +42 -0
- package/src/tui-ga-raw/shared/aef2402f8fc342f0-format.js +138 -0
- package/src/tui-ga-raw/shared/bf17cbee28e58197-index.js +5 -0
- package/src/tui-ga-raw/shared/ca21dc417b36dc5d-codec.js +12 -0
- package/src/tui-ga-raw/shared/ecc214300932dfb6-merge.js +162 -0
- package/src/tui-raw/common-auth-embedded/logger/capture-sink.js +13 -0
- package/src/tui-raw/common-auth-embedded/logger/engine.js +246 -0
- package/src/tui-raw/common-auth-embedded/logger/index.js +3 -0
- package/src/tui-raw/common-auth-embedded/logger/redact.js +83 -0
- package/src/tui-raw/common-auth-embedded/quota/codec.js +12 -0
- package/src/tui-raw/common-auth-embedded/quota/format.js +138 -0
- package/src/tui-raw/common-auth-embedded/quota/index.js +5 -0
- package/src/tui-raw/common-auth-embedded/quota/map.js +105 -0
- package/src/tui-raw/common-auth-embedded/quota/merge.js +162 -0
- package/src/tui-raw/common-auth-embedded/quota/projection.js +134 -0
- package/src/tui-raw/common-auth-embedded/rpc/client.js +2 -0
- package/src/tui-raw/common-auth-embedded/rpc/port-file.js +217 -0
- package/src/tui-raw/common-auth-embedded/rpc/rpc-client.js +253 -0
- package/src/tui-raw/logging/provider-key-policy.js +3 -0
- package/src/tui-raw/quota-presentation.js +42 -0
- package/src/tui-raw/rpc/rpc-client.js +35 -0
- package/src/tui-raw/rpc/rpc-dir.js +13 -0
- package/src/tui-raw/selector.js +21 -0
- package/src/tui-raw/sidebar-state.js +401 -0
- package/src/tui-raw/tui/command-dialogs.tsx +468 -0
- package/src/tui-raw/tui/file-logger.js +73 -0
- package/src/tui-raw/tui/host-api.js +269 -0
- package/src/tui-raw/tui/host-v1.tsx +249 -0
- package/src/tui-raw/tui-preferences.js +230 -0
- package/src/tui-raw/tui.tsx +1088 -0
- package/src/tui.tsx +58 -141
- package/tui.js +6 -0
- package/src/tui-compiled/plugin/command-data.ts +0 -931
- package/src/tui-compiled/rpc/port-file.ts +0 -143
- package/src/tui-compiled/rpc/protocol.ts +0 -31
- package/src/tui-compiled/rpc/rpc-client.ts +0 -102
- package/src/tui-compiled/rpc/rpc-dir.ts +0 -24
- package/src/tui-compiled/sidebar-state.ts +0 -991
- package/src/tui-compiled/tui/command-dialogs.tsx +0 -779
- package/src/tui-compiled/tui/file-logger.ts +0 -145
- package/src/tui-compiled/tui-preferences.ts +0 -416
|
@@ -0,0 +1,413 @@
|
|
|
1
|
+
import type { Plugin } from '@opencode/plugin';
|
|
2
|
+
import type { SessionRequestKind, SessionRetryDecision } from '@opencode/plugin/promise/session';
|
|
3
|
+
/** The parts of the OpenCode 2 plugin context the installer uses. */
|
|
4
|
+
export type OpenCode2HookContext = {
|
|
5
|
+
readonly session: Pick<Plugin.Context['session'], 'hook'>;
|
|
6
|
+
/** Used only to forget per-session records when a session is deleted. */
|
|
7
|
+
readonly event?: Pick<Plugin.Context['event'], 'subscribe'>;
|
|
8
|
+
};
|
|
9
|
+
export type RequestKind = SessionRequestKind;
|
|
10
|
+
/** Which request a hook call belongs to, as the host reports it. */
|
|
11
|
+
export interface RequestScope {
|
|
12
|
+
readonly providerID: string;
|
|
13
|
+
readonly modelID: string;
|
|
14
|
+
readonly sessionID: string;
|
|
15
|
+
readonly agent: string;
|
|
16
|
+
readonly kind: RequestKind;
|
|
17
|
+
}
|
|
18
|
+
/** Where a reading or a refusal was seen. */
|
|
19
|
+
export type Transport = 'http' | 'ws';
|
|
20
|
+
/**
|
|
21
|
+
* A provider refusal that should move the request to another account: a rate
|
|
22
|
+
* limit, an exhausted usage window, or anything else the adapter decides is
|
|
23
|
+
* tied to the account rather than to the request.
|
|
24
|
+
*/
|
|
25
|
+
export interface LimitSignal {
|
|
26
|
+
/** Short machine-readable reason, such as the provider's error code. */
|
|
27
|
+
readonly reason: string;
|
|
28
|
+
readonly status?: number;
|
|
29
|
+
/** How long the provider asked the account to wait, when it said. */
|
|
30
|
+
readonly retryAfterMs?: number;
|
|
31
|
+
}
|
|
32
|
+
/** What the adapter learned from one streamed event or WebSocket frame. */
|
|
33
|
+
export interface EventVerdict<Q> {
|
|
34
|
+
/** The user has seen output from this response: a retry would repeat it. */
|
|
35
|
+
readonly outputStarted?: boolean;
|
|
36
|
+
readonly quota?: Q;
|
|
37
|
+
readonly limit?: LimitSignal;
|
|
38
|
+
/**
|
|
39
|
+
* This is the last event of the response (completed or failed); the
|
|
40
|
+
* attempt ends here. On WebSocket this is the only way an attempt ends
|
|
41
|
+
* normally, because the socket stays open between responses.
|
|
42
|
+
*/
|
|
43
|
+
readonly done?: boolean;
|
|
44
|
+
/**
|
|
45
|
+
* The response failed with this message. Ends the attempt with
|
|
46
|
+
* `error.reason` `failed`; implies `done`.
|
|
47
|
+
*/
|
|
48
|
+
readonly error?: string;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Header changes for one account. A string sets the header (replacing every
|
|
52
|
+
* spelling of its name); `null` removes it.
|
|
53
|
+
*/
|
|
54
|
+
export type HeaderEdits = Readonly<Record<string, string | null>>;
|
|
55
|
+
export interface ChooseAccountInput extends RequestScope {
|
|
56
|
+
/**
|
|
57
|
+
* The account of the attempt this one retries, when the retry hook just
|
|
58
|
+
* asked the host to retry an attempt of this session and kind; otherwise
|
|
59
|
+
* the account of the newest attempt of this session and kind.
|
|
60
|
+
*/
|
|
61
|
+
readonly previousAccountId?: string;
|
|
62
|
+
/**
|
|
63
|
+
* Set when the attempt this one retries was refused for a limit before any
|
|
64
|
+
* output and the retry hook asked the host to try again. The adapter
|
|
65
|
+
* should not pick `accountId` again unless it has nothing else.
|
|
66
|
+
*/
|
|
67
|
+
readonly rerouteFrom?: {
|
|
68
|
+
readonly accountId: string;
|
|
69
|
+
readonly limit: LimitSignal;
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
export interface AccountRequest extends RequestScope {
|
|
73
|
+
readonly accountId: string;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* One physical send: created when an account is chosen for a request, and
|
|
77
|
+
* handed back on every hook call and event that belongs to that send, so a
|
|
78
|
+
* plugin can tie a response, a frame, a limit, a retry decision and the end
|
|
79
|
+
* of the send to the credential it chose for it.
|
|
80
|
+
*
|
|
81
|
+
* `A` is the plugin's own per-attempt value, returned by `accountHeaders`
|
|
82
|
+
* next to the headers (a served credential receipt, say); the installer
|
|
83
|
+
* only carries it.
|
|
84
|
+
*/
|
|
85
|
+
export interface Attempt<A = unknown> extends AccountRequest {
|
|
86
|
+
/** Unique within one installation. */
|
|
87
|
+
readonly attemptId: string;
|
|
88
|
+
/**
|
|
89
|
+
* The transport that carried the send. `undefined` until `http.request` or
|
|
90
|
+
* `experimental.ws.handshake` has run for it: an account chosen in
|
|
91
|
+
* `model.request` is chosen before the host has picked the transport.
|
|
92
|
+
*/
|
|
93
|
+
readonly transport: Transport | undefined;
|
|
94
|
+
/**
|
|
95
|
+
* What `accountHeaders` returned as `attempt`, if anything, or what
|
|
96
|
+
* `answeredBy` replaced it with.
|
|
97
|
+
*/
|
|
98
|
+
readonly data: A | undefined;
|
|
99
|
+
/**
|
|
100
|
+
* Set when `answeredBy` said another account answered this attempt's HTTP
|
|
101
|
+
* response: the account `chooseAccount` picked. `accountId` is then the
|
|
102
|
+
* account that answered, and everything from the response on is attributed
|
|
103
|
+
* to it.
|
|
104
|
+
*/
|
|
105
|
+
readonly reboundFrom?: string;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* The account that actually answered an HTTP response, as `answeredBy`
|
|
109
|
+
* reports it. `data`, when the key is present, replaces the attempt's `data`
|
|
110
|
+
* (the answering account's own credential receipt, say).
|
|
111
|
+
*/
|
|
112
|
+
export interface ResponseAccount<A = unknown> {
|
|
113
|
+
readonly accountId: string;
|
|
114
|
+
readonly data?: A;
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Why an attempt ended without completing.
|
|
118
|
+
*
|
|
119
|
+
* - `failed`: the response stream errored, or the adapter's `inspectEvent`
|
|
120
|
+
* reported the response as failed;
|
|
121
|
+
* - `cancelled`: the host cancelled the HTTP response body (the user stopped
|
|
122
|
+
* the turn, say);
|
|
123
|
+
* - `abandoned`: the attempt can no longer be observed: it was on WebSocket
|
|
124
|
+
* (or the retry hook had already judged it) when a newer attempt of the
|
|
125
|
+
* same session and kind began, another attempt of its session and kind
|
|
126
|
+
* went out over WebSocket, its session was forgotten, it was dropped for
|
|
127
|
+
* space, or the installation was disposed. A WebSocket closed or cancelled
|
|
128
|
+
* mid-response ends this way, since the host has no hook for either.
|
|
129
|
+
*/
|
|
130
|
+
export type AttemptEndReason = 'failed' | 'cancelled' | 'abandoned';
|
|
131
|
+
/** How an attempt ended, as `onAttemptEnd` reports it. */
|
|
132
|
+
export interface AttemptOutcome {
|
|
133
|
+
/** The HTTP status of the response, when an HTTP response was seen. */
|
|
134
|
+
readonly status?: number;
|
|
135
|
+
/** Output from this attempt had reached the user. */
|
|
136
|
+
readonly outputStarted: boolean;
|
|
137
|
+
/** The account-level refusal recorded for this attempt, if any. */
|
|
138
|
+
readonly limit?: LimitSignal;
|
|
139
|
+
/** Absent when the response completed, whatever its status. */
|
|
140
|
+
readonly error?: {
|
|
141
|
+
readonly reason: AttemptEndReason;
|
|
142
|
+
readonly message?: string;
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* `accountHeaders` may return the header edits alone, or the edits together
|
|
147
|
+
* with a per-attempt value that the installer hands back in
|
|
148
|
+
* `Attempt.data`.
|
|
149
|
+
*/
|
|
150
|
+
export interface AccountHeadersResult<A = unknown> {
|
|
151
|
+
readonly headers: HeaderEdits;
|
|
152
|
+
readonly attempt?: A;
|
|
153
|
+
}
|
|
154
|
+
/** A host-supplied error, as the retry hook reports it. */
|
|
155
|
+
export interface HostError {
|
|
156
|
+
readonly type: string;
|
|
157
|
+
readonly message: string;
|
|
158
|
+
readonly status?: number;
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Everything provider-specific the installer needs. `Q` is the plugin's own
|
|
162
|
+
* quota reading type; the installer only carries it to the `quota` event.
|
|
163
|
+
* `A` is the plugin's per-attempt value (see `Attempt`).
|
|
164
|
+
*/
|
|
165
|
+
export interface OpenCode2AuthAdapter<Q = unknown, A = unknown> {
|
|
166
|
+
/** Every hook is scoped to this provider; other providers are untouched. */
|
|
167
|
+
readonly providerID: string;
|
|
168
|
+
/**
|
|
169
|
+
* Picks the account for one model request. Called again for every retry,
|
|
170
|
+
* so a refused account can be skipped. Returning `undefined` stops the
|
|
171
|
+
* request with `OpenCode2AuthError` kind `no-account`.
|
|
172
|
+
*/
|
|
173
|
+
chooseAccount(input: ChooseAccountInput): Promise<string | undefined> | string | undefined;
|
|
174
|
+
/**
|
|
175
|
+
* The credential and per-account headers for an account, applied in
|
|
176
|
+
* `model.request`, `http.request` and `experimental.ws.handshake`. The last
|
|
177
|
+
* two run after the host has applied its own credential, so these headers
|
|
178
|
+
* win on the wire. With `gateOnPlaceholder`, only the transport hook applies
|
|
179
|
+
* them, and only to owned requests. Put per-account and session headers here
|
|
180
|
+
* rather than in a separate `model.request` hook.
|
|
181
|
+
*
|
|
182
|
+
* Called once per attempt, when the account is chosen. Returning
|
|
183
|
+
* `{headers, attempt}` instead of the bare edits stores `attempt` as the
|
|
184
|
+
* attempt's `data`, handed back on everything that belongs to the attempt.
|
|
185
|
+
*/
|
|
186
|
+
accountHeaders(input: AccountRequest): Promise<HeaderEdits | AccountHeadersResult<A>> | HeaderEdits | AccountHeadersResult<A>;
|
|
187
|
+
/**
|
|
188
|
+
* Optional request rewrite (URL, body) before the account headers are
|
|
189
|
+
* applied. Return `undefined` to keep the request. With `gateOnPlaceholder`,
|
|
190
|
+
* runs only for owned requests; move endpoint and body edits here rather
|
|
191
|
+
* than changing `model.request`.
|
|
192
|
+
*/
|
|
193
|
+
rewriteRequest?(input: AccountRequest & {
|
|
194
|
+
readonly request: Request;
|
|
195
|
+
readonly attempt: Attempt<A>;
|
|
196
|
+
}): Promise<Request | undefined> | Request | undefined;
|
|
197
|
+
/**
|
|
198
|
+
* Optional response rewrite (body stream, status). It receives the
|
|
199
|
+
* response after quota, limit and output detection have been attached, so
|
|
200
|
+
* detection always sees the provider's own events.
|
|
201
|
+
*/
|
|
202
|
+
rewriteResponse?(input: AccountRequest & {
|
|
203
|
+
readonly request: Request;
|
|
204
|
+
readonly response: Response;
|
|
205
|
+
readonly attempt: Attempt<A>;
|
|
206
|
+
}): Promise<Response | undefined> | Response | undefined;
|
|
207
|
+
/**
|
|
208
|
+
* Optional. For an adapter whose own sender can move a request to another
|
|
209
|
+
* account after `rewriteRequest` (a bridge that answers a 401 or 403 by
|
|
210
|
+
* retrying on the next account, say): runs first in `http.response`,
|
|
211
|
+
* before quota, refusal, output or end detection, and returns the account
|
|
212
|
+
* that actually answered, or `undefined` when the attempt's own account
|
|
213
|
+
* did. A different account rebinds the attempt to it (`Attempt.accountId`
|
|
214
|
+
* becomes that account and `reboundFrom` the one chosen), so the response's
|
|
215
|
+
* quota, refusal, stream events, end and any retry reroute are attributed
|
|
216
|
+
* to the answering account, once, and never to the chosen one. What the
|
|
217
|
+
* sender saw from the chosen account before it moved on (the 401 itself)
|
|
218
|
+
* never reaches the installer: the adapter accounts for it itself.
|
|
219
|
+
* Throwing ends the attempt as `failed` and fails the response hook.
|
|
220
|
+
*/
|
|
221
|
+
answeredBy?(input: {
|
|
222
|
+
readonly request: Request;
|
|
223
|
+
readonly response: Response;
|
|
224
|
+
readonly attempt: Attempt<A>;
|
|
225
|
+
}): Promise<ResponseAccount<A> | undefined> | ResponseAccount<A> | undefined;
|
|
226
|
+
/**
|
|
227
|
+
* Optional WebSocket URL rewrite. With `gateOnPlaceholder`, runs only for
|
|
228
|
+
* handshakes whose prepared credential belongs to this plugin's login.
|
|
229
|
+
* Return `undefined` to keep the URL.
|
|
230
|
+
*/
|
|
231
|
+
rewriteHandshakeURL?(input: AccountRequest & {
|
|
232
|
+
readonly url: string;
|
|
233
|
+
readonly attempt: Attempt<A>;
|
|
234
|
+
}): string | undefined;
|
|
235
|
+
/**
|
|
236
|
+
* Optional rewrite of each outgoing WebSocket frame of this provider,
|
|
237
|
+
* from `experimental.ws.send`. Return the frame to send, or `undefined` to
|
|
238
|
+
* send it unchanged.
|
|
239
|
+
*
|
|
240
|
+
* The rewrite must be a deterministic function of the frame (stable for
|
|
241
|
+
* the session): the host chains turns with `previous_response_id` by
|
|
242
|
+
* diffing its own request as it was before this hook ran, so the server
|
|
243
|
+
* only stays in step when every frame is rewritten the same way. Never
|
|
244
|
+
* alter, drop or reorder the `input` items the host put in the frame, and
|
|
245
|
+
* never touch `previous_response_id`: the host's next frame assumes the
|
|
246
|
+
* server holds exactly what it sent. Adding items to `input`, or adding or
|
|
247
|
+
* changing settings fields, keeps the host's order and continuation when
|
|
248
|
+
* done the same way for every frame: the added items become part of the
|
|
249
|
+
* server's history and the follow-up turn stays incremental.
|
|
250
|
+
*
|
|
251
|
+
* What inserting `input` items into every frame does not keep is the
|
|
252
|
+
* equivalence of the two ways a history reaches the server (settings
|
|
253
|
+
* fields carry no history, so they are not affected). Incrementally, each
|
|
254
|
+
* frame carries only
|
|
255
|
+
* the new items, so an item the rewrite inserts into every frame lands at
|
|
256
|
+
* every network boundary of the accumulated history. After a reconnect the
|
|
257
|
+
* host replays the whole history in one frame, and the same rewrite
|
|
258
|
+
* inserts that item once. The two server-side histories, and their cache
|
|
259
|
+
* prefixes, then differ. A rewrite that only adds or changes settings
|
|
260
|
+
* fields is unaffected. An adapter that inserts `input` items must show,
|
|
261
|
+
* for its own insertion, that the accumulated incremental history equals
|
|
262
|
+
* the rewritten full replay (including across tool loops), or accept the
|
|
263
|
+
* divergence and name what it costs (a cache miss and a different prompt
|
|
264
|
+
* after every reconnect).
|
|
265
|
+
*
|
|
266
|
+
* It runs for every frame, including one no attempt can be tied to
|
|
267
|
+
* (`attempt` is then `undefined`), so the rewrite never depends on
|
|
268
|
+
* attribution. With `gateOnPlaceholder`, it runs only after an owned
|
|
269
|
+
* handshake, including frames after that socket's attempt has ended.
|
|
270
|
+
*/
|
|
271
|
+
rewriteWebSocketFrame?(input: RequestScope & {
|
|
272
|
+
readonly attempt: Attempt<A> | undefined;
|
|
273
|
+
readonly frame: string;
|
|
274
|
+
}): Promise<string | undefined> | string | undefined;
|
|
275
|
+
/** Quota carried in HTTP response headers. */
|
|
276
|
+
quotaFromHeaders?(headers: Headers, status: number, attempt: Attempt<A>): Q | undefined;
|
|
277
|
+
/**
|
|
278
|
+
* Recognises an account-level refusal from an HTTP response before its
|
|
279
|
+
* body is streamed. `body()` reads a copy, so the host still gets the body.
|
|
280
|
+
*/
|
|
281
|
+
limitFromResponse?(input: {
|
|
282
|
+
readonly status: number;
|
|
283
|
+
readonly headers: Headers;
|
|
284
|
+
readonly body: () => Promise<string>;
|
|
285
|
+
readonly attempt: Attempt<A>;
|
|
286
|
+
}): Promise<LimitSignal | undefined> | LimitSignal | undefined;
|
|
287
|
+
/**
|
|
288
|
+
* Inspects one server-sent event (`data` payload) or one WebSocket frame.
|
|
289
|
+
* Detects output, quota, refusals and the end of the response inside the
|
|
290
|
+
* stream.
|
|
291
|
+
*/
|
|
292
|
+
inspectEvent?(input: {
|
|
293
|
+
readonly transport: Transport;
|
|
294
|
+
readonly data: string;
|
|
295
|
+
readonly event?: string;
|
|
296
|
+
readonly attempt: Attempt<A>;
|
|
297
|
+
}): EventVerdict<Q> | undefined;
|
|
298
|
+
/**
|
|
299
|
+
* Recognises an account-level refusal from the error the host hands the
|
|
300
|
+
* retry hook, for refusals no other hook saw. `attempt` is the attempt
|
|
301
|
+
* the retry hook judged.
|
|
302
|
+
*/
|
|
303
|
+
limitFromError?(error: HostError, attempt: Attempt<A>): LimitSignal | undefined;
|
|
304
|
+
/**
|
|
305
|
+
* Called once per attempt when it ends: an HTTP response body finished,
|
|
306
|
+
* errored or was cancelled; an HTTP response with an error status or no
|
|
307
|
+
* body arrived; an event's verdict said `done` or `error`; or the attempt
|
|
308
|
+
* was abandoned (see `AttemptEndReason`). Errors are logged and never
|
|
309
|
+
* reach the host. The retry hook waits for this call to settle before it
|
|
310
|
+
* decides, so a plugin that records a refusal here has it in place when
|
|
311
|
+
* `chooseAccount` runs again.
|
|
312
|
+
*/
|
|
313
|
+
onAttemptEnd?(attempt: Attempt<A>, outcome: AttemptOutcome): Promise<void> | void;
|
|
314
|
+
}
|
|
315
|
+
export interface OpenCode2AuthLogger {
|
|
316
|
+
warn(message: string, data?: unknown): void;
|
|
317
|
+
}
|
|
318
|
+
export interface InstallOpenCode2AuthOptions {
|
|
319
|
+
/**
|
|
320
|
+
* Opt in to acting only on this plugin's login. Extract the request-bound
|
|
321
|
+
* prepared secret from the host's transport headers (not global connection
|
|
322
|
+
* state). The installer compares it byte for byte with
|
|
323
|
+
* `placeholderSecret(adapter.providerID)`; any other value passes untouched.
|
|
324
|
+
* `model.request` becomes a no-op; selection and rewrites happen at transport.
|
|
325
|
+
*/
|
|
326
|
+
readonly gateOnPlaceholder?: {
|
|
327
|
+
readonly credential: (headers: Headers) => string | undefined;
|
|
328
|
+
};
|
|
329
|
+
/**
|
|
330
|
+
* Values that must never reach the wire, normally the placeholder the host
|
|
331
|
+
* holds as its credential. Defaults to the placeholder secret for the
|
|
332
|
+
* adapter's provider. With `gateOnPlaceholder`, that placeholder is always
|
|
333
|
+
* forbidden, even if this list is customized.
|
|
334
|
+
*/
|
|
335
|
+
readonly hostCredentials?: readonly string[];
|
|
336
|
+
/** Most attempts kept before the oldest is abandoned and dropped. */
|
|
337
|
+
readonly maxRecords?: number;
|
|
338
|
+
readonly logger?: OpenCode2AuthLogger;
|
|
339
|
+
}
|
|
340
|
+
export type RetryReason = 'reroute' | 'output-started' | 'no-account' | 'host-decides';
|
|
341
|
+
/**
|
|
342
|
+
* The hook that picked an account. Normally `model.request`; a transport hook
|
|
343
|
+
* picks only when the host skipped `model.request` for that request, which a
|
|
344
|
+
* plugin may want to log as a host change.
|
|
345
|
+
*/
|
|
346
|
+
export type SelectingHook = 'model.request' | 'http.request' | 'experimental.ws.handshake';
|
|
347
|
+
/**
|
|
348
|
+
* Every event that belongs to one attempt carries it as `handle` (the
|
|
349
|
+
* `retry` event already uses `attempt` for the host's retry count).
|
|
350
|
+
*/
|
|
351
|
+
export interface OpenCode2AuthEvents<Q, A = unknown> {
|
|
352
|
+
/** An account was picked for a model request. */
|
|
353
|
+
readonly select: AccountRequest & {
|
|
354
|
+
readonly hook: SelectingHook;
|
|
355
|
+
readonly previousAccountId?: string;
|
|
356
|
+
readonly rerouteFrom?: ChooseAccountInput['rerouteFrom'];
|
|
357
|
+
readonly handle: Attempt<A>;
|
|
358
|
+
};
|
|
359
|
+
/** A quota reading, attributed through this installer's own record. */
|
|
360
|
+
readonly quota: AccountRequest & {
|
|
361
|
+
readonly transport: Transport;
|
|
362
|
+
readonly status?: number;
|
|
363
|
+
readonly quota: Q;
|
|
364
|
+
readonly handle: Attempt<A>;
|
|
365
|
+
};
|
|
366
|
+
/**
|
|
367
|
+
* An account-level refusal. The retry hook waits for every listener of
|
|
368
|
+
* this event before asking the host to retry, so a plugin that marks the
|
|
369
|
+
* account limited here has the mark in place when `chooseAccount` runs.
|
|
370
|
+
*/
|
|
371
|
+
readonly limit: AccountRequest & {
|
|
372
|
+
readonly via: Transport | 'error';
|
|
373
|
+
readonly limit: LimitSignal;
|
|
374
|
+
readonly outputStarted: boolean;
|
|
375
|
+
readonly handle: Attempt<A>;
|
|
376
|
+
};
|
|
377
|
+
/** The retry hook ran for this provider. */
|
|
378
|
+
readonly retry: {
|
|
379
|
+
readonly sessionID: string;
|
|
380
|
+
readonly accountId?: string;
|
|
381
|
+
readonly kind?: RequestKind;
|
|
382
|
+
readonly attempt: number;
|
|
383
|
+
readonly reason: RetryReason;
|
|
384
|
+
readonly hostDecision: SessionRetryDecision;
|
|
385
|
+
readonly decision: SessionRetryDecision;
|
|
386
|
+
/** The attempt the decision was about, when it had an account. */
|
|
387
|
+
readonly handle?: Attempt<A>;
|
|
388
|
+
};
|
|
389
|
+
}
|
|
390
|
+
export type OpenCode2AuthEventName = keyof OpenCode2AuthEvents<unknown>;
|
|
391
|
+
export interface OpenCode2AuthInstallation<Q, A = unknown> {
|
|
392
|
+
/**
|
|
393
|
+
* Listens to an event. Listener errors are logged and never reach the
|
|
394
|
+
* host. Returns a function that removes the listener.
|
|
395
|
+
*/
|
|
396
|
+
on<E extends OpenCode2AuthEventName>(event: E, listener: (payload: OpenCode2AuthEvents<Q, A>[E]) => void | Promise<void>): () => void;
|
|
397
|
+
/**
|
|
398
|
+
* The account of the newest attempt of a session and request kind (after
|
|
399
|
+
* any `answeredBy` rebind). With several attempts of one session and kind
|
|
400
|
+
* in flight it names only the newest; each attempt's own account is on its
|
|
401
|
+
* handle.
|
|
402
|
+
*/
|
|
403
|
+
accountFor(sessionID: string, kind: RequestKind): string | undefined;
|
|
404
|
+
/**
|
|
405
|
+
* Drops every attempt and revokes in-flight auth selections of a session.
|
|
406
|
+
* Session deletion does this itself. Later requests may reuse the session id.
|
|
407
|
+
*/
|
|
408
|
+
forgetSession(sessionID: string): void;
|
|
409
|
+
/** Number of attempts held. */
|
|
410
|
+
readonly size: number;
|
|
411
|
+
/** Removes every hook, revokes in-flight auth and stops listening for session deletion. */
|
|
412
|
+
dispose(): Promise<void>;
|
|
413
|
+
}
|
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
import { rmdirSync, statSync } from 'node:fs';
|
|
2
|
+
import { mkdir, rmdir, stat, utimes } from 'node:fs/promises';
|
|
3
|
+
// Protocol source: proper-lockfile 4.1.2 lib/lockfile.js and lib/mtime-precision.js;
|
|
4
|
+
// line-level citations and the Pi lock options are recorded in docs/sources.md.
|
|
5
|
+
// Pi's async acquireLockAsync uses stale=30s (update=15s). Keep takeover at 30s
|
|
6
|
+
// so a live async writer's lock cannot be reclaimed between its renewals.
|
|
7
|
+
const STALE = 30_000;
|
|
8
|
+
// Pi's sync acquireLockSyncWithRetry uses proper-lockfile defaults: stale=10s,
|
|
9
|
+
// update=5s. Renew every 3s for margin and stop retrying failed renewals after 10s.
|
|
10
|
+
const RENEWAL_STALE = 10_000;
|
|
11
|
+
const UPDATE = 3_000;
|
|
12
|
+
let precision;
|
|
13
|
+
/** Held locks, with the time each last renewed, for cleanup at process exit. */
|
|
14
|
+
const active = new Map();
|
|
15
|
+
process.once('exit', () => {
|
|
16
|
+
for (const [path, identity] of active) {
|
|
17
|
+
try {
|
|
18
|
+
// Pi's synchronous auth.json writer treats a lock whose mtime has not
|
|
19
|
+
// been refreshed for 10s as abandoned and may take it over. A lease that
|
|
20
|
+
// went 10s without renewing may therefore already be that writer's, so
|
|
21
|
+
// it is left in place; whoever next needs the lock clears it as stale.
|
|
22
|
+
if (identity.renewedAt + RENEWAL_STALE < Date.now())
|
|
23
|
+
continue;
|
|
24
|
+
const observed = statSync(path);
|
|
25
|
+
if (sameDirectory(observed, identity) &&
|
|
26
|
+
observed.mtime.getTime() === identity.mtime)
|
|
27
|
+
rmdirSync(path);
|
|
28
|
+
}
|
|
29
|
+
catch {
|
|
30
|
+
/* A compromised or already removed lock is not ours to clean up. */
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
function sameDirectory(observed, identity) {
|
|
35
|
+
return observed.dev === identity.dev && observed.ino === identity.ino;
|
|
36
|
+
}
|
|
37
|
+
function errorCode(error) {
|
|
38
|
+
return typeof error === 'object' && error !== null && 'code' in error
|
|
39
|
+
? error.code
|
|
40
|
+
: undefined;
|
|
41
|
+
}
|
|
42
|
+
function held() {
|
|
43
|
+
return Object.assign(new Error('Pi auth lock held'), { code: 'ELOCKED' });
|
|
44
|
+
}
|
|
45
|
+
async function remove(path) {
|
|
46
|
+
try {
|
|
47
|
+
await rmdir(path);
|
|
48
|
+
}
|
|
49
|
+
catch (error) {
|
|
50
|
+
if (errorCode(error) !== 'ENOENT')
|
|
51
|
+
throw error;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
async function acquire(path, stale) {
|
|
55
|
+
try {
|
|
56
|
+
await mkdir(path);
|
|
57
|
+
}
|
|
58
|
+
catch (error) {
|
|
59
|
+
if (errorCode(error) !== 'EEXIST')
|
|
60
|
+
throw error;
|
|
61
|
+
if (stale <= 0)
|
|
62
|
+
throw held();
|
|
63
|
+
let mtime;
|
|
64
|
+
try {
|
|
65
|
+
mtime = (await stat(path)).mtime.getTime();
|
|
66
|
+
}
|
|
67
|
+
catch (error) {
|
|
68
|
+
if (errorCode(error) === 'ENOENT')
|
|
69
|
+
return acquire(path, 0);
|
|
70
|
+
throw error;
|
|
71
|
+
}
|
|
72
|
+
if (!(mtime < Date.now() - stale))
|
|
73
|
+
throw held();
|
|
74
|
+
// Match upstream: rmdir (ignore ENOENT), then one mkdir attempt without another stale check.
|
|
75
|
+
await remove(path);
|
|
76
|
+
return acquire(path, 0);
|
|
77
|
+
}
|
|
78
|
+
try {
|
|
79
|
+
if (!precision) {
|
|
80
|
+
const probe = new Date(Math.ceil(Date.now() / 1_000) * 1_000 + 5);
|
|
81
|
+
await utimes(path, probe, probe);
|
|
82
|
+
}
|
|
83
|
+
const observed = await stat(path);
|
|
84
|
+
const mtime = observed.mtime.getTime();
|
|
85
|
+
precision ??= mtime % 1_000 === 0 ? 's' : 'ms';
|
|
86
|
+
return { dev: observed.dev, ino: observed.ino, mtime };
|
|
87
|
+
}
|
|
88
|
+
catch (error) {
|
|
89
|
+
await remove(path).catch(() => { });
|
|
90
|
+
throw error;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
/** The same mkdir/mtime/rmdir protocol as Pi's proper-lockfile, with realpath disabled. */
|
|
94
|
+
export async function acquirePiLock(authPath, onCompromised, onRenew) {
|
|
95
|
+
const path = `${authPath}.lock`;
|
|
96
|
+
const identity = await acquire(path, STALE);
|
|
97
|
+
let mtime = identity.mtime;
|
|
98
|
+
let lastUpdate = Date.now();
|
|
99
|
+
let released = false;
|
|
100
|
+
let timer;
|
|
101
|
+
active.set(path, { ...identity, renewedAt: lastUpdate });
|
|
102
|
+
function compromise() {
|
|
103
|
+
released = true;
|
|
104
|
+
if (timer)
|
|
105
|
+
clearTimeout(timer);
|
|
106
|
+
active.delete(path);
|
|
107
|
+
onCompromised();
|
|
108
|
+
}
|
|
109
|
+
function assertFresh() {
|
|
110
|
+
// A sync writer may already have reclaimed an unrenewed lock after 10s,
|
|
111
|
+
// even if the directory still matches. Never revive that expired lease.
|
|
112
|
+
if (!released && lastUpdate + RENEWAL_STALE < Date.now())
|
|
113
|
+
compromise();
|
|
114
|
+
}
|
|
115
|
+
function schedule(delay = UPDATE) {
|
|
116
|
+
if (released)
|
|
117
|
+
return;
|
|
118
|
+
timer = setTimeout(() => {
|
|
119
|
+
void update();
|
|
120
|
+
}, delay);
|
|
121
|
+
timer.unref();
|
|
122
|
+
}
|
|
123
|
+
function retry(error) {
|
|
124
|
+
if (released)
|
|
125
|
+
return;
|
|
126
|
+
if (errorCode(error) === 'ENOENT' ||
|
|
127
|
+
lastUpdate + RENEWAL_STALE < Date.now())
|
|
128
|
+
compromise();
|
|
129
|
+
else
|
|
130
|
+
schedule(1_000);
|
|
131
|
+
}
|
|
132
|
+
async function update() {
|
|
133
|
+
assertFresh();
|
|
134
|
+
if (released)
|
|
135
|
+
return;
|
|
136
|
+
let observed;
|
|
137
|
+
try {
|
|
138
|
+
observed = await stat(path);
|
|
139
|
+
}
|
|
140
|
+
catch (error) {
|
|
141
|
+
retry(error);
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
144
|
+
assertFresh();
|
|
145
|
+
if (released)
|
|
146
|
+
return;
|
|
147
|
+
if (!sameDirectory(observed, identity) ||
|
|
148
|
+
observed.mtime.getTime() !== mtime) {
|
|
149
|
+
compromise();
|
|
150
|
+
return;
|
|
151
|
+
}
|
|
152
|
+
const next = new Date(precision === 's' ? Math.ceil(Date.now() / 1_000) * 1_000 : Date.now());
|
|
153
|
+
try {
|
|
154
|
+
await utimes(path, next, next);
|
|
155
|
+
}
|
|
156
|
+
catch (error) {
|
|
157
|
+
retry(error);
|
|
158
|
+
return;
|
|
159
|
+
}
|
|
160
|
+
if (released)
|
|
161
|
+
return;
|
|
162
|
+
mtime = next.getTime();
|
|
163
|
+
lastUpdate = Date.now();
|
|
164
|
+
active.set(path, { ...identity, mtime, renewedAt: lastUpdate });
|
|
165
|
+
schedule();
|
|
166
|
+
}
|
|
167
|
+
// Tests can resume a paused renewal without waiting for the production timer.
|
|
168
|
+
onRenew?.(async () => {
|
|
169
|
+
if (timer)
|
|
170
|
+
clearTimeout(timer);
|
|
171
|
+
await update();
|
|
172
|
+
});
|
|
173
|
+
schedule();
|
|
174
|
+
return {
|
|
175
|
+
assertFresh,
|
|
176
|
+
async release() {
|
|
177
|
+
if (released)
|
|
178
|
+
return;
|
|
179
|
+
released = true;
|
|
180
|
+
if (timer)
|
|
181
|
+
clearTimeout(timer);
|
|
182
|
+
active.delete(path);
|
|
183
|
+
// An expired lease is never removed, even when the directory still
|
|
184
|
+
// matches. Pi's synchronous auth.json writer may take over a lock that
|
|
185
|
+
// went 10s without an mtime refresh, so after 10s without renewing the
|
|
186
|
+
// directory may be that writer's. Whoever next needs the lock clears it
|
|
187
|
+
// as stale.
|
|
188
|
+
const expired = () => lastUpdate + RENEWAL_STALE < Date.now();
|
|
189
|
+
if (expired()) {
|
|
190
|
+
compromise();
|
|
191
|
+
return;
|
|
192
|
+
}
|
|
193
|
+
let observed;
|
|
194
|
+
try {
|
|
195
|
+
observed = await stat(path);
|
|
196
|
+
}
|
|
197
|
+
catch (error) {
|
|
198
|
+
if (errorCode(error) !== 'ENOENT')
|
|
199
|
+
throw error;
|
|
200
|
+
compromise();
|
|
201
|
+
return;
|
|
202
|
+
}
|
|
203
|
+
if (expired() ||
|
|
204
|
+
!sameDirectory(observed, identity) ||
|
|
205
|
+
mtime !== observed.mtime.getTime()) {
|
|
206
|
+
compromise();
|
|
207
|
+
return;
|
|
208
|
+
}
|
|
209
|
+
await remove(path);
|
|
210
|
+
},
|
|
211
|
+
};
|
|
212
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
export type PiSlotErrorCode = 'invalid-options' | 'invalid-auth' | 'invalid-stash' | 'unsafe-path' | 'missing-stash' | 'conflict' | 'lock-timeout' | 'lock-compromised' | 'io';
|
|
2
|
+
/** Errors deliberately contain neither paths nor credentials nor underlying error messages. */
|
|
3
|
+
export declare class PiSlotError extends Error {
|
|
4
|
+
readonly code: PiSlotErrorCode;
|
|
5
|
+
constructor(code: PiSlotErrorCode);
|
|
6
|
+
}
|
|
7
|
+
export interface PiSlotOptions {
|
|
8
|
+
authPath: string;
|
|
9
|
+
provider: string;
|
|
10
|
+
/**
|
|
11
|
+
* Where the provider's original Pi login is kept while the vault serves.
|
|
12
|
+
* Put it in a private directory, and give each provider its own file: one
|
|
13
|
+
* stash holds one provider's original login, and a second provider writing
|
|
14
|
+
* to it would overwrite the first one's backup.
|
|
15
|
+
*/
|
|
16
|
+
stashPath: string;
|
|
17
|
+
/**
|
|
18
|
+
* The api_key Pi stores in the slot while the vault serves. It is a fixed,
|
|
19
|
+
* non-secret string that no provider accepts. Pi runs a key starting with
|
|
20
|
+
* `!` as a shell command and expands `$NAME` from the environment, so the
|
|
21
|
+
* placeholder may contain neither.
|
|
22
|
+
*/
|
|
23
|
+
placeholderKey: string;
|
|
24
|
+
lockTimeoutMs?: number;
|
|
25
|
+
}
|
|
26
|
+
export interface PiSlotInspection {
|
|
27
|
+
slot: 'original' | 'placeholder' | 'foreign' | 'empty';
|
|
28
|
+
stash: 'valid' | 'missing';
|
|
29
|
+
}
|
|
30
|
+
export interface PiSlot {
|
|
31
|
+
inspect(): Promise<PiSlotInspection>;
|
|
32
|
+
enterVault(): Promise<void>;
|
|
33
|
+
exitVault(): Promise<'restored' | 'conflict' | 'nothing-to-do'>;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Production entry point. Pi caches which models are usable; after a
|
|
37
|
+
* successful transition the extension calls `ctx.modelRegistry.refresh()` so
|
|
38
|
+
* Pi re-reads the slot it just changed.
|
|
39
|
+
*/
|
|
40
|
+
export declare function openPiSlot(options: PiSlotOptions): PiSlot;
|
|
41
|
+
/**
|
|
42
|
+
* Internal test entry point: pause reads, renewals, or renames to simulate races,
|
|
43
|
+
* and observe durable writes/deletion to simulate crashes. Not a public export.
|
|
44
|
+
*/
|
|
45
|
+
export declare function createPiSlot(options: PiSlotOptions, onStep?: (step: 'stash-written' | 'auth-written' | 'stash-deleted') => void, hooks?: {
|
|
46
|
+
afterReadCheck?: (path: string) => Promise<void>;
|
|
47
|
+
onRenew?: (renew: () => Promise<void>) => void;
|
|
48
|
+
beforeRename?: (path: string) => Promise<void>;
|
|
49
|
+
}): PiSlot;
|