@songsid/agend 2.3.5-alpha.8 → 2.3.5-alpha.9

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 (266) hide show
  1. package/dist/accounts-profiles.d.ts +6 -0
  2. package/dist/accounts-profiles.js +16 -0
  3. package/dist/accounts-profiles.js.map +1 -1
  4. package/dist/agent-cli-instructions.md +1 -1
  5. package/dist/agent-cli.js +5 -2
  6. package/dist/agent-cli.js.map +1 -1
  7. package/dist/agent-whats-new.js +5 -0
  8. package/dist/agent-whats-new.js.map +1 -1
  9. package/dist/authority/company-join.d.ts +16 -0
  10. package/dist/authority/company-join.js +37 -0
  11. package/dist/authority/company-join.js.map +1 -0
  12. package/dist/authority/hub-initialization.d.ts +13 -0
  13. package/dist/authority/hub-initialization.js +30 -0
  14. package/dist/authority/hub-initialization.js.map +1 -0
  15. package/dist/backend/claude-code.d.ts +1 -0
  16. package/dist/backend/claude-code.js +13 -0
  17. package/dist/backend/claude-code.js.map +1 -1
  18. package/dist/backend/types.d.ts +4 -0
  19. package/dist/backend/types.js.map +1 -1
  20. package/dist/build-provenance.json +1 -1
  21. package/dist/channel/mcp-tools.js +2 -2
  22. package/dist/channel/mcp-tools.js.map +1 -1
  23. package/dist/claude-model-minimum.d.ts +7 -0
  24. package/dist/claude-model-minimum.js +16 -0
  25. package/dist/claude-model-minimum.js.map +1 -0
  26. package/dist/daemon.d.ts +43 -1
  27. package/dist/daemon.js +176 -27
  28. package/dist/daemon.js.map +1 -1
  29. package/dist/decision-list.d.ts +2 -0
  30. package/dist/decision-list.js +1 -1
  31. package/dist/decision-list.js.map +1 -1
  32. package/dist/fleet-manager.d.ts +50 -1
  33. package/dist/fleet-manager.js +306 -32
  34. package/dist/fleet-manager.js.map +1 -1
  35. package/dist/general-knowledge/skills/concepts/SKILL.md +14 -3
  36. package/dist/general-knowledge/skills/delegation-playbook/SKILL.md +4 -1
  37. package/dist/hub/client.js +2 -0
  38. package/dist/hub/client.js.map +1 -1
  39. package/dist/hub/compose/member.js +1 -1
  40. package/dist/hub/compose/member.js.map +1 -1
  41. package/dist/hub/compose/server.d.ts +48 -1
  42. package/dist/hub/compose/server.js +30 -5
  43. package/dist/hub/compose/server.js.map +1 -1
  44. package/dist/hub/directory/directory.d.ts +2 -0
  45. package/dist/hub/directory/directory.js +49 -4
  46. package/dist/hub/directory/directory.js.map +1 -1
  47. package/dist/hub/directory/types.d.ts +2 -0
  48. package/dist/hub/directory/types.js.map +1 -1
  49. package/dist/hub/enrollment-budget.d.ts +6 -0
  50. package/dist/hub/enrollment-budget.js +24 -0
  51. package/dist/hub/enrollment-budget.js.map +1 -0
  52. package/dist/hub/group-policy/authorization.d.ts +5 -0
  53. package/dist/hub/group-policy/authorization.js +24 -1
  54. package/dist/hub/group-policy/authorization.js.map +1 -1
  55. package/dist/hub/http/compose.js +62 -8
  56. package/dist/hub/http/compose.js.map +1 -1
  57. package/dist/hub/http/core.d.ts +2 -0
  58. package/dist/hub/http/core.js +10 -1
  59. package/dist/hub/http/core.js.map +1 -1
  60. package/dist/hub/http/deps.d.ts +3 -0
  61. package/dist/hub/http/schema.js +4 -0
  62. package/dist/hub/http/schema.js.map +1 -1
  63. package/dist/hub/init/browser-certificate.d.ts +6 -1
  64. package/dist/hub/init/browser-certificate.js +22 -1
  65. package/dist/hub/init/browser-certificate.js.map +1 -1
  66. package/dist/hub/init/initializer.d.ts +11 -1
  67. package/dist/hub/init/initializer.js +202 -83
  68. package/dist/hub/init/initializer.js.map +1 -1
  69. package/dist/hub/init/layout.js +1 -1
  70. package/dist/hub/init/layout.js.map +1 -1
  71. package/dist/hub/init/text.js +2 -2
  72. package/dist/hub/init/text.js.map +1 -1
  73. package/dist/hub/init/types.d.ts +32 -4
  74. package/dist/hub/init/types.js.map +1 -1
  75. package/dist/hub/init/web-audit-import.d.ts +12 -0
  76. package/dist/hub/init/web-audit-import.js +39 -0
  77. package/dist/hub/init/web-audit-import.js.map +1 -0
  78. package/dist/hub/init/web-audit.d.ts +30 -0
  79. package/dist/hub/init/web-audit.js +42 -0
  80. package/dist/hub/init/web-audit.js.map +1 -0
  81. package/dist/hub/init/web-error.d.ts +6 -0
  82. package/dist/hub/init/web-error.js +8 -0
  83. package/dist/hub/init/web-error.js.map +1 -0
  84. package/dist/hub/init/web-http.d.ts +9 -0
  85. package/dist/hub/init/web-http.js +103 -0
  86. package/dist/hub/init/web-http.js.map +1 -0
  87. package/dist/hub/init/web.d.ts +118 -0
  88. package/dist/hub/init/web.js +428 -0
  89. package/dist/hub/init/web.js.map +1 -0
  90. package/dist/hub/init/wizard.js +1 -3
  91. package/dist/hub/init/wizard.js.map +1 -1
  92. package/dist/hub/join/client.d.ts +35 -0
  93. package/dist/hub/join/client.js +112 -0
  94. package/dist/hub/join/client.js.map +1 -0
  95. package/dist/hub/join/descriptor.d.ts +45 -0
  96. package/dist/hub/join/descriptor.js +52 -0
  97. package/dist/hub/join/descriptor.js.map +1 -0
  98. package/dist/hub/join/fleet-authority.d.ts +2 -0
  99. package/dist/hub/join/fleet-authority.js +3 -0
  100. package/dist/hub/join/fleet-authority.js.map +1 -0
  101. package/dist/hub/join/http.d.ts +8 -0
  102. package/dist/hub/join/http.js +112 -0
  103. package/dist/hub/join/http.js.map +1 -0
  104. package/dist/hub/join/invitation.d.ts +28 -0
  105. package/dist/hub/join/invitation.js +28 -0
  106. package/dist/hub/join/invitation.js.map +1 -0
  107. package/dist/hub/join/local-journal.d.ts +84 -0
  108. package/dist/hub/join/local-journal.js +65 -0
  109. package/dist/hub/join/local-journal.js.map +1 -0
  110. package/dist/hub/join/local.d.ts +116 -0
  111. package/dist/hub/join/local.js +419 -0
  112. package/dist/hub/join/local.js.map +1 -0
  113. package/dist/hub/join/private.d.ts +3 -0
  114. package/dist/hub/join/private.js +46 -0
  115. package/dist/hub/join/private.js.map +1 -0
  116. package/dist/hub/join/protocol.d.ts +69 -0
  117. package/dist/hub/join/protocol.js +96 -0
  118. package/dist/hub/join/protocol.js.map +1 -0
  119. package/dist/hub/join/receipt.d.ts +42 -0
  120. package/dist/hub/join/receipt.js +75 -0
  121. package/dist/hub/join/receipt.js.map +1 -0
  122. package/dist/hub/join/service.d.ts +177 -0
  123. package/dist/hub/join/service.js +564 -0
  124. package/dist/hub/join/service.js.map +1 -0
  125. package/dist/hub/join/store.d.ts +97 -0
  126. package/dist/hub/join/store.js +87 -0
  127. package/dist/hub/join/store.js.map +1 -0
  128. package/dist/hub/join/trust.d.ts +13 -0
  129. package/dist/hub/join/trust.js +68 -0
  130. package/dist/hub/join/trust.js.map +1 -0
  131. package/dist/hub/member/pairing-api.js +6 -1
  132. package/dist/hub/member/pairing-api.js.map +1 -1
  133. package/dist/hub/member/pairing-notices.js +6 -4
  134. package/dist/hub/member/pairing-notices.js.map +1 -1
  135. package/dist/hub/pairing-notices.d.ts +3 -3
  136. package/dist/hub/pairing-notices.js +13 -8
  137. package/dist/hub/pairing-notices.js.map +1 -1
  138. package/dist/hub/pairing.d.ts +6 -0
  139. package/dist/hub/pairing.js +6 -6
  140. package/dist/hub/pairing.js.map +1 -1
  141. package/dist/hub/protocol.d.ts +29 -0
  142. package/dist/hub/protocol.js +3 -1
  143. package/dist/hub/protocol.js.map +1 -1
  144. package/dist/hub/room-read-pacer.d.ts +14 -0
  145. package/dist/hub/room-read-pacer.js +51 -0
  146. package/dist/hub/room-read-pacer.js.map +1 -0
  147. package/dist/hub/rooms.d.ts +7 -1
  148. package/dist/hub/rooms.js +25 -13
  149. package/dist/hub/rooms.js.map +1 -1
  150. package/dist/hub/runtime.d.ts +4 -0
  151. package/dist/hub/runtime.js +2 -0
  152. package/dist/hub/runtime.js.map +1 -1
  153. package/dist/hub/server.d.ts +3 -0
  154. package/dist/hub/server.js +14 -0
  155. package/dist/hub/server.js.map +1 -1
  156. package/dist/hub/session-directory-transition.d.ts +48 -0
  157. package/dist/hub/session-directory-transition.js +118 -0
  158. package/dist/hub/session-directory-transition.js.map +1 -0
  159. package/dist/hub/session-epoch.d.ts +16 -0
  160. package/dist/hub/session-epoch.js +50 -0
  161. package/dist/hub/session-epoch.js.map +1 -0
  162. package/dist/hub/sessions.d.ts +13 -0
  163. package/dist/hub/sessions.js +36 -16
  164. package/dist/hub/sessions.js.map +1 -1
  165. package/dist/hub/settings-api.d.ts +50 -0
  166. package/dist/hub/settings-api.js +92 -0
  167. package/dist/hub/settings-api.js.map +1 -0
  168. package/dist/hub/settings-commit.d.ts +95 -0
  169. package/dist/hub/settings-commit.js +490 -0
  170. package/dist/hub/settings-commit.js.map +1 -0
  171. package/dist/hub/settings-directory-decision.d.ts +433 -0
  172. package/dist/hub/settings-directory-decision.js +236 -0
  173. package/dist/hub/settings-directory-decision.js.map +1 -0
  174. package/dist/hub/settings-directory-proof.d.ts +77 -0
  175. package/dist/hub/settings-directory-proof.js +303 -0
  176. package/dist/hub/settings-directory-proof.js.map +1 -0
  177. package/dist/hub/store.d.ts +2 -1
  178. package/dist/hub/store.js +2 -1
  179. package/dist/hub/store.js.map +1 -1
  180. package/dist/hub/types.d.ts +4 -2
  181. package/dist/hub-host-settings.d.ts +48 -0
  182. package/dist/hub-host-settings.js +85 -0
  183. package/dist/hub-host-settings.js.map +1 -0
  184. package/dist/instance-lifecycle.d.ts +3 -0
  185. package/dist/instance-lifecycle.js +4 -0
  186. package/dist/instance-lifecycle.js.map +1 -1
  187. package/dist/locale.js +32 -14
  188. package/dist/locale.js.map +1 -1
  189. package/dist/outbound-schemas.d.ts +2 -0
  190. package/dist/outbound-schemas.js +4 -2
  191. package/dist/outbound-schemas.js.map +1 -1
  192. package/dist/pane-port.d.ts +1 -1
  193. package/dist/profile-signins.d.ts +107 -0
  194. package/dist/profile-signins.js +249 -0
  195. package/dist/profile-signins.js.map +1 -0
  196. package/dist/scheduler/db.d.ts +10 -0
  197. package/dist/scheduler/db.js +38 -11
  198. package/dist/scheduler/db.js.map +1 -1
  199. package/dist/scheduler/types.d.ts +6 -1
  200. package/dist/settings-api.d.ts +7 -0
  201. package/dist/settings-api.js +197 -2
  202. package/dist/settings-api.js.map +1 -1
  203. package/dist/settings-confirmation.d.ts +1 -1
  204. package/dist/settings-confirmation.js +1 -1
  205. package/dist/settings-confirmation.js.map +1 -1
  206. package/dist/settings-effect.js +58 -0
  207. package/dist/settings-effect.js.map +1 -1
  208. package/dist/settings-http-confirmation.d.ts +3 -0
  209. package/dist/settings-http-confirmation.js +8 -5
  210. package/dist/settings-http-confirmation.js.map +1 -1
  211. package/dist/settings-request-capability.d.ts +5 -0
  212. package/dist/settings-request-capability.js +6 -1
  213. package/dist/settings-request-capability.js.map +1 -1
  214. package/dist/structured-signin-transport.d.ts +20 -2
  215. package/dist/structured-signin-transport.js +57 -6
  216. package/dist/structured-signin-transport.js.map +1 -1
  217. package/dist/team-membership.d.ts +7 -0
  218. package/dist/team-membership.js +10 -0
  219. package/dist/team-membership.js.map +1 -0
  220. package/dist/tmux-manager.d.ts +1 -1
  221. package/dist/tmux-manager.js +4 -1
  222. package/dist/tmux-manager.js.map +1 -1
  223. package/dist/topic-commands.js +1 -1
  224. package/dist/topic-commands.js.map +1 -1
  225. package/dist/ui/backend-signin.js +51 -15
  226. package/dist/ui/hub-attachments.js +3 -3
  227. package/dist/ui/hub-chat-strings.js +2 -0
  228. package/dist/ui/hub-client.js +9 -3
  229. package/dist/ui/hub-company-join-strings.js +74 -0
  230. package/dist/ui/hub-company-join.js +119 -0
  231. package/dist/ui/hub-group-policy.js +7 -2
  232. package/dist/ui/hub-owner-strings.js +8 -8
  233. package/dist/ui/hub-quick-pairing.js +15 -8
  234. package/dist/ui/hub-quick-strings.js +3 -3
  235. package/dist/ui/hub-this-hub.js +112 -0
  236. package/dist/ui/hub-welcome.js +8 -5
  237. package/dist/ui/panel-hub.js +178 -26
  238. package/dist/ui/panel-needs.js +1 -1
  239. package/dist/ui/settings-hub-company-join.js +90 -0
  240. package/dist/ui/settings-hub-membership.js +2 -1
  241. package/dist/ui/settings-hub-preview.js +74 -0
  242. package/dist/ui/settings-hub-run.js +60 -0
  243. package/dist/ui/settings-hub-section.js +4 -2
  244. package/dist/ui/settings-registry.js +2 -0
  245. package/dist/ui/shared/app-i18n.js +1 -1
  246. package/dist/ui/shared/app-shell.js +21 -17
  247. package/dist/ui/shared/app.css +9 -8
  248. package/dist/ui/shared/chat-strings.js +13 -13
  249. package/dist/ui/shared/hub-chat.css +12 -0
  250. package/dist/ui/shared/hub-groups.css +2 -0
  251. package/dist/ui/shared/hub-owner.css +19 -1
  252. package/dist/ui/shared/hub.css +7 -1
  253. package/dist/ui/structured-signin.js +24 -6
  254. package/dist/update-dispatch.d.ts +32 -4
  255. package/dist/update-dispatch.js +146 -16
  256. package/dist/update-dispatch.js.map +1 -1
  257. package/dist/update-launch.d.ts +1 -1
  258. package/dist/update-launch.js +2 -2
  259. package/dist/update-launch.js.map +1 -1
  260. package/dist/view-api.d.ts +2 -8
  261. package/dist/view-api.js +3 -9
  262. package/dist/view-api.js.map +1 -1
  263. package/dist/web-api.d.ts +2 -0
  264. package/dist/web-api.js +66 -9
  265. package/dist/web-api.js.map +1 -1
  266. package/package.json +1 -1
