@songsid/agend 2.4.0-alpha.1 → 2.4.0-alpha.2

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 (235) hide show
  1. package/README.md +1 -1
  2. package/README.zh-TW.md +1 -1
  3. package/dist/agent-whats-new.js +2 -0
  4. package/dist/agent-whats-new.js.map +1 -1
  5. package/dist/auth-api.js +3 -1
  6. package/dist/auth-api.js.map +1 -1
  7. package/dist/backend/claude-code.js +4 -0
  8. package/dist/backend/claude-code.js.map +1 -1
  9. package/dist/backend/types.d.ts +6 -0
  10. package/dist/backend/types.js.map +1 -1
  11. package/dist/backend-availability.d.ts +1 -1
  12. package/dist/backend-availability.js +28 -1
  13. package/dist/backend-availability.js.map +1 -1
  14. package/dist/browser-backend-signins.d.ts +7 -1
  15. package/dist/browser-backend-signins.js +8 -4
  16. package/dist/browser-backend-signins.js.map +1 -1
  17. package/dist/build-provenance.json +1 -1
  18. package/dist/channel/mcp-tools.js +1 -1
  19. package/dist/channel/mcp-tools.js.map +1 -1
  20. package/dist/config-validator.js +47 -7
  21. package/dist/config-validator.js.map +1 -1
  22. package/dist/daemon.d.ts +3 -0
  23. package/dist/daemon.js +4 -0
  24. package/dist/daemon.js.map +1 -1
  25. package/dist/fleet-manager.d.ts +33 -4
  26. package/dist/fleet-manager.js +143 -61
  27. package/dist/fleet-manager.js.map +1 -1
  28. package/dist/general-knowledge/skills/credential-profiles/SKILL.md +19 -0
  29. package/dist/hub/audit/index.js +12 -5
  30. package/dist/hub/audit/index.js.map +1 -1
  31. package/dist/hub/catalog.d.ts +6 -0
  32. package/dist/hub/catalog.js +14 -4
  33. package/dist/hub/catalog.js.map +1 -1
  34. package/dist/hub/client.js +2 -0
  35. package/dist/hub/client.js.map +1 -1
  36. package/dist/hub/compose/member.d.ts +2 -0
  37. package/dist/hub/compose/member.js +11 -2
  38. package/dist/hub/compose/member.js.map +1 -1
  39. package/dist/hub/compose/server.js +2 -1
  40. package/dist/hub/compose/server.js.map +1 -1
  41. package/dist/hub/enrolment-code.d.ts +126 -0
  42. package/dist/hub/enrolment-code.js +266 -0
  43. package/dist/hub/enrolment-code.js.map +1 -0
  44. package/dist/hub/group-policy/admin-impact.js +4 -2
  45. package/dist/hub/group-policy/admin-impact.js.map +1 -1
  46. package/dist/hub/group-policy/admin-inventory.js +6 -6
  47. package/dist/hub/group-policy/admin-inventory.js.map +1 -1
  48. package/dist/hub/group-policy/authorization.d.ts +16 -2
  49. package/dist/hub/group-policy/authorization.js +69 -5
  50. package/dist/hub/group-policy/authorization.js.map +1 -1
  51. package/dist/hub/group-policy/impact-inventory.js +3 -3
  52. package/dist/hub/group-policy/impact-inventory.js.map +1 -1
  53. package/dist/hub/group-policy/resources.d.ts +40 -1
  54. package/dist/hub/group-policy/resources.js +51 -13
  55. package/dist/hub/group-policy/resources.js.map +1 -1
  56. package/dist/hub/group-policy/store.d.ts +6 -0
  57. package/dist/hub/group-policy/store.js +49 -4
  58. package/dist/hub/group-policy/store.js.map +1 -1
  59. package/dist/hub/http/compose.js +30 -6
  60. package/dist/hub/http/compose.js.map +1 -1
  61. package/dist/hub/init/text.js +2 -2
  62. package/dist/hub/init/text.js.map +1 -1
  63. package/dist/hub/init/web.d.ts +7 -0
  64. package/dist/hub/init/web.js +6 -1
  65. package/dist/hub/init/web.js.map +1 -1
  66. package/dist/hub/join/local.d.ts +27 -0
  67. package/dist/hub/join/local.js +70 -5
  68. package/dist/hub/join/local.js.map +1 -1
  69. package/dist/hub/join/receipt.d.ts +1 -0
  70. package/dist/hub/join/receipt.js +1 -1
  71. package/dist/hub/join/receipt.js.map +1 -1
  72. package/dist/hub/join/service.d.ts +92 -6
  73. package/dist/hub/join/service.js +199 -28
  74. package/dist/hub/join/service.js.map +1 -1
  75. package/dist/hub/join/store.d.ts +2 -1
  76. package/dist/hub/join/store.js +7 -7
  77. package/dist/hub/join/store.js.map +1 -1
  78. package/dist/hub/member/exposure-api.d.ts +2 -0
  79. package/dist/hub/member/exposure-api.js +3 -2
  80. package/dist/hub/member/exposure-api.js.map +1 -1
  81. package/dist/hub/member/exposures.d.ts +4 -0
  82. package/dist/hub/member/exposures.js +12 -2
  83. package/dist/hub/member/exposures.js.map +1 -1
  84. package/dist/hub/member/pairing-notices.js +8 -6
  85. package/dist/hub/member/pairing-notices.js.map +1 -1
  86. package/dist/hub/pairing-notices.d.ts +5 -2
  87. package/dist/hub/pairing-notices.js +38 -13
  88. package/dist/hub/pairing-notices.js.map +1 -1
  89. package/dist/hub/pairing.d.ts +7 -2
  90. package/dist/hub/protocol.d.ts +47 -0
  91. package/dist/hub/protocol.js +3 -1
  92. package/dist/hub/protocol.js.map +1 -1
  93. package/dist/hub/server.js +15 -1
  94. package/dist/hub/server.js.map +1 -1
  95. package/dist/hub/types.d.ts +12 -4
  96. package/dist/hub-pairing-summary.js +1 -1
  97. package/dist/hub-pairing-summary.js.map +1 -1
  98. package/dist/instance-config-impact.js +4 -0
  99. package/dist/instance-config-impact.js.map +1 -1
  100. package/dist/instance-lifecycle.js +4 -0
  101. package/dist/instance-lifecycle.js.map +1 -1
  102. package/dist/locale.js +6 -2
  103. package/dist/locale.js.map +1 -1
  104. package/dist/log-service.d.ts +62 -6
  105. package/dist/log-service.js +135 -28
  106. package/dist/log-service.js.map +1 -1
  107. package/dist/log-steps-agy-grok.d.ts +74 -0
  108. package/dist/log-steps-agy-grok.js +440 -0
  109. package/dist/log-steps-agy-grok.js.map +1 -0
  110. package/dist/log-steps.d.ts +62 -3
  111. package/dist/log-steps.js +188 -22
  112. package/dist/log-steps.js.map +1 -1
  113. package/dist/log-transcript-paths.d.ts +29 -0
  114. package/dist/log-transcript-paths.js +109 -0
  115. package/dist/log-transcript-paths.js.map +1 -0
  116. package/dist/login-controller.d.ts +17 -3
  117. package/dist/login-controller.js +57 -5
  118. package/dist/login-controller.js.map +1 -1
  119. package/dist/login-window-lock.d.ts +20 -8
  120. package/dist/login-window-lock.js +35 -16
  121. package/dist/login-window-lock.js.map +1 -1
  122. package/dist/outbound-handlers.d.ts +14 -0
  123. package/dist/outbound-handlers.js +49 -1
  124. package/dist/outbound-handlers.js.map +1 -1
  125. package/dist/profile-signins.d.ts +2 -0
  126. package/dist/profile-signins.js +1 -1
  127. package/dist/profile-signins.js.map +1 -1
  128. package/dist/settings-api.d.ts +34 -0
  129. package/dist/settings-api.js +184 -6
  130. package/dist/settings-api.js.map +1 -1
  131. package/dist/settings-change.js +38 -1
  132. package/dist/settings-change.js.map +1 -1
  133. package/dist/settings-effect.js +14 -0
  134. package/dist/settings-effect.js.map +1 -1
  135. package/dist/tool-progress.d.ts +7 -0
  136. package/dist/tool-progress.js +21 -9
  137. package/dist/tool-progress.js.map +1 -1
  138. package/dist/types.d.ts +13 -0
  139. package/dist/ui/accounts-view.js +14 -4
  140. package/dist/ui/agent-details-settings.js +2 -2
  141. package/dist/ui/agent-page-strings.js +2 -2
  142. package/dist/ui/backend-signin.js +47 -14
  143. package/dist/ui/chat-activity-groups.js +225 -0
  144. package/dist/ui/chat-activity.js +355 -0
  145. package/dist/ui/chat-popout-header.js +35 -0
  146. package/dist/ui/chat-popout-transport.js +80 -0
  147. package/dist/ui/chat-popout.js +63 -0
  148. package/dist/ui/chat-quote.js +3 -1
  149. package/dist/ui/chat-store.js +45 -4
  150. package/dist/ui/chat-workspace-gestures.js +177 -0
  151. package/dist/ui/chat-workspace-navigation.js +34 -10
  152. package/dist/ui/chat-workspace.js +96 -32
  153. package/dist/ui/host-install.js +2 -2
  154. package/dist/ui/hub-agent-copy.js +7 -7
  155. package/dist/ui/hub-chat-strings.js +3 -3
  156. package/dist/ui/hub-client.js +77 -17
  157. package/dist/ui/hub-company-join-strings.js +12 -10
  158. package/dist/ui/hub-company-join.js +52 -39
  159. package/dist/ui/hub-confirm-place.js +44 -0
  160. package/dist/ui/hub-directory-editor-strings.js +3 -3
  161. package/dist/ui/hub-directory-notice-strings.js +1 -1
  162. package/dist/ui/hub-enrolment-code-strings.js +44 -0
  163. package/dist/ui/hub-enrolment-code.js +159 -0
  164. package/dist/ui/hub-group-search.js +82 -0
  165. package/dist/ui/hub-group-strings.js +8 -8
  166. package/dist/ui/hub-join-approval.js +31 -0
  167. package/dist/ui/hub-join-code-input.js +66 -0
  168. package/dist/ui/hub-join-queue.js +62 -0
  169. package/dist/ui/hub-join-steps.js +231 -0
  170. package/dist/ui/hub-joincode-flow-strings.js +22 -0
  171. package/dist/ui/hub-owner-strings.js +9 -9
  172. package/dist/ui/hub-pairing-progress-strings.js +1 -1
  173. package/dist/ui/hub-quick-pairing.js +8 -4
  174. package/dist/ui/hub-quick-strings.js +11 -11
  175. package/dist/ui/hub-share-refused.js +17 -0
  176. package/dist/ui/hub-strings.js +61 -61
  177. package/dist/ui/hub-this-hub.js +2 -2
  178. package/dist/ui/hub-welcome.js +26 -5
  179. package/dist/ui/image-annotate.js +283 -0
  180. package/dist/ui/image-lightbox.js +26 -6
  181. package/dist/ui/log-row.js +327 -0
  182. package/dist/ui/panel-chat.js +151 -12
  183. package/dist/ui/panel-details.js +14 -6
  184. package/dist/ui/panel-hub.js +42 -13
  185. package/dist/ui/panel-log.js +9 -154
  186. package/dist/ui/panel-settings.js +48 -11
  187. package/dist/ui/search-dialog.js +1 -0
  188. package/dist/ui/settings-access-overview.js +1 -1
  189. package/dist/ui/settings-hub-browser-certificate.js +3 -3
  190. package/dist/ui/settings-hub-company-join.js +41 -30
  191. package/dist/ui/settings-hub-connection.js +8 -5
  192. package/dist/ui/settings-hub-membership.js +3 -3
  193. package/dist/ui/settings-hub-section.js +1 -1
  194. package/dist/ui/settings-hub-setup-strings.js +6 -6
  195. package/dist/ui/settings-hub-setup.js +44 -6
  196. package/dist/ui/settings-hub.js +35 -10
  197. package/dist/ui/settings-layout.js +6 -4
  198. package/dist/ui/settings-public-session-strings.js +37 -0
  199. package/dist/ui/settings-registry.js +4 -0
  200. package/dist/ui/settings-strings.js +2 -2
  201. package/dist/ui/shared/app-shell.js +16 -10
  202. package/dist/ui/shared/app.css +195 -30
  203. package/dist/ui/shared/app.js +8 -1
  204. package/dist/ui/shared/chat-render.js +11 -2
  205. package/dist/ui/shared/chat-thread.js +20 -3
  206. package/dist/ui/shared/chat-work-bar.css +7 -0
  207. package/dist/ui/shared/chat-workspace-model.js +39 -9
  208. package/dist/ui/shared/hub-owner.css +8 -0
  209. package/dist/ui/shared/identity-color.js +9 -3
  210. package/dist/ui/shared/image-annotate.css +45 -0
  211. package/dist/ui/shared/instance-nav.js +59 -22
  212. package/dist/ui/shared/pane-geometry.js +29 -0
  213. package/dist/ui/shared/signin.js +2 -2
  214. package/dist/ui/shared/tokens.css +14 -0
  215. package/dist/ui/shared/ui-menu.js +22 -7
  216. package/dist/ui/signin.html +1 -1
  217. package/dist/ui/structured-signin.js +11 -4
  218. package/dist/web-api.d.ts +1 -0
  219. package/dist/web-api.js +34 -4
  220. package/dist/web-api.js.map +1 -1
  221. package/dist/web-backend-login.d.ts +9 -3
  222. package/dist/web-backend-login.js +7 -4
  223. package/dist/web-backend-login.js.map +1 -1
  224. package/dist/web-chat-history.d.ts +11 -0
  225. package/dist/web-chat-history.js +9 -1
  226. package/dist/web-chat-history.js.map +1 -1
  227. package/dist/web-guest-access.js +2 -2
  228. package/dist/web-guest-access.js.map +1 -1
  229. package/dist/web-session.d.ts +31 -3
  230. package/dist/web-session.js +25 -4
  231. package/dist/web-session.js.map +1 -1
  232. package/dist/web-settings-patch.d.ts +8 -2
  233. package/dist/web-settings-patch.js +22 -10
  234. package/dist/web-settings-patch.js.map +1 -1
  235. package/package.json +1 -1
