@clagentic/console 1.8.0 → 1.9.0-beta.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/lib/build-sha.json +2 -2
- package/lib/generated/claude-model-catalog.json +180 -0
- package/lib/model-catalog.js +202 -0
- package/lib/model-context-windows.js +9 -0
- package/lib/model-families.js +243 -0
- package/lib/project-connection.js +16 -4
- package/lib/project-sessions.js +102 -18
- package/lib/project.js +4 -0
- package/lib/public/css/menus.css +67 -0
- package/lib/public/css/server-settings.css +72 -0
- package/lib/public/index.html +3 -0
- package/lib/public/modules/app-loop-ui.js +4 -0
- package/lib/public/modules/app-messages.js +29 -4
- package/lib/public/modules/app-panels.js +93 -24
- package/lib/public/modules/app-rate-limit.js +1 -1
- package/lib/public/modules/model-context-windows.js +9 -0
- package/lib/public/modules/model-families.js +230 -0
- package/lib/public/modules/project-settings.js +1 -0
- package/lib/public/modules/scheduler.js +5 -0
- package/lib/public/modules/server-settings.js +14 -12
- package/lib/public/modules/settings-defaults.js +151 -41
- package/lib/public/modules/tools.js +38 -0
- package/lib/sdk-bridge.js +88 -13
- package/lib/sdk-message-processor.js +128 -3
- package/lib/server.js +55 -0
- package/lib/session-activity.js +282 -0
- package/lib/sessions.js +58 -3
- package/lib/terminal-manager.js +40 -0
- package/lib/utils.js +44 -0
- package/lib/ws-schema.js +1 -0
- package/lib/yoke/adapters/claude-worker.js +6 -2
- package/lib/yoke/adapters/claude.js +377 -87
- package/lib/yoke/adapters/codex.js +20 -0
- package/package.json +1 -1
- package/scripts/generate-model-catalog.js +337 -0
package/lib/build-sha.json
CHANGED
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
{
|
|
2
|
+
"generatedAt": "2026-07-31T16:37:55.539Z",
|
|
3
|
+
"source": "deprecations-page",
|
|
4
|
+
"models": [
|
|
5
|
+
{
|
|
6
|
+
"id": "claude-1.0",
|
|
7
|
+
"displayName": "claude-1.0",
|
|
8
|
+
"createdAt": null,
|
|
9
|
+
"status": "retired"
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
"id": "claude-1.1",
|
|
13
|
+
"displayName": "claude-1.1",
|
|
14
|
+
"createdAt": null,
|
|
15
|
+
"status": "retired"
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
"id": "claude-1.2",
|
|
19
|
+
"displayName": "claude-1.2",
|
|
20
|
+
"createdAt": null,
|
|
21
|
+
"status": "retired"
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
"id": "claude-1.3",
|
|
25
|
+
"displayName": "claude-1.3",
|
|
26
|
+
"createdAt": null,
|
|
27
|
+
"status": "retired"
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
"id": "claude-2.0",
|
|
31
|
+
"displayName": "claude-2.0",
|
|
32
|
+
"createdAt": null,
|
|
33
|
+
"status": "retired"
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
"id": "claude-2.1",
|
|
37
|
+
"displayName": "claude-2.1",
|
|
38
|
+
"createdAt": null,
|
|
39
|
+
"status": "retired"
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
"id": "claude-3-5-haiku-20241022",
|
|
43
|
+
"displayName": "claude-3-5-haiku-20241022",
|
|
44
|
+
"createdAt": null,
|
|
45
|
+
"status": "retired"
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
"id": "claude-3-5-sonnet-20240620",
|
|
49
|
+
"displayName": "claude-3-5-sonnet-20240620",
|
|
50
|
+
"createdAt": null,
|
|
51
|
+
"status": "retired"
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
"id": "claude-3-5-sonnet-20241022",
|
|
55
|
+
"displayName": "claude-3-5-sonnet-20241022",
|
|
56
|
+
"createdAt": null,
|
|
57
|
+
"status": "retired"
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
"id": "claude-3-7-sonnet-20250219",
|
|
61
|
+
"displayName": "claude-3-7-sonnet-20250219",
|
|
62
|
+
"createdAt": null,
|
|
63
|
+
"status": "retired"
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
"id": "claude-3-haiku-20240307",
|
|
67
|
+
"displayName": "claude-3-haiku-20240307",
|
|
68
|
+
"createdAt": null,
|
|
69
|
+
"status": "retired"
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
"id": "claude-3-opus-20240229",
|
|
73
|
+
"displayName": "claude-3-opus-20240229",
|
|
74
|
+
"createdAt": null,
|
|
75
|
+
"status": "retired"
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
"id": "claude-3-sonnet-20240229",
|
|
79
|
+
"displayName": "claude-3-sonnet-20240229",
|
|
80
|
+
"createdAt": null,
|
|
81
|
+
"status": "retired"
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
"id": "claude-fable-5",
|
|
85
|
+
"displayName": "claude-fable-5",
|
|
86
|
+
"createdAt": null,
|
|
87
|
+
"status": "active"
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
"id": "claude-haiku-4-5-20251001",
|
|
91
|
+
"displayName": "claude-haiku-4-5-20251001",
|
|
92
|
+
"createdAt": null,
|
|
93
|
+
"status": "active"
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
"id": "claude-instant-1.0",
|
|
97
|
+
"displayName": "claude-instant-1.0",
|
|
98
|
+
"createdAt": null,
|
|
99
|
+
"status": "retired"
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
"id": "claude-instant-1.1",
|
|
103
|
+
"displayName": "claude-instant-1.1",
|
|
104
|
+
"createdAt": null,
|
|
105
|
+
"status": "retired"
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
"id": "claude-instant-1.2",
|
|
109
|
+
"displayName": "claude-instant-1.2",
|
|
110
|
+
"createdAt": null,
|
|
111
|
+
"status": "retired"
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
"id": "claude-opus-4-1-20250805",
|
|
115
|
+
"displayName": "claude-opus-4-1-20250805",
|
|
116
|
+
"createdAt": null,
|
|
117
|
+
"status": "deprecated"
|
|
118
|
+
},
|
|
119
|
+
{
|
|
120
|
+
"id": "claude-opus-4-20250514",
|
|
121
|
+
"displayName": "claude-opus-4-20250514",
|
|
122
|
+
"createdAt": null,
|
|
123
|
+
"status": "retired"
|
|
124
|
+
},
|
|
125
|
+
{
|
|
126
|
+
"id": "claude-opus-4-5-20251101",
|
|
127
|
+
"displayName": "claude-opus-4-5-20251101",
|
|
128
|
+
"createdAt": null,
|
|
129
|
+
"status": "active"
|
|
130
|
+
},
|
|
131
|
+
{
|
|
132
|
+
"id": "claude-opus-4-6",
|
|
133
|
+
"displayName": "claude-opus-4-6",
|
|
134
|
+
"createdAt": null,
|
|
135
|
+
"status": "active"
|
|
136
|
+
},
|
|
137
|
+
{
|
|
138
|
+
"id": "claude-opus-4-7",
|
|
139
|
+
"displayName": "claude-opus-4-7",
|
|
140
|
+
"createdAt": null,
|
|
141
|
+
"status": "active"
|
|
142
|
+
},
|
|
143
|
+
{
|
|
144
|
+
"id": "claude-opus-4-8",
|
|
145
|
+
"displayName": "claude-opus-4-8",
|
|
146
|
+
"createdAt": null,
|
|
147
|
+
"status": "active"
|
|
148
|
+
},
|
|
149
|
+
{
|
|
150
|
+
"id": "claude-opus-5",
|
|
151
|
+
"displayName": "claude-opus-5",
|
|
152
|
+
"createdAt": null,
|
|
153
|
+
"status": "active"
|
|
154
|
+
},
|
|
155
|
+
{
|
|
156
|
+
"id": "claude-sonnet-4-20250514",
|
|
157
|
+
"displayName": "claude-sonnet-4-20250514",
|
|
158
|
+
"createdAt": null,
|
|
159
|
+
"status": "retired"
|
|
160
|
+
},
|
|
161
|
+
{
|
|
162
|
+
"id": "claude-sonnet-4-5-20250929",
|
|
163
|
+
"displayName": "claude-sonnet-4-5-20250929",
|
|
164
|
+
"createdAt": null,
|
|
165
|
+
"status": "active"
|
|
166
|
+
},
|
|
167
|
+
{
|
|
168
|
+
"id": "claude-sonnet-4-6",
|
|
169
|
+
"displayName": "claude-sonnet-4-6",
|
|
170
|
+
"createdAt": null,
|
|
171
|
+
"status": "active"
|
|
172
|
+
},
|
|
173
|
+
{
|
|
174
|
+
"id": "claude-sonnet-5",
|
|
175
|
+
"displayName": "claude-sonnet-5",
|
|
176
|
+
"createdAt": null,
|
|
177
|
+
"status": "active"
|
|
178
|
+
}
|
|
179
|
+
]
|
|
180
|
+
}
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* model-catalog.js — loads the release-time-generated Claude model catalog
|
|
3
|
+
* and merges it into a live vendor model list. (lr-f22787)
|
|
4
|
+
*
|
|
5
|
+
* DESIGN (operator-approved, see PR body for lr-f22787):
|
|
6
|
+
*
|
|
7
|
+
* The Claude Agent SDK's live enumeration (stream.supportedModels()) only
|
|
8
|
+
* ever reports the current alias set (default/opus/sonnet/haiku/fable) — see
|
|
9
|
+
* lib/yoke/adapters/claude.js's enrichment comments and
|
|
10
|
+
* test/model-picker-no-free-text-lr-f22787.test.js for the full empirical
|
|
11
|
+
* trail. There is no runtime path to a list of older, still-runnable
|
|
12
|
+
* versioned IDs (e.g. claude-opus-4-5). GET https://api.anthropic.com/v1/models
|
|
13
|
+
* DOES enumerate them, but requires an API key — which this project's
|
|
14
|
+
* runtime is never allowed to hold (OAuth-only, workspace rule 17: no
|
|
15
|
+
* Anthropic SDK / API-key calls at runtime). So the catalog is generated
|
|
16
|
+
* ONCE per release, in CI, using a repo-secret API key that never leaves
|
|
17
|
+
* CI, and committed as lib/generated/claude-model-catalog.json — shipped
|
|
18
|
+
* inside the npm package like lib/themes/*.json.
|
|
19
|
+
*
|
|
20
|
+
* This module is the read + merge side only. It never makes a network call
|
|
21
|
+
* and never touches ANTHROPIC_API_KEY (that only exists in the GitHub
|
|
22
|
+
* Actions release workflow — see .github/workflows/release.yml).
|
|
23
|
+
*
|
|
24
|
+
* RETIRED MODELS (lr-d3817f, REVERSES the original lr-f22787 decision
|
|
25
|
+
* below): the generator is still ADDITIVE — each release's catalog is a
|
|
26
|
+
* union of the freshly-fetched /v1/models response with whatever was
|
|
27
|
+
* already committed, never a drop of an entry the vendor stopped listing.
|
|
28
|
+
* The committed file is allowed to accumulate retired history so past
|
|
29
|
+
* releases stay diffable/auditable. But the PICKER must never show a
|
|
30
|
+
* retired entry, in any state, on any surface. The original lr-f22787
|
|
31
|
+
* rationale ("shown-but-disabled beats silently vanishing") was never
|
|
32
|
+
* something the operator asked for — the corrected spec (lr-d3817f) is
|
|
33
|
+
* that a fully-retired model (one that provably cannot run) is simply
|
|
34
|
+
* filtered out before it ever reaches a render function. See
|
|
35
|
+
* filterSelectableCatalogModels below, which is the enforcement point.
|
|
36
|
+
*
|
|
37
|
+
* PICKER BEHAVIOR FOR RETIRED/DEPRECATED (lr-d3817f, corrected): the
|
|
38
|
+
* committed catalog carries a per-entry `status` field
|
|
39
|
+
* ("active"/"deprecated"/"retired"/"unknown" — populated by
|
|
40
|
+
* scripts/generate-model-catalog.js from the deprecations page's own
|
|
41
|
+
* three-state "Current state" column, the natural source of truth, rather
|
|
42
|
+
* than an invented heuristic).
|
|
43
|
+
* - status "retired": excluded entirely by filterSelectableCatalogModels
|
|
44
|
+
* — never merged into the live picker list, on any surface, in any
|
|
45
|
+
* state (collapsed or expanded).
|
|
46
|
+
* - status "deprecated": marked isDeprecated:true via applyRetiredMarking,
|
|
47
|
+
* still fully selectable — a deprecated model still runs (it just has a
|
|
48
|
+
* retirement date on the horizon), so filtering it would be
|
|
49
|
+
* overcautious; the marker itself is the appropriate signal. The
|
|
50
|
+
* operator's spec named retired, not deprecated, for exclusion.
|
|
51
|
+
* - status "active"/"unknown"/absent: no marking, no filtering. "unknown"
|
|
52
|
+
* (a status string the deprecations-page parser didn't recognize) fails
|
|
53
|
+
* open — the alternative (treat unknown as retired-and-filtered) would
|
|
54
|
+
* risk hiding a model that is actually fine, on the strength of a
|
|
55
|
+
* parser hiccup this codebase can't verify either way.
|
|
56
|
+
*
|
|
57
|
+
* MISSING SECRET / FETCH FAILURE (PR body point (b)): loadClaudeModelCatalog
|
|
58
|
+
* never throws and never returns an empty list on a read/parse failure — it
|
|
59
|
+
* falls back to whatever was last committed. The catalog can only ever go
|
|
60
|
+
* stale, never empty; the picker must never regress to "no options."
|
|
61
|
+
*/
|
|
62
|
+
|
|
63
|
+
var fs = require("fs");
|
|
64
|
+
var path = require("path");
|
|
65
|
+
|
|
66
|
+
var CATALOG_PATH = path.join(__dirname, "generated", "claude-model-catalog.json");
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Read the committed/generated catalog file. Never throws.
|
|
70
|
+
* @returns {{ ok: boolean, models: Array<{id,displayName,createdAt}>, generatedAt: string|null, source: string|null, reason?: string }}
|
|
71
|
+
*/
|
|
72
|
+
function loadClaudeModelCatalog() {
|
|
73
|
+
var raw;
|
|
74
|
+
try {
|
|
75
|
+
raw = fs.readFileSync(CATALOG_PATH, "utf8");
|
|
76
|
+
} catch (e) {
|
|
77
|
+
// No catalog shipped at all (should not happen once the seed file is
|
|
78
|
+
// committed, but a corrupted install or a future path change must
|
|
79
|
+
// degrade to "no catalog entries to merge," never a thrown error that
|
|
80
|
+
// could break warmup/model listing entirely).
|
|
81
|
+
return { ok: false, models: [], generatedAt: null, source: null, reason: "missing" };
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
var parsed;
|
|
85
|
+
try {
|
|
86
|
+
parsed = JSON.parse(raw);
|
|
87
|
+
} catch (e) {
|
|
88
|
+
return { ok: false, models: [], generatedAt: null, source: null, reason: "invalid" };
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
if (!parsed || !Array.isArray(parsed.models)) {
|
|
92
|
+
return { ok: false, models: [], generatedAt: null, source: null, reason: "invalid" };
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
return {
|
|
96
|
+
ok: true,
|
|
97
|
+
models: parsed.models,
|
|
98
|
+
generatedAt: parsed.generatedAt || null,
|
|
99
|
+
source: parsed.source || null,
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Merge the generated catalog into a live vendor model list.
|
|
105
|
+
*
|
|
106
|
+
* @param {Array<string|object>} liveModels - the vendor's live-reported list
|
|
107
|
+
* (e.g. from stream.supportedModels() — normally just the alias set).
|
|
108
|
+
* @param {Array<{id:string,displayName?:string,status?:string}>} catalogModels - entries
|
|
109
|
+
* from loadClaudeModelCatalog().models.
|
|
110
|
+
* @returns {Array<object>} liveModels followed by any catalog entries whose
|
|
111
|
+
* id is not already present in liveModels (by value/id), each tagged
|
|
112
|
+
* { value, displayName, fromCatalog: true, status } so callers/UI can
|
|
113
|
+
* mark them (PR body point (c): shown, never hidden — the "Older models"
|
|
114
|
+
* disclosure already covers the visual distinction via isLatest tiering
|
|
115
|
+
* upstream; applyRetiredMarking below adds the retired/deprecated marker
|
|
116
|
+
* on top of that using the carried-through status field).
|
|
117
|
+
*/
|
|
118
|
+
function mergeModelCatalog(liveModels, catalogModels) {
|
|
119
|
+
var live = liveModels || [];
|
|
120
|
+
var catalog = catalogModels || [];
|
|
121
|
+
|
|
122
|
+
var seen = {};
|
|
123
|
+
for (var i = 0; i < live.length; i++) {
|
|
124
|
+
var entry = live[i];
|
|
125
|
+
var value = (entry && typeof entry === "object") ? (entry.value || "") : String(entry || "");
|
|
126
|
+
if (value) seen[value] = true;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
var merged = live.slice();
|
|
130
|
+
for (var j = 0; j < catalog.length; j++) {
|
|
131
|
+
var c = catalog[j];
|
|
132
|
+
if (!c || !c.id || seen[c.id]) continue;
|
|
133
|
+
seen[c.id] = true;
|
|
134
|
+
merged.push({
|
|
135
|
+
value: c.id,
|
|
136
|
+
displayName: c.displayName || c.id,
|
|
137
|
+
fromCatalog: true,
|
|
138
|
+
status: c.status || "unknown",
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
return merged;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* Apply the deprecated marking described in this module's header comment
|
|
146
|
+
* ("PICKER BEHAVIOR FOR RETIRED/DEPRECATED"). Pure and additive: only ever
|
|
147
|
+
* ADDS isDeprecated onto entries that already carry a `status` field from
|
|
148
|
+
* mergeModelCatalog — never removes an entry, never touches entries with no
|
|
149
|
+
* status field at all (e.g. a live vendor entry that went through
|
|
150
|
+
* mergeModelCatalog untouched, which has no `status` key — see
|
|
151
|
+
* mergeModelCatalog above, only catalog-sourced entries get one).
|
|
152
|
+
*
|
|
153
|
+
* lr-d3817f: this used to also mark status:"retired" entries isRetired/
|
|
154
|
+
* disabled instead of filtering them. That decision is reversed — a retired
|
|
155
|
+
* entry is now removed entirely by filterSelectableCatalogModels (below)
|
|
156
|
+
* BEFORE this function runs, so applyRetiredMarking never sees one in
|
|
157
|
+
* practice. It still no-ops safely on a stray "retired" status (e.g. a
|
|
158
|
+
* caller that skips the filter) rather than mismarking it as deprecated.
|
|
159
|
+
*
|
|
160
|
+
* @param {Array<object>} models - output of mergeModelCatalog (or any list
|
|
161
|
+
* of model objects, some of which may carry a `status` field).
|
|
162
|
+
* @returns {Array<object>} the SAME entries, each with isDeprecated added
|
|
163
|
+
* when status is "deprecated".
|
|
164
|
+
*/
|
|
165
|
+
function applyRetiredMarking(models) {
|
|
166
|
+
var list = models || [];
|
|
167
|
+
return list.map(function (m) {
|
|
168
|
+
if (!m || typeof m !== "object" || !m.status) return m;
|
|
169
|
+
if (m.status === "deprecated") {
|
|
170
|
+
return Object.assign({}, m, { isDeprecated: true });
|
|
171
|
+
}
|
|
172
|
+
return m;
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* Remove status:"retired" catalog entries before they ever reach a picker
|
|
178
|
+
* surface (lr-d3817f). A retired model provably cannot run; the corrected
|
|
179
|
+
* spec is that it appears NOWHERE — not shown-and-disabled, not in the
|
|
180
|
+
* expanded "Older models" tier, not on any surface. This must run on the
|
|
181
|
+
* CATALOG list (before mergeModelCatalog), not on the merged live+catalog
|
|
182
|
+
* list, so a live vendor entry (which never carries a `status` field) is
|
|
183
|
+
* never accidentally filtered.
|
|
184
|
+
*
|
|
185
|
+
* @param {Array<{id:string,status?:string}>} catalogModels - entries from
|
|
186
|
+
* loadClaudeModelCatalog().models.
|
|
187
|
+
* @returns {Array<object>} the same entries, minus any with status:"retired".
|
|
188
|
+
*/
|
|
189
|
+
function filterSelectableCatalogModels(catalogModels) {
|
|
190
|
+
var list = catalogModels || [];
|
|
191
|
+
return list.filter(function (m) {
|
|
192
|
+
return !(m && m.status === "retired");
|
|
193
|
+
});
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
module.exports = {
|
|
197
|
+
CATALOG_PATH: CATALOG_PATH,
|
|
198
|
+
loadClaudeModelCatalog: loadClaudeModelCatalog,
|
|
199
|
+
mergeModelCatalog: mergeModelCatalog,
|
|
200
|
+
applyRetiredMarking: applyRetiredMarking,
|
|
201
|
+
filterSelectableCatalogModels: filterSelectableCatalogModels,
|
|
202
|
+
};
|
|
@@ -17,6 +17,15 @@
|
|
|
17
17
|
* The map is keyed by a lowercase model-name substring. Lookup is a linear scan so
|
|
18
18
|
* insertion order matters for overlapping substrings — more-specific keys should
|
|
19
19
|
* appear before less-specific ones.
|
|
20
|
+
*
|
|
21
|
+
* Fallback-only (lr-d91ecf): this map is consulted only when the vendor
|
|
22
|
+
* hasn't reported a context window for the active model at runtime
|
|
23
|
+
* (resolveModelContextWindow returns 0 for anything not listed here, and
|
|
24
|
+
* callers degrade gracefully — see resolveContextWindow in app-panels.js,
|
|
25
|
+
* which falls back further to the SDK-reported value before a last-resort
|
|
26
|
+
* default). A vendor-reported window always wins when present; this table
|
|
27
|
+
* exists only to cover models/betas the vendor's runtime response doesn't
|
|
28
|
+
* carry a window for.
|
|
20
29
|
*/
|
|
21
30
|
|
|
22
31
|
var KNOWN_CONTEXT_WINDOWS = {
|
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* model-families.js — shared source of truth for Claude model family/version
|
|
3
|
+
* parsing, derived display names, and capability heuristics. (lr-d91ecf)
|
|
4
|
+
*
|
|
5
|
+
* This is the CJS backend copy, consumed by lib/yoke/adapters/claude.js.
|
|
6
|
+
* The ES module (browser) copy lives at lib/public/modules/model-families.js
|
|
7
|
+
* and is consumed by settings-defaults.js and app-panels.js. A CI test
|
|
8
|
+
* (test/model-families-parity.test.js) asserts both files produce identical
|
|
9
|
+
* results so they cannot silently drift — same discipline as the existing
|
|
10
|
+
* lib/model-context-windows.js / lib/public/modules/model-context-windows.js
|
|
11
|
+
* pair (lr-336f).
|
|
12
|
+
*
|
|
13
|
+
* Before this module existed, family/version detection was duplicated three
|
|
14
|
+
* ways: lib/yoke/adapters/claude.js (parseClaudeModelVersion etc., added by
|
|
15
|
+
* lr-e03635), lib/public/modules/settings-defaults.js (isSonnetModel/
|
|
16
|
+
* isOpusModel/isHaikuModel), and lib/public/modules/app-panels.js (its own
|
|
17
|
+
* private isSonnetModel copy). This is the single shared location — do not
|
|
18
|
+
* add a fourth copy elsewhere.
|
|
19
|
+
*
|
|
20
|
+
* No hardcoded model IDs or display-name tables: everything here is derived
|
|
21
|
+
* from the ID string's family substring + numeric version ordering, so a
|
|
22
|
+
* model release the code has never seen gets a sane display name and correct
|
|
23
|
+
* latest/older tiering with zero code changes.
|
|
24
|
+
*
|
|
25
|
+
* Keep this module dependency-light: no project imports, no Node built-ins.
|
|
26
|
+
* That constraint is what lets it stay close to the browser copy.
|
|
27
|
+
*/
|
|
28
|
+
|
|
29
|
+
var CLAUDE_MODEL_FAMILIES = ["opus", "sonnet", "haiku", "fable"];
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* True if the given model ID string belongs to the given family (substring
|
|
33
|
+
* match on the lowercased ID). Generic helper backing isSonnetModel/
|
|
34
|
+
* isOpusModel/isHaikuModel below.
|
|
35
|
+
*/
|
|
36
|
+
function isClaudeFamily(model, family) {
|
|
37
|
+
if (!model) return false;
|
|
38
|
+
var str = typeof model === "string" ? model : (model.value || "");
|
|
39
|
+
return str.toLowerCase().indexOf(family) !== -1;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function isSonnetModel(model) { return isClaudeFamily(model, "sonnet"); }
|
|
43
|
+
function isOpusModel(model) { return isClaudeFamily(model, "opus"); }
|
|
44
|
+
function isHaikuModel(model) { return isClaudeFamily(model, "haiku"); }
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Parse a single ID/description-style string into { family, version } (or
|
|
48
|
+
* null). Shared core behind parseClaudeModelVersion below — no family
|
|
49
|
+
* resolution fallback, just the raw substring + numeric-segment extraction.
|
|
50
|
+
*/
|
|
51
|
+
function parseClaudeFamilyVersion(str) {
|
|
52
|
+
var lower = (str || "").toLowerCase();
|
|
53
|
+
// Strip pinned-version/beta suffix like "[1m]" before parsing.
|
|
54
|
+
var clean = lower.replace(/\[.*?\]$/, "").trim();
|
|
55
|
+
|
|
56
|
+
var family = null;
|
|
57
|
+
for (var i = 0; i < CLAUDE_MODEL_FAMILIES.length; i++) {
|
|
58
|
+
if (clean.indexOf(CLAUDE_MODEL_FAMILIES[i]) !== -1) { family = CLAUDE_MODEL_FAMILIES[i]; break; }
|
|
59
|
+
}
|
|
60
|
+
if (!family) return null;
|
|
61
|
+
|
|
62
|
+
// Numeric segments after the family name, stopping before a trailing date
|
|
63
|
+
// stamp (8 digits, e.g. "-20250929") which is a release date, not a version.
|
|
64
|
+
var afterFamily = clean.slice(clean.indexOf(family) + family.length);
|
|
65
|
+
var withoutDate = afterFamily.replace(/-?\d{8}\b/, "");
|
|
66
|
+
var nums = withoutDate.match(/\d+/g);
|
|
67
|
+
var version = nums ? nums.map(function(n) { return parseInt(n, 10); }) : [];
|
|
68
|
+
|
|
69
|
+
return { family: family, version: version };
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Extract ONLY the leading dotted-number run immediately following the
|
|
74
|
+
* family name in free-text description prose (e.g. "Opus 4.8 with 1M
|
|
75
|
+
* context" -> [4, 8], stopping before the unrelated "1" in "1M"). Unlike
|
|
76
|
+
* parseClaudeFamilyVersion (which scans the entire remainder of a tight ID
|
|
77
|
+
* string), description text can contain trailing prose with unrelated
|
|
78
|
+
* digits, so only a contiguous number immediately after the family name
|
|
79
|
+
* (allowing a single separator character, e.g. the space in "Opus 4.8") is
|
|
80
|
+
* trusted as the version.
|
|
81
|
+
*/
|
|
82
|
+
function parseClaudeFamilyVersionFromDescription(str) {
|
|
83
|
+
var lower = (str || "").toLowerCase();
|
|
84
|
+
var family = null;
|
|
85
|
+
for (var i = 0; i < CLAUDE_MODEL_FAMILIES.length; i++) {
|
|
86
|
+
if (lower.indexOf(CLAUDE_MODEL_FAMILIES[i]) !== -1) { family = CLAUDE_MODEL_FAMILIES[i]; break; }
|
|
87
|
+
}
|
|
88
|
+
if (!family) return null;
|
|
89
|
+
|
|
90
|
+
var afterFamily = lower.slice(lower.indexOf(family) + family.length);
|
|
91
|
+
var m = afterFamily.match(/^[\s-]?(\d+(?:\.\d+)*)/);
|
|
92
|
+
var version = m ? m[1].split(".").map(function(n) { return parseInt(n, 10); }) : [];
|
|
93
|
+
|
|
94
|
+
return { family: family, version: version };
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Parse a raw Claude model ID into { family, version } for ordering.
|
|
99
|
+
* version is an array of numeric segments (e.g. "claude-opus-4-6" -> [4, 6]),
|
|
100
|
+
* so comparison is lexicographic-numeric (4.6 > 4.5 > 4 > 3.7 > 3.5 > 3).
|
|
101
|
+
* Returns null when the ID doesn't match a known family (e.g. an ID with no
|
|
102
|
+
* family substring at all) — such entries are excluded from the tiering
|
|
103
|
+
* comparison entirely and default to isLatest: true (never hidden behind a
|
|
104
|
+
* disclosure we can't reason about).
|
|
105
|
+
*
|
|
106
|
+
* Live Claude runtimes report an alias for `modelId` (e.g. "opus", "sonnet",
|
|
107
|
+
* "fable") with NO version digits at all — the family resolves but the
|
|
108
|
+
* version array comes back empty. When the caller also has the vendor's
|
|
109
|
+
* `description` string (e.g. "Opus 4.8 with 1M context", "Sonnet 4.6"), pass
|
|
110
|
+
* it as the optional second argument: if the alias itself carried no version
|
|
111
|
+
* digits, ONLY the leading number immediately after the family name in the
|
|
112
|
+
* description is trusted (see parseClaudeFamilyVersionFromDescription) —
|
|
113
|
+
* trailing prose digits (e.g. the "1" in "1M context") are never picked up.
|
|
114
|
+
* This is what lets an alias-only model list still surface real version
|
|
115
|
+
* numbers (lr-5c07ce) without ever hardcoding a model ID.
|
|
116
|
+
*/
|
|
117
|
+
function parseClaudeModelVersion(modelId, description) {
|
|
118
|
+
var parsed = parseClaudeFamilyVersion(modelId);
|
|
119
|
+
if (!parsed) return null;
|
|
120
|
+
if (parsed.version.length === 0 && description) {
|
|
121
|
+
var fromDesc = parseClaudeFamilyVersionFromDescription(description);
|
|
122
|
+
if (fromDesc && fromDesc.family === parsed.family && fromDesc.version.length > 0) {
|
|
123
|
+
return { family: parsed.family, version: fromDesc.version };
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
return parsed;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* Compare two version arrays lexicographically (missing segments treated as 0).
|
|
131
|
+
* Returns >0 if a > b, <0 if a < b, 0 if equal.
|
|
132
|
+
*/
|
|
133
|
+
function compareClaudeVersions(a, b) {
|
|
134
|
+
var len = Math.max(a.length, b.length);
|
|
135
|
+
for (var i = 0; i < len; i++) {
|
|
136
|
+
var av = a[i] || 0;
|
|
137
|
+
var bv = b[i] || 0;
|
|
138
|
+
if (av !== bv) return av - bv;
|
|
139
|
+
}
|
|
140
|
+
return 0;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* Given the full list of raw model IDs (or rich objects) reported by the
|
|
145
|
+
* vendor, compute isLatest per model: true iff it holds the max version
|
|
146
|
+
* within its own family, or its ID doesn't parse into a known family at all
|
|
147
|
+
* (unparseable entries are never hidden).
|
|
148
|
+
*
|
|
149
|
+
* When an entry is a rich object with a `description` field, it feeds
|
|
150
|
+
* parseClaudeModelVersion's optional second argument (see its doc comment) —
|
|
151
|
+
* this is what lets a live alias-only list (value: "opus"/"sonnet"/"haiku",
|
|
152
|
+
* no version digits) still tier correctly against a real versioned ID that
|
|
153
|
+
* might appear alongside it, using the version embedded in the vendor's
|
|
154
|
+
* description text instead of a hardcoded table (lr-5c07ce).
|
|
155
|
+
* @returns {Object<string, boolean>} map of raw model value -> isLatest
|
|
156
|
+
*/
|
|
157
|
+
function deriveClaudeLatestTiers(models) {
|
|
158
|
+
var parsed = models.map(function(m) {
|
|
159
|
+
var value = (m && typeof m === "object") ? (m.value || "") : String(m || "");
|
|
160
|
+
var description = (m && typeof m === "object") ? m.description : null;
|
|
161
|
+
return { value: value, parsed: parseClaudeModelVersion(value, description) };
|
|
162
|
+
});
|
|
163
|
+
|
|
164
|
+
var maxVersionByFamily = {};
|
|
165
|
+
for (var i = 0; i < parsed.length; i++) {
|
|
166
|
+
var p = parsed[i].parsed;
|
|
167
|
+
if (!p) continue;
|
|
168
|
+
var current = maxVersionByFamily[p.family];
|
|
169
|
+
if (!current || compareClaudeVersions(p.version, current) > 0) {
|
|
170
|
+
maxVersionByFamily[p.family] = p.version;
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
var result = {};
|
|
175
|
+
for (var j = 0; j < parsed.length; j++) {
|
|
176
|
+
var entry = parsed[j];
|
|
177
|
+
if (!entry.parsed) {
|
|
178
|
+
result[entry.value] = true; // unparseable — never hidden
|
|
179
|
+
continue;
|
|
180
|
+
}
|
|
181
|
+
var maxV = maxVersionByFamily[entry.parsed.family];
|
|
182
|
+
result[entry.value] = compareClaudeVersions(entry.parsed.version, maxV) === 0;
|
|
183
|
+
}
|
|
184
|
+
return result;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
// Title-case a family name for display (e.g. "opus" -> "Opus").
|
|
188
|
+
function titleCaseFamily(family) {
|
|
189
|
+
return family.charAt(0).toUpperCase() + family.slice(1);
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
/**
|
|
193
|
+
* Derive a human-readable display name purely from the parsed family +
|
|
194
|
+
* version — no lookup table, so an ID the code has never seen still gets a
|
|
195
|
+
* sane label with zero code changes (e.g. "claude-opus-4-6" -> "Opus 4.6").
|
|
196
|
+
* Falls back to stripping the "claude-" prefix for IDs with no recognized
|
|
197
|
+
* family substring at all (e.g. "default" -> "Default").
|
|
198
|
+
*
|
|
199
|
+
* @param {string} modelId
|
|
200
|
+
* @param {string} [description] - optional vendor description string (e.g.
|
|
201
|
+
* "Opus 4.8 with 1M context"). When modelId is a bare alias with no
|
|
202
|
+
* version digits (the live runtime shape for opus/sonnet/haiku/fable —
|
|
203
|
+
* lr-5c07ce), the version embedded in description is used instead, so
|
|
204
|
+
* "Opus" (alias) displays as "Opus 4.8" rather than just "Opus".
|
|
205
|
+
*/
|
|
206
|
+
function claudeDisplayName(modelId, description) {
|
|
207
|
+
var parsed = parseClaudeModelVersion(modelId, description);
|
|
208
|
+
if (parsed) {
|
|
209
|
+
var label = titleCaseFamily(parsed.family);
|
|
210
|
+
if (parsed.version.length > 0) {
|
|
211
|
+
label += " " + parsed.version.join(".");
|
|
212
|
+
}
|
|
213
|
+
return label;
|
|
214
|
+
}
|
|
215
|
+
// Fallback: strip "claude-" prefix, title-case remainder
|
|
216
|
+
var stripped = (modelId || "").replace(/^claude-/i, "");
|
|
217
|
+
return stripped;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
// Haiku models do not support extended thinking.
|
|
221
|
+
function claudeModelSupportsThinking(modelId) {
|
|
222
|
+
return !isHaikuModel(modelId);
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
// Models known to support effort control. Currently all Claude 4.x opus/sonnet
|
|
226
|
+
// models support effort; haiku does not (no reasoning). Defaults to true for
|
|
227
|
+
// unknown models so new releases are not accidentally silenced.
|
|
228
|
+
function claudeModelSupportsEffort(modelId) {
|
|
229
|
+
return !isHaikuModel(modelId);
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
module.exports = {
|
|
233
|
+
CLAUDE_MODEL_FAMILIES: CLAUDE_MODEL_FAMILIES,
|
|
234
|
+
isSonnetModel: isSonnetModel,
|
|
235
|
+
isOpusModel: isOpusModel,
|
|
236
|
+
isHaikuModel: isHaikuModel,
|
|
237
|
+
parseClaudeModelVersion: parseClaudeModelVersion,
|
|
238
|
+
compareClaudeVersions: compareClaudeVersions,
|
|
239
|
+
deriveClaudeLatestTiers: deriveClaudeLatestTiers,
|
|
240
|
+
claudeDisplayName: claudeDisplayName,
|
|
241
|
+
claudeModelSupportsThinking: claudeModelSupportsThinking,
|
|
242
|
+
claudeModelSupportsEffort: claudeModelSupportsEffort,
|
|
243
|
+
};
|