style(auth): normalize auth choice formatting

This commit is contained in:
Peter Steinberger
2026-04-04 12:18:54 +01:00
parent f3aad63f4e
commit c70b10460c
12 changed files with 25 additions and 44 deletions

View File

@@ -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];

View File

@@ -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,

View File

@@ -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 };

View File

@@ -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);

View File

@@ -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;

View File

@@ -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,

View File

@@ -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";

View File

@@ -523,13 +523,14 @@ describe("legacy migrate channel streaming aliases", () => {
(validated.config.channels?.googlechat as Record<string, unknown> | undefined)?.streamMode,
).toBeUndefined();
expect(
(
validated.config.channels?.googlechat?.accounts?.work as Record<string, unknown> | undefined
)?.streamMode,
(validated.config.channels?.googlechat?.accounts?.work as Record<string, unknown> | 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).",
);

View File

@@ -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),
},
{

View File

@@ -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) {

View File

@@ -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,

View File

@@ -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");