@stablekernel/opencode-bifrost 0.5.1 → 0.5.2

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stablekernel/opencode-bifrost",
3
- "version": "0.5.1",
3
+ "version": "0.5.2",
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",
@@ -71,6 +71,43 @@ describe("parseDatasheet", () => {
71
71
  expect(byId.get("accounts/fireworks/models/glm-5p2")?.image_input).toBeUndefined();
72
72
  });
73
73
 
74
+ test("maps supports_vision to image_input — the upstream field name (1570 rows vs 8 for supports_image_input)", () => {
75
+ const out = parseDatasheet({
76
+ "fireworks_ai/accounts/fireworks/models/deepseek-v4-flash-vision-exp": {
77
+ ...glmFlash,
78
+ supports_vision: true,
79
+ },
80
+ "fireworks_ai/accounts/fireworks/models/deepseek-v4-flash": {
81
+ ...glmFlash,
82
+ supports_vision: false,
83
+ },
84
+ });
85
+ expect(out).toHaveLength(2);
86
+ const byId = new Map(out.map((m) => [m.id, m]));
87
+ expect(byId.get("accounts/fireworks/models/deepseek-v4-flash-vision-exp")?.image_input).toBe(true);
88
+ expect(byId.get("accounts/fireworks/models/deepseek-v4-flash")?.image_input).toBeUndefined();
89
+ });
90
+
91
+ test("falls back to max_input_tokens when context_length is absent — upstream rows never carry context_length", () => {
92
+ const { context_length, ...upstreamShape } = glmFlash;
93
+ const out = parseDatasheet({
94
+ "fireworks_ai/accounts/fireworks/models/glm-5p3-flash": upstreamShape,
95
+ });
96
+ expect(out).toHaveLength(1);
97
+ expect(out[0].context_window).toBe(upstreamShape.max_input_tokens);
98
+ });
99
+
100
+ test("reads cache_write from cache_creation_input_token_cost — the upstream field name (503 rows vs 0)", () => {
101
+ const out = parseDatasheet({
102
+ "fireworks_ai/accounts/fireworks/models/glm-5p3-flash": {
103
+ ...glmFlash,
104
+ cache_creation_input_token_cost: 0.00000015,
105
+ },
106
+ });
107
+ expect(out).toHaveLength(1);
108
+ expect(out[0].cost?.cache_write).toBe(0.15);
109
+ });
110
+
74
111
  test("drops non-chat entries, unknown providers, and rows without limits", () => {
75
112
  const out = parseDatasheet({
76
113
  "fireworks_ai/accounts/fireworks/models/qwen3-embedding-8b": {
@@ -81,6 +118,7 @@ describe("parseDatasheet", () => {
81
118
  "fireworks_ai/accounts/fireworks/models/no-limits": {
82
119
  ...glmFlash,
83
120
  context_length: undefined,
121
+ max_input_tokens: undefined,
84
122
  },
85
123
  "fireworks_ai/accounts/fireworks/models/no-max-out": {
86
124
  ...glmFlash,
package/src/datasheet.ts CHANGED
@@ -33,8 +33,15 @@ export type DatasheetEntry = {
33
33
  input_cost_per_token?: number;
34
34
  output_cost_per_token?: number;
35
35
  cache_read_input_token_cost?: number;
36
+ // Upstream rows name the cache-write rate `cache_creation_input_token_cost`
37
+ // (503 rows); the `cache_write_…` spelling appears on zero rows and is
38
+ // kept for symmetry with Bifrost's own pricing-card vocabulary.
36
39
  cache_write_input_token_cost?: number;
40
+ cache_creation_input_token_cost?: number;
37
41
  supports_reasoning?: boolean;
42
+ // Upstream rows express image capability as `supports_vision` (1,570
43
+ // rows); `supports_image_input` appears on only 8. Either true counts.
44
+ supports_vision?: boolean;
38
45
  supports_image_input?: boolean;
39
46
  };
40
47
 
@@ -210,8 +217,16 @@ export function parseDatasheet(
210
217
  if (!prefix) continue;
211
218
  const id = key.slice(prefix.length);
212
219
  if (!id) continue;
220
+ // Upstream rows never carry `context_length` (0 of 4,336); they state
221
+ // `max_input_tokens` instead. Either sets the context window.
222
+ const contextLength =
223
+ typeof e.context_length === "number"
224
+ ? e.context_length
225
+ : typeof e.max_input_tokens === "number"
226
+ ? e.max_input_tokens
227
+ : undefined;
213
228
  if (
214
- typeof e.context_length !== "number" ||
229
+ typeof contextLength !== "number" ||
215
230
  typeof e.max_output_tokens !== "number"
216
231
  ) {
217
232
  continue;
@@ -224,7 +239,7 @@ export function parseDatasheet(
224
239
  id,
225
240
  name:
226
241
  typeof e.base_model === "string" && e.base_model ? e.base_model : slug,
227
- context_window: e.context_length,
242
+ context_window: contextLength,
228
243
  max_output_tokens: e.max_output_tokens,
229
244
  limits_source: "datasheet",
230
245
  ...(priced
@@ -234,12 +249,17 @@ export function parseDatasheet(
234
249
  input: perMillion(e.input_cost_per_token),
235
250
  output: perMillion(e.output_cost_per_token),
236
251
  cache_read: perMillion(e.cache_read_input_token_cost),
237
- cache_write: perMillion(e.cache_write_input_token_cost),
252
+ cache_write: perMillion(
253
+ e.cache_write_input_token_cost ??
254
+ e.cache_creation_input_token_cost,
255
+ ),
238
256
  },
239
257
  }
240
258
  : {}),
241
259
  ...(e.supports_reasoning === true ? { reasoning: true } : {}),
242
- ...(e.supports_image_input === true ? { image_input: true } : {}),
260
+ ...(e.supports_image_input === true || e.supports_vision === true
261
+ ? { image_input: true }
262
+ : {}),
243
263
  });
244
264
  }
245
265
  return out;