mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-04 18:50:20 +00:00
fix: skip cli backends in models auth warnings
This commit is contained in:
@@ -18,6 +18,7 @@ import {
|
||||
import { resolveEnvApiKey } from "../../agents/model-auth.js";
|
||||
import {
|
||||
buildModelAliasIndex,
|
||||
isCliProvider,
|
||||
parseModelRef,
|
||||
resolveConfiguredModelRef,
|
||||
resolveDefaultModelForAgent,
|
||||
@@ -189,6 +190,7 @@ export async function modelsStatusCommand(
|
||||
const providerAuthMap = new Map(providerAuth.map((entry) => [entry.provider, entry]));
|
||||
const missingProvidersInUse = Array.from(providersInUse)
|
||||
.filter((provider) => !providerAuthMap.has(provider))
|
||||
.filter((provider) => !isCliProvider(provider, cfg))
|
||||
.toSorted((a, b) => a.localeCompare(b));
|
||||
|
||||
const probeProfileIds = (() => {
|
||||
|
||||
@@ -293,6 +293,42 @@ describe("modelsStatusCommand auth overview", () => {
|
||||
);
|
||||
});
|
||||
|
||||
it("does not report cli backends as missing auth", async () => {
|
||||
const localRuntime = createRuntime();
|
||||
const originalLoadConfig = mocks.loadConfig.getMockImplementation();
|
||||
const originalEnvImpl = mocks.resolveEnvApiKey.getMockImplementation();
|
||||
mocks.loadConfig.mockReturnValue({
|
||||
agents: {
|
||||
defaults: {
|
||||
model: { primary: "claude-cli/claude-sonnet-4-6", fallbacks: [] },
|
||||
models: { "claude-cli/claude-sonnet-4-6": {} },
|
||||
cliBackends: { "claude-cli": {} },
|
||||
},
|
||||
},
|
||||
models: { providers: {} },
|
||||
env: { shellEnv: { enabled: true } },
|
||||
});
|
||||
mocks.resolveEnvApiKey.mockImplementation(() => null);
|
||||
|
||||
try {
|
||||
await modelsStatusCommand({ json: true }, localRuntime as never);
|
||||
const payload = JSON.parse(String((localRuntime.log as Mock).mock.calls[0]?.[0]));
|
||||
expect(payload.defaultModel).toBe("claude-cli/claude-sonnet-4-6");
|
||||
expect(payload.auth.missingProvidersInUse).toEqual([]);
|
||||
} finally {
|
||||
if (originalLoadConfig) {
|
||||
mocks.loadConfig.mockImplementation(originalLoadConfig);
|
||||
}
|
||||
if (originalEnvImpl) {
|
||||
mocks.resolveEnvApiKey.mockImplementation(originalEnvImpl);
|
||||
} else if (defaultResolveEnvApiKeyImpl) {
|
||||
mocks.resolveEnvApiKey.mockImplementation(defaultResolveEnvApiKeyImpl);
|
||||
} else {
|
||||
mocks.resolveEnvApiKey.mockImplementation(() => null);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
it("labels defaults when --agent has no overrides", async () => {
|
||||
const localRuntime = createRuntime();
|
||||
await withAgentScopeOverrides(
|
||||
|
||||
Reference in New Issue
Block a user