@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
package/lib/drain.js CHANGED
@@ -2,7 +2,9 @@
2
2
  //
3
3
  // Two distinct states, deliberately not merged:
4
4
  //
5
- // Drain (operator-initiated restart): entered by SIGUSR1 or SIGUSR2.
5
+ // Drain (operator-initiated restart): entered by SIGUSR1 or SIGUSR2, and by
6
+ // SIGTERM/SIGINT with a short bound (enterTermDrain) that fits the unit's
7
+ // stop timeout.
6
8
  // - New WebSocket connections are rejected with a structured error.
7
9
  // - In-flight sessions are allowed to complete; the controller polls
8
10
  // opts.getActiveCount() and exits once it hits zero.
@@ -34,6 +36,19 @@ var DEFAULT_DRAIN_TIMEOUT_MS = 60 * 1000;
34
36
  // How often to check the live-query count after entering drain state.
35
37
  var DRAIN_POLL_INTERVAL_MS = 1000;
36
38
 
39
+ // SIGTERM (systemctl stop/restart) drain bound. The unit's TimeoutStopSec is
40
+ // 20 s and gracefulShutdown() arms its own 10 s forced exit once it starts, so
41
+ // the drain wait plus that 10 s must stay under 20 s with margin. The default
42
+ // leaves 4 s of margin (6 + 10 = 16 s); the ceiling leaves 2 s (8 + 10 = 18 s)
43
+ // and clamps any configured value.
44
+ var DEFAULT_SIGTERM_DRAIN_TIMEOUT_MS = 6 * 1000;
45
+ var MAX_SIGTERM_DRAIN_TIMEOUT_MS = 8 * 1000;
46
+
47
+ function resolveSigtermTimeoutMs(configured) {
48
+ if (typeof configured !== 'number' || !(configured > 0)) return DEFAULT_SIGTERM_DRAIN_TIMEOUT_MS;
49
+ return Math.min(configured, MAX_SIGTERM_DRAIN_TIMEOUT_MS);
50
+ }
51
+
37
52
  /**
38
53
  * Create a drain controller.
39
54
  *
@@ -69,6 +84,7 @@ function createDrain(opts) {
69
84
  var drainTimeoutMs = (opts.drainTimeoutMs != null && opts.drainTimeoutMs > 0)
70
85
  ? opts.drainTimeoutMs
71
86
  : DEFAULT_DRAIN_TIMEOUT_MS;
87
+ var sigtermTimeoutMs = resolveSigtermTimeoutMs(opts.sigtermDrainTimeoutMs);
72
88
 
73
89
  var _log = opts.log || function (event) {
74
90
  try {
@@ -82,6 +98,7 @@ function createDrain(opts) {
82
98
  var _underPressure = false;
83
99
  var _drainReason = null;
84
100
  var _drainTimeout = null;
101
+ var _drainDeadline = 0;
85
102
  var _drainPollHandle = null;
86
103
  var _signalsRegistered = false;
87
104
  var _exitCalled = false;
@@ -124,6 +141,16 @@ function createDrain(opts) {
124
141
  }
125
142
  }
126
143
 
144
+ function _armTimeout(ms) {
145
+ if (_drainTimeout) clearTimeout(_drainTimeout);
146
+ _drainDeadline = Date.now() + ms;
147
+ _drainTimeout = setTimeout(_forceExit, ms);
148
+ // Unref so the timeout alone does not prevent other exit paths.
149
+ if (_drainTimeout && typeof _drainTimeout.unref === 'function') {
150
+ _drainTimeout.unref();
151
+ }
152
+ }
153
+
127
154
  function _forceExit() {
128
155
  _callExit('timeout_forced');
129
156
  }
@@ -136,9 +163,18 @@ function createDrain(opts) {
136
163
  *
137
164
  * @param {string} reason — 'signal_usr1' | 'signal_usr2'
138
165
  * @param {object} [detail] — optional extra fields for the log event
166
+ * @param {number} [timeoutMs] — bound for this entry; defaults to drainTimeoutMs
139
167
  */
