@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
@@ -0,0 +1,54 @@
1
+ // M-3339 (A2): a chat message's contact badge — message.contactTicket = { id, state } (the contract's ContactBadge), on a
2
+ // ClassicBot room's held request or its status line ("聯絡申請 #R12"), and on the worker's inbound copy of an approved one
3
+ // ("已准轉交 #R12"). A link to that request (Fleet → Authorizations, where the server scopes who may read it).
4
+ // Kept current: on the stream's contact-auth frame naming a request a badge shows, that request is read again from its
5
+ // scoped route (installBadgeRefresh) and its badges change in place; later draws use that state too. A reader the route
6
+ // refuses keeps the message's own state.
7
+ // HTML text for chat-thread.js's opts.contactBadge hook (the Fleet chat's only; a Hub room passes none): every value escaped.
8
+ import { appStore } from "/assets/app-store.js";
9
+ import { ca } from "./contact-auth-strings.js";
10
+ import { getTicket, shortTicketId } from "./contact-auth-client.js";
11
+
12
+ const esc = (s) => String(s).replace(/[&<>"']/g, (c) => ({ "&": "&amp;", "<": "&lt;", ">": "&gt;", '"': "&quot;", "'": "&#39;" })[c]);
13
+ const ID = /^[A-Za-z0-9_-]{1,64}$/;
14
+ const STATES = new Set(["pending", "approved", "delivered", "declined", "expired", "unknown"]);
15
+ /** The latest state read for a request (its scoped route), over the message's own. */
16
+ const fresh = new Map();
17
+ /** Requests a badge has shown on this page (the only ones a contact-auth frame reads again). */
18
+ const shown = new Set();
19
+
20
+ const badgeText = (full, state) => { const id = shortTicketId(full); return state === "delivered" ? `${ca("forwarded")} #${id}`
21
+ : state === "pending" || !STATES.has(state) ? ca("ticket", id) : `${ca("ticket", id)} · ${ca(`state_${state}`)}`; };
22
+
23
+ export function contactBadgeHtml(x) {
24
+ const tk = x && x.contactTicket;
25
+ if (!tk || typeof tk.id !== "string" || !ID.test(tk.id)) return "";
26
+ shown.add(tk.id);
27
+ const state = fresh.get(tk.id) ?? tk.state;
28
+ const ok = state === "delivered" || state === "approved";
29
+ return `<a class="contact-badge${ok ? " ok" : ""}" data-contact-ticket="${esc(tk.id)}" href="/ui/fleet/authorizations?ticket=${encodeURIComponent(tk.id)}">${esc(badgeText(tk.id, state))}</a>`;
30
+ }
31
+
32
+ /** Read one request again and change its badges on the page in place. */
33
+ export async function refreshBadge(id, doc = typeof document !== "undefined" ? document : null) {
34
+ if (!ID.test(String(id || "")) || !shown.has(id)) return;
35
+ const r = await getTicket(id);
36
+ if (!r.ok || !STATES.has(r.data?.state)) return;
37
+ fresh.set(id, r.data.state);
38
+ for (const a of doc ? doc.querySelectorAll("a.contact-badge") : []) {
39
+ if (a.getAttribute("data-contact-ticket") !== id) continue;
40
+ a.textContent = badgeText(id, r.data.state);
41
+ a.classList.toggle("ok", r.data.state === "delivered" || r.data.state === "approved");
42
+ }
43
+ }
44
+
45
+ let installed = null;
46
+ /** Once per page: the stream's contact-auth frames with a ticketId refresh that request's badges. */
47
+ export function installBadgeRefresh() {
48
+ if (installed) return installed;
49
+ const sub = appStore.get().streamOn;
50
+ if (typeof sub !== "function") return () => {};
51
+ const off = sub("contact-auth", (d) => { if (d && typeof d.ticketId === "string") void refreshBadge(d.ticketId); });
52
+ installed = () => { if (typeof off === "function") off(); installed = null; };
53
+ return installed;
54
+ }
@@ -34,7 +34,7 @@ import { OC, REST_KEY, SUM_LINE, canvasLayout, hits, needle, openingRegion, summ
34
34
  import { createTrafficStore, FAR_K, HEAD, POLL_MS, sendingBy, trafficEdges } from "./fleet-traffic.js";
35
35
  import { routeScene } from "./fleet-route-scene.js";
36
36
  import { K_MAX, K_MIN, fitView, gestureState, gestures, miniPoint, pinchView, wheelFactor, zoomAt, zoomKey } from "./fleet-canvas-view.js";
37
- import { createRouteClient } from "./fleet-route.js";
37
+ import { createRouteClient, warmRouter } from "./fleet-route.js";
38
38
 
39
39
  register("orgc", {
40
40
  en: {
@@ -461,6 +461,8 @@ export function OrgCanvas({ org, app, lease }) {
461
461
  // M-3253: on a phone the Office's tools (and Live) are one ⋯ sheet at the end of this bar: one row, Find keeps its width.
462
462
  const phone = useOfficePhone(), [officeMore, setOfficeMore] = useState(false), officeSheet = phone && mode === "office";
463
463
  const traffic = useTraffic(lease, live);
464
+ // M-3328: Live on — the router's files are asked for now, together, not one by one at the first routed scene.
465
+ useEffect(() => { if (live && typeof Worker === "function") warmRouter(); }, [live]);
464
466
  const sending = useMemo(() => sendingBy(traffic), [traffic]);
465
467
  const [folded, setFolded] = useState(readFolded);
466
468
  const [query, setQuery] = useState("");
@@ -47,6 +47,7 @@ import { t } from "/assets/app-i18n.js";
47
47
  import { frameAt, nameHash } from "./fleet-office-model.js";
48
48
  import { CHAR_DEPTH, LOGICAL, checkSkinPack, own, packPortraitImages, packSceneImages, poseStrip, stripBox, walkStrip } from "./fleet-office-pack.js";
49
49
  import { tierColours } from "./fleet-office-levels.js";
50
+ import { assetUrl } from "/assets/asset-url.js";
50
51
 
51
52
  export { nameHash };
52
53
 
@@ -615,7 +616,7 @@ export function spriteSkin(pack, images, base = pixelSkin) {
615
616
  // ── The built-in cozy (#2631): the zones layout on a warm pixel-art office drawn as one picture, the built-in people ──
616
617
 
617
618
  /** Its picture, shipped with the page (src/ui/shared/office/cozy.png, auth-api.ts ASSETS: public static, as the font). */
618
- export const COZY_BACKGROUND = "/assets/office-cozy.png";
619
+ export const COZY_BACKGROUND = assetUrl("/assets/office-cozy.png");
619
620
  const pts = (...xy) => xy.map(([x, y]) => ({ x, y }));
620
621
  // The seats are feet points on the picture: chairs in front of the desks, the sofa, the coffee table and machine, the
621
622
  // beanbags (a sleeper's bottom), in front of the whiteboard. The rects put a crowd's first extra spots (fleet-office-zones.js
@@ -662,7 +663,7 @@ const wps = (list) => list.map(([id, x, y]) => ({ id, x, y }));
662
663
  // alert corner bottom-right, one straight aisle up the middle from a bottom-centre door ──
663
664
 
664
665
  /** The guild: a fantasy adventurers' guild hall (src/ui/shared/office/guild.png). */
665
- export const GUILD_BACKGROUND = "/assets/office-guild.png";
666
+ export const GUILD_BACKGROUND = assetUrl("/assets/office-guild.png");
666
667
  // Seats: the chairs at the six map desks, the tavern bench, the stools round the table, the bar; the inn beds (a sleeper's
667
668
  // middle); in front of the quest board.
668
669
  const GUILD_AREAS = {
@@ -696,7 +697,7 @@ export const GUILD_PACK = {
696
697
  };
697
698
 
698
699
  /** The school: a classroom (src/ui/shared/office/school.png). */
699
- export const SCHOOL_BACKGROUND = "/assets/office-school.png";
700
+ export const SCHOOL_BACKGROUND = assetUrl("/assets/office-school.png");
700
701
  // Seats: the chairs at the six student desks; the sofa, the two stools, the vending machine; the nurse's beds; in front
701
702
  // of the chalkboard.
702
703
  const SCHOOL_AREAS = {
@@ -7,6 +7,46 @@ import { routeOk } from "./fleet-route-scene.js";
7
7
 
8
8
  export const WORKER_URL = "/ui/js/fleet-route-worker.js";
9
9
  export const WASM_URL = "/ui/vendor/libavoid-0.4.5/libavoid.wasm";
10
+ export const LIBAVOID_JS = "/ui/vendor/libavoid-0.4.5/libavoid.js";
11
+
12
+ /**
13
+ * M-3328 (measured in M-3316): the worker under this module's own version. A worker does not use the page's import
14
+ * map, so a plain WORKER_URL was a `no-store` request on every open, and its `./fleet-route-scene.js` and
15
+ * `./fleet-canvas-layout.js` plain copies of modules the page already holds under its version. Under the version, its
16
+ * relative imports are the page's own (cached) files, and a tab older than the server asks for its own version: the
17
+ * stale-module answer fails the worker, and the lines keep their lane routes — never a newer worker in an older page.
18
+ * Loaded by a plain path (the office share page, tests), the plain WORKER_URL.
19
+ */
20
+ export function workerUrlFor(url) {
21
+ const m = /\/ui\/js\/(v-[0-9a-f]{12})\/[^/?#]+(?:[?#].*)?$/.exec(String(url || ""));
22
+ return m ? `/ui/js/${m[1]}/fleet-route-worker.js` : WORKER_URL;
23
+ }
24
+
25
+ const wasmBytes = async (get) => {
26
+ const res = await get(WASM_URL, { credentials: "same-origin" });
27
+ if (!res.ok) throw new Error(`libavoid.wasm: ${res.status}`);
28
+ return res.arrayBuffer();
29
+ };
30
+ let warmed = null;
31
+ /**
32
+ * M-3328: with the org chart's Live traffic on, everything the router needs is asked for at once — the .wasm, libavoid's
33
+ * glue and (under a version, where the answer is cached for good) the worker — instead of one after another once the
34
+ * first scene is routed (.wasm, then the worker, then its imports: about 1.7 s over a slow link). Once per page; a
35
+ * failed .wasm is asked for again by the next try. The bytes it fetched are what the client starts the worker with.
36
+ */
37
+ export function warmRouter(get = (...a) => fetch(...a), url = import.meta.url) {
38
+ if (warmed) return warmed;
39
+ const worker = workerUrlFor(url);
40
+ for (const u of worker === WORKER_URL ? [LIBAVOID_JS] : [worker, LIBAVOID_JS]) {
41
+ Promise.resolve().then(() => get(u, { credentials: "same-origin" })).then((r) => r && r.arrayBuffer && r.arrayBuffer()).catch(() => {});
42
+ }
43
+ const p = wasmBytes(get);
44
+ warmed = p;
45
+ p.catch(() => { if (warmed === p) warmed = null; });
46
+ return p;
47
+ }
48
+ /** Tests: forget the warmed bytes. */
49
+ export function resetRouterWarm() { warmed = null; }
10
50
  export const TIMEOUT_MS = 4000;
11
51
  const FAIL_LIMIT = 2;
12
52
 
@@ -17,6 +57,7 @@ const FAIL_LIMIT = 2;
17
57
  export function createRouteClient(deps = {}) {
18
58
  const W = deps.Worker ?? (typeof Worker === "function" ? Worker : null);
19
59
  const get = deps.fetch ?? ((...a) => fetch(...a));
60
+ const workerUrl = deps.workerUrl ?? workerUrlFor(import.meta.url);
20
61
  const timers = deps.timers ?? { set: (f, ms) => setTimeout(f, ms), clear: (t) => clearTimeout(t) };
21
62
  let worker = null, wasm = null, fails = 0, nextId = 1;
22
63
  let busy = null, waiting = null; // { id, scene, resolve, timer }
@@ -29,15 +70,12 @@ export function createRouteClient(deps = {}) {
29
70
  pump();
30
71
  };
31
72
  async function start(job) {
32
- if (!wasm) {
33
- const res = await get(WASM_URL, { credentials: "same-origin" });
34
- if (!res.ok) throw new Error(`libavoid.wasm: ${res.status}`);
35
- wasm = await res.arrayBuffer();
36
- }
73
+ // The bytes warmRouter fetched when Live was turned on (this page's), else fetched now.
74
+ if (!wasm) wasm = await (warmed ? warmed.catch(() => wasmBytes(get)) : wasmBytes(get));
37
75
  // #2194 review: closed, timed out or replaced while the .wasm was on its way — start nothing (a worker made now
38
76
  // would be nobody's, and a later start would make another).
39
77
  if (busy !== job || worker) return;
40
- const w = new W(WORKER_URL, { type: "module" });
78
+ const w = new W(workerUrl, { type: "module" });
41
79
  w.onmessage = (ev) => {
42
80
  const m = ev.data;
43
81
  if (!m || typeof m !== "object" || w !== worker) return;
@@ -10,13 +10,14 @@ import { t, register, lang } from "/assets/app-i18n.js";
10
10
  import { Icon } from "/assets/ui-icons.js";
11
11
  import { Menu } from "/assets/ui-menu.js";
12
12
  import { COLUMNS, ProgressBar, UNASSIGNED, Who, readStored, recentlyDone, relTime, reviewLabel, waitsForYou, wrapUpText, writeStored } from "./fleet-task-common.js";
13
+ import { assetUrl } from "/assets/asset-url.js";
13
14
 
14
15
  /** The task board's stylesheet, linked once (a tab opened before an upgrade has an app.css without these rules). */
15
16
  export function linkTaskBoardCss(doc = typeof document !== "undefined" ? document : null) {
16
17
  try {
17
18
  if (!doc || !doc.head || doc.querySelector('link[data-tb-css="1"]')) return;
18
19
  const link = doc.createElement("link");
19
- link.setAttribute("rel", "stylesheet"); link.setAttribute("href", "/assets/task-board.css"); link.setAttribute("data-tb-css", "1");
20
+ link.setAttribute("rel", "stylesheet"); link.setAttribute("href", assetUrl("/assets/task-board.css")); link.setAttribute("data-tb-css", "1");
20
21
  doc.head.appendChild(link);
21
22
  } catch { /* the board still works without it */ }
22
23
  }
@@ -9,6 +9,7 @@ import { register, t } from "/assets/app-i18n.js";
9
9
  import { createStore, useStore } from "/assets/app-store.js";
10
10
  import { toast } from "/assets/ui-toast.js";
11
11
  import { confirmedWrite } from "./settings-confirm.js";
12
+ import { assetUrl } from "/assets/asset-url.js";
12
13
 
13
14
  register("hostinstall", {
14
15
  en: {
@@ -130,6 +131,7 @@ register("hostinstall", {
130
131
  err_not_npm: "Claude Code here is not an npm install, so there is nothing to switch.",
131
132
  err_still_npm: "There is no native install of Claude Code yet: switch to it first, then remove the npm copy.",
132
133
  err_no_npm_copy: "There is no npm copy of Claude Code to remove.",
134
+ err_npm_busy: "Another npm is installing or updating packages on this computer right now (an agent's Claude Code may be updating itself). Nothing was removed: try again in a few minutes.",
133
135
  },
134
136
  "zh-TW": {
135
137
  nativeOffer: "Claude Code 是用 npm 安裝的({0})。AgEnD 重啟時可能打斷 npm 自己的更新,讓 `claude` 只裝了一半。改用 Claude 的原生安裝就不會這樣:切換會用 claude.ai/install.sh 安裝 {1},也就是 AgEnD 稽核過的版本。",
@@ -148,13 +150,14 @@ register("hostinstall", {
148
150
  err_not_npm: "這裡的 Claude Code 不是用 npm 安裝的,不需要切換。",
149
151
  err_still_npm: "還沒有 Claude Code 的原生安裝:請先改用原生安裝,再移除 npm 那份。",
150
152
  err_no_npm_copy: "沒有 npm 安裝的 Claude Code 可以移除。",
153
+ err_npm_busy: "這台電腦上有另一個 npm 正在安裝或更新套件(可能是 agent 的 Claude Code 在自行更新)。沒有移除任何東西,請過幾分鐘再試。",
151
154
  },
152
155
  });
153
156
  const th = (k, ...v) => t(`hostinstall.${k}`, ...v);
154
157
  function installStyles() {
155
- if (typeof document === "undefined" || !document.head || document.querySelector('link[href="/assets/host-install.css"]')) return;
158
+ if (typeof document === "undefined" || !document.head || document.querySelector(`link[href="${assetUrl("/assets/host-install.css")}"]`)) return;
156
159
  const link = document.createElement("link");
157
- link.setAttribute("rel", "stylesheet"); link.setAttribute("href", "/assets/host-install.css"); document.head.appendChild(link);
160
+ link.setAttribute("rel", "stylesheet"); link.setAttribute("href", assetUrl("/assets/host-install.css")); document.head.appendChild(link);
158
161
  }
159
162
  function revealPending(id) {
160
163
  const show = () => Array.from(document.querySelectorAll("[data-pending]")).find(n => n.getAttribute("data-pending") === id)?.scrollIntoView?.({ block: "center" });
@@ -4,13 +4,14 @@ import {lang} from "/assets/app-i18n.js";
4
4
  import {hubConnectorPrompt} from "/assets/connector-prompt.js";
5
5
  import {SubjectPicker,subjectText} from "./hub-subject-picker.js";
6
6
  import {ha} from "./hub-ai-apps-strings.js";
7
+ import { assetUrl } from "/assets/asset-url.js";
7
8
 
8
9
  export const APP_SCOPES=Object.freeze(["rooms:read","rooms:post","agents:ask"]);
9
10
  const keys={"rooms:read":"read","rooms:post":"post","agents:ask":"ask"};
10
11
  const styles=new WeakMap();
11
12
  export function linkHubAppsCss(doc=typeof document==="undefined"?null:document){
12
13
  if(!doc?.head)return Promise.resolve(false);if(styles.has(doc))return styles.get(doc);
13
- const loaded=new Promise(resolve=>{const link=doc.createElement("link");link.setAttribute("rel","stylesheet");link.setAttribute("href","/assets/hub-ai-apps.css");link.setAttribute("data-hub-apps-css","1");
14
+ const loaded=new Promise(resolve=>{const link=doc.createElement("link");link.setAttribute("rel","stylesheet");link.setAttribute("href",assetUrl("/assets/hub-ai-apps.css"));link.setAttribute("data-hub-apps-css","1");
14
15
  link.addEventListener("load",()=>resolve(true),{once:true});link.addEventListener("error",()=>{link.remove();styles.delete(doc);resolve(false);},{once:true});doc.head.appendChild(link);});styles.set(doc,loaded);return loaded;
15
16
  }
16
17
  function useStyle(){const[ready,setReady]=useState(null),[retry,setRetry]=useState(0);useEffect(()=>{let live=true;linkHubAppsCss().then(r=>{if(live)setReady(r);});return()=>{live=false;};},[retry]);return[ready,()=>setRetry(n=>n+1)];}
@@ -2,6 +2,7 @@
2
2
  // its stylesheet. A module of its own (a tab opened before an upgrade holds an older hub-strings.js without these words,
3
3
  // and an older hub.css without these rules). The thread's own words are the fleet chat's (/assets/chat-strings.js).
4
4
  import { register, t } from "/assets/app-i18n.js";
5
+ import { assetUrl } from "/assets/asset-url.js";
5
6
 
6
7
  register("hubChat", {
7
8
  en: {
@@ -80,7 +81,7 @@ export function linkHubChatCss(doc = typeof document !== "undefined" ? document
80
81
  try {
81
82
  if (!doc || !doc.head || doc.querySelector('link[data-hub-chat-css="1"]')) return;
82
83
  const link = doc.createElement("link");
83
- link.setAttribute("rel", "stylesheet"); link.setAttribute("href", "/assets/hub-chat.css"); link.setAttribute("data-hub-chat-css", "1");
84
+ link.setAttribute("rel", "stylesheet"); link.setAttribute("href", assetUrl("/assets/hub-chat.css")); link.setAttribute("data-hub-chat-css", "1");
84
85
  doc.head.appendChild(link);
85
86
  } catch { /* the chat still works without it */ }
86
87
  }
@@ -232,7 +232,7 @@ export function createStubClient({ now = () => Date.now(), agents = () => [] } =
232
232
  export function createHubWebClient({ fetchImpl = (...a) => fetch(...a), readTimeoutMs = 120_000 } = {}) {
233
233
  // The factory override is for owned transports/rehearsals; the page uses the finite default.
234
234
  const readBudget = Number.isInteger(readTimeoutMs) && readTimeoutMs > 0 && readTimeoutMs <= 300_000 ? readTimeoutMs : 120_000;
235
- let csrf = null, codeNotices = false, roomsLive = false, teamsLive = false, generation = 0;
235
+ let csrf = null, codeNotices = false, roomsLive = false, teamsLive = false, ownerRequestsLive = false, roomDiscoveryLive = false, generation = 0;
236
236
  const ended = new Set(), pendingReads = new Map(), waits = new Set(), readControllers = new Set();
237
237
  let readTail = Promise.resolve();
238
238
  const retired = () => ({ ok: false, status: 401, code: "unauthenticated" });
@@ -302,18 +302,24 @@ export function createHubWebClient({ fetchImpl = (...a) => fetch(...a), readTime
302
302
  let json = null;
303
303
  try { json = await r.json(); } catch { json = null; }
304
304
  if (method === "GET" && signal?.aborted) return unreachable();
305
- if (r.status === 401 && mine === generation) { retireReads(); csrf = null; codeNotices = false; roomsLive = false; teamsLive = false; for (const fn of ended) { try { fn(); } catch { /* a listener's own failure */ } } }
305
+ if (r.status === 401 && mine === generation) { retireReads(); csrf = null; codeNotices = false; roomsLive = false; teamsLive = false; ownerRequestsLive = false; roomDiscoveryLive = false; for (const fn of ended) { try { fn(); } catch { /* a listener's own failure */ } } }
306
306
  if (!r.ok) return { ok: false, status: r.status, code: (json && typeof json.code === "string" && json.code) || "failed", retryAfter: Number(r.headers.get("Retry-After")) || 0,
307
307
  ...(method === "POST" && path === "/hub/v1/admin/enrolment-codes" && r.status === 429 && json?.code === "backpressure"
308
308
  && ["live-code-limit", "hourly-code-limit"].includes(json.reason) ? { reason: json.reason } : {}), ...roomRefusal(json) };
309
309
  return { ok: true, ...(json && typeof json === "object" ? json : {}) };
310
310
  }
311
311
  const id = (v) => encodeURIComponent(String(v));
312
+ const ownerRequestCall = async (scope, method, path, body) => {
313
+ if (!scope || scope !== csrf) return retired();
314
+ const mine = generation, result = await call(method, path, body);
315
+ return mine === generation && scope === csrf ? result : retired();
316
+ };
312
317
  // Track U2: a refused room write says what the person is told — 409 people-limit the room's would-be head count (the
313
318
  // deduplicated union, the creator and current members included) and the limit; 503 group-unavailable which group.
314
319
  const roomRefusal = (json) => json?.code === "people-limit" && Number.isSafeInteger(json.people)
315
320
  ? { people: json.people, limit: Number.isSafeInteger(json.limit) ? json.limit : 100 }
316
- : json?.code === "group-unavailable" && typeof json.group === "string" ? { group: json.group } : {};
321
+ : json?.code === "group-unavailable" && typeof json.group === "string" ? { group: json.group }
322
+ : json?.code === "request-limit" && Number.isSafeInteger(json.resetsAt) && json.resetsAt > 0 && json.resetsAt <= 8.64e15 ? { resetsAt: json.resetsAt } : {};
317
323
  // One stream per tab (#1580): every live subscription shares one EventSource. A Hub with rooms carries the notices on
318
324
  // its rooms stream too (`notices` = the notice version); before that the notices have their own. Listeners are kept
319
325
  // per event name; the stream closes with its last listener, and a refused (CLOSED) stream tells every subscriber once.
@@ -361,10 +367,22 @@ export function createHubWebClient({ fetchImpl = (...a) => fetch(...a), readTime
361
367
  stub: false, web: true,
362
368
  /** Hear the session end (a 401 anywhere). @returns {() => void} */
363
369
  onSignedOut(fn) { ended.add(fn); return () => ended.delete(fn); },
364
- async session() { const r = await call("GET", "/hub/v1/session"); if (r.ok) { csrf = r.signedIn ? r.csrf || null : null; codeNotices = r.signedIn === true && r.features?.includes("enrolment-code-v1") === true; roomsLive = r.signedIn === true && r.features?.includes(ROOMS_FEATURE) === true; teamsLive = r.signedIn === true && r.features?.includes(TEAMS_FEATURE) === true; } return r; },
365
- async signIn(login, password) { retireReads(); teamsLive = false; const r = await call("POST", "/hub/v1/session", { login, password }); if (r.ok) { csrf = r.csrf || null; codeNotices = r.features?.includes("enrolment-code-v1") === true; roomsLive = r.features?.includes(ROOMS_FEATURE) === true; teamsLive = r.features?.includes(TEAMS_FEATURE) === true; } return r; },
366
- async signOut() { retireReads(); const r = await call("DELETE", "/hub/v1/session"); csrf = null; codeNotices = false; roomsLive = false; teamsLive = false; return r; },
370
+ async session() { const r = await call("GET", "/hub/v1/session"); if (r.ok) { csrf = r.signedIn ? r.csrf || null : null; codeNotices = r.signedIn === true && r.features?.includes("enrolment-code-v1") === true; roomsLive = r.signedIn === true && r.features?.includes(ROOMS_FEATURE) === true; teamsLive = r.signedIn === true && r.features?.includes(TEAMS_FEATURE) === true; ownerRequestsLive = r.signedIn === true && r.features?.includes("room-owner-requests-v1") === true; roomDiscoveryLive = r.signedIn === true && r.features?.includes("room-agent-discovery-v1") === true; } return r; },
371
+ async signIn(login, password) { retireReads(); teamsLive = false; ownerRequestsLive = false; roomDiscoveryLive = false; const r = await call("POST", "/hub/v1/session", { login, password }); if (r.ok) { csrf = r.csrf || null; codeNotices = r.features?.includes("enrolment-code-v1") === true; roomsLive = r.features?.includes(ROOMS_FEATURE) === true; teamsLive = r.features?.includes(TEAMS_FEATURE) === true; ownerRequestsLive = r.features?.includes("room-owner-requests-v1") === true; roomDiscoveryLive = r.features?.includes("room-agent-discovery-v1") === true; } return r; },
372
+ async signOut() { retireReads(); const r = await call("DELETE", "/hub/v1/session"); csrf = null; codeNotices = false; roomsLive = false; teamsLive = false; ownerRequestsLive = false; roomDiscoveryLive = false; return r; },
367
373
  aiAppsScope() { return csrf; },
374
+ roomAgentRequestScope() { return csrf; },
375
+ requestRoomAgent(scope, roomId, input) { return ownerRequestCall(scope, "POST", "/hub/v1/rooms/" + id(roomId) + "/agent-requests", input); },
376
+ roomAgentRequests(scope, roomId, after) { return ownerRequestCall(scope, "GET", "/hub/v1/rooms/" + id(roomId) + "/agent-requests" + (after ? "?after=" + id(after) : "")); },
377
+ cancelRoomAgentRequest(scope, roomId, requestId) { return ownerRequestCall(scope, "DELETE", "/hub/v1/rooms/" + id(roomId) + "/agent-requests/" + id(requestId)); },
378
+ ownerRequestsLive() { return ownerRequestsLive; },
379
+ roomDiscoveryLive() { return roomDiscoveryLive; },
380
+ agentRoomDiscovery(scope, exposureId, input) { return ownerRequestCall(scope, input === undefined ? "GET" : "PUT", "/hub/v1/exposures/" + id(exposureId) + "/room-discovery", input); },
381
+ ownerAgentRequest(scope, requestId) { return ownerRequestCall(scope, "GET", "/hub/v1/agent-requests/" + id(requestId)); },
382
+ acceptOwnerAgentRequest(scope, requestId, input) { return ownerRequestCall(scope, "POST", "/hub/v1/agent-requests/" + id(requestId) + "/accept", input); },
383
+ declineOwnerAgentRequest(scope, requestId) { return ownerRequestCall(scope, "POST", "/hub/v1/agent-requests/" + id(requestId) + "/decline", {}); },
384
+ ownerAgentRequests(scope, after) { return ownerRequestCall(scope, "GET", "/hub/v1/agent-requests" + (after ? "?after=" + id(after) : "")); },
385
+ agentRequestSettings(scope, input) { return ownerRequestCall(scope, input === undefined ? "GET" : "PUT", "/hub/v1/me/agent-request-settings", input); },
368
386
  aiApps(scope) { return scope && scope === csrf ? call("GET", "/hub/v1/me/ai-apps") : Promise.resolve(retired()); },
369
387
  disconnectAiApp(scope, appId) { return scope && scope === csrf ? call("DELETE", `/hub/v1/me/ai-apps/${id(appId)}`) : Promise.resolve(retired()); },
370
388
  appConsent(scope, request) { return scope && scope === csrf ? call("GET", `/hub/v1/mcp/consent?${new URLSearchParams({request})}`) : Promise.resolve(retired()); },
@@ -443,7 +461,7 @@ export function createHubWebClient({ fetchImpl = (...a) => fetch(...a), readTime
443
461
  * server without rooms ignores the parameter (its answer is then normalised here).
444
462
  */
445
463
  async roomList() {
446
- const r = await call("GET", "/hub/v1/rooms?v=2");
464
+ const r = await call("GET", "/hub/v1/rooms?v=2" + (ownerRequestsLive ? "&ownerRequests=1" : ""));
447
465
  if (!r.ok || roomsLive) return r;
448
466
  return { ...r, rooms: (Array.isArray(r.rooms) ? r.rooms : []).map(legacyRoom).filter(Boolean) };
449
467
  },
@@ -479,6 +497,10 @@ export function createHubWebClient({ fetchImpl = (...a) => fetch(...a), readTime
479
497
  },
480
498
  /** M-3127: add (`on`) or take back my reaction `emoji` on a group-room message → { reactions }. */
481
499
  reactRoomMessage(roomId, messageId, emoji, on) { return call("POST", `/hub/v1/rooms/${id(roomId)}/messages/${id(messageId)}/reactions`, { emoji: String(emoji), on: on === true }); },
500
+ /** M-3340: my own pins in a group room (nobody else's) → { pins: [{ messageId, pinnedAt, message }] }, newest first. */
501
+ roomPins(roomId) { return call("GET", `/hub/v1/rooms/${id(roomId)}/pins`); },
502
+ /** M-3340: pin (`on`) or unpin a group-room message for me only → { pins }. Past 50: the Hub refuses (pins-full). */
503
+ pinRoomMessage(roomId, messageId, on) { return call(on ? "PUT" : "DELETE", `/hub/v1/rooms/${id(roomId)}/pins/${id(messageId)}`); },
482
504
  markRoomRead(roomId, upTo) { return call("POST", `/hub/v1/rooms/${id(roomId)}/read`, { upTo }); },
483
505
  /**
484
506
  * The one live stream of everything this person may see (seam 1): `handlers[name](data)` for each of ROOM_EVENTS,
@@ -531,6 +553,7 @@ export function createHubWebClient({ fetchImpl = (...a) => fetch(...a), readTime
531
553
  roomCandidates(q, kind, signal) {
532
554
  const s = new URLSearchParams({ q: String(q ?? "") });
533
555
  if (kind) s.set("kind", kind);
556
+ if (kind === "agent" && roomDiscoveryLive) s.set("discovery", "1");
534
557
  return call("GET", `/hub/v1/rooms/candidates?${s}`, undefined, signal);
535
558
  },
536
559
  /**
@@ -4,6 +4,7 @@ import { register, t } from "/assets/app-i18n.js";
4
4
  import { Dialog } from "/assets/ui-dialog.js";
5
5
  import { SubjectPicker } from "./hub-subject-picker.js";
6
6
  import { hubClient } from "./hub-client.js";
7
+ import { assetUrl } from "/assets/asset-url.js";
7
8
  register("hubGrantPicker", {
8
9
  en: {
9
10
  title: "Allow access to {0}", kind: "Allow", person: "A person", group: "An AD security group", team: "A team", teamPick: "Choose a team", teamHint: "The team's current members may ask. Removing someone from the team ends that permission. The grant's expiry keeps running.", findPerson: "Find a person", query: "Name or login", hint: "Type 2 to 64 characters.",
@@ -28,7 +29,7 @@ export function linkHubGrantPickerCss(doc = typeof document !== "undefined" ? do
28
29
  try {
29
30
  if (!doc?.head || doc.querySelector('link[data-hub-grant-picker-css="1"]')) return;
30
31
  const link = doc.createElement("link");
31
- link.setAttribute("rel", "stylesheet"); link.setAttribute("href", "/assets/hub-grant-picker.css"); link.setAttribute("data-hub-grant-picker-css", "1");
32
+ link.setAttribute("rel", "stylesheet"); link.setAttribute("href", assetUrl("/assets/hub-grant-picker.css")); link.setAttribute("data-hub-grant-picker-css", "1");
32
33
  doc.head.appendChild(link);
33
34
  } catch { /* The form's existing controls still work if the stylesheet cannot be linked. */ }
34
35
  }
@@ -2,6 +2,7 @@
2
2
  // module so a tab holding an older hub-strings.js still draws these pages (retained-module SKEW). Preview; off unless the
3
3
  // Hub's session says `group-policy-v1`.
4
4
  import { register, t } from "/assets/app-i18n.js";
5
+ import { assetUrl } from "/assets/asset-url.js";
5
6
 
6
7
  register("hubGroups", {
7
8
  en: {
@@ -112,7 +113,7 @@ export function linkHubGroupsCss(doc = typeof document !== "undefined" ? documen
112
113
  try {
113
114
  if (!doc || !doc.head || doc.querySelector('link[data-hub-groups-css="1"]')) return;
114
115
  const link = doc.createElement("link");
115
- link.setAttribute("rel", "stylesheet"); link.setAttribute("href", "/assets/hub-groups.css"); link.setAttribute("data-hub-groups-css", "1");
116
+ link.setAttribute("rel", "stylesheet"); link.setAttribute("href", assetUrl("/assets/hub-groups.css")); link.setAttribute("data-hub-groups-css", "1");
116
117
  doc.head.appendChild(link);
117
118
  } catch { /* the pages still work without it */ }
118
119
  }
@@ -8,6 +8,7 @@ import { hubClient } from "./hub-client.js";
8
8
  import { hi } from "./hub-invitations-strings.js";
9
9
  import { hroom } from "./hub-room-strings.js";
10
10
  import { linkRoomsU2Css } from "./hub-room-new-strings.js";
11
+ import { OwnerAgentRequestsList } from "./hub-room-owner-requests.js";
11
12
 
12
13
  linkRoomsU2Css();
13
14
 
@@ -42,7 +43,10 @@ const valid = (x) => x && typeof x.id === "string" && x.room && typeof x.room.na
42
43
  * The invitations themselves, each with 同意 / 不要. Nothing when there are none (My shared agents shows no empty box).
43
44
  * heading: the list's own 「邀請」 title — false where the page already says it (the invitations page's header).
44
45
  */
45
- export function InvitationsList({ client = hubClient(), heading = true } = {}) { // onOpenRoom: not used — the owner is not a member of the inviting room
46
+ export function InvitationsList({ client = hubClient(), heading = true } = {}) {
47
+ return html`<${OwnerAgentRequestsList} client=${client} heading=${heading} /><${LegacyInvitationsList} client=${client} heading=${heading} />`;
48
+ }
49
+ function LegacyInvitationsList({ client, heading }) { // onOpenRoom: not used — the owner is not a member of the inviting room
46
50
  const { list, error, reload, answer } = useInvitations(client);
47
51
  const [busy, setBusy] = useState(null), [note, setNote] = useState(null), inflight = useRef(false);
48
52
  if (error && !list) return html`<p class="note hub-invitations-error" role="alert">${hi("loadFailed")} <button type="button" class="btn btn-link" onClick=${() => { void reload(); }}>${hi("retry")}</button></p>`;
@@ -6,6 +6,7 @@ import { Dialog } from "/assets/ui-dialog.js";
6
6
  import { ms } from "./hub-my-agents-strings.js";
7
7
  import { rowAvailability, rowKey, shareRows, reconcileSharing } from "./hub-my-agents-model.js";
8
8
  import { HubGrantPicker } from "./hub-grant-picker.js";
9
+ import { assetUrl } from "/assets/asset-url.js";
9
10
  const tone = name => { let h = 0; for (const c of name) h = (h * 31 + c.codePointAt(0)) >>> 0; return h % 6; };
10
11
  const shortSeen = at => Number.isFinite(at) ? new Intl.DateTimeFormat(lang() === "zh-TW" ? "zh-TW" : "en-GB", { month: "short", day: "numeric", hour: "2-digit", minute: "2-digit", hourCycle: "h23" }).format(at) : "—";
11
12
  const Avatar = ({ name }) => html`<span class=${`hub-av sm t${tone(name)}`} aria-hidden="true">${[...name][0] || "?"}</span>`;
@@ -14,7 +15,7 @@ const STORE = "agend.hub.owner-sharing";
14
15
  const safeRead = scope => { try { const v = JSON.parse(sessionStorage.getItem(STORE)); return v?.scope === scope && Array.isArray(v.operations) ? v.operations.filter(op => op && typeof op.at === "number" && Array.isArray(op.rows) && op.input && typeof op.input.idempotencyKey === "string" && typeof op.input.fleetId === "string" && Array.isArray(op.input.share) && Array.isArray(op.input.stop)).slice(-32) : []; } catch { return []; } };
15
16
  function css() {
16
17
  if (document.querySelector('link[data-hub-my-agents-css]')) return;
17
- const link = document.createElement("link"); link.rel = "stylesheet"; link.href = "/assets/hub-my-agents.css"; link.setAttribute("data-hub-my-agents-css", "1"); document.head.appendChild(link);
18
+ const link = document.createElement("link"); link.rel = "stylesheet"; link.href = assetUrl("/assets/hub-my-agents.css"); link.setAttribute("data-hub-my-agents-css", "1"); document.head.appendChild(link);
18
19
  }
19
20
  const summary = x => !x?.grants?.length ? ms("nobody") : x.grants.some(g => g.subject?.kind !== "person") ? ms("subjects", x.grants.length) : mc("people", x.grants.length);
20
21
  export function HubMyAgents({ client, scope, shared = [], policy = false, personal = false, apps = false, pausable = false, subjects = false, onChanged, onAllow }) {
@@ -2,6 +2,7 @@
2
2
  // of its own (#3261 review): a tab that loaded B's hub-chat-strings.js / hub-chat.css before C keeps them, so C's words
3
3
  // and rules come only from here.
4
4
  import { register, t } from "/assets/app-i18n.js";
5
+ import { assetUrl } from "/assets/asset-url.js";
5
6
 
6
7
  export const ownerAdminEntryV1 = true;
7
8
  register("hubOwner", {
@@ -50,7 +51,7 @@ export function linkHubOwnerCss(doc = typeof document !== "undefined" ? document
50
51
  try {
51
52
  if (!doc || !doc.head || doc.querySelector('link[data-hub-owner-css="1"]')) return;
52
53
  const link = doc.createElement("link");
53
- link.setAttribute("rel", "stylesheet"); link.setAttribute("href", "/assets/hub-owner.css"); link.setAttribute("data-hub-owner-css", "1");
54
+ link.setAttribute("rel", "stylesheet"); link.setAttribute("href", assetUrl("/assets/hub-owner.css")); link.setAttribute("data-hub-owner-css", "1");
54
55
  doc.head.appendChild(link);
55
56
  } catch { /* the pages still work without it */ }
56
57
  }
@@ -4,6 +4,7 @@ import {ErrorState,Skeleton} from "/assets/ui-states.js";
4
4
  import {confirmDialog} from "/assets/ui-confirm.js";
5
5
  import {runtimeEnrollCommand} from "./runtime-commands.js";
6
6
  import {hp} from "./hub-personal-agent-strings.js";
7
+ import { assetUrl } from "/assets/asset-url.js";
7
8
  const refused=()=>({ok:false});
8
9
  const fields=agent=>({name:agent?.name??"",description:agent?.introBy?agent.intro:introPreview(agent?.description??""),cli:agent?.cli??"",model:agent?.model??"",ifRevision:agent?.revision??0,answerOnly:agent?.answerOnly===true});
9
10
  const policy=value=>({enabled:value.enabled===true,people:[...(value.people??[])],teams:[...(value.teams??[])]});
@@ -14,7 +15,7 @@ export function personalCliReason(cli){
14
15
  if(cli.id==="codex"&&["sandbox-unavailable","profile-unavailable"].includes(cli.personalStatus)&&cli.answerOnlyAvailable===false)return "answerOnlyFailed";
15
16
  return cli.id==="codex"&&cli.personalStatus==="sandbox-unavailable"?"codexSandbox":"profile";
16
17
  }
17
- function installCss(){if(typeof document==="undefined"||document.querySelector('link[data-personal-install="1"]'))return;const link=document.createElement("link");link.rel="stylesheet";link.href="/assets/runtime-install.css";link.setAttribute("data-personal-install","1");document.head.appendChild(link);}
18
+ function installCss(){if(typeof document==="undefined"||document.querySelector('link[data-personal-install="1"]'))return;const link=document.createElement("link");link.rel="stylesheet";link.href=assetUrl("/assets/runtime-install.css");link.setAttribute("data-personal-install","1");document.head.appendChild(link);}
18
19
  /** The captured sign-in is passed through every client call, including writes after an await. */
19
20
  export function HubPersonalAgent({client,scope,isAdmin=false,onSaved=()=>{}}){
20
21
  const [view,setView]=useState(null),[form,setForm]=useState(null),[busy,setBusy]=useState(false),[error,setError]=useState(""),[issued,setIssued]=useState(null),[copied,setCopied]=useState(false),[clock,setClock]=useState(Date.now()),[editing,setEditing]=useState(false),[waiting,setWaiting]=useState(false);
@@ -2,9 +2,10 @@
2
2
  import { html, useEffect, useState } from "/assets/app-html.js";
3
3
  import { register, t } from "/assets/app-i18n.js";
4
4
  import { hubClient } from "./hub-client.js";
5
+ import { assetUrl } from "/assets/asset-url.js";
5
6
 
6
7
  if (typeof document !== "undefined" && !document.querySelector('link[data-hub-quota]')) {
7
- const css = document.createElement("link"); css.rel = "stylesheet"; css.href = "/assets/hub-quota.css";
8
+ const css = document.createElement("link"); css.rel = "stylesheet"; css.href = assetUrl("/assets/hub-quota.css");
8
9
  css.setAttribute("data-hub-quota", ""); document.head.appendChild(css);
9
10
  }
10
11
 
@@ -1,4 +1,5 @@
1
1
  import {register,t} from "/assets/app-i18n.js";
2
+ import { assetUrl } from "/assets/asset-url.js";
2
3
  register("hubRole",{
3
4
  "en": {
4
5
  "migrationNotice": "Roles and permissions are now available. Nobody’s access changed during migration.",
@@ -435,5 +436,5 @@ const styles = new WeakMap();
435
436
  export function linkRoleCss(doc = typeof document === "undefined" ? null : document) {
436
437
  if (!doc?.head) return Promise.resolve(false);
437
438
  if (styles.has(doc)) return styles.get(doc);
438
- const ready = new Promise(resolve => {const link=doc.createElement("link");link.setAttribute("rel","stylesheet");link.setAttribute("href","/assets/hub-roles.css");link.setAttribute("data-hub-roles-css","1");link.addEventListener("load",()=>resolve(true),{once:true});link.addEventListener("error",()=>{styles.delete(doc);link.remove();resolve(false);},{once:true});doc.head.appendChild(link);});styles.set(doc,ready);return ready;
439
+ const ready = new Promise(resolve => {const link=doc.createElement("link");link.setAttribute("rel","stylesheet");link.setAttribute("href",assetUrl("/assets/hub-roles.css"));link.setAttribute("data-hub-roles-css","1");link.addEventListener("load",()=>resolve(true),{once:true});link.addEventListener("error",()=>{styles.delete(doc);link.remove();resolve(false);},{once:true});doc.head.appendChild(link);});styles.set(doc,ready);return ready;
439
440
  }
@@ -2,6 +2,7 @@
2
2
  // settings, section 7): only the words the shared room vocabulary (hub-room-strings.js, namespace hubRoom) does not have.
3
3
  // A module of its own, so a tab holding an older dictionary still has every word (upgrade skew).
4
4
  import { register, t } from "/assets/app-i18n.js";
5
+ import { assetUrl } from "/assets/asset-url.js";
5
6
 
6
7
  register("hubRoomNew", {
7
8
  en: {
@@ -40,7 +41,7 @@ export function linkRoomsU2Css(doc = typeof document !== "undefined" ? document
40
41
  try {
41
42
  if (!doc || !doc.head || doc.querySelector('link[data-hub-rooms-u2-css="1"]')) return;
42
43
  const link = doc.createElement("link");
43
- link.setAttribute("rel", "stylesheet"); link.setAttribute("href", "/assets/hub-rooms-u2.css"); link.setAttribute("data-hub-rooms-u2-css", "1");
44
+ link.setAttribute("rel", "stylesheet"); link.setAttribute("href", assetUrl("/assets/hub-rooms-u2.css")); link.setAttribute("data-hub-rooms-u2-css", "1");
44
45
  doc.head.appendChild(link);
45
46
  } catch { /* the screens still work without it */ }
46
47
  }
@@ -8,6 +8,7 @@ import {RoomPurposeField,purposeCount} from "./hub-room-purpose.js";
8
8
  import { html, useEffect, useRef, useState } from "/assets/app-html.js";
9
9
  import { Dialog } from "/assets/ui-dialog.js";
10
10
  import { hubClient } from "./hub-client.js";
11
+ import { hrq } from "./hub-room-owner-requests-strings.js";
11
12
  import { hroom } from "./hub-room-strings.js";
12
13
  import { hn, linkRoomsU2Css } from "./hub-room-new-strings.js";
13
14
 
@@ -33,12 +34,17 @@ const keyOf = (item) => `${item.kind}:${item.id}`;
33
34
  * A picked AD group is read first (client.roomGroup): its tag shows its head count, and a group the directory cannot
34
35
  * read whole is not added — the other picks stay.
35
36
  */
36
- export function RoomPicker({ client, kinds, picked, onChange, placeholder, label, id, exclude = [], fixed = null, note = "" } = {}) {
37
+ export function RoomPicker({ client, kinds, picked, onChange, placeholder, label, id, exclude = [], fixed = null, note = "", searchHelp = null } = {}) {
37
38
  const [q, setQ] = useState(""), [results, setResults] = useState(null), [failed, setFailed] = useState(false), [groupNote, setGroupNote] = useState("");
38
39
  const asked = useRef(0), timer = useRef(null), latest = useRef(picked), live = useRef(true);
39
40
  latest.current = picked;
40
41
  const agents = kinds.includes("agent");
41
42
  useEffect(() => { live.current = true; return () => { live.current = false; clearTimeout(timer.current); }; }, []);
43
+ const leave = (event) => {
44
+ // Null is ambiguous on touch/Safari; retain in-field pointer selection.
45
+ if (!event.relatedTarget || event.currentTarget.contains(event.relatedTarget)) return;
46
+ clearTimeout(timer.current); ++asked.current; setResults(null);
47
+ };
42
48
  const search = (text) => {
43
49
  setQ(text); clearTimeout(timer.current);
44
50
  const mine = ++asked.current;
@@ -63,7 +69,7 @@ export function RoomPicker({ client, kinds, picked, onChange, placeholder, label
63
69
  if (!r?.ok) { setGroupNote(hn("groupUnavailable", item.name)); return; }
64
70
  onChange([...latest.current, { ...item, ...(typeof r.name === "string" && r.name ? { name: r.name } : {}), ...(Number.isSafeInteger(r.people) ? { people: r.people } : {}) }]);
65
71
  };
66
- return html`<div class="field hub-room-picker">
72
+ return html`<div class="field hub-room-picker" onFocusOut=${leave}>
67
73
  <label for=${id}><span>${label}</span></label>
68
74
  <ul class="hub-room-tags">
69
75
  ${fixed}
@@ -74,8 +80,9 @@ export function RoomPicker({ client, kinds, picked, onChange, placeholder, label
74
80
  ${failed ? html`<p class="note" role="alert">${hn("searchFailed")}</p>` : null}
75
81
  ${groupNote || note ? html`<p class="note hub-room-picker-note" role="alert">${groupNote || note}</p>` : null}
76
82
  ${results && !failed ? offer.length ? html`<ul class="hub-room-results" role="listbox" aria-label=${label}>${offer.map(c => html`<li key=${keyOf(c)}>
77
- <button type="button" role="option" class="hub-room-result" onClick=${() => { void pick(c); }}>${pickLabel(c)}${c.intro?html` <small class="note">${c.intro}</small>`:null}${c.owner?.name && c.kind === "agent" ? html` <small class="note">${c.owner.name}</small>` : null}${c.kind === "agent" && !c.mine ? html` <small class="note">${hroom("invitePending")}</small>` : null}</button></li>`)}</ul>`
83
+ <button type="button" role="option" class=${`hub-room-result${c.kind === "agent" ? " hub-room-result-agent" : ""}`} aria-label=${c.kind === "person" ? `${c.name}${c.detail ? `, ${c.detail}` : ""}` : c.kind === "agent" && !c.mine ? hrq("askOwnerLabel", c.owner?.name || "", c.name) : undefined} onClick=${() => { void pick(c); }}>${c.kind === "person" ? html`<span class="hub-room-person-label"><span class="hub-room-person-name" title=${c.name}>${c.name}</span>${c.detail ? html`<small class="note hub-room-person-detail" title=${c.detail}>${c.detail}</small>` : null}</span>` : c.kind === "agent" ? html`<span class="hub-room-agent-label"><span class="hub-room-agent-title">${c.name}${c.owner?.name ? html` <small class="note">${c.owner.name}</small>` : null}</span>${c.intro ? html`<small class="note hub-room-agent-intro" title=${c.intro}>${c.intro}</small>` : null}</span> ${!c.mine ? html`<span class="btn btn-sm hub-room-agent-action">${hrq("askOwner", c.owner?.name || "")}</span>` : null}` : pickLabel(c)}${c.kind !== "agent" && c.intro ? html` <small class="note">${c.intro}</small>` : null}</button></li>`)}</ul>`
78
84
  : html`<p class="note">${hn("noMatch")}</p>` : null}
85
+ ${q.trim() ? searchHelp : null}
79
86
  </div>`;
80
87
  }
81
88