@clagentic/console 1.10.0-beta.2 → 1.10.0-beta.4

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 (59) hide show
  1. package/lib/activity-clock.js +23 -0
  2. package/lib/build-sha.json +2 -2
  3. package/lib/build-update-offer.js +29 -0
  4. package/lib/cli-transcript-title.js +131 -0
  5. package/lib/daemon.js +5 -9
  6. package/lib/debug-log.js +17 -0
  7. package/lib/exit-flush.js +44 -0
  8. package/lib/grant-keys.js +66 -0
  9. package/lib/identity/config.js +118 -0
  10. package/lib/identity/contract.js +61 -0
  11. package/lib/identity/delivery.js +224 -0
  12. package/lib/identity/holder.js +87 -0
  13. package/lib/identity/index.js +229 -0
  14. package/lib/identity/jose.js +13 -0
  15. package/lib/identity/origin.js +28 -0
  16. package/lib/identity/owner.js +30 -0
  17. package/lib/identity/providers/gatekeeper.js +91 -0
  18. package/lib/identity/providers/jwks-self.js +85 -0
  19. package/lib/identity/providers/module.js +98 -0
  20. package/lib/identity/providers/signing-key.js +118 -0
  21. package/lib/identity/record.js +23 -0
  22. package/lib/identity/unavailable.js +29 -0
  23. package/lib/log-field.js +34 -0
  24. package/lib/project-http.js +2 -0
  25. package/lib/project-notifications.js +3 -0
  26. package/lib/project-prompt-responses.js +2 -1
  27. package/lib/project-session-grants.js +73 -0
  28. package/lib/project-sessions.js +12 -0
  29. package/lib/project-user-message.js +6 -5
  30. package/lib/project.js +2 -0
  31. package/lib/prompt-label.js +60 -0
  32. package/lib/prompt-registry.js +105 -10
  33. package/lib/prompt-source.js +65 -0
  34. package/lib/public/css/notifications-center.css +9 -0
  35. package/lib/public/css/overlays.css +18 -0
  36. package/lib/public/css/rewind.css +7 -0
  37. package/lib/public/modules/app-messages.js +3 -0
  38. package/lib/public/modules/app-notifications.js +5 -0
  39. package/lib/public/modules/build-notice-gate.js +73 -0
  40. package/lib/public/modules/diagnostics.js +43 -1
  41. package/lib/public/modules/prompt-label.js +44 -0
  42. package/lib/public/modules/prompts.js +9 -0
  43. package/lib/public/modules/session-grants.js +131 -0
  44. package/lib/public/modules/sidebar-sessions.js +11 -0
  45. package/lib/runtime-env.js +1 -1
  46. package/lib/sdk-bridge.js +135 -104
  47. package/lib/sdk-message-processor.js +14 -67
  48. package/lib/session-ai-title.js +80 -0
  49. package/lib/session-input.js +32 -2
  50. package/lib/sessions.js +21 -18
  51. package/lib/turn-initiator.js +29 -14
  52. package/lib/utils.js +5 -46
  53. package/lib/ws-schema.js +6 -3
  54. package/lib/yoke/adapters/claude-worker.js +5 -5
  55. package/lib/yoke/adapters/claude.js +5 -62
  56. package/lib/yoke/adapters/codex.js +4 -75
  57. package/lib/yoke/interface.js +3 -7
  58. package/package.json +3 -1
  59. package/scripts/vendor-identity-vectors.js +52 -0
@@ -27,6 +27,11 @@ 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
29
  import { buildUpdateDetailEl } from './build-update-detail.js';
30
+ import {
31
+ BUILD_NOTICE_SOURCE, BUILD_NOTICE_ACTION, noticeKeyOf, cooldownOf, createNoticeGate,
32
+ } from './build-notice-gate.js';
33
+
34
+ var _noticeGate = createNoticeGate();
30
35
 
31
36
  // Allowlist of actionable.action values this client will act on.
