Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,10 @@ export async function CrofaiPlugin() {
// second pass, not plugin-returned model variants).
config: async (config) => {
config.provider = config.provider || {};
// Preserve any pre-existing user config (whitelist, blacklist, options, etc.)
// before setting our provider definition fields.
config.provider.crofai = {
...config.provider.crofai,
id: PROVIDER_ID,
name: "CrofAI",
npm: "@ai-sdk/openai-compatible",
Expand Down
40 changes: 40 additions & 0 deletions test/plugin.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,46 @@ describe("config hook", () => {
assert.equal(cfg.provider.crofai.id, "crofai");
});

it("preserves user-defined whitelist, blacklist, and options on the crofai provider", async () => {
const hooks = await CrofaiPlugin();
const cfg = {
provider: {
crofai: {
whitelist: ["deepseek-v4-pro", "kimi-k2.6"],
blacklist: ["some-model-i-dont-want"],
options: { timeout: 300000 },
},
},
};
await hooks.config(cfg);

const p = cfg.provider.crofai;
assert.deepEqual(p.whitelist, ["deepseek-v4-pro", "kimi-k2.6"], "whitelist should survive config hook");
assert.deepEqual(p.blacklist, ["some-model-i-dont-want"], "blacklist should survive config hook");
assert.deepEqual(p.options, { timeout: 300000 }, "options should survive config hook");
// Core provider fields should still be set
assert.equal(p.id, "crofai");
assert.equal(p.npm, "@ai-sdk/openai-compatible");
});

it("allows overriding provider options while preserving whitelist", async () => {
const hooks = await CrofaiPlugin();
const cfg = {
provider: {
crofai: {
whitelist: ["kimi-k2.6"],
},
},
};
await hooks.config(cfg);

assert.deepEqual(
cfg.provider.crofai.whitelist,
["kimi-k2.6"],
"whitelist alone should survive the config hook",
);
});

it("injects all models from cache with full config data", async () => {
const cachePath = getCachePath();
const cacheDir = join(cachePath, "..");
Expand Down