@songsid/agend 2.4.0-beta.20 → 2.4.0-beta.21

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 (176) hide show
  1. package/dist/agent-cli-instructions.md +1 -1
  2. package/dist/backend/claude-carry.d.ts +11 -0
  3. package/dist/backend/claude-carry.js +88 -6
  4. package/dist/backend/claude-carry.js.map +1 -1
  5. package/dist/build-provenance.json +1 -1
  6. package/dist/channel/mcp-tools.js +6 -4
  7. package/dist/channel/mcp-tools.js.map +1 -1
  8. package/dist/contact-change-proposals.d.ts +47 -0
  9. package/dist/contact-change-proposals.js +131 -0
  10. package/dist/contact-change-proposals.js.map +1 -0
  11. package/dist/fleet-manager.d.ts +25 -1
  12. package/dist/fleet-manager.js +166 -3
  13. package/dist/fleet-manager.js.map +1 -1
  14. package/dist/general-knowledge/skills/concepts/SKILL.md +2 -1
  15. package/dist/general-knowledge/skills/hub/SKILL.md +39 -2
  16. package/dist/general-knowledge/skills/task-board/SKILL.md +4 -0
  17. package/dist/general-knowledge/skills/web-appearance/SKILL.md +1 -1
  18. package/dist/general-knowledge/skills/web-dashboard/SKILL.md +16 -6
  19. package/dist/hub/agent-pictures-model.d.ts +147 -0
  20. package/dist/hub/agent-pictures-model.js +64 -0
  21. package/dist/hub/agent-pictures-model.js.map +1 -0
  22. package/dist/hub/agent-pictures.d.ts +52 -0
  23. package/dist/hub/agent-pictures.js +202 -0
  24. package/dist/hub/agent-pictures.js.map +1 -0
  25. package/dist/hub/client.d.ts +2 -0
  26. package/dist/hub/client.js +16 -2
  27. package/dist/hub/client.js.map +1 -1
  28. package/dist/hub/compose/member.d.ts +10 -2
  29. package/dist/hub/compose/member.js +32 -8
  30. package/dist/hub/compose/member.js.map +1 -1
  31. package/dist/hub/compose/server.d.ts +1 -0
  32. package/dist/hub/compose/server.js +4 -2
  33. package/dist/hub/compose/server.js.map +1 -1
  34. package/dist/hub/direct-posts-model.d.ts +1 -0
  35. package/dist/hub/direct-posts-model.js +2 -0
  36. package/dist/hub/direct-posts-model.js.map +1 -0
  37. package/dist/hub/direct-posts.d.ts +36 -0
  38. package/dist/hub/direct-posts.js +145 -0
  39. package/dist/hub/direct-posts.js.map +1 -0
  40. package/dist/hub/http/compose.d.ts +2 -0
  41. package/dist/hub/http/compose.js +155 -19
  42. package/dist/hub/http/compose.js.map +1 -1
  43. package/dist/hub/http/core.d.ts +9 -1
  44. package/dist/hub/http/core.js +21 -1
  45. package/dist/hub/http/core.js.map +1 -1
  46. package/dist/hub/http/schema.js +6 -0
  47. package/dist/hub/http/schema.js.map +1 -1
  48. package/dist/hub/join/service.d.ts +2 -0
  49. package/dist/hub/join/service.js +7 -3
  50. package/dist/hub/join/service.js.map +1 -1
  51. package/dist/hub/mcp/policy.d.ts +1 -1
  52. package/dist/hub/member/agent-pictures.d.ts +43 -0
  53. package/dist/hub/member/agent-pictures.js +125 -0
  54. package/dist/hub/member/agent-pictures.js.map +1 -0
  55. package/dist/hub/member/direct-rooms.d.ts +9 -0
  56. package/dist/hub/member/direct-rooms.js +14 -0
  57. package/dist/hub/member/direct-rooms.js.map +1 -0
  58. package/dist/hub/member/room-post.d.ts +11 -10
  59. package/dist/hub/member/room-post.js +51 -7
  60. package/dist/hub/member/room-post.js.map +1 -1
  61. package/dist/hub/policy.d.ts +11 -2
  62. package/dist/hub/policy.js +60 -7
  63. package/dist/hub/policy.js.map +1 -1
  64. package/dist/hub/protocol.d.ts +123 -1
  65. package/dist/hub/protocol.js +17 -7
  66. package/dist/hub/protocol.js.map +1 -1
  67. package/dist/hub/representative.d.ts +28 -0
  68. package/dist/hub/representative.js +127 -12
  69. package/dist/hub/representative.js.map +1 -1
  70. package/dist/hub/rooms/agents.d.ts +2 -0
  71. package/dist/hub/rooms/agents.js +14 -3
  72. package/dist/hub/rooms/agents.js.map +1 -1
  73. package/dist/hub/rooms/direct-view.d.ts +3 -2
  74. package/dist/hub/rooms/direct-view.js +23 -8
  75. package/dist/hub/rooms/direct-view.js.map +1 -1
  76. package/dist/hub/rooms/office.d.ts +9 -0
  77. package/dist/hub/rooms/office.js +10 -2
  78. package/dist/hub/rooms/office.js.map +1 -1
  79. package/dist/hub/rooms/service.d.ts +32 -1
  80. package/dist/hub/rooms/service.js +37 -3
  81. package/dist/hub/rooms/service.js.map +1 -1
  82. package/dist/hub/rooms/types.d.ts +5 -2
  83. package/dist/hub/rooms.d.ts +9 -0
  84. package/dist/hub/rooms.js +97 -26
  85. package/dist/hub/rooms.js.map +1 -1
  86. package/dist/hub/runtime.d.ts +1 -1
  87. package/dist/hub/server.js +19 -2
  88. package/dist/hub/server.js.map +1 -1
  89. package/dist/hub/session-directory-transition.d.ts +1 -0
  90. package/dist/hub/session-directory-transition.js +15 -9
  91. package/dist/hub/session-directory-transition.js.map +1 -1
  92. package/dist/hub/session-limits.d.ts +58 -0
  93. package/dist/hub/session-limits.js +121 -0
  94. package/dist/hub/session-limits.js.map +1 -0
  95. package/dist/hub/sessions.d.ts +1 -1
  96. package/dist/hub/sessions.js +13 -7
  97. package/dist/hub/sessions.js.map +1 -1
  98. package/dist/hub/settings-directory-decision.js +1 -1
  99. package/dist/hub/settings-directory-decision.js.map +1 -1
  100. package/dist/hub/types.d.ts +8 -2
  101. package/dist/hub-picture-reduce.d.ts +14 -0
  102. package/dist/hub-picture-reduce.js +49 -0
  103. package/dist/hub-picture-reduce.js.map +1 -0
  104. package/dist/hub-picture-worker.d.ts +1 -0
  105. package/dist/hub-picture-worker.js +11 -0
  106. package/dist/hub-picture-worker.js.map +1 -0
  107. package/dist/hub-report-target.d.ts +6 -0
  108. package/dist/hub-report-target.js +6 -0
  109. package/dist/hub-report-target.js.map +1 -1
  110. package/dist/locale.js +90 -2
  111. package/dist/locale.js.map +1 -1
  112. package/dist/needs-you.d.ts +4 -0
  113. package/dist/needs-you.js +2 -0
  114. package/dist/needs-you.js.map +1 -1
  115. package/dist/outbound-handlers.d.ts +4 -0
  116. package/dist/outbound-handlers.js +37 -4
  117. package/dist/outbound-handlers.js.map +1 -1
  118. package/dist/outbound-schemas.d.ts +2 -0
  119. package/dist/outbound-schemas.js +6 -4
  120. package/dist/outbound-schemas.js.map +1 -1
  121. package/dist/task-board-tool.d.ts +17 -0
  122. package/dist/task-board-tool.js +58 -6
  123. package/dist/task-board-tool.js.map +1 -1
  124. package/dist/tool-permissions.js +2 -2
  125. package/dist/tool-permissions.js.map +1 -1
  126. package/dist/ui/contact-tool-groups.js +1 -1
  127. package/dist/ui/fleet-canvas.js +2 -1
  128. package/dist/ui/fleet-office-card.js +20 -5
  129. package/dist/ui/fleet-office-dialogue.d.ts +6 -3
  130. package/dist/ui/fleet-office-dialogue.js +13 -3
  131. package/dist/ui/fleet-office-layout.js +13 -13
  132. package/dist/ui/fleet-office-model.js +3 -2
  133. package/dist/ui/fleet-office-overview.js +1 -1
  134. package/dist/ui/fleet-office-pack.d.ts +17 -7
  135. package/dist/ui/fleet-office-pack.js +106 -38
  136. package/dist/ui/fleet-office-play.js +11 -4
  137. package/dist/ui/fleet-office-skin.js +25 -11
  138. package/dist/ui/fleet-office-store.js +10 -1
  139. package/dist/ui/fleet-office-talk.js +423 -0
  140. package/dist/ui/fleet-office-view.js +26 -17
  141. package/dist/ui/fleet-office-zones.js +20 -12
  142. package/dist/ui/fleet-office.js +173 -44
  143. package/dist/ui/fleet-task-common.js +1 -1
  144. package/dist/ui/fleet-task-sort.js +88 -0
  145. package/dist/ui/fleet-task-view.js +38 -9
  146. package/dist/ui/fleet-tasks.js +47 -15
  147. package/dist/ui/hub-chat-store.js +4 -3
  148. package/dist/ui/hub-chat-strings.js +2 -0
  149. package/dist/ui/hub-client.js +3 -0
  150. package/dist/ui/hub-my-agents-strings.js +2 -2
  151. package/dist/ui/hub-my-agents.js +3 -0
  152. package/dist/ui/hub-room-composer.js +24 -4
  153. package/dist/ui/hub-room-members.js +7 -3
  154. package/dist/ui/hub-room-office.js +2 -1
  155. package/dist/ui/hub-room-presence.js +9 -0
  156. package/dist/ui/hub-room-strings.js +18 -2
  157. package/dist/ui/hub-room-thread.js +82 -13
  158. package/dist/ui/hub-room-working.js +37 -0
  159. package/dist/ui/hub-session-limits.js +79 -0
  160. package/dist/ui/panel-hub.js +41 -6
  161. package/dist/ui/panel-needs.js +28 -2
  162. package/dist/ui/shared/app.css +84 -3
  163. package/dist/ui/shared/chat-strings.js +1 -1
  164. package/dist/ui/shared/hub-owner.css +5 -0
  165. package/dist/ui/shared/hub-rooms-u2.css +3 -0
  166. package/dist/ui/shared/office-dialogue.css +110 -0
  167. package/dist/ui/shared/task-board.css +103 -7
  168. package/dist/web-api.d.ts +5 -0
  169. package/dist/web-api.js +29 -0
  170. package/dist/web-api.js.map +1 -1
  171. package/dist/web-office-skins.d.ts +8 -2
  172. package/dist/web-office-skins.js +33 -14
  173. package/dist/web-office-skins.js.map +1 -1
  174. package/dist/web-office-store.js +5 -3
  175. package/dist/web-office-store.js.map +1 -1
  176. package/package.json +1 -1
