mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 20:18:28 +00:00
chore: apply local workspace updates (#9911)
* chore: apply local workspace updates * fix: resolve prep findings after rebase (#9898) (thanks @gumadeiras) * refactor: centralize model allowlist normalization (#9898) (thanks @gumadeiras) * fix: guard model allowlist initialization (#9911) * docs: update changelog scope for #9911 * docs: remove model names from changelog entry (#9911) * fix: satisfy type-aware lint in model allowlist (#9911)
This commit is contained in:
committed by
GitHub
parent
93b450349f
commit
4629054403
77
src/commands/auth-choice.default-model.test.ts
Normal file
77
src/commands/auth-choice.default-model.test.ts
Normal file
@@ -0,0 +1,77 @@
|
||||
import { describe, expect, it, vi } from "vitest";
|
||||
import type { OpenClawConfig } from "../config/config.js";
|
||||
import type { WizardPrompter } from "../wizard/prompts.js";
|
||||
import { applyDefaultModelChoice } from "./auth-choice.default-model.js";
|
||||
|
||||
function makePrompter(): WizardPrompter {
|
||||
return {
|
||||
intro: async () => {},
|
||||
outro: async () => {},
|
||||
note: async () => {},
|
||||
select: async () => "",
|
||||
multiselect: async () => [],
|
||||
text: async () => "",
|
||||
confirm: async () => false,
|
||||
progress: () => ({ update: () => {}, stop: () => {} }),
|
||||
};
|
||||
}
|
||||
|
||||
describe("applyDefaultModelChoice", () => {
|
||||
it("ensures allowlist entry exists when returning an agent override", async () => {
|
||||
const defaultModel = "vercel-ai-gateway/anthropic/claude-opus-4.6";
|
||||
const noteAgentModel = vi.fn(async () => {});
|
||||
const applied = await applyDefaultModelChoice({
|
||||
config: {},
|
||||
setDefaultModel: false,
|
||||
defaultModel,
|
||||
// Simulate a provider function that does not explicitly add the entry.
|
||||
applyProviderConfig: (config: OpenClawConfig) => config,
|
||||
applyDefaultConfig: (config: OpenClawConfig) => config,
|
||||
noteAgentModel,
|
||||
prompter: makePrompter(),
|
||||
});
|
||||
|
||||
expect(noteAgentModel).toHaveBeenCalledWith(defaultModel);
|
||||
expect(applied.agentModelOverride).toBe(defaultModel);
|
||||
expect(applied.config.agents?.defaults?.models?.[defaultModel]).toEqual({});
|
||||
});
|
||||
|
||||
it("adds canonical allowlist key for anthropic aliases", async () => {
|
||||
const defaultModel = "anthropic/opus-4.6";
|
||||
const applied = await applyDefaultModelChoice({
|
||||
config: {},
|
||||
setDefaultModel: false,
|
||||
defaultModel,
|
||||
applyProviderConfig: (config: OpenClawConfig) => config,
|
||||
applyDefaultConfig: (config: OpenClawConfig) => config,
|
||||
noteAgentModel: async () => {},
|
||||
prompter: makePrompter(),
|
||||
});
|
||||
|
||||
expect(applied.config.agents?.defaults?.models?.[defaultModel]).toEqual({});
|
||||
expect(applied.config.agents?.defaults?.models?.["anthropic/claude-opus-4-6"]).toEqual({});
|
||||
});
|
||||
|
||||
it("uses applyDefaultConfig path when setDefaultModel is true", async () => {
|
||||
const defaultModel = "openai/gpt-5.1-codex";
|
||||
const applied = await applyDefaultModelChoice({
|
||||
config: {},
|
||||
setDefaultModel: true,
|
||||
defaultModel,
|
||||
applyProviderConfig: (config: OpenClawConfig) => config,
|
||||
applyDefaultConfig: () => ({
|
||||
agents: {
|
||||
defaults: {
|
||||
model: { primary: defaultModel },
|
||||
},
|
||||
},
|
||||
}),
|
||||
noteDefault: defaultModel,
|
||||
noteAgentModel: async () => {},
|
||||
prompter: makePrompter(),
|
||||
});
|
||||
|
||||
expect(applied.agentModelOverride).toBeUndefined();
|
||||
expect(applied.config.agents?.defaults?.model).toEqual({ primary: defaultModel });
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user