opencode-statboard 2.10.17 → 2.10.19

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.
Files changed (3) hide show
  1. package/package.json +1 -1
  2. package/pricing.js +109 -13
  3. package/fix-dup.py +0 -28
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-statboard",
3
- "version": "2.10.17",
3
+ "version": "2.10.19",
4
4
  "description": "Real-time dashboard for opencode token usage and cost statistics",
5
5
  "main": "server.js",
6
6
  "bin": {
package/pricing.js CHANGED
@@ -9,7 +9,8 @@
9
9
  // -contributor-free) or duplicated provider prefix -> kind 'sibling'
10
10
  // 3. same base name under provider 'opencode' -> kind 'proxy'
11
11
  // 4. same base name anywhere else (cheapest nonzero) -> kind 'proxy'
12
- // 5. nothing in the catalog -> null (NOT priced;
12
+ // 5. manual FREE_MODEL_MAPPING for free models without automatic match
13
+ // 6. nothing in the catalog -> null (NOT priced;
13
14
  // inventing a number here is how a $0 model turned into $212 of fake
14
15
  // savings). Callers must show '—' and can disclose the unpriced rows.
15
16
  //
@@ -19,6 +20,83 @@
19
20
  const fs = require('fs');
20
21
  const path = require('path');
21
22
 
23
+ const stripFree = (m) => String(m).replace(/-contributor-free$/, '').replace(/-free$/, '').replace(/:free$/, '');
24
+
25
+ // Manual paid-model mapping for free opencode models that have no automatic
26
+ // sibling/proxy match. Key: free model name (with or without provider prefix),
27
+ // value: paid model full name (provider/model from cache).
28
+ const FREE_MODEL_MAPPING = {
29
+ 'opencode/space-bunny-free': 'pioneer/mistralai/Mistral-7B-Instruct-v0.3',
30
+ 'opencode/beam-free': 'openrouter/xiaomi/mimo-v2.5',
31
+ 'opencode/fledge-alpha-free': 'pioneer/mistralai/Mistral-7B-Instruct-v0.3',
32
+ 'opencode/grok-code': 'vercel/spacexai/grok-4.1-fast-reasoning',
33
+ 'opencode/laguna-s-2.1-free': 'nano-gpt/poolside/laguna-s-2.1',
34
+ 'opencode/x-preview-f-free': 'vercel/spacexai/grok-4.1-fast-reasoning',
35
+ 'opencode/nemotron-3.5-lightning-free': 'nano-gpt/nvidia/nemotron-3.5-lightning',
36
+ 'opencode/big-pickle': 'vercel/spacexai/grok-4.1-fast-reasoning',
37
+ 'opencode/ling-3.0-flash-fin-free': 'empiriolabs/qwen3-8-flash',
38
+ 'opencode/mimo-v2.5-free': 'openrouter/xiaomi/mimo-v2.5',
39
+ 'opencode/nemotron-3-super-free': 'openrouter/nvidia/nemotron-3-super-120b-a12b',
40
+ 'opencode/nemotron-3-ultra-free': 'openrouter/nvidia/nemotron-3-ultra-550b-a55b',
41
+ 'opencode/glm-4.7-free': 'openrouter/z-ai/glm-4.7',
42
+ 'opencode/glm-5-free': 'openrouter/z-ai/glm-5',
43
+ 'opencode/mimo-v2-flash-free': 'openrouter/xiaomi/mimo-v2-flash',
44
+ 'opencode/qwen3.6-plus-free': 'nano-gpt/qwen/qwen3.6-plus',
45
+ 'opencode/mimo-v2-omni-free': 'openrouter/xiaomi/mimo-v2-omni',
46
+ 'opencode/mimo-v2-pro-free': 'openrouter/xiaomi/mimo-v2-pro',
47
+ 'opencode/ling-3.0-tiny-free': 'empiriolabs/qwen3-8-flash',
48
+ 'opencode/trinity-large-preview-free': 'vercel/spacexai/grok-4.1-fast-reasoning',
49
+ 'opencode/nemotron-3.5-super-vl-free': 'openrouter/nvidia/nemotron-3.5-super-vl',
50
+ 'opencode/ling-2.6-flash-free': 'empiriolabs/qwen3-8-flash',
51
+ 'opencode/minimax-m2.5-free': 'openrouter/minimax/minimax-m2.5',
52
+ 'opencode/minimax-m3-free': 'openrouter/minimax/minimax-m3',
53
+ 'opencode/muse-spark-1.2-contributor-free': 'nano-gpt/meta/muse-spark-1.2',
54
+ 'opencode/muse-spark-1.3-contributor-free': 'bothub/muse-spark-1.3-contributor',
55
+ 'opencode/deepseek-v4-flash-free': 'openrouter/deepseek/deepseek-v4-flash',
56
+ 'opencode/deepseek-v4.1-flash-free': 'openrouter/deepseek/deepseek-v4.1-flash',
57
+ 'opencode/hy3-free': 'openrouter/tencent/hy3',
58
+ 'opencode/glm-5.3-flash-free': 'openrouter/z-ai/glm-5.3-flash',
59
+ 'opencode/nemotron-3.5-super-vl-free': 'openrouter/nvidia/nemotron-3.5-super-vl',
60
+ 'opencode/beam-free': 'openrouter/xiaomi/mimo-v2.5',
61
+ 'opencode/space-bunny-free': 'pioneer/mistralai/Mistral-7B-Instruct-v0.3',
62
+ 'opencode/fledge-alpha-free': 'pioneer/mistralai/Mistral-7B-Instruct-v0.3',
63
+ 'opencode/big-pickle': 'vercel/spacexai/grok-4.1-fast-reasoning',
64
+ 'opencode/grok-code': 'vercel/spacexai/grok-4.1-fast-reasoning',
65
+ 'opencode/x-preview-f-free': 'vercel/spacexai/grok-4.1-fast-reasoning',
66
+ 'opencode/nemotron-3.5-lightning-free': 'nano-gpt/nvidia/nemotron-3.5-lightning',
67
+ 'opencode/big-pickle': 'vercel/spacexai/grok-4.1-fast-reasoning',
68
+ 'opencode/ling-3.0-flash-fin-free': 'empiriolabs/qwen3-8-flash',
69
+ 'opencode/ling-3.0-tiny-free': 'empiriolabs/qwen3-8-flash',
70
+ 'opencode/ling-2.6-flash-free': 'empiriolabs/qwen3-8-flash',
71
+ 'opencode/trinity-large-preview-free': 'vercel/spacexai/grok-4.1-fast-reasoning',
72
+ 'opencode/mimo-v2.5-free': 'openrouter/xiaomi/mimo-v2.5',
73
+ 'opencode/mimo-v2-flash-free': 'openrouter/xiaomi/mimo-v2-flash',
74
+ 'opencode/mimo-v2-omni-free': 'openrouter/xiaomi/mimo-v2-omni',
75
+ 'opencode/mimo-v2-pro-free': 'openrouter/xiaomi/mimo-v2-pro',
76
+ 'opencode/qwen3.6-plus-free': 'nano-gpt/qwen/qwen3.6-plus',
77
+ 'opencode/glm-4.7-free': 'openrouter/z-ai/glm-4.7',
78
+ 'opencode/glm-5-free': 'openrouter/z-ai/glm-5',
79
+ 'opencode/hy3-free': 'openrouter/tencent/hy3',
80
+ 'opencode/glm-5.3-flash-free': 'openrouter/z-ai/glm-5.3-flash',
81
+ 'opencode/minimax-m2.5-free': 'openrouter/minimax/minimax-m2.5',
82
+ 'opencode/minimax-m3-free': 'openrouter/minimax/minimax-m3',
83
+ 'opencode/muse-spark-1.2-contributor-free': 'nano-gpt/meta/muse-spark-1.2',
84
+ 'opencode/muse-spark-1.3-contributor-free': 'bothub/muse-spark-1.3-contributor',
85
+ 'opencode/deepseek-v4-flash-free': 'openrouter/deepseek/deepseek-v4-flash',
86
+ 'opencode/deepseek-v4.1-flash-free': 'openrouter/deepseek/deepseek-v4.1-flash',
87
+ 'opencode/hy3-free': 'openrouter/tencent/hy3',
88
+ 'opencode/glm-5.3-flash-free': 'openrouter/z-ai/glm-5.3-flash',
89
+ 'opencode/nemotron-3.5-super-vl-free': 'openrouter/nvidia/nemotron-3.5-super-vl',
90
+ };
91
+
92
+ function getFreeModelMapping(provider, model) {
93
+ const key = `${provider}/${model}`;
94
+ const mapped = FREE_MODEL_MAPPING[key] || FREE_MODEL_MAPPING[model];
95
+ if (!mapped) return null;
96
+ const [mp, ...mm] = mapped.split('/');
97
+ return { provider: mp, model: mm.join('/') };
98
+ }
99
+
22
100
  function catalogCandidates() {
23
101
  const homes = [process.env.USERPROFILE, process.env.HOME].filter(Boolean);
24
102
  const out = [];
@@ -52,18 +130,14 @@ function entry(data, provider, model) {
52
130
  return nonzero(c) ? { input: c.input || 0, output: c.output || 0, cacheRead: c.cache_read || 0 } : null;
53
131
  }
54
132
 
55
- const stripFree = (m) => String(m).replace(/-contributor-free$/, '').replace(/-free$/, '').replace(/:free$/, '');
56
-
57
133
  // Map a usage model (provider/model as recorded in the DB) to paid rates.
58
- // Returns { input, output, cacheRead, source, kind } or null when the catalog
59
- // has no comparable paid listing at all.
60
134
  function priceFor(provider, model) {
61
135
  const cat = loadCatalog();
62
136
  if (!cat.data) return null;
63
137
  const data = cat.data;
64
138
  provider = provider || 'unknown';
65
139
  model = model || 'unknown';
66
- if (model === 'unknown') return null; // unattributed usage: never invent a rate
140
+ if (model === 'unknown') return null;
67
141
 
68
142
  const mk = (p, m, kind) => {
69
143
  const r = entry(data, p, m);
@@ -73,10 +147,7 @@ function priceFor(provider, model) {
73
147
  let r = mk(provider, model, 'exact');
74
148
  if (r) return r;
75
149
 
76
- // Free suffixes and a provider prefix duplicated inside the model id
77
- // (opencode records nvidia/nvidia/nemotron-... on some sessions). The plain
78
- // base is always kept: a model that is free at ITS provider (cost 0) may
79
- // still have a paid listing elsewhere (e.g. nvidia/z-ai/glm-5.3-flash).
150
+ // Free suffixes
80
151
  const bases = [];
81
152
  const deDup = model.startsWith(`${provider}/`) ? model.slice(provider.length + 1) : null;
82
153
  for (const b of [stripFree(model), deDup && stripFree(deDup), deDup, model]) {
@@ -91,9 +162,26 @@ function priceFor(provider, model) {
91
162
  r = mk('opencode', b, 'proxy');
92
163
  if (r) return r;
93
164
  }
94
- // Any provider, cheapest nonzero listing for the same base name. Cheapest
95
- // keeps the estimate conservative (it understates savings, never inflates).
96
- for (const b of bases) {
165
+
166
+ // Any provider, cheapest nonzero listing for the same base name
167
+ const allBases = [...bases];
168
+ if (model !== bases[0] && !allBases.includes(model)) allBases.push(model);
169
+ const providerModel = `${provider}/${model}`;
170
+ if (!allBases.includes(providerModel)) allBases.push(providerModel);
171
+ const openrouterModel = `openrouter/${model}`;
172
+ if (!allBases.includes(openrouterModel)) allBases.push(openrouterModel);
173
+ const openrouterProviderModel = `openrouter/${provider}/${model}`;
174
+ if (!allBases.includes(openrouterProviderModel)) allBases.push(openrouterProviderModel);
175
+ if (provider === 'openrouter' && !model.includes('/')) {
176
+ const subProviders = ['reflection', 'nvidia', 'google', 'anthropic', 'meta', 'mistral', 'cohere', 'mistralai'];
177
+ for (const sub of subProviders) {
178
+ const subModel = `${sub}/${model}`;
179
+ if (!allBases.includes(subModel)) allBases.push(subModel);
180
+ const openrouterSubModel = `openrouter/${sub}/${model}`;
181
+ if (!allBases.includes(openrouterSubModel)) allBases.push(openrouterSubModel);
182
+ }
183
+ }
184
+ for (const b of allBases) {
97
185
  let best = null;
98
186
  for (const pid of Object.keys(data).sort()) {
99
187
  const e = entry(data, pid, b);
@@ -107,6 +195,14 @@ function priceFor(provider, model) {
107
195
  return { ...rates, source: `${pid}/${b}`, kind: 'proxy' };
108
196
  }
109
197
  }
198
+
199
+ // Check manual free model mapping before final null return
200
+ const freeMapping = getFreeModelMapping(provider, model);
201
+ if (freeMapping) {
202
+ const r2 = mk(freeMapping.provider, freeMapping.model, 'proxy');
203
+ if (r2) return r2;
204
+ }
205
+
110
206
  return null;
111
207
  }
112
208
 
package/fix-dup.py DELETED
@@ -1,28 +0,0 @@
1
- c = open('tui-dashboard.js', encoding='utf-8').read()
2
-
3
- # Find the two renderChart declarations
4
- first = c.find(' const renderChart = (data, label, color, maxVal) => {')
5
- second = c.find(' const renderChart = (data, label, color, maxVal) => {', first + 1)
6
-
7
- # Show context around first
8
- print("First renderChart at line:", c[:first].count('\n') + 1)
9
- print("Second renderChart at line:", c[:second].count('\n') + 1)
10
-
11
- # The first renderChart ends at the semicolon + blank line before "const maxInOut"
12
- # Find the line after the first closing of renderChart function
13
- # The pattern: " return lines.join('\\n');\n };" appears twice
14
- marker = " return lines.join('\\n');\n };"
15
- first_marker = c.find(marker, first)
16
- second_marker = c.find(marker, first_marker + 1)
17
-
18
- print("First marker at line:", c[:first_marker].count('\n') + 1)
19
-
20
- # Remove everything from first renderChart to second renderChart (inclusive of first)
21
- # We want to keep from first renderChart line to the line before second renderChart
22
- old_block = c[first:first_marker + len(marker)]
23
- print("Block to remove length:", len(old_block))
24
- print("Block preview:", old_block[:200])
25
-
26
- # Check what's between
27
- between_preview = c[first_marker + len(marker):second][:200]
28
- print("Between:", repr(between_preview))