@@ -9,6 +9,7 @@ import { HubPreviousAccess } from "../sharing-previous-access.js";
9
9
  import { HubAgentIntros } from "../agent-intro.js";
10
10
  import { HubSharingRequests } from "../sharing-requests.js";
11
11
  import { HubAgentCatalogs } from "../agent-catalog.js";
12
+ import { HubAgentPictures } from "../agent-pictures.js";
12
13
  import { hubAdminOverviewPermit } from "../roles/overview.js";
13
14
  import { HUB_ROOM_CONTEXT_CAPABILITY } from "../room-context-model.js";
14
15
  /**
@@ -28,6 +29,7 @@ import { HUB_ROOM_CONTEXT_CAPABILITY } from "../room-context-model.js";
28
29
  */
29
30
  import { HubAdminDashboard } from "../admin-dashboard.js";
30
31
  import { HubVersionRecommendations, HubRecommendationRefusal } from "../recommendations.js";
32
+ import { HubSessionLimitSettings, HubSessionLimitRefusal } from "../session-limits.js";
31
33
  import { HubFleetUpdates, HubFleetUpdateRefusal } from "../fleet-updates.js";
32
34
  import { HubFleetVersions } from "../fleet-versions.js";
33
35
  import { HubGroupPolicyError } from "../group-policy/errors.js";
