@songsid/agend 2.4.0-beta.12 → 2.4.0-beta.14

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 (226) hide show
  1. package/dist/agent-endpoint.js +28 -6
  2. package/dist/agent-endpoint.js.map +1 -1
  3. package/dist/auth-api.js +5 -0
  4. package/dist/auth-api.js.map +1 -1
  5. package/dist/backend/claude-code.d.ts +9 -0
  6. package/dist/backend/claude-code.js +60 -4
  7. package/dist/backend/claude-code.js.map +1 -1
  8. package/dist/backend/codex.js +11 -0
  9. package/dist/backend/codex.js.map +1 -1
  10. package/dist/backend/grok.js +11 -0
  11. package/dist/backend/grok.js.map +1 -1
  12. package/dist/backend/types.d.ts +4 -1
  13. package/dist/backend/types.js.map +1 -1
  14. package/dist/backend-availability.d.ts +1 -16
  15. package/dist/backend-availability.js +2 -91
  16. package/dist/backend-availability.js.map +1 -1
  17. package/dist/backend-version-static.d.ts +15 -0
  18. package/dist/backend-version-static.js +95 -0
  19. package/dist/backend-version-static.js.map +1 -0
  20. package/dist/build-provenance.json +1 -1
  21. package/dist/channel/adapters/telegram.js +3 -1
  22. package/dist/channel/adapters/telegram.js.map +1 -1
  23. package/dist/channel/mcp-server.js +18 -1
  24. package/dist/channel/mcp-server.js.map +1 -1
  25. package/dist/channel/tool-router.d.ts +4 -0
  26. package/dist/channel/tool-router.js +43 -19
  27. package/dist/channel/tool-router.js.map +1 -1
  28. package/dist/classic-channel-manager.d.ts +3 -0
  29. package/dist/classic-channel-manager.js +18 -0
  30. package/dist/classic-channel-manager.js.map +1 -1
  31. package/dist/classic-cli-guard.d.ts +66 -0
  32. package/dist/classic-cli-guard.js +209 -0
  33. package/dist/classic-cli-guard.js.map +1 -0
  34. package/dist/cli-audited.js +7 -5
  35. package/dist/cli-audited.js.map +1 -1
  36. package/dist/config-validator.js +3 -0
  37. package/dist/config-validator.js.map +1 -1
  38. package/dist/contact-auth-api.d.ts +16 -0
  39. package/dist/contact-auth-api.js +78 -0
  40. package/dist/contact-auth-api.js.map +1 -0
  41. package/dist/contact-auth-files.d.ts +6 -0
  42. package/dist/contact-auth-files.js +29 -0
  43. package/dist/contact-auth-files.js.map +1 -0
  44. package/dist/contact-auth-policy.d.ts +75 -0
  45. package/dist/contact-auth-policy.js +23 -0
  46. package/dist/contact-auth-policy.js.map +1 -0
  47. package/dist/contact-auth-service.d.ts +32 -0
  48. package/dist/contact-auth-service.js +99 -0
  49. package/dist/contact-auth-service.js.map +1 -0
  50. package/dist/contact-auth-store.d.ts +75 -0
  51. package/dist/contact-auth-store.js +295 -0
  52. package/dist/contact-auth-store.js.map +1 -0
  53. package/dist/contact-auth-types.d.ts +170 -0
  54. package/dist/contact-auth-types.js +7 -0
  55. package/dist/contact-auth-types.js.map +1 -0
  56. package/dist/daemon.d.ts +16 -1
  57. package/dist/daemon.js +127 -11
  58. package/dist/daemon.js.map +1 -1
  59. package/dist/delivery-outbox.d.ts +6 -0
  60. package/dist/delivery-outbox.js +19 -0
  61. package/dist/delivery-outbox.js.map +1 -1
  62. package/dist/dispatcher-liveness.js +2 -2
  63. package/dist/dispatcher-liveness.js.map +1 -1
  64. package/dist/fleet-manager.d.ts +45 -0
  65. package/dist/fleet-manager.js +450 -23
  66. package/dist/fleet-manager.js.map +1 -1
  67. package/dist/general-knowledge/skills/concepts/SKILL.md +18 -0
  68. package/dist/general-knowledge/skills/credential-profiles/SKILL.md +12 -0
  69. package/dist/general-knowledge/skills/cross-instance-messaging/SKILL.md +28 -0
  70. package/dist/general-knowledge/skills/hub/SKILL.md +6 -0
  71. package/dist/hub/audit/index.d.ts +3 -1
  72. package/dist/hub/audit/index.js +35 -3
  73. package/dist/hub/audit/index.js.map +1 -1
  74. package/dist/hub/catalog.d.ts +8 -0
  75. package/dist/hub/catalog.js +39 -4
  76. package/dist/hub/catalog.js.map +1 -1
  77. package/dist/hub/compose/server.d.ts +2 -0
  78. package/dist/hub/compose/server.js +11 -1
  79. package/dist/hub/compose/server.js.map +1 -1
  80. package/dist/hub/directory/directory.js +5 -2
  81. package/dist/hub/directory/directory.js.map +1 -1
  82. package/dist/hub/directory/types.d.ts +5 -1
  83. package/dist/hub/directory/types.js.map +1 -1
  84. package/dist/hub/group-policy/resources.d.ts +1 -1
  85. package/dist/hub/http/compose.d.ts +2 -0
  86. package/dist/hub/http/compose.js +123 -6
  87. package/dist/hub/http/compose.js.map +1 -1
  88. package/dist/hub/http/deps.d.ts +2 -0
  89. package/dist/hub/http/schema.js +6 -1
  90. package/dist/hub/http/schema.js.map +1 -1
  91. package/dist/hub/invitations.js +15 -7
  92. package/dist/hub/invitations.js.map +1 -1
  93. package/dist/hub/roles/cutover-inventory.d.ts +3 -0
  94. package/dist/hub/roles/cutover-inventory.js +20 -4
  95. package/dist/hub/roles/cutover-inventory.js.map +1 -1
  96. package/dist/hub/roles/cutover-marker.d.ts +18 -2
  97. package/dist/hub/roles/cutover-marker.js +6 -2
  98. package/dist/hub/roles/cutover-marker.js.map +1 -1
  99. package/dist/hub/room-agent-discovery-model.d.ts +29 -0
  100. package/dist/hub/room-agent-discovery-model.js +33 -0
  101. package/dist/hub/room-agent-discovery-model.js.map +1 -0
  102. package/dist/hub/room-agent-discovery.d.ts +14 -0
  103. package/dist/hub/room-agent-discovery.js +65 -0
  104. package/dist/hub/room-agent-discovery.js.map +1 -0
  105. package/dist/hub/room-agent-requests.d.ts +71 -0
  106. package/dist/hub/room-agent-requests.js +377 -0
  107. package/dist/hub/room-agent-requests.js.map +1 -0
  108. package/dist/hub/rooms/directory.d.ts +13 -0
  109. package/dist/hub/rooms/directory.js +12 -3
  110. package/dist/hub/rooms/directory.js.map +1 -1
  111. package/dist/hub/rooms/schema.d.ts +5 -0
  112. package/dist/hub/rooms/schema.js +9 -0
  113. package/dist/hub/rooms/schema.js.map +1 -1
  114. package/dist/hub/rooms/service.d.ts +43 -19
  115. package/dist/hub/rooms/service.js +67 -11
  116. package/dist/hub/rooms/service.js.map +1 -1
  117. package/dist/hub/rooms/types.d.ts +1 -1
  118. package/dist/instance-lifecycle.d.ts +6 -1
  119. package/dist/instance-lifecycle.js +11 -4
  120. package/dist/instance-lifecycle.js.map +1 -1
  121. package/dist/locale.js +34 -4
  122. package/dist/locale.js.map +1 -1
  123. package/dist/needs-you-hub.d.ts +1 -0
  124. package/dist/needs-you-hub.js +6 -0
  125. package/dist/needs-you-hub.js.map +1 -1
  126. package/dist/needs-you.d.ts +14 -2
  127. package/dist/needs-you.js +4 -0
  128. package/dist/needs-you.js.map +1 -1
  129. package/dist/office-share-page.js +1 -1
  130. package/dist/office-share-page.js.map +1 -1
  131. package/dist/outbound-handlers.d.ts +9 -0
  132. package/dist/outbound-handlers.js +48 -10
  133. package/dist/outbound-handlers.js.map +1 -1
  134. package/dist/pause-marker.d.ts +1 -1
  135. package/dist/pause-marker.js +1 -1
  136. package/dist/pause-marker.js.map +1 -1
  137. package/dist/public-web-gateway.d.ts +20 -0
  138. package/dist/public-web-gateway.js +61 -4
  139. package/dist/public-web-gateway.js.map +1 -1
  140. package/dist/runtime-cli-install.js +7 -7
  141. package/dist/runtime-cli-install.js.map +1 -1
  142. package/dist/topic-commands.d.ts +1 -1
  143. package/dist/topic-commands.js +4 -6
  144. package/dist/topic-commands.js.map +1 -1
  145. package/dist/ui/accounts-keepalive.js +2 -1
  146. package/dist/ui/accounts-view.js +2 -1
  147. package/dist/ui/agent-details-settings.js +7 -5
  148. package/dist/ui/contact-auth-client.js +48 -0
  149. package/dist/ui/contact-auth-strings.js +164 -0
  150. package/dist/ui/contact-authorizations.js +125 -0
  151. package/dist/ui/contact-needs.js +84 -0
  152. package/dist/ui/contact-permissions.js +193 -0
  153. package/dist/ui/contact-ticket-badge.js +54 -0
  154. package/dist/ui/fleet-canvas.js +3 -1
  155. package/dist/ui/fleet-office-skin.js +4 -3
  156. package/dist/ui/fleet-route.js +44 -6
  157. package/dist/ui/fleet-task-view.js +2 -1
  158. package/dist/ui/host-install.js +5 -2
  159. package/dist/ui/hub-ai-apps.js +2 -1
  160. package/dist/ui/hub-chat-strings.js +2 -1
  161. package/dist/ui/hub-client.js +30 -7
  162. package/dist/ui/hub-grant-picker.js +2 -1
  163. package/dist/ui/hub-group-strings.js +2 -1
  164. package/dist/ui/hub-invitations.js +5 -1
  165. package/dist/ui/hub-my-agents.js +2 -1
  166. package/dist/ui/hub-owner-strings.js +2 -1
  167. package/dist/ui/hub-personal-agent.js +2 -1
  168. package/dist/ui/hub-quota.js +2 -1
  169. package/dist/ui/hub-roles-strings.js +2 -1
  170. package/dist/ui/hub-room-new-strings.js +2 -1
  171. package/dist/ui/hub-room-new.js +10 -3
  172. package/dist/ui/hub-room-owner-requests-strings.js +114 -0
  173. package/dist/ui/hub-room-owner-requests.js +264 -0
  174. package/dist/ui/hub-room-pins.js +43 -0
  175. package/dist/ui/hub-room-settings.js +11 -2
  176. package/dist/ui/hub-room-source.js +2 -1
  177. package/dist/ui/hub-room-strings.js +3 -0
  178. package/dist/ui/hub-room-thread.js +47 -5
  179. package/dist/ui/hub-strings.js +2 -1
  180. package/dist/ui/hub-teams.js +2 -1
  181. package/dist/ui/model-picker.js +3 -2
  182. package/dist/ui/panel-chat.js +8 -2
  183. package/dist/ui/panel-details.js +2 -0
  184. package/dist/ui/panel-fleet.js +3 -2
  185. package/dist/ui/panel-hub.js +14 -4
  186. package/dist/ui/panel-needs.js +8 -3
  187. package/dist/ui/panel-runtimes.js +2 -1
  188. package/dist/ui/panel-settings.js +3 -0
  189. package/dist/ui/reply-file-preview.js +2 -1
  190. package/dist/ui/settings-access-overview.js +2 -1
  191. package/dist/ui/settings-connector.js +2 -1
  192. package/dist/ui/shared/agent-sheet.js +2 -1
  193. package/dist/ui/shared/app-i18n.js +2 -2
  194. package/dist/ui/shared/app-route.js +1 -1
  195. package/dist/ui/shared/app-shell.js +35 -9
  196. package/dist/ui/shared/app-stream.js +3 -1
  197. package/dist/ui/shared/app.css +42 -0
  198. package/dist/ui/shared/asset-url.d.ts +2 -0
  199. package/dist/ui/shared/asset-url.js +20 -0
  200. package/dist/ui/shared/chat-quote.js +26 -2
  201. package/dist/ui/shared/chat-table-select.js +175 -0
  202. package/dist/ui/shared/chat-thread.js +6 -2
  203. package/dist/ui/shared/hub-rooms-u2.css +22 -0
  204. package/dist/ui/shared/image-annotate.js +2 -1
  205. package/dist/ui/shared/text-undo.js +17 -3
  206. package/dist/ui/shared/ui-states.js +3 -2
  207. package/dist/ui/shared/view-history.js +2 -1
  208. package/dist/ui/subagent-row.js +3 -2
  209. package/dist/ui/usage-pool.js +2 -1
  210. package/dist/ui/workspace-panel.js +2 -1
  211. package/dist/wake-coordinator.js +3 -2
  212. package/dist/wake-coordinator.js.map +1 -1
  213. package/dist/web-api.d.ts +9 -0
  214. package/dist/web-api.js +56 -4
  215. package/dist/web-api.js.map +1 -1
  216. package/dist/web-chat-history.d.ts +5 -0
  217. package/dist/web-chat-history.js +26 -0
  218. package/dist/web-chat-history.js.map +1 -1
  219. package/dist/web-host-install.d.ts +1 -1
  220. package/dist/web-reply-files.d.ts +1 -0
  221. package/dist/web-reply-files.js +2 -0
  222. package/dist/web-reply-files.js.map +1 -1
  223. package/dist/web-shell-routes.d.ts +1 -1
  224. package/dist/web-shell-routes.js +2 -1
  225. package/dist/web-shell-routes.js.map +1 -1
  226. package/package.json +1 -1
