@clagentic/console 1.10.0-beta.1 → 1.10.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.
Files changed (68) hide show
  1. package/README.md +1 -1
  2. package/bin/cli.js +10 -0
  3. package/lib/agent-dispatch-tool.js +20 -0
  4. package/lib/build-changes.js +79 -0
  5. package/lib/build-identity.js +192 -0
  6. package/lib/build-monitor.js +125 -0
  7. package/lib/build-sha.json +2 -2
  8. package/lib/build-update-offer.js +141 -0
  9. package/lib/build-update-restart.js +142 -0
  10. package/lib/build-update-standing.js +184 -0
  11. package/lib/cli/daemon-launch.js +8 -5
  12. package/lib/cli/ipc-subcommands.js +6 -0
  13. package/lib/cli/session-subcommands.js +122 -0
  14. package/lib/cli-sessions.js +8 -1
  15. package/lib/codex-defaults.js +8 -2
  16. package/lib/daemon-projects.js +19 -0
  17. package/lib/daemon.js +166 -127
  18. package/lib/memory-shed.js +13 -32
  19. package/lib/project-connection.js +14 -0
  20. package/lib/project-external-trigger.js +91 -123
  21. package/lib/project-loop.js +5 -4
  22. package/lib/project-prompt-responses.js +5 -4
  23. package/lib/project-sessions.js +43 -68
  24. package/lib/project-user-message.js +7 -20
  25. package/lib/project.js +23 -5
  26. package/lib/prompt-registry.js +7 -0
  27. package/lib/public/css/diagnostics.css +30 -0
  28. package/lib/public/modules/agent-dispatch-tool.js +9 -0
  29. package/lib/public/modules/app-messages.js +7 -2
  30. package/lib/public/modules/app-panels.js +0 -1
  31. package/lib/public/modules/build-update-detail.js +54 -0
  32. package/lib/public/modules/diagnostics.js +126 -20
  33. package/lib/public/modules/tools.js +14 -2
  34. package/lib/public/modules/vendor-picker.js +2 -2
  35. package/lib/public/modules/vendor-registry.js +11 -2
  36. package/lib/sdk-bridge.js +62 -15
  37. package/lib/sdk-message-processor.js +11 -20
  38. package/lib/sdk-skill-discovery.js +65 -60
  39. package/lib/server.js +15 -2
  40. package/lib/session-id.js +33 -0
  41. package/lib/session-input-ipc.js +32 -0
  42. package/lib/session-input.js +379 -0
  43. package/lib/session-reclaim.js +284 -0
  44. package/lib/session-resume.js +172 -0
  45. package/lib/sessions.js +16 -2
  46. package/lib/supervisor.js +39 -0
  47. package/lib/turn-initiator.js +108 -0
  48. package/lib/vendor-registry-message.js +1 -0
  49. package/lib/ws-schema.js +3 -1
  50. package/lib/yoke/adapters/claude-vendor.js +0 -1
  51. package/lib/yoke/adapters/claude-worker.js +6 -4
  52. package/lib/yoke/adapters/claude.js +34 -34
  53. package/lib/yoke/adapters/codex-capabilities.js +9 -6
  54. package/lib/yoke/adapters/codex-vendor.js +15 -15
  55. package/lib/yoke/adapters/codex.js +121 -61
  56. package/lib/yoke/auth-checks.js +8 -21
  57. package/lib/yoke/codex-app-server.js +27 -71
  58. package/lib/yoke/codex-binary.js +254 -0
  59. package/lib/yoke/codex-command.js +122 -0
  60. package/lib/yoke/codex-protocol.js +96 -0
  61. package/lib/yoke/codex-version.js +135 -0
  62. package/lib/yoke/index.js +20 -4
  63. package/lib/yoke/install-probe.js +21 -6
  64. package/lib/yoke/interface.js +11 -5
  65. package/lib/yoke/registry.js +41 -4
  66. package/package.json +1 -2
  67. package/scripts/verify-installed-build.js +59 -17
  68. package/lib/lore-attestation.js +0 -73
package/lib/project.js CHANGED
@@ -34,9 +34,11 @@ var { attachMcp } = require("./project-mcp");
34
34
  var { createLocalMcp } = require("./mcp-local");
35
35
  var { attachTeam } = require("./project-team");
36
36
  var runtimeEnv = require("./runtime-env");
37
+ var { INITIATORS } = require("./turn-initiator");
37
38
  var mcpToolSchema = require("./mcp-tool-schema");
38
39
  var { reclaimIdleAdapters } = require("./idle-adapter-reaper");
39
40
  var sessionCapabilities = require("./session-capabilities");
