@cortexkit/opencode-antigravity-auth 3.0.5 → 3.0.6
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 +9199 -8799
- package/dist/cli.js.map +4 -4
- package/dist/cli.meta.json +1286 -1064
- package/dist/index.js +13641 -14559
- package/dist/index.js.map +4 -4
- package/dist/index.meta.json +1333 -1342
- package/dist/server.js +10618 -11080
- 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 +33 -3
- package/dist/src/common-auth-embedded/claustrum/consumer.js +96 -1
- package/dist/src/common-auth-embedded/claustrum/custody.d.ts +4 -1
- 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 +2 -1
- 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.js +20 -11
- 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 +26 -0
- package/dist/src/common-auth-embedded/quota/format.js +78 -42
- 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-runner.js +49 -0
- package/dist/src/common-auth-embedded/setup/command.d.ts +3 -0
- package/dist/src/common-auth-embedded/setup/command.js +215 -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 +70 -0
- package/dist/src/common-auth-embedded/setup/index.d.ts +5 -0
- package/dist/src/common-auth-embedded/setup/index.js +4 -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 +130 -0
- package/dist/src/common-auth-embedded/setup/types.d.ts +136 -0
- package/dist/src/common-auth-embedded/source-output.json +228 -80
- 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 +214 -53
- 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 +17 -49
- 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 +0 -43
- 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 +120 -40
- package/dist/src/plugin/ga-location-services.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 +15 -4
- package/dist/src/plugin/index.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 +5 -3
- package/dist/src/plugin/request.d.ts.map +1 -1
- package/dist/src/plugin/request.js +87 -168
- 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 +19 -25
- package/dist/src/plugin/shared/request-services.d.ts.map +1 -1
- package/dist/src/plugin/shared/request-services.js +105 -188
- 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 +4 -1
- package/dist/src/plugin/shared/vault-request-credentials.d.ts.map +1 -1
- package/dist/src/plugin/shared/vault-request-credentials.js +41 -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.map +1 -1
- package/dist/src/plugin/vault-custody.js +147 -35
- 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 +1 -1
- package/dist/src/sidebar-projection.d.ts.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.d.ts.map +1 -1
- package/dist/src/tui.js +205 -110
- package/dist/src/tui.js.map +1 -1
- package/dist/tui-build-map.json +37 -37
- package/dist/tui-ga-build-map.json +33 -33
- 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 +132 -0
- package/dist/types/src/common-auth-embedded/claustrum/custody.d.ts +178 -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/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 +26 -0
- 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.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 +5 -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 +136 -0
- 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/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/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 +5 -3
- 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 +19 -25
- package/dist/types/src/plugin/shared/request-services.d.ts.map +1 -1
- package/dist/types/src/plugin/shared/vault-request-credentials.d.ts +4 -1
- 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.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 +33 -3
- package/src/common-auth-embedded/claustrum/consumer.js +96 -1
- package/src/common-auth-embedded/claustrum/custody.d.ts +4 -1
- 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 +2 -1
- 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.js +20 -11
- 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 +26 -0
- package/src/common-auth-embedded/quota/format.js +78 -42
- 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-runner.js +49 -0
- package/src/common-auth-embedded/setup/command.d.ts +3 -0
- package/src/common-auth-embedded/setup/command.js +215 -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 +70 -0
- package/src/common-auth-embedded/setup/index.d.ts +5 -0
- package/src/common-auth-embedded/setup/index.js +4 -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 +130 -0
- package/src/common-auth-embedded/setup/types.d.ts +136 -0
- package/src/common-auth-embedded/source-output.json +228 -80
- 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 +78 -42
- 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.js +516 -334
- package/src/tui-ga-compiled/host-ga.js +11 -38
- package/src/tui-ga-compiled/shared/1ff34afa7c42d196-projection.js +3 -1
- package/src/tui-ga-compiled/shared/77138df80c7ae006-map.js +36 -1
- package/src/tui-ga-compiled/shared/98cc0c186c46c42d-quota-presentation.js +42 -9
- package/src/tui-ga-compiled/shared/aef2402f8fc342f0-format.js +78 -42
- 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/ecc214300932dfb6-merge.js +21 -5
- package/src/tui-ga-raw/host-ga.tsx +31 -62
- package/src/tui-ga-raw/shared/1ff34afa7c42d196-projection.js +3 -1
- package/src/tui-ga-raw/shared/77138df80c7ae006-map.js +36 -1
- package/src/tui-ga-raw/shared/98cc0c186c46c42d-quota-presentation.js +42 -9
- package/src/tui-ga-raw/shared/aef2402f8fc342f0-format.js +78 -42
- 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/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 +78 -42
- 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.tsx +423 -218
- package/src/tui.tsx +423 -218
- 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,270 @@
|
|
|
1
|
+
import { defaultCommandRunner } from './command-runner.js';
|
|
2
|
+
// A cold PowerShell/WMI query took 13.8 s on Windows Server 2022; warm queries
|
|
3
|
+
// took less than 0.5 s. This is the product's one-shot latency budget, not a test
|
|
4
|
+
// deadline: 45 s is about three times the worst measured cold start.
|
|
5
|
+
const WINDOWS_CIM_TIMEOUT_MS = 45_000;
|
|
6
|
+
const HOSTS = new Set(['opencode', 'litecode', 'opencode2', 'pi']);
|
|
7
|
+
const RUNTIMES = new Set(['node', 'bun']);
|
|
8
|
+
const PI_SCRIPT_PATTERN = /(?:^|[/\\])pi-coding-agent[/\\]dist[/\\](?:(?:bundle|bun)[/\\])?cli\.m?js$/i;
|
|
9
|
+
/** Splits a command line into arguments, keeping double-quoted ones whole. */
|
|
10
|
+
function commandArguments(command) {
|
|
11
|
+
return [...command.matchAll(/"([^"]*)"|(\S+)/g)].map((match) => match[1] ?? match[2] ?? '');
|
|
12
|
+
}
|
|
13
|
+
function executableName(argument) {
|
|
14
|
+
return (argument.split(/[/\\]/).pop() ?? '')
|
|
15
|
+
.toLowerCase()
|
|
16
|
+
.replace(/\.(?:exe|cmd|bat|m?js)$/, '');
|
|
17
|
+
}
|
|
18
|
+
// Node and Bun options whose value is the next argument, so that value is not
|
|
19
|
+
// mistaken for the script (`node --require ./preload.cjs …/opencode`).
|
|
20
|
+
const VALUE_OPTIONS = new Set([
|
|
21
|
+
'-r',
|
|
22
|
+
'--require',
|
|
23
|
+
'--import',
|
|
24
|
+
'--loader',
|
|
25
|
+
'--experimental-loader',
|
|
26
|
+
'-C',
|
|
27
|
+
'--conditions',
|
|
28
|
+
'--env-file',
|
|
29
|
+
'--title',
|
|
30
|
+
'--input-type',
|
|
31
|
+
'--preload',
|
|
32
|
+
'--cwd',
|
|
33
|
+
'-c',
|
|
34
|
+
'--config',
|
|
35
|
+
'--tsconfig-override',
|
|
36
|
+
'-d',
|
|
37
|
+
'--define',
|
|
38
|
+
'-l',
|
|
39
|
+
'--main-fields',
|
|
40
|
+
]);
|
|
41
|
+
// Options that run inline code instead of a script file.
|
|
42
|
+
const INLINE_OPTIONS = new Set(['-e', '--eval', '-p', '--print']);
|
|
43
|
+
/** The script a Node or Bun runtime was started with, if any. */
|
|
44
|
+
function runtimeScript(runtime, args) {
|
|
45
|
+
for (let index = 0; index < args.length; index++) {
|
|
46
|
+
const argument = args[index] ?? '';
|
|
47
|
+
if (argument === '--')
|
|
48
|
+
return args[index + 1];
|
|
49
|
+
if (INLINE_OPTIONS.has(argument))
|
|
50
|
+
return undefined;
|
|
51
|
+
if (argument.startsWith('-')) {
|
|
52
|
+
if (!argument.includes('=') && VALUE_OPTIONS.has(argument))
|
|
53
|
+
index++;
|
|
54
|
+
continue;
|
|
55
|
+
}
|
|
56
|
+
// `bun run <script>` names the script after the subcommand.
|
|
57
|
+
if (runtime === 'bun' && argument === 'run')
|
|
58
|
+
continue;
|
|
59
|
+
return argument;
|
|
60
|
+
}
|
|
61
|
+
return undefined;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Names the host a process runs, judged by what it executes: the program
|
|
65
|
+
* itself, or the script a Node or Bun runtime was started with. Any other
|
|
66
|
+
* argument is ignored, so a shell whose command line merely mentions an
|
|
67
|
+
* `opencode` folder (`bash -c "cd …/opencode && …"`) is not a running host.
|
|
68
|
+
* `ps` prints arguments unquoted, so on macOS and Linux a program or script
|
|
69
|
+
* path containing spaces is not recognized; npm and Bun install OpenCode and Pi
|
|
70
|
+
* under paths without spaces.
|
|
71
|
+
*/
|
|
72
|
+
function hostName(command) {
|
|
73
|
+
const [program, ...rest] = commandArguments(command);
|
|
74
|
+
if (program === undefined)
|
|
75
|
+
return null;
|
|
76
|
+
const name = executableName(program);
|
|
77
|
+
if (HOSTS.has(name))
|
|
78
|
+
return name;
|
|
79
|
+
if (!RUNTIMES.has(name))
|
|
80
|
+
return null;
|
|
81
|
+
const script = runtimeScript(name, rest);
|
|
82
|
+
if (script === undefined)
|
|
83
|
+
return null;
|
|
84
|
+
const scriptName = executableName(script);
|
|
85
|
+
if (HOSTS.has(scriptName))
|
|
86
|
+
return scriptName;
|
|
87
|
+
return PI_SCRIPT_PATTERN.test(script) ? 'pi' : null;
|
|
88
|
+
}
|
|
89
|
+
export class ProcessInspectionError extends Error {
|
|
90
|
+
code = 'process-inspection-failed';
|
|
91
|
+
step;
|
|
92
|
+
exitCode;
|
|
93
|
+
signal;
|
|
94
|
+
timedOut;
|
|
95
|
+
durationMs;
|
|
96
|
+
constructor(details) {
|
|
97
|
+
super('Process inspection failed; setup cannot prove hosts are stopped.');
|
|
98
|
+
this.name = 'ProcessInspectionError';
|
|
99
|
+
this.step = details.step;
|
|
100
|
+
this.exitCode = details.exitCode;
|
|
101
|
+
this.signal = details.signal;
|
|
102
|
+
this.timedOut = details.timedOut;
|
|
103
|
+
this.durationMs = details.durationMs;
|
|
104
|
+
}
|
|
105
|
+
get refusalText() {
|
|
106
|
+
const outcome = this.timedOut
|
|
107
|
+
? 'timed out'
|
|
108
|
+
: this.signal
|
|
109
|
+
? `signal ${this.signal}`
|
|
110
|
+
: this.exitCode === null
|
|
111
|
+
? 'could not start or complete'
|
|
112
|
+
: this.exitCode === 0
|
|
113
|
+
? 'invalid output (exit code 0)'
|
|
114
|
+
: `exit code ${this.exitCode}`;
|
|
115
|
+
return `${this.message} ${this.step}: ${outcome} after ${Math.round(this.durationMs)} ms.`;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
export class ProcessFenceViolationError extends Error {
|
|
119
|
+
activeHosts;
|
|
120
|
+
constructor(activeHosts) {
|
|
121
|
+
// Process arguments may contain credentials; report only the recognized host name.
|
|
122
|
+
const safeHosts = activeHosts.map((host) => ({
|
|
123
|
+
pid: host.pid,
|
|
124
|
+
command: hostName(host.command) ?? 'host',
|
|
125
|
+
}));
|
|
126
|
+
super(`OpenCode or Pi processes are currently running:\n${safeHosts.map((host) => ` - PID ${host.pid}: ${host.command}`).join('\n')}\n\nPlease quit all OpenCode, LiteCode, and Pi processes before running setup.`);
|
|
127
|
+
this.activeHosts = safeHosts;
|
|
128
|
+
this.name = 'ProcessFenceViolationError';
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
/** List processes before filtering hosts; Windows PID 0 is a valid idle-process row. */
|
|
132
|
+
export async function listSetupProcesses(runner = defaultCommandRunner, options = {}) {
|
|
133
|
+
const windows = (options.platform ?? process.platform) === 'win32';
|
|
134
|
+
let inspection = {
|
|
135
|
+
step: windows ? 'tasklist' : 'ps',
|
|
136
|
+
exitCode: null,
|
|
137
|
+
signal: null,
|
|
138
|
+
timedOut: false,
|
|
139
|
+
durationMs: 0,
|
|
140
|
+
};
|
|
141
|
+
const inspect = async (step, file, args, timeoutMs) => {
|
|
142
|
+
const started = performance.now();
|
|
143
|
+
inspection = {
|
|
144
|
+
step,
|
|
145
|
+
exitCode: null,
|
|
146
|
+
signal: null,
|
|
147
|
+
timedOut: false,
|
|
148
|
+
durationMs: 0,
|
|
149
|
+
};
|
|
150
|
+
try {
|
|
151
|
+
const result = await runner.run(file, args, {
|
|
152
|
+
env: options.env,
|
|
153
|
+
timeoutMs,
|
|
154
|
+
});
|
|
155
|
+
inspection = {
|
|
156
|
+
step,
|
|
157
|
+
exitCode: result.exitCode,
|
|
158
|
+
signal: result.signal ?? null,
|
|
159
|
+
timedOut: result.timedOut ?? false,
|
|
160
|
+
durationMs: result.durationMs ?? performance.now() - started,
|
|
161
|
+
};
|
|
162
|
+
return result;
|
|
163
|
+
}
|
|
164
|
+
finally {
|
|
165
|
+
if (inspection.exitCode === null)
|
|
166
|
+
inspection.durationMs = performance.now() - started;
|
|
167
|
+
options.onStep?.({ ...inspection });
|
|
168
|
+
}
|
|
169
|
+
};
|
|
170
|
+
try {
|
|
171
|
+
const result = await inspect(windows ? 'tasklist' : 'ps', windows ? 'tasklist.exe' : 'ps', windows ? ['/fo', 'csv', '/nh'] : ['-eo', 'pid,command']);
|
|
172
|
+
if (result.exitCode !== 0)
|
|
173
|
+
throw new ProcessInspectionError(inspection);
|
|
174
|
+
const processes = [];
|
|
175
|
+
for (const line of result.stdout.split(/\r?\n/)) {
|
|
176
|
+
const trimmed = line.trim();
|
|
177
|
+
if (!trimmed)
|
|
178
|
+
continue;
|
|
179
|
+
let pid;
|
|
180
|
+
let command;
|
|
181
|
+
if (windows) {
|
|
182
|
+
const match = /^"([^"]+)","(\d+)"(?:,|$)/.exec(trimmed);
|
|
183
|
+
if (!match)
|
|
184
|
+
throw new ProcessInspectionError(inspection);
|
|
185
|
+
command = match[1] ?? '';
|
|
186
|
+
pid = Number(match[2]);
|
|
187
|
+
}
|
|
188
|
+
else {
|
|
189
|
+
const match = /^(\d+)\s+(.+)$/.exec(trimmed);
|
|
190
|
+
if (!match) {
|
|
191
|
+
if (/^PID\s+COMMAND$/i.test(trimmed))
|
|
192
|
+
continue;
|
|
193
|
+
throw new ProcessInspectionError(inspection);
|
|
194
|
+
}
|
|
195
|
+
pid = Number(match[1]);
|
|
196
|
+
command = match[2] ?? '';
|
|
197
|
+
}
|
|
198
|
+
if (!Number.isSafeInteger(pid) || pid < 0)
|
|
199
|
+
throw new ProcessInspectionError(inspection);
|
|
200
|
+
processes.push({ pid, command });
|
|
201
|
+
}
|
|
202
|
+
if (!processes.length)
|
|
203
|
+
throw new ProcessInspectionError(inspection);
|
|
204
|
+
// tasklist identifies native hosts, but npm Pi/OpenCode scripts appear as Node or Bun.
|
|
205
|
+
const runtimes = processes.filter((entry) => entry.pid !== process.pid && /^(?:node|bun)\.exe$/i.test(entry.command));
|
|
206
|
+
if (windows && runtimes.length && options.inspectRuntimes !== false) {
|
|
207
|
+
const details = await inspect('CIM', 'powershell.exe', [
|
|
208
|
+
'-NoProfile',
|
|
209
|
+
'-NonInteractive',
|
|
210
|
+
'-Command',
|
|
211
|
+
"$ErrorActionPreference = 'Stop'; Get-CimInstance Win32_Process -Filter \"Name = 'node.exe' OR Name = 'bun.exe'\" | Select-Object ProcessId,CommandLine | ConvertTo-Json -Compress",
|
|
212
|
+
], WINDOWS_CIM_TIMEOUT_MS);
|
|
213
|
+
if (details.exitCode !== 0)
|
|
214
|
+
throw new ProcessInspectionError(inspection);
|
|
215
|
+
const value = JSON.parse(details.stdout || 'null');
|
|
216
|
+
const rows = value === null ? [] : Array.isArray(value) ? value : [value];
|
|
217
|
+
const commands = new Map();
|
|
218
|
+
for (const row of rows) {
|
|
219
|
+
if (!row ||
|
|
220
|
+
typeof row !== 'object' ||
|
|
221
|
+
!('ProcessId' in row) ||
|
|
222
|
+
!('CommandLine' in row) ||
|
|
223
|
+
!Number.isSafeInteger(row.ProcessId))
|
|
224
|
+
throw new ProcessInspectionError(inspection);
|
|
225
|
+
if (typeof row.CommandLine === 'string')
|
|
226
|
+
commands.set(Number(row.ProcessId), row.CommandLine);
|
|
227
|
+
else if (runtimes.some((entry) => entry.pid === row.ProcessId))
|
|
228
|
+
throw new ProcessInspectionError(inspection);
|
|
229
|
+
}
|
|
230
|
+
for (const entry of runtimes) {
|
|
231
|
+
// A process absent from the later CIM snapshot already exited.
|
|
232
|
+
entry.command = commands.get(entry.pid) ?? '';
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
return processes;
|
|
236
|
+
}
|
|
237
|
+
catch (error) {
|
|
238
|
+
if (error instanceof ProcessInspectionError)
|
|
239
|
+
throw error;
|
|
240
|
+
throw new ProcessInspectionError(inspection);
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
export function createProcessFence(runner = defaultCommandRunner, options = {}) {
|
|
244
|
+
const isHost = (entry) => entry.pid !== process.pid && hostName(entry.command) !== null;
|
|
245
|
+
return {
|
|
246
|
+
async listRunningHosts(env) {
|
|
247
|
+
return (await listSetupProcesses(runner, { ...options, env })).filter(isHost);
|
|
248
|
+
},
|
|
249
|
+
async previewRunningHosts(env) {
|
|
250
|
+
const processes = await listSetupProcesses(runner, {
|
|
251
|
+
...options,
|
|
252
|
+
env,
|
|
253
|
+
inspectRuntimes: false,
|
|
254
|
+
});
|
|
255
|
+
const windows = (options.platform ?? process.platform) === 'win32';
|
|
256
|
+
return {
|
|
257
|
+
hosts: processes.filter(isHost),
|
|
258
|
+
uncheckedRuntimes: windows
|
|
259
|
+
? processes.filter((entry) => entry.pid !== process.pid &&
|
|
260
|
+
/^(?:node|bun)\.exe$/i.test(entry.command)).length
|
|
261
|
+
: 0,
|
|
262
|
+
};
|
|
263
|
+
},
|
|
264
|
+
};
|
|
265
|
+
}
|
|
266
|
+
export async function assertHostsStopped(fence, env) {
|
|
267
|
+
const active = await fence.listRunningHosts(env);
|
|
268
|
+
if (active.length)
|
|
269
|
+
throw new ProcessFenceViolationError(active);
|
|
270
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { select } from '../auth-menu/select.js';
|
|
2
|
+
/** Reuse the terminal selector for a toggle list with an explicit final choice. */
|
|
3
|
+
export async function selectSetupHosts(terminal, found) {
|
|
4
|
+
const selected = new Set(found);
|
|
5
|
+
for (;;) {
|
|
6
|
+
const choice = await select(terminal, [
|
|
7
|
+
...['opencode', 'pi'].map((host) => ({
|
|
8
|
+
value: host,
|
|
9
|
+
label: `[${selected.has(host) ? 'x' : ' '}] ${host === 'opencode' ? 'OpenCode' : 'Pi'}`,
|
|
10
|
+
hint: found.includes(host) ? 'found' : 'not found',
|
|
11
|
+
})),
|
|
12
|
+
{ value: 'done', label: 'Continue with selected hosts' },
|
|
13
|
+
], {
|
|
14
|
+
message: 'Select hosts to set up',
|
|
15
|
+
subtitle: 'Enter toggles a host; choose Continue when ready.',
|
|
16
|
+
});
|
|
17
|
+
if (choice === null)
|
|
18
|
+
return null;
|
|
19
|
+
if (choice === 'done')
|
|
20
|
+
return [...selected];
|
|
21
|
+
if (selected.has(choice))
|
|
22
|
+
selected.delete(choice);
|
|
23
|
+
else
|
|
24
|
+
selected.add(choice);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { OpenCodeGeneration, SetupIO, SetupPlugin } from './types.js';
|
|
2
|
+
export interface PlannedWrite {
|
|
3
|
+
path: string;
|
|
4
|
+
content: string;
|
|
5
|
+
changed: boolean;
|
|
6
|
+
}
|
|
7
|
+
/** Edit only array entries so unrelated JSONC text, including comments, survives. */
|
|
8
|
+
export declare function updatePluginConfig(text: string, key: 'plugin' | 'plugins', pkg: string, version: string): string;
|
|
9
|
+
export declare function planOpenCodeRegistration(plugin: SetupPlugin, generation: OpenCodeGeneration, io?: SetupIO): PlannedWrite[];
|
|
10
|
+
export declare function registerOpenCode(writes: readonly PlannedWrite[], beforeWrite?: () => Promise<void>): Promise<void>;
|
|
11
|
+
export declare function registerPi(plugin: SetupPlugin, executable: string, io?: SetupIO): Promise<void>;
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import { applyEdits, createScanner, findNodeAtLocation, modify, parse, parseTree, } from 'jsonc-parser';
|
|
2
|
+
import { defaultCommandRunner, runResolvedCommand } from './command-runner.js';
|
|
3
|
+
import { writeHostConfigAtomic } from './config-write.js';
|
|
4
|
+
import { defaultSetupFileSystem } from './detect.js';
|
|
5
|
+
import { setupPaths } from './paths.js';
|
|
6
|
+
function packageOf(value) {
|
|
7
|
+
const entry = typeof value === 'string'
|
|
8
|
+
? value
|
|
9
|
+
: Array.isArray(value)
|
|
10
|
+
? value[0]
|
|
11
|
+
: value && typeof value === 'object' && 'package' in value
|
|
12
|
+
? value.package
|
|
13
|
+
: null;
|
|
14
|
+
if (typeof entry !== 'string')
|
|
15
|
+
return null;
|
|
16
|
+
const at = entry.indexOf('@', entry.startsWith('@') ? 1 : 0);
|
|
17
|
+
return at < 0 ? entry : entry.slice(0, at);
|
|
18
|
+
}
|
|
19
|
+
function removeArrayEntry(text, key, index) {
|
|
20
|
+
const tree = parseTree(text);
|
|
21
|
+
const array = tree && findNodeAtLocation(tree, [key]);
|
|
22
|
+
const nodes = array?.children ?? [];
|
|
23
|
+
const node = nodes[index];
|
|
24
|
+
if (!node || !array)
|
|
25
|
+
throw new Error('Invalid plugin array edit.');
|
|
26
|
+
const edits = [{ offset: node.offset, length: node.length, content: '' }];
|
|
27
|
+
const removeComma = (start, end) => {
|
|
28
|
+
const scanner = createScanner(text.slice(start, end), true);
|
|
29
|
+
scanner.scan();
|
|
30
|
+
if (text[start + scanner.getTokenOffset()] === ',')
|
|
31
|
+
edits.push({
|
|
32
|
+
offset: start + scanner.getTokenOffset(),
|
|
33
|
+
length: 1,
|
|
34
|
+
content: '',
|
|
35
|
+
});
|
|
36
|
+
};
|
|
37
|
+
// Delete punctuation separately so comments beside other entries are not removed.
|
|
38
|
+
if (index === nodes.length - 1) {
|
|
39
|
+
const previous = nodes[index - 1];
|
|
40
|
+
if (previous)
|
|
41
|
+
removeComma(previous.offset + previous.length, node.offset);
|
|
42
|
+
removeComma(node.offset + node.length, array.offset + array.length - 1);
|
|
43
|
+
}
|
|
44
|
+
else
|
|
45
|
+
removeComma(node.offset + node.length, nodes[index + 1]?.offset ?? node.offset + node.length);
|
|
46
|
+
return applyEdits(text, edits);
|
|
47
|
+
}
|
|
48
|
+
/** Edit only array entries so unrelated JSONC text, including comments, survives. */
|
|
49
|
+
export function updatePluginConfig(text, key, pkg, version) {
|
|
50
|
+
const errors = [];
|
|
51
|
+
const value = parse(text, errors, { allowTrailingComma: true });
|
|
52
|
+
if (errors.length ||
|
|
53
|
+
!value ||
|
|
54
|
+
typeof value !== 'object' ||
|
|
55
|
+
Array.isArray(value))
|
|
56
|
+
throw new Error('Invalid OpenCode config; refusing to overwrite it.');
|
|
57
|
+
const options = {
|
|
58
|
+
formattingOptions: {
|
|
59
|
+
insertSpaces: !/^\t+/m.test(text),
|
|
60
|
+
tabSize: /^([ ]+)"/m.exec(text)?.[1]?.length ?? 2,
|
|
61
|
+
eol: text.includes('\r\n') ? '\r\n' : '\n',
|
|
62
|
+
},
|
|
63
|
+
};
|
|
64
|
+
let output = text;
|
|
65
|
+
const array = value[key];
|
|
66
|
+
if (array !== undefined && !Array.isArray(array))
|
|
67
|
+
throw new Error(`OpenCode ${key} must be an array.`);
|
|
68
|
+
const entries = Array.isArray(array) ? [...array] : [];
|
|
69
|
+
const matches = entries.flatMap((entry, index) => packageOf(entry) === pkg ? [index] : []);
|
|
70
|
+
const entry = `${pkg}@${version}`;
|
|
71
|
+
if (!matches.length) {
|
|
72
|
+
output = applyEdits(output, modify(output, array === undefined ? [key] : [key, entries.length], array === undefined ? [entry] : entry, options));
|
|
73
|
+
}
|
|
74
|
+
else {
|
|
75
|
+
const first = matches[0];
|
|
76
|
+
const previous = entries[first];
|
|
77
|
+
// Preserve options in OpenCode's [package, options] and { package, options } entries.
|
|
78
|
+
const replacement = Array.isArray(previous)
|
|
79
|
+
? [entry, ...previous.slice(1)]
|
|
80
|
+
: previous && typeof previous === 'object'
|
|
81
|
+
? { ...previous, package: entry }
|
|
82
|
+
: entry;
|
|
83
|
+
if (JSON.stringify(previous) !== JSON.stringify(replacement))
|
|
84
|
+
output = applyEdits(output, modify(output, [key, first], replacement, options));
|
|
85
|
+
for (const index of matches.slice(1).reverse())
|
|
86
|
+
output = removeArrayEntry(output, key, index);
|
|
87
|
+
}
|
|
88
|
+
const other = key === 'plugin' ? 'plugins' : 'plugin';
|
|
89
|
+
if (Array.isArray(value[other])) {
|
|
90
|
+
const otherEntries = value[other];
|
|
91
|
+
for (let index = otherEntries.length - 1; index >= 0; index--) {
|
|
92
|
+
if (packageOf(otherEntries[index]) === pkg)
|
|
93
|
+
output = removeArrayEntry(output, other, index);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
return output;
|
|
97
|
+
}
|
|
98
|
+
export function planOpenCodeRegistration(plugin, generation, io = {}) {
|
|
99
|
+
const fs = io.fs ?? defaultSetupFileSystem;
|
|
100
|
+
const { path, opencode } = setupPaths(io);
|
|
101
|
+
const key = generation === '2' ? 'plugins' : 'plugin';
|
|
102
|
+
const names = generation === '2' ? ['opencode'] : ['opencode', 'tui'];
|
|
103
|
+
return names.map((name) => {
|
|
104
|
+
const jsonc = path.join(opencode, `${name}.jsonc`);
|
|
105
|
+
const json = path.join(opencode, `${name}.json`);
|
|
106
|
+
const file = fs.exists(jsonc) ? jsonc : fs.exists(json) ? json : jsonc;
|
|
107
|
+
const exists = fs.exists(file);
|
|
108
|
+
const before = exists
|
|
109
|
+
? fs.readText(file)
|
|
110
|
+
: `${JSON.stringify({ $schema: `https://opencode.ai/${name === 'tui' ? 'tui' : 'config'}.json` }, null, 2)}\n`;
|
|
111
|
+
const content = updatePluginConfig(before, key, plugin.packages.opencode, plugin.version);
|
|
112
|
+
return { path: file, content, changed: !exists || content !== before };
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
export async function registerOpenCode(writes, beforeWrite) {
|
|
116
|
+
for (const write of writes) {
|
|
117
|
+
if (!write.changed)
|
|
118
|
+
continue;
|
|
119
|
+
await beforeWrite?.();
|
|
120
|
+
await writeHostConfigAtomic(write.path, write.content, {
|
|
121
|
+
beforeRename: beforeWrite,
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
export async function registerPi(plugin, executable, io = {}) {
|
|
126
|
+
const { platform, env } = setupPaths(io);
|
|
127
|
+
const result = await runResolvedCommand(io.runner ?? defaultCommandRunner, platform, executable, ['install', `npm:${plugin.packages.pi}@${plugin.version}`], env);
|
|
128
|
+
if (result.exitCode !== 0)
|
|
129
|
+
throw new Error('Pi install failed; run pi install after checking your npm connection.');
|
|
130
|
+
}
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import type { MenuTerminal } from '../auth-menu/terminal.js';
|
|
2
|
+
import type { ClaustrumEnrollmentConnection, hostEnrollmentPaths } from '../claustrum/index.js';
|
|
3
|
+
export type SetupHost = 'opencode' | 'pi';
|
|
4
|
+
export type OpenCodeGeneration = '1' | '2' | 'both';
|
|
5
|
+
export type SetupEnvironment = Record<string, string | undefined>;
|
|
6
|
+
/**
|
|
7
|
+
* What setup decided before calling a plugin callback. The OpenCode generation
|
|
8
|
+
* is the one being registered, after `--opencode` or the interactive choice, so
|
|
9
|
+
* a plugin can sign in the way that generation expects (OpenCode 2 does not
|
|
10
|
+
* read OpenCode 1's login file).
|
|
11
|
+
*/
|
|
12
|
+
export interface SetupCallbackContext {
|
|
13
|
+
opencodeGeneration: OpenCodeGeneration;
|
|
14
|
+
mode: 'local' | 'claustrum';
|
|
15
|
+
/**
|
|
16
|
+
* Every host this run sets up, in order, so the first `beforeSignIn` can
|
|
17
|
+
* check conditions across all of them (for example that their storage paths
|
|
18
|
+
* do not overlap) before any host is changed.
|
|
19
|
+
*/
|
|
20
|
+
hosts: readonly SetupHost[];
|
|
21
|
+
/**
|
|
22
|
+
* Pi's agent folder, resolved the way Pi itself does (`PI_CODING_AGENT_DIR`,
|
|
23
|
+
* with `~` expanded, else `~/.pi/agent`). Pi's own `auth.json` lives here;
|
|
24
|
+
* use it rather than a plugin path setting, which can point elsewhere.
|
|
25
|
+
*/
|
|
26
|
+
piAgentDir: string;
|
|
27
|
+
}
|
|
28
|
+
/** Provider login, credential migration and vault activation stay in plugin callbacks. */
|
|
29
|
+
export interface SetupPlugin {
|
|
30
|
+
packages: {
|
|
31
|
+
opencode: string;
|
|
32
|
+
pi: string;
|
|
33
|
+
};
|
|
34
|
+
version: string;
|
|
35
|
+
displayName: string;
|
|
36
|
+
slashCommand: string;
|
|
37
|
+
vault: {
|
|
38
|
+
connectionFile: string;
|
|
39
|
+
hosts: Record<SetupHost, {
|
|
40
|
+
name: string;
|
|
41
|
+
paths: Parameters<typeof hostEnrollmentPaths>[0];
|
|
42
|
+
}>;
|
|
43
|
+
};
|
|
44
|
+
/**
|
|
45
|
+
* Runs for each host on a real run after the host, mode and generation are
|
|
46
|
+
* chosen and before the vault ceremony or `signInLocal`, while nothing has
|
|
47
|
+
* changed yet. Rejecting stops setup for that host, so a plugin can ask for
|
|
48
|
+
* consent or check preconditions before any credential or authority change.
|
|
49
|
+
*/
|
|
50
|
+
beforeSignIn?(host: SetupHost, context: SetupCallbackContext): Promise<void>;
|
|
51
|
+
signInLocal(host: SetupHost, context: SetupCallbackContext): Promise<void>;
|
|
52
|
+
migrate(host: SetupHost, context: SetupCallbackContext): Promise<void>;
|
|
53
|
+
/** Reject mixed local/vault credentials and activate provider-specific vault access before registration. */
|
|
54
|
+
beforeRegister?(host: SetupHost, mode: 'local' | 'claustrum', context: SetupCallbackContext): Promise<void>;
|
|
55
|
+
}
|
|
56
|
+
export interface CommandResult {
|
|
57
|
+
exitCode: number;
|
|
58
|
+
stdout: string;
|
|
59
|
+
stderr: string;
|
|
60
|
+
signal?: NodeJS.Signals | null;
|
|
61
|
+
timedOut?: boolean;
|
|
62
|
+
durationMs?: number;
|
|
63
|
+
}
|
|
64
|
+
export interface CommandRunner {
|
|
65
|
+
run(file: string, args: readonly string[], options?: {
|
|
66
|
+
env?: SetupEnvironment;
|
|
67
|
+
timeoutMs?: number;
|
|
68
|
+
windowsVerbatimArguments?: boolean;
|
|
69
|
+
}): Promise<CommandResult>;
|
|
70
|
+
}
|
|
71
|
+
export interface SetupFileSystem {
|
|
72
|
+
exists(path: string): boolean;
|
|
73
|
+
isDirectory(path: string): boolean;
|
|
74
|
+
isFile(path: string): boolean;
|
|
75
|
+
isExecutable(path: string): boolean;
|
|
76
|
+
readText(path: string): string;
|
|
77
|
+
realpath(path: string): string;
|
|
78
|
+
}
|
|
79
|
+
export interface ProcessFence {
|
|
80
|
+
listRunningHosts(env?: SetupEnvironment): Promise<Array<{
|
|
81
|
+
pid: number;
|
|
82
|
+
command: string;
|
|
83
|
+
}>>;
|
|
84
|
+
/**
|
|
85
|
+
* For a dry run, which must change nothing: the hosts found without starting
|
|
86
|
+
* any program that writes files. On Windows that skips the PowerShell query
|
|
87
|
+
* for Node and Bun command lines (PowerShell writes a startup cache into the
|
|
88
|
+
* user's profile), so Node or Bun processes are only counted. A fence without
|
|
89
|
+
* it is previewed with `listRunningHosts`.
|
|
90
|
+
*/
|
|
91
|
+
previewRunningHosts?(env?: SetupEnvironment): Promise<{
|
|
92
|
+
hosts: Array<{
|
|
93
|
+
pid: number;
|
|
94
|
+
command: string;
|
|
95
|
+
}>;
|
|
96
|
+
uncheckedRuntimes: number;
|
|
97
|
+
}>;
|
|
98
|
+
}
|
|
99
|
+
/** Defaults use the process terminal and environment; overrides are test seams. */
|
|
100
|
+
export interface SetupIO {
|
|
101
|
+
terminal?: MenuTerminal;
|
|
102
|
+
env?: SetupEnvironment;
|
|
103
|
+
platform?: string;
|
|
104
|
+
home?: string;
|
|
105
|
+
cwd?: string;
|
|
106
|
+
fs?: SetupFileSystem;
|
|
107
|
+
runner?: CommandRunner;
|
|
108
|
+
fence?: ProcessFence;
|
|
109
|
+
connect?: (options: {
|
|
110
|
+
connectionFile: string;
|
|
111
|
+
handshakeTimeoutMs: number;
|
|
112
|
+
}) => Promise<ClaustrumEnrollmentConnection>;
|
|
113
|
+
wait?: (ms: number) => Promise<void>;
|
|
114
|
+
}
|
|
115
|
+
export interface HostDetection {
|
|
116
|
+
installed: boolean;
|
|
117
|
+
executable: string | null;
|
|
118
|
+
version: string | null;
|
|
119
|
+
directory: string;
|
|
120
|
+
}
|
|
121
|
+
export interface SetupDetection {
|
|
122
|
+
opencode: HostDetection & {
|
|
123
|
+
generation: '1' | '2' | 'ambiguous';
|
|
124
|
+
};
|
|
125
|
+
pi: HostDetection;
|
|
126
|
+
claustrum: {
|
|
127
|
+
available: boolean;
|
|
128
|
+
executable: string | null;
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
export interface SetupResult {
|
|
132
|
+
hosts: SetupHost[];
|
|
133
|
+
dryRun: boolean;
|
|
134
|
+
mode: 'local' | 'claustrum';
|
|
135
|
+
detection: SetupDetection;
|
|
136
|
+
}
|