@clagentic/console 1.12.0-beta.2 → 1.12.0-beta.3

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
@@ -17,15 +17,18 @@
17
17
  return !!data && data.core === 1;
18
18
  }
19
19
 
20
- // iOS and desktop Safari revoke a push subscription whose pushes do not each
21
- // show a notification, so a close there is a visible replacement. Other
22
- // browsers allow a push that closes a notification and shows nothing.
23
- function requiresVisible(userAgent) {
24
- var ua = userAgent || "";
25
- if (/iPhone|iPad|iPod/.test(ua)) return true;
26
- return /Safari\//.test(ua) && !/Chrome\/|Chromium\/|Android|Edg\//.test(ua);
20
+ // Browsers that enforce userVisibleOnly (Chrome and other Chromium browsers,
21
+ // iOS and desktop Safari) fail a push event that shows no notification: Safari
22
+ // revokes the subscription, Chrome posts its own generic "updated in the
23
+ // background" notice. No browser is known to allow a silent push, so every
24
+ // push shows something, whatever the user agent.
25
+ function requiresVisible() {
26
+ return true;
27
27
  }
28
28
 
29
+ // The tag of the silent notice for a push that names no tag to replace.
30
+ var SILENT_TAG = "console-silent";
31
+
29
32
  /** The options a core notification is shown with: all from the payload. */
30
33
  function optionsFor(data) {
31
34
  return {
@@ -76,27 +79,22 @@
76
79
  });
77
80
  }
78
81
 
