@songsid/agend 2.4.0-beta.13 → 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 (172) hide show
  1. package/dist/agent-endpoint.js +28 -6
  2. package/dist/agent-endpoint.js.map +1 -1
  3. package/dist/backend/claude-code.d.ts +9 -0
  4. package/dist/backend/claude-code.js +60 -4
  5. package/dist/backend/claude-code.js.map +1 -1
  6. package/dist/backend/grok.js +11 -0
  7. package/dist/backend/grok.js.map +1 -1
  8. package/dist/backend/types.d.ts +3 -0
  9. package/dist/backend/types.js.map +1 -1
  10. package/dist/backend-availability.d.ts +1 -16
  11. package/dist/backend-availability.js +2 -91
  12. package/dist/backend-availability.js.map +1 -1
  13. package/dist/backend-version-static.d.ts +15 -0
  14. package/dist/backend-version-static.js +95 -0
  15. package/dist/backend-version-static.js.map +1 -0
  16. package/dist/build-provenance.json +1 -1
  17. package/dist/channel/adapters/telegram.js +3 -1
  18. package/dist/channel/adapters/telegram.js.map +1 -1
  19. package/dist/channel/mcp-server.js +18 -1
  20. package/dist/channel/mcp-server.js.map +1 -1
  21. package/dist/channel/tool-router.d.ts +4 -0
  22. package/dist/channel/tool-router.js +43 -19
  23. package/dist/channel/tool-router.js.map +1 -1
  24. package/dist/classic-channel-manager.d.ts +3 -0
  25. package/dist/classic-channel-manager.js +18 -0
  26. package/dist/classic-channel-manager.js.map +1 -1
  27. package/dist/classic-cli-guard.d.ts +66 -0
  28. package/dist/classic-cli-guard.js +209 -0
  29. package/dist/classic-cli-guard.js.map +1 -0
  30. package/dist/cli-audited.js +7 -5
  31. package/dist/cli-audited.js.map +1 -1
  32. package/dist/config-validator.js +3 -0
  33. package/dist/config-validator.js.map +1 -1
  34. package/dist/contact-auth-api.d.ts +16 -0
  35. package/dist/contact-auth-api.js +78 -0
  36. package/dist/contact-auth-api.js.map +1 -0
  37. package/dist/contact-auth-files.d.ts +6 -0
  38. package/dist/contact-auth-files.js +29 -0
  39. package/dist/contact-auth-files.js.map +1 -0
  40. package/dist/contact-auth-policy.d.ts +75 -0
  41. package/dist/contact-auth-policy.js +23 -0
  42. package/dist/contact-auth-policy.js.map +1 -0
  43. package/dist/contact-auth-service.d.ts +32 -0
  44. package/dist/contact-auth-service.js +99 -0
  45. package/dist/contact-auth-service.js.map +1 -0
  46. package/dist/contact-auth-store.d.ts +75 -0
  47. package/dist/contact-auth-store.js +295 -0
  48. package/dist/contact-auth-store.js.map +1 -0
  49. package/dist/contact-auth-types.d.ts +170 -0
  50. package/dist/contact-auth-types.js +7 -0
  51. package/dist/contact-auth-types.js.map +1 -0
  52. package/dist/daemon.d.ts +8 -0
  53. package/dist/daemon.js +93 -4
  54. package/dist/daemon.js.map +1 -1
  55. package/dist/delivery-outbox.d.ts +6 -0
  56. package/dist/delivery-outbox.js +19 -0
  57. package/dist/delivery-outbox.js.map +1 -1
  58. package/dist/fleet-manager.d.ts +40 -0
  59. package/dist/fleet-manager.js +429 -22
  60. package/dist/fleet-manager.js.map +1 -1
  61. package/dist/general-knowledge/skills/concepts/SKILL.md +18 -0
  62. package/dist/general-knowledge/skills/credential-profiles/SKILL.md +5 -0
  63. package/dist/general-knowledge/skills/cross-instance-messaging/SKILL.md +28 -0
  64. package/dist/general-knowledge/skills/hub/SKILL.md +6 -0
  65. package/dist/hub/audit/index.d.ts +3 -1
  66. package/dist/hub/audit/index.js +35 -3
  67. package/dist/hub/audit/index.js.map +1 -1
  68. package/dist/hub/catalog.d.ts +8 -0
  69. package/dist/hub/catalog.js +39 -4
  70. package/dist/hub/catalog.js.map +1 -1
  71. package/dist/hub/compose/server.d.ts +2 -0
  72. package/dist/hub/compose/server.js +11 -1
  73. package/dist/hub/compose/server.js.map +1 -1
  74. package/dist/hub/directory/directory.js +5 -2
  75. package/dist/hub/directory/directory.js.map +1 -1
  76. package/dist/hub/directory/types.d.ts +5 -1
  77. package/dist/hub/directory/types.js.map +1 -1
  78. package/dist/hub/group-policy/resources.d.ts +1 -1
  79. package/dist/hub/http/compose.d.ts +2 -0
  80. package/dist/hub/http/compose.js +123 -6
  81. package/dist/hub/http/compose.js.map +1 -1
  82. package/dist/hub/http/deps.d.ts +2 -0
  83. package/dist/hub/http/schema.js +6 -1
  84. package/dist/hub/http/schema.js.map +1 -1
  85. package/dist/hub/invitations.js +15 -7
  86. package/dist/hub/invitations.js.map +1 -1
  87. package/dist/hub/roles/cutover-inventory.d.ts +3 -0
  88. package/dist/hub/roles/cutover-inventory.js +20 -4
  89. package/dist/hub/roles/cutover-inventory.js.map +1 -1
  90. package/dist/hub/roles/cutover-marker.d.ts +18 -2
  91. package/dist/hub/roles/cutover-marker.js +6 -2
  92. package/dist/hub/roles/cutover-marker.js.map +1 -1
  93. package/dist/hub/room-agent-discovery-model.d.ts +29 -0
  94. package/dist/hub/room-agent-discovery-model.js +33 -0
  95. package/dist/hub/room-agent-discovery-model.js.map +1 -0
  96. package/dist/hub/room-agent-discovery.d.ts +14 -0
  97. package/dist/hub/room-agent-discovery.js +65 -0
  98. package/dist/hub/room-agent-discovery.js.map +1 -0
  99. package/dist/hub/room-agent-requests.d.ts +71 -0
  100. package/dist/hub/room-agent-requests.js +377 -0
  101. package/dist/hub/room-agent-requests.js.map +1 -0
  102. package/dist/hub/rooms/directory.d.ts +13 -0
  103. package/dist/hub/rooms/directory.js +12 -3
  104. package/dist/hub/rooms/directory.js.map +1 -1
  105. package/dist/hub/rooms/schema.d.ts +5 -0
  106. package/dist/hub/rooms/schema.js +9 -0
  107. package/dist/hub/rooms/schema.js.map +1 -1
  108. package/dist/hub/rooms/service.d.ts +43 -19
  109. package/dist/hub/rooms/service.js +67 -11
  110. package/dist/hub/rooms/service.js.map +1 -1
  111. package/dist/hub/rooms/types.d.ts +1 -1
  112. package/dist/instance-lifecycle.d.ts +3 -1
  113. package/dist/instance-lifecycle.js +4 -1
  114. package/dist/instance-lifecycle.js.map +1 -1
  115. package/dist/locale.js +28 -4
  116. package/dist/locale.js.map +1 -1
  117. package/dist/needs-you-hub.d.ts +1 -0
  118. package/dist/needs-you-hub.js +6 -0
  119. package/dist/needs-you-hub.js.map +1 -1
  120. package/dist/needs-you.d.ts +10 -2
  121. package/dist/needs-you.js.map +1 -1
  122. package/dist/outbound-handlers.d.ts +9 -0
  123. package/dist/outbound-handlers.js +46 -10
  124. package/dist/outbound-handlers.js.map +1 -1
  125. package/dist/runtime-cli-install.js +7 -7
  126. package/dist/runtime-cli-install.js.map +1 -1
  127. package/dist/topic-commands.d.ts +1 -1
  128. package/dist/topic-commands.js +4 -6
  129. package/dist/topic-commands.js.map +1 -1
  130. package/dist/ui/agent-details-settings.js +7 -5
  131. package/dist/ui/contact-auth-client.js +48 -0
  132. package/dist/ui/contact-auth-strings.js +164 -0
  133. package/dist/ui/contact-authorizations.js +125 -0
  134. package/dist/ui/contact-needs.js +84 -0
  135. package/dist/ui/contact-permissions.js +193 -0
  136. package/dist/ui/contact-ticket-badge.js +54 -0
  137. package/dist/ui/hub-client.js +30 -7
  138. package/dist/ui/hub-invitations.js +5 -1
  139. package/dist/ui/hub-room-new.js +10 -3
  140. package/dist/ui/hub-room-owner-requests-strings.js +114 -0
  141. package/dist/ui/hub-room-owner-requests.js +264 -0
  142. package/dist/ui/hub-room-pins.js +43 -0
  143. package/dist/ui/hub-room-settings.js +11 -2
  144. package/dist/ui/hub-room-strings.js +3 -0
  145. package/dist/ui/hub-room-thread.js +47 -5
  146. package/dist/ui/panel-chat.js +2 -0
  147. package/dist/ui/panel-details.js +2 -0
  148. package/dist/ui/panel-fleet.js +3 -2
  149. package/dist/ui/panel-hub.js +7 -1
  150. package/dist/ui/panel-needs.js +5 -1
  151. package/dist/ui/panel-settings.js +3 -0
  152. package/dist/ui/shared/app-route.js +1 -1
  153. package/dist/ui/shared/app-shell.js +2 -0
  154. package/dist/ui/shared/app-stream.js +3 -1
  155. package/dist/ui/shared/app.css +31 -0
  156. package/dist/ui/shared/chat-quote.js +26 -2
  157. package/dist/ui/shared/chat-thread.js +6 -2
  158. package/dist/ui/shared/hub-rooms-u2.css +22 -0
  159. package/dist/ui/shared/text-undo.js +17 -3
  160. package/dist/web-api.d.ts +9 -0
  161. package/dist/web-api.js +55 -3
  162. package/dist/web-api.js.map +1 -1
  163. package/dist/web-chat-history.d.ts +5 -0
  164. package/dist/web-chat-history.js +26 -0
  165. package/dist/web-chat-history.js.map +1 -1
  166. package/dist/web-reply-files.d.ts +1 -0
  167. package/dist/web-reply-files.js +2 -0
  168. package/dist/web-reply-files.js.map +1 -1
  169. package/dist/web-shell-routes.d.ts +1 -1
  170. package/dist/web-shell-routes.js +2 -1
  171. package/dist/web-shell-routes.js.map +1 -1
  172. package/package.json +1 -1