@@ -1,3 +1,5 @@
1
+ import { hj, joinError } from "./hub-company-join-strings.js";
2
+ import { joinRequest, companyInfoRequest, CompanyJoinInfoPage, useCompanyJoinContext, CompanyJoinLead, approveCompanyJoin, HubCompanyJoinPage, CompanyJoinAdminCard } from "./hub-company-join.js";
1
3
  // AgEnD Hub P1, slice 3: the Hub workspace's pages — the chats (/ui/hub, a room at /ui/hub?room=<id>; #3226 B), My
2
4
  // exposures and Administration (/ui/hub/exposures, /ui/hub/admin; reached from the session row's menu) — and its session row. Served only by a Hub's own listener at its own origin, over the Hub's /hub/v1/*
3
5
  // API (hub-client.js createHubWebClient); nothing here reads or reaches a fleet. A lazy module: it imports only names
@@ -6,7 +8,7 @@
6
8
  // What people see is what the server says now: every list is read fresh, every change is checked again by the server
7
9
  // (who, the revision shown, the directory), and a conflict reloads the list instead of guessing.
8
10
  import { html, useEffect, useLayoutEffect, useMemo, useRef, useState } from "/assets/app-html.js";
9
- import { PanelHeader, closeDrawer, setTitle } from "/assets/app-shell.js";
11
+ import { DevicePrefs, PanelHeader, closeDrawer, isMacLike, searchShortcut, setTitle } from "/assets/app-shell.js";
10
12
  import { lang, register, t } from "/assets/app-i18n.js";