32
37
  // A diagnostic's `actionable.action` string is never sent to the server
@@ -203,6 +208,9 @@ export function addDiagnostic(msg, opts) {
203
208
  ts: now,
204
209
  id: _nextDiagnosticId++,
205
210
  };
211
+ var gate = _gateBuildNotice(msg, now);
212
+ if (gate.action === "skip") return;
213
+ entry.noticeKey = gate.key;
206
214
  diagnostics.push(entry);
207
215
 
208
216
  // Render the new entry in the panel list.
@@ -212,12 +220,39 @@ export function addDiagnostic(msg, opts) {
212
220
  _updateBadge();
213
221
 
214
222
  // Toast for warning and error severity only.
215
- var toastAllowed = !(opts && opts.toast === false);
223
+ var toastAllowed = !(opts && opts.toast === false) && gate.toast;
216
224
  if (toastAllowed && (entry.severity === "warning" || entry.severity === "error")) {
217
225
  _showDiagnosticToast(entry);
218
226
  }
219
227
  }
220
228
 
229
+ // The standing build-update notice is replayed to every connection and refreshed
230
+ // while the build is stale; build-notice-gate.js decides whether this arrival
231
+ // adds, replaces, re-toasts or is dropped. Anything else passes through.
232
+ function _gateBuildNotice(msg, now) {
233
+ var key = noticeKeyOf(msg);
234
+ if (!key) return { action: "add", toast: true, key: null };
235
+ var held = diagnostics.filter(function (e) {
236
+ return e.source === BUILD_NOTICE_SOURCE && _actionOf(e) === BUILD_NOTICE_ACTION;
237
+ })[0] || null;
238
+ var decision = _noticeGate.decide({
239
+ key: key,
240
+ heldKey: held ? held.noticeKey || null : null,
241
+ toastOnScreen: held ? _toastsFor(BUILD_NOTICE_SOURCE, BUILD_NOTICE_ACTION).length > 0 : false,
242
+ now: now,
243
+ cooldownMs: cooldownOf(msg),
244
+ });
245
+ if (decision.action === "replace" || decision.action === "retract") {
246
+ retractDiagnostics(BUILD_NOTICE_SOURCE, BUILD_NOTICE_ACTION);
247
+ }
248
+ if (decision.action === "retract") return { action: "skip", toast: false, key: key };
249
+ if (decision.action === "retoast") {
250
+ _showDiagnosticToast(held);
251
+ return { action: "skip", toast: false, key: key };
252
+ }
253
+ return { action: decision.action, toast: decision.toast, key: key };
254
+ }
255
+
221
256
  /**
222
257
  * Updates the entry a source already holds with a newer message (the update
223
258
  * offer, once its change list is read). It replaces in place: no second entry,
@@ -379,6 +414,7 @@ function _showDiagnosticToast(entry) {
379
414
  // Manual dismiss.
380
415
  dismissBtn.addEventListener("click", function () {
381
416
  clearTimeout(timer);
417
+ _noticeGate.toastClosed(entry.noticeKey, Date.now());
382
418
  _removeDiagnosticToast(el);
383
419
  });
384
420
 
@@ -386,6 +422,7 @@ function _showDiagnosticToast(entry) {
386
422
  el.addEventListener("keydown", function (e) {
387
423
  if (e.key === "Escape" || e.key === "Enter" || e.key === " ") {
388
424
  clearTimeout(timer);
425
+ _noticeGate.toastClosed(entry.noticeKey, Date.now());
389
426
  _removeDiagnosticToast(el);
390
427
  }
391
428
  });
@@ -537,6 +574,7 @@ function dismissDiagnostic(id) {
537
574
  if (diagnostics[i].id === id) { idx = i; break; }
538
575
  }
539
576
  if (idx === -1) return;
577
+ _noticeGate.entryDismissed(diagnostics[idx].noticeKey, Date.now());
540
578
  diagnostics.splice(idx, 1);
541
579
 
542
580
  if (panelListEl) {
@@ -555,6 +593,10 @@ function dismissDiagnostic(id) {
555
593
  * no server-side dismiss contract (see module header note).
556
594
  */