41
+ var sessionReclaim = require("./session-reclaim");
40
42
  var { buildVendorRegistryMessage } = require("./vendor-registry-message");
41
43
  // project-notifications is attached globally in server.js, passed via opts.notificationsModule
42
44
 
@@ -166,7 +168,7 @@ function createProjectContext(opts) {
166
168
  var _liteStatus = detectLite();
167
169
 
168
170
  // --- YOKE adapters (multi-vendor, lazy init) ---
169
- var _yokeState = yoke.createAdapters({ cwd: cwd, slug: slug });
171
+ var _yokeState = yoke.createAdapters({ cwd: cwd, slug: slug, osUsers: osUsers });
170
172
  var adapters = _yokeState.adapters;
171
173
  // The project starts on the most preferred registered agent that is available.
172
174
  var defaultVendor = yoke.registry.defaultVendorId(Object.keys(adapters));
@@ -443,6 +445,8 @@ function createProjectContext(opts) {
443
445
  });
444
446
  sm.availableVendors = Object.keys(adapters);
445
447
  sm.defaultVendor = defaultVendor;
448
+ // Sessions the previous shutdown ended with background agents running.
449
+ sessionReclaim.surfaceRestartReclaims({ sm: sm });
446
450
 
447
451
  var _projMode = typeof opts.onGetProjectDefaultMode === "function" ? opts.onGetProjectDefaultMode(slug) : null;
448
452
  var _srvMode = typeof opts.onGetServerDefaultMode === "function" ? opts.onGetServerDefaultMode() : null;