11
13
  import { createStore, useStore } from "/assets/app-store.js";
12
14
  import { navigate, navStore } from "/assets/app-nav.js";
@@ -26,6 +28,7 @@ import "/assets/chat-strings.js";
26
28
  import { compareGroups, hubClient } from "./hub-client.js";
27
29
  import { hw, linkHubCss } from "./hub-strings.js";
28
30
  import { hc, linkHubChatCss } from "./hub-chat-strings.js";
31
+ import { hr } from "./hub-read-strings.js";
29
32
  import { ho, linkHubOwnerCss } from "./hub-owner-strings.js";
30
33
  import { hg } from "./hub-grant-strings.js";
31
34
  import { createHubChatStore } from "./hub-chat-store.js";
@@ -93,23 +96,37 @@ const errText = (r) => hw(r.code === "conflict" || r.code === "stale" ? "errConf
93
96
 
94
97
  export function HubPanel({ route }) {
95
98
  const tab = TITLES[route && route.tab] ? route.tab : "ask";
99
+ const companyPage = tab === "ask" && (companyInfoRequest() || !!joinRequest());
96
100
  const s = useSession();
97
- useEffect(() => { linkHubCss(); if (tab === "ask") linkHubChatCss(); }, [tab]);
98
- useEffect(() => { setTitle(hw(TITLES[tab])); }, [tab]);
101
+ useStore(navStore); // ?view= changes without a new route
102
+ const view = viewParam();
103
+ // The owner stylesheet holds the page column (.hub-owner, 860 px) every page with a column uses — Notices too (Argon #12).
104
+ useEffect(() => { linkHubCss(); linkHubOwnerCss(); if (tab === "ask") linkHubChatCss(); }, [tab]);
105
+ // Join takes precedence over other query views. Rooms and Group permissions otherwise name their own pages.
106
+ const pageName = companyPage ? hj("title") : tab === "exposures" ? hc("mine") : tab === "admin" ? hc("admin") : view === "notices" ? hc("noticesTitle") : hc("chats");
107
+ useEffect(() => { if (companyPage || !(tab === "ask" && roomParam()) && !(tab === "admin" && view === "groups")) setTitle(pageName); }, [tab, view, pageName, roomParam(), companyPage]);
99
108
  let body = tab === "ask" ? roomParam() ? html`<${HubRoomLoading} />`
100
109
  : html`<${PanelHeader} title=${hc("chats")} /><div class="hub-home"><${Skeleton} variant="rows" lines=${4} /></div>`
101
110
  : html`<${Skeleton} variant="rows" lines=${4} />`;
102
111
  // Signed out: the sign-in page alone (no panel header, no chat chrome).
112
+ if (companyInfoRequest()) return html`<div data-effect-panel="hub" class="panel p-hub p-hub-info"><${PanelHeader} title=${hj("title")} /><div data-trust="panel-content" class="panel-body hub-page-body"><${CompanyJoinInfoPage} /></div></div>`;
103
113
  if (s === null) return html`<div data-effect-panel="hub" class="panel p-hub p-hub-signin"><${HubSignIn} /></div>`;
104
114
  if (s) body = tab === "ask" ? html`<${HubChats} />` : tab === "exposures" ? html`<${HubMine} />` : html`<${HubAdmin} admin=${!!s.admin} />`;
105
- const notices = s?.features?.includes("quick-pairing-v1") && hubClient().quickPairingV1 ? html`<${PairingNotices} admin=${!!s.admin} />` : null;
115
+ if (s && tab === "ask" && joinRequest()) return html`<div data-effect-panel="hub" class="panel p-hub p-hub-join">
116
+ <${PanelHeader} title=${hj("title")} /><div data-trust="panel-content" class="panel-body hub-page-body"><${HubCompanyJoinPage} session=${s} /></div></div>`;
117
+ // Security notices stay on their own page. The bound join branch above never renders the chat or notices page.
118
+ if (s && tab === "ask" && view === "notices" && noticesOffered(s)) return html`<div data-effect-panel="hub" class="panel p-hub p-hub-notices">
119
+ <${PanelHeader} title=${hc("noticesTitle")} /><div data-trust="panel-content" class="panel-body hub-page-body">
120
+ <div class="col hub-owner hub-notices-col"><p class="s-page-lead hub-page-lead">${hc("noticesLead")}</p>
121
+ <${PairingNotices} admin=${!!s.admin} empty=${html`<${Empty} icon="bell" title=${hc("noNotices")} />`} /></div></div></div>`;
106
122
  // The chats draw their own header (the room's); the other pages keep the panel's.
107
- if (s !== null && tab === "ask") return html`<div data-effect-panel="hub" class="panel p-hub p-hub-ask"><div data-trust="panel-content" class="panel-body hub-chat-body">${notices}${body}</div></div>`;
108
- // #3226 C: My shared agents and Administration are Settings-like pages (their own PageHead under the panel's header).
109
- const pageTitle = tab === "exposures" ? hc("mine") : tab === "admin" ? hc("admin") : hw(TITLES[tab]);
123
+ if (s !== null && tab === "ask") return html`<div data-effect-panel="hub" class="panel p-hub p-hub-ask"><div data-trust="panel-content" class="panel-body hub-chat-body">${body}</div></div>`;
124
+ // #3226 C: My shared agents and Administration are Settings-like pages. The panel's header names the page once, its scope
125
+ // beside it ("Yours" / "This Hub"); the page itself opens with its lead — no second title repeating the first (Argon #7).
126
+ const scope = s && tab === "exposures" && !agentParam() ? ho("scopeYou") : s && tab === "admin" && s.admin && view !== "groups" ? ho("scopeHub") : null;
110
127
  return html`<div data-effect-panel="hub" class=${`panel p-hub p-hub-${tab}`}>
111
- <${PanelHeader} title=${s ? pageTitle : hw(TITLES[tab])} />
112
- <div data-trust="panel-content" class=${`panel-body ${s ? "hub-page-body" : "hub-body"}`}>${notices}${body}</div>
128
+ <${PanelHeader} title=${pageName} sub=${scope ? html`<span class="s-scope">${scope}</span>` : null} />
129
+ <div data-trust="panel-content" class=${`panel-body ${s ? "hub-page-body" : "hub-body"}`}>${body}</div>
113
130
  </div>`;
114
131
  }
115
132
 
@@ -147,6 +164,7 @@ function linkHubSigninCss(doc = typeof document !== "undefined" ? document : nul
147
164
  } catch { /* the page still works without it */ }
148
165
  }
