mirror of
https://github.com/openclaw/openclaw.git
synced 2026-03-28 18:33:37 +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(
|
||||
|
||||
@@ -182,6 +182,7 @@ describe("cli session history", () => {
|
||||
const messages = augmentChatHistoryWithCliSessionImports({
|
||||
entry: {
|
||||
sessionId: "openclaw-session",
|
||||
updatedAt: Date.now(),
|
||||
cliSessionBindings: {
|
||||
"claude-cli": {
|
||||
sessionId,
|
||||
@@ -205,6 +206,7 @@ describe("cli session history", () => {
|
||||
const messages = augmentChatHistoryWithCliSessionImports({
|
||||
entry: {
|
||||
sessionId: "openclaw-session",
|
||||
updatedAt: Date.now(),
|
||||
cliSessionIds: {
|
||||
"claude-cli": sessionId,
|
||||
},
|
||||
@@ -226,6 +228,7 @@ describe("cli session history", () => {
|
||||
const messages = augmentChatHistoryWithCliSessionImports({
|
||||
entry: {
|
||||
sessionId: "openclaw-session",
|
||||
updatedAt: Date.now(),
|
||||
claudeCliSessionId: sessionId,
|
||||
},
|
||||
provider: "claude-cli",
|
||||
|
||||
@@ -29,6 +29,9 @@ type ClaudeCliProjectEntry = {
|
||||
};
|
||||
};
|
||||
|
||||
type ClaudeCliMessage = NonNullable<ClaudeCliProjectEntry["message"]>;
|
||||
type ClaudeCliUsage = ClaudeCliMessage["usage"];
|
||||
|
||||
type TranscriptLikeMessage = Record<string, unknown>;
|
||||
|
||||
function resolveHistoryHomeDir(homeDir?: string): string {
|
||||
@@ -64,7 +67,7 @@ function resolveTimestampMs(value: unknown): number | undefined {
|
||||
return Number.isFinite(parsed) ? parsed : undefined;
|
||||
}
|
||||
|
||||
function resolveClaudeCliUsage(raw: ClaudeCliProjectEntry["message"]["usage"]) {
|
||||
function resolveClaudeCliUsage(raw: ClaudeCliUsage) {
|
||||
if (!raw || typeof raw !== "object") {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user