CLI: reuse OpenRouter credentials
This commit is contained in:
committed by
Peter Steinberger
parent
b6982236a6
commit
7890bd7369
@@ -9,8 +9,11 @@ import {
|
||||
applyAuthProfileConfig,
|
||||
applyMinimaxApiConfig,
|
||||
applyMinimaxApiProviderConfig,
|
||||
applyOpenrouterConfig,
|
||||
applyOpenrouterProviderConfig,
|
||||
applyOpencodeZenConfig,
|
||||
applyOpencodeZenProviderConfig,
|
||||
OPENROUTER_DEFAULT_MODEL_REF,
|
||||
writeOAuthCredentials,
|
||||
} from "./onboard-auth.js";
|
||||
|
||||
@@ -301,3 +304,48 @@ describe("applyOpencodeZenConfig", () => {
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
||||
describe("applyOpenrouterProviderConfig", () => {
|
||||
it("adds allowlist entry for the default model", () => {
|
||||
const cfg = applyOpenrouterProviderConfig({});
|
||||
const models = cfg.agents?.defaults?.models ?? {};
|
||||
expect(Object.keys(models)).toContain(OPENROUTER_DEFAULT_MODEL_REF);
|
||||
});
|
||||
|
||||
it("preserves existing alias for the default model", () => {
|
||||
const cfg = applyOpenrouterProviderConfig({
|
||||
agents: {
|
||||
defaults: {
|
||||
models: {
|
||||
[OPENROUTER_DEFAULT_MODEL_REF]: { alias: "Router" },
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
expect(
|
||||
cfg.agents?.defaults?.models?.[OPENROUTER_DEFAULT_MODEL_REF]?.alias,
|
||||
).toBe("Router");
|
||||
});
|
||||
});
|
||||
|
||||
describe("applyOpenrouterConfig", () => {
|
||||
it("sets correct primary model", () => {
|
||||
const cfg = applyOpenrouterConfig({});
|
||||
expect(cfg.agents?.defaults?.model?.primary).toBe(
|
||||
OPENROUTER_DEFAULT_MODEL_REF,
|
||||
);
|
||||
});
|
||||
|
||||
it("preserves existing model fallbacks", () => {
|
||||
const cfg = applyOpenrouterConfig({
|
||||
agents: {
|
||||
defaults: {
|
||||
model: { fallbacks: ["anthropic/claude-opus-4-5"] },
|
||||
},
|
||||
},
|
||||
});
|
||||
expect(cfg.agents?.defaults?.model?.fallbacks).toEqual([
|
||||
"anthropic/claude-opus-4-5",
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user