@clagentic/console 1.12.0 → 1.13.0-beta.1

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 (243) hide show
  1. package/README.md +7 -1
  2. package/bin/cli.js +18 -15
  3. package/lib/agent-roster-ws.js +38 -13
  4. package/lib/agent-roster.js +111 -12
  5. package/lib/agents.js +68 -33
  6. package/lib/atomic-install.js +334 -0
  7. package/lib/build-changes.js +33 -4
  8. package/lib/build-sha.json +2 -2
  9. package/lib/build-update-offer.js +12 -0
  10. package/lib/chat-width.js +31 -0
  11. package/lib/cli/agent-usage.js +126 -0
  12. package/lib/cli/arg-validation.js +1 -1
  13. package/lib/cli/compact-output.js +69 -0
  14. package/lib/cli/ipc-subcommands.js +92 -67
  15. package/lib/cli/output.js +28 -0
  16. package/lib/cli/restart-verb.js +132 -0
  17. package/lib/cli/schedule-input-subcommands.js +45 -8
  18. package/lib/cli/session-subcommands.js +37 -11
  19. package/lib/cli/settings-subcommands.js +74 -0
  20. package/lib/cli-transcript-title.js +56 -3
  21. package/lib/client-files.js +79 -0
  22. package/lib/daemon.js +100 -28
  23. package/lib/default-avatar-color.js +4 -0
  24. package/lib/drain.js +58 -10
  25. package/lib/mcp-tool-input.js +2 -2
  26. package/lib/model-families.js +49 -1
  27. package/lib/notify/type-registry.js +4 -0
  28. package/lib/notify/types.js +7 -4
  29. package/lib/pages.js +13 -63
  30. package/lib/permission-summary.js +12 -16
  31. package/lib/plan-usage-reader.js +70 -0
  32. package/lib/project-connection.js +4 -2
  33. package/lib/project-filesystem.js +6 -7
  34. package/lib/project-notifications.js +55 -8
  35. package/lib/project-prompt-expiry-settings.js +42 -0
  36. package/lib/project-sessions.js +52 -0
  37. package/lib/project-settings-gate.js +98 -0
  38. package/lib/project-user-mention.js +3 -2
  39. package/lib/project.js +1 -1
  40. package/lib/prompt-expiry-settings.js +49 -0
  41. package/lib/prompt-expiry.js +24 -3
  42. package/lib/prompt-kinds/codecs.js +6 -2
  43. package/lib/public/app.js +36 -36
  44. package/lib/public/css/admin.css +156 -170
  45. package/lib/public/css/agent-messages.css +24 -24
  46. package/lib/public/css/agent-picker.css +90 -38
  47. package/lib/public/css/agent-roster.css +61 -27
  48. package/lib/public/css/at-agents.css +10 -10
  49. package/lib/public/css/base.css +207 -184
  50. package/lib/public/css/chat-layout.css +228 -0
  51. package/lib/public/css/command-palette.css +86 -88
  52. package/lib/public/css/diagnostics.css +78 -204
  53. package/lib/public/css/diff.css +10 -10
  54. package/lib/public/css/filebrowser.css +32 -60
  55. package/lib/public/css/home-hub.css +100 -100
  56. package/lib/public/css/icon-strip.css +195 -238
  57. package/lib/public/css/input.css +191 -212
  58. package/lib/public/css/login-panel.css +16 -16
  59. package/lib/public/css/loop.css +96 -187
  60. package/lib/public/css/mention.css +49 -110
  61. package/lib/public/css/menus.css +162 -169
  62. package/lib/public/css/messages.css +49 -123
  63. package/lib/public/css/mobile-nav.css +207 -264
  64. package/lib/public/css/notifications-center.css +45 -124
  65. package/lib/public/css/overlay.css +269 -0
  66. package/lib/public/css/overlays.css +134 -156
  67. package/lib/public/css/playbook.css +41 -41
  68. package/lib/public/css/profile.css +43 -112
  69. package/lib/public/css/rewind.css +112 -112
  70. package/lib/public/css/scheduler-modal.css +27 -135
  71. package/lib/public/css/scheduler.css +204 -210
  72. package/lib/public/css/server-settings.css +173 -239
  73. package/lib/public/css/session-search.css +20 -20
  74. package/lib/public/css/settings-nav.css +197 -0
  75. package/lib/public/css/sidebar.css +213 -304
  76. package/lib/public/css/skills.css +121 -135
  77. package/lib/public/css/sticky-notes.css +114 -200
  78. package/lib/public/css/stt.css +17 -26
  79. package/lib/public/css/team-panel.css +36 -36
  80. package/lib/public/css/team-view.css +9 -9
  81. package/lib/public/css/title-bar.css +83 -100
  82. package/lib/public/css/tooltip.css +10 -10
  83. package/lib/public/css/user-settings.css +78 -131
  84. package/lib/public/css/user-shell.css +125 -29
  85. package/lib/public/index.html +178 -177
  86. package/lib/public/manifest.json +0 -2
  87. package/lib/public/modules/admin.js +54 -92
  88. package/lib/public/modules/agent-avatar.js +134 -3
  89. package/lib/public/modules/agent-messages.js +2 -1
  90. package/lib/public/modules/agent-picker.js +23 -21
  91. package/lib/public/modules/agent-roster-groups.js +128 -0
  92. package/lib/public/modules/agent-roster.js +40 -11
  93. package/lib/public/modules/app-connection.js +13 -1
  94. package/lib/public/modules/app-cursors.js +9 -9
  95. package/lib/public/modules/app-favicon.js +8 -16
  96. package/lib/public/modules/app-header.js +28 -19
  97. package/lib/public/modules/app-history-replay.js +67 -4
  98. package/lib/public/modules/app-home-hub.js +15 -0
  99. package/lib/public/modules/app-loop-ui.js +41 -47
  100. package/lib/public/modules/app-loop-wizard.js +9 -10
  101. package/lib/public/modules/app-messages.js +32 -36
  102. package/lib/public/modules/app-misc.js +22 -92
  103. package/lib/public/modules/app-modals.js +98 -0
  104. package/lib/public/modules/app-notifications.js +124 -135
  105. package/lib/public/modules/app-panels.js +28 -32
  106. package/lib/public/modules/app-projects.js +30 -40
  107. package/lib/public/modules/app-rate-limit.js +26 -9
  108. package/lib/public/modules/app-rendering.js +128 -110
  109. package/lib/public/modules/app-skills-install.js +6 -4
  110. package/lib/public/modules/assistant-identity.js +55 -0
  111. package/lib/public/modules/at-agents.js +3 -0
  112. package/lib/public/modules/build-guard.js +25 -11
  113. package/lib/public/modules/chat-width-choice.js +75 -0
  114. package/lib/public/modules/chat-width-prefs.js +52 -0
  115. package/lib/public/modules/chat-width.js +102 -0
  116. package/lib/public/modules/collapsible-text.js +36 -4
  117. package/lib/public/modules/command-palette.js +28 -34
  118. package/lib/public/modules/context-sources.js +3 -5
  119. package/lib/public/modules/diagnostics.js +130 -129
  120. package/lib/public/modules/info-panel.js +31 -0
  121. package/lib/public/modules/injected-identity.js +8 -8
  122. package/lib/public/modules/input-list-menu.js +39 -0
  123. package/lib/public/modules/input.js +22 -21
  124. package/lib/public/modules/markdown.js +10 -11
  125. package/lib/public/modules/mcp-ui.js +4 -14
  126. package/lib/public/modules/mention.js +100 -229
  127. package/lib/public/modules/message-header.js +80 -0
  128. package/lib/public/modules/message-participants.js +39 -0
  129. package/lib/public/modules/mobile-action-sheet.js +46 -0
  130. package/lib/public/modules/mobile-nav-sheet.js +104 -0
  131. package/lib/public/modules/model-families.js +41 -4
  132. package/lib/public/modules/note-order.js +39 -0
  133. package/lib/public/modules/notifications.js +35 -52
  134. package/lib/public/modules/overlay-history.js +73 -19
  135. package/lib/public/modules/overlay-menu.js +123 -0
  136. package/lib/public/modules/overlay-modal.js +186 -0
  137. package/lib/public/modules/overlay-registry.js +392 -0
  138. package/lib/public/modules/overlay-stack.js +110 -0
  139. package/lib/public/modules/overlay.js +117 -0
  140. package/lib/public/modules/popover-position.js +18 -2
  141. package/lib/public/modules/preference-sync.js +28 -0
  142. package/lib/public/modules/profile.js +24 -49
  143. package/lib/public/modules/project-settings.js +27 -172
  144. package/lib/public/modules/prompt-expiry-controls.js +46 -0
  145. package/lib/public/modules/prompt-kinds/command-summary.js +149 -0
  146. package/lib/public/modules/prompt-kinds/permission.js +70 -92
  147. package/lib/public/modules/prompts.js +1 -2
  148. package/lib/public/modules/qrcode.js +6 -21
  149. package/lib/public/modules/queued-button.js +15 -2
  150. package/lib/public/modules/rewind.js +9 -3
  151. package/lib/public/modules/schedule-time.js +32 -7
  152. package/lib/public/modules/scheduled-outbox.js +51 -18
  153. package/lib/public/modules/scheduler-config.js +87 -127
  154. package/lib/public/modules/scheduler.js +29 -26
  155. package/lib/public/modules/serialized-save.js +79 -0
  156. package/lib/public/modules/server-settings.js +75 -65
  157. package/lib/public/modules/session-grants.js +16 -19
  158. package/lib/public/modules/session-list-avatars.js +98 -0
  159. package/lib/public/modules/session-vendor-state.js +86 -0
  160. package/lib/public/modules/settings-access.js +35 -0
  161. package/lib/public/modules/settings-hub.js +125 -0
  162. package/lib/public/modules/settings-nav.js +182 -0
  163. package/lib/public/modules/shell-line.js +24 -0
  164. package/lib/public/modules/sidebar-mobile.js +151 -195
  165. package/lib/public/modules/sidebar-projects.js +88 -129
  166. package/lib/public/modules/sidebar-sessions.js +66 -34
  167. package/lib/public/modules/sidebar.js +2 -2
  168. package/lib/public/modules/skills.js +11 -26
  169. package/lib/public/modules/sticky-notes.js +19 -16
  170. package/lib/public/modules/stt.js +9 -23
  171. package/lib/public/modules/terminal.js +86 -90
  172. package/lib/public/modules/theme-choice.js +126 -0
  173. package/lib/public/modules/theme-colors.js +19 -0
  174. package/lib/public/modules/theme-prefs.js +121 -0
  175. package/lib/public/modules/theme.js +227 -605
  176. package/lib/public/modules/tool-palette.js +7 -17
  177. package/lib/public/modules/tools.js +8 -10
  178. package/lib/public/modules/user-settings.js +59 -115
  179. package/lib/public/modules/user-shell.js +9 -2
  180. package/lib/public/modules/utils.js +10 -12
  181. package/lib/public/modules/vendor-picker.js +4 -2
  182. package/lib/public/modules/vendor-registry.js +1 -2
  183. package/lib/public/style.css +3 -1
  184. package/lib/public/sw.js +9 -2
  185. package/lib/public/theme-core.js +411 -0
  186. package/lib/request-body.js +70 -0
  187. package/lib/sdk-bridge.js +227 -88
  188. package/lib/sdk-message-processor.js +44 -16
  189. package/lib/server-admin.js +198 -200
  190. package/lib/server-auth.js +16 -13
  191. package/lib/server-dm.js +4 -3
  192. package/lib/server-settings.js +177 -130
  193. package/lib/server.js +87 -36
  194. package/lib/session-background-tasks.js +79 -0
  195. package/lib/session-directory.js +138 -13
  196. package/lib/session-input-ipc.js +2 -0
  197. package/lib/session-input.js +39 -5
  198. package/lib/session-list-avatars.js +16 -0
  199. package/lib/session-reclaim.js +37 -25
  200. package/lib/session-vendor.js +37 -0
  201. package/lib/sessions.js +99 -34
  202. package/lib/settings-ipc.js +60 -0
  203. package/lib/settings-registry.js +86 -0
  204. package/lib/terminal-manager.js +17 -5
  205. package/lib/theme-files.js +132 -0
  206. package/lib/theme-seed.js +136 -0
  207. package/lib/themes/clagentic-dark.json +13 -6
  208. package/lib/themes/clagentic-light.json +12 -5
  209. package/lib/updater.js +6 -4
  210. package/lib/usage-store.js +97 -10
  211. package/lib/users-preferences.js +118 -19
  212. package/lib/users.js +19 -10
  213. package/lib/vendor-catalog.js +130 -0
  214. package/lib/ws-schema.js +4 -2
  215. package/lib/yoke/adapters/claude.js +81 -1
  216. package/lib/yoke/adapters/codex-user-shell.js +87 -23
  217. package/lib/yoke/adapters/codex.js +89 -5
  218. package/lib/yoke/codex-binary.js +59 -0
  219. package/package.json +1 -1
  220. package/scripts/check-test-count.js +5 -0
  221. package/scripts/install-local-test.js +50 -9
  222. package/scripts/write-build-sha.js +18 -2
  223. package/lib/public/css/channel-layout.css +0 -329
  224. package/lib/themes/ayu-light.json +0 -9
  225. package/lib/themes/catppuccin-latte.json +0 -9
  226. package/lib/themes/catppuccin-mocha.json +0 -9
  227. package/lib/themes/dracula.json +0 -9
  228. package/lib/themes/everforest-light.json +0 -9
  229. package/lib/themes/everforest.json +0 -9
  230. package/lib/themes/github-light.json +0 -9
  231. package/lib/themes/gruvbox-dark.json +0 -9
  232. package/lib/themes/gruvbox-light.json +0 -9
  233. package/lib/themes/monokai.json +0 -9
  234. package/lib/themes/nord-light.json +0 -9
  235. package/lib/themes/nord.json +0 -9
  236. package/lib/themes/one-dark.json +0 -9
  237. package/lib/themes/one-light.json +0 -9
  238. package/lib/themes/rose-pine-dawn.json +0 -9
  239. package/lib/themes/rose-pine.json +0 -9
  240. package/lib/themes/solarized-dark.json +0 -9
  241. package/lib/themes/solarized-light.json +0 -9
  242. package/lib/themes/tokyo-night-light.json +0 -9
  243. package/lib/themes/tokyo-night.json +0 -9
