@songsid/agend 2.4.0-beta.31 → 2.4.0-beta.34

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 (91) hide show
  1. package/dist/build-provenance.json +1 -1
  2. package/dist/channel/mcp-tools.js +1 -1
  3. package/dist/channel/mcp-tools.js.map +1 -1
  4. package/dist/daemon.d.ts +9 -1
  5. package/dist/daemon.js +104 -25
  6. package/dist/daemon.js.map +1 -1
  7. package/dist/fleet-context.d.ts +2 -0
  8. package/dist/fleet-manager.d.ts +16 -0
  9. package/dist/fleet-manager.js +92 -9
  10. package/dist/fleet-manager.js.map +1 -1
  11. package/dist/general-knowledge/skills/concepts/SKILL.md +21 -2
  12. package/dist/general-knowledge/skills/credential-profiles/SKILL.md +9 -4
  13. package/dist/general-knowledge/skills/hub/SKILL.md +16 -4
  14. package/dist/general-knowledge/skills/web-dashboard/SKILL.md +2 -0
  15. package/dist/hub/client.js +23 -7
  16. package/dist/hub/client.js.map +1 -1
  17. package/dist/hub/compose/member.d.ts +11 -0
  18. package/dist/hub/compose/member.js +17 -5
  19. package/dist/hub/compose/member.js.map +1 -1
  20. package/dist/hub/compose/server.js +2 -1
  21. package/dist/hub/compose/server.js.map +1 -1
  22. package/dist/hub/group-policy/resources.d.ts +1 -1
  23. package/dist/hub/http/compose.d.ts +2 -0
  24. package/dist/hub/http/compose.js +45 -6
  25. package/dist/hub/http/compose.js.map +1 -1
  26. package/dist/hub/member/room-ask.d.ts +1 -0
  27. package/dist/hub/member/room-ask.js +11 -4
  28. package/dist/hub/member/room-ask.js.map +1 -1
  29. package/dist/hub/member-journal.d.ts +2 -0
  30. package/dist/hub/member-journal.js +5 -0
  31. package/dist/hub/member-journal.js.map +1 -1
  32. package/dist/hub/member-reconciliation.d.ts +2 -0
  33. package/dist/hub/member-reconciliation.js +3 -1
  34. package/dist/hub/member-reconciliation.js.map +1 -1
  35. package/dist/hub/protocol.d.ts +15 -8
  36. package/dist/hub/protocol.js +15 -3
  37. package/dist/hub/protocol.js.map +1 -1
  38. package/dist/hub/receipt-reason.d.ts +6 -0
  39. package/dist/hub/receipt-reason.js +12 -0
  40. package/dist/hub/receipt-reason.js.map +1 -0
  41. package/dist/hub/representative.d.ts +6 -0
  42. package/dist/hub/representative.js +21 -4
  43. package/dist/hub/representative.js.map +1 -1
  44. package/dist/hub/rooms/direct-view.js +2 -0
  45. package/dist/hub/rooms/direct-view.js.map +1 -1
  46. package/dist/hub/rooms/types.d.ts +2 -0
  47. package/dist/hub/rooms.d.ts +12 -0
  48. package/dist/hub/rooms.js +14 -3
  49. package/dist/hub/rooms.js.map +1 -1
  50. package/dist/hub/server.js +9 -2
  51. package/dist/hub/server.js.map +1 -1
  52. package/dist/hub/settings-member-address-decision.js +1 -1
  53. package/dist/hub/settings-member-address-decision.js.map +1 -1
  54. package/dist/hub/settings-web-address-decision.js +2 -2
  55. package/dist/hub/settings-web-address-decision.js.map +1 -1
  56. package/dist/hub-reply-route.d.ts +36 -0
  57. package/dist/hub-reply-route.js +67 -0
  58. package/dist/hub-reply-route.js.map +1 -0
  59. package/dist/hub-report-target.d.ts +4 -0
  60. package/dist/instance-lifecycle.d.ts +2 -0
  61. package/dist/instance-lifecycle.js +4 -0
  62. package/dist/instance-lifecycle.js.map +1 -1
  63. package/dist/locale.js +2 -2
  64. package/dist/locale.js.map +1 -1
  65. package/dist/outbound-handlers.d.ts +2 -0
  66. package/dist/outbound-handlers.js +22 -7
  67. package/dist/outbound-handlers.js.map +1 -1
  68. package/dist/outbound-schemas.d.ts +1 -0
  69. package/dist/outbound-schemas.js +1 -0
  70. package/dist/outbound-schemas.js.map +1 -1
  71. package/dist/topic-commands.js +6 -4
  72. package/dist/topic-commands.js.map +1 -1
  73. package/dist/turn-reply-guard.d.ts +3 -1
  74. package/dist/turn-reply-guard.js +7 -3
  75. package/dist/turn-reply-guard.js.map +1 -1
  76. package/dist/ui/hub-assistant-admin.js +10 -3
  77. package/dist/ui/hub-assistant-usage-strings.js +8 -0
  78. package/dist/ui/hub-chat-store.js +9 -6
  79. package/dist/ui/hub-chat-strings.js +4 -2
  80. package/dist/ui/hub-owner-strings.js +2 -2
  81. package/dist/ui/hub-room-composer.js +9 -2
  82. package/dist/ui/hub-room-strings.js +4 -4
  83. package/dist/ui/hub-room-thread.js +45 -11
  84. package/dist/ui/panel-chat.js +18 -5
  85. package/dist/ui/panel-hub.js +3 -3
  86. package/dist/ui/report-columns.js +137 -0
  87. package/dist/ui/shared/app.css +28 -2
  88. package/dist/ui/shared/chat-msg-actions.js +1 -1
  89. package/dist/ui/shared/chat-thread.js +1 -1
  90. package/dist/ui/shared/hub-owner.css +12 -0
  91. package/package.json +1 -1
