@clagentic/console 1.9.0 → 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 (172) hide show
  1. package/LICENSE +117 -12
  2. package/LICENSES/MIT-legacy.txt +22 -0
  3. package/LICENSES/README.md +15 -0
  4. package/README.md +9 -3
  5. package/bin/cli.js +40 -5
  6. package/deploy/clagentic-console.service +10 -6
  7. package/lib/agent-dispatch-tool.js +20 -0
  8. package/lib/audit.js +3 -2
  9. package/lib/build-changes.js +79 -0
  10. package/lib/build-identity.js +192 -0
  11. package/lib/build-monitor.js +125 -0
  12. package/lib/build-sha.json +2 -2
  13. package/lib/build-update-check.js +138 -0
  14. package/lib/build-update-offer.js +141 -0
  15. package/lib/build-update-restart.js +142 -0
  16. package/lib/build-update-standing.js +184 -0
  17. package/lib/cli/daemon-launch.js +25 -22
  18. package/lib/cli/ipc-subcommands.js +6 -0
  19. package/lib/cli/session-subcommands.js +122 -0
  20. package/lib/cli-sessions.js +8 -1
  21. package/lib/codex-defaults.js +8 -2
  22. package/lib/config.js +32 -20
  23. package/lib/daemon-env-settings.js +84 -0
  24. package/lib/daemon-projects.js +57 -0
  25. package/lib/daemon.js +288 -205
  26. package/lib/drain.js +74 -17
  27. package/lib/env-compat.js +61 -0
  28. package/lib/extension-commands.js +45 -0
  29. package/lib/history-visibility.js +4 -0
  30. package/lib/idle-adapter-reaper.js +71 -0
  31. package/lib/link-trap.js +78 -0
  32. package/lib/mcp-local.js +8 -6
  33. package/lib/mcp-tool-input.js +116 -0
  34. package/lib/mcp-tool-schema.js +179 -0
  35. package/lib/memory-limits.js +61 -5
  36. package/lib/memory-setting-validate.js +65 -0
  37. package/lib/memory-shed.js +13 -32
  38. package/lib/new-work-gate.js +47 -0
  39. package/lib/os-users.js +5 -3
  40. package/lib/project-access.js +139 -0
  41. package/lib/project-connection.js +37 -22
  42. package/lib/project-external-trigger.js +166 -105
  43. package/lib/project-file-scope.js +172 -0
  44. package/lib/project-file-watch.js +86 -61
  45. package/lib/project-filesystem.js +144 -128
  46. package/lib/project-git.js +119 -0
  47. package/lib/project-http.js +44 -28
  48. package/lib/project-loop.js +17 -9
  49. package/lib/project-mcp.js +53 -72
  50. package/lib/project-message-gate.js +70 -0
  51. package/lib/project-notifications.js +31 -4
  52. package/lib/project-prompt-responses.js +217 -0
  53. package/lib/project-sessions.js +192 -355
  54. package/lib/project-user-message.js +27 -15
  55. package/lib/project.js +212 -147
  56. package/lib/projects-dir.js +90 -0
  57. package/lib/prompt-access.js +22 -0
  58. package/lib/prompt-kinds/answer-limits.js +15 -0
  59. package/lib/prompt-kinds/ask-user.js +58 -0
  60. package/lib/prompt-kinds/codecs.js +97 -0
  61. package/lib/prompt-kinds/elicitation.js +77 -0
  62. package/lib/prompt-kinds/extension.js +39 -0
  63. package/lib/prompt-kinds/index.js +68 -0
  64. package/lib/prompt-kinds/permission.js +114 -0
  65. package/lib/prompt-kinds/plan.js +79 -0
  66. package/lib/prompt-kinds/tool-call.js +38 -0
  67. package/lib/prompt-registry.js +680 -0
  68. package/lib/public/app.js +1 -1
  69. package/lib/public/css/diagnostics.css +80 -0
  70. package/lib/public/css/input.css +17 -3
  71. package/lib/public/css/menus.css +10 -0
  72. package/lib/public/css/messages.css +5 -0
  73. package/lib/public/css/rewind.css +22 -0
  74. package/lib/public/index.html +4 -12
  75. package/lib/public/modules/agent-dispatch-tool.js +9 -0
  76. package/lib/public/modules/app-connection.js +7 -0
  77. package/lib/public/modules/app-cursors.js +7 -5
  78. package/lib/public/modules/app-messages.js +52 -47
  79. package/lib/public/modules/app-notifications.js +47 -71
  80. package/lib/public/modules/app-panels.js +61 -59
  81. package/lib/public/modules/app-projects.js +2 -1
  82. package/lib/public/modules/app-rendering.js +4 -10
  83. package/lib/public/modules/build-update-detail.js +54 -0
  84. package/lib/public/modules/diagnostics.js +170 -20
  85. package/lib/public/modules/filebrowser.js +18 -16
  86. package/lib/public/modules/history-visibility.js +4 -0
  87. package/lib/public/modules/mention.js +3 -2
  88. package/lib/public/modules/mode-options.js +38 -0
  89. package/lib/public/modules/project-settings.js +19 -8
  90. package/lib/public/modules/prompt-banner.js +78 -0
  91. package/lib/public/modules/prompt-card.js +201 -0
  92. package/lib/public/modules/prompt-kinds/ask-user-codec.js +131 -0
  93. package/lib/public/modules/prompt-kinds/ask-user.js +213 -0
  94. package/lib/public/modules/prompt-kinds/elicitation-codec.js +343 -0
  95. package/lib/public/modules/prompt-kinds/elicitation.js +176 -0
  96. package/lib/public/modules/prompt-kinds/index.js +18 -0
  97. package/lib/public/modules/prompt-kinds/own-key.js +29 -0
  98. package/lib/public/modules/prompt-kinds/package.json +3 -0
  99. package/lib/public/modules/prompt-kinds/permission-choices.js +31 -0
  100. package/lib/public/modules/prompt-kinds/permission.js +209 -0
  101. package/lib/public/modules/prompt-kinds/plan.js +102 -0
  102. package/lib/public/modules/prompt-state.js +142 -0
  103. package/lib/public/modules/prompts.js +134 -0
  104. package/lib/public/modules/rewind.js +4 -1
  105. package/lib/public/modules/server-settings.js +2 -4
  106. package/lib/public/modules/sidebar-mobile.js +19 -9
  107. package/lib/public/modules/sidebar-sessions.js +21 -14
  108. package/lib/public/modules/sticky-notes.js +3 -2
  109. package/lib/public/modules/team-panel.js +5 -4
  110. package/lib/public/modules/tools.js +81 -906
  111. package/lib/public/modules/vendor-picker.js +53 -0
  112. package/lib/public/modules/vendor-registry.js +142 -0
  113. package/lib/public/sw.js +3 -1
  114. package/lib/rc-migrate.js +44 -0
  115. package/lib/runtime-env-keys.js +109 -0
  116. package/lib/runtime-env.js +236 -0
  117. package/lib/sdk-bridge.js +348 -284
  118. package/lib/sdk-message-processor.js +117 -146
  119. package/lib/sdk-skill-discovery.js +65 -60
  120. package/lib/server-hub-sessions.js +13 -10
  121. package/lib/server-palette.js +28 -19
  122. package/lib/server.js +156 -115
  123. package/lib/service-install.js +96 -0
  124. package/lib/session-capabilities.js +76 -0
  125. package/lib/session-id.js +33 -0
  126. package/lib/session-input-ipc.js +32 -0
  127. package/lib/session-input.js +379 -0
  128. package/lib/session-reclaim.js +284 -0
  129. package/lib/session-resume.js +172 -0
  130. package/lib/sessions.js +61 -30
  131. package/lib/supervisor.js +39 -0
  132. package/lib/turn-initiator.js +108 -0
  133. package/lib/users-permissions.js +9 -6
  134. package/lib/users.js +9 -0
  135. package/lib/utils.js +4 -2
  136. package/lib/vendor-auth.js +22 -0
  137. package/lib/vendor-registry-message.js +66 -0
  138. package/lib/ws-origin.js +99 -0
  139. package/lib/ws-schema.js +36 -23
  140. package/lib/yoke/adapters/claude-capabilities.js +38 -0
  141. package/lib/yoke/adapters/claude-vendor.js +34 -0
  142. package/lib/yoke/adapters/claude-worker.js +57 -87
  143. package/lib/yoke/adapters/claude.js +182 -88
  144. package/lib/yoke/adapters/codex-capabilities.js +40 -0
  145. package/lib/yoke/adapters/codex-vendor.js +46 -0
  146. package/lib/yoke/adapters/codex.js +462 -211
  147. package/lib/yoke/adapters/effort-control.js +34 -0
  148. package/lib/yoke/adapters/permission-relay.js +58 -0
  149. package/lib/yoke/adapters/worker-mcp-servers.js +81 -0
  150. package/lib/yoke/auth-checks.js +91 -0
  151. package/lib/yoke/capabilities.js +49 -0
  152. package/lib/yoke/codex-app-server.js +30 -56
  153. package/lib/yoke/codex-binary.js +254 -0
  154. package/lib/yoke/codex-command.js +122 -0
  155. package/lib/yoke/codex-protocol.js +96 -0
  156. package/lib/yoke/codex-version.js +135 -0
  157. package/lib/yoke/env-ownership.js +40 -0
  158. package/lib/yoke/index.js +84 -174
  159. package/lib/yoke/install-probe.js +136 -0
  160. package/lib/yoke/instructions.js +7 -11
  161. package/lib/yoke/interface.js +206 -4
  162. package/lib/yoke/package.json +1 -1
  163. package/lib/yoke/provider-credentials.js +96 -0
  164. package/lib/yoke/registry.js +377 -0
  165. package/package.json +12 -9
  166. package/scripts/check-sdk-lock-drift.js +160 -0
  167. package/scripts/check-test-count.js +76 -1
  168. package/scripts/postinstall.js +218 -136
  169. package/scripts/prompt-harness-history.js +202 -0
  170. package/scripts/verify-installed-build.js +59 -17
  171. package/scripts/verify-installed.js +67 -0
  172. package/lib/sdk-permission-ownership.js +0 -136
