@clagentic/console 1.12.0-beta.1 → 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 (161) hide show
  1. package/LICENSES/README.md +5 -0
  2. package/README.md +1 -0
  3. package/bin/cli.js +5 -2
  4. package/lib/agent-roster-ws.js +84 -0
  5. package/lib/agent-roster.js +312 -0
  6. package/lib/auth-required-notify.js +42 -0
  7. package/lib/build-changes.js +8 -2
  8. package/lib/build-sha.json +2 -2
  9. package/lib/build-update-notify.js +45 -0
  10. package/lib/build-update-offer.js +34 -11
  11. package/lib/build-update-standing.js +34 -14
  12. package/lib/claude-settings-env.js +142 -0
  13. package/lib/cli/duration.js +27 -0
  14. package/lib/cli/schedule-input-subcommands.js +1 -22
  15. package/lib/cli/session-subcommands.js +60 -11
  16. package/lib/client-address.js +44 -0
  17. package/lib/daemon.js +31 -10
  18. package/lib/idle-compaction-setting.js +203 -0
  19. package/lib/mcp-bridge-credential.js +41 -0
  20. package/lib/notification-prefs.js +18 -22
  21. package/lib/notify/core.js +210 -0
  22. package/lib/notify/index.js +31 -0
  23. package/lib/notify/live-prompts.js +36 -0
  24. package/lib/notify/payload.js +62 -0
  25. package/lib/notify/target.js +5 -0
  26. package/lib/notify/type-registry.js +81 -0
  27. package/lib/notify/types.js +57 -0
  28. package/lib/open-sockets.js +27 -0
  29. package/lib/outbound-access.js +85 -0
  30. package/lib/outbound-entry.js +116 -0
  31. package/lib/outbound-ledger.js +306 -0
  32. package/lib/outbound-query.js +153 -0
  33. package/lib/pending-prompts.js +31 -16
  34. package/lib/project-connection.js +48 -8
  35. package/lib/project-filesystem.js +43 -5
  36. package/lib/project-http.js +9 -1
  37. package/lib/project-loop.js +38 -26
  38. package/lib/project-notifications.js +122 -39
  39. package/lib/project-prompt-responses.js +1 -1
  40. package/lib/project-sessions.js +11 -1
  41. package/lib/project-user-mention.js +22 -34
  42. package/lib/project-user-message.js +208 -4
  43. package/lib/project-user-shell.js +298 -0
  44. package/lib/project.js +41 -5
  45. package/lib/prompt-answer.js +145 -0
  46. package/lib/prompt-expiry.js +50 -0
  47. package/lib/prompt-registry.js +98 -25
  48. package/lib/prompt-reminders.js +38 -33
  49. package/lib/prompt-source.js +59 -8
  50. package/lib/public/app.js +32 -2
  51. package/lib/public/css/agent-messages.css +96 -0
  52. package/lib/public/css/agent-roster.css +93 -0
  53. package/lib/public/css/diagnostics.css +29 -1
  54. package/lib/public/css/home-hub.css +12 -0
  55. package/lib/public/css/icon-strip.css +9 -0
  56. package/lib/public/css/input.css +20 -141
  57. package/lib/public/css/login-panel.css +73 -0
  58. package/lib/public/css/menus.css +2 -2
  59. package/lib/public/css/mobile-nav.css +11 -0
  60. package/lib/public/css/sidebar.css +18 -0
  61. package/lib/public/css/team-panel.css +1 -6
  62. package/lib/public/css/team-view.css +101 -0
  63. package/lib/public/css/title-bar.css +10 -0
  64. package/lib/public/css/user-shell.css +144 -0
  65. package/lib/public/index.html +44 -7
  66. package/lib/public/modules/activity-state.js +20 -4
  67. package/lib/public/modules/agent-avatar-picker.js +162 -0
  68. package/lib/public/modules/agent-avatar.js +153 -0
  69. package/lib/public/modules/agent-messages.js +285 -0
  70. package/lib/public/modules/agent-roster.js +157 -0
  71. package/lib/public/modules/app-connection.js +34 -5
  72. package/lib/public/modules/app-messages.js +55 -16
  73. package/lib/public/modules/app-notifications.js +104 -75
  74. package/lib/public/modules/app-panels.js +26 -3
  75. package/lib/public/modules/app-projects.js +3 -1
  76. package/lib/public/modules/app-rate-limit.js +8 -165
  77. package/lib/public/modules/app-rendering.js +32 -7
  78. package/lib/public/modules/build-update-sessions.js +81 -0
  79. package/lib/public/modules/collapsible-text.js +33 -18
  80. package/lib/public/modules/compaction-state.js +34 -0
  81. package/lib/public/modules/custom-icons.js +23 -5
  82. package/lib/public/modules/diagnostics.js +61 -57
  83. package/lib/public/modules/env-shadow-notice.js +34 -0
  84. package/lib/public/modules/injected-identity.js +24 -21
  85. package/lib/public/modules/input.js +176 -15
  86. package/lib/public/modules/login-panel.js +136 -0
  87. package/lib/public/modules/login-parser.js +73 -0
  88. package/lib/public/modules/login-tab.js +66 -0
  89. package/lib/public/modules/notifications.js +9 -1
  90. package/lib/public/modules/notify-client.js +246 -0
  91. package/lib/public/modules/pending-term-request.js +30 -0
  92. package/lib/public/modules/project-icon.js +22 -2
  93. package/lib/public/modules/project-settings.js +5 -0
  94. package/lib/public/modules/prompt-state.js +3 -3
  95. package/lib/public/modules/prompts.js +1 -1
  96. package/lib/public/modules/queued-button.js +11 -0
  97. package/lib/public/modules/scheduled-input-actions.js +12 -4
  98. package/lib/public/modules/scheduled-outbox.js +230 -0
  99. package/lib/public/modules/send-now.js +200 -0
  100. package/lib/public/modules/server-settings.js +50 -1
  101. package/lib/public/modules/shell-card.js +76 -0
  102. package/lib/public/modules/shell-line.js +49 -0
  103. package/lib/public/modules/shell-queue.js +253 -0
  104. package/lib/public/modules/shell-settings-controls.js +76 -0
  105. package/lib/public/modules/sidebar-mobile.js +3 -3
  106. package/lib/public/modules/sidebar-sessions.js +8 -0
  107. package/lib/public/modules/sidebar-users.js +5 -7
  108. package/lib/public/modules/team-panel.js +30 -88
  109. package/lib/public/modules/team-view.js +211 -0
  110. package/lib/public/modules/terminal-links.js +193 -0
  111. package/lib/public/modules/terminal.js +84 -107
  112. package/lib/public/modules/tools.js +19 -0
  113. package/lib/public/modules/user-shell.js +824 -0
  114. package/lib/public/notify-sw-logic.js +252 -0
  115. package/lib/public/notify-target.js +157 -0
  116. package/lib/public/style.css +5 -0
  117. package/lib/public/sw.js +20 -69
  118. package/lib/push.js +63 -19
  119. package/lib/queued-chat.js +392 -0
  120. package/lib/runtime-env.js +1 -0
  121. package/lib/scheduled-input/ws.js +67 -9
  122. package/lib/sdk-bridge.js +184 -73
  123. package/lib/sdk-message-processor.js +124 -76
  124. package/lib/server-auth.js +6 -4
  125. package/lib/server-dm.js +11 -20
  126. package/lib/server-settings.js +39 -1
  127. package/lib/server.js +112 -16
  128. package/lib/session-directory.js +39 -12
  129. package/lib/session-end.js +97 -0
  130. package/lib/session-input-ipc.js +37 -1
  131. package/lib/session-input.js +263 -21
  132. package/lib/session-liveness.js +53 -0
  133. package/lib/session-reclaim.js +37 -2
  134. package/lib/session-resume.js +1 -0
  135. package/lib/session-settings-file.js +53 -0
  136. package/lib/sessions.js +80 -9
  137. package/lib/team-traffic-ws.js +68 -0
  138. package/lib/team-traffic.js +318 -0
  139. package/lib/usage-store.js +36 -7
  140. package/lib/user-shell-settings.js +105 -0
  141. package/lib/vendor-auth.js +33 -2
  142. package/lib/ws-schema.js +33 -5
  143. package/lib/yoke/adapters/claude-capabilities.js +2 -0
  144. package/lib/yoke/adapters/claude-vendor.js +17 -1
  145. package/lib/yoke/adapters/claude-worker.js +39 -11
  146. package/lib/yoke/adapters/claude.js +225 -6
  147. package/lib/yoke/adapters/codex-capabilities.js +6 -1
  148. package/lib/yoke/adapters/codex-user-shell.js +265 -0
  149. package/lib/yoke/adapters/codex-vendor.js +7 -0
  150. package/lib/yoke/adapters/codex.js +186 -52
  151. package/lib/yoke/auth-checks.js +17 -2
  152. package/lib/yoke/codex-app-server.js +8 -2
  153. package/lib/yoke/index.js +21 -3
  154. package/lib/yoke/interface.js +54 -1
  155. package/lib/yoke/mcp-bridge-server.js +12 -8
  156. package/lib/yoke/provider-credentials.js +24 -0
  157. package/lib/yoke/registry.js +40 -1
  158. package/lib/yoke/user-shell.js +224 -0
  159. package/package.json +2 -2
  160. package/scripts/check-test-count.js +14 -0
  161. package/lib/public/modules/build-notice-gate.js +0 -73
