From c70b10460c4aeec653082ea8b40bff2dd5eef0de Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Sat, 4 Apr 2026 12:18:54 +0100 Subject: [PATCH] style(auth): normalize auth choice formatting --- src/cli/command-secret-gateway.test.ts | 4 +--- src/commands/auth-choice-legacy.ts | 2 +- src/commands/auth-choice-options.static.ts | 2 +- src/commands/auth-choice-options.ts | 2 +- src/commands/auth-choice.apply.ts | 4 ++-- src/commands/auth-choice.test.ts | 12 +++++------ .../local/auth-choice.ts | 4 ++-- src/config/legacy-migrate.test.ts | 9 ++++---- src/config/legacy.migrations.channels.ts | 3 +-- src/gateway/server.reload.test.ts | 4 +--- src/infra/device-bootstrap.test.ts | 21 +++---------------- src/plugins/manifest-registry.test.ts | 2 +- 12 files changed, 25 insertions(+), 44 deletions(-) diff --git a/src/cli/command-secret-gateway.test.ts b/src/cli/command-secret-gateway.test.ts index cee29ef4fa1..f69637c94f2 100644 --- a/src/cli/command-secret-gateway.test.ts +++ b/src/cli/command-secret-gateway.test.ts @@ -717,9 +717,7 @@ describe("resolveCommandSecretRefsViaGateway", () => { expect(readTalkProviderApiKey(result.resolvedConfig)).toBe("target-only"); expect(result.hadUnresolvedTargets).toBe(false); - expect(result.targetStatesByPath["talk.providers.elevenlabs.apiKey"]).toBe( - "resolved_local", - ); + expect(result.targetStatesByPath["talk.providers.elevenlabs.apiKey"]).toBe("resolved_local"); } finally { if (priorTalkValue === undefined) { delete process.env[talkEnvKey]; diff --git a/src/commands/auth-choice-legacy.ts b/src/commands/auth-choice-legacy.ts index 82bce76ffa7..d60702fb557 100644 --- a/src/commands/auth-choice-legacy.ts +++ b/src/commands/auth-choice-legacy.ts @@ -1,9 +1,9 @@ import type { OpenClawConfig } from "../config/config.js"; -import type { AuthChoice } from "./onboard-types.js"; import { resolveManifestDeprecatedProviderAuthChoice, resolveManifestProviderAuthChoices, } from "../plugins/provider-auth-choices.js"; +import type { AuthChoice } from "./onboard-types.js"; function resolveLegacyCliBackendChoice( choice: string, diff --git a/src/commands/auth-choice-options.static.ts b/src/commands/auth-choice-options.static.ts index e4980811b9b..da25536b9aa 100644 --- a/src/commands/auth-choice-options.static.ts +++ b/src/commands/auth-choice-options.static.ts @@ -1,5 +1,5 @@ -import type { AuthChoice, AuthChoiceGroupId } from "./onboard-types.js"; import { resolveLegacyAuthChoiceAliasesForCli } from "./auth-choice-legacy.js"; +import type { AuthChoice, AuthChoiceGroupId } from "./onboard-types.js"; export type { AuthChoiceGroupId }; diff --git a/src/commands/auth-choice-options.ts b/src/commands/auth-choice-options.ts index 8bee688cc4f..2f015cb6132 100644 --- a/src/commands/auth-choice-options.ts +++ b/src/commands/auth-choice-options.ts @@ -1,6 +1,5 @@ import type { AuthProfileStore } from "../agents/auth-profiles.js"; import type { OpenClawConfig } from "../config/config.js"; -import type { AuthChoice, AuthChoiceGroupId } from "./onboard-types.js"; import { resolveManifestProviderSetupFlowContributions, resolveProviderSetupFlowContributions, @@ -11,6 +10,7 @@ import { type AuthChoiceOption, formatStaticAuthChoiceChoicesForCli, } from "./auth-choice-options.static.js"; +import type { AuthChoice, AuthChoiceGroupId } from "./onboard-types.js"; function compareOptionLabels(a: AuthChoiceOption, b: AuthChoiceOption): number { return a.label.localeCompare(b.label); diff --git a/src/commands/auth-choice.apply.ts b/src/commands/auth-choice.apply.ts index 8a22b62832a..efb3f32647b 100644 --- a/src/commands/auth-choice.apply.ts +++ b/src/commands/auth-choice.apply.ts @@ -1,12 +1,12 @@ import type { OpenClawConfig } from "../config/config.js"; +import { applyAuthChoiceLoadedPluginProvider } from "../plugins/provider-auth-choice.js"; import type { RuntimeEnv } from "../runtime.js"; import type { WizardPrompter } from "../wizard/prompts.js"; -import type { AuthChoice, OnboardOptions } from "./onboard-types.js"; -import { applyAuthChoiceLoadedPluginProvider } from "../plugins/provider-auth-choice.js"; import { normalizeLegacyOnboardAuthChoice } from "./auth-choice-legacy.js"; import { applyAuthChoiceApiProviders } from "./auth-choice.apply.api-providers.js"; import { normalizeApiKeyTokenProviderAuthChoice } from "./auth-choice.apply.api-providers.js"; import { applyAuthChoiceOAuth } from "./auth-choice.apply.oauth.js"; +import type { AuthChoice, OnboardOptions } from "./onboard-types.js"; export type ApplyAuthChoiceParams = { authChoice: AuthChoice; diff --git a/src/commands/auth-choice.test.ts b/src/commands/auth-choice.test.ts index cffb9543b5e..9a552e65b53 100644 --- a/src/commands/auth-choice.test.ts +++ b/src/commands/auth-choice.test.ts @@ -1,19 +1,19 @@ -import type { OAuthCredentials } from "@mariozechner/pi-ai"; import fs from "node:fs/promises"; +import type { OAuthCredentials } from "@mariozechner/pi-ai"; import { afterEach, describe, expect, it, vi } from "vitest"; -import type { OpenClawConfig } from "../config/config.js"; -import type { ModelProviderConfig } from "../config/types.models.js"; -import type { ProviderAuthMethod, ProviderPlugin } from "../plugins/types.js"; -import type { WizardPrompter } from "../wizard/prompts.js"; -import type { AuthChoice } from "./onboard-types.js"; import { resolveAgentDir } from "../agents/agent-scope.js"; +import type { OpenClawConfig } from "../config/config.js"; import { resolveAgentModelPrimaryValue } from "../config/model-input.js"; +import type { ModelProviderConfig } from "../config/types.models.js"; import { GOOGLE_GEMINI_DEFAULT_MODEL } from "../plugin-sdk/google.js"; import { MINIMAX_CN_API_BASE_URL } from "../plugin-sdk/minimax.js"; import { ZAI_CODING_CN_BASE_URL, ZAI_CODING_GLOBAL_BASE_URL } from "../plugin-sdk/zai.js"; import { createProviderApiKeyAuthMethod } from "../plugins/provider-api-key-auth.js"; import { providerApiKeyAuthRuntime } from "../plugins/provider-api-key-auth.runtime.js"; +import type { ProviderAuthMethod, ProviderPlugin } from "../plugins/types.js"; +import type { WizardPrompter } from "../wizard/prompts.js"; import { applyAuthChoice, resolvePreferredProviderForAuthChoice } from "./auth-choice.js"; +import type { AuthChoice } from "./onboard-types.js"; import { authProfilePathForAgent, createAuthTestLifecycle, diff --git a/src/commands/onboard-non-interactive/local/auth-choice.ts b/src/commands/onboard-non-interactive/local/auth-choice.ts index 51f5e796307..507e447e096 100644 --- a/src/commands/onboard-non-interactive/local/auth-choice.ts +++ b/src/commands/onboard-non-interactive/local/auth-choice.ts @@ -1,9 +1,8 @@ import type { ApiKeyCredential } from "../../../agents/auth-profiles/types.js"; import type { OpenClawConfig } from "../../../config/config.js"; import type { SecretInput } from "../../../config/types.secrets.js"; -import type { RuntimeEnv } from "../../../runtime.js"; -import type { AuthChoice, OnboardOptions } from "../../onboard-types.js"; import { resolveManifestDeprecatedProviderAuthChoice } from "../../../plugins/provider-auth-choices.js"; +import type { RuntimeEnv } from "../../../runtime.js"; import { resolveDefaultSecretProviderAlias } from "../../../secrets/ref-contract.js"; import { formatDeprecatedNonInteractiveAuthChoiceError, @@ -17,6 +16,7 @@ import { parseNonInteractiveCustomApiFlags, resolveCustomProviderId, } from "../../onboard-custom.js"; +import type { AuthChoice, OnboardOptions } from "../../onboard-types.js"; import { resolveNonInteractiveApiKey } from "../api-keys.js"; import { applyNonInteractivePluginProviderChoice } from "./auth-choice.plugin-providers.js"; diff --git a/src/config/legacy-migrate.test.ts b/src/config/legacy-migrate.test.ts index 2b4ae42a96b..72456e0bcc3 100644 --- a/src/config/legacy-migrate.test.ts +++ b/src/config/legacy-migrate.test.ts @@ -523,13 +523,14 @@ describe("legacy migrate channel streaming aliases", () => { (validated.config.channels?.googlechat as Record | undefined)?.streamMode, ).toBeUndefined(); expect( - ( - validated.config.channels?.googlechat?.accounts?.work as Record | undefined - )?.streamMode, + (validated.config.channels?.googlechat?.accounts?.work as Record | undefined) + ?.streamMode, ).toBeUndefined(); const res = migrateLegacyConfig(raw); - expect(res.changes).toContain("Removed channels.googlechat.streamMode (legacy key no longer used)."); + expect(res.changes).toContain( + "Removed channels.googlechat.streamMode (legacy key no longer used).", + ); expect(res.changes).toContain( "Removed channels.googlechat.accounts.work.streamMode (legacy key no longer used).", ); diff --git a/src/config/legacy.migrations.channels.ts b/src/config/legacy.migrations.channels.ts index 24a747e5ae1..a63b3179e9d 100644 --- a/src/config/legacy.migrations.channels.ts +++ b/src/config/legacy.migrations.channels.ts @@ -420,8 +420,7 @@ const CHANNEL_ENABLED_ALIAS_RULES: LegacyConfigRule[] = [ const GOOGLECHAT_STREAMMODE_RULES: LegacyConfigRule[] = [ { path: ["channels", "googlechat"], - message: - "channels.googlechat.streamMode is legacy and no longer used; it is removed on load.", + message: "channels.googlechat.streamMode is legacy and no longer used; it is removed on load.", match: (value) => hasLegacyGoogleChatStreamMode(value), }, { diff --git a/src/gateway/server.reload.test.ts b/src/gateway/server.reload.test.ts index e9c9c07b479..aad53eb24fd 100644 --- a/src/gateway/server.reload.test.ts +++ b/src/gateway/server.reload.test.ts @@ -785,9 +785,7 @@ describe("gateway hot reload", () => { targetIds: ["talk.providers.*.apiKey"], }); expect(postResolve.ok).toBe(true); - expect(postResolve.payload?.assignments?.[0]?.path).toBe( - "talk.providers.elevenlabs.apiKey", - ); + expect(postResolve.payload?.assignments?.[0]?.path).toBe("talk.providers.elevenlabs.apiKey"); expect(postResolve.payload?.assignments?.[0]?.value).toBe("talk-key-before-reload-failure"); } finally { if (previousRefValue === undefined) { diff --git a/src/infra/device-bootstrap.test.ts b/src/infra/device-bootstrap.test.ts index ff7c83641a2..813f7c3abc8 100644 --- a/src/infra/device-bootstrap.test.ts +++ b/src/infra/device-bootstrap.test.ts @@ -105,12 +105,7 @@ describe("device bootstrap tokens", () => { await expect(getDeviceBootstrapTokenProfile({ baseDir, token: issued.token })).resolves.toEqual( { roles: ["node", "operator"], - scopes: [ - "operator.approvals", - "operator.read", - "operator.talk.secrets", - "operator.write", - ], + scopes: ["operator.approvals", "operator.read", "operator.talk.secrets", "operator.write"], }, ); await expect(getDeviceBootstrapTokenProfile({ baseDir, token: "invalid" })).resolves.toBeNull(); @@ -136,12 +131,7 @@ describe("device bootstrap tokens", () => { await expect( verifyBootstrapToken(baseDir, issued.token, { role: "operator", - scopes: [ - "operator.approvals", - "operator.read", - "operator.write", - "operator.talk.secrets", - ], + scopes: ["operator.approvals", "operator.read", "operator.write", "operator.talk.secrets"], }), ).resolves.toEqual({ ok: true }); await expect( @@ -149,12 +139,7 @@ describe("device bootstrap tokens", () => { baseDir, token: issued.token, role: "operator", - scopes: [ - "operator.approvals", - "operator.read", - "operator.write", - "operator.talk.secrets", - ], + scopes: ["operator.approvals", "operator.read", "operator.write", "operator.talk.secrets"], }), ).resolves.toEqual({ recorded: true, diff --git a/src/plugins/manifest-registry.test.ts b/src/plugins/manifest-registry.test.ts index b6a0350bf85..aec328a4cda 100644 --- a/src/plugins/manifest-registry.test.ts +++ b/src/plugins/manifest-registry.test.ts @@ -2,11 +2,11 @@ import fs from "node:fs"; import path from "node:path"; import { afterEach, describe, expect, it, vi } from "vitest"; import type { PluginCandidate } from "./discovery.js"; -import type { OpenClawPackageManifest } from "./manifest.js"; import { clearPluginManifestRegistryCache, loadPluginManifestRegistry, } from "./manifest-registry.js"; +import type { OpenClawPackageManifest } from "./manifest.js"; import { cleanupTrackedTempDirs, makeTrackedTempDir } from "./test-helpers/fs-fixtures.js"; vi.unmock("../version.js");