@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,224 @@
1
+ "use strict";
2
+
3
+ // One shell command the person typed for themselves, run by the console for an
4
+ // agent that has no call of its own for it, and the text that records it in the
5
+ // agent's transcript. Adapters call this; the callers above the adapter go
6
+ // through QueryHandle.runUserShellCommand and never reach this module.
7
+ //
8
+ // The command runs through the platform shell, in the given directory, with the
9
+ // environment the caller hands over, under the identity of the console process:
10
+ // this module never changes uid.
11
+
12
+ var { spawn } = require("child_process");
13
+
14
+ // After the shell exits, how long to wait for its output pipes to close before
15
+ // settling anyway: a background process the command left behind can hold them.
16
+ var PIPE_DRAIN_GRACE_MS = 250;
17
+
18
+ function warnUnlessGone(err) {
19
+ if (err && err.code !== "ESRCH") console.warn("[yoke/user-shell] could not stop the command:", err.message);
20
+ }
21
+
22
+ function truncationMarker(maxBytes) {
23
+ return "\n[output truncated at " + maxBytes + " bytes]";
24
+ }
25
+
26
+ // A buffer cut at an arbitrary byte can end inside a multibyte character, which
27
+ // would decode to U+FFFD. Drops that partial character from the end, so what is
28
+ // kept is whole characters and never more than was kept before.
29
+ function dropPartialChar(buf) {
30
+ var lead = buf.length - 1;
31
+ var back = 0;
32
+ while (lead >= 0 && back < 3 && (buf[lead] & 0xC0) === 0x80) { lead--; back++; }
33
+ if (lead < 0) return buf;
34
+ var b = buf[lead];
35
+ var width = b >= 0xF0 ? 4 : b >= 0xE0 ? 3 : b >= 0xC0 ? 2 : 1;
36
+ return width > buf.length - lead ? buf.subarray(0, lead) : buf;
37
+ }
38
+
39
+ // The one place the cap is applied. Text that fits is returned whole; text that
40
+ // does not is cut and followed by the truncation marker, and the marker's bytes
41
+ // are reserved before the cut so the result, marker included, is never longer
42
+ // than maxBytes. forceCut is for a buffer that already lost bytes while being
43
+ // read. When maxBytes cannot hold the marker, the marker itself is cut to fit
44
+ // (it is ASCII, so any byte count is a whole-character count).
45
+ function capBuffer(buf, maxBytes, forceCut) {
46
+ if (!forceCut && buf.length <= maxBytes) return { output: buf.toString("utf8"), truncated: false };
47
+ var marker = truncationMarker(maxBytes);
48
+ var room = maxBytes - Buffer.byteLength(marker, "utf8");
49
+ if (room <= 0) return { output: marker.slice(0, Math.max(0, maxBytes)), truncated: true };
50
+ return { output: dropPartialChar(buf.subarray(0, room)).toString("utf8") + marker, truncated: true };
51
+ }
52
+
53
+ /**
54
+ * Cuts text so the result, truncation marker included, is at most maxBytes of
55
+ * UTF-8. The cut backs off to a character boundary.
56
+ * @param {string} text
57
+ * @param {number} maxBytes
58
+ * @returns {{output: string, truncated: boolean}}
59
+ */
60
+ function capText(text, maxBytes) {
61
+ return capBuffer(Buffer.from(String(text == null ? "" : text), "utf8"), maxBytes, false);
62
+ }
63
+
64
+ /**
65
+ * Runs a command to its end, its timeout, or an interrupt.
66
+ *
67
+ * @param {object} opts
68
+ * @param {string} opts.command
69
+ * @param {string} opts.cwd
70
+ * @param {number} opts.timeoutMs the command's process group is killed when it runs longer
71
+ * @param {number} opts.maxOutputBytes output kept; the rest is read and dropped
72
+ * @param {object} [opts.env] default: the console process's own
73
+ * @param {AbortSignal} [opts.signal] aborting kills the command's process group
74
+ * @returns {Promise<{exitCode: ?number, durationMs: number, output: string,
75
+ * truncated: boolean, timedOut: boolean, interrupted: boolean}>}
76
+ */
77
+ function runShellCommand(opts) {
78
+ var started = Date.now();
79
+ var maxBytes = opts.maxOutputBytes;
80
+ var signal = opts.signal || null;
81
+
82
+ return new Promise(function (resolve) {
83
+ var chunks = [];
84
+ var kept = 0;
85
+ var readTruncated = false;
86
+ var timedOut = false;
87
+ var interrupted = false;
88
+ var settled = false;
89
+ var exited = false;
90
+ var drainTimer = null;
91
+ var timeoutTimer = null;
92
+ var child = null;
93
+
94
+ function finish(exitCode, extraOutput) {
95
+ if (settled) return;
96
+ settled = true;
97
+ clearTimeout(timeoutTimer);
98
+ clearTimeout(drainTimer);
99
+ if (signal) signal.removeEventListener("abort", onAbort);
100
+ // The cap is applied to everything the person is shown, the failure text
101
+ // included, so no text added here can push the output past it.
102
+ var buf = Buffer.concat(chunks);
103
+ if (extraOutput) buf = Buffer.concat([buf, Buffer.from((buf.length ? "\n" : "") + extraOutput, "utf8")]);
104
+ // Bytes dropped while reading mean the kept ones may end inside a character.
105
+ var capped = capBuffer(buf, maxBytes, readTruncated);
106
+ resolve({
107
+ exitCode: typeof exitCode === "number" ? exitCode : null,
108
+ durationMs: Date.now() - started,
109
+ output: capped.output,
110
+ truncated: capped.truncated,
111
+ timedOut: timedOut,
112
+ interrupted: interrupted,
113
+ });
114
+ }
115
+
116
+ function killTree() {
117
+ if (!child || !child.pid) return;
118
+ try {
119
+ // The command's own process group, so what it started dies with it.
120
+ if (process.platform === "win32") child.kill();
121
+ else process.kill(-child.pid, "SIGKILL");
122
+ } catch (err) {
123
+ warnUnlessGone(err);
124
+ }
125
+ }
126
+
127
+ function onAbort() {
128
+ // An abort that arrives after the shell exited (while the pipes drain)
129
+ // stopped nothing the command was doing, so it does not relabel the result.
130
+ if (!exited) interrupted = true;
131
+ killTree();
132
+ }
133
+
134
+ function collect(chunk) {
135
+ var room = maxBytes - kept;
136
+ if (room <= 0) { readTruncated = true; return; }
137
+ if (chunk.length > room) {
138
+ chunks.push(chunk.subarray(0, room));
139
+ kept += room;
140
+ readTruncated = true;
141
+ return;
142
+ }
143
+ chunks.push(chunk);
144
+ kept += chunk.length;
145
+ }
146
+
147
+ if (signal && signal.aborted) {
148
+ interrupted = true;
149
+ finish(null, null);
150
+ return;
151
+ }
152
+
153
+ try {
154
+ child = spawn(opts.command, {
155
+ shell: true,
156
+ cwd: opts.cwd,
157
+ env: opts.env || process.env,
158
+ stdio: ["ignore", "pipe", "pipe"],
159
+ detached: process.platform !== "win32",
160
+ windowsHide: true,
161
+ });
162
+ } catch (err) {
163
+ finish(null, "Could not start the command: " + err.message);
164
+ return;
165
+ }
166
+
167
+ child.stdout.on("data", collect);
168
+ child.stderr.on("data", collect);
169
+ child.on("error", function (err) {
170
+ finish(null, "Could not run the command: " + err.message);
171
+ });
172
+ child.on("exit", function (code) {
173
+ exited = true;
174
+ // The command is over: a timeout that fires during the drain must not mark
175
+ // it as timed out.
176
+ clearTimeout(timeoutTimer);
177
+ drainTimer = setTimeout(function () { finish(code, null); }, PIPE_DRAIN_GRACE_MS);
178
+ });
179
+ child.on("close", function (code) {
180
+ finish(code, null);
181
+ });
182
+
183
+ timeoutTimer = setTimeout(function () {
184
+ timedOut = true;
185
+ killTree();
186
+ }, opts.timeoutMs);
187
+ if (signal) signal.addEventListener("abort", onAbort, { once: true });
188
+ });
189
+ }
190
+
191
+ function escapeAngles(text) {
192
+ return String(text).replace(/</g, "&lt;").replace(/>/g, "&gt;");
193
+ }
194
+
195
+ /**
196
+ * The text that records a finished command in an agent's conversation. The
197
+ * command and its output are data a program (or a hostile file) can shape, so
198
+ * angle brackets in them are escaped: the wrapper's own tags are then the only
199
+ * tags in the block, and output cannot close it early and pose as what follows.
200
+ *
201
+ * @param {string} command
202
+ * @param {{exitCode: ?number, durationMs: number, output: string, truncated: boolean,
203
+ * timedOut: boolean, interrupted?: boolean}} result
204
+ * @returns {string}
205
+ */
206
+ function formatTranscriptText(command, result) {
207
+ var lines = [
208
+ "<user_shell_command>",
209
+ "<command>" + escapeAngles(command) + "</command>",
210
+ "<exit_code>" + (result.exitCode === null || result.exitCode === undefined ? "none" : result.exitCode) + "</exit_code>",
211
+ "<duration_ms>" + Math.round(result.durationMs || 0) + "</duration_ms>",
212
+ ];
213
+ if (result.timedOut) lines.push("<timed_out>true</timed_out>");
214
+ if (result.interrupted) lines.push("<interrupted>true</interrupted>");
215
+ if (result.truncated) lines.push("<truncated>true</truncated>");
216
+ lines.push("<output>", escapeAngles(result.output || ""), "</output>", "</user_shell_command>");
217
+ return lines.join("\n");
218
+ }
219
+
220
+ module.exports = {
221
+ runShellCommand: runShellCommand,
222
+ formatTranscriptText: formatTranscriptText,
223
+ capText: capText,
224
+ };
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "1.12.0-beta.2",
6
+ "version": "1.12.0",
7
7
  "description": "Self-hosted console for Claude Code and Codex. Multi-user, browser-based, persistent AI sessions.",
