@clagentic/console 1.12.0-beta.2 → 1.12.0

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 (127) hide show
  1. package/LICENSES/README.md +5 -0
  2. package/bin/cli.js +4 -2
  3. package/lib/agent-roster-ws.js +84 -0
  4. package/lib/agent-roster.js +312 -0
  5. package/lib/auth-required-notify.js +42 -0
  6. package/lib/build-sha.json +2 -2
  7. package/lib/build-update-notify.js +45 -0
  8. package/lib/build-update-offer.js +3 -4
  9. package/lib/build-update-standing.js +34 -14
  10. package/lib/cli/session-subcommands.js +26 -8
  11. package/lib/client-address.js +44 -0
  12. package/lib/daemon.js +25 -10
  13. package/lib/idle-compaction-setting.js +203 -0
  14. package/lib/mcp-bridge-credential.js +41 -0
  15. package/lib/notification-prefs.js +16 -22
  16. package/lib/notify/core.js +53 -18
  17. package/lib/notify/payload.js +2 -3
  18. package/lib/notify/type-registry.js +17 -0
  19. package/lib/notify/types.js +38 -1
  20. package/lib/outbound-access.js +12 -1
  21. package/lib/outbound-entry.js +8 -1
  22. package/lib/project-connection.js +9 -8
  23. package/lib/project-filesystem.js +23 -0
  24. package/lib/project-loop.js +16 -19
  25. package/lib/project-notifications.js +68 -7
  26. package/lib/project-sessions.js +9 -0
  27. package/lib/project-user-mention.js +22 -34
  28. package/lib/project-user-message.js +208 -4
  29. package/lib/project-user-shell.js +298 -0
  30. package/lib/project.js +26 -4
  31. package/lib/prompt-answer.js +145 -0
  32. package/lib/prompt-expiry.js +50 -0
  33. package/lib/prompt-registry.js +24 -1
  34. package/lib/prompt-source.js +16 -0
  35. package/lib/public/app.js +31 -2
  36. package/lib/public/css/agent-messages.css +96 -0
  37. package/lib/public/css/agent-roster.css +93 -0
  38. package/lib/public/css/diagnostics.css +1 -1
  39. package/lib/public/css/input.css +20 -141
  40. package/lib/public/css/login-panel.css +73 -0
  41. package/lib/public/css/menus.css +2 -2
  42. package/lib/public/css/sidebar.css +11 -0
  43. package/lib/public/css/team-panel.css +1 -6
  44. package/lib/public/css/team-view.css +101 -0
  45. package/lib/public/css/title-bar.css +10 -0
  46. package/lib/public/css/user-shell.css +144 -0
  47. package/lib/public/index.html +41 -7
  48. package/lib/public/modules/agent-avatar-picker.js +162 -0
  49. package/lib/public/modules/agent-avatar.js +153 -0
  50. package/lib/public/modules/agent-messages.js +285 -0
  51. package/lib/public/modules/agent-roster.js +157 -0
  52. package/lib/public/modules/app-connection.js +12 -0
  53. package/lib/public/modules/app-messages.js +55 -16
  54. package/lib/public/modules/app-notifications.js +59 -29
  55. package/lib/public/modules/app-panels.js +26 -3
  56. package/lib/public/modules/app-rate-limit.js +8 -165
  57. package/lib/public/modules/app-rendering.js +22 -7
  58. package/lib/public/modules/collapsible-text.js +33 -18
  59. package/lib/public/modules/compaction-state.js +34 -0
  60. package/lib/public/modules/custom-icons.js +23 -5
  61. package/lib/public/modules/diagnostics.js +52 -55
  62. package/lib/public/modules/injected-identity.js +24 -21
  63. package/lib/public/modules/input.js +176 -15
  64. package/lib/public/modules/login-panel.js +136 -0
  65. package/lib/public/modules/login-parser.js +73 -0
  66. package/lib/public/modules/login-tab.js +66 -0
  67. package/lib/public/modules/notifications.js +9 -1
  68. package/lib/public/modules/notify-client.js +114 -21
  69. package/lib/public/modules/pending-term-request.js +30 -0
  70. package/lib/public/modules/project-icon.js +22 -2
  71. package/lib/public/modules/queued-button.js +11 -0
  72. package/lib/public/modules/scheduled-input-actions.js +12 -4
  73. package/lib/public/modules/scheduled-outbox.js +230 -0
  74. package/lib/public/modules/send-now.js +200 -0
  75. package/lib/public/modules/server-settings.js +47 -1
  76. package/lib/public/modules/shell-card.js +76 -0
  77. package/lib/public/modules/shell-line.js +49 -0
  78. package/lib/public/modules/shell-queue.js +253 -0
  79. package/lib/public/modules/shell-settings-controls.js +76 -0
  80. package/lib/public/modules/sidebar-mobile.js +3 -3
  81. package/lib/public/modules/sidebar-sessions.js +8 -0
  82. package/lib/public/modules/sidebar-users.js +5 -7
  83. package/lib/public/modules/team-panel.js +30 -88
  84. package/lib/public/modules/team-view.js +211 -0
  85. package/lib/public/modules/terminal-links.js +18 -0
  86. package/lib/public/modules/terminal.js +65 -4
  87. package/lib/public/modules/tools.js +19 -0
  88. package/lib/public/modules/user-shell.js +824 -0
  89. package/lib/public/notify-sw-logic.js +35 -83
  90. package/lib/public/notify-target.js +70 -10
  91. package/lib/public/style.css +5 -0
  92. package/lib/public/sw.js +7 -3
  93. package/lib/queued-chat.js +392 -0
  94. package/lib/scheduled-input/ws.js +67 -9
  95. package/lib/sdk-bridge.js +122 -43
  96. package/lib/sdk-message-processor.js +46 -39
  97. package/lib/server-auth.js +6 -4
  98. package/lib/server-dm.js +11 -20
  99. package/lib/server-settings.js +39 -1
  100. package/lib/server.js +83 -19
  101. package/lib/session-directory.js +33 -8
  102. package/lib/session-end.js +97 -0
  103. package/lib/session-input-ipc.js +26 -0
  104. package/lib/session-input.js +176 -9
  105. package/lib/session-resume.js +1 -0
  106. package/lib/session-settings-file.js +53 -0
  107. package/lib/sessions.js +49 -5
  108. package/lib/team-traffic-ws.js +68 -0
  109. package/lib/team-traffic.js +318 -0
  110. package/lib/usage-store.js +7 -0
  111. package/lib/user-shell-settings.js +105 -0
  112. package/lib/ws-schema.js +27 -4
  113. package/lib/yoke/adapters/claude-capabilities.js +2 -0
  114. package/lib/yoke/adapters/claude-vendor.js +6 -0
  115. package/lib/yoke/adapters/claude-worker.js +39 -11
  116. package/lib/yoke/adapters/claude.js +218 -6
  117. package/lib/yoke/adapters/codex-capabilities.js +6 -1
  118. package/lib/yoke/adapters/codex-user-shell.js +265 -0
  119. package/lib/yoke/adapters/codex-vendor.js +7 -0
  120. package/lib/yoke/adapters/codex.js +186 -52
  121. package/lib/yoke/codex-app-server.js +8 -2
  122. package/lib/yoke/interface.js +54 -1
  123. package/lib/yoke/mcp-bridge-server.js +12 -8
  124. package/lib/yoke/registry.js +32 -0
  125. package/lib/yoke/user-shell.js +224 -0
  126. package/package.json +1 -1
  127. package/lib/public/modules/build-notice-gate.js +0 -73
