Repository navigation
Commit ccf3354
feat(models): dynamic open-source model catalog from CC provider API (#8)
* feat(models): dynamic open-source model catalog from CC provider API
Replace the fully hand-maintained models.json catalog with a hybrid:
the CC provider /provider/v1/models endpoint is now the source of truth
for the model list, display names, and context windows (1h TTL cache,
modeled on fetchLatestCliVersion), while models.json keeps what the API
never returns — aliases, reasoning efforts, max output tokens — and
doubles as the offline fallback.
Closed models (claude-*, gpt-*, google/* and other closed orgs) are
filtered out so the proxy only exposes open-source models available on
the GO plan. New CC models now appear without a proxy release.
- new src/translate/catalog.ts: merge (static-first order preserves the
default model), isClosedModel, TTL + inflight-deduped refreshCatalog
- models.ts/server.ts/opencode.ts read the live catalog; opencode setup
fetches it when a key is available (env or saved auth)
- models.json: closedModelOrgs blocklist + metadata/aliases for the new
open models (GLM-5.3, Qwen 3.8 family, Grok 4.6, Hy4, Muse Spark,
Fugu, Laguna, free MiniMax variants, ...)
Co-Authored-By: Claude <noreply@anthropic.com>
* refactor(catalog): review cleanup — drop dead fetchModelList, dedupe helpers
Post-review of PR #8:
- remove fetchModelList (no remaining callers after server.ts migrated
to refreshCatalog)
- extract displayNameFor() to collapse the three display-name fallback
chains in catalog.ts
- share the URL-filtering CC models fetch mock between test files via
tests/helpers.ts
Co-Authored-By: Claude <noreply@anthropic.com>
* test(catalog): cover TTL expiry, retired models, malformed payloads
Closes the four gaps flagged in the review of PR #8:
- TTL expiry actually elapses and refetches (Date.now spy)
- static entries survive when the API no longer lists them (retired
upstream models keep static name/context, source: "static")
- malformed payloads: data:null keeps the catalog; id-less and null
items are skipped instead of discarding the whole refresh (also
hardened the filter in catalog.ts for this); null context_length
falls back to 128k
- resolveAnthropicModel keeps the claude-* default pinned to the static
first entry even when the API returns a reordered list
166 tests pass, typecheck clean.
Co-Authored-By: Claude <noreply@anthropic.com>
* fix(catalog): absorb duplicate ids within the API model list
Self-review pass: an API payload listing the same API-only id twice
would append it twice to the catalog (the `seen` set only tracked
static ids). Now the second loop adds to `seen` as well; first
occurrence wins. Regression test included.
Co-Authored-By: Claude <noreply@anthropic.com>
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent 2dbd904 commit ccf3354
10 files changed
Lines changed: 570 additions & 64 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
| 30 | + | |
30 | 31 | | |
31 | 32 | | |
32 | 33 | | |
| |||
83 | 84 | | |
84 | 85 | | |
85 | 86 | | |
86 | | - | |
| 87 | + | |
87 | 88 | | |
88 | 89 | | |
89 | 90 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
| 2 | + | |
2 | 3 | | |
3 | 4 | | |
4 | 5 | | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
5 | 9 | | |
6 | 10 | | |
7 | 11 | | |
8 | 12 | | |
9 | 13 | | |
10 | 14 | | |
| 15 | + | |
| 16 | + | |
11 | 17 | | |
12 | 18 | | |
13 | 19 | | |
14 | 20 | | |
15 | 21 | | |
16 | 22 | | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
17 | 26 | | |
18 | 27 | | |
| 28 | + | |
19 | 29 | | |
20 | 30 | | |
21 | 31 | | |
22 | 32 | | |
23 | 33 | | |
24 | 34 | | |
| 35 | + | |
25 | 36 | | |
26 | 37 | | |
27 | 38 | | |
28 | | - | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
29 | 48 | | |
30 | 49 | | |
31 | 50 | | |
32 | 51 | | |
33 | 52 | | |
34 | 53 | | |
35 | 54 | | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
36 | 61 | | |
37 | 62 | | |
38 | 63 | | |
| |||
41 | 66 | | |
42 | 67 | | |
43 | 68 | | |
| 69 | + | |
44 | 70 | | |
45 | 71 | | |
| 72 | + | |
46 | 73 | | |
47 | 74 | | |
48 | 75 | | |
| |||
56 | 83 | | |
57 | 84 | | |
58 | 85 | | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
59 | 92 | | |
60 | 93 | | |
61 | 94 | | |
62 | 95 | | |
63 | | - | |
| 96 | + | |
| 97 | + | |
64 | 98 | | |
65 | | - | |
| 99 | + | |
66 | 100 | | |
| 101 | + | |
67 | 102 | | |
68 | 103 | | |
69 | 104 | | |
| |||
72 | 107 | | |
73 | 108 | | |
74 | 109 | | |
| 110 | + | |
| 111 | + | |
75 | 112 | | |
76 | 113 | | |
77 | 114 | | |
78 | 115 | | |
79 | 116 | | |
80 | | - | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
81 | 128 | | |
82 | 129 | | |
83 | 130 | | |
84 | 131 | | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
85 | 135 | | |
86 | 136 | | |
87 | 137 | | |
88 | 138 | | |
89 | 139 | | |
90 | 140 | | |
| 141 | + | |
| 142 | + | |
91 | 143 | | |
92 | 144 | | |
93 | 145 | | |
94 | 146 | | |
95 | 147 | | |
96 | 148 | | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
97 | 152 | | |
98 | 153 | | |
| 154 | + | |
99 | 155 | | |
100 | 156 | | |
101 | 157 | | |
102 | 158 | | |
103 | 159 | | |
104 | 160 | | |
| 161 | + | |
105 | 162 | | |
106 | 163 | | |
107 | 164 | | |
108 | | - | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
109 | 174 | | |
110 | 175 | | |
111 | 176 | | |
112 | 177 | | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
113 | 181 | | |
114 | 182 | | |
115 | 183 | | |
116 | 184 | | |
117 | 185 | | |
118 | 186 | | |
| 187 | + | |
| 188 | + | |
119 | 189 | | |
120 | 190 | | |
121 | 191 | | |
122 | 192 | | |
123 | 193 | | |
124 | 194 | | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
125 | 198 | | |
126 | 199 | | |
| 200 | + | |
127 | 201 | | |
128 | 202 | | |
129 | 203 | | |
130 | 204 | | |
131 | 205 | | |
132 | 206 | | |
| 207 | + | |
133 | 208 | | |
134 | 209 | | |
135 | 210 | | |
136 | | - | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
137 | 220 | | |
138 | 221 | | |
139 | 222 | | |
140 | 223 | | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
141 | 227 | | |
| 228 | + | |
142 | 229 | | |
143 | 230 | | |
144 | 231 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
11 | | - | |
| 11 | + | |
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| |||
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
29 | | - | |
30 | 29 | | |
31 | 30 | | |
32 | | - | |
33 | | - | |
34 | | - | |
35 | | - | |
36 | 31 | | |
37 | 32 | | |
38 | 33 | | |
| |||
251 | 246 | | |
252 | 247 | | |
253 | 248 | | |
254 | | - | |
| 249 | + | |
| 250 | + | |
255 | 251 | | |
256 | | - | |
257 | | - | |
| 252 | + | |
| 253 | + | |
258 | 254 | | |
259 | | - | |
| 255 | + | |
260 | 256 | | |
261 | 257 | | |
262 | 258 | | |
263 | 259 | | |
264 | 260 | | |
265 | 261 | | |
266 | | - | |
267 | | - | |
| 262 | + | |
| 263 | + | |
268 | 264 | | |
269 | 265 | | |
270 | 266 | | |
271 | 267 | | |
272 | 268 | | |
273 | 269 | | |
274 | 270 | | |
275 | | - | |
| 271 | + | |
276 | 272 | | |
277 | 273 | | |
278 | 274 | | |
| |||
586 | 582 | | |
587 | 583 | | |
588 | 584 | | |
589 | | - | |
| 585 | + | |
| 586 | + | |
590 | 587 | | |
591 | | - | |
592 | | - | |
593 | | - | |
594 | | - | |
595 | | - | |
596 | | - | |
597 | | - | |
| 588 | + | |
| 589 | + | |
| 590 | + | |
598 | 591 | | |
599 | 592 | | |
600 | 593 | | |
| |||
0 commit comments