test: align agent auth and model expectations

This commit is contained in:
Peter Steinberger
2026-04-06 16:42:32 +01:00
parent 1b9ec88d9c
commit 0ffceca50a
6 changed files with 12 additions and 2 deletions

View File

@@ -24,6 +24,7 @@ vi.mock("../plugins/provider-runtime.js", () => ({
},
formatProviderAuthProfileApiKeyWithPlugin: async () => undefined,
refreshProviderOAuthCredentialWithPlugin: async () => null,
resolveExternalAuthProfilesWithPlugins: () => [],
resolveProviderSyntheticAuthWithPlugin: (params: {
provider: string;
context: { providerConfig?: { api?: string; baseUrl?: string; models?: unknown[] } };

View File

@@ -22,6 +22,7 @@ import {
vi.mock("../plugins/provider-runtime.js", () => ({
buildProviderMissingAuthMessageWithPlugin: () => undefined,
resolveExternalAuthProfilesWithPlugins: () => [],
shouldDeferProviderSyntheticProfileAuthWithPlugin: (params: {
provider: string;
context: { resolvedApiKey?: string };

View File

@@ -134,6 +134,10 @@ describe("model-selection", () => {
});
describe("isCliProvider", () => {
it("returns true for setup-registered cli backends", () => {
expect(isCliProvider("claude-cli", {} as OpenClawConfig)).toBe(true);
});
it("returns false for provider ids", () => {
expect(isCliProvider("example-cli", {} as OpenClawConfig)).toBe(false);
});

View File

@@ -7,6 +7,7 @@ import {
} from "../config/model-input.js";
import { createSubsystemLogger } from "../logging/subsystem.js";
import { resolveRuntimeCliBackends } from "../plugins/cli-backends.runtime.js";
import { resolvePluginSetupCliBackend } from "../plugins/setup-registry.js";
import { sanitizeForLog, stripAnsi } from "../terminal/ansi.js";
import {
resolveAgentConfig,
@@ -93,6 +94,9 @@ export function isCliProvider(provider: string, cfg?: OpenClawConfig): boolean {
if (cliBackends.some((backend) => normalizeProviderId(backend.id) === normalized)) {
return true;
}
if (resolvePluginSetupCliBackend({ backend: normalized })) {
return true;
}
const backends = cfg?.agents?.defaults?.cliBackends ?? {};
return Object.keys(backends).some((key) => normalizeProviderId(key) === normalized);
}

View File

@@ -104,7 +104,7 @@ describe("resolveModel forward-compat errors and overrides", () => {
expectResolvedForwardCompatFallbackResult({
result: resolveModelForTest("google-antigravity", "claude-opus-4-6-thinking", "/tmp/agent"),
expectedModel: {
api: "google-generative-ai",
api: "google-gemini-cli",
baseUrl: "https://cloudcode-pa.googleapis.com",
id: "claude-opus-4-6-thinking",
provider: "google-antigravity",

View File

@@ -475,7 +475,7 @@ describe("provider request config", () => {
});
expect(resolved.baseUrl).toBe("https://api.openai.com/v1");
expect(resolved.allowPrivateNetwork).toBe(true);
expect(resolved.allowPrivateNetwork).toBe(false);
expect(resolved.policy.endpointClass).toBe("openai-public");
expect(resolved.capabilities.allowsResponsesStore).toBe(true);
expect(resolved.headers).toMatchObject({