@@ -0,0 +1,211 @@
1
+ // team-view.js - The Team view: a registry of sections plus the desktop view
2
+ // that hosts them. A section registers an id, a title, a render(container)
3
+ // and an optional isAvailable(). Sections know nothing about each other, so
4
+ // adding one touches no existing section. The desktop view (#team-view) and
5
+ // the mobile Team tab both draw through renderTeamSections().
6
+
7
+ import { refreshIcons } from './icons.js';
8
+ import { isMobileViewport } from './popover-position.js';
9
+
10
+ // Registration order is display order.
11
+ var sections = [];
12
+ var selectedId = null;
13
+
14
+ var viewEl = null;
15
+ var bodyEl = null;
16
+ var openedAutomatically = false;
17
+
18
+ // --- Registry ---
19
+
20
+ /**
21
+ * Register a section. Registering an id that already exists replaces it in
22
+ * place, so a module that is loaded twice does not list itself twice.
23
+ *
24
+ * @param {{id: string, title: string, render: function(HTMLElement): void,
25
+ * isAvailable?: function(): boolean}} section
26
+ */
27
+ export function registerTeamSection(section) {
28
+ if (!section || typeof section.id !== "string" || !section.id) {
29
+ throw new Error("team section needs a string id");
30
+ }
31
+ if (typeof section.title !== "string" || !section.title) {
32
+ throw new Error("team section " + section.id + " needs a title");
33
+ }
34
+ if (typeof section.render !== "function") {
35
+ throw new Error("team section " + section.id + " needs a render(container) function");
36
+ }
37
+ var entry = {
38
+ id: section.id,
39
+ title: section.title,
40
+ render: section.render,
41
+ isAvailable: typeof section.isAvailable === "function" ? section.isAvailable : null,
42
+ };
43
+ for (var i = 0; i < sections.length; i++) {
44
+ if (sections[i].id === entry.id) {
45
+ sections[i] = entry;
46
+ return;
47
+ }
48
+ }
49
+ sections.push(entry);
50
+ }
51
+
52
+ export function unregisterTeamSection(id) {
53
+ sections = sections.filter(function (s) { return s.id !== id; });
54
+ if (selectedId === id) selectedId = null;
55
+ }
56
+
57
+ /** Sections that have something to show right now, in registration order. */
58
+ export function listTeamSections() {
59
+ return sections.filter(function (s) { return !s.isAvailable || s.isAvailable(); });
60
+ }
61
+
62
+ // --- Rendering (shared by desktop and mobile) ---
63
+
64
+ function buildEmptyState() {
65
+ var empty = document.createElement("div");
66
+ empty.className = "team-empty-state";
67
+
68
+ var title = document.createElement("p");
69
+ title.textContent = "Nothing active";
70
+ empty.appendChild(title);
71
+
72
+ var hint = document.createElement("p");
73
+ hint.className = "team-empty-hint";
74
+ hint.textContent = "Agent activity appears here while it is running. Start a session with Agent Teams enabled to see live team activity.";
75
+ empty.appendChild(hint);
76
+
77
+ return empty;
78
+ }
79
+
80
+ function buildTabs(available, active, onSelect) {
81
+ var tabs = document.createElement("div");
82
+ tabs.className = "team-view-tabs";
83
+ tabs.setAttribute("role", "tablist");
84
+
85
+ available.forEach(function (s) {
86
+ var tab = document.createElement("button");
87
+ tab.className = "team-view-tab" + (s === active ? " active" : "");
88
+ tab.setAttribute("role", "tab");
89
+ tab.setAttribute("data-section-id", s.id);
90
+ tab.textContent = s.title;
91
+ tab.addEventListener("click", function () { onSelect(s.id); });
92
+ tabs.appendChild(tab);
93
+ });
94
+
95
+ return tabs;
96
+ }
97
+
98
+ /**
99
+ * Draw the available sections into container: a tab strip when there is more
100
+ * than one, the selected section's content, or the empty state when none is
101
+ * available. Replaces whatever the container held.
102
+ */
103
+ export function renderTeamSections(container) {
104
+ container.innerHTML = "";
105
+
106
+ var available = listTeamSections();
107
+ if (available.length === 0) {
108
+ container.appendChild(buildEmptyState());
109
+ return;
110
+ }
111
+
112
+ var active = available[0];
113
+ for (var i = 0; i < available.length; i++) {
114
+ if (available[i].id === selectedId) { active = available[i]; break; }
115
+ }
116
+ selectedId = active.id;
117
+
118
+ if (available.length > 1) {
119
+ container.appendChild(buildTabs(available, active, function (id) {
120
+ selectedId = id;
121
+ renderTeamSections(container);
122
+ }));
123
+ }
124
+
125
+ var content = document.createElement("div");
126
+ content.className = "team-view-section";
127
+ content.setAttribute("data-section-id", active.id);
128
+ active.render(content);
129
+ container.appendChild(content);
130
+ }
131
+
132
+ // --- Desktop view ---
133
+
134
+ export function initTeamView() {
135
+ viewEl = document.getElementById("team-view");
136
+ bodyEl = document.getElementById("team-view-body");
137
+ if (!viewEl) return;
138
+
139
+ var closeBtn = document.getElementById("team-view-close");
140
+ if (closeBtn) closeBtn.addEventListener("click", closeTeamView);
141
+
142
+ document.addEventListener("keydown", function (e) {
143
+ if (e.key === "Escape" && isTeamViewOpen()) closeTeamView();
144
+ });
145
+ }
146
+
147
+ export function isTeamViewOpen() {
148
+ return !!viewEl && !viewEl.classList.contains("hidden");
149
+ }
150
+
151
+ function setTeamButtonActive(on) {
152
+ var btn = document.getElementById("icon-strip-team-btn");
153
+ if (!btn) return;
154
+ if (on) btn.classList.add("active");
155
+ else btn.classList.remove("active");
156
+ }
157
+
158
+ /**
159
+ * Open the view. A no-op on a phone viewport, where the Team tab is the entry.
160
+ * opts.auto marks an open the client made on its own (a section announcing
161
+ * live activity); a view the user already had open stays the user's.
162
+ */
163
+ export function openTeamView(opts) {
164
+ if (!viewEl || !bodyEl || isMobileViewport()) return;
165
+ if (!isTeamViewOpen()) openedAutomatically = !!(opts && opts.auto);
166
+ viewEl.classList.remove("hidden");
167
+ setTeamButtonActive(true);
168
+ renderTeamSections(bodyEl);
169
+ refreshIcons();
170
+ }
171
+
172
+ export function closeTeamView() {
173
+ if (!viewEl) return;
174
+ viewEl.classList.add("hidden");
175
+ openedAutomatically = false;
176
+ setTeamButtonActive(false);
177
+ }
178
+
179
+ /**
180
+ * Close the view only when the client opened it on its own, so the chat comes
181
+ * back when the activity that opened it ends. A view the user opened stays.
182
+ */
183
+ export function closeTeamViewIfAutoOpened() {
184
+ if (openedAutomatically) closeTeamView();
185
+ }
186
+
187
+ export function toggleTeamView() {
188
+ if (isTeamViewOpen()) closeTeamView();
189
+ else openTeamView();
190
+ }
191
+
192
+ /**
193
+ * Whether a container a section drew into is still on screen: the registry has
194
+ * no close hook, so a section that updates itself later asks this first. False
195
+ * once the container was detached (a tab switch or re-render) or sits inside a
196
+ * hidden view.
197
+ */
198
+ export function isSectionContainerShown(container) {
199
+ if (!container) return false;
200
+ if (container.isConnected === false) return false;
201
+ for (var node = container; node; node = node.parentNode) {
202
+ if (node.classList && node.classList.contains("hidden")) return false;
203
+ }
204
+ return true;
205
+ }
206
+
207
+ /** Re-render in place after a section's data changed; a no-op while closed. */
208
+ export function refreshTeamView() {
209
+ if (!isTeamViewOpen()) return;
210
+ renderTeamSections(bodyEl);
211
+ }
@@ -116,6 +116,24 @@ function findMultiRowUrls(logical) {
116
116
  return found;
117
117
  }