@@ -47,7 +47,7 @@ var formatters = {
47
47
  build_update_offer: function (data) {
48
48
  return {
49
49
  type: "build_update_offer",
50
- title: data.title || "A newer build is installed",
50
+ title: data.title || "",
51
51
  body: data.body || "",
52
52
  meta: {
53
53
  message: data.message || "",
@@ -111,6 +111,27 @@ var formatters = {
111
111
  };
112
112
  },
113
113
 
114
+ // A question to the person and an MCP server's request for input. Not
115
+ // actionable from the banner: the answer needs the prompt card, so a click goes
116
+ // to the session. Closed by the prompt registry when the prompt settles.
117
+ ask_user: function (data) {
118
+ return {
119
+ type: "ask_user",
120
+ title: data.title || "Claude has a question",
121
+ body: data.body || "",
122
+ meta: { requestId: data.requestId, kind: "ask_user" },
123
+ };
124
+ },
125
+
126
+ elicitation: function (data) {
127
+ return {
128
+ type: "elicitation",
129
+ title: data.title || "Input requested",
130
+ body: data.body || "",
131
+ meta: { requestId: data.requestId, kind: "elicitation" },
132
+ };
133
+ },
134
+
114
135
  // The one live reminder of a session's unanswered prompts (see
115
136
  // lib/prompt-reminders.js). Not actionable: it names what waits, and a click
116
137
  // goes to the session, where the prompt card answers.
@@ -199,7 +220,7 @@ function attachNotifications(ctx) {
199
220
  return parsed.filter(function (n) {
200
221
  if (!n) return false;
201
222
  var registered = notifyCore.getType(n.type);
202
- return !(n.type === "permission_request" || n.type === "permission_reminder" || (registered && registered.ephemeral));
223
+ return !(registered && (registered.ephemeral || registered.liveInState)) && n.type !== "permission_request" && n.type !== "permission_reminder";
203
224
  });
204
225
  }
205
226
  } catch (e) {}
@@ -305,7 +326,8 @@ function attachNotifications(ctx) {
305
326
  return notif;
306
327
  }
307
328
 
308
- function dismiss(ids) {
329
+ function dismiss(ids, opts) {
330
+ var replaced = !!(opts && opts.replaced);
309
331
  var before = notifications.length;
310
332
  notifications = notifications.filter(function(n) { return ids.indexOf(n.id) === -1; });
311
333
  if (notifications.length !== before) {
@@ -314,6 +336,7 @@ function attachNotifications(ctx) {
314
336
  return {
315
337
  type: "notification_dismissed",
316
338
  ids: ids,
339
+ replaced: replaced,
317
340
  unreadCount: broadcastPerViewer ? unreadCountFor(viewer) : getUnreadCount(),
318
341
  };
319
342
  });
@@ -327,7 +350,9 @@ function attachNotifications(ctx) {
327
350
  var key = meta && meta.key;
328
351
  if (key) {
329
352
  var old = idsByKey([key]);
330
- if (old.length) dismiss(old);
353
+ // Marked as a replacement: the page keeps what it shows for the key
354
+ // (an offer's pop-up) and swaps it for the notification that follows.
355
+ if (old.length) dismiss(old, { replaced: true });
331
356
  }
332
357
  return notify(event, data, meta);
333
358
  }
@@ -376,12 +401,32 @@ function attachNotifications(ctx) {
376
401
  });
377
402
  }
378
403
 
404
+ // A type that asks the operator for a decision (the build-update offer) is
405
+ // not cleared with the rest: it ends by its own close or its resolve, so a
406
+ // clear-all never declines it. The message names what stands.
407
+ function survivesClearAll(n) {
408
+ var type = notifyCore.getType(n.type);
409
+ return !!(type && type.survivesClearAll);
410
+ }
411
+
379
412
  function dismissAll() {
380
413
  if (notifications.length > 0) {
381
- var closing = notifications;
382
- notifications = [];
414
+ var closing = notifications.filter(function (n) { return !survivesClearAll(n); });
415
+ notifications = notifications.filter(survivesClearAll);
416
+ var standing = notifications;
383
417
  saveNotifications();
384
- broadcastAll({ type: "notification_dismissed_all", unreadCount: 0 });
418
+ deliver(null, function (viewer) {
419
+ // The ids a viewer is told are only those it can see: an admin-only
420
+ // offer's id is not handed to anyone else. Without per-viewer delivery
421
+ // there is one message for everyone, as with the unread count.
422
+ var kept = standing.filter(function (n) { return !broadcastPerViewer || visibleTo(n, viewer); })
423
+ .map(function (n) { return n.id; });
424
+ return {
425
+ type: "notification_dismissed_all",
426
+ kept: kept,
427
+ unreadCount: broadcastPerViewer ? unreadCountFor(viewer) : getUnreadCount(),
428
+ };
429
+ });
385
430
  resolveDismissed(closing);
386
431
  }
387
432
  }
@@ -422,13 +467,15 @@ function attachNotifications(ctx) {
422
467
  // A notification aimed at admins only, or a prompt banner aimed at its
423
468
  // owner, is not handed to anyone else on connect, as it is not live.
424
469
  var viewer = userIdOf(ws);
470
+ // The preferences first: the page decides whether a standing offer pops up
471
+ // from the state that follows, by the user's banner choice for its category.
472
+ if (prefsStore) sendTo(ws, prefsMessage(viewer));
425
473
  sendTo(ws, {
426
474
  type: "notifications_state",
427
475
  notifications: notifications.filter(function (n) { return visibleTo(n, viewer); }),
428
476
  unreadCount: unreadCountFor(viewer),
429
477
  livePrompts: livePrompts || null,
430
478
  });
431
- if (prefsStore) sendTo(ws, prefsMessage(userIdOf(ws)));
432
479
  }
433
480
 
434
481
  // --- Per-user preferences (lib/notification-prefs.js) ---
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+
3
+ // The WebSocket side of the prompt expiry setting (lib/prompt-expiry-settings.js):
4
+ // one message to change it, admin only, answered to every client of the server
5
+ // so an open settings page follows the change. A refused request saves nothing.
6
+ //
7
+ // ctx fields: slug, sendTo, send, opts (onGetPromptExpirySettings,
8
+ // onSetPromptExpirySettings, broadcastAll), projectAccess
9
+
10
+ var promptExpirySettings = require("./prompt-expiry-settings");
11
+ var { isServerAdmin } = require("./project-permission-settings");
12
+
13
+ function attachPromptExpirySettings(ctx) {
14
+ var opts = ctx.opts || {};
15
+
16
+ function refuse(ws, text) {
17
+ ctx.sendTo(ws, { type: "error", text: text });
18
+ return true;
19
+ }
20
+
21
+ /** Returns true when msg was a prompt-expiry message (handled). */
22
+ function handlePromptExpiryMessage(ws, msg) {
23
+ if (msg.type !== "set_prompt_expiry_settings") return false;
24
+ if (!isServerAdmin(ctx.projectAccess, ws)) {
25
+ console.warn("[project-prompt-expiry-settings] refused set_prompt_expiry_settings in " + ctx.slug + ": caller is not an admin");
26
+ return refuse(ws, "Only admins can change the prompt expiry.");
27
+ }
28
+ var picked = promptExpirySettings.pickSettingChange(msg);
29
+ if (!picked.ok) return refuse(ws, picked.reason);
30
+ if (typeof opts.onSetPromptExpirySettings !== "function" || typeof opts.onGetPromptExpirySettings !== "function") {
31
+ return refuse(ws, "The server cannot store the prompt expiry.");
32
+ }
33
+ opts.onSetPromptExpirySettings(picked.minutes);
34
+ var announce = typeof opts.broadcastAll === "function" ? opts.broadcastAll : ctx.send;
35
+ announce(opts.onGetPromptExpirySettings());
36
+ return true;
37
+ }
38
+
39
+ return { handlePromptExpiryMessage: handlePromptExpiryMessage };
40
+ }
41
+
42
+ module.exports = { attachPromptExpirySettings: attachPromptExpirySettings };
@@ -19,6 +19,8 @@ var { isKnownVendor } = require("./yoke");
19
19
  var sessionCapabilities = require("./session-capabilities");
20
20
  var { checkPermissionMode } = require("./permission-mode-policy");
21
21
  var { attachPermissionSettings, isServerAdmin } = require("./project-permission-settings");
22
+ var { attachPromptExpirySettings } = require("./project-prompt-expiry-settings");
23
+ var { createProjectSettingsGate } = require("./project-settings-gate");
22
24
  var { effectiveSessionMode } = require("./sessions");
23
25
  var { composeRestartingNotice } = require("./build-update-offer");
24
26
  var { notifyFor } = require("./notify");
@@ -43,6 +45,10 @@ if (!process.env.NODE_TEST_CONTEXT) {
43
45
  agentsModule.refresh().catch(function (e) {
44
46
  console.error("[project-sessions] initial agent refresh failed:", e && e.message ? e.message : e);
45
47
  });
48
+ // The vendor's own built-in helpers feed the vendor catalog (lib/vendor-catalog.js).
49
+ agentsModule.refreshBuiltinHelpers(require("./vendor-catalog").defaultCatalog).catch(function (e) {
50
+ console.error("[project-sessions] built-in helper discovery failed:", e && e.message ? e.message : e);
51
+ });
46
52
  }
47
53
 
48
54
  /**
@@ -162,6 +168,24 @@ function attachSessions(ctx) {
162
168
  projectAccess: projectAccess,
163
169
  checkRequestedMode: checkRequestedMode,
164
170
  });
171
+ var promptExpirySettings = attachPromptExpirySettings({
172
+ slug: slug,
173
+ sendTo: sendTo,
174
+ send: send,
175
+ opts: opts,
176
+ projectAccess: projectAccess,
177
+ });
178
+ // The shared rule for every project- or folder-scoped setting write.
179
+ var settingsGate = createProjectSettingsGate({
180
+ projectAccess: projectAccess, usersModule: usersModule, osUsers: osUsers, sendTo: sendTo,
181
+ });
182
+
183
+ // The slugs of every project in a folder, or none when the server cannot say
184
+ // (the gate then refuses a non-administrator).
185
+ function folderMembers(folderName) {
186
+ if (typeof opts.getFolderProjectSlugs !== "function" || typeof folderName !== "string") return [];
187
+ return opts.getFolderProjectSlugs(folderName);
188
+ }
165
189
 
166
190
  // The shared mode check (lib/permission-mode-policy.js) for a mode that a
167
191
  // client asks for. `session` is the session it would run in, or null for a
@@ -214,6 +238,18 @@ function attachSessions(ctx) {
214
238
  return false;
215
239
  }
216
240
 
241
+ // Gate for the server-wide setters that persist or apply to every project.
242
+ // Same administrator check as set_server_default_mode (isServerAdmin: in
243
+ // single-user mode the authenticated connection is the implicit admin).
244
+ // Returns true when the request was refused (logged and answered), false
245
+ // when the caller may go on.
246
+ function refuseNonAdminServerWide(ws, what, text) {
247
+ if (isServerAdmin(projectAccess, ws)) return false;
248
+ console.warn("[project-sessions] refused " + what + " in " + slug + ": caller is not an admin");
249
+ sendTo(ws, { type: "error", text: text });
250
+ return true;
251
+ }
252
+
217
253
  // The mode a client is shown for a session (sessions.js effectiveSessionMode).
218
254
  function shownMode(session) {
219
255
  return effectiveSessionMode(session, sm);
@@ -268,6 +304,7 @@ function attachSessions(ctx) {
268
304
  if (promptResponses.handlePromptMessage(ws, msg)) return true;
269
305
  if (sessionGrants.handleGrantMessage(ws, msg)) return true;
270
306
  if (permissionSettings.handlePermissionSettingsMessage(ws, msg)) return true;
307
+ if (promptExpirySettings.handlePromptExpiryMessage(ws, msg)) return true;
271
308
 
272
309
  if (msg.type === "push_subscribe") {
273
310
  var _pushUserId = ws._clagenticUser ? ws._clagenticUser.id : null;
@@ -792,6 +829,7 @@ function attachSessions(ctx) {
792
829
  }
793
830
 
794
831
  if (msg.type === "set_update_channel") {
832
+ if (refuseNonAdminServerWide(ws, "set_update_channel", "Only admins can change the update channel.")) return true;
795
833
  var channel = msg.channel === "beta" ? "beta" : "stable";
796
834
  ctx.setUpdateChannel && ctx.setUpdateChannel(channel);
797
835
  return true;
@@ -1061,6 +1099,7 @@ function attachSessions(ctx) {
1061
1099
  }
1062
1100
 
1063
1101
  if (msg.type === "set_server_default_model" && msg.model) {
1102
+ if (refuseNonAdminServerWide(ws, "set_server_default_model", "Only admins can change the server default model.")) return true;
1064
1103
  if (typeof opts.onSetServerDefaultModel === "function") {
1065
1104
  opts.onSetServerDefaultModel(msg.model);
1066
1105
  }
@@ -1078,6 +1117,7 @@ function attachSessions(ctx) {
1078
1117
  }
1079
1118
 
1080
1119
  if (msg.type === "set_project_default_model" && msg.model) {
1120
+ if (settingsGate.refuse(ws, msg.type, slug)) return true;
1081
1121
  if (typeof opts.onSetProjectDefaultModel === "function") {
1082
1122
  opts.onSetProjectDefaultModel(slug, msg.model);
1083
1123
  }
@@ -1121,6 +1161,7 @@ function attachSessions(ctx) {
1121
1161
  }
1122
1162
 
1123
1163
  if (msg.type === "set_project_default_mode" && msg.mode) {
1164
+ if (settingsGate.refuse(ws, msg.type, slug, getProjectOwnerId ? getProjectOwnerId() : null)) return true;
1124
1165
  if (refuseDefaultMode(ws, msg)) return true;
1125
1166
  if (typeof opts.onSetProjectDefaultMode === "function") {
1126
1167
  opts.onSetProjectDefaultMode(slug, msg.mode);
@@ -1151,6 +1192,7 @@ function attachSessions(ctx) {
1151
1192
  }
1152
1193
 
1153
1194
  if (msg.type === "set_server_default_effort" && msg.effort) {
1195
+ if (refuseNonAdminServerWide(ws, "set_server_default_effort", "Only admins can change the server default effort level.")) return true;
1154
1196
  if (typeof opts.onSetServerDefaultEffort === "function") {
1155
1197
  opts.onSetServerDefaultEffort(msg.effort);
1156
1198
  }
@@ -1160,6 +1202,7 @@ function attachSessions(ctx) {
1160
1202
  }
1161
1203
 
1162
1204
  if (msg.type === "set_project_default_effort" && msg.effort) {
1205
+ if (settingsGate.refuse(ws, msg.type, slug)) return true;
1163
1206
  if (typeof opts.onSetProjectDefaultEffort === "function") {
1164
1207
  opts.onSetProjectDefaultEffort(slug, msg.effort);
1165
1208
  }
@@ -1175,6 +1218,7 @@ function attachSessions(ctx) {
1175
1218
  }
1176
1219
 
1177
1220
  if (msg.type === "set_server_default_betas") {
1221
+ if (refuseNonAdminServerWide(ws, "set_server_default_betas", "Only admins can change the server default beta flags.")) return true;
1178
1222
  if (typeof opts.onSetServerDefaultBetas === "function") {
1179
1223
  opts.onSetServerDefaultBetas(msg.betas || []);
1180
1224
  }
@@ -1184,6 +1228,7 @@ function attachSessions(ctx) {
1184
1228
  }
1185
1229
 
1186
1230
  if (msg.type === "set_project_default_betas") {
1231
+ if (settingsGate.refuse(ws, msg.type, slug)) return true;
1187
1232
  if (typeof opts.onSetProjectDefaultBetas === "function") {
1188
1233
  opts.onSetProjectDefaultBetas(slug, msg.betas || []);
1189
1234
  }
@@ -1695,6 +1740,7 @@ function attachSessions(ctx) {
1695
1740
  sendTo(ws, { type: "set_project_title_result", ok: false, error: "Missing slug" });
1696
1741
  return true;
1697
1742
  }
1743
+ if (settingsGate.refuse(ws, msg.type, msg.slug)) return true;
1698
1744
  if (typeof opts.onSetProjectTitle === "function") {
1699
1745
  var titleResult = opts.onSetProjectTitle(msg.slug, msg.title || null);
1700
1746
  sendTo(ws, { type: "set_project_title_result", ok: titleResult.ok, slug: msg.slug, error: titleResult.error });
@@ -1710,6 +1756,7 @@ function attachSessions(ctx) {
1710
1756
  sendTo(ws, { type: "set_project_icon_result", ok: false, error: "Missing slug" });
1711
1757
  return true;
1712
1758
  }
1759
+ if (settingsGate.refuse(ws, msg.type, msg.slug)) return true;
1713
1760
  if (typeof opts.onSetProjectIcon === "function") {
1714
1761
  var iconResult = opts.onSetProjectIcon(msg.slug, msg.icon || null);
1715
1762
  sendTo(ws, { type: "set_project_icon_result", ok: iconResult.ok, slug: msg.slug, error: iconResult.error });
@@ -1725,6 +1772,7 @@ function attachSessions(ctx) {
1725
1772
  sendTo(ws, { type: "set_project_preferred_agent_result", ok: false, error: "Missing slug" });
1726
1773
  return true;
1727
1774
  }
1775
+ if (settingsGate.refuse(ws, msg.type, msg.slug)) return true;
1728
1776
  if (typeof opts.onSetProjectPreferredAgent === "function") {
1729
1777
  // agent is null to clear, or { name, kind, pluginName } to set
1730
1778
  var agentVal = msg.agent || null;
@@ -1742,6 +1790,7 @@ function attachSessions(ctx) {
1742
1790
  sendTo(ws, { type: "set_project_folder_result", ok: false, error: "Missing slug" });
1743
1791
  return true;
1744
1792
  }
1793
+ if (settingsGate.refuse(ws, msg.type, msg.slug)) return true;
1745
1794
  if (typeof opts.onSetProjectFolder === "function") {
1746
1795
  var folderResult = opts.onSetProjectFolder(msg.slug, msg.folderName || null);
1747
1796
  sendTo(ws, { type: "set_project_folder_result", ok: folderResult.ok, slug: msg.slug, error: folderResult.error });
@@ -1757,6 +1806,7 @@ function attachSessions(ctx) {
1757
1806
  sendTo(ws, { type: "rename_project_folder_result", ok: false, error: "Missing oldName or newName" });
1758
1807
  return true;
1759
1808
  }
1809
+ if (settingsGate.refuseFolder(ws, msg.type, msg.oldName, folderMembers(msg.oldName))) return true;
1760
1810
  if (typeof opts.onRenameProjectFolder === "function") {
1761
1811
  var renameResult = opts.onRenameProjectFolder(msg.oldName, msg.newName);
1762
1812
  sendTo(ws, { type: "rename_project_folder_result", ok: renameResult.ok, error: renameResult.error });
@@ -1772,6 +1822,7 @@ function attachSessions(ctx) {
1772
1822
  sendTo(ws, { type: "set_folder_icon_result", ok: false, error: "Missing folderName" });
1773
1823
  return true;
1774
1824
  }
1825
+ if (settingsGate.refuseFolder(ws, msg.type, msg.folderName, folderMembers(msg.folderName))) return true;
1775
1826
  if (typeof opts.onSetFolderIcon === "function") {
1776
1827
  var fIconResult = opts.onSetFolderIcon(msg.folderName, msg.icon || null);
1777
1828
  sendTo(ws, { type: "set_folder_icon_result", ok: fIconResult.ok, error: fIconResult.error });
@@ -1820,6 +1871,7 @@ function attachSessions(ctx) {
1820
1871
  // not msg.message -- both admin-gate rejections in this file used
1821
1872
  // to send `message:`, so the frame arrived client-side but rendered
1822
1873
  // as addSystemMessage(undefined, true), effectively swallowed.
1874
+ console.warn("[project-sessions] refused " + msg.type + " in " + slug + ": caller is not an admin");
1823
1875
  sendTo(ws, { type: "error", text: "Admin access required" });
1824
1876
  return true;
1825
1877
  }
@@ -0,0 +1,98 @@
1
+ "use strict";
2
+
3
+ // The one server-side rule for every message that writes a project-scoped or
4
+ // folder-scoped setting: the caller needs the projectSettings permission AND
5
+ // access to the project the write lands on. It is the rule the client applies
6
+ // before it opens Project Settings (public/modules/settings-access.js), now
7
+ // enforced where a hand-built message cannot skip it.
8
+ //
9
+ // Administrators hold every permission and every project (users-permissions.js),
10
+ // and an owner reaches their own project through the same access check. In
11
+ // single-user mode the authenticated connection is the implicit owner and is
12
+ // let through; a user record on a single-user connection still needs the
13
+ // permission, as it did before.
14
+
15
+ var REFUSAL_TEXT = "Project settings access is not permitted";
16
+
17
+ // Every reason is a fixed string so a log line never carries caller input.
18
+ var REASON = {
19
+ unauthenticated: "caller is not authenticated",
20
+ permission: "caller lacks the projectSettings permission",
21
+ access: "caller cannot access the target project",
22
+ emptyFolder: "the named folder holds no project",
23
+ unavailable: "the permission check is not available",
24
+ };
25
+
26
+ // Log fields echo caller-chosen text; keep them short and single-line.
27
+ function logSlug(value) {
28
+ var s = typeof value === "string" ? value : "";
29
+ return JSON.stringify(s.length > 80 ? s.slice(0, 80) : s);
30
+ }
31
+
32
+ /**
33
+ * deps: projectAccess (lib/project-access.js), usersModule (getEffectivePermissions),
34
+ * osUsers (os-users mode flag), sendTo(ws, msg)
35
+ * Returns { refuse(ws, type, targetSlug, ownerId?), refuseFolder(ws, type, folderName, memberSlugs) }:
36
+ * true when the message was refused (logged and answered, nothing written),
37
+ * false when the caller may go on.
38
+ */
39
+ function createProjectSettingsGate(deps) {
40
+ var projectAccess = deps.projectAccess;
41
+ var usersModule = deps.usersModule;
42
+ var osUsers = !!deps.osUsers;
43
+ var sendTo = deps.sendTo;
44
+
45
+ // slugs: every project the write lands on (one for a project setter, each
46
+ // member of the folder for a folder setter). A folder with no members fails
47
+ // closed for a non-administrator: there is nothing to prove access to.
48
+ // ownerId: the target project's owner, for a setter whose rule has always let
49
+ // the owner in without the permission (the project default permission mode).
50
+ function verdict(ws, slugs, ownerId) {
51
+ if (!projectAccess || typeof projectAccess.principalFor !== "function") return REASON.unavailable;
52
+ var principal = projectAccess.principalFor(ws._clagenticUser, projectAccess.authOf(ws));
53
+ if (!principal) return REASON.unauthenticated;
54
+ if (principal.implicit) return null;
55
+ var isOwner = !!ownerId && principal.id === ownerId;
56
+ // An administrator holds every permission (users-permissions.js).
57
+ if (!principal.admin && !isOwner) {
58
+ if (!usersModule || typeof usersModule.getEffectivePermissions !== "function") return REASON.unavailable;
59
+ var perms = usersModule.getEffectivePermissions(principal.user, osUsers);
60
+ if (!perms || !perms.projectSettings) return REASON.permission;
61
+ }
62
+ // ...and every project, and an owner reaches their own, so neither needs a
63
+ // per-project lookup.
64
+ if (principal.admin || isOwner) return null;
65
+ if (!slugs.length) return REASON.emptyFolder;
66
+ var multiUser = typeof projectAccess.isMultiUser === "function" ? projectAccess.isMultiUser() : true;
67
+ if (!multiUser) return null;
68
+ var proof = projectAccess.authOf(ws);
69
+ for (var i = 0; i < slugs.length; i++) {
70
+ if (!projectAccess.canAccess(principal.id, slugs[i], proof)) return REASON.access;
71
+ }
72
+ return null;
73
+ }
74
+
75
+ function deny(ws, type, label, reason) {
76
+ console.warn("[project-settings-gate] refused " + type + " for " + label + ": " + reason);
77
+ sendTo(ws, { type: "error", text: REFUSAL_TEXT });
78
+ return true;
79
+ }
80
+
81
+ function refuse(ws, type, targetSlug, ownerId) {
82
+ var reason = verdict(ws, [targetSlug], ownerId);
83
+ return reason ? deny(ws, type, logSlug(targetSlug), reason) : false;
84
+ }
85
+
86
+ // Folder setters change a folder that can hold other users' projects, so the
87
+ // caller must reach every project in the named folder, not just the project
88
+ // the connection is open on. memberSlugs: slugs currently in that folder.
89
+ function refuseFolder(ws, type, folderName, memberSlugs) {
90
+ var members = Array.isArray(memberSlugs) ? memberSlugs : [];
91
+ var reason = verdict(ws, members, null);
92
+ return reason ? deny(ws, type, "folder " + logSlug(folderName), reason) : false;
93
+ }
94
+
95
+ return { refuse: refuse, refuseFolder: refuseFolder };
96
+ }
97
+
98
+ module.exports = { createProjectSettingsGate: createProjectSettingsGate, REFUSAL_TEXT: REFUSAL_TEXT };
@@ -13,6 +13,7 @@
13
13
  // tracking simple. Multi-target support can be layered on later.
14
14
 
15
15
  var { notifyFor } = require("./notify");
16
+ var { DEFAULT_AVATAR_COLOR } = require("./default-avatar-color");
16
17
 
17
18
  function attachUserMention(ctx) {
18
19
  var slug = ctx.slug || "";
@@ -51,7 +52,7 @@ function attachUserMention(ctx) {
51
52
  return {
52
53
  style: p.avatarStyle || "thumbs",
53
54
  seed: p.avatarSeed || u.username || u.id,
54
- color: p.avatarColor || "#7c3aed",
55
+ color: p.avatarColor || DEFAULT_AVATAR_COLOR,
55
56
  custom: p.avatarCustom || "",
56
57
  };
57
58
  }
@@ -67,7 +68,7 @@ function attachUserMention(ctx) {
67
68
  username: u.username,
68
69
  avatarStyle: p.avatarStyle || "thumbs",
69
70
  avatarSeed: p.avatarSeed || u.username,
70
- avatarColor: p.avatarColor || "#7c3aed",
71
+ avatarColor: p.avatarColor || DEFAULT_AVATAR_COLOR,
71
72
  };
72
73
  }
73
74
 
package/lib/project.js CHANGED
@@ -454,7 +454,7 @@ function createProjectContext(opts) {
454
454
  });
455
455
  sm.availableVendors = Object.keys(adapters);
456
456
  sm.defaultVendor = defaultVendor;
457
- // Sessions the previous shutdown ended with background agents running.
457
+ // Sessions the previous shutdown ended with a query or background agents running.
458
458
  sessionReclaim.surfaceRestartReclaims({ sm: sm });
459
459
 
460
460
  var _projMode = typeof opts.onGetProjectDefaultMode === "function" ? opts.onGetProjectDefaultMode(slug) : null;
@@ -0,0 +1,49 @@
1
+ "use strict";
2
+
3
+ // The settings API for the unanswered-prompt bound (lib/prompt-expiry.js): which
4
+ // values a client may set, how daemon.json is updated, and the wire message that
5
+ // tells clients the current value. The registry reads daemon.json at each
6
+ // open(), so a saved change applies to the next prompt with no restart.
7
+
8
+ var { KEY, DEFAULT_MINUTES, MAX_MINUTES, readExpiryMinutes } = require("./prompt-expiry");
9
+
10
+ function isMinutes(v) {
11
+ return typeof v === "number" && isFinite(v) && Math.floor(v) === v && v >= 0 && v <= MAX_MINUTES;
12
+ }
13
+
14
+ /**
15
+ * The change a request asks for, or a reason it is refused.
16
+ * @returns {{ok: true, minutes: number}|{ok: false, reason: string}}
17
+ */
18
+ function pickSettingChange(request) {
19
+ var req = request || {};
20
+ var extra = Object.keys(req).filter(function (name) { return name !== "type" && name !== KEY; });
21
+ if (extra.length > 0) return { ok: false, reason: "Unknown prompt expiry setting: " + extra.join(", ") };
22
+ if (!isMinutes(req[KEY])) {
23
+ return { ok: false, reason: KEY + " must be a whole number of minutes from 0 (no expiry) to " + MAX_MINUTES + "." };
24
+ }
25
+ return { ok: true, minutes: req[KEY] };
26
+ }
27
+
28
+ /** The wire message that tells a client the current setting. */
29
+ function settingsMessage(config) {
30
+ var message = { type: "prompt_expiry_settings" };
31
+ message[KEY] = readExpiryMinutes(config);
32
+ return message;
33
+ }
34
+
35
+ /**
36
+ * Applies an accepted value to a daemon configuration object; the default is
37
+ * removed so daemon.json keeps showing only what was changed.
38
+ */
39
+ function applySettingChange(config, minutes) {
40
+ if (minutes === DEFAULT_MINUTES) delete config[KEY];
41
+ else config[KEY] = minutes;
42
+ return config;
43
+ }
44
+
45
+ module.exports = {
46
+ pickSettingChange: pickSettingChange,
47
+ settingsMessage: settingsMessage,
48
+ applySettingChange: applySettingChange,
49
+ };
@@ -4,17 +4,32 @@
4
4
  // `promptExpiryMinutes`. Read at each open(), so an edit applies to the next
5
5
  // prompt; a prompt already open keeps the deadline it was given.
6
6
  //
7
- // absent -> 1440 (24 hours)
7
+ // absent -> 30 minutes
8
8
  // 0 -> no expiry
9
9
  // positive number -> that many minutes
10
10
  // anything else -> the default, with one warning naming the key
11
11
  //
12
12
  // Malformed means: not a number, negative, not finite, or beyond what a timer
13
13
  // can hold (a larger value would make setTimeout fire at once).
14
+ // An administrator sets it in Settings (lib/prompt-expiry-settings.js).
14
15
 
15
16
  var KEY = "promptExpiryMinutes";
16
- var DEFAULT_MINUTES = 1440;
17
+ var DEFAULT_MINUTES = 30;
17
18
  var MAX_TIMER_MS = 2147483647;
19
+ // The largest whole number of minutes a timer can hold.
20
+ var MAX_MINUTES = Math.floor(MAX_TIMER_MS / 60000);
21
+
22
+ /**
23
+ * @param {?object} cfg - the daemon configuration.
24
+ * @returns {number} the configured minutes (0 = no expiry), or the default when
25
+ * the key is absent or malformed. Never warns: it is for showing the setting.
26
+ */
27
+ function readExpiryMinutes(cfg) {
28
+ var v = cfg ? cfg[KEY] : undefined;
29
+ if (typeof v !== "number" || !isFinite(v) || v < 0) return DEFAULT_MINUTES;
30
+ if (v === 0) return 0;
31
+ return Math.max(1, Math.round(v * 60000)) > MAX_TIMER_MS ? DEFAULT_MINUTES : v;
32
+ }
18
33
 
19
34
  /**
20
35
  * @returns {function(?object): number} (daemon config) -> expiry in ms, 0 for
@@ -47,4 +62,10 @@ function createExpiryReader() {
47
62
  };
48
63
  }
49
64
 
50
- module.exports = { createExpiryReader: createExpiryReader, KEY: KEY, DEFAULT_MINUTES: DEFAULT_MINUTES };
65
+ module.exports = {
66
+ createExpiryReader: createExpiryReader,
67
+ readExpiryMinutes: readExpiryMinutes,
68
+ KEY: KEY,
69
+ DEFAULT_MINUTES: DEFAULT_MINUTES,
70
+ MAX_MINUTES: MAX_MINUTES,
71
+ };
@@ -1,7 +1,8 @@
1
1
  "use strict";
2
2
 
3
3
  // The server's handle on the modules it shares with the browser: the answer
4
- // codecs (ask-user-codec.js, elicitation-codec.js) and the own-key lookups.
4
+ // codecs (ask-user-codec.js, elicitation-codec.js), the own-key lookups and the
5
+ // command naming (command-summary.js).
5
6
  // Each has one source, the ES module the browser is served from
6
7
  // lib/public/modules/prompt-kinds/; the package.json beside them declares
7
8
  // them ES modules, so every supported Node loads them as such.
@@ -22,6 +23,7 @@ var FILES = {
22
23
  askUser: "ask-user-codec.js",
23
24
  elicitation: "elicitation-codec.js",
24
25
  ownKey: "own-key.js",
26
+ commandSummary: "command-summary.js",
25
27
  };
26
28
  var NAMES = Object.keys(FILES);
27
29
  // How a Node that cannot require() these modules refuses; they then load
@@ -63,7 +65,7 @@ function loadOnce() {
63
65
 
64
66
  /**
65
67
  * Load every shared module, once. Resolves to {askUser, elicitation,
66
- * ownKey}; rejects, naming the directory, when any of them fails to load.
68
+ * ownKey, commandSummary}; rejects, naming the directory, when any of them fails to load.
67
69
  * @returns {Promise<object>}
68
70
  */
69
71
  function load() {
@@ -79,6 +81,7 @@ function loaded(name) {
79
81
  function askUser() { return loaded("askUser"); }
80
82
  function elicitation() { return loaded("elicitation"); }
81
83
  function ownKey() { return loaded("ownKey"); }
84
+ function commandSummary() { return loaded("commandSummary"); }
82
85
 
83
86
  // The own-key lookups, called through so a caller can take them by name.
84
87
  function hasOwnKey(map, key) { return ownKey().hasOwnKey(map, key); }
@@ -91,6 +94,7 @@ module.exports = {
91
94
  askUser: askUser,
92
95
  elicitation: elicitation,
93
96
  ownKey: ownKey,
97
+ commandSummary: commandSummary,
94
98
  hasOwnKey: hasOwnKey,
95
99
  ownValue: ownValue,
96
100
  putOwn: putOwn,