8
8
  "bin": {
9
9
  "clagentic-console": "./bin/cli.js"
@@ -1,73 +0,0 @@
1
- // build-notice-gate.js — decides what the diagnostics list does with the
2
- // "newer build installed" notice, which the daemon replays to every client that
3
- // connects (once per project connection) and refreshes while the build is stale.
4
- //
5
- // Pure state and rules, no DOM: lib/public/modules/diagnostics.js asks it what
6
- // to do and does it. The rules:
7
- // - one notice per running/installed build pair; an identical one never stacks;
8
- // - a different pair replaces the held one, or retracts it when the incoming
9
- // pair is itself quiet (nothing new is shown until the cooldown passes);
10
- // - once the operator has closed the notice (the toast, or the panel entry),
11
- // the same pair stays quiet until the cooldown has passed.
12
-
13
- export var BUILD_NOTICE_SOURCE = 'build-update';
14
- export var BUILD_NOTICE_ACTION = 'restart_for_build_update';
15
- export var DEFAULT_COOLDOWN_MS = 60 * 60 * 1000;
16
-
17
- /** The pair a standing notice is about, or null when `msg` is not that notice. */
18
- export function noticeKeyOf(msg) {
19
- if (!msg || msg.source !== BUILD_NOTICE_SOURCE) return null;
20
- if (!msg.actionable || msg.actionable.action !== BUILD_NOTICE_ACTION) return null;
21
- var b = msg.buildUpdate;
22
- if (!b || !b.loadedBuildSha || !b.installedBuildSha) return null;
23
- return b.loadedBuildSha + ':' + b.installedBuildSha;
24
- }
25
-
26
- /** The daemon-configured cooldown carried on the notice, else the default. */
27
- export function cooldownOf(msg) {
28
- var ms = msg && msg.noticeCooldownMs;
29
- return typeof ms === 'number' && isFinite(ms) && ms >= 0 ? ms : DEFAULT_COOLDOWN_MS;
30
- }
31
-
32
- export function createNoticeGate() {
33
- // key -> {at, entryGone}. entryGone: the operator removed the panel entry too,
34
- // so the notice must not come back at all, not just without a toast.
35
- var closed = Object.create(null);
36
-
37
- return {
38
- /**
39
- * @param {object} s
40
- * @param {string} s.key — noticeKeyOf(msg)
41
- * @param {?string} s.heldKey — key of the notice already in the list, or null
42
- * @param {boolean} s.toastOnScreen — a toast for the held notice is showing
43
- * @param {number} s.now
44
- * @param {number} s.cooldownMs
45
- * @returns {{action: 'add'|'replace'|'retract'|'skip'|'retoast', toast: boolean}}
46
- */
47
- decide: function (s) {
48
- var rec = closed[s.key];
49
- var quiet = rec !== undefined && s.now - rec.at < s.cooldownMs;
50
- if (rec !== undefined && !quiet) delete closed[s.key];
51
-
52
- if (s.heldKey === s.key) {
53
- // Identical notice: never a second entry. After the cooldown the toast
54
- // may come back if the operator had closed it.
55
- if (rec !== undefined && !quiet && !s.toastOnScreen) return { action: 'retoast', toast: true };
56
- return { action: 'skip', toast: false };
57
- }
58
- // A quiet current pair shows nothing, so a different held pair is stale
59
- // and must go too: one current notice, never an obsolete one left visible.
60
- if (quiet && s.heldKey) return { action: 'retract', toast: false };
61
- if (quiet && rec.entryGone) return { action: 'skip', toast: false };
62
- return { action: s.heldKey ? 'replace' : 'add', toast: !quiet };
63
- },
64
- toastClosed: function (key, now) {
65
- if (!key) return;
66
- var rec = closed[key];
67
- closed[key] = { at: now, entryGone: rec ? rec.entryGone : false };
68
- },
69
- entryDismissed: function (key, now) {
70
- if (key) closed[key] = { at: now, entryGone: true };
71
- },
72
- };
73
- }