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