140
- function enterDrain(reason, detail) {
141
- if (_isDraining) return; // already draining — idempotent
168
+ function enterDrain(reason, detail, timeoutMs) {
169
+ var bound = timeoutMs > 0 ? timeoutMs : drainTimeoutMs;
170
+ if (_isDraining) {
171
+ // A shorter bound from a later entry (SIGTERM during an operator drain)
172
+ // wins, so the stop timeout is never outlived; otherwise a no-op.
173
+ if (!_exitCalled && _drainTimeout && Date.now() + bound < _drainDeadline) {
174
+ _armTimeout(bound);
175
+ }
176
+ return;
177
+ }
142
178
  _isDraining = true;
143
179
  _drainReason = reason;
144
180
 
@@ -147,7 +183,7 @@ function createDrain(opts) {
147
183
  event: 'drain_enter',
148
184
  reason: reason,
149
185
  activeCount: activeCount,
150
- drainTimeoutMs: drainTimeoutMs,
186
+ drainTimeoutMs: bound,
151
187
  timestamp: new Date().toISOString(),
152
188
  }, detail || {});
153
189
  _emitLog(logEvent);
@@ -159,11 +195,7 @@ function createDrain(opts) {
159
195
  }
160
196
 
161
197
  // Arm the timeout guard so a stuck session cannot hold the daemon up forever.
162
- _drainTimeout = setTimeout(_forceExit, drainTimeoutMs);
163
- // Unref so the timeout alone does not prevent other exit paths.
164
- if (_drainTimeout && typeof _drainTimeout.unref === 'function') {
165
- _drainTimeout.unref();
166
- }
198
+ _armTimeout(bound);
167
199
 
168
200
  // Poll the live-query count every second so we exit as soon as sessions finish.
169
201
  _drainPollHandle = setInterval(_checkActiveCount, DRAIN_POLL_INTERVAL_MS);
@@ -172,6 +204,16 @@ function createDrain(opts) {
172
204
  }
173
205
  }
174
206
 
207
+ /**
208
+ * Enter drain for SIGTERM/SIGINT with the short stop-timeout-safe bound.
209
+ * Idempotent; a second signal never extends the bound.
210
+ *
211
+ * @param {string} reason — 'signal_term' | 'signal_int'
212
+ */
213
+ function enterTermDrain(reason) {
214
+ enterDrain(reason, undefined, sigtermTimeoutMs);
215
+ }
216
+
175
217
  /**
176
218
  * Returns true when the daemon is in drain state.
177
219
  *
@@ -258,6 +300,7 @@ function createDrain(opts) {
258
300
  isUnderPressure: isUnderPressure,
259
301
  isRefusingNewWork: isRefusingNewWork,
260
302
  enterDrain: enterDrain,
303
+ enterTermDrain: enterTermDrain,
261
304
  registerSignals: registerSignals,
262
305
  onMemoryHighCrossing: onMemoryHighCrossing,
263
306
  onMemoryHighRecovery: onMemoryHighRecovery,
@@ -267,4 +310,9 @@ function createDrain(opts) {
267
310
  };
268
311
  }
269
312
 
270
- module.exports = { createDrain: createDrain, DEFAULT_DRAIN_TIMEOUT_MS: DEFAULT_DRAIN_TIMEOUT_MS };
313
+ module.exports = {
314
+ createDrain: createDrain,
315
+ DEFAULT_DRAIN_TIMEOUT_MS: DEFAULT_DRAIN_TIMEOUT_MS,
316
+ DEFAULT_SIGTERM_DRAIN_TIMEOUT_MS: DEFAULT_SIGTERM_DRAIN_TIMEOUT_MS,
317
+ MAX_SIGTERM_DRAIN_TIMEOUT_MS: MAX_SIGTERM_DRAIN_TIMEOUT_MS,
318
+ };
@@ -7,8 +7,8 @@
7
7
  // - deciding whether a call's arguments are valid uses ajv on the tool's
8
8
  // original JSON schema, applied to the arguments exactly as received.
9
9
  // zod's converter is documented as semi-experimental and widens some schemas
10
- // (a `required` list next to no `properties`, an enum next to a `type`,
11
- // `uniqueItems`), so it never decides validity. A tool whose schema either
10
+ // (a `required` list next to no `properties`, an enum next to a `type`), so it
11
+ // never decides validity. A tool whose schema either
12
12
  // library cannot read is left out and reported by the caller; nothing is
13
13
  // registered with a looser schema than the one the tool declared.
14
14
 
@@ -26,7 +26,52 @@
26
26
  * That constraint is what lets it stay close to the browser copy.
27
27
  */
28
28
 