@@ -0,0 +1,43 @@
1
+ // M-3340 (the user: personal pins): a Hub room's pinned messages — each person's own, kept on the Hub per person per room
2
+ // (GET/PUT/DELETE /hub/v1/rooms/<id>/pins; room-pins-v1), never shown to anyone else in the room. The Fleet chat's pin UX
3
+ // (#4095, chat-pins.js — its look, its words): Pin / Unpin in a message's menu, the header's 📌 with the count, and the
4
+ // list (newest first; a row shows its message in the room, flashed; × unpins it). At most 50 per room.
5
+ // A Hub module: imports only the shared /assets/ (never the Fleet's chat-pins.js); the room store (hub-room-thread.js)
6
+ // holds the list and answers pin/unpin.
7
+ import { html } from "/assets/app-html.js";
8
+ import { lang, t } from "/assets/app-i18n.js";
9
+ import { Dialog } from "/assets/ui-dialog.js";
10
+ import { Icon } from "/assets/ui-icons.js";
11
+ import { hroom } from "./hub-room-strings.js";
12
+
13
+ /** The Hub's limit per person per room (src/hub/rooms/service.ts ROOM_PINS_MAX). */
14
+ export const ROOM_PINS_MAX = 50;
15
+
16
+ const when = (ms) => { const d = new Date(ms); return Number.isFinite(d.getTime()) ? d.toLocaleString(lang(), { dateStyle: "medium", timeStyle: "short" }) : ""; };
17
+ const snippet = (s, n = 40) => { const one = String(s || "").replace(/\s+/g, " ").trim(); return one.length > n ? `${one.slice(0, n - 1)}…` : one; };
18
+ const textOf = (m) => String(m?.text || "");
19
+ const filesOf = (m) => (Array.isArray(m?.files) ? m.files.map((f) => f && f.name).filter(Boolean) : []);
20
+
21
+ /** The header's 📌 with the count: only when I have a pin in this room. */
22
+ export function RoomPinsButton({ count, onOpen }) {
23
+ if (!count) return null;
24
+ const label = t("chat.pinsButton", String(count));
25
+ return html`<button type="button" class="btn btn-ghost btn-sm chat-pins-btn hub-room-pins-btn" title=${label} aria-label=${label} onClick=${() => onOpen?.()}>
26
+ <${Icon} name="pin" size=${16} /><span class="chat-pins-count" aria-hidden="true">${count}</span></button>`;
27
+ }
28
+
29
+ /** The list: newest pin first; a row shows its message (`onJump(pin)`), its × unpins it (`onUnpin(pin)`). Only mine. */
30
+ export function RoomPinsDialog({ pins, onClose, onJump, onUnpin }) {
31
+ return html`<${Dialog} title=${`${t("chat.pinsTitle")} · ${pins.length}`} onClose=${onClose} cls="chat-pins-dlg hub-room-pins-dlg">
32
+ <p class="note hub-room-pins-only">${hroom("pinsOnlyYou")}</p>
33
+ ${pins.length ? html`<ul class="chat-pins">${pins.map((p) => html`<li key=${p.messageId} class="chat-pin" data-message=${p.messageId}>
34
+ <button type="button" class="chat-pin-go" title=${t("chat.pinShow")} onClick=${() => onJump?.(p)}>
35
+ <span class="chat-pin-meta"><strong>${String(p.message?.author?.name || "")}</strong><time datetime=${new Date(p.message?.at || 0).toISOString()}>${when(p.message?.at)}</time></span>
36
+ <span class="chat-pin-text">${textOf(p.message)}</span>
37
+ ${filesOf(p.message).length ? html`<span class="chat-pin-files">${t("chat.pinFiles", filesOf(p.message).join(", "))}</span>` : null}
38
+ </button>
39
+ <button type="button" class="icon-btn chat-pin-x" title=${t("chat.unpin")} aria-label=${t("chat.pinUnpin", snippet(textOf(p.message)))}
40
+ onClick=${() => onUnpin?.(p)}><${Icon} name="close" size=${14} /></button>
41
+ </li>`)}</ul>` : html`<p class="note">${t("chat.pinsEmpty")}</p>`}
42
+ </${Dialog}>`;
43
+ }
@@ -17,6 +17,8 @@ import { hroom } from "./hub-room-strings.js";
17
17
  import { hs } from "./hub-room-settings-strings.js";
18
18
  import {ha} from "./hub-ai-apps-strings.js";
19
19
  import { RoomPicker } from "./hub-room-new.js";
20
+ import { OwnerAgentRequestDialog, OwnerAgentRequestRows } from "./hub-room-owner-requests.js";
21
+ import { hrq } from "./hub-room-owner-requests-strings.js";
20
22
  import { hn, linkRoomsU2Css } from "./hub-room-new-strings.js";
21
23
 
22
24
  linkRoomsU2Css();
