@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
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
// settings-defaults.js — Shared rendering for model/mode/effort/thinking controls
|
|
2
2
|
// Used by both server-settings.js and project-settings.js
|
|
3
3
|
|
|
4
|
+
import { refreshIcons } from './icons.js';
|
|
5
|
+
import { isSonnetModel } from './model-families.js';
|
|
6
|
+
|
|
4
7
|
export var MODE_OPTIONS = [
|
|
5
8
|
{ value: "default", label: "Default", desc: "Claude asks for permission before running tools and editing files." },
|
|
6
9
|
{ value: "plan", label: "Plan", desc: "Claude creates a plan first and asks for approval before making changes." },
|
|
@@ -25,7 +28,8 @@ export var MODEL_DESCRIPTIONS = {
|
|
|
25
28
|
"default": "Automatically selects the best model for the task.",
|
|
26
29
|
"sonnet": "Fast and capable. Great balance of speed and intelligence.",
|
|
27
30
|
"haiku": "Fastest model. Best for quick tasks and simple questions.",
|
|
28
|
-
"opus": "
|
|
31
|
+
"opus": "Highly capable. Best for complex reasoning and analysis.",
|
|
32
|
+
"fable": "Anthropic's most capable model. Best for the hardest problems.",
|
|
29
33
|
// Codex/OpenAI families
|
|
30
34
|
"gpt-5.5": "Latest GPT-5.5. Frontier model for complex coding and agentic workflows.",
|
|
31
35
|
"gpt-5.4": "GPT-5.4. Strong reasoning and agentic coding.",
|
|
@@ -49,33 +53,125 @@ export function getModelDesc(model) {
|
|
|
49
53
|
return "";
|
|
50
54
|
}
|
|
51
55
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
+
// isSonnetModel re-exported from ./model-families.js (lr-d91ecf) — the
|
|
57
|
+
// single shared family-detection module also consumed by app-panels.js.
|
|
58
|
+
// Re-exported (not just imported) because server-settings.js imports it
|
|
59
|
+
// from this module directly.
|
|
60
|
+
export { isSonnetModel };
|
|
61
|
+
|
|
62
|
+
// --- Render functions ---
|
|
63
|
+
// Each takes an element ID prefix (e.g. "ss" or "ps"), a send function, and state getters.
|
|
56
64
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
65
|
+
// lr-db0437: every model/mode picker surface must state the scope it
|
|
66
|
+
// applies to ("This session only" / "Default for new sessions in this
|
|
67
|
+
// project" / "Server default" / loop-scoped) — model-scope honesty was the
|
|
68
|
+
// point of this task, not just the plumbing fix. Single shared renderer so
|
|
69
|
+
// each surface (session chip, project settings, server settings, Ralph-loop,
|
|
70
|
+
// scheduler) gets identical markup/behavior; each call site just passes its
|
|
71
|
+
// own static scope string via opts.scopeLabel.
|
|
72
|
+
export function renderScopeLabel(prefix, scopeLabel) {
|
|
73
|
+
var el = document.getElementById(prefix + "-model-scope");
|
|
74
|
+
if (!el) return;
|
|
75
|
+
if (scopeLabel) {
|
|
76
|
+
el.textContent = scopeLabel;
|
|
77
|
+
el.style.display = "";
|
|
78
|
+
} else {
|
|
79
|
+
el.style.display = "none";
|
|
80
|
+
}
|
|
60
81
|
}
|
|
61
82
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
83
|
+
// lr-e03635: split a models array into { latest, older } tiers.
|
|
84
|
+
//
|
|
85
|
+
// Both vendor adapters attach isLatest per model at the source (Codex from
|
|
86
|
+
// model/list's "upgrade" field, Claude from runtime ID version-ordering — see
|
|
87
|
+
// lib/yoke/adapters/claude.js deriveClaudeLatestTiers). A model with no
|
|
88
|
+
// isLatest field at all (an older/unenriched shape) is treated as latest —
|
|
89
|
+
// never hidden by a field it doesn't carry.
|
|
90
|
+
//
|
|
91
|
+
// Single shared partition function so every picker surface (renderModelList
|
|
92
|
+
// below and app-panels.js's session-chip rebuildModelList) applies identical
|
|
93
|
+
// tiering logic.
|
|
94
|
+
export function splitModelsByTier(models) {
|
|
95
|
+
var latest = [];
|
|
96
|
+
var older = [];
|
|
97
|
+
for (var i = 0; i < (models || []).length; i++) {
|
|
98
|
+
var m = models[i];
|
|
99
|
+
var isLatest = (m && typeof m === "object") ? (m.isLatest !== false) : true;
|
|
100
|
+
if (isLatest) latest.push(m);
|
|
101
|
+
else older.push(m);
|
|
102
|
+
}
|
|
103
|
+
return { latest: latest, older: older };
|
|
65
104
|
}
|
|
66
105
|
|
|
67
|
-
//
|
|
68
|
-
//
|
|
106
|
+
// Build one `.settings-model-item` row. Shared by the always-visible latest
|
|
107
|
+
// list and the collapsible older-models body so both render identically.
|
|
108
|
+
function buildModelItem(m, currentModel, listEl, opts) {
|
|
109
|
+
var value = m.value || "";
|
|
110
|
+
var label = m.displayName || value;
|
|
111
|
+
var item = document.createElement("div");
|
|
112
|
+
// lr-d3817f: a retired catalog entry is filtered out entirely upstream
|
|
113
|
+
// (model-catalog.js's filterSelectableCatalogModels) and never reaches
|
|
114
|
+
// this function — there is no isRetired/disabled row rendering here
|
|
115
|
+
// anymore. Only deprecated (still-runnable) entries carry a marker.
|
|
116
|
+
item.className = "settings-model-item" + (value === currentModel ? " active" : "");
|
|
117
|
+
item.dataset.model = value;
|
|
118
|
+
|
|
119
|
+
var nameSpan = document.createElement("span");
|
|
120
|
+
nameSpan.className = "settings-model-name";
|
|
121
|
+
nameSpan.textContent = label;
|
|
122
|
+
item.appendChild(nameSpan);
|
|
123
|
+
|
|
124
|
+
// lr-f22787: entries sourced from the release-time-generated catalog
|
|
125
|
+
// (not the vendor's live enumeration) get a small non-blocking marker —
|
|
126
|
+
// shown, never hidden, so the operator can still pick an older version
|
|
127
|
+
// while knowing it wasn't independently confirmed by this session's live
|
|
128
|
+
// vendor check.
|
|
129
|
+
if (m && m.fromCatalog) {
|
|
130
|
+
var catalogBadge = document.createElement("span");
|
|
131
|
+
catalogBadge.className = "settings-model-catalog-badge";
|
|
132
|
+
catalogBadge.textContent = "Catalog";
|
|
133
|
+
item.appendChild(catalogBadge);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
// lr-f22787: deprecated (not retired) entries still run — marker only,
|
|
137
|
+
// no disabling. Retired entries never reach this function (lr-d3817f).
|
|
138
|
+
if (m && m.isDeprecated) {
|
|
139
|
+
var deprecatedBadge = document.createElement("span");
|
|
140
|
+
deprecatedBadge.className = "settings-model-deprecated-badge";
|
|
141
|
+
deprecatedBadge.textContent = "Deprecated";
|
|
142
|
+
item.appendChild(deprecatedBadge);
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
var desc = getModelDesc(value);
|
|
146
|
+
if (desc) {
|
|
147
|
+
var descSpan = document.createElement("span");
|
|
148
|
+
descSpan.className = "settings-model-desc";
|
|
149
|
+
descSpan.textContent = desc;
|
|
150
|
+
item.appendChild(descSpan);
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
item.addEventListener("click", function () {
|
|
154
|
+
opts.sendMsg(opts.modelMsgType, { model: value });
|
|
155
|
+
var items = listEl.querySelectorAll(".settings-model-item");
|
|
156
|
+
for (var j = 0; j < items.length; j++) items[j].classList.remove("active");
|
|
157
|
+
item.classList.add("active");
|
|
158
|
+
if (opts.onModelSelect) opts.onModelSelect(value);
|
|
159
|
+
});
|
|
160
|
+
|
|
161
|
+
return item;
|
|
162
|
+
}
|
|
69
163
|
|
|
70
164
|
/**
|
|
71
165
|
* Render model list into `${prefix}-model-list`
|
|
72
166
|
* @param {string} prefix - Element ID prefix
|
|
73
|
-
* @param {object} opts - { models, currentModel, sendMsg, onModelSelect }
|
|
167
|
+
* @param {object} opts - { models, currentModel, sendMsg, onModelSelect, scopeLabel }
|
|
74
168
|
*/
|
|
75
169
|
export function renderModelList(prefix, opts) {
|
|
76
170
|
var listEl = document.getElementById(prefix + "-model-list");
|
|
77
171
|
if (!listEl) return;
|
|
78
172
|
|
|
173
|
+
renderScopeLabel(prefix, opts.scopeLabel);
|
|
174
|
+
|
|
79
175
|
var models = opts.models || [];
|
|
80
176
|
var currentModel = opts.currentModel || "";
|
|
81
177
|
|
|
@@ -85,38 +181,52 @@ export function renderModelList(prefix, opts) {
|
|
|
85
181
|
return;
|
|
86
182
|
}
|
|
87
183
|
|
|
88
|
-
|
|
89
|
-
(function (m) {
|
|
90
|
-
var value = m.value || "";
|
|
91
|
-
var label = m.displayName || value;
|
|
92
|
-
var item = document.createElement("div");
|
|
93
|
-
item.className = "settings-model-item" + (value === currentModel ? " active" : "");
|
|
94
|
-
item.dataset.model = value;
|
|
184
|
+
var tiers = splitModelsByTier(models);
|
|
95
185
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
item.appendChild(nameSpan);
|
|
186
|
+
for (var i = 0; i < tiers.latest.length; i++) {
|
|
187
|
+
listEl.appendChild(buildModelItem(tiers.latest[i], currentModel, listEl, opts));
|
|
188
|
+
}
|
|
100
189
|
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
190
|
+
// lr-e03635: empty-disclosure rule — if the vendor reports no older
|
|
191
|
+
// models, the disclosure must be ABSENT, not present-and-empty.
|
|
192
|
+
if (tiers.older.length > 0) {
|
|
193
|
+
// Reuse the existing in-section collapsible "Advanced" disclosure pattern
|
|
194
|
+
// (aria-expanded toggle + hidden body) rather than inventing a new one —
|
|
195
|
+
// see lib/public/index.html's settings-advanced-memory-toggle/-body for
|
|
196
|
+
// the reference implementation this mirrors.
|
|
197
|
+
var toggle = document.createElement("button");
|
|
198
|
+
toggle.type = "button";
|
|
199
|
+
toggle.className = "settings-older-models-toggle";
|
|
200
|
+
toggle.setAttribute("aria-expanded", "false");
|
|
201
|
+
|
|
202
|
+
var toggleLabel = document.createElement("span");
|
|
203
|
+
toggleLabel.textContent = "Older models";
|
|
204
|
+
toggle.appendChild(toggleLabel);
|
|
205
|
+
|
|
206
|
+
var chevron = document.createElement("i");
|
|
207
|
+
chevron.setAttribute("data-lucide", "chevron-right");
|
|
208
|
+
chevron.className = "settings-adv-chevron";
|
|
209
|
+
toggle.appendChild(chevron);
|
|
210
|
+
|
|
211
|
+
var body = document.createElement("div");
|
|
212
|
+
body.className = "settings-older-models-body hidden";
|
|
213
|
+
|
|
214
|
+
for (var k = 0; k < tiers.older.length; k++) {
|
|
215
|
+
body.appendChild(buildModelItem(tiers.older[k], currentModel, listEl, opts));
|
|
216
|
+
}
|
|
108
217
|
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
});
|
|
218
|
+
toggle.addEventListener("click", function () {
|
|
219
|
+
var isOpen = !body.classList.contains("hidden");
|
|
220
|
+
body.classList.toggle("hidden", isOpen);
|
|
221
|
+
toggle.setAttribute("aria-expanded", String(!isOpen));
|
|
222
|
+
chevron.style.transform = isOpen ? "" : "rotate(90deg)";
|
|
223
|
+
});
|
|
116
224
|
|
|
117
|
-
|
|
118
|
-
|
|
225
|
+
listEl.appendChild(toggle);
|
|
226
|
+
listEl.appendChild(body);
|
|
119
227
|
}
|
|
228
|
+
|
|
229
|
+
refreshIcons(listEl);
|
|
120
230
|
}
|
|
121
231
|
|
|
122
232
|
/**
|
|
@@ -24,6 +24,16 @@ var inPlanMode = false;
|
|
|
24
24
|
var planContent = null;
|
|
25
25
|
var currentPlanCardEl = null;
|
|
26
26
|
|
|
27
|
+
// --- Backgrounded subagent (Task tool) liveness tracking ---
|
|
28
|
+
// lr-255e: the parent turn's SDK stream ends with a normal 'result' message
|
|
29
|
+
// as soon as a Task tool call is dispatched -- the Task itself keeps running
|
|
30
|
+
// as a background child. app-messages.js's 'result' handler unconditionally
|
|
31
|
+
// called setActivity(null), which killed the "thinking dots" indicator even
|
|
32
|
+
// though a subagent was still actively working. Tracking live subagents here
|
|
33
|
+
// (keyed by parentToolId, the same id used for the stop-button dedup guard)
|
|
34
|
+
// lets callers ask hasActiveSubagents() before clearing the indicator.
|
|
35
|
+
var activeSubagentToolIds = {};
|
|
36
|
+
|
|
27
37
|
// --- Todo state ---
|
|
28
38
|
var todoItems = [];
|
|
29
39
|
var todoWidgetEl = null;
|
|
@@ -2008,6 +2018,20 @@ export function markAllToolsDone() {
|
|
|
2008
2018
|
}
|
|
2009
2019
|
|
|
2010
2020
|
// --- Sub-agent (Task tool) log ---
|
|
2021
|
+
|
|
2022
|
+
// lr-255e: whether any backgrounded Task subagent is still running for the
|
|
2023
|
+
// current session. Callers (e.g. app-messages.js's 'result' handler) use
|
|
2024
|
+
// this to decide whether it's safe to clear the "thinking dots" indicator —
|
|
2025
|
+
// the parent turn's own stream can end while a dispatched subagent keeps
|
|
2026
|
+
// working, and the indicator must stay up until the LAST live subagent
|
|
2027
|
+
// actually finishes.
|
|
2028
|
+
export function hasActiveSubagents() {
|
|
2029
|
+
for (var id in activeSubagentToolIds) {
|
|
2030
|
+
if (activeSubagentToolIds.hasOwnProperty(id)) return true;
|
|
2031
|
+
}
|
|
2032
|
+
return false;
|
|
2033
|
+
}
|
|
2034
|
+
|
|
2011
2035
|
export function updateSubagentActivity(parentToolId, text) {
|
|
2012
2036
|
var tool = tools[parentToolId];
|
|
2013
2037
|
if (!tool || !tool.el) return;
|
|
@@ -2107,6 +2131,7 @@ export function updateSubagentProgress(parentToolId, usage, lastToolName, summar
|
|
|
2107
2131
|
}
|
|
2108
2132
|
|
|
2109
2133
|
export function initSubagentStop(parentToolId, taskId) {
|
|
2134
|
+
activeSubagentToolIds[parentToolId] = true;
|
|
2110
2135
|
var tool = tools[parentToolId];
|
|
2111
2136
|
if (!tool || !tool.el) return;
|
|
2112
2137
|
var header = tool.el.querySelector(".tool-header");
|
|
@@ -2124,6 +2149,9 @@ export function initSubagentStop(parentToolId, taskId) {
|
|
|
2124
2149
|
}
|
|
2125
2150
|
|
|
2126
2151
|
export function updateSubagentTaskStatus(parentToolId, patch) {
|
|
2152
|
+
if (patch.status === "failed" || patch.status === "killed") {
|
|
2153
|
+
delete activeSubagentToolIds[parentToolId];
|
|
2154
|
+
}
|
|
2127
2155
|
var tool = tools[parentToolId];
|
|
2128
2156
|
if (!tool || !tool.el) return;
|
|
2129
2157
|
if (patch.description) {
|
|
@@ -2147,6 +2175,15 @@ export function updateSubagentTaskStatus(parentToolId, patch) {
|
|
|
2147
2175
|
}
|
|
2148
2176
|
|
|
2149
2177
|
export function markSubagentDone(parentToolId, status, summary, usage) {
|
|
2178
|
+
delete activeSubagentToolIds[parentToolId];
|
|
2179
|
+
// lr-255e: the parent turn's 'result' already fired (and, per hasActiveSubagents(),
|
|
2180
|
+
// may have skipped clearing the indicator because this subagent was still live).
|
|
2181
|
+
// Once the last live subagent finishes, clear the indicator here too so it
|
|
2182
|
+
// doesn't linger until some unrelated later message happens to null it out.
|
|
2183
|
+
if (!hasActiveSubagents()) {
|
|
2184
|
+
ctx.setActivity(null);
|
|
2185
|
+
}
|
|
2186
|
+
|
|
2150
2187
|
var tool = tools[parentToolId];
|
|
2151
2188
|
if (!tool || !tool.el) return;
|
|
2152
2189
|
|
|
@@ -2272,6 +2309,7 @@ export function resetToolState() {
|
|
|
2272
2309
|
currentToolGroup = null;
|
|
2273
2310
|
toolGroupCounter = 0;
|
|
2274
2311
|
toolGroups = {};
|
|
2312
|
+
activeSubagentToolIds = {};
|
|
2275
2313
|
// NOTE: do NOT reset _lastCumulativeCost here — it must persist across
|
|
2276
2314
|
// turns so addTurnMeta can compute per-turn deltas. It is only cleared
|
|
2277
2315
|
// on new conversation via resetTurnMetaCost().
|
package/lib/sdk-bridge.js
CHANGED
|
@@ -14,6 +14,8 @@ var { buildEnrichedSlashCommands } = require("./sdk-slash-enrichment");
|
|
|
14
14
|
var { KNOWN_CONTEXT_WINDOWS: _BACKEND_KNOWN_CONTEXT_WINDOWS, resolveModelContextWindow } = require("./model-context-windows");
|
|
15
15
|
var { runPreflight } = require("./settings-preflight");
|
|
16
16
|
var { partitionSubagentOwnedPermissions, retainPreservedTaskBookkeeping, sweepClearedPermissionIndex } = require("./sdk-permission-ownership");
|
|
17
|
+
var { permissionGrantKey } = require("./utils");
|
|
18
|
+
var sessionActivity = require("./session-activity");
|
|
17
19
|
|
|
18
20
|
// --- lr-29f9: Global concurrent-session ceiling ---
|
|
19
21
|
// Counts queries that are actively running (startQuery entered, processQueryStream
|
|
@@ -314,6 +316,28 @@ function createSDKBridge(opts) {
|
|
|
314
316
|
installedVendors: sm.installedVendors || [],
|
|
315
317
|
});
|
|
316
318
|
}
|
|
319
|
+
|
|
320
|
+
// lr-041af8: session-scoped counterpart to sendModelInfoForVendor above.
|
|
321
|
+
// A single session's model choice (setModel, or the worker-driven
|
|
322
|
+
// model_changed event) must only update the chip for clients CURRENTLY
|
|
323
|
+
// VIEWING that session — sendModelInfoForVendor's broadcast (send()) was
|
|
324
|
+
// overwriting every other open session's model_info with whatever session
|
|
325
|
+
// last called setModel. Falls back to the broadcast helper when no session
|
|
326
|
+
// is available yet (mirrors setModel's own no-session-vendor-bound branch).
|
|
327
|
+
function sendModelInfoToSession(session, vendor, model) {
|
|
328
|
+
if (!session) {
|
|
329
|
+
sendModelInfoForVendor(vendor, model);
|
|
330
|
+
return;
|
|
331
|
+
}
|
|
332
|
+
sendToSession(session, {
|
|
333
|
+
type: "model_info",
|
|
334
|
+
model: model || "",
|
|
335
|
+
models: getModelsForVendor(vendor),
|
|
336
|
+
vendor: vendor || (adapter && adapter.vendor) || "claude",
|
|
337
|
+
availableVendors: sm.availableVendors || [],
|
|
338
|
+
installedVendors: sm.installedVendors || [],
|
|
339
|
+
});
|
|
340
|
+
}
|
|
317
341
|
var onTurnDone = opts.onTurnDone || null;
|
|
318
342
|
|
|
319
343
|
// --- Idle session reaper ---
|
|
@@ -796,8 +820,10 @@ function createSDKBridge(opts) {
|
|
|
796
820
|
});
|
|
797
821
|
}
|
|
798
822
|
|
|
799
|
-
// Auto-approve if tool was previously allowed for session
|
|
800
|
-
|
|
823
|
+
// Auto-approve if tool was previously allowed for session (lr-f969dc:
|
|
824
|
+
// keyed on toolName + input discriminator, not bare toolName — see
|
|
825
|
+
// permissionGrantKey doc comment for why the Skill tool needs this).
|
|
826
|
+
if (session.allowedTools && session.allowedTools[permissionGrantKey(toolName, input)]) {
|
|
801
827
|
return Promise.resolve({ behavior: "allow", updatedInput: input });
|
|
802
828
|
}
|
|
803
829
|
|
|
@@ -957,9 +983,18 @@ function createSDKBridge(opts) {
|
|
|
957
983
|
sendToSession(session, { type: "context_usage", data: metaData.data });
|
|
958
984
|
break;
|
|
959
985
|
case "model_changed":
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
986
|
+
// lr-041af8: this event is scoped to ONE session's worker
|
|
987
|
+
// (the CLI itself changed model mid-stream, e.g. via a /model
|
|
988
|
+
// slash command) — writing it into the shared sm.currentModel
|
|
989
|
+
// was the same class of leak lr-db0437 fixed for setModel()
|
|
990
|
+
// (see that function's header comment), just in the reverse
|
|
991
|
+
// direction and left unfixed. Session-only write; targeted
|
|
992
|
+
// sends via sendToSession so only clients viewing THIS session
|
|
993
|
+
// see the change, matching every other per-session config_state
|
|
994
|
+
// reply (project-sessions.js's set_model/switch_session).
|
|
995
|
+
session.model = metaData.model;
|
|
996
|
+
sendModelInfoToSession(session, session.vendor || (adapter && adapter.vendor) || "claude", metaData.model);
|
|
997
|
+
sendToSession(session, { type: "config_state", model: metaData.model, mode: sm.currentPermissionMode || "default", effort: sm.currentEffort || "medium", betas: sm.currentBetas || [] });
|
|
963
998
|
break;
|
|
964
999
|
case "effort_changed":
|
|
965
1000
|
sm.currentEffort = metaData.effort;
|
|
@@ -1191,7 +1226,15 @@ function createSDKBridge(opts) {
|
|
|
1191
1226
|
// Auto-continue on rate limit (scheduler sessions, or user setting)
|
|
1192
1227
|
// Mark session as done processing so the late rate_limit_event handler
|
|
1193
1228
|
// can detect the race condition and schedule auto-continue itself.
|
|
1194
|
-
|
|
1229
|
+
//
|
|
1230
|
+
// lr-9bcd7b: mirrors the same reconciliation as the 'result' handler's
|
|
1231
|
+
// setIsProcessingFromRegistry (sdk-message-processor.js) — only clear
|
|
1232
|
+
// isProcessing when the activity registry agrees nothing else (e.g. a
|
|
1233
|
+
// still-active backgrounded Task) is live for this session. This is
|
|
1234
|
+
// the SAME finally block that lr-9d4b already teaches must not
|
|
1235
|
+
// unconditionally wipe subagent-owned bookkeeping; this is the
|
|
1236
|
+
// isProcessing counterpart of that lesson.
|
|
1237
|
+
session.isProcessing = sessionActivity.isSessionActive(session);
|
|
1195
1238
|
}
|
|
1196
1239
|
|
|
1197
1240
|
var didScheduleAutoContinue = false;
|
|
@@ -1574,6 +1617,14 @@ function createSDKBridge(opts) {
|
|
|
1574
1617
|
session.activeTaskToolIds = {};
|
|
1575
1618
|
session.pendingElicitations = {};
|
|
1576
1619
|
session.streamedText = false;
|
|
1620
|
+
// lr-9bcd7b: PRIMARY leak-resistance layer — bump the activity
|
|
1621
|
+
// generation at every startQuery call (turn boundary), same spot
|
|
1622
|
+
// activeTaskToolIds is reset above. Any token from a prior generation
|
|
1623
|
+
// (e.g. a subagent that died silently mid-turn without ever releasing)
|
|
1624
|
+
// becomes invisible to isSessionActive immediately, with no explicit
|
|
1625
|
+
// release or timer needed — see lib/session-activity.js header.
|
|
1626
|
+
var _bumpResult = sessionActivity.bumpGeneration(session);
|
|
1627
|
+
if (_bumpResult.changed) sm.broadcastSessionList();
|
|
1577
1628
|
session.responsePreview = "";
|
|
1578
1629
|
|
|
1579
1630
|
// For in-process path, create AbortController. For worker path, the adapter
|
|
@@ -2052,30 +2103,54 @@ function createSDKBridge(opts) {
|
|
|
2052
2103
|
});
|
|
2053
2104
|
}
|
|
2054
2105
|
|
|
2106
|
+
// lr-db0437: session-only write, mirroring setPermissionMode's pattern
|
|
2107
|
+
// (:2096-2111 below). A per-session model choice must never leak into
|
|
2108
|
+
// sm.currentModel — that field is the project/global DEFAULT, consulted by
|
|
2109
|
+
// new_session when seeding a fresh session (project-sessions.js) and by
|
|
2110
|
+
// startQuery's precedence chain (agent-declared > loop settings >
|
|
2111
|
+
// session.model > sm.currentModel) as the last-resort fallback. Writing it
|
|
2112
|
+
// here made every session's model choice silently become the de-facto
|
|
2113
|
+
// default for every subsequently created session — the root cause this
|
|
2114
|
+
// task fixes. Callers that need to change the actual default (server/
|
|
2115
|
+
// project settings pages) go through onSetServerDefaultModel /
|
|
2116
|
+
// onSetProjectDefaultModel (project-sessions.js) instead, which update
|
|
2117
|
+
// sm.currentModel directly without touching any session.
|
|
2118
|
+
// lr-f22787: returns { ok: true } or { ok: false, error: <message> } so the
|
|
2119
|
+
// caller (project-sessions.js) can tell whether the switch actually
|
|
2120
|
+
// succeeded and reply to the REQUESTING client specifically, instead of
|
|
2121
|
+
// always sending a success-shaped config_state reply regardless of outcome.
|
|
2122
|
+
// A broadcast error is still sent here too (existing behavior other
|
|
2123
|
+
// surfaces may depend on), but it is not a substitute for a targeted reply.
|
|
2055
2124
|
async function setModel(session, model) {
|
|
2056
2125
|
// Normalize to string id in case a { value, displayName } object slips in
|
|
2057
2126
|
if (model && typeof model !== "string") {
|
|
2058
2127
|
model = modelEntryValue(model);
|
|
2059
2128
|
}
|
|
2060
2129
|
if (!session.queryInstance) {
|
|
2061
|
-
// No active query — store on session
|
|
2130
|
+
// No active query — store on session only (not sm — that's for project
|
|
2131
|
+
// defaults, see header comment above).
|
|
2062
2132
|
session.model = model;
|
|
2063
|
-
sm.currentModel = model;
|
|
2064
2133
|
// Don't send vendor here: session vendor not yet bound, let client keep its selection
|
|
2065
|
-
sendModelInfoForVendor
|
|
2134
|
+
// lr-041af8: targeted to this session's own clients — sendModelInfoForVendor
|
|
2135
|
+
// (broadcast) was overwriting every other open session's model_info with
|
|
2136
|
+
// this one's choice on every setModel call.
|
|
2137
|
+
sendModelInfoToSession(session, null, model);
|
|
2066
2138
|
// config_state is sent targeted by the caller (project-sessions.js) to
|
|
2067
2139
|
// avoid broadcasting this session's model to all other open sessions.
|
|
2068
|
-
return;
|
|
2140
|
+
return { ok: true };
|
|
2069
2141
|
}
|
|
2070
2142
|
try {
|
|
2071
2143
|
await session.queryInstance.setModel(model);
|
|
2072
2144
|
session.model = model;
|
|
2073
|
-
sm.currentModel = model;
|
|
2074
2145
|
var sessionVendor = session.vendor || (adapter && adapter.vendor) || "claude";
|
|
2075
|
-
|
|
2146
|
+
// lr-041af8: targeted — see comment in the no-active-query branch above.
|
|
2147
|
+
sendModelInfoToSession(session, sessionVendor, model);
|
|
2076
2148
|
// config_state sent targeted by caller — no broadcast here.
|
|
2149
|
+
return { ok: true };
|
|
2077
2150
|
} catch (e) {
|
|
2078
|
-
|
|
2151
|
+
var errMsg = e.message || String(e);
|
|
2152
|
+
send({ type: "error", text: "Failed to switch model: " + errMsg });
|
|
2153
|
+
return { ok: false, error: errMsg };
|
|
2079
2154
|
}
|
|
2080
2155
|
}
|
|
2081
2156
|
|