29
- var CLAUDE_MODEL_FAMILIES = ["opus", "sonnet", "haiku", "fable"];
29
+ // The Claude families, derived from the vendor's own alias entries (the
30
+ // supportedModels() values that carry no "claude-" prefix, other than
31
+ // "default"): setClaudeModelFamilies below fills this in place whenever the
32
+ // vendor reports a list. The literal is the documented last-resort fallback,
33
+ // used only until a vendor list has been reported or when the vendor call
34
+ // failed; a derived set replaces it and is never merged with it. Keep it in
35
+ // step with lib/public/modules/model-families.js (the parity test checks it).
36
+ var CLAUDE_MODEL_FAMILIES_FALLBACK = ["opus", "sonnet", "haiku", "fable"];
37
+ var CLAUDE_MODEL_FAMILIES = CLAUDE_MODEL_FAMILIES_FALLBACK.slice();
38
+
39
+ /**
40
+ * The family names a vendor model list's alias entries spell, in list order
41
+ * (e.g. values "opus", "sonnet" -> ["opus", "sonnet"]); [] when it has none.
42
+ * @param {Array<string|{value: string}>} models
43
+ */
44
+ function deriveClaudeFamilies(models) {
45
+ var out = [];
46
+ (Array.isArray(models) ? models : []).forEach(function(m) {
47
+ var value = (m && typeof m === "object") ? m.value : m;
48
+ if (typeof value !== "string") return;
49
+ var alias = value.toLowerCase();
50
+ if (!/^[a-z]+$/.test(alias) || alias === "default" || out.indexOf(alias) !== -1) return;
51
+ out.push(alias);
52
+ });
53
+ return out;
54
+ }
55
+
56
+ /**
57
+ * Use the families derived from a vendor model list. A list with no alias
58
+ * entry changes nothing, so the fallback stays in force. Mutates
59
+ * CLAUDE_MODEL_FAMILIES in place so every holder of the array sees it.
60
+ * @returns {boolean} true when the families came from the list
61
+ */
62
+ function setClaudeModelFamilies(models) {
63
+ var derived = deriveClaudeFamilies(models);
64
+ if (derived.length === 0) return false;
65
+ CLAUDE_MODEL_FAMILIES.length = 0;
66
+ derived.forEach(function(f) { CLAUDE_MODEL_FAMILIES.push(f); });
67
+ return true;
68
+ }
69
+
70
+ // Back to the fallback literal (a vendor list that cannot be trusted any more).
71
+ function resetClaudeModelFamilies() {
72
+ CLAUDE_MODEL_FAMILIES.length = 0;
73
+ CLAUDE_MODEL_FAMILIES_FALLBACK.forEach(function(f) { CLAUDE_MODEL_FAMILIES.push(f); });
74
+ }
30
75
 
31
76
  /**
32
77
  * True if the given model ID string belongs to the given family (substring
@@ -231,6 +276,9 @@ function claudeModelSupportsEffort(modelId) {
231
276
 
232
277
  module.exports = {
233
278
  CLAUDE_MODEL_FAMILIES: CLAUDE_MODEL_FAMILIES,
279
+ deriveClaudeFamilies: deriveClaudeFamilies,
280
+ setClaudeModelFamilies: setClaudeModelFamilies,
281
+ resetClaudeModelFamilies: resetClaudeModelFamilies,
234
282
  isSonnetModel: isSonnetModel,
235
283
  isOpusModel: isOpusModel,
236
284
  isHaikuModel: isHaikuModel,
@@ -39,6 +39,9 @@ function createTypeRegistry() {
39
39
  * otherwise; the emitter cannot widen it.
40
40
  * @param {boolean} [def.ephemeral] its banner does not outlive a daemon
41
41
  * restart: what it announces is rebuilt from live state (default false).
42
+ * @param {boolean} [def.survivesClearAll] a clear-all of the notifications
43
+ * leaves it standing: it asks the operator for a decision, so only its own
44
+ * close (or its resolve) ends it (default false).
42
45
  * @param {function(object): {title: string, body: string}} [def.format]
43
46
  */
44
47
  function register(name, def) {
@@ -62,6 +65,7 @@ function createTypeRegistry() {
62
65
  pushUnlessOnline: def.pushUnlessOnline === true,
63
66
  audience: def.audience || "target",
64
67
  ephemeral: def.ephemeral === true,
68
+ survivesClearAll: def.survivesClearAll === true,
65
69
  format: typeof def.format === "function" ? def.format : defaultFormat,
66
70
  });
67
71
  return types[name];
@@ -6,8 +6,8 @@
6
6
  var PROMPT_TYPES = {
7
7
  permission_request: { category: "approval", collapse: "request", persistent: true, banner: true, liveInState: true },
8
8
  permission_reminder: { category: "approval_reminder", collapse: "session", persistent: true, renotify: true, banner: true, liveInState: true },
9
- ask_user: { category: "approval", collapse: "request", persistent: true, liveInState: true },
10
- elicitation: { category: "approval", collapse: "request", persistent: true, liveInState: true },
9
+ ask_user: { category: "approval", collapse: "request", persistent: true, banner: true, liveInState: true },
10
+ elicitation: { category: "approval", collapse: "request", persistent: true, banner: true, liveInState: true },
11
11
  };