@@ -42,6 +44,8 @@ export function invitedLabel(row) {
42
44
  export function RoomSettings({ client = hubClient(), roomId, detail, onClose, onChanged, assistant } = {}) {
43
45
  const room = detail?.room ?? {}, settings = detail?.settings ?? {}, members = Array.isArray(detail?.members) ? detail.members : [];
44
46
  const invited = Array.isArray(detail?.invited) ? detail.invited : [];
47
+ const [askOwner, setAskOwner] = useState(false);
48
+ const ownerRequestsLive = settings.ownerAgentRequests === true && typeof client.requestRoomAgent === "function";
45
49
  const [purpose,setPurpose]=useState(room.purpose??"");
46
50
  useEffect(()=>setPurpose(room.purpose??""),[roomId,room.purpose]);
47
51
  const purposeSupported=client.roomPurposeV1===true&&typeof room.purpose==="string"&&detail?.me?.role==="manager";
@@ -138,12 +142,17 @@ export function RoomSettings({ client = hubClient(), roomId, detail, onClose, on
138
142
  ? html`<button type="button" class="btn btn-link" disabled=${busy} onClick=${() => { void act(async () => { const r = await client.inviteToRoom(roomId, { agents: [row.exposureId] }); if (r?.ok) await client.cancelRoomInvitation(roomId, row.id); return r; }); }}>${hs("inviteAgain")}</button>`
139
143
  : html`<button type="button" class="btn btn-link" disabled=${busy} onClick=${() => { void act(() => client.cancelRoomInvitation(roomId, row.id)); }}>${hroom("cancelInvite")}</button>`}</li>`)}</ul>` : null}
140
144
  <${RoomPicker} client=${client} id="hubRoomAddAgents" kinds=${["agent", "team"]} label=${hroom("addOrInviteAgents")} placeholder=${hroom("addAgents")}
141
- picked=${addAgents} exclude=${taken} onChange=${(next) => { void add(next, setAddAgents); }} />
145
+ picked=${addAgents} exclude=${taken} onChange=${(next) => { void add(next, setAddAgents); }}
146
+ searchHelp=${ownerRequestsLive ? html`<p class="note hub-owner-request-entry">${hrq("missing")}
147
+ <button type="button" class="btn btn-link" disabled=${busy} onClick=${() => setAskOwner(true)}>${hrq("ask")}</button></p>` : null} />
148
+ ${ownerRequestsLive ? html`<${OwnerAgentRequestRows} client=${client} roomId=${roomId} page=${detail.agentRequests} onChanged=${onChanged} busy=${busy} />` : null}
142
149
  ${offered || hasAssistant ? html`<label class="check"><input id="hubRoomSettingsAssistant" class="s-ui-toggle" type="checkbox" role="switch" checked=${hasAssistant} disabled=${busy}
143
150
  onChange=${(e) => { const v = e.target.checked, id = members.find(m => m.kind === "assistant")?.id; void act(() => v ? client.addRoomMember(roomId, { kind: "assistant" }) : client.removeRoomMember(roomId, id)); }} /><span>${hs("assistantSwitch")}</span></label>` : null}
144
151
  </section>
145
152
  <section class="form"><h4>${hroom("other")}</h4>
146
153
  <button type="button" class="btn btn-danger" disabled=${busy || room.archived === true} onClick=${() => { void archive(); }}>${hroom("archiveRoom")}</button>
147
154
  </section>
148
- </${Dialog}>`;
155
+ </${Dialog}>
156
+ ${askOwner && ownerRequestsLive ? html`<${OwnerAgentRequestDialog} key=${roomId} client=${client} roomId=${roomId} roomName=${room.name}
157
+ onClose=${() => setAskOwner(false)} onSent=${() => onChanged?.()} />` : null}`;
149
158
  }
@@ -27,6 +27,8 @@ register("hubRoom", {
27
27
  // M-3127 reactions: who reacted ("Alex, Bob and 3 others reacted with 👍"), the add button, the picker
28
28
  reactAdd: "Add reaction", reactPick: "Reactions", reactedWith: "{0} reacted with {1}", reactMore: "{0} and {1} others",
29
29
  reactYou: "You", listSep: ", ", reactFailed: "Couldn't add the reaction. Try again.",
30
+ // M-3340: personal pins (the Fleet chat's words for the rest: chat.pin…)
31
+ pinsOnlyYou: "Only you see your pins.", pinsFull: "You already have {0} pinned messages in this room — unpin one first.",
30
32
  // M-3127 B: an agent's buttons (its asker's) and polls (everyone's)
31
33
  onlyAsker: "Only {0} can answer", sysPollClosed: "{0}'s poll closed", buttonFailed: "That didn't go through. Try again.",
32
34
  buttonNotAsker: "Only the person who asked can answer these buttons.", buttonExpired: "These buttons are no longer open.",
@@ -163,6 +165,7 @@ register("hubRoom", {
163
165
  allAnswered: "{0} 個都回答了", expandRest: "展開其餘 {0} 則",
164
166
  reactAdd: "加上表情", reactPick: "表情回應", reactedWith: "{0} 回應了 {1}", reactMore: "{0} 和其他 {1} 人",
165
167
  reactYou: "你", listSep: "、", reactFailed: "表情沒加上,請再試一次。",
168
+ pinsOnlyYou: "只有你看得到你的釘選。", pinsFull: "你在這個房間已有 {0} 則釘選訊息——請先取消一則。",
166
169
  onlyAsker: "只有 {0} 能回答", sysPollClosed: "{0} 的投票已結束", buttonFailed: "沒有送出,請再試一次。",
167
170
  buttonNotAsker: "只有提問的人能按這些按鈕。", buttonExpired: "這些按鈕已經關閉。",
168
171
  searchLabel: "搜尋", searchPlaceholder: "搜尋房間、聊天與訊息…", searchClose: "關閉",
@@ -36,6 +36,7 @@ import { roomSource, mountSourceAuthor } from "./hub-room-source.js";
36
36
  import { countsLine } from "./hub-room-list.js";
37
37
  import { DropOverlay, MAX_FILES, PendingFiles, hf, hubFileAttachment, pageCarriesFiles, putBackText, roomTakesFiles, uploadChosen, useFileDrop } from "./hub-attachments.js";
38
38
  import { LightboxHost, openLightbox } from "/assets/image-lightbox.js";
39
+ import { ROOM_PINS_MAX, RoomPinsButton, RoomPinsDialog } from "./hub-room-pins.js";
39
40
  // M-3125 PR3: the one quote target an annotated room picture has (here, so a page with an older dictionary has the words).
40
41
  register("hubRoomAnnotate", { en: { quote: "Quote in this room" }, "zh-TW": { quote: "引用到這個房間" } });
41
42
 
@@ -220,9 +221,10 @@ export function toThreadMessages(messages, { meId, ids, direct = false, expanded
220
221
  * `send(text, { mentions, replyTo })` → the client's answer (a refusal's code is the caller's to word; a soft warning is
221
222
  * stored and drawn), `older()`, `findQuoted(key)`, `markRead()`, `refresh()`, `stop()`. M-3127 B: `clickButton` / `vote` / `busy` / `mine` are the direct chat's button actions (hub-button-actions.js), on group rooms only.
222
223
  */
223
- export function createRoomStore(roomId, { client, meId = "" } = {}) {
224
+ export function createRoomStore(roomId, { client, meId = "", pinsOn = false } = {}) {
224
225
  const subs = new Set(), ids = new Map(), expanded = new Set();
225
- const st = { live: true, detail: null, messages: [], loaded: false, error: null, removed: false, more: false, view: [] };
226
+ // M-3340: `pins` — my own pins in this group room (null: this Hub offers none, or not read yet); nobody else's, ever.
227
+ const st = { live: true, detail: null, messages: [], loaded: false, error: null, removed: false, more: false, view: [], pins: null };
226
228
  let loadingOlder = false;
227
229
  // The room's committed order (Ridge: `sequence`, from the stored row): a waiting answer replaced in place, or an event that
228
230
  // arrives out of order, is drawn where the room has it. Rows without it (a direct chat, an older Hub) keep arrival order.
@@ -245,6 +247,14 @@ export function createRoomStore(roomId, { client, meId = "" } = {}) {
245
247
  if (page.ok) { for (const m of page.messages || []) upsert(m); st.more = page.more === true; st.loaded = true; if (d.ok) st.error = null; }
246
248
  else st.error = page.code || "failed";
247
249
  changed();
250
+ void readPins();
251
+ }
252
+ /** M-3340: my pins, read again (opening the room; my other tab or device changed them: pins.changed). A group room only. */
253
+ async function readPins() {
254
+ if (!pinsOn || typeof client.roomPins !== "function" || st.detail?.room?.kind !== "group") return;
255
+ const r = await client.roomPins(roomId);
256
+ if (!st.live) return;
257
+ if (r?.ok && Array.isArray(r.pins)) { st.pins = r.pins.filter((p) => p && typeof p.messageId === "string"); changed(); }
248
258
  }
249
259
  const on = (fn) => (data) => { if (st.live && data && data.roomId === roomId) { fn(data); changed(); } };
250
260
  // M-3127 B: an answer's buttons and polls — the direct chat's own actions (one key per intent, my vote kept in this tab),
@@ -260,6 +270,7 @@ export function createRoomStore(roomId, { client, meId = "" } = {}) {
260
270
  "presence.changed": on((d) => { const m = st.detail?.members?.find((x) => x.id === d.memberId); if (m) { m.presence = d.presence;
261
271
  for (const k of ["presenceNote", "presenceReason"]) { if (d[k]) m[k] = d[k]; else delete m[k]; } } }),
262
272
  "member.changed": on(() => { void readDetail().then(changed); }),
273
+ "pins.changed": on(() => { void readPins(); }),
263
274
  "room.changed": on((d) => { if (d.removed) st.removed = true; else if (d.room && st.detail) st.detail = { ...st.detail, room: { ...st.detail.room, ...d.room } }; }),
264
275
  }) : () => {};
265
276
  /** One page older than what is held (the server's `before=`). False when there was nothing to fetch. */
@@ -349,6 +360,17 @@ export function createRoomStore(roomId, { client, meId = "" } = {}) {
349
360
  if (st.live && r?.ok && m && Array.isArray(r.reactions)) { if (r.reactions.length) m.reactions = r.reactions; else delete m.reactions; changed(); }
350
361
  return r;
351
362
  },
363
+ /** M-3340: my pins (newest first: { messageId, pinnedAt, message }); offered when this Hub keeps them for me. */
364
+ pins: () => st.pins || [],
365
+ pinsOffered: () => Array.isArray(st.pins),
366
+ isPinned: (messageId) => (st.pins || []).some((p) => p.messageId === messageId),
367
+ /** Pin (on) or unpin a message for me only; the Hub answers with my pins → the client's answer (pins-full past 50). */
368
+ async setPin(messageId, on) {
369
+ if (!Array.isArray(st.pins) || typeof client.pinRoomMessage !== "function") return { ok: false, code: "unavailable" };
370
+ const r = await client.pinRoomMessage(roomId, messageId, on);
371
+ if (st.live && r?.ok && Array.isArray(r.pins)) { st.pins = r.pins.filter((p) => p && typeof p.messageId === "string"); changed(); }
372
+ return r;
373
+ },
352
374
  markRead() { const last = st.messages.at(-1); return last ? client.markRoomRead(roomId, last.id) : Promise.resolve({ ok: true }); },
353
375
  refresh, clickButton: actions.clickButton, vote: actions.vote, busy: actions.busy, mine: actions.mine,
354
376
  stop() { st.live = false; subs.clear(); unsubscribe(); actions.stop(); },
@@ -378,8 +400,9 @@ function useMembersPanel() {
378
400
  * Fleet chat's thread (panel-hub.js's HubThread, given as `Thread`: the thread wiring is one), the room's composer, and
379
401
  * the members panel on the right. `client`: the Hub client; `me`: { id } from the session.
380
402
  */
381
- export function HubRoomPage({ roomId, listed = null, Thread, client, meId = "", rooms = [], openRoom = () => {}, goList = () => {}, onLeft = () => {}, onMe = () => {} }) {
382
- const store = useMemo(() => createRoomStore(roomId, { client, meId }), [roomId]);
403
+ export function HubRoomPage({ roomId, listed = null, Thread, client, meId = "", rooms = [], openRoom = () => {}, goList = () => {}, onLeft = () => {}, onMe = () => {}, pinsOn = false }) {
404
+ const store = useMemo(() => createRoomStore(roomId, { client, meId, pinsOn }), [roomId]);
405
+ const [pinsOpen, setPinsOpen] = useState(false);
383
406
  useEffect(() => () => store.stop(), [store]);
384
407
  const [, tick] = useState(0);
385
408
  // The first read may land before this subscribes: read once more on subscribing.
@@ -506,13 +529,31 @@ export function HubRoomPage({ roomId, listed = null, Thread, client, meId = "",
506
529
  quote: { field: () => input.current, can: () => !store.closed() },
507
530
  // M-3311 (3): the Fleet chat's Copy link — a room message's address (opening it shows that message).
508
531
  linkOf: roomLinkOf(roomId),
532
+ // M-3340: the Fleet chat's Pin / Unpin — mine only (read when the menu opens: the pins arrive after the first render).
533
+ pin: (x) => { void togglePin(x.roomMessage); },
534
+ pinned: (x) => store.isPinned(x.roomMessage),
535
+ canPin: (x) => store.pinsOffered() && !!x.roomMessage && x.role !== "status",
509
536
  };
537
+ // M-3340: pin or unpin a message for me; said in a toast either way (as the Fleet chat says it).
538
+ async function togglePin(messageId) {
539
+ const on = !store.isPinned(messageId), r = await store.setPin(messageId, on);
540
+ if (r?.ok) toast(t(on ? "chat.pinned" : "chat.unpinned"));
541
+ else toast(r?.code === "pins-full" ? hroom("pinsFull", String(ROOM_PINS_MAX)) : t("chat.pinFailed"), false);
542
+ }
543
+ const pinCount = store.pinsOffered() ? store.pins().length : 0;
544
+ // M-3340: a pin's message in the room — loaded back to it, scrolled to and flashed (the search hit's way); gone: said.
545
+ async function showPin(pin) {
546
+ setPinsOpen(false);
547
+ const key = await store.find(pin.messageId);
548
+ if (key) setTimeout(() => threadRef.current?.reveal(key), 60); else toast(hroom("jumpMissing"), false);
549
+ }
510
550
  // M-3311 (3): the header's menu — a group room's Room settings and Leave, and on a desk the Fleet chat's 「全寬」 for any room.
511
551
  const [fullWidth, setFullWidth] = useState(hubChatWide);
512
552
  const textSize = useStore(textSizeStore), notify = useStore(notifyStore), narrow = useNarrowScreen();
513
553
  const menuItems = [
514
554
  group && detail?.me?.role === "manager" ? { key: "settings", label: hroom("roomSettings"), icon: "settings", onSelect: openSettings } : null,
515
555
  group && detail?.me ? { key: "leave", label: hroom("leaveRoom"), icon: "close", onSelect: () => { void leave(); } } : null,
556
+ pinCount ? { key: "pins", label: `${t("chat.pinsTitle")} · ${pinCount}`, icon: "pin", onSelect: () => setPinsOpen(true) } : null,
516
557
  !narrow && detail?.me ? { key: "fullWidth", checkbox: true, checked: fullWidth, label: t("chat.fullWidth"), onSelect: () => { setHubChatWide(!fullWidth); setFullWidth(!fullWidth); } } : null,
517
558
  // M-3311 (4): a phone's header is one row (back, the room, members, ⋯) as the Fleet chat's — its text size and Notify
518
559
  // move into ⋯ there (hub-chat.css hides the two buttons at the same width).
@@ -533,6 +574,7 @@ export function HubRoomPage({ roomId, listed = null, Thread, client, meId = "",
533
574
  onSettings=${() => { setSheet(false); openSettings(); }} />` : null;
534
575
  return html`<div class=${`hub-chat hub-room-page${showRail ? " with-rail" : ""}`} data-room=${roomId} data-width=${fullWidth ? "full" : undefined}>
535
576
  <${LightboxHost} />
577
+ ${pinsOpen ? html`<${RoomPinsDialog} pins=${store.pins()} onClose=${() => setPinsOpen(false)} onJump=${(p) => void showPin(p)} onUnpin=${(p) => void togglePin(p.messageId)} />` : null}
536
578
  <section class="hub-chat-main" ref=${mainRef}>
537
579
  ${attach ? html`<${DropOverlay} />` : null}
538
580
  <header class=${`hub-chat-head${room.agent?.answerOnly?" hub-answer-only-head":""}`} data-trust="panel-content">
@@ -541,7 +583,7 @@ export function HubRoomPage({ roomId, listed = null, Thread, client, meId = "",
541
583
  onClick=${(e) => { if (e.metaKey || e.ctrlKey) return; e.preventDefault(); goList(); }}><${Icon} name="back" /></a>
542
584
  <span class=${`av${group ? " av-square" : ""}`} aria-hidden="true"><span class="av-text">${firstCharacter(title || "?") || "?"}</span></span>
543
585
  <span class="hub-chat-title"><strong>${title}</strong>${group&&typeof room.purpose==="string"?html`<${RoomPurposeHeader} purpose=${room.purpose} onEdit=${detail?.me?.role==="manager"&&client.roomPurposeV1===true?openSettings:undefined} />`:null}<span class=${`s${room.agent?.answerOnly?" hub-answer-only-note":""}`}>${line2}</span>${room.assistant||room.agent?.intro?html`<span class="s hub-agent-intro-line">${room.assistant?hi("assistant"):room.agent.intro}</span>`:null}</span>
544
- <span class="hub-head-tools"><${TextSizeButton} /><${HubNotifyToggle} /></span>
586
+ <span class="hub-head-tools"><${RoomPinsButton} count=${pinCount} onOpen=${() => setPinsOpen(true)} /><${TextSizeButton} /><${HubNotifyToggle} /></span>
545
587
  ${group && Panel ? html`<button type="button" class="icon-btn hub-room-rail-toggle" aria-pressed=${(wide ? rail : sheet) ? "true" : "false"} title=${hroom("members")} aria-label=${hroom("members")}
546
588
  onClick=${() => (wide ? setRail(!rail) : setSheet(true))}><${Icon} name="team" size=${18} /></button>` : null}
547
589
  ${menuItems.length ? html`<${Menu} cls="hub-room-menu" label=${hroom("menu")} fit=${true} ownerKey=${roomId} items=${menuItems} />` : null}
@@ -166,6 +166,7 @@ import { ComposerInput, WorkBarView, touchScreen } from "/assets/chat-composer.j
166
166
  import { installMessageActions } from "/assets/chat-msg-actions.js";
167
167
  import { composerCaret, insertQuote, installQuoteSelection, showCaret } from "./chat-quote.js";
168
168
  import { installTableSelection } from "/assets/chat-table-select.js";
169
+ import { contactBadgeHtml, installBadgeRefresh } from "./contact-ticket-badge.js";
169
170
  import { createEmojiIndex } from "./chat-emojis.js";
170
171
  import { pollPublicPreview } from "./preview-status.js";
171
172
  import { createMentionIndex } from "./chat-mentions.js";
@@ -759,6 +760,7 @@ function threadEntry(name, doc) {
759
760
  onEmpty: (v) => e.sink?.setEmpty(v && store.allHidden(name) ? "hidden" : v),
760
761
  setPreviewOptIn, copyText, download: downloadHtml, toggleWrap,
761
762
  clickReplyButton: (id, index) => store.clickReplyButton(name, id, index), // #1266
763
+ contactBadge: (x) => { installBadgeRefresh(); return contactBadgeHtml(x); }, // M-3339: 聯絡申請 #R… / 已准轉交 #R… (kept current)
762
764
  retryOutgoing: (clientId) => store.retryOutgoing(name, clientId), // a failed send's Retry and Delete
763
765
  deleteOutgoing: (clientId) => store.deleteOutgoing(name, clientId),
764
766
  putBackOutgoing: (clientId) => { recordEdit(composerField(name)); store.putBackOutgoing(name, clientId); }, // undoable, as typing
@@ -33,6 +33,7 @@ import { api } from "./settings-confirm.js";
33
33
  import { InstanceBoardWork } from "./fleet-task-work.js";
34
34
  import { Icon } from "/assets/ui-icons.js";
35
35
  import { AgentCategoryNav, AgentPageHead, AgentSettingsPanels, agentKind, categoryFromSearch, useAgentSettings } from "./agent-details-settings.js";
36
+ import { ContactPermissionsPanel } from "./contact-permissions.js";
36
37
  import "./agent-page-strings.js";
37
38
  import { pt } from "./agent-page-strings.js";
38
39
 
@@ -201,6 +202,7 @@ function DetailsView({ name, inst, navKey, exec, awaiting }) {
201
202
  <div class="s-section-layout" data-agent-category=${shownCat}>
202
203
  <div class="ap-panel" id=${pane ? `pane-${pane.id}-ap-panel-overview` : "ap-panel-overview"} hidden=${shownCat !== "overview"}>${overview}</div>
203
204
  ${opened ? html`<${AgentSettingsPanels} name=${name} kind=${kind} cat=${shownCat} sess=${sess} onDirty=${onDirty} />` : null}
205
+ ${shownCat === "permissions" ? html`<div class="ap-panel" id=${pane ? `pane-${pane.id}-ap-panel-permissions` : "ap-panel-permissions"}><${ContactPermissionsPanel} key=${name} name=${name} /></div>` : null}
204
206
  </div></div></div>
205
207
  ${sess.staged.size && Pending ? html`<${Pending} staged=${sess.staged} busy=${!!sess.op && ["writing", "posting", "watching"].includes(sess.op.phase)} onApply=${sess.apply} onDiscard=${sess.discard} section="agents" />` : null}
206
208
  </div>`;
@@ -20,6 +20,7 @@ import { ClaudeAccountSelect, accountCli } from "./credential-profile-select.js"
20
20
  import { AccountSelect } from "./accounts-view.js"; // the same Account field as the agent dialog (a new module: never a stale named import)
21
21
  import { capsOf } from "./cli-caps.js";
22
22
  import { chatPath, fleetPath, FLEET_TABS, rememberFleetTab } from "/assets/app-route.js";
23
+ import { ContactAuthorizations } from "./contact-authorizations.js";
23
24
  import { Dialog } from "/assets/ui-dialog.js";
24
25
  import { Empty, ErrorState, Skeleton } from "/assets/ui-states.js";
25
26
  import { Icon } from "/assets/ui-icons.js";
@@ -104,7 +105,7 @@ const DOCS_SITE = "https://songsid.github.io/AgEnD";
104
105
  export function docsUrl(language = lang()) {
105
106
  return `${DOCS_SITE}${language === "zh-TW" ? "/zh-tw" : ""}/docs/web-guide/`;
106
107
  }
107
- const ICONS = { tasks: "tasks", schedules: "clock", teams: "team", org: "org", cache: "chart", usage: "chart" };
108
+ const ICONS = { tasks: "tasks", schedules: "clock", teams: "team", org: "org", cache: "chart", usage: "chart", authorizations: "key" };
108
109
  const BACKENDS = ["claude-code", "codex", "opencode", "kiro-cli", "antigravity", "grok", "muse"];
109
110
 
110
111
  async function api(method, path, body, lease) {
@@ -212,7 +213,7 @@ export function FleetPanel({ route, navKey }) {
212
213
  const tab = route.tab;
213
214
  useEffect(() => { setTitle(`${t("fleet.title")} · ${t(`fleet.${tab}`)}`); }, [tab, navKey]);
214
215
  useEffect(() => { rememberFleetTab(tab); }, [tab]); // #2183: the sidebar's and the phone's Fleet reopen it
215
- const Body = { tasks: TaskBoardTab, schedules: Schedules, teams: Teams, org: Org, cache: Cache, usage: UsageTab }[tab] || TaskBoardTab;
216
+ const Body = { tasks: TaskBoardTab, schedules: Schedules, teams: Teams, org: Org, cache: Cache, usage: UsageTab, authorizations: ContactAuthorizations }[tab] || TaskBoardTab;
216
217
  // #1685: host memory pressure slowing or holding new agents — shown here, where macOS's routine "elevated" is not a chat notice.
217
218
  const { hostMemory, hostMemoryTop } = useStore(appStore);
218
219
  // #2015: and which processes hold the most, and whose — text only (never chat, #1712).
@@ -590,7 +590,7 @@ function HubChats() {
590
590
  // A room of a Hub with rooms: the shared thread with the room's store, composer and members panel (hub-room-thread.js).
591
591
  if (id && listed && !listed.legacy) return html`<${HubRoomPage} key=${id} roomId=${id} listed=${listed} Thread=${HubThread} client=${hubClient()}
592
592
  rooms=${rs.rooms} openRoom=${(rid) => navigate(roomPath(rid))} goList=${() => navigate("/ui/hub")}
593
- onLeft=${() => { void refreshRooms(); navigate("/ui/hub"); }} onMe=${noteHubMeId} />`;
593
+ onLeft=${() => { void refreshRooms(); navigate("/ui/hub"); }} onMe=${noteHubMeId} pinsOn=${roomPinsLive()} />`;
594
594
  if (id && room) return html`<${HubRoomView} key=${id} room=${room} />`;
595
595
  if (id) return html`<${HubRoomLoading} error=${rs.error} />`;
596
596
  if (opening && (!rs.loaded || recentRoom(rs.rooms))) return html`<${PanelHeader} title=${hc("chats")} /><div class="hub-home"><div class="hub-home-pick center"><${Skeleton} variant="rows" lines=${4} /></div></div>`;
@@ -910,6 +910,8 @@ function HubThread({ store, name, panelKey, threadRef, extra = null, emptyView =
910
910
  ...(typeof ex.react === "function" ? { react: (x) => thread.pickReaction?.(msgKey(x)), canReact: (x) => !!x.roomMessage && ex.canReact?.(x) !== false, reactLabel: ex.reactLabel } : {}),
911
911
  // M-3311 (3): Copy link where the page gives a message an address (a room: extra.linkOf).
912
912
  ...(typeof ex.linkOf === "function" ? { linkOf: (x) => ex.linkOf(x) } : {}),
913
+ // M-3340: Pin / Unpin where the page keeps pins (a room of a Hub with room-pins-v1: extra.pin), mine only.
914
+ ...(typeof ex.pin === "function" ? { pin: (x) => ex.pin(x), pinned: (x) => ex.pinned?.(x) === true, canPin: (x) => ex.canPin?.(x) !== false } : {}),
913
915
  });
914
916
  // M-3311 (2): the Fleet chat's 「引用」 — a passage selected in one message goes into this conversation's composer as a quote
915
917
  // at the caret (chat-quote.js; panel-chat.js's own install), through the box's typing path. `extra.quote.field()`: the box.
@@ -1055,6 +1057,7 @@ function HubMine() {
1055
1057
  <div class="hub-rows">${mine.map((e) => html`<a key=${e.id} class="s-row hub-row hub-row-link" href=${`/ui/hub/exposures?agent=${encodeURIComponent(e.id)}`}>
1056
1058
  <${Avatar} name=${e.displayName} /><span class="hub-row-text"><strong>${e.displayName}</strong>${e.intro?html`<small class="note">${e.intro}</small>`:null}<small class="note">${grantSummary(e.grants)}</small></span>
1057
1059
  ${stateTag(e.state, e.kind === "personal")}<${Icon} name="next" size=${16} /></a>`)}</div></section>` : null}
1060
+ ${mine.length > 0 && session?.features?.includes("room-owner-requests-v1") ? html`<${LazyRoomPart} load=${() => import("./hub-room-owner-requests.js")} name="OwnerAgentRequestSetting" props=${{ client: hubClient(), scope: session.csrf }} />` : null}
1058
1061
  </div>${allowTarget ? html`<${AllowDialog} x=${allowTarget} act=${act} onClose=${() => setAllowTarget(null)} />` : null}</div>`;
1059
1062
  }
1060
1063
 
@@ -1101,6 +1104,7 @@ function HubAgentPage({ x, act, msg }) {
1101
1104
  </div>`)}</div>` : html`<p class="note">${roomCount > 0 ? hroom("agentNoOneToOne") : hw("noGrants")}</p>`}
1102
1105
  ${roomCount > 0 ? html`<p class="note hub-rooms-can-ask">${hroom("roomsCanAskIt")}</p>` : null}
1103
1106
  </section>
1107
+ ${session?.features?.includes("room-agent-discovery-v1") && typeof client.agentRoomDiscovery === "function" ? html`<${LazyRoomPart} load=${() => import("./hub-room-owner-requests.js")} name="OwnerAgentDiscoverySetting" props=${{ client, scope: session.csrf, exposure: x }} />` : null}
1104
1108
  ${roomsLive() ? html`<${LazyRoomPart} load=${() => import("./hub-invitations.js")} name="AgentRoomsSection" props=${{ client: hubClient(), exposureId: x.id, onRooms: setRoomCount }} />` : null}
1105
1109
  <${QuotaVisibilityRow} exposure=${x} onSaved=${() => act(async () => ({ ok: true }))} />
1106
1110
  <section class="card"><h3>${ho("recent")}</h3><p class="note">${ho("recentLead")}</p>
@@ -1223,6 +1227,8 @@ function LazyRoomPart({ load, name, props = {} }) {
1223
1227
  }
1224
1228
  const teamsLive = () => { const c = hubClient(); return typeof c.teamsLive === "function" && c.teamsLive() === true; };
1225
1229
  const roomPurposeLive=()=>session?.features?.includes("room-purpose-v1")&&hubClient().roomPurposeV1===true;
1230
+ // M-3340: personal pins — a Hub that keeps them (room-pins-v1) and a client that can ask; an older Hub shows no Pin at all.
1231
+ const roomPinsLive=()=>session?.features?.includes("room-pins-v1")===true&&typeof hubClient().roomPins==="function";
1226
1232
  const roomsLive = () => { const c = hubClient(); return typeof c.roomsLive === "function" && c.roomsLive() === true; };
1227
1233
  function LazyThisHub({ directory }) {
1228
1234
  const [C, setC] = useState(null);
@@ -28,6 +28,7 @@ import { openSignIn, signInOffered } from "./backend-signin.js";
28
28
  import { decideProposal, installProposals } from "./agent-proposals.js";
29
29
  import { GeneralLocation } from "./general-location.js";
30
30
  import { runtimeUpdateText } from "./runtime-update-status.js";
31
+ import { ContactNeedsItem } from "./contact-needs.js";
31
32
  import { HostDirectoryNotices, hostDirectoryNoticesOffered } from "./hub-host-security-notices.js";
32
33
 
33
34
  // A pre-upgrade tab retains app-i18n.js. Register these reasons when the updated panel is loaded, too.
@@ -215,7 +216,10 @@ export function NeedsPanel({ navKey }) {
215
216
  : !items.length && !asks.length && !decidedHere.length ? hostDirectoryNoticesOffered() ? html`<p class="muted">${tn("otherEmpty")}</p>` : html`<${Empty} icon="check" title=${tn("empty")} hint=${tn(chatApp ? "emptyHint" : "emptyHintWeb")} />`
216
217
  : groups.map((g) => html`<section key=${JSON.stringify([g.instance, g.items[0]?.type === "config", !!g.items[0]?.runtimeUpdate])} class="n-group" aria-label=${g.items[0]?.runtimeUpdate ? runtimeUpdateText("attention") : g.instance}>
217
218
  <h2 class="n-group-head">${g.items[0]?.runtimeUpdate ? runtimeUpdateText("attention") : g.instance ? html`<a href=${chatPath(g.instance)} title=${g.instance}>${nameFor(g.instance)}</a>` : g.items[0]?.type === "config" ? t("app.settings") : tn(g.items.some(i => i.type === "backend") ? "fleetSignIns" : "noAssignee")}</h2>
218
- ${g.items.map((item) => html`<${NeedsItem} key=${item.id} item=${item} nowMs=${nowMs} owner=${owner} />`)}
219
+ ${g.items.map((item) => item.type === "contact"
220
+ // M-3339: a contact request or the restricted-mode suggestion — its own card (contact-needs.js; references only).
221
+ ? html`<${ContactNeedsItem} key=${item.id} item=${item} />`
222
+ : html`<${NeedsItem} key=${item.id} item=${item} nowMs=${nowMs} owner=${owner} />`)}
219
223
  </section>`)}
220
224
  <${HostDirectoryNotices} />
221
225
  <${NotifyToggle} />
@@ -79,6 +79,7 @@ import { useRuntimeCatalog } from "./runtime-catalog.js";
79
79
  import { ShortcutsHelpRow } from "./settings-shortcuts.js";
80
80
  import { GeneralLocation } from "./general-location.js";
81
81
  import { SettingsConnector } from "./settings-connector.js";
82
+ import { ca } from "./contact-auth-strings.js";
82
83
 
83
84
  const tn = (k, ...v) => k === "sec_notifications" ? quotaNoticeText().title : t(`settings.${k}`, ...v);
84
85
  /**
@@ -1208,6 +1209,8 @@ function General({ ctx, part = "all" }) {
1208
1209
  return html`<div class=${fleetPart ? "s-defaults-layout" : "s-classic-layout"}><div class=${`form s-general s-part-${part}`}>
1209
1210
  ${fleetPart ? html`<${SharedAgentSettings} ctx=${ctx} form=${{ f, set, base, errors, warnings, unset, fc, notes, replyNote: fleetReply }} />` : null}
1210
1211
  ${classicPart ? html`<section class="card s-classic-defaults-card"><h3>${tn("classicDefaultsTitle")}</h3>
1212
+ ${/* M-3339 (the leader's A3 decision): what a new room's default means, before any room is set — said here, plainly. */ ""}
1213
+ <p class="s-info contact-new-rooms"><span aria-hidden="true">ⓘ</span><span>${ca("newRoomsRestricted")}</span></p>
1211
1214
  <div class="grid2">
1212
1215
  <div class=${fc("field", "classicBackend")}>${L(tn("classicBackend"), "classic_defaults.backend", "g-cbe")}<${BackendSelect} id="g-cbe" value=${f.classicBackend} onChange=${set("classicBackend")} hostOnly />
1213
1216
  ${!c.backend && f.classicBackend === base.classicBackend ? html`<${Inherited} text=${valueText(f.classicBackend, "backend")} builtin=${!d.backend} from=${inAgentDefaults("#g-be")} />` : null}</div>
@@ -2,7 +2,7 @@
2
2
  // a test runs both over one list of cases). Pure: no DOM, no history.
3
3
 
4
4
  // #2347 §10: Config is gone from Fleet — each of its settings has one home in Settings (/ui/fleet/config leads there).
5
- export const FLEET_TABS = ["tasks", "schedules", "teams", "org", "cache", "usage"];
5
+ export const FLEET_TABS = ["tasks", "schedules", "teams", "org", "cache", "usage", "authorizations"];
6
6
  // #2347: two groups — "You" changes only you or this browser; "Fleet" changes AgEnD for everyone.
7
7
  export const SETTINGS_GROUPS = Object.freeze([
8
8
  Object.freeze({ id: "you", sections: Object.freeze(["preferences", "look"]) }),
@@ -1264,6 +1264,8 @@ export function Shell({ panels, onNewInstance, viewOnly = false }) {
1264
1264
  // composer's box writes its height only when its line count changes (#4026).
1265
1265
  // Pinned per keystroke by tests/web-typing-steady-m3265.test.ts and tests/web-keyboard-fit-3111.test.ts, and in the real app
1266
1266
  // (WebKit) by smoke-phone-kb-steady, smoke-phone-ime-keyboard-m3244 and smoke-phone-typing-steady-m3265.
1267
+ // M-3357: every past keyboard case, each with the fix undone as a revert that must turn its tests red, is
1268
+ // scripts/ci/keyboard-suite.mjs (CI's keyboard-suite job; docs/dev/iphone-keyboard-suite.md) — a fix here adds its case.
1267
1269
  // The bottom tabs (and the line under the composer) give their room to the keyboard on a phone (#2478).
1268
1270
  useEffect(() => {
1269
1271
  const vv = typeof window !== "undefined" ? window.visualViewport : null;
@@ -46,7 +46,9 @@
46
46
  // office_skins — a skin pack was uploaded or deleted ({ rev }; SSE only: the Office view reads /ui/office-skins again).
47
47
  // office_acts — the agents' live acts in the Office view changed ({ acts }, #2578; a poll page reads /ui/office-acts).
48
48
  // pins — an agent's pinned messages changed ({ instance, rev }, M-3271; SSE only: its open chat reads /ui/pins again).
49
- const EVENTS = ["status", "message", "agent_reply_live", "delivery", "deliveries", "prompt", "prompts", "prompt_resolved", "activity", "needs", "reply_buttons", "reactions", "steps_tick", "clock", "traffic", "delegation", "backend_login", "models", "tasks", "offices", "office_skins", "office_acts", "office_pack_changes", "agent_proposals", "pins", "notice"];
49
+ // contact-auth — an agent's contact permissions or one of its contact requests changed ({ instance, ticketId?, revision },
50
+ // M-3339; SSE only: an open Permissions tab or Authorizations page reads its own scoped route again).
51
+ const EVENTS = ["status", "message", "agent_reply_live", "delivery", "deliveries", "prompt", "prompts", "prompt_resolved", "activity", "needs", "reply_buttons", "reactions", "steps_tick", "clock", "traffic", "delegation", "backend_login", "models", "tasks", "offices", "office_skins", "office_acts", "office_pack_changes", "agent_proposals", "pins", "contact-auth", "notice"];
50
52
  const MAX_HELD = 1000; // live events held during one catch-up read; more → read again afterwards
51
53
  const RETRY_DELAYS = [1000, 2000, 4000]; // after the first failed catch-up read; then it waits for Retry
52
54
  const POLL_LIMIT_MS = 10000; // a poll that has not answered by then counts as failed
@@ -4823,3 +4823,34 @@ html.oo-immersive .p-fleet > .panel-body { z-index: 50; }
4823
4823
  .toasts .toast { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; border-radius: var(--r-full); padding: var(--s-1) var(--s-3); font-size: var(--fs-sm); cursor: pointer; }
4824
4824
  .kb-open .toasts { display: none; }
4825
4825
  }
4826
+
4827
+ /* ── M-3339: contact authorizations (contact-permissions.js, contact-authorizations.js, the chat badge, Needs you) ── */
4828
+ .contact-pill { display: inline-flex; align-items: center; gap: var(--s-1); padding: 1px var(--s-2); border-radius: 999px; font-size: var(--fs-xs); font-weight: var(--fw-semibold); border: 1px solid transparent; }
4829
+ .contact-pill.ok { color: var(--ok); background: var(--ok-bg); }
4830
+ .contact-pill.warn { color: var(--warn); background: var(--warn-bg); border-color: var(--warn-line); }
4831
+ .contact-pill.bad { color: var(--danger); background: var(--danger-bg); border-color: var(--danger-line); }
4832
+ .contact-pill.muted { color: var(--text-2); background: var(--surface); border-color: var(--border); }
4833
+ .contact-perm, .contact-auth-page, .contact-ticket-list { display: flex; flex-direction: column; gap: var(--s-3); }
4834
+ .contact-list { list-style: none; margin: var(--s-2) 0; padding: 0; display: flex; flex-direction: column; gap: var(--s-2); }
4835
+ .contact-list > li { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-1) var(--s-2); padding: var(--s-2) 0; border-top: 1px solid var(--border); }
4836
+ .contact-list > li:first-child { border-top: 0; }
4837
+ .contact-list > li > div, .contact-list > li > .feedback { flex-basis: 100%; }
4838
+ .contact-list .icon-btn { margin-left: auto; }
4839
+ .contact-would ul { margin: var(--s-1) 0 0; padding-left: var(--s-5); }
4840
+ .contact-toggle { min-height: var(--tap); }
4841
+ .contact-approver-add select, .contact-mcp-add .input { flex: 1; min-width: 0; }
4842
+ .contact-owner-warning { display: flex; align-items: center; gap: var(--s-1); margin: 0; }
4843
+ .contact-ticket.focus { border-color: var(--accent); }
4844
+ .contact-ticket-head { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2); }
4845
+ .contact-ticket-route, .contact-ticket-origin, .contact-ticket-times { margin: var(--s-1) 0; }
4846
+ .contact-ticket-origin .link-btn { border: 0; background: none; padding: 0; color: var(--accent); cursor: pointer; font: inherit; }
4847
+ .contact-ticket-message { margin: var(--s-2) 0; padding: var(--s-2) var(--s-3); max-height: 16em; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere; background: var(--surface); border-radius: var(--r-sm); font-family: var(--font-ui); font-size: var(--fs-sm); }
4848
+ .contact-decide { display: flex; flex-direction: column; gap: var(--s-2); margin-top: var(--s-2); padding-top: var(--s-2); border-top: 1px solid var(--border); }
4849
+ .contact-allow .field { flex: 1; min-width: 10em; }
4850
+ .contact-filters { flex-wrap: wrap; align-items: flex-end; gap: var(--s-2); }
4851
+ @media (max-width: 899px), (pointer: coarse) and (max-height: 500px) and (max-width: 1023px) {
4852
+ .contact-ticket-origin .link-btn, .contact-perm .icon-btn, .contact-filters .seg-item { min-height: var(--tap); }
4853
+ }
4854
+ .msg .meta .contact-badge { display: inline-flex; align-items: center; margin-left: var(--s-2); padding: 0 var(--s-2); border-radius: 999px; font-size: var(--fs-xs); font-weight: var(--fw-semibold);
4855
+ color: var(--warn); background: var(--warn-bg); border: 1px solid var(--warn-line); text-decoration: none; }
4856
+ .msg .meta .contact-badge.ok { color: var(--ok); background: var(--ok-bg); border-color: transparent; }
@@ -224,7 +224,14 @@ export function installQuoteSelection(list, deps) {
224
224
  place(passage);
225
225
  }
226
226
  function soon() { if (timer) clearTimeout(timer); timer = setTimeout(check, 120); }
227
- const onSelection = () => soon();
227
+ // M-3356 (the user, iPhone, 注音: the candidate bar blanked on every key): while an IME composes in the composer, no
228
+ // selection check (iOS redraws its candidate bar when the page reads the selection); a selection in the thread is not
229
+ // being made then. `composing` is kept by the composer's composition events (below).
230
+ let composing = false;
231
+ const onSelection = () => {
232
+ if (composing) { if (timer) { clearTimeout(timer); timer = null; } return; }
233
+ soon();
234
+ };
228
235
  const onDown = (e) => { if (pop && pop.contains(e.target)) return; down = true; hide(); };
229
236
  // A gesture the browser took over (a touch scroll: pointerdown → pointercancel, no pointerup — #3555 review P2-1)
230
237
  // ends the press as a pointerup does; the selection then decides.
@@ -233,10 +240,25 @@ export function installQuoteSelection(list, deps) {
233
240
  const onScroll = () => { if (pop && current) place(current); };
234
241
  const onFocusIn = (e) => { const f = deps.field?.(); if (f && e.target === f) f.dataset.touched = "1"; };
235
242
  // The caret as the person leaves it: kept on every move inside the composer and when it loses the focus.
236
- const keep = (e) => { const f = deps.field?.(); if (f && e.target === f) remembered.set(f, { value: f.value, caret: f.selectionStart ?? f.value.length }); };
243
+ // M-3356: never while an IME composes (its keys, their keyup): the caret is kept when the composition ends, or on leaving.
244
+ // Any compositionend ends it, and so does the composer losing the focus (#4208 review: a blur, a tab switch or a
245
+ // re-rendered composer may never send the field its compositionend — the pill would never show again).
246
+ const onCompose = (e) => {
247
+ if (e.type === "compositionend") { composing = false; return; }
248
+ const f = deps.field?.(); if (f && e.target === f) composing = true;
249
+ };
250
+ const keep = (e) => {
251
+ const f = deps.field?.();
252
+ if (!f || e.target !== f) return;
253
+ if (e.type === "focusout") composing = false;
254
+ if (composing || e.isComposing || e.keyCode === 229) return;
255
+ remembered.set(f, { value: f.value, caret: f.selectionStart ?? f.value.length });
256
+ };
237
257
  const KEEP = ["focusout", "input", "keyup", "mouseup", "select"];
238
258
  doc.addEventListener("focusin", onFocusIn);
239
259
  for (const k of KEEP) doc.addEventListener(k, keep, true);
260
+ doc.addEventListener("compositionstart", onCompose, true);
261
+ doc.addEventListener("compositionend", onCompose, true);
240
262
  doc.addEventListener("selectionchange", onSelection);
241
263
  list.addEventListener("pointerdown", onDown);
242
264
  doc.addEventListener("pointerup", onUp);
@@ -249,6 +271,8 @@ export function installQuoteSelection(list, deps) {
249
271
  hide();
250
272
  doc.removeEventListener("focusin", onFocusIn);
251
273
  for (const k of KEEP) doc.removeEventListener(k, keep, true);
274
+ doc.removeEventListener("compositionstart", onCompose, true);
275
+ doc.removeEventListener("compositionend", onCompose, true);
252
276
  doc.removeEventListener("selectionchange", onSelection);
253
277
  list.removeEventListener("pointerdown", onDown);
254
278
  doc.removeEventListener("pointerup", onUp);
@@ -210,8 +210,10 @@ export function createThread(list, scroller, opts) {
210
210
  // A Hub sender's stateless badge is mounted as DOM below. Its escaped descriptor participates in keyed updates;
211
211
  // Fleet callers supply no senderBadge hook and retain their existing sender markup.
212
212
  const badge = opts.senderBadge && x.sourceBadge ? ` data-source-badge="${escAttr(JSON.stringify(x.sourceBadge))}"` : "";
213
+ // M-3339: a contact request's badge (聯絡申請 #R… / 已准轉交 #R…) — escaped HTML from the Fleet chat's hook; a Hub passes none.
214
+ const contact = typeof opts.contactBadge === "function" && x.contactTicket ? String(opts.contactBadge(x) || "") : "";
213
215
  // M-3092 (Hub rooms): another person's message, a bubble on the left (`msg-person`); the fleet never sets x.person.
214
- return `<div class="msg ${u ? "user" : "agent"}${x.person ? " msg-person" : ""}" data-key="${escAttr(key)}" tabindex="-1">${act}<div class="meta"><span class="sender"${badge}>${escAttr(x.sender)}</span>${time}${ticks}</div>${quoteHtml(x.replyTo)}<div class="body">${clicked ? clickHtml(x.click) : `<div class="md">${renderedMarkdown(x.text, x.role === "agent", opts.emojis, opts.mentions, opts.mentionLabels?.())}</div>`}${R().attachmentsHtml(x.attachments, { htmlCards: x.role === "agent", goneTitle: tr(x.archived ? "chat.attNotKeptTitle" : "chat.attGone"), goneLabel: tr(x.archived ? "chat.attNotKept" : "chat.attUnavailable"), inlinePreviews: !PUBLIC_LINK(), textPreviews: true })}${buttons}</div>${Array.isArray(x.reactionBar) ? reactBarHtml(x, key, reactable) : R().reactionsHtml(x.reactions, tr("chat.reactedBy", x.instance || ""))}${tools}</div>`;
216
+ return `<div class="msg ${u ? "user" : "agent"}${x.person ? " msg-person" : ""}" data-key="${escAttr(key)}" tabindex="-1">${act}<div class="meta"><span class="sender"${badge}>${escAttr(x.sender)}</span>${time}${ticks}${contact}</div>${quoteHtml(x.replyTo)}<div class="body">${clicked ? clickHtml(x.click) : `<div class="md">${renderedMarkdown(x.text, x.role === "agent", opts.emojis, opts.mentions, opts.mentionLabels?.())}</div>`}${R().attachmentsHtml(x.attachments, { htmlCards: x.role === "agent", goneTitle: tr(x.archived ? "chat.attNotKeptTitle" : "chat.attGone"), goneLabel: tr(x.archived ? "chat.attNotKept" : "chat.attUnavailable"), inlinePreviews: !PUBLIC_LINK(), textPreviews: true })}${buttons}</div>${Array.isArray(x.reactionBar) ? reactBarHtml(x, key, reactable) : R().reactionsHtml(x.reactions, tr("chat.reactedBy", x.instance || ""))}${tools}</div>`;
215
217
  }
216
218
  /** M-3127: a room's words for its reaction controls (opts.reactText(key)), English when the page gives none. */
217
219
  function reactText(k, ...a) {
@@ -349,7 +351,9 @@ export function createThread(list, scroller, opts) {
349
351
  ? `<button type="button" data-trust="thread-control" class="chip-btn st-action" data-act="statusAction" data-arg="${escAttr(x.action.arg)}">${escAttr(x.action.label)}</button>` : "";
350
352
  // A Hub mention-stop sentence must stay readable at phone width. Ordinary Fleet status rows still fold.
351
353
  const folded = x.wrap === true ? "" : ` folded${overflows ? " overflows" : ""}`;
352
- return `<div class="msg status-line${folded}"><div class="meta">${time}</div><div class="body"><div class="st-text">${body}</div>${x.wrap === true ? "" : more}${action}</div>${x.bare === true ? "" : tools}</div>`;
354
+ // M-3339: a ClassicBot room's held-request line carries its contact badge too (the Fleet chat's hook; a Hub passes none).
355
+ const contact = typeof opts.contactBadge === "function" && x.contactTicket ? String(opts.contactBadge(x) || "") : "";
356
+ return `<div class="msg status-line${folded}"><div class="meta">${time}${contact}</div><div class="body"><div class="st-text">${body}</div>${x.wrap === true ? "" : more}${action}</div>${x.bare === true ? "" : tools}</div>`;
353
357
  }
354
358
  /**
355
359
  * #1266: an agent reply's buttons. Labels are text (escaped, never Markdown); the click names the set and the index,
@@ -8,6 +8,14 @@
8
8
  .hub-room-results { list-style: none; margin: 0; padding: 0; border: 1px solid var(--border); border-radius: var(--r-sm); max-height: 240px; overflow-y: auto; }
9
9
  .hub-room-result { display: flex; width: 100%; align-items: baseline; gap: var(--s-2); padding: var(--s-2); background: transparent; border: 0; text-align: start; cursor: pointer; color: inherit; font: inherit; min-height: 40px; }
10
10
  .hub-room-result:hover, .hub-room-result:focus-visible { background: var(--surface-2); }
11
+ .hub-room-person-label { display: flex; flex-direction: column; min-width: 0; max-width: 100%; }
12
+ .hub-room-person-label > :is(.hub-room-person-name, .hub-room-person-detail) { display: block; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
13
+ .hub-room-result-agent { align-items: flex-start; flex-wrap: wrap; justify-content: space-between; }
14
+ .hub-room-agent-label { display: flex; flex: 1 1 18rem; flex-direction: column; min-width: 0; gap: var(--s-1); }
15
+ .hub-room-agent-title { overflow-wrap: anywhere; }
16
+ .hub-room-agent-title > small { margin-inline-start: var(--s-1); }
17
+ .hub-room-agent-intro { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
18
+ .hub-room-agent-action { flex: 0 1 auto; max-width: 100%; white-space: normal; pointer-events: none; }
11
19
  .hub-room-new .form, .hub-room-settings section.form { display: flex; flex-direction: column; gap: var(--s-3); }
12
20
  .hub-room-settings section + section { margin-top: var(--s-4); }
13
21
  /* Room settings → Name: the label above, then the input and 儲存 on one line, the input taking the rest of it. */
@@ -79,3 +87,17 @@
79
87
  .hub-room-purpose-trigger{display:block;max-width:100%;min-height:24px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;text-align:start;border:0;background:none;padding:0;color:var(--text-3);font:inherit;font-size:var(--fs-xs);cursor:pointer}
80
88
  .hub-room-purpose-full,.hub-room-purpose-panel p{white-space:pre-wrap;overflow-wrap:anywhere}
81
89
  @media(max-width:640px),(pointer:coarse){.hub-room-purpose-trigger{min-height:var(--tap)}}
90
+
91
+ /* Owner requests use the existing room form and modal spacing. */
92
+ .hub-owner-request .form fieldset { border: 0; padding: 0; margin: 0; min-width: 0; display: grid; gap: var(--space-3, .75rem); }
93
+ .hub-owner-request .field { display: grid; gap: var(--space-2, .5rem); }
94
+ .hub-owner-request-entry .btn { margin-inline-start: .35rem; }
95
+ .hub-room-owner-requests:empty { display: none; }
96
+ /* Owner requests reuse the room consent card and ordinary checkbox/radio layout. */
97
+ .hub-owner-agent-choices { border:0; padding:0; margin:12px 0; display:grid; gap:10px; }
98
+ .hub-owner-agent-choices .check { align-items:flex-start; }
99
+ .hub-owner-agent-choices input[type="radio"] { margin-top:.25em; }
100
+ .hub-owner-agent-requests .hub-owner-request-title { font-weight:var(--fw-semibold); }
101
+ .hub-owner-agent-choices small { display:block; }
102
+ .hub-owner-agent-requests blockquote { overflow-wrap:anywhere; margin:var(--s-2) 0; padding-left:var(--s-3); border-left:3px solid var(--border-strong); color:var(--text-2); }
103
+ .hub-owner-agent-requests a { color:var(--accent); text-decoration:underline; }