149
166
  function HubSignIn() {
167
+ const company = useCompanyJoinContext();
150
168
  useEffect(() => {
151
169
  linkHubSigninCss();
152
170
  // #3318 review F1: signed out from the phone drawer's session menu (or a session that ended while it was open), the
@@ -172,25 +190,34 @@ function HubSignIn() {
172
190
  }
173
191
  setBusy(true); setMsg(null);
174
192
  const r = await hubClient().signIn(form.login.trim(), form.password);
193
+ if (r.ok) {
194
+ setForm({ login: "", password: "" });
195
+ if (company.requestId) {
196
+ const joined = await approveCompanyJoin(company.requestId, r.csrf);
197
+ if (!joined.ok) { setBusy(false); setSession({ ...r, companyJoinFailure: { requestId: company.requestId, code: joined.code } }); return; }
198
+ }
199
+ setBusy(false); setSession(r); return;
200
+ }
175
201
  setBusy(false);
176
- if (r.ok) { setForm({ login: "", password: "" }); setSession(r); return; }
177
202
  setForm((f) => ({ ...f, password: "" }));
178
203
  setMsg(r.code === "backpressure" ? hw("errBusyHub") : r.code === "unavailable" ? hw("errDirectory") : hw("errSignIn"));
179
204
  };
180
205
  return html`<main class="hub-signin-page"><section class="hub-signin hub-signin-card" aria-labelledby="hubSignInTitle">
181
206
  <div class="hub-signin-brand"><strong>${t("hubShell.brand")}</strong>${name ? html`<span>${name}</span>` : null}</div>
182
207
  <h1 id="hubSignInTitle">${hw("signInTitle")}</h1>
183
- <p class="hub-signin-lead">${hw("signInLead")}</p>
184
- <form class="hub-signin-form" onSubmit=${submit}>
208
+ ${company.requestId ? html`<${CompanyJoinLead} context=${company.view?.ok ? company.view : null} />` : html`<p class="hub-signin-lead">${hw("signInLead")}</p>`}
209
+ ${company.requestId && company.view === undefined ? html`<${Skeleton} variant="form" lines=${2} label=${hj("loading")} />` : company.requestId && company.view && !company.view.ok ? html`<${ErrorState} message=${joinError(company.view.code)} onRetry=${company.retry} />` : null}
210
+ ${!company.requestId || company.view?.ok && company.view.state === "pending" ? html`<form class="hub-signin-form" onSubmit=${submit}>
185
211
  <label for="hubLogin">${hw("login")}</label>
186
212
  <input id="hubLogin" autocomplete="username" spellcheck=${false} autocapitalize="none"
187
213
  value=${form.login} onInput=${(e) => { const v = e.target.value; setForm((f) => ({ ...f, login: v })); }} />
188
214
  <label for="hubPassword">${hw("password")}</label>
189
215
  <input id="hubPassword" type="password" autocomplete="current-password"
190
216
  value=${form.password} onInput=${(e) => { const v = e.target.value; setForm((f) => ({ ...f, password: v })); }} />
191
- <button type="submit" class="hub-signin-go" disabled=${busy}>${hw("signIn")}</button>
192
- </form>
217
+ <button type="submit" class="hub-signin-go" disabled=${busy || company.requestId && !company.view?.ok}>${company.requestId ? hj("signInConnect") : hw("signIn")}</button>
218
+ </form>` : company.view?.ok ? html`<p role="status">${joinError(company.view.reason || company.view.state)}</p>` : null}
193
219
  <p class="hub-signin-msg" role=${msg ? "alert" : undefined}>${msg || ""}</p>
220
+ ${company.requestId && (msg || company.view?.state !== "pending") && company.view?.returnPath ? html`<a class="btn btn-sm" href=${company.view.returnPath} rel="noreferrer">${hj("return")}</a>` : null}
194
221
  </section></main>`;
195
222
  }
196
223
 
@@ -231,6 +258,10 @@ function useRooms() {
231
258
  }
232
259
  const roomParam = () => { try { const v = new URLSearchParams(location.search).get("room"); return v && /^[a-f0-9-]{36}$/.test(v) ? v : null; } catch { return null; } };
233
260
  const roomPath = (id) => `/ui/hub?room=${encodeURIComponent(id)}`;
261
+ /** cid-hub-shell-parity: the Notices page is /ui/hub?view=notices (the path every Hub listener and router already serves). */
262
+ const viewParam = () => { try { return new URLSearchParams(location.search).get("view"); } catch { return null; } };
263
+ export const NOTICES_PATH = "/ui/hub?view=notices";
264
+ const noticesOffered = (s) => !!s && Array.isArray(s.features) && s.features.includes("quick-pairing-v1") && !!hubClient().quickPairingV1;
234
265
  const initial = (name) => (String(name || "?").trim()[0] || "?").toUpperCase();
235
266
  const AV_TONES = 6;
236
267
  const tone = (name) => { let h = 0; for (const c of String(name || "")) h = (h * 31 + c.codePointAt(0)) >>> 0; return h % AV_TONES; };
@@ -264,7 +295,7 @@ export function HubNav({ onPick } = {}) {
264
295
  <div class="hub-sec">${hc("chats")}</div>
265
296
  ${rs.error ? html`<${ErrorState} message=${rs.error} onRetry=${refreshRooms} />` : null}
266
297
  ${!rs.loaded ? html`<${Skeleton} variant="rows" lines=${4} />` : null}
267
- ${rs.loaded && !rs.error && !rs.denied && !rs.rooms.length ? html`<p class="note hub-list-empty">${hc("noChatsHint")}</p>` : null}
298
+ ${rs.loaded && !rs.error && !rs.denied && !rs.rooms.length ? html`<p class="note hub-list-empty">${hc("noChats")}</p>` : null}
268
299
  ${rs.rooms.length && !shown.length ? html`<p class="note hub-list-empty">${hc("noMatch")}</p>` : null}
269
300
  <ul class="hub-rooms" role="list">${shown.map((r) => html`<li key=${r.id}>
270
301
  <a class=${`hub-room-row${current === r.id ? " active" : ""}${r.state === "closed" ? " closed" : ""}`} href=${roomPath(r.id)} aria-current=${current === r.id ? "page" : undefined} onClick=${(e) => pick(e, r)}>
@@ -276,6 +307,115 @@ export function HubNav({ onPick } = {}) {
276
307
  </div>`;
277
308
  }
278
309
 
310
+ /**
311
+ * cid-hub-shell-parity (the user: 「agend 排得很好看, agend hub 醜到不行」; approved mockup): the Hub's sidebar is the fleet
312
+ * dashboard's own — style guide rule 1, its shell components, not Hub-only ones. Icon rows (`side-row`): Conversations, My
313
+ * shared agents, Administration (the administrator only), Notices (only where the Hub offers its security notices), Search
314
+ * (Ctrl K: the conversation filter) and New conversation (`side-new`); then the conversation list under a `side-label`
315
+ * section, with a one-line empty state. The app shell mounts it (HubSidebar); an older shell keeps HubNav.
316
+ * Notices has no count: the Hub exposes the retained notices, not which of them this person has read.
317
+ */
318
+ export function HubSide({ onPick } = {}) {
319
+ const s = useSession();
320
+ const rs = useRooms();
321
+ const { route } = useStore(navStore);
322
+ const [q, setQ] = useState("");
323
+ const [filtering, setFiltering] = useState(false);
324
+ const [picking, setPicking] = useState(false);
325
+ const filter = useRef(null);
326
+ useEffect(() => { linkHubChatCss(); }, []);
327
+ const openFilter = () => { setFiltering(true); setTimeout(() => filter.current?.focus(), 0); };
328
+ // Ctrl K (⌘K): the conversation filter — the dashboard's search shortcut, on the Hub's own search (no fleet search here).
329
+ useEffect(() => {
330
+ const onKey = (e) => {
331
+ if (e.isComposing || e.altKey || e.shiftKey || !(isMacLike() ? e.metaKey : e.ctrlKey) || (e.key || "").toLowerCase() !== "k") return;
332
+ if (typeof document !== "undefined" && document.querySelector("dialog[open]:not(.side-panel)")) return;
333
+ e.preventDefault(); openFilter();
334
+ };
335
+ document.addEventListener("keydown", onKey);
336
+ return () => document.removeEventListener("keydown", onKey);
337
+ }, []);
338
+ if (!s) return null;
339
+ const tab = route && route.panel === "hub" ? route.tab : "ask";
340
+ const view = viewParam();
341
+ const here = (key) => key === "notices" ? tab === "ask" && view === "notices" : key === "ask" ? tab === "ask" && view !== "notices" : tab === key;
342
+ const go = (e, href) => { if (onPick) onPick(); if (e && (e.metaKey || e.ctrlKey)) return; e && e.preventDefault(); navigate(href); };
343
+ const row = (key, href, icon, label) => html`<a class=${`side-row${here(key) ? " active" : ""}`} href=${href} aria-current=${here(key) ? "page" : undefined}
344
+ onClick=${(e) => go(e, href)}><${Icon} name=${icon} /><span class="grow">${label}</span></a>`;
345
+ // On the chats' own home (no room open, no filter) the page already says "No chats yet": the list doesn't say it twice (Argon #19).
346
+ const home = tab === "ask" && view !== "notices" && !roomParam();
347
+ return html`<nav data-trust="navigation" class="side-nav" aria-label=${t("app.menu")}>
348
+ ${row("ask", "/ui/hub", "chat", hc("chats"))}
349
+ ${row("exposures", "/ui/hub/exposures", "globe", hc("mine"))}
350
+ ${s.admin ? row("admin", "/ui/hub/admin", "key", hc("admin")) : null}
351
+ ${noticesOffered(s) ? row("notices", NOTICES_PATH, "bell", hc("notices")) : null}
352
+ <button type="button" class="side-row side-search" onClick=${openFilter} title=${`${hc("search")} (${searchShortcut()})`}
353
+ aria-keyshortcuts=${isMacLike() ? "Meta+K" : "Control+K"}><${Icon} name="search" /><span class="grow">${hc("navSearch")}</span><kbd class="kbd-hint" aria-hidden="true">${searchShortcut()}</kbd></button>
354
+ <button type="button" class="side-row side-new" onClick=${() => setPicking(true)}><${Icon} name="plus" /><span class="grow">${hc("newChat")}</span></button>
355
+ </nav>
356
+ <${HubRoomList} rs=${rs} q=${q} setQ=${setQ} filtering=${filtering} setFiltering=${setFiltering} filterRef=${filter} onPick=${onPick} quietEmpty=${home} />
357
+ ${picking ? html`<${NewChatDialog} onClose=${() => setPicking(false)} />` : null}`;
358
+ }
359
+
360
+ /**
361
+ * The conversation list, as the dashboard draws its roster (`view-roster inst-nav > side-section`, the section's label and
362
+ * count, one-line empty states) — the sidebar's (HubSide) and, on a phone, the chats' home page's (with its own New chat
363
+ * row and the filter always shown): one drawing, not two (Argon #9). `quietEmpty`: the page beside it already says "No chats yet".
364
+ */
365
+ function HubRoomList({ rs, q, setQ, filtering, setFiltering, filterRef, onPick, quietEmpty = false, onNew = null }) {
366
+ const current = roomParam();
367
+ const go = (e, href) => { if (onPick) onPick(); if (e && (e.metaKey || e.ctrlKey)) return; e && e.preventDefault(); navigate(href); };
368
+ const shown = rs.rooms.filter((r) => !q.trim() || `${r.exposureName} ${r.ownerName}`.toLowerCase().includes(q.trim().toLowerCase()));
369
+ const always = !!onNew; // the home page's list: its filter is always there (when there's a list to filter)
370
+ return html`<div class="view-roster inst-nav hub-side-rooms"><div data-trust="navigation" class="side-section">
371
+ ${onNew ? html`<button type="button" class="side-row side-new" onClick=${onNew}><${Icon} name="plus" /><span class="grow">${hc("newChat")}</span></button>` : null}
372
+ <div class="inst-head"><h2 class="side-label">${hc("chats")}</h2>${rs.rooms.length ? html`<span class="count">${rs.rooms.length}</span>` : null}</div>
373
+ ${filtering || q || (always && rs.rooms.length) ? html`<label class="hub-side-filter"><${Icon} name="search" size=${14} /><input ref=${filterRef} type="search" placeholder=${hc("search")} aria-label=${hc("search")} value=${q}
374
+ onInput=${(e) => setQ(e.target.value)} onKeyDown=${(e) => { if (e.key === "Escape") { setQ(""); setFiltering(false); } }} /></label>` : null}
375
+ ${rs.error ? html`<${ErrorState} message=${rs.error} onRetry=${refreshRooms} />` : null}
376
+ ${!rs.loaded ? html`<${Skeleton} variant="rows" lines=${4} />` : null}
377
+ ${rs.loaded && !rs.error && !rs.denied && !rs.rooms.length && !quietEmpty ? html`<p class="side-empty muted">${hc("noChats")}</p>` : null}
378
+ ${rs.rooms.length && !shown.length ? html`<p class="side-empty muted">${hc("noMatch")}</p>` : null}
379
+ <ul class="hub-rooms" role="list">${shown.map((r) => html`<li key=${r.id}>
380
+ <a class=${`hub-room-row${current === r.id ? " active" : ""}${r.state === "closed" ? " closed" : ""}`} href=${roomPath(r.id)} aria-current=${current === r.id ? "page" : undefined} onClick=${(e) => go(e, roomPath(r.id))}>
381
+ <${Avatar} name=${r.exposureName} />
382
+ <span class="hub-room-text"><span class="t">${r.exposureName}</span><span class="s">${r.state === "closed" ? hc("tagClosed") : r.waiting ? hc("waiting") : r.ownerName ? hc("represents", r.ownerName) : ""}</span></span>
383
+ <span class="hub-room-side"><span class="time">${listTime(r.lastAt)}</span>${r.waiting ? html`<span class="pulse" title=${hc("waiting")}></span>` : null}</span>
384
+ </a></li>`)}</ul>
385
+ </div></div>`;
386
+ }
387
+
388
+ /** The phone's chats home: the same roster, with New chat at its head and the filter in place. */
389
+ function HubHomeList() {
390
+ const rs = useRooms();
391
+ const [q, setQ] = useState(""), [filtering, setFiltering] = useState(false), [picking, setPicking] = useState(false);
392
+ const filter = useRef(null);
393
+ return html`<${HubRoomList} rs=${rs} q=${q} setQ=${setQ} filtering=${filtering} setFiltering=${setFiltering} filterRef=${filter} onNew=${() => setPicking(true)} />
394
+ ${picking ? html`<${NewChatDialog} onClose=${() => setPicking(false)} />` : null}`;
395
+ }
396
+
397
+ /**
398
+ * cid-hub-shell-parity: the sidebar's foot, as the dashboard's — Settings (this device's theme and language: the shell's own
399
+ * DevicePrefs) and the session row ("Signed in", the person's name beside it), whose menu holds Sign out.
400
+ */
401
+ export function HubFoot() {
402
+ const s = useSession();
403
+ const [busy, setBusy] = useState(false);
404
+ const prefs = html`<details class="prefs-pop hub-prefs"><summary class="side-row"><${Icon} name="settings" /><span class="grow">${hc("settings")}</span></summary>
405
+ <div data-trust="popover" class="pop" role="group" aria-label=${t("app.devicePrefs")}><${DevicePrefs} labels=${true} fields=${["theme", "language"]} /></div></details>`;
406
+ if (s === undefined) return html`${prefs}<div class="session"><${Skeleton} variant="inline" lines=${1} /></div>`;
407
+ if (!s) return prefs;
408
+ const out = async () => { setBusy(true); await hubClient().signOut(); setBusy(false); setSession(null); };
409
+ // Who is signed in heads the menu — their name and sign-in name (the foot's row says "Signed in", as the dashboard's) — then
410
+ // Sign out. My shared agents and Administration are the sidebar's own rows, not repeated here (Argon #10).
411
+ const items = [
412
+ { key: "who", label: s.login && s.login !== s.displayName ? `${s.displayName} (${s.login})` : s.displayName, icon: "user", disabled: true },
413
+ { key: "out", label: hc("signOut"), icon: "back", onSelect: out, disabled: busy },
414
+ ];
415
+ return html`${prefs}<div class="session hub-session-row"><${Menu} items=${items} label=${hc("signedIn")} cls="hub-session-menu" triggerClass="side-row"
416
+ trigger=${html`<span class="dot ok" aria-hidden="true"></span><span class="grow">${hc("signedIn")}</span><span class="meta" title=${s.displayName}>${s.displayName}</span>`} /></div>`;
417
+ }
418
+
279
419
  /** New chat: the agents someone allowed this person to ask; Ask opens (or reopens) its room. */
280
420
  function NewChatDialog({ onClose }) {
281
421
  const [cat, reload] = useRead(() => hubClient().catalog());
@@ -324,10 +464,10 @@ function HubChats() {
324
464
  if (id) return html`<${HubRoomLoading} error=${rs.error} />`;
325
465
  return html`<${PanelHeader} title=${hc("chats")} />
326
466
  <div class=${`hub-home${groupPolicyOn(s, hubClient()) ? " has-welcome" : ""}`}>
327
- <div class="hub-home-list"><${HubNav} /></div>
467
+ <div class="hub-home-list"><${HubHomeList} /></div>
328
468
  ${groupPolicyOn(s, hubClient()) ? html`<div class="hub-home-pick hub-home-welcome"><${LazyGroups} pick=${(m) => m.HubWelcome} props=${{ name: s.displayName, quick: s.features.includes("quick-pairing-v1"), onChats: () => setPicking(true) }} /></div>`
329
469
  : html`<div class="hub-home-pick center">${!rs.loaded ? html`<${Skeleton} variant="rows" lines=${4} />` : rs.error && !rs.rooms.length ? html`<${ErrorState} message=${rs.error} onRetry=${refreshRooms} />` : !rs.rooms.length
330
- ? html`<${Empty} icon="chat" title=${hc("noChats")} hint=${hc("noChatsHint")} />`
470
+ ? html`<${Empty} icon="chat" title=${hc("noChats")} />`
331
471
  : html`<${Empty} icon="chat" title=${hc("choose")} hint=${hc("chooseHint")} />`}</div>`}
332
472
  ${picking ? html`<${NewChatDialog} onClose=${() => setPicking(false)} />` : null}
333
473
  </div>`;
@@ -546,7 +686,8 @@ function HubThread({ store, name, panelKey, threadRef }) {
546
686
  <div class="thread-host" ref=${host}></div>
547
687
  ${/* #3145: that every asker shares the agent's one conversation is said before anyone types. */ ""}
548
688
  ${!loaded && !store.error() && !store.closed() ? html`<${Skeleton} variant="rows" lines=${5} />` : null}
549
- ${!loaded && store.error() ? html`<${ErrorState} message=${errText({ code: store.error() })} onRetry=${() => store.refresh()} />` : null}
689
+ ${store.error() === "backpressure" ? html`<p class="hub-banner warn" role="status">${hr("busy")}</p>`
690
+ : !loaded && store.error() ? html`<${ErrorState} message=${errText({ code: store.error() })} onRetry=${() => store.refresh()} />` : null}
550
691
  ${empty && loaded && !store.closed() ? html`<div class="center hub-room-empty"><${Empty} icon="chat" title=${hc("emptyRoom", name)} hint=${`${hc("emptyRoomHint", store.room().ownerName || name)}${lang() === "zh-TW" ? "" : " "}${hw("roomShared")}`} /></div>` : null}
551
692
  <div class="jump-dock">${jump.show ? html`<button data-trust="thread-control" type="button" class="jump-latest" onClick=${() => th.current && th.current.jumpLatest()}>
552
693
  <${Icon} name="down" size=${16} />${jump.unseen > 0 ? t("chat.newBelow", jump.unseen) : t("chat.jumpLatest")}</button>` : null}</div>
@@ -616,7 +757,8 @@ function HubMine() {
616
757
  // Keyed by the agent: another ?agent= is another page (its reads, its dialog), and a late answer for the previous one
617
758
  // lands nowhere (useRead's own liveness ends with that page).
618
759
  if (x) return html`<${HubAgentPage} key=${x.id} x=${x} act=${act} msg=${msg} />`;
619
- return html`<div class="col hub-owner"><${PageHead} title=${hc("mine")} scope=${ho("scopeYou")} lead=${ho("mineLead")} />
760
+ // Nothing shared yet: the empty state below says where to share from, so the lead doesn't say it too (Argon #20).
761
+ return html`<div class="col hub-owner"><p class="s-page-lead hub-page-lead">${ho(cat && !cat.error && !mine.length ? "mineLeadShort" : "mineLead")}</p>
620
762
  <div class="s-section-layout">
621
763
  ${msg ? html`<p class="err" role="alert">${msg}</p>` : null}
622
764
  ${!pairings ? html`<${Skeleton} lines=${2} />` : pairings.error ? html`<${ErrorState} message=${pairings.error} onRetry=${reloadPairings} />` : null}
@@ -715,7 +857,13 @@ function HubAdmin({ admin }) {
715
857
  // Reached from a fleet's Settings link on a Hub (or a tab) without group permissions: say so instead of a silent admin page.
716
858
  const unavailable = adminView() === "groups" && !groupPolicyOn(s, hubClient());
717
859
  return html`${unavailable ? html`<p class="note" role="status" data-groups="unavailable">${t("hubGroupsNote.unavailable")}</p>` : null}
718
- <${HubAdminPage} groups=${groupPolicyOn(s, hubClient())} />`;
860
+ <${HubAdminPage} groups=${groupPolicyOn(s, hubClient())} companyJoin=${s?.features?.includes("company-join-v1")} />`;
861
+ }
862
+ /** M-2682: Administration → This Hub, its own lazy module (an older server doesn't serve it: then it's left out). */
863
+ function LazyThisHub() {
864
+ const [C, setC] = useState(null);
865
+ useEffect(() => { let live = true; import("./hub-this-hub.js").then((m) => { if (live) setC(() => m.ThisHubCard); }, () => {}); return () => { live = false; }; }, []);
866
+ return C ? html`<${C} />` : null;
719
867
  }
720
868
  /** #3298 S-89: Administration's sub-page (?view=groups: Group permissions), from the page's own address. */
721
869
  function adminView() { try { return new URLSearchParams(location.search).get("view") || ""; } catch { return ""; } }
@@ -723,7 +871,7 @@ function adminView() { try { return new URLSearchParams(location.search).get("vi
723
871
  function GroupPermissionsEntry() {
724
872
  return html`<${LazyGroups} pick=${(m) => m.GroupPermissionsCard} props=${{}} />`;
725
873
  }
726
- function HubAdminPage({ groups = false } = {}) {
874
+ function HubAdminPage({ groups = false, companyJoin = false } = {}) {
727
875
  const [view, reload] = useRead(() => hubClient().adminOverview());
728
876
  const [login, setLogin] = useState("");
729
877
  const [offer, setOffer] = useState(null);
@@ -731,7 +879,8 @@ function HubAdminPage({ groups = false } = {}) {
731
879
  useEffect(() => { linkHubChatCss(); linkHubOwnerCss(); }, []);
732
880
  const create = async (e) => {
733
881
  e.preventDefault();
734
- if (!login.trim()) return;
882
+ // The button is always ready (a disabled one reads as grey, "broken" — Argon #16): an empty field just takes the focus.
883
+ if (!login.trim()) { (typeof document !== "undefined" ? document.getElementById("hubOwnerLogin") : null)?.focus(); return; }
735
884
  setMsg(null);
736
885
  const r = await hubClient().createPairing(login.trim());
737
886
  if (!r.ok) { setMsg(errText(r)); return; }
@@ -751,20 +900,22 @@ function HubAdminPage({ groups = false } = {}) {
751
900
  if (!r.ok) setMsg(errText(r));
752
901
  reload();
753
902
  };
754
- if (!view || (view.error && !view.fleets)) return html`<div class="col hub-owner hub-admin"><${PageHead} title=${hc("admin")} scope=${ho("scopeHub")} lead=${ho("adminLead")} />
903
+ const lead = html`<p class="s-page-lead hub-page-lead">${ho("adminLead")}</p>`;
904
+ if (!view || (view.error && !view.fleets)) return html`<div class="col hub-owner hub-admin">${lead}
755
905
  <div class="s-section-layout">${view?.error ? html`<${ErrorState} message=${view.error} onRetry=${reload} />`
756
906
  : html`<section class="card"><h3>${ho("pairSteps")}</h3><${Skeleton} variant="rows" lines=${3} /></section><section class="card"><${Skeleton} variant="rows" lines=${3} /></section>`}</div></div>`;
757
907
  const fleets = view.fleets || [], pairings = view.pairings || [];
758
- return html`<div class="col hub-owner hub-admin"><${PageHead} title=${hc("admin")} scope=${ho("scopeHub")} lead=${ho("adminLead")} />
908
+ return html`<div class="col hub-owner hub-admin">${lead}
759
909
  <div class="s-section-layout">
760
910
  ${groups ? html`<${GroupPermissionsEntry} />` : null}
911
+ ${companyJoin ? html`<${CompanyJoinAdminCard} />` : null}
761
912
  ${view.error ? html`<${ErrorState} message=${view.error} onRetry=${reload} />` : null}
762
913
  ${msg ? html`<p class="err" role="alert">${msg}</p>` : null}
763
914
  <section class="card"><h3>${ho("pairSteps")}</h3>
764
915
  <ol class="hub-steps">
765
916
  <li class=${offer || pairings.length ? "done" : "now"}><div class="hub-step-body"><span><b>${ho("stepCode")}</b><small class="note">${ho("stepCodeHint")}</small></span>
766
- <form class="hub-step-form" onSubmit=${create}><label class="field"><span class="sr-only">${ho("ownerLogin")}</span><input placeholder=${ho("ownerLogin")} autocomplete="off" spellcheck=${false} autocapitalize="none" value=${login} onInput=${(e) => setLogin(e.target.value)} /></label>
767
- <button type="submit" class="btn btn-sm" disabled=${!login.trim()}>${ho("makeCode")}</button></form>
917
+ <form class="hub-step-form" onSubmit=${create}><label class="field"><span class="sr-only">${ho("ownerLogin")}</span><input id="hubOwnerLogin" placeholder=${ho("ownerLogin")} autocomplete="off" spellcheck=${false} autocapitalize="none" value=${login} onInput=${(e) => setLogin(e.target.value)} /></label>
918
+ <button type="submit" class="btn btn-sm btn-primary">${ho("makeCode")}</button></form>
768
919
  ${offer ? html`<div class="hub-offer" role="status"><small class="note">${ho("codeFor", offer.login)}</small><code class="hub-code">${offer.code}</code><small class="note">${hw("expires", when(offer.expiresAt))}</small>
769
920
  ${offer.memberOrigin ? html`<div class="field"><span>${ho("memberAddress")}</span><span class="hub-origin"><code>${offer.memberOrigin}</code></span><small class="note">${ho("memberAddressHint")}</small></div>
770
921
  <button type="button" class="btn btn-sm" onClick=${async () => { const ok = await copyText(`${ho("memberAddress")}: ${offer.memberOrigin}\n${ho("codeFor", offer.login)}: ${offer.code}\n${hw("expires", when(offer.expiresAt))}`); toast(ho(ok ? "handoffCopied" : "handoffCopyFailed"), !ok); }}><${Icon} name="copy" size=${14} />${ho("copyHandoff")}</button>`
@@ -789,6 +940,7 @@ function HubAdminPage({ groups = false } = {}) {
789
940
  : html`<span class="tag">${ho("revokedTag")}</span>`}
790
941
  </div>`)}</div>` : html`<p class="note">${ho("noFleets")}</p>`}
791
942
  </section>
943
+ <${LazyThisHub} />
792
944
  </div></div>`;
793
945
  }
794
946
 
@@ -72,7 +72,7 @@ register("needs", {
72
72
  notifyInsecure: "通知需要安全的網址(localhost 或 HTTPS 公開連結),區網的一般 HTTP 網址不行。",
73
73
  notifyUnsupported: "這個瀏覽器無法顯示通知。", turnOn: "開啟", turnOff: "關閉",
74
74
  typePrompt: "Fleet 提示", typeAwaiting: "在終端機上", typeInstance: "Instance", typeDelivery: "傳送", typeMissed: "離線時錯過",
75
- proposals: "代理人的請求", proposalFrom: "{0} 的請求", proposalHint: "在你核准之前,不會建立或修改任何東西。核准時,AgEnD 會再次檢查這個請求、目標電腦和你的登入,然後只執行一次。",
75
+ proposals: "Agent 的請求", proposalFrom: "{0} 的請求", proposalHint: "在你核准之前,不會建立或修改任何東西。核准時,AgEnD 會再次檢查這個請求、目標電腦和你的登入,然後只執行一次。",
76
76
  approve: "核准", reject: "拒絕", deciding: "處理中…", expiresIn: "{0} 分鐘後過期", expiresSoon: "不到一分鐘後過期",
77
77
  applying: "正在套用…", openAgent: "開啟新 agent 的聊天", decided: "已在這裡決定", failedReason: "原因:{0}",
78
78
  f_runtime: "執行於", f_machine: "電腦", f_thisPc: "這台電腦(Windows)", f_topic_name: "名稱", f_backend: "CLI", f_model: "模型", f_directory: "資料夾",
@@ -0,0 +1,90 @@
1
+ /** Fleet-only company handoff; all fields live in the actual Settings section and use its shared confirmation card. */
2
+ import { html, useEffect, useRef, useState } from "/assets/app-html.js";
3
+ import { Skeleton, ErrorState } from "/assets/ui-states.js";
4
+ import { api, confirmedWrite } from "./settings-confirm.js";
5
+ import { hj, joinError, joinResponseCode } from "./hub-company-join-strings.js";
6
+ const root = "/api/hub/member/company-join";
7
+ export function CompanyJoinSettings({ onSaved, memberEnabled = false } = {}) {
8
+ const notified = useRef(null);
9
+ const waiting = (() => { try { return new URLSearchParams(location.search).get("joinWait"); } catch { return null; } })();
10
+ const [view, setView] = useState(undefined), [error, setError] = useState(null), [busy, setBusy] = useState(false), [pending, setPending] = useState(false), [identityChanged, setIdentityChanged] = useState(false);
11
+ const [bound, setBound] = useState(false);
12
+ const [form, setForm] = useState(() => {
13
+ let address = ""; try { const candidate = new URLSearchParams(location.hash.slice(1)).get("join"); if (candidate && candidate.length <= 8192) address = candidate; } catch {}
14
+ return { address, label: hj("defaultFleet") };
15
+ }), live = useRef(true), token = useRef(0);
16
+ const read = async () => {
17
+ const gen = token.current;
18
+ try { const result = await api(root + (view?.operationId ? `?operationId=${encodeURIComponent(view.operationId)}` : ""));
19
+ if (!live.current || gen !== token.current) return;
20
+ if (!result.ok) { setError(joinError(result.body?.error)); return; }
21
+ setView(result.body.operation ?? null); setBound(result.body.bound === true); setError(null);
22
+ } catch { if (live.current && gen === token.current) setError(hj("unknown")); }
23
+ };
24
+ useEffect(() => { live.current = true; read(); return () => { live.current = false; token.current++; }; }, []);
25
+ useEffect(() => {
26
+ if (!waiting && (!view?.operationId || !["joining", "awaiting-sign-in", "durable"].includes(view.state) && !(view.state === "saved" && view.link !== "online"))) return;
27
+ if (waiting && view?.handoffId === waiting && view.state === "awaiting-sign-in") {
28
+ location.replace(root + "/bridge?operationId=" + encodeURIComponent(view.operationId)); return;
29
+ }
30
+ const timer = setTimeout(read, 1500); return () => clearTimeout(timer);
31
+ }, [view, waiting]);
32
+ useEffect(() => { if (view?.state === "saved" && view.link === "online" && notified.current !== view.operationId) { notified.current = view.operationId; onSaved?.(); } }, [view, onSaved]);
33
+ const start = async e => {
34
+ e.preventDefault(); if (busy) return;
35
+ const gen = ++token.current; setBusy(true); setError(null); setPending(false); setIdentityChanged(false);
36
+ const handoffId = crypto.randomUUID();
37
+ // Open the Fleet-owned waiting page during the user gesture, with no opener or cross-origin messaging.
38
+ globalThis.open("/settings/hub?joinWait=" + encodeURIComponent(handoffId), "_blank", "noopener");
39
+ try {
40
+ const result = await confirmedWrite(root + "/start", { body: { ...form, handoffId }, label: hj("title"), onPending: () => { if (live.current && gen === token.current) setPending(true); } });
41
+ if (!live.current || gen !== token.current) return;
42
+ if (!result.ok || !result.body?.operation) { await read(); const code = joinResponseCode(result); setError(joinError(code)); setIdentityChanged(code === "identity-changed"); return; }
43
+ const operation = result.body.operation; setView(operation); setError(null);
44
+
45
+ } catch { if (live.current && gen === token.current) setError(hj("unknown")); }
46
+ finally { if (live.current && gen === token.current) { setBusy(false); setPending(false); } }
47
+ };
48
+ const repair = async () => {
49
+ if (busy) return; const gen = ++token.current; setBusy(true); setError(null);
50
+ try {
51
+ const result = await confirmedWrite(root + "/repair-trust", { body: { address: form.address }, label: hj("repair"), onPending: () => { if (live.current && gen === token.current) setPending(true); } });
52
+ if (!live.current || gen !== token.current) return;
53
+ if (result.ok) { setIdentityChanged(false); setError(null); } else setError(joinError(joinResponseCode(result)));
54
+ } catch { if (live.current && gen === token.current) setError(hj("unknown")); }
55
+ finally { if (live.current && gen === token.current) { setBusy(false); setPending(false); } }
56
+ };
57
+ const action = async step => {
58
+ if (busy || !view?.operationId) return;
59
+ const gen = ++token.current; setBusy(true); setError(null);
60
+ try {
61
+ const options = { body: { operationId: view.operationId }, label: hj("title") };
62
+ const result = step === "resume" ? await confirmedWrite(root + "/resume", options) : await api(root + "/cancel", { method: "POST", body: JSON.stringify(options.body) });
63
+ if (!live.current || gen !== token.current) return;
64
+ if (result.ok) setView(result.body.operation); else setError(joinError(joinResponseCode(result)));
65
+ } catch { if (live.current && gen === token.current) setError(hj("unknown")); }
66
+ finally { if (live.current && gen === token.current) setBusy(false); }
67
+ };
68
+ const canStart = !waiting && (view === null || view && ["ended", "cancelled"].includes(view.state) && !view.issued && view.outcomeKnown);
69
+ // The existing connection card owns ready status, sharing and disconnect. Do not duplicate it after handoff.
70
+ if (!waiting && bound && view === null || view?.state === "saved" && (memberEnabled || view.link === "online") && onSaved) return null;
71
+ return html`<section class="card s-company-join"><h3>${hj("title")}</h3><p class="note">${hj("lead")}</p>
72
+ ${(view === undefined || waiting && view?.handoffId !== waiting) && !error ? html`<${Skeleton} variant="form" lines=${4} label=${hj("loading")} />` : null}
73
+ ${error ? html`<${ErrorState} message=${error} onRetry=${read} />` : null}
74
+ ${pending ? html`<p role="status" class="note">${hj("pending")}</p>` : null}
75
+ ${waiting && view !== undefined && view?.handoffId !== waiting ? html`<p role="status" class="note">${hj("pending")}</p><a class="btn btn-sm" href="/settings/hub">${hj("return")}</a>` : null}
76
+ ${canStart ? html`<form class="form" onSubmit=${start}>
77
+ <label class="field" for="hubCompanyAddress"><span>${hj("address")}</span><input id="hubCompanyAddress" type="text" value=${form.address} autocomplete="off" spellcheck=${false} onInput=${e => setForm(f => ({ ...f, address: e.target.value }))} /><small class="note">${hj("addressHint")}</small></label>
78
+ <label class="field" for="hubCompanyFleetName"><span>${hj("fleetName")}</span><input id="hubCompanyFleetName" value=${form.label} maxlength="120" onInput=${e => setForm(f => ({ ...f, label: e.target.value }))} /></label>
79
+ <p class="note">${hj("firstUse")}</p><div class="field-row"><button class="btn btn-primary" type="submit" disabled=${busy || !form.address.trim() || !form.label.trim()}>${hj("start")}</button></div>
80
+ ${identityChanged ? html`<p class="note">${hj("repairLead")}</p><button class="btn btn-sm" type="button" disabled=${busy || !form.address.trim()} onClick=${repair}>${hj("repair")}</button>` : null}
81
+ </form>` : null}
82
+ ${view && (!waiting || view.handoffId === waiting) ? html`<div role="status"><strong>${hj(view.state === "saved" ? view.link === "online" ? "saved" : "joining" : view.state === "awaiting-sign-in" ? "awaiting" : view.state === "cancelled" ? "cancelled" : view.state === "held" || view.state === "ended" ? "held" : "joining")}</strong>
83
+ ${view.state === "saved" ? html`<p class="note">${hj(view.link === "online" ? "fleetDone" : "offline")}</p>` : view.reason && view.reason !== "cancelled" ? html`<p class="note">${joinError(view.reason)}</p>` : null}
84
+ ${view.issued && view.state !== "saved" ? html`<p class="note">${hj("issued")}</p>` : null}
85
+ <div class="field-row">${view.state === "awaiting-sign-in" ? html`<a class="btn btn-sm" href=${root + "/bridge?operationId=" + encodeURIComponent(view.operationId)} target="_blank" rel="noopener">${hj("start")}</a>` : null}${view.state === "held" && !["authority", "expired"].includes(view.reason) ? html`<button type="button" class="btn btn-sm" disabled=${busy} onClick=${() => action("resume")}>${hj("resume")}</button>` : null}
86
+ ${!["saved", "cancelled", "ended"].includes(view.state) ? html`<button type="button" class="btn btn-sm" disabled=${busy} onClick=${() => action("cancel")}>${hj("stop")}</button>` : null}
87
+ ${view.hubOrigin ? html`<a class="btn btn-sm" href=${view.hubOrigin + "/ui/hub"} target="_blank" rel="noopener noreferrer">${hj("inspect")}</a>` : null}</div>
88
+ </div>` : null}
89
+ </section>`;
90
+ }
@@ -1,3 +1,4 @@
1
+ import { CompanyJoinSettings } from "./settings-hub-company-join.js";
1
2
  // Pure lazy owner Settings while off. Hub clients/pairing UI load only after a saved on state and a member page mark.
2
3
  import { html, useEffect, useRef, useState } from "/assets/app-html.js";
3
4
  import { Skeleton, ErrorState } from "/assets/ui-states.js";
@@ -81,7 +82,7 @@ export function HubMembershipSettings() {
81
82
  finally { owner.current.busy = false; if (owner.current.mounted) setBusy(false); }
82
83
  };
83
84
  if (publicPage) return null;
84
- return html`<div class="form hub-membership-settings"><section class="card" id="hub-membership">
85
+ return html`<div class="form hub-membership-settings"><${CompanyJoinSettings} onSaved=${read} memberEnabled=${view?.enabled === true} /><section class="card" id="hub-membership">
85
86
  <h3>${copy("title")}</h3><p class="note">${copy("hint")}</p>
86
87
  ${!view && messageKey === "loading" ? html`<${Skeleton} variant="rows" lines=${2} label=${copy("loading")} />` : html`<label class="check"><input id="hubMemberEnabled" class="s-ui-toggle" type="checkbox" role="switch" checked=${view?.enabled === true}
87
88
  disabled=${!view || busy} onChange=${e => change(e.target.checked)} /><span>${copy("enabled")}</span></label>`}
@@ -0,0 +1,74 @@
1
+ // M-2682 part B: fleet Settings → Hub → "HTML previews on this Hub" (host owner, on a fleet that runs a Hub). The switch and
2
+ // port behind hub.web.preview_port, saved and confirmed like the retention card; the server checks the port against the
3
+ // Hub's own listeners, this fleet's ports and a free bind before it saves. The Hub reloads to apply it (the runtime's
4
+ // reload key includes this setting). Own lazy module with its own words, so an older tab's strings still work.
5
+ import { html, useEffect, useState } from "/assets/app-html.js";
6
+ import { Skeleton } from "/assets/ui-states.js";
7
+ import { register, t } from "/assets/app-i18n.js";
8
+ import { api, confirmedWrite } from "./settings-confirm.js";
9
+ register("hubPreview", {
10
+ en: {
11
+ title: "HTML previews on this Hub",
12
+ hint: "When this is on, an HTML page an agent sends in a Hub chat can open as a preview. The Hub serves previews on their own port, which people's browsers must be able to reach.",
13
+ on: "Allow HTML previews", port: "Preview port", portHint: "1–65535, not one of the Hub's or this fleet's own ports.",
14
+ save: "Save previews", saved: "Saved. The Hub reloads to apply it.",
15
+ invalid_port: "Use a whole number from 1 to 65535.",
16
+ port_conflict: "That port is already one of the Hub's or this fleet's own. Pick another.",
17
+ port_in_use: "Something on this computer is already using that port. Pick another.",
18
+ busy: "Another change to the Hub's settings is still finishing. Try again in a moment.",
19
+ failed: "Previews could not be saved. Reload and try again.",
20
+ unavailable: "Previews can be set here once this fleet runs its Hub.",
21
+ },
22
+ "zh-TW": {
23
+ title: "這個 Hub 的 HTML 預覽",
24
+ hint: "開啟後,Agent 在 Hub 對話中傳送的 HTML 頁面可以開成預覽。Hub 用另一個連接埠提供預覽,使用者的瀏覽器必須連得到這個連接埠。",
25
+ on: "允許 HTML 預覽", port: "預覽連接埠", portHint: "1 到 65535,不能是 Hub 或這個 Fleet 自己使用的連接埠。",
26
+ save: "儲存預覽設定", saved: "已儲存。Hub 會重新載入以套用。",
27
+ invalid_port: "請輸入 1 到 65535 的整數。",
28
+ port_conflict: "這個連接埠已經是 Hub 或這個 Fleet 自己在用的,請換一個。",
29
+ port_in_use: "這台電腦上已經有程式在使用這個連接埠,請換一個。",
30
+ busy: "Hub 設定的另一項變更還在完成中,請稍後再試。",
31
+ failed: "無法儲存預覽設定。請重新整理後再試。",
32
+ unavailable: "這個 Fleet 執行自己的 Hub 之後,才能在這裡設定預覽。",
33
+ },
34
+ });
35
+ const copy = (key) => t(`hubPreview.${key}`);
36
+ const REFUSALS = new Set(["invalid_port", "port_conflict", "port_in_use", "busy"]);
37
+ // #3451: a confirmed save answers through the pending change; the route's own refusal is its failed outcome's detail.
38
+ const refusalOf = (r) => /^apply_rejected: ([a-z_]+)$/.exec(r.confirmed?.outcome?.detail ?? "")?.[1] ?? r.body?.error;
39
+ const validPort = (v) => /^\d{1,5}$/.test(v) && Number(v) >= 1 && Number(v) <= 65535;
40
+
41
+ export function HubPreviewSettings() {
42
+ const [view, setView] = useState(null), [on, setOn] = useState(false), [port, setPort] = useState("");
43
+ const [busy, setBusy] = useState(false), [messageKey, setMessageKey] = useState("");
44
+ const show = (v) => { setView(v); setOn(v.enabled); setPort(v.port !== null ? String(v.port) : v.suggested !== null ? String(v.suggested) : ""); };
45
+ useEffect(() => {
46
+ let live = true;
47
+ api("/api/settings/hub/preview").then((r) => {
48
+ if (!live) return;
49
+ if (r.ok && r.body?.hosted) show(r.body); else setMessageKey("unavailable");
50
+ }, () => { if (live) setMessageKey("unavailable"); });
51
+ return () => { live = false; };
52
+ }, []);
53
+ const changed = view && (on !== view.enabled || (on && String(view.port ?? "") !== port));
54
+ const save = async (e) => {
55
+ e.preventDefault();
56
+ if (!view || busy || !changed || (on && !validPort(port))) return;
57
+ setBusy(true); setMessageKey("");
58
+ try {
59
+ const r = await confirmedWrite("/api/settings/hub/preview", { method: "PUT", label: copy("title"), body: on ? { enabled: true, port: Number(port) } : { enabled: false } });
60
+ if (r.ok && r.body?.ok) { show(r.body); setMessageKey("saved"); }
61
+ else { const why = refusalOf(r); setMessageKey(REFUSALS.has(why) ? why : "failed"); }
62
+ } catch { setMessageKey("failed"); } finally { setBusy(false); }
63
+ };
64
+ return html`<section class="card hub-preview-settings"><h3>${copy("title")}</h3>
65
+ <p class="note">${copy("hint")}</p>
66
+ ${!view && !messageKey ? html`<${Skeleton} variant="form" lines=${3} />` : null}
67
+ ${view ? html`<form class="form" onSubmit=${save}>
68
+ <label class="check"><input type="checkbox" class="s-ui-toggle" id="hubPreviewOn" checked=${on} disabled=${busy} onChange=${(e) => { setOn(e.target.checked); setMessageKey(""); }} /> ${copy("on")}</label>
69
+ ${on ? html`<label class="field">${copy("port")}<input id="hubPreviewPort" type="number" min="1" max="65535" step="1" inputmode="numeric" value=${port} disabled=${busy}
70
+ onInput=${(e) => { setPort(e.target.value); setMessageKey(""); }} /><small class="note">${copy("portHint")}</small></label>` : null}
71
+ <button class="btn" type="submit" disabled=${busy || !changed || (on && !validPort(port))}>${copy("save")}</button></form>` : null}
72
+ ${messageKey ? html`<p role="status" class=${REFUSALS.has(messageKey) || messageKey === "failed" ? "err" : "note"}>${copy(messageKey)}</p>` : null}
73
+ </section>`;
74
+ }