@cortexkit/opencode-antigravity-auth 3.0.5 → 3.0.7
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 +38 -352
- package/dist/cli.js +13757 -12857
- package/dist/cli.js.map +4 -4
- package/dist/cli.meta.json +1362 -1056
- package/dist/index.js +16038 -16162
- package/dist/index.js.map +4 -4
- package/dist/index.meta.json +1447 -1375
- package/dist/server.js +11254 -10921
- package/dist/server.js.map +4 -4
- package/dist/server.meta.json +1 -1
- package/dist/src/auth-method-labels.d.ts +3 -0
- package/dist/src/auth-method-labels.d.ts.map +1 -0
- package/dist/src/auth-method-labels.js +5 -0
- package/dist/src/auth-method-labels.js.map +1 -0
- package/dist/src/cli.d.ts +3 -1
- package/dist/src/cli.d.ts.map +1 -1
- package/dist/src/cli.js +98 -12
- package/dist/src/cli.js.map +1 -1
- package/dist/src/common-auth-embedded/claustrum/consumer.d.ts +44 -4
- package/dist/src/common-auth-embedded/claustrum/consumer.js +134 -2
- package/dist/src/common-auth-embedded/claustrum/custody.d.ts +33 -1
- package/dist/src/common-auth-embedded/claustrum/custody.js +17 -0
- package/dist/src/common-auth-embedded/claustrum/enrollment.d.ts +6 -1
- package/dist/src/common-auth-embedded/claustrum/enrollment.js +6 -1
- package/dist/src/common-auth-embedded/claustrum/index.d.ts +3 -2
- package/dist/src/common-auth-embedded/claustrum/index.js +5 -3
- package/dist/src/common-auth-embedded/claustrum/insula.d.ts +69 -0
- package/dist/src/common-auth-embedded/claustrum/insula.js +152 -0
- package/dist/src/common-auth-embedded/claustrum/roster.d.ts +13 -0
- package/dist/src/common-auth-embedded/claustrum/roster.js +33 -3
- package/dist/src/common-auth-embedded/fs/refresh-file-lock.d.ts +8 -2
- package/dist/src/common-auth-embedded/fs/refresh-file-lock.js +26 -12
- package/dist/src/common-auth-embedded/pi-slot/lock.js +7 -3
- package/dist/src/common-auth-embedded/quota/codec.d.ts +2 -0
- package/dist/src/common-auth-embedded/quota/codec.js +2 -1
- package/dist/src/common-auth-embedded/quota/format.d.ts +40 -3
- package/dist/src/common-auth-embedded/quota/format.js +196 -43
- package/dist/src/common-auth-embedded/quota/index.d.ts +4 -4
- package/dist/src/common-auth-embedded/quota/index.js +2 -2
- package/dist/src/common-auth-embedded/quota/map.d.ts +11 -0
- package/dist/src/common-auth-embedded/quota/map.js +36 -1
- package/dist/src/common-auth-embedded/quota/merge.d.ts +3 -1
- package/dist/src/common-auth-embedded/quota/merge.js +21 -5
- package/dist/src/common-auth-embedded/quota/projection.d.ts +2 -1
- package/dist/src/common-auth-embedded/quota/projection.js +3 -1
- package/dist/src/common-auth-embedded/setup/command-error.d.ts +32 -0
- package/dist/src/common-auth-embedded/setup/command-error.js +79 -0
- package/dist/src/common-auth-embedded/setup/command-runner.js +143 -0
- package/dist/src/common-auth-embedded/setup/command.d.ts +3 -0
- package/dist/src/common-auth-embedded/setup/command.js +271 -0
- package/dist/src/common-auth-embedded/setup/config-write.js +60 -0
- package/dist/src/common-auth-embedded/setup/detect.d.ts +6 -0
- package/dist/src/common-auth-embedded/setup/detect.js +224 -0
- package/dist/src/common-auth-embedded/setup/enroll.js +82 -0
- package/dist/src/common-auth-embedded/setup/index.d.ts +6 -0
- package/dist/src/common-auth-embedded/setup/index.js +5 -0
- package/dist/src/common-auth-embedded/setup/paths.js +33 -0
- package/dist/src/common-auth-embedded/setup/process-fence.d.ts +43 -0
- package/dist/src/common-auth-embedded/setup/process-fence.js +270 -0
- package/dist/src/common-auth-embedded/setup/prompts.js +26 -0
- package/dist/src/common-auth-embedded/setup/register.d.ts +11 -0
- package/dist/src/common-auth-embedded/setup/register.js +136 -0
- package/dist/src/common-auth-embedded/setup/types.d.ts +150 -0
- package/dist/src/common-auth-embedded/source-output.json +265 -101
- package/dist/src/common-auth-embedded/store/pool.d.ts +1 -1
- package/dist/src/common-auth-embedded/store/pool.js +0 -1
- package/dist/src/common-auth-embedded/store/refresh-lock.d.ts +0 -1
- package/dist/src/common-auth-embedded/store/refresh-lock.js +0 -1
- package/dist/src/common-auth-embedded/store/schema.d.ts +2 -0
- package/dist/src/common-auth-embedded/store/schema.js +3 -2
- package/dist/src/ga/rpc/protocol.d.ts +4 -7
- package/dist/src/ga/rpc/protocol.d.ts.map +1 -1
- package/dist/src/ga/rpc/protocol.js +5 -13
- package/dist/src/ga/rpc/protocol.js.map +1 -1
- package/dist/src/ga/server/auth.d.ts +8 -3
- package/dist/src/ga/server/auth.d.ts.map +1 -1
- package/dist/src/ga/server/auth.js +25 -9
- package/dist/src/ga/server/auth.js.map +1 -1
- package/dist/src/ga/server/index.d.ts +39 -12
- package/dist/src/ga/server/index.d.ts.map +1 -1
- package/dist/src/ga/server/index.js +218 -55
- package/dist/src/ga/server/index.js.map +1 -1
- package/dist/src/ga/server/pool-login.d.ts +22 -0
- package/dist/src/ga/server/pool-login.d.ts.map +1 -0
- package/dist/src/ga/server/pool-login.js +150 -0
- package/dist/src/ga/server/pool-login.js.map +1 -0
- package/dist/src/ga/tui/host-ga.d.ts +2 -5
- package/dist/src/ga/tui/host-ga.d.ts.map +1 -1
- package/dist/src/ga/tui/host-ga.js +54 -52
- package/dist/src/ga/tui/host-ga.js.map +1 -1
- package/dist/src/plugin/accounts.d.ts +1 -1
- package/dist/src/plugin/accounts.d.ts.map +1 -1
- package/dist/src/plugin/accounts.js +1 -0
- package/dist/src/plugin/accounts.js.map +1 -1
- package/dist/src/plugin/background-vault-quota-refresh.d.ts +2 -0
- package/dist/src/plugin/background-vault-quota-refresh.d.ts.map +1 -1
- package/dist/src/plugin/background-vault-quota-refresh.js +125 -10
- package/dist/src/plugin/background-vault-quota-refresh.js.map +1 -1
- package/dist/src/plugin/command-apply.d.ts +2 -2
- package/dist/src/plugin/command-apply.d.ts.map +1 -1
- package/dist/src/plugin/command-apply.js +3 -10
- package/dist/src/plugin/command-apply.js.map +1 -1
- package/dist/src/plugin/commands.d.ts +1 -0
- package/dist/src/plugin/commands.d.ts.map +1 -1
- package/dist/src/plugin/commands.js +2 -2
- package/dist/src/plugin/commands.js.map +1 -1
- package/dist/src/plugin/config/operator-settings-schema.d.ts +0 -4
- package/dist/src/plugin/config/operator-settings-schema.d.ts.map +1 -1
- package/dist/src/plugin/config/operator-settings-schema.js +0 -5
- package/dist/src/plugin/config/operator-settings-schema.js.map +1 -1
- package/dist/src/plugin/config/schema.d.ts +0 -7
- package/dist/src/plugin/config/schema.d.ts.map +1 -1
- package/dist/src/plugin/config/schema.js +2 -44
- package/dist/src/plugin/config/schema.js.map +1 -1
- package/dist/src/plugin/config/writer.d.ts +1 -1
- package/dist/src/plugin/config/writer.js +1 -1
- package/dist/src/plugin/fetch/retry-state.d.ts +19 -3
- package/dist/src/plugin/fetch/retry-state.d.ts.map +1 -1
- package/dist/src/plugin/fetch/retry-state.js +0 -6
- package/dist/src/plugin/fetch/retry-state.js.map +1 -1
- package/dist/src/plugin/fetch-interceptor.d.ts.map +1 -1
- package/dist/src/plugin/fetch-interceptor.js +0 -3
- package/dist/src/plugin/fetch-interceptor.js.map +1 -1
- package/dist/src/plugin/fetch-routing.d.ts +0 -16
- package/dist/src/plugin/fetch-routing.d.ts.map +1 -1
- package/dist/src/plugin/fetch-routing.js +0 -49
- package/dist/src/plugin/fetch-routing.js.map +1 -1
- package/dist/src/plugin/ga-location-services.d.ts +14 -9
- package/dist/src/plugin/ga-location-services.d.ts.map +1 -1
- package/dist/src/plugin/ga-location-services.js +124 -43
- package/dist/src/plugin/ga-location-services.js.map +1 -1
- package/dist/src/plugin/gemini-dump.d.ts.map +1 -1
- package/dist/src/plugin/gemini-dump.js +2 -5
- package/dist/src/plugin/gemini-dump.js.map +1 -1
- package/dist/src/plugin/google-origin.d.ts +7 -0
- package/dist/src/plugin/google-origin.d.ts.map +1 -0
- package/dist/src/plugin/google-origin.js +14 -0
- package/dist/src/plugin/google-origin.js.map +1 -0
- package/dist/src/plugin/index.d.ts.map +1 -1
- package/dist/src/plugin/index.js +18 -7
- package/dist/src/plugin/index.js.map +1 -1
- package/dist/src/plugin/logging-utils.d.ts.map +1 -1
- package/dist/src/plugin/logging-utils.js +2 -5
- package/dist/src/plugin/logging-utils.js.map +1 -1
- package/dist/src/plugin/oauth-methods.d.ts.map +1 -1
- package/dist/src/plugin/oauth-methods.js +0 -33
- package/dist/src/plugin/oauth-methods.js.map +1 -1
- package/dist/src/plugin/operator-settings.d.ts +1 -1
- package/dist/src/plugin/operator-settings.d.ts.map +1 -1
- package/dist/src/plugin/operator-settings.js +1 -8
- package/dist/src/plugin/operator-settings.js.map +1 -1
- package/dist/src/plugin/quota.d.ts +11 -7
- package/dist/src/plugin/quota.d.ts.map +1 -1
- package/dist/src/plugin/quota.js +128 -102
- package/dist/src/plugin/quota.js.map +1 -1
- package/dist/src/plugin/request.d.ts +6 -5
- package/dist/src/plugin/request.d.ts.map +1 -1
- package/dist/src/plugin/request.js +95 -180
- package/dist/src/plugin/request.js.map +1 -1
- package/dist/src/plugin/server.d.ts.map +1 -1
- package/dist/src/plugin/server.js +60 -53
- package/dist/src/plugin/server.js.map +1 -1
- package/dist/src/plugin/shared/advisory-repository.d.ts +20 -0
- package/dist/src/plugin/shared/advisory-repository.d.ts.map +1 -0
- package/dist/src/plugin/shared/advisory-repository.js +91 -0
- package/dist/src/plugin/shared/advisory-repository.js.map +1 -0
- package/dist/src/plugin/shared/request-services.d.ts +27 -26
- package/dist/src/plugin/shared/request-services.d.ts.map +1 -1
- package/dist/src/plugin/shared/request-services.js +244 -245
- package/dist/src/plugin/shared/request-services.js.map +1 -1
- package/dist/src/plugin/shared/runtime.js +4 -2
- package/dist/src/plugin/shared/runtime.js.map +1 -1
- package/dist/src/plugin/shared/vault-request-credentials.d.ts +16 -4
- package/dist/src/plugin/shared/vault-request-credentials.d.ts.map +1 -1
- package/dist/src/plugin/shared/vault-request-credentials.js +44 -7
- package/dist/src/plugin/shared/vault-request-credentials.js.map +1 -1
- package/dist/src/plugin/storage.d.ts +2 -2
- package/dist/src/plugin/storage.d.ts.map +1 -1
- package/dist/src/plugin/storage.js.map +1 -1
- package/dist/src/plugin/vault-custody.d.ts +14 -1
- package/dist/src/plugin/vault-custody.d.ts.map +1 -1
- package/dist/src/plugin/vault-custody.js +203 -44
- package/dist/src/plugin/vault-custody.js.map +1 -1
- package/dist/src/plugin/vault-quota-outcome.d.ts +19 -0
- package/dist/src/plugin/vault-quota-outcome.d.ts.map +1 -0
- package/dist/src/plugin/vault-quota-outcome.js +47 -0
- package/dist/src/plugin/vault-quota-outcome.js.map +1 -0
- package/dist/src/quota-presentation.d.ts +29 -1
- package/dist/src/quota-presentation.d.ts.map +1 -1
- package/dist/src/quota-presentation.js +52 -17
- package/dist/src/quota-presentation.js.map +1 -1
- package/dist/src/setup.d.ts +15 -0
- package/dist/src/setup.d.ts.map +1 -0
- package/dist/src/setup.js +320 -0
- package/dist/src/setup.js.map +1 -0
- package/dist/src/sidebar-projection.d.ts +5 -1
- package/dist/src/sidebar-projection.d.ts.map +1 -1
- package/dist/src/sidebar-projection.js +6 -2
- package/dist/src/sidebar-projection.js.map +1 -1
- package/dist/src/sidebar-state.d.ts +1 -1
- package/dist/src/sidebar-state.d.ts.map +1 -1
- package/dist/src/sidebar-state.js +19 -1
- package/dist/src/sidebar-state.js.map +1 -1
- package/dist/src/tui/quota-layout.d.ts +94 -0
- package/dist/src/tui/quota-layout.d.ts.map +1 -0
- package/dist/src/tui/quota-layout.js +139 -0
- package/dist/src/tui/quota-layout.js.map +1 -0
- package/dist/src/tui/route-layout.d.ts +8 -0
- package/dist/src/tui/route-layout.d.ts.map +1 -0
- package/dist/src/tui/route-layout.js +36 -0
- package/dist/src/tui/route-layout.js.map +1 -0
- package/dist/src/tui.d.ts.map +1 -1
- package/dist/src/tui.js +120 -127
- package/dist/src/tui.js.map +1 -1
- package/dist/tui-build-map.json +66 -37
- package/dist/tui-ga-build-map.json +66 -37
- package/dist/types/src/auth-method-labels.d.ts +3 -0
- package/dist/types/src/auth-method-labels.d.ts.map +1 -0
- package/dist/types/src/cli.d.ts +3 -1
- package/dist/types/src/cli.d.ts.map +1 -1
- package/dist/types/src/common-auth-embedded/auth-menu/terminal.d.ts +43 -0
- package/dist/types/src/common-auth-embedded/claustrum/consumer.d.ts +142 -0
- package/dist/types/src/common-auth-embedded/claustrum/custody.d.ts +207 -0
- package/dist/types/src/common-auth-embedded/claustrum/enrollment.d.ts +164 -0
- package/dist/types/src/common-auth-embedded/claustrum/errors.d.ts +16 -0
- package/dist/types/src/common-auth-embedded/claustrum/host-slot.d.ts +39 -0
- package/dist/types/src/common-auth-embedded/claustrum/index.d.ts +19 -0
- package/dist/types/src/common-auth-embedded/claustrum/insula.d.ts +69 -0
- package/dist/types/src/common-auth-embedded/claustrum/interlock.d.ts +27 -0
- package/dist/types/src/common-auth-embedded/claustrum/roster.d.ts +221 -0
- package/dist/types/src/common-auth-embedded/fs/refresh-file-lock.d.ts +8 -2
- package/dist/types/src/common-auth-embedded/opencode2/errors.d.ts +25 -0
- package/dist/types/src/common-auth-embedded/opencode2/index.d.ts +8 -0
- package/dist/types/src/common-auth-embedded/opencode2/install.d.ts +55 -0
- package/dist/types/src/common-auth-embedded/opencode2/integration.d.ts +112 -0
- package/dist/types/src/common-auth-embedded/opencode2/sse.d.ts +12 -0
- package/dist/types/src/common-auth-embedded/opencode2/types.d.ts +413 -0
- package/dist/types/src/common-auth-embedded/quota/codec.d.ts +2 -0
- package/dist/types/src/common-auth-embedded/quota/format.d.ts +40 -3
- package/dist/types/src/common-auth-embedded/quota/index.d.ts +4 -4
- package/dist/types/src/common-auth-embedded/quota/map.d.ts +11 -0
- package/dist/types/src/common-auth-embedded/quota/merge.d.ts +3 -1
- package/dist/types/src/common-auth-embedded/quota/projection.d.ts +2 -1
- package/dist/types/src/common-auth-embedded/routing/admission.d.ts +93 -0
- package/dist/types/src/common-auth-embedded/routing/index.d.ts +8 -0
- package/dist/types/src/common-auth-embedded/routing/ordered.d.ts +47 -0
- package/dist/types/src/common-auth-embedded/routing/pins.d.ts +22 -0
- package/dist/types/src/common-auth-embedded/routing/sticky.d.ts +158 -0
- package/dist/types/src/common-auth-embedded/setup/command-error.d.ts +32 -0
- package/dist/types/src/common-auth-embedded/setup/command.d.ts +3 -0
- package/dist/types/src/common-auth-embedded/setup/detect.d.ts +6 -0
- package/dist/types/src/common-auth-embedded/setup/index.d.ts +6 -0
- package/dist/types/src/common-auth-embedded/setup/process-fence.d.ts +43 -0
- package/dist/types/src/common-auth-embedded/setup/register.d.ts +11 -0
- package/dist/types/src/common-auth-embedded/setup/types.d.ts +150 -0
- package/dist/types/src/common-auth-embedded/store/pool.d.ts +1 -1
- package/dist/types/src/common-auth-embedded/store/refresh-lock.d.ts +0 -1
- package/dist/types/src/common-auth-embedded/store/schema.d.ts +2 -0
- package/dist/types/src/ga/rpc/protocol.d.ts +4 -7
- package/dist/types/src/ga/rpc/protocol.d.ts.map +1 -1
- package/dist/types/src/ga/server/auth.d.ts +8 -3
- package/dist/types/src/ga/server/auth.d.ts.map +1 -1
- package/dist/types/src/ga/server/index.d.ts +39 -12
- package/dist/types/src/ga/server/index.d.ts.map +1 -1
- package/dist/types/src/ga/server/pool-login.d.ts +22 -0
- package/dist/types/src/ga/server/pool-login.d.ts.map +1 -0
- package/dist/types/src/plugin/accounts.d.ts +1 -1
- package/dist/types/src/plugin/accounts.d.ts.map +1 -1
- package/dist/types/src/plugin/background-vault-quota-refresh.d.ts +2 -0
- package/dist/types/src/plugin/background-vault-quota-refresh.d.ts.map +1 -1
- package/dist/types/src/plugin/command-apply.d.ts +2 -2
- package/dist/types/src/plugin/command-apply.d.ts.map +1 -1
- package/dist/types/src/plugin/commands.d.ts +1 -0
- package/dist/types/src/plugin/commands.d.ts.map +1 -1
- package/dist/types/src/plugin/config/operator-settings-schema.d.ts +0 -4
- package/dist/types/src/plugin/config/operator-settings-schema.d.ts.map +1 -1
- package/dist/types/src/plugin/config/schema.d.ts +0 -7
- package/dist/types/src/plugin/config/schema.d.ts.map +1 -1
- package/dist/types/src/plugin/config/writer.d.ts +1 -1
- package/dist/types/src/plugin/fetch/retry-state.d.ts +19 -3
- package/dist/types/src/plugin/fetch/retry-state.d.ts.map +1 -1
- package/dist/types/src/plugin/fetch-interceptor.d.ts.map +1 -1
- package/dist/types/src/plugin/fetch-routing.d.ts +0 -16
- package/dist/types/src/plugin/fetch-routing.d.ts.map +1 -1
- package/dist/types/src/plugin/ga-location-services.d.ts +14 -9
- package/dist/types/src/plugin/ga-location-services.d.ts.map +1 -1
- package/dist/types/src/plugin/gemini-dump.d.ts.map +1 -1
- package/dist/types/src/plugin/google-origin.d.ts +7 -0
- package/dist/types/src/plugin/google-origin.d.ts.map +1 -0
- package/dist/types/src/plugin/index.d.ts.map +1 -1
- package/dist/types/src/plugin/logging-utils.d.ts.map +1 -1
- package/dist/types/src/plugin/oauth-methods.d.ts.map +1 -1
- package/dist/types/src/plugin/operator-settings.d.ts +1 -1
- package/dist/types/src/plugin/operator-settings.d.ts.map +1 -1
- package/dist/types/src/plugin/quota.d.ts +11 -7
- package/dist/types/src/plugin/quota.d.ts.map +1 -1
- package/dist/types/src/plugin/request.d.ts +6 -5
- package/dist/types/src/plugin/request.d.ts.map +1 -1
- package/dist/types/src/plugin/server.d.ts.map +1 -1
- package/dist/types/src/plugin/shared/advisory-repository.d.ts +20 -0
- package/dist/types/src/plugin/shared/advisory-repository.d.ts.map +1 -0
- package/dist/types/src/plugin/shared/request-services.d.ts +27 -26
- package/dist/types/src/plugin/shared/request-services.d.ts.map +1 -1
- package/dist/types/src/plugin/shared/vault-request-credentials.d.ts +16 -4
- package/dist/types/src/plugin/shared/vault-request-credentials.d.ts.map +1 -1
- package/dist/types/src/plugin/storage.d.ts +2 -2
- package/dist/types/src/plugin/storage.d.ts.map +1 -1
- package/dist/types/src/plugin/vault-custody.d.ts +14 -1
- package/dist/types/src/plugin/vault-custody.d.ts.map +1 -1
- package/dist/types/src/plugin/vault-quota-outcome.d.ts +19 -0
- package/dist/types/src/plugin/vault-quota-outcome.d.ts.map +1 -0
- package/dist/types/src/setup.d.ts +15 -0
- package/dist/types/src/setup.d.ts.map +1 -0
- package/dist/types/src/sidebar-state.d.ts +1 -1
- package/dist/types/src/sidebar-state.d.ts.map +1 -1
- package/package.json +5 -4
- package/src/common-auth-embedded/claustrum/consumer.d.ts +44 -4
- package/src/common-auth-embedded/claustrum/consumer.js +134 -2
- package/src/common-auth-embedded/claustrum/custody.d.ts +33 -1
- package/src/common-auth-embedded/claustrum/custody.js +17 -0
- package/src/common-auth-embedded/claustrum/enrollment.d.ts +6 -1
- package/src/common-auth-embedded/claustrum/enrollment.js +6 -1
- package/src/common-auth-embedded/claustrum/index.d.ts +3 -2
- package/src/common-auth-embedded/claustrum/index.js +5 -3
- package/src/common-auth-embedded/claustrum/insula.d.ts +69 -0
- package/src/common-auth-embedded/claustrum/insula.js +152 -0
- package/src/common-auth-embedded/claustrum/roster.d.ts +13 -0
- package/src/common-auth-embedded/claustrum/roster.js +33 -3
- package/src/common-auth-embedded/fs/refresh-file-lock.d.ts +8 -2
- package/src/common-auth-embedded/fs/refresh-file-lock.js +26 -12
- package/src/common-auth-embedded/pi-slot/lock.js +7 -3
- package/src/common-auth-embedded/quota/codec.d.ts +2 -0
- package/src/common-auth-embedded/quota/codec.js +2 -1
- package/src/common-auth-embedded/quota/format.d.ts +40 -3
- package/src/common-auth-embedded/quota/format.js +196 -43
- package/src/common-auth-embedded/quota/index.d.ts +4 -4
- package/src/common-auth-embedded/quota/index.js +2 -2
- package/src/common-auth-embedded/quota/map.d.ts +11 -0
- package/src/common-auth-embedded/quota/map.js +36 -1
- package/src/common-auth-embedded/quota/merge.d.ts +3 -1
- package/src/common-auth-embedded/quota/merge.js +21 -5
- package/src/common-auth-embedded/quota/projection.d.ts +2 -1
- package/src/common-auth-embedded/quota/projection.js +3 -1
- package/src/common-auth-embedded/setup/command-error.d.ts +32 -0
- package/src/common-auth-embedded/setup/command-error.js +79 -0
- package/src/common-auth-embedded/setup/command-runner.js +143 -0
- package/src/common-auth-embedded/setup/command.d.ts +3 -0
- package/src/common-auth-embedded/setup/command.js +271 -0
- package/src/common-auth-embedded/setup/config-write.js +60 -0
- package/src/common-auth-embedded/setup/detect.d.ts +6 -0
- package/src/common-auth-embedded/setup/detect.js +224 -0
- package/src/common-auth-embedded/setup/enroll.js +82 -0
- package/src/common-auth-embedded/setup/index.d.ts +6 -0
- package/src/common-auth-embedded/setup/index.js +5 -0
- package/src/common-auth-embedded/setup/paths.js +33 -0
- package/src/common-auth-embedded/setup/process-fence.d.ts +43 -0
- package/src/common-auth-embedded/setup/process-fence.js +270 -0
- package/src/common-auth-embedded/setup/prompts.js +26 -0
- package/src/common-auth-embedded/setup/register.d.ts +11 -0
- package/src/common-auth-embedded/setup/register.js +136 -0
- package/src/common-auth-embedded/setup/types.d.ts +150 -0
- package/src/common-auth-embedded/source-output.json +265 -101
- package/src/common-auth-embedded/store/pool.d.ts +1 -1
- package/src/common-auth-embedded/store/pool.js +0 -1
- package/src/common-auth-embedded/store/refresh-lock.d.ts +0 -1
- package/src/common-auth-embedded/store/refresh-lock.js +0 -1
- package/src/common-auth-embedded/store/schema.d.ts +2 -0
- package/src/common-auth-embedded/store/schema.js +3 -2
- package/src/sidebar-state.ts +19 -2
- package/src/tui-compiled/common-auth-embedded/quota/codec.js +2 -1
- package/src/tui-compiled/common-auth-embedded/quota/format.js +196 -43
- package/src/tui-compiled/common-auth-embedded/quota/index.js +2 -2
- package/src/tui-compiled/common-auth-embedded/quota/map.js +36 -1
- package/src/tui-compiled/common-auth-embedded/quota/merge.js +21 -5
- package/src/tui-compiled/common-auth-embedded/quota/projection.js +3 -1
- package/src/tui-compiled/quota-presentation.js +42 -9
- package/src/tui-compiled/sidebar-state.js +15 -1
- package/src/tui-compiled/tui/quota-layout.js +378 -0
- package/src/tui-compiled/tui/route-layout.js +30 -0
- package/src/tui-compiled/tui.js +271 -371
- package/src/tui-ga-compiled/host-ga.js +93 -90
- package/src/tui-ga-compiled/shared/1ff34afa7c42d196-projection.js +3 -1
- package/src/tui-ga-compiled/shared/6ca47cd4ec33fe72-route-layout.js +30 -0
- package/src/tui-ga-compiled/shared/77138df80c7ae006-map.js +36 -1
- package/src/tui-ga-compiled/shared/8ae1927e5910ea81-sidebar-projection.js +2 -2
- package/src/tui-ga-compiled/shared/98cc0c186c46c42d-quota-presentation.js +42 -9
- package/src/tui-ga-compiled/shared/aef2402f8fc342f0-format.js +196 -43
- package/src/tui-ga-compiled/shared/bf17cbee28e58197-index.js +2 -2
- package/src/tui-ga-compiled/shared/ca21dc417b36dc5d-codec.js +2 -1
- package/src/tui-ga-compiled/shared/dd4c9e1a907f8ef0-quota-layout.js +378 -0
- package/src/tui-ga-compiled/shared/ecc214300932dfb6-merge.js +21 -5
- package/src/tui-ga-raw/host-ga.tsx +102 -92
- package/src/tui-ga-raw/shared/1ff34afa7c42d196-projection.js +3 -1
- package/src/tui-ga-raw/shared/6ca47cd4ec33fe72-route-layout.js +30 -0
- package/src/tui-ga-raw/shared/77138df80c7ae006-map.js +36 -1
- package/src/tui-ga-raw/shared/8ae1927e5910ea81-sidebar-projection.js +2 -2
- package/src/tui-ga-raw/shared/98cc0c186c46c42d-quota-presentation.js +42 -9
- package/src/tui-ga-raw/shared/aef2402f8fc342f0-format.js +196 -43
- package/src/tui-ga-raw/shared/bf17cbee28e58197-index.js +2 -2
- package/src/tui-ga-raw/shared/ca21dc417b36dc5d-codec.js +2 -1
- package/src/tui-ga-raw/shared/dd4c9e1a907f8ef0-quota-layout.tsx +391 -0
- package/src/tui-ga-raw/shared/ecc214300932dfb6-merge.js +21 -5
- package/src/tui-raw/common-auth-embedded/quota/codec.js +2 -1
- package/src/tui-raw/common-auth-embedded/quota/format.js +196 -43
- package/src/tui-raw/common-auth-embedded/quota/index.js +2 -2
- package/src/tui-raw/common-auth-embedded/quota/map.js +36 -1
- package/src/tui-raw/common-auth-embedded/quota/merge.js +21 -5
- package/src/tui-raw/common-auth-embedded/quota/projection.js +3 -1
- package/src/tui-raw/quota-presentation.js +42 -9
- package/src/tui-raw/sidebar-state.js +15 -1
- package/src/tui-raw/tui/quota-layout.tsx +391 -0
- package/src/tui-raw/tui/route-layout.js +30 -0
- package/src/tui-raw/tui.tsx +218 -272
- package/src/tui.tsx +218 -272
- package/dist/src/tui/vault-setup.d.ts +0 -98
- package/dist/src/tui/vault-setup.d.ts.map +0 -1
- package/dist/src/tui/vault-setup.js +0 -198
- package/dist/src/tui/vault-setup.js.map +0 -1
- package/dist/types/src/plugin/transform/model-resolver.d.ts +0 -2
- package/dist/types/src/plugin/transform/model-resolver.d.ts.map +0 -1
- package/dist/types/src/quota-presentation.d.ts +0 -18
- package/dist/types/src/quota-presentation.d.ts.map +0 -1
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import { spawn } from 'node:child_process';
|
|
2
|
+
export const STDERR_TAIL_MAX_BYTES = 4 * 1024;
|
|
3
|
+
const STDOUT_MAX_BYTES = 1024 * 1024;
|
|
4
|
+
class ByteTail {
|
|
5
|
+
buffer = Buffer.alloc(STDERR_TAIL_MAX_BYTES);
|
|
6
|
+
start = 0;
|
|
7
|
+
length = 0;
|
|
8
|
+
truncated = false;
|
|
9
|
+
get didTruncate() {
|
|
10
|
+
return this.truncated;
|
|
11
|
+
}
|
|
12
|
+
push(chunk) {
|
|
13
|
+
if (chunk.length >= STDERR_TAIL_MAX_BYTES) {
|
|
14
|
+
if (chunk.length > STDERR_TAIL_MAX_BYTES || this.length > 0)
|
|
15
|
+
this.truncated = true;
|
|
16
|
+
chunk.copy(this.buffer, 0, chunk.length - STDERR_TAIL_MAX_BYTES);
|
|
17
|
+
this.start = 0;
|
|
18
|
+
this.length = STDERR_TAIL_MAX_BYTES;
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
const overflow = Math.max(0, this.length + chunk.length - STDERR_TAIL_MAX_BYTES);
|
|
22
|
+
if (overflow > 0)
|
|
23
|
+
this.truncated = true;
|
|
24
|
+
this.start = (this.start + overflow) % STDERR_TAIL_MAX_BYTES;
|
|
25
|
+
this.length -= overflow;
|
|
26
|
+
const writeAt = (this.start + this.length) % STDERR_TAIL_MAX_BYTES;
|
|
27
|
+
const firstLength = Math.min(chunk.length, STDERR_TAIL_MAX_BYTES - writeAt);
|
|
28
|
+
chunk.copy(this.buffer, writeAt, 0, firstLength);
|
|
29
|
+
if (firstLength < chunk.length)
|
|
30
|
+
chunk.copy(this.buffer, 0, firstLength);
|
|
31
|
+
this.length += chunk.length;
|
|
32
|
+
}
|
|
33
|
+
toString() {
|
|
34
|
+
const bytes = Buffer.alloc(this.length);
|
|
35
|
+
const firstLength = Math.min(this.length, STDERR_TAIL_MAX_BYTES - this.start);
|
|
36
|
+
this.buffer.copy(bytes, 0, this.start, this.start + firstLength);
|
|
37
|
+
if (firstLength < this.length)
|
|
38
|
+
this.buffer.copy(bytes, firstLength, 0, this.length - firstLength);
|
|
39
|
+
let start = 0;
|
|
40
|
+
while (start < bytes.length) {
|
|
41
|
+
const byte = bytes[start];
|
|
42
|
+
if (byte === undefined || (byte & 0xc0) !== 0x80)
|
|
43
|
+
break;
|
|
44
|
+
start++;
|
|
45
|
+
}
|
|
46
|
+
return bytes.subarray(start).toString('utf8');
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
export const defaultCommandRunner = {
|
|
50
|
+
run(file, args, options = {}) {
|
|
51
|
+
return new Promise((resolve) => {
|
|
52
|
+
const started = performance.now();
|
|
53
|
+
const timeoutMs = options.timeoutMs ?? 15_000;
|
|
54
|
+
const stderr = new ByteTail();
|
|
55
|
+
const stdout = [];
|
|
56
|
+
let stdoutLength = 0;
|
|
57
|
+
let outputExceeded = false;
|
|
58
|
+
let spawnError = false;
|
|
59
|
+
let timedOut = false;
|
|
60
|
+
let child;
|
|
61
|
+
try {
|
|
62
|
+
child = spawn(file, [...args], {
|
|
63
|
+
env: options.env ?? process.env,
|
|
64
|
+
windowsHide: true,
|
|
65
|
+
windowsVerbatimArguments: options.windowsVerbatimArguments,
|
|
66
|
+
stdio: ['ignore', 'pipe', 'pipe'],
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
catch {
|
|
70
|
+
resolve({
|
|
71
|
+
exitCode: 1,
|
|
72
|
+
stdout: '',
|
|
73
|
+
stderr: '',
|
|
74
|
+
spawnError: true,
|
|
75
|
+
signal: null,
|
|
76
|
+
timedOut: false,
|
|
77
|
+
durationMs: performance.now() - started,
|
|
78
|
+
});
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
const timer = timeoutMs > 0
|
|
82
|
+
? setTimeout(() => {
|
|
83
|
+
timedOut = true;
|
|
84
|
+
child.kill('SIGTERM');
|
|
85
|
+
}, timeoutMs)
|
|
86
|
+
: undefined;
|
|
87
|
+
child.stdout?.on('data', (chunk) => {
|
|
88
|
+
const remaining = STDOUT_MAX_BYTES - stdoutLength;
|
|
89
|
+
const length = Math.min(remaining, chunk.length);
|
|
90
|
+
if (length > 0) {
|
|
91
|
+
stdout.push(chunk.subarray(0, length));
|
|
92
|
+
stdoutLength += length;
|
|
93
|
+
}
|
|
94
|
+
if (chunk.length > remaining) {
|
|
95
|
+
outputExceeded = true;
|
|
96
|
+
child.kill('SIGTERM');
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
child.stderr?.on('data', (chunk) => stderr.push(chunk));
|
|
100
|
+
let settled = false;
|
|
101
|
+
const settle = (code, signal) => {
|
|
102
|
+
if (settled)
|
|
103
|
+
return;
|
|
104
|
+
settled = true;
|
|
105
|
+
if (timer)
|
|
106
|
+
clearTimeout(timer);
|
|
107
|
+
resolve({
|
|
108
|
+
exitCode: spawnError ? 1 : outputExceeded ? 1 : (code ?? 1),
|
|
109
|
+
stdout: Buffer.concat(stdout, stdoutLength).toString('utf8'),
|
|
110
|
+
stderr: stderr.toString(),
|
|
111
|
+
stderrTruncated: stderr.didTruncate,
|
|
112
|
+
...(spawnError ? { spawnError: true } : {}),
|
|
113
|
+
signal: signal ?? null,
|
|
114
|
+
timedOut,
|
|
115
|
+
durationMs: performance.now() - started,
|
|
116
|
+
});
|
|
117
|
+
};
|
|
118
|
+
child.once('error', () => {
|
|
119
|
+
spawnError = true;
|
|
120
|
+
// A child that never started (ENOENT, EACCES) has no process for the
|
|
121
|
+
// timer to kill. Node documents no guarantee that 'close' follows that
|
|
122
|
+
// 'error', so settle here rather than wait for it.
|
|
123
|
+
if (child.pid === undefined)
|
|
124
|
+
settle(null, null);
|
|
125
|
+
});
|
|
126
|
+
child.once('close', (code, signal) => settle(code, signal));
|
|
127
|
+
});
|
|
128
|
+
},
|
|
129
|
+
};
|
|
130
|
+
/** Batch launchers need cmd.exe; no free-form user text is accepted as shell arguments. */
|
|
131
|
+
export function runResolvedCommand(runner, platform, file, args, env, timeoutMs = 15_000) {
|
|
132
|
+
if (platform === 'win32' && /\.(cmd|bat)$/i.test(file)) {
|
|
133
|
+
if (/["%!\r\n]/.test(file) ||
|
|
134
|
+
args.some((arg) => !/^[a-zA-Z0-9@:/._+-]+$/.test(arg)))
|
|
135
|
+
throw new Error('Unsafe batch launcher or argument; use an executable instead.');
|
|
136
|
+
return runner.run('cmd.exe', ['/d', '/s', '/c', `""${file}" ${args.join(' ')}"`], {
|
|
137
|
+
env,
|
|
138
|
+
timeoutMs,
|
|
139
|
+
windowsVerbatimArguments: true,
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
return runner.run(file, args, { env, timeoutMs });
|
|
143
|
+
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { SetupIO, SetupPlugin, SetupResult } from './types.js';
|
|
2
|
+
export declare const AMBIGUOUS_OPENCODE_MESSAGE = "Multiple OpenCode generations found. Choose --opencode=1|2|both before running noninteractive setup.";
|
|
3
|
+
export declare function runSetup(plugin: SetupPlugin, argv?: readonly string[], io?: SetupIO): Promise<SetupResult>;
|
|
@@ -0,0 +1,271 @@
|
|
|
1
|
+
import { select } from '../auth-menu/select.js';
|
|
2
|
+
import { isInteractive, printLine, processTerminal, } from '../auth-menu/terminal.js';
|
|
3
|
+
import { enrollmentAuthority, hostEnrollmentPaths, } from '../claustrum/enrollment.js';
|
|
4
|
+
import { recordSetupEnrollment, setupEnrollmentLine } from './command-error.js';
|
|
5
|
+
import { defaultCommandRunner } from './command-runner.js';
|
|
6
|
+
import { detectHosts } from './detect.js';
|
|
7
|
+
import { connectSetupHost, HostNotEnrolledError } from './enroll.js';
|
|
8
|
+
import { setupPaths } from './paths.js';
|
|
9
|
+
import { assertHostsStopped, createProcessFence, ProcessFenceViolationError, ProcessInspectionError, } from './process-fence.js';
|
|
10
|
+
import { selectSetupHosts } from './prompts.js';
|
|
11
|
+
import { planOpenCodeRegistration, registerOpenCode, registerPi, } from './register.js';
|
|
12
|
+
export const AMBIGUOUS_OPENCODE_MESSAGE = 'Multiple OpenCode generations found. Choose --opencode=1|2|both before running noninteractive setup.';
|
|
13
|
+
function flags(argv) {
|
|
14
|
+
const result = {
|
|
15
|
+
yes: false,
|
|
16
|
+
dryRun: false,
|
|
17
|
+
claustrum: false,
|
|
18
|
+
noClaustrum: false,
|
|
19
|
+
login: false,
|
|
20
|
+
opencode: undefined,
|
|
21
|
+
};
|
|
22
|
+
for (const arg of argv) {
|
|
23
|
+
if (arg === '--yes')
|
|
24
|
+
result.yes = true;
|
|
25
|
+
else if (arg === '--dry-run')
|
|
26
|
+
result.dryRun = true;
|
|
27
|
+
else if (arg === '--claustrum')
|
|
28
|
+
result.claustrum = true;
|
|
29
|
+
else if (arg === '--no-claustrum')
|
|
30
|
+
result.noClaustrum = true;
|
|
31
|
+
else if (arg === '--login')
|
|
32
|
+
result.login = true;
|
|
33
|
+
else if (/^--opencode=(1|2|both)$/.test(arg))
|
|
34
|
+
result.opencode = arg.slice('--opencode='.length);
|
|
35
|
+
else
|
|
36
|
+
throw new Error(`Unknown setup argument: ${arg}`);
|
|
37
|
+
}
|
|
38
|
+
if (result.claustrum && result.noClaustrum)
|
|
39
|
+
throw new Error('--claustrum and --no-claustrum cannot be used together.');
|
|
40
|
+
if (result.login && result.claustrum)
|
|
41
|
+
throw new Error('--login and --claustrum cannot be used together.');
|
|
42
|
+
return result;
|
|
43
|
+
}
|
|
44
|
+
function validatePlugin(plugin) {
|
|
45
|
+
for (const pkg of Object.values(plugin.packages)) {
|
|
46
|
+
if (!/^(?:@[a-z0-9._-]+\/)?[a-z0-9._-]+$/.test(pkg))
|
|
47
|
+
throw new Error('Setup requires npm package names.');
|
|
48
|
+
}
|
|
49
|
+
if (!/^\d+\.\d+\.\d+(?:-[a-zA-Z0-9.-]+)?(?:\+[a-zA-Z0-9.-]+)?$/.test(plugin.version))
|
|
50
|
+
throw new Error('Setup requires a concrete package version.');
|
|
51
|
+
for (const host of Object.values(plugin.vault.hosts)) {
|
|
52
|
+
if (!/^[a-z0-9][a-z0-9-]*$/.test(host.name))
|
|
53
|
+
throw new Error('Setup requires lowercase vault names containing only letters, digits and dashes.');
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Turn what setup recorded into one outcome per selected host, in setup order.
|
|
58
|
+
* A host setup never reached was never asked to enroll. Only a host whose
|
|
59
|
+
* enrollment was in flight when setup failed is checked on disk, by reading its
|
|
60
|
+
* enrollment files once with `enrollmentAuthority`; if that read fails it stays
|
|
61
|
+
* `unknown`.
|
|
62
|
+
*/
|
|
63
|
+
async function enrollmentReport(plugin, hosts, recorded) {
|
|
64
|
+
const report = [];
|
|
65
|
+
for (const host of hosts) {
|
|
66
|
+
let outcome = recorded.get(host) ?? 'not-enrolled';
|
|
67
|
+
if (outcome === 'unknown') {
|
|
68
|
+
const { name, paths } = plugin.vault.hosts[host];
|
|
69
|
+
const authority = await enrollmentAuthority(hostEnrollmentPaths(paths), name).catch(() => 'unreadable');
|
|
70
|
+
if (authority === 'vault')
|
|
71
|
+
outcome = 'enrolled';
|
|
72
|
+
else if (authority === 'local')
|
|
73
|
+
outcome = 'not-enrolled';
|
|
74
|
+
}
|
|
75
|
+
report.push({ host, outcome });
|
|
76
|
+
}
|
|
77
|
+
return report;
|
|
78
|
+
}
|
|
79
|
+
export async function runSetup(plugin, argv = [], io = {}) {
|
|
80
|
+
const options = flags(argv);
|
|
81
|
+
validatePlugin(plugin);
|
|
82
|
+
const terminal = io.terminal ?? processTerminal();
|
|
83
|
+
const detection = await detectHosts(plugin, io);
|
|
84
|
+
printLine(terminal, `${plugin.displayName} setup`);
|
|
85
|
+
for (const [label, host] of [
|
|
86
|
+
['OpenCode', detection.opencode],
|
|
87
|
+
['Pi', detection.pi],
|
|
88
|
+
]) {
|
|
89
|
+
printLine(terminal, `${label}: ${host.installed ? `found (version ${host.version ?? 'unknown'})` : 'not found'} — ${host.directory}`);
|
|
90
|
+
}
|
|
91
|
+
printLine(terminal, `Claustrum: ${detection.claustrum.available ? 'available' : 'not available'}`);
|
|
92
|
+
// Pi is registered by running its CLI, so a leftover Pi folder without the
|
|
93
|
+
// CLI cannot be set up. Leave it out instead of failing the whole run, so it
|
|
94
|
+
// never blocks setting up OpenCode.
|
|
95
|
+
const piWithoutCli = detection.pi.installed && !detection.pi.executable;
|
|
96
|
+
if (piWithoutCli)
|
|
97
|
+
printLine(terminal, 'Pi: skipped, because its folder exists but pi is not on PATH. Install the Pi CLI and rerun setup to add it.');
|
|
98
|
+
const found = ['opencode', 'pi'].filter((host) => detection[host].installed && !(host === 'pi' && piWithoutCli));
|
|
99
|
+
// A dry run changes nothing, so without a terminal it plans the --yes path
|
|
100
|
+
// instead of refusing; scripts and CI can preview setup with --dry-run alone.
|
|
101
|
+
const assumeYes = options.yes || (options.dryRun && !isInteractive(terminal));
|
|
102
|
+
if (!assumeYes && !isInteractive(terminal))
|
|
103
|
+
throw new Error('Setup requires a TTY or --yes.');
|
|
104
|
+
const hosts = assumeYes
|
|
105
|
+
? found
|
|
106
|
+
: ((await selectSetupHosts(terminal, found)) ?? []);
|
|
107
|
+
let generation = options.opencode ??
|
|
108
|
+
(detection.opencode.generation === 'ambiguous'
|
|
109
|
+
? '1'
|
|
110
|
+
: detection.opencode.generation);
|
|
111
|
+
if (hosts.includes('opencode') &&
|
|
112
|
+
!options.opencode &&
|
|
113
|
+
detection.opencode.generation === 'ambiguous') {
|
|
114
|
+
if (assumeYes || !isInteractive(terminal))
|
|
115
|
+
throw new Error(AMBIGUOUS_OPENCODE_MESSAGE);
|
|
116
|
+
const choice = await select(terminal, [
|
|
117
|
+
{ value: '1', label: 'OpenCode 1' },
|
|
118
|
+
{ value: '2', label: 'OpenCode 2' },
|
|
119
|
+
{ value: 'both', label: 'Both (one compatible registration)' },
|
|
120
|
+
], { message: 'Which OpenCode generation should be registered?' });
|
|
121
|
+
if (choice === null)
|
|
122
|
+
return { hosts: [], dryRun: options.dryRun, mode: 'local', detection };
|
|
123
|
+
generation = choice;
|
|
124
|
+
}
|
|
125
|
+
if (!hosts.length) {
|
|
126
|
+
printLine(terminal, 'No hosts selected. Install OpenCode or Pi and rerun setup.');
|
|
127
|
+
return { hosts, dryRun: options.dryRun, mode: 'local', detection };
|
|
128
|
+
}
|
|
129
|
+
const { env, platform } = setupPaths(io);
|
|
130
|
+
const fence = io.fence ??
|
|
131
|
+
createProcessFence(io.runner ?? defaultCommandRunner, { platform });
|
|
132
|
+
const stopped = async () => {
|
|
133
|
+
try {
|
|
134
|
+
await assertHostsStopped(fence, env);
|
|
135
|
+
}
|
|
136
|
+
catch (error) {
|
|
137
|
+
if (error instanceof ProcessInspectionError)
|
|
138
|
+
printLine(terminal, error.refusalText);
|
|
139
|
+
throw error;
|
|
140
|
+
}
|
|
141
|
+
};
|
|
142
|
+
printLine(terminal, 'Checking that OpenCode and Pi are not running…');
|
|
143
|
+
if (options.dryRun) {
|
|
144
|
+
try {
|
|
145
|
+
const preview = fence.previewRunningHosts
|
|
146
|
+
? await fence.previewRunningHosts(env)
|
|
147
|
+
: { hosts: await fence.listRunningHosts(env), uncheckedRuntimes: 0 };
|
|
148
|
+
const active = preview.hosts;
|
|
149
|
+
if (preview.uncheckedRuntimes > 0)
|
|
150
|
+
printLine(terminal, 'Node or Bun programs are running; a real run checks whether any of them is OpenCode or Pi.');
|
|
151
|
+
const names = new Set(new ProcessFenceViolationError(active).activeHosts.map((host) => host.command.toLowerCase() === 'pi' ? 'Pi' : 'OpenCode'));
|
|
152
|
+
for (const name of names)
|
|
153
|
+
printLine(terminal, `${name} is running; setup will ask you to quit it.`);
|
|
154
|
+
}
|
|
155
|
+
catch (error) {
|
|
156
|
+
printLine(terminal, 'Process inspection failed; real setup will require successful inspection and stopped OpenCode/Pi hosts.');
|
|
157
|
+
if (error instanceof ProcessInspectionError)
|
|
158
|
+
printLine(terminal, error.refusalText);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
else
|
|
162
|
+
await stopped();
|
|
163
|
+
if (options.claustrum && !detection.claustrum.available)
|
|
164
|
+
throw new Error('Claustrum is not available. Start ck or use --no-claustrum for local sign-in.');
|
|
165
|
+
let useVault = Boolean(options.claustrum);
|
|
166
|
+
if (!useVault &&
|
|
167
|
+
!options.login &&
|
|
168
|
+
!options.noClaustrum &&
|
|
169
|
+
!assumeYes &&
|
|
170
|
+
detection.claustrum.available &&
|
|
171
|
+
isInteractive(terminal)) {
|
|
172
|
+
// Not `confirm`: it reads Escape and Ctrl-C as "No", and "No" here means
|
|
173
|
+
// a local sign-in. Cancelling must stop setup before anything changes.
|
|
174
|
+
const choice = await select(terminal, [
|
|
175
|
+
{ label: 'No', value: false },
|
|
176
|
+
{ label: 'Yes', value: true },
|
|
177
|
+
], { message: 'Connect these hosts to the Claustrum vault?' });
|
|
178
|
+
if (choice === null) {
|
|
179
|
+
printLine(terminal, 'Setup cancelled. Nothing was changed.');
|
|
180
|
+
return { hosts: [], dryRun: options.dryRun, mode: 'local', detection };
|
|
181
|
+
}
|
|
182
|
+
useVault = choice === true;
|
|
183
|
+
}
|
|
184
|
+
const mode = useVault ? 'claustrum' : 'local';
|
|
185
|
+
// Validate every config before login or enrollment can change credential state.
|
|
186
|
+
const writes = hosts.includes('opencode')
|
|
187
|
+
? planOpenCodeRegistration(plugin, generation, io)
|
|
188
|
+
: [];
|
|
189
|
+
if (options.dryRun) {
|
|
190
|
+
printLine(terminal, 'Dry run: no registrations, enrollment, sign-in or migration will be performed.');
|
|
191
|
+
for (const host of hosts) {
|
|
192
|
+
if (plugin.beforeSignIn)
|
|
193
|
+
printLine(terminal, `Would run beforeSignIn(${host}, ${mode}).`);
|
|
194
|
+
if (useVault) {
|
|
195
|
+
const paths = hostEnrollmentPaths(plugin.vault.hosts[host].paths);
|
|
196
|
+
printLine(terminal, `Would Connect ${host}: write ${paths.statePath} and ${paths.tokenPath}; wait for ck auth enroll approve.`);
|
|
197
|
+
}
|
|
198
|
+
else
|
|
199
|
+
printLine(terminal, `Would sign in locally for ${host}.`);
|
|
200
|
+
if (plugin.beforeRegister)
|
|
201
|
+
printLine(terminal, `Would run beforeRegister(${host}, ${mode}).`);
|
|
202
|
+
}
|
|
203
|
+
for (const write of writes)
|
|
204
|
+
printLine(terminal, `${write.changed ? 'Would write' : 'Unchanged'} ${write.path}:\n${write.content}`);
|
|
205
|
+
if (hosts.includes('pi'))
|
|
206
|
+
printLine(terminal, `Would run ${detection.pi.executable} install npm:${plugin.packages.pi}@${plugin.version}`);
|
|
207
|
+
for (const host of hosts)
|
|
208
|
+
printLine(terminal, `Would migrate ${host} using the plugin callback (provider-specific writes).`);
|
|
209
|
+
}
|
|
210
|
+
else {
|
|
211
|
+
const context = {
|
|
212
|
+
opencodeGeneration: generation,
|
|
213
|
+
mode,
|
|
214
|
+
hosts: Object.freeze([...hosts]),
|
|
215
|
+
piAgentDir: detection.pi.directory,
|
|
216
|
+
};
|
|
217
|
+
// Each host's vault enrollment as it happens. A host the operator approved
|
|
218
|
+
// stays enrolled if a later step fails, so a failure reports this record.
|
|
219
|
+
const enrollment = new Map();
|
|
220
|
+
try {
|
|
221
|
+
for (const host of hosts) {
|
|
222
|
+
await stopped();
|
|
223
|
+
await plugin.beforeSignIn?.(host, context);
|
|
224
|
+
await stopped();
|
|
225
|
+
if (useVault) {
|
|
226
|
+
enrollment.set(host, 'unknown');
|
|
227
|
+
try {
|
|
228
|
+
await connectSetupHost(plugin, host, io, terminal, stopped);
|
|
229
|
+
}
|
|
230
|
+
catch (error) {
|
|
231
|
+
if (error instanceof HostNotEnrolledError)
|
|
232
|
+
enrollment.set(host, 'not-enrolled');
|
|
233
|
+
throw error;
|
|
234
|
+
}
|
|
235
|
+
enrollment.set(host, 'enrolled');
|
|
236
|
+
}
|
|
237
|
+
else
|
|
238
|
+
await plugin.signInLocal(host, context);
|
|
239
|
+
await stopped();
|
|
240
|
+
await plugin.beforeRegister?.(host, mode, context);
|
|
241
|
+
await stopped();
|
|
242
|
+
if (host === 'opencode')
|
|
243
|
+
await registerOpenCode(writes, stopped);
|
|
244
|
+
else
|
|
245
|
+
await registerPi(plugin, detection.pi.executable, io);
|
|
246
|
+
await stopped();
|
|
247
|
+
await plugin.migrate(host, context);
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
catch (error) {
|
|
251
|
+
// Before any enrollment began nothing is connected: nothing to report.
|
|
252
|
+
if (enrollment.size === 0)
|
|
253
|
+
throw error;
|
|
254
|
+
// A host the operator approved stays enrolled after a later step fails.
|
|
255
|
+
// Print which hosts are connected and record it for `setupEnrollment`,
|
|
256
|
+
// then rethrow the original value untouched. Reporting must never
|
|
257
|
+
// replace the failure, so its own errors are ignored.
|
|
258
|
+
try {
|
|
259
|
+
const report = await enrollmentReport(plugin, hosts, enrollment);
|
|
260
|
+
recordSetupEnrollment(error, report);
|
|
261
|
+
for (const entry of report)
|
|
262
|
+
printLine(terminal, setupEnrollmentLine(entry));
|
|
263
|
+
}
|
|
264
|
+
catch { }
|
|
265
|
+
throw error;
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
printLine(terminal, `${options.dryRun ? 'Planned' : 'Configured'} ${plugin.displayName} for ${hosts.join(', ')} (${mode}).`);
|
|
269
|
+
printLine(terminal, `Next: ${hosts.includes('opencode') ? 'start OpenCode' : 'start Pi'} and run ${plugin.slashCommand}.`);
|
|
270
|
+
return { hosts, dryRun: options.dryRun, mode, detection };
|
|
271
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { randomUUID } from 'node:crypto';
|
|
2
|
+
import { mkdir, open, rename, stat, unlink } from 'node:fs/promises';
|
|
3
|
+
import { basename, dirname, join } from 'node:path';
|
|
4
|
+
import { setTimeout as delay } from 'node:timers/promises';
|
|
5
|
+
/** Ordinary host config inherits Windows ACLs and preserves an existing POSIX mode. */
|
|
6
|
+
export async function writeHostConfigAtomic(file, content, options = {}) {
|
|
7
|
+
const windows = (options.platform ?? process.platform) === 'win32';
|
|
8
|
+
const parent = dirname(file);
|
|
9
|
+
await mkdir(parent, { recursive: true });
|
|
10
|
+
let mode;
|
|
11
|
+
if (!windows) {
|
|
12
|
+
try {
|
|
13
|
+
mode = (await stat(file)).mode & 0o7777;
|
|
14
|
+
}
|
|
15
|
+
catch (error) {
|
|
16
|
+
if (error.code !== 'ENOENT')
|
|
17
|
+
throw error;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
const stage = join(parent, `.${basename(file)}.${(options.stageName ?? randomUUID)()}.tmp`);
|
|
21
|
+
let created = false;
|
|
22
|
+
try {
|
|
23
|
+
const handle = await open(stage, 'wx', mode ?? 0o666);
|
|
24
|
+
created = true;
|
|
25
|
+
try {
|
|
26
|
+
await handle.writeFile(content, 'utf8');
|
|
27
|
+
// An existing mode is deliberate; restore bits masked by the current umask.
|
|
28
|
+
if (mode !== undefined)
|
|
29
|
+
await handle.chmod(mode);
|
|
30
|
+
}
|
|
31
|
+
finally {
|
|
32
|
+
await handle.close();
|
|
33
|
+
}
|
|
34
|
+
const now = options.now ?? (() => performance.now());
|
|
35
|
+
const started = now();
|
|
36
|
+
for (let attempt = 0;; attempt++) {
|
|
37
|
+
await options.beforeRename?.();
|
|
38
|
+
try {
|
|
39
|
+
await (options.rename ?? rename)(stage, file);
|
|
40
|
+
created = false;
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
catch (error) {
|
|
44
|
+
const code = error.code;
|
|
45
|
+
const remaining = 2000 - (now() - started);
|
|
46
|
+
if (!windows ||
|
|
47
|
+
!['EPERM', 'EBUSY', 'EACCES'].includes(code ?? '') ||
|
|
48
|
+
remaining <= 0 ||
|
|
49
|
+
attempt >= 40)
|
|
50
|
+
throw new Error(`Unable to replace host config ${file}. Close editors or other programs using the file, then rerun setup.`);
|
|
51
|
+
await (options.wait ?? delay)(Math.min(remaining, 25 * 2 ** Math.min(attempt, 2)));
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
finally {
|
|
56
|
+
// Never remove a colliding stage that this call did not create.
|
|
57
|
+
if (created)
|
|
58
|
+
await unlink(stage).catch(() => { });
|
|
59
|
+
}
|
|
60
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { SetupDetection, SetupFileSystem, SetupIO, SetupPlugin } from './types.js';
|
|
2
|
+
export declare const defaultSetupFileSystem: SetupFileSystem;
|
|
3
|
+
export declare function findExecutableOnPath(name: string, io?: SetupIO): string | null;
|
|
4
|
+
export declare function openCodeDesktopMarkers(io?: SetupIO): string[];
|
|
5
|
+
export declare function detectOpenCodeGeneration(io?: SetupIO): '1' | '2' | 'ambiguous';
|
|
6
|
+
export declare function detectHosts(plugin: SetupPlugin, io?: SetupIO): Promise<SetupDetection>;
|