@@ -577,6 +581,7 @@ function createProjectContext(opts) {
577
581
  var sdk = createSDKBridge({
578
582
  cwd: cwd,
579
583
  slug: slug,
584
+ osUsers: osUsers,
580
585
  sessionManager: sm,
581
586
  send: send,
582
587
  sendVendorRegistry: sendVendorRegistry,
@@ -736,7 +741,7 @@ function createProjectContext(opts) {
736
741
  session.isProcessing = true;
737
742
  onProcessingChanged();
738
743
  sendToSession(session.localId, { type: "status", status: "processing" });
739
- sdk.startQuery(session, text, null, ensureProjectAccessForSession(session));
744
+ sdk.startQuery(session, text, null, ensureProjectAccessForSession(session), INITIATORS.SCHEDULED);
740
745
  sm.broadcastSessionList();
741
746
  }, schedDelay),
742
747
  };
@@ -810,6 +815,7 @@ function createProjectContext(opts) {
810
815
  if (!vendorAdapter) {
811
816
  vendorAdapter = await yoke.lazyCreateAdapter(adapters, requestedVendor, {
812
817
  cwd: cwd,
818
+ osUsers: osUsers,
813
819
  clayPort: serverPort,
814
820
  clayTls: serverTls,
815
821
  clayAuthToken: serverAuthToken,
@@ -1222,11 +1228,23 @@ function createProjectContext(opts) {
1222
1228
  });
1223
1229
 
1224
1230
  // --- Destroy ---
1225
- function destroy() {
1231
+ // opts.reason says why the project is going away. Only a daemon shutdown
1232
+ // (sessionReclaim.RESTART_REASON) records its live background agents as
1233
+ // resumable: removing a project is a deliberate operator act, and its
1234
+ // sessions are not expected to come back. opts.tally, when given, collects
1235
+ // the announcement results so the caller logs one summary per shutdown.
1236
+ function destroy(opts) {
1237
+ var daemonShutdown = !!opts && opts.reason === sessionReclaim.RESTART_REASON;
1238
+ var tally = opts && opts.tally;
1226
1239
  _loop.stopTimer();
1227
1240
  stopAllWatches();
1228
1241
  // Abort all active sessions and clean up mention sessions
1229
1242
  sm.sessions.forEach(function (session) {
1243
+ // Before the abort below drops the agents' registration: the shutdown
1244
+ // kills them, so the session is recorded as resumable.
1245
+ if (daemonShutdown) {
1246
+ sessionReclaim.countShutdownReclaim(tally, sessionReclaim.announceShutdownReclaim(session, sm));
1247
+ }
1230
1248
  session.destroying = true;
1231
1249
  if (session.autoContinueTimer) {
1232
1250
  clearTimeout(session.autoContinueTimer);
@@ -1411,9 +1429,9 @@ function createProjectContext(opts) {
1411
1429
  reclaimIdleAdapters: function (idleMs) {
1412
1430
  return reclaimIdleAdapters(adapters, idleMs);
1413
1431
  },
1414
- destroy: function () {
1432
+ destroy: function (opts) {
1415
1433
  sdk.stopIdleReaper();
1416
- return destroy();
1434
+ return destroy(opts);
1417
1435
  },
1418
1436
  };
1419
1437
  }
@@ -504,6 +504,12 @@ function createPromptRegistry(deps) {
504
504
  });
505
505
  }
506
506
 
507
+ /** The Task id owning a tool call raised by a sub-agent, or null. */
508
+ function ownerTaskOfTool(session, toolUseId) {
509
+ if (!toolUseId) return null;
510
+ return ownValue(toolOwners(session), toolUseId) || null;
511
+ }
512
+
507
513
  function noteSubagentTool(session, toolUseId, taskId) {
508
514
  if (toolUseId && taskId) putOwn(toolOwners(session), toolUseId, taskId);
509
515
  }
@@ -625,6 +631,7 @@ function createPromptRegistry(deps) {
625
631
  cancelSession: cancelSession,
626
632
  shutdown: shutdown,
627
633
  noteSubagentTool: noteSubagentTool,
634
+ ownerTaskOfTool: ownerTaskOfTool,
628
635
  taskStarted: taskStarted,
629
636
  taskEnded: taskEnded,
630
637
  isTaskTracked: isTaskTracked,
@@ -229,6 +229,36 @@
229
229
  }
230
230
  .diagnostics-actionable-btn .lucide { width: 12px; height: 12px; }
231
231
 
232
+ /* A diagnostic's message may be several lines (the sessions a restart would end). */
233
+ .diagnostic-multiline { white-space: pre-line; }
234
+
235
+ /* Body of a "newer build installed" offer: both builds and the commits between them. */
236
+ .build-update-detail {
237
+ display: flex;
238
+ flex-direction: column;
239
+ gap: 3px;
240
+ margin-top: 4px;
241
+ font-size: 11px;
242
+ color: var(--text-secondary);
243
+ overflow-wrap: anywhere;
244
+ }
245
+ .build-update-builds { font-family: var(--font-mono, monospace); }
246
+ .build-update-heading { font-weight: 600; }
247
+ .build-update-commits {
248
+ margin: 0;
249
+ padding-left: 16px;
250
+ max-height: 140px;
251
+ overflow-y: auto;
252
+ }
253
+ .build-update-note { color: var(--text-muted); }
254
+ .diagnostics-actionable-btn.build-update-decline,
255
+ .toast-diagnostic-action-btn.build-update-decline {
256
+ background: transparent;
257
+ color: var(--text-secondary);
258
+ border: 1px solid var(--border, rgba(128, 128, 128, 0.4));
259
+ margin-left: 6px;
260
+ }
261
+
232
262
  /* Empty state */
233
263
  .diagnostics-empty {
234
264
  padding: 20px 14px;
@@ -0,0 +1,9 @@
1
+ // Browser-side copy of lib/agent-dispatch-tool.js (the backend is CJS and the
2
+ // frontend is ESM, so neither can import the other). The claude CLI names the
3
+ // sub-agent dispatch tool "Task" in older builds and "Agent" in current ones;
4
+ // a test asserts both copies accept the same names.
5
+ export var AGENT_DISPATCH_TOOL_NAMES = ["Task", "Agent"];
6
+
7
+ export function isAgentDispatchTool(name) {
8
+ return typeof name === "string" && AGENT_DISPATCH_TOOL_NAMES.indexOf(name) !== -1;
9
+ }
@@ -68,7 +68,7 @@ import { handleSkillInstallWs } from './app-skills-install.js';
68
68
  import { handleNotificationsState, handleNotificationCreated, handleNotificationDismissed, handleNotificationDismissedAll, showUpdateBanner } from './app-notifications.js';
69
69
  import { handleMentionStart, handleMentionActivity, handleMentionStream, handleMentionDone, handleMentionError, renderMentionUser, renderMentionResponse, renderUserMention } from './mention.js';
70
70
  import { handleTeamState, handleTeamMemberUpdate, handleTeamTaskUpdate, handleTeamMessage as handleTeamMsg, handleTeamGone } from './team-panel.js';
71
- import { addDiagnostic } from './diagnostics.js';
71
+ import { addDiagnostic, refreshDiagnostic, retractDiagnostics } from './diagnostics.js';
72
72
  import { handleHistoryMeta, handleHistoryDone } from './app-history-replay.js';
73
73
  import { shouldApplyActivityEdge } from './activity-latch.js';
74
74
  import { deriveSessionListProcessing } from './activity-state.js';
@@ -1297,7 +1297,12 @@ registerHandlers({
1297
1297
  // Diagnostic events from CLI stderr (stage 4/5, lr-8294, epic lr-1a52).
1298
1298
  // Future sources (e.g. settings preflight from stage 5/5 lr-1a26) will
1299
1299
  // also arrive via this same type — the render path must not assume CLI origin.
1300
- addDiagnostic(msg);
1300
+ if (msg.refresh === true) refreshDiagnostic(msg);
1301
+ else addDiagnostic(msg);
1302
+ },
1303
+
1304
+ diagnostic_retract: function (msg) {
1305
+ retractDiagnostics(msg.source);
1301
1306
  },
1302
1307
 
1303
1308
  daemon_config: function (msg) {
@@ -92,7 +92,6 @@ var EFFORT_LEVELS_BY_VENDOR = {
92
92
  var THINKING_OPTIONS = ["disabled", "adaptive", "budget"];
93
93
  var CODEX_APPROVAL_OPTIONS = [
94
94
  { value: "never", label: "Auto" },
95
- { value: "on-failure", label: "On Fail" },
96
95
  { value: "on-request", label: "Ask" },
97
96
  ];
98
97
  var CODEX_SANDBOX_OPTIONS = [
@@ -0,0 +1,54 @@
1
+ // build-update-detail.js — the body of a "newer build installed" diagnostic:
2
+ // which build is running, which is installed, and the commits between them
3
+ // when git history was available. Every value is set with textContent: commit
4
+ // subjects are repository content, never markup.
5
+
6
+ var SHORT_SHA_LENGTH = 12;
7
+
8
+ export function shortSha(sha) {
9
+ return typeof sha === 'string' && sha ? sha.slice(0, SHORT_SHA_LENGTH) : '(unknown)';
10
+ }
11
+
12
+ function line(className, text) {
13
+ var el = document.createElement('div');
14
+ el.className = className;
15
+ el.textContent = text;
16
+ return el;
17
+ }
18
+
19
+ /**
20
+ * @param {{loadedBuildSha: ?string, installedBuildSha: ?string, reason: string,
21
+ * changes: {available: boolean, commits: Array<{sha: string, subject: string}>, truncated: boolean, reason: ?string}}} offer
22
+ * @returns {?HTMLElement} null when the diagnostic carries no offer
23
+ */
24
+ export function buildUpdateDetailEl(offer) {
25
+ if (!offer || typeof offer !== 'object') return null;
26
+ var root = document.createElement('div');
27
+ root.className = 'build-update-detail';
28
+
29
+ root.appendChild(line('build-update-builds',
30
+ 'Running: ' + shortSha(offer.loadedBuildSha) + ' Installed: ' + shortSha(offer.installedBuildSha)));
31
+
32
+ var changes = offer.changes || {};
33
+ if (offer.reason === 'content') {
34
+ root.appendChild(line('build-update-note',
35
+ 'Both report the same build, but the installed files differ from the ones this process loaded.'));
36
+ } else if (changes.available && Array.isArray(changes.commits) && changes.commits.length > 0) {
37
+ root.appendChild(line('build-update-heading', 'Changes since the running build:'));
38
+ var list = document.createElement('ul');
39
+ list.className = 'build-update-commits';
40
+ changes.commits.forEach(function (c) {
41
+ var item = document.createElement('li');
42
+ item.textContent = shortSha(c.sha).slice(0, 8) + ' ' + c.subject;
43
+ list.appendChild(item);
44
+ });
45
+ root.appendChild(list);
46
+ if (changes.truncated) root.appendChild(line('build-update-note', 'More commits not shown.'));
47
+ } else if (changes.available) {
48
+ root.appendChild(line('build-update-note', 'No commits between these builds were found in the available history.'));
49
+ } else {
50
+ root.appendChild(line('build-update-note',
51
+ 'Change list unavailable' + (changes.reason ? ': ' + changes.reason : '') + '.'));
52
+ }
53
+ return root;
54
+ }
@@ -26,17 +26,28 @@
26
26
  import { iconHtml, refreshIcons } from './icons.js';
27
27
  import { formatDiagnosticSource as _formatSource } from './diagnostic-format.js';
28
28
  import { sendWs } from './ws-ref.js';
29
+ import { buildUpdateDetailEl } from './build-update-detail.js';
29
30
 
30
- // lr-e85fec: allowlist of actionable.action values this client will act on.
31
+ // Allowlist of actionable.action values this client will act on.
31
32
  // A diagnostic's `actionable.action` string is never sent to the server
32
33
  // verbatim as a WS message type — only a value in this map is ever wired to
33
34
  // a click, so the backend cannot steer the client into sending an arbitrary
34
35
  // WS command by way of a diagnostic message.
36
+ //
37
+ // Applying an installed build takes two clicks. The first asks the daemon for
38
+ // the offer (what a restart would end); nothing restarts. The offer arrives as
39
+ // another diagnostic carrying a one-use token, and only its "Restart now"
40
+ // sends that token back.
41
+ var CONFIRM_BUILD_UPDATE = 'confirm_build_update_restart';
35
42
  var ACTIONABLE_HANDLERS = {
36
43
  restart_for_build_update: function () { sendWs({ type: 'restart_for_build_update' }); },
44
+ confirm_build_update_restart: function (entry) {
45
+ var token = entry.buildUpdate && entry.buildUpdate.token;
46
+ if (typeof token === 'string' && token) sendWs({ type: 'restart_for_build_update', confirmToken: token });
47
+ },
37
48
  };
38
49
 
39
- // lr-e85fec: shared by both render sites below (panel entry + toast). Returns
50
+ // Shared by both render sites below (panel entry + toast). Returns
40
51
  // a clickable button when entry.actionable.action is a known action, or null
41
52
  // when there is no label or no known handler — callers render their own
42
53
  // existing icon+text hint in the null case, so this only owns the "known
@@ -50,11 +61,22 @@ function _buildActionableEl(entry, btnClass) {
50
61
  btn.textContent = entry.actionable.label;
51
62
  btn.addEventListener("click", function () {
52
63
  btn.disabled = true;
53
- handler();
64
+ handler(entry);
54
65
  });
55
66
  return btn;
56
67
  }
57
68
 
69
+ // The operator declines a restart offer by closing it; "Not now" says so
70
+ // beside the confirm button. Only an offer has one.
71
+ function _buildDeclineEl(entry, btnClass, onDecline) {
72
+ if (!entry.actionable || entry.actionable.action !== CONFIRM_BUILD_UPDATE) return null;
73
+ var btn = document.createElement("button");
74
+ btn.className = btnClass + " build-update-decline";
75
+ btn.textContent = "Not now";
76
+ btn.addEventListener("click", onDecline);
77
+ return btn;
78
+ }
79
+
58
80
  // --- Module state ---
59
81
  var diagnostics = []; // [{id, severity, source, message, actionable, ts}]
60
82
  var panelEl = null;
@@ -164,7 +186,7 @@ export function initDiagnostics() {
164
186
  // Public: add a diagnostic
165
187
  // ============================================================
166
188
 
167
- export function addDiagnostic(msg) {
189
+ export function addDiagnostic(msg, opts) {
168
190
  var now = Date.now();
169
191
 
170
192
  // lr-e901: same condition can arrive via two independent emitters (CLI-stderr
@@ -177,6 +199,7 @@ export function addDiagnostic(msg) {
177
199
  scope: msg.scope || "",
178
200
  message: msg.message || "",
179
201
  actionable: msg.actionable || null,
202
+ buildUpdate: msg.buildUpdate || null,
180
203
  ts: now,
181
204
  id: _nextDiagnosticId++,
182
205
  };
@@ -189,11 +212,73 @@ export function addDiagnostic(msg) {
189
212
  _updateBadge();
190
213
 
191
214
  // Toast for warning and error severity only.
192
- if (entry.severity === "warning" || entry.severity === "error") {
215
+ var toastAllowed = !(opts && opts.toast === false);
216
+ if (toastAllowed && (entry.severity === "warning" || entry.severity === "error")) {
193
217
  _showDiagnosticToast(entry);
194
218
  }
195
219
  }
196
220
 
221
+ /**
222
+ * Updates the entry a source already holds with a newer message (the update
223
+ * offer, once its change list is read). It replaces in place: no second entry,
224
+ * no new toast unless one was on screen, and nothing at all when the operator
225
+ * already dismissed the entry, so a refresh never resurrects a declined offer.
226
+ */
227
+ export function refreshDiagnostic(msg) {
228
+ var source = msg.source || "";
229
+ var action = _actionOf(msg);
230
+ // Only the entry carrying the same action is replaced: the restart
231
+ // confirmation shares the source and must survive a refresh of the offer.
232
+ var held = diagnostics.some(function (entry) { return entry.source === source && _actionOf(entry) === action; });
233
+ if (!held) return;
234
+ var toastOnScreen = _toastsFor(source, action).length > 0;
235
+ retractDiagnostics(source, action);
236
+ addDiagnostic(msg, { toast: toastOnScreen });
237
+ }
238
+
239
+ function _actionOf(entry) {
240
+ return entry && entry.actionable && entry.actionable.action ? entry.actionable.action : "";
241
+ }
242
+
243
+ function _toastsFor(source, action) {
244
+ return Array.prototype.filter.call(
245
+ _getToastContainer().querySelectorAll('[data-diag-source="' + source + '"]'),
246
+ function (el) { return action === undefined || el.getAttribute("data-diag-action") === action; }
247
+ );
248
+ }
249
+
250
+ /**
251
+ * Withdraws every diagnostic from one source: the condition it reported no
252
+ * longer holds, so its action must not stay clickable. Used when the daemon
253
+ * adopts the installed build while an update offer is on screen. With `action`
254
+ * only the entries carrying that action are withdrawn.
255
+ */
256
+ export function retractDiagnostics(source, action) {
257
+ if (!source) return;
258
+ var keep = [];
259
+ var removed = [];
260
+ diagnostics.forEach(function (entry) {
261
+ if (entry.source !== source || (action !== undefined && _actionOf(entry) !== action)) { keep.push(entry); return; }
262
+ removed.push(entry);
263
+ if (panelListEl) {
264
+ var itemEl = panelListEl.querySelector('[data-diag-id="' + entry.id + '"]');
265
+ if (itemEl && itemEl.parentNode) itemEl.parentNode.removeChild(itemEl);
266
+ }
267
+ });
268
+ diagnostics = keep;
269
+ // A repeat of the same condition must show again, not be taken for a duplicate.
270
+ if (action === undefined) {
271
+ Object.keys(_recentDiagnosticKeys).forEach(function (key) {
272
+ if (key.indexOf(source + "|") === 0) delete _recentDiagnosticKeys[key];
273
+ });
274
+ } else {
275
+ removed.forEach(function (entry) { delete _recentDiagnosticKeys[_diagnosticKey(entry)]; });
276
+ }
277
+ _toastsFor(source, action).forEach(_removeDiagnosticToast);
278
+ if (diagnostics.length === 0) _restoreEmptyPlaceholder();
279
+ _updateBadge();
280
+ }
281
+
197
282
  // Re-export the pure formatter so callers that import from this module
198
283
  // can reach it without a second import. Tests should import from
199
284
  // diagnostic-format.js directly (no DOM deps there).
@@ -220,12 +305,34 @@ function _getToastContainer() {
220
305
  return toastContainerEl;
221
306
  }
222
307
 
308
+ // The toast's lower part: the offer detail when the diagnostic carries one,
309
+ // then a known actionable.action as a real button (with "Not now" for an
310
+ // offer), else the plain hint. Returns whether an action button was added.
311
+ function _appendToastActions(el, entry, onDecline) {
312
+ var detailEl = buildUpdateDetailEl(entry.buildUpdate);
313
+ if (detailEl) el.appendChild(detailEl);
314
+ var actionBtn = _buildActionableEl(entry, "toast-diagnostic-action-btn");
315
+ if (actionBtn) {
316
+ el.appendChild(actionBtn);
317
+ var declineBtn = _buildDeclineEl(entry, "toast-diagnostic-action-btn", onDecline);
318
+ if (declineBtn) el.appendChild(declineBtn);
319
+ return true;
320
+ }
321
+ var hintEl = document.createElement("div");
322
+ hintEl.className = "toast-diagnostic-hint";
323
+ hintEl.textContent = "See Diagnostics panel for details";
324
+ el.appendChild(hintEl);
325
+ return false;
326
+ }
327
+
223
328
  function _showDiagnosticToast(entry) {
224
329
  var el = document.createElement("div");
225
330
  // Use a dedicated class so diagnostics are visually distinct from error messages.
226
331
  el.className = "toast toast-diagnostic toast-diagnostic-" + entry.severity;
227
332
  el.setAttribute("role", "alert");
228
333
  el.setAttribute("aria-live", "assertive");
334
+ el.setAttribute("data-diag-source", entry.source);
335
+ el.setAttribute("data-diag-action", _actionOf(entry));
229
336
 
230
337
  var headerEl = document.createElement("div");
231
338
  headerEl.className = "toast-diagnostic-header";
@@ -248,22 +355,15 @@ function _showDiagnosticToast(entry) {
248
355
  headerEl.appendChild(dismissBtn);
249
356
 
250
357
  var msgEl = document.createElement("div");
251
- msgEl.className = "toast-diagnostic-msg";
358
+ msgEl.className = "toast-diagnostic-msg diagnostic-multiline";
252
359
  msgEl.textContent = entry.message;
253
360
 
254
361
  el.appendChild(headerEl);
255
362
  el.appendChild(msgEl);
256
-
257
- // lr-e85fec: known actionable.action -> real button; else the plain hint.
258
- var actionBtn = _buildActionableEl(entry, "toast-diagnostic-action-btn");
259
- if (actionBtn) {
260
- el.appendChild(actionBtn);
261
- } else {
262
- var hintEl = document.createElement("div");
263
- hintEl.className = "toast-diagnostic-hint";
264
- hintEl.textContent = "See Diagnostics panel for details";
265
- el.appendChild(hintEl);
266
- }
363
+ var hasAction = _appendToastActions(el, entry, function () {
364
+ clearTimeout(timer);
365
+ _removeDiagnosticToast(el);
366
+ });
267
367
 
268
368
  _getToastContainer().appendChild(el);
269
369
  refreshIcons();
@@ -273,8 +373,8 @@ function _showDiagnosticToast(entry) {
273
373
 
274
374
  // Auto-dismiss after 6s — EXCEPT when an action button is present: an
275
375
  // operator deciding whether to restart must not have the offer vanish out
276
- // from under them before they've read it (lr-e85fec).
277
- var timer = actionBtn ? null : setTimeout(function () { _removeDiagnosticToast(el); }, 6000);
376
+ // from under them before they've read it.
377
+ var timer = hasAction ? null : setTimeout(function () { _removeDiagnosticToast(el); }, 6000);
278
378
 
279
379
  // Manual dismiss.
280
380
  dismissBtn.addEventListener("click", function () {
@@ -360,11 +460,13 @@ function _appendEntry(entry) {
360
460
  meta.appendChild(dismissBtn);
361
461
 
362
462
  var msgEl = document.createElement("div");
363
- msgEl.className = "diagnostics-message";
463
+ msgEl.className = "diagnostics-message diagnostic-multiline";
364
464
  msgEl.textContent = entry.message;
365
465
 
366
466
  item.appendChild(meta);
367
467
  item.appendChild(msgEl);
468
+ var panelDetail = buildUpdateDetailEl(entry.buildUpdate);
469
+ if (panelDetail) item.appendChild(panelDetail);
368
470
 
369
471
  // Actionable hint: surface label when present. lr-e85fec: a known action
370
472
  // renders as a real button (_buildActionableEl), not just a hint icon — a
@@ -376,6 +478,10 @@ function _appendEntry(entry) {
376
478
  var panelBtn = _buildActionableEl(entry, "diagnostics-actionable-btn");
377
479
  if (panelBtn) {
378
480
  actionEl.appendChild(panelBtn);
481
+ var panelDecline = _buildDeclineEl(entry, "diagnostics-actionable-btn", function () {
482
+ dismissDiagnostic(entry.id);
483
+ });
484
+ if (panelDecline) actionEl.appendChild(panelDecline);
379
485
  } else {
380
486
  var fixIcon = document.createElement("span");
381
487
  fixIcon.className = "diagnostics-actionable-icon";
@@ -7,6 +7,7 @@ import { getChatLayout } from './theme.js';
7
7
  import { store } from './store.js';
8
8
  import { VENDOR_NAMES } from './app-rendering.js';
9
9
  import { createPromptController } from './prompts.js';
10
+ import { isAgentDispatchTool } from './agent-dispatch-tool.js';
10
11
 
11
12
  var ctx;
12
13
 
@@ -92,10 +93,21 @@ function toolGroupSummary(group) {
92
93
  counts[names[i]] = (counts[names[i]] || 0) + 1;
93
94
  }
94
95
  var uniqueNames = Object.keys(counts);
96
+ // A group mixing "Task" and "Agent" dispatches is still one kind of tool.
97
+ var dispatchKinds = uniqueNames.filter(isAgentDispatchTool);
98
+ if (dispatchKinds.length > 1 && dispatchKinds.length === uniqueNames.length) {
99
+ var dispatchTotal = 0;
100
+ dispatchKinds.forEach(function (k) { dispatchTotal += counts[k]; });
101
+ uniqueNames = ["Task"];
102
+ counts = { Task: dispatchTotal };
103
+ }
95
104
 
96
105
  if (uniqueNames.length === 1) {
97
106
  var name = uniqueNames[0];
107
+ // Read the count under the name it was tallied with, then pick the label
108
+ // family: an Agent-only group has no "Task" entry in counts.
98
109
  var n = counts[name];
110
+ if (isAgentDispatchTool(name)) name = "Task";
99
111
  if (allDone) {
100
112
  switch (name) {
101
113
  case "Read": return "Read " + n + " file" + (n > 1 ? "s" : "");
@@ -169,6 +181,7 @@ function isPlanFile(filePath) {
169
181
 
170
182
  export function toolSummary(name, input) {
171
183
  if (!input || typeof input !== "object") return "";
184
+ if (isAgentDispatchTool(name)) return input.description || "";
172
185
  switch (name) {
173
186
  case "Read": return shortPath(input.file_path);
174
187
  case "Edit": return shortPath(input.file_path);
@@ -178,7 +191,6 @@ export function toolSummary(name, input) {
178
191
  case "Grep": return (input.pattern || "") + (input.path ? " in " + shortPath(input.path) : "");
179
192
  case "WebFetch": return input.url || "";
180
193
  case "WebSearch": return input.query || "";
181
- case "Task": return input.description || "";
182
194
  case "EnterPlanMode": return "";
183
195
  case "ExitPlanMode": return "";
184
196
  default: return JSON.stringify(input).substring(0, 60);
@@ -194,7 +206,7 @@ export function toolActivityText(name, input) {
194
206
  if (name === "Glob" && input && input.pattern) return "Finding " + input.pattern;
195
207
  if (name === "WebSearch" && input && input.query) return "Searching: " + input.query;
196
208
  if (name === "WebFetch") return "Fetching URL...";
197
- if (name === "Task" && input && input.description) return input.description;
209
+ if (isAgentDispatchTool(name) && input && input.description) return input.description;
198
210
  if (name === "EnterPlanMode") return "Entering plan mode...";
199
211
  if (name === "ExitPlanMode") return "Finalizing the plan...";
200
212
  return "Running " + name + "...";
@@ -32,10 +32,10 @@ export function renderVendorPicker(container, rows, actions) {
32
32
  label.className = "vendor-toggle-label";
33
33
  label.textContent = row.displayName;
34
34
  btn.appendChild(label);
35
- if (row.checkFailed) {
35
+ if (row.checkFailed || row.version) {
36
36
  var note = document.createElement("span");
37
37
  note.className = "vendor-toggle-note";
38
- note.textContent = "Could not check";
38
+ note.textContent = row.checkFailed ? "Could not check" : row.version;
39
39
  btn.appendChild(note);
40
40
  }
41
41
  btn.addEventListener("click", function () { actions.onSelect(row.id); });
@@ -83,7 +83,9 @@ export function capabilityGate(key) {
83
83
  var value = caps[key];
84
84
  var enabled = Array.isArray(value) ? value.length > 0 : value === true;
85
85
  var reasons = store.get('capabilityReasons') || {};
86
- return { enabled: enabled, reason: enabled ? "" : (reasons[key] || "This agent does not support this.") };
86
+ var entry = vendorEntry(store.get('currentVendor') || defaultVendorId());
87
+ var own = entry && entry.capabilityReasons ? entry.capabilityReasons[key] : "";
88
+ return { enabled: enabled, reason: enabled ? "" : (own || reasons[key] || "This agent does not support this.") };
87
89
  }
88
90
 
89
91
  function escapeAttr(text) {
@@ -112,14 +114,20 @@ export function loginCommandFor(vendorId) {
112
114
  * The picker's rows, one per registered agent.
113
115
  * An agent whose install lookup failed is not reported as missing: its row says
114
116
  * the check could not be made, with the failure class.
115
- * @returns {Array<{id: string, displayName: string, icon: string, installed: boolean, checkFailed: boolean, active: boolean, title: string}>}
117
+ * An agent that is not usable says why when its probe knows (not installed, too
118
+ * old, an override that points nowhere); one that is usable says which binary
119
+ * and version will run.
120
+ * @returns {Array<{id: string, displayName: string, icon: string, installed: boolean, checkFailed: boolean, active: boolean, version: string, title: string}>}
116
121
  */
117
122
  export function pickerRows(vendors, current) {
118
123
  return (vendors || []).map(function (v) {
119
124
  var checkFailed = !v.installed && !!v.probeFailure;
125
+ var detail = v.installDetail || {};
120
126
  var title = v.displayName;
121
127
  if (checkFailed) title = v.displayName + ". Could not check: " + v.probeFailure + ". Use Re-check to try again.";
128
+ else if (!v.installed && detail.reason) title = v.displayName + ". " + detail.reason;
122
129
  else if (!v.installed) title = v.displayName + " is not installed. " + v.installHint;
130
+ else if (detail.version) title = v.displayName + " " + detail.version + (detail.path ? " (" + detail.path + ")" : "");
123
131
  return {
124
132
  id: v.id,
125
133
  displayName: v.displayName,
@@ -127,6 +135,7 @@ export function pickerRows(vendors, current) {
127
135
  installed: !!v.installed,
128
136
  checkFailed: checkFailed,
129
137
  active: v.id === current,
138
+ version: v.installed && detail.version ? detail.version : "",
130
139
  title: title,
131
140
  };
132
141
  });