79
- // Closes the shown notification under each tag. Where a push must show
80
- // something (requiresVisible), the shown one is replaced under the same tag
81
- // by a silent, non-interactive notice that closes itself shortly after. When
82
- // nothing was shown under any tag (the person already dismissed it), the
83
- // push still has to show something there, so a single silent notice is shown
84
- // and closed at once: the least visible thing such a platform allows.
82
+ // Closes the shown notification under each tag. The shown one is replaced
83
+ // under the same tag by a silent, non-interactive notice that closes itself
84
+ // shortly after. When nothing was shown under any tag (the person already
85
+ // dismissed it), the push still has to show something, so a single silent
86
+ // notice is shown and closed at once: the least visible thing a browser
87
+ // allows.
85
88
  function closeByTags(env, data) {
86
89
  var tags = Array.isArray(data.tags) ? data.tags : [];
87
- var visible = requiresVisible(env.userAgent);
88
90
  return Promise.all(tags.map(function (tag) {
89
91
  return env.registration.getNotifications({ tag: tag }).then(function (shown) {
90
92
  return { tag: tag, shown: shown.filter(function (n) { return !isPlaceholder(n); }) };
91
93
  });
92
94
  })).then(function (found) {
93
- if (!visible) {
94
- found.forEach(function (f) { f.shown.forEach(function (n) { n.close(); }); });
95
- return;
96
- }
97
95
  var matched = found.filter(function (f) { return f.shown.length > 0; });
98
96
  if (matched.length === 0) {
99
- return tags.length ? showPlaceholder(env, data, tags[0], 0) : undefined;
97
+ return showPlaceholder(env, data, tags.length ? tags[0] : SILENT_TAG, 0);
100
98
  }
101
99
  return Promise.all(matched.map(function (f) {
102
100
  return showPlaceholder(env, data, f.tag, RESOLVED_LINGER_MS);
@@ -181,73 +179,20 @@
181
179
  });
182
180
  }
183
181
 
184
- // Legacy payloads shown even when the app is in the foreground: the ones
185
- // that wait on the operator. Every other legacy type is suppressed then.
186
- var LEGACY_ALWAYS_SHOWN = ["permission_request", "permission_reminder", "ask_user"];
187
-
188
- function isLegacyForeground(type) {
189
- return LEGACY_ALWAYS_SHOWN.indexOf(type) === -1;
190
- }
191
-
192
- // The payloads emitters not yet on the core send, shown as they always were.
193
- function showLegacy(env, data) {
194
- var options = {
195
- body: data.body || "",
196
- tag: data.tag || "clagentic",
197
- data: data,
198
- };
199
- if (data.type === "permission_request") {
200
- options.requireInteraction = true;
201
- options.tag = "perm-" + data.requestId;
202
- } else if (data.type === "permission_reminder") {
203
- options.requireInteraction = true;
204
- options.tag = data.tag || "prompt-reminder";
205
- options.renotify = true;
206
- } else if (data.type === "done") {
207
- options.tag = data.tag || "claude-done";
208
- } else if (data.type === "ask_user") {
209
- options.requireInteraction = true;
210
- options.tag = "claude-ask";
211
- } else if (data.type === "dm") {
212
- options.tag = data.tag || "dm";
213
- }
214
- return env.clients.matchAll({ type: "window", includeUncontrolled: true }).then(function (list) {
215
- if (isLegacyForeground(data.type)) {
216
- for (var i = 0; i < list.length; i++) {
217
- if (list[i].focused || list[i].visibilityState === "visible") return;
218
- }
219
- }
220
- return env.registration.showNotification(data.title || "Clagentic: Console", options);
221
- });
222
- }
223
-
224
182
  /**
225
183
  * @param {object} env
226
184
  * @param {object} data the parsed push payload.
227
185
  * @returns {Promise<*>}
228
186
  */
229
187
  function handlePush(env, data) {
230
- if (!data || data.type === "test") return Promise.resolve();
231
- if (isCore(data)) {
232
- if (data.type === "notify_close") return closeByTags(env, data);
233
- return showCore(env, data);
234
- }
235
- return showLegacy(env, data);
236
- }
237
-
238
- function legacyClick(env, data) {
239
- var baseUrl = env.scope || "/";
240
- var targetUrl = data.slug ? baseUrl + "p/" + data.slug + "/" : baseUrl;
241
- return env.clients.matchAll({ type: "window", includeUncontrolled: true }).then(function (list) {
242
- for (var i = 0; i < list.length; i++) {
243
- if (list[i].url.indexOf(targetUrl) !== -1) return list[i].focus();
244
- }
245
- for (var j = 0; j < list.length; j++) {
246
- if (list[j].visibilityState !== "hidden") return list[j].focus();
247
- }
248
- if (list.length > 0) return list[0].focus();
249
- return env.clients.openWindow(targetUrl);
250
- });
188
+ // A push that has nothing to display (a test push, an absent or malformed
189
+ // payload, one queued on a device before the notification core with no
190
+ // core mark) still shows the silent notice, closed at once, so the browser
191
+ // posts no generic notice of its own. Showing it carries no title or body
192
+ // from the payload: those are not trusted when the payload is unmarked.
193
+ if (!isCore(data)) return showPlaceholder(env, {}, SILENT_TAG, 0);
194
+ if (data.type === "notify_close") return closeByTags(env, data);
195
+ return showCore(env, data);
251
196
  }
252
197
 
253
198
  // Focus a window and hand it the target to route to; open one at the deep
@@ -256,7 +201,9 @@
256
201
  function coreClick(env, data) {
257
202
  var t = NotifyTarget.makeTarget(data.target);
258
203
  var base = env.scope || "/";
259
- var url = NotifyTarget.urlForTarget(t, base);
204
+ // A window opened cold has no router message to wait for: the type rides
205
+ // in the URL so the page lands on the place the notice leads to.
206
+ var url = NotifyTarget.urlForTarget(t, base, isCore(data) ? data.type : undefined);
260
207
  var prefix = t && t.slug ? base + "p/" + t.slug + "/" : null;
261
208
  return env.clients.matchAll({ type: "window", includeUncontrolled: true }).then(function (list) {
262
209
  var pick = null;
@@ -272,7 +219,11 @@
272
219
  if (!pick && list.length > 0) pick = list[0];
273
220
  if (!pick) return env.clients.openWindow(url);
274
221
  return Promise.resolve(pick.focus()).then(function () {
275
- pick.postMessage({ type: "notify_route", target: t });
222
+ // The type travels with the target: a system target names no place, and
223
+ // the page's router looks the place up by type.
224
+ var route = { type: "notify_route", target: t };
225
+ if (isCore(data) && typeof data.type === "string") route.notifyType = data.type;
226
+ pick.postMessage(route);
276
227
  });
277
228
  });
278
229
  }
@@ -285,7 +236,8 @@
285
236
  function handleClick(env, notification) {
286
237
  var data = notification.data || {};
287
238
  if (data.resolved === true) return Promise.resolve();
288
- return isCore(data) ? coreClick(env, data) : legacyClick(env, data);
239
+ // A notification shown before the upgrade has no target: it opens the app.
240
+ return coreClick(env, data);
289
241
  }
290
242
 
291
243
  return {
@@ -6,7 +6,8 @@
6
6
  // A target names where a notification's action lives: the project (slug), the
7
7
  // console session (sessionId) and, where there is one, the prompt (requestId).
8
8
  // Session ids restart in every project, so a target without its slug is
9
- // ambiguous: the slug is always part of its identity.
9
+ // ambiguous: the slug is always part of its identity. A direct message belongs
10
+ // to no project: its target names the other person (peerId) instead.
10
11
  (function (root, factory) {
11
12
  var api = factory();
12
13
  // Always published on the global too: a module-graph import in a CommonJS
@@ -15,6 +16,9 @@
15
16
  if (typeof module === "object" && module.exports) module.exports = api;
16
17
  })(typeof self !== "undefined" ? self : globalThis, function () {
17
18
  var SLUG_RE = /^[a-z0-9_-]+$/;
19
+ // User ids, as the direct-message keys accept them.
20
+ var PEER_RE = /^[A-Za-z0-9_-]+$/;
21
+ var TYPE_RE = /^[a-z][a-z0-9_]*$/;
18
22
 
19
23
  // An id is a string or a number; anything else (an object from a hostile or
20
24
  // broken message) names nothing, and is never coerced to text.
@@ -23,48 +27,79 @@
23
27
  }
24
28
 
25
29
  /**
26
- * @param {{slug: ?string, sessionId: ?(number|string), requestId: ?string}} t
27
- * @returns {{slug: ?string, sessionId: ?string, requestId: ?string}|null}
30
+ * @param {{slug: ?string, sessionId: ?(number|string), requestId: ?string, peerId: ?string}} t
31
+ * @returns {{slug: ?string, sessionId: ?string, requestId: ?string, peerId?: string}|null}
28
32
  * a normalised target, or null when the input names no valid target. An id
29
33
  * is carried as a string; a slug that is not a plain project slug is
30
- * refused, since it ends up in a URL path.
34
+ * refused, since it ends up in a URL path. peerId (the other person of a
35
+ * direct message) is present only when given.
31
36
  */
32
37
  function makeTarget(t) {
33
38
  if (!t || typeof t !== "object") return null;
34
39
  var slug = present(t.slug) ? String(t.slug) : null;
35
40
  if (slug !== null && !SLUG_RE.test(slug)) return null;
36
- return {
41
+ var peerId = null;
42
+ if (present(t.peerId)) {
43
+ peerId = String(t.peerId);
44
+ if (!PEER_RE.test(peerId)) return null;
45
+ }
46
+ var out = {
37
47
  slug: slug,
38
48
  sessionId: present(t.sessionId) ? String(t.sessionId) : null,
39
49
  requestId: present(t.requestId) ? String(t.requestId) : null,
40
50
  };
51
+ if (peerId !== null) out.peerId = peerId;
52
+ return out;
53
+ }
54
+
55
+ // The identity of where a target lives, before any request: the project and
56
+ // session, or the conversation with a peer.
57
+ function placeKey(n) {
58
+ return n.peerId ? "dm:" + n.peerId : (n.slug || "") + ":" + (n.sessionId || "");
41
59
  }
42
60
 
43
61
  /** The one identity behind collapse, close and route: slug:sessionId[:requestId]. */
44
62
  function targetKey(t) {
45
63
  var n = makeTarget(t);
46
64
  if (!n) return "";
47
- var key = (n.slug || "") + ":" + (n.sessionId || "");
65
+ var key = placeKey(n);
48
66
  return n.requestId ? key + ":" + n.requestId : key;
49
67
  }
50
68
 
51
69
  /** The session-level identity (no request): slug:sessionId. */
52
70
  function sessionKey(t) {
53
71
  var n = makeTarget(t);
54
- return n ? (n.slug || "") + ":" + (n.sessionId || "") : "";
72
+ return n ? placeKey(n) : "";
73
+ }
74
+
75
+ /**
76
+ * The tag a notification of a type shows under, on every device: the type
77
+ * and the target's identity, at the type's collapse level. The server core
78
+ * and the page's own notifications derive it here, so they agree.
79
+ * @param {string} typeName
80
+ * @param {"request"|"session"} collapse
81
+ * @param {object} target
82
+ */
83
+ function tagFor(typeName, collapse, target) {
84
+ return "n:" + typeName + ":" + (collapse === "request" ? targetKey(target) : sessionKey(target));
55
85
  }
56
86
 
57
87
  /**
58
88
  * The deep link that opens a target: <base>p/<slug>/?session=<id>[&request=<id>].
59
- * A target with no slug (a system notice) opens the base page.
89
+ * A target with no slug (a system notice) opens the base page; a direct
90
+ * message's, the base page with its conversation named. A system target also
91
+ * names its notification type when one is given, so a page opened cold knows
92
+ * which place the notice leads to: <base>?notify=<type>.
60
93
  * @param {object} target
61
94
  * @param {string} [base] the app root with a trailing slash; "/" by default.
95
+ * @param {string} [type] the notification type, used only for a system target.
62
96
  */
63
- function urlForTarget(target, base) {
97
+ function urlForTarget(target, base, type) {
64
98
  var n = makeTarget(target);
65
99
  var root = base || "/";
66
100
  if (root.charAt(root.length - 1) !== "/") root += "/";
67
- if (!n || !n.slug) return root;
101
+ if (n && n.peerId) return root + "?dm=" + encodeURIComponent(n.peerId);
102
+ if (!n || !n.slug) return typeof type === "string" && TYPE_RE.test(type) ? root + "?notify=" + type : root;
68
103
  var url = root + "p/" + n.slug + "/";
69
104
  var q = [];
70
105
  if (n.sessionId) q.push("session=" + encodeURIComponent(n.sessionId));
@@ -87,10 +122,35 @@
87
122
  return { sessionId: session, requestId: request || null };
88
123
  }
89
124
 
125
+ /**
126
+ * Reads the conversation a deep link names: the base page with ?dm=<userId>.
127
+ * @param {string} search location.search
128
+ * @returns {?string} the other person's user id.
129
+ */
130
+ function parsePeerLink(search) {
131
+ if (typeof search !== "string" || !search) return null;
132
+ var peer = new URLSearchParams(search).get("dm");
133
+ return peer && PEER_RE.test(peer) ? peer : null;
134
+ }
135
+
136
+ /**
137
+ * Reads the system notification type a cold-start deep link names.
138
+ * @param {string} search location.search
139
+ * @returns {?string}
140
+ */
141
+ function parsePlaceLink(search) {
142
+ if (typeof search !== "string" || !search) return null;
143
+ var type = new URLSearchParams(search).get("notify");
144
+ return type && TYPE_RE.test(type) ? type : null;
145
+ }
146
+
90
147
  return {
91
148
  makeTarget: makeTarget,
149
+ parsePeerLink: parsePeerLink,
150
+ parsePlaceLink: parsePlaceLink,
92
151
  targetKey: targetKey,
93
152
  sessionKey: sessionKey,
153
+ tagFor: tagFor,
94
154
  urlForTarget: urlForTarget,
95
155
  parseDeepLink: parseDeepLink,
96
156
  };
@@ -1,4 +1,5 @@
1
1
  @import url("css/base.css");
2
+ @import url("css/login-panel.css");
2
3
  @import url("css/icon-strip.css");
3
4
  @import url("css/title-bar.css");
4
5
  @import url("css/sidebar.css");
@@ -33,5 +34,9 @@
33
34
  @import url("css/at-agents.css");
34
35
  @import url("css/notifications-center.css");
35
36
  @import url("css/team-panel.css");
37
+ @import url("css/team-view.css");
38
+ @import url("css/agent-messages.css");
39
+ @import url("css/agent-roster.css");
36
40
  @import url("css/diagnostics.css");
41
+ @import url("css/user-shell.css");
37
42
 
package/lib/public/sw.js CHANGED
@@ -129,9 +129,13 @@ function notifyEnv() {
129
129
  }
130
130
 
131
131
  self.addEventListener("push", function (event) {
132
- var data = {};
133
- try { data = event.data.json(); } catch (e) { return; }
134
- event.waitUntil(NotifySw.handlePush(notifyEnv(), data).catch(function () {}));
132
+ // An unreadable payload is handled as an empty one: the push still shows the
133
+ // silent notice instead of leaving the browser to post its generic one.
134
+ var data = null;
135
+ try { data = event.data.json(); } catch (e) { data = null; }
136
+ event.waitUntil(NotifySw.handlePush(notifyEnv(), data).catch(function () {
137
+ return NotifySw.handlePush(notifyEnv(), null).catch(function () {});
138
+ }));
135
139
  });
136
140
 
137
141
  // --- Notification click ---