@clagentic/console 1.8.0 → 1.9.0-beta.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/bin/cli.js +12 -1
- package/lib/agents.js +13 -3
- package/lib/build-sha.json +2 -2
- package/lib/cli/ipc-subcommands.js +40 -4
- package/lib/daemon.js +25 -1
- package/lib/generated/claude-model-catalog.json +180 -0
- package/lib/model-catalog.js +202 -0
- package/lib/model-families.js +243 -0
- package/lib/project-connection.js +30 -5
- package/lib/project-loop.js +46 -2
- package/lib/project-sessions.js +133 -21
- package/lib/project-user-message.js +70 -3
- package/lib/project.js +11 -1
- package/lib/public/app.js +14 -4
- package/lib/public/css/base.css +14 -0
- package/lib/public/css/home-hub.css +28 -8
- package/lib/public/css/icon-strip.css +17 -0
- package/lib/public/css/menus.css +67 -0
- package/lib/public/css/messages.css +11 -0
- package/lib/public/css/mobile-nav.css +22 -0
- package/lib/public/css/server-settings.css +72 -0
- package/lib/public/css/sidebar.css +15 -0
- package/lib/public/css/title-bar.css +10 -1
- package/lib/public/index.html +4 -0
- package/lib/public/modules/activity-latch.js +159 -0
- package/lib/public/modules/activity-state.js +157 -0
- package/lib/public/modules/app-connection.js +10 -4
- package/lib/public/modules/app-favicon.js +88 -1
- package/lib/public/modules/app-home-hub.js +14 -11
- package/lib/public/modules/app-loop-ui.js +90 -2
- package/lib/public/modules/app-messages.js +117 -28
- package/lib/public/modules/app-panels.js +184 -56
- package/lib/public/modules/app-projects.js +28 -8
- package/lib/public/modules/app-rate-limit.js +14 -2
- 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/sidebar-mobile.js +32 -22
- package/lib/public/modules/sidebar-projects.js +42 -14
- package/lib/public/modules/sidebar-sessions.js +168 -48
- package/lib/public/modules/tools.js +22 -12
- package/lib/sdk-bridge.js +389 -35
- package/lib/sdk-message-processor.js +215 -7
- package/lib/sdk-skill-discovery.js +46 -6
- package/lib/sdk-slash-enrichment.js +5 -2
- package/lib/server-hub-sessions.js +70 -0
- package/lib/server.js +79 -22
- package/lib/session-activity.js +289 -0
- package/lib/sessions.js +104 -3
- package/lib/smtp.js +10 -1
- package/lib/terminal-manager.js +40 -0
- package/lib/utils.js +44 -0
- package/lib/ws-schema.js +17 -0
- package/lib/yoke/adapters/claude-worker.js +6 -2
- package/lib/yoke/adapters/claude.js +384 -88
- package/lib/yoke/adapters/codex.js +239 -31
- package/package.json +2 -2
- package/scripts/check-test-count.js +397 -0
- package/scripts/generate-model-catalog.js +337 -0
- package/scripts/test-file-completion-reporter.js +43 -0
- package/lib/model-context-windows.js +0 -65
- package/lib/public/modules/model-context-windows.js +0 -62
|
@@ -11,6 +11,8 @@ var net = require("net");
|
|
|
11
11
|
var crypto = require("crypto");
|
|
12
12
|
var { spawn } = require("child_process");
|
|
13
13
|
var { resolveOsUserInfo } = require("../../os-users");
|
|
14
|
+
var modelFamilies = require("../../model-families");
|
|
15
|
+
var modelCatalog = require("../../model-catalog");
|
|
14
16
|
|
|
15
17
|
// --- SDK loading ---
|
|
16
18
|
// Async loader (ESM dynamic import, same pattern as current project.js getSDK)
|
|
@@ -89,7 +91,13 @@ function flattenEvent(raw) {
|
|
|
89
91
|
base.yokeType = "turn_start";
|
|
90
92
|
if (evt.message && evt.message.usage) {
|
|
91
93
|
var u = evt.message.usage;
|
|
92
|
-
|
|
94
|
+
// lr-3af675: input_tokens, cache_read_input_tokens, and
|
|
95
|
+
// cache_creation_input_tokens are disjoint (Anthropic prompt-caching
|
|
96
|
+
// docs) and all three occupy the context window. The input_tokens +
|
|
97
|
+
// cache_read_input_tokens sum was correct as far as it went;
|
|
98
|
+
// cache_creation_input_tokens was simply omitted, under-reporting
|
|
99
|
+
// context fill on cache-write-heavy turns.
|
|
100
|
+
base.inputTokens = (u.input_tokens || 0) + (u.cache_read_input_tokens || 0) + (u.cache_creation_input_tokens || 0);
|
|
93
101
|
}
|
|
94
102
|
return base;
|
|
95
103
|
}
|
|
@@ -170,6 +178,14 @@ function flattenEvent(raw) {
|
|
|
170
178
|
base.parentToolId = raw.tool_use_id;
|
|
171
179
|
base.taskId = raw.task_id;
|
|
172
180
|
base.description = raw.description || "";
|
|
181
|
+
// lr-1317b8: parity fields (sdk.d.ts:4060-4082), not yet rendered
|
|
182
|
+
// anywhere (frontend derivation lands in a later task) — carried
|
|
183
|
+
// through now as substrate for CLI-parity labels (e.g. subagent_type
|
|
184
|
+
// is the data behind "PRAX researching...").
|
|
185
|
+
base.subagentType = raw.subagent_type || null;
|
|
186
|
+
base.taskType = raw.task_type || null;
|
|
187
|
+
base.workflowName = raw.workflow_name || null;
|
|
188
|
+
base.skipTranscript = !!raw.skip_transcript;
|
|
173
189
|
return base;
|
|
174
190
|
}
|
|
175
191
|
if (raw.subtype === "task_progress") {
|
|
@@ -180,6 +196,39 @@ function flattenEvent(raw) {
|
|
|
180
196
|
base.lastToolName = raw.last_tool_name || null;
|
|
181
197
|
base.description = raw.description || "";
|
|
182
198
|
base.summary = raw.summary || null;
|
|
199
|
+
// lr-1317b8: parity field (sdk.d.ts:4038-4058).
|
|
200
|
+
base.subagentType = raw.subagent_type || null;
|
|
201
|
+
return base;
|
|
202
|
+
}
|
|
203
|
+
// lr-1317b8 (Defect 3): the SDK emits task_notification as a SYSTEM
|
|
204
|
+
// SUBTYPE (sdk.d.ts:4020-4036), not a top-level message type. The old
|
|
205
|
+
// top-level raw.type === "task_notification" check below never matched
|
|
206
|
+
// anything real, so this event fell through to the generic catch-all,
|
|
207
|
+
// was silently relabeled yokeType:"system", and the drain path in
|
|
208
|
+
// sdk-message-processor.js (subagent_done + taskIdMap cleanup) never
|
|
209
|
+
// ran on the Claude path. See lr-255e comment #8.
|
|
210
|
+
if (raw.subtype === "task_notification") {
|
|
211
|
+
base.yokeType = "task_notification";
|
|
212
|
+
base.parentToolId = raw.tool_use_id;
|
|
213
|
+
base.taskId = raw.task_id;
|
|
214
|
+
base.status = raw.status || "completed";
|
|
215
|
+
base.summary = raw.summary || "";
|
|
216
|
+
base.usage = raw.usage || null;
|
|
217
|
+
// lr-1317b8: parity field (sdk.d.ts:4033).
|
|
218
|
+
base.skipTranscript = !!raw.skip_transcript;
|
|
219
|
+
return base;
|
|
220
|
+
}
|
|
221
|
+
// lr-1317b8 (Defect 4): task_updated was branched on by
|
|
222
|
+
// sdk-message-processor.js but no adapter ever produced it — the SDK
|
|
223
|
+
// emits it as {type:'system', subtype:'task_updated'} (sdk.d.ts:4084-
|
|
224
|
+
// 4101) carrying a wire-safe patch (status/description/end_time/
|
|
225
|
+
// total_paused_ms/error/is_backgrounded). Without this branch,
|
|
226
|
+
// updateSubagentTaskStatus's failed/killed drain (tools.js:2152-2154)
|
|
227
|
+
// was unreachable.
|
|
228
|
+
if (raw.subtype === "task_updated") {
|
|
229
|
+
base.yokeType = "task_updated";
|
|
230
|
+
base.taskId = raw.task_id;
|
|
231
|
+
base.patch = raw.patch || {};
|
|
183
232
|
return base;
|
|
184
233
|
}
|
|
185
234
|
// Catch-all system event
|
|
@@ -235,22 +284,32 @@ function flattenEvent(raw) {
|
|
|
235
284
|
return base;
|
|
236
285
|
}
|
|
237
286
|
|
|
238
|
-
//
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
base.parentToolId = raw.parent_tool_use_id;
|
|
242
|
-
base.taskId = raw.task_id;
|
|
243
|
-
base.status = raw.status || "completed";
|
|
244
|
-
base.summary = raw.summary || "";
|
|
245
|
-
base.usage = raw.usage || null;
|
|
246
|
-
return base;
|
|
247
|
-
}
|
|
287
|
+
// Note: task_notification has no top-level raw.type — the SDK emits it as
|
|
288
|
+
// {type:'system', subtype:'task_notification'} (sdk.d.ts:4020-4036), and
|
|
289
|
+
// that case is handled in the system-events branch above (lr-1317b8).
|
|
248
290
|
|
|
249
291
|
// --- tool_progress ---
|
|
292
|
+
// lr-1317b8 (Defect 1): SDKToolProgressMessage (sdk.d.ts:4115-4124) has NO
|
|
293
|
+
// `content` field — it carries tool_use_id, tool_name, parent_tool_use_id,
|
|
294
|
+
// elapsed_time_seconds, task_id. The old `raw.content || ""` read was
|
|
295
|
+
// always undefined, so text was always "". Downstream, subagent_activity
|
|
296
|
+
// was emitted with text:"" (sdk-message-processor.js), updateSubagentActivity
|
|
297
|
+
// called ctx.setActivity(""), and "" is falsy, so setActivity took its
|
|
298
|
+
// clear branch and destroyed the indicator — a raise-site that was
|
|
299
|
+
// secretly a clear-site. Fix: derive text from tool_name + elapsed_time_seconds.
|
|
250
300
|
if (raw.type === "tool_progress") {
|
|
251
301
|
base.yokeType = "tool_progress";
|
|
252
302
|
base.parentToolId = raw.parent_tool_use_id;
|
|
253
|
-
base.
|
|
303
|
+
base.toolName = raw.tool_name || null;
|
|
304
|
+
base.elapsedTimeSeconds = typeof raw.elapsed_time_seconds === "number" ? raw.elapsed_time_seconds : null;
|
|
305
|
+
base.taskId = raw.task_id || null;
|
|
306
|
+
if (raw.tool_name && typeof raw.elapsed_time_seconds === "number") {
|
|
307
|
+
base.text = raw.tool_name + " (" + Math.round(raw.elapsed_time_seconds) + "s)";
|
|
308
|
+
} else if (raw.tool_name) {
|
|
309
|
+
base.text = raw.tool_name;
|
|
310
|
+
} else {
|
|
311
|
+
base.text = "";
|
|
312
|
+
}
|
|
254
313
|
return base;
|
|
255
314
|
}
|
|
256
315
|
|
|
@@ -358,12 +417,15 @@ function createQueryHandle(rawQuery, messageQueue, abortController) {
|
|
|
358
417
|
return Promise.resolve(null);
|
|
359
418
|
},
|
|
360
419
|
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
420
|
+
// lr-d91ecf: a per-query supportedModels() used to live here, but it was
|
|
421
|
+
// not part of the documented QueryHandle contract (see
|
|
422
|
+
// yoke/interface.js's QUERY_HANDLE_METHODS) and had no caller anywhere
|
|
423
|
+
// in the codebase — the worker variant was a pure Promise.resolve([])
|
|
424
|
+
// stub that never round-tripped through IPC. Model lists are fetched via
|
|
425
|
+
// the adapter-level supportedModels() (populated at init/warmup and
|
|
426
|
+
// cached), which every real caller (sdk-bridge.js, project.js) already
|
|
427
|
+
// uses. Removed rather than "fixed" to avoid adding a documented surface
|
|
428
|
+
// for a capability nothing needs per-query.
|
|
367
429
|
|
|
368
430
|
abort: function() {
|
|
369
431
|
if (abortController) {
|
|
@@ -732,6 +794,16 @@ function createWorkerQueryHandle(worker, canUseTool, onElicitation, callMcpTool)
|
|
|
732
794
|
// requestId and holds { resolve, reject } of the in-flight Promise.
|
|
733
795
|
var pendingRewinds = {};
|
|
734
796
|
|
|
797
|
+
// lr-f22787: same correlation pattern as pendingRewinds, for setModel.
|
|
798
|
+
// Without this, an invalid/unentitled model ID sent to a worker session
|
|
799
|
+
// failed silently — the worker-side handleSetModel() (claude-worker.js)
|
|
800
|
+
// already caught the SDK rejection and reported it via a "worker_error"
|
|
801
|
+
// message, but the daemon-side setModel() below returned
|
|
802
|
+
// Promise.resolve() immediately without ever waiting for that reply, so
|
|
803
|
+
// the failure had no path back to the caller (sdk-bridge.js's setModel,
|
|
804
|
+
// then project-sessions.js) to surface to the user.
|
|
805
|
+
var pendingSetModel = {};
|
|
806
|
+
|
|
735
807
|
function pushToIter(value) {
|
|
736
808
|
if (iterEnded) return;
|
|
737
809
|
if (iterWaiting) {
|
|
@@ -833,14 +905,40 @@ function createWorkerQueryHandle(worker, canUseTool, onElicitation, callMcpTool)
|
|
|
833
905
|
break;
|
|
834
906
|
|
|
835
907
|
case "context_usage":
|
|
836
|
-
case "model_changed":
|
|
837
908
|
case "effort_changed":
|
|
838
909
|
case "permission_mode_changed":
|
|
839
|
-
case "worker_error":
|
|
840
910
|
// Yield these as _worker_meta events so processQueryStream can handle them
|
|
841
911
|
pushToIter({ type: "_worker_meta", subtype: msg.type, data: msg });
|
|
842
912
|
break;
|
|
843
913
|
|
|
914
|
+
case "model_changed":
|
|
915
|
+
// lr-f22787: still yielded as a _worker_meta event (unchanged
|
|
916
|
+
// consumer contract for sdk-bridge.js), AND resolves the pending
|
|
917
|
+
// setModel() promise correlated by requestId, if present. Older
|
|
918
|
+
// worker builds that don't echo requestId simply leave the pending
|
|
919
|
+
// map untouched — pushToIter below is unaffected either way.
|
|
920
|
+
pushToIter({ type: "_worker_meta", subtype: msg.type, data: msg });
|
|
921
|
+
if (msg.requestId && pendingSetModel[msg.requestId]) {
|
|
922
|
+
var smOk = pendingSetModel[msg.requestId];
|
|
923
|
+
delete pendingSetModel[msg.requestId];
|
|
924
|
+
smOk.resolve();
|
|
925
|
+
}
|
|
926
|
+
break;
|
|
927
|
+
|
|
928
|
+
case "worker_error":
|
|
929
|
+
// Yielded as a _worker_meta event (unchanged consumer contract), AND
|
|
930
|
+
// rejects the pending setModel() promise when this worker_error
|
|
931
|
+
// belongs to an in-flight set_model request (lr-f22787). worker_error
|
|
932
|
+
// is also used for effort/permission-mode failures, which carry no
|
|
933
|
+
// requestId and so never match a pendingSetModel entry.
|
|
934
|
+
pushToIter({ type: "_worker_meta", subtype: msg.type, data: msg });
|
|
935
|
+
if (msg.requestId && pendingSetModel[msg.requestId]) {
|
|
936
|
+
var smErr = pendingSetModel[msg.requestId];
|
|
937
|
+
delete pendingSetModel[msg.requestId];
|
|
938
|
+
smErr.reject(new Error(msg.error || "Failed to set model"));
|
|
939
|
+
}
|
|
940
|
+
break;
|
|
941
|
+
|
|
844
942
|
case "rewind_files_response": {
|
|
845
943
|
var rp = pendingRewinds[msg.requestId];
|
|
846
944
|
if (rp) {
|
|
@@ -929,9 +1027,21 @@ function createWorkerQueryHandle(worker, canUseTool, onElicitation, callMcpTool)
|
|
|
929
1027
|
worker.send({ type: "push_message", content: userMsg });
|
|
930
1028
|
},
|
|
931
1029
|
|
|
1030
|
+
// lr-f22787: correlated by requestId (mirrors rewindFiles below) so the
|
|
1031
|
+
// returned promise reflects the worker's real outcome — a rejected
|
|
1032
|
+
// model ID rejects this promise instead of resolving immediately
|
|
1033
|
+
// regardless of whether the SDK accepted it.
|
|
932
1034
|
setModel: function(model) {
|
|
933
|
-
|
|
934
|
-
return Promise
|
|
1035
|
+
var requestId = crypto.randomUUID();
|
|
1036
|
+
return new Promise(function(resolve, reject) {
|
|
1037
|
+
pendingSetModel[requestId] = { resolve: resolve, reject: reject };
|
|
1038
|
+
try {
|
|
1039
|
+
worker.send({ type: "set_model", requestId: requestId, model: model });
|
|
1040
|
+
} catch (e) {
|
|
1041
|
+
delete pendingSetModel[requestId];
|
|
1042
|
+
reject(e);
|
|
1043
|
+
}
|
|
1044
|
+
});
|
|
935
1045
|
},
|
|
936
1046
|
|
|
937
1047
|
setEffort: function(effort) {
|
|
@@ -959,9 +1069,9 @@ function createWorkerQueryHandle(worker, canUseTool, onElicitation, callMcpTool)
|
|
|
959
1069
|
return Promise.resolve(null);
|
|
960
1070
|
},
|
|
961
1071
|
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
1072
|
+
// lr-d91ecf: per-query supportedModels() removed — see the matching
|
|
1073
|
+
// comment in createQueryHandle above. This stub never round-tripped
|
|
1074
|
+
// through worker IPC and had no caller.
|
|
965
1075
|
|
|
966
1076
|
abort: function() {
|
|
967
1077
|
console.log("[yoke/claude] ABORT sent to worker pid=" + (worker.process ? worker.process.pid : "?"));
|
|
@@ -1010,65 +1120,106 @@ function createWorkerQueryHandle(worker, canUseTool, onElicitation, callMcpTool)
|
|
|
1010
1120
|
}
|
|
1011
1121
|
|
|
1012
1122
|
|
|
1013
|
-
// --- Model enrichment ---
|
|
1014
|
-
//
|
|
1015
|
-
//
|
|
1016
|
-
//
|
|
1017
|
-
//
|
|
1018
|
-
|
|
1123
|
+
// --- Model enrichment (lr-af9d66) ---
|
|
1124
|
+
//
|
|
1125
|
+
// stream.supportedModels() (SDK >=0.3.x) returns rich ModelInfo objects, not
|
|
1126
|
+
// bare ID strings — verified directly against the live CLI (claude-agent-sdk
|
|
1127
|
+
// 0.3.173 / claudeCodeVersion 2.1.173): every entry carries at minimum
|
|
1128
|
+
// {value, displayName, description}, and MAY carry supportsEffort,
|
|
1129
|
+
// supportedEffortLevels, supportsAdaptiveThinking, supportsFastMode,
|
|
1130
|
+
// supportsAutoMode. A model the vendor says nothing about for a given field
|
|
1131
|
+
// (e.g. haiku today reports no effort/thinking keys at all) omits that key
|
|
1132
|
+
// entirely rather than sending false — so "vendor said no" and "vendor said
|
|
1133
|
+
// nothing" are different wire shapes, and must stay distinguishable through
|
|
1134
|
+
// enrichment rather than being silently collapsed into the same boolean.
|
|
1135
|
+
//
|
|
1136
|
+
// enrichClaudeModel is the ONE place that resolves "vendor said nothing" to
|
|
1137
|
+
// a concrete UI value (see FAIL-OPEN rationale below) — do not duplicate
|
|
1138
|
+
// this fallback decision elsewhere.
|
|
1139
|
+
//
|
|
1140
|
+
// The historical claim that this branch was unreachable (bare ID strings
|
|
1141
|
+
// only) does not hold against the currently pinned SDK version; see PR body
|
|
1142
|
+
// for the reproduction. Kept as a defensive plain-string branch below in case
|
|
1143
|
+
// a future SDK/CLI combination or a worker-relayed shape ever regresses to
|
|
1144
|
+
// bare strings.
|
|
1145
|
+
|
|
1146
|
+
// Fallback-only (lr-af9d66, same discipline as KNOWN_CONTEXT_WINDOWS and
|
|
1147
|
+
// CODEX_DEFAULT_MODELS — lr-d91ecf): consulted only when a model's
|
|
1148
|
+
// supportedEffortLevels is absent or empty in the vendor response. A
|
|
1149
|
+
// vendor-reported list always wins outright when present (see
|
|
1150
|
+
// enrichClaudeModel below) — this table exists purely to cover the case
|
|
1151
|
+
// where the vendor reports no levels at all, not as the primary source.
|
|
1019
1152
|
var CLAUDE_EFFORT_LEVELS = ["low", "medium", "high", "xhigh", "max"];
|
|
1020
1153
|
|
|
1021
|
-
//
|
|
1022
|
-
//
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
// Sonnet 4.x
|
|
1032
|
-
{ key: "claude-sonnet-4-5", label: "Sonnet 4.5" },
|
|
1033
|
-
{ key: "claude-sonnet-4-6", label: "Sonnet 4.6" },
|
|
1034
|
-
{ key: "claude-sonnet-4", label: "Sonnet 4" },
|
|
1035
|
-
{ key: "claude-sonnet-3-7", label: "Sonnet 3.7" },
|
|
1036
|
-
{ key: "claude-sonnet-3-5", label: "Sonnet 3.5" },
|
|
1037
|
-
{ key: "claude-sonnet-3", label: "Sonnet 3" },
|
|
1038
|
-
// Haiku 4.x
|
|
1039
|
-
{ key: "claude-haiku-3-5", label: "Haiku 3.5" },
|
|
1040
|
-
{ key: "claude-haiku-3", label: "Haiku 3" },
|
|
1041
|
-
// Generic family fallbacks
|
|
1042
|
-
{ key: "opus", label: "Opus" },
|
|
1043
|
-
{ key: "sonnet", label: "Sonnet" },
|
|
1044
|
-
{ key: "haiku", label: "Haiku" },
|
|
1045
|
-
];
|
|
1046
|
-
|
|
1047
|
-
function claudeDisplayName(modelId) {
|
|
1048
|
-
var lower = modelId.toLowerCase();
|
|
1049
|
-
// Strip pinned-version suffix like "[1m]"
|
|
1050
|
-
var clean = lower.replace(/\[.*?\]$/, "").trim();
|
|
1051
|
-
for (var i = 0; i < CLAUDE_MODEL_DISPLAY_NAMES.length; i++) {
|
|
1052
|
-
if (clean.indexOf(CLAUDE_MODEL_DISPLAY_NAMES[i].key) !== -1) {
|
|
1053
|
-
return CLAUDE_MODEL_DISPLAY_NAMES[i].label;
|
|
1054
|
-
}
|
|
1055
|
-
}
|
|
1056
|
-
// Fallback: strip "claude-" prefix, title-case remainder
|
|
1057
|
-
return modelId.replace(/^claude-/i, "");
|
|
1058
|
-
}
|
|
1154
|
+
// Display name, thinking/effort capability heuristics, and family/version
|
|
1155
|
+
// parsing all live in ../../model-families.js (lr-d91ecf) — the single
|
|
1156
|
+
// shared location also consumed by the frontend (settings-defaults.js,
|
|
1157
|
+
// app-panels.js) via its ESM twin, lib/public/modules/model-families.js.
|
|
1158
|
+
// No hardcoded per-ID display-name table: claudeDisplayName derives the
|
|
1159
|
+
// label from the parsed family + version, so an ID this code has never seen
|
|
1160
|
+
// still gets a sane label with zero code changes here.
|
|
1161
|
+
var claudeDisplayName = modelFamilies.claudeDisplayName;
|
|
1162
|
+
var claudeModelSupportsThinking = modelFamilies.claudeModelSupportsThinking;
|
|
1163
|
+
var claudeModelSupportsEffort = modelFamilies.claudeModelSupportsEffort;
|
|
1059
1164
|
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1165
|
+
/**
|
|
1166
|
+
* Resolve a capability flag from vendor-reported data, falling back to the
|
|
1167
|
+
* family-substring heuristic when the vendor field is absent OR malformed.
|
|
1168
|
+
*
|
|
1169
|
+
* FAIL-OPEN, BY DESIGN (lr-af9d66): when the vendor is silent, this resolves
|
|
1170
|
+
* to whatever the heuristic says (which itself defaults to true for any
|
|
1171
|
+
* unrecognized family — see model-families.js:153-161). A brand-new family
|
|
1172
|
+
* the parser has never seen therefore gets full capabilities on day one with
|
|
1173
|
+
* zero code change, the same property lr-e03635 built for latest/older
|
|
1174
|
+
* tiering. The alternative (fail-closed: unknown === unsupported) would
|
|
1175
|
+
* silently strip thinking/effort from every new tier until someone updates
|
|
1176
|
+
* the parser, which is worse than an occasional false positive on a model
|
|
1177
|
+
* that turns out not to support a flag — the operator-observed case (fable)
|
|
1178
|
+
* is a fail-open success story, not a bug. This function is the ONLY place
|
|
1179
|
+
* that makes that call; do not re-derive it elsewhere.
|
|
1180
|
+
*
|
|
1181
|
+
* STRICT BOOLEAN, BY DESIGN: a present field is only trusted as a real
|
|
1182
|
+
* vendor determination when it is literally `true` or `false`. A present
|
|
1183
|
+
* field holding a truthy-but-non-boolean value (a string, a number, an
|
|
1184
|
+
* object) is treated the SAME as an absent field — vendor silence, not a
|
|
1185
|
+
* "supported" reading via loose `!!` coercion. This is deliberate, not an
|
|
1186
|
+
* oversight: lr-af9d66's whole thesis is that "vendor said nothing" must
|
|
1187
|
+
* stay distinguishable from "vendor made a real determination" rather than
|
|
1188
|
+
* collapsing into one boolean. A malformed value is closer to "we received
|
|
1189
|
+
* garbage we don't understand" than to an affirmative "yes" — coercing it
|
|
1190
|
+
* to true would silently reintroduce the same indistinguishability at the
|
|
1191
|
+
* value layer that hasOwnProperty already fixed at the key-presence layer.
|
|
1192
|
+
*
|
|
1193
|
+
* @param {object} model - rich model object from the vendor
|
|
1194
|
+
* @param {string} vendorField - field name the vendor actually uses (e.g. "supportsAdaptiveThinking")
|
|
1195
|
+
* @param {function(string): boolean} heuristic - family-substring fallback (model-families.js)
|
|
1196
|
+
* @param {string} value - raw model ID, passed to the heuristic
|
|
1197
|
+
* @returns {boolean}
|
|
1198
|
+
*/
|
|
1199
|
+
function resolveClaudeCapability(model, vendorField, heuristic, value) {
|
|
1200
|
+
if (Object.prototype.hasOwnProperty.call(model, vendorField)) {
|
|
1201
|
+
var reported = model[vendorField];
|
|
1202
|
+
if (reported === true || reported === false) return reported;
|
|
1203
|
+
// Present but not a real boolean — treat as vendor silence, not "yes".
|
|
1204
|
+
}
|
|
1205
|
+
return heuristic(value);
|
|
1064
1206
|
}
|
|
1065
1207
|
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1208
|
+
/**
|
|
1209
|
+
* True iff `levels` is a non-empty array of strings — the shape
|
|
1210
|
+
* enrichClaudeModel requires before trusting it over the static fallback.
|
|
1211
|
+
* A malformed value (non-array, empty array, or an array containing a
|
|
1212
|
+
* non-string entry) is rejected wholesale rather than partially trusted;
|
|
1213
|
+
* see resolveClaudeCapability's doc comment for why "malformed" is treated
|
|
1214
|
+
* as "vendor didn't tell us," not coerced into a partial truth.
|
|
1215
|
+
* @param {*} levels
|
|
1216
|
+
* @returns {boolean}
|
|
1217
|
+
*/
|
|
1218
|
+
function isValidEffortLevelsList(levels) {
|
|
1219
|
+
if (!Array.isArray(levels) || levels.length === 0) return false;
|
|
1220
|
+
for (var i = 0; i < levels.length; i++) {
|
|
1221
|
+
if (typeof levels[i] !== "string") return false;
|
|
1222
|
+
}
|
|
1072
1223
|
return true;
|
|
1073
1224
|
}
|
|
1074
1225
|
|
|
@@ -1082,15 +1233,55 @@ function enrichClaudeModel(model) {
|
|
|
1082
1233
|
// Already a rich object — passthrough but ensure all fields present
|
|
1083
1234
|
if (model && typeof model === "object") {
|
|
1084
1235
|
var v = model.value || "";
|
|
1085
|
-
|
|
1236
|
+
// Vendor displayName (e.g. "Fable", "Sonnet") is a bare family label with
|
|
1237
|
+
// no version — pass description through to claudeDisplayName so the
|
|
1238
|
+
// fallback derivation (used when displayName is absent) can recover a
|
|
1239
|
+
// real version number from it for an alias-only value (lr-5c07ce).
|
|
1240
|
+
var enriched = {
|
|
1086
1241
|
value: v,
|
|
1087
|
-
displayName: model.displayName || claudeDisplayName(v),
|
|
1088
|
-
supportsEffort:
|
|
1089
|
-
|
|
1090
|
-
|
|
1242
|
+
displayName: model.displayName || claudeDisplayName(v, model.description),
|
|
1243
|
+
// supportsEffort: vendor field name matches ours — no translation needed.
|
|
1244
|
+
supportsEffort: resolveClaudeCapability(model, "supportsEffort", claudeModelSupportsEffort, v),
|
|
1245
|
+
// supportedEffortLevels: reported list wins outright when present,
|
|
1246
|
+
// non-empty, AND every entry is a string — the same "malformed reads
|
|
1247
|
+
// as silence, not as a real determination" rule as
|
|
1248
|
+
// resolveClaudeCapability above, applied to an array shape instead of
|
|
1249
|
+
// a boolean one. CLAUDE_EFFORT_LEVELS is the documented fallback-only
|
|
1250
|
+
// static table (lr-af9d66 tertiary item — see its declaration above).
|
|
1251
|
+
supportedEffortLevels: isValidEffortLevelsList(model.supportedEffortLevels)
|
|
1252
|
+
? model.supportedEffortLevels
|
|
1253
|
+
: CLAUDE_EFFORT_LEVELS,
|
|
1254
|
+
// supportsThinking: the vendor's actual field is "supportsAdaptiveThinking"
|
|
1255
|
+
// (confirmed against the live CLI — see the enrichment comment above).
|
|
1256
|
+
// "supportsThinking" is also checked for forward/backward compat in case
|
|
1257
|
+
// a future or older CLI build uses that name instead.
|
|
1258
|
+
supportsThinking: Object.prototype.hasOwnProperty.call(model, "supportsThinking")
|
|
1259
|
+
? resolveClaudeCapability(model, "supportsThinking", claudeModelSupportsThinking, v)
|
|
1260
|
+
: resolveClaudeCapability(model, "supportsAdaptiveThinking", claudeModelSupportsThinking, v),
|
|
1091
1261
|
};
|
|
1262
|
+
// isLatest is derived across the whole model list (enrichClaudeModels),
|
|
1263
|
+
// not per-model — but preserve an explicitly-set value on passthrough so
|
|
1264
|
+
// a caller that already computed tiering isn't silently overridden.
|
|
1265
|
+
if (Object.prototype.hasOwnProperty.call(model, "isLatest")) enriched.isLatest = model.isLatest;
|
|
1266
|
+
// lr-f22787: fromCatalog marks an entry that came from the release-time
|
|
1267
|
+
// generated catalog rather than the vendor's live enumeration — the
|
|
1268
|
+
// picker uses this to show a small non-blocking "Catalog" marker (PR
|
|
1269
|
+
// body point (c): shown, never hidden, but visually distinguished from
|
|
1270
|
+
// a live-confirmed-current entry).
|
|
1271
|
+
if (model.fromCatalog) enriched.fromCatalog = true;
|
|
1272
|
+
// lr-f22787 (coordinator follow-up): carry the retired/deprecated
|
|
1273
|
+
// marking applied by model-catalog.js's applyRetiredMarking straight
|
|
1274
|
+
// through enrichment — these fields are set upstream (mergeStaticCatalog
|
|
1275
|
+
// in this file), not derived here, so this is a passthrough, not a
|
|
1276
|
+
// second source of truth.
|
|
1277
|
+
if (model.status) enriched.status = model.status;
|
|
1278
|
+
if (model.isRetired) enriched.isRetired = true;
|
|
1279
|
+
if (model.isDeprecated) enriched.isDeprecated = true;
|
|
1280
|
+
if (model.disabled) enriched.disabled = true;
|
|
1281
|
+
return enriched;
|
|
1092
1282
|
}
|
|
1093
|
-
// Plain string
|
|
1283
|
+
// Plain string — defensive fallback, see enrichment comment above for why
|
|
1284
|
+
// this is not expected to be the live path against current SDK versions.
|
|
1094
1285
|
var value = String(model || "");
|
|
1095
1286
|
return {
|
|
1096
1287
|
value: value,
|
|
@@ -1101,15 +1292,107 @@ function enrichClaudeModel(model) {
|
|
|
1101
1292
|
};
|
|
1102
1293
|
}
|
|
1103
1294
|
|
|
1295
|
+
// --- Latest/older tier derivation (lr-e03635) ---
|
|
1296
|
+
//
|
|
1297
|
+
// No hardcoded model IDs or names: the split is derived purely from the ID
|
|
1298
|
+
// pattern (family substring + numeric version ordering). A model release
|
|
1299
|
+
// that lands with a higher version number in an already-known family, or as
|
|
1300
|
+
// a brand-new family, is automatically "latest" with zero code changes here.
|
|
1301
|
+
//
|
|
1302
|
+
// Parsing/derivation itself lives in ../../model-families.js (lr-d91ecf) —
|
|
1303
|
+
// the shared location also consumed by the frontend's ESM twin
|
|
1304
|
+
// (lib/public/modules/model-families.js). Do not add another copy elsewhere.
|
|
1305
|
+
|
|
1306
|
+
var deriveClaudeLatestTiers = modelFamilies.deriveClaudeLatestTiers;
|
|
1307
|
+
|
|
1308
|
+
// --- Static catalog merge (lr-f22787) ---
|
|
1309
|
+
//
|
|
1310
|
+
// The live vendor list (`models` below) only ever contains the current
|
|
1311
|
+
// alias set (opus/sonnet/haiku/fable) — see model-catalog.js's header
|
|
1312
|
+
// comment for the full empirical trail. Older, still-runnable versioned IDs
|
|
1313
|
+
// (e.g. claude-opus-4-5) come from a release-time-generated catalog file
|
|
1314
|
+
// (lib/generated/claude-model-catalog.json) merged in here, BEFORE tiering,
|
|
1315
|
+
// so catalog-only entries flow through exactly the same enrichment/
|
|
1316
|
+
// latest-older derivation as live entries — no separate code path, no
|
|
1317
|
+
// separate display logic. A catalog read failure (missing/corrupt file)
|
|
1318
|
+
// degrades to "no extra entries merged," never an exception — see
|
|
1319
|
+
// loadClaudeModelCatalog's doc comment.
|
|
1320
|
+
// lr-d3817f: retired entries are filtered out of the CATALOG before merge
|
|
1321
|
+
// (never just marked/disabled — see model-catalog.js's header comment and
|
|
1322
|
+
// filterSelectableCatalogModels) so they never reach the live list on any
|
|
1323
|
+
// surface, collapsed or expanded.
|
|
1324
|
+
function mergeStaticCatalog(models) {
|
|
1325
|
+
var catalog = modelCatalog.loadClaudeModelCatalog();
|
|
1326
|
+
if (!catalog.ok || !catalog.models.length) return models;
|
|
1327
|
+
var selectable = modelCatalog.filterSelectableCatalogModels(catalog.models);
|
|
1328
|
+
if (!selectable.length) return models;
|
|
1329
|
+
var merged = modelCatalog.mergeModelCatalog(models, selectable);
|
|
1330
|
+
// Deprecated (not retired) entries still get their marker — they still
|
|
1331
|
+
// run, so they stay in the list, just visually distinguished.
|
|
1332
|
+
return modelCatalog.applyRetiredMarking(merged);
|
|
1333
|
+
}
|
|
1334
|
+
|
|
1335
|
+
// enrichClaudeModels stays a PURE function of its input list (lr-e03635/
|
|
1336
|
+
// lr-af9d66/lr-5c07ce regression tests call it directly with a closed-world
|
|
1337
|
+
// synthetic model list and assert on that exact set — merging in
|
|
1338
|
+
// filesystem-backed catalog data unconditionally inside this function would
|
|
1339
|
+
// silently change what those tests are asserting against, which is exactly
|
|
1340
|
+
// the "never modify existing tests" rule this repo enforces). Static catalog
|
|
1341
|
+
// merging + alias reconciliation live in the separate wrapper below,
|
|
1342
|
+
// enrichClaudeModelsWithCatalog, which ONLY the real adapter.init()/
|
|
1343
|
+
// warmup_done code paths call — the one place a live vendor list actually
|
|
1344
|
+
// needs augmenting with release-time-generated data.
|
|
1104
1345
|
function enrichClaudeModels(models) {
|
|
1105
1346
|
if (!models || !models.length) return models;
|
|
1347
|
+
var latestTiers = deriveClaudeLatestTiers(models);
|
|
1106
1348
|
var result = [];
|
|
1107
1349
|
for (var i = 0; i < models.length; i++) {
|
|
1108
|
-
|
|
1350
|
+
var enriched = enrichClaudeModel(models[i]);
|
|
1351
|
+
if (!Object.prototype.hasOwnProperty.call(enriched, "isLatest")) {
|
|
1352
|
+
enriched.isLatest = latestTiers[enriched.value] !== false;
|
|
1353
|
+
}
|
|
1354
|
+
result.push(enriched);
|
|
1109
1355
|
}
|
|
1110
1356
|
return result;
|
|
1111
1357
|
}
|
|
1112
1358
|
|
|
1359
|
+
// lr-f22787 (behavior corrected by lr-d3817f): the real adapter-facing
|
|
1360
|
+
// entry point. Merges the release-time static catalog so the "Older
|
|
1361
|
+
// models" disclosure can offer real, still-runnable versioned IDs the
|
|
1362
|
+
// vendor's live enumeration never lists — see model-catalog.js's header
|
|
1363
|
+
// comment for why supportedModels() alone is not the full universe
|
|
1364
|
+
// (lr-f22787's original motivation, still valid).
|
|
1365
|
+
//
|
|
1366
|
+
// lr-d3817f CORRECTION: the collapsed/default view must show the vendor's
|
|
1367
|
+
// own alias list EXACTLY as it rendered before lr-f22787 touched this path
|
|
1368
|
+
// — Default/Opus/Fable/Sonnet/Haiku, never a raw versioned catalog ID, and
|
|
1369
|
+
// never an alias whose value has been silently substituted for a concrete
|
|
1370
|
+
// ID (the old reconcileAliasesWithCatalogIds — removed). Achieving that
|
|
1371
|
+
// means the live alias list and the catalog-only list are TIERED AS TWO
|
|
1372
|
+
// COMPLETELY SEPARATE GROUPS, not just enriched together and patched
|
|
1373
|
+
// after the fact by family/version comparison:
|
|
1374
|
+
// - every live-sourced entry is forced isLatest:true (mirroring the
|
|
1375
|
+
// pre-lr-f22787 world, where the live list had nothing else to compare
|
|
1376
|
+
// against within its own family) — the collapsed tier is ALWAYS
|
|
1377
|
+
// exactly the live alias set, regardless of what versions the catalog
|
|
1378
|
+
// happens to contain (even a catalog entry that would otherwise be the
|
|
1379
|
+
// numerically highest version in its family must NOT bump a live
|
|
1380
|
+
// alias out of, or itself into, the collapsed tier).
|
|
1381
|
+
// - every catalog-sourced entry is forced isLatest:false — it always
|
|
1382
|
+
// belongs in the "Older models" expansion, never the collapsed view,
|
|
1383
|
+
// even if it happens to be the highest version the catalog knows
|
|
1384
|
+
// about for its family. The alias already occupies that family's
|
|
1385
|
+
// collapsed slot.
|
|
1386
|
+
function enrichClaudeModelsWithCatalog(models) {
|
|
1387
|
+
if (!models || !models.length) return models;
|
|
1388
|
+
var withCatalog = mergeStaticCatalog(models);
|
|
1389
|
+
var enriched = enrichClaudeModels(withCatalog);
|
|
1390
|
+
for (var i = 0; i < enriched.length; i++) {
|
|
1391
|
+
enriched[i].isLatest = !enriched[i].fromCatalog;
|
|
1392
|
+
}
|
|
1393
|
+
return enriched;
|
|
1394
|
+
}
|
|
1395
|
+
|
|
1113
1396
|
|
|
1114
1397
|
// --- Adapter factory ---
|
|
1115
1398
|
|
|
@@ -1517,7 +1800,7 @@ function createClaudeAdapter(opts) {
|
|
|
1517
1800
|
|
|
1518
1801
|
try {
|
|
1519
1802
|
var models = await stream.supportedModels();
|
|
1520
|
-
result.models =
|
|
1803
|
+
result.models = enrichClaudeModelsWithCatalog(models || []);
|
|
1521
1804
|
_cachedModels = result.models;
|
|
1522
1805
|
} catch (e) {
|
|
1523
1806
|
// supportedModels may fail, models list will be empty
|
|
@@ -1574,7 +1857,7 @@ function createClaudeAdapter(opts) {
|
|
|
1574
1857
|
if (msg.type === "warmup_done" && !warmupDone) {
|
|
1575
1858
|
warmupDone = true;
|
|
1576
1859
|
var r = msg.result || {};
|
|
1577
|
-
var enrichedModels =
|
|
1860
|
+
var enrichedModels = enrichClaudeModelsWithCatalog(r.models || []);
|
|
1578
1861
|
_cachedModels = enrichedModels;
|
|
1579
1862
|
resolve({
|
|
1580
1863
|
models: enrichedModels,
|
|
@@ -1616,5 +1899,18 @@ module.exports = {
|
|
|
1616
1899
|
// Test seam for hop-A diagnostic routing (lr-0868): allows test/diagnostic-routing-lr-0868.test.js
|
|
1617
1900
|
// to call flattenEvent directly without spawning a worker process.
|
|
1618
1901
|
_test_flattenEvent: flattenEvent,
|
|
1902
|
+
// Test seams for lr-e03635 latest/older model tiering: exercise the pure
|
|
1903
|
+
// enrichment/derivation functions directly without spinning up the SDK.
|
|
1904
|
+
_test_enrichClaudeModels: enrichClaudeModels,
|
|
1905
|
+
_test_enrichClaudeModel: enrichClaudeModel,
|
|
1906
|
+
_test_deriveClaudeLatestTiers: deriveClaudeLatestTiers,
|
|
1907
|
+
// Test seams for lr-f22787 (behavior corrected by lr-d3817f): static
|
|
1908
|
+
// catalog merge, exercised directly without touching the filesystem-
|
|
1909
|
+
// backed catalog loader or spinning up the SDK. (Alias/description
|
|
1910
|
+
// reconciliation, reconcileAliasesWithCatalogIds, was removed by
|
|
1911
|
+
// lr-d3817f — the collapsed picker view must show the vendor's own
|
|
1912
|
+
// alias untouched, not a substituted concrete ID.)
|
|
1913
|
+
_test_mergeStaticCatalog: mergeStaticCatalog,
|
|
1914
|
+
_test_enrichClaudeModelsWithCatalog: enrichClaudeModelsWithCatalog,
|
|
1619
1915
|
};
|
|
1620
1916
|
|