@@ -11,18 +11,24 @@ import { Dialog } from "/assets/ui-dialog.js";
11
11
  import { register, t } from "/assets/app-i18n.js";
12
12
  import { toast } from "/assets/ui-toast.js";
13
13
  import { routePath, detailsPath } from "/assets/app-route.js";
14
- import { supportsInstanceFeature } from "/assets/instance-nav.js";
14
+ import { labelOf, modelText, supportsInstanceFeature } from "/assets/instance-nav.js";
15
+ import { modelLabel } from "./model-picker.js";
15
16
  import { agentRoute, PANE_VIEWS, twoPaneFits } from "/assets/chat-workspace-model.js";
16
17
  import { workspaceMemory } from "/assets/chat-workspace-memory.js";
17
- import { installWorkspaceNavigation } from "./chat-workspace-navigation.js";
18
+ import * as workspaceNavigation from "./chat-workspace-navigation.js";
19
+ import { floatBox, splitSize } from "/assets/pane-geometry.js";
20
+ import { createWorkspaceGestures, geometryText } from "./chat-workspace-gestures.js";
21
+ import { createPanePopout, popoutText } from "./chat-popout.js";
18
22
 
19
23
  register("chatWorkspace", {
20
24
  en: { beside: "Open beside", replace: "Replace: {0}", split: "Split chat", choose: "Choose a second agent", current: "Focused pane", currentShort: "Active",
21
25
  right: "Side by side", stack: "Top and bottom", swap: "Swap positions", close: "Close this pane", other: "Focus the other pane",
22
- unavailable: "Split chat could not load. Your current chat is unchanged. Reload this page to try again.", pane: "{0} · {1}", quote: "Quote into the other pane: {0}", quoteAgain: "Finish or discard the other pane's settings, then quote again." },
26
+ paneGroup: "Pane", agentGroup: "Agent", appearanceGroup: "Appearance", deleteGroup: "Delete", modelEffort: "Model and effort…",
27
+ unavailable: "Split chat could not load. Your current chat is unchanged. Reload this page to try again.", pane: "{0} · {1}", quote: "Quote into the other pane ({0})", quoteAgain: "Finish or discard the other pane's settings, then quote again." },
23
28
  "zh-TW": { beside: "在旁邊開啟", replace: "取代:{0}", split: "分割對話", choose: "選擇第二個 Agent", current: "目前窗格", currentShort: "目前",
24
29
  right: "左右排列", stack: "上下排列", swap: "交換位置", close: "收起此格", other: "切換到另一窗格",
25
- unavailable: "未能載入分割對話。目前對話不變;請重新整理頁面再試。", pane: "{0}・{1}", quote: "引用到另一窗格:{0}", quoteAgain: "請先完成或放棄另一窗格的設定變更,再次引用。" },
30
+ paneGroup: "窗格", agentGroup: "Agent", appearanceGroup: "外觀", deleteGroup: "刪除", modelEffort: "模型與強度…",
31
+ unavailable: "未能載入分割對話。目前對話不變;請重新整理頁面再試。", pane: "{0}・{1}", quote: "引用到另一格({0})", quoteAgain: "請先完成或放棄另一窗格的設定變更,再次引用。" },
26
32
  });
