chore(deadcode): prune stale model metadata wrappers

This commit is contained in:
Vincent Koc
2026-06-20 13:37:35 +08:00
parent 352141a1be
commit d0812126c8
11 changed files with 24 additions and 74 deletions

View File

@@ -11,8 +11,10 @@ import {
MINIMAX_M27_API_COST,
MINIMAX_M25_API_COST,
MINIMAX_M25_API_HIGHSPEED_COST,
MINIMAX_M3_CONTEXT_WINDOW,
} from "./model-definitions.js";
import { MINIMAX_TEXT_MODEL_CATALOG } from "./provider-models.js";
const MINIMAX_M3_CATALOG_CONTEXT_WINDOW = MINIMAX_TEXT_MODEL_CATALOG["MiniMax-M3"].contextWindow;
describe("minimax model definitions", () => {
it("uses M3 as default hosted model", () => {
@@ -20,7 +22,7 @@ describe("minimax model definitions", () => {
});
it("uses the current upstream MiniMax context, token, and pricing defaults", () => {
expect(MINIMAX_M3_CONTEXT_WINDOW).toBe(1_000_000);
expect(MINIMAX_M3_CATALOG_CONTEXT_WINDOW).toBe(1_000_000);
expect(DEFAULT_MINIMAX_CONTEXT_WINDOW).toBe(204800);
expect(DEFAULT_MINIMAX_MAX_TOKENS).toBe(131072);
expect(MINIMAX_API_COST).toEqual({
@@ -35,11 +37,11 @@ describe("minimax model definitions", () => {
const model = buildMinimaxModelDefinition({
id: "MiniMax-M3",
cost: MINIMAX_API_COST,
contextWindow: MINIMAX_M3_CONTEXT_WINDOW,
contextWindow: MINIMAX_M3_CATALOG_CONTEXT_WINDOW,
maxTokens: DEFAULT_MINIMAX_MAX_TOKENS,
});
expect(model).toEqual({
contextWindow: MINIMAX_M3_CONTEXT_WINDOW,
contextWindow: MINIMAX_M3_CATALOG_CONTEXT_WINDOW,
cost: MINIMAX_API_COST,
id: "MiniMax-M3",
input: ["text", "image"],
@@ -70,7 +72,7 @@ describe("minimax model definitions", () => {
it("builds API model definition with standard cost for M3", () => {
const model = buildMinimaxApiModelDefinition("MiniMax-M3");
expect(model.cost).toEqual(MINIMAX_API_COST);
expect(model.contextWindow).toBe(MINIMAX_M3_CONTEXT_WINDOW);
expect(model.contextWindow).toBe(MINIMAX_M3_CATALOG_CONTEXT_WINDOW);
expect(model.maxTokens).toBe(DEFAULT_MINIMAX_MAX_TOKENS);
expect(model.input).toEqual(["text", "image"]);
});

View File

@@ -8,7 +8,6 @@ export const MINIMAX_CN_API_BASE_URL = "https://api.minimaxi.com/anthropic";
export const MINIMAX_HOSTED_MODEL_ID = MINIMAX_DEFAULT_MODEL_ID;
export const MINIMAX_HOSTED_MODEL_REF = `minimax/${MINIMAX_HOSTED_MODEL_ID}`;
export const DEFAULT_MINIMAX_CONTEXT_WINDOW = 204800;
export const MINIMAX_M3_CONTEXT_WINDOW = 1_000_000;
export const DEFAULT_MINIMAX_MAX_TOKENS = 131072;
export const MINIMAX_API_COST = {

View File

@@ -12,18 +12,6 @@ import { writePersistedAuthProfileStoreRaw } from "./auth-profiles/sqlite.js";
vi.mock("./model-auth-env-vars.js", () => ({
listProviderEnvAuthLookupKeys: () => ["mistral", "workspace-cloud"],
resolveProviderEnvApiKeyCandidates: () => ({
mistral: ["MISTRAL_API_KEY"],
}),
resolveProviderEnvAuthEvidence: () => ({
"workspace-cloud": [
{
type: "local-file-with-env",
credentialMarker: "workspace-cloud-local-credentials",
source: "workspace cloud credentials",
},
],
}),
resolveProviderEnvAuthLookupMaps: () => ({
aliasMap: {},
envCandidateMap: {

View File

@@ -5,8 +5,6 @@
*/
import {
listKnownProviderAuthEnvVarNames,
resolveProviderAuthEvidence,
resolveProviderAuthEnvVarCandidates,
resolveProviderAuthLookupMaps,
} from "../secrets/provider-env-vars.js";
import type {
@@ -15,20 +13,6 @@ import type {
ProviderEnvVarLookupParams,
} from "../secrets/provider-env-vars.js";
/** Returns provider-to-env-var candidates for API-key style auth lookup. */
export function resolveProviderEnvApiKeyCandidates(
params?: ProviderEnvVarLookupParams,
): Record<string, readonly string[]> {
return resolveProviderAuthEnvVarCandidates(params);
}
/** Returns provider auth evidence that may come from env vars, files, or plugin manifests. */
export function resolveProviderEnvAuthEvidence(
params?: ProviderEnvVarLookupParams,
): Record<string, readonly ProviderAuthEvidence[]> {
return resolveProviderAuthEvidence(params);
}
/** Resolves both env-var candidates and richer auth evidence from one manifest snapshot. */
export function resolveProviderEnvAuthLookupMaps(
params?: ProviderEnvVarLookupParams,

View File

@@ -152,7 +152,7 @@ vi.mock("./model-auth-env-vars.js", () => {
bedrock: "amazon-bedrock",
"aws-bedrock": "amazon-bedrock",
};
const resolveProviderEnvAuthEvidence = (params?: { config?: OpenClawConfig }) => {
const resolveMockProviderAuthEvidence = (params?: { config?: OpenClawConfig }) => {
const evidence = {
"google-vertex": [
{
@@ -186,12 +186,10 @@ vi.mock("./model-auth-env-vars.js", () => {
};
return {
listKnownProviderEnvApiKeyNames: () => [...new Set(Object.values(candidates).flat())],
resolveProviderEnvApiKeyCandidates: () => candidates,
resolveProviderEnvAuthEvidence,
resolveProviderEnvAuthLookupMaps: (params?: { config?: OpenClawConfig }) => ({
aliasMap,
envCandidateMap: candidates,
authEvidenceMap: resolveProviderEnvAuthEvidence(params),
authEvidenceMap: resolveMockProviderAuthEvidence(params),
setupProviderFallbackRefs: ["anthropic-vertex"],
}),
};

View File

@@ -23,8 +23,6 @@ vi.mock("./model-auth-env-vars.js", () => {
} as const;
return {
listKnownProviderEnvApiKeyNames: () => [...new Set(Object.values(candidates).flat())],
resolveProviderEnvApiKeyCandidates: () => candidates,
resolveProviderEnvAuthEvidence: () => ({}),
resolveProviderEnvAuthLookupMaps: () => ({
aliasMap: {},
envCandidateMap: candidates,

View File

@@ -30,8 +30,6 @@ vi.mock("./model-auth-env-vars.js", () => {
} as const;
return {
listKnownProviderEnvApiKeyNames: () => [...new Set(Object.values(candidates).flat())],
resolveProviderEnvApiKeyCandidates: () => candidates,
resolveProviderEnvAuthEvidence: () => ({}),
resolveProviderEnvAuthLookupMaps: () => ({
aliasMap: {},
envCandidateMap: candidates,

View File

@@ -17,8 +17,6 @@ vi.mock("../plugins/manifest-registry.js", () => ({
vi.mock("./model-auth-env-vars.js", () => ({
listKnownProviderEnvApiKeyNames: () => ["OPENAI_API_KEY"],
resolveProviderEnvApiKeyCandidates: () => ({ openai: ["OPENAI_API_KEY"] }),
resolveProviderEnvAuthEvidence: () => ({}),
resolveProviderEnvAuthLookupMaps: () => ({
aliasMap: {},
envCandidateMap: { openai: ["OPENAI_API_KEY"] },

View File

@@ -19,8 +19,6 @@ vi.mock("./provider-auth-aliases.js", () => ({
vi.mock("./model-auth-env-vars.js", () => ({
listKnownProviderEnvApiKeyNames: () => [],
resolveProviderEnvApiKeyCandidates: () => ({}),
resolveProviderEnvAuthEvidence: () => ({}),
resolveProviderEnvAuthLookupMaps: () => ({
aliasMap: {},
envCandidateMap: {},

View File

@@ -26,21 +26,16 @@ const pluginRegistryMocks = vi.hoisted(() => ({
}));
const envCandidateMocks = vi.hoisted(() => ({
resolveProviderEnvApiKeyCandidates: vi.fn(),
resolveProviderEnvAuthLookupMaps: vi.fn(),
}));
vi.mock("../../agents/model-auth-env-vars.js", async (importOriginal) => {
const actual = await importOriginal<typeof import("../../agents/model-auth-env-vars.js")>();
envCandidateMocks.resolveProviderEnvApiKeyCandidates.mockImplementation(
actual.resolveProviderEnvApiKeyCandidates,
);
envCandidateMocks.resolveProviderEnvAuthLookupMaps.mockImplementation(
actual.resolveProviderEnvAuthLookupMaps,
);
return {
...actual,
resolveProviderEnvApiKeyCandidates: envCandidateMocks.resolveProviderEnvApiKeyCandidates,
resolveProviderEnvAuthLookupMaps: envCandidateMocks.resolveProviderEnvAuthLookupMaps,
};
});
@@ -102,7 +97,6 @@ async function writeWorkspaceAuthEvidencePlugin(workspaceDir: string) {
describe("createModelListAuthIndex", () => {
beforeEach(() => {
envCandidateMocks.resolveProviderEnvApiKeyCandidates.mockClear();
envCandidateMocks.resolveProviderEnvAuthLookupMaps.mockClear();
pluginRegistryMocks.loadPluginRegistrySnapshotWithMetadata.mockClear();
});

View File

@@ -89,15 +89,6 @@ const mocks = vi.hoisted(() => {
}
return null;
}),
resolveProviderEnvApiKeyCandidates: vi.fn().mockReturnValue({
anthropic: ["ANTHROPIC_API_KEY"],
google: ["GEMINI_API_KEY", "GOOGLE_API_KEY"],
minimax: ["MINIMAX_API_KEY"],
"minimax-portal": ["MINIMAX_OAUTH_TOKEN", "MINIMAX_API_KEY"],
openai: ["OPENAI_OAUTH_TOKEN", "OPENAI_API_KEY"],
fal: ["FAL_KEY"],
}),
resolveProviderEnvAuthEvidence: vi.fn().mockReturnValue({}),
resolveProviderEnvAuthLookupMaps: vi.fn().mockReturnValue({
aliasMap: { "codex-cli": "openai" },
envCandidateMap: {
@@ -224,8 +215,6 @@ vi.mock("../../agents/model-auth.js", () => ({
}));
vi.mock("../../agents/model-auth-env-vars.js", () => ({
listProviderEnvAuthLookupKeys: mocks.listProviderEnvAuthLookupKeys,
resolveProviderEnvApiKeyCandidates: mocks.resolveProviderEnvApiKeyCandidates,
resolveProviderEnvAuthEvidence: mocks.resolveProviderEnvAuthEvidence,
resolveProviderEnvAuthLookupMaps: mocks.resolveProviderEnvAuthLookupMaps,
listKnownProviderEnvApiKeyNames: mocks.listKnownProviderEnvApiKeyNames,
}));
@@ -2024,18 +2013,22 @@ describe("modelsStatusCommand auth overview", () => {
it("includes auth-evidence-only providers in the auth overview", async () => {
const localRuntime = createRuntime();
const originalKeysImpl = mocks.listProviderEnvAuthLookupKeys.getMockImplementation();
const originalEvidenceImpl = mocks.resolveProviderEnvAuthEvidence.getMockImplementation();
const originalLookupImpl = mocks.resolveProviderEnvAuthLookupMaps.getMockImplementation();
const originalEnvImpl = mocks.resolveEnvApiKey.getMockImplementation();
mocks.listProviderEnvAuthLookupKeys.mockReturnValue(["workspace-cloud"]);
mocks.resolveProviderEnvAuthEvidence.mockReturnValue({
"workspace-cloud": [
{
type: "local-file-with-env",
credentialMarker: "workspace-cloud-local-credentials",
source: "workspace cloud credentials",
},
],
mocks.resolveProviderEnvAuthLookupMaps.mockReturnValue({
aliasMap: { "codex-cli": "openai" },
envCandidateMap: {},
authEvidenceMap: {
"workspace-cloud": [
{
type: "local-file-with-env",
credentialMarker: "workspace-cloud-local-credentials",
source: "workspace cloud credentials",
},
],
},
});
mocks.resolveEnvApiKey.mockImplementation(
(provider: string, _env?: NodeJS.ProcessEnv, options?: { workspaceDir?: string }) =>
@@ -2061,8 +2054,8 @@ describe("modelsStatusCommand auth overview", () => {
if (originalKeysImpl) {
mocks.listProviderEnvAuthLookupKeys.mockImplementation(originalKeysImpl);
}
if (originalEvidenceImpl) {
mocks.resolveProviderEnvAuthEvidence.mockImplementation(originalEvidenceImpl);
if (originalLookupImpl) {
mocks.resolveProviderEnvAuthLookupMaps.mockImplementation(originalLookupImpl);
}
if (originalEnvImpl) {
mocks.resolveEnvApiKey.mockImplementation(originalEnvImpl);