@@ -40,6 +40,26 @@ function isIsoOrNull(v) {
40
40
  function isStrOrNull(v) {
41
41
  return v === null || typeof v === "string";
42
42
  }
43
+ // Session ids arrive as numbers from the session layer and as strings from
44
+ // older files; both are stored as strings, which is also how confirm() and
45
+ // endProcess() key them. Anything else is not an id.
46
+ function idOrNull(v) {
47
+ if (typeof v === "string") return v;
48
+ if (typeof v === "number" && isFinite(v)) return String(v);
49
+ return null;
50
+ }
51
+ function strOrNull(v) {
52
+ return typeof v === "string" ? v : null;
53
+ }
54
+ function finiteOrNull(v) {
55
+ return typeof v === "number" && isFinite(v) ? v : null;
56
+ }
57
+ // Epoch seconds to ISO, or null when the value is not a representable time.
58
+ function epochSecondsToIsoOrNull(sec) {
59
+ if (typeof sec !== "number" || !isFinite(sec) || sec === 0) return null;
60
+ var ms = sec * 1000;
61
+ return isFinite(new Date(ms).getTime()) ? toIso(ms) : null;
62
+ }
43
63
 
44
64
  // Vendor and bucket names come from persisted JSON and CLI output, so they are
45
65
  // untrusted. Internal maps have no prototype (a name like "constructor" or
@@ -58,7 +78,9 @@ function validRecord(r) {
58
78
  if (typeof r.observedAt !== "string" || !isFinite(Date.parse(r.observedAt))) return null;
59
79
  if (!(r.utilization === null || (typeof r.utilization === "number" && isFinite(r.utilization)))) return null;
60
80
  if (!isIsoOrNull(r.utilizationObservedAt) || !isIsoOrNull(r.resetsAt)) return null;
61
- if (!isStrOrNull(r.status) || !isStrOrNull(r.source) || !isStrOrNull(r.sessionLocalId)) return null;
81
+ if (!isStrOrNull(r.status) || !isStrOrNull(r.source)) return null;
82
+ var sessionLocalId = r.sessionLocalId === undefined ? null : r.sessionLocalId;
83
+ if (sessionLocalId !== null && idOrNull(sessionLocalId) === null) return null;
62
84
  // confirmedAt is absent in files written before confirmation existed.
63
85
  var confirmedAt = r.confirmedAt === undefined ? null : r.confirmedAt;
64
86
  if (!isIsoOrNull(confirmedAt)) return null;
@@ -70,7 +92,7 @@ function validRecord(r) {
70
92
  observedAt: r.observedAt,
71
93
  confirmedAt: confirmedAt,
72
94
  source: r.source,
73
- sessionLocalId: r.sessionLocalId,
95
+ sessionLocalId: idOrNull(sessionLocalId),
74
96
  };
75
97
  }
76
98
 
@@ -173,6 +195,8 @@ function createUsageStore(opts) {
173
195
  }
174
196
  var loaded = newMap();
175
197
  var dropped = 0;
198
+ var kept = 0;
199
+ var newest = null;
176
200
  Object.keys(parsed.vendors).forEach(function (vendor) {
177
201
  var buckets = parsed.vendors[vendor];
178
202
  if (isUnsafeKey(vendor)) { dropped++; return; }
@@ -181,10 +205,15 @@ function createUsageStore(opts) {
181
205
  var rec = isUnsafeKey(b) ? null : validRecord(buckets[b]);
182
206
  if (!rec) { dropped++; return; }
183
207
  (loaded[vendor] || (loaded[vendor] = newMap()))[b] = rec;
208
+ kept++;
209
+ var t = typeof rec.observedAt === "string" ? Date.parse(rec.observedAt) : NaN;
210
+ if (isFinite(t) && (newest === null || t > newest)) newest = t;
184
211
  });
185
212
  });