27
33
  export const tw = (key, ...values) => t(`chatWorkspace.${key}`, ...values);
28
34
  const viewLabel = view => t(`app.${view === "details" ? "details" : view}`);
@@ -34,7 +40,8 @@ export async function verifyWorkspaceDependencies({ chat, details, log, view })
34
40
  import("/assets/instance-switch.js"), import("/assets/ui-menu.js"), import("/assets/view-roster-store.js"),
35
41
  import("/assets/chat-composer.js"), import("./image-lightbox.js"), import("/assets/preview-panel.js"),
36
42
  import("./agent-runtime-settings.js"), import("./agent-export-dialog.js"), import("/assets/app-session.js")]);
37
- if (!paneState.usePaneState || !chat.ChatPanel.workspaceVersion || !details.DetailsPanel.workspaceVersion || !log.LogPanel.workspaceVersion || !view.ViewPanel.workspaceVersion
43
+ if (getComputedStyle(document.documentElement).getPropertyValue("--chat-workspace-geometry-version").trim() !== "1"
44
+ || !workspaceNavigation.workspaceGeometryVersion || !paneState.usePaneState || !chat.ChatPanel.workspaceVersion || !details.DetailsPanel.workspaceVersion || !log.LogPanel.workspaceVersion || !view.ViewPanel.workspaceVersion
38
45
  || !fields.AgentFields.paneIds || !fields.ClassicFields.paneIds || !native.NativeFields.paneIds
39
46
  || !quote.installQuoteSelection.workspaceVersion || !tabs.InstanceSwitch.workspaceVersion || !menu.Menu.workspaceVersion || !roster.followRoster
40
47
  || !composer.ComposerInput.paneIds || !composer.WorkBarView.paneIds || !image.LightboxHost.paneOwner
@@ -89,17 +96,36 @@ export function PaneHeader({ title, sub, headingRef, nav, notice, pageControls,
89
96
  }, [pane.focused, pageControls, foldTools]);
90
97
  useLayoutEffect(() => () => pane.controls.release(token.current), []);
91
98
  const tabs = pane.tabs.filter(tab => !pane.visibleTabs.includes(tab));
99
+ const app = useStore(appStore), inst = app.instances.find(it => it.name === pane.name);
100
+ const inherited = (pane.focused ? pageActions || [] : []).filter(item => item && !item.heading
101
+ && !["splitChat", "split", "pane-backend", "pane-model", "pane-effort"].includes(item.key) && item.label !== tw("split"));
102
+ const appearance = item => /^(identity-color|theme-|page-|widget-|ambient-|fullWidth)/.test(item.key || "");
103
+ const group = (key, actions) => actions.length ? [{ key: `${key}-heading`, heading: true, label: tw(`${key}Group`) }, ...actions.map(item => ({ ...item, icon: item.icon || "settings" }))] : [];
104
+ const value = inst && [modelLabel(inst.model || modelText(inst) || ""), inst.effort || (inst.effort_supported ? "auto" : "")].filter(Boolean).join(" · ");
92
105
  const items = [
93
- ...tabs.map(view => ({ key: `tab-${view}`, label: viewLabel(view), onSelect: () => pane.navigate(routePath({ panel: view, instance: pane.name })) })),
94
- { key: "right", label: tw("right"), checked: pane.layout === "right", onSelect: () => pane.controller.layout("right") },
95
- { key: "stack", label: tw("stack"), checked: pane.layout === "stack", onSelect: () => pane.controller.layout("stack") },
96
- { key: "swap", label: tw("swap"), onSelect: () => pane.controller.swap() },
97
- { key: "other", label: tw("other"), onSelect: () => pane.controller.focus(pane.id === "a" ? "b" : "a", { moveFocus: true }) },
106
+ ...group("pane", [
107
+ ...tabs.map(view => ({ key: `tab-${view}`, label: viewLabel(view), icon: view === "details" ? "settings" : view === "log" ? "file" : view, onSelect: () => pane.navigate(routePath({ panel: view, instance: pane.name })) })),
108
+ { key: "right", label: tw("right"), icon: "sidebar", checked: pane.layout === "right", onSelect: () => pane.controller.layout("right") },
109
+ { key: "stack", label: tw("stack"), icon: "down", checked: pane.layout === "stack", onSelect: () => pane.controller.layout("stack") },
110
+ { key: "float", label: geometryText("float"), icon: "external", checked: pane.floating, onSelect: () => pane.controller.layout("float", pane.id) },
111
+ ...(pane.floating ? [{ key: "move-float", label: geometryText("move"), icon: "fullscreen", onSelect: () => pane.gestures.keyboard("move", pane.id) },
112
+ { key: "resize-float", label: geometryText("resize"), icon: "fitwidth", onSelect: () => pane.gestures.keyboard("resize", pane.id) }] : []),
113
+ ...(pane.layout !== "float" ? [{ key: "halves", label: geometryText("reset"), icon: "restart", onSelect: () => pane.controller.geometry({ ratio: .5 }) }] : []),
114
+ { key: "swap", label: tw("swap"), icon: "restart", onSelect: () => pane.controller.swap() },
115
+ { key: "other", label: tw("other"), icon: "sidebar", onSelect: () => pane.controller.focus(pane.id === "a" ? "b" : "a", { moveFocus: true }) },
98
116
  { key: "split", label: tw("split"), icon: "sidebar", onSelect: () => choose(pane.controller, undefined, pane.id) },
99
- { key: "close", label: tw("close"), icon: "close", onSelect: () => pane.controller.closePane(pane.id) },
100
- ...(pane.focused ? pageActions || [] : []),
117
+ ...(pane.popout ? [{ key: "popout", label: popoutText("open"), icon: "external", onSelect: () => pane.popout.open(pane.controller, pane.id) }] : []),
118
+ { key: "close", label: tw("close"), icon: "close", onSelect: () => pane.controller.closePane(pane.id) }]),
119
+ ...group("agent", [
120
+ ...(pane.focused && inst && supportsInstanceFeature(inst, "details") ? [{ key: "model-effort", icon: "settings", label: html`<span class="menu-label-value"><span>${tw("modelEffort")}</span><span class="menu-value" title=${value}>${value}</span></span>`, onSelect: () => pane.navigate(`${detailsPath(pane.name)}?cat=runtime`) }] : []),
121
+ ...inherited.filter(item => !appearance(item) && item.key !== "delete")]),
122
+ ...group("appearance", inherited.filter(appearance)),
123
+ ...group("delete", inherited.filter(item => item.key === "delete")),
101
124
  ];
102
- return html`<header data-trust="header" class="panel-head ws-pane-head">
125
+ const interactive = event => event.target.closest("a,button,input,textarea,select,[contenteditable],.ws-page-tools");
126
+ return html`<header data-trust="header" class="panel-head ws-pane-head" draggable=${!pane.floating}
127
+ onDragStart=${event => { if (interactive(event) || !pane.gestures.dragStart(pane.name, event, pane.id)) event.preventDefault(); }} onDragEnd=${pane.gestures.dragEnd}
128
+ onPointerDown=${event => { if (pane.floating && !interactive(event)) pane.gestures.floatDown("move", pane.id, event); }}>
103
129
  ${shell.collapsed && pane.focused ? html`<button type="button" id="sbOpen" class="icon-btn sb-open" aria-label=${t("app.expand")}
104
130
  title=${t("app.expand")} aria-controls="sidebar" onClick=${toggleSidebar}><${Icon} name="menu" /></button>` : null}
105
131
  <div class="panel-title">${pane.focused ? html`<span class="tag ws-focus-label">${tw("currentShort")}</span>` : null}<h1 ref=${headingRef} tabindex="-1" title=${typeof title === "string" ? title : pane.name}>${title}</h1>
@@ -107,15 +133,16 @@ export function PaneHeader({ title, sub, headingRef, nav, notice, pageControls,
107
133
  ${nav}
108
134
  <div class="panel-actions"><span class=${`ws-tools-slot${foldTools ? " ws-tools-folded" : ""}`} ref=${slot}></span>
109
135
  <button type="button" class="icon-btn ws-pane-split" title=${tw("split")} aria-label=${tw("split")} onClick=${event => choose(pane.controller, event, pane.id)}><${Icon} name="sidebar" /></button>
110
- <${Menu} ownerKey=${`${pane.name}:${pane.route.panel}`} inactive=${!pane.focused} onOpen=${() => pane.controller.focus(pane.id)} items=${items} label=${t("app.more")}
136
+ <${Menu} cls="agent-menu" fit=${true} ownerKey=${`${pane.name}:${pane.route.panel}`} inactive=${!pane.focused} onOpen=${() => pane.controller.focus(pane.id)} items=${items} label=${t("app.more")}
111
137
  leading=${foldTools && pane.focused ? html`<div class="ws-menu-tools" role="presentation" ref=${el => { menuSlot.current = el; pane.controls.move(token.current, el || slot.current, !!el); }}></div>` : null} />
112
138
  <button type="button" class="icon-btn ws-pane-close" title=${tw("close")} aria-label=${tw("close")} onClick=${() => pane.controller.closePane(pane.id)}><${Icon} name="close" /></button>
113
139
  </div>${notice || null}
114
140
  </header>`;
115
141
  }
116
142
 
117
- function Pane({ id, w, focused, compact, width, controller, controls, panels }) {
118
- const pointer = useRef(false);
143
+ function Pane({ id, w, focused, compact, width, height, controller, controls, panels, gestures, popout }) {
144
+ const pointer = useRef(false), ref = useRef(null);
145
+ useLayoutEffect(() => { ref.current?.style.setProperty("--ws-pane-height", `${height}px`); }, [height]);
119
146
  useEffect(() => {
120
147
  const reset = () => { pointer.current = false; };
121
148
  window.addEventListener("pointerup", reset); window.addEventListener("pointercancel", reset); window.addEventListener("blur", reset);
@@ -128,8 +155,8 @@ function Pane({ id, w, focused, compact, width, controller, controls, panels })
128
155
  const visibleTabs = tabs.slice();
129
156
  for (let n = visibleTabs.length - 1; visibleTabs.length > keep && n >= 0; n--) if (visibleTabs[n] !== p.route.panel) visibleTabs.splice(n, 1);
130
157
  const value = { ...controller.pane(id), id, name: p.route.instance, route: p.route, search: p.search, hash: p.hash, focused,
131
- tabs, visibleTabs: compact ? tabs : visibleTabs, width, controller, controls, layout: w.layout, Header: compact ? null : PaneHeader };
132
- return html`<section class=${`ws-pane${focused ? " ws-focused" : ""}`} data-pane=${id} role="region"
158
+ tabs, visibleTabs: compact ? tabs : visibleTabs, width, controller, controls, gestures, popout, floating: !compact && w.layout === "float" && w.floating === id, layout: w.layout, Header: compact ? null : PaneHeader };
159
+ return html`<section ref=${ref} id=${`ws-pane-${id}`} class=${`ws-pane${focused ? " ws-focused" : ""}${value.floating ? " ws-floating" : ""}`} data-pane=${id} role="region"
133
160
  aria-label=${tw("pane", p.route.instance, viewLabel(p.route.panel))} aria-current=${focused ? "true" : undefined}
134
161
  onPointerDown=${event => {
135
162
  pointer.current = true;
@@ -140,16 +167,28 @@ function Pane({ id, w, focused, compact, width, controller, controls, panels })
140
167
  onClick=${event => { pointer.current = false; if (!event.defaultPrevented && !event.target.closest(".menu, .ws-page-tools") && !event.metaKey && !event.ctrlKey && !event.altKey && !event.shiftKey && event.button === 0) controller.focus(id); }}
141
168
  onFocusIn=${() => { if (!pointer.current) controller.focus(id); }}>
142
169
  <${PaneScope} value=${value}><${Outlet} route=${p.route} seq=${p.seq} panels=${panels} /></${PaneScope}>
170
+ ${value.floating ? html`<button type="button" class="ws-float-resize" aria-label=${geometryText("resize")} title=${geometryText("resize")}
171
+ onPointerDown=${event => gestures.floatDown("resize", id, event)} onKeyDown=${event => { if (event.key === "Enter" || event.key === " ") { event.preventDefault(); gestures.keyboard("resize", id); } }}></button>` : null}
143
172
  ${focused && !compact ? html`<span class="sr-only">${tw("current")}</span>` : null}
144
173
  </section>`;
145
174
  }
146
175
 
147
- export function createWorkspaceHost(controller) {
176
+ export function createWorkspaceHost(controller, pageGestures, popout) {
148
177
  return function WorkspaceHost({ nav, panels }) {
149
178
  const ref = useRef(null), [size, setSize] = useState({ width: 0, height: 0, viewport: 0 });
150
179
  const controls = useMemo(() => createPageControls(), []);
180
+ const gestures = useMemo(() => pageGestures || createWorkspaceGestures({ controller, getRoot: () => ref.current }), []);
181
+ const movement = useStore(gestures.store);
182
+ useLayoutEffect(() => () => { if (!pageGestures) gestures.close(); }, []);
151
183
  const w = nav.workspace;
152
184
  const compact = !w || !twoPaneFits(size.viewport, size.width, size.height, w.layout);
185
+ const chosen = { ...w, ...movement.transient };
186
+ const split = splitSize(size.width, size.height, w?.layout, chosen.ratio), box = floatBox(size.width, size.height, chosen.rect);
187
+ useLayoutEffect(() => {
188
+ const el = ref.current; if (!el || compact) return;
189
+ el.style.setProperty("--ws-first", `${split.first}px`);
190
+ for (const [key, value] of Object.entries(box)) el.style.setProperty(`--ws-float-${key}`, `${value}px`);
191
+ }, [compact, split.first, box.x, box.y, box.width, box.height]);
153
192
  useLayoutEffect(() => {
154
193
  if (!ref.current) return;
155
194
  const update = () => { const r = ref.current?.getBoundingClientRect(); if (r) setSize({ width: r.width, height: r.height, viewport: window.innerWidth }); };
@@ -161,15 +200,23 @@ export function createWorkspaceHost(controller) {
161
200
  useLayoutEffect(() => { if (compact) controls.close(); }, [compact]);
162
201
  useLayoutEffect(() => () => controls.close(), []);
163
202
  if (!w) return html`<${Outlet} route=${nav.route} seq=${nav.seq} panels=${panels} />`;
164
- const ids = compact ? [w.focus] : w.flipped ? ["b", "a"] : ["a", "b"];
165
- return html`<div ref=${ref} class=${`chat-workspace ws-${compact ? "compact" : w.layout}`} data-layout=${compact ? "single" : w.layout}>
203
+ const ids = compact ? [w.focus] : w.layout === "float" ? [w.floating === "a" ? "b" : "a", w.floating] : w.flipped ? ["b", "a"] : ["a", "b"];
204
+ const paneWidth = id => compact || w.layout === "stack" ? size.width : w.layout === "float" ? id === w.floating ? box.width : size.width : id === ids[0] ? split.first : split.second;
205
+ const paneHeight = id => compact || w.layout === "right" ? size.height : w.layout === "float" ? id === w.floating ? box.height : size.height : id === ids[0] ? split.first : split.second;
206
+ return html`<div ref=${ref} class=${`chat-workspace ws-geometry ws-${compact ? "compact" : w.layout}${movement.transient || movement.keyboard ? " ws-resizing" : ""}`} data-layout=${compact ? "single" : w.layout}>
166
207
  ${compact ? html`<nav class="ws-agent-tabs seg" aria-label=${tw("choose")}>${["a", "b"].map(id => html`<span class="ws-agent-tab">
167
208
  <button type="button" class=${`seg-item${w.focus === id ? " active" : ""}`} aria-current=${w.focus === id ? "page" : undefined}
168
209
  title=${w[id].route.instance} onClick=${() => controller.focus(id)}><span class="ws-agent-name">${w[id].route.instance}</span></button>
169
210
  <button type="button" class="icon-btn ws-agent-close" aria-label=${`${tw("close")}: ${w[id].route.instance}`}
170
211
  title=${tw("close")} onClick=${() => controller.closePane(id)}><${Icon} name="close" /></button></span>`)}</nav>` : null}
171
- ${ids.map(id => html`<${Pane} key=${id} id=${id} w=${w} focused=${w.focus === id} compact=${compact}
172
- width=${w.layout === "stack" ? size.width : (size.width - 8) / 2} controller=${controller} controls=${controls} panels=${panels} />`)}
212
+ ${ids.flatMap((id, n) => [n === 1 && !compact && w.layout !== "float" ? html`<div key="sash" class="ws-sash-slot"><div class="ws-sash" role="separator" tabindex="0"
213
+ aria-controls="ws-pane-a ws-pane-b" aria-label=${geometryText("sash")} title=${geometryText("reset")}
214
+ aria-orientation=${w.layout === "stack" ? "horizontal" : "vertical"} aria-valuemin=${Math.round(split.min)} aria-valuemax=${Math.round(split.max)} aria-valuenow=${Math.round(split.first)}
215
+ onKeyDown=${gestures.sashKey} onPointerDown=${gestures.sashDown} ondblclick=${() => controller.geometry({ ratio: .5 })}></div></div>` : null,
216
+ html`<${Pane} key=${id} id=${id} w=${w} focused=${w.focus === id} compact=${compact}
217
+ width=${paneWidth(id)} height=${paneHeight(id)} controller=${controller} controls=${controls} panels=${panels} gestures=${gestures} popout=${popout} />`])}
218
+ <span class="sr-only" role="status" aria-live="polite">${movement.announcement}</span>
219
+ ${movement.keyboard ? html`<p class="ws-geometry-hint" role="status">${geometryText("help")}</p>` : null}
173
220
  </div>`;
174
221
  };
175
222
  }
@@ -181,13 +228,20 @@ export function installWorkspaceEntry({ nav, ready, landing = false, scope = "",
181
228
  let storage = null;
182
229
  try { storage = localStorage; } catch { /* memory-only */ }
183
230
  const memory = workspaceMemory(storage, scope);
231
+ const popout = createPanePopout({ scope, chat });
232
+ const gestures = createWorkspaceGestures({ getRoot: () => document.querySelector(".chat-workspace") || document.getElementById("main"),
233
+ controller: { current: () => controller?.current(), stamp: () => nav.navStore.get(), subscribe: fn => nav.navStore.subscribe(fn),
234
+ focus: id => controller?.focus(id), geometry: change => controller?.geometry(change) },
235
+ onDrop: (name, target, zone) => { if (agentRoute(nav.navStore.get().route)) void open(name, undefined, { target, zone }); } });
184
236
  const retire = () => {
185
237
  if (!alive) return; alive = false; memory.clear();
238
+ popout?.close();
186
239
  controller?.close();
240
+ gestures.close();
187
241
  window.removeEventListener("resize", refresh); document.removeEventListener("keydown", key);
188
242
  appStore.set({ chatWorkspace: null, chatWorkspaceSessionEnd: null });
189
243
  };
190
- async function open(name, layout = "right") {
244
+ async function open(name, layout = "right", drop) {
191
245
  if (!alive) return;
192
246
  const attempt = nav.navStore.get();
193
247
  try {
@@ -196,8 +250,8 @@ export function installWorkspaceEntry({ nav, ready, landing = false, scope = "",
196
250
  if (!alive || nav.navStore.get() !== attempt) return; // a later navigation retires this loading intent
197
251
  if (!controller) {
198
252
  if (!nav.installNavigation || !PanelHeader.workspaceVersion) throw new Error("old shell");
199
- controller = installWorkspaceNavigation(nav, { beforeLayout: services?.stopPreview,
200
- onWorkspace: () => { if (!shellStore.get().workspaceHost) shellStore.set({ workspaceHost: createWorkspaceHost(controller) }); } });
253
+ controller = workspaceNavigation.installWorkspaceNavigation(nav, { geometry: true, beforeLayout: services?.stopPreview,
254
+ onWorkspace: () => { if (!shellStore.get().workspaceHost) shellStore.set({ workspaceHost: createWorkspaceHost(controller, gestures, popout) }); } });
201
255
  let previous = null;
202
256
  nav.navStore.subscribe(next => {
203
257
  if (!alive) return;
@@ -210,26 +264,36 @@ export function installWorkspaceEntry({ nav, ready, landing = false, scope = "",
210
264
  if (controller.current()) memory.write(controller.current());
211
265
  }
212
266
  }
213
- if (name) controller.open(name, layout);
267
+ if (name) { if (drop) controller.dock(name, drop.target, drop.zone); else controller.open(name, layout); }
214
268
  } catch { toast(tw("unavailable"), false); }
215
269
  }
216
270
  const entry = { open, pick: event => showDialog(AgentPicker, { controller: { current: () => controller?.current(), open }, currentName: nav.navStore.get().route?.instance, layout: event?.altKey ? "stack" : "right" }),
271
+ dragStart: (name, event) => agentRoute(nav.navStore.get().route) && gestures.dragStart(name, event), dragEnd: gestures.dragEnd,
217
272
  settings: name => nav.navigate(`${detailsPath(name)}?cat=basic`),
218
273
  quoteTargets(source) {
219
274
  const w = controller?.current(); if (!w) return [];
220
275
  const from = ["a", "b"].find(id => w[id].route.instance === source); if (!from) return [];
221
276
  const id = from === "a" ? "b" : "a", name = w[id].route.instance, sourcePane = w[from];
222
- return [{ label: tw("quote", name), async insert(text) {
223
- const current = () => { const now = controller.current(); return alive && !!now && now[from] === sourcePane && now[id].route.instance === name; };
224
- if (!current()) return;
277
+ const targetName = labelOf(appStore.get().instances.find(it => it.name === name) || { name });
278
+ // #3727: `commit` (optional) runs right after the quote went in, in the same turn and under the same fence — the
279
+ // annotated picture's attachment — so both land in this exact pane or neither does. True when they did. `live`
280
+ // (optional): the caller's own validity (the annotation editor still open), part of the same fence throughout the
281
+ // wait for the Chat mount and at the commit.
282
+ return [{ name, label: tw("quote", targetName), async insert(text, commit, live) {
283
+ const callerLive = () => typeof live !== "function" || live() === true;
284
+ const current = () => { const now = controller.current(); return alive && callerLive() && !!now && now[from] === sourcePane && now[id].route.instance === name; };
285
+ if (!current()) return false;
225
286
  if (controller.current()[id].route.panel !== "chat") controller.pane(id).navigate(routePath({ panel: "chat", instance: name }));
226
- if (!current() || controller.current()[id].route.panel !== "chat") { toast(tw("quoteAgain"), false); return; }
287
+ if (!current() || controller.current()[id].route.panel !== "chat") { toast(tw("quoteAgain"), false); return false; }
227
288
  const target = controller.current()[id];
228
289
  const valid = () => current() && controller.current()[id] === target;
229
290
  // B may have been on Log. Wait only for that exact Chat mount; a changed destination permanently cancels.
230
291
  const start = performance.now();
231
292
  while (valid() && !chat.paneComposerReady(name) && performance.now() - start < 2000) await new Promise(resolve => setTimeout(resolve, 16));
232
- if (valid() && performance.now() - start < 2000 && chat.insertPaneQuote(name, source, text, valid)) controller.focus(id);
293
+ if (!(valid() && performance.now() - start < 2000 && chat.insertPaneQuote(name, source, text, valid))) return false;
294
+ if (typeof commit === "function") commit();
295
+ controller.focus(id);
296
+ return true;
233
297
  } }];
234
298
  },
235
299
  label(name) { const w = controller?.current(); return w && ![w.a.route.instance, w.b.route.instance].includes(name)
@@ -225,10 +225,10 @@ export function VersionLine({ row, label, blocked = false }) {
225
225
  const u = row.cliUpdate;
226
226
  if (!u || !hostInstallOffered()) return null;
227
227
  const installed = u.installed || row.version || "?";
228
- const text = u.latest ? th(u.state === "current" ? "verLatestCurrent" : u.state === "newer" ? "verLatestNewer" : "verLatestBehind", installed, u.audited)
228
+ // AGEND-223: a version that could not be read says so, for the vendor-latest CLIs too (it used to fall into the "{0} is installed" line with "?" as the version).
229
+ const text = u.state === "unknown" ? th("verUnknown", u.audited) : u.latest ? th(u.state === "current" ? "verLatestCurrent" : u.state === "newer" ? "verLatestNewer" : "verLatestBehind", installed, u.audited)
229
230
  : u.state === "current" ? th("verCurrent", installed, u.audited)
230
231
  : u.state === "newer" ? th("verNewer", installed, u.audited)
231
- : u.state === "unknown" ? th("verUnknown", u.audited)
232
232
  : u.via === "self" ? th("verSelf", installed, u.audited)
233
233
  : th("verBehind", installed, u.audited);
234
234
  const run = runFor(state, row.backend);
@@ -3,7 +3,7 @@
3
3
  import { register } from "/assets/app-i18n.js";
4
4
  register("hub", {
5
5
  en: {
6
- agentLead: "Every agent is private unless you share it. A shared agent answers Hub questions in its own conversation, with its own folder and the tools its Settings allow. Actions that need approval still come to you.",
6
+ agentLead: "Every agent is private unless you share it. A shared agent answers Hub questions in its own conversation, with its own folder and the tools its Settings allow. Actions that need approval still come to you. Only fleet agents can be shared for now: ClassicBot rooms can't be shared yet.",
7
7
  agentShared: "Shared: Hub questions go to this agent's own conversation.",
8
8
  republishRequired: "Shared under the older restricted mode. Hub questions are refused until you share this agent again.",
9
9
  shareAgain: "Share again",
@@ -11,12 +11,12 @@ register("hub", {
11
11
  agentDeliveryUnavailable: "Sharing isn't available on this fleet yet: Hub questions can't reach an agent here.",
12
12
  },
13
13
  "zh-TW": {
14
- agentLead: "每個 Agent 預設都不公開。公開後,Agent 會在自己的對話中回答 Hub 的提問,使用它自己的資料夾和設定允許的工具。需要核准的動作仍會交給你。",
15
- agentShared: "已公開:Hub 的提問會送到這個 Agent 自己的對話。",
16
- republishRequired: "這是舊的受限模式公開。重新公開這個 Agent 之前,Hub 的提問都會被拒絕。",
17
- shareAgain: "重新公開",
18
- agentNotShareable: "目前無法公開這個 Agent。請重新整理頁面後再試一次。",
19
- agentDeliveryUnavailable: "這個 Fleet 還不能公開:Hub 的提問目前無法送到這裡的 Agent。",
14
+ agentLead: "每個 Agent 預設都不分享。分享後,Agent 會在自己的對話中回答 Hub 的提問,使用它自己的資料夾和設定允許的工具。需要核准的動作仍會交給你。目前只能分享 Fleet 的 Agent,ClassicBot 房間還不能分享。",
15
+ agentShared: "已分享:Hub 的提問會送到這個 Agent 自己的對話。",
16
+ republishRequired: "這是舊的受限模式分享。重新分享這個 Agent 之前,Hub 的提問都會被拒絕。",
17
+ shareAgain: "重新分享",
18
+ agentNotShareable: "目前無法分享這個 Agent。請重新整理頁面後再試一次。",
19
+ agentDeliveryUnavailable: "這個 Fleet 還不能分享:Hub 的提問目前無法送到這裡的 Agent。",
20
20
  },
21
21
  });
22
22
  /** What a Share sends: the agent itself, no Hub tools (agent-mode.ts on the member). */
@@ -5,7 +5,7 @@ import { register, t } from "/assets/app-i18n.js";
5
5
 
6
6
  register("hubChat", {
7
7
  en: {
8
- navSearch: "Search", notices: "Notices", noticesTitle: "Notices", noNotices: "No security notices", noticesLead: "When a new fleet connects to this Hub, you're told here. If you don't recognise it, revoke it.", settings: "Settings", signedIn: "Signed in", signOut: "Sign out",
8
+ navSearch: "Search", notices: "Notices", noticesTitle: "Notices", noNotices: "No security notices", noticesLead: "When a new fleet connects to this Hub, you're told here. If you don't recognize it, revoke it.", settings: "Settings", signedIn: "Signed in", signOut: "Sign out",
9
9
  chats: "Chats", newChat: "New chat", search: "Search chats", noChats: "No chats yet", noChatsHint: "Start one with New chat: it lists the agents someone allowed you to ask.",
10
10
  noMatch: "No chat matches.", waiting: "Waiting for an answer", represents: "Answers for {0}",
11
11
  pickTitle: "New chat", pickSearch: "Search agents or owners", pickHint: "Only the agents someone allowed you to ask are listed.",
@@ -31,7 +31,7 @@ register("hubChat", {
31
31
  adminTitle: "Hub administrator", adminSees: "Can't see the content.",
32
32
  notHere: "Not here", notHereText: "{0}'s files and changes, its terminal (View) and its tool progress: only {1} sees them, in their own fleet.",
33
33
  oneToOne: "A chat has only you and this agent.",
34
- menu: "Menu", mine: "My shared agents", mineHint: "Who may ask them, until when", admin: "Administration", adminHint: "Pair fleets",
34
+ menu: "Menu", mine: "My shared agents", mineHint: "Who may ask them, until when", admin: "Administration", adminHint: "Connect fleets",
35
35
  back: "Chats",
36
36
  },
37
37
  "zh-TW": {
@@ -61,7 +61,7 @@ register("hubChat", {
61
61
  adminTitle: "Hub 管理員", adminSees: "看不到內容。",
62
62
  notHere: "這裡沒有", notHereText: "{0} 的檔案與變更、終端機畫面(View)、工具進度:只有 {1} 在自己的 fleet 看得到。",
63
63
  oneToOne: "一個聊天室只有你和這個 Agent。",
64
- menu: "選單", mine: "我分享的 Agent", mineHint: "誰可以提問、到什麼時候", admin: "管理", adminHint: "配對 fleet",
64
+ menu: "選單", mine: "我分享的 Agent", mineHint: "誰可以提問、到什麼時候", admin: "管理", adminHint: "連接 Fleet",
65
65
  back: "對話",
66
66
  },
67
67
  });
@@ -205,9 +205,42 @@ export function createStubClient({ now = () => Date.now(), agents = () => [] } =
205
205
  * Every answer is { ok: true, ...body } or { ok: false, status, code }; a 401 also tells the page the session ended.
206
206
  */
207
207
  export function createHubWebClient({ fetchImpl = (...a) => fetch(...a) } = {}) {
208
- let csrf = null;
209
- const ended = new Set();
210
- async function call(method, path, body, signal) {
208
+ let csrf = null, codeNotices = false, generation = 0;
209
+ const ended = new Set(), pendingReads = new Map(), waits = new Set();
210
+ let readTail = Promise.resolve();
211
+ const retired = () => ({ ok: false, status: 401, code: "unauthenticated" });
212
+ const retireReads = () => { generation++; pendingReads.clear(); for (const wake of waits) wake(); };
213
+ const pause = ms => new Promise(resolve => {
214
+ const wake = () => { clearTimeout(timer); waits.delete(wake); resolve(); };
215
+ const timer = setTimeout(wake, ms); waits.add(wake);
216
+ });
217
+ // Private reads share fresh directory eligibility admission. One read per client, with only simultaneous identical
218
+ // reads shared (never an allow-cache). Other tabs/writes can still fill the server pool, so back off at most 3 times.
219
+ function call(method, path, body, signal) {
220
+ if (method !== "GET") { pendingReads.clear(); return request(method, path, body, signal); }
221
+ if (!signal && pendingReads.has(path)) return pendingReads.get(path);
222
+ const mine = generation;
223
+ const run = async () => {
224
+ for (let attempt = 0; ; attempt++) {
225
+ if (mine !== generation) return retired();
226
+ if (signal?.aborted) return { ok: false, status: 0, code: "unreachable" };
227
+ const result = await request(method, path, body, signal);
228
+ if (mine !== generation) return retired();
229
+ if (result.ok || result.status !== 429 || result.code !== "backpressure" || attempt === 3) return result;
230
+ await pause(Math.min(2000, Math.max(500 * 2 ** attempt, Number(result.retryAfter) * 1000 || 0)));
231
+ }
232
+ };
233
+ const result = readTail.then(run, run);
234
+ readTail = result.then(() => {}, () => {});
235
+ if (!signal) {
236
+ pendingReads.set(path, result);
237
+ const forget = () => { if (pendingReads.get(path) === result) pendingReads.delete(path); };
238
+ void result.then(forget, forget);
239
+ }
240
+ return result;
241
+ }
242
+ async function request(method, path, body, signal) {
243
+ const mine = generation;
211
244
  const headers = { Accept: "application/json" };
212
245
  if (body !== undefined) headers["Content-Type"] = "application/json";
213
246
  if (method !== "GET" && csrf) headers["X-AgEnD-Hub-CSRF"] = csrf;
@@ -216,8 +249,10 @@ export function createHubWebClient({ fetchImpl = (...a) => fetch(...a) } = {}) {
216
249
  catch { return { ok: false, status: 0, code: "unreachable" }; }
217
250
  let json = null;
218
251
  try { json = await r.json(); } catch { json = null; }
219
- if (r.status === 401) { csrf = null; for (const fn of ended) { try { fn(); } catch { /* a listener's own failure */ } } }
220
- 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 };
252
+ if (r.status === 401 && mine === generation) { retireReads(); csrf = null; codeNotices = false; for (const fn of ended) { try { fn(); } catch { /* a listener's own failure */ } } }
253
+ 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,
254
+ ...(method === "POST" && path === "/hub/v1/admin/enrolment-codes" && r.status === 429 && json?.code === "backpressure"
255
+ && ["live-code-limit", "hourly-code-limit"].includes(json.reason) ? { reason: json.reason } : {}) };
221
256
  return { ok: true, ...(json && typeof json === "object" ? json : {}) };
222
257
  }
223
258
  const id = (v) => encodeURIComponent(String(v));
@@ -225,9 +260,9 @@ export function createHubWebClient({ fetchImpl = (...a) => fetch(...a) } = {}) {
225
260
  stub: false, web: true,
226
261
  /** Hear the session end (a 401 anywhere). @returns {() => void} */
227
262
  onSignedOut(fn) { ended.add(fn); return () => ended.delete(fn); },
228
- async session() { const r = await call("GET", "/hub/v1/session"); if (r.ok) csrf = r.signedIn ? r.csrf || null : null; return r; },
229
- async signIn(login, password) { const r = await call("POST", "/hub/v1/session", { login, password }); if (r.ok) csrf = r.csrf || null; return r; },
230
- async signOut() { const r = await call("DELETE", "/hub/v1/session"); csrf = null; return r; },
263
+ 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; } return r; },
264
+ async signIn(login, password) { retireReads(); 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; } return r; },
265
+ async signOut() { retireReads(); const r = await call("DELETE", "/hub/v1/session"); csrf = null; codeNotices = false; return r; },
231
266
  catalog() { return call("GET", "/hub/v1/exposures"); },
232
267
  grant(input) { return call("POST", "/hub/v1/grants", input); },
233
268
  revokeGrant(grantId, revision) { return call("DELETE", `/hub/v1/grants/${id(grantId)}?revision=${id(revision)}`); },
@@ -245,6 +280,7 @@ export function createHubWebClient({ fetchImpl = (...a) => fetch(...a) } = {}) {
245
280
  /** #3226 D: one file for a later question in this room, sent as is (the server types it by its name, images by
246
281
  * their bytes). → { ok: true, file: { id, name, size, mime, url } } or { ok: false, status, code }. */
247
282
  async upload(roomId, file) {
283
+ const mine = generation;
248
284
  const headers = { Accept: "application/json", "Content-Type": "application/octet-stream", "X-File-Name": encodeURIComponent(String(file && file.name || "")) };
249
285
  if (csrf) headers["X-AgEnD-Hub-CSRF"] = csrf;
250
286
  let r;
@@ -252,7 +288,7 @@ export function createHubWebClient({ fetchImpl = (...a) => fetch(...a) } = {}) {
252
288
  catch { return { ok: false, status: 0, code: "unreachable" }; }
253
289
  let json = null;
254
290
  try { json = await r.json(); } catch { json = null; }
255
- if (r.status === 401) { csrf = null; for (const fn of ended) { try { fn(); } catch { /* a listener's own failure */ } } }
291
+ if (r.status === 401 && mine === generation) { retireReads(); csrf = null; for (const fn of ended) { try { fn(); } catch { /* a listener's own failure */ } } }
256
292
  if (!r.ok) return { ok: false, status: r.status, code: (json && typeof json.code === "string" && json.code) || "failed" };
257
293
  return { ok: true, ...(json && typeof json === "object" ? json : {}) };
258
294
  },
@@ -264,7 +300,9 @@ export function createHubWebClient({ fetchImpl = (...a) => fetch(...a) } = {}) {
264
300
  quickPairing(pairingId) { return call("GET", `/hub/v1/quick-pairing${pairingId ? `?id=${id(pairingId)}` : ""}`); },
265
301
  stopQuickPairing(pairingId) { return call("POST", `/hub/v1/quick-pairing/${id(pairingId)}/stop`); },
266
302
  revokeOwnFleet(fleetId, generation) { return call("POST", `/hub/v1/fleets/${id(fleetId)}/revoke`, { generation }); },
267
- pairingNotices() { return call("GET", "/hub/v1/notices?v=2"); },
303
+ // A cached notice renderer calls with no version and must never receive a code row it would label as group approval.
304
+ pairingNoticesV3: true,
305
+ pairingNotices(version = 2) { return call("GET", `/hub/v1/notices?v=${version === 3 && codeNotices ? 3 : 2}`); },
268
306
  directorySecurityNoticesV1: true,
269
307
  directorySecurityNotices({ before, limit = 25 } = {}) {
270
308
  const query = new URLSearchParams({ limit: String(limit) });
@@ -275,9 +313,9 @@ export function createHubWebClient({ fetchImpl = (...a) => fetch(...a) } = {}) {
275
313
  /** The Hub's stream begins with the complete current snapshot; no bootstrap GET is needed. */
276
314
  pairingNoticeSnapshotV1: typeof EventSource !== "undefined",
277
315
  acknowledgePairingNotice(noticeId) { return call("POST", `/hub/v1/notices/${id(noticeId)}/ack`); },
278
- subscribePairingNotices(fn, onClosed = () => {}) {
316
+ subscribePairingNotices(fn, onClosed = () => {}, version = 2) {
279
317
  if (typeof EventSource === "undefined") return () => {};
280
- const events = new EventSource("/hub/v1/notices/events?v=2"); let live = true;
318
+ const events = new EventSource(`/hub/v1/notices/events?v=${version === 3 && codeNotices ? 3 : 2}`); let live = true;
281
319
  events.addEventListener("notices", (event) => { if (!live) return; try { const value = JSON.parse(event.data); if (Array.isArray(value.notices)) fn(value.notices); } catch { /* bounded server DTO only */ } });
282
320
  events.addEventListener("error", () => {
283
321
  // A refused handshake is CLOSED, unlike a transient disconnect that EventSource itself reconnects.
@@ -286,7 +324,13 @@ export function createHubWebClient({ fetchImpl = (...a) => fetch(...a) } = {}) {
286
324
  return () => { live = false; events.close(); };
287
325
  },
288
326
  confirmPairing(pairingId, fingerprint) { return call("POST", `/hub/v1/pairings/${id(pairingId)}/confirm`, { fingerprint }); },
327
+ companyJoinSettings() { return call("GET", "/hub/v1/admin/company-join"); },
289
328
  adminOverview() { return call("GET", "/hub/v1/admin/overview"); },
329
+ /** B2 capability, not permission: the server still checks the configured administrator on every call. */
330
+ enrolmentCodeV1: true,
331
+ enrolmentCodes() { return call("GET", "/hub/v1/admin/enrolment-codes"); },
332
+ createEnrolmentCode(input) { return call("POST", "/hub/v1/admin/enrolment-codes", input); },
333
+ revokeEnrolmentCode(codeId) { return call("POST", `/hub/v1/admin/enrolment-codes/${id(codeId)}/revoke`, {}); },
290
334
  createPairing(login) { return call("POST", "/hub/v1/admin/pairings", { login }); },
291
335
  approvePairing(pairingId, fingerprint) { return call("POST", `/hub/v1/admin/pairings/${id(pairingId)}/approve`, { fingerprint }); },
292
336
  revokeFleet(fleetId) { return call("POST", `/hub/v1/admin/fleets/${id(fleetId)}/revoke`); },
@@ -294,6 +338,10 @@ export function createHubWebClient({ fetchImpl = (...a) => fetch(...a) } = {}) {
294
338
  // signed-in person (display only — every action still asks the server).
295
339
  groupPolicy() { return call("GET", "/hub/v1/admin/group-policy"); },
296
340
  resolveGroup(dn) { return call("POST", "/hub/v1/admin/group-policy/resolve", { dn }); },
341
+ /** M-2932 (Hub UX U2, S2): a prefix search of the directory's groups — input feedback only; choosing one still resolves its DN. */
342
+ searchGroups(q) { return call("POST", "/hub/v1/admin/group-policy/search", { q }); },
343
+ /** #3698 r1: the public join metadata a Fleet's discovery reads — its features name company-join-v1 only while joining is ON. */
344
+ joinMetadata() { return call("GET", "/hub/v1/join/metadata"); },
297
345
  previewGroupPolicy(policy) { return call("POST", "/hub/v1/admin/group-policy/preview", { policy }); },
298
346
  /** The policy that was previewed and that preview's digest: the server applies only its own sealed candidate for them. */
299
347
  saveGroupPolicy(policy, previewDigest) { return call("PUT", "/hub/v1/admin/group-policy", { policy, previewDigest }); },
@@ -330,7 +378,8 @@ export function createHubWebClient({ fetchImpl = (...a) => fetch(...a) } = {}) {
330
378
  * `confirm` is settings-confirm.js (loaded with the card): { api, isPendingResponse, track, newKey }.
331
379
  */
332
380
  export function createMemberClient({ confirm, pollMs = 5000, doc = typeof document !== "undefined" ? document : null, timers = globalThis }) {
333
- let pairingNotices = [];
381
+ let pairingNotices = [], noticeEpoch = 0;
382
+ const noticeReaders = new Set();
334
383
  const listed = async () => {
335
384
  const r = await confirm.api("/api/hub/member/exposures");
336
385
  return r.ok && r.body && Array.isArray(r.body.exposures) ? r.body.exposures : r.status === 404 ? null : [];
@@ -339,9 +388,14 @@ export function createMemberClient({ confirm, pollMs = 5000, doc = typeof docume
339
388
  // Pairing (S3c PR B): GET the projection; connect / confirm / disconnect go through the Settings confirmation (a 202:
340
389
  // "sent for confirmation", followed in the background; the poll shows the result); cancel at once.
341
390
  const pairingNow = async () => {
342
- const r = await confirm.api("/api/hub/member/pairing?v=2");
343
- if (r.ok && r.body && r.body.pairing) { pairingNotices = Array.isArray(r.body.notices) ? r.body.notices : []; return r.body.pairing; }
344
- pairingNotices = [];
391
+ const mine = noticeEpoch, version = noticeReaders.size ? 3 : 2;
392
+ const r = await confirm.api(`/api/hub/member/pairing?v=2${version === 3 ? "&notices=3" : ""}`);
393
+ if (r.ok && r.body && r.body.pairing) {
394
+ if (mine === noticeEpoch) pairingNotices = Array.isArray(r.body.notices) ? r.body.notices.filter(n => n && typeof n === "object"
395
+ && (n.source === undefined || n.source === "group" || n.source === "manual" || n.source === "code" && version === 3)) : [];
396
+ return r.body.pairing;
397
+ }
398
+ if (mine === noticeEpoch) pairingNotices = [];
345
399
  return { state: "held", hold: r.status === 404 ? "unavailable" : "unsaved" };
346
400
  };
347
401
  const step = async (name, body) => {
@@ -370,6 +424,12 @@ export function createMemberClient({ confirm, pollMs = 5000, doc = typeof docume
370
424
  stub: false, member: true,
371
425
  pairing: pairingNow,
372
426
  pairingNotices: () => pairingNotices,
427
+ /** Presentation lease only. Cached renderers never call this and continue to receive v2. */
428
+ usePairingNoticeVersion(version) {
429
+ if (version !== 3) return () => {};
430
+ const reader = {}; if (!noticeReaders.size) noticeEpoch++; noticeReaders.add(reader);
431
+ return () => { if (noticeReaders.delete(reader) && !noticeReaders.size) { noticeEpoch++; pairingNotices = pairingNotices.filter(n => n.source !== "code"); } };
432
+ },
373
433
  async connect({ address, code }) {
374
434
  const a = String(address || "").trim(), c = String(code || "").trim();
375
435
  if (!ADDRESS_HINT.test(a)) return { ok: false, error: "address" };
@@ -402,7 +462,7 @@ export function createMemberClient({ confirm, pollMs = 5000, doc = typeof docume
402
462
  body: JSON.stringify({ agent, dataViewId: choice.dataViewId, tools: choice.tools, expectedRevision }) });
403
463
  if (confirm.isPendingResponse(r)) {
404
464
  const p = r.body.pending_change;
405
- return { ok: true, pending: { expiresAt: p.expires_at }, view: { ...row, pending: { expiresAt: p.expires_at } }, settled: confirm.track(p, "hub") };
465
+ return { ok: true, pending: { id: p.id, expiresAt: p.expires_at }, view: { ...row, pending: { expiresAt: p.expires_at } }, settled: confirm.track(p, "hub") };
406
466
  }
407
467
  return r.ok && r.body && r.body.ok ? { ok: true, view: r.body.view } : fail(r);
408
468
  },