@@ -93,7 +93,7 @@ export const HUB_UI_MODULES = Object.freeze(["panel-hub.js", "hub-notify-keep.js
93
93
  // 管理 → 房間.
94
94
  "hub-room-new.js", "hub-room-purpose.js", "hub-room-new-strings.js", "hub-room-settings.js", "hub-room-owner-requests.js", "hub-room-owner-requests-strings.js", "hub-room-settings-strings.js", "hub-room-members.js", "hub-room-members-strings.js", "hub-invitations.js", "hub-invitations-strings.js", "hub-admin-rooms.js", "hub-admin-rooms-strings.js",
95
95
  // M-3092 (Hub rooms, track U): the conversation list, a room on the shared thread, its composer.
96
- "hub-room-list.js", "hub-room-thread.js", "hub-room-agent-strings.js", "hub-room-composer.js", "hub-assistant-admin.js", "hub-assistant-admin-strings.js",
96
+ "hub-room-list.js", "hub-room-thread.js", "hub-room-agent-strings.js", "hub-room-composer.js", "hub-assistant-admin.js", "hub-assistant-admin-strings.js", "hub-assistant-usage-strings.js",
97
97
  // M-3092 S-145: the list's favourites (the Fleet sidebar's #1664 rules; synced per person by the Hub).
98
98
  "hub-room-favorites.js",
99
99
  // M-3340: personal pins in a room (its list and 📌; the store keeps them in hub-room-thread.js).
@@ -197,6 +197,8 @@ const uuid = (v) => { if (typeof v !== "string" || !UUID.test(v))
197
197
  const int = (v) => { const n = typeof v === "string" && /^\d{1,15}$/.test(v) ? Number(v) : v; if (!Number.isSafeInteger(n) || n < 0)
198
198
  throw new HubProtocolError("invalid"); return n; };
199
199
  /** Build S3's HTTP handler and member receiver over S5's deps. `sql` is S5's `hubTxDatabase`. */
200
+ /** M-3955: open event streams per sign-in session (see streamSlot). */
201
+ export const STREAMS_PER_SESSION = 4;
200
202
  export function createHubHttp(deps, sql) {
201
203
  let closed = false;
202
204
  const teamFactory = deps.teams;
@@ -292,6 +294,28 @@ export function createHubHttp(deps, sql) {
292
294
  const uploading = new Map();
293
295
  let uploadingTotal = 0;
294
296
  const streams = new Set();
297
+ // M-3955 (Fable): at most STREAMS_PER_SESSION open event streams (rooms and notices alike) per sign-in session. A page
298
+ // opens one per tab. A stream's message projection is not charged to the session's polling allowance, so this bounds
299
+ // how far one session's events fan out, and keeps one person from taking the Hub-wide 64. Past it a new stream is
300
+ // refused (backpressure; the page retries), never by closing an older one (two tabs would take turns closing each other).
301
+ const sessionStreams = new Map();
302
+ const streamSlot = (sessionId) => {
303
+ const open = sessionStreams.get(sessionId) ?? 0;
304
+ if (open >= STREAMS_PER_SESSION)
305
+ throw new HubProtocolError("backpressure");
306
+ sessionStreams.set(sessionId, open + 1);
307
+ let released = false;
308
+ return () => {
309
+ if (released)
310
+ return;
311
+ released = true;
312
+ const left = (sessionStreams.get(sessionId) ?? 1) - 1;
313
+ if (left > 0)
314
+ sessionStreams.set(sessionId, left);
315
+ else
316
+ sessionStreams.delete(sessionId);
317
+ };
318
+ };
295
319
  /** One API request: method and path enumerated, mutations same-origin with the session's CSRF token. */
296
320
  async function api(req, res, path, query) {
297
321
  const method = req.method ?? "GET";
@@ -663,16 +687,17 @@ export function createHubHttp(deps, sql) {
663
687
  if (path === "/hub/v1/notices/events") {
664
688
  if (method !== "GET")
665
689
  throw new HttpError(405, "method");
666
- signedIn();
690
+ const noticeSession = signedIn();
667
691
  if (streams.size >= 64)
668
692
  throw new HubProtocolError("backpressure");
669
693
  const initial = await guard(() => notices.forSession(ctx, query.get("v") === "3" ? 3 : query.get("v") === "2" ? 2 : 1));
670
694
  if (streams.size >= 64 || !live() || ctx.isCurrent?.() !== true)
671
695
  throw new HubProtocolError("backpressure");
696
+ const releaseSlot = streamSlot(noticeSession.sessionId);
672
697
  res.writeHead(200, { ...API_HEADERS, "Content-Type": "text/event-stream; charset=utf-8", Connection: "keep-alive", "X-Accel-Buffering": "no" });
673
698
  let ended = false, running = false, dirty = false;
674
699
  const close = () => { if (ended)
675
- return; ended = true; off(); clearInterval(heartbeat); streams.delete(close); res.end(); };
700
+ return; ended = true; off(); clearInterval(heartbeat); streams.delete(close); releaseSlot(); res.end(); };
676
701
  const push = async () => {
677
702
  if (ended)
678
703
  return;
@@ -1140,11 +1165,17 @@ export function createHubHttp(deps, sql) {
1140
1165
  const initialNotices = notices && noticeVersion ? await guard(() => notices.forSession(ctx, noticeVersion)) : null;
1141
1166
  if (streams.size >= 64 || !ctx.isCurrent?.())
1142
1167
  throw new HubProtocolError("backpressure");
1168
+ const releaseSlot = streamSlot(streamSession.sessionId);
1143
1169
  res.writeHead(200, { ...API_HEADERS, "Content-Type": "text/event-stream; charset=utf-8", Connection: "keep-alive", "X-Accel-Buffering": "no" });
1144
1170
  let ended = false, queued = 0, tail = Promise.resolve(), noticesRunning = false, noticesDirty = false;
1145
1171
  let offNotices = () => { };
1146
1172
  const close = () => { if (ended)
1147
- return; ended = true; off(); offNotices(); clearInterval(heartbeat); streams.delete(close); res.end(); };
1173
+ return; ended = true; off(); offNotices(); clearInterval(heartbeat); streams.delete(close); releaseSlot(); res.end(); };
1174
+ // M-3951 S-1: a viewer-addressed event carries only which room/message; its projection reads the current state when
1175
+ // it runs. One such event still waiting in this stream's queue therefore already covers a later identical one: the
1176
+ // later one is dropped, never projected twice (each projection re-checks the viewer's authority). It is forgotten
1177
+ // as its projection starts, so a change made during a projection is always read again.
1178
+ const waiting = new Set();
1148
1179
  const off = groupRooms.subscribe(event => {
1149
1180
  if (ended)
1150
1181
  return;
@@ -1152,11 +1183,18 @@ export function createHubHttp(deps, sql) {
1152
1183
  return;
1153
1184
  if (!event.audiencePerson && !groupRooms.interested(streamPerson, event))
1154
1185
  return;
1186
+ const key = event.audiencePerson ? `${event.type}\0${event.roomId}\0${typeof event.data.messageId === "string" ? event.data.messageId : ""}` : null;
1187
+ if (key !== null && waiting.has(key))
1188
+ return;
1155
1189
  if (++queued > 64) {
1156
1190
  close();
1157
1191
  return;
1158
1192
  }
1193
+ if (key !== null)
1194
+ waiting.add(key);
1159
1195
  tail = tail.then(async () => {
1196
+ if (key !== null)
1197
+ waiting.delete(key);
1160
1198
  if (ended)
1161
1199
  return;
1162
1200
  const finishTiming = core.sendTiming?.start("sse.project");
@@ -1188,7 +1226,8 @@ export function createHubHttp(deps, sql) {
1188
1226
  // unused room proof before it; nothing is retained across this event or its viewer's session.
1189
1227
  if (typeof event.data.messageId !== "string")
1190
1228
  throw new HubProtocolError("invalid");
1191
- const page = await rooms.readPage(ctx, event.roomId, 0, streamSession.sessionId, { before: null, limit: 100, messageId: event.data.messageId });
1229
+ // M-3955: outside the session's polling allowance (a live stream's projection, not a poll).
1230
+ const page = await rooms.readStreamMessage(ctx, event.roomId, event.data.messageId);
1192
1231
  const message = directMessages(page.room, page.entries, streamSession.displayName).find(m => m.id === event.data.messageId);
1193
1232
  data = message ? { roomId: event.roomId, message } : null;
1194
1233
  }
@@ -1451,7 +1490,7 @@ export function createHubHttp(deps, sql) {
1451
1490
  const room = await guard(() => rooms.view(ctx, roomId));
1452
1491
  groupRooms.publish({ type: "message.added", roomId, data: { roomId, messageId: receipt.messageId }, audiencePerson: personKeyString(room.asker) });
1453
1492
  return send(res, 200, { id: receipt.messageId, roomId, at: receipt.at, author: { kind: "person", id: personKeyString(room.asker), name: signedIn().displayName },
1454
- text: typeof b.text === "string" ? b.text : "", mentions: [], idempotencyKey: b.idempotencyKey, receipt });
1493
+ text: typeof b.text === "string" ? b.text : "", mentions: [], idempotencyKey: b.idempotencyKey, receiptStage: receipt.stage, receipt });
1455
1494
  }
1456
1495
  finally {
1457
1496
  finishTiming?.();