118
118
 
119
+ // The last maxRows rows of the buffer as logical lines: soft-wrapped and
120
+ // hard-wrapped rows are joined exactly as the link provider joins them, so a
121
+ // URL a program broke across rows reads as one token. Used to read a login
122
+ // terminal's output; the join rules are the provider's own.
123
+ export function bufferLogicalLines(buffer, cols, maxRows) {
124
+ var first = Math.max(0, buffer.length - (maxRows || 200));
125
+ var lines = [];
126
+ var y = first;
127
+ while (y < buffer.length) {
128
+ var logical = getLogicalLine(buffer, y, cols);
129
+ // A logical line that began above the window is read from its start, so
130
+ // its head is never dropped.
131
+ lines.push(logical.text);
132
+ y = Math.max(logical.endY, y) + 1;
133
+ }
134
+ return lines;
135
+ }
136
+
119
137
  // opts.onHover(url) / opts.onLeave() let the owner remember the link under
120
138
  // the pointer, for a copy-link action.
121
139
  export function createMultiLineLinkProvider(xterm, opts) {
@@ -5,6 +5,9 @@ import { copyToClipboard } from './utils.js';
5
5
  import { getTerminalTheme } from './theme.js';
6
6
  import { positionAtPoint } from './popover-position.js';
7
7
  import { createMultiLineLinkProvider, copyTextForSelection } from './terminal-links.js';
8
+ import { store } from './store.js';
9
+ import { vendorEntry } from './vendor-registry.js';
10
+ import { createLoginTab } from './login-tab.js';
8
11
 
9
12
  var ctx;
10
13
  var tabs = new Map(); // termId -> { id, title, exited, xterm, fitAddon, bodyEl }
@@ -15,8 +18,53 @@ var altActive = false;
15
18
  var isTouchDevice = "ontouchstart" in window;
16
19
  var viewportHandler = null;
17
20
  var resizeObserver = null;
21
+ // termId -> sign-in panel controller. Present only for the terminal that
22
+ // startLoginCommand opened; every other terminal's output is never parsed.
23
+ var loginTabs = new Map();
24
+
25
+ function closeLoginTab(termId) {
26
+ var login = loginTabs.get(termId);
27
+ if (!login) return;
28
+ login.close();
29
+ loginTabs.delete(termId);
30
+ }
31
+
32
+ function loginIdentity() {
33
+ if (store.get('isOsUsers')) return "os-users";
34
+ return store.get('isMultiUserMode') ? "shared" : "";
35
+ }
36
+
37
+ /**
38
+ * Marks a terminal as the login tab for an agent, so its output feeds the
39
+ * sign-in panel. Called once, for the terminal the login command was typed into.
40
+ * @param {string} termId
41
+ * @param {string} vendorId
42
+ */
43
+ export function markLoginTerminal(termId, vendorId) {
44
+ if (!termId) return;
45
+ var entry = vendorEntry(vendorId);
46
+ if (!entry || !entry.loginPatterns) return;
47
+ closeLoginTab(termId);
48
+ loginTabs.set(termId, createLoginTab({
49
+ patterns: entry.loginPatterns,
50
+ vendorName: entry.displayName,
51
+ identity: loginIdentity(),
52
+ sendCode: function (text) { sendTerminalInput(termId, text); },
53
+ copy: copyToClipboard,
54
+ openLink: function (url) { window.open(url, "_blank", "noopener"); },
55
+ mount: function (panelEl) {
56
+ ctx.terminalContainerEl.insertBefore(panelEl, ctx.terminalBodyEl);
57
+ },
58
+ }));
59
+ syncLoginPanels();
60
+ }
61
+
62
+ function syncLoginPanels() {
63
+ for (var entry of loginTabs.entries()) entry[1].setActive(entry[0] === activeTabId);
64
+ }
18
65
 
19
66
  function disposeTab(tab) {
67
+ closeLoginTab(tab.id);
20
68
  if (tab._webglAddon) {
21
69
  try { tab._webglAddon.dispose(); } catch (e) {}
22
70
  tab._webglAddon = null;
@@ -200,6 +248,7 @@ function activateTab(termId) {
200
248
  }
201
249
 
202
250
  activeTabId = termId;
251
+ syncLoginPanels();
203
252
 
204
253
  // Lazy-create xterm instance
205
254
  if (!tab.xterm) {
@@ -632,7 +681,13 @@ export function handleTermOutput(msg) {
632
681
  if (!msg.id) return;
633
682
  var tab = tabs.get(msg.id);
634
683
  if (tab && tab.xterm && msg.data) {
635
- tab.xterm.write(msg.data);
684
+ var login = loginTabs.get(msg.id);
685
+ if (login) {
686
+ // Read the buffer once xterm has parsed this chunk, not the raw bytes.
687
+ tab.xterm.write(msg.data, function () { login.feed(tab.xterm); });
688
+ } else {
689
+ tab.xterm.write(msg.data);
690
+ }
636
691
  }
637
692
  }
638
693
 
@@ -649,6 +704,7 @@ export function handleTermExited(msg) {
649
704
  var tab = tabs.get(msg.id);
650
705
  if (tab) {
651
706
  tab.exited = true;
707
+ closeLoginTab(msg.id);
652
708
  if (tab.xterm) {
653
709
  tab.xterm.write("\r\n\x1b[90m[Process exited]\x1b[0m\r\n");
654
710
  }
@@ -692,13 +748,18 @@ export function resetTerminals() {
692
748
  renderTabBar();
693
749
  }
694
750
 
695
- export function sendTerminalCommand(command) {
696
- if (!activeTabId || !tabs.has(activeTabId)) return;
751
+ // Types text into one named terminal through the ordinary input message.
752
+ export function sendTerminalInput(termId, data) {
753
+ if (!termId || !tabs.has(termId)) return;
697
754
  if (ctx.ws && ctx.connected) {
698
- ctx.ws.send(JSON.stringify({ type: "term_input", id: activeTabId, data: command }));
755
+ ctx.ws.send(JSON.stringify({ type: "term_input", id: termId, data: data }));
699
756
  }
700
757
  }
701
758
 
759
+ export function sendTerminalCommand(command) {
760
+ sendTerminalInput(activeTabId, command);
761
+ }
762
+
702
763
  export function setTerminalTheme(xtermTheme) {
703
764
  for (var tab of tabs.values()) {
704
765
  if (tab.xterm) {
@@ -8,6 +8,9 @@ import { store } from './store.js';
8
8
  import { VENDOR_NAMES } from './app-rendering.js';
9
9
  import { createPromptController } from './prompts.js';
10
10
  import { isAgentDispatchTool } from './agent-dispatch-tool.js';
11
+ import { createAgentAvatar } from './agent-avatar.js';
12
+
13
+ var SUBAGENT_AVATAR_SIZE = 16;
11
14
 
12
15
  var ctx;
13
16
 
@@ -822,6 +825,21 @@ export function createToolItem(id, name) {
822
825
  tools[id] = { el: el, name: name, input: null, done: false, groupId: currentToolGroup.id };
823
826
  }
824
827
 
828
+ // A Task or Agent dispatch is labelled with the sub-agent it starts: its avatar
829
+ // from the shared resolver (agent-avatar.js), then its subagent_type as given.
830
+ function addSubagentLabel(tool, descEl, name, input) {
831
+ if (!isAgentDispatchTool(name) || !input || typeof input.subagent_type !== "string" || !input.subagent_type) return;
832
+ if (tool.el.querySelector(".tool-agent")) return;
833
+ var label = document.createElement("span");
834
+ label.className = "tool-agent";
835
+ label.appendChild(createAgentAvatar(input.subagent_type, SUBAGENT_AVATAR_SIZE, "tool-agent-avatar"));
836
+ var text = document.createElement("span");
837
+ text.className = "tool-agent-name";
838
+ text.textContent = input.subagent_type;
839
+ label.appendChild(text);
840
+ descEl.parentNode.insertBefore(label, descEl);
841
+ }
842
+
825
843
  export function updateToolExecuting(id, name, input) {
826
844
  var tool = tools[id];
827
845
  if (!tool) return;
@@ -829,6 +847,7 @@ export function updateToolExecuting(id, name, input) {
829
847
  tool.input = input;
830
848
  var descEl = tool.el.querySelector(".tool-desc");
831
849
  descEl.textContent = toolSummary(name, input);
850
+ addSubagentLabel(tool, descEl, name, input);
832
851
 
833
852
  // Make file path clickable for Read/Edit/Write tools
834
853
  var filePath = input && input.file_path;