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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (127) hide show
  1. package/LICENSES/README.md +5 -0
  2. package/bin/cli.js +4 -2
  3. package/lib/agent-roster-ws.js +84 -0
  4. package/lib/agent-roster.js +312 -0
  5. package/lib/auth-required-notify.js +42 -0
  6. package/lib/build-sha.json +2 -2
  7. package/lib/build-update-notify.js +45 -0
  8. package/lib/build-update-offer.js +3 -4
  9. package/lib/build-update-standing.js +34 -14
  10. package/lib/cli/session-subcommands.js +26 -8
  11. package/lib/client-address.js +44 -0
  12. package/lib/daemon.js +25 -10
  13. package/lib/idle-compaction-setting.js +203 -0
  14. package/lib/mcp-bridge-credential.js +41 -0
  15. package/lib/notification-prefs.js +16 -22
  16. package/lib/notify/core.js +53 -18
  17. package/lib/notify/payload.js +2 -3
  18. package/lib/notify/type-registry.js +17 -0
  19. package/lib/notify/types.js +38 -1
  20. package/lib/outbound-access.js +12 -1
  21. package/lib/outbound-entry.js +8 -1
  22. package/lib/project-connection.js +9 -8
  23. package/lib/project-filesystem.js +23 -0
  24. package/lib/project-loop.js +16 -19
  25. package/lib/project-notifications.js +68 -7
  26. package/lib/project-sessions.js +9 -0
  27. package/lib/project-user-mention.js +22 -34
  28. package/lib/project-user-message.js +208 -4
  29. package/lib/project-user-shell.js +298 -0
  30. package/lib/project.js +26 -4
  31. package/lib/prompt-answer.js +145 -0
  32. package/lib/prompt-expiry.js +50 -0
  33. package/lib/prompt-registry.js +24 -1
  34. package/lib/prompt-source.js +16 -0
  35. package/lib/public/app.js +31 -2
  36. package/lib/public/css/agent-messages.css +96 -0
  37. package/lib/public/css/agent-roster.css +93 -0
  38. package/lib/public/css/diagnostics.css +1 -1
  39. package/lib/public/css/input.css +20 -141
  40. package/lib/public/css/login-panel.css +73 -0
  41. package/lib/public/css/menus.css +2 -2
  42. package/lib/public/css/sidebar.css +11 -0
  43. package/lib/public/css/team-panel.css +1 -6
  44. package/lib/public/css/team-view.css +101 -0
  45. package/lib/public/css/title-bar.css +10 -0
  46. package/lib/public/css/user-shell.css +144 -0
  47. package/lib/public/index.html +41 -7
  48. package/lib/public/modules/agent-avatar-picker.js +162 -0
  49. package/lib/public/modules/agent-avatar.js +153 -0
  50. package/lib/public/modules/agent-messages.js +285 -0
  51. package/lib/public/modules/agent-roster.js +157 -0
  52. package/lib/public/modules/app-connection.js +12 -0
  53. package/lib/public/modules/app-messages.js +55 -16
  54. package/lib/public/modules/app-notifications.js +59 -29
  55. package/lib/public/modules/app-panels.js +26 -3
  56. package/lib/public/modules/app-rate-limit.js +8 -165
  57. package/lib/public/modules/app-rendering.js +22 -7
  58. package/lib/public/modules/collapsible-text.js +33 -18
  59. package/lib/public/modules/compaction-state.js +34 -0
  60. package/lib/public/modules/custom-icons.js +23 -5
  61. package/lib/public/modules/diagnostics.js +52 -55
  62. package/lib/public/modules/injected-identity.js +24 -21
  63. package/lib/public/modules/input.js +176 -15
  64. package/lib/public/modules/login-panel.js +136 -0
  65. package/lib/public/modules/login-parser.js +73 -0
  66. package/lib/public/modules/login-tab.js +66 -0
  67. package/lib/public/modules/notifications.js +9 -1
  68. package/lib/public/modules/notify-client.js +114 -21
  69. package/lib/public/modules/pending-term-request.js +30 -0
  70. package/lib/public/modules/project-icon.js +22 -2
  71. package/lib/public/modules/queued-button.js +11 -0
  72. package/lib/public/modules/scheduled-input-actions.js +12 -4
  73. package/lib/public/modules/scheduled-outbox.js +230 -0
  74. package/lib/public/modules/send-now.js +200 -0
  75. package/lib/public/modules/server-settings.js +47 -1
  76. package/lib/public/modules/shell-card.js +76 -0
  77. package/lib/public/modules/shell-line.js +49 -0
  78. package/lib/public/modules/shell-queue.js +253 -0
  79. package/lib/public/modules/shell-settings-controls.js +76 -0
  80. package/lib/public/modules/sidebar-mobile.js +3 -3
  81. package/lib/public/modules/sidebar-sessions.js +8 -0
  82. package/lib/public/modules/sidebar-users.js +5 -7
  83. package/lib/public/modules/team-panel.js +30 -88
  84. package/lib/public/modules/team-view.js +211 -0
  85. package/lib/public/modules/terminal-links.js +18 -0
  86. package/lib/public/modules/terminal.js +65 -4
  87. package/lib/public/modules/tools.js +19 -0
  88. package/lib/public/modules/user-shell.js +824 -0
  89. package/lib/public/notify-sw-logic.js +35 -83
  90. package/lib/public/notify-target.js +70 -10
  91. package/lib/public/style.css +5 -0
  92. package/lib/public/sw.js +7 -3
  93. package/lib/queued-chat.js +392 -0
  94. package/lib/scheduled-input/ws.js +67 -9
  95. package/lib/sdk-bridge.js +122 -43
  96. package/lib/sdk-message-processor.js +46 -39
  97. package/lib/server-auth.js +6 -4
  98. package/lib/server-dm.js +11 -20
  99. package/lib/server-settings.js +39 -1
  100. package/lib/server.js +83 -19
  101. package/lib/session-directory.js +33 -8
  102. package/lib/session-end.js +97 -0
  103. package/lib/session-input-ipc.js +26 -0
  104. package/lib/session-input.js +176 -9
  105. package/lib/session-resume.js +1 -0
  106. package/lib/session-settings-file.js +53 -0
  107. package/lib/sessions.js +49 -5
  108. package/lib/team-traffic-ws.js +68 -0
  109. package/lib/team-traffic.js +318 -0
  110. package/lib/usage-store.js +7 -0
  111. package/lib/user-shell-settings.js +105 -0
  112. package/lib/ws-schema.js +27 -4
  113. package/lib/yoke/adapters/claude-capabilities.js +2 -0
  114. package/lib/yoke/adapters/claude-vendor.js +6 -0
  115. package/lib/yoke/adapters/claude-worker.js +39 -11
  116. package/lib/yoke/adapters/claude.js +218 -6
  117. package/lib/yoke/adapters/codex-capabilities.js +6 -1
  118. package/lib/yoke/adapters/codex-user-shell.js +265 -0
  119. package/lib/yoke/adapters/codex-vendor.js +7 -0
  120. package/lib/yoke/adapters/codex.js +186 -52
  121. package/lib/yoke/codex-app-server.js +8 -2
  122. package/lib/yoke/interface.js +54 -1
  123. package/lib/yoke/mcp-bridge-server.js +12 -8
  124. package/lib/yoke/registry.js +32 -0
  125. package/lib/yoke/user-shell.js +224 -0
  126. package/package.json +1 -1
  127. package/lib/public/modules/build-notice-gate.js +0 -73
@@ -12,4 +12,9 @@ this change remain under MIT.
12
12
  The FSL-1.1-MIT license applies from commit db3c533 (PR #434) onward; the first
13
13
  release cut after that commit is the first FSL release.
14
14
 
15
+ That release is `v1.10.0-beta.1`, published 2026-10-11; the first stable FSL
16
+ release is `v1.10.0`, published 2026-10-16. The last MIT release is `v1.9.0`,
17
+ published 2026-09-04. Commit db3c533 is in `v1.10.0-beta.1` and not in
18
+ `v1.9.0`.
19
+
15
20
  Third-party components keep their own licenses.
package/bin/cli.js CHANGED
@@ -89,7 +89,7 @@ if (args[0] === "release") {
89
89
  }
90
90
  }
91
91
 
92
- // --- `open-session` / `send-input` / `list-sessions` / `list-outbound`: drive a session through the running daemon ---
92
+ // --- `open-session` / `send-input` / `end-session` / `list-sessions` / `list-outbound`: drive a session through the running daemon ---
93
93
  // Positional verbs, handled before flag parsing: `clagentic-console send-input --project <slug> ...`.
94
94
  var { SESSION_VERBS, runSessionVerb } = require("../lib/cli/session-subcommands");
95
95
  if (SESSION_VERBS.indexOf(args[0]) !== -1) {
@@ -198,8 +198,10 @@ for (var i = 0; i < args.length; i++) {
198
198
  console.log(" clagentic-console --activity-diagnostics Print activity-divergence probe totals as JSON (agent-readable)");
199
199
  console.log(" clagentic-console --usage Print account usage per vendor and rate-limit bucket as JSON, with how fresh each reading is and why (agent-readable)");
200
200
  console.log(" clagentic-console --process-build-status Print the running process's loaded build SHA as JSON (agent-readable)");
201
- console.log(" clagentic-console open-session (--project <slug> | --to <address>) --prompt <text|-> [--vendor <id>] [--agent <name>] [--name <session-name>] [--visibility shared|private] [--permission-mode <mode>] [--initiator <kind>] [--context-note <text>] [--from <name>] [--from-session <id>] Open a session and run a first prompt (prints JSON)");
201
+ console.log(" clagentic-console open-session (--project <slug> | --to <address>) --prompt <text|-> [--vendor <id>] [--agent <name>] [--name <session-name>] [--visibility shared|private] [--permission-mode <mode>] [--settings <path>] [--initiator <kind>] [--context-note <text>] [--from <name>] [--from-session <id>] Open a session and run a first prompt (prints JSON)");
202
202
  console.log(" clagentic-console send-input (--project <slug> --session <id> | --to <address> | --reply) --prompt <text|-> [--initiator <kind>] [--context-note <text>] [--from <name>] [--from-session <id>] Send input to a session, resuming it if needed (prints JSON; exit 3 ambiguous, 4 not found by address)");
203
+ console.log(" clagentic-console end-session (--project <slug> --session <id> | --to <address>) [--from <name>] [--from-session <id>] [--reason <text>] Stand one live session down, even one blocked on a permission prompt; history is kept and the session resumes by id (prints JSON; exit 3 ambiguous, 4 not found by address)");
204
+ console.log(" clagentic-console answer-prompt (--project <slug> --session <id> | --to <address>) --request <id> --decision <allow|deny|allow_always|text> [--from <name>] [--from-session <id>] Answer one pending prompt of a live session, as the browser would (prints JSON; exit 3 ambiguous, 4 not found by address)");
203
205
  console.log(" clagentic-console list-sessions [--project <slug>] [--agent <name>] [--vendor <id>] [--state live|idle|reaped|any] List the console's sessions (prints JSON)");
204
206
  console.log(" clagentic-console list-outbound --session <vendor-session-id> [--project <slug>] [--since <dur>] [--kind sent|opens] List what a session (by vendor session id, see list-sessions) sent out with send-input and open-session: target, prompt, time, initiator (prints JSON; read-only; kept 30 days by default)");
205
207
  console.log(" clagentic-console schedule-input create --session <id> [--project <slug>] (--in <dur> | --at <time> | --every <dur> (--until <time> | --count <n>)) (--prompt <text|-> | --prompt-file <path>) Send text into a session later, once or on a repeat with an end (prints JSON)");
@@ -0,0 +1,84 @@
1
+ // agent-roster-ws.js - the browser's side of the Team view's agent roster
2
+ // (lib/agent-roster.js).
3
+ //
4
+ // agent_roster_request c2s ask for the roster
5
+ // agent_avatar_set c2s {key, avatar}: choose an avatar for a seen agent;
6
+ // avatar is {style, seed}, {custom} or null (clear)
7
+ // agent_roster s2c the roster as this connection may read it:
8
+ // {agents: [{key, firstSeen, lastSeen, places,
9
+ // avatar}]}, a place being {source, project,
10
+ // lastSeen}. Sent on connect and on request; each
11
+ // place is limited to projects the connection can
12
+ // read, and an agent with none is left out.
13
+ // agent_roster_changed s2c the roster changed; ask again. It carries no
14
+ // content, so what a connection may read is decided
15
+ // only when it asks, never by a broadcast.
16
+ // agent_avatar_set_result s2c {key, ok, error?} to the client that asked
17
+
18
+ var REQUEST = "agent_roster_request";
19
+ var SET_AVATAR = "agent_avatar_set";
20
+ var ROSTER = "agent_roster";
21
+ var CHANGED = "agent_roster_changed";
22
+ var SET_RESULT = "agent_avatar_set_result";
23
+
24
+ // The caller of a socket, as lib/outbound-access.js reads it.
25
+ function callerOf(ws) {
26
+ return { user: (ws && ws._clagenticUser) || null, authenticated: !!ws && ws._clagenticAuthenticated === true };
27
+ }
28
+
29
+ // service: { listFor(caller) } or null. A service that cannot say what a caller
30
+ // may read answers nothing rather than everything.
31
+ function rosterMessage(service, caller) {
32
+ return { type: ROSTER, agents: service && typeof service.listFor === "function" ? service.listFor(caller) : [] };
33
+ }
34
+
35
+ // deps: { service ({ listFor(caller), setAvatar(caller, key, avatar) }, or null), sendTo(ws, obj) }
36
+ function createWsHandlers(deps) {
37
+ var service = deps.service;
38
+
39
+ // Answers true when the message was one of ours.
40
+ function handle(ws, msg) {
41
+ if (!msg) return false;
42
+ if (msg.type === REQUEST) {
43
+ var message;
44
+ try {
45
+ message = rosterMessage(service, callerOf(ws));
46
+ } catch (e) {
47
+ console.error("[agent-roster] reading the roster failed:", e && e.message ? e.message : e);
48
+ message = { type: ROSTER, agents: [] };
49
+ }
50
+ deps.sendTo(ws, message);
51
+ return true;
52
+ }
53
+ if (msg.type === SET_AVATAR) {
54
+ var key = typeof msg.key === "string" ? msg.key : "";
55
+ if (!service) {
56
+ deps.sendTo(ws, { type: SET_RESULT, key: key, ok: false, error: "the agent roster is not available here" });
57
+ return true;
58
+ }
59
+ var outcome;
60
+ try {
61
+ outcome = service.setAvatar(callerOf(ws), msg.key, msg.avatar);
62
+ } catch (e) {
63
+ console.error("[agent-roster] setting an avatar failed:", e && e.message ? e.message : e);
64
+ outcome = { ok: false, error: "the avatar could not be saved" };
65
+ }
66
+ deps.sendTo(ws, outcome.ok ? { type: SET_RESULT, key: key, ok: true } : { type: SET_RESULT, key: key, ok: false, error: outcome.error });
67
+ return true;
68
+ }
69
+ return false;
70
+ }
71
+
72
+ return { handle: handle };
73
+ }
74
+
75
+ module.exports = {
76
+ createWsHandlers: createWsHandlers,
77
+ rosterMessage: rosterMessage,
78
+ callerOf: callerOf,
79
+ REQUEST: REQUEST,
80
+ SET_AVATAR: SET_AVATAR,
81
+ ROSTER: ROSTER,
82
+ CHANGED: CHANGED,
83
+ SET_RESULT: SET_RESULT,
84
+ };
@@ -0,0 +1,312 @@
1
+ // agent-roster.js - every agent identity the console has seen, with when and
2
+ // where, and the avatar the operator chose for it.
3
+ //
4
+ // Built only from what is observed. An identity is recorded under the exact key
5
+ // it arrived with (a session's agent name, a Task or Agent tool call's
6
+ // subagent_type, an injected sender's name); nothing is guessed, merged or
7
+ // case-folded. Nothing in this file names an agent.
8
+ //
9
+ // Observation is read-only: callers report a sighting and carry on, and a
10
+ // sighting that cannot be recorded is logged, never thrown into the session or
11
+ // delivery that produced it.
12
+ //
13
+ // Persistence is one file under the console data dir. daemon.json is not used:
14
+ // the daemon rewrites it wholesale from its in-memory config, which would drop
15
+ // entries written from here. The file holds the roster and each agent's avatar
16
+ // reference together, so a restart restores both.
17
+ //
18
+ // An avatar reference is {style, seed} (a built-in robot style) or {custom}
19
+ // (a slug in the global custom-icon store, /api/custom-emoji). The store keeps
20
+ // the image; this file only keeps the slug.
21
+
22
+ var fs = require("fs");
23
+
24
+ var FILE_VERSION = 1;
25
+
26
+ var SOURCE = Object.freeze({ SESSION: "session", SUBAGENT: "subagent", SENDER: "sender" });
27
+ var SOURCES = Object.freeze(Object.keys(SOURCE).map(function (k) { return SOURCE[k]; }));
28
+
29
+ var MAX_AGENTS = 1000;
30
+ var MAX_KEY_LENGTH = 128;
31
+ var MAX_PLACES = 20;
32
+ var MAX_PLACE_FIELD_LENGTH = 128;
33
+ var MAX_SEED_LENGTH = 128;
34
+ var PERSIST_DELAY_MS = 500;
35
+
36
+ // Mirrors the custom-icon store's slug rule (lib/server-settings.js).
37
+ var SLUG_RE = /^[a-z0-9_-]{1,64}$/;
38
+ var STYLE_RE = /^[a-z0-9-]{1,32}$/;
39
+ var CONTROL_CHARS = /[\u0000-\u001f\u007f-\u009f]/;
40
+
41
+ function isUsableKey(key) {
42
+ return typeof key === "string" && key.length > 0 && key.length <= MAX_KEY_LENGTH
43
+ && key.trim().length > 0 && !CONTROL_CHARS.test(key);
44
+ }
45
+
46
+ function fieldOf(value) {
47
+ if (value === undefined || value === null) return null;
48
+ var text = String(value);
49
+ return text.length > 0 && text.length <= MAX_PLACE_FIELD_LENGTH ? text : null;
50
+ }
51
+
52
+ // Returns { ok: true, avatar } (avatar null clears the choice) or { ok: false, error }.
53
+ function validateAvatar(ref) {
54
+ if (ref === null || ref === undefined) return { ok: true, avatar: null };
55
+ if (typeof ref !== "object" || Array.isArray(ref)) return { ok: false, error: "avatar must be an object or null" };
56
+ if (ref.custom !== undefined) {
57
+ if (typeof ref.custom !== "string" || !SLUG_RE.test(ref.custom)) return { ok: false, error: "custom must be a custom-icon slug" };
58
+ return { ok: true, avatar: { custom: ref.custom } };
59
+ }
60
+ if (typeof ref.style !== "string" || !STYLE_RE.test(ref.style)) return { ok: false, error: "style must be a built-in avatar style id" };
61
+ if (typeof ref.seed !== "string" || ref.seed.length === 0 || ref.seed.length > MAX_SEED_LENGTH || CONTROL_CHARS.test(ref.seed)) {
62
+ return { ok: false, error: "seed must be a non-empty string of at most " + MAX_SEED_LENGTH + " characters" };
63
+ }
64
+ return { ok: true, avatar: { style: ref.style, seed: ref.seed } };
65
+ }
66
+
67
+ // A place is {source, project, lastSeen}. It never carries a session id: a
68
+ // session id would tell a reader which session of a project an agent ran in,
69
+ // which the project-level read decision does not cover. A stored place from an
70
+ // earlier file that has a session field is read without it.
71
+ function placeFromStored(raw) {
72
+ if (!raw || typeof raw !== "object" || SOURCES.indexOf(raw.source) === -1) return null;
73
+ var lastSeen = typeof raw.lastSeen === "number" ? raw.lastSeen : null;
74
+ if (lastSeen === null) return null;
75
+ return { source: raw.source, project: fieldOf(raw.project), lastSeen: lastSeen };
76
+ }
77
+
78
+ // Dropping the session can leave two stored places identical; keep the newest.
79
+ function mergePlaces(places) {
80
+ var byKey = new Map();
81
+ places.forEach(function (p) {
82
+ var k = p.source + "\u0000" + (p.project === null ? "" : "p" + p.project);
83
+ var held = byKey.get(k);
84
+ if (!held || p.lastSeen > held.lastSeen) byKey.set(k, p);
85
+ });
86
+ return Array.from(byKey.values());
87
+ }
88
+
89
+ function entryFromStored(raw) {
90
+ if (!raw || !isUsableKey(raw.key) || typeof raw.firstSeen !== "number" || typeof raw.lastSeen !== "number") return null;
91
+ var avatar = validateAvatar(raw.avatar);
92
+ var places = Array.isArray(raw.places) ? mergePlaces(raw.places.map(placeFromStored).filter(Boolean)).slice(0, MAX_PLACES) : [];
93
+ return { key: raw.key, firstSeen: raw.firstSeen, lastSeen: raw.lastSeen, places: places, avatar: avatar.ok ? avatar.avatar : null };
94
+ }
95
+
96
+ // The roster key of an injected sender, from the fields lib/injected-sender.js
97
+ // records. An extracted sender is keyed by its agent name: its fromName is the
98
+ // "<agent or vendor>@<project>" label and names no agent by itself. A declared
99
+ // sender is keyed by the name it gave. Every other kind (undeclared, the
100
+ // console's own automations, unrecorded) names no agent and has no key.
101
+ // lib/public/modules/agent-avatar.js (senderAgentKey) applies the same rule in
102
+ // the browser; test/agent-roster.test.js holds the two together.
103
+ function senderKey(sender) {
104
+ if (!sender) return null;
105
+ if (sender.senderKind === "extracted") return sender.senderAgent || sender.fromName || null;
106
+ if (sender.senderKind === "declared") return sender.fromName || null;
107
+ return null;
108
+ }
109
+
110
+ // The reply to a key the caller cannot see. It is the one reply for a key never
111
+ // seen and a key seen only where the caller cannot read, so no reply tells the
112
+ // two apart.
113
+ var NOT_SEEN = "that agent has not been seen";
114
+
115
+ function loadFile(file) {
116
+ var raw;
117
+ try {
118
+ raw = fs.readFileSync(file, "utf8");
119
+ } catch (e) {
120
+ if (e && e.code !== "ENOENT") console.error("[agent-roster] could not read " + file + ":", e.message);
121
+ return [];
122
+ }
123
+ var parsed;
124
+ try {
125
+ parsed = JSON.parse(raw);
126
+ } catch (e) {
127
+ console.error("[agent-roster] " + file + " is not valid JSON; starting with an empty roster:", e.message);
128
+ return [];
129
+ }
130
+ var stored = parsed && Array.isArray(parsed.agents) ? parsed.agents : [];
131
+ return stored.map(entryFromStored).filter(Boolean).slice(0, MAX_AGENTS);
132
+ }
133
+
134
+ function copyEntry(entry) {
135
+ return {
136
+ key: entry.key,
137
+ firstSeen: entry.firstSeen,
138
+ lastSeen: entry.lastSeen,
139
+ places: entry.places.map(function (p) { return { source: p.source, project: p.project, lastSeen: p.lastSeen }; }),
140
+ avatar: entry.avatar ? Object.assign({}, entry.avatar) : null,
141
+ };
142
+ }
143
+
144
+ // deps: {
145
+ // file absolute path of the roster file
146
+ // writeJson(file, obj) returns a promise (lib/store.js writeJsonAt)
147
+ // clock() ms since epoch; defaults to Date.now
148
+ // onChange() called after the roster or an avatar changed
149
+ // mayReadProject(slug, caller) true when the caller may read that project
150
+ // (slug is null for a sighting that named none). Absent,
151
+ // no caller may read anything.
152
+ // }
153
+ function createAgentRoster(deps) {
154
+ var clock = typeof deps.clock === "function" ? deps.clock : Date.now;
155
+ var agents = new Map();
156
+ loadFile(deps.file).forEach(function (entry) { agents.set(entry.key, entry); });
157
+
158
+ var timer = null;
159
+ var lastWrite = Promise.resolve();
160
+ var fullLogged = false;
161
+
162
+ function changed() {
163
+ if (typeof deps.onChange !== "function") return;
164
+ try { deps.onChange(); }
165
+ catch (e) { console.error("[agent-roster] change hook failed:", e && e.message ? e.message : e); }
166
+ }
167
+
168
+ function persistNow() {
169
+ if (timer) { clearTimeout(timer); timer = null; }
170
+ var body = { version: FILE_VERSION, agents: list() };
171
+ lastWrite = Promise.resolve(deps.writeJson(deps.file, body)).catch(function (e) {
172
+ console.error("[agent-roster] could not write " + deps.file + ":", e && e.message ? e.message : e);
173
+ });
174
+ return lastWrite;
175
+ }
176
+
177
+ // Sightings repeat on every Task call; the file is written once per burst.
178
+ function persistSoon() {
179
+ if (timer) return;
180
+ timer = setTimeout(persistNow, PERSIST_DELAY_MS);
181
+ if (typeof timer.unref === "function") timer.unref();
182
+ }
183
+
184
+ // Every stored entry, unfiltered. For persistence only: nothing that answers
185
+ // a caller may use it.
186
+ function list() {
187
+ return Array.from(agents.values())
188
+ .sort(function (a, b) { return b.lastSeen - a.lastSeen || (a.key < b.key ? -1 : a.key > b.key ? 1 : 0); })
189
+ .map(copyEntry);
190
+ }
191
+
192
+ // THE access decision. The one place the roster asks whether a caller may
193
+ // read a project. Returns a copy of the entry limited to the places the caller
194
+ // may read, or null when the key is unknown or has no such place. An agent's
195
+ // existence would say where it was seen, so "unknown" and "not yours" are the
196
+ // same answer. Avatar references name no project.
197
+ function visibleEntry(caller, key) {
198
+ var entry = typeof key === "string" ? agents.get(key) : null;
199
+ if (!entry || typeof deps.mayReadProject !== "function") return null;
200
+ var places = entry.places.filter(function (p) { return deps.mayReadProject(p.project, caller) === true; });
201
+ if (places.length === 0) return null;
202
+ return Object.assign(copyEntry(entry), { places: places.map(function (p) { return Object.assign({}, p); }) });
203
+ }
204
+
205
+ // The roster as one caller may see it, most recently seen first.
206
+ function listFor(caller) {
207
+ var out = [];
208
+ list().forEach(function (e) {
209
+ var visible = visibleEntry(caller, e.key);
210
+ if (visible) out.push(visible);
211
+ });
212
+ return out;
213
+ }
214
+
215
+ function recordPlace(entry, sighting, now) {
216
+ var project = fieldOf(sighting.project);
217
+ var found = null;
218
+ for (var i = 0; i < entry.places.length; i++) {
219
+ var p = entry.places[i];
220
+ if (p.source === sighting.source && p.project === project) { found = p; break; }
221
+ }
222
+ if (found) {
223
+ found.lastSeen = now;
224
+ return;
225
+ }
226
+ entry.places.push({ source: sighting.source, project: project, lastSeen: now });
227
+ if (entry.places.length > MAX_PLACES) {
228
+ entry.places.sort(function (a, b) { return b.lastSeen - a.lastSeen; });
229
+ entry.places.length = MAX_PLACES;
230
+ }
231
+ }
232
+
233
+ // sighting: { key, source, project? }. Returns true when recorded.
234
+ function observe(sighting) {
235
+ try {
236
+ if (!sighting || !isUsableKey(sighting.key) || SOURCES.indexOf(sighting.source) === -1) return false;
237
+ var now = clock();
238
+ var entry = agents.get(sighting.key);
239
+ if (!entry) {
240
+ if (agents.size >= MAX_AGENTS) {
241
+ if (!fullLogged) {
242
+ fullLogged = true;
243
+ console.warn("[agent-roster] roster holds " + MAX_AGENTS + " agents; new identities are not recorded");
244
+ }
245
+ return false;
246
+ }
247
+ entry = { key: sighting.key, firstSeen: now, lastSeen: now, places: [], avatar: null };
248
+ agents.set(entry.key, entry);
249
+ }
250
+ entry.lastSeen = now;
251
+ recordPlace(entry, sighting, now);
252
+ persistSoon();
253
+ changed();
254
+ return true;
255
+ } catch (e) {
256
+ console.error("[agent-roster] could not record a sighting:", e && e.message ? e.message : e);
257
+ return false;
258
+ }
259
+ }
260
+
261
+ // Returns { ok: true, agent } or { ok: false, error }. A key the caller cannot
262
+ // see (never seen, or seen only where the caller cannot read) gets the same
263
+ // reply, and nothing changes. The reply carries the caller's own view.
264
+ function setAvatar(caller, key, ref) {
265
+ if (!visibleEntry(caller, key)) return { ok: false, error: NOT_SEEN };
266
+ var checked = validateAvatar(ref);
267
+ if (!checked.ok) return checked;
268
+ var entry = agents.get(key);
269
+ entry.avatar = checked.avatar;
270
+ persistNow();
271
+ changed();
272
+ return { ok: true, agent: visibleEntry(caller, key) };
273
+ }
274
+
275
+ // The custom-icon store renamed a slug: choices that named it follow it.
276
+ function renameCustomIcon(oldSlug, newSlug) {
277
+ var moved = 0;
278
+ agents.forEach(function (entry) {
279
+ if (entry.avatar && entry.avatar.custom === oldSlug) {
280
+ entry.avatar = { custom: newSlug };
281
+ moved++;
282
+ }
283
+ });
284
+ if (moved > 0) {
285
+ persistNow();
286
+ changed();
287
+ }
288
+ return moved;
289
+ }
290
+
291
+ // Resolves once everything recorded so far is on disk.
292
+ function flush() {
293
+ if (timer) return persistNow();
294
+ return lastWrite;
295
+ }
296
+
297
+ return {
298
+ observe: observe, visibleEntry: visibleEntry, listFor: listFor, setAvatar: setAvatar,
299
+ renameCustomIcon: renameCustomIcon, list: list, flush: flush,
300
+ };
301
+ }
302
+
303
+ module.exports = {
304
+ createAgentRoster: createAgentRoster,
305
+ validateAvatar: validateAvatar,
306
+ senderKey: senderKey,
307
+ NOT_SEEN: NOT_SEEN,
308
+ SOURCE: SOURCE,
309
+ MAX_AGENTS: MAX_AGENTS,
310
+ MAX_PLACES: MAX_PLACES,
311
+ MAX_KEY_LENGTH: MAX_KEY_LENGTH,
312
+ };
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+
3
+ // The one place a "sign-in needed" notification is raised. The bridge and the
4
+ // message processor both detect the condition; neither owns a tag, a dedupe or
5
+ // a route: the core collapses a repeat for a session into one notification and
6
+ // the shared router opens the session.
7
+
8
+ var { notifyFor } = require("./notify");
9
+
10
+ var AUTH_BODY = "Open a terminal, then click the URL and follow the instructions.";
11
+
12
+ /**
13
+ * @param {?object} pushModule the push module.
14
+ * @param {?object} notifications the in-app banner store.
15
+ * @param {object} f
16
+ * @param {string} f.slug the project.
17
+ * @param {{localId: (number|string), ownerId: ?string}} f.session
18
+ * @param {string} f.title
19
+ * @param {string} f.vendor the agent that needs the sign-in.
20
+ * @param {string} f.loginCommand
21
+ * @param {?string} f.linuxUser
22
+ * @param {boolean} f.canAutoLogin
23
+ * @returns {?object} what the core delivered, or null when nothing was.
24
+ */
25
+ function notifyAuthRequired(pushModule, notifications, f) {
26
+ return notifyFor(pushModule, notifications).notify("auth_required", {
27
+ slug: f.slug,
28
+ sessionId: f.session.localId,
29
+ }, {
30
+ push: { title: f.title, body: AUTH_BODY },
31
+ banner: {
32
+ title: f.title,
33
+ body: AUTH_BODY,
34
+ vendor: f.vendor,
35
+ loginCommand: f.loginCommand,
36
+ linuxUser: f.linuxUser,
37
+ canAutoLogin: f.canAutoLogin,
38
+ },
39
+ }, { ownerId: f.session.ownerId || null });
40
+ }
41
+
42
+ module.exports = { notifyAuthRequired: notifyAuthRequired };
@@ -1,4 +1,4 @@
1
1
  {
2
- "sha": "539865735f50f10bc98a10405ad939dd97d47b75",
3
- "writtenAt": "2026-11-07T22:06:56.438Z"
2
+ "sha": "c4b5f54829f8c5179fff4b23e713a9ac46f59c33",
3
+ "writtenAt": "2026-11-11T15:20:10.109Z"
4
4
  }
@@ -0,0 +1,45 @@
1
+ "use strict";
2
+
3
+ // Raises and withdraws the build-update offer through the notification core.
4
+ // The offer is one notification for the console itself (no project, no
5
+ // session): the core collapses every repeat (the standing reconcile, a
6
+ // broadcast, a re-emit) into the one shown on each surface, and resolve closes
7
+ // it on the phone and in every open page.
8
+
9
+ var { notifyFor } = require("./notify");
10
+
11
+ var TYPE = "build_update_offer";
12
+ var CONSOLE_TARGET = { slug: null, sessionId: null };
13
+
14
+ /**
15
+ * @param {object} message the composed offer (build-update-offer.composeNotice).
16
+ */
17
+ function offerContent(message) {
18
+ return { title: "A newer build is installed", body: message.message };
19
+ }
20
+
21
+ /**
22
+ * @param {{push: ?object, inApp: ?object, isMultiUser: ?function, listAdmins: ?function}} env
23
+ * @param {object} message the composed offer.
24
+ */
25
+ function showBuildOffer(env, message) {
26
+ var text = offerContent(message);
27
+ return notifyFor(env.push, env.inApp).notify(TYPE, CONSOLE_TARGET, {
28
+ push: text,
29
+ banner: Object.assign({}, text, {
30
+ message: message.message,
31
+ buildUpdate: message.buildUpdate,
32
+ actionable: message.actionable,
33
+ }),
34
+ }, { isMultiUser: env.isMultiUser, listAdmins: env.listAdmins });
35
+ }
36
+
37
+ /** The build was adopted or the offer declined: close it everywhere. */
38
+ function resolveBuildOffer(env) {
39
+ return notifyFor(env.push, env.inApp).resolve(CONSOLE_TARGET, {
40
+ isMultiUser: env.isMultiUser,
41
+ listAdmins: env.listAdmins,
42
+ }, { type: TYPE });
43
+ }
44
+
45
+ module.exports = { showBuildOffer: showBuildOffer, resolveBuildOffer: resolveBuildOffer, TYPE: TYPE };
@@ -149,7 +149,7 @@ function summarizeOffer(a) {
149
149
  var DEFAULT_NOTICE_COOLDOWN_MS = 60 * 60 * 1000;
150
150
 
151
151
  /**
152
- * How long a client keeps a closed build-update notice quiet. `raw` is the
152
+ * How long a declined build-update offer stays quiet. `raw` is the
153
153
  * CLAGENTIC_CONSOLE_BUILD_NOTICE_COOLDOWN_MS value; unset, empty or invalid
154
154
  * (not a non-negative number) falls back to the default. 0 disables the quiet period.
155
155
  */
@@ -159,8 +159,8 @@ function noticeCooldownFrom(raw) {
159
159
  return isFinite(n) && n >= 0 ? n : DEFAULT_NOTICE_COOLDOWN_MS;
160
160
  }
161
161
 
162
- /** The standing diagnostic every client is sent for a stale build. */
163
- function composeNotice(assessment, changes, cooldownMs) {
162
+ /** The standing offer, as the page builds its diagnostics entry from it. */
163
+ function composeNotice(assessment, changes) {
164
164
  return {
165
165
  type: 'diagnostic',
166
166
  severity: 'warning',
@@ -168,7 +168,6 @@ function composeNotice(assessment, changes, cooldownMs) {
168
168
  message: summarizeOffer(assessment) + ' Restart to apply it when it suits you; nothing restarts on its own.',
169
169
  buildUpdate: buildOffer({ assessment: assessment, changes: changes }),
170
170
  actionable: { label: 'Restart to apply update', action: 'restart_for_build_update' },
171
- noticeCooldownMs: cooldownMs,
172
171
  };
173
172
  }
174
173
 
@@ -14,7 +14,10 @@
14
14
  // place when a read succeeds. A slow, failed or throwing read never removes or
15
15
  // withholds the restart action.
16
16
  //
17
- // It broadcasts; it never restarts anything (that is
17
+ // It raises and withdraws the offer through the notification core (the caller's
18
+ // show and retract); the core collapses a repeat into the one offer on every
19
+ // surface, so what is kept here is only what was last asked for, to know when
20
+ // the state changed. It never restarts anything (that is
18
21
  // lib/build-update-restart.js, on a confirmed click).
19
22
 
20
23
  var SOURCE = 'build-update';
@@ -44,7 +47,10 @@ function readKeyOf(a) {
44
47
  * @param {object} o
45
48
  * @param {function(object): Promise<object>} o.listChanges — ({fromSha, toSha}) -> changes
46
49
  * @param {function(object, object): object} o.compose — (assessment, changes) -> diagnostic message
47
- * @param {function(object): void} o.broadcast — sends a message to every connected client
50
+ * @param {function(object, {refresh: boolean}): void} o.show — raises the offer (the
51
+ * composed message); refresh: true when the same build's offer is updated in place
52
+ * @param {function(): void} o.retract — withdraws the offer everywhere
53
+ * @param {number} [o.quietMs] — how long a declined offer stays quiet; 0 disables
48
54
  * @param {function(): ?object} o.desired — the CURRENT desired assessment (confirmed stale) or null
49
55
  * @param {number} [o.retryAfterMs] — minimum time between retries of a failed read
50
56
  * @param {function(): number} [o.now]
@@ -54,10 +60,14 @@ function createStandingOffer(o) {
54
60
  var log = typeof o.log === 'function' ? o.log : function () {};
55
61
  var now = typeof o.now === 'function' ? o.now : Date.now;
56
62
  var retryAfterMs = o.retryAfterMs >= 0 ? o.retryAfterMs : 30 * 60 * 1000;
63
+ var quietMs = o.quietMs >= 0 ? o.quietMs : 0;
57
64
 
58
65
  // What clients were last shown: {offerKey, changeListStatus, message}, set only
59
66
  // after the broadcast succeeded.
60
67
  var shown = null;
68
+ // The offer the operator declined and when: it is not raised again until
69
+ // quietMs has passed or the offer changes.
70
+ var declined = null;
61
71
  // readKey -> {status, changes, reason, failedAt, inFlight}
62
72
  var reads = {};
63
73
 
@@ -111,7 +121,7 @@ function createStandingOffer(o) {
111
121
  }
112
122
 
113
123
  function retract() {
114
- o.broadcast({ type: 'diagnostic_retract', source: SOURCE });
124
+ o.retract();
115
125
  shown = null;
116
126
  }
117
127
 
@@ -123,11 +133,19 @@ function createStandingOffer(o) {
123
133
 
124
134
  function reconcileUnsafe(desired) {
125
135
  if (!desired) {
136
+ declined = null;
126
137
  if (shown !== null) retract();
127
138
  prune(null);
128
139
  return;
129
140
  }
130
141
  var offerKey = offerKeyOf(desired);
142
+ if (declined !== null) {
143
+ if (declined.offerKey === offerKey && now() - declined.at < quietMs) {
144
+ prune(null);
145
+ return;
146
+ }
147
+ declined = null;
148
+ }
131
149
  var readKey = readKeyOf(desired);
132
150
  var entry = reads[readKey];
133
151
  if (!entry) {
@@ -144,14 +162,11 @@ function createStandingOffer(o) {
144
162
  }
145
163
 
146
164
  var message = o.compose(desired, changesFor(entry));
147
- // A different build replaces the offer; the same build is refreshed in place
148
- // (never retracted first, so the restart action does not flicker).
165
+ // A different build replaces the offer and the same build is refreshed: the
166
+ // core collapses either into the single offer, so the restart action is
167
+ // never retracted first (it would flicker).
149
168
  var refresh = shown !== null && shown.offerKey === summary.offerKey;
150
- if (shown !== null && !refresh) retract();
151
- // The stored copy, replayed to a client that connects later, is a plain
152
- // diagnostic; `refresh` tells a client already holding the entry to update it
153
- // and not to bring back one the operator dismissed.
154
- o.broadcast(refresh ? Object.assign({}, message, { refresh: true }) : message);
169
+ o.show(message, { refresh: refresh });
155
170
  shown = { offerKey: summary.offerKey, changeListStatus: summary.changeListStatus, message: message };
156
171
  prune(readKey);
157
172
  }
@@ -172,11 +187,16 @@ function createStandingOffer(o) {
172
187
 
173
188
  return {
174
189
  reconcile: reconcile,
175
- /** What a client that connects now should be shown, or null when no offer stands. */
190
+ /** The offer last raised, or null when none stands. */
176
191
  current: function () { return shown === null ? null : shown.message; },
177
- /** The state to send a client on connect: the held offer, or an explicit "no offer". */
178
- forNewClient: function () {
179
- return shown === null ? { type: 'diagnostic_retract', source: SOURCE } : shown.message;
192
+ /**
193
+ * The operator closed the offer on some client: it stays quiet for the
194
+ * quiet period, then comes back if the build is still stale.
195
+ */
196
+ declined: function () {
197
+ if (shown === null) return;
198
+ declined = { offerKey: shown.offerKey, at: now() };
199
+ shown = null;
180
200
  },
181
201
  };
182
202
  }