557
595
  function clearAllDiagnostics() {
596
+ var clearedAt = Date.now();
597
+ diagnostics.forEach(function (entry) { _noticeGate.entryDismissed(entry.noticeKey, clearedAt); });
598
+ // Toasts for the cleared entries go too, so clear-all leaves nothing on screen.
599
+ Array.prototype.slice.call(_getToastContainer().querySelectorAll("[data-diag-source]")).forEach(_removeDiagnosticToast);
558
600
  diagnostics = [];
559
601
  if (panelListEl) panelListEl.innerHTML = "";
560
602
  _restoreEmptyPlaceholder();
@@ -0,0 +1,44 @@
1
+ // prompt-label.js - how a prompt says whose it is: its project, its session
2
+ // and, when a background agent raised it, that agent. The server builds the
3
+ // label (lib/prompt-label.js) and sends it on every prompt and its
4
+ // notification; the card and the banner both draw it from here so the two
5
+ // cannot disagree.
6
+ //
7
+ // Deliberately free of DOM globals and of imports beyond escape-html, so the
8
+ // banner and tests can load it without the rest of the frontend module graph.
9
+
10
+ import { escapeHtml } from './escape-html.js';
11
+
12
+ /**
13
+ * @param {?{project?: string, session?: string, agent?: string}} label
14
+ * @returns {{name: string, value: string}[]} the parts that are present, in order.
15
+ */
16
+ export function promptLabelParts(label) {
17
+ if (!label || typeof label !== "object") return [];
18
+ var parts = [];
19
+ if (typeof label.project === "string" && label.project) parts.push({ name: "Project", value: label.project });
20
+ if (typeof label.session === "string" && label.session) parts.push({ name: "Session", value: label.session });
21
+ if (typeof label.agent === "string" && label.agent) parts.push({ name: "Agent", value: label.agent });
22
+ return parts;
23
+ }
24
+
25
+ /** The label as one line of plain text; "" when there is none. */
26
+ export function promptLabelText(label) {
27
+ return promptLabelParts(label).map(function (p) { return p.name + ": " + p.value; }).join(" | ");
28
+ }
29
+
30
+ /** The label as an element for a card, or null when there is none. */
31
+ export function promptLabelElement(label) {
32
+ var text = promptLabelText(label);
33
+ if (!text) return null;
34
+ var el = document.createElement("div");
35
+ el.className = "prompt-label";
36
+ el.textContent = text;
37
+ return el;
38
+ }
39
+
40
+ /** The label as escaped HTML for a banner, or "" when there is none. */
41
+ export function promptLabelHtml(label) {
42
+ var text = promptLabelText(label);
43
+ return text ? '<div class="notif-banner-label">' + escapeHtml(text) + '</div>' : "";
44
+ }
@@ -16,6 +16,7 @@ import {
16
16
  } from './prompt-card.js';
17
17
  import { PROMPT_KINDS } from './prompt-kinds/index.js';
18
18
  import { ownValue } from './prompt-kinds/own-key.js';
19
+ import { promptLabelElement } from './prompt-label.js';
19
20
 
20
21
  /**
21
22
  * @param {object} host
@@ -63,6 +64,14 @@ export function createPromptController(host) {
63
64
  });
64
65
  var container = renderer.draw(n.fields, n.requestId, rendererHost);
65
66
  container.dataset.promptKind = n.kind;
67
+ // Whose prompt this is, above everything else on the card. The kinds lay
68
+ // themselves out differently (a body block, a flex row with an avatar), so
69
+ // it goes in the first block that holds the card's text.
70
+ var label = promptLabelElement(n.fields && n.fields.label);
71
+ if (label) {
72
+ var holder = container.querySelector(".permission-body, .dm-bubble-content") || container;
73
+ holder.insertBefore(label, holder.firstChild);
74
+ }
66
75
  cards[n.requestId] = { container: container, kind: n.kind, fields: n.fields, host: rendererHost };
67
76
  host.place(container, renderer.focusSelector || null);
68
77
  return cards[n.requestId];
@@ -0,0 +1,131 @@
1
+ // session-grants.js - the operator's list of what a session may do without
2
+ // asking (its Allow for session grants), with a Revoke for each. The server
3
+ // owns the grants (lib/prompt-registry.js); this only asks for the list,
4
+ // draws what it is told and sends a revoke. A revoke takes effect on the
5
+ // session's next tool call, and the server answers with the list as it now is.
6
+ //
7
+ // Free of the rest of the frontend module graph apart from the connection, so
8
+ // a test can drive it with a hand-built DOM.
9
+
10
+ import { getWs } from './ws-ref.js';
11
+
12
+ var MODAL_ID = "session-grants-modal";
13
+
14
+ function send(msg) {
15
+ var ws = getWs();
16
+ if (!ws || ws.readyState !== 1) return false;
17
+ ws.send(JSON.stringify(msg));
18
+ return true;
19
+ }
20
+
21
+ function modal() {
22
+ return document.getElementById(MODAL_ID);
23
+ }
24
+
25
+ function close() {
26
+ var m = modal();
27
+ if (m && m.parentNode) m.parentNode.removeChild(m);
28
+ }
29
+
30
+ /**
31
+ * Draw a grant list into list; exported for tests.
32
+ * @param {Element} list
33
+ * @param {{key: string, text: string, wholeTool: boolean}[]} grants
34
+ * @param {number} sessionId
35
+ * @param {function(object): boolean} sendMsg
36
+ */
37
+ export function renderGrantList(list, grants, sessionId, sendMsg) {
38
+ list.textContent = "";
39
+ var error = document.createElement("div");
40
+ error.className = "session-grants-error";
41
+ list.appendChild(error);
42
+ if (!grants.length) {
43
+ var empty = document.createElement("div");
44
+ empty.className = "session-grants-empty";
45
+ empty.textContent = "This session has no Allow for session grants. Every tool call that needs approval asks.";
46
+ list.appendChild(empty);
47
+ return;
48
+ }
49
+ grants.forEach(function (g) {
50
+ var row = document.createElement("div");
51
+ row.className = "session-grants-row" + (g.wholeTool ? " session-grants-whole" : "");
52
+ row.dataset.grantKey = g.key;
53
+ var text = document.createElement("span");
54
+ text.className = "session-grants-text";
55
+ text.textContent = g.text;
56
+ var revoke = document.createElement("button");
57
+ revoke.className = "session-grants-revoke";
58
+ revoke.textContent = "Revoke";
59
+ // Disabled only while the request is in flight. The row goes when the
60
+ // server's list arrives without the grant; a failed send or a server
61
+ // refusal re-enables the button so the revoke can be retried.
62
+ revoke.addEventListener("click", function () {
63
+ revoke.disabled = true;
64
+ error.textContent = "";
65
+ var sent = sendMsg({ type: "revoke_session_grant", sessionId: sessionId, key: g.key });
66
+ if (sent === false) {
67
+ revoke.disabled = false;
68
+ error.textContent = "Could not revoke: not connected. Try again.";
69
+ }
70
+ });
71
+ row.appendChild(text);
72
+ row.appendChild(revoke);
73
+ list.appendChild(row);
74
+ });
75
+ }
76
+
77
+ /** Open the grants list for a session. */
78
+ export function openSessionGrants(sessionId) {
79
+ close();
80
+ var m = document.createElement("div");
81
+ m.id = MODAL_ID;
82
+ m.dataset.sessionId = String(sessionId);
83
+ var backdrop = document.createElement("div");
84
+ backdrop.className = "confirm-backdrop";
85
+ backdrop.addEventListener("click", close);
86
+ var dialog = document.createElement("div");
87
+ dialog.className = "confirm-dialog session-grants-dialog";
88
+ var title = document.createElement("div");
89
+ title.className = "session-grants-title";
90
+ title.textContent = "Allow for session grants";
91
+ var list = document.createElement("div");
92
+ list.className = "session-grants-list";
93
+ list.textContent = "Loading...";
94
+ var done = document.createElement("button");
95
+ done.className = "confirm-btn confirm-cancel";
96
+ done.textContent = "Close";
97
+ done.addEventListener("click", close);
98
+ dialog.appendChild(title);
99
+ dialog.appendChild(list);
100
+ dialog.appendChild(done);
101
+ m.appendChild(backdrop);
102
+ m.appendChild(dialog);
103
+ document.body.appendChild(m);
104
+ send({ type: "list_session_grants", sessionId: sessionId });
105
+ }
106
+
107
+ /**
108
+ * A server refusal: keep the rows, show why, and let each Revoke be tried
109
+ * again. Exported for tests.
110
+ * @param {Element} list
111
+ * @param {string} message
112
+ */
113
+ export function showGrantError(list, message) {
114
+ var buttons = list.querySelectorAll(".session-grants-revoke");
115
+ for (var i = 0; i < buttons.length; i++) buttons[i].disabled = false;
116
+ var error = list.querySelector(".session-grants-error");
117
+ if (error) error.textContent = message;
118
+ }
119
+
120
+ /** The server's session_grants message: redraw the list if it is the one open. */
121
+ export function handleSessionGrants(msg) {
122
+ var m = modal();
123
+ if (!m || m.dataset.sessionId !== String(msg.sessionId)) return;
124
+ var list = m.querySelector(".session-grants-list");
125
+ if (!list) return;
126
+ if (typeof msg.error === "string" && msg.error) {
127
+ showGrantError(list, "Could not revoke: " + msg.error);
128
+ return;
129
+ }
130
+ renderGrantList(list, Array.isArray(msg.grants) ? msg.grants : [], msg.sessionId, send);
131
+ }
@@ -8,6 +8,7 @@ import { openSearch as openSessionSearch } from './session-search.js';
8
8
  import { store } from './store.js';
9
9
  import { capabilityGate } from './vendor-registry.js';
10
10
  import { getWs } from './ws-ref.js';
11
+ import { openSessionGrants } from './session-grants.js';
11
12
  import { getSessionListEl } from './dom-refs.js';
12
13
  import { dismissOverlayPanels, closeSidebar, updatePageTitle, spawnDustParticles } from './sidebar.js';
13
14
  import { showConfirm } from './app-misc.js';
@@ -677,6 +678,16 @@ function showSessionCtxMenu(anchorBtn, sessionId, title, cliSid, sessionData) {
677
678
  });
678
679
  menu.appendChild(renameItem);
679
680
 
681
+ var grantsItem = document.createElement("button");
682
+ grantsItem.className = "session-ctx-item";
683
+ grantsItem.innerHTML = iconHtml("shield") + " <span>Permission grants</span>";
684
+ grantsItem.addEventListener("click", function (e) {
685
+ e.stopPropagation();
686
+ closeSessionCtxMenu();
687
+ openSessionGrants(sessionId);
688
+ });
689
+ menu.appendChild(grantsItem);
690
+
680
691
  // Session visibility toggle (only the session owner can change)
681
692
  if (sessionData && sessionData.ownerId && sessionData.ownerId === store.get('myUserId')) {
682
693
  var currentVis = (sessionData && sessionData.sessionVisibility) || "shared";
@@ -2,7 +2,7 @@
2
2
  //
3
3
  // Settings hold two environment texts: shared (every project, administrators
4
4
  // only) and per project. Every agent-runtime start (a Claude query in process
5
- // or in a worker, a Codex app-server, title generation, a model-list warmup)
5
+ // or in a worker, a Codex app-server, a model-list warmup)
6
6
  // takes its environment from here: the runtime's own environment first, then
7
7
  // the shared text, then the project text.
8
8
  //