@@ -50,6 +52,7 @@ import { HubRoomAdmin } from "../rooms/admin.js";
50
52
  import { HubGroupRooms, HubRoomRefusal } from "../rooms/service.js";
51
53
  import { HUB_ROOM_OFFICE_FEATURE } from "../rooms/office.js";
52
54
  import { SHARE_MODULES } from "../../office-share-page.js";
55
+ import { HubDirectPosts, HUB_DIRECT_POST_CAPABILITY } from "../direct-posts.js";
53
56
  import { directMessages, directRoomView, directUnread, markDirectRead } from "../rooms/direct-view.js";
54
57
  import { HubAttachmentRefused } from "../attachments/store.js";
55
58
  import { HubQuotaService } from "../quota.js";
@@ -100,7 +103,9 @@ export const HUB_UI_MODULES = Object.freeze(["panel-hub.js", "hub-personal-agent
100
103
  // M-3137: Fleet versions (Connected fleets' columns and summary, the older-Fleet banner) with its own words.
101
104
  "hub-fleet-versions.js",
102
105
  // M-3162: Administration → Overview (the counts dashboard), its own words.
103
- "hub-admin-overview.js", "hub-ai-apps.js", "hub-ai-apps-strings.js", "hub-room-source.js", "hub-room-source-strings.js"]);
106
+ "hub-admin-overview.js", "hub-ai-apps.js", "hub-ai-apps-strings.js", "hub-room-source.js", "hub-room-source-strings.js",
107
+ // M-3592: Administration → Sign-in.
108
+ "hub-session-limits.js"]);
104
109
  const BODY_LIMIT = 96 * 1024;
105
110
  const UPLOADS_PER_SESSION = 2, UPLOADS_TOTAL = 8;
106
111
  const UUID = /^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/;
@@ -208,7 +213,8 @@ export function createHubHttp(deps, sql) {
208
213
  const personal = personalFactory?.(core);
209
214
  if (personal)
210
215
  Object.defineProperty(mountedDeps, "personal", { value: personal.turns });
211
- const sessions = new HubSessions(core), catalog = new HubCatalogService(core, publishSharingSettlement), policy = new HubPolicyService(core);
216
+ const sessionLimits = new HubSessionLimitSettings(core);
217
+ const sessions = new HubSessions(core), catalog = new HubCatalogService(core, publishSharingSettlement), policy = new HubPolicyService(core, deps.log);
212
218
  const grantSearch = new HubGrantSearch(core);
213
219
  const ownerIntro = (e) => {
214
220
  const value = intros.projection(e.id), report = e.fleetId ? agentCatalogs.reportOf(e.fleetId) : null;
@@ -217,6 +223,25 @@ export function createHubHttp(deps, sql) {
217
223
  };
218
224
  const rooms = new HubRoomsService(core, policy);
219
225
  const groupRooms = new HubGroupRooms(core, deps.roomOffice === true);
226
+ const directPosts = new HubDirectPosts(core, (roomId, asker, id) => {
227
+ if (id) {
228
+ groupRooms.publish({ type: "message.added", roomId, data: { roomId, messageId: id }, audiencePerson: asker });
229
+ groupRooms.publish({ type: "unread.changed", roomId, data: { roomId }, audiencePerson: asker });
230
+ }
231
+ else
232
+ groupRooms.publish({ type: "room.changed", roomId, data: { roomId }, audiencePerson: asker });
233
+ });
234
+ /**
235
+ * M-3596: a 1:1 room's agent as its asker sees it. The room's own presence (offline, paused, held) wins; on a current link
236
+ * the agent's reported state (agent.state: working, or paused with a reason) says whether it is busy right now.
237
+ */
238
+ const directPresence = (exposureId) => {
239
+ const own = rooms.presence(exposureId);
240
+ if (own !== "idle")
241
+ return own;
242
+ const reported = groupRooms.agents.presence(exposureId).presence;
243
+ return reported === "working" || reported === "paused" ? reported : own;
244
+ };
220
245
  const mcp = new HubMcpDoor(core, sessions, { groups: groupRooms, direct: rooms, catalog });
221
246
  const invitations = deps.roomInvitations?.(core, groupRooms.invitationHost());
222
247
  const roomAgentRequests = deps.roomAgentRequests?.(core, groupRooms.invitationHost());
@@ -226,11 +251,29 @@ export function createHubHttp(deps, sql) {
226
251
  const fleetVersions = new HubFleetVersions(core);
227
252
  const agentCatalogs = new HubAgentCatalogs(core);
228
253
  // M-3533 R2a: a room office draws each shared agent in its owner's colour and emoji, from the owner's catalog rows.
254
+ // M-3533 R2b: and its pictures (the sidebar's disc, the identity card's portrait) as its Fleet last reported them.
255
+ const agentPictures = new HubAgentPictures(core);
229
256
  groupRooms.looks = (fleetId) => {
230
- const report = agentCatalogs.reportOf(fleetId);
231
- if (!report)
257
+ const report = agentCatalogs.reportOf(fleetId), pictures = agentPictures.looksOf(fleetId);
258
+ if (!report && !pictures.size)
232
259
  return null;
233
- return new Map(report.catalog.agents.filter((a) => a.exposure && a.avatar).map((a) => [a.exposure.id, { color: a.avatar.color, emoji: a.avatar.emoji }]));
260
+ const out = new Map(report ? report.catalog.agents.filter((a) => a.exposure && a.avatar).map((a) => [a.exposure.id, { color: a.avatar.color, emoji: a.avatar.emoji }]) : []);
261
+ for (const [id, p] of pictures)
262
+ if (p.disc || p.portrait)
263
+ out.set(id, { ...(out.get(id) ?? { color: null, emoji: null }), ...(p.disc ? { disc: p.disc } : {}), ...(p.portrait ? { portrait: p.portrait } : {}) });
264
+ return out;
265
+ };
266
+ groupRooms.pictureFile = (sha256) => agentPictures.file(sha256);
267
+ agentPictures.changed = (ids) => { if (live())
268
+ groupRooms.lookChanged(ids); };
269
+ agentPictures.start();
270
+ /** The owner's own view: which of a Fleet's agents have a picture too large to show (My agents says so; nobody else sees it). */
271
+ const picturesTooLarge = (fleetId) => {
272
+ const out = Object.create(null);
273
+ for (const [id, p] of agentPictures.looksOf(fleetId))
274
+ if (p.tooLarge?.length)
275
+ out[id] = p.tooLarge;
276
+ return Object.keys(out).length ? out : null;
234
277
  };
235
278
  const previousAccess = new HubPreviousAccess(core, agentCatalogs);
236
279
  const sharingRequests = new HubSharingRequests(core, agentCatalogs, publishSharingSettlement);
@@ -387,7 +430,10 @@ export function createHubHttp(deps, sql) {
387
430
  if (query.size)
388
431
  throw new HubProtocolError("invalid");
389
432
  signedIn();
390
- return send(res, 200, await guard(() => agentCatalogs.view(ctx)));
433
+ return send(res, 200, await guard(async () => {
434
+ const view = await agentCatalogs.view(ctx);
435
+ return { ...view, fleets: view.fleets.map(f => { const tooLarge = picturesTooLarge(f.id); return tooLarge ? { ...f, picturesTooLarge: tooLarge } : f; }) };
436
+ }));
391
437
  }
392
438
  // Composed routes, not enrollment authority or the administrator's on/off switch. Older Hubs omit unsupported cards.
393
439
  const offered = ["agent-intro-defaults-v1", "agent-sharing-v1", "agent-intros-v1", "admin-dashboard-v1", "rooms-v1", "room-purpose-v1", "room-pins-v1", "person-prefs-v1", ...(roomAgentRequests ? ["room-owner-requests-v1"] : []), ...(roomDiscovery ? ["room-agent-discovery-v1"] : []), ...(personal ? ["personal-agents-v1"] : []), ...(teams ? ["teams-v1"] : []), ...(deps.roleAdmin ? ["role-settings-v1"] : []), ...(deps.roomAssistant && deps.assistantAdmin ? ["room-assistant-v1"] : []), ...(deps.refreshAuthorization ? ["sharing-pause-v1"] : []), ...(deps.groupHttp ? [GROUP_POLICY_FEATURE, ...(deps.pairingNotices ? ["quick-pairing-v1"] : [])] : []), ...(grantSubjectsOffered() ? ["grant-subjects-v1"] : []),
@@ -1115,7 +1161,7 @@ export function createHubHttp(deps, sql) {
1115
1161
  if (event.type === "unread.changed")
1116
1162
  data = { roomId: event.roomId, unread: directUnread(core, view) };
1117
1163
  else if (event.type === "room.changed")
1118
- data = { roomId: event.roomId, room: directRoomView(view, rooms.presence(view.exposureId), directUnread(core, view), intros.projection(view.exposureId)) };
1164
+ data = { roomId: event.roomId, room: directRoomView(view, directPresence(view.exposureId), directUnread(core, view), intros.projection(view.exposureId), groupRooms.agents.reported(view.exposureId)) };
1119
1165
  else {
1120
1166
  const page = await rooms.readPage(ctx, event.roomId, 0, streamSession.sessionId, { before: null, limit: 100 });
1121
1167
  const message = directMessages(page.room, page.entries, streamSession.displayName).find(m => m.id === event.data.messageId);
@@ -1196,7 +1242,7 @@ export function createHubHttp(deps, sql) {
1196
1242
  const groups = await guard(() => groupRooms.list(ctx));
1197
1243
  const pending = invitations ? await guard(() => invitations.pending(ctx)) : null;
1198
1244
  const ownerRequests = roomAgentRequests && query.get("ownerRequests") === "1" ? await guard(() => roomAgentRequests.pendingCount(ctx)) : 0;
1199
- return send(res, 200, { ...groups, invitations: (pending?.invitations.length ?? 0) + ownerRequests, rooms: [...groups.rooms, ...view.rooms.map(room => ({ ...directRoomView(room, rooms.presence(room.exposureId), directUnread(core, room), intros.projection(room.exposureId)), ...quota.roomProjection(room, view.grantProof) }))] });
1245
+ return send(res, 200, { ...groups, invitations: (pending?.invitations.length ?? 0) + ownerRequests, rooms: [...groups.rooms, ...view.rooms.map(room => ({ ...directRoomView(room, directPresence(room.exposureId), directUnread(core, room), intros.projection(room.exposureId), groupRooms.agents.reported(room.exposureId)), ...quota.roomProjection(room, view.grantProof) }))] });
1200
1246
  }
1201
1247
  if (method === "POST") {
1202
1248
  csrf();
@@ -1227,12 +1273,22 @@ export function createHubHttp(deps, sql) {
1227
1273
  return send(res, 200, await guard(() => groupRooms.patch(ctx, roomId, b)));
1228
1274
  }
1229
1275
  }
1276
+ else if (method === "PATCH") {
1277
+ csrf();
1278
+ const b = await body();
1279
+ if (Object.keys(b).length !== 1 || typeof b.directMessagesMuted !== "boolean")
1280
+ throw new HubProtocolError("invalid");
1281
+ const room = await guard(() => rooms.view(ctx, roomId));
1282
+ await ctx.current();
1283
+ directPosts.setMuted(roomId, personKeyString(room.asker), b.directMessagesMuted);
1284
+ return send(res, 200, { ok: true });
1285
+ }
1230
1286
  else if (method === "GET") {
1231
1287
  const room = await guard(() => rooms.view(ctx, roomId));
1232
1288
  const person = personKeyString(room.asker), name = signedIn().displayName;
1233
- return send(res, 200, { room: directRoomView(room, rooms.presence(room.exposureId), directUnread(core, room), intros.projection(room.exposureId)), me: { id: person, role: "member" },
1289
+ return send(res, 200, { room: directRoomView(room, directPresence(room.exposureId), directUnread(core, room), intros.projection(room.exposureId), groupRooms.agents.reported(room.exposureId)), me: { id: person, role: "member" },
1234
1290
  members: [{ id: person, kind: "person", name, role: "member", presence: "online" }, { id: room.exposureId, kind: "agent", name: room.exposureName,
1235
- ...(room.answerOnly ? { answerOnly: true } : {}), owner: { name: room.ownerName }, role: "member", presence: rooms.presence(room.exposureId), canAsk: room.state === "active" }],
1291
+ ...(room.answerOnly ? { answerOnly: true } : {}), owner: { name: room.ownerName }, role: "member", presence: directPresence(room.exposureId), canAsk: room.state === "active" }],
1236
1292
  settings: { allMention: false, historyForNew: "all" }, invited: [] });
1237
1293
  }
1238
1294
  throw new HttpError(405, "method");
@@ -1351,8 +1407,15 @@ export function createHubHttp(deps, sql) {
1351
1407
  csrf();
1352
1408
  const b = await body();
1353
1409
  const files = b.files === undefined ? [] : Array.isArray(b.files) && b.files.length <= 10 ? b.files.map(uuid) : (() => { throw new HubProtocolError("invalid"); })();
1354
- if (b.mentions !== undefined && (!Array.isArray(b.mentions) || b.mentions.length))
1410
+ if (b.mentions !== undefined && (!Array.isArray(b.mentions) || b.mentions.length > 64))
1355
1411
  throw new HubProtocolError("invalid");
1412
+ if (b.mentions?.length) {
1413
+ // M-3604: the shared room composer names the room's own agent when the text @-mentions it ("@Desk …"). In a 1:1
1414
+ // that agent is the only one, so the mention changes nothing: the question goes as written. Anything else stays refused.
1415
+ const own = (await guard(() => rooms.view(ctx, roomId))).exposureId;
1416
+ if (!b.mentions.every((x) => x === own || x === "all"))
1417
+ throw new HubProtocolError("invalid");
1418
+ }
1356
1419
  const receipt = await guard(() => rooms.ask(ctx, roomId, uuid(b.idempotencyKey), typeof b.text === "string" ? b.text : "", files));
1357
1420
  const room = await guard(() => rooms.view(ctx, roomId));
1358
1421
  groupRooms.publish({ type: "message.added", roomId, data: { roomId, messageId: receipt.messageId }, audiencePerson: personKeyString(room.asker) });
@@ -1405,6 +1468,19 @@ export function createHubHttp(deps, sql) {
1405
1468
  }
1406
1469
  }
1407
1470
  // `/inline` (a plain path, as the shared thread's renderer takes it) is the same as `?inline=1`: images only.
1471
+ // M-3533 R2b: a room agent's disc or portrait, for the room's members. `?v=` is the hash the room showed: kept while it matches.
1472
+ if ((r = m(/^\/hub\/v1\/rooms\/([^/]+)\/agents\/([^/]+)\/picture\/(disc|portrait)$/))) {
1473
+ if (method !== "GET")
1474
+ throw new HttpError(405, "method");
1475
+ const roomId = uuid(r[1]), exposureId = uuid(r[2]), slot = r[3];
1476
+ signedIn();
1477
+ const file = await guard(() => groupRooms.picture(ctx, roomId, exposureId, slot));
1478
+ res.writeHead(200, { "Content-Type": file.mime, "Content-Length": String(file.bytes.length), "X-Content-Type-Options": "nosniff",
1479
+ "Content-Security-Policy": "default-src 'none'; sandbox", "Cache-Control": query.get("v") === file.sha256 ? "private, max-age=86400" : "private, no-cache",
1480
+ ETag: `"${file.sha256}"`, "Referrer-Policy": "no-referrer", "Cross-Origin-Resource-Policy": "same-origin" });
1481
+ res.end(file.bytes);
1482
+ return;
1483
+ }
1408
1484
  if ((r = m(/^\/hub\/v1\/rooms\/([^/]+)\/files\/([^/]+)(\/inline)?$/))) {
1409
1485
  if (method !== "GET")
1410
1486
  throw new HttpError(405, "method");
@@ -1476,6 +1552,27 @@ export function createHubHttp(deps, sql) {
1476
1552
  }
1477
1553
  async function admin(req, res, path, ctx, method, signedIn, csrf, body, guard) {
1478
1554
  let r;
1555
+ // M-3592: how long a sign-in lasts (absolute and idle), the administrator's.
1556
+ if (path === "/hub/v1/admin/session-limits") {
1557
+ if ((req.url ?? "").includes("?"))
1558
+ throw new HubProtocolError("invalid");
1559
+ if (method !== "GET" && method !== "PUT")
1560
+ throw new HttpError(405, "method");
1561
+ try {
1562
+ if (method === "GET") {
1563
+ signedIn();
1564
+ return send(res, 200, await guard(() => sessionLimits.settings(ctx)));
1565
+ }
1566
+ csrf();
1567
+ const input = await body();
1568
+ return send(res, 200, await guard(() => sessionLimits.save(ctx, input)));
1569
+ }
1570
+ catch (error) {
1571
+ if (!(error instanceof HubSessionLimitRefusal))
1572
+ throw error;
1573
+ return send(res, error.status, { code: error.code });
1574
+ }
1575
+ }
1479
1576
  if (path === "/hub/v1/admin/recommended-version" || path === "/hub/v1/admin/recommended-version/preview") {
1480
1577
  try {
1481
1578
  if (path.endsWith("/preview")) {
@@ -1676,6 +1773,17 @@ export function createHubHttp(deps, sql) {
1676
1773
  return servePublicAsset(res, path.slice("/assets/".length));
1677
1774
  return false;
1678
1775
  }
1776
+ /** M-3533 R2b: a pictures exchange refused for the link's state answers so; a malformed or unnegotiated frame stays an error. */
1777
+ function pictureCall(fn) {
1778
+ try {
1779
+ return fn();
1780
+ }
1781
+ catch (error) {
1782
+ if (!(error instanceof HubProtocolError) || error.code === "incompatible" || error.code === "invalid")
1783
+ throw error;
1784
+ return { ok: false, code: error.code === "stale" || error.code === "revoked" ? error.code : "unavailable" };
1785
+ }
1786
+ }
1679
1787
  function roomPostCode(error) {
1680
1788
  switch (error.code) {
1681
1789
  case "invalid":
@@ -1704,8 +1812,12 @@ export function createHubHttp(deps, sql) {
1704
1812
  return;
1705
1813
  case "agent.catalog":
1706
1814
  agentCatalogs.report(frame.payload, link);
1815
+ rooms.shareLapsesChanged(link.fleetId);
1816
+ groupRooms.agents.publicationChanged(link.fleetId);
1707
1817
  sharingRequests.wake();
1708
1818
  return;
1819
+ case "agent.pictures": return { ...reply, type: "agent.pictures-result", payload: pictureCall(() => agentPictures.report(frame.payload, link)) };
1820
+ case "agent.picture": return { ...reply, type: "agent.picture-result", payload: pictureCall(() => agentPictures.chunk(frame.payload, link)) };
1709
1821
  case "exposure.request-result":
1710
1822
  sharingRequests.result(frame.requestId, frame.payload, link);
1711
1823
  return { ...reply, type: "exposure.request-ack", payload: { ok: true } };
@@ -1721,7 +1833,8 @@ export function createHubHttp(deps, sql) {
1721
1833
  return;
1722
1834
  case "room.list":
1723
1835
  try {
1724
- return { ...reply, type: "room.list-result", payload: await groupRooms.agentRooms(frame.payload, link) };
1836
+ return { ...reply, type: "room.list-result", payload: await (async () => { const result = await groupRooms.agentRooms(frame.payload, link); if (!result.ok || !link.features.has(HUB_DIRECT_POST_CAPABILITY))
1837
+ return result; const all = [...result.rooms, ...await directPosts.rooms(frame.payload.exposureId, link)]; return { ...result, rooms: all.slice(0, 200), ...(all.length > 200 ? { truncated: true } : {}) }; })() };
1725
1838
  }
1726
1839
  catch (error) {
1727
1840
  if (!(error instanceof HubProtocolError))
@@ -1738,7 +1851,7 @@ export function createHubHttp(deps, sql) {
1738
1851
  catch (error) {
1739
1852
  if (!(error instanceof HubProtocolError))
1740
1853
  throw error;
1741
- return { ...reply, type: "room.members-result", payload: { ok: false, code: roomPostCode(error) } };
1854
+ return { ...reply, type: "room.members-result", payload: { ok: false, code: roomPostCode(error), } };
1742
1855
  }
1743
1856
  case "people.search":
1744
1857
  try {
@@ -1747,16 +1860,16 @@ export function createHubHttp(deps, sql) {
1747
1860
  catch (error) {
1748
1861
  if (!(error instanceof HubProtocolError))
1749
1862
  throw error;
1750
- return { ...reply, type: "people.search-result", payload: { ok: false, code: roomPostCode(error) } };
1863
+ return { ...reply, type: "people.search-result", payload: { ok: false, code: roomPostCode(error), } };
1751
1864
  }
1752
1865
  case "room.post":
1753
1866
  try {
1754
- return { ...reply, type: "room.post-result", payload: await groupRooms.agentPost(frame.payload, link) };
1867
+ return { ...reply, type: "room.post-result", payload: await (frame.payload.direct ? directPosts.post(frame.payload, link) : groupRooms.agentPost(frame.payload, link)) };
1755
1868
  }
1756
1869
  catch (error) {
1757
1870
  if (!(error instanceof HubProtocolError))
1758
1871
  throw error;
1759
- return { ...reply, type: "room.post-result", payload: { ok: false, code: roomPostCode(error) } };
1872
+ return { ...reply, type: "room.post-result", payload: { ok: false, code: roomPostCode(error), ...(frame.payload.direct ? { message: error.code === "stale" ? "The sharing or sending connection changed; check hub_room_list before trying again." : "The person is no longer allowed to ask this agent, or their permission expired." } : {}) } };
1760
1873
  }
1761
1874
  case "room.context-state": return { ...reply, type: "room.context-state-result", payload: groupRooms.agents.contextState(frame.payload, link) };
1762
1875
  case "room.context-input": return { ...reply, type: "room.context-input-result", payload: groupRooms.agents.contextInput(frame.payload, link) };
@@ -1772,6 +1885,7 @@ export function createHubHttp(deps, sql) {
1772
1885
  }
1773
1886
  case "agent.state":
1774
1887
  groupRooms.agents.state(frame.payload, link);
1888
+ directAgentChanged(frame.payload.exposureId);
1775
1889
  return;
1776
1890
  // M-3127 (agent reactions, on room-answer-buttons-v1): an agent's reaction to the room question it was asked; the result says why not.
1777
1891
  case "room.react":
@@ -1785,6 +1899,10 @@ export function createHubHttp(deps, sql) {
1785
1899
  }
1786
1900
  case "exposure.snapshot":
1787
1901
  await catalog.receiveSnapshot(frame.payload, link, frame.requestId);
1902
+ try {
1903
+ agentPictures.prune();
1904
+ }
1905
+ catch { /* the periodic sweep */ }
1788
1906
  await sharingRequests.snapshot(link);
1789
1907
  quota.prune();
1790
1908
  groupRooms.agents.publicationChanged(link.fleetId);
@@ -1807,7 +1925,13 @@ export function createHubHttp(deps, sql) {
1807
1925
  directChanged(payload.messageId, true);
1808
1926
  return { ...reply, type: "receipt", payload };
1809
1927
  }
1810
- case "authorize.request": return { ...reply, type: "authorize.result", payload: await policy.authorize(frame.payload, link) };
1928
+ case "authorize.request": {
1929
+ const payload = await policy.authorize(frame.payload, link);
1930
+ // M-3596: a begin lease is the hand-off to the agent: the asker's question now reads "working on it".
1931
+ if (payload.ok && frame.payload.phase === "begin")
1932
+ directStarted(frame.payload.messageId);
1933
+ return { ...reply, type: "authorize.result", payload };
1934
+ }
1811
1935
  case "reconcile": {
1812
1936
  const page = rooms.reconcile(frame.payload, link);
1813
1937
  // The link becomes ready once S1 has sent this last page; questions follow it (retrying briefly until it is).
@@ -1829,6 +1953,18 @@ export function createHubHttp(deps, sql) {
1829
1953
  }
1830
1954
  groupRooms.agents.publicationSettled(settlement.group);
1831
1955
  }
1956
+ /** M-3596: the agent of these 1:1 rooms changed state (working, idle, paused): each asker's room view is read again. */
1957
+ function directAgentChanged(exposureId) {
1958
+ const rows = core.atomic(db => db.prepare("SELECT id,asker FROM hub_rooms WHERE exposure_id=? AND state='active'").all(exposureId));
1959
+ for (const r of rows)
1960
+ groupRooms.publish({ type: "room.changed", roomId: r.id, data: { roomId: r.id }, audiencePerson: r.asker });
1961
+ }
1962
+ /** M-3596: the question was handed to its agent — its pending answer row reads "working" now (the asker only). */
1963
+ function directStarted(messageId) {
1964
+ const row = core.atomic(db => db.prepare("SELECT room_id,asker FROM hub_messages WHERE id=?").get(messageId));
1965
+ if (row)
1966
+ groupRooms.publish({ type: "message.updated", roomId: row.room_id, data: { roomId: row.room_id, messageId: `${messageId}:answer` }, audiencePerson: row.asker });
1967
+ }
1832
1968
  function directChanged(messageId, answer) {
1833
1969
  const row = core.atomic(db => db.prepare("SELECT room_id,asker FROM hub_messages WHERE id=?").get(messageId));
1834
1970
  if (!row)
@@ -1859,9 +1995,9 @@ export function createHubHttp(deps, sql) {
1859
1995
  completeDirectoryRotation: (rotation, operationId) => sessions.completeDirectoryRotation(rotation, operationId),
1860
1996
  }),
1861
1997
  handle, receive, memberReady: link => { recommendations.ready(link); fleetUpdates.ready(link); }, memberConnected: link => { fleetVersions.connected(link); agentCatalogs.connected(link); }, memberClosed: fleetId => { if (live())
1862
- groupRooms.agents.disconnected(fleetId); }, agentIntroV1: true, agentCatalogV1: true, exposureRequestsV1: true, features: Object.freeze(["agent-intro-defaults-v1", "agent-sharing-v1", "agent-intros-v1", "admin-dashboard-v1", "fleet-update-v1", "rooms-v1", "room-purpose-v1", "room-ask-v1", "room-post-v1", HUB_ROOM_CONTEXT_CAPABILITY, HUB_ROOM_BRIEF_CAPABILITY, HUB_ROOM_MEMBERS_CAPABILITY, HUB_ROOM_ANSWER_STATUS_CAPABILITY, "person-prefs-v1", ...(roomAgentRequests ? ["room-owner-requests-v1"] : []), ...(roomDiscovery ? ["room-agent-discovery-v1"] : []), ...(personal ? ["personal-agents-v1"] : []), ...(teams ? ["teams-v1"] : []), ...(deps.roleAdmin ? ["role-settings-v1"] : []), ...(deps.roomAssistant && deps.assistantAdmin ? ["room-assistant-v1"] : []), ...(deps.refreshAuthorization ? ["sharing-pause-v1"] : []), ...(deps.groupHttp ? [GROUP_POLICY_FEATURE, ...(deps.pairingNotices ? ["quick-pairing-v1"] : [])] : []), ...(grantSubjectsOffered() ? ["grant-subjects-v1"] : []),
1998
+ groupRooms.agents.disconnected(fleetId); }, agentIntroV1: true, agentCatalogV1: true, agentPicturesV1: true, exposureRequestsV1: true, features: Object.freeze(["agent-intro-defaults-v1", "agent-sharing-v1", "agent-intros-v1", "admin-dashboard-v1", "fleet-update-v1", "rooms-v1", "room-purpose-v1", "room-ask-v1", "room-post-v1", HUB_DIRECT_POST_CAPABILITY, HUB_ROOM_CONTEXT_CAPABILITY, HUB_ROOM_BRIEF_CAPABILITY, HUB_ROOM_MEMBERS_CAPABILITY, HUB_ROOM_ANSWER_STATUS_CAPABILITY, "person-prefs-v1", ...(roomAgentRequests ? ["room-owner-requests-v1"] : []), ...(roomDiscovery ? ["room-agent-discovery-v1"] : []), ...(personal ? ["personal-agents-v1"] : []), ...(teams ? ["teams-v1"] : []), ...(deps.roleAdmin ? ["role-settings-v1"] : []), ...(deps.roomAssistant && deps.assistantAdmin ? ["room-assistant-v1"] : []), ...(deps.refreshAuthorization ? ["sharing-pause-v1"] : []), ...(deps.groupHttp ? [GROUP_POLICY_FEATURE, ...(deps.pairingNotices ? ["quick-pairing-v1"] : [])] : []), ...(grantSubjectsOffered() ? ["grant-subjects-v1"] : []),
1863
1999
  ...(deps.directoryNotices ? ["directory-security-notices-v1"] : []), ...(deps.memberAddressNotices ? ["member-address-notices-v1"] : []), ...(deps.directorySettings ? [HUB_DIRECTORY_SETTINGS_FEATURE, HUB_DIRECTORY_CA_FEATURE, HUB_DIRECTORY_EDITOR_FEATURE] : [])]),
1864
- async close() { closed = true; sharingRequests.close(); agentCatalogs.close(); personal?.owner.close(); await personal?.turns.close(); fleetUpdates.close(); recommendations.close(); fleetVersions.close(); grantSearch.close(); for (const end of streams)
2000
+ async close() { closed = true; sharingRequests.close(); agentCatalogs.close(); agentPictures.close(); personal?.owner.close(); await personal?.turns.close(); fleetUpdates.close(); recommendations.close(); fleetVersions.close(); grantSearch.close(); for (const end of streams)
1865
2001
  end(); await mcp.close(); await groupRooms.close(); await rooms.buttons.close(); rooms.forget(); quota.close(); },
1866
2002
  };
1867
2003
  }