12
12
 
13
13
  // What happened in a session, a loop or a conversation. Nothing waits on the
@@ -34,8 +34,11 @@ var SYSTEM_TYPES = {
34
34
  auth_required: { category: "system", collapse: "session", persistent: true, renotify: true, banner: true, closeOnResolve: false, audience: "target" },
35
35
  // The installed build is newer than the running one. Target: the console
36
36
  // itself (slug and session null). Only an admin can restart, so only admins
37
- // are told. Closed when the build is adopted or the offer is declined.
38
- build_update_offer: { category: "system", collapse: "session", persistent: true, banner: true, closeOnResolve: false, audience: "admins", ephemeral: true },
37
+ // are told. Closed when the build is adopted or the offer is declined from
38
+ // its pop-up; a clear-all of the notifications leaves it standing. The page
39
+ // draws no stack banner for it: the notification carries the offer to the
40
+ // diagnostics pop-up, which is its one in-console alert.
41
+ build_update_offer: { category: "system", collapse: "session", persistent: true, banner: true, closeOnResolve: false, audience: "admins", ephemeral: true, survivesClearAll: true },
39
42
  // A newer release exists. Target: the console itself; admins only. Ephemeral:
40
43
  // after the update the banner would announce the version already running.
41
44
  update_available: { category: "system", collapse: "session", banner: true, closeOnResolve: false, audience: "admins", ephemeral: true },
package/lib/pages.js CHANGED
@@ -1,3 +1,5 @@
1
+ var themeSeed = require("./theme-seed");
2
+
1
3
  function setupPageHtml(httpsUrl, httpUrl, hasCert, lanMode) {
2
4
  return `<!DOCTYPE html><html lang="en"><head>
3
5
  <meta charset="UTF-8">
@@ -7,8 +9,8 @@ function setupPageHtml(httpsUrl, httpUrl, hasCert, lanMode) {
7
9
  <link rel="apple-touch-icon" href="/apple-touch-icon.png">
8
10
  <title>Setup - Clagentic: Console</title>
9
11
  <style>
10
- :root{--s-bg:#060810;--s-text:#C8D4E0;--s-accent:#00CFFF;--s-muted:#7A8FA6;--s-border:#1E2E48;--s-dimmer:#3D5068;--s-success:#29D9A8;--s-accent-15:rgba(0,207,255,0.15);--s-success-10:rgba(41,217,168,0.1);--s-success-15:rgba(41,217,168,0.15);--s-accent-06:rgba(0,207,255,0.06);--s-muted-06:rgba(122,143,166,0.06);--s-muted-15:rgba(122,143,166,0.15)}
11
- @media(prefers-color-scheme:light){:root{--s-bg:#F4F7FB;--s-text:#1E2A38;--s-accent:#0099CC;--s-muted:#4A5D72;--s-border:#B4C6D9;--s-dimmer:#8FA4BA;--s-success:#1BA87E;--s-accent-15:rgba(0,153,204,0.15);--s-success-10:rgba(27,168,126,0.1);--s-success-15:rgba(27,168,126,0.15);--s-accent-06:rgba(0,153,204,0.06);--s-muted-06:rgba(74,93,114,0.06);--s-muted-15:rgba(74,93,114,0.15)}}
12
+ ${themeSeed.systemVarsCss()}
13
+ :root{--s-bg:var(--bg);--s-text:var(--text-secondary);--s-accent:var(--accent);--s-muted:var(--text-muted);--s-border:var(--border);--s-dimmer:var(--text-dimmer);--s-success:var(--success);--s-accent-15:var(--accent-15);--s-success-10:var(--success-12);--s-success-15:var(--success-15);--s-accent-06:var(--accent-8);--s-muted-06:color-mix(in srgb,var(--text-muted) 6%,transparent);--s-muted-15:color-mix(in srgb,var(--text-muted) 15%,transparent)}
12
14
  *{margin:0;padding:0;box-sizing:border-box}
13
15
  body{background:var(--s-bg);color:var(--s-text);font-family:system-ui,-apple-system,sans-serif;min-height:100dvh;display:flex;justify-content:center;padding:env(safe-area-inset-top,0) 20px 40px}
14
16
  .c{max-width:480px;width:100%;padding-top:40px}
@@ -35,7 +37,7 @@ h1{color:var(--s-accent);font-size:22px;margin:0 0 4px;text-align:center}
35
37
  .inst-text{font-size:14px;line-height:1.6}
36
38
  .inst-text .note{font-size:12px;color:var(--s-dimmer);margin-top:4px}
37
39
 
38
- .btn{display:inline-flex;align-items:center;justify-content:center;gap:8px;background:var(--s-accent);color:#fff;text-decoration:none;padding:12px 24px;border-radius:12px;font-weight:600;font-size:14px;margin:4px 0;border:none;cursor:pointer;font-family:inherit;transition:opacity 0.15s}
40
+ .btn{display:inline-flex;align-items:center;justify-content:center;gap:8px;background:var(--s-accent);color:var(--on-accent);text-decoration:none;padding:12px 24px;border-radius:12px;font-weight:600;font-size:14px;margin:4px 0;border:none;cursor:pointer;font-family:inherit;transition:opacity 0.15s}
39
41
  .btn:hover{opacity:0.9}
40
42
  .btn.outline{background:transparent;border:1.5px solid var(--s-border);color:var(--s-text)}
41
43
  .btn.outline:hover{border-color:var(--s-dimmer)}
@@ -554,64 +556,12 @@ if (!isHttps && !isLocal) {
554
556
  }
555
557
 
556
558
 
557
- // --- Build auth page CSS variables from ayu-light theme (same logic as theme.js computeVars) ---
558
- var path = require("path");
559
- var _authTheme = require(path.join(__dirname, "themes", "ayu-light.json"));
560
-
561
- function _hexToRgb(hex) {
562
- hex = hex.replace("#", "");
563
- return {
564
- r: parseInt(hex.substring(0, 2), 16),
565
- g: parseInt(hex.substring(2, 4), 16),
566
- b: parseInt(hex.substring(4, 6), 16)
567
- };
568
- }
569
-
570
- function _hexToRgba(hex, alpha) {
571
- var c = _hexToRgb(hex);
572
- return "rgba(" + c.r + "," + c.g + "," + c.b + "," + alpha + ")";
573
- }
574
-
575
- function _mixColors(hex1, hex2, weight) {
576
- var c1 = _hexToRgb(hex1), c2 = _hexToRgb(hex2);
577
- var w = weight;
578
- var r = Math.round(c1.r * w + c2.r * (1 - w));
579
- var g = Math.round(c1.g * w + c2.g * (1 - w));
580
- var b = Math.round(c1.b * w + c2.b * (1 - w));
581
- return "#" + ((1 << 24) + (r << 16) + (g << 8) + b).toString(16).slice(1);
582
- }
583
-
584
- var _t = {};
585
- var _keys = ["base00","base01","base02","base03","base04","base05","base06","base07",
586
- "base08","base09","base0A","base0B","base0C","base0D","base0E","base0F"];
587
- for (var _ki = 0; _ki < _keys.length; _ki++) {
588
- _t[_keys[_ki]] = "#" + _authTheme[_keys[_ki]];
589
- }
590
-
591
- var _authVarsObj = {
592
- "--bg": _t.base00,
593
- "--bg-alt": _t.base01,
594
- "--text": _t.base06,
595
- "--text-muted": _t.base04,
596
- "--text-dimmer": _t.base03,
597
- "--accent": _t.base09,
598
- "--accent-15": _hexToRgba(_t.base09, 0.15),
599
- "--accent-20": _hexToRgba(_t.base09, 0.20),
600
- "--border": _t.base02,
601
- "--input-bg": _mixColors(_t.base01, _t.base02, 0.5),
602
- "--error": _t.base08,
603
- };
604
-
605
- var _authVarsStr = ":root{";
606
- var _avKeys = Object.keys(_authVarsObj);
607
- for (var _vi = 0; _vi < _avKeys.length; _vi++) {
608
- _authVarsStr += _avKeys[_vi] + ":" + _authVarsObj[_avKeys[_vi]] + ";";
609
- }
610
- _authVarsStr += "}";
611
-
612
- // --- Shared CSS for auth pages (Clay Light theme via CSS variables) ---
559
+ // --- Shared CSS for auth pages (Dark and Light via CSS variables) ---
560
+ // The variables come from the bundled theme files through lib/theme-seed.js:
561
+ // Dark by default, Light when the system asks for it. These pages are served
562
+ // before sign-in, so there is no stored choice to read.
613
563
  var authPageStyles =
614
- _authVarsStr +
564
+ themeSeed.systemVarsCss() +
615
565
  // Reset & layout
616
566
  '*{margin:0;padding:0;box-sizing:border-box}' +
617
567
  'body{background:var(--bg);color:var(--text);font-family:system-ui,-apple-system,sans-serif;' +
@@ -621,13 +571,13 @@ var authPageStyles =
621
571
  '.sub{color:var(--text-muted);font-size:14px;margin-bottom:28px}' +
622
572
  '.field{margin-bottom:16px;text-align:left}' +
623
573
  '.field label{display:block;font-size:12px;color:var(--text-muted);margin-bottom:6px;text-transform:uppercase;letter-spacing:0.5px}' +
624
- 'input{width:100%;background:var(--input-bg);border:1px solid var(--border);border-radius:12px;' +
574
+ 'input{width:100%;background:var(--input-bg);border:1px solid var(--border-strong);border-radius:12px;' +
625
575
  'color:var(--text);font-size:16px;padding:12px 14px;outline:none;font-family:inherit}' +
626
576
  'input:focus{border-color:var(--accent);box-shadow:0 0 0 2px var(--accent-15)}' +
627
577
  'input::placeholder{font-size:14px;color:var(--text-dimmer)}' +
628
578
  // PIN digit boxes
629
579
  '.pin-wrap{display:flex;gap:8px;justify-content:center}' +
630
- '.pin-digit{width:44px;height:56px;background:var(--input-bg);border:1.5px solid var(--border);border-radius:8px;' +
580
+ '.pin-digit{width:44px;height:56px;background:var(--input-bg);border:1.5px solid var(--border-strong);border-radius:8px;' +
631
581
  'color:var(--text);font-family:"Courier New",Courier,"Roboto Mono",monospace;font-size:28px;font-weight:700;' +
632
582
  'text-align:center;line-height:56px;outline:none;caret-color:transparent;' +
633
583
  'transition:border-color 0.15s,box-shadow 0.15s}' +
@@ -636,7 +586,7 @@ var authPageStyles =
636
586
  // Legacy single-input fallback
637
587
  '.pin-input{font-size:24px;letter-spacing:12px;text-align:center;-webkit-text-security:disc;' +
638
588
  'font-family:"Courier New",Courier,"Roboto Mono",monospace}' +
639
- '.btn{width:100%;background:var(--accent);color:#fff;border:none;border-radius:12px;' +
589
+ '.btn{width:100%;background:var(--accent);color:var(--on-accent);border:none;border-radius:12px;' +
640
590
  'padding:14px;font-size:15px;font-weight:600;cursor:pointer;font-family:inherit;' +
641
591
  'transition:opacity 0.15s;margin-top:8px}' +
642
592
  '.btn:hover{opacity:0.9}' +
@@ -5,21 +5,25 @@
5
5
  // pending prompt. One source, so no surface shows more of a call than the
6
6
  // banner does.
7
7
 
8
+ var codecs = require("./prompt-kinds/codecs");
9
+
8
10
  // Summary bound, in characters, ellipsis included.
9
11
  var SUMMARY_MAX = 120;
10
12
 
11
- // C0 and C1 controls (ESC, CR, LF, NUL, ...) and the Unicode line and
12
- // paragraph separators. A summary is printed by a tool that may reach a
13
- // terminal, so none of these may pass.
14
- function isControl(code) {
15
- return code <= 0x1f || (code >= 0x7f && code <= 0x9f) || code === 0x2028 || code === 0x2029;
13
+ // The command with its leading environment assignments shortened to their
14
+ // names, so a bounded summary shows the command they prefix. A non-string
15
+ // command is passed through for summarize() to refuse.
16
+ function headOf(command) {
17
+ if (typeof command !== "string") return command;
18
+ var shared = codecs.commandSummary();
19
+ return shared.oneLine(shared.commandHead(command));
16
20
  }
17
21
 
18
22
  function pushBody(toolName, input) {
19
23
  if (!input) return "";
20
24
  var text = "";
21
25
  if (toolName === "Bash" && input.command) {
22
- text = input.command;
26
+ text = headOf(input.command);
23
27
  } else if (toolName === "Edit" && input.file_path) {
24
28
  text = input.file_path.split(/[/\\]/).pop() + ": " + (input.old_string || "").substring(0, 40) + " " + String.fromCharCode(0x2192) + " " + (input.new_string || "").substring(0, 40);
25
29
  } else if (toolName === "Write" && input.file_path) {
@@ -27,7 +31,7 @@ function pushBody(toolName, input) {
27
31
  } else if (input.file_path) {
28
32
  text = input.file_path;
29
33
  } else if (input.command) {
30
- text = input.command;
34
+ text = headOf(input.command);
31
35
  } else if (input.url) {
32
36
  text = input.url;
33
37
  } else if (input.query) {
@@ -41,14 +45,6 @@ function pushBody(toolName, input) {
41
45
  return text;
42
46
  }
43
47
 
44
- function oneLine(text) {
45
- var out = "";
46
- for (var i = 0; i < text.length; i++) {
47
- out += isControl(text.charCodeAt(i)) ? " " : text.charAt(i);
48
- }
49
- return out.replace(/ {2,}/g, " ").trim();
50
- }
51
-
52
48
  // A single printable line of at most SUMMARY_MAX characters. A non-string
53
49
  // field of a hostile input is not a summary.
54
50
  function summarize(toolName, input) {
@@ -59,7 +55,7 @@ function summarize(toolName, input) {
59
55
  return "";
60
56
  }
61
57
  if (typeof body !== "string") return "";
62
- var line = oneLine(body);
58
+ var line = codecs.commandSummary().oneLine(body);
63
59
  if (line.length > SUMMARY_MAX) line = line.slice(0, SUMMARY_MAX - 3) + "...";
64
60
  return line;
65
61
  }
@@ -0,0 +1,70 @@
1
+ // plan-usage-reader.js — turn-end read of plan usage into the usage store.
2
+ //
3
+ // The Claude CLI reports rate limits only above its warning threshold, so a
4
+ // low utilization is invisible to rate_limit_event. A live query handle that
5
+ // can read plan usage (handle.readPlanUsage, a Claude adapter capability that
6
+ // resolves readings or null) is asked at turn end, at most once per interval
7
+ // per process, and each reading is recorded like a rate-limit event. A handle
8
+ // without the method, a null or malformed reading, or a failure records
9
+ // nothing and surfaces nothing: the rate_limit_event path is the fallback and
10
+ // is untouched.
11
+
12
+ var usageStore = require("./usage-store");
13
+
14
+ var DEFAULT_INTERVAL_MS = 5 * 60 * 1000;
15
+ var SOURCE = "claude-sdk:get_usage";
16
+
17
+ // opts (all optional):
18
+ // store { record }, defaults to the shared usage store (looked up at call
19
+ // time, because enabling persistence swaps its functions)
20
+ // intervalMs minimum spacing between reads
21
+ // now function() -> ms, for tests
22
+ function createPlanUsageReader(opts) {
23
+ opts = opts || {};
24
+ var store = opts.store || usageStore;
25
+ var intervalMs = opts.intervalMs !== undefined ? opts.intervalMs : DEFAULT_INTERVAL_MS;
26
+ var clock = opts.now || Date.now;
27
+ // The spacing starts when a read is issued, so a failing read is not retried
28
+ // by every turn that ends inside the interval.
29
+ var lastIssuedAt = null;
30
+
31
+ // Resolves true when a read was issued, whatever it returned. Never rejects.
32
+ function maybeRead(handle, vendor) {
33
+ if (!handle || typeof handle.readPlanUsage !== "function" || !vendor) return Promise.resolve(false);
34
+ var now = clock();
35
+ if (lastIssuedAt !== null && now - lastIssuedAt < intervalMs) return Promise.resolve(false);
36
+ lastIssuedAt = now;
37
+ var pending;
38
+ try {
39
+ pending = Promise.resolve(handle.readPlanUsage());
40
+ } catch (e) {
41
+ return Promise.resolve(true);
42
+ }
43
+ return pending.then(function (readings) {
44
+ if (!Array.isArray(readings)) return true;
45
+ // Stamped when the reply lands, not when the read was issued: a
46
+ // rate_limit_event recorded while the read was pending must not be
47
+ // overwritten by a reading that carries an older observation time.
48
+ var observedAt = clock();
49
+ readings.forEach(function (info) {
50
+ try {
51
+ store.record(vendor, info, { source: SOURCE, now: observedAt, keepStatus: true });
52
+ } catch (e) {
53
+ // A reading that cannot be recorded is dropped, like a malformed one.
54
+ console.warn("[plan-usage-reader] dropped a reading: " + (e && e.message));
55
+ }
56
+ });
57
+ return true;
58
+ }, function () {
59
+ return true;
60
+ });
61
+ }
62
+
63
+ return { maybeRead: maybeRead };
64
+ }
65
+
66
+ module.exports = {
67
+ createPlanUsageReader: createPlanUsageReader,
68
+ DEFAULT_INTERVAL_MS: DEFAULT_INTERVAL_MS,
69
+ SOURCE: SOURCE,
70
+ };
@@ -184,6 +184,9 @@ function attachConnection(ctx) {
184
184
  if (typeof opts.onGetUserShellSettings === "function") {
185
185
  sendTo(ws, userShellSettings.settingsMessage(opts.onGetUserShellSettings()));
186
186
  }
187
+ if (typeof opts.onGetPromptExpirySettings === "function") {
188
+ sendTo(ws, opts.onGetPromptExpirySettings());
189
+ }
187
190
  // Every client holds the roster's avatar choices from the start: a transcript
188
191
  // draws agents before the Team view is ever opened.
189
192
  // The roster is filtered to what this connection may read, as on request.
@@ -226,7 +229,6 @@ function attachConnection(ctx) {
226
229
  }
227
230
  if (active && !autoCreated) {
228
231
  ws._clagenticActiveSession = active.localId;
229
- var _vendorCaps = (sm.capabilitiesByVendor && sm.capabilitiesByVendor[active.vendor || sm.defaultVendor || "claude"]) || {};
230
232
  // Load history from disk before checking hasHistory — the session may have
231
233
  // been evicted from the LRU cache (lr-f311 lazy load), in which case
232
234
  // active.history is [] in memory even though the session file has content.
@@ -276,7 +278,7 @@ function attachConnection(ctx) {
276
278
  // server truth across a reconnect. Carrying it directly on
277
279
  // session_switched matches switchSession() and gives the client a
278
280
  // single authoritative snapshot value to reconcile the footer against.
279
- sendTo(ws, { type: "session_switched", id: active.localId, cliSessionId: active.cliSessionId || null, loop: active.loop || null, vendor: active.vendor || null, model: sm.effectiveSessionModel(active), mode: effectiveSessionMode(active, sm), hasHistory: _hasHistory, capabilities: _vendorCaps, isProcessing: !!active.isProcessing, agentName: active.agentName || null });
281
+ sendTo(ws, sm.buildSessionSwitchedMessage(active, _hasHistory));
280
282
  // Send per-session context sources
281
283
  var sessionSources = loadContextSources(slug, active.localId);
282
284
  sendTo(ws, { type: "context_sources_state", active: sessionSources });
@@ -6,6 +6,7 @@ var claudeSettingsEnv = require("./claude-settings-env");
6
6
  var idleCompaction = require("./idle-compaction-setting");
7
7
  var runtimeEnv = require("./runtime-env");
8
8
  var { REAL_HOME } = require("./config");
9
+ var { createProjectSettingsGate } = require("./project-settings-gate");
9
10
 
10
11
  // Settings that act on the whole machine (not on this project), so the
11
12
  // per-user projectSettings permission is not enough: administrators only.
@@ -59,6 +60,9 @@ function attachFilesystem(ctx) {
59
60
  var IGNORED_DIRS = ctx.IGNORED_DIRS;
60
61
  var IMAGE_EXTS = ctx.IMAGE_EXTS;
61
62
  var fileAccess = ctx.fileAccess;
63
+ var settingsGate = createProjectSettingsGate({
64
+ projectAccess: projectAccess, usersModule: usersModule, osUsers: osUsers, sendTo: sendTo,
65
+ });
62
66
 
63
67
  // Names a Settings text sets that the daemon user's Claude settings file
64
68
  // sets too; the file wins at the runtime, so the editor says so. The one file
@@ -102,6 +106,7 @@ function attachFilesystem(ctx) {
102
106
  // --- Settings that act beyond this project: administrators only ---
103
107
  if (typeof msg.type === "string" && ADMIN_ONLY_TYPES[msg.type] === true) {
104
108
  if (!projectAccess.isAdmin(ws._clagenticUser, projectAccess.authOf(ws))) {
109
+ console.warn("[project-filesystem] refused " + msg.type + " in " + slug + ": caller is not an admin");
105
110
  sendTo(ws, { type: "error", text: "Admin access required" });
106
111
  return true;
107
112
  }
@@ -233,13 +238,7 @@ function attachFilesystem(ctx) {
233
238
  // --- Project settings permission gate ---
234
239
  if (msg.type === "get_project_env" || msg.type === "set_project_env" ||
235
240
  msg.type === "transfer_project_owner") {
236
- if (ws._clagenticUser) {
237
- var psPerms = usersModule.getEffectivePermissions(ws._clagenticUser, osUsers);
238
- if (!psPerms.projectSettings) {
239
- sendTo(ws, { type: "error", text: "Project settings access is not permitted" });
240
- return true;
241
- }
242
- }
241
+ if (settingsGate.refuse(ws, msg.type, slug)) return true;
243
242
  }
244
243
 
245
244
  // --- Project environment variables ---