@stablekernel/opencode-bifrost 0.4.0 → 0.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/datasheet.test.ts +17 -0
- package/src/datasheet.ts +3 -0
- package/src/index.test.ts +19 -0
- package/src/index.ts +15 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stablekernel/opencode-bifrost",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.1",
|
|
4
4
|
"description": "OpenCode plugin that routes models through the Bifrost gateway, resolving per-project virtual keys via gateway-cli.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "src/index.ts",
|
package/src/datasheet.test.ts
CHANGED
|
@@ -54,6 +54,23 @@ describe("parseDatasheet", () => {
|
|
|
54
54
|
} satisfies SupplementalModel);
|
|
55
55
|
});
|
|
56
56
|
|
|
57
|
+
test("maps supports_image_input to image_input only when true", () => {
|
|
58
|
+
const out = parseDatasheet({
|
|
59
|
+
"fireworks_ai/accounts/fireworks/models/glm-5p3-flash": {
|
|
60
|
+
...glmFlash,
|
|
61
|
+
supports_image_input: true,
|
|
62
|
+
},
|
|
63
|
+
"fireworks_ai/accounts/fireworks/models/glm-5p2": {
|
|
64
|
+
...glmFlash,
|
|
65
|
+
supports_image_input: false,
|
|
66
|
+
},
|
|
67
|
+
});
|
|
68
|
+
expect(out).toHaveLength(2);
|
|
69
|
+
const byId = new Map(out.map((m) => [m.id, m]));
|
|
70
|
+
expect(byId.get("accounts/fireworks/models/glm-5p3-flash")?.image_input).toBe(true);
|
|
71
|
+
expect(byId.get("accounts/fireworks/models/glm-5p2")?.image_input).toBeUndefined();
|
|
72
|
+
});
|
|
73
|
+
|
|
57
74
|
test("drops non-chat entries, unknown providers, and rows without limits", () => {
|
|
58
75
|
const out = parseDatasheet({
|
|
59
76
|
"fireworks_ai/accounts/fireworks/models/qwen3-embedding-8b": {
|
package/src/datasheet.ts
CHANGED
|
@@ -35,6 +35,7 @@ export type DatasheetEntry = {
|
|
|
35
35
|
cache_read_input_token_cost?: number;
|
|
36
36
|
cache_write_input_token_cost?: number;
|
|
37
37
|
supports_reasoning?: boolean;
|
|
38
|
+
supports_image_input?: boolean;
|
|
38
39
|
};
|
|
39
40
|
|
|
40
41
|
/** A model in the same shape `gateway-cli models` emits (structural subset). */
|
|
@@ -52,6 +53,7 @@ export type SupplementalModel = {
|
|
|
52
53
|
cache_write: number;
|
|
53
54
|
};
|
|
54
55
|
reasoning?: boolean;
|
|
56
|
+
image_input?: boolean;
|
|
55
57
|
};
|
|
56
58
|
|
|
57
59
|
/** Datasheet provider prefixes whose entries this module understands. */
|
|
@@ -237,6 +239,7 @@ export function parseDatasheet(
|
|
|
237
239
|
}
|
|
238
240
|
: {}),
|
|
239
241
|
...(e.supports_reasoning === true ? { reasoning: true } : {}),
|
|
242
|
+
...(e.supports_image_input === true ? { image_input: true } : {}),
|
|
240
243
|
});
|
|
241
244
|
}
|
|
242
245
|
return out;
|
package/src/index.test.ts
CHANGED
|
@@ -309,6 +309,25 @@ describe("datasheet supplement gate", () => {
|
|
|
309
309
|
});
|
|
310
310
|
});
|
|
311
311
|
|
|
312
|
+
describe("image input", () => {
|
|
313
|
+
test("declares image modalities + attachment when the CLI advertises it", () => {
|
|
314
|
+
// OpenCode computes input.image and attachment from the config model and
|
|
315
|
+
// DEFAULTS BOTH TO FALSE for plugin-provided models. Without these
|
|
316
|
+
// fields OpenCode strips image parts for every Bifrost model.
|
|
317
|
+
const models = toConfigModels({ models: [{ ...NOVA, image_input: true }] });
|
|
318
|
+
const m = models["bedrock/amazon.nova-lite-v1:0"];
|
|
319
|
+
expect(m.modalities?.input).toContain("image");
|
|
320
|
+
expect(m.attachment).toBe(true);
|
|
321
|
+
});
|
|
322
|
+
|
|
323
|
+
test("stays silent for a text-only model so OpenCode's false default holds", () => {
|
|
324
|
+
const models = toConfigModels({ models: [NOVA] });
|
|
325
|
+
const m = models["bedrock/amazon.nova-lite-v1:0"];
|
|
326
|
+
expect(m.modalities).toBeUndefined();
|
|
327
|
+
expect(m.attachment).toBeUndefined();
|
|
328
|
+
});
|
|
329
|
+
});
|
|
330
|
+
|
|
312
331
|
describe("unpriced models", () => {
|
|
313
332
|
test("omits cost entirely rather than declaring zero", () => {
|
|
314
333
|
// A zeroed rate card renders as free, which is worse than blank.
|
package/src/index.ts
CHANGED
|
@@ -59,6 +59,12 @@ type ConfigModel = {
|
|
|
59
59
|
reasoning?: boolean;
|
|
60
60
|
/** Named per-effort variants; each body is a provider-options overlay. */
|
|
61
61
|
variants?: Record<string, { reasoningEffort: string }>;
|
|
62
|
+
/** Whether the model accepts file/image attachments. OpenCode defaults
|
|
63
|
+
* this to false for config-provided models when absent. */
|
|
64
|
+
attachment?: boolean;
|
|
65
|
+
/** Input/output modalities. OpenCode reads input.image from here to
|
|
66
|
+
* decide whether image parts may be sent; absent defaults to false. */
|
|
67
|
+
modalities?: { input: string[] };
|
|
62
68
|
/** Provider options passed on every request (e.g. a seeded default
|
|
63
69
|
* reasoningEffort); a variant or agent override replaces these. */
|
|
64
70
|
options?: Record<string, unknown>;
|
|
@@ -85,6 +91,10 @@ export type CliModel = {
|
|
|
85
91
|
reasoning?: boolean;
|
|
86
92
|
reasoning_efforts?: string[];
|
|
87
93
|
reasoning_budget_min?: number;
|
|
94
|
+
/** True when the model accepts image content blocks (from the catalog's
|
|
95
|
+
* modalities.input). Absent means text-only, so a harness never guesses a
|
|
96
|
+
* capability from silence. */
|
|
97
|
+
image_input?: boolean;
|
|
88
98
|
};
|
|
89
99
|
|
|
90
100
|
export type CliModels = { models?: CliModel[] };
|
|
@@ -396,6 +406,11 @@ export function toConfigModels(
|
|
|
396
406
|
name: m.cost ? m.name : `${m.name}${UNPRICED_SUFFIX}`,
|
|
397
407
|
limit: { context: m.context_window, output: m.max_output_tokens },
|
|
398
408
|
...(m.cost ? { cost: m.cost } : {}),
|
|
409
|
+
// OpenCode defaults input.image and attachment to false for config
|
|
410
|
+
// models; both must come from the CLI or images are stripped.
|
|
411
|
+
...(m.image_input
|
|
412
|
+
? { attachment: true, modalities: { input: ["text", "image"] } }
|
|
413
|
+
: {}),
|
|
399
414
|
};
|
|
400
415
|
if (m.reasoning) {
|
|
401
416
|
entry.reasoning = true;
|