@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
@@ -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/README.md CHANGED
@@ -24,6 +24,7 @@ Agents do not need a browser. From a shell, or from inside a console session, an
24
24
  - **Message sessions:** `clagentic-console send-input --to builder@my-project --prompt "The build passed."` The input is pushed into the session, which is resumed first if it was reaped.
25
25
  - **Reply:** `clagentic-console send-input --reply --prompt "Done."` answers whoever last messaged the calling session.
26
26
  - **List sessions:** `clagentic-console list-sessions --state live` shows each session's state and any prompts it is waiting on.
27
+ - **List what a session sent:** `clagentic-console list-outbound --session 4f1c9d2e-7a3b-4c55-9e0a-1b2c3d4e5f60 --since 2h` shows the calls that session (named by its vendor session id, from `list-sessions`) made with `send-input` and `open-session`: target, prompt, time and initiator. The daemon keeps them for 30 days by default (`outboundRetentionDays` in `daemon.json`; `0` stops recording and deletes existing entries). Prompt text goes to the daemon's OS user for every session that runs as it; a session that runs as another OS user (os-users mode) is listed without its text, because that text is never stored. See the [agent guide](docs/guides/AGENT-GUIDE.md#list-outbound).
27
28
  - **Schedule input:** `clagentic-console schedule-input create --session 12 --project my-project --every 30m --count 4 --prompt "Check the build."` sends text into a session later, once or on a repeat that always has an end. People do the same from the clock button next to the message box.
28
29
 
29
30
  Every injected message records who sent it, and an agent's message is never recorded as a human's. See the [agents guide](docs/guides/AGENT-GUIDE.md) for every verb and flag.
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`: 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,9 +198,12 @@ 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)");
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)");
204
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)");
205
208
  console.log(" clagentic-console schedule-input list [--session <id>] [--project <slug>] [--state armed|done|ended|any] List scheduled input, from the browser or the CLI (prints JSON)");
206
209
  console.log(" clagentic-console schedule-input delete --id <id> [--project <slug>] Cancel a scheduled input");
@@ -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 };
@@ -16,6 +16,12 @@ var DEFAULT_LIMIT = 30;
16
16
  var SUBJECT_MAX = 200;
17
17
  var GIT_TIMEOUT_MS = 5000;
18
18
 
19
+ // An install made from a packed tarball (npm install -g, including the
20
+ // install:local-test script) carries no .git directory, so the package
21
+ // directory cannot answer; only buildSourceRepo in daemon.json can.
22
+ var NO_REPO_REASON = 'this install carries no git history (it was installed from a package, not a checkout); ' +
23
+ 'set buildSourceRepo in daemon.json to the checkout it was built from to list the changes';
24
+
19
25
  /** The repository to read history from, or null when there is none to try. */
20
26
  function resolveHistoryRepo(configured, packageRoot) {
21
27
  if (typeof configured === 'string' && path.isAbsolute(configured)) return configured;
@@ -47,7 +53,7 @@ function listBuildChanges(o) {
47
53
  function unavailable(reason) {
48
54
  return { available: false, commits: [], truncated: false, reason: reason };
49
55
  }
50
- if (!o.repo) return Promise.resolve(unavailable('no git history is available for this install'));
56
+ if (!o.repo) return Promise.resolve(unavailable(NO_REPO_REASON));
51
57
  // Only hex revisions reach git, so a value can never be read as an option.
52
58
  if (!SHA_RE.test(String(o.fromSha)) || !SHA_RE.test(String(o.toSha))) {
53
59
  return Promise.resolve(unavailable('a build sha is not a git revision'));
@@ -76,4 +82,4 @@ function listBuildChanges(o) {
76
82
  });
77
83
  }
78
84
 
79
- module.exports = { listBuildChanges: listBuildChanges, resolveHistoryRepo: resolveHistoryRepo, DEFAULT_LIMIT: DEFAULT_LIMIT };
85
+ module.exports = { listBuildChanges: listBuildChanges, resolveHistoryRepo: resolveHistoryRepo, DEFAULT_LIMIT: DEFAULT_LIMIT, NO_REPO_REASON: NO_REPO_REASON };
@@ -1,4 +1,4 @@
1
1
  {
2
- "sha": "5f4c7d6096bab03fe3f9cedac6ea45d9f59c872e",
3
- "writtenAt": "2026-11-04T21:44:36.944Z"
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 };