186
213
  records = loaded;
187
214
  if (dropped > 0) log("[usage-store] Clagentic: Console dropped " + dropped + " malformed usage record(s) from " + file);
215
+ // The restart journal's proof that persisted usage survived the restart.
216
+ log("[usage-store] Clagentic: Console loaded " + kept + " usage record(s) from " + file + ", newest observedAt " + (newest === null ? "none" : new Date(newest).toISOString()));
188
217
  }
189
218
 
190
219
  // info.resetsAt is epoch seconds, as the adapters report it.
@@ -201,8 +230,8 @@ function createUsageStore(opts) {
201
230
  if (isUnsafeKey(vendor) || isUnsafeKey(info.rateLimitType)) return;
202
231
  meta = meta || {};
203
232
  var now = meta.now !== undefined ? meta.now : Date.now();
204
- var util = typeof info.utilization === "number" ? info.utilization : null;
205
- var resetsAt = info.resetsAt ? toIso(info.resetsAt * 1000) : null;
233
+ var util = finiteOrNull(info.utilization);
234
+ var resetsAt = epochSecondsToIsoOrNull(info.resetsAt);
206
235
  var byBucket = records[vendor] || (records[vendor] = newMap());
207
236
  var prev = byBucket[info.rateLimitType];
208
237
  var utilizationObservedAt = util !== null ? toIso(now) : null;
@@ -218,11 +247,11 @@ function createUsageStore(opts) {
218
247
  utilization: util,
219
248
  utilizationObservedAt: utilizationObservedAt,
220
249
  resetsAt: resetsAt,
221
- status: info.status || null,
250
+ status: strOrNull(info.status) || null,
222
251
  observedAt: toIso(now),
223
252
  confirmedAt: null,
224
- source: meta.source || null,
225
- sessionLocalId: meta.sessionLocalId || null,
253
+ source: strOrNull(meta.source) || null,
254
+ sessionLocalId: idOrNull(meta.sessionLocalId) || null,
226
255
  };
227
256
  seenThisRun[vendor] = true;
228
257
  if (meta.processKey && meta.sessionLocalId && !isUnsafeKey(String(meta.sessionLocalId))) {
@@ -0,0 +1,105 @@
1
+ "use strict";
2
+
3
+ // The settings of the composer's ! mode: whether it is on, how long a command
4
+ // may run, and how much of its output is kept. Stored in daemon.json beside the
5
+ // other server settings and read when a command is sent, so a change needs no
6
+ // restart. Each default is what runs until an administrator changes it.
7
+
8
+ var { ownValue } = require("./prompt-kinds/codecs");
9
+
10
+ var DEFAULT_TIMEOUT_MINUTES = 10;
11
+ var DEFAULT_MAX_OUTPUT_KIB = 256;
12
+
13
+ // A day is far past any command worth waiting on in a chat; 4 MiB is far past
14
+ // any output worth putting in a conversation.
15
+ var MAX_TIMEOUT_MINUTES = 24 * 60;
16
+ var MAX_OUTPUT_KIB = 4096;
17
+
18
+ function isCount(v, max) {
19
+ return typeof v === "number" && isFinite(v) && Math.floor(v) === v && v >= 1 && v <= max;
20
+ }
21
+
22
+ // The setting names a client may send, each with its type check. Anything else
23
+ // in a request is refused rather than stored. A name is also its daemon.json key.
24
+ var SETTING_TYPES = {
25
+ userShellEnabled: function (v) { return typeof v === "boolean"; },
26
+ userShellTimeoutMinutes: function (v) { return isCount(v, MAX_TIMEOUT_MINUTES); },
27
+ userShellMaxOutputKiB: function (v) { return isCount(v, MAX_OUTPUT_KIB); },
28
+ };
29
+
30
+ /**
31
+ * @param {?object} config - the daemon configuration (daemon.json contents).
32
+ * @returns {{enabled: boolean, timeoutMinutes: number, maxOutputKiB: number,
33
+ * timeoutMs: number, maxOutputBytes: number}}
34
+ */
35
+ function readUserShellSettings(config) {
36
+ var cfg = config || {};
37
+ var timeoutMinutes = isCount(cfg.userShellTimeoutMinutes, MAX_TIMEOUT_MINUTES)
38
+ ? cfg.userShellTimeoutMinutes : DEFAULT_TIMEOUT_MINUTES;
39
+ var maxOutputKiB = isCount(cfg.userShellMaxOutputKiB, MAX_OUTPUT_KIB)
40
+ ? cfg.userShellMaxOutputKiB : DEFAULT_MAX_OUTPUT_KIB;
41
+ return {
42
+ // Only an explicit false turns it off: an absent field is the default, on.
43
+ enabled: cfg.userShellEnabled !== false,
44
+ timeoutMinutes: timeoutMinutes,
45
+ maxOutputKiB: maxOutputKiB,
46
+ timeoutMs: timeoutMinutes * 60 * 1000,
47
+ maxOutputBytes: maxOutputKiB * 1024,
48
+ };
49
+ }
50
+
51
+ /**
52
+ * The fields of a change request that name a known setting with a value of the
53
+ * right type; nothing else passes. `rejected` lists the names that did not.
54
+ * @returns {{values: object, rejected: string[]}}
55
+ */
56
+ function pickSettingChanges(request) {
57
+ var values = {};
58
+ var rejected = [];
59
+ Object.keys(request || {}).forEach(function (name) {
60
+ if (name === "type") return;
61
+ var check = ownValue(SETTING_TYPES, name);
62
+ if (typeof check === "function" && check(request[name])) values[name] = request[name];
63
+ else rejected.push(name);
64
+ });
65
+ return { values: values, rejected: rejected };
66
+ }
67
+
68
+ /** The wire message that tells a client the current settings. */
69
+ function settingsMessage(settings) {
70
+ return {
71
+ type: "user_shell_settings",
72
+ userShellEnabled: settings.enabled,
73
+ userShellTimeoutMinutes: settings.timeoutMinutes,
74
+ userShellMaxOutputKiB: settings.maxOutputKiB,
75
+ };
76
+ }
77
+
78
+ /**
79
+ * Applies accepted changes to a daemon configuration object; a value equal to
80
+ * its default is removed so daemon.json keeps showing only what was changed.
81
+ */
82
+ function applySettingChanges(config, values) {
83
+ if (values.userShellEnabled !== undefined) {
84
+ if (values.userShellEnabled === false) config.userShellEnabled = false;
85
+ else delete config.userShellEnabled;
86
+ }
87
+ if (values.userShellTimeoutMinutes !== undefined) {
88
+ if (values.userShellTimeoutMinutes === DEFAULT_TIMEOUT_MINUTES) delete config.userShellTimeoutMinutes;
89
+ else config.userShellTimeoutMinutes = values.userShellTimeoutMinutes;
90
+ }
91
+ if (values.userShellMaxOutputKiB !== undefined) {
92
+ if (values.userShellMaxOutputKiB === DEFAULT_MAX_OUTPUT_KIB) delete config.userShellMaxOutputKiB;
93
+ else config.userShellMaxOutputKiB = values.userShellMaxOutputKiB;
94
+ }
95
+ return config;
96
+ }
97
+
98
+ module.exports = {
99
+ DEFAULT_TIMEOUT_MINUTES: DEFAULT_TIMEOUT_MINUTES,
100
+ DEFAULT_MAX_OUTPUT_KIB: DEFAULT_MAX_OUTPUT_KIB,
101
+ readUserShellSettings: readUserShellSettings,
102
+ pickSettingChanges: pickSettingChanges,
103
+ settingsMessage: settingsMessage,
104
+ applySettingChanges: applySettingChanges,
105
+ };
@@ -2,7 +2,9 @@
2
2
  // registry so the title and the login command are written once and every
3
3
  // surface (chat message, notification, terminal launcher) agrees.
4
4
 
5
- var registry = require("./yoke").registry;
5
+ var yoke = require("./yoke");
6
+ var registry = yoke.registry;
7
+ var providerCredentials = yoke.providerCredentials;
6
8
 
7
9
  /**
8
10
  * @param {string} vendor a registered vendor id
@@ -19,4 +21,33 @@ function authRequiredFacts(vendor) {
19
21
  };
20
22
  }
21
23
 
22
- module.exports = { authRequiredFacts: authRequiredFacts };
24
+ /**
25
+ * When the agent talks to a cloud provider (Bedrock, Vertex, Foundry) the
26
+ * session's environment selects, an auth-like error is that provider's
27
+ * credentials failing, not a missing sign-in: there is no login to offer.
28
+ * Only an agent that owns the provider's credential group is attributed to it.
29
+ *
30
+ * @param {string} vendor a registered vendor id
31
+ * @param {?object} env the composed environment the session runs with
32
+ * @param {boolean} [osUsers] os-users mode: no settings file is read
33
+ * @returns {?{provider: string, label: string, message: string}}
34
+ */
35
+ function providerAuthFailure(vendor, env, osUsers) {
36
+ if (!registry.isKnown(vendor)) return null;
37
+ var descriptor = registry.get(vendor);
38
+ var seen = typeof descriptor.effectiveRuntimeEnv === "function" ? descriptor.effectiveRuntimeEnv(env, osUsers) : env;
39
+ var provider = providerCredentials.configuredProvider(seen);
40
+ if (!provider) return null;
41
+ var groups = descriptor.credentialGroups || [];
42
+ var owns = groups.some(function (g) { return g.id === provider; });
43
+ if (!owns) return null;
44
+ var label = providerCredentials.PROVIDER_LABELS[provider];
45
+ return {
46
+ provider: provider,
47
+ label: label,
48
+ message: label + " is configured for " + registry.get(vendor).displayName + " on this host, and its credentials failed. " +
49
+ "Check them in Settings (environment) or on the host. Signing in is not the fix.",
50
+ };
51
+ }
52
+
53
+ module.exports = { authRequiredFacts: authRequiredFacts, providerAuthFailure: providerAuthFailure };
package/lib/ws-schema.js CHANGED
@@ -60,8 +60,18 @@ var schema = {
60
60
  // -----------------------------------------------------------------------
61
61
  // Chat / streaming
62
62
  // -----------------------------------------------------------------------
63
- "message": { direction: "c2s", handler: "lib/project-user-message.js", description: "Send a user chat message" },
63
+ "message": { direction: "c2s", handler: "lib/project-user-message.js", description: "Send a user chat message. sendNow:true delivers it into the running turn when the agent can steer; otherwise it is queued as usual. messageId (a uuid minted by the page) is the message uuid at the agent and names it on message_delivered and cancel_queued_message" },
64
+ "message_delivered": { direction: "s2c", handler: "lib/public/modules/app-messages.js", description: "The agent took a chat message into the turn: {messageId}. The page turns the queued item it drew for that id into the normal user message, once. Also sent at once for a message that was not held as queued (the turn had ended, or the agent cannot withdraw a queued message)" },
65
+ "cancel_queued_message": { direction: "c2s", handler: "lib/project-user-message.js", description: "Withdraw a chat message the page drew as queued: {messageId}. Answered with queued_message_cancelled" },
66
+ "queued_message_cancelled": { direction: "s2c", handler: "lib/public/modules/app-messages.js", description: "The outcome for a queued chat message: {messageId, result}. cancelled: the agent dropped it and it is never delivered; the reply carries {text, pastes, imageCount} so the page can hand the message back even when it no longer holds its queued item. already_delivered: the server no longer tracks the message, because the agent took it in (message_delivered follows, or came first), it was cancelled before, or the id is unknown; no message_delivered follows in the last two cases. Nothing is handed back, so nothing is lost or doubled. pending: the agent did not drop it from its queue and cannot say whether it runs (a coalesced batch member, a held-back message); it stays queued and ends as message_delivered, or as dropped with its text when the agent never takes it. unsupported: the agent cannot withdraw it. error: the agent did not answer (message says why). dropped: the agent will not run the message: its query was closed before it took it, or a cancel answered pending and no turn took it in (a turn ending with a message merely waiting is not a drop: the agent runs it as its next turn); carries {text, pastes, imageCount, cause} (cause: closed, the query closed; send_now_missed, Send now interrupted the turn and the agent's receipt did not list the message as kept; not_taken, the idle grace timer settled it after a cancel the agent answered false to, with no turn running and no frame having named it; restart, the daemon restarted while it waited) and the page hands the text back. A dropped reply with nobody viewing the session is kept with the session and sent when a page next shows it. pending can also arrive unasked: a cancel of another message may have dropped this one too (it shares the dropped batch), and the page disables its controls. cancelled also goes, without text, to the other pages on the session when one page withdraws the message: a page that drew the item drops it, one that did not changes nothing" },
67
+ "queued_message_tracked": { direction: "s2c", handler: "lib/public/modules/app-messages.js", description: "A chat message the agent has not taken in yet, sent after a session is shown (a reload, a second tab): {messageId, text, pastes, imageCount, unconfirmed, sendNow?}. The page draws it as queued again with its controls, or, when sendNow is true (Send now was pressed on it), as sending with no controls and never as queued; message_delivered or queued_message_cancelled then ends it. A page that already holds an item for the id ignores it" },
68
+ "send_now_queued_message": { direction: "c2s", handler: "lib/project-user-message.js", description: "Send now on a chat message the page drew as queued (already pushed to the agent): {messageId}. The server interrupts the running turn with the agent's queue kept, so the message runs as the next input at once; nothing is pushed again. Answered with queued_message_send_now" },
69
+ "queued_message_send_now": { direction: "s2c", handler: "lib/public/modules/app-messages.js", description: "The outcome of Send now on a queued chat message: {messageId, result}. requested: the turn was interrupted and the agent still holds the message (or sent no receipt to say otherwise); the page draws the item as sending, with no queued label or controls, and message_delivered ends it. Also sent, unasked, to the other pages on the session. already_delivered: the server no longer tracks the message (taken, cancelled, unknown); nothing was interrupted. no_turn: no turn runs, or the message was pushed into a query that is no longer the session's live one; nothing was interrupted and the item stays as it was. missed: the interrupt receipt did not list the message, so it was not kept; it is handed back through queued_message_cancelled (dropped, cause send_now_missed, with its text) and never pushed again. unsupported: the agent cannot interrupt. error: the agent did not answer (message says why); the item is drawn as queued again" },
64
70
  "user_message": { direction: "s2c", handler: "lib/public/modules/app-messages.js", description: "Echo of the user message in the timeline" },
71
+ "shell": { direction: "c2s", handler: "lib/project-user-shell.js", description: "Run a command typed with !: {command, requestId?}. Only leading whitespace is dropped from the command. The server checks in order: the setting off, OS-user isolation, plan mode, a running turn or command, no live query, an adapter without runUserShellCommand, then the permission gate as a Bash tool call. Answered with shell_result. A stop request cancels a pending approval and aborts a running command" },
72
+ "shell_result": { direction: "s2c", handler: "lib/public/modules/app-messages.js", description: "The outcome of a shell request, sent to every client viewing the session and recorded in its history: {requestId, command, exitCode, durationMs, output, truncated, timedOut, interrupted}, plus refused:true with reason (disabled, empty, os_users, plan, no_terminal, busy, no_query, unsupported) and message, denied:true when the gate did not approve it, or error:true (output carries the message) when it could not run" },
73
+ "set_user_shell_settings": { direction: "c2s", handler: "lib/project-user-shell.js", description: "Change the ! settings (admin only): userShellEnabled, userShellTimeoutMinutes, userShellMaxOutputKiB" },
74
+ "user_shell_settings": { direction: "s2c", handler: "lib/public/modules/app-messages.js", description: "The ! settings, sent on connect and to every client after a change: userShellEnabled (default true), userShellTimeoutMinutes (default 10), userShellMaxOutputKiB (default 256)" },
65
75
  "delta": { direction: "s2c", handler: "lib/public/modules/app-messages.js", description: "Incremental text delta from the assistant" },
66
76
  "result": { direction: "s2c", handler: "lib/public/modules/app-messages.js", description: "Final assistant result text" },
67
77
  "status": { direction: "s2c", handler: "lib/public/modules/app-messages.js", description: "Processing status update (e.g. 'processing')" },
@@ -114,6 +124,14 @@ var schema = {
114
124
  "team_message": { direction: "s2c", handler: "lib/public/modules/team-panel.js", description: "Teammate SendMessage event (peer DM)" },
115
125
  "team_gone": { direction: "s2c", handler: "lib/public/modules/team-panel.js", description: "Team was deleted/cleaned up" },
116
126
  "team_request_state": { direction: "c2s", handler: "lib/project-team.js", description: "Client requests current team snapshot" },
127
+ "team_traffic_request": { direction: "c2s", handler: "lib/team-traffic-ws.js", description: "Ask for the agent-to-agent traffic through the console that this connection may read" },
128
+ "team_traffic": { direction: "s2c", handler: "lib/public/modules/app-messages.js", description: "Agent messages (drawn by agent-messages.js): pairs (count, last seen), messages, pending scheduled inputs, withheld count and reasons" },
129
+ "team_traffic_changed": { direction: "s2c", handler: "lib/public/modules/app-messages.js", description: "An open or send landed; ask again (carries no content)" },
130
+ "agent_roster_request": { direction: "c2s", handler: "lib/agent-roster-ws.js", description: "Ask for the agent roster" },
131
+ "agent_roster": { direction: "s2c", handler: "lib/public/modules/app-messages.js", description: "The agent roster (drawn by agent-roster.js): every agent identity the console has seen, each {key, firstSeen, lastSeen, places [{source, project, session, lastSeen}], avatar}; avatar is {style, seed}, {custom} (a custom-icon slug) or null. Sent to a connection on connect and on request, limited to the projects that connection may read (an agent with no readable place is omitted); the avatar map every agent label resolves from" },
132
+ "agent_roster_changed": { direction: "s2c", handler: "lib/public/modules/app-messages.js", description: "The agent roster changed; send agent_roster_request (carries no content)" },
133
+ "agent_avatar_set": { direction: "c2s", handler: "lib/agent-roster-ws.js", description: "Choose the avatar of a seen agent: {key, avatar}; avatar is {style, seed}, {custom} or null to clear" },
134
+ "agent_avatar_set_result": { direction: "s2c", handler: "lib/public/modules/app-messages.js", description: "The outcome of agent_avatar_set for the client that asked: {key, ok, error?}" },
117
135
  "task_started": { direction: "s2c", handler: "lib/public/modules/app-messages.js", description: "Background task started" },
118
136
  "task_progress": { direction: "s2c", handler: "lib/public/modules/app-messages.js", description: "Background task progress update" },
119
137
  // lr-66c118 fold-in: see the plan_content/sdk_notification/diagnostic note above.
@@ -130,8 +148,8 @@ var schema = {
130
148
  "prompt_request": { direction: "s2c", handler: "lib/public/modules/app-messages.js", description: "A prompt awaits the operator: {requestId, kind, toolUseId, label: {project, session, agent}, ...kind fields} (label names whose prompt it is; agent is empty unless a background agent raised it). On history replay it carries promptState {state: pending|resolved|cancelled, decision|answers|skipped|action, reason}, the server's authoritative state for the prompt at replay time" },
131
149
  "prompt_pending": { direction: "s2c", handler: "lib/public/modules/app-messages.js", description: "A prompt still awaiting the operator, re-presented on connect and session switch; same fields as prompt_request" },
132
150
  "prompt_response": { direction: "c2s", handler: "lib/project-prompt-responses.js", description: "The operator's answer: {requestId, kind, ...} with decision (+ feedback, planContent) for permission/plan, answers or decision:\"skip\" for ask_user (answers keyed by question index; each a label or text, or for a multi-select question the list of chosen labels), action (+ content, held to the requested schema) for elicitation. The kind is required and must match the prompt's. Decision allow_always grants the whole tool (Skill: the one skill) for the rest of the session, and to a permission prompt that carries suppressAlwaysAllowRule settles nothing: the prompt is sent again as prompt_pending. A prompt of the extension kind is never answered this way" },
133
- "prompt_resolved": { direction: "s2c", handler: "lib/public/modules/app-messages.js", description: "A prompt was answered: {requestId, kind, decision|answers|skipped|action, source?}; a permission prompt forced by a user ask rule also carries matchedAskRule. source says who answered, as {kind:\"ws\", clientId, user} for a browser connection (clientId is a per-connection label, user the user id or null) or {kind:\"push\", action, user} for a push notification answer; it is absent when the answering path named none. The same source is written to the journal line the settle logs. Prompt content is never part of a source" },
134
- "prompt_cancel": { direction: "s2c", handler: "lib/public/modules/app-messages.js", description: "A prompt ended without an answer: {requestId, kind, reason}; reason is aborted, expired, turn_ended, query_ended, rewind, cleared or shutdown. Reason \"stale\" is sent only to a client whose prompt_response named a prompt the server no longer holds, and is not recorded in history" },
151
+ "prompt_resolved": { direction: "s2c", handler: "lib/public/modules/app-messages.js", description: "A prompt was answered: {requestId, kind, decision|answers|skipped|action, source?}; a permission prompt forced by a user ask rule also carries matchedAskRule. source says who answered, as {kind:\"ws\", clientId, user} for a browser connection (clientId is a per-connection label, user the user id or null) or {kind:\"push\", action, user} for a push notification answer, or the string user or caller:<name> for an answer from the answer-prompt CLI verb; it is absent when the answering path named none. The same source is written to the journal line the settle logs. Prompt content is never part of a source" },
152
+ "prompt_cancel": { direction: "s2c", handler: "lib/public/modules/app-messages.js", description: "A prompt ended without an answer: {requestId, kind, reason, source}; reason is aborted, expired, turn_ended, query_ended, rewind, cleared or shutdown; source says who or what ended it: user, timeout, session_end, daemon_restart, worker, caller:<name> or unspecified (a replayed ending recorded before cancels carried a source). promptState on a replayed request carries the same source for a cancelled prompt. Reason \"stale\" is sent only to a client whose prompt_response named a prompt the server no longer holds, and is not recorded in history" },
135
153
 
136
154
  // Aliases kept for compatibility: the s2c types appear in history recorded
137
155
  // before prompts had one shape (the client maps them onto the prompt_*
@@ -183,10 +201,11 @@ var schema = {
183
201
  // input with an end. The scheduled_message_* names are the original ones, kept;
184
202
  // a current client takes its state from scheduled_input_list alone.
185
203
  "schedule_message": { direction: "c2s", handler: "lib/scheduled-input/ws.js", description: "Schedule input for the session on screen: once ({ text, resetsAt }) or recurring ({ text, kind, every, until | count })" },
186
- "send_scheduled_now": { direction: "c2s", handler: "lib/scheduled-input/ws.js", description: "Send a scheduled input immediately ({ id? }), into a running turn if need be" },
187
- "cancel_scheduled_message": { direction: "c2s", handler: "lib/scheduled-input/ws.js", description: "Cancel a scheduled input ({ id? })" },
204
+ "send_scheduled_now": { direction: "c2s", handler: "lib/scheduled-input/ws.js", description: "Send a scheduled input immediately ({ id?, requestId? }), into a running turn if need be" },
205
+ "cancel_scheduled_message": { direction: "c2s", handler: "lib/scheduled-input/ws.js", description: "Cancel a scheduled input ({ id?, requestId? })" },
188
206
  "scheduled_input_list_request": { direction: "c2s", handler: "lib/scheduled-input/ws.js", description: "Ask for the armed scheduled inputs of the session on screen" },
189
207
  "scheduled_input_list": { direction: "s2c", handler: "lib/public/modules/app-messages.js", description: "The armed scheduled inputs of a session, in full, after every change" },
208
+ "scheduled_request_result": { direction: "s2c", handler: "lib/public/modules/app-messages.js", description: "The answer to a send_scheduled_now or cancel_scheduled_message that carried a requestId (carries requestId, id, ok)" },
190
209
  "scheduled_message_queued": { direction: "s2c", handler: "lib/public/modules/app-messages.js", description: "A scheduled input was queued (older clients draw their bubble from it; also carries id, kind, every, until, count)" },
191
210
  "scheduled_message_sent": { direction: "s2c", handler: "lib/public/modules/app-messages.js", description: "A scheduled input was sent (carries id, kind and final)" },
192
211
  "scheduled_message_cancelled": { direction: "s2c", handler: "lib/public/modules/app-messages.js", description: "A scheduled input was cancelled or ended (carries id and reason)" },
@@ -238,6 +257,11 @@ var schema = {
238
257
 
239
258
  // -----------------------------------------------------------------------
240
259
  // Push notifications
260
+ // notification_created, notification_dismissed and notifications_state carry
261
+ // each banner notification with the fields the notification core sets
262
+ // (lib/notify/): key (the collapse identity), collapse ("request"|"session"),
263
+ // persistent (not auto-dismissed) and liveInState (checkable against the
264
+ // live prompts). notifications_state also carries livePrompts. All additive.
241
265
  // -----------------------------------------------------------------------
242
266
  "set_session_prompt_reminders": { direction: "c2s", handler: "lib/project-sessions.js", description: "Turn reminders for a session's unanswered prompts on or off: {sessionId, enabled}" },
243
267
  "notification_prefs": { direction: "s2c", handler: "lib/public/modules/app-messages.js", description: "The user's per-type notification preferences ({prefs: {banner|sound|push: {category: boolean}}, preset, known, categories, presets}); sent on connect and to every connection of the user after a change" },
@@ -358,6 +382,10 @@ var schema = {
358
382
  "project_env_result": { direction: "s2c", handler: "lib/public/modules/app-messages.js", description: "Project .envrc content" },
359
383
  "set_project_env": { direction: "c2s", handler: "lib/project-filesystem.js", description: "Write the project .envrc" },
360
384
  "set_project_env_result": { direction: "s2c", handler: "lib/public/modules/app-messages.js", description: "Project .envrc write result" },
385
+ "get_idle_compaction": { direction: "c2s", handler: "lib/project-filesystem.js", description: "Read the Claude idleCompaction user setting" },
386
+ "idle_compaction_result": { direction: "s2c", handler: "lib/public/modules/server-settings.js", description: "Current idleCompaction value (off, default or on) or a read error" },
387
+ "set_idle_compaction": { direction: "c2s", handler: "lib/project-filesystem.js", description: "Set idleCompaction off or remove it (default)" },
388
+ "set_idle_compaction_result": { direction: "s2c", handler: "lib/public/modules/server-settings.js", description: "idleCompaction write result" },
361
389
  "read_global_claude_md": { direction: "c2s", handler: "lib/project-filesystem.js", description: "Read the global CLAUDE.md" },
362
390
  "global_claude_md_result": { direction: "s2c", handler: "lib/public/modules/app-messages.js", description: "Global CLAUDE.md content" },
363
391
  "write_global_claude_md": { direction: "c2s", handler: "lib/project-filesystem.js", description: "Write the global CLAUDE.md" },
@@ -29,9 +29,11 @@ function claudeCapabilities() {
29
29
  backgroundTasks: true,
30
30
  steering: true,
31
31
  agentInjection: true,
32
+ queuedMessageCancel: true,
32
33
  executionPolicy: false,
33
34
  toolPolicy: ["ask", "allow-all"],
34
35
  permissionModes: PERMISSION_MODES.slice(),
36
+ additiveSettings: true,
35
37
  };
36
38
  }
37
39
 
@@ -8,8 +8,17 @@
8
8
  var registry = require("../registry");
9
9
  var authChecks = require("../auth-checks");
10
10
  var providerCredentials = require("../provider-credentials");
11
+ var claudeSettingsEnv = require("../../claude-settings-env");
11
12
  var claudeCapabilities = require("./claude-capabilities").claudeCapabilities;
12
13
 
14
+ // The provider variables are Claude Code's, read after its settings file's env
15
+ // block is applied; so the classification is declared here, by the agent that
16
+ // reads them.
17
+ // osUsers: the daemon reads no settings file for another account's session.
18
+ function effectiveRuntimeEnv(env, osUsers) {
19
+ return claudeSettingsEnv.applyUserSettingsEnv(env || {}, { osUsers: !!osUsers });
20
+ }
21
+
13
22
  registry.register({
14
23
  id: "claude",
15
24
  displayName: "Claude Code",
@@ -18,8 +27,15 @@ registry.register({
18
27
  binaryNames: ["claude"],
19
28
  probeInstalled: function(ctx) { return ctx.lookupBinary("claude"); },
20
29
  checkAuth: authChecks.checkClaudeAuth,
30
+ effectiveRuntimeEnv: effectiveRuntimeEnv,
21
31
  installHint: "Install Claude Code (npm install -g @anthropic-ai/claude-code), then sign in.",
22
- loginCommand: "claude login",
32
+ loginCommand: "claude auth login",
33
+ // The login prints a sign-in URL and then asks for the code the sign-in
34
+ // page shows.
35
+ loginPatterns: {
36
+ url: "https:\\/\\/[^\\s'\"\\]>)}{]+",
37
+ codePrompt: "[Pp]aste code here",
38
+ },
23
39
  osUsersSupported: true,
24
40
  needsRuntimeEnv: false,
25
41
  perProjectRuntime: false,
@@ -220,6 +220,12 @@ function handleMessage(msg) {
220
220
  case "push_message":
221
221
  handlePushMessage(msg);
222
222
  break;
223
+ case "cancel_message":
224
+ handleCancelMessage(msg);
225
+ break;
226
+ case "interrupt_query":
227
+ handleInterruptQuery(msg);
228
+ break;
223
229
  case "end_messages":
224
230
  if (messageQueue) messageQueue.end();
225
231
  break;
@@ -269,23 +275,15 @@ function canUseTool(toolName, input, opts) {
269
275
  var requestId = crypto.randomUUID();
270
276
  sendToDaemon(permissionRelay.toRequestMessage(requestId, toolName, input, opts));
271
277
  return new Promise(function(resolve) {
272
- var timeoutId = setTimeout(function() {
273
- if (pendingPermissions[requestId]) {
274
- delete pendingPermissions[requestId];
275
- resolve({ behavior: "deny", message: "Permission request timed out after 30s" });
276
- // The daemon still shows the request as answerable; tell it the
277
- // decision can no longer take effect.
278
- sendToDaemon({ type: "permission_expired", requestId: requestId });
279
- }
280
- }, 30000);
278
+ // No timer here: the daemon's prompt registry bounds an unanswered
279
+ // prompt (daemon.json promptExpiryMinutes) and answers deny through the
280
+ // relay.
281
281
  pendingPermissions[requestId] = function(result) {
282
- clearTimeout(timeoutId);
283
282
  resolve(result);
284
283
  };
285
284
  if (opts.signal) {
286
285
  opts.signal.addEventListener("abort", function() {
287
286
  if (pendingPermissions[requestId]) {
288
- clearTimeout(timeoutId);
289
287
  delete pendingPermissions[requestId];
290
288
  resolve({ behavior: "deny", message: "Cancelled" });
291
289
  sendToDaemon({ type: "prompt_cancelled", kind: "permission", id: requestId });
@@ -585,6 +583,36 @@ function handlePushMessage(msg) {
585
583
  messageQueue.push(msg.content);
586
584
  }
587
585
 
586
+ // Bridges the daemon's cancelQueuedMessage to the SDK query held here. The
587
+ // answer is the SDK's own: true only when the message was still queued.
588
+ async function handleCancelMessage(msg) {
589
+ if (!queryInstance || typeof queryInstance.cancelAsyncMessage !== "function") {
590
+ sendToDaemon({ type: "cancel_message_response", requestId: msg.requestId, error: "The installed Claude SDK cannot cancel a queued message." });
591
+ return;
592
+ }
593
+ try {
594
+ var cancelled = await queryInstance.cancelAsyncMessage(msg.messageId);
595
+ sendToDaemon({ type: "cancel_message_response", requestId: msg.requestId, cancelled: cancelled === true });
596
+ } catch (e) {
597
+ sendToDaemon({ type: "cancel_message_response", requestId: msg.requestId, error: (e && e.message) ? e.message : String(e) });
598
+ }
599
+ }
600
+
601
+ // Interrupts the running turn with the SDK's queue kept (Query.interrupt() with
602
+ // no cancelQueued), and answers with the interrupt receipt as the SDK returns it.
603
+ async function handleInterruptQuery(msg) {
604
+ if (!queryInstance || typeof queryInstance.interrupt !== "function") {
605
+ sendToDaemon({ type: "interrupt_response", requestId: msg.requestId, error: "The installed Claude SDK cannot interrupt a query." });
606
+ return;
607
+ }
608
+ try {
609
+ var receipt = await queryInstance.interrupt();
610
+ sendToDaemon({ type: "interrupt_response", requestId: msg.requestId, receipt: receipt || null });
611
+ } catch (e) {
612
+ sendToDaemon({ type: "interrupt_response", requestId: msg.requestId, error: (e && e.message) ? e.message : String(e) });
613
+ }
614
+ }
615
+
588
616
  async function handleSetModel(msg) {
589
617
  if (!queryInstance) return;
590
618
  try {