@@ -25,6 +25,57 @@
25
25
 
26
26
  import { iconHtml, refreshIcons } from './icons.js';
27
27
  import { formatDiagnosticSource as _formatSource } from './diagnostic-format.js';
28
+ import { sendWs } from './ws-ref.js';
29
+ import { buildUpdateDetailEl } from './build-update-detail.js';
30
+
31
+ // Allowlist of actionable.action values this client will act on.
32
+ // A diagnostic's `actionable.action` string is never sent to the server
33
+ // verbatim as a WS message type — only a value in this map is ever wired to
34
+ // a click, so the backend cannot steer the client into sending an arbitrary
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';
42
+ var ACTIONABLE_HANDLERS = {
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
+ },
48
+ };
49
+
50
+ // Shared by both render sites below (panel entry + toast). Returns
51
+ // a clickable button when entry.actionable.action is a known action, or null
52
+ // when there is no label or no known handler — callers render their own
53
+ // existing icon+text hint in the null case, so this only owns the "known
54
+ // action -> real button" half of the branch, not the fallback shape.
55
+ function _buildActionableEl(entry, btnClass) {
56
+ if (!entry.actionable || !entry.actionable.label) return null;
57
+ var handler = entry.actionable.action ? ACTIONABLE_HANDLERS[entry.actionable.action] : null;
58
+ if (!handler) return null;
59
+ var btn = document.createElement("button");
60
+ btn.className = btnClass;
61
+ btn.textContent = entry.actionable.label;
62
+ btn.addEventListener("click", function () {
63
+ btn.disabled = true;
64
+ handler(entry);
65
+ });
66
+ return btn;
67
+ }
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
+ }
28
79
 
29
80
  // --- Module state ---
30
81
  var diagnostics = []; // [{id, severity, source, message, actionable, ts}]
@@ -135,7 +186,7 @@ export function initDiagnostics() {
135
186
  // Public: add a diagnostic
136
187
  // ============================================================
137
188
 
138
- export function addDiagnostic(msg) {
189
+ export function addDiagnostic(msg, opts) {
139
190
  var now = Date.now();
140
191
 
141
192
  // lr-e901: same condition can arrive via two independent emitters (CLI-stderr
@@ -148,6 +199,7 @@ export function addDiagnostic(msg) {
148
199
  scope: msg.scope || "",
149
200
  message: msg.message || "",
150
201
  actionable: msg.actionable || null,
202
+ buildUpdate: msg.buildUpdate || null,
151
203
  ts: now,
152
204
  id: _nextDiagnosticId++,
153
205
  };
@@ -160,11 +212,73 @@ export function addDiagnostic(msg) {
160
212
  _updateBadge();
161
213
 
162
214
  // Toast for warning and error severity only.
163
- if (entry.severity === "warning" || entry.severity === "error") {
215
+ var toastAllowed = !(opts && opts.toast === false);
216
+ if (toastAllowed && (entry.severity === "warning" || entry.severity === "error")) {
164
217
  _showDiagnosticToast(entry);
165
218
  }
166
219
  }
167
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
+
168
282
  // Re-export the pure formatter so callers that import from this module
169
283
  // can reach it without a second import. Tests should import from
170
284
  // diagnostic-format.js directly (no DOM deps there).
@@ -191,12 +305,34 @@ function _getToastContainer() {
191
305
  return toastContainerEl;
192
306
  }
193
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
+
194
328
  function _showDiagnosticToast(entry) {
195
329
  var el = document.createElement("div");
196
330
  // Use a dedicated class so diagnostics are visually distinct from error messages.
197
331
  el.className = "toast toast-diagnostic toast-diagnostic-" + entry.severity;
198
332
  el.setAttribute("role", "alert");
199
333
  el.setAttribute("aria-live", "assertive");
334
+ el.setAttribute("data-diag-source", entry.source);
335
+ el.setAttribute("data-diag-action", _actionOf(entry));
200
336
 
201
337
  var headerEl = document.createElement("div");
202
338
  headerEl.className = "toast-diagnostic-header";
@@ -219,16 +355,15 @@ function _showDiagnosticToast(entry) {
219
355
  headerEl.appendChild(dismissBtn);
220
356
 
221
357
  var msgEl = document.createElement("div");
222
- msgEl.className = "toast-diagnostic-msg";
358
+ msgEl.className = "toast-diagnostic-msg diagnostic-multiline";
223
359
  msgEl.textContent = entry.message;
224
360
 
225
- var hintEl = document.createElement("div");
226
- hintEl.className = "toast-diagnostic-hint";
227
- hintEl.textContent = "See Diagnostics panel for details";
228
-
229
361
  el.appendChild(headerEl);
230
362
  el.appendChild(msgEl);
231
- el.appendChild(hintEl);
363
+ var hasAction = _appendToastActions(el, entry, function () {
364
+ clearTimeout(timer);
365
+ _removeDiagnosticToast(el);
366
+ });
232
367
 
233
368
  _getToastContainer().appendChild(el);
234
369
  refreshIcons();
@@ -236,8 +371,10 @@ function _showDiagnosticToast(entry) {
236
371
  // Animate in.
237
372
  requestAnimationFrame(function () { el.classList.add("visible"); });
238
373
 
239
- // Auto-dismiss after 6s.
240
- var timer = setTimeout(function () { _removeDiagnosticToast(el); }, 6000);
374
+ // Auto-dismiss after 6s — EXCEPT when an action button is present: an
375
+ // operator deciding whether to restart must not have the offer vanish out
376
+ // from under them before they've read it.
377
+ var timer = hasAction ? null : setTimeout(function () { _removeDiagnosticToast(el); }, 6000);
241
378
 
242
379
  // Manual dismiss.
243
380
  dismissBtn.addEventListener("click", function () {
@@ -323,27 +460,40 @@ function _appendEntry(entry) {
323
460
  meta.appendChild(dismissBtn);
324
461
 
325
462
  var msgEl = document.createElement("div");
326
- msgEl.className = "diagnostics-message";
463
+ msgEl.className = "diagnostics-message diagnostic-multiline";
327
464
  msgEl.textContent = entry.message;
328
465
 
329
466
  item.appendChild(meta);
330
467
  item.appendChild(msgEl);
468
+ var panelDetail = buildUpdateDetailEl(entry.buildUpdate);
469
+ if (panelDetail) item.appendChild(panelDetail);
331
470
 
332
- // Actionable hint: surface label when present.
471
+ // Actionable hint: surface label when present. lr-e85fec: a known action
472
+ // renders as a real button (_buildActionableEl), not just a hint icon — a
473
+ // detector with no attached actuator is the failure mode this closes.
333
474
  if (entry.actionable && entry.actionable.label) {
334
475
  var actionEl = document.createElement("div");
335
476
  actionEl.className = "diagnostics-actionable";
336
477
 
337
- var fixIcon = document.createElement("span");
338
- fixIcon.className = "diagnostics-actionable-icon";
339
- fixIcon.innerHTML = iconHtml("info");
478
+ var panelBtn = _buildActionableEl(entry, "diagnostics-actionable-btn");
479
+ if (panelBtn) {
480
+ actionEl.appendChild(panelBtn);
481
+ var panelDecline = _buildDeclineEl(entry, "diagnostics-actionable-btn", function () {
482
+ dismissDiagnostic(entry.id);
483
+ });
484
+ if (panelDecline) actionEl.appendChild(panelDecline);
485
+ } else {
486
+ var fixIcon = document.createElement("span");
487
+ fixIcon.className = "diagnostics-actionable-icon";
488
+ fixIcon.innerHTML = iconHtml("info");
340
489
 
341
- var fixText = document.createElement("span");
342
- fixText.className = "diagnostics-actionable-text";
343
- fixText.textContent = entry.actionable.label;
490
+ var fixText = document.createElement("span");
491
+ fixText.className = "diagnostics-actionable-text";
492
+ fixText.textContent = entry.actionable.label;
344
493
 
345
- actionEl.appendChild(fixIcon);
346
- actionEl.appendChild(fixText);
494
+ actionEl.appendChild(fixIcon);
495
+ actionEl.appendChild(fixText);
496
+ }
347
497
  item.appendChild(actionEl);
348
498
  }
349
499
 
@@ -15,7 +15,7 @@ import { registerHandlers } from './app-messages.js';
15
15
 
16
16
  var ctx;
17
17
  var showDropHint = function () {};
18
- var treeData = {}; // path -> { loaded, children }
18
+ var treeData = Object.create(null); // path -> { loaded, children }
19
19
  var currentContent = null; // last read file content for copy
20
20
  var currentFilePath = null; // path of the currently viewed file
21
21
  var isRendered = false; // markdown render toggle state
@@ -26,9 +26,9 @@ var currentHistoryEntries = [];
26
26
  var selectedEntries = []; // up to 2 selected for compare
27
27
  var compareMode = false;
28
28
  var inlineDiffActive = false;
29
- var gitDiffCache = {}; // hash -> diff text
29
+ var gitDiffCache = Object.create(null); // hash -> diff text
30
30
  var pendingGitDiff = null; // callback for pending git diff
31
- var fileAtCache = {}; // hash -> file content
31
+ var fileAtCache = Object.create(null); // hash -> file content
32
32
  var pendingFileAt = null; // { hash, cb } for the in-flight fs_file_at request, or null
33
33
 
34
34
  export function initFileBrowser(_ctx) {
@@ -419,7 +419,7 @@ export function resetFileBrowser() {
419
419
  // Close viewer
420
420
  closeFileViewer();
421
421
  // Clear all cached state
422
- treeData = {};
422
+ treeData = Object.create(null);
423
423
  currentContent = null;
424
424
  currentFilePath = null;
425
425
  isRendered = false;
@@ -430,9 +430,9 @@ export function resetFileBrowser() {
430
430
  selectedEntries = [];
431
431
  compareMode = false;
432
432
  inlineDiffActive = false;
433
- gitDiffCache = {};
433
+ gitDiffCache = Object.create(null);
434
434
  pendingGitDiff = null;
435
- fileAtCache = {};
435
+ fileAtCache = Object.create(null);
436
436
  pendingFileAt = null;
437
437
  pendingReadPath = null;
438
438
  pendingOpenMode = null;
@@ -563,13 +563,15 @@ export function handleFsSearch(msg) {
563
563
  }
564
564
 
565
565
  // Build a tree structure from flat search results
566
- var tree = {};
566
+ // Keyed by file and directory names, so a file called "constructor" or
567
+ // "__proto__" must not find an inherited entry.
568
+ var tree = Object.create(null);
567
569
  for (var i = 0; i < entries.length; i++) {
568
570
  var entry = entries[i];
569
571
  var parts = entry.path.split("/");
570
572
  var node = tree;
571
573
  for (var j = 0; j < parts.length; j++) {
572
- if (!node[parts[j]]) node[parts[j]] = {};
574
+ if (!node[parts[j]]) node[parts[j]] = Object.create(null);
573
575
  if (j === parts.length - 1) {
574
576
  node[parts[j]]._entry = entry;
575
577
  } else {
@@ -713,7 +715,7 @@ export function handleFsList(msg) {
713
715
  // Root level
714
716
  if (dirPath === ".") {
715
717
  // Preserve expanded state across re-render
716
- var expandedSet = {};
718
+ var expandedSet = Object.create(null);
717
719
  var expandedEls = ctx.fileTreeEl.querySelectorAll(".file-tree-item.expanded");
718
720
  for (var ei = 0; ei < expandedEls.length; ei++) {
719
721
  var sib = expandedEls[ei].nextElementSibling;
@@ -747,7 +749,7 @@ export function handleDirChanged(msg) {
747
749
  }
748
750
 
749
751
  // Collect expanded directories before re-render
750
- var expandedSet = {};
752
+ var expandedSet = Object.create(null);
751
753
  var expandedEls = ctx.fileTreeEl.querySelectorAll(".file-tree-item.expanded");
752
754
  for (var i = 0; i < expandedEls.length; i++) {
753
755
  var sib = expandedEls[i].nextElementSibling;
@@ -987,8 +989,8 @@ function showFileContent(msg) {
987
989
  compareMode = false;
988
990
  selectedEntries = [];
989
991
  currentHistoryEntries = [];
990
- gitDiffCache = {};
991
- fileAtCache = {};
992
+ gitDiffCache = Object.create(null);
993
+ fileAtCache = Object.create(null);
992
994
  var historyBtn2 = document.getElementById("file-viewer-history");
993
995
  historyBtn2.classList.add("hidden");
994
996
  historyBtn2.classList.remove("active");
@@ -1004,8 +1006,8 @@ function showFileContent(msg) {
1004
1006
  compareMode = false;
1005
1007
  selectedEntries = [];
1006
1008
  currentHistoryEntries = [];
1007
- gitDiffCache = {};
1008
- fileAtCache = {};
1009
+ gitDiffCache = Object.create(null);
1010
+ fileAtCache = Object.create(null);
1009
1011
  var historyBtn = document.getElementById("file-viewer-history");
1010
1012
  historyBtn.classList.add("hidden");
1011
1013
  historyBtn.classList.remove("active");
@@ -1728,7 +1730,7 @@ function editCodeSummary(oldStr, newStr) {
1728
1730
  // Find the first meaningful added or changed line to use as a subtitle
1729
1731
  var oldLines = oldStr ? oldStr.split("\n") : [];
1730
1732
  var newLines = newStr ? newStr.split("\n") : [];
1731
- var oldSet = {};
1733
+ var oldSet = Object.create(null);
1732
1734
  for (var i = 0; i < oldLines.length; i++) {
1733
1735
  var trimmed = oldLines[i].trim();
1734
1736
  if (trimmed) oldSet[trimmed] = true;
@@ -1742,7 +1744,7 @@ function editCodeSummary(oldStr, newStr) {
1742
1744
  }
1743
1745
  }
1744
1746
  // Fallback: find first removed line
1745
- var newSet = {};
1747
+ var newSet = Object.create(null);
1746
1748
  for (var k = 0; k < newLines.length; k++) {
1747
1749
  var t = newLines[k].trim();
1748
1750
  if (t) newSet[t] = true;
@@ -43,6 +43,10 @@ export var INVISIBLE_TYPES = {
43
43
  thinking_delta: 1,
44
44
  thinking_stop: 1,
45
45
  ask_user_answered: 1,
46
+ prompt_request: 1,
47
+ prompt_pending: 1,
48
+ prompt_resolved: 1,
49
+ prompt_cancel: 1,
46
50
  permission_request: 1,
47
51
  permission_request_pending: 1,
48
52
  permission_cancel: 1,
@@ -3,6 +3,7 @@ import { renderMarkdown, highlightCodeBlocks } from './markdown.js';
3
3
  import { escapeHtml, copyToClipboard } from './utils.js';
4
4
  import { iconHtml, refreshIcons } from './icons.js';
5
5
  import { store } from './store.js';
6
+ import { gatedButtonAttrs } from './vendor-registry.js';
6
7
 
7
8
  var ctx;
8
9
 
@@ -1000,8 +1001,8 @@ export function renderMentionUser(entry) {
1000
1001
  actions.innerHTML =
1001
1002
  '<span class="msg-action-time">' + ts2 + '</span>' +
1002
1003
  '<button class="msg-action-btn msg-action-copy" type="button" title="Copy">' + iconHtml("copy") + '</button>' +
1003
- '<button class="msg-action-btn msg-action-fork" type="button" title="Fork">' + iconHtml("git-branch") + '</button>' +
1004
- (((store.get('vendorCapabilities') || {}).rewind !== false) ? '<button class="msg-action-btn msg-action-rewind msg-user-rewind-btn" type="button" title="Rewind">' + iconHtml("rotate-ccw") + '</button>' : '') +
1004
+ '<button class="msg-action-btn msg-action-fork" type="button" ' + gatedButtonAttrs("fork", "Fork") + '>' + iconHtml("git-branch") + '</button>' +
1005
+ '<button class="msg-action-btn msg-action-rewind msg-user-rewind-btn" type="button" ' + gatedButtonAttrs("rewind", "Rewind") + '>' + iconHtml("rotate-ccw") + '</button>' +
1005
1006
  '<button class="msg-action-btn msg-action-hidden msg-action-edit" type="button" title="Edit">' + iconHtml("pencil") + '</button>';
1006
1007
  div.appendChild(actions);
1007
1008
 
@@ -0,0 +1,38 @@
1
+ // mode-options.js - the permission modes the config chip offers, and their
2
+ // labels. Import-free so it can be exercised without the frontend module
3
+ // graph.
4
+ //
5
+ // Default, Plan and Auto-accept edits are offered for every session. Don't
6
+ // ask and Auto exist only in Claude Code: they are offered for a session whose
7
+ // vendor declares them in capabilities.permissionModes, so a vendor that does
8
+ // not (Codex, or one whose capabilities are not known yet) never shows them.
9
+ // Full auto is offered when the daemon allows it. Labels follow the Claude
10
+ // Code CLI's wording.
11
+
12
+ var BASE_MODES = [
13
+ { value: "default", label: "Default" },
14
+ { value: "plan", label: "Plan" },
15
+ { value: "acceptEdits", label: "Auto-accept edits" },
16
+ ];
17
+
18
+ var CAPABILITY_MODES = [
19
+ { value: "dontAsk", label: "Don’t ask" },
20
+ { value: "auto", label: "Auto" },
21
+ ];
22
+
23
+ var FULL_AUTO = { value: "bypassPermissions", label: "Full auto" };
24
+
25
+ /**
26
+ * @param {?object} capabilities - the session vendor's capabilities.
27
+ * @param {boolean} fullAutoEnabled
28
+ * @returns {{value: string, label: string}[]}
29
+ */
30
+ export function modeOptions(capabilities, fullAutoEnabled) {
31
+ var declared = capabilities && Array.isArray(capabilities.permissionModes) ? capabilities.permissionModes : [];
32
+ var options = BASE_MODES.slice();
33
+ CAPABILITY_MODES.forEach(function (m) {
34
+ if (declared.indexOf(m.value) !== -1) options.push(m);
35
+ });
36
+ if (fullAutoEnabled) options.push(FULL_AUTO);
37
+ return options;
38
+ }
@@ -687,6 +687,21 @@ export function handleProjectEnv(msg) {
687
687
  var notice = document.getElementById("ps-env-override-notice");
688
688
  if (notice) notice.classList.toggle("hidden", !msg.hasEnvrc);
689
689
 
690
+ // Say whom these variables reach: in multi-user mode only the project owner's
691
+ // sessions get them, so no one else's runtime can be changed from here.
692
+ var scopeHint = document.getElementById("ps-env-scope-hint");
693
+ if (scopeHint) {
694
+ if (msg.canEdit === false) {
695
+ scopeHint.textContent = "Only the project owner or an administrator can view and change this project's variables. They apply only to the project owner's sessions; other users' sessions get the shared variables only. Applies to sessions started after saving.";
696
+ } else if (msg.appliesTo === "owner") {
697
+ scopeHint.textContent = "These variables apply only to sessions owned by the project owner. Other users' sessions in this project get the shared variables only. Applies to sessions started after saving.";
698
+ } else {
699
+ scopeHint.textContent = "These variables apply to every session in this project. Applies to sessions started after saving.";
700
+ }
701
+ }
702
+ var addBtn = document.getElementById("ps-env-add-btn");
703
+ if (addBtn) addBtn.disabled = msg.canEdit === false;
704
+
690
705
  // Parse envrc string into key-value pairs
691
706
  var list = document.getElementById("ps-env-list");
692
707
  if (!list) return;
@@ -832,11 +847,9 @@ function autoSaveEnv() {
832
847
  var envrc = buildEnvString();
833
848
  if (ctx.ws && ctx.connected) {
834
849
  ctx.ws.send(JSON.stringify({ type: "set_project_env", slug: currentSlug, envrc: envrc }));
850
+ // "Saved" or the reason it was refused is shown when the server answers.
835
851
  var saveStatus = document.getElementById("ps-env-save-status");
836
- if (saveStatus) {
837
- saveStatus.textContent = "Saved";
838
- setTimeout(function () { saveStatus.textContent = ""; }, 2000);
839
- }
852
+ if (saveStatus) saveStatus.textContent = "Saving...";
840
853
  }
841
854
  }, 800);
842
855
  }
@@ -986,11 +999,9 @@ function autoSaveSharedEnv() {
986
999
  var envrc = buildSharedEnvString();
987
1000
  if (ctx.ws && ctx.connected) {
988
1001
  ctx.ws.send(JSON.stringify({ type: "set_shared_env", envrc: envrc }));
1002
+ // "Saved" or the reason it was refused is shown when the server answers.
989
1003
  var saveStatus = document.getElementById("ps-shared-env-save-status");
990
- if (saveStatus) {
991
- saveStatus.textContent = "Saved";
992
- setTimeout(function () { saveStatus.textContent = ""; }, 2000);
993
- }
1004
+ if (saveStatus) saveStatus.textContent = "Saving...";
994
1005
  }
995
1006
  }, 800);
996
1007
  }
@@ -0,0 +1,78 @@
1
+ // prompt-banner.js - the answer buttons of a prompt's notification banner.
2
+ //
3
+ // A banner answers through the same state machine as the prompt's card
4
+ // (prompt-card.js): a click locks its answer buttons and shows "Sending..."
5
+ // until the server settles the prompt and dismisses the banner; no
6
+ // confirmation in time, or a dropped connection, makes them answerable
7
+ // again. Close and "Go to session" stay usable throughout.
8
+ //
9
+ // Deliberately free of DOM globals beyond the banner element it is given, so
10
+ // it can be exercised without the rest of the frontend module graph.
11
+
12
+ import { definePromptSurface, submitPromptResponse, restoreUnconfirmedUnder } from './prompt-card.js';
13
+ import { permissionChoices } from './prompt-kinds/permission-choices.js';
14
+
15
+ var DECISION_BUTTONS = "button[data-decision]";
16
+ var ACTIONS = ".notif-banner-actions";
17
+
18
+ var PERMISSION_BUTTONS = {
19
+ allow: { label: "Sure", className: "notif-banner-allow" },
20
+ allow_always: { label: "Allow for session", className: "notif-banner-always" },
21
+ deny: { label: "No", className: "notif-banner-deny" },
22
+ };
23
+
24
+ var PLAN_BUTTONS = [
25
+ { decision: "allow", label: "Approve", className: "notif-banner-allow" },
26
+ { decision: "deny", label: "Reject", className: "notif-banner-deny" },
27
+ ];
28
+
29
+ /**
30
+ * The answer buttons a prompt's banner offers; a kind with none offers only
31
+ * "Go to session". A tool-permission banner offers the card's answers, in the
32
+ * card's order: no Allow for session for an ask that may not offer it, and
33
+ * No first for an ask that must open on No.
34
+ * @param {string} kind
35
+ * @param {object} [meta] - the notification's meta (the ask's hints).
36
+ * @returns {{decision: string, label: string, className: string}[]}
37
+ */
38
+ export function bannerActions(kind, meta) {
39
+ if (kind === "permission") {
40
+ return permissionChoices(meta).map(function (decision) {
41
+ return Object.assign({ decision: decision }, PERMISSION_BUTTONS[decision]);
42
+ });
43
+ }
44
+ if (kind === "plan") return PLAN_BUTTONS.map(function (a) { return Object.assign({}, a); });
45
+ return [];
46
+ }
47
+
48
+ /**
49
+ * Wire a banner's decision buttons to answer its prompt.
50
+ * @param {Element} banner
51
+ * @param {object} prompt
52
+ * @param {string} prompt.requestId
53
+ * @param {string} prompt.kind
54
+ * @param {?string} [prompt.slug] - the project the prompt belongs to.
55
+ * @param {function(object): boolean} send - sends a WS message; false when
56
+ * the socket is unusable.
57
+ */
58
+ export function wirePromptBanner(banner, prompt, send) {
59
+ definePromptSurface(banner, { controls: DECISION_BUTTONS, actions: ACTIONS });
60
+ var buttons = banner.querySelectorAll(DECISION_BUTTONS);
61
+ for (var i = 0; i < buttons.length; i++) {
62
+ buttons[i].addEventListener("click", answerWith(buttons[i]));
63
+ }
64
+
65
+ function answerWith(btn) {
66
+ return function (e) {
67
+ if (e && e.stopPropagation) e.stopPropagation();
68
+ var msg = { type: "prompt_response", requestId: prompt.requestId, kind: prompt.kind, decision: btn.getAttribute("data-decision") };
69
+ if (prompt.slug) msg.targetSlug = prompt.slug;
70
+ submitPromptResponse(banner, function () { return send(msg); });
71
+ };
72
+ }
73
+ }
74
+
75
+ /** Make every banner under root that awaits a confirmation answerable again. */
76
+ export function restoreUnconfirmedBanners(root, message) {
77
+ if (root) restoreUnconfirmedUnder(root, message);
78
+ }