@@ -27,6 +27,8 @@ export declare function searchSnippet(text: string, terms: string[], width?: num
27
27
  };
28
28
  /** M-3127: the most distinct emoji one post carries. */
29
29
  export declare const ROOM_REACTION_LIMIT = 12;
30
+ /** M-3340: a person's pins per room (the Fleet chat's own limit, chat-pins.js PINS_MAX). */
31
+ export declare const ROOM_PINS_MAX = 50;
30
32
  /** One emoji as a person picks it: one grapheme, a pictograph (ZWJ sequences, FE0F and skin tones kept), no controls. */
31
33
  export declare function validRoomEmoji(s: unknown): s is string;
32
34
  export declare class HubRoomRefusal extends Error {
@@ -138,18 +140,16 @@ export declare class HubGroupRooms {
138
140
  };
139
141
  invitations: number;
140
142
  }>;
141
- candidates(ctx: HubRequestContext, q: string, kind: string): Promise<{
143
+ candidates(ctx: HubRequestContext, q: string, kind: string, discovery?: boolean): Promise<{
142
144
  kind: "person";
143
145
  id: string;
144
146
  name: string;
147
+ detail?: string | undefined;
145
148
  }[] | {
146
149
  kind: "group";
147
150
  id: string;
148
151
  name: string;
149
152
  }[] | {
150
- intro: string;
151
- introBy?: "owner" | "agent" | "default";
152
- introAt?: number;
153
153
  kind: "agent";
154
154
  id: string;
155
155
  name: string;
@@ -157,6 +157,9 @@ export declare class HubGroupRooms {
157
157
  owner: {
158
158
  name: string;
159
159
  };
160
+ intro: string;
161
+ introBy?: "owner" | "agent" | "default";
162
+ introAt?: number;
160
163
  }[] | {
161
164
  id: string;
162
165
  name: string;
@@ -254,9 +257,6 @@ export declare class HubGroupRooms {
254
257
  presence: "idle" | "paused" | "working";
255
258
  signedIn?: undefined;
256
259
  } | {
257
- intro: string;
258
- introBy?: "owner" | "agent" | "default";
259
- introAt?: number;
260
260
  presence: "idle" | "later" | "offline" | "paused" | "working";
261
261
  presenceReason?: undefined;
262
262
  id: string;
@@ -270,10 +270,10 @@ export declare class HubGroupRooms {
270
270
  };
271
271
  canAsk: boolean;
272
272
  signedIn?: undefined;
273
- } | {
274
273
  intro: string;
275
274
  introBy?: "owner" | "agent" | "default";
276
275
  introAt?: number;
276
+ } | {
277
277
  presence: "offline";
278
278
  presenceReason: "update";
279
279
  id: string;
@@ -287,10 +287,10 @@ export declare class HubGroupRooms {
287
287
  };
288
288
  canAsk: boolean;
289
289
  signedIn?: undefined;
290
- } | {
291
290
  intro: string;
292
291
  introBy?: "owner" | "agent" | "default";
293
292
  introAt?: number;
293
+ } | {
294
294
  presence: "idle" | "paused" | "working";
295
295
  presenceReason?: import("../types.js").HubAgentStateReason | undefined;
296
296
  presenceNote?: string | undefined;
@@ -305,6 +305,9 @@ export declare class HubGroupRooms {
305
305
  };
306
306
  canAsk: boolean;
307
307
  signedIn?: undefined;
308
+ intro: string;
309
+ introBy?: "owner" | "agent" | "default";
310
+ introAt?: number;
308
311
  } | {
309
312
  id: string;
310
313
  kind: "person";
@@ -369,9 +372,6 @@ export declare class HubGroupRooms {
369
372
  presence: "idle" | "paused" | "working";
370
373
  signedIn?: undefined;
371
374
  } | {
372
- intro: string;
373
- introBy?: "owner" | "agent" | "default";
374
- introAt?: number;
375
375
  presence: "idle" | "later" | "offline" | "paused" | "working";
376
376
  presenceReason?: undefined;
377
377
  id: string;
@@ -385,10 +385,10 @@ export declare class HubGroupRooms {
385
385
  };
386
386
  canAsk: boolean;
387
387
  signedIn?: undefined;
388
- } | {
389
388
  intro: string;
390
389
  introBy?: "owner" | "agent" | "default";
391
390
  introAt?: number;
391
+ } | {
392
392
  presence: "offline";
393
393
  presenceReason: "update";
394
394
  id: string;
@@ -402,10 +402,10 @@ export declare class HubGroupRooms {
402
402
  };
403
403
  canAsk: boolean;
404
404
  signedIn?: undefined;
405
- } | {
406
405
  intro: string;
407
406
  introBy?: "owner" | "agent" | "default";
408
407
  introAt?: number;
408
+ } | {
409
409
  presence: "idle" | "paused" | "working";
410
410
  presenceReason?: import("../types.js").HubAgentStateReason | undefined;
411
411
  presenceNote?: string | undefined;
@@ -420,6 +420,9 @@ export declare class HubGroupRooms {
420
420
  };
421
421
  canAsk: boolean;
422
422
  signedIn?: undefined;
423
+ intro: string;
424
+ introBy?: "owner" | "agent" | "default";
425
+ introAt?: number;
423
426
  } | {
424
427
  id: string;
425
428
  kind: "person";
@@ -484,9 +487,6 @@ export declare class HubGroupRooms {
484
487
  presence: "idle" | "paused" | "working";
485
488
  signedIn?: undefined;
486
489
  } | {
487
- intro: string;
488
- introBy?: "owner" | "agent" | "default";
489
- introAt?: number;
490
490
  presence: "idle" | "later" | "offline" | "paused" | "working";
491
491
  presenceReason?: undefined;
492
492
  id: string;
@@ -500,10 +500,10 @@ export declare class HubGroupRooms {
500
500
  };
501
501
  canAsk: boolean;
502
502
  signedIn?: undefined;
503
- } | {
504
503
  intro: string;
505
504
  introBy?: "owner" | "agent" | "default";
506
505
  introAt?: number;
506
+ } | {
507
507
  presence: "offline";
508
508
  presenceReason: "update";
509
509
  id: string;
@@ -517,10 +517,10 @@ export declare class HubGroupRooms {
517
517
  };
518
518
  canAsk: boolean;
519
519
  signedIn?: undefined;
520
- } | {
521
520
  intro: string;
522
521
  introBy?: "owner" | "agent" | "default";
523
522
  introAt?: number;
523
+ } | {
524
524
  presence: "idle" | "paused" | "working";
525
525
  presenceReason?: import("../types.js").HubAgentStateReason | undefined;
526
526
  presenceNote?: string | undefined;
@@ -535,6 +535,9 @@ export declare class HubGroupRooms {
535
535
  };
536
536
  canAsk: boolean;
537
537
  signedIn?: undefined;
538
+ intro: string;
539
+ introBy?: "owner" | "agent" | "default";
540
+ introAt?: number;
538
541
  } | {
539
542
  id: string;
540
543
  kind: "person";
@@ -572,6 +575,27 @@ export declare class HubGroupRooms {
572
575
  react(ctx: HubRequestContext, id: string, postId: unknown, input: unknown): Promise<{
573
576
  reactions: NonNullable<RoomMessage["reactions"]>;
574
577
  }>;
578
+ /**
579
+ * M-3340: the signed-in person's own pins in a group room — newest first, each with the message as messages() shows it to
580
+ * them now. A pin whose message they can no longer see (it is older than their joining, or its question is not theirs)
581
+ * is left out. Nobody else's pins are ever read, and nobody else learns of these.
582
+ */
583
+ pins(ctx: HubRequestContext, id: string): Promise<{
584
+ pins: Array<{
585
+ messageId: string;
586
+ pinnedAt: number;
587
+ message: RoomMessage;
588
+ }>;
589
+ }>;
590
+ /** M-3340: pin (on) or unpin a message the person can see; answers with their pins. Past ROOM_PINS_MAX: 409 pins-full. */
591
+ pin(ctx: HubRequestContext, id: string, postId: unknown, on: boolean): Promise<{
592
+ pins: {
593
+ messageId: string;
594
+ pinnedAt: number;
595
+ message: RoomMessage;
596
+ }[];
597
+ }>;
598
+ private pinList;
575
599
  /**
576
600
  * M-3127: a post exactly as messages() shows it to `member` — since their joined_sequence, its lineage's audience floor
577
601
  * too (Ridge, M-3118: the descendants of a question older than them stay hidden), and an answer only when its question
@@ -21,7 +21,7 @@ import { RoomButtons } from "./buttons.js";
21
21
  import { HUB_ROOM_REACT_CAPABILITY, roomReactSchema } from "../protocol.js";
22
22
  import { replyButtonClickText } from "../../reply-buttons.js";
23
23
  import { pollResultsText } from "../../reply-polls.js";
24
- import { RoomDirectoryCandidates, rememberRoomPeople } from "./directory.js";
24
+ import { RoomDirectoryCandidates, rememberRoomPeople, roomPersonLabels } from "./directory.js";
25
25
  import { isInlineImage } from "../attachments/limits.js";
26
26
  import { HUB_ROOM_MENTION_FEEDBACK_CAPABILITY } from "../room-mention-feedback-model.js";
27
27
  import { personalMentionRefusals, recordPersonalMentionRefusals } from "../personal/refusals.js";
@@ -71,6 +71,8 @@ export function searchSnippet(text, terms, width = 120) {
71
71
  const reactSchema = z.strictObject({ emoji: z.string().min(1).max(16), on: z.boolean() });
72
72
  /** M-3127: the most distinct emoji one post carries. */
73
73
  export const ROOM_REACTION_LIMIT = 12;
74
+ /** M-3340: a person's pins per room (the Fleet chat's own limit, chat-pins.js PINS_MAX). */
75
+ export const ROOM_PINS_MAX = 50;
74
76
  /** One emoji as a person picks it: one grapheme, a pictograph (ZWJ sequences, FE0F and skin tones kept), no controls. */
75
77
  export function validRoomEmoji(s) {
76
78
  if (typeof s !== "string" || s.length < 1 || s.length > 16 || /[\u0000-\u001f\u007f\s]/u.test(s))
@@ -602,7 +604,7 @@ export class HubGroupRooms {
602
604
  me: { canCreateRooms: canCreateRoom(this.core, db, me), assistant: this.assistant.availability()?.enabled === true }, invitations: 0 };
603
605
  }, this.fence(ctx));
604
606
  }
605
- async candidates(ctx, q, kind) {
607
+ async candidates(ctx, q, kind, discovery = false) {
606
608
  if (q.length > 64 || /[\u0000-\u001f\u007f]/.test(q) || !["person", "team", "group", "agent"].includes(kind))
607
609
  throw new HubProtocolError("invalid");
608
610
  const me = await this.who(ctx);
@@ -611,12 +613,19 @@ export class HubGroupRooms {
611
613
  if (kind === "agent") {
612
614
  this.core.atomic(db => { if (!allowed(db))
613
615
  throw new HubRoomRefusal(403, "denied"); }, this.fence(ctx));
614
- const view = await new HubCatalogService(this.core).visible(ctx);
615
- const hits = [...view.mine.map(e => ({ kind: "agent", id: e.id, name: e.displayName, mine: true, owner: { name: this.core.atomic(db => this.name(db, me)) } })),
616
- ...view.askable.map(({ exposure: e, ownerName }) => ({ kind: "agent", id: e.id, name: e.displayName, mine: false, owner: { name: ownerName } }))]
617
- .filter(e => e.name.toLowerCase().startsWith(q.trim().toLowerCase())).slice(0, 20);
618
- this.fence(ctx).assertCurrent();
619
- return this.core.atomic(db => hits.map(row => ({ ...row, ...agentIntro(db, row.id) })), this.fence(ctx));
616
+ const catalog = new HubCatalogService(this.core);
617
+ return (discovery ? catalog.withRoomVisible.bind(catalog) : catalog.withVisible.bind(catalog))(ctx, view => {
618
+ const hits = [...view.mine.map(e => ({ kind: "agent", id: e.id, name: e.displayName, mine: true, owner: { name: this.core.atomic(db => this.name(db, me)) } })),
619
+ ...view.askable.map(({ exposure: e, ownerName }) => ({ kind: "agent", id: e.id, name: e.displayName, mine: false, owner: { name: ownerName } })),
620
+ ...(view.findable ?? []).map(({ exposure: e, ownerName }) => ({ kind: "agent", id: e.id, name: e.displayName, mine: false, discoverable: true, owner: { name: ownerName } }))]
621
+ .filter(e => e.name.toLowerCase().startsWith(q.trim().toLowerCase())).slice(0, 20);
622
+ this.fence(ctx).assertCurrent();
623
+ return this.core.atomic(db => {
624
+ if (!allowed(db))
625
+ throw new HubRoomRefusal(403, "denied");
626
+ return hits.map(row => ({ ...row, ...agentIntro(db, row.id) }));
627
+ }, this.fence(ctx));
628
+ });
620
629
  }
621
630
  if (q.trim().length >= 2 && (kind === "group" && this.core.deps.directory.searchPolicyGroups || kind === "person" && this.core.deps.directory.searchGrantPeople)) {
622
631
  return this.directory.search(ctx, me, q.trim(), kind, () => this.core.atomic(db => {
@@ -632,17 +641,17 @@ export class HubGroupRooms {
632
641
  if (kind !== "person")
633
642
  return [];
634
643
  const prefix = `${q.trim().replace(/[\\%_]/g, c => `\\${c}`)}%`;
635
- return db.prepare("SELECT person,display_name FROM hub_people WHERE status='active' AND (display_name LIKE ? ESCAPE '\\' OR login_label LIKE ? ESCAPE '\\') ORDER BY display_name,person LIMIT 20")
644
+ return db.prepare("SELECT person,display_name,login_label FROM hub_people WHERE status='active' AND (display_name LIKE ? ESCAPE '\\' OR login_label LIKE ? ESCAPE '\\') ORDER BY display_name,person LIMIT 20")
636
645
  .all(prefix, prefix);
637
646
  }, this.fence(ctx));
638
647
  const hits = [];
639
648
  for (const row of rows)
640
649
  if (await this.core.eligible(personFromString(row.person)))
641
- hits.push({ kind: "person", id: row.person, name: row.display_name });
650
+ hits.push({ id: row.person, name: row.display_name, account: row.login_label });
642
651
  return this.core.atomic(db => {
643
652
  if (!allowed(db))
644
653
  throw new HubRoomRefusal(403, "denied");
645
- return kind === "team" ? (this.core.deps.roomTeamCandidates?.(db, q.trim()) ?? []).slice(0, 20).map(row => ({ kind: "team", ...row })) : hits;
654
+ return kind === "team" ? (this.core.deps.roomTeamCandidates?.(db, q.trim()) ?? []).slice(0, 20).map(row => ({ kind: "team", ...row })) : roomPersonLabels(hits);
646
655
  }, this.fence(ctx));
647
656
  }
648
657
  candidateAllowed(ctx, me) {
@@ -1046,6 +1055,53 @@ export class HubGroupRooms {
1046
1055
  this.emit({ type: "message.updated", roomId: id, data: { roomId: id, message: this.projection(done.post) }, sequence: done.post.sequence });
1047
1056
  return { reactions: done.reactions };
1048
1057
  }
1058
+ /**
1059
+ * M-3340: the signed-in person's own pins in a group room — newest first, each with the message as messages() shows it to
1060
+ * them now. A pin whose message they can no longer see (it is older than their joining, or its question is not theirs)
1061
+ * is left out. Nobody else's pins are ever read, and nobody else learns of these.
1062
+ */
1063
+ async pins(ctx, id) {
1064
+ const me = await this.who(ctx);
1065
+ return this.core.atomic(db => ({ pins: this.pinList(db, id, this.member(db, id, me), me) }), this.fence(ctx));
1066
+ }
1067
+ /** M-3340: pin (on) or unpin a message the person can see; answers with their pins. Past ROOM_PINS_MAX: 409 pins-full. */
1068
+ async pin(ctx, id, postId, on) {
1069
+ const target = validated(uuid, postId), me = await this.who(ctx);
1070
+ const out = this.core.atomic(db => {
1071
+ const member = this.member(db, id, me);
1072
+ if (on) {
1073
+ const post = this.visiblePost(db, id, member, target);
1074
+ if (post.author_kind === "system")
1075
+ throw new HubRoomRefusal(409, "invalid");
1076
+ const has = db.prepare("SELECT 1 FROM hub_room_pins WHERE room_id=? AND person=? AND post_id=?").get(id, me, post.id);
1077
+ if (!has && db.prepare("SELECT COUNT(*) n FROM hub_room_pins WHERE room_id=? AND person=?").get(id, me).n >= ROOM_PINS_MAX)
1078
+ throw new HubRoomRefusal(409, "pins-full");
1079
+ if (!has)
1080
+ db.prepare("INSERT INTO hub_room_pins(room_id,person,post_id,pinned_at) VALUES(?,?,?,?)").run(id, me, post.id, this.core.now());
1081
+ }
1082
+ else
1083
+ db.prepare("DELETE FROM hub_room_pins WHERE room_id=? AND person=? AND post_id=?").run(id, me, target);
1084
+ return { pins: this.pinList(db, id, member, me) };
1085
+ }, this.fence(ctx));
1086
+ // The person's other tabs and devices read their pins again; the event says only which room.
1087
+ this.emit({ type: "pins.changed", roomId: id, data: { roomId: id }, audiencePerson: me });
1088
+ return out;
1089
+ }
1090
+ pinList(db, id, member, me) {
1091
+ const rows = db.prepare("SELECT post_id,pinned_at FROM hub_room_pins WHERE room_id=? AND person=? ORDER BY pinned_at DESC,rowid DESC").all(id, me);
1092
+ const out = [];
1093
+ for (const row of rows) {
1094
+ let post;
1095
+ try {
1096
+ post = this.visiblePost(db, id, member, row.post_id);
1097
+ }
1098
+ catch {
1099
+ continue;
1100
+ }
1101
+ out.push({ messageId: row.post_id, pinnedAt: row.pinned_at, message: this.projection(post) });
1102
+ }
1103
+ return out;
1104
+ }
1049
1105
  /**
1050
1106
  * M-3127: a post exactly as messages() shows it to `member` — since their joined_sequence, its lineage's audience floor
1051
1107
  * too (Ridge, M-3118: the descendants of a question older than them stay hidden), and an answer only when its question