@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,6 @@
|
|
|
1
|
+
export { writeJsonAtomic } from './atomic-write.js';
|
|
2
|
+
export { WRITER_LOCK_CONSTANTS } from './lock-constants.js';
|
|
3
|
+
// The try-once lock underneath withLock, for callers that hold a lock across
|
|
4
|
+
// several steps or poll instead of waiting (for example a refresh lease).
|
|
5
|
+
export { acquireRefreshFileLock, isLostMarkerRaceError, } from './refresh-file-lock.js';
|
|
6
|
+
export { LockContentionError, LockOwnershipError, lockPathFor, withLock, } from './with-lock.js';
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export declare const WRITER_LOCK_CONSTANTS: Readonly<{
|
|
2
|
+
sidebar: Readonly<{
|
|
3
|
+
name: "sidebar-write";
|
|
4
|
+
ttlMs: 10000;
|
|
5
|
+
timeoutMs: 15000;
|
|
6
|
+
renew: true;
|
|
7
|
+
}>;
|
|
8
|
+
preferences: Readonly<{
|
|
9
|
+
name: "preferences";
|
|
10
|
+
ttlMs: 10000;
|
|
11
|
+
timeoutMs: 2000;
|
|
12
|
+
renew: true;
|
|
13
|
+
}>;
|
|
14
|
+
}>;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export const WRITER_LOCK_CONSTANTS = Object.freeze({
|
|
2
|
+
sidebar: Object.freeze({
|
|
3
|
+
name: 'sidebar-write',
|
|
4
|
+
ttlMs: 10_000,
|
|
5
|
+
timeoutMs: 15_000,
|
|
6
|
+
renew: true,
|
|
7
|
+
}),
|
|
8
|
+
preferences: Object.freeze({
|
|
9
|
+
name: 'preferences',
|
|
10
|
+
ttlMs: 10_000,
|
|
11
|
+
timeoutMs: 2_000,
|
|
12
|
+
renew: true,
|
|
13
|
+
}),
|
|
14
|
+
});
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
export declare function isLostMarkerRaceError(error: unknown): boolean;
|
|
2
|
+
export interface LockLoss {
|
|
3
|
+
readonly reason: 'taken-over' | 'expired' | 'unreadable' | 'renewal-failed' | 'marker-lost';
|
|
4
|
+
readonly expectedOwnerId: string;
|
|
5
|
+
readonly observedOwnerId?: string;
|
|
6
|
+
readonly observedExpiresAt?: number;
|
|
7
|
+
}
|
|
8
|
+
export interface RefreshFileLock {
|
|
9
|
+
readonly ownerId: string;
|
|
10
|
+
assertOwned(): Promise<void>;
|
|
11
|
+
release(): Promise<void>;
|
|
12
|
+
/** Resolves once on detected loss; remains pending after an owner's release. */
|
|
13
|
+
whenLost(): Promise<LockLoss>;
|
|
14
|
+
hasLost(): boolean;
|
|
15
|
+
}
|
|
16
|
+
export declare function acquireRefreshFileLock(options: {
|
|
17
|
+
name: string;
|
|
18
|
+
ttlMs: number;
|
|
19
|
+
/**
|
|
20
|
+
* File the lock is named after. Required: the lock and the write it guards
|
|
21
|
+
* must target the same file, and a default resolved in here could only ever
|
|
22
|
+
* be one host's path.
|
|
23
|
+
*/
|
|
24
|
+
path: string;
|
|
25
|
+
now?: () => number;
|
|
26
|
+
renew?: boolean;
|
|
27
|
+
renewIntervalMs?: number;
|
|
28
|
+
/** Notifies a live-owner refusal without awaiting; observer failures are ignored. */
|
|
29
|
+
onContended?: () => void;
|
|
30
|
+
/** Synchronous, never awaited; throws and returned promise/thenable rejections are isolated. */
|
|
31
|
+
onRenewalTimer?: (event: 'scheduled' | 'cancelled') => void;
|
|
32
|
+
onStep?: (step: 'stale-marker-stat' | 'stale-marker-claimed' | 'stale-lock-observed' | 'stale-lock-confirmed' | 'stale-lock-removed' | 'stale-lock-recreated' | 'eviction-marker-acquired' | 'renewal-owner-confirmed' | 'renewal-marker-unavailable' | 'renewal-write-fenced' | 'renewal-write-ready' | 'relinquish-read' | 'renewal-finished' | 'release-owner-confirmed') => void | Promise<void>;
|
|
33
|
+
}): Promise<RefreshFileLock | null>;
|
|
@@ -0,0 +1,501 @@
|
|
|
1
|
+
import { randomUUID } from 'node:crypto';
|
|
2
|
+
import { mkdir, open, readFile, rename, rm, stat, writeFile, } from 'node:fs/promises';
|
|
3
|
+
import { dirname, join } from 'node:path';
|
|
4
|
+
import { LockOwnershipError, lockPathFor } from './with-lock.js';
|
|
5
|
+
const setRefreshLockRenewalTimeout = globalThis.setTimeout.bind(globalThis);
|
|
6
|
+
const clearRefreshLockRenewalTimeout = globalThis.clearTimeout.bind(globalThis);
|
|
7
|
+
// A concurrent contender renaming the freshly-created eviction-marker directory
|
|
8
|
+
// away surfaces the vanished parent differently per platform: ENOENT on Linux,
|
|
9
|
+
// EINVAL or ENOTDIR on macOS/APFS. All three mean the marker is no longer ours
|
|
10
|
+
// to hold — a lost race the caller should retry, not a fatal lock error.
|
|
11
|
+
export function isLostMarkerRaceError(error) {
|
|
12
|
+
const code = error?.code;
|
|
13
|
+
return code === 'ENOENT' || code === 'EINVAL' || code === 'ENOTDIR';
|
|
14
|
+
}
|
|
15
|
+
export async function acquireRefreshFileLock(options) {
|
|
16
|
+
const lockPath = lockPathFor(options.path, options.name);
|
|
17
|
+
const legacyOwnerPath = join(lockPath, 'owner.json');
|
|
18
|
+
const ownerId = randomUUID();
|
|
19
|
+
const now = options.now ?? Date.now;
|
|
20
|
+
let renewTimer = null;
|
|
21
|
+
let released = false;
|
|
22
|
+
let loss;
|
|
23
|
+
let resolveLoss;
|
|
24
|
+
const lostPromise = new Promise((resolve) => {
|
|
25
|
+
resolveLoss = resolve;
|
|
26
|
+
});
|
|
27
|
+
function notifyTimerStep(event) {
|
|
28
|
+
try {
|
|
29
|
+
const result = options.onRenewalTimer?.(event);
|
|
30
|
+
if (result &&
|
|
31
|
+
(typeof result === 'object' || typeof result === 'function') &&
|
|
32
|
+
'then' in result &&
|
|
33
|
+
typeof result.then === 'function') {
|
|
34
|
+
void Promise.resolve(result).catch(() => { });
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
catch {
|
|
38
|
+
// Timer observer failures must not replace the lock operation result.
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
function cancelRenewalTimer() {
|
|
42
|
+
if (!renewTimer)
|
|
43
|
+
return;
|
|
44
|
+
clearRefreshLockRenewalTimeout(renewTimer);
|
|
45
|
+
renewTimer = null;
|
|
46
|
+
notifyTimerStep('cancelled');
|
|
47
|
+
}
|
|
48
|
+
function recordLoss(reason, owner) {
|
|
49
|
+
if (loss || released)
|
|
50
|
+
return;
|
|
51
|
+
loss = Object.freeze({
|
|
52
|
+
reason,
|
|
53
|
+
expectedOwnerId: ownerId,
|
|
54
|
+
...(typeof owner?.ownerId === 'string'
|
|
55
|
+
? { observedOwnerId: owner.ownerId }
|
|
56
|
+
: {}),
|
|
57
|
+
...(typeof owner?.expiresAt === 'number'
|
|
58
|
+
? { observedExpiresAt: owner.expiresAt }
|
|
59
|
+
: {}),
|
|
60
|
+
});
|
|
61
|
+
cancelRenewalTimer();
|
|
62
|
+
resolveLoss(loss);
|
|
63
|
+
}
|
|
64
|
+
let renewalInFlight = null;
|
|
65
|
+
// Only the owner of this exclusively-created marker may remove or renew a
|
|
66
|
+
// lock. A contender recovering a stale marker can accidentally rename a newer
|
|
67
|
+
// marker instead; checking its owner file before each mutation prevents the
|
|
68
|
+
// displaced owner from continuing to act on the lock.
|
|
69
|
+
const evictPath = `${lockPath}.evicting`;
|
|
70
|
+
const evictOwnerPath = join(evictPath, 'owner.json');
|
|
71
|
+
const evictOwnerId = randomUUID();
|
|
72
|
+
const EVICT_TTL = 5_000;
|
|
73
|
+
const MAX_STEAL_ATTEMPTS = 8;
|
|
74
|
+
async function readOwner() {
|
|
75
|
+
try {
|
|
76
|
+
return JSON.parse(await readFile(lockPath, 'utf8'));
|
|
77
|
+
}
|
|
78
|
+
catch (error) {
|
|
79
|
+
const code = error.code;
|
|
80
|
+
if (code !== 'EISDIR')
|
|
81
|
+
throw error;
|
|
82
|
+
return JSON.parse(await readFile(legacyOwnerPath, 'utf8'));
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
async function writeOwner() {
|
|
86
|
+
// Readers must see a complete lease, even while renewal is writing.
|
|
87
|
+
const tempPath = `${lockPath}.${randomUUID()}.tmp`;
|
|
88
|
+
let handle;
|
|
89
|
+
let created = false;
|
|
90
|
+
try {
|
|
91
|
+
handle = await open(tempPath, 'wx', 0o600);
|
|
92
|
+
created = true;
|
|
93
|
+
await handle.writeFile(`${JSON.stringify({ ownerId, expiresAt: now() + options.ttlMs })}\n`, 'utf8');
|
|
94
|
+
await handle.chmod(0o600);
|
|
95
|
+
await handle.close();
|
|
96
|
+
handle = undefined;
|
|
97
|
+
await rename(tempPath, lockPath);
|
|
98
|
+
created = false;
|
|
99
|
+
}
|
|
100
|
+
finally {
|
|
101
|
+
await handle?.close().catch(() => { });
|
|
102
|
+
if (created)
|
|
103
|
+
await rm(tempPath, { force: true }).catch(() => { });
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
async function tryAcquire() {
|
|
107
|
+
try {
|
|
108
|
+
await writeFile(lockPath, `${JSON.stringify({ ownerId, expiresAt: now() + options.ttlMs })}\n`, { encoding: 'utf8', mode: 0o600, flag: 'wx' });
|
|
109
|
+
return true;
|
|
110
|
+
}
|
|
111
|
+
catch (error) {
|
|
112
|
+
const code = error.code;
|
|
113
|
+
if (code === 'EEXIST' || code === 'EISDIR')
|
|
114
|
+
return false;
|
|
115
|
+
if (code === 'ENOENT') {
|
|
116
|
+
// Reboots can clear runtime temp directories before the next lock acquisition.
|
|
117
|
+
await mkdir(dirname(lockPath), { recursive: true });
|
|
118
|
+
try {
|
|
119
|
+
await writeFile(lockPath, `${JSON.stringify({ ownerId, expiresAt: now() + options.ttlMs })}\n`, { encoding: 'utf8', mode: 0o600, flag: 'wx' });
|
|
120
|
+
return true;
|
|
121
|
+
}
|
|
122
|
+
catch (retryError) {
|
|
123
|
+
const retryCode = retryError.code;
|
|
124
|
+
if (retryCode === 'EEXIST' || retryCode === 'EISDIR')
|
|
125
|
+
return false;
|
|
126
|
+
throw retryError;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
throw error;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
async function backoff() {
|
|
133
|
+
await new Promise((resolve) => setTimeout(resolve, Math.floor(Math.random() * 4)));
|
|
134
|
+
}
|
|
135
|
+
async function lockIsLive() {
|
|
136
|
+
try {
|
|
137
|
+
const currentOwner = await readOwner();
|
|
138
|
+
return Number(currentOwner?.expiresAt) > now();
|
|
139
|
+
}
|
|
140
|
+
catch {
|
|
141
|
+
try {
|
|
142
|
+
const current = await stat(lockPath);
|
|
143
|
+
return current.mtimeMs + options.ttlMs > now();
|
|
144
|
+
}
|
|
145
|
+
catch {
|
|
146
|
+
// Lock doesn't exist — safe to acquire.
|
|
147
|
+
return false;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
// Fail-closed: any read error means we do NOT own the marker.
|
|
152
|
+
async function ownsEvictionMarker() {
|
|
153
|
+
try {
|
|
154
|
+
const owner = JSON.parse(await readFile(evictOwnerPath, 'utf8'));
|
|
155
|
+
return owner?.ownerId === evictOwnerId;
|
|
156
|
+
}
|
|
157
|
+
catch {
|
|
158
|
+
return false;
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
async function releaseEvictionMarker() {
|
|
162
|
+
if (await ownsEvictionMarker()) {
|
|
163
|
+
await rm(evictPath, { recursive: true, force: true }).catch(() => { });
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
async function tryAcquireEvictionMarker() {
|
|
167
|
+
await mkdir(evictPath);
|
|
168
|
+
try {
|
|
169
|
+
await writeFile(evictOwnerPath, `${JSON.stringify({ ownerId: evictOwnerId, createdAt: now() })}\n`, { encoding: 'utf8', mode: 0o600, flag: 'wx' });
|
|
170
|
+
}
|
|
171
|
+
catch (error) {
|
|
172
|
+
// A competing contender can rename our just-created marker directory
|
|
173
|
+
// away between the mkdir above and this write (the stale-marker steal
|
|
174
|
+
// path below does exactly that). That is a lost race, not a failure, so
|
|
175
|
+
// report it as such and let the caller back off and retry rather than
|
|
176
|
+
// failing the whole lock acquisition.
|
|
177
|
+
if (isLostMarkerRaceError(error))
|
|
178
|
+
return false;
|
|
179
|
+
await releaseEvictionMarker();
|
|
180
|
+
throw error;
|
|
181
|
+
}
|
|
182
|
+
if (options.onStep)
|
|
183
|
+
await options.onStep('eviction-marker-acquired');
|
|
184
|
+
return true;
|
|
185
|
+
}
|
|
186
|
+
async function recoverStaleEvictionMarker() {
|
|
187
|
+
let evictStat;
|
|
188
|
+
try {
|
|
189
|
+
evictStat = await stat(evictPath);
|
|
190
|
+
}
|
|
191
|
+
catch (error) {
|
|
192
|
+
if (error.code === 'ENOENT')
|
|
193
|
+
return 'missing';
|
|
194
|
+
throw error;
|
|
195
|
+
}
|
|
196
|
+
if (evictStat.mtimeMs + EVICT_TTL > now())
|
|
197
|
+
return 'fresh';
|
|
198
|
+
if (options.onStep)
|
|
199
|
+
await options.onStep('stale-marker-stat');
|
|
200
|
+
const claimedPath = `${evictPath}.${randomUUID()}`;
|
|
201
|
+
try {
|
|
202
|
+
await rename(evictPath, claimedPath);
|
|
203
|
+
}
|
|
204
|
+
catch (error) {
|
|
205
|
+
if (error.code === 'ENOENT')
|
|
206
|
+
return 'missing';
|
|
207
|
+
throw error;
|
|
208
|
+
}
|
|
209
|
+
if (options.onStep)
|
|
210
|
+
await options.onStep('stale-marker-claimed');
|
|
211
|
+
await rm(claimedPath, { recursive: true, force: true }).catch(() => { });
|
|
212
|
+
return 'recovered';
|
|
213
|
+
}
|
|
214
|
+
async function withEvictionMarker(action) {
|
|
215
|
+
try {
|
|
216
|
+
if (!(await tryAcquireEvictionMarker()))
|
|
217
|
+
return false;
|
|
218
|
+
}
|
|
219
|
+
catch (error) {
|
|
220
|
+
if (error.code === 'EEXIST')
|
|
221
|
+
return false;
|
|
222
|
+
throw error;
|
|
223
|
+
}
|
|
224
|
+
try {
|
|
225
|
+
await action();
|
|
226
|
+
}
|
|
227
|
+
finally {
|
|
228
|
+
await releaseEvictionMarker();
|
|
229
|
+
}
|
|
230
|
+
return true;
|
|
231
|
+
}
|
|
232
|
+
// Marker loss after a write may mean another contender has taken over.
|
|
233
|
+
// Delete only a record still owned by us, so an already-installed
|
|
234
|
+
// successor is preserved. The owner read and the removal are not atomic:
|
|
235
|
+
// a successor record written between them can still be deleted.
|
|
236
|
+
async function relinquishLockAfterMarkerLoss() {
|
|
237
|
+
for (let attempt = 0; attempt < MAX_STEAL_ATTEMPTS; attempt++) {
|
|
238
|
+
if (options.onStep)
|
|
239
|
+
await options.onStep('relinquish-read');
|
|
240
|
+
let owner;
|
|
241
|
+
try {
|
|
242
|
+
owner = await readOwner();
|
|
243
|
+
}
|
|
244
|
+
catch {
|
|
245
|
+
return;
|
|
246
|
+
}
|
|
247
|
+
if (owner?.ownerId !== ownerId)
|
|
248
|
+
return;
|
|
249
|
+
try {
|
|
250
|
+
await rm(lockPath, { recursive: true, force: true });
|
|
251
|
+
return;
|
|
252
|
+
}
|
|
253
|
+
catch {
|
|
254
|
+
await backoff();
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
function scheduleRenewal() {
|
|
259
|
+
if (!options.renew || released || loss)
|
|
260
|
+
return;
|
|
261
|
+
const intervalMs = options.renewIntervalMs ?? Math.max(1_000, Math.floor(options.ttlMs / 3));
|
|
262
|
+
renewTimer = setRefreshLockRenewalTimeout(() => {
|
|
263
|
+
renewTimer = null;
|
|
264
|
+
const renewal = (async () => {
|
|
265
|
+
let shouldReschedule = !released;
|
|
266
|
+
try {
|
|
267
|
+
const markerAcquired = await withEvictionMarker(async () => {
|
|
268
|
+
const owner = await readOwner();
|
|
269
|
+
const currentNow = now();
|
|
270
|
+
if (released || loss) {
|
|
271
|
+
shouldReschedule = false;
|
|
272
|
+
return;
|
|
273
|
+
}
|
|
274
|
+
if (owner?.ownerId !== ownerId) {
|
|
275
|
+
recordLoss('taken-over', owner);
|
|
276
|
+
shouldReschedule = false;
|
|
277
|
+
return;
|
|
278
|
+
}
|
|
279
|
+
// An expired lease is no longer ours to extend; a contender may
|
|
280
|
+
// already be eligible to acquire it.
|
|
281
|
+
if (!(Number(owner?.expiresAt) > currentNow)) {
|
|
282
|
+
recordLoss('expired', owner);
|
|
283
|
+
shouldReschedule = false;
|
|
284
|
+
return;
|
|
285
|
+
}
|
|
286
|
+
if (options.onStep)
|
|
287
|
+
await options.onStep('renewal-owner-confirmed');
|
|
288
|
+
if (released || loss) {
|
|
289
|
+
shouldReschedule = false;
|
|
290
|
+
return;
|
|
291
|
+
}
|
|
292
|
+
if (!(await ownsEvictionMarker()))
|
|
293
|
+
return;
|
|
294
|
+
if (options.onStep)
|
|
295
|
+
await options.onStep('renewal-write-fenced');
|
|
296
|
+
if (released || loss) {
|
|
297
|
+
shouldReschedule = false;
|
|
298
|
+
return;
|
|
299
|
+
}
|
|
300
|
+
if (!(await ownsEvictionMarker()))
|
|
301
|
+
return;
|
|
302
|
+
if (options.onStep)
|
|
303
|
+
await options.onStep('renewal-write-ready');
|
|
304
|
+
if (released || loss) {
|
|
305
|
+
shouldReschedule = false;
|
|
306
|
+
return;
|
|
307
|
+
}
|
|
308
|
+
await writeOwner();
|
|
309
|
+
if (!(await ownsEvictionMarker())) {
|
|
310
|
+
// If marker ownership cannot be read, stop claiming the lease
|
|
311
|
+
// and remove only a record that still carries our owner id.
|
|
312
|
+
recordLoss('marker-lost');
|
|
313
|
+
shouldReschedule = false;
|
|
314
|
+
await relinquishLockAfterMarkerLoss();
|
|
315
|
+
return;
|
|
316
|
+
}
|
|
317
|
+
});
|
|
318
|
+
if (!markerAcquired && options.onStep) {
|
|
319
|
+
await options.onStep('renewal-marker-unavailable');
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
catch {
|
|
323
|
+
// Retry transient failures only while the lease can still be verified.
|
|
324
|
+
try {
|
|
325
|
+
const owner = await readOwner();
|
|
326
|
+
if (owner?.ownerId !== ownerId)
|
|
327
|
+
recordLoss('taken-over', owner);
|
|
328
|
+
else if (!(Number(owner?.expiresAt) > now()))
|
|
329
|
+
recordLoss('expired', owner);
|
|
330
|
+
}
|
|
331
|
+
catch {
|
|
332
|
+
recordLoss('renewal-failed');
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
finally {
|
|
336
|
+
if (options.onStep) {
|
|
337
|
+
try {
|
|
338
|
+
await options.onStep('renewal-finished');
|
|
339
|
+
}
|
|
340
|
+
catch {
|
|
341
|
+
// Errors from the onStep observer must not reject the renewal.
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
if (shouldReschedule && !released && !loss)
|
|
345
|
+
scheduleRenewal();
|
|
346
|
+
}
|
|
347
|
+
})();
|
|
348
|
+
renewalInFlight = renewal;
|
|
349
|
+
void renewal.finally(() => {
|
|
350
|
+
if (renewalInFlight === renewal)
|
|
351
|
+
renewalInFlight = null;
|
|
352
|
+
});
|
|
353
|
+
}, intervalMs);
|
|
354
|
+
if ('unref' in renewTimer)
|
|
355
|
+
renewTimer.unref();
|
|
356
|
+
notifyTimerStep('scheduled');
|
|
357
|
+
}
|
|
358
|
+
function contended() {
|
|
359
|
+
try {
|
|
360
|
+
const result = options.onContended?.();
|
|
361
|
+
if (result &&
|
|
362
|
+
(typeof result === 'object' || typeof result === 'function') &&
|
|
363
|
+
'then' in result &&
|
|
364
|
+
typeof result.then === 'function') {
|
|
365
|
+
void Promise.resolve(result).catch(() => { });
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
catch {
|
|
369
|
+
// Observers cannot change whether the lock is acquired.
|
|
370
|
+
}
|
|
371
|
+
return null;
|
|
372
|
+
}
|
|
373
|
+
let acquired = await tryAcquire();
|
|
374
|
+
if (!acquired) {
|
|
375
|
+
for (let attempt = 0; attempt < MAX_STEAL_ATTEMPTS; attempt++) {
|
|
376
|
+
acquired = await tryAcquire();
|
|
377
|
+
if (acquired)
|
|
378
|
+
break;
|
|
379
|
+
if (await lockIsLive())
|
|
380
|
+
return contended();
|
|
381
|
+
if (options.onStep)
|
|
382
|
+
await options.onStep('stale-lock-observed');
|
|
383
|
+
try {
|
|
384
|
+
if (!(await tryAcquireEvictionMarker())) {
|
|
385
|
+
await backoff();
|
|
386
|
+
continue;
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
catch (evictError) {
|
|
390
|
+
const code = evictError.code;
|
|
391
|
+
if (code !== 'EEXIST')
|
|
392
|
+
throw evictError;
|
|
393
|
+
const recovered = await recoverStaleEvictionMarker();
|
|
394
|
+
if (recovered === 'fresh')
|
|
395
|
+
return null;
|
|
396
|
+
await backoff();
|
|
397
|
+
continue;
|
|
398
|
+
}
|
|
399
|
+
try {
|
|
400
|
+
if (await lockIsLive())
|
|
401
|
+
return contended();
|
|
402
|
+
// Verify marker ownership before removing a lock found not live.
|
|
403
|
+
if (!(await ownsEvictionMarker()))
|
|
404
|
+
return null;
|
|
405
|
+
if (options.onStep)
|
|
406
|
+
await options.onStep('stale-lock-confirmed');
|
|
407
|
+
// The onStep callback can pause while another contender renames
|
|
408
|
+
// our marker, so verify ownership again after the callback.
|
|
409
|
+
if (!(await ownsEvictionMarker()))
|
|
410
|
+
return null;
|
|
411
|
+
await rm(lockPath, { recursive: true, force: true }).catch(() => { });
|
|
412
|
+
// Fence check 3: re-verify ownership after removing the stale lock.
|
|
413
|
+
if (!(await ownsEvictionMarker()))
|
|
414
|
+
return null;
|
|
415
|
+
if (options.onStep)
|
|
416
|
+
await options.onStep('stale-lock-removed');
|
|
417
|
+
acquired = await tryAcquire();
|
|
418
|
+
if (!acquired)
|
|
419
|
+
return null;
|
|
420
|
+
if (options.onStep)
|
|
421
|
+
await options.onStep('stale-lock-recreated');
|
|
422
|
+
// Fence check 4: re-verify ownership after acquiring the lock. If the
|
|
423
|
+
// marker was stolen between tryAcquire and this check, release the
|
|
424
|
+
// just-acquired lock and return null (fail-closed).
|
|
425
|
+
if (!(await ownsEvictionMarker())) {
|
|
426
|
+
await relinquishLockAfterMarkerLoss();
|
|
427
|
+
acquired = false;
|
|
428
|
+
return null;
|
|
429
|
+
}
|
|
430
|
+
break;
|
|
431
|
+
}
|
|
432
|
+
finally {
|
|
433
|
+
await releaseEvictionMarker();
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
if (!acquired)
|
|
438
|
+
return null;
|
|
439
|
+
scheduleRenewal();
|
|
440
|
+
return {
|
|
441
|
+
ownerId,
|
|
442
|
+
whenLost: () => lostPromise,
|
|
443
|
+
hasLost: () => loss !== undefined,
|
|
444
|
+
assertOwned: async () => {
|
|
445
|
+
let observed;
|
|
446
|
+
try {
|
|
447
|
+
const owner = await readOwner();
|
|
448
|
+
observed = owner;
|
|
449
|
+
if (!released &&
|
|
450
|
+
!loss &&
|
|
451
|
+
owner?.ownerId === ownerId &&
|
|
452
|
+
Number(owner?.expiresAt) > now())
|
|
453
|
+
return;
|
|
454
|
+
recordLoss(owner?.ownerId !== ownerId ? 'taken-over' : 'expired', owner);
|
|
455
|
+
}
|
|
456
|
+
catch {
|
|
457
|
+
// Unreadable ownership is not evidence of a valid lease.
|
|
458
|
+
recordLoss('unreadable');
|
|
459
|
+
}
|
|
460
|
+
throw new LockOwnershipError({
|
|
461
|
+
target: options.path,
|
|
462
|
+
name: options.name,
|
|
463
|
+
expectedOwnerId: ownerId,
|
|
464
|
+
...(typeof observed?.ownerId === 'string'
|
|
465
|
+
? { observedOwnerId: observed.ownerId }
|
|
466
|
+
: {}),
|
|
467
|
+
...(typeof observed?.expiresAt === 'number'
|
|
468
|
+
? { observedExpiresAt: observed.expiresAt }
|
|
469
|
+
: {}),
|
|
470
|
+
});
|
|
471
|
+
},
|
|
472
|
+
release: async () => {
|
|
473
|
+
released = true;
|
|
474
|
+
cancelRenewalTimer();
|
|
475
|
+
await renewalInFlight;
|
|
476
|
+
for (let attempt = 0; attempt < MAX_STEAL_ATTEMPTS; attempt++) {
|
|
477
|
+
try {
|
|
478
|
+
const markerAcquired = await withEvictionMarker(async () => {
|
|
479
|
+
const owner = await readOwner();
|
|
480
|
+
if (owner?.ownerId !== ownerId)
|
|
481
|
+
return;
|
|
482
|
+
if (options.onStep)
|
|
483
|
+
await options.onStep('release-owner-confirmed');
|
|
484
|
+
if (!(await ownsEvictionMarker()))
|
|
485
|
+
return;
|
|
486
|
+
await rm(lockPath, { recursive: true, force: true }).catch(() => { });
|
|
487
|
+
});
|
|
488
|
+
if (markerAcquired)
|
|
489
|
+
return;
|
|
490
|
+
await recoverStaleEvictionMarker();
|
|
491
|
+
}
|
|
492
|
+
catch {
|
|
493
|
+
return;
|
|
494
|
+
}
|
|
495
|
+
await backoff();
|
|
496
|
+
}
|
|
497
|
+
// Do not delete by pathname without the marker: bounded retries leave the
|
|
498
|
+
// lease to expire rather than risking removal of a successor's lock.
|
|
499
|
+
},
|
|
500
|
+
};
|
|
501
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
export declare function lockPathFor(target: string, name: string): string;
|
|
2
|
+
export declare class LockContentionError extends Error {
|
|
3
|
+
readonly details: {
|
|
4
|
+
target: string;
|
|
5
|
+
name: string;
|
|
6
|
+
timeoutMs: number;
|
|
7
|
+
};
|
|
8
|
+
constructor(details: {
|
|
9
|
+
target: string;
|
|
10
|
+
name: string;
|
|
11
|
+
timeoutMs: number;
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
export interface LockOwnershipDetails {
|
|
15
|
+
target: string;
|
|
16
|
+
name: string;
|
|
17
|
+
expectedOwnerId?: string;
|
|
18
|
+
observedOwnerId?: string;
|
|
19
|
+
observedExpiresAt?: number;
|
|
20
|
+
}
|
|
21
|
+
export declare class LockOwnershipError extends Error {
|
|
22
|
+
readonly details: LockOwnershipDetails;
|
|
23
|
+
constructor(details: LockOwnershipDetails);
|
|
24
|
+
}
|
|
25
|
+
export interface LockOptions {
|
|
26
|
+
name: string;
|
|
27
|
+
ttlMs: number;
|
|
28
|
+
timeoutMs: number;
|
|
29
|
+
renew?: boolean;
|
|
30
|
+
}
|
|
31
|
+
export declare function withLock<T>(target: string, options: LockOptions, fn: (lock: {
|
|
32
|
+
assertOwned(): Promise<void>;
|
|
33
|
+
}) => Promise<T>): Promise<T>;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { acquireRefreshFileLock } from './refresh-file-lock.js';
|
|
2
|
+
export function lockPathFor(target, name) {
|
|
3
|
+
return `${target}.${name}.lock`;
|
|
4
|
+
}
|
|
5
|
+
export class LockContentionError extends Error {
|
|
6
|
+
details;
|
|
7
|
+
constructor(details) {
|
|
8
|
+
super(`Timed out acquiring ${details.name} lock for ${details.target}`);
|
|
9
|
+
this.name = 'LockContentionError';
|
|
10
|
+
this.details = details;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
export class LockOwnershipError extends Error {
|
|
14
|
+
details;
|
|
15
|
+
constructor(details) {
|
|
16
|
+
super(`Lost ${details.name} lock for ${details.target}`);
|
|
17
|
+
this.name = 'LockOwnershipError';
|
|
18
|
+
this.details = details;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
export async function withLock(target, options, fn) {
|
|
22
|
+
const started = performance.now();
|
|
23
|
+
for (;;) {
|
|
24
|
+
const lock = await acquireRefreshFileLock({
|
|
25
|
+
path: target,
|
|
26
|
+
name: options.name,
|
|
27
|
+
ttlMs: options.ttlMs,
|
|
28
|
+
renew: options.renew ?? false,
|
|
29
|
+
});
|
|
30
|
+
if (lock) {
|
|
31
|
+
try {
|
|
32
|
+
return await fn(lock);
|
|
33
|
+
}
|
|
34
|
+
finally {
|
|
35
|
+
await lock.release();
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
const remaining = options.timeoutMs - (performance.now() - started);
|
|
39
|
+
if (remaining <= 0) {
|
|
40
|
+
throw new LockContentionError({
|
|
41
|
+
target,
|
|
42
|
+
name: options.name,
|
|
43
|
+
timeoutMs: options.timeoutMs,
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
await new Promise((resolve) => setTimeout(resolve, Math.min(25, Math.ceil(remaining))));
|
|
47
|
+
}
|
|
48
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { Level } from './engine.js';
|
|
2
|
+
export interface LogTestRecord {
|
|
3
|
+
channel: string;
|
|
4
|
+
level: Level;
|
|
5
|
+
message: string;
|
|
6
|
+
data?: unknown;
|
|
7
|
+
}
|
|
8
|
+
/** The engine delivers scrubbed records only; this sink never sees raw credentials. */
|
|
9
|
+
export type CaptureSink = (record: LogTestRecord) => void;
|
|
10
|
+
export declare function createCaptureSink(): {
|
|
11
|
+
records: LogTestRecord[];
|
|
12
|
+
sink: CaptureSink;
|
|
13
|
+
clear: